@repros/sdk 0.0.1 → 0.0.2
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.cjs +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/repros-sdk.global.js +14 -14
- package/dist/repros-sdk.global.js.map +1 -1
- package/package.json +8 -8
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";var Repros=(()=>{var J=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.prototype.hasOwnProperty;var nt=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})},rt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of et(t))!tt.call(e,o)&&o!==n&&J(e,o,{get:()=>t[o],enumerable:!(r=Ze(t,o))||r.enumerable});return e};var ot=e=>rt(J({},"__esModule",{value:!0}),e);var In={};nt(In,{captureScreenshot:()=>D,getSession:()=>Je,init:()=>ce});var at="https://www.repros.dev",ue="repros_claim";function de(){if(typeof window=="undefined")return null;let e=new URL(window.location.href),t=e.searchParams.get(ue);return t?(e.searchParams.delete(ue),window.history.replaceState(window.history.state,"",e.toString()),t):null}async function pe(e,t=at){var n;try{let r=await fetch(`${t.replace(/\/+$/,"")}/api/customer-sessions/claim`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e})}),o=await r.json().catch(()=>null);return!r.ok||!(o!=null&&o.ok)||!o.sessionId?(console.warn("[Repros SDK] couldn't claim report link:",(n=o==null?void 0:o.reason)!=null?n:r.status),null):{sessionId:o.sessionId,token:e,apiBase:t}}catch(r){return console.warn("[Repros SDK] couldn't reach Repros to claim report link:",r),null}}function Q(e,t){let n=document.createElement("div");n.style.cssText="position:fixed;pointer-events:none;z-index:2147483645;border:2px solid #7c3aed;background:rgba(124,58,237,0.15);border-radius:2px;display:none;box-sizing:border-box;",document.body.appendChild(n);let r=null;function o(d){if(d===r)return;r=d;let c=d.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${c.left}px`,top:`${c.top}px`,width:`${c.width}px`,height:`${c.height}px`})}function s(d){let c=document.elementFromPoint(d.clientX,d.clientY);c&&c!==n&&o(c)}function i(d){d.preventDefault(),d.stopPropagation();let c=r;if(l(),!c){t();return}let m=c.getBoundingClientRect();e({rect:{x:m.left+window.scrollX,y:m.top+window.scrollY,width:m.width,height:m.height}})}function a(d){d.key==="Escape"&&(l(),t())}function l(){window.removeEventListener("mousemove",s,!0),window.removeEventListener("click",i,!0),window.removeEventListener("keydown",a,!0),n.remove()}return window.addEventListener("mousemove",s,!0),window.addEventListener("click",i,!0),window.addEventListener("keydown",a,!0),l}function Z(e,t){let n=document.createElement("div");n.style.cssText="position:fixed;inset:0;z-index:2147483645;cursor:crosshair;background:rgba(0,0,0,0.01);";let r=document.createElement("div");r.style.cssText="position:fixed;pointer-events:none;z-index:2147483645;border:2px solid #7c3aed;background:rgba(124,58,237,0.15);display:none;box-sizing:border-box;",document.body.appendChild(n),document.body.appendChild(r);let o=!1,s=0,i=0;function a(p,h){return{x:Math.min(s,p),y:Math.min(i,h),width:Math.abs(p-s),height:Math.abs(h-i)}}function l(p){o=!0,s=p.clientX,i=p.clientY,r.style.display="block",d(a(p.clientX,p.clientY))}function d(p){Object.assign(r.style,{left:`${p.x}px`,top:`${p.y}px`,width:`${p.width}px`,height:`${p.height}px`})}function c(p){o&&d(a(p.clientX,p.clientY))}function m(p){if(!o)return;o=!1;let h=a(p.clientX,p.clientY);if(g(),h.width<4||h.height<4){t();return}e({rect:{x:h.x+window.scrollX,y:h.y+window.scrollY,width:h.width,height:h.height}})}function u(p){p.key==="Escape"&&(g(),t())}function g(){n.removeEventListener("mousedown",l),window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",m),window.removeEventListener("keydown",u,!0),n.remove(),r.remove()}return n.addEventListener("mousedown",l),window.addEventListener("mousemove",c),window.addEventListener("mouseup",m),window.addEventListener("keydown",u,!0),g}function st(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new Error("Failed to load screenshot for compositing")),r.src=e})}async function ee(e,t,n){let r=await st(e),o=document.createElement("canvas");o.width=r.width,o.height=r.height;let s=o.getContext("2d");if(!s)throw new Error("2d canvas context unavailable");s.drawImage(r,0,0);let i=r.width/(n.width||r.width),a=r.height/(n.height||r.height),l=t.x*i,d=t.y*a,c=t.width*i,m=t.height*a;return s.fillStyle="rgba(124, 58, 237, 0.15)",s.fillRect(l,d,c,m),s.lineWidth=3,s.strokeStyle="#7c3aed",s.strokeRect(l,d,c,m),o.toDataURL("image/png")}function it(e,t){return e[13]=1,e[14]=t>>8,e[15]=t&255,e[16]=t>>8,e[17]=t&255,e}var ve=112,Se=72,Ee=89,ke=115,te;function ct(){let e=new Int32Array(256);for(let t=0;t<256;t++){let n=t;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}return e}function lt(e){let t=-1;te||(te=ct());for(let n=0;n<e.length;n++)t=te[(t^e[n])&255]^t>>>8;return t^-1}function ut(e){let t=e.length-1;for(let n=t;n>=4;n--)if(e[n-4]===9&&e[n-3]===ve&&e[n-2]===Se&&e[n-1]===Ee&&e[n]===ke)return n-3;return 0}function dt(e,t,n=!1){let r=new Uint8Array(13);t*=39.3701,r[0]=ve,r[1]=Se,r[2]=Ee,r[3]=ke,r[4]=t>>>24,r[5]=t>>>16,r[6]=t>>>8,r[7]=t&255,r[8]=r[4],r[9]=r[5],r[10]=r[6],r[11]=r[7],r[12]=1;let o=lt(r),s=new Uint8Array(4);if(s[0]=o>>>24,s[1]=o>>>16,s[2]=o>>>8,s[3]=o&255,n){let i=ut(e);return e.set(r,i),e.set(s,i+13),e}else{let i=new Uint8Array(4);i[0]=0,i[1]=0,i[2]=0,i[3]=9;let a=new Uint8Array(54);return a.set(e,0),a.set(i,33),a.set(r,37),a.set(s,50),a}}var pt="AAlwSFlz",ft="AAAJcEhZ",mt="AAAACXBI";function gt(e){let t=e.indexOf(pt);return t===-1&&(t=e.indexOf(ft)),t===-1&&(t=e.indexOf(mt)),t}var xe="[modern-screenshot]",N=typeof window!="undefined",ht=N&&"Worker"in window,wt=N&&"atob"in window,bt=N&&"btoa"in window,ye,oe=N?(ye=window.navigator)==null?void 0:ye.userAgent:"",Ce=oe.includes("Chrome"),z=oe.includes("AppleWebKit")&&!Ce,ae=oe.includes("Firefox"),yt=e=>e&&"__CONTEXT__"in e,vt=e=>e.constructor.name==="CSSFontFaceRule",St=e=>e.constructor.name==="CSSImportRule",Et=e=>e.constructor.name==="CSSLayerBlockRule",A=e=>e.nodeType===1,q=e=>typeof e.className=="object",Te=e=>e.tagName==="image",kt=e=>e.tagName==="use",B=e=>A(e)&&typeof e.style!="undefined"&&!q(e),xt=e=>e.nodeType===8,Ct=e=>e.nodeType===3,_=e=>e.tagName==="IMG",j=e=>e.tagName==="VIDEO",Tt=e=>e.tagName==="CANVAS",Rt=e=>e.tagName==="TEXTAREA",At=e=>e.tagName==="INPUT",Nt=e=>e.tagName==="STYLE",Lt=e=>e.tagName==="SCRIPT",It=e=>e.tagName==="SELECT",Mt=e=>e.tagName==="SLOT",_t=e=>e.tagName==="IFRAME",Dt=(...e)=>console.warn(xe,...e);function Pt(e){var n;let t=(n=e==null?void 0:e.createElement)==null?void 0:n.call(e,"canvas");return t&&(t.height=t.width=1),!!t&&"toDataURL"in t&&!!t.toDataURL("image/webp").includes("image/webp")}var ne=e=>e.startsWith("data:");function Re(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(N&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!N)return e;let n=H().implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),t&&(r.href=t),o.href=e,o.href}function H(e){var t;return(t=e&&A(e)?e==null?void 0:e.ownerDocument:e)!=null?t:window.document}var X="http://www.w3.org/2000/svg";function Ut(e,t,n){let r=H(n).createElementNS(X,"svg");return r.setAttributeNS(null,"width",e.toString()),r.setAttributeNS(null,"height",t.toString()),r.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),r}function $t(e,t){let n=new XMLSerializer().serializeToString(e);return t&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}function Bt(e,t){return new Promise((n,r)=>{let o=new FileReader;o.onload=()=>n(o.result),o.onerror=()=>r(o.error),o.onabort=()=>r(new Error(`Failed read blob to ${t}`)),t==="dataUrl"?o.readAsDataURL(e):t==="arrayBuffer"&&o.readAsArrayBuffer(e)})}var Ot=e=>Bt(e,"dataUrl");function M(e,t){let n=H(t).createElement("img");return n.decoding="sync",n.loading="eager",n.src=e,n}function O(e,t){return new Promise(n=>{let{timeout:r,ownerDocument:o,onError:s,onWarn:i}=t!=null?t:{},a=typeof e=="string"?M(e,H(o)):e,l=null,d=null;function c(){n(a),l&&clearTimeout(l),d==null||d()}if(r&&(l=setTimeout(c,r)),j(a)){let m=a.currentSrc||a.src;if(!m)return a.poster?O(a.poster,t).then(n):c();if(a.readyState>=2)return c();let u=c,g=p=>{i==null||i("Failed video load",m,p),s==null||s(p),c()};d=()=>{a.removeEventListener("loadeddata",u),a.removeEventListener("error",g)},a.addEventListener("loadeddata",u,{once:!0}),a.addEventListener("error",g,{once:!0})}else{let m=Te(a)?a.href.baseVal:a.currentSrc||a.src;if(!m)return c();let u=async()=>{if(_(a)&&"decode"in a)try{await a.decode()}catch(p){i==null||i("Failed to decode image, trying to render anyway",a.dataset.originalSrc||m,p)}c()},g=p=>{i==null||i("Failed image load",a.dataset.originalSrc||m,p),c()};if(_(a)&&a.complete)return u();d=()=>{a.removeEventListener("load",u),a.removeEventListener("error",g)},a.addEventListener("load",u,{once:!0}),a.addEventListener("error",g,{once:!0})}})}async function Ft(e,t){B(e)&&(_(e)||j(e)?await O(e,t):await Promise.all(["img","video"].flatMap(n=>Array.from(e.querySelectorAll(n)).map(r=>O(r,t)))))}var Ae=(function(){let t=0,n=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${n()}${t}`)})();function Ne(e){return e==null?void 0:e.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}var fe=0;function qt(e){let t=`${xe}[#${fe}]`;return fe++,{time:n=>e&&console.time(`${t} ${n}`),timeEnd:n=>e&&console.timeEnd(`${t} ${n}`),warn:(...n)=>e&&Dt(...n)}}function zt(e){return{cache:e?"no-cache":"force-cache"}}async function V(e,t){return yt(e)?e:jt(e,{...t,autoDestruct:!0})}async function jt(e,t){var g,p,h,b,E;let{scale:n=1,workerUrl:r,workerNumber:o=1}=t||{},s=!!(t!=null&&t.debug),i=(g=t==null?void 0:t.features)!=null?g:!0,a=(p=e.ownerDocument)!=null?p:N?window.document:void 0,l=(b=(h=e.ownerDocument)==null?void 0:h.defaultView)!=null?b:N?window:void 0,d=new Map,c={width:0,height:0,quality:1,type:"image/png",scale:n,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:s,fetch:{requestInit:zt((E=t==null?void 0:t.fetch)==null?void 0:E.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1,...t==null?void 0:t.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:o,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...t,__CONTEXT__:!0,log:qt(s),node:e,ownerDocument:a,ownerWindow:l,dpi:n===1?null:96*n,svgStyleElement:Le(a),svgDefsElement:a==null?void 0:a.createElementNS(X,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:ht&&r&&o?o:0})].map(()=>{try{let w=new Worker(r);return w.onmessage=async f=>{var k,T,R,U;let{url:v,result:S}=f.data;S?(T=(k=d.get(v))==null?void 0:k.resolve)==null||T.call(k,S):(U=(R=d.get(v))==null?void 0:R.reject)==null||U.call(R,new Error(`Error receiving message from worker: ${v}`))},w.onmessageerror=f=>{var S,k;let{url:v}=f.data;(k=(S=d.get(v))==null?void 0:S.reject)==null||k.call(S,new Error(`Error receiving message from worker: ${v}`))},w}catch(w){return c.log.warn("Failed to new Worker",w),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[Pt(a)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:d,drawImageCount:0,tasks:[],features:i,isEnable:w=>{var f,v;return w==="restoreScrollPosition"?typeof i=="boolean"?!1:(f=i[w])!=null?f:!1:typeof i=="boolean"?i:(v=i[w])!=null?v:!0},shadowRoots:[]};c.log.time("wait until load"),await Ft(e,{timeout:c.timeout,onWarn:c.log.warn}),c.log.timeEnd("wait until load");let{width:m,height:u}=Ht(e,c);return c.width=m,c.height=u,c}function Le(e){if(!e)return;let t=e.createElement("style"),n=t.ownerDocument.createTextNode(`
|
|
1
|
+
"use strict";var Repros=(()=>{var J=Object.defineProperty;var Ze=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var tt=Object.prototype.hasOwnProperty;var nt=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:!0})},rt=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of et(t))!tt.call(e,o)&&o!==n&&J(e,o,{get:()=>t[o],enumerable:!(r=Ze(t,o))||r.enumerable});return e};var ot=e=>rt(J({},"__esModule",{value:!0}),e);var Mn={};nt(Mn,{captureScreenshot:()=>D,getSession:()=>Je,init:()=>le});var at="https://www.repros.dev",de="repros_claim";function pe(){if(typeof window=="undefined")return null;let e=new URL(window.location.href),t=e.searchParams.get(de);return t?(e.searchParams.delete(de),window.history.replaceState(window.history.state,"",e.toString()),t):null}async function fe(e,t=at){var n;try{let r=await fetch(`${t.replace(/\/+$/,"")}/api/customer-sessions/claim`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e})}),o=await r.json().catch(()=>null);return!r.ok||!(o!=null&&o.ok)||!o.sessionId?(console.warn("[Repros SDK] couldn't claim report link:",(n=o==null?void 0:o.reason)!=null?n:r.status),null):{sessionId:o.sessionId,token:e,apiBase:t}}catch(r){return console.warn("[Repros SDK] couldn't reach Repros to claim report link:",r),null}}function Q(e,t){let n=document.createElement("div");n.style.cssText="position:fixed;pointer-events:none;z-index:2147483645;border:2px solid #7c3aed;background:rgba(124,58,237,0.15);border-radius:2px;display:none;box-sizing:border-box;",document.body.appendChild(n);let r=null;function o(d){if(d===r)return;r=d;let c=d.getBoundingClientRect();Object.assign(n.style,{display:"block",left:`${c.left}px`,top:`${c.top}px`,width:`${c.width}px`,height:`${c.height}px`})}function s(d){let c=document.elementFromPoint(d.clientX,d.clientY);c&&c!==n&&o(c)}function i(d){d.preventDefault(),d.stopPropagation();let c=r;if(l(),!c){t();return}let m=c.getBoundingClientRect();e({rect:{x:m.left+window.scrollX,y:m.top+window.scrollY,width:m.width,height:m.height}})}function a(d){d.key==="Escape"&&(l(),t())}function l(){window.removeEventListener("mousemove",s,!0),window.removeEventListener("click",i,!0),window.removeEventListener("keydown",a,!0),n.remove()}return window.addEventListener("mousemove",s,!0),window.addEventListener("click",i,!0),window.addEventListener("keydown",a,!0),l}function Z(e,t){let n=document.createElement("div");n.style.cssText="position:fixed;inset:0;z-index:2147483645;cursor:crosshair;background:rgba(0,0,0,0.01);";let r=document.createElement("div");r.style.cssText="position:fixed;pointer-events:none;z-index:2147483645;border:2px solid #7c3aed;background:rgba(124,58,237,0.15);display:none;box-sizing:border-box;",document.body.appendChild(n),document.body.appendChild(r);let o=!1,s=0,i=0;function a(f,h){return{x:Math.min(s,f),y:Math.min(i,h),width:Math.abs(f-s),height:Math.abs(h-i)}}function l(f){o=!0,s=f.clientX,i=f.clientY,r.style.display="block",d(a(f.clientX,f.clientY))}function d(f){Object.assign(r.style,{left:`${f.x}px`,top:`${f.y}px`,width:`${f.width}px`,height:`${f.height}px`})}function c(f){o&&d(a(f.clientX,f.clientY))}function m(f){if(!o)return;o=!1;let h=a(f.clientX,f.clientY);if(g(),h.width<4||h.height<4){t();return}e({rect:{x:h.x+window.scrollX,y:h.y+window.scrollY,width:h.width,height:h.height}})}function u(f){f.key==="Escape"&&(g(),t())}function g(){n.removeEventListener("mousedown",l),window.removeEventListener("mousemove",c),window.removeEventListener("mouseup",m),window.removeEventListener("keydown",u,!0),n.remove(),r.remove()}return n.addEventListener("mousedown",l),window.addEventListener("mousemove",c),window.addEventListener("mouseup",m),window.addEventListener("keydown",u,!0),g}function st(e){return new Promise((t,n)=>{let r=new Image;r.onload=()=>t(r),r.onerror=()=>n(new Error("Failed to load screenshot for compositing")),r.src=e})}async function ee(e,t,n){let r=await st(e),o=document.createElement("canvas");o.width=r.width,o.height=r.height;let s=o.getContext("2d");if(!s)throw new Error("2d canvas context unavailable");s.drawImage(r,0,0);let i=r.width/(n.width||r.width),a=r.height/(n.height||r.height),l=t.x*i,d=t.y*a,c=t.width*i,m=t.height*a;return s.fillStyle="rgba(124, 58, 237, 0.15)",s.fillRect(l,d,c,m),s.lineWidth=3,s.strokeStyle="#7c3aed",s.strokeRect(l,d,c,m),o.toDataURL("image/png")}function it(e,t){return e[13]=1,e[14]=t>>8,e[15]=t&255,e[16]=t>>8,e[17]=t&255,e}var Se=112,Ee=72,ke=89,xe=115,te;function ct(){let e=new Int32Array(256);for(let t=0;t<256;t++){let n=t;for(let r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n}return e}function lt(e){let t=-1;te||(te=ct());for(let n=0;n<e.length;n++)t=te[(t^e[n])&255]^t>>>8;return t^-1}function ut(e){let t=e.length-1;for(let n=t;n>=4;n--)if(e[n-4]===9&&e[n-3]===Se&&e[n-2]===Ee&&e[n-1]===ke&&e[n]===xe)return n-3;return 0}function dt(e,t,n=!1){let r=new Uint8Array(13);t*=39.3701,r[0]=Se,r[1]=Ee,r[2]=ke,r[3]=xe,r[4]=t>>>24,r[5]=t>>>16,r[6]=t>>>8,r[7]=t&255,r[8]=r[4],r[9]=r[5],r[10]=r[6],r[11]=r[7],r[12]=1;let o=lt(r),s=new Uint8Array(4);if(s[0]=o>>>24,s[1]=o>>>16,s[2]=o>>>8,s[3]=o&255,n){let i=ut(e);return e.set(r,i),e.set(s,i+13),e}else{let i=new Uint8Array(4);i[0]=0,i[1]=0,i[2]=0,i[3]=9;let a=new Uint8Array(54);return a.set(e,0),a.set(i,33),a.set(r,37),a.set(s,50),a}}var pt="AAlwSFlz",ft="AAAJcEhZ",mt="AAAACXBI";function gt(e){let t=e.indexOf(pt);return t===-1&&(t=e.indexOf(ft)),t===-1&&(t=e.indexOf(mt)),t}var Ce="[modern-screenshot]",N=typeof window!="undefined",ht=N&&"Worker"in window,wt=N&&"atob"in window,bt=N&&"btoa"in window,ve,oe=N?(ve=window.navigator)==null?void 0:ve.userAgent:"",Te=oe.includes("Chrome"),z=oe.includes("AppleWebKit")&&!Te,ae=oe.includes("Firefox"),yt=e=>e&&"__CONTEXT__"in e,vt=e=>e.constructor.name==="CSSFontFaceRule",St=e=>e.constructor.name==="CSSImportRule",Et=e=>e.constructor.name==="CSSLayerBlockRule",A=e=>e.nodeType===1,q=e=>typeof e.className=="object",Re=e=>e.tagName==="image",kt=e=>e.tagName==="use",B=e=>A(e)&&typeof e.style!="undefined"&&!q(e),xt=e=>e.nodeType===8,Ct=e=>e.nodeType===3,_=e=>e.tagName==="IMG",H=e=>e.tagName==="VIDEO",Tt=e=>e.tagName==="CANVAS",Rt=e=>e.tagName==="TEXTAREA",At=e=>e.tagName==="INPUT",Nt=e=>e.tagName==="STYLE",Lt=e=>e.tagName==="SCRIPT",Mt=e=>e.tagName==="SELECT",It=e=>e.tagName==="SLOT",_t=e=>e.tagName==="IFRAME",Dt=(...e)=>console.warn(Ce,...e);function Pt(e){var n;let t=(n=e==null?void 0:e.createElement)==null?void 0:n.call(e,"canvas");return t&&(t.height=t.width=1),!!t&&"toDataURL"in t&&!!t.toDataURL("image/webp").includes("image/webp")}var ne=e=>e.startsWith("data:");function Ae(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(N&&e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i)||!N)return e;let n=j().implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),t&&(r.href=t),o.href=e,o.href}function j(e){var t;return(t=e&&A(e)?e==null?void 0:e.ownerDocument:e)!=null?t:window.document}var X="http://www.w3.org/2000/svg";function Ut(e,t,n){let r=j(n).createElementNS(X,"svg");return r.setAttributeNS(null,"width",e.toString()),r.setAttributeNS(null,"height",t.toString()),r.setAttributeNS(null,"viewBox",`0 0 ${e} ${t}`),r}function $t(e,t){let n=new XMLSerializer().serializeToString(e);return t&&(n=n.replace(/[\u0000-\u0008\v\f\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]/gu,"")),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}function Bt(e,t){return new Promise((n,r)=>{let o=new FileReader;o.onload=()=>n(o.result),o.onerror=()=>r(o.error),o.onabort=()=>r(new Error(`Failed read blob to ${t}`)),t==="dataUrl"?o.readAsDataURL(e):t==="arrayBuffer"&&o.readAsArrayBuffer(e)})}var Ot=e=>Bt(e,"dataUrl");function I(e,t){let n=j(t).createElement("img");return n.decoding="sync",n.loading="eager",n.src=e,n}function O(e,t){return new Promise(n=>{let{timeout:r,ownerDocument:o,onError:s,onWarn:i}=t!=null?t:{},a=typeof e=="string"?I(e,j(o)):e,l=null,d=null;function c(){n(a),l&&clearTimeout(l),d==null||d()}if(r&&(l=setTimeout(c,r)),H(a)){let m=a.currentSrc||a.src;if(!m)return a.poster?O(a.poster,t).then(n):c();if(a.readyState>=2)return c();let u=c,g=f=>{i==null||i("Failed video load",m,f),s==null||s(f),c()};d=()=>{a.removeEventListener("loadeddata",u),a.removeEventListener("error",g)},a.addEventListener("loadeddata",u,{once:!0}),a.addEventListener("error",g,{once:!0})}else{let m=Re(a)?a.href.baseVal:a.currentSrc||a.src;if(!m)return c();let u=async()=>{if(_(a)&&"decode"in a)try{await a.decode()}catch(f){i==null||i("Failed to decode image, trying to render anyway",a.dataset.originalSrc||m,f)}c()},g=f=>{i==null||i("Failed image load",a.dataset.originalSrc||m,f),c()};if(_(a)&&a.complete)return u();d=()=>{a.removeEventListener("load",u),a.removeEventListener("error",g)},a.addEventListener("load",u,{once:!0}),a.addEventListener("error",g,{once:!0})}})}async function Ft(e,t){B(e)&&(_(e)||H(e)?await O(e,t):await Promise.all(["img","video"].flatMap(n=>Array.from(e.querySelectorAll(n)).map(r=>O(r,t)))))}var Ne=(function(){let t=0,n=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${n()}${t}`)})();function Le(e){return e==null?void 0:e.split(",").map(t=>t.trim().replace(/"|'/g,"").toLowerCase()).filter(Boolean)}var me=0;function qt(e){let t=`${Ce}[#${me}]`;return me++,{time:n=>e&&console.time(`${t} ${n}`),timeEnd:n=>e&&console.timeEnd(`${t} ${n}`),warn:(...n)=>e&&Dt(...n)}}function zt(e){return{cache:e?"no-cache":"force-cache"}}async function V(e,t){return yt(e)?e:Ht(e,{...t,autoDestruct:!0})}async function Ht(e,t){var g,f,h,b,E;let{scale:n=1,workerUrl:r,workerNumber:o=1}=t||{},s=!!(t!=null&&t.debug),i=(g=t==null?void 0:t.features)!=null?g:!0,a=(f=e.ownerDocument)!=null?f:N?window.document:void 0,l=(b=(h=e.ownerDocument)==null?void 0:h.defaultView)!=null?b:N?window:void 0,d=new Map,c={width:0,height:0,quality:1,type:"image/png",scale:n,backgroundColor:null,style:null,filter:null,maximumCanvasSize:0,timeout:3e4,progress:null,debug:s,fetch:{requestInit:zt((E=t==null?void 0:t.fetch)==null?void 0:E.bypassingCache),placeholderImage:"data:image/png;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",bypassingCache:!1,...t==null?void 0:t.fetch},fetchFn:null,font:{},drawImageInterval:100,workerUrl:null,workerNumber:o,onCloneEachNode:null,onCloneNode:null,onEmbedNode:null,onCreateForeignObjectSvg:null,includeStyleProperties:null,autoDestruct:!1,...t,__CONTEXT__:!0,log:qt(s),node:e,ownerDocument:a,ownerWindow:l,dpi:n===1?null:96*n,svgStyleElement:Me(a),svgDefsElement:a==null?void 0:a.createElementNS(X,"defs"),svgStyles:new Map,defaultComputedStyles:new Map,workers:[...Array.from({length:ht&&r&&o?o:0})].map(()=>{try{let w=new Worker(r);return w.onmessage=async p=>{var k,T,R,U;let{url:v,result:S}=p.data;S?(T=(k=d.get(v))==null?void 0:k.resolve)==null||T.call(k,S):(U=(R=d.get(v))==null?void 0:R.reject)==null||U.call(R,new Error(`Error receiving message from worker: ${v}`))},w.onmessageerror=p=>{var S,k;let{url:v}=p.data;(k=(S=d.get(v))==null?void 0:S.reject)==null||k.call(S,new Error(`Error receiving message from worker: ${v}`))},w}catch(w){return c.log.warn("Failed to new Worker",w),null}}).filter(Boolean),fontFamilies:new Map,fontCssTexts:new Map,acceptOfImage:`${[Pt(a)&&"image/webp","image/svg+xml","image/*","*/*"].filter(Boolean).join(",")};q=0.8`,requests:d,drawImageCount:0,tasks:[],features:i,isEnable:w=>{var p,v;return w==="restoreScrollPosition"?typeof i=="boolean"?!1:(p=i[w])!=null?p:!1:typeof i=="boolean"?i:(v=i[w])!=null?v:!0},shadowRoots:[]};c.log.time("wait until load"),await Ft(e,{timeout:c.timeout,onWarn:c.log.warn}),c.log.timeEnd("wait until load");let{width:m,height:u}=jt(e,c);return c.width=m,c.height=u,c}function Me(e){if(!e)return;let t=e.createElement("style"),n=t.ownerDocument.createTextNode(`
|
|
2
2
|
.______background-clip--text {
|
|
3
3
|
background-clip: text;
|
|
4
4
|
-webkit-background-clip: text;
|
|
5
5
|
}
|
|
6
|
-
`);return t.appendChild(n),t}function
|
|
7
|
-
`),w=a.get(E);w||(w=[],a.set(E,w)),w.push(`.${g[0]}${c}`)}nn.forEach(d),n&&rn.forEach(d)}var
|
|
8
|
-
`))}else{let l=Array.from(n.styleSheets).filter(g=>{try{return"cssRules"in g&&!!g.cssRules.length}catch(
|
|
9
|
-
`)):i.push(
|
|
10
|
-
`))}))})}}var bn=/(\/\*[\s\S]*?\*\/)/g,
|
|
6
|
+
`);return t.appendChild(n),t}function jt(e,t){let{width:n,height:r}=t;if(A(e)&&(!n||!r)){let o=e.getBoundingClientRect();n=n||o.width||Number(e.getAttribute("width"))||0,r=r||o.height||Number(e.getAttribute("height"))||0}return{width:n,height:r}}async function Xt(e,t){let{log:n,timeout:r,drawImageCount:o,drawImageInterval:s}=t;n.time("image to canvas");let i=await O(e,{timeout:r,onWarn:t.log.warn}),{canvas:a,context2d:l}=Vt(e.ownerDocument,t),d=()=>{try{l==null||l.drawImage(i,0,0,a.width,a.height)}catch(c){t.log.warn("Failed to drawImage",c)}};if(d(),t.isEnable("fixSvgXmlDecode"))for(let c=0;c<o;c++)await new Promise(m=>{setTimeout(()=>{l==null||l.clearRect(0,0,a.width,a.height),d(),m()},c+s)});return t.drawImageCount=0,n.timeEnd("image to canvas"),a}function Vt(e,t){let{width:n,height:r,scale:o,backgroundColor:s,maximumCanvasSize:i}=t,a=e.createElement("canvas");a.width=Math.floor(n*o),a.height=Math.floor(r*o),a.style.width=`${n}px`,a.style.height=`${r}px`,i&&(a.width>i||a.height>i)&&(a.width>i&&a.height>i?a.width>a.height?(a.height*=i/a.width,a.width=i):(a.width*=i/a.height,a.height=i):a.width>i?(a.height*=i/a.width,a.width=i):(a.width*=i/a.height,a.height=i));let l=a.getContext("2d");return l&&s&&(l.fillStyle=s,l.fillRect(0,0,a.width,a.height)),{canvas:a,context2d:l}}function Ie(e,t){if(e.ownerDocument)try{let s=e.toDataURL();if(s!=="data:,")return I(s,e.ownerDocument)}catch(s){t.log.warn("Failed to clone canvas",s)}let n=e.cloneNode(!1),r=e.getContext("2d"),o=n.getContext("2d");try{return r&&o&&o.putImageData(r.getImageData(0,0,e.width,e.height),0,0),n}catch(s){t.log.warn("Failed to clone canvas",s)}return n}function Wt(e,t){var n;try{if((n=e==null?void 0:e.contentDocument)!=null&&n.documentElement)return se(e.contentDocument.documentElement,t)}catch(r){t.log.warn("Failed to clone iframe",r)}return e.cloneNode(!1)}function Yt(e){let t=e.cloneNode(!1);return e.currentSrc&&e.currentSrc!==e.src&&(t.src=e.currentSrc,t.srcset=""),t.loading==="lazy"&&(t.loading="eager"),t}async function Gt(e,t){if(e.ownerDocument&&!e.currentSrc&&e.poster)return I(e.poster,e.ownerDocument);let n=e.cloneNode(!1);n.crossOrigin="anonymous",e.currentSrc&&e.currentSrc!==e.src&&(n.src=e.currentSrc);let r=n.ownerDocument;if(r){let o=!0;if(await O(n,{onError:()=>o=!1,onWarn:t.log.warn}),!o)return e.poster?I(e.poster,e.ownerDocument):n;n.currentTime=e.currentTime,await new Promise(i=>{n.addEventListener("seeked",i,{once:!0})});let s=r.createElement("canvas");s.width=e.offsetWidth,s.height=e.offsetHeight;try{let i=s.getContext("2d");i&&i.drawImage(n,0,0,s.width,s.height)}catch(i){return t.log.warn("Failed to clone video",i),e.poster?I(e.poster,e.ownerDocument):n}return Ie(s,t)}return n}function Kt(e,t){return Tt(e)?Ie(e,t):_t(e)?Wt(e,t):_(e)?Yt(e):H(e)?Gt(e,t):e.cloneNode(!1)}function Jt(e){let t=e.sandbox;if(!t){let{ownerDocument:n}=e;try{n&&(t=n.createElement("iframe"),t.id=`__SANDBOX__${Ne()}`,t.width="0",t.height="0",t.style.visibility="hidden",t.style.position="fixed",n.body.appendChild(t),t.srcdoc='<!DOCTYPE html><meta charset="UTF-8"><title></title><body>',e.sandbox=t)}catch(r){e.log.warn("Failed to getSandBox",r)}}return t}var Qt=["width","height","-webkit-text-fill-color"],Zt=["stroke","fill"];function _e(e,t,n){let{defaultComputedStyles:r}=n,o=e.nodeName.toLowerCase(),s=q(e)&&o!=="svg",i=s?Zt.map(h=>[h,e.getAttribute(h)]).filter(([,h])=>h!==null):[],a=[s&&"svg",o,i.map((h,b)=>`${h}=${b}`).join(","),t].filter(Boolean).join(":");if(r.has(a))return r.get(a);let l=Jt(n),d=l==null?void 0:l.contentWindow;if(!d)return new Map;let c=d==null?void 0:d.document,m,u;s?(m=c.createElementNS(X,"svg"),u=m.ownerDocument.createElementNS(m.namespaceURI,o),i.forEach(([h,b])=>{u.setAttributeNS(null,h,b)}),m.appendChild(u)):m=u=c.createElement(o),u.textContent=" ",c.body.appendChild(m);let g=d.getComputedStyle(u,t),f=new Map;for(let h=g.length,b=0;b<h;b++){let E=g.item(b);Qt.includes(E)||f.set(E,g.getPropertyValue(E))}return c.body.removeChild(m),r.set(a,f),f}function De(e,t,n){var a;let r=new Map,o=[],s=new Map;if(n)for(let l of n)i(l);else for(let l=e.length,d=0;d<l;d++){let c=e.item(d);i(c)}for(let l=o.length,d=0;d<l;d++)(a=s.get(o[d]))==null||a.forEach((c,m)=>r.set(m,c));function i(l){let d=e.getPropertyValue(l),c=e.getPropertyPriority(l),m=l.lastIndexOf("-"),u=m>-1?l.substring(0,m):void 0;if(u){let g=s.get(u);g||(g=new Map,s.set(u,g)),g.set(l,[d,c])}t.get(l)===d&&!c||(u?o.push(u):r.set(l,[d,c]))}return r}function en(e,t,n,r){var m,u,g,f;let{ownerWindow:o,includeStyleProperties:s,currentParentNodeStyle:i}=r,a=t.style,l=o.getComputedStyle(e),d=_e(e,null,r);i==null||i.forEach((h,b)=>{d.delete(b)});let c=De(l,d,s);c.delete("transition-property"),c.delete("all"),c.delete("d"),c.delete("content"),n&&(c.delete("position"),c.delete("margin-top"),c.delete("margin-right"),c.delete("margin-bottom"),c.delete("margin-left"),c.delete("margin-block-start"),c.delete("margin-block-end"),c.delete("margin-inline-start"),c.delete("margin-inline-end"),c.set("box-sizing",["border-box",""])),((m=c.get("background-clip"))==null?void 0:m[0])==="text"&&t.classList.add("______background-clip--text"),Te&&(c.has("font-kerning")||c.set("font-kerning",["normal",""]),(((u=c.get("overflow-x"))==null?void 0:u[0])==="hidden"||((g=c.get("overflow-y"))==null?void 0:g[0])==="hidden")&&((f=c.get("text-overflow"))==null?void 0:f[0])==="ellipsis"&&e.scrollWidth===e.clientWidth&&c.set("text-overflow",["clip",""]));for(let h=a.length,b=0;b<h;b++)a.removeProperty(a.item(b));return c.forEach(([h,b],E)=>{a.setProperty(E,h,b)}),c}function tn(e,t){(Rt(e)||At(e)||Mt(e))&&t.setAttribute("value",e.value)}var nn=["::before","::after"],rn=["::-webkit-scrollbar","::-webkit-scrollbar-button","::-webkit-scrollbar-thumb","::-webkit-scrollbar-track","::-webkit-scrollbar-track-piece","::-webkit-scrollbar-corner","::-webkit-resizer"];function on(e,t,n,r,o){let{ownerWindow:s,svgStyleElement:i,svgStyles:a,currentNodeStyle:l}=r;if(!i||!s)return;function d(c){var p;let m=s.getComputedStyle(e,c),u=m.getPropertyValue("content");if(!u||u==="none")return;o==null||o(u),u=u.replace(/(')|(")|(counter\(.+\))/g,"");let g=[Ne()],f=_e(e,c,r);l==null||l.forEach((v,S)=>{f.delete(S)});let h=De(m,f,r.includeStyleProperties);h.delete("content"),h.delete("-webkit-locale"),((p=h.get("background-clip"))==null?void 0:p[0])==="text"&&t.classList.add("______background-clip--text");let b=[`content: '${u}';`];if(h.forEach(([v,S],k)=>{b.push(`${k}: ${v}${S?" !important":""};`)}),b.length===1)return;try{t.className=[t.className,...g].join(" ")}catch(v){r.log.warn("Failed to copyPseudoClass",v);return}let E=b.join(`
|
|
7
|
+
`),w=a.get(E);w||(w=[],a.set(E,w)),w.push(`.${g[0]}${c}`)}nn.forEach(d),n&&rn.forEach(d)}var ge=new Set(["symbol"]);async function he(e,t,n,r,o){if(A(n)&&(Nt(n)||Lt(n))||r.filter&&!r.filter(n))return;ge.has(t.nodeName)||ge.has(n.nodeName)?r.currentParentNodeStyle=void 0:r.currentParentNodeStyle=r.currentNodeStyle;let s=await se(n,r,!1,o);r.isEnable("restoreScrollPosition")&&an(e,s),t.appendChild(s)}async function we(e,t,n,r){var s;let o=e.firstChild;A(e)&&e.shadowRoot&&(o=(s=e.shadowRoot)==null?void 0:s.firstChild,n.shadowRoots.push(e.shadowRoot));for(let i=o;i;i=i.nextSibling)if(!xt(i))if(A(i)&&It(i)&&typeof i.assignedNodes=="function"){let a=i.assignedNodes();for(let l=0;l<a.length;l++)await he(e,t,a[l],n,r)}else await he(e,t,i,n,r)}function an(e,t){if(!B(e)||!B(t))return;let{scrollTop:n,scrollLeft:r}=e;if(!n&&!r)return;let{transform:o}=t.style,s=new DOMMatrix(o),{a:i,b:a,c:l,d}=s;s.a=1,s.b=0,s.c=0,s.d=1,s.translateSelf(-r,-n),s.a=i,s.b=a,s.c=l,s.d=d,t.style.transform=s.toString()}function sn(e,t){let{backgroundColor:n,width:r,height:o,style:s}=t,i=e.style;if(n&&i.setProperty("background-color",n,"important"),r&&i.setProperty("width",`${r}px`,"important"),o&&i.setProperty("height",`${o}px`,"important"),s)for(let a in s)i[a]=s[a]}var cn=/^[\w-:]+$/;async function se(e,t,n=!1,r){var d,c,m,u;let{ownerDocument:o,ownerWindow:s,fontFamilies:i,onCloneEachNode:a}=t;if(o&&Ct(e))return r&&/\S/.test(e.data)&&r(e.data),o.createTextNode(e.data);if(o&&s&&A(e)&&(B(e)||q(e))){let g=await Kt(e,t);if(t.isEnable("removeAbnormalAttributes")){let p=g.getAttributeNames();for(let v=p.length,S=0;S<v;S++){let k=p[S];cn.test(k)||g.removeAttribute(k)}}let f=t.currentNodeStyle=en(e,g,n,t);n&&sn(g,t);let h=!1;if(t.isEnable("copyScrollbar")){let p=[(d=f.get("overflow-x"))==null?void 0:d[0],(c=f.get("overflow-y"))==null?void 0:c[0]];h=p.includes("scroll")||(p.includes("auto")||p.includes("overlay"))&&(e.scrollHeight>e.clientHeight||e.scrollWidth>e.clientWidth)}let b=(m=f.get("text-transform"))==null?void 0:m[0],E=Le((u=f.get("font-family"))==null?void 0:u[0]),w=E?p=>{b==="uppercase"?p=p.toUpperCase():b==="lowercase"?p=p.toLowerCase():b==="capitalize"&&(p=p[0].toUpperCase()+p.substring(1)),E.forEach(v=>{let S=i.get(v);S||i.set(v,S=new Set),p.split("").forEach(k=>S.add(k))})}:void 0;return on(e,g,h,t,w),tn(e,g),H(e)||await we(e,g,t,w),await(a==null?void 0:a(g)),g}let l=e.cloneNode(!1);return await we(e,l,t),await(a==null?void 0:a(l)),l}function ln(e){if(e.ownerDocument=void 0,e.ownerWindow=void 0,e.svgStyleElement=void 0,e.svgDefsElement=void 0,e.svgStyles.clear(),e.defaultComputedStyles.clear(),e.sandbox){try{e.sandbox.remove()}catch(t){e.log.warn("Failed to destroyContext",t)}e.sandbox=void 0}e.workers=[],e.fontFamilies.clear(),e.fontCssTexts.clear(),e.requests.clear(),e.tasks=[],e.shadowRoots=[]}function un(e){let{url:t,timeout:n,responseType:r,...o}=e,s=new AbortController,i=n?setTimeout(()=>s.abort(),n):void 0;return fetch(t,{signal:s.signal,...o}).then(a=>{if(!a.ok)throw new Error("Failed fetch, not 2xx response",{cause:a});switch(r){case"arrayBuffer":return a.arrayBuffer();case"dataUrl":return a.blob().then(Ot);default:return a.text()}}).finally(()=>clearTimeout(i))}function F(e,t){let{url:n,requestType:r="text",responseType:o="text",imageDom:s}=t,i=n,{timeout:a,acceptOfImage:l,requests:d,fetchFn:c,fetch:{requestInit:m,bypassingCache:u,placeholderImage:g},font:f,workers:h,fontFamilies:b}=e;r==="image"&&(z||ae)&&e.drawImageCount++;let E=d.get(n);if(!E){u&&u instanceof RegExp&&u.test(i)&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let w=r.startsWith("font")&&f&&f.minify,p=new Set;w&&r.split(";")[1].split(",").forEach(T=>{b.has(T)&&b.get(T).forEach(R=>p.add(R))});let v=w&&p.size,S={url:i,timeout:a,responseType:v?"arrayBuffer":o,headers:r==="image"?{accept:l}:void 0,...m};E={type:r,resolve:void 0,reject:void 0,response:null},E.response=(async()=>{if(c&&r==="image"){let k=await c(n);if(k)return k}return!z&&n.startsWith("http")&&h.length?new Promise((k,T)=>{h[d.size&h.length-1].postMessage({rawUrl:n,...S}),E.resolve=k,E.reject=T}):un(S)})().catch(k=>{if(d.delete(n),r==="image"&&g)return e.log.warn("Failed to fetch image base64, trying to use placeholder image",i),typeof g=="string"?g:g(s);throw k}),d.set(n,E)}return E.response}async function Pe(e,t,n,r){if(!Ue(e))return e;for(let[o,s]of dn(e,t))try{let i=await F(n,{url:s,requestType:r?"image":"text",responseType:"dataUrl"});e=e.replace(pn(o),`$1${i}$3`)}catch(i){n.log.warn("Failed to fetch css data url",o,i)}return e}function Ue(e){return/url\((['"]?)([^'"]+?)\1\)/.test(e)}var $e=/url\((['"]?)([^'"]+?)\1\)/g;function dn(e,t){let n=[];return e.replace($e,(r,o,s)=>(n.push([s,Ae(s,t)]),r)),n.filter(([r])=>!ne(r))}function pn(e){let t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}var fn=["background-image","border-image-source","-webkit-border-image","-webkit-mask-image","list-style-image"];function mn(e,t){return fn.map(n=>{let r=e.getPropertyValue(n);return!r||r==="none"?null:((z||ae)&&t.drawImageCount++,Pe(r,null,t,!0).then(o=>{!o||r===o||e.setProperty(n,o,e.getPropertyPriority(n))}))}).filter(Boolean)}function gn(e,t){if(_(e)){let n=e.currentSrc||e.src;if(!ne(n))return[F(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(e.srcset="",e.dataset.originalSrc=n,e.src=r||"")})];(z||ae)&&t.drawImageCount++}else if(q(e)&&!ne(e.href.baseVal)){let n=e.href.baseVal;return[F(t,{url:n,imageDom:e,requestType:"image",responseType:"dataUrl"}).then(r=>{r&&(e.dataset.originalSrc=n,e.href.baseVal=r||"")})]}return[]}function hn(e,t){var a;let{ownerDocument:n,svgDefsElement:r}=t,o=(a=e.getAttribute("href"))!=null?a:e.getAttribute("xlink:href");if(!o)return[];let[s,i]=o.split("#");if(i){let l=`#${i}`,d=t.shadowRoots.reduce((c,m)=>c!=null?c:m.querySelector(`svg ${l}`),n==null?void 0:n.querySelector(`svg ${l}`));if(s&&e.setAttribute("href",l),r!=null&&r.querySelector(l))return[];if(d)return r==null||r.appendChild(d.cloneNode(!0)),[];if(s)return[F(t,{url:s,responseType:"text"}).then(c=>{r==null||r.insertAdjacentHTML("beforeend",c)})]}return[]}function Be(e,t){let{tasks:n}=t;A(e)&&((_(e)||Re(e))&&n.push(...gn(e,t)),kt(e)&&n.push(...hn(e,t))),B(e)&&n.push(...mn(e.style,t)),e.childNodes.forEach(r=>{Be(r,t)})}async function wn(e,t){let{ownerDocument:n,svgStyleElement:r,fontFamilies:o,fontCssTexts:s,tasks:i,font:a}=t;if(!(!n||!r||!o.size))if(a&&a.cssText){let l=ye(a.cssText,t);r.appendChild(n.createTextNode(`${l}
|
|
8
|
+
`))}else{let l=Array.from(n.styleSheets).filter(g=>{try{return"cssRules"in g&&!!g.cssRules.length}catch(f){return t.log.warn(`Error while reading CSS rules from ${g.href}`,f),!1}}),d=n.implementation.createHTMLDocument(""),c=d.createElement("style");d.head.appendChild(c);let m=c.sheet;await Promise.all(l.flatMap(g=>Array.from(g.cssRules).map(async f=>{if(St(f)){let h=f.href,b="";try{b=await F(t,{url:h,requestType:"text",responseType:"text"})}catch(w){t.log.warn(`Error fetch remote css import from ${h}`,w)}let E=b.replace($e,(w,p,v)=>w.replace(v,Ae(v,h)));for(let w of yn(E))try{m.insertRule(w,m.cssRules.length)}catch(p){t.log.warn("Error inserting rule from remote css import",{rule:w,error:p})}}}))),m.cssRules.length&&l.push(m);let u=[];l.forEach(g=>{re(g.cssRules,u)}),u.filter(g=>{var f;return vt(g)&&Ue(g.style.getPropertyValue("src"))&&((f=Le(g.style.getPropertyValue("font-family")))==null?void 0:f.some(h=>o.has(h)))}).forEach(g=>{let f=g,h=s.get(f.cssText);h?r.appendChild(n.createTextNode(`${h}
|
|
9
|
+
`)):i.push(Pe(f.cssText,f.parentStyleSheet?f.parentStyleSheet.href:null,t).then(b=>{b=ye(b,t),s.set(f.cssText,b),r.appendChild(n.createTextNode(`${b}
|
|
10
|
+
`))}))})}}var bn=/(\/\*[\s\S]*?\*\/)/g,be=/((@.*?keyframes [\s\S]*?){([\s\S]*?}\s*?)})/gi;function yn(e){if(e==null)return[];let t=[],n=e.replace(bn,"");for(;;){let s=be.exec(n);if(!s)break;t.push(s[0])}n=n.replace(be,"");let r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let s=r.exec(n);if(s)o.lastIndex=r.lastIndex;else if(s=o.exec(n),s)r.lastIndex=o.lastIndex;else break;t.push(s[0])}return t}var vn=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,Sn=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function ye(e,t){let{font:n}=t,r=n?n==null?void 0:n.preferredFormat:void 0;return r?e.replace(Sn,o=>{for(;;){let[s,,i]=vn.exec(o)||[];if(!i)return"";if(i===r)return`src: ${s};`}}):e}function re(e,t=[]){for(let n of Array.from(e))Et(n)?t.push(...re(n.cssRules)):"cssRules"in n?re(n.cssRules,t):t.push(n);return t}var En=/\bx?link:?href\s*=\s*["'](?!data:)[^"']+["']/i;function kn(e){return En.test(e.innerHTML)}async function xn(e,t){let n=await V(e,t);if(A(n.node)&&q(n.node)&&!kn(n.node))return n.node;let{ownerDocument:r,log:o,tasks:s,svgStyleElement:i,svgDefsElement:a,svgStyles:l,font:d,progress:c,autoDestruct:m,onCloneNode:u,onEmbedNode:g,onCreateForeignObjectSvg:f}=n;o.time("clone node");let h=await se(n.node,n,!0);if(i&&r){let v="";l.forEach((S,k)=>{v+=`${S.join(`,
|
|
11
11
|
`)} {
|
|
12
12
|
${k}
|
|
13
13
|
}
|
|
14
|
-
`}),i.appendChild(r.createTextNode(v))}o.timeEnd("clone node"),await(u==null?void 0:u(h)),d!==!1&&A(h)&&(o.time("embed web font"),await wn(h,n),o.timeEnd("embed web font")),o.time("embed node")
|
|
14
|
+
`}),i.appendChild(r.createTextNode(v))}o.timeEnd("clone node"),await(u==null?void 0:u(h)),d!==!1&&A(h)&&(o.time("embed web font"),await wn(h,n),o.timeEnd("embed web font")),o.time("embed node"),Be(h,n);let b=s.length,E=0,w=async()=>{for(;;){let v=s.pop();if(!v)break;try{await v}catch(S){n.log.warn("Failed to run task",S)}c==null||c(++E,b)}};c==null||c(E,b),await Promise.all([...Array.from({length:4})].map(w)),o.timeEnd("embed node"),await(g==null?void 0:g(h));let p=Cn(h,n);return a&&p.insertBefore(a,p.children[0]),i&&p.insertBefore(i,p.children[0]),m&&ln(n),await(f==null?void 0:f(p)),p}function Cn(e,t){let{width:n,height:r}=t,o=Ut(n,r,e.ownerDocument),s=o.ownerDocument.createElementNS(o.namespaceURI,"foreignObject");return s.setAttributeNS(null,"x","0%"),s.setAttributeNS(null,"y","0%"),s.setAttributeNS(null,"width","100%"),s.setAttributeNS(null,"height","100%"),s.append(e),o.appendChild(s),o}async function Tn(e,t){var i;let n=await V(e,t),r=await xn(n),o=$t(r,n.isEnable("removeControlCharacter"));n.autoDestruct||(n.svgStyleElement=Me(n.ownerDocument),n.svgDefsElement=(i=n.ownerDocument)==null?void 0:i.createElementNS(X,"defs"),n.svgStyles.clear());let s=I(o,r.ownerDocument);return await Xt(s,n)}async function Rn(e,t){let n=await V(e,t),{log:r,quality:o,type:s,dpi:i}=n,a=await Tn(n);r.time("canvas to data url");let l=a.toDataURL(s,o);if(["image/png","image/jpeg"].includes(s)&&i&&wt&&bt){let[d,c]=l.split(","),m=0,u=!1;if(s==="image/png"){let p=gt(c);p>=0?(m=Math.ceil((p+28)/3)*4,u=!0):m=33/3*4}else s==="image/jpeg"&&(m=18/3*4);let g=c.substring(0,m),f=c.substring(m),h=window.atob(g),b=new Uint8Array(h.length);for(let p=0;p<b.length;p++)b[p]=h.charCodeAt(p);let E=s==="image/png"?dt(b,i,u):it(b,i),w=window.btoa(String.fromCharCode(...E));l=[d,",",w,f].join("")}return r.timeEnd("canvas to data url"),l}async function Oe(e,t){return Rn(await V(e,{...t,type:"image/png"}))}async function D(){try{let e=document.documentElement.getBoundingClientRect();return{dataUrl:await Oe(document.documentElement,{backgroundColor:"#ffffff",quality:.92,filter:n=>!(n instanceof HTMLElement&&n.hasAttribute("data-repros-toolbar"))}),width:e.width,height:e.height}}catch(e){return console.warn("[Repros SDK] screenshot capture failed:",e),null}}var Fe=`
|
|
15
15
|
:host { all: initial; }
|
|
16
16
|
|
|
17
17
|
.rp-root {
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
|
|
152
152
|
.rp-error { font-size: 11.5px; color: var(--rp-error); margin: 0; }
|
|
153
153
|
.rp-fine-print { font-size: 10.5px; color: var(--rp-ink-3); margin: 0; }
|
|
154
|
-
`;async function
|
|
154
|
+
`;async function qe(e,t){var n;try{let r=await fetch(`${t.replace(/\/+$/,"")}/api/customer-sessions/submit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e})}),o=await r.json().catch(()=>null);return o!=null&&o.ok?"ok":(o==null?void 0:o.reason)==="already_submitted"?"already_submitted":(console.warn("[Repros SDK] couldn't send report:",(n=o==null?void 0:o.reason)!=null?n:r.status),"error")}catch(r){return console.warn("[Repros SDK] couldn't reach Repros to send report:",r),"error"}}async function ze(e,t,n,r){var o;try{let s=await fetch(`${t.replace(/\/+$/,"")}/api/customer-sessions/annotation`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e,note:n,screenshot:r})}),i=await s.json().catch(()=>null);return i!=null&&i.ok?"ok":(console.warn("[Repros SDK] couldn't save that note:",(o=i==null?void 0:i.reason)!=null?o:s.status),"error")}catch(s){return console.warn("[Repros SDK] couldn't reach Repros to save that note:",s),"error"}}function ie(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,"0")}`}function ce(e,t){let n=document.createElement("div");n.setAttribute("data-repros-toolbar","");let r=n.attachShadow({mode:"open"}),o=document.createElement("style");o.textContent=Fe,r.appendChild(o);let s=document.createElement("div");s.className="rp-root",r.appendChild(s),document.body.appendChild(n);let i=Date.now(),a=t.mode==="customer"?{kind:"consent"}:{kind:"active",minimized:!1,submitting:!1,error:null,annotate:{kind:"idle"}},l,d={errors:0,warnings:0,failedRequests:0},c=0,m=null;function u(w){a=w,E()}function g(){l||(l=setInterval(()=>{if(a.kind!=="active")return;let w=a.minimized?".rp-pill .rp-mono":".rp-elapsed",p=s.querySelector(w);p&&(p.textContent=ie(Date.now()-i))},1e3))}async function f(){var p;if(a.kind!=="active")return;u({...a,submitting:!0,error:null});let w=await qe(e.token,e.apiBase);if(w==="ok"||w==="already_submitted"){l&&clearInterval(l),(p=t.onSubmitted)==null||p.call(t),u({kind:"sent"});return}u({kind:"active",minimized:!1,submitting:!1,error:"Couldn't send that \u2014 check your connection and try again.",annotate:{kind:"idle"}})}function h(w){if(a.kind!=="active")return;u({...a,annotate:{kind:"picking",mode:w}}),n.style.display="none";let p=({rect:S})=>{m=null,n.style.display="",a.kind==="active"&&u({...a,annotate:{kind:"composing",rect:S,note:"",saving:!1,error:null}})},v=()=>{m=null,n.style.display="",a.kind==="active"&&u({...a,annotate:{kind:"idle"}})};m=w==="element"?Q(p,v):Z(p,v)}async function b(){if(a.kind!=="active"||a.annotate.kind!=="composing")return;let{rect:w,note:p}=a.annotate,v=p.trim();if(!v)return;u({...a,annotate:{...a.annotate,saving:!0,error:null}});let S=await D();if(!S){u({...a,annotate:{kind:"composing",rect:w,note:p,saving:!1,error:"Couldn't capture a screenshot \u2014 try again."}});return}let k=await ee(S.dataUrl,w,{width:S.width,height:S.height});if(await ze(e.token,e.apiBase,v,k)!=="ok"){u({...a,annotate:{kind:"composing",rect:w,note:p,saving:!1,error:"Couldn't save that note \u2014 try again."}});return}c++,a.kind==="active"&&u({...a,annotate:{kind:"idle"}})}function E(){var k,T,R,U;if(s.innerHTML="",a.kind==="consent"){let y=document.createElement("div");y.className="rp-consent",y.setAttribute("role","dialog"),y.setAttribute("aria-label","Repros consent"),y.innerHTML=`
|
|
155
155
|
<div class="rp-title">Help report this problem?</div>
|
|
156
156
|
<p class="rp-body">Repros will note what you do on this page \u2014 clicks, errors, a note you add \u2014 so the team can see exactly what went wrong. Nothing is shared until you send it.</p>
|
|
157
157
|
<div class="rp-actions">
|
|
@@ -161,19 +161,19 @@
|
|
|
161
161
|
`,(k=y.querySelector('[data-action="decline"]'))==null||k.addEventListener("click",()=>{var x;n.remove(),(x=t.onDeclined)==null||x.call(t)}),(T=y.querySelector('[data-action="accept"]'))==null||T.addEventListener("click",()=>{var x;g(),(x=t.onAccepted)==null||x.call(t),u({kind:"active",minimized:!1,submitting:!1,error:null,annotate:{kind:"idle"}})}),s.appendChild(y);return}if(a.kind==="sent"){let y=document.createElement("div");y.className="rp-consent",y.innerHTML=`
|
|
162
162
|
<div class="rp-title">Thanks \u2014 report sent</div>
|
|
163
163
|
<p class="rp-body">The team can now see what happened here.</p>
|
|
164
|
-
`,s.appendChild(y),setTimeout(()=>n.remove(),4e3);return}g();let w=a;if(w.minimized){let y=document.createElement("button");y.className="rp-pill",y.title="Show the Repros toolbar";let x=t.mode==="qa"&&d.errors>0?`<span class="rp-pill-count rp-tone-error">${d.errors}</span>`:"";y.innerHTML=`<span class="rp-dot"></span><span class="rp-mono">${
|
|
164
|
+
`,s.appendChild(y),setTimeout(()=>n.remove(),4e3);return}g();let w=a;if(w.minimized){let y=document.createElement("button");y.className="rp-pill",y.title="Show the Repros toolbar";let x=t.mode==="qa"&&d.errors>0?`<span class="rp-pill-count rp-tone-error">${d.errors}</span>`:"";y.innerHTML=`<span class="rp-dot"></span><span class="rp-mono">${ie(Date.now()-i)}</span>${x}`,y.addEventListener("click",()=>u({...w,minimized:!1})),s.appendChild(y);return}let p=document.createElement("div");p.className="rp-panel",p.setAttribute("role","region"),p.setAttribute("aria-label",t.mode==="customer"?"Repros report":"Repros test session");let v=document.createElement("div");v.className="rp-header",v.innerHTML=`
|
|
165
165
|
<div class="rp-header-main">
|
|
166
166
|
<span class="rp-status"><span class="rp-dot"></span>${t.mode==="customer"?"RECORDING":"REC"}</span>
|
|
167
|
-
<span class="rp-mono rp-elapsed">${
|
|
167
|
+
<span class="rp-mono rp-elapsed">${ie(Date.now()-i)}</span>
|
|
168
168
|
</div>
|
|
169
|
-
`;let S=document.createElement("button");if(S.className="rp-icon-btn",S.title="Minimize",S.setAttribute("aria-label","Minimize toolbar"),S.textContent="\u2013",S.addEventListener("click",()=>u({...w,minimized:!0})),v.appendChild(S),
|
|
169
|
+
`;let S=document.createElement("button");if(S.className="rp-icon-btn",S.title="Minimize",S.setAttribute("aria-label","Minimize toolbar"),S.textContent="\u2013",S.addEventListener("click",()=>u({...w,minimized:!0})),v.appendChild(S),p.appendChild(v),t.mode==="qa"){let y=document.createElement("div");y.className="rp-counts",y.innerHTML=`
|
|
170
170
|
<span class="rp-count rp-count-error"><span class="rp-count-value">${d.errors}</span>errors</span>
|
|
171
171
|
<span class="rp-count rp-count-error"><span class="rp-count-value">${d.failedRequests}</span>failed req</span>
|
|
172
172
|
<span class="rp-count"><span class="rp-count-value">${d.warnings}</span>warnings</span>
|
|
173
173
|
<span class="rp-count rp-count-note"><span class="rp-count-value">${c}</span>notes</span>
|
|
174
|
-
`,
|
|
174
|
+
`,p.appendChild(y)}if(w.annotate.kind==="choosing"){let y=document.createElement("div");y.className="rp-actions",y.innerHTML=`
|
|
175
175
|
<button class="rp-btn rp-btn-secondary" data-action="element">Select element</button>
|
|
176
176
|
<button class="rp-btn rp-btn-secondary" data-action="draw">Draw box</button>
|
|
177
|
-
`,(R=y.querySelector('[data-action="element"]'))==null||R.addEventListener("click",()=>h("element")),(U=y.querySelector('[data-action="draw"]'))==null||U.addEventListener("click",()=>h("draw")),
|
|
178
|
-
${(r=e.stack)!=null?r:""}`;if(typeof e=="undefined")return"undefined";if(typeof e=="function")return`[Function ${e.name||"anonymous"}]`;if(typeof e=="symbol"||typeof e=="bigint")return String(e);let t=new WeakSet;try{return(o=JSON.stringify(e,(s,i)=>{if(typeof i=="object"&&i!==null){if(t.has(i))return"[Circular]";if(t.add(i),i instanceof Map)return Object.fromEntries(i);if(i instanceof Set)return[...i]}return typeof i=="bigint"?`${i}n`:i}))!=null?o:String(e)}catch(s){try{return String(e)}catch(i){return"[Unserializable]"}}}function Y(e){return e.length>2e3?`${e.slice(0,2e3)}\u2026 [truncated]`:e}function
|
|
177
|
+
`,(R=y.querySelector('[data-action="element"]'))==null||R.addEventListener("click",()=>h("element")),(U=y.querySelector('[data-action="draw"]'))==null||U.addEventListener("click",()=>h("draw")),p.appendChild(y);let x=document.createElement("button");x.className="rp-btn rp-btn-secondary",x.textContent="Cancel",x.addEventListener("click",()=>u({...w,annotate:{kind:"idle"}})),p.appendChild(x)}else if(w.annotate.kind==="picking"){let y=document.createElement("p");y.className="rp-fine-print",y.textContent=w.annotate.mode==="element"?"Click something on the page\u2026 (Esc to cancel)":"Drag a box\u2026 (Esc to cancel)",p.appendChild(y)}else if(w.annotate.kind==="composing"){let y=w.annotate,x=document.createElement("div");x.innerHTML=`<textarea class="rp-fine-print" style="width:100%;min-height:56px;background:var(--rp-surface-2);border:1px solid var(--rp-border);border-radius:8px;padding:6px 8px;color:var(--rp-ink);font:inherit;resize:vertical;" placeholder="What's wrong here?"></textarea>`;let C=x.querySelector("textarea");C.value=y.note,p.appendChild(x);let L=document.createElement("div");L.className="rp-actions";let M=document.createElement("button");M.className="rp-btn rp-btn-primary",M.disabled=y.saving||!y.note.trim(),M.textContent=y.saving?"Saving\u2026":"Save note",M.addEventListener("click",()=>{b()}),C.addEventListener("input",()=>{a.kind==="active"&&a.annotate.kind==="composing"&&(a.annotate.note=C.value),M.disabled=y.saving||!C.value.trim()});let $=document.createElement("button");if($.className="rp-btn rp-btn-secondary",$.disabled=y.saving,$.textContent="Cancel",$.addEventListener("click",()=>u({...w,annotate:{kind:"idle"}})),L.append(M,$),p.appendChild(L),y.error){let K=document.createElement("p");K.className="rp-error",K.textContent=y.error,p.appendChild(K)}}else{let y=document.createElement("div");y.className="rp-actions";let x=document.createElement("button");if(x.className="rp-btn rp-btn-secondary",x.textContent="Note",x.addEventListener("click",()=>u({...w,annotate:{kind:"choosing"}})),y.appendChild(x),t.mode==="customer"){let C=document.createElement("button");C.className="rp-btn rp-btn-primary",C.disabled=w.submitting,C.textContent=w.submitting?"Sending\u2026":"Send report",C.addEventListener("click",()=>{f()}),y.appendChild(C)}else{let C=document.createElement("button");C.className="rp-btn rp-btn-stop",C.disabled=!t.onStop,C.title=t.onStop?"Stop recording":"Not wired up yet",C.textContent="Stop",C.addEventListener("click",()=>{var L;return(L=t.onStop)==null?void 0:L.call(t)}),y.appendChild(C)}if(p.appendChild(y),w.error){let C=document.createElement("p");C.className="rp-error",C.textContent=w.error,p.appendChild(C)}}s.appendChild(p)}return E(),{setCounts(w){d=w,a.kind==="active"&&E()},destroy(){l&&clearInterval(l),m==null||m(),n.remove()}}}function He(e,t){let n=[],r=[],o={errors:0,warnings:0,failedRequests:0};function s(u){return u.split(e.token).join("[repros-token]")}function i(u){n.length>=50||(n.push({...u,message:s(u.message),stackTrace:u.stackTrace?s(u.stackTrace):u.stackTrace,sourceUrl:u.sourceUrl?s(u.sourceUrl):u.sourceUrl}),u.type==="console_warn"?o.warnings++:o.errors++,t({...o}))}function a(u){r.length>=50||(r.push({...u,url:s(u.url)}),o.failedRequests++,t({...o}))}async function l(){if(n.length===0&&r.length===0)return;let u=n,g=r;n=[],r=[];let f=`${e.apiBase.replace(/\/+$/,"")}/api/customer-sessions/capture`;try{await fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e.token,logEntries:u,networkRequests:g}),keepalive:!0})}catch(h){console.warn("[Repros SDK] capture flush failed:",h)}}let d=setInterval(()=>{l()},5e3),c=()=>{document.visibilityState==="hidden"&&l()};document.addEventListener("visibilitychange",c),window.addEventListener("pagehide",()=>{l()});function m(){clearInterval(d),document.removeEventListener("visibilitychange",c),l()}return{addLog:i,addNetwork:a,stop:m}}function W(e){var n,r,o;if(typeof e=="string")return e;if(e instanceof Error)return(n=e.stack)!=null&&n.startsWith(e.name)?e.stack:`${e.name}: ${e.message}
|
|
178
|
+
${(r=e.stack)!=null?r:""}`;if(typeof e=="undefined")return"undefined";if(typeof e=="function")return`[Function ${e.name||"anonymous"}]`;if(typeof e=="symbol"||typeof e=="bigint")return String(e);let t=new WeakSet;try{return(o=JSON.stringify(e,(s,i)=>{if(typeof i=="object"&&i!==null){if(t.has(i))return"[Circular]";if(t.add(i),i instanceof Map)return Object.fromEntries(i);if(i instanceof Set)return[...i]}return typeof i=="bigint"?`${i}n`:i}))!=null?o:String(e)}catch(s){try{return String(e)}catch(i){return"[Unserializable]"}}}function Y(e){return e.length>2e3?`${e.slice(0,2e3)}\u2026 [truncated]`:e}function je(e){return Y(e.map(W).join(" "))}var Xe={warn:"console_warn",error:"console_error"};function Ve(e){let t={warn:console.warn.bind(console),error:console.error.bind(console)};return Object.keys(Xe).forEach(n=>{console[n]=(...r)=>{var o;t[n](...r);try{let s=r.find(i=>i instanceof Error);e.addLog({type:Xe[n],message:je(r),stackTrace:(o=s==null?void 0:s.stack)!=null?o:n==="error"?new Error().stack:void 0,sourceUrl:window.location.href,occurredAt:new Date().toISOString()})}catch(s){}}}),()=>{console.warn=t.warn,console.error=t.error}}function We(e){let t=r=>{let o=r.filename?`${r.filename}:${r.lineno}:${r.colno}`:void 0;e.addLog({type:"window_error",message:Y(r.message||W(r.error)),stackTrace:r.error instanceof Error?r.error.stack:o?` at ${o}`:void 0,sourceUrl:window.location.href,occurredAt:new Date().toISOString()})},n=r=>{let o=r.reason;e.addLog({type:"unhandled_rejection",message:Y(o instanceof Error?`${o.name}: ${o.message}`:W(o)),stackTrace:o instanceof Error?o.stack:void 0,sourceUrl:window.location.href,occurredAt:new Date().toISOString()})};return window.addEventListener("error",t),window.addEventListener("unhandledrejection",n),()=>{window.removeEventListener("error",t),window.removeEventListener("unhandledrejection",n)}}function Ye(e){let t=Nn(e),n=Ln(e);return()=>{t(),n()}}function An(e,t){var n,r,o,s;return typeof e=="string"||e instanceof URL?{method:(r=(n=t==null?void 0:t.method)==null?void 0:n.toUpperCase())!=null?r:"GET",url:String(e)}:{method:((s=(o=t==null?void 0:t.method)!=null?o:e.method)!=null?s:"GET").toUpperCase(),url:e.url}}function Nn(e){if(typeof window.fetch!="function")return()=>{};let t=window.fetch.bind(window);return window.fetch=async(n,r)=>{let{method:o,url:s}=An(n,r),i=performance.now();try{let a=await t(n,r);return a.ok||e.addNetwork({method:o,url:s,statusCode:a.status,statusText:a.statusText,durationMs:Math.round(performance.now()-i),occurredAt:new Date().toISOString()}),a}catch(a){throw e.addNetwork({method:o,url:s,errorText:a instanceof Error?a.message:String(a),durationMs:Math.round(performance.now()-i),occurredAt:new Date().toISOString()}),a}},()=>{window.fetch=t}}var G=new WeakMap;function Ln(e){let t=XMLHttpRequest.prototype,n=t.open,r=t.send;return t.open=function(o,s,...i){return G.set(this,{method:o.toUpperCase(),url:String(s),startedAt:0}),n.call(this,o,s,...i)},t.send=function(...o){let s=G.get(this);s&&(s.startedAt=performance.now());let i=()=>{let a=G.get(this);a&&((this.status===0||this.status>=400)&&e.addNetwork({method:a.method,url:a.url,statusCode:this.status||void 0,statusText:this.statusText||void 0,errorText:this.status===0?"Network error":void 0,durationMs:Math.round(performance.now()-a.startedAt),occurredAt:new Date().toISOString()}),this.removeEventListener("loadend",i),G.delete(this))};return this.addEventListener("loadend",i),r.apply(this,o)},()=>{t.open=n,t.send=r}}function Ge(e,t){let n=He(e,t),r=Ve(n),o=We(n),s=Ye(n);return()=>{r(),o(),s(),n.stop()}}var P=null,Ke=!1;async function le(e={}){if(Ke)return P;Ke=!0;let t=pe();if(!t||(P=await fe(t,e.apiBase),!P))return null;let n=P,r=null,o=ce(n,{mode:"customer",onAccepted:()=>{r=Ge(n,s=>o.setCounts(s))},onSubmitted:()=>r==null?void 0:r()});return P}function Je(){return P}var ue=document.currentScript,Qe=ue==null?void 0:ue.dataset.apiBase;le(Qe?{apiBase:Qe}:void 0);return ot(Mn);})();
|
|
179
179
|
//# sourceMappingURL=repros-sdk.global.js.map
|