@qaiddev/thumbs-embed 1.3.0 → 1.5.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/dist/auto.d.ts +24 -0
- package/dist/auto.js +2 -0
- package/dist/auto.js.map +1 -0
- package/dist/bootstrap.d.ts +15 -0
- package/dist/chunks/annotate-BNibaDg3.js +367 -0
- package/dist/chunks/annotate-BNibaDg3.js.map +1 -0
- package/dist/chunks/bootstrap-U4yiPm5-.js +1099 -0
- package/dist/chunks/bootstrap-U4yiPm5-.js.map +1 -0
- package/dist/chunks/modal-BX5wqy4s.js +119 -0
- package/dist/chunks/modal-BX5wqy4s.js.map +1 -0
- package/dist/chunks/network-capture-DMbMwwwR.js +63 -0
- package/dist/chunks/network-capture-DMbMwwwR.js.map +1 -0
- package/dist/chunks/recording--IwOtRL2.js +256 -0
- package/dist/chunks/recording--IwOtRL2.js.map +1 -0
- package/dist/chunks/screenshot-BkOCLuS2.js +33 -0
- package/dist/chunks/screenshot-BkOCLuS2.js.map +1 -0
- package/dist/chunks/screenshot-dom-CME7tYRE.js +63 -0
- package/dist/chunks/screenshot-dom-CME7tYRE.js.map +1 -0
- package/dist/chunks/targeting-DwdDr9Cm.js +295 -0
- package/dist/chunks/targeting-DwdDr9Cm.js.map +1 -0
- package/dist/chunks/video-BOYqf2Im.js +209 -0
- package/dist/chunks/video-BOYqf2Im.js.map +1 -0
- package/dist/dom.d.ts +36 -0
- package/dist/embed.d.ts +53 -68
- package/dist/index.d.ts +10 -12
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/loader.d.ts +18 -0
- package/dist/loader.js +7 -0
- package/dist/loader.js.map +1 -0
- package/dist/modal.d.ts +49 -0
- package/dist/qaid.umd.cjs +23 -23
- package/dist/qaid.umd.cjs.map +1 -1
- package/dist/recording.d.ts +74 -0
- package/dist/targeting.d.ts +72 -0
- package/dist/types.d.ts +7 -1
- package/dist/video-capture.d.ts +7 -0
- package/dist/video-orientation.d.ts +2 -0
- package/dist/video-redaction.d.ts +58 -0
- package/package.json +12 -5
- package/dist/qaid.js +0 -2013
- package/dist/qaid.js.map +0 -1
package/dist/qaid.umd.cjs
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
(function(b,
|
|
1
|
+
(function(b,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(b=typeof globalThis<"u"?globalThis:b||self,E(b.Qaid={}))})(this,(function(b){"use strict";const E=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
2
2
|
<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"/>
|
|
3
|
-
</svg>`,
|
|
3
|
+
</svg>`,O=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
4
4
|
<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"/>
|
|
5
|
-
</svg>`,
|
|
5
|
+
</svg>`,Lt=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
6
6
|
<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"/>
|
|
7
|
-
</svg>`,
|
|
7
|
+
</svg>`,Rt=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
8
8
|
<rect x="4" y="6" width="16" height="12" rx="1" stroke-linejoin="round"/>
|
|
9
|
-
</svg>`,
|
|
9
|
+
</svg>`,Mt=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
10
10
|
<path stroke-linecap="round" stroke-linejoin="round" d="M5 19L19 5m0 0h-8m8 0v8"/>
|
|
11
|
-
</svg>`,
|
|
11
|
+
</svg>`,Pt=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
12
12
|
<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"/>
|
|
13
|
-
</svg>`,
|
|
13
|
+
</svg>`,Bt=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
14
14
|
<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"/>
|
|
15
|
-
</svg>`,
|
|
15
|
+
</svg>`,Ht=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
16
16
|
<path stroke-linecap="round" stroke-linejoin="round" d="M9 14L4 9l5-5M4 9h11a5 5 0 010 10h-4"/>
|
|
17
|
-
</svg>`,
|
|
17
|
+
</svg>`,Ot=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
18
18
|
<path stroke-linecap="round" stroke-linejoin="round" d="M20 6L9 17l-5-5"/>
|
|
19
|
-
</svg>`,
|
|
19
|
+
</svg>`,zt=`<svg xmlns="http://www.w3.org/2000/svg" class="qaid-icon" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
|
|
20
20
|
<path stroke-linecap="round" stroke-linejoin="round" d="M6 6l12 12M18 6L6 18"/>
|
|
21
|
-
</svg>`,Et="button{cursor:pointer}.qaid-buttons{display:flex;gap:.5rem}.qaid-buttons.qaid-vertical{flex-direction:column}.qaid-buttons.qaid-auto-container{position:fixed;z-index:50}.qaid-buttons.qaid-auto-container.qaid-bottom-right{bottom:1rem;right:1rem}.qaid-buttons.qaid-auto-container.qaid-bottom-left{bottom:1rem;left:1rem}.qaid-buttons.qaid-auto-container.qaid-top-right{top:1rem;right:1rem}.qaid-buttons.qaid-auto-container.qaid-top-left{top:1rem;left:1rem}.qaid-buttons.qaid-incognito{opacity:0;transition:opacity .2s ease-in-out}.qaid-buttons.qaid-incognito:hover{opacity:1}.qaid-buttons.qaid-dismissed{display:none!important}.qaid-dismiss-btn{width:20px;height:20px;padding:0;border:none;border-radius:50%;background:#0006;color:#fff;display:flex;align-items:center;justify-content:center;align-self:center;opacity:0;transition:opacity .15s,background .15s;cursor:pointer;pointer-events:auto;-webkit-appearance:none;appearance:none}.qaid-dismiss-btn:hover{background:#0009}.qaid-buttons:hover .qaid-dismiss-btn{opacity:1}button.qaid-btn-structural{display:inline-flex;align-items:center;justify-content:center;cursor:pointer;-webkit-appearance:none;appearance:none}.qaid-icon{width:24px;height:24px}.qaid-btn-structural:not(:has(svg)),.qaid-btn:not(:has(svg)){font-size:var(--qaid-icon-size, 24px);line-height:1}.qaid-emoji-icon{font-size:var(--qaid-icon-size, 24px);line-height:1}.qaid-buttons,.qaid-buttons *,.qaid-modal-container,.qaid-modal-container *{cursor:pointer!important}.qaid-tooltip-wrapper{position:relative}.qaid-tooltip-text{position:fixed;padding:.5rem .75rem;background:#1f2937;color:#fff;font-size:1rem;font-weight:600;border-radius:.5rem;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s;z-index:99999}.qaid-tooltip-text.qaid-tooltip-visible{opacity:1}.qaid-targeting-overlay{position:fixed;inset:0;z-index:40;pointer-events:none}.qaid-capture-layer{position:fixed;inset:0;pointer-events:none;z-index:9999}@keyframes qaid-slideDown{0%{transform:translateY(-100%)}to{transform:translateY(0)}}.qaid-vignette{position:fixed;inset:0;pointer-events:none;background:radial-gradient(ellipse at center,transparent 30%,rgba(0,0,0,.3) 70%,rgba(0,0,0,.6) 100%);z-index:41}.qaid-crosshair-h,.qaid-crosshair-v{position:fixed;pointer-events:none;z-index:42}.qaid-crosshair-h{left:0;right:0;height:1px;background:color-mix(in srgb,var(--qaid-negative) 60%,transparent)}.qaid-crosshair-v{top:0;bottom:0;width:1px;background:color-mix(in srgb,var(--qaid-negative) 60%,transparent)}.qaid-type-up .qaid-crosshair-h,.qaid-type-up .qaid-crosshair-v{background:color-mix(in srgb,var(--qaid-positive) 60%,transparent)}.qaid-highlight-box{position:fixed;top:0;left:0;pointer-events:none;z-index:41;display:none;border:3px solid color-mix(in srgb,var(--qaid-negative) 80%,transparent);border-radius:2px;background:color-mix(in srgb,var(--qaid-negative) 8%,transparent);will-change:transform,width,height}.qaid-type-up .qaid-highlight-box{border-color:color-mix(in srgb,var(--qaid-positive) 80%,transparent);background:color-mix(in srgb,var(--qaid-positive) 8%,transparent)}.qaid-scope{position:fixed;width:80px;height:80px;pointer-events:none;z-index:43;transform:translate(-50%,-50%)}.qaid-scope-ring{position:absolute;inset:10px;border:2px solid color-mix(in srgb,var(--qaid-negative) 80%,transparent);border-radius:50%}.qaid-type-up .qaid-scope-ring{border-color:color-mix(in srgb,var(--qaid-positive) 80%,transparent)}.qaid-scope-ring-inner{position:absolute;inset:20px;border:1px solid color-mix(in srgb,var(--qaid-negative) 50%,transparent);border-radius:50%}.qaid-type-up .qaid-scope-ring-inner{border-color:color-mix(in srgb,var(--qaid-positive) 50%,transparent)}.qaid-scope-dot{position:absolute;top:50%;left:50%;width:4px;height:4px;background:var(--qaid-negative);border-radius:50%;transform:translate(-50%,-50%)}.qaid-type-up .qaid-scope-dot{background:var(--qaid-positive)}.qaid-selected-marker{position:fixed;border:3px solid var(--qaid-marker, #6366f1);border-radius:50%;pointer-events:none;z-index:44;animation:qaid-markerPulse 1.5s ease-in-out infinite}@keyframes qaid-markerPulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.7;transform:scale(1.05)}}.qaid-backdrop{position:fixed;inset:0;z-index:45;background:#0000004d}.qaid-modal-container{position:fixed;z-index:50;display:flex;flex-direction:column;align-items:flex-start;max-height:calc(100vh - 32px);font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-modal-container.qaid-above{flex-direction:column-reverse}.qaid-modal-arrow{width:0;height:0;border-left:12px solid transparent;border-right:12px solid transparent;position:relative;align-self:flex-start}.qaid-modal-container.qaid-below .qaid-modal-arrow{border-bottom:12px solid light-dark(#ffffff,#1f2937)}.qaid-modal-container.qaid-above .qaid-modal-arrow{border-top:12px solid light-dark(#ffffff,#1f2937)}.qaid-modal-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5));width:var(--qaid-modal-width, 400px);max-width:calc(100vw - 32px);max-height:calc(100vh - 60px);overflow-y:auto}.qaid-modal-header{display:flex;align-items:flex-start;gap:.75rem;margin-bottom:1rem}button.qaid-type-toggle{border:none;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s;flex-shrink:0;-webkit-appearance:none;appearance:none}button.qaid-type-toggle:hover{transform:scale(1.1)}button.qaid-type-toggle:not(.qaid-type-toggle-custom){width:2.5rem;height:2.5rem;border-radius:50%}button.qaid-type-toggle:not(.qaid-type-toggle-custom) svg{width:1.25rem;height:1.25rem}button.qaid-type-toggle.qaid-type-up{background:var(--qaid-positive);color:#fff}button.qaid-type-toggle.qaid-type-down{background:var(--qaid-negative);color:#fff}.qaid-modal-header-text{flex:1;min-width:0}.qaid-modal-title{font-size:1.125rem;font-weight:700;margin:0 0 .25rem;color:light-dark(#1f2937,#f9fafb)}.qaid-modal-subtitle{color:light-dark(#6b7280,#9ca3af);margin:0;font-size:.875rem}.qaid-textarea{width:100%;height:6rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:1rem;resize:vertical;margin-bottom:1rem;box-sizing:border-box;background:light-dark(#ffffff,#111827);color:light-dark(#1f2937,#f9fafb)}.qaid-textarea:focus{outline:none;border-color:var(--qaid-marker);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 20%,transparent)}.qaid-btn-row{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-btn-submit{padding:.5rem 1rem;background:var(--qaid-marker);color:var(--qaid-marker-text, white);border:none;border-radius:.5rem;font-size:.875rem;font-weight:500;cursor:pointer;transition:background-color .2s,filter .2s;-webkit-appearance:none;appearance:none}button.qaid-btn-submit:hover{filter:brightness(.85)}button.qaid-btn-submit:focus{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 30%,transparent)}.qaid-bottom-sheet{position:fixed;bottom:0;left:0;right:0;z-index:50;animation:qaid-slideUpSheet .3s ease-out;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-bottom-sheet-content{background:light-dark(#ffffff,#1f2937);border-radius:1rem 1rem 0 0;padding:1.5rem;padding-bottom:max(1.5rem,env(safe-area-inset-bottom))}.qaid-bottom-sheet-handle{width:36px;height:4px;background:light-dark(rgba(0,0,0,.2),rgba(255,255,255,.2));border-radius:2px;margin:0 auto 1rem}@keyframes qaid-slideUpSheet{0%{transform:translateY(100%)}to{transform:translateY(0)}}button.qaid-btn-record:hover{background:#dc2626;color:#fff}.qaid-recording-indicator{position:fixed;top:12px;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:.5rem;padding:.5rem 1rem;background:light-dark(#1f2937,#374151);color:#fff;border-radius:9999px;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:.875rem;font-weight:500;box-shadow:0 4px 12px #0000004d;z-index:99999;animation:qaid-slideDown .2s ease-out}.qaid-recording-dot{width:10px;height:10px;background:#dc2626;border-radius:50%;animation:qaid-dotPulse 1.5s ease-in-out infinite}@keyframes qaid-dotPulse{0%,to{opacity:1}50%{opacity:.3}}.qaid-recording-time{font-variant-numeric:tabular-nums;min-width:2.5rem;text-align:center}button.qaid-recording-stop{padding:.25rem .75rem;background:#dc2626;color:#fff;border:none;border-radius:9999px;font-size:.75rem;font-weight:600;cursor:pointer;transition:background-color .2s;-webkit-appearance:none;appearance:none}button.qaid-recording-stop:hover{background:#b91c1c}.qaid-video-preview{position:fixed;inset:0 0 auto;height:100vh;height:100dvh;display:flex;align-items:center;justify-content:center;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#0009;z-index:99998;animation:qaid-fadeIn .2s ease-out}@keyframes qaid-fadeIn{0%{opacity:0}to{opacity:1}}.qaid-video-preview-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px #00000080;width:560px;max-width:100%;max-height:100%;overflow-y:auto;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-video-preview-box h3{font-size:1.125rem;font-weight:700;margin:0 0 1rem;color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box video{width:100%;max-height:50vh;max-height:50dvh;object-fit:contain;border-radius:.5rem;background:#000;margin-bottom:1rem}.qaid-video-preview-box textarea{width:100%;height:4rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:.875rem;resize:vertical;margin-bottom:1rem;box-sizing:border-box;background:light-dark(#ffffff,#111827);color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box textarea:focus{outline:none;border-color:var(--qaid-marker);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 20%,transparent)}.qaid-video-preview-actions{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-video-btn{padding:.5rem 1rem;border:none;border-radius:.5rem;font-size:.875rem;font-weight:500;cursor:pointer;transition:background-color .2s,filter .2s;-webkit-appearance:none;appearance:none}button.qaid-video-btn-cancel{background:light-dark(#f3f4f6,#374151);color:light-dark(#374151,#d1d5db)}button.qaid-video-btn-cancel:hover{background:light-dark(#e5e7eb,#4b5563)}button.qaid-video-btn-rerecord{background:light-dark(#fef3c7,#78350f);color:light-dark(#92400e,#fde68a)}button.qaid-video-btn-rerecord:hover{filter:brightness(.9)}button.qaid-video-btn-send{background:var(--qaid-marker);color:var(--qaid-marker-text, white)}button.qaid-video-btn-send:hover{filter:brightness(.85)}button.qaid-video-btn-send:disabled{opacity:.5;cursor:not-allowed}.qaid-video-sending{display:flex;align-items:center;gap:.5rem;font-size:.875rem;color:light-dark(#6b7280,#9ca3af)}.qaid-annotate{position:fixed;inset:0;z-index:2147483000;display:flex;flex-direction:column;gap:.75rem;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#000000d9;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px);animation:qaid-fadeIn .2s ease-out}.qaid-annotate-title{margin:0;font-size:1rem;font-weight:700;text-align:center;color:#f9fafb}.qaid-annotate-desc{margin:0;font-size:.8125rem;line-height:1.4;text-align:center;color:#f9fafbbf}.qaid-annotate-stage{flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center;overflow:auto}.qaid-annotate-canvas{max-width:100%;max-height:100%;object-fit:contain;background:light-dark(#ffffff,#111827);border-radius:.5rem;box-shadow:0 10px 30px #00000080;touch-action:none;cursor:crosshair}.qaid-annotate-toolbar{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center;justify-content:center;padding:.5rem .75rem;background:light-dark(#ffffff,#1f2937);border-radius:.75rem;box-shadow:0 10px 30px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5))}.qaid-annotate-tools,.qaid-annotate-actions{display:flex;gap:.375rem;align-items:center}button.qaid-annotate-tool,button.qaid-annotate-action{display:inline-flex;align-items:center;justify-content:center;gap:.375rem;min-width:44px;min-height:44px;padding:0 .75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;background:light-dark(#f9fafb,#111827);color:light-dark(#1f2937,#f9fafb);font-family:inherit;font-size:.8125rem;font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none;transition:background-color .15s,color .15s,border-color .15s,filter .15s}button.qaid-annotate-tool{padding:0}button.qaid-annotate-tool svg,button.qaid-annotate-action svg{width:20px;height:20px}button.qaid-annotate-tool:hover,button.qaid-annotate-action:hover{background:light-dark(#eef2ff,#312e81)}button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{background:var(--qaid-marker, #6366f1);color:var(--qaid-marker-text, #fff);border-color:var(--qaid-marker, #6366f1)}button.qaid-annotate-done:hover{filter:brightness(.9);background:var(--qaid-marker, #6366f1)}button.qaid-annotate-action:disabled{opacity:.45;cursor:not-allowed}@media(forced-colors:active){button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{border:2px solid Highlight}.qaid-annotate-canvas{border:1px solid CanvasText}}button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible{outline:2px solid var(--qaid-marker, #6366f1);outline-offset:2px}.qaid-textarea:focus-visible,button.qaid-btn-submit:focus-visible,.qaid-video-preview-box textarea:focus-visible{outline:2px solid var(--qaid-marker, #6366f1);outline-offset:2px}.qaid-buttons.qaid-incognito:focus-within{opacity:1}.qaid-buttons:focus-within .qaid-dismiss-btn,.qaid-dismiss-btn:focus-visible{opacity:1}.qaid-dismiss-btn{min-width:24px;min-height:24px}button.qaid-recording-stop{min-height:24px}@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}@media(forced-colors:active){button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible,.qaid-textarea:focus,button.qaid-btn-submit:focus,.qaid-video-preview-box textarea:focus{outline:2px solid CanvasText;outline-offset:2px}.qaid-selected-marker,.qaid-highlight-box{border-color:Highlight}}",St="body.qaid-targeting,body.qaid-targeting *{cursor:none!important}";let E=0;const Tt="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 svg{width:var(--qaid-icon-size);height:var(--qaid-icon-size)}",Lt={small:36,medium:48,large:64},At={small:18,medium:24,large:32};function It(e,t,i){const[o,n,s]=[e,t,i].map(a=>(a=a/255,a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)));return .2126*o+.7152*n+.0722*s}function Dt(e){if(e.startsWith("#")){const i=e.slice(1),o=i.length===3?i.split("").map(s=>s+s).join(""):i,n=parseInt(o,16);return{r:n>>16&255,g:n>>8&255,b:n&255}}const t=e.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}function Mt(e){const t=Dt(e);return t&&It(t.r,t.g,t.b)>.4?"black":"white"}function Rt(e={}){const{positiveColor:t="rgb(0, 200, 83)",negativeColor:i="rgb(255, 0, 0)",markerColor:o="#6366f1",buttonSize:n="medium",modalWidth:s=400,backdropOpacity:a=.3,fontFamily:d="system-ui, -apple-system, sans-serif",fontSize:c=16}=e,r=Lt[n],l=At[n],p=Mt(o);return{"--qaid-positive":t,"--qaid-negative":i,"--qaid-marker":o,"--qaid-marker-text":p,"--qaid-btn-size":`${r}px`,"--qaid-icon-size":`${l}px`,"--qaid-modal-width":`${s}px`,"--qaid-backdrop-opacity":String(a),"--qaid-font-family":d,"--qaid-font-size":`${c}px`}}function Bt(e,t){for(const[i,o]of Object.entries(t))e.style.setProperty(i,o)}function N(){return Et+Tt}function Ht(){if(E++,E>1)return;const e=document.createElement("style");e.id="qaid-styles",e.textContent=St,document.head.appendChild(e)}function Pt(){E<=0||(E--,E===0&&document.getElementById("qaid-styles").remove())}const F=["data-comp","data-qa","data-testid","data-id"];function U(e,t=document.body){let i=e;for(;i&&i!==t;){for(const o of F){const n=i.getAttribute(o);if(n)return`${o}="${n}"`}i=i.parentElement}return null}function Ot(e,t=100){const i=e.textContent?.trim().slice(0,t)||"";return i.length===t?i+"...":i}function zt(e){let t=1,i=e.previousElementSibling;for(;i;)t++,i=i.previousElementSibling;return t}function $t(e){const t=[];let i=e;for(;i&&i!==document.body&&i!==document.documentElement;){const o=i.tagName.toLowerCase(),n=zt(i);t.unshift(`${o}:nth-child(${n})`),i=i.parentElement}return t.length>0?`body > ${t.join(" > ")}`:"body"}function Nt(e){return e.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function Ft(e){const t=U(e);return t?`[${t}]`:e.id?`#${Nt(e.id)}`:$t(e)}function R(e){const t=Ot(e),i=U(e);return{selector:Ft(e),text:t,dataAttr:i}}const Ut=["a[href]","button","input:not([type=hidden])","select","textarea","summary","[tabindex]","[role]","img","h1","h2","h3","h4","h5","h6","p","li","label",...F.map(e=>`[${e}]`)].join(","),Vt=/^(?:A|BUTTON|INPUT|SELECT|TEXTAREA|SUMMARY)$/;function _t(e){if(e.hasAttribute("hidden")||e.getAttribute("aria-hidden")==="true")return!1;const t=e.ownerDocument?.defaultView;if(t&&typeof t.getComputedStyle=="function"){const i=t.getComputedStyle(e);if(i.display==="none"||i.visibility==="hidden")return!1}return!0}function Kt(e={}){const t=e.root??document.body,i=e.selector??Ut,o=e.isExcluded??(()=>!1),n=e.isVisible??_t;return Array.from(t.querySelectorAll(i)).filter(s=>!o(s)&&n(s))}function jt(e){const t=e.candidates??Kt({root:e.root,selector:e.selector,isExcluded:e.isExcluded,isVisible:e.isVisible}),i=e.moveFocus??!0,o=e.eventTarget??document,n=new Set;let s=-1,a=!1;const d=e.initial!==void 0?e.initial:typeof document<"u"?document.activeElement:null;if(d){const h=t.indexOf(d);h>=0&&(s=h)}s<0&&t.length>0&&(s=0);function c(h){if(!i)return;const q=h;if(typeof q.focus=="function"){h.getAttribute("tabindex")===null&&!Vt.test(h.tagName)&&(h.setAttribute("tabindex","-1"),n.add(h));try{q.focus()}catch{}}}function r(){const h=t[s];h&&(c(h),e.onHighlight?.(h,s))}function l(h){if(a||t.length===0)return;const q=t.length;s=(h%q+q)%q,r()}function p(){l(s+1)}function u(){l(s-1)}function f(){return t[s]??null}function g(){a||(a=!0,o.removeEventListener("keydown",m,!0),n.forEach(h=>h.removeAttribute("tabindex")),n.clear())}function y(){if(a)return;const h=f();g(),h&&e.onSelect(h)}function w(){a||(g(),e.onCancel?.())}function m(h){if(!a)switch(h.key){case"Tab":h.preventDefault(),h.stopPropagation(),h.shiftKey?u():p();break;case"ArrowDown":case"ArrowRight":h.preventDefault(),h.stopPropagation(),p();break;case"ArrowUp":case"ArrowLeft":h.preventDefault(),h.stopPropagation(),u();break;case"Enter":case" ":case"Spacebar":h.preventDefault(),h.stopPropagation(),y();break;case"Escape":case"Esc":h.preventDefault(),h.stopPropagation(),w();break}}return o.addEventListener("keydown",m,!0),s>=0&&r(),{candidates:t,getIndex:()=>s,getCurrent:f,next:p,prev:u,moveTo:l,select:y,cancel:w,handleKey:m,stop:g}}const V="data-qaid-a11y-live",Wt="position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;",Xt=["a[href]","button","input","textarea","select","[tabindex]"].join(",");function Yt(e){return e.ownerDocument||document}function Qt(e,t){const i=t?"assertive":"polite",o=e.querySelector(`[${V}="${i}"]`);if(o)return o;const s=Yt(e).createElement("div");return s.setAttribute(V,i),s.setAttribute("role",t?"alert":"status"),s.setAttribute("aria-live",t?"assertive":"polite"),s.setAttribute("aria-atomic","true"),s.style.cssText=Wt,e.appendChild(s),s}function Gt(e,t,i={}){const o=Qt(e,!!i.assertive);o.textContent="",o.textContent=t}function Jt(e){return e.hasAttribute("disabled")?!0:e.disabled===!0}function Zt(e){let t=e;for(;t;){if(t.hasAttribute("hidden"))return!0;const i=t.style;if(i&&(i.display==="none"||i.visibility==="hidden"||i.visibility==="collapse"))return!0;t=t.parentElement}return!1}function _(e){return Array.from(e.querySelectorAll(Xt)).filter(i=>!(i.getAttribute("tabindex")==="-1"||i instanceof HTMLInputElement&&i.type==="hidden"||i instanceof HTMLAnchorElement&&!i.getAttribute("href")||Jt(i)||Zt(i)))}function K(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null}function te(e){const t=e.ownerDocument||document;let i=!1;const o=s=>{if(s.key!=="Tab")return;const a=_(e);if(a.length===0){s.preventDefault(),e.focus();return}const d=a[0],c=a[a.length-1],r=K(t),l=r?a.indexOf(r)!==-1:!1;s.shiftKey?(!l||r===d)&&(s.preventDefault(),c.focus()):(!l||r===c)&&(s.preventDefault(),d.focus())};e.addEventListener("keydown",o);const n=_(e);return n.length>0?n[0].focus():(e.hasAttribute("tabindex")||(e.setAttribute("tabindex","-1"),i=!0),e.focus()),{release(){e.removeEventListener("keydown",o),i&&(e.removeAttribute("tabindex"),i=!1)}}}function ee(){return K(document)}function ie(e){if(!(!e||typeof e.focus!="function"))try{e.focus()}catch{}}function oe(e,t={}){e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),t.labelledbyId&&e.setAttribute("aria-labelledby",t.labelledbyId),t.describedbyId&&e.setAttribute("aria-describedby",t.describedbyId),t.label&&e.setAttribute("aria-label",t.label)}function ne(e,t){let i=e;for(;i&&i!==t;){const o=i.parentNode;if(o===t)return i;if(o&&o.host){i=o.host;continue}if(!o)return null;i=o}return null}function se(e){const i=(e.ownerDocument||document).body;if(!i)return()=>{};const o=ne(e,i),n=[];return Array.from(i.children).forEach(s=>{if(!(s instanceof HTMLElement)||o&&s===o)return;const a=s.inert===!0,d=s.getAttribute("aria-hidden");a&&d==="true"||(s.inert=!0,s.setAttribute("aria-hidden","true"),n.push({el:s,prevInert:a,prevAriaHidden:d}))}),function(){for(;n.length;){const a=n.pop();a.el.inert=a.prevInert,a.prevAriaHidden===null?a.el.removeAttribute("aria-hidden"):a.el.setAttribute("aria-hidden",a.prevAriaHidden)}}}const j={width:400,height:280,arrowHeight:12,gap:8,viewportPadding:16};function ae(e,t,i,o,n){const s=e.y,a=t-(e.y+e.height);if(a>=i+o)return{top:e.y+e.height+o,position:"below"};if(s>=i+o)return{top:e.y-i-o,position:"above"};const d=a>s?"below":"above";let c;return d==="below"?c=Math.min(e.y+e.height+o,t-i-n):c=Math.max(n,e.y-i-o),{top:c,position:d}}function re(e,t,i,o){let s=e.x+e.width/2-i/2;return s=Math.max(o,Math.min(s,t-i-o)),s}function de(e,t,i,o=24,n=24){const a=e.clickX-t-n/2;return Math.max(o,Math.min(a,i-o-n/2))}function le(e,t,i,o=j){const n=o.height+o.arrowHeight,s=ae(e,i,n,o.gap,o.viewportPadding),a=re(e,t,o.width,o.viewportPadding);return{top:s.top,left:a,position:s.position}}function ce(e,t,i,o={}){const n=o.gap??8;let s=e.bottom+n;s+t.height>i.height-n&&(s=e.top-t.height-n);let a=e.left;return a<n?a=n:a+t.width>i.width-n&&(a=i.width-t.width-n),s<n?s=n:s+t.height>i.height-n&&(s=i.height-t.height-n),{top:s,left:a}}function he(e,t,i,o=j){const n=le(e,t,i,o),s=de(e,n.left,o.width);return{modal:n,arrow:{left:s}}}const ue=20;function pe(e){const t=[],i=console.error,o=console.warn,n=console.log,s=(a,d)=>{const c={message:d.map(r=>String(r)).join(" "),timestamp:Date.now(),level:a};t.length>=ue&&t.shift(),t.push(c),e&&e(c)};return console.error=function(...a){s("error",a),i.apply(console,a)},console.warn=function(...a){s("warn",a),o.apply(console,a)},console.log=function(...a){s("log",a),n.apply(console,a)},{errors:t,restore:()=>{console.error=i,console.warn=o,console.log=n}}}const fe=20,W=4096;function L(e){const t=typeof e=="string"?e:JSON.stringify(e);return t.length>W?t.slice(0,W)+"…[truncated]":t}function X(e,t){e.length>=fe&&e.shift(),e.push(t)}async function me(e){try{const t=await e.clone().text();return L(t)}catch{return}}function Y(){const e=[],t=window.fetch;window.fetch=async function(n,s){const a=typeof n=="string"?n:n instanceof URL?n.toString():n.url,d=s?.method??(typeof n=="object"&&"method"in n?n.method:"GET");let c;s?.body&&(c=L(s.body));const r=await t.apply(window,[n,s]);if(r.status>=400){const l=await me(r);X(e,{url:a,method:d.toUpperCase(),status:r.status,statusText:r.statusText,requestBody:c,responseBody:l,timestamp:Date.now()})}return r};const i=XMLHttpRequest.prototype.open,o=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(n,s,...a){return this._qaid_method=n,this._qaid_url=typeof s=="string"?s:s.toString(),i.apply(this,[n,s,...a])},XMLHttpRequest.prototype.send=function(n){const s=this,a=n?L(n):void 0;return s.addEventListener("load",function(){s.status>=400&&X(e,{url:s._qaid_url,method:s._qaid_method.toUpperCase(),status:s.status,statusText:s.statusText,requestBody:a,responseBody:L(s.responseText),timestamp:Date.now()})}),o.apply(this,[n])},{errors:e,restore:()=>{window.fetch=t,XMLHttpRequest.prototype.open=i,XMLHttpRequest.prototype.send=o}}}function be(){const e=navigator.userAgent||"";return/iP(hone|ad|od)/.test(e)||navigator.platform==="MacIntel"&&(navigator.maxTouchPoints||0)>1}function ge(e,t,i,o,n){const s=e>=t,a=i>=o;return s===a?{width:e,height:t,rotate:0}:{width:t,height:e,rotate:n===270?-90:90}}function ve(e,t,i){if(i.rotate===0){e.drawImage(t,0,0,i.width,i.height);return}e.save(),i.rotate===90?(e.translate(i.width,0),e.rotate(Math.PI/2)):(e.translate(0,i.height),e.rotate(-Math.PI/2)),e.drawImage(t,0,0,i.height,i.width),e.restore()}function ye(){const e=typeof screen<"u"?screen.orientation:void 0;return e&&typeof e.angle=="number"?e.angle:0}function we(e){return new Promise(t=>{if(e.videoWidth>0){t();return}e.addEventListener("loadedmetadata",()=>t(),{once:!0})})}async function qe(e){try{await e.play()}catch{}}async function ke(e,t=15){const i=document.createElement("canvas");if(typeof i.captureStream!="function")return null;const o=i.getContext("2d");if(!o)return null;const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=e,await we(n);const s=ge(n.videoWidth,n.videoHeight,window.innerWidth,window.innerHeight,ye());i.width=s.width,i.height=s.height,await qe(n);let a=0;const d=()=>{ve(o,n,s),a=requestAnimationFrame(d)};d();const c=i.captureStream(t);return{stream:c,stop:()=>{a&&cancelAnimationFrame(a),a=0,c.getTracks().forEach(r=>r.stop()),n.pause(),n.srcObject=null}}}function Q(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}function G(){if(typeof MediaRecorder>"u")return"";const e=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(const t of e)if(MediaRecorder.isTypeSupported(t))return t;return""}function J(e={}){const t=e.maxDuration??15,i=e.videoBitsPerSecond??8e5;let o=null,n=null,s=null,a=[],d=null,c=null,r=null,l=0,p=null,u=null,f=!1,g=null;function y(){r!==null&&(clearInterval(r),r=null),g!==null&&(clearTimeout(g),g=null),n&&(n.stop(),n=null),o&&(o.getTracks().forEach(m=>m.stop()),o=null),s=null,a=[],d=null,c=null,p=null,u=null}function w(){f||(f=!0,s&&s.state!=="inactive"&&s.stop())}return{async start(){f=!1,a=[];const m=G();if(!m)throw new Error("No supported video MIME type found");o=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15},audio:!1,preferCurrentTab:!0});const h=o.getVideoTracks()[0];h&&h.addEventListener("ended",()=>{w()});let q=o;if(be()){const v=await ke(o);v&&(n=v,q=v.stream)}s=new MediaRecorder(q,{mimeType:m,videoBitsPerSecond:i}),s.ondataavailable=v=>{v.data.size>0&&a.push(v.data)},s.onstop=()=>{const v=new Blob(a,{type:m});p&&p(v),c&&c(v),n&&(n.stop(),n=null),o&&o.getTracks().forEach(D=>D.stop())},s.onerror=()=>{u&&u(new Error("MediaRecorder error"))},s.start(1e3),l=Date.now(),r=setInterval(()=>{const v=Math.floor((Date.now()-l)/1e3);d&&d(v)},1e3),g=setTimeout(()=>{w()},t*1e3)},stop(){return new Promise((m,h)=>{p=m,u=h,w()})},onTick(m){d=m},onStop(m){c=m},destroy(){w(),y()}}}function k(e,t,i){const o=document.createElement(e);if(t)for(const[n,s]of Object.entries(t))n==="className"?o.className=s:o.setAttribute(n,s);return o}function xe(e=640){return typeof window<"u"&&window.innerWidth<e}function Z(e,t,i){const o=i.map(s=>s.style.visibility);i.forEach(s=>s.style.visibility="hidden");const n=document.elementFromPoint(e,t);return i.forEach((s,a)=>s.style.visibility=o[a]),n}function B(e){return e?e.hasAttribute("data-qaid-embed")||e.hasAttribute("data-qaid-embed-overlay")?!0:!!e.closest("[data-qaid-embed], [data-qaid-embed-overlay]"):!1}function tt(e,t=0){const i=e.getBoundingClientRect();return{x:i.left-t,y:i.top-t,width:i.width+t*2,height:i.height+t*2}}async function Ce(e={}){const{quality:t=1,maxWidth:i=1280,maxHeight:o=800}=e;try{if(!navigator.mediaDevices?.getDisplayMedia)return console.warn("Screen Capture API not available"),null;const n=await navigator.mediaDevices.getDisplayMedia({preferCurrentTab:!0,video:{displaySurface:"browser"}}),s=n.getVideoTracks()[0],a=s.getSettings(),d=document.createElement("video");d.srcObject=n,d.muted=!0,await new Promise(y=>{d.onloadedmetadata=()=>{d.play(),y()}}),await new Promise(y=>{const w=()=>{d.readyState>=2?y():requestAnimationFrame(w)};w()}),await new Promise(y=>setTimeout(y,100));const c=a.width||d.videoWidth,r=a.height||d.videoHeight,l=Math.min(i/c,o/r,1),p=Math.round(c*l),u=Math.round(r*l),f=document.createElement("canvas");f.width=p,f.height=u;const g=f.getContext("2d");return g?(g.drawImage(d,0,0,p,u),s.stop(),f.toDataURL("image/webp",t)):(s.stop(),null)}catch(n){return console.warn("Screenshot capture failed:",n),null}}const et="https://qaid.dev/lib/html2canvas.min.js",Ee=1e4,Se=50;let S=null;function Te(){if(typeof document>"u"||typeof window>"u")return!1;const e=document.createElement("canvas");return typeof e.getContext=="function"&&!!e.getContext("2d")}function Le(){return window.html2canvas?Promise.resolve(!0):S||(S=new Promise(e=>{if(!document.querySelector(`script[src="${et}"]`)){const n=document.createElement("script");n.src=et,n.async=!0,document.head.appendChild(n)}const i=Date.now(),o=()=>{if(window.html2canvas){e(!0);return}if(Date.now()-i>Ee){S=null,e(!1);return}setTimeout(o,Se)};o()}),S)}async function it(e={}){const{quality:t=.8,maxWidth:i=1280,maxHeight:o=800}=e;try{if(!await Le()||!window.html2canvas)return console.warn("html2canvas failed to load"),null;const s=await window.html2canvas(document.body,{useCORS:!0,allowTaint:!1,logging:!1,windowWidth:document.documentElement.clientWidth,windowHeight:document.documentElement.clientHeight,width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,x:window.scrollX,y:window.scrollY,ignoreElements:r=>r instanceof HTMLElement?r.classList.contains("qaid-buttons")||r.classList.contains("qaid-targeting-overlay")||r.classList.contains("qaid-modal-container")||r.classList.contains("qaid-bottom-sheet")||r.classList.contains("qaid-backdrop")||r.classList.contains("qaid-selected-marker")||r.classList.contains("qaid-tooltip-text")||r.classList.contains("qaid-recording-indicator")||r.classList.contains("qaid-video-preview")||r.className?.toString().startsWith?.("qaid-"):!1}),a=s.width,d=s.height,c=Math.min(i/a,o/d,1);if(c<1){const r=Math.round(a*c),l=Math.round(d*c),p=document.createElement("canvas");p.width=r,p.height=l;const u=p.getContext("2d");return u?(u.drawImage(s,0,0,r,l),p.toDataURL("image/webp",t)):null}return s.toDataURL("image/webp",t)}catch(n){return console.warn("DOM screenshot capture failed:",n),null}}const C=12,Ae="#ef4444",Ie=4,De=.8,Me={title:"Annotate screenshot",instructions:"Draw on the screenshot to highlight or hide details, then choose Done to attach it or Skip to send the original.",rectangle:"Rectangle",arrow:"Arrow",pen:"Pen",blur:"Blur or redact",undo:"Undo last",skip:"Skip annotation",done:"Done"};function A(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function Re(e){if(e.type==="pen")return e.points.length<2;const t=A(e.points[0],e.points[1]);return t.w<3&&t.h<3}function Be(e,t,i,o){e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.stroke();const n=Math.atan2(i.y-t.y,i.x-t.x),s=Math.max(10,o*3);e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(i.x-s*Math.cos(n-Math.PI/6),i.y-s*Math.sin(n-Math.PI/6)),e.moveTo(i.x,i.y),e.lineTo(i.x-s*Math.cos(n+Math.PI/6),i.y-s*Math.sin(n+Math.PI/6)),e.stroke()}function He(e,t){if(t.length!==0){e.beginPath(),e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;i++)e.lineTo(t[i].x,t[i].y);e.stroke()}}function Pe(e,t,i,o,n){e.fillStyle="rgb(15, 23, 42)",e.fillRect(t,i,o,n),e.fillStyle="rgb(37, 47, 63)";for(let s=i;s<i+n;s+=C)for(let a=t;a<t+o;a+=C)(Math.floor((a-t)/C)+Math.floor((s-i)/C))%2===0&&e.fillRect(a,s,Math.min(C,t+o-a),Math.min(C,i+n-s))}function I(e,t){switch(e.save(),e.strokeStyle=t.color,e.fillStyle=t.color,e.lineWidth=t.strokeWidth,e.lineJoin="round",e.lineCap="round",t.type){case"rect":{const i=A(t.points[0],t.points[1]);e.strokeRect(i.x,i.y,i.w,i.h);break}case"arrow":Be(e,t.points[0],t.points[1],t.strokeWidth);break;case"pen":He(e,t.points);break;case"blur":{const i=A(t.points[0],t.points[1]);Pe(e,i.x,i.y,i.w,i.h);break}}e.restore()}function ot(e){return new Promise((t,i)=>{const o=new Image;o.onload=()=>t(o),o.onerror=()=>i(new Error("Failed to load screenshot")),o.src=e})}async function nt(e,t,i={}){const o=i.quality??De;let n;try{n=await ot(e)}catch{return e}const s=document.createElement("canvas");s.width=n.naturalWidth||n.width||1,s.height=n.naturalHeight||n.height||1;const a=s.getContext("2d");if(!a)return e;a.drawImage(n,0,0,s.width,s.height);for(const d of t)I(a,d);return s.toDataURL("image/webp",o)}let Oe=0;class st{shapes=[];tool="rect";opts;labels;color;strokeWidth;uid=`qaid-annotate-${++Oe}`;container;canvas;ctx=null;toolbar;undoBtn;img=null;drawing=!1;current=null;settled=!1;resolveResult;constructor(t){this.opts=t,this.labels={...Me,...t.labels??{}},this.color=t.color??Ae,this.strokeWidth=t.strokeWidth??Ie}open(){const t=new Promise(i=>{this.resolveResult=i});return this.mount(),t}toolButton(t,i,o){const n=k("button",{type:"button",class:"qaid-annotate-tool","data-qaid-tool":t,"aria-pressed":t===this.tool?"true":"false","aria-label":`${o} tool`,title:o});return n.innerHTML=i,n}actionButton(t,i,o,n){const s=k("button",{type:"button",class:`qaid-annotate-action ${n}`,"data-qaid-action":t,"aria-label":o,title:o});return s.innerHTML=`${i}<span class="qaid-annotate-btn-text">${o}</span>`,s}mount(){const t=`${this.uid}-title`,i=`${this.uid}-desc`;this.container=k("div",{class:"qaid-annotate"}),this.opts.applyVars?.(this.container);const o=k("h2",{id:t,class:"qaid-annotate-title"});o.textContent=this.labels.title;const n=k("p",{id:i,class:"qaid-annotate-desc"});n.textContent=this.labels.instructions;const s=k("div",{class:"qaid-annotate-stage"});this.canvas=document.createElement("canvas"),this.canvas.className="qaid-annotate-canvas",this.canvas.width=1,this.canvas.height=1,this.canvas.setAttribute("role","img"),this.canvas.setAttribute("aria-label",this.labels.title),this.ctx=this.canvas.getContext("2d"),s.appendChild(this.canvas),this.toolbar=k("div",{class:"qaid-annotate-toolbar",role:"toolbar","aria-label":this.labels.title});const a=k("div",{class:"qaid-annotate-tools"});a.appendChild(this.toolButton("rect",vt,this.labels.rectangle)),a.appendChild(this.toolButton("arrow",yt,this.labels.arrow)),a.appendChild(this.toolButton("pen",wt,this.labels.pen)),a.appendChild(this.toolButton("blur",qt,this.labels.blur)),this.undoBtn=this.actionButton("undo",kt,this.labels.undo,"qaid-annotate-undo"),this.undoBtn.disabled=!0;const d=this.actionButton("skip",Ct,this.labels.skip,"qaid-annotate-skip"),c=this.actionButton("done",xt,this.labels.done,"qaid-annotate-done"),r=k("div",{class:"qaid-annotate-actions"});r.appendChild(this.undoBtn),r.appendChild(d),r.appendChild(c),this.toolbar.appendChild(a),this.toolbar.appendChild(r),this.container.appendChild(o),this.container.appendChild(n),this.container.appendChild(s),this.container.appendChild(this.toolbar),this.opts.root.appendChild(this.container),this.toolbar.addEventListener("click",this.onToolbarClick),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp),this.container.addEventListener("keydown",this.onKeyDown),this.opts.openDialog?.(this.container,{labelledbyId:t,describedbyId:i}),this.opts.announce?.(this.labels.instructions),ot(this.opts.dataUrl).then(l=>{this.img=l,this.canvas.width=l.naturalWidth||l.width||1,this.canvas.height=l.naturalHeight||l.height||1,this.redraw()}).catch(()=>{this.img=null,this.redraw()})}toImageCoords(t){const i=this.canvas.getBoundingClientRect(),o=this.canvas.width/(i.width||this.canvas.width),n=this.canvas.height/(i.height||this.canvas.height);return{x:(t.clientX-i.left)*o,y:(t.clientY-i.top)*n}}redraw(){const t=this.ctx;if(t){t.clearRect(0,0,this.canvas.width,this.canvas.height),this.img&&t.drawImage(this.img,0,0,this.canvas.width,this.canvas.height);for(const i of this.shapes)I(t,i);this.current&&I(t,this.current)}}selectTool(t){this.tool=t,this.toolbar.querySelectorAll("[data-qaid-tool]").forEach(n=>{n.setAttribute("aria-pressed",n.getAttribute("data-qaid-tool")===t?"true":"false")});const o=this.labels[ze[t]];this.opts.announce?.(`${o} tool selected`)}onToolbarClick=t=>{const o=t.target?.closest("[data-qaid-tool],[data-qaid-action]");if(!o)return;const n=o.getAttribute("data-qaid-tool");if(n){this.selectTool(n);return}const s=o.getAttribute("data-qaid-action");s==="undo"?this.undo():s==="skip"?this.skip():s==="done"&&this.done()};onPointerDown=t=>{t.preventDefault?.(),this.drawing=!0;const i=this.toImageCoords(t);this.current={type:this.tool,color:this.color,strokeWidth:this.strokeWidth,points:this.tool==="pen"?[i]:[i,{...i}]},this.redraw()};onPointerMove=t=>{if(!this.drawing||!this.current)return;const i=this.toImageCoords(t);this.current.type==="pen"?this.current.points.push(i):this.current.points[1]=i,this.redraw()};onPointerUp=()=>{if(!this.drawing||!this.current)return;this.drawing=!1;const t=this.current;if(this.current=null,Re(t)){this.redraw();return}this.shapes.push(t),this.undoBtn.disabled=!1,this.opts.announce?.("Annotation added"),this.redraw()};onKeyDown=t=>{if(t.key==="Escape"){t.preventDefault(),this.skip();return}if(t.key==="Enter"){const i=t.target;if(i?.getAttribute("data-qaid-tool")||i?.getAttribute("data-qaid-action"))return;t.preventDefault(),this.done()}};undo(){if(this.shapes.length===0){this.opts.announce?.("Nothing to undo");return}this.shapes.pop(),this.undoBtn.disabled=this.shapes.length===0,this.opts.announce?.("Removed last annotation"),this.redraw()}async done(){if(this.settled)return;const t=await nt(this.opts.dataUrl,this.shapes,{quality:this.opts.quality});this.opts.announce?.("Annotated screenshot attached"),this.settle(t)}skip(){this.settled||(this.opts.announce?.("Annotation skipped"),this.settle(null))}settle(t){this.settled=!0,this.teardown(),this.resolveResult(t)}teardown(){this.toolbar.removeEventListener("click",this.onToolbarClick),this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.container.removeEventListener("pointermove",this.onPointerMove),this.container.removeEventListener("pointerup",this.onPointerUp),this.container.removeEventListener("keydown",this.onKeyDown),this.opts.closeDialog?.(),this.container.remove()}}const ze={rect:"rectangle",arrow:"arrow",pen:"pen",blur:"blur"};function at(e){return new st(e).open()}const $e="https://unpkg.com/@qaiddev/quests-embed@1/dist/qaid-quests.js";let Ne=e=>import(e),T=null,H=null;function Fe(e){return T&&H===e||(H=e,T=Promise.resolve(Ne(e)).then(t=>{const i=t;if(!i||typeof i.QaidQuests!="function")throw new Error("quests module has no QaidQuests export");return i}).catch(t=>{throw T=null,H=null,t})),T}async function Ue(e){const t=await Fe(e.moduleUrl),i=e.base.replace(/\/+$/,""),o=e.feedbackId!=null?{feedbackId:e.feedbackId}:void 0;return new t.QaidQuests({endpoint:`${i}/responses`,configUrl:`${i}/${encodeURIComponent(e.questId)}/definition`,apiKey:e.apiKey||void 0,metadata:o,onClose:e.onClose})}const rt="qaid_visitor_id",dt="qaid_hide_feedback",Ve=12;function _e(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function P(e){return e?`${dt}_${e}`:dt}function Ke(e){try{return localStorage.getItem(P(e))==="1"}catch{return!1}}function lt(e,t=!0){try{t?localStorage.setItem(P(e),"1"):localStorage.removeItem(P(e))}catch{}}function je(){try{let e=localStorage.getItem(rt);return e||(e=crypto.randomUUID(),localStorage.setItem(rt,e)),e}catch{return crypto.randomUUID()}}class ct{config;state="IDLE";feedbackData={feedbackType:null,elementSelector:null,elementText:null,consoleErrors:[]};selectedBounds={x:0,y:0,width:0,height:0,clickX:0,clickY:0,visible:!1};feedbackId=null;activeQuest=null;mousePos={x:0,y:0};isMobile=!1;visitorId;consoleCapture=null;videoRecorder=null;networkCapture=null;recordedBlob=null;recordingIndicator=null;videoPreview=null;isRecording=!1;isSendingVideo=!1;shadowHost=null;shadowRoot=null;overlayShadowHost=null;overlayShadowRoot=null;buttonsContainer=null;isUserProvidedContainer=!1;overlayContainer=null;captureLayer=null;crosshairH=null;crosshairV=null;scope=null;highlightBox=null;marker=null;modalContainer=null;backdrop=null;dismissBtn=null;cssVars={};keyboardController=null;activeThumbBtn=null;keyboardActivation=!1;dialogTrigger=null;dialogTrap=null;dialogRestoreInert=null;uid=Math.random().toString(36).slice(2,9);boundKeyDown;boundMouseMove;boundClick;boundTouchStart;boundTouchEnd;touchStartPos=null;boundResize;_startDismissed=!1;destroyed=!1;domObserver=null;boundBeforeSwap=null;constructor(t){this.config={endpoint:t.endpoint,apiKey:t.apiKey??"",container:t.container??"",buttonClass:t.buttonClass??"",direction:t.direction??"horizontal",position:t.position??"bottom-right",offset:{x:t.offset?.x??16,y:t.offset?.y??16},zIndex:t.zIndex??50,skipTargeting:t.skipTargeting??!1,colors:{positive:t.colors?.positive??"rgb(0, 200, 83)",negative:t.colors?.negative??"rgb(255, 0, 0)",marker:t.colors?.marker??"#6366f1"},buttonSize:t.buttonSize??"medium",text:{tooltip:t.text?.tooltip??"",modalTitle:t.text?.modalTitle??"Thank you for your feedback!",modalSubtitle:t.text?.modalSubtitle??"Would you like to add a message to help us understand your feedback better?",placeholder:t.text?.placeholder??"Optional: Tell us more about your experience...",submitButton:t.text?.submitButton??"Submit",skipButton:t.text?.skipButton??"Skip",positiveLabel:t.text?.positiveLabel??"Send positive feedback",negativeLabel:t.text?.negativeLabel??"Send negative feedback",recordLabel:t.text?.recordLabel??"Record a screen recording",dismissLabel:t.text?.dismissLabel??"Hide Feedback"},modalWidth:t.modalWidth??400,backdropOpacity:t.backdropOpacity??.3,fontFamily:t.fontFamily??"system-ui, -apple-system, sans-serif",fontSize:t.fontSize??16,captureScreenshot:t.captureScreenshot??!1,annotate:t.annotate??!0,screenshotMethod:t.screenshotMethod??"permission",screenshotOptions:{quality:t.screenshotOptions?.quality??.8,maxWidth:t.screenshotOptions?.maxWidth??1280,maxHeight:t.screenshotOptions?.maxHeight??800},incognito:t.incognito??!1,hideDismiss:t.hideDismiss??!1,positiveIcon:t.positiveIcon??"",negativeIcon:t.negativeIcon??"",hideThumbs:t.hideThumbs??!1,css:t.css??"",captureVideo:t.captureVideo??!1,videoOptions:{maxDuration:t.videoOptions?.maxDuration??15},recordIcon:t.recordIcon??"",quests:{base:t.quests?.base??"",up:t.quests?.up??"",down:t.quests?.down??"",video:t.quests?.video??"",apiKey:t.quests?.apiKey??t.apiKey??"",moduleUrl:t.quests?.moduleUrl??$e}},this.boundKeyDown=this.handleKeyDown.bind(this),this.boundMouseMove=this.handleMouseMove.bind(this),this.boundClick=this.handleClick.bind(this),this.boundTouchStart=this.handleTouchStart.bind(this),this.boundTouchEnd=this.handleTouchEnd.bind(this),this.boundResize=this.handleResize.bind(this),this.visitorId=je(),this.init()}applyVars(t){Bt(t,this.cssVars)}announceMsg(t,i=!1){const o=this.overlayShadowRoot??this.shadowRoot;o&&Gt(o,t,{assertive:i})}openDialogA11y(t,i){this.dialogTrigger=ee(),oe(t,i),this.dialogTrap=te(t),this.dialogRestoreInert=se(t)}closeDialogA11y(){this.dialogTrap?.release(),this.dialogTrap=null,this.dialogRestoreInert&&(this.dialogRestoreInert(),this.dialogRestoreInert=null),ie(this.dialogTrigger),this.dialogTrigger=null}clearActiveThumb(){this.activeThumbBtn&&(this.activeThumbBtn.setAttribute("aria-pressed","false"),this.activeThumbBtn=null)}init(){Ht(),this.cssVars=Rt({positiveColor:this.config.colors.positive,negativeColor:this.config.colors.negative,markerColor:this.config.colors.marker,buttonSize:this.config.buttonSize,modalWidth:this.config.modalWidth,backdropOpacity:this.config.backdropOpacity,fontFamily:this.config.fontFamily,fontSize:this.config.fontSize}),!this.config.hideDismiss&&Ke(this.config.apiKey)&&(this._startDismissed=!0),this.checkMobile(),window.addEventListener("resize",this.boundResize),this.createEmbed(),this.consoleCapture=pe(t=>{this.feedbackData.consoleErrors=this.consoleCapture?.errors??[]}),this.feedbackData.consoleErrors=this.consoleCapture.errors,this.observeDom()}observeDom(){this.boundBeforeSwap=t=>{const i=t.newDocument;!i||this.destroyed||(this.shadowHost&&i.body.appendChild(this.shadowHost),this.overlayShadowHost&&i.body.appendChild(this.overlayShadowHost))},document.addEventListener("astro:before-swap",this.boundBeforeSwap),this.domObserver=new MutationObserver(()=>{this.destroyed||(this.shadowHost&&!this.shadowHost.isConnected&&document.body.appendChild(this.shadowHost),this.overlayShadowHost&&!this.overlayShadowHost.isConnected&&document.body.appendChild(this.overlayShadowHost))}),this.domObserver.observe(document.body,{childList:!0})}checkMobile(){this.isMobile=xe()}handleResize(){this.checkMobile()}createEmbed(){this.shadowHost=document.createElement("div"),this.shadowHost.setAttribute("data-qaid-embed",""),this.shadowHost.style.position="static",this.shadowHost.style.display="contents";let t=null;this.config.container&&(t=document.querySelector(this.config.container)),t?(t.appendChild(this.shadowHost),this.isUserProvidedContainer=!0,this.config.hideDismiss=!0):(this.shadowHost.style.position="fixed",this.shadowHost.style.display="block",this.shadowHost.style.inset="0",this.shadowHost.style.pointerEvents="none",this.shadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.shadowHost)),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"});const i=document.createElement("style");if(i.textContent=N(),this.shadowRoot.appendChild(i),this.config.css){const r=document.createElement("style");r.textContent=this.config.css,this.shadowRoot.appendChild(r)}const o=this.config.direction==="vertical"?"qaid-vertical":"";if(this.isUserProvidedContainer)this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-${this.config.position} ${o}`.trim(),this.config.incognito&&this.buttonsContainer.classList.add("qaid-incognito");else{this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-auto-container qaid-${this.config.position} ${o}${this.config.incognito?" qaid-incognito":""}`.trim(),this.buttonsContainer.style.pointerEvents="auto";const{x:r,y:l}=this.config.offset;this.config.position.includes("right")?this.buttonsContainer.style.right=`${r}px`:this.buttonsContainer.style.left=`${r}px`,this.config.position.includes("bottom")?this.buttonsContainer.style.bottom=`${l}px`:this.buttonsContainer.style.top=`${l}px`}this.applyVars(this.buttonsContainer),this.shadowRoot.appendChild(this.buttonsContainer),this.buttonsContainer.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" "||r.key==="Spacebar")&&(this.keyboardActivation=!0)}),this.buttonsContainer.addEventListener("mousedown",()=>{this.keyboardActivation=!1}),this.buttonsContainer.addEventListener("pointerdown",()=>{this.keyboardActivation=!1});const n=!!this.config.buttonClass,s=n?`qaid-btn-structural ${this.config.buttonClass}`:"qaid-btn",d=this.config.text.tooltip||"Feedback for us?",c=document.createElement("div");if(c.className="qaid-tooltip-text",c.textContent=d,this.applyVars(c),this.shadowRoot.appendChild(c),this.tooltipElement=c,!this.config.hideThumbs){const r=document.createElement("div");r.className="qaid-tooltip-wrapper";const l=document.createElement("button");l.type="button",l.className=n?`${s} qaid-btn-up`:"qaid-btn qaid-btn-up",l.setAttribute("aria-label",this.config.text.positiveLabel),l.innerHTML=this.config.positiveIcon||x,l.addEventListener("click",f=>this.handleThumbClick("up",f.currentTarget,f)),l.addEventListener("mouseenter",()=>this.showTooltip(l)),l.addEventListener("mouseleave",()=>this.hideTooltip()),r.appendChild(l);const p=document.createElement("div");p.className="qaid-tooltip-wrapper";const u=document.createElement("button");u.type="button",u.className=n?`${s} qaid-btn-down`:"qaid-btn qaid-btn-down",u.setAttribute("aria-label",this.config.text.negativeLabel),u.innerHTML=this.config.negativeIcon||M,u.addEventListener("click",f=>this.handleThumbClick("down",f.currentTarget,f)),u.addEventListener("mouseenter",()=>this.showTooltip(u)),u.addEventListener("mouseleave",()=>this.hideTooltip()),p.appendChild(u),this.buttonsContainer.appendChild(r),this.buttonsContainer.appendChild(p)}if(this.config.captureVideo&&Q()){const r=document.createElement("div");r.className="qaid-tooltip-wrapper";const l=document.createElement("button");l.type="button",l.className=n?`${s} qaid-btn-record`:"qaid-btn qaid-btn-record",l.setAttribute("aria-label",this.config.text.recordLabel),l.innerHTML=this.config.recordIcon||gt,l.addEventListener("click",()=>this.startRecording()),l.addEventListener("mouseenter",()=>this.showTooltip(l)),l.addEventListener("mouseleave",()=>this.hideTooltip()),r.appendChild(l),this.buttonsContainer.appendChild(r)}this.config.hideDismiss||(this.dismissBtn=document.createElement("button"),this.dismissBtn.type="button",this.dismissBtn.className="qaid-dismiss-btn",this.dismissBtn.setAttribute("aria-label",this.config.text.dismissLabel),this.dismissBtn.title=this.config.text.dismissLabel,this.dismissBtn.innerHTML='<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>',this.dismissBtn.addEventListener("click",r=>{r.stopPropagation(),this.handleDismiss()}),this.buttonsContainer.insertBefore(this.dismissBtn,this.buttonsContainer.firstChild),this._startDismissed&&this.buttonsContainer.classList.add("qaid-dismissed"))}ensureOverlayHost(){if(this.overlayShadowRoot)return this.overlayShadowRoot;this.overlayShadowHost=document.createElement("div"),this.overlayShadowHost.setAttribute("data-qaid-embed-overlay",""),this.overlayShadowHost.style.position="fixed",this.overlayShadowHost.style.inset="0",this.overlayShadowHost.style.pointerEvents="none",this.overlayShadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.overlayShadowHost),this.overlayShadowRoot=this.overlayShadowHost.attachShadow({mode:"open"});const t=document.createElement("style");if(t.textContent=N(),this.overlayShadowRoot.appendChild(t),this.config.css){const i=document.createElement("style");i.textContent=this.config.css,this.overlayShadowRoot.appendChild(i)}return this.overlayShadowRoot}tooltipElement=null;showTooltip(t){const i=this.tooltipElement;i.style.visibility="hidden",i.classList.add("qaid-tooltip-visible");const o=t.getBoundingClientRect(),n=i.getBoundingClientRect(),{top:s,left:a}=ce(o,n,{width:window.innerWidth,height:window.innerHeight});i.style.top=`${s}px`,i.style.left=`${a}px`,i.style.visibility="visible"}hideTooltip(){this.tooltipElement.classList.remove("qaid-tooltip-visible")}handleDismiss(){this.buttonsContainer.classList.add("qaid-dismissed"),lt(this.config.apiKey,!0)}handleThumbClick(t,i,o){if(this.buttonsContainer?.classList.contains("qaid-incognito")&&(this.buttonsContainer.classList.remove("qaid-incognito"),lt(this.config.apiKey,!1)),this.config.skipTargeting)this.submitDirectFeedback(t,i);else{this.activeThumbBtn=i,i.setAttribute("aria-pressed","true");const n=this.keyboardActivation;this.keyboardActivation=!1,n?this.startKeyboardTargetingFlow(t):this.startTargeting(t,o)}}submitDirectFeedback(t,i){this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null;const o=i.getBoundingClientRect();this.selectedBounds={x:o.left,y:o.top,width:o.width,height:o.height,clickX:o.left+o.width/2,clickY:o.top+o.height/2,visible:!1},this.submitFeedback()}startTargeting(t,i){this.state="TARGETING",this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1,this.mousePos.x=i.clientX,this.mousePos.y=i.clientY,document.body.classList.add("qaid-targeting"),t==="up"?document.body.classList.add("qaid-type-up"):document.body.classList.remove("qaid-type-up"),document.body.style.setProperty("--qaid-positive",this.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.cssVars["--qaid-negative"]),this.createTargetingOverlay(),document.addEventListener("keydown",this.boundKeyDown),document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("click",this.boundClick,!0),document.addEventListener("touchstart",this.boundTouchStart,{passive:!0}),document.addEventListener("touchend",this.boundTouchEnd,{passive:!1})}startKeyboardTargetingFlow(t){this.state="TARGETING",this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1,document.body.style.setProperty("--qaid-positive",this.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.cssVars["--qaid-negative"]),this.createTargetingOverlay(),this.crosshairH&&(this.crosshairH.style.display="none"),this.crosshairV&&(this.crosshairV.style.display="none"),this.scope&&(this.scope.style.display="none"),this.keyboardController=jt({isExcluded:i=>B(i),onHighlight:i=>{const o=i.getBoundingClientRect(),n=this.highlightBox;n&&(n.style.transform=`translate(${o.left}px, ${o.top}px)`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`,n.style.display="block");const{text:s}=R(i);this.announceMsg(`Targeting ${s||i.tagName.toLowerCase()}`)},onSelect:i=>this.selectKeyboardTarget(i),onCancel:()=>this.cancelTargeting()})}selectKeyboardTarget(t){const i=tt(t,8);this.selectedBounds={...i,clickX:i.x+i.width/2,clickY:i.y+i.height/2,visible:!0};const{selector:o,text:n}=R(t);this.feedbackData.elementSelector=o,this.feedbackData.elementText=n,this.removeTargetingOverlay(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.keyboardController=null,this.clearActiveThumb(),this.state="SELECTED",this.showSelectedMarker(),this.submitFeedback()}createTargetingOverlay(){const t=this.ensureOverlayHost();this.overlayContainer=document.createElement("div"),this.overlayContainer.className=`qaid-targeting-overlay qaid-type-${this.feedbackData.feedbackType}`,this.captureLayer=document.createElement("div"),this.captureLayer.className="qaid-capture-layer";const i=document.createElement("div");i.className="qaid-vignette",this.crosshairH=document.createElement("div"),this.crosshairH.className="qaid-crosshair-h",this.crosshairV=document.createElement("div"),this.crosshairV.className="qaid-crosshair-v",this.scope=document.createElement("div"),this.scope.className="qaid-scope",this.scope.innerHTML=`
|
|
22
|
-
<div class="qaid-scope-ring"></div>
|
|
23
|
-
<div class="qaid-scope-ring-inner"></div>
|
|
24
|
-
<div class="qaid-scope-dot"></div>
|
|
25
|
-
`,this.highlightBox=document.createElement("div"),this.highlightBox.className="qaid-highlight-box",this.overlayContainer.appendChild(this.captureLayer),this.overlayContainer.appendChild(i),this.overlayContainer.appendChild(this.highlightBox),this.overlayContainer.appendChild(this.crosshairH),this.overlayContainer.appendChild(this.crosshairV),this.overlayContainer.appendChild(this.scope),this.crosshairH.style.top=`${this.mousePos.y}px`,this.crosshairV.style.left=`${this.mousePos.x}px`,this.scope.style.left=`${this.mousePos.x}px`,this.scope.style.top=`${this.mousePos.y}px`,this.applyVars(this.overlayContainer),t.appendChild(this.overlayContainer)}handleKeyDown(t){t.key==="Escape"&&(this.isRecording?this.stopRecording():this.videoPreview?this.cancelRecordingPreview():this.state==="TARGETING"?this.cancelTargeting():this.state==="MODAL_OPEN"&&this.closeModal())}handleMouseMove(t){this.updateReticleAt(t.clientX,t.clientY)}updateReticleAt(t,i){if(this.mousePos.x=t,this.mousePos.y=i,this.crosshairH&&(this.crosshairH.style.top=`${i}px`),this.crosshairV&&(this.crosshairV.style.left=`${t}px`),this.scope&&(this.scope.style.left=`${t}px`,this.scope.style.top=`${i}px`),this.captureLayer&&this.shadowHost){const o=[this.shadowHost,this.overlayShadowHost].filter(Boolean),n=Z(t,i,o);if(n&&!B(n)){if(this.highlightBox){const s=n.getBoundingClientRect();this.highlightBox.style.transform=`translate(${s.left}px, ${s.top}px)`,this.highlightBox.style.width=`${s.width}px`,this.highlightBox.style.height=`${s.height}px`,this.highlightBox.style.display="block"}}else this.highlightBox&&(this.highlightBox.style.display="none")}}handleClick(t){t.preventDefault(),t.stopPropagation(),this.selectAt(t.clientX,t.clientY)}handleTouchStart(t){const i=t.touches[0];i&&(this.touchStartPos={x:i.clientX,y:i.clientY},this.updateReticleAt(i.clientX,i.clientY))}handleTouchEnd(t){const i=t.changedTouches[0],o=this.touchStartPos;this.touchStartPos=null,!(!i||!o||Math.hypot(i.clientX-o.x,i.clientY-o.y)>Ve)&&(t.preventDefault(),this.selectAt(i.clientX,i.clientY))}selectAt(t,i){const o=[this.shadowHost,this.overlayShadowHost].filter(Boolean),n=Z(t,i,o);if(!n||B(n))return;const s=tt(n,8);this.selectedBounds={...s,clickX:t,clickY:i,visible:!0};const{selector:a,text:d}=R(n);this.feedbackData.elementSelector=a,this.feedbackData.elementText=d,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.state="SELECTED",this.clearActiveThumb(),this.showSelectedMarker(),this.submitFeedback()}stopTargetingListeners(){this.removeTargetingOverlay(),this.touchStartPos=null,document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),document.removeEventListener("touchstart",this.boundTouchStart),document.removeEventListener("touchend",this.boundTouchEnd),document.removeEventListener("keydown",this.boundKeyDown)}cancelTargeting(){this.keyboardController?.stop(),this.keyboardController=null,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.clearActiveThumb(),this.state="IDLE",this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1}removeTargetingOverlay(){this.overlayContainer&&(this.overlayContainer.remove(),this.overlayContainer=null),this.captureLayer=null,this.crosshairH=null,this.crosshairV=null,this.scope=null}showSelectedMarker(){const t=this.ensureOverlayHost();this.marker=document.createElement("div"),this.marker.className="qaid-selected-marker",this.marker.style.left=`${this.selectedBounds.x}px`,this.marker.style.top=`${this.selectedBounds.y}px`,this.marker.style.width=`${this.selectedBounds.width}px`,this.marker.style.height=`${this.selectedBounds.height}px`,this.marker.style.zIndex=String(this.config.zIndex+1),this.applyVars(this.marker),t.appendChild(this.marker)}hideSelectedMarker(){this.marker&&(this.marker.remove(),this.marker=null)}shouldCaptureViaDom(){return this.config.screenshotMethod==="dom"||_e()}async openAnnotationEditor(t){const i=this.ensureOverlayHost(),o=this.overlayShadowHost,n=o.style.pointerEvents;o.style.pointerEvents="auto";try{return await at({dataUrl:t,root:i,quality:this.config.screenshotOptions.quality,color:this.config.colors.marker,applyVars:s=>this.applyVars(s),announce:(s,a)=>this.announceMsg(s,a),openDialog:(s,a)=>this.openDialogA11y(s,a),closeDialog:()=>this.closeDialogA11y()})}finally{o.style.pointerEvents=n}}async submitFeedback(){let t=null;this.config.captureScreenshot&&(t=this.shouldCaptureViaDom()?await it(this.config.screenshotOptions):await Ce(this.config.screenshotOptions),t&&this.announceMsg("Screenshot captured")),t&&this.config.annotate&&(t=await this.openAnnotationEditor(t)??t);const i=this.feedbackData.elementSelector?{x:this.selectedBounds.x,y:this.selectedBounds.y,width:this.selectedBounds.width,height:this.selectedBounds.height}:null,o={feedbackType:this.feedbackData.feedbackType,pageUrl:window.location.href,apiKey:this.config.apiKey||void 0,elementSelector:this.feedbackData.elementSelector,elementText:this.feedbackData.elementText,consoleErrors:[...this.feedbackData.consoleErrors],screenWidth:window.innerWidth,screenHeight:window.innerHeight,clickX:this.selectedBounds.clickX,clickY:this.selectedBounds.clickY,scrollX:window.scrollX,scrollY:window.scrollY,screenshot:t,visitorId:this.visitorId,elementBounds:i,userAgent:navigator.userAgent};try{const s=await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(s.ok){const a=await s.json();this.feedbackId=a.id,this.announceMsg("Feedback sent")}}catch(s){console.error("Failed to submit feedback:",s),this.announceMsg("Failed to send feedback",!0)}const n=this.feedbackData.feedbackType;if(n&&await this.tryLaunchQuest(n,this.feedbackId)){this.resetFeedbackUi();return}this.state="MODAL_OPEN",this.showModal(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto")}questIdFor(t){const i=this.config.quests;return i.base&&i[t]||""}async tryLaunchQuest(t,i){const o=this.questIdFor(t);if(!o)return!1;try{return this.activeQuest?.destroy(),this.activeQuest=await Ue({questId:o,base:this.config.quests.base,apiKey:this.config.quests.apiKey||void 0,moduleUrl:this.config.quests.moduleUrl,feedbackId:i,onClose:()=>{this.activeQuest=null}}),!0}catch(n){return console.error("Failed to launch quest:",n),this.activeQuest=null,!1}}resetFeedbackUi(){this.hideSelectedMarker(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="none"),this.state="IDLE",this.feedbackId=null,this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1}showModal(){const t=this.ensureOverlayHost();this.backdrop=document.createElement("div"),this.backdrop.className="qaid-backdrop",this.backdrop.style.zIndex=String(this.config.zIndex+2),this.backdrop.style.background=`rgba(0, 0, 0, ${this.config.backdropOpacity})`,this.backdrop.addEventListener("click",()=>this.closeModal()),this.applyVars(this.backdrop),this.isMobile?this.showBottomSheet():this.showPositionedModal(),t.appendChild(this.backdrop),document.addEventListener("keydown",this.boundKeyDown)}showBottomSheet(){const t=this.ensureOverlayHost(),i=document.createElement("div");i.className="qaid-bottom-sheet",i.style.zIndex=String(this.config.zIndex+3),i.innerHTML=`
|
|
21
|
+
</svg>`,$t="button{cursor:pointer}.qaid-buttons{display:flex;gap:.5rem}.qaid-buttons.qaid-vertical{flex-direction:column}.qaid-buttons.qaid-auto-container{position:fixed;z-index:50}.qaid-buttons.qaid-auto-container.qaid-bottom-right{bottom:1rem;right:1rem}.qaid-buttons.qaid-auto-container.qaid-bottom-left{bottom:1rem;left:1rem}.qaid-buttons.qaid-auto-container.qaid-top-right{top:1rem;right:1rem}.qaid-buttons.qaid-auto-container.qaid-top-left{top:1rem;left:1rem}.qaid-buttons.qaid-incognito{opacity:0;transition:opacity .2s ease-in-out}.qaid-buttons.qaid-incognito:hover{opacity:1}.qaid-buttons.qaid-dismissed{display:none!important}.qaid-dismiss-btn{width:20px;height:20px;padding:0;border:none;border-radius:50%;background:#0006;color:#fff;display:flex;align-items:center;justify-content:center;align-self:center;opacity:0;transition:opacity .15s,background .15s;cursor:pointer;pointer-events:auto;-webkit-appearance:none;appearance:none}.qaid-dismiss-btn:hover{background:#0009}.qaid-buttons:hover .qaid-dismiss-btn{opacity:1}button.qaid-btn-structural{display:inline-flex;align-items:center;justify-content:center;cursor:pointer;-webkit-appearance:none;appearance:none}.qaid-icon{width:24px;height:24px}.qaid-btn-structural:not(:has(svg)),.qaid-btn:not(:has(svg)){font-size:var(--qaid-icon-size, 24px);line-height:1}.qaid-emoji-icon{font-size:var(--qaid-icon-size, 24px);line-height:1}.qaid-buttons,.qaid-buttons *,.qaid-modal-container,.qaid-modal-container *{cursor:pointer!important}.qaid-tooltip-wrapper{position:relative}.qaid-tooltip-text{position:fixed;padding:.5rem .75rem;background:#1f2937;color:#fff;font-size:1rem;font-weight:600;border-radius:.5rem;white-space:nowrap;opacity:0;pointer-events:none;transition:opacity .15s;z-index:99999}.qaid-tooltip-text.qaid-tooltip-visible{opacity:1}.qaid-targeting-overlay{position:fixed;inset:0;z-index:40;pointer-events:none}.qaid-capture-layer{position:fixed;inset:0;pointer-events:none;z-index:9999}@keyframes qaid-slideDown{0%{transform:translateY(-100%)}to{transform:translateY(0)}}.qaid-vignette{position:fixed;inset:0;pointer-events:none;background:radial-gradient(ellipse at center,transparent 30%,rgba(0,0,0,.3) 70%,rgba(0,0,0,.6) 100%);z-index:41}.qaid-crosshair-h,.qaid-crosshair-v{position:fixed;pointer-events:none;z-index:42}.qaid-crosshair-h{left:0;right:0;height:1px;background:color-mix(in srgb,var(--qaid-negative) 60%,transparent)}.qaid-crosshair-v{top:0;bottom:0;width:1px;background:color-mix(in srgb,var(--qaid-negative) 60%,transparent)}.qaid-type-up .qaid-crosshair-h,.qaid-type-up .qaid-crosshair-v{background:color-mix(in srgb,var(--qaid-positive) 60%,transparent)}.qaid-highlight-box{position:fixed;top:0;left:0;pointer-events:none;z-index:41;display:none;border:3px solid color-mix(in srgb,var(--qaid-negative) 80%,transparent);border-radius:2px;background:color-mix(in srgb,var(--qaid-negative) 8%,transparent);will-change:transform,width,height}.qaid-type-up .qaid-highlight-box{border-color:color-mix(in srgb,var(--qaid-positive) 80%,transparent);background:color-mix(in srgb,var(--qaid-positive) 8%,transparent)}.qaid-scope{position:fixed;width:80px;height:80px;pointer-events:none;z-index:43;transform:translate(-50%,-50%)}.qaid-scope-ring{position:absolute;inset:10px;border:2px solid color-mix(in srgb,var(--qaid-negative) 80%,transparent);border-radius:50%}.qaid-type-up .qaid-scope-ring{border-color:color-mix(in srgb,var(--qaid-positive) 80%,transparent)}.qaid-scope-ring-inner{position:absolute;inset:20px;border:1px solid color-mix(in srgb,var(--qaid-negative) 50%,transparent);border-radius:50%}.qaid-type-up .qaid-scope-ring-inner{border-color:color-mix(in srgb,var(--qaid-positive) 50%,transparent)}.qaid-scope-dot{position:absolute;top:50%;left:50%;width:4px;height:4px;background:var(--qaid-negative);border-radius:50%;transform:translate(-50%,-50%)}.qaid-type-up .qaid-scope-dot{background:var(--qaid-positive)}.qaid-selected-marker{position:fixed;border:3px solid var(--qaid-marker, #6366f1);border-radius:50%;pointer-events:none;z-index:44;animation:qaid-markerPulse 1.5s ease-in-out infinite}@keyframes qaid-markerPulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.7;transform:scale(1.05)}}.qaid-backdrop{position:fixed;inset:0;z-index:45;background:#0000004d}.qaid-modal-container{position:fixed;z-index:50;display:flex;flex-direction:column;align-items:flex-start;max-height:calc(100vh - 32px);font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-modal-container.qaid-above{flex-direction:column-reverse}.qaid-modal-arrow{width:0;height:0;border-left:12px solid transparent;border-right:12px solid transparent;position:relative;align-self:flex-start}.qaid-modal-container.qaid-below .qaid-modal-arrow{border-bottom:12px solid light-dark(#ffffff,#1f2937)}.qaid-modal-container.qaid-above .qaid-modal-arrow{border-top:12px solid light-dark(#ffffff,#1f2937)}.qaid-modal-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5));width:var(--qaid-modal-width, 400px);max-width:calc(100vw - 32px);max-height:calc(100vh - 60px);overflow-y:auto}.qaid-modal-header{display:flex;align-items:flex-start;gap:.75rem;margin-bottom:1rem}button.qaid-type-toggle{border:none;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .2s;flex-shrink:0;-webkit-appearance:none;appearance:none}button.qaid-type-toggle:hover{transform:scale(1.1)}button.qaid-type-toggle:not(.qaid-type-toggle-custom){width:2.5rem;height:2.5rem;border-radius:50%}button.qaid-type-toggle:not(.qaid-type-toggle-custom) svg{width:1.25rem;height:1.25rem}button.qaid-type-toggle.qaid-type-up{background:var(--qaid-positive);color:#fff}button.qaid-type-toggle.qaid-type-down{background:var(--qaid-negative);color:#fff}.qaid-modal-header-text{flex:1;min-width:0}.qaid-modal-title{font-size:1.125rem;font-weight:700;margin:0 0 .25rem;color:light-dark(#1f2937,#f9fafb)}.qaid-modal-subtitle{color:light-dark(#6b7280,#9ca3af);margin:0;font-size:.875rem}.qaid-textarea{width:100%;height:6rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:1rem;resize:vertical;margin-bottom:1rem;box-sizing:border-box;background:light-dark(#ffffff,#111827);color:light-dark(#1f2937,#f9fafb)}.qaid-textarea:focus{outline:none;border-color:var(--qaid-marker);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 20%,transparent)}.qaid-btn-row{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-btn-submit{padding:.5rem 1rem;background:var(--qaid-marker);color:var(--qaid-marker-text, white);border:none;border-radius:.5rem;font-size:.875rem;font-weight:500;cursor:pointer;transition:background-color .2s,filter .2s;-webkit-appearance:none;appearance:none}button.qaid-btn-submit:hover{filter:brightness(.85)}button.qaid-btn-submit:focus{outline:none;box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 30%,transparent)}.qaid-bottom-sheet{position:fixed;bottom:0;left:0;right:0;z-index:50;animation:qaid-slideUpSheet .3s ease-out;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-bottom-sheet-content{background:light-dark(#ffffff,#1f2937);border-radius:1rem 1rem 0 0;padding:1.5rem;padding-bottom:max(1.5rem,env(safe-area-inset-bottom))}.qaid-bottom-sheet-handle{width:36px;height:4px;background:light-dark(rgba(0,0,0,.2),rgba(255,255,255,.2));border-radius:2px;margin:0 auto 1rem}@keyframes qaid-slideUpSheet{0%{transform:translateY(100%)}to{transform:translateY(0)}}button.qaid-btn-record:hover{background:#dc2626;color:#fff}.qaid-recording-indicator{position:fixed;top:12px;left:50%;transform:translate(-50%);display:flex;align-items:center;gap:.5rem;padding:.5rem 1rem;background:light-dark(#1f2937,#374151);color:#fff;border-radius:9999px;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:.875rem;font-weight:500;box-shadow:0 4px 12px #0000004d;z-index:99999;animation:qaid-slideDown .2s ease-out}.qaid-recording-dot{width:10px;height:10px;background:#dc2626;border-radius:50%;animation:qaid-dotPulse 1.5s ease-in-out infinite}@keyframes qaid-dotPulse{0%,to{opacity:1}50%{opacity:.3}}.qaid-recording-time{font-variant-numeric:tabular-nums;min-width:2.5rem;text-align:center}button.qaid-recording-stop{padding:.25rem .75rem;background:#dc2626;color:#fff;border:none;border-radius:9999px;font-size:.75rem;font-weight:600;cursor:pointer;transition:background-color .2s;-webkit-appearance:none;appearance:none}button.qaid-recording-stop:hover{background:#b91c1c}.qaid-video-preview{position:fixed;inset:0 0 auto;height:100vh;height:100dvh;display:flex;align-items:center;justify-content:center;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#0009;z-index:99998;animation:qaid-fadeIn .2s ease-out}@keyframes qaid-fadeIn{0%{opacity:0}to{opacity:1}}.qaid-video-preview-box{color-scheme:inherit;background:light-dark(#ffffff,#1f2937);border-radius:1rem;padding:1.5rem;box-shadow:0 25px 50px -12px #00000080;width:560px;max-width:100%;max-height:100%;overflow-y:auto;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px)}.qaid-video-preview-box h3{font-size:1.125rem;font-weight:700;margin:0 0 1rem;color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box video{width:100%;max-height:50vh;max-height:50dvh;object-fit:contain;border-radius:.5rem;background:#000;margin-bottom:1rem}.qaid-video-preview-box textarea{width:100%;height:4rem;padding:.75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;font-family:inherit;font-size:.875rem;resize:vertical;margin-bottom:1rem;box-sizing:border-box;background:light-dark(#ffffff,#111827);color:light-dark(#1f2937,#f9fafb)}.qaid-video-preview-box textarea:focus{outline:none;border-color:var(--qaid-marker);box-shadow:0 0 0 3px color-mix(in srgb,var(--qaid-marker) 20%,transparent)}.qaid-video-preview-actions{display:flex;gap:.5rem;justify-content:flex-end}button.qaid-video-btn{padding:.5rem 1rem;border:none;border-radius:.5rem;font-size:.875rem;font-weight:500;cursor:pointer;transition:background-color .2s,filter .2s;-webkit-appearance:none;appearance:none}button.qaid-video-btn-cancel{background:light-dark(#f3f4f6,#374151);color:light-dark(#374151,#d1d5db)}button.qaid-video-btn-cancel:hover{background:light-dark(#e5e7eb,#4b5563)}button.qaid-video-btn-rerecord{background:light-dark(#fef3c7,#78350f);color:light-dark(#92400e,#fde68a)}button.qaid-video-btn-rerecord:hover{filter:brightness(.9)}button.qaid-video-btn-send{background:var(--qaid-marker);color:var(--qaid-marker-text, white)}button.qaid-video-btn-send:hover{filter:brightness(.85)}button.qaid-video-btn-send:disabled{opacity:.5;cursor:not-allowed}.qaid-video-sending{display:flex;align-items:center;gap:.5rem;font-size:.875rem;color:light-dark(#6b7280,#9ca3af)}.qaid-annotate{position:fixed;inset:0;z-index:2147483000;display:flex;flex-direction:column;gap:.75rem;padding:16px;padding-top:max(16px,env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom));box-sizing:border-box;background:#000000d9;font-family:var(--qaid-font-family, system-ui, -apple-system, sans-serif);font-size:var(--qaid-font-size, 16px);animation:qaid-fadeIn .2s ease-out}.qaid-annotate-title{margin:0;font-size:1rem;font-weight:700;text-align:center;color:#f9fafb}.qaid-annotate-desc{margin:0;font-size:.8125rem;line-height:1.4;text-align:center;color:#f9fafbbf}.qaid-annotate-stage{flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center;overflow:auto}.qaid-annotate-canvas{max-width:100%;max-height:100%;object-fit:contain;background:light-dark(#ffffff,#111827);border-radius:.5rem;box-shadow:0 10px 30px #00000080;touch-action:none;cursor:crosshair}.qaid-annotate-toolbar{display:flex;flex-wrap:wrap;gap:.75rem;align-items:center;justify-content:center;padding:.5rem .75rem;background:light-dark(#ffffff,#1f2937);border-radius:.75rem;box-shadow:0 10px 30px light-dark(rgba(0,0,0,.25),rgba(0,0,0,.5))}.qaid-annotate-tools,.qaid-annotate-actions{display:flex;gap:.375rem;align-items:center}button.qaid-annotate-tool,button.qaid-annotate-action{display:inline-flex;align-items:center;justify-content:center;gap:.375rem;min-width:44px;min-height:44px;padding:0 .75rem;border:1px solid light-dark(#d1d5db,#374151);border-radius:.5rem;background:light-dark(#f9fafb,#111827);color:light-dark(#1f2937,#f9fafb);font-family:inherit;font-size:.8125rem;font-weight:600;cursor:pointer;-webkit-appearance:none;appearance:none;transition:background-color .15s,color .15s,border-color .15s,filter .15s}button.qaid-annotate-tool{padding:0}button.qaid-annotate-tool svg,button.qaid-annotate-action svg{width:20px;height:20px}button.qaid-annotate-tool:hover,button.qaid-annotate-action:hover{background:light-dark(#eef2ff,#312e81)}button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{background:var(--qaid-marker, #6366f1);color:var(--qaid-marker-text, #fff);border-color:var(--qaid-marker, #6366f1)}button.qaid-annotate-done:hover{filter:brightness(.9);background:var(--qaid-marker, #6366f1)}button.qaid-annotate-action:disabled{opacity:.45;cursor:not-allowed}@media(forced-colors:active){button.qaid-annotate-tool[aria-pressed=true],button.qaid-annotate-done{border:2px solid Highlight}.qaid-annotate-canvas{border:1px solid CanvasText}}button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible{outline:2px solid var(--qaid-marker, #6366f1);outline-offset:2px}.qaid-textarea:focus-visible,button.qaid-btn-submit:focus-visible,.qaid-video-preview-box textarea:focus-visible{outline:2px solid var(--qaid-marker, #6366f1);outline-offset:2px}.qaid-buttons.qaid-incognito:focus-within{opacity:1}.qaid-buttons:focus-within .qaid-dismiss-btn,.qaid-dismiss-btn:focus-visible{opacity:1}.qaid-dismiss-btn{min-width:24px;min-height:24px}button.qaid-recording-stop{min-height:24px}@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}@media(forced-colors:active){button:focus-visible,textarea:focus-visible,a:focus-visible,[tabindex]:focus-visible,[role=button]:focus-visible,.qaid-textarea:focus,button.qaid-btn-submit:focus,.qaid-video-preview-box textarea:focus{outline:2px solid CanvasText;outline-offset:2px}.qaid-selected-marker,.qaid-highlight-box{border-color:Highlight}}",_t="body.qaid-targeting,body.qaid-targeting *{cursor:none!important}";let A=0;const Vt="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 svg{width:var(--qaid-icon-size);height:var(--qaid-icon-size)}",Ft={small:36,medium:48,large:64},Nt={small:18,medium:24,large:32};function Ut(i,t,e){const[o,n,s]=[i,t,e].map(a=>(a=a/255,a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4)));return .2126*o+.7152*n+.0722*s}function jt(i){if(i.startsWith("#")){const e=i.slice(1),o=e.length===3?e.split("").map(s=>s+s).join(""):e,n=parseInt(o,16);return{r:n>>16&255,g:n>>8&255,b:n&255}}const t=i.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);return t?{r:parseInt(t[1]),g:parseInt(t[2]),b:parseInt(t[3])}:null}function Kt(i){const t=jt(i);return t&&Ut(t.r,t.g,t.b)>.4?"black":"white"}function Wt(i={}){const{positiveColor:t="rgb(0, 200, 83)",negativeColor:e="rgb(255, 0, 0)",markerColor:o="#6366f1",buttonSize:n="medium",modalWidth:s=400,backdropOpacity:a=.3,fontFamily:c="system-ui, -apple-system, sans-serif",fontSize:l=16}=i,r=Ft[n],d=Nt[n],p=Kt(o);return{"--qaid-positive":t,"--qaid-negative":e,"--qaid-marker":o,"--qaid-marker-text":p,"--qaid-btn-size":`${r}px`,"--qaid-icon-size":`${d}px`,"--qaid-modal-width":`${s}px`,"--qaid-backdrop-opacity":String(a),"--qaid-font-family":c,"--qaid-font-size":`${l}px`}}function Xt(i,t){for(const[e,o]of Object.entries(t))i.style.setProperty(e,o)}function Y(){return $t+Vt}function Yt(){if(A++,A>1)return;const i=document.createElement("style");i.id="qaid-styles",i.textContent=_t,document.head.appendChild(i)}function Qt(){A<=0||(A--,A===0&&document.getElementById("qaid-styles").remove())}const Q="data-qaid-a11y-live",Gt="position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;",Jt=["a[href]","button","input","textarea","select","[tabindex]"].join(",");function Zt(i){return i.ownerDocument||document}function te(i,t){const e=t?"assertive":"polite",o=i.querySelector(`[${Q}="${e}"]`);if(o)return o;const s=Zt(i).createElement("div");return s.setAttribute(Q,e),s.setAttribute("role",t?"alert":"status"),s.setAttribute("aria-live",t?"assertive":"polite"),s.setAttribute("aria-atomic","true"),s.style.cssText=Gt,i.appendChild(s),s}function ee(i,t,e={}){const o=te(i,!!e.assertive);o.textContent="",o.textContent=t}function ie(i){return i.hasAttribute("disabled")?!0:i.disabled===!0}function oe(i){let t=i;for(;t;){if(t.hasAttribute("hidden"))return!0;const e=t.style;if(e&&(e.display==="none"||e.visibility==="hidden"||e.visibility==="collapse"))return!0;t=t.parentElement}return!1}function G(i){return Array.from(i.querySelectorAll(Jt)).filter(e=>!(e.getAttribute("tabindex")==="-1"||e instanceof HTMLInputElement&&e.type==="hidden"||e instanceof HTMLAnchorElement&&!e.getAttribute("href")||ie(e)||oe(e)))}function J(i){let t=i.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t instanceof HTMLElement?t:null}function ne(i){const t=i.ownerDocument||document;let e=!1;const o=s=>{if(s.key!=="Tab")return;const a=G(i);if(a.length===0){s.preventDefault(),i.focus();return}const c=a[0],l=a[a.length-1],r=J(t),d=r?a.indexOf(r)!==-1:!1;s.shiftKey?(!d||r===c)&&(s.preventDefault(),l.focus()):(!d||r===l)&&(s.preventDefault(),c.focus())};i.addEventListener("keydown",o);const n=G(i);return n.length>0?n[0].focus():(i.hasAttribute("tabindex")||(i.setAttribute("tabindex","-1"),e=!0),i.focus()),{release(){i.removeEventListener("keydown",o),e&&(i.removeAttribute("tabindex"),e=!1)}}}function se(){return J(document)}function ae(i){if(!(!i||typeof i.focus!="function"))try{i.focus()}catch{}}function re(i,t={}){i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),t.labelledbyId&&i.setAttribute("aria-labelledby",t.labelledbyId),t.describedbyId&&i.setAttribute("aria-describedby",t.describedbyId),t.label&&i.setAttribute("aria-label",t.label)}function de(i,t){let e=i;for(;e&&e!==t;){const o=e.parentNode;if(o===t)return e;if(o&&o.host){e=o.host;continue}if(!o)return null;e=o}return null}function ce(i){const e=(i.ownerDocument||document).body;if(!e)return()=>{};const o=de(i,e),n=[];return Array.from(e.children).forEach(s=>{if(!(s instanceof HTMLElement)||o&&s===o)return;const a=s.inert===!0,c=s.getAttribute("aria-hidden");a&&c==="true"||(s.inert=!0,s.setAttribute("aria-hidden","true"),n.push({el:s,prevInert:a,prevAriaHidden:c}))}),function(){for(;n.length;){const a=n.pop();a.el.inert=a.prevInert,a.prevAriaHidden===null?a.el.removeAttribute("aria-hidden"):a.el.setAttribute("aria-hidden",a.prevAriaHidden)}}}const Z={width:400,height:280,arrowHeight:12,gap:8,viewportPadding:16};function le(i,t,e,o,n){const s=i.y,a=t-(i.y+i.height);if(a>=e+o)return{top:i.y+i.height+o,position:"below"};if(s>=e+o)return{top:i.y-e-o,position:"above"};const c=a>s?"below":"above";let l;return c==="below"?l=Math.min(i.y+i.height+o,t-e-n):l=Math.max(n,i.y-e-o),{top:l,position:c}}function he(i,t,e,o){let s=i.x+i.width/2-e/2;return s=Math.max(o,Math.min(s,t-e-o)),s}function ue(i,t,e,o=24,n=24){const a=i.clickX-t-n/2;return Math.max(o,Math.min(a,e-o-n/2))}function pe(i,t,e,o=Z){const n=o.height+o.arrowHeight,s=le(i,e,n,o.gap,o.viewportPadding),a=he(i,t,o.width,o.viewportPadding);return{top:s.top,left:a,position:s.position}}function fe(i,t,e,o={}){const n=o.gap??8;let s=i.bottom+n;s+t.height>e.height-n&&(s=i.top-t.height-n);let a=i.left;return a<n?a=n:a+t.width>e.width-n&&(a=e.width-t.width-n),s<n?s=n:s+t.height>e.height-n&&(s=e.height-t.height-n),{top:s,left:a}}function me(i,t,e,o=Z){const n=pe(i,t,e,o),s=ue(i,n.left,o.width);return{modal:n,arrow:{left:s}}}const ge=20;function be(i){const t=[],e=console.error,o=console.warn,n=console.log,s=(a,c)=>{const l={message:c.map(r=>String(r)).join(" "),timestamp:Date.now(),level:a};t.length>=ge&&t.shift(),t.push(l),i&&i(l)};return console.error=function(...a){s("error",a),e.apply(console,a)},console.warn=function(...a){s("warn",a),o.apply(console,a)},console.log=function(...a){s("log",a),n.apply(console,a)},{errors:t,restore:()=>{console.error=e,console.warn=o,console.log=n}}}function C(i,t,e){const o=document.createElement(i);if(t)for(const[n,s]of Object.entries(t))n==="className"?o.className=s:o.setAttribute(n,s);return o}function ve(i=640){return typeof window<"u"&&window.innerWidth<i}function tt(i,t,e){const o=e.map(s=>s.style.visibility);e.forEach(s=>s.style.visibility="hidden");const n=document.elementFromPoint(i,t);return e.forEach((s,a)=>s.style.visibility=o[a]),n}function B(i){return i?i.hasAttribute("data-qaid-embed")||i.hasAttribute("data-qaid-embed-overlay")?!0:!!i.closest("[data-qaid-embed], [data-qaid-embed-overlay]"):!1}function et(i,t=0){const e=i.getBoundingClientRect();return{x:e.left-t,y:e.top-t,width:e.width+t*2,height:e.height+t*2}}const ye="https://unpkg.com/@qaiddev/quests-embed@1/dist/qaid-quests.js";let we=i=>import(i),D=null,z=null;function ke(i){return D&&z===i||(z=i,D=Promise.resolve(we(i)).then(t=>{const e=t;if(!e||typeof e.QaidQuests!="function")throw new Error("quests module has no QaidQuests export");return e}).catch(t=>{throw D=null,z=null,t})),D}async function xe(i){const t=await ke(i.moduleUrl),e=i.base.replace(/\/+$/,""),o=i.feedbackId!=null?{feedbackId:i.feedbackId}:void 0;return new t.QaidQuests({endpoint:`${e}/responses`,configUrl:`${e}/${encodeURIComponent(i.questId)}/definition`,apiKey:i.apiKey||void 0,metadata:o,onClose:i.onClose})}const it="qaid_visitor_id",ot="qaid_hide_feedback";function qe(){return typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function $(i){return i?`${ot}_${i}`:ot}function Ce(i){try{return localStorage.getItem($(i))==="1"}catch{return!1}}function nt(i,t=!0){try{t?localStorage.setItem($(i),"1"):localStorage.removeItem($(i))}catch{}}function Se(){try{let i=localStorage.getItem(it);return i||(i=crypto.randomUUID(),localStorage.setItem(it,i)),i}catch{return crypto.randomUUID()}}class st{config;state="IDLE";feedbackData={feedbackType:null,elementSelector:null,elementText:null,consoleErrors:[]};selectedBounds={x:0,y:0,width:0,height:0,clickX:0,clickY:0,visible:!1};feedbackId=null;activeQuest=null;isMobile=!1;visitorId;consoleCapture=null;recording=null;targeting=null;targetingPrewarmed=!1;prewarmHandle=null;prewarmIsTimeout=!1;videoPrewarmed=!1;screenshotPrewarmed=!1;shadowHost=null;shadowRoot=null;overlayShadowHost=null;overlayShadowRoot=null;buttonsContainer=null;isUserProvidedContainer=!1;modal=null;modalPrewarmed=!1;dismissBtn=null;cssVars={};activeThumbBtn=null;keyboardActivation=!1;dialogTrigger=null;dialogTrap=null;dialogRestoreInert=null;uid=Math.random().toString(36).slice(2,9);boundKeyDown;boundResize;_startDismissed=!1;destroyed=!1;domObserver=null;boundBeforeSwap=null;constructor(t){this.config={endpoint:t.endpoint,apiKey:t.apiKey??"",container:t.container??"",buttonClass:t.buttonClass??"",direction:t.direction??"horizontal",position:t.position??"bottom-right",offset:{x:t.offset?.x??16,y:t.offset?.y??16},zIndex:t.zIndex??50,skipTargeting:t.skipTargeting??!1,colors:{positive:t.colors?.positive??"rgb(0, 200, 83)",negative:t.colors?.negative??"rgb(255, 0, 0)",marker:t.colors?.marker??"#6366f1"},buttonSize:t.buttonSize??"medium",text:{tooltip:t.text?.tooltip??"",modalTitle:t.text?.modalTitle??"Thank you for your feedback!",modalSubtitle:t.text?.modalSubtitle??"Would you like to add a message to help us understand your feedback better?",placeholder:t.text?.placeholder??"Optional: Tell us more about your experience...",submitButton:t.text?.submitButton??"Submit",skipButton:t.text?.skipButton??"Skip",positiveLabel:t.text?.positiveLabel??"Send positive feedback",negativeLabel:t.text?.negativeLabel??"Send negative feedback",recordLabel:t.text?.recordLabel??"Record a screen recording",dismissLabel:t.text?.dismissLabel??"Hide Feedback"},modalWidth:t.modalWidth??400,backdropOpacity:t.backdropOpacity??.3,fontFamily:t.fontFamily??"system-ui, -apple-system, sans-serif",fontSize:t.fontSize??16,captureScreenshot:t.captureScreenshot??!1,annotate:t.annotate??!0,screenshotMethod:t.screenshotMethod??"permission",screenshotOptions:{quality:t.screenshotOptions?.quality??.8,maxWidth:t.screenshotOptions?.maxWidth??1280,maxHeight:t.screenshotOptions?.maxHeight??800},incognito:t.incognito??!1,hideDismiss:t.hideDismiss??!1,positiveIcon:t.positiveIcon??"",negativeIcon:t.negativeIcon??"",hideThumbs:t.hideThumbs??!1,css:t.css??"",captureVideo:t.captureVideo??!1,videoOptions:{maxDuration:t.videoOptions?.maxDuration??15,redaction:t.videoOptions?.redaction??!1},recordIcon:t.recordIcon??"",quests:{base:t.quests?.base??"",up:t.quests?.up??"",down:t.quests?.down??"",video:t.quests?.video??"",apiKey:t.quests?.apiKey??t.apiKey??"",moduleUrl:t.quests?.moduleUrl??ye}},this.boundKeyDown=this.handleKeyDown.bind(this),this.boundResize=this.handleResize.bind(this),this.visitorId=Se(),this.init()}applyVars(t){Xt(t,this.cssVars)}announceMsg(t,e=!1){const o=this.overlayShadowRoot??this.shadowRoot;o&&ee(o,t,{assertive:e})}openDialogA11y(t,e){this.dialogTrigger=se(),re(t,e),this.dialogTrap=ne(t),this.dialogRestoreInert=ce(t)}closeDialogA11y(){this.dialogTrap?.release(),this.dialogTrap=null,this.dialogRestoreInert&&(this.dialogRestoreInert(),this.dialogRestoreInert=null),ae(this.dialogTrigger),this.dialogTrigger=null}clearActiveThumb(){this.activeThumbBtn&&(this.activeThumbBtn.setAttribute("aria-pressed","false"),this.activeThumbBtn=null)}init(){Yt(),this.cssVars=Wt({positiveColor:this.config.colors.positive,negativeColor:this.config.colors.negative,markerColor:this.config.colors.marker,buttonSize:this.config.buttonSize,modalWidth:this.config.modalWidth,backdropOpacity:this.config.backdropOpacity,fontFamily:this.config.fontFamily,fontSize:this.config.fontSize}),!this.config.hideDismiss&&Ce(this.config.apiKey)&&(this._startDismissed=!0),this.checkMobile(),window.addEventListener("resize",this.boundResize),this.createEmbed(),this.consoleCapture=be(t=>{this.feedbackData.consoleErrors=this.consoleCapture?.errors??[]}),this.feedbackData.consoleErrors=this.consoleCapture.errors,this.observeDom(),(this.config.captureVideo&&this.videoSupported()||this.config.captureScreenshot)&&this.schedulePrewarm(()=>{this.config.captureVideo&&this.videoSupported()&&this.prewarmVideo(),this.config.captureScreenshot&&this.prewarmScreenshot()})}prewarmVideo(){this.videoPrewarmed||(this.videoPrewarmed=!0,Promise.resolve().then(()=>xt).catch(()=>{}),Promise.resolve().then(()=>ft).catch(()=>{}))}prewarmScreenshot(){this.screenshotPrewarmed||(this.screenshotPrewarmed=!0,(this.shouldCaptureViaDom()?Promise.resolve().then(()=>vt):Promise.resolve().then(()=>qt)).catch(()=>{}),this.config.annotate&&Promise.resolve().then(()=>kt).catch(()=>{}))}schedulePrewarm(t){const e=window,o=()=>{this.destroyed||t()};typeof e.requestIdleCallback=="function"?(this.prewarmIsTimeout=!1,this.prewarmHandle=e.requestIdleCallback(o,{timeout:2e3})):(this.prewarmIsTimeout=!0,this.prewarmHandle=window.setTimeout(o,1200))}observeDom(){this.boundBeforeSwap=t=>{const e=t.newDocument;!e||this.destroyed||(this.shadowHost&&e.body.appendChild(this.shadowHost),this.overlayShadowHost&&e.body.appendChild(this.overlayShadowHost))},document.addEventListener("astro:before-swap",this.boundBeforeSwap),this.domObserver=new MutationObserver(()=>{this.destroyed||(this.shadowHost&&!this.shadowHost.isConnected&&document.body.appendChild(this.shadowHost),this.overlayShadowHost&&!this.overlayShadowHost.isConnected&&document.body.appendChild(this.overlayShadowHost))}),this.domObserver.observe(document.body,{childList:!0})}checkMobile(){this.isMobile=ve()}handleResize(){this.checkMobile()}createEmbed(){this.shadowHost=document.createElement("div"),this.shadowHost.setAttribute("data-qaid-embed",""),this.shadowHost.style.position="static",this.shadowHost.style.display="contents";let t=null;this.config.container&&(t=document.querySelector(this.config.container)),t?(t.appendChild(this.shadowHost),this.isUserProvidedContainer=!0,this.config.hideDismiss=!0):(this.shadowHost.style.position="fixed",this.shadowHost.style.display="block",this.shadowHost.style.inset="0",this.shadowHost.style.pointerEvents="none",this.shadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.shadowHost)),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"});const e=document.createElement("style");if(e.textContent=Y(),this.shadowRoot.appendChild(e),this.config.css){const r=document.createElement("style");r.textContent=this.config.css,this.shadowRoot.appendChild(r)}const o=this.config.direction==="vertical"?"qaid-vertical":"";if(this.isUserProvidedContainer)this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-${this.config.position} ${o}`.trim(),this.config.incognito&&this.buttonsContainer.classList.add("qaid-incognito");else{this.buttonsContainer=document.createElement("div"),this.buttonsContainer.className=`qaid-buttons qaid-auto-container qaid-${this.config.position} ${o}${this.config.incognito?" qaid-incognito":""}`.trim(),this.buttonsContainer.style.pointerEvents="auto";const{x:r,y:d}=this.config.offset;this.config.position.includes("right")?this.buttonsContainer.style.right=`${r}px`:this.buttonsContainer.style.left=`${r}px`,this.config.position.includes("bottom")?this.buttonsContainer.style.bottom=`${d}px`:this.buttonsContainer.style.top=`${d}px`}this.applyVars(this.buttonsContainer),this.shadowRoot.appendChild(this.buttonsContainer),this.buttonsContainer.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" "||r.key==="Spacebar")&&(this.keyboardActivation=!0)}),this.buttonsContainer.addEventListener("mousedown",()=>{this.keyboardActivation=!1}),this.buttonsContainer.addEventListener("pointerdown",()=>{this.keyboardActivation=!1});const n=!!this.config.buttonClass,s=n?`qaid-btn-structural ${this.config.buttonClass}`:"qaid-btn",c=this.config.text.tooltip||"Feedback for us?",l=document.createElement("div");if(l.className="qaid-tooltip-text",l.textContent=c,this.applyVars(l),this.shadowRoot.appendChild(l),this.tooltipElement=l,!this.config.hideThumbs){const r=document.createElement("div");r.className="qaid-tooltip-wrapper";const d=document.createElement("button");d.type="button",d.className=n?`${s} qaid-btn-up`:"qaid-btn qaid-btn-up",d.setAttribute("aria-label",this.config.text.positiveLabel),d.innerHTML=this.config.positiveIcon||E,d.addEventListener("click",m=>this.handleThumbClick("up",m.currentTarget,m)),d.addEventListener("mouseenter",()=>{this.prewarmTargeting(),this.showTooltip(d)}),d.addEventListener("mouseleave",()=>this.hideTooltip()),r.appendChild(d);const p=document.createElement("div");p.className="qaid-tooltip-wrapper";const u=document.createElement("button");u.type="button",u.className=n?`${s} qaid-btn-down`:"qaid-btn qaid-btn-down",u.setAttribute("aria-label",this.config.text.negativeLabel),u.innerHTML=this.config.negativeIcon||O,u.addEventListener("click",m=>this.handleThumbClick("down",m.currentTarget,m)),u.addEventListener("mouseenter",()=>{this.prewarmTargeting(),this.showTooltip(u)}),u.addEventListener("mouseleave",()=>this.hideTooltip()),p.appendChild(u),this.buttonsContainer.appendChild(r),this.buttonsContainer.appendChild(p)}if(this.config.captureVideo&&this.videoSupported()){const r=document.createElement("div");r.className="qaid-tooltip-wrapper";const d=document.createElement("button");d.type="button",d.className=n?`${s} qaid-btn-record`:"qaid-btn qaid-btn-record",d.setAttribute("aria-label",this.config.text.recordLabel),d.innerHTML=this.config.recordIcon||Lt,d.addEventListener("click",()=>{this.ensureRecording().then(u=>this.config.videoOptions.redaction?u.startPicking():u.startRecording())});const p=()=>this.prewarmVideo();d.addEventListener("mouseenter",()=>{p(),this.showTooltip(d)}),d.addEventListener("focus",p),d.addEventListener("touchstart",p,{passive:!0}),d.addEventListener("mouseleave",()=>this.hideTooltip()),r.appendChild(d),this.buttonsContainer.appendChild(r)}this.config.hideDismiss||(this.dismissBtn=document.createElement("button"),this.dismissBtn.type="button",this.dismissBtn.className="qaid-dismiss-btn",this.dismissBtn.setAttribute("aria-label",this.config.text.dismissLabel),this.dismissBtn.title=this.config.text.dismissLabel,this.dismissBtn.innerHTML='<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>',this.dismissBtn.addEventListener("click",r=>{r.stopPropagation(),this.handleDismiss()}),this.buttonsContainer.insertBefore(this.dismissBtn,this.buttonsContainer.firstChild),this._startDismissed&&this.buttonsContainer.classList.add("qaid-dismissed"))}ensureOverlayHost(){if(this.overlayShadowRoot)return this.overlayShadowRoot;this.overlayShadowHost=document.createElement("div"),this.overlayShadowHost.setAttribute("data-qaid-embed-overlay",""),this.overlayShadowHost.style.position="fixed",this.overlayShadowHost.style.inset="0",this.overlayShadowHost.style.pointerEvents="none",this.overlayShadowHost.style.zIndex=String(this.config.zIndex),document.body.appendChild(this.overlayShadowHost),this.overlayShadowRoot=this.overlayShadowHost.attachShadow({mode:"open"});const t=document.createElement("style");if(t.textContent=Y(),this.overlayShadowRoot.appendChild(t),this.config.css){const e=document.createElement("style");e.textContent=this.config.css,this.overlayShadowRoot.appendChild(e)}return this.overlayShadowRoot}tooltipElement=null;showTooltip(t){const e=this.tooltipElement;e.style.visibility="hidden",e.classList.add("qaid-tooltip-visible");const o=t.getBoundingClientRect(),n=e.getBoundingClientRect(),{top:s,left:a}=fe(o,n,{width:window.innerWidth,height:window.innerHeight});e.style.top=`${s}px`,e.style.left=`${a}px`,e.style.visibility="visible"}hideTooltip(){this.tooltipElement.classList.remove("qaid-tooltip-visible")}handleDismiss(){this.buttonsContainer.classList.add("qaid-dismissed"),nt(this.config.apiKey,!0)}handleThumbClick(t,e,o){if(this.buttonsContainer?.classList.contains("qaid-incognito")&&(this.buttonsContainer.classList.remove("qaid-incognito"),nt(this.config.apiKey,!1)),this.prewarmModal(),this.config.skipTargeting)this.submitDirectFeedback(t,e);else{this.activeThumbBtn=e,e.setAttribute("aria-pressed","true");const n=this.keyboardActivation;this.keyboardActivation=!1,this.ensureTargeting().then(s=>{this.destroyed||(n?s.startKeyboard(t):s.startPointer(t,o))})}}submitDirectFeedback(t,e){this.feedbackData.feedbackType=t,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null;const o=e.getBoundingClientRect();this.selectedBounds={x:o.left,y:o.top,width:o.width,height:o.height,clickX:o.left+o.width/2,clickY:o.top+o.height/2,visible:!1},this.submitFeedback()}handleKeyDown(t){if(t.key==="Escape"){if(this.recording?.handleEscape())return;this.state==="TARGETING"?this.targeting?.cancel():this.state==="MODAL_OPEN"&&this.modal?.close()}}shouldCaptureViaDom(){return this.config.screenshotMethod==="dom"||qe()}async openAnnotationEditor(t){const e=this.ensureOverlayHost(),o=this.overlayShadowHost,n=o.style.pointerEvents;o.style.pointerEvents="auto";try{const{openAnnotationEditor:s}=await Promise.resolve().then(()=>kt);return await s({dataUrl:t,root:e,quality:this.config.screenshotOptions.quality,color:this.config.colors.marker,applyVars:a=>this.applyVars(a),announce:(a,c)=>this.announceMsg(a,c),openDialog:(a,c)=>this.openDialogA11y(a,c),closeDialog:()=>this.closeDialogA11y()})}finally{o.style.pointerEvents=n}}async submitFeedback(){let t=null;if(this.config.captureScreenshot){if(this.shouldCaptureViaDom()){const{captureDomScreenshot:a}=await Promise.resolve().then(()=>vt);t=await a(this.config.screenshotOptions)}else{const{captureScreenshot:a}=await Promise.resolve().then(()=>qt);t=await a(this.config.screenshotOptions)}t&&this.announceMsg("Screenshot captured")}t&&this.config.annotate&&(t=await this.openAnnotationEditor(t)??t);const e=this.feedbackData.elementSelector?{x:this.selectedBounds.x,y:this.selectedBounds.y,width:this.selectedBounds.width,height:this.selectedBounds.height}:null,o={feedbackType:this.feedbackData.feedbackType,pageUrl:window.location.href,apiKey:this.config.apiKey||void 0,elementSelector:this.feedbackData.elementSelector,elementText:this.feedbackData.elementText,consoleErrors:[...this.feedbackData.consoleErrors],screenWidth:window.innerWidth,screenHeight:window.innerHeight,clickX:this.selectedBounds.clickX,clickY:this.selectedBounds.clickY,scrollX:window.scrollX,scrollY:window.scrollY,screenshot:t,visitorId:this.visitorId,elementBounds:e,userAgent:navigator.userAgent};try{const a=await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(a.ok){const c=await a.json();this.feedbackId=c.id,this.announceMsg("Feedback sent")}}catch(a){console.error("Failed to submit feedback:",a),this.announceMsg("Failed to send feedback",!0)}const n=this.feedbackData.feedbackType;if(n&&await this.tryLaunchQuest(n,this.feedbackId)){this.resetFeedbackUi();return}this.state="MODAL_OPEN";const s=await this.ensureModal();this.destroyed||(s.open(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto"))}questIdFor(t){const e=this.config.quests;return e.base&&e[t]||""}async tryLaunchQuest(t,e){const o=this.questIdFor(t);if(!o)return!1;try{return this.activeQuest?.destroy(),this.activeQuest=await xe({questId:o,base:this.config.quests.base,apiKey:this.config.quests.apiKey||void 0,moduleUrl:this.config.quests.moduleUrl,feedbackId:e,onClose:()=>{this.activeQuest=null}}),!0}catch(n){return console.error("Failed to launch quest:",n),this.activeQuest=null,!1}}resetFeedbackUi(){this.targeting?.hideMarker(),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="none"),this.state="IDLE",this.feedbackId=null,this.feedbackData.feedbackType=null,this.feedbackData.elementSelector=null,this.feedbackData.elementText=null,this.selectedBounds.visible=!1}async ensureModal(){if(!this.modal){const{ModalController:t}=await Promise.resolve().then(()=>Ct);this.modal=new t(this.makeModalHost())}return this.modal}makeModalHost(){const t=this;return{get config(){return t.config},get uid(){return t.uid},get isMobile(){return t.isMobile},get state(){return t.state},get boundKeyDown(){return t.boundKeyDown},get feedbackData(){return t.feedbackData},get selectedBounds(){return t.selectedBounds},get feedbackId(){return t.feedbackId},setFeedbackId:e=>{t.feedbackId=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),openDialogA11y:(e,o)=>t.openDialogA11y(e,o),closeDialogA11y:()=>t.closeDialogA11y(),resetFeedbackUi:()=>t.resetFeedbackUi()}}prewarmModal(){this.modalPrewarmed||(this.modalPrewarmed=!0,Promise.resolve().then(()=>Ct).catch(()=>{}))}async ensureTargeting(){if(!this.targeting){const{TargetingController:t}=await Promise.resolve().then(()=>Tt);this.targeting=new t(this.makeTargetingHost())}return this.targeting}makeTargetingHost(){const t=this;return{get config(){return t.config},get cssVars(){return t.cssVars},get state(){return t.state},get shadowHost(){return t.shadowHost},get overlayShadowHost(){return t.overlayShadowHost},get boundKeyDown(){return t.boundKeyDown},get feedbackData(){return t.feedbackData},get selectedBounds(){return t.selectedBounds},setState:e=>{t.state=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),clearActiveThumb:()=>t.clearActiveThumb(),submitFeedback:()=>t.submitFeedback()}}prewarmTargeting(){this.targetingPrewarmed||this.config.skipTargeting||(this.targetingPrewarmed=!0,Promise.resolve().then(()=>Tt).catch(()=>{}))}videoSupported(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}async ensureRecording(){if(!this.recording){const{RecordingController:t}=await Promise.resolve().then(()=>xt);this.recording=new t(this.makeRecordingHost())}return this.recording}makeRecordingHost(){const t=this;return{get config(){return t.config},get visitorId(){return t.visitorId},get uid(){return t.uid},get overlayShadowHost(){return t.overlayShadowHost},get consoleCapture(){return t.consoleCapture},get boundKeyDown(){return t.boundKeyDown},get state(){return t.state},setState:e=>{t.state=e},ensureOverlayHost:()=>t.ensureOverlayHost(),applyVars:e=>t.applyVars(e),announceMsg:(e,o)=>t.announceMsg(e,o),openDialogA11y:(e,o)=>t.openDialogA11y(e,o),closeDialogA11y:()=>t.closeDialogA11y(),setButtonsDisabled:e=>t.setButtonsDisabled(e),tryLaunchQuest:(e,o)=>t.tryLaunchQuest(e,o)}}setButtonsDisabled(t){if(!this.buttonsContainer)return;this.buttonsContainer.querySelectorAll("button.qaid-btn, button.qaid-btn-structural").forEach(o=>{t?o.classList.contains("qaid-btn-record")||(o.disabled=!0,o.style.opacity="0.5"):(o.disabled=!1,o.style.opacity="")})}destroy(){if(this.destroyed=!0,this.domObserver&&(this.domObserver.disconnect(),this.domObserver=null),this.boundBeforeSwap&&(document.removeEventListener("astro:before-swap",this.boundBeforeSwap),this.boundBeforeSwap=null),this.targeting?.destroy(),this.targeting=null,this.clearActiveThumb(),this.closeDialogA11y(),this.prewarmHandle!==null){const t=window;this.prewarmIsTimeout?clearTimeout(this.prewarmHandle):t.cancelIdleCallback?.(this.prewarmHandle),this.prewarmHandle=null}this.recording?.destroy(),this.recording=null,this.modal?.destroy(),this.modal=null,this.activeQuest?.destroy(),this.activeQuest=null,this.consoleCapture&&(this.consoleCapture.restore(),this.consoleCapture=null),window.removeEventListener("resize",this.boundResize),document.removeEventListener("keydown",this.boundKeyDown),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.shadowHost&&(this.shadowHost.remove(),this.shadowHost=null,this.shadowRoot=null),this.overlayShadowHost&&(this.overlayShadowHost.remove(),this.overlayShadowHost=null,this.overlayShadowRoot=null),this.buttonsContainer=null,this.dismissBtn=null,this.tooltipElement=null,Qt()}}function at(i){return document.querySelector(i)?.textContent?.trim()??""}function Ee(){const i=document.querySelector('script[type="application/json"][data-feedback-config]');if(!i)return null;const t=i.textContent?.trim();if(!t)return null;try{const e=JSON.parse(t);return e.cssSelector&&!e.css&&(e.css=at(e.cssSelector),delete e.cssSelector),e}catch{return null}}function Te(i){const t=i.getAttribute("data-endpoint");if(!t)return null;const e=i.getAttribute("data-position"),o=i.getAttribute("data-zindex"),n=i.getAttribute("data-positive-color"),s=i.getAttribute("data-negative-color"),a=i.getAttribute("data-marker-color"),c=i.getAttribute("data-container"),l=i.getAttribute("data-button-class"),r=i.getAttribute("data-skip-targeting"),d=i.getAttribute("data-incognito"),p=i.getAttribute("data-button-size"),u=i.getAttribute("data-offset-x"),m=i.getAttribute("data-offset-y"),y=i.getAttribute("data-modal-width"),v=i.getAttribute("data-backdrop-opacity"),x=i.getAttribute("data-font-family"),q=i.getAttribute("data-font-size"),h=i.getAttribute("data-tooltip"),w=i.getAttribute("data-modal-title"),k=i.getAttribute("data-modal-subtitle"),S=i.getAttribute("data-placeholder"),P=i.getAttribute("data-submit-button"),I=i.getAttribute("data-skip-button"),g=i.getAttribute("data-positive-icon"),U=i.getAttribute("data-negative-icon"),fi=i.getAttribute("data-api-key"),mi=i.getAttribute("data-capture-screenshot"),gi=i.getAttribute("data-annotate"),j=i.getAttribute("data-screenshot-quality"),K=i.getAttribute("data-screenshot-max-width"),W=i.getAttribute("data-screenshot-max-height"),bi=i.getAttribute("data-capture-video"),It=i.getAttribute("data-video-redaction"),vi=i.getAttribute("data-hide-thumbs"),yi=i.getAttribute("data-hide-dismiss"),X=i.getAttribute("data-video-max-duration"),wi=i.getAttribute("data-screenshot-method"),ki=i.getAttribute("data-direction"),At=i.getAttribute("data-css-selector"),Dt=i.getAttribute("data-quest-base"),xi=i.getAttribute("data-quest-up"),qi=i.getAttribute("data-quest-down"),Ci=i.getAttribute("data-quest-video"),Si=i.getAttribute("data-quest-api-key"),Ei=i.getAttribute("data-quest-module-url");return{endpoint:t,css:At?at(At):void 0,apiKey:fi??void 0,captureScreenshot:mi==="true"?!0:void 0,annotate:gi==="false"?!1:void 0,screenshotOptions:j||K||W?{quality:j?parseFloat(j):void 0,maxWidth:K?parseInt(K,10):void 0,maxHeight:W?parseInt(W,10):void 0}:void 0,container:c??void 0,buttonClass:l??void 0,direction:ki??void 0,position:e??void 0,zIndex:o?parseInt(o,10):void 0,skipTargeting:r==="true"?!0:void 0,incognito:d==="true"?!0:void 0,buttonSize:p??void 0,offset:u||m?{x:u?parseInt(u,10):void 0,y:m?parseInt(m,10):void 0}:void 0,modalWidth:y?parseInt(y,10):void 0,backdropOpacity:v?parseFloat(v):void 0,fontFamily:x??void 0,fontSize:q?parseInt(q,10):void 0,colors:{positive:n??void 0,negative:s??void 0,marker:a??void 0},text:h||w||k||S||P||I?{tooltip:h??void 0,modalTitle:w??void 0,modalSubtitle:k??void 0,placeholder:S??void 0,submitButton:P??void 0,skipButton:I??void 0}:void 0,positiveIcon:g??void 0,negativeIcon:U??void 0,screenshotMethod:wi??void 0,captureVideo:bi==="true"?!0:void 0,hideThumbs:vi==="true"?!0:void 0,hideDismiss:yi==="true"?!0:void 0,videoOptions:X||It?{maxDuration:X?parseInt(X,10):void 0,redaction:It==="true"?!0:void 0}:void 0,quests:Dt?{base:Dt,up:xi??void 0,down:qi??void 0,video:Ci??void 0,apiKey:Si??void 0,moduleUrl:Ei??void 0}:void 0}}function Ie(){if(typeof document>"u")return;const i=()=>{const t=document.currentScript??document.querySelector("script[data-endpoint]"),e=Ee(),o=t?Te(t):null,n=e??o;n?.endpoint&&new st(n)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i):i()}const Ae=20,rt=4096;function H(i){const t=typeof i=="string"?i:JSON.stringify(i);return t.length>rt?t.slice(0,rt)+"…[truncated]":t}function dt(i,t){i.length>=Ae&&i.shift(),i.push(t)}async function De(i){try{const t=await i.clone().text();return H(t)}catch{return}}function ct(){const i=[],t=window.fetch;window.fetch=async function(n,s){const a=typeof n=="string"?n:n instanceof URL?n.toString():n.url,c=s?.method??(typeof n=="object"&&"method"in n?n.method:"GET");let l;s?.body&&(l=H(s.body));const r=await t.apply(window,[n,s]);if(r.status>=400){const d=await De(r);dt(i,{url:a,method:c.toUpperCase(),status:r.status,statusText:r.statusText,requestBody:l,responseBody:d,timestamp:Date.now()})}return r};const e=XMLHttpRequest.prototype.open,o=XMLHttpRequest.prototype.send;return XMLHttpRequest.prototype.open=function(n,s,...a){return this._qaid_method=n,this._qaid_url=typeof s=="string"?s:s.toString(),e.apply(this,[n,s,...a])},XMLHttpRequest.prototype.send=function(n){const s=this,a=n?H(n):void 0;return s.addEventListener("load",function(){s.status>=400&&dt(i,{url:s._qaid_url,method:s._qaid_method.toUpperCase(),status:s.status,statusText:s.statusText,requestBody:a,responseBody:H(s.responseText),timestamp:Date.now()})}),o.apply(this,[n])},{errors:i,restore:()=>{window.fetch=t,XMLHttpRequest.prototype.open=e,XMLHttpRequest.prototype.send=o}}}function Le(){const i=navigator.userAgent||"";return/iP(hone|ad|od)/.test(i)||navigator.platform==="MacIntel"&&(navigator.maxTouchPoints||0)>1}function Re(i,t,e,o,n){const s=i>=t,a=e>=o;return s===a?{width:i,height:t,rotate:0}:{width:t,height:i,rotate:n===270?-90:90}}function Me(i,t,e){if(e.rotate===0){i.drawImage(t,0,0,e.width,e.height);return}i.save(),e.rotate===90?(i.translate(e.width,0),i.rotate(Math.PI/2)):(i.translate(0,e.height),i.rotate(-Math.PI/2)),i.drawImage(t,0,0,e.height,e.width),i.restore()}function Pe(){const i=typeof screen<"u"?screen.orientation:void 0;return i&&typeof i.angle=="number"?i.angle:0}function lt(i){return new Promise(t=>{if(i.videoWidth>0){t();return}i.addEventListener("loadedmetadata",()=>t(),{once:!0})})}async function ht(i){try{await i.play()}catch{}}async function Be(i,t=15){const e=document.createElement("canvas");if(typeof e.captureStream!="function")return null;const o=e.getContext("2d");if(!o)return null;const n=document.createElement("video");n.muted=!0,n.playsInline=!0,n.srcObject=i,await lt(n);const s=Re(n.videoWidth,n.videoHeight,window.innerWidth,window.innerHeight,Pe());e.width=s.width,e.height=s.height,await ht(n);let a=0;const c=()=>{Me(o,n,s),a=requestAnimationFrame(c)};c();const l=e.captureStream(t);return{stream:l,stop:()=>{a&&cancelAnimationFrame(a),a=0,l.getTracks().forEach(r=>r.stop()),n.pause(),n.srcObject=null}}}function He(i,t,e,o,n){const s=Math.max(0,Math.min(o,i.left*t)),a=Math.max(0,Math.min(n,i.top*e)),c=Math.max(0,Math.min(o,(i.left+i.width)*t)),l=Math.max(0,Math.min(n,(i.top+i.height)*e)),r=c-s,d=l-a;return r<=0||d<=0?null:{x:s,y:a,w:r,h:d}}function Oe(i,t,e,o,n,s,a){i.drawImage(t,0,0,o,n);const c=o/Math.max(1,window.innerWidth),l=n/Math.max(1,window.innerHeight);for(const r of e){const d=He(r.getBoundingClientRect(),c,l,o,n);d&&(i.save(),a?(i.filter=`blur(${s}px)`,i.drawImage(t,d.x,d.y,d.w,d.h,d.x,d.y,d.w,d.h)):(i.fillStyle="#0b0b0b",i.fillRect(d.x,d.y,d.w,d.h)),i.restore())}}async function ze(i,t,e={}){const o=e.frameRate??15,n=e.blurRadius??12,s=document.createElement("canvas");if(typeof s.captureStream!="function")return null;const a=s.getContext("2d");if(!a)return null;const c="filter"in a,l=document.createElement("video");l.muted=!0,l.playsInline=!0,l.srcObject=i,await lt(l),s.width=l.videoWidth,s.height=l.videoHeight,await ht(l);let r=0;const d=()=>{Oe(a,l,t,s.width,s.height,n,c),r=requestAnimationFrame(d)};d();const p=s.captureStream(o);return{stream:p,stop:()=>{r&&cancelAnimationFrame(r),r=0,p.getTracks().forEach(u=>u.stop()),l.pause(),l.srcObject=null}}}function ut(){return typeof navigator<"u"&&!!navigator.mediaDevices&&typeof navigator.mediaDevices.getDisplayMedia=="function"&&typeof MediaRecorder<"u"}function _(){if(typeof MediaRecorder>"u")return"";const i=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(const t of i)if(MediaRecorder.isTypeSupported(t))return t;return""}function pt(i={}){const t=i.maxDuration??15,e=i.videoBitsPerSecond??8e5,o=i.redactionElements??[],n=i.redactionBlurRadius;let s=null,a=null,c=null,l=null,r=[],d=null,p=null,u=null,m=0,y=null,v=null,x=!1,q=null;function h(){u!==null&&(clearInterval(u),u=null),q!==null&&(clearTimeout(q),q=null),a&&(a.stop(),a=null),c&&(c.stop(),c=null),s&&(s.getTracks().forEach(k=>k.stop()),s=null),l=null,r=[],d=null,p=null,y=null,v=null}function w(){x||(x=!0,l&&l.state!=="inactive"&&l.stop())}return{async start(){x=!1,r=[];const k=_();if(!k)throw new Error("No supported video MIME type found");s=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15,displaySurface:"browser"},audio:!1,preferCurrentTab:!0,selfBrowserSurface:"include",monitorTypeSurfaces:"exclude",surfaceSwitching:"exclude"});const S=s.getVideoTracks()[0],P=S?.getSettings?.()?.displaySurface;if(P==="monitor"||P==="window")throw s.getTracks().forEach(g=>g.stop()),s=null,new Error("qaid records only the current tab — please share this tab, not a window or your whole screen.");S&&S.addEventListener("ended",()=>{w()});let I=s;if(Le()){const g=await Be(s);g&&(a=g,I=g.stream)}else if(o.length>0){const g=await ze(s,o,{blurRadius:n});g&&(c=g,I=g.stream)}l=new MediaRecorder(I,{mimeType:k,videoBitsPerSecond:e}),l.ondataavailable=g=>{g.data.size>0&&r.push(g.data)},l.onstop=()=>{const g=new Blob(r,{type:k});y&&y(g),p&&p(g),a&&(a.stop(),a=null),c&&(c.stop(),c=null),s&&s.getTracks().forEach(U=>U.stop())},l.onerror=()=>{v&&v(new Error("MediaRecorder error"))},l.start(1e3),m=Date.now(),u=setInterval(()=>{const g=Math.floor((Date.now()-m)/1e3);d&&d(g)},1e3),q=setTimeout(()=>{w()},t*1e3)},stop(){return new Promise((k,S)=>{y=k,v=S,w()})},onTick(k){d=k},onStop(k){p=k},destroy(){w(),h()}}}const ft=Object.freeze(Object.defineProperty({__proto__:null,createVideoRecorder:pt,getSupportedMimeType:_,isVideoRecordingSupported:ut},Symbol.toStringTag,{value:"Module"})),mt="https://qaid.dev/lib/html2canvas.min.js",$e=1e4,_e=50;let L=null;function gt(){if(typeof document>"u"||typeof window>"u")return!1;const i=document.createElement("canvas");return typeof i.getContext=="function"&&!!i.getContext("2d")}function Ve(){return window.html2canvas?Promise.resolve(!0):L||(L=new Promise(i=>{if(!document.querySelector(`script[src="${mt}"]`)){const n=document.createElement("script");n.src=mt,n.async=!0,document.head.appendChild(n)}const e=Date.now(),o=()=>{if(window.html2canvas){i(!0);return}if(Date.now()-e>$e){L=null,i(!1);return}setTimeout(o,_e)};o()}),L)}async function bt(i={}){const{quality:t=.8,maxWidth:e=1280,maxHeight:o=800}=i;try{if(!await Ve()||!window.html2canvas)return console.warn("html2canvas failed to load"),null;const s=await window.html2canvas(document.body,{useCORS:!0,allowTaint:!1,logging:!1,windowWidth:document.documentElement.clientWidth,windowHeight:document.documentElement.clientHeight,width:document.documentElement.clientWidth,height:document.documentElement.clientHeight,x:window.scrollX,y:window.scrollY,ignoreElements:r=>r instanceof HTMLElement?r.classList.contains("qaid-buttons")||r.classList.contains("qaid-targeting-overlay")||r.classList.contains("qaid-modal-container")||r.classList.contains("qaid-bottom-sheet")||r.classList.contains("qaid-backdrop")||r.classList.contains("qaid-selected-marker")||r.classList.contains("qaid-tooltip-text")||r.classList.contains("qaid-recording-indicator")||r.classList.contains("qaid-video-preview")||r.className?.toString().startsWith?.("qaid-"):!1}),a=s.width,c=s.height,l=Math.min(e/a,o/c,1);if(l<1){const r=Math.round(a*l),d=Math.round(c*l),p=document.createElement("canvas");p.width=r,p.height=d;const u=p.getContext("2d");return u?(u.drawImage(s,0,0,r,d),p.toDataURL("image/webp",t)):null}return s.toDataURL("image/webp",t)}catch(n){return console.warn("DOM screenshot capture failed:",n),null}}const vt=Object.freeze(Object.defineProperty({__proto__:null,captureDomScreenshot:bt,isDomScreenshotSupported:gt},Symbol.toStringTag,{value:"Module"})),T=12,Fe="#ef4444",Ne=4,Ue=.8,je={title:"Annotate screenshot",instructions:"Draw on the screenshot to highlight or hide details, then choose Done to attach it or Skip to send the original.",rectangle:"Rectangle",arrow:"Arrow",pen:"Pen",blur:"Blur or redact",undo:"Undo last",skip:"Skip annotation",done:"Done"};function R(i,t){return{x:Math.min(i.x,t.x),y:Math.min(i.y,t.y),w:Math.abs(i.x-t.x),h:Math.abs(i.y-t.y)}}function Ke(i){if(i.type==="pen")return i.points.length<2;const t=R(i.points[0],i.points[1]);return t.w<3&&t.h<3}function We(i,t,e,o){i.beginPath(),i.moveTo(t.x,t.y),i.lineTo(e.x,e.y),i.stroke();const n=Math.atan2(e.y-t.y,e.x-t.x),s=Math.max(10,o*3);i.beginPath(),i.moveTo(e.x,e.y),i.lineTo(e.x-s*Math.cos(n-Math.PI/6),e.y-s*Math.sin(n-Math.PI/6)),i.moveTo(e.x,e.y),i.lineTo(e.x-s*Math.cos(n+Math.PI/6),e.y-s*Math.sin(n+Math.PI/6)),i.stroke()}function Xe(i,t){if(t.length!==0){i.beginPath(),i.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)i.lineTo(t[e].x,t[e].y);i.stroke()}}function Ye(i,t,e,o,n){i.fillStyle="rgb(15, 23, 42)",i.fillRect(t,e,o,n),i.fillStyle="rgb(37, 47, 63)";for(let s=e;s<e+n;s+=T)for(let a=t;a<t+o;a+=T)(Math.floor((a-t)/T)+Math.floor((s-e)/T))%2===0&&i.fillRect(a,s,Math.min(T,t+o-a),Math.min(T,e+n-s))}function M(i,t){switch(i.save(),i.strokeStyle=t.color,i.fillStyle=t.color,i.lineWidth=t.strokeWidth,i.lineJoin="round",i.lineCap="round",t.type){case"rect":{const e=R(t.points[0],t.points[1]);i.strokeRect(e.x,e.y,e.w,e.h);break}case"arrow":We(i,t.points[0],t.points[1],t.strokeWidth);break;case"pen":Xe(i,t.points);break;case"blur":{const e=R(t.points[0],t.points[1]);Ye(i,e.x,e.y,e.w,e.h);break}}i.restore()}function yt(i){return new Promise((t,e)=>{const o=new Image;o.onload=()=>t(o),o.onerror=()=>e(new Error("Failed to load screenshot")),o.src=i})}async function V(i,t,e={}){const o=e.quality??Ue;let n;try{n=await yt(i)}catch{return i}const s=document.createElement("canvas");s.width=n.naturalWidth||n.width||1,s.height=n.naturalHeight||n.height||1;const a=s.getContext("2d");if(!a)return i;a.drawImage(n,0,0,s.width,s.height);for(const c of t)M(a,c);return s.toDataURL("image/webp",o)}let Qe=0;class F{shapes=[];tool="rect";opts;labels;color;strokeWidth;uid=`qaid-annotate-${++Qe}`;container;canvas;ctx=null;toolbar;undoBtn;img=null;drawing=!1;current=null;settled=!1;resolveResult;constructor(t){this.opts=t,this.labels={...je,...t.labels??{}},this.color=t.color??Fe,this.strokeWidth=t.strokeWidth??Ne}open(){const t=new Promise(e=>{this.resolveResult=e});return this.mount(),t}toolButton(t,e,o){const n=C("button",{type:"button",class:"qaid-annotate-tool","data-qaid-tool":t,"aria-pressed":t===this.tool?"true":"false","aria-label":`${o} tool`,title:o});return n.innerHTML=e,n}actionButton(t,e,o,n){const s=C("button",{type:"button",class:`qaid-annotate-action ${n}`,"data-qaid-action":t,"aria-label":o,title:o});return s.innerHTML=`${e}<span class="qaid-annotate-btn-text">${o}</span>`,s}mount(){const t=`${this.uid}-title`,e=`${this.uid}-desc`;this.container=C("div",{class:"qaid-annotate"}),this.opts.applyVars?.(this.container);const o=C("h2",{id:t,class:"qaid-annotate-title"});o.textContent=this.labels.title;const n=C("p",{id:e,class:"qaid-annotate-desc"});n.textContent=this.labels.instructions;const s=C("div",{class:"qaid-annotate-stage"});this.canvas=document.createElement("canvas"),this.canvas.className="qaid-annotate-canvas",this.canvas.width=1,this.canvas.height=1,this.canvas.setAttribute("role","img"),this.canvas.setAttribute("aria-label",this.labels.title),this.ctx=this.canvas.getContext("2d"),s.appendChild(this.canvas),this.toolbar=C("div",{class:"qaid-annotate-toolbar",role:"toolbar","aria-label":this.labels.title});const a=C("div",{class:"qaid-annotate-tools"});a.appendChild(this.toolButton("rect",Rt,this.labels.rectangle)),a.appendChild(this.toolButton("arrow",Mt,this.labels.arrow)),a.appendChild(this.toolButton("pen",Pt,this.labels.pen)),a.appendChild(this.toolButton("blur",Bt,this.labels.blur)),this.undoBtn=this.actionButton("undo",Ht,this.labels.undo,"qaid-annotate-undo"),this.undoBtn.disabled=!0;const c=this.actionButton("skip",zt,this.labels.skip,"qaid-annotate-skip"),l=this.actionButton("done",Ot,this.labels.done,"qaid-annotate-done"),r=C("div",{class:"qaid-annotate-actions"});r.appendChild(this.undoBtn),r.appendChild(c),r.appendChild(l),this.toolbar.appendChild(a),this.toolbar.appendChild(r),this.container.appendChild(o),this.container.appendChild(n),this.container.appendChild(s),this.container.appendChild(this.toolbar),this.opts.root.appendChild(this.container),this.toolbar.addEventListener("click",this.onToolbarClick),this.canvas.addEventListener("pointerdown",this.onPointerDown),this.container.addEventListener("pointermove",this.onPointerMove),this.container.addEventListener("pointerup",this.onPointerUp),this.container.addEventListener("keydown",this.onKeyDown),this.opts.openDialog?.(this.container,{labelledbyId:t,describedbyId:e}),this.opts.announce?.(this.labels.instructions),yt(this.opts.dataUrl).then(d=>{this.img=d,this.canvas.width=d.naturalWidth||d.width||1,this.canvas.height=d.naturalHeight||d.height||1,this.redraw()}).catch(()=>{this.img=null,this.redraw()})}toImageCoords(t){const e=this.canvas.getBoundingClientRect(),o=this.canvas.width/(e.width||this.canvas.width),n=this.canvas.height/(e.height||this.canvas.height);return{x:(t.clientX-e.left)*o,y:(t.clientY-e.top)*n}}redraw(){const t=this.ctx;if(t){t.clearRect(0,0,this.canvas.width,this.canvas.height),this.img&&t.drawImage(this.img,0,0,this.canvas.width,this.canvas.height);for(const e of this.shapes)M(t,e);this.current&&M(t,this.current)}}selectTool(t){this.tool=t,this.toolbar.querySelectorAll("[data-qaid-tool]").forEach(n=>{n.setAttribute("aria-pressed",n.getAttribute("data-qaid-tool")===t?"true":"false")});const o=this.labels[Ge[t]];this.opts.announce?.(`${o} tool selected`)}onToolbarClick=t=>{const o=t.target?.closest("[data-qaid-tool],[data-qaid-action]");if(!o)return;const n=o.getAttribute("data-qaid-tool");if(n){this.selectTool(n);return}const s=o.getAttribute("data-qaid-action");s==="undo"?this.undo():s==="skip"?this.skip():s==="done"&&this.done()};onPointerDown=t=>{t.preventDefault?.(),this.drawing=!0;const e=this.toImageCoords(t);this.current={type:this.tool,color:this.color,strokeWidth:this.strokeWidth,points:this.tool==="pen"?[e]:[e,{...e}]},this.redraw()};onPointerMove=t=>{if(!this.drawing||!this.current)return;const e=this.toImageCoords(t);this.current.type==="pen"?this.current.points.push(e):this.current.points[1]=e,this.redraw()};onPointerUp=()=>{if(!this.drawing||!this.current)return;this.drawing=!1;const t=this.current;if(this.current=null,Ke(t)){this.redraw();return}this.shapes.push(t),this.undoBtn.disabled=!1,this.opts.announce?.("Annotation added"),this.redraw()};onKeyDown=t=>{if(t.key==="Escape"){t.preventDefault(),this.skip();return}if(t.key==="Enter"){const e=t.target;if(e?.getAttribute("data-qaid-tool")||e?.getAttribute("data-qaid-action"))return;t.preventDefault(),this.done()}};undo(){if(this.shapes.length===0){this.opts.announce?.("Nothing to undo");return}this.shapes.pop(),this.undoBtn.disabled=this.shapes.length===0,this.opts.announce?.("Removed last annotation"),this.redraw()}async done(){if(this.settled)return;const t=await V(this.opts.dataUrl,this.shapes,{quality:this.opts.quality});this.opts.announce?.("Annotated screenshot attached"),this.settle(t)}skip(){this.settled||(this.opts.announce?.("Annotation skipped"),this.settle(null))}settle(t){this.settled=!0,this.teardown(),this.resolveResult(t)}teardown(){this.toolbar.removeEventListener("click",this.onToolbarClick),this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.container.removeEventListener("pointermove",this.onPointerMove),this.container.removeEventListener("pointerup",this.onPointerUp),this.container.removeEventListener("keydown",this.onKeyDown),this.opts.closeDialog?.(),this.container.remove()}}const Ge={rect:"rectangle",arrow:"arrow",pen:"pen",blur:"blur"};function wt(i){return new F(i).open()}const kt=Object.freeze(Object.defineProperty({__proto__:null,AnnotationEditor:F,compositeAnnotations:V,drawShape:M,openAnnotationEditor:wt,rectFromPoints:R},Symbol.toStringTag,{value:"Module"}));Ie();const Je=document;function f(i,t,...e){const o=Je.createElement(i);if(t){if(t.class&&(o.className=t.class),t.style&&(o.style.cssText=t.style),t.html!=null&&(o.innerHTML=t.html),t.text!=null&&(o.textContent=t.text),t.attrs)for(const n in t.attrs)o.setAttribute(n,t.attrs[n]);if(t.on)for(const n in t.on)o.addEventListener(n,t.on[n])}for(const n of e)n!=null&&n!==!1&&o.append(n);return o}class Ze{constructor(t){this.host=t}videoRecorder=null;networkCapture=null;recordedBlob=null;recordingIndicator=null;videoPreview=null;isRecording=!1;isSendingVideo=!1;redactPicks=[];redactPickerRoot=null;redactRafId=0;boundRedactClick=t=>this.handleRedactPickClick(t);handleEscape(){return this.isRecording?(this.stopRecording(),!0):this.videoPreview?(this.cancelRecordingPreview(),!0):this.redactPickerRoot?(this.finishRedactionPicking(!1),!0):!1}destroy(){this.redactRafId&&cancelAnimationFrame(this.redactRafId),this.redactRafId=0,document.removeEventListener("click",this.boundRedactClick,!0),this.redactPickerRoot&&(this.redactPickerRoot.remove(),this.redactPickerRoot=null),this.redactPicks=[],this.cleanupRecording(),this.removeVideoPreview()}async startRecording(t=[]){if(!(this.isRecording||this.host.state!=="IDLE"))try{this.networkCapture=ct();const{createVideoRecorder:e}=await Promise.resolve().then(()=>ft);this.videoRecorder=e({maxDuration:this.host.config.videoOptions.maxDuration,redactionElements:t}),this.videoRecorder.onTick(o=>{this.updateRecordingTimer(o)}),this.videoRecorder.onStop(o=>{this.isRecording&&(this.recordedBlob=o,this.isRecording=!1,this.host.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.host.boundKeyDown),this.host.setButtonsDisabled(!1),o&&o.size>0?this.showRecordingPreview():this.cleanupRecording())}),await this.videoRecorder.start(),this.isRecording=!0,this.host.announceMsg("Recording started"),this.host.setButtonsDisabled(!0),this.showRecordingIndicator(),document.addEventListener("keydown",this.host.boundKeyDown)}catch(e){e instanceof Error&&/current tab/i.test(e.message)&&this.host.announceMsg(e.message),this.cleanupRecording()}}async stopRecording(){try{this.recordedBlob=await this.videoRecorder.stop()}catch{this.recordedBlob=null}this.isRecording=!1,this.host.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.host.boundKeyDown),this.recordedBlob&&this.recordedBlob.size>0?this.showRecordingPreview():this.cleanupRecording()}startPicking(){if(this.isRecording||this.host.state!=="IDLE")return;this.host.setState("REDACT_PICKING"),this.redactPicks=[];const t=this.host.ensureOverlayHost(),e=f("div",{style:"position:absolute;inset:0;"}),o=f("div",{class:"qaid-redact-picker",style:"position:fixed;inset:0;pointer-events:none;"},e,f("div",{style:"position:fixed;left:50%;bottom:24px;transform:translateX(-50%);display:flex;gap:12px;align-items:center;pointer-events:auto;background:#0b1220;color:#fff;border:1px solid #ff6b6b;border-radius:9999px;padding:10px 16px;font:600 13px system-ui,sans-serif;box-shadow:0 8px 30px rgba(0,0,0,.5);"},f("span",{text:"Click sensitive areas to blur",attrs:{"data-qaid-redact-label":""}}),f("button",{text:"Start recording",attrs:{type:"button"},style:"cursor:pointer;border:0;border-radius:9999px;padding:8px 14px;background:#ff6b6b;color:#0b1220;font:inherit;",on:{click:()=>this.finishRedactionPicking(!0)}}),f("button",{text:"Cancel",attrs:{type:"button"},style:"cursor:pointer;border:0;background:transparent;color:#9fb3c8;font:inherit;",on:{click:()=>this.finishRedactionPicking(!1)}})));t.appendChild(o),this.redactPickerRoot=o;const n=()=>{this.renderRedactPicks(e),this.redactRafId=requestAnimationFrame(n)};n(),document.addEventListener("click",this.boundRedactClick,!0),document.addEventListener("keydown",this.host.boundKeyDown),this.host.announceMsg("Click sensitive areas to blur, then start recording")}handleRedactPickClick(t){const e=t.target instanceof Element?t.target:null;if(!e||B(e)||this.redactPickerRoot?.contains(e))return;t.preventDefault(),t.stopPropagation();const o=this.redactPicks.indexOf(e);o>=0?this.redactPicks.splice(o,1):this.redactPicks.push(e);const n=this.redactPickerRoot?.querySelector("[data-qaid-redact-label]");if(n){const s=this.redactPicks.length;n.textContent=s===0?"Click sensitive areas to blur":`${s} area${s===1?"":"s"} will be blurred`}}renderRedactPicks(t){t.textContent="";for(const e of this.redactPicks){const o=e.getBoundingClientRect();o.width<=0||o.height<=0||t.appendChild(f("div",{style:`position:fixed;left:${o.left}px;top:${o.top}px;width:${o.width}px;height:${o.height}px;border:2px solid #ff6b6b;border-radius:4px;background:rgba(255,107,107,.18);pointer-events:none;`}))}}finishRedactionPicking(t){this.redactRafId&&cancelAnimationFrame(this.redactRafId),this.redactRafId=0,document.removeEventListener("click",this.boundRedactClick,!0),document.removeEventListener("keydown",this.host.boundKeyDown),this.redactPickerRoot&&(this.redactPickerRoot.remove(),this.redactPickerRoot=null);const e=this.redactPicks;this.redactPicks=[],this.host.setState("IDLE"),t&&this.startRecording(e)}showRecordingIndicator(){const t=this.host.ensureOverlayHost();this.recordingIndicator=f("div",{class:"qaid-recording-indicator",style:`z-index:${this.host.config.zIndex+100}`},f("div",{class:"qaid-recording-dot"}),f("span",{class:"qaid-recording-time",text:this.formatTime(this.host.config.videoOptions.maxDuration)}),f("button",{class:"qaid-recording-stop",text:"Stop",attrs:{type:"button"},on:{click:()=>this.stopRecording()}})),this.host.applyVars(this.recordingIndicator),this.host.overlayShadowHost&&(this.host.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.recordingIndicator)}updateRecordingTimer(t){if(!this.recordingIndicator)return;const e=this.recordingIndicator.querySelector(".qaid-recording-time");if(e){const o=Math.max(0,this.host.config.videoOptions.maxDuration-t);e.textContent=this.formatTime(o),o>0&&o<=5&&this.host.announceMsg(`${o} second${o===1?"":"s"} remaining`)}}formatTime(t){const e=Math.floor(t/60),o=t%60;return`${e}:${o.toString().padStart(2,"0")}`}removeRecordingIndicator(){this.recordingIndicator&&(this.recordingIndicator.remove(),this.recordingIndicator=null)}showRecordingPreview(){const t=this.host.ensureOverlayHost(),e=URL.createObjectURL(this.recordedBlob),o=`qaid-video-title-${this.host.uid}`,n=f("h3",{text:"Review your recording",attrs:{id:o}}),s=f("video");s.src=e,s.controls=!0,s.autoplay=!0,s.muted=!0;const a=f("textarea",{attrs:{placeholder:"Optional: Describe the issue you recorded...","aria-label":"Describe the issue you recorded"}}),c=f("button",{class:"qaid-video-btn qaid-video-btn-send",text:"Send",attrs:{type:"button"},on:{click:()=>this.submitVideoFeedback(a.value.trim()||null,c)}}),l=f("div",{class:"qaid-video-preview-box"},n,s,a,f("div",{class:"qaid-video-preview-actions"},f("button",{class:"qaid-video-btn qaid-video-btn-cancel",text:"Cancel",attrs:{type:"button"},on:{click:()=>this.cancelRecordingPreview()}}),f("button",{class:"qaid-video-btn qaid-video-btn-rerecord",text:"Re-record",attrs:{type:"button"},on:{click:()=>{this.cancelRecordingPreview(),this.startRecording()}}}),c));this.videoPreview=f("div",{class:"qaid-video-preview",style:`z-index:${this.host.config.zIndex+100}`},l),this.host.applyVars(this.videoPreview),this.host.overlayShadowHost&&(this.host.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.videoPreview),this.host.openDialogA11y(l,{labelledbyId:n.id}),document.addEventListener("keydown",this.host.boundKeyDown)}cancelRecordingPreview(){this.removeVideoPreview(),this.cleanupRecording()}removeVideoPreview(){if(this.host.closeDialogA11y(),this.videoPreview){const t=this.videoPreview.querySelector("video");t?.src&&URL.revokeObjectURL(t.src),this.videoPreview.remove(),this.videoPreview=null}document.removeEventListener("keydown",this.host.boundKeyDown)}async submitVideoFeedback(t,e){if(!this.recordedBlob||this.isSendingVideo)return;this.isSendingVideo=!0,e.disabled=!0,e.textContent="Sending...";const o=new FormData;o.append("video",this.recordedBlob,`recording.${this.recordedBlob.type.includes("mp4")?"mp4":"webm"}`),o.append("pageUrl",window.location.href),o.append("visitorId",this.host.visitorId),this.host.config.apiKey&&o.append("apiKey",this.host.config.apiKey),t&&o.append("message",t),this.host.consoleCapture&&o.append("consoleErrors",JSON.stringify(this.host.consoleCapture.errors)),this.networkCapture&&o.append("networkErrors",JSON.stringify(this.networkCapture.errors));let n=null;try{const s=await fetch(`${this.host.config.endpoint}/video`,{method:"POST",body:o});if(s.ok){this.host.announceMsg("Recording sent");try{n=(await s.json())?.id??null}catch{}}else console.error("Failed to submit video feedback:",await s.text()),this.host.announceMsg("Failed to send recording",!0)}catch(s){console.error("Failed to submit video feedback:",s),this.host.announceMsg("Failed to send recording",!0)}this.isSendingVideo=!1,this.removeVideoPreview(),this.cleanupRecording(),await this.host.tryLaunchQuest("video",n)}cleanupRecording(){this.isRecording=!1,this.removeRecordingIndicator(),this.videoRecorder&&(this.videoRecorder.destroy(),this.videoRecorder=null),this.networkCapture&&(this.networkCapture.restore(),this.networkCapture=null),this.recordedBlob&&(this.recordedBlob=null),this.host.setButtonsDisabled(!1),this.host.overlayShadowHost&&this.host.state==="IDLE"&&(this.host.overlayShadowHost.style.pointerEvents="none")}}const xt=Object.freeze(Object.defineProperty({__proto__:null,RecordingController:Ze},Symbol.toStringTag,{value:"Module"}));async function ti(i={}){const{quality:t=1,maxWidth:e=1280,maxHeight:o=800}=i;try{if(!navigator.mediaDevices?.getDisplayMedia)return console.warn("Screen Capture API not available"),null;const n=await navigator.mediaDevices.getDisplayMedia({preferCurrentTab:!0,video:{displaySurface:"browser"}}),s=n.getVideoTracks()[0],a=s.getSettings(),c=document.createElement("video");c.srcObject=n,c.muted=!0,await new Promise(v=>{c.onloadedmetadata=()=>{c.play(),v()}}),await new Promise(v=>{const x=()=>{c.readyState>=2?v():requestAnimationFrame(x)};x()}),await new Promise(v=>setTimeout(v,100));const l=a.width||c.videoWidth,r=a.height||c.videoHeight,d=Math.min(e/l,o/r,1),p=Math.round(l*d),u=Math.round(r*d),m=document.createElement("canvas");m.width=p,m.height=u;const y=m.getContext("2d");return y?(y.drawImage(c,0,0,p,u),s.stop(),m.toDataURL("image/webp",t)):(s.stop(),null)}catch(n){return console.warn("Screenshot capture failed:",n),null}}const qt=Object.freeze(Object.defineProperty({__proto__:null,captureScreenshot:ti},Symbol.toStringTag,{value:"Module"}));class ei{constructor(t){this.host=t}modalContainer=null;backdrop=null;open(){const t=this.host.ensureOverlayHost();this.backdrop=document.createElement("div"),this.backdrop.className="qaid-backdrop",this.backdrop.style.zIndex=String(this.host.config.zIndex+2),this.backdrop.style.background=`rgba(0, 0, 0, ${this.host.config.backdropOpacity})`,this.backdrop.addEventListener("click",()=>this.close()),this.host.applyVars(this.backdrop),this.host.isMobile?this.showBottomSheet():this.showPositionedModal(),t.appendChild(this.backdrop),document.addEventListener("keydown",this.host.boundKeyDown)}close(){this.host.state==="MODAL_OPEN"&&this.host.feedbackId&&fetch(`${this.host.config.endpoint}/${this.host.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:null})}).catch(t=>console.error("Failed to finalize feedback:",t)),this.teardown(),this.host.resetFeedbackUi()}destroy(){this.teardown()}teardown(){this.host.closeDialogA11y(),this.modalContainer&&(this.modalContainer.remove(),this.modalContainer=null),this.backdrop&&(this.backdrop.remove(),this.backdrop=null),document.removeEventListener("keydown",this.host.boundKeyDown)}showBottomSheet(){const t=this.host.ensureOverlayHost(),e=document.createElement("div");e.className="qaid-bottom-sheet",e.style.zIndex=String(this.host.config.zIndex+3),e.innerHTML=`
|
|
26
22
|
<div class="qaid-bottom-sheet-content">
|
|
27
23
|
<div class="qaid-bottom-sheet-handle"></div>
|
|
28
24
|
${this.getModalContent()}
|
|
29
25
|
</div>
|
|
30
|
-
`,this.applyVars(
|
|
26
|
+
`,this.host.applyVars(e),t.appendChild(e),this.modalContainer=e,this.setupModalInteractions()}showPositionedModal(){const t=this.host.ensureOverlayHost(),{modal:e,arrow:o}=me(this.host.selectedBounds,window.innerWidth,window.innerHeight,{width:this.host.config.modalWidth,height:280,arrowHeight:12,gap:8,viewportPadding:16});this.modalContainer=document.createElement("div"),this.modalContainer.className=`qaid-modal-container qaid-${e.position}`,this.modalContainer.style.top=`${e.top}px`,this.modalContainer.style.left=`${e.left}px`,this.modalContainer.style.zIndex=String(this.host.config.zIndex+3);const n=document.createElement("div");n.className="qaid-modal-arrow",n.style.left=`${o.left}px`;const s=document.createElement("div");s.className="qaid-modal-box",s.innerHTML=this.getModalContent(),this.modalContainer.appendChild(n),this.modalContainer.appendChild(s),this.host.applyVars(this.modalContainer),t.appendChild(this.modalContainer),this.setupModalInteractions()}getModalContent(){const t=this.host.feedbackData.feedbackType==="up",e=this.host.config.positiveIcon||E,o=this.host.config.negativeIcon||O;return`
|
|
31
27
|
<div class="qaid-modal-header">
|
|
32
|
-
<button type="button" class="${this.config.buttonClass?`qaid-type-toggle qaid-type-toggle-custom ${this.config.buttonClass} ${t?"qaid-btn-up":"qaid-btn-down"}`:`qaid-type-toggle ${t?"qaid-type-up":"qaid-type-down"}`}" title="Click to switch" aria-pressed="${t}" aria-label="${t?"Feedback type: positive":"Feedback type: negative"}">
|
|
33
|
-
${t?
|
|
28
|
+
<button type="button" class="${this.host.config.buttonClass?`qaid-type-toggle qaid-type-toggle-custom ${this.host.config.buttonClass} ${t?"qaid-btn-up":"qaid-btn-down"}`:`qaid-type-toggle ${t?"qaid-type-up":"qaid-type-down"}`}" title="Click to switch" aria-pressed="${t}" aria-label="${t?"Feedback type: positive":"Feedback type: negative"}">
|
|
29
|
+
${t?e:o}
|
|
34
30
|
</button>
|
|
35
31
|
<div class="qaid-modal-header-text">
|
|
36
|
-
<h3 class="qaid-modal-title" id="qaid-modal-title-${this.uid}">${this.config.text.modalTitle}</h3>
|
|
37
|
-
<p class="qaid-modal-subtitle" id="qaid-modal-subtitle-${this.uid}">${this.config.text.modalSubtitle}</p>
|
|
32
|
+
<h3 class="qaid-modal-title" id="qaid-modal-title-${this.host.uid}">${this.host.config.text.modalTitle}</h3>
|
|
33
|
+
<p class="qaid-modal-subtitle" id="qaid-modal-subtitle-${this.host.uid}">${this.host.config.text.modalSubtitle}</p>
|
|
38
34
|
</div>
|
|
39
35
|
</div>
|
|
40
|
-
<textarea class="qaid-textarea" aria-label="${this.config.text.modalSubtitle}" placeholder="${this.config.text.placeholder}"></textarea>
|
|
36
|
+
<textarea class="qaid-textarea" aria-label="${this.host.config.text.modalSubtitle}" placeholder="${this.host.config.text.placeholder}"></textarea>
|
|
41
37
|
<div class="qaid-btn-row">
|
|
42
|
-
<button type="button" class="qaid-btn-submit">${this.config.text.skipButton}</button>
|
|
38
|
+
<button type="button" class="qaid-btn-submit">${this.host.config.text.skipButton}</button>
|
|
43
39
|
</div>
|
|
44
|
-
`}setupModalInteractions(){this.openDialogA11y(this.modalContainer,{labelledbyId:`qaid-modal-title-${this.uid}`,describedbyId:`qaid-modal-subtitle-${this.uid}`});const t=this.modalContainer.querySelector(".qaid-textarea"),i=this.modalContainer.querySelector(".qaid-btn-submit");t&&(setTimeout(()=>t.focus(),100),t.addEventListener("input",()=>{i&&(i.textContent=t.value.trim()?this.config.text.submitButton:this.config.text.skipButton)})),i&&i.addEventListener("click",()=>{const n=t?.value.trim()||null;this.submitMessage(n)});const o=this.modalContainer.querySelector(".qaid-type-toggle");o&&o.addEventListener("click",()=>{const n=this.feedbackData.feedbackType==="up"?"down":"up";this.feedbackData.feedbackType=n,this.config.buttonClass?(o.classList.toggle("qaid-btn-up",n==="up"),o.classList.toggle("qaid-btn-down",n==="down")):(o.classList.toggle("qaid-type-up",n==="up"),o.classList.toggle("qaid-type-down",n==="down"));const s=this.config.positiveIcon||x,a=this.config.negativeIcon||M;o.innerHTML=n==="up"?s:a;const d=n==="up"?"Feedback type: positive":"Feedback type: negative";o.setAttribute("aria-pressed",String(n==="up")),o.setAttribute("aria-label",d),this.announceMsg(d),this.feedbackId&&fetch(`${this.config.endpoint}/${this.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedbackType:n})}).catch(c=>console.error("Failed to update feedback type:",c))})}async submitMessage(t){if(this.feedbackId){try{await fetch(`${this.config.endpoint}/${this.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t})})}catch(i){console.error("Failed to submit feedback message:",i)}this.feedbackId=null}this.closeModal()}closeModal(){this.state==="MODAL_OPEN"&&this.feedbackId&&fetch(`${this.config.endpoint}/${this.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:null})}).catch(t=>console.error("Failed to finalize feedback:",t)),this.closeDialogA11y(),this.modalContainer&&(this.modalContainer.remove(),this.modalContainer=null),this.backdrop&&(this.backdrop.remove(),this.backdrop=null),document.removeEventListener("keydown",this.boundKeyDown),this.resetFeedbackUi()}async startRecording(){if(!(this.isRecording||this.state!=="IDLE"))try{this.networkCapture=Y(),this.videoRecorder=J({maxDuration:this.config.videoOptions.maxDuration}),this.videoRecorder.onTick(t=>{this.updateRecordingTimer(t)}),this.videoRecorder.onStop(t=>{this.isRecording&&(this.recordedBlob=t,this.isRecording=!1,this.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.boundKeyDown),this.setButtonsDisabled(!1),t&&t.size>0?this.showRecordingPreview():this.cleanupRecording())}),await this.videoRecorder.start(),this.isRecording=!0,this.announceMsg("Recording started"),this.setButtonsDisabled(!0),this.showRecordingIndicator(),document.addEventListener("keydown",this.boundKeyDown)}catch{this.cleanupRecording()}}async stopRecording(){try{this.recordedBlob=await this.videoRecorder.stop()}catch{this.recordedBlob=null}this.isRecording=!1,this.announceMsg("Recording stopped"),this.removeRecordingIndicator(),document.removeEventListener("keydown",this.boundKeyDown),this.recordedBlob&&this.recordedBlob.size>0?this.showRecordingPreview():this.cleanupRecording()}showRecordingIndicator(){const t=this.ensureOverlayHost();this.recordingIndicator=document.createElement("div"),this.recordingIndicator.className="qaid-recording-indicator",this.recordingIndicator.style.zIndex=String(this.config.zIndex+100);const i=document.createElement("div");i.className="qaid-recording-dot";const o=document.createElement("span");o.className="qaid-recording-time",o.textContent=this.formatTime(this.config.videoOptions.maxDuration);const n=document.createElement("button");n.type="button",n.className="qaid-recording-stop",n.textContent="Stop",n.addEventListener("click",()=>this.stopRecording()),this.recordingIndicator.appendChild(i),this.recordingIndicator.appendChild(o),this.recordingIndicator.appendChild(n),this.applyVars(this.recordingIndicator),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.recordingIndicator)}updateRecordingTimer(t){if(!this.recordingIndicator)return;const i=this.recordingIndicator.querySelector(".qaid-recording-time");if(i){const o=Math.max(0,this.config.videoOptions.maxDuration-t);i.textContent=this.formatTime(o),o>0&&o<=5&&this.announceMsg(`${o} second${o===1?"":"s"} remaining`)}}formatTime(t){const i=Math.floor(t/60),o=t%60;return`${i}:${o.toString().padStart(2,"0")}`}removeRecordingIndicator(){this.recordingIndicator&&(this.recordingIndicator.remove(),this.recordingIndicator=null)}showRecordingPreview(){const t=this.ensureOverlayHost(),i=URL.createObjectURL(this.recordedBlob);this.videoPreview=document.createElement("div"),this.videoPreview.className="qaid-video-preview",this.videoPreview.style.zIndex=String(this.config.zIndex+100);const o=document.createElement("div");o.className="qaid-video-preview-box";const n=document.createElement("h3");n.textContent="Review your recording",n.id=`qaid-video-title-${this.uid}`;const s=document.createElement("video");s.src=i,s.controls=!0,s.autoplay=!0,s.muted=!0;const a=document.createElement("textarea");a.placeholder="Optional: Describe the issue you recorded...",a.setAttribute("aria-label","Describe the issue you recorded");const d=document.createElement("div");d.className="qaid-video-preview-actions";const c=document.createElement("button");c.type="button",c.className="qaid-video-btn qaid-video-btn-cancel",c.textContent="Cancel",c.addEventListener("click",()=>this.cancelRecordingPreview());const r=document.createElement("button");r.type="button",r.className="qaid-video-btn qaid-video-btn-rerecord",r.textContent="Re-record",r.addEventListener("click",()=>{this.cancelRecordingPreview(),this.startRecording()});const l=document.createElement("button");l.type="button",l.className="qaid-video-btn qaid-video-btn-send",l.textContent="Send",l.addEventListener("click",()=>{const p=a.value.trim()||null;this.submitVideoFeedback(p,l)}),d.appendChild(c),d.appendChild(r),d.appendChild(l),o.appendChild(n),o.appendChild(s),o.appendChild(a),o.appendChild(d),this.videoPreview.appendChild(o),this.applyVars(this.videoPreview),this.overlayShadowHost&&(this.overlayShadowHost.style.pointerEvents="auto"),t.appendChild(this.videoPreview),this.openDialogA11y(o,{labelledbyId:n.id}),document.addEventListener("keydown",this.boundKeyDown)}cancelRecordingPreview(){this.removeVideoPreview(),this.cleanupRecording()}removeVideoPreview(){if(this.closeDialogA11y(),this.videoPreview){const t=this.videoPreview.querySelector("video");t?.src&&URL.revokeObjectURL(t.src),this.videoPreview.remove(),this.videoPreview=null}document.removeEventListener("keydown",this.boundKeyDown)}async submitVideoFeedback(t,i){if(!this.recordedBlob||this.isSendingVideo)return;this.isSendingVideo=!0,i.disabled=!0,i.textContent="Sending...";const o=new FormData;o.append("video",this.recordedBlob,`recording.${this.recordedBlob.type.includes("mp4")?"mp4":"webm"}`),o.append("pageUrl",window.location.href),o.append("visitorId",this.visitorId),this.config.apiKey&&o.append("apiKey",this.config.apiKey),t&&o.append("message",t),this.consoleCapture&&o.append("consoleErrors",JSON.stringify(this.consoleCapture.errors)),this.networkCapture&&o.append("networkErrors",JSON.stringify(this.networkCapture.errors));let n=null;try{const s=await fetch(`${this.config.endpoint}/video`,{method:"POST",body:o});if(s.ok){this.announceMsg("Recording sent");try{n=(await s.json())?.id??null}catch{}}else console.error("Failed to submit video feedback:",await s.text()),this.announceMsg("Failed to send recording",!0)}catch(s){console.error("Failed to submit video feedback:",s),this.announceMsg("Failed to send recording",!0)}this.isSendingVideo=!1,this.removeVideoPreview(),this.cleanupRecording(),await this.tryLaunchQuest("video",n)}cleanupRecording(){this.isRecording=!1,this.removeRecordingIndicator(),this.videoRecorder&&(this.videoRecorder.destroy(),this.videoRecorder=null),this.networkCapture&&(this.networkCapture.restore(),this.networkCapture=null),this.recordedBlob&&(this.recordedBlob=null),this.setButtonsDisabled(!1),this.overlayShadowHost&&this.state==="IDLE"&&(this.overlayShadowHost.style.pointerEvents="none")}setButtonsDisabled(t){if(!this.buttonsContainer)return;this.buttonsContainer.querySelectorAll("button.qaid-btn, button.qaid-btn-structural").forEach(o=>{t?o.classList.contains("qaid-btn-record")||(o.disabled=!0,o.style.opacity="0.5"):(o.disabled=!1,o.style.opacity="")})}destroy(){this.destroyed=!0,this.domObserver&&(this.domObserver.disconnect(),this.domObserver=null),this.boundBeforeSwap&&(document.removeEventListener("astro:before-swap",this.boundBeforeSwap),this.boundBeforeSwap=null),this.keyboardController?.stop(),this.keyboardController=null,this.clearActiveThumb(),this.closeDialogA11y(),this.cleanupRecording(),this.removeVideoPreview(),this.activeQuest?.destroy(),this.activeQuest=null,this.consoleCapture&&(this.consoleCapture.restore(),this.consoleCapture=null),window.removeEventListener("resize",this.boundResize),document.removeEventListener("keydown",this.boundKeyDown),document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),document.removeEventListener("touchstart",this.boundTouchStart),document.removeEventListener("touchend",this.boundTouchEnd),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.shadowHost&&(this.shadowHost.remove(),this.shadowHost=null,this.shadowRoot=null),this.overlayShadowHost&&(this.overlayShadowHost.remove(),this.overlayShadowHost=null,this.overlayShadowRoot=null),this.buttonsContainer=null,this.overlayContainer=null,this.captureLayer=null,this.crosshairH=null,this.crosshairV=null,this.scope=null,this.marker=null,this.modalContainer=null,this.backdrop=null,this.dismissBtn=null,this.tooltipElement=null,Pt()}}function ht(e){return document.querySelector(e)?.textContent?.trim()??""}function We(){const e=document.querySelector('script[type="application/json"][data-feedback-config]');if(!e)return null;const t=e.textContent?.trim();if(!t)return null;try{const i=JSON.parse(t);return i.cssSelector&&!i.css&&(i.css=ht(i.cssSelector),delete i.cssSelector),i}catch{return null}}function Xe(e){const t=e.getAttribute("data-endpoint");if(!t)return null;const i=e.getAttribute("data-position"),o=e.getAttribute("data-zindex"),n=e.getAttribute("data-positive-color"),s=e.getAttribute("data-negative-color"),a=e.getAttribute("data-marker-color"),d=e.getAttribute("data-container"),c=e.getAttribute("data-button-class"),r=e.getAttribute("data-skip-targeting"),l=e.getAttribute("data-incognito"),p=e.getAttribute("data-button-size"),u=e.getAttribute("data-offset-x"),f=e.getAttribute("data-offset-y"),g=e.getAttribute("data-modal-width"),y=e.getAttribute("data-backdrop-opacity"),w=e.getAttribute("data-font-family"),m=e.getAttribute("data-font-size"),h=e.getAttribute("data-tooltip"),q=e.getAttribute("data-modal-title"),v=e.getAttribute("data-modal-subtitle"),D=e.getAttribute("data-placeholder"),ut=e.getAttribute("data-submit-button"),pt=e.getAttribute("data-skip-button"),Ye=e.getAttribute("data-positive-icon"),Qe=e.getAttribute("data-negative-icon"),Ge=e.getAttribute("data-api-key"),Je=e.getAttribute("data-capture-screenshot"),Ze=e.getAttribute("data-annotate"),O=e.getAttribute("data-screenshot-quality"),z=e.getAttribute("data-screenshot-max-width"),$=e.getAttribute("data-screenshot-max-height"),ti=e.getAttribute("data-capture-video"),ei=e.getAttribute("data-hide-thumbs"),ii=e.getAttribute("data-hide-dismiss"),ft=e.getAttribute("data-video-max-duration"),oi=e.getAttribute("data-screenshot-method"),ni=e.getAttribute("data-direction"),mt=e.getAttribute("data-css-selector"),bt=e.getAttribute("data-quest-base"),si=e.getAttribute("data-quest-up"),ai=e.getAttribute("data-quest-down"),ri=e.getAttribute("data-quest-video"),di=e.getAttribute("data-quest-api-key"),li=e.getAttribute("data-quest-module-url");return{endpoint:t,css:mt?ht(mt):void 0,apiKey:Ge??void 0,captureScreenshot:Je==="true"?!0:void 0,annotate:Ze==="false"?!1:void 0,screenshotOptions:O||z||$?{quality:O?parseFloat(O):void 0,maxWidth:z?parseInt(z,10):void 0,maxHeight:$?parseInt($,10):void 0}:void 0,container:d??void 0,buttonClass:c??void 0,direction:ni??void 0,position:i??void 0,zIndex:o?parseInt(o,10):void 0,skipTargeting:r==="true"?!0:void 0,incognito:l==="true"?!0:void 0,buttonSize:p??void 0,offset:u||f?{x:u?parseInt(u,10):void 0,y:f?parseInt(f,10):void 0}:void 0,modalWidth:g?parseInt(g,10):void 0,backdropOpacity:y?parseFloat(y):void 0,fontFamily:w??void 0,fontSize:m?parseInt(m,10):void 0,colors:{positive:n??void 0,negative:s??void 0,marker:a??void 0},text:h||q||v||D||ut||pt?{tooltip:h??void 0,modalTitle:q??void 0,modalSubtitle:v??void 0,placeholder:D??void 0,submitButton:ut??void 0,skipButton:pt??void 0}:void 0,positiveIcon:Ye??void 0,negativeIcon:Qe??void 0,screenshotMethod:oi??void 0,captureVideo:ti==="true"?!0:void 0,hideThumbs:ei==="true"?!0:void 0,hideDismiss:ii==="true"?!0:void 0,videoOptions:ft?{maxDuration:parseInt(ft,10)}:void 0,quests:bt?{base:bt,up:si??void 0,down:ai??void 0,video:ri??void 0,apiKey:di??void 0,moduleUrl:li??void 0}:void 0}}if(typeof document<"u"){const e=()=>{const t=document.currentScript,i=We(),o=t?Xe(t):null,n=i??o;n?.endpoint&&new ct(n)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):e()}b.AnnotationEditor=st,b.QaidFeedback=ct,b.captureDomScreenshot=it,b.captureNetworkErrors=Y,b.compositeAnnotations=nt,b.createVideoRecorder=J,b.drawShape=I,b.getSupportedMimeType=G,b.isDomScreenshotSupported=Te,b.isVideoRecordingSupported=Q,b.openAnnotationEditor=at,b.rectFromPoints=A,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
|
|
40
|
+
`}setupModalInteractions(){this.host.openDialogA11y(this.modalContainer,{labelledbyId:`qaid-modal-title-${this.host.uid}`,describedbyId:`qaid-modal-subtitle-${this.host.uid}`});const t=this.modalContainer.querySelector(".qaid-textarea"),e=this.modalContainer.querySelector(".qaid-btn-submit");t&&(setTimeout(()=>t.focus(),100),t.addEventListener("input",()=>{e&&(e.textContent=t.value.trim()?this.host.config.text.submitButton:this.host.config.text.skipButton)})),e&&e.addEventListener("click",()=>{const n=t?.value.trim()||null;this.submitMessage(n)});const o=this.modalContainer.querySelector(".qaid-type-toggle");o&&o.addEventListener("click",()=>{const n=this.host.feedbackData.feedbackType==="up"?"down":"up";this.host.feedbackData.feedbackType=n,this.host.config.buttonClass?(o.classList.toggle("qaid-btn-up",n==="up"),o.classList.toggle("qaid-btn-down",n==="down")):(o.classList.toggle("qaid-type-up",n==="up"),o.classList.toggle("qaid-type-down",n==="down"));const s=this.host.config.positiveIcon||E,a=this.host.config.negativeIcon||O;o.innerHTML=n==="up"?s:a;const c=n==="up"?"Feedback type: positive":"Feedback type: negative";o.setAttribute("aria-pressed",String(n==="up")),o.setAttribute("aria-label",c),this.host.announceMsg(c),this.host.feedbackId&&fetch(`${this.host.config.endpoint}/${this.host.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedbackType:n})}).catch(l=>console.error("Failed to update feedback type:",l))})}async submitMessage(t){if(this.host.feedbackId){try{await fetch(`${this.host.config.endpoint}/${this.host.feedbackId}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:t})})}catch(e){console.error("Failed to submit feedback message:",e)}this.host.setFeedbackId(null)}this.close()}}const Ct=Object.freeze(Object.defineProperty({__proto__:null,ModalController:ei},Symbol.toStringTag,{value:"Module"})),St=["data-comp","data-qa","data-testid","data-id"];function Et(i,t=document.body){let e=i;for(;e&&e!==t;){for(const o of St){const n=e.getAttribute(o);if(n)return`${o}="${n}"`}e=e.parentElement}return null}function ii(i,t=100){const e=i.textContent?.trim().slice(0,t)||"";return e.length===t?e+"...":e}function oi(i){let t=1,e=i.previousElementSibling;for(;e;)t++,e=e.previousElementSibling;return t}function ni(i){const t=[];let e=i;for(;e&&e!==document.body&&e!==document.documentElement;){const o=e.tagName.toLowerCase(),n=oi(e);t.unshift(`${o}:nth-child(${n})`),e=e.parentElement}return t.length>0?`body > ${t.join(" > ")}`:"body"}function si(i){return i.replace(/([!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function ai(i){const t=Et(i);return t?`[${t}]`:i.id?`#${si(i.id)}`:ni(i)}function N(i){const t=ii(i),e=Et(i);return{selector:ai(i),text:t,dataAttr:e}}const ri=["a[href]","button","input:not([type=hidden])","select","textarea","summary","[tabindex]","[role]","img","h1","h2","h3","h4","h5","h6","p","li","label",...St.map(i=>`[${i}]`)].join(","),di=/^(?:A|BUTTON|INPUT|SELECT|TEXTAREA|SUMMARY)$/;function ci(i){if(i.hasAttribute("hidden")||i.getAttribute("aria-hidden")==="true")return!1;const t=i.ownerDocument?.defaultView;if(t&&typeof t.getComputedStyle=="function"){const e=t.getComputedStyle(i);if(e.display==="none"||e.visibility==="hidden")return!1}return!0}function li(i={}){const t=i.root??document.body,e=i.selector??ri,o=i.isExcluded??(()=>!1),n=i.isVisible??ci;return Array.from(t.querySelectorAll(e)).filter(s=>!o(s)&&n(s))}function hi(i){const t=i.candidates??li({root:i.root,selector:i.selector,isExcluded:i.isExcluded,isVisible:i.isVisible}),e=i.moveFocus??!0,o=i.eventTarget??document,n=new Set;let s=-1,a=!1;const c=i.initial!==void 0?i.initial:typeof document<"u"?document.activeElement:null;if(c){const h=t.indexOf(c);h>=0&&(s=h)}s<0&&t.length>0&&(s=0);function l(h){if(!e)return;const w=h;if(typeof w.focus=="function"){h.getAttribute("tabindex")===null&&!di.test(h.tagName)&&(h.setAttribute("tabindex","-1"),n.add(h));try{w.focus()}catch{}}}function r(){const h=t[s];h&&(l(h),i.onHighlight?.(h,s))}function d(h){if(a||t.length===0)return;const w=t.length;s=(h%w+w)%w,r()}function p(){d(s+1)}function u(){d(s-1)}function m(){return t[s]??null}function y(){a||(a=!0,o.removeEventListener("keydown",q,!0),n.forEach(h=>h.removeAttribute("tabindex")),n.clear())}function v(){if(a)return;const h=m();y(),h&&i.onSelect(h)}function x(){a||(y(),i.onCancel?.())}function q(h){if(!a)switch(h.key){case"Tab":h.preventDefault(),h.stopPropagation(),h.shiftKey?u():p();break;case"ArrowDown":case"ArrowRight":h.preventDefault(),h.stopPropagation(),p();break;case"ArrowUp":case"ArrowLeft":h.preventDefault(),h.stopPropagation(),u();break;case"Enter":case" ":case"Spacebar":h.preventDefault(),h.stopPropagation(),v();break;case"Escape":case"Esc":h.preventDefault(),h.stopPropagation(),x();break}}return o.addEventListener("keydown",q,!0),s>=0&&r(),{candidates:t,getIndex:()=>s,getCurrent:m,next:p,prev:u,moveTo:d,select:v,cancel:x,handleKey:q,stop:y}}const ui=12;class pi{constructor(t){this.host=t}mousePos={x:0,y:0};touchStartPos=null;overlayContainer=null;captureLayer=null;crosshairH=null;crosshairV=null;scope=null;highlightBox=null;marker=null;keyboardController=null;boundMouseMove=t=>this.handleMouseMove(t);boundClick=t=>this.handleClick(t);boundTouchStart=t=>this.handleTouchStart(t);boundTouchEnd=t=>this.handleTouchEnd(t);startPointer(t,e){this.host.setState("TARGETING"),this.host.feedbackData.feedbackType=t,this.host.feedbackData.elementSelector=null,this.host.feedbackData.elementText=null,this.host.selectedBounds.visible=!1,this.mousePos.x=e.clientX,this.mousePos.y=e.clientY,document.body.classList.add("qaid-targeting"),t==="up"?document.body.classList.add("qaid-type-up"):document.body.classList.remove("qaid-type-up"),document.body.style.setProperty("--qaid-positive",this.host.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.host.cssVars["--qaid-negative"]),this.createTargetingOverlay(),document.addEventListener("keydown",this.host.boundKeyDown),document.addEventListener("mousemove",this.boundMouseMove),document.addEventListener("click",this.boundClick,!0),document.addEventListener("touchstart",this.boundTouchStart,{passive:!0}),document.addEventListener("touchend",this.boundTouchEnd,{passive:!1})}startKeyboard(t){this.host.setState("TARGETING"),this.host.feedbackData.feedbackType=t,this.host.feedbackData.elementSelector=null,this.host.feedbackData.elementText=null,this.host.selectedBounds.visible=!1,document.body.style.setProperty("--qaid-positive",this.host.cssVars["--qaid-positive"]),document.body.style.setProperty("--qaid-negative",this.host.cssVars["--qaid-negative"]),this.createTargetingOverlay(),this.crosshairH&&(this.crosshairH.style.display="none"),this.crosshairV&&(this.crosshairV.style.display="none"),this.scope&&(this.scope.style.display="none"),this.keyboardController=hi({isExcluded:e=>B(e),onHighlight:e=>{const o=e.getBoundingClientRect(),n=this.highlightBox;n&&(n.style.transform=`translate(${o.left}px, ${o.top}px)`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`,n.style.display="block");const{text:s}=N(e);this.host.announceMsg(`Targeting ${s||e.tagName.toLowerCase()}`)},onSelect:e=>this.selectKeyboardTarget(e),onCancel:()=>this.cancel()})}selectKeyboardTarget(t){const e=et(t,8);Object.assign(this.host.selectedBounds,e,{clickX:e.x+e.width/2,clickY:e.y+e.height/2,visible:!0});const{selector:o,text:n}=N(t);this.host.feedbackData.elementSelector=o,this.host.feedbackData.elementText=n,this.removeTargetingOverlay(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.keyboardController=null,this.host.clearActiveThumb(),this.host.setState("SELECTED"),this.showSelectedMarker(),this.host.submitFeedback()}createTargetingOverlay(){const t=this.host.ensureOverlayHost();this.overlayContainer=document.createElement("div"),this.overlayContainer.className=`qaid-targeting-overlay qaid-type-${this.host.feedbackData.feedbackType}`,this.captureLayer=document.createElement("div"),this.captureLayer.className="qaid-capture-layer";const e=document.createElement("div");e.className="qaid-vignette",this.crosshairH=document.createElement("div"),this.crosshairH.className="qaid-crosshair-h",this.crosshairV=document.createElement("div"),this.crosshairV.className="qaid-crosshair-v",this.scope=document.createElement("div"),this.scope.className="qaid-scope",this.scope.innerHTML=`
|
|
41
|
+
<div class="qaid-scope-ring"></div>
|
|
42
|
+
<div class="qaid-scope-ring-inner"></div>
|
|
43
|
+
<div class="qaid-scope-dot"></div>
|
|
44
|
+
`,this.highlightBox=document.createElement("div"),this.highlightBox.className="qaid-highlight-box",this.overlayContainer.appendChild(this.captureLayer),this.overlayContainer.appendChild(e),this.overlayContainer.appendChild(this.highlightBox),this.overlayContainer.appendChild(this.crosshairH),this.overlayContainer.appendChild(this.crosshairV),this.overlayContainer.appendChild(this.scope),this.crosshairH.style.top=`${this.mousePos.y}px`,this.crosshairV.style.left=`${this.mousePos.x}px`,this.scope.style.left=`${this.mousePos.x}px`,this.scope.style.top=`${this.mousePos.y}px`,this.host.applyVars(this.overlayContainer),t.appendChild(this.overlayContainer)}handleMouseMove(t){this.updateReticleAt(t.clientX,t.clientY)}updateReticleAt(t,e){if(this.mousePos.x=t,this.mousePos.y=e,this.crosshairH&&(this.crosshairH.style.top=`${e}px`),this.crosshairV&&(this.crosshairV.style.left=`${t}px`),this.scope&&(this.scope.style.left=`${t}px`,this.scope.style.top=`${e}px`),this.captureLayer&&this.host.shadowHost){const o=[this.host.shadowHost,this.host.overlayShadowHost].filter(Boolean),n=tt(t,e,o);if(n&&!B(n)){if(this.highlightBox){const s=n.getBoundingClientRect();this.highlightBox.style.transform=`translate(${s.left}px, ${s.top}px)`,this.highlightBox.style.width=`${s.width}px`,this.highlightBox.style.height=`${s.height}px`,this.highlightBox.style.display="block"}}else this.highlightBox&&(this.highlightBox.style.display="none")}}handleClick(t){t.preventDefault(),t.stopPropagation(),this.selectAt(t.clientX,t.clientY)}handleTouchStart(t){const e=t.touches[0];e&&(this.touchStartPos={x:e.clientX,y:e.clientY},this.updateReticleAt(e.clientX,e.clientY))}handleTouchEnd(t){const e=t.changedTouches[0],o=this.touchStartPos;this.touchStartPos=null,!(!e||!o||Math.hypot(e.clientX-o.x,e.clientY-o.y)>ui)&&(t.preventDefault(),this.selectAt(e.clientX,e.clientY))}selectAt(t,e){const o=[this.host.shadowHost,this.host.overlayShadowHost].filter(Boolean),n=tt(t,e,o);if(!n||B(n))return;const s=et(n,8);Object.assign(this.host.selectedBounds,s,{clickX:t,clickY:e,visible:!0});const{selector:a,text:c}=N(n);this.host.feedbackData.elementSelector=a,this.host.feedbackData.elementText=c,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.host.setState("SELECTED"),this.host.clearActiveThumb(),this.showSelectedMarker(),this.host.submitFeedback()}stopTargetingListeners(){this.removeTargetingOverlay(),this.touchStartPos=null,document.removeEventListener("mousemove",this.boundMouseMove),document.removeEventListener("click",this.boundClick,!0),document.removeEventListener("touchstart",this.boundTouchStart),document.removeEventListener("touchend",this.boundTouchEnd),document.removeEventListener("keydown",this.host.boundKeyDown)}cancel(){this.keyboardController?.stop(),this.keyboardController=null,this.stopTargetingListeners(),document.body.classList.remove("qaid-targeting","qaid-type-up"),document.body.style.removeProperty("--qaid-positive"),document.body.style.removeProperty("--qaid-negative"),this.host.clearActiveThumb(),this.host.setState("IDLE"),this.host.feedbackData.feedbackType=null,this.host.feedbackData.elementSelector=null,this.host.feedbackData.elementText=null,this.host.selectedBounds.visible=!1}removeTargetingOverlay(){this.overlayContainer&&(this.overlayContainer.remove(),this.overlayContainer=null),this.captureLayer=null,this.crosshairH=null,this.crosshairV=null,this.scope=null}showSelectedMarker(){const t=this.host.ensureOverlayHost();this.marker=document.createElement("div"),this.marker.className="qaid-selected-marker",this.marker.style.left=`${this.host.selectedBounds.x}px`,this.marker.style.top=`${this.host.selectedBounds.y}px`,this.marker.style.width=`${this.host.selectedBounds.width}px`,this.marker.style.height=`${this.host.selectedBounds.height}px`,this.marker.style.zIndex=String(this.host.config.zIndex+1),this.host.applyVars(this.marker),t.appendChild(this.marker)}hideMarker(){this.marker&&(this.marker.remove(),this.marker=null)}destroy(){this.keyboardController?.stop(),this.keyboardController=null,this.stopTargetingListeners(),this.hideMarker()}}const Tt=Object.freeze(Object.defineProperty({__proto__:null,TargetingController:pi},Symbol.toStringTag,{value:"Module"}));b.AnnotationEditor=F,b.QaidFeedback=st,b.captureDomScreenshot=bt,b.captureNetworkErrors=ct,b.compositeAnnotations=V,b.createVideoRecorder=pt,b.drawShape=M,b.getSupportedMimeType=_,b.isDomScreenshotSupported=gt,b.isVideoRecordingSupported=ut,b.openAnnotationEditor=wt,b.rectFromPoints=R,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})}));
|
|
45
45
|
//# sourceMappingURL=qaid.umd.cjs.map
|