@spectosh/browser 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-VtKEKQLX.cjs");let t=require("react");var n={identify:e.r,track:e.d,captureError:e.t,sessionUrl:e.s,stop:e.u,grantConsent:e.n,revokeConsent:e.o,optOut:e.a,optIn:e.i},r=(0,t.createContext)(n);function i(t){if(typeof window>`u`)return null;try{return e.l(t)}catch(e){try{console.error(`[specto] ${e?.message||e}`)}catch{}return null}}function a({apiKey:a,user:o,children:s,...c}){(0,t.useState)(()=>i({key:a,...c}));let l=o?.id??null,u=o?JSON.stringify(Object.fromEntries(Object.entries(o).filter(([e])=>e!==`id`))):``;return(0,t.useEffect)(()=>{l!=null&&l!==``&&e.r(l,u?JSON.parse(u):void 0)},[l,u]),(0,t.createElement)(r.Provider,{value:n},s)}var o=()=>(0,t.useContext)(r),s=class extends t.Component{constructor(e){super(e),this.state={error:null},this.reset=()=>this.setState({error:null})}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(t,n){e.t(t,{componentStack:n?.componentStack,source:`react-boundary`}),this.props.onError?.(t,n)}render(){let{error:e}=this.state;if(!e)return this.props.children;let{fallback:t}=this.props;return typeof t==`function`?t({error:e,reset:this.reset}):t??null}};function c(t){return(n,r)=>{if(e.t(n,{componentStack:r?.componentStack,source:`react-root`}),t)t(n,r);else try{console.error(n)}catch{}}}exports.SpectoErrorBoundary=s,exports.SpectoProvider=a,exports.captureError=e.t,exports.spectoErrorHandler=c,exports.useSpecto=o;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./src-By9NWWVq.cjs");let t=require("react");var n={identify:e.r,track:e.d,captureError:e.t,sessionUrl:e.s,stop:e.u,grantConsent:e.n,revokeConsent:e.o,optOut:e.a,optIn:e.i},r=(0,t.createContext)(n);function i(t){if(typeof window>`u`)return null;try{return e.l(t)}catch(e){try{console.error(`[specto] ${e?.message||e}`)}catch{}return null}}function a({apiKey:a,user:o,children:s,...c}){(0,t.useState)(()=>i({key:a,...c}));let l=o?.id??null,u=o?JSON.stringify(Object.fromEntries(Object.entries(o).filter(([e])=>e!==`id`))):``;return(0,t.useEffect)(()=>{l!=null&&l!==``&&e.r(l,u?JSON.parse(u):void 0)},[l,u]),(0,t.createElement)(r.Provider,{value:n},s)}var o=()=>(0,t.useContext)(r),s=class extends t.Component{constructor(e){super(e),this.state={error:null},this.reset=()=>this.setState({error:null})}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(t,n){e.t(t,{componentStack:n?.componentStack,source:`react-boundary`}),this.props.onError?.(t,n)}render(){let{error:e}=this.state;if(!e)return this.props.children;let{fallback:t}=this.props;return typeof t==`function`?t({error:e,reset:this.reset}):t??null}};function c(t){return(n,r)=>{if(e.t(n,{componentStack:r?.componentStack,source:`react-root`}),t)t(n,r);else try{console.error(n)}catch{}}}exports.SpectoErrorBoundary=s,exports.SpectoProvider=a,exports.captureError=e.t,exports.spectoErrorHandler=c,exports.useSpecto=o;
package/dist/react.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, d as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./src-KEdhVklE.js";
1
+ import { a as e, d as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./src-CWM5vchW.js";
2
2
  import { Component as u, createContext as d, createElement as f, useContext as p, useEffect as m, useState as h } from "react";
3
3
  //#region src/react.js
4
4
  var g = {
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./src-VtKEKQLX.cjs");exports.DEFAULT_HOST=e.g,exports.SDK_VERSION=e.f,exports.captureError=e.t,exports.default=e.c,exports.grantConsent=e.n,exports.hasConsent=e.p,exports.identify=e.r,exports.isOptedOut=e.m,exports.optIn=e.i,exports.optOut=e.a,exports.parseKey=e._,exports.revokeConsent=e.o,exports.scrubText=e.h,exports.sessionUrl=e.s,exports.startRecording=e.l,exports.stopRecording=e.u,exports.track=e.d;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./src-By9NWWVq.cjs");exports.DEFAULT_HOST=e.g,exports.SDK_VERSION=e.f,exports.captureError=e.t,exports.default=e.c,exports.grantConsent=e.n,exports.hasConsent=e.p,exports.identify=e.r,exports.isOptedOut=e.m,exports.optIn=e.i,exports.optOut=e.a,exports.parseKey=e._,exports.revokeConsent=e.o,exports.scrubText=e.h,exports.sessionUrl=e.s,exports.startRecording=e.l,exports.stopRecording=e.u,exports.track=e.d;
@@ -1,2 +1,2 @@
1
- import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g } from "./src-KEdhVklE.js";
1
+ import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g } from "./src-CWM5vchW.js";
2
2
  export { a as DEFAULT_HOST, i as SDK_VERSION, h as captureError, n as default, u as grantConsent, f as hasConsent, p as identify, l as isOptedOut, s as optIn, t as optOut, e as parseKey, d as revokeConsent, o as scrubText, m as sessionUrl, c as startRecording, g as stopRecording, r as track };
@@ -131,7 +131,7 @@ or you can use record.mirror to access the mirror instance during recording.`,Qi
131
131
  };
132
132
  })();
133
133
  //# sourceMappingURL=image-bitmap-data-url-worker-IJpC7g_b.js.map
134
- `,bo=typeof self<`u`&&self.Blob&&new Blob([yo],{type:`text/javascript;charset=utf-8`});function xo(e){let t;try{if(t=bo&&(self.URL||self.webkitURL).createObjectURL(bo),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(yo),{name:e?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}var So=class{constructor(e){n(this,`pendingCanvasMutations`,new Map),n(this,`rafStamps`,{latestId:0,invokeId:null}),n(this,`mirror`),n(this,`mutationCb`),n(this,`resetObservers`),n(this,`frozen`,!1),n(this,`locked`,!1),n(this,`processMutation`,(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});let{sampling:t=`all`,win:r,blockClass:i,blockSelector:a,recordCanvas:o,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&t===`all`&&this.initCanvasMutationObserver(r,i,a),o&&typeof t==`number`&&this.initCanvasFPSObserver(t,r,i,a,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,i){let a=go(t,n,r,!0),o=new Map,s=new xo;s.onmessage=e=>{let{id:t}=e.data;if(o.set(t,!1),!(`base64`in e.data))return;let{base64:n,type:r,width:i,height:a}=e.data;this.mutationCb({id:t,type:ya[`2D`],commands:[{property:`clearRect`,args:[0,0,i,a]},{property:`drawImage`,args:[{rr_type:`ImageBitmap`,args:[{rr_type:`Blob`,data:[{rr_type:`ArrayBuffer`,base64:n}],type:r}]},0,0]}]})};let c=1e3/e,l=0,u,d=()=>{let e=[];return t.document.querySelectorAll(`canvas`).forEach(t=>{G(t,n,r,!0)||e.push(t)}),e},f=e=>{if(l&&e-l<c){u=requestAnimationFrame(f);return}l=e,d().forEach(async e=>{let t=this.mirror.getId(e);if(o.get(t)||e.width===0||e.height===0)return;if(o.set(t,!0),[`webgl`,`webgl2`].includes(e.__context)){let t=e.getContext(e.__context);t?.getContextAttributes()?.preserveDrawingBuffer===!1&&t.clear(t.COLOR_BUFFER_BIT)}let n=await createImageBitmap(e);s.postMessage({id:t,bitmap:n,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[n])}),u=requestAnimationFrame(f)};u=requestAnimationFrame(f),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();let r=go(e,t,n,!1),i=mo(this.processMutation.bind(this),e,t,n),a=vo(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),i(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{let n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;let n=this.pendingCanvasMutations.get(e);if(!n||t===-1)return;let r=n.map(e=>{let{type:t,...n}=e;return n}),{type:i}=n[0];this.mutationCb({id:t,type:i,commands:r}),this.pendingCanvasMutations.delete(e)}},Co=class{constructor(e){n(this,`trackedLinkElements`,new WeakSet),n(this,`mutationCb`),n(this,`adoptedStyleSheetCb`),n(this,`styleMirror`,new pa),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){`_cssText`in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(e.length===0)return;let n={id:t,styleIds:[]},r=[];for(let t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),r.push({styleId:e,rules:Array.from(t.rules||CSSRule,(e,n)=>({rule:F(e,t.href),index:n}))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}},wo=class{constructor(){n(this,`nodeMap`,new WeakMap),n(this,`active`,!1)}inOtherBuffer(e,t){let n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}destroy(){}},X,To,Eo,Do=!1;try{if(Array.from([1],e=>e*2)[0]!==2){let e=document.createElement(`iframe`);document.body.appendChild(e),Array.from=e.contentWindow?.Array.from||Array.from,document.body.removeChild(e)}}catch(e){console.debug(`Unable to override Array.from`,e)}var Z=fe();function Oo(e={}){let{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:i=`rr-block`,blockSelector:a=null,ignoreClass:o=`rr-ignore`,ignoreSelector:s=null,maskTextClass:c=`rr-mask`,maskTextSelector:l=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:f,slimDOMOptions:p,maskInputFn:m,maskTextFn:h,hooks:g,packFn:_,sampling:v={},dataURLOptions:y={},mousemoveWait:b,recordDOM:x=!0,recordCanvas:S=!1,recordCrossOriginIframes:C=!1,recordAfter:w=e.recordAfter===`DOMContentLoaded`?e.recordAfter:`load`,userTriggeredOnInput:T=!1,collectFonts:E=!1,inlineImages:D=!1,plugins:O,keepIframeSrcFn:ee=()=>!1,ignoreCSSAttributes:k=new Set([]),errorHandler:te}=e;ka(te);let A=!C||window.parent===window,j=!1;if(!A)try{window.parent.document&&(j=!1)}catch{j=!0}if(A&&!t)throw Error(`emit function is required`);if(!A&&!j)return()=>{};b!==void 0&&v.mousemove===void 0&&(v.mousemove=b),Z.reset();let ne=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:f===void 0?{password:!0}:f,re=$e(p);la();let M,ie=0,ae=e=>{for(let t of O||[])t.eventProcessor&&(e=t.eventProcessor(e));return _&&!j&&(e=_(e)),e};X=(e,i)=>{let a=e;if(a.timestamp=Yi(),ja[0]?.isFrozen()&&a.type!==K.FullSnapshot&&(a.type!==K.IncrementalSnapshot||a.data.source!==q.Mutation)&&ja.forEach(e=>e.unfreeze()),A)t?.(ae(a),i);else if(j){let e={type:`rrweb`,event:ae(a),origin:window.location.origin,isCheckout:i};window.parent.postMessage(e,`*`)}if(a.type===K.FullSnapshot)M=a,ie=0;else if(a.type===K.IncrementalSnapshot){if(a.data.source===q.Mutation&&a.data.isAttachIframe)return;ie++;let e=r&&ie>=r,t=n&&a.timestamp-M.timestamp>n;(e||t)&&To(!0)}};let N=e=>{X({type:K.IncrementalSnapshot,data:{source:q.Mutation,...e}})},oe=e=>X({type:K.IncrementalSnapshot,data:{source:q.Scroll,...e}}),se=e=>X({type:K.IncrementalSnapshot,data:{source:q.CanvasMutation,...e}}),P=new Co({mutationCb:N,adoptedStyleSheetCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.AdoptedStyleSheet,...e}})}),F=new to({mirror:Z,mutationCb:N,stylesheetManager:P,recordCrossOriginIframes:C,wrappedEmit:X});for(let e of O||[])e.getMirror&&e.getMirror({nodeMirror:Z,crossOriginIframeMirror:F.crossOriginIframeMirror,crossOriginIframeStyleMirror:F.crossOriginIframeStyleMirror});let ce=new wo;Eo=new So({recordCanvas:S,mutationCb:se,win:window,blockClass:i,blockSelector:a,mirror:Z,sampling:v.canvas,dataURLOptions:y});let le=new no({mutationCb:N,scrollCb:oe,bypassOptions:{blockClass:i,blockSelector:a,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:ne,dataURLOptions:y,maskTextFn:h,maskInputFn:m,recordCanvas:S,inlineImages:D,sampling:v,slimDOMOptions:re,iframeManager:F,stylesheetManager:P,canvasManager:Eo,keepIframeSrcFn:ee,processedNodeManager:ce},mirror:Z});To=(e=!1)=>{if(!x)return;X({type:K.Meta,data:{href:window.location.href,width:ra(),height:na()}},e),P.reset(),le.init(),ja.forEach(e=>e.lock());let t=nt(document,{mirror:Z,blockClass:i,blockSelector:a,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskAllInputs:ne,maskTextFn:h,maskInputFn:m,slimDOM:re,dataURLOptions:y,recordCanvas:S,inlineImages:D,onSerialize:e=>{ua(e,Z)&&F.addIframe(e),da(e,Z)&&P.trackLinkElement(e),fa(e)&&le.addShadowRoot(U.shadowRoot(e),document)},onIframeLoad:(e,t)=>{F.attachIframe(e,t),le.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:ee});if(!t)return console.warn(`Failed to snapshot the document`);X({type:K.FullSnapshot,data:{node:t,initialOffset:ta(window)}},e),ja.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Z.getId(document))};try{let e=[],t=e=>Y(Za)({mutationCb:N,mousemoveCb:(e,t)=>X({type:K.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.MouseInteraction,...e}}),scrollCb:oe,viewportResizeCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.ViewportResize,...e}}),inputCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.Input,...e}}),mediaInteractionCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.MediaInteraction,...e}}),styleSheetRuleCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.StyleSheetRule,...e}}),styleDeclarationCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.StyleDeclaration,...e}}),canvasMutationCb:se,fontCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.Font,...e}}),selectionCb:e=>{X({type:K.IncrementalSnapshot,data:{source:q.Selection,...e}})},customElementCb:e=>{X({type:K.IncrementalSnapshot,data:{source:q.CustomElement,...e}})},blockClass:i,ignoreClass:o,ignoreSelector:s,maskTextClass:c,maskTextSelector:l,maskInputOptions:ne,inlineStylesheet:u,sampling:v,recordDOM:x,recordCanvas:S,inlineImages:D,userTriggeredOnInput:T,collectFonts:E,doc:e,maskInputFn:m,maskTextFn:h,keepIframeSrcFn:ee,blockSelector:a,slimDOMOptions:re,dataURLOptions:y,mirror:Z,iframeManager:F,stylesheetManager:P,shadowDomManager:le,processedNodeManager:ce,canvasManager:Eo,ignoreCSSAttributes:k,plugins:(O?.filter(e=>e.observer))?.map(e=>({observer:e.observer,options:e.options,callback:t=>X({type:K.Plugin,data:{plugin:e.name,payload:t}})}))||[]},g);F.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}});let n=()=>{To(),e.push(t(document)),Do=!0};return[`interactive`,`complete`].includes(document.readyState)?n():(e.push(W(`DOMContentLoaded`,()=>{X({type:K.DomContentLoaded,data:{}}),w===`DOMContentLoaded`&&n()})),e.push(W(`load`,()=>{X({type:K.Load,data:{}}),w===`load`&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(e){String(e).toLowerCase().includes(`cross-origin`)||console.warn(e)}}),ce.destroy(),Do=!1,Aa()}}catch(e){console.warn(e)}}Oo.addCustomEvent=(e,t)=>{if(!Do)throw Error(`please add custom event after start recording`);X({type:K.Custom,data:{tag:e,payload:t}})},Oo.freezePage=()=>{ja.forEach(e=>e.freeze())},Oo.takeFullSnapshot=e=>{if(!Do)throw Error(`please take full snapshot after start recording`);To(e)},Oo.mirror=Z;var ko;(function(e){e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`})(ko||={});var{addCustomEvent:Ao}=Oo,{freezePage:jo}=Oo,{takeFullSnapshot:Mo}=Oo,No=40,Po=7,Fo=6e4;async function Io(e){if(typeof CompressionStream>`u`)return null;try{return await new Response(new Blob([e]).stream().pipeThrough(new CompressionStream(`gzip`))).blob()}catch{return null}}function Lo({endpoint:e,onEvent:t=()=>{}}){let n=[],r=!1,i=null,a=!1,o=(e,r)=>{if(e.tries++,e.tries>=Po)return n.shift(),t({t:`drop`,b:e.b,reason:`retries`}),s();let a=r>0?r*1e3:Math.min(3e4,1e3*2**(e.tries-1))*(.75+Math.random()/2);i=setTimeout(()=>{i=null,s()},a)};async function s(){if(r||i||a||!n.length)return;r=!0;let c=n[0];try{let i=await Io(c.json),s=i||c.json,l=i?i.size:c.json.length,u=await fetch(e,{method:`POST`,body:s,credentials:`omit`,mode:`cors`,headers:{"Content-Type":`text/plain;charset=UTF-8`},keepalive:l<Fo});if(u.ok)n.shift(),t({t:`ack`,b:c.b});else{let e=``;try{e=(await u.json())?.code||``}catch{}if(e===`session_limit`||e===`session_key`)n.length=0,t({t:`rotate`,code:e});else if(e===`quota_exceeded`||e===`recording_disabled`||u.status===401||u.status===403)n.length=0,a=!0,t({t:`stop`,code:e||String(u.status)});else if(u.status===429||u.status>=500)return r=!1,o(c,Number(u.headers.get(`Retry-After`))||0);else n.shift(),t({t:`drop`,b:c.b,reason:String(u.status)})}}catch{return r=!1,o(c,0)}r=!1,s()}return{push(e){a||(n.push({...e,tries:0}),n.length>No&&t({t:`drop`,b:n.shift().b,reason:`overflow`}),s())},nudge(){i&&=(clearTimeout(i),null),s()},stop(){a=!0,n.length=0,i&&clearTimeout(i)},pending:()=>n.length}}var Ro=`https://specto.sh`,zo=/^(localhost|127(?:\.\d{1,3}){3}|\[::1\]|0\.0\.0\.0|[^/:]+\.localhost)(?::\d+)?(?:\/|$)/i;function Bo(e){let t=String(e??``).trim(),n=t.indexOf(`@`);return n<=0?{key:t,host:null}:{key:t.slice(0,n),host:t.slice(n+1).trim()||null}}function Vo(e){let t=String(e??``).trim().replace(/\/+$/,``);if(!t)throw Error(`Specto: host is empty`);/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||(t=(zo.test(t)?`http://`:`https://`)+t);let n;try{n=new URL(t)}catch{throw Error(`Specto: "${e}" is not a host — use e.g. eu.specto.sh or https://replay.example.com`)}if(n.protocol!==`https:`&&n.protocol!==`http:`)throw Error(`Specto: host must be http(s) — got "${e}"`);return(n.origin+n.pathname).replace(/\/+$/,``)}function Ho(e={},{fallback:t=null,guessed:n=!1}={}){let{key:r,host:i}=Bo(e.key),a=t=>e.configUrl===!1?null:e.configUrl||String(t).replace(/\/api\/ingest$/,`/api/sdk/config`);if(e.endpoint){let t=String(e.endpoint);return{key:r,endpoint:t,configUrl:a(t),host:null,guessed:!1}}let o=e.host||i;if(!o&&!t)return{key:r,endpoint:`/api/ingest`,configUrl:a(`/api/ingest`),host:null,guessed:!1};let s=Vo(o||t),c=`${s}/api/ingest`;return{key:r,endpoint:c,configUrl:a(c),host:s,guessed:!o&&!!n}}var Uo=`0.2.3`,Wo=e=>(e=e.toLowerCase(),e.startsWith(`data-`)||e===`title`||e===`alt`||e===`placeholder`||e===`aria-label`||e===`value`);function Go(e){if(e&&typeof e==`object`)for(let t of Object.keys(e))Wo(t)&&typeof e[t]==`string`&&e[t]&&(e[t]=`***`)}function Ko(e){e&&typeof e==`object`&&(e.attributes&&Go(e.attributes),Array.isArray(e.childNodes)&&e.childNodes.forEach(Ko))}function qo(e,t){try{e.type===4&&typeof e.data?.href==`string`?e.data.href=$(e.data.href,t):e.type===2&&e.data?.node?Ko(e.data.node):e.type===3&&e.data&&(Array.isArray(e.data.adds)&&e.data.adds.forEach(e=>Ko(e.node)),Array.isArray(e.data.attributes)&&e.data.attributes.forEach(e=>Go(e.attributes)))}catch{}return e}var Jo=[[/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,`[email]`],[/\beyJ[\w-]{6,}\.[\w-]{6,}\.[\w-]{6,}\b/g,`[jwt]`],[/\b(Bearer|Basic)\s+[\w.~+/=-]{8,}/gi,`$1 [token]`],[/\b(?:\d[ -]?){13,19}\b/g,`[number]`],[/\b(sk|pk|rk)_(live|test)_[\w]{8,}\b/g,`[key]`]];function Q(e){let t=String(e??``);for(let[e,n]of Jo)t=t.replace(e,n);return t}function Yo(e){return typeof e==`string`?e:e&&typeof e.href==`string`?e.href:e&&typeof e.url==`string`?e.url:e==null?``:String(e)}var Xo=600,Zo=/(?:^|[-_.])(token|secret|password|passwd|auth|authorization|key|apikey|api[-_]?key|session|sid|code|signature|credential|email)s?$/i,Qo=e=>e.split(/[?&=]/)[0];function $(e,t=!1){let n=String(e??``);try{let e=new URL(n,location.href),r=!1;(e.username||e.password)&&(e.username=``,e.password=``,r=!0),t&&(e.search||Qo(e.hash)!==e.hash)&&(e.search=``,e.hash=Qo(e.hash),r=!0);for(let t of[...e.searchParams.keys()])Zo.test(t)&&(e.searchParams.set(t,`***`),r=!0);if(e.hash){let t=e.hash.replace(/([?&#]|^)([^=&?#]+)=([^&#]*)/g,(e,t,n)=>Zo.test(n)?`${t}${n}=***`:e);t!==e.hash&&(e.hash=t,r=!0)}let i=Q(decodeURIComponent(e.pathname));return i!==decodeURIComponent(e.pathname)&&(e.pathname=i,r=!0),r?(/^[a-z][a-z0-9+.-]*:/i.test(n)?e.href:e.pathname+e.search+e.hash).slice(0,Xo):n.slice(0,Xo)}catch{return Q(t?n.split(`?`)[0]:n).slice(0,Xo)}}var $o=e=>{try{return new URL(e,location.href).href}catch{return String(e??``)}},es=[`content-type`,`content-length`,`content-encoding`,`cache-control`,`etag`,`vary`,`age`,`server-timing`,`x-request-id`];function ts(e){let t={};for(let n of es)try{let r=e(n);r&&(t[n]=String(r).slice(0,200))}catch{}return Object.keys(t).length?t:void 0}function ns(e,t){try{if(!e)return;if(typeof e.get==`function`)return e.get(t)||void 0;if(Array.isArray(e)){let n=e.find(e=>String(e?.[0]).toLowerCase()===t);return n?String(n[1]):void 0}for(let n of Object.keys(e))if(n.toLowerCase()===t)return String(e[n])}catch{}}function rs(e){try{return e==null?void 0:typeof e==`string`?e.length:typeof Blob<`u`&&e instanceof Blob?e.size:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof URLSearchParams<`u`&&e instanceof URLSearchParams?String(e).length:void 0}catch{return}}function is(e,t,n,r=()=>!0){typeof performance<`u`&&performance.getEntriesByName&&setTimeout(()=>{try{if(!r())return;let i=null;for(let e of performance.getEntriesByName(t,`resource`)){let t=Math.abs(e.startTime-n);t<1500&&(!i||t<Math.abs(i.startTime-n))&&(i=e)}if(!i)return;let a=e.detail||={};if(i.transferSize&&(a.xfer=Math.round(i.transferSize)),i.decodedBodySize&&a.resSize==null&&(a.resSize=Math.round(i.decodedBodySize)),i.responseStart>0){let e=i.secureConnectionStart>0?i.secureConnectionStart:i.connectEnd,t={dns:i.domainLookupEnd-i.domainLookupStart,tcp:e-i.connectStart,tls:i.secureConnectionStart>0?i.connectEnd-i.secureConnectionStart:0,ttfb:i.responseStart-i.requestStart,dl:i.responseEnd-i.responseStart};a.timing={};for(let e of Object.keys(t))t[e]>0&&(a.timing[e]=Math.round(t[e]*10)/10);Object.keys(a.timing).length||delete a.timing}}catch{}},300)}function as(e=`rec_`){return e+(typeof crypto<`u`&&crypto.getRandomValues?Array.from(crypto.getRandomValues(new Uint8Array(12))).map(e=>e.toString(16).padStart(2,`0`)).join(``):Math.abs(Date.now()^performance.now()*1e3|0).toString(16)+Math.random().toString(16).slice(2,10))}function os(){if(typeof crypto>`u`||!crypto.getRandomValues)return null;let e=crypto.getRandomValues(new Uint8Array(16));return btoa(String.fromCharCode(...e)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}var ss={get(e,t){try{return JSON.parse(window[e].getItem(t))}catch{return null}},set(e,t,n){try{window[e].setItem(t,JSON.stringify(n))}catch{}},del(e,t){try{window[e].removeItem(t)}catch{}}},cs=`specto-optout`,ls=`specto-consent`,us=()=>ss.get(`localStorage`,cs)===!0,ds=()=>ss.get(`localStorage`,ls)===`granted`;function fs(){let e=ss.get(`localStorage`,`specto-vid`);return typeof e!=`string`&&(e=as(`v_`),ss.set(`localStorage`,`specto-vid`,e)),e}var ps=18e5,ms=144e5,hs=4e3;async function gs(e,t){if(!e)return null;try{let n=typeof AbortController<`u`?new AbortController:null,r=n&&setTimeout(()=>n.abort(),3e3),i=await fetch(`${e}?key=${encodeURIComponent(t)}`,{credentials:`omit`,signal:n?.signal});if(r&&clearTimeout(r),i.ok)return await i.json();let a=null;try{a=await i.json()}catch{}return i.status===404&&a?.error===`unknown key`?{unknownKey:!0}:{failed:!0}}catch{return{failed:!0}}}function _s(e={}){if(typeof window>`u`)return{disabled:!0,reason:`no window`,stop(){}};if(window.__spectoRec&&!window.__spectoRec.disabled)return window.__spectoRec;let t=Ho(e,{fallback:e._fallback||null,guessed:!!e._guessed});if(!t.key)throw Error(`Specto: a publishable key is required — copy it from your project's Install page`);let{key:n,endpoint:r,configUrl:i}=t,a={disabled:!0,reason:`starting`,sessionId:null,stop(){},flushNow(){},count:()=>0,identify(){},track(){},sessionUrl:()=>null};if(navigator.doNotTrack===`1`||navigator.globalPrivacyControl)return Object.assign(a,{reason:`dnt`});if(us())return Object.assign(a,{reason:`opted-out`});if(e.consent===`required`&&!ds())return Object.assign(a,{reason:`consent-required`});let o=bs(e,t);window.__spectoRec=o;let s=e=>gs(i,n).then(n=>{if(n?.failed&&t.guessed&&e<3)return setTimeout(()=>s(e+1),e*2e3);o._begin(n)});return s(1),o}var vs=e=>{try{console.warn(`[specto] ${e}`)}catch{}},ys={dom:4e3,console:200,network:300,event:300,identify:20};function bs(e,t){let{key:n,endpoint:r}=t,i=[],a=0,o=!1,s=!1,c=null,l=[],u=performance.now(),d=()=>Math.round(performance.now()-u),f=`specto-session:${n}`,p=null,m={strict:e.privacy===`strict`,console:e.console!==!1,networkDetails:e.networkDetails!==!1},h=null,g=()=>h||m,_=()=>{},v=typeof WeakSet<`u`?new WeakSet:null,y=null,b=!1,x=[],S=null,C=Date.now(),w=[],T={},E=!1,D=(t,n)=>{if(!s){if(!o){if((T[t]=(T[t]||0)+1)>(ys[t]??100)){t===`dom`&&(E=!0);return}w.push([t,n]);return}i.push({kind:t,payload:n}),a++,e.onUpdate?.({total:a,kind:t})}},O=()=>ss.set(`sessionStorage`,f,p);function ee(e){let t=Date.now(),n=e?null:ss.get(`sessionStorage`,f),r=!!(n&&typeof n.id==`string`&&t-n.active<ps&&t-n.started<ms);if(r)p=n;else{let e=Math.max(0,Math.min(1,h.sampleRate));p={id:as(),sk:os(),b:0,started:t,active:t,sampled:Math.random()<e}}return p.active=t,O(),r}function k(){if(j(),ee(!0),!p.sampled)return M.stop(`not-sampled`);try{Oo.takeFullSnapshot(!0)}catch{}}function te(e){if(!e.length||!p?.sampled)return;let t={b:p.b++,json:JSON.stringify({key:n,sessionId:p.id,...p.sk?{sk:p.sk}:{},b:p.b-1,sdk:Uo,meta:{page:$(location.pathname),userAgent:navigator.userAgent,visitorId:fs()},events:e})};p.active=Math.max(p.active,C),O(),y?(y.postMessage({t:`upload`,item:t}),b||x.push(t)):S.push(t)}function A(){if(!S){try{y?.terminate()}catch{}y=null,S=Lo({endpoint:r,onEvent:ne});for(let e of x.splice(0))S.push(e)}}function j(){if(!i.length)return;let e=i;i=[],te(e)}function ne(t){t.t===`stop`?M.stop(t.code):t.t===`rotate`&&k(),e.onDelivery?.(t)}function re(){if(!i.length||!navigator.sendBeacon||!p?.sampled)return;let e=i;i=[];let t=[],a=0,o=()=>{if(!t.length)return;let e=JSON.stringify({key:n,sessionId:p.id,...p.sk?{sk:p.sk}:{},b:p.b++,sdk:Uo,meta:{page:$(location.pathname)},events:t});try{navigator.sendBeacon(r,new Blob([e],{type:`text/plain;charset=UTF-8`}))}catch{}t=[],a=0};for(let n of e){let e=JSON.stringify(n).length;a+e>55e3&&o(),!(e>55e3)&&(t.push(n),a+=e)}o(),O()}let M={disabled:!1,get sessionId(){return p?.id||null},count:()=>a,flushNow:()=>j(),identify(e,t){e!=null&&e!==``&&D(`identify`,{id:String(e).slice(0,256),traits:t&&typeof t==`object`?t:void 0})},track(e,t){e&&D(`event`,{t:d(),type:`custom`,name:String(e).slice(0,120),props:t&&typeof t==`object`?JSON.parse(JSON.stringify(t,(e,t)=>typeof t==`string`?Q(t).slice(0,500):t)):void 0})},captureError(e,t){if(e&&typeof e==`object`&&v){if(v.has(e))return;v.add(e)}let n=Q(String(e&&e.message||e||`error`)).slice(0,500),r=xs(e?.stack),i=t?.componentStack?Q(String(t.componentStack)).split(`
134
+ `,bo=typeof self<`u`&&self.Blob&&new Blob([yo],{type:`text/javascript;charset=utf-8`});function xo(e){let t;try{if(t=bo&&(self.URL||self.webkitURL).createObjectURL(bo),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(yo),{name:e?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}var So=class{constructor(e){n(this,`pendingCanvasMutations`,new Map),n(this,`rafStamps`,{latestId:0,invokeId:null}),n(this,`mirror`),n(this,`mutationCb`),n(this,`resetObservers`),n(this,`frozen`,!1),n(this,`locked`,!1),n(this,`processMutation`,(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});let{sampling:t=`all`,win:r,blockClass:i,blockSelector:a,recordCanvas:o,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&t===`all`&&this.initCanvasMutationObserver(r,i,a),o&&typeof t==`number`&&this.initCanvasFPSObserver(t,r,i,a,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,i){let a=go(t,n,r,!0),o=new Map,s=new xo;s.onmessage=e=>{let{id:t}=e.data;if(o.set(t,!1),!(`base64`in e.data))return;let{base64:n,type:r,width:i,height:a}=e.data;this.mutationCb({id:t,type:ya[`2D`],commands:[{property:`clearRect`,args:[0,0,i,a]},{property:`drawImage`,args:[{rr_type:`ImageBitmap`,args:[{rr_type:`Blob`,data:[{rr_type:`ArrayBuffer`,base64:n}],type:r}]},0,0]}]})};let c=1e3/e,l=0,u,d=()=>{let e=[];return t.document.querySelectorAll(`canvas`).forEach(t=>{G(t,n,r,!0)||e.push(t)}),e},f=e=>{if(l&&e-l<c){u=requestAnimationFrame(f);return}l=e,d().forEach(async e=>{let t=this.mirror.getId(e);if(o.get(t)||e.width===0||e.height===0)return;if(o.set(t,!0),[`webgl`,`webgl2`].includes(e.__context)){let t=e.getContext(e.__context);t?.getContextAttributes()?.preserveDrawingBuffer===!1&&t.clear(t.COLOR_BUFFER_BIT)}let n=await createImageBitmap(e);s.postMessage({id:t,bitmap:n,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[n])}),u=requestAnimationFrame(f)};u=requestAnimationFrame(f),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();let r=go(e,t,n,!1),i=mo(this.processMutation.bind(this),e,t,n),a=vo(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),i(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{let n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;let n=this.pendingCanvasMutations.get(e);if(!n||t===-1)return;let r=n.map(e=>{let{type:t,...n}=e;return n}),{type:i}=n[0];this.mutationCb({id:t,type:i,commands:r}),this.pendingCanvasMutations.delete(e)}},Co=class{constructor(e){n(this,`trackedLinkElements`,new WeakSet),n(this,`mutationCb`),n(this,`adoptedStyleSheetCb`),n(this,`styleMirror`,new pa),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){`_cssText`in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(e.length===0)return;let n={id:t,styleIds:[]},r=[];for(let t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),r.push({styleId:e,rules:Array.from(t.rules||CSSRule,(e,n)=>({rule:F(e,t.href),index:n}))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}},wo=class{constructor(){n(this,`nodeMap`,new WeakMap),n(this,`active`,!1)}inOtherBuffer(e,t){let n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}destroy(){}},X,To,Eo,Do=!1;try{if(Array.from([1],e=>e*2)[0]!==2){let e=document.createElement(`iframe`);document.body.appendChild(e),Array.from=e.contentWindow?.Array.from||Array.from,document.body.removeChild(e)}}catch(e){console.debug(`Unable to override Array.from`,e)}var Z=fe();function Oo(e={}){let{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:i=`rr-block`,blockSelector:a=null,ignoreClass:o=`rr-ignore`,ignoreSelector:s=null,maskTextClass:c=`rr-mask`,maskTextSelector:l=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:f,slimDOMOptions:p,maskInputFn:m,maskTextFn:h,hooks:g,packFn:_,sampling:v={},dataURLOptions:y={},mousemoveWait:b,recordDOM:x=!0,recordCanvas:S=!1,recordCrossOriginIframes:C=!1,recordAfter:w=e.recordAfter===`DOMContentLoaded`?e.recordAfter:`load`,userTriggeredOnInput:T=!1,collectFonts:E=!1,inlineImages:D=!1,plugins:O,keepIframeSrcFn:ee=()=>!1,ignoreCSSAttributes:k=new Set([]),errorHandler:te}=e;ka(te);let A=!C||window.parent===window,j=!1;if(!A)try{window.parent.document&&(j=!1)}catch{j=!0}if(A&&!t)throw Error(`emit function is required`);if(!A&&!j)return()=>{};b!==void 0&&v.mousemove===void 0&&(v.mousemove=b),Z.reset();let ne=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:f===void 0?{password:!0}:f,re=$e(p);la();let M,ie=0,ae=e=>{for(let t of O||[])t.eventProcessor&&(e=t.eventProcessor(e));return _&&!j&&(e=_(e)),e};X=(e,i)=>{let a=e;if(a.timestamp=Yi(),ja[0]?.isFrozen()&&a.type!==K.FullSnapshot&&(a.type!==K.IncrementalSnapshot||a.data.source!==q.Mutation)&&ja.forEach(e=>e.unfreeze()),A)t?.(ae(a),i);else if(j){let e={type:`rrweb`,event:ae(a),origin:window.location.origin,isCheckout:i};window.parent.postMessage(e,`*`)}if(a.type===K.FullSnapshot)M=a,ie=0;else if(a.type===K.IncrementalSnapshot){if(a.data.source===q.Mutation&&a.data.isAttachIframe)return;ie++;let e=r&&ie>=r,t=n&&a.timestamp-M.timestamp>n;(e||t)&&To(!0)}};let N=e=>{X({type:K.IncrementalSnapshot,data:{source:q.Mutation,...e}})},oe=e=>X({type:K.IncrementalSnapshot,data:{source:q.Scroll,...e}}),se=e=>X({type:K.IncrementalSnapshot,data:{source:q.CanvasMutation,...e}}),P=new Co({mutationCb:N,adoptedStyleSheetCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.AdoptedStyleSheet,...e}})}),F=new to({mirror:Z,mutationCb:N,stylesheetManager:P,recordCrossOriginIframes:C,wrappedEmit:X});for(let e of O||[])e.getMirror&&e.getMirror({nodeMirror:Z,crossOriginIframeMirror:F.crossOriginIframeMirror,crossOriginIframeStyleMirror:F.crossOriginIframeStyleMirror});let ce=new wo;Eo=new So({recordCanvas:S,mutationCb:se,win:window,blockClass:i,blockSelector:a,mirror:Z,sampling:v.canvas,dataURLOptions:y});let le=new no({mutationCb:N,scrollCb:oe,bypassOptions:{blockClass:i,blockSelector:a,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:ne,dataURLOptions:y,maskTextFn:h,maskInputFn:m,recordCanvas:S,inlineImages:D,sampling:v,slimDOMOptions:re,iframeManager:F,stylesheetManager:P,canvasManager:Eo,keepIframeSrcFn:ee,processedNodeManager:ce},mirror:Z});To=(e=!1)=>{if(!x)return;X({type:K.Meta,data:{href:window.location.href,width:ra(),height:na()}},e),P.reset(),le.init(),ja.forEach(e=>e.lock());let t=nt(document,{mirror:Z,blockClass:i,blockSelector:a,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskAllInputs:ne,maskTextFn:h,maskInputFn:m,slimDOM:re,dataURLOptions:y,recordCanvas:S,inlineImages:D,onSerialize:e=>{ua(e,Z)&&F.addIframe(e),da(e,Z)&&P.trackLinkElement(e),fa(e)&&le.addShadowRoot(U.shadowRoot(e),document)},onIframeLoad:(e,t)=>{F.attachIframe(e,t),le.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{P.attachLinkElement(e,t)},keepIframeSrcFn:ee});if(!t)return console.warn(`Failed to snapshot the document`);X({type:K.FullSnapshot,data:{node:t,initialOffset:ta(window)}},e),ja.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&P.adoptStyleSheets(document.adoptedStyleSheets,Z.getId(document))};try{let e=[],t=e=>Y(Za)({mutationCb:N,mousemoveCb:(e,t)=>X({type:K.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.MouseInteraction,...e}}),scrollCb:oe,viewportResizeCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.ViewportResize,...e}}),inputCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.Input,...e}}),mediaInteractionCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.MediaInteraction,...e}}),styleSheetRuleCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.StyleSheetRule,...e}}),styleDeclarationCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.StyleDeclaration,...e}}),canvasMutationCb:se,fontCb:e=>X({type:K.IncrementalSnapshot,data:{source:q.Font,...e}}),selectionCb:e=>{X({type:K.IncrementalSnapshot,data:{source:q.Selection,...e}})},customElementCb:e=>{X({type:K.IncrementalSnapshot,data:{source:q.CustomElement,...e}})},blockClass:i,ignoreClass:o,ignoreSelector:s,maskTextClass:c,maskTextSelector:l,maskInputOptions:ne,inlineStylesheet:u,sampling:v,recordDOM:x,recordCanvas:S,inlineImages:D,userTriggeredOnInput:T,collectFonts:E,doc:e,maskInputFn:m,maskTextFn:h,keepIframeSrcFn:ee,blockSelector:a,slimDOMOptions:re,dataURLOptions:y,mirror:Z,iframeManager:F,stylesheetManager:P,shadowDomManager:le,processedNodeManager:ce,canvasManager:Eo,ignoreCSSAttributes:k,plugins:(O?.filter(e=>e.observer))?.map(e=>({observer:e.observer,options:e.options,callback:t=>X({type:K.Plugin,data:{plugin:e.name,payload:t}})}))||[]},g);F.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}});let n=()=>{To(),e.push(t(document)),Do=!0};return[`interactive`,`complete`].includes(document.readyState)?n():(e.push(W(`DOMContentLoaded`,()=>{X({type:K.DomContentLoaded,data:{}}),w===`DOMContentLoaded`&&n()})),e.push(W(`load`,()=>{X({type:K.Load,data:{}}),w===`load`&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(e){String(e).toLowerCase().includes(`cross-origin`)||console.warn(e)}}),ce.destroy(),Do=!1,Aa()}}catch(e){console.warn(e)}}Oo.addCustomEvent=(e,t)=>{if(!Do)throw Error(`please add custom event after start recording`);X({type:K.Custom,data:{tag:e,payload:t}})},Oo.freezePage=()=>{ja.forEach(e=>e.freeze())},Oo.takeFullSnapshot=e=>{if(!Do)throw Error(`please take full snapshot after start recording`);To(e)},Oo.mirror=Z;var ko;(function(e){e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`})(ko||={});var{addCustomEvent:Ao}=Oo,{freezePage:jo}=Oo,{takeFullSnapshot:Mo}=Oo,No=40,Po=7,Fo=6e4;async function Io(e){if(typeof CompressionStream>`u`)return null;try{return await new Response(new Blob([e]).stream().pipeThrough(new CompressionStream(`gzip`))).blob()}catch{return null}}function Lo({endpoint:e,onEvent:t=()=>{}}){let n=[],r=!1,i=null,a=!1,o=(e,r)=>{if(e.tries++,e.tries>=Po)return n.shift(),t({t:`drop`,b:e.b,reason:`retries`}),s();let a=r>0?r*1e3:Math.min(3e4,1e3*2**(e.tries-1))*(.75+Math.random()/2);i=setTimeout(()=>{i=null,s()},a)};async function s(){if(r||i||a||!n.length)return;r=!0;let c=n[0];try{let i=await Io(c.json),s=i||c.json,l=i?i.size:c.json.length,u=await fetch(e,{method:`POST`,body:s,credentials:`omit`,mode:`cors`,headers:{"Content-Type":`text/plain;charset=UTF-8`},keepalive:l<Fo});if(u.ok)n.shift(),t({t:`ack`,b:c.b});else{let e=``;try{e=(await u.json())?.code||``}catch{}if(e===`session_limit`||e===`session_key`)n.length=0,t({t:`rotate`,code:e});else if(e===`quota_exceeded`||e===`recording_disabled`||u.status===401||u.status===403)n.length=0,a=!0,t({t:`stop`,code:e||String(u.status)});else if(u.status===429||u.status>=500)return r=!1,o(c,Number(u.headers.get(`Retry-After`))||0);else n.shift(),t({t:`drop`,b:c.b,reason:String(u.status)})}}catch{return r=!1,o(c,0)}r=!1,s()}return{push(e){a||(n.push({...e,tries:0}),n.length>No&&t({t:`drop`,b:n.shift().b,reason:`overflow`}),s())},nudge(){i&&=(clearTimeout(i),null),s()},stop(){a=!0,n.length=0,i&&clearTimeout(i)},pending:()=>n.length}}var Ro=`https://specto.sh`,zo=/^(localhost|127(?:\.\d{1,3}){3}|\[::1\]|0\.0\.0\.0|[^/:]+\.localhost)(?::\d+)?(?:\/|$)/i;function Bo(e){let t=String(e??``).trim(),n=t.indexOf(`@`);return n<=0?{key:t,host:null}:{key:t.slice(0,n),host:t.slice(n+1).trim()||null}}function Vo(e){let t=String(e??``).trim().replace(/\/+$/,``);if(!t)throw Error(`Specto: host is empty`);/^[a-z][a-z0-9+.-]*:\/\//i.test(t)||(t=(zo.test(t)?`http://`:`https://`)+t);let n;try{n=new URL(t)}catch{throw Error(`Specto: "${e}" is not a host — use e.g. eu.specto.sh or https://replay.example.com`)}if(n.protocol!==`https:`&&n.protocol!==`http:`)throw Error(`Specto: host must be http(s) — got "${e}"`);return(n.origin+n.pathname).replace(/\/+$/,``)}function Ho(e={},{fallback:t=null,guessed:n=!1}={}){let{key:r,host:i}=Bo(e.key),a=t=>e.configUrl===!1?null:e.configUrl||String(t).replace(/\/api\/ingest$/,`/api/sdk/config`);if(e.endpoint){let t=String(e.endpoint);return{key:r,endpoint:t,configUrl:a(t),host:null,guessed:!1}}let o=e.host||i;if(!o&&!t)return{key:r,endpoint:`/api/ingest`,configUrl:a(`/api/ingest`),host:null,guessed:!1};let s=Vo(o||t),c=`${s}/api/ingest`;return{key:r,endpoint:c,configUrl:a(c),host:s,guessed:!o&&!!n}}var Uo=`0.2.4`,Wo=e=>(e=e.toLowerCase(),e.startsWith(`data-`)||e===`title`||e===`alt`||e===`placeholder`||e===`aria-label`||e===`value`);function Go(e){if(e&&typeof e==`object`)for(let t of Object.keys(e))Wo(t)&&typeof e[t]==`string`&&e[t]&&(e[t]=`***`)}function Ko(e){e&&typeof e==`object`&&(e.attributes&&Go(e.attributes),Array.isArray(e.childNodes)&&e.childNodes.forEach(Ko))}function qo(e,t){try{e.type===4&&typeof e.data?.href==`string`?e.data.href=$(e.data.href,t):e.type===2&&e.data?.node?Ko(e.data.node):e.type===3&&e.data&&(Array.isArray(e.data.adds)&&e.data.adds.forEach(e=>Ko(e.node)),Array.isArray(e.data.attributes)&&e.data.attributes.forEach(e=>Go(e.attributes)))}catch{}return e}var Jo=[[/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,`[email]`],[/\beyJ[\w-]{6,}\.[\w-]{6,}\.[\w-]{6,}\b/g,`[jwt]`],[/\b(Bearer|Basic)\s+[\w.~+/=-]{8,}/gi,`$1 [token]`],[/\b(?:\d[ -]?){13,19}\b/g,`[number]`],[/\b(sk|pk|rk)_(live|test)_[\w]{8,}\b/g,`[key]`]];function Q(e){let t=String(e??``);for(let[e,n]of Jo)t=t.replace(e,n);return t}function Yo(e){return typeof e==`string`?e:e&&typeof e.href==`string`?e.href:e&&typeof e.url==`string`?e.url:e==null?``:String(e)}var Xo=600,Zo=/(?:^|[-_.])(token|secret|password|passwd|auth|authorization|key|apikey|api[-_]?key|session|sid|code|signature|credential|email)s?$/i,Qo=e=>e.split(/[?&=]/)[0];function $(e,t=!1){let n=String(e??``);try{let e=new URL(n,location.href),r=!1;(e.username||e.password)&&(e.username=``,e.password=``,r=!0),t&&(e.search||Qo(e.hash)!==e.hash)&&(e.search=``,e.hash=Qo(e.hash),r=!0);for(let t of[...e.searchParams.keys()])Zo.test(t)&&(e.searchParams.set(t,`***`),r=!0);if(e.hash){let t=e.hash.replace(/([?&#]|^)([^=&?#]+)=([^&#]*)/g,(e,t,n)=>Zo.test(n)?`${t}${n}=***`:e);t!==e.hash&&(e.hash=t,r=!0)}let i=Q(decodeURIComponent(e.pathname));return i!==decodeURIComponent(e.pathname)&&(e.pathname=i,r=!0),r?(/^[a-z][a-z0-9+.-]*:/i.test(n)?e.href:e.pathname+e.search+e.hash).slice(0,Xo):n.slice(0,Xo)}catch{return Q(t?n.split(`?`)[0]:n).slice(0,Xo)}}var $o=e=>{try{return new URL(e,location.href).href}catch{return String(e??``)}},es=[`content-type`,`content-length`,`content-encoding`,`cache-control`,`etag`,`vary`,`age`,`server-timing`,`x-request-id`];function ts(e){let t={};for(let n of es)try{let r=e(n);r&&(t[n]=String(r).slice(0,200))}catch{}return Object.keys(t).length?t:void 0}function ns(e,t){try{if(!e)return;if(typeof e.get==`function`)return e.get(t)||void 0;if(Array.isArray(e)){let n=e.find(e=>String(e?.[0]).toLowerCase()===t);return n?String(n[1]):void 0}for(let n of Object.keys(e))if(n.toLowerCase()===t)return String(e[n])}catch{}}function rs(e){try{return e==null?void 0:typeof e==`string`?e.length:typeof Blob<`u`&&e instanceof Blob?e.size:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof URLSearchParams<`u`&&e instanceof URLSearchParams?String(e).length:void 0}catch{return}}function is(e,t,n,r=()=>!0){typeof performance<`u`&&performance.getEntriesByName&&setTimeout(()=>{try{if(!r())return;let i=null;for(let e of performance.getEntriesByName(t,`resource`)){let t=Math.abs(e.startTime-n);t<1500&&(!i||t<Math.abs(i.startTime-n))&&(i=e)}if(!i)return;let a=e.detail||={};if(i.transferSize&&(a.xfer=Math.round(i.transferSize)),i.decodedBodySize&&a.resSize==null&&(a.resSize=Math.round(i.decodedBodySize)),i.responseStart>0){let e=i.secureConnectionStart>0?i.secureConnectionStart:i.connectEnd,t={dns:i.domainLookupEnd-i.domainLookupStart,tcp:e-i.connectStart,tls:i.secureConnectionStart>0?i.connectEnd-i.secureConnectionStart:0,ttfb:i.responseStart-i.requestStart,dl:i.responseEnd-i.responseStart};a.timing={};for(let e of Object.keys(t))t[e]>0&&(a.timing[e]=Math.round(t[e]*10)/10);Object.keys(a.timing).length||delete a.timing}}catch{}},300)}function as(e=`rec_`){return e+(typeof crypto<`u`&&crypto.getRandomValues?Array.from(crypto.getRandomValues(new Uint8Array(12))).map(e=>e.toString(16).padStart(2,`0`)).join(``):Math.abs(Date.now()^performance.now()*1e3|0).toString(16)+Math.random().toString(16).slice(2,10))}function os(){if(typeof crypto>`u`||!crypto.getRandomValues)return null;let e=crypto.getRandomValues(new Uint8Array(16));return btoa(String.fromCharCode(...e)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}var ss={get(e,t){try{return JSON.parse(window[e].getItem(t))}catch{return null}},set(e,t,n){try{window[e].setItem(t,JSON.stringify(n))}catch{}},del(e,t){try{window[e].removeItem(t)}catch{}}},cs=`specto-optout`,ls=`specto-consent`,us=()=>ss.get(`localStorage`,cs)===!0,ds=()=>ss.get(`localStorage`,ls)===`granted`;function fs(){let e=ss.get(`localStorage`,`specto-vid`);return typeof e!=`string`&&(e=as(`v_`),ss.set(`localStorage`,`specto-vid`,e)),e}var ps=18e5,ms=144e5,hs=4e3;async function gs(e,t){if(!e)return null;try{let n=typeof AbortController<`u`?new AbortController:null,r=n&&setTimeout(()=>n.abort(),3e3),i=await fetch(`${e}?key=${encodeURIComponent(t)}`,{credentials:`omit`,signal:n?.signal});if(r&&clearTimeout(r),i.ok)return await i.json();let a=null;try{a=await i.json()}catch{}return i.status===404&&a?.error===`unknown key`?{unknownKey:!0}:{failed:!0}}catch{return{failed:!0}}}function _s(e={}){if(typeof window>`u`)return{disabled:!0,reason:`no window`,stop(){}};if(window.__spectoRec&&!window.__spectoRec.disabled)return window.__spectoRec;let t=Ho(e,{fallback:e._fallback||null,guessed:!!e._guessed});if(!t.key)throw Error(`Specto: a publishable key is required — copy it from your project's Install page`);let{key:n,endpoint:r,configUrl:i}=t,a={disabled:!0,reason:`starting`,sessionId:null,stop(){},flushNow(){},count:()=>0,identify(){},track(){},sessionUrl:()=>null};if(navigator.doNotTrack===`1`||navigator.globalPrivacyControl)return Object.assign(a,{reason:`dnt`});if(us())return Object.assign(a,{reason:`opted-out`});if(e.consent===`required`&&!ds())return Object.assign(a,{reason:`consent-required`});let o=bs(e,t);window.__spectoRec=o;let s=e=>gs(i,n).then(n=>{if(n?.failed&&t.guessed&&e<3)return setTimeout(()=>s(e+1),e*2e3);o._begin(n)});return s(1),o}var vs=e=>{try{console.warn(`[specto] ${e}`)}catch{}},ys={dom:4e3,console:200,network:300,event:300,identify:20};function bs(e,t){let{key:n,endpoint:r}=t,i=[],a=0,o=!1,s=!1,c=null,l=[],u=performance.now(),d=()=>Math.round(performance.now()-u),f=`specto-session:${n}`,p=null,m={strict:e.privacy===`strict`,console:e.console!==!1,networkDetails:e.networkDetails!==!1},h=null,g=()=>h||m,_=()=>{},v=typeof WeakSet<`u`?new WeakSet:null,y=null,b=!1,x=[],S=null,C=Date.now(),w=[],T={},E=!1,D=(t,n)=>{if(!s){if(!o){if((T[t]=(T[t]||0)+1)>(ys[t]??100)){t===`dom`&&(E=!0);return}w.push([t,n]);return}i.push({kind:t,payload:n}),a++,e.onUpdate?.({total:a,kind:t})}},O=()=>ss.set(`sessionStorage`,f,p);function ee(e){let t=Date.now(),n=e?null:ss.get(`sessionStorage`,f),r=!!(n&&typeof n.id==`string`&&t-n.active<ps&&t-n.started<ms);if(r)p=n;else{let e=Math.max(0,Math.min(1,h.sampleRate));p={id:as(),sk:os(),b:0,started:t,active:t,sampled:Math.random()<e}}return p.active=t,O(),r}function k(){if(j(),ee(!0),!p.sampled)return M.stop(`not-sampled`);try{Oo.takeFullSnapshot(!0)}catch{}}function te(e){if(!e.length||!p?.sampled)return;let t={b:p.b++,json:JSON.stringify({key:n,sessionId:p.id,...p.sk?{sk:p.sk}:{},b:p.b-1,sdk:Uo,meta:{page:$(location.pathname),userAgent:navigator.userAgent,visitorId:fs()},events:e})};p.active=Math.max(p.active,C),O(),y?(y.postMessage({t:`upload`,item:t}),b||x.push(t)):S.push(t)}function A(){if(!S){try{y?.terminate()}catch{}y=null,S=Lo({endpoint:r,onEvent:ne});for(let e of x.splice(0))S.push(e)}}function j(){if(!i.length)return;let e=i;i=[],te(e)}function ne(t){t.t===`stop`?M.stop(t.code):t.t===`rotate`&&k(),e.onDelivery?.(t)}function re(){if(!i.length||!navigator.sendBeacon||!p?.sampled)return;let e=i;i=[];let t=[],a=0,o=()=>{if(!t.length)return;let e=JSON.stringify({key:n,sessionId:p.id,...p.sk?{sk:p.sk}:{},b:p.b++,sdk:Uo,meta:{page:$(location.pathname)},events:t});try{navigator.sendBeacon(r,new Blob([e],{type:`text/plain;charset=UTF-8`}))}catch{}t=[],a=0};for(let n of e){let e=JSON.stringify(n).length;a+e>55e3&&o(),!(e>55e3)&&(t.push(n),a+=e)}o(),O()}let M={disabled:!1,get sessionId(){return p?.id||null},count:()=>a,flushNow:()=>j(),identify(e,t){e!=null&&e!==``&&D(`identify`,{id:String(e).slice(0,256),traits:t&&typeof t==`object`?t:void 0})},track(e,t){e&&D(`event`,{t:d(),type:`custom`,name:String(e).slice(0,120),props:t&&typeof t==`object`?JSON.parse(JSON.stringify(t,(e,t)=>typeof t==`string`?Q(t).slice(0,500):t)):void 0})},captureError(e,t){if(e&&typeof e==`object`&&v){if(v.has(e))return;v.add(e)}let n=Q(String(e&&e.message||e||`error`)).slice(0,500),r=xs(e?.stack),i=t?.componentStack?Q(String(t.componentStack)).split(`
135
135
  `).map(e=>e.trim()).filter(Boolean).slice(0,8).join(`
136
136
  `).slice(0,800):void 0;D(`event`,{t:d(),type:`error`,message:n,...r?{stack:r}:{},...i?{component:i}:{},...t?.source?{source:String(t.source).slice(0,40)}:{}})},sessionUrl(){try{return p?`${t.host||new URL(r,location.href).origin}/#replay/${p.id}`:null}catch{return null}},stop(e){if(s)return;s=!0,M.disabled=!0,M.reason=e||`stopped`;try{c?.()}catch{}for(let e of l.splice(0))try{e()}catch{}j(),y&&!b&&x.length&&A();let t=y;t&&setTimeout(()=>t.terminate(),2e3),window.__spectoRec===M&&delete window.__spectoRec},_begin(i){if(s||o)return;let a=i&&typeof i==`object`?i:{},u=t.host||r;if(a.unknownKey)return M.stop(`unknown-key`),vs(`${u} has no project with the key ${n}, so nothing is recorded. Copy the key from the project's Install page${t.guessed?` — a self-hosted or EU-region project includes its host: pk_…@your-host`:``}.`);if(a.failed&&t.guessed)return M.stop(`unconfirmed`),vs(`couldn't reach ${u} to confirm the key ${n}, so this page isn't recorded.`);if(a.enabled===!1)return M.stop(`recording-disabled`);h={strict:e.privacy===`strict`||a.privacy===`strict`,console:e.console!==!1&&a.captureConsole!==!1,networkDetails:e.networkDetails!==!1&&a.captureNetworkDetails!==!1,sampleRate:Math.min(e.sampleRate??1,typeof a.sampleRate==`number`?a.sampleRate:1)};let d=ee(!1);if(!p.sampled)return M.stop(`not-sampled`);let f=h.strict&&!m.strict,g=f||E;o=!0;for(let[e,t]of w.splice(0)){let n=ae(e,t,f,g);n&&D(e,n)}if(g){try{c?.()}catch{}c=ie()}try{if(y=e.createWorker?e.createWorker():null,y){y.onmessage=e=>{let t=e.data||{};if(t.t===`ready`){b=!0,x=[];return}ne(t)},y.onerror=()=>{b||A()},y.postMessage({t:`init`,endpoint:r});let e=setTimeout(()=>{b||A()},hs);l.push(()=>clearTimeout(e))}}catch{y=null}y||(S=Lo({endpoint:r,onEvent:ne})),se(d);let _=setInterval(j,2e3);l.push(()=>clearInterval(_))}};function ie(){let e=g().strict;return Oo({emit:e=>D(`dom`,qo(e,g().strict)),maskAllInputs:!0,maskInputOptions:{password:!0,email:!0,tel:!0,color:!1},maskTextClass:`specto-mask`,maskTextSelector:e?`*`:void 0,blockClass:`specto-block`,recordCanvas:!1,collectFonts:!1,checkoutEveryNms:3e5,sampling:{mousemove:50,scroll:150,input:`last`}})}function ae(e,t,n,r){if(e===`dom`)return r?null:t;if(!t||typeof t!=`object`)return t;if(e===`console`){if(!h.console)return null;n&&(t.text=`[masked]`)}else e===`network`?(n&&t.url&&(t.url=$(t.url,!0)),h.networkDetails||delete t.detail):e===`event`&&t.type===`nav`&&n&&t.path&&(t.path=$(t.path,!0).slice(0,300));return t}function N(){if(c=ie(),m.console)for(let e of[`log`,`info`,`warn`,`error`]){let t=console[e];console[e]=(...n)=>{try{g().console&&D(`console`,{t:d(),level:e,text:g().strict?`[masked]`:Q(n.map(Ts).join(` `)).slice(0,2e3)})}catch{}t.apply(console,n)},l.push(()=>{console[e]=t})}if(m.networkDetails)try{performance.setResourceTimingBufferSize?.(1e3)}catch{}let n=()=>g().networkDetails,i=window.fetch,a=e=>new URL(e,location.href).href.split(/[?#]/)[0],o=new Set;for(let e of[r,t.configUrl])try{e&&o.add(a(e))}catch{}let s=e=>{try{return o.has(a(e))}catch{return!1}},u=new Set((Array.isArray(e.traceOrigins)?e.traceOrigins:[]).map(e=>{try{return new URL(e).origin}catch{return null}}).filter(Boolean)),f=!!e.traces||u.size>0,p=e=>{if(!f)return!1;try{let t=new URL(e,location.href).origin;return t===location.origin||u.has(t)}catch{return!1}},h=e=>{try{let[t,n]=e,r=typeof Request<`u`&&t instanceof Request,i=new Headers(n?.headers??(r?t.headers:void 0)),a=Cs.exec(i.get(`traceparent`)||``);if(a)return[e,a[1].toLowerCase()];let o=Ss(16);return i.set(`traceparent`,`00-${o}-${Ss(8)}-01`),[[t,{...n,headers:i}],o]}catch{return[e,void 0]}};window.fetch=async(...e)=>{if(s(Yo(e[0])))return i.apply(window,e);let t=performance.now(),r=Yo(e[0]),a=$(r,g().strict),o=(e[1]?.method||typeof e[0]!=`string`&&e[0]?.method||`GET`).toUpperCase(),c;p(r)&&([e,c]=h(e));try{let s=await i.apply(window,e),l=c;try{l=l||s.headers.get(`x-trace-id`)||void 0}catch{}let u={t:d(),method:o,url:a,status:s.status,dur:Math.round(performance.now()-t),...l?{traceId:l}:{}};if(n()){let i={initiator:`fetch`};try{s.statusText&&(i.statusText=String(s.statusText).slice(0,80));let t=ts(e=>s.headers.get(e));t&&(i.headers=t),t?.[`content-type`]&&(i.resType=t[`content-type`].split(`;`)[0]);let n=Number(t?.[`content-length`]);t?.[`content-length`]!=null&&Number.isFinite(n)&&(i.resSize=n);let r=ns((e[1]||(typeof e[0]==`object`?e[0]:null))?.headers,`content-type`);r&&(i.reqType=r.split(`;`)[0].slice(0,80));let a=rs(e[1]?.body);a!=null&&(i.reqSize=a)}catch{}u.detail=i,is(u,$o(r),t,n)}return D(`network`,u),s}catch(e){throw D(`network`,{t:d(),method:o,url:a,status:0,dur:Math.round(performance.now()-t),error:!0,...n()?{detail:{initiator:`fetch`,message:Q(String(e?.message||e)).slice(0,200)}}:{}}),e}},l.push(()=>{window.fetch=i});let y=window.XMLHttpRequest,b=y.prototype.open,x=y.prototype.send,S=y.prototype.setRequestHeader;y.prototype.open=function(e,t){return this.__specto={method:String(e).toUpperCase(),url:$(t,g().strict),rawUrl:$o(t),started:0,trace:p(t)},b.apply(this,arguments)},y.prototype.setRequestHeader=function(e,t){let n=String(e).toLowerCase();if(this.__specto&&n===`content-type`&&(this.__specto.reqType=String(t).split(`;`)[0].slice(0,80)),this.__specto&&n===`traceparent`){let e=Cs.exec(String(t));e&&(this.__specto.traceId=e[1].toLowerCase()),this.__specto.trace=!1}return S.apply(this,arguments)},y.prototype.send=function(e){if(this.__specto){if(this.__specto.trace)try{let e=Ss(16);S.call(this,`traceparent`,`00-${e}-${Ss(8)}-01`),this.__specto.traceId=e}catch{}this.__specto.started=performance.now(),n()&&(this.__specto.reqSize=rs(e)),this.addEventListener(`loadend`,()=>{let e=this.__specto,t=e.traceId;try{t=t||this.getResponseHeader(`x-trace-id`)||void 0}catch{}let r={t:d(),method:e.method,url:e.url,status:this.status,dur:Math.round(performance.now()-e.started),...t?{traceId:t}:{},...this.status===0?{error:!0}:{}};if(n()){let t={initiator:`xhr`};try{this.statusText&&(t.statusText=String(this.statusText).slice(0,80));let n=ts(e=>this.getResponseHeader(e));n&&(t.headers=n),n?.[`content-type`]&&(t.resType=n[`content-type`].split(`;`)[0]);let r=Number(n?.[`content-length`]);n?.[`content-length`]!=null&&Number.isFinite(r)&&(t.resSize=r),e.reqType&&(t.reqType=e.reqType),e.reqSize!=null&&(t.reqSize=e.reqSize)}catch{}r.detail=t,is(r,e.rawUrl,e.started,n)}D(`network`,r)})}return x.apply(this,arguments)},l.push(()=>{y.prototype.open=b,y.prototype.send=x,y.prototype.setRequestHeader=S});let C=e=>{let t=e.error||e.reason,n=xs(t?.stack),r={t:d(),type:`error`,message:Q(String(e.message||t?.message||e.reason||`error`)).slice(0,500),...n?{stack:n}:{}};setTimeout(()=>{if(t&&typeof t==`object`&&v){if(v.has(t))return;v.add(t)}D(`event`,r)},0)};window.addEventListener(`error`,C),window.addEventListener(`unhandledrejection`,C),l.push(()=>{window.removeEventListener(`error`,C),window.removeEventListener(`unhandledrejection`,C)}),oe=()=>{_(),D(`event`,{t:d(),type:`nav`,path:$(location.pathname+location.search+location.hash,g().strict).slice(0,300)})};let w=history.pushState,T=history.replaceState;history.pushState=function(...e){let t=w.apply(this,e);try{oe()}catch{}return t},history.replaceState=function(...e){let t=T.apply(this,e);try{oe()}catch{}return t};let E=()=>oe();window.addEventListener(`popstate`,E),window.addEventListener(`hashchange`,E),l.push(()=>{history.pushState=w,history.replaceState=T,window.removeEventListener(`popstate`,E),window.removeEventListener(`hashchange`,E)})}let oe=()=>{};function se(e){let t=()=>{let e=Date.now();if(e-C>ps){C=e,k();return}C=e};for(let e of[`click`,`keydown`,`scroll`,`pointerdown`])window.addEventListener(e,t,{capture:!0,passive:!0}),l.push(()=>window.removeEventListener(e,t,{capture:!0}));if(e||location.hash.length>1)try{oe()}catch{}let n=[],r=e=>{let t=performance.now();if(n=n.filter(n=>t-n.t<800&&Math.abs(n.x-e.clientX)<40&&Math.abs(n.y-e.clientY)<40),n.push({t,x:e.clientX,y:e.clientY}),n.length>=3){let t=e.target?.tagName?e.target.tagName.toLowerCase()+(e.target.id?`#`+e.target.id:``):`element`;D(`event`,{t:d(),type:`rage`,target:t.slice(0,80),count:n.length}),n=[]}};window.addEventListener(`click`,r,!0),l.push(()=>window.removeEventListener(`click`,r,!0));let i=()=>Math.max(document.documentElement?.scrollHeight||0,document.body?.scrollHeight||0),a=null,o=()=>{let e=i();a&&e>0&&(a.depth=Math.max(a.depth,Math.min(1,(window.scrollY+window.innerHeight)/e)))},s=()=>{a={id:Math.random().toString(36).slice(2,10),path:$(location.pathname,g().strict).slice(0,300),depth:0,clicks:0},o()},c=()=>{a&&D(`event`,{t:d(),type:`scroll`,path:a.path,pv:a.id,depth:Math.round(a.depth*1e3)/1e3,vw:window.innerWidth,dh:i()})};s(),_=()=>{$(location.pathname,g().strict).slice(0,300)!==a?.path&&(c(),s())};let u=!1,f=()=>{u||(u=!0,requestAnimationFrame(()=>{u=!1,o()}))},p=e=>{!a||a.clicks>=300||(a.clicks++,D(`event`,{t:d(),type:`click`,path:a.path,pv:a.id,x:Math.round(e.pageX),y:Math.round(e.pageY),vw:window.innerWidth,dh:i(),sel:ws(e.target)}))};window.addEventListener(`scroll`,f,{passive:!0,capture:!0}),window.addEventListener(`click`,p,!0),l.push(()=>{window.removeEventListener(`scroll`,f,{capture:!0}),window.removeEventListener(`click`,p,!0)});let m=()=>{c(),re()},h=()=>{document.visibilityState===`hidden`&&(c(),re())},v=()=>{y?y.postMessage({t:`nudge`}):S?.nudge()};window.addEventListener(`pagehide`,m),document.addEventListener(`visibilitychange`,h),window.addEventListener(`online`,v),l.push(()=>{window.removeEventListener(`pagehide`,m),document.removeEventListener(`visibilitychange`,h),window.removeEventListener(`online`,v)})}return N(),M}function xs(e){if(e)return Q(String(e)).split(`
137
137
  `).slice(0,6).map(e=>e.replace(/\?[^\s:)]*/g,``).slice(0,300)).join(`
@@ -7327,7 +7327,7 @@ function Ho(e = {}, { fallback: t = null, guessed: n = !1 } = {}) {
7327
7327
  }
7328
7328
  //#endregion
7329
7329
  //#region src/recorder.js
7330
- var Uo = "0.2.3", Wo = (e) => (e = e.toLowerCase(), e.startsWith("data-") || e === "title" || e === "alt" || e === "placeholder" || e === "aria-label" || e === "value");
7330
+ var Uo = "0.2.4", Wo = (e) => (e = e.toLowerCase(), e.startsWith("data-") || e === "title" || e === "alt" || e === "placeholder" || e === "aria-label" || e === "value");
7331
7331
  function Go(e) {
7332
7332
  if (e && typeof e == "object") for (let t of Object.keys(e)) Wo(t) && typeof e[t] == "string" && e[t] && (e[t] = "***");
7333
7333
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectosh/browser",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Specto session-replay recorder for bundler users — rrweb DOM capture, console/network/error/rage signals, privacy-masked in the browser.",
5
5
  "type": "module",
6
6
  "publishConfig": {
package/src/recorder.js CHANGED
@@ -33,7 +33,7 @@ import { record } from 'rrweb'
33
33
  import { createUploader } from './uploader.js'
34
34
  import { resolveDestination } from './destination.js'
35
35
 
36
- export const SDK_VERSION = '0.2.3'
36
+ export const SDK_VERSION = '0.2.4'
37
37
 
38
38
  // ---- privacy helpers --------------------------------------------------------
39
39
  // Attribute scrubbing — rrweb masks text/inputs but NOT element attributes,