@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.
@@ -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
- `}};_l.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",_l);function bl(n,e,t="merge"){return t==="first-match"?vC(n,e):yC(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 ey([i])}return null}function yC(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:ey(t)}function ey(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 Fd=!1;function ty(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("syntro_debug")==="true"}catch{return!1}}function Dd(n){if(ty()){Fd=!0;return}Fd=n??!1}function _C(){return ty()?!0:Fd}function q(n,e,t){_C()&&(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 wl(n,e,t){t!==void 0?console.error(`[${n}]`,e,t):console.error(`[${n}]`,e)}var xl=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:ny(i,.5),p95:ny(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 ny(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 io=null;function Hd(n){return io?.stop(),io=new xl(n),io.start(),io}function jt(){return io}var hn=(n,e)=>({key:n,value:{stringValue:e}}),Bd=(n,e)=>({key:n,value:{intValue:Math.round(e)}}),ry=(n,e)=>({key:n,value:{doubleValue:e}});function bC(n){let{resource:e,counters:t,histograms:r,windowSeconds:i,windowStartUnixMs:s}=n,o=[hn("service.name",e.serviceName),hn("service.version",e.serviceVersion),hn("syntro.posthog_key",e.posthogKey),hn("syntro.session_id",e.sessionId),hn("syntro.surface_type",e.surfaceType),hn("syntro.surface_host",e.surfaceHost),hn("syntro.surface_device",e.surfaceDevice),hn("syntro.surface_mode",e.surfaceMode),hn("syntro.host_origin",e.hostOrigin)],a=[Bd("window_seconds",i)];for(let[u,p]of Object.entries(t))p!==void 0&&a.push(Bd(u,p));for(let[u,p]of Object.entries(r))p!==void 0&&(a.push(Bd(`${u}_count`,p.count)),a.push(ry(`${u}_p50`,p.p50)),a.push(ry(`${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 Vd(n){let e=n.fetchImpl??fetch;return async t=>{let r=JSON.stringify(bC(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 wC(){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 Ud=wC();function jd(){if(!Ud)return;let n=Ud.lastIndexOf("/");if(n!==-1)return Ud.substring(0,n+1)}var py=-1,ki=n=>{addEventListener("pageshow",(e=>{e.persisted&&(py=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)))}},Xd=n=>{requestAnimationFrame((()=>requestAnimationFrame((()=>n()))))},Qd=()=>{let n=performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},so=()=>Qd()?.activationStart??0,zt=(n,e=-1)=>{let t=Qd(),r="navigate";return py>=0?r="back-forward-cache":t&&(document.prerendering||so()>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}},Wd=new WeakMap;function ep(n,e){return Wd.get(n)||Wd.set(n,new e),Wd.get(n)}var qd=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)}},oo=(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{}},tp=n=>{let e=!1;return()=>{e||(n(),e=!0)}},Ci=-1,fy=new Set,iy=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,Zd=n=>{if(document.visibilityState==="hidden"){if(n.type==="visibilitychange")for(let e of fy)e();isFinite(Ci)||(Ci=n.type==="visibilitychange"?n.timeStamp:0,removeEventListener("prerenderingchange",Zd,!0))}},El=()=>{if(Ci<0){let n=so();Ci=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((t=>t.name==="hidden"&&t.startTime>n))[0]?.startTime)??iy(),addEventListener("visibilitychange",Zd,!0),addEventListener("prerenderingchange",Zd,!0),ki((()=>{setTimeout((()=>{Ci=iy()}))}))}return{get firstHiddenTime(){return Ci},onHidden(n){fy.add(n)}}},Cl=n=>{document.prerendering?addEventListener("prerenderingchange",(()=>n()),!0):n()},sy=[1800,3e3],np=(n,e={})=>{Cl((()=>{let t=El(),r,i=zt("FCP"),s=oo("paint",(o=>{for(let a of o)a.name==="first-contentful-paint"&&(s.disconnect(),a.startTime<t.firstHiddenTime&&(i.value=Math.max(a.startTime-so(),0),i.entries.push(a),r(!0)))}));s&&(r=Wt(n,i,sy,e.reportAllChanges),ki((o=>{i=zt("FCP"),r=Wt(n,i,sy,e.reportAllChanges),Xd((()=>{i.value=performance.now()-o.timeStamp,r(!0)}))})))}))},oy=[.1,.25],hy=(n,e={})=>{let t=El();np(tp((()=>{let r,i=zt("CLS",0),s=ep(e,qd),o=l=>{for(let c of l)s.h(c);s.i>i.value&&(i.value=s.i,i.entries=s.o,r())},a=oo("layout-shift",o);a&&(r=Wt(n,i,oy,e.reportAllChanges),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),ki((()=>{s.i=0,i=zt("CLS",0),r=Wt(n,i,oy,e.reportAllChanges),Xd((()=>r()))})),setTimeout(r))})))},gy=0,zd=1/0,Sl=0,xC=n=>{for(let e of n)e.interactionId&&(zd=Math.min(zd,e.interactionId),Sl=Math.max(Sl,e.interactionId),gy=Sl?(Sl-zd)/7+1:0)},Gd,ay=()=>Gd?gy:performance.interactionCount??0,SC=()=>{"interactionCount"in performance||Gd||(Gd=oo("event",xC,{type:"event",buffered:!0,durationThreshold:0}))},ly=0,Kd=class{constructor(){en(this,"u",[]);en(this,"l",new Map);en(this,"m");en(this,"p")}v(){ly=ay(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((ay()-ly)/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)}}},my=n=>{let e=globalThis.requestIdleCallback||setTimeout;document.visibilityState==="hidden"?n():(n=tp(n),addEventListener("visibilitychange",n,{once:!0,capture:!0}),e((()=>{n(),removeEventListener("visibilitychange",n,{capture:!0})})))},cy=[200,500],vy=(n,e={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let t=El();Cl((()=>{SC();let r,i=zt("INP"),s=ep(e,Kd),o=l=>{my((()=>{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=oo("event",o,{durationThreshold:e.durationThreshold??40});r=Wt(n,i,cy,e.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),ki((()=>{s.v(),i=zt("INP"),r=Wt(n,i,cy,e.reportAllChanges)})))}))},Yd=class{constructor(){en(this,"m")}h(e){this.m?.(e)}},uy=[2500,4e3],yy=(n,e={})=>{Cl((()=>{let t=El(),r,i=zt("LCP"),s=ep(e,Yd),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-so(),0),i.entries=[c],r())},a=oo("largest-contentful-paint",o);if(a){r=Wt(n,i,uy,e.reportAllChanges);let l=tp((()=>{o(a.takeRecords()),a.disconnect(),r(!0)})),c=u=>{u.isTrusted&&(my(l),removeEventListener(u.type,c,{capture:!0}))};for(let u of["keydown","click","visibilitychange"])addEventListener(u,c,{capture:!0});ki((u=>{i=zt("LCP"),r=Wt(n,i,uy,e.reportAllChanges),Xd((()=>{i.value=performance.now()-u.timeStamp,r(!0)}))}))}}))},dy=[800,1800],Jd=n=>{document.prerendering?Cl((()=>Jd(n))):document.readyState!=="complete"?addEventListener("load",(()=>Jd(n)),!0):setTimeout(n)},_y=(n,e={})=>{let t=zt("TTFB"),r=Wt(n,t,dy,e.reportAllChanges);Jd((()=>{let i=Qd();i&&(t.value=Math.max(i.responseStart-so(),0),t.entries=[i],r(!0),ki((()=>{t=zt("TTFB",0),r=Wt(n,t,dy,e.reportAllChanges),r(!0)})))}))};var by="__syntro_vitals_bound",kl="__syntro_vitals_current_reporter";function rp(n,e){if(typeof window>"u")return()=>{};let t=window;t[kl]=n;let r=null,i=e?.attributedScriptUrlPrefix;if(i&&"PerformanceObserver"in window)try{r=new PerformanceObserver(s=>{let o=t[kl];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[by]){t[by]=!0;let s=o=>a=>{t[kl]?.recordHistogram(o,a.value)};yy(s("lcp_ms")),vy(s("inp_ms")),np(s("fcp_ms")),_y(s("ttfb_ms")),hy(o=>{t[kl]?.recordHistogram("cls_score",o.value)})}return()=>{r?.disconnect()}}var ao="2.8.0-canary.477";var Vn="2.0";var EC=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function CC(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):EC.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 kC(n){if(typeof window>"u")return!1;try{return new URL(n).origin===window.location.origin}catch{return!1}}var wy="syntro_config_cache",AC=1440*60*1e3;function xy(){try{return typeof localStorage<"u"&&localStorage!==null}catch{return!1}}function TC(n,e){if(xy())try{let t={config:n,timestamp:Date.now(),sdkVersion:e};localStorage.setItem(wy,JSON.stringify(t))}catch{}}function RC(n){if(!xy())return null;try{let e=localStorage.getItem(wy);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>AC?null:t.config}catch{return null}}var IC=({configUri:n,experiments:e,featureKey:t})=>{if(n)return n;if(e&&t){let r=e.getFeatureValue?.(t,null);if(r)return r}};function $C(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 Ai=({configUri:n,experiments:e,featureKey:t,credentials:r,manifestKey:i,variantFlagPrefix:s,sdkVersion:o})=>async()=>{if(e&&(i||s||e.getAllFeatures)){let p=$C(e,i,s);if(console.log("[SmartCanvas Config] Variant key discovery:",p.length,"keys found"),p.length>0){let f=bl(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=IC({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(!CC(a))throw new Error(`SmartCanvas: config URI not allowed: ${a}`);let l=r??(kC(a)?"include":"omit"),c=performance.now(),u=!1;try{let p=await fetch(a,{credentials:l,headers:{"X-SDK-Version":ao,"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&&TC(f,o),f}catch(p){if(u||jt()?.increment("flag_fetch_errors"),o){let f=RC(o);if(f)return q("SmartCanvas Config","Serving config from offline cache"),f}throw p}};var ip=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)}},Sy=n=>new ip(n);var $t={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"},ut={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"},lo={0:"#051533",1:"#0a2a66",2:"#0f3f98",3:"#1454cb",4:"#1969fe",5:"#4787fe",6:"#75a5fe",7:"#a3c3ff",8:"#d1e1ff",9:"#e8f0ff"},co={0:"#662500",1:"#993d00",2:"#cc5800",3:"#ff7700",4:"#fea85d",5:"#fec58f",6:"#ffd6ae",7:"#fee6cd",8:"#fff1e1",9:"#fff8f0"},uo={0:"#151229",1:"#2a2452",2:"#40357c",3:"#5547a5",4:"#6a59ce",5:"#887ad8",6:"#a69be2",7:"#c3bdeb",8:"#e1def5",9:"#f0eefa"},po={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]},z2={primary:E[2],secondary:E[0]},q2={primary:E[4],secondary:E[3]},Al={primary:{text:$t.white,icon:$t.white,border:ce[3],backgroundDefault:ce[3],backgroundHover:ce[2]},neutral:{text:E[10],textHover:$t.white,icon:E[10],iconHover:$t.white,border:E[4],background:E[2]},link:{text:$t.white,icon:$t.white,hover:ce[5]},error:{text:Ce[5],hover:Ce[6]},success:{text:Ae[5],hover:Ae[6]}},Z2={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:ut[8],pillOutline:ut[4],borderPrimary:ut[2],borderSecondary:ut[2],background:ut[0]},green:{content:Ae[8],pillOutline:Ae[4],borderPrimary:Ae[2],borderSecondary:Ae[2],background:Ae[0]},purple:{content:uo[8],pillOutline:uo[4],borderPrimary:uo[2],borderSecondary:uo[2],background:uo[0]},blue:{content:lo[8],pillOutline:lo[4],borderPrimary:lo[2],borderSecondary:lo[2],background:lo[0]},orange:{content:co[8],pillOutline:co[4],borderPrimary:co[2],borderSecondary:co[2],background:co[0]},pink:{content:po[8],pillOutline:po[4],borderPrimary:po[2],borderSecondary:po[2],background:po[0]}},G2={green:{content:Ae[8],border:Ae[2],background:Ae[0]},yellow:{content:ut[8],border:ut[2],background:ut[0]},red:{content:Ce[8],border:Ce[2],background:Ce[0]}},K2={green:{content:Ae[1],background:Ae[9]},yellow:{content:ut[1],background:ut[9]},red:{content:Ce[1],background:Ce[9]}},Y2={content:E[10],border:E[4],background:E[3]},J2={backgroundDefault:E[2],backgroundHover:E[1],selected:E[3]},X2={background:E[2],icon:E[10],borderDefault:E[4],borderSelected:ce[3],textLabel:E[9],textPlaceholder:E[8],textHint:E[8]},Q2={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]},eL={handleDefault:$t.white,handleDisabled:E[10],off:{backgroundDefault:E[4],backgroundHover:E[5],backgroundDisabled:E[4]},on:{backgroundDefault:Ae[3],backgroundHover:Ae[2],backgroundDisabled:E[4]}},tL={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]}},nL={content:E[10],background:E[4]},rL={background:E[4],active:Ae[3]},iL={background:E[1],content:E[9],border:E[4]},sL={backgroundDefault:E[1],backgroundHover:E[3],backgroundActive:E[4],border:E[4],contentPrimary:E[10],contentSecondary:E[9],contentTertiary:E[8]},oL={background:E[1],content:E[9],border:E[4]},aL={activeBackground:E[3],activeContent:ce[5],inactiveContent:E[9],border:E[4]},lL={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]}},cL={textPrimaryDefault:E[10],textPrimaryHover:E[10],textSecondaryDefault:E[8],textSecondaryHover:E[9],iconPrimary:E[10],iconSecondary:E[8]},uL={background:Ae[1],active:Ae[5]},dL={textDefault:E[10],textSelected:$t.white,textDisabled:E[7],backgroundDefault:E[2],backgroundMiddle:E[3],backgroundSelected:ce[3],border:E[4]},pL=E[9];var mL={size:56,inset:12,background:$t.black,color:$t.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 PC(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}var Ey={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:Al.primary.backgroundDefault,backgroundHover:Al.primary.backgroundHover,color:Al.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:ut[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}}},Cy={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:ut[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 ky(n){let e=n.mode==="light"?Cy:Ey;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 Ay(n,e){let t=e.mode??n.mode??"dark",r=t==="light"?Cy:Ey;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 OC=["canvas","launcher","tile","overlay","notification","content"];function Ty(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 OC){let r=n[t];if(r)for(let[i,s]of Object.entries(r))s!==void 0&&typeof s=="string"&&(e[`--sc-${t}-${PC(i)}`]=s)}return e}var Un,Ur,jr,gn,mn,sp,Tl,fo=class{constructor(e,t,r){ne(this,mn);ne(this,Un);ne(this,Ur);ne(this,jr);ne(this,gn);L(this,Un,e),L(this,Ur,t??{}),L(this,jr,r),L(this,gn,ue(this,mn,sp).call(this)),e.addController(this)}get config(){return C(this,gn).config}get mode(){return C(this,gn).mode}get cssVariables(){return C(this,gn).cssVariables}hostConnected(){ue(this,mn,Tl).call(this)}hostDisconnected(){}hostUpdated(){ue(this,mn,Tl).call(this)}setThemeConfig(e,t){L(this,Ur,e),L(this,jr,t),L(this,gn,ue(this,mn,sp).call(this)),ue(this,mn,Tl).call(this),C(this,Un).requestUpdate()}};Un=new WeakMap,Ur=new WeakMap,jr=new WeakMap,gn=new WeakMap,mn=new WeakSet,sp=function(){let e=C(this,jr)?Ay(C(this,jr),C(this,Ur)):ky(C(this,Ur)),t=Ty(e);return{config:e,mode:e.mode,cssVariables:t}},Tl=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,gn).cssVariables).map(([i,s])=>` ${i}: ${s};`).join(`
383
+ `}};_l.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",_l);function bl(n,e,t="merge"){return t==="first-match"?vC(n,e):yC(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 ey([i])}return null}function yC(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:ey(t)}function ey(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 Fd=!1;function ty(){if(typeof window>"u")return!1;try{return new URLSearchParams(window.location.search).get("syntro_debug")==="true"}catch{return!1}}function Dd(n){if(ty()){Fd=!0;return}Fd=n??!1}function _C(){return ty()?!0:Fd}function q(n,e,t){_C()&&(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 wl(n,e,t){t!==void 0?console.error(`[${n}]`,e,t):console.error(`[${n}]`,e)}var xl=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:ny(i,.5),p95:ny(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 ny(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 io=null;function Hd(n){return io?.stop(),io=new xl(n),io.start(),io}function jt(){return io}var hn=(n,e)=>({key:n,value:{stringValue:e}}),Bd=(n,e)=>({key:n,value:{intValue:Math.round(e)}}),ry=(n,e)=>({key:n,value:{doubleValue:e}});function bC(n){let{resource:e,counters:t,histograms:r,windowSeconds:i,windowStartUnixMs:s}=n,o=[hn("service.name",e.serviceName),hn("service.version",e.serviceVersion),hn("syntro.posthog_key",e.posthogKey),hn("syntro.session_id",e.sessionId),hn("syntro.surface_type",e.surfaceType),hn("syntro.surface_host",e.surfaceHost),hn("syntro.surface_device",e.surfaceDevice),hn("syntro.surface_mode",e.surfaceMode),hn("syntro.host_origin",e.hostOrigin)],a=[Bd("window_seconds",i)];for(let[u,p]of Object.entries(t))p!==void 0&&a.push(Bd(u,p));for(let[u,p]of Object.entries(r))p!==void 0&&(a.push(Bd(`${u}_count`,p.count)),a.push(ry(`${u}_p50`,p.p50)),a.push(ry(`${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 Vd(n){let e=n.fetchImpl??fetch;return async t=>{let r=JSON.stringify(bC(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 wC(){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 Ud=wC();function jd(){if(!Ud)return;let n=Ud.lastIndexOf("/");if(n!==-1)return Ud.substring(0,n+1)}var py=-1,ki=n=>{addEventListener("pageshow",(e=>{e.persisted&&(py=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)))}},Xd=n=>{requestAnimationFrame((()=>requestAnimationFrame((()=>n()))))},Qd=()=>{let n=performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},so=()=>Qd()?.activationStart??0,zt=(n,e=-1)=>{let t=Qd(),r="navigate";return py>=0?r="back-forward-cache":t&&(document.prerendering||so()>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}},Wd=new WeakMap;function ep(n,e){return Wd.get(n)||Wd.set(n,new e),Wd.get(n)}var qd=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)}},oo=(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{}},tp=n=>{let e=!1;return()=>{e||(n(),e=!0)}},Ci=-1,fy=new Set,iy=()=>document.visibilityState!=="hidden"||document.prerendering?1/0:0,Zd=n=>{if(document.visibilityState==="hidden"){if(n.type==="visibilitychange")for(let e of fy)e();isFinite(Ci)||(Ci=n.type==="visibilitychange"?n.timeStamp:0,removeEventListener("prerenderingchange",Zd,!0))}},El=()=>{if(Ci<0){let n=so();Ci=(document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((t=>t.name==="hidden"&&t.startTime>n))[0]?.startTime)??iy(),addEventListener("visibilitychange",Zd,!0),addEventListener("prerenderingchange",Zd,!0),ki((()=>{setTimeout((()=>{Ci=iy()}))}))}return{get firstHiddenTime(){return Ci},onHidden(n){fy.add(n)}}},Cl=n=>{document.prerendering?addEventListener("prerenderingchange",(()=>n()),!0):n()},sy=[1800,3e3],np=(n,e={})=>{Cl((()=>{let t=El(),r,i=zt("FCP"),s=oo("paint",(o=>{for(let a of o)a.name==="first-contentful-paint"&&(s.disconnect(),a.startTime<t.firstHiddenTime&&(i.value=Math.max(a.startTime-so(),0),i.entries.push(a),r(!0)))}));s&&(r=Wt(n,i,sy,e.reportAllChanges),ki((o=>{i=zt("FCP"),r=Wt(n,i,sy,e.reportAllChanges),Xd((()=>{i.value=performance.now()-o.timeStamp,r(!0)}))})))}))},oy=[.1,.25],hy=(n,e={})=>{let t=El();np(tp((()=>{let r,i=zt("CLS",0),s=ep(e,qd),o=l=>{for(let c of l)s.h(c);s.i>i.value&&(i.value=s.i,i.entries=s.o,r())},a=oo("layout-shift",o);a&&(r=Wt(n,i,oy,e.reportAllChanges),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),ki((()=>{s.i=0,i=zt("CLS",0),r=Wt(n,i,oy,e.reportAllChanges),Xd((()=>r()))})),setTimeout(r))})))},gy=0,zd=1/0,Sl=0,xC=n=>{for(let e of n)e.interactionId&&(zd=Math.min(zd,e.interactionId),Sl=Math.max(Sl,e.interactionId),gy=Sl?(Sl-zd)/7+1:0)},Gd,ay=()=>Gd?gy:performance.interactionCount??0,SC=()=>{"interactionCount"in performance||Gd||(Gd=oo("event",xC,{type:"event",buffered:!0,durationThreshold:0}))},ly=0,Kd=class{constructor(){en(this,"u",[]);en(this,"l",new Map);en(this,"m");en(this,"p")}v(){ly=ay(),this.u.length=0,this.l.clear()}L(){let e=Math.min(this.u.length-1,Math.floor((ay()-ly)/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)}}},my=n=>{let e=globalThis.requestIdleCallback||setTimeout;document.visibilityState==="hidden"?n():(n=tp(n),addEventListener("visibilitychange",n,{once:!0,capture:!0}),e((()=>{n(),removeEventListener("visibilitychange",n,{capture:!0})})))},cy=[200,500],vy=(n,e={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;let t=El();Cl((()=>{SC();let r,i=zt("INP"),s=ep(e,Kd),o=l=>{my((()=>{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=oo("event",o,{durationThreshold:e.durationThreshold??40});r=Wt(n,i,cy,e.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),t.onHidden((()=>{o(a.takeRecords()),r(!0)})),ki((()=>{s.v(),i=zt("INP"),r=Wt(n,i,cy,e.reportAllChanges)})))}))},Yd=class{constructor(){en(this,"m")}h(e){this.m?.(e)}},uy=[2500,4e3],yy=(n,e={})=>{Cl((()=>{let t=El(),r,i=zt("LCP"),s=ep(e,Yd),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-so(),0),i.entries=[c],r())},a=oo("largest-contentful-paint",o);if(a){r=Wt(n,i,uy,e.reportAllChanges);let l=tp((()=>{o(a.takeRecords()),a.disconnect(),r(!0)})),c=u=>{u.isTrusted&&(my(l),removeEventListener(u.type,c,{capture:!0}))};for(let u of["keydown","click","visibilitychange"])addEventListener(u,c,{capture:!0});ki((u=>{i=zt("LCP"),r=Wt(n,i,uy,e.reportAllChanges),Xd((()=>{i.value=performance.now()-u.timeStamp,r(!0)}))}))}}))},dy=[800,1800],Jd=n=>{document.prerendering?Cl((()=>Jd(n))):document.readyState!=="complete"?addEventListener("load",(()=>Jd(n)),!0):setTimeout(n)},_y=(n,e={})=>{let t=zt("TTFB"),r=Wt(n,t,dy,e.reportAllChanges);Jd((()=>{let i=Qd();i&&(t.value=Math.max(i.responseStart-so(),0),t.entries=[i],r(!0),ki((()=>{t=zt("TTFB",0),r=Wt(n,t,dy,e.reportAllChanges),r(!0)})))}))};var by="__syntro_vitals_bound",kl="__syntro_vitals_current_reporter";function rp(n,e){if(typeof window>"u")return()=>{};let t=window;t[kl]=n;let r=null,i=e?.attributedScriptUrlPrefix;if(i&&"PerformanceObserver"in window)try{r=new PerformanceObserver(s=>{let o=t[kl];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[by]){t[by]=!0;let s=o=>a=>{t[kl]?.recordHistogram(o,a.value)};yy(s("lcp_ms")),vy(s("inp_ms")),np(s("fcp_ms")),_y(s("ttfb_ms")),hy(o=>{t[kl]?.recordHistogram("cls_score",o.value)})}return()=>{r?.disconnect()}}var ao="2.8.0-canary.478";var Vn="2.0";var EC=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function CC(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):EC.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 kC(n){if(typeof window>"u")return!1;try{return new URL(n).origin===window.location.origin}catch{return!1}}var wy="syntro_config_cache",AC=1440*60*1e3;function xy(){try{return typeof localStorage<"u"&&localStorage!==null}catch{return!1}}function TC(n,e){if(xy())try{let t={config:n,timestamp:Date.now(),sdkVersion:e};localStorage.setItem(wy,JSON.stringify(t))}catch{}}function RC(n){if(!xy())return null;try{let e=localStorage.getItem(wy);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>AC?null:t.config}catch{return null}}var IC=({configUri:n,experiments:e,featureKey:t})=>{if(n)return n;if(e&&t){let r=e.getFeatureValue?.(t,null);if(r)return r}};function $C(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 Ai=({configUri:n,experiments:e,featureKey:t,credentials:r,manifestKey:i,variantFlagPrefix:s,sdkVersion:o})=>async()=>{if(e&&(i||s||e.getAllFeatures)){let p=$C(e,i,s);if(console.log("[SmartCanvas Config] Variant key discovery:",p.length,"keys found"),p.length>0){let f=bl(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=IC({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(!CC(a))throw new Error(`SmartCanvas: config URI not allowed: ${a}`);let l=r??(kC(a)?"include":"omit"),c=performance.now(),u=!1;try{let p=await fetch(a,{credentials:l,headers:{"X-SDK-Version":ao,"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&&TC(f,o),f}catch(p){if(u||jt()?.increment("flag_fetch_errors"),o){let f=RC(o);if(f)return q("SmartCanvas Config","Serving config from offline cache"),f}throw p}};var ip=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)}},Sy=n=>new ip(n);var $t={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"},ut={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"},lo={0:"#051533",1:"#0a2a66",2:"#0f3f98",3:"#1454cb",4:"#1969fe",5:"#4787fe",6:"#75a5fe",7:"#a3c3ff",8:"#d1e1ff",9:"#e8f0ff"},co={0:"#662500",1:"#993d00",2:"#cc5800",3:"#ff7700",4:"#fea85d",5:"#fec58f",6:"#ffd6ae",7:"#fee6cd",8:"#fff1e1",9:"#fff8f0"},uo={0:"#151229",1:"#2a2452",2:"#40357c",3:"#5547a5",4:"#6a59ce",5:"#887ad8",6:"#a69be2",7:"#c3bdeb",8:"#e1def5",9:"#f0eefa"},po={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]},z2={primary:E[2],secondary:E[0]},q2={primary:E[4],secondary:E[3]},Al={primary:{text:$t.white,icon:$t.white,border:ce[3],backgroundDefault:ce[3],backgroundHover:ce[2]},neutral:{text:E[10],textHover:$t.white,icon:E[10],iconHover:$t.white,border:E[4],background:E[2]},link:{text:$t.white,icon:$t.white,hover:ce[5]},error:{text:Ce[5],hover:Ce[6]},success:{text:Ae[5],hover:Ae[6]}},Z2={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:ut[8],pillOutline:ut[4],borderPrimary:ut[2],borderSecondary:ut[2],background:ut[0]},green:{content:Ae[8],pillOutline:Ae[4],borderPrimary:Ae[2],borderSecondary:Ae[2],background:Ae[0]},purple:{content:uo[8],pillOutline:uo[4],borderPrimary:uo[2],borderSecondary:uo[2],background:uo[0]},blue:{content:lo[8],pillOutline:lo[4],borderPrimary:lo[2],borderSecondary:lo[2],background:lo[0]},orange:{content:co[8],pillOutline:co[4],borderPrimary:co[2],borderSecondary:co[2],background:co[0]},pink:{content:po[8],pillOutline:po[4],borderPrimary:po[2],borderSecondary:po[2],background:po[0]}},G2={green:{content:Ae[8],border:Ae[2],background:Ae[0]},yellow:{content:ut[8],border:ut[2],background:ut[0]},red:{content:Ce[8],border:Ce[2],background:Ce[0]}},K2={green:{content:Ae[1],background:Ae[9]},yellow:{content:ut[1],background:ut[9]},red:{content:Ce[1],background:Ce[9]}},Y2={content:E[10],border:E[4],background:E[3]},J2={backgroundDefault:E[2],backgroundHover:E[1],selected:E[3]},X2={background:E[2],icon:E[10],borderDefault:E[4],borderSelected:ce[3],textLabel:E[9],textPlaceholder:E[8],textHint:E[8]},Q2={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]},eL={handleDefault:$t.white,handleDisabled:E[10],off:{backgroundDefault:E[4],backgroundHover:E[5],backgroundDisabled:E[4]},on:{backgroundDefault:Ae[3],backgroundHover:Ae[2],backgroundDisabled:E[4]}},tL={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]}},nL={content:E[10],background:E[4]},rL={background:E[4],active:Ae[3]},iL={background:E[1],content:E[9],border:E[4]},sL={backgroundDefault:E[1],backgroundHover:E[3],backgroundActive:E[4],border:E[4],contentPrimary:E[10],contentSecondary:E[9],contentTertiary:E[8]},oL={background:E[1],content:E[9],border:E[4]},aL={activeBackground:E[3],activeContent:ce[5],inactiveContent:E[9],border:E[4]},lL={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]}},cL={textPrimaryDefault:E[10],textPrimaryHover:E[10],textSecondaryDefault:E[8],textSecondaryHover:E[9],iconPrimary:E[10],iconSecondary:E[8]},uL={background:Ae[1],active:Ae[5]},dL={textDefault:E[10],textSelected:$t.white,textDisabled:E[7],backgroundDefault:E[2],backgroundMiddle:E[3],backgroundSelected:ce[3],border:E[4]},pL=E[9];var mL={size:56,inset:12,background:$t.black,color:$t.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 PC(n){return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}var Ey={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:Al.primary.backgroundDefault,backgroundHover:Al.primary.backgroundHover,color:Al.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:ut[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}}},Cy={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:ut[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 ky(n){let e=n.mode==="light"?Cy:Ey;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 Ay(n,e){let t=e.mode??n.mode??"dark",r=t==="light"?Cy:Ey;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 OC=["canvas","launcher","tile","overlay","notification","content"];function Ty(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 OC){let r=n[t];if(r)for(let[i,s]of Object.entries(r))s!==void 0&&typeof s=="string"&&(e[`--sc-${t}-${PC(i)}`]=s)}return e}var Un,Ur,jr,gn,mn,sp,Tl,fo=class{constructor(e,t,r){ne(this,mn);ne(this,Un);ne(this,Ur);ne(this,jr);ne(this,gn);L(this,Un,e),L(this,Ur,t??{}),L(this,jr,r),L(this,gn,ue(this,mn,sp).call(this)),e.addController(this)}get config(){return C(this,gn).config}get mode(){return C(this,gn).mode}get cssVariables(){return C(this,gn).cssVariables}hostConnected(){ue(this,mn,Tl).call(this)}hostDisconnected(){}hostUpdated(){ue(this,mn,Tl).call(this)}setThemeConfig(e,t){L(this,Ur,e),L(this,jr,t),L(this,gn,ue(this,mn,sp).call(this)),ue(this,mn,Tl).call(this),C(this,Un).requestUpdate()}};Un=new WeakMap,Ur=new WeakMap,jr=new WeakMap,gn=new WeakMap,mn=new WeakSet,sp=function(){let e=C(this,jr)?Ay(C(this,jr),C(this,Ur)):ky(C(this,Ur)),t=Ty(e);return{config:e,mode:e.mode,cssVariables:t}},Tl=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,gn).cssVariables).map(([i,s])=>` ${i}: ${s};`).join(`
384
384
  `);t.textContent=`:host {
385
385
  ${r}
386
386
  }`};var MC=new Set(["tag_name","$el_text"]);function LC(n){return MC.has(n)||n.startsWith("attr__")}function Ry(n,e){return n.equals!==void 0?e===n.equals:n.contains!==void 0?typeof e=="string"&&e.includes(n.contains):!1}function NC(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(LC(i)){let o=r.props?.elements;if(!o||!o.some(l=>Ry(s,l[i])))return!1}else if(!Ry(s,r.props?.[i]))return!1}return!0}}function Iy(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?NC(i):()=>!0,o=typeof r.withinMs=="number";e.register(r.key,s,o)}}function Ti(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"&&Iy(o.triggerWhen,e)}if(t)for(let r of t){let i=r;i.triggerWhen?.type==="rules"&&Iy(i.triggerWhen,e)}}var FC=uu,$y="smart-canvas",Py=n=>[...n].sort((e,t)=>(t.priority??0)-(e.priority??0));function Oy(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 DC(n,e){if(On(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 My=1e4;function HC(n,e){let t=e.apps;if(!t.get&&!t.isActive)return[];let r=new Set;for(let i of n){let s=On(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 BC=new Set(["drawer","floating"]);function VC(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 UC(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 jC(n){if(!n)return[];let e=[];for(let[t,r]of Object.entries(n)){if(BC.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 WC(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,Ii,Zt,vn,Pt,Wr,$i,ho,Wn,Pi,zr,go,mo,vo,yo,qr,Zr,zn,qn,Zn,tt,Oi,Gn,Kn,Yn,Jn,Xn,Mi,Gt,Qn,$l,Gr,Kr,er,_o,Pl,Li,oe,op,Ly,ap,Ny,Ni,Rl,Il,lp,cp,up,Fy,dp,Dy,Hy,pp,By,fp,Yr,Ol,Ml,Ri=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,Ii,null);ne(this,Zt,null);ne(this,vn,null);ne(this,Pt,null);ne(this,Wr);ne(this,$i,"[]");ne(this,ho,0);ne(this,Wn,null);ne(this,Pi,"[]");ne(this,zr,"[]");ne(this,go,"null");ne(this,mo,"null");ne(this,vo,"null");ne(this,yo,"[]");ne(this,qr,null);ne(this,Zr,null);ne(this,zn,null);ne(this,qn,null);ne(this,Zn,null);ne(this,tt,null);ne(this,Oi,!1);ne(this,Gn,null);ne(this,Kn,null);ne(this,Yn,null);ne(this,Jn,null);ne(this,Xn,null);ne(this,Mi,!1);ne(this,Gt,new Map);ne(this,Qn,new Set);ne(this,$l,new Set);ne(this,Gr,!1);ne(this,Kr,()=>{this._pageUrl=window.location.href});ne(this,er);ne(this,_o);ne(this,Pl,0);ne(this,Li,new Map);ne(this,Ni,0);ne(this,Yr,t=>{this._chatTakeover=!1,this._nudgeBadgeCount=0,C(this,lt).toggle()});ne(this,Ol,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,Ml,t=>{this._chatTakeover=!!t.detail?.active});L(this,lt,Sy()),L(this,Wr,!1),L(this,er,new fo(this)),L(this,_o,new hi(this,{context:FC,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,Ii,C(this,lt).subscribe(t=>{this._isOpen&&!t.open&&L(this,Gr,!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,vn,document.createElement("div")),C(this,vn).id="portalRoot",this.shadowRoot.appendChild(C(this,vn)),ue(this,oe,lp).call(this),ue(this,oe,fp).call(this),ue(this,oe,up).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,Ii))==null||t.call(this),L(this,Ii,null),(r=C(this,Zr))==null||r.call(this),L(this,Zr,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,Mi,!1),ue(this,oe,cp).call(this),C(this,Pt)&&(C(this,Pt).revertAll().catch(f=>{console.error("[SmartCanvasElementLit] Failed to revert actions on disconnect:",f)}),L(this,Pt,null)),C(this,Zt)?.remove(),L(this,Zt,null),C(this,vn)?.remove(),L(this,vn,null)}willUpdate(t){t.has("initialBatchHandle")&&this.initialBatchHandle&&(L(this,Pt,this.initialBatchHandle),L(this,Wr,!0),this.initialBatchActions&&(this._configActions=this.initialBatchActions,L(this,$i,JSON.stringify(this.initialBatchActions)),L(this,Pi,C(this,$i))));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,ap).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,Gr,!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,Gr)&&C(this,lt).setOpen(!1)}}updated(t){var i;t.has("runtime")&&(C(this,_o).setValue(this.runtime??null),ue(this,oe,By).call(this),ue(this,oe,up).call(this),ue(this,oe,fp).call(this),ue(this,oe,cp).call(this),ue(this,oe,lp).call(this)),(t.has("runtime")||t.has("fetcher")||t.has("configUri")||t.has("configUriFeatureKey")||t.has("fetchCredentials")||t.has("experiments"))&&((i=C(this,Zr))==null||i.call(this),this.experiments?.onFeaturesChanged&&L(this,Zr,this.experiments.onFeaturesChanged(()=>this._loadConfig({silent:!0})))),(t.has("_configActions")||t.has("_pageUrl"))&&ue(this,oe,Il).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 GC=["cdn.syntrologie.com","api.syntrologie.com","dev-api.syntrologie.com","localhost","127.0.0.1",".syntrologie.com"];function Gy(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 hp="__syntro_rt_editor_source",gp="__syntro_rt_editor_conf";function Fl(n,e){try{sessionStorage.setItem(n,JSON.stringify(e))}catch{}}function Ky(n){try{let e=sessionStorage.getItem(n);return e?JSON.parse(e):null}catch{return null}}var tr,nr;function xo(){if(tr==null){let n=typeof window<"u"?window.__SYNTRO_EDITOR_PARAMS__:null;if(n?.token)tr={token:n.token,api_base:n.apiBase||""},Fl(hp,tr),console.log(`[DIAG] getEditorSource: from __SYNTRO_EDITOR_PARAMS__ (token=${tr.token.slice(0,15)}...)`);else{let e=Gy("editor_source");if(e)tr=e,Fl(hp,e);else{let t=Ky(hp);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 Dl(){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},Fl(gp,nr),console.log(`[DIAG] getEditorConf: from __SYNTRO_EDITOR_PARAMS__ (mode=${nr.mode})`);else{let e=Gy("editor_conf");if(e)nr=e,Fl(gp,e);else{let t=Ky(gp);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 KC(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):GC.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 Hl=()=>{let n=Dl();return!xo()?.token||!n?.mode?null:n.mode};function YC(){return xo()?.token??null}function JC(){return xo()?.api_base??null}var wo=null,Yy=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(wo)return q("Syntro Runtime","Editor SDK load already in progress, waiting..."),wo;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=JC(),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=YC(),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"}),!KC(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..."),wo=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","================================"),wo=null,l(u)},document.head.appendChild(c),q("Syntro Runtime","Script tag appended to <head>")}),wo};function XC(n,e){let t=On(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 QC(n,e){let t=new Set;for(let r of n){let i=XC(r,e);i&&t.add(i)}return[...t]}function ek(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 mp=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=Zy(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=QC(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&&Ti(m.tiles,s.accumulator,m.actions)}catch(m){console.error("[SmartCanvas] Error fetching/applying initial config:",m)}e&&e();let l=Hl();Ll();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??Ai({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&&jv(y)}};document.body?g():document.addEventListener("DOMContentLoaded",g,{once:!0}),(l||n.editorUrl)&&(console.log(`[SmartCanvas] Loading editor SDK for ${l??"config"} mode`),Yy(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=ek(m);r=y,c.setOverrideFetcher(y),s?.accumulator&&y().then(w=>{w?.tiles&&Ti(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 mp(n)}});var vp="syn_";function So(n){if(!n.startsWith(vp))throw new Error("Invalid Syntro token: must start with 'syn_'");let t=n.slice(vp.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 yp(n){let e=JSON.stringify(n),t=btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return vp+t}function xt(n){if(typeof process<"u"&&process.env)return process.env[n];if(typeof import.meta.env<"u"&&import.meta.env)return import.meta.env[n]}function xp(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 Sp(n,e){if(!(typeof window>"u"))try{let t={ts:Date.now(),data:e};localStorage.setItem(n,JSON.stringify(t))}catch{}}var Qy="syntro_segment_attributes";function e_(){let n=xp(Qy);return n?(q("Syntro Bootstrap","Loaded cached segment attributes:",n),n):{}}function t_(n){Sp(Qy,n),q("Syntro Bootstrap","Cached segment attributes:",n)}var Bl="syntro_device_id",Eo="syntro_session_id_choice",Fi=null,wp=!1,_p=null;function tk(n){return!n||n.startsWith("$")?null:n}var n_=n=>{if(n!=="denied"){wp=!1;return}wp=!0;let e=null;try{e=localStorage.getItem(Bl),localStorage.removeItem(Bl)}catch{}if(e){try{sessionStorage.getItem(Eo)===e&&sessionStorage.removeItem(Eo)}catch{}Fi===e&&(Fi=null)}};function bp(){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 nk(){if(wp)return{id:bp(),source:"session_uuid",persisted:!1};try{let n=localStorage.getItem(Bl);if(n)return{id:n,source:"device_uuid",persisted:!0};let e=bp();return localStorage.setItem(Bl,e),{id:e,source:"device_uuid",persisted:!0}}catch{return{id:bp(),source:"device_uuid",persisted:!1}}}function Di(n){if(Fi)return Fi;try{let o=sessionStorage.getItem(Eo);if(o)if(o.startsWith("$"))try{sessionStorage.removeItem(Eo)}catch{}else return Fi=o,_p={source:"session_choice",persisted:!0},o}catch{}let e=tk(n),t,r,i;if(e)t=e,r="posthog_distinct_id",i=!1;else{let o=nk();t=o.id,r=o.source,i=o.persisted}Fi=t;let s=!1;try{sessionStorage.setItem(Eo,t),s=!0}catch{}return _p={source:r,persisted:r==="posthog_distinct_id"||i||s},q("Syntro Bootstrap","Stable visitor id chosen:",_p),t}function r_(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 rk(n){return!n||n==="/"?n:n.replace(/\/+$/,"")||"/"}function Ep(){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=rk(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 i_="syntro_initial_attrs",ik=1800*1e3,Jy=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"];function sk(n){if(typeof window>"u")return!1;try{return n===window.location.hostname}catch{return!1}}function Cp(n,e){let t={},r=Jy.some(o=>typeof n[o]=="string");for(let o of Jy){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?sk(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 s_(){return xp(i_,ik)}function o_(n){Sp(i_,n),q("Syntro Bootstrap","Cached initial attrs:",n)}var Xy="syntro_geo",a_="https://geo.syntrologie.com";async function kp(n){if(typeof window>"u")return{};try{let e=localStorage.getItem(Xy);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(Xy,JSON.stringify(r))}catch{}return q("Syntro Bootstrap","Geo: fetched from worker:",r),r}}catch{}return{}}var l_=!1;function c_(n){return typeof window<"u"&&typeof window.Shopify<"u"&&!l_&&(l_=!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 u_=["fbclid","ttclid","gclid","gbraid","wbraid","msclkid","twclid","li_fat_id","epik","ScCid","yclid","_kx","mc_eid","mc_cid"];function Ap(n){if(typeof window>"u"||!n.setPersonPropertiesOnce)return;let e=new URLSearchParams(window.location.search),t={};for(let r of u_){let i=e.get(r);i&&(t[`$initial_${r}`]=i)}Object.keys(t).length>0&&n.setPersonPropertiesOnce(t)}var ok=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,ak=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,lk=[/@yopmail\.com$/i,/@mailinator\.com$/i,/@guerrillamail\.(com|info|net|org|biz)$/i,/@10minutemail\.com$/i,/^test@/i,/^noreply@/i,/^no-reply@/i];function Vl(n){return n?ak.test(n):!1}function d_(n){return lk.some(e=>e.test(n))}function ck(n){if(n.type==="email")return!0;let e=(n.name||"").toLowerCase(),t=(n.id||"").toLowerCase();return!!(/email/.test(e)||/email/.test(t))}function uk(n){return n.closest("[data-syntro-no-identify]")!==null}function dk(n){return n?ok.test(n):!0}function Tp(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}dk(o)?n.identify?.(s,{email:s}):n.alias?.(s),t.add(s)},i=s=>{let o=s.target;if(!(o instanceof HTMLInputElement)||uk(o)||!ck(o))return;let a=(o.value??"").trim().toLowerCase();if(!Vl(a)||d_(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 p_="_syu",pk=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function fk(n){return n?pk.test(n):!0}function Rp(n,e){if(typeof window>"u"||!n.identify&&!n.alias)return;let t=new URLSearchParams(window.location.search).get(p_);if(!t)return;let r=t.trim();if(!r)return;let i=()=>{let a=n.getDistinctId?.();if(a===r)return;let l=Vl(r)?{email:r}:void 0;fk(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 hk=["utm_source","utm_medium","utm_campaign","utm_content","utm_term"];function gk(n){return n.is_eu==="true"||n.country_code==="GB"||n.country_code==="CH"||!n.is_eu&&!n.country_code}function mk(n){if(!n)return"";try{return new URL(n).hostname}catch{return""}}function Ip(){return typeof window>"u"?"":`${window.location.origin}${window.location.pathname}`}function $p(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:mk(t)};for(let s of hk){let o=r.get(s);o&&(i[`$initial_${s}`]=o)}if(n.setPersonPropertiesOnce(i),!e){n.setPersonPropertiesOnce({$initial_url:Ip()});return}e.then(s=>{let o=gk(s)?Ip():window.location.href;n.setPersonPropertiesOnce?.({$initial_url:o})}).catch(()=>{n.setPersonPropertiesOnce?.({$initial_url:Ip()})})}var f_=new Set(["email","telephone","streetAddress","addressLocality","addressRegion","postalCode","givenName","familyName"]),h_=500,Pp=3;function Ul(n){if(Array.isArray(n))return n.map(Ul);if(n&&typeof n=="object"){let e={};for(let[t,r]of Object.entries(n))f_.has(t)||(e[t]=Ul(r));return e}return n}function jl(n){if(Array.isArray(n))return n.map(jl);if(n&&typeof n=="object"){let e={};for(let[t,r]of Object.entries(n))if(!(t==="description"&&typeof r=="string"&&r.length>h_)){if(t==="image"&&Array.isArray(r)&&r.length>Pp){e[t]=r.slice(0,Pp);continue}e[t]=jl(r)}return e}return n}function vk(){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 Op(n){if(!n.register)return;let e=vk().map(jl).map(Ul);e.length!==0&&n.register({json_ld:e})}function g_(n,e,t={}){$p(n,t.geoPromise),Ap(n),Op(n),Rp(n,e);let r=Tp(n,e);return()=>{r()}}var Co=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 v_={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function y_(){return v_}function Mp(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 ko(n,e,t){return t===2?Mp(Mp(n+e)+"")%1e4/1e4:t===1?Mp(e+n)%1e3/1e3:null}function yk(n){return n<=0?[]:new Array(n).fill(1/n)}function Wl(n,e){return n>=e[0]&&n<e[1]}function __(n,e){let t=ko("__"+e[0],n,1);return t===null?!1:t>=e[1]&&t<e[2]}function b_(n,e){for(let t=0;t<e.length;t++)if(Wl(n,e[t]))return t;return-1}function Np(n){try{let e=n.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function zl(n,e){if(!e.length)return!1;let t=!1,r=!1;for(let i=0;i<e.length;i++){let s=wk(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 _k(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 bk(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=>!_k(i[0],i[1],i[2]))}catch{return!1}}function wk(n,e,t){try{let r=new URL(n,"https://_");if(e==="regex"){let i=Np(t);return i?i.test(r.href)||i.test(r.href.substring(r.origin.length)):!1}else if(e==="simple")return bk(r,t);return!1}catch{return!1}}function w_(n,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let r=yk(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 x_(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 S_(n){try{return n()}catch(e){return console.error(e),!1}}var Lp=n=>Uint8Array.from(atob(n),e=>e.charCodeAt(0));async function Jr(n,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||v_.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let r=await t.importKey("raw",Lp(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[i,s]=n.split("."),o=await t.decrypt({name:"AES-CBC",iv:Lp(i)},r,Lp(s));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function Ao(n){return typeof n=="string"?n:JSON.stringify(n)}function dt(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 E_(){let n;try{n="1.6.4"}catch{n=""}return n}function C_(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 m_(n){return typeof n=="object"&&n!==null}function ql(n){return n.urlPatterns&&n.variations.some(e=>m_(e)&&"urlRedirect"in e)?"redirect":n.variations.some(e=>m_(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function Zl(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=y_(),Hi={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),Ek()):document.visibilityState==="hidden"&&(n=window.setTimeout(Sk,Ke.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(Kt.localStorage=globalThis.localStorage)}catch{}var Bi=new Map,k_=!1,yn=new Map,Gl=new Map,Vi=new Map,Ui=new Set;function T_(n){Object.assign(Ke,n),Ke.backgroundSync||Up()}async function R_({instance:n,timeout:e,skipCache:t,allowStale:r,backgroundSync:i}){return i||(Ke.backgroundSync=!1),Ck({instance:n,allowStale:r,timeout:e,skipCache:t})}function xk(n){let e=To(n),t=Bi.get(e)||new Set;t.add(n),Bi.set(e,t)}function I_(n){Bi.forEach(e=>e.delete(n))}function Sk(){Vi.forEach(n=>{n&&(n.state="idle",Bp(n))})}function Ek(){Vi.forEach(n=>{n&&n.state==="idle"&&Vp(n)})}async function A_(){try{if(!Kt.localStorage)return;await Kt.localStorage.setItem(Ke.cacheKey,JSON.stringify(Array.from(yn.entries())))}catch{}}async function Ck({instance:n,allowStale:e,timeout:t,skipCache:r}){let i=To(n),s=Dp(n),o=new Date,a=new Date(o.getTime()-Ke.maxAge+Ke.staleTTL);await kk();let l=!Ke.disableCache&&!r?yn.get(s):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&Ui.add(i),l.staleAt<o?Fp(n):Hp(n),{data:l.data,success:!0,source:"cache"}):await Zl(Fp(n),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function To(n){let[e,t]=n.getApiInfo();return`${e}||${t}`}function Dp(n){let e=To(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 kk(){if(!k_){k_=!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])=>{yn.set(t,{...r,staleAt:new Date(r.staleAt)})}),$_()}}}catch{}if(!Ke.disableIdleStreams){let n=Hi.startIdleListener();n&&(Hi.stopIdleListener=n)}}}function $_(){let n=Array.from(yn.entries()).map(([t,r])=>({key:t,staleAt:r.staleAt.getTime()})).sort((t,r)=>t.staleAt-r.staleAt),e=Math.min(Math.max(0,yn.size-Ke.maxEntries),yn.size);for(let t=0;t<e;t++)yn.delete(n[t].key)}function P_(n,e,t){let r=t.dateUpdated||"",i=new Date(Date.now()+Ke.staleTTL),s=Ke.disableCache?void 0:yn.get(e);if(s&&r&&s.version===r){s.staleAt=i,A_();return}Ke.disableCache||(yn.set(e,{data:t,version:r,staleAt:i,sse:Ui.has(n)}),$_()),A_();let o=Bi.get(n);o&&o.forEach(a=>Ak(a,t))}async function Ak(n,e){await n.setPayload(e||n.getPayload())}async function Fp(n){let{apiHost:e,apiRequestHeaders:t}=n.getApiHosts(),r=n.getClientKey(),i="isRemoteEval"in n&&n.isRemoteEval(),s=To(n),o=Dp(n),a=Gl.get(o);return a||(a=(i?Hi.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:n.getAttributes(),forcedVariations:n.getForcedVariations(),forcedFeatures:Array.from(n.getForcedFeatures().entries()),url:n.getUrl()},headers:t}):Hi.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"&&Ui.add(s),c.json()}).then(c=>(P_(s,o,c),Hp(n),Gl.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(Gl.delete(o),{data:null,source:"error",success:!1,error:c})),Gl.set(o,a)),a}function Hp(n,e=!1){let t=To(n),r=Dp(n),{streamingHost:i,streamingHostRequestHeaders:s}=n.getApiHosts(),o=n.getClientKey();if(e&&Ui.add(t),Ke.backgroundSync&&Ui.has(t)&&Kt.EventSource){if(Vi.has(t))return;let a={src:null,host:i,clientKey:o,headers:s,cb:l=>{try{if(l.type==="features-updated"){let c=Bi.get(t);c&&c.forEach(u=>{Fp(u)})}else if(l.type==="features"){let c=JSON.parse(l.data);P_(t,r,c)}a.errors=0}catch{O_(a)}},errors:0,state:"active"};Vi.set(t,a),Vp(a)}}function O_(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);Bp(n),setTimeout(()=>{["idle","active"].includes(n.state)||Vp(n)},Math.min(e,3e5))}}function Bp(n){n.src&&(n.src.onopen=null,n.src.onerror=null,n.src.close(),n.src=null,n.state==="active"&&(n.state="disabled"))}function Vp(n){n.src=Hi.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=()=>O_(n),n.src.onopen=()=>{n.errors=0}}function Tk(n,e){Bp(n),Vi.delete(e)}function Up(){Ui.clear(),Vi.forEach(Tk),Bi.clear(),Hi.stopIdleListener()}function Kl(n,e){if(e.streaming){if(!n.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&Hp(n,!0),xk(n)}}var Rk=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,zp={revert:function(){}},Ql=new Map,qp=new Set;function Ik(n){return n==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[n]}}function ec(n){var e=Ql.get(n);return e||(e={element:n,attributes:{}},Ql.set(n,e)),e}function tc(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,Ik(e)),o}function nc(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,M_()):n!==t&&(e.isDirty=!0,M_())}function $k(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),nc(zk(e),n)}function Pk(n){var e=new Set(n.originalValue.split(/\s+/).filter(Boolean));n.mutations.forEach(function(t){return t.mutate(e)}),nc(Array.from(e).filter(Boolean).join(" "),n)}function Ok(n){var e=n.originalValue;n.mutations.forEach(function(t){return e=t.mutate(e)}),nc(e,n)}function Mk(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 Lk(n){var e=n.originalValue;n.mutations.forEach(function(t){var r=t.mutate(),i=Mk(r);e=i||e}),nc(e,n)}var Nk=function(e){return e.innerHTML},Fk=function(e,t){return e.innerHTML=t};function N_(n){var e=ec(n);return e.html||(e.html=tc(n,"html",Nk,Fk,$k)),e.html}var Dk=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},Hk=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};function F_(n){var e=ec(n);return e.position||(e.position=tc(n,"position",Dk,Hk,Lk)),e.position}var Bk=function(e,t){return t?e.className=t:e.removeAttribute("class")},Vk=function(e){return e.className};function D_(n){var e=ec(n);return e.classes||(e.classes=tc(n,"class",Vk,Bk,Pk)),e.classes}var Uk=function(e){return function(t){var r;return(r=t.getAttribute(e))!=null?r:null}},jk=function(e){return function(t,r){return r!==null?t.setAttribute(e,r):t.removeAttribute(e)}};function H_(n,e){var t=ec(n);return t.attributes[e]||(t.attributes[e]=tc(n,e,Uk(e),jk(e),Ok)),t.attributes[e]}function Wk(n,e){var t=Ql.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 Yl;function zk(n){return Yl||(Yl=document.createElement("div")),Yl.innerHTML=n,Yl.innerHTML}function Jl(n,e,t){if(t.isDirty){t.isDirty=!1;var r=t.virtualValue;t.mutations.length||Wk(n,e),t.setValue(n,r)}}function qk(n,e){n.html&&Jl(e,"html",n.html),n.classes&&Jl(e,"class",n.classes),n.position&&Jl(e,"position",n.position),Object.keys(n.attributes).forEach(function(t){Jl(e,t,n.attributes[t])})}function M_(){Ql.forEach(qk)}function Zk(n,e){var t=null;n.kind==="html"?t=N_(e):n.kind==="class"?t=D_(e):n.kind==="attribute"?t=H_(e,n.attribute):n.kind==="position"&&(t=F_(e)),t&&(t.mutations.push(n),t.mutationRunner(t))}function Gk(n,e){var t=null;if(n.kind==="html"?t=N_(e):n.kind==="class"?t=D_(e):n.kind==="attribute"?t=H_(e,n.attribute):n.kind==="position"&&(t=F_(e)),!!t){var r=t.mutations.indexOf(n);r!==-1&&t.mutations.splice(r,1),t.mutationRunner(t)}}function B_(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),Zk(n,r))})}}function Kk(n){n.elements.forEach(function(e){return Gk(n,e)}),n.elements.clear(),qp.delete(n)}function L_(){qp.forEach(B_)}var jp;function Yk(){typeof document>"u"||(jp||(jp=new MutationObserver(function(){L_()})),L_(),jp.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}Yk();function rc(n){return typeof document>"u"?zp:(qp.add(n),B_(n),{revert:function(){Kk(n)}})}function Wp(n,e){return rc({kind:"html",elements:new Set,mutate:e,selector:n})}function V_(n,e){return rc({kind:"position",elements:new Set,mutate:e,selector:n})}function Ro(n,e){return rc({kind:"class",elements:new Set,mutate:e,selector:n})}function Xl(n,e,t){return Rk.test(e)?e==="class"||e==="className"?Ro(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)})}):rc({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:n}):zp}function Jk(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 Wp(e,function(a){return a+(r??"")});if(t==="set")return Wp(e,function(){return r??""})}else if(i==="class"){if(t==="append")return Ro(e,function(a){r&&a.add(r)});if(t==="remove")return Ro(e,function(a){r&&a.delete(r)});if(t==="set")return Ro(e,function(a){a.clear(),r&&a.add(r)})}else if(i==="position"){if(t==="set"&&s)return V_(e,function(){return{insertBeforeSelector:o,parentSelector:s}})}else{if(t==="append")return Xl(e,i,function(a){return a!==null?a+(r??""):r??""});if(t==="set")return Xl(e,i,function(){return r??""});if(t==="remove")return Xl(e,i,function(){return null})}return zp}var Xk={html:Wp,classes:Ro,attribute:Xl,position:V_,declarative:Jk},U_=Xk;var Zp={};function rr(n,e,t){t=t||{};for(let[r,i]of Object.entries(e))switch(r){case"$or":if(!z_(n,i,t))return!1;break;case"$nor":if(z_(n,i,t))return!1;break;case"$and":if(!rA(n,i,t))return!1;break;case"$not":if(rr(n,i,t))return!1;break;default:if(!Io(i,Qk(n,r),t))return!1}return!0}function Qk(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 Zp[t]||(Zp[t]=new RegExp(n.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Zp[t]}function Io(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)||!q_(n))return JSON.stringify(e)===JSON.stringify(n);for(let i in n)if(!nA(i,e,n[i],t))return!1;return!0}function q_(n){let e=Object.keys(n);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function eA(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 tA(n,e,t){if(!Array.isArray(n))return!1;let r=q_(e)?i=>Io(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 ji(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 W_(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(Io(e[i],n[o],t,r)){s=!0;break}if(!s)return!1}return!0}function nA(n,e,t,r){switch(n){case"$veq":return dt(e)===dt(t);case"$vne":return dt(e)!==dt(t);case"$vgt":return dt(e)>dt(t);case"$vgte":return dt(e)>=dt(t);case"$vlt":return dt(e)<dt(t);case"$vlte":return dt(e)<=dt(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)?ji(e,t):!1;case"$ini":return Array.isArray(t)?ji(e,t,!0):!1;case"$inGroup":return ji(e,r[t]||[]);case"$notInGroup":return!ji(e,r[t]||[]);case"$nin":return Array.isArray(t)?!ji(e,t):!1;case"$nini":return Array.isArray(t)?!ji(e,t,!0):!1;case"$not":return!Io(t,e,r);case"$size":return Array.isArray(e)?Io(t,e.length,r):!1;case"$elemMatch":return tA(e,t,r);case"$all":return Array.isArray(t)?W_(e,t,r):!1;case"$alli":return Array.isArray(t)?W_(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 eA(e)===t;default:return console.error("Unknown operator: "+n),!1}}function z_(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 rA(n,e,t){for(let r=0;r<e.length;r++)if(!rr(n,e[r],t))return!1;return!0}var iA="Feature Evaluated",sA="Experiment Viewed";function oA(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 aA(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 Wi(n){try{await n()}catch{}}function Z_(n,e,t){if(n.user.trackedExperiments){let i=oc(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(Wi(()=>i(e,t,n.user)))}if(n.user.trackingCallback){let i=n.user.trackingCallback;r.push(Wi(()=>i(e,t)))}if(n.global.eventLogger){let i=n.global.eventLogger;r.push(Wi(()=>i(sA,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},n.user)))}return r}function lA(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;Wi(()=>r(e,t,n.user))}if(n.user.onFeatureUsage){let r=n.user.onFeatureUsage;Wi(()=>r(e,t))}if(n.global.eventLogger){let r=n.global.eventLogger;Wi(()=>r(iA,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},n.user))}}function ic(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=oA(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=ic(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&&Y_(s.filters,e))continue;if("force"in s){if(s.condition&&!K_(s.condition,e)||!cA(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=>{!Z_(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}=sc(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 sc(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=uA(n,t),n.urlPatterns&&!zl(t.user.url||"",n.urlPatterns))return{result:ke(t,n,-1,!1,e)};let s=x_(r,t.user.url||"",i);if(s!==null)return{result:ke(t,n,s,!1,e)};let o=aA(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}=Xr(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}=fA({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(Y_(n.filters,t))return{result:ke(t,n,-1,!1,e)}}else if(n.namespace&&!__(l,n.namespace))return{result:ke(t,n,-1,!1,e)};if(n.include&&!S_(n.include))return{result:ke(t,n,-1,!1,e)};if(n.condition&&!K_(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=ic(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&&!pA(n.groups,t))return{result:ke(t,n,-1,!1,e)}}if(n.url&&!dA(n.url,t))return{result:ke(t,n,-1,!1,e)};let f=ko(n.seed||r,l,n.hashVersion||1);if(f===null)return{result:ke(t,n,-1,!1,e)};if(!u){let m=n.ranges||w_(i,n.coverage===void 0?1:n.coverage,n.weights);c=b_(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}=gA(t,a,Ao(l),{[Gp(n.key,n.bucketVersion)]:h.key});m&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[y]=w,t.user.saveStickyBucketAssignmentDoc(w))}let g=Z_(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"&&lA(n,e,a),a}function G_(n){return{...n.user.attributes,...n.user.attributeOverrides}}function K_(n,e){return rr(G_(e),n,e.global.savedGroups||{})}function Y_(n,e){return n.some(t=>{let{hashValue:r}=Xr(e,t.attribute);if(!r)return!0;let i=ko(t.seed,r,t.hashVersion||2);return i===null?!0:!t.ranges.some(s=>Wl(i,s))})}function cA(n,e,t,r,i,s,o){if(!i&&s===void 0)return!0;if(!i&&s===0)return!1;let{hashValue:a}=Xr(n,t,r);if(!a)return!1;let l=ko(e,a,o||1);return l===null?!1:i?Wl(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}=Xr(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 uA(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=Np(n.url))),n}function Xr(n,e,t){let r=e||"id",i="",s=G_(n);return s[r]&&(i=s[r]),!i&&t&&(s[t]&&(i=s[t]),i&&(r=t)),{hashAttribute:r,hashValue:i}}function dA(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 pA(n,e){let t=e.global.groups||{};for(let r=0;r<n.length;r++)if(t[n[r]])return!0;return!1}function fA({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=Gp(e,t),l=hA(n,r,i);if(s>0)for(let p=0;p<s;p++){let f=Gp(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 Gp(n,e){return e=e||0,`${n}__${e}`}function Kp(n,e){return`${n}||${e}`}function hA(n,e,t){if(!n.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:r,hashValue:i}=Xr(n,e),s=Kp(r,Ao(i)),{hashAttribute:o,hashValue:a}=Xr(n,t),l=a?Kp(o,Ao(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 gA(n,e,t,r){let i=Kp(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 mA(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 J_(n,e,t){let r=Yp(n,t);return e.getAllAssignments(r)}function Yp(n,e){let t={};return mA(n,e).forEach(i=>{let{hashValue:s}=Xr(n,i);t[i]=Ao(s)}),t}async function X_(n,e,t){if(n={...n},n.encryptedFeatures){try{n.features=JSON.parse(await Jr(n.encryptedFeatures,e,t))}catch(r){console.error(r)}delete n.encryptedFeatures}if(n.encryptedExperiments){try{n.experiments=JSON.parse(await Jr(n.encryptedExperiments,e,t))}catch(r){console.error(r)}delete n.encryptedExperiments}if(n.encryptedSavedGroups){try{n.savedGroups=JSON.parse(await Jr(n.encryptedSavedGroups,e,t))}catch(r){console.error(r)}delete n.encryptedSavedGroups}return n}function Q_(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 oc(n,e){return e.hashAttribute+e.hashValue+n.key+e.variationId}var zi=typeof window<"u"&&typeof document<"u",vA=E_(),$o=class{constructor(e){if(e=e||{},this.version=vA,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),zi&&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 X_(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,Kl(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&T_(e.cacheSettings),e.payload)return await this.setPayload(e.payload),Kl(this,e),{success:!0,source:"init"};{let{data:t,...r}=await this._refresh({...e,allowStale:!0});return Kl(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 Q_(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 R_({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 Jr(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 Jr(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,I_(this),e.destroyAllStreams&&Up(),this.logs=[],zi&&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}=sc(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}=sc(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=ql(e);if(l==="redirect"&&s.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?C_(this._getContextUrl(),s.value.urlRedirect):s.value.urlRedirect;if(zl(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(zi)Promise.all([...o?[Zl(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&&ql(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 ic(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=>[oc(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(oc(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(zi?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=ql(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}:zi?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!zi)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(U_.declarative(r).revert)}),()=>{t.forEach(r=>r())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),r=await J_(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=Yp(r,t);return e.getAllAssignmentsSync(i)}inDevMode(){return!!this._options.enableDevMode}};var yA="https://experiment.syntrologie.com",Jp=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 $o({...e,apiHost:e.apiHost??yA,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 Xp(n={}){return new Jp(n)}var eb={growthbook:n=>Xp({...n,autoInit:!0})};function tb(n,e){let t=eb[n];if(!t)throw new Error(`Unknown experiment provider: ${n}. Supported: ${Object.keys(eb).join(", ")}`);return t(e)}var _A=["cdn.syntrologie.com","localhost","127.0.0.1"];function bA(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):_A.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 Qp=class{constructor(e){this.name="cdn";if(this.url=`${e.baseUrl}/${e.configId}.json`,this.integrity=e.integrity,!bA(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 wA(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 wA(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 nb(n){return new Qp(n)}var xA="syntro_exp",SA="syntro_var",ef=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(xA),o=i.get(SA);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:bl(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 rb(n){return new ef(n)}var EA="https://cdn.syntrologie.com/configs",ib={cdn:n=>{if(!n.configId)throw new Error("CDN fetcher requires 'configId' option");return nb({baseUrl:n.baseUrl??EA,configId:n.configId,integrity:n.integrity})},experiments:n=>{if(!n.featureKey)throw new Error("Experiments fetcher requires 'featureKey' option");return rb({featureKey:n.featureKey})}};function sb(n,e={}){let t=ib[n];if(!t)throw new Error(`Unknown config fetcher type: ${n}. Supported: ${Object.keys(ib).join(", ")}`);return t(e)}var CA=[25,50,75,100];function ob(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 CA)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 kA=new Set(["adaptive-chat-anchor","adaptive-spill-anchor","drawer-anchor"]);function ab(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]")||kA.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 lb="syntro_session_metrics",ac=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(lb);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(lb,JSON.stringify(e))}catch(e){console.warn("[SessionMetricTracker] Failed to save to sessionStorage:",e)}}};function tf(n={}){return new ac(n)}var AA=/\/(?:products?|pdp\/dynamic)\/([a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?)/,TA=/^[a-zA-Z0-9](?:[a-zA-Z0-9_-]*[a-zA-Z0-9])?$/;function RA(n){let e=n.attr__href??n.href;return typeof e=="string"&&e.length>0?e:void 0}function IA(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 $A(n){let e=RA(n);if(!e)return null;let t=AA.exec(e);if(!t)return null;let r=t[1],i=e.slice(e.indexOf(t[0])).split(/[?#]/)[0],s=IA(n);return s?{productHandle:r,productUrl:i,productTitle:s}:{productHandle:r,productUrl:i}}function PA(n){let e=n["attr__data-product-handle"];if(typeof e!="string"||!TA.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 nf(n){for(let e of n){let t=$A(e)??PA(e);if(t)return t}return null}var Po=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 Oo=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 Po(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 nf(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 CF=720*60*60;var cb=[()=>new Oo];function ub(){for(let n of cb){let e=n();if(e.detect())return e}return null}var DA="syntro:score:v2:",qi="unknown";function pb(n,e){return`${DA}${n}:${e}`}function sf(n,e){if(!e)return null;try{let t=sessionStorage.getItem(pb(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 _n(n,e){return sf(n,e)?.v??qi}function fb(n,e,t,r){try{let i={v:t,exp:Date.now()+r*1e3};sessionStorage.setItem(pb(n,e),JSON.stringify(i))}catch{}}var Qr=new Map,rf=new Map,hb=new Map;function Mo(n,e){return`${n}:${e}`}function lc(n,e){let t=hb.get(Mo(n,e))??0;return Date.now()-t<5e3}function cc(n,e){hb.set(Mo(n,e),Date.now())}async function gb(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 _n(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)}"`),_n(e.name,t);let p=typeof u.value=="string"?u.value:qi;if(e.type==="enum"&&e.values&&!e.values.includes(p))return console.warn(`[syntro] score drift: "${p}" not in declared values for "${e.name}"`),_n(e.name,t);let f=typeof u.ttl_s=="number"?u.ttl_s:30;return fb(e.name,t,p,f),p}catch{return _n(e.name,t)}}async function db(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:qi;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;fb(f.name,t,h,g),a.set(f.name,h)}return a}catch{return a}}function mb(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=>_n(u.name,t)));let i=new Map,s=[],o=[];for(let u of e){let p=sf(u.name,t);p&&p.v!==qi?(i.set(u.name,p.v),Date.now()>=p.exp&&s.push(u)):o.push(u)}let a=s.filter(u=>!Qr.has(Mo(u.name,t))&&!lc(u.name,t));if(a.length>0){for(let u of a)cc(u.name,t);db(n,a,t,r)}if(o.length===0)return Promise.resolve(e.map(u=>i.get(u.name)??qi));let l=`${o.map(u=>u.name).join("\0")}:${t}`,c=rf.get(l);if(!c){let u=o.filter(p=>!lc(p.name,t));if(u.length===0)return Promise.resolve(e.map(p=>i.get(p.name)??_n(p.name,t)));for(let p of u)cc(p.name,t);c=db(n,u,t,r).finally(()=>rf.delete(l)),rf.set(l,c)}return c.then(u=>e.map(p=>i.get(p.name)??u.get(p.name)??_n(p.name,t)))}function HA(n,e,t,r){let i=Mo(e.name,t);if(Qr.has(i)||lc(e.name,t))return;cc(e.name,t);let s=gb(n,e,t,r).finally(()=>Qr.delete(i));Qr.set(i,s)}function vb(n,e){let t=n.getSessionId(),r=n.getUserId();if(!t||!r)return Promise.resolve(_n(e.name,t));let i=sf(e.name,t);if(i&&i.v!==qi)return Date.now()<i.exp||HA(n,e,t,r),Promise.resolve(i.v);let s=Mo(e.name,t),o=Qr.get(s);if(!o){if(lc(e.name,t))return Promise.resolve(_n(e.name,t));cc(e.name,t),o=gb(n,e,t,r).finally(()=>Qr.delete(s)),Qr.set(s,o)}return o}function yb(n){return n==="granted"?"granted":n==="denied"?"denied":"pending"}function of(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 Lo=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(of(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=of(a);l!==null&&e(yb(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=of(e[t]);if(r!==null)return yb(r)}return"pending"}};var No=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 _b="visitorConsentCollected",Fo=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(_b,r)}),()=>{r&&document.removeEventListener(_b,r)}}};var Do=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 Ho=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 Bo=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 BA(){let n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="";for(let t=0;t<16;t++)e+=n[Math.floor(Math.random()*n.length)];return e}var af=class{constructor(){this.sessionId=BA(),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 lf(){return new af}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 g0=Array.prototype,bb=g0.forEach,wb=g0.indexOf,ft=Ze?.navigator,D=Ze?.document,qe=Ze?.location,kf=Ze?.fetch,Af=Ze!=null&&Ze.XMLHttpRequest&&"withCredentials"in new Ze.XMLHttpRequest?Ze.XMLHttpRequest:void 0,xb=Ze?.AbortController,ct=ft?.userAgent,ee=S??{},xn={DEBUG:!1,LIB_VERSION:"1.341.0"};function Sb(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 Ji(n){return function(){var e=this,t=arguments;return new Promise((function(r,i){var s=n.apply(e,t);function o(l){Sb(s,r,i,o,a,"next",l)}function a(l){Sb(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 m0(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 VA=["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"],Eb=function(n,e){if(e===void 0&&(e=[]),!n)return!1;var t=n.toLowerCase();return VA.concat(e).some((r=>{var i=r.toLowerCase();return t.indexOf(i)!==-1}))},UA=["$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 Hc=function(n){return n.trim()},Tf=function(n){return n.replace(/^\$/,"")},jA=Array.isArray,v0=Object.prototype,y0=v0.hasOwnProperty,Bc=v0.toString,_e=jA||function(n){return Bc.call(n)==="[object Array]"},ur=n=>typeof n=="function",He=n=>n===Object(n)&&!_e(n),Xi=n=>{if(He(n)){for(var e in n)if(y0.call(n,e))return!1;return!0}return!1},H=n=>n===void 0,Be=n=>Bc.call(n)=="[object String]",Rf=n=>Be(n)&&n.trim().length===0,Ot=n=>n===null,ve=n=>H(n)||Ot(n),Tn=n=>Bc.call(n)=="[object Number]"&&n==n,Ki=n=>Tn(n)&&n>0,An=n=>Bc.call(n)==="[object Boolean]",WA=n=>n instanceof FormData,zA=n=>me(UA,n);function If(n){return n===null||typeof n!="object"}function vc(n,e){return Object.prototype.toString.call(n)==="[object "+e+"]"}function _0(n){return!H(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(n,Event)}var qA=[!0,"true",1,"1","yes"],cf=n=>me(qA,n),ZA=[!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),Tn(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 $f=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",yc="iOS",kn="Android",aa="Tablet",b0=kn+" "+aa,w0="iPad",x0="Apple",S0=x0+" Watch",la="Safari",ns="BlackBerry",E0="Samsung",C0=E0+"Browser",k0=E0+" Internet",ri="Chrome",GA=ri+" OS",A0=ri+" "+yc,Hh="Internet Explorer",T0=Hh+" "+St,Bh="Opera",KA=Bh+" Mini",Vh="Edge",R0="Microsoft "+Vh,es="Firefox",I0=es+" "+yc,ca="Nintendo",ua="PlayStation",ts="Xbox",$0=kn+" "+St,P0=St+" "+la,Yo="Windows",Pf=Yo+" Phone",Cb="Nokia",Of="Ouya",O0="Generic",YA=O0+" "+St.toLowerCase(),M0=O0+" "+aa.toLowerCase(),Mf="Konqueror",nt="(\\d+(\\.\\d+)?)",uf=new RegExp("Version/"+nt),JA=new RegExp(ts,"i"),XA=new RegExp(ua+" \\w+","i"),QA=new RegExp(ca+" \\w+","i"),Uh=new RegExp(ns+"|PlayBook|BB10","i"),e1={"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"},uc,kb,df,t1=(n,e)=>e&&me(e,x0)||(function(t){return me(t,la)&&!me(t,ri)&&!me(t,kn)})(n),L0=function(n,e){return e=e||"",me(n," OPR/")&&me(n,"Mini")?KA:me(n," OPR/")?Bh:Uh.test(n)?ns:me(n,"IE"+St)||me(n,"WPDesktop")?T0:me(n,C0)?k0:me(n,Vh)||me(n,"Edg/")?R0:me(n,"FBIOS")?"Facebook "+St:me(n,"UCWEB")||me(n,"UCBrowser")?"UC Browser":me(n,"CriOS")?A0:me(n,"CrMo")||me(n,ri)?ri:me(n,kn)&&me(n,la)?$0:me(n,"FxiOS")?I0:me(n.toLowerCase(),Mf.toLowerCase())?Mf:t1(n,e)?me(n,St)?P0:la:me(n,es)?es:me(n,"MSIE")||me(n,"Trident/")?Hh:me(n,"Gecko")?es:""},n1={[T0]:[new RegExp("rv:"+nt)],[R0]:[new RegExp(Vh+"?\\/"+nt)],[ri]:[new RegExp("("+ri+"|CrMo)\\/"+nt)],[A0]:[new RegExp("CriOS\\/"+nt)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+nt)],[la]:[uf],[P0]:[uf],[Bh]:[new RegExp("(Opera|OPR)\\/"+nt)],[es]:[new RegExp(es+"\\/"+nt)],[I0]:[new RegExp("FxiOS\\/"+nt)],[Mf]:[new RegExp("Konqueror[:/]?"+nt,"i")],[ns]:[new RegExp(ns+" "+nt),uf],[$0]:[new RegExp("android\\s"+nt,"i")],[k0]:[new RegExp(C0+"\\/"+nt)],[Hh]:[new RegExp("(rv:|MSIE )"+nt)],Mozilla:[new RegExp("rv:"+nt)]},r1=function(n,e){var t=L0(n,e),r=n1[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},Ab=[[new RegExp(ts+"; "+ts+" (.*?)[);]","i"),n=>[ts,n&&n[1]||""]],[new RegExp(ca,"i"),[ca,""]],[new RegExp(ua,"i"),[ua,""]],[Uh,[ns,""]],[new RegExp(Yo,"i"),(n,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Pf,""];if(new RegExp(St).test(e)&&!/IEMobile\b/.test(e))return[Yo+" "+St,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var r=t[1],i=e1[r]||"";return/arm/i.test(e)&&(i="RT"),[Yo,i]}return[Yo,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,n=>{if(n&&n[3]){var e=[n[3],n[4],n[5]||"0"];return[yc,e.join(".")]}return[yc,""]}],[/(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("("+kn+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+kn+")","i"),n=>{if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[kn,e.join(".")]}return[kn,""]}],[/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/,[GA,""]],[/Linux|debian/i,["Linux",""]]],Tb=function(n){return QA.test(n)?ca:XA.test(n)?ua:JA.test(n)?ts:new RegExp(Of,"i").test(n)?Of:new RegExp("("+Pf+"|WPDesktop)","i").test(n)?Pf:/iPad/.test(n)?w0:/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(n)?S0:Uh.test(n)?ns:/(kobo)\s(ereader|touch)/i.test(n)?"Kobo":new RegExp(Cb,"i").test(n)?Cb:/(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)?kn:b0:new RegExp("(pda|"+St+")","i").test(n)?YA:new RegExp(aa,"i").test(n)&&!new RegExp(aa+" pc","i").test(n)?M0:""},i1=n=>n instanceof Error;function s1(n){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return df&&t.length===kb||(kb=t.length,df=t.reduce(((r,i)=>{uc||(uc={});var s=uc[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,uc[i]=[c,u];break}}return r}),{})),df}}var Lf=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 Ji((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 Ji((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:s1(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)})}},rs="?";function Nf(n,e,t,r,i){var s={platform:n,filename:e,function:t==="<anonymous>"?rs:t,in_app:!0};return H(r)||(s.lineno=r),H(i)||(s.colno=i),s}var N0=(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]:rs,t?"safari-extension:"+e:"safari-web-extension:"+e]:[n,e]},o1=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,a1=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,l1=/\((\S*)(?::(\d+))(?::(\d+))\)/,c1=(n,e)=>{var t=o1.exec(n);if(t){var[,r,i,s]=t;return Nf(e,r,rs,+i,+s)}var o=a1.exec(n);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=l1.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=N0(o[1]||rs,o[2]);return Nf(e,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},u1=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,d1=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,p1=(n,e)=>{var t=u1.exec(n);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var r=d1.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]||rs;return[s,i]=N0(s,i),Nf(e,i,s,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},Rb=/\(error: (.*)\)/,Ib=50;function f1(){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=Rb.test(c)?c.replace(Rb,"$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>=Ib)break}}}return(function(h){if(!h.length)return[];var g=Array.from(h);return g.reverse(),g.slice(0,Ib).map((v=>{return W({},v,{filename:v.filename||(m=g,m[m.length-1]||{}).filename,function:v.function||rs});var m}))})(o)}})("web:javascript",c1,p1)}var Ff=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var r=Be(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 vc(e,"DOMException")}isDOMError(e){return vc(e,"DOMError")}},Df=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}},Hf=class{constructor(){}match(e){return vc(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}}},h1=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Bf=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(h1);return i&&(t=i[1],r=i[2]),[t,r]}},g1=["fatal","error","warning","log","info","debug"];function F0(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 Vf=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 _0(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: "+F0(e)}isSeverityLevel(e){return Be(e)&&!Rf(e)&&g1.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var r=e[t];if(i1(r))return r}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},Uf=class{match(e){return _0(e)}coerce(e,t){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+F0(e),stack:(r=t.syntheticException)==null?void 0:r.stack,synthetic:!0}}},jf=class{match(e){return If(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}}},Wf=class{match(e){return vc(e,"PromiseRejectionEvent")}coerce(e,t){var r,i=this.getUnhandledRejectionReason(e);return If(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(If(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}},D0=function(n,e){var{debugEnabled:t}=e===void 0?{}:e,r={k:function(i){if(S&&(xn.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)=>D0(n+" "+i,s)};return r},V=D0("[PostHog.js]"),$e=V.createLogger,m1=$e("[ExternalScriptsLoader]"),$b=(n,e,t)=>{if(n.config.disable_external_dependency_loading)return m1.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);$b(n,s,t)},ee.__PosthogExtensions__.loadSiteApp=(n,e,t)=>{var r=n.requestRouter.endpointFor("api",e);$b(n,r,t)};var _c={};function dr(n,e,t){if(_e(n)){if(bb&&n.forEach===bb)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)===_c)return}}}function xe(n,e,t){if(!ve(n)){if(_e(n))return dr(n,e,t);if(WA(n)){for(var r of n.entries())if(e.call(t,r[1],r[0])===_c)return}else for(var i in n)if(y0.call(n,i)&&e.call(t,n[i],i)===_c)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},ss=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 gc(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 Pb=function(n){try{return n()}catch{return}},v1=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)}}},jh=function(n){var e={};return xe(n,(function(t,r){(Be(t)&&t.length>0||Tn(t))&&(e[r]=t)})),e};function y1(n,e){return t=n,r=s=>Be(s)&&!Ot(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 _1=["herokuapp.com","vercel.app","netlify.app"];function b1(n){var e=n?.hostname;if(!Be(e))return!1;var t=e.split(".").slice(-2).join(".");for(var r of _1)if(t===r)return!1;return!0}function H0(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 B0="$people_distinct_id",Jo="__alias",Xo="__timers",Ob="$autocapture_disabled_server_side",zf="$heatmaps_enabled_server_side",Mb="$exception_capture_enabled_server_side",qf="$error_tracking_suppression_rules",Lb="$error_tracking_capture_extension_exceptions",Nb="$web_vitals_enabled_server_side",V0="$dead_clicks_enabled_server_side",Fb="$product_tours_enabled_server_side",Db="$web_vitals_allowed_metrics",pf="$session_recording_remote_config",bc="$sesid",U0="$session_is_sampled",Qi="$enabled_feature_flags",Qo="$early_access_features",Zf="$feature_flag_details",ea="$stored_person_properties",ni="$stored_group_properties",Gf="$surveys",wc="$flag_call_reported",Sn="$user_state",Kf="$client_session_props",Yf="$capture_rate_limit",Jf="$initial_campaign_params",Xf="$initial_referrer_info",xc="$initial_person_info",Sc="$epp",j0="__POSTHOG_TOOLBAR__",Vo="$posthog_cookieless",w1=[B0,Jo,"__cmpns",Xo,"$session_recording_enabled_server_side",zf,bc,Qi,qf,Sn,Qo,Zf,ni,ea,Gf,wc,Kf,Yf,Jf,Xf,Sc,xc,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function Hb(n){return n instanceof Element&&(n.id===j0||!(n.closest==null||!n.closest(".toolbar-global-fade-container")))}function Vc(n){return!!n&&n.nodeType===1}function pr(n,e){return!!n&&!!n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function W0(n){return!!n&&n.nodeType===3}function z0(n){return!!n&&n.nodeType===11}function Wh(n){return n?Hc(n).split(/\s+/):[]}function Bb(n){var e=S?.location.href;return!!(e&&n&&n.some((t=>e.match(t))))}function Ec(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 Wh(e)}function q0(n){return ve(n)?null:Hc(n).split(/(\s+)/).filter((e=>da(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function fa(n){var e="";return Qf(n)&&!J0(n)&&n.childNodes&&n.childNodes.length&&xe(n.childNodes,(function(t){var r;W0(t)&&t.textContent&&(e+=(r=q0(t.textContent))!==null&&r!==void 0?r:"")})),Hc(e)}function Z0(n){return H(n.target)?n.srcElement||null:(e=n.target)!=null&&e.shadowRoot?n.composedPath()[0]||null:n.target||null;var e}var zh=["a","button","form","input","select","textarea","label"];function G0(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 K0(n){var e=n.parentNode;return!(!e||!Vc(e))&&e}var x1=["next","previous","prev",">","<"],Vb=10,Ub=[".ph-no-rageclick",".ph-no-capture"];function S1(n,e){if(!S||qh(n))return!1;var t,r,i;if(An(e)?(t=!!e&&Ub,r=void 0):(t=(i=e?.css_selector_ignorelist)!==null&&i!==void 0?i:Ub,r=e?.content_ignorelist),t===!1)return!1;var{targetElementList:s}=Y0(n,!1);return!(function(o,a){if(o===!1||H(o))return!1;var l;if(o===!0)l=x1;else{if(!_e(o))return!1;if(o.length>Vb)return V.error("[PostHog] content_ignorelist array cannot exceed "+Vb+" 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:fa(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!G0(s,t)}var qh=n=>!n||pr(n,"html")||!Vc(n),Y0=(n,e)=>{if(!S||qh(n))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,r=[n],i=n;i.parentNode&&!pr(i,"body");)if(z0(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=K0(i);if(!s)break;if(e||zh.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 E1(n,e,t,r,i){var s,o,a,l;if(t===void 0&&(t=void 0),!S||qh(n)||(s=t)!=null&&s.url_allowlist&&!Bb(t.url_allowlist)||(o=t)!=null&&o.url_ignorelist&&Bb(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}=Y0(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)||!G0(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&&(zh.indexOf(h)>-1||n.getAttribute("contenteditable")==="true")}}function Qf(n){for(var e=n;e.parentNode&&!pr(e,"body");e=e.parentNode){var t=Ec(e);if(me(t,"ph-sensitive")||me(t,"ph-no-capture"))return!1}if(me(Ec(n),"ph-include"))return!0;var r=n.type||"";if(Be(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=n.name||n.id||"";return!(Be(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 J0(n){return!!(pr(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||pr(n,"select")||pr(n,"textarea")||n.getAttribute("contenteditable")==="true")}var X0="(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})",C1=new RegExp("^(?:"+X0+")$"),k1=new RegExp(X0),Q0="\\d{3}-?\\d{2}-?\\d{4}",A1=new RegExp("^("+Q0+")$"),T1=new RegExp("("+Q0+")");function da(n,e){return e===void 0&&(e=!0),!(ve(n)||Be(n)&&(n=Hc(n),(e?C1:k1).test((n||"").replace(/[- ]/g,""))||(e?A1:T1).test(n)))}function ew(n){var e=fa(n);return da(e=(e+" "+tw(n)).trim())?e:""}function tw(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=fa(t);e=(e+" "+i).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+tw(t)).trim())}catch(s){V.error("[AutoCapture]",s)}})),e}function R1(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 gc(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+=gc(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:I1(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return gc(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 I1(n){var e=n.attr__class;return e?_e(e)?e:Wh(e):void 0}var Cc=class{constructor(e){this.disabled=e===!1;var t=He(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}},kc=n=>{var e=D?.createElement("a");return H(e)?null:(e.href=n,e)},$1=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)},Ac=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," ")},ha=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},Tc=function(n,e){var t=n.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},ff="$copy_autocapture",Wb=$e("[AutoCapture]");function hf(n,e){return e.length>n?e.slice(0,n)+"...":e}function P1(n){if(n.previousElementSibling)return n.previousElementSibling;var e=n;do e=e.previousSibling;while(e&&!Vc(e));return e}function O1(n,e,t,r){var i=n.tagName.toLowerCase(),s={tag_name:i};zh.indexOf(i)>-1&&!t&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=hf(1024,ew(n)):s.$el_text=hf(1024,fa(n)));var o=Ec(n);o.length>0&&(s.classes=o.filter((function(u){return u!==""}))),xe(n.attributes,(function(u){var p;if((!J0(n)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!e&&da(u.value)&&(p=u.name,!Be(p)||p.substring(0,10)!=="_ngcontent"&&p.substring(0,7)!=="_nghost")){var f=u.value;u.name==="class"&&(f=Wh(f).join(" ")),s["attr__"+u.name]=hf(1024,f)}}));for(var a=1,l=1,c=n;c=P1(c);)a++,c.tagName===n.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function M1(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");)z0(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=Qf(_);_.tagName.toLowerCase()==="a"&&(g=_.getAttribute("href"),g=k&&g&&da(g)&&g),me(Ec(_),"ph-no-capture")&&(v=!0),f.push(O1(_,s,o,a));var I=(function(b){if(!Qf(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&&$&&da($)&&(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=ew(n):f[0].$el_text=fa(n)),g){var m,y;f[0].attr__href=g;var w=(m=kc(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:R1(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 eh=class{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Cc(e.config.rageclick),this.C=null}get R(){var e,t,r=He(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){Wb.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,ff)};Fe(D,"copy",t,{capture:!0}),Fe(D,"cut",t,{capture:!0})}}}else Wb.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({[Ob]:!!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[Ob],i=this.T;if(Ot(i)&&!An(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=Z0(e);W0(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())&&S1(i,this.instance.config.rageclick)&&this.O(e,"$rageclick");var s=t===ff;if(i&&E1(i,e,this.R,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=M1(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===ff){var c,u=q0(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 Tn(n)&&isFinite(n)&&Math.floor(n)===n});var zb="0123456789abcdef",th=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+zb.charAt(this.bytes[t]>>>4)+zb.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}},nh=class{constructor(){this.A=0,this.j=0,this.D=new rh}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 th.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())}},qb,nw=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&&(nw=n=>crypto.getRandomValues(n));var rh=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(nw(this.N),this.U=0),this.N[this.U++]}},cr=()=>L1().toString(),L1=()=>(qb||(qb=new nh)).generate(),Uo="",N1=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function F1(n,e){if(e){var t=(function(i,s){if(s===void 0&&(s=D),Uo)return Uo;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();!Uo&&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",Uo=c)}return Uo})(n);if(!t){var r=(i=>{var s=i.match(N1);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=F1(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}}},gf=null,Te={H:function(){if(!Ot(gf))return gf;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"),gf=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)}}},D1=["$device_id","distinct_id",bc,U0,Sc,xc],dc={},H1={H:function(){return!0},B:function(n){V.error("memoryStorage error: "+n)},q:function(n){return dc[n]||null},W:function(n){return dc[n]||null},G:function(n,e){dc[n]=e},V:function(n){delete dc[n]}},ei=null,ze={H:function(){if(!Ot(ei))return ei;if(ei=!0,H(S))ei=!1;else try{var n="__support__";ze.G(n,"xyz"),ze.q(n)!=='"xyz"'&&(ei=!1),ze.V(n)}catch{ei=!1}return ei},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)}}},En=(function(n){return n[n.PENDING=-1]="PENDING",n[n.DENIED=0]="DENIED",n[n.GRANTED=1]="GRANTED",n})({}),ih=class{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?En.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===En.DENIED||this.consent===En.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===En.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 cf(e)?En.GRANTED:me(ZA,e)?En.DENIED:En.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(cf(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!H0([ft?.doNotTrack,ft?.msDoNotTrack,ee.doNotTrack],(e=>cf(e)))}},pc=$e("[Dead Clicks]"),B1=()=>!0,V1=n=>{var e,t=!((e=n.instance.persistence)==null||!e.get_property(V0)),r=n.instance.config.capture_dead_clicks;return An(r)?r:!!He(r)||t},Rc=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({[V0]: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?pc.error("failed to load script",i):e()}))}et(){var e;if(D){if(!this.tt&&(e=ee.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=He(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),pc.info("starting...")}}else pc.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,pc.info("stopping..."))}},jo=$e("[ExceptionAutocapture]"),sh=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){jo.error("failed to start",c),this.ut()}}},this._instance=e,this.ht=!((t=this._instance.persistence)==null||!t.props[Mb]),this.dt=new $f({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:jo}),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 He(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?(jo.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 jo.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({[Mb]: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)?jo.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(e)}};function Zb(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 oh=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__||Zb(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__||Zb(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)}}}},mf=$e("[SegmentIntegration]");function U1(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(Sn,"identified")),i()},a=s.user();"then"in a&&ur(a.then)?a.then(o):o(a)})(n,(()=>{t.register((r=>{Promise&&Promise.resolve||mf.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()||(mf.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(mf.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 rw="posthog-js";function iw(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 ah=class{constructor(e,t,r,i,s,o){this.name=rw,this.setupOnce=function(a){a(iw(e,{organization:t,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}},j1=S!=null&&S.location?Tc(S.location.hash,"__posthog")||Tc(location.hash,"state"):null,Gb="_postHogToolbarParams",Kb=$e("[Toolbar]"),lr=(function(n){return n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED",n})(lr||{}),lh=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=j1||Tc(e.hash,"__posthog")||Tc(e.hash,"state"),o=s?Pb((()=>JSON.parse(atob(decodeURIComponent(s)))))||Pb((()=>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(Gb)||"{}")).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):Kb.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(Gb,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 Kb.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)}},W1=$e("[TracingHeaders]"),ch=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 W1.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)}},fc="https?://(.*)",os=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],z1=ss(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],os),ga="<masked>",q1=["li_fat_id"];function sw(n,e,t){if(!D)return{};var r,i=e?ss([],os,t||[]):[],s=ow(ha(D.URL,i,ga),n),o=(r={},xe(q1,(function(a){var l=Yt.q(a);r[a]=l||null})),r);return Me(o,s)}function ow(n,e){var t=z1.concat(e||[]),r={};return xe(t,(function(i){var s=Ac(n,i);r[i]=s||null})),r}function aw(n){var e=(function(s){return s?s.search(fc+"google.([^/?]*)")===0?"google":s.search(fc+"bing.com")===0?"bing":s.search(fc+"yahoo.com")===0?"yahoo":s.search(fc+"duckduckgo.com")===0?"duckduckgo":null:null})(n),t=e!="yahoo"?"q":"p",r={};if(!Ot(e)){r.$search_engine=e;var i=D?Ac(D.referrer,t):"";i.length&&(r.ph_keyword=i)}return r}function Yb(){return navigator.language||navigator.userLanguage}function lw(){return D?.referrer||"$direct"}function cw(n,e){var t=n?ss([],os,e||[]):[],r=qe?.href.substring(0,1e3);return{r:lw().substring(0,1e3),u:r?ha(r,t,ga):void 0}}function uw(n){var e,{r:t,u:r}=n,i={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=kc(t))==null?void 0:e.host};if(r){i.$current_url=r;var s=kc(r);i.$host=s?.host,i.$pathname=s?.pathname;var o=ow(r);Me(i,o)}if(t){var a=aw(t);Me(i,a)}return i}function dw(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Z1(){try{return new Date().getTimezoneOffset()}catch{return}}function G1(n,e){if(!ct)return{};var t,r,i,s=n?ss([],os,e||[]):[],[o,a]=(function(l){for(var c=0;c<Ab.length;c++){var[u,p]=Ab[c],f=u.exec(l),h=f&&(ur(p)?p(f,l):p);if(h)return h}return["",""]})(ct);return Me(jh({$os:o,$os_version:a,$browser:L0(ct,navigator.vendor),$device:Tb(ct),$device_type:(r=ct,i=Tb(r),i===w0||i===b0||i==="Kobo"||i==="Kindle Fire"||i===M0?aa:i===ca||i===ts||i===ua||i===Of?"Console":i===S0?"Wearable":i?St:"Desktop"),$timezone:dw(),$timezone_offset:Z1()}),{$current_url:ha(qe?.href,s,ga),$host:qe?.host,$pathname:qe?.pathname,$raw_user_agent:ct.length>1e3?ct.substring(0,997)+"...":ct,$browser_version:r1(ct,navigator.vendor),$browser_language:Yb(),$browser_language_prefix:(t=Yb(),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:xn.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var sr=$e("[Web Vitals]"),Jb=9e5,uh=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[Nb]),this.startIfEnabled()}get allowedMetrics(){var e,t,r=He(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[Db])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(He(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=He(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return e!=null&&e}get Rt(){var e=He(this._instance.config.capture_performance)&&Tn(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Jb;return 0<e&&e<=6e4?Jb: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=He(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:An(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return An(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(sr.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=He(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=He(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Nb]:t}),this._instance.persistence.register({[Db]: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?ss([],os,r||[]):[];return ha(e,i,ga)}sr.error("Could not determine current URL")}},K1=$e("[Heatmaps]");function Xb(n){return He(n)&&"clientX"in n&&"clientY"in n&&Tn(n.clientX)&&Tn(n.clientY)}var dh=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[zf]),this.rageclicks=new Cc(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return He(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;K1.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({[zf]: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 Rc(this.instance,B1,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&&Vc(u)&&!pr(u,"body");){if(u===c)return!1;if(me(l,S?.getComputedStyle(u).position))return!0;u=K0(u)}return!1})(Z0(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"),!Hb(e.target)&&Xb(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){!Hb(e.target)&&Xb(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?ss([],os,i||[]):[],o=ha(t,s,ga);this.N=this.N||{},this.N[o]||(this.N[o]=[]),this.N[o].push(e)}}Lt(){this.N&&!Xi(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},Ic=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 Cn=(function(n){return n.GZipJS="gzip-js",n.Base64="base64",n})({}),Et=Uint8Array,rt=Uint16Array,is=Uint32Array,Zh=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]),Gh=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]),Qb=new Et([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),pw=function(n,e){for(var t=new rt(31),r=0;r<31;++r)t[r]=e+=1<<n[r-1];var i=new is(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]},fw=pw(Zh,2),Y1=fw[0],ph=fw[1];Y1[28]=258,ph[258]=28;for(fh=pw(Gh,0)[1],$c=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,$c[Se]=((65280&or)>>>8|(255&or)<<8)>>>1;var or,fh,$c,Se,ia=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[$c[p]>>>l]=c}else for(o=new rt(r),i=0;i<r;++i)o[i]=$c[a[n[i]-1]++]>>>15-n[i];return o},ii=new Et(288);for(Se=0;Se<144;++Se)ii[Se]=8;for(Se=144;Se<256;++Se)ii[Se]=9;for(Se=256;Se<280;++Se)ii[Se]=7;for(Se=280;Se<288;++Se)ii[Se]=8;var Pc=new Et(32);for(Se=0;Se<32;++Se)Pc[Se]=5;var J1=ia(ii,9,0),X1=ia(Pc,5,0),hw=function(n){return(n/8>>0)+(7&n&&1)},gw=function(n,e,t){(t==null||t>n.length)&&(t=n.length);var r=new(n instanceof rt?rt:n instanceof is?is:Et)(t-e);return r.set(n.subarray(e,t)),r},bn=function(n,e,t){t<<=7&e;var r=e/8>>0;n[r]|=t,n[r+1]|=t>>>8},Wo=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},vf=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=hh(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]},hh=function(n,e,t){return n.s==-1?Math.max(hh(n.l,e,t+1),hh(n.r,e,t+1)):e[n.s]=t},e0=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]},zo=function(n,e){for(var t=0,r=0;r<e.length;++r)t+=n[r]*e[r];return t},gh=function(n,e,t){var r=t.length,i=hw(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)},t0=function(n,e,t,r,i,s,o,a,l,c,u){bn(e,u++,t),++i[256];for(var p=vf(i,15),f=p[0],h=p[1],g=vf(s,15),v=g[0],m=g[1],y=e0(f),w=y[0],x=y[1],_=e0(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=vf(b,7),J=M[0],$=M[1],U=19;U>4&&!J[Qb[U-1]];--U);var G,Z,te,ye,pe=c+5<<3,j=zo(i,ii)+zo(s,Pc)+o,X=zo(i,f)+zo(s,v)+o+14+3*U+zo(b,J)+(2*b[16]+3*b[17]+7*b[18]);if(pe<=j&&pe<=X)return gh(e,u,n.subarray(l,l+c));if(bn(e,u,1+(X<j)),u+=2,X<j){G=ia(f,h,0),Z=f,te=ia(v,m,0),ye=v;var Pe=ia(J,$,0);for(bn(e,u,x-257),bn(e,u+5,I-1),bn(e,u+10,U-4),u+=14,A=0;A<U;++A)bn(e,u+3*A,J[Qb[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];bn(e,u,Pe[Xe]),u+=J[Xe],Xe>15&&(bn(e,u,Je[A]>>>5&127),u+=Je[A]>>>12)}}}else G=J1,Z=ii,te=X1,ye=Pc;for(A=0;A<a;++A)if(r[A]>255){Xe=r[A]>>>18&31,Wo(e,u,G[Xe+257]),u+=Z[Xe+257],Xe>7&&(bn(e,u,r[A]>>>23&31),u+=Zh[Xe]);var Rn=31&r[A];Wo(e,u,te[Rn]),u+=ye[Rn],Rn>3&&(Wo(e,u,r[A]>>>5&8191),u+=Gh[Rn])}else Wo(e,u,G[r[A]]),u+=Z[r[A]];return Wo(e,u,G[256]),u+Z[256]},Q1=new is([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),eT=(function(){for(var n=new is(256),e=0;e<256;++e){for(var t=e,r=9;--r;)t=(1&t&&3988292384)^t>>>1;n[e]=t}return n})(),tT=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=gh(h,g,s.subarray(v,m)):(h[v]=u,g=gh(h,g,s.subarray(v,p)))}else{for(var y=Q1[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(ls){return(s[ls]^s[ls+1]<<b^s[ls+2]<<A)&_},J=new is(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,Pe=I[j];if(k[X]=Pe,I[j]=X,ye<=v){var Ye=p-v;if((G>7e3||te>24576)&&Ye>423){g=t0(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,Rn=x,Mt=X-Pe&32767;if(Ye>2&&j==M(v-Mt))for(var as=Math.min(w,Ye)-1,R=Math.min(32767,v),Y=Math.min(258,Ye);Mt<=R&&--Rn&&X!=Pe;){if(s[v+Je]==s[v+Je-Mt]){for(var B=0;B<Y&&s[v+B]==s[v+B-Mt];++B);if(B>Je){if(Je=B,Xe=Mt,B>as)break;var fe=Math.min(Mt,B-2),he=0;for(De=0;De<fe;++De){var se=v-Mt+De+32768&32767,Re=se-k[se]+32768&32767;Re>he&&(he=Re,Pe=se)}}}Mt+=(X=Pe)-(Pe=k[X])+32768&32767}if(Xe){J[te++]=268435456|ph[Je]<<18|fh[Xe];var Xt=31&ph[Je],Qt=31&fh[Xe];Z+=Zh[Xt]+Gh[Qt],++$[257+Xt],++U[Qt],ye=v+Je,++G}else J[te++]=s[v],++$[s[v]]}}g=t0(s,h,u,J,$,U,Z,te,pe,v-pe,g)}return gw(f,0,l+hw(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)},yf=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8};function nT(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=eT[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}})(),r=n.length;t.p(n);var i,s=tT(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&&yf(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),yf(s,o-8,t.d()),yf(s,o-4,r),s}var rT=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),Ot(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},iT=!!Af||!!kf,n0="text/plain",Oc=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=$1(o);return l&&a.push(l),i+"?"+a.join("&")},ta=(n,e)=>JSON.stringify(n,((t,r)=>typeof r=="bigint"?r.toString():r),e),_f=n=>{var{data:e,compression:t}=n;if(e){if(t===Cn.GZipJS){var r=nT((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 gw(p,0,f)})(ta(e)),{mtime:0}),i=new Blob([r],{type:n0});return{contentType:n0,body:i,estimatedSize:i.size}}if(t===Cn.Base64){var s=(function(l){var c,u,p,f,h,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,m=0,y="",w=[];if(!l)return l;l=rT(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})(ta(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:ta(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=ta(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},mc=[];kf&&mc.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=_f(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(xb){var c=new xb;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),n.timeout)}}kf(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))}}),Af&&mc.push({transport:"XHR",method:n=>{var e,t=new Af;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=_f(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)}}),ft!=null&&ft.sendBeacon&&mc.push({transport:"sendBeacon",method:n=>{var e=Oc(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=_f(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;ft.sendBeacon(e,s)}catch{}}});var Mc=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 r0(n,e,t){return ta({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var mw={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=>Mc(t,r))))),not_regex:(n,e)=>e.every((t=>n.every((r=>!Mc(t,r))))),icontains:(n,e)=>e.map(hc).some((t=>n.map(hc).some((r=>t.includes(r))))),not_icontains:(n,e)=>e.map(hc).every((t=>n.map(hc).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)))}))},hc=n=>n.toLowerCase();function vw(n,e){return!n||Object.entries(n).every((t=>{var[r,i]=t,s=e?.[r];if(H(s)||Ot(s))return!1;var o=[String(s)],a=mw[i.operator];return!!a&&a(i.values,o)}))}var bf=$e("[Error tracking]"),mh=class{constructor(e){var t,r;this.Zt=[],this.ti=new Lf([new Ff,new Wf,new Hf,new Df,new Uf,new Vf,new Bf,new jf],f1()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(qf))!==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({[qf]:this.Zt,[Lb]:o})}get ii(){var e,t=!!this._instance.get_property(Lb),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 bf.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void bf.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void bf.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 Be(s)&&s.length>0&&r.$exception_types.push(s),Be(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=mw[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)}},pt=$e("[FeatureFlags]"),qo=$e("[FeatureFlags]",{debugEnabled:!0}),wf="$active_feature_flags",Zi="$override_feature_flags",i0="$feature_flag_payloads",Zo="$override_feature_flag_payloads",s0="$feature_flag_request_id",o0="$feature_flag_evaluated_at",a0=n=>{var e={};for(var[t,r]of gc(n||{}))r&&(e[t]=r);return e},sT=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]})))):pt.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},oT=(function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n})({}),vh=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||(pt.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||pt.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(Zf),t=this._instance.get_property(Zi),r=this._instance.get_property(Zo);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||(pt.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(Qi),t=this._instance.get_property(Zi);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||(pt.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(i0),t=this._instance.get_property(Zo);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||(pt.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(ea)||{}),group_properties:this._instance.get_property(ni)};Ot(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=dw()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:Cn.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(oT.FeatureFlags))pt.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}pt.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(s0)||void 0,c=this._instance.get_property(o0)||void 0,u=this._instance.get_property(wc)||{};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({[wc]: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 pt.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:Cn.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}pt.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=sT(o),f=p.flags,h=p.featureFlags,g=p.featureFlagPayloads;if(h){var v=o.requestId,m=o.evaluatedAt;if(_e(h)){pt.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({[wf]:h,[Qi]: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({[wf]:Object.keys(a0(x)),[Qi]:x||{},[i0]:_||{},[Zf]:k||{}},v?{[s0]:v}:{},m?{[o0]:m}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),pt.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return pt.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(Zi),this._instance.persistence.unregister(Zo),this.wi(),qo.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(Zi),qo.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({[Zi]:i})}else this._instance.persistence.register({[Zi]:r.flags});qo.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(Zo),qo.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[Zo]:r.payloads}),qo.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(Qo)||[]).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({[wf]:Object.keys(a0(l)),[Qi]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(Qo),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(Qo),(l=this._instance.persistence)==null||l.register({[Qo]: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(ea)||{};this._instance.register({[ea]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(ea)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(ni)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=W({},r[i],e[i]),delete e[i]})),this._instance.register({[ni]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(ni)||{};this._instance.register({[ni]:W({},t,{[e]:{}})})}else this._instance.unregister(ni)}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}},aT=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],sa=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){aT.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=[...D1,...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"?H1:r==="cookie"?Yt:t.H()?t:Yt}properties(){var e={};return xe(this.props,(function(t,r){if(r===Qi&&He(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,(Ot(o=w1)?l:wb&&o.indexOf===wb?o.indexOf(a)!=-1:(xe(o,(function(c){if(l||(l=c===a))return _c})),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(He(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(He(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=sw(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);Xi(jh(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=D?.referrer)?aw(e):{})}update_referrer_info(){var e;this.register_once({$referrer:lw(),$referring_domain:D!=null&&D.referrer&&((e=kc(D.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Jf]||this.props[Xf]||this.register_once({[xc]:cw(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};xe([Xf,Jf],(o=>{var a=this.props[o];a&&xe(a,(function(l,c){e["$initial_"+Tf(c)]=l}))}));var t,r,i=this.props[xc];if(i){var s=(t=uw(i),r={},xe(t,(function(o,a){r["$initial_"+Tf(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[Xo]||{};r[e]=t,this.props[Xo]=r,this.save()}remove_event_timer(e){var t=(this.props[Xo]||{})[e];return H(t)||(delete this.props[Xo][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},l0=$e("[Product Tours]"),xf="ph_product_tours",yh=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Fb]:!(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(Fb)||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?l0.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[xf];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 l0.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({[xf]: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(xf)}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)}},Go=(function(n){return n.Activation="events",n.Cancellation="cancelEvents",n})({}),aD=(function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n})({}),lD=(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})({}),cD=(function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n})({}),Sf=(function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n})({}),uD=(function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n})({}),dD=(function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n})({}),pD=(function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n})({}),na=(function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n})({}),Ef=(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})({}),_h=(function(n){return n.Popover="popover",n.Inline="inline",n})({}),we=$e("[Surveys]"),yw="seenSurvey_",lT=(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},c0=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(yw,n),cT=[Sf.Popover,Sf.Widget,Sf.API],uT={ignoreConditions:!1,ignoreDelay:!1,displayType:_h.Popover},pa=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 Gi(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 bh=class{constructor(e){this.Ai=new pa,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"||!Gi(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=>Gi(a.href,t.href,t.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&Gi((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=>Gi(c.text,t.text,t.text_matching||"exact")||Gi(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=>Gi(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||vw(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)}},wh=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&vw(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===Go.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 bh(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,Go.Activation),this.Yi=this.Zi(e,Go.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,Go.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,Go.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}},xh=class extends wh{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return na.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()}},Sh=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(yw)||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 xh(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(Gf);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({[Gf]: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(cT.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!==_h.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!==_h.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()}},wn=$e("[Conversations]"),Eh=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)||(An(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 wn.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),wn.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else wn.error("Cannot complete initialization: remote config is null")}Se(e,t){wn.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():wn.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!Ot(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 Ji((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(wn.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var r=this;return Ji((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(wn.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return Ji((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(wn.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return Ji((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(wn.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}},Ch=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=$e("[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.")}}},u0=$e("[RateLimiter]"),kh=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=>{u0.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void u0.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(Yf))!==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(Yf,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},ti=$e("[RemoteConfig]"),Ah=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))):(ti.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 ti.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void ti.warn("Remote config is disabled. Falling back to local config.");this.Te((e=>{if(!e)return ti.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){ti.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()):ti.info("__preview_remote_config is disabled. Logging config instead",e):ti.error("Failed to fetch remote config from PostHog.")}},Th=3e3,Rh=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=Jt(t?.flush_interval_ms||Th,250,5e3,V.createLogger("flush interval"),Th),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}},dT=["retriesPerformedSoFar"],Ih=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=m0(e,dT);Ki(t)&&(r.url=Oc(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=[]}},$h=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}},pT=n=>cw(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),Lc=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({[Kf]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||pT,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[Kf]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?uw(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(jh(this.getSetOnceProps()),((t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+Tf(r)]=t})),e}},Cf=$e("[SessionId]"),Nc=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 pa,this.er=(u,p)=>!(!Ki(u)||!Ki(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,Cf.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){Cf.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({[bc]:[t,e,r]}))}_r(){var e=this.Xe.props[bc];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=Ki(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(),Cf.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=Ki(i)&&e&&!l?i:r,h=Ki(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)}},fT=["$set_once","$set"],ar=$e("[SiteApps]"),Ph=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({},m0(e,fT),{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.')}},_w=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&Eb(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>Eb(i?.brand,e))))return!0}catch{}return!!n.webdriver},ra=(function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n})({}),d0="i.posthog.com",Oh=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("."+d0,".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]=ra.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=ra.EU:this.Sr[this.apiHost]=ra.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===ra.CUSTOM)return this.apiHost+t;var r=d0+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},hT={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&&Mc(e.href,n),not_regex:(n,e)=>!!S&&!Mc(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Mh=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);Be(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=Ac(e?.search,"__experiment_id"),r=Ac(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||hT[(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=sw();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 ft&&this._instance?_w(ft,this._instance.config.custom_blocked_useragents):void 0}},gT=$e("[PostHog ExternalIntegrations]"),mT={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Lh=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 gT.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(mT[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)}}},Nh="[SessionRecording]",Ko=$e(Nh),Fc=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 Ko.error("started without valid sessionManager"),new Error(Nh+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Nh+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(pf))==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),Ko.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 Ko.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(U0)}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({[pf]: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:Ko.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):Ko.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(pf);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))}},oa={},Fh=()=>{},Yi="posthog",bw=!iT&&ct?.indexOf("MSIE")===-1&&ct?.indexOf("Mozilla")===-1,p0=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:b1(D?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Fh,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&&Be(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:Th},error_tracking:{},_onCapture:Fh,__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))},f0=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},Dh=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}},Dc=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 Dh,this.Br=!1,this.version=xn.LIB_VERSION,this.qr=new pa,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=p0(),this.SentryIntegration=ah,this.sentryIntegration=e=>(function(t,r){var i=iw(t,r);return{name:rw,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 vh(this),this.toolbar=new lh(this),this.scrollManager=new $h(this),this.pageViewManager=new Ic(this),this.surveys=new Sh(this),this.conversations=new Eh(this),this.logs=new Ch(this),this.experiments=new Mh(this),this.exceptions=new mh(this),this.rateLimiter=new kh(this),this.requestRouter=new Oh(this),this.consent=new ih(this),this.externalIntegrations=new Lh(this),this.people={set:(e,t,r)=>{var i=Be(e)?{[e]:t}:e;this.setPersonProperties(i),r?.({})},set_once:(e,t,r)=>{var i=Be(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!==Yi){var i,s=(i=oa[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),oa[r]=s,oa[Yi][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),H(e)||Rf(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({},p0(t.defaults),f0(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:Cn.GZipJS;var s=this.Qr();this.persistence=new sa(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new sa(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 Rh((w=>this.ts(w)),this.config.request_queue_config),this.es=new Ih(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 Nc(this),this.sessionPropsManager=new Lc(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)),xn.DEBUG=xn.DEBUG||this.config.debug,xn.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(Sn,(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:Vo,$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(Sn,"anonymous")}return Fe(S,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?U1(this,(()=>this.ns())):this.ns(),ur(this.config._onCapture)&&this.config._onCapture!==Fh&&(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 oh(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new ch(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new Ph(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new Fc(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new eh(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.logs.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new yh(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new dh(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new uh(this)})),r.push((()=>{this.exceptionObserver=new sh(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new Rc(this,V1),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,Cn.GZipJS)?Cn.GZipJS:me(e.supportedCompression,Cn.Base64)?Cn.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 Ah(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&&(bw?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Oc(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=Oc(o.url,{_:new Date().getTime().toString(),ver:xn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=mc.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(i=(s=H0(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)&&Be(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&&!Be(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=y1(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===na.DISMISSED||e===na.SENT){var g=t?.[Ef.SURVEY_ID],v=t?.[Ef.SURVEY_ITERATION];p={id:g,current_iteration:v},localStorage.getItem(c0(p))||localStorage.setItem(c0(p),"true"),u.$set=W({},u.$set,{[lT({id:g,current_iteration:v},e===na.SENT?"responded":"dismissed")]:!0})}else e===na.SHOWN&&(u.$set=W({},u.$set,{[Ef.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var m=W({},u.properties.$set,u.$set);if(Xi(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,(!Be(a.distinct_id)&&!Tn(a.distinct_id)||Rf(a.distinct_id))&&V.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=G1(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===ra.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),Xi(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=uT),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(Tn(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!==Vo){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(Jo)&&(this.unregister(Jo),this.register({distinct_id:e}));var o=(this.persistence.get_property(Sn)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(Sn,"identified"),this.setPersonPropertiesForFlags(W({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=r0(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(wc))}}else V.critical('The string "'+Vo+'" 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=r0(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(Sn,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Vo,$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(B0)?(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(Jo,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(He(e)){var r,i,s,o,a,l,c;Me(this.config,f0(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 sa(W({},this.config,{persistence:"sessionStorage"}),u);var p=this.Kr(this.config.debug);An(p)&&(this.config.debug=p),An(this.config.debug)&&(this.config.debug?(xn.DEBUG=!0,Te.H()&&Te.G("ph_debug","true"),V.info("set_config",{config:e,oldConfig:t,newConfig:W({},this.config)})):(xn.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:Yi;return t!==Yi&&(t=Yi+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(Sn))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(Sn))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Xi(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Jo])&&((t=this.persistence)==null||(t=t.props)==null||!t[Sc]))}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(Sc,!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 Nc(this),this.pageViewManager=new Ic(this),this.persistence&&(this.sessionPropsManager=new Lc(this,this.sessionManager,this.persistence)),this.sessionRecording=new Fc(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:Vo,$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===En.GRANTED?"granted":e===En.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 ft?_w(ft,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 zA(e.event)?V.warn(s+". This can cause unexpected behavior."):V.info(s),null}r.properties&&!Xi(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=An(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]]=v1(n.prototype[e[t]])})(Dc,["identify"]);var h0;var ww=(h0=oa[Yi]=new Dc,(function(){function n(){n.done||(n.done=!0,bw=!1,xe(oa,(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")})(),h0);var Kh=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=ww.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 Yh(n={}){return new Kh(n)}var xw={posthog:n=>Yh(n),noop:()=>lf()};function Sw(n,e){let t=xw[n];if(!t)throw new Error(`Unknown telemetry provider: ${n}. Supported: ${Object.keys(xw).join(", ")}`);return t(e)}function vT(n){return n?.manifest?.runtime!==void 0}async function Ew(n){Dd(),q("Syntro Bootstrap","====== INIT ======"),q("Syntro Bootstrap","Options:",{hasToken:!!n.token,tokenPrefix:`${n.token?.slice(0,15)}...`,hasCanvasOptions:!!n.canvas});let e=Hl();if(console.log(`[DIAG] Mode detection: sdkMode=${e}`),console.log("[DIAG] editorSource:",xo()),console.log("[DIAG] editorConf:",Dl()),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=Dl()?.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=So(t),Dd(r.d);else if(e)q("Syntro Bootstrap",`\u2713 Non-syn_ token allowed (${e} mode)`);else throw wl("Syntro Bootstrap","\u274C Token does not start with syn_ and NOT in editor/audit/review mode!"),wl("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 wl("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=Hd({resource:{serviceName:"syntro-runtime-sdk",serviceVersion:ao,posthogKey:r.t??"",hostOrigin:typeof window<"u"?window.location.origin:""},emit:Vd({endpoint:R})}),B=jd()??"https://cdn.syntrologie.com/runtime-sdk/",fe=rp(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")||a_,l=e_(),c=Ep(),u=n.appSignalsInit??{},p=s_(),f=Cp(c,p);o_(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=kp(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=Js({debug:n.debug,history:y?new Co(n.testMode?0:100):void 0,testMode:n.testMode});console.log("[Syntro Bootstrap] EventBus created");let x=Du({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{ob(w),ab(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 _=ub(),k,I=R=>{q("Syntro Bootstrap","Phase 2: PostHog feature flags loaded");let Y=r_(R);if(q("Syntro Bootstrap","Segment flags from PostHog:",Y),t_(Y),m){let B=A?.getAll?.()??{},fe=Di(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=Sw(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=()=>Di(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 Ho({initialStatus:"pending",pendingResolver:fe,onConsentChange:se=>{n_(se),se==="granted"?B.optInCapturing?.():se==="denied"&&B.optOutCapturing?.()}});try{B.track?.("syntro_bootstrap_step",{stage:"consent_gate_constructed"})}catch{}try{g_(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 Do({adapters:[new Fo,new No,new Lo],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=c_({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=tb("growthbook",{clientKey:r.e,apiHost:i,attributes:{...h,id:Di(b?.getDistinctId?.())},onExperimentViewed:b?.trackExperiment?(R,Y,B)=>{b.trackExperiment(R,Y,B)}:void 0})),A=tf({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=Nd({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 vb({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 mb({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")||nl()||"https://cdn.syntrologie.com",pe=lu({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"&&vT(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:Di(b?.getDistinctId?.())};q("Syntro Bootstrap","Merging geo data into GrowthBook attributes:",X),m.setAttributes?.(R)}let Pe=await v;Pe&&m&&(c.surface_type="mcp-app",c.surface_host=Pe.name,m.setAttributes?.({...c,...f,...X,id:Di(b?.getDistinctId?.())}),U.context.setSurfaceType("mcp-app"),U.context.setSurfaceHost(Pe.name),q("Syntro Bootstrap","MCP App detected:",Pe.name));let Ye;if(n.fetcher)Ye=n.fetcher;else if(r?.f){let R=sb(r.f,r.o??{});Ye=async()=>{let Y=await R.fetch();return{...Y.config,tiles:Y.config.tiles??[]}}}else m&&(Ye=Ai({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&&Ua({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 Rn=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(Tw){console.warn("[Syntro] interventionTracker nav unsub threw:",Tw)}Xt=new Bo(b,fe),se&&(se.interventionTracker=Xt);let ls=U.navigation.subscribe(()=>{Xt.resetPage()});se&&(se.interventionTrackerUnsub=ls)}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 Mt=await mp({...n.canvas,fetcher:Rn,integrations:{experiments:m,telemetry:b},editorUrl:o,runtime:U}),as=jt();if(as!==null)try{let R=b,Y=U;as.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 as?.increment("bootstrap_ok"),{canvas:Mt,runtime:U,experiments:m,telemetry:b,sessionMetrics:A,appLoader:pe}}async function yT(n){try{return await Ew(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 _T(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 bT(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 Cw={init:yT,loadAdaptive:bT,encodeToken:yp,decodeToken:So,events:{emit:_T}};typeof window<"u"&&(window.Syntro=Cw);function ma(n){let e=n.split(".");return{major:parseInt(e[0]||"0",10),minor:parseInt(e[1]||"0",10)}}function QD(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=ma(i),o=ma(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:wT(r,i)}):{valid:!0,warnings:e,errors:t}}function wT(n,e){let t={...n};return ma(e).major===1&&(t=xT(t)),t.schemaVersion=Vn,t}function xT(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 e5(n){if(!n||typeof n!="object")return!1;let e=n,t=e.schemaVersion||"1.0",r=ma(t),i=ma(Vn);return r.major<i.major||!e.schemaVersion}var ST=d.object({url:d.string(),routeId:d.string().optional(),title:d.string().optional(),locale:d.string().optional()}),ET=d.object({url:d.string(),ts:d.number()}),CT=d.object({sessionId:d.string(),startTs:d.number(),pageHistory:d.array(ET).optional()}),kT=d.object({width:d.number(),height:d.number()}),AT=d.object({x:d.number(),y:d.number(),w:d.number(),h:d.number()}),TT=d.object({anchorId:d.string(),present:d.boolean(),visible:d.boolean().optional(),boundingBox:AT.optional()}),RT=d.record(d.string(),d.union([d.number(),d.string(),d.boolean(),d.undefined()])),IT=d.object({page:ST,session:CT,viewport:kT,anchors:d.array(TT).optional(),augmented:RT.optional()});function r5(n){return IT.safeParse(n)}var Jh=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 Xh=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 Qh=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 kw=d.enum(["posthog","canvas","derived"]),$T=d.object({ts:d.number(),name:d.string(),source:kw,props:d.record(d.string(),d.unknown()).optional(),schemaVersion:d.string()}),PT=d.object({names:d.array(d.string()).optional(),patterns:d.array(d.string()).optional(),sources:d.array(kw).optional()});function A5(n){return $T.safeParse(n)}function T5(n){return PT.safeParse(n)}var OT=d.object({value:d.unknown(),expiresAt:d.number().optional()}),MT=d.object({count:d.number(),resetAt:d.number().optional()});function j5(n){return OT.safeParse(n)}function W5(n){return MT.safeParse(n)}var Aw="2026-07-24T18:59:36.948Z (31156e4c3)";if(typeof window<"u"){console.log(`[Syntro Runtime] Build: ${Aw} (Lit)`);let n=window.SynOS,e=n?.appRegistry||Ps;window.SynOS={...n,appRegistry:e,_runtimeBuild:Aw,_renderer:"lit"},Ll(),ym(e)}export{no as ANIMATION_KEYFRAMES,al as ActivationConfigZ,yv as AddClassZ,bt as AnchorIdZ,TT as AnchorStateZ,_u as AnchorVisibleConditionZ,$s as AppRegistry,RT as AugmentationZ,av as BadgePositionZ,Ev as BadgeZ,AT as BoundingBoxZ,Ks as CanvasEvents,Dn as ConditionZ,ll as ContextManager,Cu as CooldownActiveConditionZ,Ds as CounterDefZ,pd as CtaButtonZ,Hu as DEFAULT_COOLDOWN,Jh as DecisionController,Ws as DecisionStrategyZ,Eu as DismissedConditionZ,Oe as EVENT_SCHEMA_VERSION,pl as EventBus,Au as EventCountConditionZ,PT as EventFilterZ,Co as EventHistory,bu as EventOccurredConditionZ,kw as EventSourceZ,rl as ExecutorRegistry,js as ExternalStrategyZ,MT as FrequencyEntryZ,ku as FrequencyLimitConditionZ,ov as HighlightStyleZ,xv as HighlightZ,wv as InsertHtmlZ,dv as InsertPositionZ,Bo as InterventionTracker,Xa as MAX_VISIBLE_TOASTS,du as MOUNT_PLUMBING_KEYS,Fs as MatchOpZ,uv as ModalContentZ,kv as ModalZ,Us as ModelStrategyZ,Rv as MountWidgetZ,Tv as NavigateZ,Xs as NavigationMonitor,$T as NormalizedEventZ,Gs as NotificationsController,ST as PageContextZ,ET as PageHistoryEntryZ,vu as PageUrlConditionZ,Pv as ParallelZ,lv as PlacementZ,Sv as PulseZ,Aw as RUNTIME_SDK_BUILD,ml as RUNTIME_VERSION,_v as RemoveClassZ,yu as RouteConditionZ,ev as RouteFilterZ,Bs as RuleStrategyZ,Hs as RuleZ,IT as RuntimeContextZ,Xh as RuntimeController,Qh as RuntimeEventsController,Vn as SDK_SCHEMA_VERSION,ao as SDK_VERSION,Gv as STATIC_SLOT_STYLES,Vs as ScoreStrategyZ,gv as ScrollBehaviorZ,dd as ScrollLogicalPositionZ,Av as ScrollToZ,$v as SequenceZ,CT as SessionContextZ,Su as SessionMetricConditionZ,ac as SessionMetricTracker,vv as SetAttrZ,bv as SetStyleZ,mv as SetTextZ,ip as SmartCanvasController,Ri as SmartCanvasElementLit,Ve as StandardEvents,wu as StateEqualsConditionZ,fl as StateStore,OT as StoredValueZ,Cw as Syntro,fo as ThemeController,cv as TooltipContentZ,pv as TooltipTriggerZ,Cv as TooltipZ,hv as TourStepForSchemaZ,Ov as TourZ,Va as TriggerWhenZ,xu as ViewportConditionZ,kT as ViewportContextZ,Iv as WaitZ,fv as WidgetConfigZ,gl as WidgetRegistry,kd as applyStaticSlotStyles,eC as coreActionStepSchemas,ld as createActionEngine,fd as createAnchorResolver,Ai as createCanvasConfigFetcher,md as createContextManager,vd as createDecisionEngine,yd as createEventAccumulator,Js as createEventBus,Xp as createGrowthBookClient,lf as createNoopClient,Yh as createPostHogClient,Ym as createPostHogNormalizer,tf as createSessionMetricTracker,mp as createSmartCanvas,Sy as createSmartCanvasController,Nd as createSmartCanvasRuntime,Cd as createStateStore,$d as createSurfaceContainer,Od as createSurfaces,VO as decisionSchemas,So as decodeToken,yp as encodeToken,Hv as evaluate,Nv as evaluateCondition,Fv as evaluateRule,cl as evaluateRuleStrategy,ul as evaluateScoreStrategy,Bv as evaluateSync,Bn as executorRegistry,ZC as getAntiFlickerSnippet,hl as getSlotAnchorId,to as getSlotType,Pd as getSlotZIndex,qu as hasExecutor,e5 as needsMigration,qs as normalizePostHogEvent,ma as parseVersion,Rd as playEnterAnimation,Id as playExitAnimation,Ti as registerConfigPredicates,Ll as registerSmartCanvasElement,IC as resolveConfigUri,FC as runtimeContext,Ad as setupAdjacentPositioning,Td as setupInlinePositioning,Zs as shouldNormalizeEvent,bm as stripMountPlumbing,Vt as validateAction,ol as validateActions,BO as validateActivationConfig,DO as validateCondition,QD as validateConfig,T5 as validateEventFilter,_d as validateEventName,W5 as validateFrequencyEntry,A5 as validateNormalizedEvent,bd as validateProps,r5 as validateRuntimeContext,j5 as validateStoredValue,HO as validateStrategy,Md as widgetRegistry};
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),Ot(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=i+1)}return t>e&&(s+=n.substring(e,n.length)),s},iT=!!Af||!!kf,n0="text/plain",Oc=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=$1(o);return l&&a.push(l),i+"?"+a.join("&")},ta=(n,e)=>JSON.stringify(n,((t,r)=>typeof r=="bigint"?r.toString():r),e),_f=n=>{var{data:e,compression:t}=n;if(e){if(t===Cn.GZipJS){var r=nT((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 gw(p,0,f)})(ta(e)),{mtime:0}),i=new Blob([r],{type:n0});return{contentType:n0,body:i,estimatedSize:i.size}}if(t===Cn.Base64){var s=(function(l){var c,u,p,f,h,g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,m=0,y="",w=[];if(!l)return l;l=rT(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})(ta(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:ta(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=ta(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},mc=[];kf&&mc.push({transport:"fetch",method:n=>{var e,t,{contentType:r,body:i,estimatedSize:s}=(e=_f(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(xb){var c=new xb;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),n.timeout)}}kf(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))}}),Af&&mc.push({transport:"XHR",method:n=>{var e,t=new Af;t.open(n.method||"GET",n.url,!0);var{contentType:r,body:i}=(e=_f(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)}}),ft!=null&&ft.sendBeacon&&mc.push({transport:"sendBeacon",method:n=>{var e=Oc(n.url,{beacon:"1"});try{var t,{contentType:r,body:i}=(t=_f(n))!==null&&t!==void 0?t:{},s=typeof i=="string"?new Blob([i],{type:r}):i;ft.sendBeacon(e,s)}catch{}}});var Mc=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 r0(n,e,t){return ta({distinct_id:n,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var mw={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=>Mc(t,r))))),not_regex:(n,e)=>e.every((t=>n.every((r=>!Mc(t,r))))),icontains:(n,e)=>e.map(hc).some((t=>n.map(hc).some((r=>t.includes(r))))),not_icontains:(n,e)=>e.map(hc).every((t=>n.map(hc).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)))}))},hc=n=>n.toLowerCase();function vw(n,e){return!n||Object.entries(n).every((t=>{var[r,i]=t,s=e?.[r];if(H(s)||Ot(s))return!1;var o=[String(s)],a=mw[i.operator];return!!a&&a(i.values,o)}))}var bf=$e("[Error tracking]"),mh=class{constructor(e){var t,r;this.Zt=[],this.ti=new Lf([new Ff,new Wf,new Hf,new Df,new Uf,new Vf,new Bf,new jf],f1()),this._instance=e,this.Zt=(t=(r=this._instance.persistence)==null?void 0:r.get_property(qf))!==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({[qf]:this.Zt,[Lb]:o})}get ii(){var e,t=!!this._instance.get_property(Lb),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 bf.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void bf.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void bf.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 Be(s)&&s.length>0&&r.$exception_types.push(s),Be(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=mw[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)}},pt=$e("[FeatureFlags]"),qo=$e("[FeatureFlags]",{debugEnabled:!0}),wf="$active_feature_flags",Zi="$override_feature_flags",i0="$feature_flag_payloads",Zo="$override_feature_flag_payloads",s0="$feature_flag_request_id",o0="$feature_flag_evaluated_at",a0=n=>{var e={};for(var[t,r]of gc(n||{}))r&&(e[t]=r);return e},sT=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]})))):pt.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),n},oT=(function(n){return n.FeatureFlags="feature_flags",n.Recordings="recordings",n})({}),vh=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||(pt.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||pt.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(Zf),t=this._instance.get_property(Zi),r=this._instance.get_property(Zo);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||(pt.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.oi=!0),i}getFlagVariants(){var e=this._instance.get_property(Qi),t=this._instance.get_property(Zi);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||(pt.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:r}),this.oi=!0),r}getFlagPayloads(){var e=this._instance.get_property(i0),t=this._instance.get_property(Zo);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||(pt.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(ea)||{}),group_properties:this._instance.get_property(ni)};Ot(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=dw()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:s,compression:this._instance.config.disable_compression?void 0:Cn.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(oT.FeatureFlags))pt.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}pt.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(s0)||void 0,c=this._instance.get_property(o0)||void 0,u=this._instance.get_property(wc)||{};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({[wc]: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 pt.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:Cn.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}pt.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=sT(o),f=p.flags,h=p.featureFlags,g=p.featureFlagPayloads;if(h){var v=o.requestId,m=o.evaluatedAt;if(_e(h)){pt.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({[wf]:h,[Qi]: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({[wf]:Object.keys(a0(x)),[Qi]:x||{},[i0]:_||{},[Zf]:k||{}},v?{[s0]:v}:{},m?{[o0]:m}:{}))}}})(e,this._instance.persistence,r,i,s),this.wi(t)}}override(e,t){t===void 0&&(t=!1),pt.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return pt.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(Zi),this._instance.persistence.unregister(Zo),this.wi(),qo.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(Zi),qo.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({[Zi]:i})}else this._instance.persistence.register({[Zi]:r.flags});qo.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(Zo),qo.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[Zo]:r.payloads}),qo.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(Qo)||[]).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({[wf]:Object.keys(a0(l)),[Qi]:l}),this.wi()}getEarlyAccessFeatures(e,t,r){t===void 0&&(t=!1);var i=this._instance.get_property(Qo),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(Qo),(l=this._instance.persistence)==null||l.register({[Qo]: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(ea)||{};this._instance.register({[ea]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(ea)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var r=this._instance.get_property(ni)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=W({},r[i],e[i]),delete e[i]})),this._instance.register({[ni]:W({},r,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(ni)||{};this._instance.register({[ni]:W({},t,{[e]:{}})})}else this._instance.unregister(ni)}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}},aT=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],sa=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){aT.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=[...D1,...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"?H1:r==="cookie"?Yt:t.H()?t:Yt}properties(){var e={};return xe(this.props,(function(t,r){if(r===Qi&&He(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,(Ot(o=w1)?l:wb&&o.indexOf===wb?o.indexOf(a)!=-1:(xe(o,(function(c){if(l||(l=c===a))return _c})),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(He(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(He(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=sw(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);Xi(jh(e))||this.register(e),this.Ei=!0}}update_search_keyword(){var e;this.register((e=D?.referrer)?aw(e):{})}update_referrer_info(){var e;this.register_once({$referrer:lw(),$referring_domain:D!=null&&D.referrer&&((e=kc(D.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Jf]||this.props[Xf]||this.register_once({[xc]:cw(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};xe([Xf,Jf],(o=>{var a=this.props[o];a&&xe(a,(function(l,c){e["$initial_"+Tf(c)]=l}))}));var t,r,i=this.props[xc];if(i){var s=(t=uw(i),r={},xe(t,(function(o,a){r["$initial_"+Tf(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[Xo]||{};r[e]=t,this.props[Xo]=r,this.save()}remove_event_timer(e){var t=(this.props[Xo]||{})[e];return H(t)||(delete this.props[Xo][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},l0=$e("[Product Tours]"),xf="ph_product_tours",yh=class{constructor(e){this.Ri=null,this.Fi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Fb]:!(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(Fb)||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?l0.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[xf];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 l0.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({[xf]: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(xf)}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)}},Go=(function(n){return n.Activation="events",n.Cancellation="cancelEvents",n})({}),aD=(function(n){return n.Button="button",n.Tab="tab",n.Selector="selector",n})({}),lD=(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})({}),cD=(function(n){return n.Top="top",n.Left="left",n.Right="right",n.Bottom="bottom",n})({}),Sf=(function(n){return n.Popover="popover",n.API="api",n.Widget="widget",n.ExternalSurvey="external_survey",n})({}),uD=(function(n){return n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link",n})({}),dD=(function(n){return n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question",n})({}),pD=(function(n){return n.Once="once",n.Recurring="recurring",n.Always="always",n})({}),na=(function(n){return n.SHOWN="survey shown",n.DISMISSED="survey dismissed",n.SENT="survey sent",n.ABANDONED="survey abandoned",n})({}),Ef=(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})({}),_h=(function(n){return n.Popover="popover",n.Inline="inline",n})({}),we=$e("[Surveys]"),yw="seenSurvey_",lT=(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},c0=n=>((e,t)=>{var r=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(r=""+e+t.id+"_"+t.current_iteration),r})(yw,n),cT=[Sf.Popover,Sf.Widget,Sf.API],uT={ignoreConditions:!1,ignoreDelay:!1,displayType:_h.Popover},pa=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 Gi(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 bh=class{constructor(e){this.Ai=new pa,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"||!Gi(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=>Gi(a.href,t.href,t.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&Gi((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=>Gi(c.text,t.text,t.text_matching||"exact")||Gi(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=>Gi(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||vw(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)}},wh=class{constructor(e){this._instance=e,this.Ki=new Map,this.Yi=new Map,this.Xi=new Map}Qi(e,t){return!!e&&vw(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===Go.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 bh(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,Go.Activation),this.Yi=this.Zi(e,Go.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,Go.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,Go.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}},xh=class extends wh{constructor(e){super(e)}oe(){return"$surveys_activated"}ae(){return na.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()}},Sh=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(yw)||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 xh(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(Gf);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({[Gf]: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(cT.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!==_h.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!==_h.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()}},wn=$e("[Conversations]"),Eh=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)||(An(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 wn.error("Conversations enabled but missing token in remote config.")}}$e(e){if(this.Ee)try{this._conversationsManager=e(this.Ee,this._instance),wn.info("Conversations loaded successfully")}catch(t){this.Se("Error completing conversations initialization",t)}else wn.error("Cannot complete initialization: remote config is null")}Se(e,t){wn.error(e,t),this._conversationsManager=null,this.xe=!1}show(){this._conversationsManager?this._conversationsManager.show():wn.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.we===!0&&!Ot(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 Ji((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(e,t,r):(wn.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var r=this;return Ji((function*(){return r._conversationsManager?r._conversationsManager.getMessages(e,t):(wn.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return Ji((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(wn.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return Ji((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(wn.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}},Ch=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=$e("[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.")}}},u0=$e("[RateLimiter]"),kh=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=>{u0.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4}))}catch(i){return void u0.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(Yf))!==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(Yf,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},ti=$e("[RemoteConfig]"),Ah=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))):(ti.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 ti.info("Using preloaded remote config",this.remoteConfig),void this.yi(this.remoteConfig);if(this._instance.M())return void ti.warn("Remote config is disabled. Falling back to local config.");this.Te((e=>{if(!e)return ti.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){ti.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()):ti.info("__preview_remote_config is disabled. Logging config instead",e):ti.error("Failed to fetch remote config from PostHog.")}},Th=3e3,Rh=class{constructor(e,t){this.Ce=!0,this.Re=[],this.Fe=Jt(t?.flush_interval_ms||Th,250,5e3,V.createLogger("flush interval"),Th),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}},dT=["retriesPerformedSoFar"],Ih=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=m0(e,dT);Ki(t)&&(r.url=Oc(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=[]}},$h=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}},pT=n=>cw(n?.config.mask_personal_data_properties,n?.config.custom_personal_data_properties),Lc=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({[Kf]:a})}},this._instance=e,this.Qe=t,this.Xe=r,this.Ye=i||pT,this.Qe.onSessionId(this.Je)}Ke(){return this.Xe.props[Kf]}getSetOnceProps(){var e,t=(e=this.Ke())==null?void 0:e.props;return t?"r"in t?uw(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(jh(this.getSetOnceProps()),((t,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+Tf(r)]=t})),e}},Cf=$e("[SessionId]"),Nc=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 pa,this.er=(u,p)=>!(!Ki(u)||!Ki(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,Cf.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){Cf.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({[bc]:[t,e,r]}))}_r(){var e=this.Xe.props[bc];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=Ki(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(),Cf.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=Ki(i)&&e&&!l?i:r,h=Ki(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)}},fT=["$set_once","$set"],ar=$e("[SiteApps]"),Ph=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({},m0(e,fT),{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.')}},_w=function(n,e){if(!n)return!1;var t=n.userAgent;if(t&&Eb(t,e))return!0;try{var r=n?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>Eb(i?.brand,e))))return!0}catch{}return!!n.webdriver},ra=(function(n){return n.US="us",n.EU="eu",n.CUSTOM="custom",n})({}),d0="i.posthog.com",Oh=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("."+d0,".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]=ra.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.Sr[this.apiHost]=ra.EU:this.Sr[this.apiHost]=ra.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===ra.CUSTOM)return this.apiHost+t;var r=d0+t;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},hT={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&&Mc(e.href,n),not_regex:(n,e)=>!!S&&!Mc(e.href,n),exact:(n,e)=>e.href===n,is_not:(n,e)=>e.href!==n},Mh=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);Be(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=Ac(e?.search,"__experiment_id"),r=Ac(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||hT[(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=sw();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 ft&&this._instance?_w(ft,this._instance.config.custom_blocked_useragents):void 0}},gT=$e("[PostHog ExternalIntegrations]"),mT={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Lh=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 gT.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(mT[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)}}},Nh="[SessionRecording]",Ko=$e(Nh),Fc=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 Ko.error("started without valid sessionManager"),new Error(Nh+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Nh+' cannot be used with cookieless_mode="always"')}get Ar(){var e,t=!((e=this._instance.get_property(pf))==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),Ko.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 Ko.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(U0)}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({[pf]: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:Ko.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):Ko.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(pf);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))}},oa={},Fh=()=>{},Yi="posthog",bw=!iT&&ct?.indexOf("MSIE")===-1&&ct?.indexOf("Mozilla")===-1,p0=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:b1(D?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Fh,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&&Be(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:Th},error_tracking:{},_onCapture:Fh,__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))},f0=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},Dh=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}},Dc=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 Dh,this.Br=!1,this.version=xn.LIB_VERSION,this.qr=new pa,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=p0(),this.SentryIntegration=ah,this.sentryIntegration=e=>(function(t,r){var i=iw(t,r);return{name:rw,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 vh(this),this.toolbar=new lh(this),this.scrollManager=new $h(this),this.pageViewManager=new Ic(this),this.surveys=new Sh(this),this.conversations=new Eh(this),this.logs=new Ch(this),this.experiments=new Mh(this),this.exceptions=new mh(this),this.rateLimiter=new kh(this),this.requestRouter=new Oh(this),this.consent=new ih(this),this.externalIntegrations=new Lh(this),this.people={set:(e,t,r)=>{var i=Be(e)?{[e]:t}:e;this.setPersonProperties(i),r?.({})},set_once:(e,t,r)=>{var i=Be(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!==Yi){var i,s=(i=oa[r])!==null&&i!==void 0?i:new n;return s._init(e,t,r),oa[r]=s,oa[Yi][r]=s,s}return this._init(e,t,r)}_init(e,t,r){var i;if(t===void 0&&(t={}),H(e)||Rf(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({},p0(t.defaults),f0(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:Cn.GZipJS;var s=this.Qr();this.persistence=new sa(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new sa(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 Rh((w=>this.ts(w)),this.config.request_queue_config),this.es=new Ih(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 Nc(this),this.sessionPropsManager=new Lc(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)),xn.DEBUG=xn.DEBUG||this.config.debug,xn.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(Sn,(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:Vo,$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(Sn,"anonymous")}return Fe(S,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?U1(this,(()=>this.ns())):this.ns(),ur(this.config._onCapture)&&this.config._onCapture!==Fh&&(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 oh(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new ch(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new Ph(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new Fc(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new eh(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.logs.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new yh(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new dh(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new uh(this)})),r.push((()=>{this.exceptionObserver=new sh(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new Rc(this,V1),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,Cn.GZipJS)?Cn.GZipJS:me(e.supportedCompression,Cn.Base64)?Cn.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 Ah(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&&(bw?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Oc(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=Oc(o.url,{_:new Date().getTime().toString(),ver:xn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=mc.filter((u=>!o.disableTransport||!u.transport||!o.disableTransport.includes(u.transport))),c=(i=(s=H0(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)&&Be(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&&!Be(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=y1(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===na.DISMISSED||e===na.SENT){var g=t?.[Ef.SURVEY_ID],v=t?.[Ef.SURVEY_ITERATION];p={id:g,current_iteration:v},localStorage.getItem(c0(p))||localStorage.setItem(c0(p),"true"),u.$set=W({},u.$set,{[lT({id:g,current_iteration:v},e===na.SENT?"responded":"dismissed")]:!0})}else e===na.SHOWN&&(u.$set=W({},u.$set,{[Ef.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var m=W({},u.properties.$set,u.$set);if(Xi(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,(!Be(a.distinct_id)&&!Tn(a.distinct_id)||Rf(a.distinct_id))&&V.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=G1(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===ra.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),Xi(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=uT),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(Tn(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!==Vo){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(Jo)&&(this.unregister(Jo),this.register({distinct_id:e}));var o=(this.persistence.get_property(Sn)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(Sn,"identified"),this.setPersonPropertiesForFlags(W({},r||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:t||{},$set_once:r||{}}),this.Jr=r0(e,t,r),this.featureFlags.setAnonymousDistinctId(i)):(t||r)&&this.setPersonProperties(t,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(wc))}}else V.critical('The string "'+Vo+'" 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=r0(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(Sn,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Vo,$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(B0)?(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(Jo,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(He(e)){var r,i,s,o,a,l,c;Me(this.config,f0(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 sa(W({},this.config,{persistence:"sessionStorage"}),u);var p=this.Kr(this.config.debug);An(p)&&(this.config.debug=p),An(this.config.debug)&&(this.config.debug?(xn.DEBUG=!0,Te.H()&&Te.G("ph_debug","true"),V.info("set_config",{config:e,oldConfig:t,newConfig:W({},this.config)})):(xn.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:Yi;return t!==Yi&&(t=Yi+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(Sn))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(Sn))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Xi(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Jo])&&((t=this.persistence)==null||(t=t.props)==null||!t[Sc]))}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(Sc,!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 Nc(this),this.pageViewManager=new Ic(this),this.persistence&&(this.sessionPropsManager=new Lc(this,this.sessionManager,this.persistence)),this.sessionRecording=new Fc(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:Vo,$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===En.GRANTED?"granted":e===En.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 ft?_w(ft,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 zA(e.event)?V.warn(s+". This can cause unexpected behavior."):V.info(s),null}r.properties&&!Xi(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=An(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]]=v1(n.prototype[e[t]])})(Dc,["identify"]);var h0;var ww=(h0=oa[Yi]=new Dc,(function(){function n(){n.done||(n.done=!0,bw=!1,xe(oa,(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")})(),h0);var Kh=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=ww.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 Yh(n={}){return new Kh(n)}var xw={posthog:n=>Yh(n),noop:()=>lf()};function Sw(n,e){let t=xw[n];if(!t)throw new Error(`Unknown telemetry provider: ${n}. Supported: ${Object.keys(xw).join(", ")}`);return t(e)}function vT(n){return n?.manifest?.runtime!==void 0}async function Ew(n){Dd(),q("Syntro Bootstrap","====== INIT ======"),q("Syntro Bootstrap","Options:",{hasToken:!!n.token,tokenPrefix:`${n.token?.slice(0,15)}...`,hasCanvasOptions:!!n.canvas});let e=Hl();if(console.log(`[DIAG] Mode detection: sdkMode=${e}`),console.log("[DIAG] editorSource:",xo()),console.log("[DIAG] editorConf:",Dl()),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=Dl()?.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=So(t),Dd(r.d);else if(e)q("Syntro Bootstrap",`\u2713 Non-syn_ token allowed (${e} mode)`);else throw wl("Syntro Bootstrap","\u274C Token does not start with syn_ and NOT in editor/audit/review mode!"),wl("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 wl("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=Hd({resource:{serviceName:"syntro-runtime-sdk",serviceVersion:ao,posthogKey:r.t??"",hostOrigin:typeof window<"u"?window.location.origin:""},emit:Vd({endpoint:R})}),B=jd()??"https://cdn.syntrologie.com/runtime-sdk/",fe=rp(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")||a_,l=e_(),c=Ep(),u=n.appSignalsInit??{},p=s_(),f=Cp(c,p);o_(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=kp(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=Js({debug:n.debug,history:y?new Co(n.testMode?0:100):void 0,testMode:n.testMode});console.log("[Syntro Bootstrap] EventBus created");let x=Du({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{ob(w),ab(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 _=ub(),k,I=R=>{q("Syntro Bootstrap","Phase 2: PostHog feature flags loaded");let Y=r_(R);if(q("Syntro Bootstrap","Segment flags from PostHog:",Y),t_(Y),m){let B=A?.getAll?.()??{},fe=Di(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=Sw(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=()=>Di(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 Ho({initialStatus:"pending",pendingResolver:fe,onConsentChange:se=>{n_(se),se==="granted"?B.optInCapturing?.():se==="denied"&&B.optOutCapturing?.()}});try{B.track?.("syntro_bootstrap_step",{stage:"consent_gate_constructed"})}catch{}try{g_(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 Do({adapters:[new Fo,new No,new Lo],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=c_({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=tb("growthbook",{clientKey:r.e,apiHost:i,attributes:{...h,id:Di(b?.getDistinctId?.())},onExperimentViewed:b?.trackExperiment?(R,Y,B)=>{b.trackExperiment(R,Y,B)}:void 0})),A=tf({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=Nd({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 vb({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 mb({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")||nl()||"https://cdn.syntrologie.com",pe=lu({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"&&vT(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:Di(b?.getDistinctId?.())};q("Syntro Bootstrap","Merging geo data into GrowthBook attributes:",X),m.setAttributes?.(R)}let Pe=await v;Pe&&m&&(c.surface_type="mcp-app",c.surface_host=Pe.name,m.setAttributes?.({...c,...f,...X,id:Di(b?.getDistinctId?.())}),U.context.setSurfaceType("mcp-app"),U.context.setSurfaceHost(Pe.name),q("Syntro Bootstrap","MCP App detected:",Pe.name));let Ye;if(n.fetcher)Ye=n.fetcher;else if(r?.f){let R=sb(r.f,r.o??{});Ye=async()=>{let Y=await R.fetch();return{...Y.config,tiles:Y.config.tiles??[]}}}else m&&(Ye=Ai({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&&Ua({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 Rn=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(Tw){console.warn("[Syntro] interventionTracker nav unsub threw:",Tw)}Xt=new Bo(b,fe),se&&(se.interventionTracker=Xt);let ls=U.navigation.subscribe(()=>{Xt.resetPage()});se&&(se.interventionTrackerUnsub=ls)}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 Mt=await mp({...n.canvas,fetcher:Rn,integrations:{experiments:m,telemetry:b},editorUrl:o,runtime:U}),as=jt();if(as!==null)try{let R=b,Y=U;as.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 as?.increment("bootstrap_ok"),{canvas:Mt,runtime:U,experiments:m,telemetry:b,sessionMetrics:A,appLoader:pe}}async function yT(n){try{return await Ew(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 _T(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 bT(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 Cw={init:yT,loadAdaptive:bT,encodeToken:yp,decodeToken:So,events:{emit:_T}};typeof window<"u"&&(window.Syntro=Cw);function ma(n){let e=n.split(".");return{major:parseInt(e[0]||"0",10),minor:parseInt(e[1]||"0",10)}}function QD(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=ma(i),o=ma(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:wT(r,i)}):{valid:!0,warnings:e,errors:t}}function wT(n,e){let t={...n};return ma(e).major===1&&(t=xT(t)),t.schemaVersion=Vn,t}function xT(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 e5(n){if(!n||typeof n!="object")return!1;let e=n,t=e.schemaVersion||"1.0",r=ma(t),i=ma(Vn);return r.major<i.major||!e.schemaVersion}var ST=d.object({url:d.string(),routeId:d.string().optional(),title:d.string().optional(),locale:d.string().optional()}),ET=d.object({url:d.string(),ts:d.number()}),CT=d.object({sessionId:d.string(),startTs:d.number(),pageHistory:d.array(ET).optional()}),kT=d.object({width:d.number(),height:d.number()}),AT=d.object({x:d.number(),y:d.number(),w:d.number(),h:d.number()}),TT=d.object({anchorId:d.string(),present:d.boolean(),visible:d.boolean().optional(),boundingBox:AT.optional()}),RT=d.record(d.string(),d.union([d.number(),d.string(),d.boolean(),d.undefined()])),IT=d.object({page:ST,session:CT,viewport:kT,anchors:d.array(TT).optional(),augmented:RT.optional()});function r5(n){return IT.safeParse(n)}var Jh=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 Xh=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 Qh=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 kw=d.enum(["posthog","canvas","derived"]),$T=d.object({ts:d.number(),name:d.string(),source:kw,props:d.record(d.string(),d.unknown()).optional(),schemaVersion:d.string()}),PT=d.object({names:d.array(d.string()).optional(),patterns:d.array(d.string()).optional(),sources:d.array(kw).optional()});function A5(n){return $T.safeParse(n)}function T5(n){return PT.safeParse(n)}var OT=d.object({value:d.unknown(),expiresAt:d.number().optional()}),MT=d.object({count:d.number(),resetAt:d.number().optional()});function j5(n){return OT.safeParse(n)}function W5(n){return MT.safeParse(n)}var Aw="2026-07-24T19:21:30.096Z (1235b1302)";if(typeof window<"u"){console.log(`[Syntro Runtime] Build: ${Aw} (Lit)`);let n=window.SynOS,e=n?.appRegistry||Ps;window.SynOS={...n,appRegistry:e,_runtimeBuild:Aw,_renderer:"lit"},Ll(),ym(e)}export{no as ANIMATION_KEYFRAMES,al as ActivationConfigZ,yv as AddClassZ,bt as AnchorIdZ,TT as AnchorStateZ,_u as AnchorVisibleConditionZ,$s as AppRegistry,RT as AugmentationZ,av as BadgePositionZ,Ev as BadgeZ,AT as BoundingBoxZ,Ks as CanvasEvents,Dn as ConditionZ,ll as ContextManager,Cu as CooldownActiveConditionZ,Ds as CounterDefZ,pd as CtaButtonZ,Hu as DEFAULT_COOLDOWN,Jh as DecisionController,Ws as DecisionStrategyZ,Eu as DismissedConditionZ,Oe as EVENT_SCHEMA_VERSION,pl as EventBus,Au as EventCountConditionZ,PT as EventFilterZ,Co as EventHistory,bu as EventOccurredConditionZ,kw as EventSourceZ,rl as ExecutorRegistry,js as ExternalStrategyZ,MT as FrequencyEntryZ,ku as FrequencyLimitConditionZ,ov as HighlightStyleZ,xv as HighlightZ,wv as InsertHtmlZ,dv as InsertPositionZ,Bo as InterventionTracker,Xa as MAX_VISIBLE_TOASTS,du as MOUNT_PLUMBING_KEYS,Fs as MatchOpZ,uv as ModalContentZ,kv as ModalZ,Us as ModelStrategyZ,Rv as MountWidgetZ,Tv as NavigateZ,Xs as NavigationMonitor,$T as NormalizedEventZ,Gs as NotificationsController,ST as PageContextZ,ET as PageHistoryEntryZ,vu as PageUrlConditionZ,Pv as ParallelZ,lv as PlacementZ,Sv as PulseZ,Aw as RUNTIME_SDK_BUILD,ml as RUNTIME_VERSION,_v as RemoveClassZ,yu as RouteConditionZ,ev as RouteFilterZ,Bs as RuleStrategyZ,Hs as RuleZ,IT as RuntimeContextZ,Xh as RuntimeController,Qh as RuntimeEventsController,Vn as SDK_SCHEMA_VERSION,ao as SDK_VERSION,Gv as STATIC_SLOT_STYLES,Vs as ScoreStrategyZ,gv as ScrollBehaviorZ,dd as ScrollLogicalPositionZ,Av as ScrollToZ,$v as SequenceZ,CT as SessionContextZ,Su as SessionMetricConditionZ,ac as SessionMetricTracker,vv as SetAttrZ,bv as SetStyleZ,mv as SetTextZ,ip as SmartCanvasController,Ri as SmartCanvasElementLit,Ve as StandardEvents,wu as StateEqualsConditionZ,fl as StateStore,OT as StoredValueZ,Cw as Syntro,fo as ThemeController,cv as TooltipContentZ,pv as TooltipTriggerZ,Cv as TooltipZ,hv as TourStepForSchemaZ,Ov as TourZ,Va as TriggerWhenZ,xu as ViewportConditionZ,kT as ViewportContextZ,Iv as WaitZ,fv as WidgetConfigZ,gl as WidgetRegistry,kd as applyStaticSlotStyles,eC as coreActionStepSchemas,ld as createActionEngine,fd as createAnchorResolver,Ai as createCanvasConfigFetcher,md as createContextManager,vd as createDecisionEngine,yd as createEventAccumulator,Js as createEventBus,Xp as createGrowthBookClient,lf as createNoopClient,Yh as createPostHogClient,Ym as createPostHogNormalizer,tf as createSessionMetricTracker,mp as createSmartCanvas,Sy as createSmartCanvasController,Nd as createSmartCanvasRuntime,Cd as createStateStore,$d as createSurfaceContainer,Od as createSurfaces,VO as decisionSchemas,So as decodeToken,yp as encodeToken,Hv as evaluate,Nv as evaluateCondition,Fv as evaluateRule,cl as evaluateRuleStrategy,ul as evaluateScoreStrategy,Bv as evaluateSync,Bn as executorRegistry,ZC as getAntiFlickerSnippet,hl as getSlotAnchorId,to as getSlotType,Pd as getSlotZIndex,qu as hasExecutor,e5 as needsMigration,qs as normalizePostHogEvent,ma as parseVersion,Rd as playEnterAnimation,Id as playExitAnimation,Ti as registerConfigPredicates,Ll as registerSmartCanvasElement,IC as resolveConfigUri,FC as runtimeContext,Ad as setupAdjacentPositioning,Td as setupInlinePositioning,Zs as shouldNormalizeEvent,bm as stripMountPlumbing,Vt as validateAction,ol as validateActions,BO as validateActivationConfig,DO as validateCondition,QD as validateConfig,T5 as validateEventFilter,_d as validateEventName,W5 as validateFrequencyEntry,A5 as validateNormalizedEvent,bd as validateProps,r5 as validateRuntimeContext,j5 as validateStoredValue,HO as validateStrategy,Md as widgetRegistry};
627
627
  /*! Bundled license information:
628
628
 
629
629
  @lit/reactive-element/css-tag.js: