class BjcCov {
    coverage: {
        [key: string]: string | number;
    };
    constructor(covData: object) {
        const gcv = "__coverage__";
        let coverage = globalThis[gcv] || (globalThis[gcv] = {});
        if (!coverage[covData.path] && true) {
            coverage[covData.path] = covData;
        }
        this.coverage = coverage[covData.path];
    }
    instrumentFunction(func: number) {
        this.coverage.functions[func].count++;
        this.coverage.functions[func].regions[0].count++;
    }
    instrumentRegion(func: number, region: number) {
        this.coverage.functions[func].regions[region].count++;
    }
    instrumentReturn(func: number, retIdx: number) {
        this.coverage.functions[func].returnes[retIdx].count++;
    }
    instrumentBranch(func: number, branch: number, trueOrFalse: boolean) {
        if (trueOrFalse) {
            this.coverage.functions[func].branches[branch].trueCount++;
            for (let r of Object.values(this.coverage.functions[func].branches[branch].group)) {
                if (r !== branch) {
                    this.coverage.functions[func].branches[r as number].falseCount++;
                }
            }
            // no-op until attached
        }
        else {
            this.coverage.functions[func].branches[branch].falseCount++;
        }
    }
}
let bjccovms5u83jv = new BjcCov({ version: "bjc v1.0.0", versionCode: 10000, path: "tencentqianwebview/src/main/ets/TencentQianWebViewController.ets", hash: "6e810756e1977db982d0f470a76a368bd54016e150a8ee67d72155e59b68f963", lineCnt: 96, count: 0, projectPath: "", functions: { 0: { name: "anonymous_0", count: 0, regions: { 0: { startLoc: { line: 34, col: 23 }, endLoc: { line: 34, col: 36 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 0 }, 1: { name: "anonymous_1", count: 0, regions: { 0: { startLoc: { line: 34, col: 39 }, endLoc: { line: 34, col: 59 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 1 }, 2: { name: "anonymous_2", count: 0, regions: { 0: { startLoc: { line: 35, col: 20 }, endLoc: { line: 35, col: 30 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 2 }, 3: { name: "anonymous_3", count: 0, regions: { 0: { startLoc: { line: 35, col: 33 }, endLoc: { line: 37, col: 4 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 3 }, 4: { name: "anonymous_4", count: 0, regions: { 0: { startLoc: { line: 38, col: 20 }, endLoc: { line: 38, col: 30 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 4 }, 5: { name: "anonymous_5", count: 0, regions: { 0: { startLoc: { line: 38, col: 33 }, endLoc: { line: 40, col: 4 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 5 }, 6: { name: "TencentQianWebViewController.canGoBack", count: 0, regions: { 0: { startLoc: { line: 48, col: 3 }, endLoc: { line: 50, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 49, col: 5 }, endLoc: { line: 50, col: 4 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 6 }, 7: { name: "TencentQianWebViewController.goBack", count: 0, regions: { 0: { startLoc: { line: 53, col: 3 }, endLoc: { line: 55, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 54, col: 5 }, endLoc: { line: 55, col: 4 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 7 }, 8: { name: "TencentQianWebViewController.reload", count: 0, regions: { 0: { startLoc: { line: 58, col: 3 }, endLoc: { line: 60, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 59, col: 5 }, endLoc: { line: 60, col: 4 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 8 }, 9: { name: "TencentQianWebViewController.handleBack", count: 0, regions: { 0: { startLoc: { line: 68, col: 3 }, endLoc: { line: 74, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 69, col: 27 }, endLoc: { line: 72, col: 6 }, count: 0, ignored: 0 }, 2: { startLoc: { line: 73, col: 5 }, endLoc: { line: 74, col: 4 }, count: 0, ignored: 0 } }, branches: { 0: { startLoc: { line: 69, col: 9 }, endLoc: { line: 69, col: 25 }, trueCount: 0, falseCount: 0, group: {}, ignored: 0 } }, ignored: 0, index: 9 }, 10: { name: "TencentQianWebViewController.attachInternal", count: 0, regions: { 0: { startLoc: { line: 79, col: 3 }, endLoc: { line: 83, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 80, col: 5 }, endLoc: { line: 83, col: 4 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 10 }, 11: { name: "anonymous_6", count: 0, regions: { 0: { startLoc: { line: 79, col: 29 }, endLoc: { line: 79, col: 42 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 11 }, 12: { name: "anonymous_7", count: 0, regions: { 0: { startLoc: { line: 79, col: 52 }, endLoc: { line: 79, col: 62 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 12 }, 13: { name: "anonymous_8", count: 0, regions: { 0: { startLoc: { line: 79, col: 72 }, endLoc: { line: 79, col: 82 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 13 }, 14: { name: "TencentQianWebViewController.detachInternal", count: 0, regions: { 0: { startLoc: { line: 86, col: 3 }, endLoc: { line: 94, col: 4 }, count: 0, ignored: 0 }, 1: { startLoc: { line: 87, col: 5 }, endLoc: { line: 94, col: 4 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 14 }, 15: { name: "anonymous_9", count: 0, regions: { 0: { startLoc: { line: 87, col: 23 }, endLoc: { line: 87, col: 43 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 15 }, 16: { name: "anonymous_10", count: 0, regions: { 0: { startLoc: { line: 88, col: 20 }, endLoc: { line: 90, col: 6 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 16 }, 17: { name: "anonymous_11", count: 0, regions: { 0: { startLoc: { line: 91, col: 20 }, endLoc: { line: 93, col: 6 }, count: 0, ignored: 0 } }, branches: {}, ignored: 0, index: 17 } }, exeLine: { 0: 32, 1: 34, 2: 35, 3: 38, 4: 48, 5: 49, 6: 53, 7: 54, 8: 58, 9: 59, 10: 68, 11: 69, 12: 70, 13: 71, 14: 73, 15: 79, 16: 80, 17: 81, 18: 82, 19: 86, 20: 87, 21: 88, 22: 91 } });
/**
 * 嵌入模式 Web 控制器，供 `TencentQianWebViewComponent` 使用。
 *
 * 嵌入模式（Component）把顶栏 / 底栏等 UI 完全交给宿主自绘，但 ArkUI 中父组件无法直接
 * 调用子组件的命令式方法。宿主通过创建本控制器并作为 `controller` 入参传给
 * `TencentQianWebViewComponent`，即可在自绘的返回按钮 / 重试按钮里主动操控内部 WebView
 * （历史后退、重新加载等）。对齐 ArkUI 官方 `WebviewController` / `TextAreaController` 的
 * 控制器对象模式。
 *
 * **生命周期**：组件 `aboutToAppear` 时把内部命令注入本控制器（`attachInternal`），
 * `aboutToDisappear` 时复位为 no-op（`detachInternal`）——组件销毁后宿主的误调用安全无副作用。
 *
 * **典型用法**：
 * ```ts
 * private webController = new TencentQianWebViewController();
 *
 * // 自绘顶栏返回按钮 / onBackPress
 * Text('<').onClick(() => {
 *   if (!this.webController.handleBack()) {
 *     router.back(); // H5 已在首屏，才真正退出
 *   }
 * });
 *
 * TencentQianWebViewComponent({
 *   url: this.url,
 *   context: this.context,
 *   controller: this.webController,
 *   onSignResult: this.handleSignResult
 * });
 * ```
 */
export class TencentQianWebViewController {
    // —— 内部命令（组件 attach 时注入，detach 时复位为 no-op）——
    private _canGoBack: () => boolean = (): boolean => { bjccovms5u83jv.instrumentFunction(1); return false; };
    private _goBack: () => void = (): void => {
        bjccovms5u83jv.instrumentFunction(3);
    };
    private _reload: () => void = (): void => {
        bjccovms5u83jv.instrumentFunction(5);
    };
    /**
     * 内部 WebView 是否可在 H5 历史栈内后退。
     *
     * 实时查询 `accessBackward()`，可覆盖整页导航与 SPA（`pushState`/`hashchange`）软路由两种
     * 历史深度，比 `OnTitleChanged` 回调里的整页快照更准确。组件未挂载时返回 false。
     */
    canGoBack(): boolean {
        bjccovms5u83jv.instrumentFunction(6);
        bjccovms5u83jv.instrumentRegion(6, 1);
        return this._canGoBack();
    }
    /** 在 H5 历史栈内后退一级。已在首屏（不可后退）时为 no-op。 */
    goBack(): void {
        bjccovms5u83jv.instrumentFunction(7);
        bjccovms5u83jv.instrumentRegion(7, 1);
        this._goBack();
    }
    /** 重新加载当前页。配合 `OnRenderUnrecoverable` 可实现「重试」按钮。 */
    reload(): void {
        bjccovms5u83jv.instrumentFunction(8);
        bjccovms5u83jv.instrumentRegion(8, 1);
        this._reload();
    }
    /**
     * 组合返回处理。可后退则退一级并返回 `true`（已消费）；否则返回 `false`
     * （宿主应自行关闭页面，如 `router.back()`）。语义与内置 Page 模式的返回处理一致。
     *
     * 宿主自绘顶栏返回按钮 / `onBackPress` 直接转发本方法即可。
     */
    handleBack(): boolean {
        bjccovms5u83jv.instrumentFunction(9);
        if (this.canGoBack()) {
            bjccovms5u83jv.instrumentBranch(9, 0, true);
            bjccovms5u83jv.instrumentRegion(9, 1);
            this.goBack();
            return true;
        }
        else {
            bjccovms5u83jv.instrumentBranch(9, 0, false);
        }
        bjccovms5u83jv.instrumentRegion(9, 2);
        return false;
    }
    // ─────────────── 以下为 internal，仅供 TencentQianWebViewComponent 调用 ───────────────
    /** 【internal】组件挂载时注入内部命令，请勿由业务方调用。 */
    attachInternal(canGoBack: () => boolean, goBack: () => void, reload: () => void): void {
        bjccovms5u83jv.instrumentFunction(10);
        bjccovms5u83jv.instrumentRegion(10, 1);
        this._canGoBack = canGoBack;
        this._goBack = goBack;
        this._reload = reload;
    }
    /** 【internal】组件销毁时复位为 no-op，防止野引用，请勿由业务方调用。 */
    detachInternal(): void {
        bjccovms5u83jv.instrumentFunction(14);
        bjccovms5u83jv.instrumentRegion(14, 1);
        this._canGoBack = (): boolean => { bjccovms5u83jv.instrumentFunction(15); return false; };
        this._goBack = (): void => {
            bjccovms5u83jv.instrumentFunction(16);
        };
        this._reload = (): void => {
            bjccovms5u83jv.instrumentFunction(17);
        };
    }
}
