@siteping/widget 0.9.11 → 0.9.12

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/react.js CHANGED
@@ -1,4 +1,4 @@
1
- import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,f,k,B,D,C,A,n,o,p,q as q$1,E as E$1}from'./chunk-EF2HNCBX.js';import {useRef,useState,useEffect}from'react';var E,Ae,dt;function ut(t,e){if(dt=new Date,t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return "html";let n={root:document.body,idName:o=>true,className:o=>true,tagName:o=>true,attr:(o,s)=>false,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};E={...n,...e},Ae=qt(E.root,n);let i=Z(t,"all",()=>Z(t,"two",()=>Z(t,"one",()=>Z(t,"none"))));if(i){let o=mt(gt(i,t));return o.length>0&&(i=o[0]),te(i)}else throw new Error("Selector was not found.")}function qt(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function Z(t,e,n){let i=null,o=[],s=t,r=0;for(;s;){let p=new Date().getTime()-dt.getTime();if(E.timeoutMs!==void 0&&p>E.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${p}ms`);let a=ee(Wt(s))||ee(...Gt(s))||ee(...Vt(s))||ee(Jt(s))||[ct()],c=Zt(s);if(e=="all")c&&(a=a.concat(a.filter(Ce).map(l=>Q(l,c))));else if(e=="two")a=a.slice(0,1),c&&(a=a.concat(a.filter(Ce).map(l=>Q(l,c))));else if(e=="one"){let[l]=a=a.slice(0,1);c&&Ce(l)&&(a=[Q(l,c)]);}else e=="none"&&(a=[ct()],c&&(a=[Q(a[0],c)]));for(let l of a)l.level=r;if(o.push(a),o.length>=E.seedMinLength&&(i=lt(o,n),i))break;s=s.parentElement,r++;}return i||(i=lt(o,n)),!i&&n?n():i}function lt(t,e){let n=mt(ft(t));if(n.length>E.threshold)return e?e():null;for(let i of n)if(ht(i))return i;return null}function te(t){let e=t[0],n=e.name;for(let i=1;i<t.length;i++){let o=t[i].level||0;e.level===o-1?n=`${t[i].name} > ${n}`:n=`${t[i].name} ${n}`,e=t[i];}return n}function pt(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function ht(t){let e=te(t);switch(Ae.querySelectorAll(e).length){case 0:throw new Error(`Can't select any node with this selector: ${e}`);case 1:return true;default:return false}}function Wt(t){let e=t.getAttribute("id");return e&&E.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Gt(t){return Array.from(t.attributes).filter(n=>E.attr(n.name,n.value)).map(n=>({name:`[${CSS.escape(n.name)}="${CSS.escape(n.value)}"]`,penalty:.5}))}function Vt(t){return Array.from(t.classList).filter(E.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function Jt(t){let e=t.tagName.toLowerCase();return E.tagName(e)?{name:e,penalty:2}:null}function ct(){return {name:"*",penalty:3}}function Zt(t){let e=t.parentNode;if(!e)return null;let n=e.firstChild;if(!n)return null;let i=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&i++,n!==t);)n=n.nextSibling;return i}function Q(t,e){return {name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function Ce(t){return t.name!=="html"&&!t.name.startsWith("#")}function ee(...t){let e=t.filter(Qt);return e.length>0?e:null}function Qt(t){return t!=null}function*ft(t,e=[]){if(t.length>0)for(let n of t[0])yield*ft(t.slice(1,t.length),e.concat(n));else yield e;}function mt(t){return [...t].sort((e,n)=>pt(e)-pt(n))}function*gt(t,e,n={counter:0,visited:new Map}){if(t.length>2&&t.length>E.optimizedMinLength)for(let i=1;i<t.length-1;i++){if(n.counter>E.maxNumberOfTries)return;n.counter+=1;let o=[...t];o.splice(i,1);let s=te(o);if(n.visited.has(s))return;ht(o)&&en(o,e)&&(yield o,n.visited.set(s,true),yield*gt(o,e,n));}}function en(t,e){return Ae.querySelector(te(t))===e}var tn=["role","aria-label","type","name","href","src","data-testid","data-id"];function nn(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n)|0;return (e>>>0).toString(36)}function Re(t){let e=t.children.length,n=0,i=t.parentElement;if(i)for(let r of i.children){if(r===t)break;r.tagName===t.tagName&&n++;}let o=[];for(let r of tn){let p=t.getAttribute(r);p&&o.push(`${r}=${p}`);}let s=o.length>0?nn(o.join(",")):"0";return `${e}:${n}:${s}`}function bt(t,e){let n=e.split(":");if(n.length!==3)return 0;let[i,o,s]=n,r=Number(i),p=Number(o);if(Number.isNaN(r)||Number.isNaN(p))return 0;let a=Re(t),[c,l,d]=a.split(":"),h=0,f=Math.abs(Number(c)-r);f===0?h+=.2:f<=2?h+=.1:f<=5&&(h+=.03);let x=Math.abs(Number(l)-p);return x===0?h+=.4:x===1?h+=.2:x<=3&&(h+=.08),d===s&&(h+=.4),h}function _(t,e){let n=e==="before"?"previousElementSibling":"nextElementSibling",i=t[n],o=3;for(;i&&o>0;){let s=i.textContent?.trim();if(s)return e==="before"?s.slice(-32):s.slice(0,32);i=i[n],o--;}return ""}function ne(t){let e=t.previousElementSibling?.textContent?.trim().slice(0,40)??"",n=t.nextElementSibling?.textContent?.trim().slice(0,40)??"";return [e,n].filter(Boolean).join(" | ")}function yt(t){if(t.id){let i=t.id.includes("'")?`concat('${t.id.replace(/'/g,`',"'",'`)}')`:`'${t.id}'`;return `//${t.localName}[@id=${i}]`}let e=[],n=t;for(;n&&n!==document.body&&e.length<6;){let i=n.localName,o=n.parentElement;if(n.id){let r=n.id.includes("'")?`concat('${n.id.replace(/'/g,`',"'",'`)}')`:`'${n.id}'`;return e.unshift(`/${i}[@id=${r}]`),"/"+e.join("")}let s=1;if(o)for(let r of o.children){if(r===n)break;r.localName===i&&s++;}e.unshift(`/${i}[${s}]`),n=o;}return "/html/body"+e.join("")}var j="data-feedback-anchor";function Le(t){let e=ut(t,{className:d=>!/^(css|sc|emotion|styled)-/.test(d)&&!/^[a-z]{1,3}[A-Za-z0-9]{4,8}$/.test(d),attr:d=>["data-testid","data-id","role","aria-label"].includes(d),idName:d=>!d.startsWith("radix-")&&!/^:r[0-9]+:$/.test(d),seedMinLength:3,optimizedMinLength:2}),n=yt(t),o=(t.textContent?.trim()??"").slice(0,120),s=_(t,"before"),r=_(t,"after"),p=Re(t),a=ne(t),l=t.closest(`[${j}]`)?.getAttribute(j)??null;return {cssSelector:e,xpath:n,textSnippet:o,textPrefix:s,textSuffix:r,fingerprint:p,neighborText:a,elementTag:t.tagName,elementId:t.id||void 0,anchorKey:l}}function vt(t,e){let n=t.getBoundingClientRect();return n.left<=e.x&&n.top<=e.y&&n.right>=e.x+e.width&&n.bottom>=e.y+e.height}function xt(t,e=document.documentElement){let n=t.x+t.width/2,i=t.y+t.height/2,o=document.elementFromPoint(n,i);if(!o||o===e)return document.body;let s=o;for(;s&&s!==document.body;){if(s.hasAttribute(j)&&vt(s,t))return s;s=s.parentElement;}for(s=o;s&&s!==document.body;){if(vt(s,t))return s;s=s.parentElement;}return document.body}function wt(t,e){return e.width<=0||e.height<=0?{xPct:0,yPct:0,wPct:1,hPct:1}:{xPct:(t.x-e.x)/e.width,yPct:(t.y-e.y)/e.height,wPct:t.width/e.width,hPct:t.height/e.height}}var ie=class{constructor(e,n$1){this.colors=e;this.t=n$1;this.root=b("div",{style:`
1
+ import {G,H as H$1,w,F,U as U$1,T,L,J as J$1,Y as Y$1,N,z as z$1,b,x,y,I,c,e,g,h,j as j$1,i,a,f,k as k$1,B,D,C,A,n,o,p,q as q$1,E}from'./chunk-EF2HNCBX.js';import {useRef,useState,useEffect}from'react';var k,Ce,ht;function ft(t,e){if(ht=new Date,t.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if(t.tagName.toLowerCase()==="html")return "html";let n={root:document.body,idName:o=>true,className:o=>true,tagName:o=>true,attr:(o,s)=>false,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};k={...n,...e},Ce=Wt(k.root,n);let i=J(t,"all",()=>J(t,"two",()=>J(t,"one",()=>J(t,"none"))));if(i){let o=gt(yt(i,t));return o.length>0&&(i=o[0]),ee(i)}else throw new Error("Selector was not found.")}function Wt(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function J(t,e,n){let i=null,o=[],s=t,r=0;for(;s;){let a=new Date().getTime()-ht.getTime();if(k.timeoutMs!==void 0&&a>k.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${a}ms`);let l=Q(Gt(s))||Q(...Vt(s))||Q(...Jt(s))||Q(Zt(s))||[ut()],c=Qt(s);if(e=="all")c&&(l=l.concat(l.filter(Te).map(d=>Z(d,c))));else if(e=="two")l=l.slice(0,1),c&&(l=l.concat(l.filter(Te).map(d=>Z(d,c))));else if(e=="one"){let[d]=l=l.slice(0,1);c&&Te(d)&&(l=[Z(d,c)]);}else e=="none"&&(l=[ut()],c&&(l=[Z(l[0],c)]));for(let d of l)d.level=r;if(o.push(l),o.length>=k.seedMinLength&&(i=pt(o,n),i))break;s=s.parentElement,r++;}return i||(i=pt(o,n)),!i&&n?n():i}function pt(t,e){let n=gt(bt(t));if(n.length>k.threshold)return e?e():null;for(let i of n)if(mt(i))return i;return null}function ee(t){let e=t[0],n=e.name;for(let i=1;i<t.length;i++){let o=t[i].level||0;e.level===o-1?n=`${t[i].name} > ${n}`:n=`${t[i].name} ${n}`,e=t[i];}return n}function dt(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function mt(t){let e=ee(t);switch(Ce.querySelectorAll(e).length){case 0:throw new Error(`Can't select any node with this selector: ${e}`);case 1:return true;default:return false}}function Gt(t){let e=t.getAttribute("id");return e&&k.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Vt(t){return Array.from(t.attributes).filter(n=>k.attr(n.name,n.value)).map(n=>({name:`[${CSS.escape(n.name)}="${CSS.escape(n.value)}"]`,penalty:.5}))}function Jt(t){return Array.from(t.classList).filter(k.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function Zt(t){let e=t.tagName.toLowerCase();return k.tagName(e)?{name:e,penalty:2}:null}function ut(){return {name:"*",penalty:3}}function Qt(t){let e=t.parentNode;if(!e)return null;let n=e.firstChild;if(!n)return null;let i=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&i++,n!==t);)n=n.nextSibling;return i}function Z(t,e){return {name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function Te(t){return t.name!=="html"&&!t.name.startsWith("#")}function Q(...t){let e=t.filter(en);return e.length>0?e:null}function en(t){return t!=null}function*bt(t,e=[]){if(t.length>0)for(let n of t[0])yield*bt(t.slice(1,t.length),e.concat(n));else yield e;}function gt(t){return [...t].sort((e,n)=>dt(e)-dt(n))}function*yt(t,e,n={counter:0,visited:new Map}){if(t.length>2&&t.length>k.optimizedMinLength)for(let i=1;i<t.length-1;i++){if(n.counter>k.maxNumberOfTries)return;n.counter+=1;let o=[...t];o.splice(i,1);let s=ee(o);if(n.visited.has(s))return;mt(o)&&tn(o,e)&&(yield o,n.visited.set(s,true),yield*yt(o,e,n));}}function tn(t,e){return Ce.querySelector(ee(t))===e}var nn=["role","aria-label","type","name","href","src","data-testid","data-id"];function on(t){let e=5381;for(let n=0;n<t.length;n++)e=(e<<5)+e+t.charCodeAt(n)|0;return (e>>>0).toString(36)}function Ae(t){let e=t.children.length,n=0,i=t.parentElement;if(i)for(let r of i.children){if(r===t)break;r.tagName===t.tagName&&n++;}let o=[];for(let r of nn){let a=t.getAttribute(r);a&&o.push(`${r}=${a}`);}let s=o.length>0?on(o.join(",")):"0";return `${e}:${n}:${s}`}function vt(t,e){let n=e.split(":");if(n.length!==3)return 0;let[i,o,s]=n,r=Number(i),a=Number(o);if(Number.isNaN(r)||Number.isNaN(a))return 0;let l=Ae(t),[c,d,p]=l.split(":"),h=0,m=Math.abs(Number(c)-r);m===0?h+=.2:m<=2?h+=.1:m<=5&&(h+=.03);let x=Math.abs(Number(d)-a);return x===0?h+=.4:x===1?h+=.2:x<=3&&(h+=.08),p===s&&(h+=.4),h}function H(t,e){let n=e==="before"?"previousElementSibling":"nextElementSibling",i=t[n],o=3;for(;i&&o>0;){let s=i.textContent?.trim();if(s)return e==="before"?s.slice(-32):s.slice(0,32);i=i[n],o--;}return ""}function te(t){let e=t.previousElementSibling?.textContent?.trim().slice(0,40)??"",n=t.nextElementSibling?.textContent?.trim().slice(0,40)??"";return [e,n].filter(Boolean).join(" | ")}function xt(t){if(t.id){let i=t.id.includes("'")?`concat('${t.id.replace(/'/g,`',"'",'`)}')`:`'${t.id}'`;return `//${t.localName}[@id=${i}]`}let e=[],n=t;for(;n&&n!==document.body&&e.length<6;){let i=n.localName,o=n.parentElement;if(n.id){let r=n.id.includes("'")?`concat('${n.id.replace(/'/g,`',"'",'`)}')`:`'${n.id}'`;return e.unshift(`/${i}[@id=${r}]`),"/"+e.join("")}let s=1;if(o)for(let r of o.children){if(r===n)break;r.localName===i&&s++;}e.unshift(`/${i}[${s}]`),n=o;}return "/html/body"+e.join("")}var z="data-feedback-anchor";function Le(t){let e=ft(t,{className:p=>!/^(css|sc|emotion|styled)-/.test(p)&&!/^[a-z]{1,3}[A-Za-z0-9]{4,8}$/.test(p),attr:p=>["data-testid","data-id","role","aria-label"].includes(p),idName:p=>!p.startsWith("radix-")&&!/^:r[0-9]+:$/.test(p),seedMinLength:3,optimizedMinLength:2}),n=xt(t),o=(t.textContent?.trim()??"").slice(0,120),s=H(t,"before"),r=H(t,"after"),a=Ae(t),l=te(t),d=t.closest(`[${z}]`)?.getAttribute(z)??null;return {cssSelector:e,xpath:n,textSnippet:o,textPrefix:s,textSuffix:r,fingerprint:a,neighborText:l,elementTag:t.tagName,elementId:t.id||void 0,anchorKey:d}}function wt(t,e){let n=t.getBoundingClientRect();return n.left<=e.x&&n.top<=e.y&&n.right>=e.x+e.width&&n.bottom>=e.y+e.height}function Et(t,e=document.documentElement){let n=t.x+t.width/2,i=t.y+t.height/2,o=document.elementFromPoint(n,i);if(!o||o===e)return document.body;let s=o;for(;s&&s!==document.body;){if(s.hasAttribute(z)&&wt(s,t))return s;s=s.parentElement;}for(s=o;s&&s!==document.body;){if(wt(s,t))return s;s=s.parentElement;}return document.body}function kt(t,e){return e.width<=0||e.height<=0?{xPct:0,yPct:0,wPct:1,hPct:1}:{xPct:(t.x-e.x)/e.width,yPct:(t.y-e.y)/e.height,wPct:t.width/e.width,hPct:t.height/e.height}}var sn={question:"type.question",change:"type.change",bug:"type.bug",other:"type.other"};function rn(){let t=navigator.userAgentData;return t?t.platform==="macOS":navigator.platform?.includes("Mac")??/Macintosh|Mac OS X/i.test(navigator.userAgent)}var ne=class{constructor(e,n$1){this.colors=e;this.t=n$1;this.root=b("div",{style:`
2
2
  position:fixed;
3
3
  z-index:${2147483647};
4
4
  width:300px;
@@ -15,7 +15,7 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
15
15
  transition:opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1),transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
16
16
  display:none;
17
17
  -webkit-font-smoothing:antialiased;
18
- `}),this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-modal","true"),this.root.setAttribute("aria-label",this.t("popup.ariaLabel"));let i=[{type:"question",label:this.t("type.question"),icon:n},{type:"change",label:this.t("type.change"),icon:o},{type:"bug",label:this.t("type.bug"),icon:p},{type:"other",label:this.t("type.other"),icon:q$1}],o$1=b("div",{style:"display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px;"});for(let l of i){let d=document.createElement("button");d.style.cssText=`
18
+ `}),this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-modal","true"),this.root.setAttribute("data-siteping-ignore","true");let i=[{type:"question",icon:n},{type:"change",icon:o},{type:"bug",icon:p},{type:"other",icon:q$1}];this.typeRow=b("div",{style:"display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px;"});for(let s of i){let r=document.createElement("button");r.style.cssText=`
19
19
  height:44px;
20
20
  border-radius:9999px;border:1px solid ${this.colors.border};
21
21
  background:${this.colors.glassBg};cursor:pointer;
@@ -24,7 +24,7 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
24
24
  font-size:13px;font-weight:500;color:${this.colors.textTertiary};
25
25
  transition:all 0.2s ease;
26
26
  padding:0 12px;
27
- `;let h=a(l.icon);h.setAttribute("style","width:13px;height:13px;flex-shrink:0;"),d.appendChild(h);let f=document.createElement("span");c(f,l.label),d.appendChild(f),d.dataset.type=l.type,d.setAttribute("aria-pressed","false"),d.addEventListener("click",()=>{this.selectType(l.type,o$1);}),d.addEventListener("mouseenter",()=>{if(d.dataset.type!==this.selectedType){let x$1=y(d.dataset.type??"",this.colors);d.style.background=x$1,d.style.borderColor=x(d.dataset.type??"",this.colors)+"40";}}),d.addEventListener("mouseleave",()=>{d.dataset.type!==this.selectedType&&(d.style.background=this.colors.glassBg,d.style.borderColor=this.colors.border);}),o$1.appendChild(d);}this.textarea=document.createElement("textarea"),this.textarea.style.cssText=`
27
+ `;let a$1=a(s.icon);a$1.setAttribute("style","width:13px;height:13px;flex-shrink:0;"),r.appendChild(a$1),r.appendChild(document.createElement("span")),r.dataset.type=s.type,r.setAttribute("aria-pressed","false"),r.addEventListener("click",()=>{this.submittingState||this.selectType(s.type,this.typeRow);}),r.addEventListener("mouseenter",()=>{if(!this.submittingState&&r.dataset.type!==this.selectedType){let l=y(r.dataset.type??"",this.colors);r.style.background=l,r.style.borderColor=x(r.dataset.type??"",this.colors)+"40";}}),r.addEventListener("mouseleave",()=>{this.submittingState||r.dataset.type!==this.selectedType&&(r.style.background=this.colors.glassBg,r.style.borderColor=this.colors.border);}),this.typeRow.appendChild(r);}this.textarea=document.createElement("textarea"),this.textarea.style.cssText=`
28
28
  width:100%;min-height:72px;max-height:152px;
29
29
  padding:10px 12px;border-radius:12px;
30
30
  border:1px solid ${this.colors.border};
@@ -33,19 +33,19 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
33
33
  font-size:13px;line-height:1.5;resize:vertical;
34
34
  outline:none;transition:all 0.2s ease;
35
35
  box-sizing:border-box;
36
- `,this.textarea.placeholder=this.t("popup.placeholder"),this.textarea.maxLength=5e3,this.textarea.setAttribute("aria-label",this.t("popup.textareaAria"));let s=b("div",{style:`
36
+ `,this.textarea.maxLength=5e3,this.hint=b("div",{style:`
37
37
  font-size:11px;color:${this.colors.textTertiary};
38
38
  text-align:right;margin-top:4px;
39
39
  font-family:"Inter",system-ui,-apple-system,sans-serif;
40
40
  letter-spacing:0.01em;
41
- `}),r=navigator.userAgentData,p$1=r?r.platform==="macOS":navigator.platform?.includes("Mac")??/Macintosh|Mac OS X/i.test(navigator.userAgent);c(s,p$1?this.t("popup.submitHintMac"):this.t("popup.submitHintOther")),this.textarea.addEventListener("focus",()=>{this.textarea.style.borderColor=this.colors.accent,this.textarea.style.boxShadow=`0 0 0 3px ${this.colors.accent}14`,this.textarea.style.background=this.colors.bg;}),this.textarea.addEventListener("blur",()=>{this.textarea.style.borderColor=this.colors.border,this.textarea.style.boxShadow="none",this.textarea.style.background=this.colors.glassBgHeavy;}),this.textarea.addEventListener("input",()=>{this.updateSubmitState();}),this.textarea.addEventListener("keydown",l=>{l.key==="Enter"&&(l.ctrlKey||l.metaKey)&&(l.preventDefault(),this.submit()),l.key==="Escape"&&this.cancel();});let a$1=b("div",{style:"display:flex;justify-content:flex-end;gap:8px;margin-top:12px;"}),c$1=document.createElement("button");c$1.style.cssText=`
41
+ `}),this.textarea.addEventListener("focus",()=>{this.submittingState||(this.textarea.style.borderColor=this.colors.accent,this.textarea.style.boxShadow=`0 0 0 3px ${this.colors.accent}14`,this.textarea.style.background=this.colors.bg);}),this.textarea.addEventListener("blur",()=>{this.submittingState||(this.textarea.style.borderColor=this.colors.border,this.textarea.style.boxShadow="none",this.textarea.style.background=this.colors.glassBgHeavy);}),this.textarea.addEventListener("input",()=>{this.updateSubmitState();}),this.textarea.addEventListener("keydown",s=>{this.submittingState||(s.key==="Enter"&&(s.ctrlKey||s.metaKey)&&(s.preventDefault(),this.submit()),s.key==="Escape"&&this.cancel());});let o$1=b("div",{style:"display:flex;justify-content:flex-end;gap:8px;margin-top:12px;"});this.cancelBtn=document.createElement("button"),this.cancelBtn.style.cssText=`
42
42
  height:34px;padding:0 16px;border-radius:9999px;
43
43
  border:1px solid ${this.colors.border};
44
44
  background:${this.colors.glassBg};
45
45
  color:${this.colors.textTertiary};font-family:"Inter",system-ui,-apple-system,sans-serif;
46
46
  font-size:13px;font-weight:500;cursor:pointer;
47
47
  transition:all 0.2s ease;
48
- `,c(c$1,this.t("popup.cancel")),c$1.addEventListener("click",()=>this.cancel()),c$1.addEventListener("mouseenter",()=>{c$1.style.borderColor=this.colors.accent,c$1.style.color=this.colors.accent;}),c$1.addEventListener("mouseleave",()=>{c$1.style.borderColor=this.colors.border,c$1.style.color=this.colors.textTertiary;}),this.submitBtn=document.createElement("button"),this.submitBtn.style.cssText=`
48
+ `,this.cancelBtn.addEventListener("click",()=>this.cancel()),this.cancelBtn.addEventListener("mouseenter",()=>{this.submittingState||(this.cancelBtn.style.borderColor=this.colors.accent,this.cancelBtn.style.color=this.colors.accent);}),this.cancelBtn.addEventListener("mouseleave",()=>{this.submittingState||(this.cancelBtn.style.borderColor=this.colors.border,this.cancelBtn.style.color=this.colors.textTertiary);}),this.submitBtn=document.createElement("button"),this.submitBtn.style.cssText=`
49
49
  height:34px;padding:0 18px;border-radius:9999px;
50
50
  border:none;background:${this.colors.accentGradient};
51
51
  color:#fff;font-family:"Inter",system-ui,-apple-system,sans-serif;
@@ -53,7 +53,14 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
53
53
  opacity:0.35;pointer-events:none;
54
54
  transition:all 0.2s ease;
55
55
  box-shadow:0 2px 8px ${this.colors.accentGlow};
56
- `,c(this.submitBtn,this.t("popup.submit")),this.submitBtn.addEventListener("click",()=>this.submit()),a$1.appendChild(c$1),a$1.appendChild(this.submitBtn),this.root.appendChild(o$1),this.root.appendChild(this.textarea),this.root.appendChild(s),this.root.appendChild(a$1),document.body.appendChild(this.root);}colors;t;root;selectedType=null;textarea;submitBtn;resolve=null;previouslyFocused=null;onKeydownTrap=null;show(e){return new Promise(n=>{this.resolve=n,this.selectedType=null,this.textarea.value="",this.updateSubmitState(),this.resetTypeButtons(),this.previouslyFocused=document.activeElement;let i=220,o=300,s=e.bottom+8,r=e.left;if(s+i>window.innerHeight){let a=e.top-i-8;a>=8?s=a:s=window.innerHeight-i-8;}r+o>window.innerWidth&&(r=e.right-o),r=Math.max(8,r),s=Math.max(8,s),this.root.style.top=`${s}px`,this.root.style.left=`${r}px`,this.root.style.display="block",this.onKeydownTrap=a=>{if(a.key==="Tab"){let c=Array.from(this.root.querySelectorAll('button:not([disabled]), textarea, input, [tabindex]:not([tabindex="-1"])'));if(c.length===0)return;let l=c[0],d=c[c.length-1];if(!l||!d)return;a.shiftKey?(document.activeElement===l||!this.root.contains(document.activeElement))&&(a.preventDefault(),d.focus()):(document.activeElement===d||!this.root.contains(document.activeElement))&&(a.preventDefault(),l.focus());}},this.root.addEventListener("keydown",this.onKeydownTrap);let p=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=p?"none":"",requestAnimationFrame(()=>{this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)",this.textarea.focus();});})}selectType(e,n){this.selectedType=e;let i=n.querySelectorAll("button");for(let o of i){let s=o.dataset.type===e,r=x(o.dataset.type??"",this.colors),p=y(o.dataset.type??"",this.colors);o.style.background=s?p:this.colors.glassBg,o.style.borderColor=s?r+"60":this.colors.border,o.style.color=s?r:this.colors.textTertiary,o.style.fontWeight=s?"600":"500",o.setAttribute("aria-pressed",String(s));}this.updateSubmitState();}resetTypeButtons(){let e=this.root.querySelectorAll("button[data-type]");for(let n of e)n.setAttribute("aria-pressed","false"),n.style.background=this.colors.glassBg,n.style.borderColor=this.colors.border,n.style.color=this.colors.textTertiary,n.style.fontWeight="500";}updateSubmitState(){let e=this.selectedType!==null&&this.textarea.value.trim().length>0;this.submitBtn.disabled=!e,this.submitBtn.style.opacity=e?"1":"0.35",this.submitBtn.style.pointerEvents=e?"auto":"none";}submit(){!this.selectedType||!this.textarea.value.trim()||(this.resolve?.({type:this.selectedType,message:this.textarea.value.trim()}),this.resolve=null,this.hideElement());}cancel(){this.resolve?.(null),this.resolve=null,this.hideElement();}hideElement(){this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.root.style.opacity="0",this.root.style.transform="translateY(8px) scale(0.98)",this.previouslyFocused?.focus(),this.previouslyFocused=null,setTimeout(()=>{this.root.style.display="none";},250);}destroy(){this.root.remove();}};var X,Et=false;async function on(){if(X!==void 0)return X;try{let t=await import('html2canvas');return X=t.default??t,X}catch(t){return X=null,Et||(Et=true,console.warn("[siteping] html2canvas import failed unexpectedly. Capture is disabled for this session \u2014 feedbacks are still submitted, just without screenshots. Underlying error:",t)),null}}async function kt(t,e){let n=await on();if(!n)return null;let i=.85,o=1200;try{let s=await n(document.body,{x:window.scrollX+t.x,y:window.scrollY+t.y,width:t.width,height:t.height,scale:window.devicePixelRatio,useCORS:!0,allowTaint:!0,logging:!1,ignoreElements:d=>d.tagName==="SITEPING-WIDGET"||d.closest?.("siteping-widget")!==null||d.getAttribute?.("data-siteping-ignore")==="true"});if(s.width<=o)return s.toDataURL("image/jpeg",i);let r=o/s.width,p=o,a=Math.round(s.height*r),c=document.createElement("canvas");c.width=p,c.height=a;let l=c.getContext("2d");return l?(l.drawImage(s,0,0,p,a),c.toDataURL("image/jpeg",i)):null}catch(s){return console.warn("[siteping] Screenshot capture failed:",s),null}}var oe=class{constructor(e,n,i,o=false){this.colors=e;this.bus=n;this.t=i;this.enableScreenshot=o;this.popup=new ie(e,i),this.bus.on("annotation:start",()=>this.activate());}colors;bus;t;enableScreenshot;overlay=null;toolbar=null;drawingRect=null;startX=0;startY=0;isDrawing=false;isActive=false;popup;savedOverflow="";preActiveFocusElement=null;rafId=null;pendingMoveEvent=null;async maybeCapture(e){return this.enableScreenshot?kt(e):null}activate(){if(this.isActive)return;this.isActive=true,this.preActiveFocusElement=document.activeElement,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.overlay=b("div",{style:`
56
+ display:inline-flex;align-items:center;justify-content:center;min-width:64px;
57
+ `,this.submitLabel=document.createElement("span"),this.submitBtn.appendChild(this.submitLabel),this.submitBtn.addEventListener("click",()=>this.submit()),o$1.appendChild(this.cancelBtn),o$1.appendChild(this.submitBtn),this.root.appendChild(this.typeRow),this.root.appendChild(this.textarea),this.root.appendChild(this.hint),this.root.appendChild(o$1),document.body.appendChild(this.root),this.applyLabels();}colors;t;root;selectedType=null;textarea;submitBtn;cancelBtn;typeRow;submitLabel;hint;resolve=null;previouslyFocused=null;onKeydownTrap=null;onSubmit=null;submittingState=false;spinnerAnimation=null;refreshLabels(){this.applyLabels();}applyLabels(){this.root.setAttribute("aria-label",this.t("popup.ariaLabel"));let e=this.root.querySelectorAll("button[data-type]");for(let n of e){let i=n.dataset.type;if(!i)continue;let o=sn[i];if(!o)continue;let s=n.querySelector("span");s&&c(s,this.t(o));}this.textarea.placeholder=this.t("popup.placeholder"),this.textarea.setAttribute("aria-label",this.t("popup.textareaAria")),c(this.hint,rn()?this.t("popup.submitHintMac"):this.t("popup.submitHintOther")),c(this.cancelBtn,this.t("popup.cancel")),c(this.submitLabel,this.t("popup.submit"));}show(e,n){return new Promise(i=>{this.resolve=i,this.onSubmit=n??null,this.selectedType=null,this.textarea.value="",this.submittingState=false,this.updateSubmitState(),this.resetTypeButtons(),this.previouslyFocused=document.activeElement;let o=220,s=300,r=e.bottom+8,a=e.left;if(r+o>window.innerHeight){let c=e.top-o-8;c>=8?r=c:r=window.innerHeight-o-8;}a+s>window.innerWidth&&(a=e.right-s),a=Math.max(8,a),r=Math.max(8,r),this.root.style.top=`${r}px`,this.root.style.left=`${a}px`,this.root.style.display="block",this.onKeydownTrap=c=>{if(c.key==="Tab"){let d=Array.from(this.root.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(d.length===0)return;let p=d[0],h=d[d.length-1];if(!p||!h)return;c.shiftKey?(document.activeElement===p||!this.root.contains(document.activeElement))&&(c.preventDefault(),h.focus()):(document.activeElement===h||!this.root.contains(document.activeElement))&&(c.preventDefault(),p.focus());}},this.root.addEventListener("keydown",this.onKeydownTrap);let l=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=l?"none":"",requestAnimationFrame(()=>{this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)",this.textarea.focus();});})}selectType(e,n){this.selectedType=e;let i=n.querySelectorAll("button");for(let o of i){let s=o.dataset.type===e,r=x(o.dataset.type??"",this.colors),a=y(o.dataset.type??"",this.colors);o.style.background=s?a:this.colors.glassBg,o.style.borderColor=s?r+"60":this.colors.border,o.style.color=s?r:this.colors.textTertiary,o.style.fontWeight=s?"600":"500",o.setAttribute("aria-pressed",String(s));}this.updateSubmitState();}resetTypeButtons(){let e=this.root.querySelectorAll("button[data-type]");for(let n of e)n.setAttribute("aria-pressed","false"),n.disabled=false,n.style.background=this.colors.glassBg,n.style.borderColor=this.colors.border,n.style.color=this.colors.textTertiary,n.style.fontWeight="500",n.style.cursor="pointer";}updateSubmitState(){if(this.submittingState)return;let e=this.selectedType!==null&&this.textarea.value.trim().length>0;this.submitBtn.disabled=!e,this.submitBtn.style.opacity=e?"1":"0.35",this.submitBtn.style.pointerEvents=e?"auto":"none";}submit(){if(this.submittingState||!this.selectedType||!this.textarea.value.trim())return;let e={type:this.selectedType,message:this.textarea.value.trim()};if(!this.onSubmit){this.resolve?.(e),this.resolve=null,this.hideElement();return}this.enterSubmittingState();let n=this.onSubmit;n(e).then(()=>{this.resolve?.(e),this.resolve=null,this.hideElement();}).catch(()=>{this.exitSubmittingState();});}cancel(){this.submittingState||(this.resolve?.(null),this.resolve=null,this.hideElement());}enterSubmittingState(){this.submittingState=true,this.submitLabel.style.display="none",this.submitBtn.disabled=true,this.submitBtn.style.cursor="wait",this.submitBtn.style.opacity="0.85",this.submitBtn.setAttribute("aria-busy","true"),this.submitBtn.appendChild(this.buildSpinner()),this.cancelBtn.disabled=true,this.cancelBtn.style.opacity="0.5",this.cancelBtn.style.cursor="not-allowed",this.cancelBtn.style.pointerEvents="none",this.textarea.disabled=true,this.textarea.style.opacity="0.6";let e=this.typeRow.querySelectorAll("button");for(let n of e)n.disabled=true,n.style.cursor="not-allowed",n.style.opacity="0.6";}exitSubmittingState(){this.submittingState=false,this.spinnerAnimation?.cancel(),this.spinnerAnimation=null,this.submitBtn.querySelector('[data-role="sp-popup-spinner"]')?.remove(),this.submitLabel.style.display="",this.submitBtn.removeAttribute("aria-busy"),this.submitBtn.style.cursor="pointer",this.cancelBtn.disabled=false,this.cancelBtn.style.opacity="1",this.cancelBtn.style.cursor="pointer",this.cancelBtn.style.pointerEvents="auto",this.textarea.disabled=false,this.textarea.style.opacity="1";let n=this.typeRow.querySelectorAll("button");for(let i of n)i.disabled=false,i.style.cursor="pointer",i.style.opacity="1";this.updateSubmitState();}buildSpinner(){let e=document.createElement("div");return e.dataset.role="sp-popup-spinner",e.style.cssText=`
58
+ width:14px;height:14px;
59
+ border:2px solid rgba(255,255,255,0.35);
60
+ border-top-color:#fff;
61
+ border-radius:50%;
62
+ box-sizing:border-box;
63
+ `,!(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)&&typeof e.animate=="function"&&(this.spinnerAnimation=e.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:600,iterations:1/0,easing:"linear"})),e}hideElement(){this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.submittingState&&this.exitSubmittingState(),this.onSubmit=null,this.root.style.opacity="0",this.root.style.transform="translateY(8px) scale(0.98)",this.previouslyFocused?.focus(),this.previouslyFocused=null,setTimeout(()=>{this.root.style.display="none";},250);}destroy(){this.submittingState&&this.exitSubmittingState(),this.resolve?.(null),this.resolve=null,this.onSubmit=null,this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.root.remove();}};var j,St=false;async function an(){if(j!==void 0)return j;try{let t=await import('html2canvas');return j=t.default??t,j}catch(t){return j=null,St||(St=true,console.warn("[siteping] html2canvas import failed unexpectedly. Capture is disabled for this session \u2014 feedbacks are still submitted, just without screenshots. Underlying error:",t)),null}}async function Tt(t,e){let n=await an();if(!n)return null;let i=.85,o=1200;try{let s=await n(document.body,{x:window.scrollX+t.x,y:window.scrollY+t.y,width:t.width,height:t.height,scale:window.devicePixelRatio,useCORS:!0,allowTaint:!0,logging:!1,ignoreElements:p=>p.tagName==="SITEPING-WIDGET"||p.closest?.("siteping-widget")!==null||p.getAttribute?.("data-siteping-ignore")==="true"});if(s.width<=o)return s.toDataURL("image/jpeg",i);let r=o/s.width,a=o,l=Math.round(s.height*r),c=document.createElement("canvas");c.width=a,c.height=l;let d=c.getContext("2d");return d?(d.drawImage(s,0,0,a,l),c.toDataURL("image/jpeg",i)):null}catch(s){return console.warn("[siteping] Screenshot capture failed:",s),null}}var ie=class{constructor(e,n,i,o=false){this.colors=e;this.bus=n;this.t=i;this.enableScreenshot=o;this.popup=new ne(e,i),this.bus.on("annotation:start",()=>this.activate());}colors;bus;t;enableScreenshot;overlay=null;toolbar=null;drawingRect=null;startX=0;startY=0;isDrawing=false;isActive=false;popup;savedOverflow="";preActiveFocusElement=null;rafId=null;pendingMoveEvent=null;rejectPendingSubmission=null;refreshLabels(){this.popup.refreshLabels();}get submissionInFlight(){return this.rejectPendingSubmission!==null}async maybeCapture(e){return this.enableScreenshot?Tt(e):null}activate(){if(this.isActive)return;this.isActive=true,this.preActiveFocusElement=document.activeElement,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.overlay=b("div",{style:`
57
64
  position:fixed;inset:0;
58
65
  z-index:${2147483646};
59
66
  background:rgba(15, 23, 42, 0.04);
@@ -83,7 +90,7 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
83
90
  color:${this.colors.textTertiary};font-family:"Inter",system-ui,-apple-system,sans-serif;
84
91
  font-size:13px;font-weight:500;cursor:pointer;
85
92
  transition:all 0.2s ease;
86
- `,c(o,this.t("annotator.cancel")),o.addEventListener("click",()=>this.deactivate()),o.addEventListener("mouseenter",()=>{o.style.borderColor=this.colors.typeBug,o.style.color=this.colors.typeBug,o.style.background=this.colors.typeBugBg;}),o.addEventListener("mouseleave",()=>{o.style.borderColor=this.colors.border,o.style.color=this.colors.textTertiary,o.style.background=this.colors.glassBg;}),this.toolbar.appendChild(e),this.toolbar.appendChild(i),this.toolbar.appendChild(o),this.overlay.addEventListener("mousedown",this.onMouseDown),this.overlay.addEventListener("mousemove",this.onMouseMove),this.overlay.addEventListener("mouseup",this.onMouseUp),this.overlay.addEventListener("touchstart",this.onTouchStart,{passive:false}),this.overlay.addEventListener("touchmove",this.onTouchMove,{passive:false}),this.overlay.addEventListener("touchend",this.onTouchEnd),this.overlay.addEventListener("keydown",this.onOverlayKeyDown),this.overlay.setAttribute("tabindex","0"),document.addEventListener("keydown",this.onKeyDown),document.body.appendChild(this.overlay),document.body.appendChild(this.toolbar);}deactivate(){this.isActive&&(this.isActive=false,this.isDrawing=false,this.preActiveFocusElement=null,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.pendingMoveEvent=null,document.body.style.overflow=this.savedOverflow,document.removeEventListener("keydown",this.onKeyDown),this.overlay?.remove(),this.toolbar?.remove(),this.drawingRect?.remove(),this.overlay=null,this.toolbar=null,this.drawingRect=null,this.bus.emit("annotation:end"));}onKeyDown=e=>{e.key==="Escape"&&this.deactivate();};onOverlayKeyDown=async e=>{if(e.key!=="Enter")return;e.preventDefault();let n=this.preActiveFocusElement;if(!n||!(n instanceof HTMLElement))return;let i=n.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let o=new DOMRect(i.x,i.y,i.width,i.height),s=await this.popup.show(o);if(!s)return;let p={anchor:Le(n),rect:{xPct:0,yPct:0,wPct:1,hPct:1},scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio},a=await this.maybeCapture(o);this.deactivate(),this.bus.emit("annotation:complete",{annotation:p,type:s.type,message:s.message,screenshotDataUrl:a});};onMouseDown=e=>{this.startDrawing(e.clientX,e.clientY);};onTouchStart=e=>{e.preventDefault();let n=e.touches[0];n&&this.startDrawing(n.clientX,n.clientY);};startDrawing(e,n){this.isDrawing=true,this.startX=e,this.startY=n,this.drawingRect?.remove(),this.drawingRect=b("div",{style:`
93
+ `,c(o,this.t("annotator.cancel")),o.addEventListener("click",()=>this.deactivate()),o.addEventListener("mouseenter",()=>{o.style.borderColor=this.colors.typeBug,o.style.color=this.colors.typeBug,o.style.background=this.colors.typeBugBg;}),o.addEventListener("mouseleave",()=>{o.style.borderColor=this.colors.border,o.style.color=this.colors.textTertiary,o.style.background=this.colors.glassBg;}),this.toolbar.appendChild(e),this.toolbar.appendChild(i),this.toolbar.appendChild(o),this.overlay.addEventListener("mousedown",this.onMouseDown),this.overlay.addEventListener("mousemove",this.onMouseMove),this.overlay.addEventListener("mouseup",this.onMouseUp),this.overlay.addEventListener("touchstart",this.onTouchStart,{passive:false}),this.overlay.addEventListener("touchmove",this.onTouchMove,{passive:false}),this.overlay.addEventListener("touchend",this.onTouchEnd),this.overlay.addEventListener("keydown",this.onOverlayKeyDown),this.overlay.setAttribute("tabindex","0"),document.addEventListener("keydown",this.onKeyDown),document.body.appendChild(this.overlay),document.body.appendChild(this.toolbar);}deactivate(){this.isActive&&(this.isActive=false,this.isDrawing=false,this.preActiveFocusElement=null,this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.pendingMoveEvent=null,document.body.style.overflow=this.savedOverflow,document.removeEventListener("keydown",this.onKeyDown),this.overlay?.remove(),this.toolbar?.remove(),this.drawingRect?.remove(),this.overlay=null,this.toolbar=null,this.drawingRect=null,this.bus.emit("annotation:end"));}onKeyDown=e=>{e.key==="Escape"&&this.deactivate();};onOverlayKeyDown=async e=>{if(e.key!=="Enter"||(e.preventDefault(),this.submissionInFlight))return;let n=this.preActiveFocusElement;if(!n||!(n instanceof HTMLElement))return;let i=n.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let o=new DOMRect(i.x,i.y,i.width,i.height),r={anchor:Le(n),rect:{xPct:0,yPct:0,wPct:1,hPct:1},scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio},a={};await this.popup.show(o,c=>this.runSubmission(r,c,o,a))&&this.deactivate();};onMouseDown=e=>{this.startDrawing(e.clientX,e.clientY);};onTouchStart=e=>{e.preventDefault();let n=e.touches[0];n&&this.startDrawing(n.clientX,n.clientY);};startDrawing(e,n){this.submissionInFlight||(this.isDrawing=true,this.startX=e,this.startY=n,this.drawingRect?.remove(),this.drawingRect=b("div",{style:`
87
94
  position:fixed;
88
95
  border:2px solid ${this.colors.accent};
89
96
  background:${this.colors.accent}12;
@@ -91,8 +98,8 @@ import {G as G$1,H,w,F,U as U$1,T,L,J,Y as Y$1,N,z,b,x,y,I,c,e,g,h,j as j$1,i,a,
91
98
  border-radius:8px;
92
99
  box-shadow:0 0 16px ${this.colors.accentGlow};
93
100
  transition:box-shadow 0.15s ease;
94
- `}),this.overlay?.appendChild(this.drawingRect);}onMouseMove=e=>{this.scheduleRectUpdate(e);};onTouchMove=e=>{e.preventDefault(),e.touches[0]&&this.scheduleRectUpdate(e.touches[0]);};scheduleRectUpdate(e){!this.isDrawing||!this.drawingRect||(this.pendingMoveEvent=e,this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;let n=this.pendingMoveEvent;if(!n||!this.drawingRect)return;let i=Math.min(n.clientX,this.startX),o=Math.min(n.clientY,this.startY),s=Math.abs(n.clientX-this.startX),r=Math.abs(n.clientY-this.startY);this.drawingRect.style.left=`${i}px`,this.drawingRect.style.top=`${o}px`,this.drawingRect.style.width=`${s}px`,this.drawingRect.style.height=`${r}px`;})));}onTouchEnd=async e=>{let n=e.changedTouches[0];n&&await this.finishDrawing(n.clientX,n.clientY);};onMouseUp=async e=>{await this.finishDrawing(e.clientX,e.clientY);};finishDrawing=async(e,n)=>{if(!this.isDrawing||!this.drawingRect)return;this.isDrawing=false;let i=Math.min(e,this.startX),o=Math.min(n,this.startY),s=Math.abs(e-this.startX),r=Math.abs(n-this.startY);if(s<10||r<10){this.drawingRect.remove(),this.drawingRect=null;return}let p=new DOMRect(i,o,s,r),a=await this.popup.show(p);if(!a){this.drawingRect?.remove(),this.drawingRect=null;return}let c=this.buildAnnotation(p);this.drawingRect?.remove(),this.drawingRect=null;let l=await this.maybeCapture(p);this.deactivate(),this.bus.emit("annotation:complete",{annotation:c,type:a.type,message:a.message,screenshotDataUrl:l});};buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let n=xt(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let i=Le(n),o=n.getBoundingClientRect(),s=wt(e,o);return {anchor:i,rect:s,scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio}}destroy(){this.deactivate(),this.popup.destroy();}};async function K(t,e){let n=await t.text().catch(()=>"Unknown error"),i=n?`${t.status} ${n}`:`${t.status}`,o=`${e}: ${i}`;return t.status===401||t.status===403?new D(o):t.status>=400&&t.status<500?new C(o):new A(o,"SERVER",false)}function U(t,e){if(t instanceof B)return t;let n=t instanceof Error?t.message:String(t);return new B(`${e}: ${n}`)}var sn=3,rn=1e4,se="siteping_retry_queue",an=20;async function Y(t,e,n=sn){for(let i=0;i<=n;i++){let o=new AbortController,s=setTimeout(()=>o.abort(),rn);try{let a=await fetch(t,{...e,signal:o.signal});if(clearTimeout(s),a.ok||a.status>=400&&a.status<500||i===n)return a}catch(a){if(clearTimeout(s),i===n)throw a}let r=1e3*2**i,p=Math.random()*1e3-500;await new Promise(a=>setTimeout(a,r+p));}throw new Error("Max retries exceeded")}var ln="siteping_retry_queue";async function Ct(t){return typeof navigator<"u"&&navigator.locks?navigator.locks.request(ln,()=>t()):t()}function At(){let t=localStorage.getItem(se);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e:[]}function pn(t,e){Ct(()=>{try{let n=At();n.length>=an&&n.shift(),n.push({endpoint:t,payload:e}),localStorage.setItem(se,JSON.stringify(n));}catch{}});}function Tt(t){return t.trim()}function St(t){return t.trim().toLowerCase()}async function Rt(t,e){await Ct(async()=>{try{let n=At();if(n.length===0)return;let i=[],o=[],s=0;for(let a of n){if(a.endpoint!==t){o.push(a);continue}!e||Tt(a.payload.authorName)===Tt(e.name)&&St(a.payload.authorEmail)===St(e.email)?i.push(a):s+=1;}if(i.length===0&&s===0)return;s>0;let r=[];for(let a of i)try{(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.payload)})).ok||r.push(a);}catch{r.push(a);}let p=o.concat(r);p.length>0?localStorage.setItem(se,JSON.stringify(p)):localStorage.removeItem(se);}catch{}});}async function Me(t){return await t.json()}var re=class{constructor(e,n){this.endpoint=e;this.projectName=n;}endpoint;projectName;async sendFeedback(e){try{let n;try{n=await Y(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch(i){throw U(i,"Failed to send feedback")}if(!n.ok)throw await K(n,"Failed to send feedback");return Me(n)}catch(n){throw pn(this.endpoint,e),n}}async getFeedbacks(e,n){let i=new URLSearchParams({projectName:e});n?.page&&i.set("page",String(n.page)),n?.limit&&i.set("limit",String(n.limit)),n?.type&&i.set("type",n.type),n?.status&&i.set("status",n.status),n?.search&&i.set("search",n.search),n?.url&&i.set("url",n.url),n?.urlPattern&&i.set("urlPattern",n.urlPattern);let o;try{o=await Y(`${this.endpoint}?${i.toString()}`,{method:"GET",cache:"no-store"});}catch(s){throw U(s,"Failed to fetch feedbacks")}if(!o.ok)throw await K(o,"Failed to fetch feedbacks");return Me(o)}async resolveFeedback(e,n){let i;try{i=await Y(this.endpoint,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName,status:n?"resolved":"open"})});}catch(o){throw U(o,"Failed to update feedback")}if(!i.ok)throw await K(i,"Failed to update feedback");return Me(i)}async deleteFeedback(e){let n;try{n=await Y(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName})});}catch(i){throw U(i,"Failed to delete feedback")}if(!n.ok)throw await K(n,"Failed to delete feedback")}async deleteAllFeedbacks(e){let n;try{n=await Y(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectName:e,deleteAll:!0})});}catch(i){throw U(i,"Failed to delete all feedbacks")}if(!n.ok)throw await K(n,"Failed to delete all feedbacks")}};var cn=["log","info","warn","error"];function dn(t){if(t===null)return "null";if(t===void 0)return "undefined";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);if(t instanceof Error)return `${t.name}: ${t.message}${t.stack?`
95
- ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof i=="function")return "[Function]";if(typeof i=="symbol")return i.toString();if(typeof i=="object"&&i!==null){if(e.has(i))return "[Circular]";e.add(i);}return i})}catch{try{return String(t)}catch{return "[Unserializable]"}}}function un(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=dn(t[n]),!(e.length>=500));n++);return e.length>500&&(e=`${e.slice(0,499)}\u2026`),e}var ae=class{maxEntries;entries=[];originals=new Map;disposed=false;constructor(e=50){if(this.maxEntries=Math.min(Math.max(Math.floor(e),0),1e3),!(typeof console>"u"))for(let n of cn){let i=console[n];if(typeof i!="function")continue;this.originals.set(n,i);let o=this,s=function(...r){try{o.push(n,r);}catch{}i.apply(this??console,r);};try{Object.defineProperty(s,"name",{value:n});}catch{}console[n]=s;}}push(e,n){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({level:e,timestamp:new Date().toISOString(),message:un(n)}));}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed&&(this.disposed=true,!(typeof console>"u"))){for(let[e,n]of this.originals)try{console[e]=n;}catch{}this.originals.clear();}}};function Lt(t){return t.length<=2e3?t:`${t.slice(0,1999)}\u2026`}function Mt(t){if(typeof t=="string")return t;if(t instanceof URL)return t.href;if(typeof t=="object"&&t!==null&&"url"in t){let e=t.url;if(typeof e=="string")return e}try{return String(t)}catch{return "(unknown)"}}var le=class{maxEntries;entries=[];originalFetch=null;originalXhrOpen=null;originalXhrSend=null;disposed=false;constructor(e=20){this.maxEntries=Math.min(Math.max(Math.floor(e),0),500),this.installFetch(),this.installXhr();}push(e){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push(e));}installFetch(){if(typeof globalThis.fetch!="function")return;let e=globalThis.fetch;this.originalFetch=e;let n=async(i,o)=>{let s=new Date,r=typeof performance<"u"?performance.now():Date.now(),p=Lt(Mt(i)),a=(o?.method??(i instanceof Request?i.method:"GET")).toUpperCase();try{let c=await e(i,o);if(!c.ok){let l=typeof performance<"u"?performance.now():Date.now();this.push({url:p,method:a,status:c.status,durationMs:Math.round(l-r),timestamp:s.toISOString()});}return c}catch(c){let l=typeof performance<"u"?performance.now():Date.now();throw this.push({url:p,method:a,status:0,durationMs:Math.round(l-r),timestamp:s.toISOString()}),c}};globalThis.fetch=n;}installXhr(){if(typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype,n=e.open,i=e.send;this.originalXhrOpen=n,this.originalXhrSend=i;let o=this,s=new WeakMap;e.open=function(r,p,...a){try{s.set(this,{method:r.toUpperCase(),url:Lt(Mt(p)),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,r,p,...a)},e.send=function(r){let p=s.get(this);if(p){let a=()=>{try{let c=typeof performance<"u"?performance.now():Date.now(),l=this.status;(l===0||l>=400)&&o.push({url:p.url,method:p.method,status:l,durationMs:Math.round(c-p.t0),timestamp:p.startedAt.toISOString()});}catch{}};try{this.addEventListener("loadend",a,{once:!0});}catch{try{this.addEventListener("loadend",a);}catch{}}}return i.call(this,r??null)};}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed){if(this.disposed=true,this.originalFetch&&typeof globalThis.fetch=="function")try{globalThis.fetch=this.originalFetch;}catch{}if(typeof XMLHttpRequest<"u")try{this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend);}catch{}}}};var q=class{listeners=new Map;on(e,n){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(n),()=>{i?.delete(n);}}off(e,n){this.listeners.get(e)?.delete(n);}emit(e,...n){let i=this.listeners.get(e);if(i)for(let o of i)try{o(...n);}catch(s){console.error(`[siteping] Error in event listener for "${String(e)}":`,s);}}removeAll(){this.listeners.clear();}};var hn=54,pe=class{constructor(e,n,i$1,o){this.bus=i$1;this.t=o;let s=n.position??"bottom-right",r=s==="bottom-right";this.items=[{id:"chat",icon:g,label:o("fab.messages")},{id:"annotate",icon:h,label:o("fab.annotate")},{id:"toggle-annotations",icon:i,iconAlt:j$1,label:o("fab.annotations")}],this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${s} sp-anim-fab-in`,this.fab.style.position="fixed",this.fab.appendChild(a(f)),this.fab.setAttribute("aria-label",o("fab.aria")),this.fab.setAttribute("aria-expanded","false"),this.fab.addEventListener("click",()=>this.toggle()),this.radialContainer=document.createElement("div"),this.radialContainer.className=`sp-radial sp-radial--${s}`,this.radialContainer.setAttribute("role","menu");for(let c=0;c<this.items.length;c++){let l=this.items[c];if(!l)continue;let d=document.createElement("button");d.className="sp-radial-item",d.style.setProperty("--sp-i",String(c)),d.appendChild(a(l.icon)),d.setAttribute("role","menuitem"),d.setAttribute("aria-label",l.label),d.dataset.itemId=l.id,d.addEventListener("click",f=>{f.stopPropagation(),this.handleItemClick(l.id);});let h=document.createElement("span");h.className="sp-radial-label",h.textContent=l.label,h.style.cssText=r?"position:absolute; right:54px; top:50%; transform:translateY(-50%); white-space:nowrap;":"position:absolute; left:54px; top:50%; transform:translateY(-50%); white-space:nowrap;",d.appendChild(h),this.radialContainer.appendChild(d);}this.root=document.createElement("div"),this.root.appendChild(this.radialContainer),this.root.appendChild(this.fab),e.appendChild(this.root);let p=e.host;this.onDocumentClick=c=>{this.isOpen&&!c.composedPath().includes(p)&&this.close();},document.addEventListener("click",this.onDocumentClick);let a$1=c=>{c.key==="Escape"&&this.isOpen&&(c.stopPropagation(),this.close());};this.fab.addEventListener("keydown",a$1),this.radialContainer.addEventListener("keydown",a$1),this.radialContainer.addEventListener("keydown",c=>{let l=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(l.length===0||!this.isOpen)return;let d=e.activeElement??document.activeElement,h=l.indexOf(d);switch(c.key){case "ArrowUp":{c.preventDefault();let f=h<=0?l.length-1:h-1;l[f]?.focus();break}case "ArrowDown":{c.preventDefault();let f=h>=l.length-1?0:h+1;l[f]?.focus();break}case "Home":{c.preventDefault(),l[0]?.focus();break}case "End":{c.preventDefault(),l[l.length-1]?.focus();break}}});}bus;t;root;fab;radialContainer;badgeEl=null;isOpen=false;annotationsVisible=true;items;onDocumentClick;updateBadge(e){if(e<=0){this.badgeEl?.remove(),this.badgeEl=null;return}this.badgeEl||(this.badgeEl=document.createElement("span"),this.badgeEl.className="sp-fab-badge",this.badgeEl.setAttribute("role","status"),this.badgeEl.setAttribute("aria-live","polite"),this.fab.appendChild(this.badgeEl));let n=e>99?"99+":String(e);c(this.badgeEl,n),this.badgeEl.setAttribute("aria-label",this.t("fab.badge").replace("{count}",String(e)));}toggle(){this.isOpen?this.close():this.open();}open(){this.isOpen=true,this.setFabIcon(k),this.fab.setAttribute("aria-expanded","true"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach((n,i)=>{let o=-(16+hn*(i+1));n.style.transform=`translate(0px, ${o}px) scale(1)`,n.classList.add("sp-radial-item--open");}),requestAnimationFrame(()=>{this.radialContainer.querySelector(".sp-radial-item")?.focus();});}close(){this.isOpen=false,this.setFabIcon(f),this.fab.setAttribute("aria-expanded","false"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach(n=>{n.style.transform="translate(0, 0) scale(0.8)",n.classList.remove("sp-radial-item--open");}),this.fab.focus();}setFabIcon(e){let n=this.badgeEl;this.fab.replaceChildren(a(e)),n&&this.fab.appendChild(n);}handleItemClick(e){switch(this.close(),e){case "chat":this.bus.emit("panel:toggle",true);break;case "annotate":this.bus.emit("annotation:start");break;case "toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let n=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]');n&&n.replaceChildren(a(this.annotationsVisible?i:j$1));break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove();}};var Ft="siteping_identity";function fn(t){if(!E$1(t,"name")||!E$1(t,"email"))return false;let e=t.name,n=t.email;return typeof e=="string"&&typeof n=="string"&&e.length>0&&n.length>0}function Fe(){try{let t=localStorage.getItem(Ft);if(!t)return null;let e=JSON.parse(t);return fn(e)?e:null}catch{return null}}function Pt(t){try{localStorage.setItem(Ft,JSON.stringify(t));}catch{}}function mn(t,e){if(t===e)return 0;if(t.length===0)return e.length;if(e.length===0)return t.length;if(t.length>e.length){let r=t;t=e,e=r;}let n=t.length,i=e.length,o=new Array(n+1);for(let r=0;r<=n;r++)o[r]=r;let s=new Array(n+1);for(let r=1;r<=i;r++){s[0]=r;for(let a=1;a<=n;a++){let c=o[a-1]??0;s[a]=t[a-1]===e[r-1]?c:1+Math.min(c,o[a]??0,s[a-1]??0);}let p=o;o=s,s=p;}return o[n]??0}function $(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-mn(t,e)/n}function Pe(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let i=e.length;if(i>t.length){let p=$(t,e);return p>=n?p:0}let o=0,s=t.length>500?t.slice(0,500):t,r=s.length-i;for(let p=0;p<=r;p++){let a=s.slice(p,p+i),c=$(a,e);if(c>o&&(o=c),o>=.95)break}return o>=n?o:0}var gn=300,bn=.3;function ce(t,e){if(!e.textSnippet)return true;let n=(t.textContent?.trim()??"").slice(0,500);return Pe(n,e.textSnippet,.5)>bn}function yn(t){if(t.anchorKey){let e=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{let n=document.querySelector(`[${j}="${e}"]`);if(n&&ce(n,t))return {element:n,confidence:1,strategy:"anchorKey"}}catch{}}if(t.elementId){let e=document.getElementById(t.elementId);if(e&&e.tagName===t.elementTag&&ce(e,t))return {element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&ce(e,t))return {element:e,confidence:.95,strategy:"css"}}catch{}try{let n=document.evaluate(t.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(n instanceof Element&&n.tagName===t.elementTag&&ce(n,t))return {element:n,confidence:.9,strategy:"xpath"}}catch{}return vn(t)}function vn(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let i=null,o=0,s=Math.min(n.length,gn);for(let r=0;r<s;r++){let p=n[r];if(!p)continue;let a=xn(p,t);if(a>o&&(o=a,i=p,o>=.85))break}return !i||o<.4?null:{element:i,confidence:Math.min(o,.85),strategy:"scan"}}function xn(t,e){let n=0,i=0,o=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(i+=40,n+=Pe(o,e.textSnippet,.5)*40),e.fingerprint&&(i+=20,n+=bt(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){i+=20;let s=0,r=0;if(e.textPrefix){let p=_(t,"before");s+=p?$(p,e.textPrefix):0,r++;}if(e.textSuffix){let p=_(t,"after");s+=p?$(p,e.textSuffix):0,r++;}r>0&&(n+=s/r*20);}if(e.neighborText){i+=20;let s=ne(t);n+=s?$(s,e.neighborText)*20:0;}return i>0?n/i:0}function de(t,e){let n=yn(t);if(!n)return null;let i=n.element.getBoundingClientRect(),o=new DOMRect(i.x+e.xPct*i.width,i.y+e.yPct*i.height,e.wPct*i.width,e.hPct*i.height);return {element:n.element,rect:o,confidence:n.confidence,strategy:n.strategy}}function Ie(t){return {cssSelector:t.cssSelector,xpath:t.xpath,textSnippet:t.textSnippet,elementTag:t.elementTag,elementId:t.elementId??void 0,textPrefix:t.textPrefix,textSuffix:t.textSuffix,fingerprint:t.fingerprint,neighborText:t.neighborText,anchorKey:t.anchorKey??null}}function ue(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var It=13;function Nt(t){return {top:t.top+window.scrollY-It,left:t.right+window.scrollX-It}}function W(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}var Dt=300,_t=200,wn=.7,En=28,$t=32,he=class{constructor(e,n,i,o,s=null){this.colors=e;this.tooltip=n;this.bus=i;this.t=o;this.liveRegion=s;this.container=b("div",{style:`position:absolute;top:0;left:0;pointer-events:none;z-index:${2147483646};`}),this.container.id="siteping-markers",document.body.appendChild(this.container),this.bus.on("annotations:toggle",r=>{this.container.style.display=r?"block":"none";}),this.resizeHandler=()=>this.scheduleReposition(),window.addEventListener("resize",this.resizeHandler,{passive:true}),this.scrollHandler=()=>this.scheduleReposition(),window.addEventListener("scroll",this.scrollHandler,{passive:true,capture:true}),this.mutationObserver=new MutationObserver(r=>{let p=false;for(let a of r)if(!(this.container.contains(a.target)||this.tooltip.contains(a.target))){p=true;break}p&&this.scheduleReposition();}),this.mutationObserver.observe(document.body,{childList:true,subtree:true,attributes:false,characterData:false}),this.onDocumentClickForClusters=r=>{this.container.contains(r.target)||this.collapseAllClusters();},document.addEventListener("click",this.onDocumentClickForClusters);}colors;tooltip;bus;t;liveRegion;container;entries=[];highlightElements=[];pinnedFeedback=null;onDocumentClick=null;repositionTimer=null;mutationObserver=null;scrollHandler=null;resizeHandler=null;anchorCache=new Map;clusters=[];onDocumentClickForClusters=null;get count(){return this.entries.length}scheduleReposition(){this.repositionTimer||("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll();},{timeout:_t+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},_t));}repositionAll(){let e=new Set;for(let n of this.entries)for(let i=0;i<n.feedback.annotations.length;i++){let o=n.elements[i];if(!o)continue;let s=n.feedback.annotations[i];if(!s)continue;let r=`${n.feedback.id}:${i}`;e.add(r);let a=this.anchorCache.get(r)?.deref(),c;if(a?.isConnected){let d=a.getBoundingClientRect(),h=ue(s);c={element:a,rect:new DOMRect(d.left+h.xPct*d.width,d.top+h.yPct*d.height,h.wPct*d.width,h.hPct*d.height),confidence:1,strategy:"css"};}else c=de(Ie(s),ue(s)),c?.element&&this.anchorCache.set(r,new WeakRef(c.element));if(!c){o.style.display="none";continue}let l=Nt(c.rect);n.baseTop=l.top,n.baseLeft=l.left,o.style.display="flex",this.applyConfidenceStyle(o,c.confidence,n.feedback);}for(let n of this.anchorCache.keys())e.has(n)||this.anchorCache.delete(n);this.applyClusterPositions(),this.pinnedFeedback&&this.showHighlight(this.pinnedFeedback);}applyClusterPositions(){for(let e of this.clusters)e.expanded?this.applyFanPositions(e):this.applyStackPositions(e);}render(e){this.clear(),e.forEach((n,i)=>{let o=this.buildEntry(n,i+1);this.entries.push(o);}),this.buildClusters(),this.liveRegion&&this.entries.length>0&&(this.liveRegion.textContent=this.t("marker.count").replace("{count}",String(this.entries.length)));}addFeedback(e,n){let i=this.buildEntry(e,n);for(let o of i.elements)o.style.animation="sp-marker-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both";this.entries.push(i),this.buildClusters();}buildEntry(e,n){let i={feedback:e,elements:[],baseTop:0,baseLeft:0};for(let o of e.annotations){let s=de(Ie(o),ue(o));if(!s)continue;let r=Nt(s.rect);i.baseTop=r.top,i.baseLeft=r.left;let p=this.createMarker(n,e,r);this.applyConfidenceStyle(p,s.confidence,e),this.container.appendChild(p),i.elements.push(p);}return i}buildClusters(){for(let i of this.container.querySelectorAll(".sp-cluster-badge"))i.remove();let e=[];for(let i of this.entries)for(let o=0;o<i.elements.length;o++)e.push({entry:i,elIdx:o});let n=new Set;this.clusters=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let o=e[i];if(!o)continue;let s={entries:[o.entry],elementIndices:[o.elIdx],expanded:false};n.add(i);for(let r=i+1;r<e.length;r++){if(n.has(r))continue;let p=o.entry,a=e[r];if(!a)continue;let c=a.entry;Math.sqrt((p.baseLeft-c.baseLeft)**2+(p.baseTop-c.baseTop)**2)<En&&(s.entries.push(c),s.elementIndices.push(a.elIdx),n.add(r));}this.clusters.push(s);}for(let i of this.clusters)i.entries.length<=1||(this.applyStackPositions(i),this.addClusterBadge(i));}applyStackPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,s=e.entries.length<=1;for(let r=0;r<e.entries.length;r++){let p=W(e,r);p&&(p.style.top=`${i+(s?0:r*3)}px`,p.style.left=`${o+(s?0:r*3)}px`,p.style.zIndex=String(r+1));}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,s=e.entries.length,r=(s-1)*$t,p=o-r/2;for(let a=0;a<s;a++){let c=W(e,a);c&&(c.style.top=`${i}px`,c.style.left=`${p+a*$t}px`,c.style.zIndex=String(10+a));}}addClusterBadge(e){let n=W(e,e.entries.length-1);if(!n)return;let i=b("div",{class:"sp-cluster-badge",style:`
101
+ `}),this.overlay?.appendChild(this.drawingRect));}onMouseMove=e=>{this.scheduleRectUpdate(e);};onTouchMove=e=>{e.preventDefault(),e.touches[0]&&this.scheduleRectUpdate(e.touches[0]);};scheduleRectUpdate(e){!this.isDrawing||!this.drawingRect||(this.pendingMoveEvent=e,this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{this.rafId=null;let n=this.pendingMoveEvent;if(!n||!this.drawingRect)return;let i=Math.min(n.clientX,this.startX),o=Math.min(n.clientY,this.startY),s=Math.abs(n.clientX-this.startX),r=Math.abs(n.clientY-this.startY);this.drawingRect.style.left=`${i}px`,this.drawingRect.style.top=`${o}px`,this.drawingRect.style.width=`${s}px`,this.drawingRect.style.height=`${r}px`;})));}onTouchEnd=async e=>{let n=e.changedTouches[0];n&&await this.finishDrawing(n.clientX,n.clientY);};onMouseUp=async e=>{await this.finishDrawing(e.clientX,e.clientY);};finishDrawing=async(e,n)=>{if(!this.isDrawing||!this.drawingRect)return;this.isDrawing=false;let i=Math.min(e,this.startX),o=Math.min(n,this.startY),s=Math.abs(e-this.startX),r=Math.abs(n-this.startY);if(s<10||r<10){this.drawingRect.remove(),this.drawingRect=null;return}let a=new DOMRect(i,o,s,r),l=this.buildAnnotation(a),c={},d=await this.popup.show(a,p=>this.runSubmission(l,p,a,c));this.drawingRect?.remove(),this.drawingRect=null,d&&this.deactivate();};async runSubmission(e,n,i,o){o.value===void 0&&(o.value=await this.maybeCapture(i));let s=o.value;await new Promise((r,a)=>{let l=()=>{c(),d(),p(),this.rejectPendingSubmission=null;},c=this.bus.on("feedback:sent",()=>{l(),r();}),d=this.bus.on("feedback:error",h=>{l(),a(h);}),p=this.bus.on("submission:cancelled",()=>{l(),a(new Error("Feedback submission cancelled"));});this.rejectPendingSubmission=h=>{l(),a(h);},this.bus.emit("annotation:complete",{annotation:e,type:n.type,message:n.message,screenshotDataUrl:s});});}buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let n=Et(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let i=Le(n),o=n.getBoundingClientRect(),s=kt(e,o);return {anchor:i,rect:s,scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio}}destroy(){this.deactivate(),this.rejectPendingSubmission?.(new Error("Annotator destroyed during submission")),this.popup.destroy();}};async function X(t,e){let n=await t.text().catch(()=>"Unknown error"),i=n?`${t.status} ${n}`:`${t.status}`,o=`${e}: ${i}`;return t.status===401||t.status===403?new D(o):t.status>=400&&t.status<500?new C(o):new A(o,"SERVER",false)}function K(t,e){if(t instanceof B)return t;let n=t instanceof Error?t.message:String(t);return new B(`${e}: ${n}`)}var ln=3,cn=1e4,oe="siteping_retry_queue",pn=20;async function q(t,e,n=ln){for(let i=0;i<=n;i++){let o=new AbortController,s=setTimeout(()=>o.abort(),cn);try{let l=await fetch(t,{...e,signal:o.signal});if(clearTimeout(s),l.ok||l.status>=400&&l.status<500||i===n)return l}catch(l){if(clearTimeout(s),i===n)throw l}let r=1e3*2**i,a=Math.random()*1e3-500;await new Promise(l=>setTimeout(l,r+a));}throw new Error("Max retries exceeded")}var dn="siteping_retry_queue";async function Lt(t){return typeof navigator<"u"&&navigator.locks?navigator.locks.request(dn,()=>t()):t()}function Rt(){let t=localStorage.getItem(oe);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e:[]}function un(t,e){Lt(()=>{try{let n=Rt();n.length>=pn&&n.shift(),n.push({endpoint:t,payload:e}),localStorage.setItem(oe,JSON.stringify(n));}catch{}});}function Ct(t){return t.trim()}function At(t){return t.trim().toLowerCase()}async function Mt(t,e){await Lt(async()=>{try{let n=Rt();if(n.length===0)return;let i=[],o=[],s=0;for(let l of n){if(l.endpoint!==t){o.push(l);continue}!e||Ct(l.payload.authorName)===Ct(e.name)&&At(l.payload.authorEmail)===At(e.email)?i.push(l):s+=1;}if(i.length===0&&s===0)return;s>0;let r=[];for(let l of i)try{(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l.payload)})).ok||r.push(l);}catch{r.push(l);}let a=o.concat(r);a.length>0?localStorage.setItem(oe,JSON.stringify(a)):localStorage.removeItem(oe);}catch{}});}async function Re(t){return await t.json()}var se=class{constructor(e,n){this.endpoint=e;this.projectName=n;}endpoint;projectName;async sendFeedback(e){try{let n;try{n=await q(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch(i){throw K(i,"Failed to send feedback")}if(!n.ok)throw await X(n,"Failed to send feedback");return Re(n)}catch(n){throw un(this.endpoint,e),n}}async getFeedbacks(e,n){let i=new URLSearchParams({projectName:e});n?.page&&i.set("page",String(n.page)),n?.limit&&i.set("limit",String(n.limit)),n?.type&&i.set("type",n.type),n?.status&&i.set("status",n.status),n?.search&&i.set("search",n.search),n?.url&&i.set("url",n.url),n?.urlPattern&&i.set("urlPattern",n.urlPattern);let o;try{o=await q(`${this.endpoint}?${i.toString()}`,{method:"GET",cache:"no-store"});}catch(s){throw K(s,"Failed to fetch feedbacks")}if(!o.ok)throw await X(o,"Failed to fetch feedbacks");return Re(o)}async resolveFeedback(e,n){let i;try{i=await q(this.endpoint,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName,status:n?"resolved":"open"})});}catch(o){throw K(o,"Failed to update feedback")}if(!i.ok)throw await X(i,"Failed to update feedback");return Re(i)}async deleteFeedback(e){let n;try{n=await q(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName})});}catch(i){throw K(i,"Failed to delete feedback")}if(!n.ok)throw await X(n,"Failed to delete feedback")}async deleteAllFeedbacks(e){let n;try{n=await q(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectName:e,deleteAll:!0})});}catch(i){throw K(i,"Failed to delete all feedbacks")}if(!n.ok)throw await X(n,"Failed to delete all feedbacks")}};var hn=["log","info","warn","error"];function fn(t){if(t===null)return "null";if(t===void 0)return "undefined";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean"||typeof t=="bigint")return String(t);if(t instanceof Error)return `${t.name}: ${t.message}${t.stack?`
102
+ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof i=="function")return "[Function]";if(typeof i=="symbol")return i.toString();if(typeof i=="object"&&i!==null){if(e.has(i))return "[Circular]";e.add(i);}return i})}catch{try{return String(t)}catch{return "[Unserializable]"}}}function mn(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=fn(t[n]),!(e.length>=500));n++);return e.length>500&&(e=`${e.slice(0,499)}\u2026`),e}var re=class{maxEntries;entries=[];originals=new Map;disposed=false;constructor(e=50){if(this.maxEntries=Math.min(Math.max(Math.floor(e),0),1e3),!(typeof console>"u"))for(let n of hn){let i=console[n];if(typeof i!="function")continue;this.originals.set(n,i);let o=this,s=function(...r){try{o.push(n,r);}catch{}i.apply(this??console,r);};try{Object.defineProperty(s,"name",{value:n});}catch{}console[n]=s;}}push(e,n){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({level:e,timestamp:new Date().toISOString(),message:mn(n)}));}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed&&(this.disposed=true,!(typeof console>"u"))){for(let[e,n]of this.originals)try{console[e]=n;}catch{}this.originals.clear();}}};function Pt(t){return t.length<=2e3?t:`${t.slice(0,1999)}\u2026`}function Ft(t){if(typeof t=="string")return t;if(t instanceof URL)return t.href;if(typeof t=="object"&&t!==null&&"url"in t){let e=t.url;if(typeof e=="string")return e}try{return String(t)}catch{return "(unknown)"}}var ae=class{maxEntries;entries=[];originalFetch=null;originalXhrOpen=null;originalXhrSend=null;disposed=false;constructor(e=20){this.maxEntries=Math.min(Math.max(Math.floor(e),0),500),this.installFetch(),this.installXhr();}push(e){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push(e));}installFetch(){if(typeof globalThis.fetch!="function")return;let e=globalThis.fetch;this.originalFetch=e;let n=async(i,o)=>{let s=new Date,r=typeof performance<"u"?performance.now():Date.now(),a=Pt(Ft(i)),l=(o?.method??(i instanceof Request?i.method:"GET")).toUpperCase();try{let c=await e(i,o);if(!c.ok){let d=typeof performance<"u"?performance.now():Date.now();this.push({url:a,method:l,status:c.status,durationMs:Math.round(d-r),timestamp:s.toISOString()});}return c}catch(c){let d=typeof performance<"u"?performance.now():Date.now();throw this.push({url:a,method:l,status:0,durationMs:Math.round(d-r),timestamp:s.toISOString()}),c}};globalThis.fetch=n;}installXhr(){if(typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype,n=e.open,i=e.send;this.originalXhrOpen=n,this.originalXhrSend=i;let o=this,s=new WeakMap;e.open=function(r,a,...l){try{s.set(this,{method:r.toUpperCase(),url:Pt(Ft(a)),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,r,a,...l)},e.send=function(r){let a=s.get(this);if(a){let l=()=>{try{let c=typeof performance<"u"?performance.now():Date.now(),d=this.status;(d===0||d>=400)&&o.push({url:a.url,method:a.method,status:d,durationMs:Math.round(c-a.t0),timestamp:a.startedAt.toISOString()});}catch{}};try{this.addEventListener("loadend",l,{once:!0});}catch{try{this.addEventListener("loadend",l);}catch{}}}return i.call(this,r??null)};}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed){if(this.disposed=true,this.originalFetch&&typeof globalThis.fetch=="function")try{globalThis.fetch=this.originalFetch;}catch{}if(typeof XMLHttpRequest<"u")try{this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend);}catch{}}}};var Y=class{listeners=new Map;on(e,n){let i=this.listeners.get(e);return i||(i=new Set,this.listeners.set(e,i)),i.add(n),()=>{i?.delete(n);}}off(e,n){this.listeners.get(e)?.delete(n);}emit(e,...n){let i=this.listeners.get(e);if(i)for(let o of i)try{o(...n);}catch(s){console.error(`[siteping] Error in event listener for "${String(e)}":`,s);}}removeAll(){this.listeners.clear();}};var bn=54,gn={chat:"fab.messages",annotate:"fab.annotate","toggle-annotations":"fab.annotations"},le=class{constructor(e,n,i$1,o){this.bus=i$1;this.t=o;let s=n.position??"bottom-right",r=s==="bottom-right";this.items=[{id:"chat",icon:g},{id:"annotate",icon:h},{id:"toggle-annotations",icon:i,iconAlt:j$1}],this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${s} sp-anim-fab-in`,this.fab.style.position="fixed",this.fab.appendChild(a(f)),this.fab.setAttribute("aria-expanded","false"),this.fab.addEventListener("click",()=>this.toggle()),this.radialContainer=document.createElement("div"),this.radialContainer.className=`sp-radial sp-radial--${s}`,this.radialContainer.setAttribute("role","menu");for(let c=0;c<this.items.length;c++){let d=this.items[c];if(!d)continue;let p=document.createElement("button");p.className="sp-radial-item",p.style.setProperty("--sp-i",String(c)),p.appendChild(a(d.icon)),p.setAttribute("role","menuitem"),p.dataset.itemId=d.id,p.addEventListener("click",m=>{m.stopPropagation(),this.handleItemClick(d.id);});let h=document.createElement("span");h.className="sp-radial-label",h.style.cssText=r?"position:absolute; right:54px; top:50%; transform:translateY(-50%); white-space:nowrap;":"position:absolute; left:54px; top:50%; transform:translateY(-50%); white-space:nowrap;",p.appendChild(h),this.radialContainer.appendChild(p);}this.root=document.createElement("div"),this.root.appendChild(this.radialContainer),this.root.appendChild(this.fab),e.appendChild(this.root),this.applyLabels();let a$1=e.host;this.onDocumentClick=c=>{this.isOpen&&!c.composedPath().includes(a$1)&&this.close();},document.addEventListener("click",this.onDocumentClick);let l=c=>{c.key==="Escape"&&this.isOpen&&(c.stopPropagation(),this.close());};this.fab.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",c=>{let d=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(d.length===0||!this.isOpen)return;let p=e.activeElement??document.activeElement,h=d.indexOf(p);switch(c.key){case "ArrowUp":{c.preventDefault();let m=h<=0?d.length-1:h-1;d[m]?.focus();break}case "ArrowDown":{c.preventDefault();let m=h>=d.length-1?0:h+1;d[m]?.focus();break}case "Home":{c.preventDefault(),d[0]?.focus();break}case "End":{c.preventDefault(),d[d.length-1]?.focus();break}}});}bus;t;root;fab;radialContainer;badgeEl=null;isOpen=false;annotationsVisible=true;items;onDocumentClick;refreshLabels(){this.applyLabels();}applyLabels(){this.fab.setAttribute("aria-label",this.t("fab.aria"));let e=this.radialContainer.querySelectorAll(".sp-radial-item");for(let n of e){let i=n.dataset.itemId;if(!i)continue;let o=gn[i];if(!o)continue;let s=this.t(o);n.setAttribute("aria-label",s);let r=n.querySelector(".sp-radial-label");r&&c(r,s);}}updateBadge(e){if(e<=0){this.badgeEl?.remove(),this.badgeEl=null;return}this.badgeEl||(this.badgeEl=document.createElement("span"),this.badgeEl.className="sp-fab-badge",this.badgeEl.setAttribute("role","status"),this.badgeEl.setAttribute("aria-live","polite"),this.fab.appendChild(this.badgeEl));let n=e>99?"99+":String(e);c(this.badgeEl,n),this.badgeEl.setAttribute("aria-label",this.t("fab.badge").replace("{count}",String(e)));}toggle(){this.isOpen?this.close():this.open();}open(){this.isOpen=true,this.setFabIcon(k$1),this.fab.setAttribute("aria-expanded","true"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach((n,i)=>{let o=-(16+bn*(i+1));n.style.transform=`translate(0px, ${o}px) scale(1)`,n.classList.add("sp-radial-item--open");}),requestAnimationFrame(()=>{this.radialContainer.querySelector(".sp-radial-item")?.focus();});}close(){this.isOpen=false,this.setFabIcon(f),this.fab.setAttribute("aria-expanded","false"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach(n=>{n.style.transform="translate(0, 0) scale(0.8)",n.classList.remove("sp-radial-item--open");}),this.fab.focus();}setFabIcon(e){let n=this.badgeEl;this.fab.replaceChildren(a(e)),n&&this.fab.appendChild(n);}handleItemClick(e){switch(this.close(),e){case "chat":this.bus.emit("panel:toggle",true);break;case "annotate":this.bus.emit("annotation:start");break;case "toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let n=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]');n&&n.replaceChildren(a(this.annotationsVisible?i:j$1));break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove();}};var It="siteping_identity";function yn(t){if(!E(t,"name")||!E(t,"email"))return false;let e=t.name,n=t.email;return typeof e=="string"&&typeof n=="string"&&e.length>0&&n.length>0}function Me(){try{let t=localStorage.getItem(It);if(!t)return null;let e=JSON.parse(t);return yn(e)?e:null}catch{return null}}function Dt(t){try{localStorage.setItem(It,JSON.stringify(t));}catch{}}function vn(t,e){if(t===e)return 0;if(t.length===0)return e.length;if(e.length===0)return t.length;if(t.length>e.length){let r=t;t=e,e=r;}let n=t.length,i=e.length,o=new Array(n+1);for(let r=0;r<=n;r++)o[r]=r;let s=new Array(n+1);for(let r=1;r<=i;r++){s[0]=r;for(let l=1;l<=n;l++){let c=o[l-1]??0;s[l]=t[l-1]===e[r-1]?c:1+Math.min(c,o[l]??0,s[l-1]??0);}let a=o;o=s,s=a;}return o[n]??0}function $(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-vn(t,e)/n}function Pe(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let i=e.length;if(i>t.length){let a=$(t,e);return a>=n?a:0}let o=0,s=t.length>500?t.slice(0,500):t,r=s.length-i;for(let a=0;a<=r;a++){let l=s.slice(a,a+i),c=$(l,e);if(c>o&&(o=c),o>=.95)break}return o>=n?o:0}var xn=300,wn=.3;function ce(t,e){if(!e.textSnippet)return true;let n=(t.textContent?.trim()??"").slice(0,500);return Pe(n,e.textSnippet,.5)>wn}function En(t){if(t.anchorKey){let e=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{let n=document.querySelector(`[${z}="${e}"]`);if(n&&ce(n,t))return {element:n,confidence:1,strategy:"anchorKey"}}catch{}}if(t.elementId){let e=document.getElementById(t.elementId);if(e&&e.tagName===t.elementTag&&ce(e,t))return {element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&ce(e,t))return {element:e,confidence:.95,strategy:"css"}}catch{}try{let n=document.evaluate(t.xpath,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(n instanceof Element&&n.tagName===t.elementTag&&ce(n,t))return {element:n,confidence:.9,strategy:"xpath"}}catch{}return kn(t)}function kn(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let i=null,o=0,s=Math.min(n.length,xn);for(let r=0;r<s;r++){let a=n[r];if(!a)continue;let l=Sn(a,t);if(l>o&&(o=l,i=a,o>=.85))break}return !i||o<.4?null:{element:i,confidence:Math.min(o,.85),strategy:"scan"}}function Sn(t,e){let n=0,i=0,o=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(i+=40,n+=Pe(o,e.textSnippet,.5)*40),e.fingerprint&&(i+=20,n+=vt(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){i+=20;let s=0,r=0;if(e.textPrefix){let a=H(t,"before");s+=a?$(a,e.textPrefix):0,r++;}if(e.textSuffix){let a=H(t,"after");s+=a?$(a,e.textSuffix):0,r++;}r>0&&(n+=s/r*20);}if(e.neighborText){i+=20;let s=te(t);n+=s?$(s,e.neighborText)*20:0;}return i>0?n/i:0}function pe(t,e){let n=En(t);if(!n)return null;let i=n.element.getBoundingClientRect(),o=new DOMRect(i.x+e.xPct*i.width,i.y+e.yPct*i.height,e.wPct*i.width,e.hPct*i.height);return {element:n.element,rect:o,confidence:n.confidence,strategy:n.strategy}}function Fe(t){return {cssSelector:t.cssSelector,xpath:t.xpath,textSnippet:t.textSnippet,elementTag:t.elementTag,elementId:t.elementId??void 0,textPrefix:t.textPrefix,textSuffix:t.textSuffix,fingerprint:t.fingerprint,neighborText:t.neighborText,anchorKey:t.anchorKey??null}}function de(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var Nt=13;function _t(t){return {top:t.top+window.scrollY-Nt,left:t.right+window.scrollX-Nt}}function U(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}var Ht=300,$t=200,Tn=.7,Cn=28,Ot=32,ue=class{constructor(e,n,i,o,s=null){this.colors=e;this.tooltip=n;this.bus=i;this.t=o;this.liveRegion=s;this.container=b("div",{style:`position:absolute;top:0;left:0;pointer-events:none;z-index:${2147483646};`}),this.container.id="siteping-markers",document.body.appendChild(this.container),this.bus.on("annotations:toggle",r=>{this.container.style.display=r?"block":"none";}),this.resizeHandler=()=>this.scheduleReposition(),window.addEventListener("resize",this.resizeHandler,{passive:true}),this.scrollHandler=()=>this.scheduleReposition(),window.addEventListener("scroll",this.scrollHandler,{passive:true,capture:true}),this.mutationObserver=new MutationObserver(r=>{let a=false;for(let l of r)if(!(this.container.contains(l.target)||this.tooltip.contains(l.target))){a=true;break}a&&this.scheduleReposition();}),this.mutationObserver.observe(document.body,{childList:true,subtree:true,attributes:false,characterData:false}),this.onDocumentClickForClusters=r=>{this.container.contains(r.target)||this.collapseAllClusters();},document.addEventListener("click",this.onDocumentClickForClusters);}colors;tooltip;bus;t;liveRegion;container;entries=[];highlightElements=[];pinnedFeedback=null;onDocumentClick=null;repositionTimer=null;mutationObserver=null;scrollHandler=null;resizeHandler=null;anchorCache=new Map;clusters=[];onDocumentClickForClusters=null;lastOpenCount=-1;get count(){return this.entries.length}get openCount(){let e=0;for(let n of this.entries)n.feedback.status==="open"&&e++;return e}scheduleReposition(){this.repositionTimer||("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll();},{timeout:$t+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},$t));}repositionAll(){let e=new Set;for(let n of this.entries)for(let i=0;i<n.feedback.annotations.length;i++){let o=n.elements[i];if(!o)continue;let s=n.feedback.annotations[i];if(!s)continue;let r=`${n.feedback.id}:${i}`;e.add(r);let l=this.anchorCache.get(r)?.deref(),c;if(l?.isConnected){let p=l.getBoundingClientRect(),h=de(s);c={element:l,rect:new DOMRect(p.left+h.xPct*p.width,p.top+h.yPct*p.height,h.wPct*p.width,h.hPct*p.height),confidence:1,strategy:"css"};}else c=pe(Fe(s),de(s)),c?.element&&this.anchorCache.set(r,new WeakRef(c.element));if(!c){o.style.display="none";continue}let d=_t(c.rect);n.baseTop=d.top,n.baseLeft=d.left,o.style.display="flex",this.applyConfidenceStyle(o,c.confidence,n.feedback);}for(let n of this.anchorCache.keys())e.has(n)||this.anchorCache.delete(n);this.applyClusterPositions(),this.pinnedFeedback&&this.showHighlight(this.pinnedFeedback);}applyClusterPositions(){for(let e of this.clusters)e.expanded?this.applyFanPositions(e):this.applyStackPositions(e);}emitMarkersChanged(){let e=this.openCount;e!==this.lastOpenCount&&(this.lastOpenCount=e,this.bus.emit("markers:changed",e));}render(e){this.clear(),e.forEach((n,i)=>{let o=this.buildEntry(n,i+1);this.entries.push(o);}),this.buildClusters(),this.liveRegion&&this.entries.length>0&&(this.liveRegion.textContent=this.t("marker.count").replace("{count}",String(this.entries.length))),this.emitMarkersChanged();}addFeedback(e,n){let i=this.buildEntry(e,n);for(let o of i.elements)o.style.animation="sp-marker-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both";this.entries.push(i),this.buildClusters(),this.emitMarkersChanged();}buildEntry(e,n){let i={feedback:e,elements:[],baseTop:0,baseLeft:0};for(let o of e.annotations){let s=pe(Fe(o),de(o));if(!s)continue;let r=_t(s.rect);i.baseTop=r.top,i.baseLeft=r.left;let a=this.createMarker(n,e,r);this.applyConfidenceStyle(a,s.confidence,e),this.container.appendChild(a),i.elements.push(a);}return i}buildClusters(){for(let i of this.container.querySelectorAll(".sp-cluster-badge"))i.remove();let e=[];for(let i of this.entries)for(let o=0;o<i.elements.length;o++)e.push({entry:i,elIdx:o});let n=new Set;this.clusters=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let o=e[i];if(!o)continue;let s={entries:[o.entry],elementIndices:[o.elIdx],expanded:false};n.add(i);for(let r=i+1;r<e.length;r++){if(n.has(r))continue;let a=o.entry,l=e[r];if(!l)continue;let c=l.entry;Math.sqrt((a.baseLeft-c.baseLeft)**2+(a.baseTop-c.baseTop)**2)<Cn&&(s.entries.push(c),s.elementIndices.push(l.elIdx),n.add(r));}this.clusters.push(s);}for(let i of this.clusters)i.entries.length<=1||(this.applyStackPositions(i),this.addClusterBadge(i));}applyStackPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,s=e.entries.length<=1;for(let r=0;r<e.entries.length;r++){let a=U(e,r);a&&(a.style.top=`${i+(s?0:r*3)}px`,a.style.left=`${o+(s?0:r*3)}px`,a.style.zIndex=String(r+1));}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,s=e.entries.length,r=(s-1)*Ot,a=o-r/2;for(let l=0;l<s;l++){let c=U(e,l);c&&(c.style.top=`${i}px`,c.style.left=`${a+l*Ot}px`,c.style.zIndex=String(10+l));}}addClusterBadge(e){let n=U(e,e.entries.length-1);if(!n)return;let i=b("div",{class:"sp-cluster-badge",style:`
96
103
  position:absolute;top:-6px;right:-6px;
97
104
  min-width:16px;height:16px;padding:0 4px;
98
105
  border-radius:9999px;
@@ -103,7 +110,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
103
110
  pointer-events:none;
104
111
  font-family:"Inter",system-ui,-apple-system,sans-serif;
105
112
  line-height:1;
106
- `});c(i,String(e.entries.length)),n.appendChild(i);}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let o=W(e,i)?.querySelector(".sp-cluster-badge");o&&(o.style.display=n?"flex":"none");}}findCluster(e){for(let n of this.clusters)if(!(n.entries.length<=1)){for(let i=0;i<n.entries.length;i++)if(W(n,i)===e)return n}return null}handleClusterClick(e,n){let i=this.findCluster(e);return i?i.expanded?false:(n.stopPropagation(),this.collapseAllClusters(),i.expanded=true,this.applyFanPositions(i),this.setBadgesVisible(i,false),true):false}collapseCluster(e){e.expanded&&(e.expanded=false,this.applyStackPositions(e),this.setBadgesVisible(e,true));}collapseAllClusters(){for(let e of this.clusters)this.collapseCluster(e);}applyConfidenceStyle(e,n,i){let o=i.status==="resolved";n<wn&&!o?(e.style.borderStyle="dashed",e.style.opacity="0.7",e.title=this.t("marker.approximate").replace("{confidence}",String(Math.round(n*100)))):(e.style.borderStyle="solid",e.style.opacity="1",e.title="");}createMarker(e,n,i){let o=x(n.type,this.colors),s=n.status==="resolved",r=b("div",{style:`
113
+ `});c(i,String(e.entries.length)),n.appendChild(i);}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let o=U(e,i)?.querySelector(".sp-cluster-badge");o&&(o.style.display=n?"flex":"none");}}findCluster(e){for(let n of this.clusters)if(!(n.entries.length<=1)){for(let i=0;i<n.entries.length;i++)if(U(n,i)===e)return n}return null}handleClusterClick(e,n){let i=this.findCluster(e);return i?i.expanded?false:(n.stopPropagation(),this.collapseAllClusters(),i.expanded=true,this.applyFanPositions(i),this.setBadgesVisible(i,false),true):false}collapseCluster(e){e.expanded&&(e.expanded=false,this.applyStackPositions(e),this.setBadgesVisible(e,true));}collapseAllClusters(){for(let e of this.clusters)this.collapseCluster(e);}applyConfidenceStyle(e,n,i){let o=i.status==="resolved";n<Tn&&!o?(e.style.borderStyle="dashed",e.style.opacity="0.7",e.title=this.t("marker.approximate").replace("{confidence}",String(Math.round(n*100)))):(e.style.borderStyle="solid",e.style.opacity="1",e.title="");}createMarker(e,n,i){let o=x(n.type,this.colors),s=n.status==="resolved",r=b("div",{style:`
107
114
  position:absolute;
108
115
  top:${i.top}px;
109
116
  left:${i.left}px;
@@ -120,7 +127,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
120
127
  transition:top 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), left 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.15s ease, box-shadow 0.15s ease;
121
128
  user-select:none;
122
129
  -webkit-font-smoothing:antialiased;
123
- `});r.dataset.feedbackId=n.id,r.setAttribute("tabindex","0"),r.setAttribute("role","button");let p=n.message.length>60?`${n.message.slice(0,60)}...`:n.message,a=this.t("marker.aria").replace("{number}",String(e)).replace("{type}",I(n.type,this.t)).replace("{message}",p);r.setAttribute("aria-label",a),r.setAttribute("aria-describedby",this.tooltip.tooltipId),c(r,s?"\u2713":String(e)),r.addEventListener("mouseenter",()=>{r.style.transform="scale(1.2)",r.style.boxShadow=s?"0 4px 16px rgba(0,0,0,0.1)":`0 4px 20px ${o}35, 0 4px 12px rgba(0,0,0,0.08)`,this.tooltip.show(n,r.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),r.addEventListener("mouseleave",()=>{r.style.transform="scale(1)",r.style.boxShadow=s?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${o}25, 0 2px 6px rgba(0,0,0,0.06)`,this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();}),r.addEventListener("focus",()=>{this.tooltip.show(n,r.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),r.addEventListener("blur",()=>{this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();});let c$1=l=>{l instanceof MouseEvent&&this.handleClusterClick(r,l)||(this.pinHighlight(n),this.bus.emit("panel:toggle",true),r.dispatchEvent(new CustomEvent("sp-marker-click",{detail:{feedbackId:n.id},bubbles:true})));};return r.addEventListener("click",l=>c$1(l)),r.addEventListener("keydown",l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),c$1(l));}),r}focusFeedback(e){let n=this.entries.find(o=>o.feedback.id===e);if(!n)return false;let i=n.elements[0];return i&&i.scrollIntoView({behavior:"smooth",block:"center"}),this.pinHighlight(n.feedback),this.highlight(e),true}highlight(e){for(let n of this.entries)if(n.feedback.id===e)for(let i of n.elements)i.style.animation="sp-pulse-ring 0.7s ease-out",i.addEventListener("animationend",()=>{i.style.animation="";},{once:true});}showHighlight(e){this.removeHighlightElements();for(let n of e.annotations){let i=de(Ie(n),ue(n));if(!i)continue;let o=x(e.type,this.colors),s=i.rect,r=b("div",{style:`
130
+ `});r.dataset.feedbackId=n.id,r.setAttribute("tabindex","0"),r.setAttribute("role","button");let a=n.message.length>60?`${n.message.slice(0,60)}...`:n.message,l=this.t("marker.aria").replace("{number}",String(e)).replace("{type}",I(n.type,this.t)).replace("{message}",a);r.setAttribute("aria-label",l),r.setAttribute("aria-describedby",this.tooltip.tooltipId),c(r,s?"\u2713":String(e)),r.addEventListener("mouseenter",()=>{r.style.transform="scale(1.2)",r.style.boxShadow=s?"0 4px 16px rgba(0,0,0,0.1)":`0 4px 20px ${o}35, 0 4px 12px rgba(0,0,0,0.08)`,this.tooltip.show(n,r.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),r.addEventListener("mouseleave",()=>{r.style.transform="scale(1)",r.style.boxShadow=s?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${o}25, 0 2px 6px rgba(0,0,0,0.06)`,this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();}),r.addEventListener("focus",()=>{this.tooltip.show(n,r.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),r.addEventListener("blur",()=>{this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();});let c$1=d=>{d instanceof MouseEvent&&this.handleClusterClick(r,d)||(this.pinHighlight(n),this.bus.emit("panel:toggle",true),r.dispatchEvent(new CustomEvent("sp-marker-click",{detail:{feedbackId:n.id},bubbles:true})));};return r.addEventListener("click",d=>c$1(d)),r.addEventListener("keydown",d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),c$1(d));}),r}focusFeedback(e){let n=this.entries.find(o=>o.feedback.id===e);if(!n)return false;let i=n.elements[0];return i&&i.scrollIntoView({behavior:"smooth",block:"center"}),this.pinHighlight(n.feedback),this.highlight(e),true}highlight(e){for(let n of this.entries)if(n.feedback.id===e)for(let i of n.elements)i.style.animation="sp-pulse-ring 0.7s ease-out",i.addEventListener("animationend",()=>{i.style.animation="";},{once:true});}showHighlight(e){this.removeHighlightElements();for(let n of e.annotations){let i=pe(Fe(n),de(n));if(!i)continue;let o=x(e.type,this.colors),s=i.rect,r=b("div",{style:`
124
131
  position:absolute;
125
132
  top:${s.top+window.scrollY}px;
126
133
  left:${s.left+window.scrollX}px;
@@ -131,8 +138,8 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
131
138
  pointer-events:none;z-index:-1;
132
139
  opacity:0;
133
140
  box-shadow:0 0 16px ${o}20;
134
- transition:opacity ${Dt}ms ease;
135
- `});this.container.appendChild(r),this.highlightElements.push(r),r.offsetHeight,r.style.opacity="1";}}pinHighlight(e){this.unpinHighlight(),this.showHighlight(e),this.pinnedFeedback=e,this.onDocumentClick=n=>{this.container.contains(n.target)||this.unpinHighlight();},document.addEventListener("click",this.onDocumentClick,{capture:true});}unpinHighlight(){this.onDocumentClick&&(document.removeEventListener("click",this.onDocumentClick,{capture:true}),this.onDocumentClick=null),this.pinnedFeedback=null,this.clearHighlight();}clearHighlight(){for(let e of this.highlightElements)e.style.opacity="0",setTimeout(()=>e.remove(),Dt);this.highlightElements=[];}removeHighlightElements(){for(let e of this.highlightElements)e.remove();this.highlightElements=[];}clear(){this.unpinHighlight(),this.container.replaceChildren(),this.entries=[],this.clusters=[],this.anchorCache.clear();}destroy(){this.unpinHighlight(),this.repositionTimer&&("cancelIdleCallback"in window&&window.cancelIdleCallback(this.repositionTimer),clearTimeout(this.repositionTimer)),this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.scrollHandler&&window.removeEventListener("scroll",this.scrollHandler,{capture:true}),this.onDocumentClickForClusters&&document.removeEventListener("click",this.onDocumentClickForClusters),this.mutationObserver?.disconnect(),this.container.remove();}};var fe=class{constructor(e,n){this.store=e;this.projectName=n;}store;projectName;async sendFeedback(e){let n=await this.store.createFeedback({projectName:e.projectName,type:e.type,message:e.message,status:"open",url:e.url,urlPattern:e.urlPattern??null,viewport:e.viewport,userAgent:e.userAgent,authorName:e.authorName,authorEmail:e.authorEmail,clientId:e.clientId,annotations:e.annotations.map(F),screenshotDataUrl:e.screenshotDataUrl??null});return Ne(n)}async getFeedbacks(e,n){let{feedbacks:i,total:o}=await this.store.getFeedbacks({projectName:e,page:n?.page,limit:n?.limit,type:n?.type,status:n?.status,search:n?.search,url:n?.url,urlPattern:n?.urlPattern});return {feedbacks:i.map(Ne),total:o}}async resolveFeedback(e,n){let i=await this.store.updateFeedback(e,{status:n?"resolved":"open",resolvedAt:n?new Date:null});return Ne(i)}async deleteFeedback(e){await this.store.deleteFeedback(e);}async deleteAllFeedbacks(e){await this.store.deleteAllFeedbacks(e);}};function Ne(t){return {id:t.id,projectName:t.projectName,type:t.type,message:t.message,status:t.status,url:t.url,urlPattern:t.urlPattern??null,viewport:t.viewport,userAgent:t.userAgent,authorName:t.authorName,authorEmail:t.authorEmail,resolvedAt:t.resolvedAt?.toISOString()??null,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),annotations:t.annotations.map(kn),screenshotUrl:t.screenshotUrl??null,diagnostics:t.diagnostics??null}}function kn(t){return {id:t.id,feedbackId:t.feedbackId,cssSelector:t.cssSelector,xpath:t.xpath,textSnippet:t.textSnippet,elementTag:t.elementTag,elementId:t.elementId,textPrefix:t.textPrefix,textSuffix:t.textSuffix,fingerprint:t.fingerprint,neighborText:t.neighborText,anchorKey:t.anchorKey??null,xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct,scrollX:t.scrollX,scrollY:t.scrollY,viewportW:t.viewportW,viewportH:t.viewportH,devicePixelRatio:t.devicePixelRatio,createdAt:t.createdAt.toISOString()}}var Tn="linear(0, 0.006, 0.025, 0.06, 0.11, 0.17, 0.25, 0.34, 0.45, 0.56, 0.67, 0.78, 0.88, 0.95, 1.01, 1.04, 1.05, 1.04, 1.02, 1, 0.99, 1)",De="cubic-bezier(0.16, 1, 0.3, 1)",_e="cubic-bezier(0.34, 1.56, 0.64, 1)",Sn="cubic-bezier(0.25, 1, 0.5, 1)",Ht=`
141
+ transition:opacity ${Ht}ms ease;
142
+ `});this.container.appendChild(r),this.highlightElements.push(r),r.offsetHeight,r.style.opacity="1";}}pinHighlight(e){this.unpinHighlight(),this.showHighlight(e),this.pinnedFeedback=e,this.onDocumentClick=n=>{this.container.contains(n.target)||this.unpinHighlight();},document.addEventListener("click",this.onDocumentClick,{capture:true});}unpinHighlight(){this.onDocumentClick&&(document.removeEventListener("click",this.onDocumentClick,{capture:true}),this.onDocumentClick=null),this.pinnedFeedback=null,this.clearHighlight();}clearHighlight(){for(let e of this.highlightElements)e.style.opacity="0",setTimeout(()=>e.remove(),Ht);this.highlightElements=[];}removeHighlightElements(){for(let e of this.highlightElements)e.remove();this.highlightElements=[];}clear(){this.unpinHighlight(),this.container.replaceChildren(),this.entries=[],this.clusters=[],this.anchorCache.clear();}destroy(){this.unpinHighlight(),this.repositionTimer&&("cancelIdleCallback"in window&&window.cancelIdleCallback(this.repositionTimer),clearTimeout(this.repositionTimer)),this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.scrollHandler&&window.removeEventListener("scroll",this.scrollHandler,{capture:true}),this.onDocumentClickForClusters&&document.removeEventListener("click",this.onDocumentClickForClusters),this.mutationObserver?.disconnect(),this.container.remove();}};var he=class{constructor(e,n){this.store=e;this.projectName=n;}store;projectName;async sendFeedback(e){let n=await this.store.createFeedback({projectName:e.projectName,type:e.type,message:e.message,status:"open",url:e.url,urlPattern:e.urlPattern??null,viewport:e.viewport,userAgent:e.userAgent,authorName:e.authorName,authorEmail:e.authorEmail,clientId:e.clientId,annotations:e.annotations.map(F),screenshotDataUrl:e.screenshotDataUrl??null});return Ie(n)}async getFeedbacks(e,n){let{feedbacks:i,total:o}=await this.store.getFeedbacks({projectName:e,page:n?.page,limit:n?.limit,type:n?.type,status:n?.status,search:n?.search,url:n?.url,urlPattern:n?.urlPattern});return {feedbacks:i.map(Ie),total:o}}async resolveFeedback(e,n){let i=await this.store.updateFeedback(e,{status:n?"resolved":"open",resolvedAt:n?new Date:null});return Ie(i)}async deleteFeedback(e){await this.store.deleteFeedback(e);}async deleteAllFeedbacks(e){await this.store.deleteAllFeedbacks(e);}};function Ie(t){return {id:t.id,projectName:t.projectName,type:t.type,message:t.message,status:t.status,url:t.url,urlPattern:t.urlPattern??null,viewport:t.viewport,userAgent:t.userAgent,authorName:t.authorName,authorEmail:t.authorEmail,resolvedAt:t.resolvedAt?.toISOString()??null,createdAt:t.createdAt.toISOString(),updatedAt:t.updatedAt.toISOString(),annotations:t.annotations.map(An),screenshotUrl:t.screenshotUrl??null,diagnostics:t.diagnostics??null}}function An(t){return {id:t.id,feedbackId:t.feedbackId,cssSelector:t.cssSelector,xpath:t.xpath,textSnippet:t.textSnippet,elementTag:t.elementTag,elementId:t.elementId,textPrefix:t.textPrefix,textSuffix:t.textSuffix,fingerprint:t.fingerprint,neighborText:t.neighborText,anchorKey:t.anchorKey??null,xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct,scrollX:t.scrollX,scrollY:t.scrollY,viewportW:t.viewportW,viewportH:t.viewportH,devicePixelRatio:t.devicePixelRatio,createdAt:t.createdAt.toISOString()}}var Ln="linear(0, 0.006, 0.025, 0.06, 0.11, 0.17, 0.25, 0.34, 0.45, 0.56, 0.67, 0.78, 0.88, 0.95, 1.01, 1.04, 1.05, 1.04, 1.02, 1, 0.99, 1)",De="cubic-bezier(0.16, 1, 0.3, 1)",Ne="cubic-bezier(0.34, 1.56, 0.64, 1)",Rn="cubic-bezier(0.25, 1, 0.5, 1)",Bt=`
136
143
  /* ---- Keyframes ---- */
137
144
 
138
145
  @keyframes sp-fab-in {
@@ -206,11 +213,11 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
206
213
  /* ---- Animation classes ---- */
207
214
 
208
215
  .sp-anim-fab-in {
209
- animation: sp-fab-in 0.5s ${Tn} both;
216
+ animation: sp-fab-in 0.5s ${Ln} both;
210
217
  }
211
218
 
212
219
  .sp-anim-marker-in {
213
- animation: sp-marker-in 0.35s ${_e} both;
220
+ animation: sp-marker-in 0.35s ${Ne} both;
214
221
  }
215
222
 
216
223
  .sp-anim-pulse {
@@ -218,7 +225,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
218
225
  }
219
226
 
220
227
  .sp-anim-flash {
221
- animation: sp-flash-bg 0.5s ${Sn};
228
+ animation: sp-flash-bg 0.5s ${Rn};
222
229
  }
223
230
 
224
231
  .sp-anim-slide-up {
@@ -245,7 +252,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
245
252
  pointer-events: none;
246
253
  transform: translate(0, 0) scale(0.8);
247
254
  transition:
248
- transform 0.35s ${_e},
255
+ transform 0.35s ${Ne},
249
256
  opacity 0.2s ease,
250
257
  background 0.2s ease,
251
258
  border-color 0.2s ease,
@@ -304,7 +311,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
304
311
  }
305
312
 
306
313
  .sp-fab-badge {
307
- animation: sp-badge-in 0.4s ${_e} both;
314
+ animation: sp-badge-in 0.4s ${Ne} both;
308
315
  }
309
316
 
310
317
  /* ---- Reduced motion ---- */
@@ -317,7 +324,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
317
324
  }
318
325
  }
319
326
 
320
- `;function $e(t){return `
327
+ `;function _e(t){return `
321
328
  :host {
322
329
  all: initial;
323
330
  position: fixed;
@@ -328,7 +335,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
328
335
  color: var(--sp-text);
329
336
  -webkit-font-smoothing: antialiased;
330
337
  -moz-osx-font-smoothing: grayscale;
331
- ${z(t)}
338
+ ${z$1(t)}
332
339
 
333
340
  /* Identity modal \u2014 theme-aware backdrop + panel */
334
341
  --sp-identity-bg: ${t.glassBgHeavy};
@@ -1486,14 +1493,14 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
1486
1493
  }
1487
1494
  }
1488
1495
 
1489
- ${Ht}
1496
+ ${Bt}
1490
1497
  ${U$1}
1491
1498
  ${T}
1492
1499
  ${L}
1493
- ${J}
1500
+ ${J$1}
1494
1501
  ${Y$1}
1495
1502
  ${N}
1496
- `}var Cn=120,An=80,me=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=b("div",{style:`
1503
+ `}var Mn=120,Pn=80,fe=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=b("div",{style:`
1497
1504
  position: fixed;
1498
1505
  z-index: ${2147483647};
1499
1506
  max-width: 280px;
@@ -1519,12 +1526,12 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
1519
1526
  border: 1px solid ${this.colors.glassBorder};
1520
1527
  transform: rotate(45deg);
1521
1528
  pointer-events: none;
1522
- `}),this.root.appendChild(this.arrow),this.root.addEventListener("mouseenter",()=>this.cancelHide()),this.root.addEventListener("mouseleave",()=>this.scheduleHide()),document.body.appendChild(this.root);}colors;locale;root;arrow;showTimer=null;hideTimer=null;currentFeedbackId=null;tooltipId="sp-tooltip";show(e,n){this.currentFeedbackId!==e.id&&(this.cancelHide(),this.cancelShow(),this.showTimer=setTimeout(()=>{this.currentFeedbackId=e.id,this.render(e),this.position(n);let i=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=i?"none":"",this.root.style.visibility="visible",this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)";},Cn));}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),An);}hide(){this.cancelShow(),this.currentFeedbackId=null,this.root.style.opacity="0",this.root.style.transform="translateY(6px) scale(0.97)",setTimeout(()=>{this.currentFeedbackId||(this.root.style.visibility="hidden");},200);}cancelShow(){this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null);}cancelHide(){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null);}render(e$1){let n=Array.from(this.root.children);for(let d of n)d!==this.arrow&&d.remove();let i=x(e$1.type,this.colors),o=y(e$1.type,this.colors),s=H(this.locale),r=I(e$1.type,s),p=b("div",{style:"display:flex;align-items:center;gap:8px;margin-bottom:8px;"}),a=b("span",{style:`
1529
+ `}),this.root.appendChild(this.arrow),this.root.addEventListener("mouseenter",()=>this.cancelHide()),this.root.addEventListener("mouseleave",()=>this.scheduleHide()),document.body.appendChild(this.root);}colors;locale;root;arrow;showTimer=null;hideTimer=null;currentFeedbackId=null;tooltipId="sp-tooltip";show(e,n){this.currentFeedbackId!==e.id&&(this.cancelHide(),this.cancelShow(),this.showTimer=setTimeout(()=>{this.currentFeedbackId=e.id,this.render(e),this.position(n);let i=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=i?"none":"",this.root.style.visibility="visible",this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)";},Mn));}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),Pn);}hide(){this.cancelShow(),this.currentFeedbackId=null,this.root.style.opacity="0",this.root.style.transform="translateY(6px) scale(0.97)",setTimeout(()=>{this.currentFeedbackId||(this.root.style.visibility="hidden");},200);}cancelShow(){this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null);}cancelHide(){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null);}render(e$1){let n=Array.from(this.root.children);for(let p of n)p!==this.arrow&&p.remove();let i=x(e$1.type,this.colors),o=y(e$1.type,this.colors),s=H$1(this.locale),r=I(e$1.type,s),a=b("div",{style:"display:flex;align-items:center;gap:8px;margin-bottom:8px;"}),l=b("span",{style:`
1523
1530
  padding:3px 10px;border-radius:9999px;
1524
1531
  font-size:11px;font-weight:600;
1525
1532
  color:${i};background:${o};
1526
1533
  letter-spacing:0.02em;
1527
- `});c(a,r);let c$1=b("span",{style:`font-size:11px;color:${this.colors.textSecondary};margin-left:auto;`});c(c$1,e(e$1.createdAt,this.locale)),p.appendChild(a),p.appendChild(c$1);let l=b("div",{style:`font-size:13px;line-height:1.55;color:${this.colors.text};display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;`});c(l,e$1.message),this.root.insertBefore(p,this.arrow),this.root.insertBefore(l,this.arrow);}position(e){let n=this.root.getBoundingClientRect(),i=10,o=e.top-n.height-i,s=e.left+e.width/2-n.width/2,r=true;o<8&&(o=e.bottom+i,r=false),s=Math.max(8,Math.min(s,window.innerWidth-n.width-8)),this.root.style.top=`${o}px`,this.root.style.left=`${s}px`;let p=Math.max(16,Math.min(e.left+e.width/2-s-6,n.width-22));r?this.arrow.style.cssText=`
1534
+ `});c(l,r);let c$1=b("span",{style:`font-size:11px;color:${this.colors.textSecondary};margin-left:auto;`});c(c$1,e(e$1.createdAt,this.locale)),a.appendChild(l),a.appendChild(c$1);let d=b("div",{style:`font-size:13px;line-height:1.55;color:${this.colors.text};display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;`});c(d,e$1.message),this.root.insertBefore(a,this.arrow),this.root.insertBefore(d,this.arrow);}position(e){let n=this.root.getBoundingClientRect(),i=10,o=e.top-n.height-i,s=e.left+e.width/2-n.width/2,r=true;o<8&&(o=e.bottom+i,r=false),s=Math.max(8,Math.min(s,window.innerWidth-n.width-8)),this.root.style.top=`${o}px`,this.root.style.left=`${s}px`;let a=Math.max(16,Math.min(e.left+e.width/2-s-6,n.width-22));r?this.arrow.style.cssText=`
1528
1535
  position:absolute;
1529
1536
  width:12px;height:12px;
1530
1537
  background:${this.colors.glassBgHeavy};
@@ -1533,7 +1540,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
1533
1540
  transform:rotate(45deg);
1534
1541
  pointer-events:none;
1535
1542
  bottom:-6px;
1536
- left:${p}px;
1543
+ left:${a}px;
1537
1544
  `:this.arrow.style.cssText=`
1538
1545
  position:absolute;
1539
1546
  width:12px;height:12px;
@@ -1543,8 +1550,8 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
1543
1550
  transform:rotate(45deg);
1544
1551
  pointer-events:none;
1545
1552
  top:-6px;
1546
- left:${p}px;
1547
- `;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var G=null;function Ln(t){return t===void 0||t===false?{console:false,network:false,maxConsoleEntries:50,maxNetworkEntries:20}:t===true?{console:true,network:true,maxConsoleEntries:50,maxNetworkEntries:20}:{console:t.console!==false,network:t.network!==false,maxConsoleEntries:typeof t.maxConsoleEntries=="number"?t.maxConsoleEntries:50,maxNetworkEntries:typeof t.maxNetworkEntries=="number"?t.maxNetworkEntries:20}}function ge(){let t=()=>{};return {destroy:t,open:t,close:t,refresh:t,focusFeedback:()=>false,on:()=>t,off:t}}function Mn(t){return t===void 0||t===false?{enabled:false,param:"siteping"}:t===true?{enabled:true,param:"siteping"}:{enabled:true,param:t.param??"siteping"}}function Ot(t){let e=t.debug?(...u)=>console.debug("[siteping]",...u):()=>{};if(G)return e("initSiteping() called more than once \u2014 returning existing instance"),G;if(!t.forceShow)try{if(typeof process<"u")return t.onSkip?.("production"),ge()}catch{}if(window.innerWidth<768){let u="mobile";return t.onSkip?.(u),ge()}if(!t.store&&(!t.endpoint||typeof t.endpoint!="string"))return console.error("[siteping] Missing 'endpoint' or 'store' in config. Provide an endpoint like '/api/siteping' or a SitepingStore instance."),ge();if(!t.projectName||typeof t.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),ge();let n=t.locale??"en";n!=="en"&&G$1(n).catch(()=>{});let i=H(n),o=t.scopeAnnotationsByUrl??true,s=()=>{try{let u=t.getPageScope?.();if(u)return u}catch(u){e("getPageScope() threw, falling back to pathname:",u);}return {url:window.location.pathname,urlPattern:null}};e("Initializing widget",{projectName:t.projectName,theme:t.theme??"light",locale:n,scopeAnnotationsByUrl:o});let r=Ln(t.captureDiagnostics),p=r.console?new ae(r.maxConsoleEntries):null,a=r.network?new le(r.maxNetworkEntries):null,c=w(t.accentColor,t.theme),l=new q,d=new q,h=(()=>{if(t.store)return new fe(t.store,t.projectName);let u=t.endpoint;if(typeof u!="string"||u.length===0)throw new Error("[siteping] internal invariant: endpoint must be a non-empty string in HTTP mode");return new re(u,t.projectName)})();t.onOpen&&l.on("open",t.onOpen),t.onClose&&l.on("close",t.onClose),t.onFeedbackSent&&l.on("feedback:sent",t.onFeedbackSent),t.onError&&l.on("feedback:error",t.onError),t.onAnnotationStart&&l.on("annotation:start",t.onAnnotationStart),t.onAnnotationEnd&&l.on("annotation:end",t.onAnnotationEnd),l.on("feedback:sent",u=>d.emit("feedback:sent",u)),l.on("feedback:deleted",u=>d.emit("feedback:deleted",u)),l.on("open",()=>d.emit("panel:open")),l.on("close",()=>d.emit("panel:close")),l.on("open",()=>e("Panel opened")),l.on("close",()=>e("Panel closed")),l.on("feedback:sent",u=>e("Feedback sent",u.id)),l.on("feedback:error",u=>e("Feedback failed",u.message)),l.on("annotation:start",()=>e("Annotation started")),l.on("annotation:end",()=>e("Annotation ended"));let f=document.createElement("siteping-widget");f.style.cssText=`position:fixed;z-index:${2147483647};`;let x=false;try{typeof process<"u"&&process.env?.["NODE_ENV"]==="test"&&(x=!0);}catch{}let I=x?"open":"closed",S=f.attachShadow({mode:I});if("adoptedStyleSheets"in ShadowRoot.prototype){let u=new CSSStyleSheet;u.replaceSync($e(c)),S.adoptedStyleSheets=[u];}else {let u=document.createElement("style");u.textContent=$e(c),S.appendChild(u);}document.body.appendChild(f);let k=document.createElement("div");k.setAttribute("role","status"),k.setAttribute("aria-live","polite"),k.setAttribute("aria-atomic","true"),k.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",document.body.appendChild(k);let O=new me(c,n),b=new he(c,O,l,i,k),T=new pe(S,t,l,i),g=null,L=null,C=false;async function M(){return C?null:g||(L||(L=import('./panel-47WTS3KH.js').then(u=>C?null:(g=new u.Panel(S,c,l,h,t.projectName,b,i,n,{getScope:s,scopeAnnotationsByUrl:o}),g))),L)}if(typeof window<"u"){let u=()=>{C||M();},y=window.requestIdleCallback;typeof y=="function"?y(u):setTimeout(u,200);}let N=false,zt=l.on("panel:toggle",u=>{g||(u?(N=true,M().then(y=>{y&&N&&y.open(),N=false;}).catch(y=>e("Failed to lazy-load panel:",y))):N=false);}),jt=new oe(c,l,i,t.enableScreenshot??false),be=false,Xt=l.on("annotation:complete",async u=>{if(!be){be=true;try{let{annotation:y,type:w,message:B,screenshotDataUrl:ve}=u,D=t.identity??Fe();if(!D){if(D=await Fn(S,i),!D)return;Pt(D);}let Ut=(()=>{try{return crypto.randomUUID()}catch{return `${Date.now()}-${Math.random().toString(36).slice(2)}`}})(),xe=s(),Be=null;(p||a)&&(Be={console:p?.getEntries()??[],network:a?.getEntries()??[]});let Yt={projectName:t.projectName,type:w,message:B,url:xe.url,urlPattern:xe.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:D.name,authorEmail:D.email,annotations:[y],clientId:Ut,screenshotDataUrl:ve??null,diagnostics:Be};try{let F=await h.sendFeedback(Yt);l.emit("feedback:sent",F),(!o||F.url===xe.url)&&b.addFeedback(F,b.count+1),k.textContent=i("feedback.sent.confirmation"),g&&await g.refresh();}catch(F){l.emit("feedback:error",F instanceof Error?F:new Error(String(F))),k.textContent=i("feedback.error.message");}}finally{be=false;}}}),Oe=s(),Kt=o?{limit:20,url:Oe.url}:{limit:20},ye=Mn(t.deepLink);return h.getFeedbacks(t.projectName,Kt).then(({feedbacks:u})=>{let y=o?u.filter(w=>w.url===Oe.url):u;if(b.render(y),ye.enabled)try{let w=new URLSearchParams(window.location.search).get(ye.param);if(w){let B=b.focusFeedback(w);e(`deepLink ?${ye.param}=${w} ${B?"focused":"did not match a visible feedback"}`);}}catch(w){e("deepLink parsing failed:",w);}}).catch(u=>{e("Failed to load initial markers:",u);}),t.endpoint&&Rt(t.endpoint,t.identity??Fe()).then(()=>e("Retry queue flushed")).catch(()=>{}),G={destroy:()=>{e("Destroying widget"),C=true,N=false,Xt(),zt(),T.destroy(),g?.destroy(),jt.destroy(),b.destroy(),O.destroy(),p?.dispose(),a?.dispose(),l.removeAll(),d.removeAll(),k.remove(),f.remove(),G=null;},open:()=>{l.emit("panel:toggle",true);},close:()=>{g?g.close():N=false;},focusFeedback:u=>b.focusFeedback(u),refresh:()=>{if(g?.isCurrentlyOpen){g.refresh();return}let u=s(),y=o?{limit:20,url:u.url}:{limit:20};h.getFeedbacks(t.projectName,y).then(({feedbacks:w})=>{let B=o?w.filter(ve=>ve.url===u.url):w;b.render(B);}).catch(()=>{});},on:(u,y)=>d.on(u,y),off:(u,y)=>{d.off(u,y);}},G}function Fn(t,e){return new Promise(n=>{let i=t.activeElement??document.activeElement,o=document.createElement("div");o.style.cssText=`
1553
+ left:${a}px;
1554
+ `;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var W=null;function In(t){return t===void 0||t===false?{console:false,network:false,maxConsoleEntries:50,maxNetworkEntries:20}:t===true?{console:true,network:true,maxConsoleEntries:50,maxNetworkEntries:20}:{console:t.console!==false,network:t.network!==false,maxConsoleEntries:typeof t.maxConsoleEntries=="number"?t.maxConsoleEntries:50,maxNetworkEntries:typeof t.maxNetworkEntries=="number"?t.maxNetworkEntries:20}}function me(){let t=()=>{};return {destroy:t,open:t,close:t,refresh:t,focusFeedback:()=>false,on:()=>t,off:t}}function Dn(t){return t===void 0||t===false?{enabled:false,param:"siteping"}:t===true?{enabled:true,param:"siteping"}:{enabled:true,param:t.param??"siteping"}}function zt(t){let e=t.debug?(...u)=>console.debug("[siteping]",...u):()=>{};if(W)return e("initSiteping() called more than once \u2014 returning existing instance"),W;if(!t.forceShow)try{if(typeof process<"u")return t.onSkip?.("production"),me()}catch{}if(window.innerWidth<768){let u="mobile";return t.onSkip?.(u),me()}if(!t.store&&(!t.endpoint||typeof t.endpoint!="string"))return console.error("[siteping] Missing 'endpoint' or 'store' in config. Provide an endpoint like '/api/siteping' or a SitepingStore instance."),me();if(!t.projectName||typeof t.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),me();let n=t.locale??"en",i=n==="en"?Promise.resolve():G(n).catch(()=>{}),o=H$1(n),s=t.scopeAnnotationsByUrl??true,r=()=>{try{let u=t.getPageScope?.();if(u)return u}catch(u){e("getPageScope() threw, falling back to pathname:",u);}return {url:window.location.pathname,urlPattern:null}};e("Initializing widget",{projectName:t.projectName,theme:t.theme??"light",locale:n,scopeAnnotationsByUrl:s});let a=In(t.captureDiagnostics),l=a.console?new re(a.maxConsoleEntries):null,c=a.network?new ae(a.maxNetworkEntries):null,d=w(t.accentColor,t.theme),p=new Y,h=new Y,m=(()=>{if(t.store)return new he(t.store,t.projectName);let u=t.endpoint;if(typeof u!="string"||u.length===0)throw new Error("[siteping] internal invariant: endpoint must be a non-empty string in HTTP mode");return new se(u,t.projectName)})();t.onOpen&&p.on("open",t.onOpen),t.onClose&&p.on("close",t.onClose),t.onFeedbackSent&&p.on("feedback:sent",t.onFeedbackSent),t.onError&&p.on("feedback:error",t.onError),t.onAnnotationStart&&p.on("annotation:start",t.onAnnotationStart),t.onAnnotationEnd&&p.on("annotation:end",t.onAnnotationEnd),p.on("feedback:sent",u=>h.emit("feedback:sent",u)),p.on("feedback:deleted",u=>h.emit("feedback:deleted",u)),p.on("open",()=>h.emit("panel:open")),p.on("close",()=>h.emit("panel:close")),p.on("open",()=>e("Panel opened")),p.on("close",()=>e("Panel closed")),p.on("feedback:sent",u=>e("Feedback sent",u.id)),p.on("feedback:error",u=>e("Feedback failed",u.message)),p.on("annotation:start",()=>e("Annotation started")),p.on("annotation:end",()=>e("Annotation ended"));let x=document.createElement("siteping-widget");x.style.cssText=`position:fixed;z-index:${2147483647};`;let M=false;try{typeof process<"u"&&process.env?.["NODE_ENV"]==="test"&&(M=!0);}catch{}let D=M?"open":"closed",C=x.attachShadow({mode:D});if("adoptedStyleSheets"in ShadowRoot.prototype){let u=new CSSStyleSheet;u.replaceSync(_e(d)),C.adoptedStyleSheets=[u];}else {let u=document.createElement("style");u.textContent=_e(d),C.appendChild(u);}document.body.appendChild(x);let w$1=document.createElement("div");w$1.setAttribute("role","status"),w$1.setAttribute("aria-live","polite"),w$1.setAttribute("aria-atomic","true"),w$1.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",document.body.appendChild(w$1);let S=new fe(d,n),b=new ue(d,S,p,o,w$1),A=new le(C,t,p,o);p.on("markers:changed",u=>A.updateBadge(u));let v=null,P=null,T=false;async function Oe(){return T?null:v||(P||(P=import('./panel-47WTS3KH.js').then(u=>T?null:(v=new u.Panel(C,d,p,m,t.projectName,b,o,n,{getScope:r,scopeAnnotationsByUrl:s}),v))),P)}if(typeof window<"u"){let u=()=>{T||Oe();},y=window.requestIdleCallback;typeof y=="function"?y(u):setTimeout(u,200);}let N=false,Xt=p.on("panel:toggle",u=>{v||(u?(N=true,Oe().then(y=>{y&&N&&y.open(),N=false;}).catch(y=>e("Failed to lazy-load panel:",y))):N=false);}),Be=new ie(d,p,o,t.enableScreenshot??false);n!=="en"&&i.then(()=>{T||(A.refreshLabels(),Be.refreshLabels());});let be=false,Kt=p.on("annotation:complete",async u=>{if(be){p.emit("submission:cancelled");return}be=true;try{let{annotation:y,type:E,message:O,screenshotDataUrl:ye}=u,_=t.identity??Me();if(!_){if(_=await Nn(C,o),!_){p.emit("submission:cancelled");return}Dt(_);}let Yt=(()=>{try{return crypto.randomUUID()}catch{return `${Date.now()}-${Math.random().toString(36).slice(2)}`}})(),ve=r(),je=null;(l||c)&&(je={console:l?.getEntries()??[],network:c?.getEntries()??[]});let Ut={projectName:t.projectName,type:E,message:O,url:ve.url,urlPattern:ve.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:_.name,authorEmail:_.email,annotations:[y],clientId:Yt,screenshotDataUrl:ye??null,diagnostics:je};try{let F=await m.sendFeedback(Ut);p.emit("feedback:sent",F),(!s||F.url===ve.url)&&b.addFeedback(F,b.count+1),w$1.textContent=o("feedback.sent.confirmation"),v&&await v.refresh();}catch(F){p.emit("feedback:error",F instanceof Error?F:new Error(String(F))),w$1.textContent=o("feedback.error.message");}}finally{be=false;}}),ze=r(),qt=s?{limit:20,url:ze.url}:{limit:20},ge=Dn(t.deepLink);return Promise.all([m.getFeedbacks(t.projectName,qt),i]).then(([{feedbacks:u}])=>{if(T)return;let y=s?u.filter(E=>E.url===ze.url):u;if(b.render(y),ge.enabled)try{let E=new URLSearchParams(window.location.search).get(ge.param);if(E){let O=b.focusFeedback(E);e(`deepLink ?${ge.param}=${E} ${O?"focused":"did not match a visible feedback"}`);}}catch(E){e("deepLink parsing failed:",E);}}).catch(u=>{e("Failed to load initial markers:",u);}),t.endpoint&&Mt(t.endpoint,t.identity??Me()).then(()=>e("Retry queue flushed")).catch(()=>{}),W={destroy:()=>{e("Destroying widget"),T=true,N=false,Kt(),Xt(),A.destroy(),v?.destroy(),Be.destroy(),b.destroy(),S.destroy(),l?.dispose(),c?.dispose(),p.removeAll(),h.removeAll(),w$1.remove(),x.remove(),W=null;},open:()=>{p.emit("panel:toggle",true);},close:()=>{v?v.close():N=false;},focusFeedback:u=>b.focusFeedback(u),refresh:()=>{if(v?.isCurrentlyOpen){v.refresh();return}let u=r(),y=s?{limit:20,url:u.url}:{limit:20};m.getFeedbacks(t.projectName,y).then(({feedbacks:E})=>{let O=s?E.filter(ye=>ye.url===u.url):E;b.render(O);}).catch(()=>{});},on:(u,y)=>h.on(u,y),off:(u,y)=>{h.off(u,y);}},W}function Nn(t,e){return new Promise(n=>{let i=t.activeElement??document.activeElement,o=document.createElement("div");o.style.cssText=`
1548
1555
  position:fixed;inset:0;
1549
1556
  background:var(--sp-identity-overlay);
1550
1557
  backdrop-filter:blur(8px);
@@ -1564,5 +1571,5 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
1564
1571
  transform:translateY(12px) scale(0.97);
1565
1572
  transition:transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
1566
1573
  -webkit-font-smoothing:antialiased;
1567
- `;let r=`sp-identity-title-${Date.now()}`;s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("aria-labelledby",r);let p=document.createElement("div");p.className="sp-identity-title",p.id=r,p.textContent=e("identity.title"),p.style.marginBottom="20px";let a=`sp-identity-name-${Date.now()}`,c=`sp-identity-email-${Date.now()}`,l=document.createElement("label");l.className="sp-input-label",l.textContent=e("identity.nameLabel"),l.setAttribute("for",a);let d=document.createElement("input");d.className="sp-input",d.id=a,d.type="text",d.placeholder=e("identity.namePlaceholder"),d.style.marginBottom="14px";let h=document.createElement("label");h.className="sp-input-label",h.textContent=e("identity.emailLabel"),h.setAttribute("for",c);let f=document.createElement("input");f.className="sp-input",f.id=c,f.type="email",f.placeholder=e("identity.emailPlaceholder");let x=document.createElement("div");x.style.cssText="display:flex;gap:8px;justify-content:flex-end;margin-top:20px;";let I=b=>{o.removeEventListener("keydown",O),o.style.opacity="0",s.style.transform="translateY(12px) scale(0.97)",setTimeout(()=>{o.remove(),i?.focus(),n(b);},250);},S=document.createElement("button");S.className="sp-btn-ghost",S.textContent=e("identity.cancel"),S.addEventListener("click",()=>I(null));let H=document.createElement("button");H.className="sp-btn-primary",H.textContent=e("identity.submit"),H.addEventListener("click",()=>{let b=d.value.trim(),T=f.value.trim();if(!b||!T)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(T)){f.style.borderColor="var(--sp-type-bug, #ef4444)";return}I({name:b,email:T});});let k='input, button, [tabindex]:not([tabindex="-1"])',O=b=>{let T=b;if(T.key==="Escape"){I(null);return}if(T.key==="Tab"){let g=Array.from(s.querySelectorAll(k));if(g.length===0)return;let L=g[0],C=g[g.length-1];if(!L||!C)return;let M=t.activeElement;T.shiftKey?(M===L||!s.contains(M))&&(T.preventDefault(),C.focus()):(M===C||!s.contains(M))&&(T.preventDefault(),L.focus());}};o.addEventListener("keydown",O),o.addEventListener("click",b=>{b.target===o&&I(null);}),x.appendChild(S),x.appendChild(H),s.appendChild(p),s.appendChild(l),s.appendChild(d),s.appendChild(h),s.appendChild(f),s.appendChild(x),o.appendChild(s),t.appendChild(o),requestAnimationFrame(()=>{o.style.opacity="1",s.style.transform="translateY(0) scale(1)",d.focus();});})}function Bt(t){return Ot(t)}function to(t){let e=useRef(t);e.current=t;let[n,i]=useState(null);return useEffect(()=>{let o=true,s=Bt(e.current);if(!o){s.destroy();return}let r=s.on("feedback:sent",c=>{e.current.onFeedbackSent?.(c);}),p=s.on("panel:open",()=>{e.current.onOpen?.();}),a=s.on("panel:close",()=>{e.current.onClose?.();});return i(s),()=>{o=false,r(),p(),a(),s.destroy(),i(null);}},[]),n}export{to as useSiteping};//# sourceMappingURL=react.js.map
1574
+ `;let r=`sp-identity-title-${Date.now()}`;s.setAttribute("role","dialog"),s.setAttribute("aria-modal","true"),s.setAttribute("aria-labelledby",r);let a=document.createElement("div");a.className="sp-identity-title",a.id=r,a.textContent=e("identity.title"),a.style.marginBottom="20px";let l=`sp-identity-name-${Date.now()}`,c=`sp-identity-email-${Date.now()}`,d=document.createElement("label");d.className="sp-input-label",d.textContent=e("identity.nameLabel"),d.setAttribute("for",l);let p=document.createElement("input");p.className="sp-input",p.id=l,p.type="text",p.placeholder=e("identity.namePlaceholder"),p.style.marginBottom="14px";let h=document.createElement("label");h.className="sp-input-label",h.textContent=e("identity.emailLabel"),h.setAttribute("for",c);let m=document.createElement("input");m.className="sp-input",m.id=c,m.type="email",m.placeholder=e("identity.emailPlaceholder");let x=document.createElement("div");x.style.cssText="display:flex;gap:8px;justify-content:flex-end;margin-top:20px;";let M=S=>{o.removeEventListener("keydown",w),o.style.opacity="0",s.style.transform="translateY(12px) scale(0.97)",setTimeout(()=>{o.remove(),i?.focus(),n(S);},250);},D=document.createElement("button");D.className="sp-btn-ghost",D.textContent=e("identity.cancel"),D.addEventListener("click",()=>M(null));let C=document.createElement("button");C.className="sp-btn-primary",C.textContent=e("identity.submit"),C.addEventListener("click",()=>{let S=p.value.trim(),b=m.value.trim();if(!S||!b)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b)){m.style.borderColor="var(--sp-type-bug, #ef4444)";return}M({name:S,email:b});});let $e='input, button, [tabindex]:not([tabindex="-1"])',w=S=>{let b=S;if(b.key==="Escape"){M(null);return}if(b.key==="Tab"){let A=Array.from(s.querySelectorAll($e));if(A.length===0)return;let v=A[0],P=A[A.length-1];if(!v||!P)return;let T=t.activeElement;b.shiftKey?(T===v||!s.contains(T))&&(b.preventDefault(),P.focus()):(T===P||!s.contains(T))&&(b.preventDefault(),v.focus());}};o.addEventListener("keydown",w),o.addEventListener("click",S=>{S.target===o&&M(null);}),x.appendChild(D),x.appendChild(C),s.appendChild(a),s.appendChild(d),s.appendChild(p),s.appendChild(h),s.appendChild(m),s.appendChild(x),o.appendChild(s),t.appendChild(o),requestAnimationFrame(()=>{o.style.opacity="1",s.style.transform="translateY(0) scale(1)",p.focus();});})}function jt(t){return zt(t)}function so(t){let e=useRef(t);e.current=t;let[n,i]=useState(null);return useEffect(()=>{let o=true,s=jt(e.current);if(!o){s.destroy();return}let r=s.on("feedback:sent",c=>{e.current.onFeedbackSent?.(c);}),a=s.on("panel:open",()=>{e.current.onOpen?.();}),l=s.on("panel:close",()=>{e.current.onClose?.();});return i(s),()=>{o=false,r(),a(),l(),s.destroy(),i(null);}},[]),n}export{so as useSiteping};//# sourceMappingURL=react.js.map
1568
1575
  //# sourceMappingURL=react.js.map