@qaiddev/thumbs-embed 1.12.2 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -5
- package/dist/bootstrap.d.ts +29 -4
- package/dist/chunks/annotate-1zompTEi.js +2 -0
- package/dist/chunks/annotate-1zompTEi.js.map +1 -0
- package/dist/chunks/core-vu1EieDc.js +26 -0
- package/dist/chunks/core-vu1EieDc.js.map +1 -0
- package/dist/chunks/dom-kdwHduNo.js +2 -0
- package/dist/chunks/dom-kdwHduNo.js.map +1 -0
- package/dist/chunks/html2canvas.esm-Csbr1w14.js +6 -0
- package/dist/chunks/html2canvas.esm-Csbr1w14.js.map +1 -0
- package/dist/chunks/modal-5G2DhiUE.js +2 -0
- package/dist/chunks/modal-5G2DhiUE.js.map +1 -0
- package/dist/chunks/{recording-BUw5-5Rf.js → recording-CVwPTtB0.js} +2 -2
- package/dist/chunks/{recording-BUw5-5Rf.js.map → recording-CVwPTtB0.js.map} +1 -1
- package/dist/chunks/screenshot-dom-DO-0UlOz.js +2 -0
- package/dist/chunks/screenshot-dom-DO-0UlOz.js.map +1 -0
- package/dist/chunks/send-C3IvslZA.js +2 -0
- package/dist/chunks/send-C3IvslZA.js.map +1 -0
- package/dist/chunks/{targeting-CMUEe-7C.js → targeting-Bpbt68Pp.js} +2 -6
- package/dist/chunks/{targeting-CMUEe-7C.js.map → targeting-Bpbt68Pp.js.map} +1 -1
- package/dist/dom.d.ts +0 -2
- package/dist/embed-loader.d.ts +7 -0
- package/dist/embed.js +1 -1
- package/dist/embed.js.map +1 -1
- package/dist/icons.d.ts +2 -0
- package/dist/index.js +6628 -1530
- package/dist/index.js.map +1 -1
- package/dist/loader.js +1 -1
- package/dist/loader.js.map +1 -1
- package/dist/origin-key.d.ts +7 -0
- package/dist/qaid.umd.cjs +17 -17
- package/dist/qaid.umd.cjs.map +1 -1
- package/dist/quest-config.d.ts +27 -2
- package/dist/quest-launcher.d.ts +12 -0
- package/dist/screenshot-dom.d.ts +7 -5
- package/dist/svg-sanitize.d.ts +35 -0
- package/dist/trusted-types.d.ts +29 -0
- package/package.json +4 -2
- package/dist/chunks/annotate-DGyRcgPt.js +0 -2
- package/dist/chunks/annotate-DGyRcgPt.js.map +0 -1
- package/dist/chunks/core-BsR7oV99.js +0 -26
- package/dist/chunks/core-BsR7oV99.js.map +0 -1
- package/dist/chunks/dom-scpOS8nl.js +0 -2
- package/dist/chunks/dom-scpOS8nl.js.map +0 -1
- package/dist/chunks/modal-DYxcs1Gm.js +0 -2
- package/dist/chunks/modal-DYxcs1Gm.js.map +0 -1
- package/dist/chunks/screenshot-dom-ZYP2w2h0.js +0 -2
- package/dist/chunks/screenshot-dom-ZYP2w2h0.js.map +0 -1
- package/dist/chunks/send-C26DRoYc.js +0 -2
- package/dist/chunks/send-C26DRoYc.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-vu1EieDc.js","sources":["../../src/icons.ts","../../src/svg-sanitize.ts","../../src/styles.ts","../../src/a11y.ts","../../src/tooltip-positioning.ts","../../src/console-capture.ts","../../src/dom-utils.ts","../../src/quest-config.ts","../../src/embed.ts","../../src/origin-key.ts","../../src/bootstrap.ts","../../src/trusted-types.ts"],"sourcesContent":["/**\n * SVG icon strings for thumbs up/down buttons\n */\n\nexport const THUMBS_UP_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M14 10h4.764a2 2 0 011.789 2.894l-3.5 7A2 2 0 0115.263 21h-4.017c-.163 0-.326-.02-.485-.06L7 20m7-10V5a2 2 0 00-2-2h-.095c-.5 0-.905.405-.905.905 0 .714-.211 1.412-.608 2.006L7 11v9m7-10h-2M7 20H5a2 2 0 01-2-2v-6a2 2 0 012-2h2.5\"/>\n</svg>`;\n\nexport const THUMBS_DOWN_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M10 14H5.236a2 2 0 01-1.789-2.894l3.5-7A2 2 0 018.737 3h4.018a2 2 0 01.485.06l3.76.94m-7 10v5a2 2 0 002 2h.095c.5 0 .905-.405.905-.905 0-.714.211-1.412.608-2.006L17 13V4m-7 10h2m5-10h2a2 2 0 012 2v6a2 2 0 01-2 2h-2.5\"/>\n</svg>`;\n\nexport const RECORD_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M15.75 10.5l4.72-4.72a.75.75 0 011.28.53v11.38a.75.75 0 01-1.28.53l-4.72-4.72M4.5 18.75h9a2.25 2.25 0 002.25-2.25v-9a2.25 2.25 0 00-2.25-2.25h-9A2.25 2.25 0 002.25 7.5v9a2.25 2.25 0 002.25 2.25z\"/>\n</svg>`;\n\n/** Chat-bubble icon for the single, sentiment-free \"Feedback\" button. */\nexport const FEEDBACK_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M8 10h8M8 14h5m-9 6l3.5-3.5H18a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v14z\"/>\n</svg>`;\n\n/** The small X that hides the buttons. */\nexport const DISMISS_ICON = `<svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M2 2l8 8M10 2l-8 8\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"/></svg>`;\n\n/* ---------------------------------------------------------------------------\n * Screenshot annotation toolbar icons. Same 24×24 stroked style as the thumbs\n * icons above so they inherit `.qaid-icon` sizing and `currentColor`.\n * ------------------------------------------------------------------------- */\n\nexport const RECTANGLE_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <rect x=\"4\" y=\"6\" width=\"16\" height=\"12\" rx=\"1\" stroke-linejoin=\"round\"/>\n</svg>`;\n\nexport const ARROW_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M5 19L19 5m0 0h-8m8 0v8\"/>\n</svg>`;\n\nexport const PENCIL_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M12 20h9M16.5 3.5a2.121 2.121 0 013 3L7 19l-4 1 1-4L16.5 3.5z\"/>\n</svg>`;\n\nexport const BLUR_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M12 3s6 6.4 6 10a6 6 0 01-12 0c0-3.6 6-10 6-10z\"/>\n</svg>`;\n\nexport const UNDO_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 14L4 9l5-5M4 9h11a5 5 0 010 10h-4\"/>\n</svg>`;\n\nexport const DONE_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M20 6L9 17l-5-5\"/>\n</svg>`;\n\n/** Exclamation mark for the \"message not sent\" screen. */\nexport const ERROR_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M12 6v8m0 4h.01\"/>\n</svg>`;\n\nexport const SKIP_ICON =`<svg xmlns=\"http://www.w3.org/2000/svg\" class=\"qaid-icon\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M6 6l12 12M18 6L6 18\"/>\n</svg>`;\n","/**\n * SVG icon sanitizer.\n *\n * Icons (`positiveIcon`, `negativeIcon`, `feedbackIcon`, `recordIcon`) are\n * SVG strings the site owner supplies, and a theme can carry them from a\n * public gallery someone else wrote. They used to go straight into\n * `innerHTML`, so an icon could carry `<script>`, `onload=` or a\n * `javascript:` link into the partner's page.\n *\n * This module never hands markup to the browser's HTML parser. A small\n * tokenizer reads the string, keeps only the elements and attributes on the\n * allowlists below, and builds the result with `document.createElementNS`.\n * That also keeps the embed free of innerHTML sinks, so it runs on pages that\n * enforce Trusted Types. Anything that is not a well-formed `<svg>` root\n * comes back as `null`; `iconNode` then draws the built-in icon instead.\n */\n\nconst SVG_NS = \"http://www.w3.org/2000/svg\";\n\n/** Allowed elements, keyed by lower case so `lineargradient` maps back. */\nconst ELEMENTS: Record<string, string> = {};\nfor (const name of [\n \"svg\", \"g\", \"path\", \"circle\", \"ellipse\", \"rect\", \"line\", \"polyline\", \"polygon\",\n \"title\", \"desc\", \"defs\", \"linearGradient\", \"radialGradient\", \"stop\", \"clipPath\",\n]) {\n ELEMENTS[name.toLowerCase()] = name;\n}\n\n/** Allowed attributes (presentation, geometry, a11y), keyed by lower case. */\nconst ATTRIBUTES: Record<string, string> = {};\nfor (const name of [\n \"viewBox\", \"width\", \"height\", \"preserveAspectRatio\", \"version\",\n \"fill\", \"fill-rule\", \"fill-opacity\", \"stroke\", \"stroke-width\", \"stroke-linecap\",\n \"stroke-linejoin\", \"stroke-miterlimit\", \"stroke-dasharray\", \"stroke-dashoffset\",\n \"stroke-opacity\", \"clip-rule\", \"clip-path\", \"clipPathUnits\", \"opacity\",\n \"vector-effect\", \"shape-rendering\",\n \"d\", \"points\", \"x\", \"y\", \"x1\", \"y1\", \"x2\", \"y2\", \"cx\", \"cy\", \"r\", \"rx\", \"ry\", \"fx\", \"fy\",\n \"transform\", \"class\", \"id\", \"offset\", \"stop-color\", \"stop-opacity\",\n \"gradientUnits\", \"gradientTransform\", \"spreadMethod\",\n \"aria-hidden\", \"aria-label\", \"focusable\", \"role\",\n]) {\n ATTRIBUTES[name.toLowerCase()] = name;\n}\n\n/** Elements whose text is kept (an icon's accessible name). */\nconst TEXT_ELEMENTS = new Set([\"title\", \"desc\"]);\n\n/** Big enough for any real icon; bounds the work a hostile string can cause. */\nconst MAX_LENGTH = 50_000;\nconst MAX_ELEMENTS = 1_000;\n\nconst NAMED_ENTITIES: Record<string, string> = {\n lt: \"<\",\n gt: \">\",\n amp: \"&\",\n quot: '\"',\n apos: \"'\",\n nbsp: \" \",\n};\n\nfunction decodeEntities(value: string): string {\n return value.replace(/&(#x[0-9a-f]+|#\\d+|[a-z]+);/gi, (whole, body: string) => {\n if (body[0] === \"#\") {\n const code = body[1] === \"x\" || body[1] === \"X\"\n ? parseInt(body.slice(2), 16)\n : parseInt(body.slice(1), 10);\n return code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : \"\";\n }\n return NAMED_ENTITIES[body.toLowerCase()] ?? whole;\n });\n}\n\nconst LOCAL_URL = /url\\(\\s*(['\"]?)#[A-Za-z_][\\w.:-]*\\1\\s*\\)/gi;\n\n/**\n * Whether an attribute value is safe to keep. No script URLs anywhere, and a\n * `url(…)` only when it points at an id inside the icon (`url(#grad)`).\n * `clip-path` takes nothing but such a reference (or `none`).\n */\nexport function isSafeValue(attr: string, value: string): boolean {\n // Strip what browsers ignore inside URLs and CSS, so `java\\tscript:` and\n // `u\\nrl(` can't slip past the checks.\n // eslint-disable-next-line no-control-regex\n const squashed = value.replace(/[\\u0000- \\u007f-\\u009f]+/g, \"\").toLowerCase();\n if (/(java|vb)script:|data:|expression\\(/.test(squashed)) return false;\n const withoutLocal = value.replace(LOCAL_URL, \"\");\n // eslint-disable-next-line no-control-regex\n if (/url\\(/.test(withoutLocal.replace(/[\\u0000- \\u007f-\\u009f]+/g, \"\").toLowerCase())) {\n return false;\n }\n if (attr === \"clip-path\") {\n return /^\\s*none\\s*$/i.test(value) || new RegExp(`^\\\\s*${LOCAL_URL.source}\\\\s*$`, \"i\").test(value);\n }\n return true;\n}\n\ninterface Frame {\n name: string;\n /** null while inside an element that was dropped. */\n node: Element | null;\n}\n\n/**\n * Parse an SVG string into a detached, allowlisted `<svg>` element, or\n * `null` when the string is not one.\n */\nexport function sanitizeSvg(markup: unknown): SVGSVGElement | null {\n if (typeof markup !== \"string\" || typeof document === \"undefined\") return null;\n const src = markup.trim();\n if (!src || src.length > MAX_LENGTH) return null;\n\n let root: SVGSVGElement | null = null;\n let rootClosed = false;\n let count = 0;\n const stack: Frame[] = [];\n let i = 0;\n\n const top = (): Frame | undefined => stack[stack.length - 1];\n\n while (i < src.length) {\n if (rootClosed) break;\n const lt = src.indexOf(\"<\", i);\n const textEnd = lt === -1 ? src.length : lt;\n if (textEnd > i) {\n const text = src.slice(i, textEnd);\n const frame = top();\n if (frame?.node && TEXT_ELEMENTS.has(frame.name)) {\n frame.node.appendChild(document.createTextNode(decodeEntities(text)));\n } else if (!frame && text.trim()) {\n return null; // text outside the root\n }\n }\n if (lt === -1) break;\n i = lt;\n\n if (src.startsWith(\"<!--\", i)) {\n const end = src.indexOf(\"-->\", i + 4);\n if (end === -1) return null;\n i = end + 3;\n continue;\n }\n if (src.startsWith(\"<?\", i)) {\n // The XML prolog (`<?xml version=\"1.0\"?>`), only before the root.\n if (root) return null;\n const end = src.indexOf(\"?>\", i + 2);\n if (end === -1) return null;\n i = end + 2;\n continue;\n }\n if (src.startsWith(\"<!\", i)) {\n // DOCTYPE (and with it entity definitions) or CDATA: never in an icon.\n return null;\n }\n\n if (src[i + 1] === \"/\") {\n const m = /^<\\/\\s*([A-Za-z][\\w:.-]*)\\s*>/.exec(src.slice(i, i + 200));\n if (!m) return null;\n i += m[0].length;\n const name = m[1].toLowerCase();\n // Pop to the matching open element; a stray close tag is ignored.\n const at = stack.map((f) => f.name).lastIndexOf(name);\n if (at !== -1) {\n stack.length = at;\n if (at === 0) rootClosed = true;\n }\n continue;\n }\n\n // Start tag.\n const nameMatch = /^<([A-Za-z][\\w:.-]*)/.exec(src.slice(i, i + 200));\n if (!nameMatch) return null;\n const rawName = nameMatch[1];\n const lowerName = rawName.toLowerCase();\n i += nameMatch[0].length;\n\n const attrs: Array<[string, string]> = [];\n let selfClosing = false;\n let closed = false;\n while (i < src.length) {\n const ws = /^\\s*/.exec(src.slice(i, i + 1000))![0];\n i += ws.length;\n if (src.startsWith(\"/>\", i)) {\n selfClosing = true;\n closed = true;\n i += 2;\n break;\n }\n if (src[i] === \">\") {\n closed = true;\n i += 1;\n break;\n }\n const attrMatch = /^([^\\s=/>\"'<]+)/.exec(src.slice(i, i + 200));\n if (!attrMatch) return null;\n const attrName = attrMatch[1];\n i += attrName.length;\n let value = \"\";\n const eq = /^\\s*=\\s*/.exec(src.slice(i, i + 1000));\n if (eq) {\n i += eq[0].length;\n const quote = src[i];\n if (quote === '\"' || quote === \"'\") {\n const end = src.indexOf(quote, i + 1);\n if (end === -1) return null;\n value = src.slice(i + 1, end);\n i = end + 1;\n } else {\n const bare = /^[^\\s>]+/.exec(src.slice(i, i + MAX_LENGTH));\n if (!bare) return null;\n value = bare[0];\n if (value.endsWith(\"/\") && src[i + value.length] === \">\") value = value.slice(0, -1);\n i += value.length;\n }\n }\n attrs.push([attrName, decodeEntities(value)]);\n }\n if (!closed) return null;\n\n if (++count > MAX_ELEMENTS) return null;\n\n const parent = top();\n if (!parent) {\n if (root || lowerName !== \"svg\") return null;\n } else if (!parent.node) {\n if (!selfClosing) stack.push({ name: lowerName, node: null });\n continue;\n }\n\n const canonical = ELEMENTS[lowerName];\n if (!canonical) {\n // Not allowed: drop it and everything inside it.\n if (!selfClosing) stack.push({ name: lowerName, node: null });\n continue;\n }\n\n const el = document.createElementNS(SVG_NS, canonical);\n for (const [name, value] of attrs) {\n const attr = ATTRIBUTES[name.toLowerCase()];\n if (!attr) continue; // on*, href, xlink:*, style, xmlns, …\n if (!isSafeValue(attr, value)) continue;\n el.setAttribute(attr, value);\n }\n\n if (parent) {\n parent.node!.appendChild(el);\n } else {\n root = el as SVGSVGElement;\n }\n if (selfClosing) {\n if (!parent) rootClosed = true;\n } else {\n stack.push({ name: lowerName, node: el });\n }\n }\n\n return root;\n}\n\n/**\n * The icon to draw: the sanitized `markup`, or the built-in `fallback` when\n * `markup` is missing or not an SVG. The fallback is one of the embed's own\n * constants and always parses.\n */\nexport function iconNode(markup: string | null | undefined, fallback: string): SVGSVGElement {\n return (markup ? sanitizeSvg(markup) : null) ?? (sanitizeSvg(fallback) as SVGSVGElement);\n}\n\n/** Replace an element's content with an icon (see {@link iconNode}). */\nexport function setIcon(el: Element, markup: string | null | undefined, fallback: string): void {\n el.textContent = \"\";\n el.appendChild(iconNode(markup, fallback));\n}\n","/**\n * CSS styles for the feedback embed\n * Uses .qaid- prefix to avoid conflicts\n */\n\n// Import CSS as strings (vite handles minification in production)\nimport shadowStyles from \"./styles-shadow.css?inline\";\nimport lightStyles from \"./styles-light.css?inline\";\n\nlet instanceCount = 0;\n\n/** Default button styles included in shadow root */\nconst DEFAULT_BUTTON_STYLES = `button.qaid-btn{width:var(--qaid-btn-size);height:var(--qaid-btn-size);border-radius:50%;border:none;background:#f3f4f6;color:#374151;display:flex;align-items:center;justify-content:center;cursor:pointer;box-shadow:0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -1px rgba(0,0,0,.06);transition:background-color .2s,color .2s,transform .2s;-webkit-appearance:none;appearance:none;--qaid-hover-up-bg:var(--qaid-positive);--qaid-hover-up-color:#fff;--qaid-hover-down-bg:var(--qaid-negative);--qaid-hover-down-color:#fff}button.qaid-btn:hover{transform:scale(1.05)}button.qaid-btn-up:hover{background:var(--qaid-hover-up-bg);color:var(--qaid-hover-up-color)}button.qaid-btn-down:hover{background:var(--qaid-hover-down-bg);color:var(--qaid-hover-down-color)}button.qaid-btn-feedback:hover{background:var(--qaid-marker,#6365f1);color:var(--qaid-marker-text,#fff)}button.qaid-btn svg{width:var(--qaid-icon-size);height:var(--qaid-icon-size)}`;\n\nexport interface BuildCssVarsOptions {\n positiveColor?: string;\n negativeColor?: string;\n /** Color for selected element marker */\n markerColor?: string;\n /** Button size: small (36px), medium (48px), large (64px) */\n buttonSize?: \"small\" | \"medium\" | \"large\";\n /** Modal width in pixels */\n modalWidth?: number;\n /** Backdrop opacity (0-1) */\n backdropOpacity?: number;\n /** Font family */\n fontFamily?: string;\n /** Base font size in pixels */\n fontSize?: number;\n}\n\nconst BUTTON_SIZES = {\n small: 36,\n medium: 48,\n large: 64,\n} as const;\n\nconst ICON_SIZES = {\n small: 18,\n medium: 24,\n large: 32,\n} as const;\n\n/**\n * Calculate relative luminance of a color\n * Returns value between 0 (black) and 1 (white)\n */\nfunction getLuminance(r: number, g: number, b: number): number {\n const [rs, gs, bs] = [r, g, b].map((c) => {\n c = c / 255;\n return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);\n });\n return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;\n}\n\n/**\n * Parse a color string (hex or rgb) and return RGB values\n */\nfunction parseColor(color: string): { r: number; g: number; b: number } | null {\n // Hex format\n if (color.startsWith(\"#\")) {\n const hex = color.slice(1);\n const fullHex = hex.length === 3\n ? hex.split(\"\").map((c) => c + c).join(\"\")\n : hex;\n const num = parseInt(fullHex, 16);\n return {\n r: (num >> 16) & 255,\n g: (num >> 8) & 255,\n b: num & 255,\n };\n }\n // RGB format\n const match = color.match(/rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)/);\n if (match) {\n return {\n r: parseInt(match[1]),\n g: parseInt(match[2]),\n b: parseInt(match[3]),\n };\n }\n return null;\n}\n\n/**\n * Get the best contrasting text color (black or white) for a background\n */\nfunction getContrastTextColor(bgColor: string): string {\n const rgb = parseColor(bgColor);\n if (!rgb) return \"white\";\n const luminance = getLuminance(rgb.r, rgb.g, rgb.b);\n // Use white text on dark backgrounds, black on light\n return luminance > 0.4 ? \"black\" : \"white\";\n}\n\n/**\n * Build a map of CSS variable names to values for per-instance scoping\n */\nexport function buildCssVars(options: BuildCssVarsOptions = {}): Record<string, string> {\n const {\n positiveColor = \"rgb(0, 200, 83)\",\n negativeColor = \"rgb(255, 0, 0)\",\n markerColor = \"#6365f1\",\n buttonSize = \"medium\",\n modalWidth = 400,\n backdropOpacity = 0.3,\n fontFamily = \"system-ui, -apple-system, sans-serif\",\n fontSize = 16,\n } = options;\n\n const btnSize = BUTTON_SIZES[buttonSize];\n const iconSize = ICON_SIZES[buttonSize];\n const markerTextColor = getContrastTextColor(markerColor);\n\n return {\n \"--qaid-positive\": positiveColor,\n \"--qaid-negative\": negativeColor,\n \"--qaid-marker\": markerColor,\n \"--qaid-marker-text\": markerTextColor,\n \"--qaid-btn-size\": `${btnSize}px`,\n \"--qaid-icon-size\": `${iconSize}px`,\n \"--qaid-modal-width\": `${modalWidth}px`,\n \"--qaid-backdrop-opacity\": String(backdropOpacity),\n \"--qaid-font-family\": fontFamily,\n \"--qaid-font-size\": `${fontSize}px`,\n };\n}\n\n/**\n * Apply CSS variables to an element via inline style properties\n */\nexport function applyCssVars(el: HTMLElement, vars: Record<string, string>): void {\n for (const [name, value] of Object.entries(vars)) {\n el.style.setProperty(name, value);\n }\n}\n\n/**\n * Get the CSS string to inject into a shadow root\n * Includes base shadow styles + default button styles\n */\nexport function getEmbedStyles(): string {\n return shadowStyles + DEFAULT_BUTTON_STYLES;\n}\n\n/**\n * Inject light DOM styles (cursor override + highlight)\n * Reference-counted across instances\n */\nexport function injectStyles(): void {\n instanceCount++;\n if (instanceCount > 1) return;\n\n const style = document.createElement(\"style\");\n style.id = \"qaid-styles\";\n style.textContent = lightStyles;\n document.head.appendChild(style);\n}\n\n/**\n * Remove light DOM styles when last instance is destroyed\n */\nexport function removeStyles(): void {\n if (instanceCount <= 0) return;\n instanceCount--;\n if (instanceCount === 0) {\n // Optional: a client-side router (Astro's view transitions, any SPA that\n // swaps <head>) can remove this element out from under us, so by the time\n // a later destroy() runs there may be nothing to remove. Asserting it here\n // threw and took the rest of destroy() — and any re-mount after it — down.\n document.getElementById(\"qaid-styles\")?.remove();\n }\n}\n\n/** Reset internal state — for tests only */\nexport function _resetStylesState(): void {\n instanceCount = 0;\n const style = document.getElementById(\"qaid-styles\");\n if (style) {\n style.remove();\n }\n}\n","/**\n * Shared accessibility primitives for the qaid embeds: live-region\n * announcements. This is all the startup chunk needs. The dialog helpers\n * (focus trap, save/restore, dialog semantics, background isolation) live in\n * a11y-dialog.ts, which only the lazily-loaded click path pulls in.\n *\n * Framework-free and self-contained (no CSS dependency), so it can be dropped\n * into any open shadow root.\n */\n\n/** Host for the live regions: either a shadow root or a plain element. */\nexport type AnnounceRoot = ShadowRoot | HTMLElement;\n\n/** Options accepted by {@link announce}. */\nexport interface AnnounceOptions {\n /** Route the message through the assertive (role=\"alert\") region. */\n assertive?: boolean;\n}\n\nconst POLITE_ATTR = \"data-qaid-a11y-live\";\n\nconst VISUALLY_HIDDEN_CSS =\n \"position:absolute;width:1px;height:1px;margin:-1px;padding:0;\" +\n \"border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);\" +\n \"white-space:nowrap;\";\n\nfunction ownerDoc(root: AnnounceRoot): Document {\n return root.ownerDocument || document;\n}\n\nfunction getLiveRegion(root: AnnounceRoot, assertive: boolean): HTMLElement {\n const kind = assertive ? \"assertive\" : \"polite\";\n const existing = root.querySelector<HTMLElement>(\n `[${POLITE_ATTR}=\"${kind}\"]`\n );\n if (existing) return existing;\n\n const doc = ownerDoc(root);\n const region = doc.createElement(\"div\");\n region.setAttribute(POLITE_ATTR, kind);\n region.setAttribute(\"role\", assertive ? \"alert\" : \"status\");\n region.setAttribute(\"aria-live\", assertive ? \"assertive\" : \"polite\");\n region.setAttribute(\"aria-atomic\", \"true\");\n region.style.cssText = VISUALLY_HIDDEN_CSS;\n root.appendChild(region);\n return region;\n}\n\n/**\n * Announce a message to assistive technology via a visually-hidden live region\n * mounted inside `root`. The two regions (polite role=\"status\" and assertive\n * role=\"alert\") are created lazily on first use and reused thereafter.\n *\n * The target region is cleared before the new text is written so that repeated\n * identical messages are re-announced rather than coalesced.\n */\nexport function announce(\n root: AnnounceRoot,\n message: string,\n opts: AnnounceOptions = {}\n): void {\n const region = getLiveRegion(root, !!opts.assertive);\n // Clear-then-set so an identical repeat is still perceived as a change.\n region.textContent = \"\";\n region.textContent = message;\n}\n","/**\n * Tooltip positioning. Kept apart from modal-positioning so the startup chunk\n * carries only this, and the modal maths travels with the modal chunk.\n */\n\nexport interface TooltipPositionOptions {\n /** Gap in pixels between anchor and tooltip, and from viewport edges */\n gap?: number;\n}\n\n/**\n * Calculate tooltip position relative to an anchor, clamped to the viewport.\n * Pure function: no DOM access — caller passes measured rects and viewport size.\n *\n * Strategy:\n * - Place below the anchor by default\n * - Flip above if below would overflow vertically\n * - Clamp horizontally to viewport, then vertically to viewport\n */\nexport function calculateTooltipPosition(\n anchor: { top: number; bottom: number; left: number },\n tooltip: { width: number; height: number },\n viewport: { width: number; height: number },\n options: TooltipPositionOptions = {}\n): { top: number; left: number } {\n const gap = options.gap ?? 8;\n\n let top = anchor.bottom + gap;\n\n // Flip above if below overflows\n if (top + tooltip.height > viewport.height - gap) {\n top = anchor.top - tooltip.height - gap;\n }\n\n // Clamp horizontally\n let left = anchor.left;\n if (left < gap) {\n left = gap;\n } else if (left + tooltip.width > viewport.width - gap) {\n left = viewport.width - tooltip.width - gap;\n }\n\n // Clamp vertically\n if (top < gap) {\n top = gap;\n } else if (top + tooltip.height > viewport.height - gap) {\n top = viewport.height - tooltip.height - gap;\n }\n\n return { top, left };\n}\n","/**\n * Console capture utilities\n */\n\nimport type { ConsoleError } from \"./types\";\n\nconst MAX_MESSAGES = 20;\n\nexport interface ConsoleCapture {\n errors: ConsoleError[];\n restore: () => void;\n}\n\ntype ConsoleLevel = \"error\" | \"warn\" | \"log\";\n\n/**\n * Wrap console methods to capture messages\n */\nexport function captureConsoleErrors(\n onError?: (error: ConsoleError) => void\n): ConsoleCapture {\n const errors: ConsoleError[] = [];\n const originalError = console.error;\n const originalWarn = console.warn;\n const originalLog = console.log;\n\n const capture = (level: ConsoleLevel, args: unknown[]) => {\n const error: ConsoleError = {\n message: args.map((arg) => String(arg)).join(\" \"),\n timestamp: Date.now(),\n level,\n };\n\n // Keep max messages\n if (errors.length >= MAX_MESSAGES) {\n errors.shift();\n }\n errors.push(error);\n\n // Call callback if provided\n if (onError) {\n onError(error);\n }\n };\n\n console.error = function (...args: unknown[]) {\n capture(\"error\", args);\n originalError.apply(console, args);\n };\n\n console.warn = function (...args: unknown[]) {\n capture(\"warn\", args);\n originalWarn.apply(console, args);\n };\n\n console.log = function (...args: unknown[]) {\n capture(\"log\", args);\n originalLog.apply(console, args);\n };\n\n return {\n errors,\n restore: () => {\n console.error = originalError;\n console.warn = originalWarn;\n console.log = originalLog;\n },\n };\n}\n\n/**\n * Add an error to the captured errors array\n */\nexport function addError(errors: ConsoleError[], error: ConsoleError): void {\n if (errors.length >= MAX_MESSAGES) {\n errors.shift();\n }\n errors.push(error);\n}\n\n/**\n * Format console error for display\n */\nexport function formatError(error: ConsoleError): string {\n const date = new Date(error.timestamp);\n const time = date.toLocaleTimeString();\n const levelPrefix = error.level === \"error\" ? \"ERR\" : error.level === \"warn\" ? \"WRN\" : \"LOG\";\n return `[${time}] [${levelPrefix}] ${error.message}`;\n}\n","/**\n * DOM utility functions\n */\n\n/**\n * Create an element with attributes and optional children\n */\nexport function createElement<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n attrs?: Record<string, string>,\n children?: (Node | string)[]\n): HTMLElementTagNameMap[K] {\n const el = document.createElement(tag);\n\n if (attrs) {\n for (const [key, value] of Object.entries(attrs)) {\n if (key === \"className\") {\n el.className = value;\n } else {\n el.setAttribute(key, value);\n }\n }\n }\n\n if (children) {\n for (const child of children) {\n if (typeof child === \"string\") {\n el.appendChild(document.createTextNode(child));\n } else {\n el.appendChild(child);\n }\n }\n }\n\n return el;\n}\n\n/**\n * Check if viewport width indicates mobile device\n */\nexport function isMobileViewport(breakpoint = 640): boolean {\n return typeof window !== \"undefined\" && window.innerWidth < breakpoint;\n}\n\n/**\n * Get element at point, temporarily hiding shadow hosts so elementFromPoint\n * sees through to the page elements underneath.\n * Uses visibility:hidden which skips the element in elementFromPoint without\n * triggering reflow.\n */\nexport function getElementAtPointUnderOverlay(\n x: number,\n y: number,\n hosts: HTMLElement[]\n): Element | null {\n const saved = hosts.map((h) => h.style.visibility);\n hosts.forEach((h) => (h.style.visibility = \"hidden\"));\n const element = document.elementFromPoint(x, y);\n hosts.forEach((h, i) => (h.style.visibility = saved[i]));\n return element;\n}\n\n/**\n * Check if an element is part of the feedback embed\n * With shadow DOM, embed elements are inside shadow hosts marked with\n * data-qaid-embed or data-qaid-embed-overlay\n */\nexport function isEmbedElement(element: Element | null): boolean {\n if (!element) return false;\n // Check if the element itself is a shadow host\n if (element.hasAttribute(\"data-qaid-embed\") || element.hasAttribute(\"data-qaid-embed-overlay\")) return true;\n // Check ancestors for shadow host\n return !!element.closest(\"[data-qaid-embed], [data-qaid-embed-overlay]\");\n}\n\n/**\n * Get element bounds with optional padding\n */\nexport function getElementBounds(\n element: Element,\n padding = 0\n): { x: number; y: number; width: number; height: number } {\n const rect = element.getBoundingClientRect();\n return {\n x: rect.left - padding,\n y: rect.top - padding,\n width: rect.width + padding * 2,\n height: rect.height + padding * 2,\n };\n}\n\n/**\n * Remove all elements with a specific class\n */\nexport function removeAllByClass(className: string): void {\n document.querySelectorAll(`.${className}`).forEach((el) => {\n el.classList.remove(className);\n });\n}\n","/**\n * Where the quests module comes from.\n *\n * The default is one exact release on unpkg, never a floating `@1`: a\n * floating tag would run whatever is published next on every partner page.\n * Its sha384 is checked before the module runs (see quest-launcher.ts), so a\n * changed file on the CDN refuses to load instead of running.\n */\n\n/** The quests-embed release this thumbs-embed release opens quests with. */\nexport const QUESTS_VERSION = \"1.11.0\";\n\n/** Default ES-module URL for the quests embed: one exact release on unpkg. */\nexport const DEFAULT_QUESTS_MODULE_URL =\n `https://unpkg.com/@qaiddev/quests-embed@${QUESTS_VERSION}/dist/qaid-quests.js`;\n\n/**\n * Subresource Integrity of {@link DEFAULT_QUESTS_MODULE_URL}: the sha384 of\n * quests-embed's `dist/qaid-quests.js` at {@link QUESTS_VERSION}. Change the\n * two together.\n */\nexport const DEFAULT_QUESTS_MODULE_INTEGRITY =\n \"sha384-w5xVbyvdrJUM+he0J0AFPtdzfem3CLSbVKUydXWcMAP28z2anhQmlNgWGulyY7kl\";\n\nconst PINNED_UNPKG =\n /^https:\\/\\/unpkg\\.com\\/@qaiddev\\/quests-embed@\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?\\//;\n\nlet warned = false;\n\n/**\n * The module URL to use for a configured `moduleUrl`. A custom URL is kept\n * only when it is same-origin with the page (self-hosting) or one exact\n * quests-embed release on unpkg over https. Anything else, a floating\n * version or another host, is refused with one warning and the default used.\n */\nexport function resolveQuestsModuleUrl(moduleUrl: string | null | undefined): string {\n if (!moduleUrl) return DEFAULT_QUESTS_MODULE_URL;\n if (moduleUrl === DEFAULT_QUESTS_MODULE_URL) return moduleUrl;\n try {\n const page = typeof location !== \"undefined\" ? location.href : undefined;\n // Judge the URL the browser will actually fetch: resolving first turns\n // `…@1.11.0/../../other-pkg/x.js` (or its %2e%2e spelling) into\n // `https://unpkg.com/other-pkg/x.js`, which the pin must refuse.\n const url = new URL(moduleUrl, page);\n if (PINNED_UNPKG.test(url.href) && !/%2e|%2f|%5c/i.test(url.pathname)) return url.href;\n if (\n page &&\n url.origin === new URL(page).origin &&\n (url.protocol === \"https:\" || url.protocol === \"http:\")\n ) {\n return url.href;\n }\n } catch {\n /* not a URL: refused below */\n }\n if (!warned) {\n warned = true;\n console.warn(\n `[thumbs-embed] Ignoring quests moduleUrl \"${moduleUrl}\": use a same-origin URL or ` +\n `https://unpkg.com/@qaiddev/quests-embed@<exact version>/…. Using ${DEFAULT_QUESTS_MODULE_URL}.`\n );\n }\n return DEFAULT_QUESTS_MODULE_URL;\n}\n\n/** @internal Test seam: let the next refusal warn again. */\nexport function _resetQuestsModuleWarning(): void {\n warned = false;\n}\n","import type {\n FeedbackConfig,\n ResolvedFeedbackConfig,\n FeedbackData,\n FeedbackType,\n SelectedBounds,\n EmbedState,\n} from \"./types\";\nimport { THUMBS_UP_ICON, THUMBS_DOWN_ICON, RECORD_ICON, FEEDBACK_ICON, DISMISS_ICON } from \"./icons\";\nimport { setIcon } from \"./svg-sanitize\";\nimport { injectStyles, removeStyles, buildCssVars, applyCssVars, getEmbedStyles } from \"./styles\";\n// The element-targeting subsystem (with element-selector, ~14 KB) lives in a\n// lazily-loaded chunk (targeting.ts), pulled in the first time the user targets.\nimport type { TargetingController, TargetingHost } from \"./targeting\";\n// Only live-region announcements are needed at startup. The dialog helpers\n// (focus trap, inert background) load with the click path (a11y-dialog.ts).\nimport { announce } from \"./a11y\";\nimport type { DialogOptions } from \"./a11y-dialog\";\nimport { calculateTooltipPosition } from \"./tooltip-positioning\";\nimport type { ModalController, ModalHost } from \"./modal\";\nimport { captureConsoleErrors, type ConsoleCapture } from \"./console-capture\";\n// The whole video-recording subsystem lives in a lazily-loaded chunk\n// (recording.ts), pulled in the first time the record button is used. Only the\n// types are imported eagerly (erased at build time).\nimport type { RecordingController, RecordingHost } from \"./recording\";\nimport { isMobileViewport } from \"./dom-utils\";\n// The send flow (screenshot, markup, POST, quest or message box) is its own\n// lazily-loaded chunk (send.ts), as is the quests loader it uses; both are\n// pre-warmed before the click (see prewarmClickPath / prewarmQuests).\nimport type { SendHost } from \"./send\";\nimport type { QuestInstance } from \"./quest-launcher\";\nimport { resolveQuestsModuleUrl } from \"./quest-config\";\n\nconst VISITOR_ID_KEY = \"qaid_visitor_id\";\nconst HIDE_FEEDBACK_KEY = \"qaid_hide_feedback\";\n/** Default annotation swatches: red, amber, green, blue, near-black, white. */\nconst DEFAULT_ANNOTATION_PALETTE = [\n \"#ef4444\",\n \"#f59e0b\",\n \"#22c55e\",\n \"#3b82f6\",\n \"#111827\",\n \"#ffffff\",\n];\n\n// True when the primary pointer is touch (phone/tablet). On these devices the\n// Screen Capture API (getDisplayMedia) shows an intrusive \"start capturing\"\n// system prompt, dims the screen, and on iOS returns a rotated frame — so the\n// permission-free DOM/canvas screenshot is the right default there.\nfunction isTouchPrimaryDevice(): boolean {\n return (\n typeof window.matchMedia === \"function\" &&\n window.matchMedia(\"(pointer: coarse)\").matches\n );\n}\n\nfunction getHideKey(apiKey?: string): string {\n return apiKey ? `${HIDE_FEEDBACK_KEY}_${apiKey}` : HIDE_FEEDBACK_KEY;\n}\n\nexport function isHiddenByUser(apiKey?: string): boolean {\n try {\n return localStorage.getItem(getHideKey(apiKey)) === \"1\";\n } catch {\n return false;\n }\n}\n\nexport function setHiddenByUser(apiKey?: string, hidden = true): void {\n try {\n if (hidden) {\n localStorage.setItem(getHideKey(apiKey), \"1\");\n } else {\n localStorage.removeItem(getHideKey(apiKey));\n }\n } catch {\n // localStorage not available\n }\n}\n\n/**\n * A random v4 UUID.\n *\n * `crypto.randomUUID` exists only in secure contexts (HTTPS and localhost). On\n * a plain http:// page it is undefined, and calling it threw inside the\n * constructor, so the widget never appeared. `crypto.getRandomValues` has no\n * such restriction; `Math.random` covers a runtime with no `crypto` at all.\n * The id only groups one browser's feedback, so it needs to be unique, not\n * secret.\n */\nexport function randomId(): string {\n const c = typeof crypto !== \"undefined\" ? crypto : undefined;\n if (c && typeof c.randomUUID === \"function\") return c.randomUUID();\n\n const bytes = new Uint8Array(16);\n if (c && typeof c.getRandomValues === \"function\") {\n c.getRandomValues(bytes);\n } else {\n for (let i = 0; i < bytes.length; i++) bytes[i] = Math.floor(Math.random() * 256);\n }\n // RFC 4122 version 4 / variant 1 bits, so the result reads as a real UUID.\n bytes[6] = (bytes[6] & 0x0f) | 0x40;\n bytes[8] = (bytes[8] & 0x3f) | 0x80;\n const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, \"0\")).join(\"\");\n return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;\n}\n\n/**\n * Get or create a visitor ID stored in localStorage\n */\nexport function getOrCreateVisitorId(): string {\n try {\n let visitorId = localStorage.getItem(VISITOR_ID_KEY);\n if (!visitorId) {\n visitorId = randomId();\n localStorage.setItem(VISITOR_ID_KEY, visitorId);\n }\n return visitorId;\n } catch {\n // localStorage not available, generate a session-only ID\n return randomId();\n }\n}\n\n/**\n * QaidFeedback - Standalone feedback collection embed\n */\n\n/**\n * Put a feature's <style> after the base styles and any earlier feature's,\n * but before the theme's, so a theme still overrides the feature defaults.\n */\nfunction insertFeatureStyle(root: ShadowRoot, css: string): void {\n const style = document.createElement(\"style\");\n style.setAttribute(\"data-qaid-feature\", \"\");\n style.textContent = css;\n const marks = root.querySelectorAll(\"style[data-qaid-base], style[data-qaid-feature]\");\n const after = marks[marks.length - 1];\n root.insertBefore(style, after ? after.nextSibling : root.firstChild);\n}\n\nexport class QaidFeedback {\n private config: ResolvedFeedbackConfig;\n private state: EmbedState = \"IDLE\";\n private feedbackData: FeedbackData = {\n feedbackType: null,\n elementSelector: null,\n elementText: null,\n consoleErrors: [],\n };\n private selectedBounds: SelectedBounds = {\n x: 0,\n y: 0,\n width: 0,\n height: 0,\n clickX: 0,\n clickY: 0,\n visible: false,\n };\n /**\n * This feedback's record id, once its POST answers (null if it failed).\n * The message box and a linked quest open without waiting for it; the\n * PATCHes that need the id wait on this instead.\n */\n private feedbackIdPromise: Promise<number | null> = Promise.resolve(null);\n private questsPrewarmed = false;\n // A quest launched from a button (in place of the message box), if any.\n private activeQuest: QuestInstance | null = null;\n private isMobile = false;\n private visitorId: string;\n\n // Console capture\n private consoleCapture: ConsoleCapture | null = null;\n\n // Video recording — the whole subsystem lives in a lazily-loaded chunk\n // (recording.ts); a thumbs-only visitor never downloads it.\n private recording: RecordingController | null = null;\n // Element targeting — also a lazily-loaded chunk (targeting.ts).\n private targeting: TargetingController | null = null;\n // Preload-on-intent: warm the lazily-split feature chunks before first use.\n // The click path (send, message box, targeting) warms when the pointer or\n // focus reaches the buttons, or on idle, whichever comes first.\n private clickPathPrewarmed = false;\n private prewarmHandle: number | null = null;\n private prewarmIsTimeout = false;\n private videoPrewarmed = false;\n private screenshotPrewarmed = false;\n\n // Shadow DOM\n private shadowHost: HTMLDivElement | null = null;\n private shadowRoot: ShadowRoot | null = null;\n\n // Overlay shadow DOM (always on document.body for full-page coverage)\n private overlayShadowHost: HTMLDivElement | null = null;\n private overlayShadowRoot: ShadowRoot | null = null;\n\n // DOM elements (inside shadow root)\n private buttonsContainer: HTMLDivElement | null = null;\n private isUserProvidedContainer = false;\n // The message modal lives in a lazily-loaded chunk (modal.ts).\n private modal: ModalController | null = null;\n private dismissBtn: HTMLButtonElement | null = null;\n\n // Per-instance CSS variables\n private cssVars: Record<string, string> = {};\n\n private activeThumbBtn: HTMLElement | null = null;\n // Tracks whether the pending activation came from the keyboard (Enter/Space)\n // rather than a pointer, so targeting can avoid elementFromPoint(0,0).\n private keyboardActivation = false;\n\n // Accessibility: dialog focus management. The helpers load with the click\n // path; `dialogClose` undoes the open dialog (trap, inert, focus).\n private dialogModule: typeof import(\"./a11y-dialog\") | null = null;\n private dialogClose: (() => void) | null = null;\n\n // Unique id suffix for aria-labelledby/describedby references\n private readonly uid = Math.random().toString(36).slice(2, 9);\n\n // Bound event handlers\n private boundKeyDown: (e: KeyboardEvent) => void;\n private boundResize: () => void;\n\n // Start with buttons slid off-screen (localStorage dismiss, no animation)\n private _startDismissed = false;\n\n // DOM persistence (survives framework client-side navigation)\n private destroyed = false;\n private domObserver: MutationObserver | null = null;\n private boundBeforeSwap: ((e: Event) => void) | null = null;\n\n constructor(config: FeedbackConfig) {\n this.config = {\n endpoint: config.endpoint,\n apiKey: config.apiKey ?? \"\",\n container: config.container ?? \"\",\n buttonClass: config.buttonClass ?? \"\",\n direction: config.direction ?? \"horizontal\",\n position: config.position ?? \"bottom-right\",\n offset: {\n x: config.offset?.x ?? 16,\n y: config.offset?.y ?? 16,\n },\n zIndex: config.zIndex ?? 50,\n skipTargeting: config.skipTargeting ?? false,\n singleButton: config.singleButton ?? false,\n feedbackMode: config.feedbackMode ?? \"target\",\n colors: {\n positive: config.colors?.positive ?? \"rgb(0, 200, 83)\",\n negative: config.colors?.negative ?? \"rgb(255, 0, 0)\",\n marker: config.colors?.marker ?? \"#6365f1\",\n },\n buttonSize: config.buttonSize ?? \"medium\",\n text: {\n tooltip: config.text?.tooltip ?? \"\",\n modalTitle: config.text?.modalTitle ?? \"Thank you for your feedback!\",\n modalSubtitle: config.text?.modalSubtitle ?? \"Would you like to add a message to help us understand your feedback better?\",\n placeholder: config.text?.placeholder ?? \"Optional: Tell us more about your experience...\",\n submitButton: config.text?.submitButton ?? \"Submit\",\n skipButton: config.text?.skipButton ?? \"Skip\",\n positiveLabel: config.text?.positiveLabel ?? \"Send positive feedback\",\n negativeLabel: config.text?.negativeLabel ?? \"Send negative feedback\",\n recordLabel: config.text?.recordLabel ?? \"Record a screen recording\",\n dismissLabel: config.text?.dismissLabel ?? \"Hide Feedback\",\n feedbackLabel: config.text?.feedbackLabel ?? \"Send feedback\",\n confirmationTitle: config.text?.confirmationTitle ?? \"Thank you!\",\n confirmationMessage:\n config.text?.confirmationMessage ?? \"Your feedback has been received.\",\n confirmationClose: config.text?.confirmationClose ?? \"Close\",\n errorTitle: config.text?.errorTitle ?? \"Message not sent\",\n errorMessage:\n config.text?.errorMessage ??\n \"Something went wrong, so we did not get your message. Please try again later.\",\n },\n hideConfirmation: config.hideConfirmation ?? false,\n modalWidth: config.modalWidth ?? 400,\n backdropOpacity: config.backdropOpacity ?? 0.3,\n fontFamily: config.fontFamily ?? \"system-ui, -apple-system, sans-serif\",\n fontSize: config.fontSize ?? 16,\n captureScreenshot: config.captureScreenshot ?? false,\n annotate: config.annotate ?? true,\n annotationColor: config.annotationColor ?? config.colors?.marker ?? \"#6365f1\",\n annotationPalette: config.annotationPalette ?? DEFAULT_ANNOTATION_PALETTE,\n screenshotMethod: config.screenshotMethod ?? \"permission\",\n screenshotOptions: {\n quality: config.screenshotOptions?.quality ?? 0.8,\n maxWidth: config.screenshotOptions?.maxWidth ?? 1280,\n maxHeight: config.screenshotOptions?.maxHeight ?? 800,\n },\n incognito: config.incognito ?? false,\n hideDismiss: config.hideDismiss ?? false,\n positiveIcon: config.positiveIcon ?? \"\",\n negativeIcon: config.negativeIcon ?? \"\",\n feedbackIcon: config.feedbackIcon ?? \"\",\n hideThumbs: config.hideThumbs ?? false,\n css: config.css ?? \"\",\n captureVideo: config.captureVideo ?? false,\n videoOptions: {\n maxDuration: config.videoOptions?.maxDuration ?? 15,\n redaction: config.videoOptions?.redaction ?? false,\n },\n recordIcon: config.recordIcon ?? \"\",\n quests: {\n base: config.quests?.base ?? \"\",\n up: config.quests?.up ?? \"\",\n down: config.quests?.down ?? \"\",\n video: config.quests?.video ?? \"\",\n // Quest service reuses the feedback API key unless overridden.\n apiKey: config.quests?.apiKey ?? config.apiKey ?? \"\",\n moduleUrl: resolveQuestsModuleUrl(config.quests?.moduleUrl),\n },\n };\n\n // Bind event handlers\n this.boundKeyDown = this.handleKeyDown.bind(this);\n this.boundResize = this.handleResize.bind(this);\n\n // Get or create visitor ID for anonymous feedback tracking\n this.visitorId = getOrCreateVisitorId();\n\n this.init();\n }\n\n private applyVars(el: HTMLElement): void {\n applyCssVars(el, this.cssVars);\n }\n\n /**\n * Announce a message via the shared visually-hidden live regions.\n * Prefer the overlay shadow root (which hosts every transient surface and\n * is never inerted by its own dialogs) so announcements are not suppressed\n * while a dialog aria-hides the main button host.\n */\n private announceMsg(message: string, assertive = false): void {\n const root = this.overlayShadowRoot ?? this.shadowRoot;\n if (root) announce(root, message, { assertive });\n }\n\n /** Load the dialog a11y helpers; every surface that opens a dialog awaits this first. */\n private async loadDialogA11y(): Promise<void> {\n this.dialogModule ??= await import(\"./a11y-dialog\");\n }\n\n /**\n * Turn a transient surface into an accessible modal dialog: save the\n * invoking control, apply dialog semantics, trap focus, and inert the\n * background. Paired with closeDialogA11y() on every close path. Callers\n * reach it only after loadDialogA11y() has resolved.\n */\n private openDialogA11y(container: HTMLElement, opts: DialogOptions): void {\n this.dialogClose = this.dialogModule!.openDialog(container, opts);\n }\n\n private closeDialogA11y(): void {\n const close = this.dialogClose;\n this.dialogClose = null;\n close?.();\n }\n\n private clearActiveThumb(): void {\n if (this.activeThumbBtn) {\n this.activeThumbBtn.setAttribute(\"aria-pressed\", \"false\");\n this.activeThumbBtn = null;\n }\n }\n\n private init(): void {\n // Inject shared light DOM styles (cursor + highlight, reference counted)\n injectStyles();\n\n // Build per-instance CSS variables\n this.cssVars = buildCssVars({\n positiveColor: this.config.colors.positive,\n negativeColor: this.config.colors.negative,\n markerColor: this.config.colors.marker,\n buttonSize: this.config.buttonSize,\n modalWidth: this.config.modalWidth,\n backdropOpacity: this.config.backdropOpacity,\n fontFamily: this.config.fontFamily,\n fontSize: this.config.fontSize,\n });\n\n // Restore dismiss preference from localStorage (skip if hideDismiss)\n if (!this.config.hideDismiss && isHiddenByUser(this.config.apiKey)) {\n this._startDismissed = true;\n }\n\n // Check mobile\n this.checkMobile();\n window.addEventListener(\"resize\", this.boundResize);\n\n // Create shadow host and embed\n this.createEmbed();\n\n // Capture console errors\n this.consoleCapture = captureConsoleErrors((_error) => {\n this.feedbackData.consoleErrors = this.consoleCapture?.errors ?? [];\n });\n this.feedbackData.consoleErrors = this.consoleCapture.errors;\n\n // Persist across client-side navigations (Astro View Transitions, etc.)\n this.observeDom();\n\n // Preload split feature chunks on idle when their config flags are set, so\n // the first screenshot / recording doesn't wait on a chunk fetch. Hovering\n // the record button also warms the video chunk (see createEmbed).\n // Linked quests are warmed the same way — the quests module and each\n // quest's definition — so a click opens the quest from memory.\n // The click path (send flow, message box, targeting) warms here too, if\n // the pointer or focus has not reached the buttons first.\n this.schedulePrewarm(() => {\n this.prewarmClickPath();\n if (this.config.captureVideo && this.videoSupported()) this.prewarmVideo();\n if (this.config.captureScreenshot) this.prewarmScreenshot();\n this.prewarmQuests();\n });\n }\n\n /**\n * Warm everything a thumb click needs: the send flow, the dialog helpers,\n * the message box, and targeting (unless it is skipped). Runs once, on the\n * first of: pointer or focus entering the buttons, or the idle callback.\n */\n private prewarmClickPath(): void {\n if (this.clickPathPrewarmed) return;\n this.clickPathPrewarmed = true;\n import(\"./send\").catch(() => {});\n import(\"./a11y-dialog\").catch(() => {});\n import(\"./modal\").catch(() => {});\n if (!this.skipsTargeting()) import(\"./targeting\").catch(() => {});\n }\n\n /** \"annotate\" mode and skipTargeting both go straight to the send flow. */\n private skipsTargeting(): boolean {\n return this.config.skipTargeting || this.config.feedbackMode === \"annotate\";\n }\n\n /**\n * Best-effort preload of a lazily-split feature chunk so its first use is\n * instant. Warming fetches + compiles (and defines) the module; the feature\n * modules have no load-time side effects, so this is safe. Errors are\n * swallowed — a failed preload just falls back to an on-demand load.\n */\n private prewarmVideo(): void {\n if (this.videoPrewarmed) return;\n this.videoPrewarmed = true;\n // Warm both the recording controller chunk and the capture chunk it pulls\n // in on start, so the first recording begins without waiting on either.\n import(\"./recording\").catch(() => {});\n import(\"./video-capture\").catch(() => {});\n }\n\n private prewarmScreenshot(): void {\n if (this.screenshotPrewarmed) return;\n this.screenshotPrewarmed = true;\n (this.shouldCaptureViaDom()\n ? import(\"./screenshot-dom\")\n : import(\"./screenshot\")\n ).catch(() => {});\n if (this.config.annotate) import(\"./annotate\").catch(() => {});\n }\n\n /** Quest ids linked to any button, when quest launching is on. */\n private linkedQuestIds(): string[] {\n const q = this.config.quests;\n return q.base ? [q.up, q.down, q.video].filter((id) => id) : [];\n }\n\n /**\n * Load the quests module and fetch every linked quest's definition, so a\n * click opens the quest with no network wait. Both are best-effort: a miss\n * just means the quest loads on click, as it always did.\n */\n private prewarmQuests(): void {\n if (this.questsPrewarmed) return;\n const ids = this.linkedQuestIds();\n if (ids.length === 0) return;\n this.questsPrewarmed = true;\n const { base, moduleUrl } = this.config.quests;\n import(\"./quest-launcher\")\n .then((q) => {\n q.loadQuestsModule(moduleUrl).catch(() => {});\n for (const id of ids) void q.prefetchQuestDefinition(q.questDefinitionUrl(base, id));\n })\n .catch(() => {});\n }\n\n /** Run fn when the main thread is idle; cancelled by destroy(). */\n private schedulePrewarm(fn: () => void): void {\n const w = window as unknown as {\n requestIdleCallback?: (cb: () => void, opts?: { timeout: number }) => number;\n };\n const guarded = (): void => {\n if (!this.destroyed) fn();\n };\n if (typeof w.requestIdleCallback === \"function\") {\n this.prewarmIsTimeout = false;\n this.prewarmHandle = w.requestIdleCallback(guarded, { timeout: 2000 });\n } else {\n this.prewarmIsTimeout = true;\n this.prewarmHandle = window.setTimeout(guarded, 1200);\n }\n }\n\n /**\n * Watch for the shadow hosts being removed from the DOM by framework\n * client-side navigation (e.g. Astro View Transitions swapping <body>\n * contents, or any SPA router that replaces DOM subtrees). If the host\n * is disconnected and destroy() wasn't called, re-append it.\n *\n * Also hooks into Astro's `astro:before-swap` when available, which\n * lets us carry elements into the new document before the swap happens\n * (avoids a flash of the widget disappearing and reappearing).\n */\n private observeDom(): void {\n // Astro View Transitions: carry hosts into the new document pre-swap\n this.boundBeforeSwap = (e: Event) => {\n const newDoc = (e as any).newDocument as Document | undefined;\n if (!newDoc || this.destroyed) return;\n if (this.shadowHost) newDoc.body.appendChild(this.shadowHost);\n if (this.overlayShadowHost) newDoc.body.appendChild(this.overlayShadowHost);\n };\n document.addEventListener(\"astro:before-swap\", this.boundBeforeSwap);\n\n // Generic fallback: MutationObserver to catch any framework removing our hosts\n this.domObserver = new MutationObserver(() => {\n if (this.destroyed) return;\n if (this.shadowHost && !this.shadowHost.isConnected) {\n document.body.appendChild(this.shadowHost);\n }\n if (this.overlayShadowHost && !this.overlayShadowHost.isConnected) {\n document.body.appendChild(this.overlayShadowHost);\n }\n });\n this.domObserver.observe(document.body, { childList: true });\n }\n\n private checkMobile(): void {\n this.isMobile = isMobileViewport();\n }\n\n private handleResize(): void {\n this.checkMobile();\n }\n\n private createEmbed(): void {\n // Create the shadow host element\n this.shadowHost = document.createElement(\"div\");\n this.shadowHost.setAttribute(\"data-qaid-embed\", \"\");\n this.shadowHost.style.position = \"static\";\n this.shadowHost.style.display = \"contents\";\n\n // Check if user provided a container selector\n let userContainer: HTMLElement | null = null;\n if (this.config.container) {\n userContainer = document.querySelector(this.config.container);\n }\n\n if (userContainer) {\n userContainer.appendChild(this.shadowHost);\n this.isUserProvidedContainer = true;\n // Container mode never needs a dismiss button\n this.config.hideDismiss = true;\n } else {\n // Set shadow host to fixed positioning for auto-created containers\n this.shadowHost.style.position = \"fixed\";\n this.shadowHost.style.display = \"block\";\n this.shadowHost.style.inset = \"0\";\n this.shadowHost.style.pointerEvents = \"none\";\n this.shadowHost.style.zIndex = String(this.config.zIndex);\n document.body.appendChild(this.shadowHost);\n }\n\n // Attach shadow root\n this.shadowRoot = this.shadowHost.attachShadow({ mode: \"open\" });\n\n // Inject base styles into shadow root\n const baseStyle = document.createElement(\"style\");\n baseStyle.setAttribute(\"data-qaid-base\", \"\");\n baseStyle.textContent = getEmbedStyles();\n this.shadowRoot.appendChild(baseStyle);\n\n // Inject theme CSS if provided\n if (this.config.css) {\n const themeStyle = document.createElement(\"style\");\n themeStyle.textContent = this.config.css;\n this.shadowRoot.appendChild(themeStyle);\n }\n\n // Create buttons container inside shadow root\n const dirClass = this.config.direction === \"vertical\" ? \"qaid-vertical\" : \"\";\n if (this.isUserProvidedContainer) {\n this.buttonsContainer = document.createElement(\"div\");\n this.buttonsContainer.className = `qaid-buttons qaid-${this.config.position} ${dirClass}`.trim();\n if (this.config.incognito) {\n this.buttonsContainer.classList.add(\"qaid-incognito\");\n }\n } else {\n this.buttonsContainer = document.createElement(\"div\");\n this.buttonsContainer.className = `qaid-buttons qaid-auto-container qaid-${this.config.position} ${dirClass}${this.config.incognito ? \" qaid-incognito\" : \"\"}`.trim();\n this.buttonsContainer.style.pointerEvents = \"auto\";\n // Apply custom offset\n const { x: offsetX, y: offsetY } = this.config.offset;\n if (this.config.position.includes(\"right\")) {\n this.buttonsContainer.style.right = `${offsetX}px`;\n } else {\n this.buttonsContainer.style.left = `${offsetX}px`;\n }\n if (this.config.position.includes(\"bottom\")) {\n this.buttonsContainer.style.bottom = `${offsetY}px`;\n } else {\n this.buttonsContainer.style.top = `${offsetY}px`;\n }\n }\n\n // Apply per-instance CSS variables to buttons container\n this.applyVars(this.buttonsContainer);\n this.shadowRoot.appendChild(this.buttonsContainer);\n\n // Track input modality so a keyboard-activated control (Enter/Space) can be\n // distinguished from a pointer click. A keyboard-fired synthetic click has\n // clientX/clientY===0, which would break elementFromPoint targeting.\n this.buttonsContainer.addEventListener(\"keydown\", (ev) => {\n if (ev.key === \"Enter\" || ev.key === \" \" || ev.key === \"Spacebar\") {\n this.keyboardActivation = true;\n }\n });\n this.buttonsContainer.addEventListener(\"mousedown\", () => {\n this.keyboardActivation = false;\n });\n this.buttonsContainer.addEventListener(\"pointerdown\", () => {\n this.keyboardActivation = false;\n });\n // The pointer or keyboard focus reaching the buttons is the moment before\n // a click: warm the click path now, unless idle got there first.\n const warmClickPath = (): void => this.prewarmClickPath();\n this.buttonsContainer.addEventListener(\"pointerenter\", warmClickPath);\n this.buttonsContainer.addEventListener(\"focusin\", warmClickPath);\n\n // Determine button classes\n const useCustomClass = !!this.config.buttonClass;\n const btnBaseClass = useCustomClass\n ? `qaid-btn-structural ${this.config.buttonClass}`\n : \"qaid-btn\";\n\n // Determine tooltip text\n const defaultTooltip = \"Feedback for us?\";\n const tooltipText = this.config.text.tooltip || defaultTooltip;\n\n // Create shared tooltip element (inside shadow root)\n const tooltip = document.createElement(\"div\");\n tooltip.className = \"qaid-tooltip-text\";\n tooltip.textContent = tooltipText;\n this.applyVars(tooltip);\n this.shadowRoot.appendChild(tooltip);\n this.tooltipElement = tooltip;\n\n // Single sentiment-free \"Feedback\" button, or the thumbs up/down pair.\n if (this.config.singleButton) {\n const fbWrapper = document.createElement(\"div\");\n fbWrapper.className = \"qaid-tooltip-wrapper\";\n\n const fbBtn = document.createElement(\"button\");\n fbBtn.type = \"button\";\n fbBtn.className = useCustomClass ? `${btnBaseClass} qaid-btn-feedback` : \"qaid-btn qaid-btn-feedback\";\n fbBtn.setAttribute(\"aria-label\", this.config.text.feedbackLabel);\n setIcon(fbBtn, this.config.feedbackIcon, FEEDBACK_ICON);\n fbBtn.addEventListener(\"click\", (e) => this.handleThumbClick(\"neutral\", e.currentTarget as HTMLElement, e));\n fbBtn.addEventListener(\"mouseenter\", () => this.showTooltip(fbBtn));\n fbBtn.addEventListener(\"mouseleave\", () => this.hideTooltip());\n fbWrapper.appendChild(fbBtn);\n\n this.buttonsContainer.appendChild(fbWrapper);\n } else if (!this.config.hideThumbs) {\n // Thumbs up button\n const upWrapper = document.createElement(\"div\");\n upWrapper.className = \"qaid-tooltip-wrapper\";\n\n const upBtn = document.createElement(\"button\");\n upBtn.type = \"button\";\n upBtn.className = useCustomClass ? `${btnBaseClass} qaid-btn-up` : \"qaid-btn qaid-btn-up\";\n upBtn.setAttribute(\"aria-label\", this.config.text.positiveLabel);\n setIcon(upBtn, this.config.positiveIcon, THUMBS_UP_ICON);\n upBtn.addEventListener(\"click\", (e) => this.handleThumbClick(\"up\", e.currentTarget as HTMLElement, e));\n upBtn.addEventListener(\"mouseenter\", () => {\n this.prewarmQuests();\n this.showTooltip(upBtn);\n });\n upBtn.addEventListener(\"mouseleave\", () => this.hideTooltip());\n upWrapper.appendChild(upBtn);\n\n // Thumbs down button\n const downWrapper = document.createElement(\"div\");\n downWrapper.className = \"qaid-tooltip-wrapper\";\n\n const downBtn = document.createElement(\"button\");\n downBtn.type = \"button\";\n downBtn.className = useCustomClass ? `${btnBaseClass} qaid-btn-down` : \"qaid-btn qaid-btn-down\";\n downBtn.setAttribute(\"aria-label\", this.config.text.negativeLabel);\n setIcon(downBtn, this.config.negativeIcon, THUMBS_DOWN_ICON);\n downBtn.addEventListener(\"click\", (e) => this.handleThumbClick(\"down\", e.currentTarget as HTMLElement, e));\n downBtn.addEventListener(\"mouseenter\", () => {\n this.prewarmQuests();\n this.showTooltip(downBtn);\n });\n downBtn.addEventListener(\"mouseleave\", () => this.hideTooltip());\n downWrapper.appendChild(downBtn);\n\n this.buttonsContainer.appendChild(upWrapper);\n this.buttonsContainer.appendChild(downWrapper);\n }\n\n // Record button (only when captureVideo is true and browser supports it)\n if (this.config.captureVideo && this.videoSupported()) {\n const recordWrapper = document.createElement(\"div\");\n recordWrapper.className = \"qaid-tooltip-wrapper\";\n\n const recordBtn = document.createElement(\"button\");\n recordBtn.type = \"button\";\n recordBtn.className = useCustomClass ? `${btnBaseClass} qaid-btn-record` : \"qaid-btn qaid-btn-record\";\n recordBtn.setAttribute(\"aria-label\", this.config.text.recordLabel);\n setIcon(recordBtn, this.config.recordIcon, RECORD_ICON);\n recordBtn.addEventListener(\"click\", () => {\n void this.ensureRecording().then((rec) =>\n this.config.videoOptions.redaction ? rec.startPicking() : rec.startRecording()\n );\n });\n // Warm the video chunk on hover/focus/touch — the ~200ms before a click —\n // so recording starts without waiting on the chunk fetch.\n const warmVideo = (): void => this.prewarmVideo();\n recordBtn.addEventListener(\"mouseenter\", () => {\n warmVideo();\n this.showTooltip(recordBtn);\n });\n recordBtn.addEventListener(\"focus\", warmVideo);\n recordBtn.addEventListener(\"touchstart\", warmVideo, { passive: true });\n recordBtn.addEventListener(\"mouseleave\", () => this.hideTooltip());\n recordWrapper.appendChild(recordBtn);\n\n this.buttonsContainer.appendChild(recordWrapper);\n }\n\n // Dismiss (X) button — only in body/fixed mode (hidden for container embeds)\n if (!this.config.hideDismiss) {\n this.dismissBtn = document.createElement(\"button\");\n this.dismissBtn.type = \"button\";\n this.dismissBtn.className = \"qaid-dismiss-btn\";\n this.dismissBtn.setAttribute(\"aria-label\", this.config.text.dismissLabel);\n this.dismissBtn.title = this.config.text.dismissLabel;\n setIcon(this.dismissBtn, null, DISMISS_ICON);\n this.dismissBtn.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n this.handleDismiss();\n });\n // Insert as first child so it sits to the left of thumb buttons\n this.buttonsContainer.insertBefore(this.dismissBtn, this.buttonsContainer.firstChild);\n\n // If previously dismissed via localStorage, start fully hidden so it\n // doesn't flash back on hover — matching the dismiss behavior.\n if (this._startDismissed) {\n this.buttonsContainer.classList.add(\"qaid-dismissed\");\n }\n }\n }\n\n /**\n * Lazily create a separate overlay shadow host on document.body.\n * This host contains all full-page elements (targeting overlay, marker,\n * backdrop, modal, recording indicator, video preview) so they escape\n * clip-path / transform containing blocks in user containers.\n */\n private ensureOverlayHost(): ShadowRoot {\n if (this.overlayShadowRoot) return this.overlayShadowRoot;\n\n this.overlayShadowHost = document.createElement(\"div\");\n this.overlayShadowHost.setAttribute(\"data-qaid-embed-overlay\", \"\");\n this.overlayShadowHost.style.position = \"fixed\";\n this.overlayShadowHost.style.inset = \"0\";\n this.overlayShadowHost.style.pointerEvents = \"none\";\n this.overlayShadowHost.style.zIndex = String(this.config.zIndex);\n document.body.appendChild(this.overlayShadowHost);\n\n this.overlayShadowRoot = this.overlayShadowHost.attachShadow({ mode: \"open\" });\n\n // Inject base styles into overlay shadow root, plus the styles of any\n // feature that loaded before this root existed.\n const baseStyle = document.createElement(\"style\");\n baseStyle.setAttribute(\"data-qaid-base\", \"\");\n baseStyle.textContent = getEmbedStyles();\n this.overlayShadowRoot.appendChild(baseStyle);\n for (const css of this.featureStyles) insertFeatureStyle(this.overlayShadowRoot, css);\n\n // Inject theme CSS if provided\n if (this.config.css) {\n const themeStyle = document.createElement(\"style\");\n themeStyle.textContent = this.config.css;\n this.overlayShadowRoot.appendChild(themeStyle);\n }\n\n return this.overlayShadowRoot;\n }\n\n /** The styles of every feature chunk loaded so far, in load order. */\n private featureStyles: string[] = [];\n\n /**\n * Add a feature chunk's styles to both shadow roots. The core stylesheet\n * styles only the buttons; the message box, targeting, video and markup\n * editor bring their own CSS with their chunk, so a page that never opens\n * them never downloads it.\n */\n private addFeatureStyles(css: string): void {\n if (this.featureStyles.includes(css)) return;\n this.featureStyles.push(css);\n for (const root of [this.shadowRoot, this.overlayShadowRoot]) {\n if (root) insertFeatureStyle(root, css);\n }\n }\n\n private tooltipElement: HTMLElement | null = null;\n\n private showTooltip(anchor: HTMLElement): void {\n const tooltip = this.tooltipElement!;\n\n // Make visible to measure\n tooltip.style.visibility = \"hidden\";\n tooltip.classList.add(\"qaid-tooltip-visible\");\n\n const anchorRect = anchor.getBoundingClientRect();\n const tooltipRect = tooltip.getBoundingClientRect();\n const { top, left } = calculateTooltipPosition(\n anchorRect,\n tooltipRect,\n { width: window.innerWidth, height: window.innerHeight }\n );\n\n tooltip.style.top = `${top}px`;\n tooltip.style.left = `${left}px`;\n tooltip.style.visibility = \"visible\";\n }\n\n private hideTooltip(): void {\n this.tooltipElement!.classList.remove(\"qaid-tooltip-visible\");\n }\n\n private handleDismiss(): void {\n // Fully remove the widget. It does not linger as a hover-reveal ghost\n // (that's `qaid-incognito`); once dismissed it stays gone until the\n // visitor clears the stored preference.\n this.buttonsContainer!.classList.add(\"qaid-dismissed\");\n setHiddenByUser(this.config.apiKey, true);\n }\n\n private handleThumbClick(type: FeedbackType, buttonEl: HTMLElement, e: MouseEvent): void {\n // If user clicks a thumb while in incognito mode, they want it back.\n // (Dismissed widgets are `display:none`, so this can't fire for them.)\n if (this.buttonsContainer?.classList.contains(\"qaid-incognito\")) {\n this.buttonsContainer.classList.remove(\"qaid-incognito\");\n setHiddenByUser(this.config.apiKey, false);\n }\n // Usually warm already (pointer/focus on the buttons, or idle); a\n // programmatic click is the exception.\n this.prewarmClickPath();\n // \"annotate\" mode and skipTargeting both bypass element targeting and go\n // straight to the (screenshot →) modal flow.\n if (this.skipsTargeting()) {\n this.submitDirectFeedback(type, buttonEl);\n } else {\n // Expose targeting on/off state on the trigger\n this.activeThumbBtn = buttonEl;\n buttonEl.setAttribute(\"aria-pressed\", \"true\");\n // A keyboard-activated <button> fires a synthetic click whose clientX/\n // clientY are (0,0). Route those through the keyboard path instead of\n // elementFromPoint(0,0). `keyboardActivation` is set by a preceding\n // Enter/Space keydown and cleared by any pointerdown/mousedown.\n const keyboard = this.keyboardActivation;\n this.keyboardActivation = false;\n // Load the targeting chunk (pre-warmed before the click) then start it.\n void this.ensureTargeting().then((t) => {\n if (this.destroyed) return;\n if (keyboard) t.startKeyboard(type);\n else t.startPointer(type, e);\n });\n }\n }\n\n private submitDirectFeedback(type: FeedbackType, buttonEl: HTMLElement): void {\n this.feedbackData.feedbackType = type;\n this.feedbackData.elementSelector = null;\n this.feedbackData.elementText = null;\n\n // Use the button's position for modal placement\n const rect = buttonEl.getBoundingClientRect();\n this.selectedBounds = {\n x: rect.left,\n y: rect.top,\n width: rect.width,\n height: rect.height,\n clickX: rect.left + rect.width / 2,\n clickY: rect.top + rect.height / 2,\n visible: false,\n };\n void this.submitFeedback();\n }\n\n\n private handleKeyDown(e: KeyboardEvent): void {\n if (e.key === \"Escape\") {\n // The recording controller owns Escape while recording / in preview /\n // picking; let it consume the key first.\n if (this.recording?.handleEscape()) return;\n if (this.state === \"TARGETING\") {\n this.targeting?.cancel();\n } else if (this.state === \"MODAL_OPEN\") {\n this.modal?.close();\n }\n }\n }\n\n\n /** Whether to capture the screenshot with the DOM/canvas method (html2canvas)\n * instead of the permission-based Screen Capture API. Explicit \"dom\" wins;\n * otherwise DOM is used on touch devices to avoid the getDisplayMedia prompt. */\n private shouldCaptureViaDom(): boolean {\n return this.config.screenshotMethod === \"dom\" || isTouchPrimaryDevice();\n }\n\n /**\n * Run the send flow (send.ts, loaded on demand and pre-warmed before the\n * click): screenshot, markup, POST, then a linked quest or the message box.\n * If its chunk will not load, say so and reset rather than leave the\n * visitor stuck mid-flow.\n */\n private async submitFeedback(): Promise<void> {\n try {\n const [send] = await Promise.all([import(\"./send\"), this.loadDialogA11y()]);\n await send.submitFeedback(this.makeSendHost());\n } catch (err) {\n console.error(\"Failed to send feedback:\", err);\n this.announceMsg(\"Failed to send feedback\", true);\n this.resetFeedbackUi();\n }\n }\n\n /**\n * Launch the quest linked to `type` through the send chunk. Resolves false\n * when none is linked, or when the chunk or the quest will not load.\n */\n private async tryLaunchQuest(\n type: \"up\" | \"down\" | \"video\",\n feedbackId: number | string | null,\n ): Promise<boolean> {\n try {\n const send = await import(\"./send\");\n return await send.tryLaunchQuest(this.makeSendHost(), type, feedbackId);\n } catch (err) {\n console.error(\"Failed to launch quest:\", err);\n return false;\n }\n }\n\n /** Narrow view of the embed the send flow talks back through. */\n private makeSendHost(): SendHost {\n const self = this;\n return {\n get config() {\n return self.config;\n },\n get visitorId() {\n return self.visitorId;\n },\n get feedbackData() {\n return self.feedbackData;\n },\n get selectedBounds() {\n return self.selectedBounds;\n },\n get destroyed() {\n return self.destroyed;\n },\n get overlayShadowHost() {\n return self.overlayShadowHost;\n },\n get activeQuest() {\n return self.activeQuest;\n },\n set activeQuest(quest) {\n self.activeQuest = quest;\n },\n setState: (state) => {\n self.state = state;\n },\n setFeedbackId: (id) => {\n self.feedbackIdPromise = id;\n },\n shouldCaptureViaDom: () => self.shouldCaptureViaDom(),\n ensureOverlayHost: () => self.ensureOverlayHost(),\n ensureModal: () => self.ensureModal(),\n addFeatureStyles: (css) => self.addFeatureStyles(css),\n applyVars: (el) => self.applyVars(el),\n announceMsg: (message, assertive) => self.announceMsg(message, assertive),\n openDialogA11y: (container, opts) => self.openDialogA11y(container, opts),\n closeDialogA11y: () => self.closeDialogA11y(),\n resetFeedbackUi: () => self.resetFeedbackUi(),\n };\n }\n\n /**\n * Reset the thumbs targeting/marker UI back to idle without opening or\n * closing the message modal. Shared by closeModal() and the quest-launch\n * path (which bypasses the modal entirely).\n */\n private resetFeedbackUi(): void {\n this.targeting?.hideMarker();\n if (this.overlayShadowHost) {\n this.overlayShadowHost.style.pointerEvents = \"none\";\n }\n this.state = \"IDLE\";\n this.feedbackIdPromise = Promise.resolve(null);\n this.feedbackData.feedbackType = null;\n this.feedbackData.elementSelector = null;\n this.feedbackData.elementText = null;\n this.selectedBounds.visible = false;\n }\n\n\n /**\n * Lazily load and instantiate the modal controller. The message modal lives\n * in a separate chunk, fetched the first time it opens (and pre-warmed\n * before the click — see prewarmClickPath).\n */\n private async ensureModal(): Promise<ModalController> {\n if (!this.modal) {\n const [{ ModalController, styles }] = await Promise.all([\n import(\"./modal\"),\n this.loadDialogA11y(),\n ]);\n this.addFeatureStyles(styles);\n this.modal = new ModalController(this.makeModalHost());\n }\n return this.modal;\n }\n\n /** Narrow view of the embed the modal controller talks back through. */\n private makeModalHost(): ModalHost {\n const self = this;\n return {\n get config() {\n return self.config;\n },\n get uid() {\n return self.uid;\n },\n get isMobile() {\n return self.isMobile;\n },\n get state() {\n return self.state;\n },\n get boundKeyDown() {\n return self.boundKeyDown;\n },\n get feedbackData() {\n return self.feedbackData;\n },\n get selectedBounds() {\n return self.selectedBounds;\n },\n whenFeedbackId: () => self.feedbackIdPromise,\n ensureOverlayHost: () => self.ensureOverlayHost(),\n applyVars: (el) => self.applyVars(el),\n announceMsg: (message, assertive) => self.announceMsg(message, assertive),\n openDialogA11y: (container, opts) => self.openDialogA11y(container, opts),\n closeDialogA11y: () => self.closeDialogA11y(),\n resetFeedbackUi: () => self.resetFeedbackUi(),\n };\n }\n\n /**\n * Lazily load and instantiate the targeting controller. The subsystem (with\n * element-selector) lives in a separate chunk, fetched the first time the\n * user targets — pre-warmed before the click (see prewarmClickPath).\n */\n private async ensureTargeting(): Promise<TargetingController> {\n if (!this.targeting) {\n const { TargetingController, styles } = await import(\"./targeting\");\n this.addFeatureStyles(styles);\n this.targeting = new TargetingController(this.makeTargetingHost());\n }\n return this.targeting;\n }\n\n /** Narrow view of the embed the targeting controller talks back through. */\n private makeTargetingHost(): TargetingHost {\n const self = this;\n return {\n get config() {\n return self.config;\n },\n get cssVars() {\n return self.cssVars;\n },\n get state() {\n return self.state;\n },\n get shadowHost() {\n return self.shadowHost;\n },\n get overlayShadowHost() {\n return self.overlayShadowHost;\n },\n get boundKeyDown() {\n return self.boundKeyDown;\n },\n get feedbackData() {\n return self.feedbackData;\n },\n get selectedBounds() {\n return self.selectedBounds;\n },\n setState: (state) => {\n self.state = state;\n },\n ensureOverlayHost: () => self.ensureOverlayHost(),\n applyVars: (el) => self.applyVars(el),\n announceMsg: (message, assertive) => self.announceMsg(message, assertive),\n clearActiveThumb: () => self.clearActiveThumb(),\n submitFeedback: () => self.submitFeedback(),\n };\n }\n\n // ==================== Video Recording ====================\n\n /**\n * Cheap synchronous capability check so the record button can render without\n * pulling in the (lazily-loaded) video subsystem. Mirrors\n * isVideoRecordingSupported() in video-capture.ts.\n */\n private videoSupported(): boolean {\n return (\n typeof navigator !== \"undefined\" &&\n !!navigator.mediaDevices &&\n typeof navigator.mediaDevices.getDisplayMedia === \"function\" &&\n typeof MediaRecorder !== \"undefined\"\n );\n }\n\n\n /**\n * Lazily load and instantiate the recording controller. The whole recording\n * subsystem lives in a separate chunk, fetched only the first time the record\n * button is used (and pre-warmed on hover — see prewarmVideo).\n */\n private async ensureRecording(): Promise<RecordingController> {\n if (!this.recording) {\n const [{ RecordingController, styles }] = await Promise.all([\n import(\"./recording\"),\n this.loadDialogA11y(),\n ]);\n this.addFeatureStyles(styles);\n this.recording = new RecordingController(this.makeRecordingHost());\n }\n return this.recording;\n }\n\n /** Narrow view of the embed the recording controller talks back through. */\n private makeRecordingHost(): RecordingHost {\n const self = this;\n return {\n get config() {\n return self.config;\n },\n get visitorId() {\n return self.visitorId;\n },\n get uid() {\n return self.uid;\n },\n get overlayShadowHost() {\n return self.overlayShadowHost;\n },\n get consoleCapture() {\n return self.consoleCapture;\n },\n get boundKeyDown() {\n return self.boundKeyDown;\n },\n get state() {\n return self.state;\n },\n setState: (state) => {\n self.state = state;\n },\n ensureOverlayHost: () => self.ensureOverlayHost(),\n applyVars: (el) => self.applyVars(el),\n announceMsg: (message, assertive) => self.announceMsg(message, assertive),\n openDialogA11y: (container, opts) => self.openDialogA11y(container, opts),\n closeDialogA11y: () => self.closeDialogA11y(),\n setButtonsDisabled: (disabled) => self.setButtonsDisabled(disabled),\n tryLaunchQuest: (type, feedbackId) => self.tryLaunchQuest(type, feedbackId),\n };\n }\n\n private setButtonsDisabled(disabled: boolean): void {\n if (!this.buttonsContainer) return;\n const buttons = this.buttonsContainer.querySelectorAll<HTMLButtonElement>(\"button.qaid-btn, button.qaid-btn-structural\");\n buttons.forEach((btn) => {\n if (disabled) {\n // Don't disable the record button itself (it has its own state)\n if (!btn.classList.contains(\"qaid-btn-record\")) {\n btn.disabled = true;\n btn.style.opacity = \"0.5\";\n }\n } else {\n btn.disabled = false;\n btn.style.opacity = \"\";\n }\n });\n }\n\n /**\n * Destroy the embed and clean up all resources\n */\n public destroy(): void {\n // Flag as destroyed so the DOM observer doesn't re-attach hosts\n this.destroyed = true;\n\n // Disconnect DOM persistence observers\n if (this.domObserver) {\n this.domObserver.disconnect();\n this.domObserver = null;\n }\n if (this.boundBeforeSwap) {\n document.removeEventListener(\"astro:before-swap\", this.boundBeforeSwap);\n this.boundBeforeSwap = null;\n }\n\n // Tear down the targeting subsystem + release any open dialog focus state\n this.targeting?.destroy();\n this.targeting = null;\n this.clearActiveThumb();\n this.closeDialogA11y();\n\n // Cancel any pending idle preload\n if (this.prewarmHandle !== null) {\n const w = window as unknown as { cancelIdleCallback?: (h: number) => void };\n if (this.prewarmIsTimeout) clearTimeout(this.prewarmHandle);\n else w.cancelIdleCallback?.(this.prewarmHandle);\n this.prewarmHandle = null;\n }\n\n // Tear down the recording subsystem (recorder, picker, preview) if loaded.\n this.recording?.destroy();\n this.recording = null;\n // Tear down the message modal if it was loaded/open.\n this.modal?.destroy();\n this.modal = null;\n\n // Tear down any quest launched from a button\n this.activeQuest?.destroy();\n this.activeQuest = null;\n\n // Restore console.error\n if (this.consoleCapture) {\n this.consoleCapture.restore();\n this.consoleCapture = null;\n }\n\n // Remove event listeners\n window.removeEventListener(\"resize\", this.boundResize);\n document.removeEventListener(\"keydown\", this.boundKeyDown);\n\n document.body.classList.remove(\"qaid-targeting\", \"qaid-type-up\");\n document.body.style.removeProperty(\"--qaid-positive\");\n document.body.style.removeProperty(\"--qaid-negative\");\n\n // Remove shadow hosts from DOM (this removes shadow roots and all their contents)\n if (this.shadowHost) {\n this.shadowHost.remove();\n this.shadowHost = null;\n this.shadowRoot = null;\n }\n if (this.overlayShadowHost) {\n this.overlayShadowHost.remove();\n this.overlayShadowHost = null;\n this.overlayShadowRoot = null;\n }\n this.buttonsContainer = null;\n this.dismissBtn = null;\n this.tooltipElement = null;\n\n // Remove light DOM styles (reference counted)\n removeStyles();\n }\n}\n","/**\n * The property embed.js sets on the tag it injects, pointing back at the\n * customer's own `<script src=\".../embed.js\">`. An expando, not an attribute:\n * markup injected into the page can't forge it. Its own module so embed.js\n * (ES5, tiny) can share it with the bootstrap without pulling the bootstrap in.\n */\nexport var ORIGIN_KEY_NAME = \"__qaidThumbsOrigin\";\n","/**\n * Auto-initialization from a `<script>` tag.\n *\n * Shared by both delivery entries: the legacy UMD/API entry (`index.ts`) and\n * the minimal ESM loader (`loader.ts`). Kept out of `index.ts` so the loader\n * can auto-init without pulling in `index.ts`'s feature re-exports — that\n * re-export graph is what anchors screenshot/video/annotate into the main\n * chunk and defeats code-splitting.\n */\n\nimport { QaidFeedback } from \"./embed\";\nimport type { FeedbackConfig } from \"./types\";\nimport { ORIGIN_KEY_NAME } from \"./origin-key\";\n\n/**\n * Find theme CSS from an element matched by a CSS selector.\n * Used by data-css-selector attribute and JSON cssSelector property.\n */\nfunction findCssFromSelector(selector: string): string {\n const el = document.querySelector(selector);\n return el?.textContent?.trim() ?? \"\";\n}\n\nconst ORIGIN_KEY = ORIGIN_KEY_NAME;\n\nfunction fileName(url: string): string {\n const path = url.split(/[?#]/)[0];\n return path.substring(path.lastIndexOf(\"/\") + 1);\n}\n\n/**\n * The `<script>` tag that loaded this copy of the embed, or null.\n *\n * A classic script has `document.currentScript`. A module has its own URL\n * (`import.meta.url`, passed in as `selfUrl`) instead: the tag whose `src` is\n * that URL. A CDN redirect (unpkg's `@1` → `@1.13.0`) changes the URL, so\n * failing an exact match we take the one tag embed.js injected, then the one\n * tag with the same file name. More than one candidate is ambiguous and\n * finds nothing: the embed never guesses which tag's config to trust.\n */\nexport function findOwnScript(selfUrl?: string): HTMLScriptElement | null {\n const cur = document.currentScript;\n if (cur && cur.tagName === \"SCRIPT\") return cur as HTMLScriptElement;\n if (!selfUrl) return null;\n const scripts = Array.from(document.getElementsByTagName(\"script\")).filter((s) => s.src);\n const exact = scripts.find((s) => s.src === selfUrl);\n if (exact) return exact;\n const injected = scripts.filter((s) => (s as unknown as Record<string, unknown>)[ORIGIN_KEY]);\n if (injected.length === 1) return injected[0];\n const file = fileName(selfUrl);\n const same = scripts.filter((s) => fileName(s.src) === file);\n return same.length === 1 ? same[0] : null;\n}\n\nfunction isJsonBlock(el: Element | null): el is HTMLScriptElement {\n return (\n !!el &&\n el.tagName === \"SCRIPT\" &&\n (el.getAttribute(\"type\") || \"\").trim().toLowerCase() === \"application/json\"\n );\n}\n\n/**\n * The JSON config block that belongs to this embed's tag: the element its\n * `data-config-id` names, else a `data-feedback-config` block right before or\n * right after the tag. A block anywhere else on the page is ignored, so\n * markup injected elsewhere can't swap the endpoint, icons or module URL.\n *\n * For the embed.js install the tag that counts is the customer's own\n * `embed.js` tag, not the one it injected into `<head>`.\n */\nexport function findConfigBlock(own: HTMLScriptElement): HTMLScriptElement | null {\n const origin = (own as unknown as Record<string, unknown>)[ORIGIN_KEY];\n const anchor = origin && (origin as Element).tagName === \"SCRIPT\" ? (origin as HTMLScriptElement) : own;\n const id = anchor.getAttribute(\"data-config-id\") || own.getAttribute(\"data-config-id\");\n if (id) {\n const named = document.getElementById(id);\n return isJsonBlock(named) ? named : null;\n }\n for (const sib of [anchor.previousElementSibling, anchor.nextElementSibling]) {\n if (isJsonBlock(sib) && sib.hasAttribute(\"data-feedback-config\")) return sib;\n }\n return null;\n}\n\n/**\n * Parse JSON config from the embed's own config block (see findConfigBlock):\n * <script type=\"application/json\" data-feedback-config>{ ... }</script>\n */\nfunction parseJsonConfig(own: HTMLScriptElement): Partial<FeedbackConfig> | null {\n const configScript = findConfigBlock(own);\n if (!configScript) return null;\n\n const textContent = configScript.textContent?.trim();\n if (!textContent) return null;\n\n try {\n const parsed = JSON.parse(textContent);\n // Resolve cssSelector → css\n if (parsed.cssSelector && !parsed.css) {\n parsed.css = findCssFromSelector(parsed.cssSelector);\n delete parsed.cssSelector;\n }\n return parsed;\n } catch {\n return null;\n }\n}\n\n/**\n * Say, once per attribute, that a value was ignored. The embed never throws\n * over a bad attribute: it keeps its default and tells the developer why.\n */\nfunction warnIgnored(attr: string, value: string, expected: string): void {\n console.warn(`[thumbs-embed] Ignoring ${attr}=\"${value}\": expected ${expected}.`);\n}\n\n/**\n * Split a comma-separated list, but not on commas inside parentheses, so\n * `rgb(0, 128, 0)` stays one colour.\n */\nfunction splitTopLevel(value: string): string[] {\n const parts: string[] = [];\n let depth = 0;\n let current = \"\";\n for (const ch of value) {\n if (ch === \"(\") depth++;\n if (ch === \")\") depth = Math.max(0, depth - 1);\n if (ch === \",\" && depth === 0) {\n parts.push(current.trim());\n current = \"\";\n } else {\n current += ch;\n }\n }\n parts.push(current.trim());\n return parts;\n}\n\n/**\n * A list of colours, written as a JSON array (`[\"#f00\",\"#0f0\"]`) or as a\n * comma-separated list (`#f00, rgb(0, 128, 0)`). Any empty entry, a\n * non-string entry, an empty list or malformed JSON rejects the whole value.\n */\nfunction parseColorList(attr: string, raw: string | null): string[] | undefined {\n if (raw === null) return undefined;\n const value = raw.trim();\n let list: unknown = null;\n // Anything that looks like JSON is read as JSON, so an object is rejected\n // rather than taken as a one-colour list.\n if (value.startsWith(\"[\") || value.startsWith(\"{\")) {\n try {\n list = JSON.parse(value);\n } catch {\n list = null;\n }\n } else {\n list = splitTopLevel(value);\n }\n if (\n Array.isArray(list) &&\n list.length > 0 &&\n list.every((c) => typeof c === \"string\" && c.trim() !== \"\")\n ) {\n return (list as string[]).map((c) => c.trim());\n }\n warnIgnored(attr, raw, \"a JSON array of colours or a comma-separated list\");\n return undefined;\n}\n\n/**\n * A screen-reader label. An empty one would leave an icon-only button with\n * no accessible name, so it is ignored in favour of the default.\n */\nfunction parseLabel(attr: string, raw: string | null): string | undefined {\n if (raw === null) return undefined;\n if (raw.trim() === \"\") {\n warnIgnored(attr, raw, \"a non-empty label\");\n return undefined;\n }\n return raw;\n}\n\n/**\n * Parse config from data-* attributes. Every option that can be written as\n * text has one, so the JSON config block is a choice, not a requirement.\n *\n * Exported for tests: index.ts does not re-export it, so this is not public API.\n */\nexport function parseDataAttributes(script: HTMLScriptElement): Partial<FeedbackConfig> | null {\n const endpoint = script.getAttribute(\"data-endpoint\");\n if (!endpoint) return null;\n\n const position = script.getAttribute(\"data-position\") as\n | \"bottom-right\"\n | \"bottom-left\"\n | \"top-right\"\n | \"top-left\"\n | null;\n const zIndex = script.getAttribute(\"data-zindex\");\n const positiveColor = script.getAttribute(\"data-positive-color\");\n const negativeColor = script.getAttribute(\"data-negative-color\");\n const markerColor = script.getAttribute(\"data-marker-color\");\n const container = script.getAttribute(\"data-container\");\n const buttonClass = script.getAttribute(\"data-button-class\");\n const skipTargeting = script.getAttribute(\"data-skip-targeting\");\n const hideConfirmation = script.getAttribute(\"data-hide-confirmation\");\n const singleButton = script.getAttribute(\"data-single-button\");\n const feedbackMode = script.getAttribute(\"data-feedback-mode\") as\n | \"target\"\n | \"annotate\"\n | null;\n const incognito = script.getAttribute(\"data-incognito\");\n const buttonSize = script.getAttribute(\"data-button-size\") as\n | \"small\"\n | \"medium\"\n | \"large\"\n | null;\n const offsetX = script.getAttribute(\"data-offset-x\");\n const offsetY = script.getAttribute(\"data-offset-y\");\n const modalWidth = script.getAttribute(\"data-modal-width\");\n const backdropOpacity = script.getAttribute(\"data-backdrop-opacity\");\n const fontFamily = script.getAttribute(\"data-font-family\");\n const fontSize = script.getAttribute(\"data-font-size\");\n const tooltip = script.getAttribute(\"data-tooltip\");\n const modalTitle = script.getAttribute(\"data-modal-title\");\n const confirmationTitle = script.getAttribute(\"data-confirmation-title\");\n const confirmationMessage = script.getAttribute(\"data-confirmation-message\");\n const confirmationClose = script.getAttribute(\"data-confirmation-close\");\n const errorTitle = script.getAttribute(\"data-error-title\");\n const errorMessage = script.getAttribute(\"data-error-message\");\n const modalSubtitle = script.getAttribute(\"data-modal-subtitle\");\n const placeholder = script.getAttribute(\"data-placeholder\");\n const submitButton = script.getAttribute(\"data-submit-button\");\n const skipButton = script.getAttribute(\"data-skip-button\");\n const positiveIcon = script.getAttribute(\"data-positive-icon\");\n const negativeIcon = script.getAttribute(\"data-negative-icon\");\n const feedbackIcon = script.getAttribute(\"data-feedback-icon\");\n const feedbackLabel = script.getAttribute(\"data-feedback-label\");\n const apiKey = script.getAttribute(\"data-api-key\");\n const captureScreenshot = script.getAttribute(\"data-capture-screenshot\");\n const annotate = script.getAttribute(\"data-annotate\");\n const annotationColor = script.getAttribute(\"data-annotation-color\");\n const screenshotQuality = script.getAttribute(\"data-screenshot-quality\");\n const screenshotMaxWidth = script.getAttribute(\"data-screenshot-max-width\");\n const screenshotMaxHeight = script.getAttribute(\"data-screenshot-max-height\");\n const captureVideo = script.getAttribute(\"data-capture-video\");\n const redaction = script.getAttribute(\"data-video-redaction\");\n const hideThumbs = script.getAttribute(\"data-hide-thumbs\");\n const hideDismiss = script.getAttribute(\"data-hide-dismiss\");\n const videoMaxDuration = script.getAttribute(\"data-video-max-duration\");\n const screenshotMethod = script.getAttribute(\"data-screenshot-method\") as \"dom\" | \"permission\" | null;\n const direction = script.getAttribute(\"data-direction\") as \"horizontal\" | \"vertical\" | null;\n const cssSelector = script.getAttribute(\"data-css-selector\");\n const css = script.getAttribute(\"data-css\");\n const positiveLabel = parseLabel(\"data-positive-label\", script.getAttribute(\"data-positive-label\"));\n const negativeLabel = parseLabel(\"data-negative-label\", script.getAttribute(\"data-negative-label\"));\n const recordLabel = parseLabel(\"data-record-label\", script.getAttribute(\"data-record-label\"));\n const dismissLabel = parseLabel(\"data-dismiss-label\", script.getAttribute(\"data-dismiss-label\"));\n const annotationPalette = parseColorList(\n \"data-annotation-palette\",\n script.getAttribute(\"data-annotation-palette\")\n );\n const recordIcon = script.getAttribute(\"data-record-icon\");\n const questBase = script.getAttribute(\"data-quest-base\");\n const questUp = script.getAttribute(\"data-quest-up\");\n const questDown = script.getAttribute(\"data-quest-down\");\n const questVideo = script.getAttribute(\"data-quest-video\");\n const questApiKey = script.getAttribute(\"data-quest-api-key\");\n const questModuleUrl = script.getAttribute(\"data-quest-module-url\");\n\n return {\n endpoint,\n // Inline CSS wins over a selector, as `css` wins over `cssSelector` in\n // the JSON block.\n css: css || (cssSelector ? findCssFromSelector(cssSelector) : undefined),\n apiKey: apiKey ?? undefined,\n captureScreenshot: captureScreenshot === \"true\" ? true : undefined,\n // Annotation is on by default; only an explicit \"false\" disables it.\n annotate: annotate === \"false\" ? false : undefined,\n annotationColor: annotationColor ?? undefined,\n annotationPalette,\n screenshotOptions: (screenshotQuality || screenshotMaxWidth || screenshotMaxHeight) ? {\n quality: screenshotQuality ? parseFloat(screenshotQuality) : undefined,\n maxWidth: screenshotMaxWidth ? parseInt(screenshotMaxWidth, 10) : undefined,\n maxHeight: screenshotMaxHeight ? parseInt(screenshotMaxHeight, 10) : undefined,\n } : undefined,\n container: container ?? undefined,\n buttonClass: buttonClass ?? undefined,\n direction: direction ?? undefined,\n position: position ?? undefined,\n zIndex: zIndex ? parseInt(zIndex, 10) : undefined,\n skipTargeting: skipTargeting === \"true\" ? true : undefined,\n hideConfirmation: hideConfirmation === \"true\" ? true : undefined,\n singleButton: singleButton === \"true\" ? true : undefined,\n feedbackMode: feedbackMode ?? undefined,\n incognito: incognito === \"true\" ? true : undefined,\n buttonSize: buttonSize ?? undefined,\n offset: (offsetX || offsetY) ? {\n x: offsetX ? parseInt(offsetX, 10) : undefined,\n y: offsetY ? parseInt(offsetY, 10) : undefined,\n } : undefined,\n modalWidth: modalWidth ? parseInt(modalWidth, 10) : undefined,\n backdropOpacity: backdropOpacity ? parseFloat(backdropOpacity) : undefined,\n fontFamily: fontFamily ?? undefined,\n fontSize: fontSize ? parseInt(fontSize, 10) : undefined,\n colors: {\n positive: positiveColor ?? undefined,\n negative: negativeColor ?? undefined,\n marker: markerColor ?? undefined,\n },\n text: (tooltip || modalTitle || modalSubtitle || placeholder || submitButton || skipButton || feedbackLabel || confirmationTitle || confirmationMessage || confirmationClose || errorTitle || errorMessage || positiveLabel || negativeLabel || recordLabel || dismissLabel) ? {\n tooltip: tooltip ?? undefined,\n modalTitle: modalTitle ?? undefined,\n modalSubtitle: modalSubtitle ?? undefined,\n placeholder: placeholder ?? undefined,\n submitButton: submitButton ?? undefined,\n skipButton: skipButton ?? undefined,\n feedbackLabel: feedbackLabel ?? undefined,\n confirmationTitle: confirmationTitle ?? undefined,\n confirmationMessage: confirmationMessage ?? undefined,\n confirmationClose: confirmationClose ?? undefined,\n errorTitle: errorTitle ?? undefined,\n errorMessage: errorMessage ?? undefined,\n positiveLabel,\n negativeLabel,\n recordLabel,\n dismissLabel,\n } : undefined,\n positiveIcon: positiveIcon ?? undefined,\n recordIcon: recordIcon ?? undefined,\n negativeIcon: negativeIcon ?? undefined,\n feedbackIcon: feedbackIcon ?? undefined,\n screenshotMethod: screenshotMethod ?? undefined,\n captureVideo: captureVideo === \"true\" ? true : undefined,\n hideThumbs: hideThumbs === \"true\" ? true : undefined,\n hideDismiss: hideDismiss === \"true\" ? true : undefined,\n videoOptions: (videoMaxDuration || redaction) ? {\n maxDuration: videoMaxDuration ? parseInt(videoMaxDuration, 10) : undefined,\n redaction: redaction === \"true\" ? true : undefined,\n } : undefined,\n quests: questBase ? {\n base: questBase,\n up: questUp ?? undefined,\n down: questDown ?? undefined,\n video: questVideo ?? undefined,\n apiKey: questApiKey ?? undefined,\n moduleUrl: questModuleUrl ?? undefined,\n } : undefined,\n };\n}\n\n/**\n * Initialize a QaidFeedback instance from the embed's own `<script>` tag: its\n * JSON config block or its data-* attributes. Safe to call in any\n * environment — it no-ops when there is no document, when the embed's own tag\n * can't be found (an npm import in a bundle), or when there is no endpoint.\n *\n * @param selfUrl the running module's URL (`import.meta.url`), used to find\n * the tag when `document.currentScript` is null (ES modules).\n */\nexport function autoInit(selfUrl?: string): void {\n if (typeof document === \"undefined\") return;\n\n // currentScript is only set while the tag's code first runs, so find the\n // tag now, not after DOMContentLoaded.\n const script = findOwnScript(selfUrl);\n if (!script) return;\n\n const run = (): void => {\n // The JSON block wins. The attributes are only read without one, so a\n // bad attribute beside a block doesn't warn about a value never used.\n const config = parseJsonConfig(script) ?? parseDataAttributes(script);\n\n if (config?.endpoint) {\n new QaidFeedback(config as FeedbackConfig);\n }\n };\n\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", run);\n } else {\n run();\n }\n}\n","/**\n * The embed's one Trusted Types policy, `qaid-embed`.\n *\n * On a page that sets `require-trusted-types-for 'script'`, assigning a plain\n * string to `script.src` throws. The embed computes every script URL it sets\n * itself (its own stage-two file, the quests module), so it passes each one\n * through this policy, which only signs URLs the embed registered a moment\n * before. A partner allows it with `trusted-types qaid-embed`.\n *\n * The policy is created once per page and kept on `window`, because embed.js,\n * the bundle it loads, and quests-embed (which keeps its own copy of this\n * file) all want the same name, and a page's `trusted-types` directive\n * refuses a second policy of one name unless it says `'allow-duplicates'`.\n *\n * When the browser has no Trusted Types, or the page's directive does not\n * list `qaid-embed`, the URL comes back as a plain string. The assignment\n * then works or throws exactly as it would have; callers catch it.\n *\n * ES5-clean on purpose: embed.js, which runs on the oldest browsers we\n * support, bundles this file too.\n */\n\ninterface ScriptUrlPolicy {\n createScriptURL(url: string): unknown;\n}\n\ninterface SharedPolicy {\n policy: ScriptUrlPolicy | null;\n allowed: Record<string, boolean>;\n}\n\ninterface TrustedTypesFactory {\n createPolicy(\n name: string,\n rules: { createScriptURL: (url: string) => string }\n ): ScriptUrlPolicy;\n}\n\nexport var POLICY_NAME = \"qaid-embed\";\nvar KEY = \"__qaidEmbedTrustedTypes\";\n\nfunction shared(): SharedPolicy | null {\n if (typeof window === \"undefined\") return null;\n var w = window as unknown as Record<string, unknown>;\n var tt = w.trustedTypes as TrustedTypesFactory | undefined;\n if (!tt || typeof tt.createPolicy !== \"function\") return null;\n var existing = w[KEY] as SharedPolicy | undefined;\n if (existing) return existing;\n\n var allowed: Record<string, boolean> = Object.create(null);\n var policy: ScriptUrlPolicy | null = null;\n try {\n policy = tt.createPolicy(POLICY_NAME, {\n createScriptURL: function (url: string): string {\n if (allowed[url] === true) return url;\n throw new TypeError(\"qaid-embed: refused script URL \" + url);\n },\n });\n } catch (e) {\n // The page's trusted-types directive does not list qaid-embed.\n policy = null;\n }\n var state: SharedPolicy = { policy: policy, allowed: allowed };\n try {\n Object.defineProperty(w, KEY, { value: state, configurable: true });\n } catch (e) {\n /* frozen window: keep it local */\n }\n return state;\n}\n\n/**\n * A value for `script.src`: a TrustedScriptURL from the `qaid-embed` policy\n * when one exists, else the string itself.\n */\nexport function trustedScriptUrl(url: string): string {\n var s = shared();\n if (!s || !s.policy) return url;\n s.allowed[url] = true;\n return s.policy.createScriptURL(url) as string;\n}\n\n/** @internal Test seam: forget the page's policy. */\nexport function _resetTrustedTypes(): void {\n if (typeof window === \"undefined\") return;\n try {\n delete (window as unknown as Record<string, unknown>)[KEY];\n } catch (e) {\n /* nothing to forget */\n }\n}\n"],"names":["THUMBS_UP_ICON","THUMBS_DOWN_ICON","RECORD_ICON","FEEDBACK_ICON","DISMISS_ICON","RECTANGLE_ICON","ARROW_ICON","PENCIL_ICON","BLUR_ICON","UNDO_ICON","DONE_ICON","ERROR_ICON","SKIP_ICON","SVG_NS","ELEMENTS","name","ATTRIBUTES","TEXT_ELEMENTS","MAX_LENGTH","MAX_ELEMENTS","NAMED_ENTITIES","decodeEntities","value","whole","body","code","LOCAL_URL","isSafeValue","attr","squashed","withoutLocal","sanitizeSvg","markup","src","root","rootClosed","count","stack","i","top","lt","textEnd","text","frame","end","m","at","f","nameMatch","lowerName","attrs","selfClosing","closed","ws","attrMatch","attrName","eq","quote","bare","parent","canonical","el","iconNode","fallback","setIcon","instanceCount","DEFAULT_BUTTON_STYLES","BUTTON_SIZES","ICON_SIZES","getLuminance","r","g","b","rs","gs","bs","c","parseColor","color","hex","fullHex","num","match","getContrastTextColor","bgColor","rgb","buildCssVars","options","positiveColor","negativeColor","markerColor","buttonSize","modalWidth","backdropOpacity","fontFamily","fontSize","btnSize","iconSize","markerTextColor","applyCssVars","vars","getEmbedStyles","shadowStyles","injectStyles","style","lightStyles","removeStyles","POLITE_ATTR","VISUALLY_HIDDEN_CSS","ownerDoc","getLiveRegion","assertive","kind","existing","region","announce","message","opts","calculateTooltipPosition","anchor","tooltip","viewport","gap","left","MAX_MESSAGES","captureConsoleErrors","onError","errors","originalError","originalWarn","originalLog","capture","level","args","error","arg","createElement","tag","children","key","child","isMobileViewport","breakpoint","getElementAtPointUnderOverlay","x","y","hosts","saved","h","element","isEmbedElement","getElementBounds","padding","rect","QUESTS_VERSION","DEFAULT_QUESTS_MODULE_URL","DEFAULT_QUESTS_MODULE_INTEGRITY","PINNED_UNPKG","warned","resolveQuestsModuleUrl","moduleUrl","page","url","VISITOR_ID_KEY","HIDE_FEEDBACK_KEY","DEFAULT_ANNOTATION_PALETTE","isTouchPrimaryDevice","getHideKey","apiKey","isHiddenByUser","setHiddenByUser","hidden","randomId","bytes","getOrCreateVisitorId","visitorId","insertFeatureStyle","css","marks","after","QaidFeedback","config","n","container","close","_error","q","id","ids","base","fn","w","guarded","e","newDoc","userContainer","baseStyle","themeStyle","dirClass","offsetX","offsetY","ev","warmClickPath","useCustomClass","btnBaseClass","tooltipText","fbWrapper","fbBtn","upWrapper","upBtn","downWrapper","downBtn","recordWrapper","recordBtn","rec","warmVideo","anchorRect","tooltipRect","type","buttonEl","keyboard","t","send","err","feedbackId","self","quest","state","ModalController","styles","TargetingController","RecordingController","disabled","btn","ORIGIN_KEY_NAME","findCssFromSelector","selector","ORIGIN_KEY","fileName","path","findOwnScript","selfUrl","cur","scripts","s","exact","injected","file","same","isJsonBlock","findConfigBlock","own","origin","named","sib","parseJsonConfig","configScript","textContent","parsed","warnIgnored","expected","splitTopLevel","parts","depth","current","ch","parseColorList","raw","list","parseLabel","parseDataAttributes","script","endpoint","position","zIndex","buttonClass","skipTargeting","hideConfirmation","singleButton","feedbackMode","incognito","modalTitle","confirmationTitle","confirmationMessage","confirmationClose","errorTitle","errorMessage","modalSubtitle","placeholder","submitButton","skipButton","positiveIcon","negativeIcon","feedbackIcon","feedbackLabel","captureScreenshot","annotate","annotationColor","screenshotQuality","screenshotMaxWidth","screenshotMaxHeight","captureVideo","redaction","hideThumbs","hideDismiss","videoMaxDuration","screenshotMethod","direction","cssSelector","positiveLabel","negativeLabel","recordLabel","dismissLabel","annotationPalette","recordIcon","questBase","questUp","questDown","questVideo","questApiKey","questModuleUrl","autoInit","run","POLICY_NAME","KEY","shared","tt","allowed","policy","trustedScriptUrl"],"mappings":"AAIO,MAAMA,EAAiB;AAAA;AAAA,QAIjBC,EAAmB;AAAA;AAAA,QAInBC,GAAc;AAAA;AAAA,QAKdC,EAAgB;AAAA;AAAA,QAKhBC,GAAe,oMAOfC,GAA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OAAOA,EAErB,IAAIsN,EAAmC,OAAO,OAAO,IAAI,EACrDC,EAAiC,KACrC,GAAI,CACFA,EAASF,EAAG,aAAaH,GAAa,CACpC,gBAAiB,SAAUjK,EAAqB,CAC9C,GAAIqK,EAAQrK,CAAG,IAAM,GAAM,OAAOA,EAClC,MAAM,IAAI,UAAU,kCAAoCA,CAAG,CAC7D,CAAA,CACD,CACH,MAAY,CAEVsK,EAAS,IACX,CACA,IAAIrG,EAAsB,CAAE,OAAAqG,EAAgB,QAAAD,CAAA,EAC5C,GAAI,CACF,OAAO,eAAexI,EAAGqI,GAAK,CAAE,MAAOjG,EAAO,aAAc,GAAM,CACpE,MAAY,CAEZ,CACA,OAAOA,CACT,CAMO,SAASsG,GAAiBvK,EAAqB,CACpD,IAAIkF,EAAIiF,GAAA,EACR,MAAI,CAACjF,GAAK,CAACA,EAAE,OAAelF,GAC5BkF,EAAE,QAAQlF,CAAG,EAAI,GACVkF,EAAE,OAAO,gBAAgBlF,CAAG,EACrC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const f=document;function i(l,t,...c){const n=f.createElement(l);if(t){if(t.class&&(n.className=t.class),t.style&&(n.style.cssText=t.style),t.text!=null&&(n.textContent=t.text),t.attrs)for(const e in t.attrs)n.setAttribute(e,t.attrs[e]);if(t.on)for(const e in t.on)n.addEventListener(e,t.on[e])}for(const e of c)e!=null&&e!==!1&&n.append(e);return n}export{i as h};
|
|
2
|
+
//# sourceMappingURL=dom-kdwHduNo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom-kdwHduNo.js","sources":["../../src/dom.ts"],"sourcesContent":["/**\n * Nano DOM factory — a purpose-built, construction-only helper for this embed.\n *\n * The embed builds all of its UI imperatively inside a Shadow DOM. That means\n * the same create → set class/style/attrs → wire events → append dance repeats\n * across every button, overlay, modal, and recording control. `h()` collapses\n * that dance into a single declarative expression.\n *\n * It is deliberately NOT a framework: no reactivity, no virtual DOM, no runtime\n * state. It only constructs. That fits what the embed actually needs (one-shot\n * DOM construction plus a few imperative updates), adds no dependency, and\n * keeps the package zero-dependency. Aliasing `document` here also lets the\n * minifier mangle the call site, which the global `document.createElement`\n * can't be.\n */\n\nconst d = document;\n\nexport interface ElProps {\n /** className */\n class?: string;\n /** Inline styles as a cssText string. */\n style?: string;\n /** textContent. */\n text?: string;\n /** Attributes set via setAttribute (aria-*, data-*, type, role, …). */\n attrs?: Record<string, string>;\n /** Event listeners keyed by type. */\n on?: Record<string, (e: Event) => void>;\n}\n\ntype Child = Node | string | null | undefined | false;\n\n/**\n * Create an element, apply props, and append children. Falsy children are\n * skipped so conditional content reads cleanly (`cond && h(...)`).\n */\nexport function h<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n props?: ElProps | null,\n ...children: Child[]\n): HTMLElementTagNameMap[K] {\n const el = d.createElement(tag);\n if (props) {\n if (props.class) el.className = props.class;\n if (props.style) el.style.cssText = props.style;\n if (props.text != null) el.textContent = props.text;\n if (props.attrs) {\n for (const k in props.attrs) el.setAttribute(k, props.attrs[k]);\n }\n if (props.on) {\n for (const k in props.on) el.addEventListener(k, props.on[k]);\n }\n }\n for (const child of children) {\n if (child != null && child !== false) el.append(child);\n }\n return el;\n}\n"],"names":["d","h","tag","props","children","el","k","child"],"mappings":"AAgBA,MAAMA,EAAI,SAqBH,SAASC,EACdC,EACAC,KACGC,EACuB,CAC1B,MAAMC,EAAKL,EAAE,cAAcE,CAAG,EAC9B,GAAIC,EAAO,CAIT,GAHIA,EAAM,QAAOE,EAAG,UAAYF,EAAM,OAClCA,EAAM,QAAOE,EAAG,MAAM,QAAUF,EAAM,OACtCA,EAAM,MAAQ,OAAME,EAAG,YAAcF,EAAM,MAC3CA,EAAM,MACR,UAAWG,KAAKH,EAAM,MAAOE,EAAG,aAAaC,EAAGH,EAAM,MAAMG,CAAC,CAAC,EAEhE,GAAIH,EAAM,GACR,UAAWG,KAAKH,EAAM,GAAIE,EAAG,iBAAiBC,EAAGH,EAAM,GAAGG,CAAC,CAAC,CAEhE,CACA,UAAWC,KAASH,EACdG,GAAS,MAAQA,IAAU,IAAOF,EAAG,OAAOE,CAAK,EAEvD,OAAOF,CACT"}
|