@prodantix/sdk 0.7.0-beta.441 → 0.7.0-beta.443
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/chat.cjs +3 -3
- package/dist/chat.d.cts +8 -4
- package/dist/chat.d.ts +8 -4
- package/dist/chat.js +4 -4
- package/dist/chunk-X2KBTZDG.js +2 -0
- package/dist/{config-C6Yz_Tdf.d.ts → config-Bhwwo-uC.d.ts} +12 -2
- package/dist/{config-Cs3L7V_P.d.cts → config-C8WD1Pge.d.cts} +12 -2
- package/dist/ctas.iife.js +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -1
- package/dist/messenger-files.iife.js +1 -1
- package/dist/messenger.cjs +1 -1
- package/dist/messenger.d.cts +1 -1
- package/dist/messenger.d.ts +1 -1
- package/dist/messenger.iife.js +2 -2
- package/dist/messenger.js +1 -1
- package/dist/node.cjs +1 -1
- package/dist/node.js +1 -1
- package/dist/pages.iife.js +1 -1
- package/dist/web.cjs +4 -4
- package/dist/web.d.cts +2 -0
- package/dist/web.d.ts +2 -0
- package/dist/web.js +24 -24
- package/package.json +1 -1
- package/dist/chunk-L4P6GMBC.js +0 -2
package/dist/node.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var Te=Object.defineProperty;var $e=(n,e,t)=>e in n?Te(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var o=(n,e,t)=>$e(n,typeof e!="symbol"?e+"":e,t);var g=class extends Error{constructor(t,r,s){super(r,s);o(this,"code");this.code=t,this.name="ProdantixError";}},v=class extends g{constructor(e){super("config",e),this.name="ConfigError";}},y=class extends g{constructor(t,r){super("validation",r);o(this,"field");this.field=t,this.name="ValidationError";}},l=class extends g{constructor(t,r,s){super("transport",t,s);o(this,"status");this.status=r,this.name="TransportError";}};function h(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function u(){let n=globalThis.AbortController;return n?new n:void 0}var W=n=>new Promise(e=>{setTimeout(e,n);});function p(n){return n.replace(/\/+$/,"")}var b=class{constructor(){o(this,"store",new Map);}getItem(e){return this.store.get(e)??null}removeItem(e){this.store.delete(e);}setItem(e,t){this.store.set(e,t);}},S=class{constructor(e,t=()=>false){this.real=e;this.passes=t;o(this,"held",new b);o(this,"opened",false);}get isOpen(){return this.opened}open(){this.opened=true;}close(){this.opened=false;}target(e){return this.opened||this.passes(e)?this.real:this.held}getItem(e){return this.target(e).getItem(e)}removeItem(e){this.target(e).removeItem(e);}setItem(e,t){this.target(e).setItem(e,t);}};var Y={now:()=>new Date};function x(n){return n.toISOString()}function X(){if(typeof window>"u"||typeof Intl>"u")return null;let n=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof n=="string"&&n!==""?n:null}function Ae(){return globalThis.crypto}function Pe(n){n[6]=n[6]&15|64,n[8]=n[8]&63|128;let e=[];for(let t=0;t<16;t+=1)e.push(n[t].toString(16).padStart(2,"0"));return `${e[0]}${e[1]}${e[2]}${e[3]}-${e[4]}${e[5]}-${e[6]}${e[7]}-${e[8]}${e[9]}-${e[10]}${e[11]}${e[12]}${e[13]}${e[14]}${e[15]}`}function Re(){let n=Ae();if(n?.randomUUID)return n.randomUUID();let e=new Uint8Array(16);if(n?.getRandomValues)n.getRandomValues(e);else for(let t=0;t<16;t+=1)e[t]=Math.floor(Math.random()*256);return Pe(e)}var Z={uuid:Re};var Me=/^pdx_pub_(?:(?:live|test)_)?[a-z0-9]{32}$/;var Ne=/^(?:\$|[a-z])[a-z0-9_.]*$/;function C(n){let e=0;for(let t of n)e+=1;return e}function ee(n){return Me.test(n)}function Oe(n){return Ne.test(n)}function te(n){let e=C(n);if(e<1||e>200)throw new y("distinct_id","distinct_id must be between 1 and 200 characters")}function ne(n){let e=C(n);if(e<1||e>200)throw new y("event_name","event_name must be between 1 and 200 characters");if(!Oe(n))throw new y("event_name","event_name must match /^(\\$|[a-z])[a-z0-9_.]*$/")}var re="prodantix-js",se="0.7.0";var qe=n=>{};function ie(n){if(!n.apiKey||!ee(n.apiKey))throw new v("apiKey must be a public project key of the form pdx_pub_<32 lowercase alphanumerics>");if(!n.host)throw new v("host is required (the ingest base URL)");let e=p(n.host),t=n.defaultProperties,r=n.storage??new b;return {apiKey:n.apiKey,autocapture:n.autocapture??false,clock:n.clock??Y,consent:n.consent,consentMode:n.consentMode,defaultProperties:typeof t=="function"?t:()=>t??{},describeElement:n.describeElement,flagsHost:n.flagsHost?p(n.flagsHost):e,flushAt:n.flushAt??20,flushIntervalMs:n.flushIntervalMs??1e4,host:e,ids:n.ids??Z,locale:n.locale,maxQueueSize:n.maxQueueSize??1e3,maxRetries:n.maxRetries??3,namespace:L(n.apiKey),onError:n.onError??qe,os:n.os,requestTimeoutMs:n.requestTimeoutMs??1e4,sdkName:n.sdkName??re,sdkVersion:n.sdkVersion??se,sessionTracking:n.sessionTracking??false,sharedStorage:n.sharedStorage??r,socketFactory:n.socketFactory,storage:r,streamFlags:n.streamFlags??false,transport:n.transport}}function L(n){return n.slice(0,16)}var oe=(n,e)=>{let t={$cta_id:n.id,$cta_kind:n.kind,$cta_variant:n.variant.key,$cta_version:n.version},r=e===void 0?void 0:n.variant.content.buttons[e];return r&&e!==void 0&&(t.$cta_button=e,t.$cta_button_label=r.label,r.action.kind==="form"&&(t.$cta_form_id=r.action.value)),t},w=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async ctas(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=new URLSearchParams({anonymous:String(e.anonymous),device:e.device,distinct_id:e.distinctId,language:e.language,url:e.url}),s=u(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(`${this.host}/v1/ctas?${r.toString()}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(a.status<200||a.status>=300)throw new l(`ctas request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).ctas}finally{i!==void 0&&clearTimeout(i);}}};function ae(n,e,t){ne(n.eventName),te(n.distinctId);let r={distinct_id:n.distinctId,event_id:n.eventId??t.uuid(),event_name:n.eventName,properties:n.properties??{},schema_version:1,timestamp:x(n.timestamp??e.now())};return n.context&&(r.context=n.context),n.sessionId&&(r.session_id=n.sessionId),r}var m=Symbol("absent");function Ke(n,e){if(n==="distinct_id")return e.distinctId;let t=e.properties??{};if(Object.prototype.hasOwnProperty.call(t,n))return t[n];let r=e.attributes??{};return Object.prototype.hasOwnProperty.call(r,n)?r[n]:m}function f(n){return n===m?"undefined":String(n)}function le(n){return n===m?Number.NaN:Number(n)}function ce(n){return n!==m&&n!==null&&n!==""}function de(n,e){if(!Array.isArray(e))return false;let t=f(n);return e.map(r=>String(r)).includes(t)}function ue(n,e){let t=Ke(n.attribute,e),r=n.value;switch(n.op){case "is_set":return ce(t);case "is_not_set":return !ce(t);case "eq":return f(t)===f(r===void 0?m:r);case "neq":return f(t)!==f(r===void 0?m:r);case "contains":return f(t).includes(f(r===void 0?m:r));case "in":return de(t,r);case "not_in":return Array.isArray(r)?!de(t,r):false;case "gt":return E(t,r,(s,i)=>s>i);case "gte":return E(t,r,(s,i)=>s>=i);case "lt":return E(t,r,(s,i)=>s<i);case "lte":return E(t,r,(s,i)=>s<=i);case "in_cohort":return typeof r=="string"&&r!==""&&(e.cohorts??[]).includes(r);case "not_in_cohort":return typeof r=="string"&&r!==""&&!(e.cohorts??[]).includes(r);default:return false}}function E(n,e,t){let r=le(n),s=e===void 0?Number.NaN:le(e);return Number.isNaN(r)||Number.isNaN(s)?false:t(r,s)}function pe(n,e){let t=`${n}:${e}`,r=2166136261;for(let s=0;s<t.length;s++)r^=t.charCodeAt(s),r=Math.imul(r,16777619);return (r>>>0)%100}function G(n,e){return n.targeting.length===0||n.targeting.every(t=>ue(t,e))}function he(n,e){let t=pe(n.key,e.distinctId),r=n.variations??[];if(r.length===0)return n.rolloutPercentage>=100||t<n.rolloutPercentage?"true":"false";let s=0;for(let i=r.length-1;i>=0;i--)if(s+=r[i].weight,t<s)return r[i].key;return r[0].key}function j(n,e,t,r){for(let s of n.prerequisites??[]){if(r.includes(s.flagKey))return false;let i=e.find(c=>c.key===s.flagKey);if(!i||!i.enabled)return false;r.push(i.key);let a=j(i,e,t,r)&&G(i,t)&&he(i,t)===s.variationKey;if(r.pop(),!a)return false}return true}function _(n,e,t){return n.enabled?j(n,e,t,[n.key])?G(n,t)?n.rolloutPercentage>=100?{enabled:true,reason:"rollout_full"}:pe(n.key,t.distinctId)<n.rolloutPercentage?{enabled:true,reason:"rollout"}:{enabled:false,reason:"rollout_excluded"}:{enabled:false,reason:"targeting"}:{enabled:false,reason:"prerequisite"}:{enabled:false,reason:"disabled"}}function ge(n,e){let t={};for(let r of n)t[r.key]=_(r,n,e).enabled;return t}function V(n,e,t){let r=n.variations??[],s=r[0];if(!s)return null;if(!n.enabled||!j(n,e,t,[n.key])||!G(n,t))return s;let i=he(n,t);return r.find(a=>a.key===i)??s}function fe(n){return n.some(e=>e.targeting.some(t=>t.op==="in_cohort"||t.op==="not_in_cohort"))}function me(n){return `40${JSON.stringify(n)}`}function ye(){return "3"}function ve(n){let e=n.charAt(0),t=n.slice(1);if(e==="2")return {kind:"ping"};if(e==="1")return {kind:"disconnect"};if(e==="0"){let a=U(t);return {kind:"open",pingInterval:typeof a?.pingInterval=="number"?a.pingInterval:25e3,pingTimeout:typeof a?.pingTimeout=="number"?a.pingTimeout:2e4}}if(e!=="4")return {kind:"other"};let r=t.charAt(0),s=t.slice(1);if(r==="0")return {kind:"connected"};if(r==="1")return {kind:"disconnect"};if(r==="4"){let a=U(s);return {kind:"connectError",message:typeof a?.message=="string"?a.message:"refused"}}if(r!=="2")return {kind:"other"};let i=U(s);return !Array.isArray(i)||typeof i[0]!="string"?{kind:"other"}:{kind:"event",name:i[0],payload:i[1]}}function U(n){try{return JSON.parse(n)}catch{return null}}var De="/socket.io/?EIO=4&transport=websocket",Le=250,I=class{constructor(e){this.options=e;o(this,"socket",null);o(this,"heartbeat",null);o(this,"pending",null);o(this,"lastKey","");o(this,"ready",false);o(this,"closed",false);o(this,"heartbeatWindow",45e3);o(this,"factory");o(this,"setTimer");o(this,"clearTimer");this.factory=e.socketFactory??Ge,this.setTimer=e.setTimer??((t,r)=>setTimeout(t,r)),this.clearTimer=e.clearTimer??(t=>clearTimeout(t));}open(){if(this.socket||this.closed)return;let e=`${this.options.host.replace(/^http/,"ws").replace(/\/+$/,"")}${De}`,t;try{t=this.factory(e);}catch{this.options.onClosed(false);return}this.socket=t,t.onmessage=r=>this.receive(String(r.data)),t.onerror=()=>t.close(),t.onclose=()=>this.fell();}close(){this.closed=true,this.stopHeartbeat(),this.pending!==null&&this.clearTimer(this.pending),this.pending=null;let e=this.socket;this.socket=null,e?.close();}receive(e){let t=ve(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),this.socket?.send(me({projectKey:this.options.projectKey}));return}if(t.kind==="ping"){this.armHeartbeat(),this.socket?.send(ye());return}if(t.kind==="connectError"||t.kind==="disconnect"){this.stopHeartbeat(),this.socket?.close();return}if(t.kind==="event"){if(t.name==="ready"){this.ready=true;return}if(t.name==="flagChange"){let r=t.payload?.key;this.lastKey=typeof r=="string"?r:"",this.pending===null&&(this.pending=this.setTimer(()=>{this.pending=null,this.options.onChange(this.lastKey);},Le));}}}fell(){this.stopHeartbeat();let e=this.ready;this.socket=null,this.ready=false,this.closed||this.options.onClosed(e);}armHeartbeat(e){e!==void 0&&(this.heartbeatWindow=e),this.stopHeartbeat(),this.heartbeat=this.setTimer(()=>this.socket?.close(),this.heartbeatWindow);}stopHeartbeat(){this.heartbeat!==null&&this.clearTimer(this.heartbeat),this.heartbeat=null;}};function Ge(n){let e=globalThis.WebSocket;if(!e)throw new l("no WebSocket");return new e(n)}var F=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async fetchAll(e){return (await this.fetchDecisions(e)).flags}async fetchDecisions(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags?distinct_id=${encodeURIComponent(e)}`,s=u(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`flags request failed with status ${a.status}`,a.status);let c=JSON.parse(await a.text());return {flags:c.flags??{},variants:c.variants??{}}}finally{i!==void 0&&clearTimeout(i);}}async snapshot(){let e=this.fetch;if(!e)throw new l("no fetch implementation available in this runtime");let t=`${this.host}/v1/flags/snapshot`,r=u(),s=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let i=await e(t,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r?.signal});if(!i.ok)throw new l(`flag snapshot request failed with status ${i.status}`,i.status);let a=JSON.parse(await i.text()),c={flags:a.flags??[],generatedAt:a.generatedAt};return typeof a.socketUrl=="string"&&a.socketUrl!==""&&(c.socketUrl=a.socketUrl),c}finally{s!==void 0&&clearTimeout(s);}}async memberships(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags/memberships?distinct_id=${encodeURIComponent(e)}`,s=u(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`memberships request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).cohorts??[]}finally{i!==void 0&&clearTimeout(i);}}};var B=class extends Error{constructor(t,r,s){super(s);o(this,"fields");o(this,"status");this.name="FormRefusedError",this.status=t,this.fields=r;}},T=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async request(e,t){let r=this.fetch;if(!r)throw new l("no fetch implementation available in this runtime");let s=u(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a={authorization:`Bearer ${this.projectKey}`};t.body!==void 0&&(a["content-type"]="application/json");let c=await r(`${this.host}${e}`,{body:t.body,headers:a,method:t.method,signal:s?.signal});return {status:c.status,text:await c.text()}}finally{i!==void 0&&clearTimeout(i);}}async form(e,t){let{status:r,text:s}=await this.request(`/v1/forms/${encodeURIComponent(e)}?distinct_id=${encodeURIComponent(t)}`,{method:"GET"});if(r<200||r>=300)throw new l(`form request failed with status ${r}`,r);return JSON.parse(s)}async submit(e,t){let{status:r,text:s}=await this.request(`/v1/forms/${encodeURIComponent(e)}/submissions`,{body:JSON.stringify(t),method:"POST"});if(r>=200&&r<300)return JSON.parse(s).afterSubmit;let i=[],a=`form submission failed with status ${r}`;try{let c=JSON.parse(s);i=c.error?.fields??[],a=c.error?.message??a;}catch{i=[];}throw new B(r,i,a)}};var be="$survey_shown",Se="$survey_dismissed",ke="$survey_sent",$=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async surveys(e,t){let r=this.fetch;if(!r)throw new l("no fetch implementation available in this runtime");let s=u(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await r(`${this.host}/v1/surveys?distinct_id=${encodeURIComponent(e)}${t?`&lang=${encodeURIComponent(t)}`:""}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`surveys request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).surveys??[]}finally{i!==void 0&&clearTimeout(i);}}};function A(n,e){let t={$survey_id:n.id,$survey_iteration:n.iteration,$survey_name:n.name};for(let[r,s]of Object.entries(e))t[`$survey_response_${r}`]=s;return t}var P=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async guides(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=u(),s=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let i=await t(`${this.host}/v1/guides?distinct_id=${encodeURIComponent(e)}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r?.signal});if(!i.ok)throw new l(`guides request failed with status ${i.status}`,i.status);return JSON.parse(await i.text()).guides??[]}finally{s!==void 0&&clearTimeout(s);}}};function xe(n,e){let t={$guide_id:n.id,$guide_iteration:n.iteration,$guide_name:n.name};return e!==void 0&&(t.$guide_step_id=e),t}function H(n){if(typeof n!="string")return;let e=Array.from(n).length;return e>=1&&e<=200?n:void 0}function J(n,e){return `pdx.${n}.${e}`}var z="consent",je=["identityLink","analytics","marketing","functional"];function k(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let s of je){let i=t[s];typeof i=="boolean"&&(r[s]=i);}return typeof t.version=="number"&&Number.isInteger(t.version)&&(r.version=t.version),Array.isArray(t.categories)&&t.categories.every(s=>typeof s=="string")&&(r.categories=t.categories),Object.keys(r).length===0?null:r}catch{return null}}var Ce=n=>n.endsWith(`.${z}`);function M(n,e){return k(n.getItem(J(e,z)))}function Ve(n,e,t){let r=J(e,z),s=k(JSON.stringify(t)),i=s===null?null:k(JSON.stringify({...M(n,e)??{},...s}));if(i===null){n.removeItem(r);return}n.setItem(r,JSON.stringify(i));}var R=class{constructor(e,t,r,s){this.storage=e;this.shared=t;this.ids=r;this.namespace=s;o(this,"anonymousId");o(this,"distinctId");o(this,"identified");this.refresh();}refresh(){let e=H(this.shared.getItem(this.key("anonymous_id"))),t=H(this.storage.getItem(this.key("anonymous_id")));e?(this.anonymousId=e,t!==e&&this.storage.setItem(this.key("anonymous_id"),e)):t?(this.anonymousId=t,this.shared.setItem(this.key("anonymous_id"),t)):(this.anonymousId=this.ids.uuid(),this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId));let r=H(this.storage.getItem(this.key("distinct_id")));r?(this.distinctId=r,this.identified=true):(this.distinctId=this.anonymousId,this.identified=false);}getAnonymousId(){return this.anonymousId}getDistinctId(){return this.distinctId}isIdentified(){return this.identified}snapshot(){return {anonymousId:this.anonymousId,distinctId:this.distinctId,identified:this.identified}}consent(){return M(this.shared,this.namespace)}setConsent(e){Ve(this.shared,this.namespace,e);}assumeAnonymousId(e){this.anonymousId=e,this.shared.setItem(this.key("anonymous_id"),e),this.storage.setItem(this.key("anonymous_id"),e),this.identified||(this.distinctId=e);}identify(e){let t=!this.identified||this.distinctId!==e,r=this.storage.getItem(this.key("linked_anonymous_id")),s=t||r!==this.anonymousId;return this.distinctId=e,this.identified=true,t&&this.storage.setItem(this.key("distinct_id"),e),!s||this.consent()?.identityLink===false?{changed:t}:(this.storage.setItem(this.key("linked_anonymous_id"),this.anonymousId),{anonymousToLink:this.anonymousId,changed:t})}reset(){this.anonymousId=this.ids.uuid(),this.distinctId=this.anonymousId,this.identified=false,this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.removeItem(this.key("distinct_id")),this.storage.removeItem(this.key("linked_anonymous_id"));}key(e){return J(this.namespace,e)}};var N=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async inbox(e){let t=this.requireFetch(),r=`${this.host}/v1/messages?distinct_id=${encodeURIComponent(e)}`,s=await this.request(t,r,{headers:this.authHeaders(),method:"GET"});if(!s.ok)throw new l(`inbox request failed with status ${s.status}`,s.status);return JSON.parse(await s.text()).messages??[]}async markRead(e,t){let r=this.requireFetch(),s=`${this.host}/v1/messages/read`,i=await this.request(r,s,{body:JSON.stringify({distinct_id:t,message_id:e}),headers:{...this.authHeaders(),"content-type":"application/json"},method:"POST"});if(!i.ok)throw new l(`mark-read request failed with status ${i.status}`,i.status)}requireFetch(){if(!this.fetch)throw new l("no fetch implementation available in this runtime");return this.fetch}authHeaders(){return {authorization:`Bearer ${this.projectKey}`}}async request(e,t,r){let s=u(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{return await e(t,{...r,signal:s?.signal})}finally{i!==void 0&&clearTimeout(i);}}};var O=class{constructor(e,t){this.maxSize=e;this.onOverflow=t;o(this,"events",[]);}get size(){return this.events.length}enqueue(e){this.events.push(e),this.enforceCap();}restore(e){this.events.push(...e),this.enforceCap();}requeue(e){this.events.unshift(...e),this.enforceCap();}drain(e){let t=e===void 0?this.events.length:Math.min(e,this.events.length);return this.events.splice(0,t)}snapshot(){return [...this.events]}enforceCap(){if(this.events.length<=this.maxSize)return;let e=this.events.splice(0,this.events.length-this.maxSize);this.onOverflow?.({dropped:e});}};var Ue={idleMs:18e5,maxMs:864e5,throttleMs:1e4};function Be(n){return `pdx.${n}.session`}var q=class{constructor(e,t,r,s,i=Ue){this.storage=e;this.ids=t;this.clock=r;this.namespace=s;this.options=i;}current(){return this.touch().id}startedAt(){return this.touch().startedAt}reset(){this.storage.removeItem(this.key());}touch(){let e=this.clock.now().getTime(),t=this.live(this.read(),e);if(t===void 0)return this.write({id:this.ids.uuid(),lastActivityAt:e,startedAt:e});if(e-t.lastActivityAt<=this.options.throttleMs)return t;let r=this.live(this.read(),e),s=r!==void 0&&r.id!==t.id?r:t;return this.write({...s,lastActivityAt:e})}live(e,t){if(e!==void 0&&!(t-e.lastActivityAt>this.options.idleMs||t-e.startedAt>this.options.maxMs))return e}write(e){return this.storage.setItem(this.key(),JSON.stringify(e)),e}read(){let e=this.storage.getItem(this.key());if(e)try{let t=JSON.parse(e);return typeof t.id=="string"&&typeof t.startedAt=="number"&&typeof t.lastActivityAt=="number"?{id:t.id,lastActivityAt:t.lastActivityAt,startedAt:t.startedAt}:void 0}catch{return}}key(){return Be(this.namespace)}};var d={createAlias:"$create_alias",featureFlagCalled:"$feature_flag_called",group:"$group",identify:"$identify",set:"$set"};function we(n){return n>=400&&n<500&&n!==429}var K=class{constructor(e={}){o(this,"fetch");o(this,"maxRetries");o(this,"requestTimeoutMs");o(this,"baseDelayMs");o(this,"maxDelayMs");o(this,"sleep");o(this,"random");this.fetch=h(e.fetch),this.maxRetries=e.maxRetries??3,this.requestTimeoutMs=e.requestTimeoutMs??1e4,this.baseDelayMs=e.baseDelayMs??500,this.maxDelayMs=e.maxDelayMs??3e4,this.sleep=e.sleep??W,this.random=e.random??Math.random;}async send(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=JSON.stringify(e.body),s;for(let i=0;i<=this.maxRetries;i+=1){try{let a=await this.attempt(t,e,r);if(a.ok)return;if(we(a.status))throw new l(`ingest rejected batch with status ${a.status}`,a.status);s=new l(`ingest transient status ${a.status}`,a.status);}catch(a){if(a instanceof l&&a.status!==void 0&&we(a.status))throw a;s=a;}i<this.maxRetries&&await this.sleep(this.backoff(i));}throw new l("ingest delivery failed after retries",void 0,{cause:s})}async attempt(e,t,r){let s=u(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{return await e(t.url,{body:r,headers:{authorization:`Bearer ${t.projectKey}`,"content-type":"application/json"},method:"POST",signal:s?.signal})}finally{i!==void 0&&clearTimeout(i);}}backoff(e){return Math.min(this.maxDelayMs,this.baseDelayMs*2**e)+this.random()*this.baseDelayMs}};var He="queue",Je=1e3,Ee=3e4,Q=n=>{let e={};return n.avatar!==void 0&&(e.$avatar=n.avatar),n.email!==void 0&&(e.$email=n.email),n.name!==void 0&&(e.$name=n.name),n.phone!==void 0&&(e.$phone=n.phone),e},D=class{constructor(e){o(this,"config");o(this,"identity");o(this,"session");o(this,"queue");o(this,"transport");o(this,"flagsClient");o(this,"messagesClient");o(this,"surveysClient");o(this,"guidesClient");o(this,"captureListeners",new Set);o(this,"formsClient");o(this,"ctasClient");o(this,"context");o(this,"flushTimer");o(this,"flushing",false);o(this,"cachedFlags");o(this,"cachedSnapshot");o(this,"membershipCache");o(this,"stream");o(this,"shutDown",false);o(this,"exposures",new Set);o(this,"gates");o(this,"cookielessId");o(this,"storageListeners",new Set);let t=ie(e),r=M(t.sharedStorage,t.namespace)??t.consent??null;if(this.gates=[new S(t.storage),new S(t.sharedStorage,Ce)],t.consentMode!=="banner"||r?.analytics===true)for(let a of this.gates)a.open();let[s,i]=this.gates;this.config={...t,sharedStorage:i,storage:s},this.identity=new R(this.config.storage,this.config.sharedStorage,this.config.ids,this.config.namespace),this.config.consent!==void 0&&this.identity.setConsent(this.config.consent),this.session=this.config.sessionTracking?new q(this.config.sharedStorage,this.config.ids,this.config.clock,this.config.namespace):void 0,this.queue=new O(this.config.maxQueueSize,({dropped:a})=>{this.config.onError(new g("queue_overflow",`event queue overflow: dropped ${a.length} oldest event(s)`));}),this.transport=this.config.transport??new K({maxRetries:this.config.maxRetries,requestTimeoutMs:this.config.requestTimeoutMs}),this.flagsClient=new F({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.messagesClient=new N({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.surveysClient=new $({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.guidesClient=new P({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.formsClient=new T({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.ctasClient=new w({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.context={sdk:this.config.sdkName,sdk_version:this.config.sdkVersion},this.config.os&&(this.context.os=this.config.os),this.config.locale&&(this.context.locale=this.config.locale),this.restoreQueue(),this.startTimer();}get distinctId(){return this.identity.getDistinctId()}get anonymousId(){return this.identity.getAnonymousId()}get isIdentified(){return this.identity.isIdentified()}get sessionId(){return this.session?.current()}get sessionStartedAt(){return this.session?.startedAt()}capture(e,t={}){try{this.identity.refresh();let r={...this.config.defaultProperties(),...t.element===void 0?{}:this.config.describeElement?.(t.element)??{},...t.properties??{}},s=ae({context:this.context,distinctId:t.distinctId??this.identity.getDistinctId(),eventName:e,properties:r,sessionId:t.sessionId??this.session?.current(),timestamp:t.timestamp},this.config.clock,this.config.ids);this.enqueue(s);}catch(r){this.config.onError(r);}for(let r of this.captureListeners)try{r(e);}catch(s){this.config.onError(s);}}onCapture(e){return this.captureListeners.add(e),()=>{this.captureListeners.delete(e);}}identify(e,t={}){if(this.isCookieless())return;this.identity.refresh();let r=this.identity.identify(e),s={};r.anonymousToLink!==void 0&&(s.$anon_distinct_id=r.anonymousToLink);let i=X(),a={...i===null?{}:{$timezone:i},...Q(t.traits??{}),...t.set??{}};Object.keys(a).length>0&&(s.$set=a),this.capture(d.identify,{properties:s});}link(e,t,r){if(this.isCookieless())return;let s={$anon_distinct_id:t},i=Q(r??{});Object.keys(i).length>0&&(s.$set=i),this.capture(d.identify,{distinctId:e,properties:s});}setConsent(e){this.identity.setConsent(e),e.analytics===true&&this.allowStorage(),e.analytics===false&&this.config.consentMode==="banner"&&this.forbidStorage();}isCookieless(){return !this.gates[0].isOpen}takeCookielessId(e){this.cookielessId=e,this.isCookieless()&&this.identity.assumeAnonymousId(e);}allowStorage(){if(this.isCookieless()){for(let e of this.gates)e.open();this.identity.refresh();for(let e of [...this.storageListeners])e();}}onStorageAllowed(e){return this.storageListeners.add(e),()=>{this.storageListeners.delete(e);}}forbidStorage(){if(!this.isCookieless()){for(let e of ["anonymous_id","distinct_id","linked_anonymous_id","session"])this.config.storage.removeItem(`pdx.${this.config.namespace}.${e}`),this.config.sharedStorage.removeItem(`pdx.${this.config.namespace}.${e}`);for(let e of this.gates)e.close();this.identity.refresh(),this.cookielessId!==void 0&&this.identity.assumeAnonymousId(this.cookielessId);}}consent(){return this.identity.consent()}alias(e){this.capture(d.createAlias,{properties:{alias:e}});}group(e,t,r){let s={$group_key:t,$group_type:e};r&&(s.$set=r),this.capture(d.group,{properties:s});}setPersonProperties(e,t){if(this.isCookieless())return;let r={};e&&(r.$set=e),t&&(r.$set_once=t),this.capture(d.set,{properties:r});}setPersonTraits(e){if(this.isCookieless())return;let t=Q(e);Object.keys(t).length!==0&&this.capture(d.set,{properties:{$set:t}});}async getAllFlags(){let e=this.identity.getDistinctId(),t=await this.flagsClient.fetchDecisions(e);return this.cachedFlags={distinctId:e,flags:t.flags,variants:t.variants??{}},t.flags}async isFeatureEnabled(e){let r=(await this.getAllFlags())[e]??false;return this.recordExposure(e,this.cachedFlags?.variants[e]?.key??String(r)),r}async getVariant(e){let t=await this.getAllFlags(),r=this.cachedFlags?.variants[e]??null;return this.recordExposure(e,r?.key??String(t[e]??false)),r}async getVariantLocal(e,t={}){let r=await this.flagSnapshot(),s=r.flags.find(Fe=>Fe.key===e),i=await this.localContext(t,r.flags),a=s?V(s,r.flags,i):null,c=s?_(s,r.flags,i).enabled:false;return this.recordExposure(e,a?.key??String(c)),a?{key:a.key,value:a.value}:null}recordExposure(e,t){let r=`${this.identity.getDistinctId()} ${e} ${t}`;this.exposures.has(r)||(this.exposures.add(r),this.capture(d.featureFlagCalled,{properties:{$feature_flag:e,$feature_flag_response:t}}));}getCachedFlag(e){if(!(!this.cachedFlags||this.cachedFlags.distinctId!==this.distinctId))return this.cachedFlags.flags[e]}async getLocalFlags(e={}){let t=await this.flagSnapshot();return ge(t.flags,await this.localContext(e,t.flags))}async isFeatureEnabledLocal(e,t={}){let r=await this.flagSnapshot(),s=r.flags.find(c=>c.key===e),i=await this.localContext(t,r.flags),a=s?_(s,r.flags,i).enabled:false;return this.recordExposure(e,(s?V(s,r.flags,i)?.key:void 0)??String(a)),a}async localContext(e,t){let r=this.identity.getDistinctId(),s=e.cohorts;if(s===void 0&&fe(t)){let i=this.config.clock.now().getTime();this.membershipCache&&this.membershipCache.distinctId===r&&i-this.membershipCache.fetchedAt<Ee?s=this.membershipCache.cohorts:(s=await this.flagsClient.memberships(r),this.membershipCache={cohorts:s,distinctId:r,fetchedAt:i});}return {attributes:e.attributes,cohorts:s,distinctId:r,properties:e.properties}}async flagSnapshot(){let e=this.config.clock.now().getTime();if(this.cachedSnapshot&&e-this.cachedSnapshot.fetchedAt<Ee)return this.cachedSnapshot.snapshot;let t=await this.flagsClient.snapshot();return this.cachedSnapshot={fetchedAt:e,snapshot:t},this.maybeStream(t),t}maybeStream(e){if(!this.config.streamFlags||this.shutDown||this.stream||!e.socketUrl)return;let t=new I({host:e.socketUrl,onChange:()=>{this.cachedSnapshot=void 0,this.flagSnapshot().catch(r=>this.config.onError(r));},onClosed:r=>{this.stream=void 0,r&&this.maybeStream(e);},projectKey:this.config.apiKey,socketFactory:this.config.socketFactory});this.stream=t,t.open();}async getInbox(){return this.messagesClient.inbox(this.identity.getDistinctId())}async markMessageRead(e){await this.messagesClient.markRead(e,this.identity.getDistinctId());}async getSurveys(e){return this.surveysClient.surveys(this.identity.getDistinctId(),e??this.config.locale)}captureSurveyShown(e){this.capture(be,{properties:A(e,{})});}captureSurveyDismissed(e){this.capture(Se,{properties:A(e,{})});}captureSurveySent(e,t){this.capture(ke,{properties:A(e,t)});}async getGuides(){return this.guidesClient.guides(this.identity.getDistinctId())}captureGuide(e,t,r){this.capture(e,{properties:xe(t,r)});}async getForm(e){return this.formsClient.form(e,this.identity.getDistinctId())}async submitForm(e,t,r,s){let{$page_id:i,$page_variant:a}=this.config.defaultProperties();return this.formsClient.submit(e,{answers:t,challenge:r,distinctId:this.identity.getDistinctId(),isAnonymous:!this.identity.isIdentified(),pageUrl:typeof window>"u"?"":window.location.href,solution:s,...typeof i=="string"&&typeof a=="string"?{pageId:i,pageVariant:a}:{}})}async getCtas(e){return this.ctasClient.ctas({...e,anonymous:!this.identity.isIdentified(),distinctId:this.identity.getDistinctId()})}captureCta(e,t,r){this.capture(e,{properties:oe(t,r)});}async flush(){if(this.flushing||this.queue.size===0)return;this.flushing=true;let e=this.queue.drain(Je);try{await this.transport.send({body:{events:e,sent_at:x(this.config.clock.now())},projectKey:this.config.apiKey,url:`${this.config.host}/v1/events`}),this.persistQueue();}catch(t){this.queue.requeue(e),this.persistQueue(),this.config.onError(t);}finally{this.flushing=false;}}reset(){this.session?.reset(),this.identity.reset(),this.cachedFlags=void 0,this.cachedSnapshot=void 0,this.membershipCache=void 0;}async shutdown(){this.shutDown=true,this.stopTimer(),this.stream?.close(),this.stream=void 0,await this.flush();}enqueue(e){this.queue.enqueue(e),this.persistQueue(),this.queue.size>=this.config.flushAt&&this.flush();}persistQueue(){try{this.config.storage.setItem(this.persistKey(),JSON.stringify(this.queue.snapshot()));}catch(e){this.config.onError(e);}}restoreQueue(){try{let e=this.config.storage.getItem(this.persistKey());if(!e)return;let t=JSON.parse(e);Array.isArray(t)&&this.queue.restore(t);}catch(e){this.config.onError(e);}}startTimer(){if(this.config.flushIntervalMs<=0)return;let e=setInterval(()=>{this.flush();},this.config.flushIntervalMs),t=e;typeof t.unref=="function"&&t.unref(),this.flushTimer=e;}stopTimer(){this.flushTimer!==void 0&&(clearInterval(this.flushTimer),this.flushTimer=void 0);}persistKey(){return `pdx.${this.config.namespace}.${He}`}};var ze=200;function _e(){return globalThis.process}function Qe(n){_e()?.on("beforeExit",()=>{n.flush();});}function Nn(n){let e=_e(),t={...n,os:n.os??(e?.platform?e.platform.slice(0,50):void 0),streamFlags:n.streamFlags??true},r=new D(t);return Qe(r),r}function On(n,e){let t=L(e),r=We(n,`pdx_${t}`);if(r===void 0)return null;let s=Ye(r);if(s===void 0)return null;let i=Ie(s[`pdx.${t}.anonymous_id`]);return i===void 0?null:{anonymousId:i,consent:k(s[`pdx.${t}.consent`]),sessionId:Xe(s[`pdx.${t}.session`])}}function We(n,e){let t=`${e}=`;for(let r of n.split(";")){let s=r.trim();if(s.startsWith(t))return s.slice(t.length)}}function Ye(n){try{let e=JSON.parse(decodeURIComponent(n));return e===null||typeof e!="object"||Array.isArray(e)?void 0:e}catch{return}}function Ie(n){if(typeof n!="string")return;let e=C(n);return e>=1&&e<=ze?n:void 0}function Xe(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);return e===null||typeof e!="object"||typeof e.startedAt!="number"||typeof e.lastActivityAt!="number"?null:Ie(e.id)??null}catch{return null}}exports.createNodeClient=Nn;exports.readSharedIdentity=On;//# sourceMappingURL=node.cjs.map
|
|
1
|
+
'use strict';var Te=Object.defineProperty;var $e=(n,e,t)=>e in n?Te(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var o=(n,e,t)=>$e(n,typeof e!="symbol"?e+"":e,t);var g=class extends Error{constructor(t,r,s){super(r,s);o(this,"code");this.code=t,this.name="ProdantixError";}},v=class extends g{constructor(e){super("config",e),this.name="ConfigError";}},y=class extends g{constructor(t,r){super("validation",r);o(this,"field");this.field=t,this.name="ValidationError";}},l=class extends g{constructor(t,r,s){super("transport",t,s);o(this,"status");this.status=r,this.name="TransportError";}};function h(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function d(){let n=globalThis.AbortController;return n?new n:void 0}var Q=n=>new Promise(e=>{setTimeout(e,n);});function p(n){return n.replace(/\/+$/,"")}var b=class{constructor(){o(this,"store",new Map);}getItem(e){return this.store.get(e)??null}removeItem(e){this.store.delete(e);}setItem(e,t){this.store.set(e,t);}},S=class{constructor(e,t=()=>false){this.real=e;this.passes=t;o(this,"held",new b);o(this,"opened",false);}get isOpen(){return this.opened}open(){this.opened=true;}close(){this.opened=false;}target(e){return this.opened||this.passes(e)?this.real:this.held}getItem(e){return this.target(e).getItem(e)}removeItem(e){this.target(e).removeItem(e);}setItem(e,t){this.target(e).setItem(e,t);}};var Y={now:()=>new Date};function x(n){return n.toISOString()}function X(){if(typeof window>"u"||typeof Intl>"u")return null;let n=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof n=="string"&&n!==""?n:null}function Ae(){return globalThis.crypto}function Pe(n){n[6]=n[6]&15|64,n[8]=n[8]&63|128;let e=[];for(let t=0;t<16;t+=1)e.push(n[t].toString(16).padStart(2,"0"));return `${e[0]}${e[1]}${e[2]}${e[3]}-${e[4]}${e[5]}-${e[6]}${e[7]}-${e[8]}${e[9]}-${e[10]}${e[11]}${e[12]}${e[13]}${e[14]}${e[15]}`}function Re(){let n=Ae();if(n?.randomUUID)return n.randomUUID();let e=new Uint8Array(16);if(n?.getRandomValues)n.getRandomValues(e);else for(let t=0;t<16;t+=1)e[t]=Math.floor(Math.random()*256);return Pe(e)}var Z={uuid:Re};var Me=/^pdx_pub_(?:(?:live|test)_)?[a-z0-9]{32}$/;var Ne=/^(?:\$|[a-z])[a-z0-9_.]*$/;function w(n){let e=0;for(let t of n)e+=1;return e}function ee(n){return Me.test(n)}function Oe(n){return Ne.test(n)}function te(n){let e=w(n);if(e<1||e>200)throw new y("distinct_id","distinct_id must be between 1 and 200 characters")}function ne(n){let e=w(n);if(e<1||e>200)throw new y("event_name","event_name must be between 1 and 200 characters");if(!Oe(n))throw new y("event_name","event_name must match /^(\\$|[a-z])[a-z0-9_.]*$/")}var re="prodantix-js",se="0.7.0";var qe=n=>{};function ie(n){if(!n.apiKey||!ee(n.apiKey))throw new v("apiKey must be a public project key of the form pdx_pub_<32 lowercase alphanumerics>");if(!n.host)throw new v("host is required (the ingest base URL)");let e=p(n.host),t=n.defaultProperties,r=n.storage??new b;return {apiKey:n.apiKey,autocapture:n.autocapture??false,clock:n.clock??Y,consent:n.consent,consentMode:n.consentMode,defaultProperties:typeof t=="function"?t:()=>t??{},describeElement:n.describeElement,flagsHost:n.flagsHost?p(n.flagsHost):e,flushAt:n.flushAt??20,flushIntervalMs:n.flushIntervalMs??1e4,host:e,ids:n.ids??Z,locale:n.locale,maxQueueSize:n.maxQueueSize??1e3,maxRetries:n.maxRetries??3,namespace:L(n.apiKey),onError:n.onError??qe,os:n.os,requestTimeoutMs:n.requestTimeoutMs??1e4,sdkName:n.sdkName??re,sdkVersion:n.sdkVersion??se,sessionTracking:n.sessionTracking??false,sharedStorage:n.sharedStorage??r,socketFactory:n.socketFactory,storage:r,streamFlags:n.streamFlags??false,transport:n.transport}}function L(n){return n.slice(0,16)}var oe=(n,e)=>{let t={$cta_id:n.id,$cta_kind:n.kind,$cta_variant:n.variant.key,$cta_version:n.version},r=e===void 0?void 0:n.variant.content.buttons[e];return r&&e!==void 0&&(t.$cta_button=e,t.$cta_button_label=r.label,r.action.kind==="form"&&(t.$cta_form_id=r.action.value)),t},C=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async ctas(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=new URLSearchParams({anonymous:String(e.anonymous),device:e.device,distinct_id:e.distinctId,language:e.language,url:e.url}),s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(`${this.host}/v1/ctas?${r.toString()}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(a.status<200||a.status>=300)throw new l(`ctas request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).ctas}finally{i!==void 0&&clearTimeout(i);}}};function ae(n,e,t){ne(n.eventName),te(n.distinctId);let r={distinct_id:n.distinctId,event_id:n.eventId??t.uuid(),event_name:n.eventName,properties:n.properties??{},schema_version:1,timestamp:x(n.timestamp??e.now())};return n.context&&(r.context=n.context),n.sessionId&&(r.session_id=n.sessionId),r}var m=Symbol("absent");function Ke(n,e){if(n==="distinct_id")return e.distinctId;let t=e.properties??{};if(Object.prototype.hasOwnProperty.call(t,n))return t[n];let r=e.attributes??{};return Object.prototype.hasOwnProperty.call(r,n)?r[n]:m}function f(n){return n===m?"undefined":String(n)}function le(n){return n===m?Number.NaN:Number(n)}function ce(n){return n!==m&&n!==null&&n!==""}function ue(n,e){if(!Array.isArray(e))return false;let t=f(n);return e.map(r=>String(r)).includes(t)}function de(n,e){let t=Ke(n.attribute,e),r=n.value;switch(n.op){case "is_set":return ce(t);case "is_not_set":return !ce(t);case "eq":return f(t)===f(r===void 0?m:r);case "neq":return f(t)!==f(r===void 0?m:r);case "contains":return f(t).includes(f(r===void 0?m:r));case "in":return ue(t,r);case "not_in":return Array.isArray(r)?!ue(t,r):false;case "gt":return _(t,r,(s,i)=>s>i);case "gte":return _(t,r,(s,i)=>s>=i);case "lt":return _(t,r,(s,i)=>s<i);case "lte":return _(t,r,(s,i)=>s<=i);case "in_cohort":return typeof r=="string"&&r!==""&&(e.cohorts??[]).includes(r);case "not_in_cohort":return typeof r=="string"&&r!==""&&!(e.cohorts??[]).includes(r);default:return false}}function _(n,e,t){let r=le(n),s=e===void 0?Number.NaN:le(e);return Number.isNaN(r)||Number.isNaN(s)?false:t(r,s)}function pe(n,e){let t=`${n}:${e}`,r=2166136261;for(let s=0;s<t.length;s++)r^=t.charCodeAt(s),r=Math.imul(r,16777619);return (r>>>0)%100}function G(n,e){return n.targeting.length===0||n.targeting.every(t=>de(t,e))}function he(n,e){let t=pe(n.key,e.distinctId),r=n.variations??[];if(r.length===0)return n.rolloutPercentage>=100||t<n.rolloutPercentage?"true":"false";let s=0;for(let i=r.length-1;i>=0;i--)if(s+=r[i].weight,t<s)return r[i].key;return r[0].key}function j(n,e,t,r){for(let s of n.prerequisites??[]){if(r.includes(s.flagKey))return false;let i=e.find(c=>c.key===s.flagKey);if(!i||!i.enabled)return false;r.push(i.key);let a=j(i,e,t,r)&&G(i,t)&&he(i,t)===s.variationKey;if(r.pop(),!a)return false}return true}function E(n,e,t){return n.enabled?j(n,e,t,[n.key])?G(n,t)?n.rolloutPercentage>=100?{enabled:true,reason:"rollout_full"}:pe(n.key,t.distinctId)<n.rolloutPercentage?{enabled:true,reason:"rollout"}:{enabled:false,reason:"rollout_excluded"}:{enabled:false,reason:"targeting"}:{enabled:false,reason:"prerequisite"}:{enabled:false,reason:"disabled"}}function ge(n,e){let t={};for(let r of n)t[r.key]=E(r,n,e).enabled;return t}function V(n,e,t){let r=n.variations??[],s=r[0];if(!s)return null;if(!n.enabled||!j(n,e,t,[n.key])||!G(n,t))return s;let i=he(n,t);return r.find(a=>a.key===i)??s}function fe(n){return n.some(e=>e.targeting.some(t=>t.op==="in_cohort"||t.op==="not_in_cohort"))}function me(n){return `40${JSON.stringify(n)}`}function ye(){return "3"}function ve(n){let e=n.charAt(0),t=n.slice(1);if(e==="2")return {kind:"ping"};if(e==="1")return {kind:"disconnect"};if(e==="0"){let a=U(t);return {kind:"open",pingInterval:typeof a?.pingInterval=="number"?a.pingInterval:25e3,pingTimeout:typeof a?.pingTimeout=="number"?a.pingTimeout:2e4}}if(e!=="4")return {kind:"other"};let r=t.charAt(0),s=t.slice(1);if(r==="0")return {kind:"connected"};if(r==="1")return {kind:"disconnect"};if(r==="4"){let a=U(s);return {kind:"connectError",message:typeof a?.message=="string"?a.message:"refused"}}if(r!=="2")return {kind:"other"};let i=U(s);return !Array.isArray(i)||typeof i[0]!="string"?{kind:"other"}:{kind:"event",name:i[0],payload:i[1]}}function U(n){try{return JSON.parse(n)}catch{return null}}var De="/socket.io/?EIO=4&transport=websocket",Le=250,I=class{constructor(e){this.options=e;o(this,"socket",null);o(this,"heartbeat",null);o(this,"pending",null);o(this,"lastKey","");o(this,"ready",false);o(this,"closed",false);o(this,"heartbeatWindow",45e3);o(this,"factory");o(this,"setTimer");o(this,"clearTimer");this.factory=e.socketFactory??Ge,this.setTimer=e.setTimer??((t,r)=>setTimeout(t,r)),this.clearTimer=e.clearTimer??(t=>clearTimeout(t));}open(){if(this.socket||this.closed)return;let e=`${this.options.host.replace(/^http/,"ws").replace(/\/+$/,"")}${De}`,t;try{t=this.factory(e);}catch{this.options.onClosed(false);return}this.socket=t,t.onmessage=r=>this.receive(String(r.data)),t.onerror=()=>t.close(),t.onclose=()=>this.fell();}close(){this.closed=true,this.stopHeartbeat(),this.pending!==null&&this.clearTimer(this.pending),this.pending=null;let e=this.socket;this.socket=null,e?.close();}receive(e){let t=ve(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),this.socket?.send(me({projectKey:this.options.projectKey}));return}if(t.kind==="ping"){this.armHeartbeat(),this.socket?.send(ye());return}if(t.kind==="connectError"||t.kind==="disconnect"){this.stopHeartbeat(),this.socket?.close();return}if(t.kind==="event"){if(t.name==="ready"){this.ready=true;return}if(t.name==="flagChange"){let r=t.payload?.key;this.lastKey=typeof r=="string"?r:"",this.pending===null&&(this.pending=this.setTimer(()=>{this.pending=null,this.options.onChange(this.lastKey);},Le));}}}fell(){this.stopHeartbeat();let e=this.ready;this.socket=null,this.ready=false,this.closed||this.options.onClosed(e);}armHeartbeat(e){e!==void 0&&(this.heartbeatWindow=e),this.stopHeartbeat(),this.heartbeat=this.setTimer(()=>this.socket?.close(),this.heartbeatWindow);}stopHeartbeat(){this.heartbeat!==null&&this.clearTimer(this.heartbeat),this.heartbeat=null;}};function Ge(n){let e=globalThis.WebSocket;if(!e)throw new l("no WebSocket");return new e(n)}var F=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async fetchAll(e){return (await this.fetchDecisions(e)).flags}async fetchDecisions(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags?distinct_id=${encodeURIComponent(e)}`,s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`flags request failed with status ${a.status}`,a.status);let c=JSON.parse(await a.text());return {flags:c.flags??{},variants:c.variants??{}}}finally{i!==void 0&&clearTimeout(i);}}async snapshot(){let e=this.fetch;if(!e)throw new l("no fetch implementation available in this runtime");let t=`${this.host}/v1/flags/snapshot`,r=d(),s=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let i=await e(t,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r?.signal});if(!i.ok)throw new l(`flag snapshot request failed with status ${i.status}`,i.status);let a=JSON.parse(await i.text()),c={flags:a.flags??[],generatedAt:a.generatedAt};return typeof a.socketUrl=="string"&&a.socketUrl!==""&&(c.socketUrl=a.socketUrl),c}finally{s!==void 0&&clearTimeout(s);}}async memberships(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags/memberships?distinct_id=${encodeURIComponent(e)}`,s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`memberships request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).cohorts??[]}finally{i!==void 0&&clearTimeout(i);}}};var B=class extends Error{constructor(t,r,s){super(s);o(this,"fields");o(this,"status");this.name="FormRefusedError",this.status=t,this.fields=r;}},T=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async request(e,t){let r=this.fetch;if(!r)throw new l("no fetch implementation available in this runtime");let s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a={authorization:`Bearer ${this.projectKey}`};t.body!==void 0&&(a["content-type"]="application/json");let c=await r(`${this.host}${e}`,{body:t.body,headers:a,method:t.method,signal:s?.signal});return {status:c.status,text:await c.text()}}finally{i!==void 0&&clearTimeout(i);}}async form(e,t){let{status:r,text:s}=await this.request(`/v1/forms/${encodeURIComponent(e)}?distinct_id=${encodeURIComponent(t)}`,{method:"GET"});if(r<200||r>=300)throw new l(`form request failed with status ${r}`,r);return JSON.parse(s)}async submit(e,t){let{status:r,text:s}=await this.request(`/v1/forms/${encodeURIComponent(e)}/submissions`,{body:JSON.stringify(t),method:"POST"});if(r>=200&&r<300)return JSON.parse(s).afterSubmit;let i=[],a=`form submission failed with status ${r}`;try{let c=JSON.parse(s);i=c.error?.fields??[],a=c.error?.message??a;}catch{i=[];}throw new B(r,i,a)}};var be="$survey_shown",Se="$survey_dismissed",ke="$survey_sent",$=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async surveys(e,t){let r=this.fetch;if(!r)throw new l("no fetch implementation available in this runtime");let s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{let a=await r(`${this.host}/v1/surveys?distinct_id=${encodeURIComponent(e)}${t?`&lang=${encodeURIComponent(t)}`:""}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:s?.signal});if(!a.ok)throw new l(`surveys request failed with status ${a.status}`,a.status);return JSON.parse(await a.text()).surveys??[]}finally{i!==void 0&&clearTimeout(i);}}};function A(n,e){let t={$survey_id:n.id,$survey_iteration:n.iteration,$survey_name:n.name};for(let[r,s]of Object.entries(e))t[`$survey_response_${r}`]=s;return t}var P=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async guides(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=d(),s=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let i=await t(`${this.host}/v1/guides?distinct_id=${encodeURIComponent(e)}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r?.signal});if(!i.ok)throw new l(`guides request failed with status ${i.status}`,i.status);return JSON.parse(await i.text()).guides??[]}finally{s!==void 0&&clearTimeout(s);}}};function xe(n,e){let t={$guide_id:n.id,$guide_iteration:n.iteration,$guide_name:n.name};return e!==void 0&&(t.$guide_step_id=e),t}function H(n){if(typeof n!="string")return;let e=Array.from(n).length;return e>=1&&e<=200?n:void 0}function J(n,e){return `pdx.${n}.${e}`}var z="consent",je=["identityLink","analytics","marketing","functional"];function k(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let s of je){let i=t[s];typeof i=="boolean"&&(r[s]=i);}return typeof t.version=="number"&&Number.isInteger(t.version)&&(r.version=t.version),Array.isArray(t.categories)&&t.categories.every(s=>typeof s=="string")&&(r.categories=t.categories),Object.keys(r).length===0?null:r}catch{return null}}var we=n=>n.endsWith(`.${z}`);function M(n,e){return k(n.getItem(J(e,z)))}function Ve(n,e,t){let r=J(e,z),s=k(JSON.stringify(t)),i=s===null?null:k(JSON.stringify({...M(n,e)??{},...s}));if(i===null){n.removeItem(r);return}n.setItem(r,JSON.stringify(i));}var R=class{constructor(e,t,r,s){this.storage=e;this.shared=t;this.ids=r;this.namespace=s;o(this,"anonymousId");o(this,"distinctId");o(this,"identified");this.refresh();}refresh(){let e=H(this.shared.getItem(this.key("anonymous_id"))),t=H(this.storage.getItem(this.key("anonymous_id")));e?(this.anonymousId=e,t!==e&&this.storage.setItem(this.key("anonymous_id"),e)):t?(this.anonymousId=t,this.shared.setItem(this.key("anonymous_id"),t)):(this.anonymousId=this.ids.uuid(),this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId));let r=H(this.storage.getItem(this.key("distinct_id")));r?(this.distinctId=r,this.identified=true):(this.distinctId=this.anonymousId,this.identified=false);}getAnonymousId(){return this.anonymousId}getDistinctId(){return this.distinctId}isIdentified(){return this.identified}snapshot(){return {anonymousId:this.anonymousId,distinctId:this.distinctId,identified:this.identified}}consent(){return M(this.shared,this.namespace)}setConsent(e){Ve(this.shared,this.namespace,e);}assumeAnonymousId(e){this.anonymousId=e,this.shared.setItem(this.key("anonymous_id"),e),this.storage.setItem(this.key("anonymous_id"),e),this.identified||(this.distinctId=e);}identify(e){let t=!this.identified||this.distinctId!==e,r=this.storage.getItem(this.key("linked_anonymous_id")),s=t||r!==this.anonymousId;return this.distinctId=e,this.identified=true,t&&this.storage.setItem(this.key("distinct_id"),e),!s||this.consent()?.identityLink===false?{changed:t}:(this.storage.setItem(this.key("linked_anonymous_id"),this.anonymousId),{anonymousToLink:this.anonymousId,changed:t})}reset(){this.anonymousId=this.ids.uuid(),this.distinctId=this.anonymousId,this.identified=false,this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.removeItem(this.key("distinct_id")),this.storage.removeItem(this.key("linked_anonymous_id"));}key(e){return J(this.namespace,e)}};var N=class{constructor(e){o(this,"fetch");o(this,"host");o(this,"projectKey");o(this,"requestTimeoutMs");this.fetch=h(e.fetch),this.host=p(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=e.requestTimeoutMs??1e4;}async inbox(e){let t=this.requireFetch(),r=`${this.host}/v1/messages?distinct_id=${encodeURIComponent(e)}`,s=await this.request(t,r,{headers:this.authHeaders(),method:"GET"});if(!s.ok)throw new l(`inbox request failed with status ${s.status}`,s.status);return JSON.parse(await s.text()).messages??[]}async markRead(e,t){let r=this.requireFetch(),s=`${this.host}/v1/messages/read`,i=await this.request(r,s,{body:JSON.stringify({distinct_id:t,message_id:e}),headers:{...this.authHeaders(),"content-type":"application/json"},method:"POST"});if(!i.ok)throw new l(`mark-read request failed with status ${i.status}`,i.status)}requireFetch(){if(!this.fetch)throw new l("no fetch implementation available in this runtime");return this.fetch}authHeaders(){return {authorization:`Bearer ${this.projectKey}`}}async request(e,t,r){let s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{return await e(t,{...r,signal:s?.signal})}finally{i!==void 0&&clearTimeout(i);}}};var O=class{constructor(e,t){this.maxSize=e;this.onOverflow=t;o(this,"events",[]);}get size(){return this.events.length}enqueue(e){this.events.push(e),this.enforceCap();}restore(e){this.events.push(...e),this.enforceCap();}requeue(e){this.events.unshift(...e),this.enforceCap();}drain(e){let t=e===void 0?this.events.length:Math.min(e,this.events.length);return this.events.splice(0,t)}snapshot(){return [...this.events]}enforceCap(){if(this.events.length<=this.maxSize)return;let e=this.events.splice(0,this.events.length-this.maxSize);this.onOverflow?.({dropped:e});}};var Ue={idleMs:18e5,maxMs:864e5,throttleMs:1e4};function Be(n){return `pdx.${n}.session`}var q=class{constructor(e,t,r,s,i=Ue){this.storage=e;this.ids=t;this.clock=r;this.namespace=s;this.options=i;}current(){return this.touch().id}startedAt(){return this.touch().startedAt}reset(){this.storage.removeItem(this.key());}touch(){let e=this.clock.now().getTime(),t=this.live(this.read(),e);if(t===void 0)return this.write({id:this.ids.uuid(),lastActivityAt:e,startedAt:e});if(e-t.lastActivityAt<=this.options.throttleMs)return t;let r=this.live(this.read(),e),s=r!==void 0&&r.id!==t.id?r:t;return this.write({...s,lastActivityAt:e})}live(e,t){if(e!==void 0&&!(t-e.lastActivityAt>this.options.idleMs||t-e.startedAt>this.options.maxMs))return e}write(e){return this.storage.setItem(this.key(),JSON.stringify(e)),e}read(){let e=this.storage.getItem(this.key());if(e)try{let t=JSON.parse(e);return typeof t.id=="string"&&typeof t.startedAt=="number"&&typeof t.lastActivityAt=="number"?{id:t.id,lastActivityAt:t.lastActivityAt,startedAt:t.startedAt}:void 0}catch{return}}key(){return Be(this.namespace)}};var u={createAlias:"$create_alias",featureFlagCalled:"$feature_flag_called",group:"$group",identify:"$identify",set:"$set"};function Ce(n){return n>=400&&n<500&&n!==429}var K=class{constructor(e={}){o(this,"fetch");o(this,"maxRetries");o(this,"requestTimeoutMs");o(this,"baseDelayMs");o(this,"maxDelayMs");o(this,"sleep");o(this,"random");this.fetch=h(e.fetch),this.maxRetries=e.maxRetries??3,this.requestTimeoutMs=e.requestTimeoutMs??1e4,this.baseDelayMs=e.baseDelayMs??500,this.maxDelayMs=e.maxDelayMs??3e4,this.sleep=e.sleep??Q,this.random=e.random??Math.random;}async send(e){let t=this.fetch;if(!t)throw new l("no fetch implementation available in this runtime");let r=JSON.stringify(e.body),s;for(let i=0;i<=this.maxRetries;i+=1){try{let a=await this.attempt(t,e,r);if(a.ok)return;if(Ce(a.status))throw new l(`ingest rejected batch with status ${a.status}`,a.status);s=new l(`ingest transient status ${a.status}`,a.status);}catch(a){if(a instanceof l&&a.status!==void 0&&Ce(a.status))throw a;s=a;}i<this.maxRetries&&await this.sleep(this.backoff(i));}throw new l("ingest delivery failed after retries",void 0,{cause:s})}async attempt(e,t,r){let s=d(),i=s?setTimeout(()=>s.abort(),this.requestTimeoutMs):void 0;try{return await e(t.url,{body:r,headers:{authorization:`Bearer ${t.projectKey}`,"content-type":"application/json"},method:"POST",signal:s?.signal})}finally{i!==void 0&&clearTimeout(i);}}backoff(e){return Math.min(this.maxDelayMs,this.baseDelayMs*2**e)+this.random()*this.baseDelayMs}};var He="queue",Je=1e3,_e=3e4,W=n=>{let e={};return n.avatar!==void 0&&(e.$avatar=n.avatar),n.email!==void 0&&(e.$email=n.email),n.name!==void 0&&(e.$name=n.name),n.phone!==void 0&&(e.$phone=n.phone),e},D=class{constructor(e){o(this,"config");o(this,"identity");o(this,"session");o(this,"queue");o(this,"transport");o(this,"flagsClient");o(this,"messagesClient");o(this,"surveysClient");o(this,"guidesClient");o(this,"captureListeners",new Set);o(this,"formsClient");o(this,"ctasClient");o(this,"context");o(this,"flushTimer");o(this,"flushing",false);o(this,"cachedFlags");o(this,"cachedSnapshot");o(this,"membershipCache");o(this,"stream");o(this,"shutDown",false);o(this,"exposures",new Set);o(this,"gates");o(this,"cookielessId");o(this,"storageListeners",new Set);let t=ie(e),r=M(t.sharedStorage,t.namespace)??t.consent??null;if(this.gates=[new S(t.storage),new S(t.sharedStorage,we)],t.consentMode!=="banner"||r?.analytics===true)for(let a of this.gates)a.open();let[s,i]=this.gates;this.config={...t,sharedStorage:i,storage:s},this.identity=new R(this.config.storage,this.config.sharedStorage,this.config.ids,this.config.namespace),this.config.consent!==void 0&&this.identity.setConsent(this.config.consent),this.session=this.config.sessionTracking?new q(this.config.sharedStorage,this.config.ids,this.config.clock,this.config.namespace):void 0,this.queue=new O(this.config.maxQueueSize,({dropped:a})=>{this.config.onError(new g("queue_overflow",`event queue overflow: dropped ${a.length} oldest event(s)`));}),this.transport=this.config.transport??new K({maxRetries:this.config.maxRetries,requestTimeoutMs:this.config.requestTimeoutMs}),this.flagsClient=new F({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.messagesClient=new N({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.surveysClient=new $({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.guidesClient=new P({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.formsClient=new T({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.ctasClient=new C({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.context={sdk:this.config.sdkName,sdk_version:this.config.sdkVersion},this.config.os&&(this.context.os=this.config.os),this.config.locale&&(this.context.locale=this.config.locale),this.restoreQueue(),this.startTimer();}get distinctId(){return this.identity.getDistinctId()}get anonymousId(){return this.identity.getAnonymousId()}get isIdentified(){return this.identity.isIdentified()}get sessionId(){return this.session?.current()}get sessionStartedAt(){return this.session?.startedAt()}capture(e,t={}){try{this.identity.refresh();let r={...this.config.defaultProperties(),...t.element===void 0?{}:this.config.describeElement?.(t.element)??{},...t.properties??{}},s=ae({context:this.context,distinctId:t.distinctId??this.identity.getDistinctId(),eventName:e,properties:r,sessionId:t.sessionId??this.session?.current(),timestamp:t.timestamp},this.config.clock,this.config.ids);this.enqueue(s);}catch(r){this.config.onError(r);}for(let r of this.captureListeners)try{r(e);}catch(s){this.config.onError(s);}}onCapture(e){return this.captureListeners.add(e),()=>{this.captureListeners.delete(e);}}identify(e,t={}){if(this.isCookieless())return;this.identity.refresh();let r=this.identity.identify(e),s={};r.anonymousToLink!==void 0&&(s.$anon_distinct_id=r.anonymousToLink);let i=X(),a={...i===null?{}:{$timezone:i},...W(t.traits??{}),...t.set??{}};Object.keys(a).length>0&&(s.$set=a),this.capture(u.identify,{properties:s});}link(e,t,r){if(this.isCookieless())return;let s={$anon_distinct_id:t},i=W(r??{});Object.keys(i).length>0&&(s.$set=i),this.capture(u.identify,{distinctId:e,properties:s});}setConsent(e){this.identity.setConsent(e),e.analytics===true&&this.allowStorage(),e.analytics===false&&this.config.consentMode==="banner"&&this.forbidStorage();}isCookieless(){return !this.gates[0].isOpen}takeCookielessId(e){this.cookielessId=e,this.isCookieless()&&this.identity.assumeAnonymousId(e);}allowStorage(){if(this.isCookieless()){for(let e of this.gates)e.open();this.identity.refresh();for(let e of [...this.storageListeners])e();}}onStorageAllowed(e){return this.storageListeners.add(e),()=>{this.storageListeners.delete(e);}}forbidStorage(){if(!this.isCookieless()){for(let e of ["anonymous_id","distinct_id","linked_anonymous_id","session"])this.config.storage.removeItem(`pdx.${this.config.namespace}.${e}`),this.config.sharedStorage.removeItem(`pdx.${this.config.namespace}.${e}`);for(let e of this.gates)e.close();this.identity.refresh(),this.cookielessId!==void 0&&this.identity.assumeAnonymousId(this.cookielessId);}}consent(){return this.identity.consent()}alias(e){this.capture(u.createAlias,{properties:{alias:e}});}group(e,t,r){let s={$group_key:t,$group_type:e};r&&(s.$set=r),this.capture(u.group,{properties:s});}setPersonProperties(e,t){if(this.isCookieless())return;let r={};e&&(r.$set=e),t&&(r.$set_once=t),this.capture(u.set,{properties:r});}setPersonTraits(e){if(this.isCookieless())return;let t=W(e);Object.keys(t).length!==0&&this.capture(u.set,{properties:{$set:t}});}async getAllFlags(){let e=this.identity.getDistinctId(),t=await this.flagsClient.fetchDecisions(e);return this.cachedFlags={distinctId:e,flags:t.flags,variants:t.variants??{}},t.flags}async isFeatureEnabled(e){let r=(await this.getAllFlags())[e]??false;return this.recordExposure(e,this.cachedFlags?.variants[e]?.key??String(r)),r}async getVariant(e){let t=await this.getAllFlags(),r=this.cachedFlags?.variants[e]??null;return this.recordExposure(e,r?.key??String(t[e]??false)),r}async getVariantLocal(e,t={}){let r=await this.flagSnapshot(),s=r.flags.find(Fe=>Fe.key===e),i=await this.localContext(t,r.flags),a=s?V(s,r.flags,i):null,c=s?E(s,r.flags,i).enabled:false;return this.recordExposure(e,a?.key??String(c)),a?{key:a.key,value:a.value}:null}recordExposure(e,t){let r=`${this.identity.getDistinctId()} ${e} ${t}`;this.exposures.has(r)||(this.exposures.add(r),this.capture(u.featureFlagCalled,{properties:{$feature_flag:e,$feature_flag_response:t}}));}getCachedFlag(e){if(!(!this.cachedFlags||this.cachedFlags.distinctId!==this.distinctId))return this.cachedFlags.flags[e]}async getLocalFlags(e={}){let t=await this.flagSnapshot();return ge(t.flags,await this.localContext(e,t.flags))}async isFeatureEnabledLocal(e,t={}){let r=await this.flagSnapshot(),s=r.flags.find(c=>c.key===e),i=await this.localContext(t,r.flags),a=s?E(s,r.flags,i).enabled:false;return this.recordExposure(e,(s?V(s,r.flags,i)?.key:void 0)??String(a)),a}async localContext(e,t){let r=this.identity.getDistinctId(),s=e.cohorts;if(s===void 0&&fe(t)){let i=this.config.clock.now().getTime();this.membershipCache&&this.membershipCache.distinctId===r&&i-this.membershipCache.fetchedAt<_e?s=this.membershipCache.cohorts:(s=await this.flagsClient.memberships(r),this.membershipCache={cohorts:s,distinctId:r,fetchedAt:i});}return {attributes:e.attributes,cohorts:s,distinctId:r,properties:e.properties}}async flagSnapshot(){let e=this.config.clock.now().getTime();if(this.cachedSnapshot&&e-this.cachedSnapshot.fetchedAt<_e)return this.cachedSnapshot.snapshot;let t=await this.flagsClient.snapshot();return this.cachedSnapshot={fetchedAt:e,snapshot:t},this.maybeStream(t),t}maybeStream(e){if(!this.config.streamFlags||this.shutDown||this.stream||!e.socketUrl)return;let t=new I({host:e.socketUrl,onChange:()=>{this.cachedSnapshot=void 0,this.flagSnapshot().catch(r=>this.config.onError(r));},onClosed:r=>{this.stream=void 0,r&&this.maybeStream(e);},projectKey:this.config.apiKey,socketFactory:this.config.socketFactory});this.stream=t,t.open();}async getInbox(){return this.messagesClient.inbox(this.identity.getDistinctId())}async markMessageRead(e){await this.messagesClient.markRead(e,this.identity.getDistinctId());}async getSurveys(e){return this.surveysClient.surveys(this.identity.getDistinctId(),e??this.config.locale)}captureSurveyShown(e){this.capture(be,{properties:A(e,{})});}captureSurveyDismissed(e){this.capture(Se,{properties:A(e,{})});}captureSurveySent(e,t){this.capture(ke,{properties:A(e,t)});}async getGuides(){return this.guidesClient.guides(this.identity.getDistinctId())}captureGuide(e,t,r){this.capture(e,{properties:xe(t,r)});}async getForm(e){return this.formsClient.form(e,this.identity.getDistinctId())}async submitForm(e,t,r,s){let{$page_id:i,$page_variant:a}=this.config.defaultProperties();return this.formsClient.submit(e,{answers:t,challenge:r,distinctId:this.identity.getDistinctId(),isAnonymous:!this.identity.isIdentified(),pageUrl:typeof window>"u"?"":window.location.href,solution:s,...typeof i=="string"&&typeof a=="string"?{pageId:i,pageVariant:a}:{}})}async getCtas(e){return this.ctasClient.ctas({...e,anonymous:!this.identity.isIdentified(),distinctId:this.identity.getDistinctId()})}captureCta(e,t,r){this.capture(e,{properties:oe(t,r)});}async flush(){if(this.flushing||this.queue.size===0)return;this.flushing=true;let e=this.queue.drain(Je);try{await this.transport.send({body:{events:e,sent_at:x(this.config.clock.now())},projectKey:this.config.apiKey,url:`${this.config.host}/v1/events`}),this.persistQueue();}catch(t){this.queue.requeue(e),this.persistQueue(),this.config.onError(t);}finally{this.flushing=false;}}reset(){this.session?.reset(),this.identity.reset(),this.cachedFlags=void 0,this.cachedSnapshot=void 0,this.membershipCache=void 0;}async shutdown(){this.shutDown=true,this.stopTimer(),this.stream?.close(),this.stream=void 0,await this.flush();}enqueue(e){this.queue.enqueue(e),this.persistQueue(),this.queue.size>=this.config.flushAt&&this.flush();}persistQueue(){try{this.config.storage.setItem(this.persistKey(),JSON.stringify(this.queue.snapshot()));}catch(e){this.config.onError(e);}}restoreQueue(){try{let e=this.config.storage.getItem(this.persistKey());if(!e)return;let t=JSON.parse(e);Array.isArray(t)&&this.queue.restore(t);}catch(e){this.config.onError(e);}}startTimer(){if(this.config.flushIntervalMs<=0)return;let e=setInterval(()=>{this.flush();},this.config.flushIntervalMs),t=e;typeof t.unref=="function"&&t.unref(),this.flushTimer=e;}stopTimer(){this.flushTimer!==void 0&&(clearInterval(this.flushTimer),this.flushTimer=void 0);}persistKey(){return `pdx.${this.config.namespace}.${He}`}};var ze=200;function Ee(){return globalThis.process}function We(n){Ee()?.on("beforeExit",()=>{n.flush();});}function Nn(n){let e=Ee(),t={...n,os:n.os??(e?.platform?e.platform.slice(0,50):void 0),streamFlags:n.streamFlags??true},r=new D(t);return We(r),r}function On(n,e){let t=L(e),r=Qe(n,`pdx_${t}`);if(r===void 0)return null;let s=Ye(r);if(s===void 0)return null;let i=Ie(s[`pdx.${t}.anonymous_id`]);return i===void 0?null:{anonymousId:i,consent:k(s[`pdx.${t}.consent`]),sessionId:Xe(s[`pdx.${t}.session`])}}function Qe(n,e){let t=`${e}=`;for(let r of n.split(";")){let s=r.trim();if(s.startsWith(t))return s.slice(t.length)}}function Ye(n){try{let e=JSON.parse(decodeURIComponent(n));return e===null||typeof e!="object"||Array.isArray(e)?void 0:e}catch{return}}function Ie(n){if(typeof n!="string")return;let e=w(n);return e>=1&&e<=ze?n:void 0}function Xe(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);return e===null||typeof e!="object"||typeof e.startedAt!="number"||typeof e.lastActivityAt!="number"?null:Ie(e.id)??null}catch{return null}}exports.createNodeClient=Nn;exports.readSharedIdentity=On;//# sourceMappingURL=node.cjs.map
|
|
2
2
|
//# sourceMappingURL=node.cjs.map
|
package/dist/node.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {_,h as h$1,R,e}from'./chunk-
|
|
1
|
+
import {_,h as h$1,R,e}from'./chunk-X2KBTZDG.js';import'./chunk-V77KYPOF.js';import'./chunk-ODN4ZELX.js';import'./chunk-5XGN7UAV.js';var a=200;function f(){return globalThis.process}function p(t){f()?.on("beforeExit",()=>{t.flush();});}function h(t){let n=f(),e={...t,os:t.os??(n?.platform?n.platform.slice(0,50):void 0),streamFlags:t.streamFlags??true},r=new _(e);return p(r),r}function w(t,n){let e=h$1(n),r=m(t,`pdx_${e}`);if(r===void 0)return null;let o=g(r);if(o===void 0)return null;let i=l(o[`pdx.${e}.anonymous_id`]);return i===void 0?null:{anonymousId:i,consent:R(o[`pdx.${e}.consent`]),sessionId:y(o[`pdx.${e}.session`])}}function m(t,n){let e=`${n}=`;for(let r of t.split(";")){let o=r.trim();if(o.startsWith(e))return o.slice(e.length)}}function g(t){try{let n=JSON.parse(decodeURIComponent(t));return n===null||typeof n!="object"||Array.isArray(n)?void 0:n}catch{return}}function l(t){if(typeof t!="string")return;let n=e(t);return n>=1&&n<=a?t:void 0}function y(t){if(typeof t!="string")return null;try{let n=JSON.parse(t);return n===null||typeof n!="object"||typeof n.startedAt!="number"||typeof n.lastActivityAt!="number"?null:l(n.id)??null}catch{return null}}export{h as createNodeClient,w as readSharedIdentity};//# sourceMappingURL=node.js.map
|
|
2
2
|
//# sourceMappingURL=node.js.map
|
package/dist/pages.iife.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){'use strict';var kt=Object.defineProperty;var Et=(n,e,t)=>e in n?kt(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var c=(n,e,t)=>Et(n,typeof e!="symbol"?e+"":e,t);var b=class extends Error{constructor(t,r,i){super(r,i);c(this,"code");this.code=t,this.name="ProdantixError";}},F=class extends b{constructor(e){super("config",e),this.name="ConfigError";}},w=class extends b{constructor(t,r){super("validation",r);c(this,"field");this.field=t,this.name="ValidationError";}},p=class extends b{constructor(t,r,i){super("transport",t,i);c(this,"status");this.status=r,this.name="TransportError";}};function y(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function h(){let n=globalThis.AbortController;return n?new n:void 0}var Ee=n=>new Promise(e=>{setTimeout(e,n);});function f(n){return n.replace(/\/+$/,"")}var E=class{constructor(){c(this,"store",new Map);}getItem(e){var t;return (t=this.store.get(e))!=null?t:null}removeItem(e){this.store.delete(e);}setItem(e,t){this.store.set(e,t);}},A=class{constructor(e,t=()=>false){this.real=e;this.passes=t;c(this,"held",new E);c(this,"opened",false);}get isOpen(){return this.opened}open(){this.opened=true;}close(){this.opened=false;}target(e){return this.opened||this.passes(e)?this.real:this.held}getItem(e){return this.target(e).getItem(e)}removeItem(e){this.target(e).removeItem(e);}setItem(e,t){this.target(e).setItem(e,t);}};function xe(){try{let n=globalThis.localStorage;if(n){let e="__pdx_probe__";return n.setItem(e,"1"),n.removeItem(e),n}}catch(n){return new E}return new E}var Te={now:()=>new Date};function O(n){return n.toISOString()}function we(){if(typeof window=="undefined"||typeof Intl=="undefined")return null;let n=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof n=="string"&&n!==""?n:null}function xt(){return globalThis.crypto}function Tt(n){n[6]=n[6]&15|64,n[8]=n[8]&63|128;let e=[];for(let t=0;t<16;t+=1)e.push(n[t].toString(16).padStart(2,"0"));return `${e[0]}${e[1]}${e[2]}${e[3]}-${e[4]}${e[5]}-${e[6]}${e[7]}-${e[8]}${e[9]}-${e[10]}${e[11]}${e[12]}${e[13]}${e[14]}${e[15]}`}function te(){let n=xt();if(n!=null&&n.randomUUID)return n.randomUUID();let e=new Uint8Array(16);if(n!=null&&n.getRandomValues)n.getRandomValues(e);else for(let t=0;t<16;t+=1)e[t]=Math.floor(Math.random()*256);return Tt(e)}var Ce={uuid:te};var wt=/^pdx_pub_(?:(?:live|test)_)?[a-z0-9]{32}$/;var Ct=/^(?:\$|[a-z])[a-z0-9_.]*$/;function _e(n){let e=0;for(let t of n)e+=1;return e}function Ie(n){return wt.test(n)}function _t(n){return Ct.test(n)}function Fe(n){let e=_e(n);if(e<1||e>200)throw new w("distinct_id","distinct_id must be between 1 and 200 characters")}function Ae(n){let e=_e(n);if(e<1||e>200)throw new w("event_name","event_name must be between 1 and 200 characters");if(!_t(n))throw new w("event_name","event_name must match /^(\\$|[a-z])[a-z0-9_.]*$/")}var $e="prodantix-js",Pe="0.7.0";var It=n=>{};function Me(n){var i,o,s,a,l,u,d,g,v,k,_,I,L,Se,ke;if(!n.apiKey||!Ie(n.apiKey))throw new F("apiKey must be a public project key of the form pdx_pub_<32 lowercase alphanumerics>");if(!n.host)throw new F("host is required (the ingest base URL)");let e=f(n.host),t=n.defaultProperties,r=(i=n.storage)!=null?i:new E;return {apiKey:n.apiKey,autocapture:(o=n.autocapture)!=null?o:false,clock:(s=n.clock)!=null?s:Te,consent:n.consent,consentMode:n.consentMode,defaultProperties:typeof t=="function"?t:()=>t!=null?t:{},describeElement:n.describeElement,flagsHost:n.flagsHost?f(n.flagsHost):e,flushAt:(a=n.flushAt)!=null?a:20,flushIntervalMs:(l=n.flushIntervalMs)!=null?l:1e4,host:e,ids:(u=n.ids)!=null?u:Ce,locale:n.locale,maxQueueSize:(d=n.maxQueueSize)!=null?d:1e3,maxRetries:(g=n.maxRetries)!=null?g:3,namespace:ne(n.apiKey),onError:(v=n.onError)!=null?v:It,os:n.os,requestTimeoutMs:(k=n.requestTimeoutMs)!=null?k:1e4,sdkName:(_=n.sdkName)!=null?_:$e,sdkVersion:(I=n.sdkVersion)!=null?I:Pe,sessionTracking:(L=n.sessionTracking)!=null?L:false,sharedStorage:(Se=n.sharedStorage)!=null?Se:r,socketFactory:n.socketFactory,storage:r,streamFlags:(ke=n.streamFlags)!=null?ke:false,transport:n.transport}}function ne(n){return n.slice(0,16)}var Le=(n,e)=>{let t={$cta_id:n.id,$cta_kind:n.kind,$cta_variant:n.variant.key,$cta_version:n.version},r=e===void 0?void 0:n.variant.content.buttons[e];return r&&e!==void 0&&(t.$cta_button=e,t.$cta_button_label=r.label,r.action.kind==="form"&&(t.$cta_form_id=r.action.value)),t},N=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=f(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async ctas(e){let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=new URLSearchParams({anonymous:String(e.anonymous),device:e.device,distinct_id:e.distinctId,language:e.language,url:e.url}),i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let s=await t(`${this.host}/v1/ctas?${r.toString()}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(s.status<200||s.status>=300)throw new p(`ctas request failed with status ${s.status}`,s.status);return JSON.parse(await s.text()).ctas}finally{o!==void 0&&clearTimeout(o);}}};function Oe(n,e,t){var i,o,s;Ae(n.eventName),Fe(n.distinctId);let r={distinct_id:n.distinctId,event_id:(i=n.eventId)!=null?i:t.uuid(),event_name:n.eventName,properties:(o=n.properties)!=null?o:{},schema_version:1,timestamp:O((s=n.timestamp)!=null?s:e.now())};return n.context&&(r.context=n.context),n.sessionId&&(r.session_id=n.sessionId),r}var T=Symbol("absent");function Ft(n,e){var i,o;if(n==="distinct_id")return e.distinctId;let t=(i=e.properties)!=null?i:{};if(Object.prototype.hasOwnProperty.call(t,n))return t[n];let r=(o=e.attributes)!=null?o:{};return Object.prototype.hasOwnProperty.call(r,n)?r[n]:T}function x(n){return n===T?"undefined":String(n)}function Ne(n){return n===T?Number.NaN:Number(n)}function Re(n){return n!==T&&n!==null&&n!==""}function De(n,e){if(!Array.isArray(e))return false;let t=x(n);return e.map(r=>String(r)).includes(t)}function qe(n,e){var i,o;let t=Ft(n.attribute,e),r=n.value;switch(n.op){case "is_set":return Re(t);case "is_not_set":return !Re(t);case "eq":return x(t)===x(r===void 0?T:r);case "neq":return x(t)!==x(r===void 0?T:r);case "contains":return x(t).includes(x(r===void 0?T:r));case "in":return De(t,r);case "not_in":return Array.isArray(r)?!De(t,r):false;case "gt":return R(t,r,(s,a)=>s>a);case "gte":return R(t,r,(s,a)=>s>=a);case "lt":return R(t,r,(s,a)=>s<a);case "lte":return R(t,r,(s,a)=>s<=a);case "in_cohort":return typeof r=="string"&&r!==""&&((i=e.cohorts)!=null?i:[]).includes(r);case "not_in_cohort":return typeof r=="string"&&r!==""&&!((o=e.cohorts)!=null?o:[]).includes(r);default:return false}}function R(n,e,t){let r=Ne(n),i=e===void 0?Number.NaN:Ne(e);return Number.isNaN(r)||Number.isNaN(i)?false:t(r,i)}function Ke(n,e){let t=`${n}:${e}`,r=2166136261;for(let i=0;i<t.length;i++)r^=t.charCodeAt(i),r=Math.imul(r,16777619);return (r>>>0)%100}function re(n,e){return n.targeting.length===0||n.targeting.every(t=>qe(t,e))}function je(n,e){var o;let t=Ke(n.key,e.distinctId),r=(o=n.variations)!=null?o:[];if(r.length===0)return n.rolloutPercentage>=100||t<n.rolloutPercentage?"true":"false";let i=0;for(let s=r.length-1;s>=0;s--)if(i+=r[s].weight,t<i)return r[s].key;return r[0].key}function ie(n,e,t,r){var i;for(let o of (i=n.prerequisites)!=null?i:[]){if(r.includes(o.flagKey))return false;let s=e.find(l=>l.key===o.flagKey);if(!s||!s.enabled)return false;r.push(s.key);let a=ie(s,e,t,r)&&re(s,t)&&je(s,t)===o.variationKey;if(r.pop(),!a)return false}return true}function D(n,e,t){return n.enabled?ie(n,e,t,[n.key])?re(n,t)?n.rolloutPercentage>=100?{enabled:true,reason:"rollout_full"}:Ke(n.key,t.distinctId)<n.rolloutPercentage?{enabled:true,reason:"rollout"}:{enabled:false,reason:"rollout_excluded"}:{enabled:false,reason:"targeting"}:{enabled:false,reason:"prerequisite"}:{enabled:false,reason:"disabled"}}function Ge(n,e){let t={};for(let r of n)t[r.key]=D(r,n,e).enabled;return t}function se(n,e,t){var s,a;let r=(s=n.variations)!=null?s:[],i=r[0];if(!i)return null;if(!n.enabled||!ie(n,e,t,[n.key])||!re(n,t))return i;let o=je(n,t);return (a=r.find(l=>l.key===o))!=null?a:i}function Ve(n){return n.some(e=>e.targeting.some(t=>t.op==="in_cohort"||t.op==="not_in_cohort"))}function Be(n){return `40${JSON.stringify(n)}`}function Ue(){return "3"}function He(n){let e=n.charAt(0),t=n.slice(1);if(e==="2")return {kind:"ping"};if(e==="1")return {kind:"disconnect"};if(e==="0"){let s=oe(t);return {kind:"open",pingInterval:typeof(s==null?void 0:s.pingInterval)=="number"?s.pingInterval:25e3,pingTimeout:typeof(s==null?void 0:s.pingTimeout)=="number"?s.pingTimeout:2e4}}if(e!=="4")return {kind:"other"};let r=t.charAt(0),i=t.slice(1);if(r==="0")return {kind:"connected"};if(r==="1")return {kind:"disconnect"};if(r==="4"){let s=oe(i);return {kind:"connectError",message:typeof(s==null?void 0:s.message)=="string"?s.message:"refused"}}if(r!=="2")return {kind:"other"};let o=oe(i);return !Array.isArray(o)||typeof o[0]!="string"?{kind:"other"}:{kind:"event",name:o[0],payload:o[1]}}function oe(n){try{return JSON.parse(n)}catch(e){return null}}var At="/socket.io/?EIO=4&transport=websocket",$t=250,q=class{constructor(e){this.options=e;c(this,"socket",null);c(this,"heartbeat",null);c(this,"pending",null);c(this,"lastKey","");c(this,"ready",false);c(this,"closed",false);c(this,"heartbeatWindow",45e3);c(this,"factory");c(this,"setTimer");c(this,"clearTimer");var t,r,i;this.factory=(t=e.socketFactory)!=null?t:Pt,this.setTimer=(r=e.setTimer)!=null?r:((o,s)=>setTimeout(o,s)),this.clearTimer=(i=e.clearTimer)!=null?i:(o=>clearTimeout(o));}open(){if(this.socket||this.closed)return;let e=`${this.options.host.replace(/^http/,"ws").replace(/\/+$/,"")}${At}`,t;try{t=this.factory(e);}catch(r){this.options.onClosed(false);return}this.socket=t,t.onmessage=r=>this.receive(String(r.data)),t.onerror=()=>t.close(),t.onclose=()=>this.fell();}close(){this.closed=true,this.stopHeartbeat(),this.pending!==null&&this.clearTimer(this.pending),this.pending=null;let e=this.socket;this.socket=null,e==null||e.close();}receive(e){var r,i,o,s;let t=He(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),(r=this.socket)==null||r.send(Be({projectKey:this.options.projectKey}));return}if(t.kind==="ping"){this.armHeartbeat(),(i=this.socket)==null||i.send(Ue());return}if(t.kind==="connectError"||t.kind==="disconnect"){this.stopHeartbeat(),(o=this.socket)==null||o.close();return}if(t.kind==="event"){if(t.name==="ready"){this.ready=true;return}if(t.name==="flagChange"){let a=(s=t.payload)==null?void 0:s.key;this.lastKey=typeof a=="string"?a:"",this.pending===null&&(this.pending=this.setTimer(()=>{this.pending=null,this.options.onChange(this.lastKey);},$t));}}}fell(){this.stopHeartbeat();let e=this.ready;this.socket=null,this.ready=false,this.closed||this.options.onClosed(e);}armHeartbeat(e){e!==void 0&&(this.heartbeatWindow=e),this.stopHeartbeat(),this.heartbeat=this.setTimer(()=>{var t;return (t=this.socket)==null?void 0:t.close()},this.heartbeatWindow);}stopHeartbeat(){this.heartbeat!==null&&this.clearTimer(this.heartbeat),this.heartbeat=null;}};function Pt(n){let e=globalThis.WebSocket;if(!e)throw new p("no WebSocket");return new e(n)}var K=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=f(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async fetchAll(e){return (await this.fetchDecisions(e)).flags}async fetchDecisions(e){var s,a;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags?distinct_id=${encodeURIComponent(e)}`,i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let l=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!l.ok)throw new p(`flags request failed with status ${l.status}`,l.status);let u=JSON.parse(await l.text());return {flags:(s=u.flags)!=null?s:{},variants:(a=u.variants)!=null?a:{}}}finally{o!==void 0&&clearTimeout(o);}}async snapshot(){var o;let e=this.fetch;if(!e)throw new p("no fetch implementation available in this runtime");let t=`${this.host}/v1/flags/snapshot`,r=h(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let s=await e(t,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r==null?void 0:r.signal});if(!s.ok)throw new p(`flag snapshot request failed with status ${s.status}`,s.status);let a=JSON.parse(await s.text()),l={flags:(o=a.flags)!=null?o:[],generatedAt:a.generatedAt};return typeof a.socketUrl=="string"&&a.socketUrl!==""&&(l.socketUrl=a.socketUrl),l}finally{i!==void 0&&clearTimeout(i);}}async memberships(e){var s;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags/memberships?distinct_id=${encodeURIComponent(e)}`,i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!a.ok)throw new p(`memberships request failed with status ${a.status}`,a.status);return (s=JSON.parse(await a.text()).cohorts)!=null?s:[]}finally{o!==void 0&&clearTimeout(o);}}};var ae=class extends Error{constructor(t,r,i){super(i);c(this,"fields");c(this,"status");this.name="FormRefusedError",this.status=t,this.fields=r;}},j=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=f(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async request(e,t){let r=this.fetch;if(!r)throw new p("no fetch implementation available in this runtime");let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let s={authorization:`Bearer ${this.projectKey}`};t.body!==void 0&&(s["content-type"]="application/json");let a=await r(`${this.host}${e}`,{body:t.body,headers:s,method:t.method,signal:i==null?void 0:i.signal});return {status:a.status,text:await a.text()}}finally{o!==void 0&&clearTimeout(o);}}async form(e,t){let{status:r,text:i}=await this.request(`/v1/forms/${encodeURIComponent(e)}?distinct_id=${encodeURIComponent(t)}`,{method:"GET"});if(r<200||r>=300)throw new p(`form request failed with status ${r}`,r);return JSON.parse(i)}async submit(e,t){var a,l,u,d;let{status:r,text:i}=await this.request(`/v1/forms/${encodeURIComponent(e)}/submissions`,{body:JSON.stringify(t),method:"POST"});if(r>=200&&r<300)return JSON.parse(i).afterSubmit;let o=[],s=`form submission failed with status ${r}`;try{let g=JSON.parse(i);o=(l=(a=g.error)==null?void 0:a.fields)!=null?l:[],s=(d=(u=g.error)==null?void 0:u.message)!=null?d:s;}catch(g){o=[];}throw new ae(r,o,s)}};var Je="$survey_shown",We="$survey_dismissed",ze="$survey_sent",G=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=f(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async surveys(e,t){var s;let r=this.fetch;if(!r)throw new p("no fetch implementation available in this runtime");let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let a=await r(`${this.host}/v1/surveys?distinct_id=${encodeURIComponent(e)}${t?`&lang=${encodeURIComponent(t)}`:""}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!a.ok)throw new p(`surveys request failed with status ${a.status}`,a.status);return (s=JSON.parse(await a.text()).surveys)!=null?s:[]}finally{o!==void 0&&clearTimeout(o);}}};function V(n,e){let t={$survey_id:n.id,$survey_iteration:n.iteration,$survey_name:n.name};for(let[r,i]of Object.entries(e))t[`$survey_response_${r}`]=i;return t}var B=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=f(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async guides(e){var o;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=h(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let s=await t(`${this.host}/v1/guides?distinct_id=${encodeURIComponent(e)}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r==null?void 0:r.signal});if(!s.ok)throw new p(`guides request failed with status ${s.status}`,s.status);return (o=JSON.parse(await s.text()).guides)!=null?o:[]}finally{i!==void 0&&clearTimeout(i);}}};function Ye(n,e){let t={$guide_id:n.id,$guide_iteration:n.iteration,$guide_name:n.name};return e!==void 0&&(t.$guide_step_id=e),t}function ce(n){if(typeof n!="string")return;let e=Array.from(n).length;return e>=1&&e<=200?n:void 0}function ue(n,e){return `pdx.${n}.${e}`}var de="consent",Mt=["identityLink","analytics","marketing","functional"];function le(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let i of Mt){let o=t[i];typeof o=="boolean"&&(r[i]=o);}return typeof t.version=="number"&&Number.isInteger(t.version)&&(r.version=t.version),Array.isArray(t.categories)&&t.categories.every(i=>typeof i=="string")&&(r.categories=t.categories),Object.keys(r).length===0?null:r}catch(e){return null}}var Qe=n=>n.endsWith(`.${de}`);function H(n,e){return le(n.getItem(ue(e,de)))}function Lt(n,e,t){var s;let r=ue(e,de),i=le(JSON.stringify(t)),o=i===null?null:le(JSON.stringify({...(s=H(n,e))!=null?s:{},...i}));if(o===null){n.removeItem(r);return}n.setItem(r,JSON.stringify(o));}var U=class{constructor(e,t,r,i){this.storage=e;this.shared=t;this.ids=r;this.namespace=i;c(this,"anonymousId");c(this,"distinctId");c(this,"identified");this.refresh();}refresh(){let e=ce(this.shared.getItem(this.key("anonymous_id"))),t=ce(this.storage.getItem(this.key("anonymous_id")));e?(this.anonymousId=e,t!==e&&this.storage.setItem(this.key("anonymous_id"),e)):t?(this.anonymousId=t,this.shared.setItem(this.key("anonymous_id"),t)):(this.anonymousId=this.ids.uuid(),this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId));let r=ce(this.storage.getItem(this.key("distinct_id")));r?(this.distinctId=r,this.identified=true):(this.distinctId=this.anonymousId,this.identified=false);}getAnonymousId(){return this.anonymousId}getDistinctId(){return this.distinctId}isIdentified(){return this.identified}snapshot(){return {anonymousId:this.anonymousId,distinctId:this.distinctId,identified:this.identified}}consent(){return H(this.shared,this.namespace)}setConsent(e){Lt(this.shared,this.namespace,e);}assumeAnonymousId(e){this.anonymousId=e,this.shared.setItem(this.key("anonymous_id"),e),this.storage.setItem(this.key("anonymous_id"),e),this.identified||(this.distinctId=e);}identify(e){var o;let t=!this.identified||this.distinctId!==e,r=this.storage.getItem(this.key("linked_anonymous_id")),i=t||r!==this.anonymousId;return this.distinctId=e,this.identified=true,t&&this.storage.setItem(this.key("distinct_id"),e),!i||((o=this.consent())==null?void 0:o.identityLink)===false?{changed:t}:(this.storage.setItem(this.key("linked_anonymous_id"),this.anonymousId),{anonymousToLink:this.anonymousId,changed:t})}reset(){this.anonymousId=this.ids.uuid(),this.distinctId=this.anonymousId,this.identified=false,this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.removeItem(this.key("distinct_id")),this.storage.removeItem(this.key("linked_anonymous_id"));}key(e){return ue(this.namespace,e)}};var J=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=f(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async inbox(e){var s;let t=this.requireFetch(),r=`${this.host}/v1/messages?distinct_id=${encodeURIComponent(e)}`,i=await this.request(t,r,{headers:this.authHeaders(),method:"GET"});if(!i.ok)throw new p(`inbox request failed with status ${i.status}`,i.status);return (s=JSON.parse(await i.text()).messages)!=null?s:[]}async markRead(e,t){let r=this.requireFetch(),i=`${this.host}/v1/messages/read`,o=await this.request(r,i,{body:JSON.stringify({distinct_id:t,message_id:e}),headers:{...this.authHeaders(),"content-type":"application/json"},method:"POST"});if(!o.ok)throw new p(`mark-read request failed with status ${o.status}`,o.status)}requireFetch(){if(!this.fetch)throw new p("no fetch implementation available in this runtime");return this.fetch}authHeaders(){return {authorization:`Bearer ${this.projectKey}`}}async request(e,t,r){let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{return await e(t,{...r,signal:i==null?void 0:i.signal})}finally{o!==void 0&&clearTimeout(o);}}};var W=class{constructor(e,t){this.maxSize=e;this.onOverflow=t;c(this,"events",[]);}get size(){return this.events.length}enqueue(e){this.events.push(e),this.enforceCap();}restore(e){this.events.push(...e),this.enforceCap();}requeue(e){this.events.unshift(...e),this.enforceCap();}drain(e){let t=e===void 0?this.events.length:Math.min(e,this.events.length);return this.events.splice(0,t)}snapshot(){return [...this.events]}enforceCap(){var t;if(this.events.length<=this.maxSize)return;let e=this.events.splice(0,this.events.length-this.maxSize);(t=this.onOverflow)==null||t.call(this,{dropped:e});}};var Ot={idleMs:18e5,maxMs:864e5,throttleMs:1e4};function Nt(n){return `pdx.${n}.session`}var z=class{constructor(e,t,r,i,o=Ot){this.storage=e;this.ids=t;this.clock=r;this.namespace=i;this.options=o;}current(){return this.touch().id}startedAt(){return this.touch().startedAt}reset(){this.storage.removeItem(this.key());}touch(){let e=this.clock.now().getTime(),t=this.live(this.read(),e);if(t===void 0)return this.write({id:this.ids.uuid(),lastActivityAt:e,startedAt:e});if(e-t.lastActivityAt<=this.options.throttleMs)return t;let r=this.live(this.read(),e),i=r!==void 0&&r.id!==t.id?r:t;return this.write({...i,lastActivityAt:e})}live(e,t){if(e!==void 0&&!(t-e.lastActivityAt>this.options.idleMs||t-e.startedAt>this.options.maxMs))return e}write(e){return this.storage.setItem(this.key(),JSON.stringify(e)),e}read(){let e=this.storage.getItem(this.key());if(e)try{let t=JSON.parse(e);return typeof t.id=="string"&&typeof t.startedAt=="number"&&typeof t.lastActivityAt=="number"?{id:t.id,lastActivityAt:t.lastActivityAt,startedAt:t.startedAt}:void 0}catch(t){return}}key(){return Nt(this.namespace)}};var m={autocapture:"$autocapture",createAlias:"$create_alias",featureFlagCalled:"$feature_flag_called",group:"$group",identify:"$identify",pageleave:"$pageleave",pageview:"$pageview",set:"$set"};function Xe(n){return n>=400&&n<500&&n!==429}var C=class{constructor(e={}){c(this,"fetch");c(this,"maxRetries");c(this,"requestTimeoutMs");c(this,"baseDelayMs");c(this,"maxDelayMs");c(this,"sleep");c(this,"random");var t,r,i,o,s,a;this.fetch=y(e.fetch),this.maxRetries=(t=e.maxRetries)!=null?t:3,this.requestTimeoutMs=(r=e.requestTimeoutMs)!=null?r:1e4,this.baseDelayMs=(i=e.baseDelayMs)!=null?i:500,this.maxDelayMs=(o=e.maxDelayMs)!=null?o:3e4,this.sleep=(s=e.sleep)!=null?s:Ee,this.random=(a=e.random)!=null?a:Math.random;}async send(e){let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=JSON.stringify(e.body),i;for(let o=0;o<=this.maxRetries;o+=1){try{let s=await this.attempt(t,e,r);if(s.ok)return;if(Xe(s.status))throw new p(`ingest rejected batch with status ${s.status}`,s.status);i=new p(`ingest transient status ${s.status}`,s.status);}catch(s){if(s instanceof p&&s.status!==void 0&&Xe(s.status))throw s;i=s;}o<this.maxRetries&&await this.sleep(this.backoff(o));}throw new p("ingest delivery failed after retries",void 0,{cause:i})}async attempt(e,t,r){let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{return await e(t.url,{body:r,headers:{authorization:`Bearer ${t.projectKey}`,"content-type":"application/json"},method:"POST",signal:i==null?void 0:i.signal})}finally{o!==void 0&&clearTimeout(o);}}backoff(e){return Math.min(this.maxDelayMs,this.baseDelayMs*2**e)+this.random()*this.baseDelayMs}};var Rt="queue",Dt=1e3,Ze=3e4,pe=n=>{let e={};return n.avatar!==void 0&&(e.$avatar=n.avatar),n.email!==void 0&&(e.$email=n.email),n.name!==void 0&&(e.$name=n.name),n.phone!==void 0&&(e.$phone=n.phone),e},Y=class{constructor(e){c(this,"config");c(this,"identity");c(this,"session");c(this,"queue");c(this,"transport");c(this,"flagsClient");c(this,"messagesClient");c(this,"surveysClient");c(this,"guidesClient");c(this,"captureListeners",new Set);c(this,"formsClient");c(this,"ctasClient");c(this,"context");c(this,"flushTimer");c(this,"flushing",false);c(this,"cachedFlags");c(this,"cachedSnapshot");c(this,"membershipCache");c(this,"stream");c(this,"shutDown",false);c(this,"exposures",new Set);c(this,"gates");c(this,"cookielessId");c(this,"storageListeners",new Set);var s,a,l;let t=Me(e),r=(a=(s=H(t.sharedStorage,t.namespace))!=null?s:t.consent)!=null?a:null;if(this.gates=[new A(t.storage),new A(t.sharedStorage,Qe)],t.consentMode!=="banner"||(r==null?void 0:r.analytics)===true)for(let u of this.gates)u.open();let[i,o]=this.gates;this.config={...t,sharedStorage:o,storage:i},this.identity=new U(this.config.storage,this.config.sharedStorage,this.config.ids,this.config.namespace),this.config.consent!==void 0&&this.identity.setConsent(this.config.consent),this.session=this.config.sessionTracking?new z(this.config.sharedStorage,this.config.ids,this.config.clock,this.config.namespace):void 0,this.queue=new W(this.config.maxQueueSize,({dropped:u})=>{this.config.onError(new b("queue_overflow",`event queue overflow: dropped ${u.length} oldest event(s)`));}),this.transport=(l=this.config.transport)!=null?l:new C({maxRetries:this.config.maxRetries,requestTimeoutMs:this.config.requestTimeoutMs}),this.flagsClient=new K({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.messagesClient=new J({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.surveysClient=new G({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.guidesClient=new B({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.formsClient=new j({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.ctasClient=new N({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.context={sdk:this.config.sdkName,sdk_version:this.config.sdkVersion},this.config.os&&(this.context.os=this.config.os),this.config.locale&&(this.context.locale=this.config.locale),this.restoreQueue(),this.startTimer();}get distinctId(){return this.identity.getDistinctId()}get anonymousId(){return this.identity.getAnonymousId()}get isIdentified(){return this.identity.isIdentified()}get sessionId(){var e;return (e=this.session)==null?void 0:e.current()}get sessionStartedAt(){var e;return (e=this.session)==null?void 0:e.startedAt()}capture(e,t={}){var r,i,o,s,a,l,u;try{this.identity.refresh();let d={...this.config.defaultProperties(),...t.element===void 0?{}:(o=(i=(r=this.config).describeElement)==null?void 0:i.call(r,t.element))!=null?o:{},...(s=t.properties)!=null?s:{}},g=Oe({context:this.context,distinctId:(a=t.distinctId)!=null?a:this.identity.getDistinctId(),eventName:e,properties:d,sessionId:(u=t.sessionId)!=null?u:(l=this.session)==null?void 0:l.current(),timestamp:t.timestamp},this.config.clock,this.config.ids);this.enqueue(g);}catch(d){this.config.onError(d);}for(let d of this.captureListeners)try{d(e);}catch(g){this.config.onError(g);}}onCapture(e){return this.captureListeners.add(e),()=>{this.captureListeners.delete(e);}}identify(e,t={}){var a,l;if(this.isCookieless())return;this.identity.refresh();let r=this.identity.identify(e),i={};r.anonymousToLink!==void 0&&(i.$anon_distinct_id=r.anonymousToLink);let o=we(),s={...o===null?{}:{$timezone:o},...pe((a=t.traits)!=null?a:{}),...(l=t.set)!=null?l:{}};Object.keys(s).length>0&&(i.$set=s),this.capture(m.identify,{properties:i});}link(e,t,r){if(this.isCookieless())return;let i={$anon_distinct_id:t},o=pe(r!=null?r:{});Object.keys(o).length>0&&(i.$set=o),this.capture(m.identify,{distinctId:e,properties:i});}setConsent(e){this.identity.setConsent(e),e.analytics===true&&this.allowStorage(),e.analytics===false&&this.config.consentMode==="banner"&&this.forbidStorage();}isCookieless(){return !this.gates[0].isOpen}takeCookielessId(e){this.cookielessId=e,this.isCookieless()&&this.identity.assumeAnonymousId(e);}allowStorage(){if(this.isCookieless()){for(let e of this.gates)e.open();this.identity.refresh();for(let e of [...this.storageListeners])e();}}onStorageAllowed(e){return this.storageListeners.add(e),()=>{this.storageListeners.delete(e);}}forbidStorage(){if(!this.isCookieless()){for(let e of ["anonymous_id","distinct_id","linked_anonymous_id","session"])this.config.storage.removeItem(`pdx.${this.config.namespace}.${e}`),this.config.sharedStorage.removeItem(`pdx.${this.config.namespace}.${e}`);for(let e of this.gates)e.close();this.identity.refresh(),this.cookielessId!==void 0&&this.identity.assumeAnonymousId(this.cookielessId);}}consent(){return this.identity.consent()}alias(e){this.capture(m.createAlias,{properties:{alias:e}});}group(e,t,r){let i={$group_key:t,$group_type:e};r&&(i.$set=r),this.capture(m.group,{properties:i});}setPersonProperties(e,t){if(this.isCookieless())return;let r={};e&&(r.$set=e),t&&(r.$set_once=t),this.capture(m.set,{properties:r});}setPersonTraits(e){if(this.isCookieless())return;let t=pe(e);Object.keys(t).length!==0&&this.capture(m.set,{properties:{$set:t}});}async getAllFlags(){var r;let e=this.identity.getDistinctId(),t=await this.flagsClient.fetchDecisions(e);return this.cachedFlags={distinctId:e,flags:t.flags,variants:(r=t.variants)!=null?r:{}},t.flags}async isFeatureEnabled(e){var i,o,s,a;let r=(i=(await this.getAllFlags())[e])!=null?i:false;return this.recordExposure(e,(a=(s=(o=this.cachedFlags)==null?void 0:o.variants[e])==null?void 0:s.key)!=null?a:String(r)),r}async getVariant(e){var i,o,s,a;let t=await this.getAllFlags(),r=(o=(i=this.cachedFlags)==null?void 0:i.variants[e])!=null?o:null;return this.recordExposure(e,(a=r==null?void 0:r.key)!=null?a:String((s=t[e])!=null?s:false)),r}async getVariantLocal(e,t={}){var l;let r=await this.flagSnapshot(),i=r.flags.find(u=>u.key===e),o=await this.localContext(t,r.flags),s=i?se(i,r.flags,o):null,a=i?D(i,r.flags,o).enabled:false;return this.recordExposure(e,(l=s==null?void 0:s.key)!=null?l:String(a)),s?{key:s.key,value:s.value}:null}recordExposure(e,t){let r=`${this.identity.getDistinctId()} ${e} ${t}`;this.exposures.has(r)||(this.exposures.add(r),this.capture(m.featureFlagCalled,{properties:{$feature_flag:e,$feature_flag_response:t}}));}getCachedFlag(e){if(!(!this.cachedFlags||this.cachedFlags.distinctId!==this.distinctId))return this.cachedFlags.flags[e]}async getLocalFlags(e={}){let t=await this.flagSnapshot();return Ge(t.flags,await this.localContext(e,t.flags))}async isFeatureEnabledLocal(e,t={}){var a,l;let r=await this.flagSnapshot(),i=r.flags.find(u=>u.key===e),o=await this.localContext(t,r.flags),s=i?D(i,r.flags,o).enabled:false;return this.recordExposure(e,(l=i?(a=se(i,r.flags,o))==null?void 0:a.key:void 0)!=null?l:String(s)),s}async localContext(e,t){let r=this.identity.getDistinctId(),i=e.cohorts;if(i===void 0&&Ve(t)){let o=this.config.clock.now().getTime();this.membershipCache&&this.membershipCache.distinctId===r&&o-this.membershipCache.fetchedAt<Ze?i=this.membershipCache.cohorts:(i=await this.flagsClient.memberships(r),this.membershipCache={cohorts:i,distinctId:r,fetchedAt:o});}return {attributes:e.attributes,cohorts:i,distinctId:r,properties:e.properties}}async flagSnapshot(){let e=this.config.clock.now().getTime();if(this.cachedSnapshot&&e-this.cachedSnapshot.fetchedAt<Ze)return this.cachedSnapshot.snapshot;let t=await this.flagsClient.snapshot();return this.cachedSnapshot={fetchedAt:e,snapshot:t},this.maybeStream(t),t}maybeStream(e){if(!this.config.streamFlags||this.shutDown||this.stream||!e.socketUrl)return;let t=new q({host:e.socketUrl,onChange:()=>{this.cachedSnapshot=void 0,this.flagSnapshot().catch(r=>this.config.onError(r));},onClosed:r=>{this.stream=void 0,r&&this.maybeStream(e);},projectKey:this.config.apiKey,socketFactory:this.config.socketFactory});this.stream=t,t.open();}async getInbox(){return this.messagesClient.inbox(this.identity.getDistinctId())}async markMessageRead(e){await this.messagesClient.markRead(e,this.identity.getDistinctId());}async getSurveys(e){return this.surveysClient.surveys(this.identity.getDistinctId(),e!=null?e:this.config.locale)}captureSurveyShown(e){this.capture(Je,{properties:V(e,{})});}captureSurveyDismissed(e){this.capture(We,{properties:V(e,{})});}captureSurveySent(e,t){this.capture(ze,{properties:V(e,t)});}async getGuides(){return this.guidesClient.guides(this.identity.getDistinctId())}captureGuide(e,t,r){this.capture(e,{properties:Ye(t,r)});}async getForm(e){return this.formsClient.form(e,this.identity.getDistinctId())}async submitForm(e,t,r,i){let{$page_id:o,$page_variant:s}=this.config.defaultProperties();return this.formsClient.submit(e,{answers:t,challenge:r,distinctId:this.identity.getDistinctId(),isAnonymous:!this.identity.isIdentified(),pageUrl:typeof window=="undefined"?"":window.location.href,solution:i,...typeof o=="string"&&typeof s=="string"?{pageId:o,pageVariant:s}:{}})}async getCtas(e){return this.ctasClient.ctas({...e,anonymous:!this.identity.isIdentified(),distinctId:this.identity.getDistinctId()})}captureCta(e,t,r){this.capture(e,{properties:Le(t,r)});}async flush(){if(this.flushing||this.queue.size===0)return;this.flushing=true;let e=this.queue.drain(Dt);try{await this.transport.send({body:{events:e,sent_at:O(this.config.clock.now())},projectKey:this.config.apiKey,url:`${this.config.host}/v1/events`}),this.persistQueue();}catch(t){this.queue.requeue(e),this.persistQueue(),this.config.onError(t);}finally{this.flushing=false;}}reset(){var e;(e=this.session)==null||e.reset(),this.identity.reset(),this.cachedFlags=void 0,this.cachedSnapshot=void 0,this.membershipCache=void 0;}async shutdown(){var e;this.shutDown=true,this.stopTimer(),(e=this.stream)==null||e.close(),this.stream=void 0,await this.flush();}enqueue(e){this.queue.enqueue(e),this.persistQueue(),this.queue.size>=this.config.flushAt&&this.flush();}persistQueue(){try{this.config.storage.setItem(this.persistKey(),JSON.stringify(this.queue.snapshot()));}catch(e){this.config.onError(e);}}restoreQueue(){try{let e=this.config.storage.getItem(this.persistKey());if(!e)return;let t=JSON.parse(e);Array.isArray(t)&&this.queue.restore(t);}catch(e){this.config.onError(e);}}startTimer(){if(this.config.flushIntervalMs<=0)return;let e=setInterval(()=>{this.flush();},this.config.flushIntervalMs),t=e;typeof t.unref=="function"&&t.unref(),this.flushTimer=e;}stopTimer(){this.flushTimer!==void 0&&(clearInterval(this.flushTimer),this.flushTimer=void 0);}persistKey(){return `pdx.${this.config.namespace}.${Rt}`}};var qt="data-prodantix",Kt="data-prodantix-action",jt="data-prodantix-ignore",$=300,ge="data-pdx-no-capture",me="pdx-no-capture",Gt=new Set(["a","button","input","label","option","select","summary","textarea"]),Vt=new Set(["button","checkbox","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","switch","tab","treeitem"]);function Bt(n){var e;return Gt.has(n.tagName.toLowerCase())||Vt.has(((e=n.getAttribute("role"))!=null?e:"").trim().toLowerCase())}function tt(n){for(let e=n;e!==null;e=e.parentElement)if(Bt(e))return e;return n}function nt(n){for(let e=n;e!==null;e=e.parentElement)if(e.getAttribute(jt)!==null)return true;return false}function rt(n){for(let e=n;e!==null;e=e.parentElement)if(e.getAttribute(ge)!==null||typeof e.className=="string"&&e.className.split(/\s+/).includes(me))return true;return false}function it(n){let e=new Set;return t=>{e.has(t.message)||(e.add(t.message),n(t));}}function et(n,e,t){let r=n.getAttribute(e);if(r===null)return;let i=r.trim();if(i!==""){if(i.length>$){t(new b("validation",`${e} on a <${n.tagName.toLowerCase()}> is ${i.length} characters, over the ${$}-character limit, so it was ignored: "${i.slice(0,40)}\u2026"`));return}return i}}function st(n,e){let t={},r=et(n,qt,e);r!==void 0&&(t.$el_description=r,t.$el_description_source="annotation");let i=et(n,Kt,e);return i!==void 0&&(t.$el_action=i),t}var Ut="$form_submitted",Ht=new Set(["button","file","hidden","image","password","reset","submit"]),ot=/(card|cc-?num|cvc|cvv|iban|security.?code)/i,Jt=n=>{var t;return ((t=n.getAttribute("autocomplete"))!=null?t:"").startsWith("cc-")||ot.test(n.name)||ot.test(n.id)},Wt=n=>{let e=n.name.toLowerCase();return n instanceof HTMLInputElement&&n.type==="email"||e==="email"||n.getAttribute("autocomplete")==="email"?"$email":e==="name"||e==="full_name"||e==="fullname"||n.getAttribute("autocomplete")==="name"?"$name":null},zt=(n,e)=>{var i,o;if(n.closest("[data-prodantix-ignore]")||n.hasAttribute("data-prodantix-form"))return null;let t={},r={};for(let s of Array.from(n.elements)){if(!(s instanceof HTMLInputElement||s instanceof HTMLSelectElement||s instanceof HTMLTextAreaElement)||!s.name||s.closest("[data-prodantix-ignore]")||Jt(s)||s instanceof HTMLInputElement&&(Ht.has(s.type)||(s.type==="checkbox"||s.type==="radio")&&!s.checked))continue;let a=s.value.trim();if(a==="")continue;t[s.name]=a;let l=Wt(s);l&&(r[l]=a);}return {$answers:t,$form_id:n.id||`${e}#${Array.from(n.ownerDocument.forms).indexOf(n)}`,$page_url:(o=(i=n.ownerDocument.location)==null?void 0:i.href)!=null?o:"",$set:r,collected:true}},at=(n,e=document)=>{let t=r=>{var i,o;if(r.target instanceof HTMLFormElement){let s=zt(r.target,(o=(i=e.location)==null?void 0:i.pathname)!=null?o:"");s&&n.capture(Ut,{properties:s});}};return e.addEventListener("submit",t,true),()=>e.removeEventListener("submit",t,true)};var Yt=new Set(["input","select","textarea"]),Qt=new Set(["email","password","tel"]);function X(){return globalThis.location}function ct(){return globalThis.document}function Xt(){let n=globalThis.window;return n!=null?n:globalThis}function Zt(n){return typeof n=="object"&&n!==null&&typeof n.tagName=="string"}function Q(n,e){let t;try{t=new URL(n,e);}catch(r){return}return t.protocol==="http:"||t.protocol==="https:"?`${t.origin}${t.pathname}`:t.protocol}function lt(){let n=X(),e=ct(),t={};if(n){let r=Q(n.href);r&&(t.$current_url=r),t.$pathname=n.pathname,t.$host=n.host;}if(e){e.title&&(t.$title=e.title);let r=e.referrer?Q(e.referrer):void 0;r&&(t.$referrer=r);}return t}function en(n){return typeof n.className=="string"?n.className:""}function tn(n){var e;return Yt.has(n.tagName.toLowerCase())||Qt.has(((e=n.getAttribute("type"))!=null?e:"").toLowerCase())}function nn(n,e,t){var l,u;let r={$el_tag:n.tagName.toLowerCase(),$event_type:"click"};if(e)return r;let i=t?(l=n.textContent)==null?void 0:l.trim():void 0;i&&(r.$el_text=i.slice(0,255)),n.id&&(r.$el_id=n.id);let o=en(n);o&&(r.$el_classes=o);let s=n.getAttribute("href"),a=s?Q(s,(u=X())==null?void 0:u.href):void 0;return a&&(r.$el_href=a),r}function he(n){return (n!=null?n:"").replace(/\s+/g," ").trim()}function P(n,e){return {$el_description:n,$el_description_source:e}}function rn(n,e,t){var s;if(!e&&t){let a=he(n.getAttribute("aria-label"));if(a!==""&&a.length<=$)return P(a,"aria_label");let l=he(n.textContent);if(l!==""&&l.length<=$)return P(l,"text")}let r=e?null:n.getAttribute("href"),i=r?Q(r,(s=X())==null?void 0:s.href):void 0;if(i)return P(i,"href");let o=he(n.getAttribute("role")).toLowerCase();return o===""?P(n.tagName.toLowerCase(),"tag"):P(o,"role")}function sn(n,e){let t=new Set,r=(u,d)=>{if(t.has(u))return false;try{return d()}catch(g){return t.add(u),e(new b("config",`autocapture maskSelectors entry "${u}" is not a valid selector`,{cause:g})),false}},i=(u,d)=>u.matches?r(d,()=>{var g;return ((g=u.matches)==null?void 0:g.call(u,d))===!0}):false,o=u=>{var g;let d=(g=u.querySelector)==null?void 0:g.bind(u);return d?d(`[${ge}], .${me}`)!==null||n.some(v=>r(v,()=>d(v)!==null)):false},s=u=>{for(let d=u;d;d=d.parentElement){let g=d;if(n.some(v=>i(g,v)))return true}return false},a=u=>{for(let d=u;d;d=d.parentElement)if(tn(d))return true;return false},l=u=>rt(u)||s(u);return {holdsMasked:o,isMasked:u=>l(u)||a(u),isOptedOut:l}}function on(n){let e=globalThis.history,t=Xt(),r="",i=()=>{let a=X(),l=a?`${a.pathname}${a.search}`:"";l!==r&&(r=l,n.capture(m.pageview,{properties:lt()}));};if(i(),!e||!t)return ()=>{};let o=e.pushState.bind(e),s=e.replaceState.bind(e);return e.pushState=(...a)=>{o(...a),i();},e.replaceState=(...a)=>{s(...a),i();},t.addEventListener("popstate",i),()=>{e.pushState=o,e.replaceState=s,t.removeEventListener("popstate",i);}}function an(n,e){var l,u,d;let t=ct();if(!t)return ()=>{};let r=(l=e.onError)!=null?l:(()=>{}),i=sn((u=e.maskSelectors)!=null?u:[],r),o=it(r),s=(d=e.captureElementText)!=null?d:false,a=g=>{let v=g.target;if(!Zt(v)||nt(v))return;let k=tt(v),_=i.isMasked(v)||i.holdsMasked(k),I=i.isOptedOut(v)?{}:st(k,o),L=I.$el_description===void 0?rn(k,_,s):{};n.capture(m.autocapture,{properties:{...lt(),...nn(k,_,s),...L,...I}});};return t.addEventListener("click",a,true),()=>t.removeEventListener("click",a,true)}function ut(n,e={}){var r,i;let t=[];return ((r=e.pageviews)==null||r)&&t.push(on(n)),((i=e.clicks)==null||i)&&t.push(an(n,e)),e.collectForms===true&&typeof document!="undefined"&&t.push(at(n)),()=>{for(let o of t)o();}}function cn(){let n=globalThis.document;return (n==null?void 0:n.visibilityState)==="hidden"}function ln(n){let e=globalThis.navigator,t=globalThis.Blob;if(!(e!=null&&e.sendBeacon)||!t)return false;let r=JSON.stringify({...n.body,api_key:n.projectKey});try{let i=new t([r],{type:"application/json"});return e.sendBeacon(n.url,i)}catch(i){return false}}var Z=class{constructor(e={}){c(this,"fetchTransport");this.fetchTransport=new C(e);}async send(e){cn()&&ln(e)||await this.fetchTransport.send(e);}};var fe="prodantix:consent-ready",ye="prodantix:consent",dt="__prodantixConsent";var pt=(n,e)=>{n.takeCookielessId(e.anonymousId),e.consent!==null?n.setConsent(e.consent):e.rule==="notice"&&n.allowStorage();},gt=(n,e)=>{let t=e[dt];t&&pt(n,t);let r=o=>{let s=o.detail;s&&pt(n,s);},i=o=>{let s=o.detail;s&&n.setConsent(s);};return e.addEventListener(fe,r),e.addEventListener(ye,i),()=>{e.removeEventListener(fe,r),e.removeEventListener(ye,i);}};var un=/^\d{1,3}(\.\d{1,3}){3}$/,dn=/^[a-z0-9.-]+$/i;function mt(){return Math.random().toString(36).slice(2,12)}function ee(n,e){let t=`${e}=`,r=[];for(let i of n.cookie.split(";")){let o=i.trim();o.startsWith(t)&&r.push(o.slice(t.length));}return r}function M(n,e,t){let r=["Path=/",`Max-Age=${e}`,"SameSite=Lax"];return n&&r.push(`Domain=${n}`),t&&r.push("Secure"),r.join("; ")}function ht(n,e,t,r){try{let i=`pdx_probe_${r()}`,o=r();n.cookie=`${i}=${o}; ${M(e,60,t)}`;let s=ee(n,i).includes(o);n.cookie=`${i}=; ${M(e,0,t)}`;let a=ee(n,i).includes(o);return s&&!a}catch(i){return false}}function pn(n){let e=n.replace(/^\[|\]$/g,"").toLowerCase();if(e.includes(":")||un.test(e)||!e.includes("."))return [];let t=e.split("."),r=[];for(let i=t.length-2;i>=0;i-=1)r.push(t.slice(i).join("."));return r}function gn(n,e,t,r=mt){for(let i of pn(n))if(ht(e,i,t,r))return i}function mn(n){let e=new Map,t=JSON.parse(decodeURIComponent(n));if(t===null||typeof t!="object"||Array.isArray(t))return e;for(let[r,i]of Object.entries(t))typeof i=="string"&&e.set(r,i);return e}var ve=class{constructor(e,t,r,i){this.jar=e;this.name=t;this.domain=r;this.secure=i;}getItem(e){var t;return (t=this.read().get(e))!=null?t:null}setItem(e,t){let r=this.read();r.set(e,t),this.write(r);}removeItem(e){let t=this.read();t.delete(e)&&this.write(t);}read(){try{let e=ee(this.jar,this.name);e.length>1&&this.domain&&(this.jar.cookie=`${this.name}=; ${M(void 0,0,this.secure)}`,e=ee(this.jar,this.name));let t=e[0];return t?mn(t):new Map}catch(e){return new Map}}write(e){try{if(e.size===0){this.jar.cookie=`${this.name}=; ${M(this.domain,0,this.secure)}`;return}let t=encodeURIComponent(JSON.stringify(Object.fromEntries(e)));this.jar.cookie=`${this.name}=${t}; ${M(this.domain,31536e3,this.secure)}`;}catch(t){return}}};function hn(){return globalThis.document}function fn(){var n,e;return (e=(n=globalThis.location)==null?void 0:n.hostname)!=null?e:""}function yn(){var n;return ((n=globalThis.location)==null?void 0:n.protocol)==="https:"}function vn(n){if(n===void 0)return;let e=n.startsWith(".")?n.slice(1):n;return dn.test(e)?e.toLowerCase():void 0}function ft(n){var s,a,l,u,d;let e="jar"in n?n.jar:hn();if(!e||((s=globalThis.navigator)==null?void 0:s.cookieEnabled)===false)return null;let r=(a=n.random)!=null?a:mt,i=(l=n.secure)!=null?l:yn(),o=(u=n.hostname)!=null?u:fn();try{let g=(d=vn(n.domain))!=null?d:gn(o,e,i,r);return ht(e,g,i,r)?new ve(e,n.name,g,i):null}catch(g){return null}}var yt=(n,e,t,r=Date.now)=>{let i=0,o=e.visibilityState==="visible"?r():void 0,s=()=>{o!==void 0&&(i+=r()-o,o=void 0,n(Math.round(i/1e3)));},a=()=>{e.visibilityState==="visible"?o!=null||(o=r()):s();};return e.addEventListener("visibilitychange",a),t.addEventListener("pagehide",s),()=>{e.removeEventListener("visibilitychange",a),t.removeEventListener("pagehide",s);}};var vt=(n,e)=>({...n.page?{$page_id:n.page}:{},...n.page&&e?{$page_view_id:e}:{},...n.variant?{$page_variant:n.variant}:{}});var bn=(n,e)=>{var t;try{return (t=ft({name:`pdx_${ne(n)}`}))!=null?t:e}catch(r){return e}},S=document.currentScript,be=S==null?void 0:S.dataset.key,bt,St;if(S&&be){let n=new URL(S.src,window.location.href).origin,e=xe(),t=S.dataset.consent==="banner",r=new Y({apiKey:be,...t?{consentMode:"banner"}:{},defaultProperties:vt(S.dataset,te()),flagsHost:(bt=S.dataset.edge)!=null?bt:n,host:(St=S.dataset.host)!=null?St:n,sharedStorage:bn(be,e),storage:e,transport:new Z({})});t&>(r,window),ut(r,{clicks:true,collectForms:false,pageviews:true}),yt(i=>{r.capture(m.pageleave,{properties:{$engaged_seconds:i}}),r.flush();},document,window);}})();//# sourceMappingURL=pages.iife.js.map
|
|
1
|
+
(function(){'use strict';var wt=Object.defineProperty;var Tt=(n,e,t)=>e in n?wt(n,e,{enumerable:true,configurable:true,writable:true,value:t}):n[e]=t;var c=(n,e,t)=>Tt(n,typeof e!="symbol"?e+"":e,t);var b=class extends Error{constructor(t,r,i){super(r,i);c(this,"code");this.code=t,this.name="ProdantixError";}},F=class extends b{constructor(e){super("config",e),this.name="ConfigError";}},T=class extends b{constructor(t,r){super("validation",r);c(this,"field");this.field=t,this.name="ValidationError";}},p=class extends b{constructor(t,r,i){super("transport",t,i);c(this,"status");this.status=r,this.name="TransportError";}};function y(n){if(n)return n;let e=globalThis.fetch;if(typeof e=="function")return e.bind(globalThis)}function h(){let n=globalThis.AbortController;return n?new n:void 0}var xe=n=>new Promise(e=>{setTimeout(e,n);});function g(n){return n.replace(/\/+$/,"")}var E=class{constructor(){c(this,"store",new Map);}getItem(e){var t;return (t=this.store.get(e))!=null?t:null}removeItem(e){this.store.delete(e);}setItem(e,t){this.store.set(e,t);}},A=class{constructor(e,t=()=>false){this.real=e;this.passes=t;c(this,"held",new E);c(this,"opened",false);}get isOpen(){return this.opened}open(){this.opened=true;}close(){this.opened=false;}target(e){return this.opened||this.passes(e)?this.real:this.held}getItem(e){return this.target(e).getItem(e)}removeItem(e){this.target(e).removeItem(e);}setItem(e,t){this.target(e).setItem(e,t);}};function we(){try{let n=globalThis.localStorage;if(n){let e="__pdx_probe__";return n.setItem(e,"1"),n.removeItem(e),n}}catch(n){return new E}return new E}var Te={now:()=>new Date};function L(n){return n.toISOString()}function Ce(){if(typeof window=="undefined"||typeof Intl=="undefined")return null;let n=Intl.DateTimeFormat().resolvedOptions().timeZone;return typeof n=="string"&&n!==""?n:null}function Ct(){return globalThis.crypto}function _t(n){n[6]=n[6]&15|64,n[8]=n[8]&63|128;let e=[];for(let t=0;t<16;t+=1)e.push(n[t].toString(16).padStart(2,"0"));return `${e[0]}${e[1]}${e[2]}${e[3]}-${e[4]}${e[5]}-${e[6]}${e[7]}-${e[8]}${e[9]}-${e[10]}${e[11]}${e[12]}${e[13]}${e[14]}${e[15]}`}function te(){let n=Ct();if(n!=null&&n.randomUUID)return n.randomUUID();let e=new Uint8Array(16);if(n!=null&&n.getRandomValues)n.getRandomValues(e);else for(let t=0;t<16;t+=1)e[t]=Math.floor(Math.random()*256);return _t(e)}var _e={uuid:te};var It=/^pdx_pub_(?:(?:live|test)_)?[a-z0-9]{32}$/;var Ft=/^(?:\$|[a-z])[a-z0-9_.]*$/;function Ie(n){let e=0;for(let t of n)e+=1;return e}function Fe(n){return It.test(n)}function At(n){return Ft.test(n)}function Ae(n){let e=Ie(n);if(e<1||e>200)throw new T("distinct_id","distinct_id must be between 1 and 200 characters")}function $e(n){let e=Ie(n);if(e<1||e>200)throw new T("event_name","event_name must be between 1 and 200 characters");if(!At(n))throw new T("event_name","event_name must match /^(\\$|[a-z])[a-z0-9_.]*$/")}var Pe="prodantix-js",Me="0.7.0";var $t=n=>{};function Oe(n){var i,o,s,a,l,u,d,f,v,k,_,I,O,ke,Ee;if(!n.apiKey||!Fe(n.apiKey))throw new F("apiKey must be a public project key of the form pdx_pub_<32 lowercase alphanumerics>");if(!n.host)throw new F("host is required (the ingest base URL)");let e=g(n.host),t=n.defaultProperties,r=(i=n.storage)!=null?i:new E;return {apiKey:n.apiKey,autocapture:(o=n.autocapture)!=null?o:false,clock:(s=n.clock)!=null?s:Te,consent:n.consent,consentMode:n.consentMode,defaultProperties:typeof t=="function"?t:()=>t!=null?t:{},describeElement:n.describeElement,flagsHost:n.flagsHost?g(n.flagsHost):e,flushAt:(a=n.flushAt)!=null?a:20,flushIntervalMs:(l=n.flushIntervalMs)!=null?l:1e4,host:e,ids:(u=n.ids)!=null?u:_e,locale:n.locale,maxQueueSize:(d=n.maxQueueSize)!=null?d:1e3,maxRetries:(f=n.maxRetries)!=null?f:3,namespace:ne(n.apiKey),onError:(v=n.onError)!=null?v:$t,os:n.os,requestTimeoutMs:(k=n.requestTimeoutMs)!=null?k:1e4,sdkName:(_=n.sdkName)!=null?_:Pe,sdkVersion:(I=n.sdkVersion)!=null?I:Me,sessionTracking:(O=n.sessionTracking)!=null?O:false,sharedStorage:(ke=n.sharedStorage)!=null?ke:r,socketFactory:n.socketFactory,storage:r,streamFlags:(Ee=n.streamFlags)!=null?Ee:false,transport:n.transport}}function ne(n){return n.slice(0,16)}var Le=(n,e)=>{let t={$cta_id:n.id,$cta_kind:n.kind,$cta_variant:n.variant.key,$cta_version:n.version},r=e===void 0?void 0:n.variant.content.buttons[e];return r&&e!==void 0&&(t.$cta_button=e,t.$cta_button_label=r.label,r.action.kind==="form"&&(t.$cta_form_id=r.action.value)),t},N=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async ctas(e){let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=new URLSearchParams({anonymous:String(e.anonymous),device:e.device,distinct_id:e.distinctId,language:e.language,url:e.url}),i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let s=await t(`${this.host}/v1/ctas?${r.toString()}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(s.status<200||s.status>=300)throw new p(`ctas request failed with status ${s.status}`,s.status);return JSON.parse(await s.text()).ctas}finally{o!==void 0&&clearTimeout(o);}}};function Ne(n,e,t){var i,o,s;$e(n.eventName),Ae(n.distinctId);let r={distinct_id:n.distinctId,event_id:(i=n.eventId)!=null?i:t.uuid(),event_name:n.eventName,properties:(o=n.properties)!=null?o:{},schema_version:1,timestamp:L((s=n.timestamp)!=null?s:e.now())};return n.context&&(r.context=n.context),n.sessionId&&(r.session_id=n.sessionId),r}var w=Symbol("absent");function Pt(n,e){var i,o;if(n==="distinct_id")return e.distinctId;let t=(i=e.properties)!=null?i:{};if(Object.prototype.hasOwnProperty.call(t,n))return t[n];let r=(o=e.attributes)!=null?o:{};return Object.prototype.hasOwnProperty.call(r,n)?r[n]:w}function x(n){return n===w?"undefined":String(n)}function Re(n){return n===w?Number.NaN:Number(n)}function De(n){return n!==w&&n!==null&&n!==""}function qe(n,e){if(!Array.isArray(e))return false;let t=x(n);return e.map(r=>String(r)).includes(t)}function Ke(n,e){var i,o;let t=Pt(n.attribute,e),r=n.value;switch(n.op){case "is_set":return De(t);case "is_not_set":return !De(t);case "eq":return x(t)===x(r===void 0?w:r);case "neq":return x(t)!==x(r===void 0?w:r);case "contains":return x(t).includes(x(r===void 0?w:r));case "in":return qe(t,r);case "not_in":return Array.isArray(r)?!qe(t,r):false;case "gt":return R(t,r,(s,a)=>s>a);case "gte":return R(t,r,(s,a)=>s>=a);case "lt":return R(t,r,(s,a)=>s<a);case "lte":return R(t,r,(s,a)=>s<=a);case "in_cohort":return typeof r=="string"&&r!==""&&((i=e.cohorts)!=null?i:[]).includes(r);case "not_in_cohort":return typeof r=="string"&&r!==""&&!((o=e.cohorts)!=null?o:[]).includes(r);default:return false}}function R(n,e,t){let r=Re(n),i=e===void 0?Number.NaN:Re(e);return Number.isNaN(r)||Number.isNaN(i)?false:t(r,i)}function Ve(n,e){let t=`${n}:${e}`,r=2166136261;for(let i=0;i<t.length;i++)r^=t.charCodeAt(i),r=Math.imul(r,16777619);return (r>>>0)%100}function re(n,e){return n.targeting.length===0||n.targeting.every(t=>Ke(t,e))}function je(n,e){var o;let t=Ve(n.key,e.distinctId),r=(o=n.variations)!=null?o:[];if(r.length===0)return n.rolloutPercentage>=100||t<n.rolloutPercentage?"true":"false";let i=0;for(let s=r.length-1;s>=0;s--)if(i+=r[s].weight,t<i)return r[s].key;return r[0].key}function ie(n,e,t,r){var i;for(let o of (i=n.prerequisites)!=null?i:[]){if(r.includes(o.flagKey))return false;let s=e.find(l=>l.key===o.flagKey);if(!s||!s.enabled)return false;r.push(s.key);let a=ie(s,e,t,r)&&re(s,t)&&je(s,t)===o.variationKey;if(r.pop(),!a)return false}return true}function D(n,e,t){return n.enabled?ie(n,e,t,[n.key])?re(n,t)?n.rolloutPercentage>=100?{enabled:true,reason:"rollout_full"}:Ve(n.key,t.distinctId)<n.rolloutPercentage?{enabled:true,reason:"rollout"}:{enabled:false,reason:"rollout_excluded"}:{enabled:false,reason:"targeting"}:{enabled:false,reason:"prerequisite"}:{enabled:false,reason:"disabled"}}function Ge(n,e){let t={};for(let r of n)t[r.key]=D(r,n,e).enabled;return t}function se(n,e,t){var s,a;let r=(s=n.variations)!=null?s:[],i=r[0];if(!i)return null;if(!n.enabled||!ie(n,e,t,[n.key])||!re(n,t))return i;let o=je(n,t);return (a=r.find(l=>l.key===o))!=null?a:i}function Be(n){return n.some(e=>e.targeting.some(t=>t.op==="in_cohort"||t.op==="not_in_cohort"))}function Ue(n){return `40${JSON.stringify(n)}`}function He(){return "3"}function Je(n){let e=n.charAt(0),t=n.slice(1);if(e==="2")return {kind:"ping"};if(e==="1")return {kind:"disconnect"};if(e==="0"){let s=oe(t);return {kind:"open",pingInterval:typeof(s==null?void 0:s.pingInterval)=="number"?s.pingInterval:25e3,pingTimeout:typeof(s==null?void 0:s.pingTimeout)=="number"?s.pingTimeout:2e4}}if(e!=="4")return {kind:"other"};let r=t.charAt(0),i=t.slice(1);if(r==="0")return {kind:"connected"};if(r==="1")return {kind:"disconnect"};if(r==="4"){let s=oe(i);return {kind:"connectError",message:typeof(s==null?void 0:s.message)=="string"?s.message:"refused"}}if(r!=="2")return {kind:"other"};let o=oe(i);return !Array.isArray(o)||typeof o[0]!="string"?{kind:"other"}:{kind:"event",name:o[0],payload:o[1]}}function oe(n){try{return JSON.parse(n)}catch(e){return null}}var Mt="/socket.io/?EIO=4&transport=websocket",Ot=250,q=class{constructor(e){this.options=e;c(this,"socket",null);c(this,"heartbeat",null);c(this,"pending",null);c(this,"lastKey","");c(this,"ready",false);c(this,"closed",false);c(this,"heartbeatWindow",45e3);c(this,"factory");c(this,"setTimer");c(this,"clearTimer");var t,r,i;this.factory=(t=e.socketFactory)!=null?t:Lt,this.setTimer=(r=e.setTimer)!=null?r:((o,s)=>setTimeout(o,s)),this.clearTimer=(i=e.clearTimer)!=null?i:(o=>clearTimeout(o));}open(){if(this.socket||this.closed)return;let e=`${this.options.host.replace(/^http/,"ws").replace(/\/+$/,"")}${Mt}`,t;try{t=this.factory(e);}catch(r){this.options.onClosed(false);return}this.socket=t,t.onmessage=r=>this.receive(String(r.data)),t.onerror=()=>t.close(),t.onclose=()=>this.fell();}close(){this.closed=true,this.stopHeartbeat(),this.pending!==null&&this.clearTimer(this.pending),this.pending=null;let e=this.socket;this.socket=null,e==null||e.close();}receive(e){var r,i,o,s;let t=Je(e);if(t.kind==="open"){this.armHeartbeat(t.pingInterval+t.pingTimeout),(r=this.socket)==null||r.send(Ue({projectKey:this.options.projectKey}));return}if(t.kind==="ping"){this.armHeartbeat(),(i=this.socket)==null||i.send(He());return}if(t.kind==="connectError"||t.kind==="disconnect"){this.stopHeartbeat(),(o=this.socket)==null||o.close();return}if(t.kind==="event"){if(t.name==="ready"){this.ready=true;return}if(t.name==="flagChange"){let a=(s=t.payload)==null?void 0:s.key;this.lastKey=typeof a=="string"?a:"",this.pending===null&&(this.pending=this.setTimer(()=>{this.pending=null,this.options.onChange(this.lastKey);},Ot));}}}fell(){this.stopHeartbeat();let e=this.ready;this.socket=null,this.ready=false,this.closed||this.options.onClosed(e);}armHeartbeat(e){e!==void 0&&(this.heartbeatWindow=e),this.stopHeartbeat(),this.heartbeat=this.setTimer(()=>{var t;return (t=this.socket)==null?void 0:t.close()},this.heartbeatWindow);}stopHeartbeat(){this.heartbeat!==null&&this.clearTimer(this.heartbeat),this.heartbeat=null;}};function Lt(n){let e=globalThis.WebSocket;if(!e)throw new p("no WebSocket");return new e(n)}var K=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async fetchAll(e){return (await this.fetchDecisions(e)).flags}async fetchDecisions(e){var s,a;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags?distinct_id=${encodeURIComponent(e)}`,i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let l=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!l.ok)throw new p(`flags request failed with status ${l.status}`,l.status);let u=JSON.parse(await l.text());return {flags:(s=u.flags)!=null?s:{},variants:(a=u.variants)!=null?a:{}}}finally{o!==void 0&&clearTimeout(o);}}async snapshot(){var o;let e=this.fetch;if(!e)throw new p("no fetch implementation available in this runtime");let t=`${this.host}/v1/flags/snapshot`,r=h(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let s=await e(t,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r==null?void 0:r.signal});if(!s.ok)throw new p(`flag snapshot request failed with status ${s.status}`,s.status);let a=JSON.parse(await s.text()),l={flags:(o=a.flags)!=null?o:[],generatedAt:a.generatedAt};return typeof a.socketUrl=="string"&&a.socketUrl!==""&&(l.socketUrl=a.socketUrl),l}finally{i!==void 0&&clearTimeout(i);}}async memberships(e){var s;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=`${this.host}/v1/flags/memberships?distinct_id=${encodeURIComponent(e)}`,i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let a=await t(r,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!a.ok)throw new p(`memberships request failed with status ${a.status}`,a.status);return (s=JSON.parse(await a.text()).cohorts)!=null?s:[]}finally{o!==void 0&&clearTimeout(o);}}};var ae=class extends Error{constructor(t,r,i){super(i);c(this,"fields");c(this,"status");this.name="FormRefusedError",this.status=t,this.fields=r;}},V=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async request(e,t){let r=this.fetch;if(!r)throw new p("no fetch implementation available in this runtime");let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let s={authorization:`Bearer ${this.projectKey}`};t.body!==void 0&&(s["content-type"]="application/json");let a=await r(`${this.host}${e}`,{body:t.body,headers:s,method:t.method,signal:i==null?void 0:i.signal});return {status:a.status,text:await a.text()}}finally{o!==void 0&&clearTimeout(o);}}async form(e,t){let{status:r,text:i}=await this.request(`/v1/forms/${encodeURIComponent(e)}?distinct_id=${encodeURIComponent(t)}`,{method:"GET"});if(r<200||r>=300)throw new p(`form request failed with status ${r}`,r);return JSON.parse(i)}async submit(e,t){var a,l,u,d;let{status:r,text:i}=await this.request(`/v1/forms/${encodeURIComponent(e)}/submissions`,{body:JSON.stringify(t),method:"POST"});if(r>=200&&r<300)return JSON.parse(i).afterSubmit;let o=[],s=`form submission failed with status ${r}`;try{let f=JSON.parse(i);o=(l=(a=f.error)==null?void 0:a.fields)!=null?l:[],s=(d=(u=f.error)==null?void 0:u.message)!=null?d:s;}catch(f){o=[];}throw new ae(r,o,s)}};var We="$survey_shown",ze="$survey_dismissed",Ye="$survey_sent",j=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async surveys(e,t){var s;let r=this.fetch;if(!r)throw new p("no fetch implementation available in this runtime");let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{let a=await r(`${this.host}/v1/surveys?distinct_id=${encodeURIComponent(e)}${t?`&lang=${encodeURIComponent(t)}`:""}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:i==null?void 0:i.signal});if(!a.ok)throw new p(`surveys request failed with status ${a.status}`,a.status);return (s=JSON.parse(await a.text()).surveys)!=null?s:[]}finally{o!==void 0&&clearTimeout(o);}}};function G(n,e){let t={$survey_id:n.id,$survey_iteration:n.iteration,$survey_name:n.name};for(let[r,i]of Object.entries(e))t[`$survey_response_${r}`]=i;return t}var B=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async guides(e){var o;let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=h(),i=r?setTimeout(()=>r.abort(),this.requestTimeoutMs):void 0;try{let s=await t(`${this.host}/v1/guides?distinct_id=${encodeURIComponent(e)}`,{headers:{authorization:`Bearer ${this.projectKey}`},method:"GET",signal:r==null?void 0:r.signal});if(!s.ok)throw new p(`guides request failed with status ${s.status}`,s.status);return (o=JSON.parse(await s.text()).guides)!=null?o:[]}finally{i!==void 0&&clearTimeout(i);}}};function Qe(n,e){let t={$guide_id:n.id,$guide_iteration:n.iteration,$guide_name:n.name};return e!==void 0&&(t.$guide_step_id=e),t}function ce(n){if(typeof n!="string")return;let e=Array.from(n).length;return e>=1&&e<=200?n:void 0}function ue(n,e){return `pdx.${n}.${e}`}var de="consent",Nt=["identityLink","analytics","marketing","functional"];function le(n){if(typeof n!="string")return null;try{let e=JSON.parse(n);if(e===null||typeof e!="object"||Array.isArray(e))return null;let t=e,r={};for(let i of Nt){let o=t[i];typeof o=="boolean"&&(r[i]=o);}return typeof t.version=="number"&&Number.isInteger(t.version)&&(r.version=t.version),Array.isArray(t.categories)&&t.categories.every(i=>typeof i=="string")&&(r.categories=t.categories),Object.keys(r).length===0?null:r}catch(e){return null}}var Xe=n=>n.endsWith(`.${de}`);function H(n,e){return le(n.getItem(ue(e,de)))}function Rt(n,e,t){var s;let r=ue(e,de),i=le(JSON.stringify(t)),o=i===null?null:le(JSON.stringify({...(s=H(n,e))!=null?s:{},...i}));if(o===null){n.removeItem(r);return}n.setItem(r,JSON.stringify(o));}var U=class{constructor(e,t,r,i){this.storage=e;this.shared=t;this.ids=r;this.namespace=i;c(this,"anonymousId");c(this,"distinctId");c(this,"identified");this.refresh();}refresh(){let e=ce(this.shared.getItem(this.key("anonymous_id"))),t=ce(this.storage.getItem(this.key("anonymous_id")));e?(this.anonymousId=e,t!==e&&this.storage.setItem(this.key("anonymous_id"),e)):t?(this.anonymousId=t,this.shared.setItem(this.key("anonymous_id"),t)):(this.anonymousId=this.ids.uuid(),this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId));let r=ce(this.storage.getItem(this.key("distinct_id")));r?(this.distinctId=r,this.identified=true):(this.distinctId=this.anonymousId,this.identified=false);}getAnonymousId(){return this.anonymousId}getDistinctId(){return this.distinctId}isIdentified(){return this.identified}snapshot(){return {anonymousId:this.anonymousId,distinctId:this.distinctId,identified:this.identified}}consent(){return H(this.shared,this.namespace)}setConsent(e){Rt(this.shared,this.namespace,e);}assumeAnonymousId(e){this.anonymousId=e,this.shared.setItem(this.key("anonymous_id"),e),this.storage.setItem(this.key("anonymous_id"),e),this.identified||(this.distinctId=e);}identify(e){var o;let t=!this.identified||this.distinctId!==e,r=this.storage.getItem(this.key("linked_anonymous_id")),i=t||r!==this.anonymousId;return this.distinctId=e,this.identified=true,t&&this.storage.setItem(this.key("distinct_id"),e),!i||((o=this.consent())==null?void 0:o.identityLink)===false?{changed:t}:(this.storage.setItem(this.key("linked_anonymous_id"),this.anonymousId),{anonymousToLink:this.anonymousId,changed:t})}reset(){this.anonymousId=this.ids.uuid(),this.distinctId=this.anonymousId,this.identified=false,this.shared.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.setItem(this.key("anonymous_id"),this.anonymousId),this.storage.removeItem(this.key("distinct_id")),this.storage.removeItem(this.key("linked_anonymous_id"));}key(e){return ue(this.namespace,e)}};var J=class{constructor(e){c(this,"fetch");c(this,"host");c(this,"projectKey");c(this,"requestTimeoutMs");var t;this.fetch=y(e.fetch),this.host=g(e.host),this.projectKey=e.projectKey,this.requestTimeoutMs=(t=e.requestTimeoutMs)!=null?t:1e4;}async inbox(e){var s;let t=this.requireFetch(),r=`${this.host}/v1/messages?distinct_id=${encodeURIComponent(e)}`,i=await this.request(t,r,{headers:this.authHeaders(),method:"GET"});if(!i.ok)throw new p(`inbox request failed with status ${i.status}`,i.status);return (s=JSON.parse(await i.text()).messages)!=null?s:[]}async markRead(e,t){let r=this.requireFetch(),i=`${this.host}/v1/messages/read`,o=await this.request(r,i,{body:JSON.stringify({distinct_id:t,message_id:e}),headers:{...this.authHeaders(),"content-type":"application/json"},method:"POST"});if(!o.ok)throw new p(`mark-read request failed with status ${o.status}`,o.status)}requireFetch(){if(!this.fetch)throw new p("no fetch implementation available in this runtime");return this.fetch}authHeaders(){return {authorization:`Bearer ${this.projectKey}`}}async request(e,t,r){let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{return await e(t,{...r,signal:i==null?void 0:i.signal})}finally{o!==void 0&&clearTimeout(o);}}};var W=class{constructor(e,t){this.maxSize=e;this.onOverflow=t;c(this,"events",[]);}get size(){return this.events.length}enqueue(e){this.events.push(e),this.enforceCap();}restore(e){this.events.push(...e),this.enforceCap();}requeue(e){this.events.unshift(...e),this.enforceCap();}drain(e){let t=e===void 0?this.events.length:Math.min(e,this.events.length);return this.events.splice(0,t)}snapshot(){return [...this.events]}enforceCap(){var t;if(this.events.length<=this.maxSize)return;let e=this.events.splice(0,this.events.length-this.maxSize);(t=this.onOverflow)==null||t.call(this,{dropped:e});}};var Dt={idleMs:18e5,maxMs:864e5,throttleMs:1e4};function qt(n){return `pdx.${n}.session`}var z=class{constructor(e,t,r,i,o=Dt){this.storage=e;this.ids=t;this.clock=r;this.namespace=i;this.options=o;}current(){return this.touch().id}startedAt(){return this.touch().startedAt}reset(){this.storage.removeItem(this.key());}touch(){let e=this.clock.now().getTime(),t=this.live(this.read(),e);if(t===void 0)return this.write({id:this.ids.uuid(),lastActivityAt:e,startedAt:e});if(e-t.lastActivityAt<=this.options.throttleMs)return t;let r=this.live(this.read(),e),i=r!==void 0&&r.id!==t.id?r:t;return this.write({...i,lastActivityAt:e})}live(e,t){if(e!==void 0&&!(t-e.lastActivityAt>this.options.idleMs||t-e.startedAt>this.options.maxMs))return e}write(e){return this.storage.setItem(this.key(),JSON.stringify(e)),e}read(){let e=this.storage.getItem(this.key());if(e)try{let t=JSON.parse(e);return typeof t.id=="string"&&typeof t.startedAt=="number"&&typeof t.lastActivityAt=="number"?{id:t.id,lastActivityAt:t.lastActivityAt,startedAt:t.startedAt}:void 0}catch(t){return}}key(){return qt(this.namespace)}};var m={autocapture:"$autocapture",createAlias:"$create_alias",featureFlagCalled:"$feature_flag_called",group:"$group",identify:"$identify",pageleave:"$pageleave",pageview:"$pageview",set:"$set",webVitals:"$web_vitals"};function Ze(n){return n>=400&&n<500&&n!==429}var C=class{constructor(e={}){c(this,"fetch");c(this,"maxRetries");c(this,"requestTimeoutMs");c(this,"baseDelayMs");c(this,"maxDelayMs");c(this,"sleep");c(this,"random");var t,r,i,o,s,a;this.fetch=y(e.fetch),this.maxRetries=(t=e.maxRetries)!=null?t:3,this.requestTimeoutMs=(r=e.requestTimeoutMs)!=null?r:1e4,this.baseDelayMs=(i=e.baseDelayMs)!=null?i:500,this.maxDelayMs=(o=e.maxDelayMs)!=null?o:3e4,this.sleep=(s=e.sleep)!=null?s:xe,this.random=(a=e.random)!=null?a:Math.random;}async send(e){let t=this.fetch;if(!t)throw new p("no fetch implementation available in this runtime");let r=JSON.stringify(e.body),i;for(let o=0;o<=this.maxRetries;o+=1){try{let s=await this.attempt(t,e,r);if(s.ok)return;if(Ze(s.status))throw new p(`ingest rejected batch with status ${s.status}`,s.status);i=new p(`ingest transient status ${s.status}`,s.status);}catch(s){if(s instanceof p&&s.status!==void 0&&Ze(s.status))throw s;i=s;}o<this.maxRetries&&await this.sleep(this.backoff(o));}throw new p("ingest delivery failed after retries",void 0,{cause:i})}async attempt(e,t,r){let i=h(),o=i?setTimeout(()=>i.abort(),this.requestTimeoutMs):void 0;try{return await e(t.url,{body:r,headers:{authorization:`Bearer ${t.projectKey}`,"content-type":"application/json"},method:"POST",signal:i==null?void 0:i.signal})}finally{o!==void 0&&clearTimeout(o);}}backoff(e){return Math.min(this.maxDelayMs,this.baseDelayMs*2**e)+this.random()*this.baseDelayMs}};var Kt="queue",Vt=1e3,et=3e4,pe=n=>{let e={};return n.avatar!==void 0&&(e.$avatar=n.avatar),n.email!==void 0&&(e.$email=n.email),n.name!==void 0&&(e.$name=n.name),n.phone!==void 0&&(e.$phone=n.phone),e},Y=class{constructor(e){c(this,"config");c(this,"identity");c(this,"session");c(this,"queue");c(this,"transport");c(this,"flagsClient");c(this,"messagesClient");c(this,"surveysClient");c(this,"guidesClient");c(this,"captureListeners",new Set);c(this,"formsClient");c(this,"ctasClient");c(this,"context");c(this,"flushTimer");c(this,"flushing",false);c(this,"cachedFlags");c(this,"cachedSnapshot");c(this,"membershipCache");c(this,"stream");c(this,"shutDown",false);c(this,"exposures",new Set);c(this,"gates");c(this,"cookielessId");c(this,"storageListeners",new Set);var s,a,l;let t=Oe(e),r=(a=(s=H(t.sharedStorage,t.namespace))!=null?s:t.consent)!=null?a:null;if(this.gates=[new A(t.storage),new A(t.sharedStorage,Xe)],t.consentMode!=="banner"||(r==null?void 0:r.analytics)===true)for(let u of this.gates)u.open();let[i,o]=this.gates;this.config={...t,sharedStorage:o,storage:i},this.identity=new U(this.config.storage,this.config.sharedStorage,this.config.ids,this.config.namespace),this.config.consent!==void 0&&this.identity.setConsent(this.config.consent),this.session=this.config.sessionTracking?new z(this.config.sharedStorage,this.config.ids,this.config.clock,this.config.namespace):void 0,this.queue=new W(this.config.maxQueueSize,({dropped:u})=>{this.config.onError(new b("queue_overflow",`event queue overflow: dropped ${u.length} oldest event(s)`));}),this.transport=(l=this.config.transport)!=null?l:new C({maxRetries:this.config.maxRetries,requestTimeoutMs:this.config.requestTimeoutMs}),this.flagsClient=new K({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.messagesClient=new J({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.surveysClient=new j({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.guidesClient=new B({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.formsClient=new V({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.ctasClient=new N({host:this.config.flagsHost,projectKey:this.config.apiKey,requestTimeoutMs:this.config.requestTimeoutMs}),this.context={sdk:this.config.sdkName,sdk_version:this.config.sdkVersion},this.config.os&&(this.context.os=this.config.os),this.config.locale&&(this.context.locale=this.config.locale),this.restoreQueue(),this.startTimer();}get distinctId(){return this.identity.getDistinctId()}get anonymousId(){return this.identity.getAnonymousId()}get isIdentified(){return this.identity.isIdentified()}get sessionId(){var e;return (e=this.session)==null?void 0:e.current()}get sessionStartedAt(){var e;return (e=this.session)==null?void 0:e.startedAt()}capture(e,t={}){var r,i,o,s,a,l,u;try{this.identity.refresh();let d={...this.config.defaultProperties(),...t.element===void 0?{}:(o=(i=(r=this.config).describeElement)==null?void 0:i.call(r,t.element))!=null?o:{},...(s=t.properties)!=null?s:{}},f=Ne({context:this.context,distinctId:(a=t.distinctId)!=null?a:this.identity.getDistinctId(),eventName:e,properties:d,sessionId:(u=t.sessionId)!=null?u:(l=this.session)==null?void 0:l.current(),timestamp:t.timestamp},this.config.clock,this.config.ids);this.enqueue(f);}catch(d){this.config.onError(d);}for(let d of this.captureListeners)try{d(e);}catch(f){this.config.onError(f);}}onCapture(e){return this.captureListeners.add(e),()=>{this.captureListeners.delete(e);}}identify(e,t={}){var a,l;if(this.isCookieless())return;this.identity.refresh();let r=this.identity.identify(e),i={};r.anonymousToLink!==void 0&&(i.$anon_distinct_id=r.anonymousToLink);let o=Ce(),s={...o===null?{}:{$timezone:o},...pe((a=t.traits)!=null?a:{}),...(l=t.set)!=null?l:{}};Object.keys(s).length>0&&(i.$set=s),this.capture(m.identify,{properties:i});}link(e,t,r){if(this.isCookieless())return;let i={$anon_distinct_id:t},o=pe(r!=null?r:{});Object.keys(o).length>0&&(i.$set=o),this.capture(m.identify,{distinctId:e,properties:i});}setConsent(e){this.identity.setConsent(e),e.analytics===true&&this.allowStorage(),e.analytics===false&&this.config.consentMode==="banner"&&this.forbidStorage();}isCookieless(){return !this.gates[0].isOpen}takeCookielessId(e){this.cookielessId=e,this.isCookieless()&&this.identity.assumeAnonymousId(e);}allowStorage(){if(this.isCookieless()){for(let e of this.gates)e.open();this.identity.refresh();for(let e of [...this.storageListeners])e();}}onStorageAllowed(e){return this.storageListeners.add(e),()=>{this.storageListeners.delete(e);}}forbidStorage(){if(!this.isCookieless()){for(let e of ["anonymous_id","distinct_id","linked_anonymous_id","session"])this.config.storage.removeItem(`pdx.${this.config.namespace}.${e}`),this.config.sharedStorage.removeItem(`pdx.${this.config.namespace}.${e}`);for(let e of this.gates)e.close();this.identity.refresh(),this.cookielessId!==void 0&&this.identity.assumeAnonymousId(this.cookielessId);}}consent(){return this.identity.consent()}alias(e){this.capture(m.createAlias,{properties:{alias:e}});}group(e,t,r){let i={$group_key:t,$group_type:e};r&&(i.$set=r),this.capture(m.group,{properties:i});}setPersonProperties(e,t){if(this.isCookieless())return;let r={};e&&(r.$set=e),t&&(r.$set_once=t),this.capture(m.set,{properties:r});}setPersonTraits(e){if(this.isCookieless())return;let t=pe(e);Object.keys(t).length!==0&&this.capture(m.set,{properties:{$set:t}});}async getAllFlags(){var r;let e=this.identity.getDistinctId(),t=await this.flagsClient.fetchDecisions(e);return this.cachedFlags={distinctId:e,flags:t.flags,variants:(r=t.variants)!=null?r:{}},t.flags}async isFeatureEnabled(e){var i,o,s,a;let r=(i=(await this.getAllFlags())[e])!=null?i:false;return this.recordExposure(e,(a=(s=(o=this.cachedFlags)==null?void 0:o.variants[e])==null?void 0:s.key)!=null?a:String(r)),r}async getVariant(e){var i,o,s,a;let t=await this.getAllFlags(),r=(o=(i=this.cachedFlags)==null?void 0:i.variants[e])!=null?o:null;return this.recordExposure(e,(a=r==null?void 0:r.key)!=null?a:String((s=t[e])!=null?s:false)),r}async getVariantLocal(e,t={}){var l;let r=await this.flagSnapshot(),i=r.flags.find(u=>u.key===e),o=await this.localContext(t,r.flags),s=i?se(i,r.flags,o):null,a=i?D(i,r.flags,o).enabled:false;return this.recordExposure(e,(l=s==null?void 0:s.key)!=null?l:String(a)),s?{key:s.key,value:s.value}:null}recordExposure(e,t){let r=`${this.identity.getDistinctId()} ${e} ${t}`;this.exposures.has(r)||(this.exposures.add(r),this.capture(m.featureFlagCalled,{properties:{$feature_flag:e,$feature_flag_response:t}}));}getCachedFlag(e){if(!(!this.cachedFlags||this.cachedFlags.distinctId!==this.distinctId))return this.cachedFlags.flags[e]}async getLocalFlags(e={}){let t=await this.flagSnapshot();return Ge(t.flags,await this.localContext(e,t.flags))}async isFeatureEnabledLocal(e,t={}){var a,l;let r=await this.flagSnapshot(),i=r.flags.find(u=>u.key===e),o=await this.localContext(t,r.flags),s=i?D(i,r.flags,o).enabled:false;return this.recordExposure(e,(l=i?(a=se(i,r.flags,o))==null?void 0:a.key:void 0)!=null?l:String(s)),s}async localContext(e,t){let r=this.identity.getDistinctId(),i=e.cohorts;if(i===void 0&&Be(t)){let o=this.config.clock.now().getTime();this.membershipCache&&this.membershipCache.distinctId===r&&o-this.membershipCache.fetchedAt<et?i=this.membershipCache.cohorts:(i=await this.flagsClient.memberships(r),this.membershipCache={cohorts:i,distinctId:r,fetchedAt:o});}return {attributes:e.attributes,cohorts:i,distinctId:r,properties:e.properties}}async flagSnapshot(){let e=this.config.clock.now().getTime();if(this.cachedSnapshot&&e-this.cachedSnapshot.fetchedAt<et)return this.cachedSnapshot.snapshot;let t=await this.flagsClient.snapshot();return this.cachedSnapshot={fetchedAt:e,snapshot:t},this.maybeStream(t),t}maybeStream(e){if(!this.config.streamFlags||this.shutDown||this.stream||!e.socketUrl)return;let t=new q({host:e.socketUrl,onChange:()=>{this.cachedSnapshot=void 0,this.flagSnapshot().catch(r=>this.config.onError(r));},onClosed:r=>{this.stream=void 0,r&&this.maybeStream(e);},projectKey:this.config.apiKey,socketFactory:this.config.socketFactory});this.stream=t,t.open();}async getInbox(){return this.messagesClient.inbox(this.identity.getDistinctId())}async markMessageRead(e){await this.messagesClient.markRead(e,this.identity.getDistinctId());}async getSurveys(e){return this.surveysClient.surveys(this.identity.getDistinctId(),e!=null?e:this.config.locale)}captureSurveyShown(e){this.capture(We,{properties:G(e,{})});}captureSurveyDismissed(e){this.capture(ze,{properties:G(e,{})});}captureSurveySent(e,t){this.capture(Ye,{properties:G(e,t)});}async getGuides(){return this.guidesClient.guides(this.identity.getDistinctId())}captureGuide(e,t,r){this.capture(e,{properties:Qe(t,r)});}async getForm(e){return this.formsClient.form(e,this.identity.getDistinctId())}async submitForm(e,t,r,i){let{$page_id:o,$page_variant:s}=this.config.defaultProperties();return this.formsClient.submit(e,{answers:t,challenge:r,distinctId:this.identity.getDistinctId(),isAnonymous:!this.identity.isIdentified(),pageUrl:typeof window=="undefined"?"":window.location.href,solution:i,...typeof o=="string"&&typeof s=="string"?{pageId:o,pageVariant:s}:{}})}async getCtas(e){return this.ctasClient.ctas({...e,anonymous:!this.identity.isIdentified(),distinctId:this.identity.getDistinctId()})}captureCta(e,t,r){this.capture(e,{properties:Le(t,r)});}async flush(){if(this.flushing||this.queue.size===0)return;this.flushing=true;let e=this.queue.drain(Vt);try{await this.transport.send({body:{events:e,sent_at:L(this.config.clock.now())},projectKey:this.config.apiKey,url:`${this.config.host}/v1/events`}),this.persistQueue();}catch(t){this.queue.requeue(e),this.persistQueue(),this.config.onError(t);}finally{this.flushing=false;}}reset(){var e;(e=this.session)==null||e.reset(),this.identity.reset(),this.cachedFlags=void 0,this.cachedSnapshot=void 0,this.membershipCache=void 0;}async shutdown(){var e;this.shutDown=true,this.stopTimer(),(e=this.stream)==null||e.close(),this.stream=void 0,await this.flush();}enqueue(e){this.queue.enqueue(e),this.persistQueue(),this.queue.size>=this.config.flushAt&&this.flush();}persistQueue(){try{this.config.storage.setItem(this.persistKey(),JSON.stringify(this.queue.snapshot()));}catch(e){this.config.onError(e);}}restoreQueue(){try{let e=this.config.storage.getItem(this.persistKey());if(!e)return;let t=JSON.parse(e);Array.isArray(t)&&this.queue.restore(t);}catch(e){this.config.onError(e);}}startTimer(){if(this.config.flushIntervalMs<=0)return;let e=setInterval(()=>{this.flush();},this.config.flushIntervalMs),t=e;typeof t.unref=="function"&&t.unref(),this.flushTimer=e;}stopTimer(){this.flushTimer!==void 0&&(clearInterval(this.flushTimer),this.flushTimer=void 0);}persistKey(){return `pdx.${this.config.namespace}.${Kt}`}};var jt="data-prodantix",Gt="data-prodantix-action",Bt="data-prodantix-ignore",$=300,fe="data-pdx-no-capture",me="pdx-no-capture",Ut=new Set(["a","button","input","label","option","select","summary","textarea"]),Ht=new Set(["button","checkbox","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","switch","tab","treeitem"]);function Jt(n){var e;return Ut.has(n.tagName.toLowerCase())||Ht.has(((e=n.getAttribute("role"))!=null?e:"").trim().toLowerCase())}function nt(n){for(let e=n;e!==null;e=e.parentElement)if(Jt(e))return e;return n}function rt(n){for(let e=n;e!==null;e=e.parentElement)if(e.getAttribute(Bt)!==null)return true;return false}function it(n){for(let e=n;e!==null;e=e.parentElement)if(e.getAttribute(fe)!==null||typeof e.className=="string"&&e.className.split(/\s+/).includes(me))return true;return false}function st(n){let e=new Set;return t=>{e.has(t.message)||(e.add(t.message),n(t));}}function tt(n,e,t){let r=n.getAttribute(e);if(r===null)return;let i=r.trim();if(i!==""){if(i.length>$){t(new b("validation",`${e} on a <${n.tagName.toLowerCase()}> is ${i.length} characters, over the ${$}-character limit, so it was ignored: "${i.slice(0,40)}\u2026"`));return}return i}}function ot(n,e){let t={},r=tt(n,jt,e);r!==void 0&&(t.$el_description=r,t.$el_description_source="annotation");let i=tt(n,Gt,e);return i!==void 0&&(t.$el_action=i),t}var Wt="$form_submitted",zt=new Set(["button","file","hidden","image","password","reset","submit"]),at=/(card|cc-?num|cvc|cvv|iban|security.?code)/i,Yt=n=>{var t;return ((t=n.getAttribute("autocomplete"))!=null?t:"").startsWith("cc-")||at.test(n.name)||at.test(n.id)},Qt=n=>{let e=n.name.toLowerCase();return n instanceof HTMLInputElement&&n.type==="email"||e==="email"||n.getAttribute("autocomplete")==="email"?"$email":e==="name"||e==="full_name"||e==="fullname"||n.getAttribute("autocomplete")==="name"?"$name":null},Xt=(n,e)=>{var i,o;if(n.closest("[data-prodantix-ignore]")||n.hasAttribute("data-prodantix-form"))return null;let t={},r={};for(let s of Array.from(n.elements)){if(!(s instanceof HTMLInputElement||s instanceof HTMLSelectElement||s instanceof HTMLTextAreaElement)||!s.name||s.closest("[data-prodantix-ignore]")||Yt(s)||s instanceof HTMLInputElement&&(zt.has(s.type)||(s.type==="checkbox"||s.type==="radio")&&!s.checked))continue;let a=s.value.trim();if(a==="")continue;t[s.name]=a;let l=Qt(s);l&&(r[l]=a);}return {$answers:t,$form_id:n.id||`${e}#${Array.from(n.ownerDocument.forms).indexOf(n)}`,$page_url:(o=(i=n.ownerDocument.location)==null?void 0:i.href)!=null?o:"",$set:r,collected:true}},ct=(n,e=document)=>{let t=r=>{var i,o;if(r.target instanceof HTMLFormElement){let s=Xt(r.target,(o=(i=e.location)==null?void 0:i.pathname)!=null?o:"");s&&n.capture(Wt,{properties:s});}};return e.addEventListener("submit",t,true),()=>e.removeEventListener("submit",t,true)};var Zt=1e3,en=5e3,tn=50,he=class{constructor(){c(this,"fcp");c(this,"lcp");c(this,"cls");c(this,"window",{end:0,start:0,sum:0});c(this,"interactions",new Map);}add(e){var t,r;if(e.entryType==="paint"&&e.name==="first-contentful-paint"&&(this.fcp=e.startTime),e.entryType==="largest-contentful-paint"&&(this.lcp=e.startTime),e.entryType==="layout-shift"&&!e.hadRecentInput&&e.value!==void 0){let i=this.window.sum>0&&e.startTime-this.window.end<Zt&&e.startTime-this.window.start<en;this.window=i?{end:e.startTime,start:this.window.start,sum:this.window.sum+e.value}:{end:e.startTime,start:e.startTime,sum:e.value},this.cls=Math.max((t=this.cls)!=null?t:0,this.window.sum);}e.entryType==="event"&&e.interactionId!==void 0&&e.interactionId>0&&this.interactions.set(e.interactionId,Math.max((r=this.interactions.get(e.interactionId))!=null?r:0,e.duration));}properties(e){var r;let t={};if(this.lcp!==void 0&&(t.$lcp_ms=Math.round(this.lcp)),this.fcp!==void 0&&(t.$fcp_ms=Math.round(this.fcp)),this.cls!==void 0&&(t.$cls=Math.round(this.cls*1e4)/1e4),this.interactions.size>0){let i=[...this.interactions.values()].sort((o,s)=>s-o);t.$inp_ms=Math.round((r=i[Math.min(i.length-1,Math.floor(i.length/tn))])!=null?r:0);}return e!==void 0&&(t.$ttfb_ms=Math.round(e)),t}},nn=[{type:"paint"},{type:"largest-contentful-paint"},{type:"layout-shift"},{durationThreshold:40,type:"event"}];function lt(n,e){let t=new he,r=[];for(let s of nn){let a=e.observer(l=>{for(let u of l)t.add(u);});if(a!==void 0)try{a.observe({...s,buffered:!0}),r.push(a);}catch(l){a.disconnect();}}let i=false,o=()=>{if(i)return;let s=t.properties(e.firstByte());if(Object.keys(s).length===0)return;i=true;let a=e.path();n.capture(m.webVitals,{properties:a===void 0?s:{...s,$pathname:a}});};return e.addEventListener("visibilitychange",()=>{e.isHidden()&&o();}),e.addEventListener("pagehide",o),()=>{for(let s of r)s.disconnect();}}function ut(){if(!(typeof window=="undefined"||typeof document=="undefined"||typeof PerformanceObserver=="undefined"))return {addEventListener:(n,e)=>(n==="pagehide"?window:document).addEventListener(n,e),firstByte:()=>{let n=performance.getEntriesByType("navigation")[0];return n instanceof PerformanceNavigationTiming&&n.responseStart>0?n.responseStart:void 0},isHidden:()=>document.visibilityState==="hidden",observer:n=>{try{return new PerformanceObserver(e=>n(e.getEntries()))}catch(e){return}},path:()=>{var n;return (n=window.location)==null?void 0:n.pathname}}}var rn=new Set(["input","select","textarea"]),sn=new Set(["email","password","tel"]);function X(){return globalThis.location}function dt(){return globalThis.document}function on(){let n=globalThis.window;return n!=null?n:globalThis}function an(n){return typeof n=="object"&&n!==null&&typeof n.tagName=="string"}function Q(n,e){let t;try{t=new URL(n,e);}catch(r){return}return t.protocol==="http:"||t.protocol==="https:"?`${t.origin}${t.pathname}`:t.protocol}function pt(){let n=X(),e=dt(),t={};if(n){let r=Q(n.href);r&&(t.$current_url=r),t.$pathname=n.pathname,t.$host=n.host;}if(e){e.title&&(t.$title=e.title);let r=e.referrer?Q(e.referrer):void 0;r&&(t.$referrer=r);}return t}function cn(n){return typeof n.className=="string"?n.className:""}function ln(n){var e;return rn.has(n.tagName.toLowerCase())||sn.has(((e=n.getAttribute("type"))!=null?e:"").toLowerCase())}function un(n,e,t){var l,u;let r={$el_tag:n.tagName.toLowerCase(),$event_type:"click"};if(e)return r;let i=t?(l=n.textContent)==null?void 0:l.trim():void 0;i&&(r.$el_text=i.slice(0,255)),n.id&&(r.$el_id=n.id);let o=cn(n);o&&(r.$el_classes=o);let s=n.getAttribute("href"),a=s?Q(s,(u=X())==null?void 0:u.href):void 0;return a&&(r.$el_href=a),r}function ge(n){return (n!=null?n:"").replace(/\s+/g," ").trim()}function P(n,e){return {$el_description:n,$el_description_source:e}}function dn(n,e,t){var s;if(!e&&t){let a=ge(n.getAttribute("aria-label"));if(a!==""&&a.length<=$)return P(a,"aria_label");let l=ge(n.textContent);if(l!==""&&l.length<=$)return P(l,"text")}let r=e?null:n.getAttribute("href"),i=r?Q(r,(s=X())==null?void 0:s.href):void 0;if(i)return P(i,"href");let o=ge(n.getAttribute("role")).toLowerCase();return o===""?P(n.tagName.toLowerCase(),"tag"):P(o,"role")}function pn(n,e){let t=new Set,r=(u,d)=>{if(t.has(u))return false;try{return d()}catch(f){return t.add(u),e(new b("config",`autocapture maskSelectors entry "${u}" is not a valid selector`,{cause:f})),false}},i=(u,d)=>u.matches?r(d,()=>{var f;return ((f=u.matches)==null?void 0:f.call(u,d))===!0}):false,o=u=>{var f;let d=(f=u.querySelector)==null?void 0:f.bind(u);return d?d(`[${fe}], .${me}`)!==null||n.some(v=>r(v,()=>d(v)!==null)):false},s=u=>{for(let d=u;d;d=d.parentElement){let f=d;if(n.some(v=>i(f,v)))return true}return false},a=u=>{for(let d=u;d;d=d.parentElement)if(ln(d))return true;return false},l=u=>it(u)||s(u);return {holdsMasked:o,isMasked:u=>l(u)||a(u),isOptedOut:l}}function fn(n){let e=globalThis.history,t=on(),r="",i=()=>{let a=X(),l=a?`${a.pathname}${a.search}`:"";l!==r&&(r=l,n.capture(m.pageview,{properties:pt()}));};if(i(),!e||!t)return ()=>{};let o=e.pushState.bind(e),s=e.replaceState.bind(e);return e.pushState=(...a)=>{o(...a),i();},e.replaceState=(...a)=>{s(...a),i();},t.addEventListener("popstate",i),()=>{e.pushState=o,e.replaceState=s,t.removeEventListener("popstate",i);}}function mn(n,e){var l,u,d;let t=dt();if(!t)return ()=>{};let r=(l=e.onError)!=null?l:(()=>{}),i=pn((u=e.maskSelectors)!=null?u:[],r),o=st(r),s=(d=e.captureElementText)!=null?d:false,a=f=>{let v=f.target;if(!an(v)||rt(v))return;let k=nt(v),_=i.isMasked(v)||i.holdsMasked(k),I=i.isOptedOut(v)?{}:ot(k,o),O=I.$el_description===void 0?dn(k,_,s):{};n.capture(m.autocapture,{properties:{...pt(),...un(k,_,s),...O,...I}});};return t.addEventListener("click",a,true),()=>t.removeEventListener("click",a,true)}function ft(n,e={}){var i,o;let t=[];((i=e.pageviews)==null||i)&&t.push(fn(n)),((o=e.clicks)==null||o)&&t.push(mn(n,e)),e.collectForms===true&&typeof document!="undefined"&&t.push(ct(n));let r=e.webVitals===false?void 0:ut();return r!==void 0&&t.push(lt(n,r)),()=>{for(let s of t)s();}}function hn(){let n=globalThis.document;return (n==null?void 0:n.visibilityState)==="hidden"}function gn(n){let e=globalThis.navigator,t=globalThis.Blob;if(!(e!=null&&e.sendBeacon)||!t)return false;let r=JSON.stringify({...n.body,api_key:n.projectKey});try{let i=new t([r],{type:"application/json"});return e.sendBeacon(n.url,i)}catch(i){return false}}var Z=class{constructor(e={}){c(this,"fetchTransport");this.fetchTransport=new C(e);}async send(e){hn()&&gn(e)||await this.fetchTransport.send(e);}};var ye="prodantix:consent-ready",ve="prodantix:consent",mt="__prodantixConsent";var ht=(n,e)=>{n.takeCookielessId(e.anonymousId),e.consent!==null?n.setConsent(e.consent):e.rule==="notice"&&n.allowStorage();},gt=(n,e)=>{let t=e[mt];t&&ht(n,t);let r=o=>{let s=o.detail;s&&ht(n,s);},i=o=>{let s=o.detail;s&&n.setConsent(s);};return e.addEventListener(ye,r),e.addEventListener(ve,i),()=>{e.removeEventListener(ye,r),e.removeEventListener(ve,i);}};var yn=/^\d{1,3}(\.\d{1,3}){3}$/,vn=/^[a-z0-9.-]+$/i;function yt(){return Math.random().toString(36).slice(2,12)}function ee(n,e){let t=`${e}=`,r=[];for(let i of n.cookie.split(";")){let o=i.trim();o.startsWith(t)&&r.push(o.slice(t.length));}return r}function M(n,e,t){let r=["Path=/",`Max-Age=${e}`,"SameSite=Lax"];return n&&r.push(`Domain=${n}`),t&&r.push("Secure"),r.join("; ")}function vt(n,e,t,r){try{let i=`pdx_probe_${r()}`,o=r();n.cookie=`${i}=${o}; ${M(e,60,t)}`;let s=ee(n,i).includes(o);n.cookie=`${i}=; ${M(e,0,t)}`;let a=ee(n,i).includes(o);return s&&!a}catch(i){return false}}function bn(n){let e=n.replace(/^\[|\]$/g,"").toLowerCase();if(e.includes(":")||yn.test(e)||!e.includes("."))return [];let t=e.split("."),r=[];for(let i=t.length-2;i>=0;i-=1)r.push(t.slice(i).join("."));return r}function Sn(n,e,t,r=yt){for(let i of bn(n))if(vt(e,i,t,r))return i}function kn(n){let e=new Map,t=JSON.parse(decodeURIComponent(n));if(t===null||typeof t!="object"||Array.isArray(t))return e;for(let[r,i]of Object.entries(t))typeof i=="string"&&e.set(r,i);return e}var be=class{constructor(e,t,r,i){this.jar=e;this.name=t;this.domain=r;this.secure=i;}getItem(e){var t;return (t=this.read().get(e))!=null?t:null}setItem(e,t){let r=this.read();r.set(e,t),this.write(r);}removeItem(e){let t=this.read();t.delete(e)&&this.write(t);}read(){try{let e=ee(this.jar,this.name);e.length>1&&this.domain&&(this.jar.cookie=`${this.name}=; ${M(void 0,0,this.secure)}`,e=ee(this.jar,this.name));let t=e[0];return t?kn(t):new Map}catch(e){return new Map}}write(e){try{if(e.size===0){this.jar.cookie=`${this.name}=; ${M(this.domain,0,this.secure)}`;return}let t=encodeURIComponent(JSON.stringify(Object.fromEntries(e)));this.jar.cookie=`${this.name}=${t}; ${M(this.domain,31536e3,this.secure)}`;}catch(t){return}}};function En(){return globalThis.document}function xn(){var n,e;return (e=(n=globalThis.location)==null?void 0:n.hostname)!=null?e:""}function wn(){var n;return ((n=globalThis.location)==null?void 0:n.protocol)==="https:"}function Tn(n){if(n===void 0)return;let e=n.startsWith(".")?n.slice(1):n;return vn.test(e)?e.toLowerCase():void 0}function bt(n){var s,a,l,u,d;let e="jar"in n?n.jar:En();if(!e||((s=globalThis.navigator)==null?void 0:s.cookieEnabled)===false)return null;let r=(a=n.random)!=null?a:yt,i=(l=n.secure)!=null?l:wn(),o=(u=n.hostname)!=null?u:xn();try{let f=(d=Tn(n.domain))!=null?d:Sn(o,e,i,r);return vt(e,f,i,r)?new be(e,n.name,f,i):null}catch(f){return null}}var St=(n,e,t,r=Date.now)=>{let i=0,o=e.visibilityState==="visible"?r():void 0,s=()=>{o!==void 0&&(i+=r()-o,o=void 0,n(Math.round(i/1e3)));},a=()=>{e.visibilityState==="visible"?o!=null||(o=r()):s();};return e.addEventListener("visibilitychange",a),t.addEventListener("pagehide",s),()=>{e.removeEventListener("visibilitychange",a),t.removeEventListener("pagehide",s);}};var kt=(n,e)=>({...n.page?{$page_id:n.page}:{},...n.page&&e?{$page_view_id:e}:{},...n.variant?{$page_variant:n.variant}:{}});var Cn=(n,e)=>{var t;try{return (t=bt({name:`pdx_${ne(n)}`}))!=null?t:e}catch(r){return e}},S=document.currentScript,Se=S==null?void 0:S.dataset.key,Et,xt;if(S&&Se){let n=new URL(S.src,window.location.href).origin,e=we(),t=S.dataset.consent==="banner",r=new Y({apiKey:Se,...t?{consentMode:"banner"}:{},defaultProperties:kt(S.dataset,te()),flagsHost:(Et=S.dataset.edge)!=null?Et:n,host:(xt=S.dataset.host)!=null?xt:n,sharedStorage:Cn(Se,e),storage:e,transport:new Z({})});t&>(r,window),ft(r,{clicks:true,collectForms:false,pageviews:true}),St(i=>{r.capture(m.pageleave,{properties:{$engaged_seconds:i}}),r.flush();},document,window);}})();//# sourceMappingURL=pages.iife.js.map
|
|
2
2
|
//# sourceMappingURL=pages.iife.js.map
|