@siteping/widget 0.9.16 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/{chunk-GRXZBZ42.js → chunk-GP6ZPMBW.js} +23 -11
- package/dist/chunk-GP6ZPMBW.js.map +1 -0
- package/dist/de-MXWDD2BZ.js +2 -0
- package/dist/de-MXWDD2BZ.js.map +1 -0
- package/dist/es-74ACSG45.js +2 -0
- package/dist/es-74ACSG45.js.map +1 -0
- package/dist/fr-XAQKRFFY.js +2 -0
- package/dist/fr-XAQKRFFY.js.map +1 -0
- package/dist/index.global.js +121 -98
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +79 -68
- package/dist/index.js.map +1 -1
- package/dist/it-4RBJ7CH6.js +2 -0
- package/dist/it-4RBJ7CH6.js.map +1 -0
- package/dist/panel-5ZGIFFJ4.js +2 -0
- package/dist/panel-5ZGIFFJ4.js.map +1 -0
- package/dist/pt-VNIESRZN.js +2 -0
- package/dist/pt-VNIESRZN.js.map +1 -0
- package/dist/react.js +83 -72
- package/dist/react.js.map +1 -1
- package/dist/ru-O4MZAQXF.js +2 -0
- package/dist/ru-O4MZAQXF.js.map +1 -0
- package/dist/schema.d.ts +4 -0
- package/dist/siteping-core.d.ts +2 -2
- package/dist/types.d.ts +76 -1
- package/package.json +1 -1
- package/dist/chunk-GRXZBZ42.js.map +0 -1
- package/dist/de-CO2K72R2.js +0 -2
- package/dist/de-CO2K72R2.js.map +0 -1
- package/dist/es-2QYDBGOD.js +0 -2
- package/dist/es-2QYDBGOD.js.map +0 -1
- package/dist/fr-7YJBFS2W.js +0 -2
- package/dist/fr-7YJBFS2W.js.map +0 -1
- package/dist/it-44RM76KH.js +0 -2
- package/dist/it-44RM76KH.js.map +0 -1
- package/dist/panel-4KOYCMDH.js +0 -2
- package/dist/panel-4KOYCMDH.js.map +0 -1
- package/dist/pt-DRKIF4UZ.js +0 -2
- package/dist/pt-DRKIF4UZ.js.map +0 -1
- package/dist/ru-EAKBDL3X.js +0 -2
- package/dist/ru-EAKBDL3X.js.map +0 -1
package/dist/react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {L,M,w,K,_,Z as Z$1,R,P,ca,T,B,b,x,A,N,c,e,J as J$1,u,v,h,g,a,f,i,D,F,E,C,l,m,n,o,G as G$1}from'./chunk-GP6ZPMBW.js';import {useRef,useState,useEffect}from'react';var Qt=new Set(["role","name","aria-label","rel","href"]);function en(t,e){let n=Qt.has(t);n||=t.startsWith("data-")&&W(t);let i=W(e)&&e.length<100;return i||=e.startsWith("#")&&W(e.slice(1)),n&&i}function tn(t){return W(t)}function nn(t){return W(t)}function on(t){return true}function xt(t,e){if(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:tn,className:nn,tagName:on,attr:en,timeoutMs:1e3,seedMinLength:3,optimizedMinLength:2,maxNumberOfPathChecks:1/0},i=new Date,s={...n,...e},o=cn(s.root,n),r,a=0;for(let c of sn(t,s,o)){if(new Date().getTime()-i.getTime()>s.timeoutMs||a>=s.maxNumberOfPathChecks){let h=an(t,o);if(!h)throw new Error(`Timeout: Can't find a unique selector after ${s.timeoutMs}ms`);return U(h)}if(a++,$e(c,o)){r=c;break}}if(!r)throw new Error("Selector was not found.");let l=[...kt(r,t,s,o,i)];return l.sort(Ie),l.length>0?U(l[0]):U(r)}function*sn(t,e,n){let i=[],s=[],o=t,r=0;for(;o&&o!==n;){let a=rn(o,e);for(let l of a)l.level=r;if(i.push(a),o=o.parentElement,r++,s.push(...Et(i)),r>=e.seedMinLength){s.sort(Ie);for(let l of s)yield l;s=[];}}s.sort(Ie);for(let a of s)yield a;}function W(t){if(/^[a-z\-]{3,}$/i.test(t)){let e=t.split(/-|[A-Z]/);for(let n of e)if(n.length<=2||/[^aeiou]{4,}/i.test(n))return false;return true}return false}function rn(t,e){let n=[],i=t.getAttribute("id");i&&e.idName(i)&&n.push({name:"#"+CSS.escape(i),penalty:0});for(let r=0;r<t.classList.length;r++){let a=t.classList[r];e.className(a)&&n.push({name:"."+CSS.escape(a),penalty:1});}for(let r=0;r<t.attributes.length;r++){let a=t.attributes[r];e.attr(a.name,a.value)&&n.push({name:`[${CSS.escape(a.name)}="${CSS.escape(a.value)}"]`,penalty:2});}let s=t.tagName.toLowerCase();if(e.tagName(s)){n.push({name:s,penalty:5});let r=Ne(t,s);r!==void 0&&n.push({name:wt(s,r),penalty:10});}let o=Ne(t);return o!==void 0&&n.push({name:ln(s,o),penalty:50}),n}function U(t){let e=t[0],n=e.name;for(let i=1;i<t.length;i++){let s=t[i].level||0;e.level===s-1?n=`${t[i].name} > ${n}`:n=`${t[i].name} ${n}`,e=t[i];}return n}function vt(t){return t.map(e=>e.penalty).reduce((e,n)=>e+n,0)}function Ie(t,e){return vt(t)-vt(e)}function Ne(t,e){let n=t.parentNode;if(!n)return;let i=n.firstChild;if(!i)return;let s=0;for(;i&&(i.nodeType===Node.ELEMENT_NODE&&(e===void 0||i.tagName.toLowerCase()===e)&&s++,i!==t);)i=i.nextSibling;return s}function an(t,e){let n=0,i=t,s=[];for(;i&&i!==e;){let o=i.tagName.toLowerCase(),r=Ne(i,o);if(r===void 0)return;s.push({name:wt(o,r),penalty:NaN,level:n}),i=i.parentElement,n++;}if($e(s,e))return s}function ln(t,e){return t==="html"?"html":`${t}:nth-child(${e})`}function wt(t,e){return t==="html"?"html":`${t}:nth-of-type(${e})`}function*Et(t,e=[]){if(t.length>0)for(let n of t[0])yield*Et(t.slice(1,t.length),e.concat(n));else yield e;}function cn(t,e){return t.nodeType===Node.DOCUMENT_NODE?t:t===e.root?t.ownerDocument:t}function $e(t,e){let n=U(t);switch(e.querySelectorAll(n).length){case 0:throw new Error(`Can't select any node with this selector: ${n}`);case 1:return true;default:return false}}function*kt(t,e,n,i,s){if(t.length>2&&t.length>n.optimizedMinLength)for(let o=1;o<t.length-1;o++){if(new Date().getTime()-s.getTime()>n.timeoutMs)return;let a=[...t];a.splice(o,1),$e(a,i)&&i.querySelector(U(a))===e&&(yield a,yield*kt(a,e,n,i,s));}}var pn=["role","aria-label","type","name","href","src","data-testid","data-id"];function dn(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 He(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 s=[];for(let r of pn){let a=t.getAttribute(r);a&&s.push(`${r}=${a}`);}let o=s.length>0?dn(s.join(",")):"0";return `${e}:${n}:${o}`}function St(t,e){let n=e.split(":");if(n.length!==3)return 0;let[i,s,o]=n,r=Number(i),a=Number(s);if(Number.isNaN(r)||Number.isNaN(a))return 0;let l=He(t),[c,u,h]=l.split(":"),p=0,f=Math.abs(Number(c)-r);f===0?p+=.2:f<=2?p+=.1:f<=5&&(p+=.03);let v=Math.abs(Number(u)-a);return v===0?p+=.4:v===1?p+=.2:v<=3&&(p+=.08),h===o&&(p+=.4),p}function j(t,e){let n=e==="before"?"previousElementSibling":"nextElementSibling",i=t[n],s=3;for(;i&&s>0;){let o=i.textContent?.trim();if(o)return e==="before"?o.slice(-32):o.slice(0,32);i=i[n],s--;}return ""}function ce(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 Tt(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,s=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 o=1;if(s)for(let r of s.children){if(r===n)break;r.localName===i&&o++;}e.unshift(`/${i}[${o}]`),n=s;}return "/html/body"+e.join("")}var G="data-feedback-anchor";function _e(t){let e=xt(t,{className:h=>!/^(css|sc|emotion|styled)-/.test(h)&&!/^[a-z]{1,3}[A-Za-z0-9]{4,8}$/.test(h),attr:h=>["data-testid","data-id","role","aria-label"].includes(h),idName:h=>!h.startsWith("radix-")&&!/^:r[0-9]+:$/.test(h),seedMinLength:3,optimizedMinLength:2}),n=Tt(t),s=(t.textContent?.trim()??"").slice(0,120),o=j(t,"before"),r=j(t,"after"),a=He(t),l=ce(t),u=t.closest(`[${G}]`)?.getAttribute(G)??null;return {cssSelector:e,xpath:n,textSnippet:s,textPrefix:o,textSuffix:r,fingerprint:a,neighborText:l,elementTag:t.tagName,elementId:t.id||void 0,anchorKey:u}}function Ct(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 At(t,e=document.documentElement){let n=t.x+t.width/2,i=t.y+t.height/2,s=document.elementFromPoint(n,i);if(!s||s===e)return document.body;let o=s;for(;o&&o!==document.body;){if(o.hasAttribute(G)&&Ct(o,t))return o;o=o.parentElement;}for(o=s;o&&o!==document.body;){if(Ct(o,t))return o;o=o.parentElement;}return document.body}function Rt(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 un={question:"type.question",change:"type.change",bug:"type.bug",other:"type.other"};function hn(){let t=navigator.userAgentData;return t?t.platform==="macOS":navigator.platform?.includes("Mac")??/Macintosh|Mac OS X/i.test(navigator.userAgent)}var pe=class{constructor(e,n$1){this.colors=e;this.t=n$1;this.root=b("div",{style:`
|
|
2
2
|
position:fixed;
|
|
3
3
|
z-index:${2147483647};
|
|
4
4
|
width:300px;
|
|
@@ -15,7 +15,7 @@ import {G as G$1,H,w,F,U as U$1,T,L,J as J$1,Y as Y$1,N,z as z$1,b,x,y,I,c,e,u,v
|
|
|
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("data-siteping-ignore","true");let i=[{type:"question",icon:l},{type:"change",icon:m},{type:"bug",icon:n},{type:"other",icon:o}];this.typeRow=b("div",{style:"display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px;"});for(let
|
|
18
|
+
`}),this.root.setAttribute("role","dialog"),this.root.setAttribute("aria-modal","true"),this.root.setAttribute("data-siteping-ignore","true");let i=[{type:"question",icon:l},{type:"change",icon:m},{type:"bug",icon:n},{type:"other",icon:o}];this.typeRow=b("div",{style:"display:grid;grid-template-columns:1fr 1fr;gap:6px;margin-bottom:12px;"});for(let o of i){let r=document.createElement("button");r.style.cssText=`
|
|
19
19
|
height:44px;
|
|
20
20
|
border-radius:9999px;border:1px solid ${this.colors.border};
|
|
21
21
|
background:${this.colors.glassBg};cursor:pointer;
|
|
@@ -24,7 +24,7 @@ import {G as G$1,H,w,F,U as U$1,T,L,J as J$1,Y as Y$1,N,z as z$1,b,x,y,I,c,e,u,v
|
|
|
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 a$1=a(
|
|
27
|
+
`;let a$1=a(o.icon);a$1.setAttribute("style","width:13px;height:13px;flex-shrink:0;"),r.appendChild(a$1),r.appendChild(document.createElement("span")),r.dataset.type=o.type,r.setAttribute("aria-pressed","false"),r.addEventListener("click",()=>{this.submittingState||this.selectType(o.type,this.typeRow);}),r.addEventListener("mouseenter",()=>{if(!this.submittingState&&r.dataset.type!==this.selectedType){let l=A(r.dataset.type??"",this.colors);r.style.background=l,r.style.borderColor=x(r.dataset.type??"",this.colors)+"40";}}),r.addEventListener("mouseleave",()=>{this.submittingState||r.dataset.type!==this.selectedType&&(r.style.background=this.colors.glassBg,r.style.borderColor=this.colors.border);}),this.typeRow.appendChild(r);}this.textarea=document.createElement("textarea"),this.textarea.style.cssText=`
|
|
28
28
|
width:100%;min-height:72px;max-height:152px;
|
|
29
29
|
padding:10px 12px;border-radius:12px;
|
|
30
30
|
border:1px solid ${this.colors.border};
|
|
@@ -38,7 +38,7 @@ import {G as G$1,H,w,F,U as U$1,T,L,J as J$1,Y as Y$1,N,z as z$1,b,x,y,I,c,e,u,v
|
|
|
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
|
-
`}),this.textarea.addEventListener("focus",()=>{this.submittingState||(this.textarea.style.borderColor=this.colors.accent,this.textarea.style.boxShadow=`0 0 0 3px ${this.colors.accent}14`,this.textarea.style.background=this.colors.bg);}),this.textarea.addEventListener("blur",()=>{this.submittingState||(this.textarea.style.borderColor=this.colors.border,this.textarea.style.boxShadow="none",this.textarea.style.background=this.colors.glassBgHeavy);}),this.textarea.addEventListener("input",()=>{this.updateSubmitState();}),this.textarea.addEventListener("keydown",
|
|
41
|
+
`}),this.textarea.addEventListener("focus",()=>{this.submittingState||(this.textarea.style.borderColor=this.colors.accent,this.textarea.style.boxShadow=`0 0 0 3px ${this.colors.accent}14`,this.textarea.style.background=this.colors.bg);}),this.textarea.addEventListener("blur",()=>{this.submittingState||(this.textarea.style.borderColor=this.colors.border,this.textarea.style.boxShadow="none",this.textarea.style.background=this.colors.glassBgHeavy);}),this.textarea.addEventListener("input",()=>{this.updateSubmitState();}),this.textarea.addEventListener("keydown",o=>{this.submittingState||(o.key==="Enter"&&(o.ctrlKey||o.metaKey)&&(o.preventDefault(),this.submit()),o.key==="Escape"&&this.cancel());});let s=b("div",{style:"display:flex;justify-content:flex-end;gap:8px;margin-top:12px;"});this.cancelBtn=document.createElement("button"),this.cancelBtn.style.cssText=`
|
|
42
42
|
height:34px;padding:0 16px;border-radius:9999px;
|
|
43
43
|
border:1px solid ${this.colors.border};
|
|
44
44
|
background:${this.colors.glassBg};
|
|
@@ -54,43 +54,43 @@ import {G as G$1,H,w,F,U as U$1,T,L,J as J$1,Y as Y$1,N,z as z$1,b,x,y,I,c,e,u,v
|
|
|
54
54
|
transition:all 0.2s ease;
|
|
55
55
|
box-shadow:0 2px 8px ${this.colors.accentGlow};
|
|
56
56
|
display:inline-flex;align-items:center;justify-content:center;min-width:64px;
|
|
57
|
-
`,this.submitLabel=document.createElement("span"),this.submitBtn.appendChild(this.submitLabel),this.submitBtn.addEventListener("click",()=>this.submit()),
|
|
57
|
+
`,this.submitLabel=document.createElement("span"),this.submitBtn.appendChild(this.submitLabel),this.submitBtn.addEventListener("click",()=>this.submit()),s.appendChild(this.cancelBtn),s.appendChild(this.submitBtn),this.root.appendChild(this.typeRow),this.root.appendChild(this.textarea),this.root.appendChild(this.hint),this.root.appendChild(s),document.body.appendChild(this.root),this.applyLabels();}colors;t;root;selectedType=null;textarea;submitBtn;cancelBtn;typeRow;submitLabel;hint;resolve=null;previouslyFocused=null;onKeydownTrap=null;onSubmit=null;submittingState=false;spinnerAnimation=null;refreshLabels(){this.applyLabels();}applyLabels(){this.root.setAttribute("aria-label",this.t("popup.ariaLabel"));let e=this.root.querySelectorAll("button[data-type]");for(let n of e){let i=n.dataset.type;if(!i)continue;let s=un[i];if(!s)continue;let o=n.querySelector("span");o&&c(o,this.t(s));}this.textarea.placeholder=this.t("popup.placeholder"),this.textarea.setAttribute("aria-label",this.t("popup.textareaAria")),c(this.hint,hn()?this.t("popup.submitHintMac"):this.t("popup.submitHintOther")),c(this.cancelBtn,this.t("popup.cancel")),c(this.submitLabel,this.t("popup.submit"));}show(e,n){return new Promise(i=>{this.resolve=i,this.onSubmit=n??null,this.selectedType=null,this.textarea.value="",this.submittingState=false,this.updateSubmitState(),this.resetTypeButtons(),this.previouslyFocused=document.activeElement;let s=220,o=300,r=e.bottom+8,a=e.left;if(r+s>window.innerHeight){let c=e.top-s-8;c>=8?r=c:r=window.innerHeight-s-8;}a+o>window.innerWidth&&(a=e.right-o),a=Math.max(8,a),r=Math.max(8,r),this.root.style.top=`${r}px`,this.root.style.left=`${a}px`,this.root.style.display="block",this.onKeydownTrap=c=>{if(c.key==="Tab"){let u=Array.from(this.root.querySelectorAll('button:not([disabled]), textarea:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'));if(u.length===0)return;let h=u[0],p=u[u.length-1];if(!h||!p)return;c.shiftKey?(document.activeElement===h||!this.root.contains(document.activeElement))&&(c.preventDefault(),p.focus()):(document.activeElement===p||!this.root.contains(document.activeElement))&&(c.preventDefault(),h.focus());}},this.root.addEventListener("keydown",this.onKeydownTrap);let l=typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;this.root.style.transition=l?"none":"",requestAnimationFrame(()=>{this.root.style.opacity="1",this.root.style.transform="translateY(0) scale(1)",this.textarea.focus();});})}selectType(e,n){this.selectedType=e;let i=n.querySelectorAll("button");for(let s of i){let o=s.dataset.type===e,r=x(s.dataset.type??"",this.colors),a=A(s.dataset.type??"",this.colors);s.style.background=o?a:this.colors.glassBg,s.style.borderColor=o?r+"60":this.colors.border,s.style.color=o?r:this.colors.textTertiary,s.style.fontWeight=o?"600":"500",s.setAttribute("aria-pressed",String(o));}this.updateSubmitState();}resetTypeButtons(){let e=this.root.querySelectorAll("button[data-type]");for(let n of e)n.setAttribute("aria-pressed","false"),n.disabled=false,n.style.background=this.colors.glassBg,n.style.borderColor=this.colors.border,n.style.color=this.colors.textTertiary,n.style.fontWeight="500",n.style.cursor="pointer";}updateSubmitState(){if(this.submittingState)return;let e=this.selectedType!==null&&this.textarea.value.trim().length>0;this.submitBtn.disabled=!e,this.submitBtn.style.opacity=e?"1":"0.35",this.submitBtn.style.pointerEvents=e?"auto":"none";}submit(){if(this.submittingState||!this.selectedType||!this.textarea.value.trim())return;let e={type:this.selectedType,message:this.textarea.value.trim()};if(!this.onSubmit){this.resolve?.(e),this.resolve=null,this.hideElement();return}this.enterSubmittingState();let n=this.onSubmit;n(e).then(()=>{this.resolve?.(e),this.resolve=null,this.hideElement();}).catch(()=>{this.exitSubmittingState();});}cancel(){this.submittingState||(this.resolve?.(null),this.resolve=null,this.hideElement());}enterSubmittingState(){this.submittingState=true,this.submitLabel.style.display="none",this.submitBtn.disabled=true,this.submitBtn.style.cursor="wait",this.submitBtn.style.opacity="0.85",this.submitBtn.setAttribute("aria-busy","true"),this.submitBtn.appendChild(this.buildSpinner()),this.cancelBtn.disabled=true,this.cancelBtn.style.opacity="0.5",this.cancelBtn.style.cursor="not-allowed",this.cancelBtn.style.pointerEvents="none",this.textarea.disabled=true,this.textarea.style.opacity="0.6";let e=this.typeRow.querySelectorAll("button");for(let n of e)n.disabled=true,n.style.cursor="not-allowed",n.style.opacity="0.6";}exitSubmittingState(){this.submittingState=false,this.spinnerAnimation?.cancel(),this.spinnerAnimation=null,this.submitBtn.querySelector('[data-role="sp-popup-spinner"]')?.remove(),this.submitLabel.style.display="",this.submitBtn.removeAttribute("aria-busy"),this.submitBtn.style.cursor="pointer",this.cancelBtn.disabled=false,this.cancelBtn.style.opacity="1",this.cancelBtn.style.cursor="pointer",this.cancelBtn.style.pointerEvents="auto",this.textarea.disabled=false,this.textarea.style.opacity="1";let n=this.typeRow.querySelectorAll("button");for(let i of n)i.disabled=false,i.style.cursor="pointer",i.style.opacity="1";this.updateSubmitState();}buildSpinner(){let e=document.createElement("div");return e.dataset.role="sp-popup-spinner",e.style.cssText=`
|
|
58
58
|
width:14px;height:14px;
|
|
59
59
|
border:2px solid rgba(255,255,255,0.35);
|
|
60
60
|
border-top-color:#fff;
|
|
61
61
|
border-radius:50%;
|
|
62
62
|
box-sizing:border-box;
|
|
63
|
-
`,!(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)&&typeof e.animate=="function"&&(this.spinnerAnimation=e.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:600,iterations:1/0,easing:"linear"})),e}hideElement(){this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.submittingState&&this.exitSubmittingState(),this.onSubmit=null,this.root.style.opacity="0",this.root.style.transform="translateY(8px) scale(0.98)",this.previouslyFocused?.focus(),this.previouslyFocused=null,setTimeout(()=>{this.root.style.display="none";},250);}destroy(){this.submittingState&&this.exitSubmittingState(),this.resolve?.(null),this.resolve=null,this.onSubmit=null,this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.root.remove();}};var
|
|
63
|
+
`,!(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)&&typeof e.animate=="function"&&(this.spinnerAnimation=e.animate([{transform:"rotate(0deg)"},{transform:"rotate(360deg)"}],{duration:600,iterations:1/0,easing:"linear"})),e}hideElement(){this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.submittingState&&this.exitSubmittingState(),this.onSubmit=null,this.root.style.opacity="0",this.root.style.transform="translateY(8px) scale(0.98)",this.previouslyFocused?.focus(),this.previouslyFocused=null,setTimeout(()=>{this.root.style.display="none";},250);}destroy(){this.submittingState&&this.exitSubmittingState(),this.resolve?.(null),this.resolve=null,this.onSubmit=null,this.onKeydownTrap&&(this.root.removeEventListener("keydown",this.onKeydownTrap),this.onKeydownTrap=null),this.root.remove();}};var V,Mt=false;async function fn(){if(V!==void 0)return V;try{let t=await import('html2canvas');return V=t.default??t,V}catch(t){return V=null,Mt||(Mt=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}}function De(t,e,n){return Math.min(n,Math.max(t,e))}function de(t){return De(0,Math.round(t*1e4)/1e4,1)}async function Lt(t,e){let n=await fn();if(!n)return null;let i=.85,s=1200,o=De(48,t.width*.6,280),r=De(48,t.height*.6,220),a=window.scrollX+t.x,l=window.scrollY+t.y,c=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth),u=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight),h=Math.max(0,a-o),p=Math.max(0,l-r),f=Math.min(c,a+t.width+o)-h,v=Math.min(u,l+t.height+r)-p;if(f<=0||v<=0)return null;let T={xPct:de((a-h)/f),yPct:de((l-p)/v),wPct:de(t.width/f),hPct:de(t.height/v)};try{let k=await n(document.body,{x:h,y:p,width:f,height:v,scale:window.devicePixelRatio,useCORS:!0,allowTaint:!0,logging:!1,ignoreElements:y=>y.tagName==="SITEPING-WIDGET"||y.closest?.("siteping-widget")!==null||y.getAttribute?.("data-siteping-ignore")==="true"});if(k.width<=s)return {dataUrl:k.toDataURL("image/jpeg",i),region:T};let F=s/k.width,C=s,K=Math.round(k.height*F),w=document.createElement("canvas");w.width=C,w.height=K;let S=w.getContext("2d");return S?(S.drawImage(k,0,0,C,K),{dataUrl:w.toDataURL("image/jpeg",i),region:T}):null}catch(k){return console.warn("[siteping] Screenshot capture failed:",k),null}}var ue=class{constructor(e,n,i,s=false){this.colors=e;this.bus=n;this.t=i;this.enableScreenshot=s;this.popup=new pe(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;instantMode=false;popup;savedOverflow="";preActiveFocusElement=null;rafId=null;pendingMoveEvent=null;rejectPendingSubmission=null;get isBusy(){return this.isActive}refreshLabels(){this.popup.refreshLabels();}get submissionInFlight(){return this.rejectPendingSubmission!==null}async maybeCapture(e){return this.enableScreenshot?Lt(e):null}activate(){if(this.isActive)return;this.isActive=true;let e=!this.instantMode;if(this.preActiveFocusElement=document.activeElement,this.savedOverflow=document.body.style.overflow,document.body.style.overflow="hidden",this.overlay=b("div",{style:`
|
|
64
64
|
position:fixed;inset:0;
|
|
65
65
|
z-index:${2147483646};
|
|
66
66
|
background:rgba(15, 23, 42, 0.04);
|
|
67
|
-
cursor:
|
|
68
|
-
`}),this.overlay.setAttribute("role","application"),this.overlay.setAttribute("aria-label",this.t("annotator.instruction")),this.overlay.setAttribute("data-siteping-ignore","true"),this.toolbar=b("div",{style:`
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
cursor:${e?"crosshair":"default"};
|
|
68
|
+
`}),this.overlay.setAttribute("role","application"),this.overlay.setAttribute("aria-label",e?this.t("annotator.instruction"):this.t("annotator.instantInstruction")),this.overlay.setAttribute("data-siteping-ignore","true"),e){this.toolbar=b("div",{style:`
|
|
69
|
+
position:fixed;top:0;left:0;right:0;
|
|
70
|
+
z-index:${2147483647};
|
|
71
|
+
height:52px;
|
|
72
|
+
background:${this.colors.glassBg};
|
|
73
|
+
backdrop-filter:blur(24px);
|
|
74
|
+
-webkit-backdrop-filter:blur(24px);
|
|
75
|
+
border-bottom:1px solid ${this.colors.glassBorder};
|
|
76
|
+
display:flex;align-items:center;justify-content:center;gap:16px;
|
|
77
|
+
font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
78
|
+
font-size:14px;color:${this.colors.text};
|
|
79
|
+
box-shadow:0 4px 16px ${this.colors.shadow};
|
|
80
|
+
-webkit-font-smoothing:antialiased;
|
|
81
|
+
`}),this.toolbar.setAttribute("data-siteping-ignore","true");let n=b("span",{style:`
|
|
82
|
+
width:8px;height:8px;border-radius:50%;
|
|
83
|
+
background:${this.colors.accent};
|
|
84
|
+
box-shadow:0 0 8px ${this.colors.accentGlow};
|
|
85
|
+
animation:pulse 1.5s ease-in-out infinite;
|
|
86
|
+
`}),i=document.createElement("style");i.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(i);let s=b("span",{style:"font-weight:500;letter-spacing:-0.01em;"});c(s,this.t("annotator.instruction"));let o=document.createElement("button");o.style.cssText=`
|
|
87
|
+
height:34px;padding:0 18px;border-radius:9999px;
|
|
88
|
+
border:1px solid ${this.colors.border};
|
|
72
89
|
background:${this.colors.glassBg};
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
78
|
-
font-size:14px;color:${this.colors.text};
|
|
79
|
-
box-shadow:0 4px 16px ${this.colors.shadow};
|
|
80
|
-
-webkit-font-smoothing:antialiased;
|
|
81
|
-
`}),this.toolbar.setAttribute("data-siteping-ignore","true");let e=b("span",{style:`
|
|
82
|
-
width:8px;height:8px;border-radius:50%;
|
|
83
|
-
background:${this.colors.accent};
|
|
84
|
-
box-shadow:0 0 8px ${this.colors.accentGlow};
|
|
85
|
-
animation:pulse 1.5s ease-in-out infinite;
|
|
86
|
-
`}),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=`
|
|
87
|
-
height:34px;padding:0 18px;border-radius:9999px;
|
|
88
|
-
border:1px solid ${this.colors.border};
|
|
89
|
-
background:${this.colors.glassBg};
|
|
90
|
-
color:${this.colors.textTertiary};font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
91
|
-
font-size:13px;font-weight:500;cursor:pointer;
|
|
92
|
-
transition:all 0.2s ease;
|
|
93
|
-
`,c(o,this.t("annotator.cancel")),o.addEventListener("click",()=>this.deactivate()),o.addEventListener("mouseenter",()=>{o.style.borderColor=this.colors.typeBug,o.style.color=this.colors.typeBug,o.style.background=this.colors.typeBugBg;}),o.addEventListener("mouseleave",()=>{o.style.borderColor=this.colors.border,o.style.color=this.colors.textTertiary,o.style.background=this.colors.glassBg;}),this.toolbar.appendChild(e),this.toolbar.appendChild(i),this.toolbar.appendChild(o),this.overlay.addEventListener("mousedown",this.onMouseDown),this.overlay.addEventListener("mousemove",this.onMouseMove),this.overlay.addEventListener("mouseup",this.onMouseUp),this.overlay.addEventListener("touchstart",this.onTouchStart,{passive:false}),this.overlay.addEventListener("touchmove",this.onTouchMove,{passive:false}),this.overlay.addEventListener("touchend",this.onTouchEnd),this.overlay.addEventListener("keydown",this.onOverlayKeyDown),this.overlay.setAttribute("tabindex","0"),document.addEventListener("keydown",this.onKeyDown),document.body.appendChild(this.overlay),document.body.appendChild(this.toolbar),this.overlay.focus({preventScroll:true});}deactivate(){if(!this.isActive)return;this.isActive=false,this.isDrawing=false;let e=this.preActiveFocusElement;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,e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:true}),this.bus.emit("annotation:end");}onKeyDown=e=>{e.key==="Escape"&&this.deactivate();};onOverlayKeyDown=async e=>{if(e.key!=="Enter"||(e.preventDefault(),this.submissionInFlight))return;let n=this.preActiveFocusElement;if(!n||!(n instanceof HTMLElement))return;let i=n.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let o=new DOMRect(i.x,i.y,i.width,i.height),s={anchor:Pe(n),rect:{xPct:0,yPct:0,wPct:1,hPct:1},scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio},a={};await this.popup.show(o,c=>this.runSubmission(s,c,o,a))&&this.deactivate();};onMouseDown=e=>{this.startDrawing(e.clientX,e.clientY);};onTouchStart=e=>{e.preventDefault();let n=e.touches[0];n&&this.startDrawing(n.clientX,n.clientY);};startDrawing(e,n){this.submissionInFlight||(this.isDrawing=true,this.startX=e,this.startY=n,this.drawingRect?.remove(),this.drawingRect=b("div",{style:`
|
|
90
|
+
color:${this.colors.textTertiary};font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
91
|
+
font-size:13px;font-weight:500;cursor:pointer;
|
|
92
|
+
transition:all 0.2s ease;
|
|
93
|
+
`,c(o,this.t("annotator.cancel")),o.addEventListener("click",()=>this.deactivate()),o.addEventListener("mouseenter",()=>{o.style.borderColor=this.colors.typeBug,o.style.color=this.colors.typeBug,o.style.background=this.colors.typeBugBg;}),o.addEventListener("mouseleave",()=>{o.style.borderColor=this.colors.border,o.style.color=this.colors.textTertiary,o.style.background=this.colors.glassBg;}),this.toolbar.appendChild(n),this.toolbar.appendChild(s),this.toolbar.appendChild(o);}e&&(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),this.toolbar&&document.body.appendChild(this.toolbar),this.overlay.focus({preventScroll:true});}deactivate(){if(!this.isActive)return;this.isActive=false,this.isDrawing=false,this.instantMode=false;let e=this.preActiveFocusElement;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,e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:true}),this.bus.emit("annotation:end");}onKeyDown=e=>{e.key==="Escape"&&this.deactivate();};onOverlayKeyDown=async e=>{if(e.key!=="Enter"||(e.preventDefault(),this.submissionInFlight))return;let n=this.preActiveFocusElement;if(!n||!(n instanceof HTMLElement))return;let i=n.getBoundingClientRect();if(i.width<=0||i.height<=0)return;let s=new DOMRect(i.x,i.y,i.width,i.height),r={anchor:_e(n),rect:{xPct:0,yPct:0,wPct:1,hPct:1},scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio},a={};await this.popup.show(s,c=>this.runSubmission(r,c,s,a))&&this.deactivate();};onMouseDown=e=>{this.startDrawing(e.clientX,e.clientY);};onTouchStart=e=>{e.preventDefault();let n=e.touches[0];n&&this.startDrawing(n.clientX,n.clientY);};startDrawing(e,n){this.submissionInFlight||(this.isDrawing=true,this.startX=e,this.startY=n,this.drawingRect?.remove(),this.drawingRect=b("div",{style:`
|
|
94
94
|
position:fixed;
|
|
95
95
|
border:2px solid ${this.colors.accent};
|
|
96
96
|
background:${this.colors.accent}12;
|
|
@@ -98,8 +98,19 @@ import {G as G$1,H,w,F,U as U$1,T,L,J as J$1,Y as Y$1,N,z as z$1,b,x,y,I,c,e,u,v
|
|
|
98
98
|
border-radius:8px;
|
|
99
99
|
box-shadow:0 0 16px ${this.colors.accentGlow};
|
|
100
100
|
transition:box-shadow 0.15s ease;
|
|
101
|
-
`}),this.drawingRect.setAttribute("data-siteping-ignore","true"),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),
|
|
102
|
-
${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof i=="function")return "[Function]";if(typeof i=="symbol")return i.toString();if(typeof i=="object"&&i!==null){if(e.has(i))return "[Circular]";e.add(i);}return i})}catch{try{return String(t)}catch{return "[Unserializable]"}}}function bn(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=mn(t[n]),!(e.length>=500));n++);return e.length>500&&(e=`${e.slice(0,499)}\u2026`),e}var ce=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 fn){let i=console[n];if(typeof i!="function")continue;this.originals.set(n,i);let o=this,r=function(...s){try{o.push(n,s);}catch{}i.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:bn(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 Mt(t){return t.length<=2e3?t:`${t.slice(0,1999)}\u2026`}function Pt(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 pe=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 r=new Date,s=typeof performance<"u"?performance.now():Date.now(),a=Mt(Pt(i)),l=(o?.method??(i instanceof Request?i.method:"GET")).toUpperCase();try{let c=await e(i,o);if(!c.ok){let d=typeof performance<"u"?performance.now():Date.now();this.push({url:a,method:l,status:c.status,durationMs:Math.round(d-s),timestamp:r.toISOString()});}return c}catch(c){let d=typeof performance<"u"?performance.now():Date.now();throw this.push({url:a,method:l,status:0,durationMs:Math.round(d-s),timestamp:r.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,r=new WeakMap;e.open=function(s,a,...l){try{r.set(this,{method:s.toUpperCase(),url:Mt(Pt(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 c=typeof performance<"u"?performance.now():Date.now(),d=this.status;(d===0||d>=400)&&o.push({url:a.url,method:a.method,status:d,durationMs:Math.round(c-a.t0),timestamp:a.startedAt.toISOString()});}catch{}};try{this.addEventListener("loadend",l,{once:!0});}catch{try{this.addEventListener("loadend",l);}catch{}}}return i.call(this,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 V=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(r){console.error(`[siteping] Error in event listener for "${String(e)}":`,r);}}removeAll(){this.listeners.clear();}};var gn=54,yn={chat:"fab.messages",annotate:"fab.annotate","toggle-annotations":"fab.annotations"},de=class{constructor(e,n,i,o){this.bus=i;this.t=o;let r=n.position??"bottom-right",s=r==="bottom-right";this.items=[{id:"chat",icon:u},{id:"annotate",icon:v}],n.showAnnotationsToggle!==false&&this.items.push({id:"toggle-annotations",icon:g,iconAlt:h}),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-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 c=0;c<this.items.length;c++){let d=this.items[c];if(!d)continue;let u=document.createElement("button");u.className="sp-radial-item",u.style.setProperty("--sp-i",String(c)),u.appendChild(a(d.icon)),u.setAttribute("role","menuitem"),u.dataset.itemId=d.id,u.addEventListener("click",b=>{b.stopPropagation(),this.handleItemClick(d.id);});let p=document.createElement("span");p.className="sp-radial-label",p.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;",u.appendChild(p),this.radialContainer.appendChild(u);}this.root=document.createElement("div"),this.root.appendChild(this.radialContainer),this.root.appendChild(this.fab),e.appendChild(this.root),this.applyLabels();let a$1=e.host;this.onDocumentClick=c=>{this.isOpen&&!c.composedPath().includes(a$1)&&this.close();},document.addEventListener("click",this.onDocumentClick);let l=c=>{c.key==="Escape"&&this.isOpen&&(c.stopPropagation(),this.close());};this.fab.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",c=>{let d=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(d.length===0||!this.isOpen)return;let u=e.activeElement??document.activeElement,p=d.indexOf(u);switch(c.key){case "ArrowUp":{c.preventDefault();let b=p<=0?d.length-1:p-1;d[b]?.focus();break}case "ArrowDown":{c.preventDefault();let b=p>=d.length-1?0:p+1;d[b]?.focus();break}case "Home":{c.preventDefault(),d[0]?.focus();break}case "End":{c.preventDefault(),d[d.length-1]?.focus();break}}});}bus;t;root;fab;radialContainer;badgeEl=null;isOpen=false;annotationsVisible=true;items;onDocumentClick;refreshLabels(){this.applyLabels();}applyLabels(){this.fab.setAttribute("aria-label",this.t("fab.aria"));let e=this.radialContainer.querySelectorAll(".sp-radial-item");for(let n of e){let i=n.dataset.itemId;if(!i)continue;let o=yn[i];if(!o)continue;let r=this.t(o);n.setAttribute("aria-label",r);let s=n.querySelector(".sp-radial-label");s&&c(s,r);}}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(i),this.fab.setAttribute("aria-expanded","true"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach((n,i)=>{let o=-(16+gn*(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":{let n=this.bus.on("annotation:end",()=>{n(),this.fab.focus();});this.bus.emit("annotation:start");break}case "toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let i=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]')?.querySelector("svg");if(i){let o=a(this.annotationsVisible?g:h);i.replaceWith(o);}break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove();}};var Ft="siteping_identity";function vn(t){if(!E(t,"name")||!E(t,"email"))return false;let e=t.name,n=t.email;return typeof e=="string"&&typeof n=="string"&&e.length>0&&n.length>0}function Ie(){try{let t=localStorage.getItem(Ft);if(!t)return null;let e=JSON.parse(t);return vn(e)?e:null}catch{return null}}function It(t){try{localStorage.setItem(Ft,JSON.stringify(t));}catch{}}function xn(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,i=e.length,o=new Array(n+1);for(let s=0;s<=n;s++)o[s]=s;let r=new Array(n+1);for(let s=1;s<=i;s++){r[0]=s;for(let l=1;l<=n;l++){let c=o[l-1]??0;r[l]=t[l-1]===e[s-1]?c:1+Math.min(c,o[l]??0,r[l-1]??0);}let a=o;o=r,r=a;}return o[n]??0}function z(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-xn(t,e)/n}function Ne(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let i=e.length;if(i>t.length){let a=z(t,e);return a>=n?a:0}let o=0,r=t.length>500?t.slice(0,500):t,s=r.length-i;for(let a=0;a<=s;a++){let l=r.slice(a,a+i),c=z(l,e);if(c>o&&(o=c),o>=.95)break}return o>=n?o:0}var wn=300,En=.3;function ue(t,e){if(!e.textSnippet)return true;let n=(t.textContent?.trim()??"").slice(0,500);return Ne(n,e.textSnippet,.5)>En}function kn(t){if(t.anchorKey){let e=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{let n=document.querySelector(`[${q}="${e}"]`);if(n&&ue(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&&ue(e,t))return {element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&ue(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&&ue(n,t))return {element:n,confidence:.9,strategy:"xpath"}}catch{}return Sn(t)}function Sn(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let i=null,o=0,r=Math.min(n.length,wn);for(let s=0;s<r;s++){let a=n[s];if(!a)continue;let l=Tn(a,t);if(l>o&&(o=l,i=a,o>=.85))break}return !i||o<.4?null:{element:i,confidence:Math.min(o,.85),strategy:"scan"}}function Tn(t,e){let n=0,i=0,o=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(i+=40,n+=Ne(o,e.textSnippet,.5)*40),e.fingerprint&&(i+=20,n+=yt(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){i+=20;let r=0,s=0;if(e.textPrefix){let a=B(t,"before");r+=a?z(a,e.textPrefix):0,s++;}if(e.textSuffix){let a=B(t,"after");r+=a?z(a,e.textSuffix):0,s++;}s>0&&(n+=r/s*20);}if(e.neighborText){i+=20;let r=oe(t);n+=r?z(r,e.neighborText)*20:0;}return i>0?n/i:0}function he(t,e){let n=kn(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 _e(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 fe(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var Nt=13;function _t(t){return {top:t.top+window.scrollY-Nt,left:t.right+window.scrollX-Nt}}function J(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}var Dt=300,Ht=200,Cn=.7,An=28,$t=32,me=class{constructor(e,n,i,o,r=null){this.colors=e;this.tooltip=n;this.bus=i;this.t=o;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;lastOpenCount=-1;get count(){return this.entries.length}get openCount(){let e=0;for(let n of this.entries)n.feedback.status==="open"&&e++;return e}scheduleReposition(){this.repositionTimer||("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll();},{timeout:Ht+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},Ht));}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 r=n.feedback.annotations[i];if(!r)continue;let s=`${n.feedback.id}:${i}`;e.add(s);let l=this.anchorCache.get(s)?.deref(),c;if(l?.isConnected){let u=l.getBoundingClientRect(),p=fe(r);c={element:l,rect:new DOMRect(u.left+p.xPct*u.width,u.top+p.yPct*u.height,p.wPct*u.width,p.hPct*u.height),confidence:1,strategy:"css"};}else c=he(_e(r),fe(r)),c?.element&&this.anchorCache.set(s,new WeakRef(c.element));if(!c){o.style.display="none";continue}let d=_t(c.rect);n.baseTop=d.top,n.baseLeft=d.left,o.style.display="flex",this.applyConfidenceStyle(o,c.confidence,n.feedback);}for(let n of this.anchorCache.keys())e.has(n)||this.anchorCache.delete(n);this.applyClusterPositions(),this.pinnedFeedback&&this.showHighlight(this.pinnedFeedback);}applyClusterPositions(){for(let e of this.clusters)e.expanded?this.applyFanPositions(e):this.applyStackPositions(e);}emitMarkersChanged(){let e=this.openCount;e!==this.lastOpenCount&&(this.lastOpenCount=e,this.bus.emit("markers:changed",e));}render(e){this.clear(),e.forEach((n,i)=>{let o=this.buildEntry(n,i+1);this.entries.push(o);}),this.buildClusters(),this.liveRegion&&this.entries.length>0&&(this.liveRegion.textContent=this.t("marker.count").replace("{count}",String(this.entries.length))),this.emitMarkersChanged();}addFeedback(e,n){let i=this.buildEntry(e,n);for(let o of i.elements)o.style.animation="sp-marker-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both";this.entries.push(i),this.buildClusters(),this.emitMarkersChanged();}buildEntry(e,n){let i={feedback:e,elements:[],baseTop:0,baseLeft:0};for(let o of e.annotations){let r=he(_e(o),fe(o));if(!r)continue;let s=_t(r.rect);i.baseTop=s.top,i.baseLeft=s.left;let a=this.createMarker(n,e,s);this.applyConfidenceStyle(a,r.confidence,e),this.container.appendChild(a),i.elements.push(a);}return i}buildClusters(){for(let i of this.container.querySelectorAll(".sp-cluster-badge"))i.remove();let e=[];for(let i of this.entries)for(let o=0;o<i.elements.length;o++)e.push({entry:i,elIdx:o});let n=new Set;this.clusters=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let o=e[i];if(!o)continue;let r={entries:[o.entry],elementIndices:[o.elIdx],expanded:false};n.add(i);for(let s=i+1;s<e.length;s++){if(n.has(s))continue;let a=o.entry,l=e[s];if(!l)continue;let c=l.entry;Math.sqrt((a.baseLeft-c.baseLeft)**2+(a.baseTop-c.baseTop)**2)<An&&(r.entries.push(c),r.elementIndices.push(l.elIdx),n.add(s));}this.clusters.push(r);}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,r=e.entries.length<=1;for(let s=0;s<e.entries.length;s++){let a=J(e,s);a&&(a.style.top=`${i+(r?0:s*3)}px`,a.style.left=`${o+(r?0:s*3)}px`,a.style.zIndex=String(s+1));}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:o}=n,r=e.entries.length,s=(r-1)*$t,a=o-s/2;for(let l=0;l<r;l++){let c=J(e,l);c&&(c.style.top=`${i}px`,c.style.left=`${a+l*$t}px`,c.style.zIndex=String(10+l));}}addClusterBadge(e){let n=J(e,e.entries.length-1);if(!n)return;let i=b("div",{class:"sp-cluster-badge",style:`
|
|
101
|
+
`}),this.drawingRect.setAttribute("data-siteping-ignore","true"),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),s=Math.min(n.clientY,this.startY),o=Math.abs(n.clientX-this.startX),r=Math.abs(n.clientY-this.startY);this.drawingRect.style.left=`${i}px`,this.drawingRect.style.top=`${s}px`,this.drawingRect.style.width=`${o}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),s=Math.min(n,this.startY),o=Math.abs(e-this.startX),r=Math.abs(n-this.startY);if(o<10||r<10){this.drawingRect.remove(),this.drawingRect=null;return}let a=new DOMRect(i,s,o,r),{annotation:l}=this.buildAnnotation(a),c={},u=await this.popup.show(a,h=>this.runSubmission(l,h,a,c));this.drawingRect?.remove(),this.drawingRect=null,u&&this.deactivate();};async startInstantAnnotation(e,n){if(this.isActive)return;this.instantMode=true,this.bus.emit("annotation:start");let i=Math.max(0,Math.min(e-20/2,window.innerWidth-20)),s=Math.max(0,Math.min(n-20/2,window.innerHeight-20)),o=new DOMRect(i,s,20,20),{annotation:r,anchorBounds:a}=this.buildAnnotation(o),l=Math.max(0,a.left),c=Math.max(0,a.top),u=new DOMRect(l,c,Math.max(0,Math.min(a.right,window.innerWidth)-l),Math.max(0,Math.min(a.bottom,window.innerHeight)-c));this.drawingRect?.remove(),this.drawingRect=b("div",{style:`
|
|
102
|
+
position:fixed;
|
|
103
|
+
left:${i}px;
|
|
104
|
+
top:${s}px;
|
|
105
|
+
width:${20}px;
|
|
106
|
+
height:${20}px;
|
|
107
|
+
border:2px solid ${this.colors.accent};
|
|
108
|
+
background:${this.colors.accent}12;
|
|
109
|
+
pointer-events:none;
|
|
110
|
+
border-radius:8px;
|
|
111
|
+
box-shadow:0 0 16px ${this.colors.accentGlow};
|
|
112
|
+
`}),this.drawingRect.setAttribute("data-siteping-ignore","true"),this.overlay?.appendChild(this.drawingRect);let h={};await this.popup.show(o,p=>this.runSubmission(r,p,u,h)),this.drawingRect?.remove(),this.drawingRect=null,this.deactivate();}async runSubmission(e,n,i,s){s.value===void 0&&(s.value=await this.maybeCapture(i));let o=s.value;await new Promise((r,a)=>{let l=()=>{c(),u(),h(),this.rejectPendingSubmission=null;},c=this.bus.on("feedback:sent",()=>{l(),r();}),u=this.bus.on("feedback:error",p=>{l(),a(p);}),h=this.bus.on("submission:cancelled",()=>{l(),a(new Error("Feedback submission cancelled"));});this.rejectPendingSubmission=p=>{l(),a(p);},this.bus.emit("annotation:complete",{annotation:e,type:n.type,message:n.message,screenshotDataUrl:o?.dataUrl??null,screenshotRegion:o?.region??null});});}buildAnnotation(e){this.overlay&&(this.overlay.style.pointerEvents="none");let n=At(e);this.overlay&&(this.overlay.style.pointerEvents="auto");let i=_e(n),s=n.getBoundingClientRect(),o=Rt(e,s);return {annotation:{anchor:i,rect:o,scrollX:window.scrollX,scrollY:window.scrollY,viewportW:window.innerWidth,viewportH:window.innerHeight,devicePixelRatio:window.devicePixelRatio},anchorBounds:s}}destroy(){this.deactivate(),this.rejectPendingSubmission?.(new Error("Annotator destroyed during submission")),this.popup.destroy();}};async function J(t,e){let n=await t.text().catch(()=>"Unknown error"),i=n?`${t.status} ${n}`:`${t.status}`,s=`${e}: ${i}`;return t.status===401||t.status===403?new F(s):t.status>=400&&t.status<500?new E(s):new C(s,"SERVER",false)}function Z(t,e){if(t instanceof D)return t;let n=t instanceof Error?t.message:String(t);return new D(`${e}: ${n}`)}var mn=3,bn=1e4,he="siteping_retry_queue",gn=20;async function Q(t,e,n=mn){for(let i=0;i<=n;i++){let s=new AbortController,o=setTimeout(()=>s.abort(),bn);try{let l=await fetch(t,{...e,signal:s.signal});if(clearTimeout(o),l.ok||l.status>=400&&l.status<500||i===n)return l}catch(l){if(clearTimeout(o),i===n)throw l}let r=1e3*2**i,a=Math.random()*1e3-500;await new Promise(l=>setTimeout(l,r+a));}throw new Error("Max retries exceeded")}var yn="siteping_retry_queue";async function It(t){return typeof navigator<"u"&&navigator.locks?navigator.locks.request(yn,()=>t()):t()}function Nt(){let t=localStorage.getItem(he);if(!t)return [];let e=JSON.parse(t);return Array.isArray(e)?e:[]}function vn(t,e){It(()=>{try{let n=Nt();n.length>=gn&&n.shift(),n.push({endpoint:t,payload:e}),localStorage.setItem(he,JSON.stringify(n));}catch{}});}function Pt(t){return t.trim()}function Ft(t){return t.trim().toLowerCase()}async function $t(t,e){await It(async()=>{try{let n=Nt();if(n.length===0)return;let i=[],s=[],o=0;for(let l of n){if(l.endpoint!==t){s.push(l);continue}!e||Pt(l.payload.authorName)===Pt(e.name)&&Ft(l.payload.authorEmail)===Ft(e.email)?i.push(l):o+=1;}if(i.length===0&&o===0)return;o>0;let r=[];for(let l of i)try{(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l.payload)})).ok||r.push(l);}catch{r.push(l);}let a=s.concat(r);a.length>0?localStorage.setItem(he,JSON.stringify(a)):localStorage.removeItem(he);}catch{}});}async function Oe(t){return await t.json()}var fe=class{constructor(e,n){this.endpoint=e;this.projectName=n;}endpoint;projectName;async sendFeedback(e){let{screenshotRegion:n,...i}=e,s=n?{...i,screenshotRegion:n}:i;try{let o;try{o=await Q(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch(r){throw Z(r,"Failed to send feedback")}if(!o.ok)throw await J(o,"Failed to send feedback");return Oe(o)}catch(o){throw vn(this.endpoint,s),o}}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?.statuses?.length&&i.set("statuses",n.statuses.join(",")),n?.search&&i.set("search",n.search),n?.url&&i.set("url",n.url),n?.urlPattern&&i.set("urlPattern",n.urlPattern);let s;try{s=await Q(`${this.endpoint}?${i.toString()}`,{method:"GET",cache:"no-store"});}catch(o){throw Z(o,"Failed to fetch feedbacks")}if(!s.ok)throw await J(s,"Failed to fetch feedbacks");return Oe(s)}async resolveFeedback(e,n){let i;try{i=await Q(this.endpoint,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName,status:n?"resolved":"open"})});}catch(s){throw Z(s,"Failed to update feedback")}if(!i.ok)throw await J(i,"Failed to update feedback");return Oe(i)}async deleteFeedback(e){let n;try{n=await Q(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,projectName:this.projectName})});}catch(i){throw Z(i,"Failed to delete feedback")}if(!n.ok)throw await J(n,"Failed to delete feedback")}async deleteAllFeedbacks(e){let n;try{n=await Q(this.endpoint,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectName:e,deleteAll:!0})});}catch(i){throw Z(i,"Failed to delete all feedbacks")}if(!n.ok)throw await J(n,"Failed to delete all feedbacks")}};var xn=["log","info","warn","error"];function wn(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?`
|
|
113
|
+
${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 En(t){let e="";for(let n=0;n<t.length&&(n>0&&(e+=" "),e+=wn(t[n]),!(e.length>=500));n++);return e.length>500&&(e=`${e.slice(0,499)}\u2026`),e}var me=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 xn){let i=console[n];if(typeof i!="function")continue;this.originals.set(n,i);let s=this,o=function(...r){try{s.push(n,r);}catch{}i.apply(this??console,r);};try{Object.defineProperty(o,"name",{value:n});}catch{}console[n]=o;}}push(e,n){this.maxEntries!==0&&(this.entries.length>=this.maxEntries&&this.entries.shift(),this.entries.push({level:e,timestamp:new Date().toISOString(),message:En(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 Ht(t){return t.length<=2e3?t:`${t.slice(0,1999)}\u2026`}function _t(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 be=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,s)=>{let o=new Date,r=typeof performance<"u"?performance.now():Date.now(),a=Ht(_t(i)),l=(s?.method??(i instanceof Request?i.method:"GET")).toUpperCase();try{let c=await e(i,s);if(!c.ok){let u=typeof performance<"u"?performance.now():Date.now();this.push({url:a,method:l,status:c.status,durationMs:Math.round(u-r),timestamp:o.toISOString()});}return c}catch(c){let u=typeof performance<"u"?performance.now():Date.now();throw this.push({url:a,method:l,status:0,durationMs:Math.round(u-r),timestamp:o.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 s=this,o=new WeakMap;e.open=function(r,a,...l){try{o.set(this,{method:r.toUpperCase(),url:Ht(_t(a)),startedAt:new Date,t0:typeof performance<"u"?performance.now():Date.now()});}catch{}return n.call(this,r,a,...l)},e.send=function(r){let a=o.get(this);if(a){let l=()=>{try{let c=typeof performance<"u"?performance.now():Date.now(),u=this.status;(u===0||u>=400)&&s.push({url:a.url,method:a.method,status:u,durationMs:Math.round(c-a.t0),timestamp:a.startedAt.toISOString()});}catch{}};try{this.addEventListener("loadend",l,{once:!0});}catch{try{this.addEventListener("loadend",l);}catch{}}}return i.call(this,r??null)};}getEntries(){return this.entries.slice()}dispose(){if(!this.disposed){if(this.disposed=true,this.originalFetch&&typeof globalThis.fetch=="function")try{globalThis.fetch=this.originalFetch;}catch{}if(typeof XMLHttpRequest<"u")try{this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend);}catch{}}}};var ee=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 s of i)try{s(...n);}catch(o){console.error(`[siteping] Error in event listener for "${String(e)}":`,o);}}removeAll(){this.listeners.clear();}};var kn=54,Sn={chat:"fab.messages",annotate:"fab.annotate","toggle-annotations":"fab.annotations"},ge=class{constructor(e,n,i,s){this.bus=i;this.t=s;let o=n.position??"bottom-right",r=o==="bottom-right";this.items=[{id:"chat",icon:u},{id:"annotate",icon:v}],n.showAnnotationsToggle!==false&&this.items.push({id:"toggle-annotations",icon:g,iconAlt:h}),this.fab=document.createElement("button"),this.fab.className=`sp-fab sp-fab--${o} sp-anim-fab-in`,this.fab.style.position="fixed",this.fab.appendChild(a(f)),this.fab.setAttribute("aria-expanded","false"),this.fab.addEventListener("click",()=>this.toggle()),this.radialContainer=document.createElement("div"),this.radialContainer.className=`sp-radial sp-radial--${o}`,this.radialContainer.setAttribute("role","menu");for(let c=0;c<this.items.length;c++){let u=this.items[c];if(!u)continue;let h=document.createElement("button");h.className="sp-radial-item",h.style.setProperty("--sp-i",String(c)),h.appendChild(a(u.icon)),h.setAttribute("role","menuitem"),h.dataset.itemId=u.id,h.addEventListener("click",f=>{f.stopPropagation(),this.handleItemClick(u.id);});let p=document.createElement("span");p.className="sp-radial-label",p.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;",h.appendChild(p),this.radialContainer.appendChild(h);}this.root=document.createElement("div"),this.root.appendChild(this.radialContainer),this.root.appendChild(this.fab),e.appendChild(this.root),this.applyLabels();let a$1=e.host;this.onDocumentClick=c=>{this.isOpen&&!c.composedPath().includes(a$1)&&this.close();},document.addEventListener("click",this.onDocumentClick);let l=c=>{c.key==="Escape"&&this.isOpen&&(c.stopPropagation(),this.close());};this.fab.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",l),this.radialContainer.addEventListener("keydown",c=>{let u=Array.from(this.radialContainer.querySelectorAll(".sp-radial-item"));if(u.length===0||!this.isOpen)return;let h=e.activeElement??document.activeElement,p=u.indexOf(h);switch(c.key){case "ArrowUp":{c.preventDefault();let f=p<=0?u.length-1:p-1;u[f]?.focus();break}case "ArrowDown":{c.preventDefault();let f=p>=u.length-1?0:p+1;u[f]?.focus();break}case "Home":{c.preventDefault(),u[0]?.focus();break}case "End":{c.preventDefault(),u[u.length-1]?.focus();break}}});}bus;t;root;fab;radialContainer;badgeEl=null;isOpen=false;annotationsVisible=true;items;onDocumentClick;refreshLabels(){this.applyLabels();}applyLabels(){this.fab.setAttribute("aria-label",this.t("fab.aria"));let e=this.radialContainer.querySelectorAll(".sp-radial-item");for(let n of e){let i=n.dataset.itemId;if(!i)continue;let s=Sn[i];if(!s)continue;let o=this.t(s);n.setAttribute("aria-label",o);let r=n.querySelector(".sp-radial-label");r&&c(r,o);}}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(i),this.fab.setAttribute("aria-expanded","true"),this.radialContainer.querySelectorAll(".sp-radial-item").forEach((n,i)=>{let s=-(16+kn*(i+1));n.style.transform=`translate(0px, ${s}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":{let n=this.bus.on("annotation:end",()=>{n(),this.fab.focus();});this.bus.emit("annotation:start");break}case "toggle-annotations":{this.annotationsVisible=!this.annotationsVisible,this.bus.emit("annotations:toggle",this.annotationsVisible);let i=this.radialContainer.querySelector('[data-item-id="toggle-annotations"]')?.querySelector("svg");if(i){let s=a(this.annotationsVisible?g:h);i.replaceWith(s);}break}}}destroy(){document.removeEventListener("click",this.onDocumentClick),this.root.remove();}};var Dt="siteping_identity";function Tn(t){if(!G$1(t,"name")||!G$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 Be(){try{let t=localStorage.getItem(Dt);if(!t)return null;let e=JSON.parse(t);return Tn(e)?e:null}catch{return null}}function Ot(t){try{localStorage.setItem(Dt,JSON.stringify(t));}catch{}}function Cn(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,s=new Array(n+1);for(let r=0;r<=n;r++)s[r]=r;let o=new Array(n+1);for(let r=1;r<=i;r++){o[0]=r;for(let l=1;l<=n;l++){let c=s[l-1]??0;o[l]=t[l-1]===e[r-1]?c:1+Math.min(c,s[l]??0,o[l-1]??0);}let a=s;s=o,o=a;}return s[n]??0}function X(t,e){if(t===e)return 1;let n=Math.max(t.length,e.length);return n===0?1:1-Cn(t,e)/n}function ze(t,e,n=.6){if(!e||!t)return 0;if(t.includes(e))return 1;let i=e.length;if(i>t.length){let a=X(t,e);return a>=n?a:0}let s=0,o=t.length>500?t.slice(0,500):t,r=o.length-i;for(let a=0;a<=r;a++){let l=o.slice(a,a+i),c=X(l,e);if(c>s&&(s=c),s>=.95)break}return s>=n?s:0}var An=300,Rn=.3;function ye(t,e){if(!e.textSnippet)return true;let n=(t.textContent?.trim()??"").slice(0,500);return ze(n,e.textSnippet,.5)>Rn}function Mn(t){if(t.anchorKey){let e=t.anchorKey.replace(/\\/g,"\\\\").replace(/"/g,'\\"');try{let n=document.querySelector(`[${G}="${e}"]`);if(n&&ye(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&&ye(e,t))return {element:e,confidence:1,strategy:"id"}}try{let e=document.querySelector(t.cssSelector);if(e&&e.tagName===t.elementTag&&ye(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&&ye(n,t))return {element:n,confidence:.9,strategy:"xpath"}}catch{}return Ln(t)}function Ln(t){let e=t.elementTag.toLowerCase(),n=document.querySelectorAll(e);if(n.length===0)return null;let i=null,s=0,o=Math.min(n.length,An);for(let r=0;r<o;r++){let a=n[r];if(!a)continue;let l=Pn(a,t);if(l>s&&(s=l,i=a,s>=.85))break}return !i||s<.4?null:{element:i,confidence:Math.min(s,.85),strategy:"scan"}}function Pn(t,e){let n=0,i=0,s=(t.textContent?.trim()??"").slice(0,500);if(e.textSnippet&&(i+=40,n+=ze(s,e.textSnippet,.5)*40),e.fingerprint&&(i+=20,n+=St(t,e.fingerprint)*20),e.textPrefix||e.textSuffix){i+=20;let o=0,r=0;if(e.textPrefix){let a=j(t,"before");o+=a?X(a,e.textPrefix):0,r++;}if(e.textSuffix){let a=j(t,"after");o+=a?X(a,e.textSuffix):0,r++;}r>0&&(n+=o/r*20);}if(e.neighborText){i+=20;let o=ce(t);n+=o?X(o,e.neighborText)*20:0;}return i>0?n/i:0}function ve(t,e){let n=Mn(t);if(!n)return null;let i=n.element.getBoundingClientRect(),s=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:s,confidence:n.confidence,strategy:n.strategy}}function je(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 xe(t){return {xPct:t.xPct,yPct:t.yPct,wPct:t.wPct,hPct:t.hPct}}var Bt=13;function zt(t){return {top:t.top+window.scrollY-Bt,left:t.right+window.scrollX-Bt}}function te(t,e){let n=t.entries[e],i=t.elementIndices[e];if(!(!n||i===void 0))return n.elements[i]}var jt=300,Xt=200,Fn=.7,In=28,Kt=32,we=class{constructor(e,n,i,s,o=null){this.colors=e;this.tooltip=n;this.bus=i;this.t=s;this.liveRegion=o;this.container=b("div",{style:`position:absolute;top:0;left:0;pointer-events:none;z-index:${2147483646};`}),this.container.id="siteping-markers",document.body.appendChild(this.container),this.bus.on("annotations:toggle",r=>{this.container.style.display=r?"block":"none";}),this.resizeHandler=()=>this.scheduleReposition(),window.addEventListener("resize",this.resizeHandler,{passive:true}),this.scrollHandler=()=>this.scheduleReposition(),window.addEventListener("scroll",this.scrollHandler,{passive:true,capture:true}),this.mutationObserver=new MutationObserver(r=>{let a=false;for(let l of r)if(!(this.container.contains(l.target)||this.tooltip.contains(l.target))){a=true;break}a&&this.scheduleReposition();}),this.mutationObserver.observe(document.body,{childList:true,subtree:true,attributes:false,characterData:false}),this.onDocumentClickForClusters=r=>{this.container.contains(r.target)||this.collapseAllClusters();},document.addEventListener("click",this.onDocumentClickForClusters);}colors;tooltip;bus;t;liveRegion;container;entries=[];highlightElements=[];pinnedFeedback=null;onDocumentClick=null;repositionTimer=null;mutationObserver=null;scrollHandler=null;resizeHandler=null;anchorCache=new Map;clusters=[];onDocumentClickForClusters=null;lastOpenCount=-1;get count(){return this.entries.length}get openCount(){let e=0;for(let n of this.entries)J$1(n.feedback.status)||e++;return e}scheduleReposition(){this.repositionTimer||("requestIdleCallback"in window?this.repositionTimer=window.requestIdleCallback(()=>{this.repositionTimer=null,this.repositionAll();},{timeout:Xt+100}):this.repositionTimer=+setTimeout(()=>{this.repositionTimer=null,this.repositionAll();},Xt));}repositionAll(){let e=new Set;for(let n of this.entries)for(let i=0;i<n.feedback.annotations.length;i++){let s=n.elements[i];if(!s)continue;let o=n.feedback.annotations[i];if(!o)continue;let r=`${n.feedback.id}:${i}`;e.add(r);let l=this.anchorCache.get(r)?.deref(),c;if(l?.isConnected){let h=l.getBoundingClientRect(),p=xe(o);c={element:l,rect:new DOMRect(h.left+p.xPct*h.width,h.top+p.yPct*h.height,p.wPct*h.width,p.hPct*h.height),confidence:1,strategy:"css"};}else c=ve(je(o),xe(o)),c?.element&&this.anchorCache.set(r,new WeakRef(c.element));if(!c){s.style.display="none";continue}let u=zt(c.rect);n.baseTop=u.top,n.baseLeft=u.left,s.style.display="flex",this.applyConfidenceStyle(s,c.confidence,n.feedback);}for(let n of this.anchorCache.keys())e.has(n)||this.anchorCache.delete(n);this.applyClusterPositions(),this.pinnedFeedback&&this.showHighlight(this.pinnedFeedback);}applyClusterPositions(){for(let e of this.clusters)e.expanded?this.applyFanPositions(e):this.applyStackPositions(e);}emitMarkersChanged(){let e=this.openCount;e!==this.lastOpenCount&&(this.lastOpenCount=e,this.bus.emit("markers:changed",e));}render(e){this.clear(),e.forEach((n,i)=>{let s=this.buildEntry(n,i+1);this.entries.push(s);}),this.buildClusters(),this.liveRegion&&this.entries.length>0&&(this.liveRegion.textContent=this.t("marker.count").replace("{count}",String(this.entries.length))),this.emitMarkersChanged();}addFeedback(e,n){let i=this.buildEntry(e,n);for(let s of i.elements)s.style.animation="sp-marker-in 0.35s cubic-bezier(0.34,1.56,0.64,1) both";this.entries.push(i),this.buildClusters(),this.emitMarkersChanged();}buildEntry(e,n){let i={feedback:e,elements:[],baseTop:0,baseLeft:0};for(let s of e.annotations){let o=ve(je(s),xe(s));if(!o)continue;let r=zt(o.rect);i.baseTop=r.top,i.baseLeft=r.left;let a=this.createMarker(n,e,r);this.applyConfidenceStyle(a,o.confidence,e),this.container.appendChild(a),i.elements.push(a);}return i}buildClusters(){for(let i of this.container.querySelectorAll(".sp-cluster-badge"))i.remove();let e=[];for(let i of this.entries)for(let s=0;s<i.elements.length;s++)e.push({entry:i,elIdx:s});let n=new Set;this.clusters=[];for(let i=0;i<e.length;i++){if(n.has(i))continue;let s=e[i];if(!s)continue;let o={entries:[s.entry],elementIndices:[s.elIdx],expanded:false};n.add(i);for(let r=i+1;r<e.length;r++){if(n.has(r))continue;let a=s.entry,l=e[r];if(!l)continue;let c=l.entry;Math.sqrt((a.baseLeft-c.baseLeft)**2+(a.baseTop-c.baseTop)**2)<In&&(o.entries.push(c),o.elementIndices.push(l.elIdx),n.add(r));}this.clusters.push(o);}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:s}=n,o=e.entries.length<=1;for(let r=0;r<e.entries.length;r++){let a=te(e,r);a&&(a.style.top=`${i+(o?0:r*3)}px`,a.style.left=`${s+(o?0:r*3)}px`,a.style.zIndex=String(r+1));}}applyFanPositions(e){let n=e.entries[0];if(!n)return;let{baseTop:i,baseLeft:s}=n,o=e.entries.length,r=(o-1)*Kt,a=s-r/2;for(let l=0;l<o;l++){let c=te(e,l);c&&(c.style.top=`${i}px`,c.style.left=`${a+l*Kt}px`,c.style.zIndex=String(10+l));}}addClusterBadge(e){let n=te(e,e.entries.length-1);if(!n)return;let i=b("div",{class:"sp-cluster-badge",style:`
|
|
103
114
|
position:absolute;top:-6px;right:-6px;
|
|
104
115
|
min-width:16px;height:16px;padding:0 4px;
|
|
105
116
|
border-radius:9999px;
|
|
@@ -110,36 +121,36 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
110
121
|
pointer-events:none;
|
|
111
122
|
font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
112
123
|
line-height:1;
|
|
113
|
-
`});c(i,String(e.entries.length)),n.appendChild(i);}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let
|
|
124
|
+
`});c(i,String(e.entries.length)),n.appendChild(i);}setBadgesVisible(e,n){for(let i=0;i<e.entries.length;i++){let s=te(e,i)?.querySelector(".sp-cluster-badge");s&&(s.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(te(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 s=J$1(i.status);n<Fn&&!s?(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 s=x(n.type,this.colors),o=J$1(n.status),r=b("div",{style:`
|
|
114
125
|
position:absolute;
|
|
115
126
|
top:${i.top}px;
|
|
116
127
|
left:${i.left}px;
|
|
117
128
|
width:26px;height:26px;
|
|
118
129
|
border-radius:50%;
|
|
119
|
-
background:${
|
|
120
|
-
border:2px solid ${
|
|
130
|
+
background:${o?"rgba(241,245,249,0.9)":"rgba(255,255,255,0.92)"};
|
|
131
|
+
border:2px solid ${o?"#cbd5e1":s};
|
|
121
132
|
display:flex;align-items:center;justify-content:center;
|
|
122
133
|
font-family:"Inter",system-ui,-apple-system,sans-serif;
|
|
123
134
|
font-size:11px;font-weight:700;
|
|
124
|
-
color:${
|
|
135
|
+
color:${o?"#94a3b8":s};
|
|
125
136
|
cursor:pointer;pointer-events:auto;
|
|
126
|
-
box-shadow:${
|
|
137
|
+
box-shadow:${o?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${s}25, 0 2px 6px rgba(0,0,0,0.06)`};
|
|
127
138
|
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;
|
|
128
139
|
user-select:none;
|
|
129
140
|
-webkit-font-smoothing:antialiased;
|
|
130
|
-
`});
|
|
141
|
+
`});r.dataset.feedbackId=n.id,r.setAttribute("tabindex","0"),r.setAttribute("role","button");let a=n.message.length>60?`${n.message.slice(0,60)}...`:n.message,l=this.t("marker.aria").replace("{number}",String(e)).replace("{type}",N(n.type,this.t)).replace("{message}",a);r.setAttribute("aria-label",l),r.setAttribute("aria-describedby",this.tooltip.tooltipId),c(r,o?"\u2713":String(e)),r.addEventListener("mouseenter",()=>{r.style.transform="scale(1.2)",r.style.boxShadow=o?"0 4px 16px rgba(0,0,0,0.1)":`0 4px 20px ${s}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=o?"0 2px 8px rgba(0,0,0,0.06)":`0 2px 12px ${s}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=u=>{u instanceof MouseEvent&&this.handleClusterClick(r,u)||(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",u=>c$1(u)),r.addEventListener("keydown",u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),c$1(u));}),r}focusFeedback(e){let n=this.entries.find(s=>s.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=ve(je(n),xe(n));if(!i)continue;let s=x(e.type,this.colors),o=i.rect,r=b("div",{style:`
|
|
131
142
|
position:absolute;
|
|
132
|
-
top:${
|
|
133
|
-
left:${
|
|
134
|
-
width:${
|
|
135
|
-
border:2px solid ${
|
|
136
|
-
background:${
|
|
143
|
+
top:${o.top+window.scrollY}px;
|
|
144
|
+
left:${o.left+window.scrollX}px;
|
|
145
|
+
width:${o.width}px;height:${o.height}px;
|
|
146
|
+
border:2px solid ${s};
|
|
147
|
+
background:${s}0c;
|
|
137
148
|
border-radius:8px;
|
|
138
149
|
pointer-events:none;z-index:-1;
|
|
139
150
|
opacity:0;
|
|
140
|
-
box-shadow:0 0 16px ${
|
|
141
|
-
transition:opacity ${
|
|
142
|
-
`});this.container.appendChild(
|
|
151
|
+
box-shadow:0 0 16px ${s}20;
|
|
152
|
+
transition:opacity ${jt}ms ease;
|
|
153
|
+
`});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(),jt);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 Ee=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(K),screenshotDataUrl:e.screenshotDataUrl??null,screenshotRegion:e.screenshotRegion??null,diagnostics:e.diagnostics??null});return Xe(n)}async getFeedbacks(e,n){let{feedbacks:i,total:s}=await this.store.getFeedbacks({projectName:e,page:n?.page,limit:n?.limit,type:n?.type,status:n?.status,statuses:n?.statuses,search:n?.search,url:n?.url,urlPattern:n?.urlPattern});return {feedbacks:i.map(Xe),total:s}}async resolveFeedback(e,n){let i=await this.store.updateFeedback(e,{status:n?"resolved":"open",resolvedAt:n?new Date:null});return Xe(i)}async deleteFeedback(e){await this.store.deleteFeedback(e);}async deleteAllFeedbacks(e){await this.store.deleteAllFeedbacks(e);}};function Xe(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(Nn),screenshotUrl:t.screenshotUrl??null,screenshotRegion:t.screenshotRegion??null,diagnostics:t.diagnostics??null}}function Nn(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 $n="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)",Ke="cubic-bezier(0.16, 1, 0.3, 1)",Ye="cubic-bezier(0.34, 1.56, 0.64, 1)",Hn="cubic-bezier(0.25, 1, 0.5, 1)",Yt=`
|
|
143
154
|
/* ---- Keyframes ---- */
|
|
144
155
|
|
|
145
156
|
@keyframes sp-fab-in {
|
|
@@ -213,11 +224,11 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
213
224
|
/* ---- Animation classes ---- */
|
|
214
225
|
|
|
215
226
|
.sp-anim-fab-in {
|
|
216
|
-
animation: sp-fab-in 0.5s ${
|
|
227
|
+
animation: sp-fab-in 0.5s ${$n} both;
|
|
217
228
|
}
|
|
218
229
|
|
|
219
230
|
.sp-anim-marker-in {
|
|
220
|
-
animation: sp-marker-in 0.35s ${
|
|
231
|
+
animation: sp-marker-in 0.35s ${Ye} both;
|
|
221
232
|
}
|
|
222
233
|
|
|
223
234
|
.sp-anim-pulse {
|
|
@@ -225,11 +236,11 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
225
236
|
}
|
|
226
237
|
|
|
227
238
|
.sp-anim-flash {
|
|
228
|
-
animation: sp-flash-bg 0.5s ${
|
|
239
|
+
animation: sp-flash-bg 0.5s ${Hn};
|
|
229
240
|
}
|
|
230
241
|
|
|
231
242
|
.sp-anim-slide-up {
|
|
232
|
-
animation: sp-slide-up 0.3s ${
|
|
243
|
+
animation: sp-slide-up 0.3s ${Ke} both;
|
|
233
244
|
}
|
|
234
245
|
|
|
235
246
|
.sp-anim-fade-in {
|
|
@@ -240,7 +251,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
240
251
|
|
|
241
252
|
.sp-panel {
|
|
242
253
|
transform: translateX(110%);
|
|
243
|
-
transition: transform 0.4s ${
|
|
254
|
+
transition: transform 0.4s ${Ke};
|
|
244
255
|
}
|
|
245
256
|
|
|
246
257
|
.sp-panel.sp-panel--open {
|
|
@@ -252,7 +263,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
252
263
|
pointer-events: none;
|
|
253
264
|
transform: translate(0, 0) scale(0.8);
|
|
254
265
|
transition:
|
|
255
|
-
transform 0.35s ${
|
|
266
|
+
transform 0.35s ${Ye},
|
|
256
267
|
opacity 0.2s ease,
|
|
257
268
|
background 0.2s ease,
|
|
258
269
|
border-color 0.2s ease,
|
|
@@ -283,7 +294,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
283
294
|
}
|
|
284
295
|
|
|
285
296
|
.sp-card {
|
|
286
|
-
animation: sp-card-in 0.35s ${
|
|
297
|
+
animation: sp-card-in 0.35s ${Ke} both;
|
|
287
298
|
animation-delay: calc(var(--sp-card-i, 0) * 40ms);
|
|
288
299
|
}
|
|
289
300
|
|
|
@@ -311,7 +322,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
311
322
|
}
|
|
312
323
|
|
|
313
324
|
.sp-fab-badge {
|
|
314
|
-
animation: sp-badge-in 0.4s ${
|
|
325
|
+
animation: sp-badge-in 0.4s ${Ye} both;
|
|
315
326
|
}
|
|
316
327
|
|
|
317
328
|
/* ---- Reduced motion ---- */
|
|
@@ -324,7 +335,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
324
335
|
}
|
|
325
336
|
}
|
|
326
337
|
|
|
327
|
-
`;function
|
|
338
|
+
`;function qe(t){return `
|
|
328
339
|
:host {
|
|
329
340
|
all: initial;
|
|
330
341
|
position: fixed;
|
|
@@ -337,7 +348,7 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
337
348
|
color-scheme: ${t.bg==="#ffffff"?"light":"dark"};
|
|
338
349
|
-webkit-font-smoothing: antialiased;
|
|
339
350
|
-moz-osx-font-smoothing: grayscale;
|
|
340
|
-
${
|
|
351
|
+
${B(t)}
|
|
341
352
|
|
|
342
353
|
/* Identity modal \u2014 theme-aware backdrop + panel */
|
|
343
354
|
--sp-identity-bg: ${t.glassBgHeavy};
|
|
@@ -1495,14 +1506,14 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
1495
1506
|
}
|
|
1496
1507
|
}
|
|
1497
1508
|
|
|
1498
|
-
${
|
|
1499
|
-
${
|
|
1509
|
+
${Yt}
|
|
1510
|
+
${_}
|
|
1511
|
+
${Z$1}
|
|
1512
|
+
${R}
|
|
1513
|
+
${P}
|
|
1514
|
+
${ca}
|
|
1500
1515
|
${T}
|
|
1501
|
-
|
|
1502
|
-
${J$1}
|
|
1503
|
-
${Y$1}
|
|
1504
|
-
${N}
|
|
1505
|
-
`}var Pn=120,Fn=80,ge=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=b("div",{style:`
|
|
1516
|
+
`}var _n=120,Dn=80,ke=class{constructor(e,n="en"){this.colors=e;this.locale=n;this.root=b("div",{style:`
|
|
1506
1517
|
position: fixed;
|
|
1507
1518
|
z-index: ${2147483647};
|
|
1508
1519
|
max-width: 280px;
|
|
@@ -1528,12 +1539,12 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
1528
1539
|
border: 1px solid ${this.colors.glassBorder};
|
|
1529
1540
|
transform: rotate(45deg);
|
|
1530
1541
|
pointer-events: none;
|
|
1531
|
-
`}),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)";},
|
|
1542
|
+
`}),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)";},_n));}scheduleHide(){this.cancelHide(),this.hideTimer=setTimeout(()=>this.hide(),Dn);}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 h of n)h!==this.arrow&&h.remove();let i=x(e$1.type,this.colors),s=A(e$1.type,this.colors),o=M(this.locale),r=N(e$1.type,o),a=b("div",{style:"display:flex;align-items:center;gap:8px;margin-bottom:8px;"}),l=b("span",{style:`
|
|
1532
1543
|
padding:3px 10px;border-radius:9999px;
|
|
1533
1544
|
font-size:11px;font-weight:600;
|
|
1534
|
-
color:${i};background:${
|
|
1545
|
+
color:${i};background:${s};
|
|
1535
1546
|
letter-spacing:0.02em;
|
|
1536
|
-
`});c(l,
|
|
1547
|
+
`});c(l,r);let c$1=b("span",{style:`font-size:11px;color:${this.colors.textSecondary};margin-left:auto;`});c(c$1,e(e$1.createdAt,this.locale)),a.appendChild(l),a.appendChild(c$1);let u=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(u,e$1.message),this.root.insertBefore(a,this.arrow),this.root.insertBefore(u,this.arrow);}position(e){let n=this.root.getBoundingClientRect(),i=10,s=e.top-n.height-i,o=e.left+e.width/2-n.width/2,r=true;s<8&&(s=e.bottom+i,r=false),o=Math.max(8,Math.min(o,window.innerWidth-n.width-8)),this.root.style.top=`${s}px`,this.root.style.left=`${o}px`;let a=Math.max(16,Math.min(e.left+e.width/2-o-6,n.width-22));r?this.arrow.style.cssText=`
|
|
1537
1548
|
position:absolute;
|
|
1538
1549
|
width:12px;height:12px;
|
|
1539
1550
|
background:${this.colors.glassBgHeavy};
|
|
@@ -1553,8 +1564,8 @@ ${t.stack}`:""}`;try{let e=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof
|
|
|
1553
1564
|
pointer-events:none;
|
|
1554
1565
|
top:-6px;
|
|
1555
1566
|
left:${a}px;
|
|
1556
|
-
`;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var
|
|
1557
|
-
${
|
|
1567
|
+
`;}contains(e){return this.root.contains(e)}destroy(){this.cancelShow(),this.cancelHide(),this.root.remove();}};var ne=null;function On(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 Se(){let t=()=>{};return {destroy:t,open:t,close:t,refresh:t,focusFeedback:()=>false,on:()=>t,off:t}}function Bn(t){return t===void 0||t===false?{enabled:false,param:"siteping"}:t===true?{enabled:true,param:"siteping"}:{enabled:true,param:t.param??"siteping"}}function qt(t){let e=t.debug?(...d)=>console.debug("[siteping]",...d):()=>{};if(ne)return e("initSiteping() called more than once \u2014 returning existing instance"),ne;if(!t.forceShow)try{if(typeof process<"u")return t.onSkip?.("production"),Se()}catch{}let n=typeof t.minViewportWidth=="number"&&Number.isFinite(t.minViewportWidth)?t.minViewportWidth:768;if(!t.forceShow&&window.innerWidth<n){let d="mobile";return t.onSkip?.(d),Se()}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."),Se();if(!t.projectName||typeof t.projectName!="string")return console.error("[siteping] Missing or invalid 'projectName' in config. Expected a non-empty string."),Se();let i=t.locale??"en",s=i==="en"?Promise.resolve():L(i).catch(()=>{}),o=M(i),r=t.scopeAnnotationsByUrl??true,a=()=>{try{let d=t.getPageScope?.();if(d)return d}catch(d){e("getPageScope() threw, falling back to pathname:",d);}return {url:window.location.pathname,urlPattern:null}};e("Initializing widget",{projectName:t.projectName,theme:t.theme??"light",locale:i,scopeAnnotationsByUrl:r});let l=On(t.captureDiagnostics),c=l.console?new me(l.maxConsoleEntries):null,u=l.network?new be(l.maxNetworkEntries):null,h=w(t.accentColor,t.theme),p=new ee,f=new ee,v=(()=>{if(t.store)return new Ee(t.store,t.projectName);let d=t.endpoint;if(typeof d!="string"||d.length===0)throw new Error("[siteping] internal invariant: endpoint must be a non-empty string in HTTP mode");return new fe(d,t.projectName)})();t.onOpen&&p.on("open",t.onOpen),t.onClose&&p.on("close",t.onClose),t.onFeedbackSent&&p.on("feedback:sent",t.onFeedbackSent),t.onError&&p.on("feedback:error",t.onError),t.onAnnotationStart&&p.on("annotation:start",t.onAnnotationStart),t.onAnnotationEnd&&p.on("annotation:end",t.onAnnotationEnd),p.on("feedback:sent",d=>f.emit("feedback:sent",d)),p.on("feedback:deleted",d=>f.emit("feedback:deleted",d)),p.on("open",()=>f.emit("panel:open")),p.on("close",()=>f.emit("panel:close")),p.on("open",()=>e("Panel opened")),p.on("close",()=>e("Panel closed")),p.on("feedback:sent",d=>e("Feedback sent",d.id)),p.on("feedback:error",d=>e("Feedback failed",d.message)),p.on("annotation:start",()=>e("Annotation started")),p.on("annotation:end",()=>e("Annotation ended"));let T=document.createElement("siteping-widget");T.style.cssText=`position:fixed;z-index:${2147483647};`;let k=false;try{typeof process<"u"&&process.env?.["NODE_ENV"]==="test"&&(k=!0);}catch{}let F=k?"open":"closed",C=T.attachShadow({mode:F});if("adoptedStyleSheets"in ShadowRoot.prototype){let d=new CSSStyleSheet;d.replaceSync(qe(h)),C.adoptedStyleSheets=[d];}else {let d=document.createElement("style");d.textContent=qe(h),C.appendChild(d);}document.body.appendChild(T);let w$1=document.createElement("div");w$1.setAttribute("role","status"),w$1.setAttribute("aria-live","polite"),w$1.setAttribute("aria-atomic","true"),w$1.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;",document.body.appendChild(w$1);let S=new ke(h,i),y=new we(h,S,p,o,w$1),M$1=new ge(C,t,p,o);p.on("markers:changed",d=>M$1.updateBadge(d));let E=null,$=null,A=false,ie=0;async function Ue(){return A?null:E||($||($=import('./panel-5ZGIFFJ4.js').then(d=>A?null:(E=new d.Panel(C,h,p,v,t.projectName,y,o,i,{getScope:a,scopeAnnotationsByUrl:r}),E))),$)}if(typeof window<"u"){let d=()=>{A||Ue();},m=window.requestIdleCallback;typeof m=="function"?m(d):setTimeout(d,200);}let O=false,Ut=p.on("panel:toggle",d=>{E||(d?(O=true,Ue().then(m=>{m&&O&&m.open(),O=false;}).catch(m=>e("Failed to lazy-load panel:",m))):O=false);}),oe=new ue(h,p,o,t.enableScreenshot??false),se=null;t.enableRightClickComment&&(se=d=>{d.defaultPrevented||d.shiftKey||d.ctrlKey||d.altKey||d.metaKey||d.composedPath().some(b=>b===T||b instanceof Element&&(b.hasAttribute("data-siteping-ignore")||b.id==="siteping-markers"))||oe.isBusy||(d.preventDefault(),oe.startInstantAnnotation(d.clientX,d.clientY).catch(b=>e("right-click annotation failed",b)));},document.addEventListener("contextmenu",se)),i!=="en"&&s.then(()=>{A||(M$1.refreshLabels(),oe.refreshLabels());});let Te=false,Gt=p.on("annotation:complete",async d=>{if(Te){p.emit("submission:cancelled");return}Te=true;try{let{annotation:m,type:b,message:L,screenshotDataUrl:B,screenshotRegion:z}=d,P=t.identity??Be();if(!P){if(P=await zn(C,o),!P){p.emit("submission:cancelled");return}Ot(P);}let R=(()=>{try{return crypto.randomUUID()}catch{return `${Date.now()}-${Math.random().toString(36).slice(2)}`}})(),Y=a(),Je=null;(c||u)&&(Je={console:c?.getEntries()??[],network:u?.getEntries()??[]});let Zt={projectName:t.projectName,type:b,message:L,url:Y.url,urlPattern:Y.urlPattern,viewport:`${window.innerWidth}x${window.innerHeight}`,userAgent:navigator.userAgent,authorName:P.name,authorEmail:P.email,annotations:[m],clientId:R,screenshotDataUrl:B??null,screenshotRegion:z??null,diagnostics:Je};try{let H=await v.sendFeedback(Zt);p.emit("feedback:sent",H),(!r||H.url===Y.url)&&y.addFeedback(H,y.count+1),w$1.textContent=o("feedback.sent.confirmation"),E&&await E.refresh();}catch(H){p.emit("feedback:error",H instanceof Error?H:new Error(String(H))),w$1.textContent=o("feedback.error.message");}}finally{Te=false;}}),Ce=a(),Vt=r?{limit:20,url:Ce.url}:{limit:20},Ae=Bn(t.deepLink),Jt=++ie;Promise.all([v.getFeedbacks(t.projectName,Vt),s]).then(([{feedbacks:d}])=>{if(A||ie!==Jt)return;let m=r?d.filter(b=>b.url===Ce.url):d;if(y.render(m),Ae.enabled)try{let b=new URLSearchParams(window.location.search).get(Ae.param);if(b){let L=y.focusFeedback(b);e(`deepLink ?${Ae.param}=${b} ${L?"focused":"did not match a visible feedback"}`);}}catch(b){e("deepLink parsing failed:",b);}}).catch(d=>{e("Failed to load initial markers:",d);}),t.endpoint&&$t(t.endpoint,t.identity??Be()).then(()=>e("Retry queue flushed")).catch(()=>{});let Ge=()=>{let d=++ie;if(E?.isCurrentlyOpen)return E.refresh();let m=a(),b=r?{limit:20,url:m.url}:{limit:20};return v.getFeedbacks(t.projectName,b).then(({feedbacks:L})=>{if(A||d!==ie||E?.isCurrentlyOpen)return;let B=r?L.filter(z=>z.url===m.url):L;y.render(B);})},Ve=null;if(t.watchNavigation!==false&&typeof window<"u"&&typeof history<"u"){let d=R=>`${R.url}
|
|
1568
|
+
${R.urlPattern??""}`,m=d(Ce),b=()=>{if(A)return;let R=d(a());if(R===m)return;let Y=m;m=R,e("SPA navigation detected \u2014 refreshing feedbacks for new scope"),Ge().catch(()=>{m===R&&(m=Y);});},L=history.pushState,B=history.replaceState,z=function(...R){L.apply(this,R),b();},P=function(...R){B.apply(this,R),b();};history.pushState=z,history.replaceState=P,window.addEventListener("popstate",b),window.addEventListener("hashchange",b),Ve=()=>{window.removeEventListener("popstate",b),window.removeEventListener("hashchange",b),history.pushState===z&&(history.pushState=L),history.replaceState===P&&(history.replaceState=B);};}return ne={destroy:()=>{e("Destroying widget"),se&&document.removeEventListener("contextmenu",se),A=true,O=false,Ve?.(),Gt(),Ut(),M$1.destroy(),E?.destroy(),oe.destroy(),y.destroy(),S.destroy(),c?.dispose(),u?.dispose(),p.removeAll(),f.removeAll(),w$1.remove(),T.remove(),ne=null;},open:()=>{p.emit("panel:toggle",true);},close:()=>{E?E.close():O=false;},focusFeedback:d=>y.focusFeedback(d),refresh:()=>{Ge().catch(()=>{});},on:(d,m)=>f.on(d,m),off:(d,m)=>{f.off(d,m);}},ne}function zn(t,e){return new Promise(n=>{let i=t.activeElement??document.activeElement,s=t.host;s.parentNode&&s.parentNode.appendChild(s);let o=document.createElement("div");o.style.cssText=`
|
|
1558
1569
|
position:fixed;inset:0;
|
|
1559
1570
|
background:var(--sp-identity-overlay);
|
|
1560
1571
|
backdrop-filter:blur(8px);
|
|
@@ -1562,7 +1573,7 @@ ${E.urlPattern??""}`,f=h(xe),y=()=>{if(k)return;let E=h(a());if(E===f)return;let
|
|
|
1562
1573
|
display:flex;align-items:center;justify-content:center;
|
|
1563
1574
|
z-index:${2147483647};
|
|
1564
1575
|
opacity:0;transition:opacity 0.25s ease;
|
|
1565
|
-
`;let
|
|
1576
|
+
`;let r=document.createElement("div");r.style.cssText=`
|
|
1566
1577
|
width:340px;padding:28px;border-radius:var(--sp-radius-xl);
|
|
1567
1578
|
background:var(--sp-identity-bg);
|
|
1568
1579
|
backdrop-filter:blur(var(--sp-blur-heavy));
|
|
@@ -1574,5 +1585,5 @@ ${E.urlPattern??""}`,f=h(xe),y=()=>{if(k)return;let E=h(a());if(E===f)return;let
|
|
|
1574
1585
|
transform:translateY(12px) scale(0.97);
|
|
1575
1586
|
transition:transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
|
1576
1587
|
-webkit-font-smoothing:antialiased;
|
|
1577
|
-
`;let a=`sp-identity-title-${Date.now()}`;
|
|
1588
|
+
`;let a=`sp-identity-title-${Date.now()}`;r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-labelledby",a);let l=document.createElement("div");l.className="sp-identity-title",l.id=a,l.textContent=e("identity.title"),l.style.marginBottom="20px";let c=`sp-identity-name-${Date.now()}`,u=`sp-identity-email-${Date.now()}`,h=document.createElement("label");h.className="sp-input-label",h.textContent=e("identity.nameLabel"),h.setAttribute("for",c);let p=document.createElement("input");p.className="sp-input",p.id=c,p.type="text",p.placeholder=e("identity.namePlaceholder"),p.style.marginBottom="14px";let f=document.createElement("label");f.className="sp-input-label",f.textContent=e("identity.emailLabel"),f.setAttribute("for",u);let v=document.createElement("input");v.className="sp-input",v.id=u,v.type="email",v.placeholder=e("identity.emailPlaceholder");let T=document.createElement("div");T.style.cssText="display:flex;gap:8px;justify-content:flex-end;margin-top:20px;";let k=S=>{o.removeEventListener("keydown",w),o.style.opacity="0",r.style.transform="translateY(12px) scale(0.97)",setTimeout(()=>{o.remove(),i?.focus(),n(S);},250);},F=document.createElement("button");F.className="sp-btn-ghost",F.textContent=e("identity.cancel"),F.addEventListener("click",()=>k(null));let C=document.createElement("button");C.className="sp-btn-primary",C.textContent=e("identity.submit"),C.addEventListener("click",()=>{let S=p.value.trim(),y=v.value.trim();if(!S||!y)return;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(y)){v.style.borderColor="var(--sp-type-bug, #ef4444)";return}k({name:S,email:y});});let K='input, button, [tabindex]:not([tabindex="-1"])',w=S=>{let y=S;if(y.key==="Escape"){k(null);return}if(y.key==="Tab"){let M=Array.from(r.querySelectorAll(K));if(M.length===0)return;let E=M[0],$=M[M.length-1];if(!E||!$)return;let A=t.activeElement;y.shiftKey?(A===E||!r.contains(A))&&(y.preventDefault(),$.focus()):(A===$||!r.contains(A))&&(y.preventDefault(),E.focus());}};o.addEventListener("keydown",w),o.addEventListener("click",S=>{S.target===o&&k(null);}),T.appendChild(F),T.appendChild(C),r.appendChild(l),r.appendChild(h),r.appendChild(p),r.appendChild(f),r.appendChild(v),r.appendChild(T),o.appendChild(r),t.appendChild(o),requestAnimationFrame(()=>{o.style.opacity="1",r.style.transform="translateY(0) scale(1)",p.focus();});})}function Wt(t){return qt(t)}function fo(t){let e=useRef(t);e.current=t;let[n,i]=useState(null);return useEffect(()=>{let s=true,o=Wt(e.current);if(!s){o.destroy();return}let r=o.on("feedback:sent",c=>{e.current.onFeedbackSent?.(c);}),a=o.on("panel:open",()=>{e.current.onOpen?.();}),l=o.on("panel:close",()=>{e.current.onClose?.();});return i(o),()=>{s=false,r(),a(),l(),o.destroy(),i(null);}},[]),n}export{fo as useSiteping};//# sourceMappingURL=react.js.map
|
|
1578
1589
|
//# sourceMappingURL=react.js.map
|