@syntrologie/runtime-sdk 2.8.0-canary.477 → 2.8.0-canary.478
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/smart-canvas.esm.js +2 -2
- package/dist/smart-canvas.esm.js.map +1 -1
- package/dist/smart-canvas.js +2 -2
- package/dist/smart-canvas.js.map +1 -1
- package/dist/smart-canvas.min.js +2 -2
- package/dist/smart-canvas.min.js.map +1 -1
- package/dist/smart-canvas.shopify.js +2 -2
- package/dist/smart-canvas.shopify.js.map +1 -1
- package/dist/smart-canvas.shopify.min.js +2 -2
- package/dist/smart-canvas.shopify.min.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/smart-canvas.min.js
CHANGED
|
@@ -380,7 +380,7 @@ Actions:`,b.map((Z,te)=>` [${te}] ${Z.kind} ${Z.anchorId?`anchor="${Z.anchorId.
|
|
|
380
380
|
style=${O({position:"relative",display:"flex",alignItems:"center",justifyContent:"center",width:"20px",height:"20px",borderRadius:"9999px",background:`var(--sc-launcher-badge-background, var(--sc-color-primary-hover, ${this.colorPrimaryHover}))`,color:"var(--sc-launcher-badge-color, #ffffff)",fontSize:"11px",fontWeight:"700"})}
|
|
381
381
|
>${r}</span>
|
|
382
382
|
</div>
|
|
383
|
-
`}};nc.properties={isOpen:{type:Boolean},notificationCount:{type:Number},launcherIcon:{attribute:!1},label:{type:String},colorPrimaryHover:{type:String},hasActiveTiles:{type:Boolean},pendingCanvasShape:{type:Boolean},_launcherPos:{state:!0},_hovered:{state:!0},_shapeReady:{state:!0},_pulseResting:{state:!0}};customElements.define("syntro-launcher",nc);function rc(n,e,t="merge"){return t==="first-match"?VC(n,e):UC(n,e)}function VC(n,e){for(let t of e){let r=n.getFeatureValue?.(t,null);if(!r||typeof r!="object")continue;let i=r,s=i.tiles&&i.tiles.length>0,o=i.actions&&i.actions.length>0,a=i.slots&&Object.keys(i.slots).length>0;if(s||o||a)return oy([i])}return null}function UC(n,e){let t=[];for(let r of e){let i=n.getFeatureValue?.(r,null);if(!i||typeof i!="object")continue;let s=i,o=s.tiles&&s.tiles.length>0,a=s.actions&&s.actions.length>0,l=s.slots&&Object.keys(s.slots).length>0;(o||a||l)&&t.push(s)}return t.length===0?null:oy(t)}function oy(n){let e=[],t=[],r=new Set,i=[],s,o,a,l,c,u,p,f,h;for(let y of n){let w=y.tiles?.length??0;y.tiles&&e.push(...y.tiles);let x=0;if(y.actions)for(let k of y.actions){let I=k.label;if(I){if(r.has(I))continue;r.add(I)}t.push(k),x++}let _=y.meta?.variant_id;_&&(w>0||x>0)&&i.push({variant_id:_,tiles:w,actions:x}),s??(s=y.fetchedAt),o??(o=y.schemaVersion),a??(a=y.configVersion),l??(l=y.canvasTitle),c??(c=y.displayMode),u??(u=y.theme),p??(p=y.launcher),f??(f=y.meta),h??(h=y.slots)}let g=new Map,v=[];for(let y of e){let w=y?.id;if(typeof w=="string"&&w){let x=g.get(w);if(x!==void 0){v[x]=y;continue}g.set(w,v.length)}v.push(y)}let m=i.length>0?{...f??{},variants:i}:f;return{tiles:v,actions:t,fetchedAt:s??new Date().toISOString(),...o&&{schemaVersion:o},...a&&{configVersion:a},...l&&{canvasTitle:l},...c&&{displayMode:c},...u&&{theme:u},...p&&{launcher:p},...m&&{meta:m},...h&&{slots:h}}}var Ip=!1;function ay(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("syntro_debug")==="true"}catch{return!1}}function $p(n){if(ay()){Ip=!0;return}Ip=n??!1}function jC(){return ay()?!0:Ip}function q(n,e,t){jC()&&(t!==void 0?console.log(`[${n}]`,e,t):console.log(`[${n}]`,e))}function We(n,e,t){t!==void 0?console.warn(`[${n}]`,e,t):console.warn(`[${n}]`,e)}function ic(n,e,t){t!==void 0?console.error(`[${n}]`,e,t):console.error(`[${n}]`,e)}var sc=class{constructor(e){this.config=e;this.counters=new Map;this.histograms=new Map;this.windowStartMs=Date.now();this.timer=null;this.pagehideHandler=null;this.runtime=null;this.adapterCleanup=null;this.resource=e.resource,this.flushIntervalMs=e.flushIntervalMs??6e4}bindRuntime(e){this.runtime=e}attachAdapterCleanup(e){this.adapterCleanup=e}increment(e,t=1){this.counters.set(e,(this.counters.get(e)??0)+t)}snapshotCounters(){let e={};for(let[t,r]of this.counters)e[t]=r;return e}recordHistogram(e,t){let r=this.histograms.get(e)??[];r.push(t),this.histograms.set(e,r)}snapshotHistograms(){let e={};for(let[t,r]of this.histograms){if(r.length===0)continue;let i=[...r].sort((s,o)=>s-o);e[t]={count:i.length,p50:ly(i,.5),p95:ly(i,.95)}}return e}async flush(){let e=this.snapshotCounters(),t=this.snapshotHistograms();if(!(Object.keys(e).length>0||Object.keys(t).length>0))return;let i=null,s="";try{i=this.runtime?.getSurface()??null}catch{}try{s=this.runtime?.getSessionId()??""}catch{}let o={resource:{...this.resource,sessionId:s,surfaceType:i?.type??"unknown",surfaceHost:i?.host??"unknown",surfaceDevice:i?.device??"unknown",surfaceMode:i?.mode??"unknown"},windowSeconds:Math.max(1,Math.round((Date.now()-this.windowStartMs)/1e3)),windowStartUnixMs:this.windowStartMs,counters:e,histograms:t};this.counters.clear(),this.histograms.clear(),this.windowStartMs=Date.now();try{await this.config.emit(o)}catch{}}start(){this.timer===null&&(this.timer=setInterval(()=>{this.flush()},this.flushIntervalMs),typeof window<"u"&&(this.pagehideHandler=()=>{this.flush()},window.addEventListener("pagehide",this.pagehideHandler)))}stop(){if(this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.pagehideHandler!==null&&typeof window<"u"&&(window.removeEventListener("pagehide",this.pagehideHandler),this.pagehideHandler=null),this.adapterCleanup!==null){try{this.adapterCleanup()}catch{}this.adapterCleanup=null}}};function ly(n,e){if(n.length===0)return 0;let t=(n.length-1)*e,r=Math.floor(t),i=Math.ceil(t);return r===i?n[r]:n[r]+(n[i]-n[r])*(t-r)}var Eo=null;function Pp(n){return Eo?.stop(),Eo=new sc(n),Eo.start(),Eo}function jt(){return Eo}var mn=(n,e)=>({key:n,value:{stringValue:e}}),Op=(n,e)=>({key:n,value:{intValue:Math.round(e)}}),cy=(n,e)=>({key:n,value:{doubleValue:e}});function WC(n){let{resource:e,counters:t,histograms:r,windowSeconds:i,windowStartUnixMs:s}=n,o=[mn("service.name",e.serviceName),mn("service.version",e.serviceVersion),mn("syntro.posthog_key",e.posthogKey),mn("syntro.session_id",e.sessionId),mn("syntro.surface_type",e.surfaceType),mn("syntro.surface_host",e.surfaceHost),mn("syntro.surface_device",e.surfaceDevice),mn("syntro.surface_mode",e.surfaceMode),mn("syntro.host_origin",e.hostOrigin)],a=[Op("window_seconds",i)];for(let[u,p]of Object.entries(t))p!==void 0&&a.push(Op(u,p));for(let[u,p]of Object.entries(r))p!==void 0&&(a.push(Op(`${u}_count`,p.count)),a.push(cy(`${u}_p50`,p.p50)),a.push(cy(`${u}_p95`,p.p95)));let l=`${Date.now()}000000`,c=`${s}000000`;return{resourceLogs:[{resource:{attributes:o},scopeLogs:[{scope:{name:"syntro.sdk.health"},logRecords:[{timeUnixNano:c,observedTimeUnixNano:l,severityText:"INFO",body:{stringValue:"sdk_health_window"},attributes:a}]}]}]}}function Mp(n){let e=n.fetchImpl??fetch;return async t=>{let r=JSON.stringify(WC(t)),i=()=>e(n.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0,mode:"cors"});try{let s=await i();if(!s.ok&&s.status>=500)try{await i()}catch{}}catch{try{await i()}catch{}}}}function zC(){if(typeof document>"u")return;let n=document.currentScript;if(n?.src)return n.src;try{let e=Array.from(document.scripts);for(let t=e.length-1;t>=0;t-=1){let r=e[t]?.src;if(typeof r=="string"&&(r.includes("runtime-sdk")||r.includes("smart-canvas")))return r}}catch{}}var Lp=zC();function Np(){if(!Lp)return;let n=Lp.lastIndexOf("/");if(n!==-1)return Lp.substring(0,n+1)}var yy=-1,qi=n=>{addEventListener("pageshow",(e=>{e.persisted&&(yy=e.timeStamp,n(e))}),!0)},Wt=(n,e,t,r)=>{let i,s;return o=>{e.value>=0&&(o||r)&&(s=e.value-(i??0),(s||i===void 0)&&(i=e.value,e.delta=s,e.rating=((a,l)=>a>l[1]?"poor":a>l[0]?"needs-improvement":"good")(e.value,t),n(e)))}},zp=n=>{requestAnimationFrame((()=>requestAnimationFrame((()=>n()))))},qp=()=>{let n=performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},Co=()=>qp()?.activationStart??0,zt=(n,e=-1)=>{let t=qp(),r="navigate";return yy>=0?r="back-forward-cache":t&&(document.prerendering||Co()>0?r="prerender":document.wasDiscarded?r="restore":t.type&&(r=t.type.replace(/_/g,"-"))),{name:n,value:e,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},Fp=new WeakMap;function Zp(n,e){return Fp.get(n)||Fp.set(n,new e),Fp.get(n)}var Hp=class{constructor(){en(this,"t");en(this,"i",0);en(this,"o",[])}h(e){if(e.hadRecentInput)return;let t=this.o[0],r=this.o.at(-1);this.i&&t&&r&&e.startTime-r.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}},ko=(n,e,t={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(n)){let r=new PerformanceObserver((i=>{Promise.resolve().then((()=>{e(i.getEntries())}))}));return r.observe({type:n,buffered:!0,...t}),r}}catch{}},Gp=n=>{let e=!1;return()=>{e||(n(),e=!0)}},zi=-1,_y=new Set,uy=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,Bp=n=>{if(document.visibilityState==="hidden"){if(n.type==="visibilitychange")for(let e of _y)e();isFinite(zi)||(zi=n.type==="visibilitychange"?n.timeStamp:0,removeEventListener("prerenderingchange",Bp,!0))}},ac=()=>{if(zi<0){let n=Co();zi=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((t=>t.name==="hidden"&&t.startTime>n))[0]?.startTime)??uy(),addEventListener("visibilitychange",Bp,!0),addEventListener("prerenderingchange",Bp,!0),qi((()=>{setTimeout((()=>{zi=uy()}))}))}return{get firstHiddenTime(){return zi},onHidden(n){_y.add(n)}}},lc=n=>{document.prerendering?addEventListener("prerenderingchange",(()=>n()),!0):n()},dy=[1800,3e3],Kp=(n,e={})=>{lc((()=>{let t=ac(),r,i=zt("FCP"),s=ko("paint",(o=>{for(let a of o)a.name==="first-contentful-paint"&&(s.disconnect(),a.startTime<t.firstHiddenTime&&(i.value=Math.max(a.startTime-Co(),0),i.entries.push(a),r(!0)))}));s&&(r=Wt(n,i,dy,e.reportAllChanges),qi((o=>{i=zt("FCP"),r=Wt(n,i,dy,e.reportAllChanges),zp((()=>{i.value=performance.now()-o.timeStamp,r(!0)}))})))}))},py=[.1,.25],by=(n,e={})=>{let t=ac();Kp(Gp((()=>{let r,i=zt("CLS",0),s=Zp(e,Hp),o=l=>{for(let c of l)s.h(c);s.i>i.value&&(i.value=s.i,i.entries=s.o,r())},a=ko("layout-shift",o);a&&(r=Wt(n,i,py,e.reportAllChanges),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),qi((()=>{s.i=0,i=zt("CLS",0),r=Wt(n,i,py,e.reportAllChanges),zp((()=>r()))})),setTimeout(r))})))},wy=0,Dp=1/0,oc=0,qC=n=>{for(let e of n)e.interactionId&&(Dp=Math.min(Dp,e.interactionId),oc=Math.max(oc,e.interactionId),wy=oc?(oc-Dp)/7+1:0)},Vp,fy=()=>Vp?wy:performance.interactionCount??0,ZC=()=>{"interactionCount"in performance||Vp||(Vp=ko("event",qC,{type:"event",buffered:!0,durationThreshold:0}))},hy=0,Up=class{constructor(){en(this,"u",[]);en(this,"l",new Map);en(this,"m");en(this,"p")}v(){hy=fy(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((fy()-hy)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&e.entryType!=="first-input")return;let t=this.u.at(-1),r=this.l.get(e.interactionId);if(r||this.u.length<10||e.duration>t.P){if(r?e.duration>r.P?(r.entries=[e],r.P=e.duration):e.duration===r.P&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],P:e.duration},this.l.set(r.id,r),this.u.push(r)),this.u.sort(((i,s)=>s.P-i.P)),this.u.length>10){let i=this.u.splice(10);for(let s of i)this.l.delete(s.id)}this.p?.(r)}}},xy=n=>{let e=globalThis.requestIdleCallback||setTimeout;document.visibilityState==="hidden"?n():(n=Gp(n),addEventListener("visibilitychange",n,{once:!0,capture:!0}),e((()=>{n(),removeEventListener("visibilitychange",n,{capture:!0})})))},gy=[200,500],Sy=(n,e={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let t=ac();lc((()=>{ZC();let r,i=zt("INP"),s=Zp(e,Up),o=l=>{xy((()=>{for(let u of l)s.h(u);let c=s.L();c&&c.P!==i.value&&(i.value=c.P,i.entries=c.entries,r())}))},a=ko("event",o,{durationThreshold:e.durationThreshold??40});r=Wt(n,i,gy,e.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),qi((()=>{s.v(),i=zt("INP"),r=Wt(n,i,gy,e.reportAllChanges)})))}))},jp=class{constructor(){en(this,"m")}h(e){this.m?.(e)}},my=[2500,4e3],Ey=(n,e={})=>{lc((()=>{let t=ac(),r,i=zt("LCP"),s=Zp(e,jp),o=l=>{e.reportAllChanges||(l=l.slice(-1));for(let c of l)s.h(c),c.startTime<t.firstHiddenTime&&(i.value=Math.max(c.startTime-Co(),0),i.entries=[c],r())},a=ko("largest-contentful-paint",o);if(a){r=Wt(n,i,my,e.reportAllChanges);let l=Gp((()=>{o(a.takeRecords()),a.disconnect(),r(!0)})),c=u=>{u.isTrusted&&(xy(l),removeEventListener(u.type,c,{capture:!0}))};for(let u of["keydown","click","visibilitychange"])addEventListener(u,c,{capture:!0});qi((u=>{i=zt("LCP"),r=Wt(n,i,my,e.reportAllChanges),zp((()=>{i.value=performance.now()-u.timeStamp,r(!0)}))}))}}))},vy=[800,1800],Wp=n=>{document.prerendering?lc((()=>Wp(n))):document.readyState!=="complete"?addEventListener("load",(()=>Wp(n)),!0):setTimeout(n)},Cy=(n,e={})=>{let t=zt("TTFB"),r=Wt(n,t,vy,e.reportAllChanges);Wp((()=>{let i=qp();i&&(t.value=Math.max(i.responseStart-Co(),0),t.entries=[i],r(!0),qi((()=>{t=zt("TTFB",0),r=Wt(n,t,vy,e.reportAllChanges),r(!0)})))}))};var ky="__syntro_vitals_bound",cc="__syntro_vitals_current_reporter";function Yp(n,e){if(typeof window>"u")return()=>{};let t=window;t[cc]=n;let r=null,i=e?.attributedScriptUrlPrefix;if(i&&"PerformanceObserver"in window)try{r=new PerformanceObserver(s=>{let o=t[cc];if(o)for(let a of s.getEntries()){let l=a.attribution;if(!l)continue;l.some(u=>(u.containerSrc??u.name??"").startsWith(i))&&(o.increment("longtasks_self_count"),o.increment("longtasks_self_blocking_ms",Math.round(a.duration)))}}),r.observe({type:"longtask",buffered:!0})}catch{r=null}if(!t[ky]){t[ky]=!0;let s=o=>a=>{t[cc]?.recordHistogram(o,a.value)};Ey(s("lcp_ms")),Sy(s("inp_ms")),Kp(s("fcp_ms")),Cy(s("ttfb_ms")),by(o=>{t[cc]?.recordHistogram("cls_score",o.value)})}return()=>{r?.disconnect()}}var Zi="2.8.0-canary.477";var vn="2.0";var GC=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function KC(n){try{let e=new URL(n),t=/^(localhost|127\.0\.0\.1)$/.test(e.hostname);return e.protocol!=="https:"&&!t?(console.warn("[SmartCanvas] Config URI must use HTTPS:",n),!1):GC.some(i=>e.hostname===i)?!0:(console.warn("[SmartCanvas] Config URI host not in allowlist:",e.hostname),!1)}catch{return console.warn("[SmartCanvas] Invalid config URI:",n),!1}}function YC(n){if(typeof window>"u")return!1;try{return new URL(n).origin===window.location.origin}catch{return!1}}var Ay="syntro_config_cache",JC=1440*60*1e3;function Ty(){try{return typeof localStorage<"u"&&localStorage!==null}catch{return!1}}function XC(n,e){if(Ty())try{let t={config:n,timestamp:Date.now(),sdkVersion:e};localStorage.setItem(Ay,JSON.stringify(t))}catch{}}function QC(n){if(!Ty())return null;try{let e=localStorage.getItem(Ay);if(!e)return null;let t=JSON.parse(e);return!t.config||typeof t.timestamp!="number"||!t.sdkVersion||t.sdkVersion!==n||Date.now()-t.timestamp>JC?null:t.config}catch{return null}}var Ry=({configUri:n,experiments:e,featureKey:t})=>{if(n)return n;if(e&&t){let r=e.getFeatureValue?.(t,null);if(r)return r}};function ek(n,e,t){if(e){let r=n.getFeatureValue?.(e,null);if(r&&typeof r=="object"){let i=r.variant_flags;if(i&&i.length>0)return i}}if(n.getAllFeatures){let r=n.getAllFeatures();return t?Object.keys(r).filter(i=>i.startsWith(t)):Object.keys(r)}return[]}var Ur=({configUri:n,experiments:e,featureKey:t,credentials:r,manifestKey:i,variantFlagPrefix:s,sdkVersion:o})=>async()=>{if(e&&(i||s||e.getAllFeatures)){let p=ek(e,i,s);if(console.log("[SmartCanvas Config] Variant key discovery:",p.length,"keys found"),p.length>0){let f=rc(e,p);if(console.log("[SmartCanvas Config] resolveVariantConfigs result:",f?`tiles=${f.tiles?.length}`:"null"),f)return q("SmartCanvas Config","Resolved config from variant flags",f),f}}else console.log("[SmartCanvas Config] Skipping multi-flag mode:",{hasExperiments:!!e,manifestKey:i,variantFlagPrefix:s,hasGetAllFeatures:!!e?.getAllFeatures});let a=Ry({configUri:n,experiments:e,featureKey:t});if(!a)return q("SmartCanvas Config","No config available \u2014 returning empty config"),{tiles:[],actions:[],fetchedAt:new Date().toISOString()};if(!KC(a))throw new Error(`SmartCanvas: config URI not allowed: ${a}`);let l=r??(YC(a)?"include":"omit"),c=performance.now(),u=!1;try{let p=await fetch(a,{credentials:l,headers:{"X-SDK-Version":Zi,"X-SDK-Schema-Version":vn}});if(!p.ok)throw jt()?.increment("flag_fetch_errors"),u=!0,new Error(`SmartCanvas: failed to fetch config (${p.status})`);let f=await p.json(),h=performance.now()-c;return jt()?.increment("flag_fetch_count"),jt()?.recordHistogram("flag_fetch_latency_ms",h),q("SmartCanvas Config","Fetched config from URI",f),o&&XC(f,o),f}catch(p){if(u||jt()?.increment("flag_fetch_errors"),o){let f=QC(o);if(f)return q("SmartCanvas Config","Serving config from offline cache"),f}throw p}};var uc=class{constructor(e){this.listeners=new Set;let t=e?.open??!1;if(e?.open===void 0)try{let r=sessionStorage?.getItem("syntro:editor:panel-open");r!==null&&(t=JSON.parse(r))}catch{}this.state={open:t}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOpen(e){if(this.state.open!==e){this.state={...this.state,open:e};try{sessionStorage?.setItem("syntro:editor:panel-open",JSON.stringify(e))}catch{}this.emit()}}toggle(){this.setOpen(!this.state.open)}emit(){for(let e of this.listeners)e(this.state)}},Jp=n=>new uc(n);var Pt={white:"#ffffff",black:"#000000"},ce={0:"#2c0b0a",1:"#5b1715",2:"#89221f",3:"#b72e2a",4:"#d44844",5:"#dd6d69",6:"#e5918f",7:"#eeb6b4",8:"#f6dada",9:"#faebea"},E={0:"#07080a",1:"#0f1318",2:"#0e1114",3:"#1c222a",4:"#2b333f",5:"#394454",6:"#475569",7:"#677384",8:"#87919f",9:"#a8afba",10:"#cbd0d7",11:"#e8eaee",12:"#f6f7f9"},Ae={0:"#07230a",1:"#0e4514",2:"#16681e",3:"#1d8a28",4:"#24ad32",5:"#4fbd5a",6:"#7acd82",7:"#a5deab",8:"#d0eed3",9:"#e5f6e7"},dt={0:"#301f09",1:"#5f3e12",2:"#8f5e1b",3:"#be7d24",4:"#ee9c2d",5:"#f1b057",6:"#f5c481",7:"#f8d7ab",8:"#fcebd5",9:"#fdf5ea"},Ce={0:"#330707",1:"#660f0e",2:"#991616",3:"#cc1e1d",4:"#ff2524",5:"#ff5150",6:"#ff7c7c",7:"#ffa8a7",8:"#ffd3d3",9:"#ffe9e9"},Ao={0:"#051533",1:"#0a2a66",2:"#0f3f98",3:"#1454cb",4:"#1969fe",5:"#4787fe",6:"#75a5fe",7:"#a3c3ff",8:"#d1e1ff",9:"#e8f0ff"},To={0:"#662500",1:"#993d00",2:"#cc5800",3:"#ff7700",4:"#fea85d",5:"#fec58f",6:"#ffd6ae",7:"#fee6cd",8:"#fff1e1",9:"#fff8f0"},Ro={0:"#151229",1:"#2a2452",2:"#40357c",3:"#5547a5",4:"#6a59ce",5:"#887ad8",6:"#a69be2",7:"#c3bdeb",8:"#e1def5",9:"#f0eefa"},Io={0:"#37091f",1:"#69123c",2:"#9b1c58",3:"#cd2575",4:"#ff2e92",5:"#ff58a8",6:"#ff82be",7:"#ffabd3",8:"#ffd5e9",9:"#ffeaf4"};var qt={primary:E[10],secondary:E[9],tertiary:E[8]},iL={primary:E[2],secondary:E[0]},sL={primary:E[4],secondary:E[3]},dc={primary:{text:Pt.white,icon:Pt.white,border:ce[3],backgroundDefault:ce[3],backgroundHover:ce[2]},neutral:{text:E[10],textHover:Pt.white,icon:E[10],iconHover:Pt.white,border:E[4],background:E[2]},link:{text:Pt.white,icon:Pt.white,hover:ce[5]},error:{text:Ce[5],hover:Ce[6]},success:{text:Ae[5],hover:Ae[6]}},oL={slateGrey:{content:E[10],pillOutline:E[10],borderPrimary:E[5],borderSecondary:E[5],background:E[3]},brand:{content:ce[9],pillOutline:ce[9],borderPrimary:ce[6],borderSecondary:ce[6],background:ce[0]},red:{content:Ce[8],pillOutline:Ce[4],borderPrimary:Ce[2],borderSecondary:Ce[2],background:Ce[0]},yellow:{content:dt[8],pillOutline:dt[4],borderPrimary:dt[2],borderSecondary:dt[2],background:dt[0]},green:{content:Ae[8],pillOutline:Ae[4],borderPrimary:Ae[2],borderSecondary:Ae[2],background:Ae[0]},purple:{content:Ro[8],pillOutline:Ro[4],borderPrimary:Ro[2],borderSecondary:Ro[2],background:Ro[0]},blue:{content:Ao[8],pillOutline:Ao[4],borderPrimary:Ao[2],borderSecondary:Ao[2],background:Ao[0]},orange:{content:To[8],pillOutline:To[4],borderPrimary:To[2],borderSecondary:To[2],background:To[0]},pink:{content:Io[8],pillOutline:Io[4],borderPrimary:Io[2],borderSecondary:Io[2],background:Io[0]}},aL={green:{content:Ae[8],border:Ae[2],background:Ae[0]},yellow:{content:dt[8],border:dt[2],background:dt[0]},red:{content:Ce[8],border:Ce[2],background:Ce[0]}},lL={green:{content:Ae[1],background:Ae[9]},yellow:{content:dt[1],background:dt[9]},red:{content:Ce[1],background:Ce[9]}},cL={content:E[10],border:E[4],background:E[3]},uL={backgroundDefault:E[2],backgroundHover:E[1],selected:E[3]},dL={background:E[2],icon:E[10],borderDefault:E[4],borderSelected:ce[3],textLabel:E[9],textPlaceholder:E[8],textHint:E[8]},pL={backgroundDefault:E[2],backgroundDisabled:E[0],textLabel:E[9],textPlaceholder:E[8],textHint:E[8],textError:Ce[5],iconDefault:E[9],iconPlaceholder:E[10],iconError:Ce[5],borderDefault:E[4],borderSelected:ce[3],borderError:Ce[5]},fL={handleDefault:Pt.white,handleDisabled:E[10],off:{backgroundDefault:E[4],backgroundHover:E[5],backgroundDisabled:E[4]},on:{backgroundDefault:Ae[3],backgroundHover:Ae[2],backgroundDisabled:E[4]}},hL={off:{backgroundDefault:"#00000000",backgroundHover:E[5],backgroundDisabled:E[2],border:E[6]},on:{backgroundDefault:Ae[0],backgroundHover:Ae[1],backgroundDisabled:E[2],border:Ae[3]}},gL={content:E[10],background:E[4]},mL={background:E[4],active:Ae[3]},vL={background:E[1],content:E[9],border:E[4]},yL={backgroundDefault:E[1],backgroundHover:E[3],backgroundActive:E[4],border:E[4],contentPrimary:E[10],contentSecondary:E[9],contentTertiary:E[8]},_L={background:E[1],content:E[9],border:E[4]},bL={activeBackground:E[3],activeContent:ce[5],inactiveContent:E[9],border:E[4]},wL={header:{textDefault:E[9],textHover:E[8],backgroundDefault:E[1]},border:E[4],cell:{textPrimary:E[10],textSecondary:E[9],backgroundDefault:E[2],backgroundHover:E[1]}},xL={textPrimaryDefault:E[10],textPrimaryHover:E[10],textSecondaryDefault:E[8],textSecondaryHover:E[9],iconPrimary:E[10],iconSecondary:E[8]},SL={background:Ae[1],active:Ae[5]},EL={textDefault:E[10],textSelected:Pt.white,textDisabled:E[7],backgroundDefault:E[2],backgroundMiddle:E[3],backgroundSelected:ce[3],border:E[4]},CL=E[9];var RL={size:56,inset:12,background:Pt.black,color:Pt.white,border:`2px solid ${ce[3]}`,shadowOpen:"0 4px 24px rgba(0,0,0,0.6), 0 0 0 2px rgba(255,255,255,0.08)",shadowClosed:"0 4px 24px rgba(0,0,0,0.6)"};function ae(n,e){return`${n}${Math.round(e*255).toString(16).padStart(2,"0")}`}function tk(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}var Iy={mode:"dark",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ce[3],colorPrimaryHover:ce[4],accentColor:"2 64% 44%",accentForeground:"#ffffff",borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:ae(E[1],.6),blur:"blur(24px)",border:"none",width:"clamp(380px, 25vw, 520px)",transitionDuration:"300ms",transitionEasing:"cubic-bezier(0.16, 1, 0.3, 1)",transitionFade:"6%",backdrop:!1,backdropColor:"rgba(0, 0, 0, 0.4)",padding:"0"},launcher:{background:dc.primary.backgroundDefault,backgroundHover:dc.primary.backgroundHover,color:dc.primary.icon,size:"56px",shadow:`0 8px 32px ${ae(E[0],.6)}`,borderRadius:"9999px"},tile:{background:ae(E[1],.6),backgroundHover:ae(E[1],.7),border:"1px solid rgba(255, 255, 255, 0.08)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.3)",titleColor:qt.primary,textColor:qt.secondary,iconBackground:`linear-gradient(135deg, ${ce[3]} 0%, ${ce[3]}cc 100%)`,iconShadow:`0 2px 8px ${ce[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:ae(E[1],.6),textColor:qt.primary,titleColor:qt.primary,arrowColor:ae(E[1],.6),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ce[3]}`},notification:{background:ae(E[0],.95),textColor:qt.primary,textSecondaryColor:qt.secondary,border:`1px solid ${E[5]}`,borderRadius:"12px",successColor:Ae[4],warningColor:dt[4],errorColor:Ce[4],iconBackground:ae(ce[3],.15),progressGradient:`linear-gradient(90deg, ${ce[3]}, ${ce[4]})`},content:{background:ae(E[3],.8),backgroundHover:ae(E[5],.6),border:`1px solid ${ae(E[5],.5)}`,borderRadius:"8px",textColor:qt.primary,textSecondaryColor:qt.secondary,itemDivider:"none",itemGap:"6px",itemPadding:"12px 16px",itemFontSize:"15px",bodyPadding:"0 16px 12px 16px",bodyFontSize:"14px",categoryPadding:"8px 4px 4px 4px",categoryGap:"4px",categoryFontSize:"12px",searchBackground:ae(E[3],.8),searchColor:qt.primary,chevronColor:"currentColor",bubbleBackground:ae(E[0],.35),bubbleBorder:`1px solid ${ae(E[12],.18)}`,bubbleBackgroundUser:ae(ce[3],.14),bubbleBorderUser:`1px solid ${ae(ce[3],.28)}`,bubbleBackgroundIdle:ae(E[3],.4),bubbleBorderIdle:`1px solid ${ae(E[12],.18)}`,bubbleBackgroundError:ae(Ce[1],.42),bubbleBorderError:`1px solid ${ae(Ce[4],.55)}`,bubbleTextError:Ce[8],codeBackground:ae(E[0],.25),codeBackgroundBlock:ae(E[0],.35),dividerColor:ae(E[12],.12),linkColor:ce[4]},mobile:{canvas:{backdrop:!0}}},$y={mode:"light",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ce[3],colorPrimaryHover:ce[2],accentColor:"2 64% 44%",accentForeground:"#ffffff",borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:ae(E[12],.7),blur:"blur(24px)",border:"none",width:"clamp(380px, 25vw, 520px)",transitionDuration:"300ms",transitionEasing:"cubic-bezier(0.16, 1, 0.3, 1)",transitionFade:"6%",backdrop:!1,backdropColor:"rgba(0, 0, 0, 0.3)",padding:"0"},launcher:{background:ce[3],backgroundHover:ce[2],color:"#ffffff",size:"56px",shadow:"0 8px 32px rgba(0, 0, 0, 0.15)",borderRadius:"9999px"},tile:{background:ae(E[12],.7),backgroundHover:ae(E[12],.8),border:"1px solid rgba(0, 0, 0, 0.06)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.12)",titleColor:E[1],textColor:E[6],iconBackground:`linear-gradient(135deg, ${ce[3]} 0%, ${ce[3]}cc 100%)`,iconShadow:`0 2px 8px ${ce[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:ae(E[12],.7),textColor:E[1],titleColor:E[1],arrowColor:ae(E[12],.7),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ce[3]}`},notification:{background:ae(E[12],.95),textColor:E[1],textSecondaryColor:E[6],border:`1px solid ${ae(E[0],.12)}`,borderRadius:"12px",successColor:Ae[4],warningColor:dt[4],errorColor:Ce[4],iconBackground:ae(ce[3],.1),progressGradient:`linear-gradient(90deg, ${ce[3]}, ${ce[2]})`},content:{background:ae(E[12],.8),backgroundHover:ae(E[11],.6),border:`1px solid ${E[11]}`,borderRadius:"8px",textColor:E[1],textSecondaryColor:E[6],itemDivider:"none",itemGap:"6px",itemPadding:"12px 16px",itemFontSize:"15px",bodyPadding:"0 16px 12px 16px",bodyFontSize:"14px",categoryPadding:"8px 4px 4px 4px",categoryGap:"4px",categoryFontSize:"12px",searchBackground:E[12],searchColor:E[1],chevronColor:"currentColor",bubbleBackground:ae(E[11],.6),bubbleBorder:`1px solid ${ae(E[6],.2)}`,bubbleBackgroundUser:ae(ce[3],.1),bubbleBorderUser:`1px solid ${ae(ce[3],.32)}`,bubbleBackgroundIdle:ae(E[10],.5),bubbleBorderIdle:`1px solid ${ae(E[6],.2)}`,bubbleBackgroundError:ae(Ce[8],.5),bubbleBorderError:`1px solid ${ae(Ce[4],.5)}`,bubbleTextError:Ce[2],codeBackground:ae(E[11],.7),codeBackgroundBlock:ae(E[11],.85),dividerColor:ae(E[6],.14),linkColor:ce[3]},mobile:{canvas:{backdrop:!0}}};function Py(n){let e=n.mode==="light"?$y:Iy;return{mode:n.mode??e.mode,fontFamily:n.fontFamily??e.fontFamily,colorPrimary:n.colorPrimary??e.colorPrimary,colorPrimaryHover:n.colorPrimaryHover??e.colorPrimaryHover,accentColor:n.accentColor??e.accentColor,accentForeground:n.accentForeground??e.accentForeground,borderRadius:n.borderRadius??e.borderRadius,canvas:{...e.canvas,...n.canvas},launcher:{...e.launcher,...n.launcher},tile:{...e.tile,...n.tile},overlay:{...e.overlay,...n.overlay},notification:{...e.notification,...n.notification},content:{...e.content,...n.content},mobile:{canvas:{...e.mobile.canvas,...n.mobile?.canvas}}}}function Oy(n,e){let t=e.mode??n.mode??"dark",r=t==="light"?$y:Iy;return{mode:t,fontFamily:e.fontFamily??n.fontFamily??r.fontFamily,colorPrimary:e.colorPrimary??n.colorPrimary??r.colorPrimary,colorPrimaryHover:e.colorPrimaryHover??n.colorPrimaryHover??r.colorPrimaryHover,accentColor:e.accentColor??n.accentColor??r.accentColor,accentForeground:e.accentForeground??n.accentForeground??r.accentForeground,borderRadius:e.borderRadius??n.borderRadius??r.borderRadius,canvas:{...r.canvas,...n.canvas,...e.canvas},launcher:{...r.launcher,...n.launcher,...e.launcher},tile:{...r.tile,...n.tile,...e.tile},overlay:{...r.overlay,...n.overlay,...e.overlay},notification:{...r.notification,...n.notification,...e.notification},content:{...r.content,...n.content,...e.content},mobile:{canvas:{...r.mobile.canvas,...n.mobile?.canvas,...e.mobile?.canvas}}}}var nk=["canvas","launcher","tile","overlay","notification","content"];function My(n){let e={};n.fontFamily&&(e["--sc-font-family"]=n.fontFamily),n.colorPrimary&&(e["--sc-color-primary"]=n.colorPrimary),n.colorPrimaryHover&&(e["--sc-color-primary-hover"]=n.colorPrimaryHover),n.accentColor&&(e["--sc-accent-color"]=n.accentColor),n.accentForeground&&(e["--sc-accent-foreground"]=n.accentForeground),n.borderRadius&&(e["--sc-border-radius"]=n.borderRadius);for(let t of nk){let r=n[t];if(r)for(let[i,s]of Object.entries(r))s!==void 0&&typeof s=="string"&&(e[`--sc-${t}-${tk(i)}`]=s)}return e}var Un,jr,Wr,yn,_n,Xp,pc,Gi=class{constructor(e,t,r){ne(this,_n);ne(this,Un);ne(this,jr);ne(this,Wr);ne(this,yn);L(this,Un,e),L(this,jr,t??{}),L(this,Wr,r),L(this,yn,ue(this,_n,Xp).call(this)),e.addController(this)}get config(){return C(this,yn).config}get mode(){return C(this,yn).mode}get cssVariables(){return C(this,yn).cssVariables}hostConnected(){ue(this,_n,pc).call(this)}hostDisconnected(){}hostUpdated(){ue(this,_n,pc).call(this)}setThemeConfig(e,t){L(this,jr,e),L(this,Wr,t),L(this,yn,ue(this,_n,Xp).call(this)),ue(this,_n,pc).call(this),C(this,Un).requestUpdate()}};Un=new WeakMap,jr=new WeakMap,Wr=new WeakMap,yn=new WeakMap,_n=new WeakSet,Xp=function(){let e=C(this,Wr)?Oy(C(this,Wr),C(this,jr)):Py(C(this,jr)),t=My(e);return{config:e,mode:e.mode,cssVariables:t}},pc=function(){let e=C(this,Un).shadowRoot??("renderRoot"in C(this,Un)?C(this,Un).renderRoot:null);if(!e||!(e instanceof ShadowRoot))return;let t=e.querySelector("#sc-theme-vars");t||(t=document.createElement("style"),t.id="sc-theme-vars",e.insertBefore(t,e.firstChild));let r=Object.entries(C(this,yn).cssVariables).map(([i,s])=>` ${i}: ${s};`).join(`
|
|
383
|
+
`}};nc.properties={isOpen:{type:Boolean},notificationCount:{type:Number},launcherIcon:{attribute:!1},label:{type:String},colorPrimaryHover:{type:String},hasActiveTiles:{type:Boolean},pendingCanvasShape:{type:Boolean},_launcherPos:{state:!0},_hovered:{state:!0},_shapeReady:{state:!0},_pulseResting:{state:!0}};customElements.define("syntro-launcher",nc);function rc(n,e,t="merge"){return t==="first-match"?VC(n,e):UC(n,e)}function VC(n,e){for(let t of e){let r=n.getFeatureValue?.(t,null);if(!r||typeof r!="object")continue;let i=r,s=i.tiles&&i.tiles.length>0,o=i.actions&&i.actions.length>0,a=i.slots&&Object.keys(i.slots).length>0;if(s||o||a)return oy([i])}return null}function UC(n,e){let t=[];for(let r of e){let i=n.getFeatureValue?.(r,null);if(!i||typeof i!="object")continue;let s=i,o=s.tiles&&s.tiles.length>0,a=s.actions&&s.actions.length>0,l=s.slots&&Object.keys(s.slots).length>0;(o||a||l)&&t.push(s)}return t.length===0?null:oy(t)}function oy(n){let e=[],t=[],r=new Set,i=[],s,o,a,l,c,u,p,f,h;for(let y of n){let w=y.tiles?.length??0;y.tiles&&e.push(...y.tiles);let x=0;if(y.actions)for(let k of y.actions){let I=k.label;if(I){if(r.has(I))continue;r.add(I)}t.push(k),x++}let _=y.meta?.variant_id;_&&(w>0||x>0)&&i.push({variant_id:_,tiles:w,actions:x}),s??(s=y.fetchedAt),o??(o=y.schemaVersion),a??(a=y.configVersion),l??(l=y.canvasTitle),c??(c=y.displayMode),u??(u=y.theme),p??(p=y.launcher),f??(f=y.meta),h??(h=y.slots)}let g=new Map,v=[];for(let y of e){let w=y?.id;if(typeof w=="string"&&w){let x=g.get(w);if(x!==void 0){v[x]=y;continue}g.set(w,v.length)}v.push(y)}let m=i.length>0?{...f??{},variants:i}:f;return{tiles:v,actions:t,fetchedAt:s??new Date().toISOString(),...o&&{schemaVersion:o},...a&&{configVersion:a},...l&&{canvasTitle:l},...c&&{displayMode:c},...u&&{theme:u},...p&&{launcher:p},...m&&{meta:m},...h&&{slots:h}}}var Ip=!1;function ay(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("syntro_debug")==="true"}catch{return!1}}function $p(n){if(ay()){Ip=!0;return}Ip=n??!1}function jC(){return ay()?!0:Ip}function q(n,e,t){jC()&&(t!==void 0?console.log(`[${n}]`,e,t):console.log(`[${n}]`,e))}function We(n,e,t){t!==void 0?console.warn(`[${n}]`,e,t):console.warn(`[${n}]`,e)}function ic(n,e,t){t!==void 0?console.error(`[${n}]`,e,t):console.error(`[${n}]`,e)}var sc=class{constructor(e){this.config=e;this.counters=new Map;this.histograms=new Map;this.windowStartMs=Date.now();this.timer=null;this.pagehideHandler=null;this.runtime=null;this.adapterCleanup=null;this.resource=e.resource,this.flushIntervalMs=e.flushIntervalMs??6e4}bindRuntime(e){this.runtime=e}attachAdapterCleanup(e){this.adapterCleanup=e}increment(e,t=1){this.counters.set(e,(this.counters.get(e)??0)+t)}snapshotCounters(){let e={};for(let[t,r]of this.counters)e[t]=r;return e}recordHistogram(e,t){let r=this.histograms.get(e)??[];r.push(t),this.histograms.set(e,r)}snapshotHistograms(){let e={};for(let[t,r]of this.histograms){if(r.length===0)continue;let i=[...r].sort((s,o)=>s-o);e[t]={count:i.length,p50:ly(i,.5),p95:ly(i,.95)}}return e}async flush(){let e=this.snapshotCounters(),t=this.snapshotHistograms();if(!(Object.keys(e).length>0||Object.keys(t).length>0))return;let i=null,s="";try{i=this.runtime?.getSurface()??null}catch{}try{s=this.runtime?.getSessionId()??""}catch{}let o={resource:{...this.resource,sessionId:s,surfaceType:i?.type??"unknown",surfaceHost:i?.host??"unknown",surfaceDevice:i?.device??"unknown",surfaceMode:i?.mode??"unknown"},windowSeconds:Math.max(1,Math.round((Date.now()-this.windowStartMs)/1e3)),windowStartUnixMs:this.windowStartMs,counters:e,histograms:t};this.counters.clear(),this.histograms.clear(),this.windowStartMs=Date.now();try{await this.config.emit(o)}catch{}}start(){this.timer===null&&(this.timer=setInterval(()=>{this.flush()},this.flushIntervalMs),typeof window<"u"&&(this.pagehideHandler=()=>{this.flush()},window.addEventListener("pagehide",this.pagehideHandler)))}stop(){if(this.timer!==null&&(clearInterval(this.timer),this.timer=null),this.pagehideHandler!==null&&typeof window<"u"&&(window.removeEventListener("pagehide",this.pagehideHandler),this.pagehideHandler=null),this.adapterCleanup!==null){try{this.adapterCleanup()}catch{}this.adapterCleanup=null}}};function ly(n,e){if(n.length===0)return 0;let t=(n.length-1)*e,r=Math.floor(t),i=Math.ceil(t);return r===i?n[r]:n[r]+(n[i]-n[r])*(t-r)}var Eo=null;function Pp(n){return Eo?.stop(),Eo=new sc(n),Eo.start(),Eo}function jt(){return Eo}var mn=(n,e)=>({key:n,value:{stringValue:e}}),Op=(n,e)=>({key:n,value:{intValue:Math.round(e)}}),cy=(n,e)=>({key:n,value:{doubleValue:e}});function WC(n){let{resource:e,counters:t,histograms:r,windowSeconds:i,windowStartUnixMs:s}=n,o=[mn("service.name",e.serviceName),mn("service.version",e.serviceVersion),mn("syntro.posthog_key",e.posthogKey),mn("syntro.session_id",e.sessionId),mn("syntro.surface_type",e.surfaceType),mn("syntro.surface_host",e.surfaceHost),mn("syntro.surface_device",e.surfaceDevice),mn("syntro.surface_mode",e.surfaceMode),mn("syntro.host_origin",e.hostOrigin)],a=[Op("window_seconds",i)];for(let[u,p]of Object.entries(t))p!==void 0&&a.push(Op(u,p));for(let[u,p]of Object.entries(r))p!==void 0&&(a.push(Op(`${u}_count`,p.count)),a.push(cy(`${u}_p50`,p.p50)),a.push(cy(`${u}_p95`,p.p95)));let l=`${Date.now()}000000`,c=`${s}000000`;return{resourceLogs:[{resource:{attributes:o},scopeLogs:[{scope:{name:"syntro.sdk.health"},logRecords:[{timeUnixNano:c,observedTimeUnixNano:l,severityText:"INFO",body:{stringValue:"sdk_health_window"},attributes:a}]}]}]}}function Mp(n){let e=n.fetchImpl??fetch;return async t=>{let r=JSON.stringify(WC(t)),i=()=>e(n.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:r,keepalive:!0,mode:"cors"});try{let s=await i();if(!s.ok&&s.status>=500)try{await i()}catch{}}catch{try{await i()}catch{}}}}function zC(){if(typeof document>"u")return;let n=document.currentScript;if(n?.src)return n.src;try{let e=Array.from(document.scripts);for(let t=e.length-1;t>=0;t-=1){let r=e[t]?.src;if(typeof r=="string"&&(r.includes("runtime-sdk")||r.includes("smart-canvas")))return r}}catch{}}var Lp=zC();function Np(){if(!Lp)return;let n=Lp.lastIndexOf("/");if(n!==-1)return Lp.substring(0,n+1)}var yy=-1,qi=n=>{addEventListener("pageshow",(e=>{e.persisted&&(yy=e.timeStamp,n(e))}),!0)},Wt=(n,e,t,r)=>{let i,s;return o=>{e.value>=0&&(o||r)&&(s=e.value-(i??0),(s||i===void 0)&&(i=e.value,e.delta=s,e.rating=((a,l)=>a>l[1]?"poor":a>l[0]?"needs-improvement":"good")(e.value,t),n(e)))}},zp=n=>{requestAnimationFrame((()=>requestAnimationFrame((()=>n()))))},qp=()=>{let n=performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},Co=()=>qp()?.activationStart??0,zt=(n,e=-1)=>{let t=qp(),r="navigate";return yy>=0?r="back-forward-cache":t&&(document.prerendering||Co()>0?r="prerender":document.wasDiscarded?r="restore":t.type&&(r=t.type.replace(/_/g,"-"))),{name:n,value:e,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},Fp=new WeakMap;function Zp(n,e){return Fp.get(n)||Fp.set(n,new e),Fp.get(n)}var Hp=class{constructor(){en(this,"t");en(this,"i",0);en(this,"o",[])}h(e){if(e.hadRecentInput)return;let t=this.o[0],r=this.o.at(-1);this.i&&t&&r&&e.startTime-r.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}},ko=(n,e,t={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(n)){let r=new PerformanceObserver((i=>{Promise.resolve().then((()=>{e(i.getEntries())}))}));return r.observe({type:n,buffered:!0,...t}),r}}catch{}},Gp=n=>{let e=!1;return()=>{e||(n(),e=!0)}},zi=-1,_y=new Set,uy=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,Bp=n=>{if(document.visibilityState==="hidden"){if(n.type==="visibilitychange")for(let e of _y)e();isFinite(zi)||(zi=n.type==="visibilitychange"?n.timeStamp:0,removeEventListener("prerenderingchange",Bp,!0))}},ac=()=>{if(zi<0){let n=Co();zi=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((t=>t.name==="hidden"&&t.startTime>n))[0]?.startTime)??uy(),addEventListener("visibilitychange",Bp,!0),addEventListener("prerenderingchange",Bp,!0),qi((()=>{setTimeout((()=>{zi=uy()}))}))}return{get firstHiddenTime(){return zi},onHidden(n){_y.add(n)}}},lc=n=>{document.prerendering?addEventListener("prerenderingchange",(()=>n()),!0):n()},dy=[1800,3e3],Kp=(n,e={})=>{lc((()=>{let t=ac(),r,i=zt("FCP"),s=ko("paint",(o=>{for(let a of o)a.name==="first-contentful-paint"&&(s.disconnect(),a.startTime<t.firstHiddenTime&&(i.value=Math.max(a.startTime-Co(),0),i.entries.push(a),r(!0)))}));s&&(r=Wt(n,i,dy,e.reportAllChanges),qi((o=>{i=zt("FCP"),r=Wt(n,i,dy,e.reportAllChanges),zp((()=>{i.value=performance.now()-o.timeStamp,r(!0)}))})))}))},py=[.1,.25],by=(n,e={})=>{let t=ac();Kp(Gp((()=>{let r,i=zt("CLS",0),s=Zp(e,Hp),o=l=>{for(let c of l)s.h(c);s.i>i.value&&(i.value=s.i,i.entries=s.o,r())},a=ko("layout-shift",o);a&&(r=Wt(n,i,py,e.reportAllChanges),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),qi((()=>{s.i=0,i=zt("CLS",0),r=Wt(n,i,py,e.reportAllChanges),zp((()=>r()))})),setTimeout(r))})))},wy=0,Dp=1/0,oc=0,qC=n=>{for(let e of n)e.interactionId&&(Dp=Math.min(Dp,e.interactionId),oc=Math.max(oc,e.interactionId),wy=oc?(oc-Dp)/7+1:0)},Vp,fy=()=>Vp?wy:performance.interactionCount??0,ZC=()=>{"interactionCount"in performance||Vp||(Vp=ko("event",qC,{type:"event",buffered:!0,durationThreshold:0}))},hy=0,Up=class{constructor(){en(this,"u",[]);en(this,"l",new Map);en(this,"m");en(this,"p")}v(){hy=fy(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((fy()-hy)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&e.entryType!=="first-input")return;let t=this.u.at(-1),r=this.l.get(e.interactionId);if(r||this.u.length<10||e.duration>t.P){if(r?e.duration>r.P?(r.entries=[e],r.P=e.duration):e.duration===r.P&&e.startTime===r.entries[0].startTime&&r.entries.push(e):(r={id:e.interactionId,entries:[e],P:e.duration},this.l.set(r.id,r),this.u.push(r)),this.u.sort(((i,s)=>s.P-i.P)),this.u.length>10){let i=this.u.splice(10);for(let s of i)this.l.delete(s.id)}this.p?.(r)}}},xy=n=>{let e=globalThis.requestIdleCallback||setTimeout;document.visibilityState==="hidden"?n():(n=Gp(n),addEventListener("visibilitychange",n,{once:!0,capture:!0}),e((()=>{n(),removeEventListener("visibilitychange",n,{capture:!0})})))},gy=[200,500],Sy=(n,e={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let t=ac();lc((()=>{ZC();let r,i=zt("INP"),s=Zp(e,Up),o=l=>{xy((()=>{for(let u of l)s.h(u);let c=s.L();c&&c.P!==i.value&&(i.value=c.P,i.entries=c.entries,r())}))},a=ko("event",o,{durationThreshold:e.durationThreshold??40});r=Wt(n,i,gy,e.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),qi((()=>{s.v(),i=zt("INP"),r=Wt(n,i,gy,e.reportAllChanges)})))}))},jp=class{constructor(){en(this,"m")}h(e){this.m?.(e)}},my=[2500,4e3],Ey=(n,e={})=>{lc((()=>{let t=ac(),r,i=zt("LCP"),s=Zp(e,jp),o=l=>{e.reportAllChanges||(l=l.slice(-1));for(let c of l)s.h(c),c.startTime<t.firstHiddenTime&&(i.value=Math.max(c.startTime-Co(),0),i.entries=[c],r())},a=ko("largest-contentful-paint",o);if(a){r=Wt(n,i,my,e.reportAllChanges);let l=Gp((()=>{o(a.takeRecords()),a.disconnect(),r(!0)})),c=u=>{u.isTrusted&&(xy(l),removeEventListener(u.type,c,{capture:!0}))};for(let u of["keydown","click","visibilitychange"])addEventListener(u,c,{capture:!0});qi((u=>{i=zt("LCP"),r=Wt(n,i,my,e.reportAllChanges),zp((()=>{i.value=performance.now()-u.timeStamp,r(!0)}))}))}}))},vy=[800,1800],Wp=n=>{document.prerendering?lc((()=>Wp(n))):document.readyState!=="complete"?addEventListener("load",(()=>Wp(n)),!0):setTimeout(n)},Cy=(n,e={})=>{let t=zt("TTFB"),r=Wt(n,t,vy,e.reportAllChanges);Wp((()=>{let i=qp();i&&(t.value=Math.max(i.responseStart-Co(),0),t.entries=[i],r(!0),qi((()=>{t=zt("TTFB",0),r=Wt(n,t,vy,e.reportAllChanges),r(!0)})))}))};var ky="__syntro_vitals_bound",cc="__syntro_vitals_current_reporter";function Yp(n,e){if(typeof window>"u")return()=>{};let t=window;t[cc]=n;let r=null,i=e?.attributedScriptUrlPrefix;if(i&&"PerformanceObserver"in window)try{r=new PerformanceObserver(s=>{let o=t[cc];if(o)for(let a of s.getEntries()){let l=a.attribution;if(!l)continue;l.some(u=>(u.containerSrc??u.name??"").startsWith(i))&&(o.increment("longtasks_self_count"),o.increment("longtasks_self_blocking_ms",Math.round(a.duration)))}}),r.observe({type:"longtask",buffered:!0})}catch{r=null}if(!t[ky]){t[ky]=!0;let s=o=>a=>{t[cc]?.recordHistogram(o,a.value)};Ey(s("lcp_ms")),Sy(s("inp_ms")),Kp(s("fcp_ms")),Cy(s("ttfb_ms")),by(o=>{t[cc]?.recordHistogram("cls_score",o.value)})}return()=>{r?.disconnect()}}var Zi="2.8.0-canary.478";var vn="2.0";var GC=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function KC(n){try{let e=new URL(n),t=/^(localhost|127\.0\.0\.1)$/.test(e.hostname);return e.protocol!=="https:"&&!t?(console.warn("[SmartCanvas] Config URI must use HTTPS:",n),!1):GC.some(i=>e.hostname===i)?!0:(console.warn("[SmartCanvas] Config URI host not in allowlist:",e.hostname),!1)}catch{return console.warn("[SmartCanvas] Invalid config URI:",n),!1}}function YC(n){if(typeof window>"u")return!1;try{return new URL(n).origin===window.location.origin}catch{return!1}}var Ay="syntro_config_cache",JC=1440*60*1e3;function Ty(){try{return typeof localStorage<"u"&&localStorage!==null}catch{return!1}}function XC(n,e){if(Ty())try{let t={config:n,timestamp:Date.now(),sdkVersion:e};localStorage.setItem(Ay,JSON.stringify(t))}catch{}}function QC(n){if(!Ty())return null;try{let e=localStorage.getItem(Ay);if(!e)return null;let t=JSON.parse(e);return!t.config||typeof t.timestamp!="number"||!t.sdkVersion||t.sdkVersion!==n||Date.now()-t.timestamp>JC?null:t.config}catch{return null}}var Ry=({configUri:n,experiments:e,featureKey:t})=>{if(n)return n;if(e&&t){let r=e.getFeatureValue?.(t,null);if(r)return r}};function ek(n,e,t){if(e){let r=n.getFeatureValue?.(e,null);if(r&&typeof r=="object"){let i=r.variant_flags;if(i&&i.length>0)return i}}if(n.getAllFeatures){let r=n.getAllFeatures();return t?Object.keys(r).filter(i=>i.startsWith(t)):Object.keys(r)}return[]}var Ur=({configUri:n,experiments:e,featureKey:t,credentials:r,manifestKey:i,variantFlagPrefix:s,sdkVersion:o})=>async()=>{if(e&&(i||s||e.getAllFeatures)){let p=ek(e,i,s);if(console.log("[SmartCanvas Config] Variant key discovery:",p.length,"keys found"),p.length>0){let f=rc(e,p);if(console.log("[SmartCanvas Config] resolveVariantConfigs result:",f?`tiles=${f.tiles?.length}`:"null"),f)return q("SmartCanvas Config","Resolved config from variant flags",f),f}}else console.log("[SmartCanvas Config] Skipping multi-flag mode:",{hasExperiments:!!e,manifestKey:i,variantFlagPrefix:s,hasGetAllFeatures:!!e?.getAllFeatures});let a=Ry({configUri:n,experiments:e,featureKey:t});if(!a)return q("SmartCanvas Config","No config available \u2014 returning empty config"),{tiles:[],actions:[],fetchedAt:new Date().toISOString()};if(!KC(a))throw new Error(`SmartCanvas: config URI not allowed: ${a}`);let l=r??(YC(a)?"include":"omit"),c=performance.now(),u=!1;try{let p=await fetch(a,{credentials:l,headers:{"X-SDK-Version":Zi,"X-SDK-Schema-Version":vn}});if(!p.ok)throw jt()?.increment("flag_fetch_errors"),u=!0,new Error(`SmartCanvas: failed to fetch config (${p.status})`);let f=await p.json(),h=performance.now()-c;return jt()?.increment("flag_fetch_count"),jt()?.recordHistogram("flag_fetch_latency_ms",h),q("SmartCanvas Config","Fetched config from URI",f),o&&XC(f,o),f}catch(p){if(u||jt()?.increment("flag_fetch_errors"),o){let f=QC(o);if(f)return q("SmartCanvas Config","Serving config from offline cache"),f}throw p}};var uc=class{constructor(e){this.listeners=new Set;let t=e?.open??!1;if(e?.open===void 0)try{let r=sessionStorage?.getItem("syntro:editor:panel-open");r!==null&&(t=JSON.parse(r))}catch{}this.state={open:t}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOpen(e){if(this.state.open!==e){this.state={...this.state,open:e};try{sessionStorage?.setItem("syntro:editor:panel-open",JSON.stringify(e))}catch{}this.emit()}}toggle(){this.setOpen(!this.state.open)}emit(){for(let e of this.listeners)e(this.state)}},Jp=n=>new uc(n);var Pt={white:"#ffffff",black:"#000000"},ce={0:"#2c0b0a",1:"#5b1715",2:"#89221f",3:"#b72e2a",4:"#d44844",5:"#dd6d69",6:"#e5918f",7:"#eeb6b4",8:"#f6dada",9:"#faebea"},E={0:"#07080a",1:"#0f1318",2:"#0e1114",3:"#1c222a",4:"#2b333f",5:"#394454",6:"#475569",7:"#677384",8:"#87919f",9:"#a8afba",10:"#cbd0d7",11:"#e8eaee",12:"#f6f7f9"},Ae={0:"#07230a",1:"#0e4514",2:"#16681e",3:"#1d8a28",4:"#24ad32",5:"#4fbd5a",6:"#7acd82",7:"#a5deab",8:"#d0eed3",9:"#e5f6e7"},dt={0:"#301f09",1:"#5f3e12",2:"#8f5e1b",3:"#be7d24",4:"#ee9c2d",5:"#f1b057",6:"#f5c481",7:"#f8d7ab",8:"#fcebd5",9:"#fdf5ea"},Ce={0:"#330707",1:"#660f0e",2:"#991616",3:"#cc1e1d",4:"#ff2524",5:"#ff5150",6:"#ff7c7c",7:"#ffa8a7",8:"#ffd3d3",9:"#ffe9e9"},Ao={0:"#051533",1:"#0a2a66",2:"#0f3f98",3:"#1454cb",4:"#1969fe",5:"#4787fe",6:"#75a5fe",7:"#a3c3ff",8:"#d1e1ff",9:"#e8f0ff"},To={0:"#662500",1:"#993d00",2:"#cc5800",3:"#ff7700",4:"#fea85d",5:"#fec58f",6:"#ffd6ae",7:"#fee6cd",8:"#fff1e1",9:"#fff8f0"},Ro={0:"#151229",1:"#2a2452",2:"#40357c",3:"#5547a5",4:"#6a59ce",5:"#887ad8",6:"#a69be2",7:"#c3bdeb",8:"#e1def5",9:"#f0eefa"},Io={0:"#37091f",1:"#69123c",2:"#9b1c58",3:"#cd2575",4:"#ff2e92",5:"#ff58a8",6:"#ff82be",7:"#ffabd3",8:"#ffd5e9",9:"#ffeaf4"};var qt={primary:E[10],secondary:E[9],tertiary:E[8]},iL={primary:E[2],secondary:E[0]},sL={primary:E[4],secondary:E[3]},dc={primary:{text:Pt.white,icon:Pt.white,border:ce[3],backgroundDefault:ce[3],backgroundHover:ce[2]},neutral:{text:E[10],textHover:Pt.white,icon:E[10],iconHover:Pt.white,border:E[4],background:E[2]},link:{text:Pt.white,icon:Pt.white,hover:ce[5]},error:{text:Ce[5],hover:Ce[6]},success:{text:Ae[5],hover:Ae[6]}},oL={slateGrey:{content:E[10],pillOutline:E[10],borderPrimary:E[5],borderSecondary:E[5],background:E[3]},brand:{content:ce[9],pillOutline:ce[9],borderPrimary:ce[6],borderSecondary:ce[6],background:ce[0]},red:{content:Ce[8],pillOutline:Ce[4],borderPrimary:Ce[2],borderSecondary:Ce[2],background:Ce[0]},yellow:{content:dt[8],pillOutline:dt[4],borderPrimary:dt[2],borderSecondary:dt[2],background:dt[0]},green:{content:Ae[8],pillOutline:Ae[4],borderPrimary:Ae[2],borderSecondary:Ae[2],background:Ae[0]},purple:{content:Ro[8],pillOutline:Ro[4],borderPrimary:Ro[2],borderSecondary:Ro[2],background:Ro[0]},blue:{content:Ao[8],pillOutline:Ao[4],borderPrimary:Ao[2],borderSecondary:Ao[2],background:Ao[0]},orange:{content:To[8],pillOutline:To[4],borderPrimary:To[2],borderSecondary:To[2],background:To[0]},pink:{content:Io[8],pillOutline:Io[4],borderPrimary:Io[2],borderSecondary:Io[2],background:Io[0]}},aL={green:{content:Ae[8],border:Ae[2],background:Ae[0]},yellow:{content:dt[8],border:dt[2],background:dt[0]},red:{content:Ce[8],border:Ce[2],background:Ce[0]}},lL={green:{content:Ae[1],background:Ae[9]},yellow:{content:dt[1],background:dt[9]},red:{content:Ce[1],background:Ce[9]}},cL={content:E[10],border:E[4],background:E[3]},uL={backgroundDefault:E[2],backgroundHover:E[1],selected:E[3]},dL={background:E[2],icon:E[10],borderDefault:E[4],borderSelected:ce[3],textLabel:E[9],textPlaceholder:E[8],textHint:E[8]},pL={backgroundDefault:E[2],backgroundDisabled:E[0],textLabel:E[9],textPlaceholder:E[8],textHint:E[8],textError:Ce[5],iconDefault:E[9],iconPlaceholder:E[10],iconError:Ce[5],borderDefault:E[4],borderSelected:ce[3],borderError:Ce[5]},fL={handleDefault:Pt.white,handleDisabled:E[10],off:{backgroundDefault:E[4],backgroundHover:E[5],backgroundDisabled:E[4]},on:{backgroundDefault:Ae[3],backgroundHover:Ae[2],backgroundDisabled:E[4]}},hL={off:{backgroundDefault:"#00000000",backgroundHover:E[5],backgroundDisabled:E[2],border:E[6]},on:{backgroundDefault:Ae[0],backgroundHover:Ae[1],backgroundDisabled:E[2],border:Ae[3]}},gL={content:E[10],background:E[4]},mL={background:E[4],active:Ae[3]},vL={background:E[1],content:E[9],border:E[4]},yL={backgroundDefault:E[1],backgroundHover:E[3],backgroundActive:E[4],border:E[4],contentPrimary:E[10],contentSecondary:E[9],contentTertiary:E[8]},_L={background:E[1],content:E[9],border:E[4]},bL={activeBackground:E[3],activeContent:ce[5],inactiveContent:E[9],border:E[4]},wL={header:{textDefault:E[9],textHover:E[8],backgroundDefault:E[1]},border:E[4],cell:{textPrimary:E[10],textSecondary:E[9],backgroundDefault:E[2],backgroundHover:E[1]}},xL={textPrimaryDefault:E[10],textPrimaryHover:E[10],textSecondaryDefault:E[8],textSecondaryHover:E[9],iconPrimary:E[10],iconSecondary:E[8]},SL={background:Ae[1],active:Ae[5]},EL={textDefault:E[10],textSelected:Pt.white,textDisabled:E[7],backgroundDefault:E[2],backgroundMiddle:E[3],backgroundSelected:ce[3],border:E[4]},CL=E[9];var RL={size:56,inset:12,background:Pt.black,color:Pt.white,border:`2px solid ${ce[3]}`,shadowOpen:"0 4px 24px rgba(0,0,0,0.6), 0 0 0 2px rgba(255,255,255,0.08)",shadowClosed:"0 4px 24px rgba(0,0,0,0.6)"};function ae(n,e){return`${n}${Math.round(e*255).toString(16).padStart(2,"0")}`}function tk(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}var Iy={mode:"dark",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ce[3],colorPrimaryHover:ce[4],accentColor:"2 64% 44%",accentForeground:"#ffffff",borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:ae(E[1],.6),blur:"blur(24px)",border:"none",width:"clamp(380px, 25vw, 520px)",transitionDuration:"300ms",transitionEasing:"cubic-bezier(0.16, 1, 0.3, 1)",transitionFade:"6%",backdrop:!1,backdropColor:"rgba(0, 0, 0, 0.4)",padding:"0"},launcher:{background:dc.primary.backgroundDefault,backgroundHover:dc.primary.backgroundHover,color:dc.primary.icon,size:"56px",shadow:`0 8px 32px ${ae(E[0],.6)}`,borderRadius:"9999px"},tile:{background:ae(E[1],.6),backgroundHover:ae(E[1],.7),border:"1px solid rgba(255, 255, 255, 0.08)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.3)",titleColor:qt.primary,textColor:qt.secondary,iconBackground:`linear-gradient(135deg, ${ce[3]} 0%, ${ce[3]}cc 100%)`,iconShadow:`0 2px 8px ${ce[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:ae(E[1],.6),textColor:qt.primary,titleColor:qt.primary,arrowColor:ae(E[1],.6),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ce[3]}`},notification:{background:ae(E[0],.95),textColor:qt.primary,textSecondaryColor:qt.secondary,border:`1px solid ${E[5]}`,borderRadius:"12px",successColor:Ae[4],warningColor:dt[4],errorColor:Ce[4],iconBackground:ae(ce[3],.15),progressGradient:`linear-gradient(90deg, ${ce[3]}, ${ce[4]})`},content:{background:ae(E[3],.8),backgroundHover:ae(E[5],.6),border:`1px solid ${ae(E[5],.5)}`,borderRadius:"8px",textColor:qt.primary,textSecondaryColor:qt.secondary,itemDivider:"none",itemGap:"6px",itemPadding:"12px 16px",itemFontSize:"15px",bodyPadding:"0 16px 12px 16px",bodyFontSize:"14px",categoryPadding:"8px 4px 4px 4px",categoryGap:"4px",categoryFontSize:"12px",searchBackground:ae(E[3],.8),searchColor:qt.primary,chevronColor:"currentColor",bubbleBackground:ae(E[0],.35),bubbleBorder:`1px solid ${ae(E[12],.18)}`,bubbleBackgroundUser:ae(ce[3],.14),bubbleBorderUser:`1px solid ${ae(ce[3],.28)}`,bubbleBackgroundIdle:ae(E[3],.4),bubbleBorderIdle:`1px solid ${ae(E[12],.18)}`,bubbleBackgroundError:ae(Ce[1],.42),bubbleBorderError:`1px solid ${ae(Ce[4],.55)}`,bubbleTextError:Ce[8],codeBackground:ae(E[0],.25),codeBackgroundBlock:ae(E[0],.35),dividerColor:ae(E[12],.12),linkColor:ce[4]},mobile:{canvas:{backdrop:!0}}},$y={mode:"light",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif",colorPrimary:ce[3],colorPrimaryHover:ce[2],accentColor:"2 64% 44%",accentForeground:"#ffffff",borderRadius:"12px",canvas:{position:"right",layout:"overlay",background:ae(E[12],.7),blur:"blur(24px)",border:"none",width:"clamp(380px, 25vw, 520px)",transitionDuration:"300ms",transitionEasing:"cubic-bezier(0.16, 1, 0.3, 1)",transitionFade:"6%",backdrop:!1,backdropColor:"rgba(0, 0, 0, 0.3)",padding:"0"},launcher:{background:ce[3],backgroundHover:ce[2],color:"#ffffff",size:"56px",shadow:"0 8px 32px rgba(0, 0, 0, 0.15)",borderRadius:"9999px"},tile:{background:ae(E[12],.7),backgroundHover:ae(E[12],.8),border:"1px solid rgba(0, 0, 0, 0.06)",borderRadius:"14px",shadow:"0 2px 12px rgba(0, 0, 0, 0.12)",titleColor:E[1],textColor:E[6],iconBackground:`linear-gradient(135deg, ${ce[3]} 0%, ${ce[3]}cc 100%)`,iconShadow:`0 2px 8px ${ce[3]}40`,headerPadding:"0.375rem 0.75rem",bodyPadding:"0 0.75rem 0.5rem",gap:"0.25rem"},overlay:{background:ae(E[12],.7),textColor:E[1],titleColor:E[1],arrowColor:ae(E[12],.7),arrowSize:"8px",border:"none",borderRadius:"0",scrimOpacity:"0",highlightRing:`2px solid ${ce[3]}`},notification:{background:ae(E[12],.95),textColor:E[1],textSecondaryColor:E[6],border:`1px solid ${ae(E[0],.12)}`,borderRadius:"12px",successColor:Ae[4],warningColor:dt[4],errorColor:Ce[4],iconBackground:ae(ce[3],.1),progressGradient:`linear-gradient(90deg, ${ce[3]}, ${ce[2]})`},content:{background:ae(E[12],.8),backgroundHover:ae(E[11],.6),border:`1px solid ${E[11]}`,borderRadius:"8px",textColor:E[1],textSecondaryColor:E[6],itemDivider:"none",itemGap:"6px",itemPadding:"12px 16px",itemFontSize:"15px",bodyPadding:"0 16px 12px 16px",bodyFontSize:"14px",categoryPadding:"8px 4px 4px 4px",categoryGap:"4px",categoryFontSize:"12px",searchBackground:E[12],searchColor:E[1],chevronColor:"currentColor",bubbleBackground:ae(E[11],.6),bubbleBorder:`1px solid ${ae(E[6],.2)}`,bubbleBackgroundUser:ae(ce[3],.1),bubbleBorderUser:`1px solid ${ae(ce[3],.32)}`,bubbleBackgroundIdle:ae(E[10],.5),bubbleBorderIdle:`1px solid ${ae(E[6],.2)}`,bubbleBackgroundError:ae(Ce[8],.5),bubbleBorderError:`1px solid ${ae(Ce[4],.5)}`,bubbleTextError:Ce[2],codeBackground:ae(E[11],.7),codeBackgroundBlock:ae(E[11],.85),dividerColor:ae(E[6],.14),linkColor:ce[3]},mobile:{canvas:{backdrop:!0}}};function Py(n){let e=n.mode==="light"?$y:Iy;return{mode:n.mode??e.mode,fontFamily:n.fontFamily??e.fontFamily,colorPrimary:n.colorPrimary??e.colorPrimary,colorPrimaryHover:n.colorPrimaryHover??e.colorPrimaryHover,accentColor:n.accentColor??e.accentColor,accentForeground:n.accentForeground??e.accentForeground,borderRadius:n.borderRadius??e.borderRadius,canvas:{...e.canvas,...n.canvas},launcher:{...e.launcher,...n.launcher},tile:{...e.tile,...n.tile},overlay:{...e.overlay,...n.overlay},notification:{...e.notification,...n.notification},content:{...e.content,...n.content},mobile:{canvas:{...e.mobile.canvas,...n.mobile?.canvas}}}}function Oy(n,e){let t=e.mode??n.mode??"dark",r=t==="light"?$y:Iy;return{mode:t,fontFamily:e.fontFamily??n.fontFamily??r.fontFamily,colorPrimary:e.colorPrimary??n.colorPrimary??r.colorPrimary,colorPrimaryHover:e.colorPrimaryHover??n.colorPrimaryHover??r.colorPrimaryHover,accentColor:e.accentColor??n.accentColor??r.accentColor,accentForeground:e.accentForeground??n.accentForeground??r.accentForeground,borderRadius:e.borderRadius??n.borderRadius??r.borderRadius,canvas:{...r.canvas,...n.canvas,...e.canvas},launcher:{...r.launcher,...n.launcher,...e.launcher},tile:{...r.tile,...n.tile,...e.tile},overlay:{...r.overlay,...n.overlay,...e.overlay},notification:{...r.notification,...n.notification,...e.notification},content:{...r.content,...n.content,...e.content},mobile:{canvas:{...r.mobile.canvas,...n.mobile?.canvas,...e.mobile?.canvas}}}}var nk=["canvas","launcher","tile","overlay","notification","content"];function My(n){let e={};n.fontFamily&&(e["--sc-font-family"]=n.fontFamily),n.colorPrimary&&(e["--sc-color-primary"]=n.colorPrimary),n.colorPrimaryHover&&(e["--sc-color-primary-hover"]=n.colorPrimaryHover),n.accentColor&&(e["--sc-accent-color"]=n.accentColor),n.accentForeground&&(e["--sc-accent-foreground"]=n.accentForeground),n.borderRadius&&(e["--sc-border-radius"]=n.borderRadius);for(let t of nk){let r=n[t];if(r)for(let[i,s]of Object.entries(r))s!==void 0&&typeof s=="string"&&(e[`--sc-${t}-${tk(i)}`]=s)}return e}var Un,jr,Wr,yn,_n,Xp,pc,Gi=class{constructor(e,t,r){ne(this,_n);ne(this,Un);ne(this,jr);ne(this,Wr);ne(this,yn);L(this,Un,e),L(this,jr,t??{}),L(this,Wr,r),L(this,yn,ue(this,_n,Xp).call(this)),e.addController(this)}get config(){return C(this,yn).config}get mode(){return C(this,yn).mode}get cssVariables(){return C(this,yn).cssVariables}hostConnected(){ue(this,_n,pc).call(this)}hostDisconnected(){}hostUpdated(){ue(this,_n,pc).call(this)}setThemeConfig(e,t){L(this,jr,e),L(this,Wr,t),L(this,yn,ue(this,_n,Xp).call(this)),ue(this,_n,pc).call(this),C(this,Un).requestUpdate()}};Un=new WeakMap,jr=new WeakMap,Wr=new WeakMap,yn=new WeakMap,_n=new WeakSet,Xp=function(){let e=C(this,Wr)?Oy(C(this,Wr),C(this,jr)):Py(C(this,jr)),t=My(e);return{config:e,mode:e.mode,cssVariables:t}},pc=function(){let e=C(this,Un).shadowRoot??("renderRoot"in C(this,Un)?C(this,Un).renderRoot:null);if(!e||!(e instanceof ShadowRoot))return;let t=e.querySelector("#sc-theme-vars");t||(t=document.createElement("style"),t.id="sc-theme-vars",e.insertBefore(t,e.firstChild));let r=Object.entries(C(this,yn).cssVariables).map(([i,s])=>` ${i}: ${s};`).join(`
|
|
384
384
|
`);t.textContent=`:host {
|
|
385
385
|
${r}
|
|
386
386
|
}`};var rk=new Set(["tag_name","$el_text"]);function ik(n){return rk.has(n)||n.startsWith("attr__")}function Ly(n,e){return n.equals!==void 0?e===n.equals:n.contains!==void 0?typeof e=="string"&&e.includes(n.contains):!1}function sk(n){let{events:e,match:t}=n;return r=>{if(!e.includes(r.name))return!1;if(t){for(let[i,s]of Object.entries(t))if(ik(i)){let o=r.props?.elements;if(!o||!o.some(l=>Ly(s,l[i])))return!1}else if(!Ly(s,r.props?.[i]))return!1}return!0}}function Ny(n,e){for(let t of n.rules)for(let r of t.conditions)if(r.type==="event_count"&&r.key){let i=r.counter,s=i?sk(i):()=>!0,o=typeof r.withinMs=="number";e.register(r.key,s,o)}}function zr(n,e,t){for(let r of n){let i=r.props;if(!i)continue;let s=i.actions;if(s)for(let o of s)o.triggerWhen?.type==="rules"&&Ny(o.triggerWhen,e)}if(t)for(let r of t){let i=r;i.triggerWhen?.type==="rules"&&Ny(i.triggerWhen,e)}}var Vy=td,Fy="smart-canvas",Dy=n=>[...n].sort((e,t)=>(t.priority??0)-(e.priority??0));function Hy(n){let e=typeof window<"u"?window.SynOS?.interventionTracker:null;if(e)for(let t of n)e.trackTriggered(t.id,t.widget??"unknown")}function ok(n,e){if(Nn(n.kind)===e)return!0;if(n.kind!=="core:mountWidget")return!1;let r=n.widget?.widgetId;return typeof r=="string"&&Rt(r)===e}var By=1e4;function ak(n,e){let t=e.apps;if(!t.get&&!t.isActive)return[];let r=new Set;for(let i of n){let s=Nn(i.kind);if(!s&&i.kind==="core:mountWidget"){let l=i.widget?.widgetId;s=typeof l=="string"?Rt(l):null}if(!s)continue;let o=t.get?.(s)?.state;if(o==="error")continue;(t.isActive?.(s)??o==="active")||r.add(s)}return[...r]}var lk=new Set(["drawer","floating"]);function ck(n){if(!n||typeof n!="object")return null;let e=n.canvas;if(!e||typeof e!="object")return null;let t=e.element;return typeof t=="string"&&t.length>0?t:null}function uk(n,e){let t=n?.[e];if(!t||typeof t!="object")return;let r=t.theme;if(!r||typeof r!="object")return;let i=r.chromeless;return typeof i=="boolean"?i:void 0}function dk(n){if(!n)return[];let e=[];for(let[t,r]of Object.entries(n)){if(lk.has(t)||!r||typeof r!="object")continue;let i=r;if(i.kind!=="inline"){typeof process<"u";continue}let s=i.anchor;!s||typeof s.selector!="string"||typeof s.route!="string"&&!Array.isArray(s.route)||e.push({name:t,config:r})}return e}function pk(n){let e=n?.drawer;if(!e||typeof e!="object")return;let t=e.lid;if(!t||typeof t!="object")return;let r=t.widget;if(typeof r!="string"||r.length===0)return;let i=t.props,s=t.hideWhileVisible;return{widget:r,props:i&&typeof i=="object"?i:void 0,hideWhileVisible:typeof s=="string"&&s.length>0?s:void 0}}var jn,lt,Ki,Zt,bn,Ot,Zr,Yi,$o,Wn,Ji,Gr,Po,Oo,Mo,Lo,Kr,Yr,zn,qn,Zn,tt,Xi,Gn,Kn,Yn,Jn,Xn,Qi,Gt,Qn,gc,Jr,Xr,er,No,mc,es,oe,Qp,Uy,ef,jy,ts,fc,hc,tf,nf,rf,Wy,sf,zy,qy,of,Zy,af,Qr,vc,yc,qr=class extends be{constructor(){super();ne(this,oe);this.fetcher=void 0;this.configUri=void 0;this.configUriFeatureKey=void 0;this.fetchCredentials="include";this.experiments=void 0;this.telemetry=void 0;this.runtime=void 0;this.initialBatchHandle=null;this.initialBatchActions=void 0;this.workspaceTheme=void 0;this._tiles=[];this._configActions=[];this._isLoading=!0;this._error=void 0;this._theme=void 0;this._launcher=void 0;this._canvasTitle=void 0;this._displayMode="standard";this._drawerLid=void 0;this._inlineSlots=[];this._isOpen=!1;this._nudgeBadgeCount=0;ne(this,jn,null);this._pageUrl=typeof window<"u"?window.location.href:"/";this._llmTilesVersion=0;this._customCanvasFailed=!1;this._previewToasts=[];this._chatTakeover=!1;ne(this,lt);ne(this,Ki,null);ne(this,Zt,null);ne(this,bn,null);ne(this,Ot,null);ne(this,Zr);ne(this,Yi,"[]");ne(this,$o,0);ne(this,Wn,null);ne(this,Ji,"[]");ne(this,Gr,"[]");ne(this,Po,"null");ne(this,Oo,"null");ne(this,Mo,"null");ne(this,Lo,"[]");ne(this,Kr,null);ne(this,Yr,null);ne(this,zn,null);ne(this,qn,null);ne(this,Zn,null);ne(this,tt,null);ne(this,Xi,!1);ne(this,Gn,null);ne(this,Kn,null);ne(this,Yn,null);ne(this,Jn,null);ne(this,Xn,null);ne(this,Qi,!1);ne(this,Gt,new Map);ne(this,Qn,new Set);ne(this,gc,new Set);ne(this,Jr,!1);ne(this,Xr,()=>{this._pageUrl=window.location.href});ne(this,er);ne(this,No);ne(this,mc,0);ne(this,es,new Map);ne(this,ts,0);ne(this,Qr,t=>{this._chatTakeover=!1,this._nudgeBadgeCount=0,C(this,lt).toggle()});ne(this,vc,t=>{let r=t.detail;q("SmartCanvas","[SmartCanvas] custom canvas load failed; falling back to bundled overlay",r),this._customCanvasFailed=!0;try{this.telemetry?.trackAction?.("canvas-load-failed",r?.canvasName??"unknown","overlay")}catch{}});ne(this,yc,t=>{this._chatTakeover=!!t.detail?.active});L(this,lt,Jp()),L(this,Zr,!1),L(this,er,new Gi(this)),L(this,No,new yi(this,{context:Vy,initialValue:null}))}connectedCallback(){super.connectedCallback(),L(this,jn,t=>{if(t.detail?.suppressToast!==!0){if(this._isOpen){this._nudgeBadgeCount=0,this.requestUpdate();return}this._nudgeBadgeCount+=1,this.requestUpdate()}}),document.addEventListener("syntro:nudge",C(this,jn)),this.style.setProperty("font-family","inherit"),L(this,Ki,C(this,lt).subscribe(t=>{this._isOpen&&!t.open&&L(this,Jr,!1),t.open&&this._previewToasts.length>0&&(this._previewToasts=[]),this._isOpen=t.open})),this._isOpen=C(this,lt).getState().open,L(this,Zt,document.createElement("div")),C(this,Zt).id="overlayContainer",Object.assign(C(this,Zt).style,{position:"fixed",inset:"0",zIndex:"2147483645",pointerEvents:"none"}),this.shadowRoot.appendChild(C(this,Zt)),L(this,bn,document.createElement("div")),C(this,bn).id="portalRoot",this.shadowRoot.appendChild(C(this,bn)),ue(this,oe,tf).call(this),ue(this,oe,af).call(this),ue(this,oe,rf).call(this)}disconnectedCallback(){var t,r,i,s,o,a,l,c,u,p;super.disconnectedCallback(),C(this,jn)&&(document.removeEventListener("syntro:nudge",C(this,jn)),L(this,jn,null)),this._nudgeBadgeCount=0,this._chatTakeover=!1,(t=C(this,Ki))==null||t.call(this),L(this,Ki,null),(r=C(this,Yr))==null||r.call(this),L(this,Yr,null),(i=C(this,zn))==null||i.call(this),L(this,zn,null),(s=C(this,qn))==null||s.call(this),L(this,qn,null),(o=C(this,Zn))==null||o.call(this),L(this,Zn,null),C(this,tt)!=null&&(clearTimeout(C(this,tt)),L(this,tt,null)),(a=C(this,Gn))==null||a.call(this),L(this,Gn,null),(l=C(this,Kn))==null||l.call(this),L(this,Kn,null),(c=C(this,Yn))==null||c.call(this),L(this,Yn,null),(u=C(this,Jn))==null||u.call(this),L(this,Jn,null),(p=C(this,Xn))==null||p.call(this),L(this,Xn,null),L(this,Qi,!1),ue(this,oe,nf).call(this),C(this,Ot)&&(C(this,Ot).revertAll().catch(f=>{console.error("[SmartCanvasElementLit] Failed to revert actions on disconnect:",f)}),L(this,Ot,null)),C(this,Zt)?.remove(),L(this,Zt,null),C(this,bn)?.remove(),L(this,bn,null)}willUpdate(t){t.has("initialBatchHandle")&&this.initialBatchHandle&&(L(this,Ot,this.initialBatchHandle),L(this,Zr,!0),this.initialBatchActions&&(this._configActions=this.initialBatchActions,L(this,Yi,JSON.stringify(this.initialBatchActions)),L(this,Ji,C(this,Yi))));let r=t.has("runtime")||t.has("fetcher")||t.has("configUri")||t.has("configUriFeatureKey")||t.has("fetchCredentials")||t.has("experiments");if(r&&ue(this,oe,ef).call(this),(r||t.has("_pageUrl"))&&this._loadConfig(),(t.has("_theme")||t.has("workspaceTheme"))&&C(this,er).setThemeConfig(this._theme??{},this.workspaceTheme),t.has("_pageUrl")&&(L(this,Jr,!1),this._chatTakeover=!1),t.has("_tiles")||t.has("_isLoading")||t.has("_error")||t.has("_llmTilesVersion")){let s=this._tiles.length+C(this,Gt).size>0&&!this._error;!this._isLoading&&!s&&C(this,lt).getState().open&&!C(this,Jr)&&C(this,lt).setOpen(!1)}}updated(t){var i;t.has("runtime")&&(C(this,No).setValue(this.runtime??null),ue(this,oe,Zy).call(this),ue(this,oe,rf).call(this),ue(this,oe,af).call(this),ue(this,oe,nf).call(this),ue(this,oe,tf).call(this)),(t.has("runtime")||t.has("fetcher")||t.has("configUri")||t.has("configUriFeatureKey")||t.has("fetchCredentials")||t.has("experiments"))&&((i=C(this,Yr))==null||i.call(this),this.experiments?.onFeaturesChanged&&L(this,Yr,this.experiments.onFeaturesChanged(()=>this._loadConfig({silent:!0})))),(t.has("_configActions")||t.has("_pageUrl"))&&ue(this,oe,hc).call(this)}render(){let r=this._tiles.length+C(this,Gt).size>0&&!this._error,i=this._isLoading||r;if(this._displayMode==="inline"){if(!i)return Q;let x=C(this,Gt).size===0?this._tiles:[...this._tiles,...C(this,Gt).values()];return F`
|
|
@@ -623,7 +623,7 @@ ${r}
|
|
|
623
623
|
})();`}var gk=["cdn.syntrologie.com","api.syntrologie.com","dev-api.syntrologie.com","localhost","127.0.0.1",".syntrologie.com"];function n_(n){if(typeof window>"u")return null;let t=new URLSearchParams(window.location.search).get(n);if(!t)return null;try{let r=t.replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(r))}catch(r){return We("Syntro Runtime",`Failed to decode ${n}:`,r),null}}var lf="__syntro_rt_editor_source",cf="__syntro_rt_editor_conf";function bc(n,e){try{sessionStorage.setItem(n,JSON.stringify(e))}catch{}}function r_(n){try{let e=sessionStorage.getItem(n);return e?JSON.parse(e):null}catch{return null}}var tr,nr;function Bo(){if(tr==null){let n=typeof window<"u"?window.__SYNTRO_EDITOR_PARAMS__:null;if(n?.token)tr={token:n.token,api_base:n.apiBase||""},bc(lf,tr),console.log(`[DIAG] getEditorSource: from __SYNTRO_EDITOR_PARAMS__ (token=${tr.token.slice(0,15)}...)`);else{let e=n_("editor_source");if(e)tr=e,bc(lf,e);else{let t=r_(lf);t?.token&&(tr=t,console.log(`[DIAG] getEditorSource: restored from sessionStorage (token=${t.token.slice(0,15)}...)`))}console.log(`[DIAG] getEditorSource: from URL param \u2192 ${e?`token=${e.token?.slice(0,15)}...`:"NULL"}`),!e&&typeof window<"u"&&console.log(`[DIAG] getEditorSource: URL search = ${window.location.search.slice(0,200)}`)}}return tr??null}function wc(){if(nr==null){let n=typeof window<"u"?window.__SYNTRO_EDITOR_PARAMS__:null;if(n?.mode)nr={mode:n.mode,audit_session_id:n.auditSessionId,syntro_token:n.syntroToken,workspace_id:n.workspaceId},bc(cf,nr),console.log(`[DIAG] getEditorConf: from __SYNTRO_EDITOR_PARAMS__ (mode=${nr.mode})`);else{let e=n_("editor_conf");if(e)nr=e,bc(cf,e);else{let t=r_(cf);t?.mode&&(nr=t,console.log(`[DIAG] getEditorConf: restored from sessionStorage (mode=${t.mode})`))}console.log(`[DIAG] getEditorConf: from URL param \u2192 ${e?`mode=${e.mode}`:"NULL"}`)}}return nr??null}function mk(n){q("Syntro Runtime","Validating editor URL:",n);try{if(n.startsWith("/"))return q("Syntro Runtime","\u2713 Relative URL allowed (same-origin):",n),!0;let e=new URL(n),t=/^(localhost|127\.0\.0\.1)$/.test(e.hostname);return e.protocol!=="https:"&&!t?(We("Syntro Runtime","\u274C Editor URL must use HTTPS:",n),!1):gk.some(i=>i.startsWith(".")?e.hostname.endsWith(i)||e.hostname===i.slice(1):e.hostname===i)?(q("Syntro Runtime","\u2713 Editor URL validated"),!0):(We("Syntro Runtime","\u274C Editor URL host not in allowlist:",e.hostname),!1)}catch(e){return We("Syntro Runtime",`\u274C Invalid editor URL: ${n}`,e),!1}}var xc=()=>{let n=wc();return!Bo()?.token||!n?.mode?null:n.mode};function vk(){return Bo()?.token??null}function yk(){return Bo()?.api_base??null}var Ho=null,i_=async n=>{if(q("Syntro Runtime","====== LOAD EDITOR SDK ======"),typeof window>"u"){q("Syntro Runtime","Not in browser - skipping editor SDK load");return}if(window.SyntroEditor){q("Syntro Runtime","Editor SDK already loaded (window.SyntroEditor exists)");return}if(Ho)return q("Syntro Runtime","Editor SDK load already in progress, waiting..."),Ho;let e=typeof n=="string"?{editorUrl:n}:n??{};if(e.editorUrl==="skip"){q("Syntro Runtime",'editorUrl="skip" \u2014 deferring to caller'),q("Syntro Runtime","================================");return}let t=yk(),i=(t?`${t}/api/editor/sdk/editor-sdk.js`:null)||e.editorUrl;if(!i){We("Syntro Runtime","\u274C No editor SDK URL available (no api_base, no editorUrl option)"),q("Syntro Runtime","================================");return}let s=vk(),o=s?`${i}?token=${encodeURIComponent(s)}`:i;if(q("Syntro Runtime","Editor URL:",o),q("Syntro Runtime","Options:",{hasIntegrity:!!e.integrity,hasEditorUrl:!!i,hasApiBase:!!t,tokenPrefix:s?`${s.slice(0,10)}...`:"none"}),!mk(i)){console.error("[Syntro Runtime] \u274C BLOCKED: Editor from untrusted URL:",i),q("Syntro Runtime","================================");return}return q("Syntro Runtime","\u2713 URL validated, injecting script tag..."),Ho=new Promise((a,l)=>{let c=document.createElement("script");c.src=o,c.async=!0,e.integrity&&(c.integrity=e.integrity,c.crossOrigin="anonymous",q("Syntro Runtime","SRI integrity check enabled")),c.onload=()=>{q("Syntro Runtime","\u2713 Editor SDK script loaded successfully"),q("Syntro Runtime","================================"),a()},c.onerror=u=>{console.error("[Syntro Runtime] \u274C Failed to load Editor SDK:",u),console.error("[Syntro Runtime] URL attempted:",o),q("Syntro Runtime","================================"),Ho=null,l(u)},document.head.appendChild(c),q("Syntro Runtime","Script tag appended to <head>")}),Ho};function _k(n,e){let t=Nn(n.kind);if(!t&&n.kind==="core:mountWidget"){let o=n.widget?.widgetId;t=typeof o=="string"?Rt(o):null}if(!t)return null;let r=e.apps,i=r.get?.(t)?.state;return i==="error"||(r.isActive?.(t)??i==="active")?null:t}function bk(n,e){let t=new Set;for(let r of n){let i=_k(r,e);i&&t.add(i)}return[...t]}function wk(n){if(typeof window>"u")return n;let t=window.SynOS?.wrapCanvasConfigFetcher;if(!t)return n;try{return t(n)}catch(r){return console.warn("[SmartCanvas] Failed to wrap config fetcher:",r),n}}var Sc=async(n={})=>{if(typeof window>"u"||typeof document>"u")throw new Error("SmartCanvas can only be created in a browser-like environment");let e=null;if(n.antiFlicker){let m=typeof n.antiFlicker=="object"?n.antiFlicker:{};e=e_(m)}let t=null,r=null,i=null,{runtime:s}=n;async function o(m){!s?.actions||m.length===0||(i?.isApplied()&&await i.revertAll(),i=await s.actions.applyBatch(m))}async function a(){i?.isApplied()&&(await i.revertAll(),i=null)}if(n.fetcher)try{r=n.fetcher,console.log("[SmartCanvas] Fetching initial config...");let m=await n.fetcher();if(t=m,console.log("[SmartCanvas] Config fetched:",`tiles=${m.tiles?.length??0},`,`actions=${m.actions?.length??0},`,`theme=${m.theme?.mode??"default"}`),m.actions?.length&&console.log("[SmartCanvas] Actions to apply:",m.actions.map((y,w)=>`[${w}] ${y.kind}${y.anchorId?` anchor="${y.anchorId.selector}"`:""}${y.label?` "${y.label}"`:""}`).join(", ")),m.actions&&m.actions.length>0&&s?.actions){let y=bk(m.actions,s);y.length>0?console.warn(`[SmartCanvas] Skipping eager action apply until app(s) activate: ${y.join(", ")}`):(await o(m.actions),console.log("[SmartCanvas] Initial actions applied successfully"))}m.tiles&&s?.accumulator&&zr(m.tiles,s.accumulator,m.actions)}catch(m){console.error("[SmartCanvas] Error fetching/applying initial config:",m)}e&&e();let l=xc();Fo();let c=document.createElement("smart-canvas");if(n.tokens)for(let[m,y]of Object.entries(n.tokens))c.style.setProperty(m,y);let u=n.integrations?.experiments,p=n.integrations?.telemetry,f=n.fetcher??Ur({configUri:n.configUri,experiments:u,featureKey:n.configUriFeatureKey,credentials:n.fetchCredentials});r||(r=f);let h={fetcher:f,configUri:n.configUri,configUriFeatureKey:n.configUriFeatureKey,fetchCredentials:n.fetchCredentials,experiments:u,telemetry:p,runtime:s,initialBatchHandle:i,initialBatchActions:i?t?.actions??[]:void 0,workspaceTheme:n.workspaceTheme};c.mountLitApp(h),n.defaultOpen&&c.open();let g=()=>{let m=n.target??document.body;if(m){m.appendChild(c);let y=c.getOverlayContainer();y&&Yv(y)}};document.body?g():document.addEventListener("DOMContentLoaded",g,{once:!0}),(l||n.editorUrl)&&(console.log(`[SmartCanvas] Loading editor SDK for ${l??"config"} mode`),i_(n.editorUrl).catch(console.error));let v={el:c,open:()=>c.open(),close:()=>c.close(),destroy:()=>{a(),c.remove()},setTokens:m=>{for(let[y,w]of Object.entries(m))c.style.setProperty(y,w)},getConfig:async()=>{if(r)try{let m=await r();return t=m,m}catch(m){console.error("[SmartCanvas] Error fetching config:",m)}return t??{tiles:[],actions:[],fetchedAt:""}},setEnabled:async m=>{m?t&&await o(t.actions):await a()},setOverrideFetcher:m=>{let y=wk(m);r=y,c.setOverrideFetcher(y),s?.accumulator&&y().then(w=>{w?.tiles&&zr(w.tiles,s.accumulator,w.actions)}).catch(()=>{})},registerTelemetryProperties:m=>{p?.register?.(m)},getSessionId:()=>p?.getSessionId?.(),startSessionRecording:()=>{p?.startSessionRecording?.()},track:(m,y)=>p?.track?(p.track(m,y),!0):!1,previewNotification:m=>c.previewNotification(m),runtime:s};if(typeof window<"u"){let m=window.SynOS;m&&(m.handle=v)}return v};typeof window<"u"&&(window.SmartCanvas={async create(n){return Sc(n)}});var uf="syn_";function ns(n){if(!n.startsWith(uf))throw new Error("Invalid Syntro token: must start with 'syn_'");let t=n.slice(uf.length).replace(/-/g,"+").replace(/_/g,"/"),r=atob(t),i=JSON.parse(r);if(i.v!==1)throw new Error(`Unsupported token version: ${i.v}`);return i}function Ec(n){let e=JSON.stringify(n),t=btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return uf+t}function xt(n){if(typeof process<"u"&&process.env)return process.env[n]}function hf(n,e){if(typeof window>"u")return null;try{let t=localStorage.getItem(n);if(!t)return null;let r=JSON.parse(t);return!r||typeof r.ts!="number"||!("data"in r)||e!=null&&Date.now()-r.ts>e?null:r.data}catch{return null}}function gf(n,e){if(!(typeof window>"u"))try{let t={ts:Date.now(),data:e};localStorage.setItem(n,JSON.stringify(t))}catch{}}var a_="syntro_segment_attributes";function l_(){let n=hf(a_);return n?(q("Syntro Bootstrap","Loaded cached segment attributes:",n),n):{}}function c_(n){gf(a_,n),q("Syntro Bootstrap","Cached segment attributes:",n)}var Cc="syntro_device_id",Vo="syntro_session_id_choice",rs=null,ff=!1,df=null;function xk(n){return!n||n.startsWith("$")?null:n}var u_=n=>{if(n!=="denied"){ff=!1;return}ff=!0;let e=null;try{e=localStorage.getItem(Cc),localStorage.removeItem(Cc)}catch{}if(e){try{sessionStorage.getItem(Vo)===e&&sessionStorage.removeItem(Vo)}catch{}rs===e&&(rs=null)}};function pf(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let e=Math.random()*16|0;return(n==="x"?e:e&3|8).toString(16)})}function Sk(){if(ff)return{id:pf(),source:"session_uuid",persisted:!1};try{let n=localStorage.getItem(Cc);if(n)return{id:n,source:"device_uuid",persisted:!0};let e=pf();return localStorage.setItem(Cc,e),{id:e,source:"device_uuid",persisted:!0}}catch{return{id:pf(),source:"device_uuid",persisted:!1}}}function is(n){if(rs)return rs;try{let o=sessionStorage.getItem(Vo);if(o)if(o.startsWith("$"))try{sessionStorage.removeItem(Vo)}catch{}else return rs=o,df={source:"session_choice",persisted:!0},o}catch{}let e=xk(n),t,r,i;if(e)t=e,r="posthog_distinct_id",i=!1;else{let o=Sk();t=o.id,r=o.source,i=o.persisted}rs=t;let s=!1;try{sessionStorage.setItem(Vo,t),s=!0}catch{}return df={source:r,persisted:r==="posthog_distinct_id"||i||s},q("Syntro Bootstrap","Stable visitor id chosen:",df),t}function d_(n){if(!n)return{};let e={};for(let[t,r]of Object.entries(n))t.startsWith("in_segment_")&&(e[t]=r===!0);return e}function Ek(n){return!n||n==="/"?n:n.replace(/\/+$/,"")||"/"}function mf(){if(typeof window>"u")return{};let n={};try{let e=new URLSearchParams(window.location.search);for(let t of["utm_source","utm_medium","utm_campaign","utm_content","utm_term"]){let r=e.get(t);r&&(n[t]=r)}}catch{}try{navigator.language&&(n.browser_language=navigator.language),navigator.languages?.length&&(n.browser_languages=[...navigator.languages])}catch{}try{let e=window.innerWidth;n.device_type=e<768?"mobile":e<1024?"tablet":"desktop"}catch{}try{if(document.referrer){n.referrer=document.referrer;try{n.referrer_hostname=new URL(document.referrer).hostname}catch{}}}catch{}try{let e=navigator.userAgent;e.includes("Edg/")?n.browser="Edge":e.includes("OPR/")||e.includes("Opera")?n.browser="Opera":e.includes("Chrome/")&&!e.includes("Chromium")?n.browser="Chrome":e.includes("Safari/")&&!e.includes("Chrome")?n.browser="Safari":e.includes("Firefox/")&&(n.browser="Firefox"),e.includes("Windows")?n.os="Windows":e.includes("iPhone")||e.includes("iPad")?n.os="iOS":e.includes("Mac OS X")||e.includes("Macintosh")?n.os="macOS":e.includes("Android")?n.os="Android":e.includes("Linux")&&(n.os="Linux")}catch{}try{n.page_url=window.location.href,n.page_path=Ek(window.location.pathname),n.page_host=window.location.hostname,window.location.search&&(n.page_query=window.location.search)}catch{}try{let e=window.Telegram?.WebApp;e?(n.surface_type="telegram",n.surface_host=e.platform||"unknown"):(n.surface_type="web",n.surface_host="web")}catch{n.surface_type="web",n.surface_host="web"}try{let e=n.surface_type;e==="telegram"||e==="mcp-app"?n.surface="personal_agent":n.device_type==="mobile"?n.surface="mobile":n.surface="desktop"}catch{n.surface="desktop"}return n}var p_="syntro_initial_attrs",Ck=1800*1e3,s_=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"];function kk(n){if(typeof window>"u")return!1;try{return n===window.location.hostname}catch{return!1}}function vf(n,e){let t={},r=s_.some(o=>typeof n[o]=="string");for(let o of s_){let a=r?n[o]:e?.[o];a&&(t[o]=a)}let i=typeof n.referrer_hostname=="string"?n.referrer_hostname:void 0;return!(i?kk(i):!0)&&typeof n.referrer=="string"?(t.referrer=n.referrer,i&&(t.referrer_hostname=i)):e?.referrer&&(t.referrer=e.referrer,e.referrer_hostname&&(t.referrer_hostname=e.referrer_hostname)),e?.initial_page_url?(t.initial_page_url=e.initial_page_url,e.initial_page_path&&(t.initial_page_path=e.initial_page_path),e.initial_page_query&&(t.initial_page_query=e.initial_page_query)):(typeof n.page_url=="string"&&(t.initial_page_url=n.page_url),typeof n.page_path=="string"&&(t.initial_page_path=n.page_path),typeof n.page_query=="string"&&(t.initial_page_query=n.page_query)),t}function f_(){return hf(p_,Ck)}function h_(n){gf(p_,n),q("Syntro Bootstrap","Cached initial attrs:",n)}var o_="syntro_geo",g_="https://geo.syntrologie.com";async function yf(n){if(typeof window>"u")return{};try{let e=localStorage.getItem(o_);if(e){let t=JSON.parse(e);return q("Syntro Bootstrap","Geo: using cached data:",t),t}}catch{}try{let e=await fetch(n,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json(),r={};for(let[i,s]of Object.entries(t))typeof s=="string"&&s&&(r[i]=s);try{localStorage.setItem(o_,JSON.stringify(r))}catch{}return q("Syntro Bootstrap","Geo: fetched from worker:",r),r}}catch{}return{}}var m_=!1;function v_(n){return typeof window<"u"&&typeof window.Shopify<"u"&&!m_&&(m_=!0,console.warn("[syntrologie-sdk] This Shopify storefront is loading the lite SDK bundle (smart-canvas.min.js), which no longer includes Shopify integration. Update your snippet to load smart-canvas.shopify.min.js \u2014 see https://docs.syntrologie.com/sdk/shopify-migration")),{}}var y_=["fbclid","ttclid","gclid","gbraid","wbraid","msclkid","twclid","li_fat_id","epik","ScCid","yclid","_kx","mc_eid","mc_cid"];function _f(n){if(typeof window>"u"||!n.setPersonPropertiesOnce)return;let e=new URLSearchParams(window.location.search),t={};for(let r of y_){let i=e.get(r);i&&(t[`$initial_${r}`]=i)}Object.keys(t).length>0&&n.setPersonPropertiesOnce(t)}var Ak=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Tk=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Rk=[/@yopmail\.com$/i,/@mailinator\.com$/i,/@guerrillamail\.(com|info|net|org|biz)$/i,/@10minutemail\.com$/i,/^test@/i,/^noreply@/i,/^no-reply@/i];function kc(n){return n?Tk.test(n):!1}function __(n){return Rk.some(e=>e.test(n))}function Ik(n){if(n.type==="email")return!0;let e=(n.name||"").toLowerCase(),t=(n.id||"").toLowerCase();return!!(/email/.test(e)||/email/.test(t))}function $k(n){return n.closest("[data-syntro-no-identify]")!==null}function Pk(n){return n?Ak.test(n):!0}function bf(n,e){if(typeof document>"u")return()=>{};if(!n.identify&&!n.alias)return()=>{};let t=new Set,r=s=>{let o=n.getDistinctId?.();if(o===s){t.add(s);return}Pk(o)?n.identify?.(s,{email:s}):n.alias?.(s),t.add(s)},i=s=>{let o=s.target;if(!(o instanceof HTMLInputElement)||$k(o)||!Ik(o))return;let a=(o.value??"").trim().toLowerCase();if(!kc(a)||__(a)||t.has(a))return;if(!e){r(a);return}let l=e.getStatus();if(l==="granted"){r(a);return}l!=="denied"&&e.resolvePending().then(c=>{c==="granted"&&r(a)})};return document.addEventListener("change",i,!0),()=>{document.removeEventListener("change",i,!0),t.clear()}}var b_="_syu",Ok=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Mk(n){return n?Ok.test(n):!0}function wf(n,e){if(typeof window>"u"||!n.identify&&!n.alias)return;let t=new URLSearchParams(window.location.search).get(b_);if(!t)return;let r=t.trim();if(!r)return;let i=()=>{let a=n.getDistinctId?.();if(a===r)return;let l=kc(r)?{email:r}:void 0;Mk(a)?n.identify?.(r,l):n.alias?.(r)};if(!e){i();return}if(e.getStatus()==="granted"){i();return}let s=!1,o=e.subscribe(a=>{s||a==="granted"&&(s=!0,o(),i())})}var Lk=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"];function Nk(n){return n.is_eu==="true"||n.country_code==="GB"||n.country_code==="CH"||!n.is_eu&&!n.country_code}function Fk(n){if(!n)return"";try{return new URL(n).hostname}catch{return""}}function xf(){return typeof window>"u"?"":`${window.location.origin}${window.location.pathname}`}function Sf(n,e){if(typeof window>"u"||typeof document>"u"||!n.setPersonPropertiesOnce)return;let t=document.referrer||"",r=new URLSearchParams(window.location.search),i={$initial_pathname:window.location.pathname,$initial_referrer:t,$initial_referring_domain:Fk(t)};for(let s of Lk){let o=r.get(s);o&&(i[`$initial_${s}`]=o)}if(n.setPersonPropertiesOnce(i),!e){n.setPersonPropertiesOnce({$initial_url:xf()});return}e.then(s=>{let o=Nk(s)?xf():window.location.href;n.setPersonPropertiesOnce?.({$initial_url:o})}).catch(()=>{n.setPersonPropertiesOnce?.({$initial_url:xf()})})}var w_=new Set(["email","telephone","streetAddress","addressLocality","addressRegion","postalCode","givenName","familyName"]),x_=500,Ef=3;function Ac(n){if(Array.isArray(n))return n.map(Ac);if(n&&typeof n=="object"){let e={};for(let[t,r]of Object.entries(n))w_.has(t)||(e[t]=Ac(r));return e}return n}function Tc(n){if(Array.isArray(n))return n.map(Tc);if(n&&typeof n=="object"){let e={};for(let[t,r]of Object.entries(n))if(!(t==="description"&&typeof r=="string"&&r.length>x_)){if(t==="image"&&Array.isArray(r)&&r.length>Ef){e[t]=r.slice(0,Ef);continue}e[t]=Tc(r)}return e}return n}function Dk(){return typeof document>"u"?[]:Array.from(document.querySelectorAll('script[type="application/ld+json"]')).filter(n=>!n.hasAttribute("data-syntro-no-jsonld")).map(n=>{try{return JSON.parse(n.textContent??"")}catch{return null}}).filter(n=>n!==null)}function Cf(n){if(!n.register)return;let e=Dk().map(Tc).map(Ac);e.length!==0&&n.register({json_ld:e})}function S_(n,e,t={}){Sf(n,t.geoPromise),_f(n),Cf(n),wf(n,e);let r=bf(n,e);return()=>{r()}}var ss=class{constructor(e=100){this.entries=[];this.maxSize=e}record(e){this.entries.push(e),this.maxSize>0&&this.entries.length>this.maxSize&&this.entries.shift()}getAll(){return[...this.entries]}clear(){this.entries=[]}};var C_={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function k_(){return C_}function kf(n){let e=2166136261,t=n.length;for(let r=0;r<t;r++)e^=n.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function Uo(n,e,t){return t===2?kf(kf(n+e)+"")%1e4/1e4:t===1?kf(e+n)%1e3/1e3:null}function Hk(n){return n<=0?[]:new Array(n).fill(1/n)}function Rc(n,e){return n>=e[0]&&n<e[1]}function A_(n,e){let t=Uo("__"+e[0],n,1);return t===null?!1:t>=e[1]&&t<e[2]}function T_(n,e){for(let t=0;t<e.length;t++)if(Rc(n,e[t]))return t;return-1}function Tf(n){try{let e=n.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function Ic(n,e){if(!e.length)return!1;let t=!1,r=!1;for(let i=0;i<e.length;i++){let s=Uk(n,e[i].type,e[i].pattern);if(e[i].include===!1){if(s)return!1}else t=!0,s&&(r=!0)}return r||!t}function Bk(n,e,t){try{let r=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(n)}catch{return!1}}function Vk(n,e){try{let t=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[n.host,t.host,!1],[n.pathname,t.pathname,!0]];return t.hash&&r.push([n.hash,t.hash,!1]),t.searchParams.forEach((i,s)=>{r.push([n.searchParams.get(s)||"",i,!1])}),!r.some(i=>!Bk(i[0],i[1],i[2]))}catch{return!1}}function Uk(n,e,t){try{let r=new URL(n,"https://_");if(e==="regex"){let i=Tf(t);return i?i.test(r.href)||i.test(r.href.substring(r.origin.length)):!1}else if(e==="simple")return Vk(r,t);return!1}catch{return!1}}function R_(n,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let r=Hk(n);t=t||r,t.length!==n&&(t=r);let i=t.reduce((o,a)=>a+o,0);(i<.99||i>1.01)&&(t=r);let s=0;return t.map(o=>{let a=s;return s+=o,[a,a+e*o]})}function I_(n,e,t){if(!e)return null;let r=e.split("?")[1];if(!r)return null;let i=r.replace(/#.*/,"").split("&").map(s=>s.split("=",2)).filter(([s])=>s===n).map(([,s])=>parseInt(s));return i.length>0&&i[0]>=0&&i[0]<t?i[0]:null}function $_(n){try{return n()}catch(e){return console.error(e),!1}}var Af=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0));async function ei(n,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||C_.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let r=await t.importKey("raw",Af(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[i,s]=n.split("."),o=await t.decrypt({name:"AES-CBC",iv:Af(i)},r,Af(s));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function jo(n){return typeof n=="string"?n:JSON.stringify(n)}function pt(n){typeof n=="number"&&(n=n+""),(!n||typeof n!="string")&&(n="0");let e=n.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}function P_(){let n;try{n="1.6.4"}catch{n=""}return n}function O_(n,e){let t,r;try{t=new URL(n),r=new URL(e)}catch(i){return console.error(`Unable to merge query strings: ${i}`),e}return t.searchParams.forEach((i,s)=>{r.searchParams.has(s)||r.searchParams.set(s,i)}),r.toString()}function E_(n){return typeof n=="object"&&n!==null}function $c(n){return n.urlPatterns&&n.variations.some(e=>E_(e)&&"urlRedirect"in e)?"redirect":n.variations.some(e=>E_(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function Pc(n,e){return new Promise(t=>{let r=!1,i,s=o=>{r||(r=!0,i&&clearTimeout(i),t(o||null))};e&&(i=setTimeout(()=>s(),e)),n.then(o=>s(o)).catch(()=>s())})}var Ke={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},Kt=k_(),os={fetchFeaturesCall:({host:n,clientKey:e,headers:t})=>Kt.fetch(`${n}/api/features/${e}`,{headers:t}),fetchRemoteEvalCall:({host:n,clientKey:e,payload:t,headers:r})=>{let i={method:"POST",headers:{"Content-Type":"application/json",...r},body:JSON.stringify(t)};return Kt.fetch(`${n}/api/eval/${e}`,i)},eventSourceCall:({host:n,clientKey:e,headers:t})=>t?new Kt.EventSource(`${n}/sub/${e}`,{headers:t}):new Kt.EventSource(`${n}/sub/${e}`),startIdleListener:()=>{let n;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(n),zk()):document.visibilityState==="hidden"&&(n=window.setTimeout(Wk,Ke.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Kt.localStorage=globalThis.localStorage)}catch{}var as=new Map,M_=!1,wn=new Map,Oc=new Map,ls=new Map,cs=new Set;function N_(n){Object.assign(Ke,n),Ke.backgroundSync||Mf()}async function F_({instance:n,timeout:e,skipCache:t,allowStale:r,backgroundSync:i}){return i||(Ke.backgroundSync=!1),qk({instance:n,allowStale:r,timeout:e,skipCache:t})}function jk(n){let e=Wo(n),t=as.get(e)||new Set;t.add(n),as.set(e,t)}function D_(n){as.forEach(e=>e.delete(n))}function Wk(){ls.forEach(n=>{n&&(n.state="idle",Pf(n))})}function zk(){ls.forEach(n=>{n&&n.state==="idle"&&Of(n)})}async function L_(){try{if(!Kt.localStorage)return;await Kt.localStorage.setItem(Ke.cacheKey,JSON.stringify(Array.from(wn.entries())))}catch{}}async function qk({instance:n,allowStale:e,timeout:t,skipCache:r}){let i=Wo(n),s=If(n),o=new Date,a=new Date(o.getTime()-Ke.maxAge+Ke.staleTTL);await Zk();let l=!Ke.disableCache&&!r?wn.get(s):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&cs.add(i),l.staleAt<o?Rf(n):$f(n),{data:l.data,success:!0,source:"cache"}):await Pc(Rf(n),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function Wo(n){let[e,t]=n.getApiInfo();return`${e}||${t}`}function If(n){let e=Wo(n);if(!("isRemoteEval"in n)||!n.isRemoteEval())return e;let t=n.getAttributes(),r=n.getCacheKeyAttributes()||Object.keys(n.getAttributes()),i={};r.forEach(a=>{i[a]=t[a]});let s=n.getForcedVariations(),o=n.getUrl();return`${e}||${JSON.stringify({ca:i,fv:s,url:o})}`}async function Zk(){if(!M_){M_=!0;try{if(Kt.localStorage){let n=await Kt.localStorage.getItem(Ke.cacheKey);if(!Ke.disableCache&&n){let e=JSON.parse(n);e&&Array.isArray(e)&&e.forEach(([t,r])=>{wn.set(t,{...r,staleAt:new Date(r.staleAt)})}),H_()}}}catch{}if(!Ke.disableIdleStreams){let n=os.startIdleListener();n&&(os.stopIdleListener=n)}}}function H_(){let n=Array.from(wn.entries()).map(([t,r])=>({key:t,staleAt:r.staleAt.getTime()})).sort((t,r)=>t.staleAt-r.staleAt),e=Math.min(Math.max(0,wn.size-Ke.maxEntries),wn.size);for(let t=0;t<e;t++)wn.delete(n[t].key)}function B_(n,e,t){let r=t.dateUpdated||"",i=new Date(Date.now()+Ke.staleTTL),s=Ke.disableCache?void 0:wn.get(e);if(s&&r&&s.version===r){s.staleAt=i,L_();return}Ke.disableCache||(wn.set(e,{data:t,version:r,staleAt:i,sse:cs.has(n)}),H_()),L_();let o=as.get(n);o&&o.forEach(a=>Gk(a,t))}async function Gk(n,e){await n.setPayload(e||n.getPayload())}async function Rf(n){let{apiHost:e,apiRequestHeaders:t}=n.getApiHosts(),r=n.getClientKey(),i="isRemoteEval"in n&&n.isRemoteEval(),s=Wo(n),o=If(n),a=Oc.get(o);return a||(a=(i?os.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:n.getAttributes(),forcedVariations:n.getForcedVariations(),forcedFeatures:Array.from(n.getForcedFeatures().entries()),url:n.getUrl()},headers:t}):os.fetchFeaturesCall({host:e,clientKey:r,headers:t})).then(c=>{if(!c.ok)throw new Error(`HTTP error: ${c.status}`);return c.headers.get("x-sse-support")==="enabled"&&cs.add(s),c.json()}).then(c=>(B_(s,o,c),$f(n),Oc.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(Oc.delete(o),{data:null,source:"error",success:!1,error:c})),Oc.set(o,a)),a}function $f(n,e=!1){let t=Wo(n),r=If(n),{streamingHost:i,streamingHostRequestHeaders:s}=n.getApiHosts(),o=n.getClientKey();if(e&&cs.add(t),Ke.backgroundSync&&cs.has(t)&&Kt.EventSource){if(ls.has(t))return;let a={src:null,host:i,clientKey:o,headers:s,cb:l=>{try{if(l.type==="features-updated"){let c=as.get(t);c&&c.forEach(u=>{Rf(u)})}else if(l.type==="features"){let c=JSON.parse(l.data);B_(t,r,c)}a.errors=0}catch{V_(a)}},errors:0,state:"active"};ls.set(t,a),Of(a)}}function V_(n){if(n.state!=="idle"&&(n.errors++,n.errors>3||n.src&&n.src.readyState===2)){let e=Math.pow(3,n.errors-3)*(1e3+Math.random()*1e3);Pf(n),setTimeout(()=>{["idle","active"].includes(n.state)||Of(n)},Math.min(e,3e5))}}function Pf(n){n.src&&(n.src.onopen=null,n.src.onerror=null,n.src.close(),n.src=null,n.state==="active"&&(n.state="disabled"))}function Of(n){n.src=os.eventSourceCall({host:n.host,clientKey:n.clientKey,headers:n.headers}),n.state="active",n.src.addEventListener("features",n.cb),n.src.addEventListener("features-updated",n.cb),n.src.onerror=()=>V_(n),n.src.onopen=()=>{n.errors=0}}function Kk(n,e){Pf(n),ls.delete(e)}function Mf(){cs.clear(),ls.forEach(Kk),as.clear(),os.stopIdleListener()}function Mc(n,e){if(e.streaming){if(!n.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&$f(n,!0),jk(n)}}var Yk=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Ff={revert:function(){}},Dc=new Map,Df=new Set;function Jk(n){return n==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[n]}}function Hc(n){var e=Dc.get(n);return e||(e={element:n,attributes:{}},Dc.set(n,e)),e}function Bc(n,e,t,r,i){var s=t(n),o={isDirty:!1,originalValue:s,virtualValue:s,mutations:[],el:n,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=t(n);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,i(o))}}),mutationRunner:i,setValue:r,getCurrentValue:t};return e==="position"&&n.parentNode?o.observer.observe(n.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(n,Jk(e)),o}function Vc(n,e){var t=e.getCurrentValue(e.el);e.virtualValue=n,n&&typeof n!="string"?(!t||n.parentNode!==t.parentNode||n.insertBeforeNode!==t.insertBeforeNode)&&(e.isDirty=!0,U_()):n!==t&&(e.isDirty=!0,U_())}function Xk(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),Vc(pA(e),n)}function Qk(n){var e=new Set(n.originalValue.split(/\s+/).filter(Boolean));n.mutations.forEach(function(t){return t.mutate(e)}),Vc(Array.from(e).filter(Boolean).join(" "),n)}function eA(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),Vc(e,n)}function tA(n){var e=n.parentSelector,t=n.insertBeforeSelector,r=document.querySelector(e);if(!r)return null;var i=t?document.querySelector(t):null;return t&&!i?null:{parentNode:r,insertBeforeNode:i}}function nA(n){var e=n.originalValue;n.mutations.forEach(function(t){var r=t.mutate(),i=tA(r);e=i||e}),Vc(e,n)}var rA=function(e){return e.innerHTML},iA=function(e,t){return e.innerHTML=t};function W_(n){var e=Hc(n);return e.html||(e.html=Bc(n,"html",rA,iA,Xk)),e.html}var sA=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},oA=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};function z_(n){var e=Hc(n);return e.position||(e.position=Bc(n,"position",sA,oA,nA)),e.position}var aA=function(e,t){return t?e.className=t:e.removeAttribute("class")},lA=function(e){return e.className};function q_(n){var e=Hc(n);return e.classes||(e.classes=Bc(n,"class",lA,aA,Qk)),e.classes}var cA=function(e){return function(t){var r;return(r=t.getAttribute(e))!=null?r:null}},uA=function(e){return function(t,r){return r!==null?t.setAttribute(e,r):t.removeAttribute(e)}};function Z_(n,e){var t=Hc(n);return t.attributes[e]||(t.attributes[e]=Bc(n,e,cA(e),uA(e),eA)),t.attributes[e]}function dA(n,e){var t=Dc.get(n);if(t)if(e==="html"){var r,i;(r=t.html)==null||(i=r.observer)==null||i.disconnect(),delete t.html}else if(e==="class"){var s,o;(s=t.classes)==null||(o=s.observer)==null||o.disconnect(),delete t.classes}else if(e==="position"){var a,l;(a=t.position)==null||(l=a.observer)==null||l.disconnect(),delete t.position}else{var c,u,p;(c=t.attributes)==null||(u=c[e])==null||(p=u.observer)==null||p.disconnect(),delete t.attributes[e]}}var Lc;function pA(n){return Lc||(Lc=document.createElement("div")),Lc.innerHTML=n,Lc.innerHTML}function Nc(n,e,t){if(t.isDirty){t.isDirty=!1;var r=t.virtualValue;t.mutations.length||dA(n,e),t.setValue(n,r)}}function fA(n,e){n.html&&Nc(e,"html",n.html),n.classes&&Nc(e,"class",n.classes),n.position&&Nc(e,"position",n.position),Object.keys(n.attributes).forEach(function(t){Nc(e,t,n.attributes[t])})}function U_(){Dc.forEach(fA)}function hA(n,e){var t=null;n.kind==="html"?t=W_(e):n.kind==="class"?t=q_(e):n.kind==="attribute"?t=Z_(e,n.attribute):n.kind==="position"&&(t=z_(e)),t&&(t.mutations.push(n),t.mutationRunner(t))}function gA(n,e){var t=null;if(n.kind==="html"?t=W_(e):n.kind==="class"?t=q_(e):n.kind==="attribute"?t=Z_(e,n.attribute):n.kind==="position"&&(t=z_(e)),!!t){var r=t.mutations.indexOf(n);r!==-1&&t.mutations.splice(r,1),t.mutationRunner(t)}}function G_(n){if(!(n.kind==="position"&&n.elements.size===1)){var e=new Set(n.elements),t=document.querySelectorAll(n.selector);t.forEach(function(r){e.has(r)||(n.elements.add(r),hA(n,r))})}}function mA(n){n.elements.forEach(function(e){return gA(n,e)}),n.elements.clear(),Df.delete(n)}function j_(){Df.forEach(G_)}var Lf;function vA(){typeof document>"u"||(Lf||(Lf=new MutationObserver(function(){j_()})),j_(),Lf.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}vA();function Uc(n){return typeof document>"u"?Ff:(Df.add(n),G_(n),{revert:function(){mA(n)}})}function Nf(n,e){return Uc({kind:"html",elements:new Set,mutate:e,selector:n})}function K_(n,e){return Uc({kind:"position",elements:new Set,mutate:e,selector:n})}function zo(n,e){return Uc({kind:"class",elements:new Set,mutate:e,selector:n})}function Fc(n,e,t){return Yk.test(e)?e==="class"||e==="className"?zo(n,function(r){var i=t(Array.from(r).join(" "));r.clear(),i&&i.split(/\s+/g).filter(Boolean).forEach(function(s){return r.add(s)})}):Uc({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:n}):Ff}function yA(n){var e=n.selector,t=n.action,r=n.value,i=n.attribute,s=n.parentSelector,o=n.insertBeforeSelector;if(i==="html"){if(t==="append")return Nf(e,function(a){return a+(r??"")});if(t==="set")return Nf(e,function(){return r??""})}else if(i==="class"){if(t==="append")return zo(e,function(a){r&&a.add(r)});if(t==="remove")return zo(e,function(a){r&&a.delete(r)});if(t==="set")return zo(e,function(a){a.clear(),r&&a.add(r)})}else if(i==="position"){if(t==="set"&&s)return K_(e,function(){return{insertBeforeSelector:o,parentSelector:s}})}else{if(t==="append")return Fc(e,i,function(a){return a!==null?a+(r??""):r??""});if(t==="set")return Fc(e,i,function(){return r??""});if(t==="remove")return Fc(e,i,function(){return null})}return Ff}var _A={html:Nf,classes:zo,attribute:Fc,position:K_,declarative:yA},Y_=_A;var Hf={};function rr(n,e,t){t=t||{};for(let[r,i]of Object.entries(e))switch(r){case"$or":if(!Q_(n,i,t))return!1;break;case"$nor":if(Q_(n,i,t))return!1;break;case"$and":if(!EA(n,i,t))return!1;break;case"$not":if(rr(n,i,t))return!1;break;default:if(!qo(i,bA(n,r),t))return!1}return!0}function bA(n,e){let t=e.split("."),r=n;for(let i=0;i<t.length;i++)if(r&&typeof r=="object"&&t[i]in r)r=r[t[i]];else return null;return r}function J_(n,e=!1){let t=`${n}${e?"/i":""}`;return Hf[t]||(Hf[t]=new RegExp(n.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Hf[t]}function qo(n,e,t,r=!1){if(typeof n=="string")return r?String(e).toLowerCase()===n.toLowerCase():e+""===n;if(typeof n=="number")return e*1===n;if(typeof n=="boolean")return e!==null&&!!e===n;if(n===null)return e===null;if(Array.isArray(n)||!eb(n))return JSON.stringify(e)===JSON.stringify(n);for(let i in n)if(!SA(i,e,n[i],t))return!1;return!0}function eb(n){let e=Object.keys(n);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function wA(n){if(n===null)return"null";if(Array.isArray(n))return"array";let e=typeof n;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function xA(n,e,t){if(!Array.isArray(n))return!1;let r=eb(e)?i=>qo(e,i,t):i=>rr(i,e,t);for(let i=0;i<n.length;i++)if(n[i]&&r(n[i]))return!0;return!1}function us(n,e,t=!1){if(t){let r=i=>typeof i=="string"?i.toLowerCase():i;return Array.isArray(n)?n.some(i=>e.some(s=>r(i)===r(s))):e.some(i=>r(n)===r(i))}return Array.isArray(n)?n.some(r=>e.includes(r)):e.includes(n)}function X_(n,e,t,r=!1){if(!Array.isArray(n))return!1;for(let i=0;i<e.length;i++){let s=!1;for(let o=0;o<n.length;o++)if(qo(e[i],n[o],t,r)){s=!0;break}if(!s)return!1}return!0}function SA(n,e,t,r){switch(n){case"$veq":return pt(e)===pt(t);case"$vne":return pt(e)!==pt(t);case"$vgt":return pt(e)>pt(t);case"$vgte":return pt(e)>=pt(t);case"$vlt":return pt(e)<pt(t);case"$vlte":return pt(e)<=pt(t);case"$eq":return e===t;case"$ne":return e!==t;case"$lt":return e<t;case"$lte":return e<=t;case"$gt":return e>t;case"$gte":return e>=t;case"$exists":return t?e!=null:e==null;case"$in":return Array.isArray(t)?us(e,t):!1;case"$ini":return Array.isArray(t)?us(e,t,!0):!1;case"$inGroup":return us(e,r[t]||[]);case"$notInGroup":return!us(e,r[t]||[]);case"$nin":return Array.isArray(t)?!us(e,t):!1;case"$nini":return Array.isArray(t)?!us(e,t,!0):!1;case"$not":return!qo(t,e,r);case"$size":return Array.isArray(e)?qo(t,e.length,r):!1;case"$elemMatch":return xA(e,t,r);case"$all":return Array.isArray(t)?X_(e,t,r):!1;case"$alli":return Array.isArray(t)?X_(e,t,r,!0):!1;case"$regex":try{return J_(t).test(e)}catch{return!1}case"$regexi":try{return J_(t,!0).test(e)}catch{return!1}case"$type":return wA(e)===t;default:return console.error("Unknown operator: "+n),!1}}function Q_(n,e,t){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(rr(n,e[r],t))return!0;return!1}function EA(n,e,t){for(let r=0;r<e.length;r++)if(!rr(n,e[r],t))return!1;return!0}var CA="Feature Evaluated",kA="Experiment Viewed";function AA(n){let e=new Map;return n.global.forcedFeatureValues&&n.global.forcedFeatureValues.forEach((t,r)=>e.set(r,t)),n.user.forcedFeatureValues&&n.user.forcedFeatureValues.forEach((t,r)=>e.set(r,t)),e}function TA(n){return n.global.forcedVariations&&n.user.forcedVariations?{...n.global.forcedVariations,...n.user.forcedVariations}:n.global.forcedVariations?n.global.forcedVariations:n.user.forcedVariations?n.user.forcedVariations:{}}async function ds(n){try{await n()}catch{}}function tb(n,e,t){if(n.user.trackedExperiments){let i=zc(e,t);if(n.user.trackedExperiments.has(i))return[];n.user.trackedExperiments.add(i)}n.user.enableDevMode&&n.user.devLogs&&n.user.devLogs.push({experiment:e,result:t,timestamp:Date.now().toString(),logType:"experiment"});let r=[];if(n.global.trackingCallback){let i=n.global.trackingCallback;r.push(ds(()=>i(e,t,n.user)))}if(n.user.trackingCallback){let i=n.user.trackingCallback;r.push(ds(()=>i(e,t)))}if(n.global.eventLogger){let i=n.global.eventLogger;r.push(ds(()=>i(kA,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},n.user)))}return r}function RA(n,e,t){if(n.user.trackedFeatureUsage){let r=JSON.stringify(t.value);if(n.user.trackedFeatureUsage[e]===r)return;n.user.trackedFeatureUsage[e]=r,n.user.enableDevMode&&n.user.devLogs&&n.user.devLogs.push({featureKey:e,result:t,timestamp:Date.now().toString(),logType:"feature"})}if(n.global.onFeatureUsage){let r=n.global.onFeatureUsage;ds(()=>r(e,t,n.user))}if(n.user.onFeatureUsage){let r=n.user.onFeatureUsage;ds(()=>r(e,t))}if(n.global.eventLogger){let r=n.global.eventLogger;ds(()=>r(CA,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},n.user))}}function jc(n,e){if(e.stack.evaluatedFeatures.has(n))return ir(e,n,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(n),e.stack.id=n;let t=AA(e);if(t.has(n))return ir(e,n,t.get(n),"override");if(!e.global.features||!e.global.features[n])return ir(e,n,null,"unknownFeature");let r=e.global.features[n];if(r.rules){let i=new Set(e.stack.evaluatedFeatures);e:for(let s of r.rules){if(s.parentConditions)for(let l of s.parentConditions){e.stack.evaluatedFeatures=new Set(i);let c=jc(l.id,e);if(c.source==="cyclicPrerequisite")return ir(e,n,null,"cyclicPrerequisite");let u={value:c.value};if(!rr(u,l.condition||{})){if(l.gate)return ir(e,n,null,"prerequisite");continue e}}if(s.filters&&ib(s.filters,e))continue;if("force"in s){if(s.condition&&!rb(s.condition,e)||!IA(e,s.seed||n,s.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing?s.fallbackAttribute:void 0,s.range,s.coverage,s.hashVersion))continue;return s.tracks&&s.tracks.forEach(l=>{!tb(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),ir(e,n,s.force,"force",s.id)}if(!s.variations)continue;let o={variations:s.variations,key:s.key||n};"coverage"in s&&(o.coverage=s.coverage),s.weights&&(o.weights=s.weights),s.hashAttribute&&(o.hashAttribute=s.hashAttribute),s.fallbackAttribute&&(o.fallbackAttribute=s.fallbackAttribute),s.disableStickyBucketing&&(o.disableStickyBucketing=s.disableStickyBucketing),s.bucketVersion!==void 0&&(o.bucketVersion=s.bucketVersion),s.minBucketVersion!==void 0&&(o.minBucketVersion=s.minBucketVersion),s.namespace&&(o.namespace=s.namespace),s.meta&&(o.meta=s.meta),s.ranges&&(o.ranges=s.ranges),s.name&&(o.name=s.name),s.phase&&(o.phase=s.phase),s.seed&&(o.seed=s.seed),s.hashVersion&&(o.hashVersion=s.hashVersion),s.filters&&(o.filters=s.filters),s.condition&&(o.condition=s.condition);let{result:a}=Wc(o,n,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return ir(e,n,a.value,"experiment",s.id,o,a)}}return ir(e,n,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function Wc(n,e,t){let r=n.key,i=n.variations.length;if(i<2)return{result:ke(t,n,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:ke(t,n,-1,!1,e)};if(n=$A(n,t),n.urlPatterns&&!Ic(t.user.url||"",n.urlPatterns))return{result:ke(t,n,-1,!1,e)};let s=I_(r,t.user.url||"",i);if(s!==null)return{result:ke(t,n,s,!1,e)};let o=TA(t);if(r in o){let m=o[r];return{result:ke(t,n,m,!1,e)}}if(n.status==="draft"||n.active===!1)return{result:ke(t,n,-1,!1,e)};let{hashAttribute:a,hashValue:l}=ti(t,n.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0);if(!l)return{result:ke(t,n,-1,!1,e)};let c=-1,u=!1,p=!1;if(t.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing){let{variation:m,versionIsBlocked:y}=MA({ctx:t,expKey:n.key,expBucketVersion:n.bucketVersion,expHashAttribute:n.hashAttribute,expFallbackAttribute:n.fallbackAttribute,expMinBucketVersion:n.minBucketVersion,expMeta:n.meta});u=m>=0,c=m,p=!!y}if(!u){if(n.filters){if(ib(n.filters,t))return{result:ke(t,n,-1,!1,e)}}else if(n.namespace&&!A_(l,n.namespace))return{result:ke(t,n,-1,!1,e)};if(n.include&&!$_(n.include))return{result:ke(t,n,-1,!1,e)};if(n.condition&&!rb(n.condition,t))return{result:ke(t,n,-1,!1,e)};if(n.parentConditions){let m=new Set(t.stack.evaluatedFeatures);for(let y of n.parentConditions){t.stack.evaluatedFeatures=new Set(m);let w=jc(y.id,t);if(w.source==="cyclicPrerequisite")return{result:ke(t,n,-1,!1,e)};let x={value:w.value};if(!rr(x,y.condition||{}))return{result:ke(t,n,-1,!1,e)}}}if(n.groups&&!OA(n.groups,t))return{result:ke(t,n,-1,!1,e)}}if(n.url&&!PA(n.url,t))return{result:ke(t,n,-1,!1,e)};let f=Uo(n.seed||r,l,n.hashVersion||1);if(f===null)return{result:ke(t,n,-1,!1,e)};if(!u){let m=n.ranges||R_(i,n.coverage===void 0?1:n.coverage,n.weights);c=T_(f,m)}if(p)return{result:ke(t,n,-1,!1,e,void 0,!0)};if(c<0)return{result:ke(t,n,-1,!1,e)};if("force"in n)return{result:ke(t,n,n.force===void 0?-1:n.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:ke(t,n,-1,!1,e)};if(n.status==="stopped")return{result:ke(t,n,-1,!1,e)};let h=ke(t,n,c,!0,e,f,u);if(t.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing){let{changed:m,key:y,doc:w}=NA(t,a,jo(l),{[Bf(n.key,n.bucketVersion)]:h.key});m&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[y]=w,t.user.saveStickyBucketAssignmentDoc(w))}let g=tb(t,n,h);g.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:n,result:h});let v=g.length?g.length===1?g[0]:Promise.all(g).then(()=>{}):void 0;return"changeId"in n&&n.changeId&&t.global.recordChangeId&&t.global.recordChangeId(n.changeId),{result:h,trackingCall:v}}function ir(n,e,t,r,i,s,o){let a={value:t,on:!!t,off:!t,source:r,ruleId:i||""};return s&&(a.experiment=s),o&&(a.experimentResult=o),r!=="override"&&RA(n,e,a),a}function nb(n){return{...n.user.attributes,...n.user.attributeOverrides}}function rb(n,e){return rr(nb(e),n,e.global.savedGroups||{})}function ib(n,e){return n.some(t=>{let{hashValue:r}=ti(e,t.attribute);if(!r)return!0;let i=Uo(t.seed,r,t.hashVersion||2);return i===null?!0:!t.ranges.some(s=>Rc(i,s))})}function IA(n,e,t,r,i,s,o){if(!i&&s===void 0)return!0;if(!i&&s===0)return!1;let{hashValue:a}=ti(n,t,r);if(!a)return!1;let l=Uo(e,a,o||1);return l===null?!1:i?Rc(l,i):s!==void 0?l<=s:!0}function ke(n,e,t,r,i,s,o){let a=!0;(t<0||t>=e.variations.length)&&(t=0,a=!1);let{hashAttribute:l,hashValue:c}=ti(n,e.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),u=e.meta?e.meta[t]:{},p={key:u.key||""+t,featureId:i,inExperiment:a,hashUsed:r,variationId:t,value:e.variations[t],hashAttribute:l,hashValue:c,stickyBucketUsed:!!o};return u.name&&(p.name=u.name),s!==void 0&&(p.bucket=s),u.passthrough&&(p.passthrough=u.passthrough),p}function $A(n,e){let t=n.key,r=e.global.overrides;return r&&r[t]&&(n=Object.assign({},n,r[t]),typeof n.url=="string"&&(n.url=Tf(n.url))),n}function ti(n,e,t){let r=e||"id",i="",s=nb(n);return s[r]&&(i=s[r]),!i&&t&&(s[t]&&(i=s[t]),i&&(r=t)),{hashAttribute:r,hashValue:i}}function PA(n,e){let t=e.user.url;if(!t)return!1;let r=t.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(n.test(t)||n.test(r))}function OA(n,e){let t=e.global.groups||{};for(let r=0;r<n.length;r++)if(t[n[r]])return!0;return!1}function MA({ctx:n,expKey:e,expBucketVersion:t,expHashAttribute:r,expFallbackAttribute:i,expMinBucketVersion:s,expMeta:o}){t=t||0,s=s||0,r=r||"id",o=o||[];let a=Bf(e,t),l=LA(n,r,i);if(s>0)for(let p=0;p<s;p++){let f=Bf(e,p);if(l[f]!==void 0)return{variation:-1,versionIsBlocked:!0}}let c=l[a];if(c===void 0)return{variation:-1};let u=o.findIndex(p=>p.key===c);return u<0?{variation:-1}:{variation:u}}function Bf(n,e){return e=e||0,`${n}__${e}`}function Vf(n,e){return`${n}||${e}`}function LA(n,e,t){if(!n.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:r,hashValue:i}=ti(n,e),s=Vf(r,jo(i)),{hashAttribute:o,hashValue:a}=ti(n,t),l=a?Vf(o,jo(a)):null,c={};return l&&n.user.stickyBucketAssignmentDocs[l]&&Object.assign(c,n.user.stickyBucketAssignmentDocs[l].assignments||{}),n.user.stickyBucketAssignmentDocs[s]&&Object.assign(c,n.user.stickyBucketAssignmentDocs[s].assignments||{}),c}function NA(n,e,t,r){let i=Vf(e,t),s=n.user.stickyBucketAssignmentDocs&&n.user.stickyBucketAssignmentDocs[i]?n.user.stickyBucketAssignmentDocs[i].assignments||{}:{},o={...s,...r},a=JSON.stringify(s)!==JSON.stringify(o);return{key:i,doc:{attributeName:e,attributeValue:t,assignments:o},changed:a}}function FA(n,e){let t=new Set,r=e&&e.features?e.features:n.global.features||{},i=e&&e.experiments?e.experiments:n.global.experiments||[];return Object.keys(r).forEach(s=>{let o=r[s];if(o.rules)for(let a of o.rules)a.variations&&(t.add(a.hashAttribute||"id"),a.fallbackAttribute&&t.add(a.fallbackAttribute))}),i.map(s=>{t.add(s.hashAttribute||"id"),s.fallbackAttribute&&t.add(s.fallbackAttribute)}),Array.from(t)}async function sb(n,e,t){let r=Uf(n,t);return e.getAllAssignments(r)}function Uf(n,e){let t={};return FA(n,e).forEach(i=>{let{hashValue:s}=ti(n,i);t[i]=jo(s)}),t}async function ob(n,e,t){if(n={...n},n.encryptedFeatures){try{n.features=JSON.parse(await ei(n.encryptedFeatures,e,t))}catch(r){console.error(r)}delete n.encryptedFeatures}if(n.encryptedExperiments){try{n.experiments=JSON.parse(await ei(n.encryptedExperiments,e,t))}catch(r){console.error(r)}delete n.encryptedExperiments}if(n.encryptedSavedGroups){try{n.savedGroups=JSON.parse(await ei(n.encryptedSavedGroups,e,t))}catch(r){console.error(r)}delete n.encryptedSavedGroups}return n}function ab(n){let e=n.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(n.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:n.apiHostRequestHeaders,streamingHostRequestHeaders:n.streamingHostRequestHeaders}}function zc(n,e){return e.hashAttribute+e.hashValue+n.key+e.variationId}var ps=typeof window<"u"&&typeof document<"u",DA=P_(),Zo=class{constructor(e){if(e=e||{},this.version=DA,this._options=this.context=e,this._renderer=e.renderer||null,this._trackedExperiments=new Set,this._completedChangeIds=new Set,this._trackedFeatures={},this.debug=!!e.debug,this._subscriptions=new Set,this.ready=!1,this._assigned=new Map,this._activeAutoExperiments=new Map,this._triggeredExpKeys=new Set,this._initialized=!1,this._redirectedUrl="",this._deferredTrackingCalls=new Map,this._autoExperimentsAllowed=!e.disableExperimentsOnLoad,this._destroyCallbacks=[],this.logs=[],this.log=this.log.bind(this),this._saveDeferredTrack=this._saveDeferredTrack.bind(this),this._onExperimentEval=this._onExperimentEval.bind(this),this._fireSubscriptions=this._fireSubscriptions.bind(this),this._recordChangedId=this._recordChangedId.bind(this),e.remoteEval){if(e.decryptionKey)throw new Error("Encryption is not available for remoteEval");if(!e.clientKey)throw new Error("Missing clientKey");let t=!1;try{t=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(t)throw new Error("Cannot use remoteEval on GrowthBook Cloud")}else if(e.cacheKeyAttributes)throw new Error("cacheKeyAttributes are only used for remoteEval");if(e.stickyBucketService){let t=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=r=>t.saveAssignments(r)}if(e.plugins)for(let t of e.plugins)t(this);if(e.features&&(this.ready=!0),ps&&e.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event("gbloaded"))),e.experiments&&(this.ready=!0,this._updateAllAutoExperiments()),this._options.stickyBucketService&&this._options.stickyBucketAssignmentDocs)for(let t in this._options.stickyBucketAssignmentDocs){let r=this._options.stickyBucketAssignmentDocs[t];r&&this._options.stickyBucketService.saveAssignments(r).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let t=await ob(e,this._options.decryptionKey);this._decryptedPayload=t,await this.refreshStickyBuckets(t),t.features&&(this._options.features=t.features),t.savedGroups&&(this._options.savedGroups=t.savedGroups),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let t=e.payload;if(t.encryptedExperiments||t.encryptedFeatures)throw new Error("initSync does not support encrypted payloads");return this._options.stickyBucketService&&!this._options.stickyBucketAssignmentDocs&&(this._options.stickyBucketAssignmentDocs=this.generateStickyBucketAssignmentDocsSync(this._options.stickyBucketService,t)),this._payload=t,this._decryptedPayload=t,t.features&&(this._options.features=t.features),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,Mc(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&N_(e.cacheSettings),e.payload)return await this.setPayload(e.payload),Mc(this,e),{success:!0,source:"init"};{let{data:t,...r}=await this._refresh({...e,allowStale:!0});return Mc(this,e),await this.setPayload(t||{}),r}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let t=await this._refresh({...e||{},allowStale:!1});t.data&&await this.setPayload(t.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return ab(this._options)}getClientKey(){return this._options.clientKey||""}getPayload(){return this._payload||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this._decryptedPayload||this.getPayload()}isRemoteEval(){return this._options.remoteEval||!1}getCacheKeyAttributes(){return this._options.cacheKeyAttributes}async _refresh({timeout:e,skipCache:t,allowStale:r,streaming:i}){if(!this._options.clientKey)throw new Error("Missing clientKey");return F_({instance:this,timeout:e,skipCache:t||this._options.disableCache,allowStale:r,backgroundSync:i??this._options.backgroundSync??!0})}_render(){if(this._renderer)try{this._renderer()}catch(e){console.error("Failed to render",e)}}setFeatures(e){this._options.features=e,this.ready=!0,this._render()}async setEncryptedFeatures(e,t,r){let i=await ei(e,t||this._options.decryptionKey,r);this.setFeatures(JSON.parse(i))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,t,r){let i=await ei(e,t||this._options.decryptionKey,r);this.setExperiments(JSON.parse(i))}async setAttributes(e){if(this._options.attributes=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async updateAttributes(e){return this.setAttributes({...this._options.attributes,...e})}async setAttributeOverrides(e){if(this._options.attributeOverrides=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async setForcedVariations(e){if(this._options.forcedVariations=e||{},this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}setForcedFeatures(e){this._options.forcedFeatureValues=e,this._render()}async setURL(e){if(e!==this._options.url){if(this._options.url=e,this._redirectedUrl="",this._options.remoteEval){await this._refreshForRemoteEval(),this._updateAllAutoExperiments(!0);return}this._updateAllAutoExperiments(!0)}}getAttributes(){return{...this._options.attributes,...this._options.attributeOverrides}}getForcedVariations(){return this._options.forcedVariations||{}}getForcedFeatures(){return this._options.forcedFeatureValues||new Map}getStickyBucketAssignmentDocs(){return this._options.stickyBucketAssignmentDocs||{}}getUrl(){return this._options.url||""}getFeatures(){return this._options.features||{}}getExperiments(){return this._options.experiments||[]}getCompletedChangeIds(){return Array.from(this._completedChangeIds)}subscribe(e){return this._subscriptions.add(e),()=>{this._subscriptions.delete(e)}}async _refreshForRemoteEval(){if(!this._options.remoteEval||!this._initialized)return;let e=await this._refresh({allowStale:!1});e.data&&await this.setPayload(e.data)}getAllResults(){return new Map(this._assigned)}onDestroy(e){this._destroyCallbacks.push(e)}isDestroyed(){return!!this._destroyed}destroy(e){e=e||{},this._destroyed=!0,this._destroyCallbacks.forEach(t=>{try{t()}catch(r){console.error(r)}}),this._subscriptions.clear(),this._assigned.clear(),this._trackedExperiments.clear(),this._completedChangeIds.clear(),this._deferredTrackingCalls.clear(),this._trackedFeatures={},this._destroyCallbacks=[],this._payload=void 0,this._saveStickyBucketAssignmentDoc=void 0,D_(this),e.destroyAllStreams&&Mf(),this.logs=[],ps&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(t=>{t.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,t){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=t,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:t}=Wc(e,null,this._getEvalContext());return this._onExperimentEval(e,t),t}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(r=>r.key===e).map(r=>this._runAutoExperiment(r)).filter(r=>r!==null):null}triggerAutoExperiments(){this._autoExperimentsAllowed=!0,this._updateAllAutoExperiments(!0)}_getEvalContext(){return{user:this._getUserContext(),global:this._getGlobalContext(),stack:{evaluatedFeatures:new Set}}}_getUserContext(){return{attributes:this._options.user?{...this._options.user,...this._options.attributes}:this._options.attributes,enableDevMode:this._options.enableDevMode,blockedChangeIds:this._options.blockedChangeIds,stickyBucketAssignmentDocs:this._options.stickyBucketAssignmentDocs,url:this._getContextUrl(),forcedVariations:this._options.forcedVariations,forcedFeatureValues:this._options.forcedFeatureValues,attributeOverrides:this._options.attributeOverrides,saveStickyBucketAssignmentDoc:this._saveStickyBucketAssignmentDoc,trackingCallback:this._options.trackingCallback,onFeatureUsage:this._options.onFeatureUsage,devLogs:this.logs,trackedExperiments:this._trackedExperiments,trackedFeatureUsage:this._trackedFeatures}}_getGlobalContext(){return{features:this._options.features,experiments:this._options.experiments,log:this.log,enabled:this._options.enabled,qaMode:this._options.qaMode,savedGroups:this._options.savedGroups,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,t){let r=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!r)return null;let i=this._isAutoExperimentBlockedByContext(e),s,o;i?s=ke(this._getEvalContext(),e,-1,!1,""):({result:s,trackingCall:o}=Wc(e,null,this._getEvalContext()),this._onExperimentEval(e,s));let a=JSON.stringify(s.value);if(!t&&s.inExperiment&&r&&r.valueHash===a)return s;if(r&&this._undoActiveAutoExperiment(e),s.inExperiment){let l=$c(e);if(l==="redirect"&&s.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?O_(this._getContextUrl(),s.value.urlRedirect):s.value.urlRedirect;if(Ic(c,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),s;this._redirectedUrl=c;let{navigate:u,delay:p}=this._getNavigateFunction();if(u)if(ps)Promise.all([...o?[Pc(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(f=>window.setTimeout(f,this._options.navigateDelay??p))]).then(()=>{try{u(c)}catch(f){console.error(f)}});else try{u(c)}catch(f){console.error(f)}}else if(l==="visual"){let c=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(s.value):this._applyDOMChanges(s.value);c&&this._activeAutoExperiments.set(e,{undo:c,valueHash:a})}}return s}_undoActiveAutoExperiment(e){let t=this._activeAutoExperiments.get(e);t&&(t.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let t=this._options.experiments||[],r=new Set(t);this._activeAutoExperiments.forEach((i,s)=>{r.has(s)||(i.undo(),this._activeAutoExperiments.delete(s))});for(let i of t){let s=this._runAutoExperiment(i,e);if(s&&s.inExperiment&&$c(i)==="redirect")break}}_onExperimentEval(e,t){let r=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:t}),this._subscriptions.size>0&&this._fireSubscriptions(e,t,r)}_fireSubscriptions(e,t,r){(!r||r.result.inExperiment!==t.inExperiment||r.result.variationId!==t.variationId)&&this._subscriptions.forEach(i=>{try{i(e,t)}catch(s){console.error(s)}})}_recordChangedId(e){this._completedChangeIds.add(e)}isOn(e){return this.evalFeature(e).on}isOff(e){return this.evalFeature(e).off}getFeatureValue(e,t){let r=this.evalFeature(e).value;return r===null?t:r}feature(e){return this.evalFeature(e)}evalFeature(e){return jc(e,this._getEvalContext())}log(e,t){this.debug&&(this._options.log?this._options.log(e,t):console.log(e,t))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(t=>t&&t.experiment&&t.result).map(t=>[zc(t.experiment,t.result),t]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(t=>{!t||!t.experiment||!t.result?console.error("Invalid deferred tracking call",{call:t}):e.push(this._options.trackingCallback(t.experiment,t.result))}),this._deferredTrackingCalls.clear(),await Promise.all(e)}setTrackingCallback(e){this._options.trackingCallback=e,this.fireDeferredTrackingCalls()}setEventLogger(e){this._options.eventLogger=e}async logEvent(e,t){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:t,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,t||{},this._getUserContext())}catch(r){console.error(r)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(zc(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(ps?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=$c(e);if(t==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(r=>r.js))return!0}else if(t==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let r=new URL(this._getContextUrl());for(let i of e.variations){if(!i||!i.urlRedirect)continue;let s=new URL(i.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(s.protocol!==r.protocol||s.host!==r.host))return!0}}catch(r){return this.log("Error parsing current or redirect URL",{id:e.key,error:r}),!0}}else return!0;return!!(e.changeId&&(this._options.blockedChangeIds||[]).includes(e.changeId))}getRedirectUrl(){return this._redirectedUrl}_getNavigateFunction(){return this._options.navigate?{navigate:this._options.navigate,delay:0}:ps?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!ps)return;let t=[];if(e.css){let r=document.createElement("style");r.innerHTML=e.css,document.head.appendChild(r),t.push(()=>r.remove())}if(e.js){let r=document.createElement("script");r.innerHTML=e.js,this._options.jsInjectionNonce&&(r.nonce=this._options.jsInjectionNonce),document.head.appendChild(r),t.push(()=>r.remove())}return e.domMutations&&e.domMutations.forEach(r=>{t.push(Y_.declarative(r).revert)}),()=>{t.forEach(r=>r())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),r=await sb(t,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=r}}generateStickyBucketAssignmentDocsSync(e,t){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let r=this._getEvalContext(),i=Uf(r,t);return e.getAllAssignmentsSync(i)}inDevMode(){return!!this._options.enableDevMode}};var HA="https://experiment.syntrologie.com",jf=class{constructor(e={}){this.featureListeners=new Set;this.lastFeatureSnapshot=null;if(e.client)this.gb=e.client;else{let t=e.onExperimentViewed?(r,i)=>{e.onExperimentViewed(r.key,i.variationId,typeof i.value=="string"?i.value:`variation_${i.variationId}`)}:void 0;this.gb=new Zo({...e,apiHost:e.apiHost??HA,enableDevMode:e.enableDevMode??!0,trackingCallback:t}),e.autoInit&&this.gb.init({streaming:!0})}}get _internal(){return this.gb}async refreshFeatures(){await this.gb.loadFeatures()}setAttributes(e){this.gb.setAttributes({...this.gb.getAttributes(),...e})}setForcedVariations(e){this.gb.setForcedVariations(e)}getFeatureValue(e,t){return this.gb.getFeatureValue(e,t)}getAllFeatures(){let e=this.gb.getFeatures(),t={};for(let r of Object.keys(e))t[r]=this.gb.getFeatureValue(r,null);return t}shouldRenderRectangle(e){return!0}onFeaturesChanged(e){return this.featureListeners.add(e),this.featureListeners.size===1&&this.gb.setRenderer(()=>{let t=this.snapshotFeatures();if(t!==this.lastFeatureSnapshot){this.lastFeatureSnapshot=t;for(let r of this.featureListeners)r()}}),()=>{this.featureListeners.delete(e),this.featureListeners.size===0&&(this.gb.setRenderer(null),this.lastFeatureSnapshot=null)}}snapshotFeatures(){let e=this.getAllFeatures(),t=Object.keys(e).sort(),r={};for(let i of t)r[i]=e[i];return JSON.stringify(r)}};function qc(n={}){return new jf(n)}var lb={growthbook:n=>qc({...n,autoInit:!0})};function cb(n,e){let t=lb[n];if(!t)throw new Error(`Unknown experiment provider: ${n}. Supported: ${Object.keys(lb).join(", ")}`);return t(e)}var BA=["cdn.syntrologie.com","localhost","127.0.0.1"];function VA(n){try{let e=new URL(n),t=/^(localhost|127\.0\.0\.1)$/.test(e.hostname);return e.protocol!=="https:"&&!t?(console.warn("[SmartCanvas] CDN URL must use HTTPS:",n),!1):BA.some(i=>e.hostname===i)?!0:(console.warn("[SmartCanvas] CDN host not in allowlist:",e.hostname),!1)}catch{return console.warn("[SmartCanvas] Invalid CDN URL:",n),!1}}var Wf=class{constructor(e){this.name="cdn";if(this.url=`${e.baseUrl}/${e.configId}.json`,this.integrity=e.integrity,!VA(this.url))throw new Error(`[SmartCanvas] CDN URL not allowed: ${this.url}`)}async fetch(){let e=performance.now(),t=await fetch(this.url,{credentials:"omit",cache:"default"});if(!t.ok)throw new Error(`[SmartCanvas] Failed to fetch config from CDN (${t.status})`);let r=await t.text();if(this.integrity){let l=await UA(r),c=this.integrity.replace("sha384-","");if(l!==c)throw new Error(`[SmartCanvas] Config integrity check failed. Expected ${c}, got ${l}`)}let i=JSON.parse(r),s=performance.now()-e,o=t.headers.get("cache-control"),a=t.headers.get("age");return{config:i,meta:{source:"cdn",fetchTimeMs:s,cached:o?.includes("public")??!1,cacheAge:a?parseInt(a,10):void 0}}}};async function UA(n){let t=new TextEncoder().encode(n),r=await crypto.subtle.digest("SHA-384",t),i=new Uint8Array(r);return btoa(String.fromCharCode(...i))}function ub(n){return new Wf(n)}var jA="syntro_exp",WA="syntro_var",zf=class{constructor(e){this.name="experiments";this.client=e.client,this.featureKey=e.featureKey,this.manifestKey=e.manifestKey,this.variantFlagPrefix=e.variantFlagPrefix}async fetch(){let e=performance.now();if(typeof window<"u"){let i=new URLSearchParams(window.location.search),s=i.get(jA),o=i.get(WA);if(s&&o!==null&&this.client.setForcedVariations){let a=parseInt(o,10);Number.isNaN(a)||(console.log(`[SmartCanvas] Preview mode: forcing "${s}" to variation ${a}`),this.client.setForcedVariations({[s]:a}))}}if(this.manifestKey||this.variantFlagPrefix||this.client.getAllFeatures){let i=this.fetchMultiFlag();if(i){let s=performance.now()-e;return{config:i,meta:{source:"experiments",fetchTimeMs:s,cached:!0}}}}if(!this.featureKey)throw new Error("[SmartCanvas] No featureKey configured and no variant flags found. Ensure at least one config feature flag exists in your experiment platform.");let t=this.client.getFeatureValue?.(this.featureKey,null);if(!t||typeof t!="object")throw new Error(`[SmartCanvas] Feature "${this.featureKey}" not found or invalid. Ensure the feature is configured in your experiment platform.`);let r=performance.now()-e;return{config:t,meta:{source:"experiments",fetchTimeMs:r,cached:!0}}}fetchMultiFlag(){let e=this.getVariantFlagKeys();return!e||e.length===0?null:rc(this.client,e)}getVariantFlagKeys(){if(this.manifestKey){let e=this.client.getFeatureValue?.(this.manifestKey,null);if(e&&typeof e=="object"){let t=e.variant_flags;if(t&&t.length>0)return t}}if(this.client.getAllFeatures){let e=this.client.getAllFeatures();return this.variantFlagPrefix?Object.keys(e).filter(t=>t.startsWith(this.variantFlagPrefix)):Object.keys(e)}return[]}};function db(n){return new zf(n)}var zA="https://cdn.syntrologie.com/configs",pb={cdn:n=>{if(!n.configId)throw new Error("CDN fetcher requires 'configId' option");return ub({baseUrl:n.baseUrl??zA,configId:n.configId,integrity:n.integrity})},experiments:n=>{if(!n.featureKey)throw new Error("Experiments fetcher requires 'featureKey' option");return db({featureKey:n.featureKey})}};function fb(n,e={}){let t=pb[n];if(!t)throw new Error(`Unknown config fetcher type: ${n}. Supported: ${Object.keys(pb).join(", ")}`);return t(e)}var qA=[25,50,75,100];function hb(n){if(typeof window>"u"||typeof document>"u")return()=>{};let e=new Set,t=!1,r=()=>{t=!1;let o=document.documentElement,a=window.scrollY||o.scrollTop,l=Math.max(1,o.scrollHeight-window.innerHeight),c=Math.round(a/l*100);for(let u of qA)c>=u&&!e.has(u)&&(e.add(u),n.publish("nav.scroll_depth",{percent:u,path:window.location.pathname}))},i=()=>{t||(t=!0,requestAnimationFrame(r))};window.addEventListener("scroll",i,{passive:!0});let s=n.subscribe?.({names:["nav.page_view"]},()=>{e.clear()});return()=>{window.removeEventListener("scroll",i),s?.()}}var ZA=new Set(["adaptive-chat-anchor","adaptive-spill-anchor","drawer-anchor"]);function gb(n){if(typeof window>"u"||typeof document>"u"||typeof IntersectionObserver>"u")return()=>{};let e=new Map,t=new Map,r=c=>{let u=c.getAttribute("data-section");return typeof u!="string"||u.length===0||c.closest("[data-syntro-anchor]")||c.querySelector("[data-syntro-anchor]")||ZA.has(u)?null:u},i=new IntersectionObserver(c=>{for(let u of c){let p=t.get(u.target);if(!p)continue;let f=e.get(p);if(f?.kind!=="emitted")if(u.intersectionRatio>=.5){if(f?.kind==="timer")continue;let h=setTimeout(()=>{t.has(u.target)&&(e.set(p,{kind:"emitted"}),n.publish("nav.section_viewed",{section:p,path:window.location.pathname}))},500);e.set(p,{kind:"timer",timer:h})}else f?.kind==="timer"&&(clearTimeout(f.timer),e.delete(p))}},{threshold:[.5]}),s=c=>{let u=r(c);u&&(t.has(c)||(t.set(c,u),i.observe(c)))},o=()=>{for(let c of document.querySelectorAll("[data-section]"))s(c)};o();let a=new MutationObserver(()=>o());a.observe(document.body,{childList:!0,subtree:!0});let l=n.subscribe?.({names:["nav.page_view"]},()=>{for(let c of e.values())c.kind==="timer"&&clearTimeout(c.timer);e.clear()});return()=>{i.disconnect(),a.disconnect(),l?.();for(let c of e.values())c.kind==="timer"&&clearTimeout(c.timer);e.clear(),t.clear()}}var mb="syntro_session_metrics",Go=class{constructor(e={}){this.metrics=new Map;this.subscribers=new Set;this.experiments=e.experiments,this.attributePrefix=e.attributePrefix??"session_",this.onMetricChange=e.onMetricChange,this.loadFromStorage()}increment(e,t=1){let i=(this.metrics.get(e)??0)+t;return this.metrics.set(e,i),this.saveToStorage(),this.updateExperimentAttributes(e,i),this.onMetricChange?.(e,i),this.notifySubscribers(),i}set(e,t){this.metrics.set(e,t),this.saveToStorage(),this.updateExperimentAttributes(e,t),this.onMetricChange?.(e,t),this.notifySubscribers()}get(e){return this.metrics.get(e)??0}meetsThreshold(e,t){return this.get(e)>=t}getAll(){return Object.fromEntries(this.metrics)}reset(e){this.metrics.delete(e),this.saveToStorage(),this.updateExperimentAttributes(e,0),this.onMetricChange?.(e,0),this.notifySubscribers()}resetAll(){let e=Array.from(this.metrics.keys());this.metrics.clear(),this.saveToStorage();let t={};for(let r of e)t[`${this.attributePrefix}${r}`]=0,this.onMetricChange?.(r,0);this.experiments?.setAttributes?.(t),this.notifySubscribers()}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}destroy(){this.subscribers.clear()}setExperiments(e){this.experiments=e,this.syncAllToExperiments()}updateExperimentAttributes(e,t){if(!this.experiments?.setAttributes)return;let r=`${this.attributePrefix}${e}`;this.experiments.setAttributes({[r]:t})}syncAllToExperiments(){if(!this.experiments?.setAttributes)return;let e={};for(let[t,r]of this.metrics)e[`${this.attributePrefix}${t}`]=r;this.experiments.setAttributes(e)}notifySubscribers(){for(let e of this.subscribers)try{e()}catch{}}loadFromStorage(){if(!(typeof window>"u"||typeof sessionStorage>"u"))try{let e=sessionStorage.getItem(mb);if(e){let t=JSON.parse(e);for(let[r,i]of Object.entries(t))this.metrics.set(r,i.count)}}catch(e){console.warn("[SessionMetricTracker] Failed to load from sessionStorage:",e)}}saveToStorage(){if(!(typeof window>"u"||typeof sessionStorage>"u"))try{let e={};for(let[t,r]of this.metrics)e[t]={count:r,lastUpdated:Date.now()};sessionStorage.setItem(mb,JSON.stringify(e))}catch(e){console.warn("[SessionMetricTracker] Failed to save to sessionStorage:",e)}}};function Zc(n={}){return new Go(n)}var GA=/\/(?:products?|pdp\/dynamic)\/([a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?)/,KA=/^[a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?$/;function YA(n){let e=n.attr__href??n.href;return typeof e=="string"&&e.length>0?e:void 0}function JA(n){let e=n["attr__aria-label"];if(typeof e=="string"&&e.trim())return e.trim();let t=n.$el_text??n.text;if(typeof t=="string"&&t.trim())return t.trim()}function XA(n){let e=YA(n);if(!e)return null;let t=GA.exec(e);if(!t)return null;let r=t[1],i=e.slice(e.indexOf(t[0])).split(/[?#]/)[0],s=JA(n);return s?{productHandle:r,productUrl:i,productTitle:s}:{productHandle:r,productUrl:i}}function QA(n){let e=n["attr__data-product-handle"];if(typeof e!="string"||!KA.test(e))return null;let t={productHandle:e,productUrl:`/products/${e}`},r=n["attr__aria-label"];return typeof r=="string"&&r.trim()&&(t.productTitle=r.trim()),t}function qf(n){for(let e of n){let t=XA(e)??QA(e);if(t)return t}return null}var Ko=class{constructor(e){this.unsubUnload=null,this.unsubLoad=null,this.destroyed=!1,this.adapter=e}activate(){this.destroyed||(this.unsubUnload=this.adapter.onRegionWillUnload(e=>{this.hideContentInSection(e)}),this.unsubLoad=this.adapter.onRegionDidLoad(e=>{this.revealContentInSection(e)}))}destroy(){this.destroyed=!0,this.unsubUnload?.(),this.unsubLoad?.(),this.unsubUnload=null,this.unsubLoad=null}hideContentInSection(e){let t=this.sectionSelector(e),r=document.querySelectorAll(`${t} [data-syntro-action-id]`);for(let i of r)i.style.opacity="0",i.style.transition="none"}revealContentInSection(e){let t=this.sectionSelector(e);requestAnimationFrame(()=>{if(this.destroyed)return;let r=document.querySelectorAll(`${t} [data-syntro-action-id]`);for(let i of r)i.style.transition="opacity 120ms ease-in",i.style.opacity="1"})}sectionSelector(e){let t=typeof CSS<"u"?CSS.escape(e):e;return document.getElementById(`shopify-section-${e}`)?`#shopify-section-${t}`:`.shopify-section[id$="-${t}"]`}};var Yo=class{constructor(e){this.name="shopify",this.loadCallbacks=new Set,this.unloadCallbacks=new Set,this.abortController=null,this.antiFlicker=null,this.initTimeoutMs=e?.initTimeoutMs??3e3}detect(){return typeof window>"u"||typeof document>"u"?!1:!!("Shopify"in window&&window.Shopify!=null||document.querySelector('meta[name="shopify-checkout-api-token"]'))}async onInit(){this.resetInitSideEffects(),this.abortController=new AbortController;let{signal:e}=this.abortController;this.attachSectionListeners(e),this.antiFlicker=new Ko(this),this.antiFlicker.activate(),await this.waitForInitialSections(this.initTimeoutMs,e)}onRegionDidLoad(e){return this.loadCallbacks.add(e),()=>{this.loadCallbacks.delete(e)}}onRegionWillUnload(e){return this.unloadCallbacks.add(e),()=>{this.unloadCallbacks.delete(e)}}onRegionMutated(e){}getAnchorScope(e){let t=e.closest(".shopify-section");return t?.id?`#${typeof CSS<"u"?CSS.escape(t.id):t.id} `:""}extractProductIdentity(e){return qf(e)}destroy(){this.resetInitSideEffects(),this.loadCallbacks.clear(),this.unloadCallbacks.clear()}resetInitSideEffects(){this.antiFlicker?.destroy(),this.antiFlicker=null,this.abortController&&(this.abortController.abort(),this.abortController=null)}attachSectionListeners(e){document.addEventListener("shopify:section:load",t=>{let r=t.detail?.sectionId;if(r)for(let i of this.loadCallbacks)try{i(r)}catch{}},{signal:e}),document.addEventListener("shopify:section:unload",t=>{let r=t.detail?.sectionId;if(r)for(let i of this.unloadCallbacks)try{i(r)}catch{}},{signal:e})}waitForInitialSections(e,t){return new Promise(r=>{if(document.querySelector(".shopify-section")){r();return}let i=!1,s=()=>{i||(i=!0,r())};document.addEventListener("shopify:section:load",()=>s(),{once:!0,signal:t});let a=window.Shopify?.designMode===!0?e:0,l=setTimeout(s,a);t.addEventListener("abort",()=>{clearTimeout(l),s()},{once:!0})})}};var DF=720*60*60;var vb=[()=>new Yo];function yb(){for(let n of vb){let e=n();if(e.detect())return e}return null}var s1="syntro:score:v2:",fs="unknown";function bb(n,e){return`${s1}${n}:${e}`}function Gf(n,e){if(!e)return null;try{let t=sessionStorage.getItem(bb(n,e));if(!t)return null;let r=JSON.parse(t);return typeof r=="object"&&r!==null&&typeof r.v=="string"&&typeof r.exp=="number"?r:null}catch{return null}}function xn(n,e){return Gf(n,e)?.v??fs}function wb(n,e,t,r){try{let i={v:t,exp:Date.now()+r*1e3};sessionStorage.setItem(bb(n,e),JSON.stringify(i))}catch{}}var ni=new Map,Zf=new Map,xb=new Map;function Jo(n,e){return`${n}:${e}`}function Gc(n,e){let t=xb.get(Jo(n,e))??0;return Date.now()-t<5e3}function Kc(n,e){xb.set(Jo(n,e),Date.now())}async function Sb(n,e,t,r){let{model_id:i,signals:s,context_fp:o,...a}=e;try{let l=await fetch(`${n.backendUrl}/api/score`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"Content-Type":"application/json","X-Distinct-Id":r},body:JSON.stringify({posthog_sdk:n.posthogKey,session_id:t,user_id:r,model_id:i,output:a,signals:s,context_fp:o})});if(!l.ok)return xn(e.name,t);let u=(await l.json()).output??{};if(u.name!==e.name)return console.warn(`[syntro] score drift: asked for "${e.name}", got "${String(u.name)}"`),xn(e.name,t);let p=typeof u.value=="string"?u.value:fs;if(e.type==="enum"&&e.values&&!e.values.includes(p))return console.warn(`[syntro] score drift: "${p}" not in declared values for "${e.name}"`),xn(e.name,t);let f=typeof u.ttl_s=="number"?u.ttl_s:30;return wb(e.name,t,p,f),p}catch{return xn(e.name,t)}}async function _b(n,e,t,r){let{model_id:i,signals:s,context_fp:o}=e[0],a=new Map;try{let l=await fetch(`${n.backendUrl}/api/score`,{method:"POST",headers:{Authorization:`Bearer ${n.token}`,"Content-Type":"application/json","X-Distinct-Id":r},body:JSON.stringify({posthog_sdk:n.posthogKey,session_id:t,user_id:r,model_id:i,outputs:e.map(({model_id:p,signals:f,context_fp:h,...g})=>g),signals:s,context_fp:o})});if(!l.ok)return a;let c=await l.json(),u=new Map(e.map(p=>[p.name,p]));for(let p of c.outputs??[]){let f=typeof p.name=="string"?u.get(p.name):void 0;if(!f)continue;let h=typeof p.value=="string"?p.value:fs;if(f.type==="enum"&&f.values&&!f.values.includes(h)){console.warn(`[syntro] score drift: "${h}" not in declared values for "${f.name}"`);continue}let g=typeof p.ttl_s=="number"?p.ttl_s:30;wb(f.name,t,h,g),a.set(f.name,h)}return a}catch{return a}}function Eb(n,e){let t=n.getSessionId(),r=n.getUserId();if(e.length===0)return Promise.resolve([]);if(!t||!r)return Promise.resolve(e.map(u=>xn(u.name,t)));let i=new Map,s=[],o=[];for(let u of e){let p=Gf(u.name,t);p&&p.v!==fs?(i.set(u.name,p.v),Date.now()>=p.exp&&s.push(u)):o.push(u)}let a=s.filter(u=>!ni.has(Jo(u.name,t))&&!Gc(u.name,t));if(a.length>0){for(let u of a)Kc(u.name,t);_b(n,a,t,r)}if(o.length===0)return Promise.resolve(e.map(u=>i.get(u.name)??fs));let l=`${o.map(u=>u.name).join("\0")}:${t}`,c=Zf.get(l);if(!c){let u=o.filter(p=>!Gc(p.name,t));if(u.length===0)return Promise.resolve(e.map(p=>i.get(p.name)??xn(p.name,t)));for(let p of u)Kc(p.name,t);c=_b(n,u,t,r).finally(()=>Zf.delete(l)),Zf.set(l,c)}return c.then(u=>e.map(p=>i.get(p.name)??u.get(p.name)??xn(p.name,t)))}function o1(n,e,t,r){let i=Jo(e.name,t);if(ni.has(i)||Gc(e.name,t))return;Kc(e.name,t);let s=Sb(n,e,t,r).finally(()=>ni.delete(i));ni.set(i,s)}function Cb(n,e){let t=n.getSessionId(),r=n.getUserId();if(!t||!r)return Promise.resolve(xn(e.name,t));let i=Gf(e.name,t);if(i&&i.v!==fs)return Date.now()<i.exp||o1(n,e,t,r),Promise.resolve(i.v);let s=Jo(e.name,t),o=ni.get(s);if(!o){if(Gc(e.name,t))return Promise.resolve(xn(e.name,t));Kc(e.name,t),o=Sb(n,e,t,r).finally(()=>ni.delete(s)),ni.set(s,o)}return o}function kb(n){return n==="granted"?"granted":n==="denied"?"denied":"pending"}function Kf(n){return n?Array.isArray(n)&&n[0]==="consent"?n[2]?.analytics_storage??null:typeof n=="object"&&n.event==="consent_update"?n.analytics_storage??null:null:null}var Xo=class{constructor(){this.name="gtm-consent-mode-v2"}detect(){if(typeof window>"u")return!1;let e=window.dataLayer;if(!Array.isArray(e))return!1;for(let t of e)if(Kf(t)!==null)return!0;return!1}initialize(e){if(typeof window>"u")return e("pending"),()=>{};Array.isArray(window.dataLayer)||(window.dataLayer=[]),e(this.readCurrentState());let t=window.dataLayer,r=t.push.bind(t),i=(...s)=>{let o=r(...s);for(let a of s){let l=Kf(a);l!==null&&e(kb(l))}return o};return t.push=i,()=>{t.push===i&&(t.push=r)}}readCurrentState(){if(typeof window>"u")return"pending";let e=window.dataLayer;if(!Array.isArray(e))return"pending";for(let t=e.length-1;t>=0;t--){let r=Kf(e[t]);if(r!==null)return kb(r)}return"pending"}};var Qo=class{constructor(){this.name="iab-tcf-v2"}detect(){return typeof window>"u"?!1:typeof window.__tcfapi=="function"}initialize(e){if(e("pending"),typeof window>"u")return()=>{};let t=window.__tcfapi;if(typeof t!="function")return()=>{};let r;return t("addEventListener",2,(i,s)=>{if(!s||!i||(r===void 0&&typeof i.listenerId=="number"&&(r=i.listenerId),!(i.eventStatus==="tcloaded"||i.eventStatus==="useractioncomplete")))return;if(i.gdprApplies===!1){e("granted");return}let a=i.purpose?.consents??{},l=a[1]===!0,c=a[8]===!0;e(l&&c?"granted":"denied")}),()=>{if(r!==void 0)try{t("removeEventListener",2,()=>{},r)}catch{}}}};var Ab="visitorConsentCollected",ea=class{constructor(){this.name="shopify-customer-privacy"}detect(){return typeof window>"u"?!1:typeof window.Shopify?.loadFeatures=="function"}initialize(e){if(e("pending"),typeof window>"u")return()=>{};let t=window.Shopify;if(!t?.loadFeatures)return()=>{};let r;return t.loadFeatures([{name:"consent-tracking-api",version:"0.1"}],i=>{if(i)return;let s=t.customerPrivacy?.userCanBeTracked()??!0;e(s?"granted":"denied"),r=o=>{let a=o.detail;e(a?.analyticsAllowed?"granted":"denied")},document.addEventListener(Ab,r)}),()=>{r&&document.removeEventListener(Ab,r)}}};var ta=class{constructor(e){this.options=e}async start(e){for(let r of this.options.adapters){let i=!1;try{i=r.detect()}catch{continue}if(i)try{let s=r.initialize(o=>e.setStatus(o));return this.options.onAdapterSelected?.(r.name),s}catch(s){console.warn(`[Syntro consent] Adapter "${r.name}" failed:`,s)}}this.options.onAdapterSelected?.(null);let t=await this.resolveFallback();return e.setStatus(t),()=>{}}async resolveFallback(){if(!this.options.fallbackStatus)return"pending";try{return await this.options.fallbackStatus()}catch{return"pending"}}};var na=class{constructor(e={}){this.listeners=new Set;this.destroyed=!1;this.status=e.initialStatus??"pending",this.configCallback=e.onConsentChange,this.gtmEnabled=e.readFromGtmConsentMode??!1,this.pendingResolverFn=e.pendingResolver}grant(){this.setStatus("granted")}deny(){this.setStatus("denied")}getStatus(){return this.status}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}subscribeOnce(e){if(this.status!=="pending")return queueMicrotask(()=>e(this.status)),()=>{};let t=this.subscribe(r=>{r!=="pending"&&(t(),e(r))});return t}async resolvePending(){if(this.status!=="pending")return this.status;if(!this.pendingResolverFn)return"denied";try{return await this.pendingResolverFn()}catch{return"denied"}}setStatus(e){this.applyStatus(e)}pollGtmConsent(){if(!this.gtmEnabled||typeof window>"u")return;let e=window.dataLayer;if(Array.isArray(e))for(let t=e.length-1;t>=0;t--){let r=e[t];if(!r)continue;if(r[0]==="consent"&&r[1]==="update"&&r[2]){let s=r[2].analytics_storage;s==="granted"?this.setStatus("granted"):s==="denied"&&this.setStatus("denied");return}}}destroy(){this.destroyed=!0,this.listeners.clear()}applyStatus(e){this.destroyed||this.status!==e&&(this.status=e,this.notify(e))}notify(e){if(this.configCallback)try{this.configCallback(e)}catch{}for(let t of this.listeners)try{t(e)}catch{}}};var hs=class{constructor(e,t){this.seenSet=new Set;this.triggeredSet=new Set;this.servedVariants=new Set;this.telemetry=e,this.variantId=t}trackServed(e,t){this.trackServedForVariant(this.variantId,e,t)}trackServedForVariant(e,t,r){this.servedVariants.has(e)||(this.servedVariants.add(e),this.telemetry.track?.("syntro_config_served",{variant_id:e,tiles:t,actions:r}))}trackSeen(e,t){this.seenSet.has(e)||(this.seenSet.add(e),this.telemetry.track?.("syntro_intervention_seen",{variant_id:this.variantId,intervention_id:e,intervention_kind:t}))}trackTriggered(e,t){this.triggeredSet.has(e)||(this.triggeredSet.add(e),this.telemetry.track?.("syntro_intervention_triggered",{variant_id:this.variantId,intervention_id:e,intervention_kind:t}))}trackInteracted(e,t,r){this.telemetry.track?.("syntro_intervention_interacted",{variant_id:this.variantId,intervention_id:e,intervention_kind:t,interaction_type:r})}resetPage(){this.seenSet.clear(),this.triggeredSet.clear()}};function a1(){let n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="";for(let t=0;t<16;t++)e+=n[Math.floor(Math.random()*n.length)];return e}var Yf=class{constructor(){this.sessionId=a1(),console.log(`[Syntro Telemetry] Using noop adapter (no telemetry configured). sessionId=${this.sessionId}`)}trackCanvasOpened(e){}trackCanvasClosed(e){}trackRectangleViewed(e,t){}trackAction(e,t,r){}register(e){}getSessionId(){return this.sessionId}startSessionRecording(){}trackExperiment(e,t,r){}setPersonProperties(e){}setPersonPropertiesOnce(e){}getDistinctId(){return"demo-user"}getAllFeatureFlags(){return{}}getSegmentFlags(){return{}}track(e,t){}identify(e,t){}alias(e,t){}optInCapturing(){}optOutCapturing(){}};function Yc(){return new Yf}var S=typeof window<"u"?window:void 0,Ze=typeof globalThis<"u"?globalThis:S;typeof self>"u"&&(Ze.self=Ze),typeof File>"u"&&(Ze.File=function(){});var S0=Array.prototype,Tb=S0.forEach,Rb=S0.indexOf,ht=Ze?.navigator,D=Ze?.document,qe=Ze?.location,hh=Ze?.fetch,gh=Ze!=null&&Ze.XMLHttpRequest&&"withCredentials"in new Ze.XMLHttpRequest?Ze.XMLHttpRequest:void 0,Ib=Ze?.AbortController,ct=ht?.userAgent,ee=S??{},Cn={DEBUG:!1,LIB_VERSION:"1.341.0"};function $b(n,e,t,r,i,s,o){try{var a=n[s](o),l=a.value}catch(c){return void t(c)}a.done?e(l):Promise.resolve(l).then(r,i)}function _s(n){return function(){var e=this,t=arguments;return new Promise((function(r,i){var s=n.apply(e,t);function o(l){$b(s,r,i,o,a,"next",l)}function a(l){$b(s,r,i,o,a,"throw",l)}o(void 0)}))}}function W(){return W=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},W.apply(null,arguments)}function E0(n,e){if(n==null)return{};var t={};for(var r in n)if({}.hasOwnProperty.call(n,r)){if(e.indexOf(r)!==-1)continue;t[r]=n[r]}return t}var l1=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],Pb=function(n,e){if(e===void 0&&(e=[]),!n)return!1;var t=n.toLowerCase();return l1.concat(e).some((r=>{var i=r.toLowerCase();return t.indexOf(i)!==-1}))},c1=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function me(n,e){return n.indexOf(e)!==-1}var ku=function(n){return n.trim()},mh=function(n){return n.replace(/^\$/,"")},u1=Array.isArray,C0=Object.prototype,k0=C0.hasOwnProperty,Au=C0.toString,_e=u1||function(n){return Au.call(n)==="[object Array]"},ur=n=>typeof n=="function",Be=n=>n===Object(n)&&!_e(n),bs=n=>{if(Be(n)){for(var e in n)if(k0.call(n,e))return!1;return!0}return!1},H=n=>n===void 0,Ve=n=>Au.call(n)=="[object String]",vh=n=>Ve(n)&&n.trim().length===0,Mt=n=>n===null,ve=n=>H(n)||Mt(n),$n=n=>Au.call(n)=="[object Number]"&&n==n,vs=n=>$n(n)&&n>0,In=n=>Au.call(n)==="[object Boolean]",d1=n=>n instanceof FormData,p1=n=>me(c1,n);function yh(n){return n===null||typeof n!="object"}function iu(n,e){return Object.prototype.toString.call(n)==="[object "+e+"]"}function A0(n){return!H(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(n,Event)}var f1=[!0,"true",1,"1","yes"],Jf=n=>me(f1,n),h1=[!1,"false",0,"0","no"];function Jt(n,e,t,r,i){return e>t&&(r.warn("min cannot be greater than max."),e=t),$n(n)?n>t?(r.warn(" cannot be greater than max: "+t+". Using max value instead."),t):n<e?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):n:(r.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+i),Jt(i||t,e,t,r))}var _h=class{constructor(e){this.t={},this.i=e.i,this.o=Jt(e.bucketSize,0,100,e.h),this.m=Jt(e.refillRate,0,this.o,e.h),this.$=Jt(e.refillInterval,0,864e5,e.h)}S(e,t){var r=t-e.lastAccess,i=Math.floor(r/this.$);if(i>0){var s=i*this.m;e.tokens=Math.min(e.tokens+s,this.o),e.lastAccess=e.lastAccess+i*this.$}}consumeRateLimit(e){var t,r=Date.now(),i=String(e),s=this.t[i];return s?this.S(s,r):(s={tokens:this.o,lastAccess:r},this.t[i]=s),s.tokens===0||(s.tokens--,s.tokens===0&&((t=this.i)==null||t.call(this,e)),s.tokens===0)}stop(){this.t={}}},St="Mobile",su="iOS",Rn="Android",Sa="Tablet",T0=Rn+" "+Sa,R0="iPad",I0="Apple",$0=I0+" Watch",Ea="Safari",Es="BlackBerry",P0="Samsung",O0=P0+"Browser",M0=P0+" Internet",oi="Chrome",g1=oi+" OS",L0=oi+" "+su,Ag="Internet Explorer",N0=Ag+" "+St,Tg="Opera",m1=Tg+" Mini",Rg="Edge",F0="Microsoft "+Rg,xs="Firefox",D0=xs+" "+su,Ca="Nintendo",ka="PlayStation",Ss="Xbox",H0=Rn+" "+St,B0=St+" "+Ea,pa="Windows",bh=pa+" Phone",Ob="Nokia",wh="Ouya",V0="Generic",v1=V0+" "+St.toLowerCase(),U0=V0+" "+Sa.toLowerCase(),xh="Konqueror",nt="(\\d+(\\.\\d+)?)",Xf=new RegExp("Version/"+nt),y1=new RegExp(Ss,"i"),_1=new RegExp(ka+" \\w+","i"),b1=new RegExp(Ca+" \\w+","i"),Ig=new RegExp(Es+"|PlayBook|BB10","i"),w1={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},Jc,Mb,Qf,x1=(n,e)=>e&&me(e,I0)||(function(t){return me(t,Ea)&&!me(t,oi)&&!me(t,Rn)})(n),j0=function(n,e){return e=e||"",me(n," OPR/")&&me(n,"Mini")?m1:me(n," OPR/")?Tg:Ig.test(n)?Es:me(n,"IE"+St)||me(n,"WPDesktop")?N0:me(n,O0)?M0:me(n,Rg)||me(n,"Edg/")?F0:me(n,"FBIOS")?"Facebook "+St:me(n,"UCWEB")||me(n,"UCBrowser")?"UC Browser":me(n,"CriOS")?L0:me(n,"CrMo")||me(n,oi)?oi:me(n,Rn)&&me(n,Ea)?H0:me(n,"FxiOS")?D0:me(n.toLowerCase(),xh.toLowerCase())?xh:x1(n,e)?me(n,St)?B0:Ea:me(n,xs)?xs:me(n,"MSIE")||me(n,"Trident/")?Ag:me(n,"Gecko")?xs:""},S1={[N0]:[new RegExp("rv:"+nt)],[F0]:[new RegExp(Rg+"?\\/"+nt)],[oi]:[new RegExp("("+oi+"|CrMo)\\/"+nt)],[L0]:[new RegExp("CriOS\\/"+nt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+nt)],[Ea]:[Xf],[B0]:[Xf],[Tg]:[new RegExp("(Opera|OPR)\\/"+nt)],[xs]:[new RegExp(xs+"\\/"+nt)],[D0]:[new RegExp("FxiOS\\/"+nt)],[xh]:[new RegExp("Konqueror[:/]?"+nt,"i")],[Es]:[new RegExp(Es+" "+nt),Xf],[H0]:[new RegExp("android\\s"+nt,"i")],[M0]:[new RegExp(O0+"\\/"+nt)],[Ag]:[new RegExp("(rv:|MSIE )"+nt)],Mozilla:[new RegExp("rv:"+nt)]},E1=function(n,e){var t=j0(n,e),r=S1[t];if(H(r))return null;for(var i=0;i<r.length;i++){var s=r[i],o=n.match(s);if(o)return parseFloat(o[o.length-2])}return null},Lb=[[new RegExp(Ss+"; "+Ss+" (.*?)[);]","i"),n=>[Ss,n&&n[1]||""]],[new RegExp(Ca,"i"),[Ca,""]],[new RegExp(ka,"i"),[ka,""]],[Ig,[Es,""]],[new RegExp(pa,"i"),(n,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[bh,""];if(new RegExp(St).test(e)&&!/IEMobile\b/.test(e))return[pa+" "+St,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var r=t[1],i=w1[r]||"";return/arm/i.test(e)&&(i="RT"),[pa,i]}return[pa,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,n=>{if(n&&n[3]){var e=[n[3],n[4],n[5]||"0"];return[su,e.join(".")]}return[su,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,n=>{var e="";return n&&n.length>=3&&(e=H(n[2])?n[3]:n[2]),["watchOS",e]}],[new RegExp("("+Rn+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Rn+")","i"),n=>{if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[Rn,e.join(".")]}return[Rn,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,n=>{var e=["Mac OS X",""];if(n&&n[1]){var t=[n[1],n[2],n[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[g1,""]],[/Linux|debian/i,["Linux",""]]],Nb=function(n){return b1.test(n)?Ca:_1.test(n)?ka:y1.test(n)?Ss:new RegExp(wh,"i").test(n)?wh:new RegExp("("+bh+"|WPDesktop)","i").test(n)?bh:/iPad/.test(n)?R0:/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(n)?$0:Ig.test(n)?Es:/(kobo)\s(ereader|touch)/i.test(n)?"Kobo":new RegExp(Ob,"i").test(n)?Ob:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(n)||/(kf[a-z]+)( bui|\)).+silk\//i.test(n)?"Kindle Fire":/(Android|ZTE)/i.test(n)?new RegExp(St).test(n)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(n)||/pixel[\daxl ]{1,6}/i.test(n)&&!/pixel c/i.test(n)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(n)||/lmy47v/i.test(n)&&!/QTAQZ3/i.test(n)?Rn:T0:new RegExp("(pda|"+St+")","i").test(n)?v1:new RegExp(Sa,"i").test(n)&&!new RegExp(Sa+" pc","i").test(n)?U0:""},C1=n=>n instanceof Error;function k1(n){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return Qf&&t.length===Mb||(Mb=t.length,Qf=t.reduce(((r,i)=>{Jc||(Jc={});var s=Jc[i];if(s)r[s[0]]=s[1];else for(var o=n(i),a=o.length-1;a>=0;a--){var l=o[a],c=l?.filename,u=e[i];if(c&&u){r[c]=u,Jc[i]=[c,u];break}}return r}),{})),Qf}}var Sh=class{constructor(e,t,r){r===void 0&&(r=[]),this.coercers=e,this.stackParser=t,this.modifiers=r}buildFromUnknown(e,t){t===void 0&&(t={});var r=t&&t.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(r,t,0).apply(e),s=this.buildParsingContext(),o=this.parseStacktrace(i,s);return{$exception_list:this.convertToExceptionList(o,r),$exception_level:"error"}}modifyFrames(e){var t=this;return _s((function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&_e(r.stacktrace.frames)&&(r.stacktrace.frames=yield t.applyModifiers(r.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var r,i;return e.cause!=null&&(r=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(i=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),t.chunkIdMap)),W({},e,{cause:r,stack:i})}applyChunkIds(e,t){return e.map((r=>(r.filename&&t&&(r.chunk_id=t[r.filename]),r)))}applyCoercers(e,t){for(var r of this.coercers)if(r.match(e))return r.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return _s((function*(){var r=e;for(var i of t.modifiers)r=yield i(r);return r}))()}convertToExceptionList(e,t){var r,i,s,o={type:e.type,value:e.value,mechanism:{type:(r=t.type)!==null&&r!==void 0?r:"generic",handled:(i=t.handled)===null||i===void 0||i,synthetic:(s=e.synthetic)!==null&&s!==void 0&&s}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,W({},t,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:k1(this.stackParser)}}buildCoercingContext(e,t,r){r===void 0&&(r=0);var i=(s,o)=>{if(o<=4){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(s,a)}};return W({},t,{syntheticException:r==0?t.syntheticException:void 0,mechanism:e,apply:s=>i(s,r),next:s=>i(s,r+1)})}},Cs="?";function Eh(n,e,t,r,i){var s={platform:n,filename:e,function:t==="<anonymous>"?Cs:t,in_app:!0};return H(r)||(s.lineno=r),H(i)||(s.colno=i),s}var W0=(n,e)=>{var t=n.indexOf("safari-extension")!==-1,r=n.indexOf("safari-web-extension")!==-1;return t||r?[n.indexOf("@")!==-1?n.split("@")[0]:Cs,t?"safari-extension:"+e:"safari-web-extension:"+e]:[n,e]},A1=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,T1=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,R1=/\((\S*)(?::(\d+))(?::(\d+))\)/,I1=(n,e)=>{var t=A1.exec(n);if(t){var[,r,i,s]=t;return Eh(e,r,Cs,+i,+s)}var o=T1.exec(n);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=R1.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=W0(o[1]||Cs,o[2]);return Eh(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},$1=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,P1=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,O1=(n,e)=>{var t=$1.exec(n);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var r=P1.exec(t[3]);r&&(t[1]=t[1]||"eval",t[3]=r[1],t[4]=r[2],t[5]="")}var i=t[3],s=t[1]||Cs;return[s,i]=W0(s,i),Eh(e,i,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},Fb=/\(error: (.*)\)/,Db=50;function M1(){return(function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return function(i,s){s===void 0&&(s=0);for(var o=[],a=i.split(`
|
|
624
624
|
`),l=s;l<a.length;l++){var c=a[l];if(!(c.length>1024)){var u=Fb.test(c)?c.replace(Fb,"$1"):c;if(!u.match(/\S*Error: /)){for(var p of t){var f=p(u,n);if(f){o.push(f);break}}if(o.length>=Db)break}}}return(function(h){if(!h.length)return[];var g=Array.from(h);return g.reverse(),g.slice(0,Db).map((v=>{return W({},v,{filename:v.filename||(m=g,m[m.length-1]||{}).filename,function:v.function||Cs});var m}))})(o)}})("web:javascript",I1,O1)}var Ch=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var r=Ve(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:r?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return iu(e,"DOMException")}isDOMError(e){return iu(e,"DOMError")}},kh=class{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var r=e.message;return r.error&&typeof r.error.message=="string"?String(r.error.message):String(r)}getStack(e){return e.stacktrace||e.stack||void 0}},Ah=class{constructor(){}match(e){return iu(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var r,i=t.apply(e.error);return i||{type:"ErrorEvent",value:e.message,stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},L1=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Th=class{match(e){return typeof e=="string"}coerce(e,t){var r,[i,s]=this.getInfos(e);return{type:i??"Error",value:s??e,stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(e){var t="Error",r=e,i=e.match(L1);return i&&(t=i[1],r=i[2]),[t,r]}},N1=["fatal","error","warning","log","info","debug"];function z0(n,e){e===void 0&&(e=40);var t=Object.keys(n);if(t.sort(),!t.length)return"[object has no keys]";for(var r=t.length;r>0;r--){var i=t.slice(0,r).join(", ");if(!(i.length>e))return r===t.length||i.length<=e?i:i.slice(0,e)+"..."}return""}var Rh=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var r,i=this.getErrorPropertyFromObject(e);return i?t.apply(i):{type:this.getType(e),value:this.getValue(e),stack:(r=t.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return A0(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var r=this.getObjectClassName(e);return(r&&r!=="Object"?"'"+r+"'":"Object")+" captured as exception with keys: "+z0(e)}isSeverityLevel(e){return Ve(e)&&!vh(e)&&N1.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];if(C1(r))return r}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Ih=class{match(e){return A0(e)}coerce(e,t){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+z0(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},$h=class{match(e){return yh(e)}coerce(e,t){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},Ph=class{match(e){return iu(e,"PromiseRejectionEvent")}coerce(e,t){var r,i=this.getUnhandledRejectionReason(e);return yh(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}:t.apply(i)}getUnhandledRejectionReason(e){if(yh(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch{}return e}},q0=function(n,e){var{debugEnabled:t}=e===void 0?{}:e,r={k:function(i){if(S&&(Cn.DEBUG||ee.POSTHOG_DEBUG||t)&&!H(S.console)&&S.console){for(var s=("__rrweb_original__"in S.console[i])?S.console[i].__rrweb_original__:S.console[i],o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];s(n,...a)}},info:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("log",...s)},warn:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("warn",...s)},error:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];r.k("error",...s)},critical:function(){for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];console.error(n,...s)},uninitializedWarning:i=>{r.error("You must initialize PostHog before calling "+i)},createLogger:(i,s)=>q0(n+" "+i,s)};return r},V=q0("[PostHog.js]"),Pe=V.createLogger,F1=Pe("[ExternalScriptsLoader]"),Hb=(n,e,t)=>{if(n.config.disable_external_dependency_loading)return F1.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var r=D?.querySelectorAll("script");if(r){for(var i,s=function(){if(r[o].src===e){var l=r[o];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(c=>{l.__posthog_loading_callback_fired=!0,t(void 0,c)})),l.onerror=c=>t(c),{v:void 0})}},o=0;o<r.length;o++)if(i=s())return i.v}var a=()=>{if(!D)return t("document not found");var l=D.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=p=>{l.__posthog_loading_callback_fired=!0,t(void 0,p)},l.onerror=p=>t(p),n.config.prepare_external_dependency_script&&(l=n.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(n.config.external_scripts_inject_target==="head")D.head.appendChild(l);else{var c,u=D.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):D.body.appendChild(l)}};D!=null&&D.body?a():D?.addEventListener("DOMContentLoaded",a)};ee.__PosthogExtensions__=ee.__PosthogExtensions__||{},ee.__PosthogExtensions__.loadExternalDependency=(n,e,t)=>{var r="/static/"+e+".js?v="+n.version;if(e==="remote-config"&&(r="/array/"+n.config.token+"/config.js"),e==="toolbar"){var i=3e5;r=r+"&t="+Math.floor(Date.now()/i)*i}var s=n.requestRouter.endpointFor("assets",r);Hb(n,s,t)},ee.__PosthogExtensions__.loadSiteApp=(n,e,t)=>{var r=n.requestRouter.endpointFor("api",e);Hb(n,r,t)};var ou={};function dr(n,e,t){if(_e(n)){if(Tb&&n.forEach===Tb)n.forEach(e,t);else if("length"in n&&n.length===+n.length){for(var r=0,i=n.length;r<i;r++)if(r in n&&e.call(t,n[r],r)===ou)return}}}function xe(n,e,t){if(!ve(n)){if(_e(n))return dr(n,e,t);if(d1(n)){for(var r of n.entries())if(e.call(t,r[1],r[0])===ou)return}else for(var i in n)if(k0.call(n,i)&&e.call(t,n[i],i)===ou)return}}var Me=function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return dr(t,(function(i){for(var s in i)i[s]!==void 0&&(n[s]=i[s])})),n},As=function(n){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return dr(t,(function(i){dr(i,(function(s){n.push(s)}))})),n};function nu(n){for(var e=Object.keys(n),t=e.length,r=new Array(t);t--;)r[t]=[e[t],n[e[t]]];return r}var Bb=function(n){try{return n()}catch{return}},D1=function(n){return function(){try{for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.apply(this,t)}catch(i){V.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),V.critical(i)}}},$g=function(n){var e={};return xe(n,(function(t,r){(Ve(t)&&t.length>0||$n(t))&&(e[r]=t)})),e};function H1(n,e){return t=n,r=s=>Ve(s)&&!Mt(e)?s.slice(0,e):s,i=new Set,(function s(o,a){return o!==Object(o)?r?r(o,a):o:i.has(o)?void 0:(i.add(o),_e(o)?(l=[],dr(o,(c=>{l.push(s(c))}))):(l={},xe(o,((c,u)=>{i.has(c)||(l[u]=s(c,u))}))),l);var l})(t);var t,r,i}var B1=["herokuapp.com","vercel.app","netlify.app"];function V1(n){var e=n?.hostname;if(!Ve(e))return!1;var t=e.split(".").slice(-2).join(".");for(var r of B1)if(t===r)return!1;return!0}function Z0(n,e){for(var t=0;t<n.length;t++)if(e(n[t]))return n[t]}function Fe(n,e,t,r){var{capture:i=!1,passive:s=!0}=r??{};n?.addEventListener(e,t,{capture:i,passive:s})}var G0="$people_distinct_id",fa="__alias",ha="__timers",Vb="$autocapture_disabled_server_side",Oh="$heatmaps_enabled_server_side",Ub="$exception_capture_enabled_server_side",Mh="$error_tracking_suppression_rules",jb="$error_tracking_capture_extension_exceptions",Wb="$web_vitals_enabled_server_side",K0="$dead_clicks_enabled_server_side",zb="$product_tours_enabled_server_side",qb="$web_vitals_allowed_metrics",eh="$session_recording_remote_config",au="$sesid",Y0="$session_is_sampled",ws="$enabled_feature_flags",ga="$early_access_features",Lh="$feature_flag_details",ma="$stored_person_properties",si="$stored_group_properties",Nh="$surveys",lu="$flag_call_reported",kn="$user_state",Fh="$client_session_props",Dh="$capture_rate_limit",Hh="$initial_campaign_params",Bh="$initial_referrer_info",cu="$initial_person_info",uu="$epp",J0="__POSTHOG_TOOLBAR__",ra="$posthog_cookieless",U1=[G0,fa,"__cmpns",ha,"$session_recording_enabled_server_side",Oh,au,ws,Mh,kn,ga,Lh,si,ma,Nh,lu,Fh,Dh,Hh,Bh,uu,cu,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function Zb(n){return n instanceof Element&&(n.id===J0||!(n.closest==null||!n.closest(".toolbar-global-fade-container")))}function Tu(n){return!!n&&n.nodeType===1}function pr(n,e){return!!n&&!!n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function X0(n){return!!n&&n.nodeType===3}function Q0(n){return!!n&&n.nodeType===11}function Pg(n){return n?ku(n).split(/\s+/):[]}function Gb(n){var e=S?.location.href;return!!(e&&n&&n.some((t=>e.match(t))))}function du(n){var e="";switch(typeof n.className){case"string":e=n.className;break;case"object":e=(n.className&&"baseVal"in n.className?n.className.baseVal:null)||n.getAttribute("class")||"";break;default:e=""}return Pg(e)}function ew(n){return ve(n)?null:ku(n).split(/(\s+)/).filter((e=>Aa(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ra(n){var e="";return Vh(n)&&!sw(n)&&n.childNodes&&n.childNodes.length&&xe(n.childNodes,(function(t){var r;X0(t)&&t.textContent&&(e+=(r=ew(t.textContent))!==null&&r!==void 0?r:"")})),ku(e)}function tw(n){return H(n.target)?n.srcElement||null:(e=n.target)!=null&&e.shadowRoot?n.composedPath()[0]||null:n.target||null;var e}var Og=["a","button","form","input","select","textarea","label"];function nw(n,e){if(H(e))return!0;var t,r=function(s){if(e.some((o=>s.matches(o))))return{v:!0}};for(var i of n)if(t=r(i))return t.v;return!1}function rw(n){var e=n.parentNode;return!(!e||!Tu(e))&&e}var j1=["next","previous","prev",">","<"],Kb=10,Yb=[".ph-no-rageclick",".ph-no-capture"];function W1(n,e){if(!S||Mg(n))return!1;var t,r,i;if(In(e)?(t=!!e&&Yb,r=void 0):(t=(i=e?.css_selector_ignorelist)!==null&&i!==void 0?i:Yb,r=e?.content_ignorelist),t===!1)return!1;var{targetElementList:s}=iw(n,!1);return!(function(o,a){if(o===!1||H(o))return!1;var l;if(o===!0)l=j1;else{if(!_e(o))return!1;if(o.length>Kb)return V.error("[PostHog] content_ignorelist array cannot exceed "+Kb+" items. Use css_selector_ignorelist for more complex matching."),!1;l=o.map((c=>c.toLowerCase()))}return a.some((c=>{var{safeText:u,ariaLabel:p}=c;return l.some((f=>u.includes(f)||p.includes(f)))}))})(r,s.map((o=>{var a;return{safeText:Ra(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!nw(s,t)}var Mg=n=>!n||pr(n,"html")||!Tu(n),iw=(n,e)=>{if(!S||Mg(n))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,r=[n],i=n;i.parentNode&&!pr(i,"body");)if(Q0(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=rw(i);if(!s)break;if(e||Og.indexOf(s.tagName.toLowerCase())>-1)t=!0;else{var o=S.getComputedStyle(s);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}r.push(s),i=s}return{parentIsUsefulElement:t,targetElementList:r}};function z1(n,e,t,r,i){var s,o,a,l;if(t===void 0&&(t=void 0),!S||Mg(n)||(s=t)!=null&&s.url_allowlist&&!Gb(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&Gb(t.url_ignorelist))return!1;if((a=t)!=null&&a.dom_event_allowlist){var c=t.dom_event_allowlist;if(c&&!c.some((g=>e.type===g)))return!1}var{parentIsUsefulElement:u,targetElementList:p}=iw(n,r);if(!(function(g,v){var m=v?.element_allowlist;if(H(m))return!0;var y,w=function(_){if(m.some((k=>_.tagName.toLowerCase()===k)))return{v:!0}};for(var x of g)if(y=w(x))return y.v;return!1})(p,t)||!nw(p,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var f=S.getComputedStyle(n);if(f&&f.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var h=n.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(i||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(i||["change","click"]).indexOf(e.type)>=0;default:return u?(i||["click"]).indexOf(e.type)>=0:(i||["click"]).indexOf(e.type)>=0&&(Og.indexOf(h)>-1||n.getAttribute("contenteditable")==="true")}}function Vh(n){for(var e=n;e.parentNode&&!pr(e,"body");e=e.parentNode){var t=du(e);if(me(t,"ph-sensitive")||me(t,"ph-no-capture"))return!1}if(me(du(n),"ph-include"))return!0;var r=n.type||"";if(Ve(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=n.name||n.id||"";return!(Ve(i)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,"")))}function sw(n){return!!(pr(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||pr(n,"select")||pr(n,"textarea")||n.getAttribute("contenteditable")==="true")}var ow="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",q1=new RegExp("^(?:"+ow+")$"),Z1=new RegExp(ow),aw="\\d{3}-?\\d{2}-?\\d{4}",G1=new RegExp("^("+aw+")$"),K1=new RegExp("("+aw+")");function Aa(n,e){return e===void 0&&(e=!0),!(ve(n)||Ve(n)&&(n=ku(n),(e?q1:Z1).test((n||"").replace(/[- ]/g,""))||(e?G1:K1).test(n)))}function lw(n){var e=Ra(n);return Aa(e=(e+" "+cw(n)).trim())?e:""}function cw(n){var e="";return n&&n.childNodes&&n.childNodes.length&&xe(n.childNodes,(function(t){var r;if(t&&((r=t.tagName)==null?void 0:r.toLowerCase())==="span")try{var i=Ra(t);e=(e+" "+i).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+cw(t)).trim())}catch(s){V.error("[AutoCapture]",s)}})),e}function Y1(n){return(function(e){var t=e.map((r=>{var i,s,o="";if(r.tag_name&&(o+=r.tag_name),r.attr_class)for(var a of(r.attr_class.sort(),r.attr_class))o+="."+a.replace(/"/g,"");var l=W({},r.text?{text:r.text}:{},{"nth-child":(i=r.nth_child)!==null&&i!==void 0?i:0,"nth-of-type":(s=r.nth_of_type)!==null&&s!==void 0?s:0},r.href?{href:r.href}:{},r.attr_id?{attr_id:r.attr_id}:{},r.attributes),c={};return nu(l).sort(((u,p)=>{var[f]=u,[h]=p;return f.localeCompare(h)})).forEach((u=>{var[p,f]=u;return c[Jb(p.toString())]=Jb(f.toString())})),o+=":",o+=nu(c).map((u=>{var[p,f]=u;return p+'="'+f+'"'})).join("")}));return t.join(";")})((function(e){return e.map((t=>{var r,i,s={text:(r=t.$el_text)==null?void 0:r.slice(0,400),tag_name:t.tag_name,href:(i=t.attr__href)==null?void 0:i.slice(0,2048),attr_class:J1(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return nu(t).filter((o=>{var[a]=o;return a.indexOf("attr__")===0})).forEach((o=>{var[a,l]=o;return s.attributes[a]=l})),s}))})(n))}function Jb(n){return n.replace(/"|\\"/g,'\\"')}function J1(n){var e=n.attr__class;return e?_e(e)?e:Pg(e):void 0}var pu=class{constructor(e){this.disabled=e===!1;var t=Be(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,r){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(t-i.y)<this.thresholdPx&&r-i.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:r}];return!1}},fu=n=>{var e=D?.createElement("a");return H(e)?null:(e.href=n,e)},X1=function(n,e){var t,r;e===void 0&&(e="&");var i=[];return xe(n,(function(s,o){H(s)||H(o)||o==="undefined"||(t=encodeURIComponent((a=>a instanceof File)(s)?s.name:s.toString()),r=encodeURIComponent(o),i[i.length]=r+"="+t)})),i.join(e)},hu=function(n,e){for(var t,r=((n.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<r.length;i++){var s=r[i].split("=");if(s[0]===e){t=s;break}}if(!_e(t)||t.length<2)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{V.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Ia=function(n,e,t){if(!n||!e||!e.length)return n;for(var r=n.split("#"),i=r[0]||"",s=r[1],o=i.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],p=0;p<c.length;p++){var f=c[p].split("=");_e(f)&&(e.includes(f[0])?u.push(f[0]+"="+t):u.push(c[p]))}var h=l;return a!=null&&(h+="?"+u.join("&")),s!=null&&(h+="#"+s),h},gu=function(n,e){var t=n.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},th="$copy_autocapture",Xb=Pe("[AutoCapture]");function nh(n,e){return e.length>n?e.slice(0,n)+"...":e}function Q1(n){if(n.previousElementSibling)return n.previousElementSibling;var e=n;do e=e.previousSibling;while(e&&!Tu(e));return e}function eT(n,e,t,r){var i=n.tagName.toLowerCase(),s={tag_name:i};Og.indexOf(i)>-1&&!t&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=nh(1024,lw(n)):s.$el_text=nh(1024,Ra(n)));var o=du(n);o.length>0&&(s.classes=o.filter((function(u){return u!==""}))),xe(n.attributes,(function(u){var p;if((!sw(n)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!e&&Aa(u.value)&&(p=u.name,!Ve(p)||p.substring(0,10)!=="_ngcontent"&&p.substring(0,7)!=="_nghost")){var f=u.value;u.name==="class"&&(f=Pg(f).join(" ")),s["attr__"+u.name]=nh(1024,f)}}));for(var a=1,l=1,c=n;c=Q1(c);)a++,c.tagName===n.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function tT(n,e){for(var t,r,{e:i,maskAllElementAttributes:s,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[n],u=n;u.parentNode&&!pr(u,"body");)Q0(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var p,f=[],h={},g=!1,v=!1;if(xe(c,(_=>{var k=Vh(_);_.tagName.toLowerCase()==="a"&&(g=_.getAttribute("href"),g=k&&g&&Aa(g)&&g),me(du(_),"ph-no-capture")&&(v=!0),f.push(eT(_,s,o,a));var I=(function(b){if(!Vh(b))return{};var A={};return xe(b.attributes,(function(M){if(M.name&&M.name.indexOf("data-ph-capture-attribute")===0){var J=M.name.replace("data-ph-capture-attribute-",""),$=M.value;J&&$&&Aa($)&&(A[J]=$)}})),A})(_);Me(h,I)})),v)return{props:{},explicitNoCapture:v};if(o||(n.tagName.toLowerCase()==="a"||n.tagName.toLowerCase()==="button"?f[0].$el_text=lw(n):f[0].$el_text=Ra(n)),g){var m,y;f[0].attr__href=g;var w=(m=fu(g))==null?void 0:m.host,x=S==null||(y=S.location)==null?void 0:y.host;w&&x&&w!==x&&(p=g)}return{props:Me({$event_type:i.type,$ce_version:1},l?{}:{$elements:f},{$elements_chain:Y1(f)},(t=f[0])!=null&&t.$el_text?{$el_text:(r=f[0])==null?void 0:r.$el_text}:{},p&&i.type==="click"?{$external_click_url:p}:{},h)}}var Uh=class{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new pu(e.config.rageclick),this.C=null}get R(){var e,t,r=Be(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=(e=r.url_allowlist)==null?void 0:e.map((i=>new RegExp(i))),r.url_ignorelist=(t=r.url_ignorelist)==null?void 0:t.map((i=>new RegExp(i))),r}F(){if(this.isBrowserSupported()){if(S&&D){var e=r=>{r=r||S?.event;try{this.O(r)}catch(i){Xb.error("Failed to capture event",i)}};if(Fe(D,"submit",e,{capture:!0}),Fe(D,"change",e,{capture:!0}),Fe(D,"click",e,{capture:!0}),this.R.capture_copied_text){var t=r=>{r=r||S?.event,this.O(r,th)};Fe(D,"copy",t,{capture:!0}),Fe(D,"cut",t,{capture:!0})}}}else Xb.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.I=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Vb]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,r=[];return(t=this.C)==null||t.forEach((i=>{var s=D?.querySelectorAll(i);s?.forEach((o=>{e===o&&r.push(i)}))})),r}get isEnabled(){var e,t,r=(e=this.instance.persistence)==null?void 0:e.props[Vb],i=this.T;if(Mt(i)&&!In(r)&&!this.instance.M())return!1;var s=(t=this.T)!==null&&t!==void 0?t:!!r;return!!this.instance.config.autocapture&&!s}O(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var r,i=tw(e);X0(i)&&(i=i.parentNode||null),t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&W1(i,this.instance.config.rageclick)&&this.O(e,"$rageclick");var s=t===th;if(i&&z1(i,e,this.R,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=tT(i,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(a)return!1;var l=this.getElementSelectors(i);if(l&&l.length>0&&(o.$element_selectors=l),t===th){var c,u=ew(S==null||(c=S.getSelection())==null?void 0:c.toString()),p=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=p}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return ur(D?.querySelectorAll)}};Math.trunc||(Math.trunc=function(n){return n<0?Math.ceil(n):Math.floor(n)}),Number.isInteger||(Number.isInteger=function(n){return $n(n)&&isFinite(n)&&Math.floor(n)===n});var Qb="0123456789abcdef",jh=class n{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,r,i){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(r)||!Number.isInteger(i)||e<0||t<0||r<0||i<0||e>0xffffffffffff||t>4095||r>1073741823||i>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|r>>>24,s[9]=r>>>16,s[10]=r>>>8,s[11]=r,s[12]=i>>>24,s[13]=i>>>16,s[14]=i>>>8,s[15]=i,new n(s)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Qb.charAt(this.bytes[t]>>>4)+Qb.charAt(15&this.bytes[t]),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new n(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;t<16;t++){var r=this.bytes[t]-e.bytes[t];if(r!==0)return Math.sign(r)}return 0}},Wh=class{constructor(){this.A=0,this.j=0,this.D=new zh}generate(){var e=this.generateOrAbort();if(H(e)){this.A=0;var t=this.generateOrAbort();if(H(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.j++,this.j>4398046511103&&(this.A++,this.L())}return jh.fromFieldsV7(this.A,Math.trunc(this.j/Math.pow(2,30)),this.j&Math.pow(2,30)-1,this.D.nextUint32())}L(){this.j=1024*this.D.nextUint32()+(1023&this.D.nextUint32())}},e0,uw=n=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<n.length;e++)n[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return n};S&&!H(S.crypto)&&crypto.getRandomValues&&(uw=n=>crypto.getRandomValues(n));var zh=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(uw(this.N),this.U=0),this.N[this.U++]}},cr=()=>nT().toString(),nT=()=>(e0||(e0=new Wh)).generate(),ia="",rT=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function iT(n,e){if(e){var t=(function(i,s){if(s===void 0&&(s=D),ia)return ia;if(!s||["localhost","127.0.0.1"].includes(i))return"";for(var o=i.split("."),a=Math.min(o.length,8),l="dmn_chk_"+cr();!ia&&a--;){var c=o.slice(a).join("."),u=l+"=1;domain=."+c+";path=/";s.cookie=u+";max-age=3",s.cookie.includes(l)&&(s.cookie=u+";max-age=0",ia=c)}return ia})(n);if(!t){var r=(i=>{var s=i.match(rT);return s?s[0]:""})(n);r!==t&&V.info("Warning: cookie subdomain discovery mismatch",r,t),t=r}return t?"; domain=."+t:""}return""}var Yt={H:()=>!!D,B:function(n){V.error("cookieStore error: "+n)},q:function(n){if(D){try{for(var e=n+"=",t=D.cookie.split(";").filter((s=>s.length)),r=0;r<t.length;r++){for(var i=t[r];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return decodeURIComponent(i.substring(e.length,i.length))}}catch{}return null}},W:function(n){var e;try{e=JSON.parse(Yt.q(n))||{}}catch{}return e},G:function(n,e,t,r,i){if(D)try{var s="",o="",a=iT(D.location.hostname,r);if(t){var l=new Date;l.setTime(l.getTime()+24*t*60*60*1e3),s="; expires="+l.toUTCString()}i&&(o="; secure");var c=n+"="+encodeURIComponent(JSON.stringify(e))+s+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&V.warn("cookieStore warning: large cookie, len="+c.length),D.cookie=c,c}catch{return}},V:function(n,e){if(D!=null&&D.cookie)try{Yt.G(n,"",-1,e)}catch{return}}},rh=null,Te={H:function(){if(!Mt(rh))return rh;var n=!0;if(H(S))n=!1;else try{var e="__mplssupport__";Te.G(e,"xyz"),Te.q(e)!=='"xyz"'&&(n=!1),Te.V(e)}catch{n=!1}return n||V.error("localStorage unsupported; falling back to cookie store"),rh=n,n},B:function(n){V.error("localStorage error: "+n)},q:function(n){try{return S?.localStorage.getItem(n)}catch(e){Te.B(e)}return null},W:function(n){try{return JSON.parse(Te.q(n))||{}}catch{}return null},G:function(n,e){try{S?.localStorage.setItem(n,JSON.stringify(e))}catch(t){Te.B(t)}},V:function(n){try{S?.localStorage.removeItem(n)}catch(e){Te.B(e)}}},sT=["$device_id","distinct_id",au,Y0,uu,cu],Xc={},oT={H:function(){return!0},B:function(n){V.error("memoryStorage error: "+n)},q:function(n){return Xc[n]||null},W:function(n){return Xc[n]||null},G:function(n,e){Xc[n]=e},V:function(n){delete Xc[n]}},ri=null,ze={H:function(){if(!Mt(ri))return ri;if(ri=!0,H(S))ri=!1;else try{var n="__support__";ze.G(n,"xyz"),ze.q(n)!=='"xyz"'&&(ri=!1),ze.V(n)}catch{ri=!1}return ri},B:function(n){V.error("sessionStorage error: ",n)},q:function(n){try{return S?.sessionStorage.getItem(n)}catch(e){ze.B(e)}return null},W:function(n){try{return JSON.parse(ze.q(n))||null}catch{}return null},G:function(n,e){try{S?.sessionStorage.setItem(n,JSON.stringify(e))}catch(t){ze.B(t)}},V:function(n){try{S?.sessionStorage.removeItem(n)}catch(e){ze.B(e)}}},An=(function(n){return n[n.PENDING=-1]="PENDING",n[n.DENIED=0]="DENIED",n[n.GRANTED=1]="GRANTED",n})({}),qh=class{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?An.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===An.DENIED||this.consent===An.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===An.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:r}=this._instance.config;return r||(t?t+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return Jf(e)?An.GRANTED:me(h1,e)?An.DENIED:An.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?Te:Yt;var t=e==="localStorage"?Yt:Te;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(Jf(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!Z0([ht?.doNotTrack,ht?.msDoNotTrack,ee.doNotTrack],(e=>Jf(e)))}},Qc=Pe("[Dead Clicks]"),aT=()=>!0,lT=n=>{var e,t=!((e=n.instance.persistence)==null||!e.get_property(K0)),r=n.instance.config.capture_dead_clicks;return In(r)?r:!!Be(r)||t},mu=class{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,r){this.instance=e,this.isEnabled=t,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[K0]:e?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it((()=>{this.et()}))}it(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?Qc.error("failed to load script",i):e()}))}et(){var e;if(D){if(!this.tt&&(e=ee.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=Be(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=ee.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(D),Qc.info("starting...")}}else Qc.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Qc.info("stopping..."))}},sa=Pe("[ExceptionAutocapture]"),Zh=class{constructor(e){var t,r,i;this.rt=()=>{var s;if(S&&this.isEnabled&&(s=ee.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var o=ee.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=ee.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=ee.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=o(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=a(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=l(this.captureException.bind(this)))}catch(c){sa.error("failed to start",c),this.ut()}}},this._instance=e,this.ht=!((t=this._instance.persistence)==null||!t.props[Ub]),this.dt=new _h({refillRate:(r=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:1,bucketSize:(i=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10,refillInterval:1e4,h:sa}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Be(e)?t=W({},t,e):(H(e)?this.ht:e)&&(t=W({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(sa.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return sa.error("failed to load script",i);e()}))}ut(){var e,t,r;(e=this.st)==null||e.call(this),this.st=void 0,(t=this.nt)==null||t.call(this),this.nt=void 0,(r=this.ot)==null||r.call(this),this.ot=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[Ub]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var t,r,i=(t=e==null||(r=e.$exception_list)==null||(r=r[0])==null?void 0:r.type)!==null&&t!==void 0?t:"Exception";this.dt.consumeRateLimit(i)?sa.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(e)}};function t0(n,e,t){try{if(!(e in n))return()=>{};var r=n[e],i=t(r);return ur(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),n[e]=i,()=>{n[e]=r}}catch{return()=>{}}}var Gh=class{constructor(e){var t;this._instance=e,this.ct=(S==null||(t=S.location)==null?void 0:t.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(V.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,V.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(S&&S.history){var r=this;(e=S.history.pushState)!=null&&e.__posthog_wrapped__||t0(S.history,"pushState",(i=>function(s,o,a){i.call(this,s,o,a),r._t("pushState")})),(t=S.history.replaceState)!=null&&t.__posthog_wrapped__||t0(S.history,"replaceState",(i=>function(s,o,a){i.call(this,s,o,a),r._t("replaceState")})),this.bt()}}_t(e){try{var t,r=S==null||(t=S.location)==null?void 0:t.pathname;if(!r)return;r!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=r}catch(i){V.error("Error capturing "+e+" pageview",i)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};Fe(S,"popstate",e),this.ft=()=>{S&&S.removeEventListener("popstate",e)}}}},ih=Pe("[SegmentIntegration]");function cT(n,e){var t=n.config.segment;if(!t)return e();(function(r,i){var s=r.config.segment;if(!s)return i();var o=l=>{var c=()=>l.anonymousId()||cr();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(kn,"identified")),i()},a=s.user();"then"in a&&ur(a.then)?a.then(o):o(a)})(n,(()=>{t.register((r=>{Promise&&Promise.resolve||ih.warn("This browser does not have Promise support, and can not use the segment integration");var i=(s,o)=>{if(!o)return s;s.event.userId||s.event.anonymousId===r.get_distinct_id()||(ih.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(ih.info("UserId set, identifying with PostHog"),r.identify(s.event.userId));var a=r.calculateEventProperties(o,s.event.properties);return s.event.properties=Object.assign({},a,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:s=>i(s,s.event.event),page:s=>i(s,"$pageview"),identify:s=>i(s,"$identify"),screen:s=>i(s,"$screen")}})(n)).then((()=>{e()}))}))}var dw="posthog-js";function pw(n,e){var{organization:t,projectId:r,prefix:i,severityAllowList:s=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,c,u,p,f;if(!(s==="*"||s.includes(a.level))||!n.__loaded)return a;a.tags||(a.tags={});var h=n.requestRouter.endpointFor("ui","/project/"+n.config.token+"/person/"+n.get_distinct_id());a.tags["PostHog Person URL"]=h,n.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=n.get_session_replay_url({withTimestamp:!0}));var g=((l=a.exception)==null?void 0:l.values)||[],v=g.map((y=>W({},y,{stacktrace:y.stacktrace?W({},y.stacktrace,{type:"raw",frames:(y.stacktrace.frames||[]).map((w=>W({},w,{platform:"web:javascript"})))}):void 0}))),m={$exception_message:((c=g[0])==null?void 0:c.value)||a.message,$exception_type:(u=g[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:v,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((p=g[0])==null?void 0:p.value)||a.message,$sentry_exception_type:(f=g[0])==null?void 0:f.type,$sentry_tags:a.tags};return t&&r&&(m.$sentry_url=(i||"https://sentry.io/organizations/")+t+"/issues/?project="+r+"&query="+a.event_id),o&&n.exceptions.sendExceptionEvent(m),a}}var Kh=class{constructor(e,t,r,i,s,o){this.name=dw,this.setupOnce=function(a){a(pw(e,{organization:t,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}},uT=S!=null&&S.location?gu(S.location.hash,"__posthog")||gu(location.hash,"state"):null,n0="_postHogToolbarParams",r0=Pe("[Toolbar]"),lr=(function(n){return n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED",n})(lr||{}),Yh=class{constructor(e){this.instance=e}yt(e){ee.ph_toolbar_state=e}wt(){var e;return(e=ee.ph_toolbar_state)!==null&&e!==void 0?e:lr.UNINITIALIZED}maybeLoadToolbar(e,t,r){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),r===void 0&&(r=void 0),!S||!D)return!1;e=e??S.location,r=r??S.history;try{if(!t){try{S.localStorage.setItem("test","test"),S.localStorage.removeItem("test")}catch{return!1}t=S?.localStorage}var i,s=uT||gu(e.hash,"__posthog")||gu(e.hash,"state"),o=s?Bb((()=>JSON.parse(atob(decodeURIComponent(s)))))||Bb((()=>JSON.parse(decodeURIComponent(s)))):null;return o&&o.action==="ph_authorize"?((i=o).source="url",i&&Object.keys(i).length>0&&(o.desiredHash?e.hash=o.desiredHash:r?r.replaceState(r.state,"",e.pathname+e.search):e.hash="")):((i=JSON.parse(t.getItem(n0)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token)&&(this.loadToolbar(i),!0)}catch{return!1}}xt(e){var t=ee.ph_load_toolbar||ee.ph_load_editor;!ve(t)&&ur(t)?t(e,this.instance):r0.warn("No toolbar load function found")}loadToolbar(e){var t=!(D==null||!D.getElementById(J0));if(!S||t)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=W({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(S.localStorage.setItem(n0,JSON.stringify(W({},i,{source:void 0}))),this.wt()===lr.LOADED)this.xt(i);else if(this.wt()===lr.UNINITIALIZED){var s;this.yt(lr.LOADING),(s=ee.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",(o=>{if(o)return r0.error("[Toolbar] Failed to load",o),void this.yt(lr.UNINITIALIZED);this.yt(lr.LOADED),this.xt(i)})),Fe(S,"turbolinks:load",(()=>{this.yt(lr.UNINITIALIZED),this.loadToolbar(i)}))}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,r){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),r===void 0&&(r=void 0),this.maybeLoadToolbar(e,t,r)}},dT=Pe("[TracingHeaders]"),Jh=class{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var t,r;H(this.$t)&&((t=ee.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),H(this.St)&&((r=ee.__PosthogExtensions__)==null||(r=r.tracingHeadersPatchFns)==null||r._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}it(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return dT.error("failed to load script",i);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):((e=this.$t)==null||e.call(this),(t=this.St)==null||t.call(this),this.$t=void 0,this.St=void 0)}},eu="https?://(.*)",Ts=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],pT=As(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Ts),$a="<masked>",fT=["li_fat_id"];function fw(n,e,t){if(!D)return{};var r,i=e?As([],Ts,t||[]):[],s=hw(Ia(D.URL,i,$a),n),o=(r={},xe(fT,(function(a){var l=Yt.q(a);r[a]=l||null})),r);return Me(o,s)}function hw(n,e){var t=pT.concat(e||[]),r={};return xe(t,(function(i){var s=hu(n,i);r[i]=s||null})),r}function gw(n){var e=(function(s){return s?s.search(eu+"google.([^/?]*)")===0?"google":s.search(eu+"bing.com")===0?"bing":s.search(eu+"yahoo.com")===0?"yahoo":s.search(eu+"duckduckgo.com")===0?"duckduckgo":null:null})(n),t=e!="yahoo"?"q":"p",r={};if(!Mt(e)){r.$search_engine=e;var i=D?hu(D.referrer,t):"";i.length&&(r.ph_keyword=i)}return r}function i0(){return navigator.language||navigator.userLanguage}function mw(){return D?.referrer||"$direct"}function vw(n,e){var t=n?As([],Ts,e||[]):[],r=qe?.href.substring(0,1e3);return{r:mw().substring(0,1e3),u:r?Ia(r,t,$a):void 0}}function yw(n){var e,{r:t,u:r}=n,i={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=fu(t))==null?void 0:e.host};if(r){i.$current_url=r;var s=fu(r);i.$host=s?.host,i.$pathname=s?.pathname;var o=hw(r);Me(i,o)}if(t){var a=gw(t);Me(i,a)}return i}function _w(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function hT(){try{return new Date().getTimezoneOffset()}catch{return}}function gT(n,e){if(!ct)return{};var t,r,i,s=n?As([],Ts,e||[]):[],[o,a]=(function(l){for(var c=0;c<Lb.length;c++){var[u,p]=Lb[c],f=u.exec(l),h=f&&(ur(p)?p(f,l):p);if(h)return h}return["",""]})(ct);return Me($g({$os:o,$os_version:a,$browser:j0(ct,navigator.vendor),$device:Nb(ct),$device_type:(r=ct,i=Nb(r),i===R0||i===T0||i==="Kobo"||i==="Kindle Fire"||i===U0?Sa:i===Ca||i===Ss||i===ka||i===wh?"Console":i===$0?"Wearable":i?St:"Desktop"),$timezone:_w(),$timezone_offset:hT()}),{$current_url:Ia(qe?.href,s,$a),$host:qe?.host,$pathname:qe?.pathname,$raw_user_agent:ct.length>1e3?ct.substring(0,997)+"...":ct,$browser_version:E1(ct,navigator.vendor),$browser_language:i0(),$browser_language_prefix:(t=i0(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:S?.screen.height,$screen_width:S?.screen.width,$viewport_height:S?.innerHeight,$viewport_width:S?.innerWidth,$lib:"web",$lib_version:Cn.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var sr=Pe("[Web Vitals]"),s0=9e5,Xh=class{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),this.N.metrics.length!==0&&(this._instance.capture("$web_vitals",this.N.metrics.reduce(((r,i)=>W({},r,{["$web_vitals_"+i.name+"_event"]:W({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=r=>{var i,s=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(H(s))sr.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var o=this.Ct();H(o)||(ve(r?.name)||ve(r?.value)?sr.error("Invalid metric received",r):this.Rt&&r.value>=this.Rt?sr.error("Ignoring metric with value >= "+this.Rt,r):(this.N.url!==o&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),H(this.N.url)&&(this.N.url=o),this.N.firstMetricTimestamp=H(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.N.metrics.push(W({},r,{$current_url:o,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var r,i,s,o,a=ee.__PosthogExtensions__;H(a)||H(a.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:i,onFCP:s,onINP:o}=a.postHogWebVitalsCallbacks),r&&i&&s&&o?(this.allowedMetrics.indexOf("LCP")>-1&&r(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&o(this.It.bind(this)),this.P=!0):sr.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!((t=this._instance.persistence)==null||!t.props[Wb]),this.startIfEnabled()}get allowedMetrics(){var e,t,r=Be(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return ve(r)?((t=this._instance.persistence)==null?void 0:t.props[qb])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(Be(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=Be(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return e!=null&&e}get Rt(){var e=Be(this._instance.config.capture_performance)&&$n(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:s0;return 0<e&&e<=6e4?s0:e}get isEnabled(){var e=qe?.protocol;if(e!=="http:"&&e!=="https:")return sr.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=Be(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:In(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return In(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(sr.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=Be(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=Be(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Wb]:t}),this._instance.persistence.register({[qb]:r})),this.kt=t,this.startIfEnabled()}it(e){var t,r;if((t=ee.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks)e();else{var i=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,i,(s=>{s?sr.error("failed to load script",s):e()}))}}Ct(){var e=S?S.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,r=this._instance.config.custom_personal_data_properties,i=t?As([],Ts,r||[]):[];return Ia(e,i,$a)}sr.error("Could not determine current URL")}},mT=Pe("[Heatmaps]");function o0(n){return Be(n)&&"clientX"in n&&"clientY"in n&&$n(n.clientX)&&$n(n.clientY)}var Qh=class{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!((t=this.instance.persistence)==null||!t.props[Oh]),this.rageclicks=new pu(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return Be(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return ve(this.instance.config.capture_heatmaps)?ve(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.P)return;mT.info("starting..."),this.Ot(),this.Mt()}else{var e;clearInterval((e=this.Ft)!==null&&e!==void 0?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Oh]:t}),this.kt=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}jt(e){this.Dt(e.originalEvent,"deadclick")}Mt(){this.Ft&&clearInterval(this.Ft),this.Ft=(function(e){return e?.visibilityState==="visible"})(D)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){S&&D&&(this.Nt=this.Lt.bind(this),Fe(S,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||S?.event),Fe(D,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||S?.event),Fe(D,"mousemove",this.zt,{capture:!0}),this.Bt=new mu(this.instance,aT,this.jt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Mt.bind(this),Fe(D,"visibilitychange",this.qt),this.P=!0)}At(){var e;S&&D&&(this.Nt&&S.removeEventListener("beforeunload",this.Nt),this.Ut&&D.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&D.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&D.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),(e=this.Bt)==null||e.stop(),this.P=!1)}Gt(e,t){var r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),o=(function(a,l,c){for(var u=a;u&&Tu(u)&&!pr(u,"body");){if(u===c)return!1;if(me(l,S?.getComputedStyle(u).position))return!0;u=rw(u)}return!1})(tw(e),["fixed","sticky"],s);return{x:e.clientX+(o?0:i),y:e.clientY+(o?0:r),target_fixed:o,type:t}}Dt(e,t){var r;if(t===void 0&&(t="click"),!Zb(e.target)&&o0(e)){var i=this.Gt(e,t);(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Vt(W({},i,{type:"rageclick"})),this.Vt(i)}}Ht(e){!Zb(e.target)&&o0(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout((()=>{this.Vt(this.Gt(e,"mousemove"))}),500))}Vt(e){if(S){var t=S.location.href,r=this.instance.config.mask_personal_data_properties,i=this.instance.config.custom_personal_data_properties,s=r?As([],Ts,i||[]):[],o=Ia(t,s,$a);this.N=this.N||{},this.N[o]||(this.N[o]=[]),this.N[o].push(e)}}Lt(){this.N&&!bs(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},vu=class{constructor(e){this.Jt=(t,r,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(V.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:i}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.Jt)}destroy(){var e;(e=this.Xt)==null||e.call(this),this.Xt=void 0}doPageView(e,t){var r,i=this.Qt(e,t);return this.Kt={pathname:(r=S?.location.pathname)!==null&&r!==void 0?r:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var t;return this.Qt(e,(t=this.Kt)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Kt)==null?void 0:e.pageViewId}}Qt(e,t){var r=this.Kt;if(!r)return{$pageview_id:t};var i={$pageview_id:t,$prev_pageview_id:r.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:p}=s;if(!(H(o)||H(a)||H(l)||H(c)||H(u)||H(p))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),p=Math.ceil(p);var f=o<=1?1:Jt(a/o,0,1,V),h=o<=1?1:Jt(l/o,0,1,V),g=c<=1?1:Jt(u/c,0,1,V),v=c<=1?1:Jt(p/c,0,1,V);i=Me(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:g,$prev_pageview_max_content:p,$prev_pageview_max_content_percentage:v})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),i}};var Tn=(function(n){return n.GZipJS="gzip-js",n.Base64="base64",n})({}),Et=Uint8Array,rt=Uint16Array,ks=Uint32Array,Lg=new Et([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Ng=new Et([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),a0=new Et([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bw=function(n,e){for(var t=new rt(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];var i=new ks(t[30]);for(r=1;r<30;++r)for(var s=t[r];s<t[r+1];++s)i[s]=s-t[r]<<5|r;return[t,i]},ww=bw(Lg,2),vT=ww[0],eg=ww[1];vT[28]=258,eg[258]=28;for(tg=bw(Ng,0)[1],yu=new rt(32768),Se=0;Se<32768;++Se)or=(43690&Se)>>>1|(21845&Se)<<1,or=(61680&(or=(52428&or)>>>2|(13107&or)<<2))>>>4|(3855&or)<<4,yu[Se]=((65280&or)>>>8|(255&or)<<8)>>>1;var or,tg,yu,Se,ba=function(n,e,t){for(var r=n.length,i=0,s=new rt(e);i<r;++i)++s[n[i]-1];var o,a=new rt(e);for(i=0;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;if(t){o=new rt(1<<e);var l=15-e;for(i=0;i<r;++i)if(n[i])for(var c=i<<4|n[i],u=e-n[i],p=a[n[i]-1]++<<u,f=p|(1<<u)-1;p<=f;++p)o[yu[p]>>>l]=c}else for(o=new rt(r),i=0;i<r;++i)o[i]=yu[a[n[i]-1]++]>>>15-n[i];return o},ai=new Et(288);for(Se=0;Se<144;++Se)ai[Se]=8;for(Se=144;Se<256;++Se)ai[Se]=9;for(Se=256;Se<280;++Se)ai[Se]=7;for(Se=280;Se<288;++Se)ai[Se]=8;var _u=new Et(32);for(Se=0;Se<32;++Se)_u[Se]=5;var yT=ba(ai,9,0),_T=ba(_u,5,0),xw=function(n){return(n/8>>0)+(7&n&&1)},Sw=function(n,e,t){(t==null||t>n.length)&&(t=n.length);var r=new(n instanceof rt?rt:n instanceof ks?ks:Et)(t-e);return r.set(n.subarray(e,t)),r},Sn=function(n,e,t){t<<=7&e;var r=e/8>>0;n[r]|=t,n[r+1]|=t>>>8},oa=function(n,e,t){t<<=7&e;var r=e/8>>0;n[r]|=t,n[r+1]|=t>>>8,n[r+2]|=t>>>16},sh=function(n,e){for(var t=[],r=0;r<n.length;++r)n[r]&&t.push({s:r,f:n[r]});var i=t.length,s=t.slice();if(!i)return[new Et(0),0];if(i==1){var o=new Et(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(k,I){return k.f-I.f})),t.push({s:-1,f:25001});var a=t[0],l=t[1],c=0,u=1,p=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=i-1;)a=t[t[c].f<t[p].f?c++:p++],l=t[c!=u&&t[c].f<t[p].f?c++:p++],t[u++]={s:-1,f:a.f+l.f,l:a,r:l};var f=s[0].s;for(r=1;r<i;++r)s[r].s>f&&(f=s[r].s);var h=new rt(f+1),g=ng(t[u-1],h,0);if(g>e){r=0;var v=0,m=g-e,y=1<<m;for(s.sort((function(k,I){return h[I.s]-h[k.s]||k.f-I.f}));r<i;++r){var w=s[r].s;if(!(h[w]>e))break;v+=y-(1<<g-h[w]),h[w]=e}for(v>>>=m;v>0;){var x=s[r].s;h[x]<e?v-=1<<e-h[x]++-1:++r}for(;r>=0&&v;--r){var _=s[r].s;h[_]==e&&(--h[_],++v)}g=e}return[new Et(h),g]},ng=function(n,e,t){return n.s==-1?Math.max(ng(n.l,e,t+1),ng(n.r,e,t+1)):e[n.s]=t},l0=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new rt(++e),r=0,i=n[0],s=1,o=function(l){t[r++]=l},a=1;a<=e;++a)if(n[a]==i&&a!=e)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=n[a]}return[t.subarray(0,r),e]},aa=function(n,e){for(var t=0,r=0;r<e.length;++r)t+=n[r]*e[r];return t},rg=function(n,e,t){var r=t.length,i=xw(e+2);n[i]=255&r,n[i+1]=r>>>8,n[i+2]=255^n[i],n[i+3]=255^n[i+1];for(var s=0;s<r;++s)n[i+s+4]=t[s];return 8*(i+4+r)},c0=function(n,e,t,r,i,s,o,a,l,c,u){Sn(e,u++,t),++i[256];for(var p=sh(i,15),f=p[0],h=p[1],g=sh(s,15),v=g[0],m=g[1],y=l0(f),w=y[0],x=y[1],_=l0(v),k=_[0],I=_[1],b=new rt(19),A=0;A<w.length;++A)b[31&w[A]]++;for(A=0;A<k.length;++A)b[31&k[A]]++;for(var M=sh(b,7),J=M[0],$=M[1],U=19;U>4&&!J[a0[U-1]];--U);var G,Z,te,ye,pe=c+5<<3,j=aa(i,ai)+aa(s,_u)+o,X=aa(i,f)+aa(s,v)+o+14+3*U+aa(b,J)+(2*b[16]+3*b[17]+7*b[18]);if(pe<=j&&pe<=X)return rg(e,u,n.subarray(l,l+c));if(Sn(e,u,1+(X<j)),u+=2,X<j){G=ba(f,h,0),Z=f,te=ba(v,m,0),ye=v;var Oe=ba(J,$,0);for(Sn(e,u,x-257),Sn(e,u+5,I-1),Sn(e,u+10,U-4),u+=14,A=0;A<U;++A)Sn(e,u+3*A,J[a0[A]]);u+=3*U;for(var Ye=[w,k],De=0;De<2;++De){var Je=Ye[De];for(A=0;A<Je.length;++A){var Xe=31&Je[A];Sn(e,u,Oe[Xe]),u+=J[Xe],Xe>15&&(Sn(e,u,Je[A]>>>5&127),u+=Je[A]>>>12)}}}else G=yT,Z=ai,te=_T,ye=_u;for(A=0;A<a;++A)if(r[A]>255){Xe=r[A]>>>18&31,oa(e,u,G[Xe+257]),u+=Z[Xe+257],Xe>7&&(Sn(e,u,r[A]>>>23&31),u+=Lg[Xe]);var Pn=31&r[A];oa(e,u,te[Pn]),u+=ye[Pn],Pn>3&&(oa(e,u,r[A]>>>5&8191),u+=Ng[Pn])}else oa(e,u,G[r[A]]),u+=Z[r[A]];return oa(e,u,G[256]),u+Z[256]},bT=new ks([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),wT=(function(){for(var n=new ks(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(1&t&&3988292384)^t>>>1;n[e]=t}return n})(),xT=function(n,e,t,r,i){return(function(s,o,a,l,c,u){var p=s.length,f=new Et(l+p+5*(1+Math.floor(p/7e3))+c),h=f.subarray(l,f.length-c),g=0;if(!o||p<8)for(var v=0;v<=p;v+=65535){var m=v+65535;m<p?g=rg(h,g,s.subarray(v,m)):(h[v]=u,g=rg(h,g,s.subarray(v,p)))}else{for(var y=bT[o-1],w=y>>>13,x=8191&y,_=(1<<a)-1,k=new rt(32768),I=new rt(_+1),b=Math.ceil(a/3),A=2*b,M=function($s){return(s[$s]^s[$s+1]<<b^s[$s+2]<<A)&_},J=new ks(25e3),$=new rt(288),U=new rt(32),G=0,Z=0,te=(v=0,0),ye=0,pe=0;v<p;++v){var j=M(v),X=32767&v,Oe=I[j];if(k[X]=Oe,I[j]=X,ye<=v){var Ye=p-v;if((G>7e3||te>24576)&&Ye>423){g=c0(s,h,0,J,$,U,Z,te,pe,v-pe,g),te=G=Z=0,pe=v;for(var De=0;De<286;++De)$[De]=0;for(De=0;De<30;++De)U[De]=0}var Je=2,Xe=0,Pn=x,Lt=X-Oe&32767;if(Ye>2&&j==M(v-Lt))for(var Is=Math.min(w,Ye)-1,R=Math.min(32767,v),Y=Math.min(258,Ye);Lt<=R&&--Pn&&X!=Oe;){if(s[v+Je]==s[v+Je-Lt]){for(var B=0;B<Y&&s[v+B]==s[v+B-Lt];++B);if(B>Je){if(Je=B,Xe=Lt,B>Is)break;var fe=Math.min(Lt,B-2),he=0;for(De=0;De<fe;++De){var se=v-Lt+De+32768&32767,Re=se-k[se]+32768&32767;Re>he&&(he=Re,Oe=se)}}}Lt+=(X=Oe)-(Oe=k[X])+32768&32767}if(Xe){J[te++]=268435456|eg[Je]<<18|tg[Xe];var Xt=31&eg[Je],Qt=31&tg[Xe];Z+=Lg[Xt]+Ng[Qt],++$[257+Xt],++U[Qt],ye=v+Je,++G}else J[te++]=s[v],++$[s[v]]}}g=c0(s,h,u,J,$,U,Z,te,pe,v-pe,g)}return Sw(f,0,l+xw(g)+c)})(n,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+e.mem,t,r,!0)},oh=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8};function ST(n,e){e===void 0&&(e={});var t=(function(){var a=4294967295;return{p:function(l){for(var c=a,u=0;u<l.length;++u)c=wT[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}})(),r=n.length;t.p(n);var i,s=xT(n,e,10+((i=e).filename&&i.filename.length+1||0),8),o=s.length;return(function(a,l){var c=l.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=l.level<2?4:l.level==9?2:0,a[9]=3,l.mtime!=0&&oh(a,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),c){a[3]=8;for(var u=0;u<=c.length;++u)a[u+10]=c.charCodeAt(u)}})(s,e),oh(s,o-8,t.d()),oh(s,o-4,r),s}var ET=function(n){var e,t,r,i,s="";for(e=t=0,r=(n=(n+"").replace(/\r\n/g,`
|
|
625
625
|
`).replace(/\r/g,`
|
|
626
|
-
`)).length,i=0;i<r;i++){var o=n.charCodeAt(i),a=null;o<128?t++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),Mt(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},CT=!!gh||!!hh,u0="text/plain",bu=function(n,e,t){var r;t===void 0&&(t=!0);var[i,s]=n.split("?"),o=W({},e),a=(r=s?.split("&").map((c=>{var u,[p,f]=c.split("="),h=t&&(u=o[p])!==null&&u!==void 0?u:f;return delete o[p],p+"="+h})))!==null&&r!==void 0?r:[],l=X1(o);return l&&a.push(l),i+"?"+a.join("&")},va=(n,e)=>JSON.stringify(n,((t,r)=>typeof r=="bigint"?r.toString():r),e),ah=n=>{var{data:e,compression:t}=n;if(e){if(t===Tn.GZipJS){var r=ST((function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var p=new Et(l.length+(l.length>>>1)),f=0,h=function(y){p[f++]=y},g=0;g<u;++g){if(f+5>p.length){var v=new Et(f+8+(u-g<<1));v.set(p),p=v}var m=l.charCodeAt(g);m<128||c?h(m):m<2048?(h(192|m>>>6),h(128|63&m)):m>55295&&m<57344?(h(240|(m=65536+(1047552&m)|1023&l.charCodeAt(++g))>>>18),h(128|m>>>12&63),h(128|m>>>6&63),h(128|63&m)):(h(224|m>>>12),h(128|m>>>6&63),h(128|63&m))}return Sw(p,0,f)})(va(e)),{mtime:0}),i=new Blob([r],{type:u0});return{contentType:u0,body:i,estimatedSize:i.size}}if(t===Tn.Base64){var s=(function(l){var c,u,p,f,h,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,m=0,y="",w=[];if(!l)return l;l=ET(l);do c=(h=l.charCodeAt(v++)<<16|l.charCodeAt(v++)<<8|l.charCodeAt(v++))>>18&63,u=h>>12&63,p=h>>6&63,f=63&h,w[m++]=g.charAt(c)+g.charAt(u)+g.charAt(p)+g.charAt(f);while(v<l.length);switch(y=w.join(""),l.length%3){case 1:y=y.slice(0,-2)+"==";break;case 2:y=y.slice(0,-1)+"="}return y})(va(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:va(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=va(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},ru=[];hh&&ru.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=ah(n))!==null&&e!==void 0?e:{},o=new Headers;xe(n.headers,(function(u,p){o.append(p,u)})),r&&o.append("Content-Type",r);var a=n.url,l=null;if(Ib){var c=new Ib;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),n.timeout)}}hh(a,W({method:n?.method||"GET",headers:o,keepalive:n.method==="POST"&&(s||0)<52428.8,body:i,signal:(t=l)==null?void 0:t.signal},n.fetchOptions)).then((u=>u.text().then((p=>{var f={statusCode:u.status,text:p};if(u.status===200)try{f.json=JSON.parse(p)}catch(h){V.error(h)}n.callback==null||n.callback(f)})))).catch((u=>{V.error(u),n.callback==null||n.callback({statusCode:0,text:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),gh&&ru.push({transport:"XHR",method:n=>{var e,t=new gh;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=ah(n))!==null&&e!==void 0?e:{};xe(n.headers,(function(s,o){t.setRequestHeader(o,s)})),r&&t.setRequestHeader("Content-Type",r),n.timeout&&(t.timeout=n.timeout),n.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var s={statusCode:t.status,text:t.responseText};if(t.status===200)try{s.json=JSON.parse(t.responseText)}catch{}n.callback==null||n.callback(s)}},t.send(i)}}),ht!=null&&ht.sendBeacon&&ru.push({transport:"sendBeacon",method:n=>{var e=bu(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=ah(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;ht.sendBeacon(e,s)}catch{}}});var wu=function(n,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(n)}catch{return!1}};function d0(n,e,t){return va({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var Ew={exact:(n,e)=>e.some((t=>n.some((r=>t===r)))),is_not:(n,e)=>e.every((t=>n.every((r=>t!==r)))),regex:(n,e)=>e.some((t=>n.some((r=>wu(t,r))))),not_regex:(n,e)=>e.every((t=>n.every((r=>!wu(t,r))))),icontains:(n,e)=>e.map(tu).some((t=>n.map(tu).some((r=>t.includes(r))))),not_icontains:(n,e)=>e.map(tu).every((t=>n.map(tu).every((r=>!t.includes(r))))),gt:(n,e)=>e.some((t=>{var r=parseFloat(t);return!isNaN(r)&&n.some((i=>r>parseFloat(i)))})),lt:(n,e)=>e.some((t=>{var r=parseFloat(t);return!isNaN(r)&&n.some((i=>r<parseFloat(i)))}))},tu=n=>n.toLowerCase();function Cw(n,e){return!n||Object.entries(n).every((t=>{var[r,i]=t,s=e?.[r];if(H(s)||Mt(s))return!1;var o=[String(s)],a=Ew[i.operator];return!!a&&a(i.values,o)}))}var lh=Pe("[Error tracking]"),ig=class{constructor(e){var t,r;this.Zt=[],this.ti=new Sh([new Ch,new Ph,new Ah,new kh,new Ih,new Rh,new Th,new $h],M1()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(Mh))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,r,i,s=(t=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&t!==void 0?t:[],o=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Zt=s,this._instance.persistence&&this._instance.persistence.register({[Mh]:this.Zt,[jb]:o})}get ii(){var e,t=!!this._instance.get_property(jb),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void lh.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void lh.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void lh.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(e){if(e.length===0)return!1;var t=e.reduce(((r,i)=>{var{type:s,value:o}=i;return Ve(s)&&s.length>0&&r.$exception_types.push(s),Ve(o)&&o.length>0&&r.$exception_values.push(o),r}),{$exception_types:[],$exception_values:[]});return this.Zt.some((r=>{var i=r.values.map((s=>{var o,a=Ew[s.operator],l=_e(s.value)?s.value:[s.value],c=(o=t[s.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,c)}));return r.type==="OR"?i.some(Boolean):i.every(Boolean)}))}si(e){return e.flatMap((t=>{var r,i;return(r=(i=t.stacktrace)==null?void 0:i.frames)!==null&&r!==void 0?r:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}ni(e){if(e.length>0){var t,r,i,s,o=(t=(r=e[0].stacktrace)==null?void 0:r.frames)!==null&&t!==void 0?t:[],a=o[o.length-1];return(i=a==null||(s=a.filename)==null?void 0:s.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}ei(e){return!ve(e)&&_e(e)}},ft=Pe("[FeatureFlags]"),la=Pe("[FeatureFlags]",{debugEnabled:!0}),ch="$active_feature_flags",gs="$override_feature_flags",p0="$feature_flag_payloads",ca="$override_feature_flag_payloads",f0="$feature_flag_request_id",h0="$feature_flag_evaluated_at",g0=n=>{var e={};for(var[t,r]of nu(n||{}))r&&(e[t]=r);return e},kT=n=>{var e=n.flags;return e?(n.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var r;return[t,(r=e[t].variant)!==null&&r!==void 0?r:e[t].enabled]}))),n.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var r;return(r=e[t].metadata)==null?void 0:r.payload})).map((t=>{var r;return[t,(r=e[t].metadata)==null?void 0:r.payload]})))):ft.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},AT=(function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n})({}),sg=class{constructor(e){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=(e=this._instance.config.evaluation_contexts)!==null&&e!==void 0?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(ft.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),t!=null&&t.length?t.filter((r=>{var i=r&&typeof r=="string"&&r.trim().length>0;return i||ft.error("Invalid evaluation context found:",r,"Expected non-empty string"),i})):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var e=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:e})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Lh),t=this._instance.get_property(gs),r=this._instance.get_property(ca);if(!r&&!t)return e||{};var i=Me({},e||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of s){var a,l,c=i[o],u=t?.[o],p=H(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,f=H(u)?c.variant:typeof u=="string"?u:void 0,h=r?.[o],g=W({},c,{enabled:p,variant:p?f??c?.variant:void 0});p!==c?.enabled&&(g.original_enabled=c?.enabled),f!==c?.variant&&(g.original_variant=c?.variant),h&&(g.metadata=W({},c?.metadata,{payload:h,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[o]=g}return this.oi||(ft.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(ws),t=this._instance.get_property(gs);if(!t)return e||{};for(var r=Me({},e),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(ft.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(p0),t=this._instance.get_property(ca);if(!t)return e||{};for(var r=Me({},e||{}),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(ft.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:r}),this.oi=!0),r}reloadFeatureFlags(){this.ui||this._instance.config.advanced_disable_feature_flags||this.gi||(this.gi=setTimeout((()=>{this.mi()}),5))}bi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ui=e}mi(e){var t;if(this.bi(),!this._instance.M())if(this.li)this.hi=!0;else{var r=this._instance.config.token,i=this._instance.get_property("$device_id"),s={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:W({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(ma)||{}),group_properties:this._instance.get_property(si)};Mt(i)||H(i)||(s.$device_id=i),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.pi()&&(s.evaluation_contexts=this.fi());var o=this._instance.config.__preview_remote_config,a=o?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",a+l);o&&(s.timezone=_w()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:Tn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var p,f,h=!0;if(u.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),h=!1),this.li=!1,this.di||(this.di=!0,this._instance.yi((f=u.json)!==null&&f!==void 0?f:{})),!s.disable_flags||this.hi)if(this.vi=!h,u.json&&(p=u.json.quotaLimited)!=null&&p.includes(AT.FeatureFlags))ft.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var g;s.disable_flags||this.receivedFeatureFlags((g=u.json)!==null&&g!==void 0?g:{},h),this.hi&&(this.hi=!1,this.mi())}}})}}getFeatureFlag(e,t){var r;if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlagResult(e,t);return(r=i?.variant)!==null&&r!==void 0?r:i?.enabled}ft.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants(),i=e in r,s=r[e],o=this.getFlagPayloads()[e],a=String(s),l=this._instance.get_property(f0)||void 0,c=this._instance.get_property(h0)||void 0,u=this._instance.get_property(lu)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var p,f,h,g,v,m,y,w,x;_e(u[e])?u[e].push(a):u[e]=[a],(p=this._instance.persistence)==null||p.register({[lu]:u});var _=this.getFeatureFlagDetails(e),k={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:o||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((f=this._instance.config.bootstrap)==null||(f=f.featureFlags)==null?void 0:f[e])||null,$feature_flag_bootstrapped_payload:((h=this._instance.config.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.vi};H(_==null||(g=_.metadata)==null?void 0:g.version)||(k.$feature_flag_version=_.metadata.version);var I,b=(v=_==null||(m=_.reason)==null?void 0:m.description)!==null&&v!==void 0?v:_==null||(y=_.reason)==null?void 0:y.code;b&&(k.$feature_flag_reason=b),_!=null&&(w=_.metadata)!=null&&w.id&&(k.$feature_flag_id=_.metadata.id),H(_?.original_variant)&&H(_?.original_enabled)||(k.$feature_flag_original_response=H(_.original_variant)?_.original_enabled:_.original_variant),_!=null&&(x=_.metadata)!=null&&x.original_payload&&(k.$feature_flag_original_payload=_==null||(I=_.metadata)==null?void 0:I.original_payload),this._instance.capture("$feature_flag_called",k)}if(i){var A=o;if(!H(o))try{A=JSON.parse(o)}catch{}return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:A}}}else ft.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.pi()&&(i.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:Tn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var o,a=(o=s.json)==null?void 0:o.featureFlagPayloads;t(a?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,t);return H(r)?void 0:!!r}ft.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this._instance.persistence){this.ai=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(o,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var p=kT(o),f=p.flags,h=p.featureFlags,g=p.featureFlagPayloads;if(h){var v=o.requestId,m=o.evaluatedAt;if(_e(h)){ft.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var y={};if(h)for(var w=0;w<h.length;w++)y[h[w]]=!0;a&&a.register({[ch]:h,[ws]:y})}else{var x=h,_=g,k=f;if(o.errorsWhileComputingFlags)if(f){var I=new Set(Object.keys(f).filter((b=>{var A;return!((A=f[b])!=null&&A.failed)})));x=W({},l,Object.fromEntries(Object.entries(x).filter((b=>{var[A]=b;return I.has(A)})))),_=W({},c,Object.fromEntries(Object.entries(_||{}).filter((b=>{var[A]=b;return I.has(A)})))),k=W({},u,Object.fromEntries(Object.entries(k||{}).filter((b=>{var[A]=b;return I.has(A)}))))}else x=W({},l,x),_=W({},c,_),k=W({},u,k);a&&a.register(W({[ch]:Object.keys(g0(x)),[ws]:x||{},[p0]:_||{},[Lh]:k||{}},v?{[f0]:v}:{},m?{[h0]:m}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),ft.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return ft.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(gs),this._instance.persistence.unregister(ca),this.wi(),la.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,r=e;if(this.oi=!!((t=r.suppressWarning)!==null&&t!==void 0&&t),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(gs),la.info("Flag overrides cleared");else if(r.flags){if(_e(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[gs]:i})}else this._instance.persistence.register({[gs]:r.flags});la.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(ca),la.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[ca]:r.payloads}),la.info("Payload overrides set",{payloads:r.payloads}))),void this.wi()}this.wi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ai){var{flags:t,flagVariants:r}=this.xi();e(t,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var i,s=(this._instance.get_property(ga)||[]).find((c=>c.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};s&&(a.$early_access_feature_name=s.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=W({},this.getFlagVariants(),{[e]:t});(i=this._instance.persistence)==null||i.register({[ch]:Object.keys(g0(l)),[ws]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(ga),s=r?"&"+r.map((o=>"stage="+o)).join("&"):"";if(i&&!t)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+s),method:"GET",callback:o=>{var a,l;if(o.json){var c=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(ga),(l=this._instance.persistence)==null||l.register({[ga]:c}),e(c)}}})}xi(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((r=>t[r])),flagVariants:Object.keys(t).filter((r=>t[r])).reduce(((r,i)=>(r[i]=t[i],r)),{})}}wi(e){var{flags:t,flagVariants:r}=this.xi();this.featureFlagEventHandlers.forEach((i=>i(t,r,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(ma)||{};this._instance.register({[ma]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(ma)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(si)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=W({},r[i],e[i]),delete e[i]})),this._instance.register({[si]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(si)||{};this._instance.register({[si]:W({},t,{[e]:{}})})}else this._instance.unregister(si)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.bi(),this.oi=!1}},TT=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],wa=class{constructor(e,t){this.R=e,this.props={},this.Ei=!1,this.$i=(r=>{var i="";return r.token&&(i=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+i+"_posthog"})(e),this.Y=this.Si(e),this.load(),e.debug&&V.info("Persistence loaded",e.persistence,W({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){TT.indexOf(e.persistence.toLowerCase())===-1&&(V.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(i){i===void 0&&(i=[]);var s=[...sT,...i];return W({},Te,{W:function(o){try{var a={};try{a=Yt.W(o)||{}}catch{}var l=Me(a,JSON.parse(Te.q(o)||"{}"));return Te.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,p){try{Te.G(o,a,void 0,void 0,p);var f={};s.forEach((h=>{a[h]&&(f[h]=a[h])})),Object.keys(f).length&&Yt.G(o,f,l,c,u,p)}catch(h){Te.B(h)}},V:function(o,a){try{S?.localStorage.removeItem(o),Yt.V(o,a)}catch(l){Te.B(l)}}})})(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&Te.H()?Te:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&ze.H()?ze:r==="memory"?oT:r==="cookie"?Yt:t.H()?t:Yt}properties(){var e={};return xe(this.props,(function(t,r){if(r===ws&&Be(t))for(var i=Object.keys(t),s=0;s<i.length;s++)e["$feature/"+i[s]]=t[i[s]];else a=r,l=!1,(Mt(o=U1)?l:Rb&&o.indexOf===Rb?o.indexOf(a)!=-1:(xe(o,(function(c){if(l||(l=c===a))return ou})),l))||(e[r]=t);var o,a,l})),e}load(){if(!this.ki){var e=this.Y.W(this.$i);e&&(this.props=Me({},e))}}save(){this.ki||this.Y.G(this.$i,this.props,this.Pi,this.Ti,this.Ii,this.R.debug)}remove(){this.Y.V(this.$i,!1),this.Y.V(this.$i,!0)}clear(){this.remove(),this.props={}}register_once(e,t,r){if(Be(e)){H(t)&&(t="None"),this.Pi=H(r)?this.Ci:r;var i=!1;if(xe(e,((s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=s,i=!0)})),i)return this.save(),!0}return!1}register(e,t){if(Be(e)){this.Pi=H(t)?this.Ci:t;var r=!1;if(xe(e,((i,s)=>{e.hasOwnProperty(s)&&this.props[s]!==i&&(this.props[s]=i,r=!0)})),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.Ei){var e=fw(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);bs($g(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=D?.referrer)?gw(e):{})}update_referrer_info(){var e;this.register_once({$referrer:mw(),$referring_domain:D!=null&&D.referrer&&((e=fu(D.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Hh]||this.props[Bh]||this.register_once({[cu]:vw(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};xe([Bh,Hh],(o=>{var a=this.props[o];a&&xe(a,(function(l,c){e["$initial_"+mh(c)]=l}))}));var t,r,i=this.props[cu];if(i){var s=(t=yw(i),r={},xe(t,(function(o,a){r["$initial_"+mh(a)]=o})),r);Me(e,s)}return e}safe_merge(e){return xe(this.props,(function(t,r){r in e||(e[r]=t)})),e}update_config(e,t,r){if(this.Ci=this.Pi=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every(((u,p)=>u===c[p]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var i=this.Si(e),s=this.props;this.clear(),this.Y=i,this.props=s,this.save()}}set_disabled(e){this.ki=e,this.ki?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ti&&(this.Ti=e,this.remove(),this.save())}set_secure(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_event_timer(e,t){var r=this.props[ha]||{};r[e]=t,this.props[ha]=r,this.save()}remove_event_timer(e){var t=(this.props[ha]||{})[e];return H(t)||(delete this.props[ha][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},m0=Pe("[Product Tours]"),uh="ph_product_tours",og=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[zb]:!(e==null||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Ri||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(zb)||this.it((()=>this.Oi()))}it(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.generateProductTours?e():(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",(i=>{i?m0.error("Could not load product tours script",i):e()}))}Oi(){var e;!this.Ri&&(e=ee.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=ee.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!_e(this.Fi)||t){var r=this._instance.persistence;if(r){var i=r.props[uh];if(_e(i)&&!t)return this.Fi=i,void e(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:s=>{var o=s.statusCode;if(o!==200||!s.json){var a="Product Tours API could not be loaded, status: "+o;return m0.error(a),void e([],{isLoaded:!1,error:a})}var l=_e(s.json.product_tours)?s.json.product_tours:[];this.Fi=l,r&&r.register({[uh]:l}),e(l,{isLoaded:!0})}})}else e(this.Fi,{isLoaded:!0})}getActiveProductTours(e){ve(this.Ri)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ri.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Ri)==null||t.showTourById(e)}previewTour(e){this.Ri?this.Ri.previewTour(e):this.it((()=>{var t;this.Oi(),(t=this.Ri)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Ri)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Ri)==null||e.nextStep()}previousStep(){var e;(e=this.Ri)==null||e.previousStep()}clearCache(){var e;this.Fi=null,(e=this._instance.persistence)==null||e.unregister(uh)}resetTour(e){var t;(t=this.Ri)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Ri)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Ri)==null||t.cancelPendingTour(e)}},ua=(function(n){return n.Activation="events",n.Cancellation="cancelEvents",n})({}),bD=(function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n})({}),wD=(function(n){return n.TopLeft="top_left",n.TopRight="top_right",n.TopCenter="top_center",n.MiddleLeft="middle_left",n.MiddleRight="middle_right",n.MiddleCenter="middle_center",n.Left="left",n.Center="center",n.Right="right",n.NextToTrigger="next_to_trigger",n})({}),xD=(function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n})({}),dh=(function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n})({}),SD=(function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n})({}),ED=(function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n})({}),CD=(function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n})({}),ya=(function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n})({}),ph=(function(n){return n.SURVEY_ID="$survey_id",n.SURVEY_NAME="$survey_name",n.SURVEY_RESPONSE="$survey_response",n.SURVEY_ITERATION="$survey_iteration",n.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",n.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",n.SURVEY_SUBMISSION_ID="$survey_submission_id",n.SURVEY_QUESTIONS="$survey_questions",n.SURVEY_COMPLETED="$survey_completed",n.PRODUCT_TOUR_ID="$product_tour_id",n.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",n})({}),ag=(function(n){return n.Popover="popover",n.Inline="inline",n})({}),we=Pe("[Surveys]"),kw="seenSurvey_",RT=(n,e)=>{var t="$survey_"+e+"/"+n.id;return n.current_iteration&&n.current_iteration>0&&(t="$survey_"+e+"/"+n.id+"/"+n.current_iteration),t},v0=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(kw,n),IT=[dh.Popover,dh.Widget,dh.API],$T={ignoreConditions:!1,ignoreDelay:!1,displayType:ag.Popover},Ta=class{constructor(){this.Mi={},this.Mi={}}on(e,t){return this.Mi[e]||(this.Mi[e]=[]),this.Mi[e].push(t),()=>{this.Mi[e]=this.Mi[e].filter((r=>r!==t))}}emit(e,t){for(var r of this.Mi[e]||[])r(t);for(var i of this.Mi["*"]||[])i(e,t)}};function ms(n,e,t){if(ve(n))return!1;switch(t){case"exact":return n===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(n);case"regex":try{return new RegExp(e).test(n)}catch{return!1}default:return!1}}var lg=class{constructor(e){this.Ai=new Ta,this.ji=(t,r)=>this.Di(t,r)&&this.Li(t,r)&&this.Ni(t,r)&&this.Ui(t,r),this.Di=(t,r)=>r==null||!r.event||t?.event===r?.event,this._instance=e,this.zi=new Set,this.Hi=new Set}init(){var e;if(!H((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook(((r,i)=>{this.on(r,i)}))}}register(e){var t,r;if(!H((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.Hi)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var u;(u=this.zi)==null||u.add(c?.event||"")}))})),(r=this._instance)!=null&&r.autocapture)){var i,s=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&s.add(l?.selector)}))})),(i=this._instance)==null||i.autocapture.setElementSelectors(s)}}on(e,t){var r;t!=null&&e.length!=0&&(this.zi.has(e)||this.zi.has(t?.event))&&this.Hi&&((r=this.Hi)==null?void 0:r.size)>0&&this.Hi.forEach((i=>{this.Bi(t,i)&&this.Ai.emit("actionCaptured",i.name)}))}qi(e){this.onAction("actionCaptured",(t=>e(t)))}Bi(e,t){if(t?.steps==null)return!1;for(var r of t.steps)if(this.ji(e,r))return!0;return!1}onAction(e,t){return this.Ai.on(e,t)}Li(e,t){if(t!=null&&t.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!ms(i,t.url,t.url_matching||"contains"))return!1}return!0}Ni(e,t){return!!this.Wi(e,t)&&!!this.Gi(e,t)&&!!this.Vi(e,t)}Wi(e,t){var r;if(t==null||!t.href)return!0;var i=this.Ji(e);if(i.length>0)return i.some((a=>ms(a.href,t.href,t.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&ms((s=o.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}Gi(e,t){var r;if(t==null||!t.text)return!0;var i=this.Ji(e);if(i.length>0)return i.some((c=>ms(c.text,t.text,t.text_matching||"exact")||ms(c.$el_text,t.text,t.text_matching||"exact")));var s,o,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(s=(function(c){for(var u,p=[],f=/(?::|")text="(.*?)"/g;!ve(u=f.exec(c));)p.includes(u[1])||p.push(u[1]);return p})(l),o=t.text,a=t.text_matching||"exact",s.some((c=>ms(c,o,a))))}Vi(e,t){var r,i;if(t==null||!t.selector)return!0;var s=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(s!=null&&s.includes(t.selector))return!0;var o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}Ji(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Ui(e,t){return t==null||!t.properties||t.properties.length===0||Cw(t.properties.reduce(((r,i)=>{var s=_e(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return r[i.key]={values:s,operator:i.operator||"exact"},r}),{}),e?.properties)}},cg=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&Cw(e.propertyFilters,t?.properties)}Zi(e,t){var r=new Map;return e.forEach((i=>{var s;(s=i.conditions)==null||(s=s[t])==null||(s=s.values)==null||s.forEach((o=>{if(o!=null&&o.name){var a=r.get(o.name)||[];a.push(i.id),r.set(o.name,a)}}))})),r}te(e,t,r){var i=(r===ua.Activation?this.Ki:this.Yi).get(e),s=[];return this.ie((o=>{s=o.filter((a=>i?.includes(a.id)))})),s.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.Qi(l,t)}))}register(e){var t;H((t=this._instance)==null?void 0:t._addCaptureHook)||(this.ee(e),this.re(e))}re(e){var t=e.filter((r=>{var i,s;return((i=r.conditions)==null?void 0:i.actions)&&((s=r.conditions)==null||(s=s.actions)==null||(s=s.values)==null?void 0:s.length)>0}));t.length!==0&&(this.se==null&&(this.se=new lg(this._instance),this.se.init(),this.se.qi((r=>{this.onAction(r)}))),t.forEach((r=>{var i,s,o,a,l;r.conditions&&(i=r.conditions)!=null&&i.actions&&(s=r.conditions)!=null&&(s=s.actions)!=null&&s.values&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.se)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.Xi.get(c.name);u&&u.push(r.id),this.Xi.set(c.name,u||[r.id])}})))})))}ee(e){var t,r=e.filter((s=>{var o,a;return((o=s.conditions)==null?void 0:o.events)&&((a=s.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),i=e.filter((s=>{var o,a;return((o=s.conditions)==null?void 0:o.cancelEvents)&&((a=s.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(r.length!==0||i.length!==0)&&((t=this._instance)==null||t._addCaptureHook(((s,o)=>{this.onEvent(s,o)})),this.Ki=this.Zi(e,ua.Activation),this.Yi=this.Zi(e,ua.Cancellation))}onEvent(e,t){var r,i=this.ne(),s=this.oe(),o=this.ae(),a=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[s])||[];if(o===e&&t&&a.length>0){var l,c;i.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var u=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(u){var p=a.indexOf(u);p>=0&&(a.splice(p,1),this.le(a))}}else{if(this.Yi.has(e)){var f=this.te(e,t,ua.Cancellation);f.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:f.map((g=>g.id))}),f.forEach((g=>{var v=a.indexOf(g.id);v>=0&&a.splice(v,1),this.ue(g.id)})),this.le(a))}if(this.Ki.has(e)){i.info("event name matched",{event:e,eventPayload:t,items:this.Ki.get(e)});var h=this.te(e,t,ua.Activation);this.le(a.concat(h.map((g=>g.id))||[]))}}}onAction(e){var t,r=this.oe(),i=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[r])||[];this.Xi.has(e)&&this.le(i.concat(this.Xi.get(e)||[]))}le(e){var t,r=this.ne(),i=this.oe(),s=[...new Set(e)].filter((o=>!this.he(o)));r.info("updating activated items",{activatedItems:s}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[i]:s})}getActivatedIds(){var e,t=this.oe(),r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return r||[]}getEventToItemsMap(){return this.Ki}de(){return this.se}},ug=class extends cg{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return ya.SHOWN}ie(e){var t;(t=this._instance)==null||t.getSurveys(e)}ue(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}ne(){return we}he(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},dg=class{constructor(e){this.ve=void 0,this._surveyManager=null,this.ce=!1,this.fe=[],this.pe=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(ve(t))return we.warn("Flags not loaded yet. Not loading surveys.");var r=_e(t);this.ve=r?t.length>0:t,we.info("flags response received, isSurveysEnabled: "+this.ve),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var r=localStorage.key(t);(r!=null&&r.startsWith(kw)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.ce)we.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)we.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())we.info("Not loading surveys in cookieless mode without consent.");else{var e=ee?.__PosthogExtensions__;if(e){if(!H(this.ve)||this._instance.config.advanced_enable_surveys){var t=this.ve||this._instance.config.advanced_enable_surveys;this.ce=!0;try{var r=e.generateSurveys;if(r)return void this.ge(r,t);var i=e.loadExternalDependency;if(!i)return void this._e("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",(s=>{s||!e.generateSurveys?this._e("Could not load surveys script",s):this.ge(e.generateSurveys,t)}))}catch(s){throw this._e("Error initializing surveys",s),s}finally{this.ce=!1}}}else we.error("PostHog Extensions not found.")}}ge(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new ug(this._instance),we.info("Surveys loaded successfully"),this.me({isLoaded:!0})}_e(e,t){we.error(e,t),this.me({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.fe.push(e),this._surveyManager&&this.me({isLoaded:!0}),()=>{this.fe=this.fe.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return we.info("Disabled. Not loading surveys."),e([]);var r,i=this._instance.get_property(Nh);if(i&&!t)return e(i,{isLoaded:!0});typeof Promise<"u"&&this.pe?this.pe.then((s=>{var{surveys:o,context:a}=s;return e(o,a)})):(typeof Promise<"u"&&(this.pe=new Promise((s=>{r=s}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:s=>{var o;this.pe=null;var a=s.statusCode;if(a!==200||!s.json){var l="Surveys API could not be loaded, status: "+a;we.error(l);var c={isLoaded:!1,error:l};return e([],c),void(r==null||r({surveys:[],context:c}))}var u,p=s.json.surveys||[],f=p.filter((g=>(function(v){return!(!v.start_date||v.end_date)})(g)&&((function(v){var m;return!((m=v.conditions)==null||(m=m.events)==null||(m=m.values)==null||!m.length)})(g)||(function(v){var m;return!((m=v.conditions)==null||(m=m.actions)==null||(m=m.values)==null||!m.length)})(g))));f.length>0&&((u=this._surveyEventReceiver)==null||u.register(f)),(o=this._instance.persistence)==null||o.register({[Nh]:p});var h={isLoaded:!0};e(p,h),r?.({surveys:p,context:h})}}))}me(e){for(var t of this.fe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(r){we.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!ve(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);we.warn("init was not called")}be(e){var t=null;return this.getSurveys((r=>{var i;t=(i=r.find((s=>s.id===e)))!==null&&i!==void 0?i:null})),t}ye(e){if(ve(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.be(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(ve(this._surveyManager))return we.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.ye(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return ve(this._surveyManager)?(we.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((r=>{this.getSurveys((i=>{var s,o=(s=i.find((l=>l.id===e)))!==null&&s!==void 0?s:null;if(o){var a=this.ye(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,r){var i;if(ve(this._surveyManager))we.warn("init was not called");else{var s=typeof e=="string"?this.be(e):e;if(s!=null&&s.id)if(IT.includes(s.type)){var o=D?.querySelector(t);if(o)return(i=s.appearance)!=null&&i.surveyPopupDelaySeconds?(we.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var a,l;we.info("Rendering survey "+s.id+" with delay of "+((a=s.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(s,o,r),we.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,o,r);we.warn("Survey element not found")}else we.warn("Surveys of type "+s.type+" cannot be rendered in the app");else we.warn("Survey not found")}}displaySurvey(e,t){var r;if(ve(this._surveyManager))we.warn("init was not called");else{var i=this.be(e);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(s=W({},i,{appearance:W({},i.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==ag.Popover&&t.initialResponses&&we.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var o=this.canRenderSurvey(i);if(!o.visible)return void we.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==ag.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else we.warn("Survey not found")}}cancelPendingSurvey(e){ve(this._surveyManager)?we.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},En=Pe("[Conversations]"),pg=class{constructor(e){this.we=void 0,this._conversationsManager=null,this.xe=!1,this.Ee=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;ve(t)||(In(t)?this.we=t:(this.we=t.enabled,this.Ee=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.we=void 0,this.Ee=null}loadIfEnabled(){if(!this._conversationsManager&&!this.xe&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=ee?.__PosthogExtensions__;if(e&&!H(this.we)&&this.we)if(this.Ee&&this.Ee.token){this.xe=!0;try{var t=e.initConversations;if(t)return this.$e(t),void(this.xe=!1);var r=e.loadExternalDependency;if(!r)return void this.Se("PostHog loadExternalDependency extension not found.");r(this._instance,"conversations",(i=>{i||!e.initConversations?this.Se("Could not load conversations script",i):this.$e(e.initConversations),this.xe=!1}))}catch(i){this.Se("Error initializing conversations",i),this.xe=!1}}else En.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),En.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else En.error("Cannot complete initialization: remote config is null")}Se(e,t){En.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():En.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!Mt(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,r){var i=this;return _s((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(En.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var r=this;return _s((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(En.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return _s((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(En.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return _s((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(En.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}},fg=class{constructor(e){var t;this.ke=!1,this.Pe=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.ke=!0)}onRemoteConfig(e){var t,r=(t=e.logs)==null?void 0:t.captureConsoleLogs;!ve(r)&&r&&(this.ke=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.ke&&!this.Pe){var e=Pe("[logs]"),t=ee?.__PosthogExtensions__;if(t){var r=t.loadExternalDependency;r?r(this._instance,"logs",(i=>{var s;i||(s=t.logs)==null||!s.initializeLogs?e.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Pe=!0)})):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}},y0=Pe("[RateLimiter]"),hg=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var r=t.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach((i=>{y0.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void y0.warn('could not rate limit - continuing. Error: "'+i?.message+'"',{text:r})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,r,i;e===void 0&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(r=this.instance.persistence)==null?void 0:r.get_property(Dh))!==null&&t!==void 0?t:{tokens:s,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>s&&(l.tokens=s);var c=l.tokens<1;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(i=this.instance.persistence)==null||i.set_property(Dh,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},ii=Pe("[RemoteConfig]"),gg=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=ee._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Te(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.loadExternalDependency?(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(ii.error("PostHog Extensions not found. Cannot load remote config."),e())}Ie(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return ii.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void ii.warn("Remote config is disabled. Falling back to local config.");this.Te((e=>{if(!e)return ii.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ie((t=>{this.yi(t)}));this.yi(e)}))}catch(e){ii.error("Error loading remote config",e)}}yi(e){e?this._instance.config.__preview_remote_config?(this._instance.yi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):ii.info("__preview_remote_config is disabled. Logging config instead",e):ii.error("Failed to fetch remote config from PostHog.")}},mg=3e3,vg=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=Jt(t?.flush_interval_ms||mg,250,5e3,V.createLogger("flush interval"),mg),this.Oe=e}enqueue(e){this.Re.push(e),this.Me||this.Ae()}unload(){this.je();var e=this.Re.length>0?this.De():{},t=Object.values(e);[...t.filter((r=>r.url.indexOf("/e")===0)),...t.filter((r=>r.url.indexOf("/e")!==0))].map((r=>{this.Oe(W({},r,{transport:"sendBeacon"}))}))}enable(){this.Ce=!1,this.Ae()}Ae(){var e=this;this.Ce||(this.Me=setTimeout((()=>{if(this.je(),this.Re.length>0){var t=this.De(),r=function(){var s=t[i],o=new Date().getTime();s.data&&_e(s.data)&&xe(s.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Oe(s)};for(var i in t)r()}}),this.Fe))}je(){clearTimeout(this.Me),this.Me=void 0}De(){var e={};return xe(this.Re,(t=>{var r,i=t,s=(i?i.batchKey:null)||i.url;H(e[s])&&(e[s]=W({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)})),this.Re=[],e}},PT=["retriesPerformedSoFar"],yg=class{constructor(e){this.Le=!1,this.Ne=3e3,this.Re=[],this._instance=e,this.Re=[],this.Ue=!0,!H(S)&&"onLine"in S.navigator&&(this.Ue=S.navigator.onLine,this.ze=()=>{this.Ue=!0,this.Lt()},this.He=()=>{this.Ue=!1},Fe(S,"online",this.ze),Fe(S,"offline",this.He))}get length(){return this.Re.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=E0(e,PT);vs(t)&&(r.url=bu(r.url,{retry_count:t})),this._instance._send_request(W({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Be(W({retriesPerformedSoFar:t},r)):r.callback==null||r.callback(i)}}))}Be(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var r=(function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(t),i=Date.now()+r;this.Re.push({retryAt:i,requestOptions:e});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),V.warn(s),this.Le||(this.Le=!0,this.qe())}qe(){if(this.We&&clearTimeout(this.We),this.Re.length===0)return this.Le=!1,void(this.We=void 0);this.We=setTimeout((()=>{this.Ue&&this.Re.length>0&&this.Lt(),this.qe()}),this.Ne)}Lt(){var e=Date.now(),t=[],r=this.Re.filter((s=>s.retryAt<e||(t.push(s),!1)));if(this.Re=t,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.We&&(clearTimeout(this.We),this.We=void 0),this.Le=!1,H(S)||(this.ze&&(S.removeEventListener("online",this.ze),this.ze=void 0),this.He&&(S.removeEventListener("offline",this.He),this.He=void 0)),this.Re))try{this._instance._send_request(W({},e,{transport:"sendBeacon"}))}catch(t){V.error(t)}this.Re=[]}},_g=class{constructor(e){this.Ge=()=>{var t,r,i,s;this.Ve||(this.Ve={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,c=a+(o?.clientHeight||0),u=o?.scrollHeight||0;this.Ve.lastScrollY=Math.ceil(a),this.Ve.maxScrollY=Math.max(a,(t=this.Ve.maxScrollY)!==null&&t!==void 0?t:0),this.Ve.maxScrollHeight=Math.max(l,(r=this.Ve.maxScrollHeight)!==null&&r!==void 0?r:0),this.Ve.lastContentY=c,this.Ve.maxContentY=Math.max(c,(i=this.Ve.maxContentY)!==null&&i!==void 0?i:0),this.Ve.maxContentHeight=Math.max(u,(s=this.Ve.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=e}getContext(){return this.Ve}resetContext(){var e=this.Ve;return setTimeout(this.Ge,0),e}startMeasuringScrollPosition(){Fe(S,"scroll",this.Ge,{capture:!0}),Fe(S,"scrollend",this.Ge,{capture:!0}),Fe(S,"resize",this.Ge)}scrollElement(){if(!this._instance.config.scroll_root_selector)return S?.document.documentElement;var e=_e(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var r=S?.document.querySelector(t);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return S&&(S.scrollY||S.pageYOffset||S.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return S&&(S.scrollX||S.pageXOffset||S.document.documentElement.scrollLeft)||0}},OT=n=>vw(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),xu=class{constructor(e,t,r,i){this.Je=s=>{var o=this.Ke();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Ye(this._instance)};this.Xe.register({[Fh]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||OT,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[Fh]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?yw(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return xe($g(this.getSetOnceProps()),((t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+mh(r)]=t})),e}},fh=Pe("[SessionId]"),Su=class{on(e,t){return this.Ze.on(e,t)}constructor(e,t,r){var i;if(this.tr=[],this.ir=void 0,this.Ze=new Ta,this.er=(u,p)=>!(!vs(u)||!vs(p))&&Math.abs(u-p)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.Xe=e.persistence,this.rr=void 0,this.sr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.nr=t||cr,this.ar=r||cr;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Jt(o,60,36e3,fh.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.lr(),this.ur="ph_"+s+"_window_id",this.hr="ph_"+s+"_primary_window_exists",this.dr()){var a=ze.W(this.ur),l=ze.W(this.hr);a&&!l?this.rr=a:ze.V(this.ur),ze.G(this.hr,!0)}if((i=this.R.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var p=u.replace(/-/g,"");if(p.length!==32)throw new Error("Not a valid UUID");if(p[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(p.substring(0,12),16)})(this.R.bootstrap.sessionID);this.vr(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){fh.error("Invalid sessionID in bootstrap",u)}this.cr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return H(this.tr)&&(this.tr=[]),this.tr.push(e),this.sr&&e(this.sr,this.rr),()=>{this.tr=this.tr.filter((t=>t!==e))}}dr(){return this.R.persistence!=="memory"&&!this.Xe.ki&&ze.H()}pr(e){e!==this.rr&&(this.rr=e,this.dr()&&ze.G(this.ur,e))}gr(){return this.rr?this.rr:this.dr()?ze.W(this.ur):null}vr(e,t,r){e===this.sr&&t===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=t,this.sr=e,this.Xe.register({[au]:[t,e,r]}))}_r(){var e=this.Xe.props[au];return _e(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.vr(null,null,null)}destroy(){clearTimeout(this.mr),this.mr=void 0,this.ir&&S&&(S.removeEventListener("beforeunload",this.ir,{capture:!1}),this.ir=void 0),this.tr=[]}cr(){this.ir=()=>{this.dr()&&ze.V(this.hr)},Fe(S,"beforeunload",this.ir,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=t||new Date().getTime(),[i,s,o]=this._r(),a=this.gr(),l=vs(o)&&Math.abs(r-o)>864e5,c=!1,u=!s,p=!u&&!e&&this.er(r,i);u||p||l?(s=this.nr(),a=this.ar(),fh.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}}),o=r,c=!0):a||(a=this.ar(),c=!0);var f=vs(i)&&e&&!l?i:r,h=vs(o)?o:new Date().getTime();return this.pr(a),this.vr(s,f,h),e||this.lr(),c&&this.tr.forEach((g=>g(s,a,c?{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}:void 0))),{sessionId:s,windowId:a,sessionStartTimestamp:h,changeReason:c?{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}lr(){clearTimeout(this.mr),this.mr=setTimeout((()=>{var[e]=this._r();if(this.er(new Date().getTime(),e)){var t=this.sr;this.resetSessionId(),this.Ze.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},MT=["$set_once","$set"],ar=Pe("[SiteApps]"),bg=class{constructor(e){this._instance=e,this.br=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}yr(e,t){if(t){var r=this.globalsForEvent(t);this.br.push(r),this.br.length>1e3&&(this.br=this.br.slice(10))}}get siteAppLoaders(){var e;return(e=ee._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.yr.bind(this));this.wr=()=>{e(),this.br=[],this.wr=void 0}}}globalsForEvent(e){var t,r,i,s,o,a,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],p=this._instance.get_property("$stored_group_properties")||{};for(var[f,h]of Object.entries(p))c[f]={id:u[f],type:f,properties:h};var{$set_once:g,$set:v}=e;return{event:W({},E0(e,MT),{properties:W({},e.properties,v?{$set:W({},(t=(r=e.properties)==null?void 0:r.$set)!==null&&t!==void 0?t:{},v)}:{},g?{$set_once:W({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},g)}:{}),elements_chain:(o=(a=e.properties)==null?void 0:a.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],r=()=>{var a;!t.errored&&this.br.length&&(ar.info("Processing "+this.br.length+" events for site app with id "+e.id),this.br.forEach((l=>t.processEvent==null?void 0:t.processEvent(l))),t.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((a=this.wr)==null||a.call(this))},i=!1,s=a=>{t.errored=!a,t.loaded=!0,ar.info("Site app with id "+e.id+" "+(a?"loaded":"errored")),i&&r()};try{var{processEvent:o}=e.init({posthog:this._instance,callback:a=>{s(a)}});o&&(t.processEvent=o),i=!0}catch(a){ar.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&t.loaded)try{r()}catch(a){ar.error("Error while processing buffered events PostHog app with config id "+e.id,a),t.errored=!0}}Er(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}$r(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(t)}catch(i){ar.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var t,r,i,s=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Er(),void this._instance.on("eventCaptured",(c=>this.$r(c)))):void ar.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.wr)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(c){var u;ee["__$$ph_site_app_"+c]=s._instance,(u=ee.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(s._instance,l,(p=>{if(p)return ar.error("Error while initializing PostHog app with config id "+c,p)}))};for(var{id:a,url:l}of e.siteApps)o(a)}else ar.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},Aw=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&Pb(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>Pb(i?.brand,e))))return!0}catch{}return!!n.webdriver},_a=(function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n})({}),_0="i.posthog.com",wg=class{constructor(e){this.Sr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+_0,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Sr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=_a.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=_a.EU:this.Sr[this.apiHost]=_a.CUSTOM),this.Sr[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===_a.CUSTOM)return this.apiHost+t;var r=_0+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},LT={icontains:(n,e)=>!!S&&e.href.toLowerCase().indexOf(n.toLowerCase())>-1,not_icontains:(n,e)=>!!S&&e.href.toLowerCase().indexOf(n.toLowerCase())===-1,regex:(n,e)=>!!S&&wu(e.href,n),not_regex:(n,e)=>!!S&&!wu(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},xg=class n{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),t.getWebExperiments((i=>{n.kr("retrieved web experiments from the server"),t.Pr=new Map,i.forEach((s=>{if(s.feature_flag_key){var o;t.Pr&&(n.kr("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=t.Pr)==null||o.set(s.feature_flag_key,s));var a=t._instance.getFeatureFlag(s.feature_flag_key);Ve(a)&&s.variants[a]&&t.Tr(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var c=s.variants[l];n.Ir(c)&&t.Tr(s.name,l,c.transforms)}}))}),r)},this._instance=e,this._instance.onFeatureFlags((r=>{this.onFeatureFlags(r)}))}onFeatureFlags(e){if(this._is_bot())n.kr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(ve(this.Pr))return this.Pr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();n.kr("applying feature flags",e),e.forEach((t=>{var r;if(this.Pr&&(r=this.Pr)!=null&&r.has(t)){var i,s=this._instance.getFeatureFlag(t),o=(i=this.Pr)==null?void 0:i.get(t);s&&o!=null&&o.variants[s]&&this.Tr(o.name,s,o.variants[s].transforms)}}))}}previewWebExperiment(){var e=n.getWindowLocation();if(e!=null&&e.search){var t=hu(e?.search,"__experiment_id"),r=hu(e?.search,"__experiment_variant");t&&r&&(n.kr("previewing web experiments "+t+" && "+r),this.getWebExperiments((i=>{this.Cr(parseInt(t),r,i)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!t)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:s=>{if(s.statusCode!==200||!s.json)return e([]);var o=s.json.experiments||[];return e(o)}})}Cr(e,t,r){var i=r.filter((s=>s.id===e));i&&i.length>0&&(n.kr("Previewing web experiment ["+i[0].name+"] with variant ["+t+"]"),this.Tr(i[0].name,t,i[0].variants[t].transforms))}static Ir(e){return!ve(e.conditions)&&n.Rr(e)&&n.Fr(e)}static Rr(e){var t;if(ve(e.conditions)||ve((t=e.conditions)==null?void 0:t.url))return!0;var r,i,s,o=n.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||LT[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return S?.location}static Fr(e){var t;if(ve(e.conditions)||ve((t=e.conditions)==null?void 0:t.utm))return!0;var r=fw();if(r.utm_source){var i,s,o,a,l,c,u,p,f=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_campaign)==r.utm_campaign,h=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,g=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==r.utm_medium,v=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((p=e.conditions)==null||(p=p.utm)==null?void 0:p.utm_term)==r.utm_term;return f&&g&&v&&h}return!1}static kr(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];V.info("[WebExperiments] "+e,r)}Tr(e,t,r){this._is_bot()?n.kr("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?r.forEach((i=>{if(i.selector){var s;n.kr("applying transform of variant "+t+" for experiment "+e+" ",i);var o=(s=document)==null?void 0:s.querySelectorAll(i.selector);o?.forEach((a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)}))}})):n.kr("Control variants leave the page unmodified.")}_is_bot(){return ht&&this._instance?Aw(ht,this._instance.config.custom_blocked_useragents):void 0}},NT=Pe("[PostHog ExternalIntegrations]"),FT={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Sg=class{constructor(e){this._instance=e}it(e,t){var r;(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(i=>{if(i)return NT.error("failed to load script",i);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!i||(a=ee.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(FT[o],(()=>{var u;(u=ee.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!i&&(l=ee.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=ee.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[r,i]of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;t(r)}}},Eg="[SessionRecording]",da=Pe(Eg),Eu=class{get started(){var e;return!((e=this.Or)==null||!e.isStarted)}get status(){return this.Or?this.Or.status:this.Mr&&!this.Ar?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Mr=!1,this.jr=void 0,this._instance=e,!this._instance.sessionManager)throw da.error("started without valid sessionManager"),new Error(Eg+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Eg+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(eh))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return S&&t&&r&&!i}startIfEnabledOrStop(e){var t;if(!this.Ar||(t=this.Or)==null||!t.isStarted){var r=!H(Object.assign)&&!H(Array.from);this.Ar&&r?(this.Dr(e),da.info("starting")):this.stopRecording()}}Dr(e){var t,r,i;this.Ar&&(ee!=null&&(t=ee.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(r=ee.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Lr(e):(i=ee.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Nr,(s=>{if(s)return da.error("could not load recorder",s);this.Lr(e)})))}stopRecording(){var e,t;(e=this.jr)==null||e.call(this),this.jr=void 0,(t=this.Or)==null||t.stop()}Ur(){var e;(e=this._instance.persistence)==null||e.unregister(Y0)}zr(e){if(this._instance.persistence){var t,r,i=this._instance.persistence,s=()=>{var o=e.sessionRecording===!1?void 0:e.sessionRecording,a=o?.sampleRate,l=ve(a)?null:parseFloat(a);ve(l)&&this.Ur();var c=o?.minimumDurationMilliseconds;i.register({[eh]:W({enabled:!!o},o,{networkPayloadCapture:W({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:H(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};s(),(t=this.jr)==null||t.call(this),this.jr=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.zr(e),this.Mr=!0,this.startIfEnabledOrStop()):this.Mr=!0:da.info("skipping remote config with no sessionRecording",e)}log(e,t){var r;t===void 0&&(t="log"),(r=this.Or)!=null&&r.log?this.Or.log(e,t):da.warn("log called before recorder was ready")}get Nr(){var e,t,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(eh);return(r==null||(t=r.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Lr(e){var t,r;if((t=ee.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Or||(this.Or=(r=ee.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.Or._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Or.start(e)}onRRwebEmit(e){var t;(t=this.Or)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Or)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_sampling:!0}),(e=this.Or)==null||e.overrideSampling()}overrideTrigger(e){var t,r;this.Or||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Or)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Or)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var r;return!((r=this.Or)==null||!r.tryAddCustomEvent(e,t))}},xa={},Cg=()=>{},ys="posthog",Tw=!CT&&ct?.indexOf("MSIE")===-1&&ct?.indexOf("Mozilla")===-1,b0=n=>{var e;return W({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:V1(D?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Cg,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:n??"unset",__preview_deferred_init_extensions:!1,debug:qe&&Ve(qe?.search)&&qe.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(S==null||(e=S.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var r="Bad HTTP status: "+t.statusCode+" "+t.text;V.error(r)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:mg},error_tracking:{},_onCapture:Cg,__preview_eager_load_replay:!1},(t=>({rageclick:!(t&&t>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(t&&t>="2025-05-24")||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(n))},w0=n=>{var e={};H(n.process_person)||(e.person_profiles=n.process_person),H(n.xhr_headers)||(e.request_headers=n.xhr_headers),H(n.cookie_name)||(e.persistence_name=n.cookie_name),H(n.disable_cookie)||(e.disable_persistence=n.disable_cookie),H(n.store_google)||(e.save_campaign_params=n.store_google),H(n.verbose)||(e.debug=n.verbose);var t=Me({},e,n);return _e(n.property_blacklist)&&(H(n.property_denylist)?t.property_denylist=n.property_blacklist:_e(n.property_denylist)?t.property_denylist=[...n.property_blacklist,...n.property_denylist]:V.error("Invalid value for property_denylist config: "+n.property_denylist)),t},kg=class{constructor(){this.__forceAllowLocalhost=!1}get Hr(){return this.__forceAllowLocalhost}set Hr(e){V.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Cu=class n{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new kg,this.Br=!1,this.version=Cn.LIB_VERSION,this.qr=new Ta,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=b0(),this.SentryIntegration=Kh,this.sentryIntegration=e=>(function(t,r){var i=pw(t,r);return{name:dw,processEvent:s=>i(s)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new sg(this),this.toolbar=new Yh(this),this.scrollManager=new _g(this),this.pageViewManager=new vu(this),this.surveys=new dg(this),this.conversations=new pg(this),this.logs=new fg(this),this.experiments=new xg(this),this.exceptions=new ig(this),this.rateLimiter=new hg(this),this.requestRouter=new wg(this),this.consent=new qh(this),this.externalIntegrations=new Sg(this),this.people={set:(e,t,r)=>{var i=Ve(e)?{[e]:t}:e;this.setPersonProperties(i),r?.({})},set_once:(e,t,r)=>{var i=Ve(e)?{[e]:t}:e;this.setPersonProperties(void 0,i),r?.({})}},this.on("eventCaptured",(e=>V.info('send "'+e?.event+'"',e)))}init(e,t,r){if(r&&r!==ys){var i,s=(i=xa[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),xa[r]=s,xa[ys][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),H(e)||vh(e))return V.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(Me({},b0(t.defaults),w0(t),{name:r,token:e})),this.config.on_xhr_error&&V.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Tn.GZipJS;var s=this.Qr();this.persistence=new wa(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new wa(W({},this.config,{persistence:"sessionStorage"}),s);var o=W({},this.persistence.props),a=W({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new vg((w=>this.ts(w)),this.config.request_queue_config),this.es=new yg(this),this.__request_queue=[];var l=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new Su(this),this.sessionPropsManager=new xu(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(V.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.rs(l)}),0)):(V.info("Initializing extensions synchronously"),this.rs(l)),Cn.DEBUG=Cn.DEBUG||this.config.debug,Cn.DEBUG&&V.info("Starting in debug mode",{this:this,config:t,thisC:W({},this.config),p:o,s:a}),((i=t.bootstrap)==null?void 0:i.distinctID)!==void 0){var c,u,p=this.config.get_device_id(cr()),f=(c=t.bootstrap)!=null&&c.isIdentifiedID?p:t.bootstrap.distinctID;this.persistence.set_property(kn,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:f})}if(this.ss()){var h,g,v=Object.keys(((h=t.bootstrap)==null?void 0:h.featureFlags)||{}).filter((w=>{var x;return!((x=t.bootstrap)==null||(x=x.featureFlags)==null||!x[w])})).reduce(((w,x)=>{var _;return w[x]=((_=t.bootstrap)==null||(_=_.featureFlags)==null?void 0:_[x])||!1,w}),{}),m=Object.keys(((g=t.bootstrap)==null?void 0:g.featureFlagPayloads)||{}).filter((w=>v[w])).reduce(((w,x)=>{var _,k;return(_=t.bootstrap)!=null&&(_=_.featureFlagPayloads)!=null&&_[x]&&(w[x]=(k=t.bootstrap)==null||(k=k.featureFlagPayloads)==null?void 0:k[x]),w}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:m})}if(l)this.register_once({distinct_id:ra,$device_id:null},"");else if(!this.get_distinct_id()){var y=this.config.get_device_id(cr());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(kn,"anonymous")}return Fe(S,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?cT(this,(()=>this.ns())):this.ns(),ur(this.config._onCapture)&&this.config._onCapture!==Cg&&(V.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(w=>this.config._onCapture(w.event,w)))),this.config.ip&&V.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}rs(e){var t=performance.now();this.historyAutocapture=new Gh(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new Jh(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new bg(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new Eu(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new Uh(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.logs.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new og(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new Qh(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new Xh(this)})),r.push((()=>{this.exceptionObserver=new Zh(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new mu(this,lT),this.deadClicksAutocapture.startIfEnabled()})),r.push((()=>{if(this.os){var i=this.os;this.os=void 0,this.yi(i)}})),this.ls(r,t)}ls(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.ls(e,t)}),0);var r=e.shift();if(r)try{r()}catch(s){V.error("Error initializing extension:",s)}}var i=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:i}),this.config.__preview_deferred_init_extensions&&V.info("PostHog extensions initialized ("+i+"ms)")}yi(e){var t,r,i,s,o,a,l,c,u;if(!D||!D.body)return V.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.yi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.os=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=me(e.supportedCompression,Tn.GZipJS)?Tn.GZipJS:me(e.supportedCompression,Tn.Base64)?Tn.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"identified_only"}),(r=this.siteApps)==null||r.onRemoteConfig(e),(i=this.sessionRecording)==null||i.onRemoteConfig(e),(s=this.autocapture)==null||s.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(r){V.critical("`loaded` function failed",r)}if(this.us(),this.config.internal_or_test_user_hostname&&qe!=null&&qe.hostname){var e=qe.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.hs()}),1),new gg(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Zr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&dr(this.__request_queue,(e=>this.ts(e))),this.__request_queue=[],this.us()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.ds()&&this.capture("$pageleave"),(e=this.Zr)==null||e.unload(),(t=this.es)==null||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(Tw?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=bu(e.url,{ip:this.config.ip?1:0}),e.headers=W({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var r,i,s,o=W({},t);o.timeout=o.timeout||6e4,o.url=bu(o.url,{_:new Date().getTime().toString(),ver:Cn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=ru.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(i=(s=Z0(l,(u=>u.transport===a)))==null?void 0:s.method)!==null&&i!==void 0?i:l[0].method;if(!c)throw new Error("No available transport method");c(o)})(W({},e,{callback:t=>{var r,i;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,t)),e.callback==null||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,r=[],i=[],s=[];dr(e,(a=>{a&&(t=a[0],_e(t)?s.push(a):ur(a)?a.call(this):_e(a)&&t==="alias"?r.push(a):_e(a)&&t.indexOf("capture")!==-1&&ur(this[t])?s.push(a):i.push(a))}));var o=function(a,l){dr(a,(function(c){if(_e(c[0])){var u=l;xe(c,(function(p){u=u[p[0]].apply(u,p.slice(1))}))}else this[c[0]].apply(this,c.slice(1))}),l)};o(r,this),o(i,this),o(s,this)}ss(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!H(e)&&Ve(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(s&&!this.config.__preview_capture_bot_pageviews)){var o=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!Ve(t?.$current_url)&&(V.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=r?.timestamp||a,c=cr(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),r?.$set&&(u.$set=r?.$set);var p,f=e!=="$groupidentify",h=this.vs(r?.$set_once,f);if(h&&(u.$set_once=h),(u=H1(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,H(r?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===ya.DISMISSED||e===ya.SENT){var g=t?.[ph.SURVEY_ID],v=t?.[ph.SURVEY_ITERATION];p={id:g,current_iteration:v},localStorage.getItem(v0(p))||localStorage.setItem(v0(p),"true"),u.$set=W({},u.$set,{[RT({id:g,current_iteration:v},e===ya.SENT?"responded":"dismissed")]:!0})}else e===ya.SHOWN&&(u.$set=W({},u.$set,{[ph.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var m=W({},u.properties.$set,u.$set);if(bs(m)||this.setPersonPropertiesForFlags(m),!ve(this.config.before_send)){var y=this.cs(u);if(!y)return;u=y}this.qr.emit("eventCaptured",u);var w={method:"POST",url:(i=r?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:r?._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.ts(w):this.Zr.enqueue(w),u}V.critical("This capture call is ignored due to client rate limiting.")}}else V.error("No event name provided to posthog.capture")}else V.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var o=s?void 0:this.persistence.remove_event_timer(e),a=W({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=W({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!Ve(a.distinct_id)&&!$n(a.distinct_id)||vh(a.distinct_id))&&V.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=gT(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:p,windowId:f}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=p,a.$window_id=f}this.sessionPropsManager&&Me(a,this.sessionPropsManager.getSessionProps());try{var h;this.sessionRecording&&Me(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(h=this.es)==null?void 0:h.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}if(this.requestRouter.region===_a.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||s?e!=="$pageleave"||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=Me(a,c),e==="$pageview"&&D&&(a.title=D.title),!H(o)){var g=r.getTime()-o;a.$duration=parseFloat((g/1e3).toFixed(3))}ct&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Me({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),_e(this.config.property_denylist)?xe(this.config.property_denylist,(function(y){delete a[y]})):V.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(V.error("sanitize_properties is deprecated. Use before_send instead"),a=v(a,e));var m=this.fs();return a.$process_person_profile=m,m&&!s&&this.ps("_calculate_event_properties"),a}vs(e,t){var r;if(t===void 0&&(t=!0),!this.persistence||!this.fs()||this.Br)return e;var i=this.persistence.get_initial_props(),s=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),o=Me({},i,s||{},e||{}),a=this.config.sanitize_properties;return a&&(V.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.Br=!0),bs(o)?void 0:o}register(e,t){var r;(r=this.persistence)==null||r.register(e,t)}register_once(e,t,r){var i;(i=this.persistence)==null||i.register_once(e,t,r)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}gs(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,r){var i=r!=null&&r.merge?this.featureFlags.getFlagVariants():{},s=r!=null&&r.merge?this.featureFlags.getFlagPayloads():{},o=W({},i,e),a=W({},s,t),l={};for(var[c,u]of Object.entries(o)){var p=typeof u=="string";l[c]={key:c,enabled:!!p||!!u,variant:p?u:void 0,reason:void 0,metadata:H(a?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,r)}getEarlyAccessFeatures(e,t,r){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,r)}on(e,t){return this.qr.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,r;return(t=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){t===void 0&&(t=$T),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,r){if(!this.__loaded||!this.persistence)return V.uninitializedWarning("posthog.identify");if($n(e)&&(e=e.toString(),V.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))V.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==ra){if(this.ps("posthog.identify")){var i=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var s=i;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==i&&e!==this.get_property(fa)&&(this.unregister(fa),this.register({distinct_id:e}));var o=(this.persistence.get_property(kn)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(kn,"identified"),this.setPersonPropertiesForFlags(W({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=d0(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(lu))}}else V.critical('The string "'+ra+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else V.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var r=d0(this.get_distinct_id(),e,t);this.Jr!==r?(this.setPersonPropertiesForFlags(W({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=r):V.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,r){if(e&&t){var i=this.getGroups();i[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:W({},i,{[e]:t})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===t||r||this.reloadFeatureFlags()}else V.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,r,i,s;if(V.info("reset"),!this.__loaded)return V.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(kn,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:ra,$device_id:null},"");else{var a=this.config.get_device_id(cr());this.register_once({distinct_id:a,$device_id:e?a:o},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&r){var s,o=(s=e.timestampLookBack)!==null&&s!==void 0?s:10;if(!r)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return i}alias(e,t){return e===this.get_property(G0)?(V.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(H(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(fa,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(V.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=W({},this.config);if(Be(e)){var r,i,s,o,a,l,c;Me(this.config,w0(e));var u=this.Qr();(r=this.persistence)==null||r.update_config(this.config,t,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new wa(W({},this.config,{persistence:"sessionStorage"}),u);var p=this.Kr(this.config.debug);In(p)&&(this.config.debug=p),In(this.config.debug)&&(this.config.debug?(Cn.DEBUG=!0,Te.H()&&Te.G("ph_debug","true"),V.info("set_config",{config:e,oldConfig:t,newConfig:W({},this.config)})):(Cn.DEBUG=!1,Te.H()&&Te.V("ph_debug"))),(i=this.exceptionObserver)==null||i.onConfigChange(),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),(c=this.externalIntegrations)==null||c.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,r={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(e==null||!e.event_trigger)};if(Object.values(r).some(Boolean)){var i,s,o,a,l;(i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),r.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),r.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),r.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),r.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(W({},i,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:ys;return t!==ys&&(t=ys+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(kn))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(kn))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&bs(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[fa])&&((t=this.persistence)==null||(t=t.props)==null||!t[uu]))}ds(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return this.config.person_profiles==="never"?(V.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(uu,!0),!0)}Qr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!t}_s(){var e,t,r,i,s=this.Qr();return((e=this.persistence)==null?void 0:e.ki)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((t=this.sessionPersistence)==null?void 0:t.ki)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){var r,i,s;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new Su(this),this.pageViewManager=new vu(this),this.persistence&&(this.sessionPropsManager=new xu(this,this.sessionManager,this.persistence)),this.sessionRecording=new Eu(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(H(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((s=e?.captureEventName)!==null&&s!==void 0?s:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.hs()}else V.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,r;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:ra,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(r=this.sessionRecording)==null||r.stopRecording(),this.sessionRecording=void 0,this.hs())):V.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===An.GRANTED?"granted":e===An.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._s()}_is_bot(){return ht?Aw(ht,this.config.custom_blocked_useragents):void 0}hs(){D&&(D.visibilityState==="visible"?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:D.title},{send_instantly:!0}),this.Gr&&(D.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),Fe(D,"visibilitychange",this.Gr)))}debug(e){e===!1?(S?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(S?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}M(){var e,t,r,i,s,o,a,l=this.Yr||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(V.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(r="advanced_disable_decide",i=!1,s=V,o=(t="advanced_disable_flags")in(e=l)&&!ve(e[t]),a=r in e&&!ve(e[r]),o?e[t]:a?(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[r]):i)}cs(e){if(ve(this.config.before_send))return e;var t=_e(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of t){if(r=i(r),ve(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return p1(e.event)?V.warn(s+". This can cause unexpected behavior."):V.info(s),null}r.properties&&!bs(r.properties)||V.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(r)})}Kr(e){var t=In(e)&&!e,r=Te.H()&&Te.q("ph_debug")==="true";return!t&&(!!r||e)}};(function(n,e){for(var t=0;t<e.length;t++)n.prototype[e[t]]=D1(n.prototype[e[t]])})(Cu,["identify"]);var x0;var Rw=(x0=xa[ys]=new Cu,(function(){function n(){n.done||(n.done=!0,Tw=!1,xe(xa,(function(e){e._dom_loaded()})))}D!=null&&D.addEventListener?D.readyState==="complete"?n():Fe(D,"DOMContentLoaded",n,{capture:!1}):S&&V.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),x0);var Fg=class{constructor(e={}){this.options=e;if(this.client=e.client,this.featureFlagsCallback=e.onFeatureFlagsLoaded,this.captureCallback=e.onCapture,this.rrwebCallback=e.onRRWebEvent,!this.client&&e.consent&&e.requireExplicitConsent&&typeof window<"u"&&e.apiKey){let t=e.consent;t.getStatus()==="granted"&&this.initPostHog(),t.subscribe(i=>{i==="granted"?this.client?this.client.opt_in_capturing():this.initPostHog():i==="denied"&&this.client&&this.client.opt_out_capturing()});return}!this.client&&typeof window<"u"&&e.apiKey&&this.initPostHog()}initPostHog(){let e=this.options;if(!e.apiKey)return;let t=e.enableFeatureFlags??!0,r=`syntro_${e.apiKey.slice(-6)||"sdk"}`,o={api_host:`${(e.apiHost??"https://telemetry.syntrologie.com").replace(/\/$/,"")}/t/${e.apiKey}`,advanced_disable_feature_flags:!t,advanced_disable_feature_flags_on_first_load:!t,autocapture:e.autocapture??!0,capture_pageview:e.capturePageview??"history_change",capture_pageleave:e.capturePageleave??!0,disable_session_recording:!(e.sessionRecording??!0),opt_out_useragent_filter:!0,session_recording:{recordCrossDomainIFrames:!0},capture_performance:!0,enable_recording_console_log:!0};e.cookieless_mode&&(o.cookieless_mode=e.cookieless_mode);let a=Rw.init(e.apiKey,o,r);if(a&&(this.client=a),this.captureCallback&&this.client&&this.client.on("eventCaptured",(...l)=>{let c=l[0],u=typeof c=="string"?c:c?.event,p=typeof c=="string"?void 0:c?.properties;typeof u=="string"&&this.captureCallback?.(u,p)}),t&&this.featureFlagsCallback&&this.client){this.client.onFeatureFlags(()=>{let c=this.getAllFeatureFlags();c&&this.featureFlagsCallback&&this.featureFlagsCallback(c)});let l=this.getAllFeatureFlags();l&&Object.keys(l).length>0&&this.featureFlagsCallback(l)}this.rrwebCallback&&this.client&&this.setupRRWebIntercept()}setupRRWebIntercept(e=30){let t=this.client?.sessionRecording;if(!t){e>0&&setTimeout(()=>this.setupRRWebIntercept(e-1),500);return}let r=null,i=t;for(let o of Object.getOwnPropertyNames(i)){let a=i[o];if(a&&typeof a=="object"&&typeof a.onRRwebEmit=="function"&&typeof a.start=="function"&&a!==t){r=a;break}}if(!r){e>0&&setTimeout(()=>this.setupRRWebIntercept(e-1),500);return}let s=r.onRRwebEmit.bind(r);r.onRRwebEmit=o=>{this.rrwebCallback?.({kind:"rrweb",...o}),s(o)},typeof window<"u"&&(window.__RRWEB_INTERCEPT_READY__=!0)}getAllFeatureFlags(){return this.client?.featureFlags?.getFlagVariants()}getSegmentFlags(){let e=this.getAllFeatureFlags();if(!e)return{};let t={};for(let[r,i]of Object.entries(e))r.startsWith("in_segment_")&&(t[r]=i===!0);return t}identify(e,t){this.client?.identify(e,t)}alias(e,t){this.client?.alias(e,t)}optInCapturing(){this.client?.opt_in_capturing()}optOutCapturing(){this.client?.opt_out_capturing()}track(e,t){this.client?.capture(e,t)}trackCanvasOpened(e){this.track("shadow_canvas_opened",{surface:e})}trackCanvasClosed(e){this.track("shadow_canvas_closed",{surface:e})}trackRectangleViewed(e,t){this.track("shadow_canvas_rectangle_viewed",{rectangleId:e,surface:t})}trackAction(e,t,r){this.track("shadow_canvas_action",{action:e,rectangleId:t,surface:r})}register(e){this.client?.register?.(e)}getSessionId(){return this.client?.get_session_id?.()}startSessionRecording(){this.client?.startSessionRecording?.()}trackExperiment(e,t,r){let i=`$experiment_${e}`;this.register({[i]:r??`variation_${t}`,[`${i}_id`]:t}),this.track("$experiment_started",{$experiment_key:e,$experiment_variation_id:t,$experiment_variation_name:r??`variation_${t}`})}setPersonProperties(e){this.client?.capture("$set",{$set:e})}setPersonPropertiesOnce(e){this.client?.capture("$set",{$set_once:e})}getDistinctId(){return this.client?.get_distinct_id?.()}};function Ru(n={}){return new Fg(n)}var Iw={posthog:n=>Ru(n),noop:()=>Yc()};function $w(n,e){let t=Iw[n];if(!t)throw new Error(`Unknown telemetry provider: ${n}. Supported: ${Object.keys(Iw).join(", ")}`);return t(e)}function DT(n){return n?.manifest?.runtime!==void 0}async function Pw(n){$p(),q("Syntro Bootstrap","====== INIT ======"),q("Syntro Bootstrap","Options:",{hasToken:!!n.token,tokenPrefix:`${n.token?.slice(0,15)}...`,hasCanvasOptions:!!n.canvas});let e=xc();if(console.log(`[DIAG] Mode detection: sdkMode=${e}`),console.log("[DIAG] editorSource:",Bo()),console.log("[DIAG] editorConf:",wc()),q("Syntro Bootstrap","SDK mode:",e??"normal"),!e&&typeof window<"u"){let R=!!window.__SYNTRO_EDITOR_PARAMS__,Y=!!window.__SYNTRO_AUDIT_LEGEND__,B=!!window.__SYNTRO_REVIEW_DATA__;if(R||Y||B){let fe=[R&&"__SYNTRO_EDITOR_PARAMS__",Y&&"__SYNTRO_AUDIT_LEGEND__",B&&"__SYNTRO_REVIEW_DATA__"].filter(Boolean);console.warn(`[Syntro Bootstrap] \u26A0 Mode detection returned null but mode-specific globals found: ${fe.join(", ")}. This suggests URL params were lost (redirect?) but the service worker injected mode data. Check if replaceState failed or if page JS changed the URL before init().`)}}console.log(`[DIAG] Token resolution: options.token=${n.token?n.token.slice(0,15)+"...":"null"}`);let t=n.token;if(!t&&e){let Y=wc()?.syntro_token;Y?.startsWith("syn_")&&(t=Y,q("Syntro Bootstrap",`\u2713 Using syntro_token from editor_conf (${e} mode)`))}let r;if(t)if(t.startsWith("syn_"))q("Syntro Bootstrap","Token starts with syn_, decoding..."),r=ns(t),$p(r.d);else if(e)q("Syntro Bootstrap",`\u2713 Non-syn_ token allowed (${e} mode)`);else throw ic("Syntro Bootstrap","\u274C Token does not start with syn_ and NOT in editor/audit/review mode!"),ic("Syntro Bootstrap","Token received:",t),new Error("Invalid Syntro token: must start with 'syn_'");else if(e)q("Syntro Bootstrap",`\u2713 No token, but ${e} mode - proceeding`);else throw ic("Syntro Bootstrap","\u274C No token provided and NOT in editor/audit/review mode!"),new Error("Syntro token is required (unless in editor, audit, or review mode)");let i=xt("NEXT_PUBLIC_SYNTRO_EXPERIMENT_HOST")||xt("VITE_SYNTRO_EXPERIMENT_HOST")||r?.eh,s=xt("NEXT_PUBLIC_SYNTRO_TELEMETRY_HOST")||xt("VITE_SYNTRO_TELEMETRY_HOST")||r?.th;if(r!=null&&r.obd!==!0&&s)try{let R=`${s.replace(/\/$/,"")}/sdk-otel/v1/logs`,Y=Pp({resource:{serviceName:"syntro-runtime-sdk",serviceVersion:Zi,posthogKey:r.t??"",hostOrigin:typeof window<"u"?window.location.origin:""},emit:Mp({endpoint:R})}),B=Np()??"https://cdn.syntrologie.com/runtime-sdk/",fe=Yp(Y,{attributedScriptUrlPrefix:B});Y.attachAdapterCleanup(fe)}catch{}let o=xt("NEXT_PUBLIC_SYNTRO_EDITOR_URL")||xt("VITE_SYNTRO_EDITOR_URL")||n.canvas?.editorUrl,a=r?.g||xt("NEXT_PUBLIC_SYNTRO_GEO_HOST")||xt("VITE_SYNTRO_GEO_HOST")||g_,l=l_(),c=mf(),u=n.appSignalsInit??{},p=f_(),f=vf(c,p);h_(f);let h={...c,...f,...l,...u};q("Syntro Bootstrap","Phase 1: Browser metadata:",c),q("Syntro Bootstrap","Phase 1: Initial attrs:",f),q("Syntro Bootstrap","Phase 1: Cached segment attributes:",l),Object.keys(u).length>0&&q("Syntro Bootstrap","Phase 1: App signals:",u);let g=yf(a),v=(()=>{try{if(typeof window>"u"||window.self===window.top)return Promise.resolve(null)}catch{}return new Promise(R=>{let Y=setTimeout(()=>{window.removeEventListener("message",B),R(null)},500);function B(fe){let he=fe.data;he?.jsonrpc==="2.0"&&he?.id===1&&he?.result?.hostInfo&&(clearTimeout(Y),window.removeEventListener("message",B),R(he.result.hostInfo))}window.addEventListener("message",B);try{window.parent.postMessage({jsonrpc:"2.0",id:1,method:"ui/initialize",params:{capabilities:{}}},"*")}catch{clearTimeout(Y),window.removeEventListener("message",B),R(null)}})})(),m,y=n.debug||n.testMode,w=Bi({debug:n.debug,history:y?new ss(n.testMode?0:100):void 0,testMode:n.testMode});console.log("[Syntro Bootstrap] EventBus created");let x=_d({elementResolver:typeof window<"u"?(R,Y)=>{let B=document.elementFromPoint(R,Y);if(!B)return null;let fe={tag_name:B.tagName.toLowerCase()};B.id&&(fe.attr__id=B.id),B.className&&typeof B.className=="string"&&(fe.classes=B.className.split(" ").filter(Boolean));for(let he of B.attributes)he.name.startsWith("data-")&&(fe[`attr__${he.name}`]=he.value);return fe}:void 0});if(x.onEvent(R=>w.publishEvent(R)),typeof window<"u")try{hb(w),gb(w)}catch(R){We("Syntro Bootstrap","scroll instrumentation install failed",R)}typeof window<"u"&&(setInterval(()=>x.tick(Date.now()),1e3),document.addEventListener("click",R=>{let Y=[],B=R.target;for(;B&&B!==document.body;){let fe={tag_name:B.tagName.toLowerCase()};for(let he of B.attributes)(he.name.startsWith("data-")||he.name==="id"||he.name==="class"||he.name==="aria-label")&&(fe[`attr__${he.name}`]=he.value);Y.push(fe),B=B.parentElement}x.enrichClickAttributes(Date.now(),Y)},!0));let _=yb(),k,I=R=>{q("Syntro Bootstrap","Phase 2: PostHog feature flags loaded");let Y=d_(R);if(q("Syntro Bootstrap","Segment flags from PostHog:",Y),c_(Y),m){let B=A?.getAll?.()??{},fe=is(b?.getDistinctId?.()),he={...c,...f,...B,...Y,...u,id:fe};q("Syntro Bootstrap","Updating GrowthBook with attributes:",he),m.setAttributes?.(he)}if(k&&b?.getDistinctId){let B=b.getDistinctId();B&&s&&r?.t&&k.updateContext({distinctId:B,telemetryHost:s,telemetryKey:r.t})}},b;if(r?.t){let R=r.t==="noop"?"noop":"posthog";if(b=$w(R,{apiKey:r.t,apiHost:s,enableFeatureFlags:!0,sessionRecording:!0,cookieless_mode:"on_reject",onFeatureFlagsLoaded:I,onCapture:(se,Re)=>{x.ingest({kind:"posthog",event:se,properties:Re,timestamp:Date.now()})},onRRWebEvent:se=>{x.ingest(se)}}),console.log(`[Syntro Bootstrap] Telemetry client created (${R}) with EventBus wiring`),b){let se=b.getDistinctId?.bind(b);b.getDistinctId=()=>is(se?.())}try{b.track?.("syntro_bootstrap_step",{stage:"telemetry_ready"})}catch{}Object.keys(u).length>0&&(b.track?.("app_signals_init",u),q("Syntro Bootstrap","Tracked app signals event:",u));let Y=b;w.setPosthogCapture((se,Re)=>{Y.track?.(se,Re)});let B=b,fe=async()=>{let se=await g;return se.is_eu==="true"||se.country_code==="GB"||se.country_code==="CH"?"denied":"granted"},he=new na({initialStatus:"pending",pendingResolver:fe,onConsentChange:se=>{u_(se),se==="granted"?B.optInCapturing?.():se==="denied"&&B.optOutCapturing?.()}});try{B.track?.("syntro_bootstrap_step",{stage:"consent_gate_constructed"})}catch{}try{S_(b,he,{geoPromise:g}),q("Syntro Bootstrap","SDK defaults installed (D-1..D-5) with consent gate");try{B.track?.("syntro_bootstrap_step",{stage:"defaults_installed"})}catch{}}catch(se){We("Syntro Bootstrap","installDefaults failed",se);try{B.track?.("syntro_bootstrap_step",{stage:"defaults_install_failed",err:String(se)})}catch{}}try{let se=new ta({adapters:[new ea,new Qo,new Xo],fallbackStatus:fe,onAdapterSelected:Re=>{B.track?.("syntro_consent_adapter_selected",{adapter:Re??"none"}),q("Syntro Bootstrap",`Consent adapter selected: ${Re??"none"}`)}});try{B.track?.("syntro_bootstrap_step",{stage:"detector_started"})}catch{}se.start(he).then(()=>{try{B.track?.("syntro_bootstrap_step",{stage:"detector_resolved"})}catch{}}).catch(Re=>{We("Syntro Bootstrap","Consent detector failed to start",Re);try{B.track?.("syntro_bootstrap_step",{stage:"detector_failed",err:String(Re)})}catch{}})}catch(se){We("Syntro Bootstrap","Consent detector setup failed",se);try{B.track?.("syntro_bootstrap_step",{stage:"detector_setup_failed",err:String(se)})}catch{}}try{k=v_({telemetry:b,telemetryHost:s,telemetryKey:r.t,platformAdapter:_,debug:q,warn:We}).shopifyPixelBridge}catch(se){We("Syntro Bootstrap","wirePlatformAdapters failed",se)}}let A;r?.e&&(m=cb("growthbook",{clientKey:r.e,apiHost:i,attributes:{...h,id:is(b?.getDistinctId?.())},onExperimentViewed:b?.trackExperiment?(R,Y,B)=>{b.trackExperiment(R,Y,B)}:void 0})),A=Zc({experiments:m,onMetricChange:(R,Y)=>{q("Syntro Bootstrap",`Session metric changed: ${R} = ${Y}`)}}),q("Syntro Bootstrap","SessionMetricTracker created");let M="production";e==="editor"?M="editor":e==="audit"?M="audit":xt("NODE_ENV")==="development"&&(M="development");let J=typeof c.surface_type=="string"?c.surface_type:"web",$=typeof c.surface_host=="string"?c.surface_host:"web",U=Ql({telemetry:b,sessionMetrics:A,mode:M,events:w,initialSurfaceType:J,initialSurfaceHost:$,backendUrl:n.backendUrl});_&&(U.getProductIdentity=R=>_.extractProductIdentity(R)),q("Syntro Bootstrap","Runtime created:",{version:U.version,mode:U.mode,hasContext:!!U.context,hasEvents:!!U.events,hasState:!!U.state,hasProductIdentity:!!U.getProductIdentity});let G=async R=>{if(!t?.startsWith("syn_")||!r?.t||!n.backendUrl)return"unknown";let Y=await Cb({backendUrl:n.backendUrl,token:t,posthogKey:r.t,getSessionId:()=>b?.getSessionId?.(),getUserId:()=>b?.getDistinctId?.()},R);return m?.setAttributes?.({[R.name]:Y}),Y},Z=async R=>{if(!t?.startsWith("syn_")||!r?.t||!n.backendUrl)return R.map(()=>"unknown");let Y=await Eb({backendUrl:n.backendUrl,token:t,posthogKey:r.t,getSessionId:()=>b?.getSessionId?.(),getUserId:()=>b?.getDistinctId?.()},R);return m?.setAttributes?.(Object.fromEntries(R.map((B,fe)=>[B.name,Y[fe]]))),Y},te=(R,Y)=>{if(!n.backendUrl)throw new Error("[syntro] authedFetch: no backendUrl configured");let B=n.backendUrl.replace(/\/$/,""),fe=/^https?:\/\//.test(R)?R:`${B}${R.startsWith("/")?R:`/${R}`}`;if(new URL(fe).origin!==new URL(B).origin)throw new Error("[syntro] authedFetch: refusing cross-origin request (token would leak)");let he={};t&&(he.Authorization=`Bearer ${t}`);let se=b?.getDistinctId?.();se&&(he["X-Distinct-Id"]=se);let Re=b?.getSessionId?.();return Re&&(he["X-Syntro-Session"]=Re),fetch(fe,{...Y,credentials:"include",headers:{"Content-Type":"application/json",...Y?.headers,...he}})};q("Syntro Bootstrap","Core app executors already registered");let ye=n.cdnBase||xt("NEXT_PUBLIC_SYNTRO_CDN_BASE")||xt("VITE_SYNTRO_CDN_BASE")||Rl()||"https://cdn.syntrologie.com",pe=Qu({cdnBase:ye,registry:U.apps,onLoadStart:R=>{q("Syntro Bootstrap",`Loading app from CDN: ${R}`)},onLoadEnd:(R,Y,B)=>{Y?q("Syntro Bootstrap",`App loaded successfully: ${R}`):We("Syntro Bootstrap",`Failed to load app: ${R}`,B)}});typeof window<"u"&&(window.SynOS={...window.SynOS,appRegistry:U.apps,appLoader:pe,runtime:U,experiments:m,score:G,scoreMulti:Z,authedFetch:te,version:U.version},q("Syntro Bootstrap","Global SynOS object exposed")),typeof window<"u"&&window.parent!==window&&pe.loadApp("adaptive-mcp").catch(R=>{q("Syntro Bootstrap","auto-load of adaptive-mcp failed (non-fatal):",R)});let j=U.apps.list?.()??[];console.log(`[DIAG] Activation loop: ${j.length} apps in registry:`,j.map(R=>`${R.manifest.id}(${R.state})`).join(", "));for(let R of j)if(R.state==="registered"&&DT(R))try{await U.apps.activate(R.manifest.id),console.log(`[DIAG] Activated: ${R.manifest.id} \u2192 widgets: [${U.widgets.list().join(", ")}]`)}catch(Y){console.error(`[DIAG] FAILED to activate: ${R.manifest.id}`,Y),We("Syntro Bootstrap",`Failed to auto-activate built-in app: ${R.manifest.id}`,Y)}if(console.log(`[DIAG] Activation complete. Total widgets: [${U.widgets.list().join(", ")}]`),m?.refreshFeatures){let Y=performance.now(),B=!1,fe=!1;try{await Promise.race([m.refreshFeatures().then(()=>{}),new Promise(he=>setTimeout(()=>{B=!0,he()},500))]),q("Syntro Bootstrap","GrowthBook features loaded (or timeout reached)")}catch(he){fe=!0,We("Syntro Bootstrap","Failed to load GrowthBook features:",he)}try{b?.track?.("syntro_bootstrap_step",{stage:"gb_features_fetch",duration_ms:Math.round(performance.now()-Y),timeout_ms:500,timed_out:B,failed:fe})}catch{}}let X=await g;if(m&&Object.keys(X).length>0){let R={...c,...f,...X,...u,id:is(b?.getDistinctId?.())};q("Syntro Bootstrap","Merging geo data into GrowthBook attributes:",X),m.setAttributes?.(R)}let Oe=await v;Oe&&m&&(c.surface_type="mcp-app",c.surface_host=Oe.name,m.setAttributes?.({...c,...f,...X,id:is(b?.getDistinctId?.())}),U.context.setSurfaceType("mcp-app"),U.context.setSurfaceHost(Oe.name),q("Syntro Bootstrap","MCP App detected:",Oe.name));let Ye;if(n.fetcher)Ye=n.fetcher;else if(r?.f){let R=fb(r.f,r.o??{});Ye=async()=>{let Y=await R.fetch();return{...Y.config,tiles:Y.config.tiles??[]}}}else m&&(Ye=Ur({experiments:m}));let De=new Set;function Je(R,Y){let B=pe.getRequiredApps(R);B.length>0?console.log("[Syntro Bootstrap] Required external apps:",B.join(", ")):q("Syntro Bootstrap","No external apps required (all executors are built-in)"),B.length!==0&&gl({appIds:B,loadApp:fe=>pe.loadApp(fe),apps:U.apps,warnedAppFailures:De}).catch(fe=>{console.error(`[Syntro Bootstrap] app loading (${Y}) rejected:`,fe)})}function Xe(R){return async()=>{let Y=await R();return Je(Y,"override"),Y}}let Pn=Ye?async()=>{let R=await Ye(),Y=R.tiles?.length??0,B=R.actions?.length??0,fe=R.meta?.variant_id,he=R.meta?.variants;if((Y>0||B>0)&&(fe||console.warn("[Syntro] Config has content but no meta.variant_id \u2014 intervention tracking disabled")),b&&fe){let se=typeof window<"u"?window.SynOS??(window.SynOS={}):void 0,Re=se?.interventionTracker,Xt;if(Re&&Re.variantId===fe)Xt=Re;else{let Qt=se?.interventionTrackerUnsub;if(Qt)try{Qt()}catch(zw){console.warn("[Syntro] interventionTracker nav unsub threw:",zw)}Xt=new hs(b,fe),se&&(se.interventionTracker=Xt);let $s=U.navigation.subscribe(()=>{Xt.resetPage()});se&&(se.interventionTrackerUnsub=$s)}if(he&&he.length>0)for(let Qt of he)Xt.trackServedForVariant(Qt.variant_id,Qt.tiles,Qt.actions);else Xt.trackServed(Y,B)}return console.log("[Syntro Bootstrap] Config fetched:",`tiles=${R.tiles?.length??0},`,`actions=${R.actions?.length??0},`,`theme=${R.theme?.name??"none"}`),R.actions?.length>0&&console.log("[Syntro Bootstrap] Actions in config:",R.actions.map((se,Re)=>`[${Re}] ${se.kind}${se.anchorId?` anchor="${se.anchorId.selector}"`:""}${se.label?` "${se.label}"`:""}`).join(", ")),Je(R,"initial"),R}:void 0;if(_){q("Syntro Bootstrap",`Detected platform: ${_.name}`);try{await _.onInit(),q("Syntro Bootstrap",`Platform adapter initialized: ${_.name}`)}catch(R){We("Syntro Bootstrap",`Platform adapter init failed: ${_.name}`,R)}}if(typeof window<"u"){let R=window.SynOS??(window.SynOS={});R.wrapCanvasConfigFetcher=Xe}let Lt=await Sc({...n.canvas,fetcher:Pn,integrations:{experiments:m,telemetry:b},editorUrl:o,runtime:U}),Is=jt();if(Is!==null)try{let R=b,Y=U;Is.bindRuntime({getSessionId:()=>{try{return R?.getSessionId?.()??""}catch{return""}},getSurface:()=>{try{let B=Y.context.get().surface;return B?{...B}:null}catch{return null}}})}catch{}return Is?.increment("bootstrap_ok"),{canvas:Lt,runtime:U,experiments:m,telemetry:b,sessionMetrics:A,appLoader:pe}}async function HT(n){try{return await Pw(n)}catch(e){let t=e instanceof Error?e.message:String(e);console.warn("[Syntrologie] SDK initialization failed:",t),jt()?.increment("bootstrap_errors"),typeof document<"u"&&document.getElementById("syntrologie-anti-flicker")?.remove();return}}function BT(n,e={}){if(typeof window>"u")return;let t=window.SynOS?.runtime;t?.events?.publish&&t.events.publish({name:n,source:"custom",props:e})}async function VT(n){if(typeof window>"u")return{appId:n,success:!1,error:"no-window"};let e=window.SynOS?.appLoader;return e?e.loadApp(n):{appId:n,success:!1,error:"syntro-not-initialized"}}var Dg={init:HT,loadAdaptive:VT,encodeToken:Ec,decodeToken:ns,events:{emit:BT}};typeof window<"u"&&(window.Syntro=Dg);function Rs(n){let e=n.split(".");return{major:parseInt(e[0]||"0",10),minor:parseInt(e[1]||"0",10)}}function UT(n){let e=[],t=[];if(!n||typeof n!="object")return{valid:!1,errors:["Config must be an object"],warnings:e};let r=n;if(r.tiles||t.push("Config missing required field: tiles"),r.actions||t.push("Config missing required field: actions"),r.fetchedAt||t.push("Config missing required field: fetchedAt"),t.length>0)return{valid:!1,errors:t,warnings:e};let i=r.schemaVersion||"1.0",s=Rs(i),o=Rs(vn);return s.major>o.major&&e.push(`Config schema v${i} is newer than SDK v${vn}. Some features may not work. Update SDK to latest version.`),s.major<o.major||!r.schemaVersion?(e.push(`Config schema v${i} is older than SDK v${vn}. Migrating config to current version.`),{valid:!0,warnings:e,errors:t,migratedConfig:jT(r,i)}):{valid:!0,warnings:e,errors:t}}function jT(n,e){let t={...n};return Rs(e).major===1&&(t=WT(t)),t.schemaVersion=vn,t}function WT(n){let e={schemaVersion:"2.0",tiles:[],actions:n.actions||[],fetchedAt:n.fetchedAt||new Date().toISOString()};return n.tiles&&Array.isArray(n.tiles)&&(e.tiles=n.tiles.map(t=>{let r={...t};return t.experiment&&delete r.experiment,r})),n.configVersion&&(e.configVersion=n.configVersion),n.canvasTitle&&(e.canvasTitle=n.canvasTitle),n.theme&&(e.theme=n.theme),n.launcher&&(e.launcher=n.launcher),e}function zT(n){if(!n||typeof n!="object")return!1;let e=n,t=e.schemaVersion||"1.0",r=Rs(t),i=Rs(vn);return r.major<i.major||!e.schemaVersion}var Ow=d.object({url:d.string(),routeId:d.string().optional(),title:d.string().optional(),locale:d.string().optional()}),Mw=d.object({url:d.string(),ts:d.number()}),Lw=d.object({sessionId:d.string(),startTs:d.number(),pageHistory:d.array(Mw).optional()}),Nw=d.object({width:d.number(),height:d.number()}),Fw=d.object({x:d.number(),y:d.number(),w:d.number(),h:d.number()}),Dw=d.object({anchorId:d.string(),present:d.boolean(),visible:d.boolean().optional(),boundingBox:Fw.optional()}),Hw=d.record(d.string(),d.union([d.number(),d.string(),d.boolean(),d.undefined()])),Bw=d.object({page:Ow,session:Lw,viewport:Nw,anchors:d.array(Dw).optional(),augmented:Hw.optional()});function qT(n){return Bw.safeParse(n)}var Iu=class{constructor(e,t,r,i){this._isFallback=!0;this._isLoading=!0;this._cancelled=!1;this._host=e,this._runtime=t,this._strategy=r,this._defaultValue=i,this._value=i,e.addController(this)}get value(){return this._value}get isFallback(){return this._isFallback}get isLoading(){return this._isLoading}hostConnected(){this._evaluate()}hostDisconnected(){this._cancelled=!0}setStrategy(e){this._strategy=e,this._evaluate()}_evaluate(){if(this._cancelled=!1,!this._runtime||!this._strategy){this._value=this._defaultValue,this._isFallback=!0,this._isLoading=!1,this._host.requestUpdate();return}this._isLoading=!0,this._host.requestUpdate();let e=this._strategy;this._runtime.evaluate(e).then(t=>{this._cancelled||(this._value=t.value,this._isFallback=t.isFallback,this._isLoading=!1,this._host.requestUpdate())})}};var $u=class{constructor(e,t){this._unsubscribe=null;this.host=e,this._runtime=t,this._context=t.context.get(),e.addController(this)}hostConnected(){this._context=this._runtime.context.get(),this._unsubscribe=this._runtime.context.subscribe(e=>{this._context=e,this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}get runtime(){return this._runtime}get context(){return this._context}get page(){return this._context?.page??null}get session(){return this._context?.session??null}get viewport(){return this._context?.viewport??null}};var Pu=class{constructor(e,t,r,i){this._runtime=t,this._filter=r,this._callback=i,e.addController(this)}hostConnected(){this._subscribe()}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=void 0}setFilter(e){this._filter=e,this._unsubscribe!==void 0&&(this._unsubscribe(),this._unsubscribe=void 0,this._subscribe())}setCallback(e){this._callback=e,this._unsubscribe!==void 0&&(this._unsubscribe(),this._unsubscribe=void 0,this._subscribe())}_subscribe(){this._runtime&&(this._unsubscribe=this._filter?this._runtime.events.subscribe(this._filter,this._callback):this._runtime.events.subscribe(this._callback))}};var Hg=d.enum(["posthog","canvas","derived"]),Vw=d.object({ts:d.number(),name:d.string(),source:Hg,props:d.record(d.string(),d.unknown()).optional(),schemaVersion:d.string()}),Uw=d.object({names:d.array(d.string()).optional(),patterns:d.array(d.string()).optional(),sources:d.array(Hg).optional()});function ZT(n){return Vw.safeParse(n)}function GT(n){return Uw.safeParse(n)}var jw=d.object({value:d.unknown(),expiresAt:d.number().optional()}),Ww=d.object({count:d.number(),resetAt:d.number().optional()});function KT(n){return jw.safeParse(n)}function YT(n){return Ww.safeParse(n)}var Bg="2026-07-24T18:59:36.948Z (31156e4c3)";if(typeof window<"u"){console.log(`[Syntro Runtime] Build: ${Bg} (Lit)`);let n=window.SynOS,e=n?.appRegistry||eo;window.SynOS={...n,appRegistry:e,_runtimeBuild:Bg,_renderer:"lit"},Fo(),sv(e)}return Jw(JT);})();
|
|
626
|
+
`)).length,i=0;i<r;i++){var o=n.charCodeAt(i),a=null;o<128?t++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),Mt(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},CT=!!gh||!!hh,u0="text/plain",bu=function(n,e,t){var r;t===void 0&&(t=!0);var[i,s]=n.split("?"),o=W({},e),a=(r=s?.split("&").map((c=>{var u,[p,f]=c.split("="),h=t&&(u=o[p])!==null&&u!==void 0?u:f;return delete o[p],p+"="+h})))!==null&&r!==void 0?r:[],l=X1(o);return l&&a.push(l),i+"?"+a.join("&")},va=(n,e)=>JSON.stringify(n,((t,r)=>typeof r=="bigint"?r.toString():r),e),ah=n=>{var{data:e,compression:t}=n;if(e){if(t===Tn.GZipJS){var r=ST((function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var p=new Et(l.length+(l.length>>>1)),f=0,h=function(y){p[f++]=y},g=0;g<u;++g){if(f+5>p.length){var v=new Et(f+8+(u-g<<1));v.set(p),p=v}var m=l.charCodeAt(g);m<128||c?h(m):m<2048?(h(192|m>>>6),h(128|63&m)):m>55295&&m<57344?(h(240|(m=65536+(1047552&m)|1023&l.charCodeAt(++g))>>>18),h(128|m>>>12&63),h(128|m>>>6&63),h(128|63&m)):(h(224|m>>>12),h(128|m>>>6&63),h(128|63&m))}return Sw(p,0,f)})(va(e)),{mtime:0}),i=new Blob([r],{type:u0});return{contentType:u0,body:i,estimatedSize:i.size}}if(t===Tn.Base64){var s=(function(l){var c,u,p,f,h,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,m=0,y="",w=[];if(!l)return l;l=ET(l);do c=(h=l.charCodeAt(v++)<<16|l.charCodeAt(v++)<<8|l.charCodeAt(v++))>>18&63,u=h>>12&63,p=h>>6&63,f=63&h,w[m++]=g.charAt(c)+g.charAt(u)+g.charAt(p)+g.charAt(f);while(v<l.length);switch(y=w.join(""),l.length%3){case 1:y=y.slice(0,-2)+"==";break;case 2:y=y.slice(0,-1)+"="}return y})(va(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:va(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=va(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},ru=[];hh&&ru.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=ah(n))!==null&&e!==void 0?e:{},o=new Headers;xe(n.headers,(function(u,p){o.append(p,u)})),r&&o.append("Content-Type",r);var a=n.url,l=null;if(Ib){var c=new Ib;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),n.timeout)}}hh(a,W({method:n?.method||"GET",headers:o,keepalive:n.method==="POST"&&(s||0)<52428.8,body:i,signal:(t=l)==null?void 0:t.signal},n.fetchOptions)).then((u=>u.text().then((p=>{var f={statusCode:u.status,text:p};if(u.status===200)try{f.json=JSON.parse(p)}catch(h){V.error(h)}n.callback==null||n.callback(f)})))).catch((u=>{V.error(u),n.callback==null||n.callback({statusCode:0,text:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),gh&&ru.push({transport:"XHR",method:n=>{var e,t=new gh;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=ah(n))!==null&&e!==void 0?e:{};xe(n.headers,(function(s,o){t.setRequestHeader(o,s)})),r&&t.setRequestHeader("Content-Type",r),n.timeout&&(t.timeout=n.timeout),n.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var s={statusCode:t.status,text:t.responseText};if(t.status===200)try{s.json=JSON.parse(t.responseText)}catch{}n.callback==null||n.callback(s)}},t.send(i)}}),ht!=null&&ht.sendBeacon&&ru.push({transport:"sendBeacon",method:n=>{var e=bu(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=ah(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;ht.sendBeacon(e,s)}catch{}}});var wu=function(n,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(n)}catch{return!1}};function d0(n,e,t){return va({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var Ew={exact:(n,e)=>e.some((t=>n.some((r=>t===r)))),is_not:(n,e)=>e.every((t=>n.every((r=>t!==r)))),regex:(n,e)=>e.some((t=>n.some((r=>wu(t,r))))),not_regex:(n,e)=>e.every((t=>n.every((r=>!wu(t,r))))),icontains:(n,e)=>e.map(tu).some((t=>n.map(tu).some((r=>t.includes(r))))),not_icontains:(n,e)=>e.map(tu).every((t=>n.map(tu).every((r=>!t.includes(r))))),gt:(n,e)=>e.some((t=>{var r=parseFloat(t);return!isNaN(r)&&n.some((i=>r>parseFloat(i)))})),lt:(n,e)=>e.some((t=>{var r=parseFloat(t);return!isNaN(r)&&n.some((i=>r<parseFloat(i)))}))},tu=n=>n.toLowerCase();function Cw(n,e){return!n||Object.entries(n).every((t=>{var[r,i]=t,s=e?.[r];if(H(s)||Mt(s))return!1;var o=[String(s)],a=Ew[i.operator];return!!a&&a(i.values,o)}))}var lh=Pe("[Error tracking]"),ig=class{constructor(e){var t,r;this.Zt=[],this.ti=new Sh([new Ch,new Ph,new Ah,new kh,new Ih,new Rh,new Th,new $h],M1()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(Mh))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,r,i,s=(t=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&t!==void 0?t:[],o=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Zt=s,this._instance.persistence&&this._instance.persistence.register({[Mh]:this.Zt,[jb]:o})}get ii(){var e,t=!!this._instance.get_property(jb),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void lh.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void lh.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void lh.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(e){if(e.length===0)return!1;var t=e.reduce(((r,i)=>{var{type:s,value:o}=i;return Ve(s)&&s.length>0&&r.$exception_types.push(s),Ve(o)&&o.length>0&&r.$exception_values.push(o),r}),{$exception_types:[],$exception_values:[]});return this.Zt.some((r=>{var i=r.values.map((s=>{var o,a=Ew[s.operator],l=_e(s.value)?s.value:[s.value],c=(o=t[s.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,c)}));return r.type==="OR"?i.some(Boolean):i.every(Boolean)}))}si(e){return e.flatMap((t=>{var r,i;return(r=(i=t.stacktrace)==null?void 0:i.frames)!==null&&r!==void 0?r:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}ni(e){if(e.length>0){var t,r,i,s,o=(t=(r=e[0].stacktrace)==null?void 0:r.frames)!==null&&t!==void 0?t:[],a=o[o.length-1];return(i=a==null||(s=a.filename)==null?void 0:s.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}ei(e){return!ve(e)&&_e(e)}},ft=Pe("[FeatureFlags]"),la=Pe("[FeatureFlags]",{debugEnabled:!0}),ch="$active_feature_flags",gs="$override_feature_flags",p0="$feature_flag_payloads",ca="$override_feature_flag_payloads",f0="$feature_flag_request_id",h0="$feature_flag_evaluated_at",g0=n=>{var e={};for(var[t,r]of nu(n||{}))r&&(e[t]=r);return e},kT=n=>{var e=n.flags;return e?(n.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var r;return[t,(r=e[t].variant)!==null&&r!==void 0?r:e[t].enabled]}))),n.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var r;return(r=e[t].metadata)==null?void 0:r.payload})).map((t=>{var r;return[t,(r=e[t].metadata)==null?void 0:r.payload]})))):ft.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},AT=(function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n})({}),sg=class{constructor(e){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=(e=this._instance.config.evaluation_contexts)!==null&&e!==void 0?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(ft.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),t!=null&&t.length?t.filter((r=>{var i=r&&typeof r=="string"&&r.trim().length>0;return i||ft.error("Invalid evaluation context found:",r,"Expected non-empty string"),i})):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var e=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:e})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Lh),t=this._instance.get_property(gs),r=this._instance.get_property(ca);if(!r&&!t)return e||{};var i=Me({},e||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(t||{})])];for(var o of s){var a,l,c=i[o],u=t?.[o],p=H(u)?(a=c?.enabled)!==null&&a!==void 0&&a:!!u,f=H(u)?c.variant:typeof u=="string"?u:void 0,h=r?.[o],g=W({},c,{enabled:p,variant:p?f??c?.variant:void 0});p!==c?.enabled&&(g.original_enabled=c?.enabled),f!==c?.variant&&(g.original_variant=c?.variant),h&&(g.metadata=W({},c?.metadata,{payload:h,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[o]=g}return this.oi||(ft.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(ws),t=this._instance.get_property(gs);if(!t)return e||{};for(var r=Me({},e),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(ft.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(p0),t=this._instance.get_property(ca);if(!t)return e||{};for(var r=Me({},e||{}),i=Object.keys(t),s=0;s<i.length;s++)r[i[s]]=t[i[s]];return this.oi||(ft.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:r}),this.oi=!0),r}reloadFeatureFlags(){this.ui||this._instance.config.advanced_disable_feature_flags||this.gi||(this.gi=setTimeout((()=>{this.mi()}),5))}bi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ui=e}mi(e){var t;if(this.bi(),!this._instance.M())if(this.li)this.hi=!0;else{var r=this._instance.config.token,i=this._instance.get_property("$device_id"),s={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:W({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(ma)||{}),group_properties:this._instance.get_property(si)};Mt(i)||H(i)||(s.$device_id=i),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.pi()&&(s.evaluation_contexts=this.fi());var o=this._instance.config.__preview_remote_config,a=o?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",a+l);o&&(s.timezone=_w()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:Tn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var p,f,h=!0;if(u.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),h=!1),this.li=!1,this.di||(this.di=!0,this._instance.yi((f=u.json)!==null&&f!==void 0?f:{})),!s.disable_flags||this.hi)if(this.vi=!h,u.json&&(p=u.json.quotaLimited)!=null&&p.includes(AT.FeatureFlags))ft.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var g;s.disable_flags||this.receivedFeatureFlags((g=u.json)!==null&&g!==void 0?g:{},h),this.hi&&(this.hi=!1,this.mi())}}})}}getFeatureFlag(e,t){var r;if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlagResult(e,t);return(r=i?.variant)!==null&&r!==void 0?r:i?.enabled}ft.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants(),i=e in r,s=r[e],o=this.getFlagPayloads()[e],a=String(s),l=this._instance.get_property(f0)||void 0,c=this._instance.get_property(h0)||void 0,u=this._instance.get_property(lu)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(a))){var p,f,h,g,v,m,y,w,x;_e(u[e])?u[e].push(a):u[e]=[a],(p=this._instance.persistence)==null||p.register({[lu]:u});var _=this.getFeatureFlagDetails(e),k={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:o||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((f=this._instance.config.bootstrap)==null||(f=f.featureFlags)==null?void 0:f[e])||null,$feature_flag_bootstrapped_payload:((h=this._instance.config.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.vi};H(_==null||(g=_.metadata)==null?void 0:g.version)||(k.$feature_flag_version=_.metadata.version);var I,b=(v=_==null||(m=_.reason)==null?void 0:m.description)!==null&&v!==void 0?v:_==null||(y=_.reason)==null?void 0:y.code;b&&(k.$feature_flag_reason=b),_!=null&&(w=_.metadata)!=null&&w.id&&(k.$feature_flag_id=_.metadata.id),H(_?.original_variant)&&H(_?.original_enabled)||(k.$feature_flag_original_response=H(_.original_variant)?_.original_enabled:_.original_variant),_!=null&&(x=_.metadata)!=null&&x.original_payload&&(k.$feature_flag_original_payload=_==null||(I=_.metadata)==null?void 0:I.original_payload),this._instance.capture("$feature_flag_called",k)}if(i){var A=o;if(!H(o))try{A=JSON.parse(o)}catch{}return{key:e,enabled:!!s,variant:typeof s=="string"?s:void 0,payload:A}}}else ft.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.pi()&&(i.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:Tn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var o,a=(o=s.json)==null?void 0:o.featureFlagPayloads;t(a?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,t);return H(r)?void 0:!!r}ft.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this._instance.persistence){this.ai=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(o,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var p=kT(o),f=p.flags,h=p.featureFlags,g=p.featureFlagPayloads;if(h){var v=o.requestId,m=o.evaluatedAt;if(_e(h)){ft.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var y={};if(h)for(var w=0;w<h.length;w++)y[h[w]]=!0;a&&a.register({[ch]:h,[ws]:y})}else{var x=h,_=g,k=f;if(o.errorsWhileComputingFlags)if(f){var I=new Set(Object.keys(f).filter((b=>{var A;return!((A=f[b])!=null&&A.failed)})));x=W({},l,Object.fromEntries(Object.entries(x).filter((b=>{var[A]=b;return I.has(A)})))),_=W({},c,Object.fromEntries(Object.entries(_||{}).filter((b=>{var[A]=b;return I.has(A)})))),k=W({},u,Object.fromEntries(Object.entries(k||{}).filter((b=>{var[A]=b;return I.has(A)}))))}else x=W({},l,x),_=W({},c,_),k=W({},u,k);a&&a.register(W({[ch]:Object.keys(g0(x)),[ws]:x||{},[p0]:_||{},[Lh]:k||{}},v?{[f0]:v}:{},m?{[h0]:m}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),ft.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return ft.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(gs),this._instance.persistence.unregister(ca),this.wi(),la.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,r=e;if(this.oi=!!((t=r.suppressWarning)!==null&&t!==void 0&&t),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(gs),la.info("Flag overrides cleared");else if(r.flags){if(_e(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[gs]:i})}else this._instance.persistence.register({[gs]:r.flags});la.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(ca),la.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[ca]:r.payloads}),la.info("Payload overrides set",{payloads:r.payloads}))),void this.wi()}this.wi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ai){var{flags:t,flagVariants:r}=this.xi();e(t,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,r){var i,s=(this._instance.get_property(ga)||[]).find((c=>c.flagKey===e)),o={["$feature_enrollment/"+e]:t},a={$feature_flag:e,$feature_enrollment:t,$set:o};s&&(a.$early_access_feature_name=s.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(o,!1);var l=W({},this.getFlagVariants(),{[e]:t});(i=this._instance.persistence)==null||i.register({[ch]:Object.keys(g0(l)),[ws]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(ga),s=r?"&"+r.map((o=>"stage="+o)).join("&"):"";if(i&&!t)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+s),method:"GET",callback:o=>{var a,l;if(o.json){var c=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(ga),(l=this._instance.persistence)==null||l.register({[ga]:c}),e(c)}}})}xi(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((r=>t[r])),flagVariants:Object.keys(t).filter((r=>t[r])).reduce(((r,i)=>(r[i]=t[i],r)),{})}}wi(e){var{flags:t,flagVariants:r}=this.xi();this.featureFlagEventHandlers.forEach((i=>i(t,r,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(ma)||{};this._instance.register({[ma]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(ma)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(si)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=W({},r[i],e[i]),delete e[i]})),this._instance.register({[si]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(si)||{};this._instance.register({[si]:W({},t,{[e]:{}})})}else this._instance.unregister(si)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.bi(),this.oi=!1}},TT=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],wa=class{constructor(e,t){this.R=e,this.props={},this.Ei=!1,this.$i=(r=>{var i="";return r.token&&(i=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+i+"_posthog"})(e),this.Y=this.Si(e),this.load(),e.debug&&V.info("Persistence loaded",e.persistence,W({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.ki}Si(e){TT.indexOf(e.persistence.toLowerCase())===-1&&(V.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(i){i===void 0&&(i=[]);var s=[...sT,...i];return W({},Te,{W:function(o){try{var a={};try{a=Yt.W(o)||{}}catch{}var l=Me(a,JSON.parse(Te.q(o)||"{}"));return Te.G(o,l),l}catch{}return null},G:function(o,a,l,c,u,p){try{Te.G(o,a,void 0,void 0,p);var f={};s.forEach((h=>{a[h]&&(f[h]=a[h])})),Object.keys(f).length&&Yt.G(o,f,l,c,u,p)}catch(h){Te.B(h)}},V:function(o,a){try{S?.localStorage.removeItem(o),Yt.V(o,a)}catch(l){Te.B(l)}}})})(e.cookie_persisted_properties||[]),r=e.persistence.toLowerCase();return r==="localstorage"&&Te.H()?Te:r==="localstorage+cookie"&&t.H()?t:r==="sessionstorage"&&ze.H()?ze:r==="memory"?oT:r==="cookie"?Yt:t.H()?t:Yt}properties(){var e={};return xe(this.props,(function(t,r){if(r===ws&&Be(t))for(var i=Object.keys(t),s=0;s<i.length;s++)e["$feature/"+i[s]]=t[i[s]];else a=r,l=!1,(Mt(o=U1)?l:Rb&&o.indexOf===Rb?o.indexOf(a)!=-1:(xe(o,(function(c){if(l||(l=c===a))return ou})),l))||(e[r]=t);var o,a,l})),e}load(){if(!this.ki){var e=this.Y.W(this.$i);e&&(this.props=Me({},e))}}save(){this.ki||this.Y.G(this.$i,this.props,this.Pi,this.Ti,this.Ii,this.R.debug)}remove(){this.Y.V(this.$i,!1),this.Y.V(this.$i,!0)}clear(){this.remove(),this.props={}}register_once(e,t,r){if(Be(e)){H(t)&&(t="None"),this.Pi=H(r)?this.Ci:r;var i=!1;if(xe(e,((s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=s,i=!0)})),i)return this.save(),!0}return!1}register(e,t){if(Be(e)){this.Pi=H(t)?this.Ci:t;var r=!1;if(xe(e,((i,s)=>{e.hasOwnProperty(s)&&this.props[s]!==i&&(this.props[s]=i,r=!0)})),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.Ei){var e=fw(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);bs($g(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=D?.referrer)?gw(e):{})}update_referrer_info(){var e;this.register_once({$referrer:mw(),$referring_domain:D!=null&&D.referrer&&((e=fu(D.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Hh]||this.props[Bh]||this.register_once({[cu]:vw(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};xe([Bh,Hh],(o=>{var a=this.props[o];a&&xe(a,(function(l,c){e["$initial_"+mh(c)]=l}))}));var t,r,i=this.props[cu];if(i){var s=(t=yw(i),r={},xe(t,(function(o,a){r["$initial_"+mh(a)]=o})),r);Me(e,s)}return e}safe_merge(e){return xe(this.props,(function(t,r){r in e||(e[r]=t)})),e}update_config(e,t,r){if(this.Ci=this.Pi=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),c=[...a].sort();return l.every(((u,p)=>u===c[p]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var i=this.Si(e),s=this.props;this.clear(),this.Y=i,this.props=s,this.save()}}set_disabled(e){this.ki=e,this.ki?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ti&&(this.Ti=e,this.remove(),this.save())}set_secure(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_event_timer(e,t){var r=this.props[ha]||{};r[e]=t,this.props[ha]=r,this.save()}remove_event_timer(e){var t=(this.props[ha]||{})[e];return H(t)||(delete this.props[ha][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},m0=Pe("[Product Tours]"),uh="ph_product_tours",og=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[zb]:!(e==null||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Ri||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(zb)||this.it((()=>this.Oi()))}it(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.generateProductTours?e():(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",(i=>{i?m0.error("Could not load product tours script",i):e()}))}Oi(){var e;!this.Ri&&(e=ee.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Ri=ee.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!_e(this.Fi)||t){var r=this._instance.persistence;if(r){var i=r.props[uh];if(_e(i)&&!t)return this.Fi=i,void e(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:s=>{var o=s.statusCode;if(o!==200||!s.json){var a="Product Tours API could not be loaded, status: "+o;return m0.error(a),void e([],{isLoaded:!1,error:a})}var l=_e(s.json.product_tours)?s.json.product_tours:[];this.Fi=l,r&&r.register({[uh]:l}),e(l,{isLoaded:!0})}})}else e(this.Fi,{isLoaded:!0})}getActiveProductTours(e){ve(this.Ri)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Ri.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Ri)==null||t.showTourById(e)}previewTour(e){this.Ri?this.Ri.previewTour(e):this.it((()=>{var t;this.Oi(),(t=this.Ri)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Ri)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Ri)==null||e.nextStep()}previousStep(){var e;(e=this.Ri)==null||e.previousStep()}clearCache(){var e;this.Fi=null,(e=this._instance.persistence)==null||e.unregister(uh)}resetTour(e){var t;(t=this.Ri)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Ri)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Ri)==null||t.cancelPendingTour(e)}},ua=(function(n){return n.Activation="events",n.Cancellation="cancelEvents",n})({}),bD=(function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n})({}),wD=(function(n){return n.TopLeft="top_left",n.TopRight="top_right",n.TopCenter="top_center",n.MiddleLeft="middle_left",n.MiddleRight="middle_right",n.MiddleCenter="middle_center",n.Left="left",n.Center="center",n.Right="right",n.NextToTrigger="next_to_trigger",n})({}),xD=(function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n})({}),dh=(function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n})({}),SD=(function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n})({}),ED=(function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n})({}),CD=(function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n})({}),ya=(function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n})({}),ph=(function(n){return n.SURVEY_ID="$survey_id",n.SURVEY_NAME="$survey_name",n.SURVEY_RESPONSE="$survey_response",n.SURVEY_ITERATION="$survey_iteration",n.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",n.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",n.SURVEY_SUBMISSION_ID="$survey_submission_id",n.SURVEY_QUESTIONS="$survey_questions",n.SURVEY_COMPLETED="$survey_completed",n.PRODUCT_TOUR_ID="$product_tour_id",n.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",n})({}),ag=(function(n){return n.Popover="popover",n.Inline="inline",n})({}),we=Pe("[Surveys]"),kw="seenSurvey_",RT=(n,e)=>{var t="$survey_"+e+"/"+n.id;return n.current_iteration&&n.current_iteration>0&&(t="$survey_"+e+"/"+n.id+"/"+n.current_iteration),t},v0=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(kw,n),IT=[dh.Popover,dh.Widget,dh.API],$T={ignoreConditions:!1,ignoreDelay:!1,displayType:ag.Popover},Ta=class{constructor(){this.Mi={},this.Mi={}}on(e,t){return this.Mi[e]||(this.Mi[e]=[]),this.Mi[e].push(t),()=>{this.Mi[e]=this.Mi[e].filter((r=>r!==t))}}emit(e,t){for(var r of this.Mi[e]||[])r(t);for(var i of this.Mi["*"]||[])i(e,t)}};function ms(n,e,t){if(ve(n))return!1;switch(t){case"exact":return n===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(n);case"regex":try{return new RegExp(e).test(n)}catch{return!1}default:return!1}}var lg=class{constructor(e){this.Ai=new Ta,this.ji=(t,r)=>this.Di(t,r)&&this.Li(t,r)&&this.Ni(t,r)&&this.Ui(t,r),this.Di=(t,r)=>r==null||!r.event||t?.event===r?.event,this._instance=e,this.zi=new Set,this.Hi=new Set}init(){var e;if(!H((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook(((r,i)=>{this.on(r,i)}))}}register(e){var t,r;if(!H((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.Hi)==null||a.add(o),(l=o.steps)==null||l.forEach((c=>{var u;(u=this.zi)==null||u.add(c?.event||"")}))})),(r=this._instance)!=null&&r.autocapture)){var i,s=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&s.add(l?.selector)}))})),(i=this._instance)==null||i.autocapture.setElementSelectors(s)}}on(e,t){var r;t!=null&&e.length!=0&&(this.zi.has(e)||this.zi.has(t?.event))&&this.Hi&&((r=this.Hi)==null?void 0:r.size)>0&&this.Hi.forEach((i=>{this.Bi(t,i)&&this.Ai.emit("actionCaptured",i.name)}))}qi(e){this.onAction("actionCaptured",(t=>e(t)))}Bi(e,t){if(t?.steps==null)return!1;for(var r of t.steps)if(this.ji(e,r))return!0;return!1}onAction(e,t){return this.Ai.on(e,t)}Li(e,t){if(t!=null&&t.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!ms(i,t.url,t.url_matching||"contains"))return!1}return!0}Ni(e,t){return!!this.Wi(e,t)&&!!this.Gi(e,t)&&!!this.Vi(e,t)}Wi(e,t){var r;if(t==null||!t.href)return!0;var i=this.Ji(e);if(i.length>0)return i.some((a=>ms(a.href,t.href,t.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&ms((s=o.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}Gi(e,t){var r;if(t==null||!t.text)return!0;var i=this.Ji(e);if(i.length>0)return i.some((c=>ms(c.text,t.text,t.text_matching||"exact")||ms(c.$el_text,t.text,t.text_matching||"exact")));var s,o,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(s=(function(c){for(var u,p=[],f=/(?::|")text="(.*?)"/g;!ve(u=f.exec(c));)p.includes(u[1])||p.push(u[1]);return p})(l),o=t.text,a=t.text_matching||"exact",s.some((c=>ms(c,o,a))))}Vi(e,t){var r,i;if(t==null||!t.selector)return!0;var s=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(s!=null&&s.includes(t.selector))return!0;var o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}Ji(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Ui(e,t){return t==null||!t.properties||t.properties.length===0||Cw(t.properties.reduce(((r,i)=>{var s=_e(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return r[i.key]={values:s,operator:i.operator||"exact"},r}),{}),e?.properties)}},cg=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&Cw(e.propertyFilters,t?.properties)}Zi(e,t){var r=new Map;return e.forEach((i=>{var s;(s=i.conditions)==null||(s=s[t])==null||(s=s.values)==null||s.forEach((o=>{if(o!=null&&o.name){var a=r.get(o.name)||[];a.push(i.id),r.set(o.name,a)}}))})),r}te(e,t,r){var i=(r===ua.Activation?this.Ki:this.Yi).get(e),s=[];return this.ie((o=>{s=o.filter((a=>i?.includes(a.id)))})),s.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.Qi(l,t)}))}register(e){var t;H((t=this._instance)==null?void 0:t._addCaptureHook)||(this.ee(e),this.re(e))}re(e){var t=e.filter((r=>{var i,s;return((i=r.conditions)==null?void 0:i.actions)&&((s=r.conditions)==null||(s=s.actions)==null||(s=s.values)==null?void 0:s.length)>0}));t.length!==0&&(this.se==null&&(this.se=new lg(this._instance),this.se.init(),this.se.qi((r=>{this.onAction(r)}))),t.forEach((r=>{var i,s,o,a,l;r.conditions&&(i=r.conditions)!=null&&i.actions&&(s=r.conditions)!=null&&(s=s.actions)!=null&&s.values&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.se)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.Xi.get(c.name);u&&u.push(r.id),this.Xi.set(c.name,u||[r.id])}})))})))}ee(e){var t,r=e.filter((s=>{var o,a;return((o=s.conditions)==null?void 0:o.events)&&((a=s.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),i=e.filter((s=>{var o,a;return((o=s.conditions)==null?void 0:o.cancelEvents)&&((a=s.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(r.length!==0||i.length!==0)&&((t=this._instance)==null||t._addCaptureHook(((s,o)=>{this.onEvent(s,o)})),this.Ki=this.Zi(e,ua.Activation),this.Yi=this.Zi(e,ua.Cancellation))}onEvent(e,t){var r,i=this.ne(),s=this.oe(),o=this.ae(),a=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[s])||[];if(o===e&&t&&a.length>0){var l,c;i.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var u=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(u){var p=a.indexOf(u);p>=0&&(a.splice(p,1),this.le(a))}}else{if(this.Yi.has(e)){var f=this.te(e,t,ua.Cancellation);f.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:f.map((g=>g.id))}),f.forEach((g=>{var v=a.indexOf(g.id);v>=0&&a.splice(v,1),this.ue(g.id)})),this.le(a))}if(this.Ki.has(e)){i.info("event name matched",{event:e,eventPayload:t,items:this.Ki.get(e)});var h=this.te(e,t,ua.Activation);this.le(a.concat(h.map((g=>g.id))||[]))}}}onAction(e){var t,r=this.oe(),i=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[r])||[];this.Xi.has(e)&&this.le(i.concat(this.Xi.get(e)||[]))}le(e){var t,r=this.ne(),i=this.oe(),s=[...new Set(e)].filter((o=>!this.he(o)));r.info("updating activated items",{activatedItems:s}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[i]:s})}getActivatedIds(){var e,t=this.oe(),r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return r||[]}getEventToItemsMap(){return this.Ki}de(){return this.se}},ug=class extends cg{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return ya.SHOWN}ie(e){var t;(t=this._instance)==null||t.getSurveys(e)}ue(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}ne(){return we}he(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},dg=class{constructor(e){this.ve=void 0,this._surveyManager=null,this.ce=!1,this.fe=[],this.pe=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(ve(t))return we.warn("Flags not loaded yet. Not loading surveys.");var r=_e(t);this.ve=r?t.length>0:t,we.info("flags response received, isSurveysEnabled: "+this.ve),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var r=localStorage.key(t);(r!=null&&r.startsWith(kw)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.ce)we.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)we.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())we.info("Not loading surveys in cookieless mode without consent.");else{var e=ee?.__PosthogExtensions__;if(e){if(!H(this.ve)||this._instance.config.advanced_enable_surveys){var t=this.ve||this._instance.config.advanced_enable_surveys;this.ce=!0;try{var r=e.generateSurveys;if(r)return void this.ge(r,t);var i=e.loadExternalDependency;if(!i)return void this._e("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",(s=>{s||!e.generateSurveys?this._e("Could not load surveys script",s):this.ge(e.generateSurveys,t)}))}catch(s){throw this._e("Error initializing surveys",s),s}finally{this.ce=!1}}}else we.error("PostHog Extensions not found.")}}ge(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new ug(this._instance),we.info("Surveys loaded successfully"),this.me({isLoaded:!0})}_e(e,t){we.error(e,t),this.me({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.fe.push(e),this._surveyManager&&this.me({isLoaded:!0}),()=>{this.fe=this.fe.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return we.info("Disabled. Not loading surveys."),e([]);var r,i=this._instance.get_property(Nh);if(i&&!t)return e(i,{isLoaded:!0});typeof Promise<"u"&&this.pe?this.pe.then((s=>{var{surveys:o,context:a}=s;return e(o,a)})):(typeof Promise<"u"&&(this.pe=new Promise((s=>{r=s}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:s=>{var o;this.pe=null;var a=s.statusCode;if(a!==200||!s.json){var l="Surveys API could not be loaded, status: "+a;we.error(l);var c={isLoaded:!1,error:l};return e([],c),void(r==null||r({surveys:[],context:c}))}var u,p=s.json.surveys||[],f=p.filter((g=>(function(v){return!(!v.start_date||v.end_date)})(g)&&((function(v){var m;return!((m=v.conditions)==null||(m=m.events)==null||(m=m.values)==null||!m.length)})(g)||(function(v){var m;return!((m=v.conditions)==null||(m=m.actions)==null||(m=m.values)==null||!m.length)})(g))));f.length>0&&((u=this._surveyEventReceiver)==null||u.register(f)),(o=this._instance.persistence)==null||o.register({[Nh]:p});var h={isLoaded:!0};e(p,h),r?.({surveys:p,context:h})}}))}me(e){for(var t of this.fe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(r){we.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!ve(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);we.warn("init was not called")}be(e){var t=null;return this.getSurveys((r=>{var i;t=(i=r.find((s=>s.id===e)))!==null&&i!==void 0?i:null})),t}ye(e){if(ve(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.be(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(ve(this._surveyManager))return we.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.ye(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return ve(this._surveyManager)?(we.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((r=>{this.getSurveys((i=>{var s,o=(s=i.find((l=>l.id===e)))!==null&&s!==void 0?s:null;if(o){var a=this.ye(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,r){var i;if(ve(this._surveyManager))we.warn("init was not called");else{var s=typeof e=="string"?this.be(e):e;if(s!=null&&s.id)if(IT.includes(s.type)){var o=D?.querySelector(t);if(o)return(i=s.appearance)!=null&&i.surveyPopupDelaySeconds?(we.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var a,l;we.info("Rendering survey "+s.id+" with delay of "+((a=s.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(s,o,r),we.info("Survey "+s.id+" rendered")}),1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,o,r);we.warn("Survey element not found")}else we.warn("Surveys of type "+s.type+" cannot be rendered in the app");else we.warn("Survey not found")}}displaySurvey(e,t){var r;if(ve(this._surveyManager))we.warn("init was not called");else{var i=this.be(e);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&t.ignoreDelay&&(s=W({},i,{appearance:W({},i.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==ag.Popover&&t.initialResponses&&we.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var o=this.canRenderSurvey(i);if(!o.visible)return void we.warn("Survey is not eligible to be displayed: ",o.disabledReason)}t.displayType!==ag.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else we.warn("Survey not found")}}cancelPendingSurvey(e){ve(this._surveyManager)?we.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}},En=Pe("[Conversations]"),pg=class{constructor(e){this.we=void 0,this._conversationsManager=null,this.xe=!1,this.Ee=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;ve(t)||(In(t)?this.we=t:(this.we=t.enabled,this.Ee=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.we=void 0,this.Ee=null}loadIfEnabled(){if(!this._conversationsManager&&!this.xe&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=ee?.__PosthogExtensions__;if(e&&!H(this.we)&&this.we)if(this.Ee&&this.Ee.token){this.xe=!0;try{var t=e.initConversations;if(t)return this.$e(t),void(this.xe=!1);var r=e.loadExternalDependency;if(!r)return void this.Se("PostHog loadExternalDependency extension not found.");r(this._instance,"conversations",(i=>{i||!e.initConversations?this.Se("Could not load conversations script",i):this.$e(e.initConversations),this.xe=!1}))}catch(i){this.Se("Error initializing conversations",i),this.xe=!1}}else En.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),En.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else En.error("Cannot complete initialization: remote config is null")}Se(e,t){En.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():En.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!Mt(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,r){var i=this;return _s((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(En.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var r=this;return _s((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(En.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return _s((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(En.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return _s((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(En.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}},fg=class{constructor(e){var t;this.ke=!1,this.Pe=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.ke=!0)}onRemoteConfig(e){var t,r=(t=e.logs)==null?void 0:t.captureConsoleLogs;!ve(r)&&r&&(this.ke=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.ke&&!this.Pe){var e=Pe("[logs]"),t=ee?.__PosthogExtensions__;if(t){var r=t.loadExternalDependency;r?r(this._instance,"logs",(i=>{var s;i||(s=t.logs)==null||!s.initializeLogs?e.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Pe=!0)})):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}},y0=Pe("[RateLimiter]"),hg=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var r=t.text;if(r&&r.length)try{(JSON.parse(r).quota_limited||[]).forEach((i=>{y0.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void y0.warn('could not rate limit - continuing. Error: "'+i?.message+'"',{text:r})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,r,i;e===void 0&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(r=this.instance.persistence)==null?void 0:r.get_property(Dh))!==null&&t!==void 0?t:{tokens:s,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>s&&(l.tokens=s);var c=l.tokens<1;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(i=this.instance.persistence)==null||i.set_property(Dh,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},ii=Pe("[RemoteConfig]"),gg=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=ee._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Te(e){var t,r;(t=ee.__PosthogExtensions__)!=null&&t.loadExternalDependency?(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(ii.error("PostHog Extensions not found. Cannot load remote config."),e())}Ie(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return ii.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void ii.warn("Remote config is disabled. Falling back to local config.");this.Te((e=>{if(!e)return ii.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ie((t=>{this.yi(t)}));this.yi(e)}))}catch(e){ii.error("Error loading remote config",e)}}yi(e){e?this._instance.config.__preview_remote_config?(this._instance.yi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):ii.info("__preview_remote_config is disabled. Logging config instead",e):ii.error("Failed to fetch remote config from PostHog.")}},mg=3e3,vg=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=Jt(t?.flush_interval_ms||mg,250,5e3,V.createLogger("flush interval"),mg),this.Oe=e}enqueue(e){this.Re.push(e),this.Me||this.Ae()}unload(){this.je();var e=this.Re.length>0?this.De():{},t=Object.values(e);[...t.filter((r=>r.url.indexOf("/e")===0)),...t.filter((r=>r.url.indexOf("/e")!==0))].map((r=>{this.Oe(W({},r,{transport:"sendBeacon"}))}))}enable(){this.Ce=!1,this.Ae()}Ae(){var e=this;this.Ce||(this.Me=setTimeout((()=>{if(this.je(),this.Re.length>0){var t=this.De(),r=function(){var s=t[i],o=new Date().getTime();s.data&&_e(s.data)&&xe(s.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Oe(s)};for(var i in t)r()}}),this.Fe))}je(){clearTimeout(this.Me),this.Me=void 0}De(){var e={};return xe(this.Re,(t=>{var r,i=t,s=(i?i.batchKey:null)||i.url;H(e[s])&&(e[s]=W({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)})),this.Re=[],e}},PT=["retriesPerformedSoFar"],yg=class{constructor(e){this.Le=!1,this.Ne=3e3,this.Re=[],this._instance=e,this.Re=[],this.Ue=!0,!H(S)&&"onLine"in S.navigator&&(this.Ue=S.navigator.onLine,this.ze=()=>{this.Ue=!0,this.Lt()},this.He=()=>{this.Ue=!1},Fe(S,"online",this.ze),Fe(S,"offline",this.He))}get length(){return this.Re.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,r=E0(e,PT);vs(t)&&(r.url=bu(r.url,{retry_count:t})),this._instance._send_request(W({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(t??0)<10?this.Be(W({retriesPerformedSoFar:t},r)):r.callback==null||r.callback(i)}}))}Be(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var r=(function(o){var a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(t),i=Date.now()+r;this.Re.push({retryAt:i,requestOptions:e});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),V.warn(s),this.Le||(this.Le=!0,this.qe())}qe(){if(this.We&&clearTimeout(this.We),this.Re.length===0)return this.Le=!1,void(this.We=void 0);this.We=setTimeout((()=>{this.Ue&&this.Re.length>0&&this.Lt(),this.qe()}),this.Ne)}Lt(){var e=Date.now(),t=[],r=this.Re.filter((s=>s.retryAt<e||(t.push(s),!1)));if(this.Re=t,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.We&&(clearTimeout(this.We),this.We=void 0),this.Le=!1,H(S)||(this.ze&&(S.removeEventListener("online",this.ze),this.ze=void 0),this.He&&(S.removeEventListener("offline",this.He),this.He=void 0)),this.Re))try{this._instance._send_request(W({},e,{transport:"sendBeacon"}))}catch(t){V.error(t)}this.Re=[]}},_g=class{constructor(e){this.Ge=()=>{var t,r,i,s;this.Ve||(this.Ve={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,c=a+(o?.clientHeight||0),u=o?.scrollHeight||0;this.Ve.lastScrollY=Math.ceil(a),this.Ve.maxScrollY=Math.max(a,(t=this.Ve.maxScrollY)!==null&&t!==void 0?t:0),this.Ve.maxScrollHeight=Math.max(l,(r=this.Ve.maxScrollHeight)!==null&&r!==void 0?r:0),this.Ve.lastContentY=c,this.Ve.maxContentY=Math.max(c,(i=this.Ve.maxContentY)!==null&&i!==void 0?i:0),this.Ve.maxContentHeight=Math.max(u,(s=this.Ve.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=e}getContext(){return this.Ve}resetContext(){var e=this.Ve;return setTimeout(this.Ge,0),e}startMeasuringScrollPosition(){Fe(S,"scroll",this.Ge,{capture:!0}),Fe(S,"scrollend",this.Ge,{capture:!0}),Fe(S,"resize",this.Ge)}scrollElement(){if(!this._instance.config.scroll_root_selector)return S?.document.documentElement;var e=_e(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var r=S?.document.querySelector(t);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return S&&(S.scrollY||S.pageYOffset||S.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return S&&(S.scrollX||S.pageXOffset||S.document.documentElement.scrollLeft)||0}},OT=n=>vw(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),xu=class{constructor(e,t,r,i){this.Je=s=>{var o=this.Ke();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Ye(this._instance)};this.Xe.register({[Fh]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||OT,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[Fh]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?yw(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return xe($g(this.getSetOnceProps()),((t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+mh(r)]=t})),e}},fh=Pe("[SessionId]"),Su=class{on(e,t){return this.Ze.on(e,t)}constructor(e,t,r){var i;if(this.tr=[],this.ir=void 0,this.Ze=new Ta,this.er=(u,p)=>!(!vs(u)||!vs(p))&&Math.abs(u-p)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.Xe=e.persistence,this.rr=void 0,this.sr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.nr=t||cr,this.ar=r||cr;var s=this.R.persistence_name||this.R.token,o=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Jt(o,60,36e3,fh.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.lr(),this.ur="ph_"+s+"_window_id",this.hr="ph_"+s+"_primary_window_exists",this.dr()){var a=ze.W(this.ur),l=ze.W(this.hr);a&&!l?this.rr=a:ze.V(this.ur),ze.G(this.hr,!0)}if((i=this.R.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var p=u.replace(/-/g,"");if(p.length!==32)throw new Error("Not a valid UUID");if(p[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(p.substring(0,12),16)})(this.R.bootstrap.sessionID);this.vr(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){fh.error("Invalid sessionID in bootstrap",u)}this.cr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return H(this.tr)&&(this.tr=[]),this.tr.push(e),this.sr&&e(this.sr,this.rr),()=>{this.tr=this.tr.filter((t=>t!==e))}}dr(){return this.R.persistence!=="memory"&&!this.Xe.ki&&ze.H()}pr(e){e!==this.rr&&(this.rr=e,this.dr()&&ze.G(this.ur,e))}gr(){return this.rr?this.rr:this.dr()?ze.W(this.ur):null}vr(e,t,r){e===this.sr&&t===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=t,this.sr=e,this.Xe.register({[au]:[t,e,r]}))}_r(){var e=this.Xe.props[au];return _e(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.vr(null,null,null)}destroy(){clearTimeout(this.mr),this.mr=void 0,this.ir&&S&&(S.removeEventListener("beforeunload",this.ir,{capture:!1}),this.ir=void 0),this.tr=[]}cr(){this.ir=()=>{this.dr()&&ze.V(this.hr)},Fe(S,"beforeunload",this.ir,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=t||new Date().getTime(),[i,s,o]=this._r(),a=this.gr(),l=vs(o)&&Math.abs(r-o)>864e5,c=!1,u=!s,p=!u&&!e&&this.er(r,i);u||p||l?(s=this.nr(),a=this.ar(),fh.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}}),o=r,c=!0):a||(a=this.ar(),c=!0);var f=vs(i)&&e&&!l?i:r,h=vs(o)?o:new Date().getTime();return this.pr(a),this.vr(s,f,h),e||this.lr(),c&&this.tr.forEach((g=>g(s,a,c?{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}:void 0))),{sessionId:s,windowId:a,sessionStartTimestamp:h,changeReason:c?{noSessionId:u,activityTimeout:p,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}lr(){clearTimeout(this.mr),this.mr=setTimeout((()=>{var[e]=this._r();if(this.er(new Date().getTime(),e)){var t=this.sr;this.resetSessionId(),this.Ze.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},MT=["$set_once","$set"],ar=Pe("[SiteApps]"),bg=class{constructor(e){this._instance=e,this.br=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}yr(e,t){if(t){var r=this.globalsForEvent(t);this.br.push(r),this.br.length>1e3&&(this.br=this.br.slice(10))}}get siteAppLoaders(){var e;return(e=ee._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.yr.bind(this));this.wr=()=>{e(),this.br=[],this.wr=void 0}}}globalsForEvent(e){var t,r,i,s,o,a,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],p=this._instance.get_property("$stored_group_properties")||{};for(var[f,h]of Object.entries(p))c[f]={id:u[f],type:f,properties:h};var{$set_once:g,$set:v}=e;return{event:W({},E0(e,MT),{properties:W({},e.properties,v?{$set:W({},(t=(r=e.properties)==null?void 0:r.$set)!==null&&t!==void 0?t:{},v)}:{},g?{$set_once:W({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},g)}:{}),elements_chain:(o=(a=e.properties)==null?void 0:a.$elements_chain)!==null&&o!==void 0?o:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],r=()=>{var a;!t.errored&&this.br.length&&(ar.info("Processing "+this.br.length+" events for site app with id "+e.id),this.br.forEach((l=>t.processEvent==null?void 0:t.processEvent(l))),t.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((a=this.wr)==null||a.call(this))},i=!1,s=a=>{t.errored=!a,t.loaded=!0,ar.info("Site app with id "+e.id+" "+(a?"loaded":"errored")),i&&r()};try{var{processEvent:o}=e.init({posthog:this._instance,callback:a=>{s(a)}});o&&(t.processEvent=o),i=!0}catch(a){ar.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&t.loaded)try{r()}catch(a){ar.error("Error while processing buffered events PostHog app with config id "+e.id,a),t.errored=!0}}Er(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}$r(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(t)}catch(i){ar.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var t,r,i,s=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.Er(),void this._instance.on("eventCaptured",(c=>this.$r(c)))):void ar.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.wr)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(c){var u;ee["__$$ph_site_app_"+c]=s._instance,(u=ee.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(s._instance,l,(p=>{if(p)return ar.error("Error while initializing PostHog app with config id "+c,p)}))};for(var{id:a,url:l}of e.siteApps)o(a)}else ar.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},Aw=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&Pb(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>Pb(i?.brand,e))))return!0}catch{}return!!n.webdriver},_a=(function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n})({}),_0="i.posthog.com",wg=class{constructor(e){this.Sr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+_0,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.Sr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=_a.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=_a.EU:this.Sr[this.apiHost]=_a.CUSTOM),this.Sr[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===_a.CUSTOM)return this.apiHost+t;var r=_0+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},LT={icontains:(n,e)=>!!S&&e.href.toLowerCase().indexOf(n.toLowerCase())>-1,not_icontains:(n,e)=>!!S&&e.href.toLowerCase().indexOf(n.toLowerCase())===-1,regex:(n,e)=>!!S&&wu(e.href,n),not_regex:(n,e)=>!!S&&!wu(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},xg=class n{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),t.getWebExperiments((i=>{n.kr("retrieved web experiments from the server"),t.Pr=new Map,i.forEach((s=>{if(s.feature_flag_key){var o;t.Pr&&(n.kr("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=t.Pr)==null||o.set(s.feature_flag_key,s));var a=t._instance.getFeatureFlag(s.feature_flag_key);Ve(a)&&s.variants[a]&&t.Tr(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var c=s.variants[l];n.Ir(c)&&t.Tr(s.name,l,c.transforms)}}))}),r)},this._instance=e,this._instance.onFeatureFlags((r=>{this.onFeatureFlags(r)}))}onFeatureFlags(e){if(this._is_bot())n.kr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(ve(this.Pr))return this.Pr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();n.kr("applying feature flags",e),e.forEach((t=>{var r;if(this.Pr&&(r=this.Pr)!=null&&r.has(t)){var i,s=this._instance.getFeatureFlag(t),o=(i=this.Pr)==null?void 0:i.get(t);s&&o!=null&&o.variants[s]&&this.Tr(o.name,s,o.variants[s].transforms)}}))}}previewWebExperiment(){var e=n.getWindowLocation();if(e!=null&&e.search){var t=hu(e?.search,"__experiment_id"),r=hu(e?.search,"__experiment_variant");t&&r&&(n.kr("previewing web experiments "+t+" && "+r),this.getWebExperiments((i=>{this.Cr(parseInt(t),r,i)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!t)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:s=>{if(s.statusCode!==200||!s.json)return e([]);var o=s.json.experiments||[];return e(o)}})}Cr(e,t,r){var i=r.filter((s=>s.id===e));i&&i.length>0&&(n.kr("Previewing web experiment ["+i[0].name+"] with variant ["+t+"]"),this.Tr(i[0].name,t,i[0].variants[t].transforms))}static Ir(e){return!ve(e.conditions)&&n.Rr(e)&&n.Fr(e)}static Rr(e){var t;if(ve(e.conditions)||ve((t=e.conditions)==null?void 0:t.url))return!0;var r,i,s,o=n.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||LT[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return S?.location}static Fr(e){var t;if(ve(e.conditions)||ve((t=e.conditions)==null?void 0:t.utm))return!0;var r=fw();if(r.utm_source){var i,s,o,a,l,c,u,p,f=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_campaign)==r.utm_campaign,h=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,g=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==r.utm_medium,v=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((p=e.conditions)==null||(p=p.utm)==null?void 0:p.utm_term)==r.utm_term;return f&&g&&v&&h}return!1}static kr(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),i=1;i<t;i++)r[i-1]=arguments[i];V.info("[WebExperiments] "+e,r)}Tr(e,t,r){this._is_bot()?n.kr("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?r.forEach((i=>{if(i.selector){var s;n.kr("applying transform of variant "+t+" for experiment "+e+" ",i);var o=(s=document)==null?void 0:s.querySelectorAll(i.selector);o?.forEach((a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)}))}})):n.kr("Control variants leave the page unmodified.")}_is_bot(){return ht&&this._instance?Aw(ht,this._instance.config.custom_blocked_useragents):void 0}},NT=Pe("[PostHog ExternalIntegrations]"),FT={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Sg=class{constructor(e){this._instance=e}it(e,t){var r;(r=ee.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(i=>{if(i)return NT.error("failed to load script",i);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,c;!i||(a=ee.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(FT[o],(()=>{var u;(u=ee.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.start(e._instance)})),!i&&(l=ee.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((c=ee.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.stop())};for(var[r,i]of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;t(r)}}},Eg="[SessionRecording]",da=Pe(Eg),Eu=class{get started(){var e;return!((e=this.Or)==null||!e.isStarted)}get status(){return this.Or?this.Or.status:this.Mr&&!this.Ar?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Mr=!1,this.jr=void 0,this._instance=e,!this._instance.sessionManager)throw da.error("started without valid sessionManager"),new Error(Eg+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Eg+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(eh))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return S&&t&&r&&!i}startIfEnabledOrStop(e){var t;if(!this.Ar||(t=this.Or)==null||!t.isStarted){var r=!H(Object.assign)&&!H(Array.from);this.Ar&&r?(this.Dr(e),da.info("starting")):this.stopRecording()}}Dr(e){var t,r,i;this.Ar&&(ee!=null&&(t=ee.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(r=ee.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Lr(e):(i=ee.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Nr,(s=>{if(s)return da.error("could not load recorder",s);this.Lr(e)})))}stopRecording(){var e,t;(e=this.jr)==null||e.call(this),this.jr=void 0,(t=this.Or)==null||t.stop()}Ur(){var e;(e=this._instance.persistence)==null||e.unregister(Y0)}zr(e){if(this._instance.persistence){var t,r,i=this._instance.persistence,s=()=>{var o=e.sessionRecording===!1?void 0:e.sessionRecording,a=o?.sampleRate,l=ve(a)?null:parseFloat(a);ve(l)&&this.Ur();var c=o?.minimumDurationMilliseconds;i.register({[eh]:W({enabled:!!o},o,{networkPayloadCapture:W({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:H(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};s(),(t=this.jr)==null||t.call(this),this.jr=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.zr(e),this.Mr=!0,this.startIfEnabledOrStop()):this.Mr=!0:da.info("skipping remote config with no sessionRecording",e)}log(e,t){var r;t===void 0&&(t="log"),(r=this.Or)!=null&&r.log?this.Or.log(e,t):da.warn("log called before recorder was ready")}get Nr(){var e,t,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(eh);return(r==null||(t=r.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Lr(e){var t,r;if((t=ee.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Or||(this.Or=(r=ee.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.Or._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Or.start(e)}onRRwebEmit(e){var t;(t=this.Or)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Or)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Or||(t=this._instance.persistence)==null||t.register({$replay_override_sampling:!0}),(e=this.Or)==null||e.overrideSampling()}overrideTrigger(e){var t,r;this.Or||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Or)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Or)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var r;return!((r=this.Or)==null||!r.tryAddCustomEvent(e,t))}},xa={},Cg=()=>{},ys="posthog",Tw=!CT&&ct?.indexOf("MSIE")===-1&&ct?.indexOf("Mozilla")===-1,b0=n=>{var e;return W({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:V1(D?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Cg,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:n??"unset",__preview_deferred_init_extensions:!1,debug:qe&&Ve(qe?.search)&&qe.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(S==null||(e=S.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var r="Bad HTTP status: "+t.statusCode+" "+t.text;V.error(r)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:mg},error_tracking:{},_onCapture:Cg,__preview_eager_load_replay:!1},(t=>({rageclick:!(t&&t>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(t&&t>="2025-05-24")||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(n))},w0=n=>{var e={};H(n.process_person)||(e.person_profiles=n.process_person),H(n.xhr_headers)||(e.request_headers=n.xhr_headers),H(n.cookie_name)||(e.persistence_name=n.cookie_name),H(n.disable_cookie)||(e.disable_persistence=n.disable_cookie),H(n.store_google)||(e.save_campaign_params=n.store_google),H(n.verbose)||(e.debug=n.verbose);var t=Me({},e,n);return _e(n.property_blacklist)&&(H(n.property_denylist)?t.property_denylist=n.property_blacklist:_e(n.property_denylist)?t.property_denylist=[...n.property_blacklist,...n.property_denylist]:V.error("Invalid value for property_denylist config: "+n.property_denylist)),t},kg=class{constructor(){this.__forceAllowLocalhost=!1}get Hr(){return this.__forceAllowLocalhost}set Hr(e){V.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Cu=class n{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new kg,this.Br=!1,this.version=Cn.LIB_VERSION,this.qr=new Ta,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=b0(),this.SentryIntegration=Kh,this.sentryIntegration=e=>(function(t,r){var i=pw(t,r);return{name:dw,processEvent:s=>i(s)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new sg(this),this.toolbar=new Yh(this),this.scrollManager=new _g(this),this.pageViewManager=new vu(this),this.surveys=new dg(this),this.conversations=new pg(this),this.logs=new fg(this),this.experiments=new xg(this),this.exceptions=new ig(this),this.rateLimiter=new hg(this),this.requestRouter=new wg(this),this.consent=new qh(this),this.externalIntegrations=new Sg(this),this.people={set:(e,t,r)=>{var i=Ve(e)?{[e]:t}:e;this.setPersonProperties(i),r?.({})},set_once:(e,t,r)=>{var i=Ve(e)?{[e]:t}:e;this.setPersonProperties(void 0,i),r?.({})}},this.on("eventCaptured",(e=>V.info('send "'+e?.event+'"',e)))}init(e,t,r){if(r&&r!==ys){var i,s=(i=xa[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),xa[r]=s,xa[ys][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),H(e)||vh(e))return V.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(Me({},b0(t.defaults),w0(t),{name:r,token:e})),this.config.on_xhr_error&&V.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:Tn.GZipJS;var s=this.Qr();this.persistence=new wa(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new wa(W({},this.config,{persistence:"sessionStorage"}),s);var o=W({},this.persistence.props),a=W({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new vg((w=>this.ts(w)),this.config.request_queue_config),this.es=new yg(this),this.__request_queue=[];var l=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new Su(this),this.sessionPropsManager=new xu(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(V.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.rs(l)}),0)):(V.info("Initializing extensions synchronously"),this.rs(l)),Cn.DEBUG=Cn.DEBUG||this.config.debug,Cn.DEBUG&&V.info("Starting in debug mode",{this:this,config:t,thisC:W({},this.config),p:o,s:a}),((i=t.bootstrap)==null?void 0:i.distinctID)!==void 0){var c,u,p=this.config.get_device_id(cr()),f=(c=t.bootstrap)!=null&&c.isIdentifiedID?p:t.bootstrap.distinctID;this.persistence.set_property(kn,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:f})}if(this.ss()){var h,g,v=Object.keys(((h=t.bootstrap)==null?void 0:h.featureFlags)||{}).filter((w=>{var x;return!((x=t.bootstrap)==null||(x=x.featureFlags)==null||!x[w])})).reduce(((w,x)=>{var _;return w[x]=((_=t.bootstrap)==null||(_=_.featureFlags)==null?void 0:_[x])||!1,w}),{}),m=Object.keys(((g=t.bootstrap)==null?void 0:g.featureFlagPayloads)||{}).filter((w=>v[w])).reduce(((w,x)=>{var _,k;return(_=t.bootstrap)!=null&&(_=_.featureFlagPayloads)!=null&&_[x]&&(w[x]=(k=t.bootstrap)==null||(k=k.featureFlagPayloads)==null?void 0:k[x]),w}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:m})}if(l)this.register_once({distinct_id:ra,$device_id:null},"");else if(!this.get_distinct_id()){var y=this.config.get_device_id(cr());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(kn,"anonymous")}return Fe(S,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?cT(this,(()=>this.ns())):this.ns(),ur(this.config._onCapture)&&this.config._onCapture!==Cg&&(V.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(w=>this.config._onCapture(w.event,w)))),this.config.ip&&V.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}rs(e){var t=performance.now();this.historyAutocapture=new Gh(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new Jh(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new bg(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new Eu(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new Uh(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.logs.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new og(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new Qh(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new Xh(this)})),r.push((()=>{this.exceptionObserver=new Zh(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new mu(this,lT),this.deadClicksAutocapture.startIfEnabled()})),r.push((()=>{if(this.os){var i=this.os;this.os=void 0,this.yi(i)}})),this.ls(r,t)}ls(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.ls(e,t)}),0);var r=e.shift();if(r)try{r()}catch(s){V.error("Error initializing extension:",s)}}var i=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:i}),this.config.__preview_deferred_init_extensions&&V.info("PostHog extensions initialized ("+i+"ms)")}yi(e){var t,r,i,s,o,a,l,c,u;if(!D||!D.body)return V.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.yi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.os=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=me(e.supportedCompression,Tn.GZipJS)?Tn.GZipJS:me(e.supportedCompression,Tn.Base64)?Tn.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"identified_only"}),(r=this.siteApps)==null||r.onRemoteConfig(e),(i=this.sessionRecording)==null||i.onRemoteConfig(e),(s=this.autocapture)==null||s.onRemoteConfig(e),(o=this.heatmaps)==null||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(r){V.critical("`loaded` function failed",r)}if(this.us(),this.config.internal_or_test_user_hostname&&qe!=null&&qe.hostname){var e=qe.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.hs()}),1),new gg(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Zr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&dr(this.__request_queue,(e=>this.ts(e))),this.__request_queue=[],this.us()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.ds()&&this.capture("$pageleave"),(e=this.Zr)==null||e.unload(),(t=this.es)==null||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(Tw?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=bu(e.url,{ip:this.config.ip?1:0}),e.headers=W({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var r,i,s,o=W({},t);o.timeout=o.timeout||6e4,o.url=bu(o.url,{_:new Date().getTime().toString(),ver:Cn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=ru.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(i=(s=Z0(l,(u=>u.transport===a)))==null?void 0:s.method)!==null&&i!==void 0?i:l[0].method;if(!c)throw new Error("No available transport method");c(o)})(W({},e,{callback:t=>{var r,i;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,t)),e.callback==null||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,r=[],i=[],s=[];dr(e,(a=>{a&&(t=a[0],_e(t)?s.push(a):ur(a)?a.call(this):_e(a)&&t==="alias"?r.push(a):_e(a)&&t.indexOf("capture")!==-1&&ur(this[t])?s.push(a):i.push(a))}));var o=function(a,l){dr(a,(function(c){if(_e(c[0])){var u=l;xe(c,(function(p){u=u[p[0]].apply(u,p.slice(1))}))}else this[c[0]].apply(this,c.slice(1))}),l)};o(r,this),o(i,this),o(s,this)}ss(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!H(e)&&Ve(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(s&&!this.config.__preview_capture_bot_pageviews)){var o=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(o==null||!o.isRateLimited){t!=null&&t.$current_url&&!Ve(t?.$current_url)&&(V.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=r?.timestamp||a,c=cr(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),o&&(u.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),r?.$set&&(u.$set=r?.$set);var p,f=e!=="$groupidentify",h=this.vs(r?.$set_once,f);if(h&&(u.$set_once=h),(u=H1(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,H(r?.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===ya.DISMISSED||e===ya.SENT){var g=t?.[ph.SURVEY_ID],v=t?.[ph.SURVEY_ITERATION];p={id:g,current_iteration:v},localStorage.getItem(v0(p))||localStorage.setItem(v0(p),"true"),u.$set=W({},u.$set,{[RT({id:g,current_iteration:v},e===ya.SENT?"responded":"dismissed")]:!0})}else e===ya.SHOWN&&(u.$set=W({},u.$set,{[ph.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var m=W({},u.properties.$set,u.$set);if(bs(m)||this.setPersonPropertiesForFlags(m),!ve(this.config.before_send)){var y=this.cs(u);if(!y)return;u=y}this.qr.emit("eventCaptured",u);var w={method:"POST",url:(i=r?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:r?._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.ts(w):this.Zr.enqueue(w),u}V.critical("This capture call is ignored due to client rate limiting.")}}else V.error("No event name provided to posthog.capture")}else V.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return t;var o=s?void 0:this.persistence.remove_event_timer(e),a=W({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=W({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!Ve(a.distinct_id)&&!$n(a.distinct_id)||vh(a.distinct_id))&&V.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=gT(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:p,windowId:f}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=p,a.$window_id=f}this.sessionPropsManager&&Me(a,this.sessionPropsManager.getSessionProps());try{var h;this.sessionRecording&&Me(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(h=this.es)==null?void 0:h.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}if(this.requestRouter.region===_a.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||s?e!=="$pageleave"||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=Me(a,c),e==="$pageview"&&D&&(a.title=D.title),!H(o)){var g=r.getTime()-o;a.$duration=parseFloat((g/1e3).toFixed(3))}ct&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Me({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),_e(this.config.property_denylist)?xe(this.config.property_denylist,(function(y){delete a[y]})):V.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(V.error("sanitize_properties is deprecated. Use before_send instead"),a=v(a,e));var m=this.fs();return a.$process_person_profile=m,m&&!s&&this.ps("_calculate_event_properties"),a}vs(e,t){var r;if(t===void 0&&(t=!0),!this.persistence||!this.fs()||this.Br)return e;var i=this.persistence.get_initial_props(),s=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),o=Me({},i,s||{},e||{}),a=this.config.sanitize_properties;return a&&(V.error("sanitize_properties is deprecated. Use before_send instead"),o=a(o,"$set_once")),t&&(this.Br=!0),bs(o)?void 0:o}register(e,t){var r;(r=this.persistence)==null||r.register(e,t)}register_once(e,t,r){var i;(i=this.persistence)==null||i.register_once(e,t,r)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}gs(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,r){var i=r!=null&&r.merge?this.featureFlags.getFlagVariants():{},s=r!=null&&r.merge?this.featureFlags.getFlagPayloads():{},o=W({},i,e),a=W({},s,t),l={};for(var[c,u]of Object.entries(o)){var p=typeof u=="string";l[c]={key:c,enabled:!!p||!!u,variant:p?u:void 0,reason:void 0,metadata:H(a?.[c])?void 0:{id:0,version:void 0,description:void 0,payload:a[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,r)}getEarlyAccessFeatures(e,t,r){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,r)}on(e,t){return this.qr.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,r;return(t=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){t===void 0&&(t=$T),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,r){if(!this.__loaded||!this.persistence)return V.uninitializedWarning("posthog.identify");if($n(e)&&(e=e.toString(),V.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))V.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==ra){if(this.ps("posthog.identify")){var i=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var s=i;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==i&&e!==this.get_property(fa)&&(this.unregister(fa),this.register({distinct_id:e}));var o=(this.persistence.get_property(kn)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(kn,"identified"),this.setPersonPropertiesForFlags(W({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=d0(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(lu))}}else V.critical('The string "'+ra+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else V.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var r=d0(this.get_distinct_id(),e,t);this.Jr!==r?(this.setPersonPropertiesForFlags(W({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=r):V.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,r){if(e&&t){var i=this.getGroups();i[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:W({},i,{[e]:t})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===t||r||this.reloadFeatureFlags()}else V.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,r,i,s;if(V.info("reset"),!this.__loaded)return V.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(kn,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:ra,$device_id:null},"");else{var a=this.config.get_device_id(cr());this.register_once({distinct_id:a,$device_id:e?a:o},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&r){var s,o=(s=e.timestampLookBack)!==null&&s!==void 0?s:10;if(!r)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-o,0)}return i}alias(e,t){return e===this.get_property(G0)?(V.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(H(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(fa,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(V.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=W({},this.config);if(Be(e)){var r,i,s,o,a,l,c;Me(this.config,w0(e));var u=this.Qr();(r=this.persistence)==null||r.update_config(this.config,t,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new wa(W({},this.config,{persistence:"sessionStorage"}),u);var p=this.Kr(this.config.debug);In(p)&&(this.config.debug=p),In(this.config.debug)&&(this.config.debug?(Cn.DEBUG=!0,Te.H()&&Te.G("ph_debug","true"),V.info("set_config",{config:e,oldConfig:t,newConfig:W({},this.config)})):(Cn.DEBUG=!1,Te.H()&&Te.V("ph_debug"))),(i=this.exceptionObserver)==null||i.onConfigChange(),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),(c=this.externalIntegrations)==null||c.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,r={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(e==null||!e.event_trigger)};if(Object.values(r).some(Boolean)){var i,s,o,a,l;(i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),r.sampling&&((s=this.sessionRecording)==null||s.overrideSampling()),r.linked_flag&&((o=this.sessionRecording)==null||o.overrideLinkedFlag()),r.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),r.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(W({},i,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:ys;return t!==ys&&(t=ys+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(kn))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(kn))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&bs(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[fa])&&((t=this.persistence)==null||(t=t.props)==null||!t[uu]))}ds(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return this.config.person_profiles==="never"?(V.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(uu,!0),!0)}Qr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!t}_s(){var e,t,r,i,s=this.Qr();return((e=this.persistence)==null?void 0:e.ki)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((t=this.sessionPersistence)==null?void 0:t.ki)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){var r,i,s;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new Su(this),this.pageViewManager=new vu(this),this.persistence&&(this.sessionPropsManager=new xu(this,this.sessionManager,this.persistence)),this.sessionRecording=new Eu(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(H(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((s=e?.captureEventName)!==null&&s!==void 0?s:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.hs()}else V.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,r;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:ra,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(r=this.sessionRecording)==null||r.stopRecording(),this.sessionRecording=void 0,this.hs())):V.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===An.GRANTED?"granted":e===An.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._s()}_is_bot(){return ht?Aw(ht,this.config.custom_blocked_useragents):void 0}hs(){D&&(D.visibilityState==="visible"?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:D.title},{send_instantly:!0}),this.Gr&&(D.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),Fe(D,"visibilitychange",this.Gr)))}debug(e){e===!1?(S?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(S?.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}M(){var e,t,r,i,s,o,a,l=this.Yr||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(V.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(r="advanced_disable_decide",i=!1,s=V,o=(t="advanced_disable_flags")in(e=l)&&!ve(e[t]),a=r in e&&!ve(e[r]),o?e[t]:a?(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[r]):i)}cs(e){if(ve(this.config.before_send))return e;var t=_e(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of t){if(r=i(r),ve(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return p1(e.event)?V.warn(s+". This can cause unexpected behavior."):V.info(s),null}r.properties&&!bs(r.properties)||V.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(r)})}Kr(e){var t=In(e)&&!e,r=Te.H()&&Te.q("ph_debug")==="true";return!t&&(!!r||e)}};(function(n,e){for(var t=0;t<e.length;t++)n.prototype[e[t]]=D1(n.prototype[e[t]])})(Cu,["identify"]);var x0;var Rw=(x0=xa[ys]=new Cu,(function(){function n(){n.done||(n.done=!0,Tw=!1,xe(xa,(function(e){e._dom_loaded()})))}D!=null&&D.addEventListener?D.readyState==="complete"?n():Fe(D,"DOMContentLoaded",n,{capture:!1}):S&&V.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),x0);var Fg=class{constructor(e={}){this.options=e;if(this.client=e.client,this.featureFlagsCallback=e.onFeatureFlagsLoaded,this.captureCallback=e.onCapture,this.rrwebCallback=e.onRRWebEvent,!this.client&&e.consent&&e.requireExplicitConsent&&typeof window<"u"&&e.apiKey){let t=e.consent;t.getStatus()==="granted"&&this.initPostHog(),t.subscribe(i=>{i==="granted"?this.client?this.client.opt_in_capturing():this.initPostHog():i==="denied"&&this.client&&this.client.opt_out_capturing()});return}!this.client&&typeof window<"u"&&e.apiKey&&this.initPostHog()}initPostHog(){let e=this.options;if(!e.apiKey)return;let t=e.enableFeatureFlags??!0,r=`syntro_${e.apiKey.slice(-6)||"sdk"}`,o={api_host:`${(e.apiHost??"https://telemetry.syntrologie.com").replace(/\/$/,"")}/t/${e.apiKey}`,advanced_disable_feature_flags:!t,advanced_disable_feature_flags_on_first_load:!t,autocapture:e.autocapture??!0,capture_pageview:e.capturePageview??"history_change",capture_pageleave:e.capturePageleave??!0,disable_session_recording:!(e.sessionRecording??!0),opt_out_useragent_filter:!0,session_recording:{recordCrossDomainIFrames:!0},capture_performance:!0,enable_recording_console_log:!0};e.cookieless_mode&&(o.cookieless_mode=e.cookieless_mode);let a=Rw.init(e.apiKey,o,r);if(a&&(this.client=a),this.captureCallback&&this.client&&this.client.on("eventCaptured",(...l)=>{let c=l[0],u=typeof c=="string"?c:c?.event,p=typeof c=="string"?void 0:c?.properties;typeof u=="string"&&this.captureCallback?.(u,p)}),t&&this.featureFlagsCallback&&this.client){this.client.onFeatureFlags(()=>{let c=this.getAllFeatureFlags();c&&this.featureFlagsCallback&&this.featureFlagsCallback(c)});let l=this.getAllFeatureFlags();l&&Object.keys(l).length>0&&this.featureFlagsCallback(l)}this.rrwebCallback&&this.client&&this.setupRRWebIntercept()}setupRRWebIntercept(e=30){let t=this.client?.sessionRecording;if(!t){e>0&&setTimeout(()=>this.setupRRWebIntercept(e-1),500);return}let r=null,i=t;for(let o of Object.getOwnPropertyNames(i)){let a=i[o];if(a&&typeof a=="object"&&typeof a.onRRwebEmit=="function"&&typeof a.start=="function"&&a!==t){r=a;break}}if(!r){e>0&&setTimeout(()=>this.setupRRWebIntercept(e-1),500);return}let s=r.onRRwebEmit.bind(r);r.onRRwebEmit=o=>{this.rrwebCallback?.({kind:"rrweb",...o}),s(o)},typeof window<"u"&&(window.__RRWEB_INTERCEPT_READY__=!0)}getAllFeatureFlags(){return this.client?.featureFlags?.getFlagVariants()}getSegmentFlags(){let e=this.getAllFeatureFlags();if(!e)return{};let t={};for(let[r,i]of Object.entries(e))r.startsWith("in_segment_")&&(t[r]=i===!0);return t}identify(e,t){this.client?.identify(e,t)}alias(e,t){this.client?.alias(e,t)}optInCapturing(){this.client?.opt_in_capturing()}optOutCapturing(){this.client?.opt_out_capturing()}track(e,t){this.client?.capture(e,t)}trackCanvasOpened(e){this.track("shadow_canvas_opened",{surface:e})}trackCanvasClosed(e){this.track("shadow_canvas_closed",{surface:e})}trackRectangleViewed(e,t){this.track("shadow_canvas_rectangle_viewed",{rectangleId:e,surface:t})}trackAction(e,t,r){this.track("shadow_canvas_action",{action:e,rectangleId:t,surface:r})}register(e){this.client?.register?.(e)}getSessionId(){return this.client?.get_session_id?.()}startSessionRecording(){this.client?.startSessionRecording?.()}trackExperiment(e,t,r){let i=`$experiment_${e}`;this.register({[i]:r??`variation_${t}`,[`${i}_id`]:t}),this.track("$experiment_started",{$experiment_key:e,$experiment_variation_id:t,$experiment_variation_name:r??`variation_${t}`})}setPersonProperties(e){this.client?.capture("$set",{$set:e})}setPersonPropertiesOnce(e){this.client?.capture("$set",{$set_once:e})}getDistinctId(){return this.client?.get_distinct_id?.()}};function Ru(n={}){return new Fg(n)}var Iw={posthog:n=>Ru(n),noop:()=>Yc()};function $w(n,e){let t=Iw[n];if(!t)throw new Error(`Unknown telemetry provider: ${n}. Supported: ${Object.keys(Iw).join(", ")}`);return t(e)}function DT(n){return n?.manifest?.runtime!==void 0}async function Pw(n){$p(),q("Syntro Bootstrap","====== INIT ======"),q("Syntro Bootstrap","Options:",{hasToken:!!n.token,tokenPrefix:`${n.token?.slice(0,15)}...`,hasCanvasOptions:!!n.canvas});let e=xc();if(console.log(`[DIAG] Mode detection: sdkMode=${e}`),console.log("[DIAG] editorSource:",Bo()),console.log("[DIAG] editorConf:",wc()),q("Syntro Bootstrap","SDK mode:",e??"normal"),!e&&typeof window<"u"){let R=!!window.__SYNTRO_EDITOR_PARAMS__,Y=!!window.__SYNTRO_AUDIT_LEGEND__,B=!!window.__SYNTRO_REVIEW_DATA__;if(R||Y||B){let fe=[R&&"__SYNTRO_EDITOR_PARAMS__",Y&&"__SYNTRO_AUDIT_LEGEND__",B&&"__SYNTRO_REVIEW_DATA__"].filter(Boolean);console.warn(`[Syntro Bootstrap] \u26A0 Mode detection returned null but mode-specific globals found: ${fe.join(", ")}. This suggests URL params were lost (redirect?) but the service worker injected mode data. Check if replaceState failed or if page JS changed the URL before init().`)}}console.log(`[DIAG] Token resolution: options.token=${n.token?n.token.slice(0,15)+"...":"null"}`);let t=n.token;if(!t&&e){let Y=wc()?.syntro_token;Y?.startsWith("syn_")&&(t=Y,q("Syntro Bootstrap",`\u2713 Using syntro_token from editor_conf (${e} mode)`))}let r;if(t)if(t.startsWith("syn_"))q("Syntro Bootstrap","Token starts with syn_, decoding..."),r=ns(t),$p(r.d);else if(e)q("Syntro Bootstrap",`\u2713 Non-syn_ token allowed (${e} mode)`);else throw ic("Syntro Bootstrap","\u274C Token does not start with syn_ and NOT in editor/audit/review mode!"),ic("Syntro Bootstrap","Token received:",t),new Error("Invalid Syntro token: must start with 'syn_'");else if(e)q("Syntro Bootstrap",`\u2713 No token, but ${e} mode - proceeding`);else throw ic("Syntro Bootstrap","\u274C No token provided and NOT in editor/audit/review mode!"),new Error("Syntro token is required (unless in editor, audit, or review mode)");let i=xt("NEXT_PUBLIC_SYNTRO_EXPERIMENT_HOST")||xt("VITE_SYNTRO_EXPERIMENT_HOST")||r?.eh,s=xt("NEXT_PUBLIC_SYNTRO_TELEMETRY_HOST")||xt("VITE_SYNTRO_TELEMETRY_HOST")||r?.th;if(r!=null&&r.obd!==!0&&s)try{let R=`${s.replace(/\/$/,"")}/sdk-otel/v1/logs`,Y=Pp({resource:{serviceName:"syntro-runtime-sdk",serviceVersion:Zi,posthogKey:r.t??"",hostOrigin:typeof window<"u"?window.location.origin:""},emit:Mp({endpoint:R})}),B=Np()??"https://cdn.syntrologie.com/runtime-sdk/",fe=Yp(Y,{attributedScriptUrlPrefix:B});Y.attachAdapterCleanup(fe)}catch{}let o=xt("NEXT_PUBLIC_SYNTRO_EDITOR_URL")||xt("VITE_SYNTRO_EDITOR_URL")||n.canvas?.editorUrl,a=r?.g||xt("NEXT_PUBLIC_SYNTRO_GEO_HOST")||xt("VITE_SYNTRO_GEO_HOST")||g_,l=l_(),c=mf(),u=n.appSignalsInit??{},p=f_(),f=vf(c,p);h_(f);let h={...c,...f,...l,...u};q("Syntro Bootstrap","Phase 1: Browser metadata:",c),q("Syntro Bootstrap","Phase 1: Initial attrs:",f),q("Syntro Bootstrap","Phase 1: Cached segment attributes:",l),Object.keys(u).length>0&&q("Syntro Bootstrap","Phase 1: App signals:",u);let g=yf(a),v=(()=>{try{if(typeof window>"u"||window.self===window.top)return Promise.resolve(null)}catch{}return new Promise(R=>{let Y=setTimeout(()=>{window.removeEventListener("message",B),R(null)},500);function B(fe){let he=fe.data;he?.jsonrpc==="2.0"&&he?.id===1&&he?.result?.hostInfo&&(clearTimeout(Y),window.removeEventListener("message",B),R(he.result.hostInfo))}window.addEventListener("message",B);try{window.parent.postMessage({jsonrpc:"2.0",id:1,method:"ui/initialize",params:{capabilities:{}}},"*")}catch{clearTimeout(Y),window.removeEventListener("message",B),R(null)}})})(),m,y=n.debug||n.testMode,w=Bi({debug:n.debug,history:y?new ss(n.testMode?0:100):void 0,testMode:n.testMode});console.log("[Syntro Bootstrap] EventBus created");let x=_d({elementResolver:typeof window<"u"?(R,Y)=>{let B=document.elementFromPoint(R,Y);if(!B)return null;let fe={tag_name:B.tagName.toLowerCase()};B.id&&(fe.attr__id=B.id),B.className&&typeof B.className=="string"&&(fe.classes=B.className.split(" ").filter(Boolean));for(let he of B.attributes)he.name.startsWith("data-")&&(fe[`attr__${he.name}`]=he.value);return fe}:void 0});if(x.onEvent(R=>w.publishEvent(R)),typeof window<"u")try{hb(w),gb(w)}catch(R){We("Syntro Bootstrap","scroll instrumentation install failed",R)}typeof window<"u"&&(setInterval(()=>x.tick(Date.now()),1e3),document.addEventListener("click",R=>{let Y=[],B=R.target;for(;B&&B!==document.body;){let fe={tag_name:B.tagName.toLowerCase()};for(let he of B.attributes)(he.name.startsWith("data-")||he.name==="id"||he.name==="class"||he.name==="aria-label")&&(fe[`attr__${he.name}`]=he.value);Y.push(fe),B=B.parentElement}x.enrichClickAttributes(Date.now(),Y)},!0));let _=yb(),k,I=R=>{q("Syntro Bootstrap","Phase 2: PostHog feature flags loaded");let Y=d_(R);if(q("Syntro Bootstrap","Segment flags from PostHog:",Y),c_(Y),m){let B=A?.getAll?.()??{},fe=is(b?.getDistinctId?.()),he={...c,...f,...B,...Y,...u,id:fe};q("Syntro Bootstrap","Updating GrowthBook with attributes:",he),m.setAttributes?.(he)}if(k&&b?.getDistinctId){let B=b.getDistinctId();B&&s&&r?.t&&k.updateContext({distinctId:B,telemetryHost:s,telemetryKey:r.t})}},b;if(r?.t){let R=r.t==="noop"?"noop":"posthog";if(b=$w(R,{apiKey:r.t,apiHost:s,enableFeatureFlags:!0,sessionRecording:!0,cookieless_mode:"on_reject",onFeatureFlagsLoaded:I,onCapture:(se,Re)=>{x.ingest({kind:"posthog",event:se,properties:Re,timestamp:Date.now()})},onRRWebEvent:se=>{x.ingest(se)}}),console.log(`[Syntro Bootstrap] Telemetry client created (${R}) with EventBus wiring`),b){let se=b.getDistinctId?.bind(b);b.getDistinctId=()=>is(se?.())}try{b.track?.("syntro_bootstrap_step",{stage:"telemetry_ready"})}catch{}Object.keys(u).length>0&&(b.track?.("app_signals_init",u),q("Syntro Bootstrap","Tracked app signals event:",u));let Y=b;w.setPosthogCapture((se,Re)=>{Y.track?.(se,Re)});let B=b,fe=async()=>{let se=await g;return se.is_eu==="true"||se.country_code==="GB"||se.country_code==="CH"?"denied":"granted"},he=new na({initialStatus:"pending",pendingResolver:fe,onConsentChange:se=>{u_(se),se==="granted"?B.optInCapturing?.():se==="denied"&&B.optOutCapturing?.()}});try{B.track?.("syntro_bootstrap_step",{stage:"consent_gate_constructed"})}catch{}try{S_(b,he,{geoPromise:g}),q("Syntro Bootstrap","SDK defaults installed (D-1..D-5) with consent gate");try{B.track?.("syntro_bootstrap_step",{stage:"defaults_installed"})}catch{}}catch(se){We("Syntro Bootstrap","installDefaults failed",se);try{B.track?.("syntro_bootstrap_step",{stage:"defaults_install_failed",err:String(se)})}catch{}}try{let se=new ta({adapters:[new ea,new Qo,new Xo],fallbackStatus:fe,onAdapterSelected:Re=>{B.track?.("syntro_consent_adapter_selected",{adapter:Re??"none"}),q("Syntro Bootstrap",`Consent adapter selected: ${Re??"none"}`)}});try{B.track?.("syntro_bootstrap_step",{stage:"detector_started"})}catch{}se.start(he).then(()=>{try{B.track?.("syntro_bootstrap_step",{stage:"detector_resolved"})}catch{}}).catch(Re=>{We("Syntro Bootstrap","Consent detector failed to start",Re);try{B.track?.("syntro_bootstrap_step",{stage:"detector_failed",err:String(Re)})}catch{}})}catch(se){We("Syntro Bootstrap","Consent detector setup failed",se);try{B.track?.("syntro_bootstrap_step",{stage:"detector_setup_failed",err:String(se)})}catch{}}try{k=v_({telemetry:b,telemetryHost:s,telemetryKey:r.t,platformAdapter:_,debug:q,warn:We}).shopifyPixelBridge}catch(se){We("Syntro Bootstrap","wirePlatformAdapters failed",se)}}let A;r?.e&&(m=cb("growthbook",{clientKey:r.e,apiHost:i,attributes:{...h,id:is(b?.getDistinctId?.())},onExperimentViewed:b?.trackExperiment?(R,Y,B)=>{b.trackExperiment(R,Y,B)}:void 0})),A=Zc({experiments:m,onMetricChange:(R,Y)=>{q("Syntro Bootstrap",`Session metric changed: ${R} = ${Y}`)}}),q("Syntro Bootstrap","SessionMetricTracker created");let M="production";e==="editor"?M="editor":e==="audit"?M="audit":xt("NODE_ENV")==="development"&&(M="development");let J=typeof c.surface_type=="string"?c.surface_type:"web",$=typeof c.surface_host=="string"?c.surface_host:"web",U=Ql({telemetry:b,sessionMetrics:A,mode:M,events:w,initialSurfaceType:J,initialSurfaceHost:$,backendUrl:n.backendUrl});_&&(U.getProductIdentity=R=>_.extractProductIdentity(R)),q("Syntro Bootstrap","Runtime created:",{version:U.version,mode:U.mode,hasContext:!!U.context,hasEvents:!!U.events,hasState:!!U.state,hasProductIdentity:!!U.getProductIdentity});let G=async R=>{if(!t?.startsWith("syn_")||!r?.t||!n.backendUrl)return"unknown";let Y=await Cb({backendUrl:n.backendUrl,token:t,posthogKey:r.t,getSessionId:()=>b?.getSessionId?.(),getUserId:()=>b?.getDistinctId?.()},R);return m?.setAttributes?.({[R.name]:Y}),Y},Z=async R=>{if(!t?.startsWith("syn_")||!r?.t||!n.backendUrl)return R.map(()=>"unknown");let Y=await Eb({backendUrl:n.backendUrl,token:t,posthogKey:r.t,getSessionId:()=>b?.getSessionId?.(),getUserId:()=>b?.getDistinctId?.()},R);return m?.setAttributes?.(Object.fromEntries(R.map((B,fe)=>[B.name,Y[fe]]))),Y},te=(R,Y)=>{if(!n.backendUrl)throw new Error("[syntro] authedFetch: no backendUrl configured");let B=n.backendUrl.replace(/\/$/,""),fe=/^https?:\/\//.test(R)?R:`${B}${R.startsWith("/")?R:`/${R}`}`;if(new URL(fe).origin!==new URL(B).origin)throw new Error("[syntro] authedFetch: refusing cross-origin request (token would leak)");let he={};t&&(he.Authorization=`Bearer ${t}`);let se=b?.getDistinctId?.();se&&(he["X-Distinct-Id"]=se);let Re=b?.getSessionId?.();return Re&&(he["X-Syntro-Session"]=Re),fetch(fe,{...Y,credentials:"include",headers:{"Content-Type":"application/json",...Y?.headers,...he}})};q("Syntro Bootstrap","Core app executors already registered");let ye=n.cdnBase||xt("NEXT_PUBLIC_SYNTRO_CDN_BASE")||xt("VITE_SYNTRO_CDN_BASE")||Rl()||"https://cdn.syntrologie.com",pe=Qu({cdnBase:ye,registry:U.apps,onLoadStart:R=>{q("Syntro Bootstrap",`Loading app from CDN: ${R}`)},onLoadEnd:(R,Y,B)=>{Y?q("Syntro Bootstrap",`App loaded successfully: ${R}`):We("Syntro Bootstrap",`Failed to load app: ${R}`,B)}});typeof window<"u"&&(window.SynOS={...window.SynOS,appRegistry:U.apps,appLoader:pe,runtime:U,experiments:m,score:G,scoreMulti:Z,authedFetch:te,version:U.version},q("Syntro Bootstrap","Global SynOS object exposed")),typeof window<"u"&&window.parent!==window&&pe.loadApp("adaptive-mcp").catch(R=>{q("Syntro Bootstrap","auto-load of adaptive-mcp failed (non-fatal):",R)});let j=U.apps.list?.()??[];console.log(`[DIAG] Activation loop: ${j.length} apps in registry:`,j.map(R=>`${R.manifest.id}(${R.state})`).join(", "));for(let R of j)if(R.state==="registered"&&DT(R))try{await U.apps.activate(R.manifest.id),console.log(`[DIAG] Activated: ${R.manifest.id} \u2192 widgets: [${U.widgets.list().join(", ")}]`)}catch(Y){console.error(`[DIAG] FAILED to activate: ${R.manifest.id}`,Y),We("Syntro Bootstrap",`Failed to auto-activate built-in app: ${R.manifest.id}`,Y)}if(console.log(`[DIAG] Activation complete. Total widgets: [${U.widgets.list().join(", ")}]`),m?.refreshFeatures){let Y=performance.now(),B=!1,fe=!1;try{await Promise.race([m.refreshFeatures().then(()=>{}),new Promise(he=>setTimeout(()=>{B=!0,he()},500))]),q("Syntro Bootstrap","GrowthBook features loaded (or timeout reached)")}catch(he){fe=!0,We("Syntro Bootstrap","Failed to load GrowthBook features:",he)}try{b?.track?.("syntro_bootstrap_step",{stage:"gb_features_fetch",duration_ms:Math.round(performance.now()-Y),timeout_ms:500,timed_out:B,failed:fe})}catch{}}let X=await g;if(m&&Object.keys(X).length>0){let R={...c,...f,...X,...u,id:is(b?.getDistinctId?.())};q("Syntro Bootstrap","Merging geo data into GrowthBook attributes:",X),m.setAttributes?.(R)}let Oe=await v;Oe&&m&&(c.surface_type="mcp-app",c.surface_host=Oe.name,m.setAttributes?.({...c,...f,...X,id:is(b?.getDistinctId?.())}),U.context.setSurfaceType("mcp-app"),U.context.setSurfaceHost(Oe.name),q("Syntro Bootstrap","MCP App detected:",Oe.name));let Ye;if(n.fetcher)Ye=n.fetcher;else if(r?.f){let R=fb(r.f,r.o??{});Ye=async()=>{let Y=await R.fetch();return{...Y.config,tiles:Y.config.tiles??[]}}}else m&&(Ye=Ur({experiments:m}));let De=new Set;function Je(R,Y){let B=pe.getRequiredApps(R);B.length>0?console.log("[Syntro Bootstrap] Required external apps:",B.join(", ")):q("Syntro Bootstrap","No external apps required (all executors are built-in)"),B.length!==0&&gl({appIds:B,loadApp:fe=>pe.loadApp(fe),apps:U.apps,warnedAppFailures:De}).catch(fe=>{console.error(`[Syntro Bootstrap] app loading (${Y}) rejected:`,fe)})}function Xe(R){return async()=>{let Y=await R();return Je(Y,"override"),Y}}let Pn=Ye?async()=>{let R=await Ye(),Y=R.tiles?.length??0,B=R.actions?.length??0,fe=R.meta?.variant_id,he=R.meta?.variants;if((Y>0||B>0)&&(fe||console.warn("[Syntro] Config has content but no meta.variant_id \u2014 intervention tracking disabled")),b&&fe){let se=typeof window<"u"?window.SynOS??(window.SynOS={}):void 0,Re=se?.interventionTracker,Xt;if(Re&&Re.variantId===fe)Xt=Re;else{let Qt=se?.interventionTrackerUnsub;if(Qt)try{Qt()}catch(zw){console.warn("[Syntro] interventionTracker nav unsub threw:",zw)}Xt=new hs(b,fe),se&&(se.interventionTracker=Xt);let $s=U.navigation.subscribe(()=>{Xt.resetPage()});se&&(se.interventionTrackerUnsub=$s)}if(he&&he.length>0)for(let Qt of he)Xt.trackServedForVariant(Qt.variant_id,Qt.tiles,Qt.actions);else Xt.trackServed(Y,B)}return console.log("[Syntro Bootstrap] Config fetched:",`tiles=${R.tiles?.length??0},`,`actions=${R.actions?.length??0},`,`theme=${R.theme?.name??"none"}`),R.actions?.length>0&&console.log("[Syntro Bootstrap] Actions in config:",R.actions.map((se,Re)=>`[${Re}] ${se.kind}${se.anchorId?` anchor="${se.anchorId.selector}"`:""}${se.label?` "${se.label}"`:""}`).join(", ")),Je(R,"initial"),R}:void 0;if(_){q("Syntro Bootstrap",`Detected platform: ${_.name}`);try{await _.onInit(),q("Syntro Bootstrap",`Platform adapter initialized: ${_.name}`)}catch(R){We("Syntro Bootstrap",`Platform adapter init failed: ${_.name}`,R)}}if(typeof window<"u"){let R=window.SynOS??(window.SynOS={});R.wrapCanvasConfigFetcher=Xe}let Lt=await Sc({...n.canvas,fetcher:Pn,integrations:{experiments:m,telemetry:b},editorUrl:o,runtime:U}),Is=jt();if(Is!==null)try{let R=b,Y=U;Is.bindRuntime({getSessionId:()=>{try{return R?.getSessionId?.()??""}catch{return""}},getSurface:()=>{try{let B=Y.context.get().surface;return B?{...B}:null}catch{return null}}})}catch{}return Is?.increment("bootstrap_ok"),{canvas:Lt,runtime:U,experiments:m,telemetry:b,sessionMetrics:A,appLoader:pe}}async function HT(n){try{return await Pw(n)}catch(e){let t=e instanceof Error?e.message:String(e);console.warn("[Syntrologie] SDK initialization failed:",t),jt()?.increment("bootstrap_errors"),typeof document<"u"&&document.getElementById("syntrologie-anti-flicker")?.remove();return}}function BT(n,e={}){if(typeof window>"u")return;let t=window.SynOS?.runtime;t?.events?.publish&&t.events.publish({name:n,source:"custom",props:e})}async function VT(n){if(typeof window>"u")return{appId:n,success:!1,error:"no-window"};let e=window.SynOS?.appLoader;return e?e.loadApp(n):{appId:n,success:!1,error:"syntro-not-initialized"}}var Dg={init:HT,loadAdaptive:VT,encodeToken:Ec,decodeToken:ns,events:{emit:BT}};typeof window<"u"&&(window.Syntro=Dg);function Rs(n){let e=n.split(".");return{major:parseInt(e[0]||"0",10),minor:parseInt(e[1]||"0",10)}}function UT(n){let e=[],t=[];if(!n||typeof n!="object")return{valid:!1,errors:["Config must be an object"],warnings:e};let r=n;if(r.tiles||t.push("Config missing required field: tiles"),r.actions||t.push("Config missing required field: actions"),r.fetchedAt||t.push("Config missing required field: fetchedAt"),t.length>0)return{valid:!1,errors:t,warnings:e};let i=r.schemaVersion||"1.0",s=Rs(i),o=Rs(vn);return s.major>o.major&&e.push(`Config schema v${i} is newer than SDK v${vn}. Some features may not work. Update SDK to latest version.`),s.major<o.major||!r.schemaVersion?(e.push(`Config schema v${i} is older than SDK v${vn}. Migrating config to current version.`),{valid:!0,warnings:e,errors:t,migratedConfig:jT(r,i)}):{valid:!0,warnings:e,errors:t}}function jT(n,e){let t={...n};return Rs(e).major===1&&(t=WT(t)),t.schemaVersion=vn,t}function WT(n){let e={schemaVersion:"2.0",tiles:[],actions:n.actions||[],fetchedAt:n.fetchedAt||new Date().toISOString()};return n.tiles&&Array.isArray(n.tiles)&&(e.tiles=n.tiles.map(t=>{let r={...t};return t.experiment&&delete r.experiment,r})),n.configVersion&&(e.configVersion=n.configVersion),n.canvasTitle&&(e.canvasTitle=n.canvasTitle),n.theme&&(e.theme=n.theme),n.launcher&&(e.launcher=n.launcher),e}function zT(n){if(!n||typeof n!="object")return!1;let e=n,t=e.schemaVersion||"1.0",r=Rs(t),i=Rs(vn);return r.major<i.major||!e.schemaVersion}var Ow=d.object({url:d.string(),routeId:d.string().optional(),title:d.string().optional(),locale:d.string().optional()}),Mw=d.object({url:d.string(),ts:d.number()}),Lw=d.object({sessionId:d.string(),startTs:d.number(),pageHistory:d.array(Mw).optional()}),Nw=d.object({width:d.number(),height:d.number()}),Fw=d.object({x:d.number(),y:d.number(),w:d.number(),h:d.number()}),Dw=d.object({anchorId:d.string(),present:d.boolean(),visible:d.boolean().optional(),boundingBox:Fw.optional()}),Hw=d.record(d.string(),d.union([d.number(),d.string(),d.boolean(),d.undefined()])),Bw=d.object({page:Ow,session:Lw,viewport:Nw,anchors:d.array(Dw).optional(),augmented:Hw.optional()});function qT(n){return Bw.safeParse(n)}var Iu=class{constructor(e,t,r,i){this._isFallback=!0;this._isLoading=!0;this._cancelled=!1;this._host=e,this._runtime=t,this._strategy=r,this._defaultValue=i,this._value=i,e.addController(this)}get value(){return this._value}get isFallback(){return this._isFallback}get isLoading(){return this._isLoading}hostConnected(){this._evaluate()}hostDisconnected(){this._cancelled=!0}setStrategy(e){this._strategy=e,this._evaluate()}_evaluate(){if(this._cancelled=!1,!this._runtime||!this._strategy){this._value=this._defaultValue,this._isFallback=!0,this._isLoading=!1,this._host.requestUpdate();return}this._isLoading=!0,this._host.requestUpdate();let e=this._strategy;this._runtime.evaluate(e).then(t=>{this._cancelled||(this._value=t.value,this._isFallback=t.isFallback,this._isLoading=!1,this._host.requestUpdate())})}};var $u=class{constructor(e,t){this._unsubscribe=null;this.host=e,this._runtime=t,this._context=t.context.get(),e.addController(this)}hostConnected(){this._context=this._runtime.context.get(),this._unsubscribe=this._runtime.context.subscribe(e=>{this._context=e,this.host.requestUpdate()})}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=null}get runtime(){return this._runtime}get context(){return this._context}get page(){return this._context?.page??null}get session(){return this._context?.session??null}get viewport(){return this._context?.viewport??null}};var Pu=class{constructor(e,t,r,i){this._runtime=t,this._filter=r,this._callback=i,e.addController(this)}hostConnected(){this._subscribe()}hostDisconnected(){this._unsubscribe?.(),this._unsubscribe=void 0}setFilter(e){this._filter=e,this._unsubscribe!==void 0&&(this._unsubscribe(),this._unsubscribe=void 0,this._subscribe())}setCallback(e){this._callback=e,this._unsubscribe!==void 0&&(this._unsubscribe(),this._unsubscribe=void 0,this._subscribe())}_subscribe(){this._runtime&&(this._unsubscribe=this._filter?this._runtime.events.subscribe(this._filter,this._callback):this._runtime.events.subscribe(this._callback))}};var Hg=d.enum(["posthog","canvas","derived"]),Vw=d.object({ts:d.number(),name:d.string(),source:Hg,props:d.record(d.string(),d.unknown()).optional(),schemaVersion:d.string()}),Uw=d.object({names:d.array(d.string()).optional(),patterns:d.array(d.string()).optional(),sources:d.array(Hg).optional()});function ZT(n){return Vw.safeParse(n)}function GT(n){return Uw.safeParse(n)}var jw=d.object({value:d.unknown(),expiresAt:d.number().optional()}),Ww=d.object({count:d.number(),resetAt:d.number().optional()});function KT(n){return jw.safeParse(n)}function YT(n){return Ww.safeParse(n)}var Bg="2026-07-24T19:21:30.096Z (1235b1302)";if(typeof window<"u"){console.log(`[Syntro Runtime] Build: ${Bg} (Lit)`);let n=window.SynOS,e=n?.appRegistry||eo;window.SynOS={...n,appRegistry:e,_runtimeBuild:Bg,_renderer:"lit"},Fo(),sv(e)}return Jw(JT);})();
|
|
627
627
|
/*! Bundled license information:
|
|
628
628
|
|
|
629
629
|
@lit/reactive-element/css-tag.js:
|