@dori-ai/dori-side-widget 1.13.152-dev.20261024141050 → 1.13.153
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{apply-C1aK27go.js → apply-BQSXIcbI.js} +1 -1
- package/dist/assets/apply-BQSXIcbI.js.br +0 -0
- package/dist/assets/apply-BQSXIcbI.js.gz +0 -0
- package/dist/widget.js +2 -2
- package/dist/widget.js.br +0 -0
- package/dist/widget.js.gz +0 -0
- package/package.json +1 -1
- package/dist/assets/apply-C1aK27go.js.br +0 -0
- package/dist/assets/apply-C1aK27go.js.gz +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as e}from"./report-BHr6U1PB.js";const t="dori-ask-button";function n(e,n){const o=Boolean(e.label),r=o?Math.max(32,Math.min(38,e.boxHeight)):Math.max(32,Math.min(44,e.boxHeight));"undefined"==typeof customElements||customElements.get(t)||customElements.define(t,class extends HTMLElement{});const a=document.createElement(t);a.style.cssText=`display:inline-flex;align-items:center;flex:0 0 auto;height:${Math.max(r,e.boxHeight)}px;margin:0;padding:0;border:0;background:none;box-shadow:none;float:none;min-width:0;max-width:none;width:auto;vertical-align:middle;position:relative;z-index:1;color:${e.color};`;const i=a.attachShadow({mode:"open",delegatesFocus:!0}),s=Math.max(12,Math.min(15,e.fontSize||14));i.innerHTML=`<style>button{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:7px;height:${r}px;width:${o?"auto":`${r}px`};padding:${o?"0 14px 0 12px":"0"};border-radius:999px;cursor:pointer;color:inherit;font:inherit;font-size:${s}px;font-weight:600;line-height:1.2;white-space:nowrap;border:1.5px solid ${o?"currentColor":"transparent"}}button:hover{background:rgba(127,127,127,.12)}button:focus-visible{outline:2px solid currentColor;outline-offset:2px}svg{width:${e.iconSize}px;height:${e.iconSize}px;flex:0 0 auto}</style><button type="button"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M12 3.5l1.9 5.1 5.1 1.9-5.1 1.9L12 17.5l-1.9-5.1L5 10.5l5.1-1.9z"/><path d="M18.5 15.5l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8z"/></svg></button>`;const l=i.querySelector("button");if(l.setAttribute("aria-label",e.aria),e.label){const t=document.createElement("span");t.textContent=e.label,l.appendChild(t)}return l.addEventListener("click",n),a}const o=()=>({w:window.innerWidth,h:window.innerHeight}),r=e=>e.getBoundingClientRect();function a(e,t=o()){if(!e)return!1;const n=r(e);if(n.width<6||n.height<6||n.right<=0||n.left>=t.w||n.bottom<=0)return!1;const a=e;if(a.checkVisibility&&!a.checkVisibility({contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0}))return!1;const i=getComputedStyle(e);return"hidden"!==i.visibility&&"none"!==i.display&&parseFloat(i.opacity)>=.05}function i(e){const t=r(e);if(t.width<2||t.height<2)return!1;const n=e;return!n.checkVisibility||n.checkVisibility({visibilityProperty:!0})}const s=['input[type="search"]','input[name="q"]','a[href$="/search"]','a[href*="/search?"]','button[aria-label*="search" i]','a[aria-label*="search" i]','summary[aria-label*="search" i]','[aria-controls*="search" i]',"details-modal.header__search summary","predictive-search","search-button",'[class*="search-toggle" i]','[class*="search-icon" i]','[class*="header__search" i]','[data-action*="search" i]'].join(","),l=['a[href$="/cart"]','a[href*="/cart?"]',"#cart-icon-bubble","[data-cart-toggle]","[data-cart-trigger]","[data-open-cart]",'[data-drawer-toggle*="cart" i]','[aria-controls*="cart" i]','button[aria-label*="cart" i]','a[aria-label*="cart" i]','button[aria-label*="bag" i]','a[aria-label*="bag" i]','[class*="cart-icon" i]','[class*="header__cart" i]',"cart-icon","cart-drawer-component button"].join(","),c=['[aria-label*="menu" i]','summary[aria-controls*="menu" i]','[class*="menu-drawer" i] summary','[class*="hamburger" i]','[class*="burger" i]','[data-drawer-toggle*="menu" i]','button[aria-controls*="menu" i]','[class*="menu-toggle" i]','[class*="nav-toggle" i]',"header-drawer summary"].join(","),h=e=>Math.min(300,.4*e.h),d=(e,t)=>a(e,t)&&r(e).top<h(t)&&!e.closest('[role="dialog"], [aria-modal="true"]'),u=(e,t)=>{const n=e.closest("a, button, summary");return n&&a(n,t)&&r(n).width<220?n:e};function f(e=o()){const t=[...document.querySelectorAll(s)].filter(t=>d(t,e)),n=[...document.querySelectorAll(l)].filter(t=>d(t,e));if(!t.length&&!n.length)return null;let i=null,f=!1;const p=t.find(e=>"INPUT"===e.tagName&&r(e).width>120);if(p){f=!0;let e=p.closest("form")||p.parentElement||p;for(let t=0;t<3&&e.parentElement&&r(e.parentElement).width<r(p).width+140;t++)e=e.parentElement;i=e}else if(t.length){const n=t.map(t=>u(t,e)).filter(t=>a(t,e)&&r(t).width<200&&r(t).height<90);n.sort((e,t)=>r(t).right-r(e).right),i=n[0]||null}let m=null;if(n.length){const t=n.map(t=>u(t,e)).filter(e=>r(e).width<260&&r(e).height<130);t.sort((e,t)=>r(t).right-r(e).right),m=t[0]||null}const g=[...document.querySelectorAll(c)].filter(t=>d(t,e)&&r(t).width<120).map(t=>u(t,e)),w="rtl"===getComputedStyle(document.documentElement).direction;g.sort((e,t)=>w?r(t).right-r(e).right:r(e).left-r(t).left);const b=g.find(t=>w?r(t).right>.65*e.w:r(t).left<.35*e.w)||null,y=i||m;let _=y.parentElement||y;for(let o=y.parentElement;o&&o!==document.body;o=o.parentElement){const t=r(o);if(t.top>h(e)||t.height>360)break;t.width>=.6*e.w&&(_=o)}return{search:i,isBar:f,cart:m,menu:b,header:_,rtl:w||"rtl"===getComputedStyle(_).direction}}function p(e){let t=e;for(let n=0;n<6;n++){const e=t.parentElement;if(!e||e===document.body||"HEADER"===e.tagName)break;if([...e.children].some(e=>e!==t&&a(e)))break;t=e}return t}function m(e){return[...e.querySelectorAll("svg, img")].find(e=>a(e))||e}function g(e){const t=getComputedStyle(e);return!(/grid/.test(t.display)||/flex/.test(t.display)&&/space-(between|around|evenly)/.test(t.justifyContent))}const w=(e,t)=>Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top)),b=e=>/^(A|BUTTON|IMG|SVG|INPUT|SELECT|TEXTAREA|LABEL|SUMMARY|VIDEO|CANVAS)$/i.test(e.tagName)||e.hasAttribute("role")||(e=>[...e.childNodes].some(e=>e.nodeType===Node.TEXT_NODE&&""!==(e.textContent||"").trim()))(e),y=e=>e.top+e.height/2,_=e=>e.shadowRoot?.querySelector("button")??null;function v(e,t,{sideways:n=!0}={}){const o=(e,t)=>Math.abs(e-t)<=1,r=(e,t)=>e.length===t.length&&e.every((e,n)=>o(e,t[n]));return o(e.x,t.x)&&o(e.y,t.y)&&e.w===t.w&&e.h===t.h&&o(e.header,t.header)&&r(e.tops,t.tops)&&(!n||r(e.lefts,t.lefts))}function k(e,t){const n=t.map(r);return{x:window.scrollX,y:window.scrollY,w:window.innerWidth,h:window.innerHeight,header:r(e).height,tops:n.map(e=>e.top),lefts:n.map(e=>e.left)}}const x=e=>new Promise(t=>setTimeout(t,e));async function M(e,t,n){const o=performance.now();await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),document.fonts&&await document.fonts.ready;const r=t-(performance.now()-o);r>0&&await x(r);let a=e();for(;performance.now()-o<n;){await x(80);const t=e();if(v(a,t))return!0;a=t}return!1}function S(e,t){return[...e.querySelectorAll("*")].filter(e=>!(e.closest("svg")&&"svg"!==e.tagName.toLowerCase())&&b(e)&&a(e,t)&&r(e).top<Math.min(300,.4*t.h)+60).slice(0,260)}function E(e,t,n){const o=e.closest("dialog[open]");if(o&&!o.contains(t))return!0;for(let a=e;a&&a!==document.body;a=a.parentElement){const e=getComputedStyle(a);if(!("fixed"!==e.position&&"sticky"!==e.position||a.contains(t)||t.contains(a))){const e=r(a);if(e.width*e.height>n.w*n.h*.4)return!0}}return!1}function $(e,t,n){for(const o of n)if(!e.contains(o)&&!o.contains(e)&&w(t,r(o))>16)return`overlaps_${o.tagName.toLowerCase()}`;return null}function C(e,t,n,o){for(let a=1;a<=5;a++)for(let i=1;i<=3;i++){const s=t.left+t.width*a/6,l=t.top+t.height*i/4,c=document.elementFromPoint(s,l);if(!(c===e||e.contains(c)||c&&E(c,n,o)))return`covered_by_${c?c.tagName.toLowerCase():"nothing"}`;const h=document.elementsFromPoint(s,l),d=h.indexOf(e);for(const t of h.slice(d+1))if(!t.contains(e)&&t!==document.body&&t!==document.documentElement&&b(t)&&r(t).width<.6*o.w)return`sits_on_${t.tagName.toLowerCase()}`}return null}function z(e,t=o()){const n=S(e,t),a=n.map(e=>r(e).top),i=n.map(e=>{const n=r(e);return n.left>=-1&&n.right<=t.w+1}),s=()=>{const e=n.map(r),t=new Set;for(let o=0;o<n.length;o++)for(let r=o+1;r<n.length;r++)n[o].contains(n[r])||n[r].contains(n[o])||w(e[o],e[r])>16&&t.add(`${o}:${r}`);return t},l=s(),c=r(e).height,h=t=>{const o=t&&_(t);return k(e,o?[...n,o]:n)},d=h();return{look:h,before:d,check(o,h){const d=_(o);if(!d)return["no_button"];const u=r(d),f=[],p=Math.round(r(e).height-c);Math.abs(p)>2&&f.push(`header_height_${p}`);const m=Math.max(0,...n.map((e,t)=>Math.abs(r(e).top-a[t])));m>3&&f.push(`item_moved_${Math.round(m)}`);const g=n.filter((e,n)=>{if(!i[n]||o.contains(e))return!1;const a=r(e);return a.left<-1||a.right>t.w+1});g.length&&f.push(`pushed_offscreen_${g.length}`),(u.left<0||u.right>t.w+1||u.top<0)&&f.push("offscreen"),(u.width<24||u.height<24)&&f.push("too_small");const w=Math.round(y(u)-y(r(h)));Math.abs(w)>4&&f.push(`not_centred_${w}`);const b=$(o,u,n);b&&f.push(b);const v=C(o,u,e,t);v&&f.push(v);const k=[...s()].filter(e=>!l.has(e));return k.length&&f.push(`theme_overlap_${k.length}`),f}}}function A(e,t){const n=r(t.header);return[_(e)??e,t.anchor,...t.controls].flatMap(e=>{if(!e.isConnected||!i(e))return[NaN,NaN,NaN,NaN];const t=r(e);return[t.left-n.left,t.top-n.top,t.width,t.height]})}function N(e,t,n,o){const a=_(e);if(!a)return null;const i=y(r(a)),s=r(n);return{header:n,size:{w:s.width,h:s.height},anchor:t,controls:o,offsets:o.map(e=>y(r(e))-i),layout:A(e,{header:n,anchor:t,controls:o})}}function L(e,t){if(!t.header.isConnected)return!0;const n=r(t.header);if(Math.abs(n.width-t.size.w)>1||Math.abs(n.height-t.size.h)>2)return!0;const o=A(e,t);return o.length!==t.layout.length||o.some((e,n)=>{const o=t.layout[n];return Number.isNaN(e)!==Number.isNaN(o)||Math.abs(e-o)>2})}function T(e){for(const t of e){const e=t.getAttribute("onclick");if(e&&/doriWidget/.test(e))return!0;const n=t.getAttribute("href");if(n&&/(#dori-chat\b|[?&]dori-chat=)/i.test(n))return!0}return!1}const B=e=>e?`${e.tagName.toLowerCase()}${e.classList[0]?`.${e.classList[0]}`:""}`:"-",P=e=>new Promise(t=>setTimeout(t,e)),q=e=>`dori_ask_spot_${e}`,W=e=>`${e.spot}:${e.label?"text":"icon"}`,I=new Set;function H(e,t){if(!I.has(e)){I.add(e);try{t?window.localStorage.setItem(q(e),W(t)):window.localStorage.removeItem(q(e))}catch{}}}const F=e=>{const t=r(e);return t.top>=0&&t.bottom<=window.innerHeight};function R(e){return F(e)?Promise.resolve():new Promise(t=>{const n=()=>{F(e)&&(clearInterval(o),window.removeEventListener("scroll",n),window.removeEventListener("resize",n),t())},o=setInterval(n,250);window.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",n,{passive:!0})})}async function j(){const e=await async function(){for(let e=0;e<32;e++){const e=f();if(e)return e;await P(250)}return null}();if(!e)return null;let t=e;for(;;){await R(t.search||t.cart||t.header);const e=z(t.header,o());if(await M(()=>e.look(),150,1500),t=f()||t,F(t.search||t.cart||t.header))return t}}function O(){window.doriWidget?.open?.({source:"header_button"})}function V(e,t,n){const o=function(e,t){for(let n=t?e.nextElementSibling:e.previousElementSibling;n;n=t?n.nextElementSibling:n.previousElementSibling)if(a(n))return n;return null}(e,"end"===t);if(!o)return;const i=r(e),s=r(o);(("end"===t?!n:n)?s.left-i.right:i.left-s.right)<6&&(e.style["end"===t?"marginInlineEnd":"marginInlineStart"]="8px")}const D=e=>[e.search,e.cart,e.menu].filter(e=>Boolean(e));function U(e,t,n){const o=t.spot.endsWith("_search")?n.search:t.spot.endsWith("_cart")?n.cart:n.menu;if(!o)return!1;const a=p(o),i=a.parentElement;if(!i)return!1;const s=parseFloat(getComputedStyle(i).columnGap)||0;if("after_search"===t.spot)return i.insertBefore(e,a.nextSibling),s||(e.style.marginInlineStart="10px",V(e,"end",n.rtl)),!0;if("before_cart"===t.spot)return i.insertBefore(e,a),s||(e.style.marginInlineEnd="10px",V(e,"start",n.rtl)),!0;const l=o.offsetParent;if(!l||l===document.body||l===document.documentElement)return!1;l.appendChild(e),e.style.position="absolute";const c=r(l),h=r(e),d=r("beside_menu"===t.spot?o:a),u="beside_search"===t.spot||"beside_menu"===t.spot,f=n.rtl?!u:u,m="beside_menu"===t.spot?4:10,g=f?d.right-c.left+m:d.left-c.left-h.width-m;return e.style.left=`${Math.round(g+l.scrollLeft)}px`,e.style.top=`${Math.round(d.top+d.height/2-c.top-h.height/2)}px`,!0}async function G(e,t,i,s){const l=o(),c=e.cart||e.search||e.menu,h=[...e.header.querySelectorAll("nav a, [class*='menu' i] a")].find(e=>a(e,l)),d=getComputedStyle(h||c),u=e.cart?m(e.cart):e.search?m(e.search):null,f=u&&/^(svg|img)$/i.test(u.tagName)?Math.max(16,Math.min(26,Math.round(r(u).height))):20,w=function(e){const t=e.desktop&&e.hasLabel?[!0,!1]:[!1],n=[];if(e.hasSearch)for(const o of t)e.searchPacked&&n.push({zone:"near_search",spot:"after_search",label:o}),n.push({zone:"near_search",spot:"beside_search",label:o}),n.push({zone:"near_search",spot:"before_search",label:o});if(e.hasCart)for(const o of t)e.cartPacked&&n.push({zone:"other_header",spot:"before_cart",label:o}),n.push({zone:"other_header",spot:"beside_cart",label:o});return e.hasMenu&&!e.desktop&&n.push({zone:"other_header",spot:"beside_menu",label:!1}),n}({desktop:"computer"===i,hasLabel:Boolean(t.label),hasSearch:Boolean(e.search),searchPacked:Boolean(e.search?.parentElement&&g(p(e.search).parentElement)),hasCart:Boolean(e.cart),cartPacked:Boolean(e.cart?.parentElement&&g(p(e.cart).parentElement)),hasMenu:Boolean(e.menu)}),b=z(e.header,l);for(const o of function(e,t){let n=null;try{n=window.localStorage.getItem(q(t))}catch{}const o=e.find(e=>W(e)===n);return o?[o,...e.filter(e=>e!==o)]:e}(w,i)){const a=o.spot.endsWith("_search")?e.search:o.spot.endsWith("_cart")?e.cart:e.menu,l=e.isBar&&o.spot.endsWith("_search")?a:m(a),h=Math.max(28,Math.min(44,Math.round(r(l).height+16))),u=n({label:o.label?t.label:null,aria:t.aria,boxHeight:h,color:getComputedStyle(c).color,fontSize:parseFloat(d.fontSize),iconSize:f},O);if(u.style.opacity="0",!U(u,o,e)){s?.push(`${W(o)} cant_apply`);continue}u.parentElement&&getComputedStyle(u.parentElement).color===getComputedStyle(c).color&&u.style.removeProperty("color");const p=u.shadowRoot.querySelector("button"),g=Math.round(r(l).top+r(l).height/2-(r(p).top+r(p).height/2));Math.abs(g)>1&&Math.abs(g)<24&&(u.style.top=`${(parseFloat(u.style.top)||0)+g}px`),await M(()=>b.look(u),120,700);let w=b.check(u,l);if(!w.length){if(await M(()=>b.look(u),450,1200),w=b.check(u,l),!w.length)return H(i,o),ae=N(u,l,e.header,D(e)),s?.push(`${W(o)} ok`),{placed:!0,zone:o.zone,spot:o.spot,label:o.label,device:i};w=w.map(e=>`${e}(confirm)`)}if(u.remove(),!v(b.before,b.look(),{sideways:!1}))return s?.push(`${W(o)} ${w.join(",")} page_moved`),"page_moved";s?.push(`${W(o)} ${w.join(",")}`)}return null}function X(){return[...document.querySelectorAll("[data-dori-ask-block]")].some(e=>{if(!i(e))return!1;const t=r(e);return t.right>0&&t.left<window.innerWidth})}async function Y(t){ae=null;const n=e(),o={placed:!1,zone:"none",device:n},r=window.__doriAskTrace;if(X())return{placed:!0,zone:"block",device:n};for(let e=0;e<=3;e++){const e=await j();if(!e)return r?.push(`${n} no_anchors`),o;if(r?.push(`${n} search=${B(e.search)}${e.isBar?"(bar)":""} cart=${B(e.cart)} menu=${B(e.menu)} header=${B(e.header)}`),T(e.header.querySelectorAll("[onclick], a[href]")))return r?.push("own_entry"),o;const a=await G(e,t,n,r);if("page_moved"!==a){if(a)return a;break}}return H(n,null),o}function J(e){window.__doriAskResult=e,window.dispatchEvent(new CustomEvent("dori:ask-button",{detail:e}))}let K=null,Q=!0,Z=null,ee=null,te=!1,ne=0,oe=0,re=0,ae=null,ie=!1,se=!1,le=0,ce=!1;const he=()=>document.querySelector(t),de=()=>window.__doriAskResult;function ue(e){return!!e&&!i(e.shadowRoot?.querySelector("button")??e)}function fe(){he()?.remove(),ae=null,de()?.placed&&J({placed:!1,zone:"none",device:e(),pending:!0})}async function pe(){if(Z&&!Q)return K||(K=(async()=>{for(;;){const t=Z,n=window.innerWidth;let o;oe++,fe();try{o=await Y(t)}catch{he()?.remove(),o={placed:!1,zone:"none",device:e()}}if(Q)return void he()?.remove();if(t!==Z||window.innerWidth!==n)continue;const r=he();return r&&(r.style.transition="opacity .2s ease",r.style.opacity="1"),re=n,void J(o)}})().finally(()=>{K=null,ge()}),K)}function me(){if(ne>=10){he()?.remove(),ae=null,re=window.innerWidth;const t=de();return void((t?.placed||t?.pending)&&J({placed:!1,zone:"none",device:e()}))}ne++,pe()}let ge=()=>{};function we(e){const t=!Z||Z.label!==e.label||Z.aria!==e.aria;t&&(Z=e);const n=Q;if(Q=!1,!n)return void(t&&pe());if(pe(),ge=()=>{se||Q||(se=!0,requestAnimationFrame(()=>{se=!1,function(){if(Q||K)return;const e=de();if(!e)return;const t=he(),n="block"===(a={placed:e.placed,zone:e.zone,pending:!0===e.pending,blockShown:X(),host:t?ue(t)?"lost":"drawn":"none",widthChanged:window.innerWidth!==re,headerChanged:Boolean(t&&ae&&L(t,ae))}).zone?a.blockShown?"keep":"redo":a.blockShown?"redo":a.placed?"drawn"!==a.host||a.widthChanged?"redo":a.headerChanged?"check_fit":"keep":a.pending||a.widthChanged?"redo":"keep";var a;"redo"===n?me():"check_fit"===n&&async function(){const e=he(),t=ae;if(ie||!e||!t)return;const n=le+1e3-performance.now();if(n>0)return void(ce||(ce=!0,setTimeout(()=>{ce=!1,ge()},n)));ie=!0;const a=oe;try{await R(e);const n=()=>k(t.header,[e,...t.controls]);for(let e=0;e<3&&!(await M(n,120,1200));e++);if(a!==oe||Q||K||!e.isConnected)return;const s=function(e,t,n=o()){const a=_(e);if(!a||!t.header.isConnected)return["header_redrawn"];const s=r(a),l=[];if((s.left<0||s.right>n.w+1)&&l.push("offscreen"),(s.width<24||s.height<24)&&l.push("too_small"),t.anchor.isConnected){const e=Math.round(y(s)-y(r(t.anchor)));Math.abs(e)>4&&l.push(`not_centred_${e}`)}const c=t.controls.map(e=>e.isConnected&&i(e)),h=Math.max(0,...t.controls.map((e,n)=>c[n]?Math.abs(y(r(e))-y(s)-t.offsets[n]):0));h>3&&l.push(`item_moved_${Math.round(h)}`);const d=t.controls.filter((e,t)=>{if(!c[t])return!1;const o=r(e);return o.left<-1||o.right>n.w+1});d.length&&l.push(`pushed_offscreen_${d.length}`);const u=$(e,s,S(t.header,n));if(u&&l.push(u),s.top>=0&&s.bottom<=n.h){const o=C(e,s,t.header,n);o&&l.push(o)}return l}(e,t);window.__doriAskTrace?.push(`refit ${s.join(",")||"ok"}`);const l=s.length?null:function(e,t){if([t.anchor,...t.controls].every(e=>e.isConnected)){const n=r(t.header);return{...t,size:{w:n.width,h:n.height},layout:A(e,t)}}const n=f(),o=de()?.spot;if(!n||!o)return null;const a=o.endsWith("_search")?n.search:o.endsWith("_cart")?n.cart:n.menu;return a?N(e,n.isBar&&o.endsWith("_search")?a:m(a),n.header,D(n)):null}(e,t);if(!l)return void me();ae=l}finally{ie=!1,le=performance.now()}}()}()}))},ee=new MutationObserver(ge),ee.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]}),te)return;let a;te=!0,setInterval(()=>{ne=0},6e4),window.addEventListener("resize",()=>{const e=de();!K&&e?.placed&&"block"!==e.zone&&window.innerWidth!==re&&fe(),clearTimeout(a),a=setTimeout(()=>ge(),200)},{passive:!0})}function be(e){return!e.designMode&&(!e.enabled||e.banned||!e.askOn)}function ye(e,t){if(!e)return;const n=window,o=!1!==e.is_widget_enabled,r=!0===e.feature_flags?.ask_button,a=be({enabled:o,banned:t,askOn:r,designMode:!0===n.Shopify?.designMode});if(document.querySelectorAll("[data-dori-ask-block]").forEach(e=>{a?(e.hidden=!0,e.style.setProperty("display","none","important"),e.dataset.doriHidden=""):void 0!==e.dataset.doriHidden&&(e.hidden=!1,e.style.removeProperty("display"),delete e.dataset.doriHidden)}),!r||!o||t||!1===n.DORI_HEADER_BUTTON)return Q=!0,oe++,ae=null,ee?.disconnect(),ee=null,void he()?.remove();we(function(e,t){const n=(e||"").trim().slice(0,30);return n?{label:n,aria:n}:{label:null,aria:(t||"").trim()||"Ask"}}(e.feature_flags?.ask_button_text,e.agent_name))}export{ye as applyAskButton,be as hideBlock};
|
|
1
|
+
import{d as e}from"./report-BHr6U1PB.js";const t="dori-ask-button";function n(e,n){const o=Boolean(e.label),r=o?Math.max(32,Math.min(38,e.boxHeight)):Math.max(32,Math.min(44,e.boxHeight));"undefined"==typeof customElements||customElements.get(t)||customElements.define(t,class extends HTMLElement{});const a=document.createElement(t);a.style.cssText=`display:inline-flex;align-items:center;flex:0 0 auto;height:${Math.max(r,e.boxHeight)}px;margin:0;padding:0;border:0;background:none;box-shadow:none;float:none;min-width:0;max-width:none;width:auto;vertical-align:middle;position:relative;z-index:1;color:${e.color};`;const i=a.attachShadow({mode:"open",delegatesFocus:!0}),s=Math.max(12,Math.min(15,e.fontSize||14));i.innerHTML=`<style>button{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:7px;height:${r}px;width:${o?"auto":`${r}px`};padding:${o?"0 14px 0 12px":"0"};border-radius:999px;cursor:pointer;color:inherit;font:inherit;font-size:${s}px;font-weight:600;line-height:1.2;white-space:nowrap;border:1.5px solid ${o?"currentColor":"transparent"}}button:hover{background:rgba(127,127,127,.12)}button:focus-visible{outline:2px solid currentColor;outline-offset:2px}svg{width:${e.iconSize}px;height:${e.iconSize}px;flex:0 0 auto}</style><button type="button"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M12 3.5l1.9 5.1 5.1 1.9-5.1 1.9L12 17.5l-1.9-5.1L5 10.5l5.1-1.9z"/><path d="M18.5 15.5l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8z"/></svg></button>`;const l=i.querySelector("button");if(l.setAttribute("aria-label",e.aria),e.label){const t=document.createElement("span");t.textContent=e.label,l.appendChild(t)}return l.addEventListener("click",n),a}const o=()=>({w:window.innerWidth,h:window.innerHeight}),r=e=>e.getBoundingClientRect();function a(e,t=o()){if(!e)return!1;const n=r(e);if(n.width<6||n.height<6||n.right<=0||n.left>=t.w||n.bottom<=0)return!1;const a=e;if(a.checkVisibility&&!a.checkVisibility({contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0}))return!1;const i=getComputedStyle(e);return"hidden"!==i.visibility&&"none"!==i.display&&parseFloat(i.opacity)>=.05}function i(e){const t=r(e);if(t.width<2||t.height<2)return!1;const n=e;return!n.checkVisibility||n.checkVisibility({visibilityProperty:!0})}const s=['input[type="search"]','input[name="q"]','a[href$="/search"]','a[href*="/search?"]','button[aria-label*="search" i]','a[aria-label*="search" i]','summary[aria-label*="search" i]','[aria-controls*="search" i]',"details-modal.header__search summary","predictive-search","search-button",'[class*="search-toggle" i]','[class*="search-icon" i]','[class*="header__search" i]','[data-action*="search" i]'].join(","),l=['a[href$="/cart"]','a[href*="/cart?"]',"#cart-icon-bubble","[data-cart-toggle]","[data-cart-trigger]","[data-open-cart]",'[data-drawer-toggle*="cart" i]','[aria-controls*="cart" i]','button[aria-label*="cart" i]','a[aria-label*="cart" i]','button[aria-label*="bag" i]','a[aria-label*="bag" i]','[class*="cart-icon" i]','[class*="header__cart" i]',"cart-icon","cart-drawer-component button"].join(","),c=['[aria-label*="menu" i]','summary[aria-controls*="menu" i]','[class*="menu-drawer" i] summary','[class*="hamburger" i]','[class*="burger" i]','[data-drawer-toggle*="menu" i]','button[aria-controls*="menu" i]','[class*="menu-toggle" i]','[class*="nav-toggle" i]',"header-drawer summary"].join(","),d=e=>Math.min(300,.4*e.h),h=(e,t)=>a(e,t)&&r(e).top<d(t)&&!e.closest('[role="dialog"], [aria-modal="true"]'),u=(e,t)=>{const n=e.closest("a, button, summary");return n&&a(n,t)&&r(n).width<220?n:e};function f(e=o()){const t=[...document.querySelectorAll(s)].filter(t=>h(t,e)),n=[...document.querySelectorAll(l)].filter(t=>h(t,e));if(!t.length&&!n.length)return null;let i=null,f=!1;const p=t.find(e=>"INPUT"===e.tagName&&r(e).width>120);if(p){f=!0;let e=p.closest("form")||p.parentElement||p;for(let t=0;t<3&&e.parentElement&&r(e.parentElement).width<r(p).width+140;t++)e=e.parentElement;i=e}else if(t.length){const n=t.map(t=>u(t,e)).filter(t=>a(t,e)&&r(t).width<200&&r(t).height<90);n.sort((e,t)=>r(t).right-r(e).right),i=n[0]||null}let m=null;if(n.length){const t=n.map(t=>u(t,e)).filter(e=>r(e).width<260&&r(e).height<130);t.sort((e,t)=>r(t).right-r(e).right),m=t[0]||null}const g=[...document.querySelectorAll(c)].filter(t=>h(t,e)&&r(t).width<120).map(t=>u(t,e)),w="rtl"===getComputedStyle(document.documentElement).direction;g.sort((e,t)=>w?r(t).right-r(e).right:r(e).left-r(t).left);const b=g.find(t=>w?r(t).right>.65*e.w:r(t).left<.35*e.w)||null,y=i||m;let _=y.parentElement||y;for(let o=y.parentElement;o&&o!==document.body;o=o.parentElement){const t=r(o);if(t.top>d(e)||t.height>360)break;t.width>=.6*e.w&&(_=o)}return{search:i,isBar:f,cart:m,menu:b,header:_,rtl:w||"rtl"===getComputedStyle(_).direction}}function p(e){let t=e;for(let n=0;n<6;n++){const e=t.parentElement;if(!e||e===document.body||"HEADER"===e.tagName)break;if([...e.children].some(e=>e!==t&&a(e)))break;t=e}return t}function m(e){return[...e.querySelectorAll("svg, img")].find(e=>a(e))||e}function g(e){const t=getComputedStyle(e);return!(/grid/.test(t.display)||/flex/.test(t.display)&&/space-(between|around|evenly)/.test(t.justifyContent))}const w=(e,t)=>Math.max(0,Math.min(e.right,t.right)-Math.max(e.left,t.left))*Math.max(0,Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top)),b=e=>/^(A|BUTTON|IMG|SVG|INPUT|SELECT|TEXTAREA|LABEL|SUMMARY|VIDEO|CANVAS)$/i.test(e.tagName)||e.hasAttribute("role")||(e=>[...e.childNodes].some(e=>e.nodeType===Node.TEXT_NODE&&""!==(e.textContent||"").trim()))(e),y=e=>e.top+e.height/2,_=e=>e.shadowRoot?.querySelector("button")??null;function v(e,t,{sideways:n=!0}={}){const o=(e,t)=>Math.abs(e-t)<=1,r=(e,t)=>e.length===t.length&&e.every((e,n)=>o(e,t[n]));return o(e.x,t.x)&&o(e.y,t.y)&&e.w===t.w&&e.h===t.h&&o(e.header,t.header)&&r(e.tops,t.tops)&&(!n||r(e.lefts,t.lefts))}function k(e,t){const n=t.map(r);return{x:window.scrollX,y:window.scrollY,w:window.innerWidth,h:window.innerHeight,header:r(e).height,tops:n.map(e=>e.top),lefts:n.map(e=>e.left)}}const x=e=>new Promise(t=>setTimeout(t,e));async function M(e,t,n){const o=performance.now();await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e()))),document.fonts&&await document.fonts.ready;const r=t-(performance.now()-o);r>0&&await x(r);let a=e();for(;performance.now()-o<n;){await x(80);const t=e();if(v(a,t))return!0;a=t}return!1}function E(e,t){return[...e.querySelectorAll("*")].filter(e=>!(e.closest("svg")&&"svg"!==e.tagName.toLowerCase())&&b(e)&&a(e,t)&&r(e).top<Math.min(300,.4*t.h)+60).slice(0,260)}function S(e,t,n){const o=e.closest("dialog[open]");if(o&&!o.contains(t))return!0;for(let a=e;a&&a!==document.body;a=a.parentElement){const e=getComputedStyle(a);if(!("fixed"!==e.position&&"sticky"!==e.position||a.contains(t)||t.contains(a))){const e=r(a);if(e.width*e.height>n.w*n.h*.4)return!0}}return!1}function $(e,t,n){for(const o of n)if(!e.contains(o)&&!o.contains(e)&&w(t,r(o))>16)return`overlaps_${o.tagName.toLowerCase()}`;return null}function C(e,t,n,o){for(let a=1;a<=5;a++)for(let i=1;i<=3;i++){const s=t.left+t.width*a/6,l=t.top+t.height*i/4,c=document.elementFromPoint(s,l);if(!(c===e||e.contains(c)||c&&S(c,n,o)))return`covered_by_${c?c.tagName.toLowerCase():"nothing"}`;const d=document.elementsFromPoint(s,l),h=d.indexOf(e);for(const t of d.slice(h+1))if(!t.contains(e)&&t!==document.body&&t!==document.documentElement&&b(t)&&r(t).width<.6*o.w)return`sits_on_${t.tagName.toLowerCase()}`}return null}function z(e,t=o()){const n=E(e,t),a=n.map(e=>r(e).top),i=n.map(e=>{const n=r(e);return n.left>=-1&&n.right<=t.w+1}),s=()=>{const e=n.map(r),t=new Set;for(let o=0;o<n.length;o++)for(let r=o+1;r<n.length;r++)n[o].contains(n[r])||n[r].contains(n[o])||w(e[o],e[r])>16&&t.add(`${o}:${r}`);return t},l=s(),c=r(e).height,d=t=>{const o=t&&_(t);return k(e,o?[...n,o]:n)},h=d();return{look:d,before:h,check(o,d){const h=_(o);if(!h)return["no_button"];const u=r(h),f=[],p=Math.round(r(e).height-c);Math.abs(p)>2&&f.push(`header_height_${p}`);const m=Math.max(0,...n.map((e,t)=>Math.abs(r(e).top-a[t])));m>3&&f.push(`item_moved_${Math.round(m)}`);const g=n.filter((e,n)=>{if(!i[n]||o.contains(e))return!1;const a=r(e);return a.left<-1||a.right>t.w+1});g.length&&f.push(`pushed_offscreen_${g.length}`),(u.left<0||u.right>t.w+1||u.top<0)&&f.push("offscreen"),(u.width<24||u.height<24)&&f.push("too_small");const w=Math.round(y(u)-y(r(d)));Math.abs(w)>4&&f.push(`not_centred_${w}`);const b=$(o,u,n);b&&f.push(b);const v=C(o,u,e,t);v&&f.push(v);const k=[...s()].filter(e=>!l.has(e));return k.length&&f.push(`theme_overlap_${k.length}`),f}}}function N(e,t){const n=r(t.header);return[_(e)??e,t.anchor,...t.controls].flatMap(e=>{if(!e.isConnected||!i(e))return[NaN,NaN,NaN,NaN];const t=r(e);return[t.left-n.left,t.top-n.top,t.width,t.height]})}function A(e,t,n,o){const a=_(e);if(!a)return null;const i=y(r(a)),s=r(n);return{header:n,size:{w:s.width,h:s.height},anchor:t,controls:o,offsets:o.map(e=>y(r(e))-i),layout:N(e,{header:n,anchor:t,controls:o})}}function L(e,t){if(!t.header.isConnected)return!0;const n=r(t.header);if(Math.abs(n.width-t.size.w)>1||Math.abs(n.height-t.size.h)>2)return!0;const o=N(e,t);return o.length!==t.layout.length||o.some((e,n)=>{const o=t.layout[n];return Number.isNaN(e)!==Number.isNaN(o)||Math.abs(e-o)>2})}function T(e){for(const t of e){const e=t.getAttribute("onclick");if(e&&/doriWidget/.test(e))return!0;const n=t.getAttribute("href");if(n&&/(#dori-chat\b|[?&]dori-chat=)/i.test(n))return!0}return!1}const B=e=>e?`${e.tagName.toLowerCase()}${e.classList[0]?`.${e.classList[0]}`:""}`:"-",P=e=>new Promise(t=>setTimeout(t,e)),q=e=>`dori_ask_spot_${e}`,W=e=>`${e.spot}:${e.label?"text":"icon"}`,I=new Set;function H(e,t){if(!I.has(e)){I.add(e);try{t?window.localStorage.setItem(q(e),W(t)):window.localStorage.removeItem(q(e))}catch{}}}const F=e=>{const t=r(e);return t.top>=0&&t.bottom<=window.innerHeight};function R(e){return F(e)?Promise.resolve():new Promise(t=>{const n=()=>{F(e)&&(clearInterval(o),window.removeEventListener("scroll",n),window.removeEventListener("resize",n),t())},o=setInterval(n,250);window.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",n,{passive:!0})})}async function j(){const e=await async function(){for(let e=0;e<32;e++){const e=f();if(e)return e;await P(250)}return null}();if(!e)return null;let t=e;for(;;){await R(t.search||t.cart||t.header);const e=z(t.header,o());if(await M(()=>e.look(),150,1500),t=f()||t,F(t.search||t.cart||t.header))return t}}function O(){window.doriWidget?.open?.({source:"header_button"})}function V(e,t,n){const o=function(e,t){for(let n=t?e.nextElementSibling:e.previousElementSibling;n;n=t?n.nextElementSibling:n.previousElementSibling)if(a(n))return n;return null}(e,"end"===t);if(!o)return;const i=r(e),s=r(o);(("end"===t?!n:n)?s.left-i.right:i.left-s.right)<6&&(e.style["end"===t?"marginInlineEnd":"marginInlineStart"]="8px")}const D=e=>[e.search,e.cart,e.menu].filter(e=>Boolean(e));function U(e,t,n){const o=t.spot.endsWith("_search")?n.search:t.spot.endsWith("_cart")?n.cart:n.menu;if(!o)return!1;const a=p(o),i=a.parentElement;if(!i)return!1;const s=parseFloat(getComputedStyle(i).columnGap)||0;if("after_search"===t.spot)return i.insertBefore(e,a.nextSibling),s||(e.style.marginInlineStart="10px",V(e,"end",n.rtl)),!0;if("before_cart"===t.spot)return i.insertBefore(e,a),s||(e.style.marginInlineEnd="10px",V(e,"start",n.rtl)),!0;const l=o.offsetParent;if(!l||l===document.body||l===document.documentElement)return!1;l.appendChild(e),e.style.position="absolute";const c=r(l),d=r(e),h=r("beside_menu"===t.spot?o:a),u="beside_search"===t.spot||"beside_menu"===t.spot,f=n.rtl?!u:u,m="beside_menu"===t.spot?4:10,g=f?h.right-c.left+m:h.left-c.left-d.width-m;return e.style.left=`${Math.round(g+l.scrollLeft)}px`,e.style.top=`${Math.round(h.top+h.height/2-c.top-d.height/2)}px`,!0}async function G(e,t,i,s){const l=o(),c=e.cart||e.search||e.menu,d=[...e.header.querySelectorAll("nav a, [class*='menu' i] a")].find(e=>a(e,l)),h=getComputedStyle(d||c),u=e.cart?m(e.cart):e.search?m(e.search):null,f=u&&/^(svg|img)$/i.test(u.tagName)?Math.max(16,Math.min(26,Math.round(r(u).height))):20,w=function(e){const t=e.desktop&&e.hasLabel?[!0,!1]:[!1],n=[];if(e.hasSearch)for(const o of t)e.searchPacked&&n.push({zone:"near_search",spot:"after_search",label:o}),n.push({zone:"near_search",spot:"beside_search",label:o}),n.push({zone:"near_search",spot:"before_search",label:o});if(e.hasCart)for(const o of t)e.cartPacked&&n.push({zone:"other_header",spot:"before_cart",label:o}),n.push({zone:"other_header",spot:"beside_cart",label:o});return e.hasMenu&&!e.desktop&&n.push({zone:"other_header",spot:"beside_menu",label:!1}),n}({desktop:"computer"===i,hasLabel:Boolean(t.label),hasSearch:Boolean(e.search),searchPacked:Boolean(e.search?.parentElement&&g(p(e.search).parentElement)),hasCart:Boolean(e.cart),cartPacked:Boolean(e.cart?.parentElement&&g(p(e.cart).parentElement)),hasMenu:Boolean(e.menu)}),b=z(e.header,l);for(const o of function(e,t){let n=null;try{n=window.localStorage.getItem(q(t))}catch{}const o=e.find(e=>W(e)===n);return o?[o,...e.filter(e=>e!==o)]:e}(w,i)){const a=o.spot.endsWith("_search")?e.search:o.spot.endsWith("_cart")?e.cart:e.menu,l=e.isBar&&o.spot.endsWith("_search")?a:m(a),d=Math.max(28,Math.min(44,Math.round(r(l).height+16))),u=n({label:o.label?t.label:null,aria:t.aria,boxHeight:d,color:getComputedStyle(c).color,fontSize:parseFloat(h.fontSize),iconSize:f},O);if(u.style.opacity="0",!U(u,o,e)){s?.push(`${W(o)} cant_apply`);continue}u.parentElement&&getComputedStyle(u.parentElement).color===getComputedStyle(c).color&&u.style.removeProperty("color");const p=u.shadowRoot.querySelector("button"),g=Math.round(r(l).top+r(l).height/2-(r(p).top+r(p).height/2));Math.abs(g)>1&&Math.abs(g)<24&&(u.style.top=`${(parseFloat(u.style.top)||0)+g}px`),await M(()=>b.look(u),120,700);let w=b.check(u,l);if(!w.length){if(await M(()=>b.look(u),450,1200),w=b.check(u,l),!w.length)return H(i,o),ae=A(u,l,e.header,D(e)),s?.push(`${W(o)} ok`),{placed:!0,zone:o.zone,spot:o.spot,label:o.label,device:i};w=w.map(e=>`${e}(confirm)`)}if(u.remove(),!v(b.before,b.look(),{sideways:!1}))return s?.push(`${W(o)} ${w.join(",")} page_moved`),"page_moved";s?.push(`${W(o)} ${w.join(",")}`)}return null}function X(){return[...document.querySelectorAll("[data-dori-ask-block]")].some(e=>{if(!i(e))return!1;const t=r(e);return t.right>0&&t.left<window.innerWidth})}async function Y(t){ae=null;const n=e(),o={placed:!1,zone:"none",device:n},r=window.__doriAskTrace;if(X())return{placed:!0,zone:"block",device:n};for(let e=0;e<=3;e++){const e=await j();if(!e)return r?.push(`${n} no_anchors`),o;if(r?.push(`${n} search=${B(e.search)}${e.isBar?"(bar)":""} cart=${B(e.cart)} menu=${B(e.menu)} header=${B(e.header)}`),T(e.header.querySelectorAll("[onclick], a[href]")))return r?.push("own_entry"),o;const a=await G(e,t,n,r);if("page_moved"!==a){if(a)return a;break}}return H(n,null),o}function J(e){window.__doriAskResult=e,window.dispatchEvent(new CustomEvent("dori:ask-button",{detail:e}))}let K=null,Q=!0,Z=null,ee=null,te=!1,ne=0,oe=0,re=0,ae=null,ie=!1,se=!1,le=0,ce=!1;const de=()=>document.querySelector(t),he=()=>window.__doriAskResult;function ue(e){return!!e&&!i(e.shadowRoot?.querySelector("button")??e)}function fe(){de()?.remove(),ae=null,he()?.placed&&J({placed:!1,zone:"none",device:e(),pending:!0})}async function pe(){if(Z&&!Q)return K||(K=(async()=>{for(;;){const t=Z,n=window.innerWidth;let o;oe++,fe();try{o=await Y(t)}catch{de()?.remove(),o={placed:!1,zone:"none",device:e()}}if(Q)return void de()?.remove();if(t!==Z||window.innerWidth!==n)continue;const r=de();return r&&(r.style.transition="opacity .2s ease",r.style.opacity="1"),re=n,void J(o)}})().finally(()=>{K=null,we()}),K)}function me(){if(ne>=10){de()?.remove(),ae=null,re=window.innerWidth;const t=he();return void((t?.placed||t?.pending)&&J({placed:!1,zone:"none",device:e()}))}ne++,pe()}let ge,we=()=>{};function be(e){const t=!Z||Z.label!==e.label||Z.aria!==e.aria;t&&(Z=e);const n=Q;if(Q=!1,!n)return void(t&&pe());if(pe(),we=()=>{se||Q||(se=!0,requestAnimationFrame(()=>{se=!1,function(){if(Q||K)return;const e=he();if(!e)return;const t=de(),n="block"===(a={placed:e.placed,zone:e.zone,pending:!0===e.pending,blockShown:X(),host:t?ue(t)?"lost":"drawn":"none",widthChanged:window.innerWidth!==re,headerChanged:Boolean(t&&ae&&L(t,ae))}).zone?a.blockShown?"keep":"redo":a.blockShown?"redo":a.placed?"drawn"!==a.host||a.widthChanged?"redo":a.headerChanged?"check_fit":"keep":a.pending||a.widthChanged?"redo":"keep";var a;"redo"===n?me():"check_fit"===n&&async function(){const e=de(),t=ae;if(ie||!e||!t)return;const n=le+1e3-performance.now();if(n>0)return void(ce||(ce=!0,setTimeout(()=>{ce=!1,we()},n)));ie=!0;const a=oe;try{await R(e);const n=()=>k(t.header,[e,...t.controls]);for(let e=0;e<3&&!(await M(n,120,1200));e++);if(a!==oe||Q||K||!e.isConnected)return;const s=function(e,t,n=o()){const a=_(e);if(!a||!t.header.isConnected)return["header_redrawn"];const s=r(a),l=[];if((s.left<0||s.right>n.w+1)&&l.push("offscreen"),(s.width<24||s.height<24)&&l.push("too_small"),t.anchor.isConnected){const e=Math.round(y(s)-y(r(t.anchor)));Math.abs(e)>4&&l.push(`not_centred_${e}`)}const c=t.controls.map(e=>e.isConnected&&i(e)),d=Math.max(0,...t.controls.map((e,n)=>c[n]?Math.abs(y(r(e))-y(s)-t.offsets[n]):0));d>3&&l.push(`item_moved_${Math.round(d)}`);const h=t.controls.filter((e,t)=>{if(!c[t])return!1;const o=r(e);return o.left<-1||o.right>n.w+1});h.length&&l.push(`pushed_offscreen_${h.length}`);const u=$(e,s,E(t.header,n));if(u&&l.push(u),s.top>=0&&s.bottom<=n.h){const o=C(e,s,t.header,n);o&&l.push(o)}return l}(e,t);window.__doriAskTrace?.push(`refit ${s.join(",")||"ok"}`);const l=s.length?null:function(e,t){if([t.anchor,...t.controls].every(e=>e.isConnected)){const n=r(t.header);return{...t,size:{w:n.width,h:n.height},layout:N(e,t)}}const n=f(),o=he()?.spot;if(!n||!o)return null;const a=o.endsWith("_search")?n.search:o.endsWith("_cart")?n.cart:n.menu;return a?A(e,n.isBar&&o.endsWith("_search")?a:m(a),n.header,D(n)):null}(e,t);if(!l)return void me();ae=l}finally{ie=!1,le=performance.now()}}()}()}))},ee=new MutationObserver(e=>{we(),ae&&e.some(e=>ae.header.contains(e.target))&&(clearTimeout(ge),ge=setTimeout(()=>we(),700))}),ee.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style","hidden"]}),te)return;te=!0,setInterval(()=>{ne=0},6e4);const a=e=>{ae&&e.target instanceof Node&&ae.header.contains(e.target)&&we()};let s;document.addEventListener("transitionend",a,!0),document.addEventListener("animationend",a,!0),window.addEventListener("resize",()=>{const e=he();!K&&e?.placed&&"block"!==e.zone&&window.innerWidth!==re&&fe(),clearTimeout(s),s=setTimeout(()=>we(),200)},{passive:!0})}function ye(e){return!e.designMode&&(!e.enabled||e.banned||!e.askOn)}function _e(e,t){if(!e)return;const n=window,o=!1!==e.is_widget_enabled,r=!0===e.feature_flags?.ask_button,a=ye({enabled:o,banned:t,askOn:r,designMode:!0===n.Shopify?.designMode});if(document.querySelectorAll("[data-dori-ask-block]").forEach(e=>{a?(e.hidden=!0,e.style.setProperty("display","none","important"),e.dataset.doriHidden=""):void 0!==e.dataset.doriHidden&&(e.hidden=!1,e.style.removeProperty("display"),delete e.dataset.doriHidden)}),!r||!o||t||!1===n.DORI_HEADER_BUTTON)return Q=!0,oe++,ae=null,ee?.disconnect(),ee=null,void de()?.remove();be(function(e,t){const n=(e||"").trim().slice(0,30);return n?{label:n,aria:n}:{label:null,aria:(t||"").trim()||"Ask"}}(e.feature_flags?.ask_button_text,e.agent_name))}export{_e as applyAskButton,ye as hideBlock};
|
|
Binary file
|
|
Binary file
|
package/dist/widget.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./assets/apply-
|
|
2
|
-
const e={},t=function(t,i,r){let s=Promise.resolve();if(i&&i.length>0){let t=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e}))))};const n=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),a=o?.nonce||o?.getAttribute("nonce");s=t(i.map(t=>{if(t=function(e,t){return new URL(e,t).href}(t,r),t in e)return;e[t]=!0;const i=t.endsWith(".css"),s=i?'[rel="stylesheet"]':"";if(r)for(let e=n.length-1;e>=0;e--){const r=n[e];if(r.href===t&&(!i||"stylesheet"===r.rel))return}else if(document.querySelector(`link[href="${t}"]${s}`))return;const o=document.createElement("link");return o.rel=i?"stylesheet":"modulepreload",i||(o.as="script"),o.crossOrigin="",o.href=t,a&&o.setAttribute("nonce",a),document.head.appendChild(o),i?new Promise((e,i)=>{o.addEventListener("load",e),o.addEventListener("error",()=>i(new Error(`Unable to preload CSS for ${t}`)))}):void 0}))}function n(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return s.then(e=>{for(const t of e||[])"rejected"===t.status&&n(t.reason);return t().catch(n)})};let i=null;function r(e){let t=e.replace(/<thought>[\s\S]*?<\/thought>/gi,"");return t=t.replace(/<thought>[\s\S]*$/gi,""),t.trim()}const s=e=>{if(!e)return;const t=e.closest('[data-scroll-container="chat-messages"]');t&&null===i&&(i=setTimeout(()=>{i=null,t.scrollTo({top:t.scrollHeight,behavior:"smooth"})},200))},n=(e,t,i=new Date)=>{const r=e?.feature_flags?.panel_greeting;return"string"==typeof r?r.trim():((e,t,i=new Date)=>{const r=e||"Dori";return`${i.getHours()>=18&&t.hiImEvening?t.hiImEvening:t.hiIm} ${r}!`})(e?.agent_name,t,i)};var o="undefined"!=typeof window?window:void 0,a="undefined"!=typeof globalThis?globalThis:o;"undefined"==typeof self&&(a.self=a),"undefined"==typeof File&&(a.File=function(){});var l=Array.prototype,c=l.forEach,u=l.indexOf,h=null==a?void 0:a.navigator,d=null==a?void 0:a.document,p=null==a?void 0:a.location,g=null==a?void 0:a.fetch,_=null!=a&&a.XMLHttpRequest&&"withCredentials"in new a.XMLHttpRequest?a.XMLHttpRequest:void 0,v=null==a?void 0:a.AbortController,f=null==h?void 0:h.userAgent,m=null!=o?o:{},y={DEBUG:!1,LIB_VERSION:"1.343.2"};function b(e,t,i,r,s,n,o){try{var a=e[n](o),l=a.value}catch(c){return void i(c)}a.done?t(l):Promise.resolve(l).then(r,s)}function w(e){return function(){var t=this,i=arguments;return new Promise(function(r,s){var n=e.apply(t,i);function o(e){b(n,r,s,o,a,"next",e)}function a(e){b(n,r,s,o,a,"throw",e)}o(void 0)})}}function E(){return E=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},E.apply(null,arguments)}function S(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var x=["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"],k=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return x.concat(t).some(e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)})},I=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function P(e,t){return-1!==e.indexOf(t)}var T=function(e){return e.trim()},F=function(e){return e.replace(/^\$/,"")},R=Array.isArray,$=Object.prototype,O=$.hasOwnProperty,A=$.toString,C=R||function(e){return"[object Array]"===A.call(e)},M=e=>"function"==typeof e,D=e=>e===Object(e)&&!C(e),N=e=>{if(D(e)){for(var t in e)if(O.call(e,t))return!1;return!0}return!1},L=e=>void 0===e,j=e=>"[object String]"==A.call(e),H=e=>j(e)&&0===e.trim().length,U=e=>null===e,q=e=>L(e)||U(e),B=e=>"[object Number]"==A.call(e)&&e==e,G=e=>B(e)&&e>0,V=e=>"[object Boolean]"===A.call(e),W=e=>P(I,e);function z(e){return null===e||"object"!=typeof e}function Y(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function J(e){return!L(Event)&&function(e,t){try{return e instanceof t}catch(i){return!1}}(e,Event)}var K=[!0,"true",1,"1","yes"],X=e=>P(K,e),Z=[!1,"false",0,"0","no"];function Q(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),B(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),Q(s||i,t,i,r))}class ee{constructor(e){this.t={},this.i=e.i,this.o=Q(e.bucketSize,0,100,e.h),this.m=Q(e.refillRate,0,this.o,e.h),this.$=Q(e.refillInterval,0,864e5,e.h)}S(e,t){var i=t-e.lastAccess,r=Math.floor(i/this.$);if(r>0){var s=r*this.m;e.tokens=Math.min(e.tokens+s,this.o),e.lastAccess=e.lastAccess+r*this.$}}consumeRateLimit(e){var t,i=Date.now(),r=String(e),s=this.t[r];return s?this.S(s,i):(s={tokens:this.o,lastAccess:i},this.t[r]=s),0===s.tokens||(s.tokens--,0===s.tokens&&(null==(t=this.i)||t.call(this,e)),0===s.tokens)}stop(){this.t={}}}var te,ie,re,se="Mobile",ne="iOS",oe="Android",ae="Tablet",le=oe+" "+ae,ce="iPad",ue="Apple",he=ue+" Watch",de="Safari",pe="BlackBerry",ge="Samsung",_e=ge+"Browser",ve=ge+" Internet",fe="Chrome",me=fe+" OS",ye=fe+" "+ne,be="Internet Explorer",we=be+" "+se,Ee="Opera",Se=Ee+" Mini",xe="Edge",ke="Microsoft "+xe,Ie="Firefox",Pe=Ie+" "+ne,Te="Nintendo",Fe="PlayStation",Re="Xbox",$e=oe+" "+se,Oe=se+" "+de,Ae="Windows",Ce=Ae+" Phone",Me="Nokia",De="Ouya",Ne="Generic",Le=Ne+" "+se.toLowerCase(),je=Ne+" "+ae.toLowerCase(),He="Konqueror",Ue="(\\d+(\\.\\d+)?)",qe=new RegExp("Version/"+Ue),Be=new RegExp(Re,"i"),Ge=new RegExp(Fe+" \\w+","i"),Ve=new RegExp(Te+" \\w+","i"),We=new RegExp(pe+"|PlayBook|BB10","i"),ze={"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"},Ye=function(e,t){return t=t||"",P(e," OPR/")&&P(e,"Mini")?Se:P(e," OPR/")?Ee:We.test(e)?pe:P(e,"IE"+se)||P(e,"WPDesktop")?we:P(e,_e)?ve:P(e,xe)||P(e,"Edg/")?ke:P(e,"FBIOS")?"Facebook "+se:P(e,"UCWEB")||P(e,"UCBrowser")?"UC Browser":P(e,"CriOS")?ye:P(e,"CrMo")||P(e,fe)?fe:P(e,oe)&&P(e,de)?$e:P(e,"FxiOS")?Pe:P(e.toLowerCase(),He.toLowerCase())?He:((e,t)=>{return t&&P(t,ue)||P(i=e,de)&&!P(i,fe)&&!P(i,oe);var i})(e,t)?P(e,se)?Oe:de:P(e,Ie)?Ie:P(e,"MSIE")||P(e,"Trident/")?be:P(e,"Gecko")?Ie:""},Je={[we]:[new RegExp("rv:"+Ue)],[ke]:[new RegExp(xe+"?\\/"+Ue)],[fe]:[new RegExp("("+fe+"|CrMo)\\/"+Ue)],[ye]:[new RegExp("CriOS\\/"+Ue)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ue)],[de]:[qe],[Oe]:[qe],[Ee]:[new RegExp("(Opera|OPR)\\/"+Ue)],[Ie]:[new RegExp(Ie+"\\/"+Ue)],[Pe]:[new RegExp("FxiOS\\/"+Ue)],[He]:[new RegExp("Konqueror[:/]?"+Ue,"i")],[pe]:[new RegExp(pe+" "+Ue),qe],[$e]:[new RegExp("android\\s"+Ue,"i")],[ve]:[new RegExp(_e+"\\/"+Ue)],[be]:[new RegExp("(rv:|MSIE )"+Ue)],Mozilla:[new RegExp("rv:"+Ue)]},Ke=function(e,t){var i=Ye(e,t),r=Je[i];if(L(r))return null;for(var s=0;s<r.length;s++){var n=r[s],o=e.match(n);if(o)return parseFloat(o[o.length-2])}return null},Xe=[[new RegExp(Re+"; "+Re+" (.*?)[);]","i"),e=>[Re,e&&e[1]||""]],[new RegExp(Te,"i"),[Te,""]],[new RegExp(Fe,"i"),[Fe,""]],[We,[pe,""]],[new RegExp(Ae,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Ce,""];if(new RegExp(se).test(t)&&!/IEMobile\b/.test(t))return[Ae+" "+se,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],s=ze[r]||"";return/arm/i.test(t)&&(s="RT"),[Ae,s]}return[Ae,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[ne,t.join(".")]}return[ne,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=L(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+oe+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+oe+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[oe,t.join(".")]}return[oe,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[me,""]],[/Linux|debian/i,["Linux",""]]],Ze=function(e){return Ve.test(e)?Te:Ge.test(e)?Fe:Be.test(e)?Re:new RegExp(De,"i").test(e)?De:new RegExp("("+Ce+"|WPDesktop)","i").test(e)?Ce:/iPad/.test(e)?ce:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?he:We.test(e)?pe:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Me,"i").test(e)?Me:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(se).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?oe:le:new RegExp("(pda|"+se+")","i").test(e)?Le:new RegExp(ae,"i").test(e)&&!new RegExp(ae+" pc","i").test(e)?je:""},Qe=e=>e instanceof Error;function et(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return re&&i.length===ie||(ie=i.length,re=i.reduce((i,r)=>{te||(te={});var s=te[r];if(s)i[s[0]]=s[1];else for(var n=e(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,c=t[r];if(l&&c){i[l]=c,te[r]=[l,c];break}}return i},{})),re}}class tt{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(t),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var t=this;return w(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:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,r;return null!=e.cause&&(i=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),E({},e,{cause:i,stack:r})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}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 w(function*(){var i=e;for(var r of t.modifiers)i=yield r(i);return i})()}convertToExceptionList(e,t){var i,r,s,n={type:e.type,value:e.value,mechanism:{type:null!==(i=t.type)&&void 0!==i?i:"generic",handled:null===(r=t.handled)||void 0===r||r,synthetic:null!==(s=e.synthetic)&&void 0!==s&&s}};e.stack&&(n.stacktrace={type:"raw",frames:e.stack});var o=[n];return null!=e.cause&&o.push(...this.convertToExceptionList(e.cause,E({},t,{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:et(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,i){void 0===i&&(i=0);var r=(i,r)=>{if(r<=4){var s=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,s)}};return E({},t,{syntheticException:0==i?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,i),next:e=>r(e,i+1)})}}var it="?";function rt(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?it:i,in_app:!0};return L(r)||(n.lineno=r),L(s)||(n.colno=s),n}var st=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:it,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},nt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ot=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,at=/\((\S*)(?::(\d+))(?::(\d+))\)/,lt=(e,t)=>{var i=nt.exec(e);if(i){var[,r,s,n]=i;return rt(t,r,it,+s,+n)}var o=ot.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=at.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=st(o[1]||it,o[2]);return rt(t,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},ct=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ut=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ht=(e,t)=>{var i=ct.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=ut.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var s=i[3],n=i[1]||it;return[n,s]=st(n,s),rt(t,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},dt=/\(error: (.*)\)/;class pt{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=j(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 Y(e,"DOMException")}isDOMError(e){return Y(e,"DOMError")}}class gt{match(e){return e instanceof Error}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&&"string"==typeof i.error.message?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}}class _t{constructor(){}match(e){return Y(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var vt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ft{match(e){return"string"==typeof e}coerce(e,t){var i,[r,s]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=s?s:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(vt);return r&&(t=r[1],i=r[2]),[t,i]}}var mt=["fatal","error","warning","log","info","debug"];function yt(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var s=i.slice(0,r).join(", ");if(!(s.length>t))return r===i.length||s.length<=t?s:s.slice(0,t)+"..."}return""}class bt{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return J(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+yt(e)}isSeverityLevel(e){return j(e)&&!H(e)&&mt.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(Qe(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(i){return}}}class wt{match(e){return J(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+yt(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Et{match(e){return z(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class St{match(e){return Y(e,"PromiseRejectionEvent")}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return z(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){if(z(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(t){}return e}}var xt=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={k:function(t){if(o&&(y.DEBUG||m.POSTHOG_DEBUG||i)&&!L(o.console)&&o.console){for(var r=("__rrweb_original__"in o.console[t]?o.console[t].__rrweb_original__:o.console[t]),s=arguments.length,n=new Array(s>1?s-1:0),a=1;a<s;a++)n[a-1]=arguments[a];r(e,...n)}},info:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("error",...t)},critical:function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning:e=>{r.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>xt(e+" "+t,i)};return r},kt=xt("[PostHog.js]"),It=kt.createLogger,Pt=It("[ExternalScriptsLoader]"),Tt=(e,t,i)=>{if(e.config.disable_external_dependency_loading)return Pt.warn(t+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var r=null==d?void 0:d.querySelectorAll("script");if(r)for(var s,n=function(){if(r[o].src===t){var e=r[o];return e.__posthog_loading_callback_fired?{v:i()}:(e.addEventListener("load",t=>{e.__posthog_loading_callback_fired=!0,i(void 0,t)}),e.onerror=e=>i(e),{v:void 0})}},o=0;o<r.length;o++)if(s=n())return s.v;var a=()=>{if(!d)return i("document not found");var r=d.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=t,r.onload=e=>{r.__posthog_loading_callback_fired=!0,i(void 0,e)},r.onerror=e=>i(e),e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return i("prepare_external_dependency_script returned null");if("head"===e.config.external_scripts_inject_target)d.head.appendChild(r);else{var s,n=d.querySelectorAll("body > script");n.length>0?null==(s=n[0].parentNode)||s.insertBefore(r,n[0]):d.body.appendChild(r)}};null!=d&&d.body?a():null==d||d.addEventListener("DOMContentLoaded",a)};m.__PosthogExtensions__=m.__PosthogExtensions__||{},m.__PosthogExtensions__.loadExternalDependency=(e,t,i)=>{var r="/static/"+t+".js?v="+e.version;if("remote-config"===t&&(r="/array/"+e.config.token+"/config.js"),"toolbar"===t){var s=3e5;r=r+"&t="+Math.floor(Date.now()/s)*s}var n=e.requestRouter.endpointFor("assets",r);Tt(e,n,i)},m.__PosthogExtensions__.loadSiteApp=(e,t,i)=>{var r=e.requestRouter.endpointFor("api",t);Tt(e,r,i)};var Ft={};function Rt(e,t,i){if(C(e))if(c&&e.forEach===c)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var r=0,s=e.length;r<s;r++)if(r in e&&t.call(i,e[r],r)===Ft)return}function $t(e,t,i){if(!q(e)){if(C(e))return Rt(e,t,i);if((e=>e instanceof FormData)(e)){for(var r of e.entries())if(t.call(i,r[1],r[0])===Ft)return}else for(var s in e)if(O.call(e,s)&&t.call(i,e[s],s)===Ft)return}}var Ot=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Rt(i,function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])}),e},At=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Rt(i,function(t){Rt(t,function(t){e.push(t)})}),e};function Ct(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var Mt=function(e){try{return e()}catch(t){return}},Dt=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return e.apply(this,i)}catch(s){kt.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),kt.critical(s)}}},Nt=function(e){var t={};return $t(e,function(e,i){(j(e)&&e.length>0||B(e))&&(t[i]=e)}),t},Lt=["herokuapp.com","vercel.app","netlify.app"];function jt(e){var t=null==e?void 0:e.hostname;if(!j(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Lt)if(i===r)return!1;return!0}function Ht(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function Ut(e,t,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:s,passive:n})}var qt="$people_distinct_id",Bt="__alias",Gt="__timers",Vt="$autocapture_disabled_server_side",Wt="$heatmaps_enabled_server_side",zt="$exception_capture_enabled_server_side",Yt="$error_tracking_suppression_rules",Jt="$error_tracking_capture_extension_exceptions",Kt="$web_vitals_enabled_server_side",Xt="$dead_clicks_enabled_server_side",Zt="$product_tours_enabled_server_side",Qt="$web_vitals_allowed_metrics",ei="$session_recording_remote_config",ti="$sesid",ii="$session_is_sampled",ri="$enabled_feature_flags",si="$early_access_features",ni="$feature_flag_details",oi="$stored_person_properties",ai="$stored_group_properties",li="$surveys",ci="$flag_call_reported",ui="$user_state",hi="$client_session_props",di="$capture_rate_limit",pi="$initial_campaign_params",gi="$initial_referrer_info",_i="$initial_person_info",vi="$epp",fi="__POSTHOG_TOOLBAR__",mi="$posthog_cookieless",yi=[qt,Bt,"__cmpns",Gt,"$session_recording_enabled_server_side",Wt,ti,ri,Yt,ui,si,ni,ai,oi,li,ci,hi,di,pi,gi,vi,_i,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function bi(e){return e instanceof Element&&(e.id===fi||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function wi(e){return!!e&&1===e.nodeType}function Ei(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Si(e){return!!e&&3===e.nodeType}function xi(e){return!!e&&11===e.nodeType}function ki(e){return e?T(e).split(/\s+/):[]}function Ii(e){var t=null==o?void 0:o.location.href;return!!(t&&e&&e.some(e=>t.match(e)))}function Pi(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return ki(t)}function Ti(e){return q(e)?null:T(e).split(/(\s+)/).filter(e=>Wi(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Fi(e){var t="";return Li(e)&&!ji(e)&&e.childNodes&&e.childNodes.length&&$t(e.childNodes,function(e){var i;Si(e)&&e.textContent&&(t+=null!==(i=Ti(e.textContent))&&void 0!==i?i:"")}),T(t)}function Ri(e){return L(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var $i=["a","button","form","input","select","textarea","label"];function Oi(e,t){if(L(t))return!0;var i,r=function(e){if(t.some(t=>e.matches(t)))return{v:!0}};for(var s of e)if(i=r(s))return i.v;return!1}function Ai(e){var t=e.parentNode;return!(!t||!wi(t))&&t}var Ci=["next","previous","prev",">","<"],Mi=[".ph-no-rageclick",".ph-no-capture"],Di=e=>!e||Ei(e,"html")||!wi(e),Ni=(e,t)=>{if(!o||Di(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!Ei(s,"body");)if(xi(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Ai(s);if(!n)break;if(t||$i.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var a=o.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Li(e){for(var t=e;t.parentNode&&!Ei(t,"body");t=t.parentNode){var i=Pi(t);if(P(i,"ph-sensitive")||P(i,"ph-no-capture"))return!1}if(P(Pi(e),"ph-include"))return!0;var r=e.type||"";if(j(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";return!j(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 ji(e){return!!(Ei(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Ei(e,"select")||Ei(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Hi="(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})",Ui=new RegExp("^(?:"+Hi+")$"),qi=new RegExp(Hi),Bi="\\d{3}-?\\d{2}-?\\d{4}",Gi=new RegExp("^("+Bi+")$"),Vi=new RegExp("("+Bi+")");function Wi(e,t){if(void 0===t&&(t=!0),q(e))return!1;if(j(e)){if(e=T(e),(t?Ui:qi).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Gi:Vi).test(e))return!1}return!0}function zi(e){var t=Fi(e);return Wi(t=(t+" "+Yi(e)).trim())?t:""}function Yi(e){var t="";return e&&e.childNodes&&e.childNodes.length&&$t(e.childNodes,function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=Fi(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Yi(e)).trim())}catch(s){kt.error("[AutoCapture]",s)}}),t}function Ji(e){return e.replace(/"|\\"/g,'\\"')}function Ki(e){var t=e.attr__class;return t?C(t)?t:ki(t):void 0}class Xi{constructor(e){this.disabled=!1===e;var t=D(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 r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&i-r.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 Zi=e=>{var t=null==d?void 0:d.createElement("a");return L(t)?null:(t.href=e,t)},Qi=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;s<r.length;s++){var n=r[s].split("=");if(n[0]===t){i=n;break}}if(!C(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(a){kt.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},er=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),s=r[0]||"",n=r[1],o=s.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],h=0;h<c.length;h++){var d=c[h].split("=");C(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(c[h]))}var p=l;return null!=a&&(p+="?"+u.join("&")),null!=n&&(p+="#"+n),p},tr=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},ir="$copy_autocapture",rr=It("[AutoCapture]");function sr(e,t){return t.length>e?t.slice(0,e)+"...":t}function nr(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!wi(t));return t}class or{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Xi(e.config.rageclick),this.C=null}get R(){var e,t,i=D(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map(e=>new RegExp(e)),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map(e=>new RegExp(e)),i}F(){if(this.isBrowserSupported()){if(o&&d){var e=e=>{e=e||(null==o?void 0:o.event);try{this.O(e)}catch(pr){rr.error("Failed to capture event",pr)}};if(Ut(d,"submit",e,{capture:!0}),Ut(d,"change",e,{capture:!0}),Ut(d,"click",e,{capture:!0}),this.R.capture_copied_text){var t=e=>{e=e||(null==o?void 0:o.event),this.O(e,ir)};Ut(d,"copy",t,{capture:!0}),Ut(d,"cut",t,{capture:!0})}}}else rr.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({[Vt]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,i=[];return null==(t=this.C)||t.forEach(t=>{var r=null==d?void 0:d.querySelectorAll(t);null==r||r.forEach(r=>{e===r&&i.push(t)})}),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[Vt],r=this.T;if(U(r)&&!V(i)&&!this.instance.M())return!1;var s=null!==(t=this.T)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!s}O(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=Ri(e);Si(r)&&(r=r.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&function(e,t){if(!o||Di(e))return!1;var i,r,s;if(V(t)?(i=!!t&&Mi,r=void 0):(i=null!==(s=null==t?void 0:t.css_selector_ignorelist)&&void 0!==s?s:Mi,r=null==t?void 0:t.content_ignorelist),!1===i)return!1;var{targetElementList:n}=Ni(e,!1);return!function(e,t){if(!1===e||L(e))return!1;var i;if(!0===e)i=Ci;else{if(!C(e))return!1;if(e.length>10)return kt.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map(e=>e.toLowerCase())}return t.some(e=>{var{safeText:t,ariaLabel:r}=e;return i.some(e=>t.includes(e)||r.includes(e))})}(r,n.map(e=>{var t;return{safeText:Fi(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}}))&&!Oi(n,i)}(r,this.instance.config.rageclick)&&this.O(e,"$rageclick");var s=t===ir;if(r&&function(e,t,i,r,s){var n,a,l,c;if(void 0===i&&(i=void 0),!o||Di(e))return!1;if(null!=(n=i)&&n.url_allowlist&&!Ii(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&Ii(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some(e=>t.type===e))return!1}var{parentIsUsefulElement:h,targetElementList:d}=Ni(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(L(i))return!0;var r,s=function(e){if(i.some(t=>e.tagName.toLowerCase()===t))return{v:!0}};for(var n of e)if(r=s(n))return r.v;return!1}(d,i))return!1;if(!Oi(d,null==(c=i)?void 0:c.css_selector_allowlist))return!1;var p=o.getComputedStyle(e);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===t.type)return!0;var g=e.tagName.toLowerCase();switch(g){case"html":return!1;case"form":return(s||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(t.type)>=0;default:return h?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&($i.indexOf(g)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this.R,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:a}=function(e,t){for(var i,r,{e:s,maskAllElementAttributes:n,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],h=e;h.parentNode&&!Ei(h,"body");)xi(h.parentNode)?(u.push(h.parentNode.host),h=h.parentNode.host):(u.push(h.parentNode),h=h.parentNode);var d,p,g,_=[],v={},f=!1,m=!1;if($t(u,e=>{var t=Li(e);"a"===e.tagName.toLowerCase()&&(f=e.getAttribute("href"),f=t&&f&&Wi(f)&&f),P(Pi(e),"ph-no-capture")&&(m=!0),_.push(function(e,t,i,r){var s=e.tagName.toLowerCase(),n={tag_name:s};$i.indexOf(s)>-1&&!i&&("a"===s.toLowerCase()||"button"===s.toLowerCase()?n.$el_text=sr(1024,zi(e)):n.$el_text=sr(1024,Fi(e)));var o=Pi(e);o.length>0&&(n.classes=o.filter(function(e){return""!==e})),$t(e.attributes,function(i){var s;if((!ji(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Wi(i.value)&&(s=i.name,!j(s)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=ki(o).join(" ")),n["attr__"+i.name]=sr(1024,o)}});for(var a=1,l=1,c=e;c=nr(c);)a++,c.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}(e,n,a,l));var i=function(e){if(!Li(e))return{};var t={};return $t(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Wi(r)&&(t[i]=r)}}),t}(e);Ot(v,i)}),m)return{props:{},explicitNoCapture:m};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?_[0].$el_text=zi(e):_[0].$el_text=Fi(e)),f){var y,b;_[0].attr__href=f;var w=null==(y=Zi(f))?void 0:y.host,S=null==o||null==(b=o.location)?void 0:b.host;w&&S&&w!==S&&(d=f)}return{props:Ot({$event_type:s.type,$ce_version:1},c?{}:{$elements:_},{$elements_chain:(g=_,p=g.map(e=>{var t,i,r={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Ki(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Ct(e).filter(e=>{var[t]=e;return 0===t.indexOf("attr__")}).forEach(e=>{var[t,i]=e;return r.attributes[t]=i}),r}),p.map(e=>{var t,i,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var s of(e.attr_class.sort(),e.attr_class))r+="."+s.replace(/"/g,"");var n=E({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),o={};return Ct(n).sort((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)}).forEach(e=>{var[t,i]=e;return o[Ji(t.toString())]=Ji(i.toString())}),(r+=":")+Ct(o).map(e=>{var[t,i]=e;return t+'="'+i+'"'}).join("")}).join(";"))},null!=(i=_[0])&&i.$el_text?{$el_text:null==(r=_[0])?void 0:r.$el_text}:{},d&&"click"===s.type?{$external_click_url:d}:{},v)}}(r,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(a)return!1;var l=this.getElementSelectors(r);if(l&&l.length>0&&(n.$element_selectors=l),t===ir){var c,u=Ti(null==o||null==(c=o.getSelection())?void 0:c.toString()),h=e.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=h}return this.instance.capture(t,n),!0}}}isBrowserSupported(){return M(null==d?void 0:d.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return B(e)&&isFinite(e)&&Math.floor(e)===e});var ar="0123456789abcdef";class lr{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||e<0||t<0||i<0||r<0||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new lr(s)}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]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new lr(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class cr{constructor(){this.A=0,this.j=0,this.D=new dr}generate(){var e=this.generateOrAbort();if(L(e)){this.A=0;var t=this.generateOrAbort();if(L(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 lr.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 ur,hr=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};o&&!L(o.crypto)&&crypto.getRandomValues&&(hr=e=>crypto.getRandomValues(e));class dr{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(hr(this.N),this.U=0),this.N[this.U++]}}var pr,gr=()=>_r().toString(),_r=()=>(ur||(ur=new cr)).generate(),vr="",fr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,mr={H:()=>!!d,B:function(e){kt.error("cookieStore error: "+e)},q:function(e){if(d){try{for(var t=e+"=",i=d.cookie.split(";").filter(e=>e.length),r=0;r<i.length;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(n){}return null}},W:function(e){var t;try{t=JSON.parse(mr.q(e))||{}}catch(i){}return t},G:function(e,t,i,r,s){if(d)try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=d),vr)return vr;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),s="dmn_chk_"+gr();!vr&&r--;){var n=i.slice(r).join("."),o=s+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(s)&&(t.cookie=o+";max-age=0",vr=n)}return vr}(e);if(!i){var r=(s=e.match(fr))?s[0]:"";r!==i&&kt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}var s;return""}(d.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),n="; expires="+l.toUTCString()}s&&(o="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&kt.warn("cookieStore warning: large cookie, len="+c.length),d.cookie=c,c}catch(u){return}},V:function(e,t){if(null!=d&&d.cookie)try{mr.G(e,"",-1,t)}catch(i){return}}},yr=null,br={H:function(){if(!U(yr))return yr;var e=!0;if(L(o))e=!1;else try{var t="__mplssupport__";br.G(t,"xyz"),'"xyz"'!==br.q(t)&&(e=!1),br.V(t)}catch(pr){e=!1}return e||kt.error("localStorage unsupported; falling back to cookie store"),yr=e,e},B:function(e){kt.error("localStorage error: "+e)},q:function(e){try{return null==o?void 0:o.localStorage.getItem(e)}catch(pr){br.B(pr)}return null},W:function(e){try{return JSON.parse(br.q(e))||{}}catch(t){}return null},G:function(e,t){try{null==o||o.localStorage.setItem(e,JSON.stringify(t))}catch(pr){br.B(pr)}},V:function(e){try{null==o||o.localStorage.removeItem(e)}catch(pr){br.B(pr)}}},wr=["$device_id","distinct_id",ti,ii,vi,_i],Er={},Sr={H:function(){return!0},B:function(e){kt.error("memoryStorage error: "+e)},q:function(e){return Er[e]||null},W:function(e){return Er[e]||null},G:function(e,t){Er[e]=t},V:function(e){delete Er[e]}},xr=null,kr={H:function(){if(!U(xr))return xr;if(xr=!0,L(o))xr=!1;else try{var e="__support__";kr.G(e,"xyz"),'"xyz"'!==kr.q(e)&&(xr=!1),kr.V(e)}catch(pr){xr=!1}return xr},B:function(e){kt.error("sessionStorage error: ",e)},q:function(e){try{return null==o?void 0:o.sessionStorage.getItem(e)}catch(pr){kr.B(pr)}return null},W:function(e){try{return JSON.parse(kr.q(e))||null}catch(t){}return null},G:function(e,t){try{null==o||o.sessionStorage.setItem(e,JSON.stringify(t))}catch(pr){kr.B(pr)}},V:function(e){try{null==o||o.sessionStorage.removeItem(e)}catch(pr){kr.B(pr)}}},Ir=((pr={})[pr.PENDING=-1]="PENDING",pr[pr.DENIED=0]="DENIED",pr[pr.GRANTED=1]="GRANTED",pr);class Pr{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?Ir.DENIED:this.K}isOptedOut(){return"always"===this.R.cookieless_mode||this.consent===Ir.DENIED||this.consent===Ir.PENDING&&(this.R.opt_out_capturing_by_default||"on_reject"===this.R.cookieless_mode)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Ir.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 X(e)?Ir.GRANTED:P(Z,e)?Ir.DENIED:Ir.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z="localStorage"===e?br:mr;var t="localStorage"===e?mr:br;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(X(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!Ht([null==h?void 0:h.doNotTrack,null==h?void 0:h.msDoNotTrack,m.doNotTrack],e=>X(e))}}var Tr=It("[Dead Clicks]"),Fr=()=>!0,Rr=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Xt)),r=e.instance.config.capture_dead_clicks;return V(r)?r:!!D(r)||i};class $r{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Xt]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it(()=>{this.et()})}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",t=>{t?Tr.error("failed to load script",t):e()})}et(){var e;if(d){if(!this.tt&&null!=(e=m.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=D(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=m.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(d),Tr.info("starting...")}}else Tr.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Tr.info("stopping..."))}}var Or=It("[ExceptionAutocapture]");class Ar{constructor(e){var t,i,r;this.rt=()=>{var e;if(o&&this.isEnabled&&null!=(e=m.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=m.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=m.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=m.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=t(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=i(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=r(this.captureException.bind(this)))}catch(pr){Or.error("failed to start",pr),this.ut()}}},this._instance=e,this.ht=!(null==(t=this._instance.persistence)||!t.props[zt]),this.dt=new ee({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,h:Or}),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 D(e)?t=E({},t,e):(L(e)?this.ht:e)&&(t=E({},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?(Or.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",t=>{if(t)return Or.error("failed to load script",t);e()})}ut(){var e,t,i;null==(e=this.st)||e.call(this),this.st=void 0,null==(t=this.nt)||t.call(this),this.nt=void 0,null==(i=this.ot)||i.call(this),this.ot=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[zt]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var t,i,r=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this.dt.consumeRateLimit(r)?Or.info("Skipping exception capture because of client rate limiting.",{exception:r}):this._instance.exceptions.sendExceptionEvent(e)}}function Cr(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],s=i(r);return M(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=s,()=>{e[t]=r}}catch(n){return()=>{}}}class Mr{constructor(e){var t;this._instance=e,this.ct=(null==o||null==(t=o.location)?void 0:t.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(kt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,kt.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(o&&o.history){var i=this;null!=(e=o.history.pushState)&&e.__posthog_wrapped__||Cr(o.history,"pushState",e=>function(t,r,s){e.call(this,t,r,s),i._t("pushState")}),null!=(t=o.history.replaceState)&&t.__posthog_wrapped__||Cr(o.history,"replaceState",e=>function(t,r,s){e.call(this,t,r,s),i._t("replaceState")}),this.bt()}}_t(e){try{var t,i=null==o||null==(t=o.location)?void 0:t.pathname;if(!i)return;i!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=i}catch(pr){kt.error("Error capturing "+e+" pageview",pr)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};Ut(o,"popstate",e),this.ft=()=>{o&&o.removeEventListener("popstate",e)}}}}var Dr=It("[SegmentIntegration]"),Nr="posthog-js";function Lr(e,t){var{organization:i,projectId:r,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=void 0===t?{}:t;return t=>{var a,l,c,u,h;if("*"!==n&&!n.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var d=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=d,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=(null==(a=t.exception)?void 0:a.values)||[],g=p.map(e=>E({},e,{stacktrace:e.stacktrace?E({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>E({},e,{platform:"web:javascript"}))}):void 0})),_={$exception_message:(null==(l=p[0])?void 0:l.value)||t.message,$exception_type:null==(c=p[0])?void 0:c.type,$exception_level:t.level,$exception_list:g,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(u=p[0])?void 0:u.value)||t.message,$sentry_exception_type:null==(h=p[0])?void 0:h.type,$sentry_tags:t.tags};return i&&r&&(_.$sentry_url=(s||"https://sentry.io/organizations/")+i+"/issues/?project="+r+"&query="+t.event_id),o&&e.exceptions.sendExceptionEvent(_),t}}class jr{constructor(e,t,i,r,s,n){this.name=Nr,this.setupOnce=function(o){o(Lr(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}var Hr=null!=o&&o.location?tr(o.location.hash,"__posthog")||tr(location.hash,"state"):null,Ur="_postHogToolbarParams",qr=It("[Toolbar]"),Br=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Br||{});class Gr{constructor(e){this.instance=e}yt(e){m.ph_toolbar_state=e}wt(){var e;return null!==(e=m.ph_toolbar_state)&&void 0!==e?e:Br.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),!o||!d)return!1;e=null!=e?e:o.location,i=null!=i?i:o.history;try{if(!t){try{o.localStorage.setItem("test","test"),o.localStorage.removeItem("test")}catch(pr){return!1}t=null==o?void 0:o.localStorage}var r,s=Hr||tr(e.hash,"__posthog")||tr(e.hash,"state"),n=s?Mt(()=>JSON.parse(atob(decodeURIComponent(s))))||Mt(()=>JSON.parse(decodeURIComponent(s))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(Ur)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(pr){return!1}}xt(e){var t=m.ph_load_toolbar||m.ph_load_editor;!q(t)&&M(t)?t(e,this.instance):qr.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==d||!d.getElementById(fi));if(!o||t)return!1;var i="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=E({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(o.localStorage.setItem(Ur,JSON.stringify(E({},r,{source:void 0}))),this.wt()===Br.LOADED)this.xt(r);else if(this.wt()===Br.UNINITIALIZED){var s;this.yt(Br.LOADING),null==(s=m.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this.instance,"toolbar",e=>{if(e)return qr.error("[Toolbar] Failed to load",e),void this.yt(Br.UNINITIALIZED);this.yt(Br.LOADED),this.xt(r)}),Ut(o,"turbolinks:load",()=>{this.yt(Br.UNINITIALIZED),this.loadToolbar(r)})}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var Vr=It("[TracingHeaders]");class Wr{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var e,t;L(this.$t)&&(null==(e=m.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),L(this.St)&&(null==(t=m.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",t=>{if(t)return Vr.error("failed to load script",t);e()})}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):(null==(e=this.$t)||e.call(this),null==(t=this.St)||t.call(this),this.$t=void 0,this.St=void 0)}}var zr="https?://(.*)",Yr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Jr=At(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Yr),Kr="<masked>",Xr=["li_fat_id"];function Zr(e,t,i){if(!d)return{};var r,s=t?At([],Yr,i||[]):[],n=Qr(er(d.URL,s,Kr),e),o=(r={},$t(Xr,function(e){var t=mr.q(e);r[e]=t||null}),r);return Ot(o,n)}function Qr(e,t){var i=Jr.concat(t||[]),r={};return $t(i,function(t){var i=Qi(e,t);r[t]=i||null}),r}function es(e){var t,i=(t=e)?0===t.search(zr+"google.([^/?]*)")?"google":0===t.search(zr+"bing.com")?"bing":0===t.search(zr+"yahoo.com")?"yahoo":0===t.search(zr+"duckduckgo.com")?"duckduckgo":null:null,r="yahoo"!=i?"q":"p",s={};if(!U(i)){s.$search_engine=i;var n=d?Qi(d.referrer,r):"";n.length&&(s.ph_keyword=n)}return s}function ts(){return navigator.language||navigator.userLanguage}function is(){return(null==d?void 0:d.referrer)||"$direct"}function rs(e,t){var i=e?At([],Yr,t||[]):[],r=null==p?void 0:p.href.substring(0,1e3);return{r:is().substring(0,1e3),u:r?er(r,i,Kr):void 0}}function ss(e){var t,{r:i,u:r}=e,s={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=Zi(i))?void 0:t.host};if(r){s.$current_url=r;var n=Zi(r);s.$host=null==n?void 0:n.host,s.$pathname=null==n?void 0:n.pathname;var o=Qr(r);Ot(s,o)}if(i){var a=es(i);Ot(s,a)}return s}function ns(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(pr){return}}function os(){try{return(new Date).getTimezoneOffset()}catch(pr){return}}var as=It("[Web Vitals]"),ls=9e5;class cs{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),0!==this.N.metrics.length&&(this._instance.capture("$web_vitals",this.N.metrics.reduce((e,t)=>E({},e,{["$web_vitals_"+t.name+"_event"]:E({},t),["$web_vitals_"+t.name+"_value"]:t.value}),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=e=>{var t,i=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(L(i))as.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.Ct();L(r)||(q(null==e?void 0:e.name)||q(null==e?void 0:e.value)?as.error("Invalid metric received",e):this.Rt&&e.value>=this.Rt?as.error("Ignoring metric with value >= "+this.Rt,e):(this.N.url!==r&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),L(this.N.url)&&(this.N.url=r),this.N.firstMetricTimestamp=L(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.N.metrics.push(E({},e,{$current_url:r,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var e,t,i,r,s=m.__PosthogExtensions__;L(s)||L(s.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),e&&t&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&e(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.It.bind(this)),this.P=!0):as.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!(null==(t=this._instance.persistence)||!t.props[Kt]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=D(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return q(i)?(null==(t=this._instance.persistence)?void 0:t.props[Qt])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return null!=e&&e}get Rt(){var e=D(this._instance.config.capture_performance)&&B(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:ls;return 0<e&&e<=6e4?ls:e}get isEnabled(){var e=null==p?void 0:p.protocol;if("http:"!==e&&"https:"!==e)return as.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:V(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return V(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(as.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=D(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=D(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Kt]:t}),this._instance.persistence.register({[Qt]:i})),this.kt=t,this.startIfEnabled()}it(e){var t,i;if(null!=(t=m.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks)e();else{var r=this.useAttribution?"web-vitals-with-attribution":"web-vitals";null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,r,t=>{t?as.error("failed to load script",t):e()})}}Ct(){var e=o?o.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,i=this._instance.config.custom_personal_data_properties,r=t?At([],Yr,i||[]):[];return er(e,r,Kr)}as.error("Could not determine current URL")}}var us=It("[Heatmaps]");function hs(e){return D(e)&&"clientX"in e&&"clientY"in e&&B(e.clientX)&&B(e.clientY)}class ds{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!(null==(t=this.instance.persistence)||!t.props[Wt]),this.rageclicks=new Xi(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return D(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 q(this.instance.config.capture_heatmaps)?q(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.P)return;us.info("starting..."),this.Ot(),this.Mt()}else{var e;clearInterval(null!==(e=this.Ft)&&void 0!==e?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Wt]: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="visible"===(null==d?void 0:d.visibilityState)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){o&&d&&(this.Nt=this.Lt.bind(this),Ut(o,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||(null==o?void 0:o.event)),Ut(d,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||(null==o?void 0:o.event)),Ut(d,"mousemove",this.zt,{capture:!0}),this.Bt=new $r(this.instance,Fr,this.jt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Mt.bind(this),Ut(d,"visibilitychange",this.qt),this.P=!0)}At(){var e;o&&d&&(this.Nt&&o.removeEventListener("beforeunload",this.Nt),this.Ut&&d.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&d.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&d.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),null==(e=this.Bt)||e.stop(),this.P=!1)}Gt(e,t){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var r=e;r&&wi(r)&&!Ei(r,"body");){if(r===i)return!1;if(P(t,null==o?void 0:o.getComputedStyle(r).position))return!0;r=Ai(r)}return!1}(Ri(e),["fixed","sticky"],s);return{x:e.clientX+(n?0:r),y:e.clientY+(n?0:i),target_fixed:n,type:t}}Dt(e,t){var i;if(void 0===t&&(t="click"),!bi(e.target)&&hs(e)){var r=this.Gt(e,t);null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this.Vt(E({},r,{type:"rageclick"})),this.Vt(r)}}Ht(e){!bi(e.target)&&hs(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout(()=>{this.Vt(this.Gt(e,"mousemove"))},500))}Vt(e){if(o){var t=o.location.href,i=this.instance.config.mask_personal_data_properties,r=this.instance.config.custom_personal_data_properties,s=i?At([],Yr,r||[]):[],n=er(t,s,Kr);this.N=this.N||{},this.N[n]||(this.N[n]=[]),this.N[n].push(e)}}Lt(){this.N&&!N(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class ps{constructor(e){this.Jt=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(kt.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this.Jt)}destroy(){var e;null==(e=this.Xt)||e.call(this),this.Xt=void 0}doPageView(e,t){var i,r=this.Qt(e,t);return this.Kt={pathname:null!==(i=null==o?void 0:o.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.Qt(e,null==(t=this.Kt)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this.Kt)?void 0:e.pageViewId}}Qt(e,t){var i=this.Kt;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=s;if(!(L(n)||L(o)||L(a)||L(l)||L(c)||L(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var h=n<=1?1:Q(o/n,0,1,kt),d=n<=1?1:Q(a/n,0,1,kt),p=l<=1?1:Q(c/l,0,1,kt),g=l<=1?1:Q(u/l,0,1,kt);r=Ot(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:g})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var gs=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),_s=Uint8Array,vs=Uint16Array,fs=Uint32Array,ms=new _s([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]),ys=new _s([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]),bs=new _s([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ws=function(e,t){for(var i=new vs(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var s=new fs(i[30]);for(r=1;r<30;++r)for(var n=i[r];n<i[r+1];++n)s[n]=n-i[r]<<5|r;return[i,s]},Es=ws(ms,2),Ss=Es[0],xs=Es[1];Ss[28]=258,xs[258]=28;for(var ks=ws(ys,0)[1],Is=new vs(32768),Ps=0;Ps<32768;++Ps){var Ts=(43690&Ps)>>>1|(21845&Ps)<<1;Ts=(61680&(Ts=(52428&Ts)>>>2|(13107&Ts)<<2))>>>4|(3855&Ts)<<4,Is[Ps]=((65280&Ts)>>>8|(255&Ts)<<8)>>>1}var Fs=function(e,t,i){for(var r=e.length,s=0,n=new vs(t);s<r;++s)++n[e[s]-1];var o,a=new vs(t);for(s=0;s<t;++s)a[s]=a[s-1]+n[s-1]<<1;for(o=new vs(r),s=0;s<r;++s)o[s]=Is[a[e[s]-1]++]>>>15-e[s];return o},Rs=new _s(288);for(Ps=0;Ps<144;++Ps)Rs[Ps]=8;for(Ps=144;Ps<256;++Ps)Rs[Ps]=9;for(Ps=256;Ps<280;++Ps)Rs[Ps]=7;for(Ps=280;Ps<288;++Ps)Rs[Ps]=8;var $s=new _s(32);for(Ps=0;Ps<32;++Ps)$s[Ps]=5;var Os=Fs(Rs,9),As=Fs($s,5),Cs=function(e){return(e/8|0)+(7&e&&1)},Ms=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof vs?vs:e instanceof fs?fs:_s)(i-t);return r.set(e.subarray(t,i)),r},Ds=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>>8},Ns=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>>8,e[r+2]|=i>>>16},Ls=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return[new _s(0),0];if(1==s){var o=new _s(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,h=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=s-1;)a=i[i[c].f<i[h].f?c++:h++],l=i[c!=u&&i[c].f<i[h].f?c++:h++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var d=n[0].s;for(r=1;r<s;++r)n[r].s>d&&(d=n[r].s);var p=new vs(d+1),g=js(i[u-1],p,0);if(g>t){r=0;var _=0,v=g-t,f=1<<v;for(n.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<s;++r){var m=n[r].s;if(!(p[m]>t))break;_+=f-(1<<g-p[m]),p[m]=t}for(_>>>=v;_>0;){var y=n[r].s;p[y]<t?_-=1<<t-p[y]++-1:++r}for(;r>=0&&_;--r){var b=n[r].s;p[b]==t&&(--p[b],++_)}g=t}return[new _s(p),g]},js=function(e,t,i){return-1==e.s?Math.max(js(e.l,t,i+1),js(e.r,t,i+1)):t[e.s]=i},Hs=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new vs(++t),r=0,s=e[0],n=1,o=function(e){i[r++]=e},a=1;a<=t;++a)if(e[a]==s&&a!=t)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=e[a]}return[i.subarray(0,r),t]},Us=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},qs=function(e,t,i){var r=i.length,s=Cs(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var n=0;n<r;++n)e[s+n+4]=i[n];return 8*(s+4+r)},Bs=function(e,t,i,r,s,n,o,a,l,c,u){Ds(t,u++,i),++s[256];for(var h=Ls(s,15),d=h[0],p=h[1],g=Ls(n,15),_=g[0],v=g[1],f=Hs(d),m=f[0],y=f[1],b=Hs(_),w=b[0],E=b[1],S=new vs(19),x=0;x<m.length;++x)S[31&m[x]]++;for(x=0;x<w.length;++x)S[31&w[x]]++;for(var k=Ls(S,7),I=k[0],P=k[1],T=19;T>4&&!I[bs[T-1]];--T);var F,R,$,O,A=c+5<<3,C=Us(s,Rs)+Us(n,$s)+o,M=Us(s,d)+Us(n,_)+o+14+3*T+Us(S,I)+(2*S[16]+3*S[17]+7*S[18]);if(A<=C&&A<=M)return qs(t,u,e.subarray(l,l+c));if(Ds(t,u,1+(M<C)),u+=2,M<C){F=Fs(d,p),R=d,$=Fs(_,v),O=_;var D=Fs(I,P);for(Ds(t,u,y-257),Ds(t,u+5,E-1),Ds(t,u+10,T-4),u+=14,x=0;x<T;++x)Ds(t,u+3*x,I[bs[x]]);u+=3*T;for(var N=[m,w],L=0;L<2;++L){var j=N[L];for(x=0;x<j.length;++x){var H=31&j[x];Ds(t,u,D[H]),u+=I[H],H>15&&(Ds(t,u,j[x]>>>5&127),u+=j[x]>>>12)}}}else F=Os,R=Rs,$=As,O=$s;for(x=0;x<a;++x)if(r[x]>255){H=r[x]>>>18&31,Ns(t,u,F[H+257]),u+=R[H+257],H>7&&(Ds(t,u,r[x]>>>23&31),u+=ms[H]);var U=31&r[x];Ns(t,u,$[U]),u+=O[U],U>3&&(Ns(t,u,r[x]>>>5&8191),u+=ys[U])}else Ns(t,u,F[r[x]]),u+=R[r[x]];return Ns(t,u,F[256]),u+R[256]},Gs=new fs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Vs=function(){for(var e=new fs(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Ws=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};var zs=!!_||!!g,Ys="text/plain",Js=function(e,t,i){var r;void 0===i&&(i=!0);var[s,n]=e.split("?"),o=E({},t),a=null!==(r=null==n?void 0:n.split("&").map(e=>{var t,[r,s]=e.split("="),n=i&&null!==(t=o[r])&&void 0!==t?t:s;return delete o[r],r+"="+n}))&&void 0!==r?r:[],l=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return $t(e,function(e,t){L(e)||L(t)||"undefined"===t||(i=encodeURIComponent(e instanceof File?e.name:e.toString()),r=encodeURIComponent(t),s[s.length]=r+"="+i)}),s.join(t)}(o);return l&&a.push(l),s+"?"+a.join("&")},Ks=(e,t)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,t),Xs=e=>{var t,{data:i,compression:r}=e;if(i){if(r===gs.GZipJS){var s=function(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=Vs[255&i^t[r]]^i>>>8;e=i},d:function(){return 4294967295^e}}}(),r=e.length;i.p(e);var s,n=function(e,t,i){return function(e,t,i,r){var s=e.length,n=new _s(r+s+5*(1+Math.floor(s/7e3))+8),o=n.subarray(r,n.length-8),a=0;if(!t||s<8)for(var l=0;l<=s;l+=65535){var c=l+65535;c<s?a=qs(o,a,e.subarray(l,c)):(o[l]=!0,a=qs(o,a,e.subarray(l,s)))}else{for(var u=Gs[t-1],h=u>>>13,d=8191&u,p=(1<<i)-1,g=new vs(32768),_=new vs(p+1),v=Math.ceil(i/3),f=2*v,m=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<f)&p},y=new fs(25e3),b=new vs(288),w=new vs(32),E=0,S=0,x=(l=0,0),k=0,I=0;l<s;++l){var P=m(l),T=32767&l,F=_[P];if(g[T]=F,_[P]=T,k<=l){var R=s-l;if((E>7e3||x>24576)&&R>423){a=Bs(e,o,0,y,b,w,S,x,I,l-I,a),x=E=S=0,I=l;for(var $=0;$<286;++$)b[$]=0;for($=0;$<30;++$)w[$]=0}var O=2,A=0,C=d,M=T-F&32767;if(R>2&&P==m(l-M))for(var D=Math.min(h,R)-1,N=Math.min(32767,l),L=Math.min(258,R);M<=N&&--C&&T!=F;){if(e[l+O]==e[l+O-M]){for(var j=0;j<L&&e[l+j]==e[l+j-M];++j);if(j>O){if(O=j,A=M,j>D)break;var H=Math.min(M,j-2),U=0;for($=0;$<H;++$){var q=l-M+$+32768&32767,B=q-g[q]+32768&32767;B>U&&(U=B,F=q)}}}M+=(T=F)-(F=g[T])+32768&32767}if(A){y[x++]=268435456|xs[O]<<18|ks[A];var G=31&xs[O],V=31&ks[A];S+=ms[G]+ys[V],++b[257+G],++w[V],k=l+O,++E}else y[x++]=e[l],++b[e[l]]}}a=Bs(e,o,!0,y,b,w,S,x,I,l-I,a)}return Ms(n,0,r+Cs(a)+8)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i)}(e,t,10+((s=t).filename&&s.filename.length+1||0)),o=n.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Ws(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}}(n,t),Ws(n,o-8,i.d()),Ws(n,o-4,r),n}(function(e){var t=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var i=new _s(e.length+(e.length>>>1)),r=0,s=function(e){i[r++]=e},n=0;n<t;++n){if(r+5>i.length){var o=new _s(r+8+(t-n<<1));o.set(i),i=o}var a=e.charCodeAt(n);a<128?s(a):a<2048?(s(192|a>>>6),s(128|63&a)):a>55295&&a<57344?(s(240|(a=65536+(1047552&a)|1023&e.charCodeAt(++n))>>>18),s(128|a>>>12&63),s(128|a>>>6&63),s(128|63&a)):(s(224|a>>>12),s(128|a>>>6&63),s(128|63&a))}return Ms(i,0,r)}(Ks(i)),{mtime:0}),n=new Blob([s],{type:Ys});return{contentType:Ys,body:n,estimatedSize:n.size}}if(r===gs.Base64){var o=function(e){var t,i,r,s,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,c="",u=[];if(!e)return e;e=function(e){var t,i,r,s,n="";for(t=i=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s<r;s++){var o=e.charCodeAt(s),a=null;o<128?i++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),U(a)||(i>t&&(n+=e.substring(t,i)),n+=a,t=i=s+1)}return i>t&&(n+=e.substring(t,e.length)),n}(e);do{t=(n=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=n>>12&63,r=n>>6&63,s=63&n,u[l++]=o.charAt(t)+o.charAt(i)+o.charAt(r)+o.charAt(s)}while(a<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(Ks(i)),a=(t=o,"data="+encodeURIComponent("string"==typeof t?t:Ks(t)));return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var l=Ks(i);return{contentType:"application/json",body:l,estimatedSize:new Blob([l]).size}}},Zs=[];g&&Zs.push({transport:"fetch",method:e=>{var t,i,{contentType:r,body:s,estimatedSize:n}=null!==(t=Xs(e))&&void 0!==t?t:{},o=new Headers;$t(e.headers,function(e,t){o.append(t,e)}),r&&o.append("Content-Type",r);var a=e.url,l=null;if(v){var c=new v;l={signal:c.signal,timeout:setTimeout(()=>c.abort(),e.timeout)}}g(a,E({method:(null==e?void 0:e.method)||"GET",headers:o,keepalive:"POST"===e.method&&(n||0)<52428.8,body:s,signal:null==(i=l)?void 0:i.signal},e.fetchOptions)).then(t=>t.text().then(i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(s){kt.error(s)}null==e.callback||e.callback(r)})).catch(t=>{kt.error(t),null==e.callback||e.callback({statusCode:0,text:t})}).finally(()=>l?clearTimeout(l.timeout):null)}}),_&&Zs.push({transport:"XHR",method:e=>{var t,i=new _;i.open(e.method||"GET",e.url,!0);var{contentType:r,body:s}=null!==(t=Xs(e))&&void 0!==t?t:{};$t(e.headers,function(e,t){i.setRequestHeader(t,e)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout),e.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(r){}null==e.callback||e.callback(t)}},i.send(s)}}),null!=h&&h.sendBeacon&&Zs.push({transport:"sendBeacon",method:e=>{var t=Js(e.url,{beacon:"1"});try{var i,{contentType:r,body:s}=null!==(i=Xs(e))&&void 0!==i?i:{},n="string"==typeof s?new Blob([s],{type:r}):s;h.sendBeacon(t,n)}catch(o){}}});var Qs=function(e,t){if(!function(){return!0}())return!1;try{return new RegExp(t).test(e)}catch(i){return!1}};function en(e,t,i){return Ks({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var tn={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>Qs(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!Qs(t,e))),icontains:(e,t)=>t.map(rn).some(t=>e.map(rn).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(rn).every(t=>e.map(rn).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})},rn=e=>e.toLowerCase();function sn(e,t){return!e||Object.entries(e).every(e=>{var[i,r]=e,s=null==t?void 0:t[i];if(L(s)||U(s))return!1;var n=[String(s)],o=tn[r.operator];return!!o&&o(r.values,n)})}var nn=It("[Error tracking]");class on{constructor(e){var t,i;this.Zt=[],this.ti=new tt([new pt,new St,new _t,new gt,new wt,new bt,new ft,new Et],function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return function(t,r){void 0===r&&(r=0);for(var s=[],n=t.split("\n"),o=r;o<n.length;o++){var a=n[o];if(!(a.length>1024)){var l=dt.test(a)?a.replace(dt,"$1"):a;if(!l.match(/\S*Error: /)){for(var c of i){var u=c(l,e);if(u){s.push(u);break}}if(s.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return E({},e,{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||it});var i})}(s)}}("web:javascript",lt,ht)),this._instance=e,this.Zt=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Yt))&&void 0!==t?t:[]}onRemoteConfig(e){var t,i,r,s=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this.Zt=s,this._instance.persistence&&this._instance.persistence.register({[Yt]:this.Zt,[Jt]:n})}get ii(){var e,t=!!this._instance.get_property(Jt),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void nn.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void nn.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void nn.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(0===e.length)return!1;var t=e.reduce((e,t)=>{var{type:i,value:r}=t;return j(i)&&i.length>0&&e.$exception_types.push(i),j(r)&&r.length>0&&e.$exception_values.push(r),e},{$exception_types:[],$exception_values:[]});return this.Zt.some(e=>{var i=e.values.map(e=>{var i,r=tn[e.operator],s=C(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}si(e){return e.flatMap(e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]}).some(e=>e.filename&&e.filename.startsWith("chrome-extension://"))}ni(e){if(e.length>0){var t,i,r,s,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=n[n.length-1];return null!==(r=null==o||null==(s=o.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}ei(e){return!q(e)&&C(e)}}var an=It("[FeatureFlags]"),ln=It("[FeatureFlags]",{debugEnabled:!0}),cn="$active_feature_flags",un="$override_feature_flags",hn="$feature_flag_payloads",dn="$override_feature_flag_payloads",pn="$feature_flag_request_id",gn="$feature_flag_evaluated_at",_n=e=>{var t={};for(var[i,r]of Ct(e||{}))r&&(t[i]=r);return t},vn=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class fn{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=null!==(e=this._instance.config.evaluation_contexts)&&void 0!==e?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(an.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),null!=t&&t.length?t.filter(e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||an.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}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(ni),t=this._instance.get_property(un),i=this._instance.get_property(dn);if(!i&&!t)return e||{};var r=Ot({},e||{}),s=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(var n of s){var o,a,l=r[n],c=null==t?void 0:t[n],u=L(c)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!c,h=L(c)?l.variant:"string"==typeof c?c:void 0,d=null==i?void 0:i[n],p=E({},l,{enabled:u,variant:u?null!=h?h:null==l?void 0:l.variant:void 0});u!==(null==l?void 0:l.enabled)&&(p.original_enabled=null==l?void 0:l.enabled),h!==(null==l?void 0:l.variant)&&(p.original_variant=null==l?void 0:l.variant),d&&(p.metadata=E({},null==l?void 0:l.metadata,{payload:d,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[n]=p}return this.oi||(an.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:r}),this.oi=!0),r}getFlagVariants(){var e=this._instance.get_property(ri),t=this._instance.get_property(un);if(!t)return e||{};for(var i=Ot({},e),r=Object.keys(t),s=0;s<r.length;s++)i[r[s]]=t[r[s]];return this.oi||(an.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this.oi=!0),i}getFlagPayloads(){var e=this._instance.get_property(hn),t=this._instance.get_property(dn);if(!t)return e||{};for(var i=Ot({},e||{}),r=Object.keys(t),s=0;s<r.length;s++)i[r[s]]=t[r[s]];return this.oi||(an.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,r=this._instance.get_property("$device_id"),s={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:E({},(null==(t=this._instance.persistence)?void 0:t.get_initial_props())||{},this._instance.get_property(oi)||{}),group_properties:this._instance.get_property(ai)};U(r)||L(r)||(s.$device_id=r),(null!=e&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.pi()&&(s.evaluation_contexts=this.fi());var n=this._instance.config.__preview_remote_config,o=n?"/flags/?v=2":"/flags/?v=2&config=true",a=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",l=this._instance.requestRouter.endpointFor("flags",o+a);n&&(s.timezone=ns()),this.li=!0,this._instance._send_request({method:"POST",url:l,data:s,compression:this._instance.config.disable_compression?void 0:gs.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r=!0;if(200===e.statusCode&&(this.hi||(this.$anon_distinct_id=void 0),r=!1),this.li=!1,this.di||(this.di=!0,this._instance.wi(null!==(i=e.json)&&void 0!==i?i:{})),!s.disable_flags||this.hi)if(this.vi=!r,e.json&&null!=(t=e.json.quotaLimited)&&t.includes(vn.FeatureFlags))an.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 n;s.disable_flags||this.receivedFeatureFlags(null!==(n=e.json)&&void 0!==n?n:{},r),this.hi&&(this.hi=!1,this.mi())}}})}}getFeatureFlag(e,t){var i;if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlagResult(e,t);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}an.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 null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants(),r=e in i,s=i[e],n=this.getFlagPayloads()[e],o=String(s),a=this._instance.get_property(pn)||void 0,l=this._instance.get_property(gn)||void 0,c=this._instance.get_property(ci)||{};if((t.send_event||!("send_event"in t))&&(!(e in c)||!c[e].includes(o))){var u,h,d,p,g,_,v,f,m;C(c[e])?c[e].push(o):c[e]=[o],null==(u=this._instance.persistence)||u.register({[ci]:c});var y=this.getFeatureFlagDetails(e),b={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(h=this._instance.config.bootstrap)||null==(h=h.featureFlags)?void 0:h[e])||null,$feature_flag_bootstrapped_payload:(null==(d=this._instance.config.bootstrap)||null==(d=d.featureFlagPayloads)?void 0:d[e])||null,$used_bootstrap_value:!this.vi};L(null==y||null==(p=y.metadata)?void 0:p.version)||(b.$feature_flag_version=y.metadata.version);var w,E=null!==(g=null==y||null==(_=y.reason)?void 0:_.description)&&void 0!==g?g:null==y||null==(v=y.reason)?void 0:v.code;E&&(b.$feature_flag_reason=E),null!=y&&null!=(f=y.metadata)&&f.id&&(b.$feature_flag_id=y.metadata.id),L(null==y?void 0:y.original_variant)&&L(null==y?void 0:y.original_enabled)||(b.$feature_flag_original_response=L(y.original_variant)?y.original_enabled:y.original_variant),null!=y&&null!=(m=y.metadata)&&m.original_payload&&(b.$feature_flag_original_payload=null==y||null==(w=y.metadata)?void 0:w.original_payload),this._instance.capture("$feature_flag_called",b)}if(r){var S=n;if(!L(n))try{S=JSON.parse(n)}catch(x){}return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:S}}}else an.warn('getFeatureFlagResult for key "'+e+"\" failed. Feature flags didn't load in time.")}getRemoteConfigPayload(e,t){var i=this._instance.config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.pi()&&(r.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:r,compression:this._instance.config.disable_compression?void 0:gs.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==s?void 0:s[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return L(i)?void 0:!!i}an.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(),r=this.getFlagPayloads(),s=this.getFlagsWithDetails();!function(e,t,i,r,s){void 0===i&&(i={}),void 0===r&&(r={}),void 0===s&&(s={});var n=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map(e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]})),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter(e=>t[e].enabled).filter(e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload}).map(e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]}))):an.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e),o=n.flags,a=n.featureFlags,l=n.featureFlagPayloads;if(a){var c=e.requestId,u=e.evaluatedAt;if(C(a)){an.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var h={};if(a)for(var d=0;d<a.length;d++)h[a[d]]=!0;t&&t.register({[cn]:a,[ri]:h})}else{var p=a,g=l,_=o;if(e.errorsWhileComputingFlags)if(o){var v=new Set(Object.keys(o).filter(e=>{var t;return!(null!=(t=o[e])&&t.failed)}));p=E({},i,Object.fromEntries(Object.entries(p).filter(e=>{var[t]=e;return v.has(t)}))),g=E({},r,Object.fromEntries(Object.entries(g||{}).filter(e=>{var[t]=e;return v.has(t)}))),_=E({},s,Object.fromEntries(Object.entries(_||{}).filter(e=>{var[t]=e;return v.has(t)})))}else p=E({},i,p),g=E({},r,g),_=E({},s,_);t&&t.register(E({[cn]:Object.keys(_n(p)),[ri]:p||{},[hn]:g||{},[ni]:_||{}},c?{[pn]:c}:{},u?{[gn]:u}:{}))}}}(e,this._instance.persistence,i,r,s),this.xi(t)}}override(e,t){void 0===t&&(t=!1),an.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return an.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(un),this._instance.persistence.unregister(dn),this.xi(),ln.info("All overrides cleared");if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this.oi=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this._instance.persistence.unregister(un),ln.info("Flag overrides cleared");else if(i.flags){if(C(i.flags)){for(var r={},s=0;s<i.flags.length;s++)r[i.flags[s]]=!0;this._instance.persistence.register({[un]:r})}else this._instance.persistence.register({[un]:i.flags});ln.info("Flag overrides set",{flags:i.flags})}return"payloads"in i&&(!1===i.payloads?(this._instance.persistence.unregister(dn),ln.info("Payload overrides cleared")):i.payloads&&(this._instance.persistence.register({[dn]:i.payloads}),ln.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 r,s=(this._instance.get_property(si)||[]).find(t=>t.flagKey===e),n={["$feature_enrollment/"+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:n};s&&(o.$early_access_feature_name=s.name),i&&(o.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=E({},this.getFlagVariants(),{[e]:t});null==(r=this._instance.persistence)||r.register({[cn]:Object.keys(_n(a)),[ri]:a}),this.xi()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._instance.get_property(si),s=i?"&"+i.map(e=>"stage="+e).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+s),method:"GET",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._instance.persistence)||i.unregister(si),null==(r=this._instance.persistence)||r.register({[si]:s}),e(s)}}})}Ei(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,i)=>(e[i]=t[i],e),{})}}xi(e){var{flags:t,flagVariants:i}=this.Ei();this.featureFlagEventHandlers.forEach(r=>r(t,i,{errorsLoading:e}))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._instance.get_property(oi)||{};this._instance.register({[oi]:E({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(oi)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._instance.get_property(ai)||{};0!==Object.keys(i).length&&Object.keys(i).forEach(t=>{i[t]=E({},i[t],e[t]),delete e[t]}),this._instance.register({[ai]:E({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(ai)||{};this._instance.register({[ai]:E({},t,{[e]:{}})})}else this._instance.unregister(ai)}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 mn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class yn{constructor(e,t){var i,r;this.R=e,this.props={},this.$i=!1,this.Si=(r="",(i=e).token&&(r=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+r+"_posthog"),this.Y=this.ki(e),this.load(),e.debug&&kt.info("Persistence loaded",e.persistence,E({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.Pi}ki(e){-1===mn.indexOf(e.persistence.toLowerCase())&&(kt.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=function(e){void 0===e&&(e=[]);var t=[...wr,...e];return E({},br,{W:function(e){try{var t={};try{t=mr.W(e)||{}}catch(r){}var i=Ot(t,JSON.parse(br.q(e)||"{}"));return br.G(e,i),i}catch(r){}return null},G:function(e,i,r,s,n,o){try{br.G(e,i,void 0,void 0,o);var a={};t.forEach(e=>{i[e]&&(a[e]=i[e])}),Object.keys(a).length&&mr.G(e,a,r,s,n,o)}catch(l){br.B(l)}},V:function(e,t){try{null==o||o.localStorage.removeItem(e),mr.V(e,t)}catch(pr){br.B(pr)}}})}(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return"localstorage"===i&&br.H()?br:"localstorage+cookie"===i&&t.H()?t:"sessionstorage"===i&&kr.H()?kr:"memory"===i?Sr:"cookie"===i?mr:t.H()?t:mr}properties(){var e={};return $t(this.props,function(t,i){if(i===ri&&D(t))for(var r=Object.keys(t),s=0;s<r.length;s++)e["$feature/"+r[s]]=t[r[s]];else o=i,a=!1,(U(n=yi)?a:u&&n.indexOf===u?-1!=n.indexOf(o):($t(n,function(e){if(a||(a=e===o))return Ft}),a))||(e[i]=t);var n,o,a}),e}load(){if(!this.Pi){var e=this.Y.W(this.Si);e&&(this.props=Ot({},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(D(e)){L(t)&&(t="None"),this.Ti=L(i)?this.Ri:i;var r=!1;if($t(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,r=!0)}),r)return this.save(),!0}return!1}register(e,t){if(D(e)){this.Ti=L(t)?this.Ri:t;var i=!1;if($t(e,(t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.props[r]=t,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=Zr(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);N(Nt(e))||this.register(e),this.$i=!0}}update_search_keyword(){var e;this.register((e=null==d?void 0:d.referrer)?es(e):{})}update_referrer_info(){var e;this.register_once({$referrer:is(),$referring_domain:null!=d&&d.referrer&&(null==(e=Zi(d.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[pi]||this.props[gi]||this.register_once({[_i]:rs(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};$t([gi,pi],t=>{var i=this.props[t];i&&$t(i,function(t,i){e["$initial_"+F(i)]=t})});var t,i,r=this.props[_i];if(r){var s=(t=ss(r),i={},$t(t,function(e,t){i["$initial_"+F(t)]=e}),i);Ot(e,s)}return e}safe_merge(e){return $t(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||!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),r=[...t].sort();return i.every((e,t)=>e===r[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.ki(e),s=this.props;this.clear(),this.Y=r,this.props=s,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[Gt]||{};i[e]=t,this.props[Gt]=i,this.save()}remove_event_timer(e){var t=(this.props[Gt]||{})[e];return L(t)||(delete this.props[Gt][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var bn=It("[Product Tours]"),wn="ph_product_tours";class En{constructor(e){this.Fi=null,this.Oi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Zt]:!(null==e||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Fi||(e=this._instance).config.disable_product_tours||null==(t=e.persistence)||!t.get_property(Zt)||this.it(()=>this.Mi())}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",t=>{t?bn.error("Could not load product tours script",t):e()})}Mi(){var e;!this.Fi&&null!=(e=m.__PosthogExtensions__)&&e.generateProductTours&&(this.Fi=m.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!C(this.Oi)||t){var i=this._instance.persistence;if(i){var r=i.props[wn];if(C(r)&&!t)return this.Oi=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:t=>{var r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return bn.error(s),void e([],{isLoaded:!1,error:s})}var n=C(t.json.product_tours)?t.json.product_tours:[];this.Oi=n,i&&i.register({[wn]:n}),e(n,{isLoaded:!0})}})}else e(this.Oi,{isLoaded:!0})}getActiveProductTours(e){q(this.Fi)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Fi.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this.Fi)||t.showTourById(e)}previewTour(e){this.Fi?this.Fi.previewTour(e):this.it(()=>{var t;this.Mi(),null==(t=this.Fi)||t.previewTour(e)})}dismissProductTour(){var e;null==(e=this.Fi)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this.Fi)||e.nextStep()}previousStep(){var e;null==(e=this.Fi)||e.previousStep()}clearCache(){var e;this.Oi=null,null==(e=this._instance.persistence)||e.unregister(wn)}resetTour(e){var t;null==(t=this.Fi)||t.resetTour(e)}resetAllTours(){var e;null==(e=this.Fi)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this.Fi)||t.cancelPendingTour(e)}}var Sn=function(e){return e.Activation="events",e.Cancellation="cancelEvents",e}({});!function(e){e.Button="button",e.Tab="tab",e.Selector="selector"}({}),function(e){e.TopLeft="top_left",e.TopRight="top_right",e.TopCenter="top_center",e.MiddleLeft="middle_left",e.MiddleRight="middle_right",e.MiddleCenter="middle_center",e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger"}({}),function(e){e.Top="top",e.Left="left",e.Right="right",e.Bottom="bottom"}({});var xn=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({});!function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}({}),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}({}),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}({});var kn=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e.ABANDONED="survey abandoned",e}({}),In=function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e.PRODUCT_TOUR_ID="$product_tour_id",e.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",e}({}),Pn=function(e){return e.Popover="popover",e.Inline="inline",e}({}),Tn=It("[Surveys]"),Fn="seenSurvey_",Rn=(e,t)=>{var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i},$n=e=>{return r=""+(t=Fn)+(i=e).id,i.current_iteration&&i.current_iteration>0&&(r=""+t+i.id+"_"+i.current_iteration),r;var t,i,r},On=[xn.Popover,xn.Widget,xn.API],An={ignoreConditions:!1,ignoreDelay:!1,displayType:Pn.Popover};class Cn{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(e=>e!==t)}}emit(e,t){for(var i of this.Ai[e]||[])i(t);for(var r of this.Ai["*"]||[])r(e,t)}}function Mn(e,t,i){if(q(e))return!1;switch(i){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(s){return!1}default:return!1}}class Dn{constructor(e){this.ji=new Cn,this.Di=(e,t)=>this.Li(e,t)&&this.Ni(e,t)&&this.Ui(e,t)&&this.zi(e,t),this.Li=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this.Hi=new Set,this.Bi=new Set}init(){var e,t;L(null==(e=this._instance)?void 0:e._addCaptureHook)||null==(t=this._instance)||t._addCaptureHook((e,t)=>{this.on(e,t)})}register(e){var t,i;if(!L(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach(e=>{var t,i;null==(t=this.Bi)||t.add(e),null==(i=e.steps)||i.forEach(e=>{var t;null==(t=this.Hi)||t.add((null==e?void 0:e.event)||"")})}),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;e.forEach(e=>{var t;null==(t=e.steps)||t.forEach(e=>{null!=e&&e.selector&&s.add(null==e?void 0:e.selector)})}),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(e,t){var i;null!=t&&0!=e.length&&(this.Hi.has(e)||this.Hi.has(null==t?void 0:t.event))&&this.Bi&&(null==(i=this.Bi)?void 0:i.size)>0&&this.Bi.forEach(e=>{this.qi(t,e)&&this.ji.emit("actionCaptured",e.name)})}Wi(e){this.onAction("actionCaptured",t=>e(t))}qi(e,t){if(null==(null==t?void 0:t.steps))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(null!=t&&t.url){var i,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Mn(r,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(null==t||!t.href)return!0;var r=this.Ki(e);if(r.length>0)return r.some(e=>Mn(e.href,t.href,t.href_matching||"exact"));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&Mn((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}Vi(e,t){var i;if(null==t||!t.text)return!0;var r=this.Ki(e);if(r.length>0)return r.some(e=>Mn(e.text,t.text,t.text_matching||"exact")||Mn(e.$el_text,t.text,t.text_matching||"exact"));var s,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(e){for(var t,i=[],r=/(?::|")text="(.*?)"/g;!q(t=r.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",s.some(e=>Mn(e,n,o)))}Ji(e,t){var i,r;if(null==t||!t.selector)return!0;var s=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(t.selector))return!0;var n=(null==e||null==(r=e.properties)?void 0:r.$elements_chain)||"";if(t.selector_regex&&n)try{return new RegExp(t.selector_regex).test(n)}catch(o){return!1}return!1}Ki(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}zi(e,t){return null==t||!t.properties||0===t.properties.length||sn(t.properties.reduce((e,t)=>{var i=C(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e},{}),null==e?void 0:e.properties)}}class Nn{constructor(e){this._instance=e,this.Yi=new Map,this.Xi=new Map,this.Qi=new Map}Zi(e,t){return!!e&&sn(e.propertyFilters,null==t?void 0:t.properties)}te(e,t){var i=new Map;return e.forEach(e=>{var r;null==(r=e.conditions)||null==(r=r[t])||null==(r=r.values)||r.forEach(t=>{if(null!=t&&t.name){var r=i.get(t.name)||[];r.push(e.id),i.set(t.name,r)}})}),i}ie(e,t,i){var r=(i===Sn.Activation?this.Yi:this.Xi).get(e),s=[];return this.ee(e=>{s=e.filter(e=>null==r?void 0:r.includes(e.id))}),s.filter(r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find(t=>t.name===e);return this.Zi(n,t)})}register(e){var t;L(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.re(e),this.se(e))}se(e){var t=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0});0!==t.length&&(null==this.ne&&(this.ne=new Dn(this._instance),this.ne.init(),this.ne.Wi(e=>{this.onAction(e)})),t.forEach(e=>{var t,i,r,s,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.ne)||s.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach(t=>{if(t&&t.name){var i=this.Qi.get(t.name);i&&i.push(e.id),this.Qi.set(t.name,i||[e.id])}}))}))}re(e){var t,i=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0}),r=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0});0===i.length&&0===r.length||(null==(t=this._instance)||t._addCaptureHook((e,t)=>{this.onEvent(e,t)}),this.Yi=this.te(e,Sn.Activation),this.Xi=this.te(e,Sn.Cancellation))}onEvent(e,t){var i,r=this.oe(),s=this.ae(),n=this.le(),o=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[s])||[];if(n===e&&t&&o.length>0){var a,l;r.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:o});var c=(null==t||null==(a=t.properties)?void 0:a.$survey_id)||(null==t||null==(l=t.properties)?void 0:l.$product_tour_id);if(c){var u=o.indexOf(c);u>=0&&(o.splice(u,1),this.ue(o))}}else{if(this.Xi.has(e)){var h=this.ie(e,t,Sn.Cancellation);h.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:h.map(e=>e.id)}),h.forEach(e=>{var t=o.indexOf(e.id);t>=0&&o.splice(t,1),this.he(e.id)}),this.ue(o))}if(this.Yi.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.Yi.get(e)});var d=this.ie(e,t,Sn.Activation);this.ue(o.concat(d.map(e=>e.id)||[]))}}}onAction(e){var t,i=this.ae(),r=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[];this.Qi.has(e)&&this.ue(r.concat(this.Qi.get(e)||[]))}ue(e){var t,i=this.oe(),r=this.ae(),s=[...new Set(e)].filter(e=>!this.de(e));i.info("updating activated items",{activatedItems:s}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[r]:s})}getActivatedIds(){var e,t=this.ae();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}getEventToItemsMap(){return this.Yi}ve(){return this.ne}}class Ln extends Nn{constructor(e){super(e)}ae(){return"$surveys_activated"}le(){return kn.SHOWN}ee(e){var t;null==(t=this._instance)||t.getSurveys(e)}he(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}oe(){return Tn}de(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class jn{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(q(t))return Tn.warn("Flags not loaded yet. Not loading surveys.");var i=C(t);this.ce=i?t.length>0:t,Tn.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);(null!=i&&i.startsWith(Fn)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach(e=>localStorage.removeItem(e))}loadIfEnabled(){if(!this._surveyManager)if(this.fe)Tn.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Tn.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Tn.info("Not loading surveys in cookieless mode without consent.");else{var e=null==m?void 0:m.__PosthogExtensions__;if(e){if(!L(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 r=e.loadExternalDependency;if(!r)return void this.me("PostHog loadExternalDependency extension not found.");r(this._instance,"surveys",i=>{i||!e.generateSurveys?this.me("Could not load surveys script",i):this._e(e.generateSurveys,t)})}catch(s){throw this.me("Error initializing surveys",s),s}finally{this.fe=!1}}}else Tn.error("PostHog Extensions not found.")}}_e(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Ln(this._instance),Tn.info("Surveys loaded successfully"),this.be({isLoaded:!0})}me(e,t){Tn.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(void 0===t&&(t=!1),this._instance.config.disable_surveys)return Tn.info("Disabled. Not loading surveys."),e([]);var i,r=this._instance.get_property(li);if(r&&!t)return e(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.ge?this.ge.then(t=>{var{surveys:i,context:r}=t;return e(i,r)}):("undefined"!=typeof Promise&&(this.ge=new Promise(e=>{i=e})),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:t=>{var r;this.ge=null;var s=t.statusCode;if(200!==s||!t.json){var n="Surveys API could not be loaded, status: "+s;Tn.error(n);var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}var a,l=t.json.surveys||[],c=l.filter(e=>{return!(!(t=e).start_date||t.end_date)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e));var t});c.length>0&&(null==(a=this._surveyEventReceiver)||a.register(c)),null==(r=this._instance.persistence)||r.register({[li]:l});var u={isLoaded:!0};e(l,u),null==i||i({surveys:l,context:u})}}))}be(e){for(var t of this.pe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){Tn.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!q(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Tn.warn("init was not called")}ye(e){var t=null;return this.getSurveys(i=>{var r;t=null!==(r=i.find(t=>t.id===e))&&void 0!==r?r:null}),t}we(e){if(q(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t="string"==typeof e?this.ye(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(q(this._surveyManager))return Tn.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 q(this._surveyManager)?(Tn.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(t=>{var r,s=null!==(r=t.find(t=>t.id===e))&&void 0!==r?r:null;if(s){var n=this.we(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var r;if(q(this._surveyManager))Tn.warn("init was not called");else{var s="string"==typeof e?this.ye(e):e;if(null!=s&&s.id)if(On.includes(s.type)){var n=null==d?void 0:d.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Tn.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var e,t;Tn.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,n,i),Tn.info("Survey "+s.id+" rendered")},1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Tn.warn("Survey element not found")}else Tn.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Tn.warn("Survey not found")}}displaySurvey(e,t){var i;if(q(this._surveyManager))Tn.warn("init was not called");else{var r=this.ye(e);if(r){var s=r;if(null!=(i=r.appearance)&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(s=E({},r,{appearance:E({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Pn.Popover&&t.initialResponses&&Tn.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var n=this.canRenderSurvey(r);if(!n.visible)return void Tn.warn("Survey is not eligible to be displayed: ",n.disabledReason)}t.displayType!==Pn.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else Tn.warn("Survey not found")}}cancelPendingSurvey(e){q(this._surveyManager)?Tn.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}var Hn=It("[Conversations]");class Un{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;q(t)||(V(t)?this.xe=t:(this.xe=t.enabled,this.$e=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||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=null==m?void 0:m.__PosthogExtensions__;if(e&&!L(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",t=>{t||!e.initConversations?this.ke("Could not load conversations script",t):this.Se(e.initConversations),this.Ee=!1})}catch(r){this.ke("Error initializing conversations",r),this.Ee=!1}}else Hn.error("Conversations enabled but missing token in remote config.")}}Se(e){if(this.$e)try{this._conversationsManager=e(this.$e,this._instance),Hn.info("Conversations loaded successfully")}catch(t){this.ke("Error completing conversations initialization",t)}else Hn.error("Cannot complete initialization: remote config is null")}ke(e,t){Hn.error(e,t),this._conversationsManager=null,this.Ee=!1}show(){this._conversationsManager?this._conversationsManager.show():Hn.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.xe&&!U(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var r=this;return w(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,i):(Hn.warn("Conversations not available yet."),null)})()}getMessages(e,t){var i=this;return w(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(Hn.warn("Conversations not available yet."),null)})()}markAsRead(e){var t=this;return w(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Hn.warn("Conversations not available yet."),null)})()}getTickets(e){var t=this;return w(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Hn.warn("Conversations not available yet."),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}}class qn{constructor(e){var t;this.Pe=!1,this.Te=!1,this._instance=e,this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this.Pe=!0)}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!q(i)&&i&&(this.Pe=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Pe&&!this.Te){var e=It("[logs]"),t=null==m?void 0:m.__PosthogExtensions__;if(t){var i=t.loadExternalDependency;i?i(this._instance,"logs",i=>{var r;i||null==(r=t.logs)||!r.initializeLogs?e.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Te=!0)}):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}}var Bn=It("[RateLimiter]");class Gn{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{Bn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(i){return void Bn.warn('could not rate limit - continuing. Error: "'+(null==i?void 0:i.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,r;void 0===e&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(di))&&void 0!==t?t:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);var l=a.tokens<1;return l||e||(a.tokens=Math.max(0,a.tokens-1)),!l||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+n+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(di,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var Vn=It("[RemoteConfig]");class Wn{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=m._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}Ie(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(Vn.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 Vn.info("Using preloaded remote config",this.remoteConfig),void this.wi(this.remoteConfig);if(this._instance.M())return void Vn.warn("Remote config is disabled. Falling back to local config.");this.Ie(e=>{if(!e)return Vn.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ce(e=>{this.wi(e)});this.wi(e)})}catch(pr){Vn.error("Error loading remote config",pr)}}wi(e){e?this._instance.config.__preview_remote_config?(this._instance.wi(e),!1!==e.hasFeatureFlags&&this._instance.featureFlags.ensureFlagsLoaded()):Vn.info("__preview_remote_config is disabled. Logging config instead",e):Vn.error("Failed to fetch remote config from PostHog.")}}var zn=3e3;class Yn{constructor(e,t){this.Re=!0,this.Fe=[],this.Oe=Q((null==t?void 0:t.flush_interval_ms)||zn,250,5e3,kt.createLogger("flush interval"),zn),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(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this.Me(E({},e,{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 i=t[r],s=(new Date).getTime();i.data&&C(i.data)&&$t(i.data,e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp}),e.Me(i)};for(var r in t)i()}},this.Oe))}De(){clearTimeout(this.Ae),this.Ae=void 0}Le(){var e={};return $t(this.Fe,t=>{var i,r=t,s=(r?r.batchKey:null)||r.url;L(e[s])&&(e[s]=E({},r,{data:[]})),null==(i=e[s].data)||i.push(r.data)}),this.Fe=[],e}}var Jn=["retriesPerformedSoFar"];class Kn{constructor(e){this.Ne=!1,this.Ue=3e3,this.Fe=[],this._instance=e,this.Fe=[],this.ze=!0,!L(o)&&"onLine"in o.navigator&&(this.ze=o.navigator.onLine,this.He=()=>{this.ze=!0,this.Lt()},this.Be=()=>{this.ze=!1},Ut(o,"online",this.He),Ut(o,"offline",this.Be))}get length(){return this.Fe.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=S(e,Jn);G(t)&&(i.url=Js(i.url,{retry_count:t})),this._instance._send_request(E({},i,{callback:e=>{200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this.qe(E({retriesPerformedSoFar:t},i)):null==i.callback||i.callback(e)}}))}qe(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i,r,s,n,o,a=(i=t,s=(r=3e3*Math.pow(2,i))/2,n=Math.min(18e5,r),o=(Math.random()-.5)*(n-s),Math.ceil(n+o)),l=Date.now()+a;this.Fe.push({retryAt:l,requestOptions:e});var c="Enqueued failed request for retry in "+a;navigator.onLine||(c+=" (Browser is offline)"),kt.warn(c),this.Ne||(this.Ne=!0,this.We())}We(){if(this.Ge&&clearTimeout(this.Ge),0===this.Fe.length)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(i=>i.retryAt<e||(t.push(i),!1));if(this.Fe=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Ge&&(clearTimeout(this.Ge),this.Ge=void 0),this.Ne=!1,L(o)||(this.He&&(o.removeEventListener("online",this.He),this.He=void 0),this.Be&&(o.removeEventListener("offline",this.Be),this.Be=void 0)),this.Fe))try{this._instance._send_request(E({},e,{transport:"sendBeacon"}))}catch(pr){kt.error(pr)}this.Fe=[]}}class Xn{constructor(e){this.Ve=()=>{var e,t,i,r;this.Je||(this.Je={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this.Je.lastScrollY=Math.ceil(n),this.Je.maxScrollY=Math.max(n,null!==(e=this.Je.maxScrollY)&&void 0!==e?e:0),this.Je.maxScrollHeight=Math.max(o,null!==(t=this.Je.maxScrollHeight)&&void 0!==t?t:0),this.Je.lastContentY=a,this.Je.maxContentY=Math.max(a,null!==(i=this.Je.maxContentY)&&void 0!==i?i:0),this.Je.maxContentHeight=Math.max(l,null!==(r=this.Je.maxContentHeight)&&void 0!==r?r:0)},this._instance=e}getContext(){return this.Je}resetContext(){var e=this.Je;return setTimeout(this.Ve,0),e}startMeasuringScrollPosition(){Ut(o,"scroll",this.Ve,{capture:!0}),Ut(o,"scrollend",this.Ve,{capture:!0}),Ut(o,"resize",this.Ve)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==o?void 0:o.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=null==o?void 0:o.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 o&&(o.scrollY||o.pageYOffset||o.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return o&&(o.scrollX||o.pageXOffset||o.document.documentElement.scrollLeft)||0}}var Zn=e=>rs(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class Qn{constructor(e,t,i,r){this.Ke=e=>{var t=this.Ye();if(!t||t.sessionId!==e){var i={sessionId:e,props:this.Xe(this._instance)};this.Qe.register({[hi]:i})}},this._instance=e,this.Ze=t,this.Qe=i,this.Xe=r||Zn,this.Ze.onSessionId(this.Ke)}Ye(){return this.Qe.props[hi]}getSetOnceProps(){var e,t=null==(e=this.Ye())?void 0:e.props;return t?"r"in t?ss(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 $t(Nt(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+F(i)]=t}),e}}var eo=It("[SessionId]");class to{on(e,t){return this.tr.on(e,t)}constructor(e,t,i){var r;if(this.ir=[],this.er=void 0,this.tr=new Cn,this.rr=(e,t)=>!(!G(e)||!G(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)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||gr,this.lr=i||gr;var s=this.R.persistence_name||this.R.token,n=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Q(n,60,36e3,eo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ur(),this.hr="ph_"+s+"_window_id",this.dr="ph_"+s+"_primary_window_exists",this.vr()){var o=kr.W(this.hr),a=kr.W(this.dr);o&&!a?this.sr=o:kr.V(this.hr),kr.G(this.dr,!0)}if(null!=(r=this.R.bootstrap)&&r.sessionID)try{var l=(()=>{var e=this.R.bootstrap.sessionID.replace(/-/g,"");if(32!==e.length)throw new Error("Not a valid UUID");if("7"!==e[12])throw new Error("Not a UUIDv7");return parseInt(e.substring(0,12),16)})();this.cr(this.R.bootstrap.sessionID,(new Date).getTime(),l)}catch(c){eo.error("Invalid sessionID in bootstrap",c)}this.pr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return L(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"memory"!==this.R.persistence&&!this.Qe.Pi&&kr.H()}gr(e){e!==this.sr&&(this.sr=e,this.vr()&&kr.G(this.hr,e))}_r(){return this.sr?this.sr:this.vr()?kr.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({[ti]:[t,e,i]}))}mr(){var e=this.Qe.props[ti];return C(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.cr(null,null,null)}destroy(){clearTimeout(this.br),this.br=void 0,this.er&&o&&(o.removeEventListener("beforeunload",this.er,{capture:!1}),this.er=void 0),this.ir=[]}pr(){this.er=()=>{this.vr()&&kr.V(this.dr)},Ut(o,"beforeunload",this.er,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this.R.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[r,s,n]=this.mr(),o=this._r(),a=G(n)&&Math.abs(i-n)>864e5,l=!1,c=!s,u=!c&&!e&&this.rr(i,r);c||u||a?(s=this.ar(),o=this.lr(),eo.info("new session ID generated",{sessionId:s,windowId:o,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this.lr(),l=!0);var h=G(r)&&e&&!a?r:i,d=G(n)?n:(new Date).getTime();return this.gr(o),this.cr(s,h,d),e||this.ur(),l&&this.ir.forEach(e=>e(s,o,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0)),{sessionId:s,windowId:o,sessionStartTimestamp:d,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:r}}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 io=["$set_once","$set"],ro=It("[SiteApps]");class so{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 null==(e=m._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?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,r,s,n,o,a;if(!e)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var[h,d]of Object.entries(u))l[h]={id:c[h],type:h,properties:d};var{$set_once:p,$set:g}=e;return{event:E({},S(e,io),{properties:E({},e.properties,g?{$set:E({},null!==(t=null==(i=e.properties)?void 0:i.$set)&&void 0!==t?t:{},g)}:{},p?{$set_once:E({},null!==(r=null==(s=e.properties)?void 0:s.$set_once)&&void 0!==r?r:{},p)}:{}),elements_chain:null!==(n=null==(o=e.properties)?void 0:o.$elements_chain)&&void 0!==n?n:"",distinct_id:null==(a=e.properties)?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this.yr.length&&(ro.info("Processing "+this.yr.length+" events for site app with id "+e.id),this.yr.forEach(e=>null==t.processEvent?void 0:t.processEvent(e)),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null==(i=this.Er)||i.call(this))},r=!1,s=s=>{t.errored=!s,t.loaded=!0,ro.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=e.init({posthog:this._instance,callback:e=>{s(e)}});n&&(t.processEvent=n),r=!0}catch(o){ro.error("Error while initializing PostHog app with config id "+e.id,o),s(!1)}if(r&&t.loaded)try{i()}catch(a){ro.error("Error while processing buffered events PostHog app with config id "+e.id,a),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(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(t)}catch(r){ro.error("Error while processing event "+e.event+" for site app "+i.id,r)}}}onRemoteConfig(e){var t,i,r,s=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this.$r(),void this._instance.on("eventCaptured",e=>this.Sr(e))):void ro.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Er)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var n=function(e){var t;m["__$$ph_site_app_"+e]=s._instance,null==(t=m.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,a,t=>{if(t)return ro.error("Error while initializing PostHog app with config id "+e,t)})};for(var{id:o,url:a}of e.siteApps)n(o)}else ro.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var no=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&k(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some(e=>k(null==e?void 0:e.brand,t)))return!0}catch(s){}return!!e.webdriver},oo=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),ao="i.posthog.com";class lo{constructor(e){this.kr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"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=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ao,".posthog.com")),"https://app.posthog.com"===t?"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]=oo.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=oo.EU:this.kr[this.apiHost]=oo.CUSTOM),this.kr[this.apiHost]}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if("flags"===e)return this.flagsApiHost+t;if(this.region===oo.CUSTOM)return this.apiHost+t;var i=ao+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var co={icontains:(e,t)=>!!o&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!o&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!o&&Qs(t.href,e),not_regex:(e,t)=>!!o&&!Qs(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class uo{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments(e=>{uo.Pr("retrieved web experiments from the server"),t.Tr=new Map,e.forEach(e=>{if(e.feature_flag_key){var i;t.Tr&&(uo.Pr("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t.Tr)||i.set(e.feature_flag_key,e));var r=t._instance.getFeatureFlag(e.feature_flag_key);j(r)&&e.variants[r]&&t.Ir(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var s in e.variants){var n=e.variants[s];uo.Cr(n)&&t.Ir(e.name,s,n.transforms)}})},e)},this._instance=e,this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}onFeatureFlags(e){if(this._is_bot())uo.Pr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(q(this.Tr))return this.Tr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();uo.Pr("applying feature flags",e),e.forEach(e=>{var t;if(this.Tr&&null!=(t=this.Tr)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),s=null==(i=this.Tr)?void 0:i.get(e);r&&null!=s&&s.variants[r]&&this.Ir(s.name,r,s.variants[r].transforms)}})}}previewWebExperiment(){var e=uo.getWindowLocation();if(null!=e&&e.search){var t=Qi(null==e?void 0:e.search,"__experiment_id"),i=Qi(null==e?void 0:e.search,"__experiment_variant");t&&i&&(uo.Pr("previewing web experiments "+t+" && "+i),this.getWebExperiments(e=>{this.Rr(parseInt(t),i,e)},!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 r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}Rr(e,t,i){var r=i.filter(t=>t.id===e);r&&r.length>0&&(uo.Pr("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Ir(r[0].name,t,r[0].variants[t].transforms))}static Cr(e){return!q(e.conditions)&&uo.Fr(e)&&uo.Or(e)}static Fr(e){var t;if(q(e.conditions)||q(null==(t=e.conditions)?void 0:t.url))return!0;var i,r,s,n=uo.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||co[null!==(r=null==(s=e.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==o?void 0:o.location}static Or(e){var t;if(q(e.conditions)||q(null==(t=e.conditions)?void 0:t.utm))return!0;var i=Zr();if(i.utm_source){var r,s,n,o,a,l,c,u,h=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=e.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,d=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,p=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,g=null==(c=e.conditions)||null==(c=c.utm)||!c.utm_term||(null==(u=e.conditions)||null==(u=u.utm)?void 0:u.utm_term)==i.utm_term;return h&&p&&g&&d}return!1}static Pr(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];kt.info("[WebExperiments] "+e,i)}Ir(e,t,i){this._is_bot()?uo.Pr("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach(i=>{if(i.selector){var r;uo.Pr("applying transform of variant "+t+" for experiment "+e+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach(e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)})}}):uo.Pr("Control variants leave the page unmodified.")}_is_bot(){return h&&this._instance?no(h,this._instance.config.custom_blocked_useragents):void 0}}var ho=It("[PostHog ExternalIntegrations]"),po={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class go{constructor(e){this._instance=e}it(e,t){var i;null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,e=>{if(e)return ho.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e=this,t=function(t){var i,s,n;!r||null!=(i=m.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e.it(po[t],()=>{var i;null==(i=m.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)}),!r&&null!=(s=m.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[t]&&(null==(n=m.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,r]of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t(i)}}}var _o="[SessionRecording]",vo=It(_o);class fo{get started(){var e;return!(null==(e=this.Mr)||!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 vo.error("started without valid sessionManager"),new Error(_o+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(_o+' cannot be used with cookieless_mode="always"')}get jr(){var e,t=!(null==(e=this._instance.get_property(ei))||!e.enabled),i=!this._instance.config.disable_session_recording,r=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return o&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this.jr||null==(t=this.Mr)||!t.isStarted){var i=!L(Object.assign)&&!L(Array.from);this.jr&&i?(this.Lr(e),vo.info("starting")):this.stopRecording()}}Lr(e){var t,i,r;this.jr&&(null!=m&&null!=(t=m.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=m.__PosthogExtensions__)&&i.initSessionRecording?this.Nr(e):null==(r=m.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Ur,t=>{if(t)return vo.error("could not load recorder",t);this.Nr(e)}))}stopRecording(){var e,t;null==(e=this.Dr)||e.call(this),this.Dr=void 0,null==(t=this.Mr)||t.stop()}zr(){var e;null==(e=this._instance.persistence)||e.unregister(ii)}Hr(e){if(this._instance.persistence){var t,i,r=this._instance.persistence,s=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,i=null==t?void 0:t.sampleRate,s=q(i)?null:parseFloat(i);q(s)&&this.zr();var n=null==t?void 0:t.minimumDurationMilliseconds;r.register({[ei]:E({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:E({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),canvasRecording:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},sampleRate:s,minimumDurationMilliseconds:L(n)?null:n,endpoint:null==t?void 0:t.endpoint,triggerMatchType:null==t?void 0:t.triggerMatchType,masking:null==t?void 0:t.masking,urlTriggers:null==t?void 0:t.urlTriggers})})};s(),null==(t=this.Dr)||t.call(this),this.Dr=null==(i=this._instance.sessionManager)?void 0:i.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?!1!==e.sessionRecording?(this.Hr(e),this.Ar=!0,this.startIfEnabledOrStop()):this.Ar=!0:vo.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this.Mr)&&i.log?this.Mr.log(e,t):vo.warn("log called before recorder was ready")}get Ur(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(ei);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}Nr(e){var t,i;if(null==(t=m.__PosthogExtensions__)||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Mr||(this.Mr=null==(i=m.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.Mr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Mr.start(e)}onRRwebEmit(e){var t;null==(t=this.Mr)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Mr||null==(t=this._instance.persistence)||t.register({$replay_override_linked_flag:!0}),null==(e=this.Mr)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Mr||null==(t=this._instance.persistence)||t.register({$replay_override_sampling:!0}),null==(e=this.Mr)||e.overrideSampling()}overrideTrigger(e){var t,i;this.Mr||null==(i=this._instance.persistence)||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(t=this.Mr)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this.Mr)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this.Mr)||!i.tryAddCustomEvent(e,t))}}var mo={},yo=()=>{},bo="posthog",wo=!zs&&-1===(null==f?void 0:f.indexOf("MSIE"))&&-1===(null==f?void 0:f.indexOf("Mozilla")),Eo=e=>{var t;return E({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:jt(null==d?void 0:d.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:yo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,debug:p&&j(null==p?void 0:p.search)&&-1!==p.search.indexOf("__posthog_debug=true")||!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:"https:"===(null==o||null==(t=o.location)?void 0:t.protocol),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:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;kt.error(t)},get_device_id:e=>e,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:zn},error_tracking:{},_onCapture:yo,__preview_eager_load_replay:!1},(e=>({rageclick:!(e&&e>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(e&&e>="2025-05-24")||"history_change",session_recording:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},So=e=>{var t={};L(e.process_person)||(t.person_profiles=e.process_person),L(e.xhr_headers)||(t.request_headers=e.xhr_headers),L(e.cookie_name)||(t.persistence_name=e.cookie_name),L(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),L(e.store_google)||(t.save_campaign_params=e.store_google),L(e.verbose)||(t.debug=e.verbose);var i=Ot({},t,e);return C(e.property_blacklist)&&(L(e.property_denylist)?i.property_denylist=e.property_blacklist:C(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:kt.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class xo{constructor(){this.__forceAllowLocalhost=!1}get Br(){return this.__forceAllowLocalhost}set Br(e){kt.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class ko{get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){this.webPerformance=new xo,this.qr=!1,this.version=y.LIB_VERSION,this.bi=new Cn,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Eo(),this.SentryIntegration=jr,this.sentryIntegration=e=>{return t=Lr(this,e),{name:Nr,processEvent:e=>t(e)};var t},this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new fn(this),this.toolbar=new Gr(this),this.scrollManager=new Xn(this),this.pageViewManager=new ps(this),this.surveys=new jn(this),this.conversations=new Un(this),this.logs=new qn(this),this.experiments=new uo(this),this.exceptions=new on(this),this.rateLimiter=new Gn(this),this.requestRouter=new lo(this),this.consent=new Pr(this),this.externalIntegrations=new go(this),this.people={set:(e,t,i)=>{var r=j(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=j(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",e=>kt.info('send "'+(null==e?void 0:e.event)+'"',e))}init(e,t,i){if(i&&i!==bo){var r,s=null!==(r=mo[i])&&void 0!==r?r:new ko;return s._init(e,t,i),mo[i]=s,mo[bo][i]=s,s}return this._init(e,t,i)}_init(e,t,i){var r;if(void 0===t&&(t={}),L(e)||H(e))return kt.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(Ot({},Eo(t.defaults),So(t),{name:i,token:e})),this.config.on_xhr_error&&kt.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:gs.GZipJS;var s=this.Qr();this.persistence=new yn(this.config,s),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new yn(E({},this.config,{persistence:"sessionStorage"}),s);var n=E({},this.persistence.props),a=E({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Zr=new Yn(e=>this.ts(e),this.config.request_queue_config),this.es=new Kn(this),this.__request_queue=[];var l="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new to(this),this.sessionPropsManager=new Qn(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(kt.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.rs(l)},0)):(kt.info("Initializing extensions synchronously"),this.rs(l)),y.DEBUG=y.DEBUG||this.config.debug,y.DEBUG&&kt.info("Starting in debug mode",{this:this,config:t,thisC:E({},this.config),p:n,s:a}),void 0!==(null==(r=t.bootstrap)?void 0:r.distinctID)){var c,u,h=this.config.get_device_id(gr()),d=null!=(c=t.bootstrap)&&c.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(ui,null!=(u=t.bootstrap)&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:d})}if(this.ss()){var p,g,_=Object.keys((null==(p=t.bootstrap)?void 0:p.featureFlags)||{}).filter(e=>{var i;return!(null==(i=t.bootstrap)||null==(i=i.featureFlags)||!i[e])}).reduce((e,i)=>{var r;return e[i]=(null==(r=t.bootstrap)||null==(r=r.featureFlags)?void 0:r[i])||!1,e},{}),v=Object.keys((null==(g=t.bootstrap)?void 0:g.featureFlagPayloads)||{}).filter(e=>_[e]).reduce((e,i)=>{var r,s;return null!=(r=t.bootstrap)&&null!=(r=r.featureFlagPayloads)&&r[i]&&(e[i]=null==(s=t.bootstrap)||null==(s=s.featureFlagPayloads)?void 0:s[i]),e},{});this.featureFlags.receivedFeatureFlags({featureFlags:_,featureFlagPayloads:v})}if(l)this.register_once({distinct_id:mi,$device_id:null},"");else if(!this.get_distinct_id()){var f=this.config.get_device_id(gr());this.register_once({distinct_id:f,$device_id:f},""),this.persistence.set_property(ui,"anonymous")}return Ut(o,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?function(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var r=i=>{var r=()=>i.anonymousId()||gr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(ui,"identified")),t()},s=i.user();"then"in s&&M(s.then)?s.then(r):r(s)}(e,()=>{i.register((e=>{Promise&&Promise.resolve||Dr.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Dr.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Dr.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then(()=>{t()})})}(this,()=>this.ns()):this.ns(),M(this.config._onCapture)&&this.config._onCapture!==yo&&(kt.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&kt.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 Mr(this),this.historyAutocapture.startIfEnabled();var i=[];i.push(()=>{new Wr(this).startIfEnabledOrStop()}),i.push(()=>{var e;this.siteApps=new so(this),null==(e=this.siteApps)||e.init()}),e||i.push(()=>{this.sessionRecording=new fo(this),this.sessionRecording.startIfEnabledOrStop()}),this.config.disable_scroll_properties||i.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),i.push(()=>{this.autocapture=new or(this),this.autocapture.startIfEnabled()}),i.push(()=>{this.surveys.loadIfEnabled()}),i.push(()=>{this.logs.loadIfEnabled()}),i.push(()=>{this.conversations.loadIfEnabled()}),i.push(()=>{this.productTours=new En(this),this.productTours.loadIfEnabled()}),i.push(()=>{this.heatmaps=new ds(this),this.heatmaps.startIfEnabled()}),i.push(()=>{this.webVitalsAutocapture=new cs(this)}),i.push(()=>{this.exceptionObserver=new Ar(this),this.exceptionObserver.startIfEnabledOrStop()}),i.push(()=>{this.deadClicksAutocapture=new $r(this,Rr),this.deadClicksAutocapture.startIfEnabled()}),i.push(()=>{if(this.os){var e=this.os;this.os=void 0,this.wi(e)}}),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(s){kt.error("Error initializing extension:",s)}}var r=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:r}),this.config.__preview_deferred_init_extensions&&kt.info("PostHog extensions initialized ("+r+"ms)")}wi(e){var t,i,r,s,n,o,a,l,c;if(!d||!d.body)return kt.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=P(e.supportedCompression,gs.GZipJS)?gs.GZipJS:P(e.supportedCompression,gs.Base64)?gs.Base64:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"identified_only"}),null==(i=this.siteApps)||i.onRemoteConfig(e),null==(r=this.sessionRecording)||r.onRemoteConfig(e),null==(s=this.autocapture)||s.onRemoteConfig(e),null==(n=this.heatmaps)||n.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),null==(o=this.productTours)||o.onRemoteConfig(e),null==(a=this.webVitalsAutocapture)||a.onRemoteConfig(e),null==(l=this.exceptionObserver)||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),null==(c=this.deadClicksAutocapture)||c.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(i){kt.critical("`loaded` function failed",i)}if(this.us(),this.config.internal_or_test_user_hostname&&null!=p&&p.hostname){var e=p.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this.hs()},1),new Wn(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this.Zr)||e.enable())}_dom_loaded(){this.is_capturing()&&Rt(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"),null==(e=this.Zr)||e.unload(),null==(t=this.es)||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(wo?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Js(e.url,{ip:this.config.ip?1:0}),e.headers=E({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?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,(e=>{var t,i,r,s=E({},e);s.timeout=s.timeout||6e4,s.url=Js(s.url,{_:(new Date).getTime().toString(),ver:y.LIB_VERSION,compression:s.compression});var n=null!==(t=s.transport)&&void 0!==t?t:"fetch",o=Zs.filter(e=>!s.disableTransport||!e.transport||!s.disableTransport.includes(e.transport)),a=null!==(i=null==(r=Ht(o,e=>e.transport===n))?void 0:r.method)&&void 0!==i?i:o[0].method;if(!a)throw new Error("No available transport method");a(s)})(E({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&(null==(i=(r=this.config).on_request_error)||i.call(r,t)),null==e.callback||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],r=[],s=[];Rt(e,e=>{e&&(t=e[0],C(t)?s.push(e):M(e)?e.call(this):C(e)&&"alias"===t?i.push(e):C(e)&&-1!==t.indexOf("capture")&&M(this[t])?s.push(e):r.push(e))});var n=function(e,t){Rt(e,function(e){if(C(e[0])){var i=t;$t(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else this[e[0]].apply(this,e.slice(1))},t)};n(i,this),n(r,this),n(s,this)}ss(){var e,t;return(null==(e=this.config.bootstrap)?void 0:e.featureFlags)&&Object.keys(null==(t=this.config.bootstrap)?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,i){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!L(e)&&j(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!s||this.config.__preview_capture_bot_pageviews){var n=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==n||!n.isRateLimited){null!=t&&t.$current_url&&!j(null==t?void 0:t.$current_url)&&(kt.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||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,a=(null==i?void 0:i.timestamp)||o,l=gr(),c={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},a,l)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&s&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),n&&(c.properties.$lib_rate_limit_remaining_tokens=n.remainingTokens),(null==i?void 0:i.$set)&&(c.$set=null==i?void 0:i.$set);var u,h="$groupidentify"!==e,d=this.vs(null==i?void 0:i.$set_once,h);if(d&&(c.$set_once=d),(c=function(e,t){return i=e,r=e=>j(e)&&!U(t)?e.slice(0,t):e,s=new Set,function e(t,i){return t!==Object(t)?r?r(t):t:s.has(t)?void 0:(s.add(t),C(t)?(n=[],Rt(t,t=>{n.push(e(t))})):(n={},$t(t,(t,i)=>{s.has(t)||(n[i]=e(t))})),n);var n}(i);var i,r,s}(c,null!=i&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=a,L(null==i?void 0:i.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=o),e===kn.DISMISSED||e===kn.SENT){var p=null==t?void 0:t[In.SURVEY_ID],g=null==t?void 0:t[In.SURVEY_ITERATION];u={id:p,current_iteration:g},localStorage.getItem($n(u))||localStorage.setItem($n(u),"true"),c.$set=E({},c.$set,{[Rn({id:p,current_iteration:g},e===kn.SENT?"responded":"dismissed")]:!0})}else e===kn.SHOWN&&(c.$set=E({},c.$set,{[In.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));var _=E({},c.properties.$set,c.$set);if(N(_)||this.setPersonPropertiesForFlags(_),!q(this.config.before_send)){var v=this.cs(c);if(!v)return;c=v}this.bi.emit("eventCaptured",c);var f={method:"POST",url:null!==(r=null==i?void 0:i._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:null==i?void 0:i._batchKey};return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly?this.ts(f):this.Zr.enqueue(f),c}kt.critical("This capture call is ignored due to client rate limiting.")}}else kt.error("No event name provided to posthog.capture")}else kt.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}calculateEventProperties(e,t,i,r,s){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var n=s?void 0:this.persistence.remove_event_timer(e),a=E({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),"$snapshot"===e){var l=E({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!j(a.distinct_id)&&!B(a.distinct_id)||H(a.distinct_id))&&kt.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=function(e,t){if(!f)return{};var i,r,s,n=e?At([],Yr,t||[]):[],[a,l]=function(e){for(var t=0;t<Xe.length;t++){var[i,r]=Xe[t],s=i.exec(e),n=s&&(M(r)?r(s,e):r);if(n)return n}return["",""]}(f);return Ot(Nt({$os:a,$os_version:l,$browser:Ye(f,navigator.vendor),$device:Ze(f),$device_type:(r=f,s=Ze(r),s===ce||s===le||"Kobo"===s||"Kindle Fire"===s||s===je?ae:s===Te||s===Re||s===Fe||s===De?"Console":s===he?"Wearable":s?se:"Desktop"),$timezone:ns(),$timezone_offset:os()}),{$current_url:er(null==p?void 0:p.href,n,Kr),$host:null==p?void 0:p.host,$pathname:null==p?void 0:p.pathname,$raw_user_agent:f.length>1e3?f.substring(0,997)+"...":f,$browser_version:Ke(f,navigator.vendor),$browser_language:ts(),$browser_language_prefix:(i=ts(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==o?void 0:o.screen.height,$screen_width:null==o?void 0:o.screen.width,$viewport_height:null==o?void 0:o.innerHeight,$viewport_width:null==o?void 0:o.innerWidth,$lib:"web",$lib_version:y.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:g}=this.sessionManager.checkAndGetSessionAndWindowId(s,i.getTime());a.$session_id=h,a.$window_id=g}this.sessionPropsManager&&Ot(a,this.sessionPropsManager.getSessionProps());try{var _;this.sessionRecording&&Ot(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=null==(_=this.es)?void 0:_.length}catch(w){a.$sdk_debug_error_capturing_properties=String(w)}if(this.requestRouter.region===oo.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||s?"$pageleave"!==e||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=Ot(a,c),"$pageview"===e&&d&&(a.title=d.title),!L(n)){var v=i.getTime()-n;a.$duration=parseFloat((v/1e3).toFixed(3))}f&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Ot({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),C(this.config.property_denylist)?$t(this.config.property_denylist,function(e){delete a[e]}):kt.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var m=this.config.sanitize_properties;m&&(kt.error("sanitize_properties is deprecated. Use before_send instead"),a=m(a,e));var b=this.fs();return a.$process_person_profile=b,b&&!s&&this.ps("_calculate_event_properties"),a}vs(e,t){var i;if(void 0===t&&(t=!0),!this.persistence||!this.fs())return e;if(this.qr)return e;var r=this.persistence.get_initial_props(),s=null==(i=this.sessionPropsManager)?void 0:i.getSetOnceProps(),n=Ot({},r,s||{},e||{}),o=this.config.sanitize_properties;return o&&(kt.error("sanitize_properties is deprecated. Use before_send instead"),n=o(n,"$set_once")),t&&(this.qr=!0),N(n)?void 0:n}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||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 r=null!=i&&i.merge?this.featureFlags.getFlagVariants():{},s=null!=i&&i.merge?this.featureFlags.getFlagPayloads():{},n=E({},r,e),o=E({},s,t),a={};for(var[l,c]of Object.entries(n)){var u="string"==typeof c;a[l]={key:l,enabled:!!u||Boolean(c),variant:u?c:void 0,reason:void 0,metadata:L(null==o?void 0:o[l])?void 0:{id:0,version:void 0,description:void 0,payload:o[l]}}}this.featureFlags.receivedFeatureFlags({flags:a})}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return void 0===t&&(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 null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){void 0===t&&(t=An),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return void 0===t&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,i){if(!this.__loaded||!this.persistence)return kt.uninitializedWarning("posthog.identify");if(B(e)&&(e=e.toString(),kt.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()))kt.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!==mi){if(this.ps("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var s=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==r&&e!==this.get_property(Bt)&&(this.unregister(Bt),this.register({distinct_id:e}));var n="anonymous"===(this.persistence.get_property(ui)||"anonymous");e!==r&&n?(this.persistence.set_property(ui,"identified"),this.setPersonPropertiesForFlags(E({},i||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this.Jr=en(e,t,i),this.featureFlags.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(ci))}}else kt.critical('The string "'+mi+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else kt.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var i=en(this.get_distinct_id(),e,t);this.Jr!==i?(this.setPersonPropertiesForFlags(E({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=i):kt.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:E({},r,{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),r[e]===t||i||this.reloadFeatureFlags()}else kt.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,s;if(kt.info("reset"),!this.__loaded)return kt.uninitializedWarning("posthog.reset");var n=this.get_property("$device_id");if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),this.surveys.reset(),this.featureFlags.reset(),null==(r=this.persistence)||r.set_property(ui,"anonymous"),null==(s=this.sessionManager)||s.resetSessionId(),this.Jr=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:mi,$device_id:null},"");else{var o=this.config.get_device_id(gr());this.register_once({distinct_id:o,$device_id:e?o:n},"")}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 null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(null!=e&&e.withTimestamp&&i){var s,n=null!==(s=e.timestampLookBack)&&void 0!==s?s:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return r}alias(e,t){return e===this.get_property(qt)?(kt.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(L(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(Bt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(kt.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=E({},this.config);if(D(e)){var i,r,s,n,o,a,l;Ot(this.config,So(e));var c=this.Qr();null==(i=this.persistence)||i.update_config(this.config,t,c),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new yn(E({},this.config,{persistence:"sessionStorage"}),c);var u=this.Kr(this.config.debug);V(u)&&(this.config.debug=u),V(this.config.debug)&&(this.config.debug?(y.DEBUG=!0,br.H()&&br.G("ph_debug","true"),kt.info("set_config",{config:e,oldConfig:t,newConfig:E({},this.config)})):(y.DEBUG=!1,br.H()&&br.V("ph_debug"))),null==(r=this.exceptionObserver)||r.onConfigChange(),null==(s=this.sessionRecording)||s.startIfEnabledOrStop(),null==(n=this.autocapture)||n.startIfEnabled(),null==(o=this.heatmaps)||o.startIfEnabled(),null==(a=this.exceptionObserver)||a.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),null==(l=this.externalIntegrations)||l.startIfEnabledOrStop()}}startSessionRecording(e){var t,i,r,s,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(E({},r,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:bo;return t!==bo&&(t=bo+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(ui))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(ui))}fs(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&N(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[Bt])&&(null==(t=this.persistence)||null==(t=t.props)||!t[vi]))}ds(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return"never"===this.config.person_profiles?(kt.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(vi,!0),!0)}Qr(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}_s(){var e,t,i,r,s=this.Qr();return(null==(e=this.persistence)?void 0:e.Pi)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(t=this.sessionPersistence)?void 0:t.Pi)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s}opt_in_capturing(e){var t,i,r,s;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new to(this),this.pageViewManager=new ps(this),this.persistence&&(this.sessionPropsManager=new Qn(this,this.sessionManager,this.persistence)),this.sessionRecording=new fo(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),(L(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(s=null==e?void 0:e.captureEventName)&&void 0!==s?s:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.hs()):kt.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,i;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:mi,$device_id:null}),null==(e=this.sessionManager)||e.destroy(),null==(t=this.pageViewManager)||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(i=this.sessionRecording)||i.stopRecording(),this.sessionRecording=void 0,this.hs())):kt.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===Ir.GRANTED?"granted":e===Ir.DENIED?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._s()}_is_bot(){return h?no(h,this.config.custom_blocked_useragents):void 0}hs(){d&&("visible"===d.visibilityState?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:d.title},{send_instantly:!0}),this.Gr&&(d.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),Ut(d,"visibilitychange",this.Gr)))}debug(e){!1===e?(null==o||o.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==o||o.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,r,s,n,o=this.Yr||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(kt.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",r=kt,s=(t="advanced_disable_flags")in(e=o)&&!q(e[t]),n=i in e&&!q(e[i]),s?e[t]:!!n&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}cs(e){if(q(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 r of t){if(i=r(i),q(i)){var s="Event '"+e.event+"' was rejected in beforeSend function";return W(e.event)?kt.warn(s+". This can cause unexpected behavior."):kt.info(s),null}i.properties&&!N(i.properties)||kt.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return null==(e=this.pageViewManager.Kt)?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=V(e)&&!e,i=br.H()&&"true"===br.q("ph_debug");return!t&&(!!i||e)}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Dt(e.prototype[t[i]])}(ko,["identify"]);var Io,Po=(Io=mo[bo]=new ko,function(){function e(){e.done||(e.done=!0,wo=!1,$t(mo,function(e){e._dom_loaded()}))}null!=d&&d.addEventListener?"complete"===d.readyState?e():Ut(d,"DOMContentLoaded",e,{capture:!1}):o&&kt.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),Io);let To=null,Fo=!1;const Ro=e=>{let t=2166136261;for(let i=0;i<e.length;i++)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return(t>>>0)/4294967296},$o="dori_shopify_end_user_id",Oo="dori_shopify_end_user_session",Ao=()=>"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2,10)}`;let Co=null;const Mo=()=>{if(Co)return Co;let e;try{const t=window?.DORI_CUSTOMER_ID;if(t){let i=window.localStorage.getItem(Oo);i&&i.trim()||(i=Ao(),window.localStorage.setItem(Oo,i)),e=`shopify_customer_${String(t)}_${i}`}else{const t=window.localStorage.getItem($o);t&&t.trim()?e=t:(e=`anon_${Ao()}`,window.localStorage.setItem($o,e))}}catch{e=`anon_${Ao()}`}return Co=e,e};let Do=null;const No=e=>(()=>{if(null===Do){const e=jo()??"";Do=Ro(`${e}:${Mo()}`)}return Do})()<e,Lo=e=>Ro(`${e}:${Mo()}`),jo=()=>{try{const e=document.querySelector("script#dori-side-widget");return e?.getAttribute("data-sharing-id")||null}catch{return null}};let Ho=null;const Uo=()=>{const e={},t=jo();return t&&(e.sharing_id=t),"undefined"!=typeof window&&window.location&&window.location.hostname&&(e.shop_domain=window.location.hostname),e},qo=e=>{if(!e)return;const t=Go();if(t)try{t.register({thread_id:e})}catch(i){}},Bo=(e,t)=>{const i=Go();if(i)try{i.register({occasion:e,occasion_arm:t})}catch(r){}},Go=()=>(To||Fo||(To=(()=>{if(Po.__loaded)return Po;if(Fo)return null;Fo=!0;try{return Po.init("phc_H5oKb44Ke85TJHMvMDD6MzxtjjVeGZZinXVTyC8t0bY",{api_host:"https://us.i.posthog.com",person_profiles:"identified_only",autocapture:!1,capture_pageview:!1,capture_pageleave:!1,capture_performance:!1,capture_dead_clicks:!1,rageclick:!1,disable_session_recording:!0,bootstrap:{distinctID:Mo()},before_send:e=>{if(!e)return e;if("$exception"===e.event)return No(.1)&&(e=>{const t=e?.properties??{};if("manual"===t.dori_capture)return!0;const i=(()=>{if(Ho)return Ho;const e=[];try{const t=document.querySelector("script#dori-side-widget"),i=t?.src;if(i){e.push(i);const t=i.slice(0,i.lastIndexOf("/")+1);t&&t!==i&&e.push(t)}}catch{}return Ho=e,e})();if(0===i.length)return!0;const r=t.$exception_list;if(!Array.isArray(r)||0===r.length)return!0;for(const s of r){const e=s?.stacktrace?.frames;if(Array.isArray(e))for(const t of e){const e=t?.filename;if("string"==typeof e&&i.some(t=>e.startsWith(t)))return!0}}return!1})(e)?e:null;const t=(e=>e.startsWith("pf.")||e.startsWith("pdp_hero"))(e.event)?1:.1;return No(t)?e:null},loaded:e=>{try{e.register({...Uo(),surface:"side",flow_version:"1.13.152"})}catch(t){}try{e.unregister("occasion"),e.unregister("occasion_arm")}catch(t){}}}),To=Po,Po}catch(e){return console.error("[PostHog] Failed to initialize:",e),null}finally{Fo=!1}})()),To),Vo=(e,t)=>{const i=Go();if(i)try{i.capture(e,t)}catch(r){}},Wo=(e,t)=>{const i=Go();if(i)try{console.error("Error captured:",e,t),i.capture("$exception",{$exception_message:e.message,$exception_type:e.name,$exception_stack_trace:e.stack,dori_capture:"manual",...t})}catch(r){console.error("[PostHog] Failed to capture exception:",r)}},zo=(e,t)=>(...i)=>{try{return console.log("withErrorHandling",e),t(...i)}catch(r){throw console.error("Error in withErrorHandling:",r),Wo(r,{context:e}),r}},Yo=(e,t)=>(...i)=>{try{return t(...i).catch(t=>{throw"AbortError"!==t.name&&Wo(t,{context:e}),t})}catch(r){throw"AbortError"!==r.name&&Wo(r,{context:e}),r}},Jo={BOT_DATA:"dori_widget_bot_data",BOT_DATA_ETAG:"dori_widget_bot_data_etag",BOT_DATA_SHARING_ID:"dori_widget_bot_data_sharing_id",SESSION_SHARING_ID:"dori_widget_session_sharing_id",CHAT_STATE:"dori_widget_chat_state",MESSAGES:"dori_widget_messages",CURRENT_STEP:"dori_widget_current_step",SESSION_TIMESTAMP:"dori_widget_session_timestamp",FAB_ANIMATION_TIMESTAMP:"dori_widget_fab_animation_timestamp",DORI_THREAD_ID:"dori_thread_id",DORI_SESSION_KEY:"dori_session_key",LOADED_FROM_STORAGE:"dori_loaded_from_storage",SHOPIFY_END_USER_ID:"dori_shopify_end_user_id",SHOPIFY_END_USER_SESSION:"dori_shopify_end_user_session"};function Ko(){if("undefined"==typeof window)return"";const e=window;if(e.chatbotData?.sharingID)return String(e.chatbotData.sharingID);const t=document.querySelector("script#dori-side-widget");return t?.getAttribute("data-sharing-id")||""}function Xo(){try{const e="__test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}function Zo(){Xo()&&localStorage.setItem(Jo.LOADED_FROM_STORAGE,"true")}function Qo(){Xo()&&localStorage.removeItem(Jo.LOADED_FROM_STORAGE)}function ea(){try{const e=localStorage.getItem(Jo.SESSION_TIMESTAMP);if(!e)return!1;const t=parseInt(e,10);return Date.now()-t<864e5}catch{return!1}}function ta(){if(Xo())try{[Jo.CHAT_STATE,Jo.MESSAGES,Jo.CURRENT_STEP,Jo.DORI_THREAD_ID,Jo.DORI_SESSION_KEY,Jo.LOADED_FROM_STORAGE,Jo.SHOPIFY_END_USER_ID,Jo.SHOPIFY_END_USER_SESSION].forEach(e=>{localStorage.removeItem(e)})}catch(e){console.error("Error clearing local storage:",e)}}function ia(){const e=Ko();return!e||localStorage.getItem(Jo.BOT_DATA_SHARING_ID)===e}function ra(e){if(Xo())try{if(e){localStorage.setItem(Jo.BOT_DATA,JSON.stringify(e));const t=Ko();t&&localStorage.setItem(Jo.BOT_DATA_SHARING_ID,t)}else localStorage.removeItem(Jo.BOT_DATA),localStorage.removeItem(Jo.BOT_DATA_SHARING_ID)}catch(t){console.error("Error saving bot data:",t)}}function sa(){if(!Xo()||!ea())return null;if(!ia())return null;try{const e=localStorage.getItem(Jo.BOT_DATA);return e?JSON.parse(e):null}catch(e){return console.error("Error loading bot data:",e),null}}function na(){if(Xo())try{localStorage.removeItem(Jo.BOT_DATA),localStorage.removeItem(Jo.BOT_DATA_ETAG),localStorage.removeItem(Jo.BOT_DATA_SHARING_ID)}catch(e){console.error("Error clearing bot data cache:",e)}}function oa(e){if(Xo())try{localStorage.setItem(Jo.CHAT_STATE,JSON.stringify(e))}catch(t){console.error("Error saving chat state:",t)}}function aa(e){if(Xo())try{const t=e.map(e=>({...e,timestamp:e.timestamp instanceof Date?e.timestamp.toISOString():e.timestamp}));localStorage.setItem(Jo.MESSAGES,JSON.stringify(t))}catch(t){console.error("Error saving messages:",t)}}function la(){if(!Xo()||!ea())return[];try{const e=localStorage.getItem(Jo.MESSAGES);return e?JSON.parse(e).map(e=>({...e,content:"string"==typeof e.content?r(e.content):e.content,timestamp:new Date(e.timestamp)})):[]}catch(e){return console.error("Error loading messages:",e),[]}}function ca(e){if(Xo())try{localStorage.setItem(Jo.CURRENT_STEP,e)}catch(t){console.error("Error saving current step:",t)}}function ua(){if(!Xo()||!ea())return null;try{const e=sa(),t=function(){if(!Xo()||!ea())return null;try{const e=localStorage.getItem(Jo.CHAT_STATE);return e?JSON.parse(e):null}catch(e){return console.error("Error loading chat state:",e),null}}(),i=la(),r=function(){if(!Xo()||!ea())return"welcome";try{return localStorage.getItem(Jo.CURRENT_STEP)||"welcome"}catch(e){return console.error("Error loading current step:",e),"welcome"}}();return e||i.length>0?{botData:e,chatState:t||{repliedProduct:null,focusedProduct:null,threadId:null,isRequestInProgress:!1},messages:i,currentStep:r,sessionTimestamp:Date.now()}:null}catch(e){return console.error("Error loading session data:",e),null}}function ha(){if(!Xo()||!ea())return!1;try{const e=sa(),t=la();return!!(e||t.length>0)}catch{return!1}}function da(){if(Xo())try{localStorage.setItem(Jo.SESSION_TIMESTAMP,Date.now().toString())}catch(e){console.error("Error updating session timestamp:",e)}}function pa(){if(Xo())try{localStorage.setItem(Jo.FAB_ANIMATION_TIMESTAMP,Date.now().toString())}catch(e){console.error("Error saving FAB animation timestamp:",e)}}function ga(){const e=function(){if(!Xo()||!ea())return null;try{const e=localStorage.getItem(Jo.FAB_ANIMATION_TIMESTAMP);return e?parseInt(e,10):null}catch(e){return console.error("Error loading FAB animation timestamp:",e),null}}();return!e||Date.now()-e>=3e5}function _a(){if(!Xo())return"";try{let e=localStorage.getItem(Jo.DORI_SESSION_KEY);return e||(e="dori_session_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),localStorage.setItem(Jo.DORI_SESSION_KEY,e)),e}catch(e){return console.error("Error generating session key:",e),""}}function va(e){if(Xo()&&e){try{localStorage.setItem(Jo.DORI_THREAD_ID,e)}catch(t){console.error("Error storing dori thread ID:",t)}qo(e)}}function fa(){if(!Xo())return null;try{const e=localStorage.getItem(Jo.DORI_THREAD_ID);return qo(e),e}catch(e){return console.error("Error retrieving dori thread ID:",e),null}}function ma(e){const t=window?.chatbotData;if("undefined"!=typeof window&&t?.ajaxurl){const i=_a();fetch(t.ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"dori_store_thread_session",thread_id:e,session_key:i,nonce:t.nonce})}).catch(e=>console.warn("Failed to store thread in WooCommerce session:",e))}}const ya="https://devapi.dori.tech",ba=["pointerdown","keydown"],wa=["pointermove","touchstart","wheel","scroll"],Ea=["pointerover","focusin","click"];function Sa(e){const t=(e instanceof Error?e.message:String(e??"")).match(/https?:\/\/[^\s"')]+/);if(!t)return null;const i=t[0].replace(/[.,;:]+$/,"");return/\.m?js(\?|$)/.test(i)?i:null}function xa(e){return e+(e.includes("?")?"&":"?")+"dori-retry=1"}async function ka(e,t,i,r=500,s=e=>import(e)){try{return await e()}catch(n){const e=Sa(n);if(!e)return i?.(n,n),{default:t};await new Promise(e=>setTimeout(e,r));try{return await s(xa(e))}catch(o){return i?.(n,o),{default:t}}}}function Ia(e,t){return e&&("header_button"===t||"header_block"===t)}function Pa(e){if("undefined"==typeof window)return;const t=window;t.__doriOpenReady=!0;const i=t.__doriOpenQueue||[];t.__doriOpenQueue=[],i.length&&e(i[i.length-1])}const Ta=(e,t=[])=>{if(!t||0===t.length)return!1;const i=e.replace(/^\/+/,"").toLowerCase();return t.some(e=>{const t=e.replace(/^\/+/,"").toLowerCase();return i.includes(t)})},Fa=()=>"undefined"==typeof window?"":window.location.pathname,Ra=new Set;let $a=!1;function Oa(){for(const e of Ra)try{e()}catch{}}const Aa="dori-bot-data-ready",Ca="dori-bot-data-error",Ma=(e,t)=>{window.dispatchEvent(new CustomEvent(e,t?{detail:{error:t}}:void 0))},Da=async e=>{const t=await fetch(e);if(200!==t.status)throw new Error(`Failed to fetch bot data: ${t.status}`);const i=await t.json();if(i.error)throw new Error(i.error);if(!i.data)throw new Error("No data received from bot sharing API");return i},Na=(e,t)=>{ra(e),t&&function(e){if(Xo())try{e?localStorage.setItem(Jo.BOT_DATA_ETAG,e):localStorage.removeItem(Jo.BOT_DATA_ETAG)}catch(t){console.error("Error saving ETag:",t)}}(t),da()};let La=!1,ja="";const Ha=()=>{const e=sa();if(!La&&!0!==e?.feature_flags?.ask_button&&!document.querySelector("[data-dori-ask-block]"))return;La||function(){if(Ra.add(()=>{window.location.pathname!==ja&&Ha()}),!$a&&"undefined"!=typeof window){$a=!0;for(const e of["pushState","replaceState"]){const t=history[e];history[e]=function(...e){const i=t.apply(this,e);return Oa(),i}}window.addEventListener("popstate",Oa)}}(),La=!0,ja=window.location.pathname;const i=!!e&&Ta(ja,e.banned_paths||[]);t(async()=>{const{applyAskButton:e}=await import("./assets/apply-C1aK27go.js");return{applyAskButton:e}},__vite__mapDeps([0,1]),import.meta.url).then(({applyAskButton:t})=>t(e,i)).catch(e=>console.error("[Dori Widget] Ask button failed to load:",e))};window.addEventListener(Aa,Ha),async function(){try{const t=(()=>{const e=document.querySelector("script#dori-side-widget");return e?.getAttribute("data-sharing-id")||null})();if(!t)return void Ma(Ca,"No sharing ID found");!function(){if(Xo())try{const e=Ko();if(!e)return;const t=localStorage.getItem(Jo.SESSION_SHARING_ID);if(t===e)return;t&&(na(),ta()),localStorage.setItem(Jo.SESSION_SHARING_ID,e)}catch(e){console.error("Error resetting session for new store:",e)}}();const i=sa(),r=function(){if(!Xo()||!ea())return null;if(!ia())return null;try{return localStorage.getItem(Jo.BOT_DATA_ETAG)}catch(e){return console.error("Error loading ETag:",e),null}}(),s=`${ya}/bot-sharing-data/${t}`;i&&Ma(Aa);const n=i?[]:[1500,4e3];for(let o=0;;o++)try{const e=r?{"If-None-Match":r}:{},t=await fetch(s,{headers:e});if(304===t.status){if(!i){const e=await Da(s);Na(e.data,t.headers.get("ETag")),Ma(Aa)}return}if(200===t.status){const e=await t.json();if(e.error)throw new Error(e.error);if(!e.data)throw new Error("No data received");return Na(e.data,t.headers.get("ETag")),void Ma(Aa)}throw new Error(`Failed to fetch bot data: ${t.status}`)}catch(e){if(i)return;if(o<n.length){await new Promise(e=>setTimeout(e,n[o]));continue}const t=e instanceof Error?e.message:String(e);return void Ma(Ca,t)}}catch(e){const t=e instanceof Error?e.message:String(e);Ma(Ca,t)}}(),function(){if("undefined"==typeof window)return;const e=window;e.__doriOpenQueue=e.__doriOpenQueue||[];const t=t=>{e.__doriOpenReady||e.__doriOpenQueue.push(t??{})};e.doriWidget=e.doriWidget||{},"function"!=typeof e.doriWidget.open&&(e.doriWidget.open=t),e.addEventListener("dori:open-widget",e=>t(e.detail))}(),"undefined"!=typeof window&&"undefined"!=typeof document&&document.addEventListener("click",e=>function(e,t){if(e.defaultPrevented||0!==e.button)return!1;if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!1;const i=e.target,r=i&&"function"==typeof i.closest?i.closest("a[href]"):null;if(!r)return!1;const s=r.getAttribute("target");if(s&&"_self"!==s)return!1;const n=function(e,t){const i={open:!1,expand:!1};try{const r=new URL(e,t);if(r.origin!==new URL(t).origin)return i;const s=r.searchParams.get("dori-chat")?.trim().toLowerCase();if("open"===s||"expand"===s)return{open:!0,expand:"expand"===s};if("#dori-chat"===r.hash.toLowerCase())return{open:!0,expand:!1}}catch{}return i}(r.getAttribute("href")||"",t);return!!n.open&&(e.preventDefault(),window.doriWidget?.open?.({source:"link",expand:n.expand}),!0)}(e,window.location.href),!0);const Ua=()=>{t(async()=>{const{initializeDoriWidget:e}=await import("./assets/main-BS5x7ctG.js").then(e=>e.h);return{initializeDoriWidget:e}},__vite__mapDeps([2,1]),import.meta.url).then(({initializeDoriWidget:e})=>e()).catch(async e=>{const t=Sa(e);if(t){await new Promise(e=>setTimeout(e,1500));try{const e=await import(xa(t));e.initializeDoriWidget?.()}catch(i){console.error("[Dori Widget] Error initializing widget (after retry):",e,i)}}else console.error("[Dori Widget] Error initializing widget:",e)})};"undefined"!=typeof window&&(window.__doriOpenQueue?.length??0)>0?Ua():function(e,t={}){let i=!1;try{i=window.self!==window.top}catch{i=!0}if(i)return t.onLoadStart?.(),void e();let r=!1;const s=[],n=()=>{if(!r){r=!0;for(const e of s)e();t.onLoadStart?.(),e()}},o=(e,t)=>{"function"==typeof window.requestIdleCallback?window.requestIdleCallback(()=>e(),{timeout:t}):window.setTimeout(e,200)},a=(e,t,i)=>{e.addEventListener(t,i,{once:!0,passive:!0,capture:!0}),s.push(()=>e.removeEventListener(t,i,!0))};for(const h of ba)a(window,h,n);let l=!1;const c=()=>{l||r||(l=!0,o(n,2e3))};for(const h of wa)a(window,h,c);for(const h of t.immediateTargets??[])if(h)for(const e of Ea)a(h,e,n);const u=()=>{if(r)return;const e=window.setTimeout(()=>o(n,1e3),5e3);s.push(()=>window.clearTimeout(e))};"complete"===document.readyState?u():window.addEventListener("load",u,{once:!0})}(Ua);export{ya as A,ka as B,Wo as C,Go as D,ga as E,Bo as F,pa as G,Fa as H,Ta as I,Pa as J,Ia as K,Jo as S,t as _,zo as a,Vo as b,na as c,oa as d,aa as e,ca as f,Ko as g,ha as h,Xo as i,ua as j,fa as k,la as l,Zo as m,s as n,ta as o,Qo as p,va as q,ma as r,ra as s,_a as t,da as u,r as v,Yo as w,sa as x,Lo as y,n as z};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./assets/apply-BQSXIcbI.js","./assets/report-BHr6U1PB.js","./assets/main-BS5x7ctG.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
const e={},t=function(t,i,r){let s=Promise.resolve();if(i&&i.length>0){let t=function(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:"fulfilled",value:e}),e=>({status:"rejected",reason:e}))))};const n=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),a=o?.nonce||o?.getAttribute("nonce");s=t(i.map(t=>{if(t=function(e,t){return new URL(e,t).href}(t,r),t in e)return;e[t]=!0;const i=t.endsWith(".css"),s=i?'[rel="stylesheet"]':"";if(r)for(let e=n.length-1;e>=0;e--){const r=n[e];if(r.href===t&&(!i||"stylesheet"===r.rel))return}else if(document.querySelector(`link[href="${t}"]${s}`))return;const o=document.createElement("link");return o.rel=i?"stylesheet":"modulepreload",i||(o.as="script"),o.crossOrigin="",o.href=t,a&&o.setAttribute("nonce",a),document.head.appendChild(o),i?new Promise((e,i)=>{o.addEventListener("load",e),o.addEventListener("error",()=>i(new Error(`Unable to preload CSS for ${t}`)))}):void 0}))}function n(e){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return s.then(e=>{for(const t of e||[])"rejected"===t.status&&n(t.reason);return t().catch(n)})};let i=null;function r(e){let t=e.replace(/<thought>[\s\S]*?<\/thought>/gi,"");return t=t.replace(/<thought>[\s\S]*$/gi,""),t.trim()}const s=e=>{if(!e)return;const t=e.closest('[data-scroll-container="chat-messages"]');t&&null===i&&(i=setTimeout(()=>{i=null,t.scrollTo({top:t.scrollHeight,behavior:"smooth"})},200))},n=(e,t,i=new Date)=>{const r=e?.feature_flags?.panel_greeting;return"string"==typeof r?r.trim():((e,t,i=new Date)=>{const r=e||"Dori";return`${i.getHours()>=18&&t.hiImEvening?t.hiImEvening:t.hiIm} ${r}!`})(e?.agent_name,t,i)};var o="undefined"!=typeof window?window:void 0,a="undefined"!=typeof globalThis?globalThis:o;"undefined"==typeof self&&(a.self=a),"undefined"==typeof File&&(a.File=function(){});var l=Array.prototype,c=l.forEach,u=l.indexOf,h=null==a?void 0:a.navigator,d=null==a?void 0:a.document,p=null==a?void 0:a.location,g=null==a?void 0:a.fetch,_=null!=a&&a.XMLHttpRequest&&"withCredentials"in new a.XMLHttpRequest?a.XMLHttpRequest:void 0,v=null==a?void 0:a.AbortController,f=null==h?void 0:h.userAgent,m=null!=o?o:{},y={DEBUG:!1,LIB_VERSION:"1.343.2"};function b(e,t,i,r,s,n,o){try{var a=e[n](o),l=a.value}catch(c){return void i(c)}a.done?t(l):Promise.resolve(l).then(r,s)}function w(e){return function(){var t=this,i=arguments;return new Promise(function(r,s){var n=e.apply(t,i);function o(e){b(n,r,s,o,a,"next",e)}function a(e){b(n,r,s,o,a,"throw",e)}o(void 0)})}}function E(){return E=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)({}).hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},E.apply(null,arguments)}function S(e,t){if(null==e)return{};var i={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(-1!==t.indexOf(r))continue;i[r]=e[r]}return i}var x=["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"],k=function(e,t){if(void 0===t&&(t=[]),!e)return!1;var i=e.toLowerCase();return x.concat(t).some(e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)})},I=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function P(e,t){return-1!==e.indexOf(t)}var T=function(e){return e.trim()},F=function(e){return e.replace(/^\$/,"")},R=Array.isArray,$=Object.prototype,O=$.hasOwnProperty,A=$.toString,C=R||function(e){return"[object Array]"===A.call(e)},M=e=>"function"==typeof e,D=e=>e===Object(e)&&!C(e),N=e=>{if(D(e)){for(var t in e)if(O.call(e,t))return!1;return!0}return!1},L=e=>void 0===e,j=e=>"[object String]"==A.call(e),H=e=>j(e)&&0===e.trim().length,U=e=>null===e,q=e=>L(e)||U(e),B=e=>"[object Number]"==A.call(e)&&e==e,G=e=>B(e)&&e>0,V=e=>"[object Boolean]"===A.call(e),W=e=>P(I,e);function z(e){return null===e||"object"!=typeof e}function Y(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"}function J(e){return!L(Event)&&function(e,t){try{return e instanceof t}catch(i){return!1}}(e,Event)}var K=[!0,"true",1,"1","yes"],X=e=>P(K,e),Z=[!1,"false",0,"0","no"];function Q(e,t,i,r,s){return t>i&&(r.warn("min cannot be greater than max."),t=i),B(e)?e>i?(r.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(r.warn(" cannot be less than min: "+t+". Using min value instead."),t):e:(r.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+s),Q(s||i,t,i,r))}class ee{constructor(e){this.t={},this.i=e.i,this.o=Q(e.bucketSize,0,100,e.h),this.m=Q(e.refillRate,0,this.o,e.h),this.$=Q(e.refillInterval,0,864e5,e.h)}S(e,t){var i=t-e.lastAccess,r=Math.floor(i/this.$);if(r>0){var s=r*this.m;e.tokens=Math.min(e.tokens+s,this.o),e.lastAccess=e.lastAccess+r*this.$}}consumeRateLimit(e){var t,i=Date.now(),r=String(e),s=this.t[r];return s?this.S(s,i):(s={tokens:this.o,lastAccess:i},this.t[r]=s),0===s.tokens||(s.tokens--,0===s.tokens&&(null==(t=this.i)||t.call(this,e)),0===s.tokens)}stop(){this.t={}}}var te,ie,re,se="Mobile",ne="iOS",oe="Android",ae="Tablet",le=oe+" "+ae,ce="iPad",ue="Apple",he=ue+" Watch",de="Safari",pe="BlackBerry",ge="Samsung",_e=ge+"Browser",ve=ge+" Internet",fe="Chrome",me=fe+" OS",ye=fe+" "+ne,be="Internet Explorer",we=be+" "+se,Ee="Opera",Se=Ee+" Mini",xe="Edge",ke="Microsoft "+xe,Ie="Firefox",Pe=Ie+" "+ne,Te="Nintendo",Fe="PlayStation",Re="Xbox",$e=oe+" "+se,Oe=se+" "+de,Ae="Windows",Ce=Ae+" Phone",Me="Nokia",De="Ouya",Ne="Generic",Le=Ne+" "+se.toLowerCase(),je=Ne+" "+ae.toLowerCase(),He="Konqueror",Ue="(\\d+(\\.\\d+)?)",qe=new RegExp("Version/"+Ue),Be=new RegExp(Re,"i"),Ge=new RegExp(Fe+" \\w+","i"),Ve=new RegExp(Te+" \\w+","i"),We=new RegExp(pe+"|PlayBook|BB10","i"),ze={"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"},Ye=function(e,t){return t=t||"",P(e," OPR/")&&P(e,"Mini")?Se:P(e," OPR/")?Ee:We.test(e)?pe:P(e,"IE"+se)||P(e,"WPDesktop")?we:P(e,_e)?ve:P(e,xe)||P(e,"Edg/")?ke:P(e,"FBIOS")?"Facebook "+se:P(e,"UCWEB")||P(e,"UCBrowser")?"UC Browser":P(e,"CriOS")?ye:P(e,"CrMo")||P(e,fe)?fe:P(e,oe)&&P(e,de)?$e:P(e,"FxiOS")?Pe:P(e.toLowerCase(),He.toLowerCase())?He:((e,t)=>{return t&&P(t,ue)||P(i=e,de)&&!P(i,fe)&&!P(i,oe);var i})(e,t)?P(e,se)?Oe:de:P(e,Ie)?Ie:P(e,"MSIE")||P(e,"Trident/")?be:P(e,"Gecko")?Ie:""},Je={[we]:[new RegExp("rv:"+Ue)],[ke]:[new RegExp(xe+"?\\/"+Ue)],[fe]:[new RegExp("("+fe+"|CrMo)\\/"+Ue)],[ye]:[new RegExp("CriOS\\/"+Ue)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ue)],[de]:[qe],[Oe]:[qe],[Ee]:[new RegExp("(Opera|OPR)\\/"+Ue)],[Ie]:[new RegExp(Ie+"\\/"+Ue)],[Pe]:[new RegExp("FxiOS\\/"+Ue)],[He]:[new RegExp("Konqueror[:/]?"+Ue,"i")],[pe]:[new RegExp(pe+" "+Ue),qe],[$e]:[new RegExp("android\\s"+Ue,"i")],[ve]:[new RegExp(_e+"\\/"+Ue)],[be]:[new RegExp("(rv:|MSIE )"+Ue)],Mozilla:[new RegExp("rv:"+Ue)]},Ke=function(e,t){var i=Ye(e,t),r=Je[i];if(L(r))return null;for(var s=0;s<r.length;s++){var n=r[s],o=e.match(n);if(o)return parseFloat(o[o.length-2])}return null},Xe=[[new RegExp(Re+"; "+Re+" (.*?)[);]","i"),e=>[Re,e&&e[1]||""]],[new RegExp(Te,"i"),[Te,""]],[new RegExp(Fe,"i"),[Fe,""]],[We,[pe,""]],[new RegExp(Ae,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[Ce,""];if(new RegExp(se).test(t)&&!/IEMobile\b/.test(t))return[Ae+" "+se,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],s=ze[r]||"";return/arm/i.test(t)&&(s="RT"),[Ae,s]}return[Ae,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[ne,t.join(".")]}return[ne,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=L(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+oe+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+oe+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[oe,t.join(".")]}return[oe,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[me,""]],[/Linux|debian/i,["Linux",""]]],Ze=function(e){return Ve.test(e)?Te:Ge.test(e)?Fe:Be.test(e)?Re:new RegExp(De,"i").test(e)?De:new RegExp("("+Ce+"|WPDesktop)","i").test(e)?Ce:/iPad/.test(e)?ce:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?he:We.test(e)?pe:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Me,"i").test(e)?Me:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?new RegExp(se).test(e)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)||/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?oe:le:new RegExp("(pda|"+se+")","i").test(e)?Le:new RegExp(ae,"i").test(e)&&!new RegExp(ae+" pc","i").test(e)?je:""},Qe=e=>e instanceof Error;function et(e){var t=globalThis._posthogChunkIds;if(t){var i=Object.keys(t);return re&&i.length===ie||(ie=i.length,re=i.reduce((i,r)=>{te||(te={});var s=te[r];if(s)i[s[0]]=s[1];else for(var n=e(r),o=n.length-1;o>=0;o--){var a=n[o],l=null==a?void 0:a.filename,c=t[r];if(l&&c){i[l]=c,te[r]=[l,c];break}}return i},{})),re}}class tt{constructor(e,t,i){void 0===i&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){void 0===t&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),s=this.buildParsingContext(t),n=this.parseStacktrace(r,s);return{$exception_list:this.convertToExceptionList(n,i),$exception_level:"error"}}modifyFrames(e){var t=this;return w(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:null==(t=e.syntheticException)?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,r;return null!=e.cause&&(i=this.parseStacktrace(e.cause,t)),""!=e.stack&&null!=e.stack&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),E({},e,{cause:i,stack:r})}applyChunkIds(e,t){return e.map(e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e))}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 w(function*(){var i=e;for(var r of t.modifiers)i=yield r(i);return i})()}convertToExceptionList(e,t){var i,r,s,n={type:e.type,value:e.value,mechanism:{type:null!==(i=t.type)&&void 0!==i?i:"generic",handled:null===(r=t.handled)||void 0===r||r,synthetic:null!==(s=e.synthetic)&&void 0!==s&&s}};e.stack&&(n.stacktrace={type:"raw",frames:e.stack});var o=[n];return null!=e.cause&&o.push(...this.convertToExceptionList(e.cause,E({},t,{handled:!0}))),o}buildParsingContext(e){var t;return{chunkIdMap:et(this.stackParser),skipFirstLines:null!==(t=e.skipFirstLines)&&void 0!==t?t:1}}buildCoercingContext(e,t,i){void 0===i&&(i=0);var r=(i,r)=>{if(r<=4){var s=this.buildCoercingContext(e,t,r);return this.applyCoercers(i,s)}};return E({},t,{syntheticException:0==i?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,i),next:e=>r(e,i+1)})}}var it="?";function rt(e,t,i,r,s){var n={platform:e,filename:t,function:"<anonymous>"===i?it:i,in_app:!0};return L(r)||(n.lineno=r),L(s)||(n.colno=s),n}var st=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:it,i?"safari-extension:"+t:"safari-web-extension:"+t]:[e,t]},nt=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,ot=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,at=/\((\S*)(?::(\d+))(?::(\d+))\)/,lt=(e,t)=>{var i=nt.exec(e);if(i){var[,r,s,n]=i;return rt(t,r,it,+s,+n)}var o=ot.exec(e);if(o){if(o[2]&&0===o[2].indexOf("eval")){var a=at.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,c]=st(o[1]||it,o[2]);return rt(t,c,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},ct=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ut=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,ht=(e,t)=>{var i=ct.exec(e);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var r=ut.exec(i[3]);r&&(i[1]=i[1]||"eval",i[3]=r[1],i[4]=r[2],i[5]="")}var s=i[3],n=i[1]||it;return[n,s]=st(n,s),rt(t,s,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},dt=/\(error: (.*)\)/;class pt{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=j(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 Y(e,"DOMException")}isDOMError(e){return Y(e,"DOMError")}}class gt{match(e){return e instanceof Error}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&&"string"==typeof i.error.message?String(i.error.message):String(i)}getStack(e){return e.stacktrace||e.stack||void 0}}class _t{constructor(){}match(e){return Y(e,"ErrorEvent")&&null!=e.error}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}var vt=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class ft{match(e){return"string"==typeof e}coerce(e,t){var i,[r,s]=this.getInfos(e);return{type:null!=r?r:"Error",value:null!=s?s:e,stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(vt);return r&&(t=r[1],i=r[2]),[t,i]}}var mt=["fatal","error","warning","log","info","debug"];function yt(e,t){void 0===t&&(t=40);var i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var s=i.slice(0,r).join(", ");if(!(s.length>t))return r===i.length||s.length<=t?s:s.slice(0,t)+"..."}return""}class bt{match(e){return"object"==typeof e&&null!==e}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:null==(i=t.syntheticException)?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return J(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&"string"==typeof e.name){var t="'"+e.name+"' captured as exception";return"message"in e&&"string"==typeof e.message&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&"string"==typeof e.message)return e.message;var i=this.getObjectClassName(e);return(i&&"Object"!==i?"'"+i+"'":"Object")+" captured as exception with keys: "+yt(e)}isSeverityLevel(e){return j(e)&&!H(e)&&mt.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if(Object.prototype.hasOwnProperty.call(e,t)){var i=e[t];if(Qe(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch(i){return}}}class wt{match(e){return J(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+yt(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class Et{match(e){return z(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}}}class St{match(e){return Y(e,"PromiseRejectionEvent")}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return z(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:null==(i=t.syntheticException)?void 0:i.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){if(z(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(t){}return e}}var xt=function(e,t){var{debugEnabled:i}=void 0===t?{}:t,r={k:function(t){if(o&&(y.DEBUG||m.POSTHOG_DEBUG||i)&&!L(o.console)&&o.console){for(var r=("__rrweb_original__"in o.console[t]?o.console[t].__rrweb_original__:o.console[t]),s=arguments.length,n=new Array(s>1?s-1:0),a=1;a<s;a++)n[a-1]=arguments[a];r(e,...n)}},info:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("log",...t)},warn:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("warn",...t)},error:function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];r.k("error",...t)},critical:function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];console.error(e,...i)},uninitializedWarning:e=>{r.error("You must initialize PostHog before calling "+e)},createLogger:(t,i)=>xt(e+" "+t,i)};return r},kt=xt("[PostHog.js]"),It=kt.createLogger,Pt=It("[ExternalScriptsLoader]"),Tt=(e,t,i)=>{if(e.config.disable_external_dependency_loading)return Pt.warn(t+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var r=null==d?void 0:d.querySelectorAll("script");if(r)for(var s,n=function(){if(r[o].src===t){var e=r[o];return e.__posthog_loading_callback_fired?{v:i()}:(e.addEventListener("load",t=>{e.__posthog_loading_callback_fired=!0,i(void 0,t)}),e.onerror=e=>i(e),{v:void 0})}},o=0;o<r.length;o++)if(s=n())return s.v;var a=()=>{if(!d)return i("document not found");var r=d.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=t,r.onload=e=>{r.__posthog_loading_callback_fired=!0,i(void 0,e)},r.onerror=e=>i(e),e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return i("prepare_external_dependency_script returned null");if("head"===e.config.external_scripts_inject_target)d.head.appendChild(r);else{var s,n=d.querySelectorAll("body > script");n.length>0?null==(s=n[0].parentNode)||s.insertBefore(r,n[0]):d.body.appendChild(r)}};null!=d&&d.body?a():null==d||d.addEventListener("DOMContentLoaded",a)};m.__PosthogExtensions__=m.__PosthogExtensions__||{},m.__PosthogExtensions__.loadExternalDependency=(e,t,i)=>{var r="/static/"+t+".js?v="+e.version;if("remote-config"===t&&(r="/array/"+e.config.token+"/config.js"),"toolbar"===t){var s=3e5;r=r+"&t="+Math.floor(Date.now()/s)*s}var n=e.requestRouter.endpointFor("assets",r);Tt(e,n,i)},m.__PosthogExtensions__.loadSiteApp=(e,t,i)=>{var r=e.requestRouter.endpointFor("api",t);Tt(e,r,i)};var Ft={};function Rt(e,t,i){if(C(e))if(c&&e.forEach===c)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var r=0,s=e.length;r<s;r++)if(r in e&&t.call(i,e[r],r)===Ft)return}function $t(e,t,i){if(!q(e)){if(C(e))return Rt(e,t,i);if((e=>e instanceof FormData)(e)){for(var r of e.entries())if(t.call(i,r[1],r[0])===Ft)return}else for(var s in e)if(O.call(e,s)&&t.call(i,e[s],s)===Ft)return}}var Ot=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Rt(i,function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])}),e},At=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return Rt(i,function(t){Rt(t,function(t){e.push(t)})}),e};function Ct(e){for(var t=Object.keys(e),i=t.length,r=new Array(i);i--;)r[i]=[t[i],e[t[i]]];return r}var Mt=function(e){try{return e()}catch(t){return}},Dt=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];return e.apply(this,i)}catch(s){kt.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),kt.critical(s)}}},Nt=function(e){var t={};return $t(e,function(e,i){(j(e)&&e.length>0||B(e))&&(t[i]=e)}),t},Lt=["herokuapp.com","vercel.app","netlify.app"];function jt(e){var t=null==e?void 0:e.hostname;if(!j(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of Lt)if(i===r)return!1;return!0}function Ht(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function Ut(e,t,i,r){var{capture:s=!1,passive:n=!0}=null!=r?r:{};null==e||e.addEventListener(t,i,{capture:s,passive:n})}var qt="$people_distinct_id",Bt="__alias",Gt="__timers",Vt="$autocapture_disabled_server_side",Wt="$heatmaps_enabled_server_side",zt="$exception_capture_enabled_server_side",Yt="$error_tracking_suppression_rules",Jt="$error_tracking_capture_extension_exceptions",Kt="$web_vitals_enabled_server_side",Xt="$dead_clicks_enabled_server_side",Zt="$product_tours_enabled_server_side",Qt="$web_vitals_allowed_metrics",ei="$session_recording_remote_config",ti="$sesid",ii="$session_is_sampled",ri="$enabled_feature_flags",si="$early_access_features",ni="$feature_flag_details",oi="$stored_person_properties",ai="$stored_group_properties",li="$surveys",ci="$flag_call_reported",ui="$user_state",hi="$client_session_props",di="$capture_rate_limit",pi="$initial_campaign_params",gi="$initial_referrer_info",_i="$initial_person_info",vi="$epp",fi="__POSTHOG_TOOLBAR__",mi="$posthog_cookieless",yi=[qt,Bt,"__cmpns",Gt,"$session_recording_enabled_server_side",Wt,ti,ri,Yt,ui,si,ni,ai,oi,li,ci,hi,di,pi,gi,vi,_i,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function bi(e){return e instanceof Element&&(e.id===fi||!(null==e.closest||!e.closest(".toolbar-global-fade-container")))}function wi(e){return!!e&&1===e.nodeType}function Ei(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Si(e){return!!e&&3===e.nodeType}function xi(e){return!!e&&11===e.nodeType}function ki(e){return e?T(e).split(/\s+/):[]}function Ii(e){var t=null==o?void 0:o.location.href;return!!(t&&e&&e.some(e=>t.match(e)))}function Pi(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return ki(t)}function Ti(e){return q(e)?null:T(e).split(/(\s+)/).filter(e=>Wi(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Fi(e){var t="";return Li(e)&&!ji(e)&&e.childNodes&&e.childNodes.length&&$t(e.childNodes,function(e){var i;Si(e)&&e.textContent&&(t+=null!==(i=Ti(e.textContent))&&void 0!==i?i:"")}),T(t)}function Ri(e){return L(e.target)?e.srcElement||null:null!=(t=e.target)&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var $i=["a","button","form","input","select","textarea","label"];function Oi(e,t){if(L(t))return!0;var i,r=function(e){if(t.some(t=>e.matches(t)))return{v:!0}};for(var s of e)if(i=r(s))return i.v;return!1}function Ai(e){var t=e.parentNode;return!(!t||!wi(t))&&t}var Ci=["next","previous","prev",">","<"],Mi=[".ph-no-rageclick",".ph-no-capture"],Di=e=>!e||Ei(e,"html")||!wi(e),Ni=(e,t)=>{if(!o||Di(e))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,r=[e],s=e;s.parentNode&&!Ei(s,"body");)if(xi(s.parentNode))r.push(s.parentNode.host),s=s.parentNode.host;else{var n=Ai(s);if(!n)break;if(t||$i.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var a=o.getComputedStyle(n);a&&"pointer"===a.getPropertyValue("cursor")&&(i=!0)}r.push(n),s=n}return{parentIsUsefulElement:i,targetElementList:r}};function Li(e){for(var t=e;t.parentNode&&!Ei(t,"body");t=t.parentNode){var i=Pi(t);if(P(i,"ph-sensitive")||P(i,"ph-no-capture"))return!1}if(P(Pi(e),"ph-include"))return!0;var r=e.type||"";if(j(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var s=e.name||e.id||"";return!j(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 ji(e){return!!(Ei(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Ei(e,"select")||Ei(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var Hi="(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})",Ui=new RegExp("^(?:"+Hi+")$"),qi=new RegExp(Hi),Bi="\\d{3}-?\\d{2}-?\\d{4}",Gi=new RegExp("^("+Bi+")$"),Vi=new RegExp("("+Bi+")");function Wi(e,t){if(void 0===t&&(t=!0),q(e))return!1;if(j(e)){if(e=T(e),(t?Ui:qi).test((e||"").replace(/[- ]/g,"")))return!1;if((t?Gi:Vi).test(e))return!1}return!0}function zi(e){var t=Fi(e);return Wi(t=(t+" "+Yi(e)).trim())?t:""}function Yi(e){var t="";return e&&e.childNodes&&e.childNodes.length&&$t(e.childNodes,function(e){var i;if(e&&"span"===(null==(i=e.tagName)?void 0:i.toLowerCase()))try{var r=Fi(e);t=(t+" "+r).trim(),e.childNodes&&e.childNodes.length&&(t=(t+" "+Yi(e)).trim())}catch(s){kt.error("[AutoCapture]",s)}}),t}function Ji(e){return e.replace(/"|\\"/g,'\\"')}function Ki(e){var t=e.attr__class;return t?C(t)?t:ki(t):void 0}class Xi{constructor(e){this.disabled=!1===e;var t=D(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 r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&i-r.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 Zi=e=>{var t=null==d?void 0:d.createElement("a");return L(t)?null:(t.href=e,t)},Qi=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),s=0;s<r.length;s++){var n=r[s].split("=");if(n[0]===t){i=n;break}}if(!C(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(a){kt.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},er=function(e,t,i){if(!e||!t||!t.length)return e;for(var r=e.split("#"),s=r[0]||"",n=r[1],o=s.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],h=0;h<c.length;h++){var d=c[h].split("=");C(d)&&(t.includes(d[0])?u.push(d[0]+"="+i):u.push(c[h]))}var p=l;return null!=a&&(p+="?"+u.join("&")),null!=n&&(p+="#"+n),p},tr=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},ir="$copy_autocapture",rr=It("[AutoCapture]");function sr(e,t){return t.length>e?t.slice(0,e)+"...":t}function nr(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!wi(t));return t}class or{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new Xi(e.config.rageclick),this.C=null}get R(){var e,t,i=D(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null==(e=i.url_allowlist)?void 0:e.map(e=>new RegExp(e)),i.url_ignorelist=null==(t=i.url_ignorelist)?void 0:t.map(e=>new RegExp(e)),i}F(){if(this.isBrowserSupported()){if(o&&d){var e=e=>{e=e||(null==o?void 0:o.event);try{this.O(e)}catch(pr){rr.error("Failed to capture event",pr)}};if(Ut(d,"submit",e,{capture:!0}),Ut(d,"change",e,{capture:!0}),Ut(d,"click",e,{capture:!0}),this.R.capture_copied_text){var t=e=>{e=e||(null==o?void 0:o.event),this.O(e,ir)};Ut(d,"copy",t,{capture:!0}),Ut(d,"cut",t,{capture:!0})}}}else rr.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({[Vt]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var t,i=[];return null==(t=this.C)||t.forEach(t=>{var r=null==d?void 0:d.querySelectorAll(t);null==r||r.forEach(r=>{e===r&&i.push(t)})}),i}get isEnabled(){var e,t,i=null==(e=this.instance.persistence)?void 0:e.props[Vt],r=this.T;if(U(r)&&!V(i)&&!this.instance.M())return!1;var s=null!==(t=this.T)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!s}O(e,t){if(void 0===t&&(t="$autocapture"),this.isEnabled){var i,r=Ri(e);Si(r)&&(r=r.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent&&this.instance.config.rageclick&&null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,e.timeStamp||(new Date).getTime())&&function(e,t){if(!o||Di(e))return!1;var i,r,s;if(V(t)?(i=!!t&&Mi,r=void 0):(i=null!==(s=null==t?void 0:t.css_selector_ignorelist)&&void 0!==s?s:Mi,r=null==t?void 0:t.content_ignorelist),!1===i)return!1;var{targetElementList:n}=Ni(e,!1);return!function(e,t){if(!1===e||L(e))return!1;var i;if(!0===e)i=Ci;else{if(!C(e))return!1;if(e.length>10)return kt.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;i=e.map(e=>e.toLowerCase())}return t.some(e=>{var{safeText:t,ariaLabel:r}=e;return i.some(e=>t.includes(e)||r.includes(e))})}(r,n.map(e=>{var t;return{safeText:Fi(e).toLowerCase(),ariaLabel:(null==(t=e.getAttribute("aria-label"))?void 0:t.toLowerCase().trim())||""}}))&&!Oi(n,i)}(r,this.instance.config.rageclick)&&this.O(e,"$rageclick");var s=t===ir;if(r&&function(e,t,i,r,s){var n,a,l,c;if(void 0===i&&(i=void 0),!o||Di(e))return!1;if(null!=(n=i)&&n.url_allowlist&&!Ii(i.url_allowlist))return!1;if(null!=(a=i)&&a.url_ignorelist&&Ii(i.url_ignorelist))return!1;if(null!=(l=i)&&l.dom_event_allowlist){var u=i.dom_event_allowlist;if(u&&!u.some(e=>t.type===e))return!1}var{parentIsUsefulElement:h,targetElementList:d}=Ni(e,r);if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(L(i))return!0;var r,s=function(e){if(i.some(t=>e.tagName.toLowerCase()===t))return{v:!0}};for(var n of e)if(r=s(n))return r.v;return!1}(d,i))return!1;if(!Oi(d,null==(c=i)?void 0:c.css_selector_allowlist))return!1;var p=o.getComputedStyle(e);if(p&&"pointer"===p.getPropertyValue("cursor")&&"click"===t.type)return!0;var g=e.tagName.toLowerCase();switch(g){case"html":return!1;case"form":return(s||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(t.type)>=0;default:return h?(s||["click"]).indexOf(t.type)>=0:(s||["click"]).indexOf(t.type)>=0&&($i.indexOf(g)>-1||"true"===e.getAttribute("contenteditable"))}}(r,e,this.R,s,s?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:a}=function(e,t){for(var i,r,{e:s,maskAllElementAttributes:n,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],h=e;h.parentNode&&!Ei(h,"body");)xi(h.parentNode)?(u.push(h.parentNode.host),h=h.parentNode.host):(u.push(h.parentNode),h=h.parentNode);var d,p,g,_=[],v={},f=!1,m=!1;if($t(u,e=>{var t=Li(e);"a"===e.tagName.toLowerCase()&&(f=e.getAttribute("href"),f=t&&f&&Wi(f)&&f),P(Pi(e),"ph-no-capture")&&(m=!0),_.push(function(e,t,i,r){var s=e.tagName.toLowerCase(),n={tag_name:s};$i.indexOf(s)>-1&&!i&&("a"===s.toLowerCase()||"button"===s.toLowerCase()?n.$el_text=sr(1024,zi(e)):n.$el_text=sr(1024,Fi(e)));var o=Pi(e);o.length>0&&(n.classes=o.filter(function(e){return""!==e})),$t(e.attributes,function(i){var s;if((!ji(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&(null==r||!r.includes(i.name))&&!t&&Wi(i.value)&&(s=i.name,!j(s)||"_ngcontent"!==s.substring(0,10)&&"_nghost"!==s.substring(0,7))){var o=i.value;"class"===i.name&&(o=ki(o).join(" ")),n["attr__"+i.name]=sr(1024,o)}});for(var a=1,l=1,c=e;c=nr(c);)a++,c.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}(e,n,a,l));var i=function(e){if(!Li(e))return{};var t={};return $t(e.attributes,function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&Wi(r)&&(t[i]=r)}}),t}(e);Ot(v,i)}),m)return{props:{},explicitNoCapture:m};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?_[0].$el_text=zi(e):_[0].$el_text=Fi(e)),f){var y,b;_[0].attr__href=f;var w=null==(y=Zi(f))?void 0:y.host,S=null==o||null==(b=o.location)?void 0:b.host;w&&S&&w!==S&&(d=f)}return{props:Ot({$event_type:s.type,$ce_version:1},c?{}:{$elements:_},{$elements_chain:(g=_,p=g.map(e=>{var t,i,r={text:null==(t=e.$el_text)?void 0:t.slice(0,400),tag_name:e.tag_name,href:null==(i=e.attr__href)?void 0:i.slice(0,2048),attr_class:Ki(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Ct(e).filter(e=>{var[t]=e;return 0===t.indexOf("attr__")}).forEach(e=>{var[t,i]=e;return r.attributes[t]=i}),r}),p.map(e=>{var t,i,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var s of(e.attr_class.sort(),e.attr_class))r+="."+s.replace(/"/g,"");var n=E({},e.text?{text:e.text}:{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),o={};return Ct(n).sort((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)}).forEach(e=>{var[t,i]=e;return o[Ji(t.toString())]=Ji(i.toString())}),(r+=":")+Ct(o).map(e=>{var[t,i]=e;return t+'="'+i+'"'}).join("")}).join(";"))},null!=(i=_[0])&&i.$el_text?{$el_text:null==(r=_[0])?void 0:r.$el_text}:{},d&&"click"===s.type?{$external_click_url:d}:{},v)}}(r,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(a)return!1;var l=this.getElementSelectors(r);if(l&&l.length>0&&(n.$element_selectors=l),t===ir){var c,u=Ti(null==o||null==(c=o.getSelection())?void 0:c.toString()),h=e.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=h}return this.instance.capture(t,n),!0}}}isBrowserSupported(){return M(null==d?void 0:d.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return B(e)&&isFinite(e)&&Math.floor(e)===e});var ar="0123456789abcdef";class lr{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||e<0||t<0||i<0||r<0||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new lr(s)}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]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new lr(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class cr{constructor(){this.A=0,this.j=0,this.D=new dr}generate(){var e=this.generateOrAbort();if(L(e)){this.A=0;var t=this.generateOrAbort();if(L(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 lr.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 ur,hr=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};o&&!L(o.crypto)&&crypto.getRandomValues&&(hr=e=>crypto.getRandomValues(e));class dr{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(hr(this.N),this.U=0),this.N[this.U++]}}var pr,gr=()=>_r().toString(),_r=()=>(ur||(ur=new cr)).generate(),vr="",fr=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,mr={H:()=>!!d,B:function(e){kt.error("cookieStore error: "+e)},q:function(e){if(d){try{for(var t=e+"=",i=d.cookie.split(";").filter(e=>e.length),r=0;r<i.length;r++){for(var s=i[r];" "==s.charAt(0);)s=s.substring(1,s.length);if(0===s.indexOf(t))return decodeURIComponent(s.substring(t.length,s.length))}}catch(n){}return null}},W:function(e){var t;try{t=JSON.parse(mr.q(e))||{}}catch(i){}return t},G:function(e,t,i,r,s){if(d)try{var n="",o="",a=function(e,t){if(t){var i=function(e,t){if(void 0===t&&(t=d),vr)return vr;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),s="dmn_chk_"+gr();!vr&&r--;){var n=i.slice(r).join("."),o=s+"=1;domain=."+n+";path=/";t.cookie=o+";max-age=3",t.cookie.includes(s)&&(t.cookie=o+";max-age=0",vr=n)}return vr}(e);if(!i){var r=(s=e.match(fr))?s[0]:"";r!==i&&kt.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}var s;return""}(d.location.hostname,r);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),n="; expires="+l.toUTCString()}s&&(o="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&kt.warn("cookieStore warning: large cookie, len="+c.length),d.cookie=c,c}catch(u){return}},V:function(e,t){if(null!=d&&d.cookie)try{mr.G(e,"",-1,t)}catch(i){return}}},yr=null,br={H:function(){if(!U(yr))return yr;var e=!0;if(L(o))e=!1;else try{var t="__mplssupport__";br.G(t,"xyz"),'"xyz"'!==br.q(t)&&(e=!1),br.V(t)}catch(pr){e=!1}return e||kt.error("localStorage unsupported; falling back to cookie store"),yr=e,e},B:function(e){kt.error("localStorage error: "+e)},q:function(e){try{return null==o?void 0:o.localStorage.getItem(e)}catch(pr){br.B(pr)}return null},W:function(e){try{return JSON.parse(br.q(e))||{}}catch(t){}return null},G:function(e,t){try{null==o||o.localStorage.setItem(e,JSON.stringify(t))}catch(pr){br.B(pr)}},V:function(e){try{null==o||o.localStorage.removeItem(e)}catch(pr){br.B(pr)}}},wr=["$device_id","distinct_id",ti,ii,vi,_i],Er={},Sr={H:function(){return!0},B:function(e){kt.error("memoryStorage error: "+e)},q:function(e){return Er[e]||null},W:function(e){return Er[e]||null},G:function(e,t){Er[e]=t},V:function(e){delete Er[e]}},xr=null,kr={H:function(){if(!U(xr))return xr;if(xr=!0,L(o))xr=!1;else try{var e="__support__";kr.G(e,"xyz"),'"xyz"'!==kr.q(e)&&(xr=!1),kr.V(e)}catch(pr){xr=!1}return xr},B:function(e){kt.error("sessionStorage error: ",e)},q:function(e){try{return null==o?void 0:o.sessionStorage.getItem(e)}catch(pr){kr.B(pr)}return null},W:function(e){try{return JSON.parse(kr.q(e))||null}catch(t){}return null},G:function(e,t){try{null==o||o.sessionStorage.setItem(e,JSON.stringify(t))}catch(pr){kr.B(pr)}},V:function(e){try{null==o||o.sessionStorage.removeItem(e)}catch(pr){kr.B(pr)}}},Ir=((pr={})[pr.PENDING=-1]="PENDING",pr[pr.DENIED=0]="DENIED",pr[pr.GRANTED=1]="GRANTED",pr);class Pr{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?Ir.DENIED:this.K}isOptedOut(){return"always"===this.R.cookieless_mode||this.consent===Ir.DENIED||this.consent===Ir.PENDING&&(this.R.opt_out_capturing_by_default||"on_reject"===this.R.cookieless_mode)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Ir.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 X(e)?Ir.GRANTED:P(Z,e)?Ir.DENIED:Ir.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z="localStorage"===e?br:mr;var t="localStorage"===e?mr:br;t.q(this.X)&&(this.Z.q(this.X)||this.optInOut(X(t.q(this.X))),t.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!Ht([null==h?void 0:h.doNotTrack,null==h?void 0:h.msDoNotTrack,m.doNotTrack],e=>X(e))}}var Tr=It("[Dead Clicks]"),Fr=()=>!0,Rr=e=>{var t,i=!(null==(t=e.instance.persistence)||!t.get_property(Xt)),r=e.instance.config.capture_dead_clicks;return V(r)?r:!!D(r)||i};class $r{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[Xt]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it(()=>{this.et()})}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.initDeadClicksAutocapture&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",t=>{t?Tr.error("failed to load script",t):e()})}et(){var e;if(d){if(!this.tt&&null!=(e=m.__PosthogExtensions__)&&e.initDeadClicksAutocapture){var t=D(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.tt=m.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.tt.start(d),Tr.info("starting...")}}else Tr.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Tr.info("stopping..."))}}var Or=It("[ExceptionAutocapture]");class Ar{constructor(e){var t,i,r;this.rt=()=>{var e;if(o&&this.isEnabled&&null!=(e=m.__PosthogExtensions__)&&e.errorWrappingFunctions){var t=m.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,i=m.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=m.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=t(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=i(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=r(this.captureException.bind(this)))}catch(pr){Or.error("failed to start",pr),this.ut()}}},this._instance=e,this.ht=!(null==(t=this._instance.persistence)||!t.props[zt]),this.dt=new ee({refillRate:null!==(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)&&void 0!==i?i:1,bucketSize:null!==(r=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)&&void 0!==r?r:10,refillInterval:1e4,h:Or}),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 D(e)?t=E({},t,e):(L(e)?this.ht:e)&&(t=E({},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?(Or.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.errorWrappingFunctions&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"exception-autocapture",t=>{if(t)return Or.error("failed to load script",t);e()})}ut(){var e,t,i;null==(e=this.st)||e.call(this),this.st=void 0,null==(t=this.nt)||t.call(this),this.nt=void 0,null==(i=this.ot)||i.call(this),this.ot=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.ht=!!t||!1,this._instance.persistence&&this._instance.persistence.register({[zt]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var t,i,r=null!==(t=null==e||null==(i=e.$exception_list)||null==(i=i[0])?void 0:i.type)&&void 0!==t?t:"Exception";this.dt.consumeRateLimit(r)?Or.info("Skipping exception capture because of client rate limiting.",{exception:r}):this._instance.exceptions.sendExceptionEvent(e)}}function Cr(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],s=i(r);return M(s)&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=s,()=>{e[t]=r}}catch(n){return()=>{}}}class Mr{constructor(e){var t;this._instance=e,this.ct=(null==o||null==(t=o.location)?void 0:t.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(kt.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,kt.info("History API monitoring stopped")}monitorHistoryChanges(){var e,t;if(o&&o.history){var i=this;null!=(e=o.history.pushState)&&e.__posthog_wrapped__||Cr(o.history,"pushState",e=>function(t,r,s){e.call(this,t,r,s),i._t("pushState")}),null!=(t=o.history.replaceState)&&t.__posthog_wrapped__||Cr(o.history,"replaceState",e=>function(t,r,s){e.call(this,t,r,s),i._t("replaceState")}),this.bt()}}_t(e){try{var t,i=null==o||null==(t=o.location)?void 0:t.pathname;if(!i)return;i!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=i}catch(pr){kt.error("Error capturing "+e+" pageview",pr)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};Ut(o,"popstate",e),this.ft=()=>{o&&o.removeEventListener("popstate",e)}}}}var Dr=It("[SegmentIntegration]"),Nr="posthog-js";function Lr(e,t){var{organization:i,projectId:r,prefix:s,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=void 0===t?{}:t;return t=>{var a,l,c,u,h;if("*"!==n&&!n.includes(t.level)||!e.__loaded)return t;t.tags||(t.tags={});var d=e.requestRouter.endpointFor("ui","/project/"+e.config.token+"/person/"+e.get_distinct_id());t.tags["PostHog Person URL"]=d,e.sessionRecordingStarted()&&(t.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var p=(null==(a=t.exception)?void 0:a.values)||[],g=p.map(e=>E({},e,{stacktrace:e.stacktrace?E({},e.stacktrace,{type:"raw",frames:(e.stacktrace.frames||[]).map(e=>E({},e,{platform:"web:javascript"}))}):void 0})),_={$exception_message:(null==(l=p[0])?void 0:l.value)||t.message,$exception_type:null==(c=p[0])?void 0:c.type,$exception_level:t.level,$exception_list:g,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:(null==(u=p[0])?void 0:u.value)||t.message,$sentry_exception_type:null==(h=p[0])?void 0:h.type,$sentry_tags:t.tags};return i&&r&&(_.$sentry_url=(s||"https://sentry.io/organizations/")+i+"/issues/?project="+r+"&query="+t.event_id),o&&e.exceptions.sendExceptionEvent(_),t}}class jr{constructor(e,t,i,r,s,n){this.name=Nr,this.setupOnce=function(o){o(Lr(e,{organization:t,projectId:i,prefix:r,severityAllowList:s,sendExceptionsToPostHog:null==n||n}))}}}var Hr=null!=o&&o.location?tr(o.location.hash,"__posthog")||tr(location.hash,"state"):null,Ur="_postHogToolbarParams",qr=It("[Toolbar]"),Br=function(e){return e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED",e}(Br||{});class Gr{constructor(e){this.instance=e}yt(e){m.ph_toolbar_state=e}wt(){var e;return null!==(e=m.ph_toolbar_state)&&void 0!==e?e:Br.UNINITIALIZED}maybeLoadToolbar(e,t,i){if(void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),!o||!d)return!1;e=null!=e?e:o.location,i=null!=i?i:o.history;try{if(!t){try{o.localStorage.setItem("test","test"),o.localStorage.removeItem("test")}catch(pr){return!1}t=null==o?void 0:o.localStorage}var r,s=Hr||tr(e.hash,"__posthog")||tr(e.hash,"state"),n=s?Mt(()=>JSON.parse(atob(decodeURIComponent(s))))||Mt(()=>JSON.parse(decodeURIComponent(s))):null;return n&&"ph_authorize"===n.action?((r=n).source="url",r&&Object.keys(r).length>0&&(n.desiredHash?e.hash=n.desiredHash:i?i.replaceState(i.state,"",e.pathname+e.search):e.hash="")):((r=JSON.parse(t.getItem(Ur)||"{}")).source="localstorage",delete r.userIntent),!(!r.token||this.instance.config.token!==r.token||(this.loadToolbar(r),0))}catch(pr){return!1}}xt(e){var t=m.ph_load_toolbar||m.ph_load_editor;!q(t)&&M(t)?t(e,this.instance):qr.warn("No toolbar load function found")}loadToolbar(e){var t=!(null==d||!d.getElementById(fi));if(!o||t)return!1;var i="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=E({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(o.localStorage.setItem(Ur,JSON.stringify(E({},r,{source:void 0}))),this.wt()===Br.LOADED)this.xt(r);else if(this.wt()===Br.UNINITIALIZED){var s;this.yt(Br.LOADING),null==(s=m.__PosthogExtensions__)||null==s.loadExternalDependency||s.loadExternalDependency(this.instance,"toolbar",e=>{if(e)return qr.error("[Toolbar] Failed to load",e),void this.yt(Br.UNINITIALIZED);this.yt(Br.LOADED),this.xt(r)}),Ut(o,"turbolinks:load",()=>{this.yt(Br.UNINITIALIZED),this.loadToolbar(r)})}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,i){return void 0===e&&(e=void 0),void 0===t&&(t=void 0),void 0===i&&(i=void 0),this.maybeLoadToolbar(e,t,i)}}var Vr=It("[TracingHeaders]");class Wr{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var e,t;L(this.$t)&&(null==(e=m.__PosthogExtensions__)||null==(e=e.tracingHeadersPatchFns)||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),L(this.St)&&(null==(t=m.__PosthogExtensions__)||null==(t=t.tracingHeadersPatchFns)||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.tracingHeadersPatchFns&&e(),null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"tracing-headers",t=>{if(t)return Vr.error("failed to load script",t);e()})}startIfEnabledOrStop(){var e,t;this._instance.config.__add_tracing_headers?this.it(this.rt):(null==(e=this.$t)||e.call(this),null==(t=this.St)||t.call(this),this.$t=void 0,this.St=void 0)}}var zr="https?://(.*)",Yr=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Jr=At(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Yr),Kr="<masked>",Xr=["li_fat_id"];function Zr(e,t,i){if(!d)return{};var r,s=t?At([],Yr,i||[]):[],n=Qr(er(d.URL,s,Kr),e),o=(r={},$t(Xr,function(e){var t=mr.q(e);r[e]=t||null}),r);return Ot(o,n)}function Qr(e,t){var i=Jr.concat(t||[]),r={};return $t(i,function(t){var i=Qi(e,t);r[t]=i||null}),r}function es(e){var t,i=(t=e)?0===t.search(zr+"google.([^/?]*)")?"google":0===t.search(zr+"bing.com")?"bing":0===t.search(zr+"yahoo.com")?"yahoo":0===t.search(zr+"duckduckgo.com")?"duckduckgo":null:null,r="yahoo"!=i?"q":"p",s={};if(!U(i)){s.$search_engine=i;var n=d?Qi(d.referrer,r):"";n.length&&(s.ph_keyword=n)}return s}function ts(){return navigator.language||navigator.userLanguage}function is(){return(null==d?void 0:d.referrer)||"$direct"}function rs(e,t){var i=e?At([],Yr,t||[]):[],r=null==p?void 0:p.href.substring(0,1e3);return{r:is().substring(0,1e3),u:r?er(r,i,Kr):void 0}}function ss(e){var t,{r:i,u:r}=e,s={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null==(t=Zi(i))?void 0:t.host};if(r){s.$current_url=r;var n=Zi(r);s.$host=null==n?void 0:n.host,s.$pathname=null==n?void 0:n.pathname;var o=Qr(r);Ot(s,o)}if(i){var a=es(i);Ot(s,a)}return s}function ns(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(pr){return}}function os(){try{return(new Date).getTimezoneOffset()}catch(pr){return}}var as=It("[Web Vitals]"),ls=9e5;class cs{constructor(e){var t;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),0!==this.N.metrics.length&&(this._instance.capture("$web_vitals",this.N.metrics.reduce((e,t)=>E({},e,{["$web_vitals_"+t.name+"_event"]:E({},t),["$web_vitals_"+t.name+"_value"]:t.value}),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=e=>{var t,i=null==(t=this._instance.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0);if(L(i))as.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this.Ct();L(r)||(q(null==e?void 0:e.name)||q(null==e?void 0:e.value)?as.error("Invalid metric received",e):this.Rt&&e.value>=this.Rt?as.error("Ignoring metric with value >= "+this.Rt,e):(this.N.url!==r&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),L(this.N.url)&&(this.N.url=r),this.N.firstMetricTimestamp=L(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.N.metrics.push(E({},e,{$current_url:r,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{if(!this.P){var e,t,i,r,s=m.__PosthogExtensions__;L(s)||L(s.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=s.postHogWebVitalsCallbacks),e&&t&&i&&r?(this.allowedMetrics.indexOf("LCP")>-1&&e(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&r(this.It.bind(this)),this.P=!0):as.error("web vitals callbacks not loaded - not starting")}},this._instance=e,this.kt=!(null==(t=this._instance.persistence)||!t.props[Kt]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=D(this._instance.config.capture_performance)?null==(e=this._instance.config.capture_performance)?void 0:e.web_vitals_allowed_metrics:void 0;return q(i)?(null==(t=this._instance.persistence)?void 0:t.props[Qt])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_attribution:void 0;return null!=e&&e}get Rt(){var e=D(this._instance.config.capture_performance)&&B(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:ls;return 0<e&&e<=6e4?ls:e}get isEnabled(){var e=null==p?void 0:p.protocol;if("http:"!==e&&"https:"!==e)return as.info("Web Vitals are disabled on non-http/https protocols"),!1;var t=D(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:V(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return V(t)?t:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(as.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var t=D(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=D(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Kt]:t}),this._instance.persistence.register({[Qt]:i})),this.kt=t,this.startIfEnabled()}it(e){var t,i;if(null!=(t=m.__PosthogExtensions__)&&t.postHogWebVitalsCallbacks)e();else{var r=this.useAttribution?"web-vitals-with-attribution":"web-vitals";null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,r,t=>{t?as.error("failed to load script",t):e()})}}Ct(){var e=o?o.location.href:void 0;if(e){var t=this._instance.config.mask_personal_data_properties,i=this._instance.config.custom_personal_data_properties,r=t?At([],Yr,i||[]):[];return er(e,r,Kr)}as.error("Could not determine current URL")}}var us=It("[Heatmaps]");function hs(e){return D(e)&&"clientX"in e&&"clientY"in e&&B(e.clientX)&&B(e.clientY)}class ds{constructor(e){var t;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!(null==(t=this.instance.persistence)||!t.props[Wt]),this.rageclicks=new Xi(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return D(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 q(this.instance.config.capture_heatmaps)?q(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.P)return;us.info("starting..."),this.Ot(),this.Mt()}else{var e;clearInterval(null!==(e=this.Ft)&&void 0!==e?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Wt]: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="visible"===(null==d?void 0:d.visibilityState)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Ot(){o&&d&&(this.Nt=this.Lt.bind(this),Ut(o,"beforeunload",this.Nt),this.Ut=e=>this.Dt(e||(null==o?void 0:o.event)),Ut(d,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||(null==o?void 0:o.event)),Ut(d,"mousemove",this.zt,{capture:!0}),this.Bt=new $r(this.instance,Fr,this.jt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Mt.bind(this),Ut(d,"visibilitychange",this.qt),this.P=!0)}At(){var e;o&&d&&(this.Nt&&o.removeEventListener("beforeunload",this.Nt),this.Ut&&d.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&d.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&d.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),null==(e=this.Bt)||e.stop(),this.P=!1)}Gt(e,t){var i=this.instance.scrollManager.scrollY(),r=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),n=function(e,t,i){for(var r=e;r&&wi(r)&&!Ei(r,"body");){if(r===i)return!1;if(P(t,null==o?void 0:o.getComputedStyle(r).position))return!0;r=Ai(r)}return!1}(Ri(e),["fixed","sticky"],s);return{x:e.clientX+(n?0:r),y:e.clientY+(n?0:i),target_fixed:n,type:t}}Dt(e,t){var i;if(void 0===t&&(t="click"),!bi(e.target)&&hs(e)){var r=this.Gt(e,t);null!=(i=this.rageclicks)&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this.Vt(E({},r,{type:"rageclick"})),this.Vt(r)}}Ht(e){!bi(e.target)&&hs(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout(()=>{this.Vt(this.Gt(e,"mousemove"))},500))}Vt(e){if(o){var t=o.location.href,i=this.instance.config.mask_personal_data_properties,r=this.instance.config.custom_personal_data_properties,s=i?At([],Yr,r||[]):[],n=er(t,s,Kr);this.N=this.N||{},this.N[n]||(this.N[n]=[]),this.N[n].push(e)}}Lt(){this.N&&!N(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class ps{constructor(e){this.Jt=(e,t,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength)&&(kt.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this.Kt=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.Yt()}Yt(){var e;this.Xt=null==(e=this._instance.sessionManager)?void 0:e.onSessionId(this.Jt)}destroy(){var e;null==(e=this.Xt)||e.call(this),this.Xt=void 0}doPageView(e,t){var i,r=this.Qt(e,t);return this.Kt={pathname:null!==(i=null==o?void 0:o.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.Qt(e,null==(t=this.Kt)?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null==(e=this.Kt)?void 0:e.pageViewId}}Qt(e,t){var i=this.Kt;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},s=this._instance.scrollManager.getContext();if(s&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=s;if(!(L(n)||L(o)||L(a)||L(l)||L(c)||L(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var h=n<=1?1:Q(o/n,0,1,kt),d=n<=1?1:Q(a/n,0,1,kt),p=l<=1?1:Q(c/l,0,1,kt),g=l<=1?1:Q(u/l,0,1,kt);r=Ot(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:g})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}var gs=function(e){return e.GZipJS="gzip-js",e.Base64="base64",e}({}),_s=Uint8Array,vs=Uint16Array,fs=Uint32Array,ms=new _s([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]),ys=new _s([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]),bs=new _s([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ws=function(e,t){for(var i=new vs(31),r=0;r<31;++r)i[r]=t+=1<<e[r-1];var s=new fs(i[30]);for(r=1;r<30;++r)for(var n=i[r];n<i[r+1];++n)s[n]=n-i[r]<<5|r;return[i,s]},Es=ws(ms,2),Ss=Es[0],xs=Es[1];Ss[28]=258,xs[258]=28;for(var ks=ws(ys,0)[1],Is=new vs(32768),Ps=0;Ps<32768;++Ps){var Ts=(43690&Ps)>>>1|(21845&Ps)<<1;Ts=(61680&(Ts=(52428&Ts)>>>2|(13107&Ts)<<2))>>>4|(3855&Ts)<<4,Is[Ps]=((65280&Ts)>>>8|(255&Ts)<<8)>>>1}var Fs=function(e,t,i){for(var r=e.length,s=0,n=new vs(t);s<r;++s)++n[e[s]-1];var o,a=new vs(t);for(s=0;s<t;++s)a[s]=a[s-1]+n[s-1]<<1;for(o=new vs(r),s=0;s<r;++s)o[s]=Is[a[e[s]-1]++]>>>15-e[s];return o},Rs=new _s(288);for(Ps=0;Ps<144;++Ps)Rs[Ps]=8;for(Ps=144;Ps<256;++Ps)Rs[Ps]=9;for(Ps=256;Ps<280;++Ps)Rs[Ps]=7;for(Ps=280;Ps<288;++Ps)Rs[Ps]=8;var $s=new _s(32);for(Ps=0;Ps<32;++Ps)$s[Ps]=5;var Os=Fs(Rs,9),As=Fs($s,5),Cs=function(e){return(e/8|0)+(7&e&&1)},Ms=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof vs?vs:e instanceof fs?fs:_s)(i-t);return r.set(e.subarray(t,i)),r},Ds=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>>8},Ns=function(e,t,i){i<<=7&t;var r=t/8|0;e[r]|=i,e[r+1]|=i>>>8,e[r+2]|=i>>>16},Ls=function(e,t){for(var i=[],r=0;r<e.length;++r)e[r]&&i.push({s:r,f:e[r]});var s=i.length,n=i.slice();if(!s)return[new _s(0),0];if(1==s){var o=new _s(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort(function(e,t){return e.f-t.f}),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,h=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=s-1;)a=i[i[c].f<i[h].f?c++:h++],l=i[c!=u&&i[c].f<i[h].f?c++:h++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var d=n[0].s;for(r=1;r<s;++r)n[r].s>d&&(d=n[r].s);var p=new vs(d+1),g=js(i[u-1],p,0);if(g>t){r=0;var _=0,v=g-t,f=1<<v;for(n.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<s;++r){var m=n[r].s;if(!(p[m]>t))break;_+=f-(1<<g-p[m]),p[m]=t}for(_>>>=v;_>0;){var y=n[r].s;p[y]<t?_-=1<<t-p[y]++-1:++r}for(;r>=0&&_;--r){var b=n[r].s;p[b]==t&&(--p[b],++_)}g=t}return[new _s(p),g]},js=function(e,t,i){return-1==e.s?Math.max(js(e.l,t,i+1),js(e.r,t,i+1)):t[e.s]=i},Hs=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new vs(++t),r=0,s=e[0],n=1,o=function(e){i[r++]=e},a=1;a<=t;++a)if(e[a]==s&&a!=t)++n;else{if(!s&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(s),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(s);n=1,s=e[a]}return[i.subarray(0,r),t]},Us=function(e,t){for(var i=0,r=0;r<t.length;++r)i+=e[r]*t[r];return i},qs=function(e,t,i){var r=i.length,s=Cs(t+2);e[s]=255&r,e[s+1]=r>>>8,e[s+2]=255^e[s],e[s+3]=255^e[s+1];for(var n=0;n<r;++n)e[s+n+4]=i[n];return 8*(s+4+r)},Bs=function(e,t,i,r,s,n,o,a,l,c,u){Ds(t,u++,i),++s[256];for(var h=Ls(s,15),d=h[0],p=h[1],g=Ls(n,15),_=g[0],v=g[1],f=Hs(d),m=f[0],y=f[1],b=Hs(_),w=b[0],E=b[1],S=new vs(19),x=0;x<m.length;++x)S[31&m[x]]++;for(x=0;x<w.length;++x)S[31&w[x]]++;for(var k=Ls(S,7),I=k[0],P=k[1],T=19;T>4&&!I[bs[T-1]];--T);var F,R,$,O,A=c+5<<3,C=Us(s,Rs)+Us(n,$s)+o,M=Us(s,d)+Us(n,_)+o+14+3*T+Us(S,I)+(2*S[16]+3*S[17]+7*S[18]);if(A<=C&&A<=M)return qs(t,u,e.subarray(l,l+c));if(Ds(t,u,1+(M<C)),u+=2,M<C){F=Fs(d,p),R=d,$=Fs(_,v),O=_;var D=Fs(I,P);for(Ds(t,u,y-257),Ds(t,u+5,E-1),Ds(t,u+10,T-4),u+=14,x=0;x<T;++x)Ds(t,u+3*x,I[bs[x]]);u+=3*T;for(var N=[m,w],L=0;L<2;++L){var j=N[L];for(x=0;x<j.length;++x){var H=31&j[x];Ds(t,u,D[H]),u+=I[H],H>15&&(Ds(t,u,j[x]>>>5&127),u+=j[x]>>>12)}}}else F=Os,R=Rs,$=As,O=$s;for(x=0;x<a;++x)if(r[x]>255){H=r[x]>>>18&31,Ns(t,u,F[H+257]),u+=R[H+257],H>7&&(Ds(t,u,r[x]>>>23&31),u+=ms[H]);var U=31&r[x];Ns(t,u,$[U]),u+=O[U],U>3&&(Ns(t,u,r[x]>>>5&8191),u+=ys[U])}else Ns(t,u,F[r[x]]),u+=R[r[x]];return Ns(t,u,F[256]),u+R[256]},Gs=new fs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Vs=function(){for(var e=new fs(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Ws=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8};var zs=!!_||!!g,Ys="text/plain",Js=function(e,t,i){var r;void 0===i&&(i=!0);var[s,n]=e.split("?"),o=E({},t),a=null!==(r=null==n?void 0:n.split("&").map(e=>{var t,[r,s]=e.split("="),n=i&&null!==(t=o[r])&&void 0!==t?t:s;return delete o[r],r+"="+n}))&&void 0!==r?r:[],l=function(e,t){var i,r;void 0===t&&(t="&");var s=[];return $t(e,function(e,t){L(e)||L(t)||"undefined"===t||(i=encodeURIComponent(e instanceof File?e.name:e.toString()),r=encodeURIComponent(t),s[s.length]=r+"="+i)}),s.join(t)}(o);return l&&a.push(l),s+"?"+a.join("&")},Ks=(e,t)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,t),Xs=e=>{var t,{data:i,compression:r}=e;if(i){if(r===gs.GZipJS){var s=function(e,t){void 0===t&&(t={});var i=function(){var e=4294967295;return{p:function(t){for(var i=e,r=0;r<t.length;++r)i=Vs[255&i^t[r]]^i>>>8;e=i},d:function(){return 4294967295^e}}}(),r=e.length;i.p(e);var s,n=function(e,t,i){return function(e,t,i,r){var s=e.length,n=new _s(r+s+5*(1+Math.floor(s/7e3))+8),o=n.subarray(r,n.length-8),a=0;if(!t||s<8)for(var l=0;l<=s;l+=65535){var c=l+65535;c<s?a=qs(o,a,e.subarray(l,c)):(o[l]=!0,a=qs(o,a,e.subarray(l,s)))}else{for(var u=Gs[t-1],h=u>>>13,d=8191&u,p=(1<<i)-1,g=new vs(32768),_=new vs(p+1),v=Math.ceil(i/3),f=2*v,m=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<f)&p},y=new fs(25e3),b=new vs(288),w=new vs(32),E=0,S=0,x=(l=0,0),k=0,I=0;l<s;++l){var P=m(l),T=32767&l,F=_[P];if(g[T]=F,_[P]=T,k<=l){var R=s-l;if((E>7e3||x>24576)&&R>423){a=Bs(e,o,0,y,b,w,S,x,I,l-I,a),x=E=S=0,I=l;for(var $=0;$<286;++$)b[$]=0;for($=0;$<30;++$)w[$]=0}var O=2,A=0,C=d,M=T-F&32767;if(R>2&&P==m(l-M))for(var D=Math.min(h,R)-1,N=Math.min(32767,l),L=Math.min(258,R);M<=N&&--C&&T!=F;){if(e[l+O]==e[l+O-M]){for(var j=0;j<L&&e[l+j]==e[l+j-M];++j);if(j>O){if(O=j,A=M,j>D)break;var H=Math.min(M,j-2),U=0;for($=0;$<H;++$){var q=l-M+$+32768&32767,B=q-g[q]+32768&32767;B>U&&(U=B,F=q)}}}M+=(T=F)-(F=g[T])+32768&32767}if(A){y[x++]=268435456|xs[O]<<18|ks[A];var G=31&xs[O],V=31&ks[A];S+=ms[G]+ys[V],++b[257+G],++w[V],k=l+O,++E}else y[x++]=e[l],++b[e[l]]}}a=Bs(e,o,!0,y,b,w,S,x,I,l-I,a)}return Ms(n,0,r+Cs(a)+8)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i)}(e,t,10+((s=t).filename&&s.filename.length+1||0)),o=n.length;return function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Ws(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}}(n,t),Ws(n,o-8,i.d()),Ws(n,o-4,r),n}(function(e){var t=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var i=new _s(e.length+(e.length>>>1)),r=0,s=function(e){i[r++]=e},n=0;n<t;++n){if(r+5>i.length){var o=new _s(r+8+(t-n<<1));o.set(i),i=o}var a=e.charCodeAt(n);a<128?s(a):a<2048?(s(192|a>>>6),s(128|63&a)):a>55295&&a<57344?(s(240|(a=65536+(1047552&a)|1023&e.charCodeAt(++n))>>>18),s(128|a>>>12&63),s(128|a>>>6&63),s(128|63&a)):(s(224|a>>>12),s(128|a>>>6&63),s(128|63&a))}return Ms(i,0,r)}(Ks(i)),{mtime:0}),n=new Blob([s],{type:Ys});return{contentType:Ys,body:n,estimatedSize:n.size}}if(r===gs.Base64){var o=function(e){var t,i,r,s,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,c="",u=[];if(!e)return e;e=function(e){var t,i,r,s,n="";for(t=i=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s<r;s++){var o=e.charCodeAt(s),a=null;o<128?i++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),U(a)||(i>t&&(n+=e.substring(t,i)),n+=a,t=i=s+1)}return i>t&&(n+=e.substring(t,e.length)),n}(e);do{t=(n=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=n>>12&63,r=n>>6&63,s=63&n,u[l++]=o.charAt(t)+o.charAt(i)+o.charAt(r)+o.charAt(s)}while(a<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(Ks(i)),a=(t=o,"data="+encodeURIComponent("string"==typeof t?t:Ks(t)));return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var l=Ks(i);return{contentType:"application/json",body:l,estimatedSize:new Blob([l]).size}}},Zs=[];g&&Zs.push({transport:"fetch",method:e=>{var t,i,{contentType:r,body:s,estimatedSize:n}=null!==(t=Xs(e))&&void 0!==t?t:{},o=new Headers;$t(e.headers,function(e,t){o.append(t,e)}),r&&o.append("Content-Type",r);var a=e.url,l=null;if(v){var c=new v;l={signal:c.signal,timeout:setTimeout(()=>c.abort(),e.timeout)}}g(a,E({method:(null==e?void 0:e.method)||"GET",headers:o,keepalive:"POST"===e.method&&(n||0)<52428.8,body:s,signal:null==(i=l)?void 0:i.signal},e.fetchOptions)).then(t=>t.text().then(i=>{var r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(s){kt.error(s)}null==e.callback||e.callback(r)})).catch(t=>{kt.error(t),null==e.callback||e.callback({statusCode:0,text:t})}).finally(()=>l?clearTimeout(l.timeout):null)}}),_&&Zs.push({transport:"XHR",method:e=>{var t,i=new _;i.open(e.method||"GET",e.url,!0);var{contentType:r,body:s}=null!==(t=Xs(e))&&void 0!==t?t:{};$t(e.headers,function(e,t){i.setRequestHeader(t,e)}),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout),e.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(4===i.readyState){var t={statusCode:i.status,text:i.responseText};if(200===i.status)try{t.json=JSON.parse(i.responseText)}catch(r){}null==e.callback||e.callback(t)}},i.send(s)}}),null!=h&&h.sendBeacon&&Zs.push({transport:"sendBeacon",method:e=>{var t=Js(e.url,{beacon:"1"});try{var i,{contentType:r,body:s}=null!==(i=Xs(e))&&void 0!==i?i:{},n="string"==typeof s?new Blob([s],{type:r}):s;h.sendBeacon(t,n)}catch(o){}}});var Qs=function(e,t){if(!function(){return!0}())return!1;try{return new RegExp(t).test(e)}catch(i){return!1}};function en(e,t,i){return Ks({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}var tn={exact:(e,t)=>t.some(t=>e.some(e=>t===e)),is_not:(e,t)=>t.every(t=>e.every(e=>t!==e)),regex:(e,t)=>t.some(t=>e.some(e=>Qs(t,e))),not_regex:(e,t)=>t.every(t=>e.every(e=>!Qs(t,e))),icontains:(e,t)=>t.map(rn).some(t=>e.map(rn).some(e=>t.includes(e))),not_icontains:(e,t)=>t.map(rn).every(t=>e.map(rn).every(e=>!t.includes(e))),gt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i>parseFloat(e))}),lt:(e,t)=>t.some(t=>{var i=parseFloat(t);return!isNaN(i)&&e.some(e=>i<parseFloat(e))})},rn=e=>e.toLowerCase();function sn(e,t){return!e||Object.entries(e).every(e=>{var[i,r]=e,s=null==t?void 0:t[i];if(L(s)||U(s))return!1;var n=[String(s)],o=tn[r.operator];return!!o&&o(r.values,n)})}var nn=It("[Error tracking]");class on{constructor(e){var t,i;this.Zt=[],this.ti=new tt([new pt,new St,new _t,new gt,new wt,new bt,new ft,new Et],function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];return function(t,r){void 0===r&&(r=0);for(var s=[],n=t.split("\n"),o=r;o<n.length;o++){var a=n[o];if(!(a.length>1024)){var l=dt.test(a)?a.replace(dt,"$1"):a;if(!l.match(/\S*Error: /)){for(var c of i){var u=c(l,e);if(u){s.push(u);break}}if(s.length>=50)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,50).map(e=>{return E({},e,{filename:e.filename||(i=t,i[i.length-1]||{}).filename,function:e.function||it});var i})}(s)}}("web:javascript",lt,ht)),this._instance=e,this.Zt=null!==(t=null==(i=this._instance.persistence)?void 0:i.get_property(Yt))&&void 0!==t?t:[]}onRemoteConfig(e){var t,i,r,s=null!==(t=null==(i=e.errorTracking)?void 0:i.suppressionRules)&&void 0!==t?t:[],n=null==(r=e.errorTracking)?void 0:r.captureExtensionExceptions;this.Zt=s,this._instance.persistence&&this._instance.persistence.register({[Yt]:this.Zt,[Jt]:n})}get ii(){var e,t=!!this._instance.get_property(Jt),i=this._instance.config.error_tracking.captureExtensionExceptions;return null!==(e=null!=i?i:t)&&void 0!==e&&e}buildProperties(e,t){return this.ti.buildFromUnknown(e,{syntheticException:null==t?void 0:t.syntheticException,mechanism:{handled:null==t?void 0:t.handled}})}sendExceptionEvent(e){var t=e.$exception_list;if(this.ei(t)){if(this.ri(t))return void nn.info("Skipping exception capture because a suppression rule matched");if(!this.ii&&this.si(t))return void nn.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ni(t))return void nn.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(0===e.length)return!1;var t=e.reduce((e,t)=>{var{type:i,value:r}=t;return j(i)&&i.length>0&&e.$exception_types.push(i),j(r)&&r.length>0&&e.$exception_values.push(r),e},{$exception_types:[],$exception_values:[]});return this.Zt.some(e=>{var i=e.values.map(e=>{var i,r=tn[e.operator],s=C(e.value)?e.value:[e.value],n=null!==(i=t[e.key])&&void 0!==i?i:[];return s.length>0&&r(s,n)});return"OR"===e.type?i.some(Boolean):i.every(Boolean)})}si(e){return e.flatMap(e=>{var t,i;return null!==(t=null==(i=e.stacktrace)?void 0:i.frames)&&void 0!==t?t:[]}).some(e=>e.filename&&e.filename.startsWith("chrome-extension://"))}ni(e){if(e.length>0){var t,i,r,s,n=null!==(t=null==(i=e[0].stacktrace)?void 0:i.frames)&&void 0!==t?t:[],o=n[n.length-1];return null!==(r=null==o||null==(s=o.filename)?void 0:s.includes("posthog.com/static"))&&void 0!==r&&r}return!1}ei(e){return!q(e)&&C(e)}}var an=It("[FeatureFlags]"),ln=It("[FeatureFlags]",{debugEnabled:!0}),cn="$active_feature_flags",un="$override_feature_flags",hn="$feature_flag_payloads",dn="$override_feature_flag_payloads",pn="$feature_flag_request_id",gn="$feature_flag_evaluated_at",_n=e=>{var t={};for(var[i,r]of Ct(e||{}))r&&(t[i]=r);return t},vn=function(e){return e.FeatureFlags="feature_flags",e.Recordings="recordings",e}({});class fn{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=null!==(e=this._instance.config.evaluation_contexts)&&void 0!==e?e:this._instance.config.evaluation_environments;return!this._instance.config.evaluation_environments||this._instance.config.evaluation_contexts||this.ci||(an.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ci=!0),null!=t&&t.length?t.filter(e=>{var t=e&&"string"==typeof e&&e.trim().length>0;return t||an.error("Invalid evaluation context found:",e,"Expected non-empty string"),t}):[]}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(ni),t=this._instance.get_property(un),i=this._instance.get_property(dn);if(!i&&!t)return e||{};var r=Ot({},e||{}),s=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(var n of s){var o,a,l=r[n],c=null==t?void 0:t[n],u=L(c)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!c,h=L(c)?l.variant:"string"==typeof c?c:void 0,d=null==i?void 0:i[n],p=E({},l,{enabled:u,variant:u?null!=h?h:null==l?void 0:l.variant:void 0});u!==(null==l?void 0:l.enabled)&&(p.original_enabled=null==l?void 0:l.enabled),h!==(null==l?void 0:l.variant)&&(p.original_variant=null==l?void 0:l.variant),d&&(p.metadata=E({},null==l?void 0:l.metadata,{payload:d,original_payload:null==l||null==(a=l.metadata)?void 0:a.payload})),r[n]=p}return this.oi||(an.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:r}),this.oi=!0),r}getFlagVariants(){var e=this._instance.get_property(ri),t=this._instance.get_property(un);if(!t)return e||{};for(var i=Ot({},e),r=Object.keys(t),s=0;s<r.length;s++)i[r[s]]=t[r[s]];return this.oi||(an.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this.oi=!0),i}getFlagPayloads(){var e=this._instance.get_property(hn),t=this._instance.get_property(dn);if(!t)return e||{};for(var i=Ot({},e||{}),r=Object.keys(t),s=0;s<r.length;s++)i[r[s]]=t[r[s]];return this.oi||(an.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,r=this._instance.get_property("$device_id"),s={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:E({},(null==(t=this._instance.persistence)?void 0:t.get_initial_props())||{},this._instance.get_property(oi)||{}),group_properties:this._instance.get_property(ai)};U(r)||L(r)||(s.$device_id=r),(null!=e&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this.pi()&&(s.evaluation_contexts=this.fi());var n=this._instance.config.__preview_remote_config,o=n?"/flags/?v=2":"/flags/?v=2&config=true",a=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",l=this._instance.requestRouter.endpointFor("flags",o+a);n&&(s.timezone=ns()),this.li=!0,this._instance._send_request({method:"POST",url:l,data:s,compression:this._instance.config.disable_compression?void 0:gs.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r=!0;if(200===e.statusCode&&(this.hi||(this.$anon_distinct_id=void 0),r=!1),this.li=!1,this.di||(this.di=!0,this._instance.wi(null!==(i=e.json)&&void 0!==i?i:{})),!s.disable_flags||this.hi)if(this.vi=!r,e.json&&null!=(t=e.json.quotaLimited)&&t.includes(vn.FeatureFlags))an.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 n;s.disable_flags||this.receivedFeatureFlags(null!==(n=e.json)&&void 0!==n?n:{},r),this.hi&&(this.hi=!1,this.mi())}}})}}getFeatureFlag(e,t){var i;if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlagResult(e,t);return null!==(i=null==r?void 0:r.variant)&&void 0!==i?i:null==r?void 0:r.enabled}an.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 null==t?void 0:t.payload}getFeatureFlagResult(e,t){if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFlagVariants(),r=e in i,s=i[e],n=this.getFlagPayloads()[e],o=String(s),a=this._instance.get_property(pn)||void 0,l=this._instance.get_property(gn)||void 0,c=this._instance.get_property(ci)||{};if((t.send_event||!("send_event"in t))&&(!(e in c)||!c[e].includes(o))){var u,h,d,p,g,_,v,f,m;C(c[e])?c[e].push(o):c[e]=[o],null==(u=this._instance.persistence)||u.register({[ci]:c});var y=this.getFeatureFlagDetails(e),b={$feature_flag:e,$feature_flag_response:s,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(null==(h=this._instance.config.bootstrap)||null==(h=h.featureFlags)?void 0:h[e])||null,$feature_flag_bootstrapped_payload:(null==(d=this._instance.config.bootstrap)||null==(d=d.featureFlagPayloads)?void 0:d[e])||null,$used_bootstrap_value:!this.vi};L(null==y||null==(p=y.metadata)?void 0:p.version)||(b.$feature_flag_version=y.metadata.version);var w,E=null!==(g=null==y||null==(_=y.reason)?void 0:_.description)&&void 0!==g?g:null==y||null==(v=y.reason)?void 0:v.code;E&&(b.$feature_flag_reason=E),null!=y&&null!=(f=y.metadata)&&f.id&&(b.$feature_flag_id=y.metadata.id),L(null==y?void 0:y.original_variant)&&L(null==y?void 0:y.original_enabled)||(b.$feature_flag_original_response=L(y.original_variant)?y.original_enabled:y.original_variant),null!=y&&null!=(m=y.metadata)&&m.original_payload&&(b.$feature_flag_original_payload=null==y||null==(w=y.metadata)?void 0:w.original_payload),this._instance.capture("$feature_flag_called",b)}if(r){var S=n;if(!L(n))try{S=JSON.parse(n)}catch(x){}return{key:e,enabled:!!s,variant:"string"==typeof s?s:void 0,payload:S}}}else an.warn('getFeatureFlagResult for key "'+e+"\" failed. Feature flags didn't load in time.")}getRemoteConfigPayload(e,t){var i=this._instance.config.token,r={distinct_id:this._instance.get_distinct_id(),token:i};this.pi()&&(r.evaluation_contexts=this.fi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:r,compression:this._instance.config.disable_compression?void 0:gs.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:i=>{var r,s=null==(r=i.json)?void 0:r.featureFlagPayloads;t((null==s?void 0:s[e])||void 0)}})}isFeatureEnabled(e,t){if(void 0===t&&(t={}),this.ai||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(e,t);return L(i)?void 0:!!i}an.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(),r=this.getFlagPayloads(),s=this.getFlagsWithDetails();!function(e,t,i,r,s){void 0===i&&(i={}),void 0===r&&(r={}),void 0===s&&(s={});var n=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map(e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]})),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter(e=>t[e].enabled).filter(e=>{var i;return null==(i=t[e].metadata)?void 0:i.payload}).map(e=>{var i;return[e,null==(i=t[e].metadata)?void 0:i.payload]}))):an.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e})(e),o=n.flags,a=n.featureFlags,l=n.featureFlagPayloads;if(a){var c=e.requestId,u=e.evaluatedAt;if(C(a)){an.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var h={};if(a)for(var d=0;d<a.length;d++)h[a[d]]=!0;t&&t.register({[cn]:a,[ri]:h})}else{var p=a,g=l,_=o;if(e.errorsWhileComputingFlags)if(o){var v=new Set(Object.keys(o).filter(e=>{var t;return!(null!=(t=o[e])&&t.failed)}));p=E({},i,Object.fromEntries(Object.entries(p).filter(e=>{var[t]=e;return v.has(t)}))),g=E({},r,Object.fromEntries(Object.entries(g||{}).filter(e=>{var[t]=e;return v.has(t)}))),_=E({},s,Object.fromEntries(Object.entries(_||{}).filter(e=>{var[t]=e;return v.has(t)})))}else p=E({},i,p),g=E({},r,g),_=E({},s,_);t&&t.register(E({[cn]:Object.keys(_n(p)),[ri]:p||{},[hn]:g||{},[ni]:_||{}},c?{[pn]:c}:{},u?{[gn]:u}:{}))}}}(e,this._instance.persistence,i,r,s),this.xi(t)}}override(e,t){void 0===t&&(t=!1),an.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return an.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(un),this._instance.persistence.unregister(dn),this.xi(),ln.info("All overrides cleared");if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this.oi=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this._instance.persistence.unregister(un),ln.info("Flag overrides cleared");else if(i.flags){if(C(i.flags)){for(var r={},s=0;s<i.flags.length;s++)r[i.flags[s]]=!0;this._instance.persistence.register({[un]:r})}else this._instance.persistence.register({[un]:i.flags});ln.info("Flag overrides set",{flags:i.flags})}return"payloads"in i&&(!1===i.payloads?(this._instance.persistence.unregister(dn),ln.info("Payload overrides cleared")):i.payloads&&(this._instance.persistence.register({[dn]:i.payloads}),ln.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 r,s=(this._instance.get_property(si)||[]).find(t=>t.flagKey===e),n={["$feature_enrollment/"+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:n};s&&(o.$early_access_feature_name=s.name),i&&(o.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=E({},this.getFlagVariants(),{[e]:t});null==(r=this._instance.persistence)||r.register({[cn]:Object.keys(_n(a)),[ri]:a}),this.xi()}getEarlyAccessFeatures(e,t,i){void 0===t&&(t=!1);var r=this._instance.get_property(si),s=i?"&"+i.map(e=>"stage="+e).join("&"):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+s),method:"GET",callback:t=>{var i,r;if(t.json){var s=t.json.earlyAccessFeatures;return null==(i=this._instance.persistence)||i.unregister(si),null==(r=this._instance.persistence)||r.register({[si]:s}),e(s)}}})}Ei(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(e=>t[e]),flagVariants:Object.keys(t).filter(e=>t[e]).reduce((e,i)=>(e[i]=t[i],e),{})}}xi(e){var{flags:t,flagVariants:i}=this.Ei();this.featureFlagEventHandlers.forEach(r=>r(t,i,{errorsLoading:e}))}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._instance.get_property(oi)||{};this._instance.register({[oi]:E({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(oi)}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0);var i=this._instance.get_property(ai)||{};0!==Object.keys(i).length&&Object.keys(i).forEach(t=>{i[t]=E({},i[t],e[t]),delete e[t]}),this._instance.register({[ai]:E({},i,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property(ai)||{};this._instance.register({[ai]:E({},t,{[e]:{}})})}else this._instance.unregister(ai)}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 mn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class yn{constructor(e,t){var i,r;this.R=e,this.props={},this.$i=!1,this.Si=(r="",(i=e).token&&(r=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+r+"_posthog"),this.Y=this.ki(e),this.load(),e.debug&&kt.info("Persistence loaded",e.persistence,E({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.Pi}ki(e){-1===mn.indexOf(e.persistence.toLowerCase())&&(kt.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=function(e){void 0===e&&(e=[]);var t=[...wr,...e];return E({},br,{W:function(e){try{var t={};try{t=mr.W(e)||{}}catch(r){}var i=Ot(t,JSON.parse(br.q(e)||"{}"));return br.G(e,i),i}catch(r){}return null},G:function(e,i,r,s,n,o){try{br.G(e,i,void 0,void 0,o);var a={};t.forEach(e=>{i[e]&&(a[e]=i[e])}),Object.keys(a).length&&mr.G(e,a,r,s,n,o)}catch(l){br.B(l)}},V:function(e,t){try{null==o||o.localStorage.removeItem(e),mr.V(e,t)}catch(pr){br.B(pr)}}})}(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return"localstorage"===i&&br.H()?br:"localstorage+cookie"===i&&t.H()?t:"sessionstorage"===i&&kr.H()?kr:"memory"===i?Sr:"cookie"===i?mr:t.H()?t:mr}properties(){var e={};return $t(this.props,function(t,i){if(i===ri&&D(t))for(var r=Object.keys(t),s=0;s<r.length;s++)e["$feature/"+r[s]]=t[r[s]];else o=i,a=!1,(U(n=yi)?a:u&&n.indexOf===u?-1!=n.indexOf(o):($t(n,function(e){if(a||(a=e===o))return Ft}),a))||(e[i]=t);var n,o,a}),e}load(){if(!this.Pi){var e=this.Y.W(this.Si);e&&(this.props=Ot({},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(D(e)){L(t)&&(t="None"),this.Ti=L(i)?this.Ri:i;var r=!1;if($t(e,(e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,r=!0)}),r)return this.save(),!0}return!1}register(e,t){if(D(e)){this.Ti=L(t)?this.Ri:t;var i=!1;if($t(e,(t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.props[r]=t,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=Zr(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);N(Nt(e))||this.register(e),this.$i=!0}}update_search_keyword(){var e;this.register((e=null==d?void 0:d.referrer)?es(e):{})}update_referrer_info(){var e;this.register_once({$referrer:is(),$referring_domain:null!=d&&d.referrer&&(null==(e=Zi(d.referrer))?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[pi]||this.props[gi]||this.register_once({[_i]:rs(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};$t([gi,pi],t=>{var i=this.props[t];i&&$t(i,function(t,i){e["$initial_"+F(i)]=t})});var t,i,r=this.props[_i];if(r){var s=(t=ss(r),i={},$t(t,function(e,t){i["$initial_"+F(t)]=e}),i);Ot(e,s)}return e}safe_merge(e){return $t(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||!((e,t)=>{if(e.length!==t.length)return!1;var i=[...e].sort(),r=[...t].sort();return i.every((e,t)=>e===r[t])})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.ki(e),s=this.props;this.clear(),this.Y=r,this.props=s,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[Gt]||{};i[e]=t,this.props[Gt]=i,this.save()}remove_event_timer(e){var t=(this.props[Gt]||{})[e];return L(t)||(delete this.props[Gt][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var bn=It("[Product Tours]"),wn="ph_product_tours";class En{constructor(e){this.Fi=null,this.Oi=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[Zt]:!(null==e||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,t;this.Fi||(e=this._instance).config.disable_product_tours||null==(t=e.persistence)||!t.get_property(Zt)||this.it(()=>this.Mi())}it(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.generateProductTours?e():null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"product-tours",t=>{t?bn.error("Could not load product tours script",t):e()})}Mi(){var e;!this.Fi&&null!=(e=m.__PosthogExtensions__)&&e.generateProductTours&&(this.Fi=m.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(void 0===t&&(t=!1),!C(this.Oi)||t){var i=this._instance.persistence;if(i){var r=i.props[wn];if(C(r)&&!t)return this.Oi=r,void e(r,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:t=>{var r=t.statusCode;if(200!==r||!t.json){var s="Product Tours API could not be loaded, status: "+r;return bn.error(s),void e([],{isLoaded:!1,error:s})}var n=C(t.json.product_tours)?t.json.product_tours:[];this.Oi=n,i&&i.register({[wn]:n}),e(n,{isLoaded:!0})}})}else e(this.Oi,{isLoaded:!0})}getActiveProductTours(e){q(this.Fi)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Fi.getActiveProductTours(e)}showProductTour(e){var t;null==(t=this.Fi)||t.showTourById(e)}previewTour(e){this.Fi?this.Fi.previewTour(e):this.it(()=>{var t;this.Mi(),null==(t=this.Fi)||t.previewTour(e)})}dismissProductTour(){var e;null==(e=this.Fi)||e.dismissTour("user_clicked_skip")}nextStep(){var e;null==(e=this.Fi)||e.nextStep()}previousStep(){var e;null==(e=this.Fi)||e.previousStep()}clearCache(){var e;this.Oi=null,null==(e=this._instance.persistence)||e.unregister(wn)}resetTour(e){var t;null==(t=this.Fi)||t.resetTour(e)}resetAllTours(){var e;null==(e=this.Fi)||e.resetAllTours()}cancelPendingTour(e){var t;null==(t=this.Fi)||t.cancelPendingTour(e)}}var Sn=function(e){return e.Activation="events",e.Cancellation="cancelEvents",e}({});!function(e){e.Button="button",e.Tab="tab",e.Selector="selector"}({}),function(e){e.TopLeft="top_left",e.TopRight="top_right",e.TopCenter="top_center",e.MiddleLeft="middle_left",e.MiddleRight="middle_right",e.MiddleCenter="middle_center",e.Left="left",e.Center="center",e.Right="right",e.NextToTrigger="next_to_trigger"}({}),function(e){e.Top="top",e.Left="left",e.Right="right",e.Bottom="bottom"}({});var xn=function(e){return e.Popover="popover",e.API="api",e.Widget="widget",e.ExternalSurvey="external_survey",e}({});!function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}({}),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}({}),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}({});var kn=function(e){return e.SHOWN="survey shown",e.DISMISSED="survey dismissed",e.SENT="survey sent",e.ABANDONED="survey abandoned",e}({}),In=function(e){return e.SURVEY_ID="$survey_id",e.SURVEY_NAME="$survey_name",e.SURVEY_RESPONSE="$survey_response",e.SURVEY_ITERATION="$survey_iteration",e.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",e.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",e.SURVEY_SUBMISSION_ID="$survey_submission_id",e.SURVEY_QUESTIONS="$survey_questions",e.SURVEY_COMPLETED="$survey_completed",e.PRODUCT_TOUR_ID="$product_tour_id",e.SURVEY_LAST_SEEN_DATE="$survey_last_seen_date",e}({}),Pn=function(e){return e.Popover="popover",e.Inline="inline",e}({}),Tn=It("[Surveys]"),Fn="seenSurvey_",Rn=(e,t)=>{var i="$survey_"+t+"/"+e.id;return e.current_iteration&&e.current_iteration>0&&(i="$survey_"+t+"/"+e.id+"/"+e.current_iteration),i},$n=e=>{return r=""+(t=Fn)+(i=e).id,i.current_iteration&&i.current_iteration>0&&(r=""+t+i.id+"_"+i.current_iteration),r;var t,i,r},On=[xn.Popover,xn.Widget,xn.API],An={ignoreConditions:!1,ignoreDelay:!1,displayType:Pn.Popover};class Cn{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(e=>e!==t)}}emit(e,t){for(var i of this.Ai[e]||[])i(t);for(var r of this.Ai["*"]||[])r(e,t)}}function Mn(e,t,i){if(q(e))return!1;switch(i){case"exact":return e===t;case"contains":var r=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(e);case"regex":try{return new RegExp(t).test(e)}catch(s){return!1}default:return!1}}class Dn{constructor(e){this.ji=new Cn,this.Di=(e,t)=>this.Li(e,t)&&this.Ni(e,t)&&this.Ui(e,t)&&this.zi(e,t),this.Li=(e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event),this._instance=e,this.Hi=new Set,this.Bi=new Set}init(){var e,t;L(null==(e=this._instance)?void 0:e._addCaptureHook)||null==(t=this._instance)||t._addCaptureHook((e,t)=>{this.on(e,t)})}register(e){var t,i;if(!L(null==(t=this._instance)?void 0:t._addCaptureHook)&&(e.forEach(e=>{var t,i;null==(t=this.Bi)||t.add(e),null==(i=e.steps)||i.forEach(e=>{var t;null==(t=this.Hi)||t.add((null==e?void 0:e.event)||"")})}),null!=(i=this._instance)&&i.autocapture)){var r,s=new Set;e.forEach(e=>{var t;null==(t=e.steps)||t.forEach(e=>{null!=e&&e.selector&&s.add(null==e?void 0:e.selector)})}),null==(r=this._instance)||r.autocapture.setElementSelectors(s)}}on(e,t){var i;null!=t&&0!=e.length&&(this.Hi.has(e)||this.Hi.has(null==t?void 0:t.event))&&this.Bi&&(null==(i=this.Bi)?void 0:i.size)>0&&this.Bi.forEach(e=>{this.qi(t,e)&&this.ji.emit("actionCaptured",e.name)})}Wi(e){this.onAction("actionCaptured",t=>e(t))}qi(e,t){if(null==(null==t?void 0:t.steps))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(null!=t&&t.url){var i,r=null==e||null==(i=e.properties)?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Mn(r,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(null==t||!t.href)return!0;var r=this.Ki(e);if(r.length>0)return r.some(e=>Mn(e.href,t.href,t.href_matching||"exact"));var s,n=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!n&&Mn((s=n.match(/(?::|")href="(.*?)"/))?s[1]:"",t.href,t.href_matching||"exact")}Vi(e,t){var i;if(null==t||!t.text)return!0;var r=this.Ki(e);if(r.length>0)return r.some(e=>Mn(e.text,t.text,t.text_matching||"exact")||Mn(e.$el_text,t.text,t.text_matching||"exact"));var s,n,o,a=(null==e||null==(i=e.properties)?void 0:i.$elements_chain)||"";return!!a&&(s=function(e){for(var t,i=[],r=/(?::|")text="(.*?)"/g;!q(t=r.exec(e));)i.includes(t[1])||i.push(t[1]);return i}(a),n=t.text,o=t.text_matching||"exact",s.some(e=>Mn(e,n,o)))}Ji(e,t){var i,r;if(null==t||!t.selector)return!0;var s=null==e||null==(i=e.properties)?void 0:i.$element_selectors;if(null!=s&&s.includes(t.selector))return!0;var n=(null==e||null==(r=e.properties)?void 0:r.$elements_chain)||"";if(t.selector_regex&&n)try{return new RegExp(t.selector_regex).test(n)}catch(o){return!1}return!1}Ki(e){var t;return null==(null==e||null==(t=e.properties)?void 0:t.$elements)?[]:null==e?void 0:e.properties.$elements}zi(e,t){return null==t||!t.properties||0===t.properties.length||sn(t.properties.reduce((e,t)=>{var i=C(t.value)?t.value.map(String):null!=t.value?[String(t.value)]:[];return e[t.key]={values:i,operator:t.operator||"exact"},e},{}),null==e?void 0:e.properties)}}class Nn{constructor(e){this._instance=e,this.Yi=new Map,this.Xi=new Map,this.Qi=new Map}Zi(e,t){return!!e&&sn(e.propertyFilters,null==t?void 0:t.properties)}te(e,t){var i=new Map;return e.forEach(e=>{var r;null==(r=e.conditions)||null==(r=r[t])||null==(r=r.values)||r.forEach(t=>{if(null!=t&&t.name){var r=i.get(t.name)||[];r.push(e.id),i.set(t.name,r)}})}),i}ie(e,t,i){var r=(i===Sn.Activation?this.Yi:this.Xi).get(e),s=[];return this.ee(e=>{s=e.filter(e=>null==r?void 0:r.includes(e.id))}),s.filter(r=>{var s,n=null==(s=r.conditions)||null==(s=s[i])||null==(s=s.values)?void 0:s.find(t=>t.name===e);return this.Zi(n,t)})}register(e){var t;L(null==(t=this._instance)?void 0:t._addCaptureHook)||(this.re(e),this.se(e))}se(e){var t=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.actions)&&(null==(i=e.conditions)||null==(i=i.actions)||null==(i=i.values)?void 0:i.length)>0});0!==t.length&&(null==this.ne&&(this.ne=new Dn(this._instance),this.ne.init(),this.ne.Wi(e=>{this.onAction(e)})),t.forEach(e=>{var t,i,r,s,n;e.conditions&&null!=(t=e.conditions)&&t.actions&&null!=(i=e.conditions)&&null!=(i=i.actions)&&i.values&&(null==(r=e.conditions)||null==(r=r.actions)||null==(r=r.values)?void 0:r.length)>0&&(null==(s=this.ne)||s.register(e.conditions.actions.values),null==(n=e.conditions)||null==(n=n.actions)||null==(n=n.values)||n.forEach(t=>{if(t&&t.name){var i=this.Qi.get(t.name);i&&i.push(e.id),this.Qi.set(t.name,i||[e.id])}}))}))}re(e){var t,i=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.events)&&(null==(i=e.conditions)||null==(i=i.events)||null==(i=i.values)?void 0:i.length)>0}),r=e.filter(e=>{var t,i;return(null==(t=e.conditions)?void 0:t.cancelEvents)&&(null==(i=e.conditions)||null==(i=i.cancelEvents)||null==(i=i.values)?void 0:i.length)>0});0===i.length&&0===r.length||(null==(t=this._instance)||t._addCaptureHook((e,t)=>{this.onEvent(e,t)}),this.Yi=this.te(e,Sn.Activation),this.Xi=this.te(e,Sn.Cancellation))}onEvent(e,t){var i,r=this.oe(),s=this.ae(),n=this.le(),o=(null==(i=this._instance)||null==(i=i.persistence)?void 0:i.props[s])||[];if(n===e&&t&&o.length>0){var a,l;r.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:o});var c=(null==t||null==(a=t.properties)?void 0:a.$survey_id)||(null==t||null==(l=t.properties)?void 0:l.$product_tour_id);if(c){var u=o.indexOf(c);u>=0&&(o.splice(u,1),this.ue(o))}}else{if(this.Xi.has(e)){var h=this.ie(e,t,Sn.Cancellation);h.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:h.map(e=>e.id)}),h.forEach(e=>{var t=o.indexOf(e.id);t>=0&&o.splice(t,1),this.he(e.id)}),this.ue(o))}if(this.Yi.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.Yi.get(e)});var d=this.ie(e,t,Sn.Activation);this.ue(o.concat(d.map(e=>e.id)||[]))}}}onAction(e){var t,i=this.ae(),r=(null==(t=this._instance)||null==(t=t.persistence)?void 0:t.props[i])||[];this.Qi.has(e)&&this.ue(r.concat(this.Qi.get(e)||[]))}ue(e){var t,i=this.oe(),r=this.ae(),s=[...new Set(e)].filter(e=>!this.de(e));i.info("updating activated items",{activatedItems:s}),null==(t=this._instance)||null==(t=t.persistence)||t.register({[r]:s})}getActivatedIds(){var e,t=this.ae();return(null==(e=this._instance)||null==(e=e.persistence)?void 0:e.props[t])||[]}getEventToItemsMap(){return this.Yi}ve(){return this.ne}}class Ln extends Nn{constructor(e){super(e)}ae(){return"$surveys_activated"}le(){return kn.SHOWN}ee(e){var t;null==(t=this._instance)||t.getSurveys(e)}he(e){var t;null==(t=this._instance)||t.cancelPendingSurvey(e)}oe(){return Tn}de(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class jn{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(q(t))return Tn.warn("Flags not loaded yet. Not loading surveys.");var i=C(t);this.ce=i?t.length>0:t,Tn.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);(null!=i&&i.startsWith(Fn)||null!=i&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach(e=>localStorage.removeItem(e))}loadIfEnabled(){if(!this._surveyManager)if(this.fe)Tn.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Tn.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())Tn.info("Not loading surveys in cookieless mode without consent.");else{var e=null==m?void 0:m.__PosthogExtensions__;if(e){if(!L(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 r=e.loadExternalDependency;if(!r)return void this.me("PostHog loadExternalDependency extension not found.");r(this._instance,"surveys",i=>{i||!e.generateSurveys?this.me("Could not load surveys script",i):this._e(e.generateSurveys,t)})}catch(s){throw this.me("Error initializing surveys",s),s}finally{this.fe=!1}}}else Tn.error("PostHog Extensions not found.")}}_e(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new Ln(this._instance),Tn.info("Surveys loaded successfully"),this.be({isLoaded:!0})}me(e,t){Tn.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(void 0===t&&(t=!1),this._instance.config.disable_surveys)return Tn.info("Disabled. Not loading surveys."),e([]);var i,r=this._instance.get_property(li);if(r&&!t)return e(r,{isLoaded:!0});"undefined"!=typeof Promise&&this.ge?this.ge.then(t=>{var{surveys:i,context:r}=t;return e(i,r)}):("undefined"!=typeof Promise&&(this.ge=new Promise(e=>{i=e})),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:t=>{var r;this.ge=null;var s=t.statusCode;if(200!==s||!t.json){var n="Surveys API could not be loaded, status: "+s;Tn.error(n);var o={isLoaded:!1,error:n};return e([],o),void(null==i||i({surveys:[],context:o}))}var a,l=t.json.surveys||[],c=l.filter(e=>{return!(!(t=e).start_date||t.end_date)&&(function(e){var t;return!(null==(t=e.conditions)||null==(t=t.events)||null==(t=t.values)||!t.length)}(e)||function(e){var t;return!(null==(t=e.conditions)||null==(t=t.actions)||null==(t=t.values)||!t.length)}(e));var t});c.length>0&&(null==(a=this._surveyEventReceiver)||a.register(c)),null==(r=this._instance.persistence)||r.register({[li]:l});var u={isLoaded:!0};e(l,u),null==i||i({surveys:l,context:u})}}))}be(e){for(var t of this.pe)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(i){Tn.error("Error in survey callback",i)}}getActiveMatchingSurveys(e,t){if(void 0===t&&(t=!1),!q(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Tn.warn("init was not called")}ye(e){var t=null;return this.getSurveys(i=>{var r;t=null!==(r=i.find(t=>t.id===e))&&void 0!==r?r:null}),t}we(e){if(q(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var t="string"==typeof e?this.ye(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(q(this._surveyManager))return Tn.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 q(this._surveyManager)?(Tn.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(t=>{var r,s=null!==(r=t.find(t=>t.id===e))&&void 0!==r?r:null;if(s){var n=this.we(s);i({visible:n.eligible,disabledReason:n.reason})}else i({visible:!1,disabledReason:"Survey not found"})},t)})}renderSurvey(e,t,i){var r;if(q(this._surveyManager))Tn.warn("init was not called");else{var s="string"==typeof e?this.ye(e):e;if(null!=s&&s.id)if(On.includes(s.type)){var n=null==d?void 0:d.querySelector(t);if(n)return null!=(r=s.appearance)&&r.surveyPopupDelaySeconds?(Tn.info("Rendering survey "+s.id+" with delay of "+s.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout(()=>{var e,t;Tn.info("Rendering survey "+s.id+" with delay of "+(null==(e=s.appearance)?void 0:e.surveyPopupDelaySeconds)+" seconds"),null==(t=this._surveyManager)||t.renderSurvey(s,n,i),Tn.info("Survey "+s.id+" rendered")},1e3*s.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(s,n,i);Tn.warn("Survey element not found")}else Tn.warn("Surveys of type "+s.type+" cannot be rendered in the app");else Tn.warn("Survey not found")}}displaySurvey(e,t){var i;if(q(this._surveyManager))Tn.warn("init was not called");else{var r=this.ye(e);if(r){var s=r;if(null!=(i=r.appearance)&&i.surveyPopupDelaySeconds&&t.ignoreDelay&&(s=E({},r,{appearance:E({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Pn.Popover&&t.initialResponses&&Tn.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),!1===t.ignoreConditions){var n=this.canRenderSurvey(r);if(!n.visible)return void Tn.warn("Survey is not eligible to be displayed: ",n.disabledReason)}t.displayType!==Pn.Inline?this._surveyManager.handlePopoverSurvey(s,t):this.renderSurvey(s,t.selector,t.properties)}else Tn.warn("Survey not found")}}cancelPendingSurvey(e){q(this._surveyManager)?Tn.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;null==(e=this._surveyManager)||e.handlePageUnload()}}var Hn=It("[Conversations]");class Un{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;q(t)||(V(t)?this.xe=t:(this.xe=t.enabled,this.$e=t),this.loadIfEnabled())}}reset(){var e;null==(e=this._conversationsManager)||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=null==m?void 0:m.__PosthogExtensions__;if(e&&!L(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",t=>{t||!e.initConversations?this.ke("Could not load conversations script",t):this.Se(e.initConversations),this.Ee=!1})}catch(r){this.ke("Error initializing conversations",r),this.Ee=!1}}else Hn.error("Conversations enabled but missing token in remote config.")}}Se(e){if(this.$e)try{this._conversationsManager=e(this.$e,this._instance),Hn.info("Conversations loaded successfully")}catch(t){this.ke("Error completing conversations initialization",t)}else Hn.error("Cannot complete initialization: remote config is null")}ke(e,t){Hn.error(e,t),this._conversationsManager=null,this.Ee=!1}show(){this._conversationsManager?this._conversationsManager.show():Hn.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.xe&&!U(this._conversationsManager)}isVisible(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.isVisible())&&void 0!==e&&e}sendMessage(e,t,i){var r=this;return w(function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,i):(Hn.warn("Conversations not available yet."),null)})()}getMessages(e,t){var i=this;return w(function*(){return i._conversationsManager?i._conversationsManager.getMessages(e,t):(Hn.warn("Conversations not available yet."),null)})()}markAsRead(e){var t=this;return w(function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(Hn.warn("Conversations not available yet."),null)})()}getTickets(e){var t=this;return w(function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(Hn.warn("Conversations not available yet."),null)})()}getCurrentTicketId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getCurrentTicketId())&&void 0!==e?e:null}getWidgetSessionId(){var e,t;return null!==(e=null==(t=this._conversationsManager)?void 0:t.getWidgetSessionId())&&void 0!==e?e:null}}class qn{constructor(e){var t;this.Pe=!1,this.Te=!1,this._instance=e,this._instance&&null!=(t=this._instance.config.logs)&&t.captureConsoleLogs&&(this.Pe=!0)}onRemoteConfig(e){var t,i=null==(t=e.logs)?void 0:t.captureConsoleLogs;!q(i)&&i&&(this.Pe=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.Pe&&!this.Te){var e=It("[logs]"),t=null==m?void 0:m.__PosthogExtensions__;if(t){var i=t.loadExternalDependency;i?i(this._instance,"logs",i=>{var r;i||null==(r=t.logs)||!r.initializeLogs?e.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.Te=!0)}):e.error("PostHog loadExternalDependency extension not found.")}else e.error("PostHog Extensions not found.")}}}var Bn=It("[RateLimiter]");class Gn{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach(e=>{Bn.info((e||"events")+" is quota limited."),this.serverLimits[e]=(new Date).getTime()+6e4})}catch(i){return void Bn.warn('could not rate limit - continuing. Error: "'+(null==i?void 0:i.message)+'"',{text:t})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return(null==(e=this.instance.config.rate_limiting)?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max((null==(e=this.instance.config.rate_limiting)?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,r;void 0===e&&(e=!1);var{captureEventsBurstLimit:s,captureEventsPerSecond:n}=this,o=(new Date).getTime(),a=null!==(t=null==(i=this.instance.persistence)?void 0:i.get_property(di))&&void 0!==t?t:{tokens:s,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>s&&(a.tokens=s);var l=a.tokens<1;return l||e||(a.tokens=Math.max(0,a.tokens-1)),!l||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+n+" events per second and "+s+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=l,null==(r=this.instance.persistence)||r.set_property(di,a),{isRateLimited:l,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var Vn=It("[RemoteConfig]");class Wn{constructor(e){this._instance=e}get remoteConfig(){var e;return null==(e=m._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?void 0:e.config}Ie(e){var t,i;null!=(t=m.__PosthogExtensions__)&&t.loadExternalDependency?null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,"remote-config",()=>e(this.remoteConfig)):(Vn.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 Vn.info("Using preloaded remote config",this.remoteConfig),void this.wi(this.remoteConfig);if(this._instance.M())return void Vn.warn("Remote config is disabled. Falling back to local config.");this.Ie(e=>{if(!e)return Vn.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ce(e=>{this.wi(e)});this.wi(e)})}catch(pr){Vn.error("Error loading remote config",pr)}}wi(e){e?this._instance.config.__preview_remote_config?(this._instance.wi(e),!1!==e.hasFeatureFlags&&this._instance.featureFlags.ensureFlagsLoaded()):Vn.info("__preview_remote_config is disabled. Logging config instead",e):Vn.error("Failed to fetch remote config from PostHog.")}}var zn=3e3;class Yn{constructor(e,t){this.Re=!0,this.Fe=[],this.Oe=Q((null==t?void 0:t.flush_interval_ms)||zn,250,5e3,kt.createLogger("flush interval"),zn),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(e=>0===e.url.indexOf("/e")),...t.filter(e=>0!==e.url.indexOf("/e"))].map(e=>{this.Me(E({},e,{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 i=t[r],s=(new Date).getTime();i.data&&C(i.data)&&$t(i.data,e=>{e.offset=Math.abs(e.timestamp-s),delete e.timestamp}),e.Me(i)};for(var r in t)i()}},this.Oe))}De(){clearTimeout(this.Ae),this.Ae=void 0}Le(){var e={};return $t(this.Fe,t=>{var i,r=t,s=(r?r.batchKey:null)||r.url;L(e[s])&&(e[s]=E({},r,{data:[]})),null==(i=e[s].data)||i.push(r.data)}),this.Fe=[],e}}var Jn=["retriesPerformedSoFar"];class Kn{constructor(e){this.Ne=!1,this.Ue=3e3,this.Fe=[],this._instance=e,this.Fe=[],this.ze=!0,!L(o)&&"onLine"in o.navigator&&(this.ze=o.navigator.onLine,this.He=()=>{this.ze=!0,this.Lt()},this.Be=()=>{this.ze=!1},Ut(o,"online",this.He),Ut(o,"offline",this.Be))}get length(){return this.Fe.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=S(e,Jn);G(t)&&(i.url=Js(i.url,{retry_count:t})),this._instance._send_request(E({},i,{callback:e=>{200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this.qe(E({retriesPerformedSoFar:t},i)):null==i.callback||i.callback(e)}}))}qe(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i,r,s,n,o,a=(i=t,s=(r=3e3*Math.pow(2,i))/2,n=Math.min(18e5,r),o=(Math.random()-.5)*(n-s),Math.ceil(n+o)),l=Date.now()+a;this.Fe.push({retryAt:l,requestOptions:e});var c="Enqueued failed request for retry in "+a;navigator.onLine||(c+=" (Browser is offline)"),kt.warn(c),this.Ne||(this.Ne=!0,this.We())}We(){if(this.Ge&&clearTimeout(this.Ge),0===this.Fe.length)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(i=>i.retryAt<e||(t.push(i),!1));if(this.Fe=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Ge&&(clearTimeout(this.Ge),this.Ge=void 0),this.Ne=!1,L(o)||(this.He&&(o.removeEventListener("online",this.He),this.He=void 0),this.Be&&(o.removeEventListener("offline",this.Be),this.Be=void 0)),this.Fe))try{this._instance._send_request(E({},e,{transport:"sendBeacon"}))}catch(pr){kt.error(pr)}this.Fe=[]}}class Xn{constructor(e){this.Ve=()=>{var e,t,i,r;this.Je||(this.Je={});var s=this.scrollElement(),n=this.scrollY(),o=s?Math.max(0,s.scrollHeight-s.clientHeight):0,a=n+((null==s?void 0:s.clientHeight)||0),l=(null==s?void 0:s.scrollHeight)||0;this.Je.lastScrollY=Math.ceil(n),this.Je.maxScrollY=Math.max(n,null!==(e=this.Je.maxScrollY)&&void 0!==e?e:0),this.Je.maxScrollHeight=Math.max(o,null!==(t=this.Je.maxScrollHeight)&&void 0!==t?t:0),this.Je.lastContentY=a,this.Je.maxContentY=Math.max(a,null!==(i=this.Je.maxContentY)&&void 0!==i?i:0),this.Je.maxContentHeight=Math.max(l,null!==(r=this.Je.maxContentHeight)&&void 0!==r?r:0)},this._instance=e}getContext(){return this.Je}resetContext(){var e=this.Je;return setTimeout(this.Ve,0),e}startMeasuringScrollPosition(){Ut(o,"scroll",this.Ve,{capture:!0}),Ut(o,"scrollend",this.Ve,{capture:!0}),Ut(o,"resize",this.Ve)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==o?void 0:o.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=null==o?void 0:o.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 o&&(o.scrollY||o.pageYOffset||o.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return o&&(o.scrollX||o.pageXOffset||o.document.documentElement.scrollLeft)||0}}var Zn=e=>rs(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class Qn{constructor(e,t,i,r){this.Ke=e=>{var t=this.Ye();if(!t||t.sessionId!==e){var i={sessionId:e,props:this.Xe(this._instance)};this.Qe.register({[hi]:i})}},this._instance=e,this.Ze=t,this.Qe=i,this.Xe=r||Zn,this.Ze.onSessionId(this.Ke)}Ye(){return this.Qe.props[hi]}getSetOnceProps(){var e,t=null==(e=this.Ye())?void 0:e.props;return t?"r"in t?ss(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 $t(Nt(this.getSetOnceProps()),(t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_"+F(i)]=t}),e}}var eo=It("[SessionId]");class to{on(e,t){return this.tr.on(e,t)}constructor(e,t,i){var r;if(this.ir=[],this.er=void 0,this.tr=new Cn,this.rr=(e,t)=>!(!G(e)||!G(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if("always"===e.config.cookieless_mode)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||gr,this.lr=i||gr;var s=this.R.persistence_name||this.R.token,n=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Q(n,60,36e3,eo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ur(),this.hr="ph_"+s+"_window_id",this.dr="ph_"+s+"_primary_window_exists",this.vr()){var o=kr.W(this.hr),a=kr.W(this.dr);o&&!a?this.sr=o:kr.V(this.hr),kr.G(this.dr,!0)}if(null!=(r=this.R.bootstrap)&&r.sessionID)try{var l=(()=>{var e=this.R.bootstrap.sessionID.replace(/-/g,"");if(32!==e.length)throw new Error("Not a valid UUID");if("7"!==e[12])throw new Error("Not a UUIDv7");return parseInt(e.substring(0,12),16)})();this.cr(this.R.bootstrap.sessionID,(new Date).getTime(),l)}catch(c){eo.error("Invalid sessionID in bootstrap",c)}this.pr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return L(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"memory"!==this.R.persistence&&!this.Qe.Pi&&kr.H()}gr(e){e!==this.sr&&(this.sr=e,this.vr()&&kr.G(this.hr,e))}_r(){return this.sr?this.sr:this.vr()?kr.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({[ti]:[t,e,i]}))}mr(){var e=this.Qe.props[ti];return C(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.cr(null,null,null)}destroy(){clearTimeout(this.br),this.br=void 0,this.er&&o&&(o.removeEventListener("beforeunload",this.er,{capture:!1}),this.er=void 0),this.ir=[]}pr(){this.er=()=>{this.vr()&&kr.V(this.dr)},Ut(o,"beforeunload",this.er,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=null),"always"===this.R.cookieless_mode)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||(new Date).getTime(),[r,s,n]=this.mr(),o=this._r(),a=G(n)&&Math.abs(i-n)>864e5,l=!1,c=!s,u=!c&&!e&&this.rr(i,r);c||u||a?(s=this.ar(),o=this.lr(),eo.info("new session ID generated",{sessionId:s,windowId:o,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this.lr(),l=!0);var h=G(r)&&e&&!a?r:i,d=G(n)?n:(new Date).getTime();return this.gr(o),this.cr(s,h,d),e||this.ur(),l&&this.ir.forEach(e=>e(s,o,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0)),{sessionId:s,windowId:o,sessionStartTimestamp:d,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:r}}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 io=["$set_once","$set"],ro=It("[SiteApps]");class so{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 null==(e=m._POSTHOG_REMOTE_CONFIG)||null==(e=e[this._instance.config.token])?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,r,s,n,o,a;if(!e)throw new Error("Event payload is required");var l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(var[h,d]of Object.entries(u))l[h]={id:c[h],type:h,properties:d};var{$set_once:p,$set:g}=e;return{event:E({},S(e,io),{properties:E({},e.properties,g?{$set:E({},null!==(t=null==(i=e.properties)?void 0:i.$set)&&void 0!==t?t:{},g)}:{},p?{$set_once:E({},null!==(r=null==(s=e.properties)?void 0:s.$set_once)&&void 0!==r?r:{},p)}:{}),elements_chain:null!==(n=null==(o=e.properties)?void 0:o.$elements_chain)&&void 0!==n?n:"",distinct_id:null==(a=e.properties)?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;!t.errored&&this.yr.length&&(ro.info("Processing "+this.yr.length+" events for site app with id "+e.id),this.yr.forEach(e=>null==t.processEvent?void 0:t.processEvent(e)),t.processedBuffer=!0),Object.values(this.apps).every(e=>e.processedBuffer||e.errored)&&(null==(i=this.Er)||i.call(this))},r=!1,s=s=>{t.errored=!s,t.loaded=!0,ro.info("Site app with id "+e.id+" "+(s?"loaded":"errored")),r&&i()};try{var{processEvent:n}=e.init({posthog:this._instance,callback:e=>{s(e)}});n&&(t.processEvent=n),r=!0}catch(o){ro.error("Error while initializing PostHog app with config id "+e.id,o),s(!1)}if(r&&t.loaded)try{i()}catch(a){ro.error("Error while processing buffered events PostHog app with config id "+e.id,a),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(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{null==i.processEvent||i.processEvent(t)}catch(r){ro.error("Error while processing event "+e.event+" for site app "+i.id,r)}}}onRemoteConfig(e){var t,i,r,s=this;if(null!=(t=this.siteAppLoaders)&&t.length)return this.isEnabled?(this.$r(),void this._instance.on("eventCaptured",e=>this.Sr(e))):void ro.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null==(i=this.Er)||i.call(this),null!=(r=e.siteApps)&&r.length)if(this.isEnabled){var n=function(e){var t;m["__$$ph_site_app_"+e]=s._instance,null==(t=m.__PosthogExtensions__)||null==t.loadSiteApp||t.loadSiteApp(s._instance,a,t=>{if(t)return ro.error("Error while initializing PostHog app with config id "+e,t)})};for(var{id:o,url:a}of e.siteApps)n(o)}else ro.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var no=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&k(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some(e=>k(null==e?void 0:e.brand,t)))return!0}catch(s){}return!!e.webdriver},oo=function(e){return e.US="us",e.EU="eu",e.CUSTOM="custom",e}({}),ao="i.posthog.com";class lo{constructor(e){this.kr={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"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=null==(e=this.instance.config.ui_host)?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+ao,".posthog.com")),"https://app.posthog.com"===t?"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]=oo.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.kr[this.apiHost]=oo.EU:this.kr[this.apiHost]=oo.CUSTOM),this.kr[this.apiHost]}endpointFor(e,t){if(void 0===t&&(t=""),t&&(t="/"===t[0]?t:"/"+t),"ui"===e)return this.uiHost+t;if("flags"===e)return this.flagsApiHost+t;if(this.region===oo.CUSTOM)return this.apiHost+t;var i=ao+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}}var co={icontains:(e,t)=>!!o&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!o&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!o&&Qs(t.href,e),not_regex:(e,t)=>!!o&&!Qs(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class uo{constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){void 0===e&&(e=!1),t.getWebExperiments(e=>{uo.Pr("retrieved web experiments from the server"),t.Tr=new Map,e.forEach(e=>{if(e.feature_flag_key){var i;t.Tr&&(uo.Pr("setting flag key ",e.feature_flag_key," to web experiment ",e),null==(i=t.Tr)||i.set(e.feature_flag_key,e));var r=t._instance.getFeatureFlag(e.feature_flag_key);j(r)&&e.variants[r]&&t.Ir(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var s in e.variants){var n=e.variants[s];uo.Cr(n)&&t.Ir(e.name,s,n.transforms)}})},e)},this._instance=e,this._instance.onFeatureFlags(e=>{this.onFeatureFlags(e)})}onFeatureFlags(e){if(this._is_bot())uo.Pr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(q(this.Tr))return this.Tr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();uo.Pr("applying feature flags",e),e.forEach(e=>{var t;if(this.Tr&&null!=(t=this.Tr)&&t.has(e)){var i,r=this._instance.getFeatureFlag(e),s=null==(i=this.Tr)?void 0:i.get(e);r&&null!=s&&s.variants[r]&&this.Ir(s.name,r,s.variants[r].transforms)}})}}previewWebExperiment(){var e=uo.getWindowLocation();if(null!=e&&e.search){var t=Qi(null==e?void 0:e.search,"__experiment_id"),i=Qi(null==e?void 0:e.search,"__experiment_variant");t&&i&&(uo.Pr("previewing web experiments "+t+" && "+i),this.getWebExperiments(e=>{this.Rr(parseInt(t),i,e)},!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 r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}Rr(e,t,i){var r=i.filter(t=>t.id===e);r&&r.length>0&&(uo.Pr("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Ir(r[0].name,t,r[0].variants[t].transforms))}static Cr(e){return!q(e.conditions)&&uo.Fr(e)&&uo.Or(e)}static Fr(e){var t;if(q(e.conditions)||q(null==(t=e.conditions)?void 0:t.url))return!0;var i,r,s,n=uo.getWindowLocation();return!!n&&(null==(i=e.conditions)||!i.url||co[null!==(r=null==(s=e.conditions)?void 0:s.urlMatchType)&&void 0!==r?r:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==o?void 0:o.location}static Or(e){var t;if(q(e.conditions)||q(null==(t=e.conditions)?void 0:t.utm))return!0;var i=Zr();if(i.utm_source){var r,s,n,o,a,l,c,u,h=null==(r=e.conditions)||null==(r=r.utm)||!r.utm_campaign||(null==(s=e.conditions)||null==(s=s.utm)?void 0:s.utm_campaign)==i.utm_campaign,d=null==(n=e.conditions)||null==(n=n.utm)||!n.utm_source||(null==(o=e.conditions)||null==(o=o.utm)?void 0:o.utm_source)==i.utm_source,p=null==(a=e.conditions)||null==(a=a.utm)||!a.utm_medium||(null==(l=e.conditions)||null==(l=l.utm)?void 0:l.utm_medium)==i.utm_medium,g=null==(c=e.conditions)||null==(c=c.utm)||!c.utm_term||(null==(u=e.conditions)||null==(u=u.utm)?void 0:u.utm_term)==i.utm_term;return h&&p&&g&&d}return!1}static Pr(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];kt.info("[WebExperiments] "+e,i)}Ir(e,t,i){this._is_bot()?uo.Pr("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach(i=>{if(i.selector){var r;uo.Pr("applying transform of variant "+t+" for experiment "+e+" ",i);var s=null==(r=document)?void 0:r.querySelectorAll(i.selector);null==s||s.forEach(e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)})}}):uo.Pr("Control variants leave the page unmodified.")}_is_bot(){return h&&this._instance?no(h,this._instance.config.custom_blocked_useragents):void 0}}var ho=It("[PostHog ExternalIntegrations]"),po={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class go{constructor(e){this._instance=e}it(e,t){var i;null==(i=m.__PosthogExtensions__)||null==i.loadExternalDependency||i.loadExternalDependency(this._instance,e,e=>{if(e)return ho.error("failed to load script",e);t()})}startIfEnabledOrStop(){var e=this,t=function(t){var i,s,n;!r||null!=(i=m.__PosthogExtensions__)&&null!=(i=i.integrations)&&i[t]||e.it(po[t],()=>{var i;null==(i=m.__PosthogExtensions__)||null==(i=i.integrations)||null==(i=i[t])||i.start(e._instance)}),!r&&null!=(s=m.__PosthogExtensions__)&&null!=(s=s.integrations)&&s[t]&&(null==(n=m.__PosthogExtensions__)||null==(n=n.integrations)||null==(n=n[t])||n.stop())};for(var[i,r]of Object.entries(null!==(s=this._instance.config.integrations)&&void 0!==s?s:{})){var s;t(i)}}}var _o="[SessionRecording]",vo=It(_o);class fo{get started(){var e;return!(null==(e=this.Mr)||!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 vo.error("started without valid sessionManager"),new Error(_o+" started without valid sessionManager. This is a bug.");if("always"===this._instance.config.cookieless_mode)throw new Error(_o+' cannot be used with cookieless_mode="always"')}get jr(){var e,t=!(null==(e=this._instance.get_property(ei))||!e.enabled),i=!this._instance.config.disable_session_recording,r=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return o&&t&&i&&!r}startIfEnabledOrStop(e){var t;if(!this.jr||null==(t=this.Mr)||!t.isStarted){var i=!L(Object.assign)&&!L(Array.from);this.jr&&i?(this.Lr(e),vo.info("starting")):this.stopRecording()}}Lr(e){var t,i,r;this.jr&&(null!=m&&null!=(t=m.__PosthogExtensions__)&&null!=(t=t.rrweb)&&t.record&&null!=(i=m.__PosthogExtensions__)&&i.initSessionRecording?this.Nr(e):null==(r=m.__PosthogExtensions__)||null==r.loadExternalDependency||r.loadExternalDependency(this._instance,this.Ur,t=>{if(t)return vo.error("could not load recorder",t);this.Nr(e)}))}stopRecording(){var e,t;null==(e=this.Dr)||e.call(this),this.Dr=void 0,null==(t=this.Mr)||t.stop()}zr(){var e;null==(e=this._instance.persistence)||e.unregister(ii)}Hr(e){if(this._instance.persistence){var t,i,r=this._instance.persistence,s=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,i=null==t?void 0:t.sampleRate,s=q(i)?null:parseFloat(i);q(s)&&this.zr();var n=null==t?void 0:t.minimumDurationMilliseconds;r.register({[ei]:E({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:E({capturePerformance:e.capturePerformance},null==t?void 0:t.networkPayloadCapture),canvasRecording:{enabled:null==t?void 0:t.recordCanvas,fps:null==t?void 0:t.canvasFps,quality:null==t?void 0:t.canvasQuality},sampleRate:s,minimumDurationMilliseconds:L(n)?null:n,endpoint:null==t?void 0:t.endpoint,triggerMatchType:null==t?void 0:t.triggerMatchType,masking:null==t?void 0:t.masking,urlTriggers:null==t?void 0:t.urlTriggers})})};s(),null==(t=this.Dr)||t.call(this),this.Dr=null==(i=this._instance.sessionManager)?void 0:i.onSessionId(s)}}onRemoteConfig(e){"sessionRecording"in e?!1!==e.sessionRecording?(this.Hr(e),this.Ar=!0,this.startIfEnabledOrStop()):this.Ar=!0:vo.info("skipping remote config with no sessionRecording",e)}log(e,t){var i;void 0===t&&(t="log"),null!=(i=this.Mr)&&i.log?this.Mr.log(e,t):vo.warn("log called before recorder was ready")}get Ur(){var e,t,i=null==(e=this._instance)||null==(e=e.persistence)?void 0:e.get_property(ei);return(null==i||null==(t=i.scriptConfig)?void 0:t.script)||"lazy-recorder"}Nr(e){var t,i;if(null==(t=m.__PosthogExtensions__)||!t.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Mr||(this.Mr=null==(i=m.__PosthogExtensions__)?void 0:i.initSessionRecording(this._instance),this.Mr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Mr.start(e)}onRRwebEmit(e){var t;null==(t=this.Mr)||null==t.onRRwebEmit||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.Mr||null==(t=this._instance.persistence)||t.register({$replay_override_linked_flag:!0}),null==(e=this.Mr)||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.Mr||null==(t=this._instance.persistence)||t.register({$replay_override_sampling:!0}),null==(e=this.Mr)||e.overrideSampling()}overrideTrigger(e){var t,i;this.Mr||null==(i=this._instance.persistence)||i.register({["url"===e?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),null==(t=this.Mr)||t.overrideTrigger(e)}get sdkDebugProperties(){var e;return(null==(e=this.Mr)?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,t){var i;return!(null==(i=this.Mr)||!i.tryAddCustomEvent(e,t))}}var mo={},yo=()=>{},bo="posthog",wo=!zs&&-1===(null==f?void 0:f.indexOf("MSIE"))&&-1===(null==f?void 0:f.indexOf("Mozilla")),Eo=e=>{var t;return E({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:jt(null==d?void 0:d.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:yo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:null!=e?e:"unset",__preview_deferred_init_extensions:!1,debug:p&&j(null==p?void 0:p.search)&&-1!==p.search.indexOf("__posthog_debug=true")||!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:"https:"===(null==o||null==(t=o.location)?void 0:t.protocol),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:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;kt.error(t)},get_device_id:e=>e,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:zn},error_tracking:{},_onCapture:yo,__preview_eager_load_replay:!1},(e=>({rageclick:!(e&&e>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(e&&e>="2025-05-24")||"history_change",session_recording:e&&e>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:e&&e>="2026-01-30"?"head":"body",internal_or_test_user_hostname:e&&e>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(e))},So=e=>{var t={};L(e.process_person)||(t.person_profiles=e.process_person),L(e.xhr_headers)||(t.request_headers=e.xhr_headers),L(e.cookie_name)||(t.persistence_name=e.cookie_name),L(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),L(e.store_google)||(t.save_campaign_params=e.store_google),L(e.verbose)||(t.debug=e.verbose);var i=Ot({},t,e);return C(e.property_blacklist)&&(L(e.property_denylist)?i.property_denylist=e.property_blacklist:C(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:kt.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class xo{constructor(){this.__forceAllowLocalhost=!1}get Br(){return this.__forceAllowLocalhost}set Br(e){kt.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class ko{get decideEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}get flagsEndpointWasHit(){var e,t;return null!==(e=null==(t=this.featureFlags)?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){this.webPerformance=new xo,this.qr=!1,this.version=y.LIB_VERSION,this.bi=new Cn,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Eo(),this.SentryIntegration=jr,this.sentryIntegration=e=>{return t=Lr(this,e),{name:Nr,processEvent:e=>t(e)};var t},this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Wr=!1,this.Gr=null,this.Vr=null,this.Jr=null,this.featureFlags=new fn(this),this.toolbar=new Gr(this),this.scrollManager=new Xn(this),this.pageViewManager=new ps(this),this.surveys=new jn(this),this.conversations=new Un(this),this.logs=new qn(this),this.experiments=new uo(this),this.exceptions=new on(this),this.rateLimiter=new Gn(this),this.requestRouter=new lo(this),this.consent=new Pr(this),this.externalIntegrations=new go(this),this.people={set:(e,t,i)=>{var r=j(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=j(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",e=>kt.info('send "'+(null==e?void 0:e.event)+'"',e))}init(e,t,i){if(i&&i!==bo){var r,s=null!==(r=mo[i])&&void 0!==r?r:new ko;return s._init(e,t,i),mo[i]=s,mo[bo][i]=s,s}return this._init(e,t,i)}_init(e,t,i){var r;if(void 0===t&&(t={}),L(e)||H(e))return kt.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Kr(t.debug),this.Yr=t,this.Xr=[],t.person_profiles&&(this.Vr=t.person_profiles),this.set_config(Ot({},Eo(t.defaults),So(t),{name:i,token:e})),this.config.on_xhr_error&&kt.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:gs.GZipJS;var s=this.Qr();this.persistence=new yn(this.config,s),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new yn(E({},this.config,{persistence:"sessionStorage"}),s);var n=E({},this.persistence.props),a=E({},this.sessionPersistence.props);this.register({$initialization_time:(new Date).toISOString()}),this.Zr=new Yn(e=>this.ts(e),this.config.request_queue_config),this.es=new Kn(this),this.__request_queue=[];var l="always"===this.config.cookieless_mode||"on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new to(this),this.sessionPropsManager=new Qn(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(kt.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this.rs(l)},0)):(kt.info("Initializing extensions synchronously"),this.rs(l)),y.DEBUG=y.DEBUG||this.config.debug,y.DEBUG&&kt.info("Starting in debug mode",{this:this,config:t,thisC:E({},this.config),p:n,s:a}),void 0!==(null==(r=t.bootstrap)?void 0:r.distinctID)){var c,u,h=this.config.get_device_id(gr()),d=null!=(c=t.bootstrap)&&c.isIdentifiedID?h:t.bootstrap.distinctID;this.persistence.set_property(ui,null!=(u=t.bootstrap)&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:t.bootstrap.distinctID,$device_id:d})}if(this.ss()){var p,g,_=Object.keys((null==(p=t.bootstrap)?void 0:p.featureFlags)||{}).filter(e=>{var i;return!(null==(i=t.bootstrap)||null==(i=i.featureFlags)||!i[e])}).reduce((e,i)=>{var r;return e[i]=(null==(r=t.bootstrap)||null==(r=r.featureFlags)?void 0:r[i])||!1,e},{}),v=Object.keys((null==(g=t.bootstrap)?void 0:g.featureFlagPayloads)||{}).filter(e=>_[e]).reduce((e,i)=>{var r,s;return null!=(r=t.bootstrap)&&null!=(r=r.featureFlagPayloads)&&r[i]&&(e[i]=null==(s=t.bootstrap)||null==(s=s.featureFlagPayloads)?void 0:s[i]),e},{});this.featureFlags.receivedFeatureFlags({featureFlags:_,featureFlagPayloads:v})}if(l)this.register_once({distinct_id:mi,$device_id:null},"");else if(!this.get_distinct_id()){var f=this.config.get_device_id(gr());this.register_once({distinct_id:f,$device_id:f},""),this.persistence.set_property(ui,"anonymous")}return Ut(o,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),t.segment?function(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var r=i=>{var r=()=>i.anonymousId()||gr();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(ui,"identified")),t()},s=i.user();"then"in s&&M(s.then)?s.then(r):r(s)}(e,()=>{i.register((e=>{Promise&&Promise.resolve||Dr.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Dr.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Dr.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e.calculateEventProperties(i,t.event.properties);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then(()=>{t()})})}(this,()=>this.ns()):this.ns(),M(this.config._onCapture)&&this.config._onCapture!==yo&&(kt.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",e=>this.config._onCapture(e.event,e))),this.config.ip&&kt.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 Mr(this),this.historyAutocapture.startIfEnabled();var i=[];i.push(()=>{new Wr(this).startIfEnabledOrStop()}),i.push(()=>{var e;this.siteApps=new so(this),null==(e=this.siteApps)||e.init()}),e||i.push(()=>{this.sessionRecording=new fo(this),this.sessionRecording.startIfEnabledOrStop()}),this.config.disable_scroll_properties||i.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),i.push(()=>{this.autocapture=new or(this),this.autocapture.startIfEnabled()}),i.push(()=>{this.surveys.loadIfEnabled()}),i.push(()=>{this.logs.loadIfEnabled()}),i.push(()=>{this.conversations.loadIfEnabled()}),i.push(()=>{this.productTours=new En(this),this.productTours.loadIfEnabled()}),i.push(()=>{this.heatmaps=new ds(this),this.heatmaps.startIfEnabled()}),i.push(()=>{this.webVitalsAutocapture=new cs(this)}),i.push(()=>{this.exceptionObserver=new Ar(this),this.exceptionObserver.startIfEnabledOrStop()}),i.push(()=>{this.deadClicksAutocapture=new $r(this,Rr),this.deadClicksAutocapture.startIfEnabled()}),i.push(()=>{if(this.os){var e=this.os;this.os=void 0,this.wi(e)}}),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(s){kt.error("Error initializing extension:",s)}}var r=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:r}),this.config.__preview_deferred_init_extensions&&kt.info("PostHog extensions initialized ("+r+"ms)")}wi(e){var t,i,r,s,n,o,a,l,c;if(!d||!d.body)return kt.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=P(e.supportedCompression,gs.GZipJS)?gs.GZipJS:P(e.supportedCompression,gs.Base64)?gs.Base64:void 0),null!=(t=e.analytics)&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Vr?this.Vr:"identified_only"}),null==(i=this.siteApps)||i.onRemoteConfig(e),null==(r=this.sessionRecording)||r.onRemoteConfig(e),null==(s=this.autocapture)||s.onRemoteConfig(e),null==(n=this.heatmaps)||n.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.logs.onRemoteConfig(e),this.conversations.onRemoteConfig(e),null==(o=this.productTours)||o.onRemoteConfig(e),null==(a=this.webVitalsAutocapture)||a.onRemoteConfig(e),null==(l=this.exceptionObserver)||l.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),null==(c=this.deadClicksAutocapture)||c.onRemoteConfig(e)}ns(){try{this.config.loaded(this)}catch(i){kt.critical("`loaded` function failed",i)}if(this.us(),this.config.internal_or_test_user_hostname&&null!=p&&p.hostname){var e=p.hostname,t=this.config.internal_or_test_user_hostname;("string"==typeof t?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||"always"===this.config.cookieless_mode)&&this.hs()},1),new Wn(this).load(),this.featureFlags.flags()}us(){var e;this.is_capturing()&&this.config.request_batching&&(null==(e=this.Zr)||e.enable())}_dom_loaded(){this.is_capturing()&&Rt(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"),null==(e=this.Zr)||e.unload(),null==(t=this.es)||t.unload()):this.ds()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(wo?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Js(e.url,{ip:this.config.ip?1:0}),e.headers=E({},this.config.request_headers,e.headers),e.compression="best-available"===e.compression?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,(e=>{var t,i,r,s=E({},e);s.timeout=s.timeout||6e4,s.url=Js(s.url,{_:(new Date).getTime().toString(),ver:y.LIB_VERSION,compression:s.compression});var n=null!==(t=s.transport)&&void 0!==t?t:"fetch",o=Zs.filter(e=>!s.disableTransport||!e.transport||!s.disableTransport.includes(e.transport)),a=null!==(i=null==(r=Ht(o,e=>e.transport===n))?void 0:r.method)&&void 0!==i?i:o[0].method;if(!a)throw new Error("No available transport method");a(s)})(E({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),t.statusCode>=400&&(null==(i=(r=this.config).on_request_error)||i.call(r,t)),null==e.callback||e.callback(t)}}))))}ts(e){this.es?this.es.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],r=[],s=[];Rt(e,e=>{e&&(t=e[0],C(t)?s.push(e):M(e)?e.call(this):C(e)&&"alias"===t?i.push(e):C(e)&&-1!==t.indexOf("capture")&&M(this[t])?s.push(e):r.push(e))});var n=function(e,t){Rt(e,function(e){if(C(e[0])){var i=t;$t(e,function(e){i=i[e[0]].apply(i,e.slice(1))})}else this[e[0]].apply(this,e.slice(1))},t)};n(i,this),n(r,this),n(s,this)}ss(){var e,t;return(null==(e=this.config.bootstrap)?void 0:e.featureFlags)&&Object.keys(null==(t=this.config.bootstrap)?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,t,i){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Zr){if(this.is_capturing())if(!L(e)&&j(e)){var s=!this.config.opt_out_useragent_filter&&this._is_bot();if(!s||this.config.__preview_capture_bot_pageviews){var n=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==n||!n.isRateLimited){null!=t&&t.$current_url&&!j(null==t?void 0:t.$current_url)&&(kt.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||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,a=(null==i?void 0:i.timestamp)||o,l=gr(),c={uuid:l,event:e,properties:this.calculateEventProperties(e,t||{},a,l)};"$pageview"===e&&this.config.__preview_capture_bot_pageviews&&s&&(c.event="$bot_pageview",c.properties.$browser_type="bot"),n&&(c.properties.$lib_rate_limit_remaining_tokens=n.remainingTokens),(null==i?void 0:i.$set)&&(c.$set=null==i?void 0:i.$set);var u,h="$groupidentify"!==e,d=this.vs(null==i?void 0:i.$set_once,h);if(d&&(c.$set_once=d),(c=function(e,t){return i=e,r=e=>j(e)&&!U(t)?e.slice(0,t):e,s=new Set,function e(t,i){return t!==Object(t)?r?r(t):t:s.has(t)?void 0:(s.add(t),C(t)?(n=[],Rt(t,t=>{n.push(e(t))})):(n={},$t(t,(t,i)=>{s.has(t)||(n[i]=e(t))})),n);var n}(i);var i,r,s}(c,null!=i&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=a,L(null==i?void 0:i.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=o),e===kn.DISMISSED||e===kn.SENT){var p=null==t?void 0:t[In.SURVEY_ID],g=null==t?void 0:t[In.SURVEY_ITERATION];u={id:p,current_iteration:g},localStorage.getItem($n(u))||localStorage.setItem($n(u),"true"),c.$set=E({},c.$set,{[Rn({id:p,current_iteration:g},e===kn.SENT?"responded":"dismissed")]:!0})}else e===kn.SHOWN&&(c.$set=E({},c.$set,{[In.SURVEY_LAST_SEEN_DATE]:(new Date).toISOString()}));var _=E({},c.properties.$set,c.$set);if(N(_)||this.setPersonPropertiesForFlags(_),!q(this.config.before_send)){var v=this.cs(c);if(!v)return;c=v}this.bi.emit("eventCaptured",c);var f={method:"POST",url:null!==(r=null==i?void 0:i._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:null==i?void 0:i._batchKey};return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly?this.ts(f):this.Zr.enqueue(f),c}kt.critical("This capture call is ignored due to client rate limiting.")}}else kt.error("No event name provided to posthog.capture")}else kt.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",t=>e(t.event,t))}calculateEventProperties(e,t,i,r,s){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var n=s?void 0:this.persistence.remove_event_timer(e),a=E({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,("always"==this.config.cookieless_mode||"on_reject"==this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),"$snapshot"===e){var l=E({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!j(a.distinct_id)&&!B(a.distinct_id)||H(a.distinct_id))&&kt.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=function(e,t){if(!f)return{};var i,r,s,n=e?At([],Yr,t||[]):[],[a,l]=function(e){for(var t=0;t<Xe.length;t++){var[i,r]=Xe[t],s=i.exec(e),n=s&&(M(r)?r(s,e):r);if(n)return n}return["",""]}(f);return Ot(Nt({$os:a,$os_version:l,$browser:Ye(f,navigator.vendor),$device:Ze(f),$device_type:(r=f,s=Ze(r),s===ce||s===le||"Kobo"===s||"Kindle Fire"===s||s===je?ae:s===Te||s===Re||s===Fe||s===De?"Console":s===he?"Wearable":s?se:"Desktop"),$timezone:ns(),$timezone_offset:os()}),{$current_url:er(null==p?void 0:p.href,n,Kr),$host:null==p?void 0:p.host,$pathname:null==p?void 0:p.pathname,$raw_user_agent:f.length>1e3?f.substring(0,997)+"...":f,$browser_version:Ke(f,navigator.vendor),$browser_language:ts(),$browser_language_prefix:(i=ts(),"string"==typeof i?i.split("-")[0]:void 0),$screen_height:null==o?void 0:o.screen.height,$screen_width:null==o?void 0:o.screen.width,$viewport_height:null==o?void 0:o.innerHeight,$viewport_width:null==o?void 0:o.innerWidth,$lib:"web",$lib_version:y.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:g}=this.sessionManager.checkAndGetSessionAndWindowId(s,i.getTime());a.$session_id=h,a.$window_id=g}this.sessionPropsManager&&Ot(a,this.sessionPropsManager.getSessionProps());try{var _;this.sessionRecording&&Ot(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=null==(_=this.es)?void 0:_.length}catch(w){a.$sdk_debug_error_capturing_properties=String(w)}if(this.requestRouter.region===oo.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c="$pageview"!==e||s?"$pageleave"!==e||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=Ot(a,c),"$pageview"===e&&d&&(a.title=d.title),!L(n)){var v=i.getTime()-n;a.$duration=parseFloat((v/1e3).toFixed(3))}f&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Ot({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),C(this.config.property_denylist)?$t(this.config.property_denylist,function(e){delete a[e]}):kt.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var m=this.config.sanitize_properties;m&&(kt.error("sanitize_properties is deprecated. Use before_send instead"),a=m(a,e));var b=this.fs();return a.$process_person_profile=b,b&&!s&&this.ps("_calculate_event_properties"),a}vs(e,t){var i;if(void 0===t&&(t=!0),!this.persistence||!this.fs())return e;if(this.qr)return e;var r=this.persistence.get_initial_props(),s=null==(i=this.sessionPropsManager)?void 0:i.getSetOnceProps(),n=Ot({},r,s||{},e||{}),o=this.config.sanitize_properties;return o&&(kt.error("sanitize_properties is deprecated. Use before_send instead"),n=o(n,"$set_once")),t&&(this.qr=!0),N(n)?void 0:n}register(e,t){var i;null==(i=this.persistence)||i.register(e,t)}register_once(e,t,i){var r;null==(r=this.persistence)||r.register_once(e,t,i)}register_for_session(e){var t;null==(t=this.sessionPersistence)||t.register(e)}unregister(e){var t;null==(t=this.persistence)||t.unregister(e)}unregister_for_session(e){var t;null==(t=this.sessionPersistence)||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 r=null!=i&&i.merge?this.featureFlags.getFlagVariants():{},s=null!=i&&i.merge?this.featureFlags.getFlagPayloads():{},n=E({},r,e),o=E({},s,t),a={};for(var[l,c]of Object.entries(n)){var u="string"==typeof c;a[l]={key:l,enabled:!!u||Boolean(c),variant:u?c:void 0,reason:void 0,metadata:L(null==o?void 0:o[l])?void 0:{id:0,version:void 0,description:void 0,payload:o[l]}}}this.featureFlags.receivedFeatureFlags({flags:a})}updateEarlyAccessFeatureEnrollment(e,t,i){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){return void 0===t&&(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 null!==(t=null==(i=this.sessionManager)?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e,t){void 0===t&&(t=!1),this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e,t){void 0===t&&(t=!1),this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}displaySurvey(e,t){void 0===t&&(t=An),this.surveys.displaySurvey(e,t)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,t){return void 0===t&&(t=!1),this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,i){if(!this.__loaded||!this.persistence)return kt.uninitializedWarning("posthog.identify");if(B(e)&&(e=e.toString(),kt.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()))kt.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!==mi){if(this.ps("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var s=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==r&&e!==this.get_property(Bt)&&(this.unregister(Bt),this.register({distinct_id:e}));var n="anonymous"===(this.persistence.get_property(ui)||"anonymous");e!==r&&n?(this.persistence.set_property(ui,"identified"),this.setPersonPropertiesForFlags(E({},i||{},t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this.Jr=en(e,t,i),this.featureFlags.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(ci))}}else kt.critical('The string "'+mi+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else kt.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this.ps("posthog.setPersonProperties")){var i=en(this.get_distinct_id(),e,t);this.Jr!==i?(this.setPersonPropertiesForFlags(E({},t||{},e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Jr=i):kt.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:E({},r,{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),r[e]===t||i||this.reloadFeatureFlags()}else kt.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){void 0===t&&(t=!0),this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){void 0===t&&(t=!0),this.ps("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,s;if(kt.info("reset"),!this.__loaded)return kt.uninitializedWarning("posthog.reset");var n=this.get_property("$device_id");if(this.consent.reset(),null==(t=this.persistence)||t.clear(),null==(i=this.sessionPersistence)||i.clear(),this.surveys.reset(),this.featureFlags.reset(),null==(r=this.persistence)||r.set_property(ui,"anonymous"),null==(s=this.sessionManager)||s.resetSessionId(),this.Jr=null,"always"===this.config.cookieless_mode)this.register_once({distinct_id:mi,$device_id:null},"");else{var o=this.config.get_device_id(gr());this.register_once({distinct_id:o,$device_id:e?o:n},"")}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 null!==(e=null==(t=this.sessionManager)?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(null!=e&&e.withTimestamp&&i){var s,n=null!==(s=e.timestampLookBack)&&void 0!==s?s:10;if(!i)return r;r+="?t="+Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0)}return r}alias(e,t){return e===this.get_property(qt)?(kt.critical("Attempting to create alias for existing People user - aborting."),-2):this.ps("posthog.alias")?(L(t)&&(t=this.get_distinct_id()),e!==t?(this.gs(Bt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(kt.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=E({},this.config);if(D(e)){var i,r,s,n,o,a,l;Ot(this.config,So(e));var c=this.Qr();null==(i=this.persistence)||i.update_config(this.config,t,c),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new yn(E({},this.config,{persistence:"sessionStorage"}),c);var u=this.Kr(this.config.debug);V(u)&&(this.config.debug=u),V(this.config.debug)&&(this.config.debug?(y.DEBUG=!0,br.H()&&br.G("ph_debug","true"),kt.info("set_config",{config:e,oldConfig:t,newConfig:E({},this.config)})):(y.DEBUG=!1,br.H()&&br.V("ph_debug"))),null==(r=this.exceptionObserver)||r.onConfigChange(),null==(s=this.sessionRecording)||s.startIfEnabledOrStop(),null==(n=this.autocapture)||n.startIfEnabled(),null==(o=this.heatmaps)||o.startIfEnabled(),null==(a=this.exceptionObserver)||a.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this._s(),null==(l=this.externalIntegrations)||l.startIfEnabledOrStop()}}startSessionRecording(e){var t,i,r,s,n,o=!0===e,a={sampling:o||!(null==e||!e.sampling),linked_flag:o||!(null==e||!e.linked_flag),url_trigger:o||!(null==e||!e.url_trigger),event_trigger:o||!(null==e||!e.event_trigger)};Object.values(a).some(Boolean)&&(null==(t=this.sessionManager)||t.checkAndGetSessionAndWindowId(),a.sampling&&(null==(i=this.sessionRecording)||i.overrideSampling()),a.linked_flag&&(null==(r=this.sessionRecording)||r.overrideLinkedFlag()),a.url_trigger&&(null==(s=this.sessionRecording)||s.overrideTrigger("url")),a.event_trigger&&(null==(n=this.sessionRecording)||n.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null==(e=this.sessionRecording)||!e.started)}captureException(e,t){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(E({},r,t))}startExceptionAutocapture(e){this.set_config({capture_exceptions:null==e||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null==(t=this.persistence)?void 0:t.props[e]}getSessionProperty(e){var t;return null==(t=this.sessionPersistence)?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:bo;return t!==bo&&(t=bo+"."+t),t}_isIdentified(){var e,t;return"identified"===(null==(e=this.persistence)?void 0:e.get_property(ui))||"identified"===(null==(t=this.sessionPersistence)?void 0:t.get_property(ui))}fs(){var e,t;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&N(this.getGroups())&&(null==(e=this.persistence)||null==(e=e.props)||!e[Bt])&&(null==(t=this.persistence)||null==(t=t.props)||!t[vi]))}ds(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this.fs()||this.ps("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.ps("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}ps(e){return"never"===this.config.person_profiles?(kt.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gs(vi,!0),!0)}Qr(){if("always"===this.config.cookieless_mode)return!0;var e=this.consent.isOptedOut(),t=this.config.opt_out_persistence_by_default||"on_reject"===this.config.cookieless_mode;return this.config.disable_persistence||e&&!!t}_s(){var e,t,i,r,s=this.Qr();return(null==(e=this.persistence)?void 0:e.Pi)!==s&&(null==(i=this.persistence)||i.set_disabled(s)),(null==(t=this.sessionPersistence)?void 0:t.Pi)!==s&&(null==(r=this.sessionPersistence)||r.set_disabled(s)),s}opt_in_capturing(e){var t,i,r,s;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),null==(i=this.sessionManager)||i.destroy(),null==(r=this.pageViewManager)||r.destroy(),this.sessionManager=new to(this),this.pageViewManager=new ps(this),this.persistence&&(this.sessionPropsManager=new Qn(this,this.sessionManager,this.persistence)),this.sessionRecording=new fo(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this._s(),this.us(),null==(t=this.sessionRecording)||t.startIfEnabledOrStop(),"on_reject"==this.config.cookieless_mode&&this.surveys.loadIfEnabled(),(L(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(s=null==e?void 0:e.captureEventName)&&void 0!==s?s:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.hs()):kt.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,t,i;"always"!==this.config.cookieless_mode?("on_reject"===this.config.cookieless_mode&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this._s(),"on_reject"===this.config.cookieless_mode&&(this.register({distinct_id:mi,$device_id:null}),null==(e=this.sessionManager)||e.destroy(),null==(t=this.pageViewManager)||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,null==(i=this.sessionRecording)||i.stopRecording(),this.sessionRecording=void 0,this.hs())):kt.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===Ir.GRANTED?"granted":e===Ir.DENIED?"denied":"pending"}is_capturing(){return"always"===this.config.cookieless_mode||("on_reject"===this.config.cookieless_mode?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this._s()}_is_bot(){return h?no(h,this.config.custom_blocked_useragents):void 0}hs(){d&&("visible"===d.visibilityState?this.Wr||(this.Wr=!0,this.capture("$pageview",{title:d.title},{send_instantly:!0}),this.Gr&&(d.removeEventListener("visibilitychange",this.Gr),this.Gr=null)):this.Gr||(this.Gr=this.hs.bind(this),Ut(d,"visibilitychange",this.Gr)))}debug(e){!1===e?(null==o||o.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(null==o||o.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,r,s,n,o=this.Yr||{};return"advanced_disable_flags"in o?!!o.advanced_disable_flags:!1!==this.config.advanced_disable_flags?!!this.config.advanced_disable_flags:!0===this.config.advanced_disable_decide?(kt.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",r=kt,s=(t="advanced_disable_flags")in(e=o)&&!q(e[t]),n=i in e&&!q(e[i]),s?e[t]:!!n&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}cs(e){if(q(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 r of t){if(i=r(i),q(i)){var s="Event '"+e.event+"' was rejected in beforeSend function";return W(e.event)?kt.warn(s+". This can cause unexpected behavior."):kt.info(s),null}i.properties&&!N(i.properties)||kt.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return null==(e=this.pageViewManager.Kt)?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=V(e)&&!e,i=br.H()&&"true"===br.q("ph_debug");return!t&&(!!i||e)}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Dt(e.prototype[t[i]])}(ko,["identify"]);var Io,Po=(Io=mo[bo]=new ko,function(){function e(){e.done||(e.done=!0,wo=!1,$t(mo,function(e){e._dom_loaded()}))}null!=d&&d.addEventListener?"complete"===d.readyState?e():Ut(d,"DOMContentLoaded",e,{capture:!1}):o&&kt.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),Io);let To=null,Fo=!1;const Ro=e=>{let t=2166136261;for(let i=0;i<e.length;i++)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return(t>>>0)/4294967296},$o="dori_shopify_end_user_id",Oo="dori_shopify_end_user_session",Ao=()=>"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():`${Date.now()}_${Math.random().toString(36).slice(2,10)}`;let Co=null;const Mo=()=>{if(Co)return Co;let e;try{const t=window?.DORI_CUSTOMER_ID;if(t){let i=window.localStorage.getItem(Oo);i&&i.trim()||(i=Ao(),window.localStorage.setItem(Oo,i)),e=`shopify_customer_${String(t)}_${i}`}else{const t=window.localStorage.getItem($o);t&&t.trim()?e=t:(e=`anon_${Ao()}`,window.localStorage.setItem($o,e))}}catch{e=`anon_${Ao()}`}return Co=e,e};let Do=null;const No=e=>(()=>{if(null===Do){const e=jo()??"";Do=Ro(`${e}:${Mo()}`)}return Do})()<e,Lo=e=>Ro(`${e}:${Mo()}`),jo=()=>{try{const e=document.querySelector("script#dori-side-widget");return e?.getAttribute("data-sharing-id")||null}catch{return null}};let Ho=null;const Uo=()=>{const e={},t=jo();return t&&(e.sharing_id=t),"undefined"!=typeof window&&window.location&&window.location.hostname&&(e.shop_domain=window.location.hostname),e},qo=e=>{if(!e)return;const t=Go();if(t)try{t.register({thread_id:e})}catch(i){}},Bo=(e,t)=>{const i=Go();if(i)try{i.register({occasion:e,occasion_arm:t})}catch(r){}},Go=()=>(To||Fo||(To=(()=>{if(Po.__loaded)return Po;if(Fo)return null;Fo=!0;try{return Po.init("phc_H5oKb44Ke85TJHMvMDD6MzxtjjVeGZZinXVTyC8t0bY",{api_host:"https://us.i.posthog.com",person_profiles:"identified_only",autocapture:!1,capture_pageview:!1,capture_pageleave:!1,capture_performance:!1,capture_dead_clicks:!1,rageclick:!1,disable_session_recording:!0,bootstrap:{distinctID:Mo()},before_send:e=>{if(!e)return e;if("$exception"===e.event)return No(.1)&&(e=>{const t=e?.properties??{};if("manual"===t.dori_capture)return!0;const i=(()=>{if(Ho)return Ho;const e=[];try{const t=document.querySelector("script#dori-side-widget"),i=t?.src;if(i){e.push(i);const t=i.slice(0,i.lastIndexOf("/")+1);t&&t!==i&&e.push(t)}}catch{}return Ho=e,e})();if(0===i.length)return!0;const r=t.$exception_list;if(!Array.isArray(r)||0===r.length)return!0;for(const s of r){const e=s?.stacktrace?.frames;if(Array.isArray(e))for(const t of e){const e=t?.filename;if("string"==typeof e&&i.some(t=>e.startsWith(t)))return!0}}return!1})(e)?e:null;const t=(e=>e.startsWith("pf.")||e.startsWith("pdp_hero"))(e.event)?1:.1;return No(t)?e:null},loaded:e=>{try{e.register({...Uo(),surface:"side",flow_version:"1.13.153"})}catch(t){}try{e.unregister("occasion"),e.unregister("occasion_arm")}catch(t){}}}),To=Po,Po}catch(e){return console.error("[PostHog] Failed to initialize:",e),null}finally{Fo=!1}})()),To),Vo=(e,t)=>{const i=Go();if(i)try{i.capture(e,t)}catch(r){}},Wo=(e,t)=>{const i=Go();if(i)try{console.error("Error captured:",e,t),i.capture("$exception",{$exception_message:e.message,$exception_type:e.name,$exception_stack_trace:e.stack,dori_capture:"manual",...t})}catch(r){console.error("[PostHog] Failed to capture exception:",r)}},zo=(e,t)=>(...i)=>{try{return console.log("withErrorHandling",e),t(...i)}catch(r){throw console.error("Error in withErrorHandling:",r),Wo(r,{context:e}),r}},Yo=(e,t)=>(...i)=>{try{return t(...i).catch(t=>{throw"AbortError"!==t.name&&Wo(t,{context:e}),t})}catch(r){throw"AbortError"!==r.name&&Wo(r,{context:e}),r}},Jo={BOT_DATA:"dori_widget_bot_data",BOT_DATA_ETAG:"dori_widget_bot_data_etag",BOT_DATA_SHARING_ID:"dori_widget_bot_data_sharing_id",SESSION_SHARING_ID:"dori_widget_session_sharing_id",CHAT_STATE:"dori_widget_chat_state",MESSAGES:"dori_widget_messages",CURRENT_STEP:"dori_widget_current_step",SESSION_TIMESTAMP:"dori_widget_session_timestamp",FAB_ANIMATION_TIMESTAMP:"dori_widget_fab_animation_timestamp",DORI_THREAD_ID:"dori_thread_id",DORI_SESSION_KEY:"dori_session_key",LOADED_FROM_STORAGE:"dori_loaded_from_storage",SHOPIFY_END_USER_ID:"dori_shopify_end_user_id",SHOPIFY_END_USER_SESSION:"dori_shopify_end_user_session"};function Ko(){if("undefined"==typeof window)return"";const e=window;if(e.chatbotData?.sharingID)return String(e.chatbotData.sharingID);const t=document.querySelector("script#dori-side-widget");return t?.getAttribute("data-sharing-id")||""}function Xo(){try{const e="__test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}function Zo(){Xo()&&localStorage.setItem(Jo.LOADED_FROM_STORAGE,"true")}function Qo(){Xo()&&localStorage.removeItem(Jo.LOADED_FROM_STORAGE)}function ea(){try{const e=localStorage.getItem(Jo.SESSION_TIMESTAMP);if(!e)return!1;const t=parseInt(e,10);return Date.now()-t<864e5}catch{return!1}}function ta(){if(Xo())try{[Jo.CHAT_STATE,Jo.MESSAGES,Jo.CURRENT_STEP,Jo.DORI_THREAD_ID,Jo.DORI_SESSION_KEY,Jo.LOADED_FROM_STORAGE,Jo.SHOPIFY_END_USER_ID,Jo.SHOPIFY_END_USER_SESSION].forEach(e=>{localStorage.removeItem(e)})}catch(e){console.error("Error clearing local storage:",e)}}function ia(){const e=Ko();return!e||localStorage.getItem(Jo.BOT_DATA_SHARING_ID)===e}function ra(e){if(Xo())try{if(e){localStorage.setItem(Jo.BOT_DATA,JSON.stringify(e));const t=Ko();t&&localStorage.setItem(Jo.BOT_DATA_SHARING_ID,t)}else localStorage.removeItem(Jo.BOT_DATA),localStorage.removeItem(Jo.BOT_DATA_SHARING_ID)}catch(t){console.error("Error saving bot data:",t)}}function sa(){if(!Xo()||!ea())return null;if(!ia())return null;try{const e=localStorage.getItem(Jo.BOT_DATA);return e?JSON.parse(e):null}catch(e){return console.error("Error loading bot data:",e),null}}function na(){if(Xo())try{localStorage.removeItem(Jo.BOT_DATA),localStorage.removeItem(Jo.BOT_DATA_ETAG),localStorage.removeItem(Jo.BOT_DATA_SHARING_ID)}catch(e){console.error("Error clearing bot data cache:",e)}}function oa(e){if(Xo())try{localStorage.setItem(Jo.CHAT_STATE,JSON.stringify(e))}catch(t){console.error("Error saving chat state:",t)}}function aa(e){if(Xo())try{const t=e.map(e=>({...e,timestamp:e.timestamp instanceof Date?e.timestamp.toISOString():e.timestamp}));localStorage.setItem(Jo.MESSAGES,JSON.stringify(t))}catch(t){console.error("Error saving messages:",t)}}function la(){if(!Xo()||!ea())return[];try{const e=localStorage.getItem(Jo.MESSAGES);return e?JSON.parse(e).map(e=>({...e,content:"string"==typeof e.content?r(e.content):e.content,timestamp:new Date(e.timestamp)})):[]}catch(e){return console.error("Error loading messages:",e),[]}}function ca(e){if(Xo())try{localStorage.setItem(Jo.CURRENT_STEP,e)}catch(t){console.error("Error saving current step:",t)}}function ua(){if(!Xo()||!ea())return null;try{const e=sa(),t=function(){if(!Xo()||!ea())return null;try{const e=localStorage.getItem(Jo.CHAT_STATE);return e?JSON.parse(e):null}catch(e){return console.error("Error loading chat state:",e),null}}(),i=la(),r=function(){if(!Xo()||!ea())return"welcome";try{return localStorage.getItem(Jo.CURRENT_STEP)||"welcome"}catch(e){return console.error("Error loading current step:",e),"welcome"}}();return e||i.length>0?{botData:e,chatState:t||{repliedProduct:null,focusedProduct:null,threadId:null,isRequestInProgress:!1},messages:i,currentStep:r,sessionTimestamp:Date.now()}:null}catch(e){return console.error("Error loading session data:",e),null}}function ha(){if(!Xo()||!ea())return!1;try{const e=sa(),t=la();return!!(e||t.length>0)}catch{return!1}}function da(){if(Xo())try{localStorage.setItem(Jo.SESSION_TIMESTAMP,Date.now().toString())}catch(e){console.error("Error updating session timestamp:",e)}}function pa(){if(Xo())try{localStorage.setItem(Jo.FAB_ANIMATION_TIMESTAMP,Date.now().toString())}catch(e){console.error("Error saving FAB animation timestamp:",e)}}function ga(){const e=function(){if(!Xo()||!ea())return null;try{const e=localStorage.getItem(Jo.FAB_ANIMATION_TIMESTAMP);return e?parseInt(e,10):null}catch(e){return console.error("Error loading FAB animation timestamp:",e),null}}();return!e||Date.now()-e>=3e5}function _a(){if(!Xo())return"";try{let e=localStorage.getItem(Jo.DORI_SESSION_KEY);return e||(e="dori_session_"+Date.now()+"_"+Math.random().toString(36).substr(2,9),localStorage.setItem(Jo.DORI_SESSION_KEY,e)),e}catch(e){return console.error("Error generating session key:",e),""}}function va(e){if(Xo()&&e){try{localStorage.setItem(Jo.DORI_THREAD_ID,e)}catch(t){console.error("Error storing dori thread ID:",t)}qo(e)}}function fa(){if(!Xo())return null;try{const e=localStorage.getItem(Jo.DORI_THREAD_ID);return qo(e),e}catch(e){return console.error("Error retrieving dori thread ID:",e),null}}function ma(e){const t=window?.chatbotData;if("undefined"!=typeof window&&t?.ajaxurl){const i=_a();fetch(t.ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"dori_store_thread_session",thread_id:e,session_key:i,nonce:t.nonce})}).catch(e=>console.warn("Failed to store thread in WooCommerce session:",e))}}const ya="https://standardapi.dori.tech",ba=["pointerdown","keydown"],wa=["pointermove","touchstart","wheel","scroll"],Ea=["pointerover","focusin","click"];function Sa(e){const t=(e instanceof Error?e.message:String(e??"")).match(/https?:\/\/[^\s"')]+/);if(!t)return null;const i=t[0].replace(/[.,;:]+$/,"");return/\.m?js(\?|$)/.test(i)?i:null}function xa(e){return e+(e.includes("?")?"&":"?")+"dori-retry=1"}async function ka(e,t,i,r=500,s=e=>import(e)){try{return await e()}catch(n){const e=Sa(n);if(!e)return i?.(n,n),{default:t};await new Promise(e=>setTimeout(e,r));try{return await s(xa(e))}catch(o){return i?.(n,o),{default:t}}}}function Ia(e,t){return e&&("header_button"===t||"header_block"===t)}function Pa(e){if("undefined"==typeof window)return;const t=window;t.__doriOpenReady=!0;const i=t.__doriOpenQueue||[];t.__doriOpenQueue=[],i.length&&e(i[i.length-1])}const Ta=(e,t=[])=>{if(!t||0===t.length)return!1;const i=e.replace(/^\/+/,"").toLowerCase();return t.some(e=>{const t=e.replace(/^\/+/,"").toLowerCase();return i.includes(t)})},Fa=()=>"undefined"==typeof window?"":window.location.pathname,Ra=new Set;let $a=!1;function Oa(){for(const e of Ra)try{e()}catch{}}const Aa="dori-bot-data-ready",Ca="dori-bot-data-error",Ma=(e,t)=>{window.dispatchEvent(new CustomEvent(e,t?{detail:{error:t}}:void 0))},Da=async e=>{const t=await fetch(e);if(200!==t.status)throw new Error(`Failed to fetch bot data: ${t.status}`);const i=await t.json();if(i.error)throw new Error(i.error);if(!i.data)throw new Error("No data received from bot sharing API");return i},Na=(e,t)=>{ra(e),t&&function(e){if(Xo())try{e?localStorage.setItem(Jo.BOT_DATA_ETAG,e):localStorage.removeItem(Jo.BOT_DATA_ETAG)}catch(t){console.error("Error saving ETag:",t)}}(t),da()};let La=!1,ja="";const Ha=()=>{const e=sa();if(!La&&!0!==e?.feature_flags?.ask_button&&!document.querySelector("[data-dori-ask-block]"))return;La||function(){if(Ra.add(()=>{window.location.pathname!==ja&&Ha()}),!$a&&"undefined"!=typeof window){$a=!0;for(const e of["pushState","replaceState"]){const t=history[e];history[e]=function(...e){const i=t.apply(this,e);return Oa(),i}}window.addEventListener("popstate",Oa)}}(),La=!0,ja=window.location.pathname;const i=!!e&&Ta(ja,e.banned_paths||[]);t(async()=>{const{applyAskButton:e}=await import("./assets/apply-BQSXIcbI.js");return{applyAskButton:e}},__vite__mapDeps([0,1]),import.meta.url).then(({applyAskButton:t})=>t(e,i)).catch(e=>console.error("[Dori Widget] Ask button failed to load:",e))};window.addEventListener(Aa,Ha),async function(){try{const t=(()=>{const e=document.querySelector("script#dori-side-widget");return e?.getAttribute("data-sharing-id")||null})();if(!t)return void Ma(Ca,"No sharing ID found");!function(){if(Xo())try{const e=Ko();if(!e)return;const t=localStorage.getItem(Jo.SESSION_SHARING_ID);if(t===e)return;t&&(na(),ta()),localStorage.setItem(Jo.SESSION_SHARING_ID,e)}catch(e){console.error("Error resetting session for new store:",e)}}();const i=sa(),r=function(){if(!Xo()||!ea())return null;if(!ia())return null;try{return localStorage.getItem(Jo.BOT_DATA_ETAG)}catch(e){return console.error("Error loading ETag:",e),null}}(),s=`${ya}/bot-sharing-data/${t}`;i&&Ma(Aa);const n=i?[]:[1500,4e3];for(let o=0;;o++)try{const e=r?{"If-None-Match":r}:{},t=await fetch(s,{headers:e});if(304===t.status){if(!i){const e=await Da(s);Na(e.data,t.headers.get("ETag")),Ma(Aa)}return}if(200===t.status){const e=await t.json();if(e.error)throw new Error(e.error);if(!e.data)throw new Error("No data received");return Na(e.data,t.headers.get("ETag")),void Ma(Aa)}throw new Error(`Failed to fetch bot data: ${t.status}`)}catch(e){if(i)return;if(o<n.length){await new Promise(e=>setTimeout(e,n[o]));continue}const t=e instanceof Error?e.message:String(e);return void Ma(Ca,t)}}catch(e){const t=e instanceof Error?e.message:String(e);Ma(Ca,t)}}(),function(){if("undefined"==typeof window)return;const e=window;e.__doriOpenQueue=e.__doriOpenQueue||[];const t=t=>{e.__doriOpenReady||e.__doriOpenQueue.push(t??{})};e.doriWidget=e.doriWidget||{},"function"!=typeof e.doriWidget.open&&(e.doriWidget.open=t),e.addEventListener("dori:open-widget",e=>t(e.detail))}(),"undefined"!=typeof window&&"undefined"!=typeof document&&document.addEventListener("click",e=>function(e,t){if(e.defaultPrevented||0!==e.button)return!1;if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return!1;const i=e.target,r=i&&"function"==typeof i.closest?i.closest("a[href]"):null;if(!r)return!1;const s=r.getAttribute("target");if(s&&"_self"!==s)return!1;const n=function(e,t){const i={open:!1,expand:!1};try{const r=new URL(e,t);if(r.origin!==new URL(t).origin)return i;const s=r.searchParams.get("dori-chat")?.trim().toLowerCase();if("open"===s||"expand"===s)return{open:!0,expand:"expand"===s};if("#dori-chat"===r.hash.toLowerCase())return{open:!0,expand:!1}}catch{}return i}(r.getAttribute("href")||"",t);return!!n.open&&(e.preventDefault(),window.doriWidget?.open?.({source:"link",expand:n.expand}),!0)}(e,window.location.href),!0);const Ua=()=>{t(async()=>{const{initializeDoriWidget:e}=await import("./assets/main-BS5x7ctG.js").then(e=>e.h);return{initializeDoriWidget:e}},__vite__mapDeps([2,1]),import.meta.url).then(({initializeDoriWidget:e})=>e()).catch(async e=>{const t=Sa(e);if(t){await new Promise(e=>setTimeout(e,1500));try{const e=await import(xa(t));e.initializeDoriWidget?.()}catch(i){console.error("[Dori Widget] Error initializing widget (after retry):",e,i)}}else console.error("[Dori Widget] Error initializing widget:",e)})};"undefined"!=typeof window&&(window.__doriOpenQueue?.length??0)>0?Ua():function(e,t={}){let i=!1;try{i=window.self!==window.top}catch{i=!0}if(i)return t.onLoadStart?.(),void e();let r=!1;const s=[],n=()=>{if(!r){r=!0;for(const e of s)e();t.onLoadStart?.(),e()}},o=(e,t)=>{"function"==typeof window.requestIdleCallback?window.requestIdleCallback(()=>e(),{timeout:t}):window.setTimeout(e,200)},a=(e,t,i)=>{e.addEventListener(t,i,{once:!0,passive:!0,capture:!0}),s.push(()=>e.removeEventListener(t,i,!0))};for(const h of ba)a(window,h,n);let l=!1;const c=()=>{l||r||(l=!0,o(n,2e3))};for(const h of wa)a(window,h,c);for(const h of t.immediateTargets??[])if(h)for(const e of Ea)a(h,e,n);const u=()=>{if(r)return;const e=window.setTimeout(()=>o(n,1e3),5e3);s.push(()=>window.clearTimeout(e))};"complete"===document.readyState?u():window.addEventListener("load",u,{once:!0})}(Ua);export{ya as A,ka as B,Wo as C,Go as D,ga as E,Bo as F,pa as G,Fa as H,Ta as I,Pa as J,Ia as K,Jo as S,t as _,zo as a,Vo as b,na as c,oa as d,aa as e,ca as f,Ko as g,ha as h,Xo as i,ua as j,fa as k,la as l,Zo as m,s as n,ta as o,Qo as p,va as q,ma as r,ra as s,_a as t,da as u,r as v,Yo as w,sa as x,Lo as y,n as z};
|
package/dist/widget.js.br
CHANGED
|
Binary file
|
package/dist/widget.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|