"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var overlay_exports = {}; __export(overlay_exports, { Overlay: () => Overlay }); module.exports = __toCommonJS(overlay_exports); var import_utils = require("../utils"); var import_page = require("./page"); class Overlay { constructor(page) { this._overlays = /* @__PURE__ */ new Map(); this._page = page; this._page.on(import_page.Page.Events.InternalFrameNavigatedToNewDocument, (frame) => { if (frame.parentFrame()) return; for (const [id, html] of this._overlays) this._doAdd(id, html).catch((e) => import_utils.debugLogger.log("error", e)); }); } dispose() { } async show(html, duration) { const id = (0, import_utils.createGuid)(); this._overlays.set(id, html); await this._doAdd(id, html).catch((e) => import_utils.debugLogger.log("error", e)); if (duration) { await new Promise((f) => setTimeout(f, duration)); await this.remove(id); } return id; } async _doAdd(id, html) { const utility = await this._page.mainFrame()._utilityContext(); await utility.evaluate(({ injected, html: html2, id: id2 }) => { return injected.addUserOverlay(id2, html2); }, { injected: await utility.injectedScript(), html, id }); } async remove(id) { this._overlays.delete(id); const utility = await this._page.mainFrame()._utilityContext(); await utility.evaluate(({ injected, id: id2 }) => { injected.removeUserOverlay(id2); }, { injected: await utility.injectedScript(), id }).catch((e) => import_utils.debugLogger.log("error", e)); } async chapter(options) { const fadeDuration = 300; const descriptionHtml = options.description ? `