@useorgx/openclaw-plugin 0.4.9 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dashboard/dist/assets/BJgZIVUQ.js +53 -0
- package/dashboard/dist/assets/BJgZIVUQ.js.br +0 -0
- package/dashboard/dist/assets/BJgZIVUQ.js.gz +0 -0
- package/dashboard/dist/assets/BXWDRGm-.js +1 -0
- package/dashboard/dist/assets/BXWDRGm-.js.br +0 -0
- package/dashboard/dist/assets/BXWDRGm-.js.gz +0 -0
- package/dashboard/dist/assets/BgOYB78t.js +4 -0
- package/dashboard/dist/assets/BgOYB78t.js.br +0 -0
- package/dashboard/dist/assets/BgOYB78t.js.gz +0 -0
- package/dashboard/dist/assets/C-KIc3Wc.js.br +0 -0
- package/dashboard/dist/assets/C-KIc3Wc.js.gz +0 -0
- package/dashboard/dist/assets/CE38zU4U.js +1 -0
- package/dashboard/dist/assets/CE38zU4U.js.br +0 -0
- package/dashboard/dist/assets/CE38zU4U.js.gz +0 -0
- package/dashboard/dist/assets/CFGKRAzG.js +1 -0
- package/dashboard/dist/assets/CFGKRAzG.js.br +0 -0
- package/dashboard/dist/assets/CFGKRAzG.js.gz +0 -0
- package/dashboard/dist/assets/CGGR2GZh.js +1 -0
- package/dashboard/dist/assets/CGGR2GZh.js.br +0 -0
- package/dashboard/dist/assets/CGGR2GZh.js.gz +0 -0
- package/dashboard/dist/assets/CL_wXqR7.js +1 -0
- package/dashboard/dist/assets/CL_wXqR7.js.br +0 -0
- package/dashboard/dist/assets/CL_wXqR7.js.gz +0 -0
- package/dashboard/dist/assets/CPFiTmlw.js +8 -0
- package/dashboard/dist/assets/CPFiTmlw.js.br +0 -0
- package/dashboard/dist/assets/CPFiTmlw.js.gz +0 -0
- package/dashboard/dist/assets/CZZTvkQZ.js +1 -0
- package/dashboard/dist/assets/CZZTvkQZ.js.br +0 -0
- package/dashboard/dist/assets/CZZTvkQZ.js.gz +0 -0
- package/dashboard/dist/assets/{CpJsfbXo.js → CxQ08qFN.js} +2 -2
- package/dashboard/dist/assets/CxQ08qFN.js.br +0 -0
- package/dashboard/dist/assets/CxQ08qFN.js.gz +0 -0
- package/dashboard/dist/assets/D-bf6hEI.js +213 -0
- package/dashboard/dist/assets/D-bf6hEI.js.br +0 -0
- package/dashboard/dist/assets/D-bf6hEI.js.gz +0 -0
- package/dashboard/dist/assets/DG6y9wJI.js +2 -0
- package/dashboard/dist/assets/DG6y9wJI.js.br +0 -0
- package/dashboard/dist/assets/DG6y9wJI.js.gz +0 -0
- package/dashboard/dist/assets/DNxKz-GV.js +1 -0
- package/dashboard/dist/assets/DNxKz-GV.js.br +0 -0
- package/dashboard/dist/assets/DNxKz-GV.js.gz +0 -0
- package/dashboard/dist/assets/DW_rKUic.js +11 -0
- package/dashboard/dist/assets/DW_rKUic.js.br +0 -0
- package/dashboard/dist/assets/DW_rKUic.js.gz +0 -0
- package/dashboard/dist/assets/DbNoijHm.js +1 -0
- package/dashboard/dist/assets/DbNoijHm.js.br +0 -0
- package/dashboard/dist/assets/DbNoijHm.js.gz +0 -0
- package/dashboard/dist/assets/DjcdE6jC.js +2 -0
- package/dashboard/dist/assets/DjcdE6jC.js.br +0 -0
- package/dashboard/dist/assets/DjcdE6jC.js.gz +0 -0
- package/dashboard/dist/assets/FZYuCDnt.js +1 -0
- package/dashboard/dist/assets/FZYuCDnt.js.br +0 -0
- package/dashboard/dist/assets/FZYuCDnt.js.gz +0 -0
- package/dashboard/dist/assets/PAUiij_z.js +1 -0
- package/dashboard/dist/assets/PAUiij_z.js.br +0 -0
- package/dashboard/dist/assets/PAUiij_z.js.gz +0 -0
- package/dashboard/dist/assets/cNrhgGc1.js +8 -0
- package/dashboard/dist/assets/cNrhgGc1.js.br +0 -0
- package/dashboard/dist/assets/cNrhgGc1.js.gz +0 -0
- package/dashboard/dist/assets/h5biQs2I.css +1 -0
- package/dashboard/dist/assets/h5biQs2I.css.br +0 -0
- package/dashboard/dist/assets/h5biQs2I.css.gz +0 -0
- package/dashboard/dist/assets/ic2FaMnh.js +1 -0
- package/dashboard/dist/assets/ic2FaMnh.js.br +0 -0
- package/dashboard/dist/assets/ic2FaMnh.js.gz +0 -0
- package/dashboard/dist/assets/nByHNHoW.js +1 -0
- package/dashboard/dist/assets/nByHNHoW.js.br +0 -0
- package/dashboard/dist/assets/nByHNHoW.js.gz +0 -0
- package/dashboard/dist/assets/qm8xLgv-.css +1 -0
- package/dashboard/dist/assets/qm8xLgv-.css.br +0 -0
- package/dashboard/dist/assets/qm8xLgv-.css.gz +0 -0
- package/dashboard/dist/assets/tS9mbYZi.js +1 -0
- package/dashboard/dist/assets/tS9mbYZi.js.br +0 -0
- package/dashboard/dist/assets/tS9mbYZi.js.gz +0 -0
- package/dashboard/dist/brand/anthropic-mark.svg.br +0 -0
- package/dashboard/dist/brand/anthropic-mark.svg.gz +0 -0
- package/dashboard/dist/brand/openai-mark.svg.br +0 -0
- package/dashboard/dist/brand/openai-mark.svg.gz +0 -0
- package/dashboard/dist/brand/openclaw-mark.svg.br +0 -0
- package/dashboard/dist/brand/openclaw-mark.svg.gz +0 -0
- package/dashboard/dist/brand/xandy-orchestrator.png +0 -0
- package/dashboard/dist/index.html +7 -5
- package/dashboard/dist/index.html.br +0 -0
- package/dashboard/dist/index.html.gz +0 -0
- package/dist/activity-actor-fields.js +26 -4
- package/dist/activity-store.js +34 -8
- package/dist/agent-context-store.js +79 -17
- package/dist/agent-run-store.js +44 -3
- package/dist/agent-suite.d.ts +9 -0
- package/dist/agent-suite.js +149 -9
- package/dist/artifacts/artifact-domain-schemas.d.ts +66 -0
- package/dist/artifacts/artifact-domain-schemas.js +357 -0
- package/dist/artifacts/register-artifact.d.ts +4 -3
- package/dist/artifacts/register-artifact.js +170 -57
- package/dist/chat-store.d.ts +157 -0
- package/dist/chat-store.js +586 -0
- package/dist/cli/orgx.js +11 -0
- package/dist/contracts/client.d.ts +43 -3
- package/dist/contracts/client.js +159 -30
- package/dist/contracts/retro-schema.d.ts +81 -0
- package/dist/contracts/retro-schema.js +80 -0
- package/dist/contracts/shared-types.d.ts +159 -0
- package/dist/contracts/shared-types.js +177 -1
- package/dist/contracts/skill-pack-schema.d.ts +192 -0
- package/dist/contracts/skill-pack-schema.js +180 -0
- package/dist/contracts/types.d.ts +227 -2
- package/dist/entities/auto-assignment.js +43 -17
- package/dist/event-sanitization.d.ts +11 -0
- package/dist/event-sanitization.js +113 -0
- package/dist/fs-utils.js +13 -1
- package/dist/gateway-watchdog.d.ts +5 -0
- package/dist/gateway-watchdog.js +50 -0
- package/dist/hooks/post-reporting-event.mjs +1 -5
- package/dist/http/helpers/activity-headline.js +13 -132
- package/dist/http/helpers/auto-continue-engine.d.ts +198 -10
- package/dist/http/helpers/auto-continue-engine.js +2531 -186
- package/dist/http/helpers/autopilot-operations.d.ts +19 -0
- package/dist/http/helpers/autopilot-operations.js +182 -31
- package/dist/http/helpers/autopilot-runtime.d.ts +1 -0
- package/dist/http/helpers/autopilot-runtime.js +308 -20
- package/dist/http/helpers/autopilot-slice-utils.d.ts +18 -0
- package/dist/http/helpers/autopilot-slice-utils.js +516 -93
- package/dist/http/helpers/decision-mapper.d.ts +40 -0
- package/dist/http/helpers/decision-mapper.js +223 -7
- package/dist/http/helpers/dispatch-lifecycle.d.ts +19 -2
- package/dist/http/helpers/dispatch-lifecycle.js +242 -37
- package/dist/http/helpers/kickoff-context.js +74 -0
- package/dist/http/helpers/llm-client.d.ts +47 -0
- package/dist/http/helpers/llm-client.js +256 -0
- package/dist/http/helpers/mission-control.d.ts +102 -3
- package/dist/http/helpers/mission-control.js +498 -9
- package/dist/http/helpers/sentinel-catalog.d.ts +23 -0
- package/dist/http/helpers/sentinel-catalog.js +193 -0
- package/dist/http/helpers/session-classification.d.ts +9 -0
- package/dist/http/helpers/session-classification.js +564 -0
- package/dist/http/helpers/slice-experience-v2.d.ts +137 -0
- package/dist/http/helpers/slice-experience-v2.js +677 -0
- package/dist/http/helpers/slice-run-projections.d.ts +72 -0
- package/dist/http/helpers/slice-run-projections.js +860 -0
- package/dist/http/helpers/triage-mapper.d.ts +43 -0
- package/dist/http/helpers/triage-mapper.js +549 -0
- package/dist/http/helpers/value-utils.js +7 -2
- package/dist/http/helpers/workspace-scope.d.ts +15 -0
- package/dist/http/helpers/workspace-scope.js +170 -0
- package/dist/http/index.js +1354 -97
- package/dist/http/routes/agent-suite.d.ts +9 -0
- package/dist/http/routes/agent-suite.js +207 -8
- package/dist/http/routes/agents-catalog.js +64 -19
- package/dist/http/routes/chat.d.ts +19 -0
- package/dist/http/routes/chat.js +522 -0
- package/dist/http/routes/decision-actions.d.ts +8 -1
- package/dist/http/routes/decision-actions.js +42 -5
- package/dist/http/routes/dispatch-gateway-envelope.d.ts +25 -0
- package/dist/http/routes/dispatch-gateway-envelope.js +26 -0
- package/dist/http/routes/entities.d.ts +16 -0
- package/dist/http/routes/entities.js +294 -6
- package/dist/http/routes/live-legacy.d.ts +5 -0
- package/dist/http/routes/live-legacy.js +23 -509
- package/dist/http/routes/live-misc.d.ts +12 -0
- package/dist/http/routes/live-misc.js +251 -31
- package/dist/http/routes/live-snapshot.d.ts +48 -2
- package/dist/http/routes/live-snapshot.js +638 -19
- package/dist/http/routes/live-terminal.d.ts +11 -0
- package/dist/http/routes/live-terminal.js +261 -0
- package/dist/http/routes/live-triage.d.ts +61 -0
- package/dist/http/routes/live-triage.js +248 -0
- package/dist/http/routes/mission-control-actions.d.ts +49 -1
- package/dist/http/routes/mission-control-actions.js +1334 -84
- package/dist/http/routes/mission-control-read.d.ts +48 -3
- package/dist/http/routes/mission-control-read.js +1593 -20
- package/dist/http/routes/realtime-orchestrator.d.ts +10 -0
- package/dist/http/routes/realtime-orchestrator.js +74 -0
- package/dist/http/routes/run-control.d.ts +5 -2
- package/dist/http/routes/run-control.js +10 -0
- package/dist/http/routes/sentinels-catalog.d.ts +7 -0
- package/dist/http/routes/sentinels-catalog.js +24 -0
- package/dist/http/routes/summary.js +10 -3
- package/dist/http/routes/usage.d.ts +24 -0
- package/dist/http/routes/usage.js +362 -0
- package/dist/http/routes/work-artifacts.js +28 -9
- package/dist/index.js +165 -27
- package/dist/local-openclaw.js +29 -6
- package/dist/mcp-client-setup.js +3 -3
- package/dist/mcp-http-handler.js +33 -59
- package/dist/next-up-queue-store.d.ts +16 -1
- package/dist/next-up-queue-store.js +89 -7
- package/dist/outbox.d.ts +5 -0
- package/dist/outbox.js +113 -9
- package/dist/paths.js +24 -5
- package/dist/reporting/rollups.d.ts +53 -0
- package/dist/reporting/rollups.js +148 -0
- package/dist/retro/domain-templates.d.ts +45 -0
- package/dist/retro/domain-templates.js +297 -0
- package/dist/retro/quality-rubric.d.ts +33 -0
- package/dist/retro/quality-rubric.js +213 -0
- package/dist/runtime-cleanup.d.ts +18 -0
- package/dist/runtime-cleanup.js +87 -0
- package/dist/services/background.d.ts +11 -0
- package/dist/services/background.js +22 -0
- package/dist/services/experiment-randomization.d.ts +21 -0
- package/dist/services/experiment-randomization.js +63 -0
- package/dist/skill-pack-state.d.ts +36 -5
- package/dist/skill-pack-state.js +273 -29
- package/dist/sync/local-agent-telemetry.d.ts +13 -0
- package/dist/sync/local-agent-telemetry.js +128 -0
- package/dist/sync/outbox-replay.js +131 -24
- package/dist/team-context-store.d.ts +23 -0
- package/dist/team-context-store.js +116 -0
- package/dist/telemetry/posthog.js +4 -2
- package/dist/tools/core-tools.d.ts +10 -14
- package/dist/tools/core-tools.js +1289 -24
- package/dist/types.d.ts +2 -0
- package/dist/types.js +2 -0
- package/dist/worker-supervisor.js +23 -0
- package/package.json +14 -4
- package/dashboard/dist/assets/B3ziCA02.js +0 -8
- package/dashboard/dist/assets/B5NEElEI.css +0 -1
- package/dashboard/dist/assets/BhapSNAs.js +0 -215
- package/dashboard/dist/assets/iFdvE7lx.js +0 -1
- package/dashboard/dist/assets/jRJsmpYM.js +0 -1
- package/dashboard/dist/assets/sAhvFnpk.js +0 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var d=typeof window<"u"?window:void 0,V=typeof globalThis<"u"?globalThis:d;typeof self>"u"&&(V.self=V),typeof File>"u"&&(V.File=function(){});var cs=Array.prototype,cr=cs.forEach,hr=cs.indexOf,te=V==null?void 0:V.navigator,y=V==null?void 0:V.document,G=V==null?void 0:V.location,xi=V==null?void 0:V.fetch,ki=V!=null&&V.XMLHttpRequest&&"withCredentials"in new V.XMLHttpRequest?V.XMLHttpRequest:void 0,dr=V==null?void 0:V.AbortController,X=te==null?void 0:te.userAgent,E=d??{},ve={DEBUG:!1,LIB_VERSION:"1.345.5"};function pr(r,e,t,i,s,n,a){try{var o=r[n](a),l=o.value}catch(c){return void t(c)}o.done?e(l):Promise.resolve(l).then(i,s)}function Ye(r){return function(){var e=this,t=arguments;return new Promise((function(i,s){var n=r.apply(e,t);function a(l){pr(n,i,s,a,o,"next",l)}function o(l){pr(n,i,s,a,o,"throw",l)}a(void 0)}))}}function w(){return w=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(r[i]=t[i])}return r},w.apply(null,arguments)}function hs(r,e){if(r==null)return{};var t={};for(var i in r)if({}.hasOwnProperty.call(r,i)){if(e.indexOf(i)!==-1)continue;t[i]=r[i]}return t}var kn=["$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"],Sn=["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"],gr=function(r,e){if(e===void 0&&(e=[]),!r)return!1;var t=r.toLowerCase();return Sn.concat(e).some((i=>{var s=i.toLowerCase();return t.indexOf(s)!==-1}))};function F(r,e){return r.indexOf(e)!==-1}var Qt=function(r){return r.trim()},Si=function(r){return r.replace(/^\$/,"")},Pn=Array.isArray,ds=Object.prototype,ps=ds.hasOwnProperty,ei=ds.toString,C=Pn||function(r){return ei.call(r)==="[object Array]"},Ce=r=>typeof r=="function",H=r=>r===Object(r)&&!C(r),Je=r=>{if(H(r)){for(var e in r)if(ps.call(r,e))return!1;return!0}return!1},_=r=>r===void 0,U=r=>ei.call(r)=="[object String]",Pi=r=>U(r)&&r.trim().length===0,oe=r=>r===null,R=r=>_(r)||oe(r),Ee=r=>ei.call(r)=="[object Number]"&&r==r,We=r=>Ee(r)&&r>0,we=r=>ei.call(r)==="[object Boolean]",Fn=r=>r instanceof FormData,$n=r=>F(kn,r);function Fi(r){return r===null||typeof r!="object"}function Nt(r,e){return Object.prototype.toString.call(r)==="[object "+e+"]"}function gs(r){return!_(Event)&&(function(e,t){try{return e instanceof t}catch{return!1}})(r,Event)}var Rn=[!0,"true",1,"1","yes"],ni=r=>F(Rn,r),In=[!1,"false",0,"0","no"];function de(r,e,t,i,s){return e>t&&(i.warn("min cannot be greater than max."),e=t),Ee(r)?r>t?(i.warn(" cannot be greater than max: "+t+". Using max value instead."),t):r<e?(i.warn(" cannot be less than min: "+e+". Using min value instead."),e):r:(i.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+s),de(s||t,e,t,i))}class Cn{constructor(e){this.t={},this.i=e.i,this.o=de(e.bucketSize,0,100,e.h),this.m=de(e.refillRate,0,this.o,e.h),this.$=de(e.refillInterval,0,864e5,e.h)}S(e,t){var i=t-e.lastAccess,s=Math.floor(i/this.$);if(s>0){var n=s*this.m;e.tokens=Math.min(e.tokens+n,this.o),e.lastAccess=e.lastAccess+s*this.$}}consumeRateLimit(e){var t,i=Date.now(),s=String(e),n=this.t[s];return n?this.S(n,i):(n={tokens:this.o,lastAccess:i},this.t[s]=n),n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.i)==null||t.call(this,e)),n.tokens===0)}stop(){this.t={}}}var ne="Mobile",jt="iOS",be="Android",xt="Tablet",fs=be+" "+xt,vs="iPad",_s="Apple",ms=_s+" Watch",kt="Safari",Qe="BlackBerry",ys="Samsung",bs=ys+"Browser",ws=ys+" Internet",je="Chrome",Tn=je+" OS",Es=je+" "+jt,Ji="Internet Explorer",xs=Ji+" "+ne,Xi="Opera",On=Xi+" Mini",Ki="Edge",ks="Microsoft "+Ki,Ke="Firefox",Ss=Ke+" "+jt,St="Nintendo",Pt="PlayStation",Ze="Xbox",Ps=be+" "+ne,Fs=ne+" "+kt,pt="Windows",$i=pt+" Phone",fr="Nokia",Ri="Ouya",$s="Generic",Mn=$s+" "+ne.toLowerCase(),Rs=$s+" "+xt.toLowerCase(),Ii="Konqueror",J="(\\d+(\\.\\d+)?)",ai=new RegExp("Version/"+J),An=new RegExp(Ze,"i"),Dn=new RegExp(Pt+" \\w+","i"),Ln=new RegExp(St+" \\w+","i"),Zi=new RegExp(Qe+"|PlayBook|BB10","i"),Nn={"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"},Ct,vr,oi,jn=(r,e)=>e&&F(e,_s)||(function(t){return F(t,kt)&&!F(t,je)&&!F(t,be)})(r),Is=function(r,e){return e=e||"",F(r," OPR/")&&F(r,"Mini")?On:F(r," OPR/")?Xi:Zi.test(r)?Qe:F(r,"IE"+ne)||F(r,"WPDesktop")?xs:F(r,bs)?ws:F(r,Ki)||F(r,"Edg/")?ks:F(r,"FBIOS")?"Facebook "+ne:F(r,"UCWEB")||F(r,"UCBrowser")?"UC Browser":F(r,"CriOS")?Es:F(r,"CrMo")||F(r,je)?je:F(r,be)&&F(r,kt)?Ps:F(r,"FxiOS")?Ss:F(r.toLowerCase(),Ii.toLowerCase())?Ii:jn(r,e)?F(r,ne)?Fs:kt:F(r,Ke)?Ke:F(r,"MSIE")||F(r,"Trident/")?Ji:F(r,"Gecko")?Ke:""},qn={[xs]:[new RegExp("rv:"+J)],[ks]:[new RegExp(Ki+"?\\/"+J)],[je]:[new RegExp("("+je+"|CrMo)\\/"+J)],[Es]:[new RegExp("CriOS\\/"+J)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+J)],[kt]:[ai],[Fs]:[ai],[Xi]:[new RegExp("(Opera|OPR)\\/"+J)],[Ke]:[new RegExp(Ke+"\\/"+J)],[Ss]:[new RegExp("FxiOS\\/"+J)],[Ii]:[new RegExp("Konqueror[:/]?"+J,"i")],[Qe]:[new RegExp(Qe+" "+J),ai],[Ps]:[new RegExp("android\\s"+J,"i")],[ws]:[new RegExp(bs+"\\/"+J)],[Ji]:[new RegExp("(rv:|MSIE )"+J)],Mozilla:[new RegExp("rv:"+J)]},Hn=function(r,e){var t=Is(r,e),i=qn[t];if(_(i))return null;for(var s=0;s<i.length;s++){var n=i[s],a=r.match(n);if(a)return parseFloat(a[a.length-2])}return null},_r=[[new RegExp(Ze+"; "+Ze+" (.*?)[);]","i"),r=>[Ze,r&&r[1]||""]],[new RegExp(St,"i"),[St,""]],[new RegExp(Pt,"i"),[Pt,""]],[Zi,[Qe,""]],[new RegExp(pt,"i"),(r,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[$i,""];if(new RegExp(ne).test(e)&&!/IEMobile\b/.test(e))return[pt+" "+ne,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var i=t[1],s=Nn[i]||"";return/arm/i.test(e)&&(s="RT"),[pt,s]}return[pt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,r=>{if(r&&r[3]){var e=[r[3],r[4],r[5]||"0"];return[jt,e.join(".")]}return[jt,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,r=>{var e="";return r&&r.length>=3&&(e=_(r[2])?r[3]:r[2]),["watchOS",e]}],[new RegExp("("+be+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+be+")","i"),r=>{if(r&&r[2]){var e=[r[2],r[3],r[4]||"0"];return[be,e.join(".")]}return[be,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,r=>{var e=["Mac OS X",""];if(r&&r[1]){var t=[r[1],r[2],r[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Tn,""]],[/Linux|debian/i,["Linux",""]]],mr=function(r){return Ln.test(r)?St:Dn.test(r)?Pt:An.test(r)?Ze:new RegExp(Ri,"i").test(r)?Ri:new RegExp("("+$i+"|WPDesktop)","i").test(r)?$i:/iPad/.test(r)?vs:/iPod/.test(r)?"iPod Touch":/iPhone/.test(r)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(r)?ms:Zi.test(r)?Qe:/(kobo)\s(ereader|touch)/i.test(r)?"Kobo":new RegExp(fr,"i").test(r)?fr:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(r)||/(kf[a-z]+)( bui|\)).+silk\//i.test(r)?"Kindle Fire":/(Android|ZTE)/i.test(r)?new RegExp(ne).test(r)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(r)||/pixel[\daxl ]{1,6}/i.test(r)&&!/pixel c/i.test(r)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(r)||/lmy47v/i.test(r)&&!/QTAQZ3/i.test(r)?be:fs:new RegExp("(pda|"+ne+")","i").test(r)?Mn:new RegExp(xt,"i").test(r)&&!new RegExp(xt+" pc","i").test(r)?Rs:""},Un=r=>r instanceof Error;function Bn(r){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return oi&&t.length===vr||(vr=t.length,oi=t.reduce(((i,s)=>{Ct||(Ct={});var n=Ct[s];if(n)i[n[0]]=n[1];else for(var a=r(s),o=a.length-1;o>=0;o--){var l=a[o],c=l==null?void 0:l.filename,u=e[s];if(c&&u){i[c]=u,Ct[s]=[c,u];break}}return i}),{})),oi}}class Gn{constructor(e,t,i){i===void 0&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){t===void 0&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},s=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),a=this.parseStacktrace(s,n);return{$exception_list:this.convertToExceptionList(a,i),$exception_level:"error"}}modifyFrames(e){var t=this;return Ye((function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&C(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,s;return e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(s=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),w({},e,{cause:i,stack:s})}applyChunkIds(e,t){return e.map((i=>(i.filename&&t&&(i.chunk_id=t[i.filename]),i)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return Ye((function*(){var i=e;for(var s of t.modifiers)i=yield s(i);return i}))()}convertToExceptionList(e,t){var i,s,n,a={type:e.type,value:e.value,mechanism:{type:(i=t.type)!==null&&i!==void 0?i:"generic",handled:(s=t.handled)===null||s===void 0||s,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(a.stacktrace={type:"raw",frames:e.stack});var o=[a];return e.cause!=null&&o.push(...this.convertToExceptionList(e.cause,w({},t,{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:Bn(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,i){i===void 0&&(i=0);var s=(n,a)=>{if(a<=4){var o=this.buildCoercingContext(e,t,a);return this.applyCoercers(n,o)}};return w({},t,{syntheticException:i==0?t.syntheticException:void 0,mechanism:e,apply:n=>s(n,i),next:n=>s(n,i+1)})}}var et="?";function Ci(r,e,t,i,s){var n={platform:r,filename:e,function:t==="<anonymous>"?et:t,in_app:!0};return _(i)||(n.lineno=i),_(s)||(n.colno=s),n}var Cs=(r,e)=>{var t=r.indexOf("safari-extension")!==-1,i=r.indexOf("safari-web-extension")!==-1;return t||i?[r.indexOf("@")!==-1?r.split("@")[0]:et,t?"safari-extension:"+e:"safari-web-extension:"+e]:[r,e]},Vn=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Wn=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,zn=/\((\S*)(?::(\d+))(?::(\d+))\)/,Yn=(r,e)=>{var t=Vn.exec(r);if(t){var[,i,s,n]=t;return Ci(e,i,et,+s,+n)}var a=Wn.exec(r);if(a){if(a[2]&&a[2].indexOf("eval")===0){var o=zn.exec(a[2]);o&&(a[2]=o[1],a[3]=o[2],a[4]=o[3])}var[l,c]=Cs(a[1]||et,a[2]);return Ci(e,c,l,a[3]?+a[3]:void 0,a[4]?+a[4]:void 0)}},Jn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Xn=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Kn=(r,e)=>{var t=Jn.exec(r);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=Xn.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var s=t[3],n=t[1]||et;return[n,s]=Cs(n,s),Ci(e,s,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},yr=/\(error: (.*)\)/,br=50;function Zn(){return(function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return function(s,n){n===void 0&&(n=0);for(var a=[],o=s.split(`
|
|
2
|
+
`),l=n;l<o.length;l++){var c=o[l];if(!(c.length>1024)){var u=yr.test(c)?c.replace(yr,"$1"):c;if(!u.match(/\S*Error: /)){for(var h of t){var p=h(u,r);if(p){a.push(p);break}}if(a.length>=br)break}}}return(function(g){if(!g.length)return[];var f=Array.from(g);return f.reverse(),f.slice(0,br).map((v=>{return w({},v,{filename:v.filename||(m=f,m[m.length-1]||{}).filename,function:v.function||et});var m}))})(a)}})("web:javascript",Yn,Kn)}class Qn{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=U(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Nt(e,"DOMException")}isDOMError(e){return Nt(e,"DOMError")}}class ea{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return i.error&&typeof i.error.message=="string"?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}}class ta{constructor(){}match(e){return Nt(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var i,s=t.apply(e.error);return s||{type:"ErrorEvent",value:e.message,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}}var ia=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ra{match(e){return typeof e=="string"}coerce(e,t){var i,[s,n]=this.getInfos(e);return{type:s??"Error",value:n??e,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,s=e.match(ia);return s&&(t=s[1],i=s[2]),[t,i]}}var sa=["fatal","error","warning","log","info","debug"];function Ts(r,e){e===void 0&&(e=40);var t=Object.keys(r);if(t.sort(),!t.length)return"[object has no keys]";for(var i=t.length;i>0;i--){var s=t.slice(0,i).join(", ");if(!(s.length>e))return i===t.length||s.length<=e?s:s.slice(0,e)+"..."}return""}class na{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var i,s=this.getErrorPropertyFromObject(e);return s?t.apply(s):{type:this.getType(e),value:this.getValue(e),stack:(i=t.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return gs(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var i=this.getObjectClassName(e);return(i&&i!=="Object"?"'"+i+"'":"Object")+" captured as exception with keys: "+Ts(e)}isSeverityLevel(e){return U(e)&&!Pi(e)&&sa.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(Un(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}}class aa{match(e){return gs(e)}coerce(e,t){var i,s=e.constructor.name;return{type:s,value:s+" captured as exception with keys: "+Ts(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}}class oa{match(e){return Fi(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}}class la{match(e){return Nt(e,"PromiseRejectionEvent")}coerce(e,t){var i,s=this.getUnhandledRejectionReason(e);return Fi(s)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(s),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}:t.apply(s)}getUnhandledRejectionReason(e){if(Fi(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}}var Os=function(r,e){var{debugEnabled:t}=e===void 0?{}:e,i={k:function(s){if(d&&(ve.DEBUG||E.POSTHOG_DEBUG||t)&&!_(d.console)&&d.console){for(var n=("__rrweb_original__"in d.console[s])?d.console[s].__rrweb_original__:d.console[s],a=arguments.length,o=new Array(a>1?a-1:0),l=1;l<a;l++)o[l-1]=arguments[l];n(r,...o)}},info:function(){for(var s=arguments.length,n=new Array(s),a=0;a<s;a++)n[a]=arguments[a];i.k("log",...n)},warn:function(){for(var s=arguments.length,n=new Array(s),a=0;a<s;a++)n[a]=arguments[a];i.k("warn",...n)},error:function(){for(var s=arguments.length,n=new Array(s),a=0;a<s;a++)n[a]=arguments[a];i.k("error",...n)},critical:function(){for(var s=arguments.length,n=new Array(s),a=0;a<s;a++)n[a]=arguments[a]},uninitializedWarning:s=>{i.error("You must initialize PostHog before calling "+s)},createLogger:(s,n)=>Os(r+" "+s,n)};return i},b=Os("[PostHog.js]"),L=b.createLogger,ua=L("[ExternalScriptsLoader]"),wr=(r,e,t)=>{if(r.config.disable_external_dependency_loading)return ua.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var i=y==null?void 0:y.querySelectorAll("script");if(i){for(var s,n=function(){if(i[a].src===e){var l=i[a];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(c=>{l.__posthog_loading_callback_fired=!0,t(void 0,c)})),l.onerror=c=>t(c),{v:void 0})}},a=0;a<i.length;a++)if(s=n())return s.v}var o=()=>{if(!y)return t("document not found");var l=y.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,t(void 0,h)},l.onerror=h=>t(h),r.config.prepare_external_dependency_script&&(l=r.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(r.config.external_scripts_inject_target==="head")y.head.appendChild(l);else{var c,u=y.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):y.body.appendChild(l)}};y!=null&&y.body?o():y==null||y.addEventListener("DOMContentLoaded",o)};E.__PosthogExtensions__=E.__PosthogExtensions__||{},E.__PosthogExtensions__.loadExternalDependency=(r,e,t)=>{var i="/static/"+e+".js?v="+r.version;if(e==="remote-config"&&(i="/array/"+r.config.token+"/config.js"),e==="toolbar"){var s=3e5;i=i+"&t="+Math.floor(Date.now()/s)*s}var n=r.requestRouter.endpointFor("assets",i);wr(r,n,t)},E.__PosthogExtensions__.loadSiteApp=(r,e,t)=>{var i=r.requestRouter.endpointFor("api",e);wr(r,i,t)};var qt={};function Te(r,e,t){if(C(r)){if(cr&&r.forEach===cr)r.forEach(e,t);else if("length"in r&&r.length===+r.length){for(var i=0,s=r.length;i<s;i++)if(i in r&&e.call(t,r[i],i)===qt)return}}}function M(r,e,t){if(!R(r)){if(C(r))return Te(r,e,t);if(Fn(r)){for(var i of r.entries())if(e.call(t,i[1],i[0])===qt)return}else for(var s in r)if(ps.call(r,s)&&e.call(t,r[s],s)===qt)return}}var N=function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return Te(t,(function(s){for(var n in s)s[n]!==void 0&&(r[n]=s[n])})),r},it=function(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;i<e;i++)t[i-1]=arguments[i];return Te(t,(function(s){Te(s,(function(n){r.push(n)}))})),r};function Dt(r){for(var e=Object.keys(r),t=e.length,i=new Array(t);t--;)i[t]=[e[t],r[e[t]]];return i}var Er=function(r){try{return r()}catch{return}},ca=function(r){return function(){try{for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return r.apply(this,t)}catch(s){b.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),b.critical(s)}}},Qi=function(r){var e={};return M(r,(function(t,i){(U(t)&&t.length>0||Ee(t))&&(e[i]=t)})),e};function ha(r,e){return t=r,i=n=>U(n)&&!oe(e)?n.slice(0,e):n,s=new Set,(function n(a,o){return a!==Object(a)?i?i(a,o):a:s.has(a)?void 0:(s.add(a),C(a)?(l=[],Te(a,(c=>{l.push(n(c))}))):(l={},M(a,((c,u)=>{s.has(c)||(l[u]=n(c,u))}))),l);var l})(t);var t,i,s}var da=["herokuapp.com","vercel.app","netlify.app"];function pa(r){var e=r==null?void 0:r.hostname;if(!U(e))return!1;var t=e.split(".").slice(-2).join(".");for(var i of da)if(t===i)return!1;return!0}function Ms(r,e){for(var t=0;t<r.length;t++)if(e(r[t]))return r[t]}function j(r,e,t,i){var{capture:s=!1,passive:n=!0}=i??{};r==null||r.addEventListener(e,t,{capture:s,passive:n})}var As="$people_distinct_id",gt="__alias",ft="__timers",xr="$autocapture_disabled_server_side",Ti="$heatmaps_enabled_server_side",kr="$exception_capture_enabled_server_side",Oi="$error_tracking_suppression_rules",Sr="$error_tracking_capture_extension_exceptions",Pr="$web_vitals_enabled_server_side",Ds="$dead_clicks_enabled_server_side",Fr="$product_tours_enabled_server_side",$r="$web_vitals_allowed_metrics",li="$session_recording_remote_config",Ht="$sesid",Ls="$session_is_sampled",Xe="$enabled_feature_flags",vt="$early_access_features",Mi="$feature_flag_details",_t="$stored_person_properties",Ne="$stored_group_properties",Ai="$surveys",Ut="$flag_call_reported",Di="$feature_flag_errors",_e="$user_state",Li="$client_session_props",Ni="$capture_rate_limit",ji="$initial_campaign_params",qi="$initial_referrer_info",Bt="$initial_person_info",Gt="$epp",Ns="__POSTHOG_TOOLBAR__",st="$posthog_cookieless",ga=[As,gt,"__cmpns",ft,"$session_recording_enabled_server_side",Ti,Ht,Xe,Oi,_e,vt,Mi,Ne,_t,Ai,Ut,Di,Li,Ni,ji,qi,Gt,Bt,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function Rr(r){return r instanceof Element&&(r.id===Ns||!(r.closest==null||!r.closest(".toolbar-global-fade-container")))}function ti(r){return!!r&&r.nodeType===1}function Oe(r,e){return!!r&&!!r.tagName&&r.tagName.toLowerCase()===e.toLowerCase()}function js(r){return!!r&&r.nodeType===3}function qs(r){return!!r&&r.nodeType===11}function er(r){return r?Qt(r).split(/\s+/):[]}function Ir(r){var e=d==null?void 0:d.location.href;return!!(e&&r&&r.some((t=>e.match(t))))}function Vt(r){var e="";switch(typeof r.className){case"string":e=r.className;break;case"object":e=(r.className&&"baseVal"in r.className?r.className.baseVal:null)||r.getAttribute("class")||"";break;default:e=""}return er(e)}function Hs(r){return R(r)?null:Qt(r).split(/(\s+)/).filter((e=>Ft(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function $t(r){var e="";return Hi(r)&&!Ws(r)&&r.childNodes&&r.childNodes.length&&M(r.childNodes,(function(t){var i;js(t)&&t.textContent&&(e+=(i=Hs(t.textContent))!==null&&i!==void 0?i:"")})),Qt(e)}function Us(r){return _(r.target)?r.srcElement||null:(e=r.target)!=null&&e.shadowRoot?r.composedPath()[0]||null:r.target||null;var e}var tr=["a","button","form","input","select","textarea","label"];function Bs(r,e){if(_(e))return!0;var t,i=function(n){if(e.some((a=>n.matches(a))))return{v:!0}};for(var s of r)if(t=i(s))return t.v;return!1}function Gs(r){var e=r.parentNode;return!(!e||!ti(e))&&e}var fa=["next","previous","prev",">","<"],Cr=10,Tr=[".ph-no-rageclick",".ph-no-capture"];function va(r,e){if(!d||ir(r))return!1;var t,i,s;if(we(e)?(t=!!e&&Tr,i=void 0):(t=(s=e==null?void 0:e.css_selector_ignorelist)!==null&&s!==void 0?s:Tr,i=e==null?void 0:e.content_ignorelist),t===!1)return!1;var{targetElementList:n}=Vs(r,!1);return!(function(a,o){if(a===!1||_(a))return!1;var l;if(a===!0)l=fa;else{if(!C(a))return!1;if(a.length>Cr)return b.error("[PostHog] content_ignorelist array cannot exceed "+Cr+" items. Use css_selector_ignorelist for more complex matching."),!1;l=a.map((c=>c.toLowerCase()))}return o.some((c=>{var{safeText:u,ariaLabel:h}=c;return l.some((p=>u.includes(p)||h.includes(p)))}))})(i,n.map((a=>{var o;return{safeText:$t(a).toLowerCase(),ariaLabel:((o=a.getAttribute("aria-label"))==null?void 0:o.toLowerCase().trim())||""}})))&&!Bs(n,t)}var ir=r=>!r||Oe(r,"html")||!ti(r),Vs=(r,e)=>{if(!d||ir(r))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,i=[r],s=r;s.parentNode&&!Oe(s,"body");)if(qs(s.parentNode))i.push(s.parentNode.host),s=s.parentNode.host;else{var n=Gs(s);if(!n)break;if(e||tr.indexOf(n.tagName.toLowerCase())>-1)t=!0;else{var a=d.getComputedStyle(n);a&&a.getPropertyValue("cursor")==="pointer"&&(t=!0)}i.push(n),s=n}return{parentIsUsefulElement:t,targetElementList:i}};function _a(r,e,t,i,s){var n,a,o,l;if(t===void 0&&(t=void 0),!d||ir(r)||(n=t)!=null&&n.url_allowlist&&!Ir(t.url_allowlist)||(a=t)!=null&&a.url_ignorelist&&Ir(t.url_ignorelist))return!1;if((o=t)!=null&&o.dom_event_allowlist){var c=t.dom_event_allowlist;if(c&&!c.some((f=>e.type===f)))return!1}var{parentIsUsefulElement:u,targetElementList:h}=Vs(r,i);if(!(function(f,v){var m=v==null?void 0:v.element_allowlist;if(_(m))return!0;var S,k=function($){if(m.some((x=>$.tagName.toLowerCase()===x)))return{v:!0}};for(var I of f)if(S=k(I))return S.v;return!1})(h,t)||!Bs(h,(l=t)==null?void 0:l.css_selector_allowlist))return!1;var p=d.getComputedStyle(r);if(p&&p.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var g=r.tagName.toLowerCase();switch(g){case"html":return!1;case"form":return(s||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(e.type)>=0;default:return u?(s||["click"]).indexOf(e.type)>=0:(s||["click"]).indexOf(e.type)>=0&&(tr.indexOf(g)>-1||r.getAttribute("contenteditable")==="true")}}function Hi(r){for(var e=r;e.parentNode&&!Oe(e,"body");e=e.parentNode){var t=Vt(e);if(F(t,"ph-sensitive")||F(t,"ph-no-capture"))return!1}if(F(Vt(r),"ph-include"))return!0;var i=r.type||"";if(U(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var s=r.name||r.id||"";return!(U(s)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g,"")))}function Ws(r){return!!(Oe(r,"input")&&!["button","checkbox","submit","reset"].includes(r.type)||Oe(r,"select")||Oe(r,"textarea")||r.getAttribute("contenteditable")==="true")}var zs="(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})",ma=new RegExp("^(?:"+zs+")$"),ya=new RegExp(zs),Ys="\\d{3}-?\\d{2}-?\\d{4}",ba=new RegExp("^("+Ys+")$"),wa=new RegExp("("+Ys+")");function Ft(r,e){return e===void 0&&(e=!0),!(R(r)||U(r)&&(r=Qt(r),(e?ma:ya).test((r||"").replace(/[- ]/g,""))||(e?ba:wa).test(r)))}function Js(r){var e=$t(r);return Ft(e=(e+" "+Xs(r)).trim())?e:""}function Xs(r){var e="";return r&&r.childNodes&&r.childNodes.length&&M(r.childNodes,(function(t){var i;if(t&&((i=t.tagName)==null?void 0:i.toLowerCase())==="span")try{var s=$t(t);e=(e+" "+s).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+Xs(t)).trim())}catch(n){b.error("[AutoCapture]",n)}})),e}function Ea(r){return(function(e){var t=e.map((i=>{var s,n,a="";if(i.tag_name&&(a+=i.tag_name),i.attr_class)for(var o of(i.attr_class.sort(),i.attr_class))a+="."+o.replace(/"/g,"");var l=w({},i.text?{text:i.text}:{},{"nth-child":(s=i.nth_child)!==null&&s!==void 0?s:0,"nth-of-type":(n=i.nth_of_type)!==null&&n!==void 0?n:0},i.href?{href:i.href}:{},i.attr_id?{attr_id:i.attr_id}:{},i.attributes),c={};return Dt(l).sort(((u,h)=>{var[p]=u,[g]=h;return p.localeCompare(g)})).forEach((u=>{var[h,p]=u;return c[Or(h.toString())]=Or(p.toString())})),a+=":",a+=Dt(c).map((u=>{var[h,p]=u;return h+'="'+p+'"'})).join("")}));return t.join(";")})((function(e){return e.map((t=>{var i,s,n={text:(i=t.$el_text)==null?void 0:i.slice(0,400),tag_name:t.tag_name,href:(s=t.attr__href)==null?void 0:s.slice(0,2048),attr_class:xa(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Dt(t).filter((a=>{var[o]=a;return o.indexOf("attr__")===0})).forEach((a=>{var[o,l]=a;return n.attributes[o]=l})),n}))})(r))}function Or(r){return r.replace(/"|\\"/g,'\\"')}function xa(r){var e=r.attr__class;return e?C(e)?e:er(e):void 0}class Ks{constructor(e){this.disabled=e===!1;var t=H(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<this.thresholdPx&&i-s.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var Wt=r=>{var e=y==null?void 0:y.createElement("a");return _(e)?null:(e.href=r,e)},ka=function(r,e){var t,i;e===void 0&&(e="&");var s=[];return M(r,(function(n,a){_(n)||_(a)||a==="undefined"||(t=encodeURIComponent((o=>o instanceof File)(n)?n.name:n.toString()),i=encodeURIComponent(a),s[s.length]=i+"="+t)})),s.join(e)},zt=function(r,e){for(var t,i=((r.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;s<i.length;s++){var n=i[s].split("=");if(n[0]===e){t=n;break}}if(!C(t)||t.length<2)return"";var a=t[1];try{a=decodeURIComponent(a)}catch{b.error("Skipping decoding for malformed query param: "+a)}return a.replace(/\+/g," ")},Rt=function(r,e,t){if(!r||!e||!e.length)return r;for(var i=r.split("#"),s=i[0]||"",n=i[1],a=s.split("?"),o=a[1],l=a[0],c=(o||"").split("&"),u=[],h=0;h<c.length;h++){var p=c[h].split("=");C(p)&&(e.includes(p[0])?u.push(p[0]+"="+t):u.push(c[h]))}var g=l;return o!=null&&(g+="?"+u.join("&")),n!=null&&(g+="#"+n),g},Yt=function(r,e){var t=r.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},ui="$copy_autocapture",Mr=L("[AutoCapture]");function ci(r,e){return e.length>r?e.slice(0,r)+"...":e}function Sa(r){if(r.previousElementSibling)return r.previousElementSibling;var e=r;do e=e.previousSibling;while(e&&!ti(e));return e}function Pa(r,e,t,i){var s=r.tagName.toLowerCase(),n={tag_name:s};tr.indexOf(s)>-1&&!t&&(s.toLowerCase()==="a"||s.toLowerCase()==="button"?n.$el_text=ci(1024,Js(r)):n.$el_text=ci(1024,$t(r)));var a=Vt(r);a.length>0&&(n.classes=a.filter((function(u){return u!==""}))),M(r.attributes,(function(u){var h;if((!Ws(r)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(i==null||!i.includes(u.name))&&!e&&Ft(u.value)&&(h=u.name,!U(h)||h.substring(0,10)!=="_ngcontent"&&h.substring(0,7)!=="_nghost")){var p=u.value;u.name==="class"&&(p=er(p).join(" ")),n["attr__"+u.name]=ci(1024,p)}}));for(var o=1,l=1,c=r;c=Sa(c);)o++,c.tagName===r.tagName&&l++;return n.nth_child=o,n.nth_of_type=l,n}function Fa(r,e){for(var t,i,{e:s,maskAllElementAttributes:n,maskAllText:a,elementAttributeIgnoreList:o,elementsChainAsString:l}=e,c=[r],u=r;u.parentNode&&!Oe(u,"body");)qs(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var h,p=[],g={},f=!1,v=!1;if(M(c,($=>{var x=Hi($);$.tagName.toLowerCase()==="a"&&(f=$.getAttribute("href"),f=x&&f&&Ft(f)&&f),F(Vt($),"ph-no-capture")&&(v=!0),p.push(Pa($,n,a,o));var q=(function(T){if(!Hi(T))return{};var P={};return M(T.attributes,(function(Z){if(Z.name&&Z.name.indexOf("data-ph-capture-attribute")===0){var W=Z.name.replace("data-ph-capture-attribute-",""),ie=Z.value;W&&ie&&Ft(ie)&&(P[W]=ie)}})),P})($);N(g,q)})),v)return{props:{},explicitNoCapture:v};if(a||(r.tagName.toLowerCase()==="a"||r.tagName.toLowerCase()==="button"?p[0].$el_text=Js(r):p[0].$el_text=$t(r)),f){var m,S;p[0].attr__href=f;var k=(m=Wt(f))==null?void 0:m.host,I=d==null||(S=d.location)==null?void 0:S.host;k&&I&&k!==I&&(h=f)}return{props:N({$event_type:s.type,$ce_version:1},l?{}:{$elements:p},{$elements_chain:Ea(p)},(t=p[0])!=null&&t.$el_text?{$el_text:(i=p[0])==null?void 0:i.$el_text}:{},h&&s.type==="click"?{$external_click_url:h}:{},g)}}class $a{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Ks(e.config.rageclick),this.C=null}get R(){var e,t,i=H(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=(e=i.url_allowlist)==null?void 0:e.map((s=>new RegExp(s))),i.url_ignorelist=(t=i.url_ignorelist)==null?void 0:t.map((s=>new RegExp(s))),i}F(){if(this.isBrowserSupported()){if(d&&y){var e=i=>{i=i||(d==null?void 0:d.event);try{this.O(i)}catch(s){Mr.error("Failed to capture event",s)}};if(j(y,"submit",e,{capture:!0}),j(y,"change",e,{capture:!0}),j(y,"click",e,{capture:!0}),this.R.capture_copied_text){var t=i=>{i=i||(d==null?void 0:d.event),this.O(i,ui)};j(y,"copy",t,{capture:!0}),j(y,"cut",t,{capture:!0})}}}else Mr.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.I=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[xr]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,i=[];return(t=this.C)==null||t.forEach((s=>{var n=y==null?void 0:y.querySelectorAll(s);n==null||n.forEach((a=>{e===a&&i.push(s)}))})),i}get isEnabled(){var e,t,i=(e=this.instance.persistence)==null?void 0:e.props[xr],s=this.T;if(oe(s)&&!we(i)&&!this.instance.M())return!1;var n=(t=this.T)!==null&&t!==void 0?t:!!i;return!!this.instance.config.autocapture&&!n}O(e,t){if(t===void 0&&(t="$autocapture"),this.isEnabled){var i,s=Us(e);js(s)&&(s=s.parentNode||null),t==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(i=this.rageclicks)!=null&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&va(s,this.instance.config.rageclick)&&this.O(e,"$rageclick");var n=t===ui;if(s&&_a(s,e,this.R,n,n?["copy","cut"]:void 0)){var{props:a,explicitNoCapture:o}=Fa(s,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(o)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(a.$element_selectors=l),t===ui){var c,u=Hs(d==null||(c=d.getSelection())==null?void 0:c.toString()),h=e.type||"clipboard";if(!u)return!1;a.$selected_content=u,a.$copy_type=h}return this.instance.capture(t,a),!0}}}isBrowserSupported(){return Ce(y==null?void 0:y.querySelectorAll)}}Math.trunc||(Math.trunc=function(r){return r<0?Math.ceil(r):Math.floor(r)}),Number.isInteger||(Number.isInteger=function(r){return Ee(r)&&isFinite(r)&&Math.floor(r)===r});var Ar="0123456789abcdef";class Jt{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,s){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||e<0||t<0||i<0||s<0||e>0xffffffffffff||t>4095||i>1073741823||s>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=s>>>24,n[13]=s>>>16,n[14]=s>>>8,n[15]=s,new Jt(n)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Ar.charAt(this.bytes[t]>>>4)+Ar.charAt(15&this.bytes[t]),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Jt(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(i!==0)return Math.sign(i)}return 0}}class Ra{constructor(){this.A=0,this.j=0,this.D=new Ia}generate(){var e=this.generateOrAbort();if(_(e)){this.A=0;var t=this.generateOrAbort();if(_(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.j++,this.j>4398046511103&&(this.A++,this.L())}return Jt.fromFieldsV7(this.A,Math.trunc(this.j/Math.pow(2,30)),this.j&Math.pow(2,30)-1,this.D.nextUint32())}L(){this.j=1024*this.D.nextUint32()+(1023&this.D.nextUint32())}}var Dr,Zs=r=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<r.length;e++)r[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return r};d&&!_(d.crypto)&&crypto.getRandomValues&&(Zs=r=>crypto.getRandomValues(r));class Ia{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(Zs(this.N),this.U=0),this.N[this.U++]}}var Ie=()=>Ca().toString(),Ca=()=>(Dr||(Dr=new Ra)).generate(),nt="",Ta=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Oa(r,e){if(e){var t=(function(s,n){if(n===void 0&&(n=y),nt)return nt;if(!n||["localhost","127.0.0.1"].includes(s))return"";for(var a=s.split("."),o=Math.min(a.length,8),l="dmn_chk_"+Ie();!nt&&o--;){var c=a.slice(o).join("."),u=l+"=1;domain=."+c+";path=/";n.cookie=u+";max-age=3",n.cookie.includes(l)&&(n.cookie=u+";max-age=0",nt=c)}return nt})(r);if(!t){var i=(s=>{var n=s.match(Ta);return n?n[0]:""})(r);i!==t&&b.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}var he={H:()=>!!y,B:function(r){b.error("cookieStore error: "+r)},q:function(r){if(y){try{for(var e=r+"=",t=y.cookie.split(";").filter((n=>n.length)),i=0;i<t.length;i++){for(var s=t[i];s.charAt(0)==" ";)s=s.substring(1,s.length);if(s.indexOf(e)===0)return decodeURIComponent(s.substring(e.length,s.length))}}catch{}return null}},W:function(r){var e;try{e=JSON.parse(he.q(r))||{}}catch{}return e},G:function(r,e,t,i,s){if(y)try{var n="",a="",o=Oa(y.location.hostname,i);if(t){var l=new Date;l.setTime(l.getTime()+24*t*60*60*1e3),n="; expires="+l.toUTCString()}s&&(a="; secure");var c=r+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+o+a;return c.length>3686.4&&b.warn("cookieStore warning: large cookie, len="+c.length),y.cookie=c,c}catch{return}},V:function(r,e){if(y!=null&&y.cookie)try{he.G(r,"",-1,e)}catch{return}}},hi=null,D={H:function(){if(!oe(hi))return hi;var r=!0;if(_(d))r=!1;else try{var e="__mplssupport__";D.G(e,"xyz"),D.q(e)!=='"xyz"'&&(r=!1),D.V(e)}catch{r=!1}return r||b.error("localStorage unsupported; falling back to cookie store"),hi=r,r},B:function(r){b.error("localStorage error: "+r)},q:function(r){try{return d==null?void 0:d.localStorage.getItem(r)}catch(e){D.B(e)}return null},W:function(r){try{return JSON.parse(D.q(r))||{}}catch{}return null},G:function(r,e){try{d==null||d.localStorage.setItem(r,JSON.stringify(e))}catch(t){D.B(t)}},V:function(r){try{d==null||d.localStorage.removeItem(r)}catch(e){D.B(e)}}},Ma=["$device_id","distinct_id",Ht,Ls,Gt,Bt],Tt={},Aa={H:function(){return!0},B:function(r){b.error("memoryStorage error: "+r)},q:function(r){return Tt[r]||null},W:function(r){return Tt[r]||null},G:function(r,e){Tt[r]=e},V:function(r){delete Tt[r]}},Ae=null,B={H:function(){if(!oe(Ae))return Ae;if(Ae=!0,_(d))Ae=!1;else try{var r="__support__";B.G(r,"xyz"),B.q(r)!=='"xyz"'&&(Ae=!1),B.V(r)}catch{Ae=!1}return Ae},B:function(r){b.error("sessionStorage error: ",r)},q:function(r){try{return d==null?void 0:d.sessionStorage.getItem(r)}catch(e){B.B(e)}return null},W:function(r){try{return JSON.parse(B.q(r))||null}catch{}return null},G:function(r,e){try{d==null||d.sessionStorage.setItem(r,JSON.stringify(e))}catch(t){B.B(t)}},V:function(r){try{d==null||d.sessionStorage.removeItem(r)}catch(e){B.B(e)}}},me=(function(r){return r[r.PENDING=-1]="PENDING",r[r.DENIED=0]="DENIED",r[r.GRANTED=1]="GRANTED",r})({});class Da{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?me.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===me.DENIED||this.consent===me.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===me.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return ni(e)?me.GRANTED:F(In,e)?me.DENIED:me.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?D:he;var t=e==="localStorage"?he:D;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(ni(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!Ms([te==null?void 0:te.doNotTrack,te==null?void 0:te.msDoNotTrack,E.doNotTrack],(e=>ni(e)))}}var Ot=L("[Dead Clicks]"),La=()=>!0,Na=r=>{var e,t=!((e=r.instance.persistence)==null||!e.get_property(Ds)),i=r.instance.config.capture_dead_clicks;return we(i)?i:!!H(i)||t};class Qs{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Ds]:e==null?void 0:e.captureDeadClicks}),this.startIfEnabledOrStop()}startIfEnabledOrStop(){this.isEnabled(this)?this.it((()=>{this.et()})):this.stop()}it(e){var t,i;(t=E.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(i=E.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(s=>{s?Ot.error("failed to load script",s):e()}))}et(){var e;if(y){if(!this.tt&&(e=E.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=H(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=E.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(y),Ot.info("starting...")}}else Ot.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Ot.info("stopping..."))}}var at=L("[ExceptionAutocapture]");class ja{constructor(e){var t,i,s;this.rt=()=>{var n;if(d&&this.isEnabled&&(n=E.__PosthogExtensions__)!=null&&n.errorWrappingFunctions){var a=E.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=E.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=E.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=a(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=o(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=l(this.captureException.bind(this)))}catch(c){at.error("failed to start",c),this.ut()}}},this._instance=e,this.ht=!((t=this._instance.persistence)==null||!t.props[kr]),this.dt=new Cn({refillRate:(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10,refillInterval:1e4,h:at}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return H(e)?t=w({},t,e):(_(e)?this.ht:e)&&(t=w({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(at.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,i;(t=E.__PosthogExtensions__)!=null&&t.errorWrappingFunctions&&e(),(i=E.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"exception-autocapture",(s=>{if(s)return at.error("failed to load script",s);e()}))}ut(){var e,t,i;(e=this.st)==null||e.call(this),this.st=void 0,(t=this.nt)==null||t.call(this),this.nt=void 0,(i=this.ot)==null||i.call(this),this.ot=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[kr]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var t,i,s=(t=e==null||(i=e.$exception_list)==null||(i=i[0])==null?void 0:i.type)!==null&&t!==void 0?t:"Exception";this.dt.consumeRateLimit(s)?at.info("Skipping exception capture because of client rate limiting.",{exception:s}):this._instance.exceptions.sendExceptionEvent(e)}}function Lr(r,e,t){try{if(!(e in r))return()=>{};var i=r[e],s=t(i);return Ce(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),r[e]=s,()=>{r[e]=i}}catch{return()=>{}}}class qa{constructor(e){var t;this._instance=e,this.ct=(d==null||(t=d.location)==null?void 0:t.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(b.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,b.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(d&&d.history){var i=this;(e=d.history.pushState)!=null&&e.__posthog_wrapped__||Lr(d.history,"pushState",(s=>function(n,a,o){s.call(this,n,a,o),i._t("pushState")})),(t=d.history.replaceState)!=null&&t.__posthog_wrapped__||Lr(d.history,"replaceState",(s=>function(n,a,o){s.call(this,n,a,o),i._t("replaceState")})),this.bt()}}_t(e){try{var t,i=d==null||(t=d.location)==null?void 0:t.pathname;if(!i)return;i!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=i}catch(s){b.error("Error capturing "+e+" pageview",s)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};j(d,"popstate",e),this.ft=()=>{d&&d.removeEventListener("popstate",e)}}}}var di=L("[SegmentIntegration]");function Ha(r,e){var t=r.config.segment;if(!t)return e();(function(i,s){var n=i.config.segment;if(!n)return s();var a=l=>{var c=()=>l.anonymousId()||Ie();i.config.get_device_id=c,l.id()&&(i.register({distinct_id:l.id(),$device_id:c()}),i.persistence.set_property(_e,"identified")),s()},o=n.user();"then"in o&&Ce(o.then)?o.then(a):a(o)})(r,(()=>{t.register((i=>{Promise&&Promise.resolve||di.warn("This browser does not have Promise support, and can not use the segment integration");var s=(n,a)=>{if(!a)return n;n.event.userId||n.event.anonymousId===i.get_distinct_id()||(di.info("No userId set, resetting PostHog"),i.reset()),n.event.userId&&n.event.userId!==i.get_distinct_id()&&(di.info("UserId set, identifying with PostHog"),i.identify(n.event.userId));var o=i.calculateEventProperties(a,n.event.properties);return n.event.properties=Object.assign({},o,n.event.properties),n};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:n=>s(n,n.event.event),page:n=>s(n,"$pageview"),identify:n=>s(n,"$identify"),screen:n=>s(n,"$screen")}})(r)).then((()=>{e()}))}))}var en="posthog-js";function tn(r,e){var{organization:t,projectId:i,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:a=!0}=e===void 0?{}:e;return o=>{var l,c,u,h,p;if(!(n==="*"||n.includes(o.level))||!r.__loaded)return o;o.tags||(o.tags={});var g=r.requestRouter.endpointFor("ui","/project/"+r.config.token+"/person/"+r.get_distinct_id());o.tags["PostHog Person URL"]=g,r.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=r.get_session_replay_url({withTimestamp:!0}));var f=((l=o.exception)==null?void 0:l.values)||[],v=f.map((S=>w({},S,{stacktrace:S.stacktrace?w({},S.stacktrace,{type:"raw",frames:(S.stacktrace.frames||[]).map((k=>w({},k,{platform:"web:javascript"})))}):void 0}))),m={$exception_message:((c=f[0])==null?void 0:c.value)||o.message,$exception_type:(u=f[0])==null?void 0:u.type,$exception_level:o.level,$exception_list:v,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:((h=f[0])==null?void 0:h.value)||o.message,$sentry_exception_type:(p=f[0])==null?void 0:p.type,$sentry_tags:o.tags};return t&&i&&(m.$sentry_url=(s||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+o.event_id),a&&r.exceptions.sendExceptionEvent(m),o}}class Ua{constructor(e,t,i,s,n,a){this.name=en,this.setupOnce=function(o){o(tn(e,{organization:t,projectId:i,prefix:s,severityAllowList:n,sendExceptionsToPostHog:a==null||a}))}}}var Ba=d!=null&&d.location?Yt(d.location.hash,"__posthog")||Yt(location.hash,"state"):null,Nr="_postHogToolbarParams",jr=L("[Toolbar]"),Re=(function(r){return r[r.UNINITIALIZED=0]="UNINITIALIZED",r[r.LOADING=1]="LOADING",r[r.LOADED=2]="LOADED",r})(Re||{});class Ga{constructor(e){this.instance=e}yt(e){E.ph_toolbar_state=e}wt(){var e;return(e=E.ph_toolbar_state)!==null&&e!==void 0?e:Re.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(e===void 0&&(e=void 0),t===void 0&&(t=void 0),i===void 0&&(i=void 0),this.instance.config.name&&this.instance.config.name==="ph_toolbar_internal"||!d||!y)return!1;e=e??d.location,i=i??d.history;try{if(!t){try{d.localStorage.setItem("test","test"),d.localStorage.removeItem("test")}catch{return!1}t=d==null?void 0:d.localStorage}var s,n=Ba||Yt(e.hash,"__posthog")||Yt(e.hash,"state"),a=n?Er((()=>JSON.parse(atob(decodeURIComponent(n)))))||Er((()=>JSON.parse(decodeURIComponent(n)))):null;return a&&a.action==="ph_authorize"?((s=a).source="url",s&&Object.keys(s).length>0&&(a.desiredHash?e.hash=a.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((s=JSON.parse(t.getItem(Nr)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token)&&(this.loadToolbar(s),!0)}catch{return!1}}xt(e){var t=E.ph_load_toolbar||E.ph_load_editor;!R(t)&&Ce(t)?t(e,this.instance):jr.warn("No toolbar load function found")}loadToolbar(e){var t=!(y==null||!y.getElementById(Ns));if(!d||t)return!1;var i=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=w({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(d.localStorage.setItem(Nr,JSON.stringify(w({},s,{source:void 0}))),this.wt()===Re.LOADED)this.xt(s);else if(this.wt()===Re.UNINITIALIZED){var n;this.yt(Re.LOADING),(n=E.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,"toolbar",(a=>{if(a)return jr.error("[Toolbar] Failed to load",a),void this.yt(Re.UNINITIALIZED);this.yt(Re.LOADED),this.xt(s)})),j(d,"turbolinks:load",(()=>{this.yt(Re.UNINITIALIZED),this.loadToolbar(s)}))}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),i===void 0&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var Va=L("[TracingHeaders]");class Wa{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var t,i;_(this.$t)&&((t=E.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),_(this.St)&&((i=E.__PosthogExtensions__)==null||(i=i.tracingHeadersPatchFns)==null||i._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}it(e){var t,i;(t=E.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns&&e(),(i=E.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"tracing-headers",(s=>{if(s)return Va.error("failed to load script",s);e()}))}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):((e=this.$t)==null||e.call(this),(t=this.St)==null||t.call(this),this.$t=void 0,this.St=void 0)}}var Mt="https?://(.*)",rt=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],za=it(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],rt),It="<masked>",Ya=["li_fat_id"];function rn(r,e,t){if(!y)return{};var i,s=e?it([],rt,t||[]):[],n=sn(Rt(y.URL,s,It),r),a=(i={},M(Ya,(function(o){var l=he.q(o);i[o]=l||null})),i);return N(a,n)}function sn(r,e){var t=za.concat(e||[]),i={};return M(t,(function(s){var n=zt(r,s);i[s]=n||null})),i}function nn(r){var e=(function(n){return n?n.search(Mt+"google.([^/?]*)")===0?"google":n.search(Mt+"bing.com")===0?"bing":n.search(Mt+"yahoo.com")===0?"yahoo":n.search(Mt+"duckduckgo.com")===0?"duckduckgo":null:null})(r),t=e!="yahoo"?"q":"p",i={};if(!oe(e)){i.$search_engine=e;var s=y?zt(y.referrer,t):"";s.length&&(i.ph_keyword=s)}return i}function qr(){return navigator.language||navigator.userLanguage}function an(){return(y==null?void 0:y.referrer)||"$direct"}function on(r,e){var t=r?it([],rt,e||[]):[],i=G==null?void 0:G.href.substring(0,1e3);return{r:an().substring(0,1e3),u:i?Rt(i,t,It):void 0}}function ln(r){var e,{r:t,u:i}=r,s={$referrer:t,$referring_domain:t==null?void 0:t=="$direct"?"$direct":(e=Wt(t))==null?void 0:e.host};if(i){s.$current_url=i;var n=Wt(i);s.$host=n==null?void 0:n.host,s.$pathname=n==null?void 0:n.pathname;var a=sn(i);N(s,a)}if(t){var o=nn(t);N(s,o)}return s}function un(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Ja(){try{return new Date().getTimezoneOffset()}catch{return}}function Xa(r,e){if(!X)return{};var t,i,s,n=r?it([],rt,e||[]):[],[a,o]=(function(l){for(var c=0;c<_r.length;c++){var[u,h]=_r[c],p=u.exec(l),g=p&&(Ce(h)?h(p,l):h);if(g)return g}return["",""]})(X);return N(Qi({$os:a,$os_version:o,$browser:Is(X,navigator.vendor),$device:mr(X),$device_type:(i=X,s=mr(i),s===vs||s===fs||s==="Kobo"||s==="Kindle Fire"||s===Rs?xt:s===St||s===Ze||s===Pt||s===Ri?"Console":s===ms?"Wearable":s?ne:"Desktop"),$timezone:un(),$timezone_offset:Ja()}),{$current_url:Rt(G==null?void 0:G.href,n,It),$host:G==null?void 0:G.host,$pathname:G==null?void 0:G.pathname,$raw_user_agent:X.length>1e3?X.substring(0,997)+"...":X,$browser_version:Hn(X,navigator.vendor),$browser_language:qr(),$browser_language_prefix:(t=qr(),typeof t=="string"?t.split("-")[0]:void 0),$screen_height:d==null?void 0:d.screen.height,$screen_width:d==null?void 0:d.screen.width,$viewport_height:d==null?void 0:d.innerHeight,$viewport_width:d==null?void 0:d.innerWidth,$lib:"web",$lib_version:ve.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var Fe=L("[Web Vitals]"),Hr=9e5;class Ka{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),this.N.metrics.length!==0&&(this._instance.capture("$web_vitals",this.N.metrics.reduce(((i,s)=>w({},i,{["$web_vitals_"+s.name+"_event"]:w({},s),["$web_vitals_"+s.name+"_value"]:s.value})),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=i=>{var s,n=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0);if(_(n))Fe.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var a=this.Ct();_(a)||(R(i==null?void 0:i.name)||R(i==null?void 0:i.value)?Fe.error("Invalid metric received",i):this.Rt&&i.value>=this.Rt?Fe.error("Ignoring metric with value >= "+this.Rt,i):(this.N.url!==a&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),_(this.N.url)&&(this.N.url=a),this.N.firstMetricTimestamp=_(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,i.attribution&&i.attribution.interactionTargetElement&&(i.attribution.interactionTargetElement=void 0),this.N.metrics.push(w({},i,{$current_url:a,$session_id:n.sessionId,$window_id:n.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var i,s,n,a,o=E.__PosthogExtensions__;_(o)||_(o.postHogWebVitalsCallbacks)||({onLCP:i,onCLS:s,onFCP:n,onINP:a}=o.postHogWebVitalsCallbacks),i&&s&&n&&a?(this.allowedMetrics.indexOf("LCP")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&s(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&n(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&a(this.It.bind(this)),this.P=!0):Fe.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!((t=this._instance.persistence)==null||!t.props[Pr]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=H(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return R(i)?((t=this._instance.persistence)==null?void 0:t.props[$r])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(H(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=H(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return e!=null&&e}get Rt(){var e=H(this._instance.config.capture_performance)&&Ee(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:Hr;return 0<e&&e<=6e4?Hr:e}get isEnabled(){var e=G==null?void 0:G.protocol;if(e!=="http:"&&e!=="https:")return Fe.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=H(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:we(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return we(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(Fe.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=H(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=H(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Pr]:t}),this._instance.persistence.register({[$r]:i})),this.kt=t,this.startIfEnabled()}it(e){var t,i;if((t=E.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks)e();else{var s=this.useAttribution?"web-vitals-with-attribution":"web-vitals";(i=E.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,s,(n=>{n?Fe.error("failed to load script",n):e()}))}}Ct(){var e=d?d.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,i=this._instance.config.custom_personal_data_properties,s=t?it([],rt,i||[]):[];return Rt(e,s,It)}Fe.error("Could not determine current URL")}}var Za=L("[Heatmaps]");function Ur(r){return H(r)&&"clientX"in r&&"clientY"in r&&Ee(r.clientX)&&Ee(r.clientY)}class Qa{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!((t=this.instance.persistence)==null||!t.props[Ti]),this.rageclicks=new Ks(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return H(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.kt:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.P)return;Za.info("starting..."),this.Ot(),this.Mt()}else{var e;clearInterval((e=this.Ft)!==null&&e!==void 0?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Ti]:t}),this.kt=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}jt(e){this.Dt(e.originalEvent,"deadclick")}Mt(){this.Ft&&clearInterval(this.Ft),this.Ft=(function(e){return(e==null?void 0:e.visibilityState)==="visible"})(y)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){d&&y&&(this.Nt=this.Lt.bind(this),j(d,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||(d==null?void 0:d.event)),j(y,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||(d==null?void 0:d.event)),j(y,"mousemove",this.zt,{capture:!0}),this.Bt=new Qs(this.instance,La,this.jt.bind(this)),this.Bt.startIfEnabledOrStop(),this.qt=this.Mt.bind(this),j(y,"visibilitychange",this.qt),this.P=!0)}At(){var e;d&&y&&(this.Nt&&d.removeEventListener("beforeunload",this.Nt),this.Ut&&y.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&y.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&y.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),(e=this.Bt)==null||e.stop(),this.P=!1)}Gt(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),a=(function(o,l,c){for(var u=o;u&&ti(u)&&!Oe(u,"body");){if(u===c)return!1;if(F(l,d==null?void 0:d.getComputedStyle(u).position))return!0;u=Gs(u)}return!1})(Us(e),["fixed","sticky"],n);return{x:e.clientX+(a?0:s),y:e.clientY+(a?0:i),target_fixed:a,type:t}}Dt(e,t){var i;if(t===void 0&&(t="click"),!Rr(e.target)&&Ur(e)){var s=this.Gt(e,t);(i=this.rageclicks)!=null&&i.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Vt(w({},s,{type:"rageclick"})),this.Vt(s)}}Ht(e){!Rr(e.target)&&Ur(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout((()=>{this.Vt(this.Gt(e,"mousemove"))}),500))}Vt(e){if(d){var t=d.location.href,i=this.instance.config.mask_personal_data_properties,s=this.instance.config.custom_personal_data_properties,n=i?it([],rt,s||[]):[],a=Rt(t,n,It);this.N=this.N||{},this.N[a]||(this.N[a]=[]),this.N[a].push(e)}}Lt(){this.N&&!Je(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class Br{constructor(e){this.Jt=(t,i,s)=>{s&&(s.noSessionId||s.activityTimeout||s.sessionPastMaximumLength)&&(b.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:s}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.Jt)}destroy(){var e;(e=this.Xt)==null||e.call(this),this.Xt=void 0}doPageView(e,t){var i,s=this.Qt(e,t);return this.Kt={pathname:(i=d==null?void 0:d.location.pathname)!==null&&i!==void 0?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this.Qt(e,(t=this.Kt)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Kt)==null?void 0:e.pageViewId}}Qt(e,t){var i=this.Kt;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:a,lastScrollY:o,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:h}=n;if(!(_(a)||_(o)||_(l)||_(c)||_(u)||_(h))){a=Math.ceil(a),o=Math.ceil(o),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),h=Math.ceil(h);var p=a<=1?1:de(o/a,0,1,b),g=a<=1?1:de(l/a,0,1,b),f=c<=1?1:de(u/c,0,1,b),v=c<=1?1:de(h/c,0,1,b);s=N(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:p,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:f,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:v})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}}var zo=["fatal","error","warning","log","info","debug"],ye=(function(r){return r.GZipJS="gzip-js",r.Base64="base64",r})({}),ae=Uint8Array,K=Uint16Array,tt=Uint32Array,rr=new ae([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]),sr=new ae([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]),Gr=new ae([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cn=function(r,e){for(var t=new K(31),i=0;i<31;++i)t[i]=e+=1<<r[i-1];var s=new tt(t[30]);for(i=1;i<30;++i)for(var n=t[i];n<t[i+1];++n)s[n]=n-t[i]<<5|i;return[t,s]},hn=cn(rr,2),eo=hn[0],Ui=hn[1];eo[28]=258,Ui[258]=28;for(var Vr=cn(sr,0)[1],dn=new K(32768),A=0;A<32768;++A){var De=(43690&A)>>>1|(21845&A)<<1;De=(61680&(De=(52428&De)>>>2|(13107&De)<<2))>>>4|(3855&De)<<4,dn[A]=((65280&De)>>>8|(255&De)<<8)>>>1}var wt=function(r,e,t){for(var i=r.length,s=0,n=new K(e);s<i;++s)++n[r[s]-1];var a,o=new K(e);for(s=0;s<e;++s)o[s]=o[s-1]+n[s-1]<<1;for(a=new K(i),s=0;s<i;++s)a[s]=dn[o[r[s]-1]++]>>>15-r[s];return a},qe=new ae(288);for(A=0;A<144;++A)qe[A]=8;for(A=144;A<256;++A)qe[A]=9;for(A=256;A<280;++A)qe[A]=7;for(A=280;A<288;++A)qe[A]=8;var Xt=new ae(32);for(A=0;A<32;++A)Xt[A]=5;var to=wt(qe,9),io=wt(Xt,5),pn=function(r){return(r/8>>0)+(7&r&&1)},gn=function(r,e,t){(t==null||t>r.length)&&(t=r.length);var i=new(r instanceof K?K:r instanceof tt?tt:ae)(t-e);return i.set(r.subarray(e,t)),i},ge=function(r,e,t){t<<=7&e;var i=e/8>>0;r[i]|=t,r[i+1]|=t>>>8},ot=function(r,e,t){t<<=7&e;var i=e/8>>0;r[i]|=t,r[i+1]|=t>>>8,r[i+2]|=t>>>16},pi=function(r,e){for(var t=[],i=0;i<r.length;++i)r[i]&&t.push({s:i,f:r[i]});var s=t.length,n=t.slice();if(!s)return[new ae(0),0];if(s==1){var a=new ae(t[0].s+1);return a[t[0].s]=1,[a,1]}t.sort((function(x,q){return x.f-q.f})),t.push({s:-1,f:25001});var o=t[0],l=t[1],c=0,u=1,h=2;for(t[0]={s:-1,f:o.f+l.f,l:o,r:l};u!=s-1;)o=t[t[c].f<t[h].f?c++:h++],l=t[c!=u&&t[c].f<t[h].f?c++:h++],t[u++]={s:-1,f:o.f+l.f,l:o,r:l};var p=n[0].s;for(i=1;i<s;++i)n[i].s>p&&(p=n[i].s);var g=new K(p+1),f=Bi(t[u-1],g,0);if(f>e){i=0;var v=0,m=f-e,S=1<<m;for(n.sort((function(x,q){return g[q.s]-g[x.s]||x.f-q.f}));i<s;++i){var k=n[i].s;if(!(g[k]>e))break;v+=S-(1<<f-g[k]),g[k]=e}for(v>>>=m;v>0;){var I=n[i].s;g[I]<e?v-=1<<e-g[I]++-1:++i}for(;i>=0&&v;--i){var $=n[i].s;g[$]==e&&(--g[$],++v)}f=e}return[new ae(g),f]},Bi=function(r,e,t){return r.s==-1?Math.max(Bi(r.l,e,t+1),Bi(r.r,e,t+1)):e[r.s]=t},Wr=function(r){for(var e=r.length;e&&!r[--e];);for(var t=new K(++e),i=0,s=r[0],n=1,a=function(l){t[i++]=l},o=1;o<=e;++o)if(r[o]==s&&o!=e)++n;else{if(!s&&n>2){for(;n>138;n-=138)a(32754);n>2&&(a(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(a(s),--n;n>6;n-=6)a(8304);n>2&&(a(n-3<<5|8208),n=0)}for(;n--;)a(s);n=1,s=r[o]}return[t.subarray(0,i),e]},lt=function(r,e){for(var t=0,i=0;i<e.length;++i)t+=r[i]*e[i];return t},Gi=function(r,e,t){var i=t.length,s=pn(e+2);r[s]=255&i,r[s+1]=i>>>8,r[s+2]=255^r[s],r[s+3]=255^r[s+1];for(var n=0;n<i;++n)r[s+n+4]=t[n];return 8*(s+4+i)},zr=function(r,e,t,i,s,n,a,o,l,c,u){ge(e,u++,t),++s[256];for(var h=pi(s,15),p=h[0],g=h[1],f=pi(n,15),v=f[0],m=f[1],S=Wr(p),k=S[0],I=S[1],$=Wr(v),x=$[0],q=$[1],T=new K(19),P=0;P<k.length;++P)T[31&k[P]]++;for(P=0;P<x.length;++P)T[31&x[P]]++;for(var Z=pi(T,7),W=Z[0],ie=Z[1],re=19;re>4&&!W[Gr[re-1]];--re);var pe,le,ue,He,xe=c+5<<3,Me=lt(s,qe)+lt(n,Xt)+a,ce=lt(s,p)+lt(n,v)+a+14+3*re+lt(T,W)+(2*T[16]+3*T[17]+7*T[18]);if(xe<=Me&&xe<=ce)return Gi(e,u,r.subarray(l,l+c));if(ge(e,u,1+(ce<Me)),u+=2,ce<Me){pe=wt(p,g),le=p,ue=wt(v,m),He=v;var ke=wt(W,ie);for(ge(e,u,I-257),ge(e,u+5,q-1),ge(e,u+10,re-4),u+=14,P=0;P<re;++P)ge(e,u+3*P,W[Gr[P]]);u+=3*re;for(var Ue=[k,x],Y=0;Y<2;++Y){var se=Ue[Y];for(P=0;P<se.length;++P){var Q=31&se[P];ge(e,u,ke[Q]),u+=W[Q],Q>15&&(ge(e,u,se[P]>>>5&127),u+=se[P]>>>12)}}}else pe=to,le=qe,ue=io,He=Xt;for(P=0;P<o;++P)if(i[P]>255){Q=i[P]>>>18&31,ot(e,u,pe[Q+257]),u+=le[Q+257],Q>7&&(ge(e,u,i[P]>>>23&31),u+=rr[Q]);var Be=31&i[P];ot(e,u,ue[Be]),u+=He[Be],Be>3&&(ot(e,u,i[P]>>>5&8191),u+=sr[Be])}else ot(e,u,pe[i[P]]),u+=le[i[P]];return ot(e,u,pe[256]),u+le[256]},ro=new tt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),so=(function(){for(var r=new tt(256),e=0;e<256;++e){for(var t=e,i=9;--i;)t=(1&t&&3988292384)^t>>>1;r[e]=t}return r})(),no=function(r,e,t,i,s){return(function(n,a,o,l,c,u){var h=n.length,p=new ae(l+h+5*(1+Math.floor(h/7e3))+c),g=p.subarray(l,p.length-c),f=0;if(!a||h<8)for(var v=0;v<=h;v+=65535){var m=v+65535;m<h?f=Gi(g,f,n.subarray(v,m)):(g[v]=u,f=Gi(g,f,n.subarray(v,h)))}else{for(var S=ro[a-1],k=S>>>13,I=8191&S,$=(1<<o)-1,x=new K(32768),q=new K($+1),T=Math.ceil(o/3),P=2*T,Z=function(si){return(n[si]^n[si+1]<<T^n[si+2]<<P)&$},W=new tt(25e3),ie=new K(288),re=new K(32),pe=0,le=0,ue=(v=0,0),He=0,xe=0;v<h;++v){var Me=Z(v),ce=32767&v,ke=q[Me];if(x[ce]=ke,q[Me]=ce,He<=v){var Ue=h-v;if((pe>7e3||ue>24576)&&Ue>423){f=zr(n,g,0,W,ie,re,le,ue,xe,v-xe,f),ue=pe=le=0,xe=v;for(var Y=0;Y<286;++Y)ie[Y]=0;for(Y=0;Y<30;++Y)re[Y]=0}var se=2,Q=0,Be=I,Se=ce-ke&32767;if(Ue>2&&Me==Z(v-Se))for(var bn=Math.min(k,Ue)-1,wn=Math.min(32767,v),En=Math.min(258,Ue);Se<=wn&&--Be&&ce!=ke;){if(n[v+se]==n[v+se-Se]){for(var Pe=0;Pe<En&&n[v+Pe]==n[v+Pe-Se];++Pe);if(Pe>se){if(se=Pe,Q=Se,Pe>bn)break;var xn=Math.min(Se,Pe-2),ar=0;for(Y=0;Y<xn;++Y){var ri=v-Se+Y+32768&32767,or=ri-x[ri]+32768&32767;or>ar&&(ar=or,ke=ri)}}}Se+=(ce=ke)-(ke=x[ce])+32768&32767}if(Q){W[ue++]=268435456|Ui[se]<<18|Vr[Q];var lr=31&Ui[se],ur=31&Vr[Q];le+=rr[lr]+sr[ur],++ie[257+lr],++re[ur],He=v+se,++pe}else W[ue++]=n[v],++ie[n[v]]}}f=zr(n,g,u,W,ie,re,le,ue,xe,v-xe,f)}return gn(p,0,l+pn(f)+c)})(r,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+e.mem,t,i,!0)},gi=function(r,e,t){for(;t;++e)r[e]=t,t>>>=8};function ao(r,e){e===void 0&&(e={});var t=(function(){var o=4294967295;return{p:function(l){for(var c=o,u=0;u<l.length;++u)c=so[255&c^l[u]]^c>>>8;o=c},d:function(){return 4294967295^o}}})(),i=r.length;t.p(r);var s,n=no(r,e,10+((s=e).filename&&s.filename.length+1||0),8),a=n.length;return(function(o,l){var c=l.filename;if(o[0]=31,o[1]=139,o[2]=8,o[8]=l.level<2?4:l.level==9?2:0,o[9]=3,l.mtime!=0&&gi(o,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),c){o[3]=8;for(var u=0;u<=c.length;++u)o[u+10]=c.charCodeAt(u)}})(n,e),gi(n,a-8,t.d()),gi(n,a-4,i),n}var oo=function(r){var e,t,i,s,n="";for(e=t=0,i=(r=(r+"").replace(/\r\n/g,`
|
|
3
|
+
`).replace(/\r/g,`
|
|
4
|
+
`)).length,s=0;s<i;s++){var a=r.charCodeAt(s),o=null;a<128?t++:o=a>127&&a<2048?String.fromCharCode(a>>6|192,63&a|128):String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128),oe(o)||(t>e&&(n+=r.substring(e,t)),n+=o,e=t=s+1)}return t>e&&(n+=r.substring(e,r.length)),n},lo=!!ki||!!xi,Yr="text/plain",Kt=function(r,e,t){var i;t===void 0&&(t=!0);var[s,n]=r.split("?"),a=w({},e),o=(i=n==null?void 0:n.split("&").map((c=>{var u,[h,p]=c.split("="),g=t&&(u=a[h])!==null&&u!==void 0?u:p;return delete a[h],h+"="+g})))!==null&&i!==void 0?i:[],l=ka(a);return l&&o.push(l),s+"?"+o.join("&")},mt=(r,e)=>JSON.stringify(r,((t,i)=>typeof i=="bigint"?i.toString():i),e),fi=r=>{var{data:e,compression:t}=r;if(e){if(t===ye.GZipJS){var i=ao((function(l,c){var u=l.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(l);for(var h=new ae(l.length+(l.length>>>1)),p=0,g=function(S){h[p++]=S},f=0;f<u;++f){if(p+5>h.length){var v=new ae(p+8+(u-f<<1));v.set(h),h=v}var m=l.charCodeAt(f);m<128||c?g(m):m<2048?(g(192|m>>>6),g(128|63&m)):m>55295&&m<57344?(g(240|(m=65536+(1047552&m)|1023&l.charCodeAt(++f))>>>18),g(128|m>>>12&63),g(128|m>>>6&63),g(128|63&m)):(g(224|m>>>12),g(128|m>>>6&63),g(128|63&m))}return gn(h,0,p)})(mt(e)),{mtime:0}),s=new Blob([i],{type:Yr});return{contentType:Yr,body:s,estimatedSize:s.size}}if(t===ye.Base64){var n=(function(l){var c,u,h,p,g,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",v=0,m=0,S="",k=[];if(!l)return l;l=oo(l);do c=(g=l.charCodeAt(v++)<<16|l.charCodeAt(v++)<<8|l.charCodeAt(v++))>>18&63,u=g>>12&63,h=g>>6&63,p=63&g,k[m++]=f.charAt(c)+f.charAt(u)+f.charAt(h)+f.charAt(p);while(v<l.length);switch(S=k.join(""),l.length%3){case 1:S=S.slice(0,-2)+"==";break;case 2:S=S.slice(0,-1)+"="}return S})(mt(e)),a=(l=>"data="+encodeURIComponent(typeof l=="string"?l:mt(l)))(n);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var o=mt(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Lt=[];xi&&Lt.push({transport:"fetch",method:r=>{var e,t,{contentType:i,body:s,estimatedSize:n}=(e=fi(r))!==null&&e!==void 0?e:{},a=new Headers;M(r.headers,(function(u,h){a.append(h,u)})),i&&a.append("Content-Type",i);var o=r.url,l=null;if(dr){var c=new dr;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),r.timeout)}}xi(o,w({method:(r==null?void 0:r.method)||"GET",headers:a,keepalive:r.method==="POST"&&(n||0)<52428.8,body:s,signal:(t=l)==null?void 0:t.signal},r.fetchOptions)).then((u=>u.text().then((h=>{var p={statusCode:u.status,text:h};if(u.status===200)try{p.json=JSON.parse(h)}catch(g){b.error(g)}r.callback==null||r.callback(p)})))).catch((u=>{b.error(u),r.callback==null||r.callback({statusCode:0,error:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),ki&&Lt.push({transport:"XHR",method:r=>{var e,t=new ki;t.open(r.method||"GET",r.url,!0);var{contentType:i,body:s}=(e=fi(r))!==null&&e!==void 0?e:{};M(r.headers,(function(n,a){t.setRequestHeader(a,n)})),i&&t.setRequestHeader("Content-Type",i),r.timeout&&(t.timeout=r.timeout),r.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}r.callback==null||r.callback(n)}},t.send(s)}}),te!=null&&te.sendBeacon&&Lt.push({transport:"sendBeacon",method:r=>{var e=Kt(r.url,{beacon:"1"});try{var t,{contentType:i,body:s}=(t=fi(r))!==null&&t!==void 0?t:{},n=typeof s=="string"?new Blob([s],{type:i}):s;te.sendBeacon(e,n)}catch{}}});var Zt=function(r,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(r)}catch{return!1}};function Jr(r,e,t){return mt({distinct_id:r,userPropertiesToSet:e,userPropertiesToSetOnce:t})}var fn={exact:(r,e)=>e.some((t=>r.some((i=>t===i)))),is_not:(r,e)=>e.every((t=>r.every((i=>t!==i)))),regex:(r,e)=>e.some((t=>r.some((i=>Zt(t,i))))),not_regex:(r,e)=>e.every((t=>r.every((i=>!Zt(t,i))))),icontains:(r,e)=>e.map(At).some((t=>r.map(At).some((i=>t.includes(i))))),not_icontains:(r,e)=>e.map(At).every((t=>r.map(At).every((i=>!t.includes(i))))),gt:(r,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&r.some((s=>i>parseFloat(s)))})),lt:(r,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&r.some((s=>i<parseFloat(s)))}))},At=r=>r.toLowerCase();function vn(r,e){return!r||Object.entries(r).every((t=>{var[i,s]=t,n=e==null?void 0:e[i];if(_(n)||oe(n))return!1;var a=[String(n)],o=fn[s.operator];return!!o&&o(s.values,a)}))}var vi=L("[Error tracking]");class uo{constructor(e){var t,i;this.Zt=[],this.ti=new Gn([new Qn,new la,new ta,new ea,new aa,new na,new ra,new oa],Zn()),this._instance=e,this.Zt=(t=(i=this._instance.persistence)==null?void 0:i.get_property(Oi))!==null&&t!==void 0?t:[]}onRemoteConfig(e){var t,i,s,n=(t=(i=e.errorTracking)==null?void 0:i.suppressionRules)!==null&&t!==void 0?t:[],a=(s=e.errorTracking)==null?void 0:s.captureExtensionExceptions;this.Zt=n,this._instance.persistence&&this._instance.persistence.register({[Oi]:this.Zt,[Sr]:a})}get ii(){var e,t=!!this._instance.get_property(Sr),i=this._instance.config.error_tracking.captureExtensionExceptions;return(e=i??t)!==null&&e!==void 0&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:t==null?void 0:t.syntheticException,mechanism:{handled:t==null?void 0:t.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void vi.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void vi.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void vi.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ri(e){if(e.length===0)return!1;var t=e.reduce(((i,s)=>{var{type:n,value:a}=s;return U(n)&&n.length>0&&i.$exception_types.push(n),U(a)&&a.length>0&&i.$exception_values.push(a),i}),{$exception_types:[],$exception_values:[]});return this.Zt.some((i=>{var s=i.values.map((n=>{var a,o=fn[n.operator],l=C(n.value)?n.value:[n.value],c=(a=t[n.key])!==null&&a!==void 0?a:[];return l.length>0&&o(l,c)}));return i.type==="OR"?s.some(Boolean):s.every(Boolean)}))}si(e){return e.flatMap((t=>{var i,s;return(i=(s=t.stacktrace)==null?void 0:s.frames)!==null&&i!==void 0?i:[]})).some((t=>t.filename&&t.filename.startsWith("chrome-extension://")))}ni(e){if(e.length>0){var t,i,s,n,a=(t=(i=e[0].stacktrace)==null?void 0:i.frames)!==null&&t!==void 0?t:[],o=a[a.length-1];return(s=o==null||(n=o.filename)==null?void 0:n.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}ei(e){return!R(e)&&C(e)}}var ee=L("[FeatureFlags]"),ut=L("[FeatureFlags]",{debugEnabled:!0}),co="errors_while_computing_flags",ho="flag_missing",po="quota_limited",go="timeout",fo="connection_error",vo="unknown_error",_o=r=>"api_error_"+r,_i="$active_feature_flags",Ge="$override_feature_flags",Xr="$feature_flag_payloads",ct="$override_feature_flag_payloads",Kr="$feature_flag_request_id",Zr="$feature_flag_evaluated_at",Qr=r=>{var e={};for(var[t,i]of Dt(r||{}))i&&(e[t]=i);return e},mo=r=>{var e=r.flags;return e?(r.featureFlags=Object.fromEntries(Object.keys(e).map((t=>{var i;return[t,(i=e[t].variant)!==null&&i!==void 0?i:e[t].enabled]}))),r.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((t=>e[t].enabled)).filter((t=>{var i;return(i=e[t].metadata)==null?void 0:i.payload})).map((t=>{var i;return[t,(i=e[t].metadata)==null?void 0:i.payload]})))):ee.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),r},yo=(function(r){return r.FeatureFlags="feature_flags",r.Recordings="recordings",r})({});class bo{constructor(e){this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.ci=!1,this._instance=e,this.featureFlagEventHandlers=[]}fi(){var e,t=(e=this._instance.config.evaluation_contexts)!==null&&e!==void 0?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(ee.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),t!=null&&t.length?t.filter((i=>{var s=i&&typeof i=="string"&&i.trim().length>0;return s||ee.error("Invalid evaluation context found:",i,"Expected non-empty string"),s})):[]}pi(){return this.fi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.di=!0;else{var e=!this.gi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.mi({disableFlags:e})}}get hasLoadedFlags(){return this.ai}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Mi),t=this._instance.get_property(Ge),i=this._instance.get_property(ct);if(!i&&!t)return e||{};var s=N({},e||{}),n=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(var a of n){var o,l,c=s[a],u=t==null?void 0:t[a],h=_(u)?(o=c==null?void 0:c.enabled)!==null&&o!==void 0&&o:!!u,p=_(u)?c.variant:typeof u=="string"?u:void 0,g=i==null?void 0:i[a],f=w({},c,{enabled:h,variant:h?p??(c==null?void 0:c.variant):void 0});h!==(c==null?void 0:c.enabled)&&(f.original_enabled=c==null?void 0:c.enabled),p!==(c==null?void 0:c.variant)&&(f.original_variant=c==null?void 0:c.variant),g&&(f.metadata=w({},c==null?void 0:c.metadata,{payload:g,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),s[a]=f}return this.oi||(ee.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:s}),this.oi=!0),s}getFlagVariants(){var e=this._instance.get_property(Xe),t=this._instance.get_property(Ge);if(!t)return e||{};for(var i=N({},e),s=Object.keys(t),n=0;n<s.length;n++)i[s[n]]=t[s[n]];return this.oi||(ee.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this.oi=!0),i}getFlagPayloads(){var e=this._instance.get_property(Xr),t=this._instance.get_property(ct);if(!t)return e||{};for(var i=N({},e||{}),s=Object.keys(t),n=0;n<s.length;n++)i[s[n]]=t[s[n]];return this.oi||(ee.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this.oi=!0),i}reloadFeatureFlags(){this.ui||this._instance.config.advanced_disable_feature_flags||this.gi||(this._instance.bi.emit("featureFlagsReloading",!0),this.gi=setTimeout((()=>{this.mi()}),5))}yi(){clearTimeout(this.gi),this.gi=void 0}ensureFlagsLoaded(){this.ai||this.li||this.gi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.ui=e}mi(e){var t;if(this.yi(),!this._instance.M())if(this.li)this.hi=!0;else{var i=this._instance.config.token,s=this._instance.get_property("$device_id"),n={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:w({},((t=this._instance.persistence)==null?void 0:t.get_initial_props())||{},this._instance.get_property(_t)||{}),group_properties:this._instance.get_property(Ne)};oe(s)||_(s)||(n.$device_id=s),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(n.disable_flags=!0),this.pi()&&(n.evaluation_contexts=this.fi());var a=this._instance.config.__preview_remote_config,o=a?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",o+l);a&&(n.timezone=un()),this.li=!0,this._instance._send_request({method:"POST",url:c,data:n,compression:this._instance.config.disable_compression?void 0:ye.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var h,p,g,f,v=!0;if(u.statusCode===200&&(this.hi||(this.$anon_distinct_id=void 0),v=!1),this.li=!1,this.di||(this.di=!0,this._instance.wi((f=u.json)!==null&&f!==void 0?f:{})),!n.disable_flags||this.hi){this.vi=!v;var m=[];u.error?u.error instanceof Error?m.push(u.error.name==="AbortError"?go:fo):m.push(vo):u.statusCode!==200&&m.push(_o(u.statusCode)),(h=u.json)!=null&&h.errorsWhileComputingFlags&&m.push(co);var S=!((p=u.json)==null||(p=p.quotaLimited)==null||!p.includes(yo.FeatureFlags));if(S&&m.push(po),(g=this._instance.persistence)==null||g.register({[Di]:m}),S)ee.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 k;n.disable_flags||this.receivedFeatureFlags((k=u.json)!==null&&k!==void 0?k:{},v),this.hi&&(this.hi=!1,this.mi())}}}})}}getFeatureFlag(e,t){var i;if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var s=this.getFeatureFlagResult(e,t);return(i=s==null?void 0:s.variant)!==null&&i!==void 0?i:s==null?void 0:s.enabled}ee.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){var t=this.getFeatureFlagResult(e,{send_event:!1});return t==null?void 0:t.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants(),s=e in i,n=i[e],a=this.getFlagPayloads()[e],o=String(n),l=this._instance.get_property(Kr)||void 0,c=this._instance.get_property(Zr)||void 0,u=this._instance.get_property(Ut)||{};if((t.send_event||!("send_event"in t))&&(!(e in u)||!u[e].includes(o))){var h,p,g,f,v,m,S,k,I,$;C(u[e])?u[e].push(o):u[e]=[o],(h=this._instance.persistence)==null||h.register({[Ut]:u});var x=this.getFeatureFlagDetails(e),q=[...(p=this._instance.get_property(Di))!==null&&p!==void 0?p:[]];_(n)&&q.push(ho);var T={$feature_flag:e,$feature_flag_response:n,$feature_flag_payload:a||null,$feature_flag_request_id:l,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((g=this._instance.config.bootstrap)==null||(g=g.featureFlags)==null?void 0:g[e])||null,$feature_flag_bootstrapped_payload:((f=this._instance.config.bootstrap)==null||(f=f.featureFlagPayloads)==null?void 0:f[e])||null,$used_bootstrap_value:!this.vi};_(x==null||(v=x.metadata)==null?void 0:v.version)||(T.$feature_flag_version=x.metadata.version);var P,Z=(m=x==null||(S=x.reason)==null?void 0:S.description)!==null&&m!==void 0?m:x==null||(k=x.reason)==null?void 0:k.code;Z&&(T.$feature_flag_reason=Z),x!=null&&(I=x.metadata)!=null&&I.id&&(T.$feature_flag_id=x.metadata.id),_(x==null?void 0:x.original_variant)&&_(x==null?void 0:x.original_enabled)||(T.$feature_flag_original_response=_(x.original_variant)?x.original_enabled:x.original_variant),x!=null&&($=x.metadata)!=null&&$.original_payload&&(T.$feature_flag_original_payload=x==null||(P=x.metadata)==null?void 0:P.original_payload),q.length&&(T.$feature_flag_error=q.join(",")),this._instance.capture("$feature_flag_called",T)}if(s){var W=a;if(!_(a))try{W=JSON.parse(a)}catch{}return{key:e,enabled:!!n,variant:typeof n=="string"?n:void 0,payload:W}}}else ee.warn('getFeatureFlagResult for key "'+e+`" failed. Feature flags didn't load in time.`)}getRemoteConfigPayload(e,t){var i=this._instance.config.token,s={distinct_id:this._instance.get_distinct_id(),token:i};this.pi()&&(s.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:s,compression:this._instance.config.disable_compression?void 0:ye.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:n=>{var a,o=(a=n.json)==null?void 0:a.featureFlagPayloads;t((o==null?void 0:o[e])||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return _(i)?void 0:!!i}ee.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t){if(this._instance.persistence){this.ai=!0;var i=this.getFlagVariants(),s=this.getFlagPayloads(),n=this.getFlagsWithDetails();(function(a,o,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var h=mo(a),p=h.flags,g=h.featureFlags,f=h.featureFlagPayloads;if(g){var v=a.requestId,m=a.evaluatedAt;if(C(g)){ee.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var S={};if(g)for(var k=0;k<g.length;k++)S[g[k]]=!0;o&&o.register({[_i]:g,[Xe]:S})}else{var I=g,$=f,x=p;if(a.errorsWhileComputingFlags)if(p){var q=new Set(Object.keys(p).filter((T=>{var P;return!((P=p[T])!=null&&P.failed)})));I=w({},l,Object.fromEntries(Object.entries(I).filter((T=>{var[P]=T;return q.has(P)})))),$=w({},c,Object.fromEntries(Object.entries($||{}).filter((T=>{var[P]=T;return q.has(P)})))),x=w({},u,Object.fromEntries(Object.entries(x||{}).filter((T=>{var[P]=T;return q.has(P)}))))}else I=w({},l,I),$=w({},c,$),x=w({},u,x);o&&o.register(w({[_i]:Object.keys(Qr(I)),[Xe]:I||{},[Xr]:$||{},[Mi]:x||{}},v?{[Kr]:v}:{},m?{[Zr]:m}:{}))}}})(e,this._instance.persistence,i,s,n),this.xi(t)}}override(e,t){t===void 0&&(t=!1),ee.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return ee.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(Ge),this._instance.persistence.unregister(ct),this.xi(),ut.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var t,i=e;if(this.oi=!!((t=i.suppressWarning)!==null&&t!==void 0&&t),"flags"in i){if(i.flags===!1)this._instance.persistence.unregister(Ge),ut.info("Flag overrides cleared");else if(i.flags){if(C(i.flags)){for(var s={},n=0;n<i.flags.length;n++)s[i.flags[n]]=!0;this._instance.persistence.register({[Ge]:s})}else this._instance.persistence.register({[Ge]:i.flags});ut.info("Flag overrides set",{flags:i.flags})}}return"payloads"in i&&(i.payloads===!1?(this._instance.persistence.unregister(ct),ut.info("Payload overrides cleared")):i.payloads&&(this._instance.persistence.register({[ct]:i.payloads}),ut.info("Payload overrides set",{payloads:i.payloads}))),void this.xi()}this.xi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.ai){var{flags:t,flagVariants:i}=this.Ei();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,i){var s,n=(this._instance.get_property(vt)||[]).find((c=>c.flagKey===e)),a={["$feature_enrollment/"+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};n&&(o.$early_access_feature_name=n.name),i&&(o.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(a,!1);var l=w({},this.getFlagVariants(),{[e]:t});(s=this._instance.persistence)==null||s.register({[_i]:Object.keys(Qr(l)),[Xe]:l}),this.xi()}getEarlyAccessFeatures(e,t,i){t===void 0&&(t=!1);var s=this._instance.get_property(vt),n=i?"&"+i.map((a=>"stage="+a)).join("&"):"";if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+n),method:"GET",callback:a=>{var o,l;if(a.json){var c=a.json.earlyAccessFeatures;return(o=this._instance.persistence)==null||o.unregister(vt),(l=this._instance.persistence)==null||l.register({[vt]:c}),e(c)}}})}Ei(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((i=>t[i])),flagVariants:Object.keys(t).filter((i=>t[i])).reduce(((i,s)=>(i[s]=t[s],i)),{})}}xi(e){var{flags:t,flagVariants:i}=this.Ei();this.featureFlagEventHandlers.forEach((s=>s(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=this._instance.get_property(_t)||{};this._instance.register({[_t]:w({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(_t)}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var i=this._instance.get_property(Ne)||{};Object.keys(i).length!==0&&Object.keys(i).forEach((s=>{i[s]=w({},i[s],e[s]),delete e[s]})),this._instance.register({[Ne]:w({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(Ne)||{};this._instance.register({[Ne]:w({},t,{[e]:{}})})}else this._instance.unregister(Ne)}reset(){this.ai=!1,this.li=!1,this.ui=!1,this.hi=!1,this.di=!1,this.vi=!1,this.$anon_distinct_id=void 0,this.yi(),this.oi=!1}}var wo=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class mi{constructor(e,t){this.R=e,this.props={},this.$i=!1,this.Si=(i=>{var s="";return i.token&&(s=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+s+"_posthog"})(e),this.Y=this.ki(e),this.load(),e.debug&&b.info("Persistence loaded",e.persistence,w({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.Pi}ki(e){wo.indexOf(e.persistence.toLowerCase())===-1&&(b.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(s){s===void 0&&(s=[]);var n=[...Ma,...s];return w({},D,{W:function(a){try{var o={};try{o=he.W(a)||{}}catch{}var l=N(o,JSON.parse(D.q(a)||"{}"));return D.G(a,l),l}catch{}return null},G:function(a,o,l,c,u,h){try{D.G(a,o,void 0,void 0,h);var p={};n.forEach((g=>{o[g]&&(p[g]=o[g])})),Object.keys(p).length&&he.G(a,p,l,c,u,h)}catch(g){D.B(g)}},V:function(a,o){try{d==null||d.localStorage.removeItem(a),he.V(a,o)}catch(l){D.B(l)}}})})(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return i==="localstorage"&&D.H()?D:i==="localstorage+cookie"&&t.H()?t:i==="sessionstorage"&&B.H()?B:i==="memory"?Aa:i==="cookie"?he:t.H()?t:he}properties(){var e={};return M(this.props,(function(t,i){if(i===Xe&&H(t))for(var s=Object.keys(t),n=0;n<s.length;n++)e["$feature/"+s[n]]=t[s[n]];else o=i,l=!1,(oe(a=ga)?l:hr&&a.indexOf===hr?a.indexOf(o)!=-1:(M(a,(function(c){if(l||(l=c===o))return qt})),l))||(e[i]=t);var a,o,l})),e}load(){if(!this.Pi){var e=this.Y.W(this.Si);e&&(this.props=N({},e))}}save(){this.Pi||this.Y.G(this.Si,this.props,this.Ti,this.Ii,this.Ci,this.R.debug)}remove(){this.Y.V(this.Si,!1),this.Y.V(this.Si,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(H(e)){_(t)&&(t="None"),this.Ti=_(i)?this.Ri:i;var s=!1;if(M(e,((n,a)=>{this.props.hasOwnProperty(a)&&this.props[a]!==t||(this.props[a]=n,s=!0)})),s)return this.save(),!0}return!1}register(e,t){if(H(e)){this.Ti=_(t)?this.Ri:t;var i=!1;if(M(e,((s,n)=>{e.hasOwnProperty(n)&&this.props[n]!==s&&(this.props[n]=s,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.$i){var e=rn(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);Je(Qi(e))||this.register(e),this.$i=!0}}update_search_keyword(){var e;this.register((e=y==null?void 0:y.referrer)?nn(e):{})}update_referrer_info(){var e;this.register_once({$referrer:an(),$referring_domain:y!=null&&y.referrer&&((e=Wt(y.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[ji]||this.props[qi]||this.register_once({[Bt]:on(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};M([qi,ji],(a=>{var o=this.props[a];o&&M(o,(function(l,c){e["$initial_"+Si(c)]=l}))}));var t,i,s=this.props[Bt];if(s){var n=(t=ln(s),i={},M(t,(function(a,o){i["$initial_"+Si(o)]=a})),i);N(e,n)}return e}safe_merge(e){return M(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this.Ri=this.Ti=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((a,o)=>{if(a.length!==o.length)return!1;var l=[...a].sort(),c=[...o].sort();return l.every(((u,h)=>u===c[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var s=this.ki(e),n=this.props;this.clear(),this.Y=s,this.props=n,this.save()}}set_disabled(e){this.Pi=e,this.Pi?this.remove():this.save()}set_cross_subdomain(e){e!==this.Ii&&(this.Ii=e,this.remove(),this.save())}set_secure(e){e!==this.Ci&&(this.Ci=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[ft]||{};i[e]=t,this.props[ft]=i,this.save()}remove_event_timer(e){var t=(this.props[ft]||{})[e];return _(t)||(delete this.props[ft][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var es=L("[Product Tours]"),yi="ph_product_tours";class Eo{constructor(e){this.Fi=null,this.Oi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Fr]:!(e==null||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Fi||(e=this._instance).config.disable_product_tours||(t=e.persistence)==null||!t.get_property(Fr)||this.it((()=>this.Mi()))}it(e){var t,i;(t=E.__PosthogExtensions__)!=null&&t.generateProductTours?e():(i=E.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"product-tours",(s=>{s?es.error("Could not load product tours script",s):e()}))}Mi(){var e;!this.Fi&&(e=E.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Fi=E.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!C(this.Oi)||t){var i=this._instance.persistence;if(i){var s=i.props[yi];if(C(s)&&!t)return this.Oi=s,void e(s,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:n=>{var a=n.statusCode;if(a!==200||!n.json){var o="Product Tours API could not be loaded, status: "+a;return es.error(o),void e([],{isLoaded:!1,error:o})}var l=C(n.json.product_tours)?n.json.product_tours:[];this.Oi=l,i&&i.register({[yi]:l}),e(l,{isLoaded:!0})}})}else e(this.Oi,{isLoaded:!0})}getActiveProductTours(e){R(this.Fi)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Fi.getActiveProductTours(e)}showProductTour(e){var t;(t=this.Fi)==null||t.showTourById(e)}previewTour(e){this.Fi?this.Fi.previewTour(e):this.it((()=>{var t;this.Mi(),(t=this.Fi)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.Fi)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Fi)==null||e.nextStep()}previousStep(){var e;(e=this.Fi)==null||e.previousStep()}clearCache(){var e;this.Oi=null,(e=this._instance.persistence)==null||e.unregister(yi)}resetTour(e){var t;(t=this.Fi)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.Fi)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.Fi)==null||t.cancelPendingTour(e)}}var ht=(function(r){return r.Activation="events",r.Cancellation="cancelEvents",r})({}),Yo=(function(r){return r.Button="button",r.Tab="tab",r.Selector="selector",r})({}),Jo=(function(r){return r.TopLeft="top_left",r.TopRight="top_right",r.TopCenter="top_center",r.MiddleLeft="middle_left",r.MiddleRight="middle_right",r.MiddleCenter="middle_center",r.Left="left",r.Center="center",r.Right="right",r.NextToTrigger="next_to_trigger",r})({}),Xo=(function(r){return r.Top="top",r.Left="left",r.Right="right",r.Bottom="bottom",r})({}),bi=(function(r){return r.Popover="popover",r.API="api",r.Widget="widget",r.ExternalSurvey="external_survey",r})({}),Ko=(function(r){return r.Open="open",r.MultipleChoice="multiple_choice",r.SingleChoice="single_choice",r.Rating="rating",r.Link="link",r})({}),Zo=(function(r){return r.NextQuestion="next_question",r.End="end",r.ResponseBased="response_based",r.SpecificQuestion="specific_question",r})({}),Qo=(function(r){return r.Once="once",r.Recurring="recurring",r.Always="always",r})({}),yt=(function(r){return r.SHOWN="survey shown",r.DISMISSED="survey dismissed",r.SENT="survey sent",r.ABANDONED="survey abandoned",r})({}),wi=(function(r){return r.SURVEY_ID="$survey_id",r.SURVEY_NAME="$survey_name",r.SURVEY_RESPONSE="$survey_response",r.SURVEY_ITERATION="$survey_iteration",r.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",r.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",r.SURVEY_SUBMISSION_ID="$survey_submission_id",r.SURVEY_QUESTIONS="$survey_questions",r.SURVEY_COMPLETED="$survey_completed",r.PRODUCT_TOUR_ID="$product_tour_id",r.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",r})({}),Vi=(function(r){return r.Popover="popover",r.Inline="inline",r})({}),O=L("[Surveys]"),_n="seenSurvey_",xo=(r,e)=>{var t="$survey_"+e+"/"+r.id;return r.current_iteration&&r.current_iteration>0&&(t="$survey_"+e+"/"+r.id+"/"+r.current_iteration),t},ts=r=>((e,t)=>{var i=""+e+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+e+t.id+"_"+t.current_iteration),i})(_n,r),ko=[bi.Popover,bi.Widget,bi.API],So={ignoreConditions:!1,ignoreDelay:!1,displayType:Vi.Popover};class nr{constructor(){this.Ai={},this.Ai={}}on(e,t){return this.Ai[e]||(this.Ai[e]=[]),this.Ai[e].push(t),()=>{this.Ai[e]=this.Ai[e].filter((i=>i!==t))}}emit(e,t){for(var i of this.Ai[e]||[])i(t);for(var s of this.Ai["*"]||[])s(e,t)}}function Ve(r,e,t){if(R(r))return!1;switch(t){case"exact":return r===e;case"contains":var i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(r);case"regex":try{return new RegExp(e).test(r)}catch{return!1}default:return!1}}class Po{constructor(e){this.ji=new nr,this.Di=(t,i)=>this.Li(t,i)&&this.Ni(t,i)&&this.Ui(t,i)&&this.zi(t,i),this.Li=(t,i)=>i==null||!i.event||(t==null?void 0:t.event)===(i==null?void 0:i.event),this._instance=e,this.Hi=new Set,this.Bi=new Set}init(){var e;if(!_((e=this._instance)==null?void 0:e._addCaptureHook)){var t;(t=this._instance)==null||t._addCaptureHook(((i,s)=>{this.on(i,s)}))}}register(e){var t,i;if(!_((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((a=>{var o,l;(o=this.Bi)==null||o.add(a),(l=a.steps)==null||l.forEach((c=>{var u;(u=this.Hi)==null||u.add((c==null?void 0:c.event)||"")}))})),(i=this._instance)!=null&&i.autocapture)){var s,n=new Set;e.forEach((a=>{var o;(o=a.steps)==null||o.forEach((l=>{l!=null&&l.selector&&n.add(l==null?void 0:l.selector)}))})),(s=this._instance)==null||s.autocapture.setElementSelectors(n)}}on(e,t){var i;t!=null&&e.length!=0&&(this.Hi.has(e)||this.Hi.has(t==null?void 0:t.event))&&this.Bi&&((i=this.Bi)==null?void 0:i.size)>0&&this.Bi.forEach((s=>{this.qi(t,s)&&this.ji.emit("actionCaptured",s.name)}))}Wi(e){this.onAction("actionCaptured",(t=>e(t)))}qi(e,t){if((t==null?void 0:t.steps)==null)return!1;for(var i of t.steps)if(this.Di(e,i))return!0;return!1}onAction(e,t){return this.ji.on(e,t)}Ni(e,t){if(t!=null&&t.url){var i,s=e==null||(i=e.properties)==null?void 0:i.$current_url;if(!s||typeof s!="string"||!Ve(s,t.url,t.url_matching||"contains"))return!1}return!0}Ui(e,t){return!!this.Gi(e,t)&&!!this.Vi(e,t)&&!!this.Ji(e,t)}Gi(e,t){var i;if(t==null||!t.href)return!0;var s=this.Ki(e);if(s.length>0)return s.some((o=>Ve(o.href,t.href,t.href_matching||"exact")));var n,a=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!a&&Ve((n=a.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}Vi(e,t){var i;if(t==null||!t.text)return!0;var s=this.Ki(e);if(s.length>0)return s.some((c=>Ve(c.text,t.text,t.text_matching||"exact")||Ve(c.$el_text,t.text,t.text_matching||"exact")));var n,a,o,l=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!l&&(n=(function(c){for(var u,h=[],p=/(?::|")text="(.*?)"/g;!R(u=p.exec(c));)h.includes(u[1])||h.push(u[1]);return h})(l),a=t.text,o=t.text_matching||"exact",n.some((c=>Ve(c,a,o))))}Ji(e,t){var i,s;if(t==null||!t.selector)return!0;var n=e==null||(i=e.properties)==null?void 0:i.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;var a=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}Ki(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e==null?void 0:e.properties.$elements}zi(e,t){return t==null||!t.properties||t.properties.length===0||vn(t.properties.reduce(((i,s)=>{var n=C(s.value)?s.value.map(String):s.value!=null?[String(s.value)]:[];return i[s.key]={values:n,operator:s.operator||"exact"},i}),{}),e==null?void 0:e.properties)}}class Fo{constructor(e){this._instance=e,this.Yi=new Map,this.Xi=new Map,this.Qi=new Map}Zi(e,t){return!!e&&vn(e.propertyFilters,t==null?void 0:t.properties)}te(e,t){var i=new Map;return e.forEach((s=>{var n;(n=s.conditions)==null||(n=n[t])==null||(n=n.values)==null||n.forEach((a=>{if(a!=null&&a.name){var o=i.get(a.name)||[];o.push(s.id),i.set(a.name,o)}}))})),i}ie(e,t,i){var s=(i===ht.Activation?this.Yi:this.Xi).get(e),n=[];return this.ee((a=>{n=a.filter((o=>s==null?void 0:s.includes(o.id)))})),n.filter((a=>{var o,l=(o=a.conditions)==null||(o=o[i])==null||(o=o.values)==null?void 0:o.find((c=>c.name===e));return this.Zi(l,t)}))}register(e){var t;_((t=this._instance)==null?void 0:t._addCaptureHook)||(this.re(e),this.se(e))}se(e){var t=e.filter((i=>{var s,n;return((s=i.conditions)==null?void 0:s.actions)&&((n=i.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));t.length!==0&&(this.ne==null&&(this.ne=new Po(this._instance),this.ne.init(),this.ne.Wi((i=>{this.onAction(i)}))),t.forEach((i=>{var s,n,a,o,l;i.conditions&&(s=i.conditions)!=null&&s.actions&&(n=i.conditions)!=null&&(n=n.actions)!=null&&n.values&&((a=i.conditions)==null||(a=a.actions)==null||(a=a.values)==null?void 0:a.length)>0&&((o=this.ne)==null||o.register(i.conditions.actions.values),(l=i.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.Qi.get(c.name);u&&u.push(i.id),this.Qi.set(c.name,u||[i.id])}})))})))}re(e){var t,i=e.filter((n=>{var a,o;return((a=n.conditions)==null?void 0:a.events)&&((o=n.conditions)==null||(o=o.events)==null||(o=o.values)==null?void 0:o.length)>0})),s=e.filter((n=>{var a,o;return((a=n.conditions)==null?void 0:a.cancelEvents)&&((o=n.conditions)==null||(o=o.cancelEvents)==null||(o=o.values)==null?void 0:o.length)>0}));(i.length!==0||s.length!==0)&&((t=this._instance)==null||t._addCaptureHook(((n,a)=>{this.onEvent(n,a)})),this.Yi=this.te(e,ht.Activation),this.Xi=this.te(e,ht.Cancellation))}onEvent(e,t){var i,s=this.oe(),n=this.ae(),a=this.le(),o=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[n])||[];if(a===e&&t&&o.length>0){var l,c;s.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:o});var u=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(c=t.properties)==null?void 0:c.$product_tour_id);if(u){var h=o.indexOf(u);h>=0&&(o.splice(h,1),this.ue(o))}}else{if(this.Xi.has(e)){var p=this.ie(e,t,ht.Cancellation);p.length>0&&(s.info("cancel event matched, cancelling items",{event:e,itemsToCancel:p.map((f=>f.id))}),p.forEach((f=>{var v=o.indexOf(f.id);v>=0&&o.splice(v,1),this.he(f.id)})),this.ue(o))}if(this.Yi.has(e)){s.info("event name matched",{event:e,eventPayload:t,items:this.Yi.get(e)});var g=this.ie(e,t,ht.Activation);this.ue(o.concat(g.map((f=>f.id))||[]))}}}onAction(e){var t,i=this.ae(),s=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[i])||[];this.Qi.has(e)&&this.ue(s.concat(this.Qi.get(e)||[]))}ue(e){var t,i=this.oe(),s=this.ae(),n=[...new Set(e)].filter((a=>!this.de(a)));i.info("updating activated items",{activatedItems:n}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[s]:n})}getActivatedIds(){var e,t=this.ae(),i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t];return i||[]}getEventToItemsMap(){return this.Yi}ve(){return this.ne}}class $o extends Fo{constructor(e){super(e)}ae(){return"$surveys_activated"}le(){return yt.SHOWN}ee(e){var t;(t=this._instance)==null||t.getSurveys(e)}he(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}oe(){return O}de(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class Ro{constructor(e){this.ce=void 0,this._surveyManager=null,this.fe=!1,this.pe=[],this.ge=null,this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var t=e.surveys;if(R(t))return O.warn("Flags not loaded yet. Not loading surveys.");var i=C(t);this.ce=i?t.length>0:t,O.info("flags response received, isSurveysEnabled: "+this.ce),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);(i!=null&&i.startsWith(_n)||i!=null&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach((s=>localStorage.removeItem(s)))}loadIfEnabled(){if(!this._surveyManager)if(this.fe)O.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)O.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())O.info("Not loading surveys in cookieless mode without consent.");else{var e=E==null?void 0:E.__PosthogExtensions__;if(e){if(!_(this.ce)||this._instance.config.advanced_enable_surveys){var t=this.ce||this._instance.config.advanced_enable_surveys;this.fe=!0;try{var i=e.generateSurveys;if(i)return void this._e(i,t);var s=e.loadExternalDependency;if(!s)return void this.me("PostHog loadExternalDependency extension not found.");s(this._instance,"surveys",(n=>{n||!e.generateSurveys?this.me("Could not load surveys script",n):this._e(e.generateSurveys,t)}))}catch(n){throw this.me("Error initializing surveys",n),n}finally{this.fe=!1}}}else O.error("PostHog Extensions not found.")}}_e(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new $o(this._instance),O.info("Surveys loaded successfully"),this.be({isLoaded:!0})}me(e,t){O.error(e,t),this.be({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.pe.push(e),this._surveyManager&&this.be({isLoaded:!0}),()=>{this.pe=this.pe.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this._instance.config.disable_surveys)return O.info("Disabled. Not loading surveys."),e([]);var i,s=this._instance.get_property(Ai);if(s&&!t)return e(s,{isLoaded:!0});typeof Promise<"u"&&this.ge?this.ge.then((n=>{var{surveys:a,context:o}=n;return e(a,o)})):(typeof Promise<"u"&&(this.ge=new Promise((n=>{i=n}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:n=>{var a;this.ge=null;var o=n.statusCode;if(o!==200||!n.json){var l="Surveys API could not be loaded, status: "+o;O.error(l);var c={isLoaded:!1,error:l};return e([],c),void(i==null||i({surveys:[],context:c}))}var u,h=n.json.surveys||[],p=h.filter((f=>(function(v){return!(!v.start_date||v.end_date)})(f)&&((function(v){var m;return!((m=v.conditions)==null||(m=m.events)==null||(m=m.values)==null||!m.length)})(f)||(function(v){var m;return!((m=v.conditions)==null||(m=m.actions)==null||(m=m.values)==null||!m.length)})(f))));p.length>0&&((u=this._surveyEventReceiver)==null||u.register(p)),(a=this._instance.persistence)==null||a.register({[Ai]:h});var g={isLoaded:!0};e(h,g),i==null||i({surveys:h,context:g})}}))}be(e){for(var t of this.pe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){O.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!R(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);O.warn("init was not called")}ye(e){var t=null;return this.getSurveys((i=>{var s;t=(s=i.find((n=>n.id===e)))!==null&&s!==void 0?s:null})),t}we(e){if(R(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t=typeof e=="string"?this.ye(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(R(this._surveyManager))return O.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=this.we(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return R(this._surveyManager)?(O.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((i=>{this.getSurveys((s=>{var n,a=(n=s.find((l=>l.id===e)))!==null&&n!==void 0?n:null;if(a){var o=this.we(a);i({visible:o.eligible,disabledReason:o.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t,i){var s;if(R(this._surveyManager))O.warn("init was not called");else{var n=typeof e=="string"?this.ye(e):e;if(n!=null&&n.id)if(ko.includes(n.type)){var a=y==null?void 0:y.querySelector(t);if(a)return(s=n.appearance)!=null&&s.surveyPopupDelaySeconds?(O.info("Rendering survey "+n.id+" with delay of "+n.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,l;O.info("Rendering survey "+n.id+" with delay of "+((o=n.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(n,a,i),O.info("Survey "+n.id+" rendered")}),1e3*n.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(n,a,i);O.warn("Survey element not found")}else O.warn("Surveys of type "+n.type+" cannot be rendered in the app");else O.warn("Survey not found")}}displaySurvey(e,t){var i;if(R(this._surveyManager))O.warn("init was not called");else{var s=this.ye(e);if(s){var n=s;if((i=s.appearance)!=null&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(n=w({},s,{appearance:w({},s.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Vi.Popover&&t.initialResponses&&O.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),t.ignoreConditions===!1){var a=this.canRenderSurvey(s);if(!a.visible)return void O.warn("Survey is not eligible to be displayed: ",a.disabledReason)}t.displayType!==Vi.Inline?this._surveyManager.handlePopoverSurvey(n,t):this.renderSurvey(n,t.selector,t.properties)}else O.warn("Survey not found")}}cancelPendingSurvey(e){R(this._surveyManager)?O.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}}var fe=L("[Conversations]");class Io{constructor(e){this.xe=void 0,this._conversationsManager=null,this.Ee=!1,this.$e=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var t=e.conversations;R(t)||(we(t)?this.xe=t:(this.xe=t.enabled,this.$e=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.xe=void 0,this.$e=null}loadIfEnabled(){if(!this._conversationsManager&&!this.Ee&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=E==null?void 0:E.__PosthogExtensions__;if(e&&!_(this.xe)&&this.xe)if(this.$e&&this.$e.token){this.Ee=!0;try{var t=e.initConversations;if(t)return this.Se(t),void(this.Ee=!1);var i=e.loadExternalDependency;if(!i)return void this.ke("PostHog loadExternalDependency extension not found.");i(this._instance,"conversations",(s=>{s||!e.initConversations?this.ke("Could not load conversations script",s):this.Se(e.initConversations),this.Ee=!1}))}catch(s){this.ke("Error initializing conversations",s),this.Ee=!1}}else fe.error("Conversations enabled but missing token in remote config.")}}Se(e){if(this.$e)try{this._conversationsManager=e(this.$e,this._instance),fe.info("Conversations loaded successfully")}catch(t){this.ke("Error completing conversations initialization",t)}else fe.error("Cannot complete initialization: remote config is null")}ke(e,t){fe.error(e,t),this._conversationsManager=null,this.Ee=!1}show(){this._conversationsManager?this._conversationsManager.show():fe.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.xe===!0&&!oe(this._conversationsManager)}isVisible(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.isVisible())!==null&&e!==void 0&&e}sendMessage(e,t,i){var s=this;return Ye((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(e,t,i):(fe.warn("Conversations not available yet."),null)}))()}getMessages(e,t){var i=this;return Ye((function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(fe.warn("Conversations not available yet."),null)}))()}markAsRead(e){var t=this;return Ye((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(fe.warn("Conversations not available yet."),null)}))()}getTickets(e){var t=this;return Ye((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(fe.warn("Conversations not available yet."),null)}))()}getCurrentTicketId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getCurrentTicketId())!==null&&e!==void 0?e:null}getWidgetSessionId(){var e,t;return(e=(t=this._conversationsManager)==null?void 0:t.getWidgetSessionId())!==null&&e!==void 0?e:null}}class Co{constructor(e){var t;this.Pe=!1,this.Te=!1,this._instance=e,this._instance&&(t=this._instance.config.logs)!=null&&t.captureConsoleLogs&&(this.Pe=!0)}onRemoteConfig(e){var t,i=(t=e.logs)==null?void 0:t.captureConsoleLogs;!R(i)&&i&&(this.Pe=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Pe&&!this.Te){var e=L("[logs]"),t=E==null?void 0:E.__PosthogExtensions__;if(t){var i=t.loadExternalDependency;i?i(this._instance,"logs",(s=>{var n;s||(n=t.logs)==null||!n.initializeLogs?e.error("Could not load logs script",s):(t.logs.initializeLogs(this._instance),this.Te=!0)})):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}}var is=L("[RateLimiter]");class To{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((s=>{is.info((s||"events")+" is quota limited."),this.serverLimits[s]=new Date().getTime()+6e4}))}catch(s){return void is.warn('could not rate limit - continuing. Error: "'+(s==null?void 0:s.message)+'"',{text:i})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,s;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:a}=this,o=new Date().getTime(),l=(t=(i=this.instance.persistence)==null?void 0:i.get_property(Ni))!==null&&t!==void 0?t:{tokens:n,last:o};l.tokens+=(o-l.last)/1e3*a,l.last=o,l.tokens>n&&(l.tokens=n);var c=l.tokens<1;return c||e||(l.tokens=Math.max(0,l.tokens-1)),!c||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+a+" events per second and "+n+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=c,(s=this.instance.persistence)==null||s.set_property(Ni,l),{isRateLimited:c,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}}var Le=L("[RemoteConfig]");class Oo{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=E._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Ie(e){var t,i;(t=E.__PosthogExtensions__)!=null&&t.loadExternalDependency?(i=E.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(Le.error("PostHog Extensions not found. Cannot load remote config."),e())}Ce(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return Le.info("Using preloaded remote config",this.remoteConfig),void this.wi(this.remoteConfig);if(this._instance.M())return void Le.warn("Remote config is disabled. Falling back to local config.");this.Ie((e=>{if(!e)return Le.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ce((t=>{this.wi(t)}));this.wi(e)}))}catch(e){Le.error("Error loading remote config",e)}}wi(e){e?this._instance.config.__preview_remote_config?(this._instance.wi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):Le.info("__preview_remote_config is disabled. Logging config instead",e):Le.error("Failed to fetch remote config from PostHog.")}}var Wi=3e3;class Mo{constructor(e,t){this.Re=!0,this.Fe=[],this.Oe=de((t==null?void 0:t.flush_interval_ms)||Wi,250,5e3,b.createLogger("flush interval"),Wi),this.Me=e}enqueue(e){this.Fe.push(e),this.Ae||this.je()}unload(){this.De();var e=this.Fe.length>0?this.Le():{},t=Object.values(e);[...t.filter((i=>i.url.indexOf("/e")===0)),...t.filter((i=>i.url.indexOf("/e")!==0))].map((i=>{this.Me(w({},i,{transport:"sendBeacon"}))}))}enable(){this.Re=!1,this.je()}je(){var e=this;this.Re||(this.Ae=setTimeout((()=>{if(this.De(),this.Fe.length>0){var t=this.Le(),i=function(){var n=t[s],a=new Date().getTime();n.data&&C(n.data)&&M(n.data,(o=>{o.offset=Math.abs(o.timestamp-a),delete o.timestamp})),e.Me(n)};for(var s in t)i()}}),this.Oe))}De(){clearTimeout(this.Ae),this.Ae=void 0}Le(){var e={};return M(this.Fe,(t=>{var i,s=t,n=(s?s.batchKey:null)||s.url;_(e[n])&&(e[n]=w({},s,{data:[]})),(i=e[n].data)==null||i.push(s.data)})),this.Fe=[],e}}var Ao=["retriesPerformedSoFar"];class Do{constructor(e){this.Ne=!1,this.Ue=3e3,this.Fe=[],this._instance=e,this.Fe=[],this.ze=!0,!_(d)&&"onLine"in d.navigator&&(this.ze=d.navigator.onLine,this.He=()=>{this.ze=!0,this.Lt()},this.Be=()=>{this.ze=!1},j(d,"online",this.He),j(d,"offline",this.Be))}get length(){return this.Fe.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=hs(e,Ao);We(t)&&(i.url=Kt(i.url,{retry_count:t})),this._instance._send_request(w({},i,{callback:s=>{s.statusCode!==200&&(s.statusCode<400||s.statusCode>=500)&&(t??0)<10?this.qe(w({retriesPerformedSoFar:t},i)):i.callback==null||i.callback(s)}}))}qe(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=(function(a){var o=3e3*Math.pow(2,a),l=o/2,c=Math.min(18e5,o),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(t),s=Date.now()+i;this.Fe.push({retryAt:s,requestOptions:e});var n="Enqueued failed request for retry in "+i;navigator.onLine||(n+=" (Browser is offline)"),b.warn(n),this.Ne||(this.Ne=!0,this.We())}We(){if(this.Ge&&clearTimeout(this.Ge),this.Fe.length===0)return this.Ne=!1,void(this.Ge=void 0);this.Ge=setTimeout((()=>{this.ze&&this.Fe.length>0&&this.Lt(),this.We()}),this.Ue)}Lt(){var e=Date.now(),t=[],i=this.Fe.filter((n=>n.retryAt<e||(t.push(n),!1)));if(this.Fe=t,i.length>0)for(var{requestOptions:s}of i)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this.Ge&&(clearTimeout(this.Ge),this.Ge=void 0),this.Ne=!1,_(d)||(this.He&&(d.removeEventListener("online",this.He),this.He=void 0),this.Be&&(d.removeEventListener("offline",this.Be),this.Be=void 0)),this.Fe))try{this._instance._send_request(w({},e,{transport:"sendBeacon"}))}catch(t){b.error(t)}this.Fe=[]}}class Lo{constructor(e){this.Ve=()=>{var t,i,s,n;this.Je||(this.Je={});var a=this.scrollElement(),o=this.scrollY(),l=a?Math.max(0,a.scrollHeight-a.clientHeight):0,c=o+((a==null?void 0:a.clientHeight)||0),u=(a==null?void 0:a.scrollHeight)||0;this.Je.lastScrollY=Math.ceil(o),this.Je.maxScrollY=Math.max(o,(t=this.Je.maxScrollY)!==null&&t!==void 0?t:0),this.Je.maxScrollHeight=Math.max(l,(i=this.Je.maxScrollHeight)!==null&&i!==void 0?i:0),this.Je.lastContentY=c,this.Je.maxContentY=Math.max(c,(s=this.Je.maxContentY)!==null&&s!==void 0?s:0),this.Je.maxContentHeight=Math.max(u,(n=this.Je.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}getContext(){return this.Je}resetContext(){var e=this.Je;return setTimeout(this.Ve,0),e}startMeasuringScrollPosition(){j(d,"scroll",this.Ve,{capture:!0}),j(d,"scrollend",this.Ve,{capture:!0}),j(d,"resize",this.Ve)}scrollElement(){if(!this._instance.config.scroll_root_selector)return d==null?void 0:d.document.documentElement;var e=C(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var t of e){var i=d==null?void 0:d.document.querySelector(t);if(i)return i}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return d&&(d.scrollY||d.pageYOffset||d.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return d&&(d.scrollX||d.pageXOffset||d.document.documentElement.scrollLeft)||0}}var No=r=>on(r==null?void 0:r.config.mask_personal_data_properties,r==null?void 0:r.config.custom_personal_data_properties);class rs{constructor(e,t,i,s){this.Ke=n=>{var a=this.Ye();if(!a||a.sessionId!==n){var o={sessionId:n,props:this.Xe(this._instance)};this.Qe.register({[Li]:o})}},this._instance=e,this.Ze=t,this.Qe=i,this.Xe=s||No,this.Ze.onSessionId(this.Ke)}Ye(){return this.Qe.props[Li]}getSetOnceProps(){var e,t=(e=this.Ye())==null?void 0:e.props;return t?"r"in t?ln(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return M(Qi(this.getSetOnceProps()),((t,i)=>{i==="$current_url"&&(i="url"),e["$session_entry_"+Si(i)]=t})),e}}var Ei=L("[SessionId]");class ss{on(e,t){return this.tr.on(e,t)}constructor(e,t,i){var s;if(this.ir=[],this.er=void 0,this.tr=new nr,this.rr=(u,h)=>!(!We(u)||!We(h))&&Math.abs(u-h)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.Qe=e.persistence,this.sr=void 0,this.nr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ar=t||Ie,this.lr=i||Ie;var n=this.R.persistence_name||this.R.token,a=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*de(a,60,36e3,Ei.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ur(),this.hr="ph_"+n+"_window_id",this.dr="ph_"+n+"_primary_window_exists",this.vr()){var o=B.W(this.hr),l=B.W(this.dr);o&&!l?this.sr=o:B.V(this.hr),B.G(this.dr,!0)}if((s=this.R.bootstrap)!=null&&s.sessionID)try{var c=(u=>{var h=u.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)})(this.R.bootstrap.sessionID);this.cr(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){Ei.error("Invalid sessionID in bootstrap",u)}this.pr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return _(this.ir)&&(this.ir=[]),this.ir.push(e),this.nr&&e(this.nr,this.sr),()=>{this.ir=this.ir.filter((t=>t!==e))}}vr(){return this.R.persistence!=="memory"&&!this.Qe.Pi&&B.H()}gr(e){e!==this.sr&&(this.sr=e,this.vr()&&B.G(this.hr,e))}_r(){return this.sr?this.sr:this.vr()?B.W(this.hr):null}cr(e,t,i){e===this.nr&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.nr=e,this.Qe.register({[Ht]:[t,e,i]}))}mr(){var e=this.Qe.props[Ht];return C(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.cr(null,null,null)}destroy(){clearTimeout(this.br),this.br=void 0,this.er&&d&&(d.removeEventListener("beforeunload",this.er,{capture:!1}),this.er=void 0),this.ir=[]}pr(){this.er=()=>{this.vr()&&B.V(this.dr)},j(d,"beforeunload",this.er,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||new Date().getTime(),[s,n,a]=this.mr(),o=this._r(),l=We(a)&&Math.abs(i-a)>864e5,c=!1,u=!n,h=!u&&!e&&this.rr(i,s);u||h||l?(n=this.ar(),o=this.lr(),Ei.info("new session ID generated",{sessionId:n,windowId:o,changeReason:{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}}),a=i,c=!0):o||(o=this.lr(),c=!0);var p=We(s)&&e&&!l?s:i,g=We(a)?a:new Date().getTime();return this.gr(o),this.cr(n,p,g),e||this.ur(),c&&this.ir.forEach((f=>f(n,o,c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:o,sessionStartTimestamp:g,changeReason:c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:s}}ur(){clearTimeout(this.br),this.br=setTimeout((()=>{var[e]=this.mr();if(this.rr(new Date().getTime(),e)){var t=this.nr;this.resetSessionId(),this.tr.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}}var jo=["$set_once","$set"],$e=L("[SiteApps]");class qo{constructor(e){this._instance=e,this.yr=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}wr(e,t){if(t){var i=this.globalsForEvent(t);this.yr.push(i),this.yr.length>1e3&&(this.yr=this.yr.slice(10))}}get siteAppLoaders(){var e;return(e=E._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.wr.bind(this));this.Er=()=>{e(),this.yr=[],this.Er=void 0}}}globalsForEvent(e){var t,i,s,n,a,o,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var[p,g]of Object.entries(h))c[p]={id:u[p],type:p,properties:g};var{$set_once:f,$set:v}=e;return{event:w({},hs(e,jo),{properties:w({},e.properties,v?{$set:w({},(t=(i=e.properties)==null?void 0:i.$set)!==null&&t!==void 0?t:{},v)}:{},f?{$set_once:w({},(s=(n=e.properties)==null?void 0:n.$set_once)!==null&&s!==void 0?s:{},f)}:{}),elements_chain:(a=(o=e.properties)==null?void 0:o.$elements_chain)!==null&&a!==void 0?a:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var o;!t.errored&&this.yr.length&&($e.info("Processing "+this.yr.length+" events for site app with id "+e.id),this.yr.forEach((l=>t.processEvent==null?void 0:t.processEvent(l))),t.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((o=this.Er)==null||o.call(this))},s=!1,n=o=>{t.errored=!o,t.loaded=!0,$e.info("Site app with id "+e.id+" "+(o?"loaded":"errored")),s&&i()};try{var{processEvent:a}=e.init({posthog:this._instance,callback:o=>{n(o)}});a&&(t.processEvent=a),s=!0}catch(o){$e.error("Error while initializing PostHog app with config id "+e.id,o),n(!1)}if(s&&t.loaded)try{i()}catch(o){$e.error("Error while processing buffered events PostHog app with config id "+e.id,o),t.errored=!0}}$r(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}Sr(e){if(Object.keys(this.apps).length!==0){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{i.processEvent==null||i.processEvent(t)}catch(s){$e.error("Error while processing event "+e.event+" for site app "+i.id,s)}}}onRemoteConfig(e){var t,i,s,n=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.$r(),void this._instance.on("eventCaptured",(c=>this.Sr(c)))):void $e.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((i=this.Er)==null||i.call(this),(s=e.siteApps)!=null&&s.length)if(this.isEnabled){var a=function(c){var u;E["__$$ph_site_app_"+c]=n._instance,(u=E.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(n._instance,l,(h=>{if(h)return $e.error("Error while initializing PostHog app with config id "+c,h)}))};for(var{id:o,url:l}of e.siteApps)a(o)}else $e.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var mn=function(r,e){if(!r)return!1;var t=r.userAgent;if(t&&gr(t,e))return!0;try{var i=r==null?void 0:r.userAgentData;if(i!=null&&i.brands&&i.brands.some((s=>gr(s==null?void 0:s.brand,e))))return!0}catch{}return!!r.webdriver},bt=(function(r){return r.US="us",r.EU="eu",r.CUSTOM="custom",r})({}),ns="i.posthog.com";class Ho{constructor(e){this.kr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ns,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.kr[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=bt.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=bt.EU:this.kr[this.apiHost]=bt.CUSTOM),this.kr[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===bt.CUSTOM)return this.apiHost+t;var i=ns+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var Uo={icontains:(r,e)=>!!d&&e.href.toLowerCase().indexOf(r.toLowerCase())>-1,not_icontains:(r,e)=>!!d&&e.href.toLowerCase().indexOf(r.toLowerCase())===-1,regex:(r,e)=>!!d&&Zt(e.href,r),not_regex:(r,e)=>!!d&&!Zt(e.href,r),exact:(r,e)=>e.href===r,is_not:(r,e)=>e.href!==r};class z{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),t.getWebExperiments((s=>{z.Pr("retrieved web experiments from the server"),t.Tr=new Map,s.forEach((n=>{if(n.feature_flag_key){var a;t.Tr&&(z.Pr("setting flag key ",n.feature_flag_key," to web experiment ",n),(a=t.Tr)==null||a.set(n.feature_flag_key,n));var o=t._instance.getFeatureFlag(n.feature_flag_key);U(o)&&n.variants[o]&&t.Ir(n.name,o,n.variants[o].transforms)}else if(n.variants)for(var l in n.variants){var c=n.variants[l];z.Cr(c)&&t.Ir(n.name,l,c.transforms)}}))}),i)},this._instance=e,this._instance.onFeatureFlags((i=>{this.onFeatureFlags(i)}))}onFeatureFlags(e){if(this._is_bot())z.Pr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(R(this.Tr))return this.Tr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();z.Pr("applying feature flags",e),e.forEach((t=>{var i;if(this.Tr&&(i=this.Tr)!=null&&i.has(t)){var s,n=this._instance.getFeatureFlag(t),a=(s=this.Tr)==null?void 0:s.get(t);n&&a!=null&&a.variants[n]&&this.Ir(a.name,n,a.variants[n].transforms)}}))}}previewWebExperiment(){var e=z.getWindowLocation();if(e!=null&&e.search){var t=zt(e==null?void 0:e.search,"__experiment_id"),i=zt(e==null?void 0:e.search,"__experiment_variant");t&&i&&(z.Pr("previewing web experiments "+t+" && "+i),this.getWebExperiments((s=>{this.Rr(parseInt(t),i,s)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this._instance.config.disable_web_experiments&&!i)return e([]);var s=this._instance.get_property("$web_experiments");if(s&&!t)return e(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:n=>{if(n.statusCode!==200||!n.json)return e([]);var a=n.json.experiments||[];return e(a)}})}Rr(e,t,i){var s=i.filter((n=>n.id===e));s&&s.length>0&&(z.Pr("Previewing web experiment ["+s[0].name+"] with variant ["+t+"]"),this.Ir(s[0].name,t,s[0].variants[t].transforms))}static Cr(e){return!R(e.conditions)&&z.Fr(e)&&z.Or(e)}static Fr(e){var t;if(R(e.conditions)||R((t=e.conditions)==null?void 0:t.url))return!0;var i,s,n,a=z.getWindowLocation();return!!a&&((i=e.conditions)==null||!i.url||Uo[(s=(n=e.conditions)==null?void 0:n.urlMatchType)!==null&&s!==void 0?s:"icontains"](e.conditions.url,a))}static getWindowLocation(){return d==null?void 0:d.location}static Or(e){var t;if(R(e.conditions)||R((t=e.conditions)==null?void 0:t.utm))return!0;var i=rn();if(i.utm_source){var s,n,a,o,l,c,u,h,p=(s=e.conditions)==null||(s=s.utm)==null||!s.utm_campaign||((n=e.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==i.utm_campaign,g=(a=e.conditions)==null||(a=a.utm)==null||!a.utm_source||((o=e.conditions)==null||(o=o.utm)==null?void 0:o.utm_source)==i.utm_source,f=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==i.utm_medium,v=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==i.utm_term;return p&&f&&v&&g}return!1}static Pr(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];b.info("[WebExperiments] "+e,i)}Ir(e,t,i){this._is_bot()?z.Pr("Refusing to render web experiment since the viewer is a likely bot"):t!=="control"?i.forEach((s=>{if(s.selector){var n;z.Pr("applying transform of variant "+t+" for experiment "+e+" ",s);var a=(n=document)==null?void 0:n.querySelectorAll(s.selector);a==null||a.forEach((o=>{var l=o;s.html&&(l.innerHTML=s.html),s.css&&l.setAttribute("style",s.css)}))}})):z.Pr("Control variants leave the page unmodified.")}_is_bot(){return te&&this._instance?mn(te,this._instance.config.custom_blocked_useragents):void 0}}var Bo=L("[PostHog ExternalIntegrations]"),Go={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class Vo{constructor(e){this._instance=e}it(e,t){var i;(i=E.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,e,(s=>{if(s)return Bo.error("failed to load script",s);t()}))}startIfEnabledOrStop(){var e=this,t=function(a){var o,l,c;!s||(o=E.__PosthogExtensions__)!=null&&(o=o.integrations)!=null&&o[a]||e.it(Go[a],(()=>{var u;(u=E.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[a])==null||u.start(e._instance)})),!s&&(l=E.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[a]&&((c=E.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[a])==null||c.stop())};for(var[i,s]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;t(i)}}}var zi="[SessionRecording]",dt=L(zi);class as{get started(){var e;return!((e=this.Mr)==null||!e.isStarted)}get status(){return this.Mr?this.Mr.status:this.Ar&&!this.jr?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Ar=!1,this.Dr=void 0,this._instance=e,!this._instance.sessionManager)throw dt.error("started without valid sessionManager"),new Error(zi+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(zi+' cannot be used with cookieless_mode="always"')}get jr(){var e,t=!((e=this._instance.get_property(li))==null||!e.enabled),i=!this._instance.config.disable_session_recording,s=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return d&&t&&i&&!s}startIfEnabledOrStop(e){var t;if(!this.jr||(t=this.Mr)==null||!t.isStarted){var i=!_(Object.assign)&&!_(Array.from);this.jr&&i?(this.Lr(e),dt.info("starting")):this.stopRecording()}}Lr(e){var t,i,s;this.jr&&(E!=null&&(t=E.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(i=E.__PosthogExtensions__)!=null&&i.initSessionRecording?this.Nr(e):(s=E.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,this.Ur,(n=>{if(n)return dt.error("could not load recorder",n);this.Nr(e)})))}stopRecording(){var e,t;(e=this.Dr)==null||e.call(this),this.Dr=void 0,(t=this.Mr)==null||t.stop()}zr(){var e;(e=this._instance.persistence)==null||e.unregister(Ls)}Hr(e){if(this._instance.persistence){var t,i,s=this._instance.persistence,n=()=>{var a=e.sessionRecording===!1?void 0:e.sessionRecording,o=a==null?void 0:a.sampleRate,l=R(o)?null:parseFloat(o);R(l)&&this.zr();var c=a==null?void 0:a.minimumDurationMilliseconds;s.register({[li]:w({cache_timestamp:Date.now(),enabled:!!a},a,{networkPayloadCapture:w({capturePerformance:e.capturePerformance},a==null?void 0:a.networkPayloadCapture),canvasRecording:{enabled:a==null?void 0:a.recordCanvas,fps:a==null?void 0:a.canvasFps,quality:a==null?void 0:a.canvasQuality},sampleRate:l,minimumDurationMilliseconds:_(c)?null:c,endpoint:a==null?void 0:a.endpoint,triggerMatchType:a==null?void 0:a.triggerMatchType,masking:a==null?void 0:a.masking,urlTriggers:a==null?void 0:a.urlTriggers})})};n(),(t=this.Dr)==null||t.call(this),this.Dr=(i=this._instance.sessionManager)==null?void 0:i.onSessionId(n)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.Hr(e),this.Ar=!0,this.startIfEnabledOrStop()):this.Ar=!0:dt.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;t===void 0&&(t="log"),(i=this.Mr)!=null&&i.log?this.Mr.log(e,t):dt.warn("log called before recorder was ready")}get Ur(){var e,t,i=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(li);return(i==null||(t=i.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Nr(e){var t,i;if((t=E.__PosthogExtensions__)==null||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Mr||(this.Mr=(i=E.__PosthogExtensions__)==null?void 0:i.initSessionRecording(this._instance),this.Mr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Mr.start(e)}onRRwebEmit(e){var t;(t=this.Mr)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Mr||(t=this._instance.persistence)==null||t.register({$replay_override_linked_flag:!0}),(e=this.Mr)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Mr||(t=this._instance.persistence)==null||t.register({$replay_override_sampling:!0}),(e=this.Mr)==null||e.overrideSampling()}overrideTrigger(e){var t,i;this.Mr||(i=this._instance.persistence)==null||i.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(t=this.Mr)==null||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Mr)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!((i=this.Mr)==null||!i.tryAddCustomEvent(e,t))}}var Et={},Yi=()=>{},ze="posthog",yn=!lo&&(X==null?void 0:X.indexOf("MSIE"))===-1&&(X==null?void 0:X.indexOf("Mozilla"))===-1,os=r=>{var e;return w({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:pa(y==null?void 0:y.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Yi,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:r??"unset",__preview_deferred_init_extensions:!1,debug:G&&U(G==null?void 0:G.search)&&G.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(d==null||(e=d.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:t=>{var i="Bad HTTP status: "+t.statusCode+" "+t.text;b.error(i)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Wi},error_tracking:{},_onCapture:Yi,__preview_eager_load_replay:!1},(t=>({rageclick:!(t&&t>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(t&&t>="2025-05-24")||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(r))},ls=r=>{var e={};_(r.process_person)||(e.person_profiles=r.process_person),_(r.xhr_headers)||(e.request_headers=r.xhr_headers),_(r.cookie_name)||(e.persistence_name=r.cookie_name),_(r.disable_cookie)||(e.disable_persistence=r.disable_cookie),_(r.store_google)||(e.save_campaign_params=r.store_google),_(r.verbose)||(e.debug=r.verbose);var t=N({},e,r);return C(r.property_blacklist)&&(_(r.property_denylist)?t.property_denylist=r.property_blacklist:C(r.property_denylist)?t.property_denylist=[...r.property_blacklist,...r.property_denylist]:b.error("Invalid value for property_denylist config: "+r.property_denylist)),t};class Wo{constructor(){this.__forceAllowLocalhost=!1}get Br(){return this.__forceAllowLocalhost}set Br(e){b.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class ii{get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new Wo,this.qr=!1,this.version=ve.LIB_VERSION,this.bi=new nr,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=os(),this.SentryIntegration=Ua,this.sentryIntegration=e=>(function(t,i){var s=tn(t,i);return{name:en,processEvent:n=>s(n)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new bo(this),this.toolbar=new Ga(this),this.scrollManager=new Lo(this),this.pageViewManager=new Br(this),this.surveys=new Ro(this),this.conversations=new Io(this),this.logs=new Co(this),this.experiments=new z(this),this.exceptions=new uo(this),this.rateLimiter=new To(this),this.requestRouter=new Ho(this),this.consent=new Da(this),this.externalIntegrations=new Vo(this),this.people={set:(e,t,i)=>{var s=U(e)?{[e]:t}:e;this.setPersonProperties(s),i==null||i({})},set_once:(e,t,i)=>{var s=U(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),i==null||i({})}},this.on("eventCaptured",(e=>b.info('send "'+(e==null?void 0:e.event)+'"',e)))}init(e,t,i){if(i&&i!==ze){var s,n=(s=Et[i])!==null&&s!==void 0?s:new ii;return n._init(e,t,i),Et[i]=n,Et[ze][i]=n,n}return this._init(e,t,i)}_init(e,t,i){var s;if(t===void 0&&(t={}),_(e)||Pi(e))return b.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 this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(N({},os(t.defaults),ls(t),{name:i,token:e})),this.config.on_xhr_error&&b.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ye.GZipJS;var n=this.Qr();this.persistence=new mi(this.config,n),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new mi(w({},this.config,{persistence:"sessionStorage"}),n);var a=w({},this.persistence.props),o=w({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Zr=new Mo((k=>this.ts(k)),this.config.request_queue_config),this.es=new Do(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 ss(this),this.sessionPropsManager=new rs(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(b.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.rs(l)}),0)):(b.info("Initializing extensions synchronously"),this.rs(l)),ve.DEBUG=ve.DEBUG||this.config.debug,ve.DEBUG&&b.info("Starting in debug mode",{this:this,config:t,thisC:w({},this.config),p:a,s:o}),((s=t.bootstrap)==null?void 0:s.distinctID)!==void 0){var c,u,h=this.config.get_device_id(Ie()),p=(c=t.bootstrap)!=null&&c.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(_e,(u=t.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:p})}if(this.ss()){var g,f,v=Object.keys(((g=t.bootstrap)==null?void 0:g.featureFlags)||{}).filter((k=>{var I;return!((I=t.bootstrap)==null||(I=I.featureFlags)==null||!I[k])})).reduce(((k,I)=>{var $;return k[I]=(($=t.bootstrap)==null||($=$.featureFlags)==null?void 0:$[I])||!1,k}),{}),m=Object.keys(((f=t.bootstrap)==null?void 0:f.featureFlagPayloads)||{}).filter((k=>v[k])).reduce(((k,I)=>{var $,x;return($=t.bootstrap)!=null&&($=$.featureFlagPayloads)!=null&&$[I]&&(k[I]=(x=t.bootstrap)==null||(x=x.featureFlagPayloads)==null?void 0:x[I]),k}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:m})}if(l)this.register_once({distinct_id:st,$device_id:null},"");else if(!this.get_distinct_id()){var S=this.config.get_device_id(Ie());this.register_once({distinct_id:S,$device_id:S},""),this.persistence.set_property(_e,"anonymous")}return j(d,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?Ha(this,(()=>this.ns())):this.ns(),Ce(this.config._onCapture)&&this.config._onCapture!==Yi&&(b.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(k=>this.config._onCapture(k.event,k)))),this.config.ip&&b.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}rs(e){var t=performance.now();this.historyAutocapture=new qa(this),this.historyAutocapture.startIfEnabled();var i=[];i.push((()=>{new Wa(this).startIfEnabledOrStop()})),i.push((()=>{var s;this.siteApps=new qo(this),(s=this.siteApps)==null||s.init()})),e||i.push((()=>{this.sessionRecording=new as(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),i.push((()=>{this.autocapture=new $a(this),this.autocapture.startIfEnabled()})),i.push((()=>{this.surveys.loadIfEnabled()})),i.push((()=>{this.logs.loadIfEnabled()})),i.push((()=>{this.conversations.loadIfEnabled()})),i.push((()=>{this.productTours=new Eo(this),this.productTours.loadIfEnabled()})),i.push((()=>{this.heatmaps=new Qa(this),this.heatmaps.startIfEnabled()})),i.push((()=>{this.webVitalsAutocapture=new Ka(this)})),i.push((()=>{this.exceptionObserver=new ja(this),this.exceptionObserver.startIfEnabledOrStop()})),i.push((()=>{this.deadClicksAutocapture=new Qs(this,Na),this.deadClicksAutocapture.startIfEnabledOrStop()})),i.push((()=>{if(this.os){var s=this.os;this.os=void 0,this.wi(s)}})),this.ls(i,t)}ls(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.ls(e,t)}),0);var i=e.shift();if(i)try{i()}catch(n){b.error("Error initializing extension:",n)}}var s=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:s}),this.config.__preview_deferred_init_extensions&&b.info("PostHog extensions initialized ("+s+"ms)")}wi(e){var t,i,s,n,a,o,l,c,u;if(!y||!y.body)return b.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.wi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.os=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=F(e.supportedCompression,ye.GZipJS)?ye.GZipJS:F(e.supportedCompression,ye.Base64)?ye.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"identified_only"}),(i=this.siteApps)==null||i.onRemoteConfig(e),(s=this.sessionRecording)==null||s.onRemoteConfig(e),(n=this.autocapture)==null||n.onRemoteConfig(e),(a=this.heatmaps)==null||a.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(o=this.productTours)==null||o.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(i){b.critical("`loaded` function failed",i)}if(this.us(),this.config.internal_or_test_user_hostname&&G!=null&&G.hostname){var e=G.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.hs()}),1),new Oo(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Zr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Te(this.__request_queue,(e=>this.ts(e))),this.__request_queue=[],this.us()}_handle_unload(){var e,t;this.surveys.handlePageUnload(),this.config.request_batching?(this.ds()&&this.capture("$pageleave"),(e=this.Zr)==null||e.unload(),(t=this.es)==null||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(yn?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Kt(e.url,{ip:this.config.ip?1:0}),e.headers=w({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var i,s,n,a=w({},t);a.timeout=a.timeout||6e4,a.url=Kt(a.url,{_:new Date().getTime().toString(),ver:ve.LIB_VERSION,compression:a.compression});var o=(i=a.transport)!==null&&i!==void 0?i:"fetch",l=Lt.filter((u=>!a.disableTransport||!u.transport||!a.disableTransport.includes(u.transport))),c=(s=(n=Ms(l,(u=>u.transport===o)))==null?void 0:n.method)!==null&&s!==void 0?s:l[0].method;if(!c)throw new Error("No available transport method");c(a)})(w({},e,{callback:t=>{var i,s;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&((i=(s=this.config).on_request_error)==null||i.call(s,t)),e.callback==null||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],s=[],n=[];Te(e,(o=>{o&&(t=o[0],C(t)?n.push(o):Ce(o)?o.call(this):C(o)&&t==="alias"?i.push(o):C(o)&&t.indexOf("capture")!==-1&&Ce(this[t])?n.push(o):s.push(o))}));var a=function(o,l){Te(o,(function(c){if(C(c[0])){var u=l;M(c,(function(h){u=u[h[0]].apply(u,h.slice(1))}))}else this[c[0]].apply(this,c.slice(1))}),l)};a(i,this),a(s,this),a(n,this)}ss(){var e,t;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)==null?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,i){var s;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!_(e)&&U(e)){var n=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(n&&!this.config.__preview_capture_bot_pageviews)){var a=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(a==null||!a.isRateLimited){t!=null&&t.$current_url&&!U(t==null?void 0:t.$current_url)&&(b.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var o=new Date,l=(i==null?void 0:i.timestamp)||o,c=Ie(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,t||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&n&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),a&&(u.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens),i!=null&&i.$set&&(u.$set=i==null?void 0:i.$set);var h,p=e!=="$groupidentify",g=this.vs(i==null?void 0:i.$set_once,p);if(g&&(u.$set_once=g),(u=ha(u,i!=null&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,_(i==null?void 0:i.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=o),e===yt.DISMISSED||e===yt.SENT){var f=t==null?void 0:t[wi.SURVEY_ID],v=t==null?void 0:t[wi.SURVEY_ITERATION];h={id:f,current_iteration:v},localStorage.getItem(ts(h))||localStorage.setItem(ts(h),"true"),u.$set=w({},u.$set,{[xo({id:f,current_iteration:v},e===yt.SENT?"responded":"dismissed")]:!0})}else e===yt.SHOWN&&(u.$set=w({},u.$set,{[wi.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var m=w({},u.properties.$set,u.$set);if(Je(m)||this.setPersonPropertiesForFlags(m),!R(this.config.before_send)){var S=this.cs(u);if(!S)return;u=S}this.bi.emit("eventCaptured",u);var k={method:"POST",url:(s=i==null?void 0:i._url)!==null&&s!==void 0?s:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:i==null?void 0:i._batchKey};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.ts(k):this.Zr.enqueue(k),u}b.critical("This capture call is ignored due to client rate limiting.")}}else b.error("No event name provided to posthog.capture")}else b.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,i,s,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var a=n?void 0:this.persistence.remove_event_timer(e),o=w({},t);if(o.token=this.config.token,o.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(o.$cookieless_mode=!0),e==="$snapshot"){var l=w({},this.persistence.properties(),this.sessionPersistence.properties());return o.distinct_id=l.distinct_id,(!U(o.distinct_id)&&!Ee(o.distinct_id)||Pi(o.distinct_id))&&b.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),o}var c,u=Xa(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:p}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime());o.$session_id=h,o.$window_id=p}this.sessionPropsManager&&N(o,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&N(o,this.sessionRecording.sdkDebugProperties),o.$sdk_debug_retry_queue_size=(g=this.es)==null?void 0:g.length}catch(S){o.$sdk_debug_error_capturing_properties=String(S)}if(this.requestRouter.region===bt.CUSTOM&&(o.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||n?e!=="$pageleave"||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,s),o=N(o,c),e==="$pageview"&&y&&(o.title=y.title),!_(a)){var f=i.getTime()-a;o.$duration=parseFloat((f/1e3).toFixed(3))}X&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?"bot":"browser"),(o=N({},u,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),C(this.config.property_denylist)?M(this.config.property_denylist,(function(S){delete o[S]})):b.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(b.error("sanitize_properties is deprecated. Use before_send instead"),o=v(o,e));var m=this.fs();return o.$process_person_profile=m,m&&!n&&this.ps("_calculate_event_properties"),o}vs(e,t){var i;if(t===void 0&&(t=!0),!this.persistence||!this.fs()||this.qr)return e;var s=this.persistence.get_initial_props(),n=(i=this.sessionPropsManager)==null?void 0:i.getSetOnceProps(),a=N({},s,n||{},e||{}),o=this.config.sanitize_properties;return o&&(b.error("sanitize_properties is deprecated. Use before_send instead"),a=o(a,"$set_once")),t&&(this.qr=!0),Je(a)?void 0:a}register(e,t){var i;(i=this.persistence)==null||i.register(e,t)}register_once(e,t,i){var s;(s=this.persistence)==null||s.register_once(e,t,i)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}gs(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){return this.featureFlags.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){return this.featureFlags.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateFlags(e,t,i){var s=i!=null&&i.merge?this.featureFlags.getFlagVariants():{},n=i!=null&&i.merge?this.featureFlags.getFlagPayloads():{},a=w({},s,e),o=w({},n,t),l={};for(var[c,u]of Object.entries(a)){var h=typeof u=="string";l[c]={key:c,enabled:!!h||!!u,variant:h?u:void 0,reason:void 0,metadata:_(o==null?void 0:o[c])?void 0:{id:0,version:void 0,description:void 0,payload:o[c]}}}this.featureFlags.receivedFeatureFlags({flags:l})}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return t===void 0&&(t=!1),this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.bi.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var t,i;return(t=(i=this.sessionManager)==null?void 0:i.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){t===void 0&&(t=So),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,i){if(!this.__loaded||!this.persistence)return b.uninitializedWarning("posthog.identify");if(Ee(e)&&(e=e.toString(),b.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()))b.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!==st){if(this.ps("posthog.identify")){var s=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=s;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==s&&e!==this.get_property(gt)&&(this.unregister(gt),this.register({distinct_id:e}));var a=(this.persistence.get_property(_e)||"anonymous")==="anonymous";e!==s&&a?(this.persistence.set_property(_e,"identified"),this.setPersonPropertiesForFlags(w({},i||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:s},{$set:t||{},$set_once:i||{}}),this.Jr=Jr(e,t,i),this.featureFlags.setAnonymousDistinctId(s)):(t||i)&&this.setPersonProperties(t,i),e!==s&&(this.reloadFeatureFlags(),this.unregister(Ut))}}else b.critical('The string "'+st+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else b.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var i=Jr(this.get_distinct_id(),e,t);this.Jr!==i?(this.setPersonPropertiesForFlags(w({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=i):b.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var s=this.getGroups();s[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:w({},s,{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),s[e]===t||i||this.reloadFeatureFlags()}else b.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,n;if(b.info("reset"),!this.__loaded)return b.uninitializedWarning("posthog.reset");var a=this.get_property("$device_id");if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(i=this.sessionPersistence)==null||i.clear(),this.surveys.reset(),this.featureFlags.reset(),(s=this.persistence)==null||s.set_property(_e,"anonymous"),(n=this.sessionManager)==null||n.resetSessionId(),this.Jr=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:st,$device_id:null},"");else{var o=this.config.get_device_id(Ie());this.register_once({distinct_id:o,$device_id:e?o:a},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),s=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&i){var n,a=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!i)return s;s+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-a,0)}return s}alias(e,t){return e===this.get_property(As)?(b.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(_(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(gt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(b.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=w({},this.config);if(H(e)){var i,s,n,a,o,l,c,u;N(this.config,ls(e));var h=this.Qr();(i=this.persistence)==null||i.update_config(this.config,t,h),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new mi(w({},this.config,{persistence:"sessionStorage"}),h);var p=this.Kr(this.config.debug);we(p)&&(this.config.debug=p),we(this.config.debug)&&(this.config.debug?(ve.DEBUG=!0,D.H()&&D.G("ph_debug","true"),b.info("set_config",{config:e,oldConfig:t,newConfig:w({},this.config)})):(ve.DEBUG=!1,D.H()&&D.V("ph_debug"))),(s=this.exceptionObserver)==null||s.onConfigChange(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),(a=this.autocapture)==null||a.startIfEnabled(),(o=this.heatmaps)==null||o.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),(u=this.externalIntegrations)==null||u.startIfEnabledOrStop()}}startSessionRecording(e){var t=e===!0,i={sampling:t||!(e==null||!e.sampling),linked_flag:t||!(e==null||!e.linked_flag),url_trigger:t||!(e==null||!e.url_trigger),event_trigger:t||!(e==null||!e.event_trigger)};if(Object.values(i).some(Boolean)){var s,n,a,o,l;(s=this.sessionManager)==null||s.checkAndGetSessionAndWindowId(),i.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),i.linked_flag&&((a=this.sessionRecording)==null||a.overrideLinkedFlag()),i.url_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("url")),i.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){var i=new Error("PostHog syntheticException"),s=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(w({},s,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:ze;return t!==ze&&(t=ze+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(_e))==="identified"||((t=this.sessionPersistence)==null?void 0:t.get_property(_e))==="identified"}fs(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Je(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[gt])&&((t=this.persistence)==null||(t=t.props)==null||!t[Gt]))}ds(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return this.config.person_profiles==="never"?(b.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(Gt,!0),!0)}Qr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!t}_s(){var e,t,i,s,n=this.Qr();return((e=this.persistence)==null?void 0:e.Pi)!==n&&((i=this.persistence)==null||i.set_disabled(n)),((t=this.sessionPersistence)==null?void 0:t.Pi)!==n&&((s=this.sessionPersistence)==null||s.set_disabled(n)),n}opt_in_capturing(e){var t;if(this.config.cookieless_mode!=="always"){var i,s,n;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(i=this.sessionManager)==null||i.destroy(),(s=this.pageViewManager)==null||s.destroy(),this.sessionManager=new ss(this),this.pageViewManager=new Br(this),this.persistence&&(this.sessionPropsManager=new rs(this,this.sessionManager,this.persistence)),this.sessionRecording=new as(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(_(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((n=e==null?void 0:e.captureEventName)!==null&&n!==void 0?n:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.hs()}else b.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:st,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(i=this.sessionRecording)==null||i.stopRecording(),this.sessionRecording=void 0,this.hs())):b.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===me.GRANTED?"granted":e===me.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._s()}_is_bot(){return te?mn(te,this.config.custom_blocked_useragents):void 0}hs(){y&&(y.visibilityState==="visible"?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:y.title},{send_instantly:!0}),this.Gr&&(y.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),j(y,"visibilitychange",this.Gr)))}debug(e){e===!1?(d==null||d.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(d==null||d.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}M(){var e,t,i,s,n,a,o,l=this.Yr||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(b.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):(i="advanced_disable_decide",s=!1,n=b,a=(t="advanced_disable_flags")in(e=l)&&!R(e[t]),o=i in e&&!R(e[i]),a?e[t]:o?(n&&n.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]):s)}cs(e){if(R(this.config.before_send))return e;var t=C(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),R(i)){var n="Event '"+e.event+"' was rejected in beforeSend function";return $n(e.event)?b.warn(n+". This can cause unexpected behavior."):b.info(n),null}i.properties&&!Je(i.properties)||b.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Kr(e){var t=we(e)&&!e,i=D.H()&&D.q("ph_debug")==="true";return!t&&(!!i||e)}}(function(r,e){for(var t=0;t<e.length;t++)r.prototype[e[t]]=ca(r.prototype[e[t]])})(ii,["identify"]);var us,el={backgroundColor:"#ffffff",textColor:"#1d1f27",buttonColor:"#1d1f27",borderRadius:8,buttonBorderRadius:6,borderColor:"#e5e7eb",fontFamily:"system-ui",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",showOverlay:!0,whiteLabel:!1,dismissOnClickOutside:!0,zIndex:2147483646},tl=(us=Et[ze]=new ii,(function(){function r(){r.done||(r.done=!0,yn=!1,M(Et,(function(e){e._dom_loaded()})))}y!=null&&y.addEventListener?y.readyState==="complete"?r():j(y,"DOMContentLoaded",r,{capture:!1}):d&&b.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),us);export{ye as Compression,el as DEFAULT_PRODUCT_TOUR_APPEARANCE,Vi as DisplaySurveyType,ii as PostHog,yt as SurveyEventName,wi as SurveyEventProperties,ht as SurveyEventType,Jo as SurveyPosition,Zo as SurveyQuestionBranchingType,Ko as SurveyQuestionType,Qo as SurveySchedule,Xo as SurveyTabPosition,bi as SurveyType,Yo as SurveyWidgetType,tl as default,tl as posthog,zo as severityLevels};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as s,j as t}from"./cNrhgGc1.js";import{r as ke}from"./D-bf6hEI.js";import"./C-KIc3Wc.js";import"./BJgZIVUQ.js";import"./CxQ08qFN.js";const I={PREVIEW:"orgx_orchestrator_preview",APPLY:"orgx_orchestrator_apply",STATUS:"orgx_orchestrator_status"};function l(p){if(typeof p!="string")return null;const n=p.trim();return n.length?n:null}function Ce(p){if(!p.trim())return{};const n=JSON.parse(p);return!n||typeof n!="object"||Array.isArray(n)?{}:n}function Q(p){const n=l(p.transcript)??l(p.text)??l(p.delta??null);if(n)return n;const h=p.item&&typeof p.item=="object"?p.item:null,v=Array.isArray(h==null?void 0:h.content)?h==null?void 0:h.content:[];for(const y of v){if(!y||typeof y!="object")continue;const f=l(y.transcript)??l(y.text);if(f)return f}return null}function Se(p){const n=p.response&&typeof p.response=="object"?p.response:null,h=Array.isArray(n==null?void 0:n.output)?n==null?void 0:n.output:[],v=[];for(const y of h){if(!y||typeof y!="object")continue;const f=y;if(f.type!=="function_call")continue;const C=l(f.name),S=l(f.call_id)??l(f.id),A=typeof f.arguments=="string"?f.arguments:"{}";!C||!S||v.push({callId:S,name:C,arguments:A})}return v}function Ae(p){const n=Number.isFinite(p)?p*100:0;return`${Math.max(0,Math.min(100,Math.round(n)))}%`}const fe=[{type:"function",name:I.PREVIEW,description:"Preview orchestrator actions from a natural language command. Use this before apply.",parameters:{type:"object",additionalProperties:!1,properties:{input:{type:"string",description:"Natural language command from the operator."},workspace_id:{type:"string",description:"Optional OrgX workspace/command_center id."}},required:["input"]}},{type:"function",name:I.APPLY,description:"Apply selected action ids from a previewed command after user confirmation.",parameters:{type:"object",additionalProperties:!1,properties:{command_id:{type:"string",description:"Command id from preview response."},confirmed_action_ids:{type:"array",items:{type:"string"},description:"Optional subset of action ids to apply. Omit to apply all."},workspace_id:{type:"string",description:"Optional OrgX workspace/command_center id."}},required:["command_id"]}},{type:"function",name:I.STATUS,description:"Get latest status for a previously created command.",parameters:{type:"object",additionalProperties:!1,properties:{command_id:{type:"string",description:"Command id from preview/apply response."}},required:["command_id"]}}];function Oe({open:p,selectedWorkspaceId:n,onClose:h}){var le,de,pe;const[v,y]=s.useState(!1),[f,C]=s.useState(!1),[S,A]=s.useState(!1),[xe,he]=s.useState("gpt-realtime-1.5"),[$,Z]=s.useState(""),[W,M]=s.useState(""),[o,P]=s.useState(null),[T,X]=s.useState([]),[ee,te]=s.useState(!1),[re,oe]=s.useState(!1),[se,b]=s.useState(null),[ne,z]=s.useState([]),G=s.useRef(null),D=s.useRef(null),O=s.useRef(null),H=s.useRef(null),E=s.useRef(""),J=s.useRef(new Set),R=s.useCallback(e=>{z(r=>[e,...r].slice(0,10))},[]),N=s.useCallback(()=>{A(!1),C(!1),J.current=new Set;const e=D.current;if(e)try{e.close()}catch{}D.current=null;const r=G.current;if(r)try{r.close()}catch{}G.current=null;const a=O.current;if(a)for(const m of a.getTracks())try{m.stop()}catch{}O.current=null;const d=H.current;if(d){try{const m=d.srcObject;m==null||m.getTracks().forEach(i=>i.stop())}catch{}try{d.pause()}catch{}d.srcObject=null}H.current=null},[]);s.useEffect(()=>{p||(N(),b(null),M(""),z([]),E.current="")},[N,p]),s.useEffect(()=>()=>N(),[N]);const g=s.useCallback(e=>{const r=D.current;!r||r.readyState!=="open"||r.send(JSON.stringify(e))},[]),ae=s.useCallback(async e=>{const r=await fetch(e),a=await r.json().catch(()=>({}));if(!r.ok)throw new Error(a&&typeof a=="object"&&"error"in a&&a.error||`Request failed: ${r.status}`);return a},[]),j=s.useCallback(async(e,r)=>{const a=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),d=await a.json().catch(()=>({}));if(!a.ok)throw new Error(d&&typeof d=="object"&&"error"in d&&d.error||`Request failed: ${a.status}`);return d},[]),L=s.useCallback(async e=>{if(!J.current.has(e.callId)){J.current.add(e.callId);try{const r=Ce(e.arguments);let a={ok:!1,error:"Unsupported tool call."};if(e.name===I.PREVIEW){const d=l(r.input);if(!d)throw new Error("Preview tool call requires input.");const m=await j("/orgx/api/orchestrator/commands/preview",{input:d,workspace_id:l(r.workspace_id)??n??void 0});if(!m.command)throw new Error(m.error??"Preview command failed.");P(m.command),X(m.command.proposedActions.map(i=>i.actionId)),a={ok:!0,command:m.command}}else if(e.name===I.APPLY){const d=l(r.command_id);if(!d)throw new Error("Apply tool call requires command_id.");const m=Array.isArray(r.confirmed_action_ids)?r.confirmed_action_ids.filter(F=>typeof F=="string"):void 0,i=await j("/orgx/api/orchestrator/commands/apply",{command_id:d,confirmed_action_ids:m,workspace_id:l(r.workspace_id)??n??void 0});if(!i.command)throw new Error(i.error??"Apply command failed.");P(i.command),a={ok:!0,command:i.command}}else if(e.name===I.STATUS){const d=l(r.command_id);if(!d)throw new Error("Status tool call requires command_id.");const m=await ae(`/orgx/api/orchestrator/commands/${encodeURIComponent(d)}`);if(!m.command)throw new Error(m.error??"Command status unavailable.");P(m.command),a={ok:!0,command:m.command}}g({type:"conversation.item.create",item:{type:"function_call_output",call_id:e.callId,output:JSON.stringify(a)}}),g({type:"response.create"}),R(`Tool executed: ${e.name}`)}catch(r){const a=r instanceof Error?r.message:"Tool execution failed.";b(a),g({type:"conversation.item.create",item:{type:"function_call_output",call_id:e.callId,output:JSON.stringify({ok:!1,error:a})}}),g({type:"response.create"}),R(`Tool failed: ${e.name}`)}}},[ae,R,j,n,g]),ye=s.useCallback(async()=>{var e,r,a,d,m;if(!((e=navigator.mediaDevices)!=null&&e.getUserMedia)){b("Microphone capture is unavailable in this browser/runtime.");return}b(null),y(!0),z([]);try{const i=await j("/orgx/api/realtime/session",{workspace_id:n??void 0,model:"gpt-realtime-1.5",voice:"alloy",tool_choice:"auto",tools:fe,instructions:"You are the OrgX realtime orchestrator copilot. Use tools for state-changing operations. Before applying actions, state the plan concisely."});if(!(i!=null&&i.session))throw new Error((i==null?void 0:i.error)??"Failed to create realtime session.");const F=l((r=i==null?void 0:i.session)==null?void 0:r.model)??l((a=i==null?void 0:i.defaults)==null?void 0:a.model)??"gpt-realtime-1.5";he(F);const me=l((m=(d=i==null?void 0:i.session)==null?void 0:d.client_secret)==null?void 0:m.value);if(!me)throw new Error("Realtime session is missing client_secret.");const U=await navigator.mediaDevices.getUserMedia({audio:!0});O.current=U;for(const _ of U.getAudioTracks())_.enabled=!1;const k=new RTCPeerConnection;G.current=k,U.getTracks().forEach(_=>k.addTrack(_,U));const q=document.createElement("audio");q.autoplay=!0,H.current=q,k.ontrack=_=>{const[u]=_.streams;u&&(q.srcObject=u,q.play().catch(()=>{}))};const V=k.createDataChannel("oai-events");D.current=V,V.onmessage=_=>{try{const u=JSON.parse(String(_.data)),x=l(u.type)??"";if(x==="error"){const c=u.error&&typeof u.error=="object"?u.error:null,w=l(c==null?void 0:c.message)??l(u.message)??"Realtime session error.";b(w),R(`Error: ${w}`);return}if(x==="conversation.item.input_audio_transcription.completed"){const c=Q(u);c&&Z(c)}if(x==="response.output_text.delta"||x==="response.text.delta"||x==="response.output_audio_transcript.delta"||x==="response.audio_transcript.delta"){const c=l(u.delta)??Q(u);c&&(E.current=`${E.current}${c}`,M(E.current))}if(x==="response.output_text.done"||x==="response.text.done"||x==="response.output_audio_transcript.done"||x==="response.audio_transcript.done"){const c=Q(u);c&&(E.current=c,M(c))}if(x==="response.function_call_arguments.done"){const c=l(u.call_id),w=l(u.name);if(c&&w){const B=typeof u.arguments=="string"?u.arguments:"{}";L({callId:c,name:w,arguments:B})}}if(x==="response.output_item.done"){const c=u.item&&typeof u.item=="object"?u.item:null;if((c==null?void 0:c.type)==="function_call"){const w=l(c.call_id)??l(c.id),B=l(c.name);if(w&&B){const Ne=typeof c.arguments=="string"?c.arguments:"{}";L({callId:w,name:B,arguments:Ne})}}}if(x==="response.done"){const c=Se(u);for(const w of c)L(w)}}catch{}},V.onopen=()=>{C(!0),g({type:"session.update",session:{tools:fe,tool_choice:"auto"}}),R("Realtime connected")},V.onclose=()=>{C(!1),A(!1)};const ue=await k.createOffer();await k.setLocalDescription(ue);const Y=await fetch(`https://api.openai.com/v1/realtime?model=${encodeURIComponent(F)}`,{method:"POST",headers:{Authorization:`Bearer ${me}`,"Content-Type":"application/sdp"},body:ue.sdp??""});if(!Y.ok){const _=await Y.text().catch(()=>Y.statusText);throw new Error(`Realtime SDP negotiation failed: ${_}`)}const ve=await Y.text();await k.setRemoteDescription({type:"answer",sdp:ve})}catch(i){N(),b(i instanceof Error?i.message:"Failed to connect realtime session.")}finally{y(!1)}},[N,L,R,j,n]),ie=s.useCallback(()=>{if(!f)return;const e=O.current;if(e){for(const r of e.getAudioTracks())r.enabled=!0;E.current="",M(""),A(!0),g({type:"input_audio_buffer.clear"})}},[f,g]),K=s.useCallback(()=>{const e=O.current;if(e)for(const r of e.getAudioTracks())r.enabled=!1;A(!1),g({type:"input_audio_buffer.commit"}),g({type:"response.create"})},[g]),ge=s.useCallback(async()=>{const e=$.trim();if(e){te(!0),b(null);try{const r=await j("/orgx/api/orchestrator/commands/preview",{input:e,workspace_id:n??void 0});if(!r.command)throw new Error(r.error??"Failed to preview command.");P(r.command),X(r.command.proposedActions.map(a=>a.actionId))}catch(r){b(r instanceof Error?r.message:"Failed to preview command.")}finally{te(!1)}}},[$,j,n]),be=s.useCallback(async()=>{if(o!=null&&o.id){oe(!0),b(null);try{const e=await j("/orgx/api/orchestrator/commands/apply",{command_id:o.id,confirmed_action_ids:T,workspace_id:n??void 0});if(!e.command)throw new Error(e.error??"Failed to apply command.");P(e.command)}catch(e){b(e instanceof Error?e.message:"Failed to apply command.")}finally{oe(!1)}}},[o==null?void 0:o.id,j,T,n]),ce=T.length,we=(((le=o==null?void 0:o.proposedActions)==null?void 0:le.length)??0)>0,je=!!(o!=null&&o.id)&&ce>0&&!re,_e=s.useMemo(()=>{const e=(o==null?void 0:o.status)??"draft";return e==="completed"?"text-lime":e==="completed_with_errors"||e==="failed"?"text-amber-300":e==="applying"?"text-teal":"text-secondary"},[o==null?void 0:o.status]);return t.jsxs(ke,{open:p,onClose:h,maxWidth:"max-w-5xl",fitContent:!0,closeOnEscapeWhenTyping:!1,children:[t.jsx("div",{className:"border-b border-strong px-4 py-3",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-caption uppercase tracking-[0.14em] text-secondary",children:"Realtime Orchestrator"}),t.jsx("h2",{className:"text-heading font-semibold text-white",children:"GPT Realtime 1.5"}),t.jsx("p",{className:"text-micro text-secondary",children:"Voice + tool-calls for initiative launch, decision resolution, and Next Up control."})]}),t.jsx("button",{type:"button",onClick:h,className:"rounded-full border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-secondary transition-colors hover:bg-white/[0.08] hover:text-white",children:"Close"})]})}),t.jsxs("div",{className:"grid gap-4 px-4 pb-4 pt-3 lg:grid-cols-[1.12fr_1fr]",children:[t.jsxs("section",{className:"space-y-3",children:[t.jsxs("div",{className:"rounded-xl border border-strong bg-white/[0.02] p-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[t.jsx("span",{className:"text-caption uppercase tracking-[0.12em] text-secondary",children:"Session"}),t.jsx("span",{className:"text-micro text-secondary",children:xe})]}),t.jsx("div",{className:"flex flex-wrap items-center gap-2",children:f?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onMouseDown:ie,onMouseUp:K,onMouseLeave:()=>{S&&K()},onTouchStart:e=>{e.preventDefault(),ie()},onTouchEnd:e=>{e.preventDefault(),K()},className:`rounded-full border px-3 py-1.5 text-caption font-semibold transition-colors ${S?"border-teal/45 bg-teal/[0.16] text-teal":"border-white/[0.2] bg-white/[0.04] text-primary hover:bg-white/[0.1]"}`,children:S?"Listening… release to send":"Hold to talk"}),t.jsx("button",{type:"button",onClick:N,className:"rounded-full border border-strong bg-white/[0.03] px-3 py-1.5 text-caption text-secondary transition-colors hover:bg-white/[0.08] hover:text-primary",children:"Disconnect"})]}):t.jsx("button",{type:"button",disabled:v,onClick:()=>void ye(),className:"rounded-full border border-lime/35 bg-lime/[0.12] px-3 py-1.5 text-caption font-semibold text-lime transition-colors hover:bg-lime/[0.2] disabled:cursor-not-allowed disabled:opacity-60",children:v?"Connecting…":"Connect Realtime"})}),ne.length>0?t.jsx("div",{className:"mt-3 rounded-lg border border-strong bg-black/20 p-2",children:ne.map((e,r)=>t.jsx("p",{className:"text-micro text-secondary",children:e},`${e}-${r}`))}):null]}),t.jsxs("div",{className:"rounded-xl border border-strong bg-white/[0.02] p-3",children:[t.jsx("label",{className:"mb-2 block text-caption uppercase tracking-[0.12em] text-secondary",children:"Command Input"}),t.jsx("textarea",{value:$,onChange:e=>Z(e.target.value),rows:4,"data-modal-autofocus":"true",placeholder:"Example: create initiative called AI Readiness Audit for this workspace",className:"w-full rounded-lg border border-strong bg-[#040912] px-3 py-2 text-body text-primary placeholder:text-secondary focus:border-lime/35 focus:outline-none"}),W?t.jsxs("p",{className:"mt-2 text-caption text-secondary",children:["Assistant: ",t.jsx("span",{className:"text-primary",children:W})]}):null,t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsx("button",{type:"button",disabled:ee||$.trim().length===0,onClick:()=>void ge(),className:"rounded-full border border-teal/35 bg-teal/[0.12] px-3 py-1.5 text-caption font-semibold text-teal transition-colors hover:bg-teal/[0.2] disabled:cursor-not-allowed disabled:opacity-60",children:ee?"Previewing…":"Preview Actions"}),t.jsx("button",{type:"button",disabled:!je,onClick:()=>void be(),className:"rounded-full border border-lime/35 bg-lime/[0.12] px-3 py-1.5 text-caption font-semibold text-lime transition-colors hover:bg-lime/[0.2] disabled:cursor-not-allowed disabled:opacity-60",children:re?"Applying…":`Apply (${ce})`})]})]})]}),t.jsxs("section",{className:"space-y-3",children:[t.jsxs("div",{className:"rounded-xl border border-strong bg-white/[0.02] p-3",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[t.jsx("span",{className:"text-caption uppercase tracking-[0.12em] text-secondary",children:"Command Status"}),t.jsx("span",{className:`text-caption font-semibold ${_e}`,children:(o==null?void 0:o.status)??"idle"})]}),t.jsx("p",{className:"text-body text-primary",children:(o==null?void 0:o.humanSummary)??"Preview a command or use voice to trigger tool calls."}),(de=o==null?void 0:o.riskFlags)!=null&&de.length?t.jsxs("p",{className:"mt-2 text-caption text-amber-200",children:["Risk flags: ",o.riskFlags.join(", ")]}):null]}),t.jsxs("div",{className:"max-h-[360px] space-y-2 overflow-y-auto rounded-xl border border-strong bg-white/[0.02] p-3",children:[t.jsx("p",{className:"text-caption uppercase tracking-[0.12em] text-secondary",children:"Proposed Actions"}),we?o.proposedActions.map(e=>{const r=T.includes(e.actionId);return t.jsx("label",{className:"block rounded-lg border border-strong bg-[#040912] p-2 text-body",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("input",{type:"checkbox",checked:r,onChange:a=>{const d=a.target.checked?[...T,e.actionId]:T.filter(m=>m!==e.actionId);X(d)},className:"mt-1"}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-semibold text-primary",children:e.type}),t.jsx("p",{className:"text-caption text-secondary",children:e.reason}),t.jsxs("p",{className:"text-micro text-secondary",children:["confidence ",Ae(e.confidence)," • impact ",e.blockingImpact]})]})]})},e.actionId)}):t.jsx("p",{className:"text-body text-secondary",children:"No actions inferred yet."})]}),(((pe=o==null?void 0:o.results)==null?void 0:pe.length)??0)>0?t.jsxs("div",{className:"max-h-[220px] space-y-2 overflow-y-auto rounded-xl border border-strong bg-white/[0.02] p-3",children:[t.jsx("p",{className:"text-caption uppercase tracking-[0.12em] text-secondary",children:"Apply Results"}),o.results.map(e=>t.jsxs("div",{className:`rounded-lg border p-2 text-body ${e.ok?"border-lime/30 bg-lime/[0.08] text-lime":"border-amber-400/35 bg-amber-500/[0.12] text-amber-100"}`,children:[t.jsx("p",{className:"font-semibold",children:e.type}),t.jsx("p",{className:"text-caption",children:e.message}),e.error?t.jsxs("p",{className:"text-micro text-amber-200",children:["error: ",e.error]}):null]},`${e.actionId}-${e.type}`))]}):null]})]}),se?t.jsx("div",{className:"border-t border-amber-500/30 bg-amber-500/[0.12] px-4 py-2 text-caption text-amber-100",children:se}):null]})}export{Oe as RealtimeOrchestratorModal};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as a,j as e}from"./cNrhgGc1.js";import{d as i}from"./D-bf6hEI.js";import{A as m,m as x}from"./CxQ08qFN.js";function f({message:l,durationMs:s=5e3,onUndo:d,onExpire:r}){const[t,c]=a.useState(!0),o=a.useRef();a.useEffect(()=>(o.current=setTimeout(()=>{c(!1),r()},s),()=>clearTimeout(o.current)),[s,r]);const n=()=>{clearTimeout(o.current),c(!1),d()};return e.jsx(m,{children:t&&e.jsx(x.div,{initial:{opacity:0,y:20,scale:.95},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:10,scale:.95},transition:{duration:.22,ease:[.22,1,.36,1]},className:"fixed bottom-6 left-1/2 z-50 -translate-x-1/2",children:e.jsxs("div",{className:"flex items-center gap-3 rounded-xl px-4 py-2.5 shadow-lg",style:{backgroundColor:i.cardBgElevated,border:`1px solid ${i.cardBorderStrong}`},children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:i.lime,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M20 6 9 17l-5-5"})}),e.jsx("span",{className:"text-body text-primary",children:l}),e.jsx("button",{onClick:n,className:"ml-1 rounded-md px-2.5 py-1 text-caption font-semibold transition-colors hover:bg-white/[0.08]",style:{color:i.lime},children:"Undo"}),e.jsx("div",{className:"absolute bottom-0 left-3 right-3 h-0.5 overflow-hidden rounded-full",children:e.jsx("div",{className:"h-full origin-left rounded-full",style:{backgroundColor:i.lime,opacity:.4,animation:`undoCountdown ${s}ms linear forwards`}})})]})})})}function y(){const[l,s]=a.useState([]),d=o=>{const n=`undo-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;return s(u=>[...u,{...o,id:n}]),n},r=o=>{s(n=>n.filter(u=>u.id!==o))},t=l[0]??null;return{enqueue:d,ToastRenderer:()=>t?e.jsx(f,{message:t.message,onUndo:()=>{t.onUndo(),r(t.id)},onExpire:()=>{t.onCommit(),r(t.id)}},t.id):null}}export{y as u};
|
|
Binary file
|
|
Binary file
|