1var e=typeof window<`u`?window:void 0,t=typeof globalThis<`u`?globalThis:e,n=t?.navigator,r=t?.document,i=t?.location,a=t?.fetch,o=t!=null&&t.XMLHttpRequest&&`withCredentials`in new t.XMLHttpRequest?t.XMLHttpRequest:void 0,s=t?.AbortController,c=t?.CompressionStream,l=n?.userAgent;function u(){return!(!e||!1===e.navigator.onLine)}var d=typeof globalThis<`u`?globalThis:e;d&&typeof self>`u`&&(d.self=d),d&&typeof File>`u`&&(d.File=function(){});var f=e??{},p={DEBUG:!1,LIB_VERSION:`0.3.1`,LIB_NAME:`browser-common`};function m(e,t,n,r,i,a,o){try{var s=e[a](o),c=s.value}catch(e){n(e);return}s.done?t(c):Promise.resolve(c).then(r,i)}function h(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){m(a,r,i,o,s,`next`,e)}function s(e){m(a,r,i,o,s,`throw`,e)}o(void 0)}))}}function g(){return g=Object.assign?Object.assign.bind():function(e){for(var t=1;arguments.length>t;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},g.apply(null,arguments)}function _(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var v=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}};function y(e){return typeof e==`string`||e}function b(e){return typeof e==`string`?e:void 0}var x,S=[`$feature_flag`,`$feature_flag_response`,`$feature_flag_has_experiment`,`$feature_flag_id`,`$feature_flag_version`,`$feature_flag_reason`,`$feature_flag_request_id`,`$feature_flag_evaluated_at`,`$feature_flag_error`,`locally_evaluated`,`$groups`,`$process_person_profile`,`$geoip_disable`,`$current_url`,`$pathname`,`$session_id`,`$window_id`,`$lib`,`$lib_version`,`$device_id`,`$is_server`],C=function(e){return e.AnonymousId=`anonymous_id`,e.DistinctId=`distinct_id`,e.Props=`props`,e.EnablePersonProcessing=`enable_person_processing`,e.PersonMode=`person_mode`,e.FeatureFlagDetails=`feature_flag_details`,e.FeatureFlags=`feature_flags`,e.FeatureFlagPayloads=`feature_flag_payloads`,e.BootstrapFeatureFlagDetails=`bootstrap_feature_flag_details`,e.BootstrapFeatureFlags=`bootstrap_feature_flags`,e.BootstrapFeatureFlagPayloads=`bootstrap_feature_flag_payloads`,e.OverrideFeatureFlags=`override_feature_flags`,e.Queue=`queue`,e.AiQueue=`ai_queue`,e.LogsQueue=`logs_queue`,e.OptedOut=`opted_out`,e.SessionId=`session_id`,e.SessionStartTimestamp=`session_start_timestamp`,e.SessionLastTimestamp=`session_timestamp`,e.PersonProperties=`person_properties`,e.GroupProperties=`group_properties`,e.InstalledAppBuild=`installed_app_build`,e.InstalledAppVersion=`installed_app_version`,e.SessionReplay=`session_replay`,e.SessionReplayEventTriggerActivatedSession=`session_replay_event_trigger_activated_session`,e.SurveyLastSeenDate=`survey_last_seen_date`,e.SurveysSeen=`surveys_seen`,e.Surveys=`surveys`,e.RemoteConfig=`remote_config`,e.FlagsEndpointWasHit=`flags_endpoint_was_hit`,e.DeviceId=`device_id`,e}({}),w=function(e){return e.GZipJS=`gzip-js`,e.Base64=`base64`,e}({}),T=[`$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`],E=[`token`],D=`NativeGzipValidationError`,O=e=>e.length>=2&&e[0]===31&&e[1]===139,ee=(e,t)=>e===w.GZipJS||t===w.GZipJS||t===`gzip`,k=e=>!(!e||typeof e!=`object`)&&(`name`in e?String(e.name):``)===`NotReadableError`,A=e=>{var t=Error(`Native gzip produced invalid output: `+e);throw t.name=D,t},te=function(){var e=h((function*(e,t){18>e.size&&A(`too-short`);var n=new Uint8Array(yield e.slice(0,10).arrayBuffer());O(n)&&n[2]===8||A(`invalid-header`);var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(e=>{for(var t=(()=>{if(x)return x;x=[];for(var e=0;256>e;e++){for(var t=e,n=0;8>n;n++)t=1&t?3988292384^t>>>1:t>>>1;x[e]=t>>>0}return x})(),n=4294967295,r=0;e.length>r;r++)n=t[255&(n^e[r])]^n>>>8;return(4294967295^n)>>>0})(t)&&A(`invalid-crc`);var i=t.length>>>0;r.getUint32(4,!0)!==i&&A(`invalid-size`)}));return function(t,n){return e.apply(this,arguments)}}();
1function j(){return j=h((function*(e,t,n){t===void 0&&(t=!0);try{var r=new TextEncoder().encode(e),i=new globalThis.CompressionStream(`gzip`),a=i.writable.getWriter(),o=a.write(r).then((()=>a.close())).catch(function(){var e=h((function*(e){try{yield a.abort(e)}catch{}throw e}));return function(t){return e.apply(this,arguments)}}()),s=new Response(i.readable).blob(),c=(yield Promise.all([s,o]))[0];return yield te(c,r),c}catch(e){if(n!=null&&n.rethrow)throw e;return null}})),j.apply(this,arguments)}var ne=`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`.split(`,`),re=function(e,t){if(t===void 0&&(t=[]),!e)return!1;var n=e.toLowerCase();return ne.concat(t).some((e=>{var t=e.toLowerCase();return n.indexOf(t)!==-1}))};function M(e,t){return e.indexOf(t)!==-1}var ie=function(e){return e.trim()},ae=function(e){return e.replace(/^\$/,``)};function oe(e){var t=[];return JSON.stringify(e,(function(e,n){if(typeof n==`bigint`)return n.toString();if(typeof n!=`function`&&typeof n!=`symbol`){if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n==`object`){for(;t.length>0&&t[t.length-1]!==this;)t.pop();if(t.includes(n))return`[Circular]`;t.push(n)}return n}}))??`null`}var se=Object.prototype,ce=se.hasOwnProperty,le=se.toString,N=Array.isArray||function(e){return le.call(e)===`[object Array]`},P=e=>typeof e==`function`,F=e=>e===Object(e)&&!N(e),ue=e=>{if(F(e)){for(var t in e)if(ce.call(e,t))return!1;return!0}return!1},I=e=>e===void 0,L=e=>le.call(e)==`[object String]`,de=e=>L(e)&&e.trim().length===0,R=e=>e===null,z=e=>I(e)||R(e),B=e=>le.call(e)==`[object Number]`&&e==e,fe=e=>B(e)&&e>0,pe=e=>le.call(e)===`[object Boolean]`,me=e=>e instanceof FormData,he=e=>M(T,e),ge=e=>M(E,e);function _e(e){return typeof e!=`object`||!e}function ve(e,t){return{}.toString.call(e)===`[object `+t+`]`}function ye(e){return typeof Event<`u`&&function(e,t){try{return e instanceof t}catch{return!1}}(e,Event)}var be=[!0,`true`,1,`1`,`yes`],xe=e=>M(be,e),Se=[!1,`false`,0,`0`,`no`];function Ce(e,t,n,r,i){return t>n&&(r.warn(`min cannot be greater than max.`),t=n),B(e)?e>n?(r.warn(` cannot be greater than max: `+n+`. Using max value instead.`),n):t>e?(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: `+n+`, fallback: `+i),Ce(i||n,t,n,r))}var we=class{constructor(e){this.tt={},this.et=e.et,this.rt=Ce(e.bucketSize,0,100,e.it),this.nt=Ce(e.refillRate,0,this.rt,e.it),this.st=Ce(e.refillInterval,0,864e5,e.it)}ot(e,t){var n=Math.floor((t-e.lastAccess)/this.st);n>0&&(e.tokens=Math.min(e.tokens+n*this.nt,this.rt),e.lastAccess+=n*this.st)}consumeRateLimit(e){var t,n=Date.now(),r=String(e),i=this.tt[r];return i?this.ot(i,n):this.tt[r]=i={tokens:this.rt,lastAccess:n},i.tokens===0||(i.tokens--,i.tokens===0&&((t=this.et)==null||t.call(this,e)),i.tokens===0)}stop(){this.tt={}}},Te=`Mobile`,Ee=`iOS`,De=`Android`,Oe=`Tablet`,ke=De+` `+Oe,Ae=`iPad`,je=`Apple`,Me=je+` Watch`,Ne=`Safari`,Pe=`BlackBerry`,Fe=`Samsung`,Ie=Fe+`Browser`,Le=Fe+` Internet`,Re=`Chrome`,ze=Re+` OS`,Be=Re+` `+Ee,Ve=`Internet Explorer`,He=Ve+` `+Te,Ue=`Opera`,We=Ue+` Mini`,Ge=`Edge`,Ke=`Microsoft `+Ge,qe=`Firefox`,Je=qe+` `+Ee,Ye=`Nintendo`,Xe=`PlayStation`,Ze=`Xbox`,Qe=De+` `+Te,$e=Te+` `+Ne,et=`Windows`,tt=et+` Phone`,nt=`Nokia`,rt=`Ouya`,it=`Generic`,at=it+` `+Te.toLowerCase(),ot=it+` `+Oe.toLowerCase(),st=`Konqueror`,ct=`Oculus Browser`,lt=`Vivaldi`,ut=`Yandex`,dt=`Whale`,ft=`DuckDuckGo`,pt=`Pale Moon`,mt=`Waterfox`,ht=`Brave`,gt=`Google Search App`,V=`(\\d+(\\.\\d+)?)`,_t=Reg
1Exp(`Version/`+V),vt=new RegExp(Ze,`i`),yt=RegExp(Xe+` \\w+`,`i`),bt=RegExp(Ye+` \\w+`,`i`),xt=RegExp(Pe+`|PlayBook|BB10`,`i`),St={"NT3.51":`NT 3.11`,"NT4.0":`NT 4.0`,"5.0":`2000`,5.1:`XP`,5.2:`XP`,"6.0":`Vista`,6.1:`7`,6.2:`8`,6.3:`8.1`,6.4:`10`,"10.0":`10`},Ct=function(e,t,n,r){return t||=``,function(e){return e!=null&&e.brave?ht:null}(n)||(r!=null&&r.detectGoogleSearchApp&&M(e,`GSA/`)?gt:M(e,` OPR/`)&&M(e,`Mini`)?We:M(e,` OPR/`)?Ue:xt.test(e)?Pe:M(e,`IE`+Te)||M(e,`WPDesktop`)?He:M(e,`OculusBrowser`)?ct:M(e,Ie)?Le:M(e,Ge)||M(e,`Edg/`)?Ke:M(e,lt+`/`)?lt:M(e,`YaBrowser/`)?ut:M(e,dt+`/`)?dt:M(e,ft+`/`)||M(e,`Ddg/`)?ft:M(e,`FBIOS`)?`Facebook `+Te:M(e,`UCWEB`)||M(e,`UCBrowser`)?`UC Browser`:M(e,`CriOS`)?Be:M(e,`CrMo`)||M(e,Re)?Re:M(e,De)&&M(e,Ne)?Qe:M(e,`FxiOS`)?Je:M(e.toLowerCase(),st.toLowerCase())?st:M(e,ht+`/`)?ht:((e,t)=>t&&M(t,je)||function(e){return M(e,Ne)&&!M(e,Re)&&!M(e,De)}(e))(e,t)?M(e,Te)?$e:Ne:M(e,`PaleMoon/`)?pt:M(e,mt+`/`)?mt:M(e,qe)?qe:M(e,`MSIE`)||M(e,`Trident/`)?Ve:M(e,`Gecko`)?qe:``)},wt={[He]:[RegExp(`rv:`+V)],[Ke]:[RegExp(Ge+`?\\/`+V)],[Re]:[RegExp(`(`+Re+`|CrMo)\\/`+V)],[Be]:[RegExp(`CriOS\\/`+V)],"UC Browser":[RegExp(`(UCBrowser|UCWEB)\\/`+V)],[Ne]:[_t],[$e]:[_t],[Ue]:[RegExp(`(Opera|OPR)\\/`+V)],[qe]:[RegExp(qe+`\\/`+V)],[Je]:[RegExp(`FxiOS\\/`+V)],[st]:[RegExp(`Konqueror[:/]?`+V,`i`)],[Pe]:[RegExp(Pe+` `+V),_t],[Qe]:[RegExp(`android\\s`+V,`i`)],[Le]:[RegExp(Ie+`\\/`+V)],[ct]:[RegExp(`OculusBrowser\\/`+V)],[lt]:[RegExp(lt+`\\/`+V)],[ut]:[RegExp(`YaBrowser\\/`+V)],[dt]:[RegExp(dt+`\\/`+V)],[ht]:[RegExp(ht+`\\/`+V)],[ft]:[RegExp(`(DuckDuckGo|Ddg)\\/`+V)],[pt]:[RegExp(`PaleMoon\\/`+V)],[mt]:[RegExp(mt+`\\/`+V)],[gt]:[RegExp(`GSA\\/`+V)],[Ve]:[RegExp(`(rv:|MSIE )`+V)],Mozilla:[RegExp(`rv:`+V)]},Tt=function(e,t,n,r){var i=wt[Ct(e,t,n,r)];if(I(i))return null;for(var a=0;i.length>a;a++){var o=e.match(i[a]);if(o)return parseFloat(o[o.length-2])}return null},Et=[[RegExp(Ze+`; `+Ze+` (.*?)[);]`,`i`),e=>[Ze,e&&e[1]||``]],[new RegExp(Ye,`i`),[Ye,``]],[new RegExp(Xe,`i`),[Xe,``]],[xt,[Pe,``]],[new RegExp(et,`i`),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[tt,``];if(new RegExp(Te).test(t)&&!/IEMobile\b/.test(t))return[et+` `+Te,``];var n=/Windows NT ([0-9.]+)/i.exec(t);if(n&&n[1]){var r=St[n[1]]||``;return/arm/i.test(t)&&(r=`RT`),[et,r]}return[et,``]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>e&&e[3]?[Ee,[e[3],e[4],e[5]||`0`].join(`.`)]:[Ee,``]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t=``;return e&&e.length>=3&&(t=I(e[2])?e[3]:e[2]),[`watchOS`,t]}],[RegExp(`(`+De+` (\\d+)\\.(\\d+)\\.?(\\d+)?|`+De+`)`,`i`),e=>e&&e[2]?[De,[e[2],e[3],e[4]||`0`].join(`.`)]:[De,``]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=[`Mac OS X`,``];return e&&e[1]&&(t[1]=[e[1],e[2],e[3]||`0`].join(`.`)),t}],[/Mac/i,[`Mac OS X`,``]],[/CrOS/,[ze,``]],[/Linux|debian/i,[`Linux`,``]]],Dt=function(e){return bt.test(e)?Ye:yt.test(e)?Xe:vt.test(e)?Ze:new RegExp(rt,`i`).test(e)?rt:RegExp(`(`+tt+`|WPDesktop)`,`i`).test(e)?tt:/iPad/.test(e)?Ae:/iPod/.test(e)?`iPod Touch`:/iPhone/.test(e)?`iPhone`:/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Me:xt.test(e)?Pe:/(kobo)\s(ereader|touch)/i.test(e)?`Kobo`:new RegExp(nt,`i`).test(e)?nt:/(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(Te).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)?De:ke:RegExp(`(pda|`+Te+`)`,`i`).test(e)?at:new RegExp(Oe,`i`).test(e)&&!RegExp(Oe+` pc`,`i`).test(e)?ot:``},Ot=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function kt(e,t){return typeof(n=e)==`string`&&Ot.test(n)?e:t();var n}function At(e){return e&&e.split(`#`)[0]}function jt(e,t){var n=setTimeout(e,t);return n!=null&&n.unref&&n?.unref(),n}var Mt=e=>e instanceof Error,Nt={trace:{text:`TRACE`,number:1},debug:{text:`DEBUG`,number:5},info:{text:`INFO`,number:9},warn:{text:`WARN`,number:13},error:{text:`ERROR`,number:17},fatal:{text:`FATAL`,number:21}},Pt=Nt.info;function Ft(e){if(pe(e))return{boolValue:e};if(typeof e==`number`)return Number.isFinite(e)?Number.isInteger(e)?{intValue:e}:{doubleValue:e}:{stringValue:String(e)};if(typeof e==`string`)return{stringValue:e};if(N(e))return{arrayValue:{values:e.map((e=>Ft(e)))}};try{return{stringValue:JSON.stringify(e)}}catch{return{stringValue:String(e)}}}function It(e){var t=[];for(var n in e){var r=e[n];R(r)||I(r)||t.push({key:n,value:Ft(r)})}return t}function Lt(e,t){var n=Nt[e.level||`info`]||Pt,r=n.text,i=n.number,a=String(Date.now())+`000000`,o={};t.distinctId&&(o.posthogDistinctId=t.distinctId),t.sessionId&&(o.sessionId=t.sessionId),t.windowId&&(o[`window.id`]=t.windowId),z(t.sessionStartTimestamp)||(o.sessionStartTimestamp=String(t.sessionStartTimestamp)),z(t.lastActivityTimestamp)||(o.lastActivityTimestamp=String(t.lastActivityTimestamp)),t.currentUrl&&(o[`url.full`]=t.currentUrl),t.screenName&&(o[`screen.name`]=t.screenName),t.appState&&(o[`app.state`]=t.appState),t.activeFeatureFlags&&t.activeFeatureFlags.length>0&&(o.feature_flags=t.activeFeatureFlags);var s=g({},o,e.attributes||{}),c={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:i,severityText:r,body:{stringValue:e.body},attributes:It(s)};return e.trace_id&&(c.traceId=e.trace_id),e.span_id&&(c.spanId=e.span_id),I(e.trace_flags)||(c.flags=e.trace_flags),c}function Rt(e,t,n){return g({},e.resourceAttributes,{"service.name":e.serviceName||`unknown_service`},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":n})}function zt(e,t,n,r){return{resourceLogs:[{resource:{attributes:It(t)},scopeLogs:[{scope:{name:n,version:r},logRecords:e}]}]}}var Bt=class{constructor(e,t,n,r,i,a,o){a===void 0&&(a=()=>Promise.resolve()),this._instance=e,this.Te=t,this.it=n,this.ut=r,this.ht=i,this.dt=a,this.ct=o,this.vt=null,this.ft=0,this.yt=0,this.bt=0,this._t=0,this.wt=!1,this.xt=t.maxBufferSize,this.kt=Math.max(t.maxQueueSize??t.maxBufferSize,t.maxBufferSize),this.St=t.flushIntervalMs,this.Ct=t.maxBatchRecordsPerPost,this.Mt=t.rateCapWindowMs,this.It=t.maxLogsPerInterval}reset(){this.Tt(),this.vt=null,this.bt=0,this._t=0,this.wt=!1,this.ft=0,this.yt=0,this.Ct=this.Te.maxBatchRecordsPerPost}onReconnect(){this.yt=0,this.Et()}captureLog(e){if(!this._instance.isDisabled&&!this._instance.optedOut&&e!=null&&e.body){var t=this.Rt(e);if(t!==null)if(t.body){if(this.Pt()){var n={record:Lt(t,this.ut())};this.ht((()=>this.Ot(n)))}}else this.it.info(`Log was rejected in beforeSend function`)}}Rt(e){var t=this.Te.beforeSend;if(!t)return e;var n=N(t)?t:[t],r=e;for(var i of n)try{var a=i(r);if(!a)return this.it.info(`Log was rejected in beforeSend function`),null;r=a}catch(e){return this.it.error(`Error in beforeSend function for log:`,e),null}return r}Pt(){if(this.It===void 0)return!0;var e=Date.now(),t=e-this.bt;return this.Mt>t&&t>=0||(this.bt=e,this._t=0,this.wt=!1),this.It>this._t?(this._t++,!0):(this.wt||=(this.it.warn(`captureLog dropping logs: exceeded `+this.It+` logs per `+this.Mt+`ms`),!0),!1)}flush(){var e=this;return h((function*(){if(!e._instance.isDisabled)return e.vt||=e.Ft().finally((()=>{e.vt=null})),e.vt}))()}Ft(){var e=this;return h((function*(){e.Tt();var t=e._instance.getPersistedProperty(C.LogsQueue)??[];
1if(t.length!==0)for(var n=t.length,r=0;t.length>0&&n>r;){e.ft=0;var i=Math.min(t.length,e.Ct),a=t.slice(0,i),o=zt(a.map((e=>e.record)),e.At(),e.ct??e._instance.getLibraryId(),e._instance.getLibraryVersion()),s=yield e._instance.$t(o);if(s.kind===`too-large`&&a.length>1)e.Ct=Math.max(1,Math.floor(a.length/2)),e.it.warn(`Received 413 when sending logs batch of size `+a.length+`, reducing batch size to `+e.Ct);else if(s.kind===`retry-later`||(s.kind===`too-large`?e.it.warn(`Dropping a single log record after 413 with batch size 1 â the record is larger than the server cap and cannot be split further.`):s.kind===`ok`&&e.Te.maxBatchRecordsPerPost>e.Ct&&(e.Ct=Math.min(e.Te.maxBatchRecordsPerPost,e.Ct+1)),yield e.Lt(a.length),t=e._instance.getPersistedProperty(C.LogsQueue)??[],r+=a.length,s.kind===`fatal`))throw s.error}}))()}Lt(e){var t=this;return h((function*(){var n=Math.max(0,e-t.ft),r=t._instance.getPersistedProperty(C.LogsQueue)??[];t._instance.setPersistedProperty(C.LogsQueue,r.slice(n)),yield t.dt()}))()}At(){return Rt(this.Te,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ot(e){if(!this._instance.optedOut){var t=this._instance.getPersistedProperty(C.LogsQueue)??[];this.kt>t.length||(t.shift(),this.ft++,this.it.info(`Logs queue is full, dropping oldest record.`)),t.push(e),this._instance.setPersistedProperty(C.LogsQueue,t),this.xt>t.length?this.Dt():this.Et()}}Dt(e){e===void 0&&(e=this.St),this.Nt||=jt((()=>{this.Nt=void 0,this.Et()}),e)}qt(){var e=Math.min(Math.max(0,this.yt-1),6);return this.St*2**e}jt(){var e=this._instance.getPersistedProperty(C.LogsQueue);return!!e&&e.length>0}shutdown(e){var t=this;return h((function*(){t.Tt();var n=t.flush().catch((()=>{}));e===void 0?yield n:yield Promise.race([n,new Promise((t=>jt(t,e)))])}))()}flushWithTimeout(e){var t=this;return h((function*(){var n=!1,r=t.flush(),i=new Promise((t=>jt((()=>{n=!0,t()}),e)));try{yield Promise.race([r,i])}finally{n&&r.catch((()=>{}))}}))()}Et(){this.flush().then((()=>{this.yt=0}),(e=>{this.yt++,this.it.error(`PostHog logs flush failed:`,e)})).finally((()=>{!this._instance.isDisabled&&this.jt()&&this.Dt(this.qt())}))}Tt(){this.Nt&&=(clearTimeout(this.Nt),void 0)}},Vt=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];function Ht(e){return String(e)+`000000`}function Ut(e,t,n,r){var i=``;return r&&(i=Object.keys(r).sort().map((e=>JSON.stringify(e)+`:`+JSON.stringify(r[e]))).join(`,`)),e+`\0`+t+`\0`+(n??``)+`\0`+i}var Wt=class{constructor(e,t,n){this._instance=e,this.Te=t,this.it=n,this.Bt=new Map,this.vt=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Vt=0}count(e,t,n){t===void 0&&(t=1),this.Wt({name:e,type:`count`,value:t,unit:n?.unit,attributes:n?.attributes})}gauge(e,t,n){this.Wt({name:e,type:`gauge`,value:t,unit:n?.unit,attributes:n?.attributes})}histogram(e,t,n){this.Wt({name:e,type:`histogram`,value:t,unit:n?.unit,attributes:n?.attributes})}flush(){var e=this,t=this.vt,n=function(){var n=h((function*(){t&&(yield t.catch((()=>{}))),yield e.Zt()}));return function(){return n.apply(this,arguments)}}()().finally((()=>{this.vt===n&&(this.vt=null)}));return this.vt=n,n}drainWindow(){if(this.Bt.size===0)return null;var e=this.Bt;return this.Bt=new Map,this.Ht=!1,this.Ut=new Map,this.zt=new Set,this.Gt(e)}reset(){this.Vt++,this.Tt(),this.Bt=new Map,this.vt=null,this.Ht=!1,this.Ut=new Map,this.zt=new Set}Wt(e){if(!this._instance.isDisabled&&!this._instance.optedOut){var t=this.Rt(e);if(t!==null)if(t.name&&typeof t.name==`string`)if(typeof t.value==`number`&&Number.isFinite(t.value))if(t.type===`count`&&0>t.value)this.it.warn(`Dropping count '`+t.name+`': counters are monotonic, value must be >= 0`);else{var n,r;try{n=t.attributes?g({},t.attributes):void 0,r=Ut(t.type,t.name,t.unit,n)}catch(e){this.it.warn(`Dropping metric '`+t.name+`': attributes could not be serialized`,e);return}var i=this.Bt.get(r);if(!i){if(!this.Qt())return;i={name:t.name,type:t.type,unit:t.unit,attributes:n,windowStartMs:Date.now()},this.Bt.set(r,i)}var a=this.Ut.get(t.name);a===void 0?this.Ut.set(t.name,t.type):a===t.type||this.zt.has(t.name)||(this.zt.add(t.name),this.it.warn(`Metric name '`+t.name+`' is already used as a `+
1a+`; recording it as a `+t.type+` too will blend both series in charts. Use a distinct name.`)),this.Jt(i,t.value),this.Dt()}else this.it.warn(`Dropping metric '`+t.name+`': value must be a finite number`);else this.it.warn(`Dropping metric with empty name`)}}Qt(){return this.Te.maxSeriesPerFlush>this.Bt.size||(this.Ht||(this.Ht=!0,this.it.warn(`Metric series cap reached (`+this.Te.maxSeriesPerFlush+` per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Jt(e,t){switch(e.type){case`count`:e.total=(e.total??0)+t;break;case`gauge`:e.last=t;break;case`histogram`:e.hist||={count:0,sum:0,min:t,max:t,bucketCounts:Array(Vt.length+1).fill(0)};var n=e.hist;n.count+=1,n.sum+=t,n.min=Math.min(n.min,t),n.max=Math.max(n.max,t),n.bucketCounts[function(e,t){for(var n=0;t.length>n;n++)if(t[n]>=e)return n;return t.length}(t,Vt)]+=1}}Rt(e){var t=this.Te.beforeSend;if(!t)return e;var n=N(t)?t:[t],r=e;for(var i of n)try{var a=i(r);if(!a)return this.it.info(`Metric was rejected in beforeSend function`),null;r=a}catch(e){return this.it.error(`Error in beforeSend function for metric:`,e),null}return r}Dt(){this.Nt||=jt((()=>{this.Nt=void 0,this.flush().catch((e=>{this.it.error(`Metrics flush failed:`,e)}))}),this.Te.flushIntervalMs)}Tt(){this.Nt&&=(clearTimeout(this.Nt),void 0)}Zt(){var e=this;return h((function*(){if(e.Bt.size!==0){var t=e.Bt;e.Bt=new Map,e.Ht=!1,e.Ut=new Map,e.zt=new Set;var n=e.Vt,r=yield e._instance.Kt(e.Gt(t));if(n===e.Vt)switch(r.kind){case`ok`:return;case`retry-later`:e.Yt(t),e.Dt();return;case`too-large`:e.it.warn(`Metrics batch exceeded the server size limit and was dropped`);return;case`fatal`:e.it.error(`Failed to send metrics batch:`,r.error);return}}}))()}Gt(e){return t=this.Xt(e),n=function(e,t,n){return g({},e.resourceAttributes,{"service.name":e.serviceName||`unknown_service`},e.environment&&{"deployment.environment":e.environment},e.serviceVersion&&{"service.version":e.serviceVersion},{"telemetry.sdk.name":t,"telemetry.sdk.version":n})}(this.Te,this._instance.getLibraryId(),this._instance.getLibraryVersion()),r=this._instance.getLibraryId(),i=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:It(n)},scopeMetrics:[{scope:{name:r,version:i},metrics:t}]}]};var t,n,r,i}Xt(e){var t=Ht(Date.now()),n=new Map;for(var r of e.values()){var i=Ut(r.type,r.name,r.unit,void 0),a=n.get(i);a||(a=g({name:r.name},r.unit&&{unit:r.unit}),r.type===`count`?a.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:r.type===`gauge`?a.gauge={dataPoints:[]}:a.histogram={aggregationTemporality:1,dataPoints:[]},n.set(i,a));var o=It(r.attributes??{}),s=Ht(r.windowStartMs);if(r.type===`count`){var c={attributes:o,startTimeUnixNano:s,timeUnixNano:t,asDouble:r.total??0};a.sum.dataPoints.push(c)}else if(r.type===`gauge`){var l={attributes:o,timeUnixNano:t,asDouble:r.last??0};a.gauge.dataPoints.push(l)}else r.hist&&a.histogram.dataPoints.push({attributes:o,startTimeUnixNano:s,timeUnixNano:t,count:r.hist.count,sum:r.hist.sum,min:r.hist.min,max:r.hist.max,bucketCounts:r.hist.bucketCounts,explicitBounds:Vt})}return Array.from(n.values())}Yt(e){for(var t of e){var n=t[0],r=t[1],i=this.Bt.get(n);if(i)switch(i.windowStartMs=Math.min(i.windowStartMs,r.windowStartMs),i.type){case`count`:i.total=(i.total??0)+(r.total??0);break;case`gauge`:break;case`histogram`:if(r.hist)if(i.hist){i.hist.count+=r.hist.count,i.hist.sum+=r.hist.sum,i.hist.min=Math.min(i.hist.min,r.hist.min),i.hist.max=Math.max(i.hist.max,r.hist.max);for(var a=0;i.hist.bucketCounts.length>a;a++)i.hist.bucketCounts[a]+=r.hist.bucketCounts[a]}else i.hist=r.hist}else this.Qt()&&this.Bt.set(n,r)}}},Gt,Kt,qt;function Jt(e){var t=globalThis._posthogChunkIds;if(t){var n=Object.keys(t);return qt&&n.length===Kt||(Kt=n.length,qt=n.reduce(((n,r)=>{Gt||={};var i=Gt[r];if(i)n[i[0]]=i[1];else for(var a=e(r),o=a.length-1;o>=0;o--){var s=a[o]?.filename,c=t[r];if(s&&c){n[s]=c,Gt[r]=[s,c];break}}return n}),{})),qt}}var Yt=class{constructor(e,t,n){n===void 0&&(n=[]),this.coercers=e,this.stackParser=t,this.modifiers=n}buildFromUnknown(e,t){t===void 0&&(t={});var n=t&&t.mechanism||{handled:!0,type:`generic`},r=this.buildCoercingContext(n,t,0).apply(e),i=this.buildParsingContext(t),a=this.parseStacktrace(r,i);return{$exception_list:this.convertToExceptionList(a,n),$exception_level:`error`}}modifyFrames(e){var t=this;return h((function*(){for(var n of e)n.stacktrace&&n.stacktrace.frames&&N(n.stacktrace.frames)&&(n.stacktrace.frames=yield t.applyModifiers(n.stacktrace.frames));return e}))()}coerceFallback(e){return{type:`Error`,value:`Unknown error`,stack:e.syntheticException?.stack,synthetic:!0}}parseStacktrace(e,t){var n,r;return e.cause!=null&&(n=this.parseStacktrace(e.cause,t)),e.stack!=``&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.ski
1pFirstLines:0),t.chunkIdMap)),g({},e,{cause:n,stack:r})}applyChunkIds(e,t){return e.map((e=>(e.filename&&t&&(e.chunk_id=t[e.filename]),e)))}applyCoercers(e,t){for(var n of this.coercers)if(n.match(e))return n.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return h((function*(){var n=e;for(var r of t.modifiers)n=yield r(n);return n}))()}convertToExceptionList(e,t){var n,r,i={type:e.type,value:e.value,mechanism:{type:t.type??`generic`,handled:(n=t.handled)==null||n,synthetic:(r=e.synthetic)!=null&&r}};e.stack&&(i.stacktrace={type:`raw`,frames:e.stack});var a=[i];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,g({},t,{handled:!0}))),a}buildParsingContext(e){return{chunkIdMap:Jt(this.stackParser),skipFirstLines:e.skipFirstLines??1}}buildCoercingContext(e,t,n){n===void 0&&(n=0);var r=(n,r)=>{if(4>=r){var i=this.buildCoercingContext(e,t,r);return this.applyCoercers(n,i)}};return g({},t,{syntheticException:n==0?t.syntheticException:void 0,mechanism:e,apply:e=>r(e,n),next:e=>r(e,n+1)})}},Xt=`?`;function Zt(e,t,n,r,i){var a={platform:e,filename:t,function:n===`<anonymous>`?Xt:n,in_app:!0};return I(r)||(a.lineno=r),I(i)||(a.colno=i),a}var Qt=(e,t)=>{var n=e.indexOf(`safari-extension`)!==-1,r=e.indexOf(`safari-web-extension`)!==-1;return n||r?[e.indexOf(`@`)===-1?Xt:e.split(`@`)[0],n?`safari-extension:`+t:`safari-web-extension:`+t]:[e,t]},$t=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,en=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,tn=/\((\S*)(?::(\d+))(?::(\d+))\)/,nn=(e,t)=>{var n=$t.exec(e);if(n)return Zt(t,n[1],Xt,+n[2],+n[3]);var r=en.exec(e);if(r){if(r[2]&&r[2].indexOf(`eval`)===0){var i=tn.exec(r[2]);i&&(r[2]=i[1],r[3]=i[2],r[4]=i[3])}var a=Qt(r[1]||Xt,r[2]);return Zt(t,a[1],a[0],r[3]?+r[3]:void 0,r[4]?+r[4]:void 0)}},rn=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,an=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,on=(e,t)=>{var n=rn.exec(e);if(n){if(n[3]&&n[3].indexOf(` > eval`)>-1){var r=an.exec(n[3]);r&&(n[1]=n[1]||`eval`,n[3]=r[1],n[4]=r[2],n[5]=``)}var i=n[3],a=n[1]||Xt,o=Qt(a,i);return Zt(t,i=o[1],a=o[0],n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},sn=/\(error: (.*)\)/,cn=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var n=L(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:n?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 ve(e,`DOMException`)}isDOMError(e){return ve(e,`DOMError`)}},ln=class{match(e){return(e=>e instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var n=e.message;return String(n.error&&typeof n.error.message==`string`?n.error.message:n)}getStack(e){return e.stacktrace||e.stack||void 0}},un=class{constructor(){}match(e){return ve(e,`ErrorEvent`)&&e.error!=null}coerce(e,t){return t.apply(e.error)||{type:`ErrorEvent`,value:e.message,stack:t.syntheticException?.stack,synthetic:!0}}},dn=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,fn=class{match(e){return typeof e==`string`}coerce(e,t){var n=this.getInfos(e),r=n[0],i=n[1];return{type:r??`Error`,value:i??e,stack:t.syntheticException?.stack,synthetic:!0}}getInfos(e){var t=`Error`,n=e,r=e.match(dn);return r&&(t=r[1],n=r[2]),[t,n]}},pn=[`fatal`,`error`,`warning`,`log`,`info`,`debug`];function mn(e,t){t===void 0&&(t=40);var n=Object.keys(e);if(n.sort(),!n.length)return`[object has no keys]`;for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(`, `);if(t>=i.length)return r===n.length?i:i.length>t?i.slice(0,t)+`...`:i}return``}var hn=class{match(e){return typeof e==`object`&&!!e}coerce(e,t){var n=this.getErrorPropertyFromObject(e);return n?t.apply(n):{type:this.getType(e),value:this.getValue(e),stack:t.syntheticException?.stack,level:this.isSeverityLevel(e.level)?e.level:`error`,synthetic:!0}}getType(e){return ye(e)?e.constructor.name:`Error`}getValue(e){if(`name`in e&&typeof e.name==`string`){var t=`'`+e.name+`' captured as exception`;return`message`in e&&typeof e.message==`string`&&(t+=` with message: '`+e.message+`'`),t}if(`message`in e&&typeof e.message==`string`)return e.message;var n=this.getObjectClassName(e);return(n&&n!==`Object`?`'`+n+`'`:`Object`)+` captured as exception with keys: `+mn(e)}isSeverityLevel(e){return L(e)&&!de(e)&&pn.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var n=e[t];if(Mt(n))return n}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},gn=class{match(e){return ye(e)}coerce(e,t){var n=e.constructor.name;return{type:n,value:n+` captured as exception with keys: `+mn(e),stack:t.syntheticException?.stack,synthetic:!0}}},_n=class{match(e){return _e(e)}coerce(e,t){return{type:`Error`,value:`Primitive value captured as exception: `+String(e),stack:t.syntheticException?.stack,synthetic:!0}}},vn=class{match(e){return ve(e,`PromiseRejectionEvent`)||this.isCu
1stomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!ye(e))return!1;try{var t=e.detail;return typeof t==`object`&&!!t&&`reason`in t}catch{return!1}}coerce(e,t){var n=this.getUnhandledRejectionReason(e);return _e(n)?{type:`UnhandledRejection`,value:`Non-Error promise rejection captured with value: `+String(n),stack:t.syntheticException?.stack,synthetic:!0}:t.apply(n)}getUnhandledRejectionReason(e){try{if(`reason`in e)return e.reason;if(`detail`in e&&e.detail!=null&&typeof e.detail==`object`&&`reason`in e.detail)return e.detail.reason}catch{}return e}},yn=`$message`,bn=`$timestamp`,xn=new Set([yn,bn]),Sn={enabled:!0,max_bytes:32768};function Cn(e){return e?{enabled:e.enabled??Sn.enabled,max_bytes:Tn(e.max_bytes,Sn.max_bytes)}:g({},Sn)}var wn=class{constructor(e){this.$e=[],this.ze=0,this.Te=Cn(e)}setConfig(e){this.Te=Cn(e),this.Ze()}add(e){var t=function(e){var t;try{t=oe(e)}catch{return}try{var n=JSON.parse(t);if(!F(n))return;var r=n,i=r[yn],a=r[bn];return!L(i)||i.trim().length===0||!L(a)&&!B(a)?void 0:{step:r,json:t}}catch{return}}(e);if(t){var n=function(e){if(typeof TextEncoder<`u`)return new TextEncoder().encode(e).length;for(var t=encodeURIComponent(e),n=0,r=0;t.length>r;r++)t[r]===`%`?(n+=1,r+=2):n+=1;return n}(t.json);n>this.Te.max_bytes||(this.$e.push({step:t.step,bytes:n}),this.ze+=n,this.Ze())}}getAttachable(){return this.$e.map((e=>e.step))}clear(){this.$e=[],this.ze=0}size(){return this.$e.length}Ze(){for(;this.ze>this.Te.max_bytes&&this.$e.length>0;){var e=this.$e.shift();e&&(this.ze-=e.bytes)}}};function Tn(e,t){if(!B(e)||e===1/0||e===-1/0)return t;var n=Math.floor(e);return 0>n?t:n}var En=function(t,n){var r=(n===void 0?{}:n).debugEnabled,i={k(n){if(e&&(p.DEBUG||e.POSTHOG_DEBUG||r)&&!I(e.console)&&e.console){for(var i=(`__rrweb_original__`in e.console[n])?e.console[n].__rrweb_original__:e.console[n],a=arguments.length,o=Array(a>1?a-1:0),s=1;a>s;s++)o[s-1]=arguments[s];i(t,...o)}},debug(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];i.k(`debug`,...t)},info(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];i.k(`log`,...t)},warn(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];i.k(`warn`,...t)},error(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];i.k(`error`,...t)},critical(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n]},uninitializedWarning(e){i.error(`You must initialize PostHog before calling `+e)},createLogger:(e,n)=>En(t+` `+e,n)};return i},H=En(`[PostHog.js]`),U=H.createLogger,Dn=U(`[ExternalScriptsLoader]`),On=(e,t,n)=>{if(e.config.disable_external_dependency_loading)return Dn.warn(t+` was requested but loading of external scripts is disabled.`),n(`Loading of external scripts is disabled`);var i=r?.querySelectorAll(`script`);if(i){for(var a,o=function(){if(i[s].src===t){var e=i[s];return e.__posthog_loading_callback_fired?{v:n()}:(e.addEventListener(`load`,(t=>{e.__posthog_loading_callback_fired=!0,n(void 0,t)})),e.onerror=e=>n(e),{v:void 0})}},s=0;i.length>s;s++)if(a=o())return a.v}var c=()=>{if(!r)return n(`document not found`);var i=r.createElement(`script`);if(i.type=`text/javascript`,i.crossOrigin=`anonymous`,i.src=t,i.onload=e=>{i.__posthog_loading_callback_fired=!0,n(void 0,e)},i.onerror=e=>n(e),e.config.prepare_external_dependency_script&&(i=e.config.prepare_external_dependency_script(i)),!i)return n(`prepare_external_dependency_script returned null`);if(e.config.external_scripts_inject_target===`head`)r.head.appendChild(i);else{var a,o=r.querySelectorAll(`body > script`);o.length>0?(a=o[0].parentNode)==null||a.insertBefore(i,o[0]):r.body.appendChild(i)}};r!=null&&r.body?c():r?.addEventListener(`DOMContentLoaded`,c)};f.__PosthogExtensions__=f.__PosthogExtensions__||{},f.__PosthogExtensions__.loadExternalDependency=(e,t,n)=>{if(t!==`remote-config`){var r;if(e.config.strict_script_versioning)r=e.requestRouter.endpointFor(`assets`,`/static/`+e.version+`/`+t+`.js`);else{var i=`/static/`+t+`.js?v=`+e.version;if(t===`toolbar`){var a=3e5;i=i+`&t=`+Math.floor(Date.now()/a)*a}r=e.requestRouter.endpointFor(`assets`,i)}On(e,r,n)}else On(e,e.requestRouter.endpointFor(`assets`,`/array/`+e.config.token+`/config.js`),n)},f.__PosthogExtensions__.loadSiteApp=(e,t,n)=>{On(e,e.requestRouter.endpointFor(`api`,t),n)},p.DEBUG=!1,p.LIB_VERSION=`1.409.5`,p.LIB_NAME=`web`;var kn=`$people_distinct_id`,An=`$device_id`,jn=`$device_model`,Mn=`__alias`,Nn=`__timers`,Pn=`$autocapture_disabled_server_side`,Fn=`$heatmaps_enabled_server_side`,In=`$exception_capture_enabled_server_side`,Ln=`$error_tracking_suppression_rules`,Rn=`$error_tracking_capture_extension_exceptions`,zn=`$web_vitals_enabled_server_side`,Bn=`$dead_clicks_enabled_server_side`,Vn=`$product_tours_enabled_server_side`,Hn=`$web_vitals_allowed_metrics`,Un=`$session_recording_remote_config`,Wn=`$replay_sample_rate`,Gn=`$replay_override_sampling`,Kn=`$replay_override_linked_flag`,qn=`$replay_override_url_trigger`,Jn=`$replay_override_event_trigger`,Yn=`$sesid`,Xn=`$session_is_sampled`,Zn=`$enabled_feature_flags`,Qn=`$active_feature_flags`,$n=`$early_access_features`,er=`$feature_flag_details`,tr=`$feature_flag_payloads`,nr=`$feature_flag_request_id`,rr=`$minimal_flag_called_events`,ir=`$override_feature_flags`,ar=`$override_feature_flag_payloads`,or=`$stored_person_properties`,sr=`$stored_group_properties`,cr=`$surveys`,lr=`$surveys_loaded_at`,ur=`$surveys_activated`,dr=`$surveys_activated_session`,fr=`ph_product_tours`,pr=`$flag_call_reported`,mr=`$flag_call_reported_session_id`,hr=`$feature_flag_errors`,gr=`$feature_flag_evaluated_at`,_r=`$user_state`,vr=`$client_session_props`,yr=`$capture_rate_limit`,br=`$initial_campaign_params`,xr=`$initial_referrer_info`,Sr=`$initial_person_info`,Cr=`$epp`,wr=`$posthog_cookieless`,Tr=`$cookieless_mode`,Er=`$sdk_debug_extensions_init_method`,Dr=`$sdk_debug_extensions_init_time_ms`,Or=`$sdk_debug_recording_script_not_loaded`,kr=`PostHog loadExternalDependency extension not found.`,Ar=`on_reject`,jr=`always`,Mr=`anonymous`,Nr=`identified`,Pr=`identified_only`,Fr=`visibilitychange`,Ir=`beforeunload`,Lr=`$pageview`,Rr=`$pageleave`,zr=`$identify`,Br=`$groupidentify`;function Vr(e,t){N(e)&&e.forEach(t)}function W(e,t){if(!z(e))if(N(e))e.forEach(t);else if(me(e))e.forEach(((e,n)=>t(e,n)));else for(var n in e)ce.call(e,n)&&t(e[n],n)}var G=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];for(var i of n)for(var a in i)i[a]!==void 0&&(e[a]=i[a]);return e};function Hr(e){for(var t=Object.keys(e),n=t.length,r=Array(n);n--;)r[n]=[t[n],e[t[n]]];return r}var Ur=function(e){try{return e()}catch{return}},Wr=function(e){return function(){try{for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,n)}catch(e){H.critical(`Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A.`),H.critical(e)}}},Gr=function(e){var t={};return W(e,(function(e,n){(L(e)&&e.length>0||B(e))&&(t[n]=e)})),t},Kr=[`herokuapp.com`,`vercel.app`,`netlify.app`];function qr(e){var t=e?.hostname;if(!L(t))return!1;var n=t.split(`.`).slice(-2).join(`.`);for(var r of Kr)if(n===r)return!1;return!0}function K(e,t,n,r){var i=r??{},a=i.capture,o=i.passive;e?.addEventListener(t,n,{capture:a!==void 0&&a,passive:o===void 0||o})}function Jr(e){return e.name===`ph_toolbar_internal`}var Yr=e=>{if(r){try{for(var t=e+`=`,n=r.cookie.split(`;`).filter((e=>e.length)),i=0;n.length>i;i++){for(var a=n[i];a.charAt(0)==` `;)a=a.substring(1,a.length);if(a.indexOf(t)===0)return decodeURIComponent(a.substring(t.length,a.length))}}catch{}return null}};Math.trunc||(Math.trunc=function(e){return 0>e?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return B(e)&&isFinite(e)&&Math.floor(e)===e});var Xr=class e{constructor(e){if(this.bytes=e,e.length!==16)throw TypeError(`not 128-bit length`)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||0>t||0>n||0>r||0>i||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw RangeError(`invalid field value`);var a=new Uint8Array(16);return a[0]=t/2**40,a[1]=t/2**32,a[2]=t/2**24,a[3]=t/2**16,a[4]=t/256,a[5]=t,a[6]=112|n>>>8,a[7]=n,a[8]=128|r>>>24,a[9]=r>>>16,a[10]=r>>>8,a[11]=r,a[12]=i>>>24,a[13]=i>>>16,a[14]=i>>>8,a[15]=i,new e(a)}toString(){for(var e=``,t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+=`-`);
1if(e.length!==36)throw Error(`Invalid UUIDv7 was generated`);return e}clone(){return new e(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var n=this.bytes[t]-e.bytes[t];if(n!==0)return Math.sign(n)}return 0}},Zr=class{generate(){var e=this.generateOrAbort();if(!I(e))return e;this.S=0;var t=this.generateOrAbort();if(I(t))throw Error(`Could not generate UUID after timestamp reset`);return t}generateOrAbort(){var e=Date.now();if(e>this.S)this.S=e,this.C();else{if(this.S>=e+1e4)return;this.M++,this.M>4398046511103&&(this.S++,this.C())}return Xr.fromFieldsV7(this.S,Math.trunc(this.M/2**30),this.M&2**30-1,this.I.nextUint32())}C(){this.M=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}constructor(){this.S=0,this.M=0,this.I=new ei}},Qr,$r=e=>{if(typeof UUIDV7_DENY_WEAK_RNG<`u`&&UUIDV7_DENY_WEAK_RNG)throw Error(`no cryptographically strong RNG available`);for(var t=0;e.length>t;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};e&&!I(e.crypto)&&crypto.getRandomValues&&($r=e=>crypto.getRandomValues(e));var ei=class{nextUint32(){return this.R.length>this.O||($r(this.R),this.O=0),this.R[this.O++]}constructor(){this.R=new Uint32Array(8),this.O=1/0}},ti=()=>ni().toString(),ni=()=>(Qr||=new Zr).generate(),ri=``,ii=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,ai={N:()=>!!r,P(e){H.error(`cookieStore error: `+e)},q:Yr,F(e){var t;try{t=JSON.parse(ai.q(e))||{}}catch{}return t},A(e,t,n,i,a){if(!r)return!1;try{var o=``,s=``,c=function(e,t){if(t){var n=function(e,t){if(t===void 0&&(t=r),ri)return ri;if(!t||[`localhost`,`127.0.0.1`].includes(e))return``;for(var n=e.split(`.`),i=Math.min(n.length,8),a=`dmn_chk_`+ti();!ri&&i--;){var o=n.slice(i).join(`.`),s=a+`=1;domain=.`+o+`;path=/`;t.cookie=s+`;max-age=3`,t.cookie.includes(a)&&(t.cookie=s+`;max-age=0`,ri=o)}return ri}(e);if(!n){var i=(e=>{var t=e.match(ii);return t?t[0]:``})(e);i!==n&&H.info(`Warning: cookie subdomain discovery mismatch`,i,n),n=i}return n?`; domain=.`+n:``}return``}(r.location.hostname,i);if(n){var l=new Date;l.setTime(l.getTime()+864e5*n),o=`; expires=`+l.toUTCString()}a&&(s=`; secure`);var u=e+`=`+encodeURIComponent(JSON.stringify(t))+o+`; SameSite=Lax; path=/`+c+s;return u.length>3686.4&&H.warn(`cookieStore warning: large cookie, len=`+u.length),r.cookie=u,!0}catch{return!1}},D(e,t){if(r!=null&&r.cookie)try{ai.A(e,``,-1,t)}catch{return}}},oi=null,q={N(){if(!R(oi))return oi;var t=!0;if(I(e))t=!1;else try{var n=`__mplssupport__`;q.A(n,`xyz`),q.q(n)!==`"xyz"`&&(t=!1),q.D(n)}catch{t=!1}return t||H.error(`localStorage unsupported; falling back to cookie store`),oi=t,t},P(e){H.error(`localStorage error: `+e)},q(t){try{return e?.localStorage.getItem(t)}catch(e){q.P(e)}return null},F(e){try{return JSON.parse(q.q(e))||{}}catch{}return null},A(t,n){try{return e?.localStorage.setItem(t,JSON.stringify(n)),!0}catch(e){q.P(e)}return!1},D(t){try{e?.localStorage.removeItem(t)}catch(e){q.P(e)}}},si=[An,`distinct_id`,Yn,Xn,Cr,Sr,_r],ci={},li={N:()=>!0,P(e){H.error(`memoryStorage error: `+e)},q:e=>ci[e]||null,F:e=>ci[e]||null,A:(e,t)=>(ci[e]=t,!0),D(e){delete ci[e]}},ui=null,J={N(){if(!R(ui))return ui;if(ui=!0,I(e))ui=!1;else try{var t=`__support__`;J.A(t,`xyz`),J.q(t)!==`"xyz"`&&(ui=!1),J.D(t)}catch{ui=!1}return ui},P(e){H.error(`sessionStorage error: `,e)},q(t){try{return e?.sessionStorage.getItem(t)}catch(e){J.P(e)}return null},F(e){try{return JSON.parse(J.q(e))||null}catch{}return null},A(t,n){try{return e?.sessionStorage.setItem(t,JSON.stringify(n)),!0}catch(e){J.P(e)}return!1},D(t){try{e?.sessionStorage.removeItem(t)}catch(e){J.P(e)}}},di=class{constructor(e){this._instance=e}get Te(){return this._instance.config}get consent(){return this.Ge()?0:this.Qe}isOptedOut(){return this.Te.cookieless_mode===jr||this.isRejected()||this.consent===-1&&this.Te.cookieless_mode===Ar}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Te.opt_out_capturing_by_default}optInOut(e){this.Je.A(this.Ke,+!!e,this.Te.cookie_expiration,this.Te.cross_subdomain_cookie,this.Te.secure_cookie)}reset(){this.Je.D(this.Ke,this.Te.cross_subdomain_cookie)}get Ke(){var e=this._instance.config,t=e.token,n=e.opt_out_capturing_cookie_prefix;return e.consent_persistence_name||(n?n+t:`__ph_opt_in_out_`+t)}get Qe(){var e=this.Je.q(this.Ke);return xe(e)?1:M(Se,e)?0:-1}get Je(){var e=this.Te.opt_out_capturing_persistence_type,t=e===`localStorage`?q:ai;if(!this.Ye||this.Ye!==t){this.Ye=t;var n=e===`localStorage`?ai:q;n.q(this.Ke)&&(this.Ye.q(this.Ke)||this.optInOut(xe(n.q(this.Ke))),n.D(this.Ke,this.Te.cross_subdomain_cookie))}return this.Ye}Ge(){return!!this.Te.respect_dnt&&[n?.doNotTrack,n?.msDoNotTrack,f.doNotTrack].some((e=>xe(e)))}};function fi(e,t){var n,r=e==null||(n=e.config)==null?void 0:n.get_current_url;if(!P(r))return t;try{var i=r(t);return L(i)&&i?i:t}catch(e){return H.error(`Error in get_current_url, falling back to window.location.href`,e),t}}var pi=`__POSTHOG_TOOLBAR__`,mi=1,hi=3,gi=11;function _i(e){return e instanceof Element&&(e.id===pi||!(e.closest==null||!e.closest(`.toolbar-global-fade-container`)))}function vi(e){return!!e&&e.nodeType===mi}function yi(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function bi(e){return!!e&&e.nodeType===hi}function xi(e){return!!e&&e.nodeType===gi&&vi(e.host)}var Si=1e3;function Ci(e){return e?ie(e).split(/\s+/):[]}function wi(t,n){var r=function(t){var n,r=e==null||(n=e.location)==null?void 0:n.href;return I(r)?void 0:fi(t,r)}(n);return!!(r&&t&&t.some((e=>r.match(e))))}function Ti(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 Ci(t)}function Ei(e){return z(e)?null:ie(e).split(/(\s+)/).filter((e=>Xi(e))).join(``).replace(/[\r\n]/g,` `).replace(/[ ]+/g,` `).substring(0,255)}function Di(e){var t=``;return Vi(e)&&!Hi(e)&&e.childNodes&&e.childNodes.length&&W(e.childNodes,(function(e){bi(e)&&e.textContent&&(t+=Ei(e.textContent)??``)})),ie(t)}function Oi(e){var t;return I(e.target)?e.srcElement||null:(t=e.target)!=null&&t.shadowRoot?e.composedPath()[0]||null:e.target||null}var ki=[`a`,`button`,`form`,`input`,`select`,`textarea`,`label`];function Ai(e,t){if(I(t))return!0;var n,r=function(e){if(t.some((t=>function(e,t){var n=e.matches||e.matchesSelector||e.msMatchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.oMatchesSelector;try{return!!n&&n.call(e,t)}catch{return!1}}(e,t))))return{v:!0}};for(var i of e)if(n=r(i))return n.v;return!1}function ji(e){var t=e.parentNode;return!(!t||!vi(t))&&t}var Mi=[`.ph-no-autocapture`,`[data-ph-no-autocapture]`],Ni=[`next`,`previous`,`prev`,`>`,`<`],Pi=[...Ni,`+`,`-`,`â`,`â`],Fi=(e,t)=>/[a-z0-9]/i.test(t)?e.includes(t):e===t,Ii=[`.ph-no-rageclick`,`.ph-no-capture`],Li=[``,`text`,`search`,`email`,`password`,`url`,`tel`,`number`];function Ri(t,n){if(!e||zi(t))return!1;var r,i,a,o;if(pe(n)?(r=!!n&&Ii,i=void 0,a=!1):(r=n?.css_selector_ignorelist??Ii,i=n?.content_ignorelist,a=(o=n?.ignore_text_selection)!=null&&o),!1===r||a&&function(e){return!(!e||!vi(e))&&(!!yi(e,`textarea`)||(yi(e,`input`)?M(Li,(e.getAttribute(`type`)||``).toLowerCase()):function(e){if(e.isContentEditable)return!0;var t=e.getAttribute==null?void 0:e.getAttribute(`contenteditable`);return t===`true`||t===``}(e)))}(t))return!1;var s=Bi(t,!1).targetElementList;return!function(e,t){if(!1===e||I(e))return!1;var n;if(!0===e)n=Ni;else{if(!N(e))return!1;if(e.length>10)return H.error(`[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching.`),!1;n=e.map((e=>e.toLowerCase()))}return t.some((e=>{var t=e.safeText,r=e.ariaLabel;return n.some((e=>Fi(t,e)||Fi(r,e)))}))}(i,s.map((e=>({safeText:Di(e).toLowerCase(),ariaLabel:e.getAttribute(`aria-label`)?.toLowerCase().trim()||``}))))&&!Ai(s,r)}var zi=e=>!e||yi(e,`html`)||!vi(e),Bi=(t,n)=>{if(!e||zi(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var r=!1,i=[t],a=t;a.parentNode&&!yi(a,`body`);)if(xi(a.parentNode))i.push(a.parentNode.host),a=a.parentNode.host;else{var o=ji(a);if(!o)break;if(n||ki.indexOf(o.tagName.toLowerCase())>-1)r=!0;else try{var s=e.getComputedStyle(o);s&&s.getPropertyValue(`cursor`)===`pointer`&&(r=!0)}catch{}i.push(o),a=o}return{parentIsUsefulElement:r,targetElementList:i}};function Vi(e){for(var t=new Set,n=0,r=e;r.parentNode&&!yi(r,`body`);r=r.parentNode){if(n++>=Si||t.has(r))return!1;t.add(r);var i=Ti(r);if(M(i,`ph-sensitive`)||M(i,`ph-no-capture`))return!1}if(M(Ti(e),`ph-include`))return!0;var a=e.type||``;if(L(a))switch(a.toLowerCase()){case`hidden`:case`password`:return!1}
1var o=e.name||e.id||``;return!L(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,``))}function Hi(e){return!!(yi(e,`input`)&&![`button`,`checkbox`,`submit`,`reset`].includes(e.type)||yi(e,`select`)||yi(e,`textarea`)||e.getAttribute(`contenteditable`)===`true`)}var Ui=RegExp(`^(?:(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}))$`),Wi=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,Gi=[16,15,14,13],Ki=RegExp(`^(\\d{3}-?\\d{2}-?\\d{4})$`),qi=RegExp(`(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))`,`g`),Ji=/[0-9A-Za-z_]/;function Yi(e){for(var t=0,n=!1,r=e.length-1;r>=0;r--){var i=e.charCodeAt(r)-48;n&&(i*=2)>9&&(i-=9),t+=i,n=!n}return t%10==0}function Xi(e,t){return t===void 0&&(t=!0),!(z(e)||L(e)&&(e=ie(e),(t?Ui.test((e||``).replace(/[- ]/g,``)):function(e){var t;for(Wi.lastIndex=0;t=Wi.exec(e);){var n=t[2];if(n)for(var r=n.replace(/[- ]/g,``),i=0;r.length>i;i++)for(var a of Gi){var o=i+a;if(r.length>=o){var s=r.slice(i,o);if(Ui.test(s)&&Yi(s))return!0}}}return!1}(e))||(t?Ki.test(e):function(e){var t;for(qi.lastIndex=0;t=qi.exec(e);){var n=t[1],r=t[3];if(!(n&&r&&Ji.test(n)&&Ji.test(r)))return!0}return!1}(e))))}function Zi(e){var t=Di(e);return Xi(t=(t+` `+Qi(e)).trim())?t:``}function Qi(e){var t=``;return e&&e.childNodes&&e.childNodes.length&&W(e.childNodes,(function(e){if(e&&e.tagName?.toLowerCase()===`span`)try{var n=Di(e);t=(t+` `+n).trim(),e.childNodes&&e.childNodes.length&&(t=(t+` `+Qi(e)).trim())}catch(e){H.error(`[AutoCapture]`,e)}})),t}function $i(e){return e.replace(/"|\\"/g,`\\"`)}function ea(e){var t=e.attr__class;if(t)return N(t)?t:Ci(t)}var ta=U(`[Dead Clicks]`),na=()=>!0,ra=e=>{var t,n=!((t=e.instance.persistence)==null||!t.get_property(Bn)),r=e.instance.config.capture_dead_clicks;return pe(r)?r:!!F(r)||n},ia=class{get lazyLoadedDeadClicksAutocapture(){return this.Xe}constructor(e,t,n){this.instance=e,this.isEnabled=t,this.onCapture=n,this.startIfEnabledOrStop()}onRemoteConfig(e){if(e.ok){var t=e.config;`captureDeadClicks`in t&&(this.instance.persistence&&this.instance.persistence.register({[Bn]:t.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.tr((()=>{this.er()})):this.stop()}tr(e){var t,n;(t=f.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture?e():(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this.instance,`dead-clicks-autocapture`,(t=>{t?ta.error(`failed to load script`,t):e()}))}er(){var e;if(r){if(!this.Xe&&(e=f.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=F(this.instance.config.capture_dead_clicks)?g({},this.instance.config.capture_dead_clicks):{};t.__onCapture=this.onCapture,this.onCapture&&(t.capture_dead_swipes=!1),this.Xe=f.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.Xe.start(r),ta.info(`starting...`)}}else ta.error("`document` not found. Cannot start.")}stop(){this.Xe&&(this.Xe.stop(),this.Xe=void 0,ta.info(`stopping...`))}},aa=U(`[SegmentIntegration]`),oa=`posthog-js`;function sa(e,t){var n=t===void 0?{}:t,r=n.organization,i=n.projectId,a=n.prefix,o=n.severityAllowList,s=o===void 0?[`error`]:o,c=n.sendExceptionsToPostHog,l=c===void 0||c;return t=>{if(s!==`*`&&!s.includes(t.level)||!e.__loaded)return t;t.tags||={};var n=e.requestRouter.endpointFor(`ui`,`/project/`+e.config.token+`/person/`+e.get_distinct_id());t.tags[`PostHog Person URL`]=n,e.sessionRecordingStarted()&&(t.tags[`PostHog Recording URL`]=e.get_session_replay_url({withTimestamp:!0}));var o,c=t.exception?.values||[],u=c.map((e=>g({},e,{stacktrace:e.stacktrace?g({},e.stacktrace,{type:`raw`,frames:(e.stacktrace.frames||[]).map((e=>g({},e,{platform:`web:javascript`})))}):void 0}))),d={$exception_message:c[0]?.value||t.message,$exception_type:c[0]?.type,$exception_level:t.level,$exception_list:u,$sentry_event_id:t.event_id,$sentry_exception:t.exception,$sentry_exception_message:c[0]?.value||t.message,$sentry_exception_type:c[0]?.type,$sentry_tags:t.tags};return r&&i&&(d.$sentry_url=(a||`https://sentry.io/organizations/`)+r+`/issues/?project=`+i+`&query=`+t.event_id),l&&((o=e.exceptions)==null||o.sendExceptionEvent(d)),t}}var ca=class{constructor(e,t,n,r,i,a){this.name=oa,this.setupOnce=function(o){o(sa(e,{organization:t,projectId:n,prefix:r,severityAllowList:i,sendExceptionsToPostHog:a==null||a}))}}},la=class{constructor(e){this.rr=(e,t,n)=>{n&&(n.noSessionId||n.activityTimeout||n.sessionPastMaximumLength||n.crossTabAdoption)&&(H.info(`[PageViewManager] Session rotated, clearing pageview state`,{sessionId:e,changeReason:n}),this.ir=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.nr()}nr(){this.sr=this._instance.sessionManager?.onSessionId(this.rr)}destroy(){var e;(e=this.sr)==null||e.call(this),this.sr=void 0}doPageView(t,n){var r=this.ar(t,n);return this.ir={pathname:e?.location.pathname??``,pageViewId:n,timestamp:t},this._instance.scrollManager.resetContext(),r}doPageLeave(e){return this.ar(e,this.ir?.pageViewId)}doEvent(){return{$pageview_id:this.ir?.pageViewId}}ar(e,t){var n=this.ir;if(!n)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:n.pageViewId},i=this._instance.scrollManager.getContext();if(i&&!this._instance.config.disable_scroll_properties){var a=i.maxScrollHeight,o=i.lastScrollY,s=i.maxScrollY,c=i.maxContentHeight,l=i.lastContentY,u=i.maxContentY;if(!(I(a)||I(o)||I(s)||I(c)||I(l)||I(u))){a=Math.ceil(a),o=Math.ceil(o),s=Math.ceil(s),c=Math.ceil(c),l=Math.ceil(l),u=Math.ceil(u);var d=a>1?Ce(o/a,0,1,H):1,f=a>1?Ce(s/a,0,1,H):1,p=c>1?Ce(l/c,0,1,H):1,m=c>1?Ce(u/c,0,1,H):1;r=G(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:s,$prev_pageview_max_scroll_percentage:f,$prev_pageview_last_content:l,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:m})}}return n.pathname&&(r.$prev_pageview_pathname=n.pathname),n.timestamp&&(r.$prev_pageview_duration=(e.getTime()-n.timestamp.getTime())/1e3),r}},ua=[`flags`,`surveys`],da={[kn]:{exposure:`hidden`},[Mn]:{exposure:`hidden`},__cmpns:{exposure:`hidden`},[Nn]:{exposure:`hidden`},[Pn]:{exposure:`event`},[Fn]:{exposure:`hidden`},[In]:{exposure:`event`},[Ln]:{exposure:`hidden`},[Rn]:{exposure:`event`},[zn]:{exposure:`event`},[Bn]:{exposure:`event`},[Vn]:{exposure:`hidden`},[Hn]:{exposure:`event`},[Un]:{exposure:`hidden`},$session_recording_enabled_server_side:{exposure:`hidden`}
1,[Yn]:{exposure:`hidden`},[Xn]:{exposure:`event`},[Wn]:{exposure:`event`,shouldSkipFromEventProperties:e=>R(e)},$session_past_minimum_duration:{exposure:`event`},$session_recording_url_trigger_activated_session:{exposure:`event`},$session_recording_event_trigger_activated_session:{exposure:`event`},$debug_first_full_snapshot_timestamp:{exposure:`event`},$sess_rec_flush_size:{exposure:`hidden`},[Zn]:{exposure:`derived`,storageGroup:`flags`,shouldSkipFromEventProperties:(e,t)=>t(),transformToEventProperties(e){if(!F(e))return{};for(var t={},n=Object.keys(e),r=0;n.length>r;r++)t[`$feature/`+n[r]]=e[n[r]];return t}},[Qn]:{exposure:`event`,storageGroup:`flags`},[$n]:{exposure:`hidden`},[er]:{exposure:`hidden`,storageGroup:`flags`},[tr]:{exposure:`event`,storageGroup:`flags`},[nr]:{exposure:`event`,storageGroup:`flags`,volatile:!0},[rr]:{exposure:`hidden`,storageGroup:`flags`},[ir]:{exposure:`event`},[ar]:{exposure:`hidden`},[or]:{exposure:`hidden`},[sr]:{exposure:`hidden`},[cr]:{exposure:`hidden`,storageGroup:`surveys`},[lr]:{exposure:`hidden`,storageGroup:`surveys`,volatile:!0},[ur]:{exposure:`event`},[dr]:{exposure:`hidden`},[fr]:{exposure:`hidden`},$product_tours_activated:{exposure:`hidden`},$product_tours_activated_session:{exposure:`hidden`},$conversations_widget_session_id:{exposure:`event`},$conversations_ticket_id:{exposure:`event`},$conversations_widget_state:{exposure:`event`},$conversations_user_traits:{exposure:`event`},[pr]:{exposure:`hidden`},[mr]:{exposure:`hidden`},[hr]:{exposure:`hidden`},[gr]:{exposure:`hidden`,storageGroup:`flags`,volatile:!0},[_r]:{exposure:`hidden`},[vr]:{exposure:`hidden`},[yr]:{exposure:`hidden`},[br]:{exposure:`hidden`},[xr]:{exposure:`hidden`},[Sr]:{exposure:`hidden`},[Cr]:{exposure:`hidden`},[Gn]:{exposure:`event`},[Kn]:{exposure:`event`},[qn]:{exposure:`event`},[Jn]:{exposure:`event`},[Er]:{exposure:`event`},[Dr]:{exposure:`event`},[Or]:{exposure:`event`},$sdk_debug_replay_event_trigger_status:{exposure:`event`},$sdk_debug_replay_linked_flag_trigger_status:{exposure:`event`},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:`event`},$sdk_debug_replay_remote_trigger_matching_config:{exposure:`event`},$sdk_debug_replay_trigger_groups_count:{exposure:`event`},$sdk_debug_replay_url_trigger_status:{exposure:`event`},$session_recording_start_reason:{exposure:`event`}},fa=[[`$posthog_sr_group_event_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_url_trigger_`,{exposure:`hidden`}],[`$posthog_sr_group_sampling_`,{exposure:`hidden`}]],pa=e=>{var t=da[e];if(t)return t;for(var n of fa){var r=n[1];if(e.indexOf(n[0])===0)return r}},ma=(e,t)=>{try{return JSON.stringify(e,((e,t)=>typeof t==`bigint`?t.toString():t),t)}catch{return oe(e)}},ha=e=>{var t=r?.createElement(`a`);return I(t)?null:(t.href=e,t)},ga=function(e,t){for(var n,r=((e.split(`#`)[0]||``).split(/\?(.*)/)[1]||``).replace(/^\?+/g,``).split(`&`),i=0;r.length>i;i++){var a=r[i].split(`=`);
1if(a[0]===t){n=a;break}}if(!N(n)||2>n.length)return``;var o=n[1];try{o=decodeURIComponent(o)}catch{H.error(`Skipping decoding for malformed query param: `+o)}return o.replace(/\+/g,` `)},_a=function(e,t,n){if(!e||!t||!t.length)return e;for(var r=e.split(`#`),i=r[1],a=(r[0]||``).split(`?`),o=a[1],s=a[0],c=(o||``).split(`&`),l=[],u=0;c.length>u;u++){var d=c[u].split(`=`);N(d)&&(t.includes(d[0])?l.push(d[0]+`=`+n):l.push(c[u]))}var f=s;return o!=null&&(f+=`?`+l.join(`&`)),i!=null&&(f+=`#`+i),f},va=function(e,t){var n=e.match(RegExp(t+`=([^&]*)`));return n?n[1]:null},ya=(e,t)=>e>=t&&u(),ba=(e,t,n,r)=>{if(e===0){if(u()){var i=t+1;return i===n&&r(),i}return t}return 0},xa=`https?://(.*)`,Sa=[`gclid`,`gclsrc`,`dclid`,`gbraid`,`wbraid`,`fbclid`,`msclkid`,`twclid`,`li_fat_id`,`igshid`,`ttclid`,`rdt_cid`,`epik`,`qclid`,`sccid`,`irclid`,`_kx`],Ca=[`utm_source`,`utm_medium`,`utm_campaign`,`utm_content`,`utm_term`,`gad_source`,`mc_cid`,...Sa],wa=`<masked>`,Ta=[`li_fat_id`];function Ea(e,t,n){if(!r)return{};var i,a=t?[...Sa,...n||[]]:[],o=Da(_a(r.URL,a,wa),e);return G((i={},W(Ta,(function(e){var t=Yr(e);i[e]=t||null})),i),o)}function Da(e,t){var n=Ca.concat(t||[]),r={};return W(n,(function(t){r[t]=ga(e,t)||null})),r}function Oa(e){var t=function(e){return e?e.search(xa+`google.([^/?]*)`)===0?`google`:e.search(xa+`bing.com`)===0?`bing`:e.search(xa+`yahoo.com`)===0?`yahoo`:e.search(xa+`duckduckgo.com`)===0?`duckduckgo`:null:null}(e),n=t==`yahoo`?`p`:`q`,i={};if(!R(t)){i.$search_engine=t;var a=r?ga(r.referrer,n):``;a.length&&(i.ph_keyword=a)}return i}function ka(){return navigator.language||navigator.userLanguage}var Aa=`$direct`;function ja(){return r?.referrer||Aa}function Ma(e,t,n){n===void 0&&(n=!1);var r=e?[...Sa,...t||[]]:[],a=(n?At(i?.href):i?.href)?.substring(0,1e3);return{r:ja().substring(0,1e3),u:a?_a(a,r,wa):void 0}}function Na(e,t){t===void 0&&(t=!1);var n=e.r,r=e.u,i=t?At(r):r,a={$referrer:n,$referring_domain:n==null?void 0:n==Aa?Aa:ha(n)?.host};if(i){a.$current_url=i;var o=ha(i);a.$host=o?.host,a.$pathname=o?.pathname,G(a,Da(i))}return n&&G(a,Oa(n)),a}function Pa(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Fa(){try{return new Date().getTimezoneOffset()}catch{return}}var Ia={flags:gr,surveys:lr},La=[`cookie`,`localstorage`,`localstorage+cookie`,`sessionstorage`,`memory`],Ra=`main`,za=class{constructor(t,n,r){if(r===void 0&&(r=!0),this.lr={},this.ur=!1,this.hr=!1,this.Te=t,this.dr=r,this.props={},this.cr=void 0,this.vr=(e=>{var t=``;return e.token&&(t=e.token.replace(/\+/g,`PL`).replace(/\//g,`SL`).replace(/=/g,`EQ`)),e.persistence_name?`ph_`+e.persistence_name:`ph_`+t+`_posthog`})(t),this.Je=this.pr(t),this.hr=this.gr(t),this.load(),t.debug&&H.info(`Persistence loaded`,t.persistence,g({},this.props)),this.update_config(t,t,n),this.save(),e){var i=()=>this.flush();K(e,`beforeunload`,i,{capture:!1}),K(e,`pagehide`,i,{capture:!1})}}mr(){var e=this.Te?.persistence_save_debounce_ms;return B(e)&&e>0?e:0}isDisabled(){return!!this.yr}pr(t){La.indexOf(t.persistence.toLowerCase())===-1&&(H.critical(`Unknown persistence type `+t.persistence+`; falling back to localStorage+cookie`),t.persistence=`localStorage+cookie`);var n,r=function(t,n){t===void 0&&(t=[]),n===void 0&&(n=!1);var r=[...si,...t];return g({},q,{F(e){try{var t={};try{t=ai.F(e)||{}}catch{}var r,i=JSON.parse(q.q(e)||`{}`);if(n){var a={};for(var o in t){var s=t[o];R(s)||s===``||(a[o]=s)}r=G(i,a)}else r=G(t,i);return q.A(e,r),r}catch{}return null},A(e,t,n,i,a,o){var s=q.A(e,t,void 0,void 0,o);try{var c={};r.forEach((e=>{t[e]&&(c[e]=t[e])})),Object.keys(c).length&&ai.A(e,c,n,i,a,o)}catch(e){q.P(e)}return s},D(t,n){try{e?.localStorage.removeItem(t),ai.D(t,n)}catch(e){q.P(e)}}})}(t.cookie_persisted_properties||[],t.__preview_cookie_wins_on_conflict||!1),i=!1,a=t.persistence.toLowerCase();return a===`localstorage`&&q.N()?(n=q,i=!0):a===`localstorage+cookie`&&r.N()?(n=r,i=!0):a===`sessionstorage`&&J.N()?n=J:a===`memory`?n=li:a===`cookie`?n=ai:r.N()?(n=r,i=!0):n=ai,this.ur=i,n}br(e){return this.vr+`__`+e}gr(e){return this.ur&&!!e.split_storage}_r(e){var t=e??this.Te.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var n=this.props[gr];return!n||typeof n!=`number`||Date.now()-n>t}properties(){var e={};return W(this.props,((t,n)=>{var r=pa(n);if(r?.exposure===`derived`){if(r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(t,n===Zn?()=>this._r():()=>!1))return;r.transformToEventProperties&&G(e,r.transformToEventProperties(t))}else if(!r||r.exposure===`event`){if(r!=null&&r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(t,(()=>!1)))return;e[n]=t}})),e}load(){if(!this.yr){var e=this.Je.F(this.vr);e&&(this.props=G({},e)),this.hr&&this.wr()}}wr(){for(var e of ua){var t=q.F(this.br(e));if(t&&!ue(t)){var n=this.kr(e);n.persisted=!0,this.Sr(e)||(n.fingerprint=this.Cr(t,e)),this.Mr(e,t)||G(this.props,t)}}}Sr(e){return Object.keys(this.props).some((t=>pa(t)?.storageGroup===e))}Mr(e,t){var n=Ia[e];if(!n)return!1;var r=t[n],i=this.props[n];return B(r)&&B(i)&&i>r}refreshKey(e){if(!this.yr){var t=this.hr?pa(e)?.storageGroup:void 0,n=t?q.F(this.br(t)):this.Je.F(this.vr);if(n&&e in n)this.Ir(e,n[e]);else{if(t){var r=this.Je.F(this.vr);if(r&&e in r)return void this.Ir(e,r[e])}this.Tr(e)}}}save(){if(!this.yr){var e=this.mr();e>0?I(this.Er)&&(this.Er=setTimeout((()=>{this.Er=void 0,this.Rr()}),e)):this.Rr()}}flush(){I(this.Er)||(clearTimeout(this.Er),this.Er=void 0,this.Rr())}Rr(){this.yr||(this.hr?this.Pr():this.Or(this.Je,this.vr,this.props,Ra))}Pr(){var e=this.Fr(),t=e.main,n=e.groups;for(var r of(this.Or(this.Je,this.vr,t,Ra),ua)){var i,a=n[r];(!ue(a)||(i=this.lr[r])!=null&&i.persisted)&&this.Or(q,this.br(r),a,r)}}Fr(){var e={},t={flags:{},surveys:{}};return W(this.props,((n,r)=>{var i=pa(r)?.storageGroup;i?t[i][r]=n:e[r]=n})),{main:e,groups:t}}Cr(e,t){if(t===Ra)return JSON.stringify(e)+`|`+this.Ar+`|`+this.$r+`|`+this.Lr;var n={};return W(e,((e,t)=>
1{var r;n[t]=(r=pa(t))!=null&&r.volatile?`__volatile__`:e})),JSON.stringify(n)}Or(e,t,n,r){var i=this.kr(r);if(r===Ra||i.dirty||I(i.fingerprint)){var a;try{if((a=this.Cr(n,r))===i.fingerprint)return void(i.dirty=!1)}catch{a=void 0}e.A(t,n,this.Ar,this.$r,this.Lr,this.Te.debug)?(i.dirty=!1,r!==Ra&&(i.persisted=!0),I(a)||(i.fingerprint=a)):this.Te.debug&&H.warn(`failed to persist storage entry "`+t+`"; will retry on next save`)}}remove(e){var t=(e===void 0?{}:e).keepGroupEntries,n=t!==void 0&&t;if(I(this.Er)||(clearTimeout(this.Er),this.Er=void 0),this.Je.D(this.vr,!1),this.Je.D(this.vr,!0),!n&&this.dr)for(var r of ua)q.D(this.br(r));n?delete this.lr[Ra]:this.lr={}}clear(){this.remove(),this.props={}}register_once(e,t,n){if(F(e)){I(t)&&(t=`None`),this.Ar=I(n)?this.Dr:n;var r=!1;if(W(e,((e,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==t||(this.Ir(n,e),r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(F(e)){this.Ar=I(t)?this.Dr:t;var n=!1;if(W(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.Ir(r,t),n=!0)})),n)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.Tr(e),this.save())}update_campaign_params(){var e=r?.URL;if(e!==this.cr){var t=Ea(this.Te.custom_campaign_params,this.Te.mask_personal_data_properties,this.Te.custom_personal_data_properties);ue(Gr(t))||this.register(t),this.cr=e}}update_search_keyword(){var e;this.register((e=r?.referrer)?Oa(e):{})}update_referrer_info(){this.register_once({$referrer:ja(),$referring_domain:r!=null&&r.referrer&&ha(r.referrer)?.host||Aa},void 0)}set_initial_person_info(){this.props[br]||this.props[xr]||this.register_once({[Sr]:Ma(this.Te.mask_personal_data_properties,this.Te.custom_personal_data_properties,this.Te.disable_capture_url_hashes)},void 0)}get_initial_props(){var e={};W([xr,br],(t=>{var n=this.props[t];n&&W(n,(function(t,n){e[`$initial_`+ae(n)]=t}))}));var t=this.props[Sr];return t&&G(e,function(e,t){t===void 0&&(t=!1);var n=Na(e,t),r={};return W(n,(function(e,t){r[`$initial_`+ae(t)]=e})),r}(t,this.Te.disable_capture_url_hashes)),e}safe_merge(e){return W(this.props,(function(t,n){n in e||(e[n]=t)})),e}update_config(e,t,n){this.Dr=this.Ar=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!n),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie);var r=e.persistence!==t.persistence||!((e,t)=>{if(e.length!==t.length)return!1;var n=[...e].sort(),r=[...t].sort();return n.every(((e,t)=>e===r[t]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[]),i=r?this.pr(e):this.Je,a=this.gr(e);if(r||a!==this.hr){var o=this.props;this.clear(),this.Je=i,this.hr=a,this.props=o,this.save()}}set_disabled(e){this.yr=e,this.yr?this.remove():this.save()}set_cross_subdomain(e){e!==this.$r&&(this.$r=e,this.remove({keepGroupEntries:!0}),this.save())}set_secure(e){e!==this.Lr&&(this.Lr=e,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(e,t){var n=this.props[Nn]||{};n[e]=t,this.Ir(Nn,n),this.save()}remove_event_timer(e){var t=this.props[Nn]||{},n=t[e];return I(n)||(delete t[e],this.Ir(Nn,t),this.save()),n}get_property(e){return this.props[e]}set_property(e,t){this.Ir(e,t),this.save()}Ir(e,t){var n;this.props[e]=t,(n=pa(e))!=null&&n.volatile||this.Nr(e)}Tr(e){delete this.props[e],this.Nr(e)}Nr(e){var t=pa(e)?.storageGroup;t&&(this.kr(t).dirty=!0)}kr(e){return this.lr[e]||(this.lr[e]={})}};function Ba(e){var t=!0;return{dispose(){if(t){t=!1;var n=e();n&&P(n.then)&&n.then(void 0,(()=>{}))}}}}var Y={GZipJS:`gzip-js`,Base64:`base64`},Va={Activation:`events`,Cancellation:`cancelEvents`},Ha={Popover:`popover`,API:`api`,Widget:`widget`,ExternalSurvey:`external_survey`},Ua={SHOWN:`survey shown`,DISMISSED:`survey dismissed`,SENT:`survey sent`,ABANDONED:`survey abandoned`},Wa={SURVEY_ID:`$survey_id`,SURVEY_NAME:`$survey_name`,SURVEY_RESPONSE:`$survey_response`,SURVEY_ITERATION:`$survey_iteration`,SURVEY_ITERATION_START_DATE:`$survey_iteration_start_date`,SURVEY_PARTIALLY_COMPLETED:`$survey_partially_completed`,SURVEY_SUBMISSION_ID:`$survey_submission_id`,SURVEY_QUESTIONS:`$survey_questions`,SURVEY_COMPLETED:`$survey_completed`,PRODUCT_TOUR_ID:`$product_tour_id`,SURVEY_LAST_SEEN_DATE:`$survey_last_seen_date`,SURVEY_LANGUAGE:`$survey_language`},Ga={Popover:`popover`,Inline:`inline`},Ka={SHOWN:`product tour shown`,DISMISSED:`product tour dismissed`,COMPLETED:`product tour completed`,STEP_SHOWN:`product tour step shown`,STEP_COMPLETED:`product tour step completed`,BUTTON_CLICKED:`product tour button clicked`,STEP_SELECTOR_FAILED:`product tour step selector failed`,BANNER_CONTAINER_SELECTOR_FAILED:`product tour banner container selector failed`,BANNER_ACTION_CLICKED:`product tour banner action clicked`},qa={TOUR_ID:`$product_tour_id`,TOUR_NAME:`$product_tour_name`,TOUR_ITERATION:`$product_tour_iteration`,TOUR_RENDER_REASON:`$product_tour_render_reason`,TOUR_STEP_ID:`$product_tour_step_id`,TOUR_STEP_ORDER:`$product_tour_step_order`,TOUR_STEP_TYPE:`$product_tour_step_type`,TOUR_DISMISS_REASON:`$product_tour_dismiss_reason`,TOUR_BUTTON_TEXT:`$product_tour_button_text`,TOUR_BUTTON_ACTION:`$product_tour_button_action`,TOUR_BUTTON_LINK:`$product_tour_button_link`,TOUR_BUTTON_TOUR_ID:`$product_tour_button_tour_id`,TOUR_STEPS_COUNT:`$product_tour_steps_count`,TOUR_STEP_SELECTOR:`$product_tour_step_selector`,TOUR_STEP_SELECTOR_FOUND:`$product_tour_step_selector_found`,TOUR_STEP_ELEMENT_TAG:`$product_tour_step_element_tag`,TOUR_STEP_ELEMENT_ID:`$product_tour_step_element_id`,TOUR_STEP_ELEMENT_CLASSES:`$product_tour_step_element_classes`,TOUR_STEP_ELEMENT_TEXT:`$product_tour_step_element_text`,TOUR_ERROR:`$product_tour_error`,TOUR_MATCHES_COUNT:`$product_tour_matches_count`,TOUR_FAILURE_PHASE:`$product_tour_failure_phase`,TOUR_WAITED_FOR_ELEMENT:`$product_tour_waited_for_element`,TOUR_WAIT_DURATION_MS:`$product_tour_wait_duration_ms`,TOUR_BANNER_SELECTOR:`$product_tour_banner_selector`,TOUR_LINKED_SURVEY_ID:`$product_tour_linked_survey_id`,USE_MANUAL_SELECTOR:`$use_manual_selector`,INFERENCE_DATA_PRESENT:`$inference_data_present`,TOUR_LAST_SEEN_DATE:`$product_tour_last_seen_date`,TOUR_TYPE:`$product_tour_type`},Ja=U(`[RateLimiter]`),Ya=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var t=e.text;
1if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Ja.info((e||`events`)+` is quota limited.`),this.serverLimits[e]=new Date().getTime()+6e4}))}catch(e){Ja.warn(`could not rate limit - continuing. Error: "`+e?.message+`"`,{text:t});return}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){return this.instance.config.rate_limiting?.events_per_second||10}get captureEventsBurstLimit(){return Math.max(this.instance.config.rate_limiting?.events_burst_limit||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t;e===void 0&&(e=!1);var n=this.captureEventsBurstLimit,r=this.captureEventsPerSecond,i=new Date().getTime(),a=this.instance.persistence?.get_property(yr)??{tokens:n,last:i};a.tokens+=(i-a.last)/1e3*r,a.last=i,a.tokens>n&&(a.tokens=n);var o=1>a.tokens;return o||e||(a.tokens=Math.max(0,a.tokens-1)),!o||this.lastEventRateLimited||e||this.instance.capture(`$$client_ingestion_warning`,{$$client_ingestion_warning_message:`posthog-js client rate limited. Config is set to `+r+` events per second and `+n+` events burst limit.`},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,(t=this.instance.persistence)==null||t.set_property(yr,a),{isRateLimited:o,remainingTokens:a.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||`events`]||!1;return!1!==t&&new Date().getTime()<t}},Xa=U(`[RemoteConfig]`),Za=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=f._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}qr(e){var t,n;(t=f.__PosthogExtensions__)!=null&&t.loadExternalDependency?(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`remote-config`,(()=>e(this.remoteConfig))):e()}jr(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 Xa.info(`Using preloaded remote config`,this.remoteConfig),this.Br(this.remoteConfig),void this.Hr();if(this._instance.Ur())return void Xa.warn(`Remote config is disabled. Falling back to local config.`);this.qr((e=>{if(!e)return Xa.info(`No config found after loading remote JS config. Falling back to JSON.`),void this.jr((e=>{this.Br(e),this.Hr()}));this.Br(e),this.Hr()}))}catch(e){Xa.error(`Error loading remote config`,e),this.Br()}}stop(){this.zr&&=(clearInterval(this.zr),void 0)}refresh(){!this._instance.Ur()&&r&&r.visibilityState!==`hidden`&&this._instance.reloadFeatureFlags()}Hr(){if(!this.zr){var e=this._instance.config.remote_config_refresh_interval_ms??3e5;e!==0&&(this.zr=setInterval((()=>{this.refresh()}),e))}}Br(e){e||Xa.error(`Failed to fetch remote config from PostHog.`);try{this._instance.Br(e?{ok:!0,config:e}:{ok:!1})}catch(e){Xa.error(`Error applying remote config`,e)}if(!1!==e?.hasFeatureFlags&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var t;(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded()}catch(e){Xa.error(`Error loading feature flags`,e)}}},Qa=Uint8Array,X=Uint16Array,$a=Uint32Array,eo=new Qa([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]),to=new Qa([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]),no=new Qa([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ro=function(e,t){for(var n=new X(31),r=0;31>r;++r)n[r]=t+=1<<e[r-1];var i=new $a(n[30]);for(r=1;30>r;++r)for(var a=n[r];n[r+1]>a;++a)i[a]=a-n[r]<<5|r;return[n,i]},io=ro(eo,2),ao=io[1];io[0][28]=258,ao[258]=28;for(var oo=ro(to,0)[1],so=new X(32768),Z=0;32768>Z;++Z){var co=(43690&Z)>>>1|(21845&Z)<<1;so[Z]=((65280&(co=(61680&(co=(52428&co)>>>2|(13107&co)<<2))>>>4|(3855&co)<<4))>>>8|(255&co)<<8)>>>1}var lo=function(e,t,n){for(var r=e.length,i=0,a=new X(t);r>i;++i)++a[e[i]-1];var o,s=new X(t);for(i=0;t>i;++i)s[i]=s[i-1]+a[i-1]<<1;if(n){o=new X(1<<t);var c=15-t;for(i=0;r>i;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=s[e[i]-1]++<<u,f=d|(1<<u)-1;f>=d;++d)o[so[d]>>>c]=l}else for(o=new X(r),i=0;r>i;++i)o[i]=so[s[e[i]-1]++]>>>15-e[i];return o},uo=new Qa(288);for(Z=0;144>Z;++Z)uo[Z]=8;for(Z=144;256>Z;++Z)uo[Z]=9;for(Z=256;280>Z;++Z)uo[Z]=7;for(Z=280;288>Z;++Z)uo[Z]=8;var fo=new Qa(32);for(Z=0;32>Z;++Z)fo[Z]=5;var po=lo(uo,9,0),mo=lo(fo,5,0),ho=function(e){return(e/8>>0)+(7&e&&1)},go=function(e,t,n){(n==null||n>e.length)&&(n=e.length);var r=new(e instanceof X?X:e instanceof $a?$a:Qa)(n-t);return r.set(e.subarray(t,n)),r},_o=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8},vo=function(e,t,n){var r=t/8>>0;e[r]|=n<<=7&t,e[r+1]|=n>>>8,e[r+2]|=n>>>16},yo=function(e,t){for(var n=[],r=0;e.length>r;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return[new Qa(0),0];if(i==1){var o=new Qa(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[d].f>n[l].f?l++:d++],c=n[l!=u&&n[d].f>n[l].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};var f=a[0].s;for(r=1;i>r;++r)a[r].s>f&&(f=a[r].s);var p=new X(f+1),m=bo(n[u-1],p,0);if(m>t){r=0;var h=0,g=m-t,_=1<<g;for(a.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));i>r;++r){var v=a[r].s;if(t>=p[v])break;h+=_-(1<<m-p[v]),p[v]=t}for(h>>>=g;h>0;){var y=a[r].s;t>p[y]?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return[new Qa(p),m]},bo=function(e,t,n){return e.s==-1?Math.max(bo(e.l,t,n+1),bo(e.r,t,n+1)):t[e.s]=n},xo=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new X(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;t>=s;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>
12&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return[n.subarray(0,r),t]},So=function(e,t){for(var n=0,r=0;t.length>r;++r)n+=e[r]*t[r];return n},Co=function(e,t,n){var r=n.length,i=ho(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var a=0;r>a;++a)e[i+a+4]=n[a];return 8*(i+4+r)},wo=function(e,t,n,r,i,a,o,s,c,l,u){_o(t,u++,n),++i[256];for(var d=yo(i,15),f=d[0],p=d[1],m=yo(a,15),h=m[0],g=m[1],_=xo(f),v=_[0],y=_[1],b=xo(h),x=b[0],S=b[1],C=new X(19),w=0;v.length>w;++w)C[31&v[w]]++;for(w=0;x.length>w;++w)C[31&x[w]]++;for(var T=yo(C,7),E=T[0],D=T[1],O=19;O>4&&!E[no[O-1]];--O);var ee,k,A,te,j=l+5<<3,ne=So(i,uo)+So(a,fo)+o,re=So(i,f)+So(a,h)+o+14+3*O+So(C,E)+(2*C[16]+3*C[17]+7*C[18]);if(ne>=j&&re>=j)return Co(t,u,e.subarray(c,c+l));if(_o(t,u,1+(ne>re)),u+=2,ne>re){ee=lo(f,p,0),k=f,A=lo(h,g,0),te=h;var M=lo(E,D,0);for(_o(t,u,y-257),_o(t,u+5,S-1),_o(t,u+10,O-4),u+=14,w=0;O>w;++w)_o(t,u+3*w,E[no[w]]);u+=3*O;for(var ie=[v,x],ae=0;2>ae;++ae){var oe=ie[ae];for(w=0;oe.length>w;++w)_o(t,u,M[se=31&oe[w]]),u+=E[se],se>15&&(_o(t,u,oe[w]>>>5&127),u+=oe[w]>>>12)}}else ee=po,k=uo,A=mo,te=fo;for(w=0;s>w;++w)if(r[w]>255){var se;vo(t,u,ee[257+(se=r[w]>>>18&31)]),u+=k[se+257],se>7&&(_o(t,u,r[w]>>>23&31),u+=eo[se]);var ce=31&r[w];vo(t,u,A[ce]),u+=te[ce],ce>3&&(vo(t,u,r[w]>>>5&8191),u+=to[ce])}else vo(t,u,ee[r[w]]),u+=k[r[w]];return vo(t,u,ee[256]),u+k[256]},To=new $a([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Eo=function(){for(var e=new $a(256),t=0;256>t;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),Do=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function Oo(e,t){t===void 0&&(t={});var n=function(){var e=4294967295;return{p(t){for(var n=e,r=0;t.length>r;++r)n=Eo[255&n^t[r]]^n>>>8;e=n},d(){return 4294967295^e}}}(),r=e.length;n.p(e);var i,a,o,s,c,l=(s=10+((i=t).filename&&i.filename.length+1||0),c=8,function(e,t,n,r,i,a){var o=e.length,s=new Qa(r+o+5*(1+Math.floor(o/7e3))+i),c=s.subarray(r,s.length-i),l=0;if(!t||8>o)for(var u=0;o>=u;u+=65535){var d=u+65535;o>d?l=Co(c,l,e.subarray(u,d)):(c[u]=!0,l=Co(c,l,e.subarray(u,o)))}else{for(var f=To[t-1],p=f>>>13,m=8191&f,h=(1<<n)-1,g=new X(32768),_=new X(h+1),v=Math.ceil(n/3),y=2*v,b=function(t){return(e[t]^e[t+1]<<v^e[t+2]<<y)&h},x=new $a(25e3),S=new X(288),C=new X(32),w=0,T=0,E=(u=0,0),D=0,O=0;o>u;++u){var ee=b(u),k=32767&u,A=_[ee];if(g[k]=A,_[ee]=k,u>=D){var te=o-u;if((w>7e3||E>24576)&&te>423){l=wo(e,c,0,x,S,C,T,E,O,u-O,l),E=w=T=0,O=u;for(var j=0;286>j;++j)S[j]=0;for(j=0;30>j;++j)C[j]=0}var ne=2,re=0,M=m,ie=k-A&32767;if(te>2&&ee==b(u-ie))for(var ae=Math.min(p,te)-1,oe=Math.min(32767,u),se=Math.min(258,te);oe>=ie&&--M&&k!=A;){if(e[u+ne]==e[u+ne-ie]){for(var ce=0;se>ce&&e[u+ce]==e[u+ce-ie];++ce);if(ce>ne){if(ne=ce,re=ie,ce>ae)break;var le=Math.min(ie,ce-2),N=0;for(j=0;le>j;++j){var P=u-ie+j+32768&32767,F=P-g[P]+32768&32767;F>N&&(N=F,A=P)}}}ie+=(k=A)-(A=g[k])+32768&32767}if(re){x[E++]=268435456|ao[ne]<<18|oo[re];var ue=31&ao[ne],I=31&oo[re];T+=eo[ue]+to[I],++S[257+ue],++C[I],D=u+ne,++w}else x[E++]=e[u],++S[e[u]]}}l=wo(e,c,!0,x,S,C,T,E,O,u-O,l)}return go(s,0,r+ho(l)+i)}(a=e,(o=t).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(a.length)))):12+o.mem,s,c)),u=l.length;return function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=2>t.level?4:t.level==9?2:0,e[9]=3,t.mtime!=0&&Do(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;n.length>=r;++r)e[r+10]=n.charCodeAt(r)}}(l,t),Do(l,u-8,n.d()),Do(l,u-4,r),l}var ko=!!o||!!a,Ao=`text/plain`,jo=!1,Mo=(e,t)=>{var n=e.split(`#`),r=n[1],i=n[0].split(`?`),a=i[0],o=i[1];if(!o)return e;var s=o.split(`&`).filter((e=>e.split(`=`)[0]!==t)).join(`&`);return a+(s?`?`+s:``)+(r?`#`+r:``)},No=function(e,t,n){n===void 0&&(n=!0);var r=e.split(`?`),i=r[0],a=r[1],o=g({},t),s=a?.split(`&`).map((e=>{var t,r=e.split(`=`),i=r[0],a=n&&(t=o[i])!=null?t:r[1];return delete o[i],i+`=`+a}))??[],c=function(e,t){var n,r;t===void 0&&(t=`&`);var i=[];return W(e,(function(e,t){I(e)||I(t)||t===`undefined`||(n=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),r=encodeURIComponent(t),i[i.length]=r+`=`+n)})),i.join(t)}(o);return c&&s.push(c),s.length>0?i+`?`+s.join(`&`):i},Po=e=>{if(e.Vr)return e.Vr;var t=e.data,n=e.compression;if(t){if(n===Y.GZipJS){var r=Oo(function(e,t){var n=e.length;if(typeof TextEncoder<`u`)return new TextEncoder().encode(e);for(var r=new Qa(e.length+(e.length>>>1)),i=0,a=function(e){r[i++]=e},o=0;n>o;++o){if(i+5>r.length){var s=new Qa(i+8+(n-o<<1));s.set(r),r=s}var c=e.charCodeAt(o);128>c?a(c):2048>c?(a(192|c>>>6),a(128|63&c)):c>55295&&57344>c?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++o))>>>18),a(128|c>>>12&63),a(128|c>>>6&63),a(128|63&c)):(a(224|c>>>12),a(128|c>>>6&63),a(128|63&c))}return go(r,0,i)}(ma(t)),{mtime:0});return{contentType:Ao,body:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),estimatedSize:r.byteLength}}if(n===Y.Base64){var i=(e=>`data=`+encodeURIComponent(typeof e==`string`?e:ma(e)))(function(e){return e&&btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,((e,t)=>
1String.fromCharCode(parseInt(t,16)))))}(ma(t)));return{contentType:`application/x-www-form-urlencoded`,body:i,estimatedSize:new Blob([i]).size}}var a=ma(t);return{contentType:`application/json`,body:a,estimatedSize:new Blob([a]).size}}},Fo=e=>{var t,n,r=()=>e.transport===`sendBeacon`?{url:No(e.url,{compression:Y.Base64}),encodedBody:Po(g({},e,{compression:Y.Base64,Vr:void 0}))}:{url:Mo(e.url,`compression`),encodedBody:Po(g({},e,{compression:void 0,Vr:void 0}))};try{t=Po(e)}catch(t){if(ee(e.compression,ga(e.url,`compression`)))return H.error(`Failed to gzip request body, sending uncompressed payload`,t),r();throw t}return t&&ee(e.compression,ga(e.url,`compression`))&&!((n=t.body)instanceof ArrayBuffer?O(new Uint8Array(n)):ArrayBuffer.isView(n)&&O(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)))?(jo=!0,r()):{url:e.url,encodedBody:t}},Io=e=>{try{return Fo(e)}catch(t){H.error(t),e.callback==null||e.callback({statusCode:0,error:t});return}},Lo=function(){var e=h((function*(e){var t=yield function(e,t,n){return j.apply(this,arguments)}(ma(e.data),p.DEBUG,{rethrow:!0});if(!t)return e;var n=yield t.arrayBuffer();return g({},e,{Vr:{contentType:Ao,body:n,estimatedSize:n.byteLength}})}));return function(t){return e.apply(this,arguments)}}(),Ro=/Failed to fetch|NetworkError|Load failed/i,zo=e=>{var t=Io(e);if(t){var n=t.url,r=t.encodedBody??{},i=r.contentType,o=r.body,c=r.estimatedSize,l=new Headers;W(e.headers,(function(e,t){l.append(t,e)})),i&&l.append(`Content-Type`,i);var u=null,d=!1;if(s){var f=new s;u={signal:f.signal,timeout:setTimeout((()=>{var t,n;d=!0,f.abort((t=e.timeout,(n=Error(`PostHog request timed out`+(t?` after `+t+`ms`:``))).name=`AbortError`,n))}),e.timeout)}}var p=t=>{d&&t?.name===`AbortError`||(e=>e?.name===`TypeError`&&Ro.test(e?.message||``))(t)?H.warn(t):H.error(t),e.callback==null||e.callback({statusCode:0,error:t})};try{a(n,g({method:e?.method||`GET`,headers:l,keepalive:e.method===`POST`&&!e.Wr&&52428.8>(c||0),body:o,signal:u?.signal},e.fetchOptions)).then((t=>t.text().then((n=>{var r={statusCode:t.status,text:n};if(t.status===200)try{r.json=JSON.parse(n)}catch(e){H.error(e)}e.callback==null||e.callback(r)})))).catch(p).finally((()=>u?clearTimeout(u.timeout):null))}catch(e){u&&clearTimeout(u.timeout),p(e)}}},Bo=e=>{try{var t=Fo(e),r=t.url,i=t.encodedBody??{},a=i.body,o=i.estimatedSize;if(!a)return;var s=a instanceof Blob?a:new Blob([a],{type:i.contentType});if(n.sendBeacon(r,s))return;var c=N(e.data)?e.data:e.data?.batch;if(N(c)&&c.length>1&&(o??0)>16384){var l=Math.ceil(c.length/2),u=t=>N(e.data)?t:g({},e.data,{batch:t});Bo(g({},e,{data:u(c.slice(0,l))})),Bo(g({},e,{data:u(c.slice(l))}));return}H.warn(`Beacon of ~`+(o??0)+` bytes was rejected by the browser, falling back to fetch`),zo(g({},e,{Wr:!0}))}catch(e){H.warn(`Beacon send failed`,e)}},Vo=(e,t,n,r)=>{var i=r===`query`?t===`POST`?`sent_at`:`_`:void 0;return No(n===Y.GZipJS?Mo(e,`compression`):e,g({},i?{[i]:Date.now().toString()}:{},n===Y.GZipJS?{}:{compression:n}))},Ho=[];a&&Ho.push({transport:`fetch`,method:zo}),o&&Ho.push({transport:`XHR`,method(e){var t=Io(e);if(t){var n=new o,r=t.encodedBody;n.open(e.method||`GET`,t.url,!0);var i=r??{},a=i.contentType,s=i.body;W(e.headers,(function(e,t){n.setRequestHeader(t,e)})),a&&n.setRequestHeader(`Content-Type`,a),e.timeout&&(n.timeout=e.timeout),n.onreadystatechange=()=>{if(n.readyState===4){var t={statusCode:n.status,text:n.responseText};if(n.status===200)try{t.json=JSON.parse(n.responseText)}catch{}e.callback==null||e.callback(t)}},n.send(s)}}}),n!=null&&n.sendBeacon&&Ho.push({transport:`sendBeacon`,method:Bo});var Uo=3e3,Wo=class{constructor(e,t){this.Zr=!0,this.Gr=[],this.Qr=Ce(t?.flush_interval_ms||Uo,250,5e3,H.createLogger(`flush interval`),Uo),this.Jr=e}enqueue(e){this.Gr.push(e),this.Kr||this.Yr()}unload(){this.Xr();var e=this.Gr.length>0?this.ti():{},t=Object.values(e);[...t.filter((e=>e.url.indexOf(`/e`)===0)),...t.filter((e=>e.url.indexOf(`/e`)!==0))].map((e=>{this.ei(g({},e,{transport:`sendBeacon`}))}))}enable(){this.Zr=!1,this.Yr()}Yr(){var e=this;this.Zr||(this.Kr=setTimeout((()=>{if(this.Xr(),this.Gr.length>0){var t=this.ti(),n=function(){var n=t[r],i=new Date().getTime();n.data&&N(n.data)&&W(n.data,(e=>{e.offset=Math.abs(e.timestamp-i),delete e.timestamp})),e.ei(n)};for(var r in t)n()}}),this.Qr))}ei(e){try{this.Jr(e)}catch(e){H.error(e)}}Xr(){clearTimeout(this.Kr),this.Kr=void 0}ti(){var e={};return W(this.Gr,(t=>{var n,r=t,i=(r?r.batchKey:null)||r.url;I(e[i])&&(e[i]=g({},r,{data:[]})),(n=e[i].data)==null||n.push(r.data)})),this.Gr=[],e}},Go=[`retriesPerformedSoFar`],Ko=class{constructor(t){this.ri=!1,this.ii=3e3,this.Gr=[],this._instance=t,this.Gr=[],this.ni=!0,!I(e)&&`onLine`in e.navigator&&(this.ni=e.navigator.onLine,this.si=()=>{this.ni=!0,this.oi()},this.ai=()=>{this.ni=!1},K(e,`online`,this.si),K(e,`offline`,this.ai))}get length(){return this.Gr.length}retriableRequest(e){var t=e.retriesPerformedSoFar,n=_(e,Go);fe(t)&&(n.url=No(n.url,{retry_count:t})),this._instance._send_request(g({},n,{callback:e=>{if(e.statusCode!==200&&(400>
1e.statusCode||e.statusCode>=500)){if((e.statusCode===0?3:10)>(t??0))return void this.Ot(g({retriesPerformedSoFar:t},n));e.statusCode===0&&H.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after `+(t??0)+` retries.`)}n.callback==null||n.callback(e)}}))}Ot(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var n=function(e){var t=3e3*2**e,n=t/2,r=Math.min(18e5,t),i=Math.random()-.5;return Math.ceil(r+i*(r-n))}(t),r=Date.now()+n;this.Gr.push({retryAt:r,requestOptions:e});var i=`Enqueued failed request for retry in `+n;navigator.onLine||(i+=` (Browser is offline)`),H.warn(i),this.ri||(this.ri=!0,this.li())}li(){if(this.ui&&clearTimeout(this.ui),this.Gr.length===0)return this.ri=!1,void(this.ui=void 0);this.ui=setTimeout((()=>{this.ni&&this.Gr.length>0&&this.oi(),this.li()}),this.ii)}oi(){var e=Date.now(),t=[],n=this.Gr.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Gr=t,n.length>0)for(var r of n)this.retriableRequest(r.requestOptions)}unload(){for(var t of(this.ui&&=(clearTimeout(this.ui),void 0),this.ri=!1,I(e)||(this.si&&=(e.removeEventListener(`online`,this.si),void 0),this.ai&&=(e.removeEventListener(`offline`,this.ai),void 0)),this.Gr)){var n=t.requestOptions;try{this._instance._send_request(g({},n,{transport:`sendBeacon`}))}catch(e){H.error(e)}}this.Gr=[]}},qo=class{constructor(e){this.hi=()=>{this.di||={};var e=this.scrollElement(),t=this.scrollY(),n=e?Math.max(0,e.scrollHeight-e.clientHeight):0,r=t+(e?.clientHeight||0),i=e?.scrollHeight||0;this.di.lastScrollY=Math.ceil(t),this.di.maxScrollY=Math.max(t,this.di.maxScrollY??0),this.di.maxScrollHeight=Math.max(n,this.di.maxScrollHeight??0),this.di.lastContentY=r,this.di.maxContentY=Math.max(r,this.di.maxContentY??0),this.di.maxContentHeight=Math.max(i,this.di.maxContentHeight??0)},this._instance=e}get ci(){return this._instance.config.scroll_root_selector}getContext(){return this.di}resetContext(){var e=this.di;return setTimeout(this.hi,0),e}startMeasuringScrollPosition(){K(e,`scroll`,this.hi,{capture:!0}),K(e,`scrollend`,this.hi,{capture:!0}),K(e,`resize`,this.hi)}scrollElement(){if(!this.ci)return e?.document.documentElement;for(var t of N(this.ci)?this.ci:[this.ci]){var n=e?.document.querySelector(t);if(n)return n}}vi(t){var n=t===`y`?`scrollTop`:`scrollLeft`;if(this.ci){var r=this.scrollElement();return r&&r[n]||0}return e?t===`y`?e.scrollY||e.pageYOffset||e.document.documentElement.scrollTop||0:e.scrollX||e.pageXOffset||e.document.documentElement.scrollLeft||0:0}scrollY(){return this.vi(`y`)}scrollX(){return this.vi(`x`)}},Jo=e=>Ma(e?.config.mask_personal_data_properties,e?.config.custom_personal_data_properties,e?.config.disable_capture_url_hashes),Yo=class{constructor(e,t,n,r){this.fi=e=>{var t=this.pi();if(!t||t.sessionId!==e){var n={sessionId:e,props:this.gi(this._instance)};this.mi.register({[vr]:n})}},this._instance=e,this.yi=t,this.mi=n,this.gi=r||Jo,this.yi.onSessionId(this.fi)}pi(){return this.mi.props[vr]}getSetOnceProps(){var e=this.pi()?.props;return e?`r`in e?Na(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var e={};return W(Gr(this.getSetOnceProps()),((t,n)=>{n===`$current_url`&&(n=`url`),e[`$session_entry_`+ae(n)]=t})),e}},Xo=class{on(e,t){return this.bi[e]||(this.bi[e]=[]),this.bi[e].push(t),()=>{this.bi[e]=this.bi[e].filter((e=>e!==t))}}emit(e,t){for(var n of this.bi[e]||[])n(t);for(var r of this.bi[`*`]||[])r(e,t)}constructor(){this.bi={}}},Zo=U(`[SessionId]`),Qo=class{on(e,t){return this.wi.on(e,t)}constructor(e,t,n){var r;if(this.xi=null,this.ki=[],this.Si=void 0,this.Ci=!1,this.wi=new Xo,this.Mi=(e,t)=>!(!fe(e)||!fe(t))&&Math.abs(e-t)>this.sessionTimeoutMs,!e.persistence)throw Error(`SessionIdManager requires a PostHogPersistence instance`);if(e.config.cookieless_mode===jr)throw Error(`SessionIdManager cannot be used with cookieless_mode="always"`);this.Te=e.config,this.mi=e.persistence,this.Ii=void 0,this.Ti=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.Ei=t||ti,this.Ri=n||ti;var i=this.Te.persistence_name||this.Te.token;if(this._sessionTimeoutMs=1e3*Ce(this.Te.session_idle_timeout_seconds||1800,60,36e3,Zo.createLogger(`session_idle_timeout_seconds`),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Pi(),this.Oi=`ph_`+i+`_window_id`,this.Fi=`ph_`+i+`_primary_window_exists`,this.Ai()){var a=J.F(this.Oi),o=J.F(this.Fi);
1a&&!o?this.Ii=a:J.D(this.Oi),J.A(this.Fi,!0)}if((r=this.Te.bootstrap)!=null&&r.sessionID)try{var s=(e=>{var t=this.Te.bootstrap.sessionID.replace(/-/g,``);if(t.length!==32)throw Error(`Not a valid UUID`);if(t[12]!==`7`)throw Error(`Not a UUIDv7`);return parseInt(t.substring(0,12),16)})();this.$i(this.Te.bootstrap.sessionID,new Date().getTime(),s)}catch(e){Zo.error(`Invalid sessionID in bootstrap`,e)}this.Li()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return I(this.ki)&&(this.ki=[]),this.ki.push(e),this.Ti&&e(this.Ti,this.Ii),()=>{this.ki=this.ki.filter((t=>t!==e))}}Ai(){return this.Te.persistence!==`memory`&&!this.mi.yr&&J.N()}Di(e){e!==this.Ii&&(this.Ii=e,this.Ai()&&J.A(this.Oi,e))}Ni(){return this.Ii?this.Ii:this.Ai()?J.F(this.Oi):null}qi(e){var t=this.xi;return!R(t)&&!R(e)&&5e3>Math.abs(e-t)}$i(e,t,n){var r=t!==this._sessionActivityTimestamp,i=e===this.Ti&&n===this._sessionStartTimestamp;this._sessionStartTimestamp=n,this._sessionActivityTimestamp=t,this.Ti=e,i&&!r||i&&this.qi(t)||(this.xi=t,this.mi.register({[Yn]:[t,e,n]}))}ji(){var e=this.Te?.persistence_save_debounce_ms;return fe(e)&&e>0}Bi(){this.ji()?this.mi.refreshKey(Yn):(this.mi.flush(),this.mi.load())}Hi(){if(!R(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.xi){this.Bi();var e=this.Ui();e[1]===this.Ti&&e[2]===this._sessionStartTimestamp&&(this.xi=this._sessionActivityTimestamp,this.mi.register({[Yn]:[this._sessionActivityTimestamp,this.Ti??null,this._sessionStartTimestamp]}),this.mi.flush())}}zi(){var e=this.Ui()[0],t=fe(e)?e:0,n=fe(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(t,n)}Vi(e){return this.Bi(),this.Mi(e,this.zi())}Ui(){var e=this.mi.props[Yn];return N(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.xi=null,clearTimeout(this.Wi),this.Wi=void 0,this.$i(null,null,null)}destroy(){this.Ci=!0,this.Hi(),clearTimeout(this.Wi),this.Wi=void 0,this.Si&&e&&(e.removeEventListener(Ir,this.Si,{capture:!1}),this.Si=void 0),this.ki=[]}Li(){this.Si=()=>{this.Hi(),this.Ai()&&J.D(this.Fi)},K(e,Ir,this.Si,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.Te.cookieless_mode===jr)throw Error(`checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"`);var n=t||new Date().getTime(),r=this.Ui(),i=r[1],a=r[2],o=this.zi(),s=this.Ni(),c=fe(a)&&Math.abs(n-a)>864e5,l=!1,u=!1,d=!i,f=i,p=!d&&!e&&this.Mi(n,o);if(p){(p=this.Vi(n))||Zo.info(`cross-tab refresh kept the session alive`,{sessionId:i});var m=this.Ui();i=m[1],a=m[2]}d||p||c?(i=this.Ei(),s=this.Ri(),Zo.info(`new session ID generated`,{sessionId:i,windowId:s,changeReason:{noSessionId:d,activityTimeout:p,sessionPastMaximumLength:c}}),a=n,l=!0):(s||(s=this.Ri(),l=!0),(u=i!==f)&&(Zo.info(`adopted cross-tab session id`,{sessionId:i,windowId:s}),l=!0));var h=fe(o)&&e&&!c?o:n,g=fe(a)?a:new Date().getTime();this.Di(s),this.$i(i,h,g),e||this.Pi();var _={noSessionId:d,activityTimeout:p,sessionPastMaximumLength:c,crossTabAdoption:u};return l&&this.ki.forEach((e=>e(i,s,_))),{sessionId:i,windowId:s,sessionStartTimestamp:g,changeReason:l?_:void 0,lastActivityTimestamp:o}}Pi(){this.Ci||(clearTimeout(this.Wi),this.Wi=setTimeout((()=>{if(!this.Ci)if(this.Vi(new Date().getTime())){var e=this.Ti;this.resetSessionId(),this.wi.emit(`forcedIdleReset`,{idleSessionId:e})}else this.Pi()}),1.1*this.sessionTimeoutMs))}},$o=function(e,t){if(!e)return!1;var n=e.userAgent;if(n&&re(n,t))return!0;try{var r=e?.userAgentData;if(r!=null&&r.brands&&r.brands.some((e=>re(e?.brand,t))))return!0}catch{}return!!e.webdriver};function es(){return(es=h((function*(){var e=n?.userAgentData;if(e!=null&&e.getHighEntropyValues)try{var t=(yield e.getHighEntropyValues([`model`]))?.model;return L(t)&&t.length>0?t:void 0}catch(e){H.info(`Unable to resolve $device_model from userAgentData.getHighEntropyValues`,e);return}}))).apply(this,arguments)}var ts=function(e,t){if(!function(e){try{new RegExp(e)}catch{return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch{return!1}};function ns(e,t,n){return ma({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:n})}
1var rs={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=>ts(t,e))))),not_regex:(e,t)=>t.every((t=>e.every((e=>!ts(t,e))))),icontains:(e,t)=>t.map(is).some((t=>e.map(is).some((e=>t.includes(e))))),not_icontains:(e,t)=>t.map(is).every((t=>e.map(is).every((e=>!t.includes(e))))),gt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n>parseFloat(e)))})),lt:(e,t)=>t.some((t=>{var n=parseFloat(t);return!isNaN(n)&&e.some((e=>n<parseFloat(e)))}))},is=e=>e.toLowerCase();function as(e,t){return!e||Object.entries(e).every((e=>{var n=e[1],r=t?.[e[0]];if(I(r)||R(r))return!1;var i=[String(r)],a=rs[n.operator];return!!a&&a(n.values,i)}))}var os=`custom`,ss=`i.posthog.com`,cs=/^\/static\//,ls=class{constructor(e){this.Zi={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,``);return e===`https://app.posthog.com`?`https://us.i.posthog.com`:e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,``):this.apiHost}get uiHost(){var e=this.instance.config.ui_host?.replace(/\/$/,``);return e||=this.apiHost.replace(`.`+ss,`.posthog.com`),e===`https://app.posthog.com`?`https://us.posthog.com`:e}get region(){return this.Zi[this.apiHost]||(this.Zi[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`us`:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?`eu`:os),this.Zi[this.apiHost]}Gi(e){if(cs.test(e)){var t=this.instance.config.asset_host;if(typeof t==`string`)return t.trim().replace(/\/$/,``)||void 0}}endpointFor(e,t){if(t===void 0&&(t=``),t&&=t[0]===`/`?t:`/`+t,e===`ui`)return this.uiHost+t;if(e===`flags`)return this.flagsApiHost+t;if(e===`assets`){var n=this.Gi(t);if(n)return``+n+t}if(this.region===os)return this.apiHost+t;var r=ss+t;switch(e){case`assets`:return`https://`+this.region+`-assets.`+r;case`api`:return`https://`+this.region+`.`+r}}};function us(e){var t;return!((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null||!t.length)}var Q=U(`[Surveys]`),ds=`seenSurvey_`,fs=e=>{try{var t=(e=>((e,t)=>``+ds+function(e){return e.current_iteration&&e.current_iteration>0?e.id+`_`+e.current_iteration:e.id}(t))(0,e))(e);if(localStorage.getItem(t))return;localStorage.setItem(t,`true`)}catch(e){Q.error(`Failed to persist survey seen state`,e)}},ps=[Ha.Popover,Ha.Widget,Ha.API],ms={ignoreConditions:!1,ignoreDelay:!1,displayType:Ga.Popover},hs=U(`[PostHog ExternalIntegrations]`),gs={intercom:`intercom-integration`,crispChat:`crisp-chat-integration`},_s=class{constructor(e){this._instance=e}tr(e,t){var n;(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,e,(e=>{if(e)return hs.error(`failed to load script`,e);t()}))}startIfEnabledOrStop(){var e=this,t=function(){var t,r,i,a=n[0],o=n[1];!o||(t=f.__PosthogExtensions__)!=null&&(t=t.integrations)!=null&&t[a]||e.tr(gs[a],(()=>{var t;(t=f.__PosthogExtensions__)==null||(t=t.integrations)==null||(t=t[a])==null||t.start(e._instance)})),!o&&(r=f.__PosthogExtensions__)!=null&&(r=r.integrations)!=null&&r[a]&&((i=f.__PosthogExtensions__)==null||(i=i.integrations)==null||(i=i[a])==null||i.stop())};for(var n of Object.entries((r=this._instance.config.integrations)??{})){var r;t()}}},vs=class{constructor(e,t){this.it=e,this.Qi=t,this.Ji=new Map,this.Ki=!1}add(e){var t=this;return h((function*(){if(t.Ki)throw Error(`Cannot add an extension to a disposed ExtensionRuntime`);if(t.Ji.has(e.name))throw Error(`Browser extension "`+e.name+`" is already registered`);t.Ji.set(e.name,e);try{var n=e.setup(t.Qi);n&&(yield n)}catch(n){var r=t.Ji.get(e.name)===e;r&&t.Ji.delete(e.name),t.it.error(`Failed to set up browser extension "`+e.name+`"`,n),r&&t.Yi(e)}}))()}dispose(){if(!this.Ki){this.Ki=!0;var e=Array.from(this.Ji.values()).reverse();for(var t of(this.Ji.clear(),e))this.Yi(t)}}Yi(e){try{var t=e.dispose==null?void 0:e.dispose();t&&P(t.then)&&t.then(void 0,(t=>{this.it.error(`Failed to dispose browser extension "`+e.name+`"`,t)}))}catch(t){this.it.error(`Failed to dispose browser extension "`+e.name+`"`,t)}}},ys=class{constructor(e){this._instance=e}get(e){return this._instance.persistence?.get_property(e)}set(e,t){var n;(n=this._instance.persistence)==null||n.set_property(e,t)}remove(e){var t;(t=this._instance.persistence)==null||t.unregister(e)}},bs=`extensionsRemoteConfig`,xs=class{constructor(e){this.Ki=!1,this.instance=e,this.it=H.createLogger(`[BrowserExtensions]`),this.Xi=e.tn,this.kv=new ys(e),this.onEvent=e=>Ba(this.instance.on(`eventCaptured`,(t=>{try{e({event:t.event,properties:t.properties})}catch(e){this.it.error(`Browser extension event listener failed`,e)}}))),this.onRemoteConfig=e=>{if(this.Ki)return Ba((()=>{}));var t=t=>{try{e(t)}catch(e){this.it.error(`Browser extension remote config listener failed`,e)}},n=this.instance.en.on(bs,t);
1return this.Xi&&t(this.Xi),Ba(n)},this.rn=new vs(this.it,this)}get logger(){return this.it}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){return this.instance.get_property(An)??this.distinctId}get groups(){return this.instance.getGroups()}get session(){try{var e=this.instance.sessionManager?.checkAndGetSessionAndWindowId(!0);return{sessionId:e?.sessionId??``,windowId:e?.windowId??``,sessionStartTimestamp:e?.sessionStartTimestamp??0}}catch{return{sessionId:``,windowId:``,sessionStartTimestamp:0}}}get projectToken(){return this.instance.config.token}add(e){return this.rn.add(e)}capture(e,t,n){var r=this;return h((function*(){n?r.instance.capture(e,t,{timestamp:n.timestamp,uuid:n.uuid,$set:n.set,$set_once:n.setOnce}):r.instance.capture(e,t)}))()}registerDynamicEventProperties(e){return Ba(this.instance.nn(e))}handleRemoteConfig(e){this.Ki||(this.Xi=e,this.instance.en.emit(bs,e))}sendRequest(e,t){var n=this;return h((function*(){t===void 0&&(t={});var r=n.instance.requestRouter.endpointFor(t.target??`api`,e),i={method:t.method,url:t.query?No(r,t.query):r,data:t.body,headers:t.headers,timeout:t.timeoutMs,fireCallbackOnDrop:!0,transport:t.transport};return t.transport===`sendBeacon`?(n.instance._send_request(i),{statusCode:202}):new Promise((e=>{i.callback=e,n.instance._send_request(i)}))}))()}dispose(){this.Ki||(this.Ki=!0,this.rn.dispose())}},Ss={},Cs=0,ws=()=>{},Ts=`Consent opt in/out is not valid with cookieless_mode="always" and will be ignored`,Es=`Surveys module not available`,Ds=`sanitize_properties is deprecated. Use before_send instead`,Os=`Invalid value for property_denylist config: `,ks=[`token`,`distinct_id`,Tr],As=`posthog`,js=!ko&&l?.indexOf(`MSIE`)===-1&&l?.indexOf(`Mozilla`)===-1,Ms=t=>{var n;return g({api_host:`https://us.i.posthog.com`,flags_api_host:null,ui_host:null,asset_host:null,token:``,autocapture:!0,cross_subdomain_cookie:qr(r?.location),persistence:`localStorage+cookie`,persistence_name:``,cookie_persisted_properties:[],loaded:ws,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:`if_capture_pageview`,defaults:t??`unset`,__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:i&&L(i?.search)&&i.search.indexOf(`__posthog_debug=true`)!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disableDeviceModel:!1,disable_external_dependency_loading:!1,strict_script_versioning:!1,enable_recording_console_log:void 0,secure_cookie:(e==null||(n=e.location)==null?void 0:n.protocol)===`https:`,ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:`localStorage`,consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!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){H.error(`Bad HTTP status: `+e.statusCode+` `+e.text)},get_device_id:e=>e,capture_performance:void 0,name:`posthog`,bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Pr,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:Uo},error_tracking:{},_onCapture:ws},(e=>({rageclick:e&&e>=`2026-05-30`?{content_ignorelist:Pi,ignore_text_selection:!0}
1:!e||`2025-11-30`>e||{content_ignorelist:!0},capture_pageview:!e||`2025-05-24`>e||`history_change`,session_recording:e&&e>=`2026-06-25`?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6},streamNetworkBody:!0}:e&&e>=`2026-05-30`?{strictMinimumDuration:!0,canvasCapture:{resolutionScale:.6}}: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,persistence_save_debounce_ms:e&&e>=`2026-05-30`?250:0,split_storage:!(!e||`2026-05-30`>e),detect_google_search_app:!(!e||`2026-05-30`>e),disable_capture_url_hashes:!(!e||`2026-06-25`>e)}))(t))},Ns=[[`process_person`,`person_profiles`],[`xhr_headers`,`request_headers`],[`cookie_name`,`persistence_name`],[`disable_cookie`,`disable_persistence`],[`__preview_disable_beacon`,`disable_beacon`],[`store_google`,`save_campaign_params`],[`verbose`,`debug`]],Ps=e=>{var t={};for(var n of Ns){var r=n[0],i=n[1];I(e[r])||(t[i]=e[r])}var a=G({},t,e),o=e.__preview_external_dependency_versioned_paths;return I(o)||(I(e.strict_script_versioning)&&(a.strict_script_versioning=!!o),L(o)&&I(e.asset_host)&&(a.asset_host=o)),N(e.property_blacklist)&&(I(e.property_denylist)?a.property_denylist=e.property_blacklist:N(e.property_denylist)?a.property_denylist=[...e.property_blacklist,...e.property_denylist]:H.error(Os+e.property_denylist)),a},Fs=class{constructor(){this.__forceAllowLocalhost=!1}get sn(){return this.__forceAllowLocalhost}set sn(e){H.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Is=class t{an(e,t){if(e){var n=this.Ji.indexOf(e);n!==-1&&this.Ji.splice(n,1)}return this.Ji.push(t),t.initialize==null||t.initialize(),t}ln(){return this.config.cookieless_mode===jr||this.config.cookieless_mode===Ar&&this.consent.isRejected()}get decideEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}get flagsEndpointWasHit(){var e;return(e=this.featureFlags?.hasLoadedFlags)!=null&&e}constructor(){this.webPerformance=new Fs,this.un=!1,this.version=p.LIB_VERSION,this.en=new Xo,this.Ji=[],this.hn=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Ms(),this.SentryIntegration=ca,this.sentryIntegration=e=>function(e,t){var n=sa(e,t);return{name:oa,processEvent:e=>n(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint=`/e/`,this.dn=!1,this.cn=null,this.vn=null,this.fn=null,this.scrollManager=new qo(this),this.pageViewManager=new la(this),this.rateLimiter=new Ya(this),this.requestRouter=new ls(this),this.consent=new di(this),this.externalIntegrations=new _s(this);var e=t.__defaultExtensionClasses??{};this.featureFlags=e.featureFlags&&new e.featureFlags(this),this.toolbar=e.toolbar&&new e.toolbar(this),this.surveys=e.surveys&&new e.surveys(this),this.conversations=e.conversations&&new e.conversations(this),this.logs=e.logs&&new e.logs(this),this.metrics=e.metrics&&new e.metrics(this),this.experiments=e.experiments&&new e.experiments(this),this.exceptions=e.exceptions&&new e.exceptions(this),this.people={set:(e,t,n)=>{var r=L(e)?{[e]:t}:e;this.setPersonProperties(r),n?.({})},set_once:(e,t,n)=>{var r=L(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),n?.({})}},this.on(`eventCaptured`,(e=>H.info(`send "`+e?.event+`"`,e)))}init(e,n,r){if(r&&r!==As){var i=Ss[r]??new t;return i._init(e,n,r),Ss[r]=i,Ss[As][r]=i,i}return this._init(e,n,r)}_init(t,n,r){var i;n===void 0&&(n={});var a=L(t)?t.trim():``;if(!a)return H.critical(`PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()`),this;if(this.__loaded)return this;this.__loaded=!0,this.config=Ms(n.defaults),n.debug=this.pn(n.debug),this.gn=n,this.mn=[],n.person_profiles?this.vn=n.person_profiles:n.process_person&&(this.vn=n.process_person);var o=Ms(n.defaults),s=Ps(n),c=G({},o,s,{name:r,token:a});F(o.rageclick)&&F(s.rageclick)&&(c.rageclick=G({},o.rageclick,s.rageclick)),F(o.session_recording)&&F(s.session_recording)&&(c.session_recording=G({},o.session_recording,s.session_recording)),this.set_config(c),this.config.on_xhr_error&&H.error(`on_xhr_error is deprecated. Use on_request_error instead`),this.compression=n.disable_compression?void 0:Y.GZipJS;var l=this.yn();this.persistence=new za(this.config,l),this.sessionPersistence=this.config.persistence===`
1sessionStorage`||this.config.persistence===`memory`?this.persistence:new za(g({},this.config,{persistence:`sessionStorage`}),l,!1);var u=g({},this.persistence.props),d=g({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.bn=new Wo((e=>this._n(e)),this.config.request_queue_config),this.wn=new Ko(this),this.__request_queue=[];var f=this.ln();if(f||(this.sessionManager=new Qo(this),this.sessionPropsManager=new Yo(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(H.info(`Deferring extension initialization to improve startup performance`),setTimeout((()=>{this.xn(f)}),0)):(H.info(`Initializing extensions synchronously`),this.xn(f)),p.DEBUG=p.DEBUG||this.config.debug,p.DEBUG&&H.info(`Starting in debug mode`,{this:this,config:n,thisC:g({},this.config),p:u,s:d}),!this.config.identity_distinct_id||(i=n.bootstrap)!=null&&i.distinctID||(n.bootstrap=g({},n.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),n.bootstrap?.distinctID!==void 0){var m=n.bootstrap.distinctID,h=this.get_distinct_id(),_=this.persistence.get_property(_r);if(n.bootstrap.isIdentifiedID&&h!=null&&h!==m&&_===Mr)this.identify(m);else if(n.bootstrap.isIdentifiedID&&h!=null&&h!==m&&_===Nr)H.warn(`Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.`);else{var v=this.config.get_device_id(ti()),y=n.bootstrap.isIdentifiedID?v:m;this.persistence.set_property(_r,n.bootstrap.isIdentifiedID?Nr:Mr),this.register({distinct_id:m,$device_id:y})}}if(f)this.register_once({distinct_id:wr,$device_id:null},``);else if(!this.get_distinct_id()){var b=this.config.get_device_id(ti());this.register_once({distinct_id:b,$device_id:b},``),this.persistence.set_property(_r,Mr)}return K(e,`onpagehide`in self?`pagehide`:`unload`,this._handle_unload.bind(this),{passive:!1}),n.segment?function(e,t){var n=e.config.segment;if(!n)return t();(function(e,t){var n=e.config.segment;if(!n)return t();var r=n=>{var r=()=>n.anonymousId()||ti();e.config.get_device_id=r,n.id()&&(e.register({distinct_id:n.id(),$device_id:r()}),e.persistence.set_property(_r,Nr)),t()},i=n.user();`then`in i&&P(i.then)?i.then(r):r(i)})(e,(()=>{n.register((e=>{typeof Promise<`u`&&Promise.resolve||aa.warn(`This browser does not have Promise support, and can not use the segment integration`);var t=(t,n)=>{if(!n)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(aa.info(`No userId set, resetting PostHog`),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(aa.info(`UserId set, identifying with PostHog`),e.identify(t.event.userId));var r=e.calculateEventProperties(n,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,Lr),identify:e=>t(e,zr),screen:e=>t(e,`$screen`)}})(e)).then((()=>{t()}))}))}(this,(()=>this.kn())):this.kn(),P(this.config._onCapture)&&this.config._onCapture!==ws&&(H.warn("onCapture is deprecated. Please use `before_send` instead"),this.on(`eventCaptured`,(e=>this.config._onCapture(e.event,e)))),this.config.ip&&H.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.config.disableDeviceModel||function(){return es.apply(this,arguments)}().then((e=>{e&&this.register({[jn]:e})})).catch(ws),this}xn(e){var n=performance.now(),r=g({},t.__defaultExtensionClasses,this.config.__extensionClasses),i=[];r.featureFlags&&this.Ji.push(this.featureFlags=this.featureFlags??new r.featureFlags(this)),r.exceptions&&this.Ji.push(this.exceptions=this.exceptions??new r.exceptions(this)),r.historyAutocapture&&this.Ji.push(this.historyAutocapture=new r.historyAutocapture(this)),r.tracingHeaders&&this.Ji.push(this.tracingHeaders=new r.tracingHeaders(this)),r.siteApps&&this.Ji.push(this.siteApps=new r.siteApps(this)),r.sessionRecording&&!e&&this.Ji.push(this.sessionRecording=new r.sessionRecording(this)),this.config.disable_scroll_properties||i.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.autocapture&&this.Ji.push(this.autocapture=new r.autocapture(this)),r.surveys&&this.Ji.push(this.surveys=this.surveys??new r.surveys(this)),r.logs&&this.Ji.push(this.logs=this.logs??new r.logs(this)),r.metrics&&this.Ji.push(this.metrics=this.metrics??new r.metrics(this)),r.conversations&&this.Ji.push(this.conversations=this.conversations??new r.conversations(this)),r.productTours&&this.Ji.push(this.productTours=new r.productTours(this)),r.heatmaps&&this.Ji.push(this.heatmaps=new r.heatmaps(this)),r.webVitalsAutocapture&&this.Ji.push(this.webVitalsAutocapture=new r.webVitalsAutocapture(this)),r.exceptionObserver&&this.Ji.push(this.exceptionObserver=new r.exceptionObserver(this)),r.deadClicksAutocapture&&this.Ji.push(this.deadClicksAutocapture=new r.deadClicksAutocapture(this,ra)),r.toolbar&&this.Ji.push(this.toolbar=this.toolbar??new r.toolbar(this)),r.experiments&&this.Ji.push(this.experiments=this.experiments??new r.experiments(this)),this.Ji.forEac
1h((e=>{e.initialize&&i.push((()=>{e.initialize==null||e.initialize()}))})),i.push((()=>{if(this.Sn){var e=this.Sn;this.Sn=void 0,this.Ji.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}})),this.Cn(i,n)}Cn(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.Cn(e,t)}),0);var n=e.shift();if(n)try{n()}catch(e){H.error(`Error initializing extension:`,e)}}var r=Math.round(performance.now()-t);this.register_for_session({[Er]:this.config.__preview_deferred_init_extensions?`deferred`:`synchronous`,[Dr]:r}),this.config.__preview_deferred_init_extensions&&H.info(`PostHog extensions initialized (`+r+`ms)`)}Br(e){var t;if(!r||!r.body)return H.info(`document not ready yet, trying again in 500 milliseconds...`),void setTimeout((()=>{this.Br(e)}),500);if(this.config.__preview_deferred_init_extensions&&(this.Sn=e),this.tn=e,this.compression=void 0,e.ok){var n,i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=M(i.supportedCompression,Y.GZipJS)?Y.GZipJS:M(i.supportedCompression,Y.Base64)?Y.Base64:void 0),(n=i.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.vn?this.vn:Pr}),(t=this.Mn)==null||t.handleRemoteConfig(e),this.Ji.forEach((t=>t.onRemoteConfig==null?void 0:t.onRemoteConfig(e)))}kn(){try{this.config.loaded(this)}catch(e){H.critical("`loaded` function failed",e)}if(this.In(),this.config.internal_or_test_user_hostname&&i!=null&&i.hostname){var e=i.hostname,t=this.config.internal_or_test_user_hostname;(typeof t==`string`?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.ln())&&this.Tn()}),1),this.En=new Za(this),this.En.load()}In(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.bn)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Vr(this.__request_queue,(e=>this._n(e))),this.__request_queue=[],this.In()}_handle_unload(){var e,t,n,r,i;(e=this.surveys)==null||e.handlePageUnload==null||e.handlePageUnload(),(t=this.metrics)==null||t.flush(`sendBeacon`),this.config.request_batching?(this.Rn()&&this.capture(Rr),(n=this.logs)==null||n.flushLogs(`sendBeacon`),(r=this.bn)==null||r.unload(),(i=this.wn)==null||i.unload()):this.Rn()&&this.capture(Rr,null,{transport:`sendBeacon`})}_send_request(e){this.__loaded?js?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=g({},this.config.request_headers,e.headers),e.compression=e.compression===`best-available`?this.compression:e.compression,(I(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=[`sendBeacon`]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t=g({},e);t.timeout=t.timeout||6e4;var n,r,i,a,o=t.transport??`fetch`;o===`sendBeacon`&&I(t.compression)&&t.data&&(t.compression=Y.Base64),t.method===`POST`&&t.data&&(t.timestampMode===`capture-body`?t.data={api_key:((a=(i=N(n=t.data)?n:[n])[0])==null||(r=a.properties)==null?void 0:r.token)??a?.token,batch:i,sent_at:new Date().toISOString()}:t.timestampMode===`body`&&(t.data=function(e,t){return t===void 0&&(t=new Date().toISOString()),N(e)?e.map((e=>g({},e,{sent_at:t}))):g({},e,{sent_at:t})}(t.data))),t.url=Vo(t.url,t.method,t.compression,t.timestampMode);var s=Ho.filter((e=>!t.disableTransport||!e.transport||!t.disableTransport.includes(e.transport))),l=function(e,t){for(var n=0;e.length>n;n++)if(e[n].transport===o)return e[n]}(s)?.method??s[0].method;if(!l)throw Error(`No available transport method`);o!==`sendBeacon`&&t.data&&t.compression===Y.GZipJS&&c&&typeof Promise<`u`&&!jo?Lo(t).then((e=>{l(e)})).catch((n=>{if(k(n))return jo=!0,void l(g({},t,{compression:void 0,url:Vo(e.url,e.method,void 0,e.timestampMode)}));(e=>{if(!e||typeof e!=`object`)return!1;var t=`name`in e?String(e.name):``;return k(e)||t===D})(n)&&(jo=!0),l(t)})):l(t)})(g({},e,{callback:t=>{var n,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(n=(r=this.config).on_request_error)==null||n.call(r,t),e.callback==null||e.callback(t)}}))):e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:0}))}_n(e){this.wn?this.wn.retriableRequest(e):this._send_request(e)}_execute_array(e){Cs++;try{var t,n=[],r=[],i=[];Vr(e,(e=>{if(e)if(N(t=e[0]))i.push(e);else if(P(e))try{e.call(this)}catch(t){H.error(`Error executing queued PostHog call`,e,t)}else N(e)&&t===`alias`?n.push(e):N(e)&&t.indexOf(`capture`)!==-1&&P(this[t])?i.push(e):r.push(e)}));var a=function(e,t){Vr(e,(function(e){try{if(N(e[0])){var n=t;W(e,(function(e){n=n[e[0]].apply(n,e.slice(1))}))}else t[e[0]].apply(t,e.slice(1))}catch(t){H.error(`Error executing queued PostHog call`,e,t)}}))};a(n,this),a(r,this),a(i,this)}finally{Cs--}}push(e){if(Cs>0&&N(e)&&L(e[0])){var n=t.prototype[e[0]];P(n)&&n.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,n){var r,i,a,o,s;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.bn){if(this.is_capturing())if(!I(e)&&L(e)){var c=!this.config.opt_out_useragent_filter&&this._is_bot();if(!c||this.config.__preview_capture_bot_pageviews){var l=n!=null&&n.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(l==null||!l.isRateLimited){if(this.hn.length>0){var u={};for(var d of this.hn.slice())try{G(u,d())}catch(e){H.error(`Failed to produce browser extension event properties`,e)}t=g({},u,t??{})}var f;(r=t)!=null&&r.$current_url&&!L(t?.$current_url)&&(H.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),(f=t)==null||delete f.$current_url),e!==`$exception`||n!=null&&n.Pn||H.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),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 p=new Date,m=n?.timestamp||p,h=kt(n?.uuid,ti),_={uuid:h,event:e,properties:this.calculateEventProperties(e,t||{},m,h)};e===Lr&&this.config.__preview_capture_bot_pageviews&&c&&(_.event=`$bot_pageview`,_.properties.$browser_type=`bot`),l&&(_.properties.$lib_rate_limit_remaining_tokens=l.remainingTokens);var v=e===`$feature_flag_called`&&!1===_.properties.$feature_flag_has_experiment&&!0===this.get_property(rr);n!=null&&n.$set&&!v&&(_.$set=n?.$set);var y=n?.$unset;y&&(_.$unset=y);var b,x,C,w=v?void 0:this.On(n?.$set_once,e!==Br,e===zr);if(w&&(_.$set_once=w),n!=null&&n._noTruncate||(i=this.config.properties_string_max_length,a=_,o=e=>L(e)?e.slice(0,i):e,s=new Set,_=function e(t,n){if(t!==Object(t))return o?o(t):t;if(!s.has(t)){var r;if(s.add(t),N(t))r=[],Vr(t,(t=>{r.push(e(t))}));else{var i={};
1W(t,((t,n)=>{s.has(t)||(i[n]=e(t,n))})),r=i}return r}}(a)),_.timestamp=m,I(n?.timestamp)||(_.properties.$event_time_override_provided=!0,_.properties.$event_time_override_system_time=p),v&&(_.properties=function(e,t){t===void 0&&(t=[]);var n={},r=t=>{e[t]!==void 0&&(n[t]=e[t])};return S.forEach(r),t.forEach(r),n}(_.properties,ks)),e===Ua.DISMISSED||e===Ua.SENT){var T=t?.[Wa.SURVEY_ID],E=t?.[Wa.SURVEY_ITERATION];fs({id:T,current_iteration:E}),_.$set=g({},_.$set,{[(b={id:T,current_iteration:E},x=e===Ua.SENT?`responded`:`dismissed`,C=`$survey_`+x+`/`+b.id,b.current_iteration&&b.current_iteration>0&&(C=`$survey_`+x+`/`+b.id+`/`+b.current_iteration),C)]:!0})}else e===Ua.SHOWN&&(_.$set=g({},_.$set,{[Wa.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Ka.SHOWN){var D=t?.[qa.TOUR_TYPE];D&&(_.$set=g({},_.$set,{[qa.TOUR_LAST_SEEN_DATE+`/`+D]:new Date().toISOString()}))}var O=g({},_.properties.$set,_.$set);if(ue(O)||this.setPersonPropertiesForFlags(O),!z(this.config.before_send)){var ee=this.Rt(_);if(!ee)return;(_=ee).uuid=kt(_.uuid,ti)}this.en.emit(`eventCaptured`,_);var k=n?._url??this.requestRouter.endpointFor(`api`,this.analyticsDefaultEndpoint),A={method:`POST`,url:k,data:_,compression:`best-available`,timestampMode:n?._batchKey===`recordings`||/\/s\/(?:\?|$)/.test(k)?`body`:`capture-body`,batchKey:n?._batchKey,transport:n?.transport};return!this.config.request_batching||n&&(n==null||!n._batchKey)||n!=null&&n.send_instantly?this._n(A):this.bn.enqueue(A),_}H.critical(`This capture call is ignored due to client rate limiting.`)}}else H.error(`No event name provided to posthog.capture`)}else H.uninitializedWarning(`posthog.capture`)}_addCaptureHook(e){return this.on(`eventCaptured`,(t=>e(t.event,t)))}Fn(){return this.Mn??=new xs(this)}nn(e){this.hn.push(e);var t=!0;return()=>{if(t){t=!1;var n=this.hn.indexOf(e);n!==-1&&this.hn.splice(n,1)}}}calculateEventProperties(t,n,a,o,s){if(a||=new Date,!this.persistence||!this.sessionPersistence)return n;var c=s?void 0:this.persistence.remove_event_timer(t),u=g({},n);if(u.token=this.config.token,u.$config_defaults=this.config.defaults,this.ln()&&(u[Tr]=!0),t===`$snapshot`){var d=g({},this.persistence.properties(),this.sessionPersistence.properties());return u.distinct_id=d.distinct_id,(!L(u.distinct_id)&&!B(u.distinct_id)||de(u.distinct_id))&&H.error(`Invalid distinct_id for replay event. This indicates a bug in your implementation`),u}var f,m=function(t,n,r,a){var o,s,c;if(a===void 0&&(a=!1),!l)return{};var u,d=t?[...Sa,...n||[]]:[],f=function(e){for(var t=0;Et.length>t;t++){var n=Et[t],r=n[1],i=n[0].exec(e),a=i&&(P(r)?r(i,e):r);if(a)return a}return[``,``]}(l),m=f[0],h=f[1],g=(u=typeof navigator<`u`?navigator:void 0)!=null&&u.brave?{brave:!0}:{},_={};I(r)||(_.detectGoogleSearchApp=r);var v={},y=(o=navigator)==null||(o=o.userAgentData)==null?void 0:o.platform,b=navigator?.maxTouchPoints,x=e==null||(s=e.screen)==null?void 0:s.width,S=e==null||(c=e.screen)==null?void 0:c.height,C=e?.devicePixelRatio;I(y)||(v.userAgentDataPlatform=y),I(b)||(v.maxTouchPoints=b),I(x)||(v.screenWidth=x),I(S)||(v.screenHeight=S),I(C)||(v.devicePixelRatio=C);var w,T,E,D,O=G(Gr({$os:m,$os_version:h,$browser:Ct(l,navigator.vendor,g,_),$device:Dt(l),$device_type:(T=l,E=v,D=Dt(T),D===Ae||D===ke||D===`Kobo`||D===`Kindle Fire`||D===ot?Oe:D===Ye||D===Ze||D===Xe||D===rt?`Console`:D===Me?`Wearable`:D?Te:E?.userAgentDataPlatform===`Android`&&(E?.maxTouchPoints??0)>0?600>Math.min(E?.screenWidth??0,E?.screenHeight??0)/(E?.devicePixelRatio??1)?Te:Oe:`Desktop`),$timezone:Pa(),$timezone_offset:Fa()}),{$current_url:_a(a?At(i?.href):i?.href,d,wa),$host:i?.host,$pathname:i?.pathname,$raw_user_agent:l.length>1e3?l.substring(0,997)+`...`:l,$browser_version:Tt(l,navigator.vendor,g,_),$browser_language:ka(),$browser_language_prefix:(w=ka(),typeof w==`string`?w.split(`-`)[0]:void 0),$screen_height:e?.screen.height,$screen_width:e?.screen.width,$viewport_height:e?.innerHeight,$viewport_width:e?.innerWidth,$lib:p.LIB_NAME,$lib_version:p.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return p.SDK_DIST_CHANNEL&&(O.$sdk_dist_channel=p.SDK_DIST_CHANNEL),O}(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes
1);if(this.sessionManager){var h=this.sessionManager.checkAndGetSessionAndWindowId(s,a.getTime()),_=h.windowId;u.$session_id=h.sessionId,u.$window_id=_}this.sessionPropsManager&&G(u,this.sessionPropsManager.getSessionProps());try{this.sessionRecording&&G(u,this.sessionRecording.sdkDebugProperties),u.$sdk_debug_retry_queue_size=this.wn?.length}catch(e){u.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===os&&(u.$lib_custom_api_host=this.config.api_host),f=t!==Lr||s?t!==Rr||s?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(a):this.pageViewManager.doPageView(a,o),u=G(u,f),t===Lr&&r&&(u.title=r.title),!I(c)){var v=a.getTime()-c;u.$duration=parseFloat((v/1e3).toFixed(3))}l&&this.config.opt_out_useragent_filter&&(u.$browser_type=this._is_bot()?`bot`:`browser`);var y=this.persistence.properties(),b=this.sessionPersistence.properties();W([`$referrer`,`$referring_domain`],(e=>{e in y&&delete b[e]})),(u=G({},m,y,b,u)).$is_identified=this._isIdentified(),N(this.config.property_denylist)?W(this.config.property_denylist,(function(e){delete u[e]})):H.error(Os+this.config.property_denylist+` or property_blacklist config: `+this.config.property_blacklist);var x=this.config.sanitize_properties;x&&(H.error(Ds),u=x(u,t));var S=this.An();return u.$process_person_profile=S,S&&!s&&this.$n(`_calculate_event_properties`),u}
1On(e,t,n){if(t===void 0&&(t=!0),n===void 0&&(n=!1),!this.persistence||!this.An()||this.un&&!n)return e;var r=G({},this.persistence.get_initial_props(),this.sessionPropsManager?.getSetOnceProps()||{},e||{}),i=this.config.sanitize_properties;return i&&(H.error(Ds),r=i(r,`$set_once`)),t&&(this.un=!0),ue(r)?void 0:r}register(e,t){var n;(n=this.persistence)==null||n.register(e,t)}register_once(e,t,n){var r;(r=this.persistence)==null||r.register_once(e,t,n)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}Ln(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)}getAllFeatureFlags(){return this.featureFlags?.getAllFeatureFlags()??[]}isFeatureEnabled(e,t){return this.featureFlags?.isFeatureEnabled(e,t)??t?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,n){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,n)}updateEarlyAccessFeatureEnrollment(e,t,n){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,n)}getEarlyAccessFeatures(e,t,n){return t===void 0&&(t=!1),this.featureFlags?.getEarlyAccessFeatures(e,t,n)}on(e,t){return this.en.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:Es}),()=>{})}onSessionId(e){return this.sessionManager?.onSessionId(e)??(()=>{})}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:Es})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:Es})}renderSurvey(e,t){var n;(n=this.surveys)==null||n.renderSurvey(e,t)}displaySurvey(e,t){var n;t===void 0&&(t=ms),(n=this.surveys)==null||n.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys?.canRenderSurvey(e)??{visible:!1,disabledReason:Es}}canRenderSurveyAsync(e,t){return t===void 0&&(t=!1),this.surveys?.canRenderSurveyAsync(e,t)??Promise.resolve({visible:!1,disabledReason:Es})}Dn(e){return!e||de(e)?(H.critical(`Unique user id has not been set in posthog.identify`),!1):e===wr?(H.critical(`The string "`+e+`" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.`),!1):![`distinct_id`,`distinctid`].includes(e.toLowerCase())&&![`undefined`,`null`].includes(e.toLowerCase())||(H.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.`),!1)}identify(e,t,n){if(!this.__loaded||!this.persistence)return H.uninitializedWarning(`posthog.identify`);if(B(e)&&(e=e.toString(),H.warn(`The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.`)),this.Dn(e)&&this.$n(`posthog.identify`)){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(An)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},``),e!==r&&e!==this.get_property(Mn)&&(this.unregister(Mn),this.register({distinct_id:e}));var i,a=(this.persistence.get_property(_r)||Mr)===Mr,o=e!==r,s=!o&&a;if(o&&a)this.persistence.set_property(_r,Nr),this.setPersonPropertiesForFlags({$set:t||{},$set_once:n||{}},!1),this.capture(zr,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:n||{}}),this.fn=ns(e,t,n),(i=this.featureFlags)==null||i.setAnonymousDistinctId(r);else if(s){this.persistence.set_property(_r,Nr);var c=t||{},l=n||{};this.setPersonPropertiesForFlags({$set:c,$set_once:l},!1),this.capture(`$set`,{$set:c,$set_once:l}),this.fn=ns(e,t,n)}else(t||n)&&this.setPersonProperties(t,n);o?(this.reloadFeatureFlags(),this.unregister(pr)):s&&(t||n)&&this.reloadFeatureFlags()}}setPersonProperties(e,t){if((e||t)&&this.$n(`posthog.setPersonProperties`)){var n=ns(this.get_distinct_id(),e,t);this.fn===n?H.info(`A duplicate setPersonProperties call was made with the same properties. It has been ignored.`):(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture(`$set`,{$set:e||{},$set_once:t||{}}),this.fn=n)}}unsetPersonProperties(e){var t,n=(N(e)?e:[e]).filter((e=>L(e)&&e.length>0));n.length!==0&&this.$n(`posthog.unsetPersonProperties`)&&((t=this.featureFlags)==null||t.unsetPersonPropertiesForFlags(n,!0),this.capture(`$set`,{$unset:n}),this.fn=null)}group(e,t,n){if(e&&t){var r=this.getGroups(),i=r[e]!==t;if(i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:g({},r,{[e]:t})}),i||n){var a={$group_type:e,$group_key:t};n&&(a.$group_set=n),this.capture(Br,a)}n&&this.setGroupPropertiesForFlags({[e]:n}),i&&!n&&this.reloadFeatureFlags()}else H.error(`posthog.group requires a group type and group key`)}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),(n=this.featureFlags)==null||n.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(e){var t;e===void 0&&(e=!0),(t=this.featureFlags)==null||t.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,t){var n;t===void 0&&(t=!0),this.$n(`posthog.setGroupPropertiesForFlags`)&&((n=this.featureFlags)==null||n.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,n,r,i,a,o,s,c,l,u;if(H.info(`reset`),!this.__loaded)return H.uninitializedWarning(`posthog.reset`);var d,f=this.get_property(An),p=this.get_property(jn),m=this.get_property(Un);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(n=this.sessionPersistence)==null||n.clear(),I(m)||(d=this.persistence)==null||d.register({[Un]:m}),(r=this.surveys)==null||r.reset(),(i=this.En)==null||i.stop(),(a=this.featureFlags)==null||a.reset(),(o=this.conversations)==null||o.reset(),(s=this.logs)==null||s.reset(),(c=this.metrics)==null||c.reset(),(l=this.persistence)==null||l.set_property(_r,Mr),(u=this.sessionManager)==null||u.resetSessionId(),this.fn=null,this.config.cookieless_mode===jr)this.register_once({distinct_id:wr,$device_id:null},``);else{var h=this.config.get_device_id(ti());this.register_once({distinct_id:h,$device_id:e?h:f},``),e||I(p)||this.register({[jn]:p})}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}shutdown(e){var t=this;return h((function*(){var e,n,r,i,a,o,s;t.__loaded?((e=t.En)==null||e.stop(),(n=t.Mn)==null||n.dispose(),(r=t.logs)==null||r.flushLogs(`sendBeacon`),(i=t.metrics)==null||i.flush(`sendBeacon`),(a=t.bn)==null||a.unload(),(o=t.wn)==null||o.unload(),(s=t.featureFlags)==null||s.destroy()):H.uninitializedWarning(`posthog.shutdown`)}))()}setIdentity(e,t){var n;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(n=this.conversations)==null||n.Nn()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.qn()}get_distinct_id(){return this.get_property(`distinct_id`)}getGroups(){return this.get_property(`$groups`)||{}}get_session_id(){return this.sessionManager?.checkAndGetSessionAndWindowId(!0).sessionId??``}get_session_replay_url(e){if(!this.sessionManager)return``;var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=t.sessionStartTimestamp,r=this.requestRouter.endpointFor(`ui`,`/project/`+this.config.token+`/replay/`+t.sessionId);if(e!=null&&e.withTimestamp&&n){var i=e.timestampLookBack??10;if(!n)return r;r+=`?t=`+Math.max(Math.floor((new Date().getTime()-n)/1e3)-i,0)}return r}alias(e,t){return e===this.get_property(kn)?(H.critical(`Attempting to create alias for existing People user - aborting.`),-2):this.$n(`posthog.alias`)?(I(t)&&(t=this.get_distinct_id()),e===t?(H.warn(`alias matches current distinct_id - skipping api call.`),this.identify(e),-1):(this.Ln(Mn,e),this.capture(`$create_alias`,{alias:e,distinct_id:t}))):void 0}set_config(e){var t=g({},this.config);if(F(e)){var n,r,i,a,o,s,c,l,u,d,f;G(this.config,Ps(e));var m=this.yn();(n=this.persistence)==null||n.update_config(this.config,t,m),this.sessionPersistence=this.config.persistence===`
1sessionStorage`||this.config.persistence===`memory`?this.persistence:new za(g({},this.config,{persistence:`sessionStorage`}),m,!1);var h=this.pn(this.config.debug);pe(h)&&(this.config.debug=h),pe(this.config.debug)&&(this.config.debug?(p.DEBUG=!0,q.N()&&q.A(`ph_debug`,!0),H.info(`set_config`,{config:e,oldConfig:t,newConfig:g({},this.config)})):(p.DEBUG=!1,q.N()&&q.D(`ph_debug`))),(r=this.exceptionObserver)==null||r.onConfigChange(),(i=this.exceptions)==null||i.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(o=this.tracingHeaders)==null||o.startIfEnabledOrStop(),(s=this.autocapture)==null||s.startIfEnabled(),(c=this.heatmaps)==null||c.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(u=this.deadClicksAutocapture)==null||u.startIfEnabledOrStop(),(d=this.surveys)==null||d.loadIfEnabled(),this.jn(),(f=this.externalIntegrations)==null||f.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){p.LIB_NAME=e,p.LIB_VERSION=t}startSessionRecording(e){var t,n,r,i,a,o=!0===e,s={sampling:o||!(e==null||!e.sampling),linked_flag:o||!(e==null||!e.linked_flag),url_trigger:o||!(e==null||!e.url_trigger),event_trigger:o||!(e==null||!e.event_trigger)};Object.values(s).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),s.sampling&&((n=this.sessionRecording)==null||n.overrideSampling()),s.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),s.url_trigger&&((i=this.sessionRecording)==null||i.overrideTrigger(`url`)),s.event_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger(`event`))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var n=Error(`PostHog syntheticException`),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:n});return this.exceptions.sendExceptionEvent(g({},r,t))}}addExceptionStep(e,t){var n;(n=this.exceptions)==null||n.addExceptionStep(e,t)}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){return this.logs?.logger??t.Bn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t;return(t=this.toolbar?.loadToolbar(e))!=null&&t}get_property(e){return this.persistence?.props[e]}getSessionProperty(e){return this.sessionPersistence?.props[e]}toString(){var e=this.config.name??As;return e!==As&&(e=As+`.`+e),e}_isIdentified(){return this.persistence?.get_property(_r)===Nr||this.sessionPersistence?.get_property(_r)===Nr}An(){var e,t;return!(this.config.person_profiles===`never`||this.config.person_profiles===Pr&&!this._isIdentified()&&ue(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Mn])&&((t=this.persistence)==null||(t=t.props)==null||!t[Cr]))}Rn(){return!0===this.config.capture_pageleave||this.config.capture_pageleave===`if_capture_pageview`&&(!0===this.config.capture_pageview||this.config.capture_pageview===`history_change`)}createPersonProfile(){this.An()||this.$n(`posthog.createPersonProfile`)&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.$n(`posthog.setInternalOrTestUser`)&&this.setPersonProperties({$internal_or_test_user:!0})}$n(e){return this.config.person_profiles===`never`?(H.error(e+` was called, but process_person is set to "never". This call will be ignored.`),!1):(this.Ln(Cr,!0),!0)}yn(){if(this.config.cookieless_mode===`always`)return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==Ar)}jn(){var e,t,n=this.yn();return this.persistence?.yr!==n&&((e=this.persistence)==null||e.set_disabled(n)),this.sessionPersistence?.yr!==n&&((t=this.sessionPersistence)==null||t.set_disabled(n)),n}opt_in_capturing(e){var n;if(this.config.cookieless_mode!==jr){if(this.ln()){var r,i;this.reset(!0),(r=this.sessionManager)==null||r.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=new Qo(this),this.pageViewM
1anager=new la(this),this.persistence&&(this.sessionPropsManager=new Yo(this,this.sessionManager,this.persistence));var a,o=this.config.__extensionClasses?.sessionRecording??t.__defaultExtensionClasses?.sessionRecording;o&&(this.sessionRecording=this.an(this.sessionRecording,new o(this)),this.tn&&((a=this.sessionRecording)==null||a.onRemoteConfig==null||a.onRemoteConfig(this.tn)))}var s;this.consent.optInOut(!0),this.jn(),this.In(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode==Ar&&((s=this.surveys)==null||s.loadIfEnabled()),(I(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture(e?.captureEventName??`$opt_in`,e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Tn()}else H.warn(Ts)}opt_out_capturing(){var e,t,n;this.config.cookieless_mode===jr?H.warn(Ts):(this.config.cookieless_mode===Ar&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.jn(),this.config.cookieless_mode===Ar&&(this.register({distinct_id:wr,$device_id:null}),(e=this.sessionRecording)==null||e.stopRecording(),this.sessionRecording=void 0,(t=this.sessionManager)==null||t.destroy(),(n=this.pageViewManager)==null||n.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Tn(),this.In()))}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===1?`granted`:e===0?`denied`:`pending`}is_capturing(){return this.config.cookieless_mode===jr||(this.config.cookieless_mode===Ar?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.jn()}_is_bot(){return n?$o(n,this.config.custom_blocked_useragents):void 0}Tn(){r&&(r.visibilityState===`visible`?this.dn||(this.dn=!0,this.capture(Lr,{title:r.title},{send_instantly:!0}),this.cn&&=(r.removeEventListener(Fr,this.cn),null)):this.cn||(this.cn=this.Tn.bind(this),K(r,Fr,this.cn)))}debug(t){!1===t?(e?.console.log(`You've disabled debug mode.`),this.set_config({debug:!1})):(e?.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}))}Ur(){var e=this.gn||{};return`advanced_disable_flags`in e?!!e.advanced_disable_flags:!1===this.config.advanced_disable_flags?!0===this.config.advanced_disable_decide?(H.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):function(e,t,n,r,i){var a=t in e&&!z(e[t]),o=n in e&&!z(e[n]);return a?e[t]:!!o&&(i&&i.warn(`Config field '`+n+`' is deprecated. Please use '`+t+`' instead. The old field will be removed in a future major version.`),e[n])}(e,`advanced_disable_flags`,`advanced_disable_decide`,0,H):!!this.config.advanced_disable_flags}Rt(e){if(z(this.config.before_send))return e;var t=Object.keys(e.properties??{}).filter(ge),n=N(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of n){if(r=i(r),z(r)){var a=`Event '`+e.event+`' was rejected in beforeSend function`;return he(e.event)?H.warn(a+`. This can cause unexpected behavior.`):H.info(a),null}r.properties&&!ue(r.properties)||H.warn(`Event '`+e.event+`' has no properties after beforeSend function, this is likely an error.`)}for(var o of t)if(r.properties&&z(r.properties[o]))return H.warn(`Event '`+e.event+`' had its '`+o+`' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return r}getPageViewId(){return this.pageViewManager.ir?.pageViewId}captureTraceFeedback(e,t){this.capture(`$ai_feedback`,{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,n){this.capture(`$ai_metric`,{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(n)})}pn(e){var t=pe(e)&&!e,n=q.N()&&q.q(`ph_debug`)===`true`;return!t&&(!!n||e)}};Is.__defaultExtensionClasses={},Is.Bn=(()=>{var e=()=>{};return{trace:e,debug:e,info:e,warn:e,error:e,fatal:e}})(),function(e,t){for(var n=0;t.length>n;n++)e.prototype[t[n]]=Wr(e.prototype[t[n]])}(Is,[`identify`]);var Ls=class{constructor(e){this.disabled=!1===e;var t=F(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,n){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&&this.timeoutMs>n-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:n}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:n}];return!1}},Rs=`$copy_autocapture`,zs=U(`[AutoCapture]`);function Bs(e,t){return t.length>e?t.slice(0,e)+`...`:t}function Vs(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!vi(t));return t}function Hs(t,n){var r,i=n.e,a=n.maskAllElementAttributes,o=n.maskAllText,s=n.elementAttributeIgnoreList,c=n.elementsC
1hainAsString,l=n.disableCaptureUrlHashes;if(!vi(t))return{props:{}};for(var u=[t],d=new Set([t]),f=t;f.parentNode&&!yi(f,`body`)&&Si>u.length;)if(xi(f.parentNode)){var p=f.parentNode.host;if(d.has(p))break;d.add(p),u.push(p),f=p}else{if(!vi(f.parentNode)||d.has(f.parentNode))break;d.add(f.parentNode),u.push(f.parentNode),f=f.parentNode}var m,h,_=[],v={},y=!1,b=!1;if(W(u,(e=>{var t=Vi(e);if(yi(e,`a`)){var n=e.getAttribute(`href`);y=!!(t&&n&&Xi(n))&&(l?At(n):n)}M(Ti(e),`ph-no-capture`)&&(b=!0),_.push(function(e,t,n,r,i){i===void 0&&(i=!1);var a=e.tagName.toLowerCase(),o={tag_name:a};ki.indexOf(a)>-1&&!n&&(o.$el_text=a.toLowerCase()===`a`||a.toLowerCase()===`button`?Bs(1024,Zi(e)):Bs(1024,Di(e)));var s=Ti(e);s.length>0&&(o.classes=s.filter((function(e){return e!==``}))),W(e.attributes,(function(n){var a;if((!Hi(e)||[`name`,`id`,`class`,`aria-label`].indexOf(n.name)!==-1)&&(r==null||!r.includes(n.name))&&!t&&Xi(n.value)&&(!L(a=n.name)||a.substring(0,10)!==`_ngcontent`&&a.substring(0,7)!==`_nghost`)){var s=n.value;n.name===`class`&&(s=Ci(s).join(` `)),o[`attr__`+n.name]=Bs(1024,n.name===`href`&&i?At(s):s)}}));for(var c=1,l=1,u=e;u=Vs(u);)c++,u.tagName===e.tagName&&l++;return o.nth_child=c,o.nth_of_type=l,o}(e,a,o,s,l)),G(v,function(e){if(!Vi(e))return{};var t={};return W(e.attributes,(function(e){if(e.name&&e.name.indexOf(`data-ph-capture-attribute`)===0){var n=e.name.replace(`data-ph-capture-attribute-`,``),r=e.value;n&&r&&Xi(r)&&(t[n]=r)}})),t}(e))})),b)return{props:{},explicitNoCapture:b};if(o||(_[0].$el_text=yi(t,`a`)||yi(t,`button`)?Zi(t):Di(t)),y){var x;_[0].attr__href=y;var S=ha(y)?.host,C=e==null||(x=e.location)==null?void 0:x.host;S&&C&&S!==C&&(m=y)}return{props:G({$event_type:i.type,$ce_version:1},c?{}:{$elements:_},{$elements_chain:(h=_,function(e){return e.map((e=>{var t=``;if(e.tag_name&&(t+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))t+=`.`+n.replace(/"/g,``);var r=g({},e.text?{text:e.text}:{},{"nth-child":e.nth_child??0,"nth-of-type":e.nth_of_type??0},e.href?{href:e.href}:{},e.attr_id?{attr_id:e.attr_id}:{},e.attributes),i={};return Hr(r).sort(((e,t)=>e[0].localeCompare(t[0]))).forEach((e=>{var t=e[1];return i[$i(e[0].toString())]=$i(t.toString())})),(t+=`:`)+Hr(i).map((e=>e[0]+`="`+e[1]+`"`)).join(``)})).join(`;`)}(function(e){return e.map((e=>{var t={text:e.$el_text?.slice(0,400),tag_name:e.tag_name,href:e.attr__href?.slice(0,2048),attr_class:ea(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Hr(e).filter((e=>e[0].indexOf(`attr__`)===0)).forEach((e=>t.attributes[e[0]]=e[1])),t}))}(h)))},(r=_[0])!=null&&r.$el_text?{$el_text:_[0]?.$el_text}:{},m&&i.type===`click`?{$external_click_url:m}:{},v)}}var Us=U(`[ExceptionAutocapture]`),Ws=()=>{},Gs=U(`[TracingHeaders]`),Ks=U(`[Web Vitals]`),qs=9e5,Js=`disabled`,Ys=`lazy_loading`,Xs=`awaiting_config`,Zs=`missing_config`;U(`[SessionRecording]`),U(`[SessionRecording]`);var Qs=`[SessionRecording]`,$s=U(Qs),ec=U(`[Heatmaps]`);function tc(e){return F(e)&&`clientX`in e&&`clientY`in e&&B(e.clientX)&&B(e.clientY)}var nc=U(`[Product Tours]`),rc=e=>{var t;return!e.config.disable_product_tours&&!((t=e.persistence)==null||!t.get_property(Vn))},ic=[`$set_once`,`$set`],ac=U(`[SiteApps]`),oc=`Error while initializing PostHog app with config id `;function sc(e,t,n){if(z(e))return!1;switch(n){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{return!1}default:return!1}}var cc=class{constructor(e){this.Hn=new Xo,this.Un=(e,t)=>this.zn(e,t)&&this.Vn(e,t)&&this.Wn(e,t)&&this.Zn(e,t),this.zn=(e,t)=>t==null||!t.event||e?.event===t?.event,this._instance=e,this.Gn=new Set,this.Qn=new Set}init(){var e;I(this._instance?._addCaptureHook)||(e=this._instance)==null||e._addCaptureHook(((e,t)=>{this.on(e,t)}))}register(e){var t;if(!I(this._instance?._addCaptureHook)&&(e.forEach((e=>{var t,n;(t=this.Qn)==null||t.add(e),(n=e.steps)==null||n.forEach((e=>{var t;(t=this.Gn)==null||t.add(e?.event||``)}))})),(t=this._instance)!=null&&t.autocapture)){var n,r=new Set;e.forEach((e=>{var t;(t=e.steps)==null||t.forEach((e=>{e!=null&&e.selector&&r.add(e?.selector)}))}
1)),(n=this._instance)==null||n.autocapture.setElementSelectors(r)}}on(e,t){t!=null&&e.length!=0&&(this.Gn.has(e)||this.Gn.has(t.event))&&this.Qn&&this.Qn?.size>0&&this.Qn.forEach((e=>{this.Jn(t,e)&&this.Hn.emit(`actionCaptured`,e.name)}))}Kn(e){this.onAction(`actionCaptured`,(t=>e(t)))}Jn(e,t){if(t?.steps==null)return!1;for(var n of t.steps)if(this.Un(e,n))return!0;return!1}onAction(e,t){return this.Hn.on(e,t)}Vn(e,t){if(t!=null&&t.url){var n,r=e==null||(n=e.properties)==null?void 0:n.$current_url;if(!r||typeof r!=`string`||!sc(r,t.url,t.url_matching||`contains`))return!1}return!0}Wn(e,t){return!!this.Yn(e,t)&&!!this.Xn(e,t)&&!!this.ts(e,t)}Yn(e,t){var n;if(t==null||!t.href)return!0;var r=this.es(e);if(r.length>0)return r.some((e=>sc(e.href,t.href,t.href_matching||`exact`)));var i,a=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!a&&sc((i=a.match(/(?::|")href="(.*?)"/))?i[1]:``,t.href,t.href_matching||`exact`)}Xn(e,t){var n;if(t==null||!t.text)return!0;var r=this.es(e);if(r.length>0)return r.some((e=>sc(e.text,t.text,t.text_matching||`exact`)||sc(e.$el_text,t.text,t.text_matching||`exact`)));var i,a,o,s=(e==null||(n=e.properties)==null?void 0:n.$elements_chain)||``;return!!s&&(i=function(e){for(var t,n=[],r=/(?::|")text="(.*?)"/g;!z(t=r.exec(e));)n.includes(t[1])||n.push(t[1]);return n}(s),a=t.text,o=t.text_matching||`exact`,i.some((e=>sc(e,a,o))))}ts(e,t){var n,r;if(t==null||!t.selector)return!0;var i=e==null||(n=e.properties)==null?void 0:n.$element_selectors;if(i!=null&&i.includes(t.selector))return!0;var a=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||``;if(t.selector_regex&&a)try{return new RegExp(t.selector_regex).test(a)}catch{return!1}return!1}es(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}Zn(e,t){return t==null||!t.properties||t.properties.length===0||as(t.properties.reduce(((e,t)=>{var n=N(t.value)?t.value.map(String):t.value==null?[]:[String(t.value)];return e[t.key]={values:n,operator:t.operator||`exact`},e}),{}),e?.properties)}},lc=class{constructor(e){var t;this.rs=[],this._instance=e,this.ns=new Map,this.ss=new Map,this.os=new Map,(t=this._instance)==null||t.onSessionId==null||t.onSessionId((e=>this.ls(e)))}us(e,t){return!!e&&as(e.propertyFilters,t?.properties)}hs(e,t){var n=new Map;return e.forEach((e=>{var r;(r=e.conditions)==null||(r=r[t])==null||(r=r.values)==null||r.forEach((t=>{if(t!=null&&t.name){var r=n.get(t.name)||[];r.push(e.id),n.set(t.name,r)}}))})),n}ds(e,t,n){var r=(n===Va.Activation?this.ns:this.ss).get(e),i=[];return this.cs((e=>{i=e.filter((e=>r?.includes(e.id)))})),i.filter((r=>{var i,a=(i=r.conditions)==null||(i=i[n])==null||(i=i.values)==null?void 0:i.find((t=>t.name===e));return this.us(a,t)}))}register(e){I(this._instance?._addCaptureHook)||(this.vs(e),this.fs(e))}fs(e){var t=e.filter((e=>{var t;return e.conditions?.actions&&((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null?void 0:t.length)>0}));t.length!==0&&(this.ps??(this.ps=new cc(this._instance),this.ps.init(),this.ps.Kn((e=>{this.onAction(e)}))),t.forEach((e=>{var t,n,r,i,a;e.conditions&&(t=e.conditions)!=null&&t.actions&&(n=e.conditions)!=null&&(n=n.actions)!=null&&n.values&&((r=e.conditions)==null||(r=r.actions)==null||(r=r.values)==null?void 0:r.length)>0&&((i=this.ps)==null||i.register(e.conditions.actions.values),(a=e.conditions)==null||(a=a.actions)==null||(a=a.values)==null||a.forEach((t=>{if(t&&t.name){var n=this.os.get(t.name);n&&n.push(e.id),this.os.set(t.name,n||[e.id])}})))})))}vs(e){var t,n=e.filter((e=>{var t;return e.conditions?.events&&((t=e.conditions)==null||(t=t.events)==null||(t=t.values)==null?void 0:t.length)>0})),r=e.filter((e=>{var t;return e.conditions?.cancelEvents&&((t=e.conditions)==null||(t=t.cancelEvents)==null||(t=t.values)==null?void 0:t.length)>0}));n.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),this.ns=this.hs(e,Va.Activation),this.ss=this.hs(e,Va.Cancellation))}onEvent(e,t){var n,r,i=this.gs(),a=(t==null||(n=t.properties)==null?void 0:n.$survey_id)||(t==null||(r=t.properties)==null?void 0:r.$product_tour_id);if(a&&this.getActivatedIds().includes(a)){var o=this.ys(e,a);if(o===`consume`)return i.info(`event consumed activated item, remov
1ing it`,{event:e,itemId:a}),void this.bs([a]);if(o===`persist`)return i.info(`shown item promoted to persisted activation`,{event:e,itemId:a}),void this._s(a)}if(this.ss.has(e)){var s=this.ds(e,t,Va.Cancellation);s.length>0&&(i.info(`cancel event matched, cancelling items`,{event:e,itemsToCancel:s.map((e=>e.id))}),this.bs(s.map((e=>e.id))),s.forEach((e=>this.ws(e.id))))}if(this.ns.has(e)){i.info(`event name matched`,{event:e,eventPayload:t,items:this.ns.get(e)});var c=this.ds(e,t,Va.Activation);this.xs(c.map((e=>e.id)))}}onAction(e){this.os.has(e)&&this.xs(this.os.get(e)||[])}xs(e){e.length!==0&&(this.rs=[...new Set([...this.rs,...e])],this.gs().info(`updating activated items`,{activatedItems:this.getActivatedIds()}))}_s(e){this.rs=this.rs.filter((t=>t!==e));var t=this.ks();t.includes(e)||(this.Ss([...t,e]),this.Cs())}bs(e){var t=new Set(e);this.rs=this.rs.filter((e=>!t.has(e)));var n=this.Ms(),r=n.filter((e=>!t.has(e)));r.length!==n.length&&(this.Ss(r),r.length===0&&this.Is())}Ms(){var e,t=this.Ts();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}ks(){var e,t,n=this.Ms();if(n.length===0)return[];var r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this.Es()],i=(t=this._instance)==null||t.get_session_id==null?void 0:t.get_session_id();return i&&r===i?n:[]}Cs(){var e,t=(e=this._instance)==null||e.get_session_id==null?void 0:e.get_session_id();t&&this.Rs(t)}Is(){this.Ps()}ls(e){var t,n=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.Es()];n&&n!==e&&(this.Ms().length>0&&this.Ss([]),this.Is())}getActivatedIds(){return[...new Set([...this.ks(),...this.rs])].filter((e=>!this.Os(e)))}reset(){this.rs=[],this.Ms().length>0&&this.Ss([]),this.Is()}getEventToItemsMap(){return this.ns}Fs(){return this.ps}},uc=class extends lc{constructor(e){super(e)}Ts(){return ur}Es(){return dr}As(){return Ua.SHOWN}cs(e){var t;(t=this._instance)==null||t.getSurveys(e)}ws(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}gs(){return Q}Ss(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[ur]:e})}Rs(e){var t;(t=this._instance)==null||(t=t.persistence)==null||t.register({[dr]:e})}Ps(){var e;(e=this._instance)==null||(e=e.persistence)==null||e.unregister(dr)}Os(){return!1}ys(e,t){var n;return this.cs((e=>{n=e.find((e=>e.id===t))})),!n||function(e){var t;return us(e)&&!((t=e.conditions)==null||(t=t.events)==null||!t.repeatedActivation)||e.schedule===`always`}(n)?e===Ua.SHOWN?`consume`:`ignore`:e===Ua.SHOWN?`persist`:e===Ua.DISMISSED||e===Ua.SENT?`consume`:`ignore`}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},dc=`SDK is not enabled or survey functionality is not yet loaded`,fc=`Disabled. Not loading surveys.`,pc=e!=null&&e.location?va(e.location.hash,`__posthog`)||va(location.hash,`state`):null,mc=`_postHogToolbarParams`,hc=U(`[Toolbar]`),$=U(`[FeatureFlags]`),gc=U(`[FeatureFlags]`,{debugEnabled:!0}),_c=`" failed. Feature flags didn't load in time.`,vc=e=>{for(var t={},n=0;e.length>n;n++)t[e[n]]=!0;return t},yc=e=>{var t={};for(var n of Hr(e||{})){var r=n[1];r&&(t[n[0]]=r)}return t},bc=U(`[Error tracking]`),xc=`Refusing to render web experiment since the viewer is a likely bot`,Sc={icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())===-1,regex:(e,t)=>ts(t,e),not_regex:(e,t)=>!ts(t,e),exact:(e,t)=>t===e,is_not:(e,t)=>t!==e},Cc=class t{get Te(){return this._instance.config}constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(e){e===void 0&&(e=!1),n.getWebExperiments((e=>{t.$s(`retrieved web experiments from the server`),n.Ls=new Map,e.forEach((e=>{if(e.feature_flag_key){var r;n.Ls&&(t.$s(`setting flag key `,e.feature_flag_key,` to web experiment `,e),(r=n.Ls)==null||r.set(e.feature_flag_key,e));var i=n._instance.getFeatureFlag(e.feature_flag_key);L(i)&&e.variants[i]&&n.Ds(e.name,i,e.variants[i].transforms)}else if(e.variants)for(var a in e.variants){var o=e.variants[a];t.Ns(o,n._instance)&&n.Ds(e.name,a,o.transforms)}}))}),e)},this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())t.$s(xc);else if(!this.Te.disable_web_experiments){if(z(this.Ls))return this.Ls=new Map,this.loadIfEnabled(),void this.previewWebExperiment();
1t.$s(`applying feature flags`,e),e.forEach((e=>{var t;if(this.Ls&&(t=this.Ls)!=null&&t.has(e)){var n=this._instance.getFeatureFlag(e),r=this.Ls?.get(e);n&&r!=null&&r.variants[n]&&this.Ds(r.name,n,r.variants[n].transforms)}}))}}previewWebExperiment(){var e=t.getWindowLocation();if(e!=null&&e.search){var n=ga(e?.search,`__experiment_id`),r=ga(e?.search,`__experiment_variant`);n&&r&&(t.$s(`previewing web experiments `+n+` && `+r),this.getWebExperiments((e=>{this.qs(parseInt(n),r,e)}),!1,!0))}}loadIfEnabled(){this.Te.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,n){if(this.Te.disable_web_experiments&&!n)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.Te.token),method:`GET`,timestampMode:`query`,callback:t=>e(t.statusCode===200&&t.json&&t.json.experiments||[])})}qs(e,n,r){var i=r.filter((t=>t.id===e));i&&i.length>0&&(t.$s(`Previewing web experiment [`+i[0].name+`] with variant [`+n+`]`),this.Ds(i[0].name,n,i[0].variants[n].transforms))}static Ns(e,n){return!z(e.conditions)&&t.js(e,n)&&t.Bs(e)}static js(e,n){if(z(e.conditions)||z(e.conditions?.url))return!0;var r=t.getWindowLocation();if(r){var i,a=fi(n,r.href);return(i=e.conditions)==null||!i.url||Sc[e.conditions?.urlMatchType??`icontains`](e.conditions.url,a)}return!1}
1static getWindowLocation(){return e?.location}static Bs(e){if(z(e.conditions)||z(e.conditions?.utm))return!0;var t=Ea();if(t.utm_source){var n,r,i,a,o,s,c,l,u=(n=e.conditions)==null||(n=n.utm)==null||!n.utm_campaign||((r=e.conditions)==null||(r=r.utm)==null?void 0:r.utm_campaign)==t.utm_campaign,d=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==t.utm_source,f=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_medium||((s=e.conditions)==null||(s=s.utm)==null?void 0:s.utm_medium)==t.utm_medium,p=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((l=e.conditions)==null||(l=l.utm)==null?void 0:l.utm_term)==t.utm_term;return u&&f&&p&&d}return!1}static $s(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];H.info(`[WebExperiments] `+e,n)}Ds(e,n,r){this._is_bot()?t.$s(xc):n===`control`?t.$s(`Control variants leave the page unmodified.`):r.forEach((r=>{r.selector&&(t.$s(`applying transform of variant `+n+` for experiment `+e+` `,r),(document?.querySelectorAll(r.selector))?.forEach((e=>{var t=e;r.html&&(t.innerHTML=r.html),r.css&&t.setAttribute(`style`,r.css)})))}))}_is_bot(){return n&&this._instance?$o(n,this.Te.custom_blocked_useragents):void 0}},wc=U(`[Conversations]`),Tc=`Conversations not available yet.`,Ec=`console`,Dc={featureFlags:class{constructor(t){this.Hs=!1,this.Us=!1,this.zs=!1,this.Vs=!1,this.Ws=!1,this.Zs=!1,this.Gs=!1,this.Qs=!1,this.Js=0,this.Ks=()=>{var e=this.Ys();this.Js=0,e&&this.reloadFeatureFlags()},this._instance=t,this.featureFlagEventHandlers=[],e&&K(e,`online`,this.Ks)}destroy(){e?.removeEventListener(`online`,this.Ks)}get Te(){return this._instance.config}get mi(){return this._instance.persistence}Xs(e){return this._instance.get_property(e)}eo(){var e;return(e=this.mi?._r(this.Te.feature_flag_cache_ttl_ms))!=null&&e}ro(){return!!this.eo()&&(this.Qs||this.zs||(this.Qs=!0,$.warn(`Feature flag cache is stale, triggering refresh...`),this.reloadFeatureFlags()),!0)}io(){var e=this.Te.evaluation_contexts??this.Te.evaluation_environments;return!this.Te.evaluation_environments||this.Te.evaluation_contexts||this.Gs||($.warn(`evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version.`),this.Gs=!0),e!=null&&e.length?e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||$.error(`Invalid evaluation context found:`,e,`Expected non-empty string`),t})):[]}no(){return this.io().length>0}so(){var e=this.Te.flag_keys;if(!I(e)){if(N(e))return e.filter((e=>{var t=e&&typeof e==`string`&&e.trim().length>0;return t||$.error(`Invalid flag key found:`,e,`Expected non-empty string`),t}));$.error(`Invalid flag_keys found:`,e,`Expected array of non-empty strings`)}}initialize(){var e=this._instance.config,t=e.bootstrap?.featureFlags??{};if(Object.keys(t).length){var n=e.bootstrap?.featureFlagPayloads??{},r=Object.keys(t).filter((e=>!!t[e])).reduce(((e,n)=>(e[n]=t[n]||!1,e)),{}),i=Object.keys(n).filter((e=>r[e])).reduce(((e,t)=>(n[t]&&(e[t]=n[t]),e)),{});this.receivedFeatureFlags({featureFlags:r,featureFlagPayloads:i})}}updateFlags(e,t,n){var r,i,a=n!=null&&n.merge&&(r=this.Xs(Zn))!=null?r:{},o=n!=null&&n.merge&&(i=this.Xs(tr))!=null?i:{},s=g({},a,e),c=g({},o,t),l={};for(var u of Object.entries(s)){var d=u[0],f=u[1];l[d]={key:d,enabled:y(f),variant:b(f),reason:void 0,metadata:I(c?.[d])?void 0:{id:0,version:void 0,description:void 0,payload:c[d]}}}this.receivedFeatureFlags({flags:l})}get hasLoadedFlags(){return this.Us}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this.Xs(er),t=this.Xs(ir),n=this.Xs(ar);if(!n&&!t)return e||{};var r=G({},e||{});for(var i of[...new Set([...Object.keys(n||{}),...Object.keys(t||{})])]){var a,o,s=r[i],c=t?.[i],l=I(c)?(a=s?.enabled)!=null&&a:!!c,u=I(c)?s.variant:typeof c==`string`?c:void 0,d=n?.[i],f=g({},s,{enabled:l,variant:l?u??s?.variant:void 0});l!==s?.enabled&&(f.original_enabled=s?.enabled),u!==s?.variant&&(f.original_variant=s?.variant),d&&(f.metadata=g({},s?.metadata,{payload:d,original_payload:s==null||(o=s.metadata)==null?void 0:o.payload})),r[i]=f}return this.Hs||=($.warn(` Overriding feature flag details!`,{flagDetails:e,overriddenPayloads:n,finalDetails:r}),!0),r}getAllFeatureFlags(){var e=this.getFlagVariants(),t=this.getFlagPayloads();return Object.keys(e).map((n=>{var r=e[n];return{key:n,enabled:y(r),variant:b(r),payload:v(t[n])}}))}getFlagVariants(){var e=this.Xs(Zn),t=this.Xs(ir);if(!t)return e||{};for(var n=G({},e),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Hs||=($.warn(` Overriding feature flags!`,{enabledFlags:e,overriddenFlags:t,finalFlags:n}),!0),n}getFlagPayloads(){var e=this.Xs(tr),t=this.Xs(ar);if(!t)return e||{};for(var n=G({},e||{}),r=Object.keys(t),i=0;r.length>i;i++)n[r[i]]=t[r[i]];return this.Hs||=($.warn(` Overriding feature flag payloads!`,{flagPayloads:e,overriddenPayloads:t,finalPayloads:n}),!0),n}reloadFeatureFlags(){this.Vs||this.Te.advanced_disable_feature_flags||this.Ys()||this.oo||(this._instance.en.emit(`featureFlagsReloading`,!0),this.oo=setTimeout((()=>{this.ao()}),5))}lo(){clearTimeout(this.oo),this.oo=void 0}ensureFlagsLoaded(){this.Us||this.zs||this.oo||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.Vs=e}ao(e){if(this.lo(),!this._instance.Ur()&&!this.Ys())if(this.zs)this.Ws=!0;else{var t=this.Te.token,n=this.Xs(An),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:g({},this.mi?.get_initial_props()||{},this.Xs(or)||{}
1,{$lib:p.LIB_NAME,$lib_version:p.LIB_VERSION}),group_properties:this.Xs(sr),timezone:Pa()};R(n)||I(n)||(r.$device_id=n),(e!=null&&e.disableFlags||this.Te.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.no()&&(r.evaluation_contexts=this.io());var i=this.so();I(i)||(r.flag_keys=i);var a=!!this.Te.advanced_only_evaluate_survey_feature_flags,o=this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`+(this.Te.advanced_only_evaluate_survey_feature_flags?`&only_evaluate_survey_feature_flags=true`:``));this.zs=!0,this._instance._send_request({method:`POST`,url:o,data:r,compression:this.Te.disable_compression?void 0:Y.Base64,timestampMode:`body`,timeout:this.Te.feature_flag_request_timeout_ms,callback:e=>{var t,n,i,o=!0;if(this.uo(e.statusCode),e.statusCode===200&&(this.Ws||(this.$anon_distinct_id=void 0),o=!1),this.zs=!1,!r.disable_flags||this.Ws){this.Zs=!o;var s=[];e.error?e.error instanceof Error?s.push(e.error.name===`AbortError`?`timeout`:`connection_error`):s.push(`unknown_error`):e.statusCode!==200&&s.push(`api_error_`+e.statusCode),(t=e.json)!=null&&t.errorsWhileComputingFlags&&s.push(`errors_while_computing_flags`);var c=!((n=e.json)==null||(n=n.quotaLimited)==null||!n.includes(`feature_flags`));c&&s.push(`quota_limited`),(i=this.mi)==null||i.register({[hr]:s}),c?$.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.`):(r.disable_flags||this.receivedFeatureFlags(e.json??{},o,{partialResponse:a}),this.Ws&&(this.Ws=!1,this.ao()))}}})}}Ys(){return ya(this.Js,3)}uo(e){this.Js=ba(e,this.Js,3,(()=>$.warn(`Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes.`)))}getFeatureFlag(e,t){if(t===void 0&&(t={}),!t.fresh||this.Zs)if(this.Us||this.getFlags()&&this.getFlags().length>0){if(!this.ro()){var n=this.getFeatureFlagResult(e,t);return n?.variant??n?.enabled}}else $.warn(`getFeatureFlag for key "`+e+_c)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFeatureFlagResult(e,{send_event:!1})?.payload}getFeatureFlagResult(e,t){if(t===void 0&&(t={}),!t.fresh||this.Zs)if(this.Us||this.getFlags()&&this.getFlags().length>0){if(!this.ro()){var n=this.getFlagVariants(),r=e in n,i=n[e],a=this.getFlagPayloads()[e],o=String(i),s=this.Xs(nr)||void 0,c=this.Xs(gr)||void 0,l=this.Xs(pr)||{};if(this.Te.advanced_feature_flags_dedup_per_session){var u,d=this._instance.get_session_id(),f=this.Xs(mr);d&&d!==f&&(l={},(u=this.mi)==null||u.register({[pr]:l,[mr]:d}))}if((t.send_event||!(`send_event`in t))&&(!(e in l)||!l[e].includes(o))){var p,m,h,g,_,y,b,x,S;N(l[e])?l[e].push(o):l[e]=[o],(p=this.mi)==null||p.register({[pr]:l});var C=this.getFeatureFlagDetails(e),w=[...this.Xs(hr)??[]];I(i)&&w.push(`flag_missing`);var T={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:a||null,$feature_flag_request_id:s,$feature_flag_evaluated_at:c,$feature_flag_bootstrapped_response:((m=this.Te.bootstrap)==null||(m=m.featureFlags)==null?void 0:m[e])||null,$feature_flag_bootstrapped_payload:((h=this.Te.bootstrap)==null||(h=h.featureFlagPayloads)==null?void 0:h[e])||null,$used_bootstrap_value:!this.Zs};I(C==null||(g=C.metadata)==null?void 0:g.has_experiment)||(T.$feature_flag_has_experiment=C.metadata.has_experiment),I(C==null||(_=C.metadata)==null?void 0:_.version)||(T.$feature_flag_version=C.metadata.version);var E,D=(C==null||(y=C.reason)==null?void 0:y.description)??(C==null||(b=C.reason)==null?void 0:b.code);D&&(T.$feature_flag_reason=D),C!=null&&(x=C.metadata)!=null&&x.id&&(T.$feature_flag_id=C.metadata.id),I(C?.original_variant)&&I(C?.original_enabled)||(T.$feature_flag_original_response=I(C.original_variant)?C.original_enabled:C.original_variant),C!=null&&(S=C.metadata)!=null&&S.original_payload&&(T.$feature_flag_original_payload=C==null||(E=C.metadata)==null?void 0:E.original_payload),w.length&&(T.$feature_flag_error=w.join(`,`)),this._instance.capture(`$feature_flag_called`,T)}if(r)return{key:e,enabled:!!i,variant:typeof i==`string`?i:void 0,payload:v(a)}}}else $.warn(`getFeatureFlagResult for key "`+e+_c)}getRemoteConfigPayload(e,t){var n=this.Te.token,r={distinct_id:this._instance.get_distinct_id(),token:n,person_properties:{$lib:p.L
1IB_NAME,$lib_version:p.LIB_VERSION}};this.no()&&(r.evaluation_contexts=this.io());var i=this.so();I(i)||(r.flag_keys=i),this._instance._send_request({method:`POST`,url:this._instance.requestRouter.endpointFor(`flags`,`/flags/?v=2`),data:r,compression:this.Te.disable_compression?void 0:Y.Base64,timestampMode:`body`,timeout:this.Te.feature_flag_request_timeout_ms,callback(n){var r=n.json?.featureFlagPayloads;t(r?.[e]||void 0)}})}isFeatureEnabled(e,t){if(t===void 0&&(t={}),t.fresh&&!this.Zs)return t.defaultValue;if(!(this.Us||this.getFlags()&&this.getFlags().length>0))return $.warn(`isFeatureEnabled for key "`+e+_c),t.defaultValue;var n=this.getFeatureFlag(e,t);return I(n)?t.defaultValue:!!n}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,t,n){if(this.mi){this.Us=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),a=this.getFlagsWithDetails();(function(e,t,n,r,i,a){n===void 0&&(n={}),r===void 0&&(r={}),i===void 0&&(i={});var o=(e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>[e,t[e].variant??t[e].enabled]))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>t[e].metadata?.payload)).map((e=>[e,t[e].metadata?.payload])))):e.featureFlags&&$.warn(`Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version`),e})(e),s=o.flags,c=o.featureFlags,l=o.featureFlagPayloads;if(c){var u=e.requestId,d=e.evaluatedAt;if(N(c)){$.warn(`v1 of the feature flags endpoint is deprecated. Please use the latest version.`);var f={};if(c)for(var p=0;c.length>p;p++)f[c[p]]=!0;t&&t.register({[Qn]:c,[Zn]:f,[rr]:!1})}else{var m=c,h=l,_=s;if(a!=null&&a.partialResponse)m=g({},n,m),h=g({},r,h),_=g({},i,_);else if(e.errorsWhileComputingFlags)if(s){var v=new Set(Object.keys(s).filter((e=>{var t;return!((t=s[e])!=null&&t.failed)})));m=g({},n,Object.fromEntries(Object.entries(m).filter((e=>v.has(e[0]))))),h=g({},r,Object.fromEntries(Object.entries(h||{}).filter((e=>v.has(e[0]))))),_=g({},i,Object.fromEntries(Object.entries(_||{}).filter((e=>v.has(e[0])))))}else m=g({},n,m),h=g({},r,h),_=g({},i,_);t&&t.register(g({[Qn]:Object.keys(yc(m)),[Zn]:m||{},[tr]:h||{},[er]:_||{},[rr]:!0===e.minimalFlagCalledEvents},u?{[nr]:u}:{},d?{[gr]:d}:{}))}}})(e,this.mi,r,i,a,n),t||(this.Qs=!1),this.ho(t)}}override(e,t){t===void 0&&(t=!1),$.warn(`override is deprecated. Please use overrideFeatureFlags instead.`),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this.mi)return $.uninitializedWarning(`posthog.featureFlags.overrideFeatureFlags`);if(!1===e)return this.mi.unregister(ir),this.mi.unregister(ar),this.ho(),gc.info(`All overrides cleared`);if(N(e)){var t=vc(e);return this.mi.register({[ir]:t}),this.ho(),gc.info(`Flag overrides set`,{flags:e})}if(e&&typeof e==`object`&&(`flags`in e||`payloads`in e)){var n,r=e;if(this.Hs=!!((n=r.suppressWarning)!=null&&n),`flags`in r){if(!1===r.flags)this.mi.unregister(ir),gc.info(`Flag overrides cleared`);else if(r.flags){if(N(r.flags)){var i=vc(r.flags);this.mi.register({[ir]:i})}else this.mi.register({[ir]:r.flags});gc.info(`Flag overrides set`,{flags:r.flags})}}`payloads`in r&&(!1===r.payloads?(this.mi.unregister(ar),gc.info(`Payload overrides cleared`)):r.payloads&&(this.mi.register({[ar]:r.payloads}),gc.info(`Payload overrides set`,{payloads:r.payloads}))),this.ho();return}if(e&&typeof e==`object`)return this.mi.register({[ir]:e}),this.ho(),gc.info(`Flag overrides set`,{flags:e});$.warn(`Invalid overrideOptions provided to overrideFeatureFlags`,{overrideOptions:e})}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.Us){var t=this.do(),n=t.flags,r=t.flagVariants;try{e(n,r)}catch(e){$.error(`Error while running feature flags callback`,e)}}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t,n){var r,i=(this.Xs($n)||[]).find((t=>t.flagKey===e)),a={[`$feature_enrollment/`+e]:t},o={$feature_flag:e,$feature_enrollment:t,$set:a};i&&(o.$early_access_feature_name=i.name),n&&(o.$feature_enrollment_stage=n),this._instance.capture(`$feature_enrollment_update`,o),this.setPersonPropertiesForFlags(a,!1);var s=g({},this.getFlagVariants(),{[e]:t});(r=this.mi)==null||r.register({[Qn]:Object.keys(yc(s)),[Zn]:s}),this.ho()}
1getEarlyAccessFeatures(e,t,n){t===void 0&&(t=!1);var r=this.Xs($n),i=n?`&`+n.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.Te.token+i),method:`GET`,timestampMode:`query`,callback:t=>{var n,r;if(t.json){var i=t.json.earlyAccessFeatures;return(n=this.mi)==null||n.unregister($n),(r=this.mi)==null||r.register({[$n]:i}),e(i)}}})}do(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,n)=>(e[n]=t[n],e)),{})}}ho(e){var t=this.do(),n=t.flags,r=t.flagVariants;this.featureFlagEventHandlers.forEach((t=>{try{t(n,r,{errorsLoading:e})}catch(e){$.error(`Error while running feature flags callback`,e)}}))}setPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Xs(or)||{},r=e?.$set||(e!=null&&e.$set_once?{}:e),i=e?.$set_once,a={};if(i)for(var o in i)({}).hasOwnProperty.call(i,o)&&(o in n||(a[o]=i[o]));this._instance.register({[or]:g({},n,a,r)}),t&&this._instance.reloadFeatureFlags()}unsetPersonPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=g({},this.Xs(or)||{});e.forEach((e=>{delete n[e]})),this._instance.register({[or]:n}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(e){e===void 0&&(e=!0),this._instance.unregister(or),e&&this._instance.reloadFeatureFlags()}setGroupPropertiesForFlags(e,t){t===void 0&&(t=!0);var n=this.Xs(sr)||{};Object.keys(n).length!==0&&Object.keys(n).forEach((t=>{n[t]=g({},n[t],e[t]),delete e[t]})),this._instance.register({[sr]:g({},n,e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this.Xs(sr)||{};this._instance.register({[sr]:g({},t,{[e]:{}})})}else this._instance.unregister(sr)}reset(){this.Us=!1,this.zs=!1,this.Vs=!1,this.Ws=!1,this.Zs=!1,this.$anon_distinct_id=void 0,this.lo(),this.Hs=!1,this.Js=0}}},Oc={sessionRecording:class{get Te(){return this._instance.config}get mi(){return this._instance.persistence}get started(){var e;return!((e=this.co)==null||!e.isStarted)}get status(){return this.vo===Xs||this.vo===Zs?this.vo:this.co?.status??this.vo}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.vo=Js,this.fo=void 0,this._instance=e,!this._instance.sessionManager)throw $s.error(`started without valid sessionManager`),Error(Qs+` started without valid sessionManager. This is a bug.`);if(this.Te.cookieless_mode===jr)throw Error(Qs+` cannot be used with cookieless_mode="always"`)}initialize(){this.startIfEnabledOrStop()}get po(){var t,n=!((t=this._instance.get_property(Un))==null||!t.enabled),r=!this.Te.disable_session_recording,i=this.Te.disable_session_recording||this._instance.consent.isOptedOut();return e&&n&&r&&!i}startIfEnabledOrStop(e){var t;if(!this.po||(t=this.co)==null||!t.isStarted){var n=!I(Object.assign)&&!I(Array.from);this.po&&n?(this.mo(e),$s.info(`starting`)):(this.vo=Js,this.stopRecording())}}mo(e){var t,n,r;this.po&&(this.vo!==Xs&&this.vo!==Zs&&(this.vo=Ys),f!=null&&(t=f.__PosthogExtensions__)!=null&&(t=t.rrweb)!=null&&t.record&&(n=f.__PosthogExtensions__)!=null&&n.initSessionRecording?this.yo(e):(r=f.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,this.bo,(t=>{if(t)return $s.error(`could not load recorder`,t);this.yo(e)})))}stopRecording(){var e,t;(e=this.fo)==null||e.call(this),this.fo=void 0,(t=this.co)==null||t.stop()}_o(){var e,t;(e=this.fo)==null||e.call(this),this.fo=void 0,(t=this.co)==null||t.discard()}wo(){var e,t;(e=this.mi)==null||e.unregister(Xn),(t=this.mi)==null||t.unregister(Wn)}xo(e,t){if(z(e))return null;var n,r=B(e)?e:parseFloat(e);return typeof(n=r)!=`number`||!Number.isFinite(n)||0>n||n>1?($s.warn(t+` must be between 0 and 1. Ignoring invalid value:`,e),null):r}ko(e){if(this.mi){var t,n=this.mi,r=()=>{var t=!1===e.sessionRecording?void 0:e.sessionRecording,r=this.xo(this.Te.session_recording?.sampleRate,`session_recording.sampleRate`),i=this.xo(t?.sampleRate,`remote config sampleRate`),a=r??i;z(a)&&this.wo();var o=t?.minimumDurationMilliseconds;n.register({[Un]:g({cache_timestamp:Date.now(),enabled:!!t},t,{networkPayloadCapture:g({capturePerformance:e.capturePerformance},t?.networkPayloadCapture),canvasRecording:{enabled:t?.recordCanvas,fps:t?.canvasFps,quality:t?.canvasQuality},sampleRate:a,minimumDurationMilliseconds:I(o)?null:o,endpoint:t?.endpoint,triggerMatchType:t?.triggerMatchType,masking:t?.masking,urlTriggers:t?.urlTriggers,version:t?.version,triggerGroups:t?.triggerGroups})})};r(),(t=this.fo)==null||t.call(this),this.fo=this._instance.sessionManager?.onSessionId(r)}}onRemoteConfig(e){var t=e.ok?e.config:void 0;t&&`sessionRecording`in t?!1===t.sessionRecording?(this.ko(t),this._o()):(this.ko(t),this.startIfEnabledOrStop()):(this.vo===Xs&&(this.vo=Zs,$s.warn(`config refresh failed, recording will not start until page reload`)),this.startIfEnabledOrStop())}log(e,t){var n;t===void 0&&(t=`log`),(n=this.co)!=null&&n.log?this.co.log(e,t):$s.warn(`log called before recorder was ready`)}get bo(){var e,t,n=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Un);return(n==null||(t=n.scriptConfig)==null?void 0:t.script)||`lazy-recorder`}So(){var e,t=this._instance.get_property(Un);if(!t)return!1;try{e=typeof t==`object`?t:JSON.parse(t)}catch(e){return $s.warn(`persisted remote config for session recording is invali
1d and will be ignored`,e),!1}var n=e.cache_timestamp??Date.now();return 36e5>=Date.now()-n}yo(e){var t;if((t=f.__PosthogExtensions__)==null||!t.initSessionRecording)return $s.warn(`Called on script loaded before session recording is available. This can be caused by adblockers.`),void this._instance.register_for_session({[Or]:!0});if(this.co||(this.co=f.__PosthogExtensions__?.initSessionRecording(this._instance),this.co._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.So()){if(this.vo===Zs||this.vo===Xs)return;this.vo=Xs,$s.info(`persisted remote config is stale, requesting fresh config before starting`),new Za(this._instance).load();return}this.vo=Ys,this.co.start(e)}onRRwebEmit(e){var t;(t=this.co)==null||t.onRRwebEmit==null||t.onRRwebEmit(e)}overrideLinkedFlag(){var e,t;this.co||(t=this.mi)==null||t.register({[Kn]:!0}),(e=this.co)==null||e.overrideLinkedFlag()}overrideSampling(){var e,t;this.co||(t=this.mi)==null||t.register({[Gn]:!0}),(e=this.co)==null||e.overrideSampling()}overrideTrigger(e){var t,n;this.co||(n=this.mi)==null||n.register({[e===`url`?qn:Jn]:!0}),(t=this.co)==null||t.overrideTrigger(e)}get sdkDebugProperties(){return this.co?.sdkDebugProperties||{$recording_status:this.status}}tryAddCustomEvent(e,t){var n;return!((n=this.co)==null||!n.tryAddCustomEvent(e,t))}}},kc={autocapture:class{constructor(e){this.Co=!1,this.Mo=null,this.Io=!1,this.To=!1,this.instance=e,this.rageclicks=new Ls(e.config.rageclick),this.Eo=null}initialize(){this.startIfEnabled()}get Te(){var e=F(this.instance.config.autocapture)?this.instance.config.autocapture:{};return e.url_allowlist=e.url_allowlist?.map((e=>new RegExp(e))),e.url_ignorelist=e.url_ignorelist?.map((e=>new RegExp(e))),e}Ro(){if(this.isBrowserSupported()){if(e&&r){var t=t=>{t||=e?.event;try{this.Po(t)}catch(e){zs.error(`Failed to capture event`,e)}};if(K(r,`submit`,t,{capture:!0}),K(r,`change`,t,{capture:!0}),K(r,`click`,t,{capture:!0}),this.Te.capture_copied_text){var n=t=>{t||=e?.event;try{this.Po(t,Rs)}catch(e){zs.error(`Failed to capture copy/cut event`,e)}};K(r,`copy`,n,{capture:!0}),K(r,`cut`,n,{capture:!0})}}}else zs.info(`Disabling Automatic Event Collection because this browser is not supported`)}startIfEnabled(){this.isEnabled&&!this.Co&&(this.Ro(),this.Co=!0)}onRemoteConfig(e){if(this.Io=!0,e.ok){var t=e.config;t.elementsChainAsString&&(this.To=t.elementsChainAsString);var n=t.autocapture_opt_out;pe(n)&&(this.instance.persistence&&this.instance.persistence.register({[Pn]:n}),this.Mo=n),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(e){this.Eo=e}getElementSelectors(e){var t,n=[];return(t=this.Eo)==null||t.forEach((t=>{(r?.querySelectorAll(t))?.forEach((r=>{e===r&&n.push(t)}))})),n}get isEnabled(){var e=this.instance.persistence?.props[Pn],t=this.Mo,n=this.instance.Ur()&&!this.Io;if(R(t)&&!pe(e)&&!n)return!1;var r=this.Mo??!!e;return!!this.instance.config.autocapture&&!r}Po(t,n){if(n===void 0&&(n=`$autocapture`),this.isEnabled){var r,i=Oi(t);bi(i)&&(i=i.parentNode||null),n===`$autocapture`&&t.type===`click`&&t instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&Ri(i,this.instance.config.rageclick)&&this.Po(t,`$rageclick`);var a=n===Rs;if(i&&function(t,n,r,i,a,o){if(!e||zi(t)||r!=null&&r.url_allowlist&&!wi(r.url_allowlist,o)||r!=null&&r.url_ignorelist&&wi(r.url_ignorelist,o))return!1;if(r!=null&&r.dom_event_allowlist){var s=r.dom_event_allowlist;if(s&&!s.some((e=>n.type===e)))return!1}var c=Bi(t,i),l=c.parentIsUsefulElement,u=c.targetElementList;if(!function(e,t){var n=t?.element_allowlist;if(I(n))return!0;var r,i=function(e){if(n.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var a of e)if(r=i(a))return r.v;return!1}(u,r)||!Ai(u,r?.css_selector_allowlist)||Ai(u,r?.css_selector_ignorelist??Mi))return!1;try{var d=e.getComputedStyle(t);if(d&&d.getPropertyValue(`cursor`)===`pointer`&&n.type===`click`)return!0}catch{}var f=t.tagName.toLowerCase();switch(f){case`html`:return!1;case`form`:return(a||[`submit`]).indexOf(n.type)>=0;
1case`input`:case`select`:case`textarea`:return(a||[`change`,`click`]).indexOf(n.type)>=0;default:return l?(a||[`click`]).indexOf(n.type)>=0:(a||[`click`]).indexOf(n.type)>=0&&(ki.indexOf(f)>-1||t.getAttribute(`contenteditable`)===`true`)}}(i,t,this.Te,a,a?[`copy`,`cut`]:void 0,this.instance)){var o=Hs(i,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Te.element_attribute_ignorelist,elementsChainAsString:this.To,disableCaptureUrlHashes:this.instance.config.disable_capture_url_hashes}),s=o.props;if(o.explicitNoCapture)return!1;var c=this.getElementSelectors(i);if(c&&c.length>0&&(s.$element_selectors=c),n===Rs){var l,u=Ei(e==null||(l=e.getSelection())==null?void 0:l.toString()),d=t.type||`clipboard`;if(!u)return!1;s.$selected_content=u,s.$copy_type=d}return this.instance.capture(n,s),!0}}}isBrowserSupported(){return P(r?.querySelectorAll)}},historyAutocapture:class{constructor(t){var n;this._instance=t,this.Oo=(e==null||(n=e.location)==null?void 0:n.pathname)||``}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview===`history_change`}startIfEnabled(){this.isEnabled&&(H.info(`History API monitoring enabled, starting...`),this.monitorHistoryChanges())}stop(){this.Fo&&this.Fo(),this.Fo=void 0,H.info(`History API monitoring stopped`)}monitorHistoryChanges(){e&&e.history&&(this.Ao(`pushState`),this.Ao(`replaceState`),this.$o())}Ao(t){var n;if(e&&((n=e.history[t])==null||!n.__posthog_wrapped__)){var r=this;(function(e,t,n){try{if(!(t in e))return Ws;var r={next:e[t]},i=n((function(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return r.next.apply(this,t)}));return P(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:r}})),e[t]=i,()=>{if(e[t]!==i)for(var n=e[t];P(n)&&n.__posthog_layer__;){var a=n.__posthog_layer__;if(a.next===i)return void(a.next=r.next);n=a.next}else e[t]=r.next}}catch{return Ws}})(e.history,t,(e=>function(n,i,a){e.call(this,n,i,a),r.Lo(t)}))}}Lo(t){try{var n,r=e==null||(n=e.location)==null?void 0:n.pathname;if(!r)return;r!==this.Oo&&this.isEnabled&&this._instance.capture(Lr,{navigation_type:t}),this.Oo=r}catch(e){H.error(`Error capturing `+t+` pageview`,e)}}$o(){if(!this.Fo){var t=()=>{this.Lo(`popstate`)};K(e,`popstate`,t),this.Fo=()=>{e&&e.removeEventListener(`popstate`,t)}}}},heatmaps:class{get Te(){return this.instance.config}constructor(e){var t;this.Do=!1,this.Co=!1,this.No=null,this.instance=e,this.Do=!((t=this.instance.persistence)==null||!t.props[Fn]),this.rageclicks=new Ls(e.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var e=5e3;return F(this.Te.capture_heatmaps)&&this.Te.capture_heatmaps.flush_interval_milliseconds&&(e=this.Te.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return z(this.Te.capture_heatmaps)?z(this.Te.enable_heatmaps)?this.Do:this.Te.enable_heatmaps:!1!==this.Te.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this.Co)return;ec.info(`starting...`),this.qo(),this.xe()}else clearInterval(this.No??void 0),this.jo(),this.getAndClearBuffer()}onRemoteConfig(e){if(e.ok){var t=e.config;if(`heatmaps`in t){var n=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Fn]:n}),this.Do=n,this.startIfEnabled()}}}getAndClearBuffer(){var e=this.R;return this.R=void 0,e}Bo(e){tc(e.originalEvent)&&this.pe(e.originalEvent,`deadclick`)}xe(){this.No&&clearInterval(this.No),this.No=r?.visibilityState===`visible`?setInterval(this.oi.bind(this),this.flushIntervalMilliseconds):null}qo(){e&&r&&(this.Ho=this.oi.bind(this),K(e,Ir,this.Ho),this.Uo=t=>this.pe(t||e?.event),K(r,`click`,this.Uo,{capture:!0}),this.zo=t=>this.Vo(t||e?.event),K(r,`mousemove`,this.zo,{capture:!0}),this.Wo=new ia(this.instance,na,this.Bo.bind(this)),this.Wo.startIfEnabledOrStop(),this.Zo=this.xe.bind(this),K(r,Fr,this.Zo),this.Co=!0)}jo(){var t;e&&r&&(this.Ho&&e.removeEventListener(Ir,this.Ho),this.Uo&&r.removeEventListener(`click`,this.Uo,{capture:!0}),this.zo&&r.removeEventListener(`mousemove`,this.zo,{capture:!0}),this.Zo&&r.removeEventListener(Fr,this.Zo),clearTimeout(this.Go),(t=this.Wo)==null||t.stop(),this.Co=!1)}Qo(t,n){var r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),a=this.instance.scrollManager.scrollElement(),o=function(t,n,r){for(var i=t;i&&vi(i)&&!yi(i,`body`);){if(i===r)return!1;var a=void 0;try{a=(i.ownerDocument?.defaultView??e)?.getComputedStyle(i).position}catch{return!1}if(M(n,a))return!0;
1i=ji(i)}return!1}(Oi(t),[`fixed`,`sticky`],a);return{x:t.clientX+(o?0:i),y:t.clientY+(o?0:r),target_fixed:o,type:n}}pe(e,t){var n;if(t===void 0&&(t=`click`),!_i(e.target)&&tc(e)){var r=this.Qo(e,t);(n=this.rageclicks)!=null&&n.isRageClick(e.clientX,e.clientY,new Date().getTime())&&Ri(Oi(e),this.instance.config.rageclick)&&this.Wt(g({},r,{type:`rageclick`})),this.Wt(r)}}Vo(e){!_i(e.target)&&tc(e)&&(clearTimeout(this.Go),this.Go=setTimeout((()=>{this.Wt(this.Qo(e,`mousemove`))}),500))}Wt(t){if(e){var n=this.Te.disable_capture_url_hashes?At(e.location.href):e.location.href,r=this.Te.custom_personal_data_properties,i=_a(n,this.Te.mask_personal_data_properties?[...Sa,...r||[]]:[],wa);this.R=this.R||{},this.R[i]||(this.R[i]=[]),this.R[i].push(t)}}oi(){this.R&&!ue(this.R)&&this.instance.capture(`$$heatmap`,{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:ia,webVitalsAutocapture:class{constructor(e){var t;this.Do=!1,this.Co=!1,this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Jo=()=>{clearTimeout(this.Ko),this.R.metrics.length!==0&&(this._instance.capture(`$web_vitals`,this.R.metrics.reduce(((e,t)=>g({},e,{[`$web_vitals_`+t.name+`_event`]:g({},t),[`$web_vitals_`+t.name+`_value`]:t.value})),{})),this.R={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Yo=e=>{this.R=this.R||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var t=this.Xo();if(!I(t))if(z(e?.name)||z(e?.value))Ks.error(`Invalid metric received`,e);else if(!this.ta||this.ta>e.value){this.R.url!==t&&(this.Jo(),this.Ko=setTimeout(this.Jo,this.flushToCaptureTimeoutMs)),I(this.R.url)&&(this.R.url=t),this.R.firstMetricTimestamp=I(this.R.firstMetricTimestamp)?Date.now():this.R.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0);var n=this._instance.sessionManager?.checkAndGetSessionAndWindowId(!0),r=g({},e,{$current_url:t,timestamp:Date.now()});I(n)||(r.$session_id=n.sessionId,r.$window_id=n.windowId),this.R.metrics.push(r),this.R.metrics.length===this.allowedMetrics.length&&this.Jo()}else Ks.error(`Ignoring metric with value >= `+this.ta,e)},this.ea=()=>{if(!this.Co){var e,t,n,r,i=f.__PosthogExtensions__;if(!I(i)&&!I(i.postHogWebVitalsCallbacks)){var a=i.postHogWebVitalsCallbacks;e=a.onLCP,t=a.onCLS,n=a.onFCP,r=a.onINP}e&&t&&n&&r?(this.allowedMetrics.indexOf(`LCP`)>-1&&e(this.Yo.bind(this)),this.allowedMetrics.indexOf(`CLS`)>-1&&t(this.Yo.bind(this)),this.allowedMetrics.indexOf(`FCP`)>-1&&n(this.Yo.bind(this)),this.allowedMetrics.indexOf(`INP`)>-1&&r(this.Yo.bind(this)),this.Co=!0):Ks.error(`web vitals callbacks not loaded - not starting`)}},this._instance=e,this.Do=!((t=this._instance.persistence)==null||!t.props[zn]),this.startIfEnabled()}get ra(){return this._instance.config.capture_performance}get allowedMetrics(){var e=F(this.ra)?this.ra?.web_vitals_allowed_metrics:void 0;return z(e)?this._instance.persistence?.props[Hn]||[`CLS`,`FCP`,`INP`,`LCP`]:e}get flushToCaptureTimeoutMs(){return(F(this.ra)?this.ra.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var e=F(this.ra)?this.ra.web_vitals_attribution:void 0;return e!=null&&e}get ta(){var e=F(this.ra)&&B(this.ra.__web_vitals_max_value)?this.ra.__web_vitals_max_value:qs;return e>0&&6e4>=e?qs:e}get isEnabled(){var e=i?.protocol;if(e!==`http:`&&e!==`https:`)return Ks.info(`Web Vitals are disabled on non-http/https protocols`),!1;var t=F(this.ra)?this.ra.web_vitals:pe(this.ra)?this.ra:void 0;return pe(t)?t:this.Do}startIfEnabled(){this.isEnabled&&!this.Co&&(Ks.info(`enabled, starting...`),this.tr(this.ea))}onRemoteConfig(e){if(e.ok){var t=e.config;if(`capturePerformance`in t){var n=F(t.capturePerformance)&&!!t.capturePerformance.web_vitals,r=F(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[zn]:n}),this._instance.persistence.register({[Hn]:r})),this.Do=n,this.startIfEnabled()}}}tr(e){var t,n;(t=f.__PosthogExtensions__)!=null&&t.postHogWebVitalsCallbacks?e():(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,this.useAttribution?`web-vitals-with-attribution`:`web-vitals`,(t=>{t?Ks.error(`failed to load script`,t):e()}))}Xo(){var t=e?this._instance.config.disable_capture_url_hashes?At(e.location.href):e.location.href:void 0;if(t){var n=this._instance.config.custom_personal_data_properties;return _a(t,this._instance.config.mask_personal_data_properties?[...Sa,...n||[]]:[],wa)}Ks.error(`Could not determine current URL`)}}},Ac={exceptionObserver:class{constructor(t){var n;this.ea=()=>{var t;if(e&&this.isEnabled&&(t=f.__PosthogExtensions__)!=null&&t.errorWrappingFunctions){var n=f.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=f.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,i=f.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.ia&&this.Te.capture_unhandled_errors&&(this.ia=n(this.captureException.bind(this))),!this.na&&this.Te.capture_unhandled_rejections&&(this.na=r(this.captureException.bind(this))),!this.sa&&this.Te.capture_console_errors&&(this.sa=i(this.captureException.bind(this)))}catch(e){Us.error(`failed to start`,e),this.oa()}}},this._instance=t,this.aa=!((n=this._instance.persistence)==null||!n.props[In]),this.la=new we(g({},function(e){return e===void 0&&(e={}),{refillRate:e.exceptionRateLimiterRefillRate??e.__exceptionRateLimiterRefillRate??1,bucketSize:e.exceptionRateLimiterBucketSize??e.__exceptionRateLimiterBucketSize??10}}(this._instance.config.error_tracking),{refillInterval:1e4,it:Us})),this.Te=this.ua(),this.startIfEnabledOrStop()}ua(){var e=this._instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return F(e)?t=g({},t,e):(I(e)?this.aa:e)&&(t=g({},t,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.Te.capture_console_errors||this.Te.capture_unhandled_errors||this.Te.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Us.info(`enabled`),this.oa(),this.tr(this.ea)):this.oa()}tr(e){var t,n;(t=f.__PosthogExtensions__)!=null&&t.errorWrappingFunctions?e():(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`exception-autocapture`,(t=>{if(t)return Us.error(`failed to load script`,t);
1e()}))}oa(){var e,t,n;(e=this.ia)==null||e.call(this),this.ia=void 0,(t=this.na)==null||t.call(this),this.na=void 0,(n=this.sa)==null||n.call(this),this.sa=void 0}onRemoteConfig(e){if(e.ok){var t=e.config;`autocaptureExceptions`in t&&(this.aa=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[In]:this.aa}),this.Te=this.ua(),this.startIfEnabledOrStop())}}onConfigChange(){this.Te=this.ua()}captureException(e){var t,n,r=(e==null||(t=e.$exception_list)==null||(t=t[0])==null?void 0:t.type)??`Exception`;this.la.consumeRateLimit(r)?Us.info(`Skipping exception capture because of client rate limiting.`,{exception:r}):(n=this._instance.exceptions)==null||n.sendExceptionEvent(e)}},exceptions:class{constructor(e){this.ha=[],this.da=new Yt([new cn,new vn,new un,new ln,new gn,new hn,new fn,new _n],function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;t>r;r++)n[r-1]=arguments[r];return function(t,r){r===void 0&&(r=0);for(var i=[],a=t.split(` 2`),o=r;a.length>o;o++){var s=a[o];if(1024>=s.length){var c=sn.test(s)?s.replace(sn,`$1`):s;if(!c.match(/\S*Error: /)){for(var l of n){var u=l(c,e);if(u){i.push(u);break}}if(i.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 g({},e,{filename:e.filename||(n=t,n[n.length-1]||{}).filename,function:e.function||Xt});var n}))}(i)}}(`web:javascript`,nn,on)),this._instance=e,this.ha=this._instance.persistence?.get_property(Ln)??[],this.ca=Cn(this.va()),this.fa=new wn(this.ca)}onConfigChange(){this.ca=Cn(this.va()),this.fa.setConfig(this.ca)}onRemoteConfig(e){if(e.ok){var t=e.config;if(`errorTracking`in t){var n=t.errorTracking?.suppressionRules??[],r=t.errorTracking?.captureExtensionExceptions;this.ha=n,this._instance.persistence&&this._instance.persistence.register({[Ln]:this.ha,[Rn]:r})}}}get pa(){var e,t=!!this._instance.get_property(Rn);return(e=this._instance.config.error_tracking.captureExtensionExceptions??t)!=null&&e}buildProperties(e,t){return this.da.buildFromUnknown(e,{syntheticException:t?.syntheticException,mechanism:{handled:t?.handled}})}addExceptionStep(e,t){if(this.ca.enabled)try{if(!L(e)||e.trim().length===0)return void bc.warn(`Ignoring exception step because message must be a non-empty string`);var n=function(e){if(!e)return{sanitizedProperties:{},droppedKeys:[]};var t=[];return{sanitizedProperties:Object.keys(e).reduce(((n,r)=>xn.has(r)?(t.push(r),n):(n[r]=e[r],n)),{}),droppedKeys:t}}(this.ga(t)),r=n.sanitizedProperties,i=n.droppedKeys;i.length>0&&bc.warn(`Ignoring reserved exception step fields`,{droppedKeys:i}),this.fa.add(g({[yn]:e,[bn]:new Date().toISOString()},r))}catch(e){bc.error(`Failed to add exception step. Ignoring breadcrumb.`,e)}}sendExceptionEvent(e){try{var t=e.$exception_list;if(this.ma(t)){if(this.ya(t))return this.ba(`Exception dropped: matched a suppression rule`),void bc.info(`Skipping exception capture because a suppression rule matched`);if(!this.pa&&this._a(t))return this.ba(`Exception dropped: thrown by a browser extension`),void bc.info(`Skipping exception capture because it was thrown by an extension`);if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.wa(t))return this.ba(`Exception dropped: thrown by the PostHog SDK`),void bc.info(`Skipping exception capture because it was thrown by the PostHog SDK`)}var n=this.ca.enabled&&z(e.$exception_steps)?this.xa(e):e,r=typeof(a=globalThis._posthogReleaseId)==`string`&&a.length>0?a:void 0;r&&(n.$release_id=r);try{var i=this._instance.capture(`$exception`,n,{_noTruncate:!0,_batchKey:`exceptionEvent`,Pn:!0});return i&&this.fa.clear(),i}catch(e){bc.error(`Failed to capture exception event. Dropping this exception.`,e),this.fa.clear();return}}catch(e){bc.error(`Failed to process exception event. Ignoring this exception.`,e);return}var a}xa(e){try{var t=this.fa.getAttachable();return t.length===0?e:g({},e,{$exception_steps:t})}catch(t){return bc.error(`Failed to read buffered exception steps. Capturing exception without steps.`,t),e}}ba(e){this.ca.enabled&&this.fa.add({[yn]:e,[bn]:new Date().toISOString()})}ga(e){return F(e)?g({},e):{}}va(){return this._instance.config.error_tracking?.exception_steps??{}}ya(e){if(e.length===0)return!1;try{var t=e.reduce(((e,t)=>{var n=t.type,r=t.value;return L(n)&&n.length>0&&e.$exception_types.push(n),L(r)&&r.length>0&&e.$exception_values.push(r),e}),{$exception_types:[],$exception_values:[]});return this.ha.some((e=>{var n=e.values.map((e=>{var n=rs[e.operator],r=t[e.key];if(!n||!r)return!1;var i=N(e.value)?e.value:[e.value];return i.length>0&&n(i,r)}));return e.type===`OR`?n.some(Boolean):n.every(Boolean)}))}catch(e){return bc.warn(`Failed to evaluate suppression rules. Capturing the exception.`,e),!1}}_a(e){return e.flatMap((e=>e.stacktrace?.frames??[])).some((e=>e.filename&&e.filename.startsWith(`chrome-extension://`)))}wa(e){if(e.length>0){var t,n,r=e[0].stacktrace?.frames??[],i=r[r.length-1];return(t=i==null||(n=i.filename)==null?void 0:n.includes(`posthog.com/static`))!=null&&t}return!1}ma(e){return!z(e)&&N(e)}}},jc=g({productTours:class{get mi(){return this._instance.persistence}constructor(e){this.ka=null,this.Sa=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config;if(`productTours`in t){var n;if(this.mi&&this.mi.register({[Vn]:!!t.productTours}),!rc(this._instance))return!this.ka&&z(this.mi?.props[fr])||nc.info(`product tours disabled; stopping and clearing cached tours`),(n=this.ka)==null||n.stop(),this.ka=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.ka&&rc(this._instance)&&this.tr((()=>this.Ca()))}tr(e){var t,n;(t=f.__PosthogExtensions__)!=null&&t.generateProductTours?e():(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`product-tours`,(t=>{t?nc.error(`Could not load product tours script`,t):e()}))}Ca(){var e;!this.ka&&(e=f.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.ka=f.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,t){if(t===void 0&&(t=!1),!N(this.Sa)||t){var n=this.mi;if(n){var r=n.props[fr];if(N(r)&&!t)return this.Sa=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`,timestampMode:`query`,callback:t=>{if(rc(this._instance)){var r=t.statusCode;if(r!==200||!t.json){var i=`Product Tours API could not be loaded, status: `+r;nc.error(i),e([],{isLoaded:!1,error:i});return}var a=N(t.json.product_tours)?t.json.product_tours:[];this.Sa=a,n&&n.register({[fr]:a}),e(a,{isLoaded:!0})}else e([],{isLoaded:!0})}})}else e(this.Sa,{isLoaded:!0})}getActiveProductTours(e){z(this.ka)?e([],{isLoaded:!1,error:`Product tours not loaded`}):this.ka.getActiveProductTours(e)}showProductTour(e){var t;(t=this.ka)==null||t.showTourById(e)}previewTour(e){this.ka?this.ka.previewTour(e):this.tr((()=>{var t;this.Ca(),(t=this.ka)==null||t.previewTour(e)}))}dismissProductTour(){var e;(e=this.ka)==null||e.dismissTour(`user_clicked_skip`)}nextStep(){var e;(e=this.ka)==null||e.nextStep()}previousStep(){var e;(e=this.ka)==null||e.previousStep()}clearCache(){var e;this.Sa=null,(e=this.mi)==null||e.unregister(fr)}resetTour(e){var t;(t=this.ka)==null||t.resetTour(e)}resetAllTours(){var e;(e=this.ka)==null||e.resetAllTours()}cancelPendingTour(e){var t;(t=this.ka)==null||t.cancelPendingTour(e)}}},Dc),Mc={siteApps:class{constructor(e){this.Ma=0,this._instance=e,this.Ia=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Ta(e,t){if(t){var n=this.globalsForEvent(t);this.Ia.push(n),this.Ia.length>1e3&&(this.Ia=this.Ia.slice(10))}}get siteAppLoaders(){var e;return(e=f._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}initialize(){if(this.isEnabled){var e=this._instance._addCaptureHook(this.Ta.bind(this));this.Ea=()=>{e(),this.Ia=[],this.Ea=void 0}}}globalsForEvent(e){if(!e)throw Error(`Event payload is required`);var t={},n=this._instance.get_property(`$groups`)||[],r=this._instance.get_property(`$stored_group_properties`)||{};for(var i of Object.entries(r)){var a=i[0];t[a]={id:n[a],type:a,properties:i[1]}}var o=e.$set_once,s=e.$set;return{event:g({},_(e,ic),{properties:g({},e.properties,s?{$set:g({},e.properties?.$set??{},s)}:{},o?{$set_once:g({},e.properties?.$set_once??{},o)}:{}),elements_chain:e.properties?.$elements_chain??``,distinct_id:e.properties?.distinct_id}),person:{properties:this._instance.get_property(`$stored_person_properties`)},groups:t}}Ra(e){var t=e.tagName?.toLowerCase();
2return t===`style`&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(e)||(ac.error(`prepare_external_dependency_stylesheet returned null`),null):t===`script`&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(e)||(ac.error(`prepare_external_dependency_script returned null`),null):e}Pa(){var e;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var t=r?.defaultView,n=t==null||(e=t.Node)==null?void 0:e.prototype;if(!t||!n)return()=>{};if(this.Ma++,this.Oa)return this.Fa();var i=[],a=this,o=new WeakSet,s=(e,t,n)=>{if(e!=null&&e[t]){var r=e[t];e[t]=n(r),i.push((()=>{e[t]=r}))}},c=e=>{if(o.has(e))return e;var t=a.Ra(e);return t&&o.add(t),t},l=e=>e.map((e=>typeof e==`string`?e:c(e))).filter((e=>!R(e)));return s(n,`appendChild`,(e=>function(t){var n=c(t);return n?e.call(this,n):t})),s(n,`insertBefore`,(e=>function(t,n){var r=c(t);return r?e.call(this,r,n):t})),s(n,`replaceChild`,(e=>function(t,n){var r=c(t);return r?e.call(this,r,n):n})),[t.Element?.prototype,t.Document?.prototype,t.DocumentFragment?.prototype].forEach((e=>{s(e,`append`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,l(n))})),s(e,`prepend`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,l(n))}))})),[t.Element?.prototype,t.CharacterData?.prototype,t.DocumentType?.prototype].forEach((e=>{s(e,`before`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,l(n))})),s(e,`after`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];return e.apply(this,l(n))})),s(e,`replaceWith`,(e=>function(){for(var t=arguments.length,n=Array(t),r=0;t>r;r++)n[r]=arguments[r];var i=l(n);return n.length&&!i.length?void 0:e.apply(this,i)}))})),s(t.Element?.prototype,`insertAdjacentElement`,(e=>function(t,n){var r=c(n);return r?e.call(this,t,r):null})),this.Oa=()=>{i.forEach((e=>e())),this.Oa=void 0},this.Fa()}Fa(){var e=!1;return()=>{var t;e||(e=!0,this.Ma--,this.Ma===0&&((t=this.Oa)==null||t.call(this)))}}Aa(e,t){t===void 0&&(t=!0);var n=this.Pa();try{var r=e(n);return t&&n(),r}catch(e){throw n(),e}}setupSiteApp(e){var t=this.apps[e.id],n=()=>{var n;!t.errored&&this.Ia.length&&(ac.info(`Processing `+this.Ia.length+` events for site app with id `+e.id),this.Ia.forEach((e=>this.Aa((()=>t.processEvent==null?void 0:t.processEvent(e))))),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored))&&((n=this.Ea)==null||n.call(this))},r=!1,i=i=>{t.errored=!i,t.loaded=!0,ac.info(`Site app with id `+e.id+` `+(i?`loaded`:`errored`)),r&&n()};try{var a=this.Aa((t=>e.init({posthog:this._instance,callback(e){t(),i(e)}})),!1).processEvent;a&&(t.processEvent=a),r=!0}catch(t){ac.error(oc+e.id,t),i(!1)}if(r&&t.loaded)try{n()}catch(n){ac.error(`Error while processing buffered events PostHog app with config id `+e.id,n),t.errored=!0}}$a(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var n of e)this.setupSiteApp(n)}La(e){var t=this;if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e),r=function(r){try{t.Aa((()=>r.processEvent==null?void 0:r.processEvent(n)))}catch(t){ac.error(`Error while processing event `+e.event+` for site app `+r.id,t)}};for(var i of Object.values(this.apps))r(i)}}onRemoteConfig(e){var t,n,r,i=this;if((t=this.siteAppLoaders)!=null&&t.length)return this.isEnabled?(this.$a(),void this._instance.on(`eventCaptured`,(e=>this.La(e)))):void ac.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`);if((n=this.Ea)==null||n.call(this),e.ok){var a=e.config;if((r=a.siteApps)!=null&&r.length)if(this.isEnabled){var o=function(){var e,t=s.id,n=s.url;f[`__$$ph_site_app_`+t]=i._instance,(e=f.__PosthogExtensions__)==null||e.loadSiteApp==null||e.loadSiteApp(i._instance,n,(e=>{if(e)return ac.error(oc+t,e)}))};for(var s of a.siteApps)o()}else ac.error(`PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.`)}}}},Nc={tracingHeaders:class{constructor(e){this.Da=void 0,this.Na=void 0,this.qa=void 0,this.ea=()=>{var e,t,n=this.ja();n?(I(this.Da)&&(this.Da=(e=f.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null?void 0:e._patchXHR(n,(()=>this._instance.get_distinct_id()),this._instance.sessionManager)),I(this.Na)&&(this.Na=(t=f.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null?void 0:t._patchFetch(n,(()=>this._instance.get_distinct_id()),this._instance.sessionManager))):this.oa()},this._instance=e}initialize(){this.startIfEnabledOrStop()}tr(e){var t,n;(t=f.__PosthogExtensions__)!=null&&t.tracingHeadersPatchFns?e():(n=f.__PosthogExtensions__)==null||n.loadExternalDependency==null||n.loadExternalDependency(this._instance,`tracing-headers`,(t=>{if(t)return Gs.error(`failed to load script`,t);
2e()}))}Ba(){return this._instance.config.tracing_headers??this._instance.config.addTracingHeaders??this._instance.config.__add_tracing_headers}ja(){var e=this.Ba();return N(e)?(N(this.qa)?this.qa.splice(0,this.qa.length,...e):this.qa=[...e],e.length>0?this.qa:void 0):(N(this.qa)&&this.qa.splice(0),this.qa=e||void 0,this.qa)}oa(){var e,t;(e=this.Da)==null||e.call(this),(t=this.Na)==null||t.call(this),this.Da=void 0,this.Na=void 0}startIfEnabledOrStop(){this.ja()?this.tr(this.ea):this.oa()}}},Pc=g({surveys:class{get Te(){return this._instance.config}constructor(e){this.Ha=void 0,this._surveyManager=null,this.Ua=!1,this.za=[],this.Va=null,this.Wa=null,this._instance=e,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this.Te.disable_surveys){if(!e.ok)return Q.warn(`Remote config unavailable. Not loading surveys.`);var t=e.config.surveys;if(z(t))return Q.warn(`Flags not loaded yet. Not loading surveys.`);var n=N(t);this.Ha=n?t.length>0:t,Q.info(`flags response received, isSurveysEnabled: `+this.Ha),this.loadIfEnabled()}}reset(){try{var e;(e=this._surveyEventReceiver)==null||e.reset(),localStorage.removeItem(`lastSeenSurveyDate`);for(var t=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(ds)||r!=null&&r.startsWith(`inProgressSurvey_`))&&t.push(r)}t.forEach((e=>localStorage.removeItem(e)))}catch{}}loadIfEnabled(){if(!this._surveyManager)if(this.Ua)Q.info(`Already initializing surveys, skipping...`);else if(this.Te.disable_surveys)Q.info(fc);else if(this.Te.cookieless_mode&&this._instance.consent.isOptedOut())Q.info(`Not loading surveys in cookieless mode without consent.`);else{var e=f?.__PosthogExtensions__;if(e){if(!I(this.Ha)||this.Te.advanced_enable_surveys){var t=this.Ha||this.Te.advanced_enable_surveys;this.Ua=!0;try{var n=e.generateSurveys;if(n)return void this.Za(n,t);var r=e.loadExternalDependency;if(!r)return void this.Ga(kr);r(this._instance,`surveys`,(n=>{n||!e.generateSurveys?this.Ga(`Could not load surveys script`,n):this.Za(e.generateSurveys,t)}))}catch(e){throw this.Ga(`Error initializing surveys`,e),e}finally{this.Ua=!1}}}else Q.error(`PostHog Extensions not found.`)}}Za(e,t){this._surveyManager=e(this._instance,t),this._surveyEventReceiver=new uc(this._instance),Q.info(`Surveys loaded successfully`),this.Qa({isLoaded:!0})}Ga(e,t){Q.error(e,t),this.Qa({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.za.push(e),this._surveyManager&&this.Qa({isLoaded:!0}),()=>{this.za=this.za.filter((t=>t!==e))}}getSurveys(e,t){if(t===void 0&&(t=!1),this.Te.disable_surveys)return Q.info(fc),e([]);var n,r=this._instance.get_property(cr);if(r&&!t)return e(r,{isLoaded:!0}),void(this.Ja()&&this.getSurveys((()=>{}),!0));typeof Promise<`u`&&this.Va?this.Va.then((t=>e(t.surveys,t.context))):(typeof Promise<`u`&&(this.Va=new Promise((e=>{n=e}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor(`api`,`/api/surveys/?token=`+this.Te.token),method:`GET`,timestampMode:`query`,timeout:this.Te.surveys_request_timeout_ms,callback:t=>{var r;this.Va=null;var i=t.statusCode;if(i!==200||!t.json){var a=`Surveys API could not be loaded, status: `+i;Q.error(a),this.Wa=Date.now();var o={isLoaded:!1,error:a};e([],o),n?.({surveys:[],context:o});return}this.Wa=null;var s,c=t.json.surveys||[],l=c.filter((e=>function(e){return!(!e.start_date||e.end_date)}(e)&&(us(e)||function(e){var t;return!((t=e.conditions)==null||(t=t.actions)==null||(t=t.values)==null||!t.length)}(e))));l.length>0&&((s=this._surveyEventReceiver)==null||s.register(l)),(r=this._instance.persistence)==null||r.register({[cr]:c,[lr]:Date.now()});var u={isLoaded:!0};e(c,u),n?.({surveys:c,context:u})}}))}Ja(){return this.Ka()&&!this.Va&&!this.Ya()}Ka(){var e=this._instance.get_property(lr);return B(e)&&Date.now()-e>3e5}Ya(){return B(this.Wa)&&3e5>Date.now()-this.Wa}markSurveyAsSeen(e,t){fs({id:e,current_iteration:t?.iteration??null});try{localStorage.setItem(`lastSeenSurveyDate`,new Date().toISOString())}catch{}}Qa(e){for(var t of this.za)try{if(!e.isLoaded)return t([],e);this.getSurveys(t)}catch(e){Q.error(`Error in survey callback`,e)}}getActiveMatchingSurveys(e,t){if(t===void 0&&(t=!1),!z(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,t);Q.warn(`init was not called`)}Xa(e){var t=null;
2return this.getSurveys((n=>{t=n.find((t=>t.id===e))??null})),t}tl(e){if(z(this._surveyManager))return{eligible:!1,reason:dc};var t=typeof e==`string`?this.Xa(e):e;return t?this._surveyManager.checkSurveyEligibility(t):{eligible:!1,reason:`Survey not found`}}el(e){if(z(this._surveyManager))return{eligible:!1,reason:dc};var t=typeof e==`string`?this.Xa(e):e;return t?this._surveyManager.checkSurveyRenderability(t):{eligible:!1,reason:`Survey not found`}}canRenderSurvey(e){if(z(this._surveyManager))return Q.warn(`init was not called`),{visible:!1,disabledReason:dc};var t=this.el(e);return{visible:t.eligible,disabledReason:t.reason}}canRenderSurveyAsync(e,t){return z(this._surveyManager)?(Q.warn(`init was not called`),Promise.resolve({visible:!1,disabledReason:dc})):new Promise((n=>{this.getSurveys((t=>{var r=t.find((t=>t.id===e))??null;if(r){var i=this.el(r);n({visible:i.eligible,disabledReason:i.reason})}else n({visible:!1,disabledReason:`Survey not found`})}),t)}))}renderSurvey(e,t,n){var i;if(z(this._surveyManager))Q.warn(`init was not called`);else{var a=typeof e==`string`?this.Xa(e):e;if(a!=null&&a.id)if(ps.includes(a.type)){var o=r?.querySelector(t);if(o)return(i=a.appearance)!=null&&i.surveyPopupDelaySeconds?(Q.info(`Rendering survey `+a.id+` with delay of `+a.appearance.surveyPopupDelaySeconds+` seconds`),void setTimeout((()=>{var e;Q.info(`Rendering survey `+a.id+` with delay of `+a.appearance?.surveyPopupDelaySeconds+` seconds`),(e=this._surveyManager)==null||e.renderSurvey(a,o,n),Q.info(`Survey `+a.id+` rendered`)}),1e3*a.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(a,o,n);Q.warn(`Survey element not found`)}else Q.warn(`Surveys of type `+a.type+` cannot be rendered in the app`);else Q.warn(`Survey not found`)}}displaySurvey(e,t){var n;if(z(this._surveyManager))Q.warn(`init was not called`);else{var r=this.Xa(e);if(r){var i=r;if((n=r.appearance)!=null&&n.surveyPopupDelaySeconds&&t.ignoreDelay&&(i=g({},r,{appearance:g({},r.appearance,{surveyPopupDelaySeconds:0})})),t.displayType!==Ga.Popover&&t.initialResponses&&Q.warn(`initialResponses is only supported for popover surveys. prefill will not be applied.`),!1===t.ignoreConditions){var a=this.tl(r);if(!a.eligible)return void Q.warn(`Survey is not eligible to be displayed: `,a.reason)}t.displayType===Ga.Inline?this.renderSurvey(i,t.selector,t.properties):this._surveyManager.handlePopoverSurvey(i,t)}else Q.warn(`Survey not found`)}}cancelPendingSurvey(e){z(this._surveyManager)?Q.warn(`init was not called`):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload==null||e.handlePageUnload()}}},Dc),Fc={toolbar:class{constructor(e){this.instance=e}rl(e){f.ph_toolbar_state=e}il(){return f.ph_toolbar_state??0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,n,i){if(t===void 0&&(t=void 0),n===void 0&&(n=void 0),i===void 0&&(i=void 0),Jr(this.instance.config)||!e||!r)return!1;t??=e.location,i??=e.history;try{if(!n){try{e.localStorage.setItem(`test`,`test`),e.localStorage.removeItem(`test`)}catch{return!1}n=e?.localStorage}var a,o=pc||va(t.hash,`__posthog`)||va(t.hash,`state`),s=o?Ur((()=>JSON.parse(atob(decodeURIComponent(o)))))||Ur((()=>JSON.parse(decodeURIComponent(o)))):null;return s&&s.action===`ph_authorize`?((a=s).source=`url`,a&&Object.keys(a).length>0&&(s.desiredHash?t.hash=s.desiredHash:i?i.replaceState(i.state,``,t.pathname+t.search):t.hash=``)):((a=JSON.parse(n.getItem(mc)||`{}`)).source=`localstorage`,delete a.userIntent),!(!a.token||this.instance.config.token!==a.token||(this.loadToolbar(a),0))}catch{return!1}}nl(e){var t=f.ph_load_toolbar||f.ph_load_editor;!z(t)&&P(t)?t(e,this.instance):hc.warn(`No toolbar load function found`)}loadToolbar(t){var n=!(r==null||!r.getElementById(pi));if(!e||n)return!1;var i=this.instance.requestRouter.region===`custom`&&this.instance.config.advanced_disable_toolbar_metrics,a=g({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor(`ui`)},i?{instrument:!1}:{});if(e.localStorage.setItem(mc,JSON.stringify(g({},a,{source:void 0}))),this.il()===2)this.nl(a);else if(this.il()===0){var o;this.rl(1),(o=f.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this.instance,`toolbar`,(e=>{if(e)return hc.error(`[Toolbar] Failed to load`,e),void this.rl(0);this.rl(2),this.nl(a)})),K(e,`turbolinks:load`,(()=>{this.rl(0),this.loadToolbar(a)}
2))}return!0}sl(e){return this.loadToolbar(e)}maybeLoadEditor(e,t,n){return e===void 0&&(e=void 0),t===void 0&&(t=void 0),n===void 0&&(n=void 0),this.maybeLoadToolbar(e,t,n)}}},Ic=g({experiments:Cc},Dc),Lc=g({},Dc,Oc,kc,Ac,jc,Mc,Pc,Nc,Fc,Ic,{conversations:class{constructor(e){this.ol=void 0,this._conversationsManager=null,this.al=!1,this.ll=null,this._instance=e}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(!this._instance.config.disable_conversations&&e.ok){var t=e.config.conversations;z(t)||(pe(t)?this.ol=t:(this.ol=t.enabled,this.ll=t),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.ol=void 0,this.ll=null}loadIfEnabled(){if(!(this._conversationsManager||this.al||this._instance.config.disable_conversations||Jr(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=f?.__PosthogExtensions__;if(e&&!I(this.ol)&&this.ol)if(this.ll&&this.ll.token){this.al=!0;try{var t=e.initConversations;if(t)return this.ul(t),void(this.al=!1);var n=e.loadExternalDependency;if(!n)return void this.hl(kr);n(this._instance,`conversations`,(t=>{t||!e.initConversations?this.hl(`Could not load conversations script`,t):this.ul(e.initConversations),this.al=!1}))}catch(e){this.hl(`Error initializing conversations`,e),this.al=!1}}else wc.error(`Conversations enabled but missing token in remote config.`)}}ul(e){if(this.ll)try{this._conversationsManager=e(this.ll,this._instance),wc.info(`Conversations loaded successfully`)}catch(e){this.hl(`Error completing conversations initialization`,e)}else wc.error(`Cannot complete initialization: remote config is null`)}hl(e,t){wc.error(e,t),this._conversationsManager=null,this.al=!1}show(){this._conversationsManager?this._conversationsManager.show():wc.warn(`Conversations not loaded yet.`)}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return!0===this.ol&&!R(this._conversationsManager)}isVisible(){var e;return(e=this._conversationsManager?.isVisible())!=null&&e}sendMessage(e,t,n){var r=this;return h((function*(){return r._conversationsManager?r._conversationsManager.sendMessage(e,t,n):(wc.warn(Tc),null)}))()}getMessages(e,t){var n=this;return h((function*(){return n._conversationsManager?n._conversationsManager.getMessages(e,t):(wc.warn(Tc),null)}))()}markAsRead(e){var t=this;return h((function*(){return t._conversationsManager?t._conversationsManager.markAsRead(e):(wc.warn(Tc),null)}))()}getTickets(e){var t=this;return h((function*(){return t._conversationsManager?t._conversationsManager.getTickets(e):(wc.warn(Tc),null)}))()}requestRestoreLink(e){var t=this;return h((function*(){return t._conversationsManager?t._conversationsManager.requestRestoreLink(e):(wc.warn(Tc),null)}))()}restoreFromToken(e){var t=this;return h((function*(){return t._conversationsManager?t._conversationsManager.restoreFromToken(e):(wc.warn(Tc),null)}))()}restoreFromUrlToken(){var e=this;return h((function*(){return e._conversationsManager?e._conversationsManager.restoreFromUrlToken():(wc.warn(Tc),null)}))()}getCurrentTicketId(){return this._conversationsManager?.getCurrentTicketId()??null}getWidgetSessionId(){return this._conversationsManager?.getWidgetSessionId()??null}Nn(){var e;(e=this._conversationsManager)==null||e.setIdentity()}qn(){var e;(e=this._conversationsManager)==null||e.clearIdentity()}}},{logs:class{constructor(t){var n;this.dl=!1,this.cl=!1,this.it=U(`[logs]`),this.Gr=[],this.vl=[],this.Js=0,this.fl=()=>{var e,t;this.Js=0,(e=this.pl)==null||e.onReconnect(),(t=this.gl)==null||t.onReconnect()},this._instance=t,this._instance&&(n=this._instance.config.logs)!=null&&n.captureConsoleLogs&&(this.dl=!0),e&&K(e,`online`,this.fl)}ml(e,t,n,r){var i,a=function(e,t){var n=e?.flushIntervalMs??3e3,r=e?.maxBufferSize??100,i=t!=null&&t.consoleCapture?void 0:e?.maxLogsPerInterval??1e3,a=I(i)?Math.max(r,2048):Math.max(r,i),o=e?.resourceAttributes;return{serviceName:o?.[`service.name`]??e?.serviceName??t?.serviceNameDefault,serviceVersion:o?.[`service.version`]??e?.serviceVersion,environment:o?.[`deployment.environment`]??e?.environment,resourceAttributes:o,beforeSend:e?.beforeSend,flushIntervalMs:n,maxBufferSize:r,maxQueueSize:a,maxBatchRecordsPerPost:100,rateCapWindowMs:n,maxLogsPerInterval:i,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}((i=this._instance)==null||(i=i.config)==null?void 0:i.logs,n);return[new Bt(this.yl(e,t),a,this.it,(()=>this.bl()),(e=>e()),void 0,r),a]}_l(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.pl||this.wl!==t){var n;(n=this.pl)==null||n.reset(),this.wl=t;var r=this.ml((()=>this.Gr),(e=>{this.Gr=e}));this.pl=r[0],this.xl=r[1]}return this.pl}kl(){var e,t=(e=this._instance)==null||(e=e.config)==null?void 0:e.logs;if(!this.gl||this.Sl!==t){var n;(n=this.gl)==null||n.reset(),this.Sl=t;var r=this.ml((()=>this.vl),(e=>{this.vl=e}),{serviceNameDefault:`posthog-browser-logs`,consoleCapture:!0},Ec);this.gl=r[0],this.Cl=r[1]}return this.gl}initialize(){this.loadIfEnabled()}onRemoteConfig(e){if(e.ok){var t=e.config.logs?.captureConsoleLogs;!z(t)&&t&&(this.dl=!0,this.loadIfEnabled())}}reset(){var e,t;this.Gr=[],(e=this.pl)==null||e.reset(),this.vl=[],(t=this.gl)==null||t.reset(),this.Js=0}captureLog(e){this._l().captureLog(e)}le(e){this.kl().captureLog(e)}get logger(){return this.Ml||={trace:(e,t)=>this.captureLog({body:e,level:`trace`,attributes:t}),debug:(e,t)=>this.captureLog({body:e,level:`debug`,attributes:t}),info:(e,t)=>this.captureLog({body:e,level:`info`,attributes:t}),warn:(e,t)=>this.captureLog({body:e,level:`warn`,attributes:t}),error:(e,t)=>
2this.captureLog({body:e,level:`error`,attributes:t}),fatal:(e,t)=>this.captureLog({body:e,level:`fatal`,attributes:t})},this.Ml}flushLogs(e){e?this.Il(e):(this.pl&&this.pl.flush().catch((e=>this.it.error(`PostHog logs flush failed:`,e))),this.gl&&this.gl.flush().catch((e=>this.it.error(`PostHog logs flush failed:`,e))))}loadIfEnabled(){if(this.dl&&!this.cl){var e=f?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,`logs`,(t=>{var n;t||(n=e.logs)==null||!n.initializeLogs?this.it.error(`Could not load logs script`,t):(e.logs.initializeLogs(this._instance),this.cl=!0)})):this.it.error(kr)}else this.it.error(`PostHog Extensions not found.`)}}yl(e,t){var n=this._instance;return{get isDisabled(){return!1},get optedOut(){return!n.is_capturing()},getPersistedProperty:t=>t===C.LogsQueue?e():void 0,setPersistedProperty(e,n){e===C.LogsQueue&&t(n??[])},$t:e=>this.$t(e),getLibraryId:()=>p.LIB_NAME,getLibraryVersion:()=>p.LIB_VERSION}}$t(e){return new Promise((t=>{if(ya(this.Js,3))t({kind:`fatal`,error:Error(`logs endpoint is unreachable, dropping batch`)});else{var n=!1,r=e=>{n||(n=!0,clearTimeout(i),t(e))},i=setTimeout((()=>r({kind:`retry-later`,error:Error(`logs request timed out`)})),9e4);this._instance._send_request({method:`POST`,url:this.Tl(),data:e,compression:`best-available`,batchKey:`logs`,fireCallbackOnDrop:!0,callback:e=>{var t=e.statusCode;this.El(t),r(t>=200&&300>t?{kind:`ok`}:t===413?{kind:`too-large`}:t!==0&&t!==429&&500>t?{kind:`fatal`,error:Error(`logs request failed with status `+t)}:{kind:`retry-later`,error:e.error??Error(`logs request failed with status `+t)})}})}}))}El(e){(e!==0||this._instance.__loaded)&&(this.Js=ba(e,this.Js,3,(()=>this.it.warn(`Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.`))))}Il(e){this.Gr.length>0&&this.Rl(e,this.Gr,this.xl,p.LIB_NAME,(e=>{this.Gr=e})),this.vl.length>0&&this.Rl(e,this.vl,this.Cl,Ec,(e=>{this.vl=e}))}Rl(e,t,n,r,i){if(t.length!==0){var a=t.map((e=>e.record));i([]);var o=zt(a,Rt(n,p.LIB_NAME,p.LIB_VERSION),r,p.LIB_VERSION);this._instance._send_request({method:`POST`,url:this.Tl(),data:o,compression:`best-available`,batchKey:`logs`,transport:e})}}Tl(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/logs`)+`?token=`+encodeURIComponent(this._instance.config.token)}bl(){var e,t={};if(t.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var n=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),r=n.windowId,i=n.sessionStartTimestamp,a=n.lastActivityTimestamp;t.sessionId=n.sessionId,t.windowId=r,z(i)||(t.sessionStartTimestamp=i),z(a)||(t.lastActivityTimestamp=a)}if(f!=null&&(e=f.location)!=null&&e.href&&(t.currentUrl=this._instance.config.disable_capture_url_hashes?At(f.location.href):f.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(t.activeFeatureFlags=o)}return t}}},{metrics:class{constructor(e){this.it=U(`[metrics]`),this._instance=e}initialize(){}_l(){var e,t,n=(e=this._instance)==null||(e=e.config)==null?void 0:e.metrics;return this.pl&&this.wl===n||((t=this.pl)==null||t.reset(),this.wl=n,this.pl=new Wt(this.yl(),function(e){var t=e?.resourceAttributes;return{serviceName:t?.[`service.name`]??e?.serviceName,serviceVersion:t?.[`service.version`]??e?.serviceVersion,environment:t?.[`deployment.environment`]??e?.environment,resourceAttributes:t,beforeSend:e?.beforeSend,flushIntervalMs:e?.flushIntervalMs??1e4,maxSeriesPerFlush:e?.maxSeriesPerFlush??1e3}}(n),this.it)),this.pl}count(e,t,n){t===void 0&&(t=1),this._l().count(e,t,n)}gauge(e,t,n){this._l().gauge(e,t,n)}histogram(e,t,n){this._l().histogram(e,t,n)}flush(e){if(!this.pl)return Promise.resolve();if(e){var t=this.pl.drainWindow();return t&&this.Kt(t,e),Promise.resolve()}return this.pl.flush().catch((e=>this.it.error(`PostHog metrics flush failed:`,e)))}reset(){var e;(e=this.pl)==null||e.reset()}yl(){var e=this._instance,t=this;return{get isDisabled(){return!1},get optedOut(){return!e.is_capturing()},Kt:e=>t.Kt(e),getLibraryId:()=>
2p.LIB_NAME,getLibraryVersion:()=>p.LIB_VERSION}}Kt(e,t){return new Promise((n=>{var r=!1,i=e=>{r||(r=!0,clearTimeout(a),n(e))},a=setTimeout((()=>i({kind:`retry-later`,error:Error(`metrics request timed out`)})),9e4);this._instance._send_request(g({method:`POST`,url:this.Pl(),data:e,compression:`best-available`,batchKey:`metrics`},t&&{transport:t},{fireCallbackOnDrop:!0,callback(e){var t=e.statusCode;i(t>=200&&300>t?{kind:`ok`}:t===413?{kind:`too-large`}:t!==0&&t!==429&&500>t?{kind:`fatal`,error:Error(`metrics request failed with status `+t)}:{kind:`retry-later`,error:e.error??Error(`metrics request failed with status `+t)})}}))}))}Pl(){return this._instance.requestRouter.endpointFor(`api`,`/i/v1/metrics`)+`?token=`+encodeURIComponent(this._instance.config.token)}}});Is.__defaultExtensionClasses=g({},Lc);var Rc=function(){p.SDK_DIST_CHANNEL=`npm`;var t=Ss[As]=new Is;return function(){function t(){t.done||(t.done=!0,js=!1,W(Ss,(function(e){e._dom_loaded()})))}r!=null&&r.addEventListener?r.readyState===`complete`?t():K(r,`DOMContentLoaded`,t,{capture:!1}):e&&H.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),t}();export{Rc as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.