// Stub for Debian packaging.
// Declares Trusted Types interfaces inline; the real @types/trusted-types
// package is not available in Debian.
//
// TrustedHTML/Script/ScriptURL are branded string subtypes so that
// 'string | TrustedHTML' is assignable to 'string' (TypeScript structural
// subtyping), matching what the real trusted-types package provides.

declare const _trustedHTMLBrand: unique symbol;
declare const _trustedScriptBrand: unique symbol;
declare const _trustedScriptURLBrand: unique symbol;

export type TrustedHTML = string & { readonly [_trustedHTMLBrand]: never };
export type TrustedScript = string & { readonly [_trustedScriptBrand]: never };
export type TrustedScriptURL = string & {
  readonly [_trustedScriptURLBrand]: never;
};

export interface TrustedTypePolicy {
  readonly name: string;
  createHTML(input: string, ...args: unknown[]): TrustedHTML;
  createScript(input: string, ...args: unknown[]): TrustedScript;
  createScriptURL(input: string, ...args: unknown[]): TrustedScriptURL;
}

export interface TrustedTypePolicyOptions {
  createHTML?: (input: string, ...args: unknown[]) => string;
  createScript?: (input: string, ...args: unknown[]) => string;
  createScriptURL?: (input: string, ...args: unknown[]) => string;
}

export interface TrustedTypePolicyFactory {
  createPolicy(
    policyName: string,
    policyOptions?: TrustedTypePolicyOptions
  ): TrustedTypePolicy;
  isHTML(value: unknown): value is TrustedHTML;
  isScript(value: unknown): value is TrustedScript;
  isScriptURL(value: unknown): value is TrustedScriptURL;
  readonly emptyScript: TrustedScript;
  readonly defaultPolicy: TrustedTypePolicy | null;
}

export interface TrustedTypesWindow {
  readonly trustedTypes: TrustedTypePolicyFactory;
}
