makethisbetter 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +8 -0
- package/dist/index.d.mts +8 -0
- package/dist/makethisbetter.cjs +4 -4
- package/dist/makethisbetter.cjs.map +1 -1
- package/dist/makethisbetter.esm.js +34 -23
- package/dist/makethisbetter.esm.js.map +1 -1
- package/dist/makethisbetter.js +3 -3
- package/dist/makethisbetter.js.map +1 -1
- package/dist/widget/controller.d.ts +2 -0
- package/dist/widget/controller.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/widget/controller.test.ts +141 -0
- package/src/widget/controller.ts +38 -8
package/dist/index.d.cts
ADDED
package/dist/index.d.mts
ADDED
package/dist/makethisbetter.cjs
CHANGED
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
</div>
|
|
110
110
|
${r}
|
|
111
111
|
${n}
|
|
112
|
-
`}clarifiedPairs(){const t=[];for(let e=0;e<this.lastMessages.length-1;e++){const r=this.lastMessages[e],s=this.lastMessages[e+1];r.role!=="user"&&s.role==="user"&&t.push({q:r.content,a:s.content})}return t}renderConversation(t,e){this.lastMessages=t,this.renderMessages(t);const r=t[t.length-1];!e&&(!r||r.role==="user")&&this.showThinking()}renderMessages(t){this.messagesEl.innerHTML="";for(const e of t)this.appendMessage(e);this.messagesEl.scrollTop=this.messagesEl.scrollHeight}appendMessage(t){const e=document.createElement("div");e.className=t.role==="user"?"mtb-clarify-bubble mtb-clarify-user":"mtb-clarify-bubble mtb-clarify-ai",e.textContent=t.content,this.messagesEl.appendChild(e),this.messagesEl.scrollTop=this.messagesEl.scrollHeight}showThinking(){if(this.messagesEl.querySelector(".mtb-clarify-thinking"))return;const t=document.createElement("div");t.className="mtb-clarify-bubble mtb-clarify-ai mtb-clarify-thinking",t.innerHTML='<span class="mtb-dot"></span><span class="mtb-dot"></span><span class="mtb-dot"></span>',this.messagesEl.appendChild(t),this.messagesEl.scrollTop=this.messagesEl.scrollHeight}removeThinking(){this.messagesEl.querySelector(".mtb-clarify-thinking")?.remove()}destroy(){this.destroyed=!0,this.stopPolling(),this.el.remove()}}const
|
|
112
|
+
`}clarifiedPairs(){const t=[];for(let e=0;e<this.lastMessages.length-1;e++){const r=this.lastMessages[e],s=this.lastMessages[e+1];r.role!=="user"&&s.role==="user"&&t.push({q:r.content,a:s.content})}return t}renderConversation(t,e){this.lastMessages=t,this.renderMessages(t);const r=t[t.length-1];!e&&(!r||r.role==="user")&&this.showThinking()}renderMessages(t){this.messagesEl.innerHTML="";for(const e of t)this.appendMessage(e);this.messagesEl.scrollTop=this.messagesEl.scrollHeight}appendMessage(t){const e=document.createElement("div");e.className=t.role==="user"?"mtb-clarify-bubble mtb-clarify-user":"mtb-clarify-bubble mtb-clarify-ai",e.textContent=t.content,this.messagesEl.appendChild(e),this.messagesEl.scrollTop=this.messagesEl.scrollHeight}showThinking(){if(this.messagesEl.querySelector(".mtb-clarify-thinking"))return;const t=document.createElement("div");t.className="mtb-clarify-bubble mtb-clarify-ai mtb-clarify-thinking",t.innerHTML='<span class="mtb-dot"></span><span class="mtb-dot"></span><span class="mtb-dot"></span>',this.messagesEl.appendChild(t),this.messagesEl.scrollTop=this.messagesEl.scrollHeight}removeThinking(){this.messagesEl.querySelector(".mtb-clarify-thinking")?.remove()}destroy(){this.destroyed=!0,this.stopPolling(),this.el.remove()}}const Kt=5e3,Xt=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;class Gt{constructor(t,e,r,s,n){this.messages=e,this.el=t.el("div","mtb-success"),this.el.style.right="20px",this.el.style.bottom="20px";const o=n?.skipFollowup?e.success.title_no_ai:e.success.title,a=n?.skipFollowup?e.success.message_no_ai:e.success.message,l=s?`<button class="mtb-view-feedback-link">${e.success.view_feedback} <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"/></svg></button>`:"",c=n?.emailCapture?`
|
|
113
113
|
<div class="mtb-email-capture">
|
|
114
114
|
<div class="mtb-email-prompt">${e.success.email_prompt}</div>
|
|
115
115
|
<div class="mtb-email-row">
|
|
@@ -128,8 +128,8 @@
|
|
|
128
128
|
${c}
|
|
129
129
|
${l}
|
|
130
130
|
<button class="mtb-close-link">${e.success.close}</button>
|
|
131
|
-
`,t.append(this.el),this.el.querySelector(".mtb-close-link").addEventListener("click",r),s&&this.el.querySelector(".mtb-view-feedback-link").addEventListener("click",s),n?.emailCapture?this.bindEmailCapture(n.emailCapture.onSubmit):setTimeout(()=>r(),Xt)}bindEmailCapture(t){const e=this.el.querySelector(".mtb-email-input"),r=this.el.querySelector(".mtb-email-submit"),s=this.el.querySelector(".mtb-email-error"),n=async()=>{const o=e.value.trim();if(!Kt.test(o)){e.classList.add("mtb-email-invalid");return}e.classList.remove("mtb-email-invalid"),s.hidden=!0,r.disabled=!0,await t(o)?this.el.querySelector(".mtb-email-capture").innerHTML=`<div class="mtb-email-saved">${this.messages.success.email_saved}</div>`:(s.hidden=!1,r.disabled=!1)};r.addEventListener("click",n),e.addEventListener("keydown",o=>{o.key==="Enter"&&n()})}destroy(){this.el.remove()}}function Jt(i,t){if(i.match(/^[a-z]+:\/\//i))return i;if(i.match(/^\/\//))return window.location.protocol+i;if(i.match(/^[a-z]+:/i))return i;const e=document.implementation.createHTMLDocument(),r=e.createElement("base"),s=e.createElement("a");return e.head.appendChild(r),e.body.appendChild(s),t&&(r.href=t),s.href=i,s.href}const Qt=(()=>{let i=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(i+=1,`u${t()}${i}`)})();function f(i){const t=[];for(let e=0,r=i.length;e<r;e++)t.push(i[e]);return t}let g=null;function ot(i={}){return g||(i.includeStyleProperties?(g=i.includeStyleProperties,g):(g=f(window.getComputedStyle(document.documentElement)),g))}function _(i,t){const r=(i.ownerDocument.defaultView||window).getComputedStyle(i).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Zt(i){const t=_(i,"border-left-width"),e=_(i,"border-right-width");return i.clientWidth+t+e}function te(i){const t=_(i,"border-top-width"),e=_(i,"border-bottom-width");return i.clientHeight+t+e}function at(i,t={}){const e=t.width||Zt(i),r=t.height||te(i);return{width:e,height:r}}function ee(){let i,t;try{t=process}catch{}const e=t&&t.env?t.env.devicePixelRatio:null;return e&&(i=parseInt(e,10),Number.isNaN(i)&&(i=1)),i||window.devicePixelRatio||1}const m=16384;function ie(i){(i.width>m||i.height>m)&&(i.width>m&&i.height>m?i.width>i.height?(i.height*=m/i.width,i.width=m):(i.width*=m/i.height,i.height=m):i.width>m?(i.height*=m/i.width,i.width=m):(i.width*=m/i.height,i.height=m))}function T(i){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=e,r.crossOrigin="anonymous",r.decoding="async",r.src=i})}async function re(i){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function se(i,t,e){const r="http://www.w3.org/2000/svg",s=document.createElementNS(r,"svg"),n=document.createElementNS(r,"foreignObject");return s.setAttribute("width",`${t}`),s.setAttribute("height",`${e}`),s.setAttribute("viewBox",`0 0 ${t} ${e}`),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("externalResourcesRequired","true"),s.appendChild(n),n.appendChild(i),re(s)}const u=(i,t)=>{if(i instanceof t)return!0;const e=Object.getPrototypeOf(i);return e===null?!1:e.constructor.name===t.name||u(e,t)};function ne(i){const t=i.getPropertyValue("content");return`${i.cssText} content: '${t.replace(/'|"/g,"")}';`}function oe(i,t){return ot(t).map(e=>{const r=i.getPropertyValue(e),s=i.getPropertyPriority(e);return`${e}: ${r}${s?" !important":""};`}).join(" ")}function ae(i,t,e,r){const s=`.${i}:${t}`,n=e.cssText?ne(e):oe(e,r);return document.createTextNode(`${s}{${n}}`)}function j(i,t,e,r){const s=window.getComputedStyle(i,e),n=s.getPropertyValue("content");if(n===""||n==="none")return;const o=Qt();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(ae(o,e,s,r)),t.appendChild(a)}function le(i,t,e){j(i,t,":before",e),j(i,t,":after",e)}const q="application/font-woff",N="image/jpeg",ce={woff:q,woff2:q,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:N,jpeg:N,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function de(i){const t=/\.([^./]*?)$/g.exec(i);return t?t[1]:""}function $(i){const t=de(i).toLowerCase();return ce[t]||""}function he(i){return i.split(/,/)[1]}function R(i){return i.search(/^(data:)/)!==-1}function ue(i,t){return`data:${t};base64,${i}`}async function lt(i,t,e){const r=await fetch(i,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const s=await r.blob();return new Promise((n,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{n(e({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(s)})}const D={};function me(i,t,e){let r=i.replace(/\?.*/,"");return e&&(r=i),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function B(i,t,e){const r=me(i,t,e.includeQueryParams);if(D[r]!=null)return D[r];e.cacheBust&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let s;try{const n=await lt(i,e.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),he(a)));s=ue(n,t)}catch(n){s=e.imagePlaceholder||"";let o=`Failed to fetch resource: ${i}`;n&&(o=typeof n=="string"?n:n.message),o&&console.warn(o)}return D[r]=s,s}async function pe(i){const t=i.toDataURL();return t==="data:,"?i.cloneNode(!1):T(t)}async function fe(i,t){if(i.currentSrc){const n=document.createElement("canvas"),o=n.getContext("2d");n.width=i.clientWidth,n.height=i.clientHeight,o?.drawImage(i,0,0,n.width,n.height);const a=n.toDataURL();return T(a)}const e=i.poster,r=$(e),s=await B(e,r,t);return T(s)}async function be(i,t){var e;try{if(!((e=i?.contentDocument)===null||e===void 0)&&e.body)return await L(i.contentDocument.body,t,!0)}catch{}return i.cloneNode(!1)}async function ge(i,t){return u(i,HTMLCanvasElement)?pe(i):u(i,HTMLVideoElement)?fe(i,t):u(i,HTMLIFrameElement)?be(i,t):i.cloneNode(ct(i))}const ye=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SLOT",ct=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SVG";async function we(i,t,e){var r,s;if(ct(t))return t;let n=[];return ye(i)&&i.assignedNodes?n=f(i.assignedNodes()):u(i,HTMLIFrameElement)&&(!((r=i.contentDocument)===null||r===void 0)&&r.body)?n=f(i.contentDocument.body.childNodes):n=f(((s=i.shadowRoot)!==null&&s!==void 0?s:i).childNodes),n.length===0||u(i,HTMLVideoElement)||await n.reduce((o,a)=>o.then(()=>L(a,e)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function xe(i,t,e){const r=t.style;if(!r)return;const s=window.getComputedStyle(i);s.cssText?(r.cssText=s.cssText,r.transformOrigin=s.transformOrigin):ot(e).forEach(n=>{let o=s.getPropertyValue(n);n==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),u(i,HTMLIFrameElement)&&n==="display"&&o==="inline"&&(o="block"),n==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(n,o,s.getPropertyPriority(n))})}function ve(i,t){u(i,HTMLTextAreaElement)&&(t.innerHTML=i.value),u(i,HTMLInputElement)&&t.setAttribute("value",i.value)}function ke(i,t){if(u(i,HTMLSelectElement)){const e=t,r=Array.from(e.children).find(s=>i.value===s.getAttribute("value"));r&&r.setAttribute("selected","")}}function Se(i,t,e){return u(t,Element)&&(xe(i,t,e),le(i,t,e),ve(i,t),ke(i,t)),t}async function Ee(i,t){const e=i.querySelectorAll?i.querySelectorAll("use"):[];if(e.length===0)return i;const r={};for(let n=0;n<e.length;n++){const a=e[n].getAttribute("xlink:href");if(a){const l=i.querySelector(a),c=document.querySelector(a);!l&&c&&!r[a]&&(r[a]=await L(c,t,!0))}}const s=Object.values(r);if(s.length){const n="http://www.w3.org/1999/xhtml",o=document.createElementNS(n,"svg");o.setAttribute("xmlns",n),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(n,"defs");o.appendChild(a);for(let l=0;l<s.length;l++)a.appendChild(s[l]);i.appendChild(o)}return i}async function L(i,t,e){return!e&&t.filter&&!t.filter(i)?null:Promise.resolve(i).then(r=>ge(r,t)).then(r=>we(i,r,t)).then(r=>Se(i,r,t)).then(r=>Ee(r,t))}const dt=/url\((['"]?)([^'"]+?)\1\)/g,Ce=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,_e=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Te(i){const t=i.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Me(i){const t=[];return i.replace(dt,(e,r,s)=>(t.push(s),e)),t.filter(e=>!R(e))}async function Le(i,t,e,r,s){try{const n=e?Jt(t,e):t,o=$(t);let a;return s||(a=await B(n,o,r)),i.replace(Te(t),`$1${a}$3`)}catch{}return i}function Pe(i,{preferredFontFormat:t}){return t?i.replace(_e,e=>{for(;;){const[r,,s]=Ce.exec(e)||[];if(!s)return"";if(s===t)return`src: ${r};`}}):i}function ht(i){return i.search(dt)!==-1}async function ut(i,t,e){if(!ht(i))return i;const r=Pe(i,e);return Me(r).reduce((n,o)=>n.then(a=>Le(a,o,t,e)),Promise.resolve(r))}async function y(i,t,e){var r;const s=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(i);if(s){const n=await ut(s,null,e);return t.style.setProperty(i,n,t.style.getPropertyPriority(i)),!0}return!1}async function Ae(i,t){await y("background",i,t)||await y("background-image",i,t),await y("mask",i,t)||await y("-webkit-mask",i,t)||await y("mask-image",i,t)||await y("-webkit-mask-image",i,t)}async function De(i,t){const e=u(i,HTMLImageElement);if(!(e&&!R(i.src))&&!(u(i,SVGImageElement)&&!R(i.href.baseVal)))return;const r=e?i.src:i.href.baseVal,s=await B(r,$(r),t);await new Promise((n,o)=>{i.onload=n,i.onerror=t.onImageErrorHandler?(...l)=>{try{n(t.onImageErrorHandler(...l))}catch(c){o(c)}}:o;const a=i;a.decode&&(a.decode=n),a.loading==="lazy"&&(a.loading="eager"),e?(i.srcset="",i.src=s):i.href.baseVal=s})}async function Re(i,t){const r=f(i.childNodes).map(s=>mt(s,t));await Promise.all(r).then(()=>i)}async function mt(i,t){u(i,Element)&&(await Ae(i,t),await De(i,t),await Re(i,t))}function Ie(i,t){const{style:e}=i;t.backgroundColor&&(e.backgroundColor=t.backgroundColor),t.width&&(e.width=`${t.width}px`),t.height&&(e.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(s=>{e[s]=r[s]}),i}const W={};async function V(i){let t=W[i];if(t!=null)return t;const r=await(await fetch(i)).text();return t={url:i,cssText:r},W[i]=t,t}async function Y(i,t){let e=i.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,n=(e.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,i.url).href),lt(a,t.fetchRequestInit,({result:l})=>(e=e.replace(o,`url(${l})`),[o,l]))});return Promise.all(n).then(()=>e)}function X(i){if(i==null)return[];const t=[],e=/(\/\*[\s\S]*?\*\/)/gi;let r=i.replace(e,"");const s=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=s.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(s,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=n.exec(r);if(l===null){if(l=a.exec(r),l===null)break;n.lastIndex=a.lastIndex}else a.lastIndex=n.lastIndex;t.push(l[0])}return t}async function He(i,t){const e=[],r=[];return i.forEach(s=>{if("cssRules"in s)try{f(s.cssRules||[]).forEach((n,o)=>{if(n.type===CSSRule.IMPORT_RULE){let a=o+1;const l=n.href,c=V(l).then(h=>Y(h,t)).then(h=>X(h).forEach(p=>{try{s.insertRule(p,p.startsWith("@import")?a+=1:s.cssRules.length)}catch(x){console.error("Error inserting rule from remote css",{rule:p,error:x})}})).catch(h=>{console.error("Error loading remote css",h.toString())});r.push(c)}})}catch(n){const o=i.find(a=>a.href==null)||document.styleSheets[0];s.href!=null&&r.push(V(s.href).then(a=>Y(a,t)).then(a=>X(a).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",n)}}),Promise.all(r).then(()=>(i.forEach(s=>{if("cssRules"in s)try{f(s.cssRules||[]).forEach(n=>{e.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${s.href}`,n)}}),e))}function $e(i){return i.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>ht(t.style.getPropertyValue("src")))}async function Be(i,t){if(i.ownerDocument==null)throw new Error("Provided element is not within a Document");const e=f(i.ownerDocument.styleSheets),r=await He(e,t);return $e(r)}function pt(i){return i.trim().replace(/["']/g,"")}function Fe(i){const t=new Set;function e(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(n=>{t.add(pt(n))}),Array.from(r.children).forEach(n=>{n instanceof HTMLElement&&e(n)})}return e(i),t}async function ze(i,t){const e=await Be(i,t),r=Fe(i);return(await Promise.all(e.filter(n=>r.has(pt(n.style.fontFamily))).map(n=>{const o=n.parentStyleSheet?n.parentStyleSheet.href:null;return ut(n.cssText,o,t)}))).join(`
|
|
132
|
-
`)}async function Oe(i,t){const e=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await ze(i,t);if(e){const r=document.createElement("style"),s=document.createTextNode(e);r.appendChild(s),i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r)}}async function Ue(i,t={}){const{width:e,height:r}=at(i,t),s=await L(i,t,!0);return await Oe(s,t),await mt(s,t),Ie(s,t),await se(s,e,r)}async function je(i,t={}){const{width:e,height:r}=at(i,t),s=await Ue(i,t),n=await T(s),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||ee(),c=t.canvasWidth||e,h=t.canvasHeight||r;return o.width=c*l,o.height=h*l,t.skipAutoScale||ie(o),o.style.width=`${c}`,o.style.height=`${h}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(n,0,0,o.width,o.height),o}async function qe(i,t={}){return(await je(i,t)).toDataURL("image/jpeg",t.quality||1)}async function Ne(i=[]){try{const t=await qe(document.body,{quality:.85,pixelRatio:1,backgroundColor:"#ffffff",skipFonts:!0,skipAutoScale:!1,filter:e=>!(e instanceof HTMLElement&&e.id==="mtb-widget-host")});if(i.length>0){const e=await We(t,i);if(e)return e}return Je(t)}catch{return null}}async function We(i,t){const e=document.createElement("canvas"),r=e.getContext("2d");if(!r)return null;const s=await Ke(i);if(!s)return null;e.width=s.naturalWidth||window.innerWidth,e.height=s.naturalHeight||window.innerHeight,r.drawImage(s,0,0);const n=e.width/window.innerWidth,o=e.height/window.innerHeight;let a=0;for(const l of t)l.type==="draw"&&l.drawPath?Ve(r,l.drawPath,n,o):l.type==="pin"&&Ye(r,l.x*n,l.y*o,++a);return Ge(e)}function Ve(i,t,e,r){i.save(),i.strokeStyle=M,i.lineWidth=3.5,i.lineCap="round",i.lineJoin="round",i.shadowColor="rgba(5,150,105,0.35)",i.shadowOffsetY=1,i.shadowBlur=2;for(const s of Xe(t))if(s.length!==0){i.beginPath(),i.moveTo(s[0][0]*e,s[0][1]*r);for(let n=1;n<s.length;n++)i.lineTo(s[n][0]*e,s[n][1]*r);i.stroke()}i.restore()}function Ye(i,t,e,r){i.save(),i.shadowColor="rgba(5,150,105,0.45)",i.shadowOffsetY=2,i.shadowBlur=8,i.fillStyle=M,i.beginPath(),i.arc(t,e,11,0,Math.PI*2),i.fill(),i.shadowColor="transparent",i.lineWidth=2,i.strokeStyle="#ffffff",i.stroke(),i.fillStyle="#ffffff",i.font=`700 10px ${Bt}`,i.textAlign="center",i.textBaseline="middle",i.fillText(String(r),t,e),i.restore()}function Xe(i){const t=[];let e=null;const r=i.match(/[ML]\s*[-\d.]+\s+[-\d.]+/g)??[];for(const s of r){const[n,o]=s.slice(1).trim().split(/\s+/).map(Number);Number.isNaN(n)||Number.isNaN(o)||(s[0]==="M"?(e=[[n,o]],t.push(e)):e&&e.push([n,o]))}return t}function Ke(i){return new Promise(t=>{const e=new Image;e.onload=()=>t(e),e.onerror=()=>t(null),e.src=i})}function Ge(i){return new Promise(t=>{try{i.toBlob(e=>t(e),"image/jpeg",.85)}catch{t(null)}})}function Je(i){const[t,e]=i.split(","),r=t.match(/:(.*?);/)?.[1]??"image/png",s=atob(e),n=new Uint8Array(s.length);for(let o=0;o<s.length;o++)n[o]=s.charCodeAt(o);return new Blob([n],{type:r})}class Qe{constructor(){this.listeners=new Set,this.originalOnError=null,this.installedOnError=null,this.rejectionHandler=null,this.hooked=!1}subscribe(t){return this.listeners.add(t),this.hook(),()=>{this.listeners.delete(t),this.listeners.size===0&&this.unhook()}}hook(){this.hooked||(this.hooked=!0,this.originalOnError=window.onerror,this.installedOnError=(t,e,r,s,n)=>(this.emit({message:String(t),source:e,line:r,col:s,error:n}),this.originalOnError?this.originalOnError.call(window,t,e,r,s,n):!1),window.onerror=this.installedOnError,this.rejectionHandler=t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason);this.emit({message:`Unhandled rejection: ${e}`})},window.addEventListener("unhandledrejection",this.rejectionHandler))}unhook(){this.hooked&&(this.hooked=!1,window.onerror===this.installedOnError&&(window.onerror=this.originalOnError),this.installedOnError=null,this.originalOnError=null,this.rejectionHandler&&(window.removeEventListener("unhandledrejection",this.rejectionHandler),this.rejectionHandler=null))}emit(t){for(const e of this.listeners)e(t)}}const F=new Qe,Ze=20;class ti{constructor(){this.errors=[],this.unsubscribe=null}start(){this.unsubscribe||(this.unsubscribe=F.subscribe(t=>this.record(t)))}record(t){const e=t.line!=null?` (${t.line}:${t.col??0})`:"";this.addError(`${t.message}${e}`)}addError(t){this.errors.length>=Ze||this.errors.includes(t)||this.errors.push(t)}getErrors(){return[...this.errors]}stop(){this.unsubscribe?.(),this.unsubscribe=null}}const ei=20;class ii{constructor(){this.breadcrumbs=[],this.active=!1,this.unsubscribeErrors=null,this.boundPopstateHandler=null,this.originalPushState=null,this.originalReplaceState=null,this.installedPushState=null,this.installedReplaceState=null,this.lastUrl="",this.boundClickHandler=t=>this.handleClick(t),this.boundChangeHandler=t=>this.handleChange(t)}start(){this.active||(this.active=!0,this.lastUrl=location.href,document.addEventListener("click",this.boundClickHandler,{capture:!0,passive:!0}),document.addEventListener("change",this.boundChangeHandler,{capture:!0,passive:!0}),this.unsubscribeErrors=F.subscribe(t=>this.recordError(t)),this.startNavigationTracking())}stop(){this.active&&(this.active=!1,document.removeEventListener("click",this.boundClickHandler,!0),document.removeEventListener("change",this.boundChangeHandler,!0),this.unsubscribeErrors?.(),this.unsubscribeErrors=null,this.stopNavigationTracking())}getBreadcrumbs(){return[...this.breadcrumbs]}add(t){this.breadcrumbs.push(t),this.breadcrumbs.length>ei&&this.breadcrumbs.shift()}handleClick(t){const e=t.target;if(e&&!S(e))try{this.add({type:"ui",category:"ui.click",timestamp:Date.now(),message:H(e),data:{selector:nt(e)}})}catch{}}handleChange(t){const e=t.target;if(e&&!S(e))try{const r=e,s=r.name||r.placeholder||e.getAttribute("aria-label")||e.tagName;this.add({type:"ui",category:"ui.input",timestamp:Date.now(),message:s,data:{field:s}})}catch{}}recordError(t){this.add({type:"console",category:"console.error",timestamp:Date.now(),message:t.message,data:{message:t.message}})}startNavigationTracking(){this.boundPopstateHandler=()=>this.handleNavigation(),window.addEventListener("popstate",this.boundPopstateHandler),this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history);const t=this.originalPushState,e=this.originalReplaceState,r=()=>this.handleNavigation();this.installedPushState=function(s,n,o){t(s,n,o),r()},this.installedReplaceState=function(s,n,o){e(s,n,o),r()},history.pushState=this.installedPushState,history.replaceState=this.installedReplaceState}stopNavigationTracking(){this.boundPopstateHandler&&(window.removeEventListener("popstate",this.boundPopstateHandler),this.boundPopstateHandler=null),this.originalPushState&&history.pushState===this.installedPushState&&(history.pushState=this.originalPushState),this.originalReplaceState&&history.replaceState===this.installedReplaceState&&(history.replaceState=this.originalReplaceState),this.originalPushState=null,this.originalReplaceState=null,this.installedPushState=null,this.installedReplaceState=null}handleNavigation(){if(!this.active)return;const t=this.lastUrl,e=location.href;t!==e&&(this.lastUrl=e,this.add({type:"navigation",category:"navigation",timestamp:Date.now(),message:`${t} → ${e}`,data:{from:t,to:e}}))}}const ri=3,si=1e3,ni=3,oi=5e3,ai=500,li=500,ci=300,di=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","LABEL","SUMMARY","DETAILS"]),hi=new Set(["button","link","checkbox","radio","tab","menuitem","option","switch","textbox","combobox","listbox","slider","spinbutton"]),K=["404","500","not found","page not found","server error","internal server error"],E=class E{constructor(t){this.clickHistory=[],this.unsubscribeErrors=null,this.active=!1,this.errorCount=0,this.deadClickCount=0,this.cooldownUntil=0,this.navTimestamps=[],this.boundPopstateHandler=null,this.originalPushState=null,this.originalReplaceState=null,this.installedPushState=null,this.installedReplaceState=null,this.boundSubmitHandler=null,this.boundInvalidHandler=null,this.errorPageUrls=new Set,this.domObserver=null,this.pendingDomChecks=0,this.lastMutationAt=-1,this.onFrustration=t,this.boundClickHandler=e=>this.handleClick(e)}start(){this.active||(this.active=!0,document.addEventListener("click",this.boundClickHandler,!0),this.unsubscribeErrors=F.subscribe(t=>{this.errorCount++}),this.startNavigationTracking(),this.startFormTracking(),this.checkErrorPage())}stop(){this.active&&(this.active=!1,document.removeEventListener("click",this.boundClickHandler,!0),this.unsubscribeErrors?.(),this.unsubscribeErrors=null,this.clickHistory=[],this.stopNavigationTracking(),this.stopFormTracking(),this.errorPageUrls.clear(),this.disconnectDomObserver())}startNavigationTracking(){this.boundPopstateHandler=()=>this.handleNavigation(),window.addEventListener("popstate",this.boundPopstateHandler),this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history);const t=this.originalPushState,e=this.originalReplaceState,r=()=>this.handleNavigation();this.installedPushState=function(s,n,o){t(s,n,o),r()},this.installedReplaceState=function(s,n,o){e(s,n,o),r()},history.pushState=this.installedPushState,history.replaceState=this.installedReplaceState}stopNavigationTracking(){this.boundPopstateHandler&&(window.removeEventListener("popstate",this.boundPopstateHandler),this.boundPopstateHandler=null),this.originalPushState&&history.pushState===this.installedPushState&&(history.pushState=this.originalPushState),this.originalReplaceState&&history.replaceState===this.installedReplaceState&&(history.replaceState=this.originalReplaceState),this.originalPushState=null,this.originalReplaceState=null,this.installedPushState=null,this.installedReplaceState=null,this.navTimestamps=[]}startFormTracking(){this.boundSubmitHandler=t=>this.handleFormSubmit(t),this.boundInvalidHandler=t=>this.handleFormInvalid(t),document.addEventListener("submit",this.boundSubmitHandler,!0),document.addEventListener("invalid",this.boundInvalidHandler,!0)}stopFormTracking(){this.boundSubmitHandler&&(document.removeEventListener("submit",this.boundSubmitHandler,!0),this.boundSubmitHandler=null),this.boundInvalidHandler&&(document.removeEventListener("invalid",this.boundInvalidHandler,!0),this.boundInvalidHandler=null)}handleClick(t){const e=t.target;if(!e||S(e))return;const r=Date.now();this.clickHistory.push({target:e,time:r});const s=r-si;if(this.clickHistory=this.clickHistory.filter(o=>o.time>s),this.clickHistory.filter(o=>o.target===e).length>=ri){this.clickHistory=[],this.emitHighPriority({signal:"rage_click",target:w(e),timestamp:r});return}this.isInteractive(e)||(this.deadClickCount++,this.deadClickCount>=3&&this.errorCount>0&&(this.deadClickCount=0,this.errorCount=0,this.emitIfReady({signal:"dead_click",target:w(e),timestamp:r}))),this.checkDeadClickDom(e,r)}handleNavigation(){const t=Date.now();this.navTimestamps.push(t);const e=t-oi;this.navTimestamps=this.navTimestamps.filter(r=>r>e),this.navTimestamps.length>=ni&&(this.navTimestamps=[],this.emitIfReady({signal:"rapid_navigation",timestamp:t})),setTimeout(()=>{this.active&&this.checkErrorPage()},ci)}handleFormSubmit(t){const e=t.target;e instanceof HTMLFormElement&&(S(e)||setTimeout(()=>{this.active&&e.querySelector('[aria-invalid="true"], .is-invalid')&&this.emitIfReady({signal:"form_failure",target:w(e),timestamp:Date.now()})},ai))}handleFormInvalid(t){const e=t.target;if(!e||S(e))return;const r=e.closest("form");this.emitIfReady({signal:"form_failure",target:w(r||e),timestamp:Date.now()})}checkErrorPage(){const t=location.href;if(this.errorPageUrls.has(t))return;const e=document.title.toLowerCase();if(K.some(s=>e.includes(s))){this.errorPageUrls.add(t),this.emitHighPriority({signal:"error_page",detail:document.title,timestamp:Date.now()});return}const r=document.querySelectorAll('h1, h2, [class*="error"], [class*="not-found"], [id*="error"], [id*="not-found"]');for(const s of r){const n=s.textContent??"";if(n.length<200&&K.some(o=>n.toLowerCase().includes(o))){this.errorPageUrls.add(t),this.emitHighPriority({signal:"error_page",detail:n.trim().slice(0,60),timestamp:Date.now()});return}}}checkDeadClickDom(t,e){this.looksInteractive(t)&&(this.pendingDomChecks++,this.ensureDomObserver(),setTimeout(()=>{this.pendingDomChecks--;const r=this.lastMutationAt>=e;this.pendingDomChecks===0&&this.disconnectDomObserver(),!r&&this.active&&this.emitIfReady({signal:"dead_click_dom",target:w(t),timestamp:e})},li))}ensureDomObserver(){this.domObserver||(this.domObserver=new MutationObserver(()=>{this.lastMutationAt=Date.now()}),this.domObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0}))}disconnectDomObserver(){this.domObserver?.disconnect(),this.domObserver=null}looksInteractive(t){if(window.getComputedStyle(t).cursor==="pointer")return!0;if(t.classList)for(const r of t.classList){const s=r.toLowerCase();if(s.includes("btn")||s.includes("button"))return!0}return!1}isInteractive(t){if(di.has(t.tagName))return!0;const e=t.getAttribute("role");return!!(e&&hi.has(e)||t.hasAttribute("onclick")||t.hasAttribute("tabindex")||t.contentEditable==="true"||window.getComputedStyle(t).cursor==="pointer"||t.closest('a, button, [role="button"], [role="link"], label'))}emitIfReady(t){const e=Date.now();e<this.cooldownUntil||(this.cooldownUntil=e+E.COOLDOWN_MS,this.onFrustration(t))}emitHighPriority(t){this.cooldownUntil=Date.now()+E.COOLDOWN_MS,this.onFrustration(t)}};E.COOLDOWN_MS=6e4;let I=E;function w(i){const t=i.tagName.toLowerCase(),e=i.id?`#${i.id}`:"",r=i.className&&typeof i.className=="string"?"."+i.className.trim().split(/\s+/).slice(0,2).join("."):"",s=i.textContent?.trim().slice(0,30)??"";return`<${t}${e}${r}>${s?` "${s}"`:""}`}function ui(){return{page_url:window.location.href,user_agent:navigator.userAgent,browser:mi(),os:pi(),screen_width:window.screen.width,screen_height:window.screen.height}}function mi(){const i=navigator.userAgent;return/Edg\//.test(i)?`Edge ${i.match(/Edg\/(\S+)/)?.[1]??""}`:/OPR\//.test(i)?`Opera ${i.match(/OPR\/(\S+)/)?.[1]??""}`:/Chrome\//.test(i)?`Chrome ${i.match(/Chrome\/(\S+)/)?.[1]??""}`:/Safari\//.test(i)&&/Version\//.test(i)?`Safari ${i.match(/Version\/(\S+)/)?.[1]??""}`:/Firefox\//.test(i)?`Firefox ${i.match(/Firefox\/(\S+)/)?.[1]??""}`:"Unknown"}function pi(){const i=navigator.userAgent;return/Windows NT 10/.test(i)?"Windows 10/11":/Windows NT/.test(i)?"Windows":/Mac OS X 10_15|macOS 1[56789]/.test(i)||/Mac OS X/.test(i)?"macOS":/Android/.test(i)?`Android ${i.match(/Android (\d+)/)?.[1]??""}`:/iPhone|iPad|iPod/.test(i)?"iOS":/Linux/.test(i)?"Linux":"Unknown"}const fi="https://makethisbetter.dev/api/v1";class bi{constructor(t,e,r=1e3,s,n){this.projectKey=t,this.apiUrl=(e??fi).replace(/\/$/,""),this.retryDelayMs=r,this.userToken=s,this.userTokenFn=n}async resolveUserToken(){return this.userTokenFn?this.userTokenFn():this.userToken}async authHeaders(t){const e={"X-Project-Key":this.projectKey},r=await this.resolveUserToken();return r&&(e["X-User-Token"]=r),t&&(e["Content-Type"]=t),e}async submissionHeaders(t,e){const r=await this.authHeaders(e);return r["X-Submission-Token"]=t,r}async createSubmissionSession(t,e){const r=wi(),s=new FormData;if(s.append("feedback[description]",t.description),s.append("feedback[page_url]",t.page_url),s.append("feedback[user_agent]",t.user_agent),s.append("feedback[browser]",t.browser),s.append("feedback[os]",t.os),s.append("feedback[screen_width]",String(t.screen_width)),s.append("feedback[screen_height]",String(t.screen_height)),s.append("feedback[console_errors]",JSON.stringify(t.console_errors)),s.append("feedback[annotations]",JSON.stringify(t.annotations)),t.target_element&&s.append("feedback[target_element]",JSON.stringify(t.target_element)),t.user_id&&s.append("feedback[user_id]",t.user_id),t.reporter_external_id&&s.append("feedback[reporter_external_id]",t.reporter_external_id),t.reporter_email&&s.append("feedback[reporter_email]",t.reporter_email),t.user_email&&s.append("feedback[user_email]",t.user_email),t.user_name&&s.append("feedback[user_name]",t.user_name),t.breadcrumbs&&t.breadcrumbs.length>0&&s.append("feedback[breadcrumbs]",JSON.stringify(t.breadcrumbs)),t.recording_events&&t.recording_events.length>0){const l=JSON.stringify(t.recording_events),c=new Blob([l],{type:"application/json"});s.append("feedback[recording]",c,"interaction-replay.json"),s.append("feedback[recording_duration]",String(t.recording_duration??0))}if(e){const l=e.type==="image/jpeg"?"jpg":"png";s.append("feedback[screenshot]",e,`screenshot.${l}`)}const n=await this.authHeaders();return n["X-Submission-Token"]=r,n["X-Idempotency-Key"]=yi(),{...(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions`,{method:"POST",headers:n,body:s})).json()).submission_session,token:r}}async createIdentityToken(t){const e=await this.authHeaders("application/json");try{return await(await this.fetchWithRetry(`${this.apiUrl}/widget/identity_tokens`,{method:"POST",headers:e,body:JSON.stringify({reporter_external_id:t})})).json()}catch{return null}}async updateReporter(t,e,r){const s=await this.authHeaders("application/json");s["X-Identity-Token"]=r;try{return await this.fetchWithRetry(`${this.apiUrl}/widget/feedbacks/${t}/reporter`,{method:"PATCH",headers:s,body:JSON.stringify({reporter:{email:e}})}),!0}catch{return!1}}async startClarification(t,e,r){const s={};r&&(s.message=r);const n=await this.submissionHeaders(e,"application/json");return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"POST",headers:n,body:JSON.stringify(s)})).json()).clarification}async getClarification(t,e){const r=await this.submissionHeaders(e);return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"GET",headers:r})).json()).clarification}async streamClarification(t,e,r){const s=await this.submissionHeaders(e,"application/json");s.Accept="text/event-stream";const n=await fetch(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"POST",headers:s,body:JSON.stringify({})}),o=n.headers.get("Content-Type")??"";if(!n.ok||!n.body||!o.includes("text/event-stream"))throw new Error("clarify stream unavailable");return gi(n.body,r)}async finalizeSubmissionSession(t,e){const r=await this.submissionHeaders(e);return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/feedback`,{method:"POST",headers:r})).json()).feedback}async abandonSubmissionSession(t,e){const r=await this.submissionHeaders(e);await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}`,{method:"DELETE",headers:r})}async fetchWithRetry(t,e,r=1){let s;try{s=await fetch(t,e)}catch(n){if(r>0)return await G(this.retryDelayMs),this.fetchWithRetry(t,e,r-1);throw n}if(s.ok)return s;if(s.status>=500&&r>0)return await G(this.retryDelayMs),this.fetchWithRetry(t,e,r-1);throw new Error(`HTTP ${s.status}`)}}function G(i){return i<=0?Promise.resolve():new Promise(t=>setTimeout(t,i))}async function gi(i,t){const e=i.getReader(),r=new TextDecoder;let s="",n={messages:[],done:!0};const o=a=>{const l=a.split(`
|
|
131
|
+
`,t.append(this.el),this.el.querySelector(".mtb-close-link").addEventListener("click",r),s&&this.el.querySelector(".mtb-view-feedback-link").addEventListener("click",s),n?.emailCapture?this.bindEmailCapture(n.emailCapture.onSubmit):setTimeout(()=>r(),Kt)}bindEmailCapture(t){const e=this.el.querySelector(".mtb-email-input"),r=this.el.querySelector(".mtb-email-submit"),s=this.el.querySelector(".mtb-email-error"),n=async()=>{const o=e.value.trim();if(!Xt.test(o)){e.classList.add("mtb-email-invalid");return}e.classList.remove("mtb-email-invalid"),s.hidden=!0,r.disabled=!0,await t(o)?this.el.querySelector(".mtb-email-capture").innerHTML=`<div class="mtb-email-saved">${this.messages.success.email_saved}</div>`:(s.hidden=!1,r.disabled=!1)};r.addEventListener("click",n),e.addEventListener("keydown",o=>{o.key==="Enter"&&n()})}destroy(){this.el.remove()}}function Jt(i,t){if(i.match(/^[a-z]+:\/\//i))return i;if(i.match(/^\/\//))return window.location.protocol+i;if(i.match(/^[a-z]+:/i))return i;const e=document.implementation.createHTMLDocument(),r=e.createElement("base"),s=e.createElement("a");return e.head.appendChild(r),e.body.appendChild(s),t&&(r.href=t),s.href=i,s.href}const Qt=(()=>{let i=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(i+=1,`u${t()}${i}`)})();function f(i){const t=[];for(let e=0,r=i.length;e<r;e++)t.push(i[e]);return t}let g=null;function ot(i={}){return g||(i.includeStyleProperties?(g=i.includeStyleProperties,g):(g=f(window.getComputedStyle(document.documentElement)),g))}function _(i,t){const r=(i.ownerDocument.defaultView||window).getComputedStyle(i).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Zt(i){const t=_(i,"border-left-width"),e=_(i,"border-right-width");return i.clientWidth+t+e}function te(i){const t=_(i,"border-top-width"),e=_(i,"border-bottom-width");return i.clientHeight+t+e}function at(i,t={}){const e=t.width||Zt(i),r=t.height||te(i);return{width:e,height:r}}function ee(){let i,t;try{t=process}catch{}const e=t&&t.env?t.env.devicePixelRatio:null;return e&&(i=parseInt(e,10),Number.isNaN(i)&&(i=1)),i||window.devicePixelRatio||1}const m=16384;function ie(i){(i.width>m||i.height>m)&&(i.width>m&&i.height>m?i.width>i.height?(i.height*=m/i.width,i.width=m):(i.width*=m/i.height,i.height=m):i.width>m?(i.height*=m/i.width,i.width=m):(i.width*=m/i.height,i.height=m))}function T(i){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=e,r.crossOrigin="anonymous",r.decoding="async",r.src=i})}async function re(i){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function se(i,t,e){const r="http://www.w3.org/2000/svg",s=document.createElementNS(r,"svg"),n=document.createElementNS(r,"foreignObject");return s.setAttribute("width",`${t}`),s.setAttribute("height",`${e}`),s.setAttribute("viewBox",`0 0 ${t} ${e}`),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("externalResourcesRequired","true"),s.appendChild(n),n.appendChild(i),re(s)}const u=(i,t)=>{if(i instanceof t)return!0;const e=Object.getPrototypeOf(i);return e===null?!1:e.constructor.name===t.name||u(e,t)};function ne(i){const t=i.getPropertyValue("content");return`${i.cssText} content: '${t.replace(/'|"/g,"")}';`}function oe(i,t){return ot(t).map(e=>{const r=i.getPropertyValue(e),s=i.getPropertyPriority(e);return`${e}: ${r}${s?" !important":""};`}).join(" ")}function ae(i,t,e,r){const s=`.${i}:${t}`,n=e.cssText?ne(e):oe(e,r);return document.createTextNode(`${s}{${n}}`)}function j(i,t,e,r){const s=window.getComputedStyle(i,e),n=s.getPropertyValue("content");if(n===""||n==="none")return;const o=Qt();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(ae(o,e,s,r)),t.appendChild(a)}function le(i,t,e){j(i,t,":before",e),j(i,t,":after",e)}const q="application/font-woff",N="image/jpeg",ce={woff:q,woff2:q,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:N,jpeg:N,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function de(i){const t=/\.([^./]*?)$/g.exec(i);return t?t[1]:""}function $(i){const t=de(i).toLowerCase();return ce[t]||""}function he(i){return i.split(/,/)[1]}function R(i){return i.search(/^(data:)/)!==-1}function ue(i,t){return`data:${t};base64,${i}`}async function lt(i,t,e){const r=await fetch(i,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const s=await r.blob();return new Promise((n,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{n(e({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(s)})}const D={};function me(i,t,e){let r=i.replace(/\?.*/,"");return e&&(r=i),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function B(i,t,e){const r=me(i,t,e.includeQueryParams);if(D[r]!=null)return D[r];e.cacheBust&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let s;try{const n=await lt(i,e.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),he(a)));s=ue(n,t)}catch(n){s=e.imagePlaceholder||"";let o=`Failed to fetch resource: ${i}`;n&&(o=typeof n=="string"?n:n.message),o&&console.warn(o)}return D[r]=s,s}async function pe(i){const t=i.toDataURL();return t==="data:,"?i.cloneNode(!1):T(t)}async function fe(i,t){if(i.currentSrc){const n=document.createElement("canvas"),o=n.getContext("2d");n.width=i.clientWidth,n.height=i.clientHeight,o?.drawImage(i,0,0,n.width,n.height);const a=n.toDataURL();return T(a)}const e=i.poster,r=$(e),s=await B(e,r,t);return T(s)}async function be(i,t){var e;try{if(!((e=i?.contentDocument)===null||e===void 0)&&e.body)return await L(i.contentDocument.body,t,!0)}catch{}return i.cloneNode(!1)}async function ge(i,t){return u(i,HTMLCanvasElement)?pe(i):u(i,HTMLVideoElement)?fe(i,t):u(i,HTMLIFrameElement)?be(i,t):i.cloneNode(ct(i))}const ye=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SLOT",ct=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SVG";async function we(i,t,e){var r,s;if(ct(t))return t;let n=[];return ye(i)&&i.assignedNodes?n=f(i.assignedNodes()):u(i,HTMLIFrameElement)&&(!((r=i.contentDocument)===null||r===void 0)&&r.body)?n=f(i.contentDocument.body.childNodes):n=f(((s=i.shadowRoot)!==null&&s!==void 0?s:i).childNodes),n.length===0||u(i,HTMLVideoElement)||await n.reduce((o,a)=>o.then(()=>L(a,e)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function xe(i,t,e){const r=t.style;if(!r)return;const s=window.getComputedStyle(i);s.cssText?(r.cssText=s.cssText,r.transformOrigin=s.transformOrigin):ot(e).forEach(n=>{let o=s.getPropertyValue(n);n==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),u(i,HTMLIFrameElement)&&n==="display"&&o==="inline"&&(o="block"),n==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(n,o,s.getPropertyPriority(n))})}function ve(i,t){u(i,HTMLTextAreaElement)&&(t.innerHTML=i.value),u(i,HTMLInputElement)&&t.setAttribute("value",i.value)}function ke(i,t){if(u(i,HTMLSelectElement)){const e=t,r=Array.from(e.children).find(s=>i.value===s.getAttribute("value"));r&&r.setAttribute("selected","")}}function Se(i,t,e){return u(t,Element)&&(xe(i,t,e),le(i,t,e),ve(i,t),ke(i,t)),t}async function Ee(i,t){const e=i.querySelectorAll?i.querySelectorAll("use"):[];if(e.length===0)return i;const r={};for(let n=0;n<e.length;n++){const a=e[n].getAttribute("xlink:href");if(a){const l=i.querySelector(a),c=document.querySelector(a);!l&&c&&!r[a]&&(r[a]=await L(c,t,!0))}}const s=Object.values(r);if(s.length){const n="http://www.w3.org/1999/xhtml",o=document.createElementNS(n,"svg");o.setAttribute("xmlns",n),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(n,"defs");o.appendChild(a);for(let l=0;l<s.length;l++)a.appendChild(s[l]);i.appendChild(o)}return i}async function L(i,t,e){return!e&&t.filter&&!t.filter(i)?null:Promise.resolve(i).then(r=>ge(r,t)).then(r=>we(i,r,t)).then(r=>Se(i,r,t)).then(r=>Ee(r,t))}const dt=/url\((['"]?)([^'"]+?)\1\)/g,Ce=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,_e=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function Te(i){const t=i.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function Me(i){const t=[];return i.replace(dt,(e,r,s)=>(t.push(s),e)),t.filter(e=>!R(e))}async function Le(i,t,e,r,s){try{const n=e?Jt(t,e):t,o=$(t);let a;return s||(a=await B(n,o,r)),i.replace(Te(t),`$1${a}$3`)}catch{}return i}function Pe(i,{preferredFontFormat:t}){return t?i.replace(_e,e=>{for(;;){const[r,,s]=Ce.exec(e)||[];if(!s)return"";if(s===t)return`src: ${r};`}}):i}function ht(i){return i.search(dt)!==-1}async function ut(i,t,e){if(!ht(i))return i;const r=Pe(i,e);return Me(r).reduce((n,o)=>n.then(a=>Le(a,o,t,e)),Promise.resolve(r))}async function y(i,t,e){var r;const s=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(i);if(s){const n=await ut(s,null,e);return t.style.setProperty(i,n,t.style.getPropertyPriority(i)),!0}return!1}async function Ae(i,t){await y("background",i,t)||await y("background-image",i,t),await y("mask",i,t)||await y("-webkit-mask",i,t)||await y("mask-image",i,t)||await y("-webkit-mask-image",i,t)}async function De(i,t){const e=u(i,HTMLImageElement);if(!(e&&!R(i.src))&&!(u(i,SVGImageElement)&&!R(i.href.baseVal)))return;const r=e?i.src:i.href.baseVal,s=await B(r,$(r),t);await new Promise((n,o)=>{i.onload=n,i.onerror=t.onImageErrorHandler?(...l)=>{try{n(t.onImageErrorHandler(...l))}catch(c){o(c)}}:o;const a=i;a.decode&&(a.decode=n),a.loading==="lazy"&&(a.loading="eager"),e?(i.srcset="",i.src=s):i.href.baseVal=s})}async function Re(i,t){const r=f(i.childNodes).map(s=>mt(s,t));await Promise.all(r).then(()=>i)}async function mt(i,t){u(i,Element)&&(await Ae(i,t),await De(i,t),await Re(i,t))}function Ie(i,t){const{style:e}=i;t.backgroundColor&&(e.backgroundColor=t.backgroundColor),t.width&&(e.width=`${t.width}px`),t.height&&(e.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(s=>{e[s]=r[s]}),i}const W={};async function V(i){let t=W[i];if(t!=null)return t;const r=await(await fetch(i)).text();return t={url:i,cssText:r},W[i]=t,t}async function Y(i,t){let e=i.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,n=(e.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,i.url).href),lt(a,t.fetchRequestInit,({result:l})=>(e=e.replace(o,`url(${l})`),[o,l]))});return Promise.all(n).then(()=>e)}function K(i){if(i==null)return[];const t=[],e=/(\/\*[\s\S]*?\*\/)/gi;let r=i.replace(e,"");const s=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=s.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(s,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=n.exec(r);if(l===null){if(l=a.exec(r),l===null)break;n.lastIndex=a.lastIndex}else a.lastIndex=n.lastIndex;t.push(l[0])}return t}async function He(i,t){const e=[],r=[];return i.forEach(s=>{if("cssRules"in s)try{f(s.cssRules||[]).forEach((n,o)=>{if(n.type===CSSRule.IMPORT_RULE){let a=o+1;const l=n.href,c=V(l).then(h=>Y(h,t)).then(h=>K(h).forEach(p=>{try{s.insertRule(p,p.startsWith("@import")?a+=1:s.cssRules.length)}catch(x){console.error("Error inserting rule from remote css",{rule:p,error:x})}})).catch(h=>{console.error("Error loading remote css",h.toString())});r.push(c)}})}catch(n){const o=i.find(a=>a.href==null)||document.styleSheets[0];s.href!=null&&r.push(V(s.href).then(a=>Y(a,t)).then(a=>K(a).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",n)}}),Promise.all(r).then(()=>(i.forEach(s=>{if("cssRules"in s)try{f(s.cssRules||[]).forEach(n=>{e.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${s.href}`,n)}}),e))}function $e(i){return i.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>ht(t.style.getPropertyValue("src")))}async function Be(i,t){if(i.ownerDocument==null)throw new Error("Provided element is not within a Document");const e=f(i.ownerDocument.styleSheets),r=await He(e,t);return $e(r)}function pt(i){return i.trim().replace(/["']/g,"")}function Fe(i){const t=new Set;function e(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(n=>{t.add(pt(n))}),Array.from(r.children).forEach(n=>{n instanceof HTMLElement&&e(n)})}return e(i),t}async function ze(i,t){const e=await Be(i,t),r=Fe(i);return(await Promise.all(e.filter(n=>r.has(pt(n.style.fontFamily))).map(n=>{const o=n.parentStyleSheet?n.parentStyleSheet.href:null;return ut(n.cssText,o,t)}))).join(`
|
|
132
|
+
`)}async function Oe(i,t){const e=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await ze(i,t);if(e){const r=document.createElement("style"),s=document.createTextNode(e);r.appendChild(s),i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r)}}async function Ue(i,t={}){const{width:e,height:r}=at(i,t),s=await L(i,t,!0);return await Oe(s,t),await mt(s,t),Ie(s,t),await se(s,e,r)}async function je(i,t={}){const{width:e,height:r}=at(i,t),s=await Ue(i,t),n=await T(s),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||ee(),c=t.canvasWidth||e,h=t.canvasHeight||r;return o.width=c*l,o.height=h*l,t.skipAutoScale||ie(o),o.style.width=`${c}`,o.style.height=`${h}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(n,0,0,o.width,o.height),o}async function qe(i,t={}){return(await je(i,t)).toDataURL("image/jpeg",t.quality||1)}async function Ne(i=[]){try{const t=await qe(document.body,{quality:.85,pixelRatio:1,backgroundColor:"#ffffff",skipFonts:!0,skipAutoScale:!1,filter:e=>!(e instanceof HTMLElement&&e.id==="mtb-widget-host")});if(i.length>0){const e=await We(t,i);if(e)return e}return Je(t)}catch{return null}}async function We(i,t){const e=document.createElement("canvas"),r=e.getContext("2d");if(!r)return null;const s=await Xe(i);if(!s)return null;e.width=s.naturalWidth||window.innerWidth,e.height=s.naturalHeight||window.innerHeight,r.drawImage(s,0,0);const n=e.width/window.innerWidth,o=e.height/window.innerHeight;let a=0;for(const l of t)l.type==="draw"&&l.drawPath?Ve(r,l.drawPath,n,o):l.type==="pin"&&Ye(r,l.x*n,l.y*o,++a);return Ge(e)}function Ve(i,t,e,r){i.save(),i.strokeStyle=M,i.lineWidth=3.5,i.lineCap="round",i.lineJoin="round",i.shadowColor="rgba(5,150,105,0.35)",i.shadowOffsetY=1,i.shadowBlur=2;for(const s of Ke(t))if(s.length!==0){i.beginPath(),i.moveTo(s[0][0]*e,s[0][1]*r);for(let n=1;n<s.length;n++)i.lineTo(s[n][0]*e,s[n][1]*r);i.stroke()}i.restore()}function Ye(i,t,e,r){i.save(),i.shadowColor="rgba(5,150,105,0.45)",i.shadowOffsetY=2,i.shadowBlur=8,i.fillStyle=M,i.beginPath(),i.arc(t,e,11,0,Math.PI*2),i.fill(),i.shadowColor="transparent",i.lineWidth=2,i.strokeStyle="#ffffff",i.stroke(),i.fillStyle="#ffffff",i.font=`700 10px ${Bt}`,i.textAlign="center",i.textBaseline="middle",i.fillText(String(r),t,e),i.restore()}function Ke(i){const t=[];let e=null;const r=i.match(/[ML]\s*[-\d.]+\s+[-\d.]+/g)??[];for(const s of r){const[n,o]=s.slice(1).trim().split(/\s+/).map(Number);Number.isNaN(n)||Number.isNaN(o)||(s[0]==="M"?(e=[[n,o]],t.push(e)):e&&e.push([n,o]))}return t}function Xe(i){return new Promise(t=>{const e=new Image;e.onload=()=>t(e),e.onerror=()=>t(null),e.src=i})}function Ge(i){return new Promise(t=>{try{i.toBlob(e=>t(e),"image/jpeg",.85)}catch{t(null)}})}function Je(i){const[t,e]=i.split(","),r=t.match(/:(.*?);/)?.[1]??"image/png",s=atob(e),n=new Uint8Array(s.length);for(let o=0;o<s.length;o++)n[o]=s.charCodeAt(o);return new Blob([n],{type:r})}class Qe{constructor(){this.listeners=new Set,this.originalOnError=null,this.installedOnError=null,this.rejectionHandler=null,this.hooked=!1}subscribe(t){return this.listeners.add(t),this.hook(),()=>{this.listeners.delete(t),this.listeners.size===0&&this.unhook()}}hook(){this.hooked||(this.hooked=!0,this.originalOnError=window.onerror,this.installedOnError=(t,e,r,s,n)=>(this.emit({message:String(t),source:e,line:r,col:s,error:n}),this.originalOnError?this.originalOnError.call(window,t,e,r,s,n):!1),window.onerror=this.installedOnError,this.rejectionHandler=t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason);this.emit({message:`Unhandled rejection: ${e}`})},window.addEventListener("unhandledrejection",this.rejectionHandler))}unhook(){this.hooked&&(this.hooked=!1,window.onerror===this.installedOnError&&(window.onerror=this.originalOnError),this.installedOnError=null,this.originalOnError=null,this.rejectionHandler&&(window.removeEventListener("unhandledrejection",this.rejectionHandler),this.rejectionHandler=null))}emit(t){for(const e of this.listeners)e(t)}}const F=new Qe,Ze=20;class ti{constructor(){this.errors=[],this.unsubscribe=null}start(){this.unsubscribe||(this.unsubscribe=F.subscribe(t=>this.record(t)))}record(t){const e=t.line!=null?` (${t.line}:${t.col??0})`:"";this.addError(`${t.message}${e}`)}addError(t){this.errors.length>=Ze||this.errors.includes(t)||this.errors.push(t)}getErrors(){return[...this.errors]}stop(){this.unsubscribe?.(),this.unsubscribe=null}}const ei=20;class ii{constructor(){this.breadcrumbs=[],this.active=!1,this.unsubscribeErrors=null,this.boundPopstateHandler=null,this.originalPushState=null,this.originalReplaceState=null,this.installedPushState=null,this.installedReplaceState=null,this.lastUrl="",this.boundClickHandler=t=>this.handleClick(t),this.boundChangeHandler=t=>this.handleChange(t)}start(){this.active||(this.active=!0,this.lastUrl=location.href,document.addEventListener("click",this.boundClickHandler,{capture:!0,passive:!0}),document.addEventListener("change",this.boundChangeHandler,{capture:!0,passive:!0}),this.unsubscribeErrors=F.subscribe(t=>this.recordError(t)),this.startNavigationTracking())}stop(){this.active&&(this.active=!1,document.removeEventListener("click",this.boundClickHandler,!0),document.removeEventListener("change",this.boundChangeHandler,!0),this.unsubscribeErrors?.(),this.unsubscribeErrors=null,this.stopNavigationTracking())}getBreadcrumbs(){return[...this.breadcrumbs]}add(t){this.breadcrumbs.push(t),this.breadcrumbs.length>ei&&this.breadcrumbs.shift()}handleClick(t){const e=t.target;if(e&&!S(e))try{this.add({type:"ui",category:"ui.click",timestamp:Date.now(),message:H(e),data:{selector:nt(e)}})}catch{}}handleChange(t){const e=t.target;if(e&&!S(e))try{const r=e,s=r.name||r.placeholder||e.getAttribute("aria-label")||e.tagName;this.add({type:"ui",category:"ui.input",timestamp:Date.now(),message:s,data:{field:s}})}catch{}}recordError(t){this.add({type:"console",category:"console.error",timestamp:Date.now(),message:t.message,data:{message:t.message}})}startNavigationTracking(){this.boundPopstateHandler=()=>this.handleNavigation(),window.addEventListener("popstate",this.boundPopstateHandler),this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history);const t=this.originalPushState,e=this.originalReplaceState,r=()=>this.handleNavigation();this.installedPushState=function(s,n,o){t(s,n,o),r()},this.installedReplaceState=function(s,n,o){e(s,n,o),r()},history.pushState=this.installedPushState,history.replaceState=this.installedReplaceState}stopNavigationTracking(){this.boundPopstateHandler&&(window.removeEventListener("popstate",this.boundPopstateHandler),this.boundPopstateHandler=null),this.originalPushState&&history.pushState===this.installedPushState&&(history.pushState=this.originalPushState),this.originalReplaceState&&history.replaceState===this.installedReplaceState&&(history.replaceState=this.originalReplaceState),this.originalPushState=null,this.originalReplaceState=null,this.installedPushState=null,this.installedReplaceState=null}handleNavigation(){if(!this.active)return;const t=this.lastUrl,e=location.href;t!==e&&(this.lastUrl=e,this.add({type:"navigation",category:"navigation",timestamp:Date.now(),message:`${t} → ${e}`,data:{from:t,to:e}}))}}const ri=3,si=1e3,ni=3,oi=5e3,ai=500,li=500,ci=300,di=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","LABEL","SUMMARY","DETAILS"]),hi=new Set(["button","link","checkbox","radio","tab","menuitem","option","switch","textbox","combobox","listbox","slider","spinbutton"]),X=["404","500","not found","page not found","server error","internal server error"],E=class E{constructor(t){this.clickHistory=[],this.unsubscribeErrors=null,this.active=!1,this.errorCount=0,this.deadClickCount=0,this.cooldownUntil=0,this.navTimestamps=[],this.boundPopstateHandler=null,this.originalPushState=null,this.originalReplaceState=null,this.installedPushState=null,this.installedReplaceState=null,this.boundSubmitHandler=null,this.boundInvalidHandler=null,this.errorPageUrls=new Set,this.domObserver=null,this.pendingDomChecks=0,this.lastMutationAt=-1,this.onFrustration=t,this.boundClickHandler=e=>this.handleClick(e)}start(){this.active||(this.active=!0,document.addEventListener("click",this.boundClickHandler,!0),this.unsubscribeErrors=F.subscribe(t=>{this.errorCount++}),this.startNavigationTracking(),this.startFormTracking(),this.checkErrorPage())}stop(){this.active&&(this.active=!1,document.removeEventListener("click",this.boundClickHandler,!0),this.unsubscribeErrors?.(),this.unsubscribeErrors=null,this.clickHistory=[],this.stopNavigationTracking(),this.stopFormTracking(),this.errorPageUrls.clear(),this.disconnectDomObserver())}startNavigationTracking(){this.boundPopstateHandler=()=>this.handleNavigation(),window.addEventListener("popstate",this.boundPopstateHandler),this.originalPushState=history.pushState.bind(history),this.originalReplaceState=history.replaceState.bind(history);const t=this.originalPushState,e=this.originalReplaceState,r=()=>this.handleNavigation();this.installedPushState=function(s,n,o){t(s,n,o),r()},this.installedReplaceState=function(s,n,o){e(s,n,o),r()},history.pushState=this.installedPushState,history.replaceState=this.installedReplaceState}stopNavigationTracking(){this.boundPopstateHandler&&(window.removeEventListener("popstate",this.boundPopstateHandler),this.boundPopstateHandler=null),this.originalPushState&&history.pushState===this.installedPushState&&(history.pushState=this.originalPushState),this.originalReplaceState&&history.replaceState===this.installedReplaceState&&(history.replaceState=this.originalReplaceState),this.originalPushState=null,this.originalReplaceState=null,this.installedPushState=null,this.installedReplaceState=null,this.navTimestamps=[]}startFormTracking(){this.boundSubmitHandler=t=>this.handleFormSubmit(t),this.boundInvalidHandler=t=>this.handleFormInvalid(t),document.addEventListener("submit",this.boundSubmitHandler,!0),document.addEventListener("invalid",this.boundInvalidHandler,!0)}stopFormTracking(){this.boundSubmitHandler&&(document.removeEventListener("submit",this.boundSubmitHandler,!0),this.boundSubmitHandler=null),this.boundInvalidHandler&&(document.removeEventListener("invalid",this.boundInvalidHandler,!0),this.boundInvalidHandler=null)}handleClick(t){const e=t.target;if(!e||S(e))return;const r=Date.now();this.clickHistory.push({target:e,time:r});const s=r-si;if(this.clickHistory=this.clickHistory.filter(o=>o.time>s),this.clickHistory.filter(o=>o.target===e).length>=ri){this.clickHistory=[],this.emitHighPriority({signal:"rage_click",target:w(e),timestamp:r});return}this.isInteractive(e)||(this.deadClickCount++,this.deadClickCount>=3&&this.errorCount>0&&(this.deadClickCount=0,this.errorCount=0,this.emitIfReady({signal:"dead_click",target:w(e),timestamp:r}))),this.checkDeadClickDom(e,r)}handleNavigation(){const t=Date.now();this.navTimestamps.push(t);const e=t-oi;this.navTimestamps=this.navTimestamps.filter(r=>r>e),this.navTimestamps.length>=ni&&(this.navTimestamps=[],this.emitIfReady({signal:"rapid_navigation",timestamp:t})),setTimeout(()=>{this.active&&this.checkErrorPage()},ci)}handleFormSubmit(t){const e=t.target;e instanceof HTMLFormElement&&(S(e)||setTimeout(()=>{this.active&&e.querySelector('[aria-invalid="true"], .is-invalid')&&this.emitIfReady({signal:"form_failure",target:w(e),timestamp:Date.now()})},ai))}handleFormInvalid(t){const e=t.target;if(!e||S(e))return;const r=e.closest("form");this.emitIfReady({signal:"form_failure",target:w(r||e),timestamp:Date.now()})}checkErrorPage(){const t=location.href;if(this.errorPageUrls.has(t))return;const e=document.title.toLowerCase();if(X.some(s=>e.includes(s))){this.errorPageUrls.add(t),this.emitHighPriority({signal:"error_page",detail:document.title,timestamp:Date.now()});return}const r=document.querySelectorAll('h1, h2, [class*="error"], [class*="not-found"], [id*="error"], [id*="not-found"]');for(const s of r){const n=s.textContent??"";if(n.length<200&&X.some(o=>n.toLowerCase().includes(o))){this.errorPageUrls.add(t),this.emitHighPriority({signal:"error_page",detail:n.trim().slice(0,60),timestamp:Date.now()});return}}}checkDeadClickDom(t,e){this.looksInteractive(t)&&(this.pendingDomChecks++,this.ensureDomObserver(),setTimeout(()=>{this.pendingDomChecks--;const r=this.lastMutationAt>=e;this.pendingDomChecks===0&&this.disconnectDomObserver(),!r&&this.active&&this.emitIfReady({signal:"dead_click_dom",target:w(t),timestamp:e})},li))}ensureDomObserver(){this.domObserver||(this.domObserver=new MutationObserver(()=>{this.lastMutationAt=Date.now()}),this.domObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0}))}disconnectDomObserver(){this.domObserver?.disconnect(),this.domObserver=null}looksInteractive(t){if(window.getComputedStyle(t).cursor==="pointer")return!0;if(t.classList)for(const r of t.classList){const s=r.toLowerCase();if(s.includes("btn")||s.includes("button"))return!0}return!1}isInteractive(t){if(di.has(t.tagName))return!0;const e=t.getAttribute("role");return!!(e&&hi.has(e)||t.hasAttribute("onclick")||t.hasAttribute("tabindex")||t.contentEditable==="true"||window.getComputedStyle(t).cursor==="pointer"||t.closest('a, button, [role="button"], [role="link"], label'))}emitIfReady(t){const e=Date.now();e<this.cooldownUntil||(this.cooldownUntil=e+E.COOLDOWN_MS,this.onFrustration(t))}emitHighPriority(t){this.cooldownUntil=Date.now()+E.COOLDOWN_MS,this.onFrustration(t)}};E.COOLDOWN_MS=6e4;let I=E;function w(i){const t=i.tagName.toLowerCase(),e=i.id?`#${i.id}`:"",r=i.className&&typeof i.className=="string"?"."+i.className.trim().split(/\s+/).slice(0,2).join("."):"",s=i.textContent?.trim().slice(0,30)??"";return`<${t}${e}${r}>${s?` "${s}"`:""}`}function ui(){return{page_url:window.location.href,user_agent:navigator.userAgent,browser:mi(),os:pi(),screen_width:window.screen.width,screen_height:window.screen.height}}function mi(){const i=navigator.userAgent;return/Edg\//.test(i)?`Edge ${i.match(/Edg\/(\S+)/)?.[1]??""}`:/OPR\//.test(i)?`Opera ${i.match(/OPR\/(\S+)/)?.[1]??""}`:/Chrome\//.test(i)?`Chrome ${i.match(/Chrome\/(\S+)/)?.[1]??""}`:/Safari\//.test(i)&&/Version\//.test(i)?`Safari ${i.match(/Version\/(\S+)/)?.[1]??""}`:/Firefox\//.test(i)?`Firefox ${i.match(/Firefox\/(\S+)/)?.[1]??""}`:"Unknown"}function pi(){const i=navigator.userAgent;return/Windows NT 10/.test(i)?"Windows 10/11":/Windows NT/.test(i)?"Windows":/Mac OS X 10_15|macOS 1[56789]/.test(i)||/Mac OS X/.test(i)?"macOS":/Android/.test(i)?`Android ${i.match(/Android (\d+)/)?.[1]??""}`:/iPhone|iPad|iPod/.test(i)?"iOS":/Linux/.test(i)?"Linux":"Unknown"}const fi="https://makethisbetter.dev/api/v1";class bi{constructor(t,e,r=1e3,s,n){this.projectKey=t,this.apiUrl=(e??fi).replace(/\/$/,""),this.retryDelayMs=r,this.userToken=s,this.userTokenFn=n}async resolveUserToken(){return this.userTokenFn?this.userTokenFn():this.userToken}async authHeaders(t){const e={"X-Project-Key":this.projectKey},r=await this.resolveUserToken();return r&&(e["X-User-Token"]=r),t&&(e["Content-Type"]=t),e}async submissionHeaders(t,e){const r=await this.authHeaders(e);return r["X-Submission-Token"]=t,r}async createSubmissionSession(t,e){const r=wi(),s=new FormData;if(s.append("feedback[description]",t.description),s.append("feedback[page_url]",t.page_url),s.append("feedback[user_agent]",t.user_agent),s.append("feedback[browser]",t.browser),s.append("feedback[os]",t.os),s.append("feedback[screen_width]",String(t.screen_width)),s.append("feedback[screen_height]",String(t.screen_height)),s.append("feedback[console_errors]",JSON.stringify(t.console_errors)),s.append("feedback[annotations]",JSON.stringify(t.annotations)),t.target_element&&s.append("feedback[target_element]",JSON.stringify(t.target_element)),t.user_id&&s.append("feedback[user_id]",t.user_id),t.reporter_external_id&&s.append("feedback[reporter_external_id]",t.reporter_external_id),t.reporter_email&&s.append("feedback[reporter_email]",t.reporter_email),t.user_email&&s.append("feedback[user_email]",t.user_email),t.user_name&&s.append("feedback[user_name]",t.user_name),t.breadcrumbs&&t.breadcrumbs.length>0&&s.append("feedback[breadcrumbs]",JSON.stringify(t.breadcrumbs)),t.recording_events&&t.recording_events.length>0){const l=JSON.stringify(t.recording_events),c=new Blob([l],{type:"application/json"});s.append("feedback[recording]",c,"interaction-replay.json"),s.append("feedback[recording_duration]",String(t.recording_duration??0))}if(e){const l=e.type==="image/jpeg"?"jpg":"png";s.append("feedback[screenshot]",e,`screenshot.${l}`)}const n=await this.authHeaders();return n["X-Submission-Token"]=r,n["X-Idempotency-Key"]=yi(),{...(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions`,{method:"POST",headers:n,body:s})).json()).submission_session,token:r}}async createIdentityToken(t){const e=await this.authHeaders("application/json");try{return await(await this.fetchWithRetry(`${this.apiUrl}/widget/identity_tokens`,{method:"POST",headers:e,body:JSON.stringify({reporter_external_id:t})})).json()}catch{return null}}async updateReporter(t,e,r){const s=await this.authHeaders("application/json");s["X-Identity-Token"]=r;try{return await this.fetchWithRetry(`${this.apiUrl}/widget/feedbacks/${t}/reporter`,{method:"PATCH",headers:s,body:JSON.stringify({reporter:{email:e}})}),!0}catch{return!1}}async startClarification(t,e,r){const s={};r&&(s.message=r);const n=await this.submissionHeaders(e,"application/json");return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"POST",headers:n,body:JSON.stringify(s)})).json()).clarification}async getClarification(t,e){const r=await this.submissionHeaders(e);return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"GET",headers:r})).json()).clarification}async streamClarification(t,e,r){const s=await this.submissionHeaders(e,"application/json");s.Accept="text/event-stream";const n=await fetch(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"POST",headers:s,body:JSON.stringify({})}),o=n.headers.get("Content-Type")??"";if(!n.ok||!n.body||!o.includes("text/event-stream"))throw new Error("clarify stream unavailable");return gi(n.body,r)}async finalizeSubmissionSession(t,e){const r=await this.submissionHeaders(e);return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/feedback`,{method:"POST",headers:r})).json()).feedback}async abandonSubmissionSession(t,e){const r=await this.submissionHeaders(e);await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}`,{method:"DELETE",headers:r})}async fetchWithRetry(t,e,r=1){let s;try{s=await fetch(t,e)}catch(n){if(r>0)return await G(this.retryDelayMs),this.fetchWithRetry(t,e,r-1);throw n}if(s.ok)return s;if(s.status>=500&&r>0)return await G(this.retryDelayMs),this.fetchWithRetry(t,e,r-1);throw new Error(`HTTP ${s.status}`)}}function G(i){return i<=0?Promise.resolve():new Promise(t=>setTimeout(t,i))}async function gi(i,t){const e=i.getReader(),r=new TextDecoder;let s="",n={messages:[],done:!0};const o=a=>{const l=a.split(`
|
|
133
133
|
`).find(x=>x.startsWith("event:")),c=a.split(`
|
|
134
134
|
`).find(x=>x.startsWith("data:"));if(!c)return;const h=l?.slice(6).trim(),p=JSON.parse(c.slice(5).trim());h==="delta"&&typeof p.text=="string"?t(p.text):h==="done"&&(n={messages:Array.isArray(p.messages)?p.messages:[],done:p.done!==!1})};for(;;){const{done:a,value:l}=await e.read();if(a)break;s+=r.decode(l,{stream:!0});let c;for(;(c=s.indexOf(`
|
|
135
135
|
|
|
@@ -137,5 +137,5 @@
|
|
|
137
137
|
<span class="mtb-record-dot"></span>
|
|
138
138
|
<span class="mtb-record-timer">00:00</span>
|
|
139
139
|
<button class="mtb-record-stop" type="button">${e.record.stop}</button>
|
|
140
|
-
`,t.append(this.el),this.timerEl=this.el.querySelector(".mtb-record-timer"),this.el.querySelector(".mtb-record-stop").addEventListener("click",s),this.intervalId=setInterval(()=>this.updateTimer(),1e3)}updateTimer(){const t=this.getDuration(),e=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");this.timerEl.textContent=`${e}:${r}`}destroy(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.el.remove()}}class zi{constructor(){this.session=null,this.bar=null,this.result=null}async start(t,e,r){this.session=new Bi(t,r),this.bar=new Fi(t,e,()=>this.session?.getDuration()??0,r),await this.session.start()}stop(){return this.session?(this.result=this.session.stop(),this.teardownUI(),this.result):null}getRecording(){return this.result}destroy(){this.teardownUI(),this.result=null}teardownUI(){this.session?.destroy(),this.session=null,this.bar?.destroy(),this.bar=null}}class st{constructor(t){this.tab=null,this.toolbar=null,this.session=null,this.drawBar=null,this.dim=null,this.popup=null,this.clarify=null,this.success=null,this.frustrationPrompt=null,this.frustrationDetector=null,this.mode="idle",this.via="pin",this.currentAnnotation=null,this.submittingUi=null,this.lastPopupPos=null,this.recordingManager=null,this.activeSubmission=null,this.submissionAttempt=0,this.lastHandoff={},this.config=t,this.messages=Pi(t.locale??"en"),this.apiClient=new bi(t.projectKey,t.apiUrl,void 0,t.userToken,t.userTokenFn),this.consoleCollector=new ti,this.consoleCollector.start(),this.breadcrumbCollector=new ii,this.breadcrumbCollector.start(),this.buildUI(),t.frustrationDetection!==!1&&(this.frustrationDetector=new I(()=>this.handleFrustration()),this.frustrationDetector.start())}buildUI(){this.shadow=new Mt(this.config.theme??"auto"),this.tab=new Lt(this.shadow,this.messages,this.config.position??"right",()=>this.handleTabClick(),this.config.tabText)}handleTabClick(){this.mode==="idle"?(this.dismissFrustrationPrompt(),this.enterAnnotationMode()):this.exitAll()}handleFrustration(){this.mode!=="idle"||this.frustrationPrompt||(this.frustrationPrompt=new At(this.shadow,this.messages,{onTell:()=>{this.dismissFrustrationPrompt(),this.enterAnnotationMode()},onDismiss:()=>this.dismissFrustrationPrompt()}))}dismissFrustrationPrompt(){this.frustrationPrompt?.destroy(),this.frustrationPrompt=null}enterAnnotationMode(){this.mode="annotating",this.tab?.setActive(!0),this.toolbar=new Rt(this.shadow,this.messages,()=>this.exitAll(),t=>this.handleToolbarModeChange(t)),this.session=this.createSession()}createSession(){return new Ut(this.shadow,this.messages,{onPin:(t,e)=>{this.currentAnnotation=t,this.via="pin",this.showPopup(t.x,t.y,e)},onDrawStroke:()=>this.handleDrawStroke()})}handleToolbarModeChange(t){if(this.mode==="clarifying"){this.toolbar?.setMode(this.via==="record"?"record":"markup");return}if(t==="record"){if(this.mode==="recording")return;this.mode="recording",this.currentAnnotation=null,this.teardownDraw(),this.session?.destroy(),this.session=null,this.recordingManager=new zi,this.recordingManager.start(this.shadow,this.messages,
|
|
140
|
+
`,t.append(this.el),this.timerEl=this.el.querySelector(".mtb-record-timer"),this.el.querySelector(".mtb-record-stop").addEventListener("click",s),this.intervalId=setInterval(()=>this.updateTimer(),1e3)}updateTimer(){const t=this.getDuration(),e=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");this.timerEl.textContent=`${e}:${r}`}destroy(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.el.remove()}}class zi{constructor(){this.session=null,this.bar=null,this.result=null}async start(t,e,r){this.session=new Bi(t,r),this.bar=new Fi(t,e,()=>this.session?.getDuration()??0,r),await this.session.start()}stop(){return this.session?(this.result=this.session.stop(),this.teardownUI(),this.result):null}getRecording(){return this.result}destroy(){this.teardownUI(),this.result=null}teardownUI(){this.session?.destroy(),this.session=null,this.bar?.destroy(),this.bar=null}}class st{constructor(t){this.tab=null,this.toolbar=null,this.session=null,this.drawBar=null,this.dim=null,this.popup=null,this.clarify=null,this.success=null,this.frustrationPrompt=null,this.frustrationDetector=null,this.mode="idle",this.via="pin",this.currentAnnotation=null,this.submittingUi=null,this.lastPopupPos=null,this.recordingManager=null,this.activeSubmission=null,this.submissionAttempt=0,this.lastHandoff={},this.handleKeydown=e=>{if(e.key==="Escape")switch(this.mode){case"annotating":case"popup":e.preventDefault(),e.stopPropagation(),this.exitAll();break;case"drawing":e.preventDefault(),e.stopPropagation(),this.cancelDraw();break;case"recording":e.preventDefault(),e.stopPropagation(),this.handleRecordStop();break}},this.handleRecordStop=()=>{this.recordingManager&&(this.recordingManager.stop(),this.via="record",this.showPopup(window.innerWidth/2,window.innerHeight/2,this.messages.record.timer_label))},this.config=t,this.messages=Pi(t.locale??"en"),this.apiClient=new bi(t.projectKey,t.apiUrl,void 0,t.userToken,t.userTokenFn),this.consoleCollector=new ti,this.consoleCollector.start(),this.breadcrumbCollector=new ii,this.breadcrumbCollector.start(),this.buildUI(),t.frustrationDetection!==!1&&(this.frustrationDetector=new I(()=>this.handleFrustration()),this.frustrationDetector.start()),document.addEventListener("keydown",this.handleKeydown,!0)}buildUI(){this.shadow=new Mt(this.config.theme??"auto"),this.tab=new Lt(this.shadow,this.messages,this.config.position??"right",()=>this.handleTabClick(),this.config.tabText)}handleTabClick(){this.mode==="idle"?(this.dismissFrustrationPrompt(),this.enterAnnotationMode()):this.exitAll()}handleFrustration(){this.mode!=="idle"||this.frustrationPrompt||(this.frustrationPrompt=new At(this.shadow,this.messages,{onTell:()=>{this.dismissFrustrationPrompt(),this.enterAnnotationMode()},onDismiss:()=>this.dismissFrustrationPrompt()}))}dismissFrustrationPrompt(){this.frustrationPrompt?.destroy(),this.frustrationPrompt=null}enterAnnotationMode(){this.mode="annotating",this.tab?.setActive(!0),this.toolbar=new Rt(this.shadow,this.messages,()=>this.exitAll(),t=>this.handleToolbarModeChange(t)),this.session=this.createSession()}createSession(){return new Ut(this.shadow,this.messages,{onPin:(t,e)=>{this.currentAnnotation=t,this.via="pin",this.showPopup(t.x,t.y,e)},onDrawStroke:()=>this.handleDrawStroke()})}handleToolbarModeChange(t){if(this.mode==="clarifying"){this.toolbar?.setMode(this.via==="record"?"record":"markup");return}if(t==="record"){if(this.mode==="recording")return;this.mode="recording",this.currentAnnotation=null,this.teardownDraw(),this.session?.destroy(),this.session=null,this.recordingManager=new zi,this.recordingManager.start(this.shadow,this.messages,this.handleRecordStop).catch(e=>{console.warn("[MakeThisBetter] Interaction replay unavailable, falling back to markup:",e),this.mode==="recording"&&(this.toolbar?.setMode("markup"),this.handleToolbarModeChange("markup"))})}else this.recordingManager?.destroy(),this.recordingManager=null,this.teardownDraw(),this.session||(this.session=this.createSession()),this.mode="annotating"}handleDrawStroke(){this.mode!=="drawing"&&(this.mode="drawing",this.drawBar=new qt(this.shadow,{messages:this.messages,onUndo:()=>this.handleDrawUndoRedo("undo"),onRedo:()=>this.handleDrawUndoRedo("redo"),onCancel:()=>this.cancelDraw(),onSubmit:t=>this.handleDrawSubmit(t)})),this.refreshDrawBar()}handleDrawUndoRedo(t){t==="undo"?this.session?.undoDraw():this.session?.redoDraw(),this.refreshDrawBar()}refreshDrawBar(){this.session&&this.drawBar?.setUndoRedo(this.session.canUndoDraw(),this.session.canRedoDraw())}cancelDraw(){this.session?.clearDraw(),this.teardownDraw(),this.mode="annotating"}teardownDraw(){this.drawBar?.destroy(),this.drawBar=null}handleDrawSubmit(t){const e=this.session?.getDrawAnnotation();if(!e){this.cancelDraw();return}this.currentAnnotation=e,this.via="draw",this.session?.dismissInteraction(),this.submittingUi=this.drawBar,this.handleSubmit(t||this.messages.annotation.drawing)}showPopup(t,e,r){this.mode="popup",this.lastPopupPos={x:t,y:e},this.teardownDraw(),this.session?.dismissInteraction(),this.popup?.destroy(),this.popup=null,this.dim?.destroy(),this.dim=null,this.dim=new Dt(this.shadow,()=>this.exitAll()),this.popup=new Nt(this.shadow,{targetName:r,x:t,y:e,messages:this.messages,onSubmit:s=>this.handleSubmit(s),onClose:()=>this.exitAll(),onMyFeedback:this.buildMyFeedbackHandler()}),this.submittingUi=this.popup}buildMyFeedbackHandler(){if(!this.config.user&&ki())return async()=>{const t=await this.apiClient.createIdentityToken(Z());!t?.identity_token||!t.board_url||(et(t.board_url),window.open(`${t.board_url}?identity=${encodeURIComponent(t.identity_token)}`,"_blank"))}}async handleSubmit(t){const e=this.submittingUi;if(!e)return;const r=++this.submissionAttempt;e.setLoading(!0),await Oi();const s=this.currentAnnotation,n=this.recordingManager?.getRecording()??void 0,[o,a]=await Promise.all([Ne(s?[s]:[]),Promise.resolve(ui())]),l=xi(t,a,this.consoleCollector.getErrors(),s,this.config.user,n,this.config.user?void 0:Z(),this.config.user?void 0:tt(),this.breadcrumbCollector.getBreadcrumbs());try{const c=await this.apiClient.createSubmissionSession(l,o);if(r!==this.submissionAttempt){await this.apiClient.abandonSubmissionSession(c.id,c.token).catch(()=>{});return}this.activeSubmission=c;const h=this.buildSummaryContext(t,a,s);this.teardownDraw(),this.popup?.destroy(),this.popup=null,this.dim?.destroy(),this.dim=null,this.session?.destroy(),this.session=null,this.recordingManager?.destroy(),this.recordingManager=null,this.submittingUi=null,this.showClarify(c,this.lastPopupPos,h)}catch{if(r!==this.submissionAttempt)return;e.setLoading(!1),e.setError(this.messages.error.submit)}}buildSummaryContext(t,e,r){const s=this.messages.clarify.summary;return{originalDescription:t,element:r?.targetName??this.messages.annotation.element,page:e.page_url,browser:`${e.browser} · ${e.os}`,captured:this.via==="record"?s.recording:s.screenshot}}showClarify(t,e,r){this.mode="clarifying",this.tab?.setActive(!0),this.clarify=new Yt(this.shadow,{submissionSessionId:t.id,submissionToken:t.token,apiClient:this.apiClient,messages:this.messages,summary:r,x:e?.x,y:e?.y,onFinalize:()=>this.finalizeSubmission()})}async finalizeSubmission(){const t=this.activeSubmission;if(!t)throw new Error("No active submission session");const e=this.submissionAttempt,r=await this.apiClient.finalizeSubmissionSession(t.id,t.token);e!==this.submissionAttempt||this.activeSubmission!==t||(this.activeSubmission=null,this.lastHandoff={feedbackId:r.id,boardUrl:r.board_url,identityToken:r.identity_token},r.board_url&&et(r.board_url),this.clarify?.destroy(),this.clarify=null,this.toolbar?.destroy(),this.toolbar=null,this.showSuccess({skipFollowup:t.ai_clarify_available===!1}))}showSuccess(t){this.mode="idle",this.tab?.setActive(!1),this.success=new Gt(this.shadow,this.messages,()=>{this.success?.destroy(),this.success=null},this.buildViewFeedbackHandler(),{...t,emailCapture:this.buildEmailCapture()})}buildEmailCapture(){const{feedbackId:t,identityToken:e}=this.lastHandoff;if(!(!t||!e)&&!tt())return{onSubmit:async r=>{const s=await this.apiClient.updateReporter(t,r,e);return s&&vi(r),s}}}buildViewFeedbackHandler(){const{boardUrl:t,identityToken:e}=this.lastHandoff;if(t){if(e)return()=>{window.open(`${t}?identity=${encodeURIComponent(e)}`,"_blank")};if(this.config.userToken||this.config.userTokenFn)return async()=>{const r=await this.apiClient.resolveUserToken();r&&window.open(`${t}?identity=${encodeURIComponent(r)}`,"_blank")}}}exitAll(){this.submissionAttempt+=1;const t=this.activeSubmission;this.activeSubmission=null,t&&this.apiClient.abandonSubmissionSession(t.id,t.token).catch(()=>{}),this.mode="idle",this.via="pin",this.tab?.setActive(!1),this.teardownDraw(),this.toolbar?.destroy(),this.toolbar=null,this.session?.destroy(),this.session=null,this.dim?.destroy(),this.dim=null,this.popup?.destroy(),this.popup=null,this.clarify?.destroy(),this.clarify=null,this.currentAnnotation=null,this.submittingUi=null,this.recordingManager?.destroy(),this.recordingManager=null}destroy(){document.removeEventListener("keydown",this.handleKeydown,!0),this.exitAll(),this.consoleCollector.stop(),this.breadcrumbCollector.stop(),this.frustrationDetector?.stop(),this.dismissFrustrationPrompt(),this.clarify?.destroy(),this.success?.destroy(),this.tab?.destroy(),this.recordingManager?.destroy(),this.shadow.destroy()}}function Oi(){return new Promise(i=>requestAnimationFrame(()=>setTimeout(i,0)))}let b=null;const wt={init(i){b&&(b.destroy(),b=null),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{b=new st(i)}):b=new st(i)},destroy(){b?.destroy(),b=null}};typeof window<"u"&&(window.MakeThisBetter=wt);exports.MakeThisBetter=wt;
|
|
141
141
|
//# sourceMappingURL=makethisbetter.cjs.map
|