@syntrologie/runtime-sdk 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/smart-canvas.esm.js +1 -1
- package/dist/smart-canvas.esm.js.map +3 -3
- package/dist/smart-canvas.js +41 -41
- package/dist/smart-canvas.js.map +2 -2
- package/dist/smart-canvas.min.js +1 -1
- package/dist/smart-canvas.min.js.map +3 -3
- package/dist/telemetry/adapters/posthog.d.ts +1 -1
- package/dist/telemetry/adapters/posthog.js +1 -1
- package/dist/telemetry/adapters/posthog.js.map +1 -1
- package/package.json +1 -1
package/dist/smart-canvas.esm.js
CHANGED
|
@@ -133,7 +133,7 @@ Error generating stack: `+s.message+`
|
|
|
133
133
|
`,e=document.createElement("style");e.setAttribute("data-syntro","base-overlay"),e.textContent=t,document.head.appendChild(e),n1=!0}var ya,n1,i1=xt(()=>{ya=null;n1=!1});function nc(t,e,n){return Dn(t,Or(e,n))}function Ei(t,e){return typeof t=="function"?t(e):t}function Nr(t){return t.split("-")[0]}function Ls(t){return t.split("-")[1]}function eg(t){return t==="x"?"y":"x"}function rc(t){return t==="y"?"height":"width"}function Vn(t){return cP.has(Nr(t))?"y":"x"}function ic(t){return eg(Vn(t))}function l1(t,e,n){n===void 0&&(n=!1);let r=Ls(t),i=ic(t),s=rc(i),o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=_a(o)),[o,_a(o)]}function u1(t){let e=_a(t);return[tc(t),e,tc(e)]}function tc(t){return t.replace(/start|end/g,e=>uP[e])}function pP(t,e,n){switch(t){case"top":case"bottom":return n?e?o1:s1:e?s1:o1;case"left":case"right":return e?dP:fP;default:return[]}}function c1(t,e,n,r){let i=Ls(t),s=pP(Nr(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(tc)))),s}function _a(t){return t.replace(/left|right|bottom|top/g,e=>lP[e])}function hP(t){return{top:0,right:0,bottom:0,left:0,...t}}function tg(t){return typeof t!="number"?hP(t):{top:t,right:t,bottom:t,left:t}}function Si(t){let{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}var a1,Or,Dn,wa,ka,Zt,lP,uP,cP,s1,o1,dP,fP,sc=xt(()=>{a1=["top","right","bottom","left"],Or=Math.min,Dn=Math.max,wa=Math.round,ka=Math.floor,Zt=t=>({x:t,y:t}),lP={left:"right",right:"left",bottom:"top",top:"bottom"},uP={start:"end",end:"start"};cP=new Set(["top","bottom"]);s1=["left","right"],o1=["right","left"],dP=["top","bottom"],fP=["bottom","top"]});function d1(t,e,n){let{reference:r,floating:i}=t,s=Vn(e),o=ic(e),a=rc(o),l=Nr(e),u=s==="y",c=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[a]/2-i[a]/2,g;switch(l){case"top":g={x:c,y:r.y-i.height};break;case"bottom":g={x:c,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:d};break;case"left":g={x:r.x-i.width,y:d};break;default:g={x:r.x,y:r.y}}switch(Ls(e)){case"start":g[o]-=f*(n&&u?-1:1);break;case"end":g[o]+=f*(n&&u?-1:1);break}return g}async function xa(t,e){var n;e===void 0&&(e={});let{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=t,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:g=0}=Ei(e,t),v=tg(g),k=a[f?d==="floating"?"reference":"floating":d],h=Si(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(k)))==null||n?k:k.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:u,rootBoundary:c,strategy:l})),p=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,m=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),_=await(s.isElement==null?void 0:s.isElement(m))?await(s.getScale==null?void 0:s.getScale(m))||{x:1,y:1}:{x:1,y:1},w=Si(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:p,offsetParent:m,strategy:l}):p);return{top:(h.top-w.top+v.top)/_.y,bottom:(w.bottom-h.bottom+v.bottom)/_.y,left:(h.left-w.left+v.left)/_.x,right:(w.right-h.right+v.right)/_.x}}function f1(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function p1(t){return a1.some(e=>t[e]>=0)}async function mP(t,e){let{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Nr(n),a=Ls(n),l=Vn(n)==="y",u=gP.has(o)?-1:1,c=s&&l?-1:1,d=Ei(e,t),{mainAxis:f,crossAxis:g,alignmentAxis:v}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof v=="number"&&(g=a==="end"?v*-1:v),l?{x:g*c,y:f*u}:{x:f*u,y:g*c}}var h1,g1,m1,v1,gP,y1,_1,w1=xt(()=>{sc();sc();h1=async(t,e,n)=>{let{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e)),u=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:c,y:d}=d1(u,r,l),f=r,g={},v=0;for(let y=0;y<a.length;y++){let{name:k,fn:h}=a[y],{x:p,y:m,data:_,reset:w}=await h({x:c,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:g,rects:u,platform:o,elements:{reference:t,floating:e}});c=p??c,d=m??d,g={...g,[k]:{...g[k],..._}},w&&v<=50&&(v++,typeof w=="object"&&(w.placement&&(f=w.placement),w.rects&&(u=w.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):w.rects),{x:c,y:d}=d1(u,f,l)),y=-1)}return{x:c,y:d,placement:f,strategy:i,middlewareData:g}};g1=t=>({name:"arrow",options:t,async fn(e){let{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=e,{element:u,padding:c=0}=Ei(t,e)||{};if(u==null)return{};let d=tg(c),f={x:n,y:r},g=ic(i),v=rc(g),y=await o.getDimensions(u),k=g==="y",h=k?"top":"left",p=k?"bottom":"right",m=k?"clientHeight":"clientWidth",_=s.reference[v]+s.reference[g]-f[g]-s.floating[v],w=f[g]-s.reference[g],b=await(o.getOffsetParent==null?void 0:o.getOffsetParent(u)),S=b?b[m]:0;(!S||!await(o.isElement==null?void 0:o.isElement(b)))&&(S=a.floating[m]||s.floating[v]);let E=_/2-w/2,j=S/2-y[v]/2-1,F=Or(d[h],j),Y=Or(d[p],j),te=F,K=S-y[v]-Y,Q=S/2-y[v]/2+E,ke=nc(te,Q,K),Oe=!l.arrow&&Ls(i)!=null&&Q!==ke&&s.reference[v]/2-(Q<te?F:Y)-y[v]/2<0,xe=Oe?Q<te?Q-te:Q-K:0;return{[g]:f[g]+xe,data:{[g]:ke,centerOffset:Q-ke-xe,...Oe&&{alignmentOffset:xe}},reset:Oe}}}),m1=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;let{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:u}=e,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:y=!0,...k}=Ei(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};let h=Nr(i),p=Vn(a),m=Nr(a)===a,_=await(l.isRTL==null?void 0:l.isRTL(u.floating)),w=f||(m||!y?[_a(a)]:u1(a)),b=v!=="none";!f&&b&&w.push(...c1(a,y,v,_));let S=[a,...w],E=await xa(e,k),j=[],F=((r=s.flip)==null?void 0:r.overflows)||[];if(c&&j.push(E[h]),d){let Q=l1(i,o,_);j.push(E[Q[0]],E[Q[1]])}if(F=[...F,{placement:i,overflows:j}],!j.every(Q=>Q<=0)){var Y,te;let Q=(((Y=s.flip)==null?void 0:Y.index)||0)+1,ke=S[Q];if(ke&&(!(d==="alignment"?p!==Vn(ke):!1)||F.every(be=>Vn(be.placement)===p?be.overflows[0]>0:!0)))return{data:{index:Q,overflows:F},reset:{placement:ke}};let Oe=(te=F.filter(xe=>xe.overflows[0]<=0).sort((xe,be)=>xe.overflows[1]-be.overflows[1])[0])==null?void 0:te.placement;if(!Oe)switch(g){case"bestFit":{var K;let xe=(K=F.filter(be=>{if(b){let Ce=Vn(be.placement);return Ce===p||Ce==="y"}return!0}).map(be=>[be.placement,be.overflows.filter(Ce=>Ce>0).reduce((Ce,Xt)=>Ce+Xt,0)]).sort((be,Ce)=>be[1]-Ce[1])[0])==null?void 0:K[0];xe&&(Oe=xe);break}case"initialPlacement":Oe=a;break}if(i!==Oe)return{reset:{placement:Oe}}}return{}}}};v1=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){let{rects:n}=e,{strategy:r="referenceHidden",...i}=Ei(t,e);switch(r){case"referenceHidden":{let s=await xa(e,{...i,elementContext:"reference"}),o=f1(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:p1(o)}}}case"escaped":{let s=await xa(e,{...i,altBoundary:!0}),o=f1(s,n.floating);return{data:{escapedOffsets:o,escaped:p1(o)}}}default:return{}}}}},gP=new Set(["left","top"]);y1=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;let{x:i,y:s,placement:o,middlewareData:a}=e,l=await mP(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},_1=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){let{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:k=>{let{x:h,y:p}=k;return{x:h,y:p}}},...l}=Ei(t,e),u={x:n,y:r},c=await xa(e,l),d=Vn(Nr(i)),f=eg(d),g=u[f],v=u[d];if(s){let k=f==="y"?"top":"left",h=f==="y"?"bottom":"right",p=g+c[k],m=g-c[h];g=nc(p,g,m)}if(o){let k=d==="y"?"top":"left",h=d==="y"?"bottom":"right",p=v+c[k],m=v-c[h];v=nc(p,v,m)}let y=a.fn({...e,[f]:g,[d]:v});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[f]:s,[d]:o}}}}}}});function oc(){return typeof window<"u"}function bi(t){return x1(t)?(t.nodeName||"").toLowerCase():"#document"}function dt(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Yt(t){var e;return(e=(x1(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function x1(t){return oc()?t instanceof Node||t instanceof dt(t).Node:!1}function Mt(t){return oc()?t instanceof Element||t instanceof dt(t).Element:!1}function Qt(t){return oc()?t instanceof HTMLElement||t instanceof dt(t).HTMLElement:!1}function k1(t){return!oc()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof dt(t).ShadowRoot}function Ms(t){let{overflow:e,overflowX:n,overflowY:r,display:i}=$t(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!vP.has(i)}function E1(t){return yP.has(bi(t))}function Ea(t){return _P.some(e=>{try{return t.matches(e)}catch{return!1}})}function ac(t){let e=lc(),n=Mt(t)?$t(t):t;return wP.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||kP.some(r=>(n.willChange||"").includes(r))||xP.some(r=>(n.contain||"").includes(r))}function S1(t){let e=jn(t);for(;Qt(e)&&!Ci(e);){if(ac(e))return e;if(Ea(e))return null;e=jn(e)}return null}function lc(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Ci(t){return EP.has(bi(t))}function $t(t){return dt(t).getComputedStyle(t)}function Sa(t){return Mt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function jn(t){if(bi(t)==="html")return t;let e=t.assignedSlot||t.parentNode||k1(t)&&t.host||Yt(t);return k1(e)?e.host:e}function b1(t){let e=jn(t);return Ci(e)?t.ownerDocument?t.ownerDocument.body:t.body:Qt(e)&&Ms(e)?e:b1(e)}function Is(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);let i=b1(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=dt(i);if(s){let a=uc(o);return e.concat(o,o.visualViewport||[],Ms(i)?i:[],a&&n?Is(a):[])}return e.concat(i,Is(i,[],n))}function uc(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}var vP,yP,_P,wP,kP,xP,EP,C1=xt(()=>{vP=new Set(["inline","contents"]);yP=new Set(["table","td","th"]);_P=[":popover-open",":modal"];wP=["transform","translate","scale","rotate","perspective"],kP=["transform","translate","scale","rotate","perspective","filter"],xP=["paint","layout","strict","content"];EP=new Set(["html","body","#document"])});function R1(t){let e=$t(t),n=parseFloat(e.width)||0,r=parseFloat(e.height)||0,i=Qt(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=wa(n)!==s||wa(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function rg(t){return Mt(t)?t:t.contextElement}function $s(t){let e=rg(t);if(!Qt(e))return Zt(1);let n=e.getBoundingClientRect(),{width:r,height:i,$:s}=R1(e),o=(s?wa(n.width):n.width)/r,a=(s?wa(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}function A1(t){let e=dt(t);return!lc()||!e.visualViewport?SP:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function bP(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==dt(t)?!1:e}function Ti(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);let i=t.getBoundingClientRect(),s=rg(t),o=Zt(1);e&&(r?Mt(r)&&(o=$s(r)):o=$s(t));let a=bP(s,n,r)?A1(s):Zt(0),l=(i.left+a.x)/o.x,u=(i.top+a.y)/o.y,c=i.width/o.x,d=i.height/o.y;if(s){let f=dt(s),g=r&&Mt(r)?dt(r):r,v=f,y=uc(v);for(;y&&r&&g!==v;){let k=$s(y),h=y.getBoundingClientRect(),p=$t(y),m=h.left+(y.clientLeft+parseFloat(p.paddingLeft))*k.x,_=h.top+(y.clientTop+parseFloat(p.paddingTop))*k.y;l*=k.x,u*=k.y,c*=k.x,d*=k.y,l+=m,u+=_,v=dt(y),y=uc(v)}}return Si({width:c,height:d,x:l,y:u})}function ig(t,e){let n=Sa(t).scrollLeft;return e?e.left+n:Ti(Yt(t)).left+n}function O1(t,e,n){n===void 0&&(n=!1);let r=t.getBoundingClientRect(),i=r.left+e.scrollLeft-(n?0:ig(t,r)),s=r.top+e.scrollTop;return{x:i,y:s}}function CP(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t,s=i==="fixed",o=Yt(r),a=e?Ea(e.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},u=Zt(1),c=Zt(0),d=Qt(r);if((d||!d&&!s)&&((bi(r)!=="body"||Ms(o))&&(l=Sa(r)),Qt(r))){let g=Ti(r);u=$s(r),c.x=g.x+r.clientLeft,c.y=g.y+r.clientTop}let f=o&&!d&&!s?O1(o,l,!0):Zt(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:n.y*u.y-l.scrollTop*u.y+c.y+f.y}}function TP(t){return Array.from(t.getClientRects())}function PP(t){let e=Yt(t),n=Sa(t),r=t.ownerDocument.body,i=Dn(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Dn(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+ig(t),a=-n.scrollTop;return $t(r).direction==="rtl"&&(o+=Dn(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}function RP(t,e){let n=dt(t),r=Yt(t),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;let u=lc();(!u||u&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a,y:l}}function AP(t,e){let n=Ti(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=Qt(t)?$s(t):Zt(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,l=i*s.x,u=r*s.y;return{width:o,height:a,x:l,y:u}}function T1(t,e,n){let r;if(e==="viewport")r=RP(t,n);else if(e==="document")r=PP(Yt(t));else if(Mt(e))r=AP(e,n);else{let i=A1(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return Si(r)}function N1(t,e){let n=jn(t);return n===e||!Mt(n)||Ci(n)?!1:$t(n).position==="fixed"||N1(n,e)}function OP(t,e){let n=e.get(t);if(n)return n;let r=Is(t,[],!1).filter(a=>Mt(a)&&bi(a)!=="body"),i=null,s=$t(t).position==="fixed",o=s?jn(t):t;for(;Mt(o)&&!Ci(o);){let a=$t(o),l=ac(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||Ms(o)&&!l&&N1(t,o))?r=r.filter(c=>c!==o):i=a,o=jn(o)}return e.set(t,r),r}function NP(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t,o=[...n==="clippingAncestors"?Ea(e)?[]:OP(e,this._c):[].concat(n),r],a=o[0],l=o.reduce((u,c)=>{let d=T1(e,c,i);return u.top=Dn(d.top,u.top),u.right=Or(d.right,u.right),u.bottom=Or(d.bottom,u.bottom),u.left=Dn(d.left,u.left),u},T1(e,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function FP(t){let{width:e,height:n}=R1(t);return{width:e,height:n}}function LP(t,e,n){let r=Qt(e),i=Yt(e),s=n==="fixed",o=Ti(t,!0,s,e),a={scrollLeft:0,scrollTop:0},l=Zt(0);if(r||!r&&!s)if((bi(e)!=="body"||Ms(i))&&(a=Sa(e)),r){let f=Ti(e,!0,s,e);l.x=f.x+e.clientLeft,l.y=f.y+e.clientTop}else i&&(l.x=ig(i));let u=i&&!r&&!s?O1(i,a):Zt(0),c=o.left+a.scrollLeft-l.x-u.x,d=o.top+a.scrollTop-l.y-u.y;return{x:c,y:d,width:o.width,height:o.height}}function ng(t){return $t(t).position==="static"}function P1(t,e){if(!Qt(t)||$t(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Yt(t)===n&&(n=n.ownerDocument.body),n}function F1(t,e){let n=dt(t);if(Ea(t))return n;if(!Qt(t)){let i=jn(t);for(;i&&!Ci(i);){if(Mt(i)&&!ng(i))return i;i=jn(i)}return n}let r=P1(t,e);for(;r&&E1(r)&&ng(r);)r=P1(r,e);return r&&Ci(r)&&ng(r)&&!ac(r)?n:r||S1(t)||n}function MP(t){return $t(t).direction==="rtl"}function L1(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function DP(t,e){let n=null,r,i=Yt(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();let u=t.getBoundingClientRect(),{left:c,top:d,width:f,height:g}=u;if(a||e(),!f||!g)return;let v=ka(d),y=ka(i.clientWidth-(c+f)),k=ka(i.clientHeight-(d+g)),h=ka(c),m={rootMargin:-v+"px "+-y+"px "+-k+"px "+-h+"px",threshold:Dn(0,Or(1,l))||1},_=!0;function w(b){let S=b[0].intersectionRatio;if(S!==l){if(!_)return o();S?o(!1,S):r=setTimeout(()=>{o(!1,1e-7)},1e3)}S===1&&!L1(u,t.getBoundingClientRect())&&o(),_=!1}try{n=new IntersectionObserver(w,{...m,root:i.ownerDocument})}catch{n=new IntersectionObserver(w,m)}n.observe(t)}return o(!0),s}function I1(t,e,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=rg(t),c=i||s?[...u?Is(u):[],...Is(e)]:[];c.forEach(h=>{i&&h.addEventListener("scroll",n,{passive:!0}),s&&h.addEventListener("resize",n)});let d=u&&a?DP(u,n):null,f=-1,g=null;o&&(g=new ResizeObserver(h=>{let[p]=h;p&&p.target===u&&g&&(g.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var m;(m=g)==null||m.observe(e)})),n()}),u&&!l&&g.observe(u),g.observe(e));let v,y=l?Ti(t):null;l&&k();function k(){let h=Ti(t);y&&!L1(y,h)&&n(),y=h,v=requestAnimationFrame(k)}return n(),()=>{var h;c.forEach(p=>{i&&p.removeEventListener("scroll",n),s&&p.removeEventListener("resize",n)}),d?.(),(h=g)==null||h.disconnect(),g=null,l&&cancelAnimationFrame(v)}}var SP,IP,$P,M1,$1,D1,V1,j1,z1,H1=xt(()=>{w1();sc();C1();SP=Zt(0);IP=async function(t){let e=this.getOffsetParent||F1,n=this.getDimensions,r=await n(t.floating);return{reference:LP(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};$P={convertOffsetParentRelativeRectToViewportRelativeRect:CP,getDocumentElement:Yt,getClippingRect:NP,getOffsetParent:F1,getElementRects:IP,getClientRects:TP,getDimensions:FP,getScale:$s,isElement:Mt,isRTL:MP};M1=y1,$1=_1,D1=m1,V1=v1,j1=g1,z1=(t,e,n)=>{let r=new Map,i={platform:$P,...n},s={...i.platform,_c:r};return h1(t,e,{...i,platform:s})}});function cc(t){if(typeof window.Sanitizer=="function")try{let l=new window.Sanitizer({}).sanitizeToFragment(t),u=document.createElement("div");return u.append(l),u.innerHTML}catch{}let n=document.createElement("template");n.innerHTML=t;let r=n.content,i=document.createTreeWalker(r,NodeFilter.SHOW_ELEMENT,null),s=new Set(["b","strong","i","em","u","span","div","p","br","ul","ol","li","code","pre","small","sup","sub","a"]),o=[];for(;i.nextNode();){let a=i.currentNode,l=a.tagName.toLowerCase();if(!s.has(l)){o.push(a);continue}for(let u of Array.from(a.attributes)){let c=u.name.toLowerCase(),d=u.value.trim().toLowerCase(),f=c.startsWith("on"),g=(c==="href"||c==="src")&&d.startsWith("javascript:");(f||g)&&a.removeAttribute(u.name)}}for(let a of o){for(;a.firstChild;)a.parentNode?.insertBefore(a.firstChild,a);a.remove()}return n.innerHTML=(r.firstChild,n.innerHTML)}var sg=xt(()=>{});function dc(t,e,n){let r=document.createElement("div");r.className="syntro-tooltip",r.setAttribute("role","tooltip"),r.innerHTML=cc(n.html);let i=document.createElement("div");i.className="syntro-tooltip-arrow",r.appendChild(i),e.appendChild(r);let s=[M1(n.offsetPx??8),D1(),$1({padding:8}),V1(),j1({element:i})],o=n.placement&&n.placement!=="auto"?n.placement:"top",a=I1(t,r,async()=>{let v=await z1(t,r,{placement:o,middleware:s}),{x:y,y:k,strategy:h,middlewareData:p,placement:m}=v;if(Object.assign(r.style,{left:`${y}px`,top:`${k}px`,position:h}),p.arrow){let{x:_,y:w}=p.arrow,b=m.split("-")[0],S={top:"bottom",right:"left",bottom:"top",left:"right"}[b];Object.assign(i.style,{left:_!=null?`${_}px`:"",top:w!=null?`${w}px`:"",right:"",bottom:"",[S]:"-4px"});let E={top:"0deg",right:"90deg",bottom:"180deg",left:"270deg"}[b]||"0deg";i.style.transform=`rotate(${E})`}}),l=v=>{v.key==="Escape"&&g.destroy()};window.addEventListener("keydown",l);let u=[],c=[];if(n.blocking&&(Array.from(document.body.children).forEach(v=>{v!==e&&v.getAttribute("inert")===null&&(v.setAttribute("inert",""),u.push(v.id||v.tagName))}),c=Array.from(r.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')),c.length>0)){let v=c[0],y=c[c.length-1],k=h=>{h.key==="Tab"&&(h.shiftKey?document.activeElement===v&&(y.focus(),h.preventDefault()):document.activeElement===y&&(v.focus(),h.preventDefault()))};r.addEventListener("keydown",k),requestAnimationFrame(()=>v.focus())}let f=(()=>{if(n.trigger==="hover"){let v=()=>{r.style.visibility="visible",r.style.opacity="1"},y=()=>{r.style.visibility="hidden",r.style.opacity="0"};return r.style.visibility="hidden",r.style.opacity="0",r.style.transition="opacity 200ms ease, visibility 200ms",t.addEventListener("mouseenter",v),t.addEventListener("mouseleave",y),t.addEventListener("focus",v),t.addEventListener("blur",y),()=>{t.removeEventListener("mouseenter",v),t.removeEventListener("mouseleave",y),t.removeEventListener("focus",v),t.removeEventListener("blur",y)}}if(n.trigger==="click"){let v=()=>{r.style.visibility==="visible"?g.destroy():(r.style.visibility="visible",r.style.opacity="1")};return r.style.visibility="hidden",r.style.opacity="0",r.style.transition="opacity 200ms ease, visibility 200ms",t.addEventListener("click",v),()=>t.removeEventListener("click",v)}return r.style.opacity="0",r.style.transition="opacity 200ms ease",requestAnimationFrame(()=>{r.style.opacity="1"}),()=>{}})(),g={el:r,destroy(){a(),f(),window.removeEventListener("keydown",l),n.blocking&&Array.from(document.body.children).forEach(v=>{v!==e&&v.removeAttribute("inert")}),r.style.opacity="0",setTimeout(()=>r.remove(),200)}};return g}var og=xt(()=>{H1();sg()});function fc(t,e,n){let r=n?.paddingPx??12,i=n?.radiusPx??12,s=Math.min(Math.max(n?.scrimOpacity??.55,0),1),o=n?.ringColor??"var(--syntro-ring, #5b8cff)",a=n?.blocking??!1,l=getComputedStyle(document.documentElement),u=l.getPropertyValue("--syntro-spotlight-backdrop").trim(),c=l.getPropertyValue("--syntro-ring").trim(),d=document.createElement("div");d.className="syntro-spotlight-scrim",Object.assign(d.style,{position:"fixed",inset:"0",zIndex:"2147483646",pointerEvents:a?"auto":"none",background:u||`rgba(2, 6, 23, ${s})`,transition:"opacity 220ms ease",opacity:"0"}),e.appendChild(d),requestAnimationFrame(()=>d.style.opacity="1");let f=document.createElement("div");f.className="syntro-spotlight-ring",Object.assign(f.style,{position:"fixed",pointerEvents:"none",borderRadius:`${i}px`,border:`2px solid ${o||c||"#5b8cff"}`,boxShadow:"0 0 0 4px rgba(255,255,255,0.35)",zIndex:"2147483647",transition:"all 220ms cubic-bezier(0.16,1,0.3,1)"}),e.appendChild(f);let g=[];if(!B1)for(let b=0;b<4;b++){let S=document.createElement("div");S.style.position="fixed",S.style.background="inherit",g.push(S),d.appendChild(S)}let v=b=>{d.style.clipPath=b,d.style.webkitClipPath=b},y=()=>{let b=t.getBoundingClientRect(),S=Math.max(0,b.left-r),E=Math.max(0,b.top-r),j=Math.min(window.innerWidth,b.width+r*2),F=Math.min(window.innerHeight,b.height+r*2);if(Object.assign(f.style,{left:`${S}px`,top:`${E}px`,width:`${j}px`,height:`${F}px`}),B1){let Y=window.innerWidth,te=window.innerHeight,K=Math.min(i,j/2,F/2),Q=`M 0 0 L ${Y} 0 L ${Y} ${te} L 0 ${te} Z`,ke=`M ${S+K} ${E} A ${K} ${K} 0 0 0 ${S} ${E+K} L ${S} ${E+F-K} A ${K} ${K} 0 0 0 ${S+K} ${E+F} L ${S+j-K} ${E+F} A ${K} ${K} 0 0 0 ${S+j} ${E+F-K} L ${S+j} ${E+K} A ${K} ${K} 0 0 0 ${S+j-K} ${E} L ${S+K} ${E} Z`,Oe=`path('${Q} ${ke}')`;v(Oe)}else{let[Y,te,K,Q]=g;Object.assign(Y.style,{left:"0px",top:"0px",width:"100vw",height:`${E}px`}),Object.assign(K.style,{left:"0px",top:`${E+F}px`,width:"100vw",height:`${Math.max(0,window.innerHeight-(E+F))}px`}),Object.assign(Q.style,{left:"0px",top:`${E}px`,width:`${S}px`,height:`${F}px`}),Object.assign(te.style,{left:`${S+j}px`,top:`${E}px`,width:`${Math.max(0,window.innerWidth-(S+j))}px`,height:`${F}px`})}},k=new ResizeObserver(()=>requestAnimationFrame(y));k.observe(t);let h=()=>requestAnimationFrame(y),p=()=>requestAnimationFrame(y);window.addEventListener("scroll",h,!0),window.addEventListener("resize",p);let m=b=>{b.key==="Escape"&&w.destroy()};window.addEventListener("keydown",m);let _=b=>{a?(b.preventDefault(),b.stopPropagation()):w.destroy()};d.addEventListener("click",_);let w={destroy(){k.disconnect(),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",p),window.removeEventListener("keydown",m),d.removeEventListener("click",_),d.style.opacity="0",setTimeout(()=>{d.remove(),f.remove()},220)}};return y(),w}var B1,ag=xt(()=>{B1=typeof CSS<"u"&&CSS.supports?.("clip-path","path('M0 0 H1 V1 Z')")});async function W1(t,e){if(t.routes&&!VP(t.routes,location.pathname))return()=>{};let n=[];for(let r of t.steps){let i=await e.resolve(r.anchor);if(!i){e.onEvent?.("syntro_anchor_missing",{stepId:r.id,anchor:r.anchor});continue}r.kind==="tooltip"?n.push(jP(r,i,e)):r.kind==="highlight"&&n.push(zP(r,i,e))}return()=>{n.forEach(r=>{try{r()}catch{}})}}function VP(t,e){return t.some(n=>n===e||e.startsWith(n))}function jP(t,e,n){let r=HP(t),i=dc(e,n.overlayRoot,{html:r,placement:t.placement??"top",offsetPx:t.offsetPx??8,blocking:!!t.blocking,trigger:t.trigger});n.onEvent?.("syntro_overlay_exposed",{kind:"tooltip",stepId:t.id,recipeId:n.recipeId});let s=[];if(t.dismiss?.timeoutMs){let l=window.setTimeout(()=>{i.destroy(),n.onEvent?.("syntro_overlay_dismissed",{stepId:t.id,reason:"timeout"})},t.dismiss.timeoutMs);s.push(l)}let o=i.el.querySelector('[data-syntro-role="close"]'),a=()=>{i.destroy(),n.onEvent?.("syntro_overlay_dismissed",{stepId:t.id,reason:"close"})};return o?.addEventListener("click",a),()=>{s.forEach(l=>clearTimeout(l)),o?.removeEventListener("click",a),i.destroy()}}function zP(t,e,n){let r=fc(e,n.overlayRoot,{paddingPx:t.ring?.paddingPx,radiusPx:t.ring?.radiusPx,scrimOpacity:t.scrim?.opacity,ringColor:t.ringColor,blocking:t.blocking});n.onEvent?.("syntro_overlay_exposed",{kind:"highlight",stepId:t.id,recipeId:n.recipeId});let i=[];if(t.dismiss?.timeoutMs){let s=window.setTimeout(()=>{r.destroy(),n.onEvent?.("syntro_overlay_dismissed",{stepId:t.id,reason:"timeout"})},t.dismiss.timeoutMs);i.push(s)}return()=>{i.forEach(s=>clearTimeout(s)),r.destroy()}}function HP(t){let e=t.content.title?`<div class="syntro-tt-title">${U1(t.content.title)}</div>`:"",n=`<div class="syntro-tt-body">${U1(t.content.body)}</div>`,r=t.dismiss?.closeButton??!0?'<button data-syntro-role="close" class="syntro-tt-close" aria-label="Close">\xD7</button>':"";return`<div class="syntro-tt">${e}${n}${r}</div>`}function U1(t){return t.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e])}var q1=xt(()=>{og();ag()});function UP(t){if(!t||t.length>500)return console.warn("[SmartCanvas] Selector too long or empty:",t?.slice(0,50)),!1;if(BP.some(e=>e.test(t)))return console.warn("[SmartCanvas] Dangerous selector pattern blocked:",t),!1;try{return document.querySelector(t),!0}catch{return console.warn("[SmartCanvas] Invalid CSS selector:",t),!1}}function ba(t,e){if(!UP(e))return null;let n=t.querySelectorAll(e);return n.length===0?(console.warn(`[SmartCanvas] No elements match selector: ${e}`),null):(n.length>1&&console.warn(`[SmartCanvas] Selector "${e}" matches ${n.length} elements. Using first match. Consider a more specific selector.`),n[0])}function K1(t){let e=t.canvasHost??document.querySelector("syntro-canvas");return async function(r){if(r.el instanceof HTMLElement)return r.el;if(r.type==="data"){let i=`[data-${r.key}${r.value?`="${r.value}"`:""}]`,s=ba(document,i);return s||(e?.shadowRoot?ba(e.shadowRoot,i):null)}if(r.type==="css")return ba(document,r.value);if(r.type==="aria"){let i=r.role?`[role="${r.role}"]`:"",s=r.label?`[aria-label="${r.label}"]`:"",o=`${i}${s}`;return ba(document,o)}return r.type==="shadow-css"?e?.shadowRoot?ba(e.shadowRoot,r.value):(console.warn("[SmartCanvas] shadow-css selector used but no shadow root available"),null):null}}var BP,G1=xt(()=>{BP=[/^\*$/,/^\s*$/,/:has\(/i,/javascript:/i]});function lg(t){let e=t.getBoundingClientRect();return e.width>0&&e.height>0&&e.bottom>=0&&e.top<=(window.innerHeight||document.documentElement.clientHeight)}function Z1(t){lg(t)||t.scrollIntoView({behavior:"smooth",block:"center",inline:"center"})}var Y1=xt(()=>{});var Q1={};xg(Q1,{createAnchorResolver:()=>K1,ensureOverlayRoot:()=>r1,injectBaseStyles:()=>Jh,isVisible:()=>lg,runOverlays:()=>W1,scrollIntoViewIfNeeded:()=>Z1,showHighlight:()=>fc,showTooltip:()=>dc});var X1=xt(()=>{i1();og();ag();q1();G1();Y1()});var ak=mn(ug=>{"use strict";var ok=Zu();ug.createRoot=ok.createRoot,ug.hydrateRoot=ok.hydrateRoot;var ZO});var x=typeof window<"u"?window:void 0,Me=typeof globalThis<"u"?globalThis:x;typeof self>"u"&&(Me.self=Me),typeof File>"u"&&(Me.File=function(){});var _m=Array.prototype,Sg=_m.forEach,bg=_m.indexOf,pt=Me?.navigator,A=Me?.document,rt=Me?.location,Dc=Me?.fetch,Vc=Me!=null&&Me.XMLHttpRequest&&"withCredentials"in new Me.XMLHttpRequest?Me.XMLHttpRequest:void 0,Cg=Me?.AbortController,nt=pt?.userAgent,z=x??{},yn={DEBUG:!1,LIB_VERSION:"1.302.2"};function Tg(t,e,n,r,i,s,o){try{var a=t[s](o),l=a.value}catch(u){return void n(u)}a.done?e(l):Promise.resolve(l).then(r,i)}function Pg(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var s=t.apply(e,n);function o(l){Tg(s,r,i,o,a,"next",l)}function a(l){Tg(s,r,i,o,a,"throw",l)}o(void 0)}))}}function L(){return L=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},L.apply(null,arguments)}function wm(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var Vk=["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"],Rg=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var n=t.toLowerCase();return Vk.concat(e).some((r=>{var i=r.toLowerCase();return n.indexOf(i)!==-1}))},jk=["$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 U(t,e){return t.indexOf(e)!==-1}var sl=function(t){return t.trim()},jc=function(t){return t.replace(/^\$/,"")},zk=Array.isArray,km=Object.prototype,xm=km.hasOwnProperty,ol=km.toString,ne=zk||function(t){return ol.call(t)==="[object Array]"},Qn=t=>typeof t=="function",Ne=t=>t===Object(t)&&!ne(t),Fi=t=>{if(Ne(t)){for(var e in t)if(xm.call(t,e))return!1;return!0}return!1},R=t=>t===void 0,Te=t=>ol.call(t)=="[object String]",zc=t=>Te(t)&&t.trim().length===0,xn=t=>t===null,ee=t=>R(t)||xn(t),rn=t=>ol.call(t)=="[object Number]",Xn=t=>ol.call(t)==="[object Boolean]",Hk=t=>t instanceof FormData,Bk=t=>U(jk,t);function Hc(t){return t===null||typeof t!="object"}function Da(t,e){return Object.prototype.toString.call(t)==="[object "+e+"]"}function Em(t){return!R(Event)&&(function(e,n){try{return e instanceof n}catch{return!1}})(t,Event)}var Uk=[!0,"true",1,"1","yes"],Ec=t=>U(Uk,t),Wk=[!1,"false",0,"0","no"];function en(t,e,n,r,i){return e>n&&(r.warn("min cannot be greater than max."),e=n),rn(t)?t>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):t<e?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+i),en(i||n,e,n,r))}var Bc=class{constructor(e){this.t={},this.i=e.i,this.o=en(e.bucketSize,0,100,e.h),this.m=en(e.refillRate,0,this.o,e.h),this.S=en(e.refillInterval,0,864e5,e.h)}$(e,n){var r=n-e.lastAccess,i=Math.floor(r/this.S);if(i>0){var s=i*this.m;e.tokens=Math.min(e.tokens+s,this.o),e.lastAccess=e.lastAccess+i*this.S}}consumeRateLimit(e){var n,r=Date.now(),i=String(e),s=this.t[i];return s?this.$(s,r):(s={tokens:this.o,lastAccess:r},this.t[i]=s),s.tokens===0||(s.tokens--,s.tokens===0&&((n=this.i)==null||n.call(this,e)),s.tokens===0)}stop(){this.t={}}},Pa,Ag,Sc,qk=t=>t instanceof Error;function Kk(t){var e=globalThis._posthogChunkIds;if(e){var n=Object.keys(e);return Sc&&n.length===Ag||(Ag=n.length,Sc=n.reduce(((r,i)=>{Pa||(Pa={});var s=Pa[i];if(s)r[s[0]]=s[1];else for(var o=t(i),a=o.length-1;a>=0;a--){var l=o[a],u=l?.filename,c=e[i];if(u&&c){r[u]=c,Pa[i]=[u,c];break}}return r}),{})),Sc}}var Uc=class{constructor(e,n,r){r===void 0&&(r=[]),this.coercers=e,this.stackParser=n,this.modifiers=r}buildFromUnknown(e,n){n===void 0&&(n={});var r=n&&n.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(r,n,0).apply(e),s=this.buildParsingContext(),o=this.parseStacktrace(i,s);return{$exception_list:this.convertToExceptionList(o,r),$exception_level:"error"}}modifyFrames(e){var n=this;return Pg((function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&ne(r.stacktrace.frames)&&(r.stacktrace.frames=yield n.applyModifiers(r.stacktrace.frames));return e}))()}coerceFallback(e){var n;return{type:"Error",value:"Unknown error",stack:(n=e.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(e,n){var r,i;return e.cause!=null&&(r=this.parseStacktrace(e.cause,n)),e.stack!=""&&e.stack!=null&&(i=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),n.chunkIdMap)),L({},e,{cause:r,stack:i})}applyChunkIds(e,n){return e.map((r=>(r.filename&&n&&(r.chunk_id=n[r.filename]),r)))}applyCoercers(e,n){for(var r of this.coercers)if(r.match(e))return r.coerce(e,n);return this.coerceFallback(n)}applyModifiers(e){var n=this;return Pg((function*(){var r=e;for(var i of n.modifiers)r=yield i(r);return r}))()}convertToExceptionList(e,n){var r,i,s,o={type:e.type,value:e.value,mechanism:{type:(r=n.type)!==null&&r!==void 0?r:"generic",handled:(i=n.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,L({},n,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:Kk(this.stackParser)}}buildCoercingContext(e,n,r){r===void 0&&(r=0);var i=(s,o)=>{if(o<=4){var a=this.buildCoercingContext(e,n,o);return this.applyCoercers(s,a)}};return L({},n,{syntheticException:r==0?n.syntheticException:void 0,mechanism:e,apply:s=>i(s,r),next:s=>i(s,r+1)})}},$i="?";function Wc(t,e,n,r,i){var s={platform:t,filename:e,function:n==="<anonymous>"?$i:n,in_app:!0};return R(r)||(s.lineno=r),R(i)||(s.colno=i),s}var Sm=(t,e)=>{var n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:$i,n?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},Gk=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Zk=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Yk=/\((\S*)(?::(\d+))(?::(\d+))\)/,Qk=(t,e)=>{var n=Gk.exec(t);if(n){var[,r,i,s]=n;return Wc(e,r,$i,+i,+s)}var o=Zk.exec(t);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Yk.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=Sm(o[1]||$i,o[2]);return Wc(e,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Xk=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Jk=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ex=(t,e)=>{var n=Xk.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=Jk.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var i=n[3],s=n[1]||$i;return[s,i]=Sm(s,i),Wc(e,i,s,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},Og=/\(error: (.*)\)/,Ng=50;function tx(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return function(i,s){s===void 0&&(s=0);for(var o=[],a=i.split(`
|
|
134
134
|
`),l=s;l<a.length;l++){var u=a[l];if(!(u.length>1024)){var c=Og.test(u)?u.replace(Og,"$1"):u;if(!c.match(/\S*Error: /)){for(var d of n){var f=d(c,t);if(f){o.push(f);break}}if(o.length>=Ng)break}}}return(function(g){if(!g.length)return[];var v=Array.from(g);return v.reverse(),v.slice(0,Ng).map((y=>{return L({},y,{filename:y.filename||(k=v,k[k.length-1]||{}).filename,function:y.function||$i});var k}))})(o)}}var qc=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,n){var r=Te(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:r?e.stack:void 0,cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var n=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?n+": "+e.message:n}isDOMException(e){return Da(e,"DOMException")}isDOMError(e){return Da(e,"DOMError")}},Kc=class{match(e){return(n=>n instanceof Error)(e)}coerce(e,n){return{type:this.getType(e),value:this.getMessage(e,n),stack:this.getStack(e),cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,n){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}},Gc=class{constructor(){}match(e){return Da(e,"ErrorEvent")&&e.error!=null}coerce(e,n){var r,i=n.apply(e.error);return i||{type:"ErrorEvent",value:e.message,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}},nx=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,Zc=class{match(e){return typeof e=="string"}coerce(e,n){var r,[i,s]=this.getInfos(e);return{type:i??"Error",value:s??e,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(e){var n="Error",r=e,i=e.match(nx);return i&&(n=i[1],r=i[2]),[n,r]}},rx=["fatal","error","warning","log","info","debug"];function bm(t,e){e===void 0&&(e=40);var n=Object.keys(t);if(n.sort(),!n.length)return"[object has no keys]";for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(", ");if(!(i.length>e))return r===n.length||i.length<=e?i:i.slice(0,e)+"..."}return""}var Yc=class{match(e){return typeof e=="object"&&e!==null}coerce(e,n){var r,i=this.getErrorPropertyFromObject(e);return i?n.apply(i):{type:this.getType(e),value:this.getValue(e),stack:(r=n.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return Em(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var n="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(n+=" with message: '"+e.message+"'"),n}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: "+bm(e)}isSeverityLevel(e){return Te(e)&&!zc(e)&&rx.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=e[n];if(qk(r))return r}}getObjectClassName(e){try{var n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch{return}}},Qc=class{match(e){return Em(e)}coerce(e,n){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+bm(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}},Xc=class{match(e){return Hc(e)}coerce(e,n){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}},Jc=class{match(e){return Da(e,"PromiseRejectionEvent")}coerce(e,n){var r,i=this.getUnhandledRejectionReason(e);return Hc(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}:n.apply(i)}getUnhandledRejectionReason(e){if(Hc(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}},Cm=function(t,e){var{debugEnabled:n}=e===void 0?{}:e,r={k:function(i){if(x&&(yn.DEBUG||z.POSTHOG_DEBUG||n)&&!R(x.console)&&x.console){for(var s=("__rrweb_original__"in x.console[i])?x.console[i].__rrweb_original__:x.console[i],o=arguments.length,a=new Array(o>1?o-1:0),l=1;l<o;l++)a[l-1]=arguments[l];s(t,...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(t,...s)},uninitializedWarning:i=>{r.error("You must initialize PostHog before calling "+i)},createLogger:(i,s)=>Cm(t+" "+i,s)};return r},O=Cm("[PostHog.js]"),Pe=O.createLogger,ix=Pe("[ExternalScriptsLoader]"),Fg=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return ix.warn(e+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var r=A?.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:n()}:(l.addEventListener("load",(u=>{l.__posthog_loading_callback_fired=!0,n(void 0,u)})),l.onerror=u=>n(u),{v:void 0})}},o=0;o<r.length;o++)if(i=s())return i.v}var a=()=>{if(!A)return n("document not found");var l=A.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=d=>{l.__posthog_loading_callback_fired=!0,n(void 0,d)},l.onerror=d=>n(d),t.config.prepare_external_dependency_script&&(l=t.config.prepare_external_dependency_script(l)),!l)return n("prepare_external_dependency_script returned null");var u,c=A.querySelectorAll("body > script");c.length>0?(u=c[0].parentNode)==null||u.insertBefore(l,c[0]):A.body.appendChild(l)};A!=null&&A.body?a():A?.addEventListener("DOMContentLoaded",a)};z.__PosthogExtensions__=z.__PosthogExtensions__||{},z.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{var r="/static/"+e+".js?v="+t.version;if(e==="remote-config"&&(r="/array/"+t.config.token+"/config.js"),e==="toolbar"){var i=3e5;r=r+"&t="+Math.floor(Date.now()/i)*i}var s=t.requestRouter.endpointFor("assets",r);Fg(t,s,n)},z.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{var r=t.requestRouter.endpointFor("api",e);Fg(t,r,n)};var Va={};function Jn(t,e,n){if(ne(t)){if(Sg&&t.forEach===Sg)t.forEach(e,n);else if("length"in t&&t.length===+t.length){for(var r=0,i=t.length;r<i;r++)if(r in t&&e.call(n,t[r],r)===Va)return}}}function re(t,e,n){if(!ee(t)){if(ne(t))return Jn(t,e,n);if(Hk(t)){for(var r of t.entries())if(e.call(n,r[1],r[0])===Va)return}else for(var i in t)if(xm.call(t,i)&&e.call(n,t[i],i)===Va)return}}var _e=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Jn(n,(function(i){for(var s in i)i[s]!==void 0&&(t[s]=i[s])})),t},ji=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return Jn(n,(function(i){Jn(i,(function(s){t.push(s)}))})),t};function Ia(t){for(var e=Object.keys(t),n=e.length,r=new Array(n);n--;)r[n]=[e[n],t[e[n]]];return r}var Lg=function(t){try{return t()}catch{return}},sx=function(t){return function(){try{for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.apply(this,n)}catch(i){O.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),O.critical(i)}}},Gd=function(t){var e={};return re(t,(function(n,r){(Te(n)&&n.length>0||rn(n))&&(e[r]=n)})),e};function ox(t,e){return n=t,r=s=>Te(s)&&!xn(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),ne(o)?(l=[],Jn(o,(u=>{l.push(s(u))}))):(l={},re(o,((u,c)=>{i.has(u)||(l[c]=s(u,c))}))),l);var l})(n);var n,r,i}var ax=["herokuapp.com","vercel.app","netlify.app"];function lx(t){var e=t?.hostname;if(!Te(e))return!1;var n=e.split(".").slice(-2).join(".");for(var r of ax)if(n===r)return!1;return!0}function Tm(t,e){for(var n=0;n<t.length;n++)if(e(t[n]))return t[n]}function Ee(t,e,n,r){var{capture:i=!1,passive:s=!0}=r??{};t?.addEventListener(e,n,{capture:i,passive:s})}var Pm="$people_distinct_id",Ys="__alias",Qs="__timers",Ig="$autocapture_disabled_server_side",ed="$heatmaps_enabled_server_side",Mg="$exception_capture_enabled_server_side",td="$error_tracking_suppression_rules",$g="$error_tracking_capture_extension_exceptions",Dg="$web_vitals_enabled_server_side",Rm="$dead_clicks_enabled_server_side",Vg="$web_vitals_allowed_metrics",bc="$session_recording_remote_config",ja="$sesid",Am="$session_is_sampled",Li="$enabled_feature_flags",Xs="$early_access_features",nd="$feature_flag_details",Js="$stored_person_properties",Vr="$stored_group_properties",rd="$surveys",Ra="$surveys_activated",za="$flag_call_reported",_n="$user_state",id="$client_session_props",sd="$capture_rate_limit",od="$initial_campaign_params",ad="$initial_referrer_info",Ha="$initial_person_info",Ba="$epp",Om="__POSTHOG_TOOLBAR__",zs="$posthog_cookieless",ux=[Pm,Ys,"__cmpns",Qs,"$session_recording_enabled_server_side",ed,ja,Li,td,_n,Xs,nd,Vr,Js,rd,za,id,sd,od,ad,Ba,Ha];function jg(t){return t instanceof Element&&(t.id===Om||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function al(t){return!!t&&t.nodeType===1}function er(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Nm(t){return!!t&&t.nodeType===3}function Fm(t){return!!t&&t.nodeType===11}function Zd(t){return t?sl(t).split(/\s+/):[]}function zg(t){var e=x?.location.href;return!!(e&&t&&t.some((n=>e.match(n))))}function Ua(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Zd(e)}function Lm(t){return ee(t)?null:sl(t).split(/(\s+)/).filter((e=>oo(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function po(t){var e="";return ld(t)&&!Vm(t)&&t.childNodes&&t.childNodes.length&&re(t.childNodes,(function(n){var r;Nm(n)&&n.textContent&&(e+=(r=Lm(n.textContent))!==null&&r!==void 0?r:"")})),sl(e)}function Im(t){return R(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var Yd=["a","button","form","input","select","textarea","label"];function Mm(t,e){if(R(e))return!0;var n,r=function(s){if(e.some((o=>s.matches(o))))return{v:!0}};for(var i of t)if(n=r(i))return n.v;return!1}function $m(t){var e=t.parentNode;return!(!e||!al(e))&&e}var cx=["next","previous","prev",">","<"],Hg=10,Bg=[".ph-no-rageclick",".ph-no-capture"];function dx(t,e){if(!x||Qd(t))return!1;var n,r,i;if(Xn(e)?(n=!!e&&Bg,r=void 0):(n=(i=e?.css_selector_ignorelist)!==null&&i!==void 0?i:Bg,r=e?.content_ignorelist),n===!1)return!1;var{targetElementList:s}=Dm(t,!1);return!(function(o,a){if(o===!1||R(o))return!1;var l;if(o===!0)l=cx;else{if(!ne(o))return!1;if(o.length>Hg)return O.error("[PostHog] content_ignorelist array cannot exceed "+Hg+" items. Use css_selector_ignorelist for more complex matching."),!1;l=o.map((u=>u.toLowerCase()))}return a.some((u=>{var{safeText:c,ariaLabel:d}=u;return l.some((f=>c.includes(f)||d.includes(f)))}))})(r,s.map((o=>{var a;return{safeText:po(o).toLowerCase(),ariaLabel:((a=o.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!Mm(s,n)}var Qd=t=>!t||er(t,"html")||!al(t),Dm=(t,e)=>{if(!x||Qd(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[t],i=t;i.parentNode&&!er(i,"body");)if(Fm(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var s=$m(i);if(!s)break;if(e||Yd.indexOf(s.tagName.toLowerCase())>-1)n=!0;else{var o=x.getComputedStyle(s);o&&o.getPropertyValue("cursor")==="pointer"&&(n=!0)}r.push(s),i=s}return{parentIsUsefulElement:n,targetElementList:r}};function fx(t,e,n,r,i){var s,o,a,l;if(n===void 0&&(n=void 0),!x||Qd(t)||(s=n)!=null&&s.url_allowlist&&!zg(n.url_allowlist)||(o=n)!=null&&o.url_ignorelist&&zg(n.url_ignorelist))return!1;if((a=n)!=null&&a.dom_event_allowlist){var u=n.dom_event_allowlist;if(u&&!u.some((v=>e.type===v)))return!1}var{parentIsUsefulElement:c,targetElementList:d}=Dm(t,r);if(!(function(v,y){var k=y?.element_allowlist;if(R(k))return!0;var h,p=function(_){if(k.some((w=>_.tagName.toLowerCase()===w)))return{v:!0}};for(var m of v)if(h=p(m))return h.v;return!1})(d,n)||!Mm(d,(l=n)==null?void 0:l.css_selector_allowlist))return!1;var f=x.getComputedStyle(t);if(f&&f.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var g=t.tagName.toLowerCase();switch(g){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 c?(i||["click"]).indexOf(e.type)>=0:(i||["click"]).indexOf(e.type)>=0&&(Yd.indexOf(g)>-1||t.getAttribute("contenteditable")==="true")}}function ld(t){for(var e=t;e.parentNode&&!er(e,"body");e=e.parentNode){var n=Ua(e);if(U(n,"ph-sensitive")||U(n,"ph-no-capture"))return!1}if(U(Ua(t),"ph-include"))return!0;var r=t.type||"";if(Te(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=t.name||t.id||"";return!(Te(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 Vm(t){return!!(er(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||er(t,"select")||er(t,"textarea")||t.getAttribute("contenteditable")==="true")}var jm="(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})",px=new RegExp("^(?:"+jm+")$"),hx=new RegExp(jm),zm="\\d{3}-?\\d{2}-?\\d{4}",gx=new RegExp("^("+zm+")$"),mx=new RegExp("("+zm+")");function oo(t,e){return e===void 0&&(e=!0),!(ee(t)||Te(t)&&(t=sl(t),(e?px:hx).test((t||"").replace(/[- ]/g,""))||(e?gx:mx).test(t)))}function Hm(t){var e=po(t);return oo(e=(e+" "+Bm(t)).trim())?e:""}function Bm(t){var e="";return t&&t.childNodes&&t.childNodes.length&&re(t.childNodes,(function(n){var r;if(n&&((r=n.tagName)==null?void 0:r.toLowerCase())==="span")try{var i=po(n);e=(e+" "+i).trim(),n.childNodes&&n.childNodes.length&&(e=(e+" "+Bm(n)).trim())}catch(s){O.error("[AutoCapture]",s)}})),e}function vx(t){return(function(e){var n=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=L({},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),u={};return Ia(l).sort(((c,d)=>{var[f]=c,[g]=d;return f.localeCompare(g)})).forEach((c=>{var[d,f]=c;return u[Ug(d.toString())]=Ug(f.toString())})),o+=":",o+=Ia(u).map((c=>{var[d,f]=c;return d+'="'+f+'"'})).join("")}));return n.join(";")})((function(e){return e.map((n=>{var r,i,s={text:(r=n.$el_text)==null?void 0:r.slice(0,400),tag_name:n.tag_name,href:(i=n.attr__href)==null?void 0:i.slice(0,2048),attr_class:yx(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return Ia(n).filter((o=>{var[a]=o;return a.indexOf("attr__")===0})).forEach((o=>{var[a,l]=o;return s.attributes[a]=l})),s}))})(t))}function Ug(t){return t.replace(/"|\\"/g,'\\"')}function yx(t){var e=t.attr__class;return e?ne(e)?e:Zd(e):void 0}var Wa=class{constructor(e){this.disabled=e===!1;var n=Ne(e)?e:{};this.thresholdPx=n.threshold_px||30,this.timeoutMs=n.timeout_ms||1e3,this.clickCount=n.click_count||3,this.clicks=[]}isRageClick(e,n,r){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(n-i.y)<this.thresholdPx&&r-i.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:n,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:n,timestamp:r}];return!1}},Cc="$copy_autocapture",kn=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({});var qa=t=>{var e=A?.createElement("a");return R(e)?null:(e.href=t,e)},_x=function(t,e){var n,r;e===void 0&&(e="&");var i=[];return re(t,(function(s,o){R(s)||R(o)||o==="undefined"||(n=encodeURIComponent((a=>a instanceof File)(s)?s.name:s.toString()),r=encodeURIComponent(o),i[i.length]=r+"="+n)})),i.join(e)},Ka=function(t,e){for(var n,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<r.length;i++){var s=r[i].split("=");if(s[0]===e){n=s;break}}if(!ne(n)||n.length<2)return"";var o=n[1];try{o=decodeURIComponent(o)}catch{O.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},ho=function(t,e,n){if(!t||!e||!e.length)return t;for(var r=t.split("#"),i=r[0]||"",s=r[1],o=i.split("?"),a=o[1],l=o[0],u=(a||"").split("&"),c=[],d=0;d<u.length;d++){var f=u[d].split("=");ne(f)&&(e.includes(f[0])?c.push(f[0]+"="+n):c.push(u[d]))}var g=l;return a!=null&&(g+="?"+c.join("&")),s!=null&&(g+="#"+s),g},Ga=function(t,e){var n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},Wg=Pe("[AutoCapture]");function Tc(t,e){return e.length>t?e.slice(0,t)+"...":e}function wx(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!al(e));return e}function kx(t,e,n,r){var i=t.tagName.toLowerCase(),s={tag_name:i};Yd.indexOf(i)>-1&&!n&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?s.$el_text=Tc(1024,Hm(t)):s.$el_text=Tc(1024,po(t)));var o=Ua(t);o.length>0&&(s.classes=o.filter((function(c){return c!==""}))),re(t.attributes,(function(c){var d;if((!Vm(t)||["name","id","class","aria-label"].indexOf(c.name)!==-1)&&(r==null||!r.includes(c.name))&&!e&&oo(c.value)&&(d=c.name,!Te(d)||d.substring(0,10)!=="_ngcontent"&&d.substring(0,7)!=="_nghost")){var f=c.value;c.name==="class"&&(f=Zd(f).join(" ")),s["attr__"+c.name]=Tc(1024,f)}}));for(var a=1,l=1,u=t;u=wx(u);)a++,u.tagName===t.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function xx(t,e){for(var n,r,{e:i,maskAllElementAttributes:s,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,u=[t],c=t;c.parentNode&&!er(c,"body");)Fm(c.parentNode)?(u.push(c.parentNode.host),c=c.parentNode.host):(u.push(c.parentNode),c=c.parentNode);var d,f=[],g={},v=!1,y=!1;if(re(u,(_=>{var w=ld(_);_.tagName.toLowerCase()==="a"&&(v=_.getAttribute("href"),v=w&&v&&oo(v)&&v),U(Ua(_),"ph-no-capture")&&(y=!0),f.push(kx(_,s,o,a));var b=(function(S){if(!ld(S))return{};var E={};return re(S.attributes,(function(j){if(j.name&&j.name.indexOf("data-ph-capture-attribute")===0){var F=j.name.replace("data-ph-capture-attribute-",""),Y=j.value;F&&Y&&oo(Y)&&(E[F]=Y)}})),E})(_);_e(g,b)})),y)return{props:{},explicitNoCapture:y};if(o||(t.tagName.toLowerCase()==="a"||t.tagName.toLowerCase()==="button"?f[0].$el_text=Hm(t):f[0].$el_text=po(t)),v){var k,h;f[0].attr__href=v;var p=(k=qa(v))==null?void 0:k.host,m=x==null||(h=x.location)==null?void 0:h.host;p&&m&&p!==m&&(d=v)}return{props:_e({$event_type:i.type,$ce_version:1},l?{}:{$elements:f},{$elements_chain:vx(f)},(n=f[0])!=null&&n.$el_text?{$el_text:(r=f[0])==null?void 0:r.$el_text}:{},d&&i.type==="click"?{$external_click_url:d}:{},g)}}var ud=class{constructor(e){this.P=!1,this.T=null,this.R=!1,this.instance=e,this.rageclicks=new Wa(e.config.rageclick),this.I=null}get F(){var e,n,r=Ne(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=(n=r.url_ignorelist)==null?void 0:n.map((i=>new RegExp(i))),r}C(){if(this.isBrowserSupported()){if(x&&A){var e=r=>{r=r||x?.event;try{this.M(r)}catch(i){Wg.error("Failed to capture event",i)}};if(Ee(A,"submit",e,{capture:!0}),Ee(A,"change",e,{capture:!0}),Ee(A,"click",e,{capture:!0}),this.F.capture_copied_text){var n=r=>{r=r||x?.event,this.M(r,Cc)};Ee(A,"copy",n,{capture:!0}),Ee(A,"cut",n,{capture:!0})}}}else Wg.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.C(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.R=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ig]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.I=e}getElementSelectors(e){var n,r=[];return(n=this.I)==null||n.forEach((i=>{var s=A?.querySelectorAll(i);s?.forEach((o=>{e===o&&r.push(i)}))})),r}get isEnabled(){var e,n,r=(e=this.instance.persistence)==null?void 0:e.props[Ig],i=this.T;if(xn(i)&&!Xn(r)&&!this.instance.O())return!1;var s=(n=this.T)!==null&&n!==void 0?n:!!r;return!!this.instance.config.autocapture&&!s}M(e,n){if(n===void 0&&(n="$autocapture"),this.isEnabled){var r,i=Im(e);Nm(i)&&(i=i.parentNode||null),n==="$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())&&dx(i,this.instance.config.rageclick)&&this.M(e,"$rageclick");var s=n===Cc;if(i&&fx(i,e,this.F,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=xx(i,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.F.element_attribute_ignorelist,elementsChainAsString:this.R});if(a)return!1;var l=this.getElementSelectors(i);if(l&&l.length>0&&(o.$element_selectors=l),n===Cc){var u,c=Lm(x==null||(u=x.getSelection())==null?void 0:u.toString()),d=e.type||"clipboard";if(!c)return!1;o.$selected_content=c,o.$copy_type=d}return this.instance.capture(n,o),!0}}}isBrowserSupported(){return Qn(A?.querySelectorAll)}};Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return rn(t)&&isFinite(t)&&Math.floor(t)===t});var qg="0123456789abcdef",cd=class t{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,n,r,i){if(!Number.isInteger(e)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||e<0||n<0||r<0||i<0||e>0xffffffffffff||n>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|n>>>8,s[7]=n,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 t(s)}toString(){for(var e="",n=0;n<this.bytes.length;n++)e=e+qg.charAt(this.bytes[n]>>>4)+qg.charAt(15&this.bytes[n]),n!==3&&n!==5&&n!==7&&n!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new t(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var n=0;n<16;n++){var r=this.bytes[n]-e.bytes[n];if(r!==0)return Math.sign(r)}return 0}},dd=class{constructor(){this.A=0,this.D=0,this.j=new fd}generate(){var e=this.generateOrAbort();if(R(e)){this.A=0;var n=this.generateOrAbort();if(R(n))throw new Error("Could not generate UUID after timestamp reset");return n}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.D++,this.D>4398046511103&&(this.A++,this.L())}return cd.fromFieldsV7(this.A,Math.trunc(this.D/Math.pow(2,30)),this.D&Math.pow(2,30)-1,this.j.nextUint32())}L(){this.D=1024*this.j.nextUint32()+(1023&this.j.nextUint32())}},Kg,Um=t=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<t.length;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};x&&!R(x.crypto)&&crypto.getRandomValues&&(Um=t=>crypto.getRandomValues(t));var fd=class{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(Um(this.N),this.U=0),this.N[this.U++]}},Yn=()=>Ex().toString(),Ex=()=>(Kg||(Kg=new dd)).generate(),Hs="",Sx=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function bx(t,e){if(e){var n=(function(i,s){if(s===void 0&&(s=A),Hs)return Hs;if(!s||["localhost","127.0.0.1"].includes(i))return"";for(var o=i.split("."),a=Math.min(o.length,8),l="dmn_chk_"+Yn();!Hs&&a--;){var u=o.slice(a).join("."),c=l+"=1;domain=."+u+";path=/";s.cookie=c+";max-age=3",s.cookie.includes(l)&&(s.cookie=c+";max-age=0",Hs=u)}return Hs})(t);if(!n){var r=(i=>{var s=i.match(Sx);return s?s[0]:""})(t);r!==n&&O.info("Warning: cookie subdomain discovery mismatch",r,n),n=r}return n?"; domain=."+n:""}return""}var nn={H:()=>!!A,B:function(t){O.error("cookieStore error: "+t)},q:function(t){if(A){try{for(var e=t+"=",n=A.cookie.split(";").filter((s=>s.length)),r=0;r<n.length;r++){for(var i=n[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(t){var e;try{e=JSON.parse(nn.q(t))||{}}catch{}return e},G:function(t,e,n,r,i){if(A)try{var s="",o="",a=bx(A.location.hostname,r);if(n){var l=new Date;l.setTime(l.getTime()+24*n*60*60*1e3),s="; expires="+l.toUTCString()}i&&(o="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+s+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&O.warn("cookieStore warning: large cookie, len="+u.length),A.cookie=u,u}catch{return}},V:function(t,e){if(A!=null&&A.cookie)try{nn.G(t,"",-1,e)}catch{return}}},Pc=null,pe={H:function(){if(!xn(Pc))return Pc;var t=!0;if(R(x))t=!1;else try{var e="__mplssupport__";pe.G(e,"xyz"),pe.q(e)!=='"xyz"'&&(t=!1),pe.V(e)}catch{t=!1}return t||O.error("localStorage unsupported; falling back to cookie store"),Pc=t,t},B:function(t){O.error("localStorage error: "+t)},q:function(t){try{return x?.localStorage.getItem(t)}catch(e){pe.B(e)}return null},W:function(t){try{return JSON.parse(pe.q(t))||{}}catch{}return null},G:function(t,e){try{x?.localStorage.setItem(t,JSON.stringify(e))}catch(n){pe.B(n)}},V:function(t){try{x?.localStorage.removeItem(t)}catch(e){pe.B(e)}}},Cx=["distinct_id",ja,Am,Ba,Ha],Aa=L({},pe,{W:function(t){try{var e={};try{e=nn.W(t)||{}}catch{}var n=_e(e,JSON.parse(pe.q(t)||"{}"));return pe.G(t,n),n}catch{}return null},G:function(t,e,n,r,i,s){try{pe.G(t,e,void 0,void 0,s);var o={};Cx.forEach((a=>{e[a]&&(o[a]=e[a])})),Object.keys(o).length&&nn.G(t,o,n,r,i,s)}catch(a){pe.B(a)}},V:function(t,e){try{x?.localStorage.removeItem(t),nn.V(t,e)}catch(n){pe.B(n)}}}),Oa={},Tx={H:function(){return!0},B:function(t){O.error("memoryStorage error: "+t)},q:function(t){return Oa[t]||null},W:function(t){return Oa[t]||null},G:function(t,e){Oa[t]=e},V:function(t){delete Oa[t]}},$r=null,Ie={H:function(){if(!xn($r))return $r;if($r=!0,R(x))$r=!1;else try{var t="__support__";Ie.G(t,"xyz"),Ie.q(t)!=='"xyz"'&&($r=!1),Ie.V(t)}catch{$r=!1}return $r},B:function(t){O.error("sessionStorage error: ",t)},q:function(t){try{return x?.sessionStorage.getItem(t)}catch(e){Ie.B(e)}return null},W:function(t){try{return JSON.parse(Ie.q(t))||null}catch{}return null},G:function(t,e){try{x?.sessionStorage.setItem(t,JSON.stringify(e))}catch(n){Ie.B(n)}},V:function(t){try{x?.sessionStorage.removeItem(t)}catch(e){Ie.B(e)}}},wn=(function(t){return t[t.PENDING=-1]="PENDING",t[t.DENIED=0]="DENIED",t[t.GRANTED=1]="GRANTED",t})({}),pd=class{constructor(e){this._instance=e}get F(){return this._instance.config}get consent(){return this.J()?wn.DENIED:this.K}isOptedOut(){return this.F.cookieless_mode==="always"||this.consent===wn.DENIED||this.consent===wn.PENDING&&(this.F.opt_out_capturing_by_default||this.F.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===wn.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.F.cookie_expiration,this.F.cross_subdomain_cookie,this.F.secure_cookie)}reset(){this.Y.V(this.X,this.F.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:n,consent_persistence_name:r}=this._instance.config;return r||(n?n+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return Ec(e)?wn.GRANTED:U(Wk,e)?wn.DENIED:wn.PENDING}get Y(){if(!this.Z){var e=this.F.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?pe:nn;var n=e==="localStorage"?nn:pe;n.q(this.X)&&(this.Z.q(this.X)||this.optInOut(Ec(n.q(this.X))),n.V(this.X,this.F.cross_subdomain_cookie))}return this.Z}J(){return!!this.F.respect_dnt&&!!Tm([pt?.doNotTrack,pt?.msDoNotTrack,z.doNotTrack],(e=>Ec(e)))}},Na=Pe("[Dead Clicks]"),Px=()=>!0,Rx=t=>{var e,n=!((e=t.instance.persistence)==null||!e.get_property(Rm)),r=t.instance.config.capture_dead_clicks;return Xn(r)?r:!!Ne(r)||n},Za=class{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,n,r){this.instance=e,this.isEnabled=n,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Rm]:e?.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it((()=>{this.et()}))}it(e){var n,r;(n=z.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture&&e(),(r=z.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?Na.error("failed to load script",i):e()}))}et(){var e;if(A){if(!this.tt&&(e=z.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var n=Ne(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this.tt=z.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.tt.start(A),Na.info("starting...")}}else Na.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Na.info("stopping..."))}},Bs=Pe("[ExceptionAutocapture]"),hd=class{constructor(e){var n,r,i;this.rt=()=>{var s;if(x&&this.isEnabled&&(s=z.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var o=z.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=z.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=z.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.F.capture_unhandled_errors&&(this.st=o(this.captureException.bind(this))),!this.nt&&this.F.capture_unhandled_rejections&&(this.nt=a(this.captureException.bind(this))),!this.ot&&this.F.capture_console_errors&&(this.ot=l(this.captureException.bind(this)))}catch(u){Bs.error("failed to start",u),this.lt()}}},this._instance=e,this.ut=!((n=this._instance.persistence)==null||!n.props[Mg]),this.F=this.ht(),this.vt=new Bc({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:Bs}),this.startIfEnabled()}ht(){var e=this._instance.config.capture_exceptions,n={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Ne(e)?n=L({},n,e):(R(e)?this.ut:e)&&(n=L({},n,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),n}get isEnabled(){return this.F.capture_console_errors||this.F.capture_unhandled_errors||this.F.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(Bs.info("enabled"),this.it(this.rt))}it(e){var n,r;(n=z.__PosthogExtensions__)!=null&&n.errorWrappingFunctions&&e(),(r=z.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return Bs.error("failed to load script",i);e()}))}lt(){var e,n,r;(e=this.st)==null||e.call(this),this.st=void 0,(n=this.nt)==null||n.call(this),this.nt=void 0,(r=this.ot)==null||r.call(this),this.ot=void 0}onRemoteConfig(e){var n=e.autocaptureExceptions;this.ut=!!n||!1,this.F=this.ht(),this._instance.persistence&&this._instance.persistence.register({[Mg]:this.ut}),this.startIfEnabled()}captureException(e){var n,r,i=(n=e==null||(r=e.$exception_list)==null||(r=r[0])==null?void 0:r.type)!==null&&n!==void 0?n:"Exception";this.vt.consumeRateLimit(i)?Bs.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(e)}};function Gg(t,e,n){try{if(!(e in t))return()=>{};var r=t[e],i=n(r);return Qn(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=i,()=>{t[e]=r}}catch{return()=>{}}}var gd=class{constructor(e){var n;this._instance=e,this.dt=(x==null||(n=x.location)==null?void 0:n.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(O.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ct&&this.ct(),this.ct=void 0,O.info("History API monitoring stopped")}monitorHistoryChanges(){var e,n;if(x&&x.history){var r=this;(e=x.history.pushState)!=null&&e.__posthog_wrapped__||Gg(x.history,"pushState",(i=>function(s,o,a){i.call(this,s,o,a),r.ft("pushState")})),(n=x.history.replaceState)!=null&&n.__posthog_wrapped__||Gg(x.history,"replaceState",(i=>function(s,o,a){i.call(this,s,o,a),r.ft("replaceState")})),this.gt()}}ft(e){try{var n,r=x==null||(n=x.location)==null?void 0:n.pathname;if(!r)return;r!==this.dt&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.dt=r}catch(i){O.error("Error capturing "+e+" pageview",i)}}gt(){if(!this.ct){var e=()=>{this.ft("popstate")};Ee(x,"popstate",e),this.ct=()=>{x&&x.removeEventListener("popstate",e)}}}},Rc=Pe("[SegmentIntegration]");function Ax(t,e){var n=t.config.segment;if(!n)return e();(function(r,i){var s=r.config.segment;if(!s)return i();var o=l=>{var u=()=>l.anonymousId()||Yn();r.config.get_device_id=u,l.id()&&(r.register({distinct_id:l.id(),$device_id:u()}),r.persistence.set_property(_n,"identified")),i()},a=s.user();"then"in a&&Qn(a.then)?a.then((l=>o(l))):o(a)})(t,(()=>{n.register((r=>{Promise&&Promise.resolve||Rc.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()||(Rc.info("No userId set, resetting PostHog"),r.reset()),s.event.userId&&s.event.userId!==r.get_distinct_id()&&(Rc.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")}})(t)).then((()=>{e()}))}))}var Wm="posthog-js";function qm(t,e){var{organization:n,projectId:r,prefix:i,severityAllowList:s=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,u,c,d,f;if(!(s==="*"||s.includes(a.level))||!t.__loaded)return a;a.tags||(a.tags={});var g=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());a.tags["PostHog Person URL"]=g,t.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var v=((l=a.exception)==null?void 0:l.values)||[],y=v.map((h=>L({},h,{stacktrace:h.stacktrace?L({},h.stacktrace,{type:"raw",frames:(h.stacktrace.frames||[]).map((p=>L({},p,{platform:"web:javascript"})))}):void 0}))),k={$exception_message:((u=v[0])==null?void 0:u.value)||a.message,$exception_type:(c=v[0])==null?void 0:c.type,$exception_level:a.level,$exception_list:y,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((d=v[0])==null?void 0:d.value)||a.message,$sentry_exception_type:(f=v[0])==null?void 0:f.type,$sentry_tags:a.tags};return n&&r&&(k.$sentry_url=(i||"https://sentry.io/organizations/")+n+"/issues/?project="+r+"&query="+a.event_id),o&&t.exceptions.sendExceptionEvent(k),a}}var md=class{constructor(e,n,r,i,s,o){this.name=Wm,this.setupOnce=function(a){a(qm(e,{organization:n,projectId:r,prefix:i,severityAllowList:s,sendExceptionsToPostHog:o==null||o}))}}},Ox=x!=null&&x.location?Ga(x.location.hash,"__posthog")||Ga(location.hash,"state"):null,Zg="_postHogToolbarParams",Yg=Pe("[Toolbar]"),Zn=(function(t){return t[t.UNINITIALIZED=0]="UNINITIALIZED",t[t.LOADING=1]="LOADING",t[t.LOADED=2]="LOADED",t})(Zn||{}),vd=class{constructor(e){this.instance=e}_t(e){z.ph_toolbar_state=e}yt(){var e;return(e=z.ph_toolbar_state)!==null&&e!==void 0?e:Zn.UNINITIALIZED}maybeLoadToolbar(e,n,r){if(e===void 0&&(e=void 0),n===void 0&&(n=void 0),r===void 0&&(r=void 0),!x||!A)return!1;e=e??x.location,r=r??x.history;try{if(!n){try{x.localStorage.setItem("test","test"),x.localStorage.removeItem("test")}catch{return!1}n=x?.localStorage}var i,s=Ox||Ga(e.hash,"__posthog")||Ga(e.hash,"state"),o=s?Lg((()=>JSON.parse(atob(decodeURIComponent(s)))))||Lg((()=>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(n.getItem(Zg)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token)&&(this.loadToolbar(i),!0)}catch{return!1}}bt(e){var n=z.ph_load_toolbar||z.ph_load_editor;!ee(n)&&Qn(n)?n(e,this.instance):Yg.warn("No toolbar load function found")}loadToolbar(e){var n=!(A==null||!A.getElementById(Om));if(!x||n)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=L({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(x.localStorage.setItem(Zg,JSON.stringify(L({},i,{source:void 0}))),this.yt()===Zn.LOADED)this.bt(i);else if(this.yt()===Zn.UNINITIALIZED){var s;this._t(Zn.LOADING),(s=z.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"toolbar",(o=>{if(o)return Yg.error("[Toolbar] Failed to load",o),void this._t(Zn.UNINITIALIZED);this._t(Zn.LOADED),this.bt(i)})),Ee(x,"turbolinks:load",(()=>{this._t(Zn.UNINITIALIZED),this.loadToolbar(i)}))}return!0}wt(e){return this.loadToolbar(e)}maybeLoadEditor(e,n,r){return e===void 0&&(e=void 0),n===void 0&&(n=void 0),r===void 0&&(r=void 0),this.maybeLoadToolbar(e,n,r)}},Nx=Pe("[TracingHeaders]"),yd=class{constructor(e){this.xt=void 0,this.St=void 0,this.rt=()=>{var n,r;R(this.xt)&&((n=z.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null||n._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),R(this.St)&&((r=z.__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 n,r;(n=z.__PosthogExtensions__)!=null&&n.tracingHeadersPatchFns&&e(),(r=z.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return Nx.error("failed to load script",i);e()}))}startIfEnabledOrStop(){var e,n;this._instance.config.__add_tracing_headers?this.it(this.rt):((e=this.xt)==null||e.call(this),(n=this.St)==null||n.call(this),this.xt=void 0,this.St=void 0)}},Et="Mobile",Ya="iOS",tn="Android",ao="Tablet",Km=tn+" "+ao,Gm="iPad",Zm="Apple",Ym=Zm+" Watch",lo="Safari",Di="BlackBerry",Qm="Samsung",Xm=Qm+"Browser",Jm=Qm+" Internet",jr="Chrome",Fx=jr+" OS",ev=jr+" "+Ya,Xd="Internet Explorer",tv=Xd+" "+Et,Jd="Opera",Lx=Jd+" Mini",ef="Edge",nv="Microsoft "+ef,Ii="Firefox",rv=Ii+" "+Ya,uo="Nintendo",co="PlayStation",Mi="Xbox",iv=tn+" "+Et,sv=Et+" "+lo,eo="Windows",_d=eo+" Phone",Qg="Nokia",wd="Ouya",ov="Generic",Ix=ov+" "+Et.toLowerCase(),av=ov+" "+ao.toLowerCase(),kd="Konqueror",Ye="(\\d+(\\.\\d+)?)",Ac=new RegExp("Version/"+Ye),Mx=new RegExp(Mi,"i"),$x=new RegExp(co+" \\w+","i"),Dx=new RegExp(uo+" \\w+","i"),tf=new RegExp(Di+"|PlayBook|BB10","i"),Vx={"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"},jx=(t,e)=>e&&U(e,Zm)||(function(n){return U(n,lo)&&!U(n,jr)&&!U(n,tn)})(t),lv=function(t,e){return e=e||"",U(t," OPR/")&&U(t,"Mini")?Lx:U(t," OPR/")?Jd:tf.test(t)?Di:U(t,"IE"+Et)||U(t,"WPDesktop")?tv:U(t,Xm)?Jm:U(t,ef)||U(t,"Edg/")?nv:U(t,"FBIOS")?"Facebook "+Et:U(t,"UCWEB")||U(t,"UCBrowser")?"UC Browser":U(t,"CriOS")?ev:U(t,"CrMo")||U(t,jr)?jr:U(t,tn)&&U(t,lo)?iv:U(t,"FxiOS")?rv:U(t.toLowerCase(),kd.toLowerCase())?kd:jx(t,e)?U(t,Et)?sv:lo:U(t,Ii)?Ii:U(t,"MSIE")||U(t,"Trident/")?Xd:U(t,"Gecko")?Ii:""},zx={[tv]:[new RegExp("rv:"+Ye)],[nv]:[new RegExp(ef+"?\\/"+Ye)],[jr]:[new RegExp("("+jr+"|CrMo)\\/"+Ye)],[ev]:[new RegExp("CriOS\\/"+Ye)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ye)],[lo]:[Ac],[sv]:[Ac],[Jd]:[new RegExp("(Opera|OPR)\\/"+Ye)],[Ii]:[new RegExp(Ii+"\\/"+Ye)],[rv]:[new RegExp("FxiOS\\/"+Ye)],[kd]:[new RegExp("Konqueror[:/]?"+Ye,"i")],[Di]:[new RegExp(Di+" "+Ye),Ac],[iv]:[new RegExp("android\\s"+Ye,"i")],[Jm]:[new RegExp(Xm+"\\/"+Ye)],[Xd]:[new RegExp("(rv:|MSIE )"+Ye)],Mozilla:[new RegExp("rv:"+Ye)]},Hx=function(t,e){var n=lv(t,e),r=zx[n];if(R(r))return null;for(var i=0;i<r.length;i++){var s=r[i],o=t.match(s);if(o)return parseFloat(o[o.length-2])}return null},Xg=[[new RegExp(Mi+"; "+Mi+" (.*?)[);]","i"),t=>[Mi,t&&t[1]||""]],[new RegExp(uo,"i"),[uo,""]],[new RegExp(co,"i"),[co,""]],[tf,[Di,""]],[new RegExp(eo,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[_d,""];if(new RegExp(Et).test(e)&&!/IEMobile\b/.test(e))return[eo+" "+Et,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var r=n[1],i=Vx[r]||"";return/arm/i.test(e)&&(i="RT"),[eo,i]}return[eo,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>{if(t&&t[3]){var e=[t[3],t[4],t[5]||"0"];return[Ya,e.join(".")]}return[Ya,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=R(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+tn+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+tn+")","i"),t=>{if(t&&t[2]){var e=[t[2],t[3],t[4]||"0"];return[tn,e.join(".")]}return[tn,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];if(t&&t[1]){var n=[t[1],t[2],t[3]||"0"];e[1]=n.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Fx,""]],[/Linux|debian/i,["Linux",""]]],Jg=function(t){return Dx.test(t)?uo:$x.test(t)?co:Mx.test(t)?Mi:new RegExp(wd,"i").test(t)?wd:new RegExp("("+_d+"|WPDesktop)","i").test(t)?_d:/iPad/.test(t)?Gm:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Ym:tf.test(t)?Di:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Qg,"i").test(t)?Qg:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?!new RegExp(Et).test(t)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)?/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?tn:Km:tn:new RegExp("(pda|"+Et+")","i").test(t)?Ix:new RegExp(ao,"i").test(t)&&!new RegExp(ao+" pc","i").test(t)?av:""},Fa="https?://(.*)",zi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Bx=ji(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],zi),go="<masked>",Ux=["li_fat_id"];function uv(t,e,n){if(!A)return{};var r,i=e?ji([],zi,n||[]):[],s=cv(ho(A.URL,i,go),t),o=(r={},re(Ux,(function(a){var l=nn.q(a);r[a]=l||null})),r);return _e(o,s)}function cv(t,e){var n=Bx.concat(e||[]),r={};return re(n,(function(i){var s=Ka(t,i);r[i]=s||null})),r}function dv(t){var e=(function(s){return s?s.search(Fa+"google.([^/?]*)")===0?"google":s.search(Fa+"bing.com")===0?"bing":s.search(Fa+"yahoo.com")===0?"yahoo":s.search(Fa+"duckduckgo.com")===0?"duckduckgo":null:null})(t),n=e!="yahoo"?"q":"p",r={};if(!xn(e)){r.$search_engine=e;var i=A?Ka(A.referrer,n):"";i.length&&(r.ph_keyword=i)}return r}function em(){return navigator.language||navigator.userLanguage}function fv(){return A?.referrer||"$direct"}function pv(t,e){var n=t?ji([],zi,e||[]):[],r=rt?.href.substring(0,1e3);return{r:fv().substring(0,1e3),u:r?ho(r,n,go):void 0}}function hv(t){var e,{r:n,u:r}=t,i={$referrer:n,$referring_domain:n==null?void 0:n=="$direct"?"$direct":(e=qa(n))==null?void 0:e.host};if(r){i.$current_url=r;var s=qa(r);i.$host=s?.host,i.$pathname=s?.pathname;var o=cv(r);_e(i,o)}if(n){var a=dv(n);_e(i,a)}return i}function gv(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Wx(){try{return new Date().getTimezoneOffset()}catch{return}}function qx(t,e){if(!nt)return{};var n,r,i,s=t?ji([],zi,e||[]):[],[o,a]=(function(l){for(var u=0;u<Xg.length;u++){var[c,d]=Xg[u],f=c.exec(l),g=f&&(Qn(d)?d(f,l):d);if(g)return g}return["",""]})(nt);return _e(Gd({$os:o,$os_version:a,$browser:lv(nt,navigator.vendor),$device:Jg(nt),$device_type:(r=nt,i=Jg(r),i===Gm||i===Km||i==="Kobo"||i==="Kindle Fire"||i===av?ao:i===uo||i===Mi||i===co||i===wd?"Console":i===Ym?"Wearable":i?Et:"Desktop"),$timezone:gv(),$timezone_offset:Wx()}),{$current_url:ho(rt?.href,s,go),$host:rt?.host,$pathname:rt?.pathname,$raw_user_agent:nt.length>1e3?nt.substring(0,997)+"...":nt,$browser_version:Hx(nt,navigator.vendor),$browser_language:em(),$browser_language_prefix:(n=em(),typeof n=="string"?n.split("-")[0]:void 0),$screen_height:x?.screen.height,$screen_width:x?.screen.width,$viewport_height:x?.innerHeight,$viewport_width:x?.innerWidth,$lib:"web",$lib_version:yn.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var qn=Pe("[Web Vitals]"),tm=9e5,xd=class{constructor(e){var n;this.Et=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.$t=()=>{clearTimeout(this.kt),this.N.metrics.length!==0&&(this._instance.capture("$web_vitals",this.N.metrics.reduce(((r,i)=>L({},r,{["$web_vitals_"+i.name+"_event"]:L({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Pt=r=>{var i,s=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(R(s))qn.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var o=this.Tt();R(o)||(ee(r?.name)||ee(r?.value)?qn.error("Invalid metric received",r):this.Rt&&r.value>=this.Rt?qn.error("Ignoring metric with value >= "+this.Rt,r):(this.N.url!==o&&(this.$t(),this.kt=setTimeout(this.$t,this.flushToCaptureTimeoutMs)),R(this.N.url)&&(this.N.url=o),this.N.firstMetricTimestamp=R(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.N.metrics.push(L({},r,{$current_url:o,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.$t()))}},this.rt=()=>{var r,i,s,o,a=z.__PosthogExtensions__;R(a)||R(a.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:i,onFCP:s,onINP:o}=a.postHogWebVitalsCallbacks),r&&i&&s&&o?(this.allowedMetrics.indexOf("LCP")>-1&&r(this.Pt.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Pt.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&s(this.Pt.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&o(this.Pt.bind(this)),this.P=!0):qn.error("web vitals callbacks not loaded - not starting")},this._instance=e,this.Et=!((n=this._instance.persistence)==null||!n.props[Dg]),this.startIfEnabled()}get allowedMetrics(){var e,n,r=Ne(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return R(r)?((n=this._instance.persistence)==null?void 0:n.props[Vg])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(Ne(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get Rt(){var e=Ne(this._instance.config.capture_performance)&&rn(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:tm;return 0<e&&e<=6e4?tm:e}get isEnabled(){var e=rt?.protocol;if(e!=="http:"&&e!=="https:")return qn.info("Web Vitals are disabled on non-http/https protocols"),!1;var n=Ne(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:Xn(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return Xn(n)?n:this.Et}startIfEnabled(){this.isEnabled&&!this.P&&(qn.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var n=Ne(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=Ne(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Dg]:n}),this._instance.persistence.register({[Vg]:r})),this.Et=n,this.startIfEnabled()}it(e){var n,r;(n=z.__PosthogExtensions__)!=null&&n.postHogWebVitalsCallbacks&&e(),(r=z.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"web-vitals",(i=>{i?qn.error("failed to load script",i):e()}))}Tt(){var e=x?x.location.href:void 0;if(e){var n=this._instance.config.mask_personal_data_properties,r=this._instance.config.custom_personal_data_properties,i=n?ji([],zi,r||[]):[];return ho(e,i,go)}qn.error("Could not determine current URL")}},Kx=Pe("[Heatmaps]");function nm(t){return Ne(t)&&"clientX"in t&&"clientY"in t&&rn(t.clientX)&&rn(t.clientY)}var Ed=class{constructor(e){var n;this.Et=!1,this.P=!1,this.It=null,this.instance=e,this.Et=!((n=this.instance.persistence)==null||!n.props[ed]),this.rageclicks=new Wa(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return Ne(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 R(this.instance.config.capture_heatmaps)?R(this.instance.config.enable_heatmaps)?this.Et:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.P)return;Kx.info("starting..."),this.Ft(),this.Ct()}else{var e;clearInterval((e=this.It)!==null&&e!==void 0?e:void 0),this.Mt(),this.getAndClearBuffer()}}onRemoteConfig(e){var n=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ed]:n}),this.Et=n,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}Ot(e){this.At(e.originalEvent,"deadclick")}Ct(){this.It&&clearInterval(this.It),this.It=(function(e){return e?.visibilityState==="visible"})(A)?setInterval(this.Dt.bind(this),this.flushIntervalMilliseconds):null}Ft(){x&&A&&(this.jt=this.Dt.bind(this),Ee(x,"beforeunload",this.jt),this.Lt=e=>this.At(e||x?.event),Ee(A,"click",this.Lt,{capture:!0}),this.Nt=e=>this.Ut(e||x?.event),Ee(A,"mousemove",this.Nt,{capture:!0}),this.zt=new Za(this.instance,Px,this.Ot.bind(this)),this.zt.startIfEnabled(),this.Ht=this.Ct.bind(this),Ee(A,"visibilitychange",this.Ht),this.P=!0)}Mt(){var e;x&&A&&(this.jt&&x.removeEventListener("beforeunload",this.jt),this.Lt&&A.removeEventListener("click",this.Lt,{capture:!0}),this.Nt&&A.removeEventListener("mousemove",this.Nt,{capture:!0}),this.Ht&&A.removeEventListener("visibilitychange",this.Ht),clearTimeout(this.Bt),(e=this.zt)==null||e.stop(),this.P=!1)}qt(e,n){var r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),o=(function(a,l,u){for(var c=a;c&&al(c)&&!er(c,"body");){if(c===u)return!1;if(U(l,x?.getComputedStyle(c).position))return!0;c=$m(c)}return!1})(Im(e),["fixed","sticky"],s);return{x:e.clientX+(o?0:i),y:e.clientY+(o?0:r),target_fixed:o,type:n}}At(e,n){var r;if(n===void 0&&(n="click"),!jg(e.target)&&nm(e)){var i=this.qt(e,n);(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Wt(L({},i,{type:"rageclick"})),this.Wt(i)}}Ut(e){!jg(e.target)&&nm(e)&&(clearTimeout(this.Bt),this.Bt=setTimeout((()=>{this.Wt(this.qt(e,"mousemove"))}),500))}Wt(e){if(x){var n=x.location.href,r=this.instance.config.mask_personal_data_properties,i=this.instance.config.custom_personal_data_properties,s=r?ji([],zi,i||[]):[],o=ho(n,s,go);this.N=this.N||{},this.N[o]||(this.N[o]=[]),this.N[o].push(e)}}Dt(){this.N&&!Fi(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},Sd=class{constructor(e){this._instance=e}doPageView(e,n){var r,i=this.Gt(e,n);return this.Vt={pathname:(r=x?.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var n;return this.Gt(e,(n=this.Vt)==null?void 0:n.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Vt)==null?void 0:e.pageViewId}}Gt(e,n){var r=this.Vt;if(!r)return{$pageview_id:n};var i={$pageview_id:n,$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:u,lastContentY:c,maxContentY:d}=s;if(!(R(o)||R(a)||R(l)||R(u)||R(c)||R(d))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c),d=Math.ceil(d);var f=o<=1?1:en(a/o,0,1,O),g=o<=1?1:en(l/o,0,1,O),v=u<=1?1:en(c/u,0,1,O),y=u<=1?1:en(d/u,0,1,O);i=_e(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:v,$prev_pageview_max_content:d,$prev_pageview_max_content_percentage:y})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),i}},St=Uint8Array,Qe=Uint16Array,Vi=Uint32Array,nf=new St([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]),rf=new St([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]),rm=new St([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),mv=function(t,e){for(var n=new Qe(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];var i=new Vi(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return[n,i]},vv=mv(nf,2),Gx=vv[0],bd=vv[1];Gx[28]=258,bd[258]=28;for(Cd=mv(rf,0)[1],Qa=new Qe(32768),ie=0;ie<32768;++ie)Kn=(43690&ie)>>>1|(21845&ie)<<1,Kn=(61680&(Kn=(52428&Kn)>>>2|(13107&Kn)<<2))>>>4|(3855&Kn)<<4,Qa[ie]=((65280&Kn)>>>8|(255&Kn)<<8)>>>1;var Kn,Cd,Qa,ie,ro=function(t,e,n){for(var r=t.length,i=0,s=new Qe(e);i<r;++i)++s[t[i]-1];var o,a=new Qe(e);for(i=0;i<e;++i)a[i]=a[i-1]+s[i-1]<<1;if(n){o=new Qe(1<<e);var l=15-e;for(i=0;i<r;++i)if(t[i])for(var u=i<<4|t[i],c=e-t[i],d=a[t[i]-1]++<<c,f=d|(1<<c)-1;d<=f;++d)o[Qa[d]>>>l]=u}else for(o=new Qe(r),i=0;i<r;++i)o[i]=Qa[a[t[i]-1]++]>>>15-t[i];return o},zr=new St(288);for(ie=0;ie<144;++ie)zr[ie]=8;for(ie=144;ie<256;++ie)zr[ie]=9;for(ie=256;ie<280;++ie)zr[ie]=7;for(ie=280;ie<288;++ie)zr[ie]=8;var Xa=new St(32);for(ie=0;ie<32;++ie)Xa[ie]=5;var Zx=ro(zr,9,0),Yx=ro(Xa,5,0),yv=function(t){return(t/8>>0)+(7&t&&1)},_v=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var r=new(t instanceof Qe?Qe:t instanceof Vi?Vi:St)(n-e);return r.set(t.subarray(e,n)),r},vn=function(t,e,n){n<<=7&e;var r=e/8>>0;t[r]|=n,t[r+1]|=n>>>8},Us=function(t,e,n){n<<=7&e;var r=e/8>>0;t[r]|=n,t[r+1]|=n>>>8,t[r+2]|=n>>>16},Oc=function(t,e){for(var n=[],r=0;r<t.length;++r)t[r]&&n.push({s:r,f:t[r]});var i=n.length,s=n.slice();if(!i)return[new St(0),0];if(i==1){var o=new St(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(w,b){return w.f-b.f})),n.push({s:-1,f:25001});var a=n[0],l=n[1],u=0,c=1,d=2;for(n[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=i-1;)a=n[n[u].f<n[d].f?u++:d++],l=n[u!=c&&n[u].f<n[d].f?u++:d++],n[c++]={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 g=new Qe(f+1),v=Td(n[c-1],g,0);if(v>e){r=0;var y=0,k=v-e,h=1<<k;for(s.sort((function(w,b){return g[b.s]-g[w.s]||w.f-b.f}));r<i;++r){var p=s[r].s;if(!(g[p]>e))break;y+=h-(1<<v-g[p]),g[p]=e}for(y>>>=k;y>0;){var m=s[r].s;g[m]<e?y-=1<<e-g[m]++-1:++r}for(;r>=0&&y;--r){var _=s[r].s;g[_]==e&&(--g[_],++y)}v=e}return[new St(g),v]},Td=function(t,e,n){return t.s==-1?Math.max(Td(t.l,e,n+1),Td(t.r,e,n+1)):e[t.s]=n},im=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Qe(++e),r=0,i=t[0],s=1,o=function(l){n[r++]=l},a=1;a<=e;++a)if(t[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=t[a]}return[n.subarray(0,r),e]},Ws=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},Pd=function(t,e,n){var r=n.length,i=yv(e+2);t[i]=255&r,t[i+1]=r>>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var s=0;s<r;++s)t[i+s+4]=n[s];return 8*(i+4+r)},sm=function(t,e,n,r,i,s,o,a,l,u,c){vn(e,c++,n),++i[256];for(var d=Oc(i,15),f=d[0],g=d[1],v=Oc(s,15),y=v[0],k=v[1],h=im(f),p=h[0],m=h[1],_=im(y),w=_[0],b=_[1],S=new Qe(19),E=0;E<p.length;++E)S[31&p[E]]++;for(E=0;E<w.length;++E)S[31&w[E]]++;for(var j=Oc(S,7),F=j[0],Y=j[1],te=19;te>4&&!F[rm[te-1]];--te);var K,Q,ke,Oe,xe=u+5<<3,be=Ws(i,zr)+Ws(s,Xa)+o,Ce=Ws(i,f)+Ws(s,y)+o+14+3*te+Ws(S,F)+(2*S[16]+3*S[17]+7*S[18]);if(xe<=be&&xe<=Ce)return Pd(e,c,t.subarray(l,l+u));if(vn(e,c,1+(Ce<be)),c+=2,Ce<be){K=ro(f,g,0),Q=f,ke=ro(y,k,0),Oe=y;var Xt=ro(F,Y,0);for(vn(e,c,m-257),vn(e,c+5,b-1),vn(e,c+10,te-4),c+=14,E=0;E<te;++E)vn(e,c+3*E,F[rm[E]]);c+=3*te;for(var Pi=[p,w],Ge=0;Ge<2;++Ge){var kt=Pi[Ge];for(E=0;E<kt.length;++E){var ft=31&kt[E];vn(e,c,Xt[ft]),c+=F[ft],ft>15&&(vn(e,c,kt[E]>>>5&127),c+=kt[E]>>>12)}}}else K=Zx,Q=zr,ke=Yx,Oe=Xa;for(E=0;E<a;++E)if(r[E]>255){ft=r[E]>>>18&31,Us(e,c,K[ft+257]),c+=Q[ft+257],ft>7&&(vn(e,c,r[E]>>>23&31),c+=nf[ft]);var Ri=31&r[E];Us(e,c,ke[Ri]),c+=Oe[Ri],Ri>3&&(Us(e,c,r[E]>>>5&8191),c+=rf[Ri])}else Us(e,c,K[r[E]]),c+=Q[r[E]];return Us(e,c,K[256]),c+Q[256]},Qx=new Vi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Xx=(function(){for(var t=new Vi(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t})(),Jx=function(t,e,n,r,i){return(function(s,o,a,l,u,c){var d=s.length,f=new St(l+d+5*(1+Math.floor(d/7e3))+u),g=f.subarray(l,f.length-u),v=0;if(!o||d<8)for(var y=0;y<=d;y+=65535){var k=y+65535;k<d?v=Pd(g,v,s.subarray(y,k)):(g[y]=c,v=Pd(g,v,s.subarray(y,d)))}else{for(var h=Qx[o-1],p=h>>>13,m=8191&h,_=(1<<a)-1,w=new Qe(32768),b=new Qe(_+1),S=Math.ceil(a/3),E=2*S,j=function(xc){return(s[xc]^s[xc+1]<<S^s[xc+2]<<E)&_},F=new Vi(25e3),Y=new Qe(288),te=new Qe(32),K=0,Q=0,ke=(y=0,0),Oe=0,xe=0;y<d;++y){var be=j(y),Ce=32767&y,Xt=b[be];if(w[Ce]=Xt,b[be]=Ce,Oe<=y){var Pi=d-y;if((K>7e3||ke>24576)&&Pi>423){v=sm(s,g,0,F,Y,te,Q,ke,xe,y-xe,v),ke=K=Q=0,xe=y;for(var Ge=0;Ge<286;++Ge)Y[Ge]=0;for(Ge=0;Ge<30;++Ge)te[Ge]=0}var kt=2,ft=0,Ri=m,Bn=Ce-Xt&32767;if(Pi>2&&be==j(y-Bn))for(var Pk=Math.min(p,Pi)-1,Rk=Math.min(32767,y),Ak=Math.min(258,Pi);Bn<=Rk&&--Ri&&Ce!=Xt;){if(s[y+kt]==s[y+kt-Bn]){for(var Un=0;Un<Ak&&s[y+Un]==s[y+Un-Bn];++Un);if(Un>kt){if(kt=Un,ft=Bn,Un>Pk)break;var Ok=Math.min(Bn,Un-2),vg=0;for(Ge=0;Ge<Ok;++Ge){var kc=y-Bn+Ge+32768&32767,yg=kc-w[kc]+32768&32767;yg>vg&&(vg=yg,Xt=kc)}}}Bn+=(Ce=Xt)-(Xt=w[Ce])+32768&32767}if(ft){F[ke++]=268435456|bd[kt]<<18|Cd[ft];var _g=31&bd[kt],wg=31&Cd[ft];Q+=nf[_g]+rf[wg],++Y[257+_g],++te[wg],Oe=y+kt,++K}else F[ke++]=s[y],++Y[s[y]]}}v=sm(s,g,c,F,Y,te,Q,ke,xe,y-xe,v)}return _v(f,0,l+yv(v)+u)})(t,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,n,r,!0)},Nc=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function eE(t,e){e===void 0&&(e={});var n=(function(){var a=4294967295;return{p:function(l){for(var u=a,c=0;c<l.length;++c)u=Xx[255&u^l[c]]^u>>>8;a=u},d:function(){return 4294967295^a}}})(),r=t.length;n.p(t);var i,s=Jx(t,e,10+((i=e).filename&&i.filename.length+1||0),8),o=s.length;return(function(a,l){var u=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&&Nc(a,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),u){a[3]=8;for(var c=0;c<=u.length;++c)a[c+10]=u.charCodeAt(c)}})(s,e),Nc(s,o-8,n.d()),Nc(s,o-4,r),s}var tE=function(t){var e,n,r,i,s="";for(e=n=0,r=(t=(t+"").replace(/\r\n/g,`
|
|
135
135
|
`).replace(/\r/g,`
|
|
136
|
-
`)).length,i=0;i<r;i++){var o=t.charCodeAt(i),a=null;o<128?n++: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),xn(a)||(n>e&&(s+=t.substring(e,n)),s+=a,e=n=i+1)}return n>e&&(s+=t.substring(e,t.length)),s},nE=!!Vc||!!Dc,om="text/plain",Ja=function(t,e,n){var r;n===void 0&&(n=!0);var[i,s]=t.split("?"),o=L({},e),a=(r=s?.split("&").map((u=>{var c,[d,f]=u.split("="),g=n&&(c=o[d])!==null&&c!==void 0?c:f;return delete o[d],d+"="+g})))!==null&&r!==void 0?r:[],l=_x(o);return l&&a.push(l),i+"?"+a.join("&")},to=(t,e)=>JSON.stringify(t,((n,r)=>typeof r=="bigint"?r.toString():r),e),Fc=t=>{var{data:e,compression:n}=t;if(e){if(n===kn.GZipJS){var r=eE((function(l,u){var c=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var d=new St(l.length+(l.length>>>1)),f=0,g=function(h){d[f++]=h},v=0;v<c;++v){if(f+5>d.length){var y=new St(f+8+(c-v<<1));y.set(d),d=y}var k=l.charCodeAt(v);k<128||u?g(k):k<2048?(g(192|k>>>6),g(128|63&k)):k>55295&&k<57344?(g(240|(k=65536+(1047552&k)|1023&l.charCodeAt(++v))>>>18),g(128|k>>>12&63),g(128|k>>>6&63),g(128|63&k)):(g(224|k>>>12),g(128|k>>>6&63),g(128|63&k))}return _v(d,0,f)})(to(e)),{mtime:0}),i=new Blob([r],{type:om});return{contentType:om,body:i,estimatedSize:i.size}}if(n===kn.Base64){var s=(function(l){var u,c,d,f,g,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",y=0,k=0,h="",p=[];if(!l)return l;l=tE(l);do u=(g=l.charCodeAt(y++)<<16|l.charCodeAt(y++)<<8|l.charCodeAt(y++))>>18&63,c=g>>12&63,d=g>>6&63,f=63&g,p[k++]=v.charAt(u)+v.charAt(c)+v.charAt(d)+v.charAt(f);while(y<l.length);switch(h=p.join(""),l.length%3){case 1:h=h.slice(0,-2)+"==";break;case 2:h=h.slice(0,-1)+"="}return h})(to(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:to(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=to(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},Ma=[];Dc&&Ma.push({transport:"fetch",method:t=>{var e,n,{contentType:r,body:i,estimatedSize:s}=(e=Fc(t))!==null&&e!==void 0?e:{},o=new Headers;re(t.headers,(function(c,d){o.append(d,c)})),r&&o.append("Content-Type",r);var a=t.url,l=null;if(Cg){var u=new Cg;l={signal:u.signal,timeout:setTimeout((()=>u.abort()),t.timeout)}}Dc(a,L({method:t?.method||"GET",headers:o,keepalive:t.method==="POST"&&(s||0)<52428.8,body:i,signal:(n=l)==null?void 0:n.signal},t.fetchOptions)).then((c=>c.text().then((d=>{var f={statusCode:c.status,text:d};if(c.status===200)try{f.json=JSON.parse(d)}catch(g){O.error(g)}t.callback==null||t.callback(f)})))).catch((c=>{O.error(c),t.callback==null||t.callback({statusCode:0,text:c})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Vc&&Ma.push({transport:"XHR",method:t=>{var e,n=new Vc;n.open(t.method||"GET",t.url,!0);var{contentType:r,body:i}=(e=Fc(t))!==null&&e!==void 0?e:{};re(t.headers,(function(s,o){n.setRequestHeader(o,s)})),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),t.disableXHRCredentials||(n.withCredentials=!0),n.onreadystatechange=()=>{if(n.readyState===4){var s={statusCode:n.status,text:n.responseText};if(n.status===200)try{s.json=JSON.parse(n.responseText)}catch{}t.callback==null||t.callback(s)}},n.send(i)}}),pt!=null&&pt.sendBeacon&&Ma.push({transport:"sendBeacon",method:t=>{var e=Ja(t.url,{beacon:"1"});try{var n,{contentType:r,body:i}=(n=Fc(t))!==null&&n!==void 0?n:{},s=typeof i=="string"?new Blob([i],{type:r}):i;pt.sendBeacon(e,s)}catch{}}});var el=function(t,e){if(!(function(n){try{new RegExp(n)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};function am(t,e,n){return to({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var wv={exact:(t,e)=>e.some((n=>t.some((r=>n===r)))),is_not:(t,e)=>e.every((n=>t.every((r=>n!==r)))),regex:(t,e)=>e.some((n=>t.some((r=>el(n,r))))),not_regex:(t,e)=>e.every((n=>t.every((r=>!el(n,r))))),icontains:(t,e)=>e.map(La).some((n=>t.map(La).some((r=>n.includes(r))))),not_icontains:(t,e)=>e.map(La).every((n=>t.map(La).every((r=>!n.includes(r)))))},La=t=>t.toLowerCase();function kv(t,e){return!t||Object.entries(t).every((n=>{var[r,i]=n,s=e?.[r];if(R(s)||xn(s))return!1;var o=[String(s)],a=wv[i.operator];return!!a&&a(i.values,o)}))}var Lc=Pe("[Error tracking]"),Rd=class{constructor(e){var n,r;this.Jt=[],this.Kt=new Uc([new qc,new Jc,new Gc,new Kc,new Qc,new Yc,new Zc,new Xc],tx("web:javascript",Qk,ex)),this._instance=e,this.Jt=(n=(r=this._instance.persistence)==null?void 0:r.get_property(td))!==null&&n!==void 0?n:[]}onRemoteConfig(e){var n,r,i,s=(n=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&n!==void 0?n:[],o=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Jt=s,this._instance.persistence&&this._instance.persistence.register({[td]:this.Jt,[$g]:o})}get Yt(){var e,n=!!this._instance.get_property($g),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??n)!==null&&e!==void 0&&e}buildProperties(e,n){return this.Kt.buildFromUnknown(e,{syntheticException:n?.syntheticException,mechanism:{handled:n?.handled}})}sendExceptionEvent(e){var n=e.$exception_list;if(this.Xt(n)){if(this.Qt(n))return void Lc.info("Skipping exception capture because a suppression rule matched");if(!this.Yt&&this.Zt(n))return void Lc.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ti(n))return void Lc.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}Qt(e){if(e.length===0)return!1;var n=e.reduce(((r,i)=>{var{type:s,value:o}=i;return Te(s)&&s.length>0&&r.$exception_types.push(s),Te(o)&&o.length>0&&r.$exception_values.push(o),r}),{$exception_types:[],$exception_values:[]});return this.Jt.some((r=>{var i=r.values.map((s=>{var o,a=wv[s.operator],l=ne(s.value)?s.value:[s.value],u=(o=n[s.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,u)}));return r.type==="OR"?i.some(Boolean):i.every(Boolean)}))}Zt(e){return e.flatMap((n=>{var r,i;return(r=(i=n.stacktrace)==null?void 0:i.frames)!==null&&r!==void 0?r:[]})).some((n=>n.filename&&n.filename.startsWith("chrome-extension://")))}ti(e){if(e.length>0){var n,r,i,s,o=(n=(r=e[0].stacktrace)==null?void 0:r.frames)!==null&&n!==void 0?n:[],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}Xt(e){return!ee(e)&&ne(e)}},Dt=Pe("[FeatureFlags]"),qs=Pe("[FeatureFlags]",{debugEnabled:!0}),Ic="$active_feature_flags",Ai="$override_feature_flags",lm="$feature_flag_payloads",Ks="$override_feature_flag_payloads",um="$feature_flag_request_id",cm="$feature_flag_evaluated_at",dm=t=>{var e={};for(var[n,r]of Ia(t||{}))r&&(e[n]=r);return e},rE=t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map((n=>{var r;return[n,(r=e[n].variant)!==null&&r!==void 0?r:e[n].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((n=>e[n].enabled)).filter((n=>{var r;return(r=e[n].metadata)==null?void 0:r.payload})).map((n=>{var r;return[n,(r=e[n].metadata)==null?void 0:r.payload]})))):Dt.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t},iE=(function(t){return t.FeatureFlags="feature_flags",t.Recordings="recordings",t})({}),Ad=class{constructor(e){this.ii=!1,this.ei=!1,this.ri=!1,this.si=!1,this.ni=!1,this.oi=!1,this.ai=!1,this._instance=e,this.featureFlagEventHandlers=[]}li(){var e=this._instance.config.evaluation_environments;return e!=null&&e.length?e.filter((n=>{var r=n&&typeof n=="string"&&n.trim().length>0;return r||Dt.error("Invalid evaluation environment found:",n,"Expected non-empty string"),r})):[]}ui(){return this.li().length>0}flags(){if(this._instance.config.__preview_remote_config)this.oi=!0;else{var e=!this.hi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.vi({disableFlags:e})}}get hasLoadedFlags(){return this.ei}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(nd),n=this._instance.get_property(Ai),r=this._instance.get_property(Ks);if(!r&&!n)return e||{};var i=_e({},e||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(n||{})])];for(var o of s){var a,l,u=i[o],c=n?.[o],d=R(c)?(a=u?.enabled)!==null&&a!==void 0&&a:!!c,f=R(c)?u.variant:typeof c=="string"?c:void 0,g=r?.[o],v=L({},u,{enabled:d,variant:d?f??u?.variant:void 0});d!==u?.enabled&&(v.original_enabled=u?.enabled),f!==u?.variant&&(v.original_variant=u?.variant),g&&(v.metadata=L({},u?.metadata,{payload:g,original_payload:u==null||(l=u.metadata)==null?void 0:l.payload})),i[o]=v}return this.ii||(Dt.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.ii=!0),i}getFlagVariants(){var e=this._instance.get_property(Li),n=this._instance.get_property(Ai);if(!n)return e||{};for(var r=_e({},e),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this.ii||(Dt.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:n,finalFlags:r}),this.ii=!0),r}getFlagPayloads(){var e=this._instance.get_property(lm),n=this._instance.get_property(Ks);if(!n)return e||{};for(var r=_e({},e||{}),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this.ii||(Dt.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:n,finalPayloads:r}),this.ii=!0),r}reloadFeatureFlags(){this.si||this._instance.config.advanced_disable_feature_flags||this.hi||(this.hi=setTimeout((()=>{this.vi()}),5))}di(){clearTimeout(this.hi),this.hi=void 0}ensureFlagsLoaded(){this.ei||this.ri||this.hi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.si=e}vi(e){var n;if(this.di(),!this._instance.O())if(this.ri)this.ni=!0;else{var r={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:L({},((n=this._instance.persistence)==null?void 0:n.get_initial_props())||{},this._instance.get_property(Js)||{}),group_properties:this._instance.get_property(Vr)};(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.ui()&&(r.evaluation_environments=this.li());var i=this._instance.config.__preview_remote_config,s=i?"/flags/?v=2":"/flags/?v=2&config=true",o=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",a=this._instance.requestRouter.endpointFor("flags",s+o);i&&(r.timezone=gv()),this.ri=!0,this._instance.ci({method:"POST",url:a,data:r,compression:this._instance.config.disable_compression?void 0:kn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:l=>{var u,c,d=!0;if(l.statusCode===200&&(this.ni||(this.$anon_distinct_id=void 0),d=!1),this.ri=!1,this.oi||(this.oi=!0,this._instance.fi((c=l.json)!==null&&c!==void 0?c:{})),!r.disable_flags||this.ni)if(this.ai=!d,l.json&&(u=l.json.quotaLimited)!=null&&u.includes(iE.FeatureFlags))Dt.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 f;r.disable_flags||this.receivedFeatureFlags((f=l.json)!==null&&f!==void 0?f:{},d),this.ni&&(this.ni=!1,this.vi())}}})}}getFeatureFlag(e,n){if(n===void 0&&(n={}),this.ei||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants()[e],i=""+r,s=this._instance.get_property(um)||void 0,o=this._instance.get_property(cm)||void 0,a=this._instance.get_property(za)||{};if((n.send_event||!("send_event"in n))&&(!(e in a)||!a[e].includes(i))){var l,u,c,d,f,g,v,y,k;ne(a[e])?a[e].push(i):a[e]=[i],(l=this._instance.persistence)==null||l.register({[za]:a});var h=this.getFeatureFlagDetails(e),p={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:s,$feature_flag_evaluated_at:o,$feature_flag_bootstrapped_response:((u=this._instance.config.bootstrap)==null||(u=u.featureFlags)==null?void 0:u[e])||null,$feature_flag_bootstrapped_payload:((c=this._instance.config.bootstrap)==null||(c=c.featureFlagPayloads)==null?void 0:c[e])||null,$used_bootstrap_value:!this.ai};R(h==null||(d=h.metadata)==null?void 0:d.version)||(p.$feature_flag_version=h.metadata.version);var m,_=(f=h==null||(g=h.reason)==null?void 0:g.description)!==null&&f!==void 0?f:h==null||(v=h.reason)==null?void 0:v.code;_&&(p.$feature_flag_reason=_),h!=null&&(y=h.metadata)!=null&&y.id&&(p.$feature_flag_id=h.metadata.id),R(h?.original_variant)&&R(h?.original_enabled)||(p.$feature_flag_original_response=R(h.original_variant)?h.original_enabled:h.original_variant),h!=null&&(k=h.metadata)!=null&&k.original_payload&&(p.$feature_flag_original_payload=h==null||(m=h.metadata)==null?void 0:m.original_payload),this._instance.capture("$feature_flag_called",p)}return r}Dt.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,n){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.ui()&&(i.evaluation_environments=this.li()),this._instance.ci({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:kn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var o,a=(o=s.json)==null?void 0:o.featureFlagPayloads;n(a?.[e]||void 0)}})}isFeatureEnabled(e,n){if(n===void 0&&(n={}),this.ei||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,n);return R(r)?void 0:!!r}Dt.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((n=>n!==e))}receivedFeatureFlags(e,n){if(this._instance.persistence){this.ei=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(o,a,l,u,c){l===void 0&&(l={}),u===void 0&&(u={}),c===void 0&&(c={});var d=rE(o),f=d.flags,g=d.featureFlags,v=d.featureFlagPayloads;if(g){var y=o.requestId,k=o.evaluatedAt;if(ne(g)){Dt.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var h={};if(g)for(var p=0;p<g.length;p++)h[g[p]]=!0;a&&a.register({[Ic]:g,[Li]:h})}else{var m=g,_=v,w=f;o.errorsWhileComputingFlags&&(m=L({},l,m),_=L({},u,_),w=L({},c,w)),a&&a.register(L({[Ic]:Object.keys(dm(m)),[Li]:m||{},[lm]:_||{},[nd]:w||{}},y?{[um]:y}:{},k?{[cm]:k}:{}))}}})(e,this._instance.persistence,r,i,s),this.pi(n)}}override(e,n){n===void 0&&(n=!1),Dt.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:n})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return Dt.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(Ai),this._instance.persistence.unregister(Ks),this.pi(),qs.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n,r=e;if(this.ii=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(Ai),qs.info("Flag overrides cleared");else if(r.flags){if(ne(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[Ai]:i})}else this._instance.persistence.register({[Ai]:r.flags});qs.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(Ks),qs.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[Ks]:r.payloads}),qs.info("Payload overrides set",{payloads:r.payloads}))),void this.pi()}this.pi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ei){var{flags:n,flagVariants:r}=this.gi();e(n,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,n,r){var i,s=(this._instance.get_property(Xs)||[]).find((u=>u.flagKey===e)),o={["$feature_enrollment/"+e]:n},a={$feature_flag:e,$feature_enrollment:n,$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=L({},this.getFlagVariants(),{[e]:n});(i=this._instance.persistence)==null||i.register({[Ic]:Object.keys(dm(l)),[Li]:l}),this.pi()}getEarlyAccessFeatures(e,n,r){n===void 0&&(n=!1);var i=this._instance.get_property(Xs),s=r?"&"+r.map((o=>"stage="+o)).join("&"):"";if(i&&!n)return e(i);this._instance.ci({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 u=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(Xs),(l=this._instance.persistence)==null||l.register({[Xs]:u}),e(u)}}})}gi(){var e=this.getFlags(),n=this.getFlagVariants();return{flags:e.filter((r=>n[r])),flagVariants:Object.keys(n).filter((r=>n[r])).reduce(((r,i)=>(r[i]=n[i],r)),{})}}pi(e){var{flags:n,flagVariants:r}=this.gi();this.featureFlagEventHandlers.forEach((i=>i(n,r,{errorsLoading:e})))}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Js)||{};this._instance.register({[Js]:L({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Js)}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Vr)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=L({},r[i],e[i]),delete e[i]})),this._instance.register({[Vr]:L({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var n=this._instance.get_property(Vr)||{};this._instance.register({[Vr]:L({},n,{[e]:{}})})}else this._instance.unregister(Vr)}reset(){this.ei=!1,this.ri=!1,this.si=!1,this.ni=!1,this.oi=!1,this.ai=!1,this.$anon_distinct_id=void 0,this.di(),this.ii=!1}},sE=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],io=class{constructor(e,n){this.F=e,this.props={},this.mi=!1,this.yi=(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.bi(e),this.load(),e.debug&&O.info("Persistence loaded",e.persistence,L({},this.props)),this.update_config(e,e,n),this.save()}isDisabled(){return!!this.wi}bi(e){sE.indexOf(e.persistence.toLowerCase())===-1&&(O.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n=e.persistence.toLowerCase();return n==="localstorage"&&pe.H()?pe:n==="localstorage+cookie"&&Aa.H()?Aa:n==="sessionstorage"&&Ie.H()?Ie:n==="memory"?Tx:n==="cookie"?nn:Aa.H()?Aa:nn}properties(){var e={};return re(this.props,(function(n,r){if(r===Li&&Ne(n))for(var i=Object.keys(n),s=0;s<i.length;s++)e["$feature/"+i[s]]=n[i[s]];else a=r,l=!1,(xn(o=ux)?l:bg&&o.indexOf===bg?o.indexOf(a)!=-1:(re(o,(function(u){if(l||(l=u===a))return Va})),l))||(e[r]=n);var o,a,l})),e}load(){if(!this.wi){var e=this.Y.W(this.yi);e&&(this.props=_e({},e))}}save(){this.wi||this.Y.G(this.yi,this.props,this.xi,this.Si,this.Ei,this.F.debug)}remove(){this.Y.V(this.yi,!1),this.Y.V(this.yi,!0)}clear(){this.remove(),this.props={}}register_once(e,n,r){if(Ne(e)){R(n)&&(n="None"),this.xi=R(r)?this.$i:r;var i=!1;if(re(e,((s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==n||(this.props[o]=s,i=!0)})),i)return this.save(),!0}return!1}register(e,n){if(Ne(e)){this.xi=R(n)?this.$i:n;var r=!1;if(re(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.mi){var e=uv(this.F.custom_campaign_params,this.F.mask_personal_data_properties,this.F.custom_personal_data_properties);Fi(Gd(e))||this.register(e),this.mi=!0}}update_search_keyword(){var e;this.register((e=A?.referrer)?dv(e):{})}update_referrer_info(){var e;this.register_once({$referrer:fv(),$referring_domain:A!=null&&A.referrer&&((e=qa(A.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[od]||this.props[ad]||this.register_once({[Ha]:pv(this.F.mask_personal_data_properties,this.F.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};re([ad,od],(o=>{var a=this.props[o];a&&re(a,(function(l,u){e["$initial_"+jc(u)]=l}))}));var n,r,i=this.props[Ha];if(i){var s=(n=hv(i),r={},re(n,(function(o,a){r["$initial_"+jc(a)]=o})),r);_e(e,s)}return e}safe_merge(e){return re(this.props,(function(n,r){r in e||(e[r]=n)})),e}update_config(e,n,r){if(this.$i=this.xi=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!==n.persistence){var i=this.bi(e),s=this.props;this.clear(),this.Y=i,this.props=s,this.save()}}set_disabled(e){this.wi=e,this.wi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Si&&(this.Si=e,this.remove(),this.save())}set_secure(e){e!==this.Ei&&(this.Ei=e,this.remove(),this.save())}set_event_timer(e,n){var r=this.props[Qs]||{};r[e]=n,this.props[Qs]=r,this.save()}remove_event_timer(e){var n=(this.props[Qs]||{})[e];return R(n)||(delete this.props[Qs][e],this.save()),n}get_property(e){return this.props[e]}set_property(e,n){this.props[e]=n,this.save()}},Gs=(function(t){return t.Activation="events",t.Cancellation="cancelEvents",t})({}),uR=(function(t){return t.Button="button",t.Tab="tab",t.Selector="selector",t})({}),cR=(function(t){return t.TopLeft="top_left",t.TopRight="top_right",t.TopCenter="top_center",t.MiddleLeft="middle_left",t.MiddleRight="middle_right",t.MiddleCenter="middle_center",t.Left="left",t.Center="center",t.Right="right",t.NextToTrigger="next_to_trigger",t})({}),dR=(function(t){return t.Top="top",t.Left="left",t.Right="right",t.Bottom="bottom",t})({}),Mc=(function(t){return t.Popover="popover",t.API="api",t.Widget="widget",t.ExternalSurvey="external_survey",t})({}),fR=(function(t){return t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link",t})({}),pR=(function(t){return t.NextQuestion="next_question",t.End="end",t.ResponseBased="response_based",t.SpecificQuestion="specific_question",t})({}),hR=(function(t){return t.Once="once",t.Recurring="recurring",t.Always="always",t})({}),$a=(function(t){return t.SHOWN="survey shown",t.DISMISSED="survey dismissed",t.SENT="survey sent",t})({}),fm=(function(t){return t.SURVEY_ID="$survey_id",t.SURVEY_NAME="$survey_name",t.SURVEY_RESPONSE="$survey_response",t.SURVEY_ITERATION="$survey_iteration",t.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",t.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",t.SURVEY_SUBMISSION_ID="$survey_submission_id",t.SURVEY_QUESTIONS="$survey_questions",t.SURVEY_COMPLETED="$survey_completed",t})({}),xv=(function(t){return t.Popover="popover",t.Inline="inline",t})({}),fo=class{constructor(){this.ki={},this.ki={}}on(e,n){return this.ki[e]||(this.ki[e]=[]),this.ki[e].push(n),()=>{this.ki[e]=this.ki[e].filter((r=>r!==n))}}emit(e,n){for(var r of this.ki[e]||[])r(n);for(var i of this.ki["*"]||[])i(e,n)}};function Oi(t,e,n){if(ee(t))return!1;switch(n){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}var Od=class{constructor(e){this.Pi=new fo,this.Ti=(n,r)=>this.Ri(n,r)&&this.Ii(n,r)&&this.Fi(n,r)&&this.Ci(n,r),this.Ri=(n,r)=>r==null||!r.event||n?.event===r?.event,this._instance=e,this.Mi=new Set,this.Oi=new Set}init(){var e;if(!R((e=this._instance)==null?void 0:e.Ai)){var n;(n=this._instance)==null||n.Ai(((r,i)=>{this.on(r,i)}))}}register(e){var n,r;if(!R((n=this._instance)==null?void 0:n.Ai)&&(e.forEach((o=>{var a,l;(a=this.Oi)==null||a.add(o),(l=o.steps)==null||l.forEach((u=>{var c;(c=this.Mi)==null||c.add(u?.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,n){var r;n!=null&&e.length!=0&&(this.Mi.has(e)||this.Mi.has(n?.event))&&this.Oi&&((r=this.Oi)==null?void 0:r.size)>0&&this.Oi.forEach((i=>{this.Di(n,i)&&this.Pi.emit("actionCaptured",i.name)}))}ji(e){this.onAction("actionCaptured",(n=>e(n)))}Di(e,n){if(n?.steps==null)return!1;for(var r of n.steps)if(this.Ti(e,r))return!0;return!1}onAction(e,n){return this.Pi.on(e,n)}Ii(e,n){if(n!=null&&n.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!Oi(i,n.url,n.url_matching||"contains"))return!1}return!0}Fi(e,n){return!!this.Li(e,n)&&!!this.Ni(e,n)&&!!this.Ui(e,n)}Li(e,n){var r;if(n==null||!n.href)return!0;var i=this.zi(e);if(i.length>0)return i.some((a=>Oi(a.href,n.href,n.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&Oi((s=o.match(/(?::|")href="(.*?)"/))?s[1]:"",n.href,n.href_matching||"exact")}Ni(e,n){var r;if(n==null||!n.text)return!0;var i=this.zi(e);if(i.length>0)return i.some((u=>Oi(u.text,n.text,n.text_matching||"exact")||Oi(u.$el_text,n.text,n.text_matching||"exact")));var s,o,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(s=(function(u){for(var c,d=[],f=/(?::|")text="(.*?)"/g;!ee(c=f.exec(u));)d.includes(c[1])||d.push(c[1]);return d})(l),o=n.text,a=n.text_matching||"exact",s.some((u=>Oi(u,o,a))))}Ui(e,n){var r,i;if(n==null||!n.selector)return!0;var s=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(s!=null&&s.includes(n.selector))return!0;var o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(n.selector_regex&&o)try{return new RegExp(n.selector_regex).test(o)}catch{return!1}return!1}zi(e){var n;return(e==null||(n=e.properties)==null?void 0:n.$elements)==null?[]:e?.properties.$elements}Ci(e,n){return n==null||!n.properties||n.properties.length===0||kv(n.properties.reduce(((r,i)=>{var s=ne(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)}},X=Pe("[Surveys]"),Nd="seenSurvey_",oE=(t,e)=>{var n="$survey_"+e+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(n="$survey_"+e+"/"+t.id+"/"+t.current_iteration),n},pm=t=>{var e=""+Nd+t.id;return t.current_iteration&&t.current_iteration>0&&(e=""+Nd+t.id+"_"+t.current_iteration),e},aE=[Mc.Popover,Mc.Widget,Mc.API],lE={ignoreConditions:!1,ignoreDelay:!1,displayType:xv.Popover},Fd=class{constructor(e){this._instance=e,this.Hi=new Map,this.Bi=new Map,this.qi=new Map}Wi(e,n){return!!e&&kv(e.propertyFilters,n?.properties)}Gi(e,n){var r=new Map;return e.forEach((i=>{var s;(s=i.conditions)==null||(s=s[n])==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}Vi(e,n,r){var i,s=(r===Gs.Activation?this.Hi:this.Bi).get(e),o=[];return(i=this._instance)==null||i.getSurveys((a=>{o=a.filter((l=>s?.includes(l.id)))})),o.filter((a=>{var l,u=(l=a.conditions)==null||(l=l[r])==null||(l=l.values)==null?void 0:l.find((c=>c.name===e));return this.Wi(u,n)}))}register(e){var n;R((n=this._instance)==null?void 0:n.Ai)||(this.Ji(e),this.Ki(e))}Ki(e){var n=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}));n.length!==0&&(this.Yi==null&&(this.Yi=new Od(this._instance),this.Yi.init(),this.Yi.ji((r=>{this.onAction(r)}))),n.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.Yi)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((u=>{if(u&&u.name){var c=this.qi.get(u.name);c&&c.push(r.id),this.qi.set(u.name,c||[r.id])}})))})))}Ji(e){var n,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)&&((n=this._instance)==null||n.Ai(((s,o)=>{this.onEvent(s,o)})),this.Hi=this.Gi(e,Gs.Activation),this.Bi=this.Gi(e,Gs.Cancellation))}onEvent(e,n){var r,i=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[Ra])||[];if($a.SHOWN===e&&n&&i.length>0){var s;X.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:n,existingActivatedSurveys:i});var o=n==null||(s=n.properties)==null?void 0:s.$survey_id;if(o){var a=i.indexOf(o);a>=0&&(i.splice(a,1),this.Xi(i))}}else{if(this.Bi.has(e)){var l=this.Vi(e,n,Gs.Cancellation);l.length>0&&(X.info("cancel event matched, cancelling surveys",{event:e,surveysToCancel:l.map((c=>c.id))}),l.forEach((c=>{var d,f=i.indexOf(c.id);f>=0&&i.splice(f,1),(d=this._instance)==null||d.cancelPendingSurvey(c.id)})),this.Xi(i))}if(this.Hi.has(e)){X.info("survey event name matched",{event:e,eventPayload:n,surveys:this.Hi.get(e)});var u=this.Vi(e,n,Gs.Activation);this.Xi(i.concat(u.map((c=>c.id))||[]))}}}onAction(e){var n,r=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[Ra])||[];this.qi.has(e)&&this.Xi(r.concat(this.qi.get(e)||[]))}Xi(e){var n;X.info("updating activated surveys",{activatedSurveys:e}),(n=this._instance)==null||(n=n.persistence)==null||n.register({[Ra]:[...new Set(e)]})}getSurveys(){var e,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[Ra];return n||[]}getEventToSurveys(){return this.Hi}Qi(){return this.Yi}},Ld=class{constructor(e){this.Zi=void 0,this._surveyManager=null,this.te=!1,this.ie=!1,this.ee=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var n=e.surveys;if(ee(n))return X.warn("Flags not loaded yet. Not loading surveys.");var r=ne(n);this.Zi=r?n.length>0:n,X.info("flags response received, isSurveysEnabled: "+this.Zi),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(Nd)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.ie)X.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)X.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())X.info("Not loading surveys in cookieless mode without consent.");else{var e=z?.__PosthogExtensions__;if(e){if(!R(this.Zi)||this._instance.config.advanced_enable_surveys){var n=this.Zi||this._instance.config.advanced_enable_surveys;this.ie=!0;try{var r=e.generateSurveys;if(r)return void this.re(r,n);var i=e.loadExternalDependency;if(!i)return void this.se("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",(s=>{s||!e.generateSurveys?this.se("Could not load surveys script",s):this.re(e.generateSurveys,n)}))}catch(s){throw this.se("Error initializing surveys",s),s}finally{this.ie=!1}}}else X.error("PostHog Extensions not found.")}}re(e,n){this._surveyManager=e(this._instance,n),this._surveyEventReceiver=new Fd(this._instance),X.info("Surveys loaded successfully"),this.ne({isLoaded:!0})}se(e,n){X.error(e,n),this.ne({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.ee.push(e),this._surveyManager&&this.ne({isLoaded:!0}),()=>{this.ee=this.ee.filter((n=>n!==e))}}getSurveys(e,n){if(n===void 0&&(n=!1),this._instance.config.disable_surveys)return X.info("Disabled. Not loading surveys."),e([]);var r=this._instance.get_property(rd);if(r&&!n)return e(r,{isLoaded:!0});if(this.te)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this.te=!0,this._instance.ci({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:i=>{var s;this.te=!1;var o=i.statusCode;if(o!==200||!i.json){var a="Surveys API could not be loaded, status: "+o;return X.error(a),e([],{isLoaded:!1,error:a})}var l,u=i.json.surveys||[],c=u.filter((d=>(function(f){return!(!f.start_date||f.end_date)})(d)&&((function(f){var g;return!((g=f.conditions)==null||(g=g.events)==null||(g=g.values)==null||!g.length)})(d)||(function(f){var g;return!((g=f.conditions)==null||(g=g.actions)==null||(g=g.values)==null||!g.length)})(d))));return c.length>0&&((l=this._surveyEventReceiver)==null||l.register(c)),(s=this._instance.persistence)==null||s.register({[rd]:u}),e(u,{isLoaded:!0})}})}catch(i){throw this.te=!1,i}}ne(e){for(var n of this.ee)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(r){X.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,n){if(n===void 0&&(n=!1),!ee(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);X.warn("init was not called")}oe(e){var n=null;return this.getSurveys((r=>{var i;n=(i=r.find((s=>s.id===e)))!==null&&i!==void 0?i:null})),n}ae(e){if(ee(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var n=typeof e=="string"?this.oe(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(ee(this._surveyManager))return X.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=this.ae(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return ee(this._surveyManager)?(X.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.ae(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})}),n)}))}renderSurvey(e,n){var r;if(ee(this._surveyManager))X.warn("init was not called");else{var i=typeof e=="string"?this.oe(e):e;if(i!=null&&i.id)if(aE.includes(i.type)){var s=A?.querySelector(n);if(s)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?(X.info("Rendering survey "+i.id+" with delay of "+i.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;X.info("Rendering survey "+i.id+" with delay of "+((o=i.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(i,s),X.info("Survey "+i.id+" rendered")}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,s);X.warn("Survey element not found")}else X.warn("Surveys of type "+i.type+" cannot be rendered in the app");else X.warn("Survey not found")}}displaySurvey(e,n){var r;if(ee(this._surveyManager))X.warn("init was not called");else{var i=this.oe(e);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&n.ignoreDelay&&(s=L({},i,{appearance:L({},i.appearance,{surveyPopupDelaySeconds:0})})),n.ignoreConditions===!1){var o=this.canRenderSurvey(i);if(!o.visible)return void X.warn("Survey is not eligible to be displayed: ",o.disabledReason)}n.displayType!==xv.Inline?this._surveyManager.handlePopoverSurvey(s):this.renderSurvey(s,n.selector)}else X.warn("Survey not found")}}cancelPendingSurvey(e){ee(this._surveyManager)?X.warn("init was not called"):this._surveyManager.cancelSurvey(e)}},hm=Pe("[RateLimiter]"),Id=class{constructor(e){var n,r;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=i=>{var s=i.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach((o=>{hm.info((o||"events")+" is quota limited."),this.serverLimits[o]=new Date().getTime()+6e4}))}catch(o){return void hm.warn('could not rate limit - continuing. Error: "'+o?.message+'"',{text:s})}},this.instance=e,this.captureEventsPerSecond=((n=e.config.rate_limiting)==null?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((r=e.config.rate_limiting)==null?void 0:r.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var n,r,i;e===void 0&&(e=!1);var s=new Date().getTime(),o=(n=(r=this.instance.persistence)==null?void 0:r.get_property(sd))!==null&&n!==void 0?n:{tokens:this.captureEventsBurstLimit,last:s};o.tokens+=(s-o.last)/1e3*this.captureEventsPerSecond,o.last=s,o.tokens>this.captureEventsBurstLimit&&(o.tokens=this.captureEventsBurstLimit);var a=o.tokens<1;return a||e||(o.tokens=Math.max(0,o.tokens-1)),!a||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=a,(i=this.instance.persistence)==null||i.set_property(sd,o),{isRateLimited:a,remainingTokens:o.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}},Dr=Pe("[RemoteConfig]"),Md=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=z._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}le(e){var n,r;(n=z.__PosthogExtensions__)!=null&&n.loadExternalDependency?(r=z.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(Dr.error("PostHog Extensions not found. Cannot load remote config."),e())}ue(e){this._instance.ci({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:n=>{e(n.json)}})}load(){try{if(this.remoteConfig)return Dr.info("Using preloaded remote config",this.remoteConfig),void this.fi(this.remoteConfig);if(this._instance.O())return void Dr.warn("Remote config is disabled. Falling back to local config.");this.le((e=>{if(!e)return Dr.info("No config found after loading remote JS config. Falling back to JSON."),void this.ue((n=>{this.fi(n)}));this.fi(e)}))}catch(e){Dr.error("Error loading remote config",e)}}fi(e){e?this._instance.config.__preview_remote_config?(this._instance.fi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):Dr.info("__preview_remote_config is disabled. Logging config instead",e):Dr.error("Failed to fetch remote config from PostHog.")}},$d=3e3,Dd=class{constructor(e,n){this.he=!0,this.ve=[],this.de=en(n?.flush_interval_ms||$d,250,5e3,O.createLogger("flush interval"),$d),this.ce=e}enqueue(e){this.ve.push(e),this.fe||this.pe()}unload(){this.ge();var e=this.ve.length>0?this._e():{},n=Object.values(e);[...n.filter((r=>r.url.indexOf("/e")===0)),...n.filter((r=>r.url.indexOf("/e")!==0))].map((r=>{this.ce(L({},r,{transport:"sendBeacon"}))}))}enable(){this.he=!1,this.pe()}pe(){var e=this;this.he||(this.fe=setTimeout((()=>{if(this.ge(),this.ve.length>0){var n=this._e(),r=function(){var s=n[i],o=new Date().getTime();s.data&&ne(s.data)&&re(s.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.ce(s)};for(var i in n)r()}}),this.de))}ge(){clearTimeout(this.fe),this.fe=void 0}_e(){var e={};return re(this.ve,(n=>{var r,i=n,s=(i?i.batchKey:null)||i.url;R(e[s])&&(e[s]=L({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)})),this.ve=[],e}},uE=["retriesPerformedSoFar"],Vd=class{constructor(e){this.me=!1,this.ye=3e3,this.ve=[],this._instance=e,this.ve=[],this.be=!0,!R(x)&&"onLine"in x.navigator&&(this.be=x.navigator.onLine,this.we=()=>{this.be=!0,this.Dt()},this.xe=()=>{this.be=!1},Ee(x,"online",this.we),Ee(x,"offline",this.xe))}get length(){return this.ve.length}retriableRequest(e){var{retriesPerformedSoFar:n}=e,r=wm(e,uE);rn(n)&&n>0&&(r.url=Ja(r.url,{retry_count:n})),this._instance.ci(L({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(n??0)<10?this.Se(L({retriesPerformedSoFar:n},r)):r.callback==null||r.callback(i)}}))}Se(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var r=(function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=(Math.random()-.5)*(u-l);return Math.ceil(u+c)})(n),i=Date.now()+r;this.ve.push({retryAt:i,requestOptions:e});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),O.warn(s),this.me||(this.me=!0,this.Ee())}Ee(){if(this.$e&&clearTimeout(this.$e),this.ve.length===0)return this.me=!1,void(this.$e=void 0);this.$e=setTimeout((()=>{this.be&&this.ve.length>0&&this.Dt(),this.Ee()}),this.ye)}Dt(){var e=Date.now(),n=[],r=this.ve.filter((s=>s.retryAt<e||(n.push(s),!1)));if(this.ve=n,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.$e&&(clearTimeout(this.$e),this.$e=void 0),this.me=!1,R(x)||(this.we&&(x.removeEventListener("online",this.we),this.we=void 0),this.xe&&(x.removeEventListener("offline",this.xe),this.xe=void 0)),this.ve))try{this._instance.ci(L({},e,{transport:"sendBeacon"}))}catch(n){O.error(n)}this.ve=[]}},jd=class{constructor(e){this.ke=()=>{var n,r,i,s;this.Pe||(this.Pe={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+(o?.clientHeight||0),c=o?.scrollHeight||0;this.Pe.lastScrollY=Math.ceil(a),this.Pe.maxScrollY=Math.max(a,(n=this.Pe.maxScrollY)!==null&&n!==void 0?n:0),this.Pe.maxScrollHeight=Math.max(l,(r=this.Pe.maxScrollHeight)!==null&&r!==void 0?r:0),this.Pe.lastContentY=u,this.Pe.maxContentY=Math.max(u,(i=this.Pe.maxContentY)!==null&&i!==void 0?i:0),this.Pe.maxContentHeight=Math.max(c,(s=this.Pe.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=e}getContext(){return this.Pe}resetContext(){var e=this.Pe;return setTimeout(this.ke,0),e}startMeasuringScrollPosition(){Ee(x,"scroll",this.ke,{capture:!0}),Ee(x,"scrollend",this.ke,{capture:!0}),Ee(x,"resize",this.ke)}scrollElement(){if(!this._instance.config.scroll_root_selector)return x?.document.documentElement;var e=ne(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var n of e){var r=x?.document.querySelector(n);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return x&&(x.scrollY||x.pageYOffset||x.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return x&&(x.scrollX||x.pageXOffset||x.document.documentElement.scrollLeft)||0}},cE=t=>pv(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties),tl=class{constructor(e,n,r,i){this.Te=s=>{var o=this.Re();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Ie(this._instance)};this.Fe.register({[id]:a})}},this._instance=e,this.Ce=n,this.Fe=r,this.Ie=i||cE,this.Ce.onSessionId(this.Te)}Re(){return this.Fe.props[id]}getSetOnceProps(){var e,n=(e=this.Re())==null?void 0:e.props;return n?"r"in n?hv(n):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var e={};return re(Gd(this.getSetOnceProps()),((n,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+jc(r)]=n})),e}},$c=Pe("[SessionId]"),nl=class{on(e,n){return this.Me.on(e,n)}constructor(e,n,r){var i;if(this.Oe=[],this.Ae=void 0,this.Me=new fo,this.De=(c,d)=>Math.abs(c-d)>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.F=e.config,this.Fe=e.persistence,this.je=void 0,this.Le=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Ne=n||Yn,this.Ue=r||Yn;var s=this.F.persistence_name||this.F.token,o=this.F.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*en(o,60,36e3,$c.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ze(),this.He="ph_"+s+"_window_id",this.Be="ph_"+s+"_primary_window_exists",this.qe()){var a=Ie.W(this.He),l=Ie.W(this.Be);a&&!l?this.je=a:Ie.V(this.He),Ie.G(this.Be,!0)}if((i=this.F.bootstrap)!=null&&i.sessionID)try{var u=(c=>{var d=c.replace(/-/g,"");if(d.length!==32)throw new Error("Not a valid UUID");if(d[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(d.substring(0,12),16)})(this.F.bootstrap.sessionID);this.We(this.F.bootstrap.sessionID,new Date().getTime(),u)}catch(c){$c.error("Invalid sessionID in bootstrap",c)}this.Ge()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return R(this.Oe)&&(this.Oe=[]),this.Oe.push(e),this.Le&&e(this.Le,this.je),()=>{this.Oe=this.Oe.filter((n=>n!==e))}}qe(){return this.F.persistence!=="memory"&&!this.Fe.wi&&Ie.H()}Ve(e){e!==this.je&&(this.je=e,this.qe()&&Ie.G(this.He,e))}Je(){return this.je?this.je:this.qe()?Ie.W(this.He):null}We(e,n,r){e===this.Le&&n===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this.Le=e,this.Fe.register({[ja]:[n,e,r]}))}Ke(){var e=this.Fe.props[ja];return ne(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.We(null,null,null)}destroy(){clearTimeout(this.Ye),this.Ye=void 0,this.Ae&&x&&(x.removeEventListener("beforeunload",this.Ae,{capture:!1}),this.Ae=void 0),this.Oe=[]}Ge(){this.Ae=()=>{this.qe()&&Ie.V(this.Be)},Ee(x,"beforeunload",this.Ae,{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.F.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),[i,s,o]=this.Ke(),a=this.Je(),l=rn(o)&&o>0&&Math.abs(r-o)>864e5,u=!1,c=!s,d=!c&&!e&&this.De(r,i);c||d||l?(s=this.Ne(),a=this.Ue(),$c.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:c,activityTimeout:d,sessionPastMaximumLength:l}}),o=r,u=!0):a||(a=this.Ue(),u=!0);var f=i===0||!e||l?r:i,g=o===0?new Date().getTime():o;return this.Ve(a),this.We(s,f,g),e||this.ze(),u&&this.Oe.forEach((v=>v(s,a,u?{noSessionId:c,activityTimeout:d,sessionPastMaximumLength:l}:void 0))),{sessionId:s,windowId:a,sessionStartTimestamp:g,changeReason:u?{noSessionId:c,activityTimeout:d,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}ze(){clearTimeout(this.Ye),this.Ye=setTimeout((()=>{var[e]=this.Ke();if(this.De(new Date().getTime(),e)){var n=this.Le;this.resetSessionId(),this.Me.emit("forcedIdleReset",{idleSessionId:n})}}),1.1*this.sessionTimeoutMs)}},dE=["$set_once","$set"],Gn=Pe("[SiteApps]"),zd=class{constructor(e){this._instance=e,this.Xe=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Qe(e,n){if(n){var r=this.globalsForEvent(n);this.Xe.push(r),this.Xe.length>1e3&&(this.Xe=this.Xe.slice(10))}}get siteAppLoaders(){var e;return(e=z._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Ai(this.Qe.bind(this));this.Ze=()=>{e(),this.Xe=[],this.Ze=void 0}}}globalsForEvent(e){var n,r,i,s,o,a,l;if(!e)throw new Error("Event payload is required");var u={},c=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var[f,g]of Object.entries(d))u[f]={id:c[f],type:f,properties:g};var{$set_once:v,$set:y}=e;return{event:L({},wm(e,dE),{properties:L({},e.properties,y?{$set:L({},(n=(r=e.properties)==null?void 0:r.$set)!==null&&n!==void 0?n:{},y)}:{},v?{$set_once:L({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},v)}:{}),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:u}}setupSiteApp(e){var n=this.apps[e.id],r=()=>{var a;!n.errored&&this.Xe.length&&(Gn.info("Processing "+this.Xe.length+" events for site app with id "+e.id),this.Xe.forEach((l=>n.processEvent==null?void 0:n.processEvent(l))),n.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((a=this.Ze)==null||a.call(this))},i=!1,s=a=>{n.errored=!a,n.loaded=!0,Gn.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&&(n.processEvent=o),i=!0}catch(a){Gn.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&n.loaded)try{r()}catch(a){Gn.error("Error while processing buffered events PostHog app with config id "+e.id,a),n.errored=!0}}tr(){var e=this.siteAppLoaders||[];for(var n of e)this.apps[n.id]={id:n.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}ir(e){if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(n)}catch(i){Gn.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var n,r,i,s=this;if((n=this.siteAppLoaders)!=null&&n.length)return this.isEnabled?(this.tr(),void this._instance.on("eventCaptured",(u=>this.ir(u)))):void Gn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.Ze)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(u){var c;z["__$$ph_site_app_"+u]=s._instance,(c=z.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(s._instance,l,(d=>{if(d)return Gn.error("Error while initializing PostHog app with config id "+u,d)}))};for(var{id:a,url:l}of e.siteApps)o(a)}else Gn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},Ev=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&Rg(n,e))return!0;try{var r=t?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>Rg(i?.brand,e))))return!0}catch{}return!!t.webdriver},no=(function(t){return t.US="us",t.EU="eu",t.CUSTOM="custom",t})({}),gm="i.posthog.com",Hd=class{constructor(e){this.er={},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,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+gm,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.er[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.er[this.apiHost]=no.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.er[this.apiHost]=no.EU:this.er[this.apiHost]=no.CUSTOM),this.er[this.apiHost]}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(e==="flags")return this.flagsApiHost+n;if(this.region===no.CUSTOM)return this.apiHost+n;var r=gm+n;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},fE={icontains:(t,e)=>!!x&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!x&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!x&&el(e.href,t),not_regex:(t,e)=>!!x&&!el(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t},Bd=class t{constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments((i=>{t.rr("retrieved web experiments from the server"),n.sr=new Map,i.forEach((s=>{if(s.feature_flag_key){var o;n.sr&&(t.rr("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=n.sr)==null||o.set(s.feature_flag_key,s));var a=n._instance.getFeatureFlag(s.feature_flag_key);Te(a)&&s.variants[a]&&n.nr(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var u=s.variants[l];t.ar(u)&&n.nr(s.name,l,u.transforms)}}))}),r)},this._instance=e,this._instance.onFeatureFlags((r=>{this.onFeatureFlags(r)}))}onFeatureFlags(e){if(this._is_bot())t.rr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(ee(this.sr))return this.sr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.rr("applying feature flags",e),e.forEach((n=>{var r;if(this.sr&&(r=this.sr)!=null&&r.has(n)){var i,s=this._instance.getFeatureFlag(n),o=(i=this.sr)==null?void 0:i.get(n);s&&o!=null&&o.variants[s]&&this.nr(o.name,s,o.variants[s].transforms)}}))}}previewWebExperiment(){var e=t.getWindowLocation();if(e!=null&&e.search){var n=Ka(e?.search,"__experiment_id"),r=Ka(e?.search,"__experiment_variant");n&&r&&(t.rr("previewing web experiments "+n+" && "+r),this.getWebExperiments((i=>{this.lr(parseInt(n),r,i)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!n)return e(i);this._instance.ci({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)}})}lr(e,n,r){var i=r.filter((s=>s.id===e));i&&i.length>0&&(t.rr("Previewing web experiment ["+i[0].name+"] with variant ["+n+"]"),this.nr(i[0].name,n,i[0].variants[n].transforms))}static ar(e){return!ee(e.conditions)&&t.ur(e)&&t.hr(e)}static ur(e){var n;if(ee(e.conditions)||ee((n=e.conditions)==null?void 0:n.url))return!0;var r,i,s,o=t.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||fE[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return x?.location}static hr(e){var n;if(ee(e.conditions)||ee((n=e.conditions)==null?void 0:n.utm))return!0;var r=uv();if(r.utm_source){var i,s,o,a,l,u,c,d,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,g=(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,v=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=e.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==r.utm_medium,y=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((d=e.conditions)==null||(d=d.utm)==null?void 0:d.utm_term)==r.utm_term;return f&&v&&y&&g}return!1}static rr(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];O.info("[WebExperiments] "+e,r)}nr(e,n,r){this._is_bot()?t.rr("Refusing to render web experiment since the viewer is a likely bot"):n!=="control"?r.forEach((i=>{if(i.selector){var s;t.rr("applying transform of variant "+n+" 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)}))}})):t.rr("Control variants leave the page unmodified.")}_is_bot(){return pt&&this._instance?Ev(pt,this._instance.config.custom_blocked_useragents):void 0}},pE=Pe("[PostHog ExternalIntegrations]"),hE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ud=class{constructor(e){this._instance=e}it(e,n){var r;(r=z.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(i=>{if(i)return pE.error("failed to load script",i);n()}))}startIfEnabledOrStop(){var e=this,n=function(o){var a,l,u;!i||(a=z.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(hE[o],(()=>{var c;(c=z.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.start(e._instance)})),!i&&(l=z.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((u=z.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.stop())};for(var[r,i]of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;n(r)}}},Wd="[SessionRecording]",Zs=Pe(Wd),rl=class{get started(){var e;return!((e=this.vr)==null||!e.isStarted)}get status(){return this.vr?this.vr.status:this.dr&&!this.cr?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.dr=!1,this.pr=void 0,this._instance=e,!this._instance.sessionManager)throw Zs.error("started without valid sessionManager"),new Error(Wd+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Wd+' cannot be used with cookieless_mode="always"')}get cr(){var e,n=!((e=this._instance.get_property(bc))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return x&&n&&r&&!i}startIfEnabledOrStop(e){var n;if(!this.cr||(n=this.vr)==null||!n.isStarted){var r=!R(Object.assign)&&!R(Array.from);this.cr&&r?(this.gr(e),Zs.info("starting")):this.stopRecording()}}gr(e){var n,r,i;this.cr&&(z!=null&&(n=z.__PosthogExtensions__)!=null&&(n=n.rrweb)!=null&&n.record&&(r=z.__PosthogExtensions__)!=null&&r.initSessionRecording?this._r(e):(i=z.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.mr,(s=>{if(s)return Zs.error("could not load recorder",s);this._r(e)})))}stopRecording(){var e,n;(e=this.pr)==null||e.call(this),this.pr=void 0,(n=this.vr)==null||n.stop()}yr(){var e;(e=this._instance.persistence)==null||e.unregister(Am)}br(e){if(this._instance.persistence){var n,r,i=this._instance.persistence,s=()=>{var o=e.sessionRecording===!1?void 0:e.sessionRecording,a=o?.sampleRate,l=ee(a)?null:parseFloat(a);ee(l)&&this.yr();var u=o?.minimumDurationMilliseconds;i.register({[bc]:L({enabled:!!o},o,{networkPayloadCapture:L({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:R(u)?null:u,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};s(),(n=this.pr)==null||n.call(this),this.pr=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.br(e),this.dr=!0,this.startIfEnabledOrStop()):this.dr=!0:Zs.info("skipping remote config with no sessionRecording",e)}log(e,n){var r;n===void 0&&(n="log"),(r=this.vr)!=null&&r.log?this.vr.log(e,n):Zs.warn("log called before recorder was ready")}get mr(){var e,n,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(bc);return(r==null||(n=r.scriptConfig)==null?void 0:n.script)||"lazy-recorder"}_r(e){var n,r;if((n=z.__PosthogExtensions__)==null||!n.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.vr||(this.vr=(r=z.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.vr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.vr.start(e)}onRRwebEmit(e){var n;(n=this.vr)==null||n.onRRwebEmit==null||n.onRRwebEmit(e)}overrideLinkedFlag(){var e,n;this.vr||(n=this._instance.persistence)==null||n.register({$replay_override_linked_flag:!0}),(e=this.vr)==null||e.overrideLinkedFlag()}overrideSampling(){var e,n;this.vr||(n=this._instance.persistence)==null||n.register({$replay_override_sampling:!0}),(e=this.vr)==null||e.overrideSampling()}overrideTrigger(e){var n,r;this.vr||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(n=this.vr)==null||n.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.vr)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,n){var r;return!((r=this.vr)==null||!r.tryAddCustomEvent(e,n))}},so={},qd=()=>{},Ni="posthog",Sv=!nE&&nt?.indexOf("MSIE")===-1&&nt?.indexOf("Mozilla")===-1,mm=t=>{var e;return L({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:lx(A?.location),persistence:"localStorage+cookie",persistence_name:"",loaded:qd,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,debug:rt&&Te(rt?.search)&&rt.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_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(x==null||(e=x.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:n=>{var r="Bad HTTP status: "+n.statusCode+" "+n.text;O.error(r)},get_device_id:n=>n,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:$d},error_tracking:{},_onCapture:qd,__preview_eager_load_replay:!1},(n=>({rageclick:!(n&&n>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(n&&n>="2025-05-24")||"history_change",session_recording:n&&n>="2025-11-30"?{strictMinimumDuration:!0}:{}}))(t))},vm=t=>{var e={};R(t.process_person)||(e.person_profiles=t.process_person),R(t.xhr_headers)||(e.request_headers=t.xhr_headers),R(t.cookie_name)||(e.persistence_name=t.cookie_name),R(t.disable_cookie)||(e.disable_persistence=t.disable_cookie),R(t.store_google)||(e.save_campaign_params=t.store_google),R(t.verbose)||(e.debug=t.verbose);var n=_e({},e,t);return ne(t.property_blacklist)&&(R(t.property_denylist)?n.property_denylist=t.property_blacklist:ne(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:O.error("Invalid value for property_denylist config: "+t.property_denylist)),n},Kd=class{constructor(){this.__forceAllowLocalhost=!1}get wr(){return this.__forceAllowLocalhost}set wr(e){O.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},il=class t{get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new Kd,this.Sr=!1,this.version=yn.LIB_VERSION,this.Er=new fo,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=mm(),this.SentryIntegration=md,this.sentryIntegration=e=>(function(n,r){var i=qm(n,r);return{name:Wm,processEvent:s=>i(s)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.$r=!1,this.kr=null,this.Pr=null,this.Tr=null,this.featureFlags=new Ad(this),this.toolbar=new vd(this),this.scrollManager=new jd(this),this.pageViewManager=new Sd(this),this.surveys=new Ld(this),this.experiments=new Bd(this),this.exceptions=new Rd(this),this.rateLimiter=new Id(this),this.requestRouter=new Hd(this),this.consent=new pd(this),this.externalIntegrations=new Ud(this),this.people={set:(e,n,r)=>{var i=Te(e)?{[e]:n}:e;this.setPersonProperties(i),r?.({})},set_once:(e,n,r)=>{var i=Te(e)?{[e]:n}:e;this.setPersonProperties(void 0,i),r?.({})}},this.on("eventCaptured",(e=>O.info('send "'+e?.event+'"',e)))}init(e,n,r){if(r&&r!==Ni){var i,s=(i=so[r])!==null&&i!==void 0?i:new t;return s._init(e,n,r),so[r]=s,so[Ni][r]=s,s}return this._init(e,n,r)}_init(e,n,r){var i;if(n===void 0&&(n={}),R(e)||zc(e))return O.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={},n.debug=this.Rr(n.debug),this.Ir=n,this.Fr=[],n.person_profiles&&(this.Pr=n.person_profiles),this.set_config(_e({},mm(n.defaults),vm(n),{name:r,token:e})),this.config.on_xhr_error&&O.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:kn.GZipJS;var s=this.Cr();this.persistence=new io(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new io(L({},this.config,{persistence:"sessionStorage"}),s);var o=L({},this.persistence.props),a=L({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Mr=new Dd((p=>this.Or(p)),this.config.request_queue_config),this.Ar=new Vd(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 nl(this),this.sessionPropsManager=new tl(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(O.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Dr(l)}),0)):(O.info("Initializing extensions synchronously"),this.Dr(l)),yn.DEBUG=yn.DEBUG||this.config.debug,yn.DEBUG&&O.info("Starting in debug mode",{this:this,config:n,thisC:L({},this.config),p:o,s:a}),((i=n.bootstrap)==null?void 0:i.distinctID)!==void 0){var u,c,d=this.config.get_device_id(Yn()),f=(u=n.bootstrap)!=null&&u.isIdentifiedID?d:n.bootstrap.distinctID;this.persistence.set_property(_n,(c=n.bootstrap)!=null&&c.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:n.bootstrap.distinctID,$device_id:f})}if(this.jr()){var g,v,y=Object.keys(((g=n.bootstrap)==null?void 0:g.featureFlags)||{}).filter((p=>{var m;return!((m=n.bootstrap)==null||(m=m.featureFlags)==null||!m[p])})).reduce(((p,m)=>{var _;return p[m]=((_=n.bootstrap)==null||(_=_.featureFlags)==null?void 0:_[m])||!1,p}),{}),k=Object.keys(((v=n.bootstrap)==null?void 0:v.featureFlagPayloads)||{}).filter((p=>y[p])).reduce(((p,m)=>{var _,w;return(_=n.bootstrap)!=null&&(_=_.featureFlagPayloads)!=null&&_[m]&&(p[m]=(w=n.bootstrap)==null||(w=w.featureFlagPayloads)==null?void 0:w[m]),p}),{});this.featureFlags.receivedFeatureFlags({featureFlags:y,featureFlagPayloads:k})}if(l)this.register_once({distinct_id:zs,$device_id:null},"");else if(!this.get_distinct_id()){var h=this.config.get_device_id(Yn());this.register_once({distinct_id:h,$device_id:h},""),this.persistence.set_property(_n,"anonymous")}return Ee(x,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),n.segment?Ax(this,(()=>this.Lr())):this.Lr(),Qn(this.config._onCapture)&&this.config._onCapture!==qd&&(O.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(p=>this.config._onCapture(p.event,p)))),this.config.ip&&O.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}Dr(e){var n=performance.now();this.historyAutocapture=new gd(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new yd(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new zd(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new rl(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new ud(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.heatmaps=new Ed(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new xd(this)})),r.push((()=>{this.exceptionObserver=new hd(this),this.exceptionObserver.startIfEnabled()})),r.push((()=>{this.deadClicksAutocapture=new Za(this,Rx),this.deadClicksAutocapture.startIfEnabled()})),r.push((()=>{if(this.Nr){var i=this.Nr;this.Nr=void 0,this.fi(i)}})),this.Ur(r,n)}Ur(e,n){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&e.length>0)return void setTimeout((()=>{this.Ur(e,n)}),0);var r=e.shift();if(r)try{r()}catch(s){O.error("Error initializing extension:",s)}}var i=Math.round(performance.now()-n);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&&O.info("PostHog extensions initialized ("+i+"ms)")}fi(e){var n,r,i,s,o,a,l,u;if(!A||!A.body)return O.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.fi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Nr=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=U(e.supportedCompression,kn.GZipJS)?kn.GZipJS:U(e.supportedCompression,kn.Base64)?kn.Base64:void 0),(n=e.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Pr?this.Pr:"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),(a=this.webVitalsAutocapture)==null||a.onRemoteConfig(e),(l=this.exceptionObserver)==null||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}Lr(){try{this.config.loaded(this)}catch(e){O.critical("`loaded` function failed",e)}this.zr(),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.Hr()}),1),new Md(this).load(),this.featureFlags.flags()}zr(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Mr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Jn(this.__request_queue,(e=>this.Or(e))),this.__request_queue=[],this.zr()}_handle_unload(){var e,n;this.config.request_batching?(this.Br()&&this.capture("$pageleave"),(e=this.Mr)==null||e.unload(),(n=this.Ar)==null||n.unload()):this.Br()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}ci(e){this.__loaded&&(Sv?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Ja(e.url,{ip:this.config.ip?1:0}),e.headers=L({},this.config.request_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,(n=>{var r,i,s,o=L({},n);o.timeout=o.timeout||6e4,o.url=Ja(o.url,{_:new Date().getTime().toString(),ver:yn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=Ma.filter((c=>!o.disableTransport||!c.transport||!o.disableTransport.includes(c.transport))),u=(i=(s=Tm(l,(c=>c.transport===a)))==null?void 0:s.method)!==null&&i!==void 0?i:l[0].method;if(!u)throw new Error("No available transport method");u(o)})(L({},e,{callback:n=>{var r,i;this.rateLimiter.checkForLimiting(n),n.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,n)),e.callback==null||e.callback(n)}}))))}Or(e){this.Ar?this.Ar.retriableRequest(e):this.ci(e)}_execute_array(e){var n,r=[],i=[],s=[];Jn(e,(a=>{a&&(n=a[0],ne(n)?s.push(a):Qn(a)?a.call(this):ne(a)&&n==="alias"?r.push(a):ne(a)&&n.indexOf("capture")!==-1&&Qn(this[n])?s.push(a):i.push(a))}));var o=function(a,l){Jn(a,(function(u){if(ne(u[0])){var c=l;re(u,(function(d){c=c[d[0]].apply(c,d.slice(1))}))}else this[u[0]].apply(this,u.slice(1))}),l)};o(r,this),o(i,this),o(s,this)}jr(){var e,n;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((n=this.config.bootstrap)==null?void 0:n.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,n,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Mr){if(this.is_capturing())if(!R(e)&&Te(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){n!=null&&n.$current_url&&!Te(n?.$current_url)&&(O.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$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,u=Yn(),c={uuid:u,event:e,properties:this.calculateEventProperties(e,n||{},l,u)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),o&&(c.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),r?.$set&&(c.$set=r?.$set);var d,f=this.qr(r?.$set_once);if(f&&(c.$set_once=f),(c=ox(c,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,R(r?.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=a),e===$a.DISMISSED||e===$a.SENT){var g=n?.[fm.SURVEY_ID],v=n?.[fm.SURVEY_ITERATION];d={id:g,current_iteration:v},localStorage.getItem(pm(d))||localStorage.setItem(pm(d),"true"),c.$set=L({},c.$set,{[oE({id:g,current_iteration:v},e===$a.SENT?"responded":"dismissed")]:!0})}var y=L({},c.properties.$set,c.$set);if(Fi(y)||this.setPersonPropertiesForFlags(y),!ee(this.config.before_send)){var k=this.Wr(c);if(!k)return;c=k}this.Er.emit("eventCaptured",c);var h={method:"POST",url:(i=r?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:r?._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.Or(h):this.Mr.enqueue(h),c}O.critical("This capture call is ignored due to client rate limiting.")}}else O.error("No event name provided to posthog.capture")}else O.uninitializedWarning("posthog.capture")}Ai(e){return this.on("eventCaptured",(n=>e(n.event,n)))}calculateEventProperties(e,n,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var o=s?void 0:this.persistence.remove_event_timer(e),a=L({},n);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=L({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!Te(a.distinct_id)&&!rn(a.distinct_id)||zc(a.distinct_id))&&O.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=qx(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:d,windowId:f}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=d,a.$window_id=f}this.sessionPropsManager&&_e(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&_e(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.Ar)==null?void 0:g.length}catch(h){a.$sdk_debug_error_capturing_properties=String(h)}if(this.requestRouter.region===no.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),u=e!=="$pageview"||s?e!=="$pageleave"||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=_e(a,u),e==="$pageview"&&A&&(a.title=A.title),!R(o)){var v=r.getTime()-o;a.$duration=parseFloat((v/1e3).toFixed(3))}nt&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=_e({},c,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),ne(this.config.property_denylist)?re(this.config.property_denylist,(function(h){delete a[h]})):O.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var y=this.config.sanitize_properties;y&&(O.error("sanitize_properties is deprecated. Use before_send instead"),a=y(a,e));var k=this.Gr();return a.$process_person_profile=k,k&&!s&&this.Vr("_calculate_event_properties"),a}qr(e){var n;if(!this.persistence||!this.Gr()||this.Sr)return e;var r=this.persistence.get_initial_props(),i=(n=this.sessionPropsManager)==null?void 0:n.getSetOnceProps(),s=_e({},r,i||{},e||{}),o=this.config.sanitize_properties;return o&&(O.error("sanitize_properties is deprecated. Use before_send instead"),s=o(s,"$set_once")),this.Sr=!0,Fi(s)?void 0:s}register(e,n){var r;(r=this.persistence)==null||r.register(e,n)}register_once(e,n,r){var i;(i=this.persistence)==null||i.register_once(e,n,r)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}Jr(e,n){this.register({[e]:n})}getFeatureFlag(e,n){return this.featureFlags.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(n)}catch{return n}}isFeatureEnabled(e,n){return this.featureFlags.isFeatureEnabled(e,n)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,n,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,n,r)}getEarlyAccessFeatures(e,n,r){return n===void 0&&(n=!1),this.featureFlags.getEarlyAccessFeatures(e,n,r)}on(e,n){return this.Er.on(e,n)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys.getSurveys(e,n)}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys.getActiveMatchingSurveys(e,n)}renderSurvey(e,n){this.surveys.renderSurvey(e,n)}displaySurvey(e,n){n===void 0&&(n=lE),this.surveys.displaySurvey(e,n)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,n){return n===void 0&&(n=!1),this.surveys.canRenderSurveyAsync(e,n)}identify(e,n,r){if(!this.__loaded||!this.persistence)return O.uninitializedWarning("posthog.identify");if(rn(e)&&(e=e.toString(),O.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()))O.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!==zs){if(this.Vr("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(Ys)&&(this.unregister(Ys),this.register({distinct_id:e}));var o=(this.persistence.get_property(_n)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(_n,"identified"),this.setPersonPropertiesForFlags(L({},r||{},n||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:n||{},$set_once:r||{}}),this.Tr=am(e,n,r),this.featureFlags.setAnonymousDistinctId(i)):(n||r)&&this.setPersonProperties(n,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(za))}}else O.critical('The string "'+zs+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else O.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,n){if((e||n)&&this.Vr("posthog.setPersonProperties")){var r=am(this.get_distinct_id(),e,n);this.Tr!==r?(this.setPersonPropertiesForFlags(L({},n||{},e||{})),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.Tr=r):O.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,n,r){if(e&&n){if(this.Vr("posthog.group")){var i=this.getGroups();i[e]!==n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:L({},i,{[e]:n})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:n,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===n||r||this.reloadFeatureFlags()}}else O.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0),this.featureFlags.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0),this.Vr("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,n)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var n,r,i,s;if(O.info("reset"),!this.__loaded)return O.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(_n,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Tr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:zs,$device_id:null},"");else{var a=this.config.get_device_id(Yn());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,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:n,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n);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,n){return e===this.get_property(Pm)?(O.critical("Attempting to create alias for existing People user - aborting."),-2):this.Vr("posthog.alias")?(R(n)&&(n=this.get_distinct_id()),e!==n?(this.Jr(Ys,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(O.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=L({},this.config);if(Ne(e)){var r,i,s,o,a;_e(this.config,vm(e));var l=this.Cr();(r=this.persistence)==null||r.update_config(this.config,n,l),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new io(L({},this.config,{persistence:"sessionStorage"}),l);var u=this.Rr(this.config.debug);Xn(u)&&(this.config.debug=u),Xn(this.config.debug)&&(this.config.debug?(yn.DEBUG=!0,pe.H()&&pe.G("ph_debug","true"),O.info("set_config",{config:e,oldConfig:n,newConfig:L({},this.config)})):(yn.DEBUG=!1,pe.H()&&pe.V("ph_debug"))),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),(s=this.autocapture)==null||s.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),this.surveys.loadIfEnabled(),this.Kr(),(a=this.externalIntegrations)==null||a.startIfEnabledOrStop()}}startSessionRecording(e){var n=e===!0,r={sampling:n||!(e==null||!e.sampling),linked_flag:n||!(e==null||!e.linked_flag),url_trigger:n||!(e==null||!e.url_trigger),event_trigger:n||!(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,n){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(L({},i,n))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:Ni;return n!==Ni&&(n=Ni+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(_n))==="identified"||((n=this.sessionPersistence)==null?void 0:n.get_property(_n))==="identified"}Gr(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Fi(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Ys])&&((n=this.persistence)==null||(n=n.props)==null||!n[Ba]))}Br(){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.Gr()||this.Vr("posthog.createPersonProfile")&&this.setPersonProperties({},{})}Vr(e){return this.config.person_profiles==="never"?(O.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Jr(Ba,!0),!0)}Cr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),n=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!n}Kr(){var e,n,r,i,s=this.Cr();return((e=this.persistence)==null?void 0:e.wi)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((n=this.sessionPersistence)==null?void 0:n.wi)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s}opt_in_capturing(e){var n;if(this.config.cookieless_mode!=="always"){var r,i;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(r=this.sessionManager)==null||r.destroy(),this.sessionManager=new nl(this),this.persistence&&(this.sessionPropsManager=new tl(this,this.sessionManager,this.persistence)),this.sessionRecording=new rl(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.Kr(),this.zr(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(R(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((i=e?.captureEventName)!==null&&i!==void 0?i:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Hr()}else O.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,n;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Kr(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:zs,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(n=this.sessionRecording)==null||n.stopRecording(),this.sessionRecording=void 0,this.Hr())):O.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===wn.GRANTED?"granted":e===wn.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.Kr()}_is_bot(){return pt?Ev(pt,this.config.custom_blocked_useragents):void 0}Hr(){A&&(A.visibilityState==="visible"?this.$r||(this.$r=!0,this.capture("$pageview",{title:A.title},{send_instantly:!0}),this.kr&&(A.removeEventListener("visibilitychange",this.kr),this.kr=null)):this.kr||(this.kr=this.Hr.bind(this),Ee(A,"visibilitychange",this.kr)))}debug(e){e===!1?(x?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(x?.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}))}O(){var e,n,r,i,s,o,a,l=this.Ir||{};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?(O.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=O,o=(n="advanced_disable_flags")in(e=l)&&!R(e[n]),a=r in e&&!R(e[r]),o?e[n]:a?(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+n+"' instead. The old field will be removed in a future major version."),e[r]):i)}Wr(e){if(ee(this.config.before_send))return e;var n=ne(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of n){if(r=i(r),ee(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return Bk(e.event)?O.warn(s+". This can cause unexpected behavior."):O.info(s),null}r.properties&&!Fi(r.properties)||O.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.Vt)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(r)})}Rr(e){var n=Xn(e)&&!e,r=pe.H()&&pe.q("ph_debug")==="true";return!n&&(!!r||e)}};(function(t,e){for(var n=0;n<e.length;n++)t.prototype[e[n]]=sx(t.prototype[e[n]])})(il,["identify"]);var ym,bv=(ym=so[Ni]=new il,(function(){function t(){t.done||(t.done=!0,Sv=!1,re(so,(function(e){e._dom_loaded()})))}A!=null&&A.addEventListener?A.readyState==="complete"?t():Ee(A,"DOMContentLoaded",t,{capture:!1}):x&&O.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),ym);var sf=class{constructor(e={}){this.options=e;Ze(this,"client");this.client=e.client,!this.client&&typeof window<"u"&&e.apiKey&&(this.client=bv,this.client.init(e.apiKey,{api_host:e.apiHost??"https://telemetry.syntrologie.com",autocapture:e.autocapture??!0,capture_pageview:e.capturePageview??!0,capture_pageleave:e.capturePageleave??!0,disable_session_recording:!(e.sessionRecording??!0),session_recording:{recordCrossDomainIFrames:!0},capture_performance:!0,enable_recording_console_log:!0}))}identify(e,n){this.client?.identify(e,n)}alias(e,n){this.client?.alias(e,n)}track(e,n){this.client?.capture(e,n)}trackCanvasOpened(e){this.track("shadow_canvas_opened",{surface:e})}trackCanvasClosed(e){this.track("shadow_canvas_closed",{surface:e})}trackRectangleViewed(e,n){this.track("shadow_canvas_rectangle_viewed",{rectangleId:e,surface:n})}trackAction(e,n,r){this.track("shadow_canvas_action",{action:e,rectangleId:n,surface:r})}};function of(t={}){return new sf(t)}var Tv={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function uf(){return Tv}function af(t){let e=2166136261,n=t.length;for(let r=0;r<n;r++)e^=t.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function mo(t,e,n){return n===2?af(af(t+e)+"")%1e4/1e4:n===1?af(e+t)%1e3/1e3:null}function gE(t){return t<=0?[]:new Array(t).fill(1/t)}function ll(t,e){return t>=e[0]&&t<e[1]}function Pv(t,e){let n=mo("__"+e[0],t,1);return n===null?!1:n>=e[1]&&n<e[2]}function Rv(t,e){for(let n=0;n<e.length;n++)if(ll(t,e[n]))return n;return-1}function cf(t){try{let e=t.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function ul(t,e){if(!e.length)return!1;let n=!1,r=!1;for(let i=0;i<e.length;i++){let s=yE(t,e[i].type,e[i].pattern);if(e[i].include===!1){if(s)return!1}else n=!0,s&&(r=!0)}return r||!n}function mE(t,e,n){try{let r=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return n&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(t)}catch{return!1}}function vE(t,e){try{let n=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&r.push([t.hash,n.hash,!1]),n.searchParams.forEach((i,s)=>{r.push([t.searchParams.get(s)||"",i,!1])}),!r.some(i=>!mE(i[0],i[1],i[2]))}catch{return!1}}function yE(t,e,n){try{let r=new URL(t,"https://_");if(e==="regex"){let i=cf(n);return i?i.test(r.href)||i.test(r.href.substring(r.origin.length)):!1}else if(e==="simple")return vE(r,n);return!1}catch{return!1}}function Av(t,e,n){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let r=gE(t);n=n||r,n.length!==t&&(n=r);let i=n.reduce((o,a)=>a+o,0);(i<.99||i>1.01)&&(n=r);let s=0;return n.map(o=>{let a=s;return s+=o,[a,a+e*o]})}function Ov(t,e,n){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=>{let[o]=s;return o===t}).map(s=>{let[,o]=s;return parseInt(o)});return i.length>0&&i[0]>=0&&i[0]<n?i[0]:null}function Nv(t){try{return t()}catch(e){return console.error(e),!1}}var lf=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0));async function Hr(t,e,n){if(e=e||"",n=n||globalThis.crypto&&globalThis.crypto.subtle||Tv.SubtleCrypto,!n)throw new Error("No SubtleCrypto implementation found");try{let r=await n.importKey("raw",lf(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[i,s]=t.split("."),o=await n.decrypt({name:"AES-CBC",iv:lf(i)},r,lf(s));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function vo(t){return typeof t=="string"?t:JSON.stringify(t)}function ht(t){typeof t=="number"&&(t=t+""),(!t||typeof t!="string")&&(t="0");let e=t.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(n=>n.match(/^[0-9]+$/)?n.padStart(5," "):n).join("-")}function Fv(){let t;try{t="1.6.2"}catch{t=""}return t}function Lv(t,e){let n,r;try{n=new URL(t),r=new URL(e)}catch(i){return console.error(`Unable to merge query strings: ${i}`),e}return n.searchParams.forEach((i,s)=>{r.searchParams.has(s)||r.searchParams.set(s,i)}),r.toString()}function Cv(t){return typeof t=="object"&&t!==null}function cl(t){return t.urlPatterns&&t.variations.some(e=>Cv(e)&&"urlRedirect"in e)?"redirect":t.variations.some(e=>Cv(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function dl(t,e){return new Promise(n=>{let r=!1,i,s=o=>{r||(r=!0,i&&clearTimeout(i),n(o||null))};e&&(i=setTimeout(()=>s(),e)),t.then(o=>s(o)).catch(()=>s())})}var ze={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},sn=uf(),Br={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:r}=t;return sn.fetch(`${e}/api/features/${n}`,{headers:r})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:r,headers:i}=t,s={method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(r)};return sn.fetch(`${e}/api/eval/${n}`,s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:r}=t;return r?new sn.EventSource(`${e}/sub/${n}`,{headers:r}):new sn.EventSource(`${e}/sub/${n}`)},startIdleListener:()=>{let t;if(!(typeof window<"u"&&typeof document<"u"))return;let n=()=>{document.visibilityState==="visible"?(window.clearTimeout(t),kE()):document.visibilityState==="hidden"&&(t=window.setTimeout(wE,ze.idleStreamInterval))};return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(sn.localStorage=globalThis.localStorage)}catch{}var Hi=new Map,Iv=!1,En=new Map,fl=new Map,Bi=new Map,Ui=new Set;function ff(t){Object.assign(ze,t),ze.backgroundSync||vf()}async function $v(t){let{instance:e,timeout:n,skipCache:r,allowStale:i,backgroundSync:s}=t;return s||(ze.backgroundSync=!1),xE({instance:e,allowStale:i,timeout:n,skipCache:r})}function _E(t){let e=yo(t),n=Hi.get(e)||new Set;n.add(t),Hi.set(e,n)}function Dv(t){Hi.forEach(e=>e.delete(t))}function wE(){Bi.forEach(t=>{t&&(t.state="idle",gf(t))})}function kE(){Bi.forEach(t=>{t&&t.state==="idle"&&mf(t)})}async function Mv(){try{if(!sn.localStorage)return;await sn.localStorage.setItem(ze.cacheKey,JSON.stringify(Array.from(En.entries())))}catch{}}async function xE(t){let{instance:e,allowStale:n,timeout:r,skipCache:i}=t,s=yo(e),o=pf(e),a=new Date,l=new Date(a.getTime()-ze.maxAge+ze.staleTTL);await EE();let u=!ze.disableCache&&!i?En.get(o):void 0;return u&&(n||u.staleAt>a)&&u.staleAt>l?(u.sse&&Ui.add(s),u.staleAt<a?df(e):hf(e),{data:u.data,success:!0,source:"cache"}):await dl(df(e),r)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function yo(t){let[e,n]=t.getApiInfo();return`${e}||${n}`}function pf(t){let e=yo(t);if(!("isRemoteEval"in t)||!t.isRemoteEval())return e;let n=t.getAttributes(),r=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),i={};r.forEach(a=>{i[a]=n[a]});let s=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:i,fv:s,url:o})}`}async function EE(){if(!Iv){Iv=!0;try{if(sn.localStorage){let t=await sn.localStorage.getItem(ze.cacheKey);if(!ze.disableCache&&t){let e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach(n=>{let[r,i]=n;En.set(r,{...i,staleAt:new Date(i.staleAt)})}),Vv()}}}catch{}if(!ze.disableIdleStreams){let t=Br.startIdleListener();t&&(Br.stopIdleListener=t)}}}function Vv(){let t=Array.from(En.entries()).map(n=>{let[r,i]=n;return{key:r,staleAt:i.staleAt.getTime()}}).sort((n,r)=>n.staleAt-r.staleAt),e=Math.min(Math.max(0,En.size-ze.maxEntries),En.size);for(let n=0;n<e;n++)En.delete(t[n].key)}function jv(t,e,n){let r=n.dateUpdated||"",i=new Date(Date.now()+ze.staleTTL),s=ze.disableCache?void 0:En.get(e);if(s&&r&&s.version===r){s.staleAt=i,Mv();return}ze.disableCache||(En.set(e,{data:n,version:r,staleAt:i,sse:Ui.has(t)}),Vv()),Mv();let o=Hi.get(t);o&&o.forEach(a=>SE(a,n))}async function SE(t,e){await t.setPayload(e||t.getPayload())}async function df(t){let{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),r=t.getClientKey(),i="isRemoteEval"in t&&t.isRemoteEval(),s=yo(t),o=pf(t),a=fl.get(o);return a||(a=(i?Br.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):Br.fetchFeaturesCall({host:e,clientKey:r,headers:n})).then(u=>{if(!u.ok)throw new Error(`HTTP error: ${u.status}`);return u.headers.get("x-sse-support")==="enabled"&&Ui.add(s),u.json()}).then(u=>(jv(s,o,u),hf(t),fl.delete(o),{data:u,success:!0,source:"network"})).catch(u=>(fl.delete(o),{data:null,source:"error",success:!1,error:u})),fl.set(o,a)),a}function hf(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=yo(t),r=pf(t),{streamingHost:i,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&Ui.add(n),ze.backgroundSync&&Ui.has(n)&&sn.EventSource){if(Bi.has(n))return;let a={src:null,host:i,clientKey:o,headers:s,cb:l=>{try{if(l.type==="features-updated"){let u=Hi.get(n);u&&u.forEach(c=>{df(c)})}else if(l.type==="features"){let u=JSON.parse(l.data);jv(n,r,u)}a.errors=0}catch{zv(a)}},errors:0,state:"active"};Bi.set(n,a),mf(a)}}function zv(t){if(t.state!=="idle"&&(t.errors++,t.errors>3||t.src&&t.src.readyState===2)){let e=Math.pow(3,t.errors-3)*(1e3+Math.random()*1e3);gf(t),setTimeout(()=>{["idle","active"].includes(t.state)||mf(t)},Math.min(e,3e5))}}function gf(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,t.state==="active"&&(t.state="disabled"))}function mf(t){t.src=Br.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state="active",t.src.addEventListener("features",t.cb),t.src.addEventListener("features-updated",t.cb),t.src.onerror=()=>zv(t),t.src.onopen=()=>{t.errors=0}}function bE(t,e){gf(t),Bi.delete(e)}function vf(){Ui.clear(),Bi.forEach(bE),Hi.clear(),Br.stopIdleListener()}function pl(t,e){if(e.streaming){if(!t.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&hf(t,!0),_E(t)}}var CE=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,wf={revert:function(){}},vl=new Map,kf=new Set;function TE(t){return t==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}function yl(t){var e=vl.get(t);return e||(e={element:t,attributes:{}},vl.set(t,e)),e}function _l(t,e,n,r,i){var s=n(t),o={isDirty:!1,originalValue:s,virtualValue:s,mutations:[],el:t,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=n(t);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:n};return e==="position"&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,TE(e)),o}function wl(t,e){var n=e.getCurrentValue(e.el);e.virtualValue=t,t&&typeof t!="string"?(!n||t.parentNode!==n.parentNode||t.insertBeforeNode!==n.insertBeforeNode)&&(e.isDirty=!0,Hv()):t!==n&&(e.isDirty=!0,Hv())}function PE(t){var e=t.originalValue;t.mutations.forEach(function(n){return e=n.mutate(e)}),wl(HE(e),t)}function RE(t){var e=new Set(t.originalValue.split(/\s+/).filter(Boolean));t.mutations.forEach(function(n){return n.mutate(e)}),wl(Array.from(e).filter(Boolean).join(" "),t)}function AE(t){var e=t.originalValue;t.mutations.forEach(function(n){return e=n.mutate(e)}),wl(e,t)}function OE(t){var e=t.parentSelector,n=t.insertBeforeSelector,r=document.querySelector(e);if(!r)return null;var i=n?document.querySelector(n):null;return n&&!i?null:{parentNode:r,insertBeforeNode:i}}function NE(t){var e=t.originalValue;t.mutations.forEach(function(n){var r=n.mutate(),i=OE(r);e=i||e}),wl(e,t)}var FE=function(e){return e.innerHTML},LE=function(e,n){return e.innerHTML=n};function Uv(t){var e=yl(t);return e.html||(e.html=_l(t,"html",FE,LE,PE)),e.html}var IE=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},ME=function(e,n){n.insertBeforeNode&&!n.parentNode.contains(n.insertBeforeNode)||n.parentNode.insertBefore(e,n.insertBeforeNode)};function Wv(t){var e=yl(t);return e.position||(e.position=_l(t,"position",IE,ME,NE)),e.position}var $E=function(e,n){return n?e.className=n:e.removeAttribute("class")},DE=function(e){return e.className};function qv(t){var e=yl(t);return e.classes||(e.classes=_l(t,"class",DE,$E,RE)),e.classes}var VE=function(e){return function(n){var r;return(r=n.getAttribute(e))!=null?r:null}},jE=function(e){return function(n,r){return r!==null?n.setAttribute(e,r):n.removeAttribute(e)}};function Kv(t,e){var n=yl(t);return n.attributes[e]||(n.attributes[e]=_l(t,e,VE(e),jE(e),AE)),n.attributes[e]}function zE(t,e){var n=vl.get(t);if(n)if(e==="html"){var r,i;(r=n.html)==null||(i=r.observer)==null||i.disconnect(),delete n.html}else if(e==="class"){var s,o;(s=n.classes)==null||(o=s.observer)==null||o.disconnect(),delete n.classes}else if(e==="position"){var a,l;(a=n.position)==null||(l=a.observer)==null||l.disconnect(),delete n.position}else{var u,c,d;(u=n.attributes)==null||(c=u[e])==null||(d=c.observer)==null||d.disconnect(),delete n.attributes[e]}}var hl;function HE(t){return hl||(hl=document.createElement("div")),hl.innerHTML=t,hl.innerHTML}function gl(t,e,n){if(n.isDirty){n.isDirty=!1;var r=n.virtualValue;n.mutations.length||zE(t,e),n.setValue(t,r)}}function BE(t,e){t.html&&gl(e,"html",t.html),t.classes&&gl(e,"class",t.classes),t.position&&gl(e,"position",t.position),Object.keys(t.attributes).forEach(function(n){gl(e,n,t.attributes[n])})}function Hv(){vl.forEach(BE)}function UE(t,e){var n=null;t.kind==="html"?n=Uv(e):t.kind==="class"?n=qv(e):t.kind==="attribute"?n=Kv(e,t.attribute):t.kind==="position"&&(n=Wv(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}function WE(t,e){var n=null;if(t.kind==="html"?n=Uv(e):t.kind==="class"?n=qv(e):t.kind==="attribute"?n=Kv(e,t.attribute):t.kind==="position"&&(n=Wv(e)),!!n){var r=n.mutations.indexOf(t);r!==-1&&n.mutations.splice(r,1),n.mutationRunner(n)}}function Gv(t){if(!(t.kind==="position"&&t.elements.size===1)){var e=new Set(t.elements),n=document.querySelectorAll(t.selector);n.forEach(function(r){e.has(r)||(t.elements.add(r),UE(t,r))})}}function qE(t){t.elements.forEach(function(e){return WE(t,e)}),t.elements.clear(),kf.delete(t)}function Bv(){kf.forEach(Gv)}var yf;function KE(){typeof document>"u"||(yf||(yf=new MutationObserver(function(){Bv()})),Bv(),yf.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}KE();function kl(t){return typeof document>"u"?wf:(kf.add(t),Gv(t),{revert:function(){qE(t)}})}function _f(t,e){return kl({kind:"html",elements:new Set,mutate:e,selector:t})}function Zv(t,e){return kl({kind:"position",elements:new Set,mutate:e,selector:t})}function _o(t,e){return kl({kind:"class",elements:new Set,mutate:e,selector:t})}function ml(t,e,n){return CE.test(e)?e==="class"||e==="className"?_o(t,function(r){var i=n(Array.from(r).join(" "));r.clear(),i&&i.split(/\s+/g).filter(Boolean).forEach(function(s){return r.add(s)})}):kl({kind:"attribute",attribute:e,elements:new Set,mutate:n,selector:t}):wf}function GE(t){var e=t.selector,n=t.action,r=t.value,i=t.attribute,s=t.parentSelector,o=t.insertBeforeSelector;if(i==="html"){if(n==="append")return _f(e,function(a){return a+(r??"")});if(n==="set")return _f(e,function(){return r??""})}else if(i==="class"){if(n==="append")return _o(e,function(a){r&&a.add(r)});if(n==="remove")return _o(e,function(a){r&&a.delete(r)});if(n==="set")return _o(e,function(a){a.clear(),r&&a.add(r)})}else if(i==="position"){if(n==="set"&&s)return Zv(e,function(){return{insertBeforeSelector:o,parentSelector:s}})}else{if(n==="append")return ml(e,i,function(a){return a!==null?a+(r??""):r??""});if(n==="set")return ml(e,i,function(){return r??""});if(n==="remove")return ml(e,i,function(){return null})}return wf}var ZE={html:_f,classes:_o,attribute:ml,position:Zv,declarative:GE},Yv=ZE;var xf={};function tr(t,e,n){n=n||{};for(let[r,i]of Object.entries(e))switch(r){case"$or":if(!Qv(t,i,n))return!1;break;case"$nor":if(Qv(t,i,n))return!1;break;case"$and":if(!tS(t,i,n))return!1;break;case"$not":if(tr(t,i,n))return!1;break;default:if(!wo(i,YE(t,r),n))return!1}return!0}function YE(t,e){let n=e.split("."),r=t;for(let i=0;i<n.length;i++)if(r&&typeof r=="object"&&n[i]in r)r=r[n[i]];else return null;return r}function QE(t){return xf[t]||(xf[t]=new RegExp(t.replace(/([^\\])\//g,"$1\\/"))),xf[t]}function wo(t,e,n){if(typeof t=="string")return e+""===t;if(typeof t=="number")return e*1===t;if(typeof t=="boolean")return e!==null&&!!e===t;if(t===null)return e===null;if(Array.isArray(t)||!Xv(t))return JSON.stringify(e)===JSON.stringify(t);for(let r in t)if(!eS(r,e,t[r],n))return!1;return!0}function Xv(t){let e=Object.keys(t);return e.length>0&&e.filter(n=>n[0]==="$").length===e.length}function XE(t){if(t===null)return"null";if(Array.isArray(t))return"array";let e=typeof t;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function JE(t,e,n){if(!Array.isArray(t))return!1;let r=Xv(e)?i=>wo(e,i,n):i=>tr(i,e,n);for(let i=0;i<t.length;i++)if(t[i]&&r(t[i]))return!0;return!1}function xl(t,e){return Array.isArray(t)?t.some(n=>e.includes(n)):e.includes(t)}function eS(t,e,n,r){switch(t){case"$veq":return ht(e)===ht(n);case"$vne":return ht(e)!==ht(n);case"$vgt":return ht(e)>ht(n);case"$vgte":return ht(e)>=ht(n);case"$vlt":return ht(e)<ht(n);case"$vlte":return ht(e)<=ht(n);case"$eq":return e===n;case"$ne":return e!==n;case"$lt":return e<n;case"$lte":return e<=n;case"$gt":return e>n;case"$gte":return e>=n;case"$exists":return n?e!=null:e==null;case"$in":return Array.isArray(n)?xl(e,n):!1;case"$inGroup":return xl(e,r[n]||[]);case"$notInGroup":return!xl(e,r[n]||[]);case"$nin":return Array.isArray(n)?!xl(e,n):!1;case"$not":return!wo(n,e,r);case"$size":return Array.isArray(e)?wo(n,e.length,r):!1;case"$elemMatch":return JE(e,n,r);case"$all":if(!Array.isArray(e))return!1;for(let i=0;i<n.length;i++){let s=!1;for(let o=0;o<e.length;o++)if(wo(n[i],e[o],r)){s=!0;break}if(!s)return!1}return!0;case"$regex":try{return QE(n).test(e)}catch{return!1}case"$type":return XE(e)===n;default:return console.error("Unknown operator: "+t),!1}}function Qv(t,e,n){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(tr(t,e[r],n))return!0;return!1}function tS(t,e,n){for(let r=0;r<e.length;r++)if(!tr(t,e[r],n))return!1;return!0}var nS="Feature Evaluated",rS="Experiment Viewed";function iS(t){let e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach((n,r)=>e.set(r,n)),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach((n,r)=>e.set(r,n)),e}function sS(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}async function Wi(t){try{await t()}catch{}}function Jv(t,e,n){if(t.user.trackedExperiments){let i=bl(e,n);if(t.user.trackedExperiments.has(i))return[];t.user.trackedExperiments.add(i)}t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({experiment:e,result:n,timestamp:Date.now().toString(),logType:"experiment"});let r=[];if(t.global.trackingCallback){let i=t.global.trackingCallback;r.push(Wi(()=>i(e,n,t.user)))}if(t.user.trackingCallback){let i=t.user.trackingCallback;r.push(Wi(()=>i(e,n)))}if(t.global.eventLogger){let i=t.global.eventLogger;r.push(Wi(()=>i(rS,{experimentId:e.key,variationId:n.key,hashAttribute:n.hashAttribute,hashValue:n.hashValue},t.user)))}return r}function oS(t,e,n){if(t.user.trackedFeatureUsage){let r=JSON.stringify(n.value);if(t.user.trackedFeatureUsage[e]===r)return;t.user.trackedFeatureUsage[e]=r,t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({featureKey:e,result:n,timestamp:Date.now().toString(),logType:"feature"})}if(t.global.onFeatureUsage){let r=t.global.onFeatureUsage;Wi(()=>r(e,n,t.user))}if(t.user.onFeatureUsage){let r=t.user.onFeatureUsage;Wi(()=>r(e,n))}if(t.global.eventLogger){let r=t.global.eventLogger;Wi(()=>r(nS,{feature:e,source:n.source,value:n.value,ruleId:n.source==="defaultValue"?"$default":n.ruleId||"",variationId:n.experimentResult?n.experimentResult.key:""},t.user))}}function El(t,e){if(e.stack.evaluatedFeatures.has(t))return nr(e,t,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(t),e.stack.id=t;let n=iS(e);if(n.has(t))return nr(e,t,n.get(t),"override");if(!e.global.features||!e.global.features[t])return nr(e,t,null,"unknownFeature");let r=e.global.features[t];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 u=El(l.id,e);if(u.source==="cyclicPrerequisite")return nr(e,t,null,"cyclicPrerequisite");let c={value:u.value};if(!tr(c,l.condition||{})){if(l.gate)return nr(e,t,null,"prerequisite");continue e}}if(s.filters&&ny(s.filters,e))continue;if("force"in s){if(s.condition&&!ty(s.condition,e)||!aS(e,s.seed||t,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=>{!Jv(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),nr(e,t,s.force,"force",s.id)}if(!s.variations)continue;let o={variations:s.variations,key:s.key||t};"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}=Sl(o,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return nr(e,t,a.value,"experiment",s.id,o,a)}}return nr(e,t,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function Sl(t,e,n){let r=t.key,i=t.variations.length;if(i<2)return{result:de(n,t,-1,!1,e)};if(n.global.enabled===!1||n.user.enabled===!1)return{result:de(n,t,-1,!1,e)};if(t=lS(t,n),t.urlPatterns&&!ul(n.user.url||"",t.urlPatterns))return{result:de(n,t,-1,!1,e)};let s=Ov(r,n.user.url||"",i);if(s!==null)return{result:de(n,t,s,!1,e)};let o=sS(n);if(r in o){let k=o[r];return{result:de(n,t,k,!1,e)}}if(t.status==="draft"||t.active===!1)return{result:de(n,t,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Ur(n,t.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!l)return{result:de(n,t,-1,!1,e)};let u=-1,c=!1,d=!1;if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{variation:k,versionIsBlocked:h}=dS({ctx:n,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});c=k>=0,u=k,d=!!h}if(!c){if(t.filters){if(ny(t.filters,n))return{result:de(n,t,-1,!1,e)}}else if(t.namespace&&!Pv(l,t.namespace))return{result:de(n,t,-1,!1,e)};if(t.include&&!Nv(t.include))return{result:de(n,t,-1,!1,e)};if(t.condition&&!ty(t.condition,n))return{result:de(n,t,-1,!1,e)};if(t.parentConditions){let k=new Set(n.stack.evaluatedFeatures);for(let h of t.parentConditions){n.stack.evaluatedFeatures=new Set(k);let p=El(h.id,n);if(p.source==="cyclicPrerequisite")return{result:de(n,t,-1,!1,e)};let m={value:p.value};if(!tr(m,h.condition||{}))return{result:de(n,t,-1,!1,e)}}}if(t.groups&&!cS(t.groups,n))return{result:de(n,t,-1,!1,e)}}if(t.url&&!uS(t.url,n))return{result:de(n,t,-1,!1,e)};let f=mo(t.seed||r,l,t.hashVersion||1);if(f===null)return{result:de(n,t,-1,!1,e)};if(!c){let k=t.ranges||Av(i,t.coverage===void 0?1:t.coverage,t.weights);u=Rv(f,k)}if(d)return{result:de(n,t,-1,!1,e,void 0,!0)};if(u<0)return{result:de(n,t,-1,!1,e)};if("force"in t)return{result:de(n,t,t.force===void 0?-1:t.force,!1,e)};if(n.global.qaMode||n.user.qaMode)return{result:de(n,t,-1,!1,e)};if(t.status==="stopped")return{result:de(n,t,-1,!1,e)};let g=de(n,t,u,!0,e,f,c);if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{changed:k,key:h,doc:p}=pS(n,a,vo(l),{[Ef(t.key,t.bucketVersion)]:g.key});k&&(n.user.stickyBucketAssignmentDocs=n.user.stickyBucketAssignmentDocs||{},n.user.stickyBucketAssignmentDocs[h]=p,n.user.saveStickyBucketAssignmentDoc(p))}let v=Jv(n,t,g);v.length===0&&n.global.saveDeferredTrack&&n.global.saveDeferredTrack({experiment:t,result:g});let y=v.length?v.length===1?v[0]:Promise.all(v).then(()=>{}):void 0;return"changeId"in t&&t.changeId&&n.global.recordChangeId&&n.global.recordChangeId(t.changeId),{result:g,trackingCall:y}}function nr(t,e,n,r,i,s,o){let a={value:n,on:!!n,off:!n,source:r,ruleId:i||""};return s&&(a.experiment=s),o&&(a.experimentResult=o),r!=="override"&&oS(t,e,a),a}function ey(t){return{...t.user.attributes,...t.user.attributeOverrides}}function ty(t,e){return tr(ey(e),t,e.global.savedGroups||{})}function ny(t,e){return t.some(n=>{let{hashValue:r}=Ur(e,n.attribute);if(!r)return!0;let i=mo(n.seed,r,n.hashVersion||2);return i===null?!0:!n.ranges.some(s=>ll(i,s))})}function aS(t,e,n,r,i,s,o){if(!i&&s===void 0)return!0;if(!i&&s===0)return!1;let{hashValue:a}=Ur(t,n,r);if(!a)return!1;let l=mo(e,a,o||1);return l===null?!1:i?ll(l,i):s!==void 0?l<=s:!0}function de(t,e,n,r,i,s,o){let a=!0;(n<0||n>=e.variations.length)&&(n=0,a=!1);let{hashAttribute:l,hashValue:u}=Ur(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),c=e.meta?e.meta[n]:{},d={key:c.key||""+n,featureId:i,inExperiment:a,hashUsed:r,variationId:n,value:e.variations[n],hashAttribute:l,hashValue:u,stickyBucketUsed:!!o};return c.name&&(d.name=c.name),s!==void 0&&(d.bucket=s),c.passthrough&&(d.passthrough=c.passthrough),d}function lS(t,e){let n=t.key,r=e.global.overrides;return r&&r[n]&&(t=Object.assign({},t,r[n]),typeof t.url=="string"&&(t.url=cf(t.url))),t}function Ur(t,e,n){let r=e||"id",i="",s=ey(t);return s[r]&&(i=s[r]),!i&&n&&(s[n]&&(i=s[n]),i&&(r=n)),{hashAttribute:r,hashValue:i}}function uS(t,e){let n=e.user.url;if(!n)return!1;let r=n.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(t.test(n)||t.test(r))}function cS(t,e){let n=e.global.groups||{};for(let r=0;r<t.length;r++)if(n[t[r]])return!0;return!1}function dS(t){let{ctx:e,expKey:n,expBucketVersion:r,expHashAttribute:i,expFallbackAttribute:s,expMinBucketVersion:o,expMeta:a}=t;r=r||0,o=o||0,i=i||"id",a=a||[];let l=Ef(n,r),u=fS(e,i,s);if(o>0)for(let f=0;f<o;f++){let g=Ef(n,f);if(u[g]!==void 0)return{variation:-1,versionIsBlocked:!0}}let c=u[l];if(c===void 0)return{variation:-1};let d=a.findIndex(f=>f.key===c);return d<0?{variation:-1}:{variation:d}}function Ef(t,e){return e=e||0,`${t}__${e}`}function Sf(t,e){return`${t}||${e}`}function fS(t,e,n){if(!t.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:r,hashValue:i}=Ur(t,e),s=Sf(r,vo(i)),{hashAttribute:o,hashValue:a}=Ur(t,n),l=a?Sf(o,vo(a)):null,u={};return l&&t.user.stickyBucketAssignmentDocs[l]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[l].assignments||{}),t.user.stickyBucketAssignmentDocs[s]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[s].assignments||{}),u}function pS(t,e,n,r){let i=Sf(e,n),s=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[i]?t.user.stickyBucketAssignmentDocs[i].assignments||{}:{},o={...s,...r},a=JSON.stringify(s)!==JSON.stringify(o);return{key:i,doc:{attributeName:e,attributeValue:n,assignments:o},changed:a}}function hS(t,e){let n=new Set,r=e&&e.features?e.features:t.global.features||{},i=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(r).forEach(s=>{let o=r[s];if(o.rules)for(let a of o.rules)a.variations&&(n.add(a.hashAttribute||"id"),a.fallbackAttribute&&n.add(a.fallbackAttribute))}),i.map(s=>{n.add(s.hashAttribute||"id"),s.fallbackAttribute&&n.add(s.fallbackAttribute)}),Array.from(n)}async function ry(t,e,n){let r=bf(t,n);return e.getAllAssignments(r)}function bf(t,e){let n={};return hS(t,e).forEach(i=>{let{hashValue:s}=Ur(t,i);n[i]=vo(s)}),n}async function iy(t,e,n){if(t={...t},t.encryptedFeatures){try{t.features=JSON.parse(await Hr(t.encryptedFeatures,e,n))}catch(r){console.error(r)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await Hr(t.encryptedExperiments,e,n))}catch(r){console.error(r)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await Hr(t.encryptedSavedGroups,e,n))}catch(r){console.error(r)}delete t.encryptedSavedGroups}return t}function sy(t){let e=t.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(t.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}function bl(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}var qi=typeof window<"u"&&typeof document<"u",gS=Fv(),Ki=class{constructor(e){if(e=e||{},this.version=gS,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 n=!1;try{n=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(n)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 n=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=r=>n.saveAssignments(r)}if(e.plugins)for(let n of e.plugins)n(this);if(e.features&&(this.ready=!0),qi&&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 n in this._options.stickyBucketAssignmentDocs){let r=this._options.stickyBucketAssignmentDocs[n];r&&this._options.stickyBucketService.saveAssignments(r).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let n=await iy(e,this._options.decryptionKey);this._decryptedPayload=n,await this.refreshStickyBuckets(n),n.features&&(this._options.features=n.features),n.savedGroups&&(this._options.savedGroups=n.savedGroups),n.experiments&&(this._options.experiments=n.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let n=e.payload;if(n.encryptedExperiments||n.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,n)),this._payload=n,this._decryptedPayload=n,n.features&&(this._options.features=n.features),n.experiments&&(this._options.experiments=n.experiments,this._updateAllAutoExperiments()),this.ready=!0,pl(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&ff(e.cacheSettings),e.payload)return await this.setPayload(e.payload),pl(this,e),{success:!0,source:"init"};{let{data:n,...r}=await this._refresh({...e,allowStale:!0});return pl(this,e),await this.setPayload(n||{}),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 n=await this._refresh({...e||{},allowStale:!1});n.data&&await this.setPayload(n.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return sy(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(e){let{timeout:n,skipCache:r,allowStale:i,streaming:s}=e;if(!this._options.clientKey)throw new Error("Missing clientKey");return $v({instance:this,timeout:n,skipCache:r||this._options.disableCache,allowStale:i,backgroundSync:s??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,n,r){let i=await Hr(e,n||this._options.decryptionKey,r);this.setFeatures(JSON.parse(i))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,n,r){let i=await Hr(e,n||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(n=>{try{n()}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,Dv(this),e.destroyAllStreams&&vf(),this.logs=[],qi&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(n=>{n.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,n){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=n,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:n}=Sl(e,null,this._getEvalContext());return this._onExperimentEval(e,n),n}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,n){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=de(this._getEvalContext(),e,-1,!1,""):({result:s,trackingCall:o}=Sl(e,null,this._getEvalContext()),this._onExperimentEval(e,s));let a=JSON.stringify(s.value);if(!n&&s.inExperiment&&r&&r.valueHash===a)return s;if(r&&this._undoActiveAutoExperiment(e),s.inExperiment){let l=cl(e);if(l==="redirect"&&s.value.urlRedirect&&e.urlPatterns){let u=e.persistQueryString?Lv(this._getContextUrl(),s.value.urlRedirect):s.value.urlRedirect;if(ul(u,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),s;this._redirectedUrl=u;let{navigate:c,delay:d}=this._getNavigateFunction();if(c)if(qi)Promise.all([...o?[dl(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(f=>window.setTimeout(f,this._options.navigateDelay??d))]).then(()=>{try{c(u)}catch(f){console.error(f)}});else try{c(u)}catch(f){console.error(f)}}else if(l==="visual"){let u=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(s.value):this._applyDOMChanges(s.value);u&&this._activeAutoExperiments.set(e,{undo:u,valueHash:a})}}return s}_undoActiveAutoExperiment(e){let n=this._activeAutoExperiments.get(e);n&&(n.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let n=this._options.experiments||[],r=new Set(n);this._activeAutoExperiments.forEach((i,s)=>{r.has(s)||(i.undo(),this._activeAutoExperiments.delete(s))});for(let i of n){let s=this._runAutoExperiment(i,e);if(s&&s.inExperiment&&cl(i)==="redirect")break}}_onExperimentEval(e,n){let r=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:n}),this._subscriptions.size>0&&this._fireSubscriptions(e,n,r)}_fireSubscriptions(e,n,r){(!r||r.result.inExperiment!==n.inExperiment||r.result.variationId!==n.variationId)&&this._subscriptions.forEach(i=>{try{i(e,n)}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,n){let r=this.evalFeature(e).value;return r===null?n:r}feature(e){return this.evalFeature(e)}evalFeature(e){return El(e,this._getEvalContext())}log(e,n){this.debug&&(this._options.log?this._options.log(e,n):console.log(e,n))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(n=>n&&n.experiment&&n.result).map(n=>[bl(n.experiment,n.result),n]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(n=>{!n||!n.experiment||!n.result?console.error("Invalid deferred tracking call",{call:n}):e.push(this._options.trackingCallback(n.experiment,n.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,n){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:n,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,n||{},this._getUserContext())}catch(r){console.error(r)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(bl(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(qi?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let n=cl(e);if(n==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(r=>r.js))return!0}else if(n==="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}:qi?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!qi)return;let n=[];if(e.css){let r=document.createElement("style");r.innerHTML=e.css,document.head.appendChild(r),n.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),n.push(()=>r.remove())}return e.domMutations&&e.domMutations.forEach(r=>{n.push(Yv.declarative(r).revert)}),()=>{n.forEach(r=>r())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let n=this._getEvalContext(),r=await ry(n,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=r}}generateStickyBucketAssignmentDocsSync(e,n){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let r=this._getEvalContext(),i=bf(r,n);return e.getAllAssignmentsSync(i)}inDevMode(){return!!this._options.enableDevMode}};var on=ve(bt());function Of(){return Of=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Of.apply(null,arguments)}var NS=on.createContext({});var FS=t=>n=>on.createElement(NS.Consumer,null,({growthbook:r})=>on.createElement(t,Of({},n,{runExperiment:i=>r.run(i)})));FS.displayName="WithRunExperiment";var LS="https://experiment.syntrologie.com",Nf=class{constructor(e={}){Ze(this,"gb");e.client?this.gb=e.client:(this.gb=new Ki({...e,apiHost:e.apiHost??LS}),e.autoInit&&this.gb.init({streaming:!0}))}get _internal(){return this.gb}async refreshFeatures(){await this.gb.loadFeatures()}setAttributes(e){this.gb.setAttributes(e)}getFeatureValue(e,n){return this.gb.getFeatureValue(e,n)}shouldRenderRectangle(e){let n=e.experiment;if(!n||!n.featureKey)return!0;let r=this.gb.getFeatureValue(n.featureKey,null);if(r==null)return!1;if(typeof n.variationId=="number")return Number(r)===n.variationId;if(typeof n.variationValue<"u")return r===n.variationValue;if(n.predicate)try{return n.predicate(r)}catch{return!1}return!!r}};function Ff(t={}){return new Nf(t)}var rr=ve(bt(),1),IS=t=>[...t].sort((e,n)=>(e.order??0)-(n.order??0));function _y({fetcher:t,pollIntervalMs:e=3e4,experiments:n}){let[r,i]=(0,rr.useState)({rectangles:[],isLoading:!0}),s=(0,rr.useCallback)(async()=>{try{i(l=>({...l,isLoading:!0,error:void 0}));let o=await t(),a=o.tiles||o.rectangles||[];n&&(a=a.filter(l=>n.shouldRenderRectangle(l))),i({rectangles:IS(a),isLoading:!1,fetchedAt:o.fetchedAt,canvasTitle:o.canvasTitle,configVersion:o.configVersion,patches:o.patches,overlayRecipe:o.overlayRecipe,displayMode:o.displayMode})}catch(o){i(a=>({...a,isLoading:!1,error:o instanceof Error?o.message:"Unknown error"}))}},[n,t]);return(0,rr.useEffect)(()=>{if(s(),!e)return;let o=setInterval(s,e);return()=>clearInterval(o)},[s,e]),(0,rr.useMemo)(()=>r,[r])}var Wr=ve(bt(),1),G=ve(Vt(),1);function HS({config:t,telemetry:e,surface:n}){let[r,i]=(0,Wr.useState)([{author:"Lumi",text:"Hi! Need clarity on a deduction?"}]),[s,o]=(0,Wr.useState)(""),a=l=>{l.preventDefault(),s.trim()&&(i(u=>[...u,{author:"You",text:s.trim()}]),setTimeout(()=>{i(u=>[...u,{author:"Lumi",text:"I will route that to the experimentation server stub for now."}])},600),e?.trackAction("chatbot_message",t.id,n),o(""))};return(0,G.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",height:"100%"},children:[(0,G.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"0.75rem",background:"rgba(0, 0, 0, 0.2)",borderRadius:"8px",fontSize:"0.85rem"},children:r.map((l,u)=>(0,G.jsxs)("p",{style:{margin:"0 0 0.5rem"},children:[(0,G.jsxs)("span",{style:{fontWeight:600,color:"#94a3b8"},children:[l.author,":"]})," ",(0,G.jsx)("span",{style:{color:"#e2e8f0"},children:l.text})]},`${l.author}-${u}`))}),(0,G.jsxs)("form",{onSubmit:a,style:{display:"flex",gap:"0.5rem"},children:[(0,G.jsx)("input",{style:{flex:1,padding:"0.5rem 0.75rem",borderRadius:"6px",border:"1px solid rgba(255, 255, 255, 0.1)",background:"rgba(0, 0, 0, 0.3)",color:"#f1f5f9",fontSize:"0.85rem",outline:"none"},value:s,onChange:l=>o(l.target.value),placeholder:"Ask anything..."}),(0,G.jsx)("button",{style:{padding:"0.5rem 0.75rem",borderRadius:"6px",border:"none",background:"#6366f1",color:"white",fontWeight:600,fontSize:"0.8rem",cursor:"pointer"},type:"submit",children:"Send"})]})]})}function BS({renderer:t,config:e,surface:n,telemetry:r,isExpanded:i}){let s=(0,Wr.useRef)(null);return(0,Wr.useEffect)(()=>{if(!s.current)return;let o=t.mount(s.current,{config:e,surface:n,telemetry:r,isExpanded:i});return()=>{o&&o()}},[t,e,n,r,i]),(0,G.jsx)("div",{ref:s,style:{width:"100%",height:"100%"}})}function xo({config:t,surface:e,telemetry:n,style:r,customRenderers:i,isExpanded:s=!1,onToggleExpand:o}){let{title:a,subtitle:l,content:u,style:c}=t,d=c?.accentColor??"#6366f1",f="72px",g={display:"flex",flexDirection:"column",borderRadius:"14px",background:c?.background??"rgba(28, 28, 30, 0.95)",border:"1px solid rgba(255, 255, 255, 0.08)",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.3)",color:c?.textColor??"#f5f5f7",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif",overflow:"hidden",cursor:o?"pointer":"default",transition:"all 0.25s ease",...r},v={display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.875rem 1rem",minHeight:f},y={width:"40px",height:"40px",borderRadius:"10px",background:`linear-gradient(135deg, ${d} 0%, ${d}cc 100%)`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.25rem",flexShrink:0,boxShadow:`0 2px 8px ${d}40`},k=()=>{switch(u.type){case"chatbot":return"\u{1F4AC}";case"metric":return"\u{1F4CA}";case"embed":return"\u{1F517}";case"custom":return"\u2699\uFE0F";default:return"\u{1F4C4}"}},h=()=>{switch(u.type){case"metric":return`${u.metricValue}${u.metricUnit?` ${u.metricUnit}`:""}`;case"text":return u.headline||u.body?.slice(0,50)||"";case"chatbot":return"Tap to chat";case"embed":return"Tap to view";case"custom":return"Tap to expand";default:return""}},p=()=>{switch(u.type){case"chatbot":return(0,G.jsx)("div",{style:{height:"200px"},children:(0,G.jsx)(HS,{config:t,surface:e,telemetry:n})});case"metric":return(0,G.jsxs)("div",{style:{textAlign:"center",padding:"0.5rem 0"},children:[(0,G.jsxs)("p",{style:{fontSize:"3rem",fontWeight:700,color:d,margin:0,letterSpacing:"-0.02em"},children:[u.metricValue,u.metricUnit&&(0,G.jsx)("span",{style:{fontSize:"1.25rem",fontWeight:400,color:"#8e8e93",marginLeft:"0.5rem"},children:u.metricUnit})]}),u.headline&&(0,G.jsx)("p",{style:{fontSize:"0.85rem",color:"#8e8e93",margin:"0.5rem 0 0"},children:u.headline})]});case"embed":return u.embedUrl?(0,G.jsx)("iframe",{src:u.embedUrl,sandbox:"allow-scripts allow-same-origin",referrerPolicy:"no-referrer",style:{width:"100%",height:"200px",borderRadius:"8px",border:"1px solid rgba(255, 255, 255, 0.1)",background:"rgba(0, 0, 0, 0.2)"},title:u.headline??t.title}):null;case"custom":{let m=u.component||u.customRendererKey;return!m||!i||!i[m]?(0,G.jsxs)("div",{style:{color:"#ff6b6b",fontSize:"0.85rem",padding:"0.5rem 0"},children:["Unknown component: ",m]}):(0,G.jsx)(BS,{renderer:i[m],config:t,surface:e,telemetry:n,isExpanded:s})}case"text":default:return(0,G.jsxs)("div",{style:{padding:"0.25rem 0"},children:[u.headline&&(0,G.jsx)("p",{style:{fontSize:"1rem",fontWeight:600,color:"#f5f5f7",margin:"0 0 0.5rem"},children:u.headline}),u.body&&(0,G.jsx)("p",{style:{fontSize:"0.9rem",color:"#8e8e93",margin:0,lineHeight:1.5},children:u.body})]})}};return(0,G.jsxs)("article",{"data-shadow-canvas-id":`rectangle-${t.id}`,style:g,onClick:m=>{s&&m.target.closest("[data-expanded-content]")||o?.()},children:[(0,G.jsxs)("div",{style:v,children:[(0,G.jsx)("div",{style:y,children:k()}),(0,G.jsxs)("div",{style:{flex:1,minWidth:0},children:[l&&(0,G.jsx)("p",{style:{fontSize:"0.7rem",textTransform:"uppercase",letterSpacing:"0.05em",color:"#8e8e93",margin:0},children:l}),(0,G.jsx)("h3",{style:{fontSize:"0.95rem",fontWeight:600,color:"#f5f5f7",margin:"0.125rem 0 0",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:a}),!s&&(0,G.jsx)("p",{style:{fontSize:"0.8rem",color:"#8e8e93",margin:"0.125rem 0 0",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:h()})]}),(0,G.jsx)("div",{style:{color:"#8e8e93",fontSize:"0.85rem",transform:s?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:"\u25BC"})]}),s&&(0,G.jsxs)("div",{"data-expanded-content":!0,style:{padding:"0 1rem 1rem",borderTop:"1px solid rgba(255, 255, 255, 0.06)"},onClick:m=>m.stopPropagation(),children:[(0,G.jsx)("div",{style:{paddingTop:"0.875rem"},children:p()}),u.actions&&u.actions.length>0&&(0,G.jsx)("div",{style:{marginTop:"1rem",paddingTop:"0.75rem",borderTop:"1px solid rgba(255, 255, 255, 0.06)",display:"flex",gap:"0.5rem"},children:u.actions.map((m,_)=>(0,G.jsx)("button",{onClick:w=>{w.stopPropagation(),m.href&&typeof window<"u"&&window.open(m.href,"_blank","noreferrer"),m.onClickId&&n?.trackAction(m.onClickId,t.id,e)},style:{flex:1,padding:"0.625rem 1rem",borderRadius:"8px",fontSize:"0.85rem",fontWeight:600,cursor:"pointer",border:"none",background:_===0?d:"rgba(255, 255, 255, 0.1)",color:"#fff",transition:"opacity 0.15s ease"},onMouseEnter:w=>{w.currentTarget.style.opacity="0.85"},onMouseLeave:w=>{w.currentTarget.style.opacity="1"},children:m.label},m.label))})]})]})}var Ss=ve(bt(),1),Kh=ve(Zu(),1);var ae=ve(Vt(),1),qC={position:"right",baseWidth:"clamp(320px, 16.666vw, 420px)",expandedWidth:"40vw",zIndex:2147483600,backdropBlur:"18px"};function zw({isOpen:t,onToggle:e,telemetry:n,launcherLabel:r="Canvas",footerSlot:i,rectangles:s,isLoading:o,error:a,canvasTitle:l,displayMode:u="standard",theme:c,customRenderers:d}){let[f,g]=(0,Ss.useState)(!1),[v,y]=(0,Ss.useState)(null),k={...qC,...c},h=E=>{y(v===E?null:E)};(0,Ss.useEffect)(()=>{!t||!n||s.forEach(E=>{n.trackRectangleViewed(E.id,"overlay")})},[n,t,s]),(0,Ss.useEffect)(()=>{g(!0)},[]);let p=()=>{!t?n?.trackCanvasOpened("overlay"):n?.trackCanvasClosed("overlay"),e()},m=u==="focused",_=k.position==="right",w={display:"flex",flexDirection:"column",width:m?k.expandedWidth:k.baseWidth,minWidth:"320px",height:"100%",maxHeight:"100%",background:m?"linear-gradient(to top right, rgba(80, 10, 20, 0.5) 0%, rgba(12, 12, 12, 0.98) 50%, rgba(8, 8, 8, 0.99) 100%)":"linear-gradient(to top right, rgba(60, 8, 15, 0.6) 0%, rgba(12, 12, 12, 0.95) 45%, rgba(8, 8, 8, 0.97) 100%)",backdropFilter:`blur(${k.backdropBlur})`,WebkitBackdropFilter:`blur(${k.backdropBlur})`,pointerEvents:"auto",opacity:t?1:.8,transition:"all 340ms cubic-bezier(0.16, 1, 0.3, 1)",border:m?_?void 0:"1px solid rgba(255, 255, 255, 0.06)":"1px solid rgba(80, 20, 30, 0.4)",borderLeft:m&&_?"1px solid rgba(255, 255, 255, 0.08)":void 0,borderRight:m&&!_?"1px solid rgba(255, 255, 255, 0.08)":void 0,borderRadius:m?"0":"24px",boxShadow:m?"none":"0 25px 80px rgba(0, 0, 0, 0.7), inset 0 0 80px rgba(60, 8, 15, 0.15)",transform:t?"translateX(0)":_?"translateX(120%)":"translateX(-120%)"},b={position:"absolute",inset:0,display:"flex",flexDirection:_?"row-reverse":"row",alignItems:"stretch",pointerEvents:"none",padding:m?"0":"1rem"},S=(0,ae.jsx)("div",{"data-shadow-canvas-id":"overlay-root",style:{position:"fixed",inset:0,pointerEvents:t?"auto":"none",zIndex:k.zIndex},children:(0,ae.jsxs)("div",{style:b,children:[(0,ae.jsxs)("div",{style:w,children:[!m&&(0,ae.jsx)("header",{style:{color:"white",padding:"1.5rem 1.5rem 0"},children:(0,ae.jsx)("p",{style:{margin:0,fontSize:"0.7rem",textTransform:"uppercase",letterSpacing:"0.5em",color:"rgba(255, 255, 255, 0.6)"},children:l??"Smart Canvas"})}),(0,ae.jsx)("div",{style:{flex:1,overflowY:"auto",padding:m?"0":"1.5rem"},children:o?(0,ae.jsx)("div",{style:{color:"rgba(255, 255, 255, 0.85)",padding:m?"1rem":"0"},children:"Loading..."}):a?(0,ae.jsxs)("div",{style:{color:"#fecdd3",padding:m?"1rem":"0"},children:["Failed to load: ",a]}):m?s.length>0?(0,ae.jsx)(xo,{config:s[0],surface:"overlay",telemetry:n,customRenderers:d,isExpanded:!0,onToggleExpand:()=>{},style:{width:"100%",height:"100%"}}):null:(0,ae.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:"0.625rem",width:"100%"},children:s.map(E=>{let j=(E.size??"half")==="quarter"||E.size==="half",F=v===E.id;return(0,ae.jsx)("div",{style:{gridColumn:j&&!F?"span 1":"span 2",transition:"all 0.25s ease"},children:(0,ae.jsx)(xo,{config:E,surface:"overlay",telemetry:n,customRenderers:d,isExpanded:F,onToggleExpand:()=>h(E.id),style:{width:"100%"}})},E.id)})})}),i]}),(0,ae.jsx)("div",{onClick:p,style:{flex:"1 1 auto",pointerEvents:t?"auto":"none",cursor:"default"}})]})});return f?(0,ae.jsxs)(ae.Fragment,{children:[(0,Kh.createPortal)((0,ae.jsx)("div",{"data-shadow-canvas-id":"overlay-launcher",style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:k.zIndex+47},children:(0,ae.jsxs)("button",{onClick:p,"aria-label":"Toggle shadow canvas",style:{position:"fixed",bottom:"2.5rem",right:_?"2.5rem":void 0,left:_?void 0:"2.5rem",pointerEvents:"auto",display:"flex",alignItems:"center",gap:"0.75rem",borderRadius:"18px",color:"white",boxShadow:"0 20px 45px rgba(15, 23, 42, 0.35)",transition:"transform 0.2s ease",outline:"none",padding:"0.65rem 1.25rem",border:"2px solid rgba(255, 255, 255, 0.25)",backgroundColor:"rgba(2, 6, 23, 0.8)",backdropFilter:"blur(12px)",cursor:"pointer"},onMouseEnter:E=>E.currentTarget.style.transform="translateY(-2px)",onMouseLeave:E=>E.currentTarget.style.transform="translateY(0)",children:[(0,ae.jsx)("div",{style:{width:"36px",height:"36px",borderRadius:"12px",background:t?"linear-gradient(135deg, #f472b6, #ec4899)":"linear-gradient(135deg, #94a3b8, #0f172a)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,ae.jsx)("span",{style:{width:"14px",height:"2px",backgroundColor:"#fff",display:"block",transform:t?"rotate(45deg)":"rotate(0)",position:"relative",transition:"transform 200ms ease"},children:t?null:(0,ae.jsx)("span",{style:{position:"absolute",top:0,left:0,width:"14px",height:"2px",backgroundColor:"#fff",transform:"rotate(90deg)"}})})}),(0,ae.jsxs)("div",{style:{display:"flex",flexDirection:"column",textAlign:"left"},children:[(0,ae.jsx)("span",{style:{fontSize:"0.55rem",letterSpacing:"0.35em",color:"rgba(255,255,255,0.7)"},children:t?"Hide":"Open"}),(0,ae.jsx)("span",{style:{fontSize:"0.85rem",letterSpacing:"0.25em"},children:r})]})]})}),document.body),t?(0,Kh.createPortal)(S,document.body):null]}):null}var Cr=ve(bt(),1);var br=ve(Vt(),1);function hA({rectangles:t,intervalMs:e=7e3,telemetry:n}){let[r,i]=(0,Cr.useState)(0),s=(0,Cr.useMemo)(()=>[...t].filter(o=>o.size!=="quarter").sort((o,a)=>(o.order??0)-(a.order??0)),[t]);return(0,Cr.useEffect)(()=>{n?.trackCanvasOpened("wheel")},[n]),(0,Cr.useEffect)(()=>{if(s.length<=1)return;let o=setInterval(()=>{i(a=>(a+1)%s.length)},e);return()=>clearInterval(o)},[s,e]),(0,Cr.useEffect)(()=>{let o=s[r];o&&n?.trackRectangleViewed(o.id,"wheel")},[r,s,n]),s.length?(0,br.jsxs)("div",{className:"relative overflow-hidden rounded-3xl border border-slate-200 bg-gradient-to-br from-white to-slate-50 p-6 shadow-2xl","data-shadow-canvas-id":"wheel",children:[(0,br.jsx)("div",{className:"flex transition-transform duration-700 ease-out",style:{transform:`translateX(-${r*100}%)`,width:`${s.length*100}%`},children:s.map(o=>(0,br.jsx)("div",{className:"w-full shrink-0 px-4",children:(0,br.jsx)(xo,{config:{...o,size:"half"},surface:"wheel",telemetry:n})},o.id))}),(0,br.jsx)("div",{className:"mt-4 flex justify-center gap-2",children:s.map((o,a)=>(0,br.jsx)("button",{className:`h-2 w-6 rounded-full ${a===r?"bg-slate-800":"bg-slate-300"}`,onClick:()=>i(a)},o.id))})]}):null}var Gh=class{constructor(e){Ze(this,"state");Ze(this,"listeners",new Set);this.state={open:e?.open??!1}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOpen(e){this.state.open!==e&&(this.state={...this.state,open:e},this.emit())}toggle(){this.setOpen(!this.state.open)}emit(){for(let e of this.listeners)e(this.state)}},Hw=t=>new Gh(t);var Fr=ve(bt(),1);var KC=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function GC(t){try{let e=new URL(t),n=/^(localhost|127\.0\.0\.1)$/.test(e.hostname);return e.protocol!=="https:"&&!n?(console.warn("[SmartCanvas] Config URI must use HTTPS:",t),!1):KC.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:",t),!1}}function ZC(t){if(typeof window>"u")return!1;try{return new URL(t).origin===window.location.origin}catch{return!1}}var Zh=({configUri:t,experiments:e,featureKey:n="smart-canvas-config-uri"})=>{if(t)return t;let r=e?.getFeatureValue?.(n,null);if(r)return r},bs=({configUri:t,experiments:e,featureKey:n,credentials:r,configFeatureKey:i="smart-canvas-config"})=>async()=>{if(e&&i){let l=e.getFeatureValue?.(i,null);if(l&&typeof l=="object")return l}let s=Zh({configUri:t,experiments:e,featureKey:n});if(!s)throw new Error("SmartCanvas: config URI missing (env + feature flag unset).");if(!GC(s))throw new Error(`SmartCanvas: config URI not allowed: ${s}`);let o=r??(ZC(s)?"include":"omit"),a=await fetch(s,{credentials:o});if(!a.ok)throw new Error(`SmartCanvas: failed to fetch config (${a.status})`);return await a.json()};var pc=ve(bt(),1);var $={};xg($,{BRAND:()=>kT,DIRTY:()=>ai,EMPTY_PATH:()=>JC,INVALID:()=>D,NEVER:()=>sP,OK:()=>Ke,ParseStatus:()=>je,Schema:()=>B,ZodAny:()=>Rr,ZodArray:()=>$n,ZodBigInt:()=>ui,ZodBoolean:()=>ci,ZodBranded:()=>ga,ZodCatch:()=>ki,ZodDate:()=>di,ZodDefault:()=>wi,ZodDiscriminatedUnion:()=>Xu,ZodEffects:()=>It,ZodEnum:()=>yi,ZodError:()=>ut,ZodFirstPartyTypeKind:()=>V,ZodFunction:()=>ec,ZodIntersection:()=>gi,ZodIssueCode:()=>C,ZodLazy:()=>mi,ZodLiteral:()=>vi,ZodMap:()=>Os,ZodNaN:()=>Fs,ZodNativeEnum:()=>_i,ZodNever:()=>Gt,ZodNull:()=>pi,ZodNullable:()=>gn,ZodNumber:()=>li,ZodObject:()=>ct,ZodOptional:()=>Ft,ZodParsedType:()=>N,ZodPipeline:()=>ma,ZodPromise:()=>Ar,ZodReadonly:()=>xi,ZodRecord:()=>Ju,ZodSchema:()=>B,ZodSet:()=>Ns,ZodString:()=>Pr,ZodSymbol:()=>Rs,ZodTransformer:()=>It,ZodTuple:()=>hn,ZodType:()=>B,ZodUndefined:()=>fi,ZodUnion:()=>hi,ZodUnknown:()=>Mn,ZodVoid:()=>As,addIssueToContext:()=>P,any:()=>AT,array:()=>LT,bigint:()=>bT,boolean:()=>Jw,coerce:()=>iP,custom:()=>Yw,date:()=>CT,datetimeRegex:()=>Gw,defaultErrorMap:()=>Ln,discriminatedUnion:()=>DT,effect:()=>YT,enum:()=>KT,function:()=>UT,getErrorMap:()=>Cs,getParsedType:()=>pn,instanceof:()=>ET,intersection:()=>VT,isAborted:()=>Yu,isAsync:()=>Ts,isDirty:()=>Qu,isValid:()=>Tr,late:()=>xT,lazy:()=>WT,literal:()=>qT,makeIssue:()=>ha,map:()=>HT,nan:()=>ST,nativeEnum:()=>GT,never:()=>NT,null:()=>RT,nullable:()=>XT,number:()=>Xw,object:()=>IT,objectUtil:()=>Yh,oboolean:()=>rP,onumber:()=>nP,optional:()=>QT,ostring:()=>tP,pipeline:()=>eP,preprocess:()=>JT,promise:()=>ZT,quotelessJson:()=>YC,record:()=>zT,set:()=>BT,setErrorMap:()=>XC,strictObject:()=>MT,string:()=>Qw,symbol:()=>TT,transformer:()=>YT,tuple:()=>jT,undefined:()=>PT,union:()=>$T,unknown:()=>OT,util:()=>q,void:()=>FT});var q;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{let s={};for(let o of i)s[o]=o;return s},t.getValidEnumValues=i=>{let s=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(let a of s)o[a]=i[a];return t.objectValues(o)},t.objectValues=i=>t.objectKeys(i).map(function(s){return i[s]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},t.find=(i,s)=>{for(let o of i)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(q||(q={}));var Yh;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Yh||(Yh={}));var N=q.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),pn=t=>{switch(typeof t){case"undefined":return N.undefined;case"string":return N.string;case"number":return Number.isNaN(t)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":return Array.isArray(t)?N.array:t===null?N.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?N.promise:typeof Map<"u"&&t instanceof Map?N.map:typeof Set<"u"&&t instanceof Set?N.set:typeof Date<"u"&&t instanceof Date?N.date:N.object;default:return N.unknown}};var C=q.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),YC=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ut=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(s){return s.message},r={_errors:[]},i=s=>{for(let o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){let u=o.path[l];l===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(o))):a[u]=a[u]||{_errors:[]},a=a[u],l++}}};return i(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,q.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let i of this.issues)if(i.path.length>0){let s=i.path[0];n[s]=n[s]||[],n[s].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};ut.create=t=>new ut(t);var QC=(t,e)=>{let n;switch(t.code){case C.invalid_type:t.received===N.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case C.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,q.jsonStringifyReplacer)}`;break;case C.unrecognized_keys:n=`Unrecognized key(s) in object: ${q.joinValues(t.keys,", ")}`;break;case C.invalid_union:n="Invalid input";break;case C.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${q.joinValues(t.options)}`;break;case C.invalid_enum_value:n=`Invalid enum value. Expected ${q.joinValues(t.options)}, received '${t.received}'`;break;case C.invalid_arguments:n="Invalid function arguments";break;case C.invalid_return_type:n="Invalid function return type";break;case C.invalid_date:n="Invalid date";break;case C.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:q.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case C.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case C.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case C.custom:n="Invalid input";break;case C.invalid_intersection_types:n="Intersection results could not be merged";break;case C.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case C.not_finite:n="Number must be finite";break;default:n=e.defaultError,q.assertNever(t)}return{message:n}},Ln=QC;var Bw=Ln;function XC(t){Bw=t}function Cs(){return Bw}var ha=t=>{let{data:e,path:n,errorMaps:r,issueData:i}=t,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="",l=r.filter(u=>!!u).slice().reverse();for(let u of l)a=u(o,{data:e,defaultError:a}).message;return{...i,path:s,message:a}},JC=[];function P(t,e){let n=Cs(),r=ha({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Ln?void 0:Ln].filter(i=>!!i)});t.common.issues.push(r)}var je=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let i of n){if(i.status==="aborted")return D;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let i of n){let s=await i.key,o=await i.value;r.push({key:s,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let i of n){let{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return D;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}},D=Object.freeze({status:"aborted"}),ai=t=>({status:"dirty",value:t}),Ke=t=>({status:"valid",value:t}),Yu=t=>t.status==="aborted",Qu=t=>t.status==="dirty",Tr=t=>t.status==="valid",Ts=t=>typeof Promise<"u"&&t instanceof Promise;var M;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(M||(M={}));var Lt=class{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Uw=(t,e)=>{if(Tr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new ut(t.common.issues);return this._error=n,this._error}}};function H(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:i}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,a)=>{let{message:l}=t;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}var B=class{get description(){return this._def.description}_getType(e){return pn(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:pn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new je,ctx:{common:e.parent.common,data:e.data,parsedType:pn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Ts(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pn(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Uw(r,i)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pn(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Tr(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Tr(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pn(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(Ts(i)?i:Promise.resolve(i));return Uw(r,s)}refine(e,n){let r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{let o=e(i),a=()=>s.addIssue({code:C.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new It({schema:this,typeName:V.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ft.create(this,this._def)}nullable(){return gn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $n.create(this)}promise(){return Ar.create(this,this._def)}or(e){return hi.create([this,e],this._def)}and(e){return gi.create(this,e,this._def)}transform(e){return new It({...H(this._def),schema:this,typeName:V.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new wi({...H(this._def),innerType:this,defaultValue:n,typeName:V.ZodDefault})}brand(){return new ga({typeName:V.ZodBranded,type:this,...H(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new ki({...H(this._def),innerType:this,catchValue:n,typeName:V.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return ma.create(this,e)}readonly(){return xi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},eT=/^c[^\s-]{8,}$/i,tT=/^[0-9a-z]+$/,nT=/^[0-9A-HJKMNP-TV-Z]{26}$/i,rT=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,iT=/^[a-z0-9_-]{21}$/i,sT=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,oT=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,aT=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,lT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Qh,uT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,cT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,dT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,fT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pT=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,hT=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,qw="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",gT=new RegExp(`^${qw}$`);function Kw(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function mT(t){return new RegExp(`^${Kw(t)}$`)}function Gw(t){let e=`${qw}T${Kw(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function vT(t,e){return!!((e==="v4"||!e)&&uT.test(t)||(e==="v6"||!e)&&dT.test(t))}function yT(t,e){if(!sT.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function _T(t,e){return!!((e==="v4"||!e)&&cT.test(t)||(e==="v6"||!e)&&fT.test(t))}var Pr=class t extends B{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==N.string){let s=this._getOrReturnCtx(e);return P(s,{code:C.invalid_type,expected:N.string,received:s.parsedType}),D}let r=new je,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),P(i,{code:C.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),P(i,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let o=e.data.length>s.value,a=e.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(e,i),o?P(i,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&P(i,{code:C.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")aT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"email",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Qh||(Qh=new RegExp(lT,"u")),Qh.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"emoji",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")rT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"uuid",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")iT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"nanoid",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")eT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"cuid",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")tT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"cuid2",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")nT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"ulid",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),P(i,{validation:"url",code:C.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"regex",code:C.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?Gw(s).test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?gT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?mT(s).test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?oT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"duration",code:C.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?vT(e.data,s.version)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"ip",code:C.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?yT(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"jwt",code:C.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?_T(e.data,s.version)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"cidr",code:C.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?pT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"base64",code:C.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?hT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"base64url",code:C.invalid_string,message:s.message}),r.dirty()):q.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:C.invalid_string,...M.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...M.errToObj(e)})}url(e){return this._addCheck({kind:"url",...M.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...M.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...M.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...M.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...M.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...M.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...M.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...M.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...M.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...M.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...M.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...M.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...M.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...M.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...M.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...M.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...M.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...M.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...M.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...M.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...M.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...M.errToObj(n)})}nonempty(e){return this.min(1,M.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Pr.create=t=>new Pr({checks:[],typeName:V.ZodString,coerce:t?.coerce??!1,...H(t)});function wT(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(t.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return s%o/10**i}var li=class t extends B{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==N.number){let s=this._getOrReturnCtx(e);return P(s,{code:C.invalid_type,expected:N.number,received:s.parsedType}),D}let r,i=new je;for(let s of this._def.checks)s.kind==="int"?q.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),P(r,{code:C.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?wT(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),P(r,{code:C.not_finite,message:s.message}),i.dirty()):q.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,M.toString(n))}gt(e,n){return this.setLimit("min",e,!1,M.toString(n))}lte(e,n){return this.setLimit("max",e,!0,M.toString(n))}lt(e,n){return this.setLimit("max",e,!1,M.toString(n))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:M.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:M.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:M.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:M.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:M.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:M.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:M.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:M.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:M.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:M.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&q.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};li.create=t=>new li({checks:[],typeName:V.ZodNumber,coerce:t?.coerce||!1,...H(t)});var ui=class t extends B{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==N.bigint)return this._getInvalidInput(e);let r,i=new je;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):q.assertNever(s);return{status:i.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return P(n,{code:C.invalid_type,expected:N.bigint,received:n.parsedType}),D}gte(e,n){return this.setLimit("min",e,!0,M.toString(n))}gt(e,n){return this.setLimit("min",e,!1,M.toString(n))}lte(e,n){return this.setLimit("max",e,!0,M.toString(n))}lt(e,n){return this.setLimit("max",e,!1,M.toString(n))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:M.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:M.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:M.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:M.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:M.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:M.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ui.create=t=>new ui({checks:[],typeName:V.ZodBigInt,coerce:t?.coerce??!1,...H(t)});var ci=class extends B{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==N.boolean){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.boolean,received:r.parsedType}),D}return Ke(e.data)}};ci.create=t=>new ci({typeName:V.ZodBoolean,coerce:t?.coerce||!1,...H(t)});var di=class t extends B{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==N.date){let s=this._getOrReturnCtx(e);return P(s,{code:C.invalid_type,expected:N.date,received:s.parsedType}),D}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return P(s,{code:C.invalid_date}),D}let r=new je,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),P(i,{code:C.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),P(i,{code:C.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):q.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:M.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:M.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};di.create=t=>new di({checks:[],coerce:t?.coerce||!1,typeName:V.ZodDate,...H(t)});var Rs=class extends B{_parse(e){if(this._getType(e)!==N.symbol){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.symbol,received:r.parsedType}),D}return Ke(e.data)}};Rs.create=t=>new Rs({typeName:V.ZodSymbol,...H(t)});var fi=class extends B{_parse(e){if(this._getType(e)!==N.undefined){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.undefined,received:r.parsedType}),D}return Ke(e.data)}};fi.create=t=>new fi({typeName:V.ZodUndefined,...H(t)});var pi=class extends B{_parse(e){if(this._getType(e)!==N.null){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.null,received:r.parsedType}),D}return Ke(e.data)}};pi.create=t=>new pi({typeName:V.ZodNull,...H(t)});var Rr=class extends B{constructor(){super(...arguments),this._any=!0}_parse(e){return Ke(e.data)}};Rr.create=t=>new Rr({typeName:V.ZodAny,...H(t)});var Mn=class extends B{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ke(e.data)}};Mn.create=t=>new Mn({typeName:V.ZodUnknown,...H(t)});var Gt=class extends B{_parse(e){let n=this._getOrReturnCtx(e);return P(n,{code:C.invalid_type,expected:N.never,received:n.parsedType}),D}};Gt.create=t=>new Gt({typeName:V.ZodNever,...H(t)});var As=class extends B{_parse(e){if(this._getType(e)!==N.undefined){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.void,received:r.parsedType}),D}return Ke(e.data)}};As.create=t=>new As({typeName:V.ZodVoid,...H(t)});var $n=class t extends B{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==N.array)return P(n,{code:C.invalid_type,expected:N.array,received:n.parsedType}),D;if(i.exactLength!==null){let o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(P(n,{code:o?C.too_big:C.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(P(n,{code:C.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(P(n,{code:C.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new Lt(n,o,n.path,a)))).then(o=>je.mergeArray(r,o));let s=[...n.data].map((o,a)=>i.type._parseSync(new Lt(n,o,n.path,a)));return je.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:M.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:M.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:M.toString(n)}})}nonempty(e){return this.min(1,e)}};$n.create=(t,e)=>new $n({type:t,minLength:null,maxLength:null,exactLength:null,typeName:V.ZodArray,...H(e)});function Ps(t){if(t instanceof ct){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Ft.create(Ps(r))}return new ct({...t._def,shape:()=>e})}else return t instanceof $n?new $n({...t._def,type:Ps(t.element)}):t instanceof Ft?Ft.create(Ps(t.unwrap())):t instanceof gn?gn.create(Ps(t.unwrap())):t instanceof hn?hn.create(t.items.map(e=>Ps(e))):t}var ct=class t extends B{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=q.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==N.object){let u=this._getOrReturnCtx(e);return P(u,{code:C.invalid_type,expected:N.object,received:u.parsedType}),D}let{status:r,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Gt&&this._def.unknownKeys==="strip"))for(let u in i.data)o.includes(u)||a.push(u);let l=[];for(let u of o){let c=s[u],d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new Lt(i,d,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Gt){let u=this._def.unknownKeys;if(u==="passthrough")for(let c of a)l.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(u==="strict")a.length>0&&(P(i,{code:C.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let c of a){let d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new Lt(i,d,i.path,c)),alwaysSet:c in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let u=[];for(let c of l){let d=await c.key,f=await c.value;u.push({key:d,value:f,alwaysSet:c.alwaysSet})}return u}).then(u=>je.mergeObjectSync(r,u)):je.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return M.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let i=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:M.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:V.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of q.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of q.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Ps(this)}partial(e){let n={};for(let r of q.objectKeys(this.shape)){let i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of q.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Ft;)s=s._def.innerType;n[r]=s}return new t({...this._def,shape:()=>n})}keyof(){return Zw(q.objectKeys(this.shape))}};ct.create=(t,e)=>new ct({shape:()=>t,unknownKeys:"strip",catchall:Gt.create(),typeName:V.ZodObject,...H(e)});ct.strictCreate=(t,e)=>new ct({shape:()=>t,unknownKeys:"strict",catchall:Gt.create(),typeName:V.ZodObject,...H(e)});ct.lazycreate=(t,e)=>new ct({shape:t,unknownKeys:"strip",catchall:Gt.create(),typeName:V.ZodObject,...H(e)});var hi=class extends B{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function i(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=s.map(a=>new ut(a.ctx.common.issues));return P(n,{code:C.invalid_union,unionErrors:o}),D}if(n.common.async)return Promise.all(r.map(async s=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s,o=[];for(let l of r){let u={...n,common:{...n.common,issues:[]},parent:null},c=l._parseSync({data:n.data,path:n.path,parent:u});if(c.status==="valid")return c;c.status==="dirty"&&!s&&(s={result:c,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(l=>new ut(l));return P(n,{code:C.invalid_union,unionErrors:a}),D}}get options(){return this._def.options}};hi.create=(t,e)=>new hi({options:t,typeName:V.ZodUnion,...H(e)});var In=t=>t instanceof mi?In(t.schema):t instanceof It?In(t.innerType()):t instanceof vi?[t.value]:t instanceof yi?t.options:t instanceof _i?q.objectValues(t.enum):t instanceof wi?In(t._def.innerType):t instanceof fi?[void 0]:t instanceof pi?[null]:t instanceof Ft?[void 0,...In(t.unwrap())]:t instanceof gn?[null,...In(t.unwrap())]:t instanceof ga||t instanceof xi?In(t.unwrap()):t instanceof ki?In(t._def.innerType):[],Xu=class t extends B{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==N.object)return P(n,{code:C.invalid_type,expected:N.object,received:n.parsedType}),D;let r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(P(n,{code:C.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),D)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let i=new Map;for(let s of n){let o=In(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,s)}}return new t({typeName:V.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:i,...H(r)})}};function Xh(t,e){let n=pn(t),r=pn(e);if(t===e)return{valid:!0,data:t};if(n===N.object&&r===N.object){let i=q.objectKeys(e),s=q.objectKeys(t).filter(a=>i.indexOf(a)!==-1),o={...t,...e};for(let a of s){let l=Xh(t[a],e[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===N.array&&r===N.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<t.length;s++){let o=t[s],a=e[s],l=Xh(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===N.date&&r===N.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var gi=class extends B{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=(s,o)=>{if(Yu(s)||Yu(o))return D;let a=Xh(s.value,o.value);return a.valid?((Qu(s)||Qu(o))&&n.dirty(),{status:n.value,value:a.data}):(P(r,{code:C.invalid_intersection_types}),D)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};gi.create=(t,e,n)=>new gi({left:t,right:e,typeName:V.ZodIntersection,...H(n)});var hn=class t extends B{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.array)return P(r,{code:C.invalid_type,expected:N.array,received:r.parsedType}),D;if(r.data.length<this._def.items.length)return P(r,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),D;!this._def.rest&&r.data.length>this._def.items.length&&(P(r,{code:C.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((o,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new Lt(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>je.mergeArray(n,o)):je.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};hn.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new hn({items:t,typeName:V.ZodTuple,rest:null,...H(e)})};var Ju=class t extends B{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.object)return P(r,{code:C.invalid_type,expected:N.object,received:r.parsedType}),D;let i=[],s=this._def.keyType,o=this._def.valueType;for(let a in r.data)i.push({key:s._parse(new Lt(r,a,r.path,a)),value:o._parse(new Lt(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?je.mergeObjectAsync(n,i):je.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof B?new t({keyType:e,valueType:n,typeName:V.ZodRecord,...H(r)}):new t({keyType:Pr.create(),valueType:e,typeName:V.ZodRecord,...H(n)})}},Os=class extends B{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.map)return P(r,{code:C.invalid_type,expected:N.map,received:r.parsedType}),D;let i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],u)=>({key:i._parse(new Lt(r,a,r.path,[u,"key"])),value:s._parse(new Lt(r,l,r.path,[u,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of o){let u=await l.key,c=await l.value;if(u.status==="aborted"||c.status==="aborted")return D;(u.status==="dirty"||c.status==="dirty")&&n.dirty(),a.set(u.value,c.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of o){let u=l.key,c=l.value;if(u.status==="aborted"||c.status==="aborted")return D;(u.status==="dirty"||c.status==="dirty")&&n.dirty(),a.set(u.value,c.value)}return{status:n.value,value:a}}}};Os.create=(t,e,n)=>new Os({valueType:e,keyType:t,typeName:V.ZodMap,...H(n)});var Ns=class t extends B{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.set)return P(r,{code:C.invalid_type,expected:N.set,received:r.parsedType}),D;let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(P(r,{code:C.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(P(r,{code:C.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let s=this._def.valueType;function o(l){let u=new Set;for(let c of l){if(c.status==="aborted")return D;c.status==="dirty"&&n.dirty(),u.add(c.value)}return{status:n.value,value:u}}let a=[...r.data.values()].map((l,u)=>s._parse(new Lt(r,l,r.path,u)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:M.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:M.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Ns.create=(t,e)=>new Ns({valueType:t,minSize:null,maxSize:null,typeName:V.ZodSet,...H(e)});var ec=class t extends B{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==N.function)return P(n,{code:C.invalid_type,expected:N.function,received:n.parsedType}),D;function r(a,l){return ha({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Cs(),Ln].filter(u=>!!u),issueData:{code:C.invalid_arguments,argumentsError:l}})}function i(a,l){return ha({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Cs(),Ln].filter(u=>!!u),issueData:{code:C.invalid_return_type,returnTypeError:l}})}let s={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Ar){let a=this;return Ke(async function(...l){let u=new ut([]),c=await a._def.args.parseAsync(l,s).catch(g=>{throw u.addIssue(r(l,g)),u}),d=await Reflect.apply(o,this,c);return await a._def.returns._def.type.parseAsync(d,s).catch(g=>{throw u.addIssue(i(d,g)),u})})}else{let a=this;return Ke(function(...l){let u=a._def.args.safeParse(l,s);if(!u.success)throw new ut([r(l,u.error)]);let c=Reflect.apply(o,this,u.data),d=a._def.returns.safeParse(c,s);if(!d.success)throw new ut([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:hn.create(e).rest(Mn.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||hn.create([]).rest(Mn.create()),returns:n||Mn.create(),typeName:V.ZodFunction,...H(r)})}},mi=class extends B{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};mi.create=(t,e)=>new mi({getter:t,typeName:V.ZodLazy,...H(e)});var vi=class extends B{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return P(n,{received:n.data,code:C.invalid_literal,expected:this._def.value}),D}return{status:"valid",value:e.data}}get value(){return this._def.value}};vi.create=(t,e)=>new vi({value:t,typeName:V.ZodLiteral,...H(e)});function Zw(t,e){return new yi({values:t,typeName:V.ZodEnum,...H(e)})}var yi=class t extends B{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return P(n,{expected:q.joinValues(r),received:n.parsedType,code:C.invalid_type}),D}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return P(n,{received:n.data,code:C.invalid_enum_value,options:r}),D}return Ke(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};yi.create=Zw;var _i=class extends B{_parse(e){let n=q.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==N.string&&r.parsedType!==N.number){let i=q.objectValues(n);return P(r,{expected:q.joinValues(i),received:r.parsedType,code:C.invalid_type}),D}if(this._cache||(this._cache=new Set(q.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let i=q.objectValues(n);return P(r,{received:r.data,code:C.invalid_enum_value,options:i}),D}return Ke(e.data)}get enum(){return this._def.values}};_i.create=(t,e)=>new _i({values:t,typeName:V.ZodNativeEnum,...H(e)});var Ar=class extends B{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==N.promise&&n.common.async===!1)return P(n,{code:C.invalid_type,expected:N.promise,received:n.parsedType}),D;let r=n.parsedType===N.promise?n.data:Promise.resolve(n.data);return Ke(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Ar.create=(t,e)=>new Ar({type:t,typeName:V.ZodPromise,...H(e)});var It=class extends B{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===V.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{P(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return D;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?D:l.status==="dirty"?ai(l.value):n.value==="dirty"?ai(l.value):l});{if(n.value==="aborted")return D;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?D:a.status==="dirty"?ai(a.value):n.value==="dirty"?ai(a.value):a}}if(i.type==="refinement"){let o=a=>{let l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?D:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?D:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Tr(o))return D;let a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Tr(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):D);q.assertNever(i)}};It.create=(t,e,n)=>new It({schema:t,typeName:V.ZodEffects,effect:e,...H(n)});It.createWithPreprocess=(t,e,n)=>new It({schema:e,effect:{type:"preprocess",transform:t},typeName:V.ZodEffects,...H(n)});var Ft=class extends B{_parse(e){return this._getType(e)===N.undefined?Ke(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ft.create=(t,e)=>new Ft({innerType:t,typeName:V.ZodOptional,...H(e)});var gn=class extends B{_parse(e){return this._getType(e)===N.null?Ke(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};gn.create=(t,e)=>new gn({innerType:t,typeName:V.ZodNullable,...H(e)});var wi=class extends B{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===N.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};wi.create=(t,e)=>new wi({innerType:t,typeName:V.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...H(e)});var ki=class extends B{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ts(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ut(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ut(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};ki.create=(t,e)=>new ki({innerType:t,typeName:V.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...H(e)});var Fs=class extends B{_parse(e){if(this._getType(e)!==N.nan){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.nan,received:r.parsedType}),D}return{status:"valid",value:e.data}}};Fs.create=t=>new Fs({typeName:V.ZodNaN,...H(t)});var kT=Symbol("zod_brand"),ga=class extends B{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},ma=class t extends B{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?D:s.status==="dirty"?(n.dirty(),ai(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?D:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:V.ZodPipeline})}},xi=class extends B{_parse(e){let n=this._def.innerType._parse(e),r=i=>(Tr(i)&&(i.value=Object.freeze(i.value)),i);return Ts(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}};xi.create=(t,e)=>new xi({innerType:t,typeName:V.ZodReadonly,...H(e)});function Ww(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Yw(t,e={},n){return t?Rr.create().superRefine((r,i)=>{let s=t(r);if(s instanceof Promise)return s.then(o=>{if(!o){let a=Ww(e,r),l=a.fatal??n??!0;i.addIssue({code:"custom",...a,fatal:l})}});if(!s){let o=Ww(e,r),a=o.fatal??n??!0;i.addIssue({code:"custom",...o,fatal:a})}}):Rr.create()}var xT={object:ct.lazycreate},V;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(V||(V={}));var ET=(t,e={message:`Input not instance of ${t.name}`})=>Yw(n=>n instanceof t,e),Qw=Pr.create,Xw=li.create,ST=Fs.create,bT=ui.create,Jw=ci.create,CT=di.create,TT=Rs.create,PT=fi.create,RT=pi.create,AT=Rr.create,OT=Mn.create,NT=Gt.create,FT=As.create,LT=$n.create,IT=ct.create,MT=ct.strictCreate,$T=hi.create,DT=Xu.create,VT=gi.create,jT=hn.create,zT=Ju.create,HT=Os.create,BT=Ns.create,UT=ec.create,WT=mi.create,qT=vi.create,KT=yi.create,GT=_i.create,ZT=Ar.create,YT=It.create,QT=Ft.create,XT=gn.create,JT=It.createWithPreprocess,eP=ma.create,tP=()=>Qw().optional(),nP=()=>Xw().optional(),rP=()=>Jw().optional(),iP={string:(t=>Pr.create({...t,coerce:!0})),number:(t=>li.create({...t,coerce:!0})),boolean:(t=>ci.create({...t,coerce:!0})),bigint:(t=>ui.create({...t,coerce:!0})),date:(t=>di.create({...t,coerce:!0}))};var sP=D;var e1=$.union([$.object({type:$.literal("data"),key:$.string(),value:$.string().optional()}),$.object({type:$.literal("css"),value:$.string()}),$.object({type:$.literal("aria"),role:$.string().optional(),label:$.string().optional()}),$.object({type:$.literal("shadow-css"),value:$.string()}),$.object({type:$.literal("ref"),el:$.any()})]),oP=$.object({kind:$.literal("tooltip"),id:$.string(),anchor:e1,content:$.object({title:$.string().optional(),body:$.string()}),placement:$.enum(["top","bottom","left","right","auto"]).optional(),offsetPx:$.number().optional(),blocking:$.boolean().optional(),trigger:$.enum(["immediate","hover","click"]).optional(),dismiss:$.object({onEsc:$.boolean().optional(),closeButton:$.boolean().optional(),timeoutMs:$.number().optional()}).optional()}),aP=$.object({kind:$.literal("highlight"),id:$.string(),anchor:e1,copy:$.string().optional(),ring:$.object({paddingPx:$.number().optional(),radiusPx:$.number().optional()}).optional(),scrim:$.object({opacity:$.number().optional()}).optional(),ringColor:$.string().optional(),blocking:$.boolean().optional(),dismiss:$.object({onClickOutside:$.boolean().optional(),onEsc:$.boolean().optional(),timeoutMs:$.number().optional()}).optional()}),va=$.object({id:$.string(),version:$.number(),routes:$.array($.string()).optional(),steps:$.array($.union([oP,aP]))});function qA(t){return va.parse(t)}var t1=({configUri:t,experiments:e,featureKey:n="smart-canvas-overlay-uri",credentials:r="include"}={})=>async()=>{let i=Zh({configUri:t,experiments:e,featureKey:n});if(!i)throw new Error("SmartCanvas overlays: recipe URI missing (env + feature unset).");let s=await fetch(i,{credentials:r});if(!s.ok)throw new Error(`SmartCanvas overlays: failed to fetch recipe (${s.status})`);let o=await s.json();return va.parse(o)};function J1({fetcher:t,configUri:e,featureKey:n,credentials:r,experiments:i,telemetry:s,canvasHost:o}){let a=(0,pc.useMemo)(()=>{if(t)return t;if(e)return t1({configUri:e,experiments:i,featureKey:n,credentials:r,validator:va})},[t,e,i,n,r]);(0,pc.useEffect)(()=>{if(!a)return;let l=!1,u;return(async()=>{try{let c=await a();if(!c?.steps?.length||l)return;let d=await Promise.resolve().then(()=>(X1(),Q1)),f=d.ensureOverlayRoot(),g=d.createAnchorResolver({canvasHost:o});u=await d.runOverlays(c,{overlayRoot:f,resolve:g,canvasHost:o,onEvent:(v,y)=>{s&&s.trackAction?.(v,y?.stepId??"","overlay")}})}catch(c){console.warn("[SmartCanvas] overlays failed",c)}})(),()=>{l=!0,u?.()}},[a,s,o])}var nk=ve(bt(),1);sg();var WP=new Set(["outline","outlineColor","outlineWidth","outlineStyle","boxShadow","filter","scrollMargin","scrollMarginTop","scrollMarginRight","scrollMarginBottom","scrollMarginLeft"]);function qP(t){return t.startsWith("--")}function KP(t){return t.startsWith("data-")||t.startsWith("aria-")||t==="role"}function GP(t){return t.startsWith("syntro-")||t.startsWith("sc-")||t.startsWith("sx-")}var Ds={allowAttribute(t,e){return!!(KP(t)||e!=="additive"&&t==="title")},allowClass(t,e){return GP(t)},allowStyle(t,e,n){return!!(qP(t)||WP.has(t)||n==="surgical"&&(t==="backgroundColor"||t==="color"))},allowSetText(t){return t==="surgical"},sanitizeHTML(t){return cc(t)}};var ZP=[/^\*$/,/^\s*$/,/:has\(/i,/javascript:/i];function YP(t){if(!t||t.length>500)return console.warn("[SmartCanvas] Selector too long or empty:",t?.slice(0,50)),!1;if(ZP.some(e=>e.test(t)))return console.warn("[SmartCanvas] Dangerous selector pattern blocked:",t),!1;try{return document.querySelector(t),!0}catch{return console.warn("[SmartCanvas] Invalid CSS selector:",t),!1}}function QP(t){let e;if(t.by==="css")e=t.value;else if(t.by==="data")e=`[data-${t.key}${t.value?`="${t.value}"`:""}]`;else if(t.by==="aria"){let n=t.role?`[role="${t.role}"]`:"",r=t.label?`[aria-label="${t.label}"]`:"";e=`${n}${r}`}else return null;return YP(e)?e:null}function ek(t,e){if(t.el instanceof HTMLElement)return t.el;let r=("within"in t?t.within==="shadow":!1)?e.shadowHost?.shadowRoot??document:document,i=QP(t);if(!i)return null;let s=r.querySelectorAll(i);return s.length===0?(console.warn(`[SmartCanvas] No elements match selector: ${i}`),null):(s.length>1&&console.warn(`[SmartCanvas] Selector "${i}" matches ${s.length} elements. Using first match. Consider a more specific selector.`),s[0])}function tk(t,e){if(!e)return!0;if(e.tag&&t.tagName.toLowerCase()!==e.tag.toLowerCase())return!1;if(e.hasAttrs){for(let[n,r]of Object.entries(e.hasAttrs))if(t.getAttribute(n)!==r)return!1}return!(e.closest&&!e.closest.some(r=>!!t.closest(r)))}var hc=new Map;function Vs(t,e,n,r){t.onLog?t.onLog(e,n,r):e!=="debug"&&console[e]("[host-patcher]",n,r??"")}function gc(t,e={}){let n=e.policy??Ds;if(hc.has(t.id))return{ok:!0};let r=ek(t.anchor,{shadowHost:e.shadowHost});if(!r)return{ok:!1,reason:"anchor-missing"};if(!tk(r,t.invariants))return{ok:!1,reason:"invariants-failed"};let i=t.tier??"additive",s=[],o={classes:void 0,attrs:void 0,styles:void 0,text:void 0};for(let a of t.operations)switch(a.kind){case"insertAdjacent":{let l=document.createElement("div");l.setAttribute("data-syntro-patch-id",t.id),a.html&&(l.innerHTML=n.sanitizeHTML(a.html)),a.node&&l.appendChild(a.node),r.insertAdjacentElement(a.where,l),s.push(l);break}case"append":{let l=a.node??(()=>{let u=document.createElement("div");return a.html&&(u.innerHTML=n.sanitizeHTML(a.html)),u})();r.appendChild(l),s.push(l);break}case"prepend":{let l=a.node??(()=>{let u=document.createElement("div");return a.html&&(u.innerHTML=n.sanitizeHTML(a.html)),u})();r.insertBefore(l,r.firstChild),s.push(l);break}case"addClass":{if(!n.allowClass(a.className,i)){Vs(e,"warn","class not allowed",a.className);break}o.classes??(o.classes=new Set(Array.from(r.classList))),r.classList.add(a.className);break}case"removeClass":{if(!n.allowClass(a.className,i)){Vs(e,"warn","class not allowed",a.className);break}o.classes??(o.classes=new Set(Array.from(r.classList))),r.classList.remove(a.className);break}case"setAttr":{if(!n.allowAttribute(a.name,i)){Vs(e,"warn","attr not allowed",a.name);break}if(o.attrs??(o.attrs=new Map),!o.attrs.has(a.name)){let l=r.getAttribute(a.name);l!==null?o.attrs.set(a.name,l):o.attrs.set(a.name,"__NULL__")}a.value===null?r.removeAttribute(a.name):r.setAttribute(a.name,a.value);break}case"setStyle":{if(!n.allowStyle(a.prop,a.value??null,i)){Vs(e,"warn","style not allowed",a.prop);break}if(o.styles??(o.styles=new Map),!o.styles.has(a.prop)){let l=r.style.getPropertyValue(a.prop);o.styles.set(a.prop,l||"__NULL__")}a.value===null?r.style.removeProperty(a.prop):r.style.setProperty(a.prop,a.value,a.important?"important":"");break}case"setText":{if(!n.allowSetText(i)){Vs(e,"warn","setText not allowed in this tier",{tier:i});break}o.text??(o.text=r.textContent??""),r.textContent=a.text;break}default:Vs(e,"warn","unknown operation",a)}return hc.set(t.id,{id:t.id,anchorEl:r,inserted:s,snapshot:o}),{ok:!0}}function mc(t,e={}){let n=hc.get(t);if(!n)return;for(let i of n.inserted)try{i.remove()}catch{}let r=n.anchorEl;if(r&&n.snapshot){if(n.snapshot.text!==void 0&&(r.textContent=n.snapshot.text),n.snapshot.attrs&&(new Set(Array.from(r.attributes).map(s=>s.name)).forEach(s=>{n.snapshot.attrs.has(s)||r.removeAttribute(s)}),n.snapshot.attrs.forEach((s,o)=>{s==="__NULL__"?r.removeAttribute(o):r.setAttribute(o,s)})),n.snapshot.classes){let i=r.classList;Array.from(i).forEach(s=>i.remove(s)),n.snapshot.classes.forEach(s=>i.add(s))}if(n.snapshot.styles){let i=r.style;Array.from(i).forEach(s=>i.removeProperty(s)),n.snapshot.styles.forEach((s,o)=>{s==="__NULL__"?i.removeProperty(o):i.setProperty(o,s)})}}hc.delete(t)}function rk({patches:t,telemetry:e,policy:n=Ds,canvasHost:r}){(0,nk.useEffect)(()=>{if(!t||t.length===0)return;let i=[];return t.forEach(s=>{gc(s,{shadowHost:r,policy:n,onLog:e?(a,l,u)=>e.trackAction?.(`syntro_patch_${a}`,s.id,"overlay"):void 0}).ok?(i.push(s.id),e?.trackAction?.("syntro_patch_applied",s.id,"overlay")):e?.trackAction?.("syntro_patch_failed",s.id,"overlay")}),()=>{i.forEach(s=>{try{mc(s),e?.trackAction?.("syntro_patch_reverted",s,"overlay")}catch(o){console.warn("[SmartCanvas] failed to revert patch",s,o)}})}},[t,e,n,r])}var sk=ve(Vt(),1);function ik({controller:t,fetcher:e,configUri:n,configUriFeatureKey:r="smart-canvas-config-uri",configFeatureKey:i="smart-canvas-config",fetchCredentials:s="include",pollIntervalMs:o,experiments:a,telemetry:l,overlayFetcher:u,overlayConfigUri:c,overlayConfigFeatureKey:d="smart-canvas-overlay-uri",overlayFetchCredentials:f="include",footerSlot:g,launcherLabel:v,canvasHost:y,customRenderers:k,theme:h}){let[p,m]=(0,Fr.useState)(t.getState().open),_=(0,Fr.useMemo)(()=>e||bs({configUri:n,experiments:a,featureKey:r,configFeatureKey:i,credentials:s}),[e,n,a,r,i,s]),w=_y({fetcher:_,pollIntervalMs:o,experiments:a}),b=w.rectangles.length>0&&!w.error;(0,Fr.useEffect)(()=>t.subscribe(E=>m(E.open)),[t]),(0,Fr.useEffect)(()=>{!b&&t.getState().open&&t.setOpen(!1)},[t,b]);let S=(0,Fr.useMemo)(()=>{if(u)return u;if(w.overlayRecipe)return async()=>w.overlayRecipe;!c&&w.isLoading},[u,w.overlayRecipe,w.isLoading,c]);return J1({fetcher:S,configUri:!S&&!w.isLoading?c:void 0,featureKey:d,credentials:f,experiments:a,telemetry:l,canvasHost:y}),rk({patches:w.patches,telemetry:l,canvasHost:y}),!w.isLoading&&!b||!b?null:(0,sk.jsx)(zw,{rectangles:w.rectangles,isLoading:w.isLoading,error:w.error,canvasTitle:w.canvasTitle,telemetry:l,launcherLabel:v,footerSlot:g,isOpen:p,onToggle:()=>t.toggle(),customRenderers:k,displayMode:w.displayMode,theme:h})}var ck=ve(ak(),1);var fk=ve(Vt(),1),lk="smart-canvas",uk=`
|
|
136
|
+
`)).length,i=0;i<r;i++){var o=t.charCodeAt(i),a=null;o<128?n++: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),xn(a)||(n>e&&(s+=t.substring(e,n)),s+=a,e=n=i+1)}return n>e&&(s+=t.substring(e,t.length)),s},nE=!!Vc||!!Dc,om="text/plain",Ja=function(t,e,n){var r;n===void 0&&(n=!0);var[i,s]=t.split("?"),o=L({},e),a=(r=s?.split("&").map((u=>{var c,[d,f]=u.split("="),g=n&&(c=o[d])!==null&&c!==void 0?c:f;return delete o[d],d+"="+g})))!==null&&r!==void 0?r:[],l=_x(o);return l&&a.push(l),i+"?"+a.join("&")},to=(t,e)=>JSON.stringify(t,((n,r)=>typeof r=="bigint"?r.toString():r),e),Fc=t=>{var{data:e,compression:n}=t;if(e){if(n===kn.GZipJS){var r=eE((function(l,u){var c=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var d=new St(l.length+(l.length>>>1)),f=0,g=function(h){d[f++]=h},v=0;v<c;++v){if(f+5>d.length){var y=new St(f+8+(c-v<<1));y.set(d),d=y}var k=l.charCodeAt(v);k<128||u?g(k):k<2048?(g(192|k>>>6),g(128|63&k)):k>55295&&k<57344?(g(240|(k=65536+(1047552&k)|1023&l.charCodeAt(++v))>>>18),g(128|k>>>12&63),g(128|k>>>6&63),g(128|63&k)):(g(224|k>>>12),g(128|k>>>6&63),g(128|63&k))}return _v(d,0,f)})(to(e)),{mtime:0}),i=new Blob([r],{type:om});return{contentType:om,body:i,estimatedSize:i.size}}if(n===kn.Base64){var s=(function(l){var u,c,d,f,g,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",y=0,k=0,h="",p=[];if(!l)return l;l=tE(l);do u=(g=l.charCodeAt(y++)<<16|l.charCodeAt(y++)<<8|l.charCodeAt(y++))>>18&63,c=g>>12&63,d=g>>6&63,f=63&g,p[k++]=v.charAt(u)+v.charAt(c)+v.charAt(d)+v.charAt(f);while(y<l.length);switch(h=p.join(""),l.length%3){case 1:h=h.slice(0,-2)+"==";break;case 2:h=h.slice(0,-1)+"="}return h})(to(e)),o=(l=>"data="+encodeURIComponent(typeof l=="string"?l:to(l)))(s);return{contentType:"application/x-www-form-urlencoded",body:o,estimatedSize:new Blob([o]).size}}var a=to(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},Ma=[];Dc&&Ma.push({transport:"fetch",method:t=>{var e,n,{contentType:r,body:i,estimatedSize:s}=(e=Fc(t))!==null&&e!==void 0?e:{},o=new Headers;re(t.headers,(function(c,d){o.append(d,c)})),r&&o.append("Content-Type",r);var a=t.url,l=null;if(Cg){var u=new Cg;l={signal:u.signal,timeout:setTimeout((()=>u.abort()),t.timeout)}}Dc(a,L({method:t?.method||"GET",headers:o,keepalive:t.method==="POST"&&(s||0)<52428.8,body:i,signal:(n=l)==null?void 0:n.signal},t.fetchOptions)).then((c=>c.text().then((d=>{var f={statusCode:c.status,text:d};if(c.status===200)try{f.json=JSON.parse(d)}catch(g){O.error(g)}t.callback==null||t.callback(f)})))).catch((c=>{O.error(c),t.callback==null||t.callback({statusCode:0,text:c})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Vc&&Ma.push({transport:"XHR",method:t=>{var e,n=new Vc;n.open(t.method||"GET",t.url,!0);var{contentType:r,body:i}=(e=Fc(t))!==null&&e!==void 0?e:{};re(t.headers,(function(s,o){n.setRequestHeader(o,s)})),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),t.disableXHRCredentials||(n.withCredentials=!0),n.onreadystatechange=()=>{if(n.readyState===4){var s={statusCode:n.status,text:n.responseText};if(n.status===200)try{s.json=JSON.parse(n.responseText)}catch{}t.callback==null||t.callback(s)}},n.send(i)}}),pt!=null&&pt.sendBeacon&&Ma.push({transport:"sendBeacon",method:t=>{var e=Ja(t.url,{beacon:"1"});try{var n,{contentType:r,body:i}=(n=Fc(t))!==null&&n!==void 0?n:{},s=typeof i=="string"?new Blob([i],{type:r}):i;pt.sendBeacon(e,s)}catch{}}});var el=function(t,e){if(!(function(n){try{new RegExp(n)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};function am(t,e,n){return to({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var wv={exact:(t,e)=>e.some((n=>t.some((r=>n===r)))),is_not:(t,e)=>e.every((n=>t.every((r=>n!==r)))),regex:(t,e)=>e.some((n=>t.some((r=>el(n,r))))),not_regex:(t,e)=>e.every((n=>t.every((r=>!el(n,r))))),icontains:(t,e)=>e.map(La).some((n=>t.map(La).some((r=>n.includes(r))))),not_icontains:(t,e)=>e.map(La).every((n=>t.map(La).every((r=>!n.includes(r)))))},La=t=>t.toLowerCase();function kv(t,e){return!t||Object.entries(t).every((n=>{var[r,i]=n,s=e?.[r];if(R(s)||xn(s))return!1;var o=[String(s)],a=wv[i.operator];return!!a&&a(i.values,o)}))}var Lc=Pe("[Error tracking]"),Rd=class{constructor(e){var n,r;this.Jt=[],this.Kt=new Uc([new qc,new Jc,new Gc,new Kc,new Qc,new Yc,new Zc,new Xc],tx("web:javascript",Qk,ex)),this._instance=e,this.Jt=(n=(r=this._instance.persistence)==null?void 0:r.get_property(td))!==null&&n!==void 0?n:[]}onRemoteConfig(e){var n,r,i,s=(n=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&n!==void 0?n:[],o=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Jt=s,this._instance.persistence&&this._instance.persistence.register({[td]:this.Jt,[$g]:o})}get Yt(){var e,n=!!this._instance.get_property($g),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r??n)!==null&&e!==void 0&&e}buildProperties(e,n){return this.Kt.buildFromUnknown(e,{syntheticException:n?.syntheticException,mechanism:{handled:n?.handled}})}sendExceptionEvent(e){var n=e.$exception_list;if(this.Xt(n)){if(this.Qt(n))return void Lc.info("Skipping exception capture because a suppression rule matched");if(!this.Yt&&this.Zt(n))return void Lc.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ti(n))return void Lc.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}Qt(e){if(e.length===0)return!1;var n=e.reduce(((r,i)=>{var{type:s,value:o}=i;return Te(s)&&s.length>0&&r.$exception_types.push(s),Te(o)&&o.length>0&&r.$exception_values.push(o),r}),{$exception_types:[],$exception_values:[]});return this.Jt.some((r=>{var i=r.values.map((s=>{var o,a=wv[s.operator],l=ne(s.value)?s.value:[s.value],u=(o=n[s.key])!==null&&o!==void 0?o:[];return l.length>0&&a(l,u)}));return r.type==="OR"?i.some(Boolean):i.every(Boolean)}))}Zt(e){return e.flatMap((n=>{var r,i;return(r=(i=n.stacktrace)==null?void 0:i.frames)!==null&&r!==void 0?r:[]})).some((n=>n.filename&&n.filename.startsWith("chrome-extension://")))}ti(e){if(e.length>0){var n,r,i,s,o=(n=(r=e[0].stacktrace)==null?void 0:r.frames)!==null&&n!==void 0?n:[],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}Xt(e){return!ee(e)&&ne(e)}},Dt=Pe("[FeatureFlags]"),qs=Pe("[FeatureFlags]",{debugEnabled:!0}),Ic="$active_feature_flags",Ai="$override_feature_flags",lm="$feature_flag_payloads",Ks="$override_feature_flag_payloads",um="$feature_flag_request_id",cm="$feature_flag_evaluated_at",dm=t=>{var e={};for(var[n,r]of Ia(t||{}))r&&(e[n]=r);return e},rE=t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map((n=>{var r;return[n,(r=e[n].variant)!==null&&r!==void 0?r:e[n].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((n=>e[n].enabled)).filter((n=>{var r;return(r=e[n].metadata)==null?void 0:r.payload})).map((n=>{var r;return[n,(r=e[n].metadata)==null?void 0:r.payload]})))):Dt.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t},iE=(function(t){return t.FeatureFlags="feature_flags",t.Recordings="recordings",t})({}),Ad=class{constructor(e){this.ii=!1,this.ei=!1,this.ri=!1,this.si=!1,this.ni=!1,this.oi=!1,this.ai=!1,this._instance=e,this.featureFlagEventHandlers=[]}li(){var e=this._instance.config.evaluation_environments;return e!=null&&e.length?e.filter((n=>{var r=n&&typeof n=="string"&&n.trim().length>0;return r||Dt.error("Invalid evaluation environment found:",n,"Expected non-empty string"),r})):[]}ui(){return this.li().length>0}flags(){if(this._instance.config.__preview_remote_config)this.oi=!0;else{var e=!this.hi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.vi({disableFlags:e})}}get hasLoadedFlags(){return this.ei}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(nd),n=this._instance.get_property(Ai),r=this._instance.get_property(Ks);if(!r&&!n)return e||{};var i=_e({},e||{}),s=[...new Set([...Object.keys(r||{}),...Object.keys(n||{})])];for(var o of s){var a,l,u=i[o],c=n?.[o],d=R(c)?(a=u?.enabled)!==null&&a!==void 0&&a:!!c,f=R(c)?u.variant:typeof c=="string"?c:void 0,g=r?.[o],v=L({},u,{enabled:d,variant:d?f??u?.variant:void 0});d!==u?.enabled&&(v.original_enabled=u?.enabled),f!==u?.variant&&(v.original_variant=u?.variant),g&&(v.metadata=L({},u?.metadata,{payload:g,original_payload:u==null||(l=u.metadata)==null?void 0:l.payload})),i[o]=v}return this.ii||(Dt.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.ii=!0),i}getFlagVariants(){var e=this._instance.get_property(Li),n=this._instance.get_property(Ai);if(!n)return e||{};for(var r=_e({},e),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this.ii||(Dt.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:n,finalFlags:r}),this.ii=!0),r}getFlagPayloads(){var e=this._instance.get_property(lm),n=this._instance.get_property(Ks);if(!n)return e||{};for(var r=_e({},e||{}),i=Object.keys(n),s=0;s<i.length;s++)r[i[s]]=n[i[s]];return this.ii||(Dt.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:n,finalPayloads:r}),this.ii=!0),r}reloadFeatureFlags(){this.si||this._instance.config.advanced_disable_feature_flags||this.hi||(this.hi=setTimeout((()=>{this.vi()}),5))}di(){clearTimeout(this.hi),this.hi=void 0}ensureFlagsLoaded(){this.ei||this.ri||this.hi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.si=e}vi(e){var n;if(this.di(),!this._instance.O())if(this.ri)this.ni=!0;else{var r={token:this._instance.config.token,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:L({},((n=this._instance.persistence)==null?void 0:n.get_initial_props())||{},this._instance.get_property(Js)||{}),group_properties:this._instance.get_property(Vr)};(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.ui()&&(r.evaluation_environments=this.li());var i=this._instance.config.__preview_remote_config,s=i?"/flags/?v=2":"/flags/?v=2&config=true",o=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",a=this._instance.requestRouter.endpointFor("flags",s+o);i&&(r.timezone=gv()),this.ri=!0,this._instance.ci({method:"POST",url:a,data:r,compression:this._instance.config.disable_compression?void 0:kn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:l=>{var u,c,d=!0;if(l.statusCode===200&&(this.ni||(this.$anon_distinct_id=void 0),d=!1),this.ri=!1,this.oi||(this.oi=!0,this._instance.fi((c=l.json)!==null&&c!==void 0?c:{})),!r.disable_flags||this.ni)if(this.ai=!d,l.json&&(u=l.json.quotaLimited)!=null&&u.includes(iE.FeatureFlags))Dt.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 f;r.disable_flags||this.receivedFeatureFlags((f=l.json)!==null&&f!==void 0?f:{},d),this.ni&&(this.ni=!1,this.vi())}}})}}getFeatureFlag(e,n){if(n===void 0&&(n={}),this.ei||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants()[e],i=""+r,s=this._instance.get_property(um)||void 0,o=this._instance.get_property(cm)||void 0,a=this._instance.get_property(za)||{};if((n.send_event||!("send_event"in n))&&(!(e in a)||!a[e].includes(i))){var l,u,c,d,f,g,v,y,k;ne(a[e])?a[e].push(i):a[e]=[i],(l=this._instance.persistence)==null||l.register({[za]:a});var h=this.getFeatureFlagDetails(e),p={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:s,$feature_flag_evaluated_at:o,$feature_flag_bootstrapped_response:((u=this._instance.config.bootstrap)==null||(u=u.featureFlags)==null?void 0:u[e])||null,$feature_flag_bootstrapped_payload:((c=this._instance.config.bootstrap)==null||(c=c.featureFlagPayloads)==null?void 0:c[e])||null,$used_bootstrap_value:!this.ai};R(h==null||(d=h.metadata)==null?void 0:d.version)||(p.$feature_flag_version=h.metadata.version);var m,_=(f=h==null||(g=h.reason)==null?void 0:g.description)!==null&&f!==void 0?f:h==null||(v=h.reason)==null?void 0:v.code;_&&(p.$feature_flag_reason=_),h!=null&&(y=h.metadata)!=null&&y.id&&(p.$feature_flag_id=h.metadata.id),R(h?.original_variant)&&R(h?.original_enabled)||(p.$feature_flag_original_response=R(h.original_variant)?h.original_enabled:h.original_variant),h!=null&&(k=h.metadata)!=null&&k.original_payload&&(p.$feature_flag_original_payload=h==null||(m=h.metadata)==null?void 0:m.original_payload),this._instance.capture("$feature_flag_called",p)}return r}Dt.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,n){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.ui()&&(i.evaluation_environments=this.li()),this._instance.ci({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:kn.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:s=>{var o,a=(o=s.json)==null?void 0:o.featureFlagPayloads;n(a?.[e]||void 0)}})}isFeatureEnabled(e,n){if(n===void 0&&(n={}),this.ei||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,n);return R(r)?void 0:!!r}Dt.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((n=>n!==e))}receivedFeatureFlags(e,n){if(this._instance.persistence){this.ei=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),s=this.getFlagsWithDetails();(function(o,a,l,u,c){l===void 0&&(l={}),u===void 0&&(u={}),c===void 0&&(c={});var d=rE(o),f=d.flags,g=d.featureFlags,v=d.featureFlagPayloads;if(g){var y=o.requestId,k=o.evaluatedAt;if(ne(g)){Dt.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var h={};if(g)for(var p=0;p<g.length;p++)h[g[p]]=!0;a&&a.register({[Ic]:g,[Li]:h})}else{var m=g,_=v,w=f;o.errorsWhileComputingFlags&&(m=L({},l,m),_=L({},u,_),w=L({},c,w)),a&&a.register(L({[Ic]:Object.keys(dm(m)),[Li]:m||{},[lm]:_||{},[nd]:w||{}},y?{[um]:y}:{},k?{[cm]:k}:{}))}}})(e,this._instance.persistence,r,i,s),this.pi(n)}}override(e,n){n===void 0&&(n=!1),Dt.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:n})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return Dt.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(Ai),this._instance.persistence.unregister(Ks),this.pi(),qs.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n,r=e;if(this.ii=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(Ai),qs.info("Flag overrides cleared");else if(r.flags){if(ne(r.flags)){for(var i={},s=0;s<r.flags.length;s++)i[r.flags[s]]=!0;this._instance.persistence.register({[Ai]:i})}else this._instance.persistence.register({[Ai]:r.flags});qs.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(Ks),qs.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[Ks]:r.payloads}),qs.info("Payload overrides set",{payloads:r.payloads}))),void this.pi()}this.pi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ei){var{flags:n,flagVariants:r}=this.gi();e(n,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,n,r){var i,s=(this._instance.get_property(Xs)||[]).find((u=>u.flagKey===e)),o={["$feature_enrollment/"+e]:n},a={$feature_flag:e,$feature_enrollment:n,$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=L({},this.getFlagVariants(),{[e]:n});(i=this._instance.persistence)==null||i.register({[Ic]:Object.keys(dm(l)),[Li]:l}),this.pi()}getEarlyAccessFeatures(e,n,r){n===void 0&&(n=!1);var i=this._instance.get_property(Xs),s=r?"&"+r.map((o=>"stage="+o)).join("&"):"";if(i&&!n)return e(i);this._instance.ci({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 u=o.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(Xs),(l=this._instance.persistence)==null||l.register({[Xs]:u}),e(u)}}})}gi(){var e=this.getFlags(),n=this.getFlagVariants();return{flags:e.filter((r=>n[r])),flagVariants:Object.keys(n).filter((r=>n[r])).reduce(((r,i)=>(r[i]=n[i],r)),{})}}pi(e){var{flags:n,flagVariants:r}=this.gi();this.featureFlagEventHandlers.forEach((i=>i(n,r,{errorsLoading:e})))}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Js)||{};this._instance.register({[Js]:L({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Js)}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Vr)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=L({},r[i],e[i]),delete e[i]})),this._instance.register({[Vr]:L({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var n=this._instance.get_property(Vr)||{};this._instance.register({[Vr]:L({},n,{[e]:{}})})}else this._instance.unregister(Vr)}reset(){this.ei=!1,this.ri=!1,this.si=!1,this.ni=!1,this.oi=!1,this.ai=!1,this.$anon_distinct_id=void 0,this.di(),this.ii=!1}},sE=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],io=class{constructor(e,n){this.F=e,this.props={},this.mi=!1,this.yi=(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.bi(e),this.load(),e.debug&&O.info("Persistence loaded",e.persistence,L({},this.props)),this.update_config(e,e,n),this.save()}isDisabled(){return!!this.wi}bi(e){sE.indexOf(e.persistence.toLowerCase())===-1&&(O.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n=e.persistence.toLowerCase();return n==="localstorage"&&pe.H()?pe:n==="localstorage+cookie"&&Aa.H()?Aa:n==="sessionstorage"&&Ie.H()?Ie:n==="memory"?Tx:n==="cookie"?nn:Aa.H()?Aa:nn}properties(){var e={};return re(this.props,(function(n,r){if(r===Li&&Ne(n))for(var i=Object.keys(n),s=0;s<i.length;s++)e["$feature/"+i[s]]=n[i[s]];else a=r,l=!1,(xn(o=ux)?l:bg&&o.indexOf===bg?o.indexOf(a)!=-1:(re(o,(function(u){if(l||(l=u===a))return Va})),l))||(e[r]=n);var o,a,l})),e}load(){if(!this.wi){var e=this.Y.W(this.yi);e&&(this.props=_e({},e))}}save(){this.wi||this.Y.G(this.yi,this.props,this.xi,this.Si,this.Ei,this.F.debug)}remove(){this.Y.V(this.yi,!1),this.Y.V(this.yi,!0)}clear(){this.remove(),this.props={}}register_once(e,n,r){if(Ne(e)){R(n)&&(n="None"),this.xi=R(r)?this.$i:r;var i=!1;if(re(e,((s,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==n||(this.props[o]=s,i=!0)})),i)return this.save(),!0}return!1}register(e,n){if(Ne(e)){this.xi=R(n)?this.$i:n;var r=!1;if(re(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.mi){var e=uv(this.F.custom_campaign_params,this.F.mask_personal_data_properties,this.F.custom_personal_data_properties);Fi(Gd(e))||this.register(e),this.mi=!0}}update_search_keyword(){var e;this.register((e=A?.referrer)?dv(e):{})}update_referrer_info(){var e;this.register_once({$referrer:fv(),$referring_domain:A!=null&&A.referrer&&((e=qa(A.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[od]||this.props[ad]||this.register_once({[Ha]:pv(this.F.mask_personal_data_properties,this.F.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};re([ad,od],(o=>{var a=this.props[o];a&&re(a,(function(l,u){e["$initial_"+jc(u)]=l}))}));var n,r,i=this.props[Ha];if(i){var s=(n=hv(i),r={},re(n,(function(o,a){r["$initial_"+jc(a)]=o})),r);_e(e,s)}return e}safe_merge(e){return re(this.props,(function(n,r){r in e||(e[r]=n)})),e}update_config(e,n,r){if(this.$i=this.xi=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!==n.persistence){var i=this.bi(e),s=this.props;this.clear(),this.Y=i,this.props=s,this.save()}}set_disabled(e){this.wi=e,this.wi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Si&&(this.Si=e,this.remove(),this.save())}set_secure(e){e!==this.Ei&&(this.Ei=e,this.remove(),this.save())}set_event_timer(e,n){var r=this.props[Qs]||{};r[e]=n,this.props[Qs]=r,this.save()}remove_event_timer(e){var n=(this.props[Qs]||{})[e];return R(n)||(delete this.props[Qs][e],this.save()),n}get_property(e){return this.props[e]}set_property(e,n){this.props[e]=n,this.save()}},Gs=(function(t){return t.Activation="events",t.Cancellation="cancelEvents",t})({}),uR=(function(t){return t.Button="button",t.Tab="tab",t.Selector="selector",t})({}),cR=(function(t){return t.TopLeft="top_left",t.TopRight="top_right",t.TopCenter="top_center",t.MiddleLeft="middle_left",t.MiddleRight="middle_right",t.MiddleCenter="middle_center",t.Left="left",t.Center="center",t.Right="right",t.NextToTrigger="next_to_trigger",t})({}),dR=(function(t){return t.Top="top",t.Left="left",t.Right="right",t.Bottom="bottom",t})({}),Mc=(function(t){return t.Popover="popover",t.API="api",t.Widget="widget",t.ExternalSurvey="external_survey",t})({}),fR=(function(t){return t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link",t})({}),pR=(function(t){return t.NextQuestion="next_question",t.End="end",t.ResponseBased="response_based",t.SpecificQuestion="specific_question",t})({}),hR=(function(t){return t.Once="once",t.Recurring="recurring",t.Always="always",t})({}),$a=(function(t){return t.SHOWN="survey shown",t.DISMISSED="survey dismissed",t.SENT="survey sent",t})({}),fm=(function(t){return t.SURVEY_ID="$survey_id",t.SURVEY_NAME="$survey_name",t.SURVEY_RESPONSE="$survey_response",t.SURVEY_ITERATION="$survey_iteration",t.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",t.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",t.SURVEY_SUBMISSION_ID="$survey_submission_id",t.SURVEY_QUESTIONS="$survey_questions",t.SURVEY_COMPLETED="$survey_completed",t})({}),xv=(function(t){return t.Popover="popover",t.Inline="inline",t})({}),fo=class{constructor(){this.ki={},this.ki={}}on(e,n){return this.ki[e]||(this.ki[e]=[]),this.ki[e].push(n),()=>{this.ki[e]=this.ki[e].filter((r=>r!==n))}}emit(e,n){for(var r of this.ki[e]||[])r(n);for(var i of this.ki["*"]||[])i(e,n)}};function Oi(t,e,n){if(ee(t))return!1;switch(n){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}var Od=class{constructor(e){this.Pi=new fo,this.Ti=(n,r)=>this.Ri(n,r)&&this.Ii(n,r)&&this.Fi(n,r)&&this.Ci(n,r),this.Ri=(n,r)=>r==null||!r.event||n?.event===r?.event,this._instance=e,this.Mi=new Set,this.Oi=new Set}init(){var e;if(!R((e=this._instance)==null?void 0:e.Ai)){var n;(n=this._instance)==null||n.Ai(((r,i)=>{this.on(r,i)}))}}register(e){var n,r;if(!R((n=this._instance)==null?void 0:n.Ai)&&(e.forEach((o=>{var a,l;(a=this.Oi)==null||a.add(o),(l=o.steps)==null||l.forEach((u=>{var c;(c=this.Mi)==null||c.add(u?.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,n){var r;n!=null&&e.length!=0&&(this.Mi.has(e)||this.Mi.has(n?.event))&&this.Oi&&((r=this.Oi)==null?void 0:r.size)>0&&this.Oi.forEach((i=>{this.Di(n,i)&&this.Pi.emit("actionCaptured",i.name)}))}ji(e){this.onAction("actionCaptured",(n=>e(n)))}Di(e,n){if(n?.steps==null)return!1;for(var r of n.steps)if(this.Ti(e,r))return!0;return!1}onAction(e,n){return this.Pi.on(e,n)}Ii(e,n){if(n!=null&&n.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!Oi(i,n.url,n.url_matching||"contains"))return!1}return!0}Fi(e,n){return!!this.Li(e,n)&&!!this.Ni(e,n)&&!!this.Ui(e,n)}Li(e,n){var r;if(n==null||!n.href)return!0;var i=this.zi(e);if(i.length>0)return i.some((a=>Oi(a.href,n.href,n.href_matching||"exact")));var s,o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!o&&Oi((s=o.match(/(?::|")href="(.*?)"/))?s[1]:"",n.href,n.href_matching||"exact")}Ni(e,n){var r;if(n==null||!n.text)return!0;var i=this.zi(e);if(i.length>0)return i.some((u=>Oi(u.text,n.text,n.text_matching||"exact")||Oi(u.$el_text,n.text,n.text_matching||"exact")));var s,o,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(s=(function(u){for(var c,d=[],f=/(?::|")text="(.*?)"/g;!ee(c=f.exec(u));)d.includes(c[1])||d.push(c[1]);return d})(l),o=n.text,a=n.text_matching||"exact",s.some((u=>Oi(u,o,a))))}Ui(e,n){var r,i;if(n==null||!n.selector)return!0;var s=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(s!=null&&s.includes(n.selector))return!0;var o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(n.selector_regex&&o)try{return new RegExp(n.selector_regex).test(o)}catch{return!1}return!1}zi(e){var n;return(e==null||(n=e.properties)==null?void 0:n.$elements)==null?[]:e?.properties.$elements}Ci(e,n){return n==null||!n.properties||n.properties.length===0||kv(n.properties.reduce(((r,i)=>{var s=ne(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)}},X=Pe("[Surveys]"),Nd="seenSurvey_",oE=(t,e)=>{var n="$survey_"+e+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(n="$survey_"+e+"/"+t.id+"/"+t.current_iteration),n},pm=t=>{var e=""+Nd+t.id;return t.current_iteration&&t.current_iteration>0&&(e=""+Nd+t.id+"_"+t.current_iteration),e},aE=[Mc.Popover,Mc.Widget,Mc.API],lE={ignoreConditions:!1,ignoreDelay:!1,displayType:xv.Popover},Fd=class{constructor(e){this._instance=e,this.Hi=new Map,this.Bi=new Map,this.qi=new Map}Wi(e,n){return!!e&&kv(e.propertyFilters,n?.properties)}Gi(e,n){var r=new Map;return e.forEach((i=>{var s;(s=i.conditions)==null||(s=s[n])==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}Vi(e,n,r){var i,s=(r===Gs.Activation?this.Hi:this.Bi).get(e),o=[];return(i=this._instance)==null||i.getSurveys((a=>{o=a.filter((l=>s?.includes(l.id)))})),o.filter((a=>{var l,u=(l=a.conditions)==null||(l=l[r])==null||(l=l.values)==null?void 0:l.find((c=>c.name===e));return this.Wi(u,n)}))}register(e){var n;R((n=this._instance)==null?void 0:n.Ai)||(this.Ji(e),this.Ki(e))}Ki(e){var n=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}));n.length!==0&&(this.Yi==null&&(this.Yi=new Od(this._instance),this.Yi.init(),this.Yi.ji((r=>{this.onAction(r)}))),n.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.Yi)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((u=>{if(u&&u.name){var c=this.qi.get(u.name);c&&c.push(r.id),this.qi.set(u.name,c||[r.id])}})))})))}Ji(e){var n,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)&&((n=this._instance)==null||n.Ai(((s,o)=>{this.onEvent(s,o)})),this.Hi=this.Gi(e,Gs.Activation),this.Bi=this.Gi(e,Gs.Cancellation))}onEvent(e,n){var r,i=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[Ra])||[];if($a.SHOWN===e&&n&&i.length>0){var s;X.info("survey event matched, removing survey from activated surveys",{event:e,eventPayload:n,existingActivatedSurveys:i});var o=n==null||(s=n.properties)==null?void 0:s.$survey_id;if(o){var a=i.indexOf(o);a>=0&&(i.splice(a,1),this.Xi(i))}}else{if(this.Bi.has(e)){var l=this.Vi(e,n,Gs.Cancellation);l.length>0&&(X.info("cancel event matched, cancelling surveys",{event:e,surveysToCancel:l.map((c=>c.id))}),l.forEach((c=>{var d,f=i.indexOf(c.id);f>=0&&i.splice(f,1),(d=this._instance)==null||d.cancelPendingSurvey(c.id)})),this.Xi(i))}if(this.Hi.has(e)){X.info("survey event name matched",{event:e,eventPayload:n,surveys:this.Hi.get(e)});var u=this.Vi(e,n,Gs.Activation);this.Xi(i.concat(u.map((c=>c.id))||[]))}}}onAction(e){var n,r=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[Ra])||[];this.qi.has(e)&&this.Xi(r.concat(this.qi.get(e)||[]))}Xi(e){var n;X.info("updating activated surveys",{activatedSurveys:e}),(n=this._instance)==null||(n=n.persistence)==null||n.register({[Ra]:[...new Set(e)]})}getSurveys(){var e,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[Ra];return n||[]}getEventToSurveys(){return this.Hi}Qi(){return this.Yi}},Ld=class{constructor(e){this.Zi=void 0,this._surveyManager=null,this.te=!1,this.ie=!1,this.ee=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var n=e.surveys;if(ee(n))return X.warn("Flags not loaded yet. Not loading surveys.");var r=ne(n);this.Zi=r?n.length>0:n,X.info("flags response received, isSurveysEnabled: "+this.Zi),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(Nd)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.ie)X.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)X.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())X.info("Not loading surveys in cookieless mode without consent.");else{var e=z?.__PosthogExtensions__;if(e){if(!R(this.Zi)||this._instance.config.advanced_enable_surveys){var n=this.Zi||this._instance.config.advanced_enable_surveys;this.ie=!0;try{var r=e.generateSurveys;if(r)return void this.re(r,n);var i=e.loadExternalDependency;if(!i)return void this.se("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",(s=>{s||!e.generateSurveys?this.se("Could not load surveys script",s):this.re(e.generateSurveys,n)}))}catch(s){throw this.se("Error initializing surveys",s),s}finally{this.ie=!1}}}else X.error("PostHog Extensions not found.")}}re(e,n){this._surveyManager=e(this._instance,n),this._surveyEventReceiver=new Fd(this._instance),X.info("Surveys loaded successfully"),this.ne({isLoaded:!0})}se(e,n){X.error(e,n),this.ne({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.ee.push(e),this._surveyManager&&this.ne({isLoaded:!0}),()=>{this.ee=this.ee.filter((n=>n!==e))}}getSurveys(e,n){if(n===void 0&&(n=!1),this._instance.config.disable_surveys)return X.info("Disabled. Not loading surveys."),e([]);var r=this._instance.get_property(rd);if(r&&!n)return e(r,{isLoaded:!0});if(this.te)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this.te=!0,this._instance.ci({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:i=>{var s;this.te=!1;var o=i.statusCode;if(o!==200||!i.json){var a="Surveys API could not be loaded, status: "+o;return X.error(a),e([],{isLoaded:!1,error:a})}var l,u=i.json.surveys||[],c=u.filter((d=>(function(f){return!(!f.start_date||f.end_date)})(d)&&((function(f){var g;return!((g=f.conditions)==null||(g=g.events)==null||(g=g.values)==null||!g.length)})(d)||(function(f){var g;return!((g=f.conditions)==null||(g=g.actions)==null||(g=g.values)==null||!g.length)})(d))));return c.length>0&&((l=this._surveyEventReceiver)==null||l.register(c)),(s=this._instance.persistence)==null||s.register({[rd]:u}),e(u,{isLoaded:!0})}})}catch(i){throw this.te=!1,i}}ne(e){for(var n of this.ee)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(r){X.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,n){if(n===void 0&&(n=!1),!ee(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);X.warn("init was not called")}oe(e){var n=null;return this.getSurveys((r=>{var i;n=(i=r.find((s=>s.id===e)))!==null&&i!==void 0?i:null})),n}ae(e){if(ee(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var n=typeof e=="string"?this.oe(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(ee(this._surveyManager))return X.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=this.ae(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return ee(this._surveyManager)?(X.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.ae(o);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})}),n)}))}renderSurvey(e,n){var r;if(ee(this._surveyManager))X.warn("init was not called");else{var i=typeof e=="string"?this.oe(e):e;if(i!=null&&i.id)if(aE.includes(i.type)){var s=A?.querySelector(n);if(s)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?(X.info("Rendering survey "+i.id+" with delay of "+i.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;X.info("Rendering survey "+i.id+" with delay of "+((o=i.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(i,s),X.info("Survey "+i.id+" rendered")}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,s);X.warn("Survey element not found")}else X.warn("Surveys of type "+i.type+" cannot be rendered in the app");else X.warn("Survey not found")}}displaySurvey(e,n){var r;if(ee(this._surveyManager))X.warn("init was not called");else{var i=this.oe(e);if(i){var s=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&n.ignoreDelay&&(s=L({},i,{appearance:L({},i.appearance,{surveyPopupDelaySeconds:0})})),n.ignoreConditions===!1){var o=this.canRenderSurvey(i);if(!o.visible)return void X.warn("Survey is not eligible to be displayed: ",o.disabledReason)}n.displayType!==xv.Inline?this._surveyManager.handlePopoverSurvey(s):this.renderSurvey(s,n.selector)}else X.warn("Survey not found")}}cancelPendingSurvey(e){ee(this._surveyManager)?X.warn("init was not called"):this._surveyManager.cancelSurvey(e)}},hm=Pe("[RateLimiter]"),Id=class{constructor(e){var n,r;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=i=>{var s=i.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach((o=>{hm.info((o||"events")+" is quota limited."),this.serverLimits[o]=new Date().getTime()+6e4}))}catch(o){return void hm.warn('could not rate limit - continuing. Error: "'+o?.message+'"',{text:s})}},this.instance=e,this.captureEventsPerSecond=((n=e.config.rate_limiting)==null?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((r=e.config.rate_limiting)==null?void 0:r.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var n,r,i;e===void 0&&(e=!1);var s=new Date().getTime(),o=(n=(r=this.instance.persistence)==null?void 0:r.get_property(sd))!==null&&n!==void 0?n:{tokens:this.captureEventsBurstLimit,last:s};o.tokens+=(s-o.last)/1e3*this.captureEventsPerSecond,o.last=s,o.tokens>this.captureEventsBurstLimit&&(o.tokens=this.captureEventsBurstLimit);var a=o.tokens<1;return a||e||(o.tokens=Math.max(0,o.tokens-1)),!a||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=a,(i=this.instance.persistence)==null||i.set_property(sd,o),{isRateLimited:a,remainingTokens:o.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}},Dr=Pe("[RemoteConfig]"),Md=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=z._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}le(e){var n,r;(n=z.__PosthogExtensions__)!=null&&n.loadExternalDependency?(r=z.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(Dr.error("PostHog Extensions not found. Cannot load remote config."),e())}ue(e){this._instance.ci({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:n=>{e(n.json)}})}load(){try{if(this.remoteConfig)return Dr.info("Using preloaded remote config",this.remoteConfig),void this.fi(this.remoteConfig);if(this._instance.O())return void Dr.warn("Remote config is disabled. Falling back to local config.");this.le((e=>{if(!e)return Dr.info("No config found after loading remote JS config. Falling back to JSON."),void this.ue((n=>{this.fi(n)}));this.fi(e)}))}catch(e){Dr.error("Error loading remote config",e)}}fi(e){e?this._instance.config.__preview_remote_config?(this._instance.fi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):Dr.info("__preview_remote_config is disabled. Logging config instead",e):Dr.error("Failed to fetch remote config from PostHog.")}},$d=3e3,Dd=class{constructor(e,n){this.he=!0,this.ve=[],this.de=en(n?.flush_interval_ms||$d,250,5e3,O.createLogger("flush interval"),$d),this.ce=e}enqueue(e){this.ve.push(e),this.fe||this.pe()}unload(){this.ge();var e=this.ve.length>0?this._e():{},n=Object.values(e);[...n.filter((r=>r.url.indexOf("/e")===0)),...n.filter((r=>r.url.indexOf("/e")!==0))].map((r=>{this.ce(L({},r,{transport:"sendBeacon"}))}))}enable(){this.he=!1,this.pe()}pe(){var e=this;this.he||(this.fe=setTimeout((()=>{if(this.ge(),this.ve.length>0){var n=this._e(),r=function(){var s=n[i],o=new Date().getTime();s.data&&ne(s.data)&&re(s.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.ce(s)};for(var i in n)r()}}),this.de))}ge(){clearTimeout(this.fe),this.fe=void 0}_e(){var e={};return re(this.ve,(n=>{var r,i=n,s=(i?i.batchKey:null)||i.url;R(e[s])&&(e[s]=L({},i,{data:[]})),(r=e[s].data)==null||r.push(i.data)})),this.ve=[],e}},uE=["retriesPerformedSoFar"],Vd=class{constructor(e){this.me=!1,this.ye=3e3,this.ve=[],this._instance=e,this.ve=[],this.be=!0,!R(x)&&"onLine"in x.navigator&&(this.be=x.navigator.onLine,this.we=()=>{this.be=!0,this.Dt()},this.xe=()=>{this.be=!1},Ee(x,"online",this.we),Ee(x,"offline",this.xe))}get length(){return this.ve.length}retriableRequest(e){var{retriesPerformedSoFar:n}=e,r=wm(e,uE);rn(n)&&n>0&&(r.url=Ja(r.url,{retry_count:n})),this._instance.ci(L({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(n??0)<10?this.Se(L({retriesPerformedSoFar:n},r)):r.callback==null||r.callback(i)}}))}Se(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var r=(function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=(Math.random()-.5)*(u-l);return Math.ceil(u+c)})(n),i=Date.now()+r;this.ve.push({retryAt:i,requestOptions:e});var s="Enqueued failed request for retry in "+r;navigator.onLine||(s+=" (Browser is offline)"),O.warn(s),this.me||(this.me=!0,this.Ee())}Ee(){if(this.$e&&clearTimeout(this.$e),this.ve.length===0)return this.me=!1,void(this.$e=void 0);this.$e=setTimeout((()=>{this.be&&this.ve.length>0&&this.Dt(),this.Ee()}),this.ye)}Dt(){var e=Date.now(),n=[],r=this.ve.filter((s=>s.retryAt<e||(n.push(s),!1)));if(this.ve=n,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.$e&&(clearTimeout(this.$e),this.$e=void 0),this.me=!1,R(x)||(this.we&&(x.removeEventListener("online",this.we),this.we=void 0),this.xe&&(x.removeEventListener("offline",this.xe),this.xe=void 0)),this.ve))try{this._instance.ci(L({},e,{transport:"sendBeacon"}))}catch(n){O.error(n)}this.ve=[]}},jd=class{constructor(e){this.ke=()=>{var n,r,i,s;this.Pe||(this.Pe={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+(o?.clientHeight||0),c=o?.scrollHeight||0;this.Pe.lastScrollY=Math.ceil(a),this.Pe.maxScrollY=Math.max(a,(n=this.Pe.maxScrollY)!==null&&n!==void 0?n:0),this.Pe.maxScrollHeight=Math.max(l,(r=this.Pe.maxScrollHeight)!==null&&r!==void 0?r:0),this.Pe.lastContentY=u,this.Pe.maxContentY=Math.max(u,(i=this.Pe.maxContentY)!==null&&i!==void 0?i:0),this.Pe.maxContentHeight=Math.max(c,(s=this.Pe.maxContentHeight)!==null&&s!==void 0?s:0)},this._instance=e}getContext(){return this.Pe}resetContext(){var e=this.Pe;return setTimeout(this.ke,0),e}startMeasuringScrollPosition(){Ee(x,"scroll",this.ke,{capture:!0}),Ee(x,"scrollend",this.ke,{capture:!0}),Ee(x,"resize",this.ke)}scrollElement(){if(!this._instance.config.scroll_root_selector)return x?.document.documentElement;var e=ne(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var n of e){var r=x?.document.querySelector(n);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return x&&(x.scrollY||x.pageYOffset||x.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return x&&(x.scrollX||x.pageXOffset||x.document.documentElement.scrollLeft)||0}},cE=t=>pv(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties),tl=class{constructor(e,n,r,i){this.Te=s=>{var o=this.Re();if(!o||o.sessionId!==s){var a={sessionId:s,props:this.Ie(this._instance)};this.Fe.register({[id]:a})}},this._instance=e,this.Ce=n,this.Fe=r,this.Ie=i||cE,this.Ce.onSessionId(this.Te)}Re(){return this.Fe.props[id]}getSetOnceProps(){var e,n=(e=this.Re())==null?void 0:e.props;return n?"r"in n?hv(n):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var e={};return re(Gd(this.getSetOnceProps()),((n,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+jc(r)]=n})),e}},$c=Pe("[SessionId]"),nl=class{on(e,n){return this.Me.on(e,n)}constructor(e,n,r){var i;if(this.Oe=[],this.Ae=void 0,this.Me=new fo,this.De=(c,d)=>Math.abs(c-d)>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.F=e.config,this.Fe=e.persistence,this.je=void 0,this.Le=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Ne=n||Yn,this.Ue=r||Yn;var s=this.F.persistence_name||this.F.token,o=this.F.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*en(o,60,36e3,$c.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ze(),this.He="ph_"+s+"_window_id",this.Be="ph_"+s+"_primary_window_exists",this.qe()){var a=Ie.W(this.He),l=Ie.W(this.Be);a&&!l?this.je=a:Ie.V(this.He),Ie.G(this.Be,!0)}if((i=this.F.bootstrap)!=null&&i.sessionID)try{var u=(c=>{var d=c.replace(/-/g,"");if(d.length!==32)throw new Error("Not a valid UUID");if(d[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(d.substring(0,12),16)})(this.F.bootstrap.sessionID);this.We(this.F.bootstrap.sessionID,new Date().getTime(),u)}catch(c){$c.error("Invalid sessionID in bootstrap",c)}this.Ge()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return R(this.Oe)&&(this.Oe=[]),this.Oe.push(e),this.Le&&e(this.Le,this.je),()=>{this.Oe=this.Oe.filter((n=>n!==e))}}qe(){return this.F.persistence!=="memory"&&!this.Fe.wi&&Ie.H()}Ve(e){e!==this.je&&(this.je=e,this.qe()&&Ie.G(this.He,e))}Je(){return this.je?this.je:this.qe()?Ie.W(this.He):null}We(e,n,r){e===this.Le&&n===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this.Le=e,this.Fe.register({[ja]:[n,e,r]}))}Ke(){var e=this.Fe.props[ja];return ne(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.We(null,null,null)}destroy(){clearTimeout(this.Ye),this.Ye=void 0,this.Ae&&x&&(x.removeEventListener("beforeunload",this.Ae,{capture:!1}),this.Ae=void 0),this.Oe=[]}Ge(){this.Ae=()=>{this.qe()&&Ie.V(this.Be)},Ee(x,"beforeunload",this.Ae,{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.F.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),[i,s,o]=this.Ke(),a=this.Je(),l=rn(o)&&o>0&&Math.abs(r-o)>864e5,u=!1,c=!s,d=!c&&!e&&this.De(r,i);c||d||l?(s=this.Ne(),a=this.Ue(),$c.info("new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:c,activityTimeout:d,sessionPastMaximumLength:l}}),o=r,u=!0):a||(a=this.Ue(),u=!0);var f=i===0||!e||l?r:i,g=o===0?new Date().getTime():o;return this.Ve(a),this.We(s,f,g),e||this.ze(),u&&this.Oe.forEach((v=>v(s,a,u?{noSessionId:c,activityTimeout:d,sessionPastMaximumLength:l}:void 0))),{sessionId:s,windowId:a,sessionStartTimestamp:g,changeReason:u?{noSessionId:c,activityTimeout:d,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}ze(){clearTimeout(this.Ye),this.Ye=setTimeout((()=>{var[e]=this.Ke();if(this.De(new Date().getTime(),e)){var n=this.Le;this.resetSessionId(),this.Me.emit("forcedIdleReset",{idleSessionId:n})}}),1.1*this.sessionTimeoutMs)}},dE=["$set_once","$set"],Gn=Pe("[SiteApps]"),zd=class{constructor(e){this._instance=e,this.Xe=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Qe(e,n){if(n){var r=this.globalsForEvent(n);this.Xe.push(r),this.Xe.length>1e3&&(this.Xe=this.Xe.slice(10))}}get siteAppLoaders(){var e;return(e=z._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Ai(this.Qe.bind(this));this.Ze=()=>{e(),this.Xe=[],this.Ze=void 0}}}globalsForEvent(e){var n,r,i,s,o,a,l;if(!e)throw new Error("Event payload is required");var u={},c=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var[f,g]of Object.entries(d))u[f]={id:c[f],type:f,properties:g};var{$set_once:v,$set:y}=e;return{event:L({},wm(e,dE),{properties:L({},e.properties,y?{$set:L({},(n=(r=e.properties)==null?void 0:r.$set)!==null&&n!==void 0?n:{},y)}:{},v?{$set_once:L({},(i=(s=e.properties)==null?void 0:s.$set_once)!==null&&i!==void 0?i:{},v)}:{}),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:u}}setupSiteApp(e){var n=this.apps[e.id],r=()=>{var a;!n.errored&&this.Xe.length&&(Gn.info("Processing "+this.Xe.length+" events for site app with id "+e.id),this.Xe.forEach((l=>n.processEvent==null?void 0:n.processEvent(l))),n.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((a=this.Ze)==null||a.call(this))},i=!1,s=a=>{n.errored=!a,n.loaded=!0,Gn.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&&(n.processEvent=o),i=!0}catch(a){Gn.error("Error while initializing PostHog app with config id "+e.id,a),s(!1)}if(i&&n.loaded)try{r()}catch(a){Gn.error("Error while processing buffered events PostHog app with config id "+e.id,a),n.errored=!0}}tr(){var e=this.siteAppLoaders||[];for(var n of e)this.apps[n.id]={id:n.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}ir(e){if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(n)}catch(i){Gn.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var n,r,i,s=this;if((n=this.siteAppLoaders)!=null&&n.length)return this.isEnabled?(this.tr(),void this._instance.on("eventCaptured",(u=>this.ir(u)))):void Gn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.Ze)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(u){var c;z["__$$ph_site_app_"+u]=s._instance,(c=z.__PosthogExtensions__)==null||c.loadSiteApp==null||c.loadSiteApp(s._instance,l,(d=>{if(d)return Gn.error("Error while initializing PostHog app with config id "+u,d)}))};for(var{id:a,url:l}of e.siteApps)o(a)}else Gn.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}},Ev=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&Rg(n,e))return!0;try{var r=t?.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>Rg(i?.brand,e))))return!0}catch{}return!!t.webdriver},no=(function(t){return t.US="us",t.EU="eu",t.CUSTOM="custom",t})({}),gm="i.posthog.com",Hd=class{constructor(e){this.er={},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,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+gm,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.er[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.er[this.apiHost]=no.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.er[this.apiHost]=no.EU:this.er[this.apiHost]=no.CUSTOM),this.er[this.apiHost]}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(e==="flags")return this.flagsApiHost+n;if(this.region===no.CUSTOM)return this.apiHost+n;var r=gm+n;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},fE={icontains:(t,e)=>!!x&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!x&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!x&&el(e.href,t),not_regex:(t,e)=>!!x&&!el(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t},Bd=class t{constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments((i=>{t.rr("retrieved web experiments from the server"),n.sr=new Map,i.forEach((s=>{if(s.feature_flag_key){var o;n.sr&&(t.rr("setting flag key ",s.feature_flag_key," to web experiment ",s),(o=n.sr)==null||o.set(s.feature_flag_key,s));var a=n._instance.getFeatureFlag(s.feature_flag_key);Te(a)&&s.variants[a]&&n.nr(s.name,a,s.variants[a].transforms)}else if(s.variants)for(var l in s.variants){var u=s.variants[l];t.ar(u)&&n.nr(s.name,l,u.transforms)}}))}),r)},this._instance=e,this._instance.onFeatureFlags((r=>{this.onFeatureFlags(r)}))}onFeatureFlags(e){if(this._is_bot())t.rr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(ee(this.sr))return this.sr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.rr("applying feature flags",e),e.forEach((n=>{var r;if(this.sr&&(r=this.sr)!=null&&r.has(n)){var i,s=this._instance.getFeatureFlag(n),o=(i=this.sr)==null?void 0:i.get(n);s&&o!=null&&o.variants[s]&&this.nr(o.name,s,o.variants[s].transforms)}}))}}previewWebExperiment(){var e=t.getWindowLocation();if(e!=null&&e.search){var n=Ka(e?.search,"__experiment_id"),r=Ka(e?.search,"__experiment_variant");n&&r&&(t.rr("previewing web experiments "+n+" && "+r),this.getWebExperiments((i=>{this.lr(parseInt(n),r,i)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!n)return e(i);this._instance.ci({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)}})}lr(e,n,r){var i=r.filter((s=>s.id===e));i&&i.length>0&&(t.rr("Previewing web experiment ["+i[0].name+"] with variant ["+n+"]"),this.nr(i[0].name,n,i[0].variants[n].transforms))}static ar(e){return!ee(e.conditions)&&t.ur(e)&&t.hr(e)}static ur(e){var n;if(ee(e.conditions)||ee((n=e.conditions)==null?void 0:n.url))return!0;var r,i,s,o=t.getWindowLocation();return!!o&&((r=e.conditions)==null||!r.url||fE[(i=(s=e.conditions)==null?void 0:s.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,o))}static getWindowLocation(){return x?.location}static hr(e){var n;if(ee(e.conditions)||ee((n=e.conditions)==null?void 0:n.utm))return!0;var r=uv();if(r.utm_source){var i,s,o,a,l,u,c,d,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,g=(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,v=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=e.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==r.utm_medium,y=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((d=e.conditions)==null||(d=d.utm)==null?void 0:d.utm_term)==r.utm_term;return f&&v&&y&&g}return!1}static rr(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];O.info("[WebExperiments] "+e,r)}nr(e,n,r){this._is_bot()?t.rr("Refusing to render web experiment since the viewer is a likely bot"):n!=="control"?r.forEach((i=>{if(i.selector){var s;t.rr("applying transform of variant "+n+" 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)}))}})):t.rr("Control variants leave the page unmodified.")}_is_bot(){return pt&&this._instance?Ev(pt,this._instance.config.custom_blocked_useragents):void 0}},pE=Pe("[PostHog ExternalIntegrations]"),hE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ud=class{constructor(e){this._instance=e}it(e,n){var r;(r=z.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(i=>{if(i)return pE.error("failed to load script",i);n()}))}startIfEnabledOrStop(){var e=this,n=function(o){var a,l,u;!i||(a=z.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.it(hE[o],(()=>{var c;(c=z.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.start(e._instance)})),!i&&(l=z.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((u=z.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.stop())};for(var[r,i]of Object.entries((s=this._instance.config.integrations)!==null&&s!==void 0?s:{})){var s;n(r)}}},Wd="[SessionRecording]",Zs=Pe(Wd),rl=class{get started(){var e;return!((e=this.vr)==null||!e.isStarted)}get status(){return this.vr?this.vr.status:this.dr&&!this.cr?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.dr=!1,this.pr=void 0,this._instance=e,!this._instance.sessionManager)throw Zs.error("started without valid sessionManager"),new Error(Wd+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(Wd+' cannot be used with cookieless_mode="always"')}get cr(){var e,n=!((e=this._instance.get_property(bc))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return x&&n&&r&&!i}startIfEnabledOrStop(e){var n;if(!this.cr||(n=this.vr)==null||!n.isStarted){var r=!R(Object.assign)&&!R(Array.from);this.cr&&r?(this.gr(e),Zs.info("starting")):this.stopRecording()}}gr(e){var n,r,i;this.cr&&(z!=null&&(n=z.__PosthogExtensions__)!=null&&(n=n.rrweb)!=null&&n.record&&(r=z.__PosthogExtensions__)!=null&&r.initSessionRecording?this._r(e):(i=z.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.mr,(s=>{if(s)return Zs.error("could not load recorder",s);this._r(e)})))}stopRecording(){var e,n;(e=this.pr)==null||e.call(this),this.pr=void 0,(n=this.vr)==null||n.stop()}yr(){var e;(e=this._instance.persistence)==null||e.unregister(Am)}br(e){if(this._instance.persistence){var n,r,i=this._instance.persistence,s=()=>{var o=e.sessionRecording===!1?void 0:e.sessionRecording,a=o?.sampleRate,l=ee(a)?null:parseFloat(a);ee(l)&&this.yr();var u=o?.minimumDurationMilliseconds;i.register({[bc]:L({enabled:!!o},o,{networkPayloadCapture:L({capturePerformance:e.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:l,minimumDurationMilliseconds:R(u)?null:u,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};s(),(n=this.pr)==null||n.call(this),this.pr=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.br(e),this.dr=!0,this.startIfEnabledOrStop()):this.dr=!0:Zs.info("skipping remote config with no sessionRecording",e)}log(e,n){var r;n===void 0&&(n="log"),(r=this.vr)!=null&&r.log?this.vr.log(e,n):Zs.warn("log called before recorder was ready")}get mr(){var e,n,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(bc);return(r==null||(n=r.scriptConfig)==null?void 0:n.script)||"lazy-recorder"}_r(e){var n,r;if((n=z.__PosthogExtensions__)==null||!n.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.vr||(this.vr=(r=z.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.vr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.vr.start(e)}onRRwebEmit(e){var n;(n=this.vr)==null||n.onRRwebEmit==null||n.onRRwebEmit(e)}overrideLinkedFlag(){var e,n;this.vr||(n=this._instance.persistence)==null||n.register({$replay_override_linked_flag:!0}),(e=this.vr)==null||e.overrideLinkedFlag()}overrideSampling(){var e,n;this.vr||(n=this._instance.persistence)==null||n.register({$replay_override_sampling:!0}),(e=this.vr)==null||e.overrideSampling()}overrideTrigger(e){var n,r;this.vr||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(n=this.vr)==null||n.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.vr)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,n){var r;return!((r=this.vr)==null||!r.tryAddCustomEvent(e,n))}},so={},qd=()=>{},Ni="posthog",Sv=!nE&&nt?.indexOf("MSIE")===-1&&nt?.indexOf("Mozilla")===-1,mm=t=>{var e;return L({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:lx(A?.location),persistence:"localStorage+cookie",persistence_name:"",loaded:qd,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,debug:rt&&Te(rt?.search)&&rt.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_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(x==null||(e=x.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:n=>{var r="Bad HTTP status: "+n.statusCode+" "+n.text;O.error(r)},get_device_id:n=>n,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:$d},error_tracking:{},_onCapture:qd,__preview_eager_load_replay:!1},(n=>({rageclick:!(n&&n>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(n&&n>="2025-05-24")||"history_change",session_recording:n&&n>="2025-11-30"?{strictMinimumDuration:!0}:{}}))(t))},vm=t=>{var e={};R(t.process_person)||(e.person_profiles=t.process_person),R(t.xhr_headers)||(e.request_headers=t.xhr_headers),R(t.cookie_name)||(e.persistence_name=t.cookie_name),R(t.disable_cookie)||(e.disable_persistence=t.disable_cookie),R(t.store_google)||(e.save_campaign_params=t.store_google),R(t.verbose)||(e.debug=t.verbose);var n=_e({},e,t);return ne(t.property_blacklist)&&(R(t.property_denylist)?n.property_denylist=t.property_blacklist:ne(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:O.error("Invalid value for property_denylist config: "+t.property_denylist)),n},Kd=class{constructor(){this.__forceAllowLocalhost=!1}get wr(){return this.__forceAllowLocalhost}set wr(e){O.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},il=class t{get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new Kd,this.Sr=!1,this.version=yn.LIB_VERSION,this.Er=new fo,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=mm(),this.SentryIntegration=md,this.sentryIntegration=e=>(function(n,r){var i=qm(n,r);return{name:Wm,processEvent:s=>i(s)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.$r=!1,this.kr=null,this.Pr=null,this.Tr=null,this.featureFlags=new Ad(this),this.toolbar=new vd(this),this.scrollManager=new jd(this),this.pageViewManager=new Sd(this),this.surveys=new Ld(this),this.experiments=new Bd(this),this.exceptions=new Rd(this),this.rateLimiter=new Id(this),this.requestRouter=new Hd(this),this.consent=new pd(this),this.externalIntegrations=new Ud(this),this.people={set:(e,n,r)=>{var i=Te(e)?{[e]:n}:e;this.setPersonProperties(i),r?.({})},set_once:(e,n,r)=>{var i=Te(e)?{[e]:n}:e;this.setPersonProperties(void 0,i),r?.({})}},this.on("eventCaptured",(e=>O.info('send "'+e?.event+'"',e)))}init(e,n,r){if(r&&r!==Ni){var i,s=(i=so[r])!==null&&i!==void 0?i:new t;return s._init(e,n,r),so[r]=s,so[Ni][r]=s,s}return this._init(e,n,r)}_init(e,n,r){var i;if(n===void 0&&(n={}),R(e)||zc(e))return O.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={},n.debug=this.Rr(n.debug),this.Ir=n,this.Fr=[],n.person_profiles&&(this.Pr=n.person_profiles),this.set_config(_e({},mm(n.defaults),vm(n),{name:r,token:e})),this.config.on_xhr_error&&O.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:kn.GZipJS;var s=this.Cr();this.persistence=new io(this.config,s),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new io(L({},this.config,{persistence:"sessionStorage"}),s);var o=L({},this.persistence.props),a=L({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Mr=new Dd((p=>this.Or(p)),this.config.request_queue_config),this.Ar=new Vd(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 nl(this),this.sessionPropsManager=new tl(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(O.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Dr(l)}),0)):(O.info("Initializing extensions synchronously"),this.Dr(l)),yn.DEBUG=yn.DEBUG||this.config.debug,yn.DEBUG&&O.info("Starting in debug mode",{this:this,config:n,thisC:L({},this.config),p:o,s:a}),((i=n.bootstrap)==null?void 0:i.distinctID)!==void 0){var u,c,d=this.config.get_device_id(Yn()),f=(u=n.bootstrap)!=null&&u.isIdentifiedID?d:n.bootstrap.distinctID;this.persistence.set_property(_n,(c=n.bootstrap)!=null&&c.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:n.bootstrap.distinctID,$device_id:f})}if(this.jr()){var g,v,y=Object.keys(((g=n.bootstrap)==null?void 0:g.featureFlags)||{}).filter((p=>{var m;return!((m=n.bootstrap)==null||(m=m.featureFlags)==null||!m[p])})).reduce(((p,m)=>{var _;return p[m]=((_=n.bootstrap)==null||(_=_.featureFlags)==null?void 0:_[m])||!1,p}),{}),k=Object.keys(((v=n.bootstrap)==null?void 0:v.featureFlagPayloads)||{}).filter((p=>y[p])).reduce(((p,m)=>{var _,w;return(_=n.bootstrap)!=null&&(_=_.featureFlagPayloads)!=null&&_[m]&&(p[m]=(w=n.bootstrap)==null||(w=w.featureFlagPayloads)==null?void 0:w[m]),p}),{});this.featureFlags.receivedFeatureFlags({featureFlags:y,featureFlagPayloads:k})}if(l)this.register_once({distinct_id:zs,$device_id:null},"");else if(!this.get_distinct_id()){var h=this.config.get_device_id(Yn());this.register_once({distinct_id:h,$device_id:h},""),this.persistence.set_property(_n,"anonymous")}return Ee(x,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),n.segment?Ax(this,(()=>this.Lr())):this.Lr(),Qn(this.config._onCapture)&&this.config._onCapture!==qd&&(O.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(p=>this.config._onCapture(p.event,p)))),this.config.ip&&O.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}Dr(e){var n=performance.now();this.historyAutocapture=new gd(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new yd(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new zd(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new rl(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new ud(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.heatmaps=new Ed(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new xd(this)})),r.push((()=>{this.exceptionObserver=new hd(this),this.exceptionObserver.startIfEnabled()})),r.push((()=>{this.deadClicksAutocapture=new Za(this,Rx),this.deadClicksAutocapture.startIfEnabled()})),r.push((()=>{if(this.Nr){var i=this.Nr;this.Nr=void 0,this.fi(i)}})),this.Ur(r,n)}Ur(e,n){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&e.length>0)return void setTimeout((()=>{this.Ur(e,n)}),0);var r=e.shift();if(r)try{r()}catch(s){O.error("Error initializing extension:",s)}}var i=Math.round(performance.now()-n);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&&O.info("PostHog extensions initialized ("+i+"ms)")}fi(e){var n,r,i,s,o,a,l,u;if(!A||!A.body)return O.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.fi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Nr=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=U(e.supportedCompression,kn.GZipJS)?kn.GZipJS:U(e.supportedCompression,kn.Base64)?kn.Base64:void 0),(n=e.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Pr?this.Pr:"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),(a=this.webVitalsAutocapture)==null||a.onRemoteConfig(e),(l=this.exceptionObserver)==null||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}Lr(){try{this.config.loaded(this)}catch(e){O.critical("`loaded` function failed",e)}this.zr(),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.Hr()}),1),new Md(this).load(),this.featureFlags.flags()}zr(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Mr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Jn(this.__request_queue,(e=>this.Or(e))),this.__request_queue=[],this.zr()}_handle_unload(){var e,n;this.config.request_batching?(this.Br()&&this.capture("$pageleave"),(e=this.Mr)==null||e.unload(),(n=this.Ar)==null||n.unload()):this.Br()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}ci(e){this.__loaded&&(Sv?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Ja(e.url,{ip:this.config.ip?1:0}),e.headers=L({},this.config.request_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,(n=>{var r,i,s,o=L({},n);o.timeout=o.timeout||6e4,o.url=Ja(o.url,{_:new Date().getTime().toString(),ver:yn.LIB_VERSION,compression:o.compression});var a=(r=o.transport)!==null&&r!==void 0?r:"fetch",l=Ma.filter((c=>!o.disableTransport||!c.transport||!o.disableTransport.includes(c.transport))),u=(i=(s=Tm(l,(c=>c.transport===a)))==null?void 0:s.method)!==null&&i!==void 0?i:l[0].method;if(!u)throw new Error("No available transport method");u(o)})(L({},e,{callback:n=>{var r,i;this.rateLimiter.checkForLimiting(n),n.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,n)),e.callback==null||e.callback(n)}}))))}Or(e){this.Ar?this.Ar.retriableRequest(e):this.ci(e)}_execute_array(e){var n,r=[],i=[],s=[];Jn(e,(a=>{a&&(n=a[0],ne(n)?s.push(a):Qn(a)?a.call(this):ne(a)&&n==="alias"?r.push(a):ne(a)&&n.indexOf("capture")!==-1&&Qn(this[n])?s.push(a):i.push(a))}));var o=function(a,l){Jn(a,(function(u){if(ne(u[0])){var c=l;re(u,(function(d){c=c[d[0]].apply(c,d.slice(1))}))}else this[u[0]].apply(this,u.slice(1))}),l)};o(r,this),o(i,this),o(s,this)}jr(){var e,n;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((n=this.config.bootstrap)==null?void 0:n.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,n,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Mr){if(this.is_capturing())if(!R(e)&&Te(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){n!=null&&n.$current_url&&!Te(n?.$current_url)&&(O.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$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,u=Yn(),c={uuid:u,event:e,properties:this.calculateEventProperties(e,n||{},l,u)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&s&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),o&&(c.properties.$lib_rate_limit_remaining_tokens=o.remainingTokens),r?.$set&&(c.$set=r?.$set);var d,f=this.qr(r?.$set_once);if(f&&(c.$set_once=f),(c=ox(c,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,R(r?.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=a),e===$a.DISMISSED||e===$a.SENT){var g=n?.[fm.SURVEY_ID],v=n?.[fm.SURVEY_ITERATION];d={id:g,current_iteration:v},localStorage.getItem(pm(d))||localStorage.setItem(pm(d),"true"),c.$set=L({},c.$set,{[oE({id:g,current_iteration:v},e===$a.SENT?"responded":"dismissed")]:!0})}var y=L({},c.properties.$set,c.$set);if(Fi(y)||this.setPersonPropertiesForFlags(y),!ee(this.config.before_send)){var k=this.Wr(c);if(!k)return;c=k}this.Er.emit("eventCaptured",c);var h={method:"POST",url:(i=r?._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:r?._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.Or(h):this.Mr.enqueue(h),c}O.critical("This capture call is ignored due to client rate limiting.")}}else O.error("No event name provided to posthog.capture")}else O.uninitializedWarning("posthog.capture")}Ai(e){return this.on("eventCaptured",(n=>e(n.event,n)))}calculateEventProperties(e,n,r,i,s){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var o=s?void 0:this.persistence.remove_event_timer(e),a=L({},n);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=L({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!Te(a.distinct_id)&&!rn(a.distinct_id)||zc(a.distinct_id))&&O.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=qx(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:d,windowId:f}=this.sessionManager.checkAndGetSessionAndWindowId(s,r.getTime());a.$session_id=d,a.$window_id=f}this.sessionPropsManager&&_e(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&_e(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.Ar)==null?void 0:g.length}catch(h){a.$sdk_debug_error_capturing_properties=String(h)}if(this.requestRouter.region===no.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),u=e!=="$pageview"||s?e!=="$pageleave"||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=_e(a,u),e==="$pageview"&&A&&(a.title=A.title),!R(o)){var v=r.getTime()-o;a.$duration=parseFloat((v/1e3).toFixed(3))}nt&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=_e({},c,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),ne(this.config.property_denylist)?re(this.config.property_denylist,(function(h){delete a[h]})):O.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var y=this.config.sanitize_properties;y&&(O.error("sanitize_properties is deprecated. Use before_send instead"),a=y(a,e));var k=this.Gr();return a.$process_person_profile=k,k&&!s&&this.Vr("_calculate_event_properties"),a}qr(e){var n;if(!this.persistence||!this.Gr()||this.Sr)return e;var r=this.persistence.get_initial_props(),i=(n=this.sessionPropsManager)==null?void 0:n.getSetOnceProps(),s=_e({},r,i||{},e||{}),o=this.config.sanitize_properties;return o&&(O.error("sanitize_properties is deprecated. Use before_send instead"),s=o(s,"$set_once")),this.Sr=!0,Fi(s)?void 0:s}register(e,n){var r;(r=this.persistence)==null||r.register(e,n)}register_once(e,n,r){var i;(i=this.persistence)==null||i.register_once(e,n,r)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}Jr(e,n){this.register({[e]:n})}getFeatureFlag(e,n){return this.featureFlags.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(n)}catch{return n}}isFeatureEnabled(e,n){return this.featureFlags.isFeatureEnabled(e,n)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,n,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,n,r)}getEarlyAccessFeatures(e,n,r){return n===void 0&&(n=!1),this.featureFlags.getEarlyAccessFeatures(e,n,r)}on(e,n){return this.Er.on(e,n)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys.getSurveys(e,n)}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys.getActiveMatchingSurveys(e,n)}renderSurvey(e,n){this.surveys.renderSurvey(e,n)}displaySurvey(e,n){n===void 0&&(n=lE),this.surveys.displaySurvey(e,n)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,n){return n===void 0&&(n=!1),this.surveys.canRenderSurveyAsync(e,n)}identify(e,n,r){if(!this.__loaded||!this.persistence)return O.uninitializedWarning("posthog.identify");if(rn(e)&&(e=e.toString(),O.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()))O.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!==zs){if(this.Vr("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(Ys)&&(this.unregister(Ys),this.register({distinct_id:e}));var o=(this.persistence.get_property(_n)||"anonymous")==="anonymous";e!==i&&o?(this.persistence.set_property(_n,"identified"),this.setPersonPropertiesForFlags(L({},r||{},n||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:n||{},$set_once:r||{}}),this.Tr=am(e,n,r),this.featureFlags.setAnonymousDistinctId(i)):(n||r)&&this.setPersonProperties(n,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(za))}}else O.critical('The string "'+zs+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else O.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,n){if((e||n)&&this.Vr("posthog.setPersonProperties")){var r=am(this.get_distinct_id(),e,n);this.Tr!==r?(this.setPersonPropertiesForFlags(L({},n||{},e||{})),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.Tr=r):O.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,n,r){if(e&&n){if(this.Vr("posthog.group")){var i=this.getGroups();i[e]!==n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:L({},i,{[e]:n})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:n,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===n||r||this.reloadFeatureFlags()}}else O.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0),this.featureFlags.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0),this.Vr("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,n)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var n,r,i,s;if(O.info("reset"),!this.__loaded)return O.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(_n,"anonymous"),(s=this.sessionManager)==null||s.resetSessionId(),this.Tr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:zs,$device_id:null},"");else{var a=this.config.get_device_id(Yn());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,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:n,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n);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,n){return e===this.get_property(Pm)?(O.critical("Attempting to create alias for existing People user - aborting."),-2):this.Vr("posthog.alias")?(R(n)&&(n=this.get_distinct_id()),e!==n?(this.Jr(Ys,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(O.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=L({},this.config);if(Ne(e)){var r,i,s,o,a;_e(this.config,vm(e));var l=this.Cr();(r=this.persistence)==null||r.update_config(this.config,n,l),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new io(L({},this.config,{persistence:"sessionStorage"}),l);var u=this.Rr(this.config.debug);Xn(u)&&(this.config.debug=u),Xn(this.config.debug)&&(this.config.debug?(yn.DEBUG=!0,pe.H()&&pe.G("ph_debug","true"),O.info("set_config",{config:e,oldConfig:n,newConfig:L({},this.config)})):(yn.DEBUG=!1,pe.H()&&pe.V("ph_debug"))),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),(s=this.autocapture)==null||s.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),this.surveys.loadIfEnabled(),this.Kr(),(a=this.externalIntegrations)==null||a.startIfEnabledOrStop()}}startSessionRecording(e){var n=e===!0,r={sampling:n||!(e==null||!e.sampling),linked_flag:n||!(e==null||!e.linked_flag),url_trigger:n||!(e==null||!e.url_trigger),event_trigger:n||!(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,n){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(L({},i,n))}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:Ni;return n!==Ni&&(n=Ni+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(_n))==="identified"||((n=this.sessionPersistence)==null?void 0:n.get_property(_n))==="identified"}Gr(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Fi(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Ys])&&((n=this.persistence)==null||(n=n.props)==null||!n[Ba]))}Br(){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.Gr()||this.Vr("posthog.createPersonProfile")&&this.setPersonProperties({},{})}Vr(e){return this.config.person_profiles==="never"?(O.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Jr(Ba,!0),!0)}Cr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),n=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!n}Kr(){var e,n,r,i,s=this.Cr();return((e=this.persistence)==null?void 0:e.wi)!==s&&((r=this.persistence)==null||r.set_disabled(s)),((n=this.sessionPersistence)==null?void 0:n.wi)!==s&&((i=this.sessionPersistence)==null||i.set_disabled(s)),s}opt_in_capturing(e){var n;if(this.config.cookieless_mode!=="always"){var r,i;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(r=this.sessionManager)==null||r.destroy(),this.sessionManager=new nl(this),this.persistence&&(this.sessionPropsManager=new tl(this,this.sessionManager,this.persistence)),this.sessionRecording=new rl(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.Kr(),this.zr(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(R(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((i=e?.captureEventName)!==null&&i!==void 0?i:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Hr()}else O.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,n;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.Kr(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:zs,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(n=this.sessionRecording)==null||n.stopRecording(),this.sessionRecording=void 0,this.Hr())):O.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===wn.GRANTED?"granted":e===wn.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.Kr()}_is_bot(){return pt?Ev(pt,this.config.custom_blocked_useragents):void 0}Hr(){A&&(A.visibilityState==="visible"?this.$r||(this.$r=!0,this.capture("$pageview",{title:A.title},{send_instantly:!0}),this.kr&&(A.removeEventListener("visibilitychange",this.kr),this.kr=null)):this.kr||(this.kr=this.Hr.bind(this),Ee(A,"visibilitychange",this.kr)))}debug(e){e===!1?(x?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(x?.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}))}O(){var e,n,r,i,s,o,a,l=this.Ir||{};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?(O.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=O,o=(n="advanced_disable_flags")in(e=l)&&!R(e[n]),a=r in e&&!R(e[r]),o?e[n]:a?(s&&s.warn("Config field '"+r+"' is deprecated. Please use '"+n+"' instead. The old field will be removed in a future major version."),e[r]):i)}Wr(e){if(ee(this.config.before_send))return e;var n=ne(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of n){if(r=i(r),ee(r)){var s="Event '"+e.event+"' was rejected in beforeSend function";return Bk(e.event)?O.warn(s+". This can cause unexpected behavior."):O.info(s),null}r.properties&&!Fi(r.properties)||O.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.Vt)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(r)})}Rr(e){var n=Xn(e)&&!e,r=pe.H()&&pe.q("ph_debug")==="true";return!n&&(!!r||e)}};(function(t,e){for(var n=0;n<e.length;n++)t.prototype[e[n]]=sx(t.prototype[e[n]])})(il,["identify"]);var ym,bv=(ym=so[Ni]=new il,(function(){function t(){t.done||(t.done=!0,Sv=!1,re(so,(function(e){e._dom_loaded()})))}A!=null&&A.addEventListener?A.readyState==="complete"?t():Ee(A,"DOMContentLoaded",t,{capture:!1}):x&&O.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),ym);var sf=class{constructor(e={}){this.options=e;Ze(this,"client");this.client=e.client,!this.client&&typeof window<"u"&&e.apiKey&&(this.client=bv,this.client.init(e.apiKey,{api_host:e.apiHost??"https://posthog-dev.syntrologie.com",autocapture:e.autocapture??!0,capture_pageview:e.capturePageview??!0,capture_pageleave:e.capturePageleave??!0,disable_session_recording:!(e.sessionRecording??!0),session_recording:{recordCrossDomainIFrames:!0},capture_performance:!0,enable_recording_console_log:!0}))}identify(e,n){this.client?.identify(e,n)}alias(e,n){this.client?.alias(e,n)}track(e,n){this.client?.capture(e,n)}trackCanvasOpened(e){this.track("shadow_canvas_opened",{surface:e})}trackCanvasClosed(e){this.track("shadow_canvas_closed",{surface:e})}trackRectangleViewed(e,n){this.track("shadow_canvas_rectangle_viewed",{rectangleId:e,surface:n})}trackAction(e,n,r){this.track("shadow_canvas_action",{action:e,rectangleId:n,surface:r})}};function of(t={}){return new sf(t)}var Tv={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};function uf(){return Tv}function af(t){let e=2166136261,n=t.length;for(let r=0;r<n;r++)e^=t.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function mo(t,e,n){return n===2?af(af(t+e)+"")%1e4/1e4:n===1?af(e+t)%1e3/1e3:null}function gE(t){return t<=0?[]:new Array(t).fill(1/t)}function ll(t,e){return t>=e[0]&&t<e[1]}function Pv(t,e){let n=mo("__"+e[0],t,1);return n===null?!1:n>=e[1]&&n<e[2]}function Rv(t,e){for(let n=0;n<e.length;n++)if(ll(t,e[n]))return n;return-1}function cf(t){try{let e=t.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function ul(t,e){if(!e.length)return!1;let n=!1,r=!1;for(let i=0;i<e.length;i++){let s=yE(t,e[i].type,e[i].pattern);if(e[i].include===!1){if(s)return!1}else n=!0,s&&(r=!0)}return r||!n}function mE(t,e,n){try{let r=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return n&&(r="\\/?"+r.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+r+"$","i").test(t)}catch{return!1}}function vE(t,e){try{let n=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),r=[[t.host,n.host,!1],[t.pathname,n.pathname,!0]];return n.hash&&r.push([t.hash,n.hash,!1]),n.searchParams.forEach((i,s)=>{r.push([t.searchParams.get(s)||"",i,!1])}),!r.some(i=>!mE(i[0],i[1],i[2]))}catch{return!1}}function yE(t,e,n){try{let r=new URL(t,"https://_");if(e==="regex"){let i=cf(n);return i?i.test(r.href)||i.test(r.href.substring(r.origin.length)):!1}else if(e==="simple")return vE(r,n);return!1}catch{return!1}}function Av(t,e,n){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let r=gE(t);n=n||r,n.length!==t&&(n=r);let i=n.reduce((o,a)=>a+o,0);(i<.99||i>1.01)&&(n=r);let s=0;return n.map(o=>{let a=s;return s+=o,[a,a+e*o]})}function Ov(t,e,n){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=>{let[o]=s;return o===t}).map(s=>{let[,o]=s;return parseInt(o)});return i.length>0&&i[0]>=0&&i[0]<n?i[0]:null}function Nv(t){try{return t()}catch(e){return console.error(e),!1}}var lf=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0));async function Hr(t,e,n){if(e=e||"",n=n||globalThis.crypto&&globalThis.crypto.subtle||Tv.SubtleCrypto,!n)throw new Error("No SubtleCrypto implementation found");try{let r=await n.importKey("raw",lf(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[i,s]=t.split("."),o=await n.decrypt({name:"AES-CBC",iv:lf(i)},r,lf(s));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function vo(t){return typeof t=="string"?t:JSON.stringify(t)}function ht(t){typeof t=="number"&&(t=t+""),(!t||typeof t!="string")&&(t="0");let e=t.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(n=>n.match(/^[0-9]+$/)?n.padStart(5," "):n).join("-")}function Fv(){let t;try{t="1.6.2"}catch{t=""}return t}function Lv(t,e){let n,r;try{n=new URL(t),r=new URL(e)}catch(i){return console.error(`Unable to merge query strings: ${i}`),e}return n.searchParams.forEach((i,s)=>{r.searchParams.has(s)||r.searchParams.set(s,i)}),r.toString()}function Cv(t){return typeof t=="object"&&t!==null}function cl(t){return t.urlPatterns&&t.variations.some(e=>Cv(e)&&"urlRedirect"in e)?"redirect":t.variations.some(e=>Cv(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function dl(t,e){return new Promise(n=>{let r=!1,i,s=o=>{r||(r=!0,i&&clearTimeout(i),n(o||null))};e&&(i=setTimeout(()=>s(),e)),t.then(o=>s(o)).catch(()=>s())})}var ze={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},sn=uf(),Br={fetchFeaturesCall:t=>{let{host:e,clientKey:n,headers:r}=t;return sn.fetch(`${e}/api/features/${n}`,{headers:r})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:n,payload:r,headers:i}=t,s={method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(r)};return sn.fetch(`${e}/api/eval/${n}`,s)},eventSourceCall:t=>{let{host:e,clientKey:n,headers:r}=t;return r?new sn.EventSource(`${e}/sub/${n}`,{headers:r}):new sn.EventSource(`${e}/sub/${n}`)},startIdleListener:()=>{let t;if(!(typeof window<"u"&&typeof document<"u"))return;let n=()=>{document.visibilityState==="visible"?(window.clearTimeout(t),kE()):document.visibilityState==="hidden"&&(t=window.setTimeout(wE,ze.idleStreamInterval))};return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(sn.localStorage=globalThis.localStorage)}catch{}var Hi=new Map,Iv=!1,En=new Map,fl=new Map,Bi=new Map,Ui=new Set;function ff(t){Object.assign(ze,t),ze.backgroundSync||vf()}async function $v(t){let{instance:e,timeout:n,skipCache:r,allowStale:i,backgroundSync:s}=t;return s||(ze.backgroundSync=!1),xE({instance:e,allowStale:i,timeout:n,skipCache:r})}function _E(t){let e=yo(t),n=Hi.get(e)||new Set;n.add(t),Hi.set(e,n)}function Dv(t){Hi.forEach(e=>e.delete(t))}function wE(){Bi.forEach(t=>{t&&(t.state="idle",gf(t))})}function kE(){Bi.forEach(t=>{t&&t.state==="idle"&&mf(t)})}async function Mv(){try{if(!sn.localStorage)return;await sn.localStorage.setItem(ze.cacheKey,JSON.stringify(Array.from(En.entries())))}catch{}}async function xE(t){let{instance:e,allowStale:n,timeout:r,skipCache:i}=t,s=yo(e),o=pf(e),a=new Date,l=new Date(a.getTime()-ze.maxAge+ze.staleTTL);await EE();let u=!ze.disableCache&&!i?En.get(o):void 0;return u&&(n||u.staleAt>a)&&u.staleAt>l?(u.sse&&Ui.add(s),u.staleAt<a?df(e):hf(e),{data:u.data,success:!0,source:"cache"}):await dl(df(e),r)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function yo(t){let[e,n]=t.getApiInfo();return`${e}||${n}`}function pf(t){let e=yo(t);if(!("isRemoteEval"in t)||!t.isRemoteEval())return e;let n=t.getAttributes(),r=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),i={};r.forEach(a=>{i[a]=n[a]});let s=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:i,fv:s,url:o})}`}async function EE(){if(!Iv){Iv=!0;try{if(sn.localStorage){let t=await sn.localStorage.getItem(ze.cacheKey);if(!ze.disableCache&&t){let e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach(n=>{let[r,i]=n;En.set(r,{...i,staleAt:new Date(i.staleAt)})}),Vv()}}}catch{}if(!ze.disableIdleStreams){let t=Br.startIdleListener();t&&(Br.stopIdleListener=t)}}}function Vv(){let t=Array.from(En.entries()).map(n=>{let[r,i]=n;return{key:r,staleAt:i.staleAt.getTime()}}).sort((n,r)=>n.staleAt-r.staleAt),e=Math.min(Math.max(0,En.size-ze.maxEntries),En.size);for(let n=0;n<e;n++)En.delete(t[n].key)}function jv(t,e,n){let r=n.dateUpdated||"",i=new Date(Date.now()+ze.staleTTL),s=ze.disableCache?void 0:En.get(e);if(s&&r&&s.version===r){s.staleAt=i,Mv();return}ze.disableCache||(En.set(e,{data:n,version:r,staleAt:i,sse:Ui.has(t)}),Vv()),Mv();let o=Hi.get(t);o&&o.forEach(a=>SE(a,n))}async function SE(t,e){await t.setPayload(e||t.getPayload())}async function df(t){let{apiHost:e,apiRequestHeaders:n}=t.getApiHosts(),r=t.getClientKey(),i="isRemoteEval"in t&&t.isRemoteEval(),s=yo(t),o=pf(t),a=fl.get(o);return a||(a=(i?Br.fetchRemoteEvalCall({host:e,clientKey:r,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:n}):Br.fetchFeaturesCall({host:e,clientKey:r,headers:n})).then(u=>{if(!u.ok)throw new Error(`HTTP error: ${u.status}`);return u.headers.get("x-sse-support")==="enabled"&&Ui.add(s),u.json()}).then(u=>(jv(s,o,u),hf(t),fl.delete(o),{data:u,success:!0,source:"network"})).catch(u=>(fl.delete(o),{data:null,source:"error",success:!1,error:u})),fl.set(o,a)),a}function hf(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=yo(t),r=pf(t),{streamingHost:i,streamingHostRequestHeaders:s}=t.getApiHosts(),o=t.getClientKey();if(e&&Ui.add(n),ze.backgroundSync&&Ui.has(n)&&sn.EventSource){if(Bi.has(n))return;let a={src:null,host:i,clientKey:o,headers:s,cb:l=>{try{if(l.type==="features-updated"){let u=Hi.get(n);u&&u.forEach(c=>{df(c)})}else if(l.type==="features"){let u=JSON.parse(l.data);jv(n,r,u)}a.errors=0}catch{zv(a)}},errors:0,state:"active"};Bi.set(n,a),mf(a)}}function zv(t){if(t.state!=="idle"&&(t.errors++,t.errors>3||t.src&&t.src.readyState===2)){let e=Math.pow(3,t.errors-3)*(1e3+Math.random()*1e3);gf(t),setTimeout(()=>{["idle","active"].includes(t.state)||mf(t)},Math.min(e,3e5))}}function gf(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,t.state==="active"&&(t.state="disabled"))}function mf(t){t.src=Br.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state="active",t.src.addEventListener("features",t.cb),t.src.addEventListener("features-updated",t.cb),t.src.onerror=()=>zv(t),t.src.onopen=()=>{t.errors=0}}function bE(t,e){gf(t),Bi.delete(e)}function vf(){Ui.clear(),Bi.forEach(bE),Hi.clear(),Br.stopIdleListener()}function pl(t,e){if(e.streaming){if(!t.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&hf(t,!0),_E(t)}}var CE=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,wf={revert:function(){}},vl=new Map,kf=new Set;function TE(t){return t==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}function yl(t){var e=vl.get(t);return e||(e={element:t,attributes:{}},vl.set(t,e)),e}function _l(t,e,n,r,i){var s=n(t),o={isDirty:!1,originalValue:s,virtualValue:s,mutations:[],el:t,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=n(t);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:n};return e==="position"&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,TE(e)),o}function wl(t,e){var n=e.getCurrentValue(e.el);e.virtualValue=t,t&&typeof t!="string"?(!n||t.parentNode!==n.parentNode||t.insertBeforeNode!==n.insertBeforeNode)&&(e.isDirty=!0,Hv()):t!==n&&(e.isDirty=!0,Hv())}function PE(t){var e=t.originalValue;t.mutations.forEach(function(n){return e=n.mutate(e)}),wl(HE(e),t)}function RE(t){var e=new Set(t.originalValue.split(/\s+/).filter(Boolean));t.mutations.forEach(function(n){return n.mutate(e)}),wl(Array.from(e).filter(Boolean).join(" "),t)}function AE(t){var e=t.originalValue;t.mutations.forEach(function(n){return e=n.mutate(e)}),wl(e,t)}function OE(t){var e=t.parentSelector,n=t.insertBeforeSelector,r=document.querySelector(e);if(!r)return null;var i=n?document.querySelector(n):null;return n&&!i?null:{parentNode:r,insertBeforeNode:i}}function NE(t){var e=t.originalValue;t.mutations.forEach(function(n){var r=n.mutate(),i=OE(r);e=i||e}),wl(e,t)}var FE=function(e){return e.innerHTML},LE=function(e,n){return e.innerHTML=n};function Uv(t){var e=yl(t);return e.html||(e.html=_l(t,"html",FE,LE,PE)),e.html}var IE=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},ME=function(e,n){n.insertBeforeNode&&!n.parentNode.contains(n.insertBeforeNode)||n.parentNode.insertBefore(e,n.insertBeforeNode)};function Wv(t){var e=yl(t);return e.position||(e.position=_l(t,"position",IE,ME,NE)),e.position}var $E=function(e,n){return n?e.className=n:e.removeAttribute("class")},DE=function(e){return e.className};function qv(t){var e=yl(t);return e.classes||(e.classes=_l(t,"class",DE,$E,RE)),e.classes}var VE=function(e){return function(n){var r;return(r=n.getAttribute(e))!=null?r:null}},jE=function(e){return function(n,r){return r!==null?n.setAttribute(e,r):n.removeAttribute(e)}};function Kv(t,e){var n=yl(t);return n.attributes[e]||(n.attributes[e]=_l(t,e,VE(e),jE(e),AE)),n.attributes[e]}function zE(t,e){var n=vl.get(t);if(n)if(e==="html"){var r,i;(r=n.html)==null||(i=r.observer)==null||i.disconnect(),delete n.html}else if(e==="class"){var s,o;(s=n.classes)==null||(o=s.observer)==null||o.disconnect(),delete n.classes}else if(e==="position"){var a,l;(a=n.position)==null||(l=a.observer)==null||l.disconnect(),delete n.position}else{var u,c,d;(u=n.attributes)==null||(c=u[e])==null||(d=c.observer)==null||d.disconnect(),delete n.attributes[e]}}var hl;function HE(t){return hl||(hl=document.createElement("div")),hl.innerHTML=t,hl.innerHTML}function gl(t,e,n){if(n.isDirty){n.isDirty=!1;var r=n.virtualValue;n.mutations.length||zE(t,e),n.setValue(t,r)}}function BE(t,e){t.html&&gl(e,"html",t.html),t.classes&&gl(e,"class",t.classes),t.position&&gl(e,"position",t.position),Object.keys(t.attributes).forEach(function(n){gl(e,n,t.attributes[n])})}function Hv(){vl.forEach(BE)}function UE(t,e){var n=null;t.kind==="html"?n=Uv(e):t.kind==="class"?n=qv(e):t.kind==="attribute"?n=Kv(e,t.attribute):t.kind==="position"&&(n=Wv(e)),n&&(n.mutations.push(t),n.mutationRunner(n))}function WE(t,e){var n=null;if(t.kind==="html"?n=Uv(e):t.kind==="class"?n=qv(e):t.kind==="attribute"?n=Kv(e,t.attribute):t.kind==="position"&&(n=Wv(e)),!!n){var r=n.mutations.indexOf(t);r!==-1&&n.mutations.splice(r,1),n.mutationRunner(n)}}function Gv(t){if(!(t.kind==="position"&&t.elements.size===1)){var e=new Set(t.elements),n=document.querySelectorAll(t.selector);n.forEach(function(r){e.has(r)||(t.elements.add(r),UE(t,r))})}}function qE(t){t.elements.forEach(function(e){return WE(t,e)}),t.elements.clear(),kf.delete(t)}function Bv(){kf.forEach(Gv)}var yf;function KE(){typeof document>"u"||(yf||(yf=new MutationObserver(function(){Bv()})),Bv(),yf.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}KE();function kl(t){return typeof document>"u"?wf:(kf.add(t),Gv(t),{revert:function(){qE(t)}})}function _f(t,e){return kl({kind:"html",elements:new Set,mutate:e,selector:t})}function Zv(t,e){return kl({kind:"position",elements:new Set,mutate:e,selector:t})}function _o(t,e){return kl({kind:"class",elements:new Set,mutate:e,selector:t})}function ml(t,e,n){return CE.test(e)?e==="class"||e==="className"?_o(t,function(r){var i=n(Array.from(r).join(" "));r.clear(),i&&i.split(/\s+/g).filter(Boolean).forEach(function(s){return r.add(s)})}):kl({kind:"attribute",attribute:e,elements:new Set,mutate:n,selector:t}):wf}function GE(t){var e=t.selector,n=t.action,r=t.value,i=t.attribute,s=t.parentSelector,o=t.insertBeforeSelector;if(i==="html"){if(n==="append")return _f(e,function(a){return a+(r??"")});if(n==="set")return _f(e,function(){return r??""})}else if(i==="class"){if(n==="append")return _o(e,function(a){r&&a.add(r)});if(n==="remove")return _o(e,function(a){r&&a.delete(r)});if(n==="set")return _o(e,function(a){a.clear(),r&&a.add(r)})}else if(i==="position"){if(n==="set"&&s)return Zv(e,function(){return{insertBeforeSelector:o,parentSelector:s}})}else{if(n==="append")return ml(e,i,function(a){return a!==null?a+(r??""):r??""});if(n==="set")return ml(e,i,function(){return r??""});if(n==="remove")return ml(e,i,function(){return null})}return wf}var ZE={html:_f,classes:_o,attribute:ml,position:Zv,declarative:GE},Yv=ZE;var xf={};function tr(t,e,n){n=n||{};for(let[r,i]of Object.entries(e))switch(r){case"$or":if(!Qv(t,i,n))return!1;break;case"$nor":if(Qv(t,i,n))return!1;break;case"$and":if(!tS(t,i,n))return!1;break;case"$not":if(tr(t,i,n))return!1;break;default:if(!wo(i,YE(t,r),n))return!1}return!0}function YE(t,e){let n=e.split("."),r=t;for(let i=0;i<n.length;i++)if(r&&typeof r=="object"&&n[i]in r)r=r[n[i]];else return null;return r}function QE(t){return xf[t]||(xf[t]=new RegExp(t.replace(/([^\\])\//g,"$1\\/"))),xf[t]}function wo(t,e,n){if(typeof t=="string")return e+""===t;if(typeof t=="number")return e*1===t;if(typeof t=="boolean")return e!==null&&!!e===t;if(t===null)return e===null;if(Array.isArray(t)||!Xv(t))return JSON.stringify(e)===JSON.stringify(t);for(let r in t)if(!eS(r,e,t[r],n))return!1;return!0}function Xv(t){let e=Object.keys(t);return e.length>0&&e.filter(n=>n[0]==="$").length===e.length}function XE(t){if(t===null)return"null";if(Array.isArray(t))return"array";let e=typeof t;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function JE(t,e,n){if(!Array.isArray(t))return!1;let r=Xv(e)?i=>wo(e,i,n):i=>tr(i,e,n);for(let i=0;i<t.length;i++)if(t[i]&&r(t[i]))return!0;return!1}function xl(t,e){return Array.isArray(t)?t.some(n=>e.includes(n)):e.includes(t)}function eS(t,e,n,r){switch(t){case"$veq":return ht(e)===ht(n);case"$vne":return ht(e)!==ht(n);case"$vgt":return ht(e)>ht(n);case"$vgte":return ht(e)>=ht(n);case"$vlt":return ht(e)<ht(n);case"$vlte":return ht(e)<=ht(n);case"$eq":return e===n;case"$ne":return e!==n;case"$lt":return e<n;case"$lte":return e<=n;case"$gt":return e>n;case"$gte":return e>=n;case"$exists":return n?e!=null:e==null;case"$in":return Array.isArray(n)?xl(e,n):!1;case"$inGroup":return xl(e,r[n]||[]);case"$notInGroup":return!xl(e,r[n]||[]);case"$nin":return Array.isArray(n)?!xl(e,n):!1;case"$not":return!wo(n,e,r);case"$size":return Array.isArray(e)?wo(n,e.length,r):!1;case"$elemMatch":return JE(e,n,r);case"$all":if(!Array.isArray(e))return!1;for(let i=0;i<n.length;i++){let s=!1;for(let o=0;o<e.length;o++)if(wo(n[i],e[o],r)){s=!0;break}if(!s)return!1}return!0;case"$regex":try{return QE(n).test(e)}catch{return!1}case"$type":return XE(e)===n;default:return console.error("Unknown operator: "+t),!1}}function Qv(t,e,n){if(!e.length)return!0;for(let r=0;r<e.length;r++)if(tr(t,e[r],n))return!0;return!1}function tS(t,e,n){for(let r=0;r<e.length;r++)if(!tr(t,e[r],n))return!1;return!0}var nS="Feature Evaluated",rS="Experiment Viewed";function iS(t){let e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach((n,r)=>e.set(r,n)),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach((n,r)=>e.set(r,n)),e}function sS(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}async function Wi(t){try{await t()}catch{}}function Jv(t,e,n){if(t.user.trackedExperiments){let i=bl(e,n);if(t.user.trackedExperiments.has(i))return[];t.user.trackedExperiments.add(i)}t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({experiment:e,result:n,timestamp:Date.now().toString(),logType:"experiment"});let r=[];if(t.global.trackingCallback){let i=t.global.trackingCallback;r.push(Wi(()=>i(e,n,t.user)))}if(t.user.trackingCallback){let i=t.user.trackingCallback;r.push(Wi(()=>i(e,n)))}if(t.global.eventLogger){let i=t.global.eventLogger;r.push(Wi(()=>i(rS,{experimentId:e.key,variationId:n.key,hashAttribute:n.hashAttribute,hashValue:n.hashValue},t.user)))}return r}function oS(t,e,n){if(t.user.trackedFeatureUsage){let r=JSON.stringify(n.value);if(t.user.trackedFeatureUsage[e]===r)return;t.user.trackedFeatureUsage[e]=r,t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({featureKey:e,result:n,timestamp:Date.now().toString(),logType:"feature"})}if(t.global.onFeatureUsage){let r=t.global.onFeatureUsage;Wi(()=>r(e,n,t.user))}if(t.user.onFeatureUsage){let r=t.user.onFeatureUsage;Wi(()=>r(e,n))}if(t.global.eventLogger){let r=t.global.eventLogger;Wi(()=>r(nS,{feature:e,source:n.source,value:n.value,ruleId:n.source==="defaultValue"?"$default":n.ruleId||"",variationId:n.experimentResult?n.experimentResult.key:""},t.user))}}function El(t,e){if(e.stack.evaluatedFeatures.has(t))return nr(e,t,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(t),e.stack.id=t;let n=iS(e);if(n.has(t))return nr(e,t,n.get(t),"override");if(!e.global.features||!e.global.features[t])return nr(e,t,null,"unknownFeature");let r=e.global.features[t];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 u=El(l.id,e);if(u.source==="cyclicPrerequisite")return nr(e,t,null,"cyclicPrerequisite");let c={value:u.value};if(!tr(c,l.condition||{})){if(l.gate)return nr(e,t,null,"prerequisite");continue e}}if(s.filters&&ny(s.filters,e))continue;if("force"in s){if(s.condition&&!ty(s.condition,e)||!aS(e,s.seed||t,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=>{!Jv(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),nr(e,t,s.force,"force",s.id)}if(!s.variations)continue;let o={variations:s.variations,key:s.key||t};"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}=Sl(o,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return nr(e,t,a.value,"experiment",s.id,o,a)}}return nr(e,t,r.defaultValue===void 0?null:r.defaultValue,"defaultValue")}function Sl(t,e,n){let r=t.key,i=t.variations.length;if(i<2)return{result:de(n,t,-1,!1,e)};if(n.global.enabled===!1||n.user.enabled===!1)return{result:de(n,t,-1,!1,e)};if(t=lS(t,n),t.urlPatterns&&!ul(n.user.url||"",t.urlPatterns))return{result:de(n,t,-1,!1,e)};let s=Ov(r,n.user.url||"",i);if(s!==null)return{result:de(n,t,s,!1,e)};let o=sS(n);if(r in o){let k=o[r];return{result:de(n,t,k,!1,e)}}if(t.status==="draft"||t.active===!1)return{result:de(n,t,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Ur(n,t.hashAttribute,n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!l)return{result:de(n,t,-1,!1,e)};let u=-1,c=!1,d=!1;if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{variation:k,versionIsBlocked:h}=dS({ctx:n,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});c=k>=0,u=k,d=!!h}if(!c){if(t.filters){if(ny(t.filters,n))return{result:de(n,t,-1,!1,e)}}else if(t.namespace&&!Pv(l,t.namespace))return{result:de(n,t,-1,!1,e)};if(t.include&&!Nv(t.include))return{result:de(n,t,-1,!1,e)};if(t.condition&&!ty(t.condition,n))return{result:de(n,t,-1,!1,e)};if(t.parentConditions){let k=new Set(n.stack.evaluatedFeatures);for(let h of t.parentConditions){n.stack.evaluatedFeatures=new Set(k);let p=El(h.id,n);if(p.source==="cyclicPrerequisite")return{result:de(n,t,-1,!1,e)};let m={value:p.value};if(!tr(m,h.condition||{}))return{result:de(n,t,-1,!1,e)}}}if(t.groups&&!cS(t.groups,n))return{result:de(n,t,-1,!1,e)}}if(t.url&&!uS(t.url,n))return{result:de(n,t,-1,!1,e)};let f=mo(t.seed||r,l,t.hashVersion||1);if(f===null)return{result:de(n,t,-1,!1,e)};if(!c){let k=t.ranges||Av(i,t.coverage===void 0?1:t.coverage,t.weights);u=Rv(f,k)}if(d)return{result:de(n,t,-1,!1,e,void 0,!0)};if(u<0)return{result:de(n,t,-1,!1,e)};if("force"in t)return{result:de(n,t,t.force===void 0?-1:t.force,!1,e)};if(n.global.qaMode||n.user.qaMode)return{result:de(n,t,-1,!1,e)};if(t.status==="stopped")return{result:de(n,t,-1,!1,e)};let g=de(n,t,u,!0,e,f,c);if(n.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{changed:k,key:h,doc:p}=pS(n,a,vo(l),{[Ef(t.key,t.bucketVersion)]:g.key});k&&(n.user.stickyBucketAssignmentDocs=n.user.stickyBucketAssignmentDocs||{},n.user.stickyBucketAssignmentDocs[h]=p,n.user.saveStickyBucketAssignmentDoc(p))}let v=Jv(n,t,g);v.length===0&&n.global.saveDeferredTrack&&n.global.saveDeferredTrack({experiment:t,result:g});let y=v.length?v.length===1?v[0]:Promise.all(v).then(()=>{}):void 0;return"changeId"in t&&t.changeId&&n.global.recordChangeId&&n.global.recordChangeId(t.changeId),{result:g,trackingCall:y}}function nr(t,e,n,r,i,s,o){let a={value:n,on:!!n,off:!n,source:r,ruleId:i||""};return s&&(a.experiment=s),o&&(a.experimentResult=o),r!=="override"&&oS(t,e,a),a}function ey(t){return{...t.user.attributes,...t.user.attributeOverrides}}function ty(t,e){return tr(ey(e),t,e.global.savedGroups||{})}function ny(t,e){return t.some(n=>{let{hashValue:r}=Ur(e,n.attribute);if(!r)return!0;let i=mo(n.seed,r,n.hashVersion||2);return i===null?!0:!n.ranges.some(s=>ll(i,s))})}function aS(t,e,n,r,i,s,o){if(!i&&s===void 0)return!0;if(!i&&s===0)return!1;let{hashValue:a}=Ur(t,n,r);if(!a)return!1;let l=mo(e,a,o||1);return l===null?!1:i?ll(l,i):s!==void 0?l<=s:!0}function de(t,e,n,r,i,s,o){let a=!0;(n<0||n>=e.variations.length)&&(n=0,a=!1);let{hashAttribute:l,hashValue:u}=Ur(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),c=e.meta?e.meta[n]:{},d={key:c.key||""+n,featureId:i,inExperiment:a,hashUsed:r,variationId:n,value:e.variations[n],hashAttribute:l,hashValue:u,stickyBucketUsed:!!o};return c.name&&(d.name=c.name),s!==void 0&&(d.bucket=s),c.passthrough&&(d.passthrough=c.passthrough),d}function lS(t,e){let n=t.key,r=e.global.overrides;return r&&r[n]&&(t=Object.assign({},t,r[n]),typeof t.url=="string"&&(t.url=cf(t.url))),t}function Ur(t,e,n){let r=e||"id",i="",s=ey(t);return s[r]&&(i=s[r]),!i&&n&&(s[n]&&(i=s[n]),i&&(r=n)),{hashAttribute:r,hashValue:i}}function uS(t,e){let n=e.user.url;if(!n)return!1;let r=n.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(t.test(n)||t.test(r))}function cS(t,e){let n=e.global.groups||{};for(let r=0;r<t.length;r++)if(n[t[r]])return!0;return!1}function dS(t){let{ctx:e,expKey:n,expBucketVersion:r,expHashAttribute:i,expFallbackAttribute:s,expMinBucketVersion:o,expMeta:a}=t;r=r||0,o=o||0,i=i||"id",a=a||[];let l=Ef(n,r),u=fS(e,i,s);if(o>0)for(let f=0;f<o;f++){let g=Ef(n,f);if(u[g]!==void 0)return{variation:-1,versionIsBlocked:!0}}let c=u[l];if(c===void 0)return{variation:-1};let d=a.findIndex(f=>f.key===c);return d<0?{variation:-1}:{variation:d}}function Ef(t,e){return e=e||0,`${t}__${e}`}function Sf(t,e){return`${t}||${e}`}function fS(t,e,n){if(!t.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:r,hashValue:i}=Ur(t,e),s=Sf(r,vo(i)),{hashAttribute:o,hashValue:a}=Ur(t,n),l=a?Sf(o,vo(a)):null,u={};return l&&t.user.stickyBucketAssignmentDocs[l]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[l].assignments||{}),t.user.stickyBucketAssignmentDocs[s]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[s].assignments||{}),u}function pS(t,e,n,r){let i=Sf(e,n),s=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[i]?t.user.stickyBucketAssignmentDocs[i].assignments||{}:{},o={...s,...r},a=JSON.stringify(s)!==JSON.stringify(o);return{key:i,doc:{attributeName:e,attributeValue:n,assignments:o},changed:a}}function hS(t,e){let n=new Set,r=e&&e.features?e.features:t.global.features||{},i=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(r).forEach(s=>{let o=r[s];if(o.rules)for(let a of o.rules)a.variations&&(n.add(a.hashAttribute||"id"),a.fallbackAttribute&&n.add(a.fallbackAttribute))}),i.map(s=>{n.add(s.hashAttribute||"id"),s.fallbackAttribute&&n.add(s.fallbackAttribute)}),Array.from(n)}async function ry(t,e,n){let r=bf(t,n);return e.getAllAssignments(r)}function bf(t,e){let n={};return hS(t,e).forEach(i=>{let{hashValue:s}=Ur(t,i);n[i]=vo(s)}),n}async function iy(t,e,n){if(t={...t},t.encryptedFeatures){try{t.features=JSON.parse(await Hr(t.encryptedFeatures,e,n))}catch(r){console.error(r)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await Hr(t.encryptedExperiments,e,n))}catch(r){console.error(r)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await Hr(t.encryptedSavedGroups,e,n))}catch(r){console.error(r)}delete t.encryptedSavedGroups}return t}function sy(t){let e=t.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(t.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}function bl(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}var qi=typeof window<"u"&&typeof document<"u",gS=Fv(),Ki=class{constructor(e){if(e=e||{},this.version=gS,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 n=!1;try{n=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(n)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 n=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=r=>n.saveAssignments(r)}if(e.plugins)for(let n of e.plugins)n(this);if(e.features&&(this.ready=!0),qi&&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 n in this._options.stickyBucketAssignmentDocs){let r=this._options.stickyBucketAssignmentDocs[n];r&&this._options.stickyBucketService.saveAssignments(r).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let n=await iy(e,this._options.decryptionKey);this._decryptedPayload=n,await this.refreshStickyBuckets(n),n.features&&(this._options.features=n.features),n.savedGroups&&(this._options.savedGroups=n.savedGroups),n.experiments&&(this._options.experiments=n.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let n=e.payload;if(n.encryptedExperiments||n.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,n)),this._payload=n,this._decryptedPayload=n,n.features&&(this._options.features=n.features),n.experiments&&(this._options.experiments=n.experiments,this._updateAllAutoExperiments()),this.ready=!0,pl(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&ff(e.cacheSettings),e.payload)return await this.setPayload(e.payload),pl(this,e),{success:!0,source:"init"};{let{data:n,...r}=await this._refresh({...e,allowStale:!0});return pl(this,e),await this.setPayload(n||{}),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 n=await this._refresh({...e||{},allowStale:!1});n.data&&await this.setPayload(n.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return sy(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(e){let{timeout:n,skipCache:r,allowStale:i,streaming:s}=e;if(!this._options.clientKey)throw new Error("Missing clientKey");return $v({instance:this,timeout:n,skipCache:r||this._options.disableCache,allowStale:i,backgroundSync:s??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,n,r){let i=await Hr(e,n||this._options.decryptionKey,r);this.setFeatures(JSON.parse(i))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,n,r){let i=await Hr(e,n||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(n=>{try{n()}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,Dv(this),e.destroyAllStreams&&vf(),this.logs=[],qi&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(n=>{n.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,n){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=n,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:n}=Sl(e,null,this._getEvalContext());return this._onExperimentEval(e,n),n}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,n){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=de(this._getEvalContext(),e,-1,!1,""):({result:s,trackingCall:o}=Sl(e,null,this._getEvalContext()),this._onExperimentEval(e,s));let a=JSON.stringify(s.value);if(!n&&s.inExperiment&&r&&r.valueHash===a)return s;if(r&&this._undoActiveAutoExperiment(e),s.inExperiment){let l=cl(e);if(l==="redirect"&&s.value.urlRedirect&&e.urlPatterns){let u=e.persistQueryString?Lv(this._getContextUrl(),s.value.urlRedirect):s.value.urlRedirect;if(ul(u,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),s;this._redirectedUrl=u;let{navigate:c,delay:d}=this._getNavigateFunction();if(c)if(qi)Promise.all([...o?[dl(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(f=>window.setTimeout(f,this._options.navigateDelay??d))]).then(()=>{try{c(u)}catch(f){console.error(f)}});else try{c(u)}catch(f){console.error(f)}}else if(l==="visual"){let u=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(s.value):this._applyDOMChanges(s.value);u&&this._activeAutoExperiments.set(e,{undo:u,valueHash:a})}}return s}_undoActiveAutoExperiment(e){let n=this._activeAutoExperiments.get(e);n&&(n.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let n=this._options.experiments||[],r=new Set(n);this._activeAutoExperiments.forEach((i,s)=>{r.has(s)||(i.undo(),this._activeAutoExperiments.delete(s))});for(let i of n){let s=this._runAutoExperiment(i,e);if(s&&s.inExperiment&&cl(i)==="redirect")break}}_onExperimentEval(e,n){let r=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:n}),this._subscriptions.size>0&&this._fireSubscriptions(e,n,r)}_fireSubscriptions(e,n,r){(!r||r.result.inExperiment!==n.inExperiment||r.result.variationId!==n.variationId)&&this._subscriptions.forEach(i=>{try{i(e,n)}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,n){let r=this.evalFeature(e).value;return r===null?n:r}feature(e){return this.evalFeature(e)}evalFeature(e){return El(e,this._getEvalContext())}log(e,n){this.debug&&(this._options.log?this._options.log(e,n):console.log(e,n))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(n=>n&&n.experiment&&n.result).map(n=>[bl(n.experiment,n.result),n]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(n=>{!n||!n.experiment||!n.result?console.error("Invalid deferred tracking call",{call:n}):e.push(this._options.trackingCallback(n.experiment,n.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,n){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:n,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,n||{},this._getUserContext())}catch(r){console.error(r)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(bl(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(qi?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let n=cl(e);if(n==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(r=>r.js))return!0}else if(n==="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}:qi?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!qi)return;let n=[];if(e.css){let r=document.createElement("style");r.innerHTML=e.css,document.head.appendChild(r),n.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),n.push(()=>r.remove())}return e.domMutations&&e.domMutations.forEach(r=>{n.push(Yv.declarative(r).revert)}),()=>{n.forEach(r=>r())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let n=this._getEvalContext(),r=await ry(n,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=r}}generateStickyBucketAssignmentDocsSync(e,n){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let r=this._getEvalContext(),i=bf(r,n);return e.getAllAssignmentsSync(i)}inDevMode(){return!!this._options.enableDevMode}};var on=ve(bt());function Of(){return Of=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Of.apply(null,arguments)}var NS=on.createContext({});var FS=t=>n=>on.createElement(NS.Consumer,null,({growthbook:r})=>on.createElement(t,Of({},n,{runExperiment:i=>r.run(i)})));FS.displayName="WithRunExperiment";var LS="https://experiment.syntrologie.com",Nf=class{constructor(e={}){Ze(this,"gb");e.client?this.gb=e.client:(this.gb=new Ki({...e,apiHost:e.apiHost??LS}),e.autoInit&&this.gb.init({streaming:!0}))}get _internal(){return this.gb}async refreshFeatures(){await this.gb.loadFeatures()}setAttributes(e){this.gb.setAttributes(e)}getFeatureValue(e,n){return this.gb.getFeatureValue(e,n)}shouldRenderRectangle(e){let n=e.experiment;if(!n||!n.featureKey)return!0;let r=this.gb.getFeatureValue(n.featureKey,null);if(r==null)return!1;if(typeof n.variationId=="number")return Number(r)===n.variationId;if(typeof n.variationValue<"u")return r===n.variationValue;if(n.predicate)try{return n.predicate(r)}catch{return!1}return!!r}};function Ff(t={}){return new Nf(t)}var rr=ve(bt(),1),IS=t=>[...t].sort((e,n)=>(e.order??0)-(n.order??0));function _y({fetcher:t,pollIntervalMs:e=3e4,experiments:n}){let[r,i]=(0,rr.useState)({rectangles:[],isLoading:!0}),s=(0,rr.useCallback)(async()=>{try{i(l=>({...l,isLoading:!0,error:void 0}));let o=await t(),a=o.tiles||o.rectangles||[];n&&(a=a.filter(l=>n.shouldRenderRectangle(l))),i({rectangles:IS(a),isLoading:!1,fetchedAt:o.fetchedAt,canvasTitle:o.canvasTitle,configVersion:o.configVersion,patches:o.patches,overlayRecipe:o.overlayRecipe,displayMode:o.displayMode})}catch(o){i(a=>({...a,isLoading:!1,error:o instanceof Error?o.message:"Unknown error"}))}},[n,t]);return(0,rr.useEffect)(()=>{if(s(),!e)return;let o=setInterval(s,e);return()=>clearInterval(o)},[s,e]),(0,rr.useMemo)(()=>r,[r])}var Wr=ve(bt(),1),G=ve(Vt(),1);function HS({config:t,telemetry:e,surface:n}){let[r,i]=(0,Wr.useState)([{author:"Lumi",text:"Hi! Need clarity on a deduction?"}]),[s,o]=(0,Wr.useState)(""),a=l=>{l.preventDefault(),s.trim()&&(i(u=>[...u,{author:"You",text:s.trim()}]),setTimeout(()=>{i(u=>[...u,{author:"Lumi",text:"I will route that to the experimentation server stub for now."}])},600),e?.trackAction("chatbot_message",t.id,n),o(""))};return(0,G.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem",height:"100%"},children:[(0,G.jsx)("div",{style:{flex:1,overflowY:"auto",padding:"0.75rem",background:"rgba(0, 0, 0, 0.2)",borderRadius:"8px",fontSize:"0.85rem"},children:r.map((l,u)=>(0,G.jsxs)("p",{style:{margin:"0 0 0.5rem"},children:[(0,G.jsxs)("span",{style:{fontWeight:600,color:"#94a3b8"},children:[l.author,":"]})," ",(0,G.jsx)("span",{style:{color:"#e2e8f0"},children:l.text})]},`${l.author}-${u}`))}),(0,G.jsxs)("form",{onSubmit:a,style:{display:"flex",gap:"0.5rem"},children:[(0,G.jsx)("input",{style:{flex:1,padding:"0.5rem 0.75rem",borderRadius:"6px",border:"1px solid rgba(255, 255, 255, 0.1)",background:"rgba(0, 0, 0, 0.3)",color:"#f1f5f9",fontSize:"0.85rem",outline:"none"},value:s,onChange:l=>o(l.target.value),placeholder:"Ask anything..."}),(0,G.jsx)("button",{style:{padding:"0.5rem 0.75rem",borderRadius:"6px",border:"none",background:"#6366f1",color:"white",fontWeight:600,fontSize:"0.8rem",cursor:"pointer"},type:"submit",children:"Send"})]})]})}function BS({renderer:t,config:e,surface:n,telemetry:r,isExpanded:i}){let s=(0,Wr.useRef)(null);return(0,Wr.useEffect)(()=>{if(!s.current)return;let o=t.mount(s.current,{config:e,surface:n,telemetry:r,isExpanded:i});return()=>{o&&o()}},[t,e,n,r,i]),(0,G.jsx)("div",{ref:s,style:{width:"100%",height:"100%"}})}function xo({config:t,surface:e,telemetry:n,style:r,customRenderers:i,isExpanded:s=!1,onToggleExpand:o}){let{title:a,subtitle:l,content:u,style:c}=t,d=c?.accentColor??"#6366f1",f="72px",g={display:"flex",flexDirection:"column",borderRadius:"14px",background:c?.background??"rgba(28, 28, 30, 0.95)",border:"1px solid rgba(255, 255, 255, 0.08)",boxShadow:"0 2px 12px rgba(0, 0, 0, 0.3)",color:c?.textColor??"#f5f5f7",fontFamily:"-apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif",overflow:"hidden",cursor:o?"pointer":"default",transition:"all 0.25s ease",...r},v={display:"flex",alignItems:"center",gap:"0.75rem",padding:"0.875rem 1rem",minHeight:f},y={width:"40px",height:"40px",borderRadius:"10px",background:`linear-gradient(135deg, ${d} 0%, ${d}cc 100%)`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"1.25rem",flexShrink:0,boxShadow:`0 2px 8px ${d}40`},k=()=>{switch(u.type){case"chatbot":return"\u{1F4AC}";case"metric":return"\u{1F4CA}";case"embed":return"\u{1F517}";case"custom":return"\u2699\uFE0F";default:return"\u{1F4C4}"}},h=()=>{switch(u.type){case"metric":return`${u.metricValue}${u.metricUnit?` ${u.metricUnit}`:""}`;case"text":return u.headline||u.body?.slice(0,50)||"";case"chatbot":return"Tap to chat";case"embed":return"Tap to view";case"custom":return"Tap to expand";default:return""}},p=()=>{switch(u.type){case"chatbot":return(0,G.jsx)("div",{style:{height:"200px"},children:(0,G.jsx)(HS,{config:t,surface:e,telemetry:n})});case"metric":return(0,G.jsxs)("div",{style:{textAlign:"center",padding:"0.5rem 0"},children:[(0,G.jsxs)("p",{style:{fontSize:"3rem",fontWeight:700,color:d,margin:0,letterSpacing:"-0.02em"},children:[u.metricValue,u.metricUnit&&(0,G.jsx)("span",{style:{fontSize:"1.25rem",fontWeight:400,color:"#8e8e93",marginLeft:"0.5rem"},children:u.metricUnit})]}),u.headline&&(0,G.jsx)("p",{style:{fontSize:"0.85rem",color:"#8e8e93",margin:"0.5rem 0 0"},children:u.headline})]});case"embed":return u.embedUrl?(0,G.jsx)("iframe",{src:u.embedUrl,sandbox:"allow-scripts allow-same-origin",referrerPolicy:"no-referrer",style:{width:"100%",height:"200px",borderRadius:"8px",border:"1px solid rgba(255, 255, 255, 0.1)",background:"rgba(0, 0, 0, 0.2)"},title:u.headline??t.title}):null;case"custom":{let m=u.component||u.customRendererKey;return!m||!i||!i[m]?(0,G.jsxs)("div",{style:{color:"#ff6b6b",fontSize:"0.85rem",padding:"0.5rem 0"},children:["Unknown component: ",m]}):(0,G.jsx)(BS,{renderer:i[m],config:t,surface:e,telemetry:n,isExpanded:s})}case"text":default:return(0,G.jsxs)("div",{style:{padding:"0.25rem 0"},children:[u.headline&&(0,G.jsx)("p",{style:{fontSize:"1rem",fontWeight:600,color:"#f5f5f7",margin:"0 0 0.5rem"},children:u.headline}),u.body&&(0,G.jsx)("p",{style:{fontSize:"0.9rem",color:"#8e8e93",margin:0,lineHeight:1.5},children:u.body})]})}};return(0,G.jsxs)("article",{"data-shadow-canvas-id":`rectangle-${t.id}`,style:g,onClick:m=>{s&&m.target.closest("[data-expanded-content]")||o?.()},children:[(0,G.jsxs)("div",{style:v,children:[(0,G.jsx)("div",{style:y,children:k()}),(0,G.jsxs)("div",{style:{flex:1,minWidth:0},children:[l&&(0,G.jsx)("p",{style:{fontSize:"0.7rem",textTransform:"uppercase",letterSpacing:"0.05em",color:"#8e8e93",margin:0},children:l}),(0,G.jsx)("h3",{style:{fontSize:"0.95rem",fontWeight:600,color:"#f5f5f7",margin:"0.125rem 0 0",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:a}),!s&&(0,G.jsx)("p",{style:{fontSize:"0.8rem",color:"#8e8e93",margin:"0.125rem 0 0",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:h()})]}),(0,G.jsx)("div",{style:{color:"#8e8e93",fontSize:"0.85rem",transform:s?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:"\u25BC"})]}),s&&(0,G.jsxs)("div",{"data-expanded-content":!0,style:{padding:"0 1rem 1rem",borderTop:"1px solid rgba(255, 255, 255, 0.06)"},onClick:m=>m.stopPropagation(),children:[(0,G.jsx)("div",{style:{paddingTop:"0.875rem"},children:p()}),u.actions&&u.actions.length>0&&(0,G.jsx)("div",{style:{marginTop:"1rem",paddingTop:"0.75rem",borderTop:"1px solid rgba(255, 255, 255, 0.06)",display:"flex",gap:"0.5rem"},children:u.actions.map((m,_)=>(0,G.jsx)("button",{onClick:w=>{w.stopPropagation(),m.href&&typeof window<"u"&&window.open(m.href,"_blank","noreferrer"),m.onClickId&&n?.trackAction(m.onClickId,t.id,e)},style:{flex:1,padding:"0.625rem 1rem",borderRadius:"8px",fontSize:"0.85rem",fontWeight:600,cursor:"pointer",border:"none",background:_===0?d:"rgba(255, 255, 255, 0.1)",color:"#fff",transition:"opacity 0.15s ease"},onMouseEnter:w=>{w.currentTarget.style.opacity="0.85"},onMouseLeave:w=>{w.currentTarget.style.opacity="1"},children:m.label},m.label))})]})]})}var Ss=ve(bt(),1),Kh=ve(Zu(),1);var ae=ve(Vt(),1),qC={position:"right",baseWidth:"clamp(320px, 16.666vw, 420px)",expandedWidth:"40vw",zIndex:2147483600,backdropBlur:"18px"};function zw({isOpen:t,onToggle:e,telemetry:n,launcherLabel:r="Canvas",footerSlot:i,rectangles:s,isLoading:o,error:a,canvasTitle:l,displayMode:u="standard",theme:c,customRenderers:d}){let[f,g]=(0,Ss.useState)(!1),[v,y]=(0,Ss.useState)(null),k={...qC,...c},h=E=>{y(v===E?null:E)};(0,Ss.useEffect)(()=>{!t||!n||s.forEach(E=>{n.trackRectangleViewed(E.id,"overlay")})},[n,t,s]),(0,Ss.useEffect)(()=>{g(!0)},[]);let p=()=>{!t?n?.trackCanvasOpened("overlay"):n?.trackCanvasClosed("overlay"),e()},m=u==="focused",_=k.position==="right",w={display:"flex",flexDirection:"column",width:m?k.expandedWidth:k.baseWidth,minWidth:"320px",height:"100%",maxHeight:"100%",background:m?"linear-gradient(to top right, rgba(80, 10, 20, 0.5) 0%, rgba(12, 12, 12, 0.98) 50%, rgba(8, 8, 8, 0.99) 100%)":"linear-gradient(to top right, rgba(60, 8, 15, 0.6) 0%, rgba(12, 12, 12, 0.95) 45%, rgba(8, 8, 8, 0.97) 100%)",backdropFilter:`blur(${k.backdropBlur})`,WebkitBackdropFilter:`blur(${k.backdropBlur})`,pointerEvents:"auto",opacity:t?1:.8,transition:"all 340ms cubic-bezier(0.16, 1, 0.3, 1)",border:m?_?void 0:"1px solid rgba(255, 255, 255, 0.06)":"1px solid rgba(80, 20, 30, 0.4)",borderLeft:m&&_?"1px solid rgba(255, 255, 255, 0.08)":void 0,borderRight:m&&!_?"1px solid rgba(255, 255, 255, 0.08)":void 0,borderRadius:m?"0":"24px",boxShadow:m?"none":"0 25px 80px rgba(0, 0, 0, 0.7), inset 0 0 80px rgba(60, 8, 15, 0.15)",transform:t?"translateX(0)":_?"translateX(120%)":"translateX(-120%)"},b={position:"absolute",inset:0,display:"flex",flexDirection:_?"row-reverse":"row",alignItems:"stretch",pointerEvents:"none",padding:m?"0":"1rem"},S=(0,ae.jsx)("div",{"data-shadow-canvas-id":"overlay-root",style:{position:"fixed",inset:0,pointerEvents:t?"auto":"none",zIndex:k.zIndex},children:(0,ae.jsxs)("div",{style:b,children:[(0,ae.jsxs)("div",{style:w,children:[!m&&(0,ae.jsx)("header",{style:{color:"white",padding:"1.5rem 1.5rem 0"},children:(0,ae.jsx)("p",{style:{margin:0,fontSize:"0.7rem",textTransform:"uppercase",letterSpacing:"0.5em",color:"rgba(255, 255, 255, 0.6)"},children:l??"Smart Canvas"})}),(0,ae.jsx)("div",{style:{flex:1,overflowY:"auto",padding:m?"0":"1.5rem"},children:o?(0,ae.jsx)("div",{style:{color:"rgba(255, 255, 255, 0.85)",padding:m?"1rem":"0"},children:"Loading..."}):a?(0,ae.jsxs)("div",{style:{color:"#fecdd3",padding:m?"1rem":"0"},children:["Failed to load: ",a]}):m?s.length>0?(0,ae.jsx)(xo,{config:s[0],surface:"overlay",telemetry:n,customRenderers:d,isExpanded:!0,onToggleExpand:()=>{},style:{width:"100%",height:"100%"}}):null:(0,ae.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:"0.625rem",width:"100%"},children:s.map(E=>{let j=(E.size??"half")==="quarter"||E.size==="half",F=v===E.id;return(0,ae.jsx)("div",{style:{gridColumn:j&&!F?"span 1":"span 2",transition:"all 0.25s ease"},children:(0,ae.jsx)(xo,{config:E,surface:"overlay",telemetry:n,customRenderers:d,isExpanded:F,onToggleExpand:()=>h(E.id),style:{width:"100%"}})},E.id)})})}),i]}),(0,ae.jsx)("div",{onClick:p,style:{flex:"1 1 auto",pointerEvents:t?"auto":"none",cursor:"default"}})]})});return f?(0,ae.jsxs)(ae.Fragment,{children:[(0,Kh.createPortal)((0,ae.jsx)("div",{"data-shadow-canvas-id":"overlay-launcher",style:{position:"fixed",inset:0,pointerEvents:"none",zIndex:k.zIndex+47},children:(0,ae.jsxs)("button",{onClick:p,"aria-label":"Toggle shadow canvas",style:{position:"fixed",bottom:"2.5rem",right:_?"2.5rem":void 0,left:_?void 0:"2.5rem",pointerEvents:"auto",display:"flex",alignItems:"center",gap:"0.75rem",borderRadius:"18px",color:"white",boxShadow:"0 20px 45px rgba(15, 23, 42, 0.35)",transition:"transform 0.2s ease",outline:"none",padding:"0.65rem 1.25rem",border:"2px solid rgba(255, 255, 255, 0.25)",backgroundColor:"rgba(2, 6, 23, 0.8)",backdropFilter:"blur(12px)",cursor:"pointer"},onMouseEnter:E=>E.currentTarget.style.transform="translateY(-2px)",onMouseLeave:E=>E.currentTarget.style.transform="translateY(0)",children:[(0,ae.jsx)("div",{style:{width:"36px",height:"36px",borderRadius:"12px",background:t?"linear-gradient(135deg, #f472b6, #ec4899)":"linear-gradient(135deg, #94a3b8, #0f172a)",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,ae.jsx)("span",{style:{width:"14px",height:"2px",backgroundColor:"#fff",display:"block",transform:t?"rotate(45deg)":"rotate(0)",position:"relative",transition:"transform 200ms ease"},children:t?null:(0,ae.jsx)("span",{style:{position:"absolute",top:0,left:0,width:"14px",height:"2px",backgroundColor:"#fff",transform:"rotate(90deg)"}})})}),(0,ae.jsxs)("div",{style:{display:"flex",flexDirection:"column",textAlign:"left"},children:[(0,ae.jsx)("span",{style:{fontSize:"0.55rem",letterSpacing:"0.35em",color:"rgba(255,255,255,0.7)"},children:t?"Hide":"Open"}),(0,ae.jsx)("span",{style:{fontSize:"0.85rem",letterSpacing:"0.25em"},children:r})]})]})}),document.body),t?(0,Kh.createPortal)(S,document.body):null]}):null}var Cr=ve(bt(),1);var br=ve(Vt(),1);function hA({rectangles:t,intervalMs:e=7e3,telemetry:n}){let[r,i]=(0,Cr.useState)(0),s=(0,Cr.useMemo)(()=>[...t].filter(o=>o.size!=="quarter").sort((o,a)=>(o.order??0)-(a.order??0)),[t]);return(0,Cr.useEffect)(()=>{n?.trackCanvasOpened("wheel")},[n]),(0,Cr.useEffect)(()=>{if(s.length<=1)return;let o=setInterval(()=>{i(a=>(a+1)%s.length)},e);return()=>clearInterval(o)},[s,e]),(0,Cr.useEffect)(()=>{let o=s[r];o&&n?.trackRectangleViewed(o.id,"wheel")},[r,s,n]),s.length?(0,br.jsxs)("div",{className:"relative overflow-hidden rounded-3xl border border-slate-200 bg-gradient-to-br from-white to-slate-50 p-6 shadow-2xl","data-shadow-canvas-id":"wheel",children:[(0,br.jsx)("div",{className:"flex transition-transform duration-700 ease-out",style:{transform:`translateX(-${r*100}%)`,width:`${s.length*100}%`},children:s.map(o=>(0,br.jsx)("div",{className:"w-full shrink-0 px-4",children:(0,br.jsx)(xo,{config:{...o,size:"half"},surface:"wheel",telemetry:n})},o.id))}),(0,br.jsx)("div",{className:"mt-4 flex justify-center gap-2",children:s.map((o,a)=>(0,br.jsx)("button",{className:`h-2 w-6 rounded-full ${a===r?"bg-slate-800":"bg-slate-300"}`,onClick:()=>i(a)},o.id))})]}):null}var Gh=class{constructor(e){Ze(this,"state");Ze(this,"listeners",new Set);this.state={open:e?.open??!1}}getState(){return this.state}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOpen(e){this.state.open!==e&&(this.state={...this.state,open:e},this.emit())}toggle(){this.setOpen(!this.state.open)}emit(){for(let e of this.listeners)e(this.state)}},Hw=t=>new Gh(t);var Fr=ve(bt(),1);var KC=["api.syntrologie.com","cdn.syntrologie.com","localhost","127.0.0.1"];function GC(t){try{let e=new URL(t),n=/^(localhost|127\.0\.0\.1)$/.test(e.hostname);return e.protocol!=="https:"&&!n?(console.warn("[SmartCanvas] Config URI must use HTTPS:",t),!1):KC.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:",t),!1}}function ZC(t){if(typeof window>"u")return!1;try{return new URL(t).origin===window.location.origin}catch{return!1}}var Zh=({configUri:t,experiments:e,featureKey:n="smart-canvas-config-uri"})=>{if(t)return t;let r=e?.getFeatureValue?.(n,null);if(r)return r},bs=({configUri:t,experiments:e,featureKey:n,credentials:r,configFeatureKey:i="smart-canvas-config"})=>async()=>{if(e&&i){let l=e.getFeatureValue?.(i,null);if(l&&typeof l=="object")return l}let s=Zh({configUri:t,experiments:e,featureKey:n});if(!s)throw new Error("SmartCanvas: config URI missing (env + feature flag unset).");if(!GC(s))throw new Error(`SmartCanvas: config URI not allowed: ${s}`);let o=r??(ZC(s)?"include":"omit"),a=await fetch(s,{credentials:o});if(!a.ok)throw new Error(`SmartCanvas: failed to fetch config (${a.status})`);return await a.json()};var pc=ve(bt(),1);var $={};xg($,{BRAND:()=>kT,DIRTY:()=>ai,EMPTY_PATH:()=>JC,INVALID:()=>D,NEVER:()=>sP,OK:()=>Ke,ParseStatus:()=>je,Schema:()=>B,ZodAny:()=>Rr,ZodArray:()=>$n,ZodBigInt:()=>ui,ZodBoolean:()=>ci,ZodBranded:()=>ga,ZodCatch:()=>ki,ZodDate:()=>di,ZodDefault:()=>wi,ZodDiscriminatedUnion:()=>Xu,ZodEffects:()=>It,ZodEnum:()=>yi,ZodError:()=>ut,ZodFirstPartyTypeKind:()=>V,ZodFunction:()=>ec,ZodIntersection:()=>gi,ZodIssueCode:()=>C,ZodLazy:()=>mi,ZodLiteral:()=>vi,ZodMap:()=>Os,ZodNaN:()=>Fs,ZodNativeEnum:()=>_i,ZodNever:()=>Gt,ZodNull:()=>pi,ZodNullable:()=>gn,ZodNumber:()=>li,ZodObject:()=>ct,ZodOptional:()=>Ft,ZodParsedType:()=>N,ZodPipeline:()=>ma,ZodPromise:()=>Ar,ZodReadonly:()=>xi,ZodRecord:()=>Ju,ZodSchema:()=>B,ZodSet:()=>Ns,ZodString:()=>Pr,ZodSymbol:()=>Rs,ZodTransformer:()=>It,ZodTuple:()=>hn,ZodType:()=>B,ZodUndefined:()=>fi,ZodUnion:()=>hi,ZodUnknown:()=>Mn,ZodVoid:()=>As,addIssueToContext:()=>P,any:()=>AT,array:()=>LT,bigint:()=>bT,boolean:()=>Jw,coerce:()=>iP,custom:()=>Yw,date:()=>CT,datetimeRegex:()=>Gw,defaultErrorMap:()=>Ln,discriminatedUnion:()=>DT,effect:()=>YT,enum:()=>KT,function:()=>UT,getErrorMap:()=>Cs,getParsedType:()=>pn,instanceof:()=>ET,intersection:()=>VT,isAborted:()=>Yu,isAsync:()=>Ts,isDirty:()=>Qu,isValid:()=>Tr,late:()=>xT,lazy:()=>WT,literal:()=>qT,makeIssue:()=>ha,map:()=>HT,nan:()=>ST,nativeEnum:()=>GT,never:()=>NT,null:()=>RT,nullable:()=>XT,number:()=>Xw,object:()=>IT,objectUtil:()=>Yh,oboolean:()=>rP,onumber:()=>nP,optional:()=>QT,ostring:()=>tP,pipeline:()=>eP,preprocess:()=>JT,promise:()=>ZT,quotelessJson:()=>YC,record:()=>zT,set:()=>BT,setErrorMap:()=>XC,strictObject:()=>MT,string:()=>Qw,symbol:()=>TT,transformer:()=>YT,tuple:()=>jT,undefined:()=>PT,union:()=>$T,unknown:()=>OT,util:()=>q,void:()=>FT});var q;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{let s={};for(let o of i)s[o]=o;return s},t.getValidEnumValues=i=>{let s=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(let a of s)o[a]=i[a];return t.objectValues(o)},t.objectValues=i=>t.objectKeys(i).map(function(s){return i[s]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},t.find=(i,s)=>{for(let o of i)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(q||(q={}));var Yh;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Yh||(Yh={}));var N=q.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),pn=t=>{switch(typeof t){case"undefined":return N.undefined;case"string":return N.string;case"number":return Number.isNaN(t)?N.nan:N.number;case"boolean":return N.boolean;case"function":return N.function;case"bigint":return N.bigint;case"symbol":return N.symbol;case"object":return Array.isArray(t)?N.array:t===null?N.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?N.promise:typeof Map<"u"&&t instanceof Map?N.map:typeof Set<"u"&&t instanceof Set?N.set:typeof Date<"u"&&t instanceof Date?N.date:N.object;default:return N.unknown}};var C=q.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),YC=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),ut=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){let n=e||function(s){return s.message},r={_errors:[]},i=s=>{for(let o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){let u=o.path[l];l===o.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(n(o))):a[u]=a[u]||{_errors:[]},a=a[u],l++}}};return i(this),r}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,q.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n={},r=[];for(let i of this.issues)if(i.path.length>0){let s=i.path[0];n[s]=n[s]||[],n[s].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};ut.create=t=>new ut(t);var QC=(t,e)=>{let n;switch(t.code){case C.invalid_type:t.received===N.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case C.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,q.jsonStringifyReplacer)}`;break;case C.unrecognized_keys:n=`Unrecognized key(s) in object: ${q.joinValues(t.keys,", ")}`;break;case C.invalid_union:n="Invalid input";break;case C.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${q.joinValues(t.options)}`;break;case C.invalid_enum_value:n=`Invalid enum value. Expected ${q.joinValues(t.options)}, received '${t.received}'`;break;case C.invalid_arguments:n="Invalid function arguments";break;case C.invalid_return_type:n="Invalid function return type";break;case C.invalid_date:n="Invalid date";break;case C.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:q.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case C.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case C.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case C.custom:n="Invalid input";break;case C.invalid_intersection_types:n="Intersection results could not be merged";break;case C.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case C.not_finite:n="Number must be finite";break;default:n=e.defaultError,q.assertNever(t)}return{message:n}},Ln=QC;var Bw=Ln;function XC(t){Bw=t}function Cs(){return Bw}var ha=t=>{let{data:e,path:n,errorMaps:r,issueData:i}=t,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="",l=r.filter(u=>!!u).slice().reverse();for(let u of l)a=u(o,{data:e,defaultError:a}).message;return{...i,path:s,message:a}},JC=[];function P(t,e){let n=Cs(),r=ha({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Ln?void 0:Ln].filter(i=>!!i)});t.common.issues.push(r)}var je=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){let r=[];for(let i of n){if(i.status==="aborted")return D;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){let r=[];for(let i of n){let s=await i.key,o=await i.value;r.push({key:s,value:o})}return t.mergeObjectSync(e,r)}static mergeObjectSync(e,n){let r={};for(let i of n){let{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return D;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}},D=Object.freeze({status:"aborted"}),ai=t=>({status:"dirty",value:t}),Ke=t=>({status:"valid",value:t}),Yu=t=>t.status==="aborted",Qu=t=>t.status==="dirty",Tr=t=>t.status==="valid",Ts=t=>typeof Promise<"u"&&t instanceof Promise;var M;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(M||(M={}));var Lt=class{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Uw=(t,e)=>{if(Tr(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new ut(t.common.issues);return this._error=n,this._error}}};function H(t){if(!t)return{};let{errorMap:e,invalid_type_error:n,required_error:r,description:i}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,a)=>{let{message:l}=t;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}var B=class{get description(){return this._def.description}_getType(e){return pn(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:pn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new je,ctx:{common:e.parent.common,data:e.data,parsedType:pn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let n=this._parse(e);if(Ts(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){let n=this._parse(e);return Promise.resolve(n)}parse(e,n){let r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){let r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pn(e)},i=this._parseSync({data:e,path:r.path,parent:r});return Uw(r,i)}"~validate"(e){let n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pn(e)};if(!this["~standard"].async)try{let r=this._parseSync({data:e,path:[],parent:n});return Tr(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>Tr(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){let r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){let r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:pn(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(Ts(i)?i:Promise.resolve(i));return Uw(r,s)}refine(e,n){let r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{let o=e(i),a=()=>s.addIssue({code:C.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new It({schema:this,typeName:V.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ft.create(this,this._def)}nullable(){return gn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $n.create(this)}promise(){return Ar.create(this,this._def)}or(e){return hi.create([this,e],this._def)}and(e){return gi.create(this,e,this._def)}transform(e){return new It({...H(this._def),schema:this,typeName:V.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let n=typeof e=="function"?e:()=>e;return new wi({...H(this._def),innerType:this,defaultValue:n,typeName:V.ZodDefault})}brand(){return new ga({typeName:V.ZodBranded,type:this,...H(this._def)})}catch(e){let n=typeof e=="function"?e:()=>e;return new ki({...H(this._def),innerType:this,catchValue:n,typeName:V.ZodCatch})}describe(e){let n=this.constructor;return new n({...this._def,description:e})}pipe(e){return ma.create(this,e)}readonly(){return xi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},eT=/^c[^\s-]{8,}$/i,tT=/^[0-9a-z]+$/,nT=/^[0-9A-HJKMNP-TV-Z]{26}$/i,rT=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,iT=/^[a-z0-9_-]{21}$/i,sT=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,oT=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,aT=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,lT="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Qh,uT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,cT=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,dT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,fT=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pT=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,hT=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,qw="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",gT=new RegExp(`^${qw}$`);function Kw(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function mT(t){return new RegExp(`^${Kw(t)}$`)}function Gw(t){let e=`${qw}T${Kw(t)}`,n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function vT(t,e){return!!((e==="v4"||!e)&&uT.test(t)||(e==="v6"||!e)&&dT.test(t))}function yT(t,e){if(!sT.test(t))return!1;try{let[n]=t.split(".");if(!n)return!1;let r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function _T(t,e){return!!((e==="v4"||!e)&&cT.test(t)||(e==="v6"||!e)&&fT.test(t))}var Pr=class t extends B{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==N.string){let s=this._getOrReturnCtx(e);return P(s,{code:C.invalid_type,expected:N.string,received:s.parsedType}),D}let r=new je,i;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),P(i,{code:C.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),P(i,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){let o=e.data.length>s.value,a=e.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(e,i),o?P(i,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&P(i,{code:C.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")aT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"email",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Qh||(Qh=new RegExp(lT,"u")),Qh.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"emoji",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")rT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"uuid",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")iT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"nanoid",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")eT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"cuid",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")tT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"cuid2",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")nT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"ulid",code:C.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),P(i,{validation:"url",code:C.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"regex",code:C.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?Gw(s).test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?gT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?mT(s).test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{code:C.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?oT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"duration",code:C.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?vT(e.data,s.version)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"ip",code:C.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?yT(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"jwt",code:C.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?_T(e.data,s.version)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"cidr",code:C.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?pT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"base64",code:C.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?hT.test(e.data)||(i=this._getOrReturnCtx(e,i),P(i,{validation:"base64url",code:C.invalid_string,message:s.message}),r.dirty()):q.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:C.invalid_string,...M.errToObj(r)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...M.errToObj(e)})}url(e){return this._addCheck({kind:"url",...M.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...M.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...M.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...M.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...M.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...M.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...M.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...M.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...M.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...M.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...M.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...M.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...M.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...M.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...M.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...M.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...M.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...M.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...M.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...M.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...M.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...M.errToObj(n)})}nonempty(e){return this.min(1,M.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Pr.create=t=>new Pr({checks:[],typeName:V.ZodString,coerce:t?.coerce??!1,...H(t)});function wT(t,e){let n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(t.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return s%o/10**i}var li=class t extends B{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==N.number){let s=this._getOrReturnCtx(e);return P(s,{code:C.invalid_type,expected:N.number,received:s.parsedType}),D}let r,i=new je;for(let s of this._def.checks)s.kind==="int"?q.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),P(r,{code:C.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?wT(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),P(r,{code:C.not_finite,message:s.message}),i.dirty()):q.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,M.toString(n))}gt(e,n){return this.setLimit("min",e,!1,M.toString(n))}lte(e,n){return this.setLimit("max",e,!0,M.toString(n))}lt(e,n){return this.setLimit("max",e,!1,M.toString(n))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:M.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:M.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:M.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:M.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:M.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:M.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:M.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:M.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:M.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:M.toString(e)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&q.isInteger(e.value))}get isFinite(){let e=null,n=null;for(let r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};li.create=t=>new li({checks:[],typeName:V.ZodNumber,coerce:t?.coerce||!1,...H(t)});var ui=class t extends B{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==N.bigint)return this._getInvalidInput(e);let r,i=new je;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),P(r,{code:C.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):q.assertNever(s);return{status:i.value,value:e.data}}_getInvalidInput(e){let n=this._getOrReturnCtx(e);return P(n,{code:C.invalid_type,expected:N.bigint,received:n.parsedType}),D}gte(e,n){return this.setLimit("min",e,!0,M.toString(n))}gt(e,n){return this.setLimit("min",e,!1,M.toString(n))}lte(e,n){return this.setLimit("max",e,!0,M.toString(n))}lt(e,n){return this.setLimit("max",e,!1,M.toString(n))}setLimit(e,n,r,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:M.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:M.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:M.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:M.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:M.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:M.toString(n)})}get minValue(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ui.create=t=>new ui({checks:[],typeName:V.ZodBigInt,coerce:t?.coerce??!1,...H(t)});var ci=class extends B{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==N.boolean){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.boolean,received:r.parsedType}),D}return Ke(e.data)}};ci.create=t=>new ci({typeName:V.ZodBoolean,coerce:t?.coerce||!1,...H(t)});var di=class t extends B{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==N.date){let s=this._getOrReturnCtx(e);return P(s,{code:C.invalid_type,expected:N.date,received:s.parsedType}),D}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return P(s,{code:C.invalid_date}),D}let r=new je,i;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),P(i,{code:C.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),P(i,{code:C.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):q.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:M.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:M.toString(n)})}get minDate(){let e=null;for(let n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};di.create=t=>new di({checks:[],coerce:t?.coerce||!1,typeName:V.ZodDate,...H(t)});var Rs=class extends B{_parse(e){if(this._getType(e)!==N.symbol){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.symbol,received:r.parsedType}),D}return Ke(e.data)}};Rs.create=t=>new Rs({typeName:V.ZodSymbol,...H(t)});var fi=class extends B{_parse(e){if(this._getType(e)!==N.undefined){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.undefined,received:r.parsedType}),D}return Ke(e.data)}};fi.create=t=>new fi({typeName:V.ZodUndefined,...H(t)});var pi=class extends B{_parse(e){if(this._getType(e)!==N.null){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.null,received:r.parsedType}),D}return Ke(e.data)}};pi.create=t=>new pi({typeName:V.ZodNull,...H(t)});var Rr=class extends B{constructor(){super(...arguments),this._any=!0}_parse(e){return Ke(e.data)}};Rr.create=t=>new Rr({typeName:V.ZodAny,...H(t)});var Mn=class extends B{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ke(e.data)}};Mn.create=t=>new Mn({typeName:V.ZodUnknown,...H(t)});var Gt=class extends B{_parse(e){let n=this._getOrReturnCtx(e);return P(n,{code:C.invalid_type,expected:N.never,received:n.parsedType}),D}};Gt.create=t=>new Gt({typeName:V.ZodNever,...H(t)});var As=class extends B{_parse(e){if(this._getType(e)!==N.undefined){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.void,received:r.parsedType}),D}return Ke(e.data)}};As.create=t=>new As({typeName:V.ZodVoid,...H(t)});var $n=class t extends B{_parse(e){let{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==N.array)return P(n,{code:C.invalid_type,expected:N.array,received:n.parsedType}),D;if(i.exactLength!==null){let o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(P(n,{code:o?C.too_big:C.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(P(n,{code:C.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(P(n,{code:C.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new Lt(n,o,n.path,a)))).then(o=>je.mergeArray(r,o));let s=[...n.data].map((o,a)=>i.type._parseSync(new Lt(n,o,n.path,a)));return je.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new t({...this._def,minLength:{value:e,message:M.toString(n)}})}max(e,n){return new t({...this._def,maxLength:{value:e,message:M.toString(n)}})}length(e,n){return new t({...this._def,exactLength:{value:e,message:M.toString(n)}})}nonempty(e){return this.min(1,e)}};$n.create=(t,e)=>new $n({type:t,minLength:null,maxLength:null,exactLength:null,typeName:V.ZodArray,...H(e)});function Ps(t){if(t instanceof ct){let e={};for(let n in t.shape){let r=t.shape[n];e[n]=Ft.create(Ps(r))}return new ct({...t._def,shape:()=>e})}else return t instanceof $n?new $n({...t._def,type:Ps(t.element)}):t instanceof Ft?Ft.create(Ps(t.unwrap())):t instanceof gn?gn.create(Ps(t.unwrap())):t instanceof hn?hn.create(t.items.map(e=>Ps(e))):t}var ct=class t extends B{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),n=q.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==N.object){let u=this._getOrReturnCtx(e);return P(u,{code:C.invalid_type,expected:N.object,received:u.parsedType}),D}let{status:r,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Gt&&this._def.unknownKeys==="strip"))for(let u in i.data)o.includes(u)||a.push(u);let l=[];for(let u of o){let c=s[u],d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new Lt(i,d,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof Gt){let u=this._def.unknownKeys;if(u==="passthrough")for(let c of a)l.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(u==="strict")a.length>0&&(P(i,{code:C.unrecognized_keys,keys:a}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let c of a){let d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new Lt(i,d,i.path,c)),alwaysSet:c in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let u=[];for(let c of l){let d=await c.key,f=await c.value;u.push({key:d,value:f,alwaysSet:c.alwaysSet})}return u}).then(u=>je.mergeObjectSync(r,u)):je.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return M.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{let i=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:M.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:V.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let n={};for(let r of q.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}omit(e){let n={};for(let r of q.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new t({...this._def,shape:()=>n})}deepPartial(){return Ps(this)}partial(e){let n={};for(let r of q.objectKeys(this.shape)){let i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new t({...this._def,shape:()=>n})}required(e){let n={};for(let r of q.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Ft;)s=s._def.innerType;n[r]=s}return new t({...this._def,shape:()=>n})}keyof(){return Zw(q.objectKeys(this.shape))}};ct.create=(t,e)=>new ct({shape:()=>t,unknownKeys:"strip",catchall:Gt.create(),typeName:V.ZodObject,...H(e)});ct.strictCreate=(t,e)=>new ct({shape:()=>t,unknownKeys:"strict",catchall:Gt.create(),typeName:V.ZodObject,...H(e)});ct.lazycreate=(t,e)=>new ct({shape:t,unknownKeys:"strip",catchall:Gt.create(),typeName:V.ZodObject,...H(e)});var hi=class extends B{_parse(e){let{ctx:n}=this._processInputParams(e),r=this._def.options;function i(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;let o=s.map(a=>new ut(a.ctx.common.issues));return P(n,{code:C.invalid_union,unionErrors:o}),D}if(n.common.async)return Promise.all(r.map(async s=>{let o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s,o=[];for(let l of r){let u={...n,common:{...n.common,issues:[]},parent:null},c=l._parseSync({data:n.data,path:n.path,parent:u});if(c.status==="valid")return c;c.status==="dirty"&&!s&&(s={result:c,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;let a=o.map(l=>new ut(l));return P(n,{code:C.invalid_union,unionErrors:a}),D}}get options(){return this._def.options}};hi.create=(t,e)=>new hi({options:t,typeName:V.ZodUnion,...H(e)});var In=t=>t instanceof mi?In(t.schema):t instanceof It?In(t.innerType()):t instanceof vi?[t.value]:t instanceof yi?t.options:t instanceof _i?q.objectValues(t.enum):t instanceof wi?In(t._def.innerType):t instanceof fi?[void 0]:t instanceof pi?[null]:t instanceof Ft?[void 0,...In(t.unwrap())]:t instanceof gn?[null,...In(t.unwrap())]:t instanceof ga||t instanceof xi?In(t.unwrap()):t instanceof ki?In(t._def.innerType):[],Xu=class t extends B{_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==N.object)return P(n,{code:C.invalid_type,expected:N.object,received:n.parsedType}),D;let r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(P(n,{code:C.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),D)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){let i=new Map;for(let s of n){let o=In(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,s)}}return new t({typeName:V.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:i,...H(r)})}};function Xh(t,e){let n=pn(t),r=pn(e);if(t===e)return{valid:!0,data:t};if(n===N.object&&r===N.object){let i=q.objectKeys(e),s=q.objectKeys(t).filter(a=>i.indexOf(a)!==-1),o={...t,...e};for(let a of s){let l=Xh(t[a],e[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===N.array&&r===N.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let s=0;s<t.length;s++){let o=t[s],a=e[s],l=Xh(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===N.date&&r===N.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var gi=class extends B{_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=(s,o)=>{if(Yu(s)||Yu(o))return D;let a=Xh(s.value,o.value);return a.valid?((Qu(s)||Qu(o))&&n.dirty(),{status:n.value,value:a.data}):(P(r,{code:C.invalid_intersection_types}),D)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};gi.create=(t,e,n)=>new gi({left:t,right:e,typeName:V.ZodIntersection,...H(n)});var hn=class t extends B{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.array)return P(r,{code:C.invalid_type,expected:N.array,received:r.parsedType}),D;if(r.data.length<this._def.items.length)return P(r,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),D;!this._def.rest&&r.data.length>this._def.items.length&&(P(r,{code:C.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());let s=[...r.data].map((o,a)=>{let l=this._def.items[a]||this._def.rest;return l?l._parse(new Lt(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>je.mergeArray(n,o)):je.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};hn.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new hn({items:t,typeName:V.ZodTuple,rest:null,...H(e)})};var Ju=class t extends B{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.object)return P(r,{code:C.invalid_type,expected:N.object,received:r.parsedType}),D;let i=[],s=this._def.keyType,o=this._def.valueType;for(let a in r.data)i.push({key:s._parse(new Lt(r,a,r.path,a)),value:o._parse(new Lt(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?je.mergeObjectAsync(n,i):je.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof B?new t({keyType:e,valueType:n,typeName:V.ZodRecord,...H(r)}):new t({keyType:Pr.create(),valueType:e,typeName:V.ZodRecord,...H(n)})}},Os=class extends B{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.map)return P(r,{code:C.invalid_type,expected:N.map,received:r.parsedType}),D;let i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],u)=>({key:i._parse(new Lt(r,a,r.path,[u,"key"])),value:s._parse(new Lt(r,l,r.path,[u,"value"]))}));if(r.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of o){let u=await l.key,c=await l.value;if(u.status==="aborted"||c.status==="aborted")return D;(u.status==="dirty"||c.status==="dirty")&&n.dirty(),a.set(u.value,c.value)}return{status:n.value,value:a}})}else{let a=new Map;for(let l of o){let u=l.key,c=l.value;if(u.status==="aborted"||c.status==="aborted")return D;(u.status==="dirty"||c.status==="dirty")&&n.dirty(),a.set(u.value,c.value)}return{status:n.value,value:a}}}};Os.create=(t,e,n)=>new Os({valueType:e,keyType:t,typeName:V.ZodMap,...H(n)});var Ns=class t extends B{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==N.set)return P(r,{code:C.invalid_type,expected:N.set,received:r.parsedType}),D;let i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(P(r,{code:C.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(P(r,{code:C.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());let s=this._def.valueType;function o(l){let u=new Set;for(let c of l){if(c.status==="aborted")return D;c.status==="dirty"&&n.dirty(),u.add(c.value)}return{status:n.value,value:u}}let a=[...r.data.values()].map((l,u)=>s._parse(new Lt(r,l,r.path,u)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,n){return new t({...this._def,minSize:{value:e,message:M.toString(n)}})}max(e,n){return new t({...this._def,maxSize:{value:e,message:M.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};Ns.create=(t,e)=>new Ns({valueType:t,minSize:null,maxSize:null,typeName:V.ZodSet,...H(e)});var ec=class t extends B{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==N.function)return P(n,{code:C.invalid_type,expected:N.function,received:n.parsedType}),D;function r(a,l){return ha({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Cs(),Ln].filter(u=>!!u),issueData:{code:C.invalid_arguments,argumentsError:l}})}function i(a,l){return ha({data:a,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,Cs(),Ln].filter(u=>!!u),issueData:{code:C.invalid_return_type,returnTypeError:l}})}let s={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Ar){let a=this;return Ke(async function(...l){let u=new ut([]),c=await a._def.args.parseAsync(l,s).catch(g=>{throw u.addIssue(r(l,g)),u}),d=await Reflect.apply(o,this,c);return await a._def.returns._def.type.parseAsync(d,s).catch(g=>{throw u.addIssue(i(d,g)),u})})}else{let a=this;return Ke(function(...l){let u=a._def.args.safeParse(l,s);if(!u.success)throw new ut([r(l,u.error)]);let c=Reflect.apply(o,this,u.data),d=a._def.returns.safeParse(c,s);if(!d.success)throw new ut([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:hn.create(e).rest(Mn.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,r){return new t({args:e||hn.create([]).rest(Mn.create()),returns:n||Mn.create(),typeName:V.ZodFunction,...H(r)})}},mi=class extends B{get schema(){return this._def.getter()}_parse(e){let{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};mi.create=(t,e)=>new mi({getter:t,typeName:V.ZodLazy,...H(e)});var vi=class extends B{_parse(e){if(e.data!==this._def.value){let n=this._getOrReturnCtx(e);return P(n,{received:n.data,code:C.invalid_literal,expected:this._def.value}),D}return{status:"valid",value:e.data}}get value(){return this._def.value}};vi.create=(t,e)=>new vi({value:t,typeName:V.ZodLiteral,...H(e)});function Zw(t,e){return new yi({values:t,typeName:V.ZodEnum,...H(e)})}var yi=class t extends B{_parse(e){if(typeof e.data!="string"){let n=this._getOrReturnCtx(e),r=this._def.values;return P(n,{expected:q.joinValues(r),received:n.parsedType,code:C.invalid_type}),D}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let n=this._getOrReturnCtx(e),r=this._def.values;return P(n,{received:n.data,code:C.invalid_enum_value,options:r}),D}return Ke(e.data)}get options(){return this._def.values}get enum(){let e={};for(let n of this._def.values)e[n]=n;return e}get Values(){let e={};for(let n of this._def.values)e[n]=n;return e}get Enum(){let e={};for(let n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return t.create(e,{...this._def,...n})}exclude(e,n=this._def){return t.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};yi.create=Zw;var _i=class extends B{_parse(e){let n=q.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==N.string&&r.parsedType!==N.number){let i=q.objectValues(n);return P(r,{expected:q.joinValues(i),received:r.parsedType,code:C.invalid_type}),D}if(this._cache||(this._cache=new Set(q.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let i=q.objectValues(n);return P(r,{received:r.data,code:C.invalid_enum_value,options:i}),D}return Ke(e.data)}get enum(){return this._def.values}};_i.create=(t,e)=>new _i({values:t,typeName:V.ZodNativeEnum,...H(e)});var Ar=class extends B{unwrap(){return this._def.type}_parse(e){let{ctx:n}=this._processInputParams(e);if(n.parsedType!==N.promise&&n.common.async===!1)return P(n,{code:C.invalid_type,expected:N.promise,received:n.parsedType}),D;let r=n.parsedType===N.promise?n.data:Promise.resolve(n.data);return Ke(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Ar.create=(t,e)=>new Ar({type:t,typeName:V.ZodPromise,...H(e)});var It=class extends B{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===V.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{P(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){let o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return D;let l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?D:l.status==="dirty"?ai(l.value):n.value==="dirty"?ai(l.value):l});{if(n.value==="aborted")return D;let a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?D:a.status==="dirty"?ai(a.value):n.value==="dirty"?ai(a.value):a}}if(i.type==="refinement"){let o=a=>{let l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){let a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?D:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?D:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){let o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Tr(o))return D;let a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Tr(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):D);q.assertNever(i)}};It.create=(t,e,n)=>new It({schema:t,typeName:V.ZodEffects,effect:e,...H(n)});It.createWithPreprocess=(t,e,n)=>new It({schema:e,effect:{type:"preprocess",transform:t},typeName:V.ZodEffects,...H(n)});var Ft=class extends B{_parse(e){return this._getType(e)===N.undefined?Ke(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ft.create=(t,e)=>new Ft({innerType:t,typeName:V.ZodOptional,...H(e)});var gn=class extends B{_parse(e){return this._getType(e)===N.null?Ke(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};gn.create=(t,e)=>new gn({innerType:t,typeName:V.ZodNullable,...H(e)});var wi=class extends B{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return n.parsedType===N.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};wi.create=(t,e)=>new wi({innerType:t,typeName:V.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...H(e)});var ki=class extends B{_parse(e){let{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Ts(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ut(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new ut(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};ki.create=(t,e)=>new ki({innerType:t,typeName:V.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...H(e)});var Fs=class extends B{_parse(e){if(this._getType(e)!==N.nan){let r=this._getOrReturnCtx(e);return P(r,{code:C.invalid_type,expected:N.nan,received:r.parsedType}),D}return{status:"valid",value:e.data}}};Fs.create=t=>new Fs({typeName:V.ZodNaN,...H(t)});var kT=Symbol("zod_brand"),ga=class extends B{_parse(e){let{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},ma=class t extends B{_parse(e){let{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?D:s.status==="dirty"?(n.dirty(),ai(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{let i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?D:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new t({in:e,out:n,typeName:V.ZodPipeline})}},xi=class extends B{_parse(e){let n=this._def.innerType._parse(e),r=i=>(Tr(i)&&(i.value=Object.freeze(i.value)),i);return Ts(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}};xi.create=(t,e)=>new xi({innerType:t,typeName:V.ZodReadonly,...H(e)});function Ww(t,e){let n=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof n=="string"?{message:n}:n}function Yw(t,e={},n){return t?Rr.create().superRefine((r,i)=>{let s=t(r);if(s instanceof Promise)return s.then(o=>{if(!o){let a=Ww(e,r),l=a.fatal??n??!0;i.addIssue({code:"custom",...a,fatal:l})}});if(!s){let o=Ww(e,r),a=o.fatal??n??!0;i.addIssue({code:"custom",...o,fatal:a})}}):Rr.create()}var xT={object:ct.lazycreate},V;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(V||(V={}));var ET=(t,e={message:`Input not instance of ${t.name}`})=>Yw(n=>n instanceof t,e),Qw=Pr.create,Xw=li.create,ST=Fs.create,bT=ui.create,Jw=ci.create,CT=di.create,TT=Rs.create,PT=fi.create,RT=pi.create,AT=Rr.create,OT=Mn.create,NT=Gt.create,FT=As.create,LT=$n.create,IT=ct.create,MT=ct.strictCreate,$T=hi.create,DT=Xu.create,VT=gi.create,jT=hn.create,zT=Ju.create,HT=Os.create,BT=Ns.create,UT=ec.create,WT=mi.create,qT=vi.create,KT=yi.create,GT=_i.create,ZT=Ar.create,YT=It.create,QT=Ft.create,XT=gn.create,JT=It.createWithPreprocess,eP=ma.create,tP=()=>Qw().optional(),nP=()=>Xw().optional(),rP=()=>Jw().optional(),iP={string:(t=>Pr.create({...t,coerce:!0})),number:(t=>li.create({...t,coerce:!0})),boolean:(t=>ci.create({...t,coerce:!0})),bigint:(t=>ui.create({...t,coerce:!0})),date:(t=>di.create({...t,coerce:!0}))};var sP=D;var e1=$.union([$.object({type:$.literal("data"),key:$.string(),value:$.string().optional()}),$.object({type:$.literal("css"),value:$.string()}),$.object({type:$.literal("aria"),role:$.string().optional(),label:$.string().optional()}),$.object({type:$.literal("shadow-css"),value:$.string()}),$.object({type:$.literal("ref"),el:$.any()})]),oP=$.object({kind:$.literal("tooltip"),id:$.string(),anchor:e1,content:$.object({title:$.string().optional(),body:$.string()}),placement:$.enum(["top","bottom","left","right","auto"]).optional(),offsetPx:$.number().optional(),blocking:$.boolean().optional(),trigger:$.enum(["immediate","hover","click"]).optional(),dismiss:$.object({onEsc:$.boolean().optional(),closeButton:$.boolean().optional(),timeoutMs:$.number().optional()}).optional()}),aP=$.object({kind:$.literal("highlight"),id:$.string(),anchor:e1,copy:$.string().optional(),ring:$.object({paddingPx:$.number().optional(),radiusPx:$.number().optional()}).optional(),scrim:$.object({opacity:$.number().optional()}).optional(),ringColor:$.string().optional(),blocking:$.boolean().optional(),dismiss:$.object({onClickOutside:$.boolean().optional(),onEsc:$.boolean().optional(),timeoutMs:$.number().optional()}).optional()}),va=$.object({id:$.string(),version:$.number(),routes:$.array($.string()).optional(),steps:$.array($.union([oP,aP]))});function qA(t){return va.parse(t)}var t1=({configUri:t,experiments:e,featureKey:n="smart-canvas-overlay-uri",credentials:r="include"}={})=>async()=>{let i=Zh({configUri:t,experiments:e,featureKey:n});if(!i)throw new Error("SmartCanvas overlays: recipe URI missing (env + feature unset).");let s=await fetch(i,{credentials:r});if(!s.ok)throw new Error(`SmartCanvas overlays: failed to fetch recipe (${s.status})`);let o=await s.json();return va.parse(o)};function J1({fetcher:t,configUri:e,featureKey:n,credentials:r,experiments:i,telemetry:s,canvasHost:o}){let a=(0,pc.useMemo)(()=>{if(t)return t;if(e)return t1({configUri:e,experiments:i,featureKey:n,credentials:r,validator:va})},[t,e,i,n,r]);(0,pc.useEffect)(()=>{if(!a)return;let l=!1,u;return(async()=>{try{let c=await a();if(!c?.steps?.length||l)return;let d=await Promise.resolve().then(()=>(X1(),Q1)),f=d.ensureOverlayRoot(),g=d.createAnchorResolver({canvasHost:o});u=await d.runOverlays(c,{overlayRoot:f,resolve:g,canvasHost:o,onEvent:(v,y)=>{s&&s.trackAction?.(v,y?.stepId??"","overlay")}})}catch(c){console.warn("[SmartCanvas] overlays failed",c)}})(),()=>{l=!0,u?.()}},[a,s,o])}var nk=ve(bt(),1);sg();var WP=new Set(["outline","outlineColor","outlineWidth","outlineStyle","boxShadow","filter","scrollMargin","scrollMarginTop","scrollMarginRight","scrollMarginBottom","scrollMarginLeft"]);function qP(t){return t.startsWith("--")}function KP(t){return t.startsWith("data-")||t.startsWith("aria-")||t==="role"}function GP(t){return t.startsWith("syntro-")||t.startsWith("sc-")||t.startsWith("sx-")}var Ds={allowAttribute(t,e){return!!(KP(t)||e!=="additive"&&t==="title")},allowClass(t,e){return GP(t)},allowStyle(t,e,n){return!!(qP(t)||WP.has(t)||n==="surgical"&&(t==="backgroundColor"||t==="color"))},allowSetText(t){return t==="surgical"},sanitizeHTML(t){return cc(t)}};var ZP=[/^\*$/,/^\s*$/,/:has\(/i,/javascript:/i];function YP(t){if(!t||t.length>500)return console.warn("[SmartCanvas] Selector too long or empty:",t?.slice(0,50)),!1;if(ZP.some(e=>e.test(t)))return console.warn("[SmartCanvas] Dangerous selector pattern blocked:",t),!1;try{return document.querySelector(t),!0}catch{return console.warn("[SmartCanvas] Invalid CSS selector:",t),!1}}function QP(t){let e;if(t.by==="css")e=t.value;else if(t.by==="data")e=`[data-${t.key}${t.value?`="${t.value}"`:""}]`;else if(t.by==="aria"){let n=t.role?`[role="${t.role}"]`:"",r=t.label?`[aria-label="${t.label}"]`:"";e=`${n}${r}`}else return null;return YP(e)?e:null}function ek(t,e){if(t.el instanceof HTMLElement)return t.el;let r=("within"in t?t.within==="shadow":!1)?e.shadowHost?.shadowRoot??document:document,i=QP(t);if(!i)return null;let s=r.querySelectorAll(i);return s.length===0?(console.warn(`[SmartCanvas] No elements match selector: ${i}`),null):(s.length>1&&console.warn(`[SmartCanvas] Selector "${i}" matches ${s.length} elements. Using first match. Consider a more specific selector.`),s[0])}function tk(t,e){if(!e)return!0;if(e.tag&&t.tagName.toLowerCase()!==e.tag.toLowerCase())return!1;if(e.hasAttrs){for(let[n,r]of Object.entries(e.hasAttrs))if(t.getAttribute(n)!==r)return!1}return!(e.closest&&!e.closest.some(r=>!!t.closest(r)))}var hc=new Map;function Vs(t,e,n,r){t.onLog?t.onLog(e,n,r):e!=="debug"&&console[e]("[host-patcher]",n,r??"")}function gc(t,e={}){let n=e.policy??Ds;if(hc.has(t.id))return{ok:!0};let r=ek(t.anchor,{shadowHost:e.shadowHost});if(!r)return{ok:!1,reason:"anchor-missing"};if(!tk(r,t.invariants))return{ok:!1,reason:"invariants-failed"};let i=t.tier??"additive",s=[],o={classes:void 0,attrs:void 0,styles:void 0,text:void 0};for(let a of t.operations)switch(a.kind){case"insertAdjacent":{let l=document.createElement("div");l.setAttribute("data-syntro-patch-id",t.id),a.html&&(l.innerHTML=n.sanitizeHTML(a.html)),a.node&&l.appendChild(a.node),r.insertAdjacentElement(a.where,l),s.push(l);break}case"append":{let l=a.node??(()=>{let u=document.createElement("div");return a.html&&(u.innerHTML=n.sanitizeHTML(a.html)),u})();r.appendChild(l),s.push(l);break}case"prepend":{let l=a.node??(()=>{let u=document.createElement("div");return a.html&&(u.innerHTML=n.sanitizeHTML(a.html)),u})();r.insertBefore(l,r.firstChild),s.push(l);break}case"addClass":{if(!n.allowClass(a.className,i)){Vs(e,"warn","class not allowed",a.className);break}o.classes??(o.classes=new Set(Array.from(r.classList))),r.classList.add(a.className);break}case"removeClass":{if(!n.allowClass(a.className,i)){Vs(e,"warn","class not allowed",a.className);break}o.classes??(o.classes=new Set(Array.from(r.classList))),r.classList.remove(a.className);break}case"setAttr":{if(!n.allowAttribute(a.name,i)){Vs(e,"warn","attr not allowed",a.name);break}if(o.attrs??(o.attrs=new Map),!o.attrs.has(a.name)){let l=r.getAttribute(a.name);l!==null?o.attrs.set(a.name,l):o.attrs.set(a.name,"__NULL__")}a.value===null?r.removeAttribute(a.name):r.setAttribute(a.name,a.value);break}case"setStyle":{if(!n.allowStyle(a.prop,a.value??null,i)){Vs(e,"warn","style not allowed",a.prop);break}if(o.styles??(o.styles=new Map),!o.styles.has(a.prop)){let l=r.style.getPropertyValue(a.prop);o.styles.set(a.prop,l||"__NULL__")}a.value===null?r.style.removeProperty(a.prop):r.style.setProperty(a.prop,a.value,a.important?"important":"");break}case"setText":{if(!n.allowSetText(i)){Vs(e,"warn","setText not allowed in this tier",{tier:i});break}o.text??(o.text=r.textContent??""),r.textContent=a.text;break}default:Vs(e,"warn","unknown operation",a)}return hc.set(t.id,{id:t.id,anchorEl:r,inserted:s,snapshot:o}),{ok:!0}}function mc(t,e={}){let n=hc.get(t);if(!n)return;for(let i of n.inserted)try{i.remove()}catch{}let r=n.anchorEl;if(r&&n.snapshot){if(n.snapshot.text!==void 0&&(r.textContent=n.snapshot.text),n.snapshot.attrs&&(new Set(Array.from(r.attributes).map(s=>s.name)).forEach(s=>{n.snapshot.attrs.has(s)||r.removeAttribute(s)}),n.snapshot.attrs.forEach((s,o)=>{s==="__NULL__"?r.removeAttribute(o):r.setAttribute(o,s)})),n.snapshot.classes){let i=r.classList;Array.from(i).forEach(s=>i.remove(s)),n.snapshot.classes.forEach(s=>i.add(s))}if(n.snapshot.styles){let i=r.style;Array.from(i).forEach(s=>i.removeProperty(s)),n.snapshot.styles.forEach((s,o)=>{s==="__NULL__"?i.removeProperty(o):i.setProperty(o,s)})}}hc.delete(t)}function rk({patches:t,telemetry:e,policy:n=Ds,canvasHost:r}){(0,nk.useEffect)(()=>{if(!t||t.length===0)return;let i=[];return t.forEach(s=>{gc(s,{shadowHost:r,policy:n,onLog:e?(a,l,u)=>e.trackAction?.(`syntro_patch_${a}`,s.id,"overlay"):void 0}).ok?(i.push(s.id),e?.trackAction?.("syntro_patch_applied",s.id,"overlay")):e?.trackAction?.("syntro_patch_failed",s.id,"overlay")}),()=>{i.forEach(s=>{try{mc(s),e?.trackAction?.("syntro_patch_reverted",s,"overlay")}catch(o){console.warn("[SmartCanvas] failed to revert patch",s,o)}})}},[t,e,n,r])}var sk=ve(Vt(),1);function ik({controller:t,fetcher:e,configUri:n,configUriFeatureKey:r="smart-canvas-config-uri",configFeatureKey:i="smart-canvas-config",fetchCredentials:s="include",pollIntervalMs:o,experiments:a,telemetry:l,overlayFetcher:u,overlayConfigUri:c,overlayConfigFeatureKey:d="smart-canvas-overlay-uri",overlayFetchCredentials:f="include",footerSlot:g,launcherLabel:v,canvasHost:y,customRenderers:k,theme:h}){let[p,m]=(0,Fr.useState)(t.getState().open),_=(0,Fr.useMemo)(()=>e||bs({configUri:n,experiments:a,featureKey:r,configFeatureKey:i,credentials:s}),[e,n,a,r,i,s]),w=_y({fetcher:_,pollIntervalMs:o,experiments:a}),b=w.rectangles.length>0&&!w.error;(0,Fr.useEffect)(()=>t.subscribe(E=>m(E.open)),[t]),(0,Fr.useEffect)(()=>{!b&&t.getState().open&&t.setOpen(!1)},[t,b]);let S=(0,Fr.useMemo)(()=>{if(u)return u;if(w.overlayRecipe)return async()=>w.overlayRecipe;!c&&w.isLoading},[u,w.overlayRecipe,w.isLoading,c]);return J1({fetcher:S,configUri:!S&&!w.isLoading?c:void 0,featureKey:d,credentials:f,experiments:a,telemetry:l,canvasHost:y}),rk({patches:w.patches,telemetry:l,canvasHost:y}),!w.isLoading&&!b||!b?null:(0,sk.jsx)(zw,{rectangles:w.rectangles,isLoading:w.isLoading,error:w.error,canvasTitle:w.canvasTitle,telemetry:l,launcherLabel:v,footerSlot:g,isOpen:p,onToggle:()=>t.toggle(),customRenderers:k,displayMode:w.displayMode,theme:h})}var ck=ve(ak(),1);var fk=ve(Vt(),1),lk="smart-canvas",uk=`
|
|
137
137
|
:host {
|
|
138
138
|
font: inherit;
|
|
139
139
|
color: inherit;
|