@corbado/observe 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analysis/client.mjs +82 -56
- package/dist/analysis/config-manager.mjs +30 -5
- package/dist/analysis/device-info-manager.mjs +16 -1
- package/dist/analysis/device.mjs +88 -10
- package/dist/analysis/handoff.mjs +7 -0
- package/dist/analysis/low-events/grouped-input-tracker.mjs +148 -33
- package/dist/analysis/low-events/input-tracker.mjs +138 -59
- package/dist/analysis/low-events/shared-window-observer.mjs +148 -77
- package/dist/analysis/low-events/viewport-batcher.mjs +3 -3
- package/dist/analysis/queue.mjs +75 -8
- package/dist/analysis/{low-events/input-paste-observer.mjs → readers/input-paste.mjs} +2 -2
- package/dist/analysis/readers/input.mjs +61 -0
- package/dist/analysis/readers/loader-global.mjs +15 -0
- package/dist/analysis/readers/network.mjs +14 -0
- package/dist/analysis/readers/page.mjs +30 -0
- package/dist/analysis/readers/storage.mjs +28 -0
- package/dist/analysis/{utils → readers}/web-lock.mjs +6 -2
- package/dist/analysis/readers/window-events.mjs +48 -0
- package/dist/analysis/storage/index.mjs +61 -9
- package/dist/analysis/store/event-store.mjs +34 -16
- package/dist/analysis/transports/fetch.mjs +45 -3
- package/dist/analysis/utils/email-link-operation-full.mjs +22 -2
- package/dist/analysis/utils/email-otp-operation-full.mjs +0 -1
- package/dist/analysis/utils/form-operation-full.mjs +0 -1
- package/dist/analysis/utils/operation-full-provide-identifier-with-cui.mjs +6 -6
- package/dist/analysis/utils/passkey-enrollment-operation-full.mjs +9 -6
- package/dist/analysis/utils/passkey-login-operation-full.mjs +10 -5
- package/dist/analysis/utils/password-login-operation-full.mjs +8 -4
- package/dist/analysis/utils/password-manager-sampler.mjs +44 -4
- package/dist/analysis/utils/sms-otp-operation-full.mjs +0 -1
- package/dist/analysis/utils/totp-operation-full.mjs +0 -1
- package/dist/analysis/version.mjs +1 -1
- package/dist/cdn/script.global.js +4 -4
- package/dist/index.d.mts +131 -19
- package/dist/index.d.ts +131 -19
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +5 -3
- package/tools/reader-meta-text.d.mts +2 -0
- package/tools/reader-meta-text.mjs +26 -0
- package/tools/strip-reader-meta.d.mts +33 -0
- package/tools/strip-reader-meta.mjs +131 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";(()=>{var
|
|
2
|
-
`);if(
|
|
3
|
-
`),s=r?"[truncated]":`[+${
|
|
4
|
-
${s}`,t)}function Nr(n,e,t){let{limits:r}=t,i=K(n),o=u=>oe(u,e-1,t);if(i==="Date")return Number.isNaN(n.getTime())?"[Invalid Date]":n.toISOString();if(i==="RegExp")return _(String(n),r.maxValueLength);if(i==="ArrayBuffer")return`[ArrayBuffer(${n.byteLength})]`;if(ArrayBuffer.isView(n))return`[${i}(${n.byteLength})]`;if(i==="Map"||i==="Set"){let u=n,f=[];for(let h of u){if(f.length===r.maxBreadth)break;f.push(o(h))}return u.size>f.length&&f.push(`[+${u.size-f.length} more]`),f}if(i==="Promise"||i==="WeakMap"||i==="WeakSet"||i==="Window")return`[${i}]`;if(typeof Node<"u"&&n instanceof Node)return`[${i}]`;if(Array.isArray(n)){let u=n.slice(0,r.maxBreadth).map(o);return n.length>r.maxBreadth&&u.push(`[+${n.length-r.maxBreadth} more]`),u}if(typeof Response<"u"&&n instanceof Response)return{status:o(n.status),statusText:o(n.statusText),url:o(n.url),redirected:o(n.redirected)};if(typeof Event<"u"&&n instanceof Event){let u=n,f={type:o(u.type)};for(let h of["message","filename","lineno","colno"])h in u&&(f[h]=o(u[h]));return"error"in u&&u.error!=null&&(f.error=o(u.error)),f}let s=Object.create(null),a=n,l=Hr(n);if(l){for(let f of _r){if(f==="stack"&&!r.stack)continue;let h=a[f];if(!(h==null||typeof h=="function")){if(f==="stack"){r.stack&&typeof h=="string"&&(s.stack=J(Tt(h,r.maxStackFrames,r.maxValueLength),t));continue}s[f]=o(h)}}let u=a.cause;u!=null&&typeof u!="function"&&(s.cause=Ur(u,e-1,t))}let p=0,d=Object.keys(a);for(let u of d){if(u in s||u==="stack"&&!r.stack||l&&u==="cause")continue;if(++p>r.maxBreadth){s["\u2026"]=`[+${d.length-r.maxBreadth} keys]`;break}let f=a[u];typeof f!="function"&&(s[J(u,t)]=u==="stack"&&typeof f=="string"?J(Tt(f,r.maxStackFrames,r.maxValueLength),t):o(f))}return!l&&i!=="Object"&&p===0?`[${i}]`:s}function Ur(n,e,t){if(typeof n!="object"||n===null)return oe(n,e,t);if(t.causeBudget<=0)return J(`[${K(n)}]`,t);t.causeBudget--;try{return oe(n,e,t)}finally{t.causeBudget++}}var qr=1500,g=class{constructor(e,t){this.tracker=e;this.operationName=t}startReference;captureSpecType;captureSessionId;lowFlushers=[];lowPrefillCapturers=[];lowEventSink(e,t){return{reserveCaptureSeq:C,enqueueLowEvent:r=>this.tracker.enqueueLowEvent({...r,captureSeq:r.captureSeq??C(),subflowStartEventId:this.startReference,sourceKind:e,fieldRole:t,initiator:r.initiator??(t?`input-${t}`:"unknown")},this.captureSessionId),flushKeepalive:()=>this.tracker.lowEventFlushKeepalive(),passwordManagerDomScan:()=>this.tracker.isPasswordManagerDomScanEnabled(),registerInputs:(r,i)=>this.tracker.getWindowObserver().registerInputs(r,()=>({subflowStartEventId:this.startReference,fieldRole:t,initiator:t?`input-${t}`:"unknown",sessionId:this.captureSessionId}),i),beginCeremony:r=>this.tracker.getWindowObserver().beginCeremony({subflowStartEventId:this.startReference,initiator:r??"unknown",sessionId:this.captureSessionId})}}createLowCollector(e){try{let t=e();return this.lowPrefillCapturers.push(r=>t.capturePrefill(r)),t}catch(t){this.tracker.getLogger().error("Failed to attach low-event collector",t);return}}registerLowFlusher(e){this.lowFlushers.push(e)}captureOptions(e,t=this.startReference,r=this.captureSessionId,i){if(!t&&!i)return e;let o={};return t&&(o.subflowStartEventId=e?.subflowStartEventId??t,o.captureSessionId=e?.captureSessionId??r),i&&(o.initiator=e?.initiator??i),Object.defineProperties({},{...Object.getOwnPropertyDescriptors(e??{}),...Object.getOwnPropertyDescriptors(o)})}get captureReference(){return this.startReference}get captureSession(){return this.captureSessionId}adoptCapture(e,t,r){this.startReference=e,this.captureSessionId=t,this.captureSpecType=r}subflowStart(e,t){try{for(let r of this.lowFlushers)try{r()}catch(i){this.tracker.getLogger().error("Failed to flush previous low-event context",i)}this.captureSpecType=e?.explicitSpecType,this.startReference=b(),this.captureSessionId=this.tracker.getSessionId(),this.tracker.trackSubflowStarted(this.operationName,e,this.captureOptions(t),this.startReference),this.captureInputPrefills(!0)}catch(r){this.tracker.getLogger().error("Failed to start low-event capture context",r)}}capturePrefill(){this.captureInputPrefills(!1)}captureInputPrefills(e){for(let t of this.lowPrefillCapturers)try{t(e)}catch(r){this.tracker.getLogger().error("Failed to capture input prefill",r)}}trigger(e,t){this.tracker.trackSubflowTrigger(this.operationName,e,this.captureOptions(t))}customStep(e){return this.defineStep(e)}subflowStepStarted(e,t,r,i){this.captureSpecType=t?.explicitSpecType??this.captureSpecType,this.tracker.trackSubflowStepStarted(this.operationName,e,t,this.captureOptions(r),i)}subflowStepFinished(e,t,r){(!r?.subflowStartEventId||r.subflowStartEventId===this.startReference)&&(this.captureSpecType=t?.explicitSpecType??this.captureSpecType),this.tracker.trackSubflowStepFinished(this.operationName,e,t,this.captureOptions(r))}subflowStepError(e,t,r){let i=t;try{let o=this.tracker.getSdkConfig().rawErrors?r?.rawError:void 0;o!==void 0&&(i={...t,rawError:It(o,r?.rawErrorLimits)})}catch{}this.tracker.trackSubflowStepError(this.operationName,e,i,this.captureOptions(r))}withWindowLowEvents(e,t){let r,i=s=>{s?.subflowStartEventId&&s.subflowStartEventId!==r||t.scheduleDisarm(qr)},o=e;return{...e,start:(s,a)=>{r=a?.subflowStartEventId??this.startReference;let l=s?.explicitSpecType??this.captureSpecType,p=a?.initiator??vt(this.operationName,l);t.arm(p,l==="passkey-cui"),o.start(s,p?{...a,initiator:p}:a)},finished:(s,a)=>{o.finished(s,a),i(a)},error:(s,a)=>{o.error(s,a),i(a)},errorTyped:(s,a)=>{o.errorTyped?.(s,a),i(a)}}}defineStep(e,t){let r,i,o,s=l=>this.captureOptions(l,r,i,o);return{start:(l,p)=>{r=this.startReference,i=this.captureSessionId,o=p?.initiator,this.subflowStepStarted(e,l,s(p),t)},finished:(l,p)=>{this.subflowStepFinished(e,l,s(p))},error:(l,p)=>{this.subflowStepError(e,{error:N(l)},s(p))},errorTyped:(l,p)=>{this.subflowStepError(e,l,s(p))}}}};function kt(n,e){if(e.explicitSpecType!==void 0)try{n.getLogger().warn("Unsupported key operation spec type; omitting it")}catch{}}var se=class extends g{prepare;sign;constructor(e,t={}){super(e,"key-signing"),this.prepare=this.defineStep("prepare"),this.sign=this.defineStep("sign"),this.subflowStart({actor:"system",explicitSpecType:kt(e,t)})}},ae=class extends g{prepare;postResponse;constructor(e,t={}){super(e,"key-registration"),this.prepare=this.defineStep("prepare"),this.postResponse=this.defineStep("post-response"),this.subflowStart({actor:"system",explicitSpecType:kt(e,t)})}};function Kr(n){try{return decodeURIComponent(n.replace(/\+/g," "))}catch{return n}}function Vr(n,e){let t=n.toLowerCase();return e.some(r=>{let i=r.toLowerCase();return i.endsWith("*")?t.startsWith(i.slice(0,-1)):t===i})}function xt(n,e,t){return e!=="allowlist"||n===""||n==="?"?n:`?${(n.startsWith("?")?n.slice(1):n).split("&").map(o=>{let s=o.indexOf("=");if(s===-1)return o;let a=o.slice(0,s);return o.slice(s+1)===""||Vr(Kr(a),t)?o:`${a}=*`}).join("&")}`}var je=(n,e,t)=>{let r=!1,i,o=null,s=null,a=()=>{s!==null&&(window.clearTimeout(s),s=null);let p=o;r=!1,o=null,p!==null&&n({...i===void 0?{}:{captureSeq:i},lowType:e,ts:p,durationMs:Date.now()-p})};return{extend:()=>{if(!r){let p=t?.();r=!0,o=Date.now(),i=p}s!==null&&window.clearTimeout(s),s=window.setTimeout(a,150)},flush:a}};var $r,Z=()=>$r??=b(),Qr=()=>{let n=[];for(let e=document.activeElement;e;e=e.shadowRoot?.activeElement??null)n.push(e);return n},le=class{constructor(e,t,r){this.logger=e;this.enqueue=t;this.flushKeepalive=r;typeof window>"u"||typeof document>"u"||(this.listen(window,"blur",()=>{this.flushInputs(),this.bracket=this.context(),this.emit({lowType:"window-blur",ts:Date.now()},this.bracket)}),this.listen(window,"focus",()=>{this.flushInputs(),this.emit({lowType:"window-focus",ts:Date.now()},this.bracket??this.context()),this.bracket=void 0}),this.listen(document,"visibilitychange",()=>{this.flushInputs(),this.emit({lowType:`document-visibilitychange-${document.visibilityState==="hidden"?"hidden":"visible"}`,ts:Date.now()})}),this.listen(document,"focusout",i=>{let o=this.findInput(i.target);this.lastBlur=o&&!i.relatedTarget&&Date.now()-this.unrelatedPointerAt>250?{registration:o,ts:Date.now()}:void 0}),this.listen(document,"focusin",i=>{this.lastBlur=void 0;let o=this.inputFocusListeners.size>0&&i.composedPath().find(s=>this.findInput(s));o&&this.notifyInputFocus(o)}),this.listen(document,"pointerdown",i=>{this.findInput(i.target)?this.unrelatedPointerAt=-1/0:(this.lastBlur=void 0,this.unrelatedPointerAt=Date.now())}),window.visualViewport&&(this.listen(window.visualViewport,"resize",()=>this.extendViewport("resize")),this.listen(window.visualViewport,"scroll",()=>this.extendViewport("scroll"))),this.listen(window,"pagehide",()=>{this.flushInputs(),this.resize.flush(),this.scroll.flush(),this.flushKeepalive()}),this.observeNavigation())}inputs=new Set;inputFocusListeners=new Set;ceremonies=new Set;removers=[];lastBlur;bracket;unrelatedPointerAt=-1/0;destroyed=!1;viewportContext={};resize=je(e=>this.emit(e,this.viewportContext.resize),"visualviewport-resize",C);scroll=je(e=>this.emit(e,this.viewportContext.scroll),"visualviewport-scroll",C);registerInputs(e,t,r){if(this.destroyed)return()=>{};let i={fields:e,context:t,flush:r};if(this.inputs.add(i),this.inputFocusListeners.size>0&&typeof document<"u"){let o=Qr(),s=e.find(a=>o.includes(a));s&&this.notifyInputFocus(s)}return()=>{this.inputs.delete(i),this.lastBlur?.registration===i&&(this.lastBlur=void 0)}}beginCeremony(e){let t={context:e,settled:!1};this.destroyed||(this.flushInputs(),this.ceremonies.add(t));let r=()=>{t.timer&&clearTimeout(t.timer),this.ceremonies.delete(t),this.bracket===t.context&&(this.bracket=void 0)};return{settle:i=>{t.settled=!0,t.timer&&clearTimeout(t.timer),t.timer=setTimeout(r,i)},destroy:r}}onInputFocus(e){return this.destroyed?()=>{}:(this.inputFocusListeners.add(e),()=>this.inputFocusListeners.delete(e))}notifyInputFocus(e){for(let t of this.inputFocusListeners)try{t(e)}catch(r){this.logger.error("Failed to notify registered input focus",r)}}context(){let e=[...this.ceremonies].filter(i=>!i.settled);if(e.length===1)return e[0].context;if(e.length>1)return;let t=this.findInput(document.activeElement);if(t)return t.context();let r=this.lastBlur;if(r&&Date.now()-r.ts<=250&&(document.activeElement===document.body||!document.activeElement))return r.registration.context()}findInput(e){return[...this.inputs].find(t=>t.fields.some(r=>r===e))}flushInputs(){for(let e of this.inputs)try{e.flush()}catch(t){this.logger.error("Failed to flush window input context",t)}}emit(e,t){if(this.destroyed)return;let{sessionId:r,...i}=t??{};this.enqueue({...e,...i,captureSeq:e.captureSeq??C(),sourceKind:"window",captureVersion:1,pageId:Z()},r)}listen(e,t,r){let i=o=>{try{r(o)}catch(s){this.logger.error(`Failed to observe window ${t}`,s)}};e.addEventListener(t,i),this.removers.push(()=>e.removeEventListener(t,i))}extendViewport(e){let t=this.context(),r=this.viewportContext[e];(r?.subflowStartEventId!==t?.subflowStartEventId||r?.fieldRole!==t?.fieldRole||r?.sessionId!==t?.sessionId)&&this[e].flush(),this.viewportContext[e]=t,this[e].extend()}observeNavigation(){let e=window.navigation;e&&this.listen(e,"currententrychange",t=>{let r=t,i=r.from?.index,o=e.currentEntry?.index;r.navigationType==="traverse"&&typeof i=="number"&&typeof o=="number"&&i>=0&&o>=0&&o<i&&(this.flushInputs(),this.emit({lowType:"window-navigate-back",ts:Date.now()}))})}destroy(){if(!this.destroyed){this.flushInputs(),this.resize.flush(),this.scroll.flush(),this.destroyed=!0;for(let e of this.removers)e();for(let e of this.ceremonies)e.timer&&clearTimeout(e.timer);this.ceremonies.clear(),this.inputs.clear(),this.inputFocusListeners.clear()}}};var Ot="cbo_sdk_config",Pt="X-Corbado-Observe-Config";var I={flushIntervalMs:{min:100,max:6e4},retryMaxAttempts:{min:1,max:10},retryDelayMs:{min:50,max:12e4},sessionInactivityMs:{min:6e4,max:864e5},seqLockTimeoutMs:{min:0,max:250},deviceInfoCollectorTimeoutMs:{min:10,max:1e4},flushOnFlowTypeFinished:{maxEntries:20,maxNameLength:100},sourcePathQueryAllow:{maxEntries:50,maxKeyLength:64}},Gr=1800*1e3,S={version:"",flushIntervalMs:500,durableOutbox:!1,durableLowOutbox:!1,beaconKeepalive:!1,sessionContinuity:!1,sessionInactivityMs:Gr,seqLockTimeoutMs:50,tvc:!0,tph:!0,td:!0,tlf:!0,telemetry:!0,flushOnTelemetry:!1,flushOnFlowTypeFinished:[],deviceInfoCollectorTimeoutMs:1e3,deviceInfoTiming:!1,rawErrors:!0,pmd:!0,retry:{maxAttempts:1,baseDelayMs:0,maxDelayMs:0},aap:"",sourcePathQuery:"allowlist",sourcePathQueryAllow:[]};function A(n,e,t){return Math.min(Math.max(n,e),t)}function M(n,e){return typeof n=="number"&&Number.isFinite(n)?n:e}function F(n,e){return typeof n=="boolean"?n:e}function Ct(n,e){return typeof n=="string"?n:e}function Wr(n){return Array.isArray(n)?n.filter(e=>typeof e=="string"&&e.length>0&&e.length<=I.flushOnFlowTypeFinished.maxNameLength).slice(0,I.flushOnFlowTypeFinished.maxEntries):[]}function zr(n){return typeof n=="string"&&n.trim().toLowerCase()==="all"?"all":"allowlist"}function jr(n){return Array.isArray(n)?n.filter(e=>typeof e=="string").map(e=>e.trim()).filter(e=>e.length>0&&e.length<=I.sourcePathQueryAllow.maxKeyLength).slice(0,I.sourcePathQueryAllow.maxEntries):[]}function ee(n){if(!n||typeof n!="object")return null;let e=n;return typeof e.version!="string"||e.version===""?null:Lt(e)}function Lt(n){let e=n.retry&&typeof n.retry=="object"?n.retry:{},t=A(M(e.baseDelayMs,S.retry.baseDelayMs),I.retryDelayMs.min,I.retryDelayMs.max);return{version:Ct(n.version,""),flushIntervalMs:A(M(n.flushIntervalMs,S.flushIntervalMs),I.flushIntervalMs.min,I.flushIntervalMs.max),durableOutbox:n.durableOutbox===!0,durableLowOutbox:n.durableLowOutbox===!0,beaconKeepalive:n.beaconKeepalive===!0,sessionContinuity:n.sessionContinuity===!0,sessionInactivityMs:A(M(n.sessionInactivityMs,S.sessionInactivityMs),I.sessionInactivityMs.min,I.sessionInactivityMs.max),seqLockTimeoutMs:A(M(n.seqLockTimeoutMs,S.seqLockTimeoutMs),I.seqLockTimeoutMs.min,I.seqLockTimeoutMs.max),tvc:F(n.tvc,S.tvc),tph:F(n.tph,S.tph),td:F(n.td,S.td),tlf:F(n.tlf,S.tlf),telemetry:F(n.telemetry,S.telemetry),flushOnTelemetry:n.flushOnTelemetry===!0,flushOnFlowTypeFinished:Wr(n.flushOnFlowTypeFinished),deviceInfoCollectorTimeoutMs:A(M(n.deviceInfoCollectorTimeoutMs,S.deviceInfoCollectorTimeoutMs),I.deviceInfoCollectorTimeoutMs.min,I.deviceInfoCollectorTimeoutMs.max),deviceInfoTiming:n.deviceInfoTiming===!0,rawErrors:F(n.rawErrors,S.rawErrors),pmd:F(n.pmd,S.pmd),aap:Ct(n.aap,""),sourcePathQuery:zr(n.sourcePathQuery),sourcePathQueryAllow:jr(n.sourcePathQueryAllow),retry:{maxAttempts:A(M(e.maxAttempts,S.retry.maxAttempts),I.retryMaxAttempts.min,I.retryMaxAttempts.max),baseDelayMs:t,maxDelayMs:A(M(e.maxDelayMs,S.retry.maxDelayMs),t,I.retryDelayMs.max)}}}function Ye(n,e={}){let t=n??S,r=Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0)),i=Object.fromEntries(Object.entries(e.retry??{}).filter(([,s])=>s!==void 0)),o=Lt({...t,...r,retry:{...t.retry,...i}});return o.retry={...t.retry,...Object.fromEntries(Object.keys(i).map(s=>[s,o.retry[s]]))},o.retry.maxDelayMs=Math.max(o.retry.baseDelayMs,o.retry.maxDelayMs),o}function Ft(n){try{if(!n||typeof n!="object")return;let e=n,t=e.pmd,r=typeof t=="boolean";return{pmd:r?t:!1,pmdExplicit:r,privateMode:F(e.privateMode,!0)}}catch{return}}function Rt(n){return ee(n.getItem(Ot))}function Dt(n,e){n.setItem(Ot,e)}var Yr=6e4,Xr=6e4,de=class{constructor(e){this.options=e}async send(e,t){try{e.meta={...e.meta,sent:Date.now(),transport:"fetch"};let r=JSON.stringify(e),i=typeof AbortController<"u"?new AbortController:void 0,o=i?setTimeout(()=>i.abort(),Xr):void 0;try{let s={method:"POST",headers:{"Content-Type":"application/json",...this.options.headers,...t},body:r,keepalive:new Blob([r]).size<=Yr,...i?{signal:i.signal}:{}},a=await fetch(this.options.url,s),l={statusCode:a.status,headers:{"retry-after":a.headers.get("Retry-After")}};if(a.headers.get("X-Corbado-Observe-Accepted")==="1"&&(l.deliveryAccepted=!0),a.status===200)try{let p=ee(await a.json());p&&(l.config=p)}catch(p){this.options.logger.error("Failed to parse SDK config response",p),this.options.logger.reportTelemetry?.("error","failed to parse SDK config response")}return l}finally{o&&clearTimeout(o)}}catch(r){return this.options.logger.error("Failed to send event",r),{}}}sendBeacon(e){try{if(this.options.logger.debug(`Sending ${e.events.length} events via beacon`),typeof navigator?.sendBeacon!="function")return!1;e.meta={...e.meta,sent:Date.now(),transport:"beacon"};let t=new Blob([JSON.stringify(e)],{type:"text/plain"});return navigator.sendBeacon(this.options.url,t)}catch(t){return this.options.logger.error("Failed to send event via beacon",t),!1}}flush(e){return Promise.resolve(!0)}};function pe(n,e,t={}){let r=typeof navigator<"u"?navigator.locks:void 0;if(r?.request){let i=t.timeoutMs,o=i!==void 0&&typeof AbortController<"u"?new AbortController:null;if(i!==void 0&&!o)return Promise.resolve().then(e);try{let s=!1,a,l=()=>{a!==void 0&&(clearTimeout(a),a=void 0)},p=()=>(s=!0,l(),e()),d=o?r.request(n,{signal:o.signal},p):r.request(n,p);return o&&i!==void 0&&!s&&(a=setTimeout(()=>{a=void 0,o.abort();try{t.onTimeout?.()}catch{}},i)),d.catch(u=>{if(s)throw u;return e()}).finally(l)}catch{}}try{return Promise.resolve(e())}catch(i){return Promise.reject(i)}}var Jr="cbo_outbox",Xe="cbo_outbox",Zr=500,ei=512*1024;function ti(n){if(!n||typeof n!="object")return!1;let e=n;return typeof e.id=="string"&&e.id!==""&&typeof e.sessionId=="string"&&typeof e.flushAfter=="number"&&Number.isFinite(e.flushAfter)&&typeof e.attempts=="number"&&Number.isFinite(e.attempts)&&typeof e.event=="object"&&e.event!==null}var V=class{constructor(e,t,r=Zr,i=ei,o=Xe,s=Jr){this.storage=e;this.logger=t;this.maxEntries=r;this.maxSerializedLength=i;this.lockName=o;this.storageKey=s;this.entries=this.read()}entries=[];reportedMalformed=!1;read(){let e=this.storage.getItem(this.storageKey);if(!Array.isArray(e))return[];let t=e.filter(ti);return t.length<e.length&&!this.reportedMalformed&&(this.reportedMalformed=!0,this.logger.error(`EventStore dropped ${e.length-t.length} malformed outbox entries`),this.logger.reportTelemetry?.("error","event store dropped malformed outbox entries")),t}mutate(e){return pe(this.lockName,()=>{try{let t=e(this.read());if(t.length>this.maxEntries){let r=t.length-this.maxEntries;t=t.slice(t.length-this.maxEntries),this.logger.error(`EventStore evicted ${r} oldest entries (cap ${this.maxEntries})`),this.logger.reportTelemetry?.("error","event store evicted entries (cap)")}t=this.enforceSizeBudget(t),this.entries=t,this.storage.setItem(this.storageKey,t)}catch(t){this.logger.error("Failed to mutate event store",t),this.logger.reportTelemetry?.("error","failed to mutate event store")}})}enforceSizeBudget(e){let t=e.map(o=>JSON.stringify(o).length),r=t.reduce((o,s)=>o+s,e.length+1),i=0;for(;r>this.maxSerializedLength&&i<e.length;)r-=t[i]+1,i++;return i===0?e:(this.logger.error(`EventStore evicted ${i} oldest entries (size budget ${this.maxSerializedLength})`),this.logger.reportTelemetry?.("error","event store evicted entries (size budget)"),e.slice(i))}add(e){return this.mutate(t=>t.some(r=>r.id===e.id)?t:[...t,e])}all(){return this.entries=this.read(),this.entries}getDue(e){return this.all().filter(t=>t.flushAfter<=e)}remove(e){if(e.length===0)return Promise.resolve();let t=new Set(e);return this.mutate(r=>r.filter(i=>!t.has(i.id)))}update(e){if(e.length===0)return Promise.resolve();let t=new Map(e.map(r=>[r.id,r]));return this.mutate(r=>r.map(i=>t.get(i.id)??i))}size(){return this.all().length}};var ri=500,ii=512*1024,_t=200,At=200*1024,ni=16*1024,Mt=6e4,Je=32e3;function ue(n){let e=0;for(let t=0;t<n.length;t++){let r=n.charCodeAt(t);r<128?e+=1:r<2048?e+=2:r>=55296&&r<=56319&&t+1<n.length?(e+=4,t++):e+=3}return e}var ce=class{constructor(e,t,r,i,o={},s){this.logger=e;this.transport=t;this.sessionId=r;this.sdk=i;this.storage=s;if(this.batchSize=o.batchSize||50,this.flushIntervalOverride=o.flushInterval,this.debug=o.debug??!1,this.requestConfig=o.requestConfig??!0,this.onConfigReceived=o.onConfigReceived,this.getDataPolicy=o.getDataPolicy,this.fixedData=o.fixedData===!0,this.beforeEventBatchSend=o.beforeEventBatchSend,this.standaloneDeviceInfo=o.standaloneDeviceInfo,this.config=o.config??S,this.priorityFlowTypes=new Set(this.config.flushOnFlowTypeFinished),this.outboxLockName=o.outboxLockName,this.config.durableOutbox&&this.storage&&(this.store=new V(this.storage,this.logger,void 0,void 0,this.outboxLockName),this.pending=this.store.all()),this.storage){this.lowStore=new V(this.storage,this.logger,1e3,256*1024,`${this.outboxLockName??"cbo_outbox"}:lows`,"cbo_low_outbox_v1");let a=this.lowStore.all();this.lowPending=a.filter(l=>this.validPendingLow(l)),this.lowStore.remove(a.filter(l=>!this.validPendingLow(l)).map(l=>l.id))}this.setupLifecycleHooks(),(this.pending.length>0||this.lowPending.length>0)&&(this.dirtySinceSyncFlush=!0,this.scheduleFlush(0,"recovery"))}pending=[];lowsQueue=[];lowPending=[];lowStore;telemetryQueue=[];probeQueue=[];probeBytes=0;probesDropped=0;timer=null;isFlushing=!1;flushingDone;destroyed=!1;dirtySinceSyncFlush=!1;onVisibilityChange=null;onPageHide=null;batchSize;flushIntervalOverride;debug;requestConfig;onConfigReceived;getDataPolicy;fixedData;beforeEventBatchSend;standaloneDeviceInfo;config;priorityFlowTypes;outboxLockName;store;configResolved=!1;setSessionId(e){this.sessionId=e}flushInterval(){return this.flushIntervalOverride??this.config.flushIntervalMs}enqueue(e,t=this.sessionId){try{let r={id:e.id,sessionId:t,flushAfter:0,attempts:0,event:e};this.pending.push(r),this.store?.add(r),this.scheduleAfterEnqueue(e)}catch(r){this.logger.error("Failed to enqueue event",r)}}enqueueLow(e,t=this.sessionId){try{let r={...e,id:e.id??b()};if(this.config.durableLowOutbox){let i={id:r.id,sessionId:t,event:r,attempts:0,flushAfter:0};this.lowPending.push(i),this.lowPending=this.lowPending.slice(-1e3),this.lowStore?.add(i)}else this.lowsQueue.push({sessionId:t,event:r});this.scheduleAfterEnqueue()}catch(r){this.logger.error("Failed to enqueue low event",r)}}notifyDeviceInfo(){try{this.dirtySinceSyncFlush=!0,this.scheduleFlush(this.flushInterval(),"timer")}catch(e){this.logger.error("Failed to schedule device info flush",e)}}enqueueTelemetry(e){try{if(!this.config.telemetry)return;this.telemetryQueue.push(e),this.dirtySinceSyncFlush=!0,this.config.flushOnTelemetry&&this.flush("telemetry")}catch(t){this.logger.error("Failed to enqueue telemetry",t)}}enqueueProbe(e,t=this.sessionId){try{if(this.destroyed)return;let r=JSON.stringify(e.payload);if(typeof r!="string"||ue(r)>ni){this.probesDropped++;return}let i={...e,payload:JSON.parse(r)},o=ue(JSON.stringify(i));for(this.probeQueue.push({sessionId:t,entry:i,bytes:o,attempts:0,flushAfter:0}),this.probeBytes+=o;this.probeQueue.length>ri||this.probeBytes>ii&&this.probeQueue.length>1;){let s=this.probeQueue.shift();this.probeBytes-=s.bytes,this.probesDropped++}this.scheduleFlush(this.flushInterval(),"timer")}catch(r){this.logger.error("Failed to enqueue probe",r)}}droppedProbeCount(){return this.probesDropped}dueProbes(e){return this.probeQueue.filter(t=>t.flushAfter<=e)}selectProbes(e,t,r,i){let o=[],s=0;for(let a of e){if(o.length>=r)break;if(a.sessionId===t){if(s+a.bytes>i){o.length===0&&i>=At&&o.push(a);break}s+=a.bytes,o.push(a)}}return o}removeProbes(e){if(e.length===0)return;let t=new Set(e);this.probeQueue=this.probeQueue.filter(r=>!t.has(r));for(let r of e)this.probeBytes-=r.bytes}dropProbes(e){this.removeProbes(e),this.probesDropped+=e.length}handleProbeSendResult(e,t,r){if(t.length===0)return;let i=e.statusCode;if(typeof i=="number"&&i>=200&&i<300){this.removeProbes(t);return}if(!this.isRetryable(i)){this.dropProbes(t);return}let o=Math.max(1,this.config.retry.maxAttempts),s=this.parseRetryAfter(e),a=[];for(let l of t)l.attempts+=1,l.attempts>=o?a.push(l):l.flushAfter=r+this.backoffForAttempt(l.attempts,s);this.dropProbes(a)}sendUnloadProbes(e,t,r,i){let o=this.sessionId,s={sessionId:o,events:[],sdk:this.sdk,probes:[]};this.attachBatchMeta(s,[],t);let a=ue(JSON.stringify(s))+120,l=e>a?this.selectProbes(this.probeQueue,o,_t,e-a):[];l.length>0&&(s.probes=l.map(p=>p.entry),this.attachBatchMeta(s,l,t),i&&this.config.beaconKeepalive&&this.transport.sendBeacon?this.transport.sendBeacon(s):Promise.resolve(this.transport.send(s)).catch(()=>{}),this.removeProbes(l)),r&&this.dropProbes(this.probeQueue.slice())}scheduleAfterEnqueue(e){if(this.dirtySinceSyncFlush=!0,e!==void 0&&this.isPriorityEvent(e)){this.flush("flow-finished");return}this.scheduleFlush(this.flushInterval(),"timer")}isPriorityEvent(e){if(e.type!=="predefined"||e.name!=="flow_finished"&&e.name!=="flow_auto_finished")return!1;let t=e.data?.flowName;return typeof t=="string"&&this.priorityFlowTypes.has(t)}scheduleFlush(e,t){this.destroyed||this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.flush(t)},e))}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}async flush(e="timer"){if(this.destroyed)return;if(this.isFlushing){if(e==="destroy"){await this.flushingDone;try{this.sendUnloadProbes(Je,e,!0,!1)}catch(r){this.logger.error("Unexpected error in queue flush",r)}}return}this.isFlushing=!0;let t;this.flushingDone=new Promise(r=>{t=r});try{for(this.clearTimer();;){let r=Date.now(),i=this.getDuePending(r),o=this.lowPending.filter(w=>w.flushAfter<=r),s=e==="destroy"?[]:this.dueProbes(r),a=i.length===0&&o.length===0&&this.lowsQueue.length===0&&this.telemetryQueue.length===0&&s.length===0;if(a&&!this.hasStandaloneDeviceInfo())break;let l=i[0]?.sessionId??o[0]?.sessionId??this.lowsQueue[0]?.sessionId??s[0]?.sessionId??this.sessionId,p=i.filter(w=>w.sessionId===l).slice(0,this.batchSize),d=o.filter(w=>w.sessionId===l).slice(0,100),u=[...d.map(w=>w.event),...this.takeLows(l,100-d.length)];this.prepareEvents(p,e);let f=l===this.sessionId?this.takeTelemetry():[],h=l===this.sessionId?this.takeStandaloneDeviceInfo():void 0,m=this.selectProbes(s,l,_t,At),c={sessionId:l,events:p.map(w=>w.event),sdk:this.sdk};if(u.length>0&&(c.lows=u),f.length>0&&(c.telemetry=f),m.length>0&&(c.probes=m.map(w=>w.entry)),h&&(c.deviceInfo=h),a&&!h)break;this.attachBatchMeta(c,[...p,...d,...m],e),d.length&&(c.deliveryAck=!0);let v=this.shouldRequestConfig()?{[Pt]:this.config.version||"1"}:void 0,y=await this.transport.send(c,v).catch(w=>(this.logger.error("Unexpected error in queue flush",w),{}));if(c.deliveryAck&&y.statusCode&&y.statusCode>=200&&y.statusCode<300&&!y.deliveryAccepted&&(y={...y,statusCode:503}),this.requestConfig&&this.handleConfigResponse(y),this.handleLowSendResult(y,d,r),this.handleProbeSendResult(y,m,r),!this.handleSendResult(y,p,r))break}e==="destroy"&&this.sendUnloadProbes(Je,e,!0,!1)}catch(r){this.logger.error("Unexpected error in queue flush",r)}finally{this.isFlushing=!1,t(),this.flushingDone=void 0,this.rescheduleIfPending()}}attachBatchMeta(e,t,r){e.meta={...e.meta,flushReason:r};let i=this.readDataPolicy();i!==void 0&&(e.meta={...e.meta,dataPolicy:i}),this.config.version&&(e.meta={...e.meta,configVersion:this.config.version}),this.fixedData&&(e.meta={...e.meta,fixedData:!0});let o=t.reduce((s,a)=>Math.max(s,a.attempts),0);o>0&&(e.meta={...e.meta,retryCount:o})}prepareEvents(e,t){if(!(!this.beforeEventBatchSend||e.length===0))try{this.beforeEventBatchSend(e.map(r=>r.event),t)}catch(r){this.logger.error("Failed to prepare events for sending",r)}}readDataPolicy(){try{return this.getDataPolicy?.()}catch(e){this.logger.debug("Failed to read data policy for batch meta",e);return}}getDuePending(e){return this.pending.filter(t=>t.flushAfter<=e)}takeLows(e=this.sessionId,t=100){let r=this.lowsQueue.filter(o=>o.sessionId===e).slice(0,t),i=new Set(r);return this.lowsQueue=this.lowsQueue.filter(o=>!i.has(o)),r.map(o=>o.event)}validPendingLow(e){return typeof e.event?.lowType=="string"&&e.event.id===e.id&&Number.isFinite(e.event.ts)&&e.event.ts>Date.now()-7*864e5}removeLowEntries(e){let t=new Set(e);this.lowPending=this.lowPending.filter(r=>!t.has(r.id)),this.lowStore?.remove(e)}handleLowSendResult(e,t,r){let i=e.statusCode;if(i!==void 0&&i>=200&&i<300){e.deliveryAccepted?this.removeLowEntries(t.map(o=>o.id)):this.deferLowEntries(t,r);return}if(!this.isRetryable(i)){this.removeLowEntries(t.map(o=>o.id)),this.logger.reportTelemetry?.("error","low events rejected by ingestion");return}this.deferLowEntries(t,r,this.parseRetryAfter(e))}deferLowEntries(e,t,r=null){let i=[];for(let o of e){if(!this.validPendingLow(o)){i.push(o.id);continue}o.attempts=Math.min(o.attempts+1,16),o.flushAfter=t+Math.max(Math.min(6e4,1e3*2**Math.min(o.attempts,6)),this.backoffForAttempt(o.attempts,r))}this.removeLowEntries(i),this.lowStore?.update(e.filter(o=>!i.includes(o.id)))}hasStandaloneDeviceInfo(){try{return this.standaloneDeviceInfo?.has()??!1}catch(e){return this.logger.error("Failed to read device info for batch",e),!1}}takeStandaloneDeviceInfo(){try{return this.standaloneDeviceInfo?.take()}catch(e){this.logger.error("Failed to read device info for batch",e);return}}takeTelemetry(){let e=this.telemetryQueue;return this.telemetryQueue=[],e}shouldRequestConfig(){return this.requestConfig&&!this.configResolved}handleConfigResponse(e){let t=e.statusCode;typeof t=="number"&&t>=200&&t<300&&(this.configResolved=!0),e.config&&(this.config.version||this.updateConfig(e.config),this.onConfigReceived?.(e.config))}updateConfig(e){if(this.destroyed)return;let t=this.config.flushIntervalMs!==e.flushIntervalMs;if(this.config={...e,durableOutbox:this.config.durableOutbox||e.durableOutbox},this.priorityFlowTypes=new Set(e.flushOnFlowTypeFinished),e.durableLowOutbox&&this.lowsQueue.length){let i=this.lowsQueue;this.lowsQueue=[];for(let{event:o,sessionId:s}of i)this.enqueueLow(o,s)}let r=!1;if(this.config.durableOutbox&&this.storage&&!this.store){this.store=new V(this.storage,this.logger,void 0,void 0,this.outboxLockName);let i=new Set(this.pending.map(s=>s.id)),o=this.store.all().filter(s=>!i.has(s.id));for(let s of this.pending)this.store.add(s);this.pending=[...o,...this.pending],r=o.length>0}r?(this.dirtySinceSyncFlush=!0,this.clearTimer(),this.scheduleFlush(0,"recovery")):t&&(this.clearTimer(),this.rescheduleIfPending())}handleSendResult(e,t,r){let i=e.statusCode,o=typeof i=="number"&&i>=200&&i<300;if(t.length===0)return o;if(o)return this.removeEntries(t.map(d=>d.id)),!0;if(!this.isRetryable(i))return this.removeEntries(t.map(d=>d.id)),!1;let s=Math.max(1,this.config.retry.maxAttempts),a=this.parseRetryAfter(e),l=[],p=[];for(let d of t)d.attempts+=1,d.attempts>=s?l.push(d.id):(d.flushAfter=r+this.backoffForAttempt(d.attempts,a),p.push(d));return this.removeEntries(l),this.store?.update(p),!1}isRetryable(e){return e===void 0||e===408||e===429?!0:e>=500}backoffForAttempt(e,t){let r=this.config.retry,i=r.baseDelayMs*Math.pow(2,Math.max(0,e-1));r.maxDelayMs>0&&(i=Math.min(i,r.maxDelayMs));let o=Math.round(i/2+Math.random()*(i/2));return t!==null&&(o=Math.max(o,t)),o}parseRetryAfter(e){let t=e.headers?.["retry-after"];if(!t)return null;let r=Number(t);if(!Number.isNaN(r))return r*1e3;let i=Date.parse(t);return Number.isNaN(i)?null:Math.max(0,i-Date.now())}removeEntries(e){if(e.length===0)return;let t=new Set(e);this.pending=this.pending.filter(r=>!t.has(r.id)),this.store?.remove(e)}rescheduleIfPending(){try{if(this.destroyed||this.timer||this.pending.length===0&&this.lowPending.length===0&&this.lowsQueue.length===0&&this.probeQueue.length===0)return;let e=Date.now();if(this.getDuePending(e).length>0||this.lowPending.some(r=>r.flushAfter<=e)||this.lowsQueue.length>0||this.probeQueue.some(r=>r.flushAfter<=e)){this.scheduleFlush(this.flushInterval(),"timer");return}let t=Math.min(...[...this.pending,...this.lowPending,...this.probeQueue].map(r=>r.flushAfter));this.scheduleFlush(Math.max(0,t-e),"backoff")}catch(e){this.logger.error("Failed to reschedule queue flush",e)}}setupLifecycleHooks(){typeof window>"u"||(this.onVisibilityChange=()=>{try{this.writeLifecycleDebugOutput("cbo_visibility_change_debug"),document.visibilityState==="hidden"&&this.config.tvc&&this.flushSync("visibility-change")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},this.onPageHide=()=>{try{this.writeLifecycleDebugOutput("cbo_pagehide_debug"),this.config.tph&&this.flushSync("pagehide")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},window.addEventListener("visibilitychange",this.onVisibilityChange),window.addEventListener("pagehide",this.onPageHide))}writeLifecycleDebugOutput(e){if(!this.debug||!this.storage)return;let t={last_executed:Date.now(),url:window.location.href};this.storage.setItem(e,t)}flushKeepalive(e="manual"){this.flushSync(e)}flushSync(e){let t=this.flushSyncEvents(e);e==="pagehide"&&this.probeQueue.length>0&&this.sendUnloadProbes(Math.min(Mt-t,Je),e,!0,!0)}flushSyncEvents(e){if(!this.dirtySinceSyncFlush)return 0;let t=this.sessionId,r=this.pending.filter(d=>d.sessionId===t),i=r.slice(0,this.batchSize),o=this.lowPending.filter(d=>d.sessionId===t).slice(0,100),s=[...o.map(d=>d.event),...this.takeLows(t,100-o.length)];this.prepareEvents(i,e);let a=this.takeTelemetry(),l=this.takeStandaloneDeviceInfo();if(i.length===0&&s.length===0&&a.length===0&&!l)return this.dirtySinceSyncFlush=!1,0;let p={sessionId:t,events:i.map(d=>d.event),sdk:this.sdk};return s.length>0&&(p.lows=s),a.length>0&&(p.telemetry=a),l&&(p.deviceInfo=l),this.attachBatchMeta(p,[...i,...o],e),o.length&&(p.deliveryAck=!0),this.config.beaconKeepalive&&this.transport.sendBeacon?this.transport.sendBeacon(p)||this.transport.send(p):this.transport.send(p),this.config.durableOutbox||this.removeEntries(i.map(d=>d.id)),this.dirtySinceSyncFlush=!this.config.durableOutbox&&r.length>i.length,this.approximateSize(p)}approximateSize(e){try{return ue(JSON.stringify(e))}catch{return Mt}}destroy(){try{this.destroyed=!0,this.clearTimer(),this.dropProbes(this.probeQueue.slice()),typeof window<"u"&&(this.onVisibilityChange&&window.removeEventListener("visibilitychange",this.onVisibilityChange),this.onPageHide&&window.removeEventListener("pagehide",this.onPageHide))}catch(e){this.logger.error("Failed to destroy queue lifecycle hooks",e)}}};function Ht(n){return typeof navigator>"u"?"":navigator.userAgent??""}async function Bt(n){if(!(typeof navigator>"u"||!navigator.bluetooth))return await navigator.bluetooth.getAvailability()}async function Nt(n){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable))return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}async function Ut(n){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isConditionalMediationAvailable))return await PublicKeyCredential.isConditionalMediationAvailable()}async function qt(n){if(typeof PublicKeyCredential>"u"||!PublicKeyCredential.getClientCapabilities)return;let e=await PublicKeyCredential.getClientCapabilities();return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,r.toString()]))}async function Kt(n){if(typeof navigator>"u"||!navigator.userAgentData)return;let e=await navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]),t=e.platform,r=e.mobile,i=e.platformVersion,o=e.model||void 0;if(!(!t||r===void 0||!i))return{platform:t,mobile:r,platformVersion:i,model:o}}function Vt(n){if(!(typeof navigator>"u"))return navigator.webdriver}function $t(n){if(!(typeof navigator>"u"||typeof navigator.maxTouchPoints!="number"))return navigator.maxTouchPoints}var Ze={d:(n,e)=>{for(var t in e)Ze.o(e,t)&&!Ze.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:e[t]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e)},et={};Ze.d(et,{A:()=>oi,k:()=>Qt});var $=function(n,e,t,r){return new(t||(t=Promise))(function(i,o){function s(p){try{l(r.next(p))}catch(d){o(d)}}function a(p){try{l(r.throw(p))}catch(d){o(d)}}function l(p){var d;p.done?i(p.value):(d=p.value,d instanceof t?d:new t(function(u){u(d)})).then(s,a)}l((r=r.apply(n,e||[])).next())})},Q=function(n,e){var t,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(p){return(function(d){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,d[0]&&(s=0)),s;)try{if(t=1,r&&(i=2&d[0]?r.return:d[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,d[1])).done)return i;switch(r=0,i&&(d=[2&d[0],i.value]),d[0]){case 0:case 1:i=d;break;case 4:return s.label++,{value:d[1],done:!1};case 5:s.label++,r=d[1],d=[0];continue;case 7:d=s.ops.pop(),s.trys.pop();continue;default:if(i=s.trys,!((i=i.length>0&&i[i.length-1])||d[0]!==6&&d[0]!==2)){s=0;continue}if(d[0]===3&&(!i||d[1]>i[0]&&d[1]<i[3])){s.label=d[1];break}if(d[0]===6&&s.label<i[1]){s.label=i[1],i=d;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(d);break}i[2]&&s.ops.pop(),s.trys.pop();continue}d=e.call(n,s)}catch(u){d=[6,u],r=0}finally{t=i=0}if(5&d[0])throw d[1];return{value:d[0]?d[1]:void 0,done:!0}})([l,p])}}};function Qt(){return $(this,void 0,Promise,function(){return Q(this,function(n){switch(n.label){case 0:return[4,new Promise(function(e,t){var r="Unknown",i=!1;function o(d){i||(i=!0,e({isPrivate:d,browserName:r}))}function s(){var d=0,u=parseInt("-1");try{u.toFixed(u)}catch(f){d=f.message.length}return d}function a(){return $(this,void 0,void 0,function(){var d,u;return Q(this,function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),[4,navigator.storage.getDirectory()];case 1:return f.sent(),o(!1),[3,3];case 2:return d=f.sent(),u=d instanceof Error&&typeof d.message=="string"?d.message:String(d),o(u.includes("unknown transient reason")),[3,3];case 3:return[2]}})})}function l(){var d;return $(this,void 0,Promise,function(){return Q(this,function(u){switch(u.label){case 0:return typeof((d=navigator.storage)===null||d===void 0?void 0:d.getDirectory)!="function"?[3,2]:[4,a()];case 1:return u.sent(),[3,3];case 2:navigator.maxTouchPoints!==void 0?(function(){var f=String(Math.random());try{var h=indexedDB.open(f,1);h.onupgradeneeded=function(m){var c=m.target.result,v=function(y){o(y)};try{c.createObjectStore("t",{autoIncrement:!0}).put(new Blob),v(!1)}catch(y){(y instanceof Error&&typeof y.message=="string"?y.message:String(y)).includes("are not yet supported")?v(!0):v(!1)}finally{c.close(),indexedDB.deleteDatabase(f)}},h.onerror=function(){return o(!1)}}catch{o(!1)}})():(function(){var f=window.openDatabase,h=window.localStorage;try{f(null,null,null,null)}catch{return void o(!0)}try{h.setItem("test","1"),h.removeItem("test")}catch{return void o(!0)}o(!1)})(),u.label=3;case 3:return[2]}})})}function p(){var d;return $(this,void 0,Promise,function(){var u,f,h;return Q(this,function(m){switch(m.label){case 0:if(typeof((d=navigator.storage)===null||d===void 0?void 0:d.getDirectory)!="function")return[3,5];m.label=1;case 1:return m.trys.push([1,3,,4]),[4,navigator.storage.getDirectory()];case 2:return m.sent(),o(!1),[3,4];case 3:return u=m.sent(),f=u instanceof Error&&typeof u.message=="string"?u.message:String(u),o(f.includes("Security error")),[2];case 4:return[3,6];case 5:(h=indexedDB.open("inPrivate")).onerror=function(c){if(h.error&&h.error.name==="InvalidStateError")return c.preventDefault(),void o(!0);o(!1)},h.onsuccess=function(){indexedDB.deleteDatabase("inPrivate"),o(!1)},m.label=6;case 6:return[2]}})})}(function(){return $(this,void 0,Promise,function(){return Q(this,function(d){switch(d.label){case 0:return s()!==44&&s()!==43?[3,2]:(r="Safari",[4,l()]);case 1:return d.sent(),[3,6];case 2:return s()!==51?[3,3]:(u=navigator.userAgent,r=u.match(/Chrome/)?navigator.brave!==void 0?"Brave":u.match(/Edg/)?"Edge":u.match(/OPR/)?"Opera":"Chrome":"Chromium",(function(){var f=this,h="__di_"+Math.random().toString(36).slice(2),m=new Uint8Array(16384),c=indexedDB.open(h,1);c.onupgradeneeded=function(){c.result.createObjectStore("s")},c.onerror=function(){indexedDB.deleteDatabase(h),o(!1)},c.onsuccess=function(){var v=c.result,y=!1;try{var w=v.transaction("s","readwrite",{durability:"strict"});y=w.durability==="strict",w.abort()}catch{}if(!y)return v.close(),indexedDB.deleteDatabase(h),void o(!1);var T=function(j){return new Promise(function(L,Y){var X=performance.now(),B=0,x=function(){if(B!==15){var D=v.transaction("s","readwrite",{durability:j});D.objectStore("s").put(m,B),B++,D.oncomplete=x,D.onerror=D.onabort=function(){return Y(D.error)}}else L(performance.now()-X)};x()})};$(f,void 0,void 0,function(){var j,L,Y,X,B;return Q(this,function(x){switch(x.label){case 0:return j=performance.now(),[4,T("relaxed")];case 1:return x.sent(),[4,T("strict")];case 2:x.sent(),L=[],Y=0,x.label=3;case 3:return Y<15?[4,T("relaxed")]:[3,7];case 4:return X=x.sent(),[4,T("strict")];case 5:if(B=x.sent(),L.push(X>0?B/X:1/0),L.length>=7&&performance.now()-j>=1e3)return[3,7];x.label=6;case 6:return Y++,[3,3];case 7:return L.sort(function(D,Or){return D-Or}),v.close(),indexedDB.deleteDatabase(h),o(L[L.length>>1]<1.3),[2]}})}).catch(function(){v.close(),indexedDB.deleteDatabase(h),o(!1)})}})(),[3,6]);case 3:return s()!==25?[3,5]:(r="Firefox",[4,p()]);case 4:return d.sent(),[3,6];case 5:navigator.msSaveBlob!==void 0?(r="Internet Explorer",o(window.indexedDB===void 0)):t(new Error("detectIncognito cannot determine the browser")),d.label=6;case 6:return[2]}var u})})})().catch(t)})];case 1:return[2,n.sent()]}})})}var oi=Qt,Gt=et.A,to=et.k;async function Wt(n){return(await Gt()).isPrivate}var si=300,te=6e3,zt="cbo_pm",ai=10080*60*1e3,jt="detectincognitojs@1.9.0",Yt={timing:!1},tt="cbo_tab_id",Xt={bluetoothAvailable:"bt",clientCapabilities:"cc",userVerifyingPlatformAuthenticatorAvailable:"uvpaa",conditionalMediationAvailable:"cm",javaScriptHighEntropy:"he",privateMode:"pm",webdriver:"wd",maxTouchPoints:"mtp"};function O(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Jt(n,e,t){return{field:n,source:e,error:{name:"TimeoutError",message:`Device info collection timed out after ${t}ms`}}}async function rt(n,e){let t;try{return await Promise.race([n.then(()=>!0,()=>!0),new Promise(r=>{t=setTimeout(()=>r(!1),Math.max(0,e))})])}finally{t&&clearTimeout(t)}}var fe=class{constructor(e,t,r="localstorage",i,o=()=>Yt,s,a=!0){this.logger=e;this.storage=t;this.storageSource=r;this.sessionStorage=i;this.settings=o;this.emitTelemetry=s;this.privateModeEnabled=a}pagePrivateMode;privateModeDetectionStarted=!1;lastKnown={};async collect(e,t={}){try{let r=this.resolveSettings(),i=O(),o=this.getClientEnvHandle(),s={type:"web",clientEnvHandle:o.value,clientEnvHandleMeta:{timestamp:o.timestamp,source:o.source},tabId:this.getTabId()},a=typeof __CBO_DATA_PRIVATE_MODE__=="boolean"?__CBO_DATA_PRIVATE_MODE__:this.privateModeEnabled,l=a?this.knownPrivateMode(r.timing):void 0,p,d=a&&l===void 0&&!this.privateModeDetectionStarted?this.detectPrivateMode(r.timing).then(T=>{p=T}):void 0,u=this.startFastFields();await rt(Promise.all(u.map(T=>T.promise)),si);let f=O()-i,h=t.refresh?this.lastKnown:{};r.timing&&this.reportFastTiming(f,u);let m=()=>p?.error?[p.error]:[];this.safePublish(e,this.buildInfo(s,u,p?p.value:l,h,m()),"fast");let c=u.filter(T=>!T.settled),v=d!==void 0&&p===void 0;if(c.length===0&&!v)return;let y=O();await Promise.all([rt(Promise.all(c.map(T=>T.promise)),te-(y-i)),d]);let w=c.filter(T=>!T.settled).map(T=>Jt(T.field,T.source,te));w.push(...m()),r.timing&&c.length>0&&this.reportLateTiming(O()-i,c),this.safePublish(e,this.buildInfo(s,u,p?p.value:l,h,w),"update")}catch(r){this.logger.error("Failed to collect device info",r)}}async getInfo(){let e;return await this.collect(t=>{e=t}),e??{}}startFastFields(){return[this.startField("bluetoothAvailable","navigator.bluetooth.getAvailability",()=>Bt({key:"browser-api:device.bluetooth-availability",fields:[{path:"result",exposure:"enum",transform:{values:[!0,!1]}}]})),this.startField("clientCapabilities","PublicKeyCredential.getClientCapabilities",()=>qt({key:"browser-api:device.client-capabilities",fields:[{path:"result.<capability>",exposure:"enum",transform:{values:["true","false"],note:"open set of capability names, kept as reported"}}]})),this.startField("userVerifyingPlatformAuthenticatorAvailable","PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable",()=>Nt({key:"browser-api:device.uvpaa",fields:[{path:"result",exposure:"enum",transform:{values:[!0,!1]}}]})),this.startField("conditionalMediationAvailable","PublicKeyCredential.isConditionalMediationAvailable",()=>Ut({key:"browser-api:device.conditional-mediation",fields:[{path:"result",exposure:"enum",transform:{values:[!0,!1]}}]})),this.startField("javaScriptHighEntropy","navigator.userAgentData.getHighEntropyValues",()=>Kt({key:"browser-api:device.ua-high-entropy",fields:[{path:"result.platform",exposure:"raw"},{path:"result.mobile",exposure:"enum",transform:{values:[!0,!1]}},{path:"result.platformVersion",exposure:"raw"},{path:"result.model",exposure:"raw"}]})),this.startField("webdriver","navigator.webdriver",()=>Vt({key:"browser-api:device.webdriver",fields:[{path:"result",exposure:"enum",transform:{values:[!0,!1]}}]})),this.startField("maxTouchPoints","navigator.maxTouchPoints",()=>$t({key:"browser-api:device.max-touch-points",fields:[{path:"result",exposure:"raw"}]}))]}startField(e,t,r){let i=O(),o={field:e,source:t};return o.promise=Promise.resolve().then(r).then(s=>({field:e,value:s,durationMs:O()-i}),s=>(this.logger.error(`Failed to collect device info field "${e}"`,s),{field:e,durationMs:O()-i,error:{field:e,source:t,error:N(s)??{message:"Unknown error"}}})).then(s=>(o.settled=s,s)),o}buildInfo(e,t,r,i,o){let s={},a=[];for(let p of t)p.settled?(p.settled.error&&a.push(p.settled.error),s[p.field]=p.settled.value,this.remember(p.field,p.settled.value)):s[p.field]=i[p.field];s.privateMode=r,a.push(...o);let l={...e,data:{bluetoothAvailable:s.bluetoothAvailable,javaScriptHighEntropy:s.javaScriptHighEntropy,privateMode:s.privateMode,webdriver:s.webdriver,conditionalMediationAvailable:s.conditionalMediationAvailable,userVerifyingPlatformAuthenticatorAvailable:s.userVerifyingPlatformAuthenticatorAvailable,clientCapabilities:s.clientCapabilities,maxTouchPoints:s.maxTouchPoints}};return a.length>0&&(l.collectionErrors=a),l}remember(e,t){t!==void 0&&(this.lastKnown[e]=t)}safePublish(e,t,r){try{e(t,r)}catch(i){this.logger.error("Failed to publish device info",i)}}knownPrivateMode(e){if(this.pagePrivateMode!==void 0)return this.pagePrivateMode;let t=this.readPrivateModeCache();return t&&(this.pagePrivateMode=t.value,e&&this.reportTelemetry(`device info privateMode from cache, age ${Math.round((Date.now()-t.ts)/1e3)}s`)),this.pagePrivateMode}canCachePrivateMode(){return this.storageSource==="localstorage"}readPrivateModeCache(){if(this.canCachePrivateMode())try{let e=this.storage.getItem(zt);if(!e||typeof e!="object"||typeof e.value!="boolean"||typeof e.ts!="number"||e.dv!==jt)return;let t=Date.now()-e.ts;return t<0||t>=ai?void 0:e}catch(e){this.logger.debug("Failed to read cached privateMode",e);return}}writePrivateModeCache(e){if(this.canCachePrivateMode())try{this.storage.setItem(zt,{value:e,ts:Date.now(),dv:jt})}catch(t){this.logger.error("Failed to cache privateMode",t)}}async detectPrivateMode(e){this.privateModeDetectionStarted=!0;let t="detectIncognito",r=O(),i=this.startField("privateMode",t,()=>typeof __CBO_DATA_PRIVATE_MODE__=="boolean"&&!__CBO_DATA_PRIVATE_MODE__?void 0:Wt({key:"browser-api:device.private-mode",fields:[{path:"result.isPrivate",exposure:"enum",transform:{values:[!0,!1]}}],dataConfig:"privateMode"}));if(!await rt(i.promise,te)||!i.settled)return e&&this.reportTelemetry(`device info privateMode timed out after ${te}ms`),{error:Jt("privateMode",t,te)};if(e&&this.reportTelemetry(`device info privateMode detected in ${Math.round(O()-r)}ms`),i.settled.error)return{error:i.settled.error};let s=i.settled.value;return typeof s!="boolean"?{value:void 0}:(this.pagePrivateMode=s,this.writePrivateModeCache(s),{value:s})}resolveSettings(){try{return{timing:this.settings()?.timing===!0}}catch(e){return this.logger.error("Failed to resolve device info collector settings",e),Yt}}reportFastTiming(e,t){let r=t.map(i=>`${Xt[i.field]}=${Math.round(i.settled?.durationMs??e)}`).join(",");this.reportTelemetry(`device info collected in ${Math.round(e)}ms (${r})`)}reportLateTiming(e,t){let r=t.map(i=>`${Xt[i.field]}=${i.settled?Math.round(i.settled.durationMs):"timeout"}`).join(",");this.reportTelemetry(`device info late fields done in ${Math.round(e)}ms (${r})`)}reportTelemetry(e){if(this.emitTelemetry)try{this.emitTelemetry("info",e)}catch(t){this.logger.error("Failed to report device info timing",t)}}static getOsAndBrowserInfo(){return{osName:this.getOsName(),browserName:this.getBrowserName()}}static getUserAgent(){return Ht({key:"browser-api:device.user-agent",fields:[{path:"result",exposure:"class",transform:{classes:["iOS","Android","Windows","macOS","Linux","ChromeOS","Chrome","Firefox","Safari","Edge","Opera","IE","other"]}}]})}static getOsName(){let e=this.getUserAgent();return e.includes("iOS")?"iOS":e.includes("Android")?"Android":e.includes("Windows")?"Windows":e.includes("Macintosh")?"macOS":e.includes("Linux")?"Linux":e.includes("ChromeOS")?"ChromeOS":"other"}static getBrowserName(){let e=this.getUserAgent();return e.includes("Chrome")?"Chrome":e.includes("Firefox")?"Firefox":e.includes("Safari")?"Safari":e.includes("Edge")?"Edge":e.includes("Opera")?"Opera":e.includes("IE")?"IE":"other"}getClientEnvHandle(){let e=this.storage.getItem("cbo_client_env_handle");if(e)return e;let t=b(),r={timestamp:Date.now(),source:this.storageSource,value:t};return this.storage.setItem("cbo_client_env_handle",r),r}getTabId(){if(!this.sessionStorage)return;let e=this.sessionStorage.getItem(tt);if(e)return e;let t=b();if(this.sessionStorage.setItem(tt,t),this.sessionStorage.getItem(tt)===t)return t}};function li(){return typeof document<"u"&&document.visibilityState==="hidden"}var he=class{constructor(e,t,r,i,o,s){this.logger=e;this.source=t;this.refreshInterval=r;this.attachInterval=i;this.diagnostics=o;this.onUndelivered=s}snapshot;snapshotPhase;publishedAt=0;version=0;deliveredVersion=0;refreshedAt=0;lastAttachedAt=null;eventsSeen=!1;refreshPromise;timer;destroyed=!1;start(){this.refresh()}getForEvent(){if(this.eventsSeen=!0,Date.now()-this.refreshedAt>=this.refreshInterval&&this.refresh(),!!this.snapshot){if(this.version!==this.deliveredVersion)return this.markDelivered("event");if(!(this.lastAttachedAt!==null&&Date.now()-this.lastAttachedAt<this.attachInterval))return this.lastAttachedAt=Date.now(),this.snapshot}}hasUndelivered(){return this.snapshot!==void 0&&this.version!==this.deliveredVersion}takeUndelivered(){if(this.hasUndelivered())return this.markDelivered("flush")}hasStandalone(){return this.eventsSeen&&this.hasUndelivered()}takeStandalone(){if(this.hasStandalone())return this.markDelivered("request")}destroy(){this.destroyed=!0,this.timer&&(clearTimeout(this.timer),this.timer=void 0)}markDelivered(e){return this.deliveredVersion=this.version,this.lastAttachedAt=Date.now(),this.snapshotPhase==="update"&&this.report(`device info update delivered via ${e} after ${Math.max(0,Date.now()-this.publishedAt)}ms`),this.snapshot}publish(e,t){if(t==="fast"&&(this.refreshedAt=Date.now()),!(this.snapshot&&JSON.stringify(this.snapshot)===JSON.stringify(e))&&(this.snapshot=e,this.snapshotPhase=t,this.publishedAt=Date.now(),this.version++,this.eventsSeen&&this.onUndelivered))try{this.onUndelivered()}catch(r){this.logger.error("Failed to announce undelivered device info",r)}}report(e){if(this.diagnostics)try{this.diagnostics.timing()&&this.diagnostics.emit("info",e)}catch(t){this.logger.error("Failed to report device info delivery",t)}}scheduleRefresh(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.refresh()},this.refreshInterval)}refresh(){if(this.refreshPromise)return this.refreshPromise;if(this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.snapshot&&li())return this.destroyed||this.scheduleRefresh(),Promise.resolve();let e=this.snapshot!==void 0;return this.refreshPromise=Promise.resolve().then(()=>this.source.collect((t,r)=>this.publish(t,r),{refresh:e})).catch(t=>this.logger.error("Failed to refresh device info",t)).finally(()=>{this.refreshPromise=void 0,this.destroyed||this.scheduleRefresh()}),this.refreshPromise}};function P(n,e){return`${n}_${e}`}var ge=class{constructor(e,t){this.engine=e;this.namespace=t}getItem(e){return this.engine.getItem(P(e,this.namespace))}setItem(e,t){this.engine.setItem(P(e,this.namespace),t)}removeItem(e){this.engine.removeItem(P(e,this.namespace))}},me=class{constructor(e){this.logger=e}getItem(e){try{if(typeof localStorage>"u")return null;let t=localStorage.getItem(e);return t?JSON.parse(t):null}catch(t){return this.logger.error(`LocalStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof localStorage>"u")return;localStorage.setItem(e,JSON.stringify(t))}catch(r){this.logger.error(`LocalStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`localStorage.setItem failed: ${e}`)}}removeItem(e){try{if(typeof localStorage>"u")return;localStorage.removeItem(e)}catch(t){this.logger.error(`LocalStorage.removeItem failed for key "${e}"`,t)}}},ye=class{constructor(e,t){this.logger=e;this.domain=t}getItem(e){try{if(typeof document>"u")return null;let t=e+"=",r=document.cookie.split(";");for(let i=0;i<r.length;i++){let o=r[i].trim();if(o.indexOf(t)===0){let s=o.substring(t.length);return JSON.parse(decodeURIComponent(s))}}return null}catch(t){return this.logger.error(`CookieStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof document>"u")return;let r=`${e}=${encodeURIComponent(JSON.stringify(t))}; path=/; SameSite=Lax`;this.domain&&(r+=`; domain=${this.domain}`),document.cookie=r}catch(r){this.logger.error(`CookieStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`cookie.setItem failed: ${e}`)}}removeItem(e){try{if(typeof document>"u")return;let t=`${e}=; Max-Age=-99999999; path=/`;this.domain&&(t+=`; domain=${this.domain}`),document.cookie=t}catch(t){this.logger.error(`CookieStorage.removeItem failed for key "${e}"`,t)}}},ve=class{constructor(e){this.logger=e}getItem(e){try{if(typeof sessionStorage>"u")return null;let t=sessionStorage.getItem(e);return t?JSON.parse(t):null}catch(t){return this.logger.error(`SessionStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof sessionStorage>"u")return;sessionStorage.setItem(e,JSON.stringify(t))}catch(r){this.logger.error(`SessionStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`sessionStorage.setItem failed: ${e}`)}}removeItem(e){try{if(typeof sessionStorage>"u")return;sessionStorage.removeItem(e)}catch(t){this.logger.error(`SessionStorage.removeItem failed for key "${e}"`,t)}}};var be=1,Se="cbo_storage_schema",di=["cbo_seq","cbo_sdk_config","cbo_experiments","cbo_client_env_handle","cbo_outbox","cbo_visibility_change_debug","cbo_pagehide_debug","cbo_session"],pi=["cbo_session_id","cbo_tab_id"],ui=["cbo_client_env_handle"];function we(n,e,t){return n.setItem(e,t),JSON.stringify(n.getItem(e))===JSON.stringify(t)}function it(n,e,t){let r=n.getItem(Se);if(r!==null){if(r.version!==be||r.projectId!==e)return!1;if(r.complete===!0)return!0;if(r.complete!==!1)return!1}else{if(t.some(i=>n.getItem(P(i,e))!==null))return we(n,Se,{version:be,projectId:e,complete:!0});if(!we(n,Se,{version:be,projectId:e,complete:!1}))return!1}for(let i of t){let o=P(i,e);if(n.getItem(o)!==null)continue;let s=n.getItem(i);if(s!==null&&!we(n,o,s))return!1}return we(n,Se,{version:be,projectId:e,complete:!0})}function Zt(n,e,t,r,i){try{if(!it(e,n,di))return;it(t,n,pi),r&&it(r,n,ui)}catch(o){i.error("Failed to migrate legacy Observe storage",o)}}var ci=10*1e3,fi=600*1e3,hi=[1e3,3e3],Te=class{constructor(e,t,r){this.url=e;this.storage=t;this.logger=r;this.initialConfig=Rt(t)??void 0}initialConfig;refreshTimer;requestTimer;retryTimer;controller;fetching=!1;stopped=!1;onConfig;start(e){this.stopped||this.onConfig||(this.onConfig=e,this.fetchConfig())}async fetchConfig(e=0){if(this.stopped||this.fetching)return;e===0&&(clearTimeout(this.refreshTimer),clearTimeout(this.retryTimer),this.refreshTimer=setTimeout(()=>{this.fetchConfig()},fi)),this.fetching=!0;let t=typeof AbortController<"u"?new AbortController:void 0;this.controller=t,this.requestTimer=t?setTimeout(()=>t.abort(),ci):void 0;let r=!0;try{let i=await fetch(this.url,{method:"GET",cache:"no-store",...t?{signal:t.signal}:{}});if(!i.ok)throw r=(i.status===408||i.status===429||i.status>=500)&&!i.headers.has("Retry-After"),new Error(`SDK config request failed (${i.status})`);let o=await i.json();r=!1;let s=ee(o);if(!s)throw new Error("Invalid SDK config response");if(this.stopped||t?.signal.aborted)return;Dt(this.storage,s),this.onConfig?.(s)}catch(i){if(!this.stopped){this.logger.error("Failed to fetch SDK config",i);let o=hi[e];(r&&!(i instanceof SyntaxError)||t?.signal.aborted)&&o!==void 0&&(this.retryTimer=setTimeout(()=>{this.fetchConfig(e+1)},o))}}finally{clearTimeout(this.requestTimer),this.requestTimer=void 0,this.controller=void 0,this.fetching=!1}}destroy(){this.stopped=!0,clearTimeout(this.refreshTimer),clearTimeout(this.requestTimer),clearTimeout(this.retryTimer),this.controller?.abort(),this.onConfig=void 0}};var G=class{constructor(e,t){this.logger=e;this.sink=t}lease;destroyed=!1;arm(e,t=!1){if(this.disarm(),!(this.destroyed||t))try{this.lease=this.sink.beginCeremony?.(e)}catch(r){this.logger.error("Failed to register ceremony low-event context",r)}}scheduleDisarm(e){try{this.lease?.settle(e)}catch(t){this.logger.error("Failed to settle ceremony low-event context",t)}}disarm(){try{this.lease?.destroy()}catch(e){this.logger.error("Failed to release ceremony low-event context",e)}this.lease=void 0}destroy(){this.disarm(),this.destroyed=!0}};var Ee=class extends g{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-login"),this.lowEventTracker=new G(e.getLogger(),this.lowEventSink("ceremony")),this.registerLowFlusher(()=>this.lowEventTracker.disarm()),this.getOptions=this.defineStep("get-options"),this.ceremony=this.withWindowLowEvents(this.defineStep("ceremony"),this.lowEventTracker),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType})}trigger(e,t){super.trigger(e,t)}destroy(){this.lowEventTracker.destroy()}};var W=class{constructor(e,t,r,i){this.previousLength=e;this.pushLow=t;this.logger=r;this.reserveCaptureSeq=i}prefillSettled=!1;inputBatch=null;currentEffect="modify";ringEffect="modify";autofillTimestamps=[];autofillStreak=null;idleTimer=null;markInputObserved(){this.prefillSettled=!0}capturePrefill(e,t=!1){t&&(this.prefillSettled=!1),!this.prefillSettled&&(this.previousLength=e,e!==0&&(this.prefillSettled=!0,this.pushLow({lowType:"input-prefill",ts:Date.now(),initiator:"unknown"})))}flush(){this.cancelIdle(),this.flushInputBatch(),this.flushAutofillStreak()}cancelIdle(){this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=null}scheduleIdle(){this.cancelIdle(),this.idleTimer=setTimeout(()=>{this.idleTimer=null;try{this.flushInputBatch(!0),this.flushAutofillStreak()}catch(e){this.logger.error("Failed to flush idle input",e)}},3e3)}extendInputBatch(e,t=this.currentEffect,r){let i=this.inputBatch;if(!i){this.inputBatch={firstTimestamp:e,lastTimestamp:e,effect:t,captureSeq:r};return}i.lastTimestamp=e}drainAutofillRingToBatch(){for(let e of this.autofillTimestamps)this.extendInputBatch(e.ts,this.ringEffect,e.captureSeq);this.autofillTimestamps.length=0}flushInputBatch(e=!1){this.drainAutofillRingToBatch();let t=this.inputBatch;t&&(this.pushLow({...t.captureSeq===void 0?{}:{captureSeq:t.captureSeq},lowType:e?"input-idle":"input",ts:t.firstTimestamp,durationMs:t.lastTimestamp-t.firstTimestamp,inputEffect:t.effect}),this.inputBatch=null)}flushAutofillStreak(){let e=this.autofillStreak;e&&(this.pushLow({...e.captureSeq===void 0?{}:{captureSeq:e.captureSeq},lowType:"big-input-add",ts:e.firstTimestamp,durationMs:e.lastTimestamp-e.firstTimestamp,inputEffect:e.effect}),this.autofillStreak=null)}detectAutofillStreak(){let e=this.autofillTimestamps;if(e.length<5)return!1;let t=1/0,r=-1/0;for(let i=1;i<e.length;i++){let o=e[i].ts-e[i-1].ts;if(o>80)return!1;o<t&&(t=o),o>r&&(r=o)}return r-t<=25}record(e,t=Date.now(),r=!1,i=this.reserveCaptureSeq?.()){this.markInputObserved(),this.scheduleIdle();let o=this.previousLength;this.currentEffect=e===0?"clear":o===0?"fill":"modify";let s=e-o;if(this.previousLength=e,e===0&&o>0){this.flush(),this.pushLow({...i===void 0?{}:{captureSeq:i},lowType:"input-clear",ts:t,inputEffect:"clear"});return}if(r){this.flushAutofillStreak(),this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect,i);return}if(s>=3){this.flushInputBatch(),this.flushAutofillStreak(),this.pushLow({...i===void 0?{}:{captureSeq:i},lowType:"big-input-add",ts:t,inputEffect:this.currentEffect});return}if(s<=-3){this.flushInputBatch(),this.flushAutofillStreak(),this.pushLow({...i===void 0?{}:{captureSeq:i},lowType:"big-input-rem",ts:t,inputEffect:this.currentEffect});return}let a=this.autofillStreak;if(a){if(s===1&&t-a.lastTimestamp<=80){a.lastTimestamp=t;return}this.flushAutofillStreak()}if(s!==1){this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect,i);return}let l=this.autofillTimestamps;if(l.length===0&&(this.ringEffect=this.currentEffect),l.push({ts:t,captureSeq:i}),l.length>5){let u=l.shift();this.extendInputBatch(u.ts,this.ringEffect,u.captureSeq),this.ringEffect="modify"}if(!this.detectAutofillStreak())return;let p=l[0],d=l[l.length-1];l.length=0,this.flushInputBatch(),this.autofillStreak={firstTimestamp:p.ts,captureSeq:p.captureSeq,lastTimestamp:d.ts,effect:this.ringEffect}}};var z=class{constructor(e,t,r,i){this.inputs=e;this.logger=t;this.changed=r;this.reserveCaptureSeq=i;for(let o of e)o.addEventListener("paste",this.onPaste,!0),o.addEventListener("beforeinput",this.onBeforeInput,!0)}before=null;timestamp=0;captureSeq;pasteEvent;timer=null;onPaste=e=>this.begin(e);onBeforeInput=e=>{e.inputType==="insertFromPaste"?this.begin(e):this.flush()};handlesInput(e){if(!this.before)return!1;let t=this.pasteEvent?.type==="paste"&&(this.pasteEvent.eventPhase??0)>0;return e.inputType==="insertFromPaste"||t?!0:(this.clear(),!1)}get pending(){return this.before!==null}begin(e){if(!(!e.isTrusted||this.before))try{this.before=this.inputs.map(t=>t.value),this.pasteEvent=e,this.timestamp=Date.now(),this.captureSeq=this.reserveCaptureSeq?.(),this.timer=setTimeout(()=>this.flush(),0)}catch(t){this.logger.error("Failed to observe paste",t),this.clear()}}flush(){let e=this.before;if(!e)return;let t=this.timestamp,r=this.captureSeq;this.clear();try{let i=0,o=!1;this.inputs.forEach((s,a)=>{let l=e[a],p=s.value;if(l===p)return;o=!0;let d=0;for(;d<l.length&&d<p.length&&l[d]===p[d];)d++;let u=0;for(;u<l.length-d&&u<p.length-d&&l[l.length-u-1]===p[p.length-u-1];)u++;i+=p.length-d-u}),o&&this.changed(t,i,r)}catch(i){this.logger.error("Failed to finish paste observation",i)}}clear(){this.timer!==null&&clearTimeout(this.timer),this.timer=null,this.before=null,this.pasteEvent=void 0}destroy(){this.flush();for(let e of this.inputs)e.removeEventListener("paste",this.onPaste,!0),e.removeEventListener("beforeinput",this.onBeforeInput,!0)}};var gi=[{query:"com-1password-button",eventType:"pa-1"},{query:"com-1password-menu",eventType:"pa-2"},{query:"com-1password-notification",eventType:"pa-3"}],mi="[data-lastpass-root], [data-lp], [data-lpignore], [data-lpfieldtype]",er="pa-4",yi='[popover="manual"]',vi=400,bi=20,nt="pa-5",ot="pa-6",st=(n,e)=>{try{return Array.from(n.querySelectorAll(e))}catch{return[]}},tr=n=>{if(n.getAttribute("popover")!=="manual")return!1;let e=n.getAttribute("style")??"";return!(e.length<vi||!/z-index:\s*2147483647\b/i.test(e)||!/position:\s*fixed\b/i.test(e)||!/display:\s*block\b/i.test(e)||(e.match(/initial\s*!important/gi)?.length??0)<bi)},Si=n=>{if(tr(n)||n.getAttribute("popover")!=="manual")return!1;let e=n.getAttribute("style")??"";return!(!/z-index:\s*2147483647\b/i.test(e)||!/position:\s*fixed\b/i.test(e)||!/backdrop-filter:\s*[^;]*blur\(\s*20px\s*\)/i.test(e)||!/background-color:\s*rgba\(\s*35\s*,\s*35\s*,\s*35\s*,/i.test(e))},wi=n=>{n(document);for(let e of Array.from(document.querySelectorAll("*"))){let t=e.shadowRoot;t&&n(t)}},Ti=()=>{let n=new Set;return typeof document>"u"||wi(e=>{for(let t of gi)n.has(t.eventType)||st(e,t.query).length>0&&n.add(t.eventType);if(!n.has(er)&&st(e,mi).length>0&&n.add(er),!n.has(nt)||!n.has(ot))for(let t of st(e,yi)){if(!n.has(nt)&&tr(t)){n.add(nt);continue}!n.has(ot)&&Si(t)&&n.add(ot)}}),n};function rr(n){return Ti()}var Ei=500,Ii=250;function re(n){return n.type==="checkbox"||n.type==="radio"?n.checked?1:0:n.value.length}var k=class{constructor(e,t,r){this.logger=e;this.inputField=t;this.sink=r;this.changes=new W(re(t),this.pushLow,e,r.reserveCaptureSeq),this.pasteObserver=new z([t],e,(i,o,s)=>{this.changes.flush(),this.changes.markInputObserved();let a=this.changes.previousLength;this.changes.previousLength=re(t),this.pushLow({...s===void 0?{}:{captureSeq:s},lowType:"input-paste",ts:i,inputEffect:re(t)===0?"clear":a===0?"fill":"modify"})},r.reserveCaptureSeq),this.boundHandlers={focus:this.wrapHandler("focus",()=>this.handleFocus()),blur:this.wrapHandler("blur",()=>this.handleBlur()),pointerdown:this.wrapHandler("pointerdown",()=>this.enqueueNonInputEvent("pointerdown")),pointerup:this.wrapHandler("pointerup",()=>this.enqueueNonInputEvent("pointerup")),click:this.wrapHandler("click",()=>this.enqueueNonInputEvent("click")),input:i=>{try{this.handleInput(i)}catch(o){this.logger.error("Failed to observe input",o)}},keyup:this.wrapKeyboardHandler("keyup",i=>this.handleKeyUp(i)),pageHide:this.wrapHandler("pagehide",()=>this.flushForTeardown())},this.unregisterInputs=r.registerInputs?.([t],()=>this.flushPending()),this.capturePrefill(),this.attach()}unregisterInputs;changes;pasteObserver;emittedSignals=new Set;firstFocusHandled=!1;mountProbeTimer=null;focusProbeTimer=null;destroyed=!1;boundHandlers;destroy(){if(!this.destroyed){this.destroyed=!0;try{this.mountProbeTimer!==null&&(clearTimeout(this.mountProbeTimer),this.mountProbeTimer=null),this.focusProbeTimer!==null&&(clearTimeout(this.focusProbeTimer),this.focusProbeTimer=null),this.changes.flush(),this.unregisterInputs?.(),this.pasteObserver.destroy(),this.detach()}catch(e){this.logger.error("Failed to destroy LowEventInputTracker",e)}}}attach(){let e=this.inputField;e.addEventListener("focus",this.boundHandlers.focus),e.addEventListener("blur",this.boundHandlers.blur),e.addEventListener("pointerdown",this.boundHandlers.pointerdown),e.addEventListener("pointerup",this.boundHandlers.pointerup),e.addEventListener("click",this.boundHandlers.click),e.addEventListener("input",this.boundHandlers.input),e.addEventListener("keyup",this.boundHandlers.keyup),typeof window<"u"&&window.addEventListener("pagehide",this.boundHandlers.pageHide),typeof document<"u"&&document.activeElement===e&&this.handleFocus(),typeof window<"u"&&(this.mountProbeTimer=setTimeout(()=>this.runEnvProbe(),Ei))}detach(){let e=this.inputField;e.removeEventListener("focus",this.boundHandlers.focus),e.removeEventListener("blur",this.boundHandlers.blur),e.removeEventListener("pointerdown",this.boundHandlers.pointerdown),e.removeEventListener("pointerup",this.boundHandlers.pointerup),e.removeEventListener("click",this.boundHandlers.click),e.removeEventListener("input",this.boundHandlers.input),e.removeEventListener("keyup",this.boundHandlers.keyup),typeof window<"u"&&window.removeEventListener("pagehide",this.boundHandlers.pageHide)}pushLow=e=>{this.sink.enqueueLowEvent(e)};runEnvProbe(){try{if(typeof __CBO_DATA_PMD__=="boolean"?__CBO_DATA_PMD__:this.sink.passwordManagerDomScan?.()!==!1){let e=rr({key:"dom:password-managers.dom-signals",fields:[{path:"signals[]",exposure:"enum",transform:{values:["pa-1","pa-2","pa-3","pa-4","pa-5","pa-6"]}}],dataConfig:"pmd"}),t=Date.now();for(let r of e)this.emittedSignals.has(r)||(this.emittedSignals.add(r),this.pushLow({lowType:r,ts:t}))}}catch(e){this.logger.error("Failed to run input env probe",e)}}scheduleFocusProbe(){this.firstFocusHandled||(this.firstFocusHandled=!0,this.focusProbeTimer=setTimeout(()=>this.runEnvProbe(),Ii))}capturePrefill(e=!1){this.destroyed||(this.flushPending(),this.changes.capturePrefill(re(this.inputField),e))}flushPending(){this.pasteObserver.flush(),this.changes.flush()}enqueueNonInputEvent(e){this.changes.flush(),this.pushLow({lowType:e,ts:Date.now()})}handleFocus(){this.scheduleFocusProbe(),this.enqueueNonInputEvent("focus")}handleBlur(){this.pasteObserver.flush(),this.enqueueNonInputEvent("blur")}handleInput(e){this.pasteObserver.handlesInput(e)||this.changes.record(re(this.inputField),Date.now(),e.isComposing||e.inputType==="insertCompositionText")}handleKeyUp(e){e.key==="Escape"&&this.enqueueNonInputEvent("keyup-escape")}flushForTeardown(){this.pasteObserver.flush(),this.changes.flush(),this.sink.flushKeepalive()}wrapHandler(e,t){return()=>{try{t()}catch(r){this.logger.error(`Failed to handle low event "${e}"`,r)}}}wrapKeyboardHandler(e,t){return r=>{try{t(r)}catch(i){this.logger.error(`Failed to handle low event "${e}"`,i)}}}};var Ie=class{constructor(e,t,r){this.logger=e;this.sink=r;this.inputs=[...new Set(t)],this.changes=new W(this.length(),i=>r.enqueueLowEvent(i),e,r.reserveCaptureSeq),this.paste=new z(this.inputs,e,(i,o,s)=>{this.cancelChange(),this.changes.flush(),this.changes.markInputObserved();let a=this.changes.previousLength;this.changes.previousLength=this.length(),r.enqueueLowEvent({...s===void 0?{}:{captureSeq:s},lowType:"input-paste",ts:i,inputEffect:this.length()===0?"clear":a===0?"fill":"modify"})},r.reserveCaptureSeq),this.unregisterInputs=r.registerInputs?.(this.inputs,()=>this.flushPending()),this.capturePrefill();for(let i of this.inputs){this.listen(i,"input",o=>{this.paste.handlesInput(o)||(this.composing||=o.isComposing||o.inputType==="insertCompositionText",this.changeTimer===null&&(this.changeTime=Date.now(),this.changeSeq=r.reserveCaptureSeq?.(),this.changeTimer=setTimeout(()=>this.safe(()=>this.flushChanges()),0)))}),this.listen(i,"focus",o=>{this.contains(o.relatedTarget)||this.emit("focus")}),this.listen(i,"blur",o=>{this.contains(o.relatedTarget)||(this.flushPending(),this.emit("blur"))});for(let o of["click","pointerdown","pointerup"])this.listen(i,o,()=>this.emit(o));this.listen(i,"keyup",o=>{o.key==="Escape"&&this.emit("keyup-escape")})}typeof window<"u"&&this.listen(window,"pagehide",()=>{this.flushPending(),r.flushKeepalive()}),typeof document<"u"&&this.contains(document.activeElement)&&this.emit("focus")}inputs;changes;paste;unregisterInputs;listeners=[];changeTimer=null;changeTime=0;changeSeq;composing=!1;destroyed=!1;contains(e){return this.inputs.some(t=>t===e)}length(){return this.inputs.reduce((e,t)=>e+t.value.length,0)}safe(e){try{e()}catch(t){this.logger.error("Failed to observe grouped input",t)}}listen(e,t,r){let i=o=>this.safe(()=>r(o));e.addEventListener(t,i),this.listeners.push(()=>e.removeEventListener(t,i))}cancelChange(){this.changeTimer!==null&&clearTimeout(this.changeTimer),this.changeTimer=null}flushChanges(){this.changeTimer!==null&&(this.cancelChange(),this.paste.pending||this.changes.record(this.length(),this.changeTime,this.composing,this.changeSeq),this.composing=!1)}emit(e){this.flushChanges(),this.changes.flush(),this.sink.enqueueLowEvent({lowType:e,ts:Date.now()})}capturePrefill(e=!1){this.destroyed||(this.flushPending(),this.changes.capturePrefill(this.length(),e))}flushPending(){this.paste.flush(),this.flushChanges(),this.changes.flush()}destroy(){this.destroyed||(this.destroyed=!0,this.safe(()=>{this.flushPending(),this.paste.destroy(),this.unregisterInputs?.();for(let e of this.listeners)e()}))}};var R=class{constructor(e,t,r){this.logger=e;this.inputSink=t;this.groupSink=r}collector;fields=[];grouped=!1;destroyed=!1;prefillClaimed=!1;setFields(e,t=!0){try{if(this.destroyed)return;let r=[...new Set(e)];if(t===this.grouped&&r.length===this.fields.length&&r.every((s,a)=>s===this.fields[a])||(this.collector?.destroy(),this.collector=void 0,this.fields=[],this.grouped=t,r.length===0))return;let i=t?this.groupSink:this.inputSink,o={...i,enqueueLowEvent:s=>this.enqueue(i,s)};this.collector=t?new Ie(this.logger,r,o):new k(this.logger,r[0],o),this.fields=r}catch(r){this.logger.error("Failed to bind OTP inputs",r)}}enqueue(e,t){if(t.lowType==="input-prefill"){if(this.prefillClaimed)return;this.prefillClaimed=!0}else["input","input-idle","input-clear","input-paste","big-input-paste","big-input-add","big-input-rem"].includes(t.lowType)&&(this.prefillClaimed=!0);e.enqueueLowEvent(t)}capturePrefill(e=!1){e&&(this.prefillClaimed=!1),this.collector?.capturePrefill(e)}flushPending(){this.collector?.flushPending()}destroy(){this.destroyed=!0,this.collector?.destroy(),this.collector=void 0,this.fields=[]}};var ke=class extends g{lowEventTracker;send;postResponse;resend;constructor(e,t={}){super(e,"email-otp"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.subflowStart({explicitSpecType:t.explicitSpecType,emailDomain:t.emailDomain}),this.lowEventTracker=this.createLowCollector(()=>new R(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var xe=class extends g{lowEventTracker;send;postResponse;resend;constructor(e,t={}){super(e,"sms-otp"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.subflowStart({explicitSpecType:t.explicitSpecType}),this.lowEventTracker=this.createLowCollector(()=>new R(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var ki=["ahrefsbot","ahrefssiteaudit","amazonbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","facebookexternal","petalbot","pinterest","screaming frog","yahoo! slurp","yandex","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google"];function ir(n){if(!n)return!1;let e=n.toLowerCase();return ki.some(t=>e.includes(t))}var nr="@corbado/observe",or="1.8.0";var at="cbo_email_link_starts";function lt(n,e){let t=n.getItem(at);return Array.isArray(t)?t.filter(r=>!!r&&typeof r=="object"&&typeof r.transactionId=="string"&&typeof r.anchor=="string"&&typeof r.sessionId=="string"&&typeof r.startedAt=="number"&&e-r.startedAt<864e5):[]}function sr(n,e){if(n)try{let t=lt(n,e.startedAt).filter(r=>r.transactionId!==e.transactionId);t.push(e),n.setItem(at,t.slice(-10))}catch{}}function ar(n,e,t=Date.now()){if(n)try{let r=lt(n,t);if(e.transactionId)return r.find(o=>o.transactionId===e.transactionId);let i=r.filter(o=>!o.continued&&(!e.specType||!o.specType||o.specType===e.specType));return i[i.length-1]}catch{return}}function lr(n,e){if(n)try{let t=lt(n,Date.now()).map(r=>r.transactionId===e?{...r,continued:!0}:r);n.setItem(at,t)}catch{}}var Ce=class extends g{send;postResponse;resend;transactionId;constructor(e,t={}){super(e,"email-link"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.transactionId=t.transactionId||b(),this.subflowStart({explicitSpecType:t.explicitSpecType},{userReference:{crossEnvironmentTransactionIDStart:this.transactionId}});let r=this.captureReference,i=this.captureSession;r&&i&&sr(e.getPersistentStorage(),{transactionId:this.transactionId,anchor:r,sessionId:i,specType:t.explicitSpecType,startedAt:Date.now()})}},Oe=class extends g{postResponse;resend;mode;continuationTracker;specType;createdAt=Date.now();transaction;started=!1;deferred=[];onPageHide=()=>this.flush();constructor(e,t={}){super(e,"email-link"),this.continuationTracker=e,this.specType=t.explicitSpecType,this.transaction=t.transactionId,this.postResponse=this.deferrable(this.defineStep("post-response"),!0),this.resend=this.deferrable(this.defineStep("resend"));let r=e.getPersistentStorage(),i=ar(r,{transactionId:t.transactionId,specType:t.explicitSpecType});if(i&&i.sessionId===e.getSessionId()){this.mode="attached",this.transaction=t.transactionId??i.transactionId,this.adoptCapture(i.anchor,i.sessionId,i.specType??t.explicitSpecType),this.started=!0;return}this.mode="detached",this.transaction?this.startDetached(this.createdAt):typeof window<"u"&&window.addEventListener("pagehide",this.onPageHide)}get transactionId(){return this.transaction}setTransactionId(e){!e||this.transaction||(this.transaction=e,this.mode==="detached"&&!this.started&&this.startDetached(this.firstDeferredAt()))}flush(){this.mode==="detached"&&!this.started&&this.startDetached(this.firstDeferredAt())}destroy(){this.flush(),this.removePageHideListener()}firstDeferredAt(){return this.deferred[0]?.at??this.createdAt}startDetached(e){this.started=!0,this.removePageHideListener(),this.subflowStart({explicitSpecType:this.specType,continuation:!0},{explicitTimestamp:e,...this.transaction?{userReference:{crossEnvironmentTransactionIDFinish:this.transaction}}:{}});let t=this.deferred;this.deferred=[];for(let r of t)r.run(r.at);try{this.continuationTracker.flushKeepalive()}catch{}}removePageHideListener(){typeof window<"u"&&window.removeEventListener("pagehide",this.onPageHide)}deferrable(e,t=!1){let r=(i,o)=>{if(this.started){i(o?.explicitTimestamp??Date.now());return}this.deferred.push({at:o?.explicitTimestamp??Date.now(),run:i})};return{start:(i,o)=>r(s=>e.start(i,{...o,explicitTimestamp:s}),o),finished:(i,o)=>{r(s=>e.finished(i,{...o,explicitTimestamp:s}),o),t&&this.transaction&&lr(this.continuationTracker.getPersistentStorage(),this.transaction)},error:(i,o)=>r(s=>e.error(i,{...o,explicitTimestamp:s}),o)}}};var Pe=class extends g{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-enrollment"),this.lowEventTracker=new G(e.getLogger(),this.lowEventSink("ceremony")),this.registerLowFlusher(()=>this.lowEventTracker.disarm()),this.getOptions=this.defineStep("get-options"),this.ceremony=this.withWindowLowEvents(this.defineStep("ceremony"),this.lowEventTracker),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType,...t?.ignoreAsInteraction?{ignoreAsInteraction:!0}:{}})}destroy(){this.lowEventTracker.destroy()}};function dr(n){let e=n.debug,t,r=(i,o)=>`[Corbado Observe SDK ${i}] ${o}`;return{reportTelemetry(i,o){if(t)try{t(i,o)}catch{}},setTelemetrySink(i){t=i},debug(i,...o){e&&console.log(r("DEBUG",i),...o)},info(i,...o){e&&console.log(r("INFO",i),...o)},warn(i,...o){e&&console.warn(r("WARN",i),...o)},error(i,...o){e&&console.error(r("ERROR",i),...o)},critical(i,...o){console.error(r("CRITICAL",i),...o)}}}var Le=class extends g{userConfirmation;deletion;constructor(e,t={}){super(e,"passkey-deletion"),this.userConfirmation=this.defineStep("user-confirmation"),this.deletion=this.defineStep("deletion"),this.subflowStart({})}};var Fe=class extends g{clientValidation;postResponse;cui;lowEventTracker;identifierLowEventTracker;constructor(e,t){super(e,"password-login"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response"),this.cui={getOptions:this.defineStep("cui-get-options",!0),ceremony:this.defineStep("cui-ceremony"),postResponse:this.defineStep("cui-post-response")},this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.identifierInputHtmlField&&(this.identifierLowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.identifierInputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.identifierLowEventTracker?.flushPending())),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","password"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}trigger(e,t){super.trigger(e,t)}destroy(){this.lowEventTracker?.destroy(),this.identifierLowEventTracker?.destroy()}};var Re=class extends g{clientValidation;postResponse;lowEventTracker;constructor(e,t){super(e,"password-enrollment"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","password"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var De=class extends g{lowEventTracker;cui;provideIdentifier;constructor(e,t){super(e,"provide-identifier"),this.cui={trigger:(r,i)=>{this.trigger(r,i)},getOptions:this.defineStep("cui-get-options",!0),ceremony:this.defineStep("cui-ceremony"),postResponse:this.defineStep("cui-post-response")},this.provideIdentifier={trigger:(r,i)=>{this.trigger(r,i)},clientValidation:this.defineStep("pi-client-validation"),postResponse:this.defineStep("pi-post-response")},this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var _e=class extends g{getRedirectUrl;exchangeCode;constructor(e,t={}){super(e,"social-login"),this.getRedirectUrl=this.defineStep("get-redirect-url"),this.exchangeCode=this.defineStep("exchange-code"),this.subflowStart({explicitSpecType:t.explicitSpecType,entry:t.entry})}};var Ae=class extends g{getRedirectUrl;exchangeCode;constructor(e,t={}){super(e,"sso-login"),this.getRedirectUrl=this.defineStep("get-redirect-url"),this.exchangeCode=this.defineStep("exchange-code");let{explicitSpecType:r,organizationDomain:i,actor:o}=xi(t??{},e);this.subflowStart({explicitSpecType:r,organizationDomain:i,actor:o})}};function xi(n,e){let t={...n},r=o=>{try{e.getLogger().warn(`SSO login: unsupported ${o}; omitted from telemetry`)}catch{}},i=t.organizationDomain;return i!==void 0&&(typeof i!="string"||i.includes("@")||i.length>253)&&(delete t.organizationDomain,r("organizationDomain")),t.actor!==void 0&&t.actor!=="user"&&t.actor!=="system"&&(delete t.actor,r("actor")),t}var Me=class extends g{lowEventTracker;postResponse;constructor(e,t={}){super(e,"totp"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType}),this.lowEventTracker=this.createLowCollector(()=>new R(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var He=class extends g{ceremony;retry;postResponse;constructor(e,t={}){super(e,"app-confirmation"),this.ceremony=this.defineStep("ceremony"),this.retry=this.defineStep("retry"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType})}};var Be=class extends g{ceremony;postResponse;constructor(e,t={}){super(e,"captcha"),this.ceremony=this.defineStep("ceremony"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType})}};var Ne=class{constructor(e,t){this.logger=e;this.sink=t}trackers=new Map;destroyed=!1;setFields(e){if(this.destroyed)return;let t=new Set(e);for(let[r,i]of this.trackers)t.has(r)||(this.safe(()=>i.destroy()),this.trackers.delete(r));for(let r of t)this.trackers.has(r)||this.safe(()=>this.trackers.set(r,new k(this.logger,r,this.sink())))}capturePrefill(e=!1){for(let t of this.trackers.values())this.safe(()=>t.capturePrefill(e))}flushPending(){for(let e of this.trackers.values())this.safe(()=>e.flushPending())}destroy(){if(!this.destroyed){this.destroyed=!0;for(let e of this.trackers.values())this.safe(()=>e.destroy());this.trackers.clear()}}safe(e){try{e()}catch(t){this.logger.error("Form input binding failed",t)}}};var dt=50,Ci=6e4,Oi=40,Pi=/^[A-Za-z0-9._-]+$/,Ue=class extends g{submit;skip;inputBinding;constructor(e,t){super(e,"form"),this.submit=this.defineStep("submit"),this.skip=this.defineStep("skip"),this.subflowStart(Fi(e,t),Li(e,t)),this.inputBinding=this.createLowCollector(()=>new Ne(e.getLogger(),()=>this.lowEventSink("input","data"))),this.registerLowFlusher(()=>this.inputBinding?.flushPending()),t?.inputHtmlFields?.length&&this.setInputFields(t.inputHtmlFields)}setInputFields(e){this.inputBinding?.setFields(e)}destroy(){this.inputBinding?.destroy()}};function Li(n,e){let t=e?.startedAt;if(t===void 0)return;let r=Date.now();if(typeof t!="number"||!Number.isFinite(t)||t>r||r-t>Ci){ie(n,"Form: implausible startedAt ignored; using the current time");return}return{explicitTimestamp:t}}function Fi(n,e){let t={},r=e?.name;typeof r=="string"&&r.trim()!==""?t.name=r:ie(n,"Form: missing name; the form will not be counted");let i=e?.fields;if(i===void 0)return t;if(!Array.isArray(i))return ie(n,"Form: fields must be an array of field names; omitted from telemetry"),t;let o=i.filter(s=>typeof s=="string"&&s.length<=Oi&&Pi.test(s));return o.length<i.length&&ie(n,"Form: unsupported field names omitted from telemetry"),o.length>dt&&ie(n,`Form: more than ${dt} field names; the rest is omitted from telemetry`),o.length>0&&(t.fields=o.slice(0,dt)),t}function ie(n,e){try{n.getLogger().warn(e)}catch{}}function pt(n,e,t){if(n===null||typeof n!="object")return n;try{let r={...n};r.purpose===void 0&&e.purpose!==void 0&&(r.purpose=e.purpose),r.storage===void 0&&e.storage!==void 0&&(r.storage=e.storage),r.trustName===void 0&&e.trustName!==void 0&&(r.trustName=e.trustName);for(let[i,o]of[["bindingReference",255],["trustName",128]])if(typeof r[i]=="string"&&[...r[i]].length>o){delete r[i];try{t.getLogger().debug(`Trusted device: omitted ${i} exceeding ${o} characters`)}catch{}}return r}catch{return n}}function qe(n,e,t){return{...n,start:(r,i)=>n.start(pt(r,e,t),i),finished:(r,i)=>n.finished(pt(r,e,t),i)}}var Ke=class extends g{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-check"),t=pr(t,e);let r={purpose:t.purpose,storage:t.storage,trustName:t.trustName};this.getOptions=this.checkStep("get-options",r,e),this.ceremony=this.checkStep("ceremony",r,e),this.postResponse=this.checkStep("post-response",r,e),this.subflowStart({explicitSpecType:t.explicitSpecType,actor:"system",ignoreAsInteraction:!0})}checkStep(e,t,r){let i=this.defineStep(e,!0);return{...qe(i,t,r),errorTyped:(o,s)=>{i.errorTyped(pt({code:o?.code,error:N(o?.error)},t,r),s)}}}},Ve=class extends g{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-enrollment"),t=pr(t,e);let r={purpose:t.purpose,storage:t.storage,trustName:t.trustName};this.getOptions=qe(this.defineStep("get-options"),r,e),this.ceremony=qe(this.defineStep("ceremony"),r,e),this.postResponse=qe(this.defineStep("post-response"),r,e),this.subflowStart({explicitSpecType:t.explicitSpecType})}};function pr(n,e){let t={...n},r=i=>{try{e.getLogger().warn(`Trusted device: missing or unsupported ${i}; omitted from telemetry`)}catch{}};return t.purpose!=="additional-verification"&&t.purpose!=="mfa-exemption"&&(delete t.purpose,r("purpose")),["cookie","indexeddb","localstore","sessionstore"].includes(t.storage)||(delete t.storage,r("storage")),t}var $e=class extends g{clientValidation;postResponse;lowEventTracker;constructor(e,t={}){super(e,"provide-data"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response");let{inputHtmlField:r,...i}=t;this.subflowStart(i),r&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),r,this.lowEventSink("input","data"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Ri="/inline/injected/webauthn-listeners.js",ur=/\/dashlane-(?:shadow-dom|top-layer)-page-script\.js/,Di=/-extension:\/\/[^/]+\/content-scripts\/passkey_proxy\/index\.js$/,_i=/-extension:\/\/[^/]+\/content_scripts\/shadow-dom\/shadowAttachNotifier\.js:/,cr=/-extension:\/\/[^/]+\/js\/nordpass-script\.js:/,Ai=/-extension:\/\/[^/]+\/js\/passkeys\.js:/,Mi=/["'`](?:keeper:shadow-root-attached|webauthn-(?:get|create)-request)["'`]/,Hi=/Intercept cancelled for `(?:get|create)`|["'`](?:conditionalMediationAvailable|verifyingPlatformAuthenticatorAvailable)["'`]/,ut=()=>Object.keys(window._sentryDebugIds??{}),ct=n=>{try{n()}catch(e){return String(e?.stack??"")}return""},fr=()=>ct(()=>Element.prototype.attachShadow.call(null,{mode:"open"})),Bi=()=>{let n=Object.getOwnPropertyDescriptor(navigator.credentials??{},"get");if(!n?.get||!n.set||n.configurable)return!1;let e=()=>{},t=n.get.call({_get:e});return t===e||typeof t=="function"&&t===n.get.call({})&&!Function.prototype.toString.call(t).includes("[native code]")},ft=(...n)=>{let e=navigator.credentials;return e?n.map(t=>Object.getOwnPropertyDescriptor(e,t)?.value):[]},Ni=()=>[navigator.credentials?.get,...ft("get","_get")].some(n=>typeof n=="function"&&n.name==="getWebAuthnCredential"),Ui=()=>{let n=document.documentElement,e=document.adoptedStyleSheets;if(!n||typeof n.getAnimations!="function"||typeof e?.push!="function"||n.getAnimations().length>0)return!1;let t=new CSSStyleSheet;t.replaceSync(":where(:root){animation:bitwardenfill 1s 1000s paused}"),e.push(t);try{let r=n.getAnimations().filter(i=>i.animationName==="bitwardenfill");return r.forEach(i=>i.cancel()),r.length>0}finally{let r=e.indexOf(t);r>=0&&e.splice(r,1)}},qi,Ki=()=>qi??=Ui(),Vi=()=>{let n=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;if(typeof n!="function"||!Object.prototype.hasOwnProperty.call(n,Symbol.hasInstance))return!1;let e=n[Symbol.hasInstance]({});return e instanceof Promise?(e.catch(()=>{}),!0):!1},$i=()=>{let n={get nodeType(){throw new Error("probe")}};return ct(()=>MutationObserver.prototype.observe.call(null,n))},Qi=()=>{let n=new Error("probe"),e=[],t={get nodeType(){return e.push("nodeType"),1},get ownerDocument(){throw e.push("ownerDocument"),n}};try{MutationObserver.prototype.observe.call(null,t)}catch(r){return r===n&&e.join()==="nodeType,ownerDocument"}return!1},Gi=()=>[Element.prototype.attachShadow,navigator.credentials?.get,navigator.credentials?.create,...ft("get","_get","create")].some(e=>typeof e=="function"&&Mi.test(Function.prototype.toString.call(e))),Wi=()=>{let n=document;for(;n;){if(n.querySelector("[data-lastpass-icon-root], [data-lastpass-root]"))return!0;n=n.activeElement?.shadowRoot}return!1},zi=()=>{let n=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;return[navigator.credentials?.get,...ft("get","_get"),n?.isConditionalMediationAvailable,n?._isConditionalMediationAvailable,n?.isUserVerifyingPlatformAuthenticatorAvailable,n?._isUserVerifyingPlatformAuthenticatorAvailable].some(t=>typeof t=="function"&&Hi.test(Function.prototype.toString.call(t)))},ji=[{name:"1password",signal:"in-field button",signedIn:!0,test:()=>document.querySelector("com-1password-button")!==null},{name:"1password",signal:"credentials.get accessor",test:Bi},{name:"1password",signal:"Sentry debug id",test:()=>ut().some(n=>n.includes(Ri))},{name:"bitwarden",signal:"passkey override",signedIn:!0,test:Ni},{name:"bitwarden",signal:"autofill keyframes",test:Ki},{name:"dashlane",signal:"injected script tag",test:()=>document.querySelector('script[src*="-extension://"][src*="/dashlane-"][src$="-page-script.js"]')!==null},{name:"dashlane",signal:"PublicKeyCredential hasInstance trap",test:Vi},{name:"dashlane",signal:"page script stack",test:()=>ur.test(fr())||typeof HTMLDialogElement<"u"&&ur.test(ct(()=>HTMLDialogElement.prototype.showModal.call(null)))},{name:"kaspersky",signal:"passkey proxy flag",test:()=>window.wasKPMKeyPassProxyInited===!0},{name:"kaspersky",signal:"injected script tag",test:()=>Di.test(document.querySelector('script[src*="/content-scripts/passkey_proxy/"]')?.src??"")},{name:"keeper",signal:"attachShadow stack",test:()=>_i.test(fr())},{name:"keeper",signal:"override source",test:Gi},{name:"keeper",signal:"field lock",test:()=>document.querySelector("[data-keeper-lock-id]")!==null},{name:"lastpass",signal:"passkey override",signedIn:!0,test:()=>typeof window.__nativeCredentialsGet=="function"},{name:"lastpass",signal:"icon root",test:Wi},{name:"nordpass",signal:"observer proxy stack",test:()=>cr.test($i())},{name:"nordpass",signal:"observer read order",test:Qi},{name:"nordpass",signal:"passkeys Sentry debug id",test:()=>ut().some(n=>Ai.test(n))},{name:"nordpass",signal:"Sentry debug id",test:()=>ut().some(n=>cr.test(n))},{name:"protonpass",signal:"WebAuthn override source",test:zi},{name:"protonpass",signal:"field icon",test:()=>document.querySelector("[data-protonpass-role]")!==null}];function Yi(){return typeof window>"u"||typeof document>"u"?[]:ji.map(({name:n,signal:e,signedIn:t,test:r})=>{try{return{name:n,signal:e,signedIn:t,matched:r()}}catch(i){return{name:n,signal:e,signedIn:t,matched:!1,error:i}}})}function Xi(){let n=new Map;for(let{name:e,signedIn:t,matched:r}of Yi()){if(!r)continue;let i=n.get(e)??{name:e};t&&(i.signedIn=!0),n.set(e,i)}return[...n.values()]}function hr(n){return Xi()}var gr=3e3,Ji=500,Zi=6,en=1e3,Qe=class{constructor(e,t,r){this.logger=e;this.isEnabled=t;if(typeof window>"u"||typeof document>"u")return;if(this.sample(),document.readyState==="complete")this.sampleAfter(gr);else{let o=()=>{this.sampleWhenIdle(),this.sampleAfter(gr)};window.addEventListener("load",o,{once:!0}),this.removers.push(()=>window.removeEventListener("load",o))}let i=r.onInputFocus(o=>{!this.isEnabled()||this.sampledFields.has(o)||(this.sampledFields.add(o),++this.focusSamples>=Zi&&i(),this.sampleAfter(Ji))});this.removers.push(i)}detected=new Map;timers=new Set;idleCallbacks=new Set;sampledFields=new WeakSet;focusSamples=0;removers=[];destroyed=!1;reportedCounts=new Map;getDetected(){return[...this.detected.values()]}takeReport(e){if(!(!this.isEnabled()||this.detected.size<=(this.reportedCounts.get(e)??0)))return this.reportedCounts.set(e,this.detected.size),this.getDetected().map(({name:t})=>({name:t}))}destroy(){this.destroyed=!0;for(let e of this.removers)e();for(let e of this.timers)clearTimeout(e);this.timers.clear();for(let e of this.idleCallbacks)cancelIdleCallback(e);this.idleCallbacks.clear()}sampleAfter(e){let t=setTimeout(()=>{this.timers.delete(t),this.sampleWhenIdle()},e);this.timers.add(t)}sampleWhenIdle(){if(typeof requestIdleCallback!="function"){this.sample();return}let e=requestIdleCallback(()=>{this.idleCallbacks.delete(e),this.sample()},{timeout:en});this.idleCallbacks.add(e)}sample(){if(!(this.destroyed||!this.isEnabled()))try{let e=hr({key:"browser-api:password-managers.extensions",fields:[{path:"result[].name",exposure:"enum",transform:{values:["1password","bitwarden","dashlane","kaspersky","keeper","lastpass","nordpass","protonpass"]}},{path:"result[].signedIn",exposure:"none"}],dataConfig:"pmd"});for(let t of e){let r=this.detected.get(t.name);(!r||t.signedIn&&!r.signedIn)&&this.detected.set(t.name,t)}}catch(e){this.logger.error("Failed to detect password manager extensions",e)}}};var ht={name:nr,version:or},tn=/^[0-9A-Za-z.+_-]{1,32}$/;function rn(n,e){return n===void 0?ht:typeof n=="string"&&tn.test(n)?{...ht,integrationVersion:n}:(e.debug("Ignoring invalid integrationVersion (expected <= 32 chars of [0-9A-Za-z.+_-])"),ht)}var mr="cbo_session_id",gt="cbo_session",H="cbo_seq",yr="cbo_experiments",vr="cbo_data_policy",nn=255,on=/^[A-Za-z0-9_-]+$/,sn=128,an=256,br=1e3,ln=/^[a-z][a-z0-9_-]{0,31}$/,Sr=/^[A-Za-z0-9_-]{1,16}$/,dn=64,pn=32,un=50,cn="cbo_seq",wr=1e3,Tr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Ge=class n{constructor(e){this.options=e;this.options.debug=e.debug??!1,this.logger=e.logger??dr({debug:this.options.debug});let t=new me(this.logger),r=new ve(this.logger),i=e.storage==="cookie",o=i?new ye(this.logger,e.cookieDomain):void 0;Zt(e.projectId,t,r,o,this.logger);let s=e.projectId,a=c=>new ge(c,s);this.seqLockName=P(cn,s),this.sessionStorage=a(r),this.persistentStorage=a(t),this.storage=a(o??t),this.configOverrides={...e.sdkConfig,...e.sdkConfig?.retry&&{retry:{...e.sdkConfig.retry}},...e.sdkConfig?.flushOnFlowTypeFinished&&{flushOnFlowTypeFinished:[...e.sdkConfig.flushOnFlowTypeFinished]},...e.sdkConfig?.sourcePathQueryAllow&&{sourcePathQueryAllow:[...e.sdkConfig.sourcePathQueryAllow]}},this.fixedData=Ft(e.fixedDataConfig),this.fixedData&&(this.configOverrides.pmd=this.fixedData.pmd);let l=Object.keys(S).every(c=>this.configOverrides[c]!==void 0)&&Object.keys(S.retry).every(c=>this.configOverrides.retry?.[c]!==void 0);l||(this.configManager=new Te(e.apiBaseUrl+(e.apiConfigPath??"/v1/observe/config")+"/"+e.projectId,this.persistentStorage,this.logger));let p=this.configManager?.initialConfig;this.config=Ye(p,this.configOverrides),!l&&!p&&e.flushInterval!=null&&this.configOverrides.flushIntervalMs===void 0&&(this.config={...this.config,flushIntervalMs:e.flushInterval}),!l&&!p&&e.deviceInfoCollectorTimeout!=null&&this.configOverrides.deviceInfoCollectorTimeoutMs===void 0&&(this.config={...this.config,deviceInfoCollectorTimeoutMs:e.deviceInfoCollectorTimeout}),e.apiBaseUrl!==""&&(/^https?:\/\//.test(e.apiBaseUrl)||(this.logger.critical(`Invalid apiBaseUrl: URL must start with http:// or https:// (got: "${e.apiBaseUrl}")`),this.reportTelemetry("error","invalid apiBaseUrl: missing http(s) scheme")),e.apiBaseUrl.endsWith("/")&&(this.logger.critical(`Invalid apiBaseUrl: URL must not have a trailing slash (got: "${e.apiBaseUrl}")`),this.reportTelemetry("error","invalid apiBaseUrl: trailing slash")));let d=e.apiBaseUrl+(e.apiEventPath??"/v1/observe/events")+"/"+e.projectId;this.logger.debug(`Using API endpoint: ${d}`);let u=new de({logger:this.logger,url:d});this.sessionId=this.resolveSessionId(),this.queue=new ce(this.logger,u,this.sessionId,rn(this.options.integrationVersion,this.logger),{debug:this.options.debug,config:this.config,requestConfig:!1,outboxLockName:P(Xe,s),getDataPolicy:()=>this.dataPolicy,fixedData:this.fixedData!==void 0||typeof __CBO_DATA_PMD__=="boolean"||typeof __CBO_DATA_PRIVATE_MODE__=="boolean",beforeEventBatchSend:c=>this.attachUndeliveredDeviceInfo(c),standaloneDeviceInfo:{has:()=>this.deviceInfoManager?.hasStandalone()??!1,take:()=>this.deviceInfoManager?.takeStandalone()}},this.persistentStorage),this.telemetryReady=!0,this.logger.setTelemetrySink?.((c,v)=>this.reportTelemetry(c,v));try{this.getWindowObserver()}catch(c){this.logger.error("Failed to attach page low-event observer",c)}if(typeof __CBO_DATA_PMD__=="boolean"?__CBO_DATA_PMD__:this.fixedData?.pmd!==!1)try{this.passwordManagerSampler=this.isTrackingBlocked()?void 0:new Qe(this.logger,()=>typeof __CBO_DATA_PMD__=="boolean"?__CBO_DATA_PMD__:this.config.pmd,this.getWindowObserver())}catch(c){this.logger.error("Failed to start password manager detection",c)}let f=this.pendingSelfTelemetry;this.pendingSelfTelemetry=[];for(let c of f)this.telemetry(c.level,c.message);let h=new fe(this.logger,this.storage,i?"cookie":"localstorage",this.sessionStorage,()=>({timing:this.config.deviceInfoTiming}),(c,v)=>this.telemetry(c,v),this.fixedData?.privateMode??!0);this.deviceCollector=h;let m=e.deviceInfoDebounceTime??3e4;this.deviceInfoManager=new he(this.logger,h,Math.max(1,m),m,{timing:()=>this.config.deviceInfoTiming,emit:(c,v)=>this.telemetry(c,v)},()=>this.queue.notifyDeviceInfo()),this.deviceInfoManager.start(),this.experiments=this.loadPersistedExperiments(),e.experiments&&this.setExperiments(e.experiments),this.dataPolicy=this.loadPersistedDataPolicy(),e.dataPolicy!==void 0&&this.setDataPolicy(e.dataPolicy),this.configManager?.start(c=>this.handleConfig(c))}logger;queue;sessionId;storage;sessionStorage;persistentStorage;seqLockName;config;configManager;configOverrides;fixedData;deviceInfoManager;deviceCollector;eventTabId;seq=0;lastActivityWriteAt=0;experiments={};dataPolicy;telemetryReporting=!1;telemetryReady=!1;reportedTelemetryKeys=new Set;pendingSelfTelemetry=[];probePageId;probeSeqs=new Map;windowObserver;passwordManagerSampler;getWindowObserver(){return this.windowObserver??=new le(this.logger,(e,t)=>this.enqueueLowEvent(e,t),()=>this.lowEventFlushKeepalive())}handleConfig(e){let t=Ye(e,this.configOverrides);t.sessionContinuity||=this.config.sessionContinuity,t.durableOutbox||=this.config.durableOutbox,this.config=t,this.queue.updateConfig(this.config)}getLogger(){return this.logger}applicationTag(){return this.options.applicationId?{applicationId:this.options.applicationId.toLowerCase()}:{}}setExperiment(e,t){this.setExperiments({[e]:t})}setExperiments(e){try{if(!e||typeof e!="object")return;let t=!1;for(let[r,i]of Object.entries(e)){if(!n.isValidExperimentKey(r)||!n.isValidExperimentVariant(i)){this.logger.debug(`Ignoring invalid experiment assignment "${String(r)}"`);continue}this.experiments[r]!==i&&(this.experiments[r]=i,t=!0)}t&&this.persistExperiments()}catch(t){this.logger.error("Failed to set experiments",t)}}clearExperiment(e){try{Object.prototype.hasOwnProperty.call(this.experiments,e)&&(delete this.experiments[e],this.persistExperiments())}catch(t){this.logger.error("Failed to clear experiment",t)}}clearExperiments(){try{if(Object.keys(this.experiments).length===0)return;this.experiments={},this.persistExperiments()}catch(e){this.logger.error("Failed to clear experiments",e)}}getExperiments(){return{...this.experiments}}getPersistentStorage(){return this.persistentStorage}getSdkConfig(){return Object.freeze({version:this.config.version,aap:this.config.aap,rawErrors:this.config.rawErrors})}setDataPolicy(e){try{if(!n.isValidDataPolicy(e)){this.logger.debug(`Ignoring invalid data policy code "${String(e)}"`);return}this.dataPolicy!==e&&(this.dataPolicy=e,this.persistDataPolicy())}catch(t){this.logger.error("Failed to set data policy",t)}}getDataPolicy(){return this.dataPolicy}static isValidDataPolicy(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=nn}loadPersistedDataPolicy(){try{let e=this.persistentStorage.getItem(vr);return n.isValidDataPolicy(e)?e:void 0}catch(e){this.logger.debug("Failed to load persisted data policy",e);return}}persistDataPolicy(){try{if(this.dataPolicy===void 0)return;this.persistentStorage.setItem(vr,this.dataPolicy)}catch(e){this.logger.debug("Failed to persist data policy",e)}}static isValidExperimentKey(e){return typeof e=="string"&&e.length>0&&e.length<=sn&&on.test(e)}static isValidExperimentVariant(e){return typeof e=="string"&&e.length>0&&e.length<=an}loadPersistedExperiments(){try{let e=this.persistentStorage.getItem(yr);if(!e||typeof e!="object")return{};let t={};for(let[r,i]of Object.entries(e))n.isValidExperimentKey(r)&&n.isValidExperimentVariant(i)&&(t[r]=i);return t}catch(e){return this.logger.debug("Failed to load persisted experiments",e),{}}}persistExperiments(){try{this.persistentStorage.setItem(yr,this.experiments)}catch(e){this.logger.debug("Failed to persist experiments",e)}}resolveExperiments(e){let t={...this.experiments};if(e&&typeof e=="object")for(let[r,i]of Object.entries(e))n.isValidExperimentKey(r)&&n.isValidExperimentVariant(i)&&(t[r]=i);return Object.keys(t).length>0?t:void 0}isTrackingBlocked(){return typeof navigator>"u"?!1:ir(navigator.userAgent)}resolveSessionId(){try{if(this.config.sessionContinuity)return this.getContinuitySessionId();let e=Date.now(),t=this.readPerTabSession();if(t&&e-t.lastActiveAt<this.perTabInactivityMs(t))return this.persistPerTabSession(t.id,e),this.seq=0,t.id;let r=b();return this.persistPerTabSession(r,e),this.seq=0,this.logger.debug("Created session id",r),r}catch(e){return this.logger.error("Failed to get session id",e),this.reportTelemetry("error","failed to get session id"),""}}getContinuitySessionId(){let e=Date.now(),t=this.persistentStorage.getItem(gt);if(t?.id&&e-t.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(t.id,e),this.seq=this.persistentStorage.getItem(H)??0,t.id;if(!t?.id){let i=this.readPerTabSession();if(i&&e-i.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(i.id,e),this.persistentStorage.setItem(H,0),this.seq=0,this.logger.debug("Adopted per-tab session id as continuity session",i.id),i.id}let r=b();return this.persistContinuitySession(r,e),this.persistentStorage.setItem(H,0),this.seq=0,this.logger.debug("Created continuity session id",r),r}persistContinuitySession(e,t){this.lastActivityWriteAt=t,this.persistentStorage.setItem(gt,{id:e,lastActiveAt:t})}readPerTabSession(){let e=this.sessionStorage.getItem(mr);if(e){if(typeof e=="string")return Tr.test(e)?{id:e,lastActiveAt:Date.now()}:void 0;if(typeof e.lastActiveAt=="number")return Tr.test(e.id)?e:void 0}}persistPerTabSession(e,t){this.lastActivityWriteAt=t;let r=this.configOverrides.sessionInactivityMs!==void 0||this.config.version?this.config.sessionInactivityMs:this.readPerTabSession()?.inactivityMs;this.sessionStorage.setItem(mr,{id:e,lastActiveAt:t,...r===void 0?{}:{inactivityMs:r}})}perTabInactivityMs(e){return this.configOverrides.sessionInactivityMs!==void 0?this.config.sessionInactivityMs:e.inactivityMs??this.config.sessionInactivityMs}nextSeq(){if(!this.config.sessionContinuity){let r=Date.now();return this.sessionId&&r-this.lastActivityWriteAt>=wr&&this.persistPerTabSession(this.sessionId,r),this.seq++}let e=()=>{let r=Date.now(),i=this.persistentStorage.getItem(gt),o=!1;if(!i?.id&&this.sessionId)this.persistContinuitySession(this.sessionId,r);else if(i?.id)r-this.lastActivityWriteAt>=wr&&this.persistContinuitySession(i.id,r),i.id!==this.sessionId&&(this.sessionId=i.id,this.queue.setSessionId(i.id),o=!0);else{let l=b();this.persistContinuitySession(l,r),this.persistentStorage.setItem(H,0),this.sessionId=l,this.queue.setSessionId(l),this.seq=0,o=!0}let s=this.persistentStorage.getItem(H);o&&(this.seq=typeof s=="number"?s:0);let a=typeof s=="number"&&s>this.seq?s:this.seq;return this.seq=a+1,this.persistentStorage.setItem(H,this.seq),a},t=this.config.seqLockTimeoutMs;return t===0||typeof navigator>"u"||!navigator.locks?.request?e():pe(this.seqLockName,e,{timeoutMs:t,onTimeout:()=>{this.logger.warn(`Sequence Web Lock acquisition timed out after ${t}ms; using fallback`),this.reportTelemetry("info",`seq web lock timeout; using fallback, ${t}ms`)}})}resolveTrackingSourcePath(){if(typeof window>"u")return;let e=xt(window.location.search,this.config.sourcePathQuery,this.config.sourcePathQueryAllow);return`${window.location.pathname}${e}`}resolveEventTabId(){return this.eventTabId===void 0&&(this.eventTabId=this.deviceCollector.getTabId()),this.eventTabId}trackSubflowStarted(e,t,r,i){let o={subflowType:e,...t};this.track("subflow_started",o,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{id:i,subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowTrigger(e,t,r){let i={subflowType:e,...t};this.track("subflow_trigger",i,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowStepStarted(e,t,r,i,o){let s={subflowType:e,stepName:t,stepData:r,identifier:i?.identifier,ignoreAsInteraction:o};this.track("subflow_step_started",s,i?.userReference,void 0,void 0,i?.explicitTimestamp,i?.experiments,{subflowStartEventId:i?.subflowStartEventId,sessionId:i?.captureSessionId,initiator:i?.initiator})}trackSubflowStepFinished(e,t,r,i){let o={subflowType:e,stepName:t,stepData:r,identifier:i?.identifier};this.track("subflow_step_finished",o,i?.userReference,void 0,void 0,i?.explicitTimestamp,i?.experiments,{subflowStartEventId:i?.subflowStartEventId,sessionId:i?.captureSessionId,initiator:i?.initiator})}trackSubflowStepError(e,t,r,i){let o={subflowType:e,stepName:t,stepData:r,identifier:i?.identifier};this.track("subflow_step_error",o,i?.userReference,void 0,void 0,i?.explicitTimestamp,i?.experiments,{subflowStartEventId:i?.subflowStartEventId,sessionId:i?.captureSessionId,initiator:i?.initiator})}trackSubflowError(e,t,r){let i={subflowType:e,stepData:t};this.track("subflow_error",i,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}async track(e,t,r,i,o,s,a,l){try{if(this.isTrackingBlocked()){this.logger.debug(`Skipping event "${e}" for blocked user agent.`);return}(e==="flow_finished"||e==="flow_auto_finished"||e==="flow_reset")&&this.windowObserver?.flushInputs();let p=s??Date.now(),d=l?.id??b(),u=l?.sessionId??this.sessionId,f=this.nextSeq(),h=typeof f=="number"?f:await f,m=this.resolveTrackingSourcePath(),c={type:"predefined",name:e,id:d,timestamp:p,seq:h,data:t,user:r,contexts:o,tags:i,experiments:this.resolveExperiments(a),meta:{captureVersion:1,pageId:Z(),initiator:l?.initiator,trackingSourcePath:m??"",subflowStartEventId:l?.subflowStartEventId,tabId:this.resolveEventTabId()}},v=this.deviceInfoManager.getForEvent();v&&(c.deviceInfo=v),this.logger.debug(`Track: ${e}`,JSON.stringify(c,null,2));let y=this.passwordManagerSampler?.takeReport(u);y&&(c.passwordManagers=y),this.queue.enqueue(c,u)}catch(p){this.logger.error(`Failed to process event "${e}" before enqueue`,p),this.reportTelemetry("error",`failed to process event "${e}" before enqueue`)}}flowStarted(e,t,r,i,o){try{let s=b(),a=this.sessionId,l={...this.options.defaultTags,...this.applicationTag(),...t};return this.track("flow_started",e,void 0,l,i,o?.explicitTimestamp,r,{id:s,sessionId:a}),this.flowHandle(s,a)}catch(s){return this.logger.warn("Failed to start flow",s),{enrich:async()=>{}}}}flowDecided(e,t,r){this.track("flow_decided",e,void 0,t,void 0,void 0,r)}conversion(e,t,r){let{userId:i,identifier:o,crossEnvironmentTransactionID:s,...a}=e,l={userId:i,identifier:o,crossEnvironmentTransactionID:s},p={...this.options.defaultTags,...this.applicationTag(),...t};this.track("conversion",a,l,p,void 0,void 0,r)}flowFinished(e,t,r){try{let{userId:i,identifier:o,...s}=e,a={userId:i,identifier:o},l=b(),p=this.sessionId;return this.track("flow_finished",s,a,t,void 0,void 0,r,{id:l,sessionId:p}),this.flowHandle(l,p)}catch(i){return this.logger.warn("Failed to finish flow",i),{enrich:async()=>{}}}}flowHandle(e,t){return{enrich:async r=>{try{await this.track("flow_enriched",{targetEventId:e},{...r},void 0,void 0,void 0,void 0,{sessionId:t})}catch(i){this.logger.warn("Failed to enrich flow",i)}}}}flowReset(e,t,r){this.track("flow_reset",e,void 0,t,void 0,void 0,r)}flowAutoFinished(e,t,r){let{userId:i,identifier:o,...s}=e,a={userId:i,identifier:o};this.track("flow_auto_finished",s,a,t,void 0,void 0,r)}setUser(e){this.track("flow_enriched",{match:{flowType:"*",at:"during"},expFol:!0},{...e})}setFlowTags(e,t){try{if(!e||typeof e!="object"){this.logger.warn("setFlowTags: ignoring non-object tags");return}let r={};for(let[o,s]of Object.entries(e)){if(o===""||typeof s!="string"){this.logger.warn(`setFlowTags: ignoring invalid tag "${o}"`);continue}r[o]=s}if(Object.keys(r).length===0)return;let i={match:{flowType:t?.flowType??"*",at:"during"}};t?.expandToChildren!==void 0&&(i.expCh=t.expandToChildren),t?.expandToFollowing!==void 0&&(i.expFol=t.expandToFollowing),this.track("flow_enriched",i,void 0,r)}catch(r){this.logger.warn("Failed to set flow tags",r)}}authMethodsDecisionStarted(e,t,r,i){this.track("auth_method_decision_started",e,void 0,t,void 0,i?.explicitTimestamp,r)}authMethodsDecisionFinished(e,t,r){this.track("auth_method_decision_finished",e,void 0,t,void 0,void 0,r)}authDecisionStarted(e,t,r){this.track("auth_decision_started",e,void 0,t,void 0,void 0,r)}authDecisionFinished(e,t,r){this.track("auth_decision_finished",e,void 0,t,void 0,void 0,r)}enqueueLowEvent(e,t){try{if(this.isTrackingBlocked()){this.logger.debug(`Skipping low event "${e.lowType}" for blocked user agent.`);return}this.queue.enqueueLow({...e,captureSeq:e.captureSeq??C(),captureVersion:1,pageId:e.pageId??Z()},t)}catch(r){this.logger.error(`Failed to process low event "${e.lowType}" before enqueue`,r)}}telemetry(e,t){try{if(this.isTrackingBlocked()){this.logger.debug("Skipping telemetry for blocked user agent.");return}let r=typeof t=="string"?t:String(t);if(r.length===0)return;let i={id:b(),level:e,message:r.length>br?r.slice(0,br):r,ts:Date.now()};this.queue.enqueueTelemetry(i)}catch(r){this.logger.error("Failed to process telemetry before enqueue",r)}}probe(e){try{if(this.isTrackingBlocked()){this.logger.debug("Skipping probe for blocked user agent.");return}if(!e||typeof e!="object"||typeof e.kind!="string"||!ln.test(e.kind)){this.logger.debug("Dropping probe with an invalid kind.");return}let t=e.payload;if(!t||typeof t!="object"){this.logger.debug(`Dropping probe "${e.kind}" without an object payload.`);return}let r=typeof e.pageId=="string"&&Sr.test(e.pageId)?e.pageId:this.defaultProbePageId(),i={id:b(),kind:e.kind,ts:typeof e.ts=="number"&&Number.isFinite(e.ts)?Math.round(e.ts):Date.now(),pageId:r,seq:this.nextProbeSeq(r),payload:t};typeof e.cfg=="string"&&Sr.test(e.cfg)&&(i.cfg=e.cfg);let o=gn(e.ctx);o&&(i.ctx=o),this.queue.enqueueProbe(i)}catch(t){this.logger.error("Failed to process probe before enqueue",t)}}defaultProbePageId(){return this.probePageId??=hn()}nextProbeSeq(e){let t=this.probeSeqs.get(e)??0;if(this.probeSeqs.delete(e),this.probeSeqs.set(e,t+1),this.probeSeqs.size>pn){let r=this.probeSeqs.keys().next().value;r!==void 0&&this.probeSeqs.delete(r)}return t}logInfo(e){this.telemetry("info",e)}logError(e){this.telemetry("error",e)}attachUndeliveredDeviceInfo(e){try{let t=this.deviceInfoManager;if(!t?.hasUndelivered())return;let r=Z(),i=e.find(o=>o.meta?.pageId===r&&!o.deviceInfo);i&&(i.deviceInfo=t.takeUndelivered())}catch(t){this.logger.error("Failed to attach device info to batch",t)}}reportTelemetry(e,t){if(!this.telemetryReporting){this.telemetryReporting=!0;try{if(this.reportedTelemetryKeys.has(t)||this.reportedTelemetryKeys.size>=un)return;if(this.reportedTelemetryKeys.add(t),!this.telemetryReady){this.pendingSelfTelemetry.push({level:e,message:t});return}this.telemetry(e,t)}catch{}finally{this.telemetryReporting=!1}}}flushKeepalive(e="manual"){try{this.queue.flushKeepalive(e)}catch(t){this.logger.error("Failed to flush queue keepalive",t)}}isPasswordManagerDomScanEnabled(){return this.fixedData?.pmdExplicit?this.fixedData.pmd:!0}lowEventFlushKeepalive(){this.config.tlf&&this.flushKeepalive("low-event-teardown")}passkeyLoginFullOperation(e){return new Ee(this,e)}passkeyEnrollmentFullOperation(e){return new Pe(this,e)}passkeyDeletionOperationFull(e){return new Le(this,e)}passwordLoginFullOperation(e){return new Fe(this,e)}passwordEnrollmentFullOperation(e){return new Re(this,e)}emailLinkOperationFull(e){return new Ce(this,e)}continueEmailLinkOperation(e){return new Oe(this,e)}emailOtpOperationFull(e){return new ke(this,e)}smsOtpOperationFull(e){return new xe(this,e)}totpOperationFull(e){return new Me(this,e)}provideIdentifierOperationFull(e){return new De(this,e)}provideDataOperationFull(e){return new $e(this,e)}formOperationFull(e){return new Ue(this,e)}socialLoginOperationFull(e){return new _e(this,e)}ssoLoginOperationFull(e){return new Ae(this,e)}appConfirmationOperationFull(e){return new He(this,e)}keySigningOperationFull(e){return new se(this,e)}keyRegistrationOperationFull(e){return new ae(this,e)}captchaOperationFull(e){return new Be(this,e)}trustedDeviceCheckOperationFull(e){return new Ke(this,e)}trustedDeviceEnrollmentOperationFull(e){return new Ve(this,e)}async destroy(){if(this.configManager?.destroy(),this.passwordManagerSampler?.destroy(),this.windowObserver?.destroy(),this.deviceInfoManager.destroy(),this.config.td)try{await this.queue.flush("destroy")}catch(e){this.logger.error("Failed to flush queue during destroy",e)}this.queue.destroy()}getSessionId(){if(!this.sessionId){let e=this.resolveSessionId();e&&(this.sessionId=e,this.queue.setSessionId(e))}return this.sessionId||void 0}resetSession(){let e=b();return this.config.sessionContinuity?(this.persistContinuitySession(e,Date.now()),this.persistentStorage.setItem(H,0)):this.persistPerTabSession(e,Date.now()),this.sessionId=e,this.seq=0,this.queue.setSessionId(e),this.logger.debug(`Session reset: ${e}`),e}},fn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";function hn(){let n=new Uint8Array(16);try{globalThis.crypto.getRandomValues(n)}catch{for(let t=0;t<n.length;t++)n[t]=Math.floor(Math.random()*256)}let e="";for(let t=0;t<n.length;t++)e+=fn[n[t]&63];return e}function gn(n){if(!n||typeof n!="object")return;let e={};for(let t of["state","flowType","step"]){let r=n[t];typeof r=="string"&&r.length>0&&(e[t]=r.slice(0,dn))}return Object.keys(e).length>0?e:void 0}var mt={};function Er(n,e="default"){mt[e]=new Ge(n)}function Ir(n="default"){if(!mt[n])throw new Error(`Tracker ${n} not initialized (call Corbado.init() first)`);return mt[n]}function mn(n){for(let e of n)Er(e[0],e[1])}var kr={};function xr(n,e,t=[],r){let i=Ir(n),o=i[e];if(typeof o!="function")return;let s=o.apply(i,t);r&&s&&typeof s=="object"&&(kr[r]=s)}function Cr(n,e,t=[]){let r=kr[n];if(!r)return;let i=e.split("."),o=r;for(let a=0;a<i.length-1;a++)if(o=o?.[i[a]],!o)return;let s=o[i[i.length-1]];typeof s=="function"&&s.apply(o,t)}function yn(n){for(let e of n)xr(e[0],e[1],Array.isArray(e[2])?e[2]:[],e[3])}function vn(n){for(let e of n)Cr(e[0],e[1],Array.isArray(e[2])?e[2]:[])}typeof window<"u"&&(window.Corbado?.IQ&&(mn(window.Corbado.IQ),delete window.Corbado.IQ),window.Corbado?.MQ&&(yn(window.Corbado.MQ),delete window.Corbado.MQ),window.Corbado?.OQ&&(vn(window.Corbado.OQ),delete window.Corbado.OQ),window.Corbado={init:Er,get:Ir,__dispatchMethod:xr,__dispatchOp:Cr});})();
|
|
1
|
+
"use strict";(()=>{var It=0;function C(){if(It===4294967295)throw new Error("Low-event capture sequence exhausted");return++It}function kt(i,e){if(i==="passkey-login")switch(e){case"passkey-known-identifier":case"passkey-no-identifier":return"passkey-button";case"passkey-known-identifier-auto":case"passkey-no-identifier-auto":case"passkey-immediate":return"automatic"}else if(i==="passkey-enrollment")switch(e){case"manual":return"passkey-button";case"auto":case"conditional":return"automatic"}}var E=[];for(let i=0;i<256;++i)E.push((i+256).toString(16).slice(1));function xt(i,e=0){return(E[i[e+0]]+E[i[e+1]]+E[i[e+2]]+E[i[e+3]]+"-"+E[i[e+4]]+E[i[e+5]]+"-"+E[i[e+6]]+E[i[e+7]]+"-"+E[i[e+8]]+E[i[e+9]]+"-"+E[i[e+10]]+E[i[e+11]]+E[i[e+12]]+E[i[e+13]]+E[i[e+14]]+E[i[e+15]]).toLowerCase()}var et,jr=new Uint8Array(16);function oe(){if(!et){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");et=crypto.getRandomValues.bind(crypto)}return et(jr)}var tt={};function Yr(i,e,t){let r;if(i)r=Ot(i.random??i.rng?.()??oe(),i.msecs,i.seq,e,t);else{let n=Date.now(),o=oe();Xr(tt,n,o),r=Ot(o,tt.msecs,tt.seq,e,t)}return e??xt(r)}function Xr(i,e,t){return i.msecs??=-1/0,i.seq??=0,e>i.msecs?(i.seq=t[6]<<23|t[7]<<16|t[8]<<8|t[9],i.msecs=e):(i.seq=i.seq+1|0,i.seq===0&&i.msecs++),i}function Ot(i,e,t,r,n=0){if(i.length<16)throw new Error("Random bytes length must be >= 16");if(!r)r=new Uint8Array(16),n=0;else if(n<0||n+16>r.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return e??=Date.now(),t??=i[6]*127<<24|i[7]<<16|i[8]<<8|i[9],r[n++]=e/1099511627776&255,r[n++]=e/4294967296&255,r[n++]=e/16777216&255,r[n++]=e/65536&255,r[n++]=e/256&255,r[n++]=e&255,r[n++]=112|t>>>28&15,r[n++]=t>>>20&255,r[n++]=128|t>>>14&63,r[n++]=t>>>6&255,r[n++]=t<<2&255|i[10]&3,r[n++]=i[11],r[n++]=i[12],r[n++]=i[13],r[n++]=i[14],r[n++]=i[15],r}var S=Yr;function U(i){if(i!=null){if(i instanceof Error)return{name:i.name,message:i.message};if(typeof i=="string")return{message:i};if(typeof i=="object"){let e=i;if(typeof e.message=="string"||typeof e.code=="string")return{name:typeof e.name=="string"?e.name:void 0,message:typeof e.message=="string"?e.message:void 0,code:typeof e.code=="string"?e.code:void 0}}return{message:String(i)}}}var Jr={maxStackFrames:{min:1,max:100,default:50},depth:{min:0,max:10,default:3},maxBreadth:{min:1,max:1e3,default:30},maxValueLength:{min:1,max:1e4,default:1024},maxCauseDepth:{min:0,max:10,default:3},maxBytes:{min:0,max:65536,default:32768}},Zr=1024,K=class extends Error{},ei=["name","message","code","errors","stack"],ti=/[^\x20-\x7E]/,V=i=>Object.prototype.toString.call(i).slice(8,-1),ri=i=>i===null?"null":typeof i=="object"?V(i):typeof i,ii=i=>i instanceof Error||V(i)==="Error"||V(i)==="DOMException";function Lt(i){return ti.test(i)?new TextEncoder().encode(i).byteLength:i.length}function q(i,e){let t=Jr[i];return typeof e!="number"||!Number.isFinite(e)?t.default:Math.min(t.max,Math.max(t.min,Math.floor(e)))}function Ct(i={}){return{stack:i.stack===!0,maxStackFrames:q("maxStackFrames",i.maxStackFrames),depth:q("depth",i.depth),maxBreadth:q("maxBreadth",i.maxBreadth),maxValueLength:q("maxValueLength",i.maxValueLength),maxCauseDepth:q("maxCauseDepth",i.maxCauseDepth),maxBytes:q("maxBytes",i.maxBytes)}}function Ft(i,e={}){if(i===void 0)return;let t=Ct(),r=n=>{let o=JSON.stringify(n);return o===void 0||Lt(o)<=t.maxBytes};try{if(t=Ct(e),t.maxBytes===0)return;let n=A(ri(i),1024);for(let s=t.depth;s>=0;s--){let a={limits:t,causeBudget:t.maxCauseDepth,seen:new Set,nodes:0,textBytes:0};try{let l={type:n,value:se(i,s,a)};if(r(l))return l}catch(l){if(!(l instanceof K))throw l}}let o={type:n,truncated:!0};return r(o)?o:void 0}catch{let n={type:"unserializable"};return r(n)?n:void 0}}function Z(i,e){if(i.length>e.limits.maxBytes)throw new K;if(e.textBytes+=Lt(JSON.stringify(i)),e.textBytes>e.limits.maxBytes)throw new K;return i}function se(i,e,t){if(++t.nodes>Zr)throw new K;let r=ni(i,e,t);return typeof r=="string"?Z(r,t):r}function ni(i,e,t){switch(typeof i){case"string":return A(i,t.limits.maxValueLength);case"number":return Number.isFinite(i)?i:String(i);case"boolean":case"undefined":return i;case"bigint":case"symbol":return A(String(i),t.limits.maxValueLength);case"function":return`[Function: ${i.name||"anonymous"}]`}if(i===null)return null;let r=i;if(t.seen.has(r))return"[Circular]";if(e<0)return`[${V(r)}]`;t.seen.add(r);try{return oi(r,e,t)}finally{t.seen.delete(r)}}function A(i,e){return i.length>e?i.slice(0,e)+"\u2026":i}function Pt(i,e,t){let r=i.length>t;i=A(i,t);let n=i.split(`
|
|
2
|
+
`);if(n.length<=e+1)return A(i,t);let o=n.slice(0,e+1).join(`
|
|
3
|
+
`),s=r?"[truncated]":`[+${n.length-e-1} frames]`;return A(`${o}
|
|
4
|
+
${s}`,t)}function oi(i,e,t){let{limits:r}=t,n=V(i),o=u=>se(u,e-1,t);if(n==="Date")return Number.isNaN(i.getTime())?"[Invalid Date]":i.toISOString();if(n==="RegExp")return A(String(i),r.maxValueLength);if(n==="ArrayBuffer")return`[ArrayBuffer(${i.byteLength})]`;if(ArrayBuffer.isView(i))return`[${n}(${i.byteLength})]`;if(n==="Map"||n==="Set"){let u=i,f=[];for(let h of u){if(f.length===r.maxBreadth)break;f.push(o(h))}return u.size>f.length&&f.push(`[+${u.size-f.length} more]`),f}if(n==="Promise"||n==="WeakMap"||n==="WeakSet"||n==="Window")return`[${n}]`;if(typeof Node<"u"&&i instanceof Node)return`[${n}]`;if(Array.isArray(i)){let u=i.slice(0,r.maxBreadth).map(o);return i.length>r.maxBreadth&&u.push(`[+${i.length-r.maxBreadth} more]`),u}if(typeof Response<"u"&&i instanceof Response)return{status:o(i.status),statusText:o(i.statusText),url:o(i.url),redirected:o(i.redirected)};if(typeof Event<"u"&&i instanceof Event){let u=i,f={type:o(u.type)};for(let h of["message","filename","lineno","colno"])h in u&&(f[h]=o(u[h]));return"error"in u&&u.error!=null&&(f.error=o(u.error)),f}let s=Object.create(null),a=i,l=ii(i);if(l){for(let f of ei){if(f==="stack"&&!r.stack)continue;let h=a[f];if(!(h==null||typeof h=="function")){if(f==="stack"){r.stack&&typeof h=="string"&&(s.stack=Z(Pt(h,r.maxStackFrames,r.maxValueLength),t));continue}s[f]=o(h)}}let u=a.cause;u!=null&&typeof u!="function"&&(s.cause=si(u,e-1,t))}let p=0,d=Object.keys(a);for(let u of d){if(u in s||u==="stack"&&!r.stack||l&&u==="cause")continue;if(++p>r.maxBreadth){s["\u2026"]=`[+${d.length-r.maxBreadth} keys]`;break}let f=a[u];typeof f!="function"&&(s[Z(u,t)]=u==="stack"&&typeof f=="string"?Z(Pt(f,r.maxStackFrames,r.maxValueLength),t):o(f))}return!l&&n!=="Object"&&p===0?`[${n}]`:s}function si(i,e,t){if(typeof i!="object"||i===null)return se(i,e,t);if(t.causeBudget<=0)return Z(`[${V(i)}]`,t);t.causeBudget--;try{return se(i,e,t)}finally{t.causeBudget++}}var ai=1500,g=class{constructor(e,t){this.tracker=e;this.operationName=t}startReference;captureSpecType;captureSessionId;lowFlushers=[];lowPrefillCapturers=[];lowEventSink(e,t){return{reserveCaptureSeq:C,enqueueLowEvent:r=>this.tracker.enqueueLowEvent({...r,captureSeq:r.captureSeq??C(),subflowStartEventId:this.startReference,sourceKind:e,fieldRole:t,initiator:r.initiator??(t?`input-${t}`:"unknown")},this.captureSessionId),flushKeepalive:()=>this.tracker.lowEventFlushKeepalive(),passwordManagerDomScan:()=>this.tracker.isPasswordManagerDomScanEnabled(),registerInputs:(r,n)=>this.tracker.getWindowObserver().registerInputs(r,()=>({subflowStartEventId:this.startReference,fieldRole:t,initiator:t?`input-${t}`:"unknown",sessionId:this.captureSessionId}),n),beginCeremony:r=>this.tracker.getWindowObserver().beginCeremony({subflowStartEventId:this.startReference,initiator:r??"unknown",sessionId:this.captureSessionId})}}createLowCollector(e){try{let t=e();return this.lowPrefillCapturers.push(r=>t.capturePrefill(r)),t}catch(t){this.tracker.getLogger().error("Failed to attach low-event collector",t);return}}registerLowFlusher(e){this.lowFlushers.push(e)}captureOptions(e,t=this.startReference,r=this.captureSessionId,n){if(!t&&!n)return e;let o={};return t&&(o.subflowStartEventId=e?.subflowStartEventId??t,o.captureSessionId=e?.captureSessionId??r),n&&(o.initiator=e?.initiator??n),Object.defineProperties({},{...Object.getOwnPropertyDescriptors(e??{}),...Object.getOwnPropertyDescriptors(o)})}get captureReference(){return this.startReference}get captureSession(){return this.captureSessionId}adoptCapture(e,t,r){this.startReference=e,this.captureSessionId=t,this.captureSpecType=r}subflowStart(e,t){try{for(let r of this.lowFlushers)try{r()}catch(n){this.tracker.getLogger().error("Failed to flush previous low-event context",n)}this.captureSpecType=e?.explicitSpecType,this.startReference=S(),this.captureSessionId=this.tracker.getSessionId(),this.tracker.trackSubflowStarted(this.operationName,e,this.captureOptions(t),this.startReference),this.captureInputPrefills(!0)}catch(r){this.tracker.getLogger().error("Failed to start low-event capture context",r)}}capturePrefill(){this.captureInputPrefills(!1)}captureInputPrefills(e){for(let t of this.lowPrefillCapturers)try{t(e)}catch(r){this.tracker.getLogger().error("Failed to capture input prefill",r)}}trigger(e,t){this.tracker.trackSubflowTrigger(this.operationName,e,this.captureOptions(t))}customStep(e){return this.defineStep(e)}subflowStepStarted(e,t,r,n){this.captureSpecType=t?.explicitSpecType??this.captureSpecType,this.tracker.trackSubflowStepStarted(this.operationName,e,t,this.captureOptions(r),n)}subflowStepFinished(e,t,r){(!r?.subflowStartEventId||r.subflowStartEventId===this.startReference)&&(this.captureSpecType=t?.explicitSpecType??this.captureSpecType),this.tracker.trackSubflowStepFinished(this.operationName,e,t,this.captureOptions(r))}subflowStepError(e,t,r){let n=t;try{let o=this.tracker.getSdkConfig().rawErrors?r?.rawError:void 0;o!==void 0&&(n={...t,rawError:Ft(o,r?.rawErrorLimits)})}catch{}this.tracker.trackSubflowStepError(this.operationName,e,n,this.captureOptions(r))}withWindowLowEvents(e,t){let r,n=s=>{s?.subflowStartEventId&&s.subflowStartEventId!==r||t.scheduleDisarm(ai)},o=e;return{...e,start:(s,a)=>{r=a?.subflowStartEventId??this.startReference;let l=s?.explicitSpecType??this.captureSpecType,p=a?.initiator??kt(this.operationName,l);t.arm(p,l==="passkey-cui"),o.start(s,p?{...a,initiator:p}:a)},finished:(s,a)=>{o.finished(s,a),n(a)},error:(s,a)=>{o.error(s,a),n(a)},errorTyped:(s,a)=>{o.errorTyped?.(s,a),n(a)}}}defineStep(e,t){let r,n,o,s=l=>this.captureOptions(l,r,n,o);return{start:(l,p)=>{r=this.startReference,n=this.captureSessionId,o=p?.initiator,this.subflowStepStarted(e,l,s(p),t)},finished:(l,p)=>{this.subflowStepFinished(e,l,s(p))},error:(l,p)=>{this.subflowStepError(e,{error:U(l)},s(p))},errorTyped:(l,p)=>{this.subflowStepError(e,l,s(p))}}}};function Rt(i,e){if(e.explicitSpecType!==void 0)try{i.getLogger().warn("Unsupported key operation spec type; omitting it")}catch{}}var ae=class extends g{prepare;sign;constructor(e,t={}){super(e,"key-signing"),this.prepare=this.defineStep("prepare"),this.sign=this.defineStep("sign"),this.subflowStart({actor:"system",explicitSpecType:Rt(e,t)})}},le=class extends g{prepare;postResponse;constructor(e,t={}){super(e,"key-registration"),this.prepare=this.defineStep("prepare"),this.postResponse=this.defineStep("post-response"),this.subflowStart({actor:"system",explicitSpecType:Rt(e,t)})}};function li(i){try{return decodeURIComponent(i.replace(/\+/g," "))}catch{return i}}function di(i,e){let t=i.toLowerCase();return e.some(r=>{let n=r.toLowerCase();return n.endsWith("*")?t.startsWith(n.slice(0,-1)):t===n})}function Dt(i,e,t){return e!=="allowlist"||i===""||i==="?"?i:`?${(i.startsWith("?")?i.slice(1):i).split("&").map(o=>{let s=o.indexOf("=");if(s===-1)return o;let a=o.slice(0,s);return o.slice(s+1)===""||di(li(a),t)?o:`${a}=*`}).join("&")}`}function x(i,e,t,r){return r===void 0?window.addEventListener(e,t):window.addEventListener(e,t,r),()=>window.removeEventListener(e,t)}function de(i){return document.visibilityState==="hidden"}function _t(i){return document.readyState==="complete"}function At(i){return window.location.href}function Mt(i,e,t){let r=Dt(window.location.search,e,t);return`${window.location.pathname}${r}`}function pe(i){return typeof navigator>"u"?"":navigator.userAgent??""}async function Ht(i){if(!(typeof navigator>"u"||!navigator.bluetooth))return await navigator.bluetooth.getAvailability()}async function Bt(i){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable))return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}async function Nt(i){if(!(typeof PublicKeyCredential>"u"||!PublicKeyCredential.isConditionalMediationAvailable))return await PublicKeyCredential.isConditionalMediationAvailable()}async function Ut(i){if(typeof PublicKeyCredential>"u"||!PublicKeyCredential.getClientCapabilities)return;let e=await PublicKeyCredential.getClientCapabilities();return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,r.toString()]))}async function qt(i){if(typeof navigator>"u"||!navigator.userAgentData)return;let e=await navigator.userAgentData.getHighEntropyValues(["platformVersion","model"]),t=e.platform,r=e.mobile,n=e.platformVersion,o=e.model||void 0;if(!(!t||r===void 0||!n))return{platform:t,mobile:r,platformVersion:n,model:o}}function Kt(i){if(!(typeof navigator>"u"))return navigator.webdriver}function Vt(i){if(!(typeof navigator>"u"||typeof navigator.maxTouchPoints!="number"))return navigator.maxTouchPoints}var rt=(i,e,t)=>{let r=!1,n,o=null,s=null,a=()=>{s!==null&&(clearTimeout(s),s=null);let p=o;r=!1,o=null,p!==null&&i({...n===void 0?{}:{captureSeq:n},lowType:e,ts:p,durationMs:Date.now()-p})};return{extend:()=>{if(!r){let p=t?.();r=!0,o=Date.now(),n=p}s!==null&&clearTimeout(s),s=setTimeout(a,150)},flush:a}};function Wt(i,e,t){let r=[],n=(s,a,l)=>{let p=d=>t(a,()=>l(d));s.addEventListener(a,p),r.push(()=>s.removeEventListener(a,p))};n(window,"blur",()=>e.blur()),n(window,"focus",()=>e.focus()),n(document,"visibilitychange",()=>e.visibilityChange(document.visibilityState==="hidden")),n(document,"focusout",s=>e.focusOut(s.target,!!s.relatedTarget)),n(document,"focusin",s=>e.focusIn(()=>s.composedPath())),n(document,"pointerdown",s=>e.pointerDown(s.target)),window.visualViewport&&(n(window.visualViewport,"resize",()=>e.viewportResize()),n(window.visualViewport,"scroll",()=>e.viewportScroll())),n(window,"pagehide",()=>e.pageHide());let o=window.navigation;return o&&n(o,"currententrychange",s=>{let a=s,l=a.from?.index,p=o.currentEntry?.index;a.navigationType==="traverse"&&typeof l=="number"&&typeof p=="number"&&l>=0&&p>=0&&p<l&&e.navigateBack()}),r}function $t(i){let e=[];for(let t=document.activeElement;t;t=t.shadowRoot?.activeElement??null)e.push(t);return e}function Qt(i){let e=document.activeElement;return{active:e,idle:e===document.body||!e}}var pi,ee=()=>pi??=S(),ue=class{constructor(e,t,r){this.logger=e;this.enqueue=t;this.flushKeepalive=r;typeof window>"u"||typeof document>"u"||(this.removers=Wt(0,{blur:()=>{this.flushInputs(),this.bracket=this.context(),this.emit({lowType:"window-blur",ts:Date.now()},this.bracket)},focus:()=>{this.flushInputs(),this.emit({lowType:"window-focus",ts:Date.now()},this.bracket??this.context()),this.bracket=void 0},visibilityChange:n=>{this.flushInputs(),this.emit({lowType:`document-visibilitychange-${n?"hidden":"visible"}`,ts:Date.now()})},focusOut:(n,o)=>{let s=this.findInput(n);this.lastBlur=s&&!o&&Date.now()-this.unrelatedPointerAt>250?{registration:s,ts:Date.now()}:void 0},focusIn:n=>{this.lastBlur=void 0;let o=this.inputFocusListeners.size>0&&n().find(s=>this.findInput(s));o&&this.notifyInputFocus(o)},pointerDown:n=>{this.findInput(n)?this.unrelatedPointerAt=-1/0:(this.lastBlur=void 0,this.unrelatedPointerAt=Date.now())},viewportResize:()=>this.extendViewport("resize"),viewportScroll:()=>this.extendViewport("scroll"),pageHide:()=>{this.flushInputs(),this.resize.flush(),this.scroll.flush(),this.flushKeepalive()},navigateBack:()=>{this.flushInputs(),this.emit({lowType:"window-navigate-back",ts:Date.now()})}},(n,o)=>{try{o()}catch(s){this.logger.error(`Failed to observe window ${n}`,s)}}))}inputs=new Set;inputFocusListeners=new Set;ceremonies=new Set;removers=[];lastBlur;bracket;unrelatedPointerAt=-1/0;destroyed=!1;viewportContext={};resize=rt(e=>this.emit(e,this.viewportContext.resize),"visualviewport-resize",C);scroll=rt(e=>this.emit(e,this.viewportContext.scroll),"visualviewport-scroll",C);registerInputs(e,t,r){if(this.destroyed)return()=>{};let n={fields:e,context:t,flush:r};if(this.inputs.add(n),this.inputFocusListeners.size>0&&typeof document<"u"){let o=$t(0),s=e.find(a=>o.includes(a));s&&this.notifyInputFocus(s)}return()=>{this.inputs.delete(n),this.lastBlur?.registration===n&&(this.lastBlur=void 0)}}beginCeremony(e){let t={context:e,settled:!1};this.destroyed||(this.flushInputs(),this.ceremonies.add(t));let r=()=>{t.timer&&clearTimeout(t.timer),this.ceremonies.delete(t),this.bracket===t.context&&(this.bracket=void 0)};return{settle:n=>{t.settled=!0,t.timer&&clearTimeout(t.timer),t.timer=setTimeout(r,n)},destroy:r}}onInputFocus(e){return this.destroyed?()=>{}:(this.inputFocusListeners.add(e),()=>this.inputFocusListeners.delete(e))}notifyInputFocus(e){for(let t of this.inputFocusListeners)try{t(e)}catch(r){this.logger.error("Failed to notify registered input focus",r)}}context(){let e=[...this.ceremonies].filter(o=>!o.settled);if(e.length===1)return e[0].context;if(e.length>1)return;let t=Qt(0),r=this.findInput(t.active);if(r)return r.context();let n=this.lastBlur;if(n&&Date.now()-n.ts<=250&&t.idle)return n.registration.context()}findInput(e){return[...this.inputs].find(t=>t.fields.some(r=>r===e))}flushInputs(){for(let e of this.inputs)try{e.flush()}catch(t){this.logger.error("Failed to flush window input context",t)}}emit(e,t){if(this.destroyed)return;let{sessionId:r,...n}=t??{};this.enqueue({...e,...n,captureSeq:e.captureSeq??C(),sourceKind:"window",captureVersion:1,pageId:ee()},r)}extendViewport(e){let t=this.context(),r=this.viewportContext[e];(r?.subflowStartEventId!==t?.subflowStartEventId||r?.fieldRole!==t?.fieldRole||r?.sessionId!==t?.sessionId)&&this[e].flush(),this.viewportContext[e]=t,this[e].extend()}destroy(){if(!this.destroyed){this.flushInputs(),this.resize.flush(),this.scroll.flush(),this.destroyed=!0;for(let e of this.removers)e();for(let e of this.ceremonies)e.timer&&clearTimeout(e.timer);this.ceremonies.clear(),this.inputs.clear(),this.inputFocusListeners.clear()}}};var zt="cbo_sdk_config",jt="X-Corbado-Observe-Config";var I={flushIntervalMs:{min:100,max:6e4},retryMaxAttempts:{min:1,max:10},retryDelayMs:{min:50,max:12e4},sessionInactivityMs:{min:6e4,max:864e5},seqLockTimeoutMs:{min:0,max:250},deviceInfoCollectorTimeoutMs:{min:10,max:1e4},flushOnFlowTypeFinished:{maxEntries:20,maxNameLength:100},sourcePathQueryAllow:{maxEntries:50,maxKeyLength:64}},ui=1800*1e3,b={version:"",flushIntervalMs:500,durableOutbox:!1,durableLowOutbox:!1,beaconKeepalive:!1,sessionContinuity:!1,sessionInactivityMs:ui,seqLockTimeoutMs:50,tvc:!0,tph:!0,td:!0,tlf:!0,telemetry:!0,flushOnTelemetry:!1,flushOnFlowTypeFinished:[],deviceInfoCollectorTimeoutMs:1e3,deviceInfoTiming:!1,rawErrors:!0,pmd:!0,retry:{maxAttempts:1,baseDelayMs:0,maxDelayMs:0},aap:"",sourcePathQuery:"allowlist",sourcePathQueryAllow:[]};function M(i,e,t){return Math.min(Math.max(i,e),t)}function H(i,e){return typeof i=="number"&&Number.isFinite(i)?i:e}function R(i,e){return typeof i=="boolean"?i:e}function Gt(i,e){return typeof i=="string"?i:e}function ci(i){return Array.isArray(i)?i.filter(e=>typeof e=="string"&&e.length>0&&e.length<=I.flushOnFlowTypeFinished.maxNameLength).slice(0,I.flushOnFlowTypeFinished.maxEntries):[]}function fi(i){return typeof i=="string"&&i.trim().toLowerCase()==="all"?"all":"allowlist"}function hi(i){return Array.isArray(i)?i.filter(e=>typeof e=="string").map(e=>e.trim()).filter(e=>e.length>0&&e.length<=I.sourcePathQueryAllow.maxKeyLength).slice(0,I.sourcePathQueryAllow.maxEntries):[]}function te(i){if(!i||typeof i!="object")return null;let e=i;return typeof e.version!="string"||e.version===""?null:Yt(e)}function Yt(i){let e=i.retry&&typeof i.retry=="object"?i.retry:{},t=M(H(e.baseDelayMs,b.retry.baseDelayMs),I.retryDelayMs.min,I.retryDelayMs.max);return{version:Gt(i.version,""),flushIntervalMs:M(H(i.flushIntervalMs,b.flushIntervalMs),I.flushIntervalMs.min,I.flushIntervalMs.max),durableOutbox:i.durableOutbox===!0,durableLowOutbox:i.durableLowOutbox===!0,beaconKeepalive:i.beaconKeepalive===!0,sessionContinuity:i.sessionContinuity===!0,sessionInactivityMs:M(H(i.sessionInactivityMs,b.sessionInactivityMs),I.sessionInactivityMs.min,I.sessionInactivityMs.max),seqLockTimeoutMs:M(H(i.seqLockTimeoutMs,b.seqLockTimeoutMs),I.seqLockTimeoutMs.min,I.seqLockTimeoutMs.max),tvc:R(i.tvc,b.tvc),tph:R(i.tph,b.tph),td:R(i.td,b.td),tlf:R(i.tlf,b.tlf),telemetry:R(i.telemetry,b.telemetry),flushOnTelemetry:i.flushOnTelemetry===!0,flushOnFlowTypeFinished:ci(i.flushOnFlowTypeFinished),deviceInfoCollectorTimeoutMs:M(H(i.deviceInfoCollectorTimeoutMs,b.deviceInfoCollectorTimeoutMs),I.deviceInfoCollectorTimeoutMs.min,I.deviceInfoCollectorTimeoutMs.max),deviceInfoTiming:i.deviceInfoTiming===!0,rawErrors:R(i.rawErrors,b.rawErrors),pmd:R(i.pmd,b.pmd),aap:Gt(i.aap,""),sourcePathQuery:fi(i.sourcePathQuery),sourcePathQueryAllow:hi(i.sourcePathQueryAllow),retry:{maxAttempts:M(H(e.maxAttempts,b.retry.maxAttempts),I.retryMaxAttempts.min,I.retryMaxAttempts.max),baseDelayMs:t,maxDelayMs:M(H(e.maxDelayMs,b.retry.maxDelayMs),t,I.retryDelayMs.max)}}}function it(i,e={}){let t=i??b,r=Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0)),n=Object.fromEntries(Object.entries(e.retry??{}).filter(([,s])=>s!==void 0)),o=Yt({...t,...r,retry:{...t.retry,...n}});return o.retry={...t.retry,...Object.fromEntries(Object.keys(n).map(s=>[s,o.retry[s]]))},o.retry.maxDelayMs=Math.max(o.retry.baseDelayMs,o.retry.maxDelayMs),o}function Xt(i){try{if(!i||typeof i!="object")return;let e=i,t=e.pmd,r=typeof t=="boolean";return{pmd:r?t:!1,pmdExplicit:r,privateMode:R(e.privateMode,!0)}}catch{return}}function Jt(i){return te(i.getItem(zt))}function Zt(i,e){i.setItem(zt,e)}function ce(i,e,t){return fetch(e,t)}function er(i){if(typeof navigator?.sendBeacon=="function")return(e,t)=>navigator.sendBeacon(e,t)}var gi=6e4,mi=6e4,fe=class{constructor(e){this.options=e}async send(e,t){try{e.meta={...e.meta,sent:Date.now(),transport:"fetch"};let r=JSON.stringify(e),n=typeof AbortController<"u"?new AbortController:void 0,o=n?setTimeout(()=>n.abort(),mi):void 0;try{let s={method:"POST",headers:{"Content-Type":"application/json",...this.options.headers,...t},body:r,keepalive:new Blob([r]).size<=gi,...n?{signal:n.signal}:{}},a=await ce(0,this.options.url,s),l={statusCode:a.status,headers:{"retry-after":a.headers.get("Retry-After")}};if(a.headers.get("X-Corbado-Observe-Accepted")==="1"&&(l.deliveryAccepted=!0),a.status===200)try{let p=te(await a.json());p&&(l.config=p)}catch(p){this.options.logger.error("Failed to parse SDK config response",p),this.options.logger.reportTelemetry?.("error","failed to parse SDK config response")}return l}finally{o&&clearTimeout(o)}}catch(r){return this.options.logger.error("Failed to send event",r),{}}}sendBeacon(e){try{this.options.logger.debug(`Sending ${e.events.length} events via beacon`);let t=er(0);if(!t)return!1;e.meta={...e.meta,sent:Date.now(),transport:"beacon"};let r=new Blob([JSON.stringify(e)],{type:"text/plain"});return t(this.options.url,r)}catch(t){return this.options.logger.error("Failed to send event via beacon",t),!1}}flush(e){return Promise.resolve(!0)}};function he(i,e,t,r={}){let n=typeof navigator<"u"?navigator.locks:void 0;if(n?.request){let o=r.timeoutMs,s=o!==void 0&&typeof AbortController<"u"?new AbortController:null;if(o!==void 0&&!s)return Promise.resolve().then(t);try{let a=!1,l,p=()=>{l!==void 0&&(clearTimeout(l),l=void 0)},d=()=>(a=!0,p(),t()),u=s?n.request(e,{signal:s.signal},d):n.request(e,d);return s&&o!==void 0&&!a&&(l=setTimeout(()=>{l=void 0,s.abort();try{r.onTimeout?.()}catch{}},o)),u.catch(f=>{if(a)throw f;return t()}).finally(p)}catch{}}try{return Promise.resolve(t())}catch(o){return Promise.reject(o)}}function tr(i){return typeof navigator<"u"&&!!navigator.locks?.request}var yi="cbo_outbox",nt="cbo_outbox",vi=500,Si=512*1024;function bi(i){if(!i||typeof i!="object")return!1;let e=i;return typeof e.id=="string"&&e.id!==""&&typeof e.sessionId=="string"&&typeof e.flushAfter=="number"&&Number.isFinite(e.flushAfter)&&typeof e.attempts=="number"&&Number.isFinite(e.attempts)&&typeof e.event=="object"&&e.event!==null}var W=class{constructor(e,t,r=vi,n=Si,o=nt,s=yi){this.storage=e;this.logger=t;this.maxEntries=r;this.maxSerializedLength=n;this.lockName=o;this.storageKey=s;this.entries=this.read()}entries=[];reportedMalformed=!1;read(){let e=this.storage.getItem(this.storageKey);if(!Array.isArray(e))return[];let t=e.filter(bi);return t.length<e.length&&!this.reportedMalformed&&(this.reportedMalformed=!0,this.logger.error(`EventStore dropped ${e.length-t.length} malformed outbox entries`),this.logger.reportTelemetry?.("error","event store dropped malformed outbox entries")),t}mutate(e){return he(0,this.lockName,()=>{try{let t=e(this.read());if(t.length>this.maxEntries){let r=t.length-this.maxEntries;t=t.slice(t.length-this.maxEntries),this.logger.error(`EventStore evicted ${r} oldest entries (cap ${this.maxEntries})`),this.logger.reportTelemetry?.("error","event store evicted entries (cap)")}t=this.enforceSizeBudget(t),this.entries=t,this.storage.setItem(this.storageKey,t)}catch(t){this.logger.error("Failed to mutate event store",t),this.logger.reportTelemetry?.("error","failed to mutate event store")}})}enforceSizeBudget(e){let t=e.map(o=>JSON.stringify(o).length),r=t.reduce((o,s)=>o+s,e.length+1),n=0;for(;r>this.maxSerializedLength&&n<e.length;)r-=t[n]+1,n++;return n===0?e:(this.logger.error(`EventStore evicted ${n} oldest entries (size budget ${this.maxSerializedLength})`),this.logger.reportTelemetry?.("error","event store evicted entries (size budget)"),e.slice(n))}add(e){return this.mutate(t=>t.some(r=>r.id===e.id)?t:[...t,e])}all(){return this.entries=this.read(),this.entries}getDue(e){return this.all().filter(t=>t.flushAfter<=e)}remove(e){if(e.length===0)return Promise.resolve();let t=new Set(e);return this.mutate(r=>r.filter(n=>!t.has(n.id)))}update(e){if(e.length===0)return Promise.resolve();let t=new Map(e.map(r=>[r.id,r]));return this.mutate(r=>r.map(n=>t.get(n.id)??n))}size(){return this.all().length}};var wi=500,Ti=512*1024,rr=200,ir=200*1024,Ei=16*1024,nr=6e4,ot=32e3;function ge(i){let e=0;for(let t=0;t<i.length;t++){let r=i.charCodeAt(t);r<128?e+=1:r<2048?e+=2:r>=55296&&r<=56319&&t+1<i.length?(e+=4,t++):e+=3}return e}var me=class{constructor(e,t,r,n,o={},s){this.logger=e;this.transport=t;this.sessionId=r;this.sdk=n;this.storage=s;if(this.batchSize=o.batchSize||50,this.flushIntervalOverride=o.flushInterval,this.debug=o.debug??!1,this.requestConfig=o.requestConfig??!0,this.onConfigReceived=o.onConfigReceived,this.getDataPolicy=o.getDataPolicy,this.fixedData=o.fixedData===!0,this.beforeEventBatchSend=o.beforeEventBatchSend,this.standaloneDeviceInfo=o.standaloneDeviceInfo,this.config=o.config??b,this.priorityFlowTypes=new Set(this.config.flushOnFlowTypeFinished),this.outboxLockName=o.outboxLockName,this.config.durableOutbox&&this.storage&&(this.store=new W(this.storage,this.logger,void 0,void 0,this.outboxLockName),this.pending=this.store.all()),this.storage){this.lowStore=new W(this.storage,this.logger,1e3,256*1024,`${this.outboxLockName??"cbo_outbox"}:lows`,"cbo_low_outbox_v1");let a=this.lowStore.all();this.lowPending=a.filter(l=>this.validPendingLow(l)),this.lowStore.remove(a.filter(l=>!this.validPendingLow(l)).map(l=>l.id))}this.setupLifecycleHooks(),(this.pending.length>0||this.lowPending.length>0)&&(this.dirtySinceSyncFlush=!0,this.scheduleFlush(0,"recovery"))}pending=[];lowsQueue=[];lowPending=[];lowStore;telemetryQueue=[];probeQueue=[];probeBytes=0;probesDropped=0;timer=null;isFlushing=!1;flushingDone;destroyed=!1;dirtySinceSyncFlush=!1;onVisibilityChange=null;onPageHide=null;removeVisibilityChange=null;removePageHide=null;batchSize;flushIntervalOverride;debug;requestConfig;onConfigReceived;getDataPolicy;fixedData;beforeEventBatchSend;standaloneDeviceInfo;config;priorityFlowTypes;outboxLockName;store;configResolved=!1;setSessionId(e){this.sessionId=e}flushInterval(){return this.flushIntervalOverride??this.config.flushIntervalMs}enqueue(e,t=this.sessionId){try{let r={id:e.id,sessionId:t,flushAfter:0,attempts:0,event:e};this.pending.push(r),this.store?.add(r),this.scheduleAfterEnqueue(e)}catch(r){this.logger.error("Failed to enqueue event",r)}}enqueueLow(e,t=this.sessionId){try{let r={...e,id:e.id??S()};if(this.config.durableLowOutbox){let n={id:r.id,sessionId:t,event:r,attempts:0,flushAfter:0};this.lowPending.push(n),this.lowPending=this.lowPending.slice(-1e3),this.lowStore?.add(n)}else this.lowsQueue.push({sessionId:t,event:r});this.scheduleAfterEnqueue()}catch(r){this.logger.error("Failed to enqueue low event",r)}}notifyDeviceInfo(){try{this.dirtySinceSyncFlush=!0,this.scheduleFlush(this.flushInterval(),"timer")}catch(e){this.logger.error("Failed to schedule device info flush",e)}}enqueueTelemetry(e){try{if(!this.config.telemetry)return;this.telemetryQueue.push(e),this.dirtySinceSyncFlush=!0,this.config.flushOnTelemetry&&this.flush("telemetry")}catch(t){this.logger.error("Failed to enqueue telemetry",t)}}enqueueProbe(e,t=this.sessionId){try{if(this.destroyed)return;let r=JSON.stringify(e.payload);if(typeof r!="string"||ge(r)>Ei){this.probesDropped++;return}let n={...e,payload:JSON.parse(r)},o=ge(JSON.stringify(n));for(this.probeQueue.push({sessionId:t,entry:n,bytes:o,attempts:0,flushAfter:0}),this.probeBytes+=o;this.probeQueue.length>wi||this.probeBytes>Ti&&this.probeQueue.length>1;){let s=this.probeQueue.shift();this.probeBytes-=s.bytes,this.probesDropped++}this.scheduleFlush(this.flushInterval(),"timer")}catch(r){this.logger.error("Failed to enqueue probe",r)}}droppedProbeCount(){return this.probesDropped}dueProbes(e){return this.probeQueue.filter(t=>t.flushAfter<=e)}selectProbes(e,t,r,n){let o=[],s=0;for(let a of e){if(o.length>=r)break;if(a.sessionId===t){if(s+a.bytes>n){o.length===0&&n>=ir&&o.push(a);break}s+=a.bytes,o.push(a)}}return o}removeProbes(e){if(e.length===0)return;let t=new Set(e);this.probeQueue=this.probeQueue.filter(r=>!t.has(r));for(let r of e)this.probeBytes-=r.bytes}dropProbes(e){this.removeProbes(e),this.probesDropped+=e.length}handleProbeSendResult(e,t,r){if(t.length===0)return;let n=e.statusCode;if(typeof n=="number"&&n>=200&&n<300){this.removeProbes(t);return}if(!this.isRetryable(n)){this.dropProbes(t);return}let o=Math.max(1,this.config.retry.maxAttempts),s=this.parseRetryAfter(e),a=[];for(let l of t)l.attempts+=1,l.attempts>=o?a.push(l):l.flushAfter=r+this.backoffForAttempt(l.attempts,s);this.dropProbes(a)}sendUnloadProbes(e,t,r,n){let o=this.sessionId,s={sessionId:o,events:[],sdk:this.sdk,probes:[]};this.attachBatchMeta(s,[],t);let a=ge(JSON.stringify(s))+120,l=e>a?this.selectProbes(this.probeQueue,o,rr,e-a):[];l.length>0&&(s.probes=l.map(p=>p.entry),this.attachBatchMeta(s,l,t),n&&this.config.beaconKeepalive&&this.transport.sendBeacon?this.transport.sendBeacon(s):Promise.resolve(this.transport.send(s)).catch(()=>{}),this.removeProbes(l)),r&&this.dropProbes(this.probeQueue.slice())}scheduleAfterEnqueue(e){if(this.dirtySinceSyncFlush=!0,e!==void 0&&this.isPriorityEvent(e)){this.flush("flow-finished");return}this.scheduleFlush(this.flushInterval(),"timer")}isPriorityEvent(e){if(e.type!=="predefined"||e.name!=="flow_finished"&&e.name!=="flow_auto_finished")return!1;let t=e.data?.flowName;return typeof t=="string"&&this.priorityFlowTypes.has(t)}scheduleFlush(e,t){this.destroyed||this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.flush(t)},e))}clearTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}async flush(e="timer"){if(this.destroyed)return;if(this.isFlushing){if(e==="destroy"){await this.flushingDone;try{this.sendUnloadProbes(ot,e,!0,!1)}catch(r){this.logger.error("Unexpected error in queue flush",r)}}return}this.isFlushing=!0;let t;this.flushingDone=new Promise(r=>{t=r});try{for(this.clearTimer();;){let r=Date.now(),n=this.getDuePending(r),o=this.lowPending.filter(w=>w.flushAfter<=r),s=e==="destroy"?[]:this.dueProbes(r),a=n.length===0&&o.length===0&&this.lowsQueue.length===0&&this.telemetryQueue.length===0&&s.length===0;if(a&&!this.hasStandaloneDeviceInfo())break;let l=n[0]?.sessionId??o[0]?.sessionId??this.lowsQueue[0]?.sessionId??s[0]?.sessionId??this.sessionId,p=n.filter(w=>w.sessionId===l).slice(0,this.batchSize),d=o.filter(w=>w.sessionId===l).slice(0,100),u=[...d.map(w=>w.event),...this.takeLows(l,100-d.length)];this.prepareEvents(p,e);let f=l===this.sessionId?this.takeTelemetry():[],h=l===this.sessionId?this.takeStandaloneDeviceInfo():void 0,m=this.selectProbes(s,l,rr,ir),c={sessionId:l,events:p.map(w=>w.event),sdk:this.sdk};if(u.length>0&&(c.lows=u),f.length>0&&(c.telemetry=f),m.length>0&&(c.probes=m.map(w=>w.entry)),h&&(c.deviceInfo=h),a&&!h)break;this.attachBatchMeta(c,[...p,...d,...m],e),d.length&&(c.deliveryAck=!0);let v=this.shouldRequestConfig()?{[jt]:this.config.version||"1"}:void 0,y=await this.transport.send(c,v).catch(w=>(this.logger.error("Unexpected error in queue flush",w),{}));if(c.deliveryAck&&y.statusCode&&y.statusCode>=200&&y.statusCode<300&&!y.deliveryAccepted&&(y={...y,statusCode:503}),this.requestConfig&&this.handleConfigResponse(y),this.handleLowSendResult(y,d,r),this.handleProbeSendResult(y,m,r),!this.handleSendResult(y,p,r))break}e==="destroy"&&this.sendUnloadProbes(ot,e,!0,!1)}catch(r){this.logger.error("Unexpected error in queue flush",r)}finally{this.isFlushing=!1,t(),this.flushingDone=void 0,this.rescheduleIfPending()}}attachBatchMeta(e,t,r){e.meta={...e.meta,flushReason:r};let n=this.readDataPolicy();n!==void 0&&(e.meta={...e.meta,dataPolicy:n}),this.config.version&&(e.meta={...e.meta,configVersion:this.config.version}),this.fixedData&&(e.meta={...e.meta,fixedData:!0});let o=t.reduce((s,a)=>Math.max(s,a.attempts),0);o>0&&(e.meta={...e.meta,retryCount:o})}prepareEvents(e,t){if(!(!this.beforeEventBatchSend||e.length===0))try{this.beforeEventBatchSend(e.map(r=>r.event),t)}catch(r){this.logger.error("Failed to prepare events for sending",r)}}readDataPolicy(){try{return this.getDataPolicy?.()}catch(e){this.logger.debug("Failed to read data policy for batch meta",e);return}}getDuePending(e){return this.pending.filter(t=>t.flushAfter<=e)}takeLows(e=this.sessionId,t=100){let r=this.lowsQueue.filter(o=>o.sessionId===e).slice(0,t),n=new Set(r);return this.lowsQueue=this.lowsQueue.filter(o=>!n.has(o)),r.map(o=>o.event)}validPendingLow(e){return typeof e.event?.lowType=="string"&&e.event.id===e.id&&Number.isFinite(e.event.ts)&&e.event.ts>Date.now()-7*864e5}removeLowEntries(e){let t=new Set(e);this.lowPending=this.lowPending.filter(r=>!t.has(r.id)),this.lowStore?.remove(e)}handleLowSendResult(e,t,r){let n=e.statusCode;if(n!==void 0&&n>=200&&n<300){e.deliveryAccepted?this.removeLowEntries(t.map(o=>o.id)):this.deferLowEntries(t,r);return}if(!this.isRetryable(n)){this.removeLowEntries(t.map(o=>o.id)),this.logger.reportTelemetry?.("error","low events rejected by ingestion");return}this.deferLowEntries(t,r,this.parseRetryAfter(e))}deferLowEntries(e,t,r=null){let n=[];for(let o of e){if(!this.validPendingLow(o)){n.push(o.id);continue}o.attempts=Math.min(o.attempts+1,16),o.flushAfter=t+Math.max(Math.min(6e4,1e3*2**Math.min(o.attempts,6)),this.backoffForAttempt(o.attempts,r))}this.removeLowEntries(n),this.lowStore?.update(e.filter(o=>!n.includes(o.id)))}hasStandaloneDeviceInfo(){try{return this.standaloneDeviceInfo?.has()??!1}catch(e){return this.logger.error("Failed to read device info for batch",e),!1}}takeStandaloneDeviceInfo(){try{return this.standaloneDeviceInfo?.take()}catch(e){this.logger.error("Failed to read device info for batch",e);return}}takeTelemetry(){let e=this.telemetryQueue;return this.telemetryQueue=[],e}shouldRequestConfig(){return this.requestConfig&&!this.configResolved}handleConfigResponse(e){let t=e.statusCode;typeof t=="number"&&t>=200&&t<300&&(this.configResolved=!0),e.config&&(this.config.version||this.updateConfig(e.config),this.onConfigReceived?.(e.config))}updateConfig(e){if(this.destroyed)return;let t=this.config.flushIntervalMs!==e.flushIntervalMs;if(this.config={...e,durableOutbox:this.config.durableOutbox||e.durableOutbox},this.priorityFlowTypes=new Set(e.flushOnFlowTypeFinished),e.durableLowOutbox&&this.lowsQueue.length){let n=this.lowsQueue;this.lowsQueue=[];for(let{event:o,sessionId:s}of n)this.enqueueLow(o,s)}let r=!1;if(this.config.durableOutbox&&this.storage&&!this.store){this.store=new W(this.storage,this.logger,void 0,void 0,this.outboxLockName);let n=new Set(this.pending.map(s=>s.id)),o=this.store.all().filter(s=>!n.has(s.id));for(let s of this.pending)this.store.add(s);this.pending=[...o,...this.pending],r=o.length>0}r?(this.dirtySinceSyncFlush=!0,this.clearTimer(),this.scheduleFlush(0,"recovery")):t&&(this.clearTimer(),this.rescheduleIfPending())}handleSendResult(e,t,r){let n=e.statusCode,o=typeof n=="number"&&n>=200&&n<300;if(t.length===0)return o;if(o)return this.removeEntries(t.map(d=>d.id)),!0;if(!this.isRetryable(n))return this.removeEntries(t.map(d=>d.id)),!1;let s=Math.max(1,this.config.retry.maxAttempts),a=this.parseRetryAfter(e),l=[],p=[];for(let d of t)d.attempts+=1,d.attempts>=s?l.push(d.id):(d.flushAfter=r+this.backoffForAttempt(d.attempts,a),p.push(d));return this.removeEntries(l),this.store?.update(p),!1}isRetryable(e){return e===void 0||e===408||e===429?!0:e>=500}backoffForAttempt(e,t){let r=this.config.retry,n=r.baseDelayMs*Math.pow(2,Math.max(0,e-1));r.maxDelayMs>0&&(n=Math.min(n,r.maxDelayMs));let o=Math.round(n/2+Math.random()*(n/2));return t!==null&&(o=Math.max(o,t)),o}parseRetryAfter(e){let t=e.headers?.["retry-after"];if(!t)return null;let r=Number(t);if(!Number.isNaN(r))return r*1e3;let n=Date.parse(t);return Number.isNaN(n)?null:Math.max(0,n-Date.now())}removeEntries(e){if(e.length===0)return;let t=new Set(e);this.pending=this.pending.filter(r=>!t.has(r.id)),this.store?.remove(e)}rescheduleIfPending(){try{if(this.destroyed||this.timer||this.pending.length===0&&this.lowPending.length===0&&this.lowsQueue.length===0&&this.probeQueue.length===0)return;let e=Date.now();if(this.getDuePending(e).length>0||this.lowPending.some(r=>r.flushAfter<=e)||this.lowsQueue.length>0||this.probeQueue.some(r=>r.flushAfter<=e)){this.scheduleFlush(this.flushInterval(),"timer");return}let t=Math.min(...[...this.pending,...this.lowPending,...this.probeQueue].map(r=>r.flushAfter));this.scheduleFlush(Math.max(0,t-e),"backoff")}catch(e){this.logger.error("Failed to reschedule queue flush",e)}}setupLifecycleHooks(){typeof window>"u"||(this.onVisibilityChange=()=>{try{this.writeLifecycleDebugOutput("cbo_visibility_change_debug"),de(0)&&this.config.tvc&&this.flushSync("visibility-change")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},this.onPageHide=()=>{try{this.writeLifecycleDebugOutput("cbo_pagehide_debug"),this.config.tph&&this.flushSync("pagehide")}catch(e){this.logger.error("Unexpected error in queue flushSync",e)}},this.removeVisibilityChange=x(0,"visibilitychange",this.onVisibilityChange),this.removePageHide=x(0,"pagehide",this.onPageHide))}writeLifecycleDebugOutput(e){if(!this.debug||!this.storage)return;let t={last_executed:Date.now(),url:At(0)};this.storage.setItem(e,t)}flushKeepalive(e="manual"){this.flushSync(e)}flushSync(e){let t=this.flushSyncEvents(e);e==="pagehide"&&this.probeQueue.length>0&&this.sendUnloadProbes(Math.min(nr-t,ot),e,!0,!0)}flushSyncEvents(e){if(!this.dirtySinceSyncFlush)return 0;let t=this.sessionId,r=this.pending.filter(d=>d.sessionId===t),n=r.slice(0,this.batchSize),o=this.lowPending.filter(d=>d.sessionId===t).slice(0,100),s=[...o.map(d=>d.event),...this.takeLows(t,100-o.length)];this.prepareEvents(n,e);let a=this.takeTelemetry(),l=this.takeStandaloneDeviceInfo();if(n.length===0&&s.length===0&&a.length===0&&!l)return this.dirtySinceSyncFlush=!1,0;let p={sessionId:t,events:n.map(d=>d.event),sdk:this.sdk};return s.length>0&&(p.lows=s),a.length>0&&(p.telemetry=a),l&&(p.deviceInfo=l),this.attachBatchMeta(p,[...n,...o],e),o.length&&(p.deliveryAck=!0),this.config.beaconKeepalive&&this.transport.sendBeacon?this.transport.sendBeacon(p)||this.transport.send(p):this.transport.send(p),this.config.durableOutbox||this.removeEntries(n.map(d=>d.id)),this.dirtySinceSyncFlush=!this.config.durableOutbox&&r.length>n.length,this.approximateSize(p)}approximateSize(e){try{return ge(JSON.stringify(e))}catch{return nr}}destroy(){try{this.destroyed=!0,this.clearTimer(),this.dropProbes(this.probeQueue.slice()),typeof window<"u"&&(this.removeVisibilityChange&&this.removeVisibilityChange(),this.removePageHide&&this.removePageHide())}catch(e){this.logger.error("Failed to destroy queue lifecycle hooks",e)}}};var st={d:(i,e)=>{for(var t in e)st.o(e,t)&&!st.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:e[t]})},o:(i,e)=>Object.prototype.hasOwnProperty.call(i,e)},at={};st.d(at,{A:()=>Ii,k:()=>or});var $=function(i,e,t,r){return new(t||(t=Promise))(function(n,o){function s(p){try{l(r.next(p))}catch(d){o(d)}}function a(p){try{l(r.throw(p))}catch(d){o(d)}}function l(p){var d;p.done?n(p.value):(d=p.value,d instanceof t?d:new t(function(u){u(d)})).then(s,a)}l((r=r.apply(i,e||[])).next())})},Q=function(i,e){var t,r,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(p){return(function(d){if(t)throw new TypeError("Generator is already executing.");for(;o&&(o=0,d[0]&&(s=0)),s;)try{if(t=1,r&&(n=2&d[0]?r.return:d[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,d[1])).done)return n;switch(r=0,n&&(d=[2&d[0],n.value]),d[0]){case 0:case 1:n=d;break;case 4:return s.label++,{value:d[1],done:!1};case 5:s.label++,r=d[1],d=[0];continue;case 7:d=s.ops.pop(),s.trys.pop();continue;default:if(n=s.trys,!((n=n.length>0&&n[n.length-1])||d[0]!==6&&d[0]!==2)){s=0;continue}if(d[0]===3&&(!n||d[1]>n[0]&&d[1]<n[3])){s.label=d[1];break}if(d[0]===6&&s.label<n[1]){s.label=n[1],n=d;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(d);break}n[2]&&s.ops.pop(),s.trys.pop();continue}d=e.call(i,s)}catch(u){d=[6,u],r=0}finally{t=n=0}if(5&d[0])throw d[1];return{value:d[0]?d[1]:void 0,done:!0}})([l,p])}}};function or(){return $(this,void 0,Promise,function(){return Q(this,function(i){switch(i.label){case 0:return[4,new Promise(function(e,t){var r="Unknown",n=!1;function o(d){n||(n=!0,e({isPrivate:d,browserName:r}))}function s(){var d=0,u=parseInt("-1");try{u.toFixed(u)}catch(f){d=f.message.length}return d}function a(){return $(this,void 0,void 0,function(){var d,u;return Q(this,function(f){switch(f.label){case 0:return f.trys.push([0,2,,3]),[4,navigator.storage.getDirectory()];case 1:return f.sent(),o(!1),[3,3];case 2:return d=f.sent(),u=d instanceof Error&&typeof d.message=="string"?d.message:String(d),o(u.includes("unknown transient reason")),[3,3];case 3:return[2]}})})}function l(){var d;return $(this,void 0,Promise,function(){return Q(this,function(u){switch(u.label){case 0:return typeof((d=navigator.storage)===null||d===void 0?void 0:d.getDirectory)!="function"?[3,2]:[4,a()];case 1:return u.sent(),[3,3];case 2:navigator.maxTouchPoints!==void 0?(function(){var f=String(Math.random());try{var h=indexedDB.open(f,1);h.onupgradeneeded=function(m){var c=m.target.result,v=function(y){o(y)};try{c.createObjectStore("t",{autoIncrement:!0}).put(new Blob),v(!1)}catch(y){(y instanceof Error&&typeof y.message=="string"?y.message:String(y)).includes("are not yet supported")?v(!0):v(!1)}finally{c.close(),indexedDB.deleteDatabase(f)}},h.onerror=function(){return o(!1)}}catch{o(!1)}})():(function(){var f=window.openDatabase,h=window.localStorage;try{f(null,null,null,null)}catch{return void o(!0)}try{h.setItem("test","1"),h.removeItem("test")}catch{return void o(!0)}o(!1)})(),u.label=3;case 3:return[2]}})})}function p(){var d;return $(this,void 0,Promise,function(){var u,f,h;return Q(this,function(m){switch(m.label){case 0:if(typeof((d=navigator.storage)===null||d===void 0?void 0:d.getDirectory)!="function")return[3,5];m.label=1;case 1:return m.trys.push([1,3,,4]),[4,navigator.storage.getDirectory()];case 2:return m.sent(),o(!1),[3,4];case 3:return u=m.sent(),f=u instanceof Error&&typeof u.message=="string"?u.message:String(u),o(f.includes("Security error")),[2];case 4:return[3,6];case 5:(h=indexedDB.open("inPrivate")).onerror=function(c){if(h.error&&h.error.name==="InvalidStateError")return c.preventDefault(),void o(!0);o(!1)},h.onsuccess=function(){indexedDB.deleteDatabase("inPrivate"),o(!1)},m.label=6;case 6:return[2]}})})}(function(){return $(this,void 0,Promise,function(){return Q(this,function(d){switch(d.label){case 0:return s()!==44&&s()!==43?[3,2]:(r="Safari",[4,l()]);case 1:return d.sent(),[3,6];case 2:return s()!==51?[3,3]:(u=navigator.userAgent,r=u.match(/Chrome/)?navigator.brave!==void 0?"Brave":u.match(/Edg/)?"Edge":u.match(/OPR/)?"Opera":"Chrome":"Chromium",(function(){var f=this,h="__di_"+Math.random().toString(36).slice(2),m=new Uint8Array(16384),c=indexedDB.open(h,1);c.onupgradeneeded=function(){c.result.createObjectStore("s")},c.onerror=function(){indexedDB.deleteDatabase(h),o(!1)},c.onsuccess=function(){var v=c.result,y=!1;try{var w=v.transaction("s","readwrite",{durability:"strict"});y=w.durability==="strict",w.abort()}catch{}if(!y)return v.close(),indexedDB.deleteDatabase(h),void o(!1);var T=function(Y){return new Promise(function(F,X){var J=performance.now(),N=0,O=function(){if(N!==15){var _=v.transaction("s","readwrite",{durability:Y});_.objectStore("s").put(m,N),N++,_.oncomplete=O,_.onerror=_.onabort=function(){return X(_.error)}}else F(performance.now()-J)};O()})};$(f,void 0,void 0,function(){var Y,F,X,J,N;return Q(this,function(O){switch(O.label){case 0:return Y=performance.now(),[4,T("relaxed")];case 1:return O.sent(),[4,T("strict")];case 2:O.sent(),F=[],X=0,O.label=3;case 3:return X<15?[4,T("relaxed")]:[3,7];case 4:return J=O.sent(),[4,T("strict")];case 5:if(N=O.sent(),F.push(J>0?N/J:1/0),F.length>=7&&performance.now()-Y>=1e3)return[3,7];O.label=6;case 6:return X++,[3,3];case 7:return F.sort(function(_,zr){return _-zr}),v.close(),indexedDB.deleteDatabase(h),o(F[F.length>>1]<1.3),[2]}})}).catch(function(){v.close(),indexedDB.deleteDatabase(h),o(!1)})}})(),[3,6]);case 3:return s()!==25?[3,5]:(r="Firefox",[4,p()]);case 4:return d.sent(),[3,6];case 5:navigator.msSaveBlob!==void 0?(r="Internet Explorer",o(window.indexedDB===void 0)):t(new Error("detectIncognito cannot determine the browser")),d.label=6;case 6:return[2]}var u})})})().catch(t)})];case 1:return[2,i.sent()]}})})}var Ii=or,sr=at.A,Lo=at.k;async function ar(i){return(await sr()).isPrivate}var ki=300,re=6e3,lr="cbo_pm",xi=10080*60*1e3,dr="detectincognitojs@1.9.0",pr={timing:!1},lt="cbo_tab_id",ur={bluetoothAvailable:"bt",clientCapabilities:"cc",userVerifyingPlatformAuthenticatorAvailable:"uvpaa",conditionalMediationAvailable:"cm",javaScriptHighEntropy:"he",privateMode:"pm",webdriver:"wd",maxTouchPoints:"mtp"};function P(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function cr(i,e,t){return{field:i,source:e,error:{name:"TimeoutError",message:`Device info collection timed out after ${t}ms`}}}async function dt(i,e){let t;try{return await Promise.race([i.then(()=>!0,()=>!0),new Promise(r=>{t=setTimeout(()=>r(!1),Math.max(0,e))})])}finally{t&&clearTimeout(t)}}var ye=class{constructor(e,t,r="localstorage",n,o=()=>pr,s,a=!0){this.logger=e;this.storage=t;this.storageSource=r;this.sessionStorage=n;this.settings=o;this.emitTelemetry=s;this.privateModeEnabled=a}pagePrivateMode;privateModeDetectionStarted=!1;lastKnown={};async collect(e,t={}){try{let r=this.resolveSettings(),n=P(),o=this.getClientEnvHandle(),s={type:"web",clientEnvHandle:o.value,clientEnvHandleMeta:{timestamp:o.timestamp,source:o.source},tabId:this.getTabId()},a=typeof __CBO_DATA_PRIVATE_MODE__=="boolean"?__CBO_DATA_PRIVATE_MODE__:this.privateModeEnabled,l=a?this.knownPrivateMode(r.timing):void 0,p,d=a&&l===void 0&&!this.privateModeDetectionStarted?this.detectPrivateMode(r.timing).then(T=>{p=T}):void 0,u=this.startFastFields();await dt(Promise.all(u.map(T=>T.promise)),ki);let f=P()-n,h=t.refresh?this.lastKnown:{};r.timing&&this.reportFastTiming(f,u);let m=()=>p?.error?[p.error]:[];this.safePublish(e,this.buildInfo(s,u,p?p.value:l,h,m()),"fast");let c=u.filter(T=>!T.settled),v=d!==void 0&&p===void 0;if(c.length===0&&!v)return;let y=P();await Promise.all([dt(Promise.all(c.map(T=>T.promise)),re-(y-n)),d]);let w=c.filter(T=>!T.settled).map(T=>cr(T.field,T.source,re));w.push(...m()),r.timing&&c.length>0&&this.reportLateTiming(P()-n,c),this.safePublish(e,this.buildInfo(s,u,p?p.value:l,h,w),"update")}catch(r){this.logger.error("Failed to collect device info",r)}}async getInfo(){let e;return await this.collect(t=>{e=t}),e??{}}startFastFields(){return[this.startField("bluetoothAvailable","navigator.bluetooth.getAvailability",()=>Ht(0)),this.startField("clientCapabilities","PublicKeyCredential.getClientCapabilities",()=>Ut(0)),this.startField("userVerifyingPlatformAuthenticatorAvailable","PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable",()=>Bt(0)),this.startField("conditionalMediationAvailable","PublicKeyCredential.isConditionalMediationAvailable",()=>Nt(0)),this.startField("javaScriptHighEntropy","navigator.userAgentData.getHighEntropyValues",()=>qt(0)),this.startField("webdriver","navigator.webdriver",()=>Kt(0)),this.startField("maxTouchPoints","navigator.maxTouchPoints",()=>Vt(0))]}startField(e,t,r){let n=P(),o={field:e,source:t};return o.promise=Promise.resolve().then(r).then(s=>({field:e,value:s,durationMs:P()-n}),s=>(this.logger.error(`Failed to collect device info field "${e}"`,s),{field:e,durationMs:P()-n,error:{field:e,source:t,error:U(s)??{message:"Unknown error"}}})).then(s=>(o.settled=s,s)),o}buildInfo(e,t,r,n,o){let s={},a=[];for(let p of t)p.settled?(p.settled.error&&a.push(p.settled.error),s[p.field]=p.settled.value,this.remember(p.field,p.settled.value)):s[p.field]=n[p.field];s.privateMode=r,a.push(...o);let l={...e,data:{bluetoothAvailable:s.bluetoothAvailable,javaScriptHighEntropy:s.javaScriptHighEntropy,privateMode:s.privateMode,webdriver:s.webdriver,conditionalMediationAvailable:s.conditionalMediationAvailable,userVerifyingPlatformAuthenticatorAvailable:s.userVerifyingPlatformAuthenticatorAvailable,clientCapabilities:s.clientCapabilities,maxTouchPoints:s.maxTouchPoints}};return a.length>0&&(l.collectionErrors=a),l}remember(e,t){t!==void 0&&(this.lastKnown[e]=t)}safePublish(e,t,r){try{e(t,r)}catch(n){this.logger.error("Failed to publish device info",n)}}knownPrivateMode(e){if(this.pagePrivateMode!==void 0)return this.pagePrivateMode;let t=this.readPrivateModeCache();return t&&(this.pagePrivateMode=t.value,e&&this.reportTelemetry(`device info privateMode from cache, age ${Math.round((Date.now()-t.ts)/1e3)}s`)),this.pagePrivateMode}canCachePrivateMode(){return this.storageSource==="localstorage"}readPrivateModeCache(){if(this.canCachePrivateMode())try{let e=this.storage.getItem(lr);if(!e||typeof e!="object"||typeof e.value!="boolean"||typeof e.ts!="number"||e.dv!==dr)return;let t=Date.now()-e.ts;return t<0||t>=xi?void 0:e}catch(e){this.logger.debug("Failed to read cached privateMode",e);return}}writePrivateModeCache(e){if(this.canCachePrivateMode())try{this.storage.setItem(lr,{value:e,ts:Date.now(),dv:dr})}catch(t){this.logger.error("Failed to cache privateMode",t)}}async detectPrivateMode(e){this.privateModeDetectionStarted=!0;let t="detectIncognito",r=P(),n=this.startField("privateMode",t,()=>typeof __CBO_DATA_PRIVATE_MODE__=="boolean"&&!__CBO_DATA_PRIVATE_MODE__?void 0:ar(0));if(!await dt(n.promise,re)||!n.settled)return e&&this.reportTelemetry(`device info privateMode timed out after ${re}ms`),{error:cr("privateMode",t,re)};if(e&&this.reportTelemetry(`device info privateMode detected in ${Math.round(P()-r)}ms`),n.settled.error)return{error:n.settled.error};let s=n.settled.value;return typeof s!="boolean"?{value:void 0}:(this.pagePrivateMode=s,this.writePrivateModeCache(s),{value:s})}resolveSettings(){try{return{timing:this.settings()?.timing===!0}}catch(e){return this.logger.error("Failed to resolve device info collector settings",e),pr}}reportFastTiming(e,t){let r=t.map(n=>`${ur[n.field]}=${Math.round(n.settled?.durationMs??e)}`).join(",");this.reportTelemetry(`device info collected in ${Math.round(e)}ms (${r})`)}reportLateTiming(e,t){let r=t.map(n=>`${ur[n.field]}=${n.settled?Math.round(n.settled.durationMs):"timeout"}`).join(",");this.reportTelemetry(`device info late fields done in ${Math.round(e)}ms (${r})`)}reportTelemetry(e){if(this.emitTelemetry)try{this.emitTelemetry("info",e)}catch(t){this.logger.error("Failed to report device info timing",t)}}static getOsAndBrowserInfo(){return{osName:this.getOsName(),browserName:this.getBrowserName()}}static getUserAgent(){return pe(0)}static getOsName(){let e=this.getUserAgent();return e.includes("iOS")?"iOS":e.includes("Android")?"Android":e.includes("Windows")?"Windows":e.includes("Macintosh")?"macOS":e.includes("Linux")?"Linux":e.includes("ChromeOS")?"ChromeOS":"other"}static getBrowserName(){let e=this.getUserAgent();return e.includes("Chrome")?"Chrome":e.includes("Firefox")?"Firefox":e.includes("Safari")?"Safari":e.includes("Edge")?"Edge":e.includes("Opera")?"Opera":e.includes("IE")?"IE":"other"}getClientEnvHandle(){let e=this.storage.getItem("cbo_client_env_handle");if(e)return e;let t=S(),r={timestamp:Date.now(),source:this.storageSource,value:t};return this.storage.setItem("cbo_client_env_handle",r),r}getTabId(){if(!this.sessionStorage)return;let e=this.sessionStorage.getItem(lt);if(e)return e;let t=S();if(this.sessionStorage.setItem(lt,t),this.sessionStorage.getItem(lt)===t)return t}};function Oi(){return typeof document<"u"&&de(0)}var ve=class{constructor(e,t,r,n,o,s){this.logger=e;this.source=t;this.refreshInterval=r;this.attachInterval=n;this.diagnostics=o;this.onUndelivered=s}snapshot;snapshotPhase;publishedAt=0;version=0;deliveredVersion=0;refreshedAt=0;lastAttachedAt=null;eventsSeen=!1;refreshPromise;timer;destroyed=!1;start(){this.refresh()}getForEvent(){if(this.eventsSeen=!0,Date.now()-this.refreshedAt>=this.refreshInterval&&this.refresh(),!!this.snapshot){if(this.version!==this.deliveredVersion)return this.markDelivered("event");if(!(this.lastAttachedAt!==null&&Date.now()-this.lastAttachedAt<this.attachInterval))return this.lastAttachedAt=Date.now(),this.snapshot}}hasUndelivered(){return this.snapshot!==void 0&&this.version!==this.deliveredVersion}takeUndelivered(){if(this.hasUndelivered())return this.markDelivered("flush")}hasStandalone(){return this.eventsSeen&&this.hasUndelivered()}takeStandalone(){if(this.hasStandalone())return this.markDelivered("request")}destroy(){this.destroyed=!0,this.timer&&(clearTimeout(this.timer),this.timer=void 0)}markDelivered(e){return this.deliveredVersion=this.version,this.lastAttachedAt=Date.now(),this.snapshotPhase==="update"&&this.report(`device info update delivered via ${e} after ${Math.max(0,Date.now()-this.publishedAt)}ms`),this.snapshot}publish(e,t){if(t==="fast"&&(this.refreshedAt=Date.now()),!(this.snapshot&&JSON.stringify(this.snapshot)===JSON.stringify(e))&&(this.snapshot=e,this.snapshotPhase=t,this.publishedAt=Date.now(),this.version++,this.eventsSeen&&this.onUndelivered))try{this.onUndelivered()}catch(r){this.logger.error("Failed to announce undelivered device info",r)}}report(e){if(this.diagnostics)try{this.diagnostics.timing()&&this.diagnostics.emit("info",e)}catch(t){this.logger.error("Failed to report device info delivery",t)}}scheduleRefresh(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.refresh()},this.refreshInterval)}refresh(){if(this.refreshPromise)return this.refreshPromise;if(this.timer&&(clearTimeout(this.timer),this.timer=void 0),this.snapshot&&Oi())return this.destroyed||this.scheduleRefresh(),Promise.resolve();let e=this.snapshot!==void 0;return this.refreshPromise=Promise.resolve().then(()=>this.source.collect((t,r)=>this.publish(t,r),{refresh:e})).catch(t=>this.logger.error("Failed to refresh device info",t)).finally(()=>{this.refreshPromise=void 0,this.destroyed||this.scheduleRefresh()}),this.refreshPromise}};function fr(i){return{getItem:e=>localStorage.getItem(e),setItem:(e,t)=>localStorage.setItem(e,t),removeItem:e=>localStorage.removeItem(e)}}function hr(i){return{getItem:e=>sessionStorage.getItem(e),setItem:(e,t)=>sessionStorage.setItem(e,t),removeItem:e=>sessionStorage.removeItem(e)}}function gr(i){return{read:()=>document.cookie,write:e=>{document.cookie=e}}}function L(i,e){return`${i}_${e}`}var Se=class{constructor(e,t){this.engine=e;this.namespace=t}getItem(e){return this.engine.getItem(L(e,this.namespace))}setItem(e,t){this.engine.setItem(L(e,this.namespace),t)}removeItem(e){this.engine.removeItem(L(e,this.namespace))}},be=class{constructor(e){this.logger=e}area=fr(0);getItem(e){try{if(typeof localStorage>"u")return null;let t=this.area.getItem(e);return t?JSON.parse(t):null}catch(t){return this.logger.error(`LocalStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof localStorage>"u")return;this.area.setItem(e,JSON.stringify(t))}catch(r){this.logger.error(`LocalStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`localStorage.setItem failed: ${e}`)}}removeItem(e){try{if(typeof localStorage>"u")return;this.area.removeItem(e)}catch(t){this.logger.error(`LocalStorage.removeItem failed for key "${e}"`,t)}}},we=class{constructor(e,t){this.logger=e;this.domain=t}jar=gr(0);getItem(e){try{if(typeof document>"u")return null;let t=e+"=",r=this.jar.read().split(";");for(let n=0;n<r.length;n++){let o=r[n].trim();if(o.indexOf(t)===0){let s=o.substring(t.length);return JSON.parse(decodeURIComponent(s))}}return null}catch(t){return this.logger.error(`CookieStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof document>"u")return;let r=`${e}=${encodeURIComponent(JSON.stringify(t))}; path=/; SameSite=Lax`;this.domain&&(r+=`; domain=${this.domain}`),this.jar.write(r)}catch(r){this.logger.error(`CookieStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`cookie.setItem failed: ${e}`)}}removeItem(e){try{if(typeof document>"u")return;let t=`${e}=; Max-Age=-99999999; path=/`;this.domain&&(t+=`; domain=${this.domain}`),this.jar.write(t)}catch(t){this.logger.error(`CookieStorage.removeItem failed for key "${e}"`,t)}}},Te=class{constructor(e){this.logger=e}area=hr(0);getItem(e){try{if(typeof sessionStorage>"u")return null;let t=this.area.getItem(e);return t?JSON.parse(t):null}catch(t){return this.logger.error(`SessionStorage.getItem failed for key "${e}"`,t),null}}setItem(e,t){try{if(typeof sessionStorage>"u")return;this.area.setItem(e,JSON.stringify(t))}catch(r){this.logger.error(`SessionStorage.setItem failed for key "${e}"`,r),this.logger.reportTelemetry?.("error",`sessionStorage.setItem failed: ${e}`)}}removeItem(e){try{if(typeof sessionStorage>"u")return;this.area.removeItem(e)}catch(t){this.logger.error(`SessionStorage.removeItem failed for key "${e}"`,t)}}};var Ee=1,Ie="cbo_storage_schema",Ci=["cbo_seq","cbo_sdk_config","cbo_experiments","cbo_client_env_handle","cbo_outbox","cbo_visibility_change_debug","cbo_pagehide_debug","cbo_session"],Pi=["cbo_session_id","cbo_tab_id"],Li=["cbo_client_env_handle"];function ke(i,e,t){return i.setItem(e,t),JSON.stringify(i.getItem(e))===JSON.stringify(t)}function pt(i,e,t){let r=i.getItem(Ie);if(r!==null){if(r.version!==Ee||r.projectId!==e)return!1;if(r.complete===!0)return!0;if(r.complete!==!1)return!1}else{if(t.some(n=>i.getItem(L(n,e))!==null))return ke(i,Ie,{version:Ee,projectId:e,complete:!0});if(!ke(i,Ie,{version:Ee,projectId:e,complete:!1}))return!1}for(let n of t){let o=L(n,e);if(i.getItem(o)!==null)continue;let s=i.getItem(n);if(s!==null&&!ke(i,o,s))return!1}return ke(i,Ie,{version:Ee,projectId:e,complete:!0})}function mr(i,e,t,r,n){try{if(!pt(e,i,Ci))return;pt(t,i,Pi),r&&pt(r,i,Li)}catch(o){n.error("Failed to migrate legacy Observe storage",o)}}var Fi=10*1e3,Ri=600*1e3,Di=[1e3,3e3],xe=class{constructor(e,t,r){this.url=e;this.storage=t;this.logger=r;this.initialConfig=Jt(t)??void 0}initialConfig;refreshTimer;requestTimer;retryTimer;controller;fetching=!1;stopped=!1;onConfig;start(e){this.stopped||this.onConfig||(this.onConfig=e,this.fetchConfig())}async fetchConfig(e=0){if(this.stopped||this.fetching)return;e===0&&(clearTimeout(this.refreshTimer),clearTimeout(this.retryTimer),this.refreshTimer=setTimeout(()=>{this.fetchConfig()},Ri)),this.fetching=!0;let t=typeof AbortController<"u"?new AbortController:void 0;this.controller=t,this.requestTimer=t?setTimeout(()=>t.abort(),Fi):void 0;let r=!0;try{let n=await ce(0,this.url,{method:"GET",cache:"no-store",...t?{signal:t.signal}:{}});if(!n.ok)throw r=(n.status===408||n.status===429||n.status>=500)&&!n.headers.has("Retry-After"),new Error(`SDK config request failed (${n.status})`);let o=await n.json();r=!1;let s=te(o);if(!s)throw new Error("Invalid SDK config response");if(this.stopped||t?.signal.aborted)return;Zt(this.storage,s),this.onConfig?.(s)}catch(n){if(!this.stopped){this.logger.error("Failed to fetch SDK config",n);let o=Di[e];(r&&!(n instanceof SyntaxError)||t?.signal.aborted)&&o!==void 0&&(this.retryTimer=setTimeout(()=>{this.fetchConfig(e+1)},o))}}finally{clearTimeout(this.requestTimer),this.requestTimer=void 0,this.controller=void 0,this.fetching=!1}}destroy(){this.stopped=!0,clearTimeout(this.refreshTimer),clearTimeout(this.requestTimer),clearTimeout(this.retryTimer),this.controller?.abort(),this.onConfig=void 0}};var G=class{constructor(e,t){this.logger=e;this.sink=t}lease;destroyed=!1;arm(e,t=!1){if(this.disarm(),!(this.destroyed||t))try{this.lease=this.sink.beginCeremony?.(e)}catch(r){this.logger.error("Failed to register ceremony low-event context",r)}}scheduleDisarm(e){try{this.lease?.settle(e)}catch(t){this.logger.error("Failed to settle ceremony low-event context",t)}}disarm(){try{this.lease?.destroy()}catch(e){this.logger.error("Failed to release ceremony low-event context",e)}this.lease=void 0}destroy(){this.disarm(),this.destroyed=!0}};var Oe=class extends g{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-login"),this.lowEventTracker=new G(e.getLogger(),this.lowEventSink("ceremony")),this.registerLowFlusher(()=>this.lowEventTracker.disarm()),this.getOptions=this.defineStep("get-options"),this.ceremony=this.withWindowLowEvents(this.defineStep("ceremony"),this.lowEventTracker),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType})}trigger(e,t){super.trigger(e,t)}destroy(){this.lowEventTracker.destroy()}};var z=class{constructor(e,t,r,n){this.previousLength=e;this.pushLow=t;this.logger=r;this.reserveCaptureSeq=n}prefillSettled=!1;inputBatch=null;currentEffect="modify";ringEffect="modify";autofillTimestamps=[];autofillStreak=null;idleTimer=null;markInputObserved(){this.prefillSettled=!0}capturePrefill(e,t=!1){t&&(this.prefillSettled=!1),!this.prefillSettled&&(this.previousLength=e,e!==0&&(this.prefillSettled=!0,this.pushLow({lowType:"input-prefill",ts:Date.now(),initiator:"unknown"})))}flush(){this.cancelIdle(),this.flushInputBatch(),this.flushAutofillStreak()}cancelIdle(){this.idleTimer!==null&&clearTimeout(this.idleTimer),this.idleTimer=null}scheduleIdle(){this.cancelIdle(),this.idleTimer=setTimeout(()=>{this.idleTimer=null;try{this.flushInputBatch(!0),this.flushAutofillStreak()}catch(e){this.logger.error("Failed to flush idle input",e)}},3e3)}extendInputBatch(e,t=this.currentEffect,r){let n=this.inputBatch;if(!n){this.inputBatch={firstTimestamp:e,lastTimestamp:e,effect:t,captureSeq:r};return}n.lastTimestamp=e}drainAutofillRingToBatch(){for(let e of this.autofillTimestamps)this.extendInputBatch(e.ts,this.ringEffect,e.captureSeq);this.autofillTimestamps.length=0}flushInputBatch(e=!1){this.drainAutofillRingToBatch();let t=this.inputBatch;t&&(this.pushLow({...t.captureSeq===void 0?{}:{captureSeq:t.captureSeq},lowType:e?"input-idle":"input",ts:t.firstTimestamp,durationMs:t.lastTimestamp-t.firstTimestamp,inputEffect:t.effect}),this.inputBatch=null)}flushAutofillStreak(){let e=this.autofillStreak;e&&(this.pushLow({...e.captureSeq===void 0?{}:{captureSeq:e.captureSeq},lowType:"big-input-add",ts:e.firstTimestamp,durationMs:e.lastTimestamp-e.firstTimestamp,inputEffect:e.effect}),this.autofillStreak=null)}detectAutofillStreak(){let e=this.autofillTimestamps;if(e.length<5)return!1;let t=1/0,r=-1/0;for(let n=1;n<e.length;n++){let o=e[n].ts-e[n-1].ts;if(o>80)return!1;o<t&&(t=o),o>r&&(r=o)}return r-t<=25}record(e,t=Date.now(),r=!1,n=this.reserveCaptureSeq?.()){this.markInputObserved(),this.scheduleIdle();let o=this.previousLength;this.currentEffect=e===0?"clear":o===0?"fill":"modify";let s=e-o;if(this.previousLength=e,e===0&&o>0){this.flush(),this.pushLow({...n===void 0?{}:{captureSeq:n},lowType:"input-clear",ts:t,inputEffect:"clear"});return}if(r){this.flushAutofillStreak(),this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect,n);return}if(s>=3){this.flushInputBatch(),this.flushAutofillStreak(),this.pushLow({...n===void 0?{}:{captureSeq:n},lowType:"big-input-add",ts:t,inputEffect:this.currentEffect});return}if(s<=-3){this.flushInputBatch(),this.flushAutofillStreak(),this.pushLow({...n===void 0?{}:{captureSeq:n},lowType:"big-input-rem",ts:t,inputEffect:this.currentEffect});return}let a=this.autofillStreak;if(a){if(s===1&&t-a.lastTimestamp<=80){a.lastTimestamp=t;return}this.flushAutofillStreak()}if(s!==1){this.drainAutofillRingToBatch(),this.extendInputBatch(t,this.currentEffect,n);return}let l=this.autofillTimestamps;if(l.length===0&&(this.ringEffect=this.currentEffect),l.push({ts:t,captureSeq:n}),l.length>5){let u=l.shift();this.extendInputBatch(u.ts,this.ringEffect,u.captureSeq),this.ringEffect="modify"}if(!this.detectAutofillStreak())return;let p=l[0],d=l[l.length-1];l.length=0,this.flushInputBatch(),this.autofillStreak={firstTimestamp:p.ts,captureSeq:p.captureSeq,lastTimestamp:d.ts,effect:this.ringEffect}}};var j=class{constructor(e,t,r,n,o){this.inputs=t;this.logger=r;this.changed=n;this.reserveCaptureSeq=o;for(let s of t)s.addEventListener("paste",this.onPaste,!0),s.addEventListener("beforeinput",this.onBeforeInput,!0)}before=null;timestamp=0;captureSeq;pasteEvent;timer=null;onPaste=e=>this.begin(e);onBeforeInput=e=>{e.inputType==="insertFromPaste"?this.begin(e):this.flush()};handlesInput(e){if(!this.before)return!1;let t=this.pasteEvent?.type==="paste"&&(this.pasteEvent.eventPhase??0)>0;return e.inputType==="insertFromPaste"||t?!0:(this.clear(),!1)}get pending(){return this.before!==null}begin(e){if(!(!e.isTrusted||this.before))try{this.before=this.inputs.map(t=>t.value),this.pasteEvent=e,this.timestamp=Date.now(),this.captureSeq=this.reserveCaptureSeq?.(),this.timer=setTimeout(()=>this.flush(),0)}catch(t){this.logger.error("Failed to observe paste",t),this.clear()}}flush(){let e=this.before;if(!e)return;let t=this.timestamp,r=this.captureSeq;this.clear();try{let n=0,o=!1;this.inputs.forEach((s,a)=>{let l=e[a],p=s.value;if(l===p)return;o=!0;let d=0;for(;d<l.length&&d<p.length&&l[d]===p[d];)d++;let u=0;for(;u<l.length-d&&u<p.length-d&&l[l.length-u-1]===p[p.length-u-1];)u++;n+=p.length-d-u}),o&&this.changed(t,n,r)}catch(n){this.logger.error("Failed to finish paste observation",n)}}clear(){this.timer!==null&&clearTimeout(this.timer),this.timer=null,this.before=null,this.pasteEvent=void 0}destroy(){this.flush();for(let e of this.inputs)e.removeEventListener("paste",this.onPaste,!0),e.removeEventListener("beforeinput",this.onBeforeInput,!0)}};var _i=["focus","blur","pointerdown","pointerup","click","input","keyup"];function Ce(i,e,t,r,n=_i){let o=[];for(let s of n){let a=Ai(s,t,r);a&&o.push([s,a])}for(let[s,a]of o)e.addEventListener(s,a);return()=>{for(let[s,a]of o)e.removeEventListener(s,a)}}function Ai(i,e,t){switch(i){case"focus":case"blur":{let r=e[i];return r&&(n=>t(i,()=>r(n.relatedTarget)))}case"pointerdown":case"pointerup":case"click":{let r=e[i];return r&&(()=>t(i,()=>r()))}case"input":{let r=e.input;return r&&(n=>t("input",()=>r(n.isComposing||n.inputType==="insertCompositionText",n)))}case"keyup":{let r=e.keyupEscape;return r&&(n=>t("keyup",()=>{n.key==="Escape"&&r()}))}}}function yr(i,e){return e.type==="checkbox"||e.type==="radio"?e.checked?1:0:e.value.length}function vr(i,e){return e.reduce((t,r)=>t+r.value.length,0)}function Pe(i,e){let t=document.activeElement;return e.find(r=>r===t)}var Mi=[{query:"com-1password-button",eventType:"pa-1"},{query:"com-1password-menu",eventType:"pa-2"},{query:"com-1password-notification",eventType:"pa-3"}],Hi="[data-lastpass-root], [data-lp], [data-lpignore], [data-lpfieldtype]",Sr="pa-4",Bi='[popover="manual"]',Ni=400,Ui=20,ut="pa-5",ct="pa-6",ft=(i,e)=>{try{return Array.from(i.querySelectorAll(e))}catch{return[]}},br=i=>{if(i.getAttribute("popover")!=="manual")return!1;let e=i.getAttribute("style")??"";return!(e.length<Ni||!/z-index:\s*2147483647\b/i.test(e)||!/position:\s*fixed\b/i.test(e)||!/display:\s*block\b/i.test(e)||(e.match(/initial\s*!important/gi)?.length??0)<Ui)},qi=i=>{if(br(i)||i.getAttribute("popover")!=="manual")return!1;let e=i.getAttribute("style")??"";return!(!/z-index:\s*2147483647\b/i.test(e)||!/position:\s*fixed\b/i.test(e)||!/backdrop-filter:\s*[^;]*blur\(\s*20px\s*\)/i.test(e)||!/background-color:\s*rgba\(\s*35\s*,\s*35\s*,\s*35\s*,/i.test(e))},Ki=i=>{i(document);for(let e of Array.from(document.querySelectorAll("*"))){let t=e.shadowRoot;t&&i(t)}},Vi=()=>{let i=new Set;return typeof document>"u"||Ki(e=>{for(let t of Mi)i.has(t.eventType)||ft(e,t.query).length>0&&i.add(t.eventType);if(!i.has(Sr)&&ft(e,Hi).length>0&&i.add(Sr),!i.has(ut)||!i.has(ct))for(let t of ft(e,Bi)){if(!i.has(ut)&&br(t)){i.add(ut);continue}!i.has(ct)&&qi(t)&&i.add(ct)}}),i};function wr(i){return Vi()}var Wi=500,$i=250;function ie(i){return yr(0,i)}var k=class{constructor(e,t,r){this.logger=e;this.inputField=t;this.sink=r;this.changes=new z(ie(t),this.pushLow,e,r.reserveCaptureSeq),this.pasteObserver=new j(0,[t],e,(n,o,s)=>{this.changes.flush(),this.changes.markInputObserved();let a=this.changes.previousLength;this.changes.previousLength=ie(t),this.pushLow({...s===void 0?{}:{captureSeq:s},lowType:"input-paste",ts:n,inputEffect:ie(t)===0?"clear":a===0?"fill":"modify"})},r.reserveCaptureSeq),this.unregisterInputs=r.registerInputs?.([t],()=>this.flushPending()),this.capturePrefill(),this.attach()}unregisterInputs;removeFieldListeners;removePageHide;changes;pasteObserver;emittedSignals=new Set;firstFocusHandled=!1;mountProbeTimer=null;focusProbeTimer=null;destroyed=!1;destroy(){if(!this.destroyed){this.destroyed=!0;try{this.mountProbeTimer!==null&&(clearTimeout(this.mountProbeTimer),this.mountProbeTimer=null),this.focusProbeTimer!==null&&(clearTimeout(this.focusProbeTimer),this.focusProbeTimer=null),this.changes.flush(),this.unregisterInputs?.(),this.pasteObserver.destroy(),this.detach()}catch(e){this.logger.error("Failed to destroy LowEventInputTracker",e)}}}attach(){let e=this.inputField;this.removeFieldListeners=Ce(0,e,{focus:()=>this.handleFocus(),blur:()=>this.handleBlur(),pointerdown:()=>this.enqueueNonInputEvent("pointerdown"),pointerup:()=>this.enqueueNonInputEvent("pointerup"),click:()=>this.enqueueNonInputEvent("click"),input:(t,r)=>this.handleInput(r,t),keyupEscape:()=>this.enqueueNonInputEvent("keyup-escape")},(t,r)=>{try{r()}catch(n){t==="input"?this.logger.error("Failed to observe input",n):this.logger.error(`Failed to handle low event "${t}"`,n)}}),typeof window<"u"&&(this.removePageHide=x(0,"pagehide",this.wrapHandler("pagehide",()=>this.flushForTeardown()))),typeof document<"u"&&Pe(0,[e])&&this.handleFocus(),typeof window<"u"&&(this.mountProbeTimer=setTimeout(()=>this.runEnvProbe(),Wi))}detach(){this.removeFieldListeners?.(),typeof window<"u"&&this.removePageHide?.()}pushLow=e=>{this.sink.enqueueLowEvent(e)};runEnvProbe(){try{if(typeof __CBO_DATA_PMD__=="boolean"?__CBO_DATA_PMD__:this.sink.passwordManagerDomScan?.()!==!1){let e=wr(0),t=Date.now();for(let r of e)this.emittedSignals.has(r)||(this.emittedSignals.add(r),this.pushLow({lowType:r,ts:t}))}}catch(e){this.logger.error("Failed to run input env probe",e)}}scheduleFocusProbe(){this.firstFocusHandled||(this.firstFocusHandled=!0,this.focusProbeTimer=setTimeout(()=>this.runEnvProbe(),$i))}capturePrefill(e=!1){this.destroyed||(this.flushPending(),this.changes.capturePrefill(ie(this.inputField),e))}flushPending(){this.pasteObserver.flush(),this.changes.flush()}enqueueNonInputEvent(e){this.changes.flush(),this.pushLow({lowType:e,ts:Date.now()})}handleFocus(){this.scheduleFocusProbe(),this.enqueueNonInputEvent("focus")}handleBlur(){this.pasteObserver.flush(),this.enqueueNonInputEvent("blur")}handleInput(e,t){this.pasteObserver.handlesInput(e)||this.changes.record(ie(this.inputField),Date.now(),t)}flushForTeardown(){this.pasteObserver.flush(),this.changes.flush(),this.sink.flushKeepalive()}wrapHandler(e,t){return()=>{try{t()}catch(r){this.logger.error(`Failed to handle low event "${e}"`,r)}}}};var Le=class{constructor(e,t,r){this.logger=e;this.sink=r;this.inputs=[...new Set(t)],this.changes=new z(this.length(),o=>r.enqueueLowEvent(o),e,r.reserveCaptureSeq),this.paste=new j(0,this.inputs,e,(o,s,a)=>{this.cancelChange(),this.changes.flush(),this.changes.markInputObserved();let l=this.changes.previousLength;this.changes.previousLength=this.length(),r.enqueueLowEvent({...a===void 0?{}:{captureSeq:a},lowType:"input-paste",ts:o,inputEffect:this.length()===0?"clear":l===0?"fill":"modify"})},r.reserveCaptureSeq),this.unregisterInputs=r.registerInputs?.(this.inputs,()=>this.flushPending()),this.capturePrefill();let n=(o,s)=>this.safe(s);for(let o of this.inputs)this.listeners.push(Ce(0,o,{input:(s,a)=>{this.paste.handlesInput(a)||(this.composing||=s,this.changeTimer===null&&(this.changeTime=Date.now(),this.changeSeq=r.reserveCaptureSeq?.(),this.changeTimer=setTimeout(()=>this.safe(()=>this.flushChanges()),0)))},focus:s=>{this.contains(s)||this.emit("focus")},blur:s=>{this.contains(s)||(this.flushPending(),this.emit("blur"))},click:()=>this.emit("click"),pointerdown:()=>this.emit("pointerdown"),pointerup:()=>this.emit("pointerup"),keyupEscape:()=>this.emit("keyup-escape")},n,["input","focus","blur","click","pointerdown","pointerup","keyup"]));typeof window<"u"&&this.listeners.push(x(0,"pagehide",o=>this.safe(()=>{this.flushPending(),r.flushKeepalive()}))),typeof document<"u"&&Pe(0,this.inputs)&&this.emit("focus")}inputs;changes;paste;unregisterInputs;listeners=[];changeTimer=null;changeTime=0;changeSeq;composing=!1;destroyed=!1;contains(e){return this.inputs.some(t=>t===e)}length(){return vr(0,this.inputs)}safe(e){try{e()}catch(t){this.logger.error("Failed to observe grouped input",t)}}cancelChange(){this.changeTimer!==null&&clearTimeout(this.changeTimer),this.changeTimer=null}flushChanges(){this.changeTimer!==null&&(this.cancelChange(),this.paste.pending||this.changes.record(this.length(),this.changeTime,this.composing,this.changeSeq),this.composing=!1)}emit(e){this.flushChanges(),this.changes.flush(),this.sink.enqueueLowEvent({lowType:e,ts:Date.now()})}capturePrefill(e=!1){this.destroyed||(this.flushPending(),this.changes.capturePrefill(this.length(),e))}flushPending(){this.paste.flush(),this.flushChanges(),this.changes.flush()}destroy(){this.destroyed||(this.destroyed=!0,this.safe(()=>{this.flushPending(),this.paste.destroy(),this.unregisterInputs?.();for(let e of this.listeners)e()}))}};var D=class{constructor(e,t,r){this.logger=e;this.inputSink=t;this.groupSink=r}collector;fields=[];grouped=!1;destroyed=!1;prefillClaimed=!1;setFields(e,t=!0){try{if(this.destroyed)return;let r=[...new Set(e)];if(t===this.grouped&&r.length===this.fields.length&&r.every((s,a)=>s===this.fields[a])||(this.collector?.destroy(),this.collector=void 0,this.fields=[],this.grouped=t,r.length===0))return;let n=t?this.groupSink:this.inputSink,o={...n,enqueueLowEvent:s=>this.enqueue(n,s)};this.collector=t?new Le(this.logger,r,o):new k(this.logger,r[0],o),this.fields=r}catch(r){this.logger.error("Failed to bind OTP inputs",r)}}enqueue(e,t){if(t.lowType==="input-prefill"){if(this.prefillClaimed)return;this.prefillClaimed=!0}else["input","input-idle","input-clear","input-paste","big-input-paste","big-input-add","big-input-rem"].includes(t.lowType)&&(this.prefillClaimed=!0);e.enqueueLowEvent(t)}capturePrefill(e=!1){e&&(this.prefillClaimed=!1),this.collector?.capturePrefill(e)}flushPending(){this.collector?.flushPending()}destroy(){this.destroyed=!0,this.collector?.destroy(),this.collector=void 0,this.fields=[]}};var Fe=class extends g{lowEventTracker;send;postResponse;resend;constructor(e,t={}){super(e,"email-otp"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.subflowStart({explicitSpecType:t.explicitSpecType,emailDomain:t.emailDomain}),this.lowEventTracker=this.createLowCollector(()=>new D(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var Re=class extends g{lowEventTracker;send;postResponse;resend;constructor(e,t={}){super(e,"sms-otp"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.subflowStart({explicitSpecType:t.explicitSpecType}),this.lowEventTracker=this.createLowCollector(()=>new D(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var Qi=["ahrefsbot","ahrefssiteaudit","amazonbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","facebookexternal","petalbot","pinterest","screaming frog","yahoo! slurp","yandex","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google"];function Tr(i){if(!i)return!1;let e=i.toLowerCase();return Qi.some(t=>e.includes(t))}var Er="@corbado/observe",Ir="1.9.0";var ht="cbo_email_link_starts";function gt(i,e){let t=i.getItem(ht);return Array.isArray(t)?t.filter(r=>!!r&&typeof r=="object"&&typeof r.transactionId=="string"&&typeof r.anchor=="string"&&typeof r.sessionId=="string"&&typeof r.startedAt=="number"&&e-r.startedAt<864e5):[]}function kr(i,e){if(i)try{let t=gt(i,e.startedAt).filter(r=>r.transactionId!==e.transactionId);t.push(e),i.setItem(ht,t.slice(-10))}catch{}}function xr(i,e,t=Date.now()){if(i)try{let r=gt(i,t);if(e.transactionId)return r.find(o=>o.transactionId===e.transactionId);let n=r.filter(o=>!o.continued&&(!e.specType||!o.specType||o.specType===e.specType));return n[n.length-1]}catch{return}}function Or(i,e){if(i)try{let t=gt(i,Date.now()).map(r=>r.transactionId===e?{...r,continued:!0}:r);i.setItem(ht,t)}catch{}}var De=class extends g{send;postResponse;resend;transactionId;constructor(e,t={}){super(e,"email-link"),this.send=this.defineStep("send"),this.postResponse=this.defineStep("post-response"),this.resend=this.defineStep("resend"),this.transactionId=t.transactionId||S(),this.subflowStart({explicitSpecType:t.explicitSpecType},{userReference:{crossEnvironmentTransactionIDStart:this.transactionId}});let r=this.captureReference,n=this.captureSession;r&&n&&kr(e.getPersistentStorage(),{transactionId:this.transactionId,anchor:r,sessionId:n,specType:t.explicitSpecType,startedAt:Date.now()})}},_e=class extends g{postResponse;resend;mode;continuationTracker;specType;createdAt=Date.now();transaction;started=!1;deferred=[];onPageHide=()=>this.flush();removePageHide;constructor(e,t={}){super(e,"email-link"),this.continuationTracker=e,this.specType=t.explicitSpecType,this.transaction=t.transactionId,this.postResponse=this.deferrable(this.defineStep("post-response"),!0),this.resend=this.deferrable(this.defineStep("resend"));let r=e.getPersistentStorage(),n=xr(r,{transactionId:t.transactionId,specType:t.explicitSpecType});if(n&&n.sessionId===e.getSessionId()){this.mode="attached",this.transaction=t.transactionId??n.transactionId,this.adoptCapture(n.anchor,n.sessionId,n.specType??t.explicitSpecType),this.started=!0;return}this.mode="detached",this.transaction?this.startDetached(this.createdAt):typeof window<"u"&&(this.removePageHide=x(0,"pagehide",this.onPageHide))}get transactionId(){return this.transaction}setTransactionId(e){!e||this.transaction||(this.transaction=e,this.mode==="detached"&&!this.started&&this.startDetached(this.firstDeferredAt()))}flush(){this.mode==="detached"&&!this.started&&this.startDetached(this.firstDeferredAt())}destroy(){this.flush(),this.removePageHideListener()}firstDeferredAt(){return this.deferred[0]?.at??this.createdAt}startDetached(e){this.started=!0,this.removePageHideListener(),this.subflowStart({explicitSpecType:this.specType,continuation:!0},{explicitTimestamp:e,...this.transaction?{userReference:{crossEnvironmentTransactionIDFinish:this.transaction}}:{}});let t=this.deferred;this.deferred=[];for(let r of t)r.run(r.at);try{this.continuationTracker.flushKeepalive()}catch{}}removePageHideListener(){typeof window<"u"&&this.removePageHide?.()}deferrable(e,t=!1){let r=(n,o)=>{if(this.started){n(o?.explicitTimestamp??Date.now());return}this.deferred.push({at:o?.explicitTimestamp??Date.now(),run:n})};return{start:(n,o)=>r(s=>e.start(n,{...o,explicitTimestamp:s}),o),finished:(n,o)=>{r(s=>e.finished(n,{...o,explicitTimestamp:s}),o),t&&this.transaction&&Or(this.continuationTracker.getPersistentStorage(),this.transaction)},error:(n,o)=>r(s=>e.error(n,{...o,explicitTimestamp:s}),o)}}};var Ae=class extends g{getOptions;ceremony;postResponse;lowEventTracker;constructor(e,t){super(e,"passkey-enrollment"),this.lowEventTracker=new G(e.getLogger(),this.lowEventSink("ceremony")),this.registerLowFlusher(()=>this.lowEventTracker.disarm()),this.getOptions=this.defineStep("get-options"),this.ceremony=this.withWindowLowEvents(this.defineStep("ceremony"),this.lowEventTracker),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType,...t?.ignoreAsInteraction?{ignoreAsInteraction:!0}:{}})}destroy(){this.lowEventTracker.destroy()}};function Cr(i){let e=i.debug,t,r=(n,o)=>`[Corbado Observe SDK ${n}] ${o}`;return{reportTelemetry(n,o){if(t)try{t(n,o)}catch{}},setTelemetrySink(n){t=n},debug(n,...o){e&&console.log(r("DEBUG",n),...o)},info(n,...o){e&&console.log(r("INFO",n),...o)},warn(n,...o){e&&console.warn(r("WARN",n),...o)},error(n,...o){e&&console.error(r("ERROR",n),...o)},critical(n,...o){console.error(r("CRITICAL",n),...o)}}}var Me=class extends g{userConfirmation;deletion;constructor(e,t={}){super(e,"passkey-deletion"),this.userConfirmation=this.defineStep("user-confirmation"),this.deletion=this.defineStep("deletion"),this.subflowStart({})}};var He=class extends g{clientValidation;postResponse;cui;lowEventTracker;identifierLowEventTracker;constructor(e,t){super(e,"password-login"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response"),this.cui={getOptions:this.defineStep("cui-get-options",!0),ceremony:this.defineStep("cui-ceremony"),postResponse:this.defineStep("cui-post-response")},this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.identifierInputHtmlField&&(this.identifierLowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.identifierInputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.identifierLowEventTracker?.flushPending())),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","password"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}trigger(e,t){super.trigger(e,t)}destroy(){this.lowEventTracker?.destroy(),this.identifierLowEventTracker?.destroy()}};var Be=class extends g{clientValidation;postResponse;lowEventTracker;constructor(e,t){super(e,"password-enrollment"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","password"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Ne=class extends g{lowEventTracker;cui;provideIdentifier;constructor(e,t){super(e,"provide-identifier"),this.cui={trigger:(r,n)=>{this.trigger(r,n)},getOptions:this.defineStep("cui-get-options",!0),ceremony:this.defineStep("cui-ceremony"),postResponse:this.defineStep("cui-post-response")},this.provideIdentifier={trigger:(r,n)=>{this.trigger(r,n)},clientValidation:this.defineStep("pi-client-validation"),postResponse:this.defineStep("pi-post-response")},this.subflowStart({explicitSpecType:t?.explicitSpecType}),t?.inputHtmlField&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),t.inputHtmlField,this.lowEventSink("input","identifier"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Ue=class extends g{getRedirectUrl;exchangeCode;constructor(e,t={}){super(e,"social-login"),this.getRedirectUrl=this.defineStep("get-redirect-url"),this.exchangeCode=this.defineStep("exchange-code"),this.subflowStart({explicitSpecType:t.explicitSpecType,entry:t.entry})}};var qe=class extends g{getRedirectUrl;exchangeCode;constructor(e,t={}){super(e,"sso-login"),this.getRedirectUrl=this.defineStep("get-redirect-url"),this.exchangeCode=this.defineStep("exchange-code");let{explicitSpecType:r,organizationDomain:n,actor:o}=Gi(t??{},e);this.subflowStart({explicitSpecType:r,organizationDomain:n,actor:o})}};function Gi(i,e){let t={...i},r=o=>{try{e.getLogger().warn(`SSO login: unsupported ${o}; omitted from telemetry`)}catch{}},n=t.organizationDomain;return n!==void 0&&(typeof n!="string"||n.includes("@")||n.length>253)&&(delete t.organizationDomain,r("organizationDomain")),t.actor!==void 0&&t.actor!=="user"&&t.actor!=="system"&&(delete t.actor,r("actor")),t}var Ke=class extends g{lowEventTracker;postResponse;constructor(e,t={}){super(e,"totp"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType}),this.lowEventTracker=this.createLowCollector(()=>new D(e.getLogger(),this.lowEventSink("input","otp"),this.lowEventSink("input-group","otp"))),t.inputHtmlFields?.length?this.setInputFields(t.inputHtmlFields):t.inputHtmlField&&this.lowEventTracker?.setFields([t.inputHtmlField],!1),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending())}setInputFields(e){this.lowEventTracker?.setFields(e)}destroy(){this.lowEventTracker?.destroy()}};var Ve=class extends g{ceremony;retry;postResponse;constructor(e,t={}){super(e,"app-confirmation"),this.ceremony=this.defineStep("ceremony"),this.retry=this.defineStep("retry"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType})}};var We=class extends g{ceremony;postResponse;constructor(e,t={}){super(e,"captcha"),this.ceremony=this.defineStep("ceremony"),this.postResponse=this.defineStep("post-response"),this.subflowStart({explicitSpecType:t.explicitSpecType})}};var $e=class{constructor(e,t){this.logger=e;this.sink=t}trackers=new Map;destroyed=!1;setFields(e){if(this.destroyed)return;let t=new Set(e);for(let[r,n]of this.trackers)t.has(r)||(this.safe(()=>n.destroy()),this.trackers.delete(r));for(let r of t)this.trackers.has(r)||this.safe(()=>this.trackers.set(r,new k(this.logger,r,this.sink())))}capturePrefill(e=!1){for(let t of this.trackers.values())this.safe(()=>t.capturePrefill(e))}flushPending(){for(let e of this.trackers.values())this.safe(()=>e.flushPending())}destroy(){if(!this.destroyed){this.destroyed=!0;for(let e of this.trackers.values())this.safe(()=>e.destroy());this.trackers.clear()}}safe(e){try{e()}catch(t){this.logger.error("Form input binding failed",t)}}};var mt=50,zi=6e4,ji=40,Yi=/^[A-Za-z0-9._-]+$/,Qe=class extends g{submit;skip;inputBinding;constructor(e,t){super(e,"form"),this.submit=this.defineStep("submit"),this.skip=this.defineStep("skip"),this.subflowStart(Ji(e,t),Xi(e,t)),this.inputBinding=this.createLowCollector(()=>new $e(e.getLogger(),()=>this.lowEventSink("input","data"))),this.registerLowFlusher(()=>this.inputBinding?.flushPending()),t?.inputHtmlFields?.length&&this.setInputFields(t.inputHtmlFields)}setInputFields(e){this.inputBinding?.setFields(e)}destroy(){this.inputBinding?.destroy()}};function Xi(i,e){let t=e?.startedAt;if(t===void 0)return;let r=Date.now();if(typeof t!="number"||!Number.isFinite(t)||t>r||r-t>zi){ne(i,"Form: implausible startedAt ignored; using the current time");return}return{explicitTimestamp:t}}function Ji(i,e){let t={},r=e?.name;typeof r=="string"&&r.trim()!==""?t.name=r:ne(i,"Form: missing name; the form will not be counted");let n=e?.fields;if(n===void 0)return t;if(!Array.isArray(n))return ne(i,"Form: fields must be an array of field names; omitted from telemetry"),t;let o=n.filter(s=>typeof s=="string"&&s.length<=ji&&Yi.test(s));return o.length<n.length&&ne(i,"Form: unsupported field names omitted from telemetry"),o.length>mt&&ne(i,`Form: more than ${mt} field names; the rest is omitted from telemetry`),o.length>0&&(t.fields=o.slice(0,mt)),t}function ne(i,e){try{i.getLogger().warn(e)}catch{}}function yt(i,e,t){if(i===null||typeof i!="object")return i;try{let r={...i};r.purpose===void 0&&e.purpose!==void 0&&(r.purpose=e.purpose),r.storage===void 0&&e.storage!==void 0&&(r.storage=e.storage),r.trustName===void 0&&e.trustName!==void 0&&(r.trustName=e.trustName);for(let[n,o]of[["bindingReference",255],["trustName",128]])if(typeof r[n]=="string"&&[...r[n]].length>o){delete r[n];try{t.getLogger().debug(`Trusted device: omitted ${n} exceeding ${o} characters`)}catch{}}return r}catch{return i}}function Ge(i,e,t){return{...i,start:(r,n)=>i.start(yt(r,e,t),n),finished:(r,n)=>i.finished(yt(r,e,t),n)}}var ze=class extends g{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-check"),t=Pr(t,e);let r={purpose:t.purpose,storage:t.storage,trustName:t.trustName};this.getOptions=this.checkStep("get-options",r,e),this.ceremony=this.checkStep("ceremony",r,e),this.postResponse=this.checkStep("post-response",r,e),this.subflowStart({explicitSpecType:t.explicitSpecType,actor:"system",ignoreAsInteraction:!0})}checkStep(e,t,r){let n=this.defineStep(e,!0);return{...Ge(n,t,r),errorTyped:(o,s)=>{n.errorTyped(yt({code:o?.code,error:U(o?.error)},t,r),s)}}}},je=class extends g{getOptions;ceremony;postResponse;constructor(e,t){super(e,"trusted-device-enrollment"),t=Pr(t,e);let r={purpose:t.purpose,storage:t.storage,trustName:t.trustName};this.getOptions=Ge(this.defineStep("get-options"),r,e),this.ceremony=Ge(this.defineStep("ceremony"),r,e),this.postResponse=Ge(this.defineStep("post-response"),r,e),this.subflowStart({explicitSpecType:t.explicitSpecType})}};function Pr(i,e){let t={...i},r=n=>{try{e.getLogger().warn(`Trusted device: missing or unsupported ${n}; omitted from telemetry`)}catch{}};return t.purpose!=="additional-verification"&&t.purpose!=="mfa-exemption"&&(delete t.purpose,r("purpose")),["cookie","indexeddb","localstore","sessionstore"].includes(t.storage)||(delete t.storage,r("storage")),t}var Ye=class extends g{clientValidation;postResponse;lowEventTracker;constructor(e,t={}){super(e,"provide-data"),this.clientValidation=this.defineStep("client-validation"),this.postResponse=this.defineStep("post-response");let{inputHtmlField:r,...n}=t;this.subflowStart(n),r&&(this.lowEventTracker=this.createLowCollector(()=>new k(e.getLogger(),r,this.lowEventSink("input","data"))),this.registerLowFlusher(()=>this.lowEventTracker?.flushPending()))}destroy(){this.lowEventTracker?.destroy()}};var Zi="/inline/injected/webauthn-listeners.js",Lr=/\/dashlane-(?:shadow-dom|top-layer)-page-script\.js/,en=/-extension:\/\/[^/]+\/content-scripts\/passkey_proxy\/index\.js$/,tn=/-extension:\/\/[^/]+\/content_scripts\/shadow-dom\/shadowAttachNotifier\.js:/,Fr=/-extension:\/\/[^/]+\/js\/nordpass-script\.js:/,rn=/-extension:\/\/[^/]+\/js\/passkeys\.js:/,nn=/["'`](?:keeper:shadow-root-attached|webauthn-(?:get|create)-request)["'`]/,on=/Intercept cancelled for `(?:get|create)`|["'`](?:conditionalMediationAvailable|verifyingPlatformAuthenticatorAvailable)["'`]/,vt=()=>Object.keys(window._sentryDebugIds??{}),St=i=>{try{i()}catch(e){return String(e?.stack??"")}return""},Rr=()=>St(()=>Element.prototype.attachShadow.call(null,{mode:"open"})),sn=()=>{let i=Object.getOwnPropertyDescriptor(navigator.credentials??{},"get");if(!i?.get||!i.set||i.configurable)return!1;let e=()=>{},t=i.get.call({_get:e});return t===e||typeof t=="function"&&t===i.get.call({})&&!Function.prototype.toString.call(t).includes("[native code]")},bt=(...i)=>{let e=navigator.credentials;return e?i.map(t=>Object.getOwnPropertyDescriptor(e,t)?.value):[]},an=()=>[navigator.credentials?.get,...bt("get","_get")].some(i=>typeof i=="function"&&i.name==="getWebAuthnCredential"),ln=()=>{let i=document.documentElement,e=document.adoptedStyleSheets;if(!i||typeof i.getAnimations!="function"||typeof e?.push!="function"||i.getAnimations().length>0)return!1;let t=new CSSStyleSheet;t.replaceSync(":where(:root){animation:bitwardenfill 1s 1000s paused}"),e.push(t);try{let r=i.getAnimations().filter(n=>n.animationName==="bitwardenfill");return r.forEach(n=>n.cancel()),r.length>0}finally{let r=e.indexOf(t);r>=0&&e.splice(r,1)}},dn,pn=()=>dn??=ln(),un=()=>{let i=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;if(typeof i!="function"||!Object.prototype.hasOwnProperty.call(i,Symbol.hasInstance))return!1;let e=i[Symbol.hasInstance]({});return e instanceof Promise?(e.catch(()=>{}),!0):!1},cn=()=>{let i={get nodeType(){throw new Error("probe")}};return St(()=>MutationObserver.prototype.observe.call(null,i))},fn=()=>{let i=new Error("probe"),e=[],t={get nodeType(){return e.push("nodeType"),1},get ownerDocument(){throw e.push("ownerDocument"),i}};try{MutationObserver.prototype.observe.call(null,t)}catch(r){return r===i&&e.join()==="nodeType,ownerDocument"}return!1},hn=()=>[Element.prototype.attachShadow,navigator.credentials?.get,navigator.credentials?.create,...bt("get","_get","create")].some(e=>typeof e=="function"&&nn.test(Function.prototype.toString.call(e))),gn=()=>{let i=document;for(;i;){if(i.querySelector("[data-lastpass-icon-root], [data-lastpass-root]"))return!0;i=i.activeElement?.shadowRoot}return!1},mn=()=>{let i=typeof PublicKeyCredential>"u"?void 0:PublicKeyCredential;return[navigator.credentials?.get,...bt("get","_get"),i?.isConditionalMediationAvailable,i?._isConditionalMediationAvailable,i?.isUserVerifyingPlatformAuthenticatorAvailable,i?._isUserVerifyingPlatformAuthenticatorAvailable].some(t=>typeof t=="function"&&on.test(Function.prototype.toString.call(t)))},yn=[{name:"1password",signal:"in-field button",signedIn:!0,test:()=>document.querySelector("com-1password-button")!==null},{name:"1password",signal:"credentials.get accessor",test:sn},{name:"1password",signal:"Sentry debug id",test:()=>vt().some(i=>i.includes(Zi))},{name:"bitwarden",signal:"passkey override",signedIn:!0,test:an},{name:"bitwarden",signal:"autofill keyframes",test:pn},{name:"dashlane",signal:"injected script tag",test:()=>document.querySelector('script[src*="-extension://"][src*="/dashlane-"][src$="-page-script.js"]')!==null},{name:"dashlane",signal:"PublicKeyCredential hasInstance trap",test:un},{name:"dashlane",signal:"page script stack",test:()=>Lr.test(Rr())||typeof HTMLDialogElement<"u"&&Lr.test(St(()=>HTMLDialogElement.prototype.showModal.call(null)))},{name:"kaspersky",signal:"passkey proxy flag",test:()=>window.wasKPMKeyPassProxyInited===!0},{name:"kaspersky",signal:"injected script tag",test:()=>en.test(document.querySelector('script[src*="/content-scripts/passkey_proxy/"]')?.src??"")},{name:"keeper",signal:"attachShadow stack",test:()=>tn.test(Rr())},{name:"keeper",signal:"override source",test:hn},{name:"keeper",signal:"field lock",test:()=>document.querySelector("[data-keeper-lock-id]")!==null},{name:"lastpass",signal:"passkey override",signedIn:!0,test:()=>typeof window.__nativeCredentialsGet=="function"},{name:"lastpass",signal:"icon root",test:gn},{name:"nordpass",signal:"observer proxy stack",test:()=>Fr.test(cn())},{name:"nordpass",signal:"observer read order",test:fn},{name:"nordpass",signal:"passkeys Sentry debug id",test:()=>vt().some(i=>rn.test(i))},{name:"nordpass",signal:"Sentry debug id",test:()=>vt().some(i=>Fr.test(i))},{name:"protonpass",signal:"WebAuthn override source",test:mn},{name:"protonpass",signal:"field icon",test:()=>document.querySelector("[data-protonpass-role]")!==null}];function vn(){return typeof window>"u"||typeof document>"u"?[]:yn.map(({name:i,signal:e,signedIn:t,test:r})=>{try{return{name:i,signal:e,signedIn:t,matched:r()}}catch(n){return{name:i,signal:e,signedIn:t,matched:!1,error:n}}})}function Sn(){let i=new Map;for(let{name:e,signedIn:t,matched:r}of vn()){if(!r)continue;let n=i.get(e)??{name:e};t&&(n.signedIn=!0),i.set(e,n)}return[...i.values()]}function Dr(i){return Sn()}var _r=3e3,bn=500,wn=6,Tn=1e3,Xe=class{constructor(e,t,r){this.logger=e;this.isEnabled=t;if(typeof window>"u"||typeof document>"u")return;if(this.sample(),_t(0))this.sampleAfter(_r);else{let o=()=>{this.sampleWhenIdle(),this.sampleAfter(_r)};this.removers.push(x(0,"load",o,{once:!0}))}let n=r.onInputFocus(o=>{!this.isEnabled()||this.sampledFields.has(o)||(this.sampledFields.add(o),++this.focusSamples>=wn&&n(),this.sampleAfter(bn))});this.removers.push(n)}detected=new Map;timers=new Set;idleCallbacks=new Set;sampledFields=new WeakSet;focusSamples=0;removers=[];destroyed=!1;reportedCounts=new Map;getDetected(){return[...this.detected.values()]}takeReport(e){if(!(!this.isEnabled()||this.detected.size<=(this.reportedCounts.get(e)??0)))return this.reportedCounts.set(e,this.detected.size),this.getDetected().map(({name:t})=>({name:t}))}destroy(){this.destroyed=!0;for(let e of this.removers)e();for(let e of this.timers)clearTimeout(e);this.timers.clear();for(let e of this.idleCallbacks)cancelIdleCallback(e);this.idleCallbacks.clear()}sampleAfter(e){let t=setTimeout(()=>{this.timers.delete(t),this.sampleWhenIdle()},e);this.timers.add(t)}sampleWhenIdle(){if(typeof requestIdleCallback!="function"){this.sample();return}let e=requestIdleCallback(()=>{this.idleCallbacks.delete(e),this.sample()},{timeout:Tn});this.idleCallbacks.add(e)}sample(){if(!(this.destroyed||!this.isEnabled()))try{let e=Dr(0);for(let t of e){let r=this.detected.get(t.name);(!r||t.signedIn&&!r.signedIn)&&this.detected.set(t.name,t)}}catch(e){this.logger.error("Failed to detect password manager extensions",e)}}};var wt={name:Er,version:Ir},En=/^[0-9A-Za-z.+_-]{1,32}$/;function In(i,e){return i===void 0?wt:typeof i=="string"&&En.test(i)?{...wt,integrationVersion:i}:(e.debug("Ignoring invalid integrationVersion (expected <= 32 chars of [0-9A-Za-z.+_-])"),wt)}var Ar="cbo_session_id",Tt="cbo_session",B="cbo_seq",Mr="cbo_experiments",Hr="cbo_data_policy",kn=255,xn=/^[A-Za-z0-9_-]+$/,On=128,Cn=256,Br=1e3,Pn=/^[a-z][a-z0-9_-]{0,31}$/,Nr=/^[A-Za-z0-9_-]{1,16}$/,Ln=64,Fn=32,Rn=50,Dn="cbo_seq",Ur=1e3,qr=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Je=class i{constructor(e){this.options=e;this.options.debug=e.debug??!1,this.logger=e.logger??Cr({debug:this.options.debug});let t=new be(this.logger),r=new Te(this.logger),n=e.storage==="cookie",o=n?new we(this.logger,e.cookieDomain):void 0;mr(e.projectId,t,r,o,this.logger);let s=e.projectId,a=c=>new Se(c,s);this.seqLockName=L(Dn,s),this.sessionStorage=a(r),this.persistentStorage=a(t),this.storage=a(o??t),this.configOverrides={...e.sdkConfig,...e.sdkConfig?.retry&&{retry:{...e.sdkConfig.retry}},...e.sdkConfig?.flushOnFlowTypeFinished&&{flushOnFlowTypeFinished:[...e.sdkConfig.flushOnFlowTypeFinished]},...e.sdkConfig?.sourcePathQueryAllow&&{sourcePathQueryAllow:[...e.sdkConfig.sourcePathQueryAllow]}},this.fixedData=Xt(e.fixedDataConfig),this.fixedData&&(this.configOverrides.pmd=this.fixedData.pmd);let l=Object.keys(b).every(c=>this.configOverrides[c]!==void 0)&&Object.keys(b.retry).every(c=>this.configOverrides.retry?.[c]!==void 0);l||(this.configManager=new xe(e.apiBaseUrl+(e.apiConfigPath??"/v1/observe/config")+"/"+e.projectId,this.persistentStorage,this.logger));let p=this.configManager?.initialConfig;this.config=it(p,this.configOverrides),!l&&!p&&e.flushInterval!=null&&this.configOverrides.flushIntervalMs===void 0&&(this.config={...this.config,flushIntervalMs:e.flushInterval}),!l&&!p&&e.deviceInfoCollectorTimeout!=null&&this.configOverrides.deviceInfoCollectorTimeoutMs===void 0&&(this.config={...this.config,deviceInfoCollectorTimeoutMs:e.deviceInfoCollectorTimeout}),e.apiBaseUrl!==""&&(/^https?:\/\//.test(e.apiBaseUrl)||(this.logger.critical(`Invalid apiBaseUrl: URL must start with http:// or https:// (got: "${e.apiBaseUrl}")`),this.reportTelemetry("error","invalid apiBaseUrl: missing http(s) scheme")),e.apiBaseUrl.endsWith("/")&&(this.logger.critical(`Invalid apiBaseUrl: URL must not have a trailing slash (got: "${e.apiBaseUrl}")`),this.reportTelemetry("error","invalid apiBaseUrl: trailing slash")));let d=e.apiBaseUrl+(e.apiEventPath??"/v1/observe/events")+"/"+e.projectId;this.logger.debug(`Using API endpoint: ${d}`);let u=new fe({logger:this.logger,url:d});this.sessionId=this.resolveSessionId(),this.queue=new me(this.logger,u,this.sessionId,In(this.options.integrationVersion,this.logger),{debug:this.options.debug,config:this.config,requestConfig:!1,outboxLockName:L(nt,s),getDataPolicy:()=>this.dataPolicy,fixedData:this.fixedData!==void 0||typeof __CBO_DATA_PMD__=="boolean"||typeof __CBO_DATA_PRIVATE_MODE__=="boolean",beforeEventBatchSend:c=>this.attachUndeliveredDeviceInfo(c),standaloneDeviceInfo:{has:()=>this.deviceInfoManager?.hasStandalone()??!1,take:()=>this.deviceInfoManager?.takeStandalone()}},this.persistentStorage),this.telemetryReady=!0,this.logger.setTelemetrySink?.((c,v)=>this.reportTelemetry(c,v));try{this.getWindowObserver()}catch(c){this.logger.error("Failed to attach page low-event observer",c)}if(typeof __CBO_DATA_PMD__=="boolean"?__CBO_DATA_PMD__:this.fixedData?.pmd!==!1)try{this.passwordManagerSampler=this.isTrackingBlocked()?void 0:new Xe(this.logger,()=>typeof __CBO_DATA_PMD__=="boolean"?__CBO_DATA_PMD__:this.config.pmd,this.getWindowObserver())}catch(c){this.logger.error("Failed to start password manager detection",c)}let f=this.pendingSelfTelemetry;this.pendingSelfTelemetry=[];for(let c of f)this.telemetry(c.level,c.message);let h=new ye(this.logger,this.storage,n?"cookie":"localstorage",this.sessionStorage,()=>({timing:this.config.deviceInfoTiming}),(c,v)=>this.telemetry(c,v),this.fixedData?.privateMode??!0);this.deviceCollector=h;let m=e.deviceInfoDebounceTime??3e4;this.deviceInfoManager=new ve(this.logger,h,Math.max(1,m),m,{timing:()=>this.config.deviceInfoTiming,emit:(c,v)=>this.telemetry(c,v)},()=>this.queue.notifyDeviceInfo()),this.deviceInfoManager.start(),this.experiments=this.loadPersistedExperiments(),e.experiments&&this.setExperiments(e.experiments),this.dataPolicy=this.loadPersistedDataPolicy(),e.dataPolicy!==void 0&&this.setDataPolicy(e.dataPolicy),this.configManager?.start(c=>this.handleConfig(c))}logger;queue;sessionId;storage;sessionStorage;persistentStorage;seqLockName;config;configManager;configOverrides;fixedData;deviceInfoManager;deviceCollector;eventTabId;seq=0;lastActivityWriteAt=0;experiments={};dataPolicy;telemetryReporting=!1;telemetryReady=!1;reportedTelemetryKeys=new Set;pendingSelfTelemetry=[];probePageId;probeSeqs=new Map;windowObserver;passwordManagerSampler;getWindowObserver(){return this.windowObserver??=new ue(this.logger,(e,t)=>this.enqueueLowEvent(e,t),()=>this.lowEventFlushKeepalive())}handleConfig(e){let t=it(e,this.configOverrides);t.sessionContinuity||=this.config.sessionContinuity,t.durableOutbox||=this.config.durableOutbox,this.config=t,this.queue.updateConfig(this.config)}getLogger(){return this.logger}applicationTag(){return this.options.applicationId?{applicationId:this.options.applicationId.toLowerCase()}:{}}setExperiment(e,t){this.setExperiments({[e]:t})}setExperiments(e){try{if(!e||typeof e!="object")return;let t=!1;for(let[r,n]of Object.entries(e)){if(!i.isValidExperimentKey(r)||!i.isValidExperimentVariant(n)){this.logger.debug(`Ignoring invalid experiment assignment "${String(r)}"`);continue}this.experiments[r]!==n&&(this.experiments[r]=n,t=!0)}t&&this.persistExperiments()}catch(t){this.logger.error("Failed to set experiments",t)}}clearExperiment(e){try{Object.prototype.hasOwnProperty.call(this.experiments,e)&&(delete this.experiments[e],this.persistExperiments())}catch(t){this.logger.error("Failed to clear experiment",t)}}clearExperiments(){try{if(Object.keys(this.experiments).length===0)return;this.experiments={},this.persistExperiments()}catch(e){this.logger.error("Failed to clear experiments",e)}}getExperiments(){return{...this.experiments}}getPersistentStorage(){return this.persistentStorage}getSdkConfig(){return Object.freeze({version:this.config.version,aap:this.config.aap,rawErrors:this.config.rawErrors})}setDataPolicy(e){try{if(!i.isValidDataPolicy(e)){this.logger.debug(`Ignoring invalid data policy code "${String(e)}"`);return}this.dataPolicy!==e&&(this.dataPolicy=e,this.persistDataPolicy())}catch(t){this.logger.error("Failed to set data policy",t)}}getDataPolicy(){return this.dataPolicy}static isValidDataPolicy(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=kn}loadPersistedDataPolicy(){try{let e=this.persistentStorage.getItem(Hr);return i.isValidDataPolicy(e)?e:void 0}catch(e){this.logger.debug("Failed to load persisted data policy",e);return}}persistDataPolicy(){try{if(this.dataPolicy===void 0)return;this.persistentStorage.setItem(Hr,this.dataPolicy)}catch(e){this.logger.debug("Failed to persist data policy",e)}}static isValidExperimentKey(e){return typeof e=="string"&&e.length>0&&e.length<=On&&xn.test(e)}static isValidExperimentVariant(e){return typeof e=="string"&&e.length>0&&e.length<=Cn}loadPersistedExperiments(){try{let e=this.persistentStorage.getItem(Mr);if(!e||typeof e!="object")return{};let t={};for(let[r,n]of Object.entries(e))i.isValidExperimentKey(r)&&i.isValidExperimentVariant(n)&&(t[r]=n);return t}catch(e){return this.logger.debug("Failed to load persisted experiments",e),{}}}persistExperiments(){try{this.persistentStorage.setItem(Mr,this.experiments)}catch(e){this.logger.debug("Failed to persist experiments",e)}}resolveExperiments(e){let t={...this.experiments};if(e&&typeof e=="object")for(let[r,n]of Object.entries(e))i.isValidExperimentKey(r)&&i.isValidExperimentVariant(n)&&(t[r]=n);return Object.keys(t).length>0?t:void 0}isTrackingBlocked(){return typeof navigator>"u"?!1:Tr(pe(0))}resolveSessionId(){try{if(this.config.sessionContinuity)return this.getContinuitySessionId();let e=Date.now(),t=this.readPerTabSession();if(t&&e-t.lastActiveAt<this.perTabInactivityMs(t))return this.persistPerTabSession(t.id,e),this.seq=0,t.id;let r=S();return this.persistPerTabSession(r,e),this.seq=0,this.logger.debug("Created session id",r),r}catch(e){return this.logger.error("Failed to get session id",e),this.reportTelemetry("error","failed to get session id"),""}}getContinuitySessionId(){let e=Date.now(),t=this.persistentStorage.getItem(Tt);if(t?.id&&e-t.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(t.id,e),this.seq=this.persistentStorage.getItem(B)??0,t.id;if(!t?.id){let n=this.readPerTabSession();if(n&&e-n.lastActiveAt<this.config.sessionInactivityMs)return this.persistContinuitySession(n.id,e),this.persistentStorage.setItem(B,0),this.seq=0,this.logger.debug("Adopted per-tab session id as continuity session",n.id),n.id}let r=S();return this.persistContinuitySession(r,e),this.persistentStorage.setItem(B,0),this.seq=0,this.logger.debug("Created continuity session id",r),r}persistContinuitySession(e,t){this.lastActivityWriteAt=t,this.persistentStorage.setItem(Tt,{id:e,lastActiveAt:t})}readPerTabSession(){let e=this.sessionStorage.getItem(Ar);if(e){if(typeof e=="string")return qr.test(e)?{id:e,lastActiveAt:Date.now()}:void 0;if(typeof e.lastActiveAt=="number")return qr.test(e.id)?e:void 0}}persistPerTabSession(e,t){this.lastActivityWriteAt=t;let r=this.configOverrides.sessionInactivityMs!==void 0||this.config.version?this.config.sessionInactivityMs:this.readPerTabSession()?.inactivityMs;this.sessionStorage.setItem(Ar,{id:e,lastActiveAt:t,...r===void 0?{}:{inactivityMs:r}})}perTabInactivityMs(e){return this.configOverrides.sessionInactivityMs!==void 0?this.config.sessionInactivityMs:e.inactivityMs??this.config.sessionInactivityMs}nextSeq(){if(!this.config.sessionContinuity){let r=Date.now();return this.sessionId&&r-this.lastActivityWriteAt>=Ur&&this.persistPerTabSession(this.sessionId,r),this.seq++}let e=()=>{let r=Date.now(),n=this.persistentStorage.getItem(Tt),o=!1;if(!n?.id&&this.sessionId)this.persistContinuitySession(this.sessionId,r);else if(n?.id)r-this.lastActivityWriteAt>=Ur&&this.persistContinuitySession(n.id,r),n.id!==this.sessionId&&(this.sessionId=n.id,this.queue.setSessionId(n.id),o=!0);else{let l=S();this.persistContinuitySession(l,r),this.persistentStorage.setItem(B,0),this.sessionId=l,this.queue.setSessionId(l),this.seq=0,o=!0}let s=this.persistentStorage.getItem(B);o&&(this.seq=typeof s=="number"?s:0);let a=typeof s=="number"&&s>this.seq?s:this.seq;return this.seq=a+1,this.persistentStorage.setItem(B,this.seq),a},t=this.config.seqLockTimeoutMs;return t===0||!tr(0)?e():he(0,this.seqLockName,e,{timeoutMs:t,onTimeout:()=>{this.logger.warn(`Sequence Web Lock acquisition timed out after ${t}ms; using fallback`),this.reportTelemetry("info",`seq web lock timeout; using fallback, ${t}ms`)}})}resolveTrackingSourcePath(){if(!(typeof window>"u"))return Mt(0,this.config.sourcePathQuery,this.config.sourcePathQueryAllow)}resolveEventTabId(){return this.eventTabId===void 0&&(this.eventTabId=this.deviceCollector.getTabId()),this.eventTabId}trackSubflowStarted(e,t,r,n){let o={subflowType:e,...t};this.track("subflow_started",o,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{id:n,subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowTrigger(e,t,r){let n={subflowType:e,...t};this.track("subflow_trigger",n,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}trackSubflowStepStarted(e,t,r,n,o){let s={subflowType:e,stepName:t,stepData:r,identifier:n?.identifier,ignoreAsInteraction:o};this.track("subflow_step_started",s,n?.userReference,void 0,void 0,n?.explicitTimestamp,n?.experiments,{subflowStartEventId:n?.subflowStartEventId,sessionId:n?.captureSessionId,initiator:n?.initiator})}trackSubflowStepFinished(e,t,r,n){let o={subflowType:e,stepName:t,stepData:r,identifier:n?.identifier};this.track("subflow_step_finished",o,n?.userReference,void 0,void 0,n?.explicitTimestamp,n?.experiments,{subflowStartEventId:n?.subflowStartEventId,sessionId:n?.captureSessionId,initiator:n?.initiator})}trackSubflowStepError(e,t,r,n){let o={subflowType:e,stepName:t,stepData:r,identifier:n?.identifier};this.track("subflow_step_error",o,n?.userReference,void 0,void 0,n?.explicitTimestamp,n?.experiments,{subflowStartEventId:n?.subflowStartEventId,sessionId:n?.captureSessionId,initiator:n?.initiator})}trackSubflowError(e,t,r){let n={subflowType:e,stepData:t};this.track("subflow_error",n,r?.userReference,void 0,void 0,r?.explicitTimestamp,r?.experiments,{subflowStartEventId:r?.subflowStartEventId,sessionId:r?.captureSessionId,initiator:r?.initiator})}async track(e,t,r,n,o,s,a,l){try{if(this.isTrackingBlocked()){this.logger.debug(`Skipping event "${e}" for blocked user agent.`);return}(e==="flow_finished"||e==="flow_auto_finished"||e==="flow_reset")&&this.windowObserver?.flushInputs();let p=s??Date.now(),d=l?.id??S(),u=l?.sessionId??this.sessionId,f=this.nextSeq(),h=typeof f=="number"?f:await f,m=this.resolveTrackingSourcePath(),c={type:"predefined",name:e,id:d,timestamp:p,seq:h,data:t,user:r,contexts:o,tags:n,experiments:this.resolveExperiments(a),meta:{captureVersion:1,pageId:ee(),initiator:l?.initiator,trackingSourcePath:m??"",subflowStartEventId:l?.subflowStartEventId,tabId:this.resolveEventTabId()}},v=this.deviceInfoManager.getForEvent();v&&(c.deviceInfo=v),this.logger.debug(`Track: ${e}`,JSON.stringify(c,null,2));let y=this.passwordManagerSampler?.takeReport(u);y&&(c.passwordManagers=y),this.queue.enqueue(c,u)}catch(p){this.logger.error(`Failed to process event "${e}" before enqueue`,p),this.reportTelemetry("error",`failed to process event "${e}" before enqueue`)}}flowStarted(e,t,r,n,o){try{let s=S(),a=this.sessionId,l={...this.options.defaultTags,...this.applicationTag(),...t};return this.track("flow_started",e,void 0,l,n,o?.explicitTimestamp,r,{id:s,sessionId:a}),this.flowHandle(s,a)}catch(s){return this.logger.warn("Failed to start flow",s),{enrich:async()=>{}}}}flowDecided(e,t,r){this.track("flow_decided",e,void 0,t,void 0,void 0,r)}conversion(e,t,r){let{userId:n,identifier:o,crossEnvironmentTransactionID:s,...a}=e,l={userId:n,identifier:o,crossEnvironmentTransactionID:s},p={...this.options.defaultTags,...this.applicationTag(),...t};this.track("conversion",a,l,p,void 0,void 0,r)}flowFinished(e,t,r){try{let{userId:n,identifier:o,...s}=e,a={userId:n,identifier:o},l=S(),p=this.sessionId;return this.track("flow_finished",s,a,t,void 0,void 0,r,{id:l,sessionId:p}),this.flowHandle(l,p)}catch(n){return this.logger.warn("Failed to finish flow",n),{enrich:async()=>{}}}}flowHandle(e,t){return{enrich:async r=>{try{await this.track("flow_enriched",{targetEventId:e},{...r},void 0,void 0,void 0,void 0,{sessionId:t})}catch(n){this.logger.warn("Failed to enrich flow",n)}}}}flowReset(e,t,r){this.track("flow_reset",e,void 0,t,void 0,void 0,r)}flowAutoFinished(e,t,r){let{userId:n,identifier:o,...s}=e,a={userId:n,identifier:o};this.track("flow_auto_finished",s,a,t,void 0,void 0,r)}setUser(e){this.track("flow_enriched",{match:{flowType:"*",at:"during"},expFol:!0},{...e})}setFlowTags(e,t){try{if(!e||typeof e!="object"){this.logger.warn("setFlowTags: ignoring non-object tags");return}let r={};for(let[o,s]of Object.entries(e)){if(o===""||typeof s!="string"){this.logger.warn(`setFlowTags: ignoring invalid tag "${o}"`);continue}r[o]=s}if(Object.keys(r).length===0)return;let n={match:{flowType:t?.flowType??"*",at:"during"}};t?.expandToChildren!==void 0&&(n.expCh=t.expandToChildren),t?.expandToFollowing!==void 0&&(n.expFol=t.expandToFollowing),this.track("flow_enriched",n,void 0,r)}catch(r){this.logger.warn("Failed to set flow tags",r)}}authMethodsDecisionStarted(e,t,r,n){this.track("auth_method_decision_started",e,void 0,t,void 0,n?.explicitTimestamp,r)}authMethodsDecisionFinished(e,t,r){this.track("auth_method_decision_finished",e,void 0,t,void 0,void 0,r)}authDecisionStarted(e,t,r){this.track("auth_decision_started",e,void 0,t,void 0,void 0,r)}authDecisionFinished(e,t,r){this.track("auth_decision_finished",e,void 0,t,void 0,void 0,r)}enqueueLowEvent(e,t){try{if(this.isTrackingBlocked()){this.logger.debug(`Skipping low event "${e.lowType}" for blocked user agent.`);return}this.queue.enqueueLow({...e,captureSeq:e.captureSeq??C(),captureVersion:1,pageId:e.pageId??ee()},t)}catch(r){this.logger.error(`Failed to process low event "${e.lowType}" before enqueue`,r)}}telemetry(e,t){try{if(this.isTrackingBlocked()){this.logger.debug("Skipping telemetry for blocked user agent.");return}let r=typeof t=="string"?t:String(t);if(r.length===0)return;let n={id:S(),level:e,message:r.length>Br?r.slice(0,Br):r,ts:Date.now()};this.queue.enqueueTelemetry(n)}catch(r){this.logger.error("Failed to process telemetry before enqueue",r)}}probe(e){try{if(this.isTrackingBlocked()){this.logger.debug("Skipping probe for blocked user agent.");return}if(!e||typeof e!="object"||typeof e.kind!="string"||!Pn.test(e.kind)){this.logger.debug("Dropping probe with an invalid kind.");return}let t=e.payload;if(!t||typeof t!="object"){this.logger.debug(`Dropping probe "${e.kind}" without an object payload.`);return}let r=typeof e.pageId=="string"&&Nr.test(e.pageId)?e.pageId:this.defaultProbePageId(),n={id:S(),kind:e.kind,ts:typeof e.ts=="number"&&Number.isFinite(e.ts)?Math.round(e.ts):Date.now(),pageId:r,seq:this.nextProbeSeq(r),payload:t};typeof e.cfg=="string"&&Nr.test(e.cfg)&&(n.cfg=e.cfg);let o=Mn(e.ctx);o&&(n.ctx=o),this.queue.enqueueProbe(n)}catch(t){this.logger.error("Failed to process probe before enqueue",t)}}defaultProbePageId(){return this.probePageId??=An()}nextProbeSeq(e){let t=this.probeSeqs.get(e)??0;if(this.probeSeqs.delete(e),this.probeSeqs.set(e,t+1),this.probeSeqs.size>Fn){let r=this.probeSeqs.keys().next().value;r!==void 0&&this.probeSeqs.delete(r)}return t}logInfo(e){this.telemetry("info",e)}logError(e){this.telemetry("error",e)}attachUndeliveredDeviceInfo(e){try{let t=this.deviceInfoManager;if(!t?.hasUndelivered())return;let r=ee(),n=e.find(o=>o.meta?.pageId===r&&!o.deviceInfo);n&&(n.deviceInfo=t.takeUndelivered())}catch(t){this.logger.error("Failed to attach device info to batch",t)}}reportTelemetry(e,t){if(!this.telemetryReporting){this.telemetryReporting=!0;try{if(this.reportedTelemetryKeys.has(t)||this.reportedTelemetryKeys.size>=Rn)return;if(this.reportedTelemetryKeys.add(t),!this.telemetryReady){this.pendingSelfTelemetry.push({level:e,message:t});return}this.telemetry(e,t)}catch{}finally{this.telemetryReporting=!1}}}flushKeepalive(e="manual"){try{this.queue.flushKeepalive(e)}catch(t){this.logger.error("Failed to flush queue keepalive",t)}}isPasswordManagerDomScanEnabled(){return this.fixedData?.pmdExplicit?this.fixedData.pmd:!0}lowEventFlushKeepalive(){this.config.tlf&&this.flushKeepalive("low-event-teardown")}passkeyLoginFullOperation(e){return new Oe(this,e)}passkeyEnrollmentFullOperation(e){return new Ae(this,e)}passkeyDeletionOperationFull(e){return new Me(this,e)}passwordLoginFullOperation(e){return new He(this,e)}passwordEnrollmentFullOperation(e){return new Be(this,e)}emailLinkOperationFull(e){return new De(this,e)}continueEmailLinkOperation(e){return new _e(this,e)}emailOtpOperationFull(e){return new Fe(this,e)}smsOtpOperationFull(e){return new Re(this,e)}totpOperationFull(e){return new Ke(this,e)}provideIdentifierOperationFull(e){return new Ne(this,e)}provideDataOperationFull(e){return new Ye(this,e)}formOperationFull(e){return new Qe(this,e)}socialLoginOperationFull(e){return new Ue(this,e)}ssoLoginOperationFull(e){return new qe(this,e)}appConfirmationOperationFull(e){return new Ve(this,e)}keySigningOperationFull(e){return new ae(this,e)}keyRegistrationOperationFull(e){return new le(this,e)}captchaOperationFull(e){return new We(this,e)}trustedDeviceCheckOperationFull(e){return new ze(this,e)}trustedDeviceEnrollmentOperationFull(e){return new je(this,e)}async destroy(){if(this.configManager?.destroy(),this.passwordManagerSampler?.destroy(),this.windowObserver?.destroy(),this.deviceInfoManager.destroy(),this.config.td)try{await this.queue.flush("destroy")}catch(e){this.logger.error("Failed to flush queue during destroy",e)}this.queue.destroy()}getSessionId(){if(!this.sessionId){let e=this.resolveSessionId();e&&(this.sessionId=e,this.queue.setSessionId(e))}return this.sessionId||void 0}resetSession(){let e=S();return this.config.sessionContinuity?(this.persistContinuitySession(e,Date.now()),this.persistentStorage.setItem(B,0)):this.persistPerTabSession(e,Date.now()),this.sessionId=e,this.seq=0,this.queue.setSessionId(e),this.logger.debug(`Session reset: ${e}`),e}},_n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";function An(){let i=new Uint8Array(16);try{crypto.getRandomValues(i)}catch{for(let t=0;t<i.length;t++)i[t]=Math.floor(Math.random()*256)}let e="";for(let t=0;t<i.length;t++)e+=_n[i[t]&63];return e}function Mn(i){if(!i||typeof i!="object")return;let e={};for(let t of["state","flowType","step"]){let r=i[t];typeof r=="string"&&r.length>0&&(e[t]=r.slice(0,Ln))}return Object.keys(e).length>0?e:void 0}function Ze(i,e,t){let r=window.Corbado;r?.[e]&&(t(r[e]),delete window.Corbado[e])}function Kr(i,e){window.Corbado=e}var Et={};function Vr(i,e="default"){Et[e]=new Je(i)}function Wr(i="default"){if(!Et[i])throw new Error(`Tracker ${i} not initialized (call Corbado.init() first)`);return Et[i]}function Hn(i){for(let e of i)Vr(e[0],e[1])}var $r={};function Qr(i,e,t=[],r){let n=Wr(i),o=n[e];if(typeof o!="function")return;let s=o.apply(n,t);r&&s&&typeof s=="object"&&($r[r]=s)}function Gr(i,e,t=[]){let r=$r[i];if(!r)return;let n=e.split("."),o=r;for(let a=0;a<n.length-1;a++)if(o=o?.[n[a]],!o)return;let s=o[n[n.length-1]];typeof s=="function"&&s.apply(o,t)}function Bn(i){for(let e of i)Qr(e[0],e[1],Array.isArray(e[2])?e[2]:[],e[3])}function Nn(i){for(let e of i)Gr(e[0],e[1],Array.isArray(e[2])?e[2]:[])}typeof window<"u"&&(Ze(0,"IQ",Hn),Ze(0,"MQ",Bn),Ze(0,"OQ",Nn),Kr(0,{init:Vr,get:Wr,__dispatchMethod:Qr,__dispatchOp:Gr}));})();
|
|
5
5
|
/*! Bundled license information:
|
|
6
6
|
|
|
7
7
|
detectincognitojs/dist/detectIncognito.esm.js:
|