@siteping/widget 0.9.9 → 0.9.11

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 {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p,q as q$1}from'./chunk-OTJZRTBK.js';import {useRef,useState,useEffect}from'react';var w,Pe,at;function lt(t,e){if(at=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:i=>true,className:i=>true,tagName:i=>true,attr:(i,r)=>false,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};w={...n,...e},Pe=jt(w.root,n);let o=ne(t,"all",()=>ne(t,"two",()=>ne(t,"one",()=>ne(t,"none"))));if(o){let i=dt(ut(o,t));return i.length>0&&(o=i[0]),re(o)}else throw new Error("Selector was not found.")}function jt(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function ne(t,e,n){let o=null,i=[],r=t,s=0;for(;r;){let a=new Date().getTime()-at.getTime();if(w.timeoutMs!==void 0&&a>w.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${a}ms`);let l=ie(zt(r))||ie(...Kt(r))||ie(...Xt(r))||ie(Ut(r))||[st()],p=Yt(r);if(e=="all")p&&(l=l.concat(l.filter(Ae).map(c=>oe(c,p))));else if(e=="two")l=l.slice(0,1),p&&(l=l.concat(l.filter(Ae).map(c=>oe(c,p))));else if(e=="one"){let[c]=l=l.slice(0,1);p&&Ae(c)&&(l=[oe(c,p)]);}else e=="none"&&(l=[st()],p&&(l=[oe(l[0],p)]));for(let c of l)c.level=s;if(i.push(l),i.length>=w.seedMinLength&&(o=it(i,n),o))break;r=r.parentElement,s++;}return o||(o=it(i,n)),!o&&n?n():o}function it(t,e){let n=dt(pt(t));if(n.length>w.threshold)return e?e():null;for(let o of n)if(ct(o))return o;return null}function re(t){let e=t[0],n=e.name;for(let o=1;o<t.length;o++){let i=t[o].level||0;e.level===i-1?n=`${t[o].name} > ${n}`:n=`${t[o].name} ${n}`,e=t[o];}return n}function rt(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function ct(t){let e=re(t);switch(Pe.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 zt(t){let e=t.getAttribute("id");return e&&w.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null}function Kt(t){return Array.from(t.attributes).filter(n=>w.attr(n.name,n.value)).map(n=>({name:`[${CSS.escape(n.name)}="${CSS.escape(n.value)}"]`,penalty:.5}))}function Xt(t){return Array.from(t.classList).filter(w.className).map(n=>({name:"."+CSS.escape(n),penalty:1}))}function Ut(t){let e=t.tagName.toLowerCase();return w.tagName(e)?{name:e,penalty:2}:null}function st(){return {name:"*",penalty:3}}function Yt(t){let e=t.parentNode;if(!e)return null;let n=e.firstChild;if(!n)return null;let o=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&o++,n!==t);)n=n.nextSibling;return o}function oe(t,e){return {name:t.name+`:nth-child(${e})`,penalty:t.penalty+1}}function Ae(t){return t.name!=="html"&&!t.name.startsWith("#")}function ie(...t){let e=t.filter(Wt);return e.length>0?e:null}function Wt(t){return t!=null}function*pt(t,e=[]){if(t.length>0)for(let n of t[0])yield*pt(t.slice(1,t.length),e.concat(n));else yield e;}function dt(t){return [...t].sort((e,n)=>rt(e)-rt(n))}function*ut(t,e,n={counter:0,visited:new Map}){if(t.length>2&&t.length>w.optimizedMinLength)for(let o=1;o<t.length-1;o++){if(n.counter>w.maxNumberOfTries)return;n.counter+=1;let i=[...t];i.splice(o,1);let r=re(i);if(n.visited.has(r))return;ct(i)&&qt(i,e)&&(yield i,n.visited.set(r,true),yield*ut(i,e,n));}}function qt(t,e){return Pe.querySelector(re(t))===e}var Gt=["role","aria-label","type","name","href","src","data-testid","data-id"];function Vt(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,o=t.parentElement;if(o)for(let s of o.children){if(s===t)break;s.tagName===t.tagName&&n++;}let i=[];for(let s of Gt){let a=t.getAttribute(s);a&&i.push(`${s}=${a}`);}let r=i.length>0?Vt(i.join(",")):"0";return `${e}:${n}:${r}`}function ht(t,e){let n=e.split(":");if(n.length!==3)return 0;let[o,i,r]=n,s=Number(o),a=Number(i);if(Number.isNaN(s)||Number.isNaN(a))return 0;let l=Re(t),[p,c,d]=l.split(":"),h=0,f=Math.abs(Number(p)-s);f===0?h+=.2:f<=2?h+=.1:f<=5&&(h+=.03);let v=Math.abs(Number(c)-a);return v===0?h+=.4:v===1?h+=.2:v<=3&&(h+=.08),d===r&&(h+=.4),h}function $(t,e){let n=e==="before"?"previousElementSibling":"nextElementSibling",o=t[n],i=3;for(;o&&i>0;){let r=o.textContent?.trim();if(r)return e==="before"?r.slice(-32):r.slice(0,32);o=o[n],i--;}return ""}function se(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 ft(t){if(t.id){let o=t.id.includes("'")?`concat('${t.id.replace(/'/g,`',"'",'`)}')`:`'${t.id}'`;return `//${t.localName}[@id=${o}]`}let e=[],n=t;for(;n&&n!==document.body&&e.length<6;){let o=n.localName,i=n.parentElement;if(n.id){let s=n.id.includes("'")?`concat('${n.id.replace(/'/g,`',"'",'`)}')`:`'${n.id}'`;return e.unshift(`/${o}[@id=${s}]`),"/"+e.join("")}let r=1;if(i)for(let s of i.children){if(s===n)break;s.localName===o&&r++;}e.unshift(`/${o}[${r}]`),n=i;}return "/html/body"+e.join("")}var K="data-feedback-anchor";function Fe(t){let e=lt(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=ft(t),i=(t.textContent?.trim()??"").slice(0,120),r=$(t,"before"),s=$(t,"after"),a=Re(t),l=se(t),c=t.closest(`[${K}]`)?.getAttribute(K)??null;return {cssSelector:e,xpath:n,textSnippet:i,textPrefix:r,textSuffix:s,fingerprint:a,neighborText:l,elementTag:t.tagName,elementId:t.id||void 0,anchorKey:c}}function mt(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 gt(t,e=document.documentElement){let n=t.x+t.width/2,o=t.y+t.height/2,i=document.elementFromPoint(n,o);if(!i||i===e)return document.body;let r=i;for(;r&&r!==document.body;){if(r.hasAttribute(K)&&mt(r,t))return r;r=r.parentElement;}for(r=i;r&&r!==document.body;){if(mt(r,t))return r;r=r.parentElement;}return document.body}function bt(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 ae=class{constructor(e,n$1){this.colors=e;this.t=n$1;this.root=b("div",{style:`
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:`
2
2
  position:fixed;
3
3
  z-index:${2147483647};
4
4
  width:300px;
@@ -15,7 +15,7 @@ import {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p
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 o$1=[{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}],i=b("div",{style:"display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px;"});for(let c$1 of o$1){let d=document.createElement("button");d.style.cssText=`
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=`
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 {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p
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(c$1.icon);h.setAttribute("style","width:13px;height:13px;flex-shrink:0;"),d.appendChild(h);let f=document.createElement("span");c(f,c$1.label),d.appendChild(f),d.dataset.type=c$1.type,d.setAttribute("aria-pressed","false"),d.addEventListener("click",()=>{this.selectType(c$1.type,i);}),d.addEventListener("mouseenter",()=>{if(d.dataset.type!==this.selectedType){let v=y(d.dataset.type??"",this.colors);d.style.background=v,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);}),i.appendChild(d);}this.textarea=document.createElement("textarea"),this.textarea.style.cssText=`
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=`
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 {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p
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 r=b("div",{style:`
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:`
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
- `}),s=navigator.userAgentData,a$1=s?s.platform==="macOS":navigator.platform?.includes("Mac")??/Macintosh|Mac OS X/i.test(navigator.userAgent);c(r,a$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",c=>{c.key==="Enter"&&(c.ctrlKey||c.metaKey)&&(c.preventDefault(),this.submit()),c.key==="Escape"&&this.cancel();});let l=b("div",{style:"display:flex;justify-content:flex-end;gap:8px;margin-top:12px;"}),p$1=document.createElement("button");p$1.style.cssText=`
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=`
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(p$1,this.t("popup.cancel")),p$1.addEventListener("click",()=>this.cancel()),p$1.addEventListener("mouseenter",()=>{p$1.style.borderColor=this.colors.accent,p$1.style.color=this.colors.accent;}),p$1.addEventListener("mouseleave",()=>{p$1.style.borderColor=this.colors.border,p$1.style.color=this.colors.textTertiary;}),this.submitBtn=document.createElement("button"),this.submitBtn.style.cssText=`
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=`
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,7 @@ import {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p
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()),l.appendChild(p$1),l.appendChild(this.submitBtn),this.root.appendChild(i),this.root.appendChild(this.textarea),this.root.appendChild(r),this.root.appendChild(l),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 o=220,i=300,r=e.bottom+8,s=e.left;if(r+o>window.innerHeight){let l=e.top-o-8;l>=8?r=l:r=window.innerHeight-o-8;}s+i>window.innerWidth&&(s=e.right-i),s=Math.max(8,s),r=Math.max(8,r),this.root.style.top=`${r}px`,this.root.style.left=`${s}px`,this.root.style.display="block",this.onKeydownTrap=l=>{if(l.key==="Tab"){let p=Array.from(this.root.querySelectorAll('button:not([disabled]), textarea, input, [tabindex]:not([tabindex="-1"])'));if(p.length===0)return;let c=p[0],d=p[p.length-1];if(!c||!d)return;l.shiftKey?(document.activeElement===c||!this.root.contains(document.activeElement))&&(l.preventDefault(),d.focus()):(document.activeElement===d||!this.root.contains(document.activeElement))&&(l.preventDefault(),c.focus());}},this.root.addEventListener("keydown",this.onKeydownTrap);let a=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=a?"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 o=n.querySelectorAll("button");for(let i of o){let r=i.dataset.type===e,s=x(i.dataset.type??"",this.colors),a=y(i.dataset.type??"",this.colors);i.style.background=r?a:this.colors.glassBg,i.style.borderColor=r?s+"60":this.colors.border,i.style.color=r?s:this.colors.textTertiary,i.style.fontWeight=r?"600":"500",i.setAttribute("aria-pressed",String(r));}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,yt=false;async function Jt(){if(X!==void 0)return X;try{let t=await import('html2canvas');return X=t.default??t,X}catch(t){return X=null,yt||(yt=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 xt(t,e){let n=await Jt();if(!n)return null;let o=.85,i=1200;try{let r=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(r.width<=i)return r.toDataURL("image/jpeg",o);let s=i/r.width,a=i,l=Math.round(r.height*s),p=document.createElement("canvas");p.width=a,p.height=l;let c=p.getContext("2d");return c?(c.drawImage(r,0,0,a,l),p.toDataURL("image/jpeg",o)):null}catch(r){return console.warn("[siteping] Screenshot capture failed:",r),null}}var le=class{constructor(e,n,o,i=false){this.colors=e;this.bus=n;this.t=o;this.enableScreenshot=i;this.popup=new ae(e,o),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?xt(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
+ `,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:`
57
57
  position:fixed;inset:0;
58
58
  z-index:${2147483646};
59
59
  background:rgba(15, 23, 42, 0.04);
@@ -76,14 +76,14 @@ import {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p
76
76
  background:${this.colors.accent};
77
77
  box-shadow:0 0 8px ${this.colors.accentGlow};
78
78
  animation:pulse 1.5s ease-in-out infinite;
79
- `}),n=document.createElement("style");n.textContent=["@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.4}}","@media(prefers-reduced-motion:reduce){@keyframes pulse{from,to{opacity:1}}}"].join(""),this.toolbar.appendChild(n);let o=b("span",{style:"font-weight:500;letter-spacing:-0.01em;"});c(o,this.t("annotator.instruction"));let i=document.createElement("button");i.style.cssText=`
79
+ `}),n=document.createElement("style");n.textContent=["@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.4}}","@media(prefers-reduced-motion:reduce){@keyframes pulse{from,to{opacity:1}}}"].join(""),this.toolbar.appendChild(n);let i=b("span",{style:"font-weight:500;letter-spacing:-0.01em;"});c(i,this.t("annotator.instruction"));let o=document.createElement("button");o.style.cssText=`
80
80
  height:34px;padding:0 18px;border-radius:9999px;
81
81
  border:1px solid ${this.colors.border};
82
82
  background:${this.colors.glassBg};
83
83
  color:${this.colors.textTertiary};font-family:"Inter",system-ui,-apple-system,sans-serif;
84
84
  font-size:13px;font-weight:500;cursor:pointer;
85
85
  transition:all 0.2s ease;
86
- `,c(i,this.t("annotator.cancel")),i.addEventListener("click",()=>this.deactivate()),i.addEventListener("mouseenter",()=>{i.style.borderColor=this.colors.typeBug,i.style.color=this.colors.typeBug,i.style.background=this.colors.typeBugBg;}),i.addEventListener("mouseleave",()=>{i.style.borderColor=this.colors.border,i.style.color=this.colors.textTertiary,i.style.background=this.colors.glassBg;}),this.toolbar.appendChild(e),this.toolbar.appendChild(o),this.toolbar.appendChild(i),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 o=n.getBoundingClientRect();if(o.width<=0||o.height<=0)return;let i=new DOMRect(o.x,o.y,o.width,o.height),r=await this.popup.show(i);if(!r)return;let a={anchor:Fe(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},l=await this.maybeCapture(i);this.deactivate(),this.bus.emit("annotation:complete",{annotation:a,type:r.type,message:r.message,screenshotDataUrl:l});};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:`
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:`
87
87
  position:fixed;
88
88
  border:2px solid ${this.colors.accent};
89
89
  background:${this.colors.accent}12;
@@ -91,8 +91,8 @@ import {A,B,w as w$1,O as O$1,N,F,D,S,H as H$1,z,b,x,y,C,c,e,g,h,j,i,a,f,k,n,o,p
91
91
  border-radius:8px;
92
92
  box-shadow:0 0 16px ${this.colors.accentGlow};
93
93
  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 o=Math.min(n.clientX,this.startX),i=Math.min(n.clientY,this.startY),r=Math.abs(n.clientX-this.startX),s=Math.abs(n.clientY-this.startY);this.drawingRect.style.left=`${o}px`,this.drawingRect.style.top=`${i}px`,this.drawingRect.style.width=`${r}px`,this.drawingRect.style.height=`${s}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 o=Math.min(e,this.startX),i=Math.min(n,this.startY),r=Math.abs(e-this.startX),s=Math.abs(n-this.startY);if(r<10||s<10){this.drawingRect.remove(),this.drawingRect=null;return}let a=new DOMRect(o,i,r,s),l=await this.popup.show(a);if(!l){this.drawingRect?.remove(),this.drawingRect=null;return}let p=this.buildAnnotation(a);this.drawingRect?.remove(),this.drawingRect=null;let c=await this.maybeCapture(a);this.deactivate(),this.bus.emit("annotation:complete",{annotation:p,type:l.type,message:l.message,screenshotDataUrl:c});};buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let n=gt(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let o=Fe(n),i=n.getBoundingClientRect(),r=bt(e,i);return {anchor:o,rect:r,scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio}}destroy(){this.deactivate(),this.popup.destroy();}};var T=class extends Error{code;retryable;constructor(e,n,o){super(e),this.code=n,this.retryable=o,this.name="SitepingError";}},H=class extends T{constructor(e){super(e,"NETWORK",true),this.name="SitepingNetworkError";}},U=class extends T{constructor(e){super(e,"VALIDATION",false),this.name="SitepingValidationError";}},Y=class extends T{constructor(e){super(e,"AUTH",false),this.name="SitepingAuthError";}};function Me(t){return {cssSelector:t.anchor.cssSelector,xpath:t.anchor.xpath,textSnippet:t.anchor.textSnippet,elementTag:t.anchor.elementTag,elementId:t.anchor.elementId,textPrefix:t.anchor.textPrefix,textSuffix:t.anchor.textSuffix,fingerprint:t.anchor.fingerprint,neighborText:t.anchor.neighborText,anchorKey:t.anchor.anchorKey??null,xPct:t.rect.xPct,yPct:t.rect.yPct,wPct:t.rect.wPct,hPct:t.rect.hPct,scrollX:t.scrollX,scrollY:t.scrollY,viewportW:t.viewportW,viewportH:t.viewportH,devicePixelRatio:t.devicePixelRatio}}async function W(t,e){let n=await t.text().catch(()=>"Unknown error"),o=n?`${t.status} ${n}`:`${t.status}`,i=`${e}: ${o}`;return t.status===401||t.status===403?new Y(i):t.status>=400&&t.status<500?new U(i):new T(i,"SERVER",false)}function q(t,e){if(t instanceof T&&t instanceof H)return t;let n=t instanceof Error?t.message:String(t);return new H(`${e}: ${n}`)}var Qt=3,Zt=1e4,V="siteping_retry_queue",en=20;async function G(t,e,n=Qt){for(let o=0;o<=n;o++){let i=new AbortController,r=setTimeout(()=>i.abort(),Zt);try{let l=await fetch(t,{...e,signal:i.signal});if(clearTimeout(r),l.ok||l.status>=400&&l.status<500||o===n)return l}catch(l){if(clearTimeout(r),o===n)throw l}let s=1e3*2**o,a=Math.random()*1e3-500;await new Promise(l=>setTimeout(l,s+a));}throw new Error("Max retries exceeded")}var tn="siteping_retry_queue";async function vt(t){return typeof navigator<"u"&&navigator.locks?navigator.locks.request(tn,()=>t()):t()}function nn(t,e){vt(()=>{try{let n=localStorage.getItem(V),o=n?JSON.parse(n):[],i=Array.isArray(o)?o:[];i.length>=en&&i.shift(),i.push({endpoint:t,payload:e}),localStorage.setItem(V,JSON.stringify(i));}catch{}});}async function wt(t){await vt(async()=>{try{let e=localStorage.getItem(V);if(!e)return;let n=JSON.parse(e),o=Array.isArray(n)?n:[],i=o.filter(a=>a.endpoint===t);if(i.length===0)return;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 s=o.filter(a=>a.endpoint!==t).concat(r);s.length>0?localStorage.setItem(V,JSON.stringify(s)):localStorage.removeItem(V);}catch{}});}var ce=class{constructor(e,n){this.endpoint=e;this.projectName=n;}endpoint;projectName;async sendFeedback(e){try{let n;try{n=await G(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch(o){throw q(o,"Failed to send feedback")}if(!n.ok)throw await W(n,"Failed to send feedback");return await n.json()}catch(n){throw nn(this.endpoint,e),n}}async getFeedbacks(e,n){let o=new URLSearchParams({projectName:e});n?.page&&o.set("page",String(n.page)),n?.limit&&o.set("limit",String(n.limit)),n?.type&&o.set("type",n.type),n?.status&&o.set("status",n.status),n?.search&&o.set("search",n.search),n?.url&&o.set("url",n.url),n?.urlPattern&&o.set("urlPattern",n.urlPattern);let i;try{i=await G(`${this.endpoint}?${o.toString()}`,{method:"GET",cache:"no-store"});}catch(r){throw q(r,"Failed to fetch feedbacks")}if(!i.ok)throw await W(i,"Failed to fetch feedbacks");return await i.json()}async resolveFeedback(e,n){let o;try{o=await G(this.endpoint,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName,status:n?"resolved":"open"})});}catch(i){throw q(i,"Failed to update feedback")}if(!o.ok)throw await W(o,"Failed to update feedback");return await o.json()}async deleteFeedback(e){let n;try{n=await G(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName})});}catch(o){throw q(o,"Failed to delete feedback")}if(!n.ok)throw await W(n,"Failed to delete feedback")}async deleteAllFeedbacks(e){let n;try{n=await G(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectName:e,deleteAll:!0})});}catch(o){throw q(o,"Failed to delete all feedbacks")}if(!n.ok)throw await W(n,"Failed to delete all feedbacks")}};var on=["log","info","warn","error"];function rn(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,o)=>{if(typeof o=="function")return "[Function]";if(typeof o=="symbol")return o.toString();if(typeof o=="object"&&o!==null){if(e.has(o))return "[Circular]";e.add(o);}return o})}catch{try{return String(t)}catch{return "[Unserializable]"}}}function sn(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=rn(t[n]),!(e.length>=500));n++);return e.length>500&&(e=`${e.slice(0,499)}\u2026`),e}var pe=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 on){let o=console[n];if(typeof o!="function")continue;this.originals.set(n,o);let i=this,r=function(...s){try{i.push(n,s);}catch{}o.apply(this??console,s);};try{Object.defineProperty(r,"name",{value:n});}catch{}console[n]=r;}}push(e,n){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({level:e,timestamp:new Date().toISOString(),message:sn(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 kt(t){return t.length<=2e3?t:`${t.slice(0,1999)}\u2026`}function Et(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 de=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(o,i)=>{let r=new Date,s=typeof performance<"u"?performance.now():Date.now(),a=kt(Et(o)),l=(i?.method??(o instanceof Request?o.method:"GET")).toUpperCase();try{let p=await e(o,i);if(!p.ok){let c=typeof performance<"u"?performance.now():Date.now();this.push({url:a,method:l,status:p.status,durationMs:Math.round(c-s),timestamp:r.toISOString()});}return p}catch(p){let c=typeof performance<"u"?performance.now():Date.now();throw this.push({url:a,method:l,status:0,durationMs:Math.round(c-s),timestamp:r.toISOString()}),p}};globalThis.fetch=n;}installXhr(){if(typeof XMLHttpRequest>"u")return;let e=XMLHttpRequest.prototype,n=e.open,o=e.send;this.originalXhrOpen=n,this.originalXhrSend=o;let i=this,r=new WeakMap;e.open=function(s,a,...l){try{r.set(this,{method:s.toUpperCase(),url:kt(Et(a)),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,s,a,...l)},e.send=function(s){let a=r.get(this);if(a){let l=()=>{try{let p=typeof performance<"u"?performance.now():Date.now(),c=this.status;(c===0||c>=400)&&i.push({url:a.url,method:a.method,status:c,durationMs:Math.round(p-a.t0),timestamp:a.startedAt.toISOString()});}catch{}};try{this.addEventListener("loadend",l,{once:!0});}catch{try{this.addEventListener("loadend",l);}catch{}}}return o.call(this,s??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 J=class{listeners=new Map;on(e,n){this.listeners.has(e)||this.listeners.set(e,new Set);let o=this.listeners.get(e);return o.add(n),()=>{o.delete(n);}}off(e,n){let o=this.listeners.get(e);o&&o.delete(n);}emit(e,...n){let o=this.listeners.get(e);if(o)for(let i of o)try{i(...n);}catch(r){console.error(`[siteping] Error in event listener for "${String(e)}":`,r);}}removeAll(){this.listeners.clear();}};var an=54,ue=class{constructor(e,n,o,i$1){this.bus=o;this.t=i$1;let r=n.position??"bottom-right",s=r==="bottom-right";this.items=[{id:"chat",icon:g,label:i$1("fab.messages")},{id:"annotate",icon:h,label:i$1("fab.annotate")},{id:"toggle-annotations",icon:i,iconAlt:j,label:i$1("fab.annotations")}],this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${r} sp-anim-fab-in`,this.fab.style.position="fixed",this.fab.appendChild(a(f)),this.fab.setAttribute("aria-label",i$1("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--${r}`,this.radialContainer.setAttribute("role","menu");for(let p=0;p<this.items.length;p++){let c=this.items[p];if(!c)continue;let d=document.createElement("button");d.className="sp-radial-item",d.style.setProperty("--sp-i",String(p)),d.appendChild(a(c.icon)),d.setAttribute("role","menuitem"),d.setAttribute("aria-label",c.label),d.dataset.itemId=c.id,d.addEventListener("click",f=>{f.stopPropagation(),this.handleItemClick(c.id);});let h=document.createElement("span");h.className="sp-radial-label",h.textContent=c.label,h.style.cssText=s?"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 a$1=e.host;this.onDocumentClick=p=>{this.isOpen&&!p.composedPath().includes(a$1)&&this.close();},document.addEventListener("click",this.onDocumentClick);let l=p=>{p.key==="Escape"&&this.isOpen&&(p.stopPropagation(),this.close());};this.fab.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",p=>{let c=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(c.length===0||!this.isOpen)return;let d=e.activeElement??document.activeElement,h=c.indexOf(d);switch(p.key){case "ArrowUp":{p.preventDefault();let f=h<=0?c.length-1:h-1;c[f]?.focus();break}case "ArrowDown":{p.preventDefault();let f=h>=c.length-1?0:h+1;c[f]?.focus();break}case "Home":{p.preventDefault(),c[0]?.focus();break}case "End":{p.preventDefault(),c[c.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,o)=>{let i=-(16+an*(o+1));n.style.transform=`translate(0px, ${i}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));break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove();}};var St="siteping_identity";function Tt(){try{let t=localStorage.getItem(St);if(!t)return null;let e=JSON.parse(t);if(typeof e=="object"&&e!==null&&"name"in e&&typeof e.name=="string"&&"email"in e&&typeof e.email=="string"){let n=e;if(n.name&&n.email)return n}return null}catch{return null}}function Ct(t){try{localStorage.setItem(St,JSON.stringify(t));}catch{}}function ln(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 s=t;t=e,e=s;}let n=t.length,o=e.length,i=new Array(n+1);for(let s=0;s<=n;s++)i[s]=s;let r=new Array(n+1);for(let s=1;s<=o;s++){r[0]=s;for(let l=1;l<=n;l++){let p=i[l-1]??0;r[l]=t[l-1]===e[s-1]?p:1+Math.min(p,i[l]??0,r[l-1]??0);}let a=i;i=r,r=a;}return i[n]??0}function O(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-ln(t,e)/n}function Ie(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let o=e.length;if(o>t.length){let a=O(t,e);return a>=n?a:0}let i=0,r=t.length>500?t.slice(0,500):t,s=r.length-o;for(let a=0;a<=s;a++){let l=r.slice(a,a+o),p=O(l,e);if(p>i&&(i=p),i>=.95)break}return i>=n?i:0}var cn=300,pn=.3;function he(t,e){if(!e.textSnippet)return true;let n=(t.textContent?.trim()??"").slice(0,500);return Ie(n,e.textSnippet,.5)>pn}function dn(t){if(t.anchorKey){let e=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{let n=document.querySelector(`[${K}="${e}"]`);if(n&&he(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&&he(e,t))return {element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&he(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&&he(n,t))return {element:n,confidence:.9,strategy:"xpath"}}catch{}return un(t)}function un(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let o=null,i=0,r=Math.min(n.length,cn);for(let s=0;s<r;s++){let a=n[s];if(!a)continue;let l=hn(a,t);if(l>i&&(i=l,o=a,i>=.85))break}return !o||i<.4?null:{element:o,confidence:Math.min(i,.85),strategy:"scan"}}function hn(t,e){let n=0,o=0,i=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(o+=40,n+=Ie(i,e.textSnippet,.5)*40),e.fingerprint&&(o+=20,n+=ht(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){o+=20;let r=0,s=0;if(e.textPrefix){let a=$(t,"before");r+=a?O(a,e.textPrefix):0,s++;}if(e.textSuffix){let a=$(t,"after");r+=a?O(a,e.textSuffix):0,s++;}s>0&&(n+=r/s*20);}if(e.neighborText){o+=20;let r=se(t);n+=r?O(r,e.neighborText)*20:0;}return o>0?n/o:0}function fe(t,e){let n=dn(t);if(!n)return null;let o=n.element.getBoundingClientRect(),i=new DOMRect(o.x+e.xPct*o.width,o.y+e.yPct*o.height,e.wPct*o.width,e.hPct*o.height);return {element:n.element,rect:i,confidence:n.confidence,strategy:n.strategy}}function De(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 me(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var At=13;function Pt(t){return {top:t.top+window.scrollY-At,left:t.right+window.scrollX-At}}function Q(t,e){let n=t.entries[e],o=t.elementIndices[e];if(!(!n||o===void 0))return n.elements[o]}var Rt=300,Ft=200,fn=.7,mn=28,Mt=32,ge=class{constructor(e,n,o,i,r=null){this.colors=e;this.tooltip=n;this.bus=o;this.t=i;this.liveRegion=r;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",s=>{this.container.style.display=s?"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(s=>{let a=false;for(let l of s)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=s=>{this.container.contains(s.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:Ft+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},Ft));}repositionAll(){let e=new Set;for(let n of this.entries)for(let o=0;o<n.feedback.annotations.length;o++){let i=n.elements[o];if(!i)continue;let r=n.feedback.annotations[o];if(!r)continue;let s=`${n.feedback.id}:${o}`;e.add(s);let l=this.anchorCache.get(s)?.deref(),p;if(l?.isConnected){let d=l.getBoundingClientRect(),h=me(r);p={element:l,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 p=fe(De(r),me(r)),p?.element&&this.anchorCache.set(s,new WeakRef(p.element));if(!p){i.style.display="none";continue}let c=Pt(p.rect);n.baseTop=c.top,n.baseLeft=c.left,i.style.display="flex",this.applyConfidenceStyle(i,p.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,o)=>{let i=this.buildEntry(n,o+1);this.entries.push(i);}),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 o=this.buildEntry(e,n);for(let i of o.elements)i.style.animation="sp-marker-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both";this.entries.push(o),this.buildClusters();}buildEntry(e,n){let o={feedback:e,elements:[],baseTop:0,baseLeft:0};for(let i of e.annotations){let r=fe(De(i),me(i));if(!r)continue;let s=Pt(r.rect);o.baseTop=s.top,o.baseLeft=s.left;let a=this.createMarker(n,e,s);this.applyConfidenceStyle(a,r.confidence,e),this.container.appendChild(a),o.elements.push(a);}return o}buildClusters(){for(let o of this.container.querySelectorAll(".sp-cluster-badge"))o.remove();let e=[];for(let o of this.entries)for(let i=0;i<o.elements.length;i++)e.push({entry:o,elIdx:i});let n=new Set;this.clusters=[];for(let o=0;o<e.length;o++){if(n.has(o))continue;let i=e[o];if(!i)continue;let r={entries:[i.entry],elementIndices:[i.elIdx],expanded:false};n.add(o);for(let s=o+1;s<e.length;s++){if(n.has(s))continue;let a=i.entry,l=e[s];if(!l)continue;let p=l.entry;Math.sqrt((a.baseLeft-p.baseLeft)**2+(a.baseTop-p.baseTop)**2)<mn&&(r.entries.push(p),r.elementIndices.push(l.elIdx),n.add(s));}this.clusters.push(r);}for(let o of this.clusters)o.entries.length<=1||(this.applyStackPositions(o),this.addClusterBadge(o));}applyStackPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:o,baseLeft:i}=n,r=e.entries.length<=1;for(let s=0;s<e.entries.length;s++){let a=Q(e,s);a&&(a.style.top=`${o+(r?0:s*3)}px`,a.style.left=`${i+(r?0:s*3)}px`,a.style.zIndex=String(s+1));}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:o,baseLeft:i}=n,r=e.entries.length,s=(r-1)*Mt,a=i-s/2;for(let l=0;l<r;l++){let p=Q(e,l);p&&(p.style.top=`${o}px`,p.style.left=`${a+l*Mt}px`,p.style.zIndex=String(10+l));}}addClusterBadge(e){let n=Q(e,e.entries.length-1);if(!n)return;let o=b("div",{class:"sp-cluster-badge",style:`
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:`
96
96
  position:absolute;top:-6px;right:-6px;
97
97
  min-width:16px;height:16px;padding:0 4px;
98
98
  border-radius:9999px;
@@ -103,36 +103,36 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
103
103
  pointer-events:none;
104
104
  font-family:"Inter",system-ui,-apple-system,sans-serif;
105
105
  line-height:1;
106
- `});c(o,String(e.entries.length)),n.appendChild(o);}setBadgesVisible(e,n){for(let o=0;o<e.entries.length;o++){let i=Q(e,o)?.querySelector(".sp-cluster-badge");i&&(i.style.display=n?"flex":"none");}}findCluster(e){for(let n of this.clusters)if(!(n.entries.length<=1)){for(let o=0;o<n.entries.length;o++)if(Q(n,o)===e)return n}return null}handleClusterClick(e,n){let o=this.findCluster(e);return o?o.expanded?false:(n.stopPropagation(),this.collapseAllClusters(),o.expanded=true,this.applyFanPositions(o),this.setBadgesVisible(o,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,o){let i=o.status==="resolved";n<fn&&!i?(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,o){let i=x(n.type,this.colors),r=n.status==="resolved",s=b("div",{style:`
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:`
107
107
  position:absolute;
108
- top:${o.top}px;
109
- left:${o.left}px;
108
+ top:${i.top}px;
109
+ left:${i.left}px;
110
110
  width:26px;height:26px;
111
111
  border-radius:50%;
112
- background:${r?"rgba(241,245,249,0.9)":"rgba(255,255,255,0.92)"};
113
- border:2px solid ${r?"#cbd5e1":i};
112
+ background:${s?"rgba(241,245,249,0.9)":"rgba(255,255,255,0.92)"};
113
+ border:2px solid ${s?"#cbd5e1":o};
114
114
  display:flex;align-items:center;justify-content:center;
115
115
  font-family:"Inter",system-ui,-apple-system,sans-serif;
116
116
  font-size:11px;font-weight:700;
117
- color:${r?"#94a3b8":i};
117
+ color:${s?"#94a3b8":o};
118
118
  cursor:pointer;pointer-events:auto;
119
- box-shadow:${r?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${i}25, 0 2px 6px rgba(0,0,0,0.06)`};
119
+ box-shadow:${s?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${o}25, 0 2px 6px rgba(0,0,0,0.06)`};
120
120
  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
121
  user-select:none;
122
122
  -webkit-font-smoothing:antialiased;
123
- `});s.dataset.feedbackId=n.id,s.setAttribute("tabindex","0"),s.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}",C(n.type,this.t)).replace("{message}",a);s.setAttribute("aria-label",l),s.setAttribute("aria-describedby",this.tooltip.tooltipId),c(s,r?"\u2713":String(e)),s.addEventListener("mouseenter",()=>{s.style.transform="scale(1.2)",s.style.boxShadow=r?"0 4px 16px rgba(0,0,0,0.1)":`0 4px 20px ${i}35, 0 4px 12px rgba(0,0,0,0.08)`,this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("mouseleave",()=>{s.style.transform="scale(1)",s.style.boxShadow=r?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${i}25, 0 2px 6px rgba(0,0,0,0.06)`,this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();}),s.addEventListener("focus",()=>{this.tooltip.show(n,s.getBoundingClientRect()),this.pinnedFeedback||this.showHighlight(n);}),s.addEventListener("blur",()=>{this.tooltip.scheduleHide(),this.pinnedFeedback||this.clearHighlight();});let p=c=>{c instanceof MouseEvent&&this.handleClusterClick(s,c)||(this.pinHighlight(n),this.bus.emit("panel:toggle",true),s.dispatchEvent(new CustomEvent("sp-marker-click",{detail:{feedbackId:n.id},bubbles:true})));};return s.addEventListener("click",c=>p(c)),s.addEventListener("keydown",c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),p(c));}),s}highlight(e){for(let n of this.entries)if(n.feedback.id===e)for(let o of n.elements)o.style.animation="sp-pulse-ring 0.7s ease-out",o.addEventListener("animationend",()=>{o.style.animation="";},{once:true});}showHighlight(e){this.removeHighlightElements();for(let n of e.annotations){let o=fe(De(n),me(n));if(!o)continue;let i=x(e.type,this.colors),r=o.rect,s=b("div",{style:`
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:`
124
124
  position:absolute;
125
- top:${r.top+window.scrollY}px;
126
- left:${r.left+window.scrollX}px;
127
- width:${r.width}px;height:${r.height}px;
128
- border:2px solid ${i};
129
- background:${i}0c;
125
+ top:${s.top+window.scrollY}px;
126
+ left:${s.left+window.scrollX}px;
127
+ width:${s.width}px;height:${s.height}px;
128
+ border:2px solid ${o};
129
+ background:${o}0c;
130
130
  border-radius:8px;
131
131
  pointer-events:none;z-index:-1;
132
132
  opacity:0;
133
- box-shadow:0 0 16px ${i}20;
134
- transition:opacity ${Rt}ms ease;
135
- `});this.container.appendChild(s),this.highlightElements.push(s),s.offsetHeight,s.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(),Rt);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 be=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(Me),screenshotDataUrl:e.screenshotDataUrl??null});return Le(n)}async getFeedbacks(e,n){let{feedbacks:o,total:i}=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:o.map(Le),total:i}}async resolveFeedback(e,n){let o=await this.store.updateFeedback(e,{status:n?"resolved":"open",resolvedAt:n?new Date:null});return Le(o)}async deleteFeedback(e){await this.store.deleteFeedback(e);}async deleteAllFeedbacks(e){await this.store.deleteAllFeedbacks(e);}};function Le(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(gn),screenshotUrl:t.screenshotUrl??null,diagnostics:t.diagnostics??null}}function gn(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 bn="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)",Ne="cubic-bezier(0.16, 1, 0.3, 1)",_e="cubic-bezier(0.34, 1.56, 0.64, 1)",yn="cubic-bezier(0.25, 1, 0.5, 1)",It=`
133
+ 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=`
136
136
  /* ---- Keyframes ---- */
137
137
 
138
138
  @keyframes sp-fab-in {
@@ -206,7 +206,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
206
206
  /* ---- Animation classes ---- */
207
207
 
208
208
  .sp-anim-fab-in {
209
- animation: sp-fab-in 0.5s ${bn} both;
209
+ animation: sp-fab-in 0.5s ${Tn} both;
210
210
  }
211
211
 
212
212
  .sp-anim-marker-in {
@@ -218,11 +218,11 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
218
218
  }
219
219
 
220
220
  .sp-anim-flash {
221
- animation: sp-flash-bg 0.5s ${yn};
221
+ animation: sp-flash-bg 0.5s ${Sn};
222
222
  }
223
223
 
224
224
  .sp-anim-slide-up {
225
- animation: sp-slide-up 0.3s ${Ne} both;
225
+ animation: sp-slide-up 0.3s ${De} both;
226
226
  }
227
227
 
228
228
  .sp-anim-fade-in {
@@ -233,7 +233,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
233
233
 
234
234
  .sp-panel {
235
235
  transform: translateX(110%);
236
- transition: transform 0.4s ${Ne};
236
+ transition: transform 0.4s ${De};
237
237
  }
238
238
 
239
239
  .sp-panel.sp-panel--open {
@@ -276,7 +276,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
276
276
  }
277
277
 
278
278
  .sp-card {
279
- animation: sp-card-in 0.35s ${Ne} both;
279
+ animation: sp-card-in 0.35s ${De} both;
280
280
  animation-delay: calc(var(--sp-card-i, 0) * 40ms);
281
281
  }
282
282
 
@@ -1486,14 +1486,14 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
1486
1486
  }
1487
1487
  }
1488
1488
 
1489
- ${It}
1490
- ${O$1}
1489
+ ${Ht}
1490
+ ${U$1}
1491
+ ${T}
1492
+ ${L}
1493
+ ${J}
1494
+ ${Y$1}
1491
1495
  ${N}
1492
- ${F}
1493
- ${D}
1494
- ${S}
1495
- ${H$1}
1496
- `}var xn=120,vn=80,ye=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=b("div",{style:`
1496
+ `}var Cn=120,An=80,me=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=b("div",{style:`
1497
1497
  position: fixed;
1498
1498
  z-index: ${2147483647};
1499
1499
  max-width: 280px;
@@ -1519,12 +1519,12 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
1519
1519
  border: 1px solid ${this.colors.glassBorder};
1520
1520
  transform: rotate(45deg);
1521
1521
  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 o=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=o?"none":"",this.root.style.visibility="visible",this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)";},xn));}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),vn);}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 o=x(e$1.type,this.colors),i=y(e$1.type,this.colors),r=B(this.locale),s=C(e$1.type,r),a=b("div",{style:"display:flex;align-items:center;gap:8px;margin-bottom:8px;"}),l=b("span",{style:`
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:`
1523
1523
  padding:3px 10px;border-radius:9999px;
1524
1524
  font-size:11px;font-weight:600;
1525
- color:${o};background:${i};
1525
+ color:${i};background:${o};
1526
1526
  letter-spacing:0.02em;
1527
- `});c(l,s);let p=b("span",{style:`font-size:11px;color:${this.colors.textSecondary};margin-left:auto;`});c(p,e(e$1.createdAt,this.locale)),a.appendChild(l),a.appendChild(p);let c$1=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(c$1,e$1.message),this.root.insertBefore(a,this.arrow),this.root.insertBefore(c$1,this.arrow);}position(e){let n=this.root.getBoundingClientRect(),o=10,i=e.top-n.height-o,r=e.left+e.width/2-n.width/2,s=true;i<8&&(i=e.bottom+o,s=false),r=Math.max(8,Math.min(r,window.innerWidth-n.width-8)),this.root.style.top=`${i}px`,this.root.style.left=`${r}px`;let a=Math.max(16,Math.min(e.left+e.width/2-r-6,n.width-22));s?this.arrow.style.cssText=`
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=`
1528
1528
  position:absolute;
1529
1529
  width:12px;height:12px;
1530
1530
  background:${this.colors.glassBgHeavy};
@@ -1533,7 +1533,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
1533
1533
  transform:rotate(45deg);
1534
1534
  pointer-events:none;
1535
1535
  bottom:-6px;
1536
- left:${a}px;
1536
+ left:${p}px;
1537
1537
  `:this.arrow.style.cssText=`
1538
1538
  position:absolute;
1539
1539
  width:12px;height:12px;
@@ -1543,8 +1543,8 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
1543
1543
  transform:rotate(45deg);
1544
1544
  pointer-events:none;
1545
1545
  top:-6px;
1546
- left:${a}px;
1547
- `;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var Z=null;function kn(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 xe(){let t=()=>{};return {destroy:t,open:t,close:t,refresh:t,on:()=>t,off:t}}function Dt(t){let e=t.debug?(...u)=>console.debug("[siteping]",...u):()=>{};if(Z)return e("initSiteping() called more than once \u2014 returning existing instance"),Z;if(!t.forceShow)try{if(typeof process<"u")return t.onSkip?.("production"),xe()}catch{}if(window.innerWidth<768){let u="mobile";return t.onSkip?.(u),xe()}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."),xe();if(!t.projectName||typeof t.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),xe();let n=t.locale??"en";n!=="en"&&A(n).catch(()=>{});let o=B(n),i=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:i});let s=kn(t.captureDiagnostics),a=s.console?new pe(s.maxConsoleEntries):null,l=s.network?new de(s.maxNetworkEntries):null,p=w$1(t.accentColor,t.theme),c=new J,d=new J,h=t.store?new be(t.store,t.projectName):new ce(t.endpoint,t.projectName);t.onOpen&&c.on("open",t.onOpen),t.onClose&&c.on("close",t.onClose),t.onFeedbackSent&&c.on("feedback:sent",t.onFeedbackSent),t.onError&&c.on("feedback:error",t.onError),t.onAnnotationStart&&c.on("annotation:start",t.onAnnotationStart),t.onAnnotationEnd&&c.on("annotation:end",t.onAnnotationEnd),c.on("feedback:sent",u=>d.emit("feedback:sent",u)),c.on("feedback:deleted",u=>d.emit("feedback:deleted",u)),c.on("open",()=>d.emit("panel:open")),c.on("close",()=>d.emit("panel:close")),c.on("open",()=>e("Panel opened")),c.on("close",()=>e("Panel closed")),c.on("feedback:sent",u=>e("Feedback sent",u.id)),c.on("feedback:error",u=>e("Feedback failed",u.message)),c.on("annotation:start",()=>e("Annotation started")),c.on("annotation:end",()=>e("Annotation ended"));let f=document.createElement("siteping-widget");f.style.cssText=`position:fixed;z-index:${2147483647};`;let v=false;try{typeof process<"u"&&process.env?.["NODE_ENV"]==="test"&&(v=!0);}catch{}let D=v?"open":"closed",S=f.attachShadow({mode:D});if("adoptedStyleSheets"in ShadowRoot.prototype){let u=new CSSStyleSheet;u.replaceSync($e(p)),S.adoptedStyleSheets=[u];}else {let u=document.createElement("style");u.textContent=$e(p),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 j=new ye(p,n),x=new ge(p,j,c,o,k),E=new ue(S,t,c,o),g=null,R=null,C=false;async function F(){return C?null:g||(R||(R=import('./panel-HDPPIATU.js').then(u=>C?null:(g=new u.Panel(S,p,c,h,t.projectName,x,o,n,{getScope:r,scopeAnnotationsByUrl:i}),g))),R)}if(typeof window<"u"){let u=()=>{C||F();},b=window.requestIdleCallback;typeof b=="function"?b(u):setTimeout(u,200);}let L=false,Nt=c.on("panel:toggle",u=>{g||(u?(L=true,F().then(b=>{b&&L&&b.open(),L=false;}).catch(b=>e("Failed to lazy-load panel:",b))):L=false);}),_t=new le(p,c,o,t.enableScreenshot??false),ve=false,$t=c.on("annotation:complete",async u=>{if(!ve){ve=true;try{let{annotation:b,type:N,message:we,screenshotDataUrl:ke}=u,_=t.identity??Tt();if(!_){if(_=await En(S,o),!_)return;Ct(_);}let Ot=(()=>{try{return crypto.randomUUID()}catch{return `${Date.now()}-${Math.random().toString(36).slice(2)}`}})(),Ee=r(),Be=null;(a||l)&&(Be={console:a?.getEntries()??[],network:l?.getEntries()??[]});let Bt={projectName:t.projectName,type:N,message:we,url:Ee.url,urlPattern:Ee.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:_.name,authorEmail:_.email,annotations:[b],clientId:Ot,screenshotDataUrl:ke??null,diagnostics:Be};try{let M=await h.sendFeedback(Bt);c.emit("feedback:sent",M),(!i||M.url===Ee.url)&&x.addFeedback(M,x.count+1),k.textContent=o("feedback.sent.confirmation"),g&&await g.refresh();}catch(M){c.emit("feedback:error",M instanceof Error?M:new Error(String(M))),k.textContent=o("feedback.error.message");}}finally{ve=false;}}}),Oe=r(),Ht=i?{limit:20,url:Oe.url}:{limit:20};return h.getFeedbacks(t.projectName,Ht).then(({feedbacks:u})=>{let b=i?u.filter(N=>N.url===Oe.url):u;x.render(b);}).catch(u=>{e("Failed to load initial markers:",u);}),t.endpoint&&wt(t.endpoint).then(()=>e("Retry queue flushed")).catch(()=>{}),Z={destroy:()=>{e("Destroying widget"),C=true,L=false,$t(),Nt(),E.destroy(),g?.destroy(),_t.destroy(),x.destroy(),j.destroy(),a?.dispose(),l?.dispose(),c.removeAll(),d.removeAll(),k.remove(),f.remove(),Z=null;},open:()=>{c.emit("panel:toggle",true);},close:()=>{g?g.close():L=false;},refresh:()=>{if(g?.isCurrentlyOpen){g.refresh();return}let u=r(),b=i?{limit:20,url:u.url}:{limit:20};h.getFeedbacks(t.projectName,b).then(({feedbacks:N})=>{let we=i?N.filter(ke=>ke.url===u.url):N;x.render(we);}).catch(()=>{});},on:(u,b)=>d.on(u,b),off:(u,b)=>{d.off(u,b);}},Z}function En(t,e){return new Promise(n=>{let o=t.activeElement??document.activeElement,i=document.createElement("div");i.style.cssText=`
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=`
1548
1548
  position:fixed;inset:0;
1549
1549
  background:var(--sp-identity-overlay);
1550
1550
  backdrop-filter:blur(8px);
@@ -1552,7 +1552,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
1552
1552
  display:flex;align-items:center;justify-content:center;
1553
1553
  z-index:${2147483647};
1554
1554
  opacity:0;transition:opacity 0.25s ease;
1555
- `;let r=document.createElement("div");r.style.cssText=`
1555
+ `;let s=document.createElement("div");s.style.cssText=`
1556
1556
  width:340px;padding:28px;border-radius:var(--sp-radius-xl);
1557
1557
  background:var(--sp-identity-bg);
1558
1558
  backdrop-filter:blur(var(--sp-blur-heavy));
@@ -1564,5 +1564,5 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,o)=>{if(typeof
1564
1564
  transform:translateY(12px) scale(0.97);
1565
1565
  transition:transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
1566
1566
  -webkit-font-smoothing:antialiased;
1567
- `;let s=`sp-identity-title-${Date.now()}`;r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-labelledby",s);let a=document.createElement("div");a.className="sp-identity-title",a.id=s,a.textContent=e("identity.title"),a.style.marginBottom="20px";let l=`sp-identity-name-${Date.now()}`,p=`sp-identity-email-${Date.now()}`,c=document.createElement("label");c.className="sp-input-label",c.textContent=e("identity.nameLabel"),c.setAttribute("for",l);let d=document.createElement("input");d.className="sp-input",d.id=l,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",p);let f=document.createElement("input");f.className="sp-input",f.id=p,f.type="email",f.placeholder=e("identity.emailPlaceholder");let v=document.createElement("div");v.style.cssText="display:flex;gap:8px;justify-content:flex-end;margin-top:20px;";let D=x=>{i.removeEventListener("keydown",j),i.style.opacity="0",r.style.transform="translateY(12px) scale(0.97)",setTimeout(()=>{i.remove(),o?.focus(),n(x);},250);},S=document.createElement("button");S.className="sp-btn-ghost",S.textContent=e("identity.cancel"),S.addEventListener("click",()=>D(null));let B=document.createElement("button");B.className="sp-btn-primary",B.textContent=e("identity.submit"),B.addEventListener("click",()=>{let x=d.value.trim(),E=f.value.trim();if(!x||!E)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(E)){f.style.borderColor="var(--sp-type-bug, #ef4444)";return}D({name:x,email:E});});let k='input, button, [tabindex]:not([tabindex="-1"])',j=x=>{let E=x;if(E.key==="Escape"){D(null);return}if(E.key==="Tab"){let g=Array.from(r.querySelectorAll(k));if(g.length===0)return;let R=g[0],C=g[g.length-1];if(!R||!C)return;let F=t.activeElement;E.shiftKey?(F===R||!r.contains(F))&&(E.preventDefault(),C.focus()):(F===C||!r.contains(F))&&(E.preventDefault(),R.focus());}};i.addEventListener("keydown",j),i.addEventListener("click",x=>{x.target===i&&D(null);}),v.appendChild(S),v.appendChild(B),r.appendChild(a),r.appendChild(c),r.appendChild(d),r.appendChild(h),r.appendChild(f),r.appendChild(v),i.appendChild(r),t.appendChild(i),requestAnimationFrame(()=>{i.style.opacity="1",r.style.transform="translateY(0) scale(1)",d.focus();});})}function Lt(t){return Dt(t)}function ii(t){let e=useRef(t);e.current=t;let[n,o]=useState(null);return useEffect(()=>{let i=true,r=Lt(e.current);if(!i){r.destroy();return}let s=r.on("feedback:sent",p=>{e.current.onFeedbackSent?.(p);}),a=r.on("panel:open",()=>{e.current.onOpen?.();}),l=r.on("panel:close",()=>{e.current.onClose?.();});return o(r),()=>{i=false,s(),a(),l(),r.destroy(),o(null);}},[]),n}export{ii as useSiteping};//# sourceMappingURL=react.js.map
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
1568
1568
  //# sourceMappingURL=react.js.map