cap-hydra-web-sdk 1.0.2 → 1.0.3

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.
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).WebSDK=e()}(this,function(){"use strict";const t="/auth/nonce",e="/mapp/events",s=6e4,i={CATEGORIES:{USER:"USER",BEHAVIORAL:"BE"},STATUSES:{PENDING:"pending"},BATCH_SIZE:50,MAX_RETRY_ATTEMPTS:5,DEFAULT_RETRY_DELAYS:[6e4,12e4,24e4,48e4,9e5],RETRYABLE_HTTP_CODES:[408,429,500,502,503,504,401],GLOBAL_SUCCESS_CODE:200,PARTIAL_SUCCESS_CODE:201},n={NONCE_DATA:"websdk_nonce_data",USER_CONTEXT:"websdk_user_context",DEVICE_ID:"websdk_device_id",SESSION_ID:"websdk_session_id"},a=n;function r(t,e,s){const i=n[t],a=[];return e&&a.push(e),s&&a.push(s),a.length>0?`${a.join("_")}_${i}`:i}const o="websdk_storage_test",h="test_value",c="INIT_ERROR",d="AUTH_ERROR",u="NETWORK_ERROR",l="EVENT_ERROR",w="WebSDK initialized successfully",y="Failed to initialize WebSDK",f="WebSDK destroyed successfully",g="Authentication successful",m="Authentication failed",v="AuthManager initialized successfully",E="Nonce request successful",p="Nonce request failed",S="Request signature generated successfully",I="Failed to store nonce data",x="Failed to restore nonce data from storage",_="Failed to clear stored nonce data",D="EventTracker initialized successfully",b="EventTracker destroyed successfully",N="Failed to track event",k="Events sent successfully",U="Failed to send events",T="Failed to initialize storage:",A="Storage test failed:",C="Storage read/write test failed",R="StorageManager destroyed successfully",O="Error during storage cleanup:",z="Failed to track user signin event",M="Failed to track user signup event",$="Failed to track user update event",F="Failed to track user signout event",P="Failed to track behavioral event",B="web",q="",W="",L="",K="user_signin",Q="user_signup",H="user_update",X="user_signout",V="1.0.2";class J{constructor(t){this.baseUrl=t.baseUrl.replace(/\/$/,"")}async request(t,e={}){const{method:s="GET",headers:i={},body:n}=e,a=!t||t.startsWith("/")?t:`/${t}`,r=`${this.baseUrl}${a}`;try{const t={method:s,headers:{"Content-Type":"application/json",...i},body:n?JSON.stringify(n):null},e=await fetch(r,t);if(!e.ok){const t=await e.text();throw new Error(`HTTP ${e.status}: ${e.statusText} - ${t}`)}return await e.json()}catch(t){throw this.handleError(t)}}handleError(t){return t instanceof Error?"AbortError"===t.name?{code:u,message:"Request timeout",details:t}:t.message.includes("HTTP 401")||t.message.includes("HTTP 403")?{code:d,message:"Authentication failed",details:t}:(t.message.includes("HTTP"),{code:u,message:t.message,details:t}):{code:u,message:`Unknown error: ${String(t)}`,details:t}}async get(t,e={}){return this.request(t,{...e,method:"GET"})}async post(t,e,s={}){return this.request(t,{...s,method:"POST",body:e})}async put(t,e,s={}){return this.request(t,{...s,method:"PUT",body:e})}async delete(t,e={}){return this.request(t,{...e,method:"DELETE"})}}function G(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function j(){return`session_${G()}`}async function Y(t,e,s,i){try{const n=i||Z(),a=function(t){const e=Object.keys(t).sort();return e.map(e=>`${e}=${t[e]}`).join("&")}({nonce:e,account_id:s,device_id:n,timestamp:Date.now(),payload:JSON.stringify(t,Object.keys(t).sort())}),r=await async function(t,e){const s=`${t}:${e}:cap-hydra-web-sdk`,i=(new TextEncoder).encode(s),n=await crypto.subtle.digest("SHA-256",i);return await crypto.subtle.importKey("raw",n,{name:"HMAC",hash:"SHA-256"},!1,["sign"])}(s,n);return await async function(t,e){const s=(new TextEncoder).encode(t),i=await crypto.subtle.sign("HMAC",e,s);return btoa(String.fromCharCode(...new Uint8Array(i)))}(a,r)}catch(t){throw new Error(`Signature generation failed: ${t instanceof Error?t.message:"Unknown error"}`)}}function Z(){const t=a.DEVICE_ID,e=localStorage.getItem(t);if(e)return e;const s=G();return localStorage.setItem(t,s),s}function tt(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return"UTC"}}function et(){return window.location.hostname||"localhost"}function st(t){const e=function(){const t=navigator.userAgent;let e="Unknown",s="Unknown";if(t.includes("Chrome")){e="Chrome";const i=t.match(/Chrome\/([0-9.]+)/);s=i?.[1]??"Unknown"}else if(t.includes("Firefox")){e="Firefox";const i=t.match(/Firefox\/([0-9.]+)/);s=i?.[1]??"Unknown"}else if(t.includes("Safari")&&!t.includes("Chrome")){e="Safari";const i=t.match(/Version\/([0-9.]+)/);s=i?.[1]??"Unknown"}else if(t.includes("Edge")){e="Edge";const i=t.match(/Edge\/([0-9.]+)/);s=i?.[1]??"Unknown"}let i="Unknown",n="Unknown";if(t.includes("Windows"))i="Windows",t.includes("Windows NT 10.0")?n="10":t.includes("Windows NT 6.3")?n="8.1":t.includes("Windows NT 6.2")?n="8":t.includes("Windows NT 6.1")&&(n="7");else if(t.includes("Mac OS X")){i="macOS";const e=t.match(/Mac OS X ([0-9_]+)/);n=e?.[1]?.replace(/_/g,".")??"Unknown"}else if(t.includes("Linux"))i="Linux",n="Unknown";else if(t.includes("Android")){i="Android";const e=t.match(/Android ([0-9.]+)/);n=e?.[1]??"Unknown"}else if(t.includes("iPhone")||t.includes("iPad")){i="iOS";const e=t.match(/OS ([0-9_]+)/);n=e?.[1]?.replace(/_/g,".")??"Unknown"}return{browserName:e,browserVersion:s,osName:i,osVersion:n}}(),s={width:window.innerWidth||document.documentElement.clientWidth||0,height:window.innerHeight||document.documentElement.clientHeight||0},i=Z();return{os_version:e.osVersion,country_code:t.country_code,os_name:e.osName,viewport_width:s.width,country:t.country,viewport_height:s.height,device_id:i,bundle_identifier:et(),last_seen:(new Date).toISOString(),city:t.city,sdk_version:V,platform:"web",browser_name:e.browserName,browser_version:e.browserVersion,browser_language:navigator.language||navigator.languages&&navigator.languages[0]||"en-US",timezone:tt()}}class it{constructor(t,e,s){this.httpClient=new J(t),this.logger=e,this.accountId=s}async getNonce(e,s){const i=s||Z();this.logger.info("Requesting nonce",{accountId:this.accountId,bundleIdentifier:e,deviceId:i});const n={account_id:this.accountId,bundle_identifier:e,device_id:i,timestamp:Date.now(),os_name:B};try{const e=await this.httpClient.post(t,n);return this.logger.info(E,{challengeId:e.challenge_id,expiresAt:e.expires_at}),e}catch(t){throw this.logger.error(p,t),t}}async sendEvents(t,s,i,n,a,r){this.logger.info("Sending events",{eventCount:t.length,cuid:s,challengeId:a});const o=r||Z(),h={system_data:st(i),request_id:G(),events:t,cuid:s};try{const s=await Y({...h,nonce:n,challenge_id:a},n,this.accountId,o);this.logger.info(S,{requestId:h.request_id,challengeId:a});const i={"X-Cap-Nonce":n,"X-Cap-Challenge-ID":a,"X-Cap-Signature":s,"X-Cap-Device-ID":o},r=await this.httpClient.post(e,h,{headers:i});return this.logger.info(k,{requestId:h.request_id,eventCount:t.length,success:r.status.success}),r}catch(e){throw this.logger.error(U,{requestId:h.request_id,eventCount:t.length,error:e}),e}}}class nt{constructor(t="WebSDK",e=2,s="data"){this.db=null,this.dbName=t,this.version=e,this.storeName=s,this.eventsStoreName="events"}async openDB(){return this.db?this.db:new Promise((t,e)=>{const s=indexedDB.open(this.dbName,this.version);s.onerror=()=>e(s.error),s.onsuccess=()=>{this.db=s.result,t(this.db)},s.onupgradeneeded=t=>{const e=t.target.result;if(e.objectStoreNames.contains(this.storeName)||e.createObjectStore(this.storeName),!e.objectStoreNames.contains(this.eventsStoreName)){const t=e.createObjectStore(this.eventsStoreName,{keyPath:"id"});t.createIndex("timestamp","timestamp",{unique:!1}),t.createIndex("status","status",{unique:!1})}}})}async getItem(t){const e=await this.openDB();return new Promise((s,i)=>{const n=e.transaction([this.storeName],"readonly").objectStore(this.storeName).get(t);n.onerror=()=>i(n.error),n.onsuccess=()=>{const t=n.result;s(null==t?null:"string"==typeof t?t:"object"==typeof t?JSON.stringify(t):String(t))}})}async setItem(t,e){const s=await this.openDB();return new Promise((i,n)=>{const a=s.transaction([this.storeName],"readwrite").objectStore(this.storeName).put(e,t);a.onerror=()=>n(a.error),a.onsuccess=()=>i()})}async removeItem(t){const e=await this.openDB();return new Promise((s,i)=>{const n=e.transaction([this.storeName],"readwrite").objectStore(this.storeName).delete(t);n.onerror=()=>i(n.error),n.onsuccess=()=>s()})}async clear(){const t=await this.openDB();return new Promise((e,s)=>{const i=t.transaction([this.storeName],"readwrite").objectStore(this.storeName).clear();i.onerror=()=>s(i.error),i.onsuccess=()=>e()})}async close(){this.db&&(this.db.close(),this.db=null)}async addEvent(t){const e=await this.openDB();return new Promise((s,i)=>{const n=e.transaction([this.eventsStoreName],"readwrite").objectStore(this.eventsStoreName).add(t);n.onerror=()=>i(n.error),n.onsuccess=()=>s()})}async getOldestPendingEvents(t=50,e){const s=await this.openDB();return new Promise((i,n)=>{const a=s.transaction([this.eventsStoreName],"readonly").objectStore(this.eventsStoreName).index("timestamp").openCursor(),r=[];let o=0;a.onerror=()=>n(a.error),a.onsuccess=s=>{const n=s.target.result;if(n&&o<t){const t=n.value;"pending"===t.status&&t.accountId===e&&(r.push(t),o++),n.continue()}else i(r)}})}async updateEventStatus(t,e,s,i){const n=await this.openDB();return new Promise((a,r)=>{const o=n.transaction([this.eventsStoreName],"readwrite").objectStore(this.eventsStoreName),h=o.get(t);h.onerror=()=>r(h.error),h.onsuccess=()=>{const n=h.result;if(n){n.status=e,n.lastAttempt=Date.now(),s&&(n.error=s),void 0!==i&&(n.attempts=i);const t=o.put(n);t.onerror=()=>r(t.error),t.onsuccess=()=>a()}else r(new Error(`Event with id ${t} not found`))}})}async removeEvents(t){const e=await this.openDB();return new Promise((s,i)=>{const n=e.transaction([this.eventsStoreName],"readwrite").objectStore(this.eventsStoreName);let a=0;const r=t.length;0!==r?t.forEach(t=>{const e=n.delete(t);e.onerror=()=>i(e.error),e.onsuccess=()=>{a++,a===r&&s()}}):s()})}async recoverOrphanedEvents(t){const e=await this.openDB();return new Promise((s,i)=>{const n=e.transaction([this.eventsStoreName],"readwrite").objectStore(this.eventsStoreName).openCursor();let a=0;n.onerror=()=>i(n.error),n.onsuccess=e=>{const i=e.target.result;if(i){const e=i.value;if("processing"===e.status&&e.accountId===t){e.status="failed",e.lastAttempt=Date.now(),e.error="Recovered from orphaned processing state";i.update(e).onsuccess=()=>{a++}}i.continue()}else s(a)}})}async getPendingEventCount(t){const e=await this.openDB();return new Promise((s,i)=>{const n=e.transaction([this.eventsStoreName],"readonly").objectStore(this.eventsStoreName).openCursor();let a=0;n.onerror=()=>i(n.error),n.onsuccess=e=>{const i=e.target.result;if(i){const e=i.value;"pending"===e.status&&e.accountId===t&&a++,i.continue()}else s(a)}})}async getRetryableEvents(t=5,e){const s=await this.openDB();return new Promise((i,n)=>{const a=s.transaction([this.eventsStoreName],"readonly").objectStore(this.eventsStoreName).openCursor(),r=[];a.onerror=()=>n(a.error),a.onsuccess=s=>{const n=s.target.result;if(n){const s=n.value;"failed"===s.status&&s.attempts<=t&&s.accountId===e&&r.push(s),n.continue()}else i(r)}})}}class at{constructor(t,e,s,n){if(this.systemDataArgs=null,this.currentAccountId=null,this.currentCuid=null,this.isProcessing=!1,this.processingPromise=null,this.BATCH_SIZE=i.BATCH_SIZE,this.authManager=t,this.logger=e,this.RETRY_DELAYS=n||i.DEFAULT_RETRY_DELAYS,s&&"getIndexedDBAdapter"in s){const t=s.getIndexedDBAdapter();t?(e.info("EventQueue: Reusing existing IndexedDB adapter from StorageManager"),this.storage=t):(e.warn("EventQueue: StorageManager has no IndexedDB adapter, creating new one"),this.storage=new nt)}else s?(e.info("EventQueue: Using provided IndexedDBStorage"),this.storage=s):(e.warn("EventQueue: No storage provided, creating new IndexedDBStorage"),this.storage=new nt)}async init(){this.logger.info("Initializing EventQueue"),await this.processQueueIfIdle(),this.logger.info("EventQueue initialized successfully")}async setUserContext(t,e,s){this.currentAccountId=t,this.currentCuid=s||null,this.systemDataArgs=e,this.logger.debug("EventQueue user context set",{accountId:t,cuid:s,systemDataArgs:e});const i=await this.storage.recoverOrphanedEvents(t);i>0&&this.logger.info(`Recovered ${i} orphaned processing events for account ${t}`)}getCurrentAccountId(){return this.currentAccountId}getCurrentCuid(){return this.currentCuid}async enqueue(t){try{if(!this.currentAccountId)throw new Error("Cannot enqueue event: No account context set");const e={id:G(),event:t,accountId:this.currentAccountId,timestamp:(new Date).toISOString(),attempts:0,status:i.STATUSES.PENDING};await this.storage.addEvent(e),this.logger.debug("Event added to queue",{eventId:e.id,eventType:t.category,eventName:t.name}),await this.processQueueIfIdle()}catch(e){throw this.logger.error("Failed to enqueue event",{event:t,error:e}),e}}async processQueueIfIdle(){if(!this.isProcessing)return this.processingPromise||(this.processingPromise=this.processQueue()),this.processingPromise;this.logger.debug("Queue processing already in progress, skipping")}async processQueue(){if(!this.isProcessing){this.isProcessing=!0,this.logger.debug("Starting queue processing");try{for(;;){if(await this.checkAndPromoteRetryEvents(),!this.currentAccountId){this.logger.debug("No account context, skipping event processing");break}const t=await this.storage.getOldestPendingEvents(this.BATCH_SIZE,this.currentAccountId);if(0===t.length){this.logger.debug("No pending events to process");break}this.logger.info("Processing batch of events",{batchSize:t.length,eventIds:t.map(t=>t.id)}),await this.markEventsAsProcessing(t),await this.sendBatch(t);if(0===await this.storage.getPendingEventCount(this.currentAccountId)){this.logger.debug("No more pending events");break}}}catch(t){this.logger.error("Queue processing failed",t)}finally{this.isProcessing=!1,this.processingPromise=null,this.logger.debug("Queue processing completed")}}}async markEventsAsProcessing(t){for(const e of t)try{await this.storage.updateEventStatus(e.id,"processing")}catch(t){this.logger.warn("Failed to mark event as processing",{eventId:e.id,error:t})}}async sendBatch(t){try{if(!this.currentAccountId)throw new Error("Missing account context for batch sending");const e=await this.authManager.getNonceData(),s=this.authManager.getApiClient(),i=t.map(t=>t.event),n=await s.sendEvents(i,this.currentCuid||"",this.systemDataArgs||{country:q,city:W,country_code:L},e.nonce,e.challengeId,e.deviceId);return await this.handleBatchResponse(t,n),!0}catch(e){const s=this.isRetryableHttpError(e);return this.logger.error("Failed to send batch",{batchSize:t.length,error:e,isRetryable:s}),s?await this.handleFailedBatch(t):await this.removeNonRetryableEvents(t),!1}}async removeSuccessfulEvents(t){const e=t.map(t=>t.id);try{await this.storage.removeEvents(e),this.logger.debug("Successfully removed events from storage",{count:e.length})}catch(t){this.logger.error("Failed to remove events from storage",{eventIds:e,error:t})}}async handleBatchResponse(t,e){const s=e.status.code;if(s===i.GLOBAL_SUCCESS_CODE)await this.removeSuccessfulEvents(t),this.logger.info("All events processed successfully",{count:t.length});else if(s===i.PARTIAL_SUCCESS_CODE)await this.handlePartialSuccess(t,e.events);else{i.RETRYABLE_HTTP_CODES.includes(parseInt(s))?(await this.handleFailedBatch(t),this.logger.warn("Batch failed with retryable error",{code:s,message:e.status.message})):(await this.removeNonRetryableEvents(t),this.logger.error("Batch failed with non-retryable error",{code:s,message:e.status.message}))}}async handlePartialSuccess(t,e){const s=new Map;e.forEach(t=>{s.set(t.event_id,t)});for(const e of t){const t=s.get(e.event.event_id);if(t)if(t.status.success)await this.storage.removeEvents([e.id]),this.logger.debug("Event processed successfully",{eventId:e.id});else{const s=parseInt(t.status.code);i.RETRYABLE_HTTP_CODES.includes(s)?(await this.markEventForRetry(e,t.status.message),this.logger.debug("Event marked for retry",{eventId:e.id,code:s,message:t.status.message})):(await this.storage.removeEvents([e.id]),this.logger.warn("Event permanently failed - removed",{eventId:e.id,code:s,message:t.status.message}))}else await this.markEventForRetry(e,"No response received")}}async markEventForRetry(t,e){const s=(t.attempts||0)+1;await this.storage.updateEventStatus(t.id,"failed",`Attempt ${s} failed: ${e}`,s);const i=Math.min(Math.max(s-1,0),this.RETRY_DELAYS.length-1),n=this.RETRY_DELAYS[i];this.logger.debug("Event marked for retry",{eventId:t.id,attempts:s,delay:n,isInfiniteRetry:s>this.RETRY_DELAYS.length})}async checkAndPromoteRetryEvents(){try{if(!this.currentAccountId)return void this.logger.debug("No account context, skipping retry check");const t=await this.storage.getRetryableEvents(Number.MAX_SAFE_INTEGER,this.currentAccountId);if(0===t.length)return;let e=0;for(const s of t){const t=Math.min(Math.max(s.attempts-1,0),this.RETRY_DELAYS.length-1),i=this.RETRY_DELAYS[t],n=Date.now()-(s.lastAttempt||0);n>=(i||0)&&(await this.storage.updateEventStatus(s.id,"pending"),e++,this.logger.debug("Failed event promoted to pending",{eventId:s.id,attempt:s.attempts+1,delay:i,timeSinceLastAttempt:n}))}e>0&&this.logger.debug(`Promoted ${e} failed events for retry`)}catch(t){this.logger.error("Failed to check retry events",t)}}isRetryableHttpError(t){if(t.code){const e=parseInt(t.code);return i.RETRYABLE_HTTP_CODES.includes(e)}return t.message?.includes("network")||t.message?.includes("timeout")||t.message?.includes("fetch")}async removeNonRetryableEvents(t){const e=t.map(t=>t.id);try{await this.storage.removeEvents(e),this.logger.warn("Non-retryable events removed permanently",{eventIds:e})}catch(t){this.logger.error("Failed to remove non-retryable events",{eventIds:e,error:t})}}async handleFailedBatch(t){for(const e of t)try{await this.markEventForRetry(e,"Batch failed")}catch(t){this.logger.error("Failed to mark event for retry",{eventId:e.id,error:t})}}async flush(){this.logger.info("Manual flush requested"),await this.processQueueIfIdle()}async destroy(){this.logger.info("Destroying EventQueue"),this.processingPromise&&await this.processingPromise,await this.storage.close(),this.logger.info("EventQueue destroyed")}async clear(){this.logger.warn("Clear method not implemented for IndexedDB queue")}}class rt{constructor(t,e,s,i){this.eventQueue=null,this.initialized=!1,this.config=t,this.logger=i,this.authManager=e,this.storageManager=s}async init(){this.initialized?this.logger.warn("EventTracker already initialized"):(this.logger.info("Initializing EventTracker with IndexedDB queue"),this.eventQueue=new at(this.authManager,this.logger,this.storageManager,this.config.retryDelays),await this.eventQueue.init(),this.initialized=!0,this.logger.info(D))}async setUserContext(t,e,s){if(!this.eventQueue)throw new Error("EventTracker not initialized");await this.eventQueue.setUserContext(t,e,s),this.logger.info("User context set",{accountId:t,systemDataArgs:e,cuid:s})}async track(t){if(!this.initialized||!this.eventQueue)throw new Error("EventTracker not initialized");this.logger.debug("Tracking event",{event:t});try{const e=this.convertToApiEvent(t);await this.eventQueue.enqueue(e)}catch(e){throw this.logger.error(N,{event:t,error:e}),new Error(`${l}: ${e}`)}}convertToApiEvent(t){const e="user"===t.type?i.CATEGORIES.USER:i.CATEGORIES.BEHAVIORAL,s={...t.data,device_id:Z()};if(!this.eventQueue)throw new Error("EventTracker not initialized");const n=this.eventQueue.getCurrentCuid();if(!n)throw new Error("User context not set. Call setUserContext() first.");return function(t,e,s,i){return{category:t,attributes:{...s,device_id:Z(),cuid:i},name:e,created_at:(new Date).toISOString(),event_id:G()}}(e,t.name||"custom",s,n)}async flush(){this.initialized&&this.eventQueue?(this.logger.info("Manual flush requested"),await this.eventQueue.flush()):this.logger.warn("Cannot flush events - EventTracker not initialized")}async destroy(){this.logger.info("Destroying EventTracker"),this.eventQueue&&await this.eventQueue.destroy(),this.initialized=!1,this.logger.info(b)}}class ot{constructor(t,e,s){this.initialized=!1,this.nonceData=null,this.config=t,this.logger=e,this.storageManager=s,this.apiClient=new it({baseUrl:t.baseURL},e,t.accountId)}async init(){this.initialized?this.logger.warn("AuthManager already initialized"):(this.logger.info("Initializing AuthManager",{accountId:this.config.accountId}),this.initialized=!0,this.logger.info(v))}async requestNonce(){if(!this.initialized)throw new Error("AuthManager not initialized");this.logger.info("Requesting nonce for authentication");try{const t=et(),e=Z(),s=await this.apiClient.getNonce(t,e);return this.nonceData={nonce:s.nonce,challengeId:s.challenge_id,expiresAt:s.expires_at,deviceId:e},await this.storeNonceData(),this.logger.info(g,{challengeId:s.challenge_id,expiresAt:s.expires_at}),this.nonceData}catch(t){throw this.logger.error(m,t),t}}async ensureValidNonce(){if(!this.initialized)throw new Error("AuthManager not initialized");this.logger.info("Ensuring valid nonce");try{return await this.restoreNonceData(),this.nonceData&&!this.isNonceExpired(this.nonceData.expiresAt)?(this.logger.info("Using existing valid nonce"),this.nonceData):(this.logger.info("No valid nonce found, requesting fresh"),await this.requestNonce())}catch(t){throw this.logger.error("Failed to ensure valid nonce",t),t}}async getNonceData(){return await this.ensureValidNonce()}isNonceExpired(t){return Date.now()>=t-s}hasValidNonce(){return!!this.nonceData&&!this.isNonceExpired(this.nonceData.expiresAt)}getApiClient(){return this.apiClient}async storeNonceData(){if(this.nonceData)try{await this.storageManager.set(a.NONCE_DATA,JSON.stringify(this.nonceData))}catch(t){this.logger.warn(I,t)}}async restoreNonceData(){try{const t=await this.storageManager.get(a.NONCE_DATA);t&&(this.nonceData=JSON.parse(t),this.logger.info("Nonce data restored from storage"))}catch(t){this.logger.warn(x,t),this.nonceData=null}}async clearNonceData(){this.nonceData=null;try{await this.storageManager.remove(a.NONCE_DATA)}catch(t){this.logger.warn(_,t)}}async destroy(){this.logger.info("Destroying AuthManager"),await this.clearNonceData(),this.initialized=!1,this.logger.info("AuthManager destroyed successfully")}}class ht{constructor(t,e,s){this.initialized=!1,this.logger=t,this.brandId=e,this.applicationId=s,this.adapter=new ct}async init(){if(this.initialized)this.logger.warn("StorageManager already initialized");else{this.logger.info("Initializing StorageManager");try{if(this.isIndexedDBSupported()){const t=["WebSDK"];this.brandId&&t.push(this.brandId),this.applicationId&&t.push(this.applicationId);const e=t.join("_"),s=new nt(e);await this.testStorageAdapter(s),this.adapter=s,this.logger.info("StorageManager initialized with IndexedDB",{dbName:e,brandId:this.brandId,applicationId:this.applicationId})}else await this.testStorageAdapter(this.adapter),this.logger.info("StorageManager initialized with localStorage");this.initialized=!0}catch(t){throw this.logger.error(T,t),new Error(`Storage initialization failed: ${t}`)}}}isIndexedDBSupported(){return"undefined"!=typeof window&&"indexedDB"in window&&null!==indexedDB}async testStorageAdapter(t){const e=o,s=h;try{await t.setItem(e,s);if(await t.getItem(e)!==s)throw new Error(C);await t.removeItem(e)}catch(t){throw new Error(`${A} ${t}`)}}async get(t){if(!this.initialized)throw new Error("StorageManager not initialized");return this.adapter.getItem(t)}async set(t,e){if(!this.initialized)throw new Error("StorageManager not initialized");return this.adapter.setItem(t,e)}async remove(t){if(!this.initialized)throw new Error("StorageManager not initialized");return this.adapter.removeItem(t)}async clear(){if(!this.initialized)throw new Error("StorageManager not initialized");return this.adapter.clear()}getIndexedDBAdapter(){return this.adapter instanceof nt?this.adapter:null}async destroy(){this.logger.info("Destroying StorageManager");try{this.adapter instanceof nt&&await this.adapter.close(),this.initialized=!1,this.logger.info(R)}catch(t){this.logger.error(O,t),this.initialized=!1}}}class ct{async getItem(t){try{return localStorage.getItem(t)}catch(t){throw new Error(`LocalStorage getItem failed: ${t}`)}}async setItem(t,e){try{localStorage.setItem(t,e)}catch(t){if(t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name))throw new Error("LocalStorage quota exceeded");throw new Error(`LocalStorage setItem failed: ${t}`)}}async removeItem(t){try{localStorage.removeItem(t)}catch(t){throw new Error(`LocalStorage removeItem failed: ${t}`)}}async clear(){try{localStorage.clear()}catch(t){throw new Error(`LocalStorage clear failed: ${t}`)}}}var dt;!function(t){t[t.VERBOSE=0]="VERBOSE",t[t.DEBUG=1]="DEBUG",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.NONE=5]="NONE"}(dt||(dt={}));class ut{constructor(t=!1,e=dt.INFO){this.logs=[],this.maxLogs=1e3,this.enabled=t,this.level=e}formatMessage(t,e){return`[${(new Date).toISOString()}] [WebSDK:${dt[t]}] ${e}`}log(t,e,s){if(!this.enabled||t<this.level)return;const i={level:t,message:e,timestamp:Date.now(),data:s};this.logs.push(i),this.logs.length>this.maxLogs&&this.logs.shift();const n=this.formatMessage(t,e),a=s?[n,s]:[n];switch(t){case dt.VERBOSE:case dt.DEBUG:break;case dt.INFO:console.info(...a);break;case dt.WARN:console.warn(...a);break;case dt.ERROR:console.error(...a)}}verbose(t,e){this.log(dt.VERBOSE,t,e)}debug(t,e){this.log(dt.DEBUG,t,e)}info(t,e){this.log(dt.INFO,t,e)}warn(t,e){this.log(dt.WARN,t,e)}error(t,e){this.log(dt.ERROR,t,e)}setLevel(t){this.level=t}setEnabled(t){this.enabled=t}getLogs(){return[...this.logs]}clearLogs(){this.logs=[]}}class lt{constructor(t){this.userContextSet=!1,this.initialized=!1,this.initializationPromise=null,this.config=t,this.logger=new ut(this.shouldEnableLogging(t.debugLevel)),this.sessionId="",this.storageManager=new ht(this.logger,t.brandId,t.applicationId),this.authManager=new ot(t,this.logger,this.storageManager),this.eventTracker=new rt(t,this.authManager,this.storageManager,this.logger)}static instanceWithConfig(t){return new lt(t)}shouldEnableLogging(t){return!(!t||"NONE"===t)&&["ERROR","WARN","INFO","DEBUG","VERBOSE"].includes(t)}async getOrCreateSessionId(){try{const t=r("SESSION_ID",this.config.brandId,this.config.applicationId),e=await this.storageManager.get(t);if(e)return e;const s=j();return await this.storageManager.set(t,s),s}catch(t){return this.logger.warn("Failed to get or create session ID",t),j()}}async restoreUserContext(){try{const t=r("USER_CONTEXT",this.config.brandId,this.config.applicationId),e=await this.storageManager.get(t);if(e){const t=JSON.parse(e),s=t.cuid;await this.eventTracker.setUserContext(this.config.accountId,t.systemDataArgs,s),this.userContextSet=!0,this.logger.info("User context restored from storage",{cuid:s,accountId:this.config.accountId})}}catch(t){this.logger.warn("Failed to restore user context from storage",t)}}async validateAndClearDifferentUserContext(t){try{const e=r("USER_CONTEXT",this.config.brandId,this.config.applicationId),s=await this.storageManager.get(e);if(s){const e=JSON.parse(s);e.cuid&&e.cuid!==t&&(this.logger.info("Different user detected, clearing previous user context",{previousCuid:e.cuid,newCuid:t}),await this.clearUserContext(),this.userContextSet=!1)}}catch(t){this.logger.warn("Error validating different user context",t),await this.clearUserContext(),this.userContextSet=!1}}async storeUserContext(t,e){try{const s={cuid:t,systemDataArgs:e,timestamp:Date.now()},i=r("USER_CONTEXT",this.config.brandId,this.config.applicationId);await this.storageManager.set(i,JSON.stringify(s))}catch(t){this.logger.warn("Failed to store user context",t)}}init(){this.initialized?this.logger.warn("WebSDK already initialized"):this.initializationPromise?this.logger.warn("WebSDK initialization already in progress"):this.initializationPromise=this.initializeAsync().catch(t=>{this.logger.error(y,t),this.initializationPromise=null})}async initializeAsync(){try{this.logger.info("Initializing WebSDK",{version:V,config:this.config}),await this.storageManager.init(),this.sessionId=await this.getOrCreateSessionId(),await this.authManager.init(),await this.eventTracker.init(),await this.authManager.ensureValidNonce(),await this.restoreUserContext(),this.initialized=!0,this.logger.info(w)}catch(t){throw new Error(`${c}: ${t}`)}}async setUserContext(t,e){if(!this.initialized)throw new Error("WebSDK must be initialized before setting user context");await this.validateAndClearDifferentUserContext(t),await this.eventTracker.setUserContext(this.config.accountId,e,t),this.userContextSet=!0,await this.storeUserContext(t,e),this.logger.info("User context set and persisted",{cuid:t,accountId:this.config.accountId})}async clearUserContext(){try{const t=r("USER_CONTEXT",this.config.brandId,this.config.applicationId);await this.storageManager.remove(t),this.userContextSet=!1,this.logger.info("User context cleared")}catch(t){this.logger.warn("Failed to clear user context",t),this.userContextSet=!1}}async track(t){if(!this.initialized)throw new Error("WebSDK must be initialized before tracking events");try{await this.eventTracker.track(t)}catch(e){throw this.logger.error(N,{event:t,error:e}),e}}async destroy(){this.logger.info("Destroying WebSDK instance");try{await this.eventTracker.flush(),await this.eventTracker.destroy(),await this.authManager.destroy(),await this.clearUserContext(),await this.storageManager.destroy(),this.initialized=!1,this.logger.info(f)}catch(t){throw this.logger.error(f,t),t}}pushUserSignin(t,e,s,i,n,a){this.pushUserSigninAsync(t,e,s,i,n,a).catch(e=>{this.logger.error(z,{cuid:t,error:e})})}async pushUserSigninAsync(t,e,s,i,n,a){await this.ensureInitialized(),await this.setUserContextIfNeeded(t);const r={cuid:t,...e&&{first_name:e},...s&&{last_name:s},...i&&{email:i},...n&&{phone:n},...a&&{custom_data:a}},o={type:"user",name:K,timestamp:Date.now(),sessionId:this.sessionId,userId:t,data:r};try{await this.track(o),this.logger.info("User signin event tracked",{cuid:t,firstName:e,lastName:s,email:i})}catch(e){throw this.logger.error(z,{cuid:t,error:e}),e}}pushUserSignup(t,e,s,i,n,a){this.pushUserSignupAsync(t,e,s,i,n,a).catch(e=>{this.logger.error(M,{cuid:t,error:e})})}async pushUserSignupAsync(t,e,s,i,n,a){await this.ensureInitialized(),await this.setUserContextIfNeeded(t);const r={cuid:t,first_name:e,last_name:s,email:i,phone:n,...a&&{custom_data:a}},o={type:"user",name:Q,timestamp:Date.now(),sessionId:this.sessionId,userId:t,data:r};try{await this.track(o),this.logger.info("User signup event tracked",{cuid:t,firstName:e,lastName:s,email:i})}catch(e){throw this.logger.error(M,{cuid:t,error:e}),e}}pushUserUpdate(t,e,s,i,n,a){this.pushUserUpdateAsync(t,e,s,i,n,a).catch(e=>{this.logger.error($,{cuid:t,error:e})})}async pushUserUpdateAsync(t,e,s,i,n,a){await this.ensureInitialized(),await this.setUserContextIfNeeded(t);const r={cuid:t,...e&&{first_name:e},...s&&{last_name:s},...i&&{email:i},...n&&{phone:n},...a&&{custom_data:a}},o={type:"user",name:H,timestamp:Date.now(),sessionId:this.sessionId,userId:t,data:r};try{await this.track(o),this.logger.info("User update event tracked",{cuid:t,firstName:e,lastName:s,email:i})}catch(e){throw this.logger.error($,{cuid:t,error:e}),e}}pushUserSignOut(t){this.pushUserSignOutAsync(t).catch(e=>{this.logger.error(F,{cuid:t,error:e}),this.destroy().catch(t=>{this.logger.error("Failed to destroy SDK after failed signout",t)})})}async pushUserSignOutAsync(t){await this.ensureInitialized(),await this.setUserContextIfNeeded(t);const e={type:"user",name:X,timestamp:Date.now(),sessionId:this.sessionId,userId:t,data:{cuid:t}};try{await this.track(e),this.logger.info("User signout event tracked",{cuid:t}),await this.destroy()}catch(e){this.logger.error(F,{cuid:t,error:e});try{await this.destroy()}catch(t){this.logger.error("Failed to destroy SDK after failed signout",t)}throw e}}pushEvent(t,e){this.pushEventAsync(t,e).catch(e=>{this.logger.error(P,{eventName:t,error:e})})}async pushEventAsync(t,e){if(await this.ensureInitialized(),!this.userContextSet)throw new Error("User context must be set before tracking behavioral events. Call setUserContext() first.");const s={event_name:t,...e&&e},i={type:"behavioral",name:t,timestamp:Date.now(),sessionId:this.sessionId,data:s};try{await this.track(i),this.logger.info("Behavioral event tracked",{eventName:t,attributes:e})}catch(e){throw this.logger.error(P,{eventName:t,error:e}),e}}async ensureInitialized(){if(this.initializationPromise)try{await this.initializationPromise}catch(t){throw new Error(`SDK initialization failed: ${t}`)}if(!this.initialized)throw new Error("WebSDK must be initialized before tracking events. Call init() first.")}async setUserContextIfNeeded(t){if(!this.userContextSet){const e={country:this.config.country,city:this.config.city,country_code:this.config.countryCode};await this.setUserContext(t,e),this.logger.debug("User context set automatically",{cuid:t,systemDataArgs:e})}}}return lt});
1
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).WebSDK=n()}(this,function(){"use strict";var t="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||"undefined"!=typeof global&&global||{},n="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),e="FormData"in t,s="ArrayBuffer"in t;if(s)var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&o.indexOf(Object.prototype.toString.call(t))>-1};function a(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function c(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var n={next:function(){var n=t.shift();return{done:void 0===n,value:n}}};return r&&(n[Symbol.iterator]=function(){return n}),n}function h(t){this.map={},t instanceof h?t.forEach(function(t,n){this.append(n,t)},this):Array.isArray(t)?t.forEach(function(t){if(2!=t.length)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+t.length);this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(n){this.append(n,t[n])},this)}function d(t){if(!t.t)return t.bodyUsed?Promise.reject(new TypeError("Already read")):void(t.bodyUsed=!0)}function v(t){return new Promise(function(n,r){t.onload=function(){n(t.result)},t.onerror=function(){r(t.error)}})}function l(t){var n=new FileReader,r=v(n);return n.readAsArrayBuffer(t),r}function g(t){if(t.slice)return t.slice(0);var n=new Uint8Array(t.byteLength);return n.set(new Uint8Array(t)),n.buffer}function w(){return this.bodyUsed=!1,this.i=function(t){var r;this.bodyUsed=this.bodyUsed,this.o=t,t?"string"==typeof t?this.u=t:i&&Blob.prototype.isPrototypeOf(t)?this.h=t:e&&FormData.prototype.isPrototypeOf(t)?this.l=t:n&&URLSearchParams.prototype.isPrototypeOf(t)?this.u=t.toString():s&&i&&((r=t)&&DataView.prototype.isPrototypeOf(r))?(this.m=g(t.buffer),this.o=new Blob([this.m])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this.m=g(t):this.u=t=Object.prototype.toString.call(t):(this.t=!0,this.u=""),this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this.h&&this.h.type?this.headers.set("content-type",this.h.type):n&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=d(this);if(t)return t;if(this.h)return Promise.resolve(this.h);if(this.m)return Promise.resolve(new Blob([this.m]));if(this.l)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this.u]))}),this.arrayBuffer=function(){if(this.m){var t=d(this);return t||(ArrayBuffer.isView(this.m)?Promise.resolve(this.m.buffer.slice(this.m.byteOffset,this.m.byteOffset+this.m.byteLength)):Promise.resolve(this.m))}if(i)return this.blob().then(l);throw new Error("could not read as ArrayBuffer")},this.text=function(){var t,n,r,i,e,s=d(this);if(s)return s;if(this.h)return t=this.h,n=new FileReader,r=v(n),i=/charset=([A-Za-z0-9_-]+)/.exec(t.type),e=i?i[1]:"utf-8",n.readAsText(t,e),r;if(this.m)return Promise.resolve(function(t){for(var n=new Uint8Array(t),r=new Array(n.length),i=0;i<n.length;i++)r[i]=String.fromCharCode(n[i]);return r.join("")}(this.m));if(this.l)throw new Error("could not read FormData body as text");return Promise.resolve(this.u)},e&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,n){t=a(t),n=c(n);var r=this.map[t];this.map[t]=r?r+", "+n:n},h.prototype.delete=function(t){delete this.map[a(t)]},h.prototype.get=function(t){return t=a(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(a(t))},h.prototype.set=function(t,n){this.map[a(t)]=c(n)},h.prototype.forEach=function(t,n){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(n,this.map[r],r,this)},h.prototype.keys=function(){var t=[];return this.forEach(function(n,r){t.push(r)}),f(t)},h.prototype.values=function(){var t=[];return this.forEach(function(n){t.push(n)}),f(t)},h.prototype.entries=function(){var t=[];return this.forEach(function(n,r){t.push([r,n])}),f(t)},r&&(h.prototype[Symbol.iterator]=h.prototype.entries);var m=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function p(n,r){if(!(this instanceof p))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var i,e,s=(r=r||{}).body;if(n instanceof p){if(n.bodyUsed)throw new TypeError("Already read");this.url=n.url,this.credentials=n.credentials,r.headers||(this.headers=new h(n.headers)),this.method=n.method,this.mode=n.mode,this.signal=n.signal,s||null==n.o||(s=n.o,n.bodyUsed=!0)}else this.url=String(n);if(this.credentials=r.credentials||this.credentials||"same-origin",!r.headers&&this.headers||(this.headers=new h(r.headers)),this.method=(i=r.method||this.method||"GET",e=i.toUpperCase(),m.indexOf(e)>-1?e:i),this.mode=r.mode||this.mode||null,this.signal=r.signal||this.signal||function(){if("AbortController"in t)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&s)throw new TypeError("Body not allowed for GET or HEAD requests");if(this.i(s),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==r.cache&&"no-cache"!==r.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function y(t){var n=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),i=r.shift().replace(/\+/g," "),e=r.join("=").replace(/\+/g," ");n.append(decodeURIComponent(i),decodeURIComponent(e))}}),n}function b(t,n){if(!(this instanceof b))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(n||(n={}),this.type="default",this.status=void 0===n.status?200:n.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===n.statusText?"":""+n.statusText,this.headers=new h(n.headers),this.url=n.url||"",this.i(t)}p.prototype.clone=function(){return new p(this,{body:this.o})},w.call(p.prototype),w.call(b.prototype),b.prototype.clone=function(){return new b(this.o,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},b.error=function(){var t=new b(null,{status:200,statusText:""});return t.ok=!1,t.status=0,t.type="error",t};var E=[301,302,303,307,308];b.redirect=function(t,n){if(-1===E.indexOf(n))throw new RangeError("Invalid status code");return new b(null,{status:n,headers:{location:t}})};var I=t.DOMException;try{new I}catch(t){(I=function(t,n){this.message=t,this.name=n;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),I.prototype.constructor=I}function S(n,r){return new Promise(function(e,o){var u=new p(n,r);if(u.signal&&u.signal.aborted)return o(new I("Aborted","AbortError"));var f=new XMLHttpRequest;function d(){f.abort()}if(f.onload=function(){var t,n,r={statusText:f.statusText,headers:(t=f.getAllResponseHeaders()||"",n=new h,t.replace(/\r?\n[\t ]+/g," ").split("\r").map(function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t}).forEach(function(t){var r=t.split(":"),i=r.shift().trim();if(i){var e=r.join(":").trim();try{n.append(i,e)}catch(t){console.warn("Response "+t.message)}}}),n)};0===u.url.indexOf("file://")&&(f.status<200||f.status>599)?r.status=200:r.status=f.status,r.url="responseURL"in f?f.responseURL:r.headers.get("X-Request-URL");var i="response"in f?f.response:f.responseText;setTimeout(function(){e(new b(i,r))},0)},f.onerror=function(){setTimeout(function(){o(new TypeError("Network request failed"))},0)},f.ontimeout=function(){setTimeout(function(){o(new TypeError("Network request timed out"))},0)},f.onabort=function(){setTimeout(function(){o(new I("Aborted","AbortError"))},0)},f.open(u.method,function(n){try{return""===n&&t.location.href?t.location.href:n}catch(t){return n}}(u.url),!0),"include"===u.credentials?f.withCredentials=!0:"omit"===u.credentials&&(f.withCredentials=!1),"responseType"in f&&(i?f.responseType="blob":s&&(f.responseType="arraybuffer")),r&&"object"==typeof r.headers&&!(r.headers instanceof h||t.Headers&&r.headers instanceof t.Headers)){var v=[];Object.getOwnPropertyNames(r.headers).forEach(function(t){v.push(a(t)),f.setRequestHeader(t,c(r.headers[t]))}),u.headers.forEach(function(t,n){-1===v.indexOf(n)&&f.setRequestHeader(n,t)})}else u.headers.forEach(function(t,n){f.setRequestHeader(n,t)});u.signal&&(u.signal.addEventListener("abort",d),f.onreadystatechange=function(){4===f.readyState&&u.signal.removeEventListener("abort",d)}),f.send(void 0===u.o?null:u.o)})}S.polyfill=!0,t.fetch||(t.fetch=S,t.Headers=h,t.Request=p,t.Response=b);var T,k,R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},A={};function _(){if(k)return T;k=1;var t=function(t){return t&&t.Math===Math&&t};return T=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof R&&R)||t("object"==typeof T&&T)||function(){return this}()||Function("return this")()}var C,O,D,F,N,x,M,P,U={};function j(){return O?C:(O=1,C=function(t){try{return!!t()}catch(t){return!0}})}function z(){if(F)return D;F=1;var t=j();return D=!t(function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})}function V(){if(x)return N;x=1;var t=j();return N=!t(function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})}function L(){if(P)return M;P=1;var t=V(),n=Function.prototype.call;return M=t?n.bind(n):function(){return n.apply(n,arguments)},M}var B,G,W,q,K,H,X,$,J,Q,Y,Z,tt,nt,rt,it,et,st,ot,ut,at,ct,ft,ht,dt,vt,lt,gt,wt,mt,pt,yt,bt,Et,It,St,Tt,kt,Rt,At,_t,Ct={};function Ot(){if(B)return Ct;B=1;var t={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,r=n&&!t.call({1:2},1);return Ct.f=r?function(t){var r=n(this,t);return!!r&&r.enumerable}:t,Ct}function Dt(){return W?G:(W=1,G=function(t,n){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:n}})}function Ft(){if(K)return q;K=1;var t=V(),n=Function.prototype,r=n.call,i=t&&n.bind.bind(r,r);return q=t?i:function(t){return function(){return r.apply(t,arguments)}},q}function Nt(){if(X)return H;X=1;var t=Ft(),n=t({}.toString),r=t("".slice);return H=function(t){return r(n(t),8,-1)}}function xt(){if(J)return $;J=1;var t=Ft(),n=j(),r=Nt(),i=Object,e=t("".split);return $=n(function(){return!i("z").propertyIsEnumerable(0)})?function(t){return"String"===r(t)?e(t,""):i(t)}:i}function Mt(){return Y?Q:(Y=1,Q=function(t){return null==t})}function Pt(){if(tt)return Z;tt=1;var t=Mt(),n=TypeError;return Z=function(r){if(t(r))throw new n("Can't call method on "+r);return r}}function Ut(){if(rt)return nt;rt=1;var t=xt(),n=Pt();return nt=function(r){return t(n(r))}}function jt(){if(et)return it;et=1;var t="object"==typeof document&&document.all;return it=void 0===t&&void 0!==t?function(n){return"function"==typeof n||n===t}:function(t){return"function"==typeof t}}function zt(){if(ot)return st;ot=1;var t=jt();return st=function(n){return"object"==typeof n?null!==n:t(n)}}function Vt(){if(at)return ut;at=1;var t=_(),n=jt();return ut=function(r,i){return arguments.length<2?(e=t[r],n(e)?e:void 0):t[r]&&t[r][i];var e},ut}function Lt(){if(ft)return ct;ft=1;var t=Ft();return ct=t({}.isPrototypeOf)}function Bt(){if(dt)return ht;dt=1;var t=_().navigator,n=t&&t.userAgent;return ht=n?String(n):""}function Gt(){if(lt)return vt;lt=1;var t,n,r=_(),i=Bt(),e=r.process,s=r.Deno,o=e&&e.versions||s&&s.version,u=o&&o.v8;return u&&(n=(t=u.split("."))[0]>0&&t[0]<4?1:+(t[0]+t[1])),!n&&i&&(!(t=i.match(/Edge\/(\d+)/))||t[1]>=74)&&(t=i.match(/Chrome\/(\d+)/))&&(n=+t[1]),vt=n}function Wt(){if(wt)return gt;wt=1;var t=Gt(),n=j(),r=_().String;return gt=!!Object.getOwnPropertySymbols&&!n(function(){var n=Symbol("symbol detection");return!r(n)||!(Object(n)instanceof Symbol)||!Symbol.sham&&t&&t<41})}function qt(){if(pt)return mt;pt=1;var t=Wt();return mt=t&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function Kt(){if(bt)return yt;bt=1;var t=Vt(),n=jt(),r=Lt(),i=qt(),e=Object;return yt=i?function(t){return"symbol"==typeof t}:function(i){var s=t("Symbol");return n(s)&&r(s.prototype,e(i))}}function Ht(){if(It)return Et;It=1;var t=String;return Et=function(n){try{return t(n)}catch(t){return"Object"}}}function Xt(){if(Tt)return St;Tt=1;var t=jt(),n=Ht(),r=TypeError;return St=function(i){if(t(i))return i;throw new r(n(i)+" is not a function")}}function $t(){if(Rt)return kt;Rt=1;var t=Xt(),n=Mt();return kt=function(r,i){var e=r[i];return n(e)?void 0:t(e)}}function Jt(){if(_t)return At;_t=1;var t=L(),n=jt(),r=zt(),i=TypeError;return At=function(e,s){var o,u;if("string"===s&&n(o=e.toString)&&!r(u=t(o,e)))return u;if(n(o=e.valueOf)&&!r(u=t(o,e)))return u;if("string"!==s&&n(o=e.toString)&&!r(u=t(o,e)))return u;throw new i("Can't convert object to primitive value")}}var Qt,Yt,Zt,tn,nn,rn,en,sn,on,un,an,cn,fn,hn,dn,vn,ln,gn,wn,mn,pn,yn,bn,En,In={exports:{}};function Sn(){return Yt?Qt:(Yt=1,Qt=!1)}function Tn(){if(tn)return Zt;tn=1;var t=_(),n=Object.defineProperty;return Zt=function(r,i){try{n(t,r,{value:i,configurable:!0,writable:!0})}catch(n){t[r]=i}return i}}function kn(){if(nn)return In.exports;nn=1;var t=Sn(),n=_(),r=Tn(),i="__core-js_shared__",e=In.exports=n[i]||r(i,{});return(e.versions||(e.versions=[])).push({version:"3.48.0",mode:t?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.48.0/LICENSE",source:"https://github.com/zloirock/core-js"}),In.exports}function Rn(){if(en)return rn;en=1;var t=kn();return rn=function(n,r){return t[n]||(t[n]=r||{})}}function An(){if(on)return sn;on=1;var t=Pt(),n=Object;return sn=function(r){return n(t(r))}}function _n(){if(an)return un;an=1;var t=Ft(),n=An(),r=t({}.hasOwnProperty);return un=Object.hasOwn||function(t,i){return r(n(t),i)}}function Cn(){if(fn)return cn;fn=1;var t=Ft(),n=0,r=Math.random(),i=t(1.1.toString);return cn=function(t){return"Symbol("+(void 0===t?"":t)+")_"+i(++n+r,36)}}function On(){if(dn)return hn;dn=1;var t=_(),n=Rn(),r=_n(),i=Cn(),e=Wt(),s=qt(),o=t.Symbol,u=n("wks"),a=s?o.for||o:o&&o.withoutSetter||i;return hn=function(t){return r(u,t)||(u[t]=e&&r(o,t)?o[t]:a("Symbol."+t)),u[t]}}function Dn(){if(ln)return vn;ln=1;var t=L(),n=zt(),r=Kt(),i=$t(),e=Jt(),s=On(),o=TypeError,u=s("toPrimitive");return vn=function(s,a){if(!n(s)||r(s))return s;var c,f=i(s,u);if(f){if(void 0===a&&(a="default"),c=t(f,s,a),!n(c)||r(c))return c;throw new o("Can't convert object to primitive value")}return void 0===a&&(a="number"),e(s,a)}}function Fn(){if(wn)return gn;wn=1;var t=Dn(),n=Kt();return gn=function(r){var i=t(r,"string");return n(i)?i:i+""}}function Nn(){if(pn)return mn;pn=1;var t=_(),n=zt(),r=t.document,i=n(r)&&n(r.createElement);return mn=function(t){return i?r.createElement(t):{}}}function xn(){if(bn)return yn;bn=1;var t=z(),n=j(),r=Nn();return yn=!t&&!n(function(){return 7!==Object.defineProperty(r("div"),"a",{get:function(){return 7}}).a})}function Mn(){if(En)return U;En=1;var t=z(),n=L(),r=Ot(),i=Dt(),e=Ut(),s=Fn(),o=_n(),u=xn(),a=Object.getOwnPropertyDescriptor;return U.f=t?a:function(t,c){if(t=e(t),c=s(c),u)try{return a(t,c)}catch(t){}if(o(t,c))return i(!n(r.f,t,c),t[c])},U}var Pn,Un,jn,zn,Vn,Ln,Bn,Gn={};function Wn(){if(Un)return Pn;Un=1;var t=z(),n=j();return Pn=t&&n(function(){return 42!==Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype})}function qn(){if(zn)return jn;zn=1;var t=zt(),n=String,r=TypeError;return jn=function(i){if(t(i))return i;throw new r(n(i)+" is not an object")}}function Kn(){if(Vn)return Gn;Vn=1;var t=z(),n=xn(),r=Wn(),i=qn(),e=Fn(),s=TypeError,o=Object.defineProperty,u=Object.getOwnPropertyDescriptor,a="enumerable",c="configurable",f="writable";return Gn.f=t?r?function(t,n,r){if(i(t),n=e(n),i(r),"function"==typeof t&&"prototype"===n&&"value"in r&&f in r&&!r[f]){var s=u(t,n);s&&s[f]&&(t[n]=r.value,r={configurable:c in r?r[c]:s[c],enumerable:a in r?r[a]:s[a],writable:!1})}return o(t,n,r)}:o:function(t,r,u){if(i(t),r=e(r),i(u),n)try{return o(t,r,u)}catch(t){}if("get"in u||"set"in u)throw new s("Accessors not supported");return"value"in u&&(t[r]=u.value),t},Gn}function Hn(){if(Bn)return Ln;Bn=1;var t=z(),n=Kn(),r=Dt();return Ln=t?function(t,i,e){return n.f(t,i,r(1,e))}:function(t,n,r){return t[n]=r,t}}var Xn,$n,Jn,Qn,Yn,Zn,tr,nr,rr,ir,er,sr,or,ur,ar,cr={exports:{}};function fr(){if($n)return Xn;$n=1;var t=z(),n=_n(),r=Function.prototype,i=t&&Object.getOwnPropertyDescriptor,e=n(r,"name"),s=e&&"something"===function(){}.name,o=e&&(!t||t&&i(r,"name").configurable);return Xn={EXISTS:e,PROPER:s,CONFIGURABLE:o}}function hr(){if(Qn)return Jn;Qn=1;var t=Ft(),n=jt(),r=kn(),i=t(Function.toString);return n(r.inspectSource)||(r.inspectSource=function(t){return i(t)}),Jn=r.inspectSource}function dr(){if(nr)return tr;nr=1;var t=Rn(),n=Cn(),r=t("keys");return tr=function(t){return r[t]||(r[t]=n(t))}}function vr(){return ir?rr:(ir=1,rr={})}function lr(){if(sr)return er;sr=1;var t,n,r,i=function(){if(Zn)return Yn;Zn=1;var t=_(),n=jt(),r=t.WeakMap;return Yn=n(r)&&/native code/.test(String(r))}(),e=_(),s=zt(),o=Hn(),u=_n(),a=kn(),c=dr(),f=vr(),h="Object already initialized",d=e.TypeError,v=e.WeakMap;if(i||a.state){var l=a.state||(a.state=new v);l.get=l.get,l.has=l.has,l.set=l.set,t=function(t,n){if(l.has(t))throw new d(h);return n.facade=t,l.set(t,n),n},n=function(t){return l.get(t)||{}},r=function(t){return l.has(t)}}else{var g=c("state");f[g]=!0,t=function(t,n){if(u(t,g))throw new d(h);return n.facade=t,o(t,g,n),n},n=function(t){return u(t,g)?t[g]:{}},r=function(t){return u(t,g)}}return er={set:t,get:n,has:r,enforce:function(i){return r(i)?n(i):t(i,{})},getterFor:function(t){return function(r){var i;if(!s(r)||(i=n(r)).type!==t)throw new d("Incompatible receiver, "+t+" required");return i}}}}function gr(){if(or)return cr.exports;or=1;var t=Ft(),n=j(),r=jt(),i=_n(),e=z(),s=fr().CONFIGURABLE,o=hr(),u=lr(),a=u.enforce,c=u.get,f=String,h=Object.defineProperty,d=t("".slice),v=t("".replace),l=t([].join),g=e&&!n(function(){return 8!==h(function(){},"length",{value:8}).length}),w=String(String).split("String"),m=cr.exports=function(t,n,r){"Symbol("===d(f(n),0,7)&&(n="["+v(f(n),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(n="get "+n),r&&r.setter&&(n="set "+n),(!i(t,"name")||s&&t.name!==n)&&(e?h(t,"name",{value:n,configurable:!0}):t.name=n),g&&r&&i(r,"arity")&&t.length!==r.arity&&h(t,"length",{value:r.arity});try{r&&i(r,"constructor")&&r.constructor?e&&h(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var o=a(t);return i(o,"source")||(o.source=l(w,"string"==typeof n?n:"")),t};return Function.prototype.toString=m(function(){return r(this)&&c(this).source||o(this)},"toString"),cr.exports}function wr(){if(ar)return ur;ar=1;var t=jt(),n=Kn(),r=gr(),i=Tn();return ur=function(e,s,o,u){u||(u={});var a=u.enumerable,c=void 0!==u.name?u.name:s;if(t(o)&&r(o,c,u),u.global)a?e[s]=o:i(s,o);else{try{u.unsafe?e[s]&&(a=!0):delete e[s]}catch(t){}a?e[s]=o:n.f(e,s,{value:o,enumerable:!1,configurable:!u.nonConfigurable,writable:!u.nonWritable})}return e}}var mr,pr,yr,br,Er,Ir,Sr,Tr,kr,Rr,Ar,_r,Cr,Or,Dr,Fr,Nr,xr={};function Mr(){if(br)return yr;br=1;var t=function(){if(pr)return mr;pr=1;var t=Math.ceil,n=Math.floor;return mr=Math.trunc||function(r){var i=+r;return(i>0?n:t)(i)}}();return yr=function(n){var r=+n;return r!=r||0===r?0:t(r)}}function Pr(){if(Ir)return Er;Ir=1;var t=Mr(),n=Math.max,r=Math.min;return Er=function(i,e){var s=t(i);return s<0?n(s+e,0):r(s,e)}}function Ur(){if(Tr)return Sr;Tr=1;var t=Mr(),n=Math.min;return Sr=function(r){var i=t(r);return i>0?n(i,9007199254740991):0}}function jr(){if(Rr)return kr;Rr=1;var t=Ur();return kr=function(n){return t(n.length)}}function zr(){if(_r)return Ar;_r=1;var t=Ut(),n=Pr(),r=jr(),i=function(i){return function(e,s,o){var u=t(e),a=r(u);if(0===a)return!i&&-1;var c,f=n(o,a);if(i&&s!=s){for(;a>f;)if((c=u[f++])!=c)return!0}else for(;a>f;f++)if((i||f in u)&&u[f]===s)return i||f||0;return!i&&-1}};return Ar={includes:i(!0),indexOf:i(!1)}}function Vr(){if(Or)return Cr;Or=1;var t=Ft(),n=_n(),r=Ut(),i=zr().indexOf,e=vr(),s=t([].push);return Cr=function(t,o){var u,a=r(t),c=0,f=[];for(u in a)!n(e,u)&&n(a,u)&&s(f,u);for(;o.length>c;)n(a,u=o[c++])&&(~i(f,u)||s(f,u));return f}}function Lr(){return Fr?Dr:(Fr=1,Dr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}function Br(){if(Nr)return xr;Nr=1;var t=Vr(),n=Lr().concat("length","prototype");return xr.f=Object.getOwnPropertyNames||function(r){return t(r,n)},xr}var Gr,Wr,qr,Kr,Hr,Xr,$r,Jr,Qr,Yr,Zr,ti,ni,ri,ii,ei,si,oi,ui,ai,ci,fi,hi,di,vi,li,gi,wi,mi,pi,yi={};function bi(){return Gr||(Gr=1,yi.f=Object.getOwnPropertySymbols),yi}function Ei(){if(qr)return Wr;qr=1;var t=Vt(),n=Ft(),r=Br(),i=bi(),e=qn(),s=n([].concat);return Wr=t("Reflect","ownKeys")||function(t){var n=r.f(e(t)),o=i.f;return o?s(n,o(t)):n}}function Ii(){if(Hr)return Kr;Hr=1;var t=_n(),n=Ei(),r=Mn(),i=Kn();return Kr=function(e,s,o){for(var u=n(s),a=i.f,c=r.f,f=0;f<u.length;f++){var h=u[f];t(e,h)||o&&t(o,h)||a(e,h,c(s,h))}}}function Si(){if($r)return Xr;$r=1;var t=j(),n=jt(),r=/#|\.prototype\./,i=function(r,i){var a=s[e(r)];return a===u||a!==o&&(n(i)?t(i):!!i)},e=i.normalize=function(t){return String(t).replace(r,".").toLowerCase()},s=i.data={},o=i.NATIVE="N",u=i.POLYFILL="P";return Xr=i}function Ti(){if(Qr)return Jr;Qr=1;var t=_(),n=Mn().f,r=Hn(),i=wr(),e=Tn(),s=Ii(),o=Si();return Jr=function(u,a){var c,f,h,d,v,l=u.target,g=u.global,w=u.stat;if(c=g?t:w?t[l]||e(l,{}):t[l]&&t[l].prototype)for(f in a){if(d=a[f],h=u.dontCallGetSet?(v=n(c,f))&&v.value:c[f],!o(g?f:l+(w?".":"#")+f,u.forced)&&void 0!==h){if(typeof d==typeof h)continue;s(d,h)}(u.sham||h&&h.sham)&&r(d,"sham",!0),i(c,f,d,u)}}}function ki(){if(Zr)return Yr;Zr=1;var t=Nt();return Yr=Array.isArray||function(n){return"Array"===t(n)}}function Ri(){if(ni)return ti;ni=1;var t=TypeError;return ti=function(n){if(n>9007199254740991)throw t("Maximum allowed index exceeded");return n}}function Ai(){if(ii)return ri;ii=1;var t=z(),n=Kn(),r=Dt();return ri=function(i,e,s){t?n.f(i,e,r(0,s)):i[e]=s}}function _i(){if(si)return ei;si=1;var t=z(),n=ki(),r=TypeError,i=Object.getOwnPropertyDescriptor,e=t&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}();return ei=e?function(t,e){if(n(t)&&!i(t,"length").writable)throw new r("Cannot set read only .length");return t.length=e}:function(t,n){return t.length=n}}function Ci(){if(ui)return oi;ui=1;var t={};return t[On()("toStringTag")]="z",oi="[object z]"===String(t)}function Oi(){if(ci)return ai;ci=1;var t=Ci(),n=jt(),r=Nt(),i=On()("toStringTag"),e=Object,s="Arguments"===r(function(){return arguments}());return ai=t?r:function(t){var o,u,a;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(u=function(t,n){try{return t[n]}catch(t){}}(o=e(t),i))?u:s?r(o):"Object"===(a=r(o))&&n(o.callee)?"Arguments":a}}function Di(){if(hi)return fi;hi=1;var t=Ft(),n=j(),r=jt(),i=Oi(),e=Vt(),s=hr(),o=function(){},u=e("Reflect","construct"),a=/^\s*(?:class|function)\b/,c=t(a.exec),f=!a.test(o),h=function(t){if(!r(t))return!1;try{return u(o,[],t),!0}catch(t){return!1}},d=function(t){if(!r(t))return!1;switch(i(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return f||!!c(a,s(t))}catch(t){return!0}};return d.sham=!0,fi=!u||n(function(){var t;return h(h.call)||!h(Object)||!h(function(){t=!0})||t})?d:h}function Fi(){if(vi)return di;vi=1;var t=ki(),n=Di(),r=zt(),i=On()("species"),e=Array;return di=function(s){var o;return t(s)&&(o=s.constructor,(n(o)&&(o===e||t(o.prototype))||r(o)&&null===(o=o[i]))&&(o=void 0)),void 0===o?e:o}}function Ni(){if(gi)return li;gi=1;var t=Fi();return li=function(n,r){return new(t(n))(0===r?0:r)}}function xi(){if(mi)return wi;mi=1;var t=j(),n=On(),r=Gt(),i=n("species");return wi=function(n){return r>=51||!t(function(){var t=[];return(t.constructor={})[i]=function(){return{foo:1}},1!==t[n](Boolean).foo})}}!function(){if(pi)return A;pi=1;var t=Ti(),n=j(),r=ki(),i=zt(),e=An(),s=jr(),o=Ri(),u=Ai(),a=_i(),c=Ni(),f=xi(),h=On(),d=Gt(),v=h("isConcatSpreadable"),l=d>=51||!n(function(){var t=[];return t[v]=!1,t.concat()[0]!==t}),g=function(t){if(!i(t))return!1;var n=t[v];return void 0!==n?!!n:r(t)};t({target:"Array",proto:!0,arity:1,forced:!l||!f("concat")},{concat:function(t){var n,r,i,f,h,d=e(this),v=c(d,0),l=0;for(n=-1,i=arguments.length;n<i;n++)if(g(h=-1===n?d:arguments[n]))for(f=s(h),o(l+f),r=0;r<f;r++,l++)r in h&&u(v,l,h[r]);else o(l+1),u(v,l++,h);return a(v,l),v}})}();var Mi,Pi,Ui,ji,zi,Vi,Li,Bi,Gi,Wi,qi={},Ki={};function Hi(){if(Pi)return Mi;Pi=1;var t=Vr(),n=Lr();return Mi=Object.keys||function(r){return t(r,n)}}function Xi(){if(zi)return ji;zi=1;var t=Vt();return ji=t("document","documentElement")}function $i(){if(Li)return Vi;Li=1;var t,n=qn(),r=function(){if(Ui)return Ki;Ui=1;var t=z(),n=Wn(),r=Kn(),i=qn(),e=Ut(),s=Hi();return Ki.f=t&&!n?Object.defineProperties:function(t,n){i(t);for(var o,u=e(n),a=s(n),c=a.length,f=0;c>f;)r.f(t,o=a[f++],u[o]);return t},Ki}(),i=Lr(),e=vr(),s=Xi(),o=Nn(),u=dr(),a="prototype",c="script",f=u("IE_PROTO"),h=function(){},d=function(t){return"<"+c+">"+t+"</"+c+">"},v=function(t){t.write(d("")),t.close();var n=t.parentWindow.Object;return t=null,n},l=function(){try{t=new ActiveXObject("htmlfile")}catch(t){}var n,r,e;l="undefined"!=typeof document?document.domain&&t?v(t):(r=o("iframe"),e="java"+c+":",r.style.display="none",s.appendChild(r),r.src=String(e),(n=r.contentWindow.document).open(),n.write(d("document.F=Object")),n.close(),n.F):v(t);for(var u=i.length;u--;)delete l[a][i[u]];return l()};return e[f]=!0,Vi=Object.create||function(t,i){var e;return null!==t?(h[a]=n(t),e=new h,h[a]=null,e[f]=t):e=l(),void 0===i?e:r.f(e,i)}}function Ji(){if(Gi)return Bi;Gi=1;var t=On(),n=$i(),r=Kn().f,i=t("unscopables"),e=Array.prototype;return void 0===e[i]&&r(e,i,{configurable:!0,value:n(null)}),Bi=function(t){e[i][t]=!0}}!function(){if(Wi)return qi;Wi=1;var t=Ti(),n=zr().includes,r=j(),i=Ji();t({target:"Array",proto:!0,forced:r(function(){return!Array(1).includes()})},{includes:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}}),i("includes")}();var Qi,Yi,Zi,te={};function ne(){if(Yi)return Qi;Yi=1;var t=j();return Qi=function(n,r){var i=[][n];return!!i&&t(function(){i.call(null,r||function(){return 1},1)})}}!function(){if(Zi)return te;Zi=1;var t=Ti(),n=Ft(),r=xt(),i=Ut(),e=ne(),s=n([].join);t({target:"Array",proto:!0,forced:r!==Object||!e("join",",")},{join:function(t){return s(i(this),void 0===t?",":t)}})}();var re,ie={};!function(){if(re)return ie;re=1;var t=Ti(),n=An(),r=Hi();t({target:"Object",stat:!0,forced:j()(function(){r(1)})},{keys:function(t){return r(n(t))}})}();var ee,se,oe,ue={};!function(){if(oe)return ue;oe=1;var t=Ci(),n=wr(),r=function(){if(se)return ee;se=1;var t=Ci(),n=Oi();return ee=t?{}.toString:function(){return"[object "+n(this)+"]"}}();t||n(Object.prototype,"toString",r,{unsafe:!0})}();var ae,ce,fe,he,de,ve,le,ge,we,me={};function pe(){if(ce)return ae;ce=1;var t=Oi(),n=String;return ae=function(r){if("Symbol"===t(r))throw new TypeError("Cannot convert a Symbol value to a string");return n(r)}}function ye(){return he?fe:(he=1,fe="\t\n\v\f\r                 \u2028\u2029\ufeff")}function be(){if(ve)return de;ve=1;var t=Ft(),n=Pt(),r=pe(),i=ye(),e=t("".replace),s=RegExp("^["+i+"]+"),o=RegExp("(^|[^"+i+"])["+i+"]+$"),u=function(t){return function(i){var u=r(n(i));return 1&t&&(u=e(u,s,"")),2&t&&(u=e(u,o,"$1")),u}};return de={start:u(1),end:u(2),trim:u(3)}}!function(){if(we)return me;we=1;var t=Ti(),n=be().trim,r=function(){if(ge)return le;ge=1;var t=fr().PROPER,n=j(),r=ye();return le=function(i){return n(function(){return!!r[i]()||"​…᠎"!=="​…᠎"[i]()||t&&r[i].name!==i})}}();t({target:"String",proto:!0,forced:r("trim")},{trim:function(){return n(this)}})}();var Ee,Ie,Se,Te,ke,Re,Ae,_e,Ce,Oe,De,Fe,Ne,xe={};function Me(){return Ie?Ee:(Ie=1,Ee={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0})}function Pe(){if(Te)return Se;Te=1;var t=Nn()("span").classList,n=t&&t.constructor&&t.constructor.prototype;return Se=n===Object.prototype?void 0:n}function Ue(){if(Re)return ke;Re=1;var t=Nt(),n=Ft();return ke=function(r){if("Function"===t(r))return n(r)}}function je(){if(_e)return Ae;_e=1;var t=Ue(),n=Xt(),r=V(),i=t(t.bind);return Ae=function(t,e){return n(t),void 0===e?t:r?i(t,e):function(){return t.apply(e,arguments)}},Ae}function ze(){if(Oe)return Ce;Oe=1;var t=je(),n=xt(),r=An(),i=jr(),e=Ni(),s=Ai(),o=function(o){var u=1===o,a=2===o,c=3===o,f=4===o,h=6===o,d=7===o,v=5===o||h;return function(l,g,w){for(var m,p,y=r(l),b=n(y),E=i(b),I=t(g,w),S=0,T=0,k=u?e(l,E):a||d?e(l,0):void 0;E>S;S++)if((v||S in b)&&(p=I(m=b[S],S,y),o))if(u)s(k,S,p);else if(p)switch(o){case 3:return!0;case 5:return m;case 6:return S;case 2:s(k,T++,m)}else switch(o){case 4:return!1;case 7:s(k,T++,m)}return h?-1:c||f?f:k}};return Ce={forEach:o(0),map:o(1),filter:o(2),some:o(3),every:o(4),find:o(5),findIndex:o(6),filterReject:o(7)}}!function(){if(Ne)return xe;Ne=1;var t=_(),n=Me(),r=Pe(),i=function(){if(Fe)return De;Fe=1;var t=ze().forEach,n=ne()("forEach");return De=n?[].forEach:function(n){return t(this,n,arguments.length>1?arguments[1]:void 0)},De}(),e=Hn(),s=function(t){if(t&&t.forEach!==i)try{e(t,"forEach",i)}catch(n){t.forEach=i}};for(var o in n)n[o]&&s(t[o]&&t[o].prototype);s(r)}();var Ve=function(t,n){return Ve=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},Ve(t,n)};var Le=function(){return Le=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++)for(var e in n=arguments[r])Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e]);return t},Le.apply(this,arguments)};function Be(t,n,r,i){return new(r||(r=Promise))(function(e,s){function o(t){try{a(i.next(t))}catch(t){s(t)}}function u(t){try{a(i.throw(t))}catch(t){s(t)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(t){t(n)})).then(o,u)}a((i=i.apply(t,n||[])).next())})}function Ge(t,n){var r,i,e,s={label:0,sent:function(){if(1&e[0])throw e[1];return e[1]},trys:[],ops:[]},o=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return o.next=u(0),o.throw=u(1),o.return=u(2),"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(u){return function(a){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,u[0]&&(s=0)),s;)try{if(r=1,i&&(e=2&u[0]?i.return:u[0]?i.throw||((e=i.return)&&e.call(i),0):i.next)&&!(e=e.call(i,u[1])).done)return e;switch(i=0,e&&(u=[2&u[0],e.value]),u[0]){case 0:case 1:e=u;break;case 4:return s.label++,{value:u[1],done:!1};case 5:s.label++,i=u[1],u=[0];continue;case 7:u=s.ops.pop(),s.trys.pop();continue;default:if(!(e=s.trys,(e=e.length>0&&e[e.length-1])||6!==u[0]&&2!==u[0])){s=0;continue}if(3===u[0]&&(!e||u[1]>e[0]&&u[1]<e[3])){s.label=u[1];break}if(6===u[0]&&s.label<e[1]){s.label=e[1],e=u;break}if(e&&s.label<e[2]){s.label=e[2],s.ops.push(u);break}e[2]&&s.ops.pop(),s.trys.pop();continue}u=n.call(t,s)}catch(t){u=[6,t],i=0}finally{r=e=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,a])}}}function We(t){var n="function"==typeof Symbol&&Symbol.iterator,r=n&&t[n],i=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function qe(t,n){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var i,e,s=r.call(t),o=[];try{for(;(void 0===n||n-- >0)&&!(i=s.next()).done;)o.push(i.value)}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(e)throw e.error}}return o}function Ke(t,n,r){if(r||2===arguments.length)for(var i,e=0,s=n.length;e<s;e++)!i&&e in n||(i||(i=Array.prototype.slice.call(n,0,e)),i[e]=n[e]);return t.concat(i||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var He="/auth/nonce",Xe="/phantom/events",$e="/phantom/api/v2/sdk/config",Je="/phantom/api/v2/visitors",Qe="/phantom/api/v2/visitors",Ye="/phantom/api/v2/visitors/merge",Ze="/api/v1/websdk/dlr",ts=6e4,ns=18e5,rs={STATUSES:{PENDING:"pending"},BATCH_SIZE:50,DEFAULT_RETRY_DELAYS:[6e4,12e4,24e4,48e4,9e5],RETRYABLE_HTTP_CODES:[408,429,500,502,503,504,401],GLOBAL_SUCCESS_CODE:200,PARTIAL_SUCCESS_CODE:201},is="/firebase-messaging-sw.js",es="hydra-websdk-fcm",ss={NONCE_DATA:"websdk_nonce_data",USER_CONTEXT:"websdk_user_context",VISITOR_ID:"websdk_visitor_id",VISITOR_REF_ID:"websdk_visitor_ref_id",VISITOR_EXPIRED_AT:"websdk_visitor_expired_at",VISITOR_CONFIG:"websdk_visitor_config",FCM_TOKEN:"websdk_fcm_token",FCM_TOKEN_CREATED_AT:"websdk_fcm_token_created_at",NOTIFICATION_STATE:"websdk_notification_state",SESSION_ID:"websdk_session_id",SESSION_START_TIME:"websdk_session_start_time",LAST_EVENT_TIME:"websdk_last_event_time",LAST_AUTHENTICATED_USER:"websdk_last_authenticated_user",MERGED_USER_ID:"websdk_merged_user_id",PENDING_MERGE:"websdk_pending_merge"},os=ss;function us(t,n,r){var i=ss[t],e=[];return n&&e.push(n),r&&e.push(r),e.length>0?"".concat(e.join("_"),"_").concat(i):i}var as,cs,fs,hs="websdk_storage_test",ds="test_value",vs="INIT_ERROR",ls="AUTH_ERROR",gs="NETWORK_ERROR",ws="EVENT_ERROR",ms="VISITOR_CONFIG_ERROR",ps="WebSDK initialized successfully",ys="Failed to initialize WebSDK",bs="WebSDK destroyed successfully",Es="Authentication successful",Is="Authentication failed",Ss="AuthManager initialized successfully",Ts="Nonce request successful",ks="Nonce request failed",Rs="Failed to store nonce data",As="Failed to restore nonce data from storage",_s="Failed to clear stored nonce data",Cs="EventTracker initialized successfully",Os="EventTracker destroyed successfully",Ds="Failed to track event",Fs="Events sent successfully",Ns="Failed to send events",xs="Failed to initialize storage:",Ms="Storage test failed:",Ps="Storage read/write test failed",Us="StorageManager destroyed successfully",js="Error during storage cleanup:",zs="New session started",Vs="Session continued",Ls="Session expired due to inactivity",Bs="Session ended on user switch (different user login)",Gs="Session restored from storage",Ws="Failed to track user signin event",qs="Failed to track user signup event",Ks="Failed to track user update event",Hs="Failed to track user signout event",Xs="Failed to track behavioral event",$s="VisitorConfigManager initialized successfully",Js="Visitor config fetched successfully",Qs="Failed to fetch visitor config",Ys="Visitor tracking is disabled",Zs="Visitor tracking is enabled",to="Visitor config retrieved from cache",no="AnonymousVisitorManager initialized successfully",ro="Visitor ID generated successfully",io="Failed to generate visitor ID",eo="Visitor ID restored from storage",so="Using cached visitor ID",oo="Visitor updated successfully",uo="Failed to update visitor",ao="Visitor merged with user successfully",co="Failed to merge visitor with user",fo="Visitor merge skipped",ho="Notification permission denied by user",vo="Notification manager initialized successfully",lo="Failed to initialize notification manager",go="Notification initialization skipped (disabled or not supported)",wo="Firebase initialized successfully",mo="Failed to initialize Firebase",po="FCM token received successfully",yo="FCM token refreshed",bo="Failed to retrieve FCM token",Eo="Service worker registered successfully",Io="Failed to register service worker",So="DLR events sent successfully",To="Failed to send DLR events",ko="web",Ro="user_signin",Ao="user_signup",_o="user_update",Co="user_signout",Oo=30,Do=3e3,Fo={WEBPUSH:"WEBPUSH"},No={WEB:"web"},xo={ACCOUNT_NOT_EXISTS:2432,ACCOUNT_ID_NOT_PASSED:9999},Mo={ALREADY_MERGED:"1429",VISITOR_NOT_FOUND:"1428"},Po={NOTIFICATION_RECEIVED:"push_notification_received",NOTIFICATION_CLICKED:"push_notification_click",NOTIFICATION_DISMISSED:"push_notification_close"},Uo="fcm",jo="push",zo="1.0.3",Vo={};function Lo(){if(cs)return as;cs=1;var t=gr(),n=Kn();return as=function(r,i,e){return e.get&&t(e.get,i,{getter:!0}),e.set&&t(e.set,i,{setter:!0}),n.f(r,i,e)}}!function(){if(fs)return Vo;fs=1;var t=z(),n=fr().EXISTS,r=Ft(),i=Lo(),e=Function.prototype,s=r(e.toString),o=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,u=r(o.exec);t&&!n&&i(e,"name",{configurable:!0,get:function(){try{return u(o,s(this))[1]}catch(t){return""}}})}();var Bo,Go,Wo,qo,Ko,Ho,Xo,$o,Jo,Qo,Yo,Zo,tu,nu,ru,iu,eu,su,ou,uu,au,cu,fu,hu,du,vu,lu,gu,wu,mu,pu,yu,bu,Eu,Iu,Su,Tu,ku,Ru,Au,_u,Cu,Ou,Du,Fu,Nu,xu,Mu,Pu,Uu,ju,zu,Vu={};function Lu(){if(Go)return Bo;Go=1;var t=_(),n=Bt(),r=Nt(),i=function(t){return n.slice(0,t.length)===t};return Bo=i("Bun/")?"BUN":i("Cloudflare-Workers")?"CLOUDFLARE":i("Deno/")?"DENO":i("Node.js/")?"NODE":t.Bun&&"string"==typeof Bun.version?"BUN":t.Deno&&"object"==typeof Deno.version?"DENO":"process"===r(t.process)?"NODE":t.window&&t.document?"BROWSER":"REST"}function Bu(){if(qo)return Wo;qo=1;var t=Lu();return Wo="NODE"===t}function Gu(){if(Ho)return Ko;Ho=1;var t=_();return Ko=t}function Wu(){if(Qo)return Jo;Qo=1;var t=zt();return Jo=function(n){return t(n)||null===n}}function qu(){if(Zo)return Yo;Zo=1;var t=Wu(),n=String,r=TypeError;return Yo=function(i){if(t(i))return i;throw new r("Can't set "+n(i)+" as a prototype")}}function Ku(){if(nu)return tu;nu=1;var t=function(){if($o)return Xo;$o=1;var t=Ft(),n=Xt();return Xo=function(r,i,e){try{return t(n(Object.getOwnPropertyDescriptor(r,i)[e]))}catch(t){}}}(),n=zt(),r=Pt(),i=qu();return tu=Object.setPrototypeOf||("__proto__"in{}?function(){var e,s=!1,o={};try{(e=t(Object.prototype,"__proto__","set"))(o,[]),s=o instanceof Array}catch(t){}return function(t,o){return r(t),i(o),n(t)?(s?e(t,o):t.__proto__=o,t):t}}():void 0)}function Hu(){if(iu)return ru;iu=1;var t=Kn().f,n=_n(),r=On()("toStringTag");return ru=function(i,e,s){i&&!s&&(i=i.prototype),i&&!n(i,r)&&t(i,r,{configurable:!0,value:e})}}function Xu(){if(su)return eu;su=1;var t=Vt(),n=Lo(),r=On(),i=z(),e=r("species");return eu=function(r){var s=t(r);i&&s&&!s[e]&&n(s,e,{configurable:!0,get:function(){return this}})}}function $u(){if(uu)return ou;uu=1;var t=Lt(),n=TypeError;return ou=function(r,i){if(t(i,r))return r;throw new n("Incorrect invocation")}}function Ju(){if(cu)return au;cu=1;var t=Di(),n=Ht(),r=TypeError;return au=function(i){if(t(i))return i;throw new r(n(i)+" is not a constructor")}}function Qu(){if(hu)return fu;hu=1;var t=qn(),n=Ju(),r=Mt(),i=On()("species");return fu=function(e,s){var o,u=t(e).constructor;return void 0===u||r(o=t(u)[i])?s:n(o)}}function Yu(){if(vu)return du;vu=1;var t=V(),n=Function.prototype,r=n.apply,i=n.call;return du="object"==typeof Reflect&&Reflect.apply||(t?i.bind(r):function(){return i.apply(r,arguments)}),du}function Zu(){if(gu)return lu;gu=1;var t=Ft();return lu=t([].slice)}function ta(){if(mu)return wu;mu=1;var t=TypeError;return wu=function(n,r){if(n<r)throw new t("Not enough arguments");return n}}function na(){if(yu)return pu;yu=1;var t=Bt();return pu=/(?:ipad|iphone|ipod).*applewebkit/i.test(t)}function ra(){if(Eu)return bu;Eu=1;var t,n,r,i,e=_(),s=Yu(),o=je(),u=jt(),a=_n(),c=j(),f=Xi(),h=Zu(),d=Nn(),v=ta(),l=na(),g=Bu(),w=e.setImmediate,m=e.clearImmediate,p=e.process,y=e.Dispatch,b=e.Function,E=e.MessageChannel,I=e.String,S=0,T={},k="onreadystatechange";c(function(){t=e.location});var R=function(t){if(a(T,t)){var n=T[t];delete T[t],n()}},A=function(t){return function(){R(t)}},C=function(t){R(t.data)},O=function(n){e.postMessage(I(n),t.protocol+"//"+t.host)};return w&&m||(w=function(t){v(arguments.length,1);var r=u(t)?t:b(t),i=h(arguments,1);return T[++S]=function(){s(r,void 0,i)},n(S),S},m=function(t){delete T[t]},g?n=function(t){p.nextTick(A(t))}:y&&y.now?n=function(t){y.now(A(t))}:E&&!l?(i=(r=new E).port2,r.port1.onmessage=C,n=o(i.postMessage,i)):e.addEventListener&&u(e.postMessage)&&!e.importScripts&&t&&"file:"!==t.protocol&&!c(O)?(n=O,e.addEventListener("message",C,!1)):n=k in d("script")?function(t){f.appendChild(d("script"))[k]=function(){f.removeChild(this),R(t)}}:function(t){setTimeout(A(t),0)}),bu={set:w,clear:m}}function ia(){if(Su)return Iu;Su=1;var t=_(),n=z(),r=Object.getOwnPropertyDescriptor;return Iu=function(i){if(!n)return t[i];var e=r(t,i);return e&&e.value}}function ea(){if(ku)return Tu;ku=1;var t=function(){this.head=null,this.tail=null};return t.prototype={add:function(t){var n={item:t,next:null},r=this.tail;r?r.next=n:this.head=n,this.tail=n},get:function(){var t=this.head;if(t)return null===(this.head=t.next)&&(this.tail=null),t.item}},Tu=t}function sa(){if(Du)return Ou;Du=1;var t,n,r,i,e,s=_(),o=ia(),u=je(),a=ra().set,c=ea(),f=na(),h=function(){if(Au)return Ru;Au=1;var t=Bt();return Ru=/ipad|iphone|ipod/i.test(t)&&"undefined"!=typeof Pebble}(),d=function(){if(Cu)return _u;Cu=1;var t=Bt();return _u=/web0s(?!.*chrome)/i.test(t)}(),v=Bu(),l=s.MutationObserver||s.WebKitMutationObserver,g=s.document,w=s.process,m=s.Promise,p=o("queueMicrotask");if(!p){var y=new c,b=function(){var n,r;for(v&&(n=w.domain)&&n.exit();r=y.get();)try{r()}catch(n){throw y.head&&t(),n}n&&n.enter()};f||v||d||!l||!g?!h&&m&&m.resolve?((i=m.resolve(void 0)).constructor=m,e=u(i.then,i),t=function(){e(b)}):v?t=function(){w.nextTick(b)}:(a=u(a,s),t=function(){a(b)}):(n=!0,r=g.createTextNode(""),new l(b).observe(r,{characterData:!0}),t=function(){r.data=n=!n}),p=function(n){y.head||t(),y.add(n)}}return Ou=p}function oa(){return Nu||(Nu=1,Fu=function(t,n){try{1===arguments.length?console.error(t):console.error(t,n)}catch(t){}}),Fu}function ua(){return Mu?xu:(Mu=1,xu=function(t){try{return{error:!1,value:t()}}catch(t){return{error:!0,value:t}}})}function aa(){if(Uu)return Pu;Uu=1;var t=_();return Pu=t.Promise}function ca(){if(zu)return ju;zu=1;var t=_(),n=aa(),r=jt(),i=Si(),e=hr(),s=On(),o=Lu(),u=Sn(),a=Gt(),c=n&&n.prototype,f=s("species"),h=!1,d=r(t.PromiseRejectionEvent),v=i("Promise",function(){var t=e(n),r=t!==String(n);if(!r&&66===a)return!0;if(u&&(!c.catch||!c.finally))return!0;if(!a||a<51||!/native code/.test(t)){var i=new n(function(t){t(1)}),s=function(t){t(function(){},function(){})};if((i.constructor={})[f]=s,!(h=i.then(function(){})instanceof s))return!0}return!(r||"BROWSER"!==o&&"DENO"!==o||d)});return ju={CONSTRUCTOR:v,REJECTION_EVENT:d,SUBCLASSING:h}}var fa,ha,da={};function va(){if(fa)return da;fa=1;var t=Xt(),n=TypeError,r=function(r){var i,e;this.promise=new r(function(t,r){if(void 0!==i||void 0!==e)throw new n("Bad Promise constructor");i=t,e=r}),this.resolve=t(i),this.reject=t(e)};return da.f=function(t){return new r(t)},da}var la,ga,wa,ma,pa,ya,ba,Ea,Ia,Sa,Ta,ka,Ra,Aa,_a,Ca,Oa,Da={};function Fa(){return ga?la:(ga=1,la={})}function Na(){if(ma)return wa;ma=1;var t=On(),n=Fa(),r=t("iterator"),i=Array.prototype;return wa=function(t){return void 0!==t&&(n.Array===t||i[r]===t)}}function xa(){if(ya)return pa;ya=1;var t=Oi(),n=$t(),r=Mt(),i=Fa(),e=On()("iterator");return pa=function(s){if(!r(s))return n(s,e)||n(s,"@@iterator")||i[t(s)]}}function Ma(){if(Ea)return ba;Ea=1;var t=L(),n=Xt(),r=qn(),i=Ht(),e=xa(),s=TypeError;return ba=function(o,u){var a=arguments.length<2?e(o):u;if(n(a))return r(t(a,o));throw new s(i(o)+" is not iterable")},ba}function Pa(){if(Sa)return Ia;Sa=1;var t=L(),n=qn(),r=$t();return Ia=function(i,e,s){var o,u;n(i);try{if(!(o=r(i,"return"))){if("throw"===e)throw s;return s}o=t(o,i)}catch(t){u=!0,o=t}if("throw"===e)throw s;if(u)throw o;return n(o),s}}function Ua(){if(ka)return Ta;ka=1;var t=je(),n=L(),r=qn(),i=Ht(),e=Na(),s=jr(),o=Lt(),u=Ma(),a=xa(),c=Pa(),f=TypeError,h=function(t,n){this.stopped=t,this.result=n},d=h.prototype;return Ta=function(v,l,g){var w,m,p,y,b,E,I,S=g&&g.that,T=!(!g||!g.AS_ENTRIES),k=!(!g||!g.IS_RECORD),R=!(!g||!g.IS_ITERATOR),A=!(!g||!g.INTERRUPTED),_=t(l,S),C=function(t){return w&&c(w,"normal"),new h(!0,t)},O=function(t){return T?(r(t),A?_(t[0],t[1],C):_(t[0],t[1])):A?_(t,C):_(t)};if(k)w=v.iterator;else if(R)w=v;else{if(!(m=a(v)))throw new f(i(v)+" is not iterable");if(e(m)){for(p=0,y=s(v);y>p;p++)if((b=O(v[p]))&&o(d,b))return b;return new h(!1)}w=u(v,m)}for(E=k?v.next:w.next;!(I=n(E,w)).done;){try{b=O(I.value)}catch(t){c(w,"throw",t)}if("object"==typeof b&&b&&o(d,b))return b}return new h(!1)}}function ja(){if(Aa)return Ra;Aa=1;var t=On()("iterator"),n=!1;try{var r=0,i={next:function(){return{done:!!r++}},return:function(){n=!0}};i[t]=function(){return this},Array.from(i,function(){throw 2})}catch(t){}return Ra=function(r,i){try{if(!i&&!n)return!1}catch(t){return!1}var e=!1;try{var s={};s[t]=function(){return{next:function(){return{done:e=!0}}}},r(s)}catch(t){}return e}}function za(){if(Ca)return _a;Ca=1;var t=aa(),n=ja(),r=ca().CONSTRUCTOR;return _a=r||!n(function(n){t.all(n).then(void 0,function(){})})}var Va,La={};var Ba,Ga={};var Wa,qa={};var Ka,Ha,Xa,$a,Ja={};function Qa(){if(Ha)return Ka;Ha=1;var t=qn(),n=zt(),r=va();return Ka=function(i,e){if(t(i),n(e)&&e.constructor===i)return e;var s=r.f(i);return(0,s.resolve)(e),s.promise}}$a||($a=1,function(){if(ha)return Vu;ha=1;var t,n,r,i,e=Ti(),s=Sn(),o=Bu(),u=_(),a=Gu(),c=L(),f=wr(),h=Ku(),d=Hu(),v=Xu(),l=Xt(),g=jt(),w=zt(),m=$u(),p=Qu(),y=ra().set,b=sa(),E=oa(),I=ua(),S=ea(),T=lr(),k=aa(),R=ca(),A=va(),C="Promise",O=R.CONSTRUCTOR,D=R.REJECTION_EVENT,F=R.SUBCLASSING,N=T.getterFor(C),x=T.set,M=k&&k.prototype,P=k,U=M,j=u.TypeError,z=u.document,V=u.process,B=A.f,G=B,W=!!(z&&z.createEvent&&u.dispatchEvent),q="unhandledrejection",K=function(t){var n;return!(!w(t)||!g(n=t.then))&&n},H=function(t,n){var r,i,e,s=n.value,o=1===n.state,u=o?t.ok:t.fail,a=t.resolve,f=t.reject,h=t.domain;try{u?(o||(2===n.rejection&&Y(n),n.rejection=1),!0===u?r=s:(h&&h.enter(),r=u(s),h&&(h.exit(),e=!0)),r===t.promise?f(new j("Promise-chain cycle")):(i=K(r))?c(i,r,a,f):a(r)):f(s)}catch(t){h&&!e&&h.exit(),f(t)}},X=function(t,n){t.notified||(t.notified=!0,b(function(){for(var r,i=t.reactions;r=i.get();)H(r,t);t.notified=!1,n&&!t.rejection&&J(t)}))},$=function(t,n,r){var i,e;W?((i=z.createEvent("Event")).promise=n,i.reason=r,i.initEvent(t,!1,!0),u.dispatchEvent(i)):i={promise:n,reason:r},!D&&(e=u["on"+t])?e(i):t===q&&E("Unhandled promise rejection",r)},J=function(t){c(y,u,function(){var n,r=t.facade,i=t.value;if(Q(t)&&(n=I(function(){o?V.emit("unhandledRejection",i,r):$(q,r,i)}),t.rejection=o||Q(t)?2:1,n.error))throw n.value})},Q=function(t){return 1!==t.rejection&&!t.parent},Y=function(t){c(y,u,function(){var n=t.facade;o?V.emit("rejectionHandled",n):$("rejectionhandled",n,t.value)})},Z=function(t,n,r){return function(i){t(n,i,r)}},tt=function(t,n,r){t.done||(t.done=!0,r&&(t=r),t.value=n,t.state=2,X(t,!0))},nt=function(t,n,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===n)throw new j("Promise can't be resolved itself");var i=K(n);i?b(function(){var r={done:!1};try{c(i,n,Z(nt,r,t),Z(tt,r,t))}catch(n){tt(r,n,t)}}):(t.value=n,t.state=1,X(t,!1))}catch(n){tt({done:!1},n,t)}}};if(O&&(U=(P=function(n){m(this,U),l(n),c(t,this);var r=N(this);try{n(Z(nt,r),Z(tt,r))}catch(t){tt(r,t)}}).prototype,(t=function(t){x(this,{type:C,done:!1,notified:!1,parent:!1,reactions:new S,rejection:!1,state:0,value:null})}).prototype=f(U,"then",function(t,n){var r=N(this),i=B(p(this,P));return r.parent=!0,i.ok=!g(t)||t,i.fail=g(n)&&n,i.domain=o?V.domain:void 0,0===r.state?r.reactions.add(i):b(function(){H(i,r)}),i.promise}),n=function(){var n=new t,r=N(n);this.promise=n,this.resolve=Z(nt,r),this.reject=Z(tt,r)},A.f=B=function(t){return t===P||t===r?new n(t):G(t)},!s&&g(k)&&M!==Object.prototype)){i=M.then,F||f(M,"then",function(t,n){var r=this;return new P(function(t,n){c(i,r,t,n)}).then(t,n)},{unsafe:!0});try{delete M.constructor}catch(t){}h&&h(M,U)}e({global:!0,constructor:!0,wrap:!0,forced:O},{Promise:P}),r=a.Promise,d(P,C,!1,!0),v(C)}(),function(){if(Oa)return Da;Oa=1;var t=Ti(),n=L(),r=Xt(),i=va(),e=ua(),s=Ua();t({target:"Promise",stat:!0,forced:za()},{all:function(t){var o=this,u=i.f(o),a=u.resolve,c=u.reject,f=e(function(){var i=r(o.resolve),e=[],u=0,f=1;s(t,function(t){var r=u++,s=!1;f++,n(i,o,t).then(function(t){s||(s=!0,e[r]=t,--f||a(e))},c)}),--f||a(e)});return f.error&&c(f.value),u.promise}})}(),function(){if(Va)return La;Va=1;var t=Ti(),n=Sn(),r=ca().CONSTRUCTOR,i=aa(),e=Vt(),s=jt(),o=wr(),u=i&&i.prototype;if(t({target:"Promise",proto:!0,forced:r,real:!0},{catch:function(t){return this.then(void 0,t)}}),!n&&s(i)){var a=e("Promise").prototype.catch;u.catch!==a&&o(u,"catch",a,{unsafe:!0})}}(),function(){if(Ba)return Ga;Ba=1;var t=Ti(),n=L(),r=Xt(),i=va(),e=ua(),s=Ua();t({target:"Promise",stat:!0,forced:za()},{race:function(t){var o=this,u=i.f(o),a=u.reject,c=e(function(){var i=r(o.resolve);s(t,function(t){n(i,o,t).then(u.resolve,a)})});return c.error&&a(c.value),u.promise}})}(),function(){if(Wa)return qa;Wa=1;var t=Ti(),n=va();t({target:"Promise",stat:!0,forced:ca().CONSTRUCTOR},{reject:function(t){var r=n.f(this);return(0,r.reject)(t),r.promise}})}(),function(){if(Xa)return Ja;Xa=1;var t=Ti(),n=Vt(),r=Sn(),i=aa(),e=ca().CONSTRUCTOR,s=Qa(),o=n("Promise"),u=r&&!e;t({target:"Promise",stat:!0,forced:r||e},{resolve:function(t){return s(u&&this===o?i:this,t)}})}());var Ya,Za,tc,nc,rc,ic,ec,sc,oc,uc,ac,cc={};function fc(){if(Za)return Ya;Za=1;var t=qn();return Ya=function(){var n=t(this),r="";return n.hasIndices&&(r+="d"),n.global&&(r+="g"),n.ignoreCase&&(r+="i"),n.multiline&&(r+="m"),n.dotAll&&(r+="s"),n.unicode&&(r+="u"),n.unicodeSets&&(r+="v"),n.sticky&&(r+="y"),r}}function hc(){if(nc)return tc;nc=1;var t=j(),n=_().RegExp,r=t(function(){var t=n("a","y");return t.lastIndex=2,null!==t.exec("abcd")}),i=r||t(function(){return!n("a","y").sticky}),e=r||t(function(){var t=n("^r","gy");return t.lastIndex=2,null!==t.exec("str")});return tc={BROKEN_CARET:e,MISSED_STICKY:i,UNSUPPORTED_Y:r}}function dc(){if(ic)return rc;ic=1;var t=j(),n=_().RegExp;return rc=t(function(){var t=n(".","s");return!(t.dotAll&&t.test("\n")&&"s"===t.flags)})}function vc(){if(sc)return ec;sc=1;var t=j(),n=_().RegExp;return ec=t(function(){var t=n("(?<a>b)","g");return"b"!==t.exec("b").groups.a||"bc"!=="b".replace(t,"$<a>c")})}function lc(){if(uc)return oc;uc=1;var t,n,r=L(),i=Ft(),e=pe(),s=fc(),o=hc(),u=Rn(),a=$i(),c=lr().get,f=dc(),h=vc(),d=u("native-string-replace",String.prototype.replace),v=RegExp.prototype.exec,l=v,g=i("".charAt),w=i("".indexOf),m=i("".replace),p=i("".slice),y=(n=/b*/g,r(v,t=/a/,"a"),r(v,n,"a"),0!==t.lastIndex||0!==n.lastIndex),b=o.BROKEN_CARET,E=void 0!==/()??/.exec("")[1];return(y||E||b||f||h)&&(l=function(t){var n,i,o,u,f,h,I,S=this,T=c(S),k=e(t),R=T.raw;if(R)return R.lastIndex=S.lastIndex,n=r(l,R,k),S.lastIndex=R.lastIndex,n;var A=T.groups,_=b&&S.sticky,C=r(s,S),O=S.source,D=0,F=k;if(_&&(C=m(C,"y",""),-1===w(C,"g")&&(C+="g"),F=p(k,S.lastIndex),S.lastIndex>0&&(!S.multiline||S.multiline&&"\n"!==g(k,S.lastIndex-1))&&(O="(?: "+O+")",F=" "+F,D++),i=new RegExp("^(?:"+O+")",C)),E&&(i=new RegExp("^"+O+"$(?!\\s)",C)),y&&(o=S.lastIndex),u=r(v,_?i:S,F),_?u?(u.input=p(u.input,D),u[0]=p(u[0],D),u.index=S.lastIndex,S.lastIndex+=u[0].length):S.lastIndex=0:y&&u&&(S.lastIndex=S.global?u.index+u[0].length:o),E&&u&&u.length>1&&r(d,u[0],i,function(){for(f=1;f<arguments.length-2;f++)void 0===arguments[f]&&(u[f]=void 0)}),u&&A)for(u.groups=h=a(null),f=0;f<A.length;f++)h[(I=A[f])[0]]=u[I[1]];return u}),oc=l}function gc(){if(ac)return cc;ac=1;var t=Ti(),n=lc();return t({target:"RegExp",proto:!0,forced:/./.exec!==n},{exec:n}),cc}gc();var wc,mc,pc,yc,bc,Ec,Ic,Sc={};function Tc(){if(mc)return wc;mc=1;var t=zt(),n=Nt(),r=On()("match");return wc=function(i){var e;return t(i)&&(void 0!==(e=i[r])?!!e:"RegExp"===n(i))}}function kc(){if(yc)return pc;yc=1;var t=Tc(),n=TypeError;return pc=function(r){if(t(r))throw new n("The method doesn't accept regular expressions");return r}}function Rc(){if(Ec)return bc;Ec=1;var t=On()("match");return bc=function(n){var r=/./;try{"/./"[n](r)}catch(i){try{return r[t]=!1,"/./"[n](r)}catch(t){}}return!1}}!function(){if(Ic)return Sc;Ic=1;var t=Ti(),n=Ft(),r=kc(),i=Pt(),e=pe(),s=Rc(),o=n("".indexOf);t({target:"String",proto:!0,forced:!s("includes")},{includes:function(t){return!!~o(e(i(this)),e(r(t)),arguments.length>1?arguments[1]:void 0)}})}();var Ac,_c,Cc,Oc,Dc,Fc,Nc,xc,Mc,Pc,Uc,jc,zc,Vc,Lc,Bc={};function Gc(){if(_c)return Ac;_c=1,gc();var t=L(),n=wr(),r=lc(),i=j(),e=On(),s=Hn(),o=e("species"),u=RegExp.prototype;return Ac=function(a,c,f,h){var d=e(a),v=!i(function(){var t={};return t[d]=function(){return 7},7!==""[a](t)}),l=v&&!i(function(){var t=!1,n=/a/;if("split"===a){var r={};r[o]=function(){return n},(n={constructor:r,flags:""})[d]=/./[d]}return n.exec=function(){return t=!0,null},n[d](""),!t});if(!v||!l||f){var g=/./[d],w=c(d,""[a],function(n,i,e,s,o){var a=i.exec;return a===r||a===u.exec?v&&!o?{done:!0,value:t(g,i,e,s)}:{done:!0,value:t(n,e,i,s)}:{done:!1}});n(String.prototype,a,w[0]),n(u,d,w[1])}h&&s(u[d],"sham",!0)},Ac}function Wc(){if(Oc)return Cc;Oc=1;var t=Ft(),n=Mr(),r=pe(),i=Pt(),e=t("".charAt),s=t("".charCodeAt),o=t("".slice),u=function(t){return function(u,a){var c,f,h=r(i(u)),d=n(a),v=h.length;return d<0||d>=v?t?"":void 0:(c=s(h,d))<55296||c>56319||d+1===v||(f=s(h,d+1))<56320||f>57343?t?e(h,d):c:t?o(h,d,d+2):f-56320+(c-55296<<10)+65536}};return Cc={codeAt:u(!1),charAt:u(!0)}}function qc(){if(Fc)return Dc;Fc=1;var t=Wc().charAt;return Dc=function(n,r,i){return r+(i?t(n,r).length:1)}}function Kc(){if(xc)return Nc;xc=1;var t=Ft(),n=An(),r=Math.floor,i=t("".charAt),e=t("".replace),s=t("".slice),o=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,u=/\$([$&'`]|\d{1,2})/g;return Nc=function(t,a,c,f,h,d){var v=c+t.length,l=f.length,g=u;return void 0!==h&&(h=n(h),g=o),e(d,g,function(n,e){var o;switch(i(e,0)){case"$":return"$";case"&":return t;case"`":return s(a,0,c);case"'":return s(a,v);case"<":o=h[s(e,1,-1)];break;default:var u=+e;if(0===u)return n;if(u>l){var d=r(u/10);return 0===d?n:d<=l?void 0===f[d-1]?i(e,1):f[d-1]+i(e,1):n}o=f[u-1]}return void 0===o?"":o})}}function Hc(){if(jc)return Uc;jc=1;var t=L(),n=_n(),r=Lt(),i=function(){if(Pc)return Mc;Pc=1;var t=_(),n=j(),r=t.RegExp,i=!n(function(){var t=!0;try{r(".","d")}catch(n){t=!1}var n={},i="",e=t?"dgimsy":"gimsy",s=function(t,r){Object.defineProperty(n,t,{get:function(){return i+=r,!0}})},o={dotAll:"s",global:"g",ignoreCase:"i",multiline:"m",sticky:"y"};for(var u in t&&(o.hasIndices="d"),o)s(u,o[u]);return Object.getOwnPropertyDescriptor(r.prototype,"flags").get.call(n)!==e||i!==e});return Mc={correct:i}}(),e=fc(),s=RegExp.prototype;return Uc=i.correct?function(t){return t.flags}:function(o){return i.correct||!r(s,o)||n(o,"flags")?o.flags:t(e,o)}}function Xc(){if(Vc)return zc;Vc=1;var t=L(),n=qn(),r=jt(),i=Nt(),e=lc(),s=TypeError;return zc=function(o,u){var a=o.exec;if(r(a)){var c=t(a,o,u);return null!==c&&n(c),c}if("RegExp"===i(o))return t(e,o,u);throw new s("RegExp#exec called on incompatible receiver")}}!function(){if(Lc)return Bc;Lc=1;var t=Yu(),n=L(),r=Ft(),i=Gc(),e=j(),s=qn(),o=jt(),u=zt(),a=Mr(),c=Ur(),f=pe(),h=Pt(),d=qc(),v=$t(),l=Kc(),g=Hc(),w=Xc(),m=On()("replace"),p=Math.max,y=Math.min,b=r([].concat),E=r([].push),I=r("".indexOf),S=r("".slice),T=function(t){return void 0===t?t:String(t)},k="$0"==="a".replace(/./,"$0"),R=!!/./[m]&&""===/./[m]("a","$0");i("replace",function(r,i,e){var k=R?"$":"$0";return[function(t,r){var e=h(this),s=u(t)?v(t,m):void 0;return s?n(s,t,e,r):n(i,f(e),t,r)},function(n,r){var u=s(this),h=f(n);if("string"==typeof r&&-1===I(r,k)&&-1===I(r,"$<")){var v=e(i,u,h,r);if(v.done)return v.value}var m=o(r);m||(r=f(r));var R,A=f(g(u)),_=-1!==I(A,"g");_&&(R=-1!==I(A,"u"),u.lastIndex=0);for(var C,O=[];null!==(C=w(u,h))&&(E(O,C),_);){""===f(C[0])&&(u.lastIndex=d(h,c(u.lastIndex),R))}for(var D="",F=0,N=0;N<O.length;N++){for(var x,M=f((C=O[N])[0]),P=p(y(a(C.index),h.length),0),U=[],j=1;j<C.length;j++)E(U,T(C[j]));var z=C.groups;if(m){var V=b([M],U,P,h);void 0!==z&&E(V,z),x=f(t(r,void 0,V))}else x=l(M,h,P,U,z,r);P>=F&&(D+=S(h,F,P)+x,F=P+M.length)}return D+S(h,F)}]},!!e(function(){var t=/./;return t.exec=function(){var t=[];return t.groups={a:"7"},t},"7"!=="".replace(t,"$<a>")})||!k||R)}();var $c,Jc={};!function(){if($c)return Jc;$c=1;var t,n=Ti(),r=Ue(),i=Mn().f,e=Ur(),s=pe(),o=kc(),u=Pt(),a=Rc(),c=Sn(),f=r("".slice),h=Math.min,d=a("startsWith");n({target:"String",proto:!0,forced:!!(c||d||(t=i(String.prototype,"startsWith"),!t||t.writable))&&!d},{startsWith:function(t){var n=s(u(this));o(t);var r=e(h(arguments.length>1?arguments[1]:void 0,n.length)),i=s(t);return f(n,r,r+i.length)===i}})}();var Qc,Yc,Zc,tf,nf,rf,ef,sf,of,uf,af,cf,ff,hf,df,vf,lf,gf=function(){function t(t){this.baseUrl=t.baseUrl.replace(/\/$/,"")}return t.prototype.request=function(t){return Be(this,arguments,void 0,function(t,n){var r,i,e,s,o,u,a,c,f,h,d;return void 0===n&&(n={}),Ge(this,function(v){switch(v.label){case 0:r=n.method,i=void 0===r?"GET":r,e=n.headers,s=void 0===e?{}:e,o=n.body,u=!t||t.startsWith("/")?t:"/".concat(t),a="".concat(this.baseUrl).concat(u),v.label=1;case 1:return v.trys.push([1,6,,7]),c={method:i,headers:Le({"Content-Type":"application/json"},s),body:o?JSON.stringify(o):null},[4,fetch(a,c)];case 2:return(f=v.sent()).ok?[3,4]:[4,f.text()];case 3:throw h=v.sent(),new Error("HTTP ".concat(f.status,": ").concat(f.statusText," - ").concat(h));case 4:return[4,f.json()];case 5:return[2,v.sent()];case 6:throw d=v.sent(),this.handleError(d);case 7:return[2]}})})},t.prototype.handleError=function(t){return t instanceof Error?"AbortError"===t.name?{code:gs,message:"Request timeout",details:t}:t.message.includes("HTTP 401")||t.message.includes("HTTP 403")?{code:ls,message:"Authentication failed",details:t}:(t.message.includes("HTTP"),{code:gs,message:t.message,details:t}):{code:gs,message:"Unknown error: ".concat(String(t)),details:t}},t.prototype.get=function(t){return Be(this,arguments,void 0,function(t,n){return void 0===n&&(n={}),Ge(this,function(r){return[2,this.request(t,Le(Le({},n),{method:"GET"}))]})})},t.prototype.post=function(t,n){return Be(this,arguments,void 0,function(t,n,r){return void 0===r&&(r={}),Ge(this,function(i){return[2,this.request(t,Le(Le({},r),{method:"POST",body:n}))]})})},t.prototype.put=function(t,n){return Be(this,arguments,void 0,function(t,n,r){return void 0===r&&(r={}),Ge(this,function(i){return[2,this.request(t,Le(Le({},r),{method:"PUT",body:n}))]})})},t.prototype.delete=function(t){return Be(this,arguments,void 0,function(t,n){return void 0===n&&(n={}),Ge(this,function(r){return[2,this.request(t,Le(Le({},n),{method:"DELETE"}))]})})},t}(),wf={};function mf(){return Yc?Qc:(Yc=1,Qc=Object.is||function(t,n){return t===n?0!==t||1/t==1/n:t!=t&&n!=n})}function pf(){if(ef)return rf;ef=1;var t=_n(),n=jt(),r=An(),i=dr(),e=function(){if(nf)return tf;nf=1;var t=j();return tf=!t(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})}(),s=i("IE_PROTO"),o=Object,u=o.prototype;return rf=e?o.getPrototypeOf:function(i){var e=r(i);if(t(e,s))return e[s];var a=e.constructor;return n(a)&&e instanceof a?a.prototype:e instanceof o?u:null}}function yf(){if(of)return sf;of=1;var t,n,r,i=j(),e=jt(),s=zt(),o=$i(),u=pf(),a=wr(),c=On(),f=Sn(),h=c("iterator"),d=!1;return[].keys&&("next"in(r=[].keys())?(n=u(u(r)))!==Object.prototype&&(t=n):d=!0),!s(t)||i(function(){var n={};return t[h].call(n)!==n})?t={}:f&&(t=o(t)),e(t[h])||a(t,h,function(){return this}),sf={IteratorPrototype:t,BUGGY_SAFARI_ITERATORS:d}}function bf(){if(af)return uf;af=1;var t=yf().IteratorPrototype,n=$i(),r=Dt(),i=Hu(),e=Fa(),s=function(){return this};return uf=function(o,u,a,c){var f=u+" Iterator";return o.prototype=n(t,{next:r(+!c,a)}),i(o,f,!1,!0),e[f]=s,o}}function Ef(){if(ff)return cf;ff=1;var t=Ti(),n=L(),r=Sn(),i=fr(),e=jt(),s=bf(),o=pf(),u=Ku(),a=Hu(),c=Hn(),f=wr(),h=On(),d=Fa(),v=yf(),l=i.PROPER,g=i.CONFIGURABLE,w=v.IteratorPrototype,m=v.BUGGY_SAFARI_ITERATORS,p=h("iterator"),y="keys",b="values",E="entries",I=function(){return this};return cf=function(i,h,v,S,T,k,R){s(v,h,S);var A,_,C,O=function(t){if(t===T&&M)return M;if(!m&&t&&t in N)return N[t];switch(t){case y:case b:case E:return function(){return new v(this,t)}}return function(){return new v(this)}},D=h+" Iterator",F=!1,N=i.prototype,x=N[p]||N["@@iterator"]||T&&N[T],M=!m&&x||O(T),P="Array"===h&&N.entries||x;if(P&&(A=o(P.call(new i)))!==Object.prototype&&A.next&&(r||o(A)===w||(u?u(A,w):e(A[p])||f(A,p,I)),a(A,D,!0,!0),r&&(d[D]=I)),l&&T===b&&x&&x.name!==b&&(!r&&g?c(N,"name",b):(F=!0,M=function(){return n(x,this)})),T)if(_={values:O(b),keys:k?M:O(y),entries:O(E)},R)for(C in _)(m||F||!(C in N))&&f(N,C,_[C]);else t({target:h,proto:!0,forced:m||F},_);return r&&!R||N[p]===M||f(N,p,M,{name:T}),d[h]=M,_},cf}function If(){return df?hf:(df=1,hf=function(t,n){return{value:t,done:n}})}function Sf(){if(lf)return vf;lf=1;var t=Ut(),n=Ji(),r=Fa(),i=lr(),e=Kn().f,s=Ef(),o=If(),u=Sn(),a=z(),c="Array Iterator",f=i.set,h=i.getterFor(c);vf=s(Array,"Array",function(n,r){f(this,{type:c,target:t(n),index:0,kind:r})},function(){var t=h(this),n=t.target,r=t.index++;if(!n||r>=n.length)return t.target=null,o(void 0,!0);switch(t.kind){case"keys":return o(r,!1);case"values":return o(n[r],!1)}return o([r,n[r]],!1)},"values");var d=r.Arguments=r.Array;if(n("keys"),n("values"),n("entries"),!u&&a&&"values"!==d.name)try{e(d,"name",{value:"values"})}catch(t){}return vf}!function(){if(Zc)return wf;Zc=1;var t=L(),n=Gc(),r=qn(),i=zt(),e=Pt(),s=mf(),o=pe(),u=$t(),a=Xc();n("search",function(n,c,f){return[function(r){var s=e(this),a=i(r)?u(r,n):void 0;return a?t(a,r,s):new RegExp(r)[n](o(s))},function(t){var n=r(this),i=o(t),e=f(c,n,i);if(e.done)return e.value;var u=n.lastIndex;s(u,0)||(n.lastIndex=0);var h=a(n,i);return s(n.lastIndex,u)||(n.lastIndex=u),null===h?-1:h.index}]})}(),Sf();var Tf,kf,Rf,Af,_f,Cf={};function Of(){if(kf)return Tf;kf=1;var t=jt(),n=zt(),r=Ku();return Tf=function(i,e,s){var o,u;return r&&t(o=e.constructor)&&o!==s&&n(u=o.prototype)&&u!==s.prototype&&r(i,u),i}}function Df(){if(Af)return Rf;Af=1;var t=Kn().f;return Rf=function(n,r,i){i in n||t(n,i,{configurable:!0,get:function(){return r[i]},set:function(t){r[i]=t}})}}!function(){if(_f)return Cf;_f=1;var t=z(),n=_(),r=Ft(),i=Si(),e=Of(),s=Hn(),o=$i(),u=Br().f,a=Lt(),c=Tc(),f=pe(),h=Hc(),d=hc(),v=Df(),l=wr(),g=j(),w=_n(),m=lr().enforce,p=Xu(),y=On(),b=dc(),E=vc(),I=y("match"),S=n.RegExp,T=S.prototype,k=n.SyntaxError,R=r(T.exec),A=r("".charAt),C=r("".replace),O=r("".indexOf),D=r("".slice),F=/^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/,N=/a/g,x=/a/g,M=new S(N)!==N,P=d.MISSED_STICKY,U=d.UNSUPPORTED_Y,V=t&&(!M||P||b||E||g(function(){return x[I]=!1,S(N)!==N||S(x)===x||"/a/i"!==String(S(N,"i"))}));if(i("RegExp",V)){for(var L=function(t,n){var r,i,u,d,v,l,g=a(T,this),p=c(t),y=void 0===n,I=[],_=t;if(!g&&p&&y&&t.constructor===L)return t;if((p||a(T,t))&&(t=t.source,y&&(n=h(_))),t=void 0===t?"":f(t),n=void 0===n?"":f(n),_=t,b&&"dotAll"in N&&(i=!!n&&O(n,"s")>-1)&&(n=C(n,/s/g,"")),r=n,P&&"sticky"in N&&(u=!!n&&O(n,"y")>-1)&&U&&(n=C(n,/y/g,"")),E&&(d=function(t){for(var n,r=t.length,i=0,e="",s=[],u=o(null),a=!1,c=!1,f=0,h="";i<r;i++){if("\\"===(n=A(t,i)))n+=A(t,++i);else if("]"===n)a=!1;else if(!a)switch(!0){case"["===n:a=!0;break;case"("===n:if(e+=n,"?:"===D(t,i+1,i+3))continue;R(F,D(t,i+1))&&(i+=2,c=!0),f++;continue;case">"===n&&c:if(""===h||w(u,h))throw new k("Invalid capture group name");u[h]=!0,s[s.length]=[h,f],c=!1,h="";continue}c?h+=n:e+=n}return[e,s]}(t),t=d[0],I=d[1]),v=e(S(t,n),g?this:T,L),(i||u||I.length)&&(l=m(v),i&&(l.dotAll=!0,l.raw=L(function(t){for(var n,r=t.length,i=0,e="",s=!1;i<r;i++)"\\"!==(n=A(t,i))?s||"."!==n?("["===n?s=!0:"]"===n&&(s=!1),e+=n):e+="[\\s\\S]":e+=n+A(t,++i);return e}(t),r)),u&&(l.sticky=!0),I.length&&(l.groups=I)),t!==_)try{s(v,"source",""===_?"(?:)":_)}catch(t){}return v},B=u(S),G=0;B.length>G;)v(L,S,B[G++]);T.constructor=L,L.prototype=T,l(n,"RegExp",L,{constructor:!0})}p("RegExp")}();var Ff,Nf={};!function(){if(Ff)return Nf;Ff=1;var t=fr().PROPER,n=wr(),r=qn(),i=pe(),e=j(),s=Hc(),o="toString",u=RegExp.prototype,a=u[o],c=e(function(){return"/a/b"!==a.call({source:"a",flags:"b"})}),f=t&&a.name!==o;(c||f)&&n(u,o,function(){var t=r(this);return"/"+i(t.source)+"/"+i(s(t))},{unsafe:!0})}();var xf,Mf={};function Pf(){if(xf)return Mf;xf=1;var t=Wc().charAt,n=pe(),r=lr(),i=Ef(),e=If(),s="String Iterator",o=r.set,u=r.getterFor(s);return i(String,"String",function(t){o(this,{type:s,string:n(t),index:0})},function(){var n,r=u(this),i=r.string,s=r.index;return s>=i.length?e(void 0,!0):(n=t(i,s),r.index+=n.length,e(n,!1))}),Mf}Pf();var Uf,jf={};!function(){if(Uf)return jf;Uf=1;var t=L(),n=Ft(),r=Gc(),i=qn(),e=zt(),s=Ur(),o=pe(),u=Pt(),a=$t(),c=qc(),f=Hc(),h=Xc(),d=n("".indexOf);r("match",function(n,r,v){return[function(r){var i=u(this),s=e(r)?a(r,n):void 0;return s?t(s,r,i):new RegExp(r)[n](o(i))},function(t){var n=i(this),e=o(t),u=v(r,n,e);if(u.done)return u.value;var a=o(f(n));if(-1===d(a,"g"))return h(n,e);var l=-1!==d(a,"u");n.lastIndex=0;for(var g,w=[],m=0;null!==(g=h(n,e));){var p=o(g[0]);w[m]=p,""===p&&(n.lastIndex=c(e,s(n.lastIndex),l)),m++}return 0===m?null:w}]})}();var zf,Vf={};!function(){if(zf)return Vf;zf=1;var t=_(),n=Me(),r=Pe(),i=Sf(),e=Hn(),s=Hu(),o=On()("iterator"),u=i.values,a=function(t,r){if(t){if(t[o]!==u)try{e(t,o,u)}catch(n){t[o]=u}if(s(t,r,!0),n[r])for(var a in i)if(t[a]!==i[a])try{e(t,a,i[a])}catch(n){t[a]=i[a]}}};for(var c in n)a(t[c]&&t[c].prototype,c);a(r,"DOMTokenList")}();var Lf,Bf,Gf,Wf,qf,Kf,Hf,Xf,$f,Jf,Qf={};function Yf(){if(Bf)return Lf;Bf=1;var t=j(),n=On(),r=z(),i=Sn(),e=n("iterator");return Lf=!t(function(){var t=new URL("b?a=1&b=2&c=3","https://a"),n=t.searchParams,s=new URLSearchParams("a=1&a=2&b=3"),o="";return t.pathname="c%20d",n.forEach(function(t,r){n.delete("b"),o+=r+t}),s.delete("a",2),s.delete("b",void 0),i&&(!t.toJSON||!s.has("a",1)||s.has("a",2)||!s.has("a",void 0)||s.has("b"))||!n.size&&(i||!r)||!n.sort||"https://a/c%20d?a=1&c=3"!==t.href||"3"!==n.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!n[e]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("https://тест").host||"#%D0%B1"!==new URL("https://a#б").hash||"a1c3"!==o||"x"!==new URL("https://x",void 0).host})}function Zf(){if(Kf)return qf;Kf=1;var t=qn(),n=Pa();return qf=function(r,i,e,s){try{return s?i(t(e)[0],e[1]):i(e)}catch(t){n(r,"throw",t)}}}function th(){if(Xf)return Hf;Xf=1;var t=je(),n=L(),r=An(),i=Zf(),e=Na(),s=Di(),o=jr(),u=Ai(),a=_i(),c=Ma(),f=xa(),h=Array;return Hf=function(d){var v=r(d),l=s(this),g=arguments.length,w=g>1?arguments[1]:void 0,m=void 0!==w;m&&(w=t(w,g>2?arguments[2]:void 0));var p,y,b,E,I,S,T=f(v),k=0;if(!T||this===h&&e(T))for(p=o(v),y=l?new this(p):h(p);p>k;k++)S=m?w(v[k],k):v[k],u(y,k,S);else for(y=l?new this:[],I=(E=c(v,T)).next;!(b=n(I,E)).done;k++)S=m?i(E,w,[b.value,k],!0):b.value,u(y,k,S);return a(y,k),y},Hf}function nh(){if(Jf)return $f;Jf=1;var t=Ft(),n=2147483647,r=/[^\0-\u007E]/,i=/[.\u3002\uFF0E\uFF61]/g,e="Overflow: input needs wider integers to process",s=RangeError,o=t(i.exec),u=Math.floor,a=String.fromCharCode,c=t("".charCodeAt),f=t([].join),h=t([].push),d=t("".replace),v=t("".split),l=t("".toLowerCase),g=function(t){return t+22+75*(t<26)},w=function(t,n,r){var i=0;for(t=r?u(t/700):t>>1,t+=u(t/n);t>455;)t=u(t/35),i+=36;return u(i+36*t/(t+38))},m=function(t){var r=[];t=function(t){for(var n=[],r=0,i=t.length;r<i;){var e=c(t,r++);if(e>=55296&&e<=56319&&r<i){var s=c(t,r++);56320==(64512&s)?h(n,((1023&e)<<10)+(1023&s)+65536):(h(n,e),r--)}else h(n,e)}return n}(t);var i,o,d=t.length,v=128,l=0,m=72;for(i=0;i<t.length;i++)(o=t[i])<128&&h(r,a(o));var p=r.length,y=p;for(p&&h(r,"-");y<d;){var b=n;for(i=0;i<t.length;i++)(o=t[i])>=v&&o<b&&(b=o);var E=y+1;if(b-v>u((n-l)/E))throw new s(e);for(l+=(b-v)*E,v=b,i=0;i<t.length;i++){if((o=t[i])<v&&++l>n)throw new s(e);if(o===v){for(var I=l,S=36;;){var T=S<=m?1:S>=m+26?26:S-m;if(I<T)break;var k=I-T,R=36-T;h(r,a(g(T+k%R))),I=u(k/R),S+=36}h(r,a(g(I))),m=w(l,E,y===p),l=0,y++}}l++,v++}return f(r,"")};return $f=function(t){var n,e,s=[],u=v(d(l(t),i,"."),".");for(n=0;n<u.length;n++)e=u[n],h(s,o(r,e)?"xn--"+m(e):e);return f(s,".")}}var rh,ih,eh,sh,oh,uh,ah,ch,fh,hh={};function dh(){if(eh)return ih;eh=1;var t=wr();return ih=function(n,r,i){for(var e in r)t(n,e,r[e],i);return n}}function vh(){if(oh)return sh;oh=1;var t=Zu(),n=Math.floor,r=function(i,e){var s=i.length;if(s<8)for(var o,u,a=1;a<s;){for(u=a,o=i[a];u&&e(i[u-1],o)>0;)i[u]=i[--u];u!==a++&&(i[u]=o)}else for(var c=n(s/2),f=r(t(i,0,c),e),h=r(t(i,c),e),d=f.length,v=h.length,l=0,g=0;l<d||g<v;)i[l+g]=l<d&&g<v?e(f[l],h[g])<=0?f[l++]:h[g++]:l<d?f[l++]:h[g++];return i};return sh=r}function lh(){if(ah)return uh;ah=1,Sf(),function(){if(rh)return hh;rh=1;var t=Ti(),n=Ft(),r=Pr(),i=RangeError,e=String.fromCharCode,s=String.fromCodePoint,o=n([].join);t({target:"String",stat:!0,arity:1,forced:!!s&&1!==s.length},{fromCodePoint:function(t){for(var n,s=[],u=arguments.length,a=0;u>a;){if(n=+arguments[a++],r(n,1114111)!==n)throw new i(n+" is not a valid code point");s[a]=n<65536?e(n):e(55296+((n-=65536)>>10),n%1024+56320)}return o(s,"")}})}();var t=Ti(),n=_(),r=ia(),i=Vt(),e=L(),s=Ft(),o=z(),u=Yf(),a=wr(),c=Lo(),f=dh(),h=Hu(),d=bf(),v=lr(),l=$u(),g=jt(),w=_n(),m=je(),p=Oi(),y=qn(),b=zt(),E=pe(),I=$i(),S=Dt(),T=Ma(),k=xa(),R=If(),A=ta(),C=On(),O=vh(),D=C("iterator"),F="URLSearchParams",N=F+"Iterator",x=v.set,M=v.getterFor(F),P=v.getterFor(N),U=r("fetch"),j=r("Request"),V=r("Headers"),B=j&&j.prototype,G=V&&V.prototype,W=n.TypeError,q=n.encodeURIComponent,K=String.fromCharCode,H=i("String","fromCodePoint"),X=parseInt,$=s("".charAt),J=s([].join),Q=s([].push),Y=s("".replace),Z=s([].shift),tt=s([].splice),nt=s("".split),rt=s("".slice),it=s(/./.exec),et=/\+/g,st=/^[0-9a-f]+$/i,ot=function(t,n){var r=rt(t,n,n+2);return it(st,r)?X(r,16):NaN},ut=function(t){for(var n=0,r=128;r>0&&0!==(t&r);r>>=1)n++;return n},at=function(t){var n=null;switch(t.length){case 1:n=t[0];break;case 2:n=(31&t[0])<<6|63&t[1];break;case 3:n=(15&t[0])<<12|(63&t[1])<<6|63&t[2];break;case 4:n=(7&t[0])<<18|(63&t[1])<<12|(63&t[2])<<6|63&t[3]}return n>1114111?null:n},ct=function(t){for(var n=(t=Y(t,et," ")).length,r="",i=0;i<n;){var e=$(t,i);if("%"===e){if("%"===$(t,i+1)||i+3>n){r+="%",i++;continue}var s=ot(t,i+1);if(s!=s){r+=e,i++;continue}i+=2;var o=ut(s);if(0===o)e=K(s);else{if(1===o||o>4){r+="�",i++;continue}for(var u=[s],a=1;a<o&&!(++i+3>n||"%"!==$(t,i));){var c=ot(t,i+1);if(c!=c){i+=3;break}if(c>191||c<128)break;Q(u,c),i+=2,a++}if(u.length!==o){r+="�";continue}var f=at(u);null===f?r+="�":e=H(f)}}r+=e,i++}return r},ft=/[!'()~]|%20/g,ht={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},dt=function(t){return ht[t]},vt=function(t){return Y(q(t),ft,dt)},lt=d(function(t,n){x(this,{type:N,target:M(t).entries,index:0,kind:n})},F,function(){var t=P(this),n=t.target,r=t.index++;if(!n||r>=n.length)return t.target=null,R(void 0,!0);var i=n[r];switch(t.kind){case"keys":return R(i.key,!1);case"values":return R(i.value,!1)}return R([i.key,i.value],!1)},!0),gt=function(t){this.entries=[],this.url=null,void 0!==t&&(b(t)?this.parseObject(t):this.parseQuery("string"==typeof t?"?"===$(t,0)?rt(t,1):t:E(t)))};gt.prototype={type:F,bindURL:function(t){this.url=t,this.update()},parseObject:function(t){var n,r,i,s,o,u,a,c=this.entries,f=k(t);if(f)for(r=(n=T(t,f)).next;!(i=e(r,n)).done;){if(o=(s=T(y(i.value))).next,(u=e(o,s)).done||(a=e(o,s)).done||!e(o,s).done)throw new W("Expected sequence with length 2");Q(c,{key:E(u.value),value:E(a.value)})}else for(var h in t)w(t,h)&&Q(c,{key:h,value:E(t[h])})},parseQuery:function(t){if(t)for(var n,r,i=this.entries,e=nt(t,"&"),s=0;s<e.length;)(n=e[s++]).length&&(r=nt(n,"="),Q(i,{key:ct(Z(r)),value:ct(J(r,"="))}))},serialize:function(){for(var t,n=this.entries,r=[],i=0;i<n.length;)t=n[i++],Q(r,vt(t.key)+"="+vt(t.value));return J(r,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var wt=function(){l(this,mt);var t=x(this,new gt(arguments.length>0?arguments[0]:void 0));o||(this.size=t.entries.length)},mt=wt.prototype;if(f(mt,{append:function(t,n){var r=M(this);A(arguments.length,2),Q(r.entries,{key:E(t),value:E(n)}),o||this.size++,r.updateURL()},delete:function(t){for(var n=M(this),r=A(arguments.length,1),i=n.entries,e=E(t),s=r<2?void 0:arguments[1],u=void 0===s?s:E(s),a=0;a<i.length;){var c=i[a];if(c.key!==e||void 0!==u&&c.value!==u)a++;else if(tt(i,a,1),void 0!==u)break}o||(this.size=i.length),n.updateURL()},get:function(t){var n=M(this).entries;A(arguments.length,1);for(var r=E(t),i=0;i<n.length;i++)if(n[i].key===r)return n[i].value;return null},getAll:function(t){var n=M(this).entries;A(arguments.length,1);for(var r=E(t),i=[],e=0;e<n.length;e++)n[e].key===r&&Q(i,n[e].value);return i},has:function(t){for(var n=M(this).entries,r=A(arguments.length,1),i=E(t),e=r<2?void 0:arguments[1],s=void 0===e?e:E(e),o=0;o<n.length;){var u=n[o++];if(u.key===i&&(void 0===s||u.value===s))return!0}return!1},set:function(t,n){var r=M(this);A(arguments.length,1);for(var i,e=r.entries,s=!1,u=E(t),a=E(n),c=0;c<e.length;c++)(i=e[c]).key===u&&(s?tt(e,c--,1):(s=!0,i.value=a));s||Q(e,{key:u,value:a}),o||(this.size=e.length),r.updateURL()},sort:function(){var t=M(this);O(t.entries,function(t,n){return t.key>n.key?1:-1}),t.updateURL()},forEach:function(t){for(var n,r=M(this).entries,i=m(t,arguments.length>1?arguments[1]:void 0),e=0;e<r.length;)i((n=r[e++]).value,n.key,this)},keys:function(){return new lt(this,"keys")},values:function(){return new lt(this,"values")},entries:function(){return new lt(this,"entries")}},{enumerable:!0}),a(mt,D,mt.entries,{name:"entries"}),a(mt,"toString",function(){return M(this).serialize()},{enumerable:!0}),o&&c(mt,"size",{get:function(){return M(this).entries.length},configurable:!0,enumerable:!0}),h(wt,F),t({global:!0,constructor:!0,forced:!u},{URLSearchParams:wt}),!u&&g(V)){var pt=s(G.has),yt=s(G.set),bt=function(t){if(b(t)){var n,r=t.body;if(p(r)===F)return n=t.headers?new V(t.headers):new V,pt(n,"content-type")||yt(n,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),I(t,{body:S(0,E(r)),headers:S(0,n)})}return t};if(g(U)&&t({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(t){return U(t,arguments.length>1?bt(arguments[1]):{})}}),g(j)){var Et=function(t){return l(this,B),new j(t,arguments.length>1?bt(arguments[1]):{})};B.constructor=Et,Et.prototype=B,t({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Et})}}return uh={URLSearchParams:wt,getState:M}}function gh(){if(ch)return Qf;ch=1,Pf();var t,n=Ti(),r=z(),i=Yf(),e=_(),s=je(),o=Ft(),u=wr(),a=Lo(),c=$u(),f=_n(),h=function(){if(Wf)return Gf;Wf=1;var t=z(),n=Ft(),r=L(),i=j(),e=Hi(),s=bi(),o=Ot(),u=An(),a=xt(),c=Object.assign,f=Object.defineProperty,h=n([].concat);return Gf=!c||i(function(){if(t&&1!==c({b:1},c(f({},"a",{enumerable:!0,get:function(){f(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var n={},r={},i=Symbol("assign detection"),s="abcdefghijklmnopqrst";return n[i]=7,s.split("").forEach(function(t){r[t]=t}),7!==c({},n)[i]||e(c({},r)).join("")!==s})?function(n,i){for(var c=u(n),f=arguments.length,d=1,v=s.f,l=o.f;f>d;)for(var g,w=a(arguments[d++]),m=v?h(e(w),v(w)):e(w),p=m.length,y=0;p>y;)g=m[y++],t&&!r(l,w,g)||(c[g]=w[g]);return c}:c,Gf}(),d=th(),v=Zu(),l=Wc().codeAt,g=nh(),w=pe(),m=Hu(),p=ta(),y=lh(),b=lr(),E=b.set,I=b.getterFor("URL"),S=y.URLSearchParams,T=y.getState,k=e.URL,R=e.TypeError,A=e.parseInt,C=Math.floor,O=Math.pow,D=o("".charAt),F=o(/./.exec),N=o([].join),x=o(1.1.toString),M=o([].pop),P=o([].push),U=o("".replace),V=o([].shift),B=o("".split),G=o("".slice),W=o("".toLowerCase),q=o([].unshift),K="Invalid scheme",H="Invalid host",X="Invalid port",$=/[a-z]/i,J=/[\d+-.a-z]/i,Q=/\d/,Y=/^0x/i,Z=/^[0-7]+$/,tt=/^\d+$/,nt=/^[\da-f]+$/i,rt=/[\0\t\n\r #%/:<>?@[\\\]^|]/,it=/[\0\t\n\r #/:<>?@[\\\]^|]/,et=/^[\u0000-\u0020]+/,st=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ot=/[\t\n\r]/g,ut=function(t){var n,r,i,e;if("number"==typeof t){for(n=[],r=0;r<4;r++)q(n,t%256),t=C(t/256);return N(n,".")}if("object"==typeof t){for(n="",i=function(t){for(var n=null,r=1,i=null,e=0,s=0;s<8;s++)0!==t[s]?(e>r&&(n=i,r=e),i=null,e=0):(null===i&&(i=s),++e);return e>r?i:n}(t),r=0;r<8;r++)e&&0===t[r]||(e&&(e=!1),i===r?(n+=r?":":"::",e=!0):(n+=x(t[r],16),r<7&&(n+=":")));return"["+n+"]"}return t},at={},ct=h({},at,{" ":1,'"':1,"<":1,">":1,"`":1}),ft=h({},ct,{"#":1,"?":1,"{":1,"}":1}),ht=h({},ft,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),dt=function(t,n){var r=l(t,0);return r>32&&r<127&&!f(n,t)?t:encodeURIComponent(t)},vt={ftp:21,file:null,http:80,https:443,ws:80,wss:443},lt=function(t,n){var r;return 2===t.length&&F($,D(t,0))&&(":"===(r=D(t,1))||!n&&"|"===r)},gt=function(t){var n;return t.length>1&&lt(G(t,0,2))&&(2===t.length||"/"===(n=D(t,2))||"\\"===n||"?"===n||"#"===n)},wt=function(t){return"."===t||"%2e"===W(t)},mt=function(t){return".."===(t=W(t))||"%2e."===t||".%2e"===t||"%2e%2e"===t},pt={},yt={},bt={},Et={},It={},St={},Tt={},kt={},Rt={},At={},_t={},Ct={},Dt={},Nt={},Mt={},Pt={},Ut={},jt={},zt={},Vt={},Lt={},Bt=function(t,n,r){var i,e,s,o=w(t);if(n){if(e=this.parse(o))throw new R(e);this.searchParams=null}else{if(void 0!==r&&(i=new Bt(r,!0)),e=this.parse(o,null,i))throw new R(e);(s=T(new S)).bindURL(this),this.searchParams=s}};Bt.prototype={type:"URL",parse:function(n,r,i){var e,s,o,u,a=this,c=r||pt,h=0,l="",g=!1,m=!1,p=!1;for(n=w(n),r||(a.scheme="",a.username="",a.password="",a.host=null,a.port=null,a.path=[],a.query=null,a.fragment=null,a.cannotBeABaseURL=!1,n=U(n,et,""),n=U(n,st,"$1")),n=U(n,ot,""),e=d(n);h<=e.length;){switch(s=e[h],c){case pt:if(!s||!F($,s)){if(r)return K;c=bt;continue}l+=W(s),c=yt;break;case yt:if(s&&(F(J,s)||"+"===s||"-"===s||"."===s))l+=W(s);else{if(":"!==s){if(r)return K;l="",c=bt,h=0;continue}if(r&&(a.isSpecial()!==f(vt,l)||"file"===l&&(a.includesCredentials()||null!==a.port)||"file"===a.scheme&&!a.host))return;if(a.scheme=l,r)return void(a.isSpecial()&&vt[a.scheme]===a.port&&(a.port=null));l="","file"===a.scheme?c=Nt:a.isSpecial()&&i&&i.scheme===a.scheme?c=Et:a.isSpecial()?c=kt:"/"===e[h+1]?(c=It,h++):(a.cannotBeABaseURL=!0,P(a.path,""),c=zt)}break;case bt:if(!i||i.cannotBeABaseURL&&"#"!==s)return K;if(i.cannotBeABaseURL&&"#"===s){a.scheme=i.scheme,a.path=v(i.path),a.query=i.query,a.fragment="",a.cannotBeABaseURL=!0,c=Lt;break}c="file"===i.scheme?Nt:St;continue;case Et:if("/"!==s||"/"!==e[h+1]){c=St;continue}c=Rt,h++;break;case It:if("/"===s){c=At;break}c=jt;continue;case St:if(a.scheme=i.scheme,s===t)a.username=i.username,a.password=i.password,a.host=i.host,a.port=i.port,a.path=v(i.path),a.query=i.query;else if("/"===s||"\\"===s&&a.isSpecial())c=Tt;else if("?"===s)a.username=i.username,a.password=i.password,a.host=i.host,a.port=i.port,a.path=v(i.path),a.query="",c=Vt;else{if("#"!==s){a.username=i.username,a.password=i.password,a.host=i.host,a.port=i.port,a.path=v(i.path),a.path.length--,c=jt;continue}a.username=i.username,a.password=i.password,a.host=i.host,a.port=i.port,a.path=v(i.path),a.query=i.query,a.fragment="",c=Lt}break;case Tt:if(!a.isSpecial()||"/"!==s&&"\\"!==s){if("/"!==s){a.username=i.username,a.password=i.password,a.host=i.host,a.port=i.port,c=jt;continue}c=At}else c=Rt;break;case kt:if(c=Rt,"/"!==s||"/"!==D(l,h+1))continue;h++;break;case Rt:if("/"!==s&&"\\"!==s){c=At;continue}break;case At:if("@"===s){g&&(l="%40"+l),g=!0,o=d(l);for(var y=0;y<o.length;y++){var b=o[y];if(":"!==b||p){var E=dt(b,ht);p?a.password+=E:a.username+=E}else p=!0}l=""}else if(s===t||"/"===s||"?"===s||"#"===s||"\\"===s&&a.isSpecial()){if(g&&""===l)return"Invalid authority";h-=d(l).length+1,l="",c=_t}else l+=s;break;case _t:case Ct:if(r&&"file"===a.scheme){c=Pt;continue}if(":"!==s||m){if(s===t||"/"===s||"?"===s||"#"===s||"\\"===s&&a.isSpecial()){if(a.isSpecial()&&""===l)return H;if(r&&""===l&&(a.includesCredentials()||null!==a.port))return;if(u=a.parseHost(l))return u;if(l="",c=Ut,r)return;continue}"["===s?m=!0:"]"===s&&(m=!1),l+=s}else{if(""===l)return H;if(u=a.parseHost(l))return u;if(l="",c=Dt,r===Ct)return}break;case Dt:if(!F(Q,s)){if(s===t||"/"===s||"?"===s||"#"===s||"\\"===s&&a.isSpecial()||r){if(""!==l){var I=A(l,10);if(I>65535)return X;a.port=a.isSpecial()&&I===vt[a.scheme]?null:I,l=""}if(r)return;c=Ut;continue}return X}l+=s;break;case Nt:if(a.scheme="file","/"===s||"\\"===s)c=Mt;else{if(!i||"file"!==i.scheme){c=jt;continue}switch(s){case t:a.host=i.host,a.path=v(i.path),a.query=i.query;break;case"?":a.host=i.host,a.path=v(i.path),a.query="",c=Vt;break;case"#":a.host=i.host,a.path=v(i.path),a.query=i.query,a.fragment="",c=Lt;break;default:gt(N(v(e,h),""))||(a.host=i.host,a.path=v(i.path),a.shortenPath()),c=jt;continue}}break;case Mt:if("/"===s||"\\"===s){c=Pt;break}i&&"file"===i.scheme&&!gt(N(v(e,h),""))&&(lt(i.path[0],!0)?P(a.path,i.path[0]):a.host=i.host),c=jt;continue;case Pt:if(s===t||"/"===s||"\\"===s||"?"===s||"#"===s){if(!r&&lt(l))c=jt;else if(""===l){if(a.host="",r)return;c=Ut}else{if(u=a.parseHost(l))return u;if("localhost"===a.host&&(a.host=""),r)return;l="",c=Ut}continue}l+=s;break;case Ut:if(a.isSpecial()){if(c=jt,"/"!==s&&"\\"!==s)continue}else if(r||"?"!==s)if(r||"#"!==s){if(s!==t&&(c=jt,"/"!==s))continue}else a.fragment="",c=Lt;else a.query="",c=Vt;break;case jt:if(s===t||"/"===s||"\\"===s&&a.isSpecial()||!r&&("?"===s||"#"===s)){if(mt(l)?(a.shortenPath(),"/"===s||"\\"===s&&a.isSpecial()||P(a.path,"")):wt(l)?"/"===s||"\\"===s&&a.isSpecial()||P(a.path,""):("file"===a.scheme&&!a.path.length&&lt(l)&&(a.host&&(a.host=""),l=D(l,0)+":"),P(a.path,l)),l="","file"===a.scheme&&(s===t||"?"===s||"#"===s))for(;a.path.length>1&&""===a.path[0];)V(a.path);"?"===s?(a.query="",c=Vt):"#"===s&&(a.fragment="",c=Lt)}else l+=dt(s,ft);break;case zt:"?"===s?(a.query="",c=Vt):"#"===s?(a.fragment="",c=Lt):s!==t&&(a.path[0]+=dt(s,at));break;case Vt:r||"#"!==s?s!==t&&("'"===s&&a.isSpecial()?a.query+="%27":a.query+="#"===s?"%23":dt(s,at)):(a.fragment="",c=Lt);break;case Lt:s!==t&&(a.fragment+=dt(s,ct))}h++}},parseHost:function(t){var n,r,i;if("["===D(t,0)){if("]"!==D(t,t.length-1))return H;if(n=function(t){var n,r,i,e,s,o,u,a=[0,0,0,0,0,0,0,0],c=0,f=null,h=0,d=function(){return D(t,h)};if(":"===d()){if(":"!==D(t,1))return;h+=2,f=++c}for(;d();){if(8===c)return;if(":"!==d()){for(n=r=0;r<4&&F(nt,d());)n=16*n+A(d(),16),h++,r++;if("."===d()){if(0===r)return;if(h-=r,c>6)return;for(i=0;d();){if(e=null,i>0){if(!("."===d()&&i<4))return;h++}if(!F(Q,d()))return;for(;F(Q,d());){if(s=A(d(),10),null===e)e=s;else{if(0===e)return;e=10*e+s}if(e>255)return;h++}a[c]=256*a[c]+e,2!==++i&&4!==i||c++}if(4!==i)return;break}if(":"===d()){if(h++,!d())return}else if(d())return;a[c++]=n}else{if(null!==f)return;h++,f=++c}}if(null!==f)for(o=c-f,c=7;0!==c&&o>0;)u=a[c],a[c--]=a[f+o-1],a[f+--o]=u;else if(8!==c)return;return a}(G(t,1,-1)),!n)return H;this.host=n}else if(this.isSpecial()){if(t=g(t),F(rt,t))return H;if(n=function(t){var n,r,i,e,s,o,u,a=B(t,".");if(a.length&&""===a[a.length-1]&&a.length--,(n=a.length)>4)return t;for(r=[],i=0;i<n;i++){if(""===(e=a[i]))return t;if(s=10,e.length>1&&"0"===D(e,0)&&(s=F(Y,e)?16:8,e=G(e,8===s?1:2)),""===e)o=0;else{if(!F(10===s?tt:8===s?Z:nt,e))return t;o=A(e,s)}P(r,o)}for(i=0;i<n;i++)if(o=r[i],i===n-1){if(o>=O(256,5-n))return null}else if(o>255)return null;for(u=M(r),i=0;i<r.length;i++)u+=r[i]*O(256,3-i);return u}(t),null===n)return H;this.host=n}else{if(F(it,t))return H;for(n="",r=d(t),i=0;i<r.length;i++)n+=dt(r[i],at);this.host=n}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return f(vt,this.scheme)},shortenPath:function(){var t=this.path,n=t.length;!n||"file"===this.scheme&&1===n&&lt(t[0],!0)||t.length--},serialize:function(){var t=this,n=t.scheme,r=t.username,i=t.password,e=t.host,s=t.port,o=t.path,u=t.query,a=t.fragment,c=n+":";return null!==e?(c+="//",t.includesCredentials()&&(c+=r+(i?":"+i:"")+"@"),c+=ut(e),null!==s&&(c+=":"+s)):"file"===n&&(c+="//"),c+=t.cannotBeABaseURL?o[0]:o.length?"/"+N(o,"/"):"",null!==u&&(c+="?"+u),null!==a&&(c+="#"+a),c},setHref:function(t){var n=this.parse(t);if(n)throw new R(n);this.searchParams.update()},getOrigin:function(){var t=this.scheme,n=this.port;if("blob"===t)try{return new Gt(t.path[0]).origin}catch(t){return"null"}return"file"!==t&&this.isSpecial()?t+"://"+ut(this.host)+(null!==n?":"+n:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(w(t)+":",pt)},getUsername:function(){return this.username},setUsername:function(t){var n=d(w(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<n.length;r++)this.username+=dt(n[r],ht)}},getPassword:function(){return this.password},setPassword:function(t){var n=d(w(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<n.length;r++)this.password+=dt(n[r],ht)}},getHost:function(){var t=this.host,n=this.port;return null===t?"":null===n?ut(t):ut(t)+":"+n},setHost:function(t){this.cannotBeABaseURL||this.parse(t,_t)},getHostname:function(){var t=this.host;return null===t?"":ut(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,Ct)},getPort:function(){var t=this.port;return null===t?"":w(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(""===(t=w(t))?this.port=null:this.parse(t,Dt))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+N(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,Ut))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){""===(t=w(t))?this.query=null:("?"===D(t,0)&&(t=G(t,1)),this.query="",this.parse(t,Vt)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){""!==(t=w(t))?("#"===D(t,0)&&(t=G(t,1)),this.fragment="",this.parse(t,Lt)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var Gt=function(t){var n=c(this,Wt),i=p(arguments.length,1)>1?arguments[1]:void 0,e=E(n,new Bt(t,!1,i));r||(n.href=e.serialize(),n.origin=e.getOrigin(),n.protocol=e.getProtocol(),n.username=e.getUsername(),n.password=e.getPassword(),n.host=e.getHost(),n.hostname=e.getHostname(),n.port=e.getPort(),n.pathname=e.getPathname(),n.search=e.getSearch(),n.searchParams=e.getSearchParams(),n.hash=e.getHash())},Wt=Gt.prototype,qt=function(t,n){return{get:function(){return I(this)[t]()},set:n&&function(t){return I(this)[n](t)},configurable:!0,enumerable:!0}};if(r&&(a(Wt,"href",qt("serialize","setHref")),a(Wt,"origin",qt("getOrigin")),a(Wt,"protocol",qt("getProtocol","setProtocol")),a(Wt,"username",qt("getUsername","setUsername")),a(Wt,"password",qt("getPassword","setPassword")),a(Wt,"host",qt("getHost","setHost")),a(Wt,"hostname",qt("getHostname","setHostname")),a(Wt,"port",qt("getPort","setPort")),a(Wt,"pathname",qt("getPathname","setPathname")),a(Wt,"search",qt("getSearch","setSearch")),a(Wt,"searchParams",qt("getSearchParams")),a(Wt,"hash",qt("getHash","setHash"))),u(Wt,"toJSON",function(){return I(this).serialize()},{enumerable:!0}),u(Wt,"toString",function(){return I(this).serialize()},{enumerable:!0}),k){var Kt=k.createObjectURL,Ht=k.revokeObjectURL;Kt&&u(Gt,"createObjectURL",s(Kt,k)),Ht&&u(Gt,"revokeObjectURL",s(Ht,k))}return m(Gt,"URL"),n({global:!0,constructor:!0,forced:!i,sham:!r},{URL:Gt}),Qf}fh||(fh=1,gh());var wh,mh={};!function(){if(wh)return mh;wh=1;var t=Ti(),n=L();t({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return n(URL.prototype.toString,this)}})}();var ph;function yh(t,n){var r;if("undefined"!=typeof URLSearchParams)return new URLSearchParams(t).get(n);var i=new RegExp("[?&]"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"=([^&#]*)"),e=t.match(i);return e?decodeURIComponent(null!==(r=e[1])&&void 0!==r?r:""):null}function bh(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return"UTC"}}function Eh(t){var n,r={campaignName:yh(n=window.location.search,"utm_campaign")||"",campaignSource:yh(n,"utm_source")||"",campaignMedium:yh(n,"utm_medium")||""};return{libraryName:"cap-hydra-web-sdk",libraryVersion:zo,locale:navigator.language||navigator.languages&&navigator.languages[0]||"en-US",userAgent:navigator.userAgent||"",timezone:bh(),ip:"",campaignName:r.campaignName,campaignSource:r.campaignSource,campaignMedium:r.campaignMedium,pageUrl:window.location.href||"",pagePath:window.location.pathname||"",pageReferrer:document.referrer||"",pageTitle:document.title||"",sessionId:t}}function Ih(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var n=16*Math.random()|0;return("x"===t?n:3&n|8).toString(16)})}ph||(ph=1,lh());var Sh,Th={};!function(){if(Sh)return Th;Sh=1;var t=Ti(),n=ze().map;t({target:"Array",proto:!0,forced:!xi()("map")},{map:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}})}();var kh,Rh={};!function(){if(kh)return Rh;kh=1;var t=Ti(),n=ki(),r=Di(),i=zt(),e=Pr(),s=jr(),o=Ut(),u=Ai(),a=_i(),c=On(),f=xi(),h=Zu(),d=f("slice"),v=c("species"),l=Array,g=Math.max;t({target:"Array",proto:!0,forced:!d},{slice:function(t,c){var f,d,w,m=o(this),p=s(m),y=e(t,p),b=e(void 0===c?p:c,p);if(n(m)&&(f=m.constructor,(r(f)&&(f===l||n(f.prototype))||i(f)&&null===(f=f[v]))&&(f=void 0),f===l||void 0===f))return h(m,y,b);for(d=new(void 0===f?l:f)(g(b-y,0)),w=0;y<b;y++,w++)y in m&&u(d,w,m[y]);return a(d,w),d}})}();var Ah,_h,Ch,Oh,Dh,Fh,Nh,xh,Mh,Ph={};function Uh(){if(_h)return Ah;_h=1;var t=Ht(),n=TypeError;return Ah=function(r,i){if(!delete r[i])throw new n("Cannot delete property "+t(i)+" of "+t(r))}}function jh(){if(Oh)return Ch;Oh=1;var t=Bt().match(/firefox\/(\d+)/i);return Ch=!!t&&+t[1]}function zh(){if(Fh)return Dh;Fh=1;var t=Bt();return Dh=/MSIE|Trident/.test(t)}function Vh(){if(xh)return Nh;xh=1;var t=Bt().match(/AppleWebKit\/(\d+)\./);return Nh=!!t&&+t[1]}!function(){if(Mh)return Ph;Mh=1;var t=Ti(),n=Ft(),r=Xt(),i=An(),e=jr(),s=Uh(),o=pe(),u=j(),a=vh(),c=ne(),f=jh(),h=zh(),d=Gt(),v=Vh(),l=[],g=n(l.sort),w=n(l.push),m=u(function(){l.sort(void 0)}),p=u(function(){l.sort(null)}),y=c("sort"),b=!u(function(){if(d)return d<70;if(!(f&&f>3)){if(h)return!0;if(v)return v<603;var t,n,r,i,e="";for(t=65;t<76;t++){switch(n=String.fromCharCode(t),t){case 66:case 69:case 70:case 72:r=3;break;case 68:case 71:r=4;break;default:r=2}for(i=0;i<47;i++)l.push({k:n+i,v:r})}for(l.sort(function(t,n){return n.v-t.v}),i=0;i<l.length;i++)n=l[i].k.charAt(0),e.charAt(e.length-1)!==n&&(e+=n);return"DGBEFHACIJK"!==e}});t({target:"Array",proto:!0,forced:m||!p||!y||!b},{sort:function(t){void 0!==t&&r(t);var n=i(this);if(b)return void 0===t?g(n):g(n,t);var u,c,f=[],h=e(n);for(c=0;c<h;c++)c in n&&w(f,n[c]);for(a(f,function(t){return function(n,r){return void 0===r?-1:void 0===n?1:void 0!==t?+t(n,r)||0:o(n)>o(r)?1:-1}}(t)),u=e(f),c=0;c<u;)n[c]=f[c++];for(;c<h;)s(n,c++);return n}})}();var Lh,Bh,Gh,Wh,qh,Kh,Hh,Xh,$h,Jh,Qh,Yh,Zh,td,nd,rd,id,ed,sd,od={};function ud(){return Bh?Lh:(Bh=1,Lh="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView)}function ad(){if(Wh)return Gh;Wh=1;var t=Mr(),n=Ur(),r=RangeError;return Gh=function(i){if(void 0===i)return 0;var e=t(i),s=n(e);if(e!==s)throw new r("Wrong length or index");return s}}function cd(){if(Jh)return $h;Jh=1;var t=Kh?qh:(Kh=1,qh=Math.sign||function(t){var n=+t;return 0===n||n!=n?n:n<0?-1:1}),n=function(){if(Xh)return Hh;Xh=1;var t=4503599627370496;return Hh=function(n){return n+t-t}}(),r=Math.abs;return $h=function(i,e,s,o){var u=+i,a=r(u),c=t(u);if(a<o)return c*n(a/o/e)*o*e;var f=(1+e/2220446049250313e-31)*a,h=f-(f-a);return h>s||h!=h?c*(1/0):c*h}}function fd(){if(td)return Zh;td=1;var t=Array,n=Math.abs,r=Math.pow,i=Math.floor,e=Math.log,s=Math.LN2;return Zh={pack:function(o,u,a){var c,f,h,d=t(a),v=8*a-u-1,l=(1<<v)-1,g=l>>1,w=23===u?r(2,-24)-r(2,-77):0,m=o<0||0===o&&1/o<0?1:0,p=0;for((o=n(o))!=o||o===1/0?(f=o!=o?1:0,c=l):(c=i(e(o)/s),o*(h=r(2,-c))<1&&(c--,h*=2),(o+=c+g>=1?w/h:w*r(2,1-g))*h>=2&&(c++,h/=2),c+g>=l?(f=0,c=l):c+g>=1?(f=(o*h-1)*r(2,u),c+=g):(f=o*r(2,g-1)*r(2,u),c=0));u>=8;)d[p++]=255&f,f/=256,u-=8;for(c=c<<u|f,v+=u;v>0;)d[p++]=255&c,c/=256,v-=8;return d[p-1]|=128*m,d},unpack:function(t,n){var i,e=t.length,s=8*e-n-1,o=(1<<s)-1,u=o>>1,a=s-7,c=e-1,f=t[c--],h=127&f;for(f>>=7;a>0;)h=256*h+t[c--],a-=8;for(i=h&(1<<-a)-1,h>>=-a,a+=n;a>0;)i=256*i+t[c--],a-=8;if(0===h)h=1-u;else{if(h===o)return i?NaN:f?-1/0:1/0;i+=r(2,n),h-=u}return(f?-1:1)*i*r(2,h-n)}}}function hd(){if(rd)return nd;rd=1;var t=An(),n=Pr(),r=jr();return nd=function(i){for(var e=t(this),s=r(e),o=arguments.length,u=n(o>1?arguments[1]:void 0,s),a=o>2?arguments[2]:void 0,c=void 0===a?s:n(a,s);c>u;)e[u++]=i;return e},nd}function dd(){if(ed)return id;ed=1;var t=_(),n=Ft(),r=z(),i=ud(),e=fr(),s=Hn(),o=Lo(),u=dh(),a=j(),c=$u(),f=Mr(),h=Ur(),d=ad(),v=function(){if(Yh)return Qh;Yh=1;var t=cd();return Qh=Math.fround||function(n){return t(n,1.1920928955078125e-7,34028234663852886e22,11754943508222875e-54)}}(),l=fd(),g=pf(),w=Ku(),m=hd(),p=Zu(),y=Of(),b=Ii(),E=Hu(),I=lr(),S=e.PROPER,T=e.CONFIGURABLE,k="ArrayBuffer",R="DataView",A="prototype",C="Wrong index",O=I.getterFor(k),D=I.getterFor(R),F=I.set,N=t[k],x=N,M=x&&x[A],P=t[R],U=P&&P[A],V=Object.prototype,L=t.Array,B=t.RangeError,G=n(m),W=n([].reverse),q=l.pack,K=l.unpack,H=function(t){return[255&t]},X=function(t){return[255&t,t>>8&255]},$=function(t){return[255&t,t>>8&255,t>>16&255,t>>24&255]},J=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},Q=function(t){return q(v(t),23,4)},Y=function(t){return q(t,52,8)},Z=function(t,n,r){o(t[A],n,{configurable:!0,get:function(){return r(this)[n]}})},tt=function(t,n,r,i){var e=D(t),s=d(r),o=!!i;if(s+n>e.byteLength)throw new B(C);var u=e.bytes,a=s+e.byteOffset,c=p(u,a,a+n);return o?c:W(c)},nt=function(t,n,r,i,e,s){var o=D(t),u=d(r),a=i(+e),c=!!s;if(u+n>o.byteLength)throw new B(C);for(var f=o.bytes,h=u+o.byteOffset,v=0;v<n;v++)f[h+v]=a[c?v:n-v-1]};if(i){var rt=S&&N.name!==k;a(function(){N(1)})&&a(function(){new N(-1)})&&!a(function(){return new N,new N(1.5),new N(NaN),1!==N.length||rt&&!T})?rt&&T&&s(N,"name",k):((x=function(t){return c(this,M),y(new N(d(t)),this,x)})[A]=M,M.constructor=x,b(x,N)),w&&g(U)!==V&&w(U,V);var it=new P(new x(2)),et=n(U.setInt8);it.setInt8(0,2147483648),it.setInt8(1,2147483649),!it.getInt8(0)&&it.getInt8(1)||u(U,{setInt8:function(t,n){et(this,t,n<<24>>24)},setUint8:function(t,n){et(this,t,n<<24>>24)}},{unsafe:!0})}else M=(x=function(t){c(this,M);var n=d(t);F(this,{type:k,bytes:G(L(n),0),byteLength:n}),r||(this.byteLength=n,this.detached=!1)})[A],U=(P=function(t,n,i){c(this,U),c(t,M);var e=O(t),s=e.byteLength,o=f(n);if(o<0||o>s)throw new B("Wrong offset");if(o+(i=void 0===i?s-o:h(i))>s)throw new B("Wrong length");F(this,{type:R,buffer:t,byteLength:i,byteOffset:o,bytes:e.bytes}),r||(this.buffer=t,this.byteLength=i,this.byteOffset=o)})[A],r&&(Z(x,"byteLength",O),Z(P,"buffer",D),Z(P,"byteLength",D),Z(P,"byteOffset",D)),u(U,{getInt8:function(t){return tt(this,1,t)[0]<<24>>24},getUint8:function(t){return tt(this,1,t)[0]},getInt16:function(t){var n=tt(this,2,t,arguments.length>1&&arguments[1]);return(n[1]<<8|n[0])<<16>>16},getUint16:function(t){var n=tt(this,2,t,arguments.length>1&&arguments[1]);return n[1]<<8|n[0]},getInt32:function(t){return J(tt(this,4,t,arguments.length>1&&arguments[1]))},getUint32:function(t){return J(tt(this,4,t,arguments.length>1&&arguments[1]))>>>0},getFloat32:function(t){return K(tt(this,4,t,arguments.length>1&&arguments[1]),23)},getFloat64:function(t){return K(tt(this,8,t,arguments.length>1&&arguments[1]),52)},setInt8:function(t,n){nt(this,1,t,H,n)},setUint8:function(t,n){nt(this,1,t,H,n)},setInt16:function(t,n){nt(this,2,t,X,n,arguments.length>2&&arguments[2])},setUint16:function(t,n){nt(this,2,t,X,n,arguments.length>2&&arguments[2])},setInt32:function(t,n){nt(this,4,t,$,n,arguments.length>2&&arguments[2])},setUint32:function(t,n){nt(this,4,t,$,n,arguments.length>2&&arguments[2])},setFloat32:function(t,n){nt(this,4,t,Q,n,arguments.length>2&&arguments[2])},setFloat64:function(t,n){nt(this,8,t,Y,n,arguments.length>2&&arguments[2])}});return E(x,k),E(P,R),id={ArrayBuffer:x,DataView:P}}!function(){if(sd)return od;sd=1;var t=Ti(),n=_(),r=dd(),i=Xu(),e="ArrayBuffer",s=r[e];t({global:!0,constructor:!0,forced:n[e]!==s},{ArrayBuffer:s}),i(e)}();var vd,ld={};!function(){if(vd)return ld;vd=1;var t=Ti(),n=Ue(),r=j(),i=dd(),e=qn(),s=Pr(),o=Ur(),u=i.ArrayBuffer,a=i.DataView,c=a.prototype,f=n(u.prototype.slice),h=n(c.getUint8),d=n(c.setUint8);t({target:"ArrayBuffer",proto:!0,unsafe:!0,forced:r(function(){return!new u(2).slice(1,void 0).byteLength})},{slice:function(t,n){if(f&&void 0===n)return f(e(this),t);for(var r=e(this).byteLength,i=s(t,r),c=s(void 0===n?r:n,r),v=new u(o(c-i)),l=new a(this),g=new a(v),w=0;i<c;)d(g,w++,h(l,i++));return v}})}();var gd,wd,md,pd,yd,bd,Ed,Id,Sd,Td,kd,Rd,Ad,_d,Cd,Od,Dd,Fd,Nd,xd,Md,Pd,Ud={exports:{}};function jd(){if(wd)return gd;wd=1;var t,n,r,i=ud(),e=z(),s=_(),o=jt(),u=zt(),a=_n(),c=Oi(),f=Ht(),h=Hn(),d=wr(),v=Lo(),l=Lt(),g=pf(),w=Ku(),m=On(),p=Cn(),y=lr(),b=y.enforce,E=y.get,I=s.Int8Array,S=I&&I.prototype,T=s.Uint8ClampedArray,k=T&&T.prototype,R=I&&g(I),A=S&&g(S),C=Object.prototype,O=s.TypeError,D=m("toStringTag"),F=p("TYPED_ARRAY_TAG"),N="TypedArrayConstructor",x=i&&!!w&&"Opera"!==c(s.opera),M=!1,P={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},U={BigInt64Array:8,BigUint64Array:8},j=function(t){var n=g(t);if(u(n)){var r=E(n);return r&&a(r,N)?r[N]:j(n)}},V=function(t){if(!u(t))return!1;var n=c(t);return a(P,n)||a(U,n)};for(t in P)(r=(n=s[t])&&n.prototype)?b(r)[N]=n:x=!1;for(t in U)(r=(n=s[t])&&n.prototype)&&(b(r)[N]=n);if((!x||!o(R)||R===Function.prototype)&&(R=function(){throw new O("Incorrect invocation")},x))for(t in P)s[t]&&w(s[t],R);if((!x||!A||A===C)&&(A=R.prototype,x))for(t in P)s[t]&&w(s[t].prototype,A);if(x&&g(k)!==A&&w(k,A),e&&!a(A,D))for(t in M=!0,v(A,D,{configurable:!0,get:function(){return u(this)?this[F]:void 0}}),P)s[t]&&h(s[t],F,t);return gd={NATIVE_ARRAY_BUFFER_VIEWS:x,TYPED_ARRAY_TAG:M&&F,aTypedArray:function(t){if(V(t))return t;throw new O("Target is not a typed array")},aTypedArrayConstructor:function(t){if(o(t)&&(!w||l(R,t)))return t;throw new O(f(t)+" is not a typed array constructor")},exportTypedArrayMethod:function(t,n,r,i){if(e){if(r)for(var o in P){var u=s[o];if(u&&a(u.prototype,t))try{delete u.prototype[t]}catch(r){try{u.prototype[t]=n}catch(t){}}}A[t]&&!r||d(A,t,r?n:x&&S[t]||n,i)}},exportTypedArrayStaticMethod:function(t,n,r){var i,o;if(e){if(w){if(r)for(i in P)if((o=s[i])&&a(o,t))try{delete o[t]}catch(t){}if(R[t]&&!r)return;try{return d(R,t,r?n:x&&R[t]||n)}catch(t){}}for(i in P)!(o=s[i])||o[t]&&!r||d(o,t,n)}},getTypedArrayConstructor:j,isView:function(t){if(!u(t))return!1;var n=c(t);return"DataView"===n||a(P,n)||a(U,n)},isTypedArray:V,TypedArray:R,TypedArrayPrototype:A}}function zd(){if(bd)return yd;bd=1;var t=zt(),n=Math.floor;return yd=Number.isInteger||function(r){return!t(r)&&isFinite(r)&&n(r)===r}}function Vd(){if(Id)return Ed;Id=1;var t=Mr(),n=RangeError;return Ed=function(r){var i=t(r);if(i<0)throw new n("The argument can't be less than 0");return i}}function Ld(){if(Td)return Sd;Td=1;var t=Vd(),n=RangeError;return Sd=function(r,i){var e=t(r);if(e%i)throw new n("Wrong offset");return e}}function Bd(){if(Rd)return kd;Rd=1;var t=Math.round;return kd=function(n){var r=t(n);return r<0?0:r>255?255:255&r}}function Gd(){if(_d)return Ad;_d=1;var t=Oi();return Ad=function(n){var r=t(n);return"BigInt64Array"===r||"BigUint64Array"===r}}function Wd(){if(Od)return Cd;Od=1;var t=Dn(),n=TypeError;return Cd=function(r){var i=t(r,"number");if("number"==typeof i)throw new n("Can't convert number to bigint");return BigInt(i)}}function qd(){if(Fd)return Dd;Fd=1;var t=je(),n=L(),r=Ju(),i=An(),e=jr(),s=Ma(),o=xa(),u=Na(),a=Gd(),c=jd().aTypedArrayConstructor,f=Wd();return Dd=function(h){var d,v,l,g,w,m,p,y,b=r(this),E=i(h),I=arguments.length,S=I>1?arguments[1]:void 0,T=void 0!==S,k=o(E);if(k&&!u(k))for(y=(p=s(E,k)).next,E=[];!(m=n(y,p)).done;)E.push(m.value);for(T&&I>2&&(S=t(S,arguments[2])),v=e(E),l=new(c(b))(v),g=a(l),d=0;v>d;d++)w=T?S(E[d],d):E[d],l[d]=g?f(w):+w;return l},Dd}function Kd(){if(xd)return Nd;xd=1;var t=jr();return Nd=function(n,r,i){for(var e=0,s=arguments.length>2?i:t(r),o=new n(s);s>e;)o[e]=r[e++];return o},Nd}function Hd(){if(Md)return Ud.exports;Md=1;var t=Ti(),n=_(),r=L(),i=z(),e=function(){if(pd)return md;pd=1;var t=_(),n=j(),r=ja(),i=jd().NATIVE_ARRAY_BUFFER_VIEWS,e=t.ArrayBuffer,s=t.Int8Array;return md=!i||!n(function(){s(1)})||!n(function(){new s(-1)})||!r(function(t){new s,new s(null),new s(1.5),new s(t)},!0)||n(function(){return 1!==new s(new e(2),1,void 0).length})}(),s=jd(),o=dd(),u=$u(),a=Dt(),c=Hn(),f=zd(),h=Ur(),d=ad(),v=Ld(),l=Bd(),g=Fn(),w=_n(),m=Oi(),p=zt(),y=Kt(),b=$i(),E=Lt(),I=Ku(),S=Br().f,T=qd(),k=ze().forEach,R=Xu(),A=Lo(),C=Kn(),O=Mn(),D=Kd(),F=lr(),N=Of(),x=F.get,M=F.set,P=F.enforce,U=C.f,V=O.f,B=n.RangeError,G=o.ArrayBuffer,W=G.prototype,q=o.DataView,K=s.NATIVE_ARRAY_BUFFER_VIEWS,H=s.TYPED_ARRAY_TAG,X=s.TypedArray,$=s.TypedArrayPrototype,J=s.isTypedArray,Q="BYTES_PER_ELEMENT",Y="Wrong length",Z=function(t,n){A(t,n,{configurable:!0,get:function(){return x(this)[n]}})},tt=function(t){var n;return E(W,t)||"ArrayBuffer"===(n=m(t))||"SharedArrayBuffer"===n},nt=function(t,n){return J(t)&&!y(n)&&n in t&&f(+n)&&n>=0},rt=function(t,n){return n=g(n),nt(t,n)?a(2,t[n]):V(t,n)},it=function(t,n,r){return n=g(n),!(nt(t,n)&&p(r)&&w(r,"value"))||w(r,"get")||w(r,"set")||r.configurable||w(r,"writable")&&!r.writable||w(r,"enumerable")&&!r.enumerable?U(t,n,r):(t[n]=r.value,t)};return i?(K||(O.f=rt,C.f=it,Z($,"buffer"),Z($,"byteOffset"),Z($,"byteLength"),Z($,"length")),t({target:"Object",stat:!0,forced:!K},{getOwnPropertyDescriptor:rt,defineProperty:it}),Ud.exports=function(i,s,o){var a=i.match(/\d+/)[0]/8,f=i+(o?"Clamped":"")+"Array",g="get"+i,w="set"+i,m=n[f],y=m,E=y&&y.prototype,A={},_=function(t,n){U(t,n,{get:function(){return function(t,n){var r=x(t);return r.view[g](n*a+r.byteOffset,!0)}(this,n)},set:function(t){return function(t,n,r){var i=x(t);i.view[w](n*a+i.byteOffset,o?l(r):r,!0)}(this,n,t)},enumerable:!0})};K?e&&(y=s(function(t,n,i,e){return u(t,E),N(p(n)?tt(n)?void 0!==e?new m(n,v(i,a),e):void 0!==i?new m(n,v(i,a)):new m(n):J(n)?D(y,n):r(T,y,n):new m(d(n)),t,y)}),I&&I(y,X),k(S(m),function(t){t in y||c(y,t,m[t])}),y.prototype=E):(y=s(function(t,n,i,e){u(t,E);var s,o,c,f=0,l=0;if(p(n)){if(!tt(n))return J(n)?D(y,n):r(T,y,n);s=n,l=v(i,a);var g=n.byteLength;if(void 0===e){if(g%a)throw new B(Y);if((o=g-l)<0)throw new B(Y)}else if((o=h(e)*a)+l>g)throw new B(Y);c=o/a}else c=d(n),s=new G(o=c*a);for(M(t,{buffer:s,byteOffset:l,byteLength:o,length:c,view:new q(s)});f<c;)_(t,f++)}),I&&I(y,X),E=y.prototype=b($)),E.constructor!==y&&c(E,"constructor",y),P(E).TypedArrayConstructor=y,H&&c(E,H,f);var C=y!==m;A[f]=y,t({global:!0,constructor:!0,forced:C,sham:!K},A),Q in y||c(y,Q,a),Q in E||c(E,Q,a),R(f)}):Ud.exports=function(){},Ud.exports}Pd||(Pd=1,Hd()("Uint8",function(t){return function(n,r,i){return t(this,n,r,i)}}));var Xd,$d,Jd,Qd={};!function(){if(Jd)return Qd;Jd=1;var t=Ft(),n=jd(),r=function(){if($d)return Xd;$d=1;var t=An(),n=Pr(),r=jr(),i=Uh(),e=Math.min;return Xd=[].copyWithin||function(s,o){var u=t(this),a=r(u),c=n(s,a),f=n(o,a),h=arguments.length>2?arguments[2]:void 0,d=e((void 0===h?a:n(h,a))-f,a-c),v=1;for(f<c&&c<f+d&&(v=-1,f+=d-1,c+=d-1);d-- >0;)f in u?u[c]=u[f]:i(u,c),c+=v,f+=v;return u},Xd}(),i=t(r),e=n.aTypedArray;(0,n.exportTypedArrayMethod)("copyWithin",function(t,n){return i(e(this),t,n,arguments.length>2?arguments[2]:void 0)})}();var Yd,Zd={};!function(){if(Yd)return Zd;Yd=1;var t=jd(),n=ze().every,r=t.aTypedArray;(0,t.exportTypedArrayMethod)("every",function(t){return n(r(this),t,arguments.length>1?arguments[1]:void 0)})}();var tv,nv={};!function(){if(tv)return nv;tv=1;var t=jd(),n=hd(),r=Wd(),i=Oi(),e=L(),s=Ft(),o=j(),u=t.aTypedArray,a=t.exportTypedArrayMethod,c=s("".slice);a("fill",function(t){var s=arguments.length;u(this);var o="Big"===c(i(this),0,3)?r(t):+t;return e(n,this,o,s>1?arguments[1]:void 0,s>2?arguments[2]:void 0)},o(function(){var t=0;return new Int8Array(2).fill({valueOf:function(){return t++}}),1!==t}))}();var rv,iv,ev,sv={};function ov(){if(iv)return rv;iv=1;var t=Kd(),n=jd().getTypedArrayConstructor;return rv=function(r,i){return t(n(r),i)}}!function(){if(ev)return sv;ev=1;var t=jd(),n=ze().filter,r=ov(),i=t.aTypedArray;(0,t.exportTypedArrayMethod)("filter",function(t){var e=n(i(this),t,arguments.length>1?arguments[1]:void 0);return r(this,e)})}();var uv,av={};!function(){if(uv)return av;uv=1;var t=jd(),n=ze().find,r=t.aTypedArray;(0,t.exportTypedArrayMethod)("find",function(t){return n(r(this),t,arguments.length>1?arguments[1]:void 0)})}();var cv,fv={};!function(){if(cv)return fv;cv=1;var t=jd(),n=ze().findIndex,r=t.aTypedArray;(0,t.exportTypedArrayMethod)("findIndex",function(t){return n(r(this),t,arguments.length>1?arguments[1]:void 0)})}();var hv,dv={};!function(){if(hv)return dv;hv=1;var t=jd(),n=ze().forEach,r=t.aTypedArray;(0,t.exportTypedArrayMethod)("forEach",function(t){n(r(this),t,arguments.length>1?arguments[1]:void 0)})}();var vv,lv={};!function(){if(vv)return lv;vv=1;var t=jd(),n=zr().includes,r=t.aTypedArray;(0,t.exportTypedArrayMethod)("includes",function(t){return n(r(this),t,arguments.length>1?arguments[1]:void 0)})}();var gv,wv={};!function(){if(gv)return wv;gv=1;var t=jd(),n=zr().indexOf,r=t.aTypedArray;(0,t.exportTypedArrayMethod)("indexOf",function(t){return n(r(this),t,arguments.length>1?arguments[1]:void 0)})}();var mv,pv={};!function(){if(mv)return pv;mv=1;var t=_(),n=j(),r=Ft(),i=jd(),e=Sf(),s=On()("iterator"),o=t.Uint8Array,u=r(e.values),a=r(e.keys),c=r(e.entries),f=i.aTypedArray,h=i.exportTypedArrayMethod,d=o&&o.prototype,v=!n(function(){d[s].call([1])}),l=!!d&&d.values&&d[s]===d.values&&"values"===d.values.name,g=function(){return u(f(this))};h("entries",function(){return c(f(this))},v),h("keys",function(){return a(f(this))},v),h("values",g,v||!l,{name:"values"}),h(s,g,v||!l,{name:"values"})}();var yv,bv={};!function(){if(yv)return bv;yv=1;var t=jd(),n=Ft(),r=t.aTypedArray,i=t.exportTypedArrayMethod,e=n([].join);i("join",function(t){return e(r(this),t)})}();var Ev,Iv,Sv,Tv={};!function(){if(Sv)return Tv;Sv=1;var t=jd(),n=Yu(),r=function(){if(Iv)return Ev;Iv=1;var t=Yu(),n=Ut(),r=Mr(),i=jr(),e=ne(),s=Math.min,o=[].lastIndexOf,u=!!o&&1/[1].lastIndexOf(1,-0)<0,a=e("lastIndexOf");return Ev=u||!a?function(e){if(u)return t(o,this,arguments)||0;var a=n(this),c=i(a);if(0===c)return-1;var f=c-1;for(arguments.length>1&&(f=s(f,r(arguments[1]))),f<0&&(f=c+f);f>=0;f--)if(f in a&&a[f]===e)return f||0;return-1}:o,Ev}(),i=t.aTypedArray;(0,t.exportTypedArrayMethod)("lastIndexOf",function(t){var e=arguments.length;return n(r,i(this),e>1?[t,arguments[1]]:[t])})}();var kv,Rv={};!function(){if(kv)return Rv;kv=1;var t=jd(),n=ze().map,r=ov(),i=t.aTypedArray;(0,t.exportTypedArrayMethod)("map",function(t){var e=n(i(this),t,arguments.length>1?arguments[1]:void 0);return r(this,e)})}();var Av,_v,Cv,Ov={};function Dv(){if(_v)return Av;_v=1;var t=Xt(),n=An(),r=xt(),i=jr(),e=TypeError,s="Reduce of empty array with no initial value",o=function(o){return function(u,a,c,f){var h=n(u),d=r(h),v=i(h);if(t(a),0===v&&c<2)throw new e(s);var l=o?v-1:0,g=o?-1:1;if(c<2)for(;;){if(l in d){f=d[l],l+=g;break}if(l+=g,o?l<0:v<=l)throw new e(s)}for(;o?l>=0:v>l;l+=g)l in d&&(f=a(f,d[l],l,h));return f}};return Av={left:o(!1),right:o(!0)}}!function(){if(Cv)return Ov;Cv=1;var t=jd(),n=Dv().left,r=t.aTypedArray;(0,t.exportTypedArrayMethod)("reduce",function(t){var i=arguments.length;return n(r(this),t,i,i>1?arguments[1]:void 0)})}();var Fv,Nv={};!function(){if(Fv)return Nv;Fv=1;var t=jd(),n=Dv().right,r=t.aTypedArray;(0,t.exportTypedArrayMethod)("reduceRight",function(t){var i=arguments.length;return n(r(this),t,i,i>1?arguments[1]:void 0)})}();var xv,Mv={};!function(){if(xv)return Mv;xv=1;var t=jd(),n=t.aTypedArray,r=t.exportTypedArrayMethod,i=Math.floor;r("reverse",function(){for(var t,r=this,e=n(r).length,s=i(e/2),o=0;o<s;)t=r[o],r[o++]=r[--e],r[e]=t;return r})}();var Pv,Uv={};!function(){if(Pv)return Uv;Pv=1;var t=_(),n=L(),r=jd(),i=jr(),e=Ld(),s=An(),o=j(),u=t.RangeError,a=t.Int8Array,c=a&&a.prototype,f=c&&c.set,h=r.aTypedArray,d=r.exportTypedArrayMethod,v=!o(function(){var t=new Uint8ClampedArray(2);return n(f,t,{length:1,0:3},1),3!==t[1]}),l=v&&r.NATIVE_ARRAY_BUFFER_VIEWS&&o(function(){var t=new a(2);return t.set(1),t.set("2",1),0!==t[0]||2!==t[1]});d("set",function(t){h(this);var r=e(arguments.length>1?arguments[1]:void 0,1),o=s(t);if(v)return n(f,this,o,r);var a=this.length,c=i(o),d=0;if(c+r>a)throw new u("Wrong length");for(;d<c;)this[r+d]=o[d++]},!v||l)}();var jv,zv={};!function(){if(jv)return zv;jv=1;var t=jd(),n=j(),r=Zu(),i=t.aTypedArray,e=t.getTypedArrayConstructor;(0,t.exportTypedArrayMethod)("slice",function(t,n){for(var s=r(i(this),t,n),o=e(this),u=0,a=s.length,c=new o(a);a>u;)c[u]=s[u++];return c},n(function(){new Int8Array(1).slice()}))}();var Vv,Lv={};!function(){if(Vv)return Lv;Vv=1;var t=jd(),n=ze().some,r=t.aTypedArray;(0,t.exportTypedArrayMethod)("some",function(t){return n(r(this),t,arguments.length>1?arguments[1]:void 0)})}();var Bv,Gv={};!function(){if(Bv)return Gv;Bv=1;var t=_(),n=Ue(),r=j(),i=Xt(),e=vh(),s=jd(),o=jh(),u=zh(),a=Gt(),c=Vh(),f=s.aTypedArray,h=s.exportTypedArrayMethod,d=t.Uint16Array,v=d&&n(d.prototype.sort),l=!(!v||r(function(){v(new d(2),null)})&&r(function(){v(new d(2),{})})),g=!!v&&!r(function(){if(a)return a<74;if(o)return o<67;if(u)return!0;if(c)return c<602;var t,n,r=new d(516),i=Array(516);for(t=0;t<516;t++)n=t%4,r[t]=515-t,i[t]=t-2*n+3;for(v(r,function(t,n){return(t/4|0)-(n/4|0)}),t=0;t<516;t++)if(r[t]!==i[t])return!0});h("sort",function(t){return void 0!==t&&i(t),g?v(this,t):e(f(this),function(t){return function(n,r){return void 0!==t?+t(n,r)||0:r!=r?-1:n!=n?1:0===n&&0===r?1/n>0&&1/r<0?1:-1:n>r}}(t))},!g||l)}();var Wv,qv={};!function(){if(Wv)return qv;Wv=1;var t=jd(),n=Ur(),r=Pr(),i=t.aTypedArray,e=t.getTypedArrayConstructor;(0,t.exportTypedArrayMethod)("subarray",function(t,s){var o=i(this),u=o.length,a=r(t,u);return new(e(o))(o.buffer,o.byteOffset+a*o.BYTES_PER_ELEMENT,n((void 0===s?u:r(s,u))-a))})}();var Kv,Hv={};!function(){if(Kv)return Hv;Kv=1;var t=_(),n=Yu(),r=jd(),i=j(),e=Zu(),s=t.Int8Array,o=r.aTypedArray,u=r.exportTypedArrayMethod,a=[].toLocaleString,c=!!s&&i(function(){a.call(new s(1))});u("toLocaleString",function(){return n(a,c?e(o(this)):o(this),e(arguments))},i(function(){return[1,2].toLocaleString()!==new s([1,2]).toLocaleString()})||!i(function(){s.prototype.toLocaleString.call([1,2])}))}();var Xv,$v={};function Jv(t){var n,r=function(){var t,n;try{if("undefined"!=typeof navigator&&"userAgentData"in navigator){var r=navigator.userAgentData;if(r&&r.brands)try{for(var i=We(r.brands),e=i.next();!e.done;e=i.next()){var s=e.value;if(s.brand&&"Chromium"!==s.brand&&"Not_A Brand"!==s.brand)return s.brand}}catch(n){t={error:n}}finally{try{e&&!e.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}}if("undefined"!=typeof navigator&&navigator.userAgent){var o=navigator.userAgent;if(o.includes("Firefox/"))return"Firefox";if(o.includes("Edg/"))return"Edge";if(o.includes("Chrome/"))return"Chrome";if(o.includes("Safari/")&&!o.includes("Chrome"))return"Safari";if(o.includes("Opera/")||o.includes("OPR/"))return"Opera"}return"Unknown"}catch(t){return"Unknown"}}(),i=function(){var t;try{if("undefined"!=typeof navigator&&"userAgentData"in navigator){var n=navigator.userAgentData;if(n&&n.platform)return n.platform}if("undefined"!=typeof navigator&&navigator.userAgent){var r,i=navigator.userAgent;if(i.includes("Mac OS X")){if((r=i.match(/Mac OS X ([\d_]+)/))&&r[1]){var e=r[1].replace(/_/g,".");return"macOS ".concat(e)}return"macOS"}if(i.includes("Windows NT"))return(r=i.match(/Windows NT ([\d.]+)/))&&r[1]?(e=r[1],"Windows ".concat(null!==(t={"10.0":"10/11",6.3:"8.1",6.2:"8",6.1:"7"}[e])&&void 0!==t?t:e)):"Windows";if(i.includes("iPhone")||i.includes("iPad"))return(r=i.match(/OS ([\d_]+)/))&&r[1]?(e=r[1].replace(/_/g,"."),"iOS ".concat(e)):"iOS";if(i.includes("Android"))return(r=i.match(/Android ([\d.]+)/))?"Android ".concat(r[1]):"Android";if(i.includes("Linux"))return"Linux"}return"Unknown"}catch(t){return"Unknown"}}(),e="en-US";try{"undefined"!=typeof navigator&&(e=navigator.language||(null===(n=navigator.languages)||void 0===n?void 0:n[0])||"en-US")}catch(t){e="en-US"}var s="UTC";try{"undefined"!=typeof Intl&&(s=Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC")}catch(t){s="UTC"}var o="0x0";try{"undefined"!=typeof window&&window.screen&&(o="".concat(window.screen.width,"x").concat(window.screen.height))}catch(t){o="0x0"}var u=null,a=null,c=null,f=null,h=null,d=null;try{if("undefined"!=typeof window&&window.location){var v=window.location.search;u=yh(v,"utm_source"),a=yh(v,"utm_medium"),c=yh(v,"utm_campaign"),f=yh(v,"utm_term"),h=yh(v,"utm_content"),d=yh(v,"gclid")||yh(v,"fbclid")||yh(v,"msclkid")||yh(v,"ttclid")}}catch(t){}var l="direct";try{"undefined"!=typeof document&&document.referrer&&(l=function(t){var n;if("undefined"!=typeof URL)try{return new URL(t).hostname}catch(t){return"direct"}var r=t.match(/^https?:\/\/([^/?#]+)/);return r&&null!==(n=r[1])&&void 0!==n?n:"direct"}(document.referrer))}catch(t){l="direct"}var g={sdk_version:zo,consent:(null==t?void 0:t.notificationPermissionGranted)?"yes":"no"};return(null==t?void 0:t.appVersion)&&(g.app_version=t.appVersion),(null==t?void 0:t.appVersion)&&(g.app_version=t.appVersion),(null==t?void 0:t.fcmTokenCreatedAt)&&(g.token_creation_date=t.fcmTokenCreatedAt),r&&"Unknown"!==r&&(g.browser=r),i&&"Unknown"!==i&&(g.os_version=i),e&&"en-US"!==e&&(g.locale=e),s&&"UTC"!==s&&(g.timezone=s),o&&"0x0"!==o&&(g.screen_resolution=o),u&&(g.utm_source=u),a&&(g.utm_medium=a),c&&(g.utm_campaign=c),f&&(g.utm_term=f),h&&(g.utm_content=h),d&&(g.ads_id=d),l&&"direct"!==l&&(g.initial_referrer=l),g}!function(){if(Xv)return $v;Xv=1;var t=jd().exportTypedArrayMethod,n=j(),r=_(),i=Ft(),e=r.Uint8Array,s=e&&e.prototype||{},o=[].toString,u=i([].join);n(function(){o.call({})})&&(o=function(){return u(this)});var a=s.toString!==o;t("toString",o,a)}();var Qv=function(){function t(t,n,r,i,e){this.httpClient=new gf(t),this.logger=n,this.accountId=r,this.orgId=i,this.source=e}return t.prototype.getNonce=function(t){return Be(this,void 0,void 0,function(){var n,r,i;return Ge(this,function(e){switch(e.label){case 0:this.logger.info("Requesting nonce",{accountId:this.accountId,bundleIdentifier:t}),n={account_id:this.accountId,bundle_identifier:t,timestamp:Date.now(),os_name:ko},e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.httpClient.post(He,n)];case 2:return r=e.sent(),this.logger.info(Ts,{challengeId:r.challenge_id,expiresAt:r.expires_at}),[2,r];case 3:throw i=e.sent(),this.logger.error(ks,i),i;case 4:return[2]}})})},t.prototype.sendEvents=function(t,n,r,i,e,s){return Be(this,void 0,void 0,function(){var o,u,a,c,f,h,d;return Ge(this,function(v){switch(v.label){case 0:if(!n&&!r&&!i)throw new Error("Either visitorId, visitorRefId, or userId must be provided for event tracking");if(!s)throw new Error("Session ID is required for event tracking");u=(o=!!n||!!r)&&i?"identified":o?"anonymous":"user-only",this.logger.info("Sending events",{eventCount:t.length,trackingMode:u,hasVisitor:o,hasUser:!!i,sessionId:s}),a=Eh(s),c={request_id:Ih(),system_data:a,events:t},n?c.visitor={identifierName:"id",identifierValue:n}:r&&(c.visitor={identifierName:"refId",identifierValue:r}),i&&e&&(c.user={identifierName:e,identifierValue:i}),v.label=1;case 1:return v.trys.push([1,3,,4]),f={"X-CAP-API-AUTH-ORG-ID":this.orgId,"X-CAP-ORG-ACCOUNT-ID":this.accountId,"X-CAP-SOURCE-NAME":this.source,"X-CAP-API-AUTH-KEY":"D2hO6eX3MT0RgGJmc0rcFVtiN38scsFJcvEgTD4","X-CAP-API-AUTH-ENTITY-ID":this.orgId},[4,this.httpClient.post(Xe,c,{headers:f})];case 2:return h=v.sent(),this.logger.info(Fs,{requestId:c.request_id,eventCount:t.length,trackingMode:u,success:h.status.success}),[2,h];case 3:throw d=v.sent(),this.logger.error(Ns,{requestId:c.request_id,eventCount:t.length,trackingMode:u,error:d}),d;case 4:return[2]}})})},t.prototype.getVisitorConfig=function(t,n){return Be(this,void 0,void 0,function(){var r,i,e,s,o;return Ge(this,function(u){switch(u.label){case 0:this.logger.info("Fetching visitor config",{orgId:t,vapId:n}),u.label=1;case 1:return u.trys.push([1,3,,4]),r={"X-CAP-API-AUTH-ORG-ID":t,"X-CAP-ORG-ACCOUNT-ID":this.accountId,"X-CAP-SOURCE-NAME":Fo.WEBPUSH},[4,this.httpClient.get($e,{headers:r})];case 2:return i=u.sent(),this.logger.info(Js,{isEnabled:null===(s=i.data)||void 0===s?void 0:s.visitorTrackingEnabled,warningCount:(null===(o=i.warnings)||void 0===o?void 0:o.length)||0}),[2,i];case 3:throw e=u.sent(),this.logger.error(Qs,e),e;case 4:return[2]}})})},t.prototype.createVisitor=function(t,n,r){return Be(this,void 0,void 0,function(){var i,e,s,o,u,a;return Ge(this,function(c){switch(c.label){case 0:this.logger.info("Creating anonymous visitor",{orgId:t,vapId:n,profileCount:r.profiles.length,hasExtendedFields:!!r.extendedFields}),c.label=1;case 1:if(c.trys.push([1,3,,4]),!r.profiles||0===r.profiles.length)throw new Error("At least one profile is required");return i={"X-CAP-API-AUTH-ORG-ID":t},[4,this.httpClient.post(Je,r,{headers:i})];case 2:return e=c.sent(),this.logger.info(ro,{visitorId:null===(o=e.data)||void 0===o?void 0:o.id,warningCount:(null===(u=e.warnings)||void 0===u?void 0:u.length)||0}),[2,e];case 3:throw s=c.sent(),this.logger.error(io,{error:s,accountId:null===(a=r.profiles[0])||void 0===a?void 0:a.accountId}),s;case 4:return[2]}})})},t.prototype.updateVisitor=function(t,n,r){return Be(this,void 0,void 0,function(){var i,e,s,o,u,a,c;return Ge(this,function(f){switch(f.label){case 0:this.logger.info("Updating visitor",{orgId:t,visitorId:n,profileCount:r.profiles.length,hasExtendedFields:!!r.extendedFields}),f.label=1;case 1:if(f.trys.push([1,3,,4]),!r.profiles||0===r.profiles.length)throw new Error("At least one profile is required");if(!n||""===n.trim())throw new Error("Visitor ID is required for update");return i={"X-CAP-API-AUTH-ORG-ID":t},e="".concat(Qe,"?identifierType=visitorId&identifierValue=").concat(encodeURIComponent(n)),[4,this.httpClient.put(e,r,{headers:i})];case 2:return s=f.sent(),this.logger.info(oo,{visitorId:null===(u=s.data)||void 0===u?void 0:u.id,warningCount:(null===(a=s.warnings)||void 0===a?void 0:a.length)||0}),[2,s];case 3:throw o=f.sent(),this.logger.error(uo,{error:o,visitorId:n,accountId:null===(c=r.profiles[0])||void 0===c?void 0:c.accountId}),o;case 4:return[2]}})})},t.prototype.mergeVisitor=function(t,n,r,i,e,s,o,u,a,c){return Be(this,void 0,void 0,function(){var f,h,d,v,l,g,w,m,p,y,b,E,I,S=this;return Ge(this,function(T){switch(T.label){case 0:if(!i&&!e&&!c)throw new Error("At least one identifier (email, mobile, or externalId) is required for visitor merge");this.logger.info("Merging visitor with user",{visitorId:t,hasEmail:!!i,hasMobile:!!e,hasExternalId:!!c,hasFcmToken:!!s}),f=[],i&&f.push({type:"email",value:i}),e&&f.push({type:"mobile",value:e}),c&&f.push({type:"externalId",value:c}),h=o||No.WEB,d=[],s&&d.push({type:h,value:s,primary:!0,verified:!0}),v={visitor:{id:t},user:{profiles:[{firstName:n,lastName:r,identifiers:f,commChannels:d,fields:u||{},source:Fo.WEBPUSH,accountId:this.accountId}],extendedFields:a||{}}},T.label=1;case 1:return T.trys.push([1,3,,4]),l={"X-CAP-API-AUTH-ORG-ID":this.orgId,"X-CAP-ORG-ACCOUNT-ID":this.accountId,"X-CAP-SOURCE-NAME":this.source},[4,this.httpClient.post(Ye,v,{headers:l})];case 2:if((g=T.sent()).warnings&&g.warnings.length>0&&g.warnings.forEach(function(t){S.logger.warn("Visitor merge warning",{code:t.code,message:t.message})}),g.errors&&g.errors.length>0){if(w=g.errors[0],m=w.code,p=w.message,y=String(m),b=p,y===Mo.ALREADY_MERGED)return this.logger.info("Visitor already merged, treating as success",{visitorId:t}),[2];if(y===Mo.VISITOR_NOT_FOUND)throw this.logger.warn("Visitor not found, merge cannot proceed",{visitorId:t}),new Yv(y,b);throw new Error("Merge API error: [".concat(y,"] ").concat(b))}if(202===(null===(I=g.status)||void 0===I?void 0:I.code))return this.logger.info(ao,{visitorId:t,statusCode:g.status.code,message:g.status.message}),[2];throw new Error("Unexpected merge API response");case 3:if((E=T.sent())instanceof Yv)throw E;throw this.logger.error(co,{visitorId:t,error:E}),E;case 4:return[2]}})})},t.prototype.sendDLR=function(t){return Be(this,void 0,void 0,function(){var n,r,i,e,s;return Ge(this,function(o){switch(o.label){case 0:this.logger.info("Sending DLR events",{eventCount:t.events.length,requestId:t.request_id,cuid:null===(e=t.user)||void 0===e?void 0:e.identifierValue,visitorId:null===(s=t.visitor)||void 0===s?void 0:s.identifierValue}),o.label=1;case 1:return o.trys.push([1,3,,4]),n={"x-cap-api-auth-key":"D2hO6eX3MT0RgGJmc0rcFVtiN38scsFJcvEgTD4","x-cap-api-auth-org-id":this.orgId,"x-cap-request-id":t.request_id},[4,this.httpClient.post(Ze,t,{headers:n})];case 2:return r=o.sent(),this.logger.info(So,{requestId:t.request_id,eventCount:t.events.length,success:r.status.success}),[2,r];case 3:throw i=o.sent(),this.logger.error(To,{requestId:t.request_id,eventCount:t.events.length,error:i}),i;case 4:return[2]}})})},t}(),Yv=function(t){function n(n,r){var i=t.call(this,r)||this;return i.name="MergeNonRetryableError",i.code=n,i}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}Ve(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,t),n}(Error);var Zv,tl={};!function(){if(Zv)return tl;Zv=1;var t=Ti(),n=ze().filter;t({target:"Array",proto:!0,forced:!xi()("filter")},{filter:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}})}();var nl,rl={};!function(){if(nl)return rl;nl=1;var t=Ti(),n=th();t({target:"Array",stat:!0,forced:!ja()(function(t){Array.from(t)})},{from:n})}();var il,el,sl,ol,ul,al,cl,fl,hl,dl,vl,ll,gl,wl,ml={exports:{}},pl={};function yl(){if(il)return pl;il=1;var t=Nt(),n=Ut(),r=Br().f,i=Zu(),e="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];return pl.f=function(s){return e&&"Window"===t(s)?function(t){try{return r(t)}catch(t){return i(e)}}(s):r(n(s))},pl}function bl(){if(ul)return ol;ul=1;var t=j(),n=zt(),r=Nt(),i=function(){if(sl)return el;sl=1;var t=j();return el=t(function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})}(),e=Object.isExtensible,s=t(function(){});return ol=s||i?function(t){return!!n(t)&&((!i||"ArrayBuffer"!==r(t))&&(!e||e(t)))}:e}function El(){if(fl)return ml.exports;fl=1;var t=Ti(),n=Ft(),r=vr(),i=zt(),e=_n(),s=Kn().f,o=Br(),u=yl(),a=bl(),c=Cn(),f=function(){if(cl)return al;cl=1;var t=j();return al=!t(function(){return Object.isExtensible(Object.preventExtensions({}))})}(),h=!1,d=c("meta"),v=0,l=function(t){s(t,d,{value:{objectID:"O"+v++,weakData:{}}})},g=ml.exports={enable:function(){g.enable=function(){},h=!0;var r=o.f,i=n([].splice),e={};e[d]=1,r(e).length&&(o.f=function(t){for(var n=r(t),e=0,s=n.length;e<s;e++)if(n[e]===d){i(n,e,1);break}return n},t({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:u.f}))},fastKey:function(t,n){if(!i(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!e(t,d)){if(!a(t))return"F";if(!n)return"E";l(t)}return t[d].objectID},getWeakData:function(t,n){if(!e(t,d)){if(!a(t))return!0;if(!n)return!1;l(t)}return t[d].weakData},onFreeze:function(t){return f&&h&&a(t)&&!e(t,d)&&l(t),t}};return r[d]=!0,ml.exports}wl||(wl=1,gl||(gl=1,function(){if(dl)return hl;dl=1;var t=Ti(),n=_(),r=Ft(),i=Si(),e=wr(),s=El(),o=Ua(),u=$u(),a=jt(),c=Mt(),f=zt(),h=j(),d=ja(),v=Hu(),l=Of();return hl=function(g,w,m){var p=-1!==g.indexOf("Map"),y=-1!==g.indexOf("Weak"),b=p?"set":"add",E=n[g],I=E&&E.prototype,S=E,T={},k=function(t){var n=r(I[t]);e(I,t,"add"===t?function(t){return n(this,0===t?0:t),this}:"delete"===t?function(t){return!(y&&!f(t))&&n(this,0===t?0:t)}:"get"===t?function(t){return y&&!f(t)?void 0:n(this,0===t?0:t)}:"has"===t?function(t){return!(y&&!f(t))&&n(this,0===t?0:t)}:function(t,r){return n(this,0===t?0:t,r),this})};if(i(g,!a(E)||!(y||I.forEach&&!h(function(){(new E).entries().next()}))))S=m.getConstructor(w,g,p,b),s.enable();else if(i(g,!0)){var R=new S,A=R[b](y?{}:-0,1)!==R,_=h(function(){R.has(1)}),C=d(function(t){new E(t)}),O=!y&&h(function(){for(var t=new E,n=5;n--;)t[b](n,n);return!t.has(-0)});C||((S=w(function(t,n){u(t,I);var r=l(new E,t,S);return c(n)||o(n,r[b],{that:r,AS_ENTRIES:p}),r})).prototype=I,I.constructor=S),(_||O)&&(k("delete"),k("has"),p&&k("get")),(O||A)&&k(b),y&&I.clear&&delete I.clear}return T[g]=S,t({global:!0,constructor:!0,forced:S!==E},T),v(S,g),y||m.setStrong(S,g,p),S}}()("Map",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},function(){if(ll)return vl;ll=1;var t=$i(),n=Lo(),r=dh(),i=je(),e=$u(),s=Mt(),o=Ua(),u=Ef(),a=If(),c=Xu(),f=z(),h=El().fastKey,d=lr(),v=d.set,l=d.getterFor;return vl={getConstructor:function(u,a,c,d){var g=u(function(n,r){e(n,w),v(n,{type:a,index:t(null),first:null,last:null,size:0}),f||(n.size=0),s(r)||o(r,n[d],{that:n,AS_ENTRIES:c})}),w=g.prototype,m=l(a),p=function(t,n,r){var i,e,s=m(t),o=y(t,n);return o?o.value=r:(s.last=o={index:e=h(n,!0),key:n,value:r,previous:i=s.last,next:null,removed:!1},s.first||(s.first=o),i&&(i.next=o),f?s.size++:t.size++,"F"!==e&&(s.index[e]=o)),t},y=function(t,n){var r,i=m(t),e=h(n);if("F"!==e)return i.index[e];for(r=i.first;r;r=r.next)if(r.key===n)return r};return r(w,{clear:function(){for(var n=m(this),r=n.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=null),r=r.next;n.first=n.last=null,n.index=t(null),f?n.size=0:this.size=0},delete:function(t){var n=this,r=m(n),i=y(n,t);if(i){var e=i.next,s=i.previous;delete r.index[i.index],i.removed=!0,s&&(s.next=e),e&&(e.previous=s),r.first===i&&(r.first=e),r.last===i&&(r.last=s),f?r.size--:n.size--}return!!i},forEach:function(t){for(var n,r=m(this),e=i(t,arguments.length>1?arguments[1]:void 0);n=n?n.next:r.first;)for(e(n.value,n.key,this);n&&n.removed;)n=n.previous},has:function(t){return!!y(this,t)}}),r(w,c?{get:function(t){var n=y(this,t);return n&&n.value},set:function(t,n){return p(this,0===t?0:t,n)}}:{add:function(t){return p(this,t=0===t?0:t,t)}}),f&&n(w,"size",{configurable:!0,get:function(){return m(this).size}}),g},setStrong:function(t,n,r){var i=n+" Iterator",e=l(n),s=l(i);u(t,n,function(t,n){v(this,{type:i,target:t,state:e(t),kind:n,last:null})},function(){for(var t=s(this),n=t.kind,r=t.last;r&&r.removed;)r=r.previous;return t.target&&(t.last=r=r?r.next:t.state.first)?a("keys"===n?r.key:"values"===n?r.value:[r.key,r.value],!1):(t.target=null,a(void 0,!0))},r?"entries":"values",!r,!0),c(n)}},vl}())));var Il;Il||(Il=1,Ti()({target:"Number",stat:!0,nonConfigurable:!0,nonWritable:!0},{MAX_SAFE_INTEGER:9007199254740991}));var Sl,Tl,kl,Rl={};function Al(t){return Al="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Al(t)}!function(){if(kl)return Rl;kl=1;var t=Ti(),n=function(){if(Tl)return Sl;Tl=1;var t=_(),n=j(),r=Ft(),i=pe(),e=be().trim,s=ye(),o=t.parseInt,u=t.Symbol,a=u&&u.iterator,c=/^[+-]?0x/i,f=r(c.exec),h=8!==o(s+"08")||22!==o(s+"0x16")||a&&!n(function(){o(Object(a))});return Sl=h?function(t,n){var r=e(i(t));return o(r,n>>>0||(f(c,r)?16:10))}:o}();t({global:!0,forced:parseInt!==n},{parseInt:n})}();var _l,Cl=function(){function t(t,n,r){void 0===t&&(t="WebSDK"),void 0===n&&(n=2),void 0===r&&(r="data"),this.db=null,this.dbName=t,this.version=n,this.storeName=r,this.eventsStoreName="events"}return t.prototype.openDB=function(){return Be(this,void 0,void 0,function(){var t=this;return Ge(this,function(n){return this.db?[2,this.db]:[2,new Promise(function(n,r){var i=indexedDB.open(t.dbName,t.version);i.onerror=function(){return r(i.error)},i.onsuccess=function(){t.db=i.result,n(t.db)},i.onupgradeneeded=function(n){var r=n.target.result;if(r.objectStoreNames.contains(t.storeName)||r.createObjectStore(t.storeName),!r.objectStoreNames.contains(t.eventsStoreName)){var i=r.createObjectStore(t.eventsStoreName,{keyPath:"id"});i.createIndex("timestamp","timestamp",{unique:!1}),i.createIndex("status","status",{unique:!1})}}})]})})},t.prototype.getItem=function(t){return Be(this,void 0,void 0,function(){var n,r=this;return Ge(this,function(i){switch(i.label){case 0:return[4,this.openDB()];case 1:return n=i.sent(),[2,new Promise(function(i,e){var s=n.transaction([r.storeName],"readonly").objectStore(r.storeName).get(t);s.onerror=function(){return e(s.error)},s.onsuccess=function(){var t=s.result;i(null==t?null:"string"==typeof t?t:"object"===Al(t)?JSON.stringify(t):String(t))}})]}})})},t.prototype.setItem=function(t,n){return Be(this,void 0,void 0,function(){var r,i=this;return Ge(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return r=e.sent(),[2,new Promise(function(e,s){var o=r.transaction([i.storeName],"readwrite").objectStore(i.storeName).put(n,t);o.onerror=function(){return s(o.error)},o.onsuccess=function(){return e()}})]}})})},t.prototype.removeItem=function(t){return Be(this,void 0,void 0,function(){var n,r=this;return Ge(this,function(i){switch(i.label){case 0:return[4,this.openDB()];case 1:return n=i.sent(),[2,new Promise(function(i,e){var s=n.transaction([r.storeName],"readwrite").objectStore(r.storeName).delete(t);s.onerror=function(){return e(s.error)},s.onsuccess=function(){return i()}})]}})})},t.prototype.clear=function(){return Be(this,void 0,void 0,function(){var t,n=this;return Ge(this,function(r){switch(r.label){case 0:return[4,this.openDB()];case 1:return t=r.sent(),[2,new Promise(function(r,i){var e=t.transaction([n.storeName],"readwrite").objectStore(n.storeName).clear();e.onerror=function(){return i(e.error)},e.onsuccess=function(){return r()}})]}})})},t.prototype.close=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){return this.db&&(this.db.close(),this.db=null),[2]})})},t.prototype.addEvent=function(t){return Be(this,void 0,void 0,function(){var n,r=this;return Ge(this,function(i){switch(i.label){case 0:return[4,this.openDB()];case 1:return n=i.sent(),[2,new Promise(function(i,e){var s=n.transaction([r.eventsStoreName],"readwrite").objectStore(r.eventsStoreName).add(t);s.onerror=function(){return e(s.error)},s.onsuccess=function(){return i()}})]}})})},t.prototype.getOldestPendingEvents=function(){return Be(this,arguments,void 0,function(t,n){var r,i=this;return void 0===t&&(t=50),Ge(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return r=e.sent(),[2,new Promise(function(e,s){var o=r.transaction([i.eventsStoreName],"readonly").objectStore(i.eventsStoreName).index("timestamp").openCursor(),u=[],a=0;o.onerror=function(){return s(o.error)},o.onsuccess=function(r){var i=r.target.result;if(i&&a<t){var s=i.value;"pending"===s.status&&s.accountId===n&&(u.push(s),a++),i.continue()}else e(u)}})]}})})},t.prototype.updateEventStatus=function(t,n,r,i){return Be(this,void 0,void 0,function(){var e,s=this;return Ge(this,function(o){switch(o.label){case 0:return[4,this.openDB()];case 1:return e=o.sent(),[2,new Promise(function(o,u){var a=e.transaction([s.eventsStoreName],"readwrite").objectStore(s.eventsStoreName),c=a.get(t);c.onerror=function(){return u(c.error)},c.onsuccess=function(){var e=c.result;if(e){e.status=n,e.lastAttempt=Date.now(),r&&(e.error=r),void 0!==i&&(e.attempts=i);var s=a.put(e);s.onerror=function(){return u(s.error)},s.onsuccess=function(){return o()}}else u(new Error("Event with id ".concat(t," not found")))}})]}})})},t.prototype.removeEvents=function(t){return Be(this,void 0,void 0,function(){var n,r=this;return Ge(this,function(i){switch(i.label){case 0:return[4,this.openDB()];case 1:return n=i.sent(),[2,new Promise(function(i,e){var s=n.transaction([r.eventsStoreName],"readwrite").objectStore(r.eventsStoreName),o=0,u=t.length;0!==u?t.forEach(function(t){var n=s.delete(t);n.onerror=function(){return e(n.error)},n.onsuccess=function(){++o===u&&i()}}):i()})]}})})},t.prototype.recoverOrphanedEvents=function(t){return Be(this,void 0,void 0,function(){var n,r=this;return Ge(this,function(i){switch(i.label){case 0:return[4,this.openDB()];case 1:return n=i.sent(),[2,new Promise(function(i,e){var s=n.transaction([r.eventsStoreName],"readwrite").objectStore(r.eventsStoreName).openCursor(),o=0;s.onerror=function(){return e(s.error)},s.onsuccess=function(n){var r=n.target.result;if(r){var e=r.value;if("processing"===e.status&&e.accountId===t)e.status="failed",e.lastAttempt=Date.now(),e.error="Recovered from orphaned processing state",r.update(e).onsuccess=function(){o++};r.continue()}else i(o)}})]}})})},t.prototype.getPendingEventCount=function(t){return Be(this,void 0,void 0,function(){var n,r=this;return Ge(this,function(i){switch(i.label){case 0:return[4,this.openDB()];case 1:return n=i.sent(),[2,new Promise(function(i,e){var s=n.transaction([r.eventsStoreName],"readonly").objectStore(r.eventsStoreName).openCursor(),o=0;s.onerror=function(){return e(s.error)},s.onsuccess=function(n){var r=n.target.result;if(r){var e=r.value;"pending"===e.status&&e.accountId===t&&o++,r.continue()}else i(o)}})]}})})},t.prototype.getRetryableEvents=function(){return Be(this,arguments,void 0,function(t,n){var r,i=this;return void 0===t&&(t=5),Ge(this,function(e){switch(e.label){case 0:return[4,this.openDB()];case 1:return r=e.sent(),[2,new Promise(function(e,s){var o=r.transaction([i.eventsStoreName],"readonly").objectStore(i.eventsStoreName).openCursor(),u=[];o.onerror=function(){return s(o.error)},o.onsuccess=function(r){var i=r.target.result;if(i){var s=i.value;"failed"===s.status&&s.attempts<=t&&s.accountId===n&&u.push(s),i.continue()}else e(u)}})]}})})},t}(),Ol=function(){function t(t,n,r,i,e){if(this.currentAccountId=null,this.currentCuid=null,this.currentUserIdentifierType=null,this.currentVisitorId=null,this.currentVisitorRefId=null,this.getSessionInfo=null,this.isProcessing=!1,this.processingPromise=null,this.paused=!1,this.authManager=t,this.logger=n,this.BATCH_SIZE=e||rs.BATCH_SIZE,this.RETRY_DELAYS=i||rs.DEFAULT_RETRY_DELAYS,r&&"getIndexedDBAdapter"in r){var s=r.getIndexedDBAdapter();s?(n.info("EventQueue: Reusing existing IndexedDB adapter from StorageManager"),this.storage=s):(n.warn("EventQueue: StorageManager has no IndexedDB adapter, creating new one"),this.storage=new Cl)}else r?(n.info("EventQueue: Using provided IndexedDBStorage"),this.storage=r):(n.warn("EventQueue: No storage provided, creating new IndexedDBStorage"),this.storage=new Cl)}return t.prototype.init=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.logger.info("Initializing EventQueue"),[4,this.processQueueIfIdle()];case 1:return t.sent(),this.logger.info("EventQueue initialized successfully"),[2]}})})},t.prototype.setUserContext=function(t,n,r){return Be(this,void 0,void 0,function(){var i;return Ge(this,function(e){switch(e.label){case 0:return this.currentAccountId=t,this.currentCuid=n||null,this.currentUserIdentifierType=r||null,this.logger.debug("EventQueue user context set",{accountId:t,cuid:n,userIdentifierType:r}),[4,this.storage.recoverOrphanedEvents(t)];case 1:return(i=e.sent())>0&&this.logger.info("Recovered ".concat(i," orphaned processing events for account ").concat(t)),[2]}})})},t.prototype.setVisitorContext=function(t,n){this.currentVisitorId=t,this.currentVisitorRefId=null!=n?n:null,this.logger.debug("EventQueue visitor context set",{visitorId:t,visitorRefId:n})},t.prototype.setSessionInfoCallback=function(t){this.getSessionInfo=t,this.logger.debug("EventQueue session info callback set")},t.prototype.getCurrentAccountId=function(){return this.currentAccountId},t.prototype.getCurrentCuid=function(){return this.currentCuid},t.prototype.getCurrentVisitorId=function(){return this.currentVisitorId},t.prototype.clearUserContext=function(){this.currentCuid=null,this.currentUserIdentifierType=null,this.logger.debug("EventQueue user context cleared (cuid removed)")},t.prototype.enqueue=function(t){return Be(this,arguments,void 0,function(t,n){var r,i,e,s;return void 0===n&&(n=!1),Ge(this,function(o){switch(o.label){case 0:if(o.trys.push([0,7,,8]),!this.currentAccountId)throw new Error("Cannot enqueue event: No account context set");if(r=null,!this.getSessionInfo)return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.getSessionInfo()];case 2:return r=o.sent(),[3,4];case 3:return i=o.sent(),this.logger.warn("Failed to resolve session ID at enqueue time",i),[3,4];case 4:return e={id:Ih(),event:t,accountId:this.currentAccountId,timestamp:(new Date).toISOString(),attempts:0,status:rs.STATUSES.PENDING,visitorId:this.currentVisitorId,visitorRefId:this.currentVisitorRefId,cuid:this.currentCuid,userIdentifierType:this.currentUserIdentifierType,sessionId:r,isDLR:n},[4,this.storage.addEvent(e)];case 5:return o.sent(),this.logger.debug("Event added to queue",{eventId:e.id,eventName:t.name,visitorId:e.visitorId,cuid:e.cuid,sessionId:e.sessionId,isDLR:n}),[4,this.processQueueIfIdle()];case 6:return o.sent(),[3,8];case 7:throw s=o.sent(),this.logger.error("Failed to enqueue event",{event:t,error:s}),s;case 8:return[2]}})})},t.prototype.processQueueIfIdle=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){return this.paused?(this.logger.debug("Queue processing paused, skipping"),[2]):this.isProcessing?(this.logger.debug("Queue processing already in progress, skipping"),[2]):(this.processingPromise||(this.processingPromise=this.processQueue()),[2,this.processingPromise])})})},t.prototype.getIdentityKey=function(t){var n,r,i,e,s,o=null!==(n=t.visitorId)&&void 0!==n?n:"_none_",u=null!==(r=t.visitorRefId)&&void 0!==r?r:"_none_",a=null!==(i=t.cuid)&&void 0!==i?i:"_none_",c=null!==(e=t.userIdentifierType)&&void 0!==e?e:"_none_",f=null!==(s=t.sessionId)&&void 0!==s?s:"_none_";return"".concat(o,"|").concat(u,"|").concat(a,"|").concat(c,"|").concat(f)},t.prototype.groupEventsByIdentity=function(t){var n,r,i=new Map;try{for(var e=We(t),s=e.next();!s.done;s=e.next()){var o=s.value,u=this.getIdentityKey(o),a=i.get(u);a?a.push(o):i.set(u,[o])}}catch(t){n={error:t}}finally{try{s&&!s.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return Array.from(i.values())},t.prototype.processQueue=function(){return Be(this,void 0,void 0,function(){var n=this;return Ge(this,function(r){switch(r.label){case 0:return this.isProcessing?[2]:"undefined"!=typeof navigator&&"locks"in navigator?[4,navigator.locks.request(t.QUEUE_LOCK_NAME,{ifAvailable:!0},function(t){return Be(n,void 0,void 0,function(){return Ge(this,function(n){switch(n.label){case 0:return t?[4,this.executeProcessQueue()]:(this.logger.debug("Queue lock held by another tab, skipping"),[2]);case 1:return n.sent(),[2]}})})})]:[3,2];case 1:return r.sent(),[3,4];case 2:return[4,this.executeProcessQueue()];case 3:r.sent(),r.label=4;case 4:return[2]}})})},t.prototype.executeProcessQueue=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o,u,a,c;return Ge(this,function(f){switch(f.label){case 0:this.isProcessing=!0,this.logger.debug("Starting queue processing"),f.label=1;case 1:f.trys.push([1,16,17,18]),f.label=2;case 2:return this.paused?(this.logger.debug("Queue processing paused mid-cycle, stopping"),[3,15]):[4,this.checkAndPromoteRetryEvents()];case 3:return f.sent(),this.currentAccountId?[4,this.storage.getOldestPendingEvents(this.BATCH_SIZE,this.currentAccountId)]:(this.logger.debug("No account context, skipping event processing"),[3,15]);case 4:if(0===(t=f.sent()).length)return this.logger.debug("No pending events to process"),[3,15];n=this.groupEventsByIdentity(t),this.logger.info("Processing events",{totalEvents:t.length,identityGroups:n.length}),f.label=5;case 5:f.trys.push([5,11,12,13]),a=void 0,r=We(n),i=r.next(),f.label=6;case 6:return i.done?[3,10]:(e=i.value,s=e[0],this.logger.debug("Processing identity group",{batchSize:e.length,visitorId:null==s?void 0:s.visitorId,cuid:null==s?void 0:s.cuid,sessionId:null==s?void 0:s.sessionId}),[4,this.markEventsAsProcessing(e)]);case 7:return f.sent(),[4,this.sendBatch(e)];case 8:f.sent(),f.label=9;case 9:return i=r.next(),[3,6];case 10:return[3,13];case 11:return o=f.sent(),a={error:o},[3,13];case 12:try{i&&!i.done&&(c=r.return)&&c.call(r)}finally{if(a)throw a.error}return[7];case 13:return[4,this.storage.getPendingEventCount(this.currentAccountId)];case 14:return 0===f.sent()?(this.logger.debug("No more pending events"),[3,15]):[3,2];case 15:return[3,18];case 16:return u=f.sent(),this.logger.error("Queue processing failed",u),[3,18];case 17:return this.isProcessing=!1,this.processingPromise=null,this.logger.debug("Queue processing completed"),[7];case 18:return[2]}})})},t.prototype.markEventsAsProcessing=function(t){return Be(this,void 0,void 0,function(){var n,r,i,e,s,o,u;return Ge(this,function(a){switch(a.label){case 0:a.trys.push([0,7,8,9]),n=We(t),r=n.next(),a.label=1;case 1:if(r.done)return[3,6];i=r.value,a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this.storage.updateEventStatus(i.id,"processing")];case 3:return a.sent(),[3,5];case 4:return e=a.sent(),this.logger.warn("Failed to mark event as processing",{eventId:i.id,error:e}),[3,5];case 5:return r=n.next(),[3,1];case 6:return[3,9];case 7:return s=a.sent(),o={error:s},[3,9];case 8:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}return[7];case 9:return[2]}})})},t.prototype.sendBatch=function(t){return Be(this,void 0,void 0,function(){var n,r,i,e,s,o,u,a,c;return Ge(this,function(f){switch(f.label){case 0:if(f.trys.push([0,5,,10]),!this.currentAccountId)throw new Error("Missing account context for batch sending");return n=t[0],r=!!(null!==(c=n.visitorId)&&void 0!==c?c:n.visitorRefId),i=!!n.cuid,e=r&&i?"identified":r?"anonymous":"user-only",this.logger.debug("Sending event batch",{batchSize:t.length,trackingMode:e,hasVisitor:r,hasUser:i}),s=t.filter(function(t){return!0===t.isDLR}),(o=t.filter(function(t){return!0!==t.isDLR})).length>0?[4,this.sendRegularEvents(o)]:[3,2];case 1:f.sent(),f.label=2;case 2:return s.length>0?[4,this.sendDLREvents(s)]:[3,4];case 3:f.sent(),f.label=4;case 4:return[2,!0];case 5:return u=f.sent(),a=this.isRetryableHttpError(u),this.logger.error("Failed to send batch",{batchSize:t.length,error:u,isRetryable:a}),a?[4,this.handleFailedBatch(t)]:[3,7];case 6:return f.sent(),[3,9];case 7:return[4,this.removeNonRetryableEvents(t)];case 8:f.sent(),f.label=9;case 9:return[2,!1];case 10:return[2]}})})},t.prototype.sendRegularEvents=function(t){return Be(this,void 0,void 0,function(){var n,r,i,e,s,o,u,a,c,f,h,d,v,l;return Ge(this,function(g){switch(g.label){case 0:if(n=t[0],r=null!==(f=n.visitorId)&&void 0!==f?f:null,i=null!==(h=n.visitorRefId)&&void 0!==h?h:null,e=null!==(d=n.cuid)&&void 0!==d?d:null,s=null!==(v=n.userIdentifierType)&&void 0!==v?v:null,o=null!==(l=n.sessionId)&&void 0!==l?l:null,u=this.authManager.getApiClient(),a=t.map(function(t){return t.event}),!o)throw new Error("Session ID is required for event tracking");return[4,u.sendEvents(a,r||void 0,i||void 0,e||void 0,s||void 0,o)];case 1:return c=g.sent(),[4,this.handleBatchResponse(t,c)];case 2:return g.sent(),[2]}})})},t.prototype.sendDLREvents=function(t){return Be(this,void 0,void 0,function(){var n,r,i,e,s,o,u;return Ge(this,function(a){switch(a.label){case 0:return n=t[0],r=this.authManager.getApiClient(),i=null!==(u=n.sessionId)&&void 0!==u?u:"",e=Eh(i),s={events:t.map(function(t){return t.event}),request_id:Ih(),system_data:e},n.cuid?s.user={identifierName:"id",identifierValue:n.cuid}:n.visitorId&&(s.visitor={identifierName:"id",identifierValue:n.visitorId}),[4,r.sendDLR(s)];case 1:return o=a.sent(),[4,this.handleBatchResponse(t,o)];case 2:return a.sent(),[2]}})})},t.prototype.removeSuccessfulEvents=function(t){return Be(this,void 0,void 0,function(){var n,r;return Ge(this,function(i){switch(i.label){case 0:n=t.map(function(t){return t.id}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.storage.removeEvents(n)];case 2:return i.sent(),this.logger.debug("Successfully removed events from storage",{count:n.length}),[3,4];case 3:return r=i.sent(),this.logger.error("Failed to remove events from storage",{eventIds:n,error:r}),[3,4];case 4:return[2]}})})},t.prototype.handleBatchResponse=function(t,n){return Be(this,void 0,void 0,function(){var r;return Ge(this,function(i){switch(i.label){case 0:return(r=n.status.code)!==rs.GLOBAL_SUCCESS_CODE?[3,2]:[4,this.removeSuccessfulEvents(t)];case 1:return i.sent(),this.logger.info("All events processed successfully",{count:t.length}),[3,8];case 2:return r!==rs.PARTIAL_SUCCESS_CODE?[3,4]:[4,this.handlePartialSuccess(t,n.events)];case 3:return i.sent(),[3,8];case 4:return rs.RETRYABLE_HTTP_CODES.includes(parseInt(r))?[4,this.handleFailedBatch(t)]:[3,6];case 5:return i.sent(),this.logger.warn("Batch failed with retryable error",{code:r,message:n.status.message}),[3,8];case 6:return[4,this.removeNonRetryableEvents(t)];case 7:i.sent(),this.logger.error("Batch failed with non-retryable error",{code:r,message:n.status.message}),i.label=8;case 8:return[2]}})})},t.prototype.handlePartialSuccess=function(t,n){return Be(this,void 0,void 0,function(){var r,i,e,s,o,u,a,c,f;return Ge(this,function(h){switch(h.label){case 0:r=new Map,n.forEach(function(t){r.set(t.eventRefId,t)}),h.label=1;case 1:h.trys.push([1,12,13,14]),i=We(t),e=i.next(),h.label=2;case 2:return e.done?[3,11]:(s=e.value,(o=r.get(s.event.eventRefId))?[3,4]:[4,this.markEventForRetry(s,"No response received")]);case 3:return h.sent(),[3,10];case 4:return o.status.success?[4,this.storage.removeEvents([s.id])]:[3,6];case 5:return h.sent(),this.logger.debug("Event processed successfully",{eventId:s.id}),[3,10];case 6:return u=parseInt(o.status.code),rs.RETRYABLE_HTTP_CODES.includes(u)?[4,this.markEventForRetry(s,o.status.message)]:[3,8];case 7:return h.sent(),this.logger.debug("Event marked for retry",{eventId:s.id,code:u,message:o.status.message}),[3,10];case 8:return[4,this.storage.removeEvents([s.id])];case 9:h.sent(),this.logger.warn("Event permanently failed - removed",{eventId:s.id,code:u,message:o.status.message}),h.label=10;case 10:return e=i.next(),[3,2];case 11:return[3,14];case 12:return a=h.sent(),c={error:a},[3,14];case 13:try{e&&!e.done&&(f=i.return)&&f.call(i)}finally{if(c)throw c.error}return[7];case 14:return[2]}})})},t.prototype.markEventForRetry=function(t,n){return Be(this,void 0,void 0,function(){var r,i,e;return Ge(this,function(s){switch(s.label){case 0:return r=(t.attempts||0)+1,[4,this.storage.updateEventStatus(t.id,"failed","Attempt ".concat(r," failed: ").concat(n),r)];case 1:return s.sent(),i=Math.min(Math.max(r-1,0),this.RETRY_DELAYS.length-1),e=this.RETRY_DELAYS[i],this.logger.debug("Event marked for retry",{eventId:t.id,attempts:r,delay:e,isInfiniteRetry:r>this.RETRY_DELAYS.length}),[2]}})})},t.prototype.checkAndPromoteRetryEvents=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o,u,a,c,f,h;return Ge(this,function(d){switch(d.label){case 0:return d.trys.push([0,10,,11]),this.currentAccountId?[4,this.storage.getRetryableEvents(Number.MAX_SAFE_INTEGER,this.currentAccountId)]:(this.logger.debug("No account context, skipping retry check"),[2]);case 1:if(0===(t=d.sent()).length)return[2];n=0,d.label=2;case 2:d.trys.push([2,7,8,9]),r=We(t),i=r.next(),d.label=3;case 3:return i.done?[3,6]:(e=i.value,s=Math.min(Math.max(e.attempts-1,0),this.RETRY_DELAYS.length-1),o=this.RETRY_DELAYS[s],(u=Date.now()-(e.lastAttempt||0))>=(o||0)?[4,this.storage.updateEventStatus(e.id,"pending")]:[3,5]);case 4:d.sent(),n++,this.logger.debug("Failed event promoted to pending",{eventId:e.id,attempt:e.attempts+1,delay:o,timeSinceLastAttempt:u}),d.label=5;case 5:return i=r.next(),[3,3];case 6:return[3,9];case 7:return a=d.sent(),f={error:a},[3,9];case 8:try{i&&!i.done&&(h=r.return)&&h.call(r)}finally{if(f)throw f.error}return[7];case 9:return n>0&&this.logger.debug("Promoted ".concat(n," failed events for retry")),[3,11];case 10:return c=d.sent(),this.logger.error("Failed to check retry events",c),[3,11];case 11:return[2]}})})},t.prototype.isRetryableHttpError=function(t){var n,r,i;if(t.code){var e=parseInt(t.code);return rs.RETRYABLE_HTTP_CODES.includes(e)}return(null===(n=t.message)||void 0===n?void 0:n.includes("network"))||(null===(r=t.message)||void 0===r?void 0:r.includes("timeout"))||(null===(i=t.message)||void 0===i?void 0:i.includes("fetch"))},t.prototype.removeNonRetryableEvents=function(t){return Be(this,void 0,void 0,function(){var n,r;return Ge(this,function(i){switch(i.label){case 0:n=t.map(function(t){return t.id}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.storage.removeEvents(n)];case 2:return i.sent(),this.logger.warn("Non-retryable events removed permanently",{eventIds:n}),[3,4];case 3:return r=i.sent(),this.logger.error("Failed to remove non-retryable events",{eventIds:n,error:r}),[3,4];case 4:return[2]}})})},t.prototype.handleFailedBatch=function(t){return Be(this,void 0,void 0,function(){var n,r,i,e,s,o,u;return Ge(this,function(a){switch(a.label){case 0:a.trys.push([0,7,8,9]),n=We(t),r=n.next(),a.label=1;case 1:if(r.done)return[3,6];i=r.value,a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this.markEventForRetry(i,"Batch failed")];case 3:return a.sent(),[3,5];case 4:return e=a.sent(),this.logger.error("Failed to mark event for retry",{eventId:i.id,error:e}),[3,5];case 5:return r=n.next(),[3,1];case 6:return[3,9];case 7:return s=a.sent(),o={error:s},[3,9];case 8:try{r&&!r.done&&(u=n.return)&&u.call(n)}finally{if(o)throw o.error}return[7];case 9:return[2]}})})},t.prototype.pause=function(){this.paused=!0,this.logger.info("EventQueue paused")},t.prototype.resume=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.paused=!1,this.logger.info("EventQueue resumed"),[4,this.processQueueIfIdle()];case 1:return t.sent(),[2]}})})},t.prototype.flush=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.logger.info("Manual flush requested"),[4,this.processQueueIfIdle()];case 1:return t.sent(),[2]}})})},t.prototype.destroy=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.logger.info("Destroying EventQueue"),this.processingPromise?[4,this.processingPromise]:[3,2];case 1:t.sent(),t.label=2;case 2:return[4,this.storage.close()];case 3:return t.sent(),this.logger.info("EventQueue destroyed"),[2]}})})},t.QUEUE_LOCK_NAME="websdk-event-queue-lock",t}(),Dl=function(){function t(t,n,r,i){this.eventQueue=null,this.initialized=!1,this.visitorId=null,this.visitorTrackingEnabled=null,this.config=t,this.logger=i,this.authManager=n,this.storageManager=r}return t.prototype.init=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.initialized?(this.logger.warn("EventTracker already initialized"),[2]):(this.logger.info("Initializing EventTracker with IndexedDB queue"),this.eventQueue=new Ol(this.authManager,this.logger,this.storageManager,this.config.retryDelays,this.config.batchSize),[4,this.eventQueue.init()]);case 1:return t.sent(),this.initialized=!0,this.logger.info(Cs),[2]}})})},t.prototype.setUserContext=function(t,n,r){return Be(this,void 0,void 0,function(){return Ge(this,function(i){switch(i.label){case 0:if(!this.eventQueue)throw new Error("EventTracker not initialized");return[4,this.eventQueue.setUserContext(t,n,r)];case 1:return i.sent(),this.logger.info("User context set",{accountId:t,cuid:n,userIdentifierType:r}),[2]}})})},t.prototype.setVisitorTrackingState=function(t,n,r){this.visitorId=t,this.visitorTrackingEnabled=n,this.eventQueue&&this.eventQueue.setVisitorContext(t,r),this.logger.debug("Visitor tracking state updated",{visitorId:t,visitorRefId:r,isEnabled:n,trackingMode:t?"anonymous":"not-configured"})},t.prototype.setSessionInfoCallback=function(t){if(!this.eventQueue)throw new Error("EventTracker not initialized");this.eventQueue.setSessionInfoCallback(t),this.logger.debug("Session info callback set in EventTracker")},t.prototype.clearUserContext=function(){this.eventQueue?(this.eventQueue.clearUserContext(),this.logger.info("User context cleared from EventTracker")):this.logger.warn("Cannot clear user context - EventTracker not initialized")},t.prototype.track=function(t){return Be(this,void 0,void 0,function(){var n,r;return Ge(this,function(i){switch(i.label){case 0:if(!this.initialized||!this.eventQueue)throw new Error("EventTracker not initialized");if(!1===this.visitorTrackingEnabled)throw this.logger.warn("Event tracking is disabled - visitor tracking is not enabled"),new Error("Event tracking is disabled");this.logger.debug("Tracking event",{event:t}),i.label=1;case 1:return i.trys.push([1,3,,4]),n=this.convertToApiEvent(t),[4,this.eventQueue.enqueue(n)];case 2:return i.sent(),[3,4];case 3:throw r=i.sent(),this.logger.error(Ds,{event:t,error:r}),new Error("".concat(ws,": ").concat(r));case 4:return[2]}})})},t.prototype.convertToApiEvent=function(t){if(!t.name||""===t.name.trim())throw new Error("Event name is required");var n=Le({},t.data);if(!this.eventQueue)throw new Error("EventTracker not initialized");var r=this.eventQueue.getCurrentCuid();if(!r&&!this.visitorId){var i=null===this.visitorTrackingEnabled?"Cannot track event: User must be identified (cuid) or visitor tracking must be configured":"Cannot track event: Either visitor tracking must be enabled or user must be identified";throw this.logger.error(i,{hasVisitorId:!!this.visitorId,hasCuid:!!r,visitorTrackingEnabled:this.visitorTrackingEnabled}),new Error(i)}var e=this.visitorId&&r?"identified":this.visitorId?"anonymous":"user-only";return this.logger.debug("Creating event payload",{eventName:t.name,hasCuid:!!r,hasVisitorId:!!this.visitorId,trackingMode:e,visitorTrackingEnabled:this.visitorTrackingEnabled}),function(t,n){if(!t||""===t.trim())throw new Error("Event name is required");return{name:t.trim(),eventRefId:Ih(),eventDateTime:(new Date).toISOString(),attributes:n||{}}}(t.name,n)},t.prototype.pause=function(){this.eventQueue&&this.eventQueue.pause(),this.logger.info("EventTracker paused")},t.prototype.resume=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.eventQueue?[4,this.eventQueue.resume()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.logger.info("EventTracker resumed"),[2]}})})},t.prototype.flush=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.initialized&&this.eventQueue?(this.logger.info("Manual flush requested"),[4,this.eventQueue.flush()]):(this.logger.warn("Cannot flush events - EventTracker not initialized"),[2]);case 1:return t.sent(),[2]}})})},t.prototype.destroy=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.logger.info("Destroying EventTracker"),this.eventQueue?[4,this.eventQueue.destroy()]:[3,2];case 1:t.sent(),t.label=2;case 2:return this.initialized=!1,this.logger.info(Os),[2]}})})},t.prototype.trackNotificationReceived=function(t){return Be(this,void 0,void 0,function(){return Ge(this,function(n){switch(n.label){case 0:return[4,this.trackDLREvent("received",t)];case 1:return n.sent(),[2]}})})},t.prototype.trackNotificationClicked=function(t){return Be(this,void 0,void 0,function(){return Ge(this,function(n){switch(n.label){case 0:return[4,this.trackDLREvent("clicked",t)];case 1:return n.sent(),[2]}})})},t.prototype.trackNotificationDismissed=function(t){return Be(this,void 0,void 0,function(){return Ge(this,function(n){switch(n.label){case 0:return[4,this.trackDLREvent("dismissed",t)];case 1:return n.sent(),[2]}})})},t.prototype.trackDLREvent=function(t,n){return Be(this,void 0,void 0,function(){var r,i;return Ge(this,function(e){switch(e.label){case 0:if(!this.initialized||!this.eventQueue)return this.logger.warn("EventTracker not initialized, skipping DLR event",{eventType:t}),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),r=this.createDLREvent(t,n),[4,this.eventQueue.enqueue(r,!0)];case 2:return e.sent(),this.logger.info("DLR event tracked: ".concat(t),{eventType:t,eventName:r.name,messageId:n.messageId}),[3,4];case 3:return i=e.sent(),this.logger.error("Failed to track DLR event",{eventType:t,notificationData:n,error:i}),[3,4];case 4:return[2]}})})},t.prototype.createDLREvent=function(t,n){var r,i={received:Po.NOTIFICATION_RECEIVED,clicked:Po.NOTIFICATION_CLICKED,dismissed:Po.NOTIFICATION_DISMISSED},e=null===(r=this.eventQueue)||void 0===r?void 0:r.getCurrentCuid(),s={messageId:n.messageId,gateway:Uo,result:{received:"SUCCESS",clicked:"CLICKED",dismissed:"DISMISSED"}[t],notification_route:jo,cuid:e||null,visitor_id:e?null:this.visitorId||null,scope:n.scope||null};return n.senderId&&(s.senderId=n.senderId),{attributes:s,name:i[t],eventDateTime:(new Date).toISOString(),eventRefId:Ih()}},t.prototype.processPendingServiceWorkerDLREvents=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o,u,a;return Ge(this,function(c){switch(c.label){case 0:if(!this.initialized)return[2];c.label=1;case 1:return c.trys.push([1,17,,18]),[4,this.getServiceWorkerPendingDLREvents()];case 2:if(0===(t=c.sent()).length)return[2];this.logger.info("Processing pending service worker DLR events",{count:t.length}),c.label=3;case 3:c.trys.push([3,13,14,15]),n=We(t),r=n.next(),c.label=4;case 4:if(r.done)return[3,12];switch(i=r.value,e={messageId:i.messageId,scope:i.scope,campaignId:i.campaignId,variationId:i.variationId,senderId:i.senderId,cuid:i.cuid,accountId:i.accountId},i.type){case"received":return[3,5];case"clicked":return[3,7];case"dismissed":return[3,9]}return[3,11];case 5:return[4,this.trackNotificationReceived(e)];case 6:return c.sent(),[3,11];case 7:return[4,this.trackNotificationClicked(e)];case 8:return c.sent(),[3,11];case 9:return[4,this.trackNotificationDismissed(e)];case 10:return c.sent(),[3,11];case 11:return r=n.next(),[3,4];case 12:return[3,15];case 13:return s=c.sent(),u={error:s},[3,15];case 14:try{r&&!r.done&&(a=n.return)&&a.call(n)}finally{if(u)throw u.error}return[7];case 15:return[4,this.clearServiceWorkerPendingDLREvents()];case 16:return c.sent(),this.logger.info("Processed pending service worker DLR events",{count:t.length}),[3,18];case 17:return o=c.sent(),this.logger.error("Failed to process pending service worker DLR events",o),[3,18];case 18:return[2]}})})},t.prototype.getServiceWorkerPendingDLREvents=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){return[2,new Promise(function(t){var n=indexedDB.open("WebSDK_DLR_SW",1);n.onerror=function(){return t([])},n.onsuccess=function(){var r=n.result;if(!r.objectStoreNames.contains("pending_dlr_events"))return r.close(),void t([]);var i=r.transaction(["pending_dlr_events"],"readonly").objectStore("pending_dlr_events").getAll();i.onerror=function(){r.close(),t([])},i.onsuccess=function(){r.close(),t(i.result||[])}},n.onupgradeneeded=function(t){var n=t.target.result;n.objectStoreNames.contains("pending_dlr_events")||n.createObjectStore("pending_dlr_events",{keyPath:"id",autoIncrement:!0})}})]})})},t.prototype.clearServiceWorkerPendingDLREvents=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){return[2,new Promise(function(t){var n=indexedDB.open("WebSDK_DLR_SW",1);n.onerror=function(){return t()},n.onsuccess=function(){var r=n.result;if(!r.objectStoreNames.contains("pending_dlr_events"))return r.close(),void t();var i=r.transaction(["pending_dlr_events"],"readwrite").objectStore("pending_dlr_events").clear();i.onerror=function(){r.close(),t()},i.onsuccess=function(){r.close(),t()}},n.onupgradeneeded=function(t){var n=t.target.result;n.objectStoreNames.contains("pending_dlr_events")||n.createObjectStore("pending_dlr_events",{keyPath:"id",autoIncrement:!0})}})]})})},t}(),Fl=function(){function t(t,n,r){this.initialized=!1,this.nonceData=null,this.config=t,this.logger=n,this.storageManager=r,this.apiClient=new Qv({baseUrl:t.baseURL||""},n,t.accountId||"",t.orgId||"",t.source||Fo.WEBPUSH)}return t.prototype.init=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){return this.initialized?(this.logger.warn("AuthManager already initialized"),[2]):(this.logger.info("Initializing AuthManager",{accountId:this.config.accountId}),this.initialized=!0,this.logger.info(Ss),[2])})})},t.prototype.requestNonce=function(){return Be(this,void 0,void 0,function(){var t,n,r;return Ge(this,function(i){switch(i.label){case 0:if(!this.initialized)throw new Error("AuthManager not initialized");this.logger.info("Requesting nonce for authentication"),i.label=1;case 1:return i.trys.push([1,4,,5]),t=function(){try{return window.location.hostname||"unknown"}catch(t){return"unknown"}}(),[4,this.apiClient.getNonce(t)];case 2:return n=i.sent(),this.nonceData={nonce:n.nonce,challengeId:n.challenge_id,expiresAt:n.expires_at},[4,this.storeNonceData()];case 3:return i.sent(),this.logger.info(Es,{challengeId:n.challenge_id,expiresAt:n.expires_at}),[2,this.nonceData];case 4:throw r=i.sent(),this.logger.error(Is,r),r;case 5:return[2]}})})},t.prototype.ensureValidNonce=function(){return Be(this,void 0,void 0,function(){var t;return Ge(this,function(n){switch(n.label){case 0:if(!this.initialized)throw new Error("AuthManager not initialized");this.logger.info("Ensuring valid nonce"),n.label=1;case 1:return n.trys.push([1,4,,5]),[4,this.restoreNonceData()];case 2:return n.sent(),this.nonceData&&!this.isNonceExpired(this.nonceData.expiresAt)?(this.logger.info("Using existing valid nonce"),[2,this.nonceData]):(this.logger.info("No valid nonce found, requesting fresh"),[4,this.requestNonce()]);case 3:return[2,n.sent()];case 4:throw t=n.sent(),this.logger.error("Failed to ensure valid nonce",t),t;case 5:return[2]}})})},t.prototype.getNonceData=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return[4,this.ensureValidNonce()];case 1:return[2,t.sent()]}})})},t.prototype.isNonceExpired=function(t){return Date.now()>=t-ts},t.prototype.hasValidNonce=function(){return!!this.nonceData&&!this.isNonceExpired(this.nonceData.expiresAt)},t.prototype.getApiClient=function(){return this.apiClient},t.prototype.storeNonceData=function(){return Be(this,void 0,void 0,function(){var t;return Ge(this,function(n){switch(n.label){case 0:if(!this.nonceData)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.storageManager.set(os.NONCE_DATA,JSON.stringify(this.nonceData))];case 2:return n.sent(),[3,4];case 3:return t=n.sent(),this.logger.warn(Rs,t),[3,4];case 4:return[2]}})})},t.prototype.restoreNonceData=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.storageManager.get(os.NONCE_DATA)];case 1:return(t=r.sent())&&(this.nonceData=JSON.parse(t),this.logger.info("Nonce data restored from storage")),[3,3];case 2:return n=r.sent(),this.logger.warn(As,n),this.nonceData=null,[3,3];case 3:return[2]}})})},t.prototype.clearNonceData=function(){return Be(this,void 0,void 0,function(){var t;return Ge(this,function(n){switch(n.label){case 0:this.nonceData=null,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.storageManager.remove(os.NONCE_DATA)];case 2:return n.sent(),[3,4];case 3:return t=n.sent(),this.logger.warn(_s,t),[3,4];case 4:return[2]}})})},t.prototype.destroy=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.logger.info("Destroying AuthManager"),[4,this.clearNonceData()];case 1:return t.sent(),this.initialized=!1,this.logger.info("AuthManager destroyed successfully"),[2]}})})},t}(),Nl=function(){function t(t,n,r){this.initialized=!1,this.logger=t,this.brandId=n,this.applicationId=r,this.adapter=new xl}return t.prototype.init=function(){return Be(this,void 0,void 0,function(){var t,n,r,i;return Ge(this,function(e){switch(e.label){case 0:if(this.initialized)return this.logger.warn("StorageManager already initialized"),[2];this.logger.info("Initializing StorageManager"),e.label=1;case 1:return e.trys.push([1,6,,7]),this.isIndexedDBSupported()?(t=["WebSDK"],this.brandId&&t.push(this.brandId),this.applicationId&&t.push(this.applicationId),n=t.join("_"),r=new Cl(n),[4,this.testStorageAdapter(r)]):[3,3];case 2:return e.sent(),this.adapter=r,this.logger.info("StorageManager initialized with IndexedDB",{dbName:n,brandId:this.brandId,applicationId:this.applicationId}),[3,5];case 3:return[4,this.testStorageAdapter(this.adapter)];case 4:e.sent(),this.logger.info("StorageManager initialized with localStorage"),e.label=5;case 5:return this.initialized=!0,[3,7];case 6:throw i=e.sent(),this.logger.error(xs,i),new Error("Storage initialization failed: ".concat(i));case 7:return[2]}})})},t.prototype.isIndexedDBSupported=function(){return"undefined"!=typeof window&&"indexedDB"in window&&null!==indexedDB},t.prototype.testStorageAdapter=function(t){return Be(this,void 0,void 0,function(){var n,r,i;return Ge(this,function(e){switch(e.label){case 0:n=hs,r=ds,e.label=1;case 1:return e.trys.push([1,5,,6]),[4,t.setItem(n,r)];case 2:return e.sent(),[4,t.getItem(n)];case 3:if(e.sent()!==r)throw new Error(Ps);return[4,t.removeItem(n)];case 4:return e.sent(),[3,6];case 5:throw i=e.sent(),new Error("".concat(Ms," ").concat(i));case 6:return[2]}})})},t.prototype.get=function(t){return Be(this,void 0,void 0,function(){return Ge(this,function(n){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.getItem(t)]})})},t.prototype.set=function(t,n){return Be(this,void 0,void 0,function(){return Ge(this,function(r){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.setItem(t,n)]})})},t.prototype.remove=function(t){return Be(this,void 0,void 0,function(){return Ge(this,function(n){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.removeItem(t)]})})},t.prototype.clear=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){if(!this.initialized)throw new Error("StorageManager not initialized");return[2,this.adapter.clear()]})})},t.prototype.getIndexedDBAdapter=function(){return this.adapter instanceof Cl?this.adapter:null},t.prototype.destroy=function(){return Be(this,void 0,void 0,function(){var t;return Ge(this,function(n){switch(n.label){case 0:this.logger.info("Destroying StorageManager"),n.label=1;case 1:return n.trys.push([1,4,,5]),this.adapter instanceof Cl?[4,this.adapter.close()]:[3,3];case 2:n.sent(),n.label=3;case 3:return this.initialized=!1,this.logger.info(Us),[3,5];case 4:return t=n.sent(),this.logger.error(js,t),this.initialized=!1,[3,5];case 5:return[2]}})})},t}(),xl=function(){function t(){}return t.prototype.getItem=function(t){return Be(this,void 0,void 0,function(){return Ge(this,function(n){try{return[2,localStorage.getItem(t)]}catch(t){throw new Error("LocalStorage getItem failed: ".concat(t))}return[2]})})},t.prototype.setItem=function(t,n){return Be(this,void 0,void 0,function(){return Ge(this,function(r){try{localStorage.setItem(t,n)}catch(t){if(t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name))throw new Error("LocalStorage quota exceeded");throw new Error("LocalStorage setItem failed: ".concat(t))}return[2]})})},t.prototype.removeItem=function(t){return Be(this,void 0,void 0,function(){return Ge(this,function(n){try{localStorage.removeItem(t)}catch(t){throw new Error("LocalStorage removeItem failed: ".concat(t))}return[2]})})},t.prototype.clear=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){try{localStorage.clear()}catch(t){throw new Error("LocalStorage clear failed: ".concat(t))}return[2]})})},t}();!function(t){t[t.VERBOSE=0]="VERBOSE",t[t.DEBUG=1]="DEBUG",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.NONE=5]="NONE"}(_l||(_l={}));var Ml,Pl,Ul=function(){function t(t,n){void 0===t&&(t=!1),void 0===n&&(n=_l.INFO),this.logs=[],this.maxLogs=1e3,this.enabled=t,this.level=n}return t.prototype.formatMessage=function(t,n){var r=(new Date).toISOString(),i=_l[t];return"[".concat(r,"] [WebSDK:").concat(i,"] ").concat(n)},t.prototype.log=function(t,n,r){if(this.enabled&&!(t<this.level)){var i={level:t,message:n,timestamp:Date.now(),data:r};this.logs.push(i),this.logs.length>this.maxLogs&&this.logs.shift();var e=this.formatMessage(t,n),s=r?[e,r]:[e];switch(t){case _l.VERBOSE:case _l.DEBUG:console.debug.apply(console,Ke([],qe(s),!1));break;case _l.INFO:console.info.apply(console,Ke([],qe(s),!1));break;case _l.WARN:console.warn.apply(console,Ke([],qe(s),!1));break;case _l.ERROR:console.error.apply(console,Ke([],qe(s),!1))}}},t.prototype.verbose=function(t,n){this.log(_l.VERBOSE,t,n)},t.prototype.debug=function(t,n){this.log(_l.DEBUG,t,n)},t.prototype.info=function(t,n){this.log(_l.INFO,t,n)},t.prototype.warn=function(t,n){this.log(_l.WARN,t,n)},t.prototype.error=function(t,n){this.log(_l.ERROR,t,n)},t.prototype.setLevel=function(t){this.level=t},t.prototype.setEnabled=function(t){this.enabled=t},t.prototype.getLogs=function(){return Ke([],qe(this.logs),!1)},t.prototype.clearLogs=function(){this.logs=[]},t}(),jl=function(){function t(t,n,r,i,e,s,o){this.initialized=!1,this.cachedConfig=null,this.orgId=t,this.vapId=n,this.apiClient=r,this.logger=i,this.storageManager=e,this.brandId=s,this.applicationId=o}return t.prototype.init=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.initialized?(this.logger.warn("VisitorConfigManager already initialized"),[2]):(this.logger.info("Initializing VisitorConfigManager",{orgId:this.orgId,vapId:this.vapId}),[4,this.restoreCachedConfig()]);case 1:return t.sent(),this.initialized=!0,this.logger.info($s),[2]}})})},t.prototype.fetchConfig=function(){return Be(this,void 0,void 0,function(){var t,n,r,i=this;return Ge(this,function(e){switch(e.label){case 0:if(!this.initialized)throw new Error("VisitorConfigManager not initialized");if(this.cachedConfig)return this.logger.info(to),[2,this.cachedConfig];e.label=1;case 1:return e.trys.push([1,4,,5]),this.logger.info("Fetching visitor config from API",{orgId:this.orgId,vapId:this.vapId}),[4,this.apiClient.getVisitorConfig(this.orgId,this.vapId)];case 2:return(t=e.sent()).warnings&&t.warnings.length>0&&t.warnings.forEach(function(t){i.logger.warn("Visitor config warning",{code:t.code,message:t.message})}),t.errors&&t.errors.length>0&&t.errors.forEach(function(t){i.logger.error("Visitor config error from response",{code:t.code,message:t.message})}),this.cachedConfig=t,[4,this.storeCachedConfig(t)];case 3:return e.sent(),this.logger.info(Js,{isEnabled:null===(r=t.data)||void 0===r?void 0:r.visitorTrackingEnabled}),[2,t];case 4:throw n=e.sent(),this.logger.error(Qs,n),new Error("".concat(ms,": ").concat(n));case 5:return[2]}})})},t.prototype.isVisitorTrackingEnabled=function(){return Be(this,void 0,void 0,function(){var t,n,r,i;return Ge(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.fetchConfig()];case 1:return t=e.sent(),(n=!0===(null===(i=t.data)||void 0===i?void 0:i.visitorTrackingEnabled))?this.logger.info(Zs):this.logger.info(Ys),[2,n];case 2:return r=e.sent(),this.logger.error("Failed to check visitor tracking status",r),[2,!1];case 3:return[2]}})})},t.prototype.refreshConfig=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){if(!this.initialized)throw new Error("VisitorConfigManager not initialized");return this.logger.info("Force refreshing visitor config from API"),this.cachedConfig=null,[2,this.fetchConfig()]})})},t.prototype.getCachedConfig=function(){return this.cachedConfig},t.prototype.storeCachedConfig=function(t){return Be(this,void 0,void 0,function(){var n,r;return Ge(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=us("VISITOR_CONFIG",this.brandId,this.applicationId),[4,this.storageManager.set(n,JSON.stringify(t))];case 1:return i.sent(),this.logger.debug("Visitor config cached to storage",{key:n}),[3,3];case 2:return r=i.sent(),this.logger.warn("Failed to store visitor config to cache",r),[3,3];case 3:return[2]}})})},t.prototype.restoreCachedConfig=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e;return Ge(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),t=us("VISITOR_CONFIG",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(n=s.sent())&&(r=JSON.parse(n),this.cachedConfig=r,this.logger.info("Visitor config restored from cache",{isEnabled:null===(e=r.data)||void 0===e?void 0:e.visitorTrackingEnabled})),[3,3];case 2:return i=s.sent(),this.logger.warn("Failed to restore visitor config from cache",i),this.cachedConfig=null,[3,3];case 3:return[2]}})})},t.prototype.clearCachedConfig=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:this.cachedConfig=null,r.label=1;case 1:return r.trys.push([1,3,,4]),t=us("VISITOR_CONFIG",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 2:return r.sent(),this.logger.debug("Visitor config cache cleared"),[3,4];case 3:return n=r.sent(),this.logger.warn("Failed to clear visitor config cache",n),[3,4];case 4:return[2]}})})},t.prototype.destroy=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.logger.info("Destroying VisitorConfigManager"),[4,this.clearCachedConfig()];case 1:return t.sent(),this.initialized=!1,this.logger.info("VisitorConfigManager destroyed successfully"),[2]}})})},t}(),zl={};Pl||(Pl=1,function(){if(Ml)return zl;Ml=1;var t=Ti(),n=_();t({global:!0,forced:n.globalThis!==n},{globalThis:n})}());var Vl,Ll=function(){function t(t,n,r,i,e,s,o,u,a){this.initialized=!1,this.visitorId=null,this.visitorRefId=null,this.expiredAt=null,this.getFcmToken=null,this.getChannelType=null,this.getExtendedFields=null,this.mergeRetryTimeoutId=null,this.accountId=t,this.orgId=n,this.vapId=r,this.source=i,this.apiClient=e,this.logger=s,this.storageManager=o,this.brandId=u,this.applicationId=a}return t.prototype.setMergeDataProviders=function(t,n,r){this.getFcmToken=t,this.getChannelType=n,this.getExtendedFields=r},t.prototype.init=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.initialized?(this.logger.warn("AnonymousVisitorManager already initialized"),[2]):(this.logger.info("Initializing AnonymousVisitorManager",{accountId:this.accountId,orgId:this.orgId,vapId:this.vapId}),[4,this.restoreVisitorId()]);case 1:return t.sent(),this.initialized=!0,this.logger.info(no),[2]}})})},t.prototype.getOrCreateVisitorId=function(t,n){return Be(this,void 0,void 0,function(){var r,i,e,s,o;return Ge(this,function(u){switch(u.label){case 0:if(!this.initialized)throw new Error("AnonymousVisitorManager not initialized");if(this.visitorId&&!this.isVisitorExpired())return this.logger.info(so,{visitorId:this.visitorId}),[2,this.visitorId];if(this.visitorId&&this.isVisitorExpired()&&this.logger.info("Visitor session expired, creating new visitor via API",{visitorId:this.visitorId,expiredAt:this.expiredAt}),!this.accountId||""===this.accountId.trim())throw r=new Error("AccountId is required for visitor creation"),this.logger.error("Visitor creation validation failed",r),r;u.label=1;case 1:return u.trys.push([1,5,,6]),this.logger.info("Creating new visitor ID",{accountId:this.accountId,hasCommChannels:!!t&&t.length>0,hasExtendedFields:!!n}),[4,this.createVisitor(t,n)];case 2:return i=u.sent(),e=i.visitorId,s=i.expiredAt,this.visitorId=e,[4,this.storeVisitorId(e)];case 3:return u.sent(),[4,this.storeExpiredAt(s)];case 4:return u.sent(),this.logger.info(ro,{visitorId:e}),[2,e];case 5:throw o=u.sent(),this.logger.error(io,o),o;case 6:return[2]}})})},t.prototype.createVisitor=function(t,n){return Be(this,void 0,void 0,function(){var r,i,e,s,o;return Ge(this,function(u){switch(u.label){case 0:return u.trys.push([0,3,,4]),[4,this.getOrGenerateVisitorRefId()];case 1:return r=u.sent(),i=t&&t.length>0?t:[],e=Le({visitorRefId:r,profiles:[{source:this.source,accountId:this.accountId,commChannels:i}]},n&&{extendedFields:n}),this.logger.debug("Visitor creation request payload",{request:e}),[4,this.apiClient.createVisitor(this.orgId,this.vapId,e)];case 2:return s=u.sent(),[2,this.handleCreateVisitorResponse(s)];case 3:throw o=u.sent(),this.handleCreateVisitorError(o),o;case 4:return[2]}})})},t.prototype.handleCreateVisitorResponse=function(t){var n,r,i=this;t.warnings&&t.warnings.length>0&&t.warnings.forEach(function(t){i.logger.warn("Visitor creation warning",{code:t.code,message:t.message})}),t.errors&&t.errors.length>0&&t.errors.forEach(function(t){i.logger.error("Visitor creation error from response",{code:t.code,message:t.message})});var e=null===(n=t.data)||void 0===n?void 0:n.id;if(!e||""===e.trim())throw new Error("Invalid visitor ID received from API");var s=null===(r=t.data)||void 0===r?void 0:r.expiredAt;if(!s)throw new Error("Missing expiredAt in visitor creation response");return{visitorId:e,expiredAt:s}},t.prototype.handleCreateVisitorError=function(t){var n,r=this;try{var i=(null===(n=t.response)||void 0===n?void 0:n.data)||t;i.warnings&&i.warnings.length>0&&i.warnings.forEach(function(t){t.code===xo.ACCOUNT_NOT_EXISTS?r.logger.error("Account does not exist",{code:t.code,message:t.message,accountId:r.accountId}):r.logger.warn("Visitor creation warning",{code:t.code,message:t.message})}),i.errors&&i.errors.length>0&&i.errors.forEach(function(t){t.code===xo.ACCOUNT_ID_NOT_PASSED?r.logger.error("AccountId not passed",{code:t.code,message:t.message}):r.logger.error("Visitor creation error",{code:t.code,message:t.message})})}catch(t){this.logger.warn("Failed to parse visitor creation error",t)}},t.prototype.updateVisitor=function(t,n){return Be(this,void 0,void 0,function(){var r,i,e,s,o;return Ge(this,function(u){switch(u.label){case 0:if(!this.initialized)throw new Error("AnonymousVisitorManager not initialized");if(!this.visitorId)throw new Error("No visitor ID exists. Create a visitor first.");u.label=1;case 1:return u.trys.push([1,3,,4]),this.logger.info("Updating visitor",{visitorId:this.visitorId,hasCommChannels:!!t&&t.length>0,hasExtendedFields:!!n}),r=t&&t.length>0?t:[],i=Le({profiles:[{source:this.source,accountId:this.accountId,commChannels:r}]},n&&{extendedFields:n}),this.logger.debug("Visitor update request payload",{request:i}),[4,this.apiClient.updateVisitor(this.orgId,this.visitorId,i)];case 2:return e=u.sent(),s=this.handleUpdateVisitorResponse(e),this.logger.info(oo,{visitorId:s}),[2,s];case 3:throw o=u.sent(),this.handleUpdateVisitorError(o),this.logger.error(uo,o),o;case 4:return[2]}})})},t.prototype.handleUpdateVisitorResponse=function(t){var n,r=this;t.warnings&&t.warnings.length>0&&t.warnings.forEach(function(t){r.logger.warn("Visitor update warning",{code:t.code,message:t.message})}),t.errors&&t.errors.length>0&&t.errors.forEach(function(t){r.logger.error("Visitor update error from response",{code:t.code,message:t.message})});var i=null===(n=t.data)||void 0===n?void 0:n.id;if(!i||""===i.trim())throw new Error("Invalid visitor ID received from update API");return i},t.prototype.handleUpdateVisitorError=function(t){var n,r=this;try{var i=(null===(n=t.response)||void 0===n?void 0:n.data)||t;i.warnings&&i.warnings.length>0&&i.warnings.forEach(function(t){t.code===xo.ACCOUNT_NOT_EXISTS?r.logger.error("Account does not exist",{code:t.code,message:t.message,accountId:r.accountId}):r.logger.warn("Visitor update warning",{code:t.code,message:t.message})}),i.errors&&i.errors.length>0&&i.errors.forEach(function(t){r.logger.error("Visitor update error",{code:t.code,message:t.message})})}catch(t){this.logger.warn("Failed to parse visitor update error",t)}},t.prototype.mergeVisitorWithUser=function(t,n,r,i,e,s){var o=this;if(this.initialized)if(this.visitorId)if(r||i||e){var u=this.visitorId;this.isMerged().then(function(a){if(!a)return o.persistPendingMerge(u,t,n,r,i,e,s).then(function(){return o.attemptPendingMerge()});o.logger.info(fo,{reason:"Visitor already merged",visitorId:u})}).catch(function(t){o.logger.warn("Merge background task failed unexpectedly",t)})}else this.logger.warn(fo,{reason:"No email, mobile, or externalId"});else this.logger.warn(fo,{reason:"No visitor ID"});else this.logger.warn(fo,{reason:"Not initialized"})},t.prototype.retryPendingMerge=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return r.trys.push([0,7,,8]),[4,this.getPendingMerge()];case 1:return(t=r.sent())?[4,this.isMerged()]:[2];case 2:return r.sent()?[4,this.clearPendingMerge()]:[3,4];case 3:return r.sent(),this.logger.info(fo,{reason:"Already merged"}),[2];case 4:return t.attempts>=Oo?(this.logger.error(co,{visitorId:t.visitorId,attempts:t.attempts,message:"Max retries exhausted"}),[4,this.clearPendingMerge()]):[3,6];case 5:return r.sent(),[2];case 6:return this.scheduleMergeRetry(),[3,8];case 7:return n=r.sent(),this.logger.warn("Failed to retry pending merge",n),[3,8];case 8:return[2]}})})},t.prototype.cancelMergeRetryTimer=function(){null!==this.mergeRetryTimeoutId&&(globalThis.clearTimeout(this.mergeRetryTimeoutId),this.mergeRetryTimeoutId=null)},t.prototype.scheduleMergeRetry=function(){var t=this;this.cancelMergeRetryTimer(),this.mergeRetryTimeoutId=globalThis.setTimeout(function(){t.mergeRetryTimeoutId=null,t.attemptPendingMerge().catch(function(n){t.logger.warn("Scheduled merge retry failed unexpectedly",n)})},Do)},t.prototype.attemptPendingMerge=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o,u;return Ge(this,function(a){switch(a.label){case 0:return[4,this.getPendingMerge()];case 1:if(!(t=a.sent()))return[2];n=this.getFcmToken?this.getFcmToken():null,r=this.getChannelType?this.getChannelType():void 0,a.label=2;case 2:return a.trys.push([2,6,,7]),this.getExtendedFields?[4,this.getExtendedFields()]:[3,4];case 3:return e=a.sent(),[3,5];case 4:e=void 0,a.label=5;case 5:return i=e,[3,7];case 6:return s=a.sent(),this.logger.warn("Failed to collect extended fields for merge, proceeding without them",s),i=void 0,[3,7];case 7:return a.trys.push([7,11,,17]),[4,this.apiClient.mergeVisitor(t.visitorId,t.firstName,t.lastName,t.email,t.mobile,n||void 0,r,t.customData||{},i,t.externalId)];case 8:return a.sent(),[4,this.markAsMerged(t.visitorId)];case 9:return a.sent(),[4,this.clearPendingMerge()];case 10:return a.sent(),this.logger.info(ao,{visitorId:t.visitorId,attempts:t.attempts+1}),[3,17];case 11:return(o=a.sent())instanceof Yv?[4,this.clearPendingMerge()]:[3,13];case 12:return a.sent(),this.logger.error("Visitor merge failed permanently, will not retry",{code:o.code,message:o.message,visitorId:t.visitorId}),[2];case 13:return u=Le(Le({},t),{attempts:t.attempts+1}),[4,this.savePendingMerge(u)];case 14:return a.sent(),u.attempts>=Oo?(this.logger.error(co,{visitorId:t.visitorId,attempts:u.attempts,message:"Max retries exhausted"}),[4,this.clearPendingMerge()]):[3,16];case 15:return a.sent(),[2];case 16:return this.logger.warn("Visitor merge attempt failed, scheduling retry",{attempt:u.attempts,maxRetries:Oo,nextRetryMs:Do,visitorId:t.visitorId,error:o}),this.scheduleMergeRetry(),[3,17];case 17:return[2]}})})},t.prototype.persistPendingMerge=function(t,n,r,i,e,s,o){return Be(this,void 0,void 0,function(){var u;return Ge(this,function(a){switch(a.label){case 0:return u=Le(Le(Le(Le(Le({visitorId:t,firstName:n,lastName:r},void 0!==i&&{email:i}),void 0!==e&&{mobile:e}),void 0!==s&&{externalId:s}),void 0!==o&&{customData:o}),{attempts:0}),[4,this.savePendingMerge(u)];case 1:return a.sent(),this.logger.debug("Pending merge request persisted to storage",{visitorId:t}),[2]}})})},t.prototype.getPendingMerge=function(){return Be(this,void 0,void 0,function(){var t,n,r;return Ge(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=us("PENDING_MERGE",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(n=i.sent())?[2,JSON.parse(n)]:[2,null];case 2:return r=i.sent(),this.logger.warn("Failed to read pending merge from storage",r),[2,null];case 3:return[2]}})})},t.prototype.savePendingMerge=function(t){return Be(this,void 0,void 0,function(){var n,r;return Ge(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=us("PENDING_MERGE",this.brandId,this.applicationId),[4,this.storageManager.set(n,JSON.stringify(t))];case 1:return i.sent(),[3,3];case 2:return r=i.sent(),this.logger.warn("Failed to save pending merge to storage",r),[3,3];case 3:return[2]}})})},t.prototype.clearPendingMerge=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:this.cancelMergeRetryTimer(),r.label=1;case 1:return r.trys.push([1,3,,4]),t=us("PENDING_MERGE",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 2:return r.sent(),this.logger.debug("Pending merge cleared from storage"),[3,4];case 3:return n=r.sent(),this.logger.warn("Failed to clear pending merge from storage",n),[3,4];case 4:return[2]}})})},t.prototype.isMerged=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),t=us("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return[2,null!=r.sent()];case 2:return n=r.sent(),this.logger.warn("Failed to check merge status",n),[2,!1];case 3:return[2]}})})},t.prototype.getMergedUserId=function(){return Be(this,void 0,void 0,function(){var t,n,r;return Ge(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=us("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return[2,null!=(n=i.sent())?n:null];case 2:return r=i.sent(),this.logger.warn("Failed to get merge status",r),[2,null];case 3:return[2]}})})},t.prototype.clearMergedUserId=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),t=us("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 1:return r.sent(),this.logger.info("Merge status cleared from storage"),[3,3];case 2:return n=r.sent(),this.logger.warn("Failed to clear merge status",n),[3,3];case 3:return[2]}})})},t.prototype.markAsMerged=function(t){return Be(this,void 0,void 0,function(){var n,r;return Ge(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=us("MERGED_USER_ID",this.brandId,this.applicationId),[4,this.storageManager.set(n,t)];case 1:return i.sent(),this.logger.debug("Visitor marked as merged",{visitorId:t,key:n}),[3,3];case 2:return r=i.sent(),this.logger.warn("Failed to store merge status",r),[3,3];case 3:return[2]}})})},t.prototype.getVisitorId=function(){return this.visitorId},t.prototype.getVisitorRefId=function(){return this.visitorRefId},t.prototype.hasVisitorId=function(){return null!==this.visitorId},t.prototype.storeVisitorId=function(t){return Be(this,void 0,void 0,function(){var n,r;return Ge(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=us("VISITOR_ID",this.brandId,this.applicationId),[4,this.storageManager.set(n,t)];case 1:return i.sent(),this.logger.debug("Visitor ID stored to storage",{visitorId:t,key:n}),[3,3];case 2:return r=i.sent(),this.logger.warn("Failed to store visitor ID",r),[3,3];case 3:return[2]}})})},t.prototype.storeExpiredAt=function(t){return Be(this,void 0,void 0,function(){var n,r;return Ge(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.expiredAt=t,n=us("VISITOR_EXPIRED_AT",this.brandId,this.applicationId),[4,this.storageManager.set(n,t)];case 1:return i.sent(),this.logger.debug("Visitor expiredAt stored to storage",{expiredAt:t}),[3,3];case 2:return r=i.sent(),this.logger.warn("Failed to store visitor expiredAt",r),[3,3];case 3:return[2]}})})},t.prototype.isVisitorExpired=function(){if(!this.expiredAt)return!0;try{return new Date(this.expiredAt).getTime()<=Date.now()}catch(t){return this.logger.warn("Invalid expiredAt format, treating as expired",{expiredAt:this.expiredAt}),!0}},t.prototype.getOrGenerateVisitorRefId=function(){return Be(this,void 0,void 0,function(){var t,n,r;return Ge(this,function(i){switch(i.label){case 0:if(this.visitorRefId)return[2,this.visitorRefId];t=Ih(),this.visitorRefId=t,i.label=1;case 1:return i.trys.push([1,3,,4]),n=us("VISITOR_REF_ID",this.brandId,this.applicationId),[4,this.storageManager.set(n,t)];case 2:return i.sent(),this.logger.debug("visitorRefId generated and stored",{visitorRefId:t}),[3,4];case 3:return r=i.sent(),this.logger.warn("Failed to store visitorRefId",r),[3,4];case 4:return[2,t]}})})},t.prototype.restoreVisitorId=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o;return Ge(this,function(u){switch(u.label){case 0:return u.trys.push([0,4,,5]),t=us("VISITOR_ID",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(n=u.sent())&&(this.visitorId=n,this.logger.info(eo,{visitorId:n})),r=us("VISITOR_REF_ID",this.brandId,this.applicationId),[4,this.storageManager.get(r)];case 2:return(i=u.sent())&&(this.visitorRefId=i),e=us("VISITOR_EXPIRED_AT",this.brandId,this.applicationId),[4,this.storageManager.get(e)];case 3:return(s=u.sent())&&(this.expiredAt=s),[3,5];case 4:return o=u.sent(),this.logger.warn("Failed to restore visitor ID from storage",o),this.visitorId=null,[3,5];case 5:return[2]}})})},t.prototype.clearVisitorId=function(){return Be(this,void 0,void 0,function(){var t,n,r,i;return Ge(this,function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),t=us("VISITOR_ID",this.brandId,this.applicationId),n=us("VISITOR_REF_ID",this.brandId,this.applicationId),r=us("VISITOR_EXPIRED_AT",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 1:return e.sent(),[4,this.storageManager.remove(n)];case 2:return e.sent(),[4,this.storageManager.remove(r)];case 3:return e.sent(),this.visitorId=null,this.visitorRefId=null,this.expiredAt=null,this.logger.info("Visitor ID cleared from storage"),[3,5];case 4:return i=e.sent(),this.logger.warn("Failed to clear visitor ID",i),this.visitorId=null,this.visitorRefId=null,this.expiredAt=null,[3,5];case 5:return[2]}})})},t.prototype.destroy=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){return this.logger.info("Destroying AnonymousVisitorManager"),this.cancelMergeRetryTimer(),this.initialized=!1,this.logger.info("AnonymousVisitorManager destroyed successfully"),[2]})})},t}(),Bl={};function Gl(){return"undefined"!=typeof window&&window.firebase?window.firebase:null}function Wl(){return Be(this,void 0,void 0,function(){var t;return Ge(this,function(n){return(t=Gl())?[2,t]:[2,import("firebase/app")]})})}function ql(){return Be(this,void 0,void 0,function(){var t;return Ge(this,function(n){return(t=Gl())&&t.messaging?[2,t]:[2,import("firebase/messaging")]})})}function Kl(){return Be(this,void 0,void 0,function(){var t;return Ge(this,function(n){return(t=Gl())&&t.remoteConfig?[2,t]:[2,import("firebase/remote-config")]})})}!function(){if(Vl)return Bl;Vl=1;var t=Ti(),n=ze().find,r=Ji(),i="find",e=!0;i in[]&&Array(1)[i](function(){e=!1}),t({target:"Array",proto:!0,forced:e},{find:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}}),r(i)}();var Hl=function(){function t(t,n,r,i,e,s,o){this.isInitialized=!1,this.firebaseApp=null,this.messaging=null,this.remoteConfig=null,this.remoteConfigGetValue=null,this.remoteConfigGetAll=null,this.currentToken=null,this.config=t,this.logger=n,this.vapidKey=r,this.serviceWorkerPath=i||is,this.onTokenReceivedCallback=e,this.p=s,this.onMessageReceivedCallback=o}return t.prototype.checkFirebaseAvailability=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,Wl()];case 1:return t.sent(),this.logger.info("Firebase available"),[2,!0];case 2:return t.sent(),this.logger.warn("Firebase not available - notifications will not work"),[2,!1];case 3:return[2]}})})},t.prototype.initialize=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o,u,a,c;return Ge(this,function(f){switch(f.label){case 0:if(this.isInitialized)return this.logger.warn("Firebase already initialized"),[2,!0];f.label=1;case 1:return f.trys.push([1,8,,9]),[4,this.checkFirebaseAvailability()];case 2:return f.sent()?(t="undefined"!=typeof window?window.firebase:null)?(this.logger.info("Initializing Firebase in compat mode"),(u=null===(c=t.apps)||void 0===c?void 0:c.find(function(t){return t.name===es}))?(this.logger.info("Using existing Firebase app"),this.firebaseApp=u):(this.logger.info("Creating new Firebase app"),this.firebaseApp=t.initializeApp(this.config,es)),this.messaging=this.firebaseApp.messaging?this.firebaseApp.messaging():null,[3,7]):[3,3]:[2,!1];case 3:return this.logger.info("Initializing Firebase in modular mode"),[4,Wl()];case 4:return n=f.sent(),[4,ql()];case 5:return r=f.sent(),i=n.initializeApp,e=n.getApps,s=r.getMessaging,[4,(0,r.isSupported)()];case 6:if(!f.sent())return this.logger.warn("Firebase Messaging not supported in this browser"),[2,!1];o=e(),(u=o.find(function(t){return t.name===es}))?(this.logger.info("Using existing Firebase app"),this.firebaseApp=u):(this.logger.info("Creating new Firebase app"),this.firebaseApp=i(this.config,es)),this.messaging=s(this.firebaseApp),f.label=7;case 7:return this.messaging?(this.isInitialized=!0,this.logger.info(wo),[2,!0]):(this.logger.error("Failed to initialize Firebase Messaging"),[2,!1]);case 8:return a=f.sent(),this.logger.error(mo,a),[2,!1];case 9:return[2]}})})},t.prototype.registerServiceWorker=function(){return Be(this,void 0,void 0,function(){var t,n,r;return Ge(this,function(i){switch(i.label){case 0:if(!("serviceWorker"in navigator))return this.logger.warn("Service Worker not supported"),[2,null];i.label=1;case 1:return i.trys.push([1,7,,8]),[4,navigator.serviceWorker.getRegistration(this.serviceWorkerPath)];case 2:return(t=i.sent())?(this.logger.info("Service worker already registered",{scope:t.scope}),[4,this.ensureServiceWorkerActive(t)]):[3,4];case 3:return i.sent(),[2,t];case 4:return this.logger.info("Registering service worker",{path:this.serviceWorkerPath}),[4,navigator.serviceWorker.register(this.serviceWorkerPath)];case 5:return n=i.sent(),this.logger.info(Eo,{scope:n.scope}),[4,this.ensureServiceWorkerActive(n)];case 6:return i.sent(),[2,n];case 7:return r=i.sent(),this.logger.error(Io,r),[2,null];case 8:return[2]}})})},t.prototype.ensureServiceWorkerActive=function(t){return Be(this,void 0,void 0,function(){var n,r=this;return Ge(this,function(i){return t.active?(this.logger.debug("Service worker is already active"),[2]):(n=t.installing||t.waiting)?(this.logger.info("Waiting for service worker to activate...",{state:n.state}),[2,new Promise(function(t,i){if("activated"!==n.state){var e=function(){"activated"===n.state?(n.removeEventListener("statechange",e),r.logger.info("Service worker activated"),t()):"redundant"===n.state&&(n.removeEventListener("statechange",e),i(new Error("Service worker became redundant")))};n.addEventListener("statechange",e)}else t()})]):(this.logger.warn("No service worker found in registration"),[2])})})},t.prototype.requestToken=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o;return Ge(this,function(u){switch(u.label){case 0:if(!this.isInitialized||!this.messaging)return this.logger.error("FirebaseManager not initialized"),[2,null];u.label=1;case 1:return u.trys.push([1,8,,9]),[4,this.registerServiceWorker()];case 2:return(t=u.sent())?(n="undefined"!=typeof window?window.firebase:null,r=void 0,n?(this.logger.info("Getting token using compat mode"),s={serviceWorkerRegistration:t},this.vapidKey&&(s.vapidKey=this.vapidKey),[4,this.messaging.getToken(s)]):[3,4]):(this.logger.warn("Service worker registration required for FCM"),[2,null]);case 3:return r=u.sent(),[3,7];case 4:return[4,ql()];case 5:return i=u.sent(),e=i.getToken,s={serviceWorkerRegistration:t},this.vapidKey&&(s.vapidKey=this.vapidKey),[4,e(this.messaging,s)];case 6:r=u.sent(),u.label=7;case 7:return r?(this.currentToken=r,this.logger.info(po,{token:r}),this.onTokenReceivedCallback&&this.onTokenReceivedCallback(r),[2,r]):(this.logger.warn("No FCM token received - permission may be denied"),[2,null]);case 8:return o=u.sent(),this.logger.error(bo,o),[2,null];case 9:return[2]}})})},t.prototype.setupMessageListener=function(){return Be(this,void 0,void 0,function(){var t,n,r,i=this;return Ge(this,function(e){switch(e.label){case 0:if(!this.isInitialized||!this.messaging)return this.logger.error("FirebaseManager not initialized"),[2];e.label=1;case 1:return e.trys.push([1,5,,6]),("undefined"!=typeof window?window.firebase:null)?(this.logger.info("Setting up message listener (compat mode)"),this.messaging.onMessage(function(t){i.handleMessage(t)}),[3,4]):[3,2];case 2:return[4,ql()];case 3:t=e.sent(),n=t.onMessage,this.logger.info("Setting up message listener (modular mode)"),n(this.messaging,function(t){i.handleMessage(t)}),e.label=4;case 4:return this.logger.info("Message listener setup successfully"),[3,6];case 5:return r=e.sent(),this.logger.error("Failed to setup message listener",r),[3,6];case 6:return[2]}})})},t.prototype.handleMessage=function(t){this.logger.info("FCM message received",t),this.onMessageReceivedCallback&&this.onMessageReceivedCallback(t)},t.prototype.handleTokenRefresh=function(t){this.logger.info("FCM token refreshed",{token:t}),this.p&&this.p(t)},t.prototype.getCurrentToken=function(){return this.currentToken},t.prototype.isFirebaseInitialized=function(){return this.isInitialized},t.prototype.initializeRemoteConfig=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o;return Ge(this,function(u){switch(u.label){case 0:if(!this.isInitialized||!this.firebaseApp)return this.logger.warn("Firebase not initialized, cannot setup Remote Config"),[2];u.label=1;case 1:return u.trys.push([1,6,,7]),(t="undefined"!=typeof window?window.firebase:null)&&t.remoteConfig?(this.remoteConfig=t.remoteConfig(this.firebaseApp),this.remoteConfig.settings.minimumFetchIntervalMillis=36e5,this.logger.info("Remote Config initialized (compat mode)"),[3,5]):[3,2];case 2:return u.trys.push([2,4,,5]),[4,Kl()];case 3:return n=u.sent(),r=n.getRemoteConfig,i=n.getValue,e=n.getAll,this.remoteConfig=r(this.firebaseApp),this.remoteConfig.settings.minimumFetchIntervalMillis=36e5,this.remoteConfigGetValue=i,this.remoteConfigGetAll=e,this.logger.info("Remote Config initialized (modular mode)"),[3,5];case 4:return s=u.sent(),this.logger.warn("Remote Config module not available:",s),[2];case 5:return[3,7];case 6:return o=u.sent(),this.logger.error("Failed to initialize Remote Config:",o),[3,7];case 7:return[2]}})})},t.prototype.getRemoteConfigString=function(t){if(!this.remoteConfig)return this.logger.warn("Remote Config not initialized"),"";try{var n="undefined"!=typeof window?window.firebase:null;return n&&n.remoteConfig?this.remoteConfig.getString(t):this.remoteConfigGetValue?this.remoteConfigGetValue(this.remoteConfig,t).asString():(this.logger.warn("Remote Config getValue function not available"),"")}catch(n){return this.logger.error('Failed to get Remote Config value for key "'.concat(t,'":'),n),""}},t.prototype.getRemoteConfigBoolean=function(t){if(!this.remoteConfig)return this.logger.warn("Remote Config not initialized"),!1;try{var n="undefined"!=typeof window?window.firebase:null;return n&&n.remoteConfig?this.remoteConfig.getBoolean(t):this.remoteConfig.getBoolean(t)||!1}catch(n){return this.logger.error('Failed to get Remote Config boolean for key "'.concat(t,'":'),n),!1}},t.prototype.getRemoteConfigNumber=function(t){if(!this.remoteConfig)return this.logger.warn("Remote Config not initialized"),0;try{var n="undefined"!=typeof window?window.firebase:null;return n&&n.remoteConfig?this.remoteConfig.getNumber(t):this.remoteConfig.getNumber(t)||0}catch(n){return this.logger.error('Failed to get Remote Config number for key "'.concat(t,'":'),n),0}},t.prototype.getAllRemoteConfigValues=function(){if(!this.remoteConfig)return this.logger.warn("Remote Config not initialized"),{};try{var t="undefined"!=typeof window?window.firebase:null;if(t&&t.remoteConfig){var n=this.remoteConfig.getAll(),r={};return Object.keys(n).forEach(function(t){r[t]=n[t].asString()}),r}if(this.remoteConfigGetAll){var i=this.remoteConfigGetAll(this.remoteConfig),e={};return Object.keys(i).forEach(function(t){e[t]=i[t].asString()}),e}return this.logger.warn("Remote Config getAll function not available"),{}}catch(t){return this.logger.error("Failed to get all Remote Config values:",t),{}}},t.prototype.getRemoteConfigJSON=function(t){if(!this.remoteConfig)return this.logger.warn("Remote Config not initialized"),null;try{var n=this.getRemoteConfigString(t);if(!n)return this.logger.warn('Remote Config key "'.concat(t,'" is empty')),null;var r=JSON.parse(n);return this.logger.info('Remote Config JSON parsed for key "'.concat(t,'"'),r),r}catch(n){return this.logger.error('Failed to parse Remote Config JSON for key "'.concat(t,'":'),n),null}},t.prototype.destroy=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return r.trys.push([0,6,,7]),this.firebaseApp?("undefined"!=typeof window?window.firebase:null)?[4,this.firebaseApp.delete()]:[3,2]:[3,5];case 1:return r.sent(),[3,5];case 2:return[4,Wl()];case 3:return t=r.sent(),[4,(0,t.deleteApp)(this.firebaseApp)];case 4:r.sent(),r.label=5;case 5:return this.isInitialized=!1,this.firebaseApp=null,this.messaging=null,this.currentToken=null,this.logger.info("FirebaseManager destroyed successfully"),[3,7];case 6:return n=r.sent(),this.logger.error("Failed to destroy FirebaseManager",n),[3,7];case 7:return[2]}})})},t}(),Xl=function(){function t(t,n,r,i,e){this.firebaseManager=null,this.tokenUpdateCallback=null,this.config=t,this.logger=n,this.storageManager=r,this.brandId=i,this.applicationId=e,this.state={isNotificationEnabled:!1,firebaseInitialized:!1,permissionStatus:"default"}}return t.prototype.isNotificationSupported=function(){return"undefined"!=typeof window&&"undefined"!=typeof Notification&&"undefined"!=typeof navigator&&"serviceWorker"in navigator},t.prototype.getPermissionStatus=function(){return this.isNotificationSupported()?Notification.permission:"denied"},t.prototype.shouldInitializeNotifications=function(){return!1===this.config.enableNotifications?(this.logger.info("Notifications disabled via config"),!1):this.isNotificationSupported()?!!this.config.firebaseConfig||(this.logger.warn("Firebase config not provided - notifications disabled"),!1):(this.logger.warn("Notifications not supported in this browser"),!1)},t.prototype.restoreState=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e;return Ge(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),t=us("NOTIFICATION_STATE",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return(n=s.sent())&&(r=JSON.parse(n),i=this.getPermissionStatus(),this.state=Le(Le(Le({},this.state),r),{permissionStatus:i}),this.logger.info("Notification state restored from storage",{storedPermission:r.permissionStatus,currentPermission:i,hasToken:!!r.fcmToken})),[3,3];case 2:return e=s.sent(),this.logger.warn("Failed to restore notification state",e),[3,3];case 3:return[2]}})})},t.prototype.saveState=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),t=us("NOTIFICATION_STATE",this.brandId,this.applicationId),[4,this.storageManager.set(t,JSON.stringify(this.state))];case 1:return r.sent(),this.logger.debug("Notification state saved to storage",this.state),[3,3];case 2:return n=r.sent(),this.logger.warn("Failed to save notification state",n),[3,3];case 3:return[2]}})})},t.prototype.init=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return r.trys.push([0,15,,17]),[4,this.restoreState()];case 1:return r.sent(),this.shouldInitializeNotifications()?[3,3]:(this.logger.info(go),this.state.isNotificationEnabled=!1,[4,this.saveState()]);case 2:return r.sent(),[2,this.state];case 3:return t=this.getPermissionStatus(),this.state.permissionStatus=t,this.logger.info("Current notification permission",{permission:t,hasStoredToken:!!this.state.fcmToken,isNotificationEnabled:this.state.isNotificationEnabled}),"denied"!==t?[3,5]:(this.logger.warn(ho),this.state.isNotificationEnabled=!1,delete this.state.fcmToken,[4,this.saveState()]);case 4:return r.sent(),[2,this.state];case 5:return"default"!==t?[3,7]:(this.logger.info("Permission not yet granted - notifications will not be shown until user grants permission"),this.state.isNotificationEnabled=!1,[4,this.saveState()]);case 6:return r.sent(),[2,this.state];case 7:return"granted"!==t?[3,14]:this.state.fcmToken?(this.logger.info("Using existing FCM token from storage",{token:this.state.fcmToken.substring(0,20)+"..."}),this.state.isNotificationEnabled=!0,this.firebaseManager?[3,9]:(this.logger.info("Initializing Firebase for message listening"),[4,this.initializeFirebaseForMessaging()])):[3,11];case 8:r.sent(),r.label=9;case 9:return[4,this.saveState()];case 10:return r.sent(),[2,this.state];case 11:return this.logger.info("Permission granted - initializing Firebase to generate FCM token"),[4,this.initializeFirebase()];case 12:return r.sent(),[4,this.saveState()];case 13:r.sent(),r.label=14;case 14:return this.logger.info(vo,this.state),[2,this.state];case 15:return n=r.sent(),this.logger.error(lo,n),this.state.isNotificationEnabled=!1,[4,this.saveState()];case 16:return r.sent(),[2,this.state];case 17:return[2]}})})},t.prototype.initializeFirebaseForMessaging=function(){return Be(this,void 0,void 0,function(){var t;return Ge(this,function(n){switch(n.label){case 0:if(!this.config.firebaseConfig)throw new Error("Firebase config is required");n.label=1;case 1:return n.trys.push([1,4,,5]),this.firebaseManager=new Hl(this.config.firebaseConfig,this.logger,this.config.vapidKey,this.config.serviceWorkerPath,this.config.onTokenReceived,this.config.onTokenRefresh,this.config.onMessageReceived),[4,this.firebaseManager.initialize()];case 2:if(!n.sent())throw new Error("Firebase initialization failed");return this.state.firebaseInitialized=!0,[4,this.firebaseManager.setupMessageListener()];case 3:return n.sent(),this.initializeRemoteConfigAsync(),this.logger.info("Firebase initialized for message listening"),[3,5];case 4:throw t=n.sent(),this.logger.error("Failed to initialize Firebase for messaging",t),t;case 5:return[2]}})})},t.prototype.initializeFirebase=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:if(!this.config.firebaseConfig)throw new Error("Firebase config is required");r.label=1;case 1:return r.trys.push([1,7,,8]),this.firebaseManager=new Hl(this.config.firebaseConfig,this.logger,this.config.vapidKey,this.config.serviceWorkerPath,this.config.onTokenReceived,this.config.onTokenRefresh,this.config.onMessageReceived),[4,this.firebaseManager.initialize()];case 2:if(!r.sent())throw new Error("Firebase initialization failed");return this.state.firebaseInitialized=!0,this.state.isNotificationEnabled=!0,[4,this.firebaseManager.requestToken()];case 3:return(t=r.sent())?(this.state.fcmToken=t,[4,this.storeFCMToken(t)]):[3,5];case 4:r.sent(),r.label=5;case 5:return[4,this.firebaseManager.setupMessageListener()];case 6:return r.sent(),this.initializeRemoteConfigAsync(),this.logger.info("Firebase initialized and FCM token retrieved",{hasToken:!!t}),[3,8];case 7:throw n=r.sent(),this.logger.error("Failed to initialize Firebase",n),this.state.firebaseInitialized=!1,this.state.isNotificationEnabled=!1,n;case 8:return[2]}})})},t.prototype.initializeRemoteConfigAsync=function(){return Be(this,void 0,void 0,function(){var t;return Ge(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),this.firebaseManager?[4,this.firebaseManager.initializeRemoteConfig()]:[3,2];case 1:n.sent(),this.logger.info("✅ Remote Config initialized and fetched successfully"),n.label=2;case 2:return[3,4];case 3:return t=n.sent(),this.logger.warn("Remote Config initialization failed (non-critical):",t),[3,4];case 4:return[2]}})})},t.prototype.storeFCMToken=function(t){return Be(this,void 0,void 0,function(){var n,r,i,e,s,o;return Ge(this,function(u){switch(u.label){case 0:return u.trys.push([0,6,,7]),n=us("FCM_TOKEN",this.brandId,this.applicationId),r=us("FCM_TOKEN_CREATED_AT",this.brandId,this.applicationId),[4,this.storageManager.get(n)];case 1:return i=u.sent(),e=!i||i!==t,[4,this.storageManager.set(n,t)];case 2:return u.sent(),e?(s=(new Date).toISOString(),[4,this.storageManager.set(r,s)]):[3,4];case 3:return u.sent(),this.logger.debug("FCM token and creation date stored successfully",{createdAt:s}),[3,5];case 4:this.logger.debug("FCM token stored (creation date unchanged)"),u.label=5;case 5:return this.tokenUpdateCallback&&(this.logger.info("Notifying token update callback",{isNewToken:e,tokenPreview:t.substring(0,20)+"..."}),this.tokenUpdateCallback(t,e)),[3,7];case 6:return o=u.sent(),this.logger.warn("Failed to store FCM token",o),[3,7];case 7:return[2]}})})},t.prototype.setTokenUpdateCallback=function(t){this.tokenUpdateCallback=t,this.logger.debug("Token update callback registered")},t.prototype.clearTokenUpdateCallback=function(){this.tokenUpdateCallback=null,this.logger.debug("Token update callback cleared")},t.prototype.getState=function(){return Le({},this.state)},t.prototype.getFCMToken=function(){return this.state.fcmToken||null},t.prototype.getTokenCreationDate=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),t=us("FCM_TOKEN_CREATED_AT",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return[2,r.sent()||null];case 2:return n=r.sent(),this.logger.warn("Failed to retrieve FCM token creation date",n),[2,null];case 3:return[2]}})})},t.prototype.isEnabled=function(){return this.state.isNotificationEnabled},t.prototype.getFirebaseManager=function(){return this.firebaseManager},t.prototype.refreshToken=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:if(!this.firebaseManager||!this.state.isNotificationEnabled)return this.logger.warn("Cannot refresh token - notifications not enabled"),[2,null];r.label=1;case 1:return r.trys.push([1,6,,7]),[4,this.firebaseManager.requestToken()];case 2:return(t=r.sent())?(this.state.fcmToken=t,[4,this.storeFCMToken(t)]):[3,5];case 3:return r.sent(),[4,this.saveState()];case 4:r.sent(),this.logger.info(yo,{token:t}),r.label=5;case 5:return[2,t];case 6:return n=r.sent(),this.logger.error("Failed to refresh FCM token",n),[2,null];case 7:return[2]}})})},t.prototype.clearToken=function(){return Be(this,void 0,void 0,function(){var t,n,r;return Ge(this,function(i){switch(i.label){case 0:return i.trys.push([0,5,,6]),this.logger.info("Clearing FCM token and notification state"),t=this.state.fcmToken,delete this.state.fcmToken,this.state.isNotificationEnabled=!1,this.state.firebaseInitialized=!1,n=us("FCM_TOKEN",this.brandId,this.applicationId),[4,this.storageManager.remove(n)];case 1:return i.sent(),this.firebaseManager?[4,this.firebaseManager.destroy()]:[3,3];case 2:i.sent(),this.firebaseManager=null,i.label=3;case 3:return[4,this.saveState()];case 4:return i.sent(),this.tokenUpdateCallback&&t&&(this.logger.info("Notifying token cleared to update backend with empty commChannels"),this.tokenUpdateCallback("",!0)),this.logger.info("FCM token and state cleared successfully"),[3,6];case 5:throw r=i.sent(),this.logger.error("Failed to clear FCM token",r),r;case 6:return[2]}})})},t.prototype.hasPermissionChanged=function(){return this.getPermissionStatus()!==this.state.permissionStatus},t.prototype.handlePermissionChange=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return t=this.getPermissionStatus(),n=this.state.permissionStatus,this.logger.info("Permission status changed",{from:n,to:t}),this.state.permissionStatus=t,"denied"!==t&&"default"!==t?[3,5]:"granted"!==n?[3,2]:(this.logger.warn("Permission revoked - clearing FCM token"),[4,this.clearToken()]);case 1:return r.sent(),[3,4];case 2:return this.state.isNotificationEnabled=!1,[4,this.saveState()];case 3:r.sent(),r.label=4;case 4:return[3,8];case 5:return"granted"!==t||"granted"===n?[3,8]:(this.logger.info("Permission granted - initializing Firebase"),[4,this.initializeFirebase()]);case 6:return r.sent(),[4,this.saveState()];case 7:r.sent(),r.label=8;case 8:return[2,this.state]}})})},t.prototype.destroy=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),this.firebaseManager?[4,this.firebaseManager.destroy()]:[3,2];case 1:r.sent(),this.firebaseManager=null,r.label=2;case 2:return t=us("NOTIFICATION_STATE",this.brandId,this.applicationId),[4,this.storageManager.remove(t)];case 3:return r.sent(),this.logger.info("NotificationManager destroyed successfully"),[3,5];case 4:return n=r.sent(),this.logger.error("Failed to destroy NotificationManager",n),[3,5];case 5:return[2]}})})},t}(),$l=function(){function t(t,n,r,i,e){this.currentSession=null,this.storageManager=t,this.logger=n,this.brandId=r,this.applicationId=i;var s=ns/6e4;this.inactivityTimeoutMs=60*(e||s)*1e3,this.logger.info("SessionManager configured with timeout:",{timeoutMinutes:e||s,timeoutMs:this.inactivityTimeoutMs,source:e?"Remote Config":"Default"})}return t.prototype.init=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return this.logger.info("Initializing SessionManager"),[4,this.restoreSession()];case 1:return t.sent(),this.logger.info("SessionManager initialized successfully"),[2]}})})},t.prototype.getOrCreateSession=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return t=Date.now(),this.currentSession?(n=t-this.currentSession.lastEventTime)<this.inactivityTimeoutMs?(this.currentSession.lastEventTime=t,[4,this.persistSession()]):[3,2]:[3,3];case 1:return r.sent(),this.logger.debug(Vs,{sessionId:this.currentSession.sessionId,inactivityDuration:n}),[2,this.currentSession.sessionId];case 2:this.logger.info(Ls,{sessionId:this.currentSession.sessionId,inactivityDuration:n,timeoutMs:this.inactivityTimeoutMs}),r.label=3;case 3:return[4,this.startNewSession()];case 4:return[2,r.sent()]}})})},t.prototype.getSessionStartTime=function(){var t;return(null===(t=this.currentSession)||void 0===t?void 0:t.sessionStartTime)||null},t.prototype.endSession=function(t){return Be(this,void 0,void 0,function(){return Ge(this,function(n){switch(n.label){case 0:return this.currentSession?(this.logger.info(Bs,{sessionId:this.currentSession.sessionId,reason:t}),this.currentSession=null,[4,this.clearSessionStorage()]):[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}})})},t.prototype.destroy=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){return this.logger.info("Destroying SessionManager (session persists in storage)"),this.currentSession=null,[2]})})},t.prototype.startNewSession=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return t=Date.now(),n=Ih(),this.currentSession={sessionId:n,sessionStartTime:t,lastEventTime:t},[4,this.persistSession()];case 1:return r.sent(),this.logger.info(zs,{sessionId:n,sessionStartTime:t}),[2,n]}})})},t.prototype.restoreSession=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o,u,a;return Ge(this,function(c){switch(c.label){case 0:return c.trys.push([0,7,,9]),t=us("SESSION_ID",this.brandId,this.applicationId),n=us("SESSION_START_TIME",this.brandId,this.applicationId),r=us("LAST_EVENT_TIME",this.brandId,this.applicationId),[4,this.storageManager.get(t)];case 1:return i=c.sent(),[4,this.storageManager.get(n)];case 2:return e=c.sent(),[4,this.storageManager.get(r)];case 3:return s=c.sent(),i&&e&&s?(o=Date.now(),(u=o-parseInt(s))<this.inactivityTimeoutMs?(this.currentSession={sessionId:i,sessionStartTime:parseInt(e),lastEventTime:parseInt(s)},this.logger.info(Gs,{sessionId:i,timeSinceLastEvent:u}),[3,6]):[3,4]):[3,6];case 4:return this.logger.debug("Stored session expired, will create new session",{timeSinceLastEvent:u,timeoutMs:this.inactivityTimeoutMs}),[4,this.clearSessionStorage()];case 5:c.sent(),c.label=6;case 6:return[3,9];case 7:return a=c.sent(),this.logger.warn("Failed to restore session from storage",a),[4,this.clearSessionStorage()];case 8:return c.sent(),[3,9];case 9:return[2]}})})},t.prototype.persistSession=function(){return Be(this,void 0,void 0,function(){var t,n,r,i;return Ge(this,function(e){switch(e.label){case 0:if(!this.currentSession)return[2];e.label=1;case 1:return e.trys.push([1,3,,4]),t=us("SESSION_ID",this.brandId,this.applicationId),n=us("SESSION_START_TIME",this.brandId,this.applicationId),r=us("LAST_EVENT_TIME",this.brandId,this.applicationId),[4,Promise.all([this.storageManager.set(t,this.currentSession.sessionId),this.storageManager.set(n,this.currentSession.sessionStartTime.toString()),this.storageManager.set(r,this.currentSession.lastEventTime.toString())])];case 2:return e.sent(),[3,4];case 3:return i=e.sent(),this.logger.warn("Failed to persist session to storage",i),[3,4];case 4:return[2]}})})},t.prototype.clearSessionStorage=function(){return Be(this,void 0,void 0,function(){var t,n,r,i;return Ge(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=us("SESSION_ID",this.brandId,this.applicationId),n=us("SESSION_START_TIME",this.brandId,this.applicationId),r=us("LAST_EVENT_TIME",this.brandId,this.applicationId),[4,Promise.all([this.storageManager.remove(t),this.storageManager.remove(n),this.storageManager.remove(r)])];case 1:return e.sent(),[3,3];case 2:return i=e.sent(),this.logger.warn("Failed to clear session storage",i),[3,3];case 3:return[2]}})})},t}();return function(){function t(t){this.userContextSet=!1,this.initialized=!1,this.initializationPromise=null,this.visitorTrackingEnabled=!1,this.visitorId=null,this.currentUserIdentifierType=null,this.notificationManager=null,this.permissionChangeCleanup=null,this.dlrMessageCleanup=null,this.lastAuthenticatedUser=null,this.sdkDisabled=!1,this.config=t,this.logger=new Ul(!1),this.validateRequiredConfig(t),this.logger.info("🔧 SDK initializing in Remote Config bootstrap mode"),this.logger.info("Will fetch configuration from Remote Config key:",t.remoteConfigKey)}return t.initialize=function(n){return t.I?(new Ul(!0).warn("WebSDK is already initialized. Returning existing instance. Call WebSDK.resetInstance() first if you need to re-initialize."),t.I):(t.I=new t(n),t.I.init(),t.I)},t.getInstance=function(){return t.I},t.isInitialized=function(){return null!==t.I},t.resetInstance=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(n){switch(n.label){case 0:return t.I?[4,t.I.destroy()]:[3,2];case 1:n.sent(),t.I=null,n.label=2;case 2:return[2]}})})},t.requireInstance=function(){if(!t.I)throw new Error("WebSDK is not initialized. Call WebSDK.initialize(config) first.");return t.I},t.pushUserSignin=function(n,r){t.requireInstance().pushUserSignin(n,r)},t.pushUserSignup=function(n,r){t.requireInstance().pushUserSignup(n,r)},t.pushUserUpdate=function(n,r){t.requireInstance().pushUserUpdate(n,r)},t.pushUserSignOut=function(n){t.requireInstance().pushUserSignOut(n)},t.pushEvent=function(n,r){t.requireInstance().pushEvent(n,r)},t.track=function(n,r){t.requireInstance().track(n,r)},t.pageView=function(n){t.requireInstance().pageView(n)},t.identify=function(n){t.requireInstance().identify(n)},t.getVisitorId=function(){return t.requireInstance().getVisitorId()},t.getNotificationState=function(){return t.requireInstance().getNotificationState()},t.getFCMToken=function(){return t.requireInstance().getFCMToken()},t.isNotificationsEnabled=function(){return t.requireInstance().isNotificationsEnabled()},t.refreshFCMToken=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(n){return[2,t.requireInstance().refreshFCMToken()]})})},t.reinitializeNotifications=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(n){return[2,t.requireInstance().reinitializeNotifications()]})})},t.hasNotificationPermissionChanged=function(){return t.requireInstance().hasNotificationPermissionChanged()},t.handleNotificationPermissionChange=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(n){return[2,t.requireInstance().handleNotificationPermissionChange()]})})},t.getRemoteConfigString=function(n){return t.requireInstance().getRemoteConfigString(n)},t.getRemoteConfigBoolean=function(n){return t.requireInstance().getRemoteConfigBoolean(n)},t.getRemoteConfigNumber=function(n){return t.requireInstance().getRemoteConfigNumber(n)},t.getChannelType=function(){return t.requireInstance().getChannelType()},t.getAllRemoteConfigValues=function(){return t.requireInstance().getAllRemoteConfigValues()},t.reset=function(){t.requireInstance().reset()},t.disableSDK=function(){t.requireInstance().disableSDK()},t.enableSDK=function(){t.requireInstance().enableSDK()},t.destroy=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(n){switch(n.label){case 0:return t.I?[4,t.I.destroy()]:[3,2];case 1:n.sent(),t.I=null,n.label=2;case 2:return[2]}})})},t.prototype.shouldEnableLogging=function(t){return!(!t||"NONE"===t)&&["ERROR","WARN","INFO","DEBUG","VERBOSE"].includes(t)},t.prototype.restoreUserContext=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o,u,a;return Ge(this,function(c){switch(c.label){case 0:return c.trys.push([0,5,,6]),t=us("USER_CONTEXT",this.config.brandId,this.config.applicationId),[4,this.storageManager.get(t)];case 1:return(n=c.sent())?(r=JSON.parse(n),i=r.cuid,e=r.userIdentifierType,this.currentUserIdentifierType=null!=e?e:null,s=this.config.accountId||"",[4,this.eventTracker.setUserContext(s,i,e)]):[3,3];case 2:c.sent(),this.userContextSet=!0,this.logger.info("User context restored from storage",{cuid:i,accountId:this.config.accountId}),c.label=3;case 3:return o=us("LAST_AUTHENTICATED_USER",this.config.brandId,this.config.applicationId),[4,this.storageManager.get(o)];case 4:return(u=c.sent())&&(this.lastAuthenticatedUser=u,this.logger.info("Last authenticated user restored from storage",{lastAuthenticatedUser:this.lastAuthenticatedUser})),[3,6];case 5:return a=c.sent(),this.logger.warn("Failed to restore user context from storage",a),[3,6];case 6:return[2]}})})},t.prototype.validateAndClearDifferentUserContext=function(t){return Be(this,void 0,void 0,function(){var n;return Ge(this,function(r){switch(r.label){case 0:return r.trys.push([0,5,,7]),this.lastAuthenticatedUser&&this.lastAuthenticatedUser!==t?(this.logger.info("Different user detected, ending session and clearing context",{previousCuid:this.lastAuthenticatedUser,newCuid:t}),[4,this.sessionManager.endSession("user_switch")]):[3,3];case 1:return r.sent(),[4,this.clearUserContext()];case 2:r.sent(),this.userContextSet=!1,r.label=3;case 3:return this.lastAuthenticatedUser=t,[4,this.persistLastAuthenticatedUser(t)];case 4:return r.sent(),[3,7];case 5:return n=r.sent(),this.logger.warn("Error validating different user context",n),[4,this.clearUserContext()];case 6:return r.sent(),this.userContextSet=!1,[3,7];case 7:return[2]}})})},t.prototype.persistLastAuthenticatedUser=function(t){return Be(this,void 0,void 0,function(){var n,r;return Ge(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=us("LAST_AUTHENTICATED_USER",this.config.brandId,this.config.applicationId),[4,this.storageManager.set(n,t)];case 1:return i.sent(),[3,3];case 2:return r=i.sent(),this.logger.warn("Failed to persist lastAuthenticatedUser",r),[3,3];case 3:return[2]}})})},t.prototype.storeUserContext=function(t){return Be(this,void 0,void 0,function(){var n,r,i;return Ge(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),n={cuid:t,timestamp:Date.now()},this.currentUserIdentifierType&&(n.userIdentifierType=this.currentUserIdentifierType),r=us("USER_CONTEXT",this.config.brandId,this.config.applicationId),[4,this.storageManager.set(r,JSON.stringify(n))];case 1:return e.sent(),[3,3];case 2:return i=e.sent(),this.logger.warn("Failed to store user context",i),[3,3];case 3:return[2]}})})},t.prototype.init=function(){var t=this;this.initialized?this.logger.warn("WebSDK already initialized"):this.initializationPromise?this.logger.warn("WebSDK initialization already in progress"):this.initializationPromise=this.initializeAsync().catch(function(n){t.logger.error(ys,n),t.initializationPromise=null})},t.prototype.initializeAsync=function(){return Be(this,void 0,void 0,function(){var t,n,r=this;return Ge(this,function(i){switch(i.label){case 0:return i.trys.push([0,13,,14]),this.logger.info("Initializing WebSDK",{version:zo,config:this.config}),[4,this.fetchAndApplyRemoteConfig()];case 1:return i.sent(),[4,this.storageManager.init()];case 2:return i.sent(),[4,this.sessionManager.init()];case 3:return i.sent(),[4,this.authManager.init()];case 4:return i.sent(),this.config.notifications?(t=Le(Le({},this.config.notifications),{firebaseConfig:this.config.firebaseConfig}),this.notificationManager=new Xl(t,this.logger,this.storageManager,this.config.brandId,this.config.applicationId),this.setupTokenUpdateCallback(),[4,this.notificationManager.init()]):[3,6];case 5:i.sent(),this.logger.info("Notifications initialized early for FCM token availability"),i.label=6;case 6:return[4,this.initializeVisitorConfig()];case 7:return i.sent(),[4,this.eventTracker.init()];case 8:return i.sent(),this.eventTracker.setSessionInfoCallback(function(){return Be(r,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return[4,this.sessionManager.getOrCreateSession()];case 1:return[2,t.sent()]}})})}),[4,this.restoreUserContext()];case 9:return i.sent(),[4,this.syncEventTrackerContext()];case 10:return i.sent(),this.initialized=!0,this.notificationManager&&this.setupPermissionChangeDetection(),this.config.notifications?(this.setupDLRServiceWorkerListener(),[4,this.eventTracker.processPendingServiceWorkerDLREvents()]):[3,12];case 11:i.sent(),i.label=12;case 12:return this.logger.info(ps),[3,14];case 13:throw n=i.sent(),new Error("".concat(vs,": ").concat(n));case 14:return[2]}})})},t.prototype.setupPermissionChangeDetection=function(){var t=this;if("undefined"!=typeof document&&"undefined"!=typeof window){var n=function(){return Be(t,void 0,void 0,function(){var t,n,r;return Ge(this,function(i){switch(i.label){case 0:if("visible"!==document.visibilityState)return[2];i.label=1;case 1:return i.trys.push([1,4,,5]),this.notificationManager?this.notificationManager.hasPermissionChanged()?(t="Notification"in window?Notification.permission:"denied",this.logger.info("Notification permission changed detected",{currentPermission:t}),[4,this.notificationManager.handlePermissionChange()]):[3,3]:[2];case 2:(n=i.sent())&&this.logger.info("Notification state updated after permission change",n),i.label=3;case 3:return[3,5];case 4:return r=i.sent(),this.logger.warn("Error handling permission change",r),[3,5];case 5:return[2]}})})};document.addEventListener("visibilitychange",n),window.addEventListener("focus",n),this.permissionChangeCleanup=function(){document.removeEventListener("visibilitychange",n),window.removeEventListener("focus",n)},this.logger.debug("Permission change detection setup complete")}},t.prototype.setupDLRServiceWorkerListener=function(){var t=this;if("undefined"!=typeof navigator&&"serviceWorker"in navigator){var n=function(n){return Be(t,void 0,void 0,function(){var t;return Ge(this,function(r){switch(r.label){case 0:if(!n.data||"HYDRA_DLR_EVENTS_PENDING"!==n.data.type)return[3,4];this.logger.info("Received DLR events pending notification from service worker"),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.eventTracker.processPendingServiceWorkerDLREvents()];case 2:return r.sent(),[3,4];case 3:return t=r.sent(),this.logger.error("Failed to process pending DLR events",t),[3,4];case 4:return[2]}})})};navigator.serviceWorker.addEventListener("message",n),this.dlrMessageCleanup=function(){navigator.serviceWorker.removeEventListener("message",n)},this.logger.debug("DLR service worker message listener setup complete")}},t.prototype.initializeVisitorConfig=function(){return Be(this,void 0,void 0,function(){var t,n,r=this;return Ge(this,function(i){switch(i.label){case 0:return this.logger.info("Initializing visitor configuration"),[4,this.visitorConfigManager.init()];case 1:return i.sent(),t=this,[4,this.visitorConfigManager.isVisitorTrackingEnabled()];case 2:return t.visitorTrackingEnabled=i.sent(),this.visitorTrackingEnabled?(this.logger.info(Zs),[4,this.anonymousVisitorManager.init()]):[3,5];case 3:return i.sent(),[4,this.getOrCreateVisitorId()];case 4:return i.sent(),this.anonymousVisitorManager.retryPendingMerge().catch(function(t){r.logger.warn("Failed to retry pending merge on init",t)}),[3,6];case 5:this.logger.info(Ys),i.label=6;case 6:return(n=this.visitorConfigManager.getCachedConfig())&&n.warnings&&n.warnings.length>0&&n.warnings.forEach(function(t){r.logger.warn("Visitor config warning",{code:t.code,message:t.message})}),[2]}})})},t.prototype.syncEventTrackerContext=function(){return Be(this,void 0,void 0,function(){var t,n,r,i;return Ge(this,function(e){switch(e.label){case 0:return t=null!==(i=null===(r=this.anonymousVisitorManager)||void 0===r?void 0:r.getVisitorRefId())&&void 0!==i?i:null,this.eventTracker.setVisitorTrackingState(this.visitorId,this.visitorTrackingEnabled,t),this.visitorTrackingEnabled?(n=this.config.accountId||"",this.userContextSet?[3,2]:[4,this.eventTracker.setUserContext(n)]):(this.logger.warn("Event tracking disabled: Visitor tracking is off"),[2]);case 1:return e.sent(),this.logger.info("Account context set for visitor tracking"),[3,3];case 2:this.logger.info("User context restored from storage"),e.label=3;case 3:return[2]}})})},t.prototype.getOrCreateVisitorId=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o,u,a,c;return Ge(this,function(f){switch(f.label){case 0:t=[],(n=null===(a=this.notificationManager)||void 0===a?void 0:a.getFCMToken())?(r=this.getChannelType(),t.push({type:r,value:n,primary:!0,verified:!0}),this.logger.info("Including FCM token in visitor creation",{tokenPreview:n.substring(0,20)+"..."})):this.logger.info("No FCM token available, creating visitor without commChannels"),f.label=1;case 1:return f.trys.push([1,5,,6]),this.notificationManager?[4,this.notificationManager.getTokenCreationDate()]:[3,3];case 2:return s=f.sent(),[3,4];case 3:s=null,f.label=4;case 4:return e=s,i=Jv({appVersion:this.config.appVersion||void 0,notificationPermissionGranted:"granted"===(null===(c=this.notificationManager)||void 0===c?void 0:c.getState().permissionStatus),fcmTokenCreatedAt:e||void 0}),this.logger.debug("Extended fields collected",{extendedFields:i}),[3,6];case 5:return o=f.sent(),this.logger.warn("Failed to collect extended fields, proceeding without them",o),i=void 0,[3,6];case 6:return u=this,[4,this.anonymousVisitorManager.getOrCreateVisitorId(t.length>0?t:void 0,i)];case 7:return u.visitorId=f.sent(),this.logger.info("Visitor ID ready",{visitorId:this.visitorId}),[2,this.visitorId]}})})},t.prototype.setupTokenUpdateCallback=function(){var t=this;this.notificationManager&&(this.notificationManager.setTokenUpdateCallback(function(n,r){return Be(t,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:return[4,this.handleTokenUpdate(n,r)];case 1:return t.sent(),[2]}})})}),this.logger.debug("Token update callback configured for backend sync"))},t.prototype.handleTokenUpdate=function(t,n){return Be(this,void 0,void 0,function(){var r,i,e,s,o,u,a,c;return Ge(this,function(f){switch(f.label){case 0:if(!this.visitorId)return this.logger.debug("Skipping token sync - no visitor ID yet (will be included in create)",{isNewToken:n}),[2];if(!n)return this.logger.debug("Skipping token sync - token unchanged"),[2];(r=!t||""===t.trim())?this.logger.info("FCM token cleared (permission revoked), syncing with backend",{visitorId:this.visitorId}):this.logger.info("FCM token updated, syncing with backend",{visitorId:this.visitorId,tokenPreview:t.substring(0,20)+"..."}),f.label=1;case 1:f.trys.push([1,9,,10]),i=r?[]:[{type:this.getChannelType(),value:t,primary:!0,verified:!0}],e=void 0,f.label=2;case 2:return f.trys.push([2,6,,7]),r||!this.notificationManager?[3,4]:[4,this.notificationManager.getTokenCreationDate()];case 3:return o=f.sent(),[3,5];case 4:o=null,f.label=5;case 5:return s=o,e=Jv({appVersion:this.config.appVersion||void 0,notificationPermissionGranted:"granted"===(null===(c=this.notificationManager)||void 0===c?void 0:c.getState().permissionStatus),fcmTokenCreatedAt:s||void 0}),[3,7];case 6:return u=f.sent(),this.logger.warn("Failed to collect extended fields for token update",u),e=void 0,[3,7];case 7:return[4,this.anonymousVisitorManager.updateVisitor(i,e)];case 8:return f.sent(),r?this.logger.info("Empty commChannels synced with backend (permission revoked)",{visitorId:this.visitorId}):this.logger.info("FCM token synced with backend successfully",{visitorId:this.visitorId}),[3,10];case 9:return a=f.sent(),this.logger.error("Failed to sync FCM token with backend",a),[3,10];case 10:return[2]}})})},t.prototype.getVisitorId=function(){return this.visitorId},t.prototype.setUserContext=function(t){return Be(this,void 0,void 0,function(){var n,r;return Ge(this,function(i){switch(i.label){case 0:if(!this.initialized)throw new Error("WebSDK must be initialized before setting user context");return[4,this.validateAndClearDifferentUserContext(t)];case 1:return i.sent(),n=this.config.accountId||"",[4,this.eventTracker.setUserContext(n,t,null!==(r=this.currentUserIdentifierType)&&void 0!==r?r:void 0)];case 2:return i.sent(),this.userContextSet=!0,this.visitorId&&this.logger.info("User identified - transitioning from anonymous to identified tracking",{visitorId:this.visitorId,cuid:t,trackingMode:"identified"}),[4,this.storeUserContext(t)];case 3:return i.sent(),this.logger.info("User context set and persisted",{cuid:t,accountId:this.config.accountId}),[2]}})})},t.prototype.clearUserContext=function(){return Be(this,void 0,void 0,function(){var t,n;return Ge(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),t=us("USER_CONTEXT",this.config.brandId,this.config.applicationId),[4,this.storageManager.remove(t)];case 1:return r.sent(),this.eventTracker&&this.eventTracker.clearUserContext(),this.currentUserIdentifierType=null,this.userContextSet=!1,this.logger.info("User context cleared"),[3,3];case 2:return n=r.sent(),this.logger.warn("Failed to clear user context",n),this.currentUserIdentifierType=null,this.userContextSet=!1,[3,3];case 3:return[2]}})})},t.prototype.track=function(t,n){this.sdkDisabled?this.logger.debug("SDK disabled, dropping track call",{eventName:t}):this.pushEvent(t,n)},t.prototype.pageView=function(t){var n,r;if(this.sdkDisabled)this.logger.debug("SDK disabled, dropping pageView call");else{var i=null!==(n=null==t?void 0:t.url)&&void 0!==n?n:"undefined"!=typeof window?window.location.href:void 0,e=null!==(r=null==t?void 0:t.title)&&void 0!==r?r:"undefined"!=typeof document?document.title:void 0,s=Le(Le(Le(Le({},i&&{url:i}),e&&{title:e}),(null==t?void 0:t.category)&&{category:t.category}),null==t?void 0:t.properties);this.pushEvent("page_view",s)}},t.prototype.identify=function(t){var n,r;if(this.sdkDisabled)this.logger.debug("SDK disabled, dropping identify call");else{var i=t.identifier,e=t.actionType,s=t.traits,o=void 0===s?{}:s;if(!i||!i.cuid)throw new Error("identifier with a non-empty cuid is required for identify");if(!["email","mobile","externalId"].includes(i.type))throw new Error("Invalid identifier type: ".concat(i.type,". Must be 'email', 'mobile', or 'externalId'."));var u=i.cuid;this.currentUserIdentifierType=i.type;var a=Le(Le(Le(Le({firstName:null!==(n=o.firstName)&&void 0!==n?n:"",lastName:null!==(r=o.lastName)&&void 0!==r?r:""},"email"===i.type&&{email:u}),"mobile"===i.type&&{mobile:u}),"externalId"===i.type&&{externalId:u}),void 0!==o.custom&&{customData:o.custom}),c={};switch(o.gender&&(c.gender=o.gender),o.birthday&&(c.birthday=o.birthday),o.city&&(c.city=o.city),o.country&&(c.country=o.country),o.timezone&&(c.timezone=o.timezone),Object.keys(c).length>0&&(a.customData=Le(Le({},c),a.customData)),e){case"USER_REGISTER":this.pushUserSignin(u,a);break;case"USER_UPDATE":this.pushUserUpdate(u,a);break;default:throw this.logger.error("Invalid identify actionType",{actionType:e,cuid:u}),new Error("Invalid identify actionType: ".concat(e,". Must be 'USER_REGISTER' or 'USER_UPDATE'."))}}},t.prototype.trackEvent=function(t){return Be(this,void 0,void 0,function(){var n;return Ge(this,function(r){switch(r.label){case 0:if(!this.initialized)throw new Error("WebSDK must be initialized before tracking events");r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.eventTracker.track(t)];case 2:return r.sent(),[3,4];case 3:throw n=r.sent(),this.logger.error(Ds,{event:t,error:n}),n;case 4:return[2]}})})},t.prototype.destroy=function(){return Be(this,void 0,void 0,function(){var t;return Ge(this,function(n){switch(n.label){case 0:this.logger.info("Destroying WebSDK instance"),n.label=1;case 1:return n.trys.push([1,18,,19]),this.eventTracker?[4,this.eventTracker.flush()]:[3,4];case 2:return n.sent(),[4,this.eventTracker.destroy()];case 3:n.sent(),n.label=4;case 4:return this.authManager?[4,this.authManager.destroy()]:[3,6];case 5:n.sent(),n.label=6;case 6:return this.visitorConfigManager?[4,this.visitorConfigManager.destroy()]:[3,8];case 7:n.sent(),n.label=8;case 8:return this.anonymousVisitorManager?[4,this.anonymousVisitorManager.destroy()]:[3,10];case 9:n.sent(),n.label=10;case 10:return this.permissionChangeCleanup&&(this.permissionChangeCleanup(),this.permissionChangeCleanup=null),this.dlrMessageCleanup&&(this.dlrMessageCleanup(),this.dlrMessageCleanup=null),this.notificationManager?(this.notificationManager.clearTokenUpdateCallback(),[4,this.notificationManager.destroy()]):[3,12];case 11:n.sent(),this.notificationManager=null,n.label=12;case 12:return this.sessionManager?[4,this.sessionManager.destroy()]:[3,14];case 13:n.sent(),n.label=14;case 14:return this.storageManager?[4,this.clearUserContext()]:[3,17];case 15:return n.sent(),[4,this.storageManager.destroy()];case 16:n.sent(),n.label=17;case 17:return this.initialized=!1,this.logger.info(bs),[3,19];case 18:throw t=n.sent(),this.logger.error(bs,t),t;case 19:return[2]}})})},t.prototype.validateUserAttributes=function(t){if(!t.email&&!t.mobile&&!t.externalId)throw new Error("At least one of email, mobile, or externalId is required")},t.prototype.attemptVisitorMerge=function(t){try{if(!this.visitorTrackingEnabled||!this.visitorId)return;if(!t.email&&!t.mobile&&!t.externalId)return void this.logger.debug(fo,{reason:"No email, mobile, or externalId"});this.anonymousVisitorManager.mergeVisitorWithUser(t.firstName,t.lastName,t.email,t.mobile,t.externalId,t.customData),this.logger.info("Visitor merge triggered in background",{visitorId:this.visitorId})}catch(t){this.logger.warn("Visitor merge attempt failed, proceeding with user flow",t)}},t.prototype.buildUserEventData=function(t,n){return Le(Le(Le(Le({cuid:t,firstName:n.firstName,lastName:n.lastName},n.email&&{email:n.email}),n.mobile&&{mobile:n.mobile}),n.externalId&&{externalId:n.externalId}),n.customData&&{customData:n.customData})},t.prototype.pushUserSignin=function(t,n){var r=this;this.pushUserSigninAsync(t,n).catch(function(n){r.logger.error(Ws,{cuid:t,error:n})})},t.prototype.pushUserSigninAsync=function(t,n){return Be(this,void 0,void 0,function(){var r,i;return Ge(this,function(e){switch(e.label){case 0:return[4,this.ensureInitialized()];case 1:return e.sent(),this.validateUserAttributes(n),[4,this.setUserContextIfNeeded(t)];case 2:e.sent(),this.attemptVisitorMerge(n),r={type:"user",name:Ro,timestamp:Date.now(),userId:t,data:this.buildUserEventData(t,n)},e.label=3;case 3:return e.trys.push([3,5,,6]),[4,this.trackEvent(r)];case 4:return e.sent(),this.logger.info("User signin event tracked",{cuid:t,firstName:n.firstName,lastName:n.lastName,email:n.email}),[3,6];case 5:throw i=e.sent(),this.logger.error(Ws,{cuid:t,error:i}),i;case 6:return[2]}})})},t.prototype.pushUserSignup=function(t,n){var r=this;this.pushUserSignupAsync(t,n).catch(function(n){r.logger.error(qs,{cuid:t,error:n})})},t.prototype.pushUserSignupAsync=function(t,n){return Be(this,void 0,void 0,function(){var r,i;return Ge(this,function(e){switch(e.label){case 0:return[4,this.ensureInitialized()];case 1:return e.sent(),this.validateUserAttributes(n),[4,this.setUserContextIfNeeded(t)];case 2:e.sent(),this.attemptVisitorMerge(n),r={type:"user",name:Ao,timestamp:Date.now(),userId:t,data:this.buildUserEventData(t,n)},e.label=3;case 3:return e.trys.push([3,5,,6]),[4,this.trackEvent(r)];case 4:return e.sent(),this.logger.info("User signup event tracked",{cuid:t,firstName:n.firstName,lastName:n.lastName,email:n.email}),[3,6];case 5:throw i=e.sent(),this.logger.error(qs,{cuid:t,error:i}),i;case 6:return[2]}})})},t.prototype.pushUserUpdate=function(t,n){var r=this;this.pushUserUpdateAsync(t,n).catch(function(n){r.logger.error(Ks,{cuid:t,error:n})})},t.prototype.pushUserUpdateAsync=function(t,n){return Be(this,void 0,void 0,function(){var r,i;return Ge(this,function(e){switch(e.label){case 0:return[4,this.ensureInitialized()];case 1:return e.sent(),this.validateUserAttributes(n),[4,this.setUserContextIfNeeded(t)];case 2:e.sent(),r={type:"user",name:_o,timestamp:Date.now(),userId:t,data:this.buildUserEventData(t,n)},e.label=3;case 3:return e.trys.push([3,5,,6]),[4,this.trackEvent(r)];case 4:return e.sent(),this.logger.info("User update event tracked",{cuid:t,firstName:n.firstName,lastName:n.lastName,email:n.email}),[3,6];case 5:throw i=e.sent(),this.logger.error(Ks,{cuid:t,error:i}),i;case 6:return[2]}})})},t.prototype.reset=function(){if(this.sdkDisabled)this.logger.debug("SDK disabled, dropping reset call");else{var t=this.lastAuthenticatedUser;t?this.pushUserSignOut(t):this.logger.warn("reset() called but no authenticated user to sign out")}},t.prototype.pushUserSignOut=function(t){var n=this;this.pushUserSignOutAsync(t).catch(function(r){n.logger.error(Hs,{cuid:t,error:r})})},t.prototype.pushUserSignOutAsync=function(t){return Be(this,void 0,void 0,function(){var n,r,i,e,s,o,u,a,c,f,h,d,v,l,g,w,m,p;return Ge(this,function(y){switch(y.label){case 0:return[4,this.ensureInitialized()];case 1:return y.sent(),[4,this.setUserContextIfNeeded(t)];case 2:y.sent(),n={type:"user",name:Co,timestamp:Date.now(),userId:t,data:{cuid:t}},y.label=3;case 3:return y.trys.push([3,5,,6]),[4,this.trackEvent(n)];case 4:return y.sent(),this.logger.info("User signout event tracked",{cuid:t}),[3,6];case 5:return r=y.sent(),this.logger.warn("Failed to track signout event (tracking may be disabled)",{cuid:t,error:r}),[3,6];case 6:return y.trys.push([6,27,,28]),[4,this.anonymousVisitorManager.clearMergedUserId()];case 7:return y.sent(),[4,this.anonymousVisitorManager.clearPendingMerge()];case 8:return y.sent(),[4,this.clearUserContext()];case 9:y.sent(),this.logger.info("User context cleared, returning to anonymous mode (session continues)"),y.label=10;case 10:return y.trys.push([10,12,,13]),[4,this.visitorConfigManager.refreshConfig()];case 11:return i=y.sent(),this.visitorTrackingEnabled=!0===(null===(w=i.data)||void 0===w?void 0:w.visitorTrackingEnabled),this.logger.info("Visitor config refreshed on signout",{visitorTrackingEnabled:this.visitorTrackingEnabled}),[3,13];case 12:return e=y.sent(),this.logger.warn("Failed to refresh visitor config on signout, using existing value",{visitorTrackingEnabled:this.visitorTrackingEnabled,error:e}),[3,13];case 13:if(!this.visitorTrackingEnabled)return[3,25];y.label=14;case 14:return y.trys.push([14,23,,24]),[4,this.anonymousVisitorManager.clearVisitorId()];case 15:y.sent(),this.logger.info("Visitor ID cleared on user signout"),s=[],(o=null===(m=this.notificationManager)||void 0===m?void 0:m.getFCMToken())&&(u=this.getChannelType(),s.push({type:u,value:o,primary:!0,verified:!0})),a=void 0,y.label=16;case 16:return y.trys.push([16,20,,21]),this.notificationManager?[4,this.notificationManager.getTokenCreationDate()]:[3,18];case 17:return f=y.sent(),[3,19];case 18:f=null,y.label=19;case 19:return c=f,a=Jv({appVersion:this.config.appVersion||void 0,notificationPermissionGranted:"granted"===(null===(p=this.notificationManager)||void 0===p?void 0:p.getState().permissionStatus),fcmTokenCreatedAt:c||void 0}),[3,21];case 20:return h=y.sent(),this.logger.warn("Failed to collect extended fields on signout, proceeding without them",h),a=void 0,[3,21];case 21:return d=this,[4,this.anonymousVisitorManager.getOrCreateVisitorId(s.length>0?s:void 0,a)];case 22:return d.visitorId=y.sent(),this.logger.info("New anonymous visitor ID generated after signout",{visitorId:this.visitorId,hasFCMToken:!!o}),v=this.anonymousVisitorManager.getVisitorRefId(),this.eventTracker.setVisitorTrackingState(this.visitorId,!0,v),[3,24];case 23:return l=y.sent(),this.logger.warn("Failed to regenerate visitor ID on signout",l),this.visitorId=null,this.eventTracker.setVisitorTrackingState(null,!0),[3,24];case 24:return[3,26];case 25:this.logger.info("Visitor tracking disabled per latest config, skipping anonymous mode"),this.visitorId=null,this.eventTracker.setVisitorTrackingState(null,!1),y.label=26;case 26:return this.logger.info("SDK remains active for anonymous tracking"),[3,28];case 27:throw g=y.sent(),this.logger.error("Failed to clear user context on signout",g),g;case 28:return[2]}})})},t.prototype.pushEvent=function(t,n){var r=this;this.pushEventAsync(t,n).catch(function(n){r.logger.error(Xs,{eventName:t,error:n})})},t.prototype.pushEventAsync=function(t,n){return Be(this,void 0,void 0,function(){var r,i,e;return Ge(this,function(s){switch(s.label){case 0:return[4,this.ensureInitialized()];case 1:if(s.sent(),!this.visitorTrackingEnabled)return this.logger.warn("Event tracking skipped: Visitor tracking is disabled",{eventName:t}),[2];if(!this.userContextSet&&!this.visitorId)return this.logger.warn("Event tracking skipped: No visitor ID available and no user context set",{eventName:t}),[2];r=Le({event_name:t},n&&n),i={type:"behavioral",name:t,timestamp:Date.now(),data:r},s.label=2;case 2:return s.trys.push([2,4,,5]),[4,this.trackEvent(i)];case 3:return s.sent(),this.logger.info("Behavioral event tracked",{eventName:t,attributes:n}),[3,5];case 4:throw e=s.sent(),this.logger.error(Xs,{eventName:t,error:e}),e;case 5:return[2]}})})},t.prototype.disableSDK=function(){this.sdkDisabled?this.logger.warn("SDK is already disabled"):(this.sdkDisabled=!0,this.eventTracker&&this.eventTracker.pause(),this.logger.info("SDK disabled — event tracking stopped"))},t.prototype.enableSDK=function(){var t=this;this.sdkDisabled?(this.sdkDisabled=!1,this.eventTracker&&this.eventTracker.resume().catch(function(n){t.logger.error("Failed to resume event tracker",n)}),this.logger.info("SDK enabled — event tracking resumed")):this.logger.warn("SDK is already enabled")},t.prototype.getNotificationState=function(){return this.notificationManager?this.notificationManager.getState():null},t.prototype.getFCMToken=function(){return this.notificationManager?this.notificationManager.getFCMToken():null},t.prototype.isNotificationsEnabled=function(){return!!this.notificationManager&&this.notificationManager.isEnabled()},t.prototype.refreshFCMToken=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:if(!this.initialized)throw new Error("WebSDK must be initialized before refreshing FCM token");return this.notificationManager?[4,this.notificationManager.refreshToken()]:(this.logger.warn("Notification manager not initialized"),[2,null]);case 1:return[2,t.sent()]}})})},t.prototype.reinitializeNotifications=function(){return Be(this,void 0,void 0,function(){var t,n,r;return Ge(this,function(i){switch(i.label){case 0:if(!this.initialized)throw new Error("WebSDK must be initialized before reinitializing notifications");return this.config.notifications?"granted"!==(t="undefined"!=typeof window&&"Notification"in window?Notification.permission:"denied")?(this.logger.warn("Cannot reinitialize notifications - permission not granted",{permission:t}),[2,null]):(this.notificationManager||(this.logger.info("Initializing notification manager for the first time"),n=Le(Le({},this.config.notifications),{firebaseConfig:this.config.firebaseConfig}),this.notificationManager=new Xl(n,this.logger,this.storageManager,this.config.brandId,this.config.applicationId),this.setupTokenUpdateCallback()),this.logger.info("Reinitializing notifications after permission granted"),[4,this.notificationManager.init()]):(this.logger.warn("Notifications not configured"),[2,null]);case 1:return r=i.sent(),this.logger.info("Notifications reinitialized successfully",r),[2,r]}})})},t.prototype.hasNotificationPermissionChanged=function(){return!!this.notificationManager&&this.notificationManager.hasPermissionChanged()},t.prototype.handleNotificationPermissionChange=function(){return Be(this,void 0,void 0,function(){return Ge(this,function(t){switch(t.label){case 0:if(!this.initialized)throw new Error("WebSDK must be initialized before handling permission changes");return this.notificationManager?(this.logger.info("Handling notification permission change"),[4,this.notificationManager.handlePermissionChange()]):(this.logger.warn("Notification manager not initialized"),[2,null]);case 1:return[2,t.sent()]}})})},t.prototype.getRemoteConfigString=function(t){if(!this.notificationManager)return this.logger.warn("Notification manager not initialized"),"";var n=this.notificationManager.firebaseManager;return n?n.getRemoteConfigString(t):(this.logger.warn("Firebase manager not initialized"),"")},t.prototype.getRemoteConfigBoolean=function(t){if(!this.notificationManager)return this.logger.warn("Notification manager not initialized"),!1;var n=this.notificationManager.firebaseManager;return n?n.getRemoteConfigBoolean(t):(this.logger.warn("Firebase manager not initialized"),!1)},t.prototype.getRemoteConfigNumber=function(t){if(!this.notificationManager)return this.logger.warn("Notification manager not initialized"),0;var n=this.notificationManager.firebaseManager;return n?n.getRemoteConfigNumber(t):(this.logger.warn("Firebase manager not initialized"),0)},t.prototype.getChannelType=function(){return this.config.channelType||No.WEB},t.prototype.getAllRemoteConfigValues=function(){if(!this.notificationManager)return this.logger.warn("Notification manager not initialized"),{};var t=this.notificationManager.firebaseManager;return t?t.getAllRemoteConfigValues():(this.logger.warn("Firebase manager not initialized"),{})},t.prototype.fetchAndApplyRemoteConfig=function(){return Be(this,void 0,void 0,function(){var t,n,r,i,e,s,o,u,a,c,f,h,d,v,l,g,w,m,p,y=this;return Ge(this,function(b){switch(b.label){case 0:this.logger.info("📡 Fetching configuration from Firebase Remote Config..."),b.label=1;case 1:return b.trys.push([1,5,,6]),[4,Wl()];case 2:return t=b.sent(),[4,Kl()];case 3:return n=b.sent(),r=t.initializeApp||t,i=n.getRemoteConfig||n,e=n.fetchAndActivate,s=n.getValue,o=r(this.config.firebaseConfig),(u=i(o)).settings.minimumFetchIntervalMillis=36e5,this.logger.info("🔄 Fetching Remote Config from Firebase..."),[4,e(u)];case 4:if(b.sent()||this.logger.warn("⚠️ Remote Config fetched but not activated (using cached values)"),a=s(u,this.config.remoteConfigKey),!(c=a.asString()))throw new Error('Remote Config key "'.concat(this.config.remoteConfigKey,'" is empty or not found'));f=void 0;try{f=JSON.parse(c)}catch(t){throw new Error("Failed to parse Remote Config JSON: ".concat(t))}return this.logger.info("✅ Remote Config fetched successfully:",f),this.config.accountId=f.accountId,this.config.baseURL=f.baseURL,this.config.orgId=f.orgId,this.config.vapId=f.vapId||this.config.firebaseConfig.messagingSenderId,this.config.source=f.source||Fo.WEBPUSH,this.config.channelType=f.channelType||No.WEB,this.config.brandId=this.config.brandId||f.brandId,this.config.applicationId=this.config.applicationId||f.applicationId,h=ns/6e4,this.config.sessionTimeoutMinutes=f.sessionTimeoutMinutes||h,this.config.batchSize=f.batchSize||rs.BATCH_SIZE,this.config.debugLevel=f.debugLevel||"NONE",d=this.shouldEnableLogging(this.config.debugLevel),this.logger.setEnabled(d),this.logger.info("Session timeout configured:",{timeoutMinutes:this.config.sessionTimeoutMinutes,source:f.sessionTimeoutMinutes?"Remote Config":"Default"}),this.logger.info("Batch size configured:",{batchSize:this.config.batchSize,source:f.batchSize?"Remote Config":"Default"}),this.logger.info("Debug level configured:",{debugLevel:this.config.debugLevel,source:f.debugLevel?"Remote Config":"Default"}),this.storageManager=new Nl(this.logger,this.config.brandId,this.config.applicationId),this.sessionManager=new $l(this.storageManager,this.logger,this.config.brandId,this.config.applicationId,this.config.sessionTimeoutMinutes),this.authManager=new Fl(this.config,this.logger,this.storageManager),this.eventTracker=new Dl(this.config,this.authManager,this.storageManager,this.logger),v=this.authManager.getApiClient(),l=this.config.orgId||"",g=this.config.vapId||"",w=this.config.accountId||"",m=this.config.source||Fo.WEBPUSH,this.visitorConfigManager=new jl(l,g,v,this.logger,this.storageManager,this.config.brandId,this.config.applicationId),this.anonymousVisitorManager=new Ll(w,l,g,m,v,this.logger,this.storageManager,this.config.brandId,this.config.applicationId),this.anonymousVisitorManager.setMergeDataProviders(function(){var t;return(null===(t=y.notificationManager)||void 0===t?void 0:t.getFCMToken())||null},function(){return y.getChannelType()},function(){return Be(y,void 0,void 0,function(){var t,n,r;return Ge(this,function(i){switch(i.label){case 0:return i.trys.push([0,4,,5]),this.notificationManager?[4,this.notificationManager.getTokenCreationDate()]:[3,2];case 1:return n=i.sent(),[3,3];case 2:n=null,i.label=3;case 3:return t=n,[2,Jv({appVersion:this.config.appVersion||void 0,notificationPermissionGranted:"granted"===(null===(r=this.notificationManager)||void 0===r?void 0:r.getState().permissionStatus),fcmTokenCreatedAt:t||void 0})];case 4:return i.sent(),[2,void 0];case 5:return[2]}})})}),this.logger.info("✅ SDK configuration applied from Remote Config"),this.logger.debug("Final SDK config:",this.config),[3,6];case 5:throw p=b.sent(),this.logger.error("❌ Failed to fetch Remote Config:",p),new Error("Remote Config bootstrap failed: ".concat(p));case 6:return[2]}})})},t.prototype.validateRequiredConfig=function(t){var n=[];if(t.firebaseConfig||n.push("firebaseConfig"),t.remoteConfigKey||n.push("remoteConfigKey"),n.length>0)throw new Error("WebSDK initialization failed: Missing required configuration fields: ".concat(n.join(", ")))},t.prototype.ensureInitialized=function(){return Be(this,void 0,void 0,function(){var t;return Ge(this,function(n){switch(n.label){case 0:if(!this.initializationPromise)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.initializationPromise];case 2:return n.sent(),[3,4];case 3:throw t=n.sent(),new Error("SDK initialization failed: ".concat(t));case 4:if(!this.initialized)throw new Error("WebSDK must be initialized before tracking events. Call init() first.");return[2]}})})},t.prototype.setUserContextIfNeeded=function(t){return Be(this,void 0,void 0,function(){return Ge(this,function(n){switch(n.label){case 0:return this.userContextSet?[3,2]:[4,this.setUserContext(t)];case 1:n.sent(),this.logger.debug("User context set automatically",{cuid:t}),n.label=2;case 2:return[2]}})})},t.I=null,t}()});