@budibase/server 3.2.34 → 3.2.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -495,7 +495,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
495
495
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function c(to,ue){if(to){if(typeof to=="string")return d$1(to,ue);var eo=Object.prototype.toString.call(to).slice(8,-1);return eo==="Object"&&to.constructor&&(eo=to.constructor.name),eo==="Map"||eo==="Set"?Array.from(to):eo==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(eo)?d$1(to,ue):void 0}}function d$1(to,ue){(ue==null||ue>to.length)&&(ue=to.length);for(var eo=0,no=new Array(ue);eo<ue;eo++)no[eo]=to[eo];return no}function h(to,ue){var eo=typeof Symbol<"u"&&to[Symbol.iterator]||to["@@iterator"];if(!eo){if(Array.isArray(to)||(eo=c(to))||ue&&to&&typeof to.length=="number"){eo&&(to=eo);var no=0,ro=function(){};return{s:ro,n:function(){return no>=to.length?{done:!0}:{done:!1,value:to[no++]}},e:function(so){throw so},f:ro}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
496
496
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var oo,io=!0,ao=!1;return{s:function(){eo=eo.call(to)},n:function(){var so=eo.next();return io=so.done,so},e:function(so){ao=!0,oo=so},f:function(){try{io||eo.return==null||eo.return()}finally{if(ao)throw oo}}}}var f={DEBUG:!1,LIB_VERSION:"1.160.0"},v=Array.isArray,p$1=Object.prototype,g=p$1.hasOwnProperty,_=p$1.toString,m=v||function(to){return _.call(to)==="[object Array]"},y=function(to){return typeof to=="function"},b=function(to){return to===Object(to)&&!m(to)},k=function(to){if(b(to)){for(var ue in to)if(g.call(to,ue))return!1;return!0}return!1},w$1=function(to){return to===void 0},S=function(to){return _.call(to)=="[object String]"},E=function(to){return S(to)&&to.trim().length===0},I=function(to){return to===null},R=function(to){return w$1(to)||I(to)},F=function(to){return _.call(to)=="[object Number]"},x$1=function(to){return _.call(to)==="[object Boolean]"},P=function(to){return to instanceof FormData},T=typeof window<"u"?window:void 0,C$1=typeof globalThis<"u"?globalThis:T,$=Array.prototype,O=$.forEach,M=$.indexOf,A=C$1==null?void 0:C$1.navigator,L=C$1==null?void 0:C$1.document,D=C$1==null?void 0:C$1.location,q=C$1==null?void 0:C$1.fetch,N=C$1!=null&&C$1.XMLHttpRequest&&"withCredentials"in new C$1.XMLHttpRequest?C$1.XMLHttpRequest:void 0,B=C$1==null?void 0:C$1.AbortController,H=A==null?void 0:A.userAgent,U=T??{},j="[PostHog.js]",G={_log:function(to){if(T&&(f.DEBUG||U.POSTHOG_DEBUG)&&!w$1(T.console)&&T.console){for(var ue=("__rrweb_original__"in T.console[to])?T.console[to].__rrweb_original__:T.console[to],eo=arguments.length,no=new Array(eo>1?eo-1:0),ro=1;ro<eo;ro++)no[ro-1]=arguments[ro];ue.apply(void 0,[j].concat(no))}},info:function(){for(var to=arguments.length,ue=new Array(to),eo=0;eo<to;eo++)ue[eo]=arguments[eo];G._log.apply(G,["log"].concat(ue))},warn:function(){for(var to=arguments.length,ue=new Array(to),eo=0;eo<to;eo++)ue[eo]=arguments[eo];G._log.apply(G,["warn"].concat(ue))},error:function(){for(var to=arguments.length,ue=new Array(to),eo=0;eo<to;eo++)ue[eo]=arguments[eo];G._log.apply(G,["error"].concat(ue))},critical:function(){for(var to,ue=arguments.length,eo=new Array(ue),no=0;no<ue;no++)eo[no]=arguments[no];(to=console).error.apply(to,[j].concat(eo))},uninitializedWarning:function(to){G.error("You must initialize PostHog before calling ".concat(to))}},W={},V=function(to){return to.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")};function z(to,ue,eo){if(m(to)){if(O&&to.forEach===O)to.forEach(ue,eo);else if("length"in to&&to.length===+to.length){for(var no=0,ro=to.length;no<ro;no++)if(no in to&&ue.call(eo,to[no],no)===W)return}}}function Q(to,ue,eo){if(!R(to)){if(m(to))return z(to,ue,eo);if(P(to)){var no,ro=h(to.entries());try{for(ro.s();!(no=ro.n()).done;){var oo=no.value;if(ue.call(eo,oo[1],oo[0])===W)return}}catch(ao){ro.e(ao)}finally{ro.f()}}else for(var io in to)if(g.call(to,io)&&ue.call(eo,to[io],io)===W)return}}var J=function(to){for(var ue=arguments.length,eo=new Array(ue>1?ue-1:0),no=1;no<ue;no++)eo[no-1]=arguments[no];return z(eo,function(ro){for(var oo in ro)ro[oo]!==void 0&&(to[oo]=ro[oo])}),to};function Y(to,ue){return to.indexOf(ue)!==-1}function X(to){for(var ue=Object.keys(to),eo=ue.length,no=new Array(eo);eo--;)no[eo]=[ue[eo],to[ue[eo]]];return no}var K=function(){return Date.now=Date.now||function(){return+new Date},Date.now()},Z=function(to){try{return to()}catch{return}},ee=function(to){return function(){try{for(var ue=arguments.length,eo=new Array(ue),no=0;no<ue;no++)eo[no]=arguments[no];return to.apply(this,eo)}catch(ro){G.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),G.critical(ro)}}},te=function(to){var ue={};return Q(to,function(eo,no){S(eo)&&eo.length>0&&(ue[no]=eo)}),ue},ne=function(to){return to.replace(/^\$/,"")};function ie$2(to,ue){return eo=to,no=function(oo){return S(oo)&&!I(ue)?oo.slice(0,ue):oo},ro=new Set,function oo(io,ao){return io!==Object(io)?no?no(io,ao):io:ro.has(io)?void 0:(ro.add(io),m(io)?(so=[],z(io,function(lo){so.push(oo(lo))})):(so={},Q(io,function(lo,co){ro.has(lo)||(so[co]=oo(lo,co))})),so);var so}(eo);var eo,no,ro}var re,se=function(to){var ue,eo,no,ro,oo="";for(ue=eo=0,no=(to=(to+"").replace(/\r\n/g,`
|
|
497
497
|
`).replace(/\r/g,`
|
|
498
|
-
`)).length,ro=0;ro<no;ro++){var io=to.charCodeAt(ro),ao=null;io<128?eo++:ao=io>127&&io<2048?String.fromCharCode(io>>6|192,63&io|128):String.fromCharCode(io>>12|224,io>>6&63|128,63&io|128),I(ao)||(eo>ue&&(oo+=to.substring(ue,eo)),oo+=ao,ue=eo=ro+1)}return eo>ue&&(oo+=to.substring(ue,to.length)),oo},oe=function(){function to(ue){return ue&&(ue.preventDefault=to.preventDefault,ue.stopPropagation=to.stopPropagation),ue}return to.preventDefault=function(){this.returnValue=!1},to.stopPropagation=function(){this.cancelBubble=!0},function(ue,eo,no,ro,oo){if(ue)if(ue.addEventListener&&!ro)ue.addEventListener(eo,no,!!oo);else{var io="on"+eo,ao=ue[io];ue[io]=function(so,lo,co){return function(uo){if(uo=uo||to(T==null?void 0:T.event)){var fo,po=!0;y(co)&&(fo=co(uo));var ho=lo.call(so,uo);return fo!==!1&&ho!==!1||(po=!1),po}}}(ue,no,ao)}else G.error("No valid element provided to register_event")}}();function ae(to,ue){for(var eo=0;eo<to.length;eo++)if(ue(to[eo]))return to[eo]}(function(to){to.GZipJS="gzip-js",to.Base64="base64"})(re||(re={}));var le="$people_distinct_id",ce="__alias",de="__timers",he="$autocapture_disabled_server_side",fe="$heatmaps_enabled_server_side",ve="$exception_capture_enabled_server_side",pe="$exception_capture_endpoint_suffix",ge="$web_vitals_enabled_server_side",_e="$session_recording_enabled_server_side",me="$console_log_recording_enabled_server_side",ye="$session_recording_network_payload_capture",be="$session_recording_canvas_recording",ke="$replay_sample_rate",we="$replay_minimum_duration",Se="$sesid",Ee="$session_is_sampled",Ie="$enabled_feature_flags",Re="$early_access_features",Fe="$stored_person_properties",xe="$stored_group_properties",Pe="$surveys",Te="$surveys_activated",Ce="$flag_call_reported",$e="$user_state",Oe="$client_session_props",Me="$capture_rate_limit",Ae="$initial_campaign_params",Le="$initial_referrer_info",De="$initial_person_info",qe="$epp",Ne="__POSTHOG_TOOLBAR__",Be=[le,ce,"__cmpns",de,_e,fe,Se,Ie,$e,Re,xe,Fe,Pe,Ce,Oe,Me,Ae,Le,qe],He="$active_feature_flags",Ue="$override_feature_flags",je="$feature_flag_payloads",Ge=function(to){var ue,eo={},no=h(X(to||{}));try{for(no.s();!(ue=no.n()).done;){var ro=u(ue.value,2),oo=ro[0],io=ro[1];io&&(eo[oo]=io)}}catch(ao){no.e(ao)}finally{no.f()}return eo},We=function(){function to(ue){i$1(this,to),this.instance=ue,this._override_warning=!1,this.featureFlagEventHandlers=[],this.reloadFeatureFlagsQueued=!1,this.reloadFeatureFlagsInAction=!1}return s(to,[{key:"getFlags",value:function(){return Object.keys(this.getFlagVariants())}},{key:"getFlagVariants",value:function(){var ue=this.instance.get_property(Ie),eo=this.instance.get_property(Ue);if(!eo)return ue||{};for(var no=J({},ue),ro=Object.keys(eo),oo=0;oo<ro.length;oo++)no[ro[oo]]=eo[ro[oo]];return this._override_warning||(G.warn(" Overriding feature flags!",{enabledFlags:ue,overriddenFlags:eo,finalFlags:no}),this._override_warning=!0),no}},{key:"getFlagPayloads",value:function(){return this.instance.get_property(je)||{}}},{key:"reloadFeatureFlags",value:function(){this.reloadFeatureFlagsQueued||(this.reloadFeatureFlagsQueued=!0,this._startReloadTimer())}},{key:"setAnonymousDistinctId",value:function(ue){this.$anon_distinct_id=ue}},{key:"setReloadingPaused",value:function(ue){this.reloadFeatureFlagsInAction=ue}},{key:"resetRequestQueue",value:function(){this.reloadFeatureFlagsQueued=!1}},{key:"_startReloadTimer",value:function(){var ue=this;this.reloadFeatureFlagsQueued&&!this.reloadFeatureFlagsInAction&&setTimeout(function(){!ue.reloadFeatureFlagsInAction&&ue.reloadFeatureFlagsQueued&&(ue.reloadFeatureFlagsQueued=!1,ue._reloadFeatureFlagsRequest())},5)}},{key:"_reloadFeatureFlagsRequest",value:function(){var ue=this;if(!this.instance.config.advanced_disable_feature_flags){this.setReloadingPaused(!0);var eo=this.instance.config.token,no=this.instance.get_property(Fe),ro=this.instance.get_property(xe),oo={token:eo,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:no,group_properties:ro,disable_flags:this.instance.config.advanced_disable_feature_flags||void 0};this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:oo,compression:this.instance.config.disable_compression?void 0:re.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:function(io){var ao;ue.setReloadingPaused(!1);var so=!0;io.statusCode===200&&(ue.$anon_distinct_id=void 0,so=!1),ue.receivedFeatureFlags((ao=io.json)!==null&&ao!==void 0?ao:{},so),ue._startReloadTimer()}})}}},{key:"getFeatureFlag",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0){var no,ro=this.getFlagVariants()[ue],oo="".concat(ro),io=this.instance.get_property(Ce)||{};return(eo.send_event||!("send_event"in eo))&&(!(ue in io)||!io[ue].includes(oo))&&(m(io[ue])?io[ue].push(oo):io[ue]=[oo],(no=this.instance.persistence)===null||no===void 0||no.register(o({},Ce,io)),this.instance.capture("$feature_flag_called",{$feature_flag:ue,$feature_flag_response:ro})),ro}G.warn('getFeatureFlag for key "'+ue+`" failed. Feature flags didn't load in time.`)}},{key:"getFeatureFlagPayload",value:function(ue){return this.getFlagPayloads()[ue]}},{key:"isFeatureEnabled",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(ue,eo);G.warn('isFeatureEnabled for key "'+ue+`" failed. Feature flags didn't load in time.`)}},{key:"addFeatureFlagsHandler",value:function(ue){this.featureFlagEventHandlers.push(ue)}},{key:"removeFeatureFlagsHandler",value:function(ue){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(function(eo){return eo!==ue})}},{key:"receivedFeatureFlags",value:function(ue,eo){if(this.instance.persistence){this.instance.decideEndpointWasHit=!0;var no=this.getFlagVariants(),ro=this.getFlagPayloads();(function(oo,io){var ao,so=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},lo=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},co=oo.featureFlags,uo=oo.featureFlagPayloads;if(co)if(m(co)){var fo,po={};if(co)for(var ho=0;ho<co.length;ho++)po[co[ho]]=!0;io&&io.register((o(fo={},He,co),o(fo,Ie,po),fo))}else{var _o=co,go=uo;oo.errorsWhileComputingFlags&&(_o=t$1(t$1({},so),_o),go=t$1(t$1({},lo),go)),io&&io.register((o(ao={},He,Object.keys(Ge(_o))),o(ao,Ie,_o||{}),o(ao,je,go||{}),ao))}})(ue,this.instance.persistence,no,ro),this._fireFeatureFlagsCallbacks(eo)}}},{key:"override",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.instance.__loaded||!this.instance.persistence)return G.uninitializedWarning("posthog.feature_flags.override");if(this._override_warning=eo,ue===!1)this.instance.persistence.unregister(Ue);else if(m(ue)){for(var no={},ro=0;ro<ue.length;ro++)no[ue[ro]]=!0;this.instance.persistence.register(o({},Ue,no))}else this.instance.persistence.register(o({},Ue,ue))}},{key:"onFeatureFlags",value:function(ue){var eo=this;if(this.addFeatureFlagsHandler(ue),this.instance.decideEndpointWasHit){var no=this._prepareFeatureFlagsForCallbacks(),ro=no.flags,oo=no.flagVariants;ue(ro,oo)}return function(){return eo.removeFeatureFlagsHandler(ue)}}},{key:"updateEarlyAccessFeatureEnrollment",value:function(ue,eo){var no,ro,oo=o({},"$feature_enrollment/".concat(ue),eo);this.instance.capture("$feature_enrollment_update",{$feature_flag:ue,$feature_enrollment:eo,$set:oo}),this.setPersonPropertiesForFlags(oo,!1);var io=t$1(t$1({},this.getFlagVariants()),{},o({},ue,eo));(no=this.instance.persistence)===null||no===void 0||no.register((o(ro={},He,Object.keys(Ge(io))),o(ro,Ie,io),ro)),this._fireFeatureFlagsCallbacks()}},{key:"getEarlyAccessFeatures",value:function(ue){var eo=this,no=arguments.length>1&&arguments[1]!==void 0&&arguments[1],ro=this.instance.get_property(Re);if(ro&&!no)return ue(ro);this.instance._send_request({transport:"XHR",url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token)),method:"GET",callback:function(oo){var io;if(oo.json){var ao=oo.json.earlyAccessFeatures;return(io=eo.instance.persistence)===null||io===void 0||io.register(o({},Re,ao)),ue(ao)}}})}},{key:"_prepareFeatureFlagsForCallbacks",value:function(){var ue=this.getFlags(),eo=this.getFlagVariants();return{flags:ue.filter(function(no){return eo[no]}),flagVariants:Object.keys(eo).filter(function(no){return eo[no]}).reduce(function(no,ro){return no[ro]=eo[ro],no},{})}}},{key:"_fireFeatureFlagsCallbacks",value:function(ue){var eo=this._prepareFeatureFlagsForCallbacks(),no=eo.flags,ro=eo.flagVariants;this.featureFlagEventHandlers.forEach(function(oo){return oo(no,ro,{errorsLoading:ue})})}},{key:"setPersonPropertiesForFlags",value:function(ue){var eo=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],no=this.instance.get_property(Fe)||{};this.instance.register(o({},Fe,t$1(t$1({},no),ue))),eo&&this.instance.reloadFeatureFlags()}},{key:"resetPersonPropertiesForFlags",value:function(){this.instance.unregister(Fe)}},{key:"setGroupPropertiesForFlags",value:function(ue){var eo=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],no=this.instance.get_property(xe)||{};Object.keys(no).length!==0&&Object.keys(no).forEach(function(ro){no[ro]=t$1(t$1({},no[ro]),ue[ro]),delete ue[ro]}),this.instance.register(o({},xe,t$1(t$1({},no),ue))),eo&&this.instance.reloadFeatureFlags()}},{key:"resetGroupPropertiesForFlags",value:function(ue){if(ue){var eo=this.instance.get_property(xe)||{};this.instance.register(o({},xe,t$1(t$1({},eo),{},o({},ue,{}))))}else this.instance.unregister(xe)}}]),to}();Math.trunc||(Math.trunc=function(to){return to<0?Math.ceil(to):Math.floor(to)}),Number.isInteger||(Number.isInteger=function(to){return F(to)&&isFinite(to)&&Math.floor(to)===to});var Ve="0123456789abcdef",ze=function(){function to(ue){if(i$1(this,to),this.bytes=ue,ue.length!==16)throw new TypeError("not 128-bit length")}return s(to,[{key:"toString",value:function(){for(var ue="",eo=0;eo<this.bytes.length;eo++)ue=ue+Ve.charAt(this.bytes[eo]>>>4)+Ve.charAt(15&this.bytes[eo]),eo!==3&&eo!==5&&eo!==7&&eo!==9||(ue+="-");if(ue.length!==36)throw new Error("Invalid UUIDv7 was generated");return ue}},{key:"clone",value:function(){return new to(this.bytes.slice(0))}},{key:"equals",value:function(ue){return this.compareTo(ue)===0}},{key:"compareTo",value:function(ue){for(var eo=0;eo<16;eo++){var no=this.bytes[eo]-ue.bytes[eo];if(no!==0)return Math.sign(no)}return 0}}],[{key:"fromFieldsV7",value:function(ue,eo,no,ro){if(!Number.isInteger(ue)||!Number.isInteger(eo)||!Number.isInteger(no)||!Number.isInteger(ro)||ue<0||eo<0||no<0||ro<0||ue>0xffffffffffff||eo>4095||no>1073741823||ro>4294967295)throw new RangeError("invalid field value");var oo=new Uint8Array(16);return oo[0]=ue/Math.pow(2,40),oo[1]=ue/Math.pow(2,32),oo[2]=ue/Math.pow(2,24),oo[3]=ue/Math.pow(2,16),oo[4]=ue/Math.pow(2,8),oo[5]=ue,oo[6]=112|eo>>>8,oo[7]=eo,oo[8]=128|no>>>24,oo[9]=no>>>16,oo[10]=no>>>8,oo[11]=no,oo[12]=ro>>>24,oo[13]=ro>>>16,oo[14]=ro>>>8,oo[15]=ro,new to(oo)}}]),to}(),Qe=function(){function to(){i$1(this,to),o(this,"timestamp",0),o(this,"counter",0),o(this,"random",new Xe)}return s(to,[{key:"generate",value:function(){var ue=this.generateOrAbort();if(w$1(ue)){this.timestamp=0;var eo=this.generateOrAbort();if(w$1(eo))throw new Error("Could not generate UUID after timestamp reset");return eo}return ue}},{key:"generateOrAbort",value:function(){var ue=Date.now();if(ue>this.timestamp)this.timestamp=ue,this.resetCounter();else{if(!(ue+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return ze.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}},{key:"resetCounter",value:function(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}]),to}(),Je=function(to){if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var ue=0;ue<to.length;ue++)to[ue]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return to};T&&!w$1(T.crypto)&&crypto.getRandomValues&&(Je=function(to){return crypto.getRandomValues(to)});var Ye,Xe=function(){function to(){i$1(this,to),o(this,"buffer",new Uint32Array(8)),o(this,"cursor",1/0)}return s(to,[{key:"nextUint32",value:function(){return this.cursor>=this.buffer.length&&(Je(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}]),to}(),Ke=function(){return Ze().toString()},Ze=function(){return(Ye||(Ye=new Qe)).generate()},et="Thu, 01 Jan 1970 00:00:00 GMT",tt="",nt=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function it(to,ue){if(ue){var eo=function(ro){var oo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:L;if(tt)return tt;if(!oo||["localhost","127.0.0.1"].includes(ro))return"";for(var io=ro.split("."),ao=Math.min(io.length,8),so="dmn_chk_"+Ke(),lo=new RegExp("(^|;)\\s*"+so+"=1");!tt&&ao--;){var co=io.slice(ao).join("."),uo=so+"=1;domain=."+co;oo.cookie=uo,lo.test(oo.cookie)&&(oo.cookie=uo+";expires="+et,tt=co)}return tt}(to);if(!eo){var no=function(ro){var oo=ro.match(nt);return oo?oo[0]:""}(to);no!==eo&&G.info("Warning: cookie subdomain discovery mismatch",no,eo),eo=no}return eo?"; domain=."+eo:""}return""}var rt,st={is_supported:function(){return!!L},error:function(to){G.error("cookieStore error: "+to)},get:function(to){if(L){try{for(var ue=to+"=",eo=L.cookie.split(";").filter(function(oo){return oo.length}),no=0;no<eo.length;no++){for(var ro=eo[no];ro.charAt(0)==" ";)ro=ro.substring(1,ro.length);if(ro.indexOf(ue)===0)return decodeURIComponent(ro.substring(ue.length,ro.length))}}catch{}return null}},parse:function(to){var ue;try{ue=JSON.parse(st.get(to))||{}}catch{}return ue},set:function(to,ue,eo,no,ro){if(L)try{var oo="",io="",ao=it(L.location.hostname,no);if(eo){var so=new Date;so.setTime(so.getTime()+24*eo*60*60*1e3),oo="; expires="+so.toUTCString()}ro&&(io="; secure");var lo=to+"="+encodeURIComponent(JSON.stringify(ue))+oo+"; SameSite=Lax; path=/"+ao+io;return lo.length>3686.4&&G.warn("cookieStore warning: large cookie, len="+lo.length),L.cookie=lo,lo}catch{return}},remove:function(to,ue){try{st.set(to,"",-1,ue)}catch{return}}},ot=null,at={is_supported:function(){if(!I(ot))return ot;var to=!0;if(w$1(T))to=!1;else try{var ue="__mplssupport__";at.set(ue,"xyz"),at.get(ue)!=='"xyz"'&&(to=!1),at.remove(ue)}catch{to=!1}return to||G.error("localStorage unsupported; falling back to cookie store"),ot=to,to},error:function(to){G.error("localStorage error: "+to)},get:function(to){try{return T==null?void 0:T.localStorage.getItem(to)}catch(ue){at.error(ue)}return null},parse:function(to){try{return JSON.parse(at.get(to))||{}}catch{}return null},set:function(to,ue){try{T==null||T.localStorage.setItem(to,JSON.stringify(ue))}catch(eo){at.error(eo)}},remove:function(to){try{T==null||T.localStorage.removeItem(to)}catch(ue){at.error(ue)}}},ut=["distinct_id",Se,Ee,qe],lt=t$1(t$1({},at),{},{parse:function(to){try{var ue={};try{ue=st.parse(to)||{}}catch{}var eo=J(ue,JSON.parse(at.get(to)||"{}"));return at.set(to,eo),eo}catch{}return null},set:function(to,ue,eo,no,ro,oo){try{at.set(to,ue,void 0,void 0,oo);var io={};ut.forEach(function(ao){ue[ao]&&(io[ao]=ue[ao])}),Object.keys(io).length&&st.set(to,io,eo,no,ro,oo)}catch(ao){at.error(ao)}},remove:function(to,ue){try{T==null||T.localStorage.removeItem(to),st.remove(to,ue)}catch(eo){at.error(eo)}}}),ct={},dt={is_supported:function(){return!0},error:function(to){G.error("memoryStorage error: "+to)},get:function(to){return ct[to]||null},parse:function(to){return ct[to]||null},set:function(to,ue){ct[to]=ue},remove:function(to){delete ct[to]}},ht=null,ft={is_supported:function(){if(!I(ht))return ht;if(ht=!0,w$1(T))ht=!1;else try{var to="__support__";ft.set(to,"xyz"),ft.get(to)!=='"xyz"'&&(ht=!1),ft.remove(to)}catch{ht=!1}return ht},error:function(to){G.error("sessionStorage error: ",to)},get:function(to){try{return T==null?void 0:T.sessionStorage.getItem(to)}catch(ue){ft.error(ue)}return null},parse:function(to){try{return JSON.parse(ft.get(to))||null}catch{}return null},set:function(to,ue){try{T==null||T.sessionStorage.setItem(to,JSON.stringify(ue))}catch(eo){ft.error(eo)}},remove:function(to){try{T==null||T.sessionStorage.removeItem(to)}catch(ue){ft.error(ue)}}},vt=["localhost","127.0.0.1"],pt=function(to){var ue=L==null?void 0:L.createElement("a");return w$1(ue)?null:(ue.href=to,ue)},gt=function(to,ue){return!!function(eo){try{new RegExp(eo)}catch{return!1}return!0}(ue)&&new RegExp(ue).test(to)},_t=function(to){var ue,eo,no=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",ro=[];return Q(to,function(oo,io){w$1(oo)||w$1(io)||io==="undefined"||(ue=encodeURIComponent(function(ao){return ao instanceof File}(oo)?oo.name:oo.toString()),eo=encodeURIComponent(io),ro[ro.length]=eo+"="+ue)}),ro.join(no)},mt=function(to,ue){for(var eo,no=((to.split("#")[0]||"").split("?")[1]||"").split("&"),ro=0;ro<no.length;ro++){var oo=no[ro].split("=");if(oo[0]===ue){eo=oo;break}}if(!m(eo)||eo.length<2)return"";var io=eo[1];try{io=decodeURIComponent(io)}catch{G.error("Skipping decoding for malformed query param: "+io)}return io.replace(/\+/g," ")},yt=function(to,ue){var eo=to.match(new RegExp(ue+"=([^&]*)"));return eo?eo[1]:null},bt="Mobile",kt="iOS",wt="Android",St="Tablet",Et=wt+" "+St,It="iPad",Rt="Apple",Ft=Rt+" Watch",xt="Safari",Pt="BlackBerry",Tt="Samsung",Ct=Tt+"Browser",$t=Tt+" Internet",Ot="Chrome",Mt=Ot+" OS",At=Ot+" "+kt,Lt="Internet Explorer",Dt=Lt+" "+bt,qt="Opera",Nt=qt+" Mini",Bt="Edge",Ht="Microsoft "+Bt,Ut="Firefox",jt=Ut+" "+kt,Gt="Nintendo",Wt="PlayStation",Vt="Xbox",zt=wt+" "+bt,Qt=bt+" "+xt,Jt="Windows",Yt=Jt+" Phone",Xt="Nokia",Kt="Ouya",Zt="Generic",en=Zt+" "+bt.toLowerCase(),tn=Zt+" "+St.toLowerCase(),nn="Konqueror",rn="(\\d+(\\.\\d+)?)",sn=new RegExp("Version/"+rn),on=new RegExp(Vt,"i"),an=new RegExp(Wt+" \\w+","i"),un=new RegExp(Gt+" \\w+","i"),ln=new RegExp(Pt+"|PlayBook|BB10","i"),cn={"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"},dn=function(to,ue){return ue&&Y(ue,Rt)||function(eo){return Y(eo,xt)&&!Y(eo,Ot)&&!Y(eo,wt)}(to)},hn=function(to,ue){return ue=ue||"",Y(to," OPR/")&&Y(to,"Mini")?Nt:Y(to," OPR/")?qt:ln.test(to)?Pt:Y(to,"IE"+bt)||Y(to,"WPDesktop")?Dt:Y(to,Ct)?$t:Y(to,Bt)||Y(to,"Edg/")?Ht:Y(to,"FBIOS")?"Facebook "+bt:Y(to,"UCWEB")||Y(to,"UCBrowser")?"UC Browser":Y(to,"CriOS")?At:Y(to,"CrMo")?Ot:Y(to,wt)&&Y(to,xt)?zt:Y(to,Ot)?Ot:Y(to,"FxiOS")?jt:Y(to.toLowerCase(),nn.toLowerCase())?nn:dn(to,ue)?Y(to,bt)?Qt:xt:Y(to,Ut)?Ut:Y(to,"MSIE")||Y(to,"Trident/")?Lt:Y(to,"Gecko")?Ut:""},fn=(o(rt={},Dt,[new RegExp("rv:"+rn)]),o(rt,Ht,[new RegExp(Bt+"?\\/"+rn)]),o(rt,Ot,[new RegExp("("+Ot+"|CrMo)\\/"+rn)]),o(rt,At,[new RegExp("CriOS\\/"+rn)]),o(rt,"UC Browser",[new RegExp("(UCBrowser|UCWEB)\\/"+rn)]),o(rt,xt,[sn]),o(rt,Qt,[sn]),o(rt,qt,[new RegExp("(Opera|OPR)\\/"+rn)]),o(rt,Ut,[new RegExp(Ut+"\\/"+rn)]),o(rt,jt,[new RegExp("FxiOS\\/"+rn)]),o(rt,nn,[new RegExp("Konqueror[:/]?"+rn,"i")]),o(rt,Pt,[new RegExp(Pt+" "+rn),sn]),o(rt,zt,[new RegExp("android\\s"+rn,"i")]),o(rt,$t,[new RegExp(Ct+"\\/"+rn)]),o(rt,Lt,[new RegExp("(rv:|MSIE )"+rn)]),o(rt,"Mozilla",[new RegExp("rv:"+rn)]),rt),vn=[[new RegExp(Vt+"; "+Vt+" (.*?)[);]","i"),function(to){return[Vt,to&&to[1]||""]}],[new RegExp(Gt,"i"),[Gt,""]],[new RegExp(Wt,"i"),[Wt,""]],[ln,[Pt,""]],[new RegExp(Jt,"i"),function(to,ue){if(/Phone/.test(ue)||/WPDesktop/.test(ue))return[Yt,""];if(new RegExp(bt).test(ue)&&!/IEMobile\b/.test(ue))return[Jt+" "+bt,""];var eo=/Windows NT ([0-9.]+)/i.exec(ue);if(eo&&eo[1]){var no=eo[1],ro=cn[no]||"";return/arm/i.test(ue)&&(ro="RT"),[Jt,ro]}return[Jt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,function(to){if(to&&to[3]){var ue=[to[3],to[4],to[5]||"0"];return[kt,ue.join(".")]}return[kt,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,function(to){var ue="";return to&&to.length>=3&&(ue=w$1(to[2])?to[3]:to[2]),["watchOS",ue]}],[new RegExp("("+wt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+wt+")","i"),function(to){if(to&&to[2]){var ue=[to[2],to[3],to[4]||"0"];return[wt,ue.join(".")]}return[wt,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,function(to){var ue=["Mac OS X",""];if(to&&to[1]){var eo=[to[1],to[2],to[3]||"0"];ue[1]=eo.join(".")}return ue}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Mt,""]],[/Linux|debian/i,["Linux",""]]],pn=function(to){return un.test(to)?Gt:an.test(to)?Wt:on.test(to)?Vt:new RegExp(Kt,"i").test(to)?Kt:new RegExp("("+Yt+"|WPDesktop)","i").test(to)?Yt:/iPad/.test(to)?It:/iPod/.test(to)?"iPod Touch":/iPhone/.test(to)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(to)?Ft:ln.test(to)?Pt:/(kobo)\s(ereader|touch)/i.test(to)?"Kobo":new RegExp(Xt,"i").test(to)?Xt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(to)||/(kf[a-z]+)( bui|\)).+silk\//i.test(to)?"Kindle Fire":/(Android|ZTE)/i.test(to)?!new RegExp(bt).test(to)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(to)?/pixel[\daxl ]{1,6}/i.test(to)&&!/pixel c/i.test(to)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(to)||/lmy47v/i.test(to)&&!/QTAQZ3/i.test(to)?wt:Et:wt:new RegExp("(pda|"+bt+")","i").test(to)?en:new RegExp(St,"i").test(to)&&!new RegExp(St+" pc","i").test(to)?tn:""},gn="https?://(.*)",_n=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","mc_cid","igshid","ttclid","rdt_cid"],mn={campaignParams:function(to){return L?this._campaignParamsFromUrl(L.URL,to):{}},_campaignParamsFromUrl:function(to,ue){var eo=_n.concat(ue||[]),no={};return Q(eo,function(ro){var oo=mt(to,ro);oo&&(no[ro]=oo)}),no},_searchEngine:function(to){return to?to.search(gn+"google.([^/?]*)")===0?"google":to.search(gn+"bing.com")===0?"bing":to.search(gn+"yahoo.com")===0?"yahoo":to.search(gn+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(to){var ue=mn._searchEngine(to),eo=ue!="yahoo"?"q":"p",no={};if(!I(ue)){no.$search_engine=ue;var ro=L?mt(L.referrer,eo):"";ro.length&&(no.ph_keyword=ro)}return no},searchInfo:function(){var to=L==null?void 0:L.referrer;return to?this._searchInfoFromReferrer(to):{}},browser:hn,browserVersion:function(to,ue){var eo=hn(to,ue),no=fn[eo];if(w$1(no))return null;for(var ro=0;ro<no.length;ro++){var oo=no[ro],io=to.match(oo);if(io)return parseFloat(io[io.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},os:function(to){for(var ue=0;ue<vn.length;ue++){var eo=u(vn[ue],2),no=eo[0],ro=eo[1],oo=no.exec(to),io=oo&&(y(ro)?ro(oo,to):ro);if(io)return io}return["",""]},device:pn,deviceType:function(to){var ue=pn(to);return ue===It||ue===Et||ue==="Kobo"||ue==="Kindle Fire"||ue===tn?St:ue===Gt||ue===Vt||ue===Wt||ue===Kt?"Console":ue===Ft?"Wearable":ue?bt:"Desktop"},referrer:function(){return(L==null?void 0:L.referrer)||"$direct"},referringDomain:function(){var to;return L!=null&&L.referrer&&((to=pt(L.referrer))===null||to===void 0?void 0:to.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},initialPersonInfo:function(){return{r:this.referrer(),u:D==null?void 0:D.href}},initialPersonPropsFromInfo:function(to){var ue,eo=to.r,no=to.u,ro={$initial_referrer:eo,$initial_referring_domain:eo==null?void 0:eo=="$direct"?"$direct":(ue=pt(eo))===null||ue===void 0?void 0:ue.host};if(no){ro.$initial_current_url=no;var oo=pt(no);ro.$initial_host=oo==null?void 0:oo.host,ro.$initial_pathname=oo==null?void 0:oo.pathname,Q(this._campaignParamsFromUrl(no),function(io,ao){ro["$initial_"+ne(ao)]=io})}return eo&&Q(this._searchInfoFromReferrer(eo),function(io,ao){ro["$initial_"+ne(ao)]=io}),ro},properties:function(){if(!H)return{};var to=u(mn.os(H),2),ue=to[0],eo=to[1];return J(te({$os:ue,$os_version:eo,$browser:mn.browser(H,navigator.vendor),$device:mn.device(H),$device_type:mn.deviceType(H)}),{$current_url:D==null?void 0:D.href,$host:D==null?void 0:D.host,$pathname:D==null?void 0:D.pathname,$raw_user_agent:H.length>1e3?H.substring(0,997)+"...":H,$browser_version:mn.browserVersion(H,navigator.vendor),$browser_language:mn.browserLanguage(),$screen_height:T==null?void 0:T.screen.height,$screen_width:T==null?void 0:T.screen.width,$viewport_height:T==null?void 0:T.innerHeight,$viewport_width:T==null?void 0:T.innerWidth,$lib:"web",$lib_version:f.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:K()/1e3})},people_properties:function(){if(!H)return{};var to=u(mn.os(H),2),ue=to[0],eo=to[1];return J(te({$os:ue,$os_version:eo,$browser:mn.browser(H,navigator.vendor)}),{$browser_version:mn.browserVersion(H,navigator.vendor)})}},yn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],bn=function(){function to(ue){i$1(this,to),this.config=ue,this.props={},this.campaign_params_saved=!1,this.name=function(eo){var no="";return eo.token&&(no=eo.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),eo.persistence_name?"ph_"+eo.persistence_name:"ph_"+no+"_posthog"}(ue),this.storage=this.buildStorage(ue),this.load(),ue.debug&&G.info("Persistence loaded",ue.persistence,t$1({},this.props)),this.update_config(ue,ue),this.save()}return s(to,[{key:"buildStorage",value:function(ue){yn.indexOf(ue.persistence.toLowerCase())===-1&&(G.critical("Unknown persistence type "+ue.persistence+"; falling back to localStorage+cookie"),ue.persistence="localStorage+cookie");var eo=ue.persistence.toLowerCase();return eo==="localstorage"&&at.is_supported()?at:eo==="localstorage+cookie"&<.is_supported()?lt:eo==="sessionstorage"&&ft.is_supported()?ft:eo==="memory"?dt:eo==="cookie"?st:lt.is_supported()?lt:st}},{key:"properties",value:function(){var ue={};return Q(this.props,function(eo,no){if(no===Ie&&b(eo))for(var ro=Object.keys(eo),oo=0;oo<ro.length;oo++)ue["$feature/".concat(ro[oo])]=eo[ro[oo]];else ao=no,so=!1,(I(io=Be)?so:M&&io.indexOf===M?io.indexOf(ao)!=-1:(Q(io,function(lo){if(so||(so=lo===ao))return W}),so))||(ue[no]=eo);var io,ao,so}),ue}},{key:"load",value:function(){if(!this.disabled){var ue=this.storage.parse(this.name);ue&&(this.props=J({},ue))}}},{key:"save",value:function(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure,this.config.debug)}},{key:"remove",value:function(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)}},{key:"clear",value:function(){this.remove(),this.props={}}},{key:"register_once",value:function(ue,eo,no){var ro=this;if(b(ue)){w$1(eo)&&(eo="None"),this.expire_days=w$1(no)?this.default_expiry:no;var oo=!1;if(Q(ue,function(io,ao){ro.props.hasOwnProperty(ao)&&ro.props[ao]!==eo||(ro.props[ao]=io,oo=!0)}),oo)return this.save(),!0}return!1}},{key:"register",value:function(ue,eo){var no=this;if(b(ue)){this.expire_days=w$1(eo)?this.default_expiry:eo;var ro=!1;if(Q(ue,function(oo,io){ue.hasOwnProperty(io)&&no.props[io]!==oo&&(no.props[io]=oo,ro=!0)}),ro)return this.save(),!0}return!1}},{key:"unregister",value:function(ue){ue in this.props&&(delete this.props[ue],this.save())}},{key:"update_campaign_params",value:function(){this.campaign_params_saved||(this.register(mn.campaignParams(this.config.custom_campaign_params)),this.campaign_params_saved=!0)}},{key:"update_search_keyword",value:function(){this.register(mn.searchInfo())}},{key:"update_referrer_info",value:function(){this.register_once(mn.referrerInfo(),void 0)}},{key:"set_initial_person_info",value:function(){this.props[Ae]||this.props[Le]||this.register_once(o({},De,mn.initialPersonInfo()),void 0)}},{key:"get_referrer_info",value:function(){return te({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}},{key:"get_initial_props",value:function(){var ue=this,eo={};Q([Le,Ae],function(oo){var io=ue.props[oo];io&&Q(io,function(ao,so){eo["$initial_"+ne(so)]=ao})});var no=this.props[De];if(no){var ro=mn.initialPersonPropsFromInfo(no);J(eo,ro)}return eo}},{key:"safe_merge",value:function(ue){return Q(this.props,function(eo,no){no in ue||(ue[no]=eo)}),ue}},{key:"update_config",value:function(ue,eo){if(this.default_expiry=this.expire_days=ue.cookie_expiration,this.set_disabled(ue.disable_persistence),this.set_cross_subdomain(ue.cross_subdomain_cookie),this.set_secure(ue.secure_cookie),ue.persistence!==eo.persistence){var no=this.buildStorage(ue),ro=this.props;this.clear(),this.storage=no,this.props=ro,this.save()}}},{key:"set_disabled",value:function(ue){this.disabled=ue,this.disabled?this.remove():this.save()}},{key:"set_cross_subdomain",value:function(ue){ue!==this.cross_subdomain&&(this.cross_subdomain=ue,this.remove(),this.save())}},{key:"get_cross_subdomain",value:function(){return!!this.cross_subdomain}},{key:"set_secure",value:function(ue){ue!==this.secure&&(this.secure=ue,this.remove(),this.save())}},{key:"set_event_timer",value:function(ue,eo){var no=this.props[de]||{};no[ue]=eo,this.props[de]=no,this.save()}},{key:"remove_event_timer",value:function(ue){var eo=(this.props[de]||{})[ue];return w$1(eo)||(delete this.props[de][ue],this.save()),eo}},{key:"get_property",value:function(ue){return this.props[ue]}},{key:"set_property",value:function(ue,eo){this.props[ue]=eo,this.save()}}]),to}();function kn(to){return JSON.stringify(to,(ue=[],function(eo,no){if(b(no)){for(;ue.length>0&&ue.at(-1)!==this;)ue.pop();return ue.includes(no)?"[Circular]":(ue.push(no),no)}return no})).length;var ue}var wn=2,Sn=4;function En(to){var ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:66060288e-1;if(to.size>=ue&&to.data.length>1){var eo=Math.floor(to.data.length/2),no=to.data.slice(0,eo),ro=to.data.slice(eo);return[En({size:kn(no),data:no,sessionId:to.sessionId,windowId:to.windowId}),En({size:kn(ro),data:ro,sessionId:to.sessionId,windowId:to.windowId})].flatMap(function(oo){return oo})}return[to]}var In=function(to){return to[to.DomContentLoaded=0]="DomContentLoaded",to[to.Load=1]="Load",to[to.FullSnapshot=2]="FullSnapshot",to[to.IncrementalSnapshot=3]="IncrementalSnapshot",to[to.Meta=4]="Meta",to[to.Custom=5]="Custom",to[to.Plugin=6]="Plugin",to}(In||{}),Rn=function(to){return to[to.Mutation=0]="Mutation",to[to.MouseMove=1]="MouseMove",to[to.MouseInteraction=2]="MouseInteraction",to[to.Scroll=3]="Scroll",to[to.ViewportResize=4]="ViewportResize",to[to.Input=5]="Input",to[to.TouchMove=6]="TouchMove",to[to.MediaInteraction=7]="MediaInteraction",to[to.StyleSheetRule=8]="StyleSheetRule",to[to.CanvasMutation=9]="CanvasMutation",to[to.Font=10]="Font",to[to.Log=11]="Log",to[to.Drag=12]="Drag",to[to.StyleDeclaration=13]="StyleDeclaration",to[to.Selection=14]="Selection",to[to.AdoptedStyleSheet=15]="AdoptedStyleSheet",to[to.CustomElement=16]="CustomElement",to}(Rn||{});function Fn(to){return to?V(to).split(/\s+/):[]}function xn(to){var ue=T==null?void 0:T.location.href;return!!(ue&&to&&to.some(function(eo){return ue.match(eo)}))}function Pn(to){var ue="";switch(n(to.className)){case"string":ue=to.className;break;case"object":ue=(to.className&&"baseVal"in to.className?to.className.baseVal:null)||to.getAttribute("class")||"";break;default:ue=""}return Fn(ue)}function Tn(to){return R(to)?null:V(to).split(/(\s+)/).filter(function(ue){return zn(ue)}).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Cn(to){var ue="";return Nn(to)&&!Bn(to)&&to.childNodes&&to.childNodes.length&&Q(to.childNodes,function(eo){var no;Mn(eo)&&eo.textContent&&(ue+=(no=Tn(eo.textContent))!==null&&no!==void 0?no:"")}),V(ue)}function $n(to){return!!to&&to.nodeType===1}function On(to,ue){return!!to&&!!to.tagName&&to.tagName.toLowerCase()===ue.toLowerCase()}function Mn(to){return!!to&&to.nodeType===3}function An(to){return!!to&&to.nodeType===11}var Ln=["a","button","form","input","select","textarea","label"];function Dn(to){var ue=to.parentNode;return!(!ue||!$n(ue))&&ue}function qn(to,ue){var eo=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,no=arguments.length>3?arguments[3]:void 0,ro=arguments.length>4?arguments[4]:void 0;if(!T||!to||On(to,"html")||!$n(to)||eo!=null&&eo.url_allowlist&&!xn(eo.url_allowlist)||eo!=null&&eo.url_ignorelist&&xn(eo.url_ignorelist))return!1;if(eo!=null&&eo.dom_event_allowlist){var oo=eo.dom_event_allowlist;if(oo&&!oo.some(function(po){return ue.type===po}))return!1}for(var io=!1,ao=[to],so=!0,lo=to;lo.parentNode&&!On(lo,"body");)if(An(lo.parentNode))ao.push(lo.parentNode.host),lo=lo.parentNode.host;else{if(!(so=Dn(lo)))break;if(no||Ln.indexOf(so.tagName.toLowerCase())>-1)io=!0;else{var co=T.getComputedStyle(so);co&&co.getPropertyValue("cursor")==="pointer"&&(io=!0)}ao.push(so),lo=so}if(!function(po,ho){var _o=ho==null?void 0:ho.element_allowlist;if(w$1(_o))return!0;var go,bo=h(po);try{var vo=function(){var wo=go.value;if(_o.some(function(ko){return wo.tagName.toLowerCase()===ko}))return{v:!0}};for(bo.s();!(go=bo.n()).done;){var yo=vo();if(n(yo)==="object")return yo.v}}catch(wo){bo.e(wo)}finally{bo.f()}return!1}(ao,eo)||!function(po,ho){var _o=ho==null?void 0:ho.css_selector_allowlist;if(w$1(_o))return!0;var go,bo=h(po);try{var vo=function(){var wo=go.value;if(_o.some(function(ko){return wo.matches(ko)}))return{v:!0}};for(bo.s();!(go=bo.n()).done;){var yo=vo();if(n(yo)==="object")return yo.v}}catch(wo){bo.e(wo)}finally{bo.f()}return!1}(ao,eo))return!1;var uo=T.getComputedStyle(to);if(uo&&uo.getPropertyValue("cursor")==="pointer"&&ue.type==="click")return!0;var fo=to.tagName.toLowerCase();switch(fo){case"html":return!1;case"form":return(ro||["submit"]).indexOf(ue.type)>=0;case"input":case"select":case"textarea":return(ro||["change","click"]).indexOf(ue.type)>=0;default:return io?(ro||["click"]).indexOf(ue.type)>=0:(ro||["click"]).indexOf(ue.type)>=0&&(Ln.indexOf(fo)>-1||to.getAttribute("contenteditable")==="true")}}function Nn(to){for(var ue=to;ue.parentNode&&!On(ue,"body");ue=ue.parentNode){var eo=Pn(ue);if(Y(eo,"ph-sensitive")||Y(eo,"ph-no-capture"))return!1}if(Y(Pn(to),"ph-include"))return!0;var no=to.type||"";if(S(no))switch(no.toLowerCase()){case"hidden":case"password":return!1}var ro=to.name||to.id||"";return!(S(ro)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(ro.replace(/[^a-zA-Z0-9]/g,"")))}function Bn(to){return!!(On(to,"input")&&!["button","checkbox","submit","reset"].includes(to.type)||On(to,"select")||On(to,"textarea")||to.getAttribute("contenteditable")==="true")}var Hn="(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})",Un=new RegExp("^(?:".concat(Hn,")$")),jn=new RegExp(Hn),Gn="\\d{3}-?\\d{2}-?\\d{4}",Wn=new RegExp("^(".concat(Gn,")$")),Vn=new RegExp("(".concat(Gn,")"));function zn(to){var ue=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(R(to)||S(to)&&(to=V(to),(ue?Un:jn).test((to||"").replace(/[- ]/g,""))||(ue?Wn:Vn).test(to)))}function Qn(to){var ue=Cn(to);return zn(ue="".concat(ue," ").concat(Jn(to)).trim())?ue:""}function Jn(to){var ue="";return to&&to.childNodes&&to.childNodes.length&&Q(to.childNodes,function(eo){var no;if(eo&&((no=eo.tagName)===null||no===void 0?void 0:no.toLowerCase())==="span")try{var ro=Cn(eo);ue="".concat(ue," ").concat(ro).trim(),eo.childNodes&&eo.childNodes.length&&(ue="".concat(ue," ").concat(Jn(eo)).trim())}catch(oo){G.error(oo)}}),ue}function Yn(to){return function(ue){var eo=ue.map(function(no){var ro,oo,io="";if(no.tag_name&&(io+=no.tag_name),no.attr_class){no.attr_class.sort();var ao,so=h(no.attr_class);try{for(so.s();!(ao=so.n()).done;){var lo=ao.value;io+=".".concat(lo.replace(/"/g,""))}}catch(fo){so.e(fo)}finally{so.f()}}var co=t$1(t$1(t$1(t$1({},no.text?{text:no.text}:{}),{},{"nth-child":(ro=no.nth_child)!==null&&ro!==void 0?ro:0,"nth-of-type":(oo=no.nth_of_type)!==null&&oo!==void 0?oo:0},no.href?{href:no.href}:{}),no.attr_id?{attr_id:no.attr_id}:{}),no.attributes),uo={};return X(co).sort(function(fo,po){var ho=u(fo,1)[0],_o=u(po,1)[0];return ho.localeCompare(_o)}).forEach(function(fo){var po=u(fo,2),ho=po[0],_o=po[1];return uo[Xn(ho.toString())]=Xn(_o.toString())}),io+=":",io+=X(co).map(function(fo){var po=u(fo,2),ho=po[0],_o=po[1];return"".concat(ho,'="').concat(_o,'"')}).join("")});return eo.join(";")}(function(ue){return ue.map(function(eo){var no,ro,oo={text:(no=eo.$el_text)===null||no===void 0?void 0:no.slice(0,400),tag_name:eo.tag_name,href:(ro=eo.attr__href)===null||ro===void 0?void 0:ro.slice(0,2048),attr_class:Kn(eo),attr_id:eo.attr__id,nth_child:eo.nth_child,nth_of_type:eo.nth_of_type,attributes:{}};return X(eo).filter(function(io){return u(io,1)[0].indexOf("attr__")===0}).forEach(function(io){var ao=u(io,2),so=ao[0],lo=ao[1];return oo.attributes[so]=lo}),oo})}(to))}function Xn(to){return to.replace(/"|\\"/g,'\\"')}function Kn(to){var ue=to.attr__class;return ue?m(ue)?ue:Fn(ue):void 0}var Zn="[SessionRecording]",ei="redacted",ti={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:function(to){return to},recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io"]},ni=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],ii=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],ri=["/s/","/e/","/i/"];function si(to,ue,eo,no){if(R(to))return to;var ro=(ue==null?void 0:ue["content-length"])||function(oo){return new Blob([oo]).size}(to);return S(ro)&&(ro=parseInt(ro)),ro>eo?Zn+" ".concat(no," body too large to record (").concat(ro," bytes)"):to}function oi(to,ue){if(R(to))return to;var eo=to;return zn(eo,!1)||(eo=Zn+" "+ue+" body "+ei),Q(ii,function(no){var ro,oo;(ro=eo)!==null&&ro!==void 0&&ro.length&&((oo=eo)===null||oo===void 0?void 0:oo.indexOf(no))!==-1&&(eo=Zn+" "+ue+" body "+ei+" as might contain: "+no)}),eo}var ai,ui=function(to,ue){var eo,no,ro,oo={payloadSizeLimitBytes:ti.payloadSizeLimitBytes,performanceEntryTypeToObserve:l(ti.performanceEntryTypeToObserve),payloadHostDenyList:[].concat(l(ue.payloadHostDenyList||[]),l(ti.payloadHostDenyList))},io=to.session_recording.recordHeaders!==!1&&ue.recordHeaders,ao=to.session_recording.recordBody!==!1&&ue.recordBody,so=to.capture_performance!==!1&&ue.recordPerformance,lo=(eo=oo,ro=Math.min(1e6,(no=eo.payloadSizeLimitBytes)!==null&&no!==void 0?no:1e6),function(fo){return fo!=null&&fo.requestBody&&(fo.requestBody=si(fo.requestBody,fo.requestHeaders,ro,"Request")),fo!=null&&fo.responseBody&&(fo.responseBody=si(fo.responseBody,fo.responseHeaders,ro,"Response")),fo}),co=function(fo){return lo(function(_o){var go=pt(_o.name);if(!(go&&go.pathname&&ri.some(function(bo){return go.pathname.indexOf(bo)===0})))return _o}((ho=(po=fo).requestHeaders,R(ho)||Q(Object.keys(ho??{}),function(_o){ni.includes(_o.toLowerCase())&&(ho[_o]=ei)}),po)));var po,ho},uo=y(to.session_recording.maskNetworkRequestFn);return uo&&y(to.session_recording.maskCapturedNetworkRequestFn)&&G.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),uo&&(to.session_recording.maskCapturedNetworkRequestFn=function(fo){var po=to.session_recording.maskNetworkRequestFn({url:fo.name});return t$1(t$1({},fo),{},{name:po==null?void 0:po.url})}),oo.maskRequestFn=y(to.session_recording.maskCapturedNetworkRequestFn)?function(fo){var po,ho,_o,go=co(fo);return go&&(po=(ho=(_o=to.session_recording).maskCapturedNetworkRequestFn)===null||ho===void 0?void 0:ho.call(_o,go))!==null&&po!==void 0?po:void 0}:function(fo){return function(po){if(!w$1(po))return po.requestBody=oi(po.requestBody,"Request"),po.responseBody=oi(po.responseBody,"Response"),po}(co(fo))},t$1(t$1(t$1({},ti),oo),{},{recordHeaders:io,recordBody:ao,recordPerformance:so,recordInitialRequests:so})},li=s(function to(ue){var eo,no,ro=this,oo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};i$1(this,to),o(this,"bucketSize",100),o(this,"refillRate",10),o(this,"mutationBuckets",{}),o(this,"loggedTracker",{}),o(this,"refillBuckets",function(){Object.keys(ro.mutationBuckets).forEach(function(io){ro.mutationBuckets[io]=ro.mutationBuckets[io]+ro.refillRate,ro.mutationBuckets[io]>=ro.bucketSize&&delete ro.mutationBuckets[io]})}),o(this,"getNodeOrRelevantParent",function(io){var ao=ro.rrweb.mirror.getNode(io);if((ao==null?void 0:ao.nodeName)!=="svg"&&ao instanceof Element){var so=ao.closest("svg");if(so)return[ro.rrweb.mirror.getId(so),so]}return[io,ao]}),o(this,"numberOfChanges",function(io){var ao,so,lo,co,uo,fo,po,ho;return((ao=(so=io.removes)===null||so===void 0?void 0:so.length)!==null&&ao!==void 0?ao:0)+((lo=(co=io.attributes)===null||co===void 0?void 0:co.length)!==null&&lo!==void 0?lo:0)+((uo=(fo=io.texts)===null||fo===void 0?void 0:fo.length)!==null&&uo!==void 0?uo:0)+((po=(ho=io.adds)===null||ho===void 0?void 0:ho.length)!==null&&po!==void 0?po:0)}),o(this,"throttleMutations",function(io){if(io.type!==3||io.data.source!==0)return io;var ao=io.data,so=ro.numberOfChanges(ao);ao.attributes&&(ao.attributes=ao.attributes.filter(function(co){var uo,fo,po,ho=u(ro.getNodeOrRelevantParent(co.id),2),_o=ho[0],go=ho[1];return ro.mutationBuckets[_o]===0?!1:(ro.mutationBuckets[_o]=(uo=ro.mutationBuckets[_o])!==null&&uo!==void 0?uo:ro.bucketSize,ro.mutationBuckets[_o]=Math.max(ro.mutationBuckets[_o]-1,0),ro.mutationBuckets[_o]===0&&(ro.loggedTracker[_o]||(ro.loggedTracker[_o]=!0,(fo=(po=ro.options).onBlockedNode)===null||fo===void 0||fo.call(po,_o,go))),co)}));var lo=ro.numberOfChanges(ao);return lo!==0||so===lo?io:void 0}),this.rrweb=ue,this.options=oo,this.refillRate=(eo=this.options.refillRate)!==null&&eo!==void 0?eo:this.refillRate,this.bucketSize=(no=this.options.bucketSize)!==null&&no!==void 0?no:this.bucketSize,setInterval(function(){ro.refillBuckets()},1e3)}),ci=3e5,di=[Rn.MouseMove,Rn.MouseInteraction,Rn.Scroll,Rn.ViewportResize,Rn.Input,Rn.TouchMove,Rn.MediaInteraction,Rn.Drag],hi=function(to){return{rrwebMethod:to,enqueuedAt:Date.now(),attempt:1}},fi="[SessionRecording]",vi=function(){function to(ue){var eo=this;if(i$1(this,to),o(this,"queuedRRWebEvents",[]),o(this,"isIdle",!1),o(this,"_linkedFlagSeen",!1),o(this,"_lastActivityTimestamp",Date.now()),o(this,"_linkedFlag",null),o(this,"_forceAllowLocalhostNetworkCapture",!1),o(this,"_onBeforeUnload",function(){eo._flushBuffer()}),o(this,"_onOffline",function(){eo._tryAddCustomEvent("browser offline",{})}),o(this,"_onOnline",function(){eo._tryAddCustomEvent("browser online",{})}),o(this,"_onVisibilityChange",function(){if(L!=null&&L.visibilityState){var io="window "+L.visibilityState;eo._tryAddCustomEvent(io,{})}}),o(this,"_samplingSessionListener",null),this.instance=ue,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw G.error(fi+" started without valid sessionManager"),new Error(fi+" started without valid sessionManager. This is a bug.");var no=this.sessionManager.checkAndGetSessionAndWindowId(),ro=no.sessionId,oo=no.windowId;this.sessionId=ro,this.windowId=oo,this.buffer=this.clearBuffer(),this._setupSampling()}return s(to,[{key:"rrwebRecord",get:function(){var ue;return U==null||(ue=U.rrweb)===null||ue===void 0?void 0:ue.record}},{key:"started",get:function(){return this._captureStarted}},{key:"sessionManager",get:function(){if(!this.instance.sessionManager)throw new Error(fi+" must be started with a valid sessionManager.");return this.instance.sessionManager}},{key:"fullSnapshotIntervalMillis",get:function(){var ue;return((ue=this.instance.config.session_recording)===null||ue===void 0?void 0:ue.full_snapshot_interval_millis)||ci}},{key:"isSampled",get:function(){var ue=this.instance.get_property(Ee);return x$1(ue)?ue:null}},{key:"sessionDuration",get:function(){var ue,eo,no=(ue=this.buffer)===null||ue===void 0?void 0:ue.data[((eo=this.buffer)===null||eo===void 0?void 0:eo.data.length)-1],ro=this.sessionManager.checkAndGetSessionAndWindowId(!0).sessionStartTimestamp;return no?no.timestamp-ro:null}},{key:"isRecordingEnabled",get:function(){var ue=!!this.instance.get_property(_e),eo=!this.instance.config.disable_session_recording;return T&&ue&&eo}},{key:"isConsoleLogCaptureEnabled",get:function(){var ue=!!this.instance.get_property(me),eo=this.instance.config.enable_recording_console_log;return eo??ue}},{key:"canvasRecording",get:function(){var ue=this.instance.get_property(be);return ue&&ue.fps&&ue.quality?{enabled:ue.enabled,fps:ue.fps,quality:ue.quality}:void 0}},{key:"networkPayloadCapture",get:function(){var ue,eo,no=this.instance.get_property(ye),ro={recordHeaders:(ue=this.instance.config.session_recording)===null||ue===void 0?void 0:ue.recordHeaders,recordBody:(eo=this.instance.config.session_recording)===null||eo===void 0?void 0:eo.recordBody},oo=(ro==null?void 0:ro.recordHeaders)||(no==null?void 0:no.recordHeaders),io=(ro==null?void 0:ro.recordBody)||(no==null?void 0:no.recordBody),ao=b(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,so=!!(x$1(ao)?ao:no!=null&&no.capturePerformance);return oo||io||so?{recordHeaders:oo,recordBody:io,recordPerformance:so}:void 0}},{key:"sampleRate",get:function(){var ue=this.instance.get_property(ke);return F(ue)?ue:null}},{key:"minimumDuration",get:function(){var ue=this.instance.get_property(we);return F(ue)?ue:null}},{key:"status",get:function(){return this.receivedDecide?this.isRecordingEnabled?R(this._linkedFlag)||this._linkedFlagSeen?x$1(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}},{key:"startIfEnabledOrStop",value:function(){this.isRecordingEnabled?(this._startCapture(),T==null||T.addEventListener("beforeunload",this._onBeforeUnload),T==null||T.addEventListener("offline",this._onOffline),T==null||T.addEventListener("online",this._onOnline),T==null||T.addEventListener("visibilitychange",this._onVisibilityChange),G.info(fi+" started")):(this.stopRecording(),this.clearBuffer())}},{key:"stopRecording",value:function(){this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,T==null||T.removeEventListener("beforeunload",this._onBeforeUnload),T==null||T.removeEventListener("offline",this._onOffline),T==null||T.removeEventListener("online",this._onOnline),T==null||T.removeEventListener("visibilitychange",this._onVisibilityChange),G.info(fi+" stopped"))}},{key:"makeSamplingDecision",value:function(ue){var eo,no=this.sessionId!==ue,ro=this.sampleRate;if(F(ro)){var oo,io=this.isSampled,ao=no||!x$1(io);ao?oo=Math.random()<ro:oo=io,!oo&&ao&&G.warn(fi+" Sample rate (".concat(ro,") has determined that this sessionId (").concat(ue,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:ro}),(eo=this.instance.persistence)===null||eo===void 0||eo.register(o({},Ee,oo))}else{var so;(so=this.instance.persistence)===null||so===void 0||so.register(o({},Ee,null))}}},{key:"afterDecideResponse",value:function(ue){var eo,no,ro,oo=this;if(this._persistDecideResponse(ue),this._linkedFlag=((eo=ue.sessionRecording)===null||eo===void 0?void 0:eo.linkedFlag)||null,(no=ue.sessionRecording)!==null&&no!==void 0&&no.endpoint&&(this._endpoint=(ro=ue.sessionRecording)===null||ro===void 0?void 0:ro.endpoint),this._setupSampling(),!R(this._linkedFlag)&&!this._linkedFlagSeen){var io=S(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,ao=S(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags(function(so,lo){var co=b(lo)&&io in lo,uo=ao?lo[io]===ao:co;if(uo){var fo={linkedFlag:io,linkedVariant:ao},po="linked flag matched";G.info(fi+" "+po,fo),oo._tryAddCustomEvent(po,fo)}oo._linkedFlagSeen=uo})}this.receivedDecide=!0,this.startIfEnabledOrStop()}},{key:"_setupSampling",value:function(){var ue=this;F(this.sampleRate)&&I(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId(function(eo){ue.makeSamplingDecision(eo)}))}},{key:"_persistDecideResponse",value:function(ue){if(this.instance.persistence){var eo=this.instance.persistence,no=function(){var ro,oo,io,ao,so,lo,co,uo,fo=(ro=ue.sessionRecording)===null||ro===void 0?void 0:ro.sampleRate,po=R(fo)?null:parseFloat(fo),ho=(oo=ue.sessionRecording)===null||oo===void 0?void 0:oo.minimumDurationMilliseconds;eo.register((o(uo={},_e,!!ue.sessionRecording),o(uo,me,(io=ue.sessionRecording)===null||io===void 0?void 0:io.consoleLogRecordingEnabled),o(uo,ye,t$1({capturePerformance:ue.capturePerformance},(ao=ue.sessionRecording)===null||ao===void 0?void 0:ao.networkPayloadCapture)),o(uo,be,{enabled:(so=ue.sessionRecording)===null||so===void 0?void 0:so.recordCanvas,fps:(lo=ue.sessionRecording)===null||lo===void 0?void 0:lo.canvasFps,quality:(co=ue.sessionRecording)===null||co===void 0?void 0:co.canvasQuality}),o(uo,ke,po),o(uo,we,w$1(ho)?null:ho),uo))};no(),this.sessionManager.onSessionId(no)}}},{key:"log",value:function(ue){var eo,no=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"log";(eo=this.instance.sessionRecording)===null||eo===void 0||eo.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:no,trace:[],payload:[JSON.stringify(ue)]}},timestamp:K()})}},{key:"_startCapture",value:function(){var ue=this;w$1(Object.assign)||this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut()||(this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),this.rrwebRecord?this._onScriptLoaded():this.instance.requestRouter.loadScript("/static/recorder.js?v=".concat(f.LIB_VERSION),function(eo){if(eo)return G.error(fi+" could not load recorder.js",eo);ue._onScriptLoaded()}))}},{key:"isInteractiveEvent",value:function(ue){var eo;return ue.type===3&&di.indexOf((eo=ue.data)===null||eo===void 0?void 0:eo.source)!==-1}},{key:"_updateWindowAndSessionIds",value:function(ue){var eo=this.isInteractiveEvent(ue);eo||this.isIdle||ue.timestamp-this._lastActivityTimestamp>3e5&&(this.isIdle=!0,clearTimeout(this._fullSnapshotTimer),this._flushBuffer());var no=!1;if(eo&&(this._lastActivityTimestamp=ue.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:ue.type}),no=!0)),!this.isIdle){var ro=this.sessionManager.checkAndGetSessionAndWindowId(!eo,ue.timestamp),oo=ro.windowId,io=ro.sessionId,ao=this.sessionId!==io,so=this.windowId!==oo;this.windowId=oo,this.sessionId=io,(no||[wn,Sn].indexOf(ue.type)===-1&&(so||ao||w$1(this._fullSnapshotTimer)))&&this._tryTakeFullSnapshot()}}},{key:"_tryRRWebMethod",value:function(ue){try{return ue.rrwebMethod(),!0}catch(eo){return this.queuedRRWebEvents.length<10?this.queuedRRWebEvents.push({enqueuedAt:ue.enqueuedAt||Date.now(),attempt:ue.attempt++,rrwebMethod:ue.rrwebMethod}):G.warn(fi+" could not emit queued rrweb event.",eo,ue),!1}}},{key:"_tryAddCustomEvent",value:function(ue,eo){var no=this;return this._tryRRWebMethod(hi(function(){return no.rrwebRecord.addCustomEvent(ue,eo)}))}},{key:"_tryTakeFullSnapshot",value:function(){var ue=this;return this._tryRRWebMethod(hi(function(){return ue.rrwebRecord.takeFullSnapshot()}))}},{key:"_onScriptLoaded",value:function(){for(var ue,eo=this,no={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},ro=this.instance.config.session_recording,oo=0,io=Object.entries(ro||{});oo<io.length;oo++){var ao=u(io[oo],2),so=ao[0],lo=ao[1];so in no&&(so==="maskInputOptions"?no.maskInputOptions=t$1({password:!0},lo):no[so]=lo)}if(this.canvasRecording&&this.canvasRecording.enabled&&(no.recordCanvas=!0,no.sampling={canvas:this.canvasRecording.fps},no.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),this.rrwebRecord){this.mutationRateLimiter=(ue=this.mutationRateLimiter)!==null&&ue!==void 0?ue:new li(this.rrwebRecord,{onBlockedNode:function(uo,fo){var po="Too many mutations on node '".concat(uo,"'. Rate limiting. This could be due to SVG animations or something similar");G.info(po,{node:fo}),eo.log(fi+" "+po,"warn")}});var co=this._gatherRRWebPlugins();this.stopRrweb=this.rrwebRecord(t$1({emit:function(uo){eo.onRRwebEmit(uo)},plugins:co},no)),this.instance._addCaptureHook(function(uo){try{if(uo==="$pageview"){var fo=T?eo._maskUrl(T.location.href):"";if(!fo)return;eo._tryAddCustomEvent("$pageview",{href:fo})}}catch(po){G.error("Could not add $pageview to rrweb session",po)}}),this._lastActivityTimestamp=Date.now(),this.isIdle=!1,this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:no,activePlugins:co.map(function(uo){return uo==null?void 0:uo.name})}),this._tryAddCustomEvent("$posthog_config",{config:this.instance.config})}else G.error(fi+"onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}},{key:"_scheduleFullSnapshot",value:function(){var ue=this;if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!this.isIdle){var eo=this.fullSnapshotIntervalMillis;eo&&(this._fullSnapshotTimer=setInterval(function(){ue._tryTakeFullSnapshot()},eo))}}},{key:"_gatherRRWebPlugins",value:function(){var ue=[];return U.rrwebConsoleRecord&&this.isConsoleLogCaptureEnabled&&ue.push(U.rrwebConsoleRecord.getRecordConsolePlugin()),this.networkPayloadCapture&&y(U.getRecordNetworkPlugin)&&(!vt.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?ue.push(U.getRecordNetworkPlugin(ui(this.instance.config,this.networkPayloadCapture))):G.info(fi+" NetworkCapture not started because we are on localhost.")),ue}},{key:"onRRwebEmit",value:function(ue){if(this._processQueuedEvents(),ue&&b(ue)){if(ue.type===In.Meta){var eo=this._maskUrl(ue.data.href);if(this._lastHref=eo,!eo)return;ue.data.href=eo}else this._pageViewFallBack();ue.type===In.FullSnapshot&&this._scheduleFullSnapshot();var no=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(ue):ue;if(no){var ro=function(ao){var so=ao;if(so&&b(so)&&so.type===6&&b(so.data)&&so.data.plugin==="rrweb/console@1"){so.data.payload.payload.length>10&&(so.data.payload.payload=so.data.payload.payload.slice(0,10),so.data.payload.payload.push("...[truncated]"));for(var lo=[],co=0;co<so.data.payload.payload.length;co++)so.data.payload.payload[co]&&so.data.payload.payload[co].length>2e3?lo.push(so.data.payload.payload[co].slice(0,2e3)+"...[truncated]"):lo.push(so.data.payload.payload[co]);return so.data.payload.payload=lo,ao}return ao}(no),oo=kn(ro);if(this._updateWindowAndSessionIds(ro),!this.isIdle||ro.type===In.Custom){var io={$snapshot_bytes:oo,$snapshot_data:ro,$session_id:this.sessionId,$window_id:this.windowId};this.status!=="disabled"?this._captureSnapshotBuffered(io):this.clearBuffer()}}}}},{key:"_pageViewFallBack",value:function(){if(!this.instance.config.capture_pageview&&T){var ue=this._maskUrl(T.location.href);this._lastHref!==ue&&(this._tryAddCustomEvent("$url_changed",{href:ue}),this._lastHref=ue)}}},{key:"_processQueuedEvents",value:function(){var ue=this;if(this.queuedRRWebEvents.length){var eo=l(this.queuedRRWebEvents);this.queuedRRWebEvents=[],eo.forEach(function(no){Date.now()-no.enqueuedAt<=2e3&&ue._tryRRWebMethod(no)})}}},{key:"_maskUrl",value:function(ue){var eo=this.instance.config.session_recording;if(eo.maskNetworkRequestFn){var no,ro={url:ue};return(no=ro=eo.maskNetworkRequestFn(ro))===null||no===void 0?void 0:no.url}return ue}},{key:"clearBuffer",value:function(){return this.buffer={size:0,data:[],sessionId:this.sessionId,windowId:this.windowId},this.buffer}},{key:"_flushBuffer",value:function(){var ue=this;this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var eo=this.minimumDuration,no=this.sessionDuration,ro=F(no)&&no>=0,oo=F(eo)&&ro&&no<eo;return this.status==="buffering"||oo?(this.flushBufferTimer=setTimeout(function(){ue._flushBuffer()},2e3),this.buffer):(this.buffer.data.length>0&&En(this.buffer).forEach(function(io){ue._captureSnapshot({$snapshot_bytes:io.size,$snapshot_data:io.data,$session_id:io.sessionId,$window_id:io.windowId})}),this.clearBuffer())}},{key:"_captureSnapshotBuffered",value:function(ue){var eo,no=this,ro=2+(((eo=this.buffer)===null||eo===void 0?void 0:eo.data.length)||0);(this.buffer.size+ue.$snapshot_bytes+ro>943718.4||this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),this.buffer.size+=ue.$snapshot_bytes,this.buffer.data.push(ue.$snapshot_data),this.flushBufferTimer||(this.flushBufferTimer=setTimeout(function(){no._flushBuffer()},2e3))}},{key:"_captureSnapshot",value:function(ue){this.instance.capture("$snapshot",ue,{_url:this.instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}},{key:"overrideLinkedFlag",value:function(){this._linkedFlagSeen=!0}}]),to}(),pi=function(){function to(ue){i$1(this,to),this.instance=ue,this.instance.decideEndpointWasHit=this.instance._hasBootstrappedFeatureFlags()}return s(to,[{key:"call",value:function(){var ue=this,eo={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),person_properties:this.instance.get_property(Fe),group_properties:this.instance.get_property(xe),disable_flags:this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load||void 0};this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:eo,compression:this.instance.config.disable_compression?void 0:re.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:function(no){return ue.parseDecideResponse(no.json)}})}},{key:"parseDecideResponse",value:function(ue){var eo=this;this.instance.featureFlags.setReloadingPaused(!1),this.instance.featureFlags._startReloadTimer();var no=!ue;if(this.instance.config.advanced_disable_feature_flags_on_first_load||this.instance.config.advanced_disable_feature_flags||this.instance.featureFlags.receivedFeatureFlags(ue??{},no),no)G.error("Failed to fetch feature flags from PostHog.");else{if(!L||!L.body)return G.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(function(){eo.parseDecideResponse(ue)},500);if(this.instance._afterDecideResponse(ue),ue.siteApps)if(this.instance.config.opt_in_site_apps){var ro,oo=h(ue.siteApps);try{var io=function(){var ao=ro.value,so=ao.id,lo=ao.url,co=eo.instance.requestRouter.endpointFor("api",lo);U["__$$ph_site_app_".concat(so)]=eo.instance,eo.instance.requestRouter.loadScript(co,function(uo){if(uo)return G.error("Error while initializing PostHog app with config id ".concat(so),uo)})};for(oo.s();!(ro=oo.n()).done;)io()}catch(ao){oo.e(ao)}finally{oo.f()}}else ue.siteApps.length>0&&G.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}]),to}(),gi=T!=null&&T.location?yt(T.location.hash,"__posthog")||yt(location.hash,"state"):null,_i="_postHogToolbarParams";(function(to){to[to.UNINITIALIZED=0]="UNINITIALIZED",to[to.LOADING=1]="LOADING",to[to.LOADED=2]="LOADED"})(ai||(ai={}));var mi=function(){function to(ue){i$1(this,to),this.instance=ue}return s(to,[{key:"setToolbarState",value:function(ue){U.ph_toolbar_state=ue}},{key:"getToolbarState",value:function(){var ue;return(ue=U.ph_toolbar_state)!==null&&ue!==void 0?ue:ai.UNINITIALIZED}},{key:"maybeLoadToolbar",value:function(){var ue,eo,no=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,ro=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,oo=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!T||!L)return!1;no=(ue=no)!==null&&ue!==void 0?ue:T.location,oo=(eo=oo)!==null&&eo!==void 0?eo:T.history;try{if(!ro){try{T.localStorage.setItem("test","test"),T.localStorage.removeItem("test")}catch{return!1}ro=T==null?void 0:T.localStorage}var io,ao=gi||yt(no.hash,"__posthog")||yt(no.hash,"state"),so=ao?Z(function(){return JSON.parse(atob(decodeURIComponent(ao)))})||Z(function(){return JSON.parse(decodeURIComponent(ao))}):null;return so&&so.action==="ph_authorize"?((io=so).source="url",io&&Object.keys(io).length>0&&(so.desiredHash?no.hash=so.desiredHash:oo?oo.replaceState(oo.state,"",no.pathname+no.search):no.hash="")):((io=JSON.parse(ro.getItem(_i)||"{}")).source="localstorage",delete io.userIntent),!(!io.token||this.instance.config.token!==io.token)&&(this.loadToolbar(io),!0)}catch{return!1}}},{key:"_callLoadToolbar",value:function(ue){(U.ph_load_toolbar||U.ph_load_editor)(ue,this.instance)}},{key:"loadToolbar",value:function(ue){var eo=this,no=!(L==null||!L.getElementById(Ne));if(!T||no)return!1;var ro=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,oo=t$1(t$1({token:this.instance.config.token},ue),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},ro?{instrument:!1}:{});if(T.localStorage.setItem(_i,JSON.stringify(t$1(t$1({},oo),{},{source:void 0}))),this.getToolbarState()===ai.LOADED)this._callLoadToolbar(oo);else if(this.getToolbarState()===ai.UNINITIALIZED){this.setToolbarState(ai.LOADING);var io=3e5,ao=Math.floor(Date.now()/io)*io;this.instance.requestRouter.loadScript("/static/toolbar.js?t=".concat(ao),function(so){if(so)return G.error("Failed to load toolbar",so),void eo.setToolbarState(ai.UNINITIALIZED);eo.setToolbarState(ai.LOADED),eo._callLoadToolbar(oo)}),oe(T,"turbolinks:load",function(){eo.setToolbarState(ai.UNINITIALIZED),eo.loadToolbar(oo)})}return!0}},{key:"_loadEditor",value:function(ue){return this.loadToolbar(ue)}},{key:"maybeLoadEditor",value:function(){var ue=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,eo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,no=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;return this.maybeLoadToolbar(ue,eo,no)}}]),to}(),yi=function(){function to(ue){i$1(this,to),o(this,"isPaused",!0),o(this,"queue",[]),o(this,"flushTimeoutMs",3e3),this.sendRequest=ue}return s(to,[{key:"enqueue",value:function(ue){this.queue.push(ue),this.flushTimeout||this.setFlushTimeout()}},{key:"unload",value:function(){var ue=this;this.clearFlushTimeout();var eo=this.queue.length>0?this.formatQueue():{},no=Object.values(eo);[].concat(l(no.filter(function(ro){return ro.url.indexOf("/e")===0})),l(no.filter(function(ro){return ro.url.indexOf("/e")!==0}))).map(function(ro){ue.sendRequest(t$1(t$1({},ro),{},{transport:"sendBeacon"}))})}},{key:"enable",value:function(){this.isPaused=!1,this.setFlushTimeout()}},{key:"setFlushTimeout",value:function(){var ue=this;this.isPaused||(this.flushTimeout=setTimeout(function(){if(ue.clearFlushTimeout(),ue.queue.length>0){var eo=ue.formatQueue(),no=function(oo){var io=eo[oo],ao=new Date().getTime();io.data&&m(io.data)&&Q(io.data,function(so){so.offset=Math.abs(so.timestamp-ao),delete so.timestamp}),ue.sendRequest(io)};for(var ro in eo)no(ro)}},this.flushTimeoutMs))}},{key:"clearFlushTimeout",value:function(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}},{key:"formatQueue",value:function(){var ue={};return Q(this.queue,function(eo){var no,ro=eo,oo=(ro?ro.batchKey:null)||ro.url;w$1(ue[oo])&&(ue[oo]=t$1(t$1({},ro),{},{data:[]})),(no=ue[oo].data)===null||no===void 0||no.push(ro.data)}),this.queue=[],ue}}]),to}(),bi=Uint8Array,ki=Uint16Array,wi=Uint32Array,Si=new bi([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]),Ei=new bi([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]),Ii=new bi([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ri=function(to,ue){for(var eo=new ki(31),no=0;no<31;++no)eo[no]=ue+=1<<to[no-1];var ro=new wi(eo[30]);for(no=1;no<30;++no)for(var oo=eo[no];oo<eo[no+1];++oo)ro[oo]=oo-eo[no]<<5|no;return[eo,ro]},Fi=Ri(Si,2),xi=Fi[0],Pi=Fi[1];xi[28]=258,Pi[258]=28;for(var Ti=Ri(Ei,0)[1],Ci=new ki(32768),$i=0;$i<32768;++$i){var Oi=(43690&$i)>>>1|(21845&$i)<<1;Oi=(61680&(Oi=(52428&Oi)>>>2|(13107&Oi)<<2))>>>4|(3855&Oi)<<4,Ci[$i]=((65280&Oi)>>>8|(255&Oi)<<8)>>>1}var Mi=function(to,ue,eo){for(var no=to.length,ro=0,oo=new ki(ue);ro<no;++ro)++oo[to[ro]-1];var io,ao=new ki(ue);for(ro=0;ro<ue;++ro)ao[ro]=ao[ro-1]+oo[ro-1]<<1;if(eo){io=new ki(1<<ue);var so=15-ue;for(ro=0;ro<no;++ro)if(to[ro])for(var lo=ro<<4|to[ro],co=ue-to[ro],uo=ao[to[ro]-1]++<<co,fo=uo|(1<<co)-1;uo<=fo;++uo)io[Ci[uo]>>>so]=lo}else for(io=new ki(no),ro=0;ro<no;++ro)io[ro]=Ci[ao[to[ro]-1]++]>>>15-to[ro];return io},Ai$1=new bi(288);for($i=0;$i<144;++$i)Ai$1[$i]=8;for($i=144;$i<256;++$i)Ai$1[$i]=9;for($i=256;$i<280;++$i)Ai$1[$i]=7;for($i=280;$i<288;++$i)Ai$1[$i]=8;var Li=new bi(32);for($i=0;$i<32;++$i)Li[$i]=5;var Di=Mi(Ai$1,9,0),qi=Mi(Li,5,0),Ni=function(to){return(to/8>>0)+(7&to&&1)},Bi=function(to,ue,eo){(ue==null||ue<0)&&(ue=0),(eo==null||eo>to.length)&&(eo=to.length);var no=new(to instanceof ki?ki:to instanceof wi?wi:bi)(eo-ue);return no.set(to.subarray(ue,eo)),no},Hi=function(to,ue,eo){eo<<=7&ue;var no=ue/8>>0;to[no]|=eo,to[no+1]|=eo>>>8},Ui=function(to,ue,eo){eo<<=7&ue;var no=ue/8>>0;to[no]|=eo,to[no+1]|=eo>>>8,to[no+2]|=eo>>>16},ji=function(to,ue){for(var eo=[],no=0;no<to.length;++no)to[no]&&eo.push({s:no,f:to[no]});var ro=eo.length,oo=eo.slice();if(!ro)return[new bi(0),0];if(ro==1){var io=new bi(eo[0].s+1);return io[eo[0].s]=1,[io,1]}eo.sort(function(ko,So){return ko.f-So.f}),eo.push({s:-1,f:25001});var ao=eo[0],so=eo[1],lo=0,co=1,uo=2;for(eo[0]={s:-1,f:ao.f+so.f,l:ao,r:so};co!=ro-1;)ao=eo[eo[lo].f<eo[uo].f?lo++:uo++],so=eo[lo!=co&&eo[lo].f<eo[uo].f?lo++:uo++],eo[co++]={s:-1,f:ao.f+so.f,l:ao,r:so};var fo=oo[0].s;for(no=1;no<ro;++no)oo[no].s>fo&&(fo=oo[no].s);var po=new ki(fo+1),ho=Gi(eo[co-1],po,0);if(ho>ue){no=0;var _o=0,go=ho-ue,bo=1<<go;for(oo.sort(function(ko,So){return po[So.s]-po[ko.s]||ko.f-So.f});no<ro;++no){var vo=oo[no].s;if(!(po[vo]>ue))break;_o+=bo-(1<<ho-po[vo]),po[vo]=ue}for(_o>>>=go;_o>0;){var yo=oo[no].s;po[yo]<ue?_o-=1<<ue-po[yo]++-1:++no}for(;no>=0&&_o;--no){var wo=oo[no].s;po[wo]==ue&&(--po[wo],++_o)}ho=ue}return[new bi(po),ho]},Gi=function to(ue,eo,no){return ue.s==-1?Math.max(to(ue.l,eo,no+1),to(ue.r,eo,no+1)):eo[ue.s]=no},Wi=function(to){for(var ue=to.length;ue&&!to[--ue];);for(var eo=new ki(++ue),no=0,ro=to[0],oo=1,io=function(so){eo[no++]=so},ao=1;ao<=ue;++ao)if(to[ao]==ro&&ao!=ue)++oo;else{if(!ro&&oo>2){for(;oo>138;oo-=138)io(32754);oo>2&&(io(oo>10?oo-11<<5|28690:oo-3<<5|12305),oo=0)}else if(oo>3){for(io(ro),--oo;oo>6;oo-=6)io(8304);oo>2&&(io(oo-3<<5|8208),oo=0)}for(;oo--;)io(ro);oo=1,ro=to[ao]}return[eo.subarray(0,no),ue]},Vi=function(to,ue){for(var eo=0,no=0;no<ue.length;++no)eo+=to[no]*ue[no];return eo},zi=function(to,ue,eo){var no=eo.length,ro=Ni(ue+2);to[ro]=255&no,to[ro+1]=no>>>8,to[ro+2]=255^to[ro],to[ro+3]=255^to[ro+1];for(var oo=0;oo<no;++oo)to[ro+oo+4]=eo[oo];return 8*(ro+4+no)},Qi=function(to,ue,eo,no,ro,oo,io,ao,so,lo,co){Hi(ue,co++,eo),++ro[256];for(var uo=ji(ro,15),fo=uo[0],po=uo[1],ho=ji(oo,15),_o=ho[0],go=ho[1],bo=Wi(fo),vo=bo[0],yo=bo[1],wo=Wi(_o),ko=wo[0],So=wo[1],Eo=new ki(19),Io=0;Io<vo.length;++Io)Eo[31&vo[Io]]++;for(Io=0;Io<ko.length;++Io)Eo[31&ko[Io]]++;for(var Ao=ji(Eo,7),To=Ao[0],zo=Ao[1],Vo=19;Vo>4&&!To[Ii[Vo-1]];--Vo);var Fo,Po,Ro,Do,qo=lo+5<<3,Uo=Vi(ro,Ai$1)+Vi(oo,Li)+io,jo=Vi(ro,fo)+Vi(oo,_o)+io+14+3*Vo+Vi(Eo,To)+(2*Eo[16]+3*Eo[17]+7*Eo[18]);if(qo<=Uo&&qo<=jo)return zi(ue,co,to.subarray(so,so+lo));if(Hi(ue,co,1+(jo<Uo)),co+=2,jo<Uo){Fo=Mi(fo,po,0),Po=fo,Ro=Mi(_o,go,0),Do=_o;var Zo=Mi(To,zo,0);for(Hi(ue,co,yo-257),Hi(ue,co+5,So-1),Hi(ue,co+10,Vo-4),co+=14,Io=0;Io<Vo;++Io)Hi(ue,co+3*Io,To[Ii[Io]]);co+=3*Vo;for(var Yo=[vo,ko],Xo=0;Xo<2;++Xo){var Qo=Yo[Xo];for(Io=0;Io<Qo.length;++Io){var Jo=31&Qo[Io];Hi(ue,co,Zo[Jo]),co+=To[Jo],Jo>15&&(Hi(ue,co,Qo[Io]>>>5&127),co+=Qo[Io]>>>12)}}}else Fo=Di,Po=Ai$1,Ro=qi,Do=Li;for(Io=0;Io<ao;++Io)if(no[Io]>255){Jo=no[Io]>>>18&31,Ui(ue,co,Fo[Jo+257]),co+=Po[Jo+257],Jo>7&&(Hi(ue,co,no[Io]>>>23&31),co+=Si[Jo]);var ra=31&no[Io];Ui(ue,co,Ro[ra]),co+=Do[ra],ra>3&&(Ui(ue,co,no[Io]>>>5&8191),co+=Ei[ra])}else Ui(ue,co,Fo[no[Io]]),co+=Po[no[Io]];return Ui(ue,co,Fo[256]),co+Po[256]},Ji=new wi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Yi=new bi(0),Xi=function(){for(var to=new wi(256),ue=0;ue<256;++ue){for(var eo=ue,no=9;--no;)eo=(1&eo&&3988292384)^eo>>>1;to[ue]=eo}return to}(),Ki=function(to,ue,eo,no,ro){return function(oo,io,ao,so,lo,co){var uo=oo.length,fo=new bi(so+uo+5*(1+Math.floor(uo/7e3))+lo),po=fo.subarray(so,fo.length-lo),ho=0;if(!io||uo<8)for(var _o=0;_o<=uo;_o+=65535){var go=_o+65535;go<uo?ho=zi(po,ho,oo.subarray(_o,go)):(po[_o]=co,ho=zi(po,ho,oo.subarray(_o,uo)))}else{for(var bo=Ji[io-1],vo=bo>>>13,yo=8191&bo,wo=(1<<ao)-1,ko=new ki(32768),So=new ki(wo+1),Eo=Math.ceil(ao/3),Io=2*Eo,Ao=function(Ba){return(oo[Ba]^oo[Ba+1]<<Eo^oo[Ba+2]<<Io)&wo},To=new wi(25e3),zo=new ki(288),Vo=new ki(32),Fo=0,Po=0,Ro=(_o=0,0),Do=0,qo=0;_o<uo;++_o){var Uo=Ao(_o),jo=32767&_o,Zo=So[Uo];if(ko[jo]=Zo,So[Uo]=jo,Do<=_o){var Yo=uo-_o;if((Fo>7e3||Ro>24576)&&Yo>423){ho=Qi(oo,po,0,To,zo,Vo,Po,Ro,qo,_o-qo,ho),Ro=Fo=Po=0,qo=_o;for(var Xo=0;Xo<286;++Xo)zo[Xo]=0;for(Xo=0;Xo<30;++Xo)Vo[Xo]=0}var Qo=2,Jo=0,ra=yo,Ko=jo-Zo&32767;if(Yo>2&&Uo==Ao(_o-Ko))for(var ia=Math.min(vo,Yo)-1,ea=Math.min(32767,_o),sa=Math.min(258,Yo);Ko<=ea&&--ra&&jo!=Zo;){if(oo[_o+Qo]==oo[_o+Qo-Ko]){for(var Ea=0;Ea<sa&&oo[_o+Ea]==oo[_o+Ea-Ko];++Ea);if(Ea>Qo){if(Qo=Ea,Jo=Ko,Ea>ia)break;var da=Math.min(Ko,Ea-2),ya=0;for(Xo=0;Xo<da;++Xo){var Aa=_o-Ko+Xo+32768&32767,ma=Aa-ko[Aa]+32768&32767;ma>ya&&(ya=ma,Zo=Aa)}}}Ko+=(jo=Zo)-(Zo=ko[jo])+32768&32767}if(Jo){To[Ro++]=268435456|Pi[Qo]<<18|Ti[Jo];var Da=31&Pi[Qo],Na=31&Ti[Jo];Po+=Si[Da]+Ei[Na],++zo[257+Da],++Vo[Na],Do=_o+Qo,++Fo}else To[Ro++]=oo[_o],++zo[oo[_o]]}}ho=Qi(oo,po,co,To,zo,Vo,Po,Ro,qo,_o-qo,ho),co||(ho=zi(po,ho,Yi))}return Bi(fo,0,so+Ni(ho)+lo)}(to,ue.level==null?6:ue.level,ue.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(to.length)))):12+ue.mem,eo,no,!ro)},Zi=function(to,ue,eo){for(;eo;++ue)to[ue]=eo,eo>>>=8};function er(to,ue){ue===void 0&&(ue={});var eo=function(){var ao=4294967295;return{p:function(so){for(var lo=ao,co=0;co<so.length;++co)lo=Xi[255&lo^so[co]]^lo>>>8;ao=lo},d:function(){return 4294967295^ao}}}(),no=to.length;eo.p(to);var ro,oo=Ki(to,ue,10+((ro=ue).filename&&ro.filename.length+1||0),8),io=oo.length;return function(ao,so){var lo=so.filename;if(ao[0]=31,ao[1]=139,ao[2]=8,ao[8]=so.level<2?4:so.level==9?2:0,ao[9]=3,so.mtime!=0&&Zi(ao,4,Math.floor(new Date(so.mtime||Date.now())/1e3)),lo){ao[3]=8;for(var co=0;co<=lo.length;++co)ao[co+10]=lo.charCodeAt(co)}}(oo,ue),Zi(oo,io-8,eo.d()),Zi(oo,io-4,no),oo}var tr=!!N||!!q,nr="text/plain",ir=function(to,ue){var eo=u(to.split("?"),2),no=eo[0],ro=eo[1],oo=t$1({},ue);ro==null||ro.split("&").forEach(function(ao){var so=u(ao.split("="),1)[0];delete oo[so]});var io=_t(oo);return io=io?(ro?ro+"&":"")+io:ro,"".concat(no,"?").concat(io)},rr=function(to){return"data="+encodeURIComponent(typeof to=="string"?to:JSON.stringify(to))},sr=function(to){var ue=to.data,eo=to.compression;if(ue){if(eo===re.GZipJS){var no=er(function(oo,io){var ao=oo.length;if(!io&&typeof TextEncoder<"u")return new TextEncoder().encode(oo);for(var so=new bi(oo.length+(oo.length>>>1)),lo=0,co=function(ho){so[lo++]=ho},uo=0;uo<ao;++uo){if(lo+5>so.length){var fo=new bi(lo+8+(ao-uo<<1));fo.set(so),so=fo}var po=oo.charCodeAt(uo);po<128||io?co(po):po<2048?(co(192|po>>>6),co(128|63&po)):po>55295&&po<57344?(co(240|(po=65536+(1047552&po)|1023&oo.charCodeAt(++uo))>>>18),co(128|po>>>12&63),co(128|po>>>6&63),co(128|63&po)):(co(224|po>>>12),co(128|po>>>6&63),co(128|63&po))}return Bi(so,0,lo)}(JSON.stringify(ue)),{mtime:0});return{contentType:nr,body:new Blob([no],{type:nr})}}if(eo===re.Base64){var ro=function(oo){var io,ao,so,lo,co,uo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",fo=0,po=0,ho="",_o=[];if(!oo)return oo;oo=se(oo);do io=(co=oo.charCodeAt(fo++)<<16|oo.charCodeAt(fo++)<<8|oo.charCodeAt(fo++))>>18&63,ao=co>>12&63,so=co>>6&63,lo=63&co,_o[po++]=uo.charAt(io)+uo.charAt(ao)+uo.charAt(so)+uo.charAt(lo);while(fo<oo.length);switch(ho=_o.join(""),oo.length%3){case 1:ho=ho.slice(0,-2)+"==";break;case 2:ho=ho.slice(0,-1)+"="}return ho}(JSON.stringify(ue));return{contentType:"application/x-www-form-urlencoded",body:rr(ro)}}return{contentType:"application/json",body:JSON.stringify(ue)}}},or=[];N&&or.push({transport:"XHR",method:function(to){var ue,eo=new N;eo.open(to.method||"GET",to.url,!0);var no=(ue=sr(to))!==null&&ue!==void 0?ue:{},ro=no.contentType,oo=no.body;Q(to.headers,function(io,ao){eo.setRequestHeader(ao,io)}),ro&&eo.setRequestHeader("Content-Type",ro),to.timeout&&(eo.timeout=to.timeout),eo.withCredentials=!0,eo.onreadystatechange=function(){if(eo.readyState===4){var io,ao={statusCode:eo.status,text:eo.responseText};if(eo.status===200)try{ao.json=JSON.parse(eo.responseText)}catch{}(io=to.callback)===null||io===void 0||io.call(to,ao)}},eo.send(oo)}}),q&&or.push({transport:"fetch",method:function(to){var ue,eo,no=(ue=sr(to))!==null&&ue!==void 0?ue:{},ro=no.contentType,oo=no.body,io=new Headers;Q(to.headers,function(co,uo){io.append(uo,co)}),ro&&io.append("Content-Type",ro);var ao=to.url,so=null;if(B){var lo=new B;so={signal:lo.signal,timeout:setTimeout(function(){return lo.abort()},to.timeout)}}q(ao,{method:(to==null?void 0:to.method)||"GET",headers:io,keepalive:to.method==="POST",body:oo,signal:(eo=so)===null||eo===void 0?void 0:eo.signal}).then(function(co){return co.text().then(function(uo){var fo,po={statusCode:co.status,text:uo};if(co.status===200)try{po.json=JSON.parse(uo)}catch(ho){G.error(ho)}(fo=to.callback)===null||fo===void 0||fo.call(to,po)})}).catch(function(co){var uo;G.error(co),(uo=to.callback)===null||uo===void 0||uo.call(to,{statusCode:0,text:co})}).finally(function(){return so?clearTimeout(so.timeout):null})}}),A!=null&&A.sendBeacon&&or.push({transport:"sendBeacon",method:function(to){var ue=ir(to.url,{beacon:"1"});try{var eo,no=(eo=sr(to))!==null&&eo!==void 0?eo:{},ro=no.contentType,oo=no.body,io=typeof oo=="string"?new Blob([oo],{type:ro}):oo;A.sendBeacon(ue,io)}catch{}}});var ar=["retriesPerformedSoFar"],ur,lr=function(){function to(ue){var eo=this;i$1(this,to),o(this,"isPolling",!1),o(this,"pollIntervalMs",3e3),o(this,"queue",[]),this.instance=ue,this.queue=[],this.areWeOnline=!0,!w$1(T)&&"onLine"in T.navigator&&(this.areWeOnline=T.navigator.onLine,T.addEventListener("online",function(){eo.areWeOnline=!0,eo.flush()}),T.addEventListener("offline",function(){eo.areWeOnline=!1}))}return s(to,[{key:"retriableRequest",value:function(ue){var eo=this,no=ue.retriesPerformedSoFar,ro=a(ue,ar);F(no)&&no>0&&(ro.url=ir(ro.url,{retry_count:no})),this.instance._send_request(t$1(t$1({},ro),{},{callback:function(oo){var io;oo.statusCode!==200&&(oo.statusCode<400||oo.statusCode>=500)&&(no??0)<10?eo.enqueue(t$1({retriesPerformedSoFar:no},ro)):(io=ro.callback)===null||io===void 0||io.call(ro,oo)}}))}},{key:"enqueue",value:function(ue){var eo=ue.retriesPerformedSoFar||0;ue.retriesPerformedSoFar=eo+1;var no=function(io){var ao=3e3*Math.pow(2,io),so=ao/2,lo=Math.min(18e5,ao),co=(Math.random()-.5)*(lo-so);return Math.ceil(lo+co)}(eo),ro=Date.now()+no;this.queue.push({retryAt:ro,requestOptions:ue});var oo="Enqueued failed request for retry in ".concat(no);navigator.onLine||(oo+=" (Browser is offline)"),G.warn(oo),this.isPolling||(this.isPolling=!0,this.poll())}},{key:"poll",value:function(){var ue=this;this.poller&&clearTimeout(this.poller),this.poller=setTimeout(function(){ue.areWeOnline&&ue.queue.length>0&&ue.flush(),ue.poll()},this.pollIntervalMs)}},{key:"flush",value:function(){var ue=Date.now(),eo=[],no=this.queue.filter(function(ao){return ao.retryAt<ue||(eo.push(ao),!1)});if(this.queue=eo,no.length>0){var ro,oo=h(no);try{for(oo.s();!(ro=oo.n()).done;){var io=ro.value.requestOptions;this.retriableRequest(io)}}catch(ao){oo.e(ao)}finally{oo.f()}}}},{key:"unload",value:function(){this.poller&&(clearTimeout(this.poller),this.poller=void 0);var ue,eo=h(this.queue);try{for(eo.s();!(ue=eo.n()).done;){var no=ue.value.requestOptions;try{this.instance._send_request(t$1(t$1({},no),{},{transport:"sendBeacon"}))}catch(ro){G.error(ro)}}}catch(ro){eo.e(ro)}finally{eo.f()}this.queue=[]}}]),to}(),cr=1800,dr=function(){function to(ue,eo,no,ro){var oo;i$1(this,to),o(this,"_sessionIdChangedHandlers",[]),this.config=ue,this.persistence=eo,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=no||Ke,this._windowIdGenerator=ro||Ke;var io=ue.persistence_name||ue.token,ao=ue.session_idle_timeout_seconds||cr;if(F(ao)?ao>cr?G.warn("session_idle_timeout_seconds cannot be greater than 30 minutes. Using 30 minutes instead."):ao<60&&G.warn("session_idle_timeout_seconds cannot be less than 60 seconds. Using 60 seconds instead."):(G.warn("session_idle_timeout_seconds must be a number. Defaulting to 30 minutes."),ao=cr),this._sessionTimeoutMs=1e3*Math.min(Math.max(ao,60),cr),this._window_id_storage_key="ph_"+io+"_window_id",this._primary_window_exists_storage_key="ph_"+io+"_primary_window_exists",this._canUseSessionStorage()){var so=ft.parse(this._window_id_storage_key),lo=ft.parse(this._primary_window_exists_storage_key);so&&!lo?this._windowId=so:ft.remove(this._window_id_storage_key),ft.set(this._primary_window_exists_storage_key,!0)}if((oo=this.config.bootstrap)!==null&&oo!==void 0&&oo.sessionID)try{var co=function(uo){var fo=uo.replace(/-/g,"");if(fo.length!==32)throw new Error("Not a valid UUID");if(fo[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(fo.substring(0,12),16)}(this.config.bootstrap.sessionID);this._setSessionId(this.config.bootstrap.sessionID,new Date().getTime(),co)}catch(uo){G.error("Invalid sessionID in bootstrap",uo)}this._listenToReloadWindow()}return s(to,[{key:"onSessionId",value:function(ue){var eo=this;return w$1(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(ue),this._sessionId&&ue(this._sessionId,this._windowId),function(){eo._sessionIdChangedHandlers=eo._sessionIdChangedHandlers.filter(function(no){return no!==ue})}}},{key:"_canUseSessionStorage",value:function(){return this.config.persistence!=="memory"&&!this.persistence.disabled&&ft.is_supported()}},{key:"_setWindowId",value:function(ue){ue!==this._windowId&&(this._windowId=ue,this._canUseSessionStorage()&&ft.set(this._window_id_storage_key,ue))}},{key:"_getWindowId",value:function(){return this._windowId?this._windowId:this._canUseSessionStorage()?ft.parse(this._window_id_storage_key):null}},{key:"_setSessionId",value:function(ue,eo,no){ue===this._sessionId&&eo===this._sessionActivityTimestamp&&no===this._sessionStartTimestamp||(this._sessionStartTimestamp=no,this._sessionActivityTimestamp=eo,this._sessionId=ue,this.persistence.register(o({},Se,[eo,ue,no])))}},{key:"_getSessionId",value:function(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var ue=this.persistence.props[Se];return m(ue)&&ue.length===2&&ue.push(ue[0]),ue||[0,null,0]}},{key:"resetSessionId",value:function(){this._setSessionId(null,null,null)}},{key:"_listenToReloadWindow",value:function(){var ue=this;T==null||T.addEventListener("beforeunload",function(){ue._canUseSessionStorage()&&ft.remove(ue._primary_window_exists_storage_key)})}},{key:"checkAndGetSessionAndWindowId",value:function(){var ue=arguments.length>0&&arguments[0]!==void 0&&arguments[0],eo=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||new Date().getTime(),no=u(this._getSessionId(),3),ro=no[0],oo=no[1],io=no[2],ao=this._getWindowId(),so=io&&io>0&&Math.abs(eo-io)>864e5,lo=!1,co=!oo,uo=!ue&&Math.abs(eo-ro)>this._sessionTimeoutMs;co||uo||so?(oo=this._sessionIdGenerator(),ao=this._windowIdGenerator(),G.info("[SessionId] new session ID generated",{sessionId:oo,windowId:ao,changeReason:{noSessionId:co,activityTimeout:uo,sessionPastMaximumLength:so}}),io=eo,lo=!0):ao||(ao=this._windowIdGenerator(),lo=!0);var fo=ro===0||!ue||so?eo:ro,po=io===0?new Date().getTime():io;return this._setWindowId(ao),this._setSessionId(oo,fo,po),lo&&this._sessionIdChangedHandlers.forEach(function(ho){return ho(oo,ao)}),{sessionId:oo,windowId:ao,sessionStartTimestamp:po}}}]),to}();(function(to){to.US="us",to.EU="eu",to.CUSTOM="custom"})(ur||(ur={}));var hr="i.posthog.com",fr=function(){function to(ue){i$1(this,to),o(this,"_regionCache",{}),this.instance=ue}return s(to,[{key:"apiHost",get:function(){var ue=this.instance.config.api_host.trim().replace(/\/$/,"");return ue==="https://app.posthog.com"?"https://us.i.posthog.com":ue}},{key:"uiHost",get:function(){var ue,eo=(ue=this.instance.config.ui_host)===null||ue===void 0?void 0:ue.replace(/\/$/,"");return eo||(eo=this.apiHost.replace(".".concat(hr),".posthog.com")),eo==="https://app.posthog.com"?"https://us.posthog.com":eo}},{key:"region",get:function(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=ur.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=ur.EU:this._regionCache[this.apiHost]=ur.CUSTOM),this._regionCache[this.apiHost]}},{key:"endpointFor",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(eo&&(eo=eo[0]==="/"?eo:"/".concat(eo)),ue==="ui")return this.uiHost+eo;if(this.region===ur.CUSTOM)return this.apiHost+eo;var no=hr+eo;switch(ue){case"assets":return"https://".concat(this.region,"-assets.").concat(no);case"api":return"https://".concat(this.region,".").concat(no)}}},{key:"loadScript",value:function(ue,eo){if(this.instance.config.disable_external_dependency_loading)return G.warn("".concat(ue," was requested but loading of external scripts is disabled.")),eo("Loading of external scripts is disabled");var no=ue[0]==="/"?this.endpointFor("assets",ue):ue,ro=function(){if(!L)return eo("document not found");var oo=L.createElement("script");oo.type="text/javascript",oo.src=no,oo.onload=function(so){return eo(void 0,so)},oo.onerror=function(so){return eo(so)};var io,ao=L.querySelectorAll("body > script");ao.length>0?(io=ao[0].parentNode)===null||io===void 0||io.insertBefore(oo,ao[0]):L.body.appendChild(oo)};L!=null&&L.body?ro():L==null||L.addEventListener("DOMContentLoaded",ro)}}]),to}(),vr="posthog-js";function pr(to){var ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},eo=ue.organization,no=ue.projectId,ro=ue.prefix,oo=ue.severityAllowList,io=oo===void 0?["error"]:oo;return function(ao){var so,lo,co,uo,fo;if(!(io==="*"||io.includes(ao.level))||!to.__loaded)return ao;ao.tags||(ao.tags={});var po=to.requestRouter.endpointFor("ui","/project/".concat(to.config.token,"/person/").concat(to.get_distinct_id()));ao.tags["PostHog Person URL"]=po,to.sessionRecordingStarted()&&(ao.tags["PostHog Recording URL"]=to.get_session_replay_url({withTimestamp:!0}));var ho=((so=ao.exception)===null||so===void 0?void 0:so.values)||[],_o={$exception_message:((lo=ho[0])===null||lo===void 0?void 0:lo.value)||ao.message,$exception_type:(co=ho[0])===null||co===void 0?void 0:co.type,$exception_personURL:po,$exception_level:ao.level,$sentry_event_id:ao.event_id,$sentry_exception:ao.exception,$sentry_exception_message:((uo=ho[0])===null||uo===void 0?void 0:uo.value)||ao.message,$sentry_exception_type:(fo=ho[0])===null||fo===void 0?void 0:fo.type,$sentry_tags:ao.tags,$level:ao.level};return eo&&no&&(_o.$sentry_url=(ro||"https://sentry.io/organizations/")+eo+"/issues/?project="+no+"&query="+ao.event_id),to.exceptions.sendExceptionEvent(_o),ao}}var gr=s(function to(ue,eo,no,ro,oo){i$1(this,to),this.name=vr,this.setupOnce=function(io){io(pr(ue,{organization:eo,projectId:no,prefix:ro,severityAllowList:oo}))}});function _r(to,ue){var eo=to.config.segment;if(!eo)return ue();(function(no,ro){var oo=no.config.segment;if(!oo)return ro();var io=function(so){var lo=function(){return so.anonymousId()||Ke()};no.config.get_device_id=lo,so.id()&&(no.register({distinct_id:so.id(),$device_id:lo()}),no.persistence.set_property($e,"identified")),ro()},ao=oo.user();"then"in ao&&y(ao.then)?ao.then(function(so){return io(so)}):io(ao)})(to,function(){eo.register(function(no){Promise&&Promise.resolve||G.warn("This browser does not have Promise support, and can not use the segment integration");var ro=function(oo,io){var ao;if(!io)return oo;oo.event.userId||oo.event.anonymousId===no.get_distinct_id()||(G.info("Segment integration does not have a userId set, resetting PostHog"),no.reset()),oo.event.userId&&oo.event.userId!==no.get_distinct_id()&&(G.info("Segment integration has a userId set, identifying with PostHog"),no.identify(oo.event.userId));var so=no._calculate_event_properties(io,(ao=oo.event.properties)!==null&&ao!==void 0?ao:{},new Date);return oo.event.properties=Object.assign({},so,oo.event.properties),oo};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},track:function(oo){return ro(oo,oo.event.event)},page:function(oo){return ro(oo,"$pageview")},identify:function(oo){return ro(oo,"$identify")},screen:function(oo){return ro(oo,"$screen")}}}(to)).then(function(){ue()})})}var mr,yr,br,kr=function(){function to(ue){i$1(this,to),this._instance=ue}return s(to,[{key:"doPageView",value:function(ue){var eo,no=this._previousPageViewProperties(ue);return this._currentPath=(eo=T==null?void 0:T.location.pathname)!==null&&eo!==void 0?eo:"",this._instance.scrollManager.resetContext(),this._prevPageviewTimestamp=ue,no}},{key:"doPageLeave",value:function(ue){return this._previousPageViewProperties(ue)}},{key:"_previousPageViewProperties",value:function(ue){var eo=this._currentPath,no=this._prevPageviewTimestamp,ro=this._instance.scrollManager.getContext();if(!no)return{};var oo={};if(ro){var io=ro.maxScrollHeight,ao=ro.lastScrollY,so=ro.maxScrollY,lo=ro.maxContentHeight,co=ro.lastContentY,uo=ro.maxContentY;w$1(io)||w$1(ao)||w$1(so)||w$1(lo)||w$1(co)||w$1(uo)||(io=Math.ceil(io),ao=Math.ceil(ao),so=Math.ceil(so),lo=Math.ceil(lo),co=Math.ceil(co),uo=Math.ceil(uo),oo={$prev_pageview_last_scroll:ao,$prev_pageview_last_scroll_percentage:io<=1?1:wr(ao/io,0,1),$prev_pageview_max_scroll:so,$prev_pageview_max_scroll_percentage:io<=1?1:wr(so/io,0,1),$prev_pageview_last_content:co,$prev_pageview_last_content_percentage:lo<=1?1:wr(co/lo,0,1),$prev_pageview_max_content:uo,$prev_pageview_max_content_percentage:lo<=1?1:wr(uo/lo,0,1)})}return eo&&(oo.$prev_pageview_pathname=eo),no&&(oo.$prev_pageview_duration=(ue.getTime()-no.getTime())/1e3),oo}}]),to}();function wr(to,ue,eo){return Math.max(ue,Math.min(to,eo))}(function(to){to.Popover="popover",to.API="api",to.Widget="widget"})(mr||(mr={})),function(to){to.Open="open",to.MultipleChoice="multiple_choice",to.SingleChoice="single_choice",to.Rating="rating",to.Link="link"}(yr||(yr={})),function(to){to.NextQuestion="next_question",to.End="end",to.ResponseBased="response_based",to.SpecificQuestion="specific_question"}(br||(br={}));var Sr=function(){function to(){i$1(this,to),o(this,"events",{}),this.events={}}return s(to,[{key:"on",value:function(ue,eo){var no=this;return this.events[ue]||(this.events[ue]=[]),this.events[ue].push(eo),function(){no.events[ue]=no.events[ue].filter(function(ro){return ro!==eo})}}},{key:"emit",value:function(ue,eo){var no,ro=h(this.events[ue]||[]);try{for(ro.s();!(no=ro.n()).done;)(0,no.value)(eo)}catch(ao){ro.e(ao)}finally{ro.f()}var oo,io=h(this.events["*"]||[]);try{for(io.s();!(oo=io.n()).done;)(0,oo.value)(ue,eo)}catch(ao){io.e(ao)}finally{io.f()}}}]),to}(),Er=function(){function to(ue){var eo=this;i$1(this,to),o(this,"_debugEventEmitter",new Sr),o(this,"checkStep",function(no,ro){return eo.checkStepEvent(no,ro)&&eo.checkStepUrl(no,ro)&&eo.checkStepElement(no,ro)}),o(this,"checkStepEvent",function(no,ro){return ro==null||!ro.event||(no==null?void 0:no.event)===(ro==null?void 0:ro.event)}),this.instance=ue,this.actionEvents=new Set,this.actionRegistry=new Set}return s(to,[{key:"init",value:function(){var ue,eo=this;if(!w$1((ue=this.instance)===null||ue===void 0?void 0:ue._addCaptureHook)){var no;(no=this.instance)===null||no===void 0||no._addCaptureHook(function(ro,oo){eo.on(ro,oo)})}}},{key:"register",value:function(ue){var eo,no,ro=this;if(!w$1((eo=this.instance)===null||eo===void 0?void 0:eo._addCaptureHook)&&(ue.forEach(function(ao){var so,lo;(so=ro.actionRegistry)===null||so===void 0||so.add(ao),(lo=ao.steps)===null||lo===void 0||lo.forEach(function(co){var uo;(uo=ro.actionEvents)===null||uo===void 0||uo.add((co==null?void 0:co.event)||"")})}),(no=this.instance)!==null&&no!==void 0&&no.autocapture)){var oo,io=new Set;ue.forEach(function(ao){var so;(so=ao.steps)===null||so===void 0||so.forEach(function(lo){lo!=null&&lo.selector&&io.add(lo==null?void 0:lo.selector)})}),(oo=this.instance)===null||oo===void 0||oo.autocapture.setElementSelectors(io)}}},{key:"on",value:function(ue,eo){var no,ro=this;eo!=null&&ue.length!=0&&(this.actionEvents.has(ue)||this.actionEvents.has(eo==null?void 0:eo.event))&&this.actionRegistry&&((no=this.actionRegistry)===null||no===void 0?void 0:no.size)>0&&this.actionRegistry.forEach(function(oo){ro.checkAction(eo,oo)&&ro._debugEventEmitter.emit("actionCaptured",oo.name)})}},{key:"_addActionHook",value:function(ue){this.onAction("actionCaptured",function(eo){return ue(eo)})}},{key:"checkAction",value:function(ue,eo){if((eo==null?void 0:eo.steps)==null)return!1;var no,ro=h(eo.steps);try{for(ro.s();!(no=ro.n()).done;){var oo=no.value;if(this.checkStep(ue,oo))return!0}}catch(io){ro.e(io)}finally{ro.f()}return!1}},{key:"onAction",value:function(ue,eo){return this._debugEventEmitter.on(ue,eo)}},{key:"checkStepUrl",value:function(ue,eo){if(eo!=null&&eo.url){var no,ro=ue==null||(no=ue.properties)===null||no===void 0?void 0:no.$current_url;if(!ro||typeof ro!="string"||!to.matchString(ro,eo==null?void 0:eo.url,(eo==null?void 0:eo.url_matching)||"contains"))return!1}return!0}},{key:"checkStepElement",value:function(ue,eo){if((eo!=null&&eo.href||eo!=null&&eo.tag_name||eo!=null&&eo.text)&&!this.getElementsList(ue).some(function(oo){return!(eo!=null&&eo.href&&!to.matchString(oo.href||"",eo==null?void 0:eo.href,(eo==null?void 0:eo.href_matching)||"exact"))&&(eo==null||!eo.tag_name||oo.tag_name===(eo==null?void 0:eo.tag_name))&&!(eo!=null&&eo.text&&!to.matchString(oo.text||"",eo==null?void 0:eo.text,(eo==null?void 0:eo.text_matching)||"exact")&&!to.matchString(oo.$el_text||"",eo==null?void 0:eo.text,(eo==null?void 0:eo.text_matching)||"exact"))}))return!1;if(eo!=null&&eo.selector){var no,ro=ue==null||(no=ue.properties)===null||no===void 0?void 0:no.$element_selectors;if(!ro||!ro.includes(eo==null?void 0:eo.selector))return!1}return!0}},{key:"getElementsList",value:function(ue){return(ue==null?void 0:ue.properties.$elements)==null?[]:ue==null?void 0:ue.properties.$elements}}],[{key:"matchString",value:function(ue,eo,no){switch(no){case"regex":return!!T&>(ue,eo);case"exact":return eo===ue;case"contains":var ro=to.escapeStringRegexp(eo).replace(/_/g,".").replace(/%/g,".*");return gt(ue,ro);default:return!1}}},{key:"escapeStringRegexp",value:function(ue){return ue.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}}]),to}(),Ir=function(){function to(ue){i$1(this,to),this.instance=ue,this.eventToSurveys=new Map,this.actionToSurveys=new Map}return s(to,[{key:"register",value:function(ue){var eo;w$1((eo=this.instance)===null||eo===void 0?void 0:eo._addCaptureHook)||(this.setupEventBasedSurveys(ue),this.setupActionBasedSurveys(ue))}},{key:"setupActionBasedSurveys",value:function(ue){var eo=this,no=ue.filter(function(ro){var oo,io,ao,so;return((oo=ro.conditions)===null||oo===void 0?void 0:oo.actions)&&((io=ro.conditions)===null||io===void 0||(ao=io.actions)===null||ao===void 0||(so=ao.values)===null||so===void 0?void 0:so.length)>0});no.length!==0&&(this.actionMatcher==null&&(this.actionMatcher=new Er(this.instance),this.actionMatcher.init(),this.actionMatcher._addActionHook(function(ro){eo.onAction(ro)})),no.forEach(function(ro){var oo,io,ao,so,lo,co,uo,fo,po,ho;ro.conditions&&(oo=ro.conditions)!==null&&oo!==void 0&&oo.actions&&(io=ro.conditions)!==null&&io!==void 0&&(ao=io.actions)!==null&&ao!==void 0&&ao.values&&((so=ro.conditions)===null||so===void 0||(lo=so.actions)===null||lo===void 0||(co=lo.values)===null||co===void 0?void 0:co.length)>0&&((uo=eo.actionMatcher)===null||uo===void 0||uo.register(ro.conditions.actions.values),(fo=ro.conditions)===null||fo===void 0||(po=fo.actions)===null||po===void 0||(ho=po.values)===null||ho===void 0||ho.forEach(function(_o){if(_o&&_o.name){var go=eo.actionToSurveys.get(_o.name);go&&go.push(ro.id),eo.actionToSurveys.set(_o.name,go||[ro.id])}}))}))}},{key:"setupEventBasedSurveys",value:function(ue){var eo,no=this;ue.filter(function(ro){var oo,io,ao,so;return((oo=ro.conditions)===null||oo===void 0?void 0:oo.events)&&((io=ro.conditions)===null||io===void 0||(ao=io.events)===null||ao===void 0||(so=ao.values)===null||so===void 0?void 0:so.length)>0}).length!==0&&((eo=this.instance)===null||eo===void 0||eo._addCaptureHook(function(ro,oo){no.onEvent(ro,oo)}),ue.forEach(function(ro){var oo,io,ao;(oo=ro.conditions)===null||oo===void 0||(io=oo.events)===null||io===void 0||(ao=io.values)===null||ao===void 0||ao.forEach(function(so){if(so&&so.name){var lo=no.eventToSurveys.get(so.name);lo&&lo.push(ro.id),no.eventToSurveys.set(so.name,lo||[ro.id])}})}))}},{key:"onEvent",value:function(ue,eo){var no,ro,oo=((no=this.instance)===null||no===void 0||(ro=no.persistence)===null||ro===void 0?void 0:ro.props[Te])||[];if(to.SURVEY_SHOWN_EVENT_NAME==ue&&eo&&oo.length>0){var io,ao=eo==null||(io=eo.properties)===null||io===void 0?void 0:io.$survey_id;if(ao){var so=oo.indexOf(ao);so>=0&&(oo.splice(so,1),this._updateActivatedSurveys(oo))}}else this.eventToSurveys.has(ue)&&this._updateActivatedSurveys(oo.concat(this.eventToSurveys.get(ue)||[]))}},{key:"onAction",value:function(ue){var eo,no,ro=((eo=this.instance)===null||eo===void 0||(no=eo.persistence)===null||no===void 0?void 0:no.props[Te])||[];this.actionToSurveys.has(ue)&&this._updateActivatedSurveys(ro.concat(this.actionToSurveys.get(ue)||[]))}},{key:"_updateActivatedSurveys",value:function(ue){var eo,no;(eo=this.instance)===null||eo===void 0||(no=eo.persistence)===null||no===void 0||no.register(o({},Te,l(new Set(ue))))}},{key:"getSurveys",value:function(){var ue,eo,no=(ue=this.instance)===null||ue===void 0||(eo=ue.persistence)===null||eo===void 0?void 0:eo.props[Te];return no||[]}},{key:"getEventToSurveys",value:function(){return this.eventToSurveys}},{key:"_getActionMatcher",value:function(){return this.actionMatcher}}]),to}();o(Ir,"SURVEY_SHOWN_EVENT_NAME","survey shown");var Rr="[Surveys]",Fr={icontains:function(to){return!!T&&T.location.href.toLowerCase().indexOf(to.toLowerCase())>-1},not_icontains:function(to){return!!T&&T.location.href.toLowerCase().indexOf(to.toLowerCase())===-1},regex:function(to){return!!T&>(T.location.href,to)},not_regex:function(to){return!!T&&!gt(T.location.href,to)},exact:function(to){return(T==null?void 0:T.location.href)===to},is_not:function(to){return(T==null?void 0:T.location.href)!==to}},xr=function(){function to(ue){i$1(this,to),this.instance=ue,this._surveyEventReceiver=null}return s(to,[{key:"afterDecideResponse",value:function(ue){this._decideServerResponse=!!ue.surveys,this.loadIfEnabled()}},{key:"loadIfEnabled",value:function(){var ue=this,eo=U==null?void 0:U.extendPostHogWithSurveys;this.instance.config.disable_surveys||!this._decideServerResponse||eo||(this._surveyEventReceiver==null&&(this._surveyEventReceiver=new Ir(this.instance)),this.instance.requestRouter.loadScript("/static/surveys.js",function(no){if(no)return G.error(Rr,"Could not load surveys script",no);ue._surveyManager=U.extendPostHogWithSurveys(ue.instance)}))}},{key:"getSurveys",value:function(ue){var eo=this,no=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(this.instance.config.disable_surveys)return ue([]);this._surveyEventReceiver==null&&(this._surveyEventReceiver=new Ir(this.instance));var ro=this.instance.get_property(Pe);if(ro&&!no)return ue(ro);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",transport:"XHR",callback:function(oo){var io;if(oo.statusCode!==200||!oo.json)return ue([]);var ao,so=oo.json.surveys||[],lo=so.filter(function(co){var uo,fo,po,ho,_o,go,bo,vo,yo,wo,ko,So;return((uo=co.conditions)===null||uo===void 0?void 0:uo.events)&&((fo=co.conditions)===null||fo===void 0||(po=fo.events)===null||po===void 0?void 0:po.values)&&((ho=co.conditions)===null||ho===void 0||(_o=ho.events)===null||_o===void 0||(go=_o.values)===null||go===void 0?void 0:go.length)>0||((bo=co.conditions)===null||bo===void 0?void 0:bo.actions)&&((vo=co.conditions)===null||vo===void 0||(yo=vo.actions)===null||yo===void 0?void 0:yo.values)&&((wo=co.conditions)===null||wo===void 0||(ko=wo.actions)===null||ko===void 0||(So=ko.values)===null||So===void 0?void 0:So.length)>0});return lo.length>0&&((ao=eo._surveyEventReceiver)===null||ao===void 0||ao.register(lo)),(io=eo.instance.persistence)===null||io===void 0||io.register(o({},Pe,so)),ue(so)}})}},{key:"getActiveMatchingSurveys",value:function(ue){var eo=this,no=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.getSurveys(function(ro){var oo,io=ro.filter(function(lo){return!(!lo.start_date||lo.end_date)}).filter(function(lo){var co,uo,fo,po;if(!lo.conditions)return!0;var ho=(co=lo.conditions)===null||co===void 0||!co.url||Fr[(uo=(fo=lo.conditions)===null||fo===void 0?void 0:fo.urlMatchType)!==null&&uo!==void 0?uo:"icontains"](lo.conditions.url),_o=(po=lo.conditions)===null||po===void 0||!po.selector||(L==null?void 0:L.querySelector(lo.conditions.selector));return ho&&_o}),ao=(oo=eo._surveyEventReceiver)===null||oo===void 0?void 0:oo.getSurveys(),so=io.filter(function(lo){var co,uo,fo,po,ho,_o,go,bo,vo,yo;if(!lo.linked_flag_key&&!lo.targeting_flag_key&&!lo.internal_targeting_flag_key)return!0;var wo=!lo.linked_flag_key||eo.instance.featureFlags.isFeatureEnabled(lo.linked_flag_key),ko=!lo.targeting_flag_key||eo.instance.featureFlags.isFeatureEnabled(lo.targeting_flag_key),So=((co=lo.conditions)===null||co===void 0?void 0:co.events)&&((uo=lo.conditions)===null||uo===void 0||(fo=uo.events)===null||fo===void 0?void 0:fo.values)&&((po=lo.conditions)===null||po===void 0||(ho=po.events)===null||ho===void 0?void 0:ho.values.length)>0,Eo=((_o=lo.conditions)===null||_o===void 0?void 0:_o.actions)&&((go=lo.conditions)===null||go===void 0||(bo=go.actions)===null||bo===void 0?void 0:bo.values)&&((vo=lo.conditions)===null||vo===void 0||(yo=vo.actions)===null||yo===void 0?void 0:yo.values.length)>0,Io=!So&&!Eo||(ao==null?void 0:ao.includes(lo.id)),Ao=eo._canActivateRepeatedly(lo),To=!(lo.internal_targeting_flag_key&&!Ao)||eo.instance.featureFlags.isFeatureEnabled(lo.internal_targeting_flag_key);return wo&&ko&&To&&Io});return ue(so)},no)}},{key:"getNextSurveyStep",value:function(ue,eo,no){var ro,oo=ue.questions[eo],io=eo+1;if((ro=oo.branching)===null||ro===void 0||!ro.type)return eo===ue.questions.length-1?br.End:io;if(oo.branching.type===br.End)return br.End;if(oo.branching.type===br.SpecificQuestion){if(Number.isInteger(oo.branching.index))return oo.branching.index}else if(oo.branching.type===br.ResponseBased){if(oo.type===yr.SingleChoice){var ao,so,lo=oo.choices.indexOf("".concat(no));if((ao=oo.branching)!==null&&ao!==void 0&&(so=ao.responseValues)!==null&&so!==void 0&&so.hasOwnProperty(lo)){var co=oo.branching.responseValues[lo];return Number.isInteger(co)?co:co===br.End?br.End:io}}else if(oo.type===yr.Rating){var uo,fo;if(typeof no!="number"||!Number.isInteger(no))throw new Error("The response type must be an integer");var po=function(_o,go){if(go===3){if(_o<1||_o>3)throw new Error("The response must be in range 1-3");return _o===1?"negative":_o===2?"neutral":"positive"}if(go===5){if(_o<1||_o>5)throw new Error("The response must be in range 1-5");return _o<=2?"negative":_o===3?"neutral":"positive"}if(go===10){if(_o<0||_o>10)throw new Error("The response must be in range 0-10");return _o<=6?"detractors":_o<=8?"passives":"promoters"}throw new Error("The scale must be one of: 3, 5, 10")}(no,oo.scale);if((uo=oo.branching)!==null&&uo!==void 0&&(fo=uo.responseValues)!==null&&fo!==void 0&&fo.hasOwnProperty(po)){var ho=oo.branching.responseValues[po];return Number.isInteger(ho)?ho:ho===br.End?br.End:io}}return io}return G.warn(Rr,"Falling back to next question index due to unexpected branching type"),io}},{key:"_canActivateRepeatedly",value:function(ue){return R(U.__PosthogExtensions__.canActivateRepeatedly)&&G.warn(Rr,"canActivateRepeatedly is not defined, must init before calling"),U.__PosthogExtensions__.canActivateRepeatedly(ue)}},{key:"canRenderSurvey",value:function(ue){var eo=this;R(this._surveyManager)?G.warn(Rr,"canActivateRepeatedly is not defined, must init before calling"):this.getSurveys(function(no){var ro=no.filter(function(oo){return oo.id===ue})[0];eo._surveyManager.canRenderSurvey(ro)})}},{key:"renderSurvey",value:function(ue,eo){var no=this;R(this._surveyManager)?G.warn(Rr,"canActivateRepeatedly is not defined, must init before calling"):this.getSurveys(function(ro){var oo=ro.filter(function(io){return io.id===ue})[0];no._surveyManager.renderSurvey(oo,L==null?void 0:L.querySelector(eo))})}}]),to}(),Pr=function(){function to(ue){var eo,no,ro=this;i$1(this,to),o(this,"serverLimits",{}),o(this,"lastEventRateLimited",!1),o(this,"checkForLimiting",function(oo){var io=oo.text;if(io&&io.length)try{(JSON.parse(io).quota_limited||[]).forEach(function(ao){G.info("[RateLimiter] ".concat(ao||"events"," is quota limited.")),ro.serverLimits[ao]=new Date().getTime()+6e4})}catch(ao){return void G.warn('[RateLimiter] could not rate limit - continuing. Error: "'.concat(ao==null?void 0:ao.message,'"'),{text:io})}}),this.instance=ue,this.captureEventsPerSecond=((eo=ue.config.rate_limiting)===null||eo===void 0?void 0:eo.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((no=ue.config.rate_limiting)===null||no===void 0?void 0:no.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}return s(to,[{key:"clientRateLimitContext",value:function(){var ue,eo,no,ro=arguments.length>0&&arguments[0]!==void 0&&arguments[0],oo=new Date().getTime(),io=(ue=(eo=this.instance.persistence)===null||eo===void 0?void 0:eo.get_property(Me))!==null&&ue!==void 0?ue:{tokens:this.captureEventsBurstLimit,last:oo};io.tokens+=(oo-io.last)/1e3*this.captureEventsPerSecond,io.last=oo,io.tokens>this.captureEventsBurstLimit&&(io.tokens=this.captureEventsBurstLimit);var ao=io.tokens<1;return ao||ro||(io.tokens=Math.max(0,io.tokens-1)),!ao||this.lastEventRateLimited||ro||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to ".concat(this.captureEventsPerSecond," events per second and ").concat(this.captureEventsBurstLimit," events burst limit.")},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=ao,(no=this.instance.persistence)===null||no===void 0||no.set_property(Me,io),{isRateLimited:ao,remainingTokens:io.tokens}}},{key:"isServerRateLimited",value:function(ue){var eo=this.serverLimits[ue||"events"]||!1;return eo!==!1&&new Date().getTime()<eo}}]),to}(),Tr=function(){return t$1({initialPathName:(D==null?void 0:D.pathname)||"",referringDomain:mn.referringDomain()},mn.campaignParams())},Cr=function(){function to(ue,eo,no){var ro=this;i$1(this,to),o(this,"_onSessionIdCallback",function(oo){var io=ro._getStoredProps();if(!io||io.sessionId!==oo){var ao={sessionId:oo,props:ro._sessionSourceParamGenerator()};ro._persistence.register(o({},Oe,ao))}}),this._sessionIdManager=ue,this._persistence=eo,this._sessionSourceParamGenerator=no||Tr,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}return s(to,[{key:"_getStoredProps",value:function(){return this._persistence.props[Oe]}},{key:"getSessionProps",value:function(){var ue,eo=(ue=this._getStoredProps())===null||ue===void 0?void 0:ue.props;return eo?{$client_session_initial_referring_host:eo.referringDomain,$client_session_initial_pathname:eo.initialPathName,$client_session_initial_utm_source:eo.utm_source,$client_session_initial_utm_campaign:eo.utm_campaign,$client_session_initial_utm_medium:eo.utm_medium,$client_session_initial_utm_content:eo.utm_content,$client_session_initial_utm_term:eo.utm_term}:{}}}]),to}(),$r=["ahrefsbot","ahrefssiteaudit","applebot","baiduspider","bingbot","bingpreview","bot.htm","bot.php","crawler","deepscan","duckduckbot","facebookexternal","facebookcatalog","gptbot","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","semrushbot","sitebulb","slurp","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","headlesschrome","cypress","Google-HotelAdsVerifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google","Bytespider;"],Or=function(to,ue){if(!to)return!1;var eo=to.toLowerCase();return $r.concat(ue||[]).some(function(no){var ro=no.toLowerCase();return eo.indexOf(ro)!==-1})},Mr=function(){function to(){i$1(this,to),this.clicks=[]}return s(to,[{key:"isRageClick",value:function(ue,eo,no){var ro=this.clicks[this.clicks.length-1];if(ro&&Math.abs(ue-ro.x)+Math.abs(eo-ro.y)<30&&no-ro.timestamp<1e3){if(this.clicks.push({x:ue,y:eo,timestamp:no}),this.clicks.length===3)return!0}else this.clicks=[{x:ue,y:eo,timestamp:no}];return!1}}]),to}();function Ar(to){var ue;return to.id===Ne||!((ue=to.closest)===null||ue===void 0||!ue.call(to,"#"+Ne))}var Lr=function(){function to(ue){var eo,no=this;i$1(this,to),o(this,"rageclicks",new Mr),o(this,"_enabledServerSide",!1),o(this,"_initialized",!1),o(this,"_flushInterval",null),this.instance=ue,this._enabledServerSide=!((eo=this.instance.persistence)===null||eo===void 0||!eo.props[fe]),T==null||T.addEventListener("beforeunload",function(){no.flush()})}return s(to,[{key:"flushIntervalMilliseconds",get:function(){var ue=5e3;return b(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(ue=this.instance.config.capture_heatmaps.flush_interval_milliseconds),ue}},{key:"isEnabled",get:function(){return w$1(this.instance.config.capture_heatmaps)?w$1(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}},{key:"startIfEnabled",value:function(){if(this.isEnabled){if(this._initialized)return;G.info("[heatmaps] starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var ue;clearInterval((ue=this._flushInterval)!==null&&ue!==void 0?ue:void 0),this.getAndClearBuffer()}}},{key:"afterDecideResponse",value:function(ue){var eo=!!ue.heatmaps;this.instance.persistence&&this.instance.persistence.register(o({},fe,eo)),this._enabledServerSide=eo,this.startIfEnabled()}},{key:"getAndClearBuffer",value:function(){var ue=this.buffer;return this.buffer=void 0,ue}},{key:"_setupListeners",value:function(){var ue=this;T&&L&&(oe(L,"click",function(eo){return ue._onClick(eo||(T==null?void 0:T.event))},!1,!0),oe(L,"mousemove",function(eo){return ue._onMouseMove(eo||(T==null?void 0:T.event))},!1,!0),this._initialized=!0)}},{key:"_getProperties",value:function(ue,eo){var no=this.instance.scrollManager.scrollY(),ro=this.instance.scrollManager.scrollX(),oo=this.instance.scrollManager.scrollElement(),io=function(ao,so,lo){for(var co=ao;co&&!On(co,"body");){if(co===lo)return!1;if(Y(so,T==null?void 0:T.getComputedStyle(co).position))return!0;co=Dn(co)}return!1}(ue.target,["fixed","sticky"],oo);return{x:ue.clientX+(io?0:ro),y:ue.clientY+(io?0:no),target_fixed:io,type:eo}}},{key:"_onClick",value:function(ue){var eo;if(!Ar(ue.target)){var no=this._getProperties(ue,"click");(eo=this.rageclicks)!==null&&eo!==void 0&&eo.isRageClick(ue.clientX,ue.clientY,new Date().getTime())&&this._capture(t$1(t$1({},no),{},{type:"rageclick"})),this._capture(no)}}},{key:"_onMouseMove",value:function(ue){var eo=this;Ar(ue.target)||(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(function(){eo._capture(eo._getProperties(ue,"mousemove"))},500))}},{key:"_capture",value:function(ue){if(T){var eo=T.location.href;this.buffer=this.buffer||{},this.buffer[eo]||(this.buffer[eo]=[]),this.buffer[eo].push(ue)}}},{key:"flush",value:function(){this.buffer&&!k(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}]),to}(),Dr=function(){function to(ue){var eo=this;i$1(this,to),o(this,"_updateScrollData",function(){var no,ro,oo,io;eo.context||(eo.context={});var ao=eo.scrollElement(),so=eo.scrollY(),lo=ao?Math.max(0,ao.scrollHeight-ao.clientHeight):0,co=so+((ao==null?void 0:ao.clientHeight)||0),uo=(ao==null?void 0:ao.scrollHeight)||0;eo.context.lastScrollY=Math.ceil(so),eo.context.maxScrollY=Math.max(so,(no=eo.context.maxScrollY)!==null&&no!==void 0?no:0),eo.context.maxScrollHeight=Math.max(lo,(ro=eo.context.maxScrollHeight)!==null&&ro!==void 0?ro:0),eo.context.lastContentY=co,eo.context.maxContentY=Math.max(co,(oo=eo.context.maxContentY)!==null&&oo!==void 0?oo:0),eo.context.maxContentHeight=Math.max(uo,(io=eo.context.maxContentHeight)!==null&&io!==void 0?io:0)}),this.instance=ue}return s(to,[{key:"getContext",value:function(){return this.context}},{key:"resetContext",value:function(){var ue=this.context;return setTimeout(this._updateScrollData,0),ue}},{key:"startMeasuringScrollPosition",value:function(){T==null||T.addEventListener("scroll",this._updateScrollData,!0),T==null||T.addEventListener("scrollend",this._updateScrollData,!0),T==null||T.addEventListener("resize",this._updateScrollData)}},{key:"scrollElement",value:function(){if(!this.instance.config.scroll_root_selector)return T==null?void 0:T.document.documentElement;var ue,eo=h(m(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector]);try{for(eo.s();!(ue=eo.n()).done;){var no=ue.value,ro=T==null?void 0:T.document.querySelector(no);if(ro)return ro}}catch(oo){eo.e(oo)}finally{eo.f()}}},{key:"scrollY",value:function(){if(this.instance.config.scroll_root_selector){var ue=this.scrollElement();return ue&&ue.scrollTop||0}return T&&(T.scrollY||T.pageYOffset||T.document.documentElement.scrollTop)||0}},{key:"scrollX",value:function(){if(this.instance.config.scroll_root_selector){var ue=this.scrollElement();return ue&&ue.scrollLeft||0}return T&&(T.scrollX||T.pageXOffset||T.document.documentElement.scrollLeft)||0}}]),to}(),qr="$copy_autocapture";function Nr(to,ue){return ue.length>to?ue.slice(0,to)+"...":ue}var Br,Hr=function(){function to(ue){i$1(this,to),o(this,"_initialized",!1),o(this,"_isDisabledServerSide",null),o(this,"rageclicks",new Mr),o(this,"_elementsChainAsString",!1),this.instance=ue,this._elementSelectors=null}return s(to,[{key:"config",get:function(){var ue,eo,no=b(this.instance.config.autocapture)?this.instance.config.autocapture:{};return no.url_allowlist=(ue=no.url_allowlist)===null||ue===void 0?void 0:ue.map(function(ro){return new RegExp(ro)}),no.url_ignorelist=(eo=no.url_ignorelist)===null||eo===void 0?void 0:eo.map(function(ro){return new RegExp(ro)}),no}},{key:"_addDomEventHandlers",value:function(){var ue=this;if(this.isBrowserSupported()){if(T&&L){var eo=function(ro){ro=ro||(T==null?void 0:T.event);try{ue._captureEvent(ro)}catch(oo){G.error("Failed to capture event",oo)}},no=function(ro){ro=ro||(T==null?void 0:T.event),ue._captureEvent(ro,qr)};oe(L,"submit",eo,!1,!0),oe(L,"change",eo,!1,!0),oe(L,"click",eo,!1,!0),this.config.capture_copied_text&&(oe(L,"copy",no,!1,!0),oe(L,"cut",no,!1,!0))}}else G.info("Disabling Automatic Event Collection because this browser is not supported")}},{key:"startIfEnabled",value:function(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}},{key:"afterDecideResponse",value:function(ue){ue.elementsChainAsString&&(this._elementsChainAsString=ue.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register(o({},he,!!ue.autocapture_opt_out)),this._isDisabledServerSide=!!ue.autocapture_opt_out,this.startIfEnabled()}},{key:"setElementSelectors",value:function(ue){this._elementSelectors=ue}},{key:"getElementSelectors",value:function(ue){var eo,no=[];return(eo=this._elementSelectors)===null||eo===void 0||eo.forEach(function(ro){var oo=L==null?void 0:L.querySelectorAll(ro);oo==null||oo.forEach(function(io){ue===io&&no.push(ro)})}),no}},{key:"isEnabled",get:function(){var ue,eo,no=(ue=this.instance.persistence)===null||ue===void 0?void 0:ue.props[he],ro=this._isDisabledServerSide;if(I(ro)&&!x$1(no)&&!this.instance.config.advanced_disable_decide)return!1;var oo=(eo=this._isDisabledServerSide)!==null&&eo!==void 0?eo:!!no;return!!this.instance.config.autocapture&&!oo}},{key:"_previousElementSibling",value:function(ue){if(ue.previousElementSibling)return ue.previousElementSibling;var eo=ue;do eo=eo.previousSibling;while(eo&&!$n(eo));return eo}},{key:"_getAugmentPropertiesFromElement",value:function(ue){if(!Nn(ue))return{};var eo={};return Q(ue.attributes,function(no){if(no.name&&no.name.indexOf("data-ph-capture-attribute")===0){var ro=no.name.replace("data-ph-capture-attribute-",""),oo=no.value;ro&&oo&&zn(oo)&&(eo[ro]=oo)}}),eo}},{key:"_getPropertiesFromElement",value:function(ue,eo,no){var ro,oo=ue.tagName.toLowerCase(),io={tag_name:oo};Ln.indexOf(oo)>-1&&!no&&(oo.toLowerCase()==="a"||oo.toLowerCase()==="button"?io.$el_text=Nr(1024,Qn(ue)):io.$el_text=Nr(1024,Cn(ue)));var ao=Pn(ue);ao.length>0&&(io.classes=ao.filter(function(fo){return fo!==""}));var so=(ro=this.config)===null||ro===void 0?void 0:ro.element_attribute_ignorelist;Q(ue.attributes,function(fo){var po;if((!Bn(ue)||["name","id","class","aria-label"].indexOf(fo.name)!==-1)&&(so==null||!so.includes(fo.name))&&!eo&&zn(fo.value)&&(po=fo.name,!S(po)||po.substring(0,10)!=="_ngcontent"&&po.substring(0,7)!=="_nghost")){var ho=fo.value;fo.name==="class"&&(ho=Fn(ho).join(" ")),io["attr__"+fo.name]=Nr(1024,ho)}});for(var lo=1,co=1,uo=ue;uo=this._previousElementSibling(uo);)lo++,uo.tagName===ue.tagName&&co++;return io.nth_child=lo,io.nth_of_type=co,io}},{key:"_getDefaultProperties",value:function(ue){return{$event_type:ue,$ce_version:1}}},{key:"_getEventTarget",value:function(ue){return w$1(ue.target)?ue.srcElement||null:(eo=ue.target)!==null&&eo!==void 0&&eo.shadowRoot?ue.composedPath()[0]||null:ue.target||null;var eo}},{key:"_captureEvent",value:function(ue){var eo=this,no=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"$autocapture";if(this.isEnabled){var ro,oo=this._getEventTarget(ue);Mn(oo)&&(oo=oo.parentNode||null),no==="$autocapture"&&ue.type==="click"&&ue instanceof MouseEvent&&this.instance.config.rageclick&&(ro=this.rageclicks)!==null&&ro!==void 0&&ro.isRageClick(ue.clientX,ue.clientY,new Date().getTime())&&this._captureEvent(ue,"$rageclick");var io=no===qr;if(oo&&qn(oo,ue,this.config,io,io?["copy","cut"]:void 0)){for(var ao,so,lo=[oo],co=oo;co.parentNode&&!On(co,"body");)An(co.parentNode)?(lo.push(co.parentNode.host),co=co.parentNode.host):(lo.push(co.parentNode),co=co.parentNode);var uo,fo,po=[],ho={},_o=!1;if(Q(lo,function(Ao){var To=Nn(Ao);Ao.tagName.toLowerCase()==="a"&&(uo=Ao.getAttribute("href"),uo=To&&zn(uo)&&uo),Y(Pn(Ao),"ph-no-capture")&&(_o=!0),po.push(eo._getPropertiesFromElement(Ao,eo.instance.config.mask_all_element_attributes,eo.instance.config.mask_all_text));var zo=eo._getAugmentPropertiesFromElement(Ao);J(ho,zo)}),this.instance.config.mask_all_text||(oo.tagName.toLowerCase()==="a"||oo.tagName.toLowerCase()==="button"?po[0].$el_text=Qn(oo):po[0].$el_text=Cn(oo)),uo){var go,bo;po[0].attr__href=uo;var vo=(go=pt(uo))===null||go===void 0?void 0:go.host,yo=T==null||(bo=T.location)===null||bo===void 0?void 0:bo.host;vo&&yo&&vo!==yo&&(fo=uo)}if(_o)return!1;var wo=J(this._getDefaultProperties(ue.type),this._elementsChainAsString?{$elements_chain:Yn(po)}:{$elements:po},(ao=po[0])!==null&&ao!==void 0&&ao.$el_text?{$el_text:(so=po[0])===null||so===void 0?void 0:so.$el_text}:{},fo&&ue.type==="click"?{$external_click_url:fo}:{},ho),ko=this.getElementSelectors(oo);if(ko&&ko.length>0&&(wo.$element_selectors=ko),no===qr){var So,Eo=Tn(T==null||(So=T.getSelection())===null||So===void 0?void 0:So.toString()),Io=ue.type||"clipboard";if(!Eo)return!1;wo.$selected_content=Eo,wo.$copy_type=Io}return this.instance.capture(no,wo),!0}}}},{key:"isBrowserSupported",value:function(){return y(L==null?void 0:L.querySelectorAll)}}]),to}(),Ur=function(){function to(ue){var eo=this;i$1(this,to),o(this,"_restoreXHRPatch",void 0),o(this,"_restoreFetchPatch",void 0),o(this,"_startCapturing",function(){w$1(eo._restoreXHRPatch)&&U.postHogTracingHeadersPatchFns._patchXHR(eo.instance.sessionManager),w$1(eo._restoreFetchPatch)&&U.postHogTracingHeadersPatchFns._patchFetch(eo.instance.sessionManager)}),this.instance=ue}return s(to,[{key:"_loadScript",value:function(ue){U.postHogTracingHeadersPatchFns&&ue(),this.instance.requestRouter.loadScript("/static/tracing-headers.js?v=".concat(f.LIB_VERSION),function(eo){if(eo)return G.error("[TRACING-HEADERS] failed to load script",eo);ue()})}},{key:"startIfEnabledOrStop",value:function(){var ue,eo;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):((ue=this._restoreXHRPatch)===null||ue===void 0||ue.call(this),(eo=this._restoreFetchPatch)===null||eo===void 0||eo.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}]),to}();(function(to){to[to.PENDING=-1]="PENDING",to[to.DENIED=0]="DENIED",to[to.GRANTED=1]="GRANTED"})(Br||(Br={}));var jr=function(){function to(ue){i$1(this,to),this.instance=ue}return s(to,[{key:"config",get:function(){return this.instance.config}},{key:"consent",get:function(){return this.getDnt()?Br.DENIED:this.storedConsent}},{key:"isOptedOut",value:function(){return this.consent===Br.DENIED||this.consent===Br.PENDING&&this.config.opt_out_capturing_by_default}},{key:"isOptedIn",value:function(){return!this.isOptedOut()}},{key:"optInOut",value:function(ue){this.storage.set(this.storageKey,ue?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}},{key:"reset",value:function(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}},{key:"storageKey",get:function(){var ue=this.instance.config,eo=ue.token;return(ue.opt_out_capturing_cookie_prefix||"__ph_opt_in_out_")+eo}},{key:"storedConsent",get:function(){var ue=this.storage.get(this.storageKey);return ue==="1"?Br.GRANTED:ue==="0"?Br.DENIED:Br.PENDING}},{key:"storage",get:function(){if(!this._storage){var ue=this.config.opt_out_capturing_persistence_type;this._storage=ue==="localStorage"?at:st;var eo=ue==="localStorage"?st:at;eo.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut(eo.get(this.storageKey)==="1"),eo.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}},{key:"getDnt",value:function(){return!!this.config.respect_dnt&&!!ae([A==null?void 0:A.doNotTrack,A==null?void 0:A.msDoNotTrack,U.doNotTrack],function(ue){return Y([!0,1,"1","yes"],ue)})}}]),to}(),Gr="[Exception Autocapture]",Wr=function(){function to(ue){var eo,no=this;i$1(this,to),o(this,"originalOnUnhandledRejectionHandler",void 0),o(this,"startCapturing",function(){if(T&&no.isEnabled&&!no.hasHandlers&&!no.isCapturing){var ro=T.posthogErrorWrappingFunctions.wrapOnError,oo=T.posthogErrorWrappingFunctions.wrapUnhandledRejection;if(ro&&oo)try{no.unwrapOnError=ro(no.captureException.bind(no)),no.unwrapUnhandledRejection=oo(no.captureException.bind(no))}catch(io){G.error(Gr+" failed to start",io),no.stopCapturing()}else G.error(Gr+" failed to load error wrapping functions - cannot start")}}),this.instance=ue,this.remoteEnabled=!((eo=this.instance.persistence)===null||eo===void 0||!eo.props[ve]),this.startIfEnabled()}return s(to,[{key:"isEnabled",get:function(){var ue;return(ue=this.remoteEnabled)!==null&&ue!==void 0&&ue}},{key:"isCapturing",get:function(){var ue;return!(T==null||(ue=T.onerror)===null||ue===void 0||!ue.__POSTHOG_INSTRUMENTED__)}},{key:"hasHandlers",get:function(){return this.originalOnUnhandledRejectionHandler||this.unwrapOnError}},{key:"startIfEnabled",value:function(){this.isEnabled&&!this.isCapturing&&(G.info(Gr+" enabled, starting..."),this.loadScript(this.startCapturing))}},{key:"loadScript",value:function(ue){this.hasHandlers&&ue(),this.instance.requestRouter.loadScript("/static/exception-autocapture.js?v=".concat(f.LIB_VERSION),function(eo){if(eo)return G.error(Gr+" failed to load script",eo);ue()})}},{key:"stopCapturing",value:function(){var ue,eo;(ue=this.unwrapOnError)===null||ue===void 0||ue.call(this),(eo=this.unwrapUnhandledRejection)===null||eo===void 0||eo.call(this)}},{key:"afterDecideResponse",value:function(ue){var eo=ue.autocaptureExceptions;this.remoteEnabled=!!eo||!1,this.instance.persistence&&this.instance.persistence.register(o({},ve,this.remoteEnabled)),this.startIfEnabled()}},{key:"captureException",value:function(ue){var eo=this.instance.requestRouter.endpointFor("ui");ue.$exception_personURL="".concat(eo,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(ue)}}]),to}(),Vr=9e5,zr="[Web Vitals]",Qr=function(){function to(ue){var eo,no=this;i$1(this,to),o(this,"_enabledServerSide",!1),o(this,"_initialized",!1),o(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),o(this,"_flushToCapture",function(){clearTimeout(no._delayedFlushTimer),no.buffer.metrics.length!==0&&(no.instance.capture("$web_vitals",no.buffer.metrics.reduce(function(ro,oo){var io;return t$1(t$1({},ro),{},(o(io={},"$web_vitals_".concat(oo.name,"_event"),t$1({},oo)),o(io,"$web_vitals_".concat(oo.name,"_value"),oo.value),io))},{})),no.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),o(this,"_addToBuffer",function(ro){var oo,io=(oo=no.instance.sessionManager)===null||oo===void 0?void 0:oo.checkAndGetSessionAndWindowId(!0);if(w$1(io))G.error(zr+"Could not read session ID. Dropping metrics!");else{no.buffer=no.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var ao=no._currentURL();w$1(ao)||(R(ro==null?void 0:ro.name)||R(ro==null?void 0:ro.value)?G.error(zr+"Invalid metric received",ro):no._maxAllowedValue&&ro.value>=no._maxAllowedValue?G.error(zr+"Ignoring metric with value >= "+no._maxAllowedValue,ro):(no.buffer.url!==ao&&(no._flushToCapture(),no._delayedFlushTimer=setTimeout(no._flushToCapture,8e3)),w$1(no.buffer.url)&&(no.buffer.url=ao),no.buffer.firstMetricTimestamp=w$1(no.buffer.firstMetricTimestamp)?Date.now():no.buffer.firstMetricTimestamp,no.buffer.metrics.push(t$1(t$1({},ro),{},{$current_url:ao,$session_id:io.sessionId,$window_id:io.windowId,timestamp:Date.now()})),no.buffer.metrics.length===4&&no._flushToCapture()))}}),o(this,"_startCapturing",function(){var ro=U.postHogWebVitalsCallbacks,oo=ro.onLCP,io=ro.onCLS,ao=ro.onFCP,so=ro.onINP;oo&&io&&ao&&so?(oo(no._addToBuffer),io(no._addToBuffer),ao(no._addToBuffer),so(no._addToBuffer),no._initialized=!0):G.error(zr+"web vitals callbacks not loaded - not starting")}),this.instance=ue,this._enabledServerSide=!((eo=this.instance.persistence)===null||eo===void 0||!eo.props[ge]),this.startIfEnabled()}return s(to,[{key:"_maxAllowedValue",get:function(){var ue=b(this.instance.config.capture_performance)&&F(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:Vr;return 0<ue&&ue<=6e4?Vr:ue}},{key:"isEnabled",get:function(){var ue=b(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return x$1(ue)?ue:this._enabledServerSide}},{key:"startIfEnabled",value:function(){this.isEnabled&&!this._initialized&&(G.info(zr+" enabled, starting..."),this.loadScript(this._startCapturing))}},{key:"afterDecideResponse",value:function(ue){var eo=b(ue.capturePerformance)&&!!ue.capturePerformance.web_vitals;this.instance.persistence&&this.instance.persistence.register(o({},ge,eo)),this._enabledServerSide=eo,this.startIfEnabled()}},{key:"loadScript",value:function(ue){T.postHogWebVitalsCallbacks&&ue(),this.instance.requestRouter.loadScript("/static/web-vitals.js?v=".concat(f.LIB_VERSION),function(eo){eo?G.error(zr+" failed to load script",eo):ue()})}},{key:"_currentURL",value:function(){var ue=T?T.location.href:void 0;return ue||G.error(zr+"Could not determine current URL"),ue}}]),to}(),Jr="/e/",Yr=function(){function to(ue){var eo;i$1(this,to),this.instance=ue,this._endpointSuffix=((eo=this.instance.persistence)===null||eo===void 0?void 0:eo.props[pe])||Jr}return s(to,[{key:"endpoint",get:function(){return this.instance.requestRouter.endpointFor("api",this._endpointSuffix)}},{key:"afterDecideResponse",value:function(ue){var eo=ue.autocaptureExceptions;this._endpointSuffix=b(eo)&&eo.endpoint||Jr,this.instance.persistence&&this.instance.persistence.register(o({},pe,this._endpointSuffix))}},{key:"sendExceptionEvent",value:function(ue){this.instance.capture("$exception",ue,{_noTruncate:!0,_batchKey:"exceptionEvent",_url:this.endpoint})}}]),to}(),Xr={},Kr=function(){},Zr="posthog",es=!tr&&(H==null?void 0:H.indexOf("MSIE"))===-1&&(H==null?void 0:H.indexOf("Mozilla"))===-1,ts=function(){var to,ue,eo;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:(ue=L==null?void 0:L.location,eo=ue==null?void 0:ue.hostname,!!S(eo)&&eo.split(".").slice(-2).join(".")!=="herokuapp.com"),persistence:"localStorage+cookie",persistence_name:"",loaded:Kr,store_google:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:D&&S(D==null?void 0:D.search)&&D.search.indexOf("__posthog_debug=true")!==-1||!1,verbose:!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_surveys:!1,enable_recording_console_log:void 0,secure_cookie:(T==null||(to=T.location)===null||to===void 0?void 0:to.protocol)==="https:",ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},inapp_protocol:"//",inapp_link_new_window:!1,request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,on_request_error:function(no){var ro="Bad HTTP status: "+no.statusCode+" "+no.text;G.error(ro)},get_device_id:function(no){return no},_onCapture:Kr,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"always",__add_tracing_headers:!1}},ns=function(to){var ue={};w$1(to.process_person)||(ue.person_profiles=to.process_person),w$1(to.xhr_headers)||(ue.request_headers=to.xhr_headers),w$1(to.cookie_name)||(ue.persistence_name=to.cookie_name),w$1(to.disable_cookie)||(ue.disable_persistence=to.disable_cookie);var eo=J({},ue,to);return m(to.property_blacklist)&&(w$1(to.property_denylist)?eo.property_denylist=to.property_blacklist:m(to.property_denylist)?eo.property_denylist=[].concat(l(to.property_blacklist),l(to.property_denylist)):G.error("Invalid value for property_denylist config: "+to.property_denylist)),eo},is=function(){function to(){i$1(this,to),o(this,"__forceAllowLocalhost",!1)}return s(to,[{key:"_forceAllowLocalhost",get:function(){return this.__forceAllowLocalhost},set:function(ue){G.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=ue}}]),to}(),rs=function(){function to(){var ue=this;i$1(this,to),o(this,"webPerformance",new is),o(this,"version",f.LIB_VERSION),o(this,"_internalEventEmitter",new Sr),this.config=ts(),this.decideEndpointWasHit=!1,this.SentryIntegration=gr,this.sentryIntegration=function(eo){return function(no,ro){var oo=pr(no,ro);return{name:vr,processEvent:function(io){return oo(io)}}}(ue,eo)},this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this.featureFlags=new We(this),this.toolbar=new mi(this),this.scrollManager=new Dr(this),this.pageViewManager=new kr(this),this.surveys=new xr(this),this.exceptions=new Yr(this),this.rateLimiter=new Pr(this),this.requestRouter=new fr(this),this.consent=new jr(this),this.people={set:function(eo,no,ro){var oo=S(eo)?o({},eo,no):eo;ue.setPersonProperties(oo),ro==null||ro({})},set_once:function(eo,no,ro){var oo=S(eo)?o({},eo,no):eo;ue.setPersonProperties(void 0,oo),ro==null||ro({})}},this.on("eventCaptured",function(eo){return G.info("send",eo)})}return s(to,[{key:"init",value:function(ue,eo,no){if(no&&no!==Zr){var ro,oo=(ro=Xr[no])!==null&&ro!==void 0?ro:new to;return oo._init(ue,eo,no),Xr[no]=oo,Xr[Zr][no]=oo,oo}return this._init(ue,eo,no)}},{key:"_init",value:function(ue){var eo,no,ro=this,oo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},io=arguments.length>2?arguments[2]:void 0;if(w$1(ue)||E(ue))return G.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 G.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],this.set_config(J({},ts(),ns(oo),{name:io,token:ue})),this.config.on_xhr_error&&G.error("[posthog] on_xhr_error is deprecated. Use on_request_error instead"),this.compression=oo.disable_compression?void 0:re.GZipJS,this.persistence=new bn(this.config),this.sessionPersistence=this.config.persistence==="sessionStorage"?this.persistence:new bn(t$1(t$1({},this.config),{},{persistence:"sessionStorage"}));var ao=t$1({},this.persistence.props),so=t$1({},this.sessionPersistence.props);if(this._requestQueue=new yi(function(vo){return ro._send_retriable_request(vo)}),this._retryQueue=new lr(this),this.__request_queue=[],this.sessionManager=new dr(this.config,this.persistence),this.sessionPropsManager=new Cr(this.sessionManager,this.persistence),new Ur(this).startIfEnabledOrStop(),this.sessionRecording=new vi(this),this.sessionRecording.startIfEnabledOrStop(),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new Hr(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new Lr(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Qr(this),this.exceptionObserver=new Wr(this),this.exceptionObserver.startIfEnabled(),f.DEBUG=f.DEBUG||this.config.debug,f.DEBUG&&G.info("Starting in debug mode",{this:this,config:oo,thisC:t$1({},this.config),p:ao,s:so}),this._sync_opt_out_with_persistence(),((eo=oo.bootstrap)===null||eo===void 0?void 0:eo.distinctID)!==void 0){var lo,co,uo=this.config.get_device_id(Ke()),fo=(lo=oo.bootstrap)!==null&&lo!==void 0&&lo.isIdentifiedID?uo:oo.bootstrap.distinctID;this.persistence.set_property($e,(co=oo.bootstrap)!==null&&co!==void 0&&co.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:oo.bootstrap.distinctID,$device_id:fo})}if(this._hasBootstrappedFeatureFlags()){var po,ho,_o=Object.keys(((po=oo.bootstrap)===null||po===void 0?void 0:po.featureFlags)||{}).filter(function(vo){var yo,wo;return!((yo=oo.bootstrap)===null||yo===void 0||(wo=yo.featureFlags)===null||wo===void 0||!wo[vo])}).reduce(function(vo,yo){var wo,ko;return vo[yo]=((wo=oo.bootstrap)===null||wo===void 0||(ko=wo.featureFlags)===null||ko===void 0?void 0:ko[yo])||!1,vo},{}),go=Object.keys(((ho=oo.bootstrap)===null||ho===void 0?void 0:ho.featureFlagPayloads)||{}).filter(function(vo){return _o[vo]}).reduce(function(vo,yo){var wo,ko,So,Eo;return(wo=oo.bootstrap)!==null&&wo!==void 0&&(ko=wo.featureFlagPayloads)!==null&&ko!==void 0&&ko[yo]&&(vo[yo]=(So=oo.bootstrap)===null||So===void 0||(Eo=So.featureFlagPayloads)===null||Eo===void 0?void 0:Eo[yo]),vo},{});this.featureFlags.receivedFeatureFlags({featureFlags:_o,featureFlagPayloads:go})}if(!this.get_distinct_id()){var bo=this.config.get_device_id(Ke());this.register_once({distinct_id:bo,$device_id:bo},""),this.persistence.set_property($e,"anonymous")}return T==null||(no=T.addEventListener)===null||no===void 0||no.call(T,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this)),this.toolbar.maybeLoadToolbar(),oo.segment?_r(this,function(){return ro._loaded()}):this._loaded(),y(this.config._onCapture)&&this.on("eventCaptured",function(vo){return ro.config._onCapture(vo.event,vo)}),this}},{key:"_afterDecideResponse",value:function(ue){var eo,no,ro,oo,io,ao,so,lo;this.compression=void 0,ue.supportedCompression&&!this.config.disable_compression&&(this.compression=Y(ue.supportedCompression,re.GZipJS)?re.GZipJS:Y(ue.supportedCompression,re.Base64)?re.Base64:void 0),(eo=ue.analytics)!==null&&eo!==void 0&&eo.endpoint&&(this.analyticsDefaultEndpoint=ue.analytics.endpoint),(no=this.sessionRecording)===null||no===void 0||no.afterDecideResponse(ue),(ro=this.autocapture)===null||ro===void 0||ro.afterDecideResponse(ue),(oo=this.heatmaps)===null||oo===void 0||oo.afterDecideResponse(ue),(io=this.surveys)===null||io===void 0||io.afterDecideResponse(ue),(ao=this.webVitalsAutocapture)===null||ao===void 0||ao.afterDecideResponse(ue),(so=this.exceptions)===null||so===void 0||so.afterDecideResponse(ue),(lo=this.exceptionObserver)===null||lo===void 0||lo.afterDecideResponse(ue)}},{key:"_loaded",value:function(){var ue=this,eo=this.config.advanced_disable_decide;eo||this.featureFlags.setReloadingPaused(!0);try{this.config.loaded(this)}catch(no){G.critical("`loaded` function failed",no)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout(function(){ue.consent.isOptedIn()&&ue._captureInitialPageview()},1),eo||(new pi(this).call(),this.featureFlags.resetRequestQueue())}},{key:"_start_queue_if_opted_in",value:function(){var ue;this.has_opted_out_capturing()||this.config.request_batching&&((ue=this._requestQueue)===null||ue===void 0||ue.enable())}},{key:"_dom_loaded",value:function(){var ue=this;this.has_opted_out_capturing()||z(this.__request_queue,function(eo){return ue._send_retriable_request(eo)}),this.__request_queue=[],this._start_queue_if_opted_in()}},{key:"_handle_unload",value:function(){var ue,eo;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),(ue=this._requestQueue)===null||ue===void 0||ue.unload(),(eo=this._retryQueue)===null||eo===void 0||eo.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}},{key:"_send_request",value:function(ue){var eo=this;this.__loaded&&(es?this.__request_queue.push(ue):this.rateLimiter.isServerRateLimited(ue.batchKey)||(ue.transport=ue.transport||this.config.api_transport,ue.url=ir(ue.url,{ip:this.config.ip?1:0}),ue.headers=t$1({},this.config.request_headers),ue.compression=ue.compression==="best-available"?this.compression:ue.compression,function(no){var ro,oo,io,ao=t$1({},no);ao.timeout=ao.timeout||6e4,ao.url=ir(ao.url,{_:new Date().getTime().toString(),ver:f.LIB_VERSION,compression:ao.compression});var so=(ro=ao.transport)!==null&&ro!==void 0?ro:"XHR",lo=(oo=(io=ae(or,function(co){return co.transport===so}))===null||io===void 0?void 0:io.method)!==null&&oo!==void 0?oo:or[0].method;if(!lo)throw new Error("No available transport method");lo(ao)}(t$1(t$1({},ue),{},{callback:function(no){var ro,oo,io;eo.rateLimiter.checkForLimiting(no),no.statusCode>=400&&((oo=(io=eo.config).on_request_error)===null||oo===void 0||oo.call(io,no)),(ro=ue.callback)===null||ro===void 0||ro.call(ue,no)}}))))}},{key:"_send_retriable_request",value:function(ue){this._retryQueue?this._retryQueue.retriableRequest(ue):this._send_request(ue)}},{key:"_execute_array",value:function(ue){var eo,no=this,ro=[],oo=[],io=[];z(ue,function(so){so&&(eo=so[0],m(eo)?io.push(so):y(so)?so.call(no):m(so)&&eo==="alias"?ro.push(so):m(so)&&eo.indexOf("capture")!==-1&&y(no[eo])?io.push(so):oo.push(so))});var ao=function(so,lo){z(so,function(co){if(m(co[0])){var uo=lo;Q(co,function(fo){uo=uo[fo[0]].apply(uo,fo.slice(1))})}else this[co[0]].apply(this,co.slice(1))},lo)};ao(ro,this),ao(oo,this),ao(io,this)}},{key:"_hasBootstrappedFeatureFlags",value:function(){var ue,eo;return((ue=this.config.bootstrap)===null||ue===void 0?void 0:ue.featureFlags)&&Object.keys((eo=this.config.bootstrap)===null||eo===void 0?void 0:eo.featureFlags).length>0||!1}},{key:"push",value:function(ue){this._execute_array([ue])}},{key:"capture",value:function(ue,eo,no){var ro;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!w$1(ue)&&S(ue)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var oo=no!=null&&no.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(oo==null||!oo.isRateLimited){this.sessionPersistence.update_search_keyword(),this.config.store_google&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.store_google||this.config.save_referrer)&&this.persistence.set_initial_person_info();var io=new Date,ao=(no==null?void 0:no.timestamp)||io,so={uuid:Ke(),event:ue,properties:this._calculate_event_properties(ue,eo||{},ao)};oo&&(so.properties.$lib_rate_limit_remaining_tokens=oo.remainingTokens),no!=null&&no.$set&&(so.$set=no==null?void 0:no.$set);var lo=this._calculate_set_once_properties(no==null?void 0:no.$set_once);lo&&(so.$set_once=lo),(so=ie$2(so,no!=null&&no._noTruncate?null:this.config.properties_string_max_length)).timestamp=ao,w$1(no==null?void 0:no.timestamp)||(so.properties.$event_time_override_provided=!0,so.properties.$event_time_override_system_time=io);var co=t$1(t$1({},so.properties.$set),so.$set);k(co)||this.setPersonPropertiesForFlags(co),this._internalEventEmitter.emit("eventCaptured",so);var uo={method:"POST",url:(ro=no==null?void 0:no._url)!==null&&ro!==void 0?ro:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:so,compression:"best-available",batchKey:no==null?void 0:no._batchKey};return!this.config.request_batching||no&&(no==null||!no._batchKey)||no!=null&&no.send_instantly?this._send_retriable_request(uo):this._requestQueue.enqueue(uo),so}G.critical("This capture call is ignored due to client rate limiting.")}}else G.error("No event name provided to posthog.capture")}else G.uninitializedWarning("posthog.capture")}},{key:"_addCaptureHook",value:function(ue){this.on("eventCaptured",function(eo){return ue(eo.event,eo)})}},{key:"_calculate_event_properties",value:function(ue,eo,no){if(no=no||new Date,!this.persistence||!this.sessionPersistence)return eo;var ro=this.persistence.remove_event_timer(ue),oo=t$1({},eo);if(oo.token=this.config.token,ue==="$snapshot"){var io=t$1(t$1({},this.persistence.properties()),this.sessionPersistence.properties());return oo.distinct_id=io.distinct_id,(!S(oo.distinct_id)&&!F(oo.distinct_id)||E(oo.distinct_id))&&G.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),oo}var ao=mn.properties();if(this.sessionManager){var so=this.sessionManager.checkAndGetSessionAndWindowId(),lo=so.sessionId,co=so.windowId;oo.$session_id=lo,oo.$window_id=co}if(this.requestRouter.region===ur.CUSTOM&&(oo.$lib_custom_api_host=this.config.api_host),this.sessionPropsManager&&this.config.__preview_send_client_session_params&&(ue==="$pageview"||ue==="$pageleave"||ue==="$autocapture")){var uo=this.sessionPropsManager.getSessionProps();oo=J(oo,uo)}if(!this.config.disable_scroll_properties){var fo={};ue==="$pageview"?fo=this.pageViewManager.doPageView(no):ue==="$pageleave"&&(fo=this.pageViewManager.doPageLeave(no)),oo=J(oo,fo)}if(ue==="$pageview"&&L&&(oo.title=L.title),!w$1(ro)){var po=no.getTime()-ro;oo.$duration=parseFloat((po/1e3).toFixed(3))}H&&this.config.opt_out_useragent_filter&&(oo.$browser_type=this._is_bot()?"bot":"browser"),(oo=J({},ao,this.persistence.properties(),this.sessionPersistence.properties(),oo)).$is_identified=this._isIdentified(),m(this.config.property_denylist)?Q(this.config.property_denylist,function(_o){delete oo[_o]}):G.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var ho=this.config.sanitize_properties;return ho&&(oo=ho(oo,ue)),oo.$process_person_profile=this._hasPersonProcessing(),oo}},{key:"_calculate_set_once_properties",value:function(ue){if(!this.persistence||!this._hasPersonProcessing())return ue;var eo=J({},this.persistence.get_initial_props(),ue||{});return k(eo)?void 0:eo}},{key:"register",value:function(ue,eo){var no;(no=this.persistence)===null||no===void 0||no.register(ue,eo)}},{key:"register_once",value:function(ue,eo,no){var ro;(ro=this.persistence)===null||ro===void 0||ro.register_once(ue,eo,no)}},{key:"register_for_session",value:function(ue){var eo;(eo=this.sessionPersistence)===null||eo===void 0||eo.register(ue)}},{key:"unregister",value:function(ue){var eo;(eo=this.persistence)===null||eo===void 0||eo.unregister(ue)}},{key:"unregister_for_session",value:function(ue){var eo;(eo=this.sessionPersistence)===null||eo===void 0||eo.unregister(ue)}},{key:"_register_single",value:function(ue,eo){this.register(o({},ue,eo))}},{key:"getFeatureFlag",value:function(ue,eo){return this.featureFlags.getFeatureFlag(ue,eo)}},{key:"getFeatureFlagPayload",value:function(ue){var eo=this.featureFlags.getFeatureFlagPayload(ue);try{return JSON.parse(eo)}catch{return eo}}},{key:"isFeatureEnabled",value:function(ue,eo){return this.featureFlags.isFeatureEnabled(ue,eo)}},{key:"reloadFeatureFlags",value:function(){this.featureFlags.reloadFeatureFlags()}},{key:"updateEarlyAccessFeatureEnrollment",value:function(ue,eo){this.featureFlags.updateEarlyAccessFeatureEnrollment(ue,eo)}},{key:"getEarlyAccessFeatures",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return this.featureFlags.getEarlyAccessFeatures(ue,eo)}},{key:"on",value:function(ue,eo){return this._internalEventEmitter.on(ue,eo)}},{key:"onFeatureFlags",value:function(ue){return this.featureFlags.onFeatureFlags(ue)}},{key:"onSessionId",value:function(ue){var eo,no;return(eo=(no=this.sessionManager)===null||no===void 0?void 0:no.onSessionId(ue))!==null&&eo!==void 0?eo:function(){}}},{key:"getSurveys",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getSurveys(ue,eo)}},{key:"getActiveMatchingSurveys",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getActiveMatchingSurveys(ue,eo)}},{key:"renderSurvey",value:function(ue,eo){this.surveys.renderSurvey(ue,eo)}},{key:"canRenderSurvey",value:function(ue){this.surveys.canRenderSurvey(ue)}},{key:"getNextSurveyStep",value:function(ue,eo,no){return this.surveys.getNextSurveyStep(ue,eo,no)}},{key:"identify",value:function(ue,eo,no){if(!this.__loaded||!this.persistence)return G.uninitializedWarning("posthog.identify");if(F(ue)&&(ue=ue.toString(),G.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),ue){if(["distinct_id","distinctid"].includes(ue.toLowerCase()))G.critical('The string "'.concat(ue,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else if(this._requirePersonProcessing("posthog.identify")){var ro=this.get_distinct_id();if(this.register({$user_id:ue}),!this.get_property("$device_id")){var oo=ro;this.register_once({$had_persisted_distinct_id:!0,$device_id:oo},"")}ue!==ro&&ue!==this.get_property(ce)&&(this.unregister(ce),this.register({distinct_id:ue}));var io=(this.persistence.get_property($e)||"anonymous")==="anonymous";ue!==ro&&io?(this.persistence.set_property($e,"identified"),this.setPersonPropertiesForFlags(eo||{},!1),this.capture("$identify",{distinct_id:ue,$anon_distinct_id:ro},{$set:eo||{},$set_once:no||{}}),this.featureFlags.setAnonymousDistinctId(ro)):(eo||no)&&this.setPersonProperties(eo,no),ue!==ro&&(this.reloadFeatureFlags(),this.unregister(Ce))}}else G.error("Unique user id has not been set in posthog.identify")}},{key:"setPersonProperties",value:function(ue,eo){(ue||eo)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(ue||{}),this.capture("$set",{$set:ue||{},$set_once:eo||{}}))}},{key:"group",value:function(ue,eo,no){if(ue&&eo){if(this._requirePersonProcessing("posthog.group")){var ro=this.getGroups();ro[ue]!==eo&&this.resetGroupPropertiesForFlags(ue),this.register({$groups:t$1(t$1({},ro),{},o({},ue,eo))}),no&&(this.capture("$groupidentify",{$group_type:ue,$group_key:eo,$group_set:no}),this.setGroupPropertiesForFlags(o({},ue,no))),ro[ue]===eo||no||this.reloadFeatureFlags()}}else G.error("posthog.group requires a group type and group key")}},{key:"resetGroups",value:function(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}},{key:"setPersonPropertiesForFlags",value:function(ue){var eo=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this._requirePersonProcessing("posthog.setPersonPropertiesForFlags")&&this.featureFlags.setPersonPropertiesForFlags(ue,eo)}},{key:"resetPersonPropertiesForFlags",value:function(){this.featureFlags.resetPersonPropertiesForFlags()}},{key:"setGroupPropertiesForFlags",value:function(ue){var eo=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(ue,eo)}},{key:"resetGroupPropertiesForFlags",value:function(ue){this.featureFlags.resetGroupPropertiesForFlags(ue)}},{key:"reset",value:function(ue){var eo,no,ro,oo;if(G.info("reset"),!this.__loaded)return G.uninitializedWarning("posthog.reset");var io=this.get_property("$device_id");this.consent.reset(),(eo=this.persistence)===null||eo===void 0||eo.clear(),(no=this.sessionPersistence)===null||no===void 0||no.clear(),(ro=this.persistence)===null||ro===void 0||ro.set_property($e,"anonymous"),(oo=this.sessionManager)===null||oo===void 0||oo.resetSessionId();var ao=this.config.get_device_id(Ke());this.register_once({distinct_id:ao,$device_id:ue?ao:io},"")}},{key:"get_distinct_id",value:function(){return this.get_property("distinct_id")}},{key:"getGroups",value:function(){return this.get_property("$groups")||{}}},{key:"get_session_id",value:function(){var ue,eo;return(ue=(eo=this.sessionManager)===null||eo===void 0?void 0:eo.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&ue!==void 0?ue:""}},{key:"get_session_replay_url",value:function(ue){if(!this.sessionManager)return"";var eo=this.sessionManager.checkAndGetSessionAndWindowId(!0),no=eo.sessionId,ro=eo.sessionStartTimestamp,oo=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(no));if(ue!=null&&ue.withTimestamp&&ro){var io,ao=(io=ue.timestampLookBack)!==null&&io!==void 0?io:10;if(!ro)return oo;var so=Math.max(Math.floor((new Date().getTime()-ro)/1e3)-ao,0);oo+="?t=".concat(so)}return oo}},{key:"alias",value:function(ue,eo){return ue===this.get_property(le)?(G.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(w$1(eo)&&(eo=this.get_distinct_id()),ue!==eo?(this._register_single(ce,ue),this.capture("$create_alias",{alias:ue,distinct_id:eo})):(G.warn("alias matches current distinct_id - skipping api call."),this.identify(ue),-1)):void 0}},{key:"set_config",value:function(ue){var eo,no,ro,oo,io=t$1({},this.config);b(ue)&&(J(this.config,ns(ue)),(eo=this.persistence)===null||eo===void 0||eo.update_config(this.config,io),this.sessionPersistence=this.config.persistence==="sessionStorage"?this.persistence:new bn(t$1(t$1({},this.config),{},{persistence:"sessionStorage"})),at.is_supported()&&at.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(f.DEBUG=!0,G.info("set_config",{config:ue,oldConfig:io,newConfig:t$1({},this.config)})),(no=this.sessionRecording)===null||no===void 0||no.startIfEnabledOrStop(),(ro=this.autocapture)===null||ro===void 0||ro.startIfEnabled(),(oo=this.heatmaps)===null||oo===void 0||oo.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}},{key:"startSessionRecording",value:function(ue){var eo,no=x$1(ue)&&ue;if(no||ue!=null&&ue.sampling){var ro,oo,io=(ro=this.sessionManager)===null||ro===void 0?void 0:ro.checkAndGetSessionAndWindowId();(oo=this.persistence)===null||oo===void 0||oo.register(o({},Ee,!0)),G.info("Session recording started with sampling override for session: ",io==null?void 0:io.sessionId)}(no||ue!=null&&ue.linked_flag)&&((eo=this.sessionRecording)===null||eo===void 0||eo.overrideLinkedFlag(),G.info("Session recording started with linked_flags override")),this.set_config({disable_session_recording:!1})}},{key:"stopSessionRecording",value:function(){this.set_config({disable_session_recording:!0})}},{key:"sessionRecordingStarted",value:function(){var ue;return!((ue=this.sessionRecording)===null||ue===void 0||!ue.started)}},{key:"captureException",value:function(ue,eo){var no=y(U.parseErrorAsProperties)?U.parseErrorAsProperties([ue.message,void 0,void 0,void 0,ue]):t$1({$exception_type:ue.name,$exception_message:ue.message,$exception_level:"error"},eo);this.exceptions.sendExceptionEvent(no)}},{key:"loadToolbar",value:function(ue){return this.toolbar.loadToolbar(ue)}},{key:"get_property",value:function(ue){var eo;return(eo=this.persistence)===null||eo===void 0?void 0:eo.props[ue]}},{key:"getSessionProperty",value:function(ue){var eo;return(eo=this.sessionPersistence)===null||eo===void 0?void 0:eo.props[ue]}},{key:"toString",value:function(){var ue,eo=(ue=this.config.name)!==null&&ue!==void 0?ue:Zr;return eo!==Zr&&(eo=Zr+"."+eo),eo}},{key:"_isIdentified",value:function(){var ue,eo;return((ue=this.persistence)===null||ue===void 0?void 0:ue.get_property($e))==="identified"||((eo=this.sessionPersistence)===null||eo===void 0?void 0:eo.get_property($e))==="identified"}},{key:"_hasPersonProcessing",value:function(){var ue,eo,no,ro;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&k(this.getGroups())&&((ue=this.persistence)===null||ue===void 0||(eo=ue.props)===null||eo===void 0||!eo[ce])&&((no=this.persistence)===null||no===void 0||(ro=no.props)===null||ro===void 0||!ro[qe]))}},{key:"_shouldCapturePageleave",value:function(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&this.config.capture_pageview}},{key:"createPersonProfile",value:function(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}},{key:"_requirePersonProcessing",value:function(ue){return this.config.person_profiles==="never"?(G.error(ue+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(qe,!0),!0)}},{key:"_sync_opt_out_with_persistence",value:function(){var ue,eo,no,ro,oo=this.consent.isOptedOut(),io=this.config.opt_out_persistence_by_default,ao=this.config.disable_persistence||oo&&!!io;((ue=this.persistence)===null||ue===void 0?void 0:ue.disabled)!==ao&&((no=this.persistence)===null||no===void 0||no.set_disabled(ao)),((eo=this.sessionPersistence)===null||eo===void 0?void 0:eo.disabled)!==ao&&((ro=this.sessionPersistence)===null||ro===void 0||ro.set_disabled(ao))}},{key:"opt_in_capturing",value:function(ue){var eo;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),(w$1(ue==null?void 0:ue.captureEventName)||ue!=null&&ue.captureEventName)&&this.capture((eo=ue==null?void 0:ue.captureEventName)!==null&&eo!==void 0?eo:"$opt_in",ue==null?void 0:ue.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}},{key:"opt_out_capturing",value:function(){this.consent.optInOut(!1),this._sync_opt_out_with_persistence()}},{key:"has_opted_in_capturing",value:function(){return this.consent.isOptedIn()}},{key:"has_opted_out_capturing",value:function(){return this.consent.isOptedOut()}},{key:"clear_opt_in_out_capturing",value:function(){this.consent.reset(),this._sync_opt_out_with_persistence()}},{key:"_is_bot",value:function(){return A?function(ue,eo){if(!ue)return!1;var no=ue.userAgent;if(no&&Or(no,eo))return!0;try{var ro=ue==null?void 0:ue.userAgentData;if(ro!=null&&ro.brands&&ro.brands.some(function(oo){return Or(oo==null?void 0:oo.brand,eo)}))return!0}catch{}return!!ue.webdriver}(A,this.config.custom_blocked_useragents):void 0}},{key:"_captureInitialPageview",value:function(){L&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:L.title},{send_instantly:!0}))}},{key:"debug",value:function(ue){ue===!1?(T==null||T.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(T==null||T.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)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}}]),to}();(function(to,ue){for(var eo=0;eo<ue.length;eo++)to.prototype[ue[eo]]=ee(to.prototype[ue[eo]])})(rs,["identify"]);var ss,os=(ss=Xr[Zr]=new rs,function(){function to(){to.done||(to.done=!0,es=!1,Q(Xr,function(ue){ue._dom_loaded()}))}L!=null&&L.addEventListener&&(L.readyState==="complete"?to():L.addEventListener("DOMContentLoaded",to,!1)),T&&oe(T,"load",to,!0)}(),ss);const Events={COMPONENT_CREATED:"component:created",COMPONENT_UPDATED:"component:updated",APP_VIEW_PUBLISHED:"app:view_published",BLOCK_EJECTED:"block:ejected"},EventSource$1={PORTAL:"portal",URL:"url",NOTIFICATION:"notification"};class PosthogClient{constructor(ue){this.token=ue}init(){this.token&&(os.init(this.token,{autocapture:!1,capture_pageview:!1}),os.set_config({persistence:"cookie"}),this.initialised=!0)}identify(ue){this.initialised&&os.identify(ue)}updateUser(ue){this.initialised&&os.people.set(ue)}captureEvent(ue,eo){this.initialised&&(eo.sourceApp="builder",os.capture(ue,eo))}npsFeedback(ue){if(!this.initialised)return;localStorage.setItem(Events.NPS.SUBMITTED,Date.now());const eo={};for(let no in ue)eo[`feedback_${no}`]=ue[no];os.capture(Events.NPS.SUBMITTED,eo)}logout(){this.initialised&&os.reset()}}const posthog=new PosthogClient(void 0);class AnalyticsHub{constructor(){this.clients=[posthog],this.initialised=!1}async activate(){(await API.getAnalyticsStatus()).enabled&&!this.initialised&&(this.clients.forEach(eo=>{eo.init()}),this.initialised=!0)}identify(ue){posthog.identify(ue)}captureException(ue){}captureEvent(ue,eo={}){posthog.captureEvent(ue,eo)}async logout(){posthog.logout()}}const analytics=new AnalyticsHub,capitalise=to=>to&&to.substring(0,1).toUpperCase()+to.substring(1),lowercase=to=>to.substring(0,1).toLowerCase()+to.substring(1),isBuilderInputFocused=to=>{var no,ro,oo;const ue=(no=document.activeElement)==null?void 0:no.tagName.toLowerCase();return!!((((oo=(ro=document.activeElement)==null?void 0:ro.classList)==null?void 0:oo.contains("cm-content"))||["input","textarea"].indexOf(ue)!==-1)&&to.key!=="Escape")},{ContextScopes:ContextScopes$1}=Constants$1,findComponent=(to,ue)=>searchComponentTree(to,eo=>eo._id===ue),findComponentParent=(to,ue,eo)=>{if(!to||!ue)return null;if(to._id===ue)return eo;if(!to._children)return null;for(const no of to._children){const ro=findComponentParent(no,ue,to);if(ro)return ro}return null},findComponentPath=(to,ue,eo=[])=>{if(!to||!ue)return[];if(to._id===ue)return[...eo,to];if(!to._children)return[];for(const no of to._children){const ro=[...eo,to],oo=findComponentPath(no,ue,ro);if(oo!=null&&oo.length)return oo}return[]},findAllMatchingComponents=(to,ue)=>{if(!to||!ue)return[];let eo=[];return to._children&&to._children.forEach(no=>{eo=[...eo,...findAllMatchingComponents(no,ue)]}),ue(to)&&eo.push(to),eo.reverse()},findAllComponents=to=>findAllMatchingComponents(to,()=>!0),findClosestMatchingComponent=(to,ue,eo)=>{if(!eo)return null;const no=findComponentPath(to,ue).reverse();for(let ro of no)if(eo(ro))return ro;return null},searchComponentTree=(to,ue)=>{if(!to||!ue)return null;if(ue(to))return to;if(!to._children)return null;for(const eo of to._children){const no=searchComponentTree(eo,ue);if(no)return no}return null},makeComponentUnique=to=>{if(!to)return;const ue=[],eo=(oo,io)=>{var lo;const ao=oo._id,so=uuid$2();io.push([ao,so]),(lo=oo._children)==null||lo.forEach(co=>eo(co,io))};eo(to,ue);let no=JSON.stringify(to);return ue.forEach(([oo,io])=>{no=no.replace(new RegExp(oo,"g"),io)}),findHBSBlocks(no).forEach(oo=>{let io=oo.replace(/\\"/g,'"'),ao=decodeJSBinding(io);if(ao!=null){ue.forEach(([lo,co])=>{ao=ao.replace(new RegExp(lo,"g"),co)});let so=encodeJSBinding(ao);so=so.replace(/"/g,'\\"'),no=no.replace(oo,so)}}),JSON.parse(no)},getComponentText=to=>{var eo;if(to==null)return"";if(to!=null&&to._instanceName)return to._instanceName;const ue=((eo=to._component)==null?void 0:eo.replace("@budibase/standard-components/",""))||"component";return capitalise(ue)},getComponentName=to=>{var no;if(to==null)return"";const eo=(((no=get_store_value(componentStore))==null?void 0:no.components)||{})[to._component]||{};return eo.friendlyName||eo.name||""},getComponentContexts=to=>{const ue=componentStore.getDefinition(to);let eo=[];return ue!=null&&ue.context&&(eo=Array.isArray(ue.context)?[...ue.context]:[ue.context]),ue!=null&&ue.actions&&eo.push({type:"action",scope:ContextScopes$1.Global,actions:ue.actions.map(no=>typeof no=="string"?{type:no}:no)}),eo},buildContextTree=(to,ue={root:[]},eo="root")=>{if(!to)return ue;const no=getComponentContexts(to._component);return no.length&&(ue[eo].push(to._id),no.some(ro=>ro.scope===ContextScopes$1.Local)&&(eo=to._id,ue[to._id]=[])),to._children&&to._children.forEach(ro=>{buildContextTree(ro,ue,eo)}),ue},buildContextTreeLookupMap=to=>{const ue=buildContextTree(to);let eo={};return Object.entries(ue).forEach(([no,ro])=>{ro.forEach(oo=>{eo[oo]=no})}),eo},getChildIdsForComponent=to=>[to._id,...((to==null?void 0:to._children)??[]).map(getChildIdsForComponent).flat(1)],TableNames={USERS:"ta_users"},AppStatus={ALL:"all",DEV:"development",DEPLOYED:"published"},IntegrationNames={POSTGRES:"PostgreSQL",MONGODB:"MongoDB",COUCHDB:"CouchDB",S3:"S3",MYSQL:"MySQL",REST:"REST",DYNAMODB:"DynamoDB",ELASTICSEARCH:"ElasticSearch",SQL_SERVER:"SQL Server",AIRTABLE:"Airtable",ARANGODB:"ArangoDB",ORACLE:"Oracle",GOOGLE_SHEETS:"Google Sheets"},UNEDITABLE_USER_FIELDS=["email","password","roleId","status","firstName","lastName"],APP_NAME_REGEX=/^[\w\s]+$/,APP_URL_REGEX=/^[0-9a-zA-Z-_]+$/,DefaultAppTheme={primaryColor:"var(--spectrum-global-color-blue-600)",primaryColorHover:"var(--spectrum-global-color-blue-500)",buttonBorderRadius:"16px",navBackground:"var(--spectrum-global-color-gray-50)",navTextColor:"var(--spectrum-global-color-gray-800)"},PluginSource={URL:"URL",NPM:"NPM",GITHUB:"Github",FILE:"File Upload"},OnboardingType={EMAIL:"email",PASSWORD:"password"},PlanModel={PER_USER:"perUser"},ChangelogURL="https://docs.budibase.com/changelog",AutoScreenTypes={BLANK:"blank",TABLE:"table",FORM:"form"},actions=[{name:"Save Row",type:"data",component:"SaveRow",context:[{label:"Saved row",value:"row"}]},{name:"Duplicate Row",type:"data",component:"DuplicateRow",context:[{label:"Duplicated row",value:"row"}]},{name:"Delete Row",displayName:"Delete Rows",type:"data",component:"DeleteRow"},{name:"Fetch Row",type:"data",component:"FetchRow",context:[{label:"Fetched row",value:"row"}]},{name:"Navigate To",type:"application",component:"NavigateTo"},{name:"Execute Query",type:"data",component:"ExecuteQuery",context:[{label:"Query result",value:"result"}]},{name:"Trigger Automation",type:"application",component:"TriggerAutomation",context:[{label:"Automation Result",value:"result"}]},{name:"Update Field Value",type:"form",component:"UpdateFieldValue"},{name:"Scroll To Field",type:"form",component:"ScrollTo"},{name:"Validate Form",type:"form",component:"ValidateForm"},{name:"Change Form Step",type:"form",component:"ChangeFormStep"},{name:"Clear Form",type:"form",component:"ClearForm"},{name:"Log Out",type:"application",component:"LogOut"},{name:"Close Screen Modal",type:"application",component:"CloseScreenModal"},{name:"Refresh Data Provider",type:"data",component:"RefreshDataProvider"},{name:"Update State",type:"data",component:"UpdateState",dependsOnFeature:"state"},{name:"Upload File to S3",type:"data",component:"S3Upload",context:[{label:"File URL",value:"publicUrl"}]},{name:"Export Data",type:"data",component:"ExportData"},{name:"Continue if / Stop if",type:"logic",component:"ContinueIf",dependsOnFeature:"continueIfAction"},{name:"Show Notification",type:"application",component:"ShowNotification",dependsOnFeature:"showNotificationAction"},{name:"Prompt User",type:"application",component:"PromptUser"},{name:"Open Side Panel",type:"application",component:"OpenSidePanel",dependsOnFeature:"sidePanel"},{name:"Close Side Panel",type:"application",component:"CloseSidePanel",dependsOnFeature:"sidePanel"},{name:"Open Modal",type:"application",component:"OpenModal",dependsOnFeature:"modal"},{name:"Close Modal",type:"application",component:"CloseModal",dependsOnFeature:"modal"},{name:"Clear Row Selection",type:"data",component:"ClearRowSelection"},{name:"Download File",type:"data",component:"DownloadFile"},{name:"Row Action",type:"data",component:"RowAction"}],ActionDefinitions={actions},DEFAULT_CONFIG={platformUrl:"",logoUrl:void 0,faviconUrl:void 0,emailBrandingEnabled:!0,testimonialsEnabled:!0,platformTitle:"Budibase",loginHeading:void 0,loginButton:void 0,metaDescription:void 0,metaImageUrl:void 0,metaTitle:void 0,docsUrl:void 0,company:"Budibase",oidc:void 0,google:void 0,googleDatasourceConfigured:void 0,oidcCallbackUrl:"",googleCallbackUrl:"",isSSOEnforced:!1,loaded:!1};function createOrganisationStore(){const to=writable(DEFAULT_CONFIG),{subscribe:ue,set:eo}=to;async function no(){const oo=get_store_value(auth).tenantId,io=await API.getTenantConfig(oo);eo({...DEFAULT_CONFIG,...io.config,loaded:!0})}async function ro(oo){const io=_$3.cloneDeep(get_store_value(to));delete io.oidc,delete io.google,delete io.googleDatasourceConfigured,delete io.oidcCallbackUrl,delete io.googleCallbackUrl,delete io.loaded,await API.saveConfig({type:"settings",config:{...io,...oo}}),await no()}return{subscribe:ue,set:eo,save:ro,init:no}}const organisation=createOrganisationStore();function createUsersStore(){const{subscribe:to,set:ue}=writable({});async function eo(So={}){const Eo=await API.searchUsers(So);return ue({...Eo,...So}),Eo}async function no(So){try{return await API.getUser(So)}catch{return null}}const ro=async()=>await API.getUsers();async function oo(So){return await API.onboardUsers(So)}async function io(So){const Eo=So.map(Io=>{let Ao;return Io.admin||Io.builder?Ao={global:!0}:Io.creator&&(Ao={creator:!0}),{email:Io.email,userInfo:{admin:Io.admin?{global:!0}:void 0,builder:Ao,userGroups:Io.groups,roles:Io.apps?Io.apps:void 0}}});return API.inviteUsers(Eo)}async function ao(So){return API.removeUserInvites(So)}async function so(So,Eo,Io,Ao){return API.acceptInvite({inviteCode:So,password:Eo,firstName:Io,lastName:Ao!=null&&Ao.trim()?Ao:void 0})}async function lo(So){return API.getUserInvite(So)}async function co(){return API.getUserInvites()}async function uo(So){return API.updateUserInvite(So.code,So)}async function fo(So){let Eo=So.users.map(Ao=>{const To={email:Ao.email,password:Ao.password,roles:{}};switch(Ao.forceResetPassword&&(To.forceResetPassword=Ao.forceResetPassword),Ao.role){case"appUser":To.builder={global:!1},To.admin={global:!1};break;case"developer":To.builder={global:!0};break;case"creator":To.builder={creator:!0,global:!1};break;case"admin":To.admin={global:!0},To.builder={global:!0};break}return To});const Io=await API.createUsers(Eo,So.groups);return await eo(),Io}async function po(So){await API.deleteUser(So),lodashExports.update(Eo=>Eo.filter(Io=>Io._id!==So))}async function ho(So){return await API.getUserCountByApp(So)}async function _o(So){return API.deleteUsers(So)}async function go(So){return await API.saveUser(So)}async function bo(So,Eo){return await API.addAppBuilder(So,Eo)}async function vo(So,Eo){return await API.removeAppBuilder(So,Eo)}async function yo(){return await API.getAccountHolder()}const wo=So=>So&&So.email===So.tenantOwnerEmail?BudibaseRoles.Owner:isAdmin(So)?BudibaseRoles.Admin:isBuilder(So)?BudibaseRoles.Developer:hasCreatorPermissions(So)?BudibaseRoles.Creator:BudibaseRoles.AppUser,ko=So=>async(...Eo)=>{const Io=await So(...Eo);return await licensing.setQuotaUsage(),Io};return{subscribe:to,search:eo,get:no,getUserRole:wo,fetch:ro,invite:io,onboard:oo,fetchInvite:lo,getInvites:co,removeInvites:ao,updateInvite:uo,getUserCountByApp:ho,addAppBuilder:bo,removeAppBuilder:vo,acceptInvite:so,create:ko(fo),save:ko(go),bulkDelete:ko(_o),delete:ko(po),getAccountHolder:yo}}const users=createUsersStore();function createAdminStore(){const to=writable({loaded:!1,multiTenancy:!1,cloud:!1,isDev:!1,disableAccountPortal:!1,offlineMode:!1,maintenance:[]});async function ue(){await oo(),await eo(),get_store_value(to).cloud&&(await ro(),no()),to.update(ao=>(ao.loaded=!0,ao))}async function eo(){const ao=await API.getEnvironment();to.update(so=>(so.multiTenancy=ao.multiTenancy,so.cloud=ao.cloud,so.disableAccountPortal=ao.disableAccountPortal,so.accountPortalUrl=ao.accountPortalUrl,so.isDev=ao.isDev,so.baseUrl=ao.baseUrl,so.offlineMode=ao.offlineMode,so.maintenance=ao.maintenance,so.passwordMinLength=ao.passwordMinLength,so))}const no=async()=>{var so,lo;const ao=(lo=(so=get_store_value(to))==null?void 0:so.status)==null?void 0:lo.health;ao!=null&&ao.passing||await banner.showStatus()};async function ro(){const ao=await API.getSystemStatus();to.update(so=>(so.status=ao,so))}async function oo(){const ao=get_store_value(auth).tenantId,so=await API.getChecklist(ao);to.update(lo=>(lo.checklist=so,lo))}function io(){to.update(ao=>(ao.loaded=!1,ao))}return{subscribe:to.subscribe,init:ue,unload:io,getChecklist:oo}}const admin=createAdminStore();class AuthStore extends BudiStore{constructor(){super({accountPortalAccess:!1,tenantId:"default",tenantSet:!1,loaded:!1,postLogout:!1,isSSO:!1})}setUser(ue){this.set({loaded:!0,user:ue,accountPortalAccess:!!(ue!=null&&ue.accountPortalAccess),tenantId:(ue==null?void 0:ue.tenantId)||"default",tenantSet:!!ue,isSSO:ue!=null&&isSSOUser(ue),postLogout:!1}),ue&&analytics.activate().then(()=>{analytics.identify(ue._id)}).catch(()=>{})}async setOrganisation(ue){const eo=get_store_value(this.store).tenantId;auth.update(no=>(no.tenantId=ue,no.tenantSet=!!ue,no)),eo!==ue&&await admin.init()}async setInitInfo(ue){return await API.setInitInfo(ue),auth.update(eo=>(eo.initInfo=ue,eo)),ue}setPostLogout(){auth.update(ue=>(ue.postLogout=!0,ue))}async getInitInfo(){const ue=await API.getInitInfo();return auth.update(eo=>(eo.initInfo=ue,eo)),ue}async checkQueryString(){const eo=new URLSearchParams(window.location.search).get("tenantId");eo&&await this.setOrganisation(eo)}async setOrg(ue){await this.setOrganisation(ue)}async getSelf(){try{const ue=await API.fetchBuilderSelf();this.setUser(ue)}catch{this.setUser()}}async login(ue,eo){const no=get_store_value(this.store).tenantId;await API.logIn(no,ue,eo),await this.getSelf()}async logout(){await API.logOut(),this.setPostLogout(),this.setUser(),await this.setInitInfo({})}async updateSelf(ue){await API.updateSelf(ue);try{const eo=await API.fetchBuilderSelf();this.setUser(eo)}catch{this.setUser()}}async forgotPassword(ue){const eo=get_store_value(this.store).tenantId;await API.requestForgotPassword(eo,ue)}async resetPassword(ue,eo){const no=get_store_value(this.store).tenantId;await API.resetPassword(no,ue,eo)}async generateAPIKey(){return API.generateAPIKey()}async fetchAPIKey(){const ue=await API.fetchDeveloperInfo();return ue==null?void 0:ue.apiKey}}const auth=new AuthStore;class AppsStore extends BudiStore{constructor(){super({apps:[]}),this.extractAppId=this.extractAppId.bind(this),this.getProdAppID=this.getProdAppID.bind(this),this.updateSort=this.updateSort.bind(this),this.load=this.load.bind(this),this.save=this.save.bind(this)}extractAppId(ue){const eo=(ue==null?void 0:ue.split("_"))||[];return eo.length?eo[eo.length-1]:null}getProdAppID(ue){if(!ue)return ue;let eo,no="";if(ue.startsWith("app_dev")){const ro=ue.split("app_dev");ro.shift(),eo=ro.join("app_dev")}else if(!ue.startsWith("app"))eo=ue,no="_";else return ue;return`app${no}${eo}`}async updateSort(ue){this.update(eo=>({...eo,sortBy:ue})),await this.updateUserSort(ue)}async updateUserSort(ue){try{await auth.updateSelf({appSort:ue})}catch(eo){console.error("couldn't save user sort: ",eo)}}async load(){const ue=await API.getApps();if(Array.isArray(ue)){let eo={},no=ue.filter(io=>io.status===AppStatus.DEV),ro=ue.filter(io=>io.status===AppStatus.DEPLOYED);no.forEach(io=>{const ao=this.extractAppId(io.appId);ao&&(eo[ao]={...io,devId:io.appId,devRev:io._rev})}),ro.forEach(io=>{const ao=this.extractAppId(io.appId);if(!ao||!eo[ao])return;let so={};eo[ao]&&(so={updatedBy:eo[ao].updatedBy,updatedAt:eo[ao].updatedAt}),eo[ao]={...eo[ao],...io,...so,prodId:io.appId,prodRev:io._rev}});const oo=Object.values(eo);oo.forEach(io=>{const ao=this.extractAppId(io.devId);ao&&(io.appId=ao),delete io._id,delete io._rev}),this.update(io=>({...io,apps:oo}))}else this.update(eo=>({...eo,apps:[]}))}async save(ue,eo){await API.saveAppMetadata(ue,eo),this.update(no=>{const ro=no.apps.findIndex(oo=>oo.instance._id===ue);if(ro!==-1){let oo=no.apps[ro];oo={...oo,...eo},no.apps.splice(ro,1,oo)}return no})}}const appsStore=new AppsStore,sortBy=derived([appsStore,auth],([to,ue])=>{var eo;return to.sortBy||((eo=ue.user)==null?void 0:eo.appSort)||"name"}),enrichedApps=derived([appsStore,auth,sortBy],([to,ue,eo])=>{const no=to.apps.map(ro=>{var io;const oo=ue.user;return{...ro,deployed:ro.status===AppStatus.DEPLOYED,lockedYou:ro.lockedBy!=null&&ro.lockedBy.email===(oo==null?void 0:oo.email),lockedOther:ro.lockedBy!=null&&ro.lockedBy.email!==(oo==null?void 0:oo.email),favourite:!!((io=oo==null?void 0:oo.appFavourites)!=null&&io.includes(ro.appId))}});return eo==="status"?no.sort((ro,oo)=>{var io,ao;return ro.favourite===oo.favourite?ro.status===oo.status?((io=ro.name)==null?void 0:io.toLowerCase())<((ao=oo.name)==null?void 0:ao.toLowerCase())?-1:1:ro.status===AppStatus.DEPLOYED?-1:1:ro.favourite?-1:1}):eo==="updated"?no==null?void 0:no.sort((ro,oo)=>{if(ro.favourite===oo.favourite){const io=ro.updatedAt||"9999",ao=oo.updatedAt||"9999";return io<ao?1:-1}return ro.favourite?-1:1}):no==null?void 0:no.sort((ro,oo)=>{var io,ao;return ro.favourite===oo.favourite?((io=ro.name)==null?void 0:io.toLowerCase())<((ao=oo.name)==null?void 0:ao.toLowerCase())?-1:1:ro.favourite?-1:1})});class EmailStore extends BudiStore{constructor(){super({templates:[]})}async fetchTemplates(){const ue=await API.getEmailTemplateDefinitions(),eo=await API.getEmailTemplates();this.set({definitions:ue,templates:eo})}async saveTemplate(ue){const eo=await API.saveEmailTemplate(ue);ue._rev=eo._rev,ue._id=eo._id,this.update(no=>{const ro=no.templates.findIndex(oo=>oo.purpose===eo.purpose);return no.templates.splice(ro,1,ue),no})}}const email=new EmailStore,OIDC_CONFIG={logo:void 0,name:void 0,uuid:void 0};function createOidcStore(){const to=writable(OIDC_CONFIG),{set:ue,subscribe:eo}=to;return{subscribe:eo,set:ue,init:async()=>{const no=get_store_value(auth).tenantId,ro=await API.getOIDCConfig(no);Object.keys(ro||{}).length?ue(...ro):ue(OIDC_CONFIG)}}}const oidc=createOidcStore();function templatesStore(){const{subscribe:to,set:ue}=writable([]);return{subscribe:to,load:async()=>{const eo=await API.getAppTemplates();ue(eo)}}}const templates=templatesStore(),ExpiringKeys={LICENSING_PAYMENT_FAILED:"licensing_payment_failed",LICENSING_ACCOUNT_DOWNGRADED_MODAL:"licensing_account_downgraded_modal",LICENSING_APP_LIMIT_MODAL:"licensing_app_limit_modal",LICENSING_ROWS_WARNING_BANNER:"licensing_rows_warning_banner",LICENSING_AUTOMATIONS_WARNING_BANNER:"licensing_automations_warning_banner",LICENSING_QUERIES_WARNING_BANNER:"licensing_queries_warning_banner",LICENSING_USERS_ABOVE_LIMIT_BANNER:"licensing_users_above_limit_banner"},StripeStatus={PAST_DUE:"past_due",ACTIVE:"active"},UNLIMITED=-1,ONE_DAY_MILLIS=864e5;class LicensingStore extends BudiStore{constructor(){super({goToUpgradePage:()=>{},goToPricingPage:()=>{},license:void 0,isFreePlan:!0,isEnterprisePlan:!0,isBusinessPlan:!0,groupsEnabled:!1,backupsEnabled:!1,brandingEnabled:!1,scimEnabled:!1,environmentVariablesEnabled:!1,budibaseAIEnabled:!1,customAIConfigsEnabled:!1,auditLogsEnabled:!1,quotaUsage:void 0,usageMetrics:void 0,quotaResetDaysRemaining:void 0,quotaResetDate:void 0,accountPastDue:!1,pastDueEndDate:void 0,pastDueDaysRemaining:void 0,accountDowngraded:!1,userCount:void 0,userLimit:void 0,userLimitReached:!1,errUserLimit:!1})}usersLimitReached(ue,eo=get_store_value(this.store).userLimit){return eo===UNLIMITED||eo===void 0?!1:ue>=eo}usersLimitExceeded(ue,eo=get_store_value(this.store).userLimit){return eo===UNLIMITED||eo===void 0?!1:ue>eo}async isCloud(){let ue=get_store_value(admin);return ue.loaded||(await admin.init(),ue=get_store_value(admin)),ue.cloud}async init(){this.setNavigation(),this.setLicense(),await this.setQuotaUsage()}setNavigation(){var io;const ue=get_store_value(admin),eo=get_store_value(auth),no=(io=eo==null?void 0:eo.user)!=null&&io.accountPortalAccess?`${ue.accountPortalUrl}/portal/upgrade`:"/builder/portal/account/upgrade",ro=()=>{window.location.href=no},oo=()=>{window.open("https://budibase.com/pricing/","_blank")};this.update(ao=>({...ao,goToUpgradePage:ro,goToPricingPage:oo}))}setLicense(){var wo;const ue=(wo=get_store_value(auth).user)==null?void 0:wo.license,eo=ue==null?void 0:ue.plan.type,no=(ue==null?void 0:ue.features)||[],ro=eo===PlanType.ENTERPRISE,oo=eo===PlanType.FREE,io=eo===PlanType.BUSINESS,ao=eo===PlanType.ENTERPRISE_BASIC_TRIAL,so=no.includes(Feature.USER_GROUPS),lo=no.includes(Feature.APP_BACKUPS),co=no.includes(Feature.SCIM),uo=no.includes(Feature.ENVIRONMENT_VARIABLES),fo=no.includes(Feature.ENFORCEABLE_SSO),po=no.includes(Feature.BRANDING),ho=no.includes(Feature.AUDIT_LOGS),_o=no.includes(Feature.SYNC_AUTOMATIONS),go=no.includes(Feature.TRIGGER_AUTOMATION_RUN),bo=no.includes(Feature.APP_BUILDERS),vo=no.includes(Feature.BUDIBASE_AI),yo=no.includes(Feature.AI_CUSTOM_CONFIGS);this.update(ko=>({...ko,license:ue,isEnterprisePlan:ro,isFreePlan:oo,isBusinessPlan:io,isEnterpriseTrial:ao,groupsEnabled:so,backupsEnabled:lo,brandingEnabled:po,budibaseAIEnabled:vo,customAIConfigsEnabled:yo,scimEnabled:co,environmentVariablesEnabled:uo,auditLogsEnabled:ho,enforceableSSO:fo,syncAutomationsEnabled:_o,triggerAutomationRunEnabled:go,perAppBuildersEnabled:bo}))}async setQuotaUsage(){const ue=await API.getQuotaUsage();this.update(eo=>({...eo,quotaUsage:ue})),await this.setUsageMetrics()}async setUsageMetrics(){var ko,So,Eo,Io,Ao,To,zo,Vo,Fo,Po,Ro;const ue=get_store_value(this.store).quotaUsage,eo=(ko=get_store_value(auth).user)==null?void 0:ko.license,no=new Date;if(!eo||!ue)return;const ro=[MonthlyQuotaName.QUERIES,MonthlyQuotaName.AUTOMATIONS].reduce((Do,qo)=>{var Zo;const Uo=eo.quotas.usage.monthly[qo].value,jo=(((Zo=ue.monthly.current)==null?void 0:Zo[qo])||0/Uo)*100;return Do[qo]=Uo>-1?Math.floor(jo):-1,Do},{}),oo=[StaticQuotaName.APPS,StaticQuotaName.ROWS].reduce((Do,qo)=>{const Uo=eo.quotas.usage.static[qo].value,jo=(ue.usageQuota[qo]||0/Uo)*100;return Do[qo]=Uo>-1?Math.floor(jo):-1,Do},{}),io=(Do,qo)=>qo>Do?Math.round((qo.getTime()-Do.getTime())/ONE_DAY_MILLIS):0,ao=new Date(ue.quotaReset),so=io(no,ao),lo=!!((Eo=(So=eo.billing)==null?void 0:So.subscription)!=null&&Eo.downgradeAt)&&((Ao=(Io=eo.billing)==null?void 0:Io.subscription)==null?void 0:Ao.downgradeAt)<=no.getTime()&&((zo=(To=eo.billing)==null?void 0:To.subscription)==null?void 0:zo.status)===StripeStatus.PAST_DUE&&eo.plan.type===PlanType.FREE,co=(Fo=(Vo=eo.billing)==null?void 0:Vo.subscription)==null?void 0:Fo.pastDueAt,uo=(Ro=(Po=eo.billing)==null?void 0:Po.subscription)==null?void 0:Ro.downgradeAt;let fo,po;co&&uo&&(po=new Date(uo),fo=io(new Date(co),po));const _o=eo.quotas.usage.static.users.value,go=ue.usageQuota.users,bo=this.usersLimitReached(go,_o),vo=this.usersLimitExceeded(go,_o),wo=await this.isCloud()&&eo.plan.model===PlanModel$1.PER_USER&&vo;this.update(Do=>({...Do,usageMetrics:{...ro,...oo},quotaResetDaysRemaining:so,quotaResetDate:ao,accountDowngraded:lo,accountPastDue:co!=null,pastDueEndDate:po,pastDueDaysRemaining:fo,userCount:go,userLimit:_o,userLimitReached:bo,errUserLimit:wo}))}}const licensing=new LicensingStore;class GroupStore extends BudiStore{constructor(){super([]),this.updateStore=ue=>{this.update(eo=>{const no=eo.findIndex(ro=>ro._id===ue._id);return no>=0?eo.splice(no,1,ue):eo.push(ue),eo})}}async init(){if(get_store_value(licensing).groupsEnabled){const ue=await API.getGroups();this.set(ue)}}async refreshGroup(ue){const eo=await API.getGroup(ue);this.updateStore(eo)}async save(ue){const{...eo}=ue;delete eo.scimInfo;const no=await API.saveGroup(eo);return ue._id=no._id,ue._rev=no._rev,this.updateStore(ue),ue}async delete(ue){await API.deleteGroup(ue._id,ue._rev),this.update(eo=>{const no=eo.findIndex(ro=>ro._id===ue._id);return no!==-1&&eo.splice(no,1),eo})}async addUser(ue,eo){await API.addUsersToGroup(ue,[eo]),await this.refreshGroup(ue)}async removeUser(ue,eo){await API.removeUsersFromGroup(ue,[eo]),await this.refreshGroup(ue)}async addApp(ue,eo,no){await API.addAppsToGroup(ue,[{appId:eo,roleId:no}]),await this.refreshGroup(ue)}async removeApp(ue,eo){await API.removeAppsFromGroup(ue,[{appId:eo}]),await this.refreshGroup(ue)}getGroupAppIds(ue){var no;let eo=Object.keys((ue==null?void 0:ue.roles)||{});return(no=ue==null?void 0:ue.builder)!=null&&no.apps&&(eo=eo.concat(ue.builder.apps)),eo}async addGroupAppBuilder(ue,eo){return await API.addGroupAppBuilder(ue,eo)}async removeGroupAppBuilder(ue,eo){return await API.removeGroupAppBuilder(ue,eo)}}const groups=new GroupStore;function createPluginsStore(){const{subscribe:to,set:ue,update:eo}=writable([]);async function no(){const ao=await API.getPlugins();ue(ao)}async function ro(ao){await API.deletePlugin(ao),eo(so=>(so=so.filter(lo=>lo._id!==ao),so))}async function oo(ao,so,lo=null){let co={source:ao,url:so};switch(ao){case PluginSource.URL:co.headers=lo;break;case PluginSource.GITHUB:co.githubToken=lo;break}let fo=(await API.createPlugin(co)).plugin;eo(po=>{const ho=po.findIndex(_o=>_o._id===fo._id);return ho>=0?po.splice(ho,1,fo):po.push(fo),po})}async function io(ao){if(!ao)return;let so=new FormData;so.append("file",ao);let co=(await API.uploadPlugin(so)).plugins[0];eo(uo=>{const fo=uo.findIndex(po=>po._id===co._id);return fo>=0?uo.splice(fo,1,co):uo.push(co),uo})}return{subscribe:to,load:no,createPlugin:oo,deletePlugin:ro,uploadPlugin:io}}const plugins$1=createPluginsStore();class BackupStore extends BudiStore{constructor(){super({})}selectBackup(ue){this.update(eo=>(eo.selectedBackup=ue,eo))}async searchBackups(ue,eo){return API.searchBackups(ue,eo)}async restoreBackup(ue,eo,no){return API.restoreBackup(ue,eo,no)}async deleteBackup(ue,eo){return API.deleteBackup(ue,eo)}async createManualBackup(ue){return API.createManualBackup(ue)}}const backups=new BackupStore;class EnvironmentStore extends BudiStore{constructor(){super({variables:[],status:{encryptionKeyAvailable:!1}})}async checkStatus(){const ue=await API.checkEnvironmentVariableStatus();this.update(eo=>(eo.status=ue,eo))}async loadVariables(){if(get_store_value(licensing).environmentVariablesEnabled){const eo=(await API.fetchEnvironmentVariables()).variables.map(no=>({name:no}));this.update(no=>(no.variables=eo,no))}}async createVariable(ue){await API.createEnvironmentVariable(ue);let eo={name:ue.name};this.update(no=>(no.variables=[eo,...no.variables],no))}async deleteVariable(ue){await API.deleteEnvironmentVariable(ue),this.update(eo=>(eo.variables=eo.variables.filter(no=>no.name!==ue),eo))}async updateVariable(ue,eo){await API.updateEnvironmentVariable(ue,eo)}async upgradePanelOpened(){await API.publishEvent(EventPublishType$1.ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED)}}const environment=new EnvironmentStore,isEnabled=to=>{var eo;const ue=get_store_value(auth).user;return!!((eo=ue==null?void 0:ue.flags)!=null&&eo[to])},menu=derived([admin,auth],([to,ue])=>{const eo=ue==null?void 0:ue.user,no=isAdmin(eo),ro=to==null?void 0:to.cloud;let oo=[{title:"Users",href:"/builder/portal/users/users"}];oo.push({title:"Groups",href:"/builder/portal/users/groups"});let io=[{title:"Apps",href:"/builder/portal/apps"}];if(isGlobalBuilder(eo)&&(io.push({title:"Users",href:"/builder/portal/users",subPages:oo}),io.push({title:"Plugins",href:"/builder/portal/plugins"})),no){let so=[{title:"Auth",href:"/builder/portal/settings/auth"},{title:"Email",href:"/builder/portal/settings/email"},{title:"Organisation",href:"/builder/portal/settings/organisation"},{title:"Branding",href:"/builder/portal/settings/branding"},{title:"Environment",href:"/builder/portal/settings/environment"}];isEnabled(FeatureFlag.AI_CUSTOM_CONFIGS)&&so.push({title:"AI",href:"/builder/portal/settings/ai"}),ro||(so.push({title:"Version",href:"/builder/portal/settings/version"}),so.push({title:"Diagnostics",href:"/builder/portal/settings/diagnostics"})),io.push({title:"Settings",href:"/builder/portal/settings",subPages:[...so].sort((lo,co)=>lo.title.localeCompare(co.title))})}let ao=[{title:"Usage",href:"/builder/portal/account/usage"}];return no&&(ao.push({title:"Audit Logs",href:"/builder/portal/account/auditLogs"}),ro||ao.push({title:"System Logs",href:"/builder/portal/account/systemLogs"})),ro&&(eo!=null&&eo.accountPortalAccess)?ao.push({title:"Upgrade",href:(to==null?void 0:to.accountPortalUrl)+"/portal/upgrade"}):!ro&&no&&ao.push({title:"Upgrade",href:"/builder/portal/account/upgrade"}),eo!=null&&eo.accountPortalAccess&&eo.account.stripeCustomerId&&ao.push({title:"Billing",href:(to==null?void 0:to.accountPortalUrl)+"/portal/billing"}),io.push({title:"Account",href:"/builder/portal/account",subPages:ao}),io});class AuditLogsStore extends BudiStore{constructor(){super({})}async search(ue={}){if(get_store_value(licensing).auditLogsEnabled){const eo=await API.searchAuditLogs(ue);return this.update(no=>({...no,logs:eo})),eo}}async getEventDefinitions(){const ue=await API.getEventDefinitions();this.update(eo=>({...eo,events:ue.events}))}getDownloadUrl(ue={}){return API.getDownloadUrl(ue)}}const auditLogs=new AuditLogsStore;class FeatureStore extends DerivedBudiStore{constructor(){const ue=eo=>derived([eo,licensing],([no,ro])=>({isScimEnabled:no.scimConfigEnabled&&ro.scimEnabled}));super({scimConfigEnabled:!1},ue)}async init(){const ue=await API.getConfig(ConfigType.SCIM);this.update(eo=>({...eo,scimConfigEnabled:isConfig(ue)&&isSCIMConfig(ue)&&ue.config.enabled}))}}const features=new FeatureStore,getThemeStore=()=>{const to=document.documentElement,eo=createLocalStorageStore("bb-theme",{theme:DefaultBuilderTheme}),no=derived(eo,ro=>({...ro,theme:ensureValidTheme(ro.theme,DefaultBuilderTheme)}));return no.subscribe(({theme:ro})=>{const oo=getThemeClassNames(ro).split(" ");ThemeOptions.forEach(io=>{const ao=`${ThemeClassPrefix}${io.id}`;to.classList.toggle(ao,oo.includes(ao))})}),{...eo,subscribe:no.subscribe}},themeStore$1=getThemeStore(),createTemporalStore=()=>{const eo=createLocalStorageStore("bb-temporal",{}),no=(oo,io,ao)=>{const so={...io,expiry:Date.now()+ao*1e3};eo.update(lo=>({...lo,[oo]:so}))},ro=oo=>{const io=get_store_value(eo)[oo];return io?io.expiry<Date.now()?(eo.update(so=>(delete so[oo],so)),null):io:void 0};return{subscribe:eo.subscribe,actions:{setExpiring:no,getExpiring:ro}}},temporalStore=createTemporalStore();function createNavigationStore(){const to=writable({initialisated:!1,goto:void 0}),{set:ue,subscribe:eo}=to;return{subscribe:eo,actions:{init:ro=>{if(typeof ro!="function")throw new Error(`gotoFunc must be a function, found a "${typeof ro}" instead`);ue({initialisated:!0,goto:ro})}}}}const navigation=createNavigationStore(),featureFlags=derived(auth,to=>{var ue;return{...FeatureFlagDefaults,...((ue=to==null?void 0:to.user)==null?void 0:ue.flags)||{}}}),sideBarCollapsed=writable(!1),convertOldFieldFormat=to=>to?to.map(eo=>typeof eo=="string"?{field:eo,active:!0}:typeof(eo==null?void 0:eo.active)!="boolean"?{field:eo.name,active:!0}:eo):[],getComponentForField=(to,ue)=>{if(!to||!(ue!=null&&ue[to]))return null;const eo=ue[to].type;return FieldTypeToComponentMap[eo]},FieldTypeToComponentMap={[FieldType.STRING]:"stringfield",[FieldType.NUMBER]:"numberfield",[FieldType.BIGINT]:"bigintfield",[FieldType.OPTIONS]:"optionsfield",[FieldType.ARRAY]:"multifieldselect",[FieldType.BOOLEAN]:"booleanfield",[FieldType.LONGFORM]:"longformfield",[FieldType.DATETIME]:"datetimefield",[FieldType.SIGNATURE_SINGLE]:"signaturesinglefield",[FieldType.ATTACHMENTS]:"attachmentfield",[FieldType.ATTACHMENT_SINGLE]:"attachmentsinglefield",[FieldType.LINK]:"relationshipfield",[FieldType.JSON]:"jsonfield",[FieldType.BARCODEQR]:"codescanner",[FieldType.BB_REFERENCE]:"bbreferencefield",[FieldType.BB_REFERENCE_SINGLE]:"bbreferencesinglefield"},{TypeIconMap}=Constants$1,AUTO_COLUMN_SUB_TYPES=AutoFieldSubType,AUTO_COLUMN_DISPLAY_NAMES={AUTO_ID:"Auto ID",CREATED_BY:"Created By",CREATED_AT:"Created At",UPDATED_BY:"Updated By",UPDATED_AT:"Updated At"},FIELDS={STRING:{name:"Text",type:FieldType.STRING,icon:TypeIconMap[FieldType.STRING],constraints:{type:"string",length:{},presence:!1}},BARCODEQR:{name:"Barcode / QR",type:FieldType.BARCODEQR,icon:TypeIconMap[FieldType.BARCODEQR],constraints:{type:"string",length:{},presence:!1}},LONGFORM:{name:"Long form text",type:FieldType.LONGFORM,icon:TypeIconMap[FieldType.LONGFORM],constraints:{type:"string",length:{},presence:!1}},OPTIONS:{name:"Single select",type:FieldType.OPTIONS,icon:TypeIconMap[FieldType.OPTIONS],constraints:{type:"string",presence:!1,inclusion:[]}},ARRAY:{name:"Multi select",type:FieldType.ARRAY,icon:TypeIconMap[FieldType.ARRAY],constraints:{type:"array",presence:!1,inclusion:[]}},NUMBER:{name:"Number",type:FieldType.NUMBER,icon:TypeIconMap[FieldType.NUMBER],constraints:{type:"number",presence:!1,numericality:{greaterThanOrEqualTo:"",lessThanOrEqualTo:""}}},BIGINT:{name:"Big integer",type:FieldType.BIGINT,icon:TypeIconMap[FieldType.BIGINT]},BOOLEAN:{name:"Boolean",type:FieldType.BOOLEAN,icon:TypeIconMap[FieldType.BOOLEAN],constraints:{type:"boolean",presence:!1}},DATETIME:{name:"Date / time",type:FieldType.DATETIME,icon:TypeIconMap[FieldType.DATETIME],constraints:{type:"string",length:{},presence:!1,datetime:{latest:"",earliest:""}}},ATTACHMENT_SINGLE:{name:"Single attachment",type:FieldType.ATTACHMENT_SINGLE,icon:TypeIconMap[FieldType.ATTACHMENT_SINGLE],constraints:{presence:!1}},ATTACHMENTS:{name:"Multi attachment",type:FieldType.ATTACHMENTS,icon:TypeIconMap[FieldType.ATTACHMENTS],constraints:{type:"array",presence:!1}},SIGNATURE_SINGLE:{name:"Signature",type:FieldType.SIGNATURE_SINGLE,icon:"AnnotatePen",constraints:{presence:!1}},LINK:{name:"Relationship",type:FieldType.LINK,icon:TypeIconMap[FieldType.LINK],constraints:{type:"array",presence:!1}},AUTO:{name:"Auto column",type:FieldType.AUTO,icon:TypeIconMap[FieldType.AUTO],constraints:{}},FORMULA:{name:"Formula",type:FieldType.FORMULA,icon:TypeIconMap[FieldType.FORMULA],constraints:{}},AI:{name:"AI",type:FieldType.AI,icon:TypeIconMap[FieldType.AI],constraints:{}},JSON:{name:"JSON",type:FieldType.JSON,icon:TypeIconMap[FieldType.JSON],constraints:{type:"object",presence:!1}},USER:{name:"Single user",type:FieldType.BB_REFERENCE_SINGLE,subtype:BBReferenceFieldSubType.USER,icon:TypeIconMap[FieldType.BB_REFERENCE_SINGLE][BBReferenceFieldSubType.USER]},USERS:{name:"Multi user",type:FieldType.BB_REFERENCE,subtype:BBReferenceFieldSubType.USER,icon:TypeIconMap[FieldType.BB_REFERENCE][BBReferenceFieldSubType.USER],constraints:{type:"array"}}},Roles$1={ADMIN:"ADMIN",POWER:"POWER",BASIC:"BASIC",PUBLIC:"PUBLIC",BUILDER:"BUILDER"};function isAutoColumnUserRelationship(to){return to===AUTO_COLUMN_SUB_TYPES.CREATED_BY||to===AUTO_COLUMN_SUB_TYPES.UPDATED_BY}const PrettyRelationshipDefinitions={MANY:"Many rows",ONE:"One row"},BUDIBASE_INTERNAL_DB_ID=INTERNAL_TABLE_SOURCE_ID,DEFAULT_BB_DATASOURCE_ID="datasource_internal_bb_default",BUDIBASE_DATASOURCE_TYPE="budibase",DB_TYPE_INTERNAL="internal",DB_TYPE_EXTERNAL="external",IntegrationTypes={POSTGRES:"POSTGRES",MONGODB:"MONGODB",COUCHDB:"COUCHDB",S3:"S3",MYSQL:"MYSQL",REST:"REST",DYNAMODB:"DYNAMODB",ELASTICSEARCH:"ELASTICSEARCH",SQL_SERVER:"SQL_SERVER",AIRTABLE:"AIRTABLE",ARANGODB:"ARANGODB",ORACLE:"ORACLE",INTERNAL:"INTERNAL",GOOGLE_SHEETS:"GOOGLE_SHEETS",FIRESTORE:"FIRESTORE",REDIS:"REDIS",SNOWFLAKE:"SNOWFLAKE"},SchemaTypeOptions=[{label:"Text",value:FieldType.STRING},{label:"Number",value:FieldType.NUMBER},{label:"Boolean",value:FieldType.BOOLEAN},{label:"Datetime",value:FieldType.DATETIME},{label:"JSON",value:FieldType.JSON}],SchemaTypeOptionsExpanded=SchemaTypeOptions.map(to=>({...to,value:{type:to.value}})),RawRestBodyTypes={NONE:"none",FORM:"form",ENCODED:"encoded",JSON:"json",TEXT:"text",XML:"xml"},RestBodyTypes=[{name:"none",value:"none"},{name:"form-data",value:"form"},{name:"x-www-form-encoded",value:"encoded"},{name:"raw (JSON)",value:"json"},{name:"raw (XML)",value:"xml"},{name:"raw (Text)",value:"text"}],PaginationTypes=[{label:"Page number based",value:"page"},{label:"Cursor based",value:"cursor"}],PaginationLocations=[{label:"Query parameters",value:"query"},{label:"Request body",value:"body"}],DatasourceTypes={RELATIONAL:"Relational",NON_RELATIONAL:"Non-relational",SPREADSHEET:"Spreadsheet",OBJECT_STORE:"Object store",GRAPH:"Graph",API:"API"},{ContextScopes}=Constants$1,CAPTURE_VAR_INSIDE_TEMPLATE=/{{([^}]+)}}/g,CAPTURE_VAR_INSIDE_JS=/\$\("([^")]+)"\)/g,UpdateReferenceAction={ADD:"add",DELETE:"delete",MOVE:"move"},getBindableProperties=(to,ue)=>{const eo=getContextBindings(to,ue),no=getUserBindings(),ro=getUrlBindings(to),oo=getDeviceBindings(),io=getStateBindings(),ao=getSelectedRowsBindings(to),so=getRoleBindings(),lo=getEmbedBindings();return[...eo,...ro,...io,...no,...oo,...ao,...so,...lo]},getRestBindings=()=>{const to=get_store_value(licensing).environmentVariablesEnabled;return[...getUserBindings(),...getAuthBindings(),...to?getEnvironmentBindings():[]]},getAuthBindings=()=>{let to=[];const ue=makePropSafe("user"),eo=makePropSafe("oauth2"),no=makePropSafe("accessToken");return to=[{runtime:`${ue}.${eo}.${no}`,readable:"Current User.OAuthToken",key:"accessToken",display:{name:"OAuthToken",type:"text"}}].map(oo=>({type:"context",runtimeBinding:oo.runtime,readableBinding:oo.readable,fieldSchema:{type:"string",name:oo.key},providerId:"user",category:"Current User",display:oo.display})),to},getEnvironmentBindings=()=>get_store_value(environment).variables.map(ue=>({type:"context",runtimeBinding:`env.${makePropSafe(ue.name)}`,readableBinding:`env.${ue.name}`,category:"Environment",icon:"Key",display:{type:"string",name:ue.name}})),toBindingsArray=(to,ue,eo)=>to?Object.keys(to).reduce((no,ro)=>{if(!ro)return no;let oo={type:"context",runtimeBinding:ro,readableBinding:`${ue}.${ro}`,icon:"Brackets"};return eo&&(oo.category=eo),no.push(oo),no},[]):[],readableToRuntimeMap=(to,ue)=>!to||!ue?{}:Object.keys(ue).reduce((eo,no)=>(eo[no]=readableToRuntimeBinding(to,ue[no]),eo),{}),runtimeToReadableMap=(to,ue)=>!to||!ue?{}:Object.keys(ue).reduce((eo,no)=>(eo[no]=runtimeToReadableBinding(to,ue[no]),eo),{}),getComponentBindableProperties=(to,ue)=>{if(!to||!ue)return[];const eo=findComponent(to.props,ue),no=componentStore.getDefinition(eo==null?void 0:eo._component);if(!(no!=null&&no.context))return[];const ro=Array.isArray(no.context)?no.context:[no.context];return generateComponentContextBindings(to,{component:eo,definition:no,contexts:ro})},getAllComponentContexts=(to,ue,eo,no={includeSelf:!1})=>{if(!to||!ue)return[];let ro={};const oo=findComponentPath(to.props,ue),io=oo.map(co=>co._id),ao=buildContextTreeLookupMap(to.props),so=co=>uo=>{const fo=ao[uo._id];if(fo!=="root"&&!io.includes(fo))return;const po=uo._component;getComponentContexts(po).forEach(_o=>{eo&&_o.type!==eo||(_o.scope||ContextScopes.Global)!==co||isContextCompatibleWithComponent(_o,uo)&&(ro[uo._id]||(ro[uo._id]={component:uo,definition:componentStore.getDefinition(po),contexts:[]}),ro[uo._id].contexts.push(_o))})};return findAllComponents(to.props).forEach(so(ContextScopes.Global)),oo.forEach(so(ContextScopes.Local)),no!=null&&no.includeSelf||delete ro[ue],Object.values(ro).filter(co=>co.contexts.length>0)},getActionProviders=(to,ue,eo,no={includeSelf:!1})=>getAllComponentContexts(to,ue,"action",{includeSelf:no==null?void 0:no.includeSelf}).map(oo=>{var io,ao;return{...oo,action:(ao=(io=oo.contexts[0])==null?void 0:io.actions)==null?void 0:ao.find(so=>so.type===eo)}}).filter(({action:oo})=>oo!=null).map(({component:oo,action:io})=>{let ao=oo._id;return io.suffix&&(ao+=`-${io.suffix}`),{readableBinding:oo._instanceName,runtimeBinding:ao}}),getDatasourceForProvider=(to,ue)=>{const eo=componentStore.getComponentSettings(ue==null?void 0:ue._component),no=eo.find(ao=>ao.type==="dataProvider");if(no){const ao=ue[no.key],so=extractLiteralHandlebarsID(ao),lo=findComponent(to==null?void 0:to.props,so);return getDatasourceForProvider(to,lo)}const ro=["dataSource","table","schema"],oo=eo.find(ao=>ro.includes(ao.type));if(!oo)return null;const io=ue[oo==null?void 0:oo.key];return typeof io=="string"?{tableId:io,type:"table"}:io},getContextBindings=(to,ue)=>getAllComponentContexts(to,ue).map(no=>generateComponentContextBindings(to,no)).flat(),generateComponentContextBindings=(to,ue)=>{const{component:eo,definition:no,contexts:ro}=ue;if(!eo||!no||!(ro!=null&&ro.length))return[];let oo=[];return ro.forEach(io=>{var ho;if(!(io!=null&&io.type))return;let ao,so,lo,co=io.suffix;if(io.type==="form")ao=buildFormSchema(eo,to),lo="Fields";else if(io.type==="static")ao={},(io.values||[]).forEach(go=>{ao[go.key]={name:go.label,type:go.type||"string"}});else if(io.type==="schema"){const _o=getDatasourceForProvider(to,eo);if(!_o)return;const go=getSchemaForDatasource(to,_o);if(ao=go.schema,so=go.table,_o.type==="jsonarray"||_o.type==="queryarray"){const bo=_o.label.split(".");lo=bo[bo.length-1]}else if(_o.type==="viewV2"){const bo=Object.values((so==null?void 0:so.views)||{}).find(vo=>vo.id===_o.id);lo=bo==null?void 0:bo.name}else lo=(ho=go.table)==null?void 0:ho.name}if(!ao)return;const uo=Object.keys(ao).sort();let fo=eo._id;co&&(fo+=`-${co}`);const po=makePropSafe(fo);uo.forEach(_o=>{var ko;const go=ao[_o],bo=_o.split(".").map(makePropSafe).join("."),vo=`${po}.${bo}`;let yo=eo._instanceName;lo&&(yo+=`.${lo}`),yo+=`.${go.name||_o}`;const wo=getComponentBindingCategory(eo,io,no);oo.push({type:"context",runtimeBinding:vo,readableBinding:`${yo}`,fieldSchema:go,providerId:fo,tableId:so==null?void 0:so._id,component:eo._component,category:wo.category,icon:wo.icon,display:{name:`${go.name||_o}`,type:((ko=go.display)==null?void 0:ko.type)||go.type}})})}),oo},isContextCompatibleWithComponent=(to,ue)=>{if(!ue)return!1;const{_component:eo,actionType:no}=ue,{type:ro}=to;return!(eo.endsWith("formblock")&&(no==="Create"&&ro==="schema"||no==="View"&&ro==="form"))},getComponentBindingCategory=(to,ue,eo)=>{let no=eo.icon,ro=to._instanceName;return to._component.endsWith("formblock")&&(ue.type==="form"?(ro=`${to._instanceName} - Fields`,no="Form"):ue.type==="schema"&&(ro=`${to._instanceName} - Row`,no="Data")),{icon:no,category:ro}},getUserBindings=()=>{let to=[];const{schema:ue}=getSchemaForDatasourcePlus(TableNames.USERS);ue.globalId={type:FieldType.STRING};const eo=Object.keys(ue).sort(),no=makePropSafe("user");return to=eo.reduce((ro,oo)=>{const io=ue[oo];return ro.push({type:"context",runtimeBinding:`${no}.${makePropSafe(oo)}`,readableBinding:`Current User.${oo}`,fieldSchema:io,providerId:"user",category:"Current User",icon:"User",display:{name:oo}}),ro},[]),to},getDeviceBindings=()=>{var ue;let to=[];if((ue=get_store_value(appStore).clientFeatures)!=null&&ue.deviceAwareness){const eo=makePropSafe("device");to=[{type:"context",runtimeBinding:`${eo}.${makePropSafe("mobile")}`,readableBinding:"Device.Mobile",category:"Device",icon:"DevicePhone",display:{type:"boolean",name:"mobile"}},{type:"context",runtimeBinding:`${eo}.${makePropSafe("tablet")}`,readableBinding:"Device.Tablet",category:"Device",icon:"DevicePhone",display:{type:"boolean",name:"tablet"}},{type:"context",runtimeBinding:`${eo}.${makePropSafe("theme")}`,readableBinding:"App.Theme",category:"Device",icon:"DevicePhone",display:{type:"string",name:"App Theme"}}]}return to},getSettingBindings=()=>{let to=[];const ue=makePropSafe("settings");return to=[{type:"context",runtimeBinding:`${ue}.${makePropSafe("url")}`,readableBinding:"Settings.url",category:"Settings",icon:"Settings",display:{type:"string",name:"url"}},{type:"context",runtimeBinding:`${ue}.${makePropSafe("logo")}`,readableBinding:"Settings.logo",category:"Settings",icon:"Settings",display:{type:"string",name:"logo"}},{type:"context",runtimeBinding:`${ue}.${makePropSafe("company")}`,readableBinding:"Settings.company",category:"Settings",icon:"Settings",display:{type:"string",name:"company"}}],to},getSelectedRowsBindings=to=>{var eo;let ue=[];if((eo=get_store_value(appStore).clientFeatures)!=null&&eo.rowSelection){let no=findAllMatchingComponents(to==null?void 0:to.props,io=>io._component.endsWith("table"));const ro=makePropSafe("rowSelection");ue=ue.concat(no.map(io=>({type:"context",runtimeBinding:`${ro}.${makePropSafe(io._id)}.${makePropSafe("selectedRows")}`,readableBinding:`${io._instanceName}.Selected Row IDs (deprecated)`,category:"Selected Row IDs (deprecated)",icon:"ViewRow",display:{name:io._instanceName}})));let oo=findAllMatchingComponents(to==null?void 0:to.props,io=>io._component.endsWith("tableblock"));ue=ue.concat(oo.map(io=>({type:"context",runtimeBinding:`${ro}.${makePropSafe(io._id+"-table")}.${makePropSafe("selectedRows")}`,readableBinding:`${io._instanceName}.Selected Row IDs (deprecated)`,category:"Selected Row IDs (deprecated)",icon:"ViewRow",display:{name:io._instanceName}})))}return ue},makeStateBinding=to=>({type:"context",runtimeBinding:`${makePropSafe("state")}.${makePropSafe(to)}`,readableBinding:`State.${to}`,category:"State",icon:"AutomatedSegment",display:{name:to}}),getStateBindings=()=>{var ue;let to=[];return(ue=get_store_value(appStore).clientFeatures)!=null&&ue.state&&(to=getAllStateVariables().map(makeStateBinding)),to},getUrlBindings=to=>{var ao;const eo=(((ao=to==null?void 0:to.routing)==null?void 0:ao.route)??"").split("/");let no=[];eo.forEach(so=>{so.startsWith(":")&&so.length>1&&no.push(so.replace(/:/g,"").replace(/\?/g,""))});const ro=makePropSafe("url"),oo=no.map(so=>({type:"context",runtimeBinding:`${ro}.${makePropSafe(so)}`,readableBinding:`URL.${so}`,category:"URL",icon:"RailTop",display:{type:"string",name:so}})),io={type:"context",runtimeBinding:makePropSafe("query"),readableBinding:"Query params",category:"URL",icon:"RailTop",display:{type:"object",name:"Query params"}};return oo.concat([io])},getRoleBindings=()=>(get_store_value(roles)||[]).map(to=>({type:"context",runtimeBinding:`'${to._id}'`,readableBinding:`Role.${to.uiMetadata.displayName}`,category:"Role",icon:"UserGroup",display:{type:"string",name:to.uiMetadata.displayName}})),getEventContextBindings=({settingKey:to,componentInstance:ue,componentId:eo,componentDefinition:no,asset:ro})=>{var co;let oo=[];ro=ro??get_store_value(selectedScreen);const io=ue??findComponent(ro.props,eo);if(!io)return oo;const ao=no??componentStore.getDefinition(io==null?void 0:io._component),lo=componentStore.getComponentSettings(io==null?void 0:io._component).find(uo=>uo.key===to);return(co=lo==null?void 0:lo.context)!=null&&co.length&&lo.context.forEach(uo=>{oo.push({readableBinding:uo.label,runtimeBinding:`${makePropSafe("eventContext")}.${makePropSafe(uo.key)}`,category:io._instanceName,icon:ao.icon,display:{name:uo.label}})}),oo},getActionBindings=(to,ue)=>{let eo=[];const no=to==null?void 0:to.findIndex(oo=>oo.id===ue);return no==null||no===-1||to.slice(0,no).forEach((oo,io)=>{const ao=ActionDefinitions.actions.find(so=>so.name===oo["##eventHandlerType"]);ao.context&&ao.context.forEach(so=>{eo.push({readableBinding:`Action ${io+1}.${so.label}`,runtimeBinding:`actions.${io}.${so.value}`,category:"Actions",icon:"JourneyAction",display:{name:so.label}})})}),eo},getEmbedBindings=()=>{let to=[];return to=[{type:"context",runtimeBinding:`${makePropSafe("embed")}`,readableBinding:"ParentWindow",category:"Embed",icon:"DistributeVertically"}],to},getSchemaForDatasourcePlus=(to,ue)=>{const no=(to==null?void 0:to.startsWith("view_"))?{type:"viewV2",id:to,tableId:to.split("_").slice(1,3).join("_")}:{type:"table",tableId:to};return getSchemaForDatasource(null,no,ue)},getSchemaForDatasource=(to,ue,eo)=>{var oo,io;eo=eo||{};let no,ro;if(ue){const{type:ao}=ue,so=get_store_value(tables).list;if(ao==="provider"){const ho=findComponent(to==null?void 0:to.props,ue.providerId),_o=getDatasourceForProvider(to,ho);return getSchemaForDatasource(to,_o,eo)}else if(ao==="query")ro=get_store_value(queries).list.find(_o=>_o._id===ue._id);else if(ao==="field"){ro={name:ue.fieldName};const{fieldType:ho}=ue;ho==="attachment"?no={url:{type:"string"},name:{type:"string"}}:ho==="array"&&(no={value:{type:"string"}})}else if(ao==="jsonarray"){ro=so.find(_o=>_o._id===ue.tableId);let ho=ro==null?void 0:ro.schema;no=getJSONArrayDatasourceSchema(ho,ue)}else if(ao==="queryarray"){ro=get_store_value(queries).list.find(bo=>bo._id===ue.tableId);let _o=ro==null?void 0:ro.schema,go=ro==null?void 0:ro.nestedSchemaFields;no=generateQueryArraySchemas(_o,go),no=getJSONArrayDatasourceSchema(no,ue)}else ro=so.find(ho=>ho._id===ue.tableId);if(ro&&!no)if(ao==="view")no=fp$1.cloneDeep((io=(oo=ro.views)==null?void 0:oo[ue.name])==null?void 0:io.schema);else if(ao==="viewV2"){const ho=Object.values(ro.views||{}).find(_o=>_o.id===ue.id);no=fp$1.cloneDeep(ho==null?void 0:ho.schema),Object.keys(no||{}).forEach(_o=>{no[_o].visible||delete no[_o]})}else ao==="query"&&(eo.formSchema||eo.searchableSchema)?(no={},(ro.parameters||[]).forEach(_o=>{_o!=null&&_o.name&&(no[_o.name]={..._o,type:"string"})})):no=fp$1.cloneDeep(ro.schema);if(no){let ho={};Object.keys(no).forEach(_o=>{const go=no[_o];if((go==null?void 0:go.type)==="json"){const bo=convertJSONSchemaToTableSchema(go,{squashObjects:!0});Object.keys(bo).forEach(vo=>{ho[`${_o}.${vo}`]={type:bo[vo].type,nestedJSON:!0}})}}),no={...no,...ho}}const lo=ro&&(ro==null?void 0:ro.sourceType)===DB_TYPE_INTERNAL,co=["table","link","viewV2"].includes(ue.type);let uo=co,fo=co&&lo;eo.formSchema?(uo=!1,fo=!1):eo.searchableSchema&&(uo=co&&lo),no&&(uo&&(no._id={type:"string"}),fo&&(no._rev={type:"string"}));let po={};Object.entries(no||{}).forEach(([ho,_o])=>{const go=Object.values(FIELDS).find(bo=>bo.type===_o.type&&bo.subtype===_o.subtype);typeof _o=="string"?po[ho]={type:_o,name:ho,display:{type:_o}}:po[ho]={..._o,name:ho,display:{type:(go==null?void 0:go.name)||_o.type}}}),no=po}return{schema:no,table:ro}},buildFormSchema=(to,ue)=>{var oo;let eo={};if(!to)return eo;if(to._component.endsWith("formblock")){let io={};const ao=getDatasourceForProvider(ue,to),so=getSchemaForDatasource(to,ao);if(!(so!=null&&so.schema))return io;if(!to.fields)Object.values(so.schema).filter(({autocolumn:lo,name:co})=>!lo&&!["_rev","_id"].includes(co)).forEach(({name:lo})=>{io[lo]={type:so==null?void 0:so.schema[lo].type}});else{const lo=convertOldFieldFormat(to.fields||[]);lo==null||lo.forEach(({field:co,active:uo})=>{uo&&so!=null&&so.schema[co]&&(io[co]={type:so==null?void 0:so.schema[co].type})})}return io}const ro=componentStore.getComponentSettings(to._component).find(io=>io.key==="field"&&io.type.startsWith("field/"));if(ro){const io=ro.type.split("field/")[1],ao=to.field||to._instanceName;io&&ao&&(eo[ao]={type:io})}return(oo=to._children)==null||oo.forEach(io=>{const ao=buildFormSchema(io,ue);eo={...eo,...ao}}),eo},getAllStateVariables=()=>{let to=[];getAllAssets().forEach(eo=>{findAllMatchingComponents(eo.props,no=>{const ro=componentStore.getComponentSettings(no._component),oo=["buttonConfiguration","fieldConfiguration","stepConfiguration"],io=(ao,so)=>{ao!=null&&ao.length&&(ao.filter(lo=>lo.type==="event").forEach(lo=>{to.push(so[lo.key])}),ao.filter(lo=>oo.includes(lo.type)).forEach(lo=>{const co=so[lo.key];Array.isArray(co)&&co.length&&co.forEach(uo=>{let fo=uo==null?void 0:uo._component;lo.type==="stepConfiguration"&&!fo&&(fo="@budibase/standard-components/multistepformblockstep");const po=componentStore.getComponentSettings(fo);io(po,uo)})}))};io(ro,no)})}),get_store_value(screenStore).screens.forEach(eo=>{eo.onLoad&&to.push(eo.onLoad)});let ue=new Set;return to.forEach(eo=>{Array.isArray(eo)&&eo.forEach(no=>{var ro,oo,io;no["##eventHandlerType"]==="Update State"&&((ro=no.parameters)==null?void 0:ro.type)==="set"&&((oo=no.parameters)!=null&&oo.key)&&((io=no.parameters)!=null&&io.value)&&ue.add(no.parameters.key)})}),Array.from(ue)},getAllAssets=()=>{let to=[];return to=to.concat(get_store_value(layoutStore).layouts||[]),to=to.concat(get_store_value(screenStore).screens||[]),to},shouldReplaceBinding=(to,ue,eo,no)=>{if(!(to!=null&&to.includes(ue)))return!1;const ro=no.runtimeBinding.includes(no.readableBinding),oo=eo==="readableBinding",ao=Object.keys(getJsHelperList()).filter(uo=>uo.includes(ue)&&to.includes(uo));if(ao.length>0){const uo=to.indexOf(ue),fo=uo+ue.length;for(let po of ao){const ho=to.indexOf(po),_o=ho+po.length;if(uo>=ho&&fo<=_o)return!1}}if(oo&&!ro)return to.indexOf(no.readableBinding)===-1;if(oo)return!0;const so=to.replace(/\s+/g,""),lo=ue.replace(/\s+/g,"");return![`[${lo}]`,`"${lo}"`,`'${lo}'`].find(uo=>so==null?void 0:so.includes(uo))},replaceBetween=(to,ue,eo,no)=>to.substring(0,ue)+no+to.substring(eo),bindingReplacement=(to,ue,eo)=>{const no=isJSBinding(ue);no&&(ue=decodeJSBinding(ue));const ro=no?CAPTURE_VAR_INSIDE_JS:CAPTURE_VAR_INSIDE_TEMPLATE,oo=eo==="runtimeBinding"?"readableBinding":"runtimeBinding";if(typeof ue!="string")return ue;const io=to.map(lo=>lo[oo]).sort((lo,co)=>co.length-lo.length),ao=ue.match(ro)||[];let so=ue;for(let lo of ao){let co=lo,uo=co;for(let fo of io){const po=to.find(ho=>ho[oo]===fo);if(no||shouldReplaceBinding(co,fo,eo,po)){let ho;do if(ho=uo.indexOf(fo),ho!==-1){let _o=ho+fo.length,go=Array(po[eo].length+1).join("*");uo=replaceBetween(uo,ho,_o,go),co=replaceBetween(co,ho,_o,po[eo])}while(ho!==-1)}}so=so.replace(lo,co)}return no&&(so=encodeJSBinding(so)),so},extractLiteralHandlebarsID=to=>{var ue;return!to||typeof to!="string"?null:(ue=to.match(/{{\s*literal\s*\[+([^\]]+)].*}}/))==null?void 0:ue[1]},readableToRuntimeBinding=(to,ue)=>bindingReplacement(to,ue,"runtimeBinding"),runtimeToReadableBinding=(to,ue)=>bindingReplacement(to,ue,"readableBinding"),updateReferencesInObject=({obj:to,modifiedIndex:ue,action:eo,label:no,originalIndex:ro})=>{const oo=new RegExp(`{{\\s*${no}\\.(\\d+)\\.`,"g"),io=(ao,so,lo)=>ao.replace(`{{ ${no}.${so}.`,`{{ ${no}.${lo}.`);for(const ao in to)if(typeof to[ao]=="string"){let so;for(;(so=oo.exec(to[ao]))!==null;){const lo=parseInt(so[1]);eo===UpdateReferenceAction.ADD&&lo>=ue?to[ao]=io(to[ao],lo,lo+1):eo===UpdateReferenceAction.DELETE&&lo>ue?to[ao]=io(to[ao],lo,lo-1):eo===UpdateReferenceAction.MOVE&&(lo===ro?to[ao]=io(to[ao],lo,ue):ue<=lo&&ue<ro?to[ao]=io(to[ao],lo,lo+1):ue>=lo&&ue>ro&&(to[ao]=io(to[ao],lo,lo-1)))}}else typeof to[ao]=="object"&&to[ao]!==null&&updateReferencesInObject({obj:to[ao],modifiedIndex:ue,action:eo,label:no,originalIndex:ro})},migrateReferencesInObject=({obj:to,label:ue="steps",steps:eo,originalIndex:no})=>{var io;const ro=new RegExp(`{{\\s*${ue}\\.(\\d+)\\.`,"g"),oo=(ao,so,lo)=>ao.replace(`{{ ${ue}.${so}.`,`{{ ${ue}.${lo}.`);for(const ao in to)if(typeof to[ao]=="string"){let so;for(;(so=ro.exec(to[ao]))!==null;){const lo=parseInt(so[1]);to[ao]=oo(to[ao],lo,(io=eo[lo])==null?void 0:io.id)}}else typeof to[ao]=="object"&&to[ao]!==null&&migrateReferencesInObject({obj:to[ao],steps:eo,originalIndex:no})},getComponentFieldOptions=(to,ue,eo,no=!0)=>{const ro=findClosestMatchingComponent(to,ue,so=>so._component==="@budibase/standard-components/form"),oo=getDatasourceForProvider(to,ro),io=getSchemaForDatasource(to,oo,{formSchema:!0}).schema;let ao=[eo];return no&&(eo==="field/options"||eo==="field/longform")&&(ao=[eo,"field/string"]),ao=ao.map(so=>so.slice(so.indexOf("/")+1)),Object.entries(io||{}).filter(so=>ao.includes(so[1].type)).map(so=>so[0])};/*!
|
|
498
|
+
`)).length,ro=0;ro<no;ro++){var io=to.charCodeAt(ro),ao=null;io<128?eo++:ao=io>127&&io<2048?String.fromCharCode(io>>6|192,63&io|128):String.fromCharCode(io>>12|224,io>>6&63|128,63&io|128),I(ao)||(eo>ue&&(oo+=to.substring(ue,eo)),oo+=ao,ue=eo=ro+1)}return eo>ue&&(oo+=to.substring(ue,to.length)),oo},oe=function(){function to(ue){return ue&&(ue.preventDefault=to.preventDefault,ue.stopPropagation=to.stopPropagation),ue}return to.preventDefault=function(){this.returnValue=!1},to.stopPropagation=function(){this.cancelBubble=!0},function(ue,eo,no,ro,oo){if(ue)if(ue.addEventListener&&!ro)ue.addEventListener(eo,no,!!oo);else{var io="on"+eo,ao=ue[io];ue[io]=function(so,lo,co){return function(uo){if(uo=uo||to(T==null?void 0:T.event)){var fo,po=!0;y(co)&&(fo=co(uo));var ho=lo.call(so,uo);return fo!==!1&&ho!==!1||(po=!1),po}}}(ue,no,ao)}else G.error("No valid element provided to register_event")}}();function ae(to,ue){for(var eo=0;eo<to.length;eo++)if(ue(to[eo]))return to[eo]}(function(to){to.GZipJS="gzip-js",to.Base64="base64"})(re||(re={}));var le="$people_distinct_id",ce="__alias",de="__timers",he="$autocapture_disabled_server_side",fe="$heatmaps_enabled_server_side",ve="$exception_capture_enabled_server_side",pe="$exception_capture_endpoint_suffix",ge="$web_vitals_enabled_server_side",_e="$session_recording_enabled_server_side",me="$console_log_recording_enabled_server_side",ye="$session_recording_network_payload_capture",be="$session_recording_canvas_recording",ke="$replay_sample_rate",we="$replay_minimum_duration",Se="$sesid",Ee="$session_is_sampled",Ie="$enabled_feature_flags",Re="$early_access_features",Fe="$stored_person_properties",xe="$stored_group_properties",Pe="$surveys",Te="$surveys_activated",Ce="$flag_call_reported",$e="$user_state",Oe="$client_session_props",Me="$capture_rate_limit",Ae="$initial_campaign_params",Le="$initial_referrer_info",De="$initial_person_info",qe="$epp",Ne="__POSTHOG_TOOLBAR__",Be=[le,ce,"__cmpns",de,_e,fe,Se,Ie,$e,Re,xe,Fe,Pe,Ce,Oe,Me,Ae,Le,qe],He="$active_feature_flags",Ue="$override_feature_flags",je="$feature_flag_payloads",Ge=function(to){var ue,eo={},no=h(X(to||{}));try{for(no.s();!(ue=no.n()).done;){var ro=u(ue.value,2),oo=ro[0],io=ro[1];io&&(eo[oo]=io)}}catch(ao){no.e(ao)}finally{no.f()}return eo},We=function(){function to(ue){i$1(this,to),this.instance=ue,this._override_warning=!1,this.featureFlagEventHandlers=[],this.reloadFeatureFlagsQueued=!1,this.reloadFeatureFlagsInAction=!1}return s(to,[{key:"getFlags",value:function(){return Object.keys(this.getFlagVariants())}},{key:"getFlagVariants",value:function(){var ue=this.instance.get_property(Ie),eo=this.instance.get_property(Ue);if(!eo)return ue||{};for(var no=J({},ue),ro=Object.keys(eo),oo=0;oo<ro.length;oo++)no[ro[oo]]=eo[ro[oo]];return this._override_warning||(G.warn(" Overriding feature flags!",{enabledFlags:ue,overriddenFlags:eo,finalFlags:no}),this._override_warning=!0),no}},{key:"getFlagPayloads",value:function(){return this.instance.get_property(je)||{}}},{key:"reloadFeatureFlags",value:function(){this.reloadFeatureFlagsQueued||(this.reloadFeatureFlagsQueued=!0,this._startReloadTimer())}},{key:"setAnonymousDistinctId",value:function(ue){this.$anon_distinct_id=ue}},{key:"setReloadingPaused",value:function(ue){this.reloadFeatureFlagsInAction=ue}},{key:"resetRequestQueue",value:function(){this.reloadFeatureFlagsQueued=!1}},{key:"_startReloadTimer",value:function(){var ue=this;this.reloadFeatureFlagsQueued&&!this.reloadFeatureFlagsInAction&&setTimeout(function(){!ue.reloadFeatureFlagsInAction&&ue.reloadFeatureFlagsQueued&&(ue.reloadFeatureFlagsQueued=!1,ue._reloadFeatureFlagsRequest())},5)}},{key:"_reloadFeatureFlagsRequest",value:function(){var ue=this;if(!this.instance.config.advanced_disable_feature_flags){this.setReloadingPaused(!0);var eo=this.instance.config.token,no=this.instance.get_property(Fe),ro=this.instance.get_property(xe),oo={token:eo,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:no,group_properties:ro,disable_flags:this.instance.config.advanced_disable_feature_flags||void 0};this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:oo,compression:this.instance.config.disable_compression?void 0:re.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:function(io){var ao;ue.setReloadingPaused(!1);var so=!0;io.statusCode===200&&(ue.$anon_distinct_id=void 0,so=!1),ue.receivedFeatureFlags((ao=io.json)!==null&&ao!==void 0?ao:{},so),ue._startReloadTimer()}})}}},{key:"getFeatureFlag",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0){var no,ro=this.getFlagVariants()[ue],oo="".concat(ro),io=this.instance.get_property(Ce)||{};return(eo.send_event||!("send_event"in eo))&&(!(ue in io)||!io[ue].includes(oo))&&(m(io[ue])?io[ue].push(oo):io[ue]=[oo],(no=this.instance.persistence)===null||no===void 0||no.register(o({},Ce,io)),this.instance.capture("$feature_flag_called",{$feature_flag:ue,$feature_flag_response:ro})),ro}G.warn('getFeatureFlag for key "'+ue+`" failed. Feature flags didn't load in time.`)}},{key:"getFeatureFlagPayload",value:function(ue){return this.getFlagPayloads()[ue]}},{key:"isFeatureEnabled",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(ue,eo);G.warn('isFeatureEnabled for key "'+ue+`" failed. Feature flags didn't load in time.`)}},{key:"addFeatureFlagsHandler",value:function(ue){this.featureFlagEventHandlers.push(ue)}},{key:"removeFeatureFlagsHandler",value:function(ue){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(function(eo){return eo!==ue})}},{key:"receivedFeatureFlags",value:function(ue,eo){if(this.instance.persistence){this.instance.decideEndpointWasHit=!0;var no=this.getFlagVariants(),ro=this.getFlagPayloads();(function(oo,io){var ao,so=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},lo=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},co=oo.featureFlags,uo=oo.featureFlagPayloads;if(co)if(m(co)){var fo,po={};if(co)for(var ho=0;ho<co.length;ho++)po[co[ho]]=!0;io&&io.register((o(fo={},He,co),o(fo,Ie,po),fo))}else{var _o=co,go=uo;oo.errorsWhileComputingFlags&&(_o=t$1(t$1({},so),_o),go=t$1(t$1({},lo),go)),io&&io.register((o(ao={},He,Object.keys(Ge(_o))),o(ao,Ie,_o||{}),o(ao,je,go||{}),ao))}})(ue,this.instance.persistence,no,ro),this._fireFeatureFlagsCallbacks(eo)}}},{key:"override",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.instance.__loaded||!this.instance.persistence)return G.uninitializedWarning("posthog.feature_flags.override");if(this._override_warning=eo,ue===!1)this.instance.persistence.unregister(Ue);else if(m(ue)){for(var no={},ro=0;ro<ue.length;ro++)no[ue[ro]]=!0;this.instance.persistence.register(o({},Ue,no))}else this.instance.persistence.register(o({},Ue,ue))}},{key:"onFeatureFlags",value:function(ue){var eo=this;if(this.addFeatureFlagsHandler(ue),this.instance.decideEndpointWasHit){var no=this._prepareFeatureFlagsForCallbacks(),ro=no.flags,oo=no.flagVariants;ue(ro,oo)}return function(){return eo.removeFeatureFlagsHandler(ue)}}},{key:"updateEarlyAccessFeatureEnrollment",value:function(ue,eo){var no,ro,oo=o({},"$feature_enrollment/".concat(ue),eo);this.instance.capture("$feature_enrollment_update",{$feature_flag:ue,$feature_enrollment:eo,$set:oo}),this.setPersonPropertiesForFlags(oo,!1);var io=t$1(t$1({},this.getFlagVariants()),{},o({},ue,eo));(no=this.instance.persistence)===null||no===void 0||no.register((o(ro={},He,Object.keys(Ge(io))),o(ro,Ie,io),ro)),this._fireFeatureFlagsCallbacks()}},{key:"getEarlyAccessFeatures",value:function(ue){var eo=this,no=arguments.length>1&&arguments[1]!==void 0&&arguments[1],ro=this.instance.get_property(Re);if(ro&&!no)return ue(ro);this.instance._send_request({transport:"XHR",url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token)),method:"GET",callback:function(oo){var io;if(oo.json){var ao=oo.json.earlyAccessFeatures;return(io=eo.instance.persistence)===null||io===void 0||io.register(o({},Re,ao)),ue(ao)}}})}},{key:"_prepareFeatureFlagsForCallbacks",value:function(){var ue=this.getFlags(),eo=this.getFlagVariants();return{flags:ue.filter(function(no){return eo[no]}),flagVariants:Object.keys(eo).filter(function(no){return eo[no]}).reduce(function(no,ro){return no[ro]=eo[ro],no},{})}}},{key:"_fireFeatureFlagsCallbacks",value:function(ue){var eo=this._prepareFeatureFlagsForCallbacks(),no=eo.flags,ro=eo.flagVariants;this.featureFlagEventHandlers.forEach(function(oo){return oo(no,ro,{errorsLoading:ue})})}},{key:"setPersonPropertiesForFlags",value:function(ue){var eo=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],no=this.instance.get_property(Fe)||{};this.instance.register(o({},Fe,t$1(t$1({},no),ue))),eo&&this.instance.reloadFeatureFlags()}},{key:"resetPersonPropertiesForFlags",value:function(){this.instance.unregister(Fe)}},{key:"setGroupPropertiesForFlags",value:function(ue){var eo=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],no=this.instance.get_property(xe)||{};Object.keys(no).length!==0&&Object.keys(no).forEach(function(ro){no[ro]=t$1(t$1({},no[ro]),ue[ro]),delete ue[ro]}),this.instance.register(o({},xe,t$1(t$1({},no),ue))),eo&&this.instance.reloadFeatureFlags()}},{key:"resetGroupPropertiesForFlags",value:function(ue){if(ue){var eo=this.instance.get_property(xe)||{};this.instance.register(o({},xe,t$1(t$1({},eo),{},o({},ue,{}))))}else this.instance.unregister(xe)}}]),to}();Math.trunc||(Math.trunc=function(to){return to<0?Math.ceil(to):Math.floor(to)}),Number.isInteger||(Number.isInteger=function(to){return F(to)&&isFinite(to)&&Math.floor(to)===to});var Ve="0123456789abcdef",ze=function(){function to(ue){if(i$1(this,to),this.bytes=ue,ue.length!==16)throw new TypeError("not 128-bit length")}return s(to,[{key:"toString",value:function(){for(var ue="",eo=0;eo<this.bytes.length;eo++)ue=ue+Ve.charAt(this.bytes[eo]>>>4)+Ve.charAt(15&this.bytes[eo]),eo!==3&&eo!==5&&eo!==7&&eo!==9||(ue+="-");if(ue.length!==36)throw new Error("Invalid UUIDv7 was generated");return ue}},{key:"clone",value:function(){return new to(this.bytes.slice(0))}},{key:"equals",value:function(ue){return this.compareTo(ue)===0}},{key:"compareTo",value:function(ue){for(var eo=0;eo<16;eo++){var no=this.bytes[eo]-ue.bytes[eo];if(no!==0)return Math.sign(no)}return 0}}],[{key:"fromFieldsV7",value:function(ue,eo,no,ro){if(!Number.isInteger(ue)||!Number.isInteger(eo)||!Number.isInteger(no)||!Number.isInteger(ro)||ue<0||eo<0||no<0||ro<0||ue>0xffffffffffff||eo>4095||no>1073741823||ro>4294967295)throw new RangeError("invalid field value");var oo=new Uint8Array(16);return oo[0]=ue/Math.pow(2,40),oo[1]=ue/Math.pow(2,32),oo[2]=ue/Math.pow(2,24),oo[3]=ue/Math.pow(2,16),oo[4]=ue/Math.pow(2,8),oo[5]=ue,oo[6]=112|eo>>>8,oo[7]=eo,oo[8]=128|no>>>24,oo[9]=no>>>16,oo[10]=no>>>8,oo[11]=no,oo[12]=ro>>>24,oo[13]=ro>>>16,oo[14]=ro>>>8,oo[15]=ro,new to(oo)}}]),to}(),Qe=function(){function to(){i$1(this,to),o(this,"timestamp",0),o(this,"counter",0),o(this,"random",new Xe)}return s(to,[{key:"generate",value:function(){var ue=this.generateOrAbort();if(w$1(ue)){this.timestamp=0;var eo=this.generateOrAbort();if(w$1(eo))throw new Error("Could not generate UUID after timestamp reset");return eo}return ue}},{key:"generateOrAbort",value:function(){var ue=Date.now();if(ue>this.timestamp)this.timestamp=ue,this.resetCounter();else{if(!(ue+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return ze.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}},{key:"resetCounter",value:function(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}]),to}(),Je=function(to){if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var ue=0;ue<to.length;ue++)to[ue]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return to};T&&!w$1(T.crypto)&&crypto.getRandomValues&&(Je=function(to){return crypto.getRandomValues(to)});var Ye,Xe=function(){function to(){i$1(this,to),o(this,"buffer",new Uint32Array(8)),o(this,"cursor",1/0)}return s(to,[{key:"nextUint32",value:function(){return this.cursor>=this.buffer.length&&(Je(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}]),to}(),Ke=function(){return Ze().toString()},Ze=function(){return(Ye||(Ye=new Qe)).generate()},et="Thu, 01 Jan 1970 00:00:00 GMT",tt="",nt=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function it(to,ue){if(ue){var eo=function(ro){var oo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:L;if(tt)return tt;if(!oo||["localhost","127.0.0.1"].includes(ro))return"";for(var io=ro.split("."),ao=Math.min(io.length,8),so="dmn_chk_"+Ke(),lo=new RegExp("(^|;)\\s*"+so+"=1");!tt&&ao--;){var co=io.slice(ao).join("."),uo=so+"=1;domain=."+co;oo.cookie=uo,lo.test(oo.cookie)&&(oo.cookie=uo+";expires="+et,tt=co)}return tt}(to);if(!eo){var no=function(ro){var oo=ro.match(nt);return oo?oo[0]:""}(to);no!==eo&&G.info("Warning: cookie subdomain discovery mismatch",no,eo),eo=no}return eo?"; domain=."+eo:""}return""}var rt,st={is_supported:function(){return!!L},error:function(to){G.error("cookieStore error: "+to)},get:function(to){if(L){try{for(var ue=to+"=",eo=L.cookie.split(";").filter(function(oo){return oo.length}),no=0;no<eo.length;no++){for(var ro=eo[no];ro.charAt(0)==" ";)ro=ro.substring(1,ro.length);if(ro.indexOf(ue)===0)return decodeURIComponent(ro.substring(ue.length,ro.length))}}catch{}return null}},parse:function(to){var ue;try{ue=JSON.parse(st.get(to))||{}}catch{}return ue},set:function(to,ue,eo,no,ro){if(L)try{var oo="",io="",ao=it(L.location.hostname,no);if(eo){var so=new Date;so.setTime(so.getTime()+24*eo*60*60*1e3),oo="; expires="+so.toUTCString()}ro&&(io="; secure");var lo=to+"="+encodeURIComponent(JSON.stringify(ue))+oo+"; SameSite=Lax; path=/"+ao+io;return lo.length>3686.4&&G.warn("cookieStore warning: large cookie, len="+lo.length),L.cookie=lo,lo}catch{return}},remove:function(to,ue){try{st.set(to,"",-1,ue)}catch{return}}},ot=null,at={is_supported:function(){if(!I(ot))return ot;var to=!0;if(w$1(T))to=!1;else try{var ue="__mplssupport__";at.set(ue,"xyz"),at.get(ue)!=='"xyz"'&&(to=!1),at.remove(ue)}catch{to=!1}return to||G.error("localStorage unsupported; falling back to cookie store"),ot=to,to},error:function(to){G.error("localStorage error: "+to)},get:function(to){try{return T==null?void 0:T.localStorage.getItem(to)}catch(ue){at.error(ue)}return null},parse:function(to){try{return JSON.parse(at.get(to))||{}}catch{}return null},set:function(to,ue){try{T==null||T.localStorage.setItem(to,JSON.stringify(ue))}catch(eo){at.error(eo)}},remove:function(to){try{T==null||T.localStorage.removeItem(to)}catch(ue){at.error(ue)}}},ut=["distinct_id",Se,Ee,qe],lt=t$1(t$1({},at),{},{parse:function(to){try{var ue={};try{ue=st.parse(to)||{}}catch{}var eo=J(ue,JSON.parse(at.get(to)||"{}"));return at.set(to,eo),eo}catch{}return null},set:function(to,ue,eo,no,ro,oo){try{at.set(to,ue,void 0,void 0,oo);var io={};ut.forEach(function(ao){ue[ao]&&(io[ao]=ue[ao])}),Object.keys(io).length&&st.set(to,io,eo,no,ro,oo)}catch(ao){at.error(ao)}},remove:function(to,ue){try{T==null||T.localStorage.removeItem(to),st.remove(to,ue)}catch(eo){at.error(eo)}}}),ct={},dt={is_supported:function(){return!0},error:function(to){G.error("memoryStorage error: "+to)},get:function(to){return ct[to]||null},parse:function(to){return ct[to]||null},set:function(to,ue){ct[to]=ue},remove:function(to){delete ct[to]}},ht=null,ft={is_supported:function(){if(!I(ht))return ht;if(ht=!0,w$1(T))ht=!1;else try{var to="__support__";ft.set(to,"xyz"),ft.get(to)!=='"xyz"'&&(ht=!1),ft.remove(to)}catch{ht=!1}return ht},error:function(to){G.error("sessionStorage error: ",to)},get:function(to){try{return T==null?void 0:T.sessionStorage.getItem(to)}catch(ue){ft.error(ue)}return null},parse:function(to){try{return JSON.parse(ft.get(to))||null}catch{}return null},set:function(to,ue){try{T==null||T.sessionStorage.setItem(to,JSON.stringify(ue))}catch(eo){ft.error(eo)}},remove:function(to){try{T==null||T.sessionStorage.removeItem(to)}catch(ue){ft.error(ue)}}},vt=["localhost","127.0.0.1"],pt=function(to){var ue=L==null?void 0:L.createElement("a");return w$1(ue)?null:(ue.href=to,ue)},gt=function(to,ue){return!!function(eo){try{new RegExp(eo)}catch{return!1}return!0}(ue)&&new RegExp(ue).test(to)},_t=function(to){var ue,eo,no=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",ro=[];return Q(to,function(oo,io){w$1(oo)||w$1(io)||io==="undefined"||(ue=encodeURIComponent(function(ao){return ao instanceof File}(oo)?oo.name:oo.toString()),eo=encodeURIComponent(io),ro[ro.length]=eo+"="+ue)}),ro.join(no)},mt=function(to,ue){for(var eo,no=((to.split("#")[0]||"").split("?")[1]||"").split("&"),ro=0;ro<no.length;ro++){var oo=no[ro].split("=");if(oo[0]===ue){eo=oo;break}}if(!m(eo)||eo.length<2)return"";var io=eo[1];try{io=decodeURIComponent(io)}catch{G.error("Skipping decoding for malformed query param: "+io)}return io.replace(/\+/g," ")},yt=function(to,ue){var eo=to.match(new RegExp(ue+"=([^&]*)"));return eo?eo[1]:null},bt="Mobile",kt="iOS",wt="Android",St="Tablet",Et=wt+" "+St,It="iPad",Rt="Apple",Ft=Rt+" Watch",xt="Safari",Pt="BlackBerry",Tt="Samsung",Ct=Tt+"Browser",$t=Tt+" Internet",Ot="Chrome",Mt=Ot+" OS",At=Ot+" "+kt,Lt="Internet Explorer",Dt=Lt+" "+bt,qt="Opera",Nt=qt+" Mini",Bt="Edge",Ht="Microsoft "+Bt,Ut="Firefox",jt=Ut+" "+kt,Gt="Nintendo",Wt="PlayStation",Vt="Xbox",zt=wt+" "+bt,Qt=bt+" "+xt,Jt="Windows",Yt=Jt+" Phone",Xt="Nokia",Kt="Ouya",Zt="Generic",en=Zt+" "+bt.toLowerCase(),tn=Zt+" "+St.toLowerCase(),nn="Konqueror",rn="(\\d+(\\.\\d+)?)",sn=new RegExp("Version/"+rn),on=new RegExp(Vt,"i"),an=new RegExp(Wt+" \\w+","i"),un=new RegExp(Gt+" \\w+","i"),ln=new RegExp(Pt+"|PlayBook|BB10","i"),cn={"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"},dn=function(to,ue){return ue&&Y(ue,Rt)||function(eo){return Y(eo,xt)&&!Y(eo,Ot)&&!Y(eo,wt)}(to)},hn=function(to,ue){return ue=ue||"",Y(to," OPR/")&&Y(to,"Mini")?Nt:Y(to," OPR/")?qt:ln.test(to)?Pt:Y(to,"IE"+bt)||Y(to,"WPDesktop")?Dt:Y(to,Ct)?$t:Y(to,Bt)||Y(to,"Edg/")?Ht:Y(to,"FBIOS")?"Facebook "+bt:Y(to,"UCWEB")||Y(to,"UCBrowser")?"UC Browser":Y(to,"CriOS")?At:Y(to,"CrMo")?Ot:Y(to,wt)&&Y(to,xt)?zt:Y(to,Ot)?Ot:Y(to,"FxiOS")?jt:Y(to.toLowerCase(),nn.toLowerCase())?nn:dn(to,ue)?Y(to,bt)?Qt:xt:Y(to,Ut)?Ut:Y(to,"MSIE")||Y(to,"Trident/")?Lt:Y(to,"Gecko")?Ut:""},fn=(o(rt={},Dt,[new RegExp("rv:"+rn)]),o(rt,Ht,[new RegExp(Bt+"?\\/"+rn)]),o(rt,Ot,[new RegExp("("+Ot+"|CrMo)\\/"+rn)]),o(rt,At,[new RegExp("CriOS\\/"+rn)]),o(rt,"UC Browser",[new RegExp("(UCBrowser|UCWEB)\\/"+rn)]),o(rt,xt,[sn]),o(rt,Qt,[sn]),o(rt,qt,[new RegExp("(Opera|OPR)\\/"+rn)]),o(rt,Ut,[new RegExp(Ut+"\\/"+rn)]),o(rt,jt,[new RegExp("FxiOS\\/"+rn)]),o(rt,nn,[new RegExp("Konqueror[:/]?"+rn,"i")]),o(rt,Pt,[new RegExp(Pt+" "+rn),sn]),o(rt,zt,[new RegExp("android\\s"+rn,"i")]),o(rt,$t,[new RegExp(Ct+"\\/"+rn)]),o(rt,Lt,[new RegExp("(rv:|MSIE )"+rn)]),o(rt,"Mozilla",[new RegExp("rv:"+rn)]),rt),vn=[[new RegExp(Vt+"; "+Vt+" (.*?)[);]","i"),function(to){return[Vt,to&&to[1]||""]}],[new RegExp(Gt,"i"),[Gt,""]],[new RegExp(Wt,"i"),[Wt,""]],[ln,[Pt,""]],[new RegExp(Jt,"i"),function(to,ue){if(/Phone/.test(ue)||/WPDesktop/.test(ue))return[Yt,""];if(new RegExp(bt).test(ue)&&!/IEMobile\b/.test(ue))return[Jt+" "+bt,""];var eo=/Windows NT ([0-9.]+)/i.exec(ue);if(eo&&eo[1]){var no=eo[1],ro=cn[no]||"";return/arm/i.test(ue)&&(ro="RT"),[Jt,ro]}return[Jt,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,function(to){if(to&&to[3]){var ue=[to[3],to[4],to[5]||"0"];return[kt,ue.join(".")]}return[kt,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,function(to){var ue="";return to&&to.length>=3&&(ue=w$1(to[2])?to[3]:to[2]),["watchOS",ue]}],[new RegExp("("+wt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+wt+")","i"),function(to){if(to&&to[2]){var ue=[to[2],to[3],to[4]||"0"];return[wt,ue.join(".")]}return[wt,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,function(to){var ue=["Mac OS X",""];if(to&&to[1]){var eo=[to[1],to[2],to[3]||"0"];ue[1]=eo.join(".")}return ue}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Mt,""]],[/Linux|debian/i,["Linux",""]]],pn=function(to){return un.test(to)?Gt:an.test(to)?Wt:on.test(to)?Vt:new RegExp(Kt,"i").test(to)?Kt:new RegExp("("+Yt+"|WPDesktop)","i").test(to)?Yt:/iPad/.test(to)?It:/iPod/.test(to)?"iPod Touch":/iPhone/.test(to)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(to)?Ft:ln.test(to)?Pt:/(kobo)\s(ereader|touch)/i.test(to)?"Kobo":new RegExp(Xt,"i").test(to)?Xt:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(to)||/(kf[a-z]+)( bui|\)).+silk\//i.test(to)?"Kindle Fire":/(Android|ZTE)/i.test(to)?!new RegExp(bt).test(to)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(to)?/pixel[\daxl ]{1,6}/i.test(to)&&!/pixel c/i.test(to)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(to)||/lmy47v/i.test(to)&&!/QTAQZ3/i.test(to)?wt:Et:wt:new RegExp("(pda|"+bt+")","i").test(to)?en:new RegExp(St,"i").test(to)&&!new RegExp(St+" pc","i").test(to)?tn:""},gn="https?://(.*)",_n=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","mc_cid","igshid","ttclid","rdt_cid"],mn={campaignParams:function(to){return L?this._campaignParamsFromUrl(L.URL,to):{}},_campaignParamsFromUrl:function(to,ue){var eo=_n.concat(ue||[]),no={};return Q(eo,function(ro){var oo=mt(to,ro);oo&&(no[ro]=oo)}),no},_searchEngine:function(to){return to?to.search(gn+"google.([^/?]*)")===0?"google":to.search(gn+"bing.com")===0?"bing":to.search(gn+"yahoo.com")===0?"yahoo":to.search(gn+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(to){var ue=mn._searchEngine(to),eo=ue!="yahoo"?"q":"p",no={};if(!I(ue)){no.$search_engine=ue;var ro=L?mt(L.referrer,eo):"";ro.length&&(no.ph_keyword=ro)}return no},searchInfo:function(){var to=L==null?void 0:L.referrer;return to?this._searchInfoFromReferrer(to):{}},browser:hn,browserVersion:function(to,ue){var eo=hn(to,ue),no=fn[eo];if(w$1(no))return null;for(var ro=0;ro<no.length;ro++){var oo=no[ro],io=to.match(oo);if(io)return parseFloat(io[io.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},os:function(to){for(var ue=0;ue<vn.length;ue++){var eo=u(vn[ue],2),no=eo[0],ro=eo[1],oo=no.exec(to),io=oo&&(y(ro)?ro(oo,to):ro);if(io)return io}return["",""]},device:pn,deviceType:function(to){var ue=pn(to);return ue===It||ue===Et||ue==="Kobo"||ue==="Kindle Fire"||ue===tn?St:ue===Gt||ue===Vt||ue===Wt||ue===Kt?"Console":ue===Ft?"Wearable":ue?bt:"Desktop"},referrer:function(){return(L==null?void 0:L.referrer)||"$direct"},referringDomain:function(){var to;return L!=null&&L.referrer&&((to=pt(L.referrer))===null||to===void 0?void 0:to.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},initialPersonInfo:function(){return{r:this.referrer(),u:D==null?void 0:D.href}},initialPersonPropsFromInfo:function(to){var ue,eo=to.r,no=to.u,ro={$initial_referrer:eo,$initial_referring_domain:eo==null?void 0:eo=="$direct"?"$direct":(ue=pt(eo))===null||ue===void 0?void 0:ue.host};if(no){ro.$initial_current_url=no;var oo=pt(no);ro.$initial_host=oo==null?void 0:oo.host,ro.$initial_pathname=oo==null?void 0:oo.pathname,Q(this._campaignParamsFromUrl(no),function(io,ao){ro["$initial_"+ne(ao)]=io})}return eo&&Q(this._searchInfoFromReferrer(eo),function(io,ao){ro["$initial_"+ne(ao)]=io}),ro},properties:function(){if(!H)return{};var to=u(mn.os(H),2),ue=to[0],eo=to[1];return J(te({$os:ue,$os_version:eo,$browser:mn.browser(H,navigator.vendor),$device:mn.device(H),$device_type:mn.deviceType(H)}),{$current_url:D==null?void 0:D.href,$host:D==null?void 0:D.host,$pathname:D==null?void 0:D.pathname,$raw_user_agent:H.length>1e3?H.substring(0,997)+"...":H,$browser_version:mn.browserVersion(H,navigator.vendor),$browser_language:mn.browserLanguage(),$screen_height:T==null?void 0:T.screen.height,$screen_width:T==null?void 0:T.screen.width,$viewport_height:T==null?void 0:T.innerHeight,$viewport_width:T==null?void 0:T.innerWidth,$lib:"web",$lib_version:f.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:K()/1e3})},people_properties:function(){if(!H)return{};var to=u(mn.os(H),2),ue=to[0],eo=to[1];return J(te({$os:ue,$os_version:eo,$browser:mn.browser(H,navigator.vendor)}),{$browser_version:mn.browserVersion(H,navigator.vendor)})}},yn=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],bn=function(){function to(ue){i$1(this,to),this.config=ue,this.props={},this.campaign_params_saved=!1,this.name=function(eo){var no="";return eo.token&&(no=eo.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),eo.persistence_name?"ph_"+eo.persistence_name:"ph_"+no+"_posthog"}(ue),this.storage=this.buildStorage(ue),this.load(),ue.debug&&G.info("Persistence loaded",ue.persistence,t$1({},this.props)),this.update_config(ue,ue),this.save()}return s(to,[{key:"buildStorage",value:function(ue){yn.indexOf(ue.persistence.toLowerCase())===-1&&(G.critical("Unknown persistence type "+ue.persistence+"; falling back to localStorage+cookie"),ue.persistence="localStorage+cookie");var eo=ue.persistence.toLowerCase();return eo==="localstorage"&&at.is_supported()?at:eo==="localstorage+cookie"&<.is_supported()?lt:eo==="sessionstorage"&&ft.is_supported()?ft:eo==="memory"?dt:eo==="cookie"?st:lt.is_supported()?lt:st}},{key:"properties",value:function(){var ue={};return Q(this.props,function(eo,no){if(no===Ie&&b(eo))for(var ro=Object.keys(eo),oo=0;oo<ro.length;oo++)ue["$feature/".concat(ro[oo])]=eo[ro[oo]];else ao=no,so=!1,(I(io=Be)?so:M&&io.indexOf===M?io.indexOf(ao)!=-1:(Q(io,function(lo){if(so||(so=lo===ao))return W}),so))||(ue[no]=eo);var io,ao,so}),ue}},{key:"load",value:function(){if(!this.disabled){var ue=this.storage.parse(this.name);ue&&(this.props=J({},ue))}}},{key:"save",value:function(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure,this.config.debug)}},{key:"remove",value:function(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)}},{key:"clear",value:function(){this.remove(),this.props={}}},{key:"register_once",value:function(ue,eo,no){var ro=this;if(b(ue)){w$1(eo)&&(eo="None"),this.expire_days=w$1(no)?this.default_expiry:no;var oo=!1;if(Q(ue,function(io,ao){ro.props.hasOwnProperty(ao)&&ro.props[ao]!==eo||(ro.props[ao]=io,oo=!0)}),oo)return this.save(),!0}return!1}},{key:"register",value:function(ue,eo){var no=this;if(b(ue)){this.expire_days=w$1(eo)?this.default_expiry:eo;var ro=!1;if(Q(ue,function(oo,io){ue.hasOwnProperty(io)&&no.props[io]!==oo&&(no.props[io]=oo,ro=!0)}),ro)return this.save(),!0}return!1}},{key:"unregister",value:function(ue){ue in this.props&&(delete this.props[ue],this.save())}},{key:"update_campaign_params",value:function(){this.campaign_params_saved||(this.register(mn.campaignParams(this.config.custom_campaign_params)),this.campaign_params_saved=!0)}},{key:"update_search_keyword",value:function(){this.register(mn.searchInfo())}},{key:"update_referrer_info",value:function(){this.register_once(mn.referrerInfo(),void 0)}},{key:"set_initial_person_info",value:function(){this.props[Ae]||this.props[Le]||this.register_once(o({},De,mn.initialPersonInfo()),void 0)}},{key:"get_referrer_info",value:function(){return te({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}},{key:"get_initial_props",value:function(){var ue=this,eo={};Q([Le,Ae],function(oo){var io=ue.props[oo];io&&Q(io,function(ao,so){eo["$initial_"+ne(so)]=ao})});var no=this.props[De];if(no){var ro=mn.initialPersonPropsFromInfo(no);J(eo,ro)}return eo}},{key:"safe_merge",value:function(ue){return Q(this.props,function(eo,no){no in ue||(ue[no]=eo)}),ue}},{key:"update_config",value:function(ue,eo){if(this.default_expiry=this.expire_days=ue.cookie_expiration,this.set_disabled(ue.disable_persistence),this.set_cross_subdomain(ue.cross_subdomain_cookie),this.set_secure(ue.secure_cookie),ue.persistence!==eo.persistence){var no=this.buildStorage(ue),ro=this.props;this.clear(),this.storage=no,this.props=ro,this.save()}}},{key:"set_disabled",value:function(ue){this.disabled=ue,this.disabled?this.remove():this.save()}},{key:"set_cross_subdomain",value:function(ue){ue!==this.cross_subdomain&&(this.cross_subdomain=ue,this.remove(),this.save())}},{key:"get_cross_subdomain",value:function(){return!!this.cross_subdomain}},{key:"set_secure",value:function(ue){ue!==this.secure&&(this.secure=ue,this.remove(),this.save())}},{key:"set_event_timer",value:function(ue,eo){var no=this.props[de]||{};no[ue]=eo,this.props[de]=no,this.save()}},{key:"remove_event_timer",value:function(ue){var eo=(this.props[de]||{})[ue];return w$1(eo)||(delete this.props[de][ue],this.save()),eo}},{key:"get_property",value:function(ue){return this.props[ue]}},{key:"set_property",value:function(ue,eo){this.props[ue]=eo,this.save()}}]),to}();function kn(to){return JSON.stringify(to,(ue=[],function(eo,no){if(b(no)){for(;ue.length>0&&ue.at(-1)!==this;)ue.pop();return ue.includes(no)?"[Circular]":(ue.push(no),no)}return no})).length;var ue}var wn=2,Sn=4;function En(to){var ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:66060288e-1;if(to.size>=ue&&to.data.length>1){var eo=Math.floor(to.data.length/2),no=to.data.slice(0,eo),ro=to.data.slice(eo);return[En({size:kn(no),data:no,sessionId:to.sessionId,windowId:to.windowId}),En({size:kn(ro),data:ro,sessionId:to.sessionId,windowId:to.windowId})].flatMap(function(oo){return oo})}return[to]}var In=function(to){return to[to.DomContentLoaded=0]="DomContentLoaded",to[to.Load=1]="Load",to[to.FullSnapshot=2]="FullSnapshot",to[to.IncrementalSnapshot=3]="IncrementalSnapshot",to[to.Meta=4]="Meta",to[to.Custom=5]="Custom",to[to.Plugin=6]="Plugin",to}(In||{}),Rn=function(to){return to[to.Mutation=0]="Mutation",to[to.MouseMove=1]="MouseMove",to[to.MouseInteraction=2]="MouseInteraction",to[to.Scroll=3]="Scroll",to[to.ViewportResize=4]="ViewportResize",to[to.Input=5]="Input",to[to.TouchMove=6]="TouchMove",to[to.MediaInteraction=7]="MediaInteraction",to[to.StyleSheetRule=8]="StyleSheetRule",to[to.CanvasMutation=9]="CanvasMutation",to[to.Font=10]="Font",to[to.Log=11]="Log",to[to.Drag=12]="Drag",to[to.StyleDeclaration=13]="StyleDeclaration",to[to.Selection=14]="Selection",to[to.AdoptedStyleSheet=15]="AdoptedStyleSheet",to[to.CustomElement=16]="CustomElement",to}(Rn||{});function Fn(to){return to?V(to).split(/\s+/):[]}function xn(to){var ue=T==null?void 0:T.location.href;return!!(ue&&to&&to.some(function(eo){return ue.match(eo)}))}function Pn(to){var ue="";switch(n(to.className)){case"string":ue=to.className;break;case"object":ue=(to.className&&"baseVal"in to.className?to.className.baseVal:null)||to.getAttribute("class")||"";break;default:ue=""}return Fn(ue)}function Tn(to){return R(to)?null:V(to).split(/(\s+)/).filter(function(ue){return zn(ue)}).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Cn(to){var ue="";return Nn(to)&&!Bn(to)&&to.childNodes&&to.childNodes.length&&Q(to.childNodes,function(eo){var no;Mn(eo)&&eo.textContent&&(ue+=(no=Tn(eo.textContent))!==null&&no!==void 0?no:"")}),V(ue)}function $n(to){return!!to&&to.nodeType===1}function On(to,ue){return!!to&&!!to.tagName&&to.tagName.toLowerCase()===ue.toLowerCase()}function Mn(to){return!!to&&to.nodeType===3}function An(to){return!!to&&to.nodeType===11}var Ln=["a","button","form","input","select","textarea","label"];function Dn(to){var ue=to.parentNode;return!(!ue||!$n(ue))&&ue}function qn(to,ue){var eo=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,no=arguments.length>3?arguments[3]:void 0,ro=arguments.length>4?arguments[4]:void 0;if(!T||!to||On(to,"html")||!$n(to)||eo!=null&&eo.url_allowlist&&!xn(eo.url_allowlist)||eo!=null&&eo.url_ignorelist&&xn(eo.url_ignorelist))return!1;if(eo!=null&&eo.dom_event_allowlist){var oo=eo.dom_event_allowlist;if(oo&&!oo.some(function(po){return ue.type===po}))return!1}for(var io=!1,ao=[to],so=!0,lo=to;lo.parentNode&&!On(lo,"body");)if(An(lo.parentNode))ao.push(lo.parentNode.host),lo=lo.parentNode.host;else{if(!(so=Dn(lo)))break;if(no||Ln.indexOf(so.tagName.toLowerCase())>-1)io=!0;else{var co=T.getComputedStyle(so);co&&co.getPropertyValue("cursor")==="pointer"&&(io=!0)}ao.push(so),lo=so}if(!function(po,ho){var _o=ho==null?void 0:ho.element_allowlist;if(w$1(_o))return!0;var go,bo=h(po);try{var vo=function(){var wo=go.value;if(_o.some(function(ko){return wo.tagName.toLowerCase()===ko}))return{v:!0}};for(bo.s();!(go=bo.n()).done;){var yo=vo();if(n(yo)==="object")return yo.v}}catch(wo){bo.e(wo)}finally{bo.f()}return!1}(ao,eo)||!function(po,ho){var _o=ho==null?void 0:ho.css_selector_allowlist;if(w$1(_o))return!0;var go,bo=h(po);try{var vo=function(){var wo=go.value;if(_o.some(function(ko){return wo.matches(ko)}))return{v:!0}};for(bo.s();!(go=bo.n()).done;){var yo=vo();if(n(yo)==="object")return yo.v}}catch(wo){bo.e(wo)}finally{bo.f()}return!1}(ao,eo))return!1;var uo=T.getComputedStyle(to);if(uo&&uo.getPropertyValue("cursor")==="pointer"&&ue.type==="click")return!0;var fo=to.tagName.toLowerCase();switch(fo){case"html":return!1;case"form":return(ro||["submit"]).indexOf(ue.type)>=0;case"input":case"select":case"textarea":return(ro||["change","click"]).indexOf(ue.type)>=0;default:return io?(ro||["click"]).indexOf(ue.type)>=0:(ro||["click"]).indexOf(ue.type)>=0&&(Ln.indexOf(fo)>-1||to.getAttribute("contenteditable")==="true")}}function Nn(to){for(var ue=to;ue.parentNode&&!On(ue,"body");ue=ue.parentNode){var eo=Pn(ue);if(Y(eo,"ph-sensitive")||Y(eo,"ph-no-capture"))return!1}if(Y(Pn(to),"ph-include"))return!0;var no=to.type||"";if(S(no))switch(no.toLowerCase()){case"hidden":case"password":return!1}var ro=to.name||to.id||"";return!(S(ro)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(ro.replace(/[^a-zA-Z0-9]/g,"")))}function Bn(to){return!!(On(to,"input")&&!["button","checkbox","submit","reset"].includes(to.type)||On(to,"select")||On(to,"textarea")||to.getAttribute("contenteditable")==="true")}var Hn="(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})",Un=new RegExp("^(?:".concat(Hn,")$")),jn=new RegExp(Hn),Gn="\\d{3}-?\\d{2}-?\\d{4}",Wn=new RegExp("^(".concat(Gn,")$")),Vn=new RegExp("(".concat(Gn,")"));function zn(to){var ue=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(R(to)||S(to)&&(to=V(to),(ue?Un:jn).test((to||"").replace(/[- ]/g,""))||(ue?Wn:Vn).test(to)))}function Qn(to){var ue=Cn(to);return zn(ue="".concat(ue," ").concat(Jn(to)).trim())?ue:""}function Jn(to){var ue="";return to&&to.childNodes&&to.childNodes.length&&Q(to.childNodes,function(eo){var no;if(eo&&((no=eo.tagName)===null||no===void 0?void 0:no.toLowerCase())==="span")try{var ro=Cn(eo);ue="".concat(ue," ").concat(ro).trim(),eo.childNodes&&eo.childNodes.length&&(ue="".concat(ue," ").concat(Jn(eo)).trim())}catch(oo){G.error(oo)}}),ue}function Yn(to){return function(ue){var eo=ue.map(function(no){var ro,oo,io="";if(no.tag_name&&(io+=no.tag_name),no.attr_class){no.attr_class.sort();var ao,so=h(no.attr_class);try{for(so.s();!(ao=so.n()).done;){var lo=ao.value;io+=".".concat(lo.replace(/"/g,""))}}catch(fo){so.e(fo)}finally{so.f()}}var co=t$1(t$1(t$1(t$1({},no.text?{text:no.text}:{}),{},{"nth-child":(ro=no.nth_child)!==null&&ro!==void 0?ro:0,"nth-of-type":(oo=no.nth_of_type)!==null&&oo!==void 0?oo:0},no.href?{href:no.href}:{}),no.attr_id?{attr_id:no.attr_id}:{}),no.attributes),uo={};return X(co).sort(function(fo,po){var ho=u(fo,1)[0],_o=u(po,1)[0];return ho.localeCompare(_o)}).forEach(function(fo){var po=u(fo,2),ho=po[0],_o=po[1];return uo[Xn(ho.toString())]=Xn(_o.toString())}),io+=":",io+=X(co).map(function(fo){var po=u(fo,2),ho=po[0],_o=po[1];return"".concat(ho,'="').concat(_o,'"')}).join("")});return eo.join(";")}(function(ue){return ue.map(function(eo){var no,ro,oo={text:(no=eo.$el_text)===null||no===void 0?void 0:no.slice(0,400),tag_name:eo.tag_name,href:(ro=eo.attr__href)===null||ro===void 0?void 0:ro.slice(0,2048),attr_class:Kn(eo),attr_id:eo.attr__id,nth_child:eo.nth_child,nth_of_type:eo.nth_of_type,attributes:{}};return X(eo).filter(function(io){return u(io,1)[0].indexOf("attr__")===0}).forEach(function(io){var ao=u(io,2),so=ao[0],lo=ao[1];return oo.attributes[so]=lo}),oo})}(to))}function Xn(to){return to.replace(/"|\\"/g,'\\"')}function Kn(to){var ue=to.attr__class;return ue?m(ue)?ue:Fn(ue):void 0}var Zn="[SessionRecording]",ei="redacted",ti={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:function(to){return to},recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io"]},ni=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],ii=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],ri=["/s/","/e/","/i/"];function si(to,ue,eo,no){if(R(to))return to;var ro=(ue==null?void 0:ue["content-length"])||function(oo){return new Blob([oo]).size}(to);return S(ro)&&(ro=parseInt(ro)),ro>eo?Zn+" ".concat(no," body too large to record (").concat(ro," bytes)"):to}function oi(to,ue){if(R(to))return to;var eo=to;return zn(eo,!1)||(eo=Zn+" "+ue+" body "+ei),Q(ii,function(no){var ro,oo;(ro=eo)!==null&&ro!==void 0&&ro.length&&((oo=eo)===null||oo===void 0?void 0:oo.indexOf(no))!==-1&&(eo=Zn+" "+ue+" body "+ei+" as might contain: "+no)}),eo}var ai,ui=function(to,ue){var eo,no,ro,oo={payloadSizeLimitBytes:ti.payloadSizeLimitBytes,performanceEntryTypeToObserve:l(ti.performanceEntryTypeToObserve),payloadHostDenyList:[].concat(l(ue.payloadHostDenyList||[]),l(ti.payloadHostDenyList))},io=to.session_recording.recordHeaders!==!1&&ue.recordHeaders,ao=to.session_recording.recordBody!==!1&&ue.recordBody,so=to.capture_performance!==!1&&ue.recordPerformance,lo=(eo=oo,ro=Math.min(1e6,(no=eo.payloadSizeLimitBytes)!==null&&no!==void 0?no:1e6),function(fo){return fo!=null&&fo.requestBody&&(fo.requestBody=si(fo.requestBody,fo.requestHeaders,ro,"Request")),fo!=null&&fo.responseBody&&(fo.responseBody=si(fo.responseBody,fo.responseHeaders,ro,"Response")),fo}),co=function(fo){return lo(function(_o){var go=pt(_o.name);if(!(go&&go.pathname&&ri.some(function(bo){return go.pathname.indexOf(bo)===0})))return _o}((ho=(po=fo).requestHeaders,R(ho)||Q(Object.keys(ho??{}),function(_o){ni.includes(_o.toLowerCase())&&(ho[_o]=ei)}),po)));var po,ho},uo=y(to.session_recording.maskNetworkRequestFn);return uo&&y(to.session_recording.maskCapturedNetworkRequestFn)&&G.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),uo&&(to.session_recording.maskCapturedNetworkRequestFn=function(fo){var po=to.session_recording.maskNetworkRequestFn({url:fo.name});return t$1(t$1({},fo),{},{name:po==null?void 0:po.url})}),oo.maskRequestFn=y(to.session_recording.maskCapturedNetworkRequestFn)?function(fo){var po,ho,_o,go=co(fo);return go&&(po=(ho=(_o=to.session_recording).maskCapturedNetworkRequestFn)===null||ho===void 0?void 0:ho.call(_o,go))!==null&&po!==void 0?po:void 0}:function(fo){return function(po){if(!w$1(po))return po.requestBody=oi(po.requestBody,"Request"),po.responseBody=oi(po.responseBody,"Response"),po}(co(fo))},t$1(t$1(t$1({},ti),oo),{},{recordHeaders:io,recordBody:ao,recordPerformance:so,recordInitialRequests:so})},li=s(function to(ue){var eo,no,ro=this,oo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};i$1(this,to),o(this,"bucketSize",100),o(this,"refillRate",10),o(this,"mutationBuckets",{}),o(this,"loggedTracker",{}),o(this,"refillBuckets",function(){Object.keys(ro.mutationBuckets).forEach(function(io){ro.mutationBuckets[io]=ro.mutationBuckets[io]+ro.refillRate,ro.mutationBuckets[io]>=ro.bucketSize&&delete ro.mutationBuckets[io]})}),o(this,"getNodeOrRelevantParent",function(io){var ao=ro.rrweb.mirror.getNode(io);if((ao==null?void 0:ao.nodeName)!=="svg"&&ao instanceof Element){var so=ao.closest("svg");if(so)return[ro.rrweb.mirror.getId(so),so]}return[io,ao]}),o(this,"numberOfChanges",function(io){var ao,so,lo,co,uo,fo,po,ho;return((ao=(so=io.removes)===null||so===void 0?void 0:so.length)!==null&&ao!==void 0?ao:0)+((lo=(co=io.attributes)===null||co===void 0?void 0:co.length)!==null&&lo!==void 0?lo:0)+((uo=(fo=io.texts)===null||fo===void 0?void 0:fo.length)!==null&&uo!==void 0?uo:0)+((po=(ho=io.adds)===null||ho===void 0?void 0:ho.length)!==null&&po!==void 0?po:0)}),o(this,"throttleMutations",function(io){if(io.type!==3||io.data.source!==0)return io;var ao=io.data,so=ro.numberOfChanges(ao);ao.attributes&&(ao.attributes=ao.attributes.filter(function(co){var uo,fo,po,ho=u(ro.getNodeOrRelevantParent(co.id),2),_o=ho[0],go=ho[1];return ro.mutationBuckets[_o]===0?!1:(ro.mutationBuckets[_o]=(uo=ro.mutationBuckets[_o])!==null&&uo!==void 0?uo:ro.bucketSize,ro.mutationBuckets[_o]=Math.max(ro.mutationBuckets[_o]-1,0),ro.mutationBuckets[_o]===0&&(ro.loggedTracker[_o]||(ro.loggedTracker[_o]=!0,(fo=(po=ro.options).onBlockedNode)===null||fo===void 0||fo.call(po,_o,go))),co)}));var lo=ro.numberOfChanges(ao);return lo!==0||so===lo?io:void 0}),this.rrweb=ue,this.options=oo,this.refillRate=(eo=this.options.refillRate)!==null&&eo!==void 0?eo:this.refillRate,this.bucketSize=(no=this.options.bucketSize)!==null&&no!==void 0?no:this.bucketSize,setInterval(function(){ro.refillBuckets()},1e3)}),ci=3e5,di=[Rn.MouseMove,Rn.MouseInteraction,Rn.Scroll,Rn.ViewportResize,Rn.Input,Rn.TouchMove,Rn.MediaInteraction,Rn.Drag],hi=function(to){return{rrwebMethod:to,enqueuedAt:Date.now(),attempt:1}},fi="[SessionRecording]",vi=function(){function to(ue){var eo=this;if(i$1(this,to),o(this,"queuedRRWebEvents",[]),o(this,"isIdle",!1),o(this,"_linkedFlagSeen",!1),o(this,"_lastActivityTimestamp",Date.now()),o(this,"_linkedFlag",null),o(this,"_forceAllowLocalhostNetworkCapture",!1),o(this,"_onBeforeUnload",function(){eo._flushBuffer()}),o(this,"_onOffline",function(){eo._tryAddCustomEvent("browser offline",{})}),o(this,"_onOnline",function(){eo._tryAddCustomEvent("browser online",{})}),o(this,"_onVisibilityChange",function(){if(L!=null&&L.visibilityState){var io="window "+L.visibilityState;eo._tryAddCustomEvent(io,{})}}),o(this,"_samplingSessionListener",null),this.instance=ue,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw G.error(fi+" started without valid sessionManager"),new Error(fi+" started without valid sessionManager. This is a bug.");var no=this.sessionManager.checkAndGetSessionAndWindowId(),ro=no.sessionId,oo=no.windowId;this.sessionId=ro,this.windowId=oo,this.buffer=this.clearBuffer(),this._setupSampling()}return s(to,[{key:"rrwebRecord",get:function(){var ue;return U==null||(ue=U.rrweb)===null||ue===void 0?void 0:ue.record}},{key:"started",get:function(){return this._captureStarted}},{key:"sessionManager",get:function(){if(!this.instance.sessionManager)throw new Error(fi+" must be started with a valid sessionManager.");return this.instance.sessionManager}},{key:"fullSnapshotIntervalMillis",get:function(){var ue;return((ue=this.instance.config.session_recording)===null||ue===void 0?void 0:ue.full_snapshot_interval_millis)||ci}},{key:"isSampled",get:function(){var ue=this.instance.get_property(Ee);return x$1(ue)?ue:null}},{key:"sessionDuration",get:function(){var ue,eo,no=(ue=this.buffer)===null||ue===void 0?void 0:ue.data[((eo=this.buffer)===null||eo===void 0?void 0:eo.data.length)-1],ro=this.sessionManager.checkAndGetSessionAndWindowId(!0).sessionStartTimestamp;return no?no.timestamp-ro:null}},{key:"isRecordingEnabled",get:function(){var ue=!!this.instance.get_property(_e),eo=!this.instance.config.disable_session_recording;return T&&ue&&eo}},{key:"isConsoleLogCaptureEnabled",get:function(){var ue=!!this.instance.get_property(me),eo=this.instance.config.enable_recording_console_log;return eo??ue}},{key:"canvasRecording",get:function(){var ue=this.instance.get_property(be);return ue&&ue.fps&&ue.quality?{enabled:ue.enabled,fps:ue.fps,quality:ue.quality}:void 0}},{key:"networkPayloadCapture",get:function(){var ue,eo,no=this.instance.get_property(ye),ro={recordHeaders:(ue=this.instance.config.session_recording)===null||ue===void 0?void 0:ue.recordHeaders,recordBody:(eo=this.instance.config.session_recording)===null||eo===void 0?void 0:eo.recordBody},oo=(ro==null?void 0:ro.recordHeaders)||(no==null?void 0:no.recordHeaders),io=(ro==null?void 0:ro.recordBody)||(no==null?void 0:no.recordBody),ao=b(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,so=!!(x$1(ao)?ao:no!=null&&no.capturePerformance);return oo||io||so?{recordHeaders:oo,recordBody:io,recordPerformance:so}:void 0}},{key:"sampleRate",get:function(){var ue=this.instance.get_property(ke);return F(ue)?ue:null}},{key:"minimumDuration",get:function(){var ue=this.instance.get_property(we);return F(ue)?ue:null}},{key:"status",get:function(){return this.receivedDecide?this.isRecordingEnabled?R(this._linkedFlag)||this._linkedFlagSeen?x$1(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}},{key:"startIfEnabledOrStop",value:function(){this.isRecordingEnabled?(this._startCapture(),T==null||T.addEventListener("beforeunload",this._onBeforeUnload),T==null||T.addEventListener("offline",this._onOffline),T==null||T.addEventListener("online",this._onOnline),T==null||T.addEventListener("visibilitychange",this._onVisibilityChange),G.info(fi+" started")):(this.stopRecording(),this.clearBuffer())}},{key:"stopRecording",value:function(){this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,T==null||T.removeEventListener("beforeunload",this._onBeforeUnload),T==null||T.removeEventListener("offline",this._onOffline),T==null||T.removeEventListener("online",this._onOnline),T==null||T.removeEventListener("visibilitychange",this._onVisibilityChange),G.info(fi+" stopped"))}},{key:"makeSamplingDecision",value:function(ue){var eo,no=this.sessionId!==ue,ro=this.sampleRate;if(F(ro)){var oo,io=this.isSampled,ao=no||!x$1(io);ao?oo=Math.random()<ro:oo=io,!oo&&ao&&G.warn(fi+" Sample rate (".concat(ro,") has determined that this sessionId (").concat(ue,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:ro}),(eo=this.instance.persistence)===null||eo===void 0||eo.register(o({},Ee,oo))}else{var so;(so=this.instance.persistence)===null||so===void 0||so.register(o({},Ee,null))}}},{key:"afterDecideResponse",value:function(ue){var eo,no,ro,oo=this;if(this._persistDecideResponse(ue),this._linkedFlag=((eo=ue.sessionRecording)===null||eo===void 0?void 0:eo.linkedFlag)||null,(no=ue.sessionRecording)!==null&&no!==void 0&&no.endpoint&&(this._endpoint=(ro=ue.sessionRecording)===null||ro===void 0?void 0:ro.endpoint),this._setupSampling(),!R(this._linkedFlag)&&!this._linkedFlagSeen){var io=S(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,ao=S(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags(function(so,lo){var co=b(lo)&&io in lo,uo=ao?lo[io]===ao:co;if(uo){var fo={linkedFlag:io,linkedVariant:ao},po="linked flag matched";G.info(fi+" "+po,fo),oo._tryAddCustomEvent(po,fo)}oo._linkedFlagSeen=uo})}this.receivedDecide=!0,this.startIfEnabledOrStop()}},{key:"_setupSampling",value:function(){var ue=this;F(this.sampleRate)&&I(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId(function(eo){ue.makeSamplingDecision(eo)}))}},{key:"_persistDecideResponse",value:function(ue){if(this.instance.persistence){var eo=this.instance.persistence,no=function(){var ro,oo,io,ao,so,lo,co,uo,fo=(ro=ue.sessionRecording)===null||ro===void 0?void 0:ro.sampleRate,po=R(fo)?null:parseFloat(fo),ho=(oo=ue.sessionRecording)===null||oo===void 0?void 0:oo.minimumDurationMilliseconds;eo.register((o(uo={},_e,!!ue.sessionRecording),o(uo,me,(io=ue.sessionRecording)===null||io===void 0?void 0:io.consoleLogRecordingEnabled),o(uo,ye,t$1({capturePerformance:ue.capturePerformance},(ao=ue.sessionRecording)===null||ao===void 0?void 0:ao.networkPayloadCapture)),o(uo,be,{enabled:(so=ue.sessionRecording)===null||so===void 0?void 0:so.recordCanvas,fps:(lo=ue.sessionRecording)===null||lo===void 0?void 0:lo.canvasFps,quality:(co=ue.sessionRecording)===null||co===void 0?void 0:co.canvasQuality}),o(uo,ke,po),o(uo,we,w$1(ho)?null:ho),uo))};no(),this.sessionManager.onSessionId(no)}}},{key:"log",value:function(ue){var eo,no=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"log";(eo=this.instance.sessionRecording)===null||eo===void 0||eo.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:no,trace:[],payload:[JSON.stringify(ue)]}},timestamp:K()})}},{key:"_startCapture",value:function(){var ue=this;w$1(Object.assign)||this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut()||(this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),this.rrwebRecord?this._onScriptLoaded():this.instance.requestRouter.loadScript("/static/recorder.js?v=".concat(f.LIB_VERSION),function(eo){if(eo)return G.error(fi+" could not load recorder.js",eo);ue._onScriptLoaded()}))}},{key:"isInteractiveEvent",value:function(ue){var eo;return ue.type===3&&di.indexOf((eo=ue.data)===null||eo===void 0?void 0:eo.source)!==-1}},{key:"_updateWindowAndSessionIds",value:function(ue){var eo=this.isInteractiveEvent(ue);eo||this.isIdle||ue.timestamp-this._lastActivityTimestamp>3e5&&(this.isIdle=!0,clearTimeout(this._fullSnapshotTimer),this._flushBuffer());var no=!1;if(eo&&(this._lastActivityTimestamp=ue.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:ue.type}),no=!0)),!this.isIdle){var ro=this.sessionManager.checkAndGetSessionAndWindowId(!eo,ue.timestamp),oo=ro.windowId,io=ro.sessionId,ao=this.sessionId!==io,so=this.windowId!==oo;this.windowId=oo,this.sessionId=io,(no||[wn,Sn].indexOf(ue.type)===-1&&(so||ao||w$1(this._fullSnapshotTimer)))&&this._tryTakeFullSnapshot()}}},{key:"_tryRRWebMethod",value:function(ue){try{return ue.rrwebMethod(),!0}catch(eo){return this.queuedRRWebEvents.length<10?this.queuedRRWebEvents.push({enqueuedAt:ue.enqueuedAt||Date.now(),attempt:ue.attempt++,rrwebMethod:ue.rrwebMethod}):G.warn(fi+" could not emit queued rrweb event.",eo,ue),!1}}},{key:"_tryAddCustomEvent",value:function(ue,eo){var no=this;return this._tryRRWebMethod(hi(function(){return no.rrwebRecord.addCustomEvent(ue,eo)}))}},{key:"_tryTakeFullSnapshot",value:function(){var ue=this;return this._tryRRWebMethod(hi(function(){return ue.rrwebRecord.takeFullSnapshot()}))}},{key:"_onScriptLoaded",value:function(){for(var ue,eo=this,no={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},ro=this.instance.config.session_recording,oo=0,io=Object.entries(ro||{});oo<io.length;oo++){var ao=u(io[oo],2),so=ao[0],lo=ao[1];so in no&&(so==="maskInputOptions"?no.maskInputOptions=t$1({password:!0},lo):no[so]=lo)}if(this.canvasRecording&&this.canvasRecording.enabled&&(no.recordCanvas=!0,no.sampling={canvas:this.canvasRecording.fps},no.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),this.rrwebRecord){this.mutationRateLimiter=(ue=this.mutationRateLimiter)!==null&&ue!==void 0?ue:new li(this.rrwebRecord,{onBlockedNode:function(uo,fo){var po="Too many mutations on node '".concat(uo,"'. Rate limiting. This could be due to SVG animations or something similar");G.info(po,{node:fo}),eo.log(fi+" "+po,"warn")}});var co=this._gatherRRWebPlugins();this.stopRrweb=this.rrwebRecord(t$1({emit:function(uo){eo.onRRwebEmit(uo)},plugins:co},no)),this.instance._addCaptureHook(function(uo){try{if(uo==="$pageview"){var fo=T?eo._maskUrl(T.location.href):"";if(!fo)return;eo._tryAddCustomEvent("$pageview",{href:fo})}}catch(po){G.error("Could not add $pageview to rrweb session",po)}}),this._lastActivityTimestamp=Date.now(),this.isIdle=!1,this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:no,activePlugins:co.map(function(uo){return uo==null?void 0:uo.name})}),this._tryAddCustomEvent("$posthog_config",{config:this.instance.config})}else G.error(fi+"onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}},{key:"_scheduleFullSnapshot",value:function(){var ue=this;if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!this.isIdle){var eo=this.fullSnapshotIntervalMillis;eo&&(this._fullSnapshotTimer=setInterval(function(){ue._tryTakeFullSnapshot()},eo))}}},{key:"_gatherRRWebPlugins",value:function(){var ue=[];return U.rrwebConsoleRecord&&this.isConsoleLogCaptureEnabled&&ue.push(U.rrwebConsoleRecord.getRecordConsolePlugin()),this.networkPayloadCapture&&y(U.getRecordNetworkPlugin)&&(!vt.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?ue.push(U.getRecordNetworkPlugin(ui(this.instance.config,this.networkPayloadCapture))):G.info(fi+" NetworkCapture not started because we are on localhost.")),ue}},{key:"onRRwebEmit",value:function(ue){if(this._processQueuedEvents(),ue&&b(ue)){if(ue.type===In.Meta){var eo=this._maskUrl(ue.data.href);if(this._lastHref=eo,!eo)return;ue.data.href=eo}else this._pageViewFallBack();ue.type===In.FullSnapshot&&this._scheduleFullSnapshot();var no=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(ue):ue;if(no){var ro=function(ao){var so=ao;if(so&&b(so)&&so.type===6&&b(so.data)&&so.data.plugin==="rrweb/console@1"){so.data.payload.payload.length>10&&(so.data.payload.payload=so.data.payload.payload.slice(0,10),so.data.payload.payload.push("...[truncated]"));for(var lo=[],co=0;co<so.data.payload.payload.length;co++)so.data.payload.payload[co]&&so.data.payload.payload[co].length>2e3?lo.push(so.data.payload.payload[co].slice(0,2e3)+"...[truncated]"):lo.push(so.data.payload.payload[co]);return so.data.payload.payload=lo,ao}return ao}(no),oo=kn(ro);if(this._updateWindowAndSessionIds(ro),!this.isIdle||ro.type===In.Custom){var io={$snapshot_bytes:oo,$snapshot_data:ro,$session_id:this.sessionId,$window_id:this.windowId};this.status!=="disabled"?this._captureSnapshotBuffered(io):this.clearBuffer()}}}}},{key:"_pageViewFallBack",value:function(){if(!this.instance.config.capture_pageview&&T){var ue=this._maskUrl(T.location.href);this._lastHref!==ue&&(this._tryAddCustomEvent("$url_changed",{href:ue}),this._lastHref=ue)}}},{key:"_processQueuedEvents",value:function(){var ue=this;if(this.queuedRRWebEvents.length){var eo=l(this.queuedRRWebEvents);this.queuedRRWebEvents=[],eo.forEach(function(no){Date.now()-no.enqueuedAt<=2e3&&ue._tryRRWebMethod(no)})}}},{key:"_maskUrl",value:function(ue){var eo=this.instance.config.session_recording;if(eo.maskNetworkRequestFn){var no,ro={url:ue};return(no=ro=eo.maskNetworkRequestFn(ro))===null||no===void 0?void 0:no.url}return ue}},{key:"clearBuffer",value:function(){return this.buffer={size:0,data:[],sessionId:this.sessionId,windowId:this.windowId},this.buffer}},{key:"_flushBuffer",value:function(){var ue=this;this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var eo=this.minimumDuration,no=this.sessionDuration,ro=F(no)&&no>=0,oo=F(eo)&&ro&&no<eo;return this.status==="buffering"||oo?(this.flushBufferTimer=setTimeout(function(){ue._flushBuffer()},2e3),this.buffer):(this.buffer.data.length>0&&En(this.buffer).forEach(function(io){ue._captureSnapshot({$snapshot_bytes:io.size,$snapshot_data:io.data,$session_id:io.sessionId,$window_id:io.windowId})}),this.clearBuffer())}},{key:"_captureSnapshotBuffered",value:function(ue){var eo,no=this,ro=2+(((eo=this.buffer)===null||eo===void 0?void 0:eo.data.length)||0);(this.buffer.size+ue.$snapshot_bytes+ro>943718.4||this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),this.buffer.size+=ue.$snapshot_bytes,this.buffer.data.push(ue.$snapshot_data),this.flushBufferTimer||(this.flushBufferTimer=setTimeout(function(){no._flushBuffer()},2e3))}},{key:"_captureSnapshot",value:function(ue){this.instance.capture("$snapshot",ue,{_url:this.instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}},{key:"overrideLinkedFlag",value:function(){this._linkedFlagSeen=!0}}]),to}(),pi=function(){function to(ue){i$1(this,to),this.instance=ue,this.instance.decideEndpointWasHit=this.instance._hasBootstrappedFeatureFlags()}return s(to,[{key:"call",value:function(){var ue=this,eo={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),person_properties:this.instance.get_property(Fe),group_properties:this.instance.get_property(xe),disable_flags:this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load||void 0};this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:eo,compression:this.instance.config.disable_compression?void 0:re.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:function(no){return ue.parseDecideResponse(no.json)}})}},{key:"parseDecideResponse",value:function(ue){var eo=this;this.instance.featureFlags.setReloadingPaused(!1),this.instance.featureFlags._startReloadTimer();var no=!ue;if(this.instance.config.advanced_disable_feature_flags_on_first_load||this.instance.config.advanced_disable_feature_flags||this.instance.featureFlags.receivedFeatureFlags(ue??{},no),no)G.error("Failed to fetch feature flags from PostHog.");else{if(!L||!L.body)return G.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(function(){eo.parseDecideResponse(ue)},500);if(this.instance._afterDecideResponse(ue),ue.siteApps)if(this.instance.config.opt_in_site_apps){var ro,oo=h(ue.siteApps);try{var io=function(){var ao=ro.value,so=ao.id,lo=ao.url,co=eo.instance.requestRouter.endpointFor("api",lo);U["__$$ph_site_app_".concat(so)]=eo.instance,eo.instance.requestRouter.loadScript(co,function(uo){if(uo)return G.error("Error while initializing PostHog app with config id ".concat(so),uo)})};for(oo.s();!(ro=oo.n()).done;)io()}catch(ao){oo.e(ao)}finally{oo.f()}}else ue.siteApps.length>0&&G.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}]),to}(),gi=T!=null&&T.location?yt(T.location.hash,"__posthog")||yt(location.hash,"state"):null,_i="_postHogToolbarParams";(function(to){to[to.UNINITIALIZED=0]="UNINITIALIZED",to[to.LOADING=1]="LOADING",to[to.LOADED=2]="LOADED"})(ai||(ai={}));var mi=function(){function to(ue){i$1(this,to),this.instance=ue}return s(to,[{key:"setToolbarState",value:function(ue){U.ph_toolbar_state=ue}},{key:"getToolbarState",value:function(){var ue;return(ue=U.ph_toolbar_state)!==null&&ue!==void 0?ue:ai.UNINITIALIZED}},{key:"maybeLoadToolbar",value:function(){var ue,eo,no=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,ro=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,oo=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!T||!L)return!1;no=(ue=no)!==null&&ue!==void 0?ue:T.location,oo=(eo=oo)!==null&&eo!==void 0?eo:T.history;try{if(!ro){try{T.localStorage.setItem("test","test"),T.localStorage.removeItem("test")}catch{return!1}ro=T==null?void 0:T.localStorage}var io,ao=gi||yt(no.hash,"__posthog")||yt(no.hash,"state"),so=ao?Z(function(){return JSON.parse(atob(decodeURIComponent(ao)))})||Z(function(){return JSON.parse(decodeURIComponent(ao))}):null;return so&&so.action==="ph_authorize"?((io=so).source="url",io&&Object.keys(io).length>0&&(so.desiredHash?no.hash=so.desiredHash:oo?oo.replaceState(oo.state,"",no.pathname+no.search):no.hash="")):((io=JSON.parse(ro.getItem(_i)||"{}")).source="localstorage",delete io.userIntent),!(!io.token||this.instance.config.token!==io.token)&&(this.loadToolbar(io),!0)}catch{return!1}}},{key:"_callLoadToolbar",value:function(ue){(U.ph_load_toolbar||U.ph_load_editor)(ue,this.instance)}},{key:"loadToolbar",value:function(ue){var eo=this,no=!(L==null||!L.getElementById(Ne));if(!T||no)return!1;var ro=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,oo=t$1(t$1({token:this.instance.config.token},ue),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},ro?{instrument:!1}:{});if(T.localStorage.setItem(_i,JSON.stringify(t$1(t$1({},oo),{},{source:void 0}))),this.getToolbarState()===ai.LOADED)this._callLoadToolbar(oo);else if(this.getToolbarState()===ai.UNINITIALIZED){this.setToolbarState(ai.LOADING);var io=3e5,ao=Math.floor(Date.now()/io)*io;this.instance.requestRouter.loadScript("/static/toolbar.js?t=".concat(ao),function(so){if(so)return G.error("Failed to load toolbar",so),void eo.setToolbarState(ai.UNINITIALIZED);eo.setToolbarState(ai.LOADED),eo._callLoadToolbar(oo)}),oe(T,"turbolinks:load",function(){eo.setToolbarState(ai.UNINITIALIZED),eo.loadToolbar(oo)})}return!0}},{key:"_loadEditor",value:function(ue){return this.loadToolbar(ue)}},{key:"maybeLoadEditor",value:function(){var ue=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,eo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,no=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;return this.maybeLoadToolbar(ue,eo,no)}}]),to}(),yi=function(){function to(ue){i$1(this,to),o(this,"isPaused",!0),o(this,"queue",[]),o(this,"flushTimeoutMs",3e3),this.sendRequest=ue}return s(to,[{key:"enqueue",value:function(ue){this.queue.push(ue),this.flushTimeout||this.setFlushTimeout()}},{key:"unload",value:function(){var ue=this;this.clearFlushTimeout();var eo=this.queue.length>0?this.formatQueue():{},no=Object.values(eo);[].concat(l(no.filter(function(ro){return ro.url.indexOf("/e")===0})),l(no.filter(function(ro){return ro.url.indexOf("/e")!==0}))).map(function(ro){ue.sendRequest(t$1(t$1({},ro),{},{transport:"sendBeacon"}))})}},{key:"enable",value:function(){this.isPaused=!1,this.setFlushTimeout()}},{key:"setFlushTimeout",value:function(){var ue=this;this.isPaused||(this.flushTimeout=setTimeout(function(){if(ue.clearFlushTimeout(),ue.queue.length>0){var eo=ue.formatQueue(),no=function(oo){var io=eo[oo],ao=new Date().getTime();io.data&&m(io.data)&&Q(io.data,function(so){so.offset=Math.abs(so.timestamp-ao),delete so.timestamp}),ue.sendRequest(io)};for(var ro in eo)no(ro)}},this.flushTimeoutMs))}},{key:"clearFlushTimeout",value:function(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}},{key:"formatQueue",value:function(){var ue={};return Q(this.queue,function(eo){var no,ro=eo,oo=(ro?ro.batchKey:null)||ro.url;w$1(ue[oo])&&(ue[oo]=t$1(t$1({},ro),{},{data:[]})),(no=ue[oo].data)===null||no===void 0||no.push(ro.data)}),this.queue=[],ue}}]),to}(),bi=Uint8Array,ki=Uint16Array,wi=Uint32Array,Si=new bi([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]),Ei=new bi([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]),Ii=new bi([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ri=function(to,ue){for(var eo=new ki(31),no=0;no<31;++no)eo[no]=ue+=1<<to[no-1];var ro=new wi(eo[30]);for(no=1;no<30;++no)for(var oo=eo[no];oo<eo[no+1];++oo)ro[oo]=oo-eo[no]<<5|no;return[eo,ro]},Fi=Ri(Si,2),xi=Fi[0],Pi=Fi[1];xi[28]=258,Pi[258]=28;for(var Ti=Ri(Ei,0)[1],Ci=new ki(32768),$i=0;$i<32768;++$i){var Oi=(43690&$i)>>>1|(21845&$i)<<1;Oi=(61680&(Oi=(52428&Oi)>>>2|(13107&Oi)<<2))>>>4|(3855&Oi)<<4,Ci[$i]=((65280&Oi)>>>8|(255&Oi)<<8)>>>1}var Mi=function(to,ue,eo){for(var no=to.length,ro=0,oo=new ki(ue);ro<no;++ro)++oo[to[ro]-1];var io,ao=new ki(ue);for(ro=0;ro<ue;++ro)ao[ro]=ao[ro-1]+oo[ro-1]<<1;if(eo){io=new ki(1<<ue);var so=15-ue;for(ro=0;ro<no;++ro)if(to[ro])for(var lo=ro<<4|to[ro],co=ue-to[ro],uo=ao[to[ro]-1]++<<co,fo=uo|(1<<co)-1;uo<=fo;++uo)io[Ci[uo]>>>so]=lo}else for(io=new ki(no),ro=0;ro<no;++ro)io[ro]=Ci[ao[to[ro]-1]++]>>>15-to[ro];return io},Ai$1=new bi(288);for($i=0;$i<144;++$i)Ai$1[$i]=8;for($i=144;$i<256;++$i)Ai$1[$i]=9;for($i=256;$i<280;++$i)Ai$1[$i]=7;for($i=280;$i<288;++$i)Ai$1[$i]=8;var Li=new bi(32);for($i=0;$i<32;++$i)Li[$i]=5;var Di=Mi(Ai$1,9,0),qi=Mi(Li,5,0),Ni=function(to){return(to/8>>0)+(7&to&&1)},Bi=function(to,ue,eo){(ue==null||ue<0)&&(ue=0),(eo==null||eo>to.length)&&(eo=to.length);var no=new(to instanceof ki?ki:to instanceof wi?wi:bi)(eo-ue);return no.set(to.subarray(ue,eo)),no},Hi=function(to,ue,eo){eo<<=7&ue;var no=ue/8>>0;to[no]|=eo,to[no+1]|=eo>>>8},Ui=function(to,ue,eo){eo<<=7&ue;var no=ue/8>>0;to[no]|=eo,to[no+1]|=eo>>>8,to[no+2]|=eo>>>16},ji=function(to,ue){for(var eo=[],no=0;no<to.length;++no)to[no]&&eo.push({s:no,f:to[no]});var ro=eo.length,oo=eo.slice();if(!ro)return[new bi(0),0];if(ro==1){var io=new bi(eo[0].s+1);return io[eo[0].s]=1,[io,1]}eo.sort(function(ko,So){return ko.f-So.f}),eo.push({s:-1,f:25001});var ao=eo[0],so=eo[1],lo=0,co=1,uo=2;for(eo[0]={s:-1,f:ao.f+so.f,l:ao,r:so};co!=ro-1;)ao=eo[eo[lo].f<eo[uo].f?lo++:uo++],so=eo[lo!=co&&eo[lo].f<eo[uo].f?lo++:uo++],eo[co++]={s:-1,f:ao.f+so.f,l:ao,r:so};var fo=oo[0].s;for(no=1;no<ro;++no)oo[no].s>fo&&(fo=oo[no].s);var po=new ki(fo+1),ho=Gi(eo[co-1],po,0);if(ho>ue){no=0;var _o=0,go=ho-ue,bo=1<<go;for(oo.sort(function(ko,So){return po[So.s]-po[ko.s]||ko.f-So.f});no<ro;++no){var vo=oo[no].s;if(!(po[vo]>ue))break;_o+=bo-(1<<ho-po[vo]),po[vo]=ue}for(_o>>>=go;_o>0;){var yo=oo[no].s;po[yo]<ue?_o-=1<<ue-po[yo]++-1:++no}for(;no>=0&&_o;--no){var wo=oo[no].s;po[wo]==ue&&(--po[wo],++_o)}ho=ue}return[new bi(po),ho]},Gi=function to(ue,eo,no){return ue.s==-1?Math.max(to(ue.l,eo,no+1),to(ue.r,eo,no+1)):eo[ue.s]=no},Wi=function(to){for(var ue=to.length;ue&&!to[--ue];);for(var eo=new ki(++ue),no=0,ro=to[0],oo=1,io=function(so){eo[no++]=so},ao=1;ao<=ue;++ao)if(to[ao]==ro&&ao!=ue)++oo;else{if(!ro&&oo>2){for(;oo>138;oo-=138)io(32754);oo>2&&(io(oo>10?oo-11<<5|28690:oo-3<<5|12305),oo=0)}else if(oo>3){for(io(ro),--oo;oo>6;oo-=6)io(8304);oo>2&&(io(oo-3<<5|8208),oo=0)}for(;oo--;)io(ro);oo=1,ro=to[ao]}return[eo.subarray(0,no),ue]},Vi=function(to,ue){for(var eo=0,no=0;no<ue.length;++no)eo+=to[no]*ue[no];return eo},zi=function(to,ue,eo){var no=eo.length,ro=Ni(ue+2);to[ro]=255&no,to[ro+1]=no>>>8,to[ro+2]=255^to[ro],to[ro+3]=255^to[ro+1];for(var oo=0;oo<no;++oo)to[ro+oo+4]=eo[oo];return 8*(ro+4+no)},Qi=function(to,ue,eo,no,ro,oo,io,ao,so,lo,co){Hi(ue,co++,eo),++ro[256];for(var uo=ji(ro,15),fo=uo[0],po=uo[1],ho=ji(oo,15),_o=ho[0],go=ho[1],bo=Wi(fo),vo=bo[0],yo=bo[1],wo=Wi(_o),ko=wo[0],So=wo[1],Eo=new ki(19),Io=0;Io<vo.length;++Io)Eo[31&vo[Io]]++;for(Io=0;Io<ko.length;++Io)Eo[31&ko[Io]]++;for(var Ao=ji(Eo,7),To=Ao[0],zo=Ao[1],Vo=19;Vo>4&&!To[Ii[Vo-1]];--Vo);var Fo,Po,Ro,Do,qo=lo+5<<3,Uo=Vi(ro,Ai$1)+Vi(oo,Li)+io,jo=Vi(ro,fo)+Vi(oo,_o)+io+14+3*Vo+Vi(Eo,To)+(2*Eo[16]+3*Eo[17]+7*Eo[18]);if(qo<=Uo&&qo<=jo)return zi(ue,co,to.subarray(so,so+lo));if(Hi(ue,co,1+(jo<Uo)),co+=2,jo<Uo){Fo=Mi(fo,po,0),Po=fo,Ro=Mi(_o,go,0),Do=_o;var Zo=Mi(To,zo,0);for(Hi(ue,co,yo-257),Hi(ue,co+5,So-1),Hi(ue,co+10,Vo-4),co+=14,Io=0;Io<Vo;++Io)Hi(ue,co+3*Io,To[Ii[Io]]);co+=3*Vo;for(var Yo=[vo,ko],Xo=0;Xo<2;++Xo){var Qo=Yo[Xo];for(Io=0;Io<Qo.length;++Io){var Jo=31&Qo[Io];Hi(ue,co,Zo[Jo]),co+=To[Jo],Jo>15&&(Hi(ue,co,Qo[Io]>>>5&127),co+=Qo[Io]>>>12)}}}else Fo=Di,Po=Ai$1,Ro=qi,Do=Li;for(Io=0;Io<ao;++Io)if(no[Io]>255){Jo=no[Io]>>>18&31,Ui(ue,co,Fo[Jo+257]),co+=Po[Jo+257],Jo>7&&(Hi(ue,co,no[Io]>>>23&31),co+=Si[Jo]);var ra=31&no[Io];Ui(ue,co,Ro[ra]),co+=Do[ra],ra>3&&(Ui(ue,co,no[Io]>>>5&8191),co+=Ei[ra])}else Ui(ue,co,Fo[no[Io]]),co+=Po[no[Io]];return Ui(ue,co,Fo[256]),co+Po[256]},Ji=new wi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Yi=new bi(0),Xi=function(){for(var to=new wi(256),ue=0;ue<256;++ue){for(var eo=ue,no=9;--no;)eo=(1&eo&&3988292384)^eo>>>1;to[ue]=eo}return to}(),Ki=function(to,ue,eo,no,ro){return function(oo,io,ao,so,lo,co){var uo=oo.length,fo=new bi(so+uo+5*(1+Math.floor(uo/7e3))+lo),po=fo.subarray(so,fo.length-lo),ho=0;if(!io||uo<8)for(var _o=0;_o<=uo;_o+=65535){var go=_o+65535;go<uo?ho=zi(po,ho,oo.subarray(_o,go)):(po[_o]=co,ho=zi(po,ho,oo.subarray(_o,uo)))}else{for(var bo=Ji[io-1],vo=bo>>>13,yo=8191&bo,wo=(1<<ao)-1,ko=new ki(32768),So=new ki(wo+1),Eo=Math.ceil(ao/3),Io=2*Eo,Ao=function(Ba){return(oo[Ba]^oo[Ba+1]<<Eo^oo[Ba+2]<<Io)&wo},To=new wi(25e3),zo=new ki(288),Vo=new ki(32),Fo=0,Po=0,Ro=(_o=0,0),Do=0,qo=0;_o<uo;++_o){var Uo=Ao(_o),jo=32767&_o,Zo=So[Uo];if(ko[jo]=Zo,So[Uo]=jo,Do<=_o){var Yo=uo-_o;if((Fo>7e3||Ro>24576)&&Yo>423){ho=Qi(oo,po,0,To,zo,Vo,Po,Ro,qo,_o-qo,ho),Ro=Fo=Po=0,qo=_o;for(var Xo=0;Xo<286;++Xo)zo[Xo]=0;for(Xo=0;Xo<30;++Xo)Vo[Xo]=0}var Qo=2,Jo=0,ra=yo,Ko=jo-Zo&32767;if(Yo>2&&Uo==Ao(_o-Ko))for(var ia=Math.min(vo,Yo)-1,ea=Math.min(32767,_o),sa=Math.min(258,Yo);Ko<=ea&&--ra&&jo!=Zo;){if(oo[_o+Qo]==oo[_o+Qo-Ko]){for(var Ea=0;Ea<sa&&oo[_o+Ea]==oo[_o+Ea-Ko];++Ea);if(Ea>Qo){if(Qo=Ea,Jo=Ko,Ea>ia)break;var da=Math.min(Ko,Ea-2),ya=0;for(Xo=0;Xo<da;++Xo){var Aa=_o-Ko+Xo+32768&32767,ma=Aa-ko[Aa]+32768&32767;ma>ya&&(ya=ma,Zo=Aa)}}}Ko+=(jo=Zo)-(Zo=ko[jo])+32768&32767}if(Jo){To[Ro++]=268435456|Pi[Qo]<<18|Ti[Jo];var Da=31&Pi[Qo],Na=31&Ti[Jo];Po+=Si[Da]+Ei[Na],++zo[257+Da],++Vo[Na],Do=_o+Qo,++Fo}else To[Ro++]=oo[_o],++zo[oo[_o]]}}ho=Qi(oo,po,co,To,zo,Vo,Po,Ro,qo,_o-qo,ho),co||(ho=zi(po,ho,Yi))}return Bi(fo,0,so+Ni(ho)+lo)}(to,ue.level==null?6:ue.level,ue.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(to.length)))):12+ue.mem,eo,no,!ro)},Zi=function(to,ue,eo){for(;eo;++ue)to[ue]=eo,eo>>>=8};function er(to,ue){ue===void 0&&(ue={});var eo=function(){var ao=4294967295;return{p:function(so){for(var lo=ao,co=0;co<so.length;++co)lo=Xi[255&lo^so[co]]^lo>>>8;ao=lo},d:function(){return 4294967295^ao}}}(),no=to.length;eo.p(to);var ro,oo=Ki(to,ue,10+((ro=ue).filename&&ro.filename.length+1||0),8),io=oo.length;return function(ao,so){var lo=so.filename;if(ao[0]=31,ao[1]=139,ao[2]=8,ao[8]=so.level<2?4:so.level==9?2:0,ao[9]=3,so.mtime!=0&&Zi(ao,4,Math.floor(new Date(so.mtime||Date.now())/1e3)),lo){ao[3]=8;for(var co=0;co<=lo.length;++co)ao[co+10]=lo.charCodeAt(co)}}(oo,ue),Zi(oo,io-8,eo.d()),Zi(oo,io-4,no),oo}var tr=!!N||!!q,nr="text/plain",ir=function(to,ue){var eo=u(to.split("?"),2),no=eo[0],ro=eo[1],oo=t$1({},ue);ro==null||ro.split("&").forEach(function(ao){var so=u(ao.split("="),1)[0];delete oo[so]});var io=_t(oo);return io=io?(ro?ro+"&":"")+io:ro,"".concat(no,"?").concat(io)},rr=function(to){return"data="+encodeURIComponent(typeof to=="string"?to:JSON.stringify(to))},sr=function(to){var ue=to.data,eo=to.compression;if(ue){if(eo===re.GZipJS){var no=er(function(oo,io){var ao=oo.length;if(!io&&typeof TextEncoder<"u")return new TextEncoder().encode(oo);for(var so=new bi(oo.length+(oo.length>>>1)),lo=0,co=function(ho){so[lo++]=ho},uo=0;uo<ao;++uo){if(lo+5>so.length){var fo=new bi(lo+8+(ao-uo<<1));fo.set(so),so=fo}var po=oo.charCodeAt(uo);po<128||io?co(po):po<2048?(co(192|po>>>6),co(128|63&po)):po>55295&&po<57344?(co(240|(po=65536+(1047552&po)|1023&oo.charCodeAt(++uo))>>>18),co(128|po>>>12&63),co(128|po>>>6&63),co(128|63&po)):(co(224|po>>>12),co(128|po>>>6&63),co(128|63&po))}return Bi(so,0,lo)}(JSON.stringify(ue)),{mtime:0});return{contentType:nr,body:new Blob([no],{type:nr})}}if(eo===re.Base64){var ro=function(oo){var io,ao,so,lo,co,uo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",fo=0,po=0,ho="",_o=[];if(!oo)return oo;oo=se(oo);do io=(co=oo.charCodeAt(fo++)<<16|oo.charCodeAt(fo++)<<8|oo.charCodeAt(fo++))>>18&63,ao=co>>12&63,so=co>>6&63,lo=63&co,_o[po++]=uo.charAt(io)+uo.charAt(ao)+uo.charAt(so)+uo.charAt(lo);while(fo<oo.length);switch(ho=_o.join(""),oo.length%3){case 1:ho=ho.slice(0,-2)+"==";break;case 2:ho=ho.slice(0,-1)+"="}return ho}(JSON.stringify(ue));return{contentType:"application/x-www-form-urlencoded",body:rr(ro)}}return{contentType:"application/json",body:JSON.stringify(ue)}}},or=[];N&&or.push({transport:"XHR",method:function(to){var ue,eo=new N;eo.open(to.method||"GET",to.url,!0);var no=(ue=sr(to))!==null&&ue!==void 0?ue:{},ro=no.contentType,oo=no.body;Q(to.headers,function(io,ao){eo.setRequestHeader(ao,io)}),ro&&eo.setRequestHeader("Content-Type",ro),to.timeout&&(eo.timeout=to.timeout),eo.withCredentials=!0,eo.onreadystatechange=function(){if(eo.readyState===4){var io,ao={statusCode:eo.status,text:eo.responseText};if(eo.status===200)try{ao.json=JSON.parse(eo.responseText)}catch{}(io=to.callback)===null||io===void 0||io.call(to,ao)}},eo.send(oo)}}),q&&or.push({transport:"fetch",method:function(to){var ue,eo,no=(ue=sr(to))!==null&&ue!==void 0?ue:{},ro=no.contentType,oo=no.body,io=new Headers;Q(to.headers,function(co,uo){io.append(uo,co)}),ro&&io.append("Content-Type",ro);var ao=to.url,so=null;if(B){var lo=new B;so={signal:lo.signal,timeout:setTimeout(function(){return lo.abort()},to.timeout)}}q(ao,{method:(to==null?void 0:to.method)||"GET",headers:io,keepalive:to.method==="POST",body:oo,signal:(eo=so)===null||eo===void 0?void 0:eo.signal}).then(function(co){return co.text().then(function(uo){var fo,po={statusCode:co.status,text:uo};if(co.status===200)try{po.json=JSON.parse(uo)}catch(ho){G.error(ho)}(fo=to.callback)===null||fo===void 0||fo.call(to,po)})}).catch(function(co){var uo;G.error(co),(uo=to.callback)===null||uo===void 0||uo.call(to,{statusCode:0,text:co})}).finally(function(){return so?clearTimeout(so.timeout):null})}}),A!=null&&A.sendBeacon&&or.push({transport:"sendBeacon",method:function(to){var ue=ir(to.url,{beacon:"1"});try{var eo,no=(eo=sr(to))!==null&&eo!==void 0?eo:{},ro=no.contentType,oo=no.body,io=typeof oo=="string"?new Blob([oo],{type:ro}):oo;A.sendBeacon(ue,io)}catch{}}});var ar=["retriesPerformedSoFar"],ur,lr=function(){function to(ue){var eo=this;i$1(this,to),o(this,"isPolling",!1),o(this,"pollIntervalMs",3e3),o(this,"queue",[]),this.instance=ue,this.queue=[],this.areWeOnline=!0,!w$1(T)&&"onLine"in T.navigator&&(this.areWeOnline=T.navigator.onLine,T.addEventListener("online",function(){eo.areWeOnline=!0,eo.flush()}),T.addEventListener("offline",function(){eo.areWeOnline=!1}))}return s(to,[{key:"retriableRequest",value:function(ue){var eo=this,no=ue.retriesPerformedSoFar,ro=a(ue,ar);F(no)&&no>0&&(ro.url=ir(ro.url,{retry_count:no})),this.instance._send_request(t$1(t$1({},ro),{},{callback:function(oo){var io;oo.statusCode!==200&&(oo.statusCode<400||oo.statusCode>=500)&&(no??0)<10?eo.enqueue(t$1({retriesPerformedSoFar:no},ro)):(io=ro.callback)===null||io===void 0||io.call(ro,oo)}}))}},{key:"enqueue",value:function(ue){var eo=ue.retriesPerformedSoFar||0;ue.retriesPerformedSoFar=eo+1;var no=function(io){var ao=3e3*Math.pow(2,io),so=ao/2,lo=Math.min(18e5,ao),co=(Math.random()-.5)*(lo-so);return Math.ceil(lo+co)}(eo),ro=Date.now()+no;this.queue.push({retryAt:ro,requestOptions:ue});var oo="Enqueued failed request for retry in ".concat(no);navigator.onLine||(oo+=" (Browser is offline)"),G.warn(oo),this.isPolling||(this.isPolling=!0,this.poll())}},{key:"poll",value:function(){var ue=this;this.poller&&clearTimeout(this.poller),this.poller=setTimeout(function(){ue.areWeOnline&&ue.queue.length>0&&ue.flush(),ue.poll()},this.pollIntervalMs)}},{key:"flush",value:function(){var ue=Date.now(),eo=[],no=this.queue.filter(function(ao){return ao.retryAt<ue||(eo.push(ao),!1)});if(this.queue=eo,no.length>0){var ro,oo=h(no);try{for(oo.s();!(ro=oo.n()).done;){var io=ro.value.requestOptions;this.retriableRequest(io)}}catch(ao){oo.e(ao)}finally{oo.f()}}}},{key:"unload",value:function(){this.poller&&(clearTimeout(this.poller),this.poller=void 0);var ue,eo=h(this.queue);try{for(eo.s();!(ue=eo.n()).done;){var no=ue.value.requestOptions;try{this.instance._send_request(t$1(t$1({},no),{},{transport:"sendBeacon"}))}catch(ro){G.error(ro)}}}catch(ro){eo.e(ro)}finally{eo.f()}this.queue=[]}}]),to}(),cr=1800,dr=function(){function to(ue,eo,no,ro){var oo;i$1(this,to),o(this,"_sessionIdChangedHandlers",[]),this.config=ue,this.persistence=eo,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=no||Ke,this._windowIdGenerator=ro||Ke;var io=ue.persistence_name||ue.token,ao=ue.session_idle_timeout_seconds||cr;if(F(ao)?ao>cr?G.warn("session_idle_timeout_seconds cannot be greater than 30 minutes. Using 30 minutes instead."):ao<60&&G.warn("session_idle_timeout_seconds cannot be less than 60 seconds. Using 60 seconds instead."):(G.warn("session_idle_timeout_seconds must be a number. Defaulting to 30 minutes."),ao=cr),this._sessionTimeoutMs=1e3*Math.min(Math.max(ao,60),cr),this._window_id_storage_key="ph_"+io+"_window_id",this._primary_window_exists_storage_key="ph_"+io+"_primary_window_exists",this._canUseSessionStorage()){var so=ft.parse(this._window_id_storage_key),lo=ft.parse(this._primary_window_exists_storage_key);so&&!lo?this._windowId=so:ft.remove(this._window_id_storage_key),ft.set(this._primary_window_exists_storage_key,!0)}if((oo=this.config.bootstrap)!==null&&oo!==void 0&&oo.sessionID)try{var co=function(uo){var fo=uo.replace(/-/g,"");if(fo.length!==32)throw new Error("Not a valid UUID");if(fo[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(fo.substring(0,12),16)}(this.config.bootstrap.sessionID);this._setSessionId(this.config.bootstrap.sessionID,new Date().getTime(),co)}catch(uo){G.error("Invalid sessionID in bootstrap",uo)}this._listenToReloadWindow()}return s(to,[{key:"onSessionId",value:function(ue){var eo=this;return w$1(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(ue),this._sessionId&&ue(this._sessionId,this._windowId),function(){eo._sessionIdChangedHandlers=eo._sessionIdChangedHandlers.filter(function(no){return no!==ue})}}},{key:"_canUseSessionStorage",value:function(){return this.config.persistence!=="memory"&&!this.persistence.disabled&&ft.is_supported()}},{key:"_setWindowId",value:function(ue){ue!==this._windowId&&(this._windowId=ue,this._canUseSessionStorage()&&ft.set(this._window_id_storage_key,ue))}},{key:"_getWindowId",value:function(){return this._windowId?this._windowId:this._canUseSessionStorage()?ft.parse(this._window_id_storage_key):null}},{key:"_setSessionId",value:function(ue,eo,no){ue===this._sessionId&&eo===this._sessionActivityTimestamp&&no===this._sessionStartTimestamp||(this._sessionStartTimestamp=no,this._sessionActivityTimestamp=eo,this._sessionId=ue,this.persistence.register(o({},Se,[eo,ue,no])))}},{key:"_getSessionId",value:function(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var ue=this.persistence.props[Se];return m(ue)&&ue.length===2&&ue.push(ue[0]),ue||[0,null,0]}},{key:"resetSessionId",value:function(){this._setSessionId(null,null,null)}},{key:"_listenToReloadWindow",value:function(){var ue=this;T==null||T.addEventListener("beforeunload",function(){ue._canUseSessionStorage()&&ft.remove(ue._primary_window_exists_storage_key)})}},{key:"checkAndGetSessionAndWindowId",value:function(){var ue=arguments.length>0&&arguments[0]!==void 0&&arguments[0],eo=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||new Date().getTime(),no=u(this._getSessionId(),3),ro=no[0],oo=no[1],io=no[2],ao=this._getWindowId(),so=io&&io>0&&Math.abs(eo-io)>864e5,lo=!1,co=!oo,uo=!ue&&Math.abs(eo-ro)>this._sessionTimeoutMs;co||uo||so?(oo=this._sessionIdGenerator(),ao=this._windowIdGenerator(),G.info("[SessionId] new session ID generated",{sessionId:oo,windowId:ao,changeReason:{noSessionId:co,activityTimeout:uo,sessionPastMaximumLength:so}}),io=eo,lo=!0):ao||(ao=this._windowIdGenerator(),lo=!0);var fo=ro===0||!ue||so?eo:ro,po=io===0?new Date().getTime():io;return this._setWindowId(ao),this._setSessionId(oo,fo,po),lo&&this._sessionIdChangedHandlers.forEach(function(ho){return ho(oo,ao)}),{sessionId:oo,windowId:ao,sessionStartTimestamp:po}}}]),to}();(function(to){to.US="us",to.EU="eu",to.CUSTOM="custom"})(ur||(ur={}));var hr="i.posthog.com",fr=function(){function to(ue){i$1(this,to),o(this,"_regionCache",{}),this.instance=ue}return s(to,[{key:"apiHost",get:function(){var ue=this.instance.config.api_host.trim().replace(/\/$/,"");return ue==="https://app.posthog.com"?"https://us.i.posthog.com":ue}},{key:"uiHost",get:function(){var ue,eo=(ue=this.instance.config.ui_host)===null||ue===void 0?void 0:ue.replace(/\/$/,"");return eo||(eo=this.apiHost.replace(".".concat(hr),".posthog.com")),eo==="https://app.posthog.com"?"https://us.posthog.com":eo}},{key:"region",get:function(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=ur.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=ur.EU:this._regionCache[this.apiHost]=ur.CUSTOM),this._regionCache[this.apiHost]}},{key:"endpointFor",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(eo&&(eo=eo[0]==="/"?eo:"/".concat(eo)),ue==="ui")return this.uiHost+eo;if(this.region===ur.CUSTOM)return this.apiHost+eo;var no=hr+eo;switch(ue){case"assets":return"https://".concat(this.region,"-assets.").concat(no);case"api":return"https://".concat(this.region,".").concat(no)}}},{key:"loadScript",value:function(ue,eo){if(this.instance.config.disable_external_dependency_loading)return G.warn("".concat(ue," was requested but loading of external scripts is disabled.")),eo("Loading of external scripts is disabled");var no=ue[0]==="/"?this.endpointFor("assets",ue):ue,ro=function(){if(!L)return eo("document not found");var oo=L.createElement("script");oo.type="text/javascript",oo.src=no,oo.onload=function(so){return eo(void 0,so)},oo.onerror=function(so){return eo(so)};var io,ao=L.querySelectorAll("body > script");ao.length>0?(io=ao[0].parentNode)===null||io===void 0||io.insertBefore(oo,ao[0]):L.body.appendChild(oo)};L!=null&&L.body?ro():L==null||L.addEventListener("DOMContentLoaded",ro)}}]),to}(),vr="posthog-js";function pr(to){var ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},eo=ue.organization,no=ue.projectId,ro=ue.prefix,oo=ue.severityAllowList,io=oo===void 0?["error"]:oo;return function(ao){var so,lo,co,uo,fo;if(!(io==="*"||io.includes(ao.level))||!to.__loaded)return ao;ao.tags||(ao.tags={});var po=to.requestRouter.endpointFor("ui","/project/".concat(to.config.token,"/person/").concat(to.get_distinct_id()));ao.tags["PostHog Person URL"]=po,to.sessionRecordingStarted()&&(ao.tags["PostHog Recording URL"]=to.get_session_replay_url({withTimestamp:!0}));var ho=((so=ao.exception)===null||so===void 0?void 0:so.values)||[],_o={$exception_message:((lo=ho[0])===null||lo===void 0?void 0:lo.value)||ao.message,$exception_type:(co=ho[0])===null||co===void 0?void 0:co.type,$exception_personURL:po,$exception_level:ao.level,$sentry_event_id:ao.event_id,$sentry_exception:ao.exception,$sentry_exception_message:((uo=ho[0])===null||uo===void 0?void 0:uo.value)||ao.message,$sentry_exception_type:(fo=ho[0])===null||fo===void 0?void 0:fo.type,$sentry_tags:ao.tags,$level:ao.level};return eo&&no&&(_o.$sentry_url=(ro||"https://sentry.io/organizations/")+eo+"/issues/?project="+no+"&query="+ao.event_id),to.exceptions.sendExceptionEvent(_o),ao}}var gr=s(function to(ue,eo,no,ro,oo){i$1(this,to),this.name=vr,this.setupOnce=function(io){io(pr(ue,{organization:eo,projectId:no,prefix:ro,severityAllowList:oo}))}});function _r(to,ue){var eo=to.config.segment;if(!eo)return ue();(function(no,ro){var oo=no.config.segment;if(!oo)return ro();var io=function(so){var lo=function(){return so.anonymousId()||Ke()};no.config.get_device_id=lo,so.id()&&(no.register({distinct_id:so.id(),$device_id:lo()}),no.persistence.set_property($e,"identified")),ro()},ao=oo.user();"then"in ao&&y(ao.then)?ao.then(function(so){return io(so)}):io(ao)})(to,function(){eo.register(function(no){Promise&&Promise.resolve||G.warn("This browser does not have Promise support, and can not use the segment integration");var ro=function(oo,io){var ao;if(!io)return oo;oo.event.userId||oo.event.anonymousId===no.get_distinct_id()||(G.info("Segment integration does not have a userId set, resetting PostHog"),no.reset()),oo.event.userId&&oo.event.userId!==no.get_distinct_id()&&(G.info("Segment integration has a userId set, identifying with PostHog"),no.identify(oo.event.userId));var so=no._calculate_event_properties(io,(ao=oo.event.properties)!==null&&ao!==void 0?ao:{},new Date);return oo.event.properties=Object.assign({},so,oo.event.properties),oo};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},track:function(oo){return ro(oo,oo.event.event)},page:function(oo){return ro(oo,"$pageview")},identify:function(oo){return ro(oo,"$identify")},screen:function(oo){return ro(oo,"$screen")}}}(to)).then(function(){ue()})})}var mr,yr,br,kr=function(){function to(ue){i$1(this,to),this._instance=ue}return s(to,[{key:"doPageView",value:function(ue){var eo,no=this._previousPageViewProperties(ue);return this._currentPath=(eo=T==null?void 0:T.location.pathname)!==null&&eo!==void 0?eo:"",this._instance.scrollManager.resetContext(),this._prevPageviewTimestamp=ue,no}},{key:"doPageLeave",value:function(ue){return this._previousPageViewProperties(ue)}},{key:"_previousPageViewProperties",value:function(ue){var eo=this._currentPath,no=this._prevPageviewTimestamp,ro=this._instance.scrollManager.getContext();if(!no)return{};var oo={};if(ro){var io=ro.maxScrollHeight,ao=ro.lastScrollY,so=ro.maxScrollY,lo=ro.maxContentHeight,co=ro.lastContentY,uo=ro.maxContentY;w$1(io)||w$1(ao)||w$1(so)||w$1(lo)||w$1(co)||w$1(uo)||(io=Math.ceil(io),ao=Math.ceil(ao),so=Math.ceil(so),lo=Math.ceil(lo),co=Math.ceil(co),uo=Math.ceil(uo),oo={$prev_pageview_last_scroll:ao,$prev_pageview_last_scroll_percentage:io<=1?1:wr(ao/io,0,1),$prev_pageview_max_scroll:so,$prev_pageview_max_scroll_percentage:io<=1?1:wr(so/io,0,1),$prev_pageview_last_content:co,$prev_pageview_last_content_percentage:lo<=1?1:wr(co/lo,0,1),$prev_pageview_max_content:uo,$prev_pageview_max_content_percentage:lo<=1?1:wr(uo/lo,0,1)})}return eo&&(oo.$prev_pageview_pathname=eo),no&&(oo.$prev_pageview_duration=(ue.getTime()-no.getTime())/1e3),oo}}]),to}();function wr(to,ue,eo){return Math.max(ue,Math.min(to,eo))}(function(to){to.Popover="popover",to.API="api",to.Widget="widget"})(mr||(mr={})),function(to){to.Open="open",to.MultipleChoice="multiple_choice",to.SingleChoice="single_choice",to.Rating="rating",to.Link="link"}(yr||(yr={})),function(to){to.NextQuestion="next_question",to.End="end",to.ResponseBased="response_based",to.SpecificQuestion="specific_question"}(br||(br={}));var Sr=function(){function to(){i$1(this,to),o(this,"events",{}),this.events={}}return s(to,[{key:"on",value:function(ue,eo){var no=this;return this.events[ue]||(this.events[ue]=[]),this.events[ue].push(eo),function(){no.events[ue]=no.events[ue].filter(function(ro){return ro!==eo})}}},{key:"emit",value:function(ue,eo){var no,ro=h(this.events[ue]||[]);try{for(ro.s();!(no=ro.n()).done;)(0,no.value)(eo)}catch(ao){ro.e(ao)}finally{ro.f()}var oo,io=h(this.events["*"]||[]);try{for(io.s();!(oo=io.n()).done;)(0,oo.value)(ue,eo)}catch(ao){io.e(ao)}finally{io.f()}}}]),to}(),Er=function(){function to(ue){var eo=this;i$1(this,to),o(this,"_debugEventEmitter",new Sr),o(this,"checkStep",function(no,ro){return eo.checkStepEvent(no,ro)&&eo.checkStepUrl(no,ro)&&eo.checkStepElement(no,ro)}),o(this,"checkStepEvent",function(no,ro){return ro==null||!ro.event||(no==null?void 0:no.event)===(ro==null?void 0:ro.event)}),this.instance=ue,this.actionEvents=new Set,this.actionRegistry=new Set}return s(to,[{key:"init",value:function(){var ue,eo=this;if(!w$1((ue=this.instance)===null||ue===void 0?void 0:ue._addCaptureHook)){var no;(no=this.instance)===null||no===void 0||no._addCaptureHook(function(ro,oo){eo.on(ro,oo)})}}},{key:"register",value:function(ue){var eo,no,ro=this;if(!w$1((eo=this.instance)===null||eo===void 0?void 0:eo._addCaptureHook)&&(ue.forEach(function(ao){var so,lo;(so=ro.actionRegistry)===null||so===void 0||so.add(ao),(lo=ao.steps)===null||lo===void 0||lo.forEach(function(co){var uo;(uo=ro.actionEvents)===null||uo===void 0||uo.add((co==null?void 0:co.event)||"")})}),(no=this.instance)!==null&&no!==void 0&&no.autocapture)){var oo,io=new Set;ue.forEach(function(ao){var so;(so=ao.steps)===null||so===void 0||so.forEach(function(lo){lo!=null&&lo.selector&&io.add(lo==null?void 0:lo.selector)})}),(oo=this.instance)===null||oo===void 0||oo.autocapture.setElementSelectors(io)}}},{key:"on",value:function(ue,eo){var no,ro=this;eo!=null&&ue.length!=0&&(this.actionEvents.has(ue)||this.actionEvents.has(eo==null?void 0:eo.event))&&this.actionRegistry&&((no=this.actionRegistry)===null||no===void 0?void 0:no.size)>0&&this.actionRegistry.forEach(function(oo){ro.checkAction(eo,oo)&&ro._debugEventEmitter.emit("actionCaptured",oo.name)})}},{key:"_addActionHook",value:function(ue){this.onAction("actionCaptured",function(eo){return ue(eo)})}},{key:"checkAction",value:function(ue,eo){if((eo==null?void 0:eo.steps)==null)return!1;var no,ro=h(eo.steps);try{for(ro.s();!(no=ro.n()).done;){var oo=no.value;if(this.checkStep(ue,oo))return!0}}catch(io){ro.e(io)}finally{ro.f()}return!1}},{key:"onAction",value:function(ue,eo){return this._debugEventEmitter.on(ue,eo)}},{key:"checkStepUrl",value:function(ue,eo){if(eo!=null&&eo.url){var no,ro=ue==null||(no=ue.properties)===null||no===void 0?void 0:no.$current_url;if(!ro||typeof ro!="string"||!to.matchString(ro,eo==null?void 0:eo.url,(eo==null?void 0:eo.url_matching)||"contains"))return!1}return!0}},{key:"checkStepElement",value:function(ue,eo){if((eo!=null&&eo.href||eo!=null&&eo.tag_name||eo!=null&&eo.text)&&!this.getElementsList(ue).some(function(oo){return!(eo!=null&&eo.href&&!to.matchString(oo.href||"",eo==null?void 0:eo.href,(eo==null?void 0:eo.href_matching)||"exact"))&&(eo==null||!eo.tag_name||oo.tag_name===(eo==null?void 0:eo.tag_name))&&!(eo!=null&&eo.text&&!to.matchString(oo.text||"",eo==null?void 0:eo.text,(eo==null?void 0:eo.text_matching)||"exact")&&!to.matchString(oo.$el_text||"",eo==null?void 0:eo.text,(eo==null?void 0:eo.text_matching)||"exact"))}))return!1;if(eo!=null&&eo.selector){var no,ro=ue==null||(no=ue.properties)===null||no===void 0?void 0:no.$element_selectors;if(!ro||!ro.includes(eo==null?void 0:eo.selector))return!1}return!0}},{key:"getElementsList",value:function(ue){return(ue==null?void 0:ue.properties.$elements)==null?[]:ue==null?void 0:ue.properties.$elements}}],[{key:"matchString",value:function(ue,eo,no){switch(no){case"regex":return!!T&>(ue,eo);case"exact":return eo===ue;case"contains":var ro=to.escapeStringRegexp(eo).replace(/_/g,".").replace(/%/g,".*");return gt(ue,ro);default:return!1}}},{key:"escapeStringRegexp",value:function(ue){return ue.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}}]),to}(),Ir=function(){function to(ue){i$1(this,to),this.instance=ue,this.eventToSurveys=new Map,this.actionToSurveys=new Map}return s(to,[{key:"register",value:function(ue){var eo;w$1((eo=this.instance)===null||eo===void 0?void 0:eo._addCaptureHook)||(this.setupEventBasedSurveys(ue),this.setupActionBasedSurveys(ue))}},{key:"setupActionBasedSurveys",value:function(ue){var eo=this,no=ue.filter(function(ro){var oo,io,ao,so;return((oo=ro.conditions)===null||oo===void 0?void 0:oo.actions)&&((io=ro.conditions)===null||io===void 0||(ao=io.actions)===null||ao===void 0||(so=ao.values)===null||so===void 0?void 0:so.length)>0});no.length!==0&&(this.actionMatcher==null&&(this.actionMatcher=new Er(this.instance),this.actionMatcher.init(),this.actionMatcher._addActionHook(function(ro){eo.onAction(ro)})),no.forEach(function(ro){var oo,io,ao,so,lo,co,uo,fo,po,ho;ro.conditions&&(oo=ro.conditions)!==null&&oo!==void 0&&oo.actions&&(io=ro.conditions)!==null&&io!==void 0&&(ao=io.actions)!==null&&ao!==void 0&&ao.values&&((so=ro.conditions)===null||so===void 0||(lo=so.actions)===null||lo===void 0||(co=lo.values)===null||co===void 0?void 0:co.length)>0&&((uo=eo.actionMatcher)===null||uo===void 0||uo.register(ro.conditions.actions.values),(fo=ro.conditions)===null||fo===void 0||(po=fo.actions)===null||po===void 0||(ho=po.values)===null||ho===void 0||ho.forEach(function(_o){if(_o&&_o.name){var go=eo.actionToSurveys.get(_o.name);go&&go.push(ro.id),eo.actionToSurveys.set(_o.name,go||[ro.id])}}))}))}},{key:"setupEventBasedSurveys",value:function(ue){var eo,no=this;ue.filter(function(ro){var oo,io,ao,so;return((oo=ro.conditions)===null||oo===void 0?void 0:oo.events)&&((io=ro.conditions)===null||io===void 0||(ao=io.events)===null||ao===void 0||(so=ao.values)===null||so===void 0?void 0:so.length)>0}).length!==0&&((eo=this.instance)===null||eo===void 0||eo._addCaptureHook(function(ro,oo){no.onEvent(ro,oo)}),ue.forEach(function(ro){var oo,io,ao;(oo=ro.conditions)===null||oo===void 0||(io=oo.events)===null||io===void 0||(ao=io.values)===null||ao===void 0||ao.forEach(function(so){if(so&&so.name){var lo=no.eventToSurveys.get(so.name);lo&&lo.push(ro.id),no.eventToSurveys.set(so.name,lo||[ro.id])}})}))}},{key:"onEvent",value:function(ue,eo){var no,ro,oo=((no=this.instance)===null||no===void 0||(ro=no.persistence)===null||ro===void 0?void 0:ro.props[Te])||[];if(to.SURVEY_SHOWN_EVENT_NAME==ue&&eo&&oo.length>0){var io,ao=eo==null||(io=eo.properties)===null||io===void 0?void 0:io.$survey_id;if(ao){var so=oo.indexOf(ao);so>=0&&(oo.splice(so,1),this._updateActivatedSurveys(oo))}}else this.eventToSurveys.has(ue)&&this._updateActivatedSurveys(oo.concat(this.eventToSurveys.get(ue)||[]))}},{key:"onAction",value:function(ue){var eo,no,ro=((eo=this.instance)===null||eo===void 0||(no=eo.persistence)===null||no===void 0?void 0:no.props[Te])||[];this.actionToSurveys.has(ue)&&this._updateActivatedSurveys(ro.concat(this.actionToSurveys.get(ue)||[]))}},{key:"_updateActivatedSurveys",value:function(ue){var eo,no;(eo=this.instance)===null||eo===void 0||(no=eo.persistence)===null||no===void 0||no.register(o({},Te,l(new Set(ue))))}},{key:"getSurveys",value:function(){var ue,eo,no=(ue=this.instance)===null||ue===void 0||(eo=ue.persistence)===null||eo===void 0?void 0:eo.props[Te];return no||[]}},{key:"getEventToSurveys",value:function(){return this.eventToSurveys}},{key:"_getActionMatcher",value:function(){return this.actionMatcher}}]),to}();o(Ir,"SURVEY_SHOWN_EVENT_NAME","survey shown");var Rr="[Surveys]",Fr={icontains:function(to){return!!T&&T.location.href.toLowerCase().indexOf(to.toLowerCase())>-1},not_icontains:function(to){return!!T&&T.location.href.toLowerCase().indexOf(to.toLowerCase())===-1},regex:function(to){return!!T&>(T.location.href,to)},not_regex:function(to){return!!T&&!gt(T.location.href,to)},exact:function(to){return(T==null?void 0:T.location.href)===to},is_not:function(to){return(T==null?void 0:T.location.href)!==to}},xr=function(){function to(ue){i$1(this,to),this.instance=ue,this._surveyEventReceiver=null}return s(to,[{key:"afterDecideResponse",value:function(ue){this._decideServerResponse=!!ue.surveys,this.loadIfEnabled()}},{key:"loadIfEnabled",value:function(){var ue=this,eo=U==null?void 0:U.extendPostHogWithSurveys;this.instance.config.disable_surveys||!this._decideServerResponse||eo||(this._surveyEventReceiver==null&&(this._surveyEventReceiver=new Ir(this.instance)),this.instance.requestRouter.loadScript("/static/surveys.js",function(no){if(no)return G.error(Rr,"Could not load surveys script",no);ue._surveyManager=U.extendPostHogWithSurveys(ue.instance)}))}},{key:"getSurveys",value:function(ue){var eo=this,no=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(this.instance.config.disable_surveys)return ue([]);this._surveyEventReceiver==null&&(this._surveyEventReceiver=new Ir(this.instance));var ro=this.instance.get_property(Pe);if(ro&&!no)return ue(ro);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",transport:"XHR",callback:function(oo){var io;if(oo.statusCode!==200||!oo.json)return ue([]);var ao,so=oo.json.surveys||[],lo=so.filter(function(co){var uo,fo,po,ho,_o,go,bo,vo,yo,wo,ko,So;return((uo=co.conditions)===null||uo===void 0?void 0:uo.events)&&((fo=co.conditions)===null||fo===void 0||(po=fo.events)===null||po===void 0?void 0:po.values)&&((ho=co.conditions)===null||ho===void 0||(_o=ho.events)===null||_o===void 0||(go=_o.values)===null||go===void 0?void 0:go.length)>0||((bo=co.conditions)===null||bo===void 0?void 0:bo.actions)&&((vo=co.conditions)===null||vo===void 0||(yo=vo.actions)===null||yo===void 0?void 0:yo.values)&&((wo=co.conditions)===null||wo===void 0||(ko=wo.actions)===null||ko===void 0||(So=ko.values)===null||So===void 0?void 0:So.length)>0});return lo.length>0&&((ao=eo._surveyEventReceiver)===null||ao===void 0||ao.register(lo)),(io=eo.instance.persistence)===null||io===void 0||io.register(o({},Pe,so)),ue(so)}})}},{key:"getActiveMatchingSurveys",value:function(ue){var eo=this,no=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.getSurveys(function(ro){var oo,io=ro.filter(function(lo){return!(!lo.start_date||lo.end_date)}).filter(function(lo){var co,uo,fo,po;if(!lo.conditions)return!0;var ho=(co=lo.conditions)===null||co===void 0||!co.url||Fr[(uo=(fo=lo.conditions)===null||fo===void 0?void 0:fo.urlMatchType)!==null&&uo!==void 0?uo:"icontains"](lo.conditions.url),_o=(po=lo.conditions)===null||po===void 0||!po.selector||(L==null?void 0:L.querySelector(lo.conditions.selector));return ho&&_o}),ao=(oo=eo._surveyEventReceiver)===null||oo===void 0?void 0:oo.getSurveys(),so=io.filter(function(lo){var co,uo,fo,po,ho,_o,go,bo,vo,yo;if(!lo.linked_flag_key&&!lo.targeting_flag_key&&!lo.internal_targeting_flag_key)return!0;var wo=!lo.linked_flag_key||eo.instance.featureFlags.isFeatureEnabled(lo.linked_flag_key),ko=!lo.targeting_flag_key||eo.instance.featureFlags.isFeatureEnabled(lo.targeting_flag_key),So=((co=lo.conditions)===null||co===void 0?void 0:co.events)&&((uo=lo.conditions)===null||uo===void 0||(fo=uo.events)===null||fo===void 0?void 0:fo.values)&&((po=lo.conditions)===null||po===void 0||(ho=po.events)===null||ho===void 0?void 0:ho.values.length)>0,Eo=((_o=lo.conditions)===null||_o===void 0?void 0:_o.actions)&&((go=lo.conditions)===null||go===void 0||(bo=go.actions)===null||bo===void 0?void 0:bo.values)&&((vo=lo.conditions)===null||vo===void 0||(yo=vo.actions)===null||yo===void 0?void 0:yo.values.length)>0,Io=!So&&!Eo||(ao==null?void 0:ao.includes(lo.id)),Ao=eo._canActivateRepeatedly(lo),To=!(lo.internal_targeting_flag_key&&!Ao)||eo.instance.featureFlags.isFeatureEnabled(lo.internal_targeting_flag_key);return wo&&ko&&To&&Io});return ue(so)},no)}},{key:"getNextSurveyStep",value:function(ue,eo,no){var ro,oo=ue.questions[eo],io=eo+1;if((ro=oo.branching)===null||ro===void 0||!ro.type)return eo===ue.questions.length-1?br.End:io;if(oo.branching.type===br.End)return br.End;if(oo.branching.type===br.SpecificQuestion){if(Number.isInteger(oo.branching.index))return oo.branching.index}else if(oo.branching.type===br.ResponseBased){if(oo.type===yr.SingleChoice){var ao,so,lo=oo.choices.indexOf("".concat(no));if((ao=oo.branching)!==null&&ao!==void 0&&(so=ao.responseValues)!==null&&so!==void 0&&so.hasOwnProperty(lo)){var co=oo.branching.responseValues[lo];return Number.isInteger(co)?co:co===br.End?br.End:io}}else if(oo.type===yr.Rating){var uo,fo;if(typeof no!="number"||!Number.isInteger(no))throw new Error("The response type must be an integer");var po=function(_o,go){if(go===3){if(_o<1||_o>3)throw new Error("The response must be in range 1-3");return _o===1?"negative":_o===2?"neutral":"positive"}if(go===5){if(_o<1||_o>5)throw new Error("The response must be in range 1-5");return _o<=2?"negative":_o===3?"neutral":"positive"}if(go===10){if(_o<0||_o>10)throw new Error("The response must be in range 0-10");return _o<=6?"detractors":_o<=8?"passives":"promoters"}throw new Error("The scale must be one of: 3, 5, 10")}(no,oo.scale);if((uo=oo.branching)!==null&&uo!==void 0&&(fo=uo.responseValues)!==null&&fo!==void 0&&fo.hasOwnProperty(po)){var ho=oo.branching.responseValues[po];return Number.isInteger(ho)?ho:ho===br.End?br.End:io}}return io}return G.warn(Rr,"Falling back to next question index due to unexpected branching type"),io}},{key:"_canActivateRepeatedly",value:function(ue){return R(U.__PosthogExtensions__.canActivateRepeatedly)&&G.warn(Rr,"canActivateRepeatedly is not defined, must init before calling"),U.__PosthogExtensions__.canActivateRepeatedly(ue)}},{key:"canRenderSurvey",value:function(ue){var eo=this;R(this._surveyManager)?G.warn(Rr,"canActivateRepeatedly is not defined, must init before calling"):this.getSurveys(function(no){var ro=no.filter(function(oo){return oo.id===ue})[0];eo._surveyManager.canRenderSurvey(ro)})}},{key:"renderSurvey",value:function(ue,eo){var no=this;R(this._surveyManager)?G.warn(Rr,"canActivateRepeatedly is not defined, must init before calling"):this.getSurveys(function(ro){var oo=ro.filter(function(io){return io.id===ue})[0];no._surveyManager.renderSurvey(oo,L==null?void 0:L.querySelector(eo))})}}]),to}(),Pr=function(){function to(ue){var eo,no,ro=this;i$1(this,to),o(this,"serverLimits",{}),o(this,"lastEventRateLimited",!1),o(this,"checkForLimiting",function(oo){var io=oo.text;if(io&&io.length)try{(JSON.parse(io).quota_limited||[]).forEach(function(ao){G.info("[RateLimiter] ".concat(ao||"events"," is quota limited.")),ro.serverLimits[ao]=new Date().getTime()+6e4})}catch(ao){return void G.warn('[RateLimiter] could not rate limit - continuing. Error: "'.concat(ao==null?void 0:ao.message,'"'),{text:io})}}),this.instance=ue,this.captureEventsPerSecond=((eo=ue.config.rate_limiting)===null||eo===void 0?void 0:eo.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((no=ue.config.rate_limiting)===null||no===void 0?void 0:no.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}return s(to,[{key:"clientRateLimitContext",value:function(){var ue,eo,no,ro=arguments.length>0&&arguments[0]!==void 0&&arguments[0],oo=new Date().getTime(),io=(ue=(eo=this.instance.persistence)===null||eo===void 0?void 0:eo.get_property(Me))!==null&&ue!==void 0?ue:{tokens:this.captureEventsBurstLimit,last:oo};io.tokens+=(oo-io.last)/1e3*this.captureEventsPerSecond,io.last=oo,io.tokens>this.captureEventsBurstLimit&&(io.tokens=this.captureEventsBurstLimit);var ao=io.tokens<1;return ao||ro||(io.tokens=Math.max(0,io.tokens-1)),!ao||this.lastEventRateLimited||ro||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to ".concat(this.captureEventsPerSecond," events per second and ").concat(this.captureEventsBurstLimit," events burst limit.")},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=ao,(no=this.instance.persistence)===null||no===void 0||no.set_property(Me,io),{isRateLimited:ao,remainingTokens:io.tokens}}},{key:"isServerRateLimited",value:function(ue){var eo=this.serverLimits[ue||"events"]||!1;return eo!==!1&&new Date().getTime()<eo}}]),to}(),Tr=function(){return t$1({initialPathName:(D==null?void 0:D.pathname)||"",referringDomain:mn.referringDomain()},mn.campaignParams())},Cr=function(){function to(ue,eo,no){var ro=this;i$1(this,to),o(this,"_onSessionIdCallback",function(oo){var io=ro._getStoredProps();if(!io||io.sessionId!==oo){var ao={sessionId:oo,props:ro._sessionSourceParamGenerator()};ro._persistence.register(o({},Oe,ao))}}),this._sessionIdManager=ue,this._persistence=eo,this._sessionSourceParamGenerator=no||Tr,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}return s(to,[{key:"_getStoredProps",value:function(){return this._persistence.props[Oe]}},{key:"getSessionProps",value:function(){var ue,eo=(ue=this._getStoredProps())===null||ue===void 0?void 0:ue.props;return eo?{$client_session_initial_referring_host:eo.referringDomain,$client_session_initial_pathname:eo.initialPathName,$client_session_initial_utm_source:eo.utm_source,$client_session_initial_utm_campaign:eo.utm_campaign,$client_session_initial_utm_medium:eo.utm_medium,$client_session_initial_utm_content:eo.utm_content,$client_session_initial_utm_term:eo.utm_term}:{}}}]),to}(),$r=["ahrefsbot","ahrefssiteaudit","applebot","baiduspider","bingbot","bingpreview","bot.htm","bot.php","crawler","deepscan","duckduckbot","facebookexternal","facebookcatalog","gptbot","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","semrushbot","sitebulb","slurp","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","headlesschrome","cypress","Google-HotelAdsVerifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google","Bytespider;"],Or=function(to,ue){if(!to)return!1;var eo=to.toLowerCase();return $r.concat(ue||[]).some(function(no){var ro=no.toLowerCase();return eo.indexOf(ro)!==-1})},Mr=function(){function to(){i$1(this,to),this.clicks=[]}return s(to,[{key:"isRageClick",value:function(ue,eo,no){var ro=this.clicks[this.clicks.length-1];if(ro&&Math.abs(ue-ro.x)+Math.abs(eo-ro.y)<30&&no-ro.timestamp<1e3){if(this.clicks.push({x:ue,y:eo,timestamp:no}),this.clicks.length===3)return!0}else this.clicks=[{x:ue,y:eo,timestamp:no}];return!1}}]),to}();function Ar(to){var ue;return to.id===Ne||!((ue=to.closest)===null||ue===void 0||!ue.call(to,"#"+Ne))}var Lr=function(){function to(ue){var eo,no=this;i$1(this,to),o(this,"rageclicks",new Mr),o(this,"_enabledServerSide",!1),o(this,"_initialized",!1),o(this,"_flushInterval",null),this.instance=ue,this._enabledServerSide=!((eo=this.instance.persistence)===null||eo===void 0||!eo.props[fe]),T==null||T.addEventListener("beforeunload",function(){no.flush()})}return s(to,[{key:"flushIntervalMilliseconds",get:function(){var ue=5e3;return b(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(ue=this.instance.config.capture_heatmaps.flush_interval_milliseconds),ue}},{key:"isEnabled",get:function(){return w$1(this.instance.config.capture_heatmaps)?w$1(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}},{key:"startIfEnabled",value:function(){if(this.isEnabled){if(this._initialized)return;G.info("[heatmaps] starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var ue;clearInterval((ue=this._flushInterval)!==null&&ue!==void 0?ue:void 0),this.getAndClearBuffer()}}},{key:"afterDecideResponse",value:function(ue){var eo=!!ue.heatmaps;this.instance.persistence&&this.instance.persistence.register(o({},fe,eo)),this._enabledServerSide=eo,this.startIfEnabled()}},{key:"getAndClearBuffer",value:function(){var ue=this.buffer;return this.buffer=void 0,ue}},{key:"_setupListeners",value:function(){var ue=this;T&&L&&(oe(L,"click",function(eo){return ue._onClick(eo||(T==null?void 0:T.event))},!1,!0),oe(L,"mousemove",function(eo){return ue._onMouseMove(eo||(T==null?void 0:T.event))},!1,!0),this._initialized=!0)}},{key:"_getProperties",value:function(ue,eo){var no=this.instance.scrollManager.scrollY(),ro=this.instance.scrollManager.scrollX(),oo=this.instance.scrollManager.scrollElement(),io=function(ao,so,lo){for(var co=ao;co&&!On(co,"body");){if(co===lo)return!1;if(Y(so,T==null?void 0:T.getComputedStyle(co).position))return!0;co=Dn(co)}return!1}(ue.target,["fixed","sticky"],oo);return{x:ue.clientX+(io?0:ro),y:ue.clientY+(io?0:no),target_fixed:io,type:eo}}},{key:"_onClick",value:function(ue){var eo;if(!Ar(ue.target)){var no=this._getProperties(ue,"click");(eo=this.rageclicks)!==null&&eo!==void 0&&eo.isRageClick(ue.clientX,ue.clientY,new Date().getTime())&&this._capture(t$1(t$1({},no),{},{type:"rageclick"})),this._capture(no)}}},{key:"_onMouseMove",value:function(ue){var eo=this;Ar(ue.target)||(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout(function(){eo._capture(eo._getProperties(ue,"mousemove"))},500))}},{key:"_capture",value:function(ue){if(T){var eo=T.location.href;this.buffer=this.buffer||{},this.buffer[eo]||(this.buffer[eo]=[]),this.buffer[eo].push(ue)}}},{key:"flush",value:function(){this.buffer&&!k(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}]),to}(),Dr=function(){function to(ue){var eo=this;i$1(this,to),o(this,"_updateScrollData",function(){var no,ro,oo,io;eo.context||(eo.context={});var ao=eo.scrollElement(),so=eo.scrollY(),lo=ao?Math.max(0,ao.scrollHeight-ao.clientHeight):0,co=so+((ao==null?void 0:ao.clientHeight)||0),uo=(ao==null?void 0:ao.scrollHeight)||0;eo.context.lastScrollY=Math.ceil(so),eo.context.maxScrollY=Math.max(so,(no=eo.context.maxScrollY)!==null&&no!==void 0?no:0),eo.context.maxScrollHeight=Math.max(lo,(ro=eo.context.maxScrollHeight)!==null&&ro!==void 0?ro:0),eo.context.lastContentY=co,eo.context.maxContentY=Math.max(co,(oo=eo.context.maxContentY)!==null&&oo!==void 0?oo:0),eo.context.maxContentHeight=Math.max(uo,(io=eo.context.maxContentHeight)!==null&&io!==void 0?io:0)}),this.instance=ue}return s(to,[{key:"getContext",value:function(){return this.context}},{key:"resetContext",value:function(){var ue=this.context;return setTimeout(this._updateScrollData,0),ue}},{key:"startMeasuringScrollPosition",value:function(){T==null||T.addEventListener("scroll",this._updateScrollData,!0),T==null||T.addEventListener("scrollend",this._updateScrollData,!0),T==null||T.addEventListener("resize",this._updateScrollData)}},{key:"scrollElement",value:function(){if(!this.instance.config.scroll_root_selector)return T==null?void 0:T.document.documentElement;var ue,eo=h(m(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector]);try{for(eo.s();!(ue=eo.n()).done;){var no=ue.value,ro=T==null?void 0:T.document.querySelector(no);if(ro)return ro}}catch(oo){eo.e(oo)}finally{eo.f()}}},{key:"scrollY",value:function(){if(this.instance.config.scroll_root_selector){var ue=this.scrollElement();return ue&&ue.scrollTop||0}return T&&(T.scrollY||T.pageYOffset||T.document.documentElement.scrollTop)||0}},{key:"scrollX",value:function(){if(this.instance.config.scroll_root_selector){var ue=this.scrollElement();return ue&&ue.scrollLeft||0}return T&&(T.scrollX||T.pageXOffset||T.document.documentElement.scrollLeft)||0}}]),to}(),qr="$copy_autocapture";function Nr(to,ue){return ue.length>to?ue.slice(0,to)+"...":ue}var Br,Hr=function(){function to(ue){i$1(this,to),o(this,"_initialized",!1),o(this,"_isDisabledServerSide",null),o(this,"rageclicks",new Mr),o(this,"_elementsChainAsString",!1),this.instance=ue,this._elementSelectors=null}return s(to,[{key:"config",get:function(){var ue,eo,no=b(this.instance.config.autocapture)?this.instance.config.autocapture:{};return no.url_allowlist=(ue=no.url_allowlist)===null||ue===void 0?void 0:ue.map(function(ro){return new RegExp(ro)}),no.url_ignorelist=(eo=no.url_ignorelist)===null||eo===void 0?void 0:eo.map(function(ro){return new RegExp(ro)}),no}},{key:"_addDomEventHandlers",value:function(){var ue=this;if(this.isBrowserSupported()){if(T&&L){var eo=function(ro){ro=ro||(T==null?void 0:T.event);try{ue._captureEvent(ro)}catch(oo){G.error("Failed to capture event",oo)}},no=function(ro){ro=ro||(T==null?void 0:T.event),ue._captureEvent(ro,qr)};oe(L,"submit",eo,!1,!0),oe(L,"change",eo,!1,!0),oe(L,"click",eo,!1,!0),this.config.capture_copied_text&&(oe(L,"copy",no,!1,!0),oe(L,"cut",no,!1,!0))}}else G.info("Disabling Automatic Event Collection because this browser is not supported")}},{key:"startIfEnabled",value:function(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}},{key:"afterDecideResponse",value:function(ue){ue.elementsChainAsString&&(this._elementsChainAsString=ue.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register(o({},he,!!ue.autocapture_opt_out)),this._isDisabledServerSide=!!ue.autocapture_opt_out,this.startIfEnabled()}},{key:"setElementSelectors",value:function(ue){this._elementSelectors=ue}},{key:"getElementSelectors",value:function(ue){var eo,no=[];return(eo=this._elementSelectors)===null||eo===void 0||eo.forEach(function(ro){var oo=L==null?void 0:L.querySelectorAll(ro);oo==null||oo.forEach(function(io){ue===io&&no.push(ro)})}),no}},{key:"isEnabled",get:function(){var ue,eo,no=(ue=this.instance.persistence)===null||ue===void 0?void 0:ue.props[he],ro=this._isDisabledServerSide;if(I(ro)&&!x$1(no)&&!this.instance.config.advanced_disable_decide)return!1;var oo=(eo=this._isDisabledServerSide)!==null&&eo!==void 0?eo:!!no;return!!this.instance.config.autocapture&&!oo}},{key:"_previousElementSibling",value:function(ue){if(ue.previousElementSibling)return ue.previousElementSibling;var eo=ue;do eo=eo.previousSibling;while(eo&&!$n(eo));return eo}},{key:"_getAugmentPropertiesFromElement",value:function(ue){if(!Nn(ue))return{};var eo={};return Q(ue.attributes,function(no){if(no.name&&no.name.indexOf("data-ph-capture-attribute")===0){var ro=no.name.replace("data-ph-capture-attribute-",""),oo=no.value;ro&&oo&&zn(oo)&&(eo[ro]=oo)}}),eo}},{key:"_getPropertiesFromElement",value:function(ue,eo,no){var ro,oo=ue.tagName.toLowerCase(),io={tag_name:oo};Ln.indexOf(oo)>-1&&!no&&(oo.toLowerCase()==="a"||oo.toLowerCase()==="button"?io.$el_text=Nr(1024,Qn(ue)):io.$el_text=Nr(1024,Cn(ue)));var ao=Pn(ue);ao.length>0&&(io.classes=ao.filter(function(fo){return fo!==""}));var so=(ro=this.config)===null||ro===void 0?void 0:ro.element_attribute_ignorelist;Q(ue.attributes,function(fo){var po;if((!Bn(ue)||["name","id","class","aria-label"].indexOf(fo.name)!==-1)&&(so==null||!so.includes(fo.name))&&!eo&&zn(fo.value)&&(po=fo.name,!S(po)||po.substring(0,10)!=="_ngcontent"&&po.substring(0,7)!=="_nghost")){var ho=fo.value;fo.name==="class"&&(ho=Fn(ho).join(" ")),io["attr__"+fo.name]=Nr(1024,ho)}});for(var lo=1,co=1,uo=ue;uo=this._previousElementSibling(uo);)lo++,uo.tagName===ue.tagName&&co++;return io.nth_child=lo,io.nth_of_type=co,io}},{key:"_getDefaultProperties",value:function(ue){return{$event_type:ue,$ce_version:1}}},{key:"_getEventTarget",value:function(ue){return w$1(ue.target)?ue.srcElement||null:(eo=ue.target)!==null&&eo!==void 0&&eo.shadowRoot?ue.composedPath()[0]||null:ue.target||null;var eo}},{key:"_captureEvent",value:function(ue){var eo=this,no=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"$autocapture";if(this.isEnabled){var ro,oo=this._getEventTarget(ue);Mn(oo)&&(oo=oo.parentNode||null),no==="$autocapture"&&ue.type==="click"&&ue instanceof MouseEvent&&this.instance.config.rageclick&&(ro=this.rageclicks)!==null&&ro!==void 0&&ro.isRageClick(ue.clientX,ue.clientY,new Date().getTime())&&this._captureEvent(ue,"$rageclick");var io=no===qr;if(oo&&qn(oo,ue,this.config,io,io?["copy","cut"]:void 0)){for(var ao,so,lo=[oo],co=oo;co.parentNode&&!On(co,"body");)An(co.parentNode)?(lo.push(co.parentNode.host),co=co.parentNode.host):(lo.push(co.parentNode),co=co.parentNode);var uo,fo,po=[],ho={},_o=!1;if(Q(lo,function(Ao){var To=Nn(Ao);Ao.tagName.toLowerCase()==="a"&&(uo=Ao.getAttribute("href"),uo=To&&zn(uo)&&uo),Y(Pn(Ao),"ph-no-capture")&&(_o=!0),po.push(eo._getPropertiesFromElement(Ao,eo.instance.config.mask_all_element_attributes,eo.instance.config.mask_all_text));var zo=eo._getAugmentPropertiesFromElement(Ao);J(ho,zo)}),this.instance.config.mask_all_text||(oo.tagName.toLowerCase()==="a"||oo.tagName.toLowerCase()==="button"?po[0].$el_text=Qn(oo):po[0].$el_text=Cn(oo)),uo){var go,bo;po[0].attr__href=uo;var vo=(go=pt(uo))===null||go===void 0?void 0:go.host,yo=T==null||(bo=T.location)===null||bo===void 0?void 0:bo.host;vo&&yo&&vo!==yo&&(fo=uo)}if(_o)return!1;var wo=J(this._getDefaultProperties(ue.type),this._elementsChainAsString?{$elements_chain:Yn(po)}:{$elements:po},(ao=po[0])!==null&&ao!==void 0&&ao.$el_text?{$el_text:(so=po[0])===null||so===void 0?void 0:so.$el_text}:{},fo&&ue.type==="click"?{$external_click_url:fo}:{},ho),ko=this.getElementSelectors(oo);if(ko&&ko.length>0&&(wo.$element_selectors=ko),no===qr){var So,Eo=Tn(T==null||(So=T.getSelection())===null||So===void 0?void 0:So.toString()),Io=ue.type||"clipboard";if(!Eo)return!1;wo.$selected_content=Eo,wo.$copy_type=Io}return this.instance.capture(no,wo),!0}}}},{key:"isBrowserSupported",value:function(){return y(L==null?void 0:L.querySelectorAll)}}]),to}(),Ur=function(){function to(ue){var eo=this;i$1(this,to),o(this,"_restoreXHRPatch",void 0),o(this,"_restoreFetchPatch",void 0),o(this,"_startCapturing",function(){w$1(eo._restoreXHRPatch)&&U.postHogTracingHeadersPatchFns._patchXHR(eo.instance.sessionManager),w$1(eo._restoreFetchPatch)&&U.postHogTracingHeadersPatchFns._patchFetch(eo.instance.sessionManager)}),this.instance=ue}return s(to,[{key:"_loadScript",value:function(ue){U.postHogTracingHeadersPatchFns&&ue(),this.instance.requestRouter.loadScript("/static/tracing-headers.js?v=".concat(f.LIB_VERSION),function(eo){if(eo)return G.error("[TRACING-HEADERS] failed to load script",eo);ue()})}},{key:"startIfEnabledOrStop",value:function(){var ue,eo;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):((ue=this._restoreXHRPatch)===null||ue===void 0||ue.call(this),(eo=this._restoreFetchPatch)===null||eo===void 0||eo.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}]),to}();(function(to){to[to.PENDING=-1]="PENDING",to[to.DENIED=0]="DENIED",to[to.GRANTED=1]="GRANTED"})(Br||(Br={}));var jr=function(){function to(ue){i$1(this,to),this.instance=ue}return s(to,[{key:"config",get:function(){return this.instance.config}},{key:"consent",get:function(){return this.getDnt()?Br.DENIED:this.storedConsent}},{key:"isOptedOut",value:function(){return this.consent===Br.DENIED||this.consent===Br.PENDING&&this.config.opt_out_capturing_by_default}},{key:"isOptedIn",value:function(){return!this.isOptedOut()}},{key:"optInOut",value:function(ue){this.storage.set(this.storageKey,ue?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}},{key:"reset",value:function(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}},{key:"storageKey",get:function(){var ue=this.instance.config,eo=ue.token;return(ue.opt_out_capturing_cookie_prefix||"__ph_opt_in_out_")+eo}},{key:"storedConsent",get:function(){var ue=this.storage.get(this.storageKey);return ue==="1"?Br.GRANTED:ue==="0"?Br.DENIED:Br.PENDING}},{key:"storage",get:function(){if(!this._storage){var ue=this.config.opt_out_capturing_persistence_type;this._storage=ue==="localStorage"?at:st;var eo=ue==="localStorage"?st:at;eo.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut(eo.get(this.storageKey)==="1"),eo.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}},{key:"getDnt",value:function(){return!!this.config.respect_dnt&&!!ae([A==null?void 0:A.doNotTrack,A==null?void 0:A.msDoNotTrack,U.doNotTrack],function(ue){return Y([!0,1,"1","yes"],ue)})}}]),to}(),Gr="[Exception Autocapture]",Wr=function(){function to(ue){var eo,no=this;i$1(this,to),o(this,"originalOnUnhandledRejectionHandler",void 0),o(this,"startCapturing",function(){if(T&&no.isEnabled&&!no.hasHandlers&&!no.isCapturing){var ro=T.posthogErrorWrappingFunctions.wrapOnError,oo=T.posthogErrorWrappingFunctions.wrapUnhandledRejection;if(ro&&oo)try{no.unwrapOnError=ro(no.captureException.bind(no)),no.unwrapUnhandledRejection=oo(no.captureException.bind(no))}catch(io){G.error(Gr+" failed to start",io),no.stopCapturing()}else G.error(Gr+" failed to load error wrapping functions - cannot start")}}),this.instance=ue,this.remoteEnabled=!((eo=this.instance.persistence)===null||eo===void 0||!eo.props[ve]),this.startIfEnabled()}return s(to,[{key:"isEnabled",get:function(){var ue;return(ue=this.remoteEnabled)!==null&&ue!==void 0&&ue}},{key:"isCapturing",get:function(){var ue;return!(T==null||(ue=T.onerror)===null||ue===void 0||!ue.__POSTHOG_INSTRUMENTED__)}},{key:"hasHandlers",get:function(){return this.originalOnUnhandledRejectionHandler||this.unwrapOnError}},{key:"startIfEnabled",value:function(){this.isEnabled&&!this.isCapturing&&(G.info(Gr+" enabled, starting..."),this.loadScript(this.startCapturing))}},{key:"loadScript",value:function(ue){this.hasHandlers&&ue(),this.instance.requestRouter.loadScript("/static/exception-autocapture.js?v=".concat(f.LIB_VERSION),function(eo){if(eo)return G.error(Gr+" failed to load script",eo);ue()})}},{key:"stopCapturing",value:function(){var ue,eo;(ue=this.unwrapOnError)===null||ue===void 0||ue.call(this),(eo=this.unwrapUnhandledRejection)===null||eo===void 0||eo.call(this)}},{key:"afterDecideResponse",value:function(ue){var eo=ue.autocaptureExceptions;this.remoteEnabled=!!eo||!1,this.instance.persistence&&this.instance.persistence.register(o({},ve,this.remoteEnabled)),this.startIfEnabled()}},{key:"captureException",value:function(ue){var eo=this.instance.requestRouter.endpointFor("ui");ue.$exception_personURL="".concat(eo,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(ue)}}]),to}(),Vr=9e5,zr="[Web Vitals]",Qr=function(){function to(ue){var eo,no=this;i$1(this,to),o(this,"_enabledServerSide",!1),o(this,"_initialized",!1),o(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),o(this,"_flushToCapture",function(){clearTimeout(no._delayedFlushTimer),no.buffer.metrics.length!==0&&(no.instance.capture("$web_vitals",no.buffer.metrics.reduce(function(ro,oo){var io;return t$1(t$1({},ro),{},(o(io={},"$web_vitals_".concat(oo.name,"_event"),t$1({},oo)),o(io,"$web_vitals_".concat(oo.name,"_value"),oo.value),io))},{})),no.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),o(this,"_addToBuffer",function(ro){var oo,io=(oo=no.instance.sessionManager)===null||oo===void 0?void 0:oo.checkAndGetSessionAndWindowId(!0);if(w$1(io))G.error(zr+"Could not read session ID. Dropping metrics!");else{no.buffer=no.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var ao=no._currentURL();w$1(ao)||(R(ro==null?void 0:ro.name)||R(ro==null?void 0:ro.value)?G.error(zr+"Invalid metric received",ro):no._maxAllowedValue&&ro.value>=no._maxAllowedValue?G.error(zr+"Ignoring metric with value >= "+no._maxAllowedValue,ro):(no.buffer.url!==ao&&(no._flushToCapture(),no._delayedFlushTimer=setTimeout(no._flushToCapture,8e3)),w$1(no.buffer.url)&&(no.buffer.url=ao),no.buffer.firstMetricTimestamp=w$1(no.buffer.firstMetricTimestamp)?Date.now():no.buffer.firstMetricTimestamp,no.buffer.metrics.push(t$1(t$1({},ro),{},{$current_url:ao,$session_id:io.sessionId,$window_id:io.windowId,timestamp:Date.now()})),no.buffer.metrics.length===4&&no._flushToCapture()))}}),o(this,"_startCapturing",function(){var ro=U.postHogWebVitalsCallbacks,oo=ro.onLCP,io=ro.onCLS,ao=ro.onFCP,so=ro.onINP;oo&&io&&ao&&so?(oo(no._addToBuffer),io(no._addToBuffer),ao(no._addToBuffer),so(no._addToBuffer),no._initialized=!0):G.error(zr+"web vitals callbacks not loaded - not starting")}),this.instance=ue,this._enabledServerSide=!((eo=this.instance.persistence)===null||eo===void 0||!eo.props[ge]),this.startIfEnabled()}return s(to,[{key:"_maxAllowedValue",get:function(){var ue=b(this.instance.config.capture_performance)&&F(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:Vr;return 0<ue&&ue<=6e4?Vr:ue}},{key:"isEnabled",get:function(){var ue=b(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return x$1(ue)?ue:this._enabledServerSide}},{key:"startIfEnabled",value:function(){this.isEnabled&&!this._initialized&&(G.info(zr+" enabled, starting..."),this.loadScript(this._startCapturing))}},{key:"afterDecideResponse",value:function(ue){var eo=b(ue.capturePerformance)&&!!ue.capturePerformance.web_vitals;this.instance.persistence&&this.instance.persistence.register(o({},ge,eo)),this._enabledServerSide=eo,this.startIfEnabled()}},{key:"loadScript",value:function(ue){T.postHogWebVitalsCallbacks&&ue(),this.instance.requestRouter.loadScript("/static/web-vitals.js?v=".concat(f.LIB_VERSION),function(eo){eo?G.error(zr+" failed to load script",eo):ue()})}},{key:"_currentURL",value:function(){var ue=T?T.location.href:void 0;return ue||G.error(zr+"Could not determine current URL"),ue}}]),to}(),Jr="/e/",Yr=function(){function to(ue){var eo;i$1(this,to),this.instance=ue,this._endpointSuffix=((eo=this.instance.persistence)===null||eo===void 0?void 0:eo.props[pe])||Jr}return s(to,[{key:"endpoint",get:function(){return this.instance.requestRouter.endpointFor("api",this._endpointSuffix)}},{key:"afterDecideResponse",value:function(ue){var eo=ue.autocaptureExceptions;this._endpointSuffix=b(eo)&&eo.endpoint||Jr,this.instance.persistence&&this.instance.persistence.register(o({},pe,this._endpointSuffix))}},{key:"sendExceptionEvent",value:function(ue){this.instance.capture("$exception",ue,{_noTruncate:!0,_batchKey:"exceptionEvent",_url:this.endpoint})}}]),to}(),Xr={},Kr=function(){},Zr="posthog",es=!tr&&(H==null?void 0:H.indexOf("MSIE"))===-1&&(H==null?void 0:H.indexOf("Mozilla"))===-1,ts=function(){var to,ue,eo;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:(ue=L==null?void 0:L.location,eo=ue==null?void 0:ue.hostname,!!S(eo)&&eo.split(".").slice(-2).join(".")!=="herokuapp.com"),persistence:"localStorage+cookie",persistence_name:"",loaded:Kr,store_google:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:D&&S(D==null?void 0:D.search)&&D.search.indexOf("__posthog_debug=true")!==-1||!1,verbose:!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_surveys:!1,enable_recording_console_log:void 0,secure_cookie:(T==null||(to=T.location)===null||to===void 0?void 0:to.protocol)==="https:",ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},inapp_protocol:"//",inapp_link_new_window:!1,request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,on_request_error:function(no){var ro="Bad HTTP status: "+no.statusCode+" "+no.text;G.error(ro)},get_device_id:function(no){return no},_onCapture:Kr,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"always",__add_tracing_headers:!1}},ns=function(to){var ue={};w$1(to.process_person)||(ue.person_profiles=to.process_person),w$1(to.xhr_headers)||(ue.request_headers=to.xhr_headers),w$1(to.cookie_name)||(ue.persistence_name=to.cookie_name),w$1(to.disable_cookie)||(ue.disable_persistence=to.disable_cookie);var eo=J({},ue,to);return m(to.property_blacklist)&&(w$1(to.property_denylist)?eo.property_denylist=to.property_blacklist:m(to.property_denylist)?eo.property_denylist=[].concat(l(to.property_blacklist),l(to.property_denylist)):G.error("Invalid value for property_denylist config: "+to.property_denylist)),eo},is=function(){function to(){i$1(this,to),o(this,"__forceAllowLocalhost",!1)}return s(to,[{key:"_forceAllowLocalhost",get:function(){return this.__forceAllowLocalhost},set:function(ue){G.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=ue}}]),to}(),rs=function(){function to(){var ue=this;i$1(this,to),o(this,"webPerformance",new is),o(this,"version",f.LIB_VERSION),o(this,"_internalEventEmitter",new Sr),this.config=ts(),this.decideEndpointWasHit=!1,this.SentryIntegration=gr,this.sentryIntegration=function(eo){return function(no,ro){var oo=pr(no,ro);return{name:vr,processEvent:function(io){return oo(io)}}}(ue,eo)},this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this.featureFlags=new We(this),this.toolbar=new mi(this),this.scrollManager=new Dr(this),this.pageViewManager=new kr(this),this.surveys=new xr(this),this.exceptions=new Yr(this),this.rateLimiter=new Pr(this),this.requestRouter=new fr(this),this.consent=new jr(this),this.people={set:function(eo,no,ro){var oo=S(eo)?o({},eo,no):eo;ue.setPersonProperties(oo),ro==null||ro({})},set_once:function(eo,no,ro){var oo=S(eo)?o({},eo,no):eo;ue.setPersonProperties(void 0,oo),ro==null||ro({})}},this.on("eventCaptured",function(eo){return G.info("send",eo)})}return s(to,[{key:"init",value:function(ue,eo,no){if(no&&no!==Zr){var ro,oo=(ro=Xr[no])!==null&&ro!==void 0?ro:new to;return oo._init(ue,eo,no),Xr[no]=oo,Xr[Zr][no]=oo,oo}return this._init(ue,eo,no)}},{key:"_init",value:function(ue){var eo,no,ro=this,oo=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},io=arguments.length>2?arguments[2]:void 0;if(w$1(ue)||E(ue))return G.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 G.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],this.set_config(J({},ts(),ns(oo),{name:io,token:ue})),this.config.on_xhr_error&&G.error("[posthog] on_xhr_error is deprecated. Use on_request_error instead"),this.compression=oo.disable_compression?void 0:re.GZipJS,this.persistence=new bn(this.config),this.sessionPersistence=this.config.persistence==="sessionStorage"?this.persistence:new bn(t$1(t$1({},this.config),{},{persistence:"sessionStorage"}));var ao=t$1({},this.persistence.props),so=t$1({},this.sessionPersistence.props);if(this._requestQueue=new yi(function(vo){return ro._send_retriable_request(vo)}),this._retryQueue=new lr(this),this.__request_queue=[],this.sessionManager=new dr(this.config,this.persistence),this.sessionPropsManager=new Cr(this.sessionManager,this.persistence),new Ur(this).startIfEnabledOrStop(),this.sessionRecording=new vi(this),this.sessionRecording.startIfEnabledOrStop(),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new Hr(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new Lr(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Qr(this),this.exceptionObserver=new Wr(this),this.exceptionObserver.startIfEnabled(),f.DEBUG=f.DEBUG||this.config.debug,f.DEBUG&&G.info("Starting in debug mode",{this:this,config:oo,thisC:t$1({},this.config),p:ao,s:so}),this._sync_opt_out_with_persistence(),((eo=oo.bootstrap)===null||eo===void 0?void 0:eo.distinctID)!==void 0){var lo,co,uo=this.config.get_device_id(Ke()),fo=(lo=oo.bootstrap)!==null&&lo!==void 0&&lo.isIdentifiedID?uo:oo.bootstrap.distinctID;this.persistence.set_property($e,(co=oo.bootstrap)!==null&&co!==void 0&&co.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:oo.bootstrap.distinctID,$device_id:fo})}if(this._hasBootstrappedFeatureFlags()){var po,ho,_o=Object.keys(((po=oo.bootstrap)===null||po===void 0?void 0:po.featureFlags)||{}).filter(function(vo){var yo,wo;return!((yo=oo.bootstrap)===null||yo===void 0||(wo=yo.featureFlags)===null||wo===void 0||!wo[vo])}).reduce(function(vo,yo){var wo,ko;return vo[yo]=((wo=oo.bootstrap)===null||wo===void 0||(ko=wo.featureFlags)===null||ko===void 0?void 0:ko[yo])||!1,vo},{}),go=Object.keys(((ho=oo.bootstrap)===null||ho===void 0?void 0:ho.featureFlagPayloads)||{}).filter(function(vo){return _o[vo]}).reduce(function(vo,yo){var wo,ko,So,Eo;return(wo=oo.bootstrap)!==null&&wo!==void 0&&(ko=wo.featureFlagPayloads)!==null&&ko!==void 0&&ko[yo]&&(vo[yo]=(So=oo.bootstrap)===null||So===void 0||(Eo=So.featureFlagPayloads)===null||Eo===void 0?void 0:Eo[yo]),vo},{});this.featureFlags.receivedFeatureFlags({featureFlags:_o,featureFlagPayloads:go})}if(!this.get_distinct_id()){var bo=this.config.get_device_id(Ke());this.register_once({distinct_id:bo,$device_id:bo},""),this.persistence.set_property($e,"anonymous")}return T==null||(no=T.addEventListener)===null||no===void 0||no.call(T,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this)),this.toolbar.maybeLoadToolbar(),oo.segment?_r(this,function(){return ro._loaded()}):this._loaded(),y(this.config._onCapture)&&this.on("eventCaptured",function(vo){return ro.config._onCapture(vo.event,vo)}),this}},{key:"_afterDecideResponse",value:function(ue){var eo,no,ro,oo,io,ao,so,lo;this.compression=void 0,ue.supportedCompression&&!this.config.disable_compression&&(this.compression=Y(ue.supportedCompression,re.GZipJS)?re.GZipJS:Y(ue.supportedCompression,re.Base64)?re.Base64:void 0),(eo=ue.analytics)!==null&&eo!==void 0&&eo.endpoint&&(this.analyticsDefaultEndpoint=ue.analytics.endpoint),(no=this.sessionRecording)===null||no===void 0||no.afterDecideResponse(ue),(ro=this.autocapture)===null||ro===void 0||ro.afterDecideResponse(ue),(oo=this.heatmaps)===null||oo===void 0||oo.afterDecideResponse(ue),(io=this.surveys)===null||io===void 0||io.afterDecideResponse(ue),(ao=this.webVitalsAutocapture)===null||ao===void 0||ao.afterDecideResponse(ue),(so=this.exceptions)===null||so===void 0||so.afterDecideResponse(ue),(lo=this.exceptionObserver)===null||lo===void 0||lo.afterDecideResponse(ue)}},{key:"_loaded",value:function(){var ue=this,eo=this.config.advanced_disable_decide;eo||this.featureFlags.setReloadingPaused(!0);try{this.config.loaded(this)}catch(no){G.critical("`loaded` function failed",no)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout(function(){ue.consent.isOptedIn()&&ue._captureInitialPageview()},1),eo||(new pi(this).call(),this.featureFlags.resetRequestQueue())}},{key:"_start_queue_if_opted_in",value:function(){var ue;this.has_opted_out_capturing()||this.config.request_batching&&((ue=this._requestQueue)===null||ue===void 0||ue.enable())}},{key:"_dom_loaded",value:function(){var ue=this;this.has_opted_out_capturing()||z(this.__request_queue,function(eo){return ue._send_retriable_request(eo)}),this.__request_queue=[],this._start_queue_if_opted_in()}},{key:"_handle_unload",value:function(){var ue,eo;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),(ue=this._requestQueue)===null||ue===void 0||ue.unload(),(eo=this._retryQueue)===null||eo===void 0||eo.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}},{key:"_send_request",value:function(ue){var eo=this;this.__loaded&&(es?this.__request_queue.push(ue):this.rateLimiter.isServerRateLimited(ue.batchKey)||(ue.transport=ue.transport||this.config.api_transport,ue.url=ir(ue.url,{ip:this.config.ip?1:0}),ue.headers=t$1({},this.config.request_headers),ue.compression=ue.compression==="best-available"?this.compression:ue.compression,function(no){var ro,oo,io,ao=t$1({},no);ao.timeout=ao.timeout||6e4,ao.url=ir(ao.url,{_:new Date().getTime().toString(),ver:f.LIB_VERSION,compression:ao.compression});var so=(ro=ao.transport)!==null&&ro!==void 0?ro:"XHR",lo=(oo=(io=ae(or,function(co){return co.transport===so}))===null||io===void 0?void 0:io.method)!==null&&oo!==void 0?oo:or[0].method;if(!lo)throw new Error("No available transport method");lo(ao)}(t$1(t$1({},ue),{},{callback:function(no){var ro,oo,io;eo.rateLimiter.checkForLimiting(no),no.statusCode>=400&&((oo=(io=eo.config).on_request_error)===null||oo===void 0||oo.call(io,no)),(ro=ue.callback)===null||ro===void 0||ro.call(ue,no)}}))))}},{key:"_send_retriable_request",value:function(ue){this._retryQueue?this._retryQueue.retriableRequest(ue):this._send_request(ue)}},{key:"_execute_array",value:function(ue){var eo,no=this,ro=[],oo=[],io=[];z(ue,function(so){so&&(eo=so[0],m(eo)?io.push(so):y(so)?so.call(no):m(so)&&eo==="alias"?ro.push(so):m(so)&&eo.indexOf("capture")!==-1&&y(no[eo])?io.push(so):oo.push(so))});var ao=function(so,lo){z(so,function(co){if(m(co[0])){var uo=lo;Q(co,function(fo){uo=uo[fo[0]].apply(uo,fo.slice(1))})}else this[co[0]].apply(this,co.slice(1))},lo)};ao(ro,this),ao(oo,this),ao(io,this)}},{key:"_hasBootstrappedFeatureFlags",value:function(){var ue,eo;return((ue=this.config.bootstrap)===null||ue===void 0?void 0:ue.featureFlags)&&Object.keys((eo=this.config.bootstrap)===null||eo===void 0?void 0:eo.featureFlags).length>0||!1}},{key:"push",value:function(ue){this._execute_array([ue])}},{key:"capture",value:function(ue,eo,no){var ro;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!w$1(ue)&&S(ue)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var oo=no!=null&&no.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(oo==null||!oo.isRateLimited){this.sessionPersistence.update_search_keyword(),this.config.store_google&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.store_google||this.config.save_referrer)&&this.persistence.set_initial_person_info();var io=new Date,ao=(no==null?void 0:no.timestamp)||io,so={uuid:Ke(),event:ue,properties:this._calculate_event_properties(ue,eo||{},ao)};oo&&(so.properties.$lib_rate_limit_remaining_tokens=oo.remainingTokens),no!=null&&no.$set&&(so.$set=no==null?void 0:no.$set);var lo=this._calculate_set_once_properties(no==null?void 0:no.$set_once);lo&&(so.$set_once=lo),(so=ie$2(so,no!=null&&no._noTruncate?null:this.config.properties_string_max_length)).timestamp=ao,w$1(no==null?void 0:no.timestamp)||(so.properties.$event_time_override_provided=!0,so.properties.$event_time_override_system_time=io);var co=t$1(t$1({},so.properties.$set),so.$set);k(co)||this.setPersonPropertiesForFlags(co),this._internalEventEmitter.emit("eventCaptured",so);var uo={method:"POST",url:(ro=no==null?void 0:no._url)!==null&&ro!==void 0?ro:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:so,compression:"best-available",batchKey:no==null?void 0:no._batchKey};return!this.config.request_batching||no&&(no==null||!no._batchKey)||no!=null&&no.send_instantly?this._send_retriable_request(uo):this._requestQueue.enqueue(uo),so}G.critical("This capture call is ignored due to client rate limiting.")}}else G.error("No event name provided to posthog.capture")}else G.uninitializedWarning("posthog.capture")}},{key:"_addCaptureHook",value:function(ue){this.on("eventCaptured",function(eo){return ue(eo.event,eo)})}},{key:"_calculate_event_properties",value:function(ue,eo,no){if(no=no||new Date,!this.persistence||!this.sessionPersistence)return eo;var ro=this.persistence.remove_event_timer(ue),oo=t$1({},eo);if(oo.token=this.config.token,ue==="$snapshot"){var io=t$1(t$1({},this.persistence.properties()),this.sessionPersistence.properties());return oo.distinct_id=io.distinct_id,(!S(oo.distinct_id)&&!F(oo.distinct_id)||E(oo.distinct_id))&&G.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),oo}var ao=mn.properties();if(this.sessionManager){var so=this.sessionManager.checkAndGetSessionAndWindowId(),lo=so.sessionId,co=so.windowId;oo.$session_id=lo,oo.$window_id=co}if(this.requestRouter.region===ur.CUSTOM&&(oo.$lib_custom_api_host=this.config.api_host),this.sessionPropsManager&&this.config.__preview_send_client_session_params&&(ue==="$pageview"||ue==="$pageleave"||ue==="$autocapture")){var uo=this.sessionPropsManager.getSessionProps();oo=J(oo,uo)}if(!this.config.disable_scroll_properties){var fo={};ue==="$pageview"?fo=this.pageViewManager.doPageView(no):ue==="$pageleave"&&(fo=this.pageViewManager.doPageLeave(no)),oo=J(oo,fo)}if(ue==="$pageview"&&L&&(oo.title=L.title),!w$1(ro)){var po=no.getTime()-ro;oo.$duration=parseFloat((po/1e3).toFixed(3))}H&&this.config.opt_out_useragent_filter&&(oo.$browser_type=this._is_bot()?"bot":"browser"),(oo=J({},ao,this.persistence.properties(),this.sessionPersistence.properties(),oo)).$is_identified=this._isIdentified(),m(this.config.property_denylist)?Q(this.config.property_denylist,function(_o){delete oo[_o]}):G.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var ho=this.config.sanitize_properties;return ho&&(oo=ho(oo,ue)),oo.$process_person_profile=this._hasPersonProcessing(),oo}},{key:"_calculate_set_once_properties",value:function(ue){if(!this.persistence||!this._hasPersonProcessing())return ue;var eo=J({},this.persistence.get_initial_props(),ue||{});return k(eo)?void 0:eo}},{key:"register",value:function(ue,eo){var no;(no=this.persistence)===null||no===void 0||no.register(ue,eo)}},{key:"register_once",value:function(ue,eo,no){var ro;(ro=this.persistence)===null||ro===void 0||ro.register_once(ue,eo,no)}},{key:"register_for_session",value:function(ue){var eo;(eo=this.sessionPersistence)===null||eo===void 0||eo.register(ue)}},{key:"unregister",value:function(ue){var eo;(eo=this.persistence)===null||eo===void 0||eo.unregister(ue)}},{key:"unregister_for_session",value:function(ue){var eo;(eo=this.sessionPersistence)===null||eo===void 0||eo.unregister(ue)}},{key:"_register_single",value:function(ue,eo){this.register(o({},ue,eo))}},{key:"getFeatureFlag",value:function(ue,eo){return this.featureFlags.getFeatureFlag(ue,eo)}},{key:"getFeatureFlagPayload",value:function(ue){var eo=this.featureFlags.getFeatureFlagPayload(ue);try{return JSON.parse(eo)}catch{return eo}}},{key:"isFeatureEnabled",value:function(ue,eo){return this.featureFlags.isFeatureEnabled(ue,eo)}},{key:"reloadFeatureFlags",value:function(){this.featureFlags.reloadFeatureFlags()}},{key:"updateEarlyAccessFeatureEnrollment",value:function(ue,eo){this.featureFlags.updateEarlyAccessFeatureEnrollment(ue,eo)}},{key:"getEarlyAccessFeatures",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return this.featureFlags.getEarlyAccessFeatures(ue,eo)}},{key:"on",value:function(ue,eo){return this._internalEventEmitter.on(ue,eo)}},{key:"onFeatureFlags",value:function(ue){return this.featureFlags.onFeatureFlags(ue)}},{key:"onSessionId",value:function(ue){var eo,no;return(eo=(no=this.sessionManager)===null||no===void 0?void 0:no.onSessionId(ue))!==null&&eo!==void 0?eo:function(){}}},{key:"getSurveys",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getSurveys(ue,eo)}},{key:"getActiveMatchingSurveys",value:function(ue){var eo=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getActiveMatchingSurveys(ue,eo)}},{key:"renderSurvey",value:function(ue,eo){this.surveys.renderSurvey(ue,eo)}},{key:"canRenderSurvey",value:function(ue){this.surveys.canRenderSurvey(ue)}},{key:"getNextSurveyStep",value:function(ue,eo,no){return this.surveys.getNextSurveyStep(ue,eo,no)}},{key:"identify",value:function(ue,eo,no){if(!this.__loaded||!this.persistence)return G.uninitializedWarning("posthog.identify");if(F(ue)&&(ue=ue.toString(),G.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),ue){if(["distinct_id","distinctid"].includes(ue.toLowerCase()))G.critical('The string "'.concat(ue,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else if(this._requirePersonProcessing("posthog.identify")){var ro=this.get_distinct_id();if(this.register({$user_id:ue}),!this.get_property("$device_id")){var oo=ro;this.register_once({$had_persisted_distinct_id:!0,$device_id:oo},"")}ue!==ro&&ue!==this.get_property(ce)&&(this.unregister(ce),this.register({distinct_id:ue}));var io=(this.persistence.get_property($e)||"anonymous")==="anonymous";ue!==ro&&io?(this.persistence.set_property($e,"identified"),this.setPersonPropertiesForFlags(eo||{},!1),this.capture("$identify",{distinct_id:ue,$anon_distinct_id:ro},{$set:eo||{},$set_once:no||{}}),this.featureFlags.setAnonymousDistinctId(ro)):(eo||no)&&this.setPersonProperties(eo,no),ue!==ro&&(this.reloadFeatureFlags(),this.unregister(Ce))}}else G.error("Unique user id has not been set in posthog.identify")}},{key:"setPersonProperties",value:function(ue,eo){(ue||eo)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(ue||{}),this.capture("$set",{$set:ue||{},$set_once:eo||{}}))}},{key:"group",value:function(ue,eo,no){if(ue&&eo){if(this._requirePersonProcessing("posthog.group")){var ro=this.getGroups();ro[ue]!==eo&&this.resetGroupPropertiesForFlags(ue),this.register({$groups:t$1(t$1({},ro),{},o({},ue,eo))}),no&&(this.capture("$groupidentify",{$group_type:ue,$group_key:eo,$group_set:no}),this.setGroupPropertiesForFlags(o({},ue,no))),ro[ue]===eo||no||this.reloadFeatureFlags()}}else G.error("posthog.group requires a group type and group key")}},{key:"resetGroups",value:function(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}},{key:"setPersonPropertiesForFlags",value:function(ue){var eo=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this._requirePersonProcessing("posthog.setPersonPropertiesForFlags")&&this.featureFlags.setPersonPropertiesForFlags(ue,eo)}},{key:"resetPersonPropertiesForFlags",value:function(){this.featureFlags.resetPersonPropertiesForFlags()}},{key:"setGroupPropertiesForFlags",value:function(ue){var eo=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(ue,eo)}},{key:"resetGroupPropertiesForFlags",value:function(ue){this.featureFlags.resetGroupPropertiesForFlags(ue)}},{key:"reset",value:function(ue){var eo,no,ro,oo;if(G.info("reset"),!this.__loaded)return G.uninitializedWarning("posthog.reset");var io=this.get_property("$device_id");this.consent.reset(),(eo=this.persistence)===null||eo===void 0||eo.clear(),(no=this.sessionPersistence)===null||no===void 0||no.clear(),(ro=this.persistence)===null||ro===void 0||ro.set_property($e,"anonymous"),(oo=this.sessionManager)===null||oo===void 0||oo.resetSessionId();var ao=this.config.get_device_id(Ke());this.register_once({distinct_id:ao,$device_id:ue?ao:io},"")}},{key:"get_distinct_id",value:function(){return this.get_property("distinct_id")}},{key:"getGroups",value:function(){return this.get_property("$groups")||{}}},{key:"get_session_id",value:function(){var ue,eo;return(ue=(eo=this.sessionManager)===null||eo===void 0?void 0:eo.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&ue!==void 0?ue:""}},{key:"get_session_replay_url",value:function(ue){if(!this.sessionManager)return"";var eo=this.sessionManager.checkAndGetSessionAndWindowId(!0),no=eo.sessionId,ro=eo.sessionStartTimestamp,oo=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(no));if(ue!=null&&ue.withTimestamp&&ro){var io,ao=(io=ue.timestampLookBack)!==null&&io!==void 0?io:10;if(!ro)return oo;var so=Math.max(Math.floor((new Date().getTime()-ro)/1e3)-ao,0);oo+="?t=".concat(so)}return oo}},{key:"alias",value:function(ue,eo){return ue===this.get_property(le)?(G.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(w$1(eo)&&(eo=this.get_distinct_id()),ue!==eo?(this._register_single(ce,ue),this.capture("$create_alias",{alias:ue,distinct_id:eo})):(G.warn("alias matches current distinct_id - skipping api call."),this.identify(ue),-1)):void 0}},{key:"set_config",value:function(ue){var eo,no,ro,oo,io=t$1({},this.config);b(ue)&&(J(this.config,ns(ue)),(eo=this.persistence)===null||eo===void 0||eo.update_config(this.config,io),this.sessionPersistence=this.config.persistence==="sessionStorage"?this.persistence:new bn(t$1(t$1({},this.config),{},{persistence:"sessionStorage"})),at.is_supported()&&at.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&(f.DEBUG=!0,G.info("set_config",{config:ue,oldConfig:io,newConfig:t$1({},this.config)})),(no=this.sessionRecording)===null||no===void 0||no.startIfEnabledOrStop(),(ro=this.autocapture)===null||ro===void 0||ro.startIfEnabled(),(oo=this.heatmaps)===null||oo===void 0||oo.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}},{key:"startSessionRecording",value:function(ue){var eo,no=x$1(ue)&&ue;if(no||ue!=null&&ue.sampling){var ro,oo,io=(ro=this.sessionManager)===null||ro===void 0?void 0:ro.checkAndGetSessionAndWindowId();(oo=this.persistence)===null||oo===void 0||oo.register(o({},Ee,!0)),G.info("Session recording started with sampling override for session: ",io==null?void 0:io.sessionId)}(no||ue!=null&&ue.linked_flag)&&((eo=this.sessionRecording)===null||eo===void 0||eo.overrideLinkedFlag(),G.info("Session recording started with linked_flags override")),this.set_config({disable_session_recording:!1})}},{key:"stopSessionRecording",value:function(){this.set_config({disable_session_recording:!0})}},{key:"sessionRecordingStarted",value:function(){var ue;return!((ue=this.sessionRecording)===null||ue===void 0||!ue.started)}},{key:"captureException",value:function(ue,eo){var no=y(U.parseErrorAsProperties)?U.parseErrorAsProperties([ue.message,void 0,void 0,void 0,ue]):t$1({$exception_type:ue.name,$exception_message:ue.message,$exception_level:"error"},eo);this.exceptions.sendExceptionEvent(no)}},{key:"loadToolbar",value:function(ue){return this.toolbar.loadToolbar(ue)}},{key:"get_property",value:function(ue){var eo;return(eo=this.persistence)===null||eo===void 0?void 0:eo.props[ue]}},{key:"getSessionProperty",value:function(ue){var eo;return(eo=this.sessionPersistence)===null||eo===void 0?void 0:eo.props[ue]}},{key:"toString",value:function(){var ue,eo=(ue=this.config.name)!==null&&ue!==void 0?ue:Zr;return eo!==Zr&&(eo=Zr+"."+eo),eo}},{key:"_isIdentified",value:function(){var ue,eo;return((ue=this.persistence)===null||ue===void 0?void 0:ue.get_property($e))==="identified"||((eo=this.sessionPersistence)===null||eo===void 0?void 0:eo.get_property($e))==="identified"}},{key:"_hasPersonProcessing",value:function(){var ue,eo,no,ro;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&k(this.getGroups())&&((ue=this.persistence)===null||ue===void 0||(eo=ue.props)===null||eo===void 0||!eo[ce])&&((no=this.persistence)===null||no===void 0||(ro=no.props)===null||ro===void 0||!ro[qe]))}},{key:"_shouldCapturePageleave",value:function(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&this.config.capture_pageview}},{key:"createPersonProfile",value:function(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}},{key:"_requirePersonProcessing",value:function(ue){return this.config.person_profiles==="never"?(G.error(ue+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(qe,!0),!0)}},{key:"_sync_opt_out_with_persistence",value:function(){var ue,eo,no,ro,oo=this.consent.isOptedOut(),io=this.config.opt_out_persistence_by_default,ao=this.config.disable_persistence||oo&&!!io;((ue=this.persistence)===null||ue===void 0?void 0:ue.disabled)!==ao&&((no=this.persistence)===null||no===void 0||no.set_disabled(ao)),((eo=this.sessionPersistence)===null||eo===void 0?void 0:eo.disabled)!==ao&&((ro=this.sessionPersistence)===null||ro===void 0||ro.set_disabled(ao))}},{key:"opt_in_capturing",value:function(ue){var eo;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),(w$1(ue==null?void 0:ue.captureEventName)||ue!=null&&ue.captureEventName)&&this.capture((eo=ue==null?void 0:ue.captureEventName)!==null&&eo!==void 0?eo:"$opt_in",ue==null?void 0:ue.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}},{key:"opt_out_capturing",value:function(){this.consent.optInOut(!1),this._sync_opt_out_with_persistence()}},{key:"has_opted_in_capturing",value:function(){return this.consent.isOptedIn()}},{key:"has_opted_out_capturing",value:function(){return this.consent.isOptedOut()}},{key:"clear_opt_in_out_capturing",value:function(){this.consent.reset(),this._sync_opt_out_with_persistence()}},{key:"_is_bot",value:function(){return A?function(ue,eo){if(!ue)return!1;var no=ue.userAgent;if(no&&Or(no,eo))return!0;try{var ro=ue==null?void 0:ue.userAgentData;if(ro!=null&&ro.brands&&ro.brands.some(function(oo){return Or(oo==null?void 0:oo.brand,eo)}))return!0}catch{}return!!ue.webdriver}(A,this.config.custom_blocked_useragents):void 0}},{key:"_captureInitialPageview",value:function(){L&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:L.title},{send_instantly:!0}))}},{key:"debug",value:function(ue){ue===!1?(T==null||T.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(T==null||T.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)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}}]),to}();(function(to,ue){for(var eo=0;eo<ue.length;eo++)to.prototype[ue[eo]]=ee(to.prototype[ue[eo]])})(rs,["identify"]);var ss,os=(ss=Xr[Zr]=new rs,function(){function to(){to.done||(to.done=!0,es=!1,Q(Xr,function(ue){ue._dom_loaded()}))}L!=null&&L.addEventListener&&(L.readyState==="complete"?to():L.addEventListener("DOMContentLoaded",to,!1)),T&&oe(T,"load",to,!0)}(),ss);const Events={COMPONENT_CREATED:"component:created",COMPONENT_UPDATED:"component:updated",APP_VIEW_PUBLISHED:"app:view_published",BLOCK_EJECTED:"block:ejected"},EventSource$1={PORTAL:"portal",URL:"url",NOTIFICATION:"notification"};class PosthogClient{constructor(ue){this.token=ue}init(){this.token&&(os.init(this.token,{autocapture:!1,capture_pageview:!1}),os.set_config({persistence:"cookie"}),this.initialised=!0)}identify(ue){this.initialised&&os.identify(ue)}updateUser(ue){this.initialised&&os.people.set(ue)}captureEvent(ue,eo){this.initialised&&(eo.sourceApp="builder",os.capture(ue,eo))}npsFeedback(ue){if(!this.initialised)return;localStorage.setItem(Events.NPS.SUBMITTED,Date.now());const eo={};for(let no in ue)eo[`feedback_${no}`]=ue[no];os.capture(Events.NPS.SUBMITTED,eo)}logout(){this.initialised&&os.reset()}}const posthog=new PosthogClient(void 0);class AnalyticsHub{constructor(){this.clients=[posthog],this.initialised=!1}async activate(){(await API.getAnalyticsStatus()).enabled&&!this.initialised&&(this.clients.forEach(eo=>{eo.init()}),this.initialised=!0)}identify(ue){posthog.identify(ue)}captureException(ue){}captureEvent(ue,eo={}){posthog.captureEvent(ue,eo)}async logout(){posthog.logout()}}const analytics=new AnalyticsHub,capitalise=to=>to&&to.substring(0,1).toUpperCase()+to.substring(1),lowercase=to=>to.substring(0,1).toLowerCase()+to.substring(1),isBuilderInputFocused=to=>{var no,ro,oo;const ue=(no=document.activeElement)==null?void 0:no.tagName.toLowerCase();return!!((((oo=(ro=document.activeElement)==null?void 0:ro.classList)==null?void 0:oo.contains("cm-content"))||["input","textarea"].indexOf(ue)!==-1)&&to.key!=="Escape")},{ContextScopes:ContextScopes$1}=Constants$1,findComponent=(to,ue)=>searchComponentTree(to,eo=>eo._id===ue),findComponentParent=(to,ue,eo)=>{if(!to||!ue)return null;if(to._id===ue)return eo;if(!to._children)return null;for(const no of to._children){const ro=findComponentParent(no,ue,to);if(ro)return ro}return null},findComponentPath=(to,ue,eo=[])=>{if(!to||!ue)return[];if(to._id===ue)return[...eo,to];if(!to._children)return[];for(const no of to._children){const ro=[...eo,to],oo=findComponentPath(no,ue,ro);if(oo!=null&&oo.length)return oo}return[]},findAllMatchingComponents=(to,ue)=>{if(!to||!ue)return[];let eo=[];return to._children&&to._children.forEach(no=>{eo=[...eo,...findAllMatchingComponents(no,ue)]}),ue(to)&&eo.push(to),eo.reverse()},findAllComponents=to=>findAllMatchingComponents(to,()=>!0),findClosestMatchingComponent=(to,ue,eo)=>{if(!eo)return null;const no=findComponentPath(to,ue).reverse();for(let ro of no)if(eo(ro))return ro;return null},searchComponentTree=(to,ue)=>{if(!to||!ue)return null;if(ue(to))return to;if(!to._children)return null;for(const eo of to._children){const no=searchComponentTree(eo,ue);if(no)return no}return null},makeComponentUnique=to=>{if(!to)return;const ue=[],eo=(oo,io)=>{var lo;const ao=oo._id,so=uuid$2();io.push([ao,so]),(lo=oo._children)==null||lo.forEach(co=>eo(co,io))};eo(to,ue);let no=JSON.stringify(to);return ue.forEach(([oo,io])=>{no=no.replace(new RegExp(oo,"g"),io)}),findHBSBlocks(no).forEach(oo=>{let io=oo.replace(/\\"/g,'"'),ao=decodeJSBinding(io);if(ao!=null){ue.forEach(([lo,co])=>{ao=ao.replace(new RegExp(lo,"g"),co)});let so=encodeJSBinding(ao);so=so.replace(/"/g,'\\"'),no=no.replace(oo,so)}}),JSON.parse(no)},getComponentText=to=>{var eo;if(to==null)return"";if(to!=null&&to._instanceName)return to._instanceName;const ue=((eo=to._component)==null?void 0:eo.replace("@budibase/standard-components/",""))||"component";return capitalise(ue)},getComponentName=to=>{var no;if(to==null)return"";const eo=(((no=get_store_value(componentStore))==null?void 0:no.components)||{})[to._component]||{};return eo.friendlyName||eo.name||""},getComponentContexts=to=>{const ue=componentStore.getDefinition(to);let eo=[];return ue!=null&&ue.context&&(eo=Array.isArray(ue.context)?[...ue.context]:[ue.context]),ue!=null&&ue.actions&&eo.push({type:"action",scope:ContextScopes$1.Global,actions:ue.actions.map(no=>typeof no=="string"?{type:no}:no)}),eo},buildContextTree=(to,ue={root:[]},eo="root")=>{if(!to)return ue;const no=getComponentContexts(to._component);return no.length&&(ue[eo].push(to._id),no.some(ro=>ro.scope===ContextScopes$1.Local)&&(eo=to._id,ue[to._id]=[])),to._children&&to._children.forEach(ro=>{buildContextTree(ro,ue,eo)}),ue},buildContextTreeLookupMap=to=>{const ue=buildContextTree(to);let eo={};return Object.entries(ue).forEach(([no,ro])=>{ro.forEach(oo=>{eo[oo]=no})}),eo},getChildIdsForComponent=to=>[to._id,...((to==null?void 0:to._children)??[]).map(getChildIdsForComponent).flat(1)],TableNames={USERS:"ta_users"},AppStatus={ALL:"all",DEV:"development",DEPLOYED:"published"},IntegrationNames={POSTGRES:"PostgreSQL",MONGODB:"MongoDB",COUCHDB:"CouchDB",S3:"S3",MYSQL:"MySQL",REST:"REST",DYNAMODB:"DynamoDB",ELASTICSEARCH:"ElasticSearch",SQL_SERVER:"SQL Server",AIRTABLE:"Airtable",ARANGODB:"ArangoDB",ORACLE:"Oracle",GOOGLE_SHEETS:"Google Sheets"},UNEDITABLE_USER_FIELDS=["email","password","roleId","status","firstName","lastName"],APP_NAME_REGEX=/^[\w\s]+$/,APP_URL_REGEX=/^[0-9a-zA-Z-_]+$/,DefaultAppTheme={primaryColor:"var(--spectrum-global-color-blue-600)",primaryColorHover:"var(--spectrum-global-color-blue-500)",buttonBorderRadius:"16px",navBackground:"var(--spectrum-global-color-gray-50)",navTextColor:"var(--spectrum-global-color-gray-800)"},PluginSource={URL:"URL",NPM:"NPM",GITHUB:"Github",FILE:"File Upload"},OnboardingType={EMAIL:"email",PASSWORD:"password"},PlanModel={PER_USER:"perUser"},ChangelogURL="https://docs.budibase.com/changelog",AutoScreenTypes={BLANK:"blank",TABLE:"table",FORM:"form"},actions=[{name:"Save Row",type:"data",component:"SaveRow",context:[{label:"Saved row",value:"row"}]},{name:"Duplicate Row",type:"data",component:"DuplicateRow",context:[{label:"Duplicated row",value:"row"}]},{name:"Delete Row",displayName:"Delete Rows",type:"data",component:"DeleteRow"},{name:"Fetch Row",type:"data",component:"FetchRow",context:[{label:"Fetched row",value:"row"}]},{name:"Navigate To",type:"application",component:"NavigateTo"},{name:"Execute Query",type:"data",component:"ExecuteQuery",context:[{label:"Query result",value:"result"}]},{name:"Trigger Automation",type:"application",component:"TriggerAutomation",context:[{label:"Automation Result",value:"result"}]},{name:"Update Field Value",type:"form",component:"UpdateFieldValue"},{name:"Scroll To Field",type:"form",component:"ScrollTo"},{name:"Validate Form",type:"form",component:"ValidateForm"},{name:"Change Form Step",type:"form",component:"ChangeFormStep"},{name:"Clear Form",type:"form",component:"ClearForm"},{name:"Log Out",type:"application",component:"LogOut"},{name:"Close Screen Modal",type:"application",component:"CloseScreenModal"},{name:"Refresh Data Provider",type:"data",component:"RefreshDataProvider"},{name:"Update State",type:"data",component:"UpdateState",dependsOnFeature:"state"},{name:"Upload File to S3",type:"data",component:"S3Upload",context:[{label:"File URL",value:"publicUrl"}]},{name:"Export Data",type:"data",component:"ExportData"},{name:"Continue if / Stop if",type:"logic",component:"ContinueIf",dependsOnFeature:"continueIfAction"},{name:"Show Notification",type:"application",component:"ShowNotification",dependsOnFeature:"showNotificationAction"},{name:"Prompt User",type:"application",component:"PromptUser"},{name:"Open Side Panel",type:"application",component:"OpenSidePanel",dependsOnFeature:"sidePanel"},{name:"Close Side Panel",type:"application",component:"CloseSidePanel",dependsOnFeature:"sidePanel"},{name:"Open Modal",type:"application",component:"OpenModal",dependsOnFeature:"modal"},{name:"Close Modal",type:"application",component:"CloseModal",dependsOnFeature:"modal"},{name:"Clear Row Selection",type:"data",component:"ClearRowSelection"},{name:"Download File",type:"data",component:"DownloadFile"},{name:"Row Action",type:"data",component:"RowAction"}],ActionDefinitions={actions},DEFAULT_CONFIG={platformUrl:"",logoUrl:void 0,faviconUrl:void 0,emailBrandingEnabled:!0,testimonialsEnabled:!0,platformTitle:"Budibase",loginHeading:void 0,loginButton:void 0,metaDescription:void 0,metaImageUrl:void 0,metaTitle:void 0,docsUrl:void 0,company:"Budibase",oidc:void 0,google:void 0,googleDatasourceConfigured:void 0,oidcCallbackUrl:"",googleCallbackUrl:"",isSSOEnforced:!1,loaded:!1};function createOrganisationStore(){const to=writable(DEFAULT_CONFIG),{subscribe:ue,set:eo}=to;async function no(){const oo=get_store_value(auth).tenantId,io=await API.getTenantConfig(oo);eo({...DEFAULT_CONFIG,...io.config,loaded:!0})}async function ro(oo){const io=_$3.cloneDeep(get_store_value(to));delete io.oidc,delete io.google,delete io.googleDatasourceConfigured,delete io.oidcCallbackUrl,delete io.googleCallbackUrl,delete io.loaded,await API.saveConfig({type:"settings",config:{...io,...oo}}),await no()}return{subscribe:ue,set:eo,save:ro,init:no}}const organisation=createOrganisationStore();function createUsersStore(){const{subscribe:to,set:ue}=writable({});async function eo(So={}){const Eo=await API.searchUsers(So);return ue({...Eo,...So}),Eo}async function no(So){try{return await API.getUser(So)}catch{return null}}const ro=async()=>await API.getUsers();async function oo(So){return await API.onboardUsers(So)}async function io(So){const Eo=So.map(Io=>{let Ao;return Io.admin||Io.builder?Ao={global:!0}:Io.creator&&(Ao={creator:!0}),{email:Io.email,userInfo:{admin:Io.admin?{global:!0}:void 0,builder:Ao,userGroups:Io.groups,roles:Io.apps?Io.apps:void 0}}});return API.inviteUsers(Eo)}async function ao(So){return API.removeUserInvites(So)}async function so(So,Eo,Io,Ao){return API.acceptInvite({inviteCode:So,password:Eo,firstName:Io,lastName:Ao!=null&&Ao.trim()?Ao:void 0})}async function lo(So){return API.getUserInvite(So)}async function co(){return API.getUserInvites()}async function uo(So){return API.updateUserInvite(So.code,So)}async function fo(So){let Eo=So.users.map(Ao=>{const To={email:Ao.email,password:Ao.password,roles:{}};switch(Ao.forceResetPassword&&(To.forceResetPassword=Ao.forceResetPassword),Ao.role){case"appUser":To.builder={global:!1},To.admin={global:!1};break;case"developer":To.builder={global:!0};break;case"creator":To.builder={creator:!0,global:!1};break;case"admin":To.admin={global:!0},To.builder={global:!0};break}return To});const Io=await API.createUsers(Eo,So.groups);return await eo(),Io}async function po(So){await API.deleteUser(So),lodashExports.update(Eo=>Eo.filter(Io=>Io._id!==So))}async function ho(So){return await API.getUserCountByApp(So)}async function _o(So){return API.deleteUsers(So)}async function go(So){return await API.saveUser(So)}async function bo(So,Eo){return await API.addAppBuilder(So,Eo)}async function vo(So,Eo){return await API.removeAppBuilder(So,Eo)}async function yo(){return await API.getAccountHolder()}const wo=So=>So&&So.email===So.tenantOwnerEmail?BudibaseRoles.Owner:isAdmin(So)?BudibaseRoles.Admin:isBuilder(So)?BudibaseRoles.Developer:hasCreatorPermissions(So)?BudibaseRoles.Creator:BudibaseRoles.AppUser,ko=So=>async(...Eo)=>{const Io=await So(...Eo);return await licensing.setQuotaUsage(),Io};return{subscribe:to,search:eo,get:no,getUserRole:wo,fetch:ro,invite:io,onboard:oo,fetchInvite:lo,getInvites:co,removeInvites:ao,updateInvite:uo,getUserCountByApp:ho,addAppBuilder:bo,removeAppBuilder:vo,acceptInvite:so,create:ko(fo),save:ko(go),bulkDelete:ko(_o),delete:ko(po),getAccountHolder:yo}}const users=createUsersStore();function createAdminStore(){const to=writable({loaded:!1,multiTenancy:!1,cloud:!1,isDev:!1,disableAccountPortal:!1,offlineMode:!1,maintenance:[]});async function ue(){await oo(),await eo(),get_store_value(to).cloud&&(await ro(),no()),to.update(ao=>(ao.loaded=!0,ao))}async function eo(){const ao=await API.getEnvironment();to.update(so=>(so.multiTenancy=ao.multiTenancy,so.cloud=ao.cloud,so.disableAccountPortal=ao.disableAccountPortal,so.accountPortalUrl=ao.accountPortalUrl,so.isDev=ao.isDev,so.baseUrl=ao.baseUrl,so.offlineMode=ao.offlineMode,so.maintenance=ao.maintenance,so.passwordMinLength=ao.passwordMinLength,so))}const no=async()=>{var so,lo;const ao=(lo=(so=get_store_value(to))==null?void 0:so.status)==null?void 0:lo.health;ao!=null&&ao.passing||await banner.showStatus()};async function ro(){const ao=await API.getSystemStatus();to.update(so=>(so.status=ao,so))}async function oo(){const ao=get_store_value(auth).tenantId,so=await API.getChecklist(ao);to.update(lo=>(lo.checklist=so,lo))}function io(){to.update(ao=>(ao.loaded=!1,ao))}return{subscribe:to.subscribe,init:ue,unload:io,getChecklist:oo}}const admin=createAdminStore();class AuthStore extends BudiStore{constructor(){super({accountPortalAccess:!1,tenantId:"default",tenantSet:!1,loaded:!1,postLogout:!1,isSSO:!1})}setUser(ue){this.set({loaded:!0,user:ue,accountPortalAccess:!!(ue!=null&&ue.accountPortalAccess),tenantId:(ue==null?void 0:ue.tenantId)||"default",tenantSet:!!ue,isSSO:ue!=null&&isSSOUser(ue),postLogout:!1}),ue&&analytics.activate().then(()=>{analytics.identify(ue._id)}).catch(()=>{})}async setOrganisation(ue){const eo=get_store_value(this.store).tenantId;auth.update(no=>(no.tenantId=ue,no.tenantSet=!!ue,no)),eo!==ue&&await admin.init()}async setInitInfo(ue){return await API.setInitInfo(ue),auth.update(eo=>(eo.initInfo=ue,eo)),ue}setPostLogout(){auth.update(ue=>(ue.postLogout=!0,ue))}async getInitInfo(){const ue=await API.getInitInfo();return auth.update(eo=>(eo.initInfo=ue,eo)),ue}async checkQueryString(){const eo=new URLSearchParams(window.location.search).get("tenantId");eo&&await this.setOrganisation(eo)}async setOrg(ue){await this.setOrganisation(ue)}async getSelf(){try{const ue=await API.fetchBuilderSelf();this.setUser(ue)}catch{this.setUser()}}async login(ue,eo){const no=get_store_value(this.store).tenantId;await API.logIn(no,ue,eo),await this.getSelf()}async logout(){await API.logOut(),this.setPostLogout(),this.setUser(),await this.setInitInfo({})}async updateSelf(ue){await API.updateSelf(ue);try{const eo=await API.fetchBuilderSelf();this.setUser(eo)}catch{this.setUser()}}async forgotPassword(ue){const eo=get_store_value(this.store).tenantId;await API.requestForgotPassword(eo,ue)}async resetPassword(ue,eo){const no=get_store_value(this.store).tenantId;await API.resetPassword(no,ue,eo)}async generateAPIKey(){return API.generateAPIKey()}async fetchAPIKey(){const ue=await API.fetchDeveloperInfo();return ue==null?void 0:ue.apiKey}}const auth=new AuthStore;class AppsStore extends BudiStore{constructor(){super({apps:[]}),this.extractAppId=this.extractAppId.bind(this),this.getProdAppID=this.getProdAppID.bind(this),this.updateSort=this.updateSort.bind(this),this.load=this.load.bind(this),this.save=this.save.bind(this)}extractAppId(ue){const eo=(ue==null?void 0:ue.split("_"))||[];return eo.length?eo[eo.length-1]:null}getProdAppID(ue){if(!ue)return ue;let eo,no="";if(ue.startsWith("app_dev")){const ro=ue.split("app_dev");ro.shift(),eo=ro.join("app_dev")}else if(!ue.startsWith("app"))eo=ue,no="_";else return ue;return`app${no}${eo}`}async updateSort(ue){this.update(eo=>({...eo,sortBy:ue})),await this.updateUserSort(ue)}async updateUserSort(ue){try{await auth.updateSelf({appSort:ue})}catch(eo){console.error("couldn't save user sort: ",eo)}}async load(){const ue=await API.getApps();if(Array.isArray(ue)){let eo={},no=ue.filter(io=>io.status===AppStatus.DEV),ro=ue.filter(io=>io.status===AppStatus.DEPLOYED);no.forEach(io=>{const ao=this.extractAppId(io.appId);ao&&(eo[ao]={...io,devId:io.appId,devRev:io._rev})}),ro.forEach(io=>{const ao=this.extractAppId(io.appId);if(!ao||!eo[ao])return;let so={};eo[ao]&&(so={updatedBy:eo[ao].updatedBy,updatedAt:eo[ao].updatedAt}),eo[ao]={...eo[ao],...io,...so,prodId:io.appId,prodRev:io._rev}});const oo=Object.values(eo);oo.forEach(io=>{const ao=this.extractAppId(io.devId);ao&&(io.appId=ao),delete io._id,delete io._rev}),this.update(io=>({...io,apps:oo}))}else this.update(eo=>({...eo,apps:[]}))}async save(ue,eo){await API.saveAppMetadata(ue,eo),this.update(no=>{const ro=no.apps.findIndex(oo=>oo.instance._id===ue);if(ro!==-1){let oo=no.apps[ro];oo={...oo,...eo},no.apps.splice(ro,1,oo)}return no})}}const appsStore=new AppsStore,sortBy=derived([appsStore,auth],([to,ue])=>{var eo;return to.sortBy||((eo=ue.user)==null?void 0:eo.appSort)||"name"}),enrichedApps=derived([appsStore,auth,sortBy],([to,ue,eo])=>{const no=to.apps.map(ro=>{var io;const oo=ue.user;return{...ro,deployed:ro.status===AppStatus.DEPLOYED,lockedYou:ro.lockedBy!=null&&ro.lockedBy.email===(oo==null?void 0:oo.email),lockedOther:ro.lockedBy!=null&&ro.lockedBy.email!==(oo==null?void 0:oo.email),favourite:!!((io=oo==null?void 0:oo.appFavourites)!=null&&io.includes(ro.appId))}});return eo==="status"?no.sort((ro,oo)=>{var io,ao;return ro.favourite===oo.favourite?ro.status===oo.status?((io=ro.name)==null?void 0:io.toLowerCase())<((ao=oo.name)==null?void 0:ao.toLowerCase())?-1:1:ro.status===AppStatus.DEPLOYED?-1:1:ro.favourite?-1:1}):eo==="updated"?no==null?void 0:no.sort((ro,oo)=>{if(ro.favourite===oo.favourite){const io=ro.updatedAt||"9999",ao=oo.updatedAt||"9999";return io<ao?1:-1}return ro.favourite?-1:1}):no==null?void 0:no.sort((ro,oo)=>{var io,ao;return ro.favourite===oo.favourite?((io=ro.name)==null?void 0:io.toLowerCase())<((ao=oo.name)==null?void 0:ao.toLowerCase())?-1:1:ro.favourite?-1:1})});class EmailStore extends BudiStore{constructor(){super({templates:[]})}async fetchTemplates(){const ue=await API.getEmailTemplateDefinitions(),eo=await API.getEmailTemplates();this.set({definitions:ue,templates:eo})}async saveTemplate(ue){const eo=await API.saveEmailTemplate(ue);ue._rev=eo._rev,ue._id=eo._id,this.update(no=>{const ro=no.templates.findIndex(oo=>oo.purpose===eo.purpose);return no.templates.splice(ro,1,ue),no})}}const email=new EmailStore,OIDC_CONFIG={logo:void 0,name:void 0,uuid:void 0};function createOidcStore(){const to=writable(OIDC_CONFIG),{set:ue,subscribe:eo}=to;return{subscribe:eo,set:ue,init:async()=>{const no=get_store_value(auth).tenantId,ro=await API.getOIDCConfig(no);Object.keys(ro||{}).length?ue(...ro):ue(OIDC_CONFIG)}}}const oidc=createOidcStore();function templatesStore(){const{subscribe:to,set:ue}=writable([]);return{subscribe:to,load:async()=>{const eo=await API.getAppTemplates();ue(eo)}}}const templates=templatesStore(),ExpiringKeys={LICENSING_PAYMENT_FAILED:"licensing_payment_failed",LICENSING_ACCOUNT_DOWNGRADED_MODAL:"licensing_account_downgraded_modal",LICENSING_APP_LIMIT_MODAL:"licensing_app_limit_modal",LICENSING_ROWS_WARNING_BANNER:"licensing_rows_warning_banner",LICENSING_AUTOMATIONS_WARNING_BANNER:"licensing_automations_warning_banner",LICENSING_QUERIES_WARNING_BANNER:"licensing_queries_warning_banner",LICENSING_USERS_ABOVE_LIMIT_BANNER:"licensing_users_above_limit_banner"},StripeStatus={PAST_DUE:"past_due",ACTIVE:"active"},UNLIMITED=-1,ONE_DAY_MILLIS=864e5;class LicensingStore extends BudiStore{constructor(){super({goToUpgradePage:()=>{},goToPricingPage:()=>{},license:void 0,isFreePlan:!0,isEnterprisePlan:!0,isBusinessPlan:!0,groupsEnabled:!1,backupsEnabled:!1,brandingEnabled:!1,scimEnabled:!1,environmentVariablesEnabled:!1,budibaseAIEnabled:!1,customAIConfigsEnabled:!1,auditLogsEnabled:!1,quotaUsage:void 0,usageMetrics:void 0,quotaResetDaysRemaining:void 0,quotaResetDate:void 0,accountPastDue:!1,pastDueEndDate:void 0,pastDueDaysRemaining:void 0,accountDowngraded:!1,userCount:void 0,userLimit:void 0,userLimitReached:!1,errUserLimit:!1})}usersLimitReached(ue,eo=get_store_value(this.store).userLimit){return eo===UNLIMITED||eo===void 0?!1:ue>=eo}usersLimitExceeded(ue,eo=get_store_value(this.store).userLimit){return eo===UNLIMITED||eo===void 0?!1:ue>eo}async isCloud(){let ue=get_store_value(admin);return ue.loaded||(await admin.init(),ue=get_store_value(admin)),ue.cloud}async init(){this.setNavigation(),this.setLicense(),await this.setQuotaUsage()}setNavigation(){var io;const ue=get_store_value(admin),eo=get_store_value(auth),no=(io=eo==null?void 0:eo.user)!=null&&io.accountPortalAccess?`${ue.accountPortalUrl}/portal/upgrade`:"/builder/portal/account/upgrade",ro=()=>{window.location.href=no},oo=()=>{window.open("https://budibase.com/pricing/","_blank")};this.update(ao=>({...ao,goToUpgradePage:ro,goToPricingPage:oo}))}setLicense(){var wo;const ue=(wo=get_store_value(auth).user)==null?void 0:wo.license,eo=ue==null?void 0:ue.plan.type,no=(ue==null?void 0:ue.features)||[],ro=eo===PlanType.ENTERPRISE,oo=eo===PlanType.FREE,io=eo===PlanType.BUSINESS,ao=eo===PlanType.ENTERPRISE_BASIC_TRIAL,so=no.includes(Feature.USER_GROUPS),lo=no.includes(Feature.APP_BACKUPS),co=no.includes(Feature.SCIM),uo=no.includes(Feature.ENVIRONMENT_VARIABLES),fo=no.includes(Feature.ENFORCEABLE_SSO),po=no.includes(Feature.BRANDING),ho=no.includes(Feature.AUDIT_LOGS),_o=no.includes(Feature.SYNC_AUTOMATIONS),go=no.includes(Feature.TRIGGER_AUTOMATION_RUN),bo=no.includes(Feature.APP_BUILDERS),vo=no.includes(Feature.BUDIBASE_AI),yo=no.includes(Feature.AI_CUSTOM_CONFIGS);this.update(ko=>({...ko,license:ue,isEnterprisePlan:ro,isFreePlan:oo,isBusinessPlan:io,isEnterpriseTrial:ao,groupsEnabled:so,backupsEnabled:lo,brandingEnabled:po,budibaseAIEnabled:vo,customAIConfigsEnabled:yo,scimEnabled:co,environmentVariablesEnabled:uo,auditLogsEnabled:ho,enforceableSSO:fo,syncAutomationsEnabled:_o,triggerAutomationRunEnabled:go,perAppBuildersEnabled:bo}))}async setQuotaUsage(){const ue=await API.getQuotaUsage();this.update(eo=>({...eo,quotaUsage:ue})),await this.setUsageMetrics()}async setUsageMetrics(){var ko,So,Eo,Io,Ao,To,zo,Vo,Fo,Po,Ro;const ue=get_store_value(this.store).quotaUsage,eo=(ko=get_store_value(auth).user)==null?void 0:ko.license,no=new Date;if(!eo||!ue)return;const ro=[MonthlyQuotaName.QUERIES,MonthlyQuotaName.AUTOMATIONS].reduce((Do,qo)=>{var Zo;const Uo=eo.quotas.usage.monthly[qo].value,jo=(((Zo=ue.monthly.current)==null?void 0:Zo[qo])||0)/Uo*100;return Do[qo]=Uo>-1?Math.floor(jo):-1,Do},{}),oo=[StaticQuotaName.APPS,StaticQuotaName.ROWS].reduce((Do,qo)=>{const Uo=eo.quotas.usage.static[qo].value,jo=(ue.usageQuota[qo]||0)/Uo*100;return Do[qo]=Uo>-1?Math.floor(jo):-1,Do},{}),io=(Do,qo)=>qo>Do?Math.round((qo.getTime()-Do.getTime())/ONE_DAY_MILLIS):0,ao=new Date(ue.quotaReset),so=io(no,ao),lo=!!((Eo=(So=eo.billing)==null?void 0:So.subscription)!=null&&Eo.downgradeAt)&&((Ao=(Io=eo.billing)==null?void 0:Io.subscription)==null?void 0:Ao.downgradeAt)<=no.getTime()&&((zo=(To=eo.billing)==null?void 0:To.subscription)==null?void 0:zo.status)===StripeStatus.PAST_DUE&&eo.plan.type===PlanType.FREE,co=(Fo=(Vo=eo.billing)==null?void 0:Vo.subscription)==null?void 0:Fo.pastDueAt,uo=(Ro=(Po=eo.billing)==null?void 0:Po.subscription)==null?void 0:Ro.downgradeAt;let fo,po;co&&uo&&(po=new Date(uo),fo=io(new Date(co),po));const _o=eo.quotas.usage.static.users.value,go=ue.usageQuota.users,bo=this.usersLimitReached(go,_o),vo=this.usersLimitExceeded(go,_o),wo=await this.isCloud()&&eo.plan.model===PlanModel$1.PER_USER&&vo;this.update(Do=>({...Do,usageMetrics:{...ro,...oo},quotaResetDaysRemaining:so,quotaResetDate:ao,accountDowngraded:lo,accountPastDue:co!=null,pastDueEndDate:po,pastDueDaysRemaining:fo,userCount:go,userLimit:_o,userLimitReached:bo,errUserLimit:wo}))}}const licensing=new LicensingStore;class GroupStore extends BudiStore{constructor(){super([]),this.updateStore=ue=>{this.update(eo=>{const no=eo.findIndex(ro=>ro._id===ue._id);return no>=0?eo.splice(no,1,ue):eo.push(ue),eo})}}async init(){if(get_store_value(licensing).groupsEnabled){const ue=await API.getGroups();this.set(ue)}}async refreshGroup(ue){const eo=await API.getGroup(ue);this.updateStore(eo)}async save(ue){const{...eo}=ue;delete eo.scimInfo;const no=await API.saveGroup(eo);return ue._id=no._id,ue._rev=no._rev,this.updateStore(ue),ue}async delete(ue){await API.deleteGroup(ue._id,ue._rev),this.update(eo=>{const no=eo.findIndex(ro=>ro._id===ue._id);return no!==-1&&eo.splice(no,1),eo})}async addUser(ue,eo){await API.addUsersToGroup(ue,[eo]),await this.refreshGroup(ue)}async removeUser(ue,eo){await API.removeUsersFromGroup(ue,[eo]),await this.refreshGroup(ue)}async addApp(ue,eo,no){await API.addAppsToGroup(ue,[{appId:eo,roleId:no}]),await this.refreshGroup(ue)}async removeApp(ue,eo){await API.removeAppsFromGroup(ue,[{appId:eo}]),await this.refreshGroup(ue)}getGroupAppIds(ue){var no;let eo=Object.keys((ue==null?void 0:ue.roles)||{});return(no=ue==null?void 0:ue.builder)!=null&&no.apps&&(eo=eo.concat(ue.builder.apps)),eo}async addGroupAppBuilder(ue,eo){return await API.addGroupAppBuilder(ue,eo)}async removeGroupAppBuilder(ue,eo){return await API.removeGroupAppBuilder(ue,eo)}}const groups=new GroupStore;function createPluginsStore(){const{subscribe:to,set:ue,update:eo}=writable([]);async function no(){const ao=await API.getPlugins();ue(ao)}async function ro(ao){await API.deletePlugin(ao),eo(so=>(so=so.filter(lo=>lo._id!==ao),so))}async function oo(ao,so,lo=null){let co={source:ao,url:so};switch(ao){case PluginSource.URL:co.headers=lo;break;case PluginSource.GITHUB:co.githubToken=lo;break}let fo=(await API.createPlugin(co)).plugin;eo(po=>{const ho=po.findIndex(_o=>_o._id===fo._id);return ho>=0?po.splice(ho,1,fo):po.push(fo),po})}async function io(ao){if(!ao)return;let so=new FormData;so.append("file",ao);let co=(await API.uploadPlugin(so)).plugins[0];eo(uo=>{const fo=uo.findIndex(po=>po._id===co._id);return fo>=0?uo.splice(fo,1,co):uo.push(co),uo})}return{subscribe:to,load:no,createPlugin:oo,deletePlugin:ro,uploadPlugin:io}}const plugins$1=createPluginsStore();class BackupStore extends BudiStore{constructor(){super({})}selectBackup(ue){this.update(eo=>(eo.selectedBackup=ue,eo))}async searchBackups(ue,eo){return API.searchBackups(ue,eo)}async restoreBackup(ue,eo,no){return API.restoreBackup(ue,eo,no)}async deleteBackup(ue,eo){return API.deleteBackup(ue,eo)}async createManualBackup(ue){return API.createManualBackup(ue)}}const backups=new BackupStore;class EnvironmentStore extends BudiStore{constructor(){super({variables:[],status:{encryptionKeyAvailable:!1}})}async checkStatus(){const ue=await API.checkEnvironmentVariableStatus();this.update(eo=>(eo.status=ue,eo))}async loadVariables(){if(get_store_value(licensing).environmentVariablesEnabled){const eo=(await API.fetchEnvironmentVariables()).variables.map(no=>({name:no}));this.update(no=>(no.variables=eo,no))}}async createVariable(ue){await API.createEnvironmentVariable(ue);let eo={name:ue.name};this.update(no=>(no.variables=[eo,...no.variables],no))}async deleteVariable(ue){await API.deleteEnvironmentVariable(ue),this.update(eo=>(eo.variables=eo.variables.filter(no=>no.name!==ue),eo))}async updateVariable(ue,eo){await API.updateEnvironmentVariable(ue,eo)}async upgradePanelOpened(){await API.publishEvent(EventPublishType$1.ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED)}}const environment=new EnvironmentStore,isEnabled=to=>{var eo;const ue=get_store_value(auth).user;return!!((eo=ue==null?void 0:ue.flags)!=null&&eo[to])},menu=derived([admin,auth],([to,ue])=>{const eo=ue==null?void 0:ue.user,no=isAdmin(eo),ro=to==null?void 0:to.cloud;let oo=[{title:"Users",href:"/builder/portal/users/users"}];oo.push({title:"Groups",href:"/builder/portal/users/groups"});let io=[{title:"Apps",href:"/builder/portal/apps"}];if(isGlobalBuilder(eo)&&(io.push({title:"Users",href:"/builder/portal/users",subPages:oo}),io.push({title:"Plugins",href:"/builder/portal/plugins"})),no){let so=[{title:"Auth",href:"/builder/portal/settings/auth"},{title:"Email",href:"/builder/portal/settings/email"},{title:"Organisation",href:"/builder/portal/settings/organisation"},{title:"Branding",href:"/builder/portal/settings/branding"},{title:"Environment",href:"/builder/portal/settings/environment"}];isEnabled(FeatureFlag.AI_CUSTOM_CONFIGS)&&so.push({title:"AI",href:"/builder/portal/settings/ai"}),ro||(so.push({title:"Version",href:"/builder/portal/settings/version"}),so.push({title:"Diagnostics",href:"/builder/portal/settings/diagnostics"})),io.push({title:"Settings",href:"/builder/portal/settings",subPages:[...so].sort((lo,co)=>lo.title.localeCompare(co.title))})}let ao=[{title:"Usage",href:"/builder/portal/account/usage"}];return no&&(ao.push({title:"Audit Logs",href:"/builder/portal/account/auditLogs"}),ro||ao.push({title:"System Logs",href:"/builder/portal/account/systemLogs"})),ro&&(eo!=null&&eo.accountPortalAccess)?ao.push({title:"Upgrade",href:(to==null?void 0:to.accountPortalUrl)+"/portal/upgrade"}):!ro&&no&&ao.push({title:"Upgrade",href:"/builder/portal/account/upgrade"}),eo!=null&&eo.accountPortalAccess&&eo.account.stripeCustomerId&&ao.push({title:"Billing",href:(to==null?void 0:to.accountPortalUrl)+"/portal/billing"}),io.push({title:"Account",href:"/builder/portal/account",subPages:ao}),io});class AuditLogsStore extends BudiStore{constructor(){super({})}async search(ue={}){if(get_store_value(licensing).auditLogsEnabled){const eo=await API.searchAuditLogs(ue);return this.update(no=>({...no,logs:eo})),eo}}async getEventDefinitions(){const ue=await API.getEventDefinitions();this.update(eo=>({...eo,events:ue.events}))}getDownloadUrl(ue={}){return API.getDownloadUrl(ue)}}const auditLogs=new AuditLogsStore;class FeatureStore extends DerivedBudiStore{constructor(){const ue=eo=>derived([eo,licensing],([no,ro])=>({isScimEnabled:no.scimConfigEnabled&&ro.scimEnabled}));super({scimConfigEnabled:!1},ue)}async init(){const ue=await API.getConfig(ConfigType.SCIM);this.update(eo=>({...eo,scimConfigEnabled:isConfig(ue)&&isSCIMConfig(ue)&&ue.config.enabled}))}}const features=new FeatureStore,getThemeStore=()=>{const to=document.documentElement,eo=createLocalStorageStore("bb-theme",{theme:DefaultBuilderTheme}),no=derived(eo,ro=>({...ro,theme:ensureValidTheme(ro.theme,DefaultBuilderTheme)}));return no.subscribe(({theme:ro})=>{const oo=getThemeClassNames(ro).split(" ");ThemeOptions.forEach(io=>{const ao=`${ThemeClassPrefix}${io.id}`;to.classList.toggle(ao,oo.includes(ao))})}),{...eo,subscribe:no.subscribe}},themeStore$1=getThemeStore(),createTemporalStore=()=>{const eo=createLocalStorageStore("bb-temporal",{}),no=(oo,io,ao)=>{const so={...io,expiry:Date.now()+ao*1e3};eo.update(lo=>({...lo,[oo]:so}))},ro=oo=>{const io=get_store_value(eo)[oo];return io?io.expiry<Date.now()?(eo.update(so=>(delete so[oo],so)),null):io:void 0};return{subscribe:eo.subscribe,actions:{setExpiring:no,getExpiring:ro}}},temporalStore=createTemporalStore();function createNavigationStore(){const to=writable({initialisated:!1,goto:void 0}),{set:ue,subscribe:eo}=to;return{subscribe:eo,actions:{init:ro=>{if(typeof ro!="function")throw new Error(`gotoFunc must be a function, found a "${typeof ro}" instead`);ue({initialisated:!0,goto:ro})}}}}const navigation=createNavigationStore(),featureFlags=derived(auth,to=>{var ue;return{...FeatureFlagDefaults,...((ue=to==null?void 0:to.user)==null?void 0:ue.flags)||{}}}),sideBarCollapsed=writable(!1),convertOldFieldFormat=to=>to?to.map(eo=>typeof eo=="string"?{field:eo,active:!0}:typeof(eo==null?void 0:eo.active)!="boolean"?{field:eo.name,active:!0}:eo):[],getComponentForField=(to,ue)=>{if(!to||!(ue!=null&&ue[to]))return null;const eo=ue[to].type;return FieldTypeToComponentMap[eo]},FieldTypeToComponentMap={[FieldType.STRING]:"stringfield",[FieldType.NUMBER]:"numberfield",[FieldType.BIGINT]:"bigintfield",[FieldType.OPTIONS]:"optionsfield",[FieldType.ARRAY]:"multifieldselect",[FieldType.BOOLEAN]:"booleanfield",[FieldType.LONGFORM]:"longformfield",[FieldType.DATETIME]:"datetimefield",[FieldType.SIGNATURE_SINGLE]:"signaturesinglefield",[FieldType.ATTACHMENTS]:"attachmentfield",[FieldType.ATTACHMENT_SINGLE]:"attachmentsinglefield",[FieldType.LINK]:"relationshipfield",[FieldType.JSON]:"jsonfield",[FieldType.BARCODEQR]:"codescanner",[FieldType.BB_REFERENCE]:"bbreferencefield",[FieldType.BB_REFERENCE_SINGLE]:"bbreferencesinglefield"},{TypeIconMap}=Constants$1,AUTO_COLUMN_SUB_TYPES=AutoFieldSubType,AUTO_COLUMN_DISPLAY_NAMES={AUTO_ID:"Auto ID",CREATED_BY:"Created By",CREATED_AT:"Created At",UPDATED_BY:"Updated By",UPDATED_AT:"Updated At"},FIELDS={STRING:{name:"Text",type:FieldType.STRING,icon:TypeIconMap[FieldType.STRING],constraints:{type:"string",length:{},presence:!1}},BARCODEQR:{name:"Barcode / QR",type:FieldType.BARCODEQR,icon:TypeIconMap[FieldType.BARCODEQR],constraints:{type:"string",length:{},presence:!1}},LONGFORM:{name:"Long form text",type:FieldType.LONGFORM,icon:TypeIconMap[FieldType.LONGFORM],constraints:{type:"string",length:{},presence:!1}},OPTIONS:{name:"Single select",type:FieldType.OPTIONS,icon:TypeIconMap[FieldType.OPTIONS],constraints:{type:"string",presence:!1,inclusion:[]}},ARRAY:{name:"Multi select",type:FieldType.ARRAY,icon:TypeIconMap[FieldType.ARRAY],constraints:{type:"array",presence:!1,inclusion:[]}},NUMBER:{name:"Number",type:FieldType.NUMBER,icon:TypeIconMap[FieldType.NUMBER],constraints:{type:"number",presence:!1,numericality:{greaterThanOrEqualTo:"",lessThanOrEqualTo:""}}},BIGINT:{name:"Big integer",type:FieldType.BIGINT,icon:TypeIconMap[FieldType.BIGINT]},BOOLEAN:{name:"Boolean",type:FieldType.BOOLEAN,icon:TypeIconMap[FieldType.BOOLEAN],constraints:{type:"boolean",presence:!1}},DATETIME:{name:"Date / time",type:FieldType.DATETIME,icon:TypeIconMap[FieldType.DATETIME],constraints:{type:"string",length:{},presence:!1,datetime:{latest:"",earliest:""}}},ATTACHMENT_SINGLE:{name:"Single attachment",type:FieldType.ATTACHMENT_SINGLE,icon:TypeIconMap[FieldType.ATTACHMENT_SINGLE],constraints:{presence:!1}},ATTACHMENTS:{name:"Multi attachment",type:FieldType.ATTACHMENTS,icon:TypeIconMap[FieldType.ATTACHMENTS],constraints:{type:"array",presence:!1}},SIGNATURE_SINGLE:{name:"Signature",type:FieldType.SIGNATURE_SINGLE,icon:"AnnotatePen",constraints:{presence:!1}},LINK:{name:"Relationship",type:FieldType.LINK,icon:TypeIconMap[FieldType.LINK],constraints:{type:"array",presence:!1}},AUTO:{name:"Auto column",type:FieldType.AUTO,icon:TypeIconMap[FieldType.AUTO],constraints:{}},FORMULA:{name:"Formula",type:FieldType.FORMULA,icon:TypeIconMap[FieldType.FORMULA],constraints:{}},AI:{name:"AI",type:FieldType.AI,icon:TypeIconMap[FieldType.AI],constraints:{}},JSON:{name:"JSON",type:FieldType.JSON,icon:TypeIconMap[FieldType.JSON],constraints:{type:"object",presence:!1}},USER:{name:"Single user",type:FieldType.BB_REFERENCE_SINGLE,subtype:BBReferenceFieldSubType.USER,icon:TypeIconMap[FieldType.BB_REFERENCE_SINGLE][BBReferenceFieldSubType.USER]},USERS:{name:"Multi user",type:FieldType.BB_REFERENCE,subtype:BBReferenceFieldSubType.USER,icon:TypeIconMap[FieldType.BB_REFERENCE][BBReferenceFieldSubType.USER],constraints:{type:"array"}}},Roles$1={ADMIN:"ADMIN",POWER:"POWER",BASIC:"BASIC",PUBLIC:"PUBLIC",BUILDER:"BUILDER"};function isAutoColumnUserRelationship(to){return to===AUTO_COLUMN_SUB_TYPES.CREATED_BY||to===AUTO_COLUMN_SUB_TYPES.UPDATED_BY}const PrettyRelationshipDefinitions={MANY:"Many rows",ONE:"One row"},BUDIBASE_INTERNAL_DB_ID=INTERNAL_TABLE_SOURCE_ID,DEFAULT_BB_DATASOURCE_ID="datasource_internal_bb_default",BUDIBASE_DATASOURCE_TYPE="budibase",DB_TYPE_INTERNAL="internal",DB_TYPE_EXTERNAL="external",IntegrationTypes={POSTGRES:"POSTGRES",MONGODB:"MONGODB",COUCHDB:"COUCHDB",S3:"S3",MYSQL:"MYSQL",REST:"REST",DYNAMODB:"DYNAMODB",ELASTICSEARCH:"ELASTICSEARCH",SQL_SERVER:"SQL_SERVER",AIRTABLE:"AIRTABLE",ARANGODB:"ARANGODB",ORACLE:"ORACLE",INTERNAL:"INTERNAL",GOOGLE_SHEETS:"GOOGLE_SHEETS",FIRESTORE:"FIRESTORE",REDIS:"REDIS",SNOWFLAKE:"SNOWFLAKE"},SchemaTypeOptions=[{label:"Text",value:FieldType.STRING},{label:"Number",value:FieldType.NUMBER},{label:"Boolean",value:FieldType.BOOLEAN},{label:"Datetime",value:FieldType.DATETIME},{label:"JSON",value:FieldType.JSON}],SchemaTypeOptionsExpanded=SchemaTypeOptions.map(to=>({...to,value:{type:to.value}})),RawRestBodyTypes={NONE:"none",FORM:"form",ENCODED:"encoded",JSON:"json",TEXT:"text",XML:"xml"},RestBodyTypes=[{name:"none",value:"none"},{name:"form-data",value:"form"},{name:"x-www-form-encoded",value:"encoded"},{name:"raw (JSON)",value:"json"},{name:"raw (XML)",value:"xml"},{name:"raw (Text)",value:"text"}],PaginationTypes=[{label:"Page number based",value:"page"},{label:"Cursor based",value:"cursor"}],PaginationLocations=[{label:"Query parameters",value:"query"},{label:"Request body",value:"body"}],DatasourceTypes={RELATIONAL:"Relational",NON_RELATIONAL:"Non-relational",SPREADSHEET:"Spreadsheet",OBJECT_STORE:"Object store",GRAPH:"Graph",API:"API"},{ContextScopes}=Constants$1,CAPTURE_VAR_INSIDE_TEMPLATE=/{{([^}]+)}}/g,CAPTURE_VAR_INSIDE_JS=/\$\("([^")]+)"\)/g,UpdateReferenceAction={ADD:"add",DELETE:"delete",MOVE:"move"},getBindableProperties=(to,ue)=>{const eo=getContextBindings(to,ue),no=getUserBindings(),ro=getUrlBindings(to),oo=getDeviceBindings(),io=getStateBindings(),ao=getSelectedRowsBindings(to),so=getRoleBindings(),lo=getEmbedBindings();return[...eo,...ro,...io,...no,...oo,...ao,...so,...lo]},getRestBindings=()=>{const to=get_store_value(licensing).environmentVariablesEnabled;return[...getUserBindings(),...getAuthBindings(),...to?getEnvironmentBindings():[]]},getAuthBindings=()=>{let to=[];const ue=makePropSafe("user"),eo=makePropSafe("oauth2"),no=makePropSafe("accessToken");return to=[{runtime:`${ue}.${eo}.${no}`,readable:"Current User.OAuthToken",key:"accessToken",display:{name:"OAuthToken",type:"text"}}].map(oo=>({type:"context",runtimeBinding:oo.runtime,readableBinding:oo.readable,fieldSchema:{type:"string",name:oo.key},providerId:"user",category:"Current User",display:oo.display})),to},getEnvironmentBindings=()=>get_store_value(environment).variables.map(ue=>({type:"context",runtimeBinding:`env.${makePropSafe(ue.name)}`,readableBinding:`env.${ue.name}`,category:"Environment",icon:"Key",display:{type:"string",name:ue.name}})),toBindingsArray=(to,ue,eo)=>to?Object.keys(to).reduce((no,ro)=>{if(!ro)return no;let oo={type:"context",runtimeBinding:ro,readableBinding:`${ue}.${ro}`,icon:"Brackets"};return eo&&(oo.category=eo),no.push(oo),no},[]):[],readableToRuntimeMap=(to,ue)=>!to||!ue?{}:Object.keys(ue).reduce((eo,no)=>(eo[no]=readableToRuntimeBinding(to,ue[no]),eo),{}),runtimeToReadableMap=(to,ue)=>!to||!ue?{}:Object.keys(ue).reduce((eo,no)=>(eo[no]=runtimeToReadableBinding(to,ue[no]),eo),{}),getComponentBindableProperties=(to,ue)=>{if(!to||!ue)return[];const eo=findComponent(to.props,ue),no=componentStore.getDefinition(eo==null?void 0:eo._component);if(!(no!=null&&no.context))return[];const ro=Array.isArray(no.context)?no.context:[no.context];return generateComponentContextBindings(to,{component:eo,definition:no,contexts:ro})},getAllComponentContexts=(to,ue,eo,no={includeSelf:!1})=>{if(!to||!ue)return[];let ro={};const oo=findComponentPath(to.props,ue),io=oo.map(co=>co._id),ao=buildContextTreeLookupMap(to.props),so=co=>uo=>{const fo=ao[uo._id];if(fo!=="root"&&!io.includes(fo))return;const po=uo._component;getComponentContexts(po).forEach(_o=>{eo&&_o.type!==eo||(_o.scope||ContextScopes.Global)!==co||isContextCompatibleWithComponent(_o,uo)&&(ro[uo._id]||(ro[uo._id]={component:uo,definition:componentStore.getDefinition(po),contexts:[]}),ro[uo._id].contexts.push(_o))})};return findAllComponents(to.props).forEach(so(ContextScopes.Global)),oo.forEach(so(ContextScopes.Local)),no!=null&&no.includeSelf||delete ro[ue],Object.values(ro).filter(co=>co.contexts.length>0)},getActionProviders=(to,ue,eo,no={includeSelf:!1})=>getAllComponentContexts(to,ue,"action",{includeSelf:no==null?void 0:no.includeSelf}).map(oo=>{var io,ao;return{...oo,action:(ao=(io=oo.contexts[0])==null?void 0:io.actions)==null?void 0:ao.find(so=>so.type===eo)}}).filter(({action:oo})=>oo!=null).map(({component:oo,action:io})=>{let ao=oo._id;return io.suffix&&(ao+=`-${io.suffix}`),{readableBinding:oo._instanceName,runtimeBinding:ao}}),getDatasourceForProvider=(to,ue)=>{const eo=componentStore.getComponentSettings(ue==null?void 0:ue._component),no=eo.find(ao=>ao.type==="dataProvider");if(no){const ao=ue[no.key],so=extractLiteralHandlebarsID(ao),lo=findComponent(to==null?void 0:to.props,so);return getDatasourceForProvider(to,lo)}const ro=["dataSource","table","schema"],oo=eo.find(ao=>ro.includes(ao.type));if(!oo)return null;const io=ue[oo==null?void 0:oo.key];return typeof io=="string"?{tableId:io,type:"table"}:io},getContextBindings=(to,ue)=>getAllComponentContexts(to,ue).map(no=>generateComponentContextBindings(to,no)).flat(),generateComponentContextBindings=(to,ue)=>{const{component:eo,definition:no,contexts:ro}=ue;if(!eo||!no||!(ro!=null&&ro.length))return[];let oo=[];return ro.forEach(io=>{var ho;if(!(io!=null&&io.type))return;let ao,so,lo,co=io.suffix;if(io.type==="form")ao=buildFormSchema(eo,to),lo="Fields";else if(io.type==="static")ao={},(io.values||[]).forEach(go=>{ao[go.key]={name:go.label,type:go.type||"string"}});else if(io.type==="schema"){const _o=getDatasourceForProvider(to,eo);if(!_o)return;const go=getSchemaForDatasource(to,_o);if(ao=go.schema,so=go.table,_o.type==="jsonarray"||_o.type==="queryarray"){const bo=_o.label.split(".");lo=bo[bo.length-1]}else if(_o.type==="viewV2"){const bo=Object.values((so==null?void 0:so.views)||{}).find(vo=>vo.id===_o.id);lo=bo==null?void 0:bo.name}else lo=(ho=go.table)==null?void 0:ho.name}if(!ao)return;const uo=Object.keys(ao).sort();let fo=eo._id;co&&(fo+=`-${co}`);const po=makePropSafe(fo);uo.forEach(_o=>{var ko;const go=ao[_o],bo=_o.split(".").map(makePropSafe).join("."),vo=`${po}.${bo}`;let yo=eo._instanceName;lo&&(yo+=`.${lo}`),yo+=`.${go.name||_o}`;const wo=getComponentBindingCategory(eo,io,no);oo.push({type:"context",runtimeBinding:vo,readableBinding:`${yo}`,fieldSchema:go,providerId:fo,tableId:so==null?void 0:so._id,component:eo._component,category:wo.category,icon:wo.icon,display:{name:`${go.name||_o}`,type:((ko=go.display)==null?void 0:ko.type)||go.type}})})}),oo},isContextCompatibleWithComponent=(to,ue)=>{if(!ue)return!1;const{_component:eo,actionType:no}=ue,{type:ro}=to;return!(eo.endsWith("formblock")&&(no==="Create"&&ro==="schema"||no==="View"&&ro==="form"))},getComponentBindingCategory=(to,ue,eo)=>{let no=eo.icon,ro=to._instanceName;return to._component.endsWith("formblock")&&(ue.type==="form"?(ro=`${to._instanceName} - Fields`,no="Form"):ue.type==="schema"&&(ro=`${to._instanceName} - Row`,no="Data")),{icon:no,category:ro}},getUserBindings=()=>{let to=[];const{schema:ue}=getSchemaForDatasourcePlus(TableNames.USERS);ue.globalId={type:FieldType.STRING};const eo=Object.keys(ue).sort(),no=makePropSafe("user");return to=eo.reduce((ro,oo)=>{const io=ue[oo];return ro.push({type:"context",runtimeBinding:`${no}.${makePropSafe(oo)}`,readableBinding:`Current User.${oo}`,fieldSchema:io,providerId:"user",category:"Current User",icon:"User",display:{name:oo}}),ro},[]),to},getDeviceBindings=()=>{var ue;let to=[];if((ue=get_store_value(appStore).clientFeatures)!=null&&ue.deviceAwareness){const eo=makePropSafe("device");to=[{type:"context",runtimeBinding:`${eo}.${makePropSafe("mobile")}`,readableBinding:"Device.Mobile",category:"Device",icon:"DevicePhone",display:{type:"boolean",name:"mobile"}},{type:"context",runtimeBinding:`${eo}.${makePropSafe("tablet")}`,readableBinding:"Device.Tablet",category:"Device",icon:"DevicePhone",display:{type:"boolean",name:"tablet"}},{type:"context",runtimeBinding:`${eo}.${makePropSafe("theme")}`,readableBinding:"App.Theme",category:"Device",icon:"DevicePhone",display:{type:"string",name:"App Theme"}}]}return to},getSettingBindings=()=>{let to=[];const ue=makePropSafe("settings");return to=[{type:"context",runtimeBinding:`${ue}.${makePropSafe("url")}`,readableBinding:"Settings.url",category:"Settings",icon:"Settings",display:{type:"string",name:"url"}},{type:"context",runtimeBinding:`${ue}.${makePropSafe("logo")}`,readableBinding:"Settings.logo",category:"Settings",icon:"Settings",display:{type:"string",name:"logo"}},{type:"context",runtimeBinding:`${ue}.${makePropSafe("company")}`,readableBinding:"Settings.company",category:"Settings",icon:"Settings",display:{type:"string",name:"company"}}],to},getSelectedRowsBindings=to=>{var eo;let ue=[];if((eo=get_store_value(appStore).clientFeatures)!=null&&eo.rowSelection){let no=findAllMatchingComponents(to==null?void 0:to.props,io=>io._component.endsWith("table"));const ro=makePropSafe("rowSelection");ue=ue.concat(no.map(io=>({type:"context",runtimeBinding:`${ro}.${makePropSafe(io._id)}.${makePropSafe("selectedRows")}`,readableBinding:`${io._instanceName}.Selected Row IDs (deprecated)`,category:"Selected Row IDs (deprecated)",icon:"ViewRow",display:{name:io._instanceName}})));let oo=findAllMatchingComponents(to==null?void 0:to.props,io=>io._component.endsWith("tableblock"));ue=ue.concat(oo.map(io=>({type:"context",runtimeBinding:`${ro}.${makePropSafe(io._id+"-table")}.${makePropSafe("selectedRows")}`,readableBinding:`${io._instanceName}.Selected Row IDs (deprecated)`,category:"Selected Row IDs (deprecated)",icon:"ViewRow",display:{name:io._instanceName}})))}return ue},makeStateBinding=to=>({type:"context",runtimeBinding:`${makePropSafe("state")}.${makePropSafe(to)}`,readableBinding:`State.${to}`,category:"State",icon:"AutomatedSegment",display:{name:to}}),getStateBindings=()=>{var ue;let to=[];return(ue=get_store_value(appStore).clientFeatures)!=null&&ue.state&&(to=getAllStateVariables().map(makeStateBinding)),to},getUrlBindings=to=>{var ao;const eo=(((ao=to==null?void 0:to.routing)==null?void 0:ao.route)??"").split("/");let no=[];eo.forEach(so=>{so.startsWith(":")&&so.length>1&&no.push(so.replace(/:/g,"").replace(/\?/g,""))});const ro=makePropSafe("url"),oo=no.map(so=>({type:"context",runtimeBinding:`${ro}.${makePropSafe(so)}`,readableBinding:`URL.${so}`,category:"URL",icon:"RailTop",display:{type:"string",name:so}})),io={type:"context",runtimeBinding:makePropSafe("query"),readableBinding:"Query params",category:"URL",icon:"RailTop",display:{type:"object",name:"Query params"}};return oo.concat([io])},getRoleBindings=()=>(get_store_value(roles)||[]).map(to=>({type:"context",runtimeBinding:`'${to._id}'`,readableBinding:`Role.${to.uiMetadata.displayName}`,category:"Role",icon:"UserGroup",display:{type:"string",name:to.uiMetadata.displayName}})),getEventContextBindings=({settingKey:to,componentInstance:ue,componentId:eo,componentDefinition:no,asset:ro})=>{var co;let oo=[];ro=ro??get_store_value(selectedScreen);const io=ue??findComponent(ro.props,eo);if(!io)return oo;const ao=no??componentStore.getDefinition(io==null?void 0:io._component),lo=componentStore.getComponentSettings(io==null?void 0:io._component).find(uo=>uo.key===to);return(co=lo==null?void 0:lo.context)!=null&&co.length&&lo.context.forEach(uo=>{oo.push({readableBinding:uo.label,runtimeBinding:`${makePropSafe("eventContext")}.${makePropSafe(uo.key)}`,category:io._instanceName,icon:ao.icon,display:{name:uo.label}})}),oo},getActionBindings=(to,ue)=>{let eo=[];const no=to==null?void 0:to.findIndex(oo=>oo.id===ue);return no==null||no===-1||to.slice(0,no).forEach((oo,io)=>{const ao=ActionDefinitions.actions.find(so=>so.name===oo["##eventHandlerType"]);ao.context&&ao.context.forEach(so=>{eo.push({readableBinding:`Action ${io+1}.${so.label}`,runtimeBinding:`actions.${io}.${so.value}`,category:"Actions",icon:"JourneyAction",display:{name:so.label}})})}),eo},getEmbedBindings=()=>{let to=[];return to=[{type:"context",runtimeBinding:`${makePropSafe("embed")}`,readableBinding:"ParentWindow",category:"Embed",icon:"DistributeVertically"}],to},getSchemaForDatasourcePlus=(to,ue)=>{const no=(to==null?void 0:to.startsWith("view_"))?{type:"viewV2",id:to,tableId:to.split("_").slice(1,3).join("_")}:{type:"table",tableId:to};return getSchemaForDatasource(null,no,ue)},getSchemaForDatasource=(to,ue,eo)=>{var oo,io;eo=eo||{};let no,ro;if(ue){const{type:ao}=ue,so=get_store_value(tables).list;if(ao==="provider"){const ho=findComponent(to==null?void 0:to.props,ue.providerId),_o=getDatasourceForProvider(to,ho);return getSchemaForDatasource(to,_o,eo)}else if(ao==="query")ro=get_store_value(queries).list.find(_o=>_o._id===ue._id);else if(ao==="field"){ro={name:ue.fieldName};const{fieldType:ho}=ue;ho==="attachment"?no={url:{type:"string"},name:{type:"string"}}:ho==="array"&&(no={value:{type:"string"}})}else if(ao==="jsonarray"){ro=so.find(_o=>_o._id===ue.tableId);let ho=ro==null?void 0:ro.schema;no=getJSONArrayDatasourceSchema(ho,ue)}else if(ao==="queryarray"){ro=get_store_value(queries).list.find(bo=>bo._id===ue.tableId);let _o=ro==null?void 0:ro.schema,go=ro==null?void 0:ro.nestedSchemaFields;no=generateQueryArraySchemas(_o,go),no=getJSONArrayDatasourceSchema(no,ue)}else ro=so.find(ho=>ho._id===ue.tableId);if(ro&&!no)if(ao==="view")no=fp$1.cloneDeep((io=(oo=ro.views)==null?void 0:oo[ue.name])==null?void 0:io.schema);else if(ao==="viewV2"){const ho=Object.values(ro.views||{}).find(_o=>_o.id===ue.id);no=fp$1.cloneDeep(ho==null?void 0:ho.schema),Object.keys(no||{}).forEach(_o=>{no[_o].visible||delete no[_o]})}else ao==="query"&&(eo.formSchema||eo.searchableSchema)?(no={},(ro.parameters||[]).forEach(_o=>{_o!=null&&_o.name&&(no[_o.name]={..._o,type:"string"})})):no=fp$1.cloneDeep(ro.schema);if(no){let ho={};Object.keys(no).forEach(_o=>{const go=no[_o];if((go==null?void 0:go.type)==="json"){const bo=convertJSONSchemaToTableSchema(go,{squashObjects:!0});Object.keys(bo).forEach(vo=>{ho[`${_o}.${vo}`]={type:bo[vo].type,nestedJSON:!0}})}}),no={...no,...ho}}const lo=ro&&(ro==null?void 0:ro.sourceType)===DB_TYPE_INTERNAL,co=["table","link","viewV2"].includes(ue.type);let uo=co,fo=co&&lo;eo.formSchema?(uo=!1,fo=!1):eo.searchableSchema&&(uo=co&&lo),no&&(uo&&(no._id={type:"string"}),fo&&(no._rev={type:"string"}));let po={};Object.entries(no||{}).forEach(([ho,_o])=>{const go=Object.values(FIELDS).find(bo=>bo.type===_o.type&&bo.subtype===_o.subtype);typeof _o=="string"?po[ho]={type:_o,name:ho,display:{type:_o}}:po[ho]={..._o,name:ho,display:{type:(go==null?void 0:go.name)||_o.type}}}),no=po}return{schema:no,table:ro}},buildFormSchema=(to,ue)=>{var oo;let eo={};if(!to)return eo;if(to._component.endsWith("formblock")){let io={};const ao=getDatasourceForProvider(ue,to),so=getSchemaForDatasource(to,ao);if(!(so!=null&&so.schema))return io;if(!to.fields)Object.values(so.schema).filter(({autocolumn:lo,name:co})=>!lo&&!["_rev","_id"].includes(co)).forEach(({name:lo})=>{io[lo]={type:so==null?void 0:so.schema[lo].type}});else{const lo=convertOldFieldFormat(to.fields||[]);lo==null||lo.forEach(({field:co,active:uo})=>{uo&&so!=null&&so.schema[co]&&(io[co]={type:so==null?void 0:so.schema[co].type})})}return io}const ro=componentStore.getComponentSettings(to._component).find(io=>io.key==="field"&&io.type.startsWith("field/"));if(ro){const io=ro.type.split("field/")[1],ao=to.field||to._instanceName;io&&ao&&(eo[ao]={type:io})}return(oo=to._children)==null||oo.forEach(io=>{const ao=buildFormSchema(io,ue);eo={...eo,...ao}}),eo},getAllStateVariables=()=>{let to=[];getAllAssets().forEach(eo=>{findAllMatchingComponents(eo.props,no=>{const ro=componentStore.getComponentSettings(no._component),oo=["buttonConfiguration","fieldConfiguration","stepConfiguration"],io=(ao,so)=>{ao!=null&&ao.length&&(ao.filter(lo=>lo.type==="event").forEach(lo=>{to.push(so[lo.key])}),ao.filter(lo=>oo.includes(lo.type)).forEach(lo=>{const co=so[lo.key];Array.isArray(co)&&co.length&&co.forEach(uo=>{let fo=uo==null?void 0:uo._component;lo.type==="stepConfiguration"&&!fo&&(fo="@budibase/standard-components/multistepformblockstep");const po=componentStore.getComponentSettings(fo);io(po,uo)})}))};io(ro,no)})}),get_store_value(screenStore).screens.forEach(eo=>{eo.onLoad&&to.push(eo.onLoad)});let ue=new Set;return to.forEach(eo=>{Array.isArray(eo)&&eo.forEach(no=>{var ro,oo,io;no["##eventHandlerType"]==="Update State"&&((ro=no.parameters)==null?void 0:ro.type)==="set"&&((oo=no.parameters)!=null&&oo.key)&&((io=no.parameters)!=null&&io.value)&&ue.add(no.parameters.key)})}),Array.from(ue)},getAllAssets=()=>{let to=[];return to=to.concat(get_store_value(layoutStore).layouts||[]),to=to.concat(get_store_value(screenStore).screens||[]),to},shouldReplaceBinding=(to,ue,eo,no)=>{if(!(to!=null&&to.includes(ue)))return!1;const ro=no.runtimeBinding.includes(no.readableBinding),oo=eo==="readableBinding",ao=Object.keys(getJsHelperList()).filter(uo=>uo.includes(ue)&&to.includes(uo));if(ao.length>0){const uo=to.indexOf(ue),fo=uo+ue.length;for(let po of ao){const ho=to.indexOf(po),_o=ho+po.length;if(uo>=ho&&fo<=_o)return!1}}if(oo&&!ro)return to.indexOf(no.readableBinding)===-1;if(oo)return!0;const so=to.replace(/\s+/g,""),lo=ue.replace(/\s+/g,"");return![`[${lo}]`,`"${lo}"`,`'${lo}'`].find(uo=>so==null?void 0:so.includes(uo))},replaceBetween=(to,ue,eo,no)=>to.substring(0,ue)+no+to.substring(eo),bindingReplacement=(to,ue,eo)=>{const no=isJSBinding(ue);no&&(ue=decodeJSBinding(ue));const ro=no?CAPTURE_VAR_INSIDE_JS:CAPTURE_VAR_INSIDE_TEMPLATE,oo=eo==="runtimeBinding"?"readableBinding":"runtimeBinding";if(typeof ue!="string")return ue;const io=to.map(lo=>lo[oo]).sort((lo,co)=>co.length-lo.length),ao=ue.match(ro)||[];let so=ue;for(let lo of ao){let co=lo,uo=co;for(let fo of io){const po=to.find(ho=>ho[oo]===fo);if(no||shouldReplaceBinding(co,fo,eo,po)){let ho;do if(ho=uo.indexOf(fo),ho!==-1){let _o=ho+fo.length,go=Array(po[eo].length+1).join("*");uo=replaceBetween(uo,ho,_o,go),co=replaceBetween(co,ho,_o,po[eo])}while(ho!==-1)}}so=so.replace(lo,co)}return no&&(so=encodeJSBinding(so)),so},extractLiteralHandlebarsID=to=>{var ue;return!to||typeof to!="string"?null:(ue=to.match(/{{\s*literal\s*\[+([^\]]+)].*}}/))==null?void 0:ue[1]},readableToRuntimeBinding=(to,ue)=>bindingReplacement(to,ue,"runtimeBinding"),runtimeToReadableBinding=(to,ue)=>bindingReplacement(to,ue,"readableBinding"),updateReferencesInObject=({obj:to,modifiedIndex:ue,action:eo,label:no,originalIndex:ro})=>{const oo=new RegExp(`{{\\s*${no}\\.(\\d+)\\.`,"g"),io=(ao,so,lo)=>ao.replace(`{{ ${no}.${so}.`,`{{ ${no}.${lo}.`);for(const ao in to)if(typeof to[ao]=="string"){let so;for(;(so=oo.exec(to[ao]))!==null;){const lo=parseInt(so[1]);eo===UpdateReferenceAction.ADD&&lo>=ue?to[ao]=io(to[ao],lo,lo+1):eo===UpdateReferenceAction.DELETE&&lo>ue?to[ao]=io(to[ao],lo,lo-1):eo===UpdateReferenceAction.MOVE&&(lo===ro?to[ao]=io(to[ao],lo,ue):ue<=lo&&ue<ro?to[ao]=io(to[ao],lo,lo+1):ue>=lo&&ue>ro&&(to[ao]=io(to[ao],lo,lo-1)))}}else typeof to[ao]=="object"&&to[ao]!==null&&updateReferencesInObject({obj:to[ao],modifiedIndex:ue,action:eo,label:no,originalIndex:ro})},migrateReferencesInObject=({obj:to,label:ue="steps",steps:eo,originalIndex:no})=>{var io;const ro=new RegExp(`{{\\s*${ue}\\.(\\d+)\\.`,"g"),oo=(ao,so,lo)=>ao.replace(`{{ ${ue}.${so}.`,`{{ ${ue}.${lo}.`);for(const ao in to)if(typeof to[ao]=="string"){let so;for(;(so=ro.exec(to[ao]))!==null;){const lo=parseInt(so[1]);to[ao]=oo(to[ao],lo,(io=eo[lo])==null?void 0:io.id)}}else typeof to[ao]=="object"&&to[ao]!==null&&migrateReferencesInObject({obj:to[ao],steps:eo,originalIndex:no})},getComponentFieldOptions=(to,ue,eo,no=!0)=>{const ro=findClosestMatchingComponent(to,ue,so=>so._component==="@budibase/standard-components/form"),oo=getDatasourceForProvider(to,ro),io=getSchemaForDatasource(to,oo,{formSchema:!0}).schema;let ao=[eo];return no&&(eo==="field/options"||eo==="field/longform")&&(ao=[eo,"field/string"]),ao=ao.map(so=>so.slice(so.indexOf("/")+1)),Object.entries(io||{}).filter(so=>ao.includes(so[1].type)).map(so=>so[0])};/*!
|
|
499
499
|
* https://github.com/Starcounter-Jack/JSON-Patch
|
|
500
500
|
* (c) 2017-2022 Joachim Wester
|
|
501
501
|
* MIT licensed
|
package/builder/index.html
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<link href="/builder/fonts/source-sans-pro/600.css" rel="stylesheet" />
|
|
10
10
|
<link href="/builder/fonts/source-sans-pro/700.css" rel="stylesheet" />
|
|
11
11
|
<link href="/builder/fonts/remixicon.css" rel="stylesheet" />
|
|
12
|
-
<script type="module" crossorigin src="/builder/assets/index-
|
|
12
|
+
<script type="module" crossorigin src="/builder/assets/index-cdea1137.js"></script>
|
|
13
13
|
<link rel="stylesheet" href="/builder/assets/index-e94680f4.css">
|
|
14
14
|
</head>
|
|
15
15
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.37",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -213,5 +213,5 @@
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
},
|
|
216
|
-
"gitHead": "
|
|
216
|
+
"gitHead": "39f78eda743e69d71d9a247f6dd63a44856b3c72"
|
|
217
217
|
}
|