@mparticle/web-rokt-kit 3.6.2 → 3.7.0

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,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ne=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Ue=new Set(Ne);function me(i){return Ue.has(i.toLowerCase())}function y(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];me(s)||(e[s]=t[s])}return e}function m(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function U(i){return typeof i=="function"}function S(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function z(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function Ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const h="mp-rokt-kit",ee="__rokt_ls_probe__";function H(){try{return window.localStorage.setItem(ee,"1"),window.localStorage.removeItem(ee),!0}catch{return!1}}const R=()=>window.localStorage;function $(i,e=R){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function _e(i,e,t=R){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Ce(i,e=R){try{e().removeItem(i)}catch{}}function O(i,e,t=R){const n=$(i,t);return m(n)?n[e]:void 0}function x(i,e,t,n=R){const r=$(i,n),s=m(r)?{...r}:{};return s[e]=t,_e(i,s,n)}function Y(i,e,t=R){const n=$(i,t);if(!m(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Ce(i,t):_e(i,r,t)}const q="pageViews",D="utmParams",Ie=25,Ke=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function ye(i){return i.slice(-Ie)}function te(){const i=O(h,q);return Array.isArray(i)?i:[]}function De(i){const e=ye(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(x(h,q,n))return n.length}return 0}function ie(){Y(h,q)}function Me(i){const e=ye(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=s&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Fe(i){if(O(h,D)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ke){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!x(h,D,t)){const r=H()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function xe(){const i=O(h,D);return m(i)?i:null}function ne(){Y(h,D)}function Ye(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return z(e)}const J=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"],optionalAttributeKeys:["firstname","lastname"]},{accountId:"2550745407543340151",pathname:"/checkout",targetPageIdentifier:"RoktExperience",attributeKeys:["email","firstname","lastname","customertype","loyaltytier","paymenttype","ccbin"],optionalAttributeKeys:["loyaltytier","paymenttype","ccbin"]},{accountId:"3236704179315511296",pathname:"/check-out/pay",targetPageIdentifier:"confirmation_page",attributeKeys:["email","firstname","lastname","loyaltytier"],optionalAttributeKeys:["firstname","lastname","loyaltytier"]}],Ge=6e4;function je(i){return m(i)&&typeof i.expiresAt=="number"&&m(i.attributes)}function He(i,e){return`activePreselect:${i}:${e}`}function Ve(i){const e=O(h,i);return je(e)?e:null}function We(i,e){x(h,i,{expiresAt:Date.now()+Ge,attributes:e})}const ze=5*6e4;function M(){return window.sessionStorage}function $e(i){return m(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&m(i.attributes)&&g(i.mpid)}function B(i){return`pendingPreselect:${i}`}function qe(i){const e=B(i),t=O(h,e,M);return $e(t)?t.expiresAt<=Date.now()?(Y(h,e,M),null):t:null}function Je(i,e,t,n,r){return x(h,B(i),{expiresAt:Date.now()+ze,pathname:e,identifier:t,attributes:n,mpid:r},M)}function L(i){Y(h,B(i),M)}function A(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function Se(i,e){if(i)return J.find(t=>t.accountId===i&&t.pathname===e)}function Be(i,e){if(!(!i||!g(e)))return J.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function Qe(i,e){return i?J.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function Xe(){return{pending:[]}}function j(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function V(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function Ae(i){const e=i?.getMPID?.();return e==null?null:String(e)}function Pe(i,e){const t=new Set((i.optionalAttributeKeys??[]).map(n=>n.toLowerCase()));return i.attributeKeys.filter(n=>!t.has(n.toLowerCase())&&S(e[n]))}function re(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r={};for(const s of t.attributeKeys){const o=i.getEventAttributeValue(e,s),c=S(o)?i.userAttributes[s]??n[s]:o;S(c)||(r[s]=c)}return{collected:r,missingKeys:Pe(t,r)}}function Ze(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function be(i,e,t,n,r,s){const o=He(e,t),c=Ve(o),u=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&u){i.logPlacementDiagnostic(A("skipped","active_preselection"));return}We(o,r),i.logPlacementDiagnostic(A("fired",s)),Ze(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function et(i,e){if(!e.accountId||!e.isKitReady())return;const t=qe(e.accountId);if(!t)return;if(i.pending.some(o=>o.pathname===t.pathname)){L(e.accountId);return}if(!e.isPreselectionEnabled()){L(e.accountId);return}if(!V(e.filteredUser)||(L(e.accountId),Ae(e.filteredUser)!==t.mpid))return;const n=Se(e.accountId,t.pathname);if(!n||n.targetPageIdentifier!==t.identifier)return;const r=y(t.attributes),s=Pe(n,r);if(s.length>0){for(const o of s)e.logPlacementDiagnostic(A("missed",`missing_persisted_attribute:${o}`));return}be(e,e.accountId,t.identifier,t.identifier,r,"recovered")}function Re(i,e,t,n=window.location.pathname){const r=Se(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],u=Ae(e.filteredUser);if(e.accountId&&u&&V(e.filteredUser)){const{collected:l,missingKeys:f}=re(e,t,r);if(f.length===0){const k=y(l);Je(e.accountId,n,r.targetPageIdentifier,k,u)||c.push(A("queued","persist_failed"))}}j(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!V(e.filteredUser)){e.logPlacementDiagnostic(A("missed","no_valid_identity")),j(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=re(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(A("missed",`missing_attribute:${c}`));j(i,{event:t,pathname:n});return}be(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function tt(i,e,t=window.location.pathname){if(et(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),Re(i,e,r,s))})}function it(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function nt(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function rt(i){i.lifecycle="attached"}function st(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function ot(i){i.lifecycle="terminated"}function ct(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function at(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const d="Rokt",C=181,lt="selectPlacements",ut="apps.roktecommerce.com",dt=.1,ht="ThankYouPageJourney",gt="rokt-launcher",ft="rokt-thank-you-element",pt="userIdentifiedInWorkspace",mt=3,Et=2,_t="page_events",It="page_view_attributes",yt="mparticle_session_id",St="mparticle_device_id",se=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},P={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},At="apps.rokt-api.com",Pt="/v1/log",bt="/v1/errors",Rt=10;function a(){return window.mParticle}function oe(i,e){const n=[G(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function ce(i){return[G(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function G(i){const e=i!==void 0?i:At;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function ke(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return G(r)+t}function ae(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function K(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function le(i){const e=i?K(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(ht)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function kt(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ue(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function de(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function he(i,e,t){return a().generateHash([i,e,t].join(""))}function vt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.6.2";return i&&(n+="_"+i),n}function W(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function ge(i,e){const t=Ee(window.location.origin);if(b._allowedOriginHashes.indexOf(t)===-1||Math.random()>=dt)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?G(i):"https://apps.rokt.com";W(c+"/v1/wsdk-init/index.html?"+o),W("https://"+ut+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function wt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Tt(){return typeof window<"u"?window.location?.href:void 0}function Lt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class ve{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Rt}}class F{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new ve,this._isEnabled=wt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:Tt(),deviceInfo:Lt(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const f=new Error("HTTP "+l.status+" from log endpoint");throw f.statusCode=l.status,f}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class fe{constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=ke(e?.errorUrl,e?.integrationDomain,bt)}report(e){if(!e)return;const t=e.severity||P.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class pe{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._placementDiagnosticTransport=new F(e,n,r,s),this._loggingUrl=ke(e?.loggingUrl,e?.integrationDomain,Pt),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,P.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?P.ERROR:P.WARNING})}})}}function Ot(i){const e=z(window.location.href),t=i.EventAttributes?.title||document.title,n=Ye(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const _=class _{constructor(){this.name=d,this.id=C,this.moduleId=C,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=it(),this.accountId=null,this._preselectState=Xe()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(S(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=z(window.location.href);const n=te(),r=Ot(e);n.push(r);const s=Math.min(n.length,Ie),o=De(n);if(o===0){const c=H()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=H()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=Be(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){tt(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&U(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[_.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!m(e))return;const t=a().EventType.Other;a().logEvent(lt,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&U(t.setIntegrationAttribute)&&t.setIntegrationAttribute(C,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(U(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){nt(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await kt([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(ot(this._launcherAttachState),!c){const u=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${u}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return at(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,rt(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,ge(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=y(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=K(o.placementEventMapping);this.placementEventMappingLookup=ue(u);const l=K(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=de(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const f=a().Rokt?.domain,{roktExtensionsQueryParams:k,legacyRoktExtensions:v,loadThankYouElement:N}=le(o.roktExtensions),E={...a().Rokt?.launcherOptions||{}};this.integrationName=vt(E.integrationName),E.integrationName=this.integrationName,this.domain=f;const w={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:f,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new fe(w,this.integrationName,window.__rokt_li_guid__,o.accountId),T=new pe(w,I,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=I,this.loggingService=T,this.isTargetingDisabled())try{ie(),ne()}catch(p){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:P.INFO,stackTrace:p instanceof Error?p.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(T),n?(this.testHelpers={generateLauncherScript:oe,generateThankYouElementScript:ce,extractRoktExtensionConfig:le,hashEventMessage:he,parseSettingsString:K,generateMappedEventLookup:ue,generateMappedEventAttributeLookup:de,sendAdBlockMeasurementSignals:ge,createAutoRemovedIframe:W,djb2:Ee,setAllowedOriginHashes:p=>{_._allowedOriginHashes=p},ReportingTransport:F,ErrorReportingService:fe,LoggingService:pe,RateLimiter:ve,ErrorCodes:Q,WSDKErrorSeverity:P,resetLauncherAttachState:()=>ct(this._launcherAttachState)},this.attachLauncher(c,E),"Successfully initialized: "+d):(N&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),ae(ft,ce(f),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:p=>{console.error("Error loading Rokt Thank You Element script:",p)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,E,v):(ae(gt,oe(f,k),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,E,v):console.error("Rokt object is not available after script load.")},onError:p=>{console.error("Error loading Rokt launcher script:",p)}}),this.captureTiming(_.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===mt&&(Fe(this.loggingService),this.capturePageView(e),Re(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===Et&&(ie(),ne(),this.accountId&&L(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(U(a().Rokt?.setLocalSessionAttribute)&&(S(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!S(this.placementEventMappingLookup))){const t=he(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return me(e)||(this.userAttributes[e]=t),Qe(this.accountId,e)&&this.flushPendingPreselectDispatches(),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=y(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];g(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.accountId&&L(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,se))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,se))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...y(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=y(l);const f=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},k=this.returnUserIdentities(c),v=this.returnLocalSessionAttributes(),N=Me(te()),E=xe(),w=this.readMpSessionId(),I=this.readMpDeviceId(),T={...k,...l,...f,...v,...N.length?{[_t]:JSON.stringify(N)}:{},...E?{[It]:E}:{},...this.userIdentifiedInWorkspace?{[pt]:!0}:{},...w?{[yt]:w}:{},...I?{[St]:I}:{},mpid:u},p=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),we={...e,attributes:T,...p!==void 0?{cacheMatchKeys:p}:{}},X=this.launcher.selectPlacements(we),Z=e.preselect===!0,Te=()=>{Z||this.logSelectPlacementsEvent(T)};return Promise.resolve(X).then(Le=>{if(!Z)return Le?.context?.sessionId?.then(Oe=>this.setRoktSessionId(Oe))}).catch(()=>{}).finally(Te),X}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(st(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};_._allowedOriginHashes=[-553112570,549508659],_.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},_.EMAIL_SHA256_KEY="emailsha256";let b=_;function Nt(){return C}function Ut(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!m(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}m(i.kits)?i.kits[d]={constructor:b}:(i.kits={},i.kits[d]={constructor:b}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:b,getId:Nt});exports.register=Ut;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ne=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Ue=new Set(Ne);function me(i){return Ue.has(i.toLowerCase())}function y(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];me(s)||(e[s]=t[s])}return e}function m(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function U(i){return typeof i=="function"}function S(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function z(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function Ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const h="mp-rokt-kit",ee="__rokt_ls_probe__";function H(){try{return window.localStorage.setItem(ee,"1"),window.localStorage.removeItem(ee),!0}catch{return!1}}const R=()=>window.localStorage;function $(i,e=R){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function _e(i,e,t=R){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Ke(i,e=R){try{e().removeItem(i)}catch{}}function O(i,e,t=R){const n=$(i,t);return m(n)?n[e]:void 0}function x(i,e,t,n=R){const r=$(i,n),s=m(r)?{...r}:{};return s[e]=t,_e(i,s,n)}function Y(i,e,t=R){const n=$(i,t);if(!m(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Ke(i,t):_e(i,r,t)}const q="pageViews",D="utmParams",Ie=25,Ce=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function ye(i){return i.slice(-Ie)}function te(){const i=O(h,q);return Array.isArray(i)?i:[]}function De(i){const e=ye(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(x(h,q,n))return n.length}return 0}function ie(){Y(h,q)}function Me(i){const e=ye(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=s&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Fe(i){if(O(h,D)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ce){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!x(h,D,t)){const r=H()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function xe(){const i=O(h,D);return m(i)?i:null}function ne(){Y(h,D)}function Ye(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return z(e)}const J=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"],optionalAttributeKeys:["firstname","lastname"]},{accountId:"2550745407543340151",pathname:"/checkout",targetPageIdentifier:"RoktExperience",attributeKeys:["email","firstname","lastname","customertype","loyaltytier","paymenttype","ccbin"],optionalAttributeKeys:["loyaltytier","paymenttype","ccbin"]},{accountId:"3236704179315511296",pathname:"/check-out/pay",targetPageIdentifier:"confirmation_page",attributeKeys:["email","firstname","lastname","loyaltytier"],optionalAttributeKeys:["firstname","lastname","loyaltytier"]},{accountId:"2192288523645376337",pathname:"/checkout/*/review",targetPageIdentifier:"ppx-ad-view-prod",attributeKeys:["email","firstname","lastname"],optionalAttributeKeys:["email"]}],Ge=6e4;function je(i){return m(i)&&typeof i.expiresAt=="number"&&m(i.attributes)}function He(i,e){return`activePreselect:${i}:${e}`}function Ve(i){const e=O(h,i);return je(e)?e:null}function We(i,e){x(h,i,{expiresAt:Date.now()+Ge,attributes:e})}const ze=5*6e4;function M(){return window.sessionStorage}function $e(i){return m(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&m(i.attributes)&&g(i.mpid)}function B(i){return`pendingPreselect:${i}`}function qe(i){const e=B(i),t=O(h,e,M);return $e(t)?t.expiresAt<=Date.now()?(Y(h,e,M),null):t:null}function Je(i,e,t,n,r){return x(h,B(i),{expiresAt:Date.now()+ze,pathname:e,identifier:t,attributes:n,mpid:r},M)}function L(i){Y(h,B(i),M)}function A(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function Be(i,e){if(!i.includes("*"))return i===e;const t=i.split("/"),n=e.split("/");return t.length!==n.length?!1:t.every((r,s)=>r==="*"?n[s]!=="":r===n[s])}function Se(i,e){if(i)return J.find(t=>t.accountId===i&&Be(t.pathname,e))}function Qe(i,e){if(!(!i||!g(e)))return J.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function Xe(i,e){return i?J.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function Ze(){return{pending:[]}}function j(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function V(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function Ae(i){const e=i?.getMPID?.();return e==null?null:String(e)}function Pe(i,e){const t=new Set((i.optionalAttributeKeys??[]).map(n=>n.toLowerCase()));return i.attributeKeys.filter(n=>!t.has(n.toLowerCase())&&S(e[n]))}function re(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r={};for(const s of t.attributeKeys){const o=i.getEventAttributeValue(e,s),c=S(o)?i.userAttributes[s]??n[s]:o;S(c)||(r[s]=c)}return{collected:r,missingKeys:Pe(t,r)}}function et(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function be(i,e,t,n,r,s){const o=He(e,t),c=Ve(o),u=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&u){i.logPlacementDiagnostic(A("skipped","active_preselection"));return}We(o,r),i.logPlacementDiagnostic(A("fired",s)),et(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function tt(i,e){if(!e.accountId||!e.isKitReady())return;const t=qe(e.accountId);if(!t)return;if(i.pending.some(o=>o.pathname===t.pathname)){L(e.accountId);return}if(!e.isPreselectionEnabled()){L(e.accountId);return}if(!V(e.filteredUser)||(L(e.accountId),Ae(e.filteredUser)!==t.mpid))return;const n=Se(e.accountId,t.pathname);if(!n||n.targetPageIdentifier!==t.identifier)return;const r=y(t.attributes),s=Pe(n,r);if(s.length>0){for(const o of s)e.logPlacementDiagnostic(A("missed",`missing_persisted_attribute:${o}`));return}be(e,e.accountId,t.identifier,t.identifier,r,"recovered")}function Re(i,e,t,n=window.location.pathname){const r=Se(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],u=Ae(e.filteredUser);if(e.accountId&&u&&V(e.filteredUser)){const{collected:l,missingKeys:f}=re(e,t,r);if(f.length===0){const k=y(l);Je(e.accountId,n,r.targetPageIdentifier,k,u)||c.push(A("queued","persist_failed"))}}j(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!V(e.filteredUser)){e.logPlacementDiagnostic(A("missed","no_valid_identity")),j(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=re(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(A("missed",`missing_attribute:${c}`));j(i,{event:t,pathname:n});return}be(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function it(i,e,t=window.location.pathname){if(tt(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),Re(i,e,r,s))})}function nt(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function rt(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function st(i){i.lifecycle="attached"}function ot(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function ct(i){i.lifecycle="terminated"}function at(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function lt(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const d="Rokt",K=181,ut="selectPlacements",dt="apps.roktecommerce.com",ht=.1,gt="ThankYouPageJourney",ft="rokt-launcher",pt="rokt-thank-you-element",mt="userIdentifiedInWorkspace",Et=3,_t=2,It="page_events",yt="page_view_attributes",St="mparticle_session_id",At="mparticle_device_id",se=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},P={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Pt="apps.rokt-api.com",bt="/v1/log",Rt="/v1/errors",kt=10;function a(){return window.mParticle}function oe(i,e){const n=[G(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function ce(i){return[G(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function G(i){const e=i!==void 0?i:Pt;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function ke(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return G(r)+t}function ae(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function C(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function le(i){const e=i?C(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(gt)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function vt(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ue(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function de(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function he(i,e,t){return a().generateHash([i,e,t].join(""))}function wt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.7.0";return i&&(n+="_"+i),n}function W(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function ge(i,e){const t=Ee(window.location.origin);if(b._allowedOriginHashes.indexOf(t)===-1||Math.random()>=ht)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?G(i):"https://apps.rokt.com";W(c+"/v1/wsdk-init/index.html?"+o),W("https://"+dt+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Tt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Lt(){return typeof window<"u"?window.location?.href:void 0}function Ot(){return typeof window<"u"?window.navigator?.userAgent:void 0}class ve{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>kt}}class F{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new ve,this._isEnabled=Tt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:Lt(),deviceInfo:Ot(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const f=new Error("HTTP "+l.status+" from log endpoint");throw f.statusCode=l.status,f}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class fe{constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=ke(e?.errorUrl,e?.integrationDomain,Rt)}report(e){if(!e)return;const t=e.severity||P.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class pe{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._placementDiagnosticTransport=new F(e,n,r,s),this._loggingUrl=ke(e?.loggingUrl,e?.integrationDomain,bt),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,P.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?P.ERROR:P.WARNING})}})}}function Nt(i){const e=z(window.location.href),t=i.EventAttributes?.title||document.title,n=Ye(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const _=class _{constructor(){this.name=d,this.id=K,this.moduleId=K,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=nt(),this.accountId=null,this._preselectState=Ze()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(S(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=z(window.location.href);const n=te(),r=Nt(e);n.push(r);const s=Math.min(n.length,Ie),o=De(n);if(o===0){const c=H()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=H()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=Qe(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){it(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&U(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[_.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!m(e))return;const t=a().EventType.Other;a().logEvent(ut,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&U(t.setIntegrationAttribute)&&t.setIntegrationAttribute(K,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(U(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){rt(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await vt([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(ct(this._launcherAttachState),!c){const u=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${u}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return lt(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,st(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,ge(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=y(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=C(o.placementEventMapping);this.placementEventMappingLookup=ue(u);const l=C(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=de(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const f=a().Rokt?.domain,{roktExtensionsQueryParams:k,legacyRoktExtensions:v,loadThankYouElement:N}=le(o.roktExtensions),E={...a().Rokt?.launcherOptions||{}};this.integrationName=wt(E.integrationName),E.integrationName=this.integrationName,this.domain=f;const w={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:f,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new fe(w,this.integrationName,window.__rokt_li_guid__,o.accountId),T=new pe(w,I,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=I,this.loggingService=T,this.isTargetingDisabled())try{ie(),ne()}catch(p){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:P.INFO,stackTrace:p instanceof Error?p.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(T),n?(this.testHelpers={generateLauncherScript:oe,generateThankYouElementScript:ce,extractRoktExtensionConfig:le,hashEventMessage:he,parseSettingsString:C,generateMappedEventLookup:ue,generateMappedEventAttributeLookup:de,sendAdBlockMeasurementSignals:ge,createAutoRemovedIframe:W,djb2:Ee,setAllowedOriginHashes:p=>{_._allowedOriginHashes=p},ReportingTransport:F,ErrorReportingService:fe,LoggingService:pe,RateLimiter:ve,ErrorCodes:Q,WSDKErrorSeverity:P,resetLauncherAttachState:()=>at(this._launcherAttachState)},this.attachLauncher(c,E),"Successfully initialized: "+d):(N&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),ae(pt,ce(f),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:p=>{console.error("Error loading Rokt Thank You Element script:",p)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,E,v):(ae(ft,oe(f,k),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,E,v):console.error("Rokt object is not available after script load.")},onError:p=>{console.error("Error loading Rokt launcher script:",p)}}),this.captureTiming(_.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===Et&&(Fe(this.loggingService),this.capturePageView(e),Re(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===_t&&(ie(),ne(),this.accountId&&L(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(U(a().Rokt?.setLocalSessionAttribute)&&(S(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!S(this.placementEventMappingLookup))){const t=he(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return me(e)||(this.userAttributes[e]=t),Xe(this.accountId,e)&&this.flushPendingPreselectDispatches(),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=y(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];g(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.accountId&&L(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,se))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,se))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...y(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=y(l);const f=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},k=this.returnUserIdentities(c),v=this.returnLocalSessionAttributes(),N=Me(te()),E=xe(),w=this.readMpSessionId(),I=this.readMpDeviceId(),T={...k,...l,...f,...v,...N.length?{[It]:JSON.stringify(N)}:{},...E?{[yt]:E}:{},...this.userIdentifiedInWorkspace?{[mt]:!0}:{},...w?{[St]:w}:{},...I?{[At]:I}:{},mpid:u},p=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),we={...e,attributes:T,...p!==void 0?{cacheMatchKeys:p}:{}},X=this.launcher.selectPlacements(we),Z=e.preselect===!0,Te=()=>{Z||this.logSelectPlacementsEvent(T)};return Promise.resolve(X).then(Le=>{if(!Z)return Le?.context?.sessionId?.then(Oe=>this.setRoktSessionId(Oe))}).catch(()=>{}).finally(Te),X}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(ot(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};_._allowedOriginHashes=[-553112570,549508659],_.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},_.EMAIL_SHA256_KEY="emailsha256";let b=_;function Ut(){return K}function Kt(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!m(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}m(i.kits)?i.kits[d]={constructor:b}:(i.kits={},i.kits[d]={constructor:b}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:b,getId:Ut});exports.register=Kt;
2
2
  //# sourceMappingURL=Rokt-Kit.common.js.map
@@ -44,7 +44,7 @@ function g(i) {
44
44
  function U(i) {
45
45
  return typeof i == "function";
46
46
  }
47
- function A(i) {
47
+ function S(i) {
48
48
  return i == null ? !0 : typeof i == "string" ? i.length === 0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
49
49
  }
50
50
  function z(i) {
@@ -85,7 +85,7 @@ function _e(i, e, t = R) {
85
85
  return !1;
86
86
  }
87
87
  }
88
- function Ce(i, e = R) {
88
+ function Ke(i, e = R) {
89
89
  try {
90
90
  e().removeItem(i);
91
91
  } catch {
@@ -104,9 +104,9 @@ function Y(i, e, t = R) {
104
104
  if (!m(n) || !(e in n))
105
105
  return;
106
106
  const r = { ...n };
107
- delete r[e], Object.keys(r).length === 0 ? Ce(i, t) : _e(i, r, t);
107
+ delete r[e], Object.keys(r).length === 0 ? Ke(i, t) : _e(i, r, t);
108
108
  }
109
- const q = "pageViews", D = "utmParams", Ie = 25, Ke = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
109
+ const q = "pageViews", D = "utmParams", Ie = 25, Ce = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
110
110
  function ye(i) {
111
111
  return i.slice(-Ie);
112
112
  }
@@ -145,7 +145,7 @@ function Fe(i) {
145
145
  if (O(h, D) !== void 0)
146
146
  return;
147
147
  const e = new URLSearchParams(window.location.search), t = {};
148
- for (const r of Ke) {
148
+ for (const r of Ce) {
149
149
  const s = e.get(r);
150
150
  s && (t[r] = s);
151
151
  }
@@ -224,6 +224,19 @@ const J = [
224
224
  "lastname",
225
225
  "loyaltytier"
226
226
  ]
227
+ },
228
+ {
229
+ accountId: "2192288523645376337",
230
+ pathname: "/checkout/*/review",
231
+ targetPageIdentifier: "ppx-ad-view-prod",
232
+ attributeKeys: [
233
+ "email",
234
+ "firstname",
235
+ "lastname"
236
+ ],
237
+ optionalAttributeKeys: [
238
+ "email"
239
+ ]
227
240
  }
228
241
  ], Ge = 6e4;
229
242
  function je(i) {
@@ -273,7 +286,7 @@ function Je(i, e, t, n, r) {
273
286
  function L(i) {
274
287
  Y(h, B(i), M);
275
288
  }
276
- function S(i, e) {
289
+ function A(i, e) {
277
290
  const t = {
278
291
  fired: "PRESELECT_FIRED",
279
292
  missed: "PRESELECT_MISSED",
@@ -285,18 +298,28 @@ function S(i, e) {
285
298
  code: t[i]
286
299
  };
287
300
  }
288
- function Ae(i, e) {
301
+ function Be(i, e) {
302
+ if (!i.includes("*"))
303
+ return i === e;
304
+ const t = i.split("/"), n = e.split("/");
305
+ return t.length !== n.length ? !1 : t.every(
306
+ (r, s) => r === "*" ? n[s] !== "" : r === n[s]
307
+ );
308
+ }
309
+ function Se(i, e) {
289
310
  if (i)
290
- return J.find((t) => t.accountId === i && t.pathname === e);
311
+ return J.find(
312
+ (t) => t.accountId === i && Be(t.pathname, e)
313
+ );
291
314
  }
292
- function Be(i, e) {
315
+ function Qe(i, e) {
293
316
  if (!(!i || !g(e)))
294
317
  return J.find((t) => t.accountId === i && t.targetPageIdentifier === e);
295
318
  }
296
- function Qe(i, e) {
319
+ function Xe(i, e) {
297
320
  return i ? J.some((t) => t.accountId === i && t.attributeKeys.includes(e)) : !1;
298
321
  }
299
- function Xe() {
322
+ function Ze() {
300
323
  return { pending: [] };
301
324
  }
302
325
  function j(i, e) {
@@ -316,26 +339,26 @@ function V(i) {
316
339
  return g(n) && n.length > 0;
317
340
  }) : !1;
318
341
  }
319
- function Se(i) {
342
+ function Ae(i) {
320
343
  const e = i?.getMPID?.();
321
344
  return e == null ? null : String(e);
322
345
  }
323
346
  function Pe(i, e) {
324
347
  const t = new Set((i.optionalAttributeKeys ?? []).map((n) => n.toLowerCase()));
325
- return i.attributeKeys.filter((n) => !t.has(n.toLowerCase()) && A(e[n]));
348
+ return i.attributeKeys.filter((n) => !t.has(n.toLowerCase()) && S(e[n]));
326
349
  }
327
350
  function re(i, e, t) {
328
351
  const n = i.filteredUser?.getAllUserAttributes?.() || {}, r = {};
329
352
  for (const s of t.attributeKeys) {
330
- const o = i.getEventAttributeValue(e, s), c = A(o) ? i.userAttributes[s] ?? n[s] : o;
331
- A(c) || (r[s] = c);
353
+ const o = i.getEventAttributeValue(e, s), c = S(o) ? i.userAttributes[s] ?? n[s] : o;
354
+ S(c) || (r[s] = c);
332
355
  }
333
356
  return {
334
357
  collected: r,
335
358
  missingKeys: Pe(t, r)
336
359
  };
337
360
  }
338
- function Ze(i, e) {
361
+ function et(i, e) {
339
362
  Promise.resolve(i.selectPlacements(e)).catch((t) => {
340
363
  const n = t instanceof Error ? t.message : String(t);
341
364
  i.log({
@@ -347,12 +370,12 @@ function Ze(i, e) {
347
370
  function be(i, e, t, n, r, s) {
348
371
  const o = He(e, t), c = Ve(o), u = !!c && JSON.stringify(c.attributes) === JSON.stringify(r);
349
372
  if (c && c.expiresAt > Date.now() && u) {
350
- i.logPlacementDiagnostic(S("skipped", "active_preselection"));
373
+ i.logPlacementDiagnostic(A("skipped", "active_preselection"));
351
374
  return;
352
375
  }
353
- We(o, r), i.logPlacementDiagnostic(S("fired", s)), Ze(i, { attributes: r, preselect: !0, identifier: n, omitUrl: !0 });
376
+ We(o, r), i.logPlacementDiagnostic(A("fired", s)), et(i, { attributes: r, preselect: !0, identifier: n, omitUrl: !0 });
354
377
  }
355
- function et(i, e) {
378
+ function tt(i, e) {
356
379
  if (!e.accountId || !e.isKitReady())
357
380
  return;
358
381
  const t = qe(e.accountId);
@@ -366,25 +389,25 @@ function et(i, e) {
366
389
  L(e.accountId);
367
390
  return;
368
391
  }
369
- if (!V(e.filteredUser) || (L(e.accountId), Se(e.filteredUser) !== t.mpid))
392
+ if (!V(e.filteredUser) || (L(e.accountId), Ae(e.filteredUser) !== t.mpid))
370
393
  return;
371
- const n = Ae(e.accountId, t.pathname);
394
+ const n = Se(e.accountId, t.pathname);
372
395
  if (!n || n.targetPageIdentifier !== t.identifier)
373
396
  return;
374
397
  const r = y(t.attributes), s = Pe(n, r);
375
398
  if (s.length > 0) {
376
399
  for (const o of s)
377
- e.logPlacementDiagnostic(S("missed", `missing_persisted_attribute:${o}`));
400
+ e.logPlacementDiagnostic(A("missed", `missing_persisted_attribute:${o}`));
378
401
  return;
379
402
  }
380
403
  be(e, e.accountId, t.identifier, t.identifier, r, "recovered");
381
404
  }
382
405
  function Re(i, e, t, n = window.location.pathname) {
383
- const r = Ae(e.accountId, n);
406
+ const r = Se(e.accountId, n);
384
407
  if (!r)
385
408
  return;
386
409
  if (!e.isKitReady()) {
387
- const c = [], u = Se(e.filteredUser);
410
+ const c = [], u = Ae(e.filteredUser);
388
411
  if (e.accountId && u && V(e.filteredUser)) {
389
412
  const { collected: l, missingKeys: f } = re(e, t, r);
390
413
  if (f.length === 0) {
@@ -395,7 +418,7 @@ function Re(i, e, t, n = window.location.pathname) {
395
418
  r.targetPageIdentifier,
396
419
  k,
397
420
  u
398
- ) || c.push(S("queued", "persist_failed"));
421
+ ) || c.push(A("queued", "persist_failed"));
399
422
  }
400
423
  }
401
424
  j(i, { event: t, pathname: n, storedDiagnostics: c });
@@ -404,53 +427,53 @@ function Re(i, e, t, n = window.location.pathname) {
404
427
  if (!e.isPreselectionEnabled())
405
428
  return;
406
429
  if (!V(e.filteredUser)) {
407
- e.logPlacementDiagnostic(S("missed", "no_valid_identity")), j(i, { event: t, pathname: n });
430
+ e.logPlacementDiagnostic(A("missed", "no_valid_identity")), j(i, { event: t, pathname: n });
408
431
  return;
409
432
  }
410
433
  const { collected: s, missingKeys: o } = re(e, t, r);
411
434
  if (o.length > 0) {
412
435
  for (const c of o)
413
- e.logPlacementDiagnostic(S("missed", `missing_attribute:${c}`));
436
+ e.logPlacementDiagnostic(A("missed", `missing_attribute:${c}`));
414
437
  j(i, { event: t, pathname: n });
415
438
  return;
416
439
  }
417
440
  be(e, e.accountId || "", n, r.targetPageIdentifier, s, "fired");
418
441
  }
419
- function tt(i, e, t = window.location.pathname) {
420
- if (et(i, e), i.pending.length === 0)
442
+ function it(i, e, t = window.location.pathname) {
443
+ if (tt(i, e), i.pending.length === 0)
421
444
  return;
422
445
  const n = i.pending;
423
446
  i.pending = [], n.forEach(({ event: r, pathname: s, storedDiagnostics: o }) => {
424
447
  s === t && (e.isKitReady() && e.isPreselectionEnabled() && o?.forEach((c) => e.logPlacementDiagnostic(c)), Re(i, e, r, s));
425
448
  });
426
449
  }
427
- function it() {
450
+ function nt() {
428
451
  return {
429
452
  context: null,
430
453
  lifecycle: "idle",
431
454
  recreateInFlight: null
432
455
  };
433
456
  }
434
- function nt(i, e) {
457
+ function rt(i, e) {
435
458
  i.context = {
436
459
  accountId: e.accountId,
437
460
  launcherOptions: { ...e.launcherOptions },
438
461
  legacyRoktExtensions: [...e.legacyRoktExtensions]
439
462
  };
440
463
  }
441
- function rt(i) {
464
+ function st(i) {
442
465
  i.lifecycle = "attached";
443
466
  }
444
- function st(i) {
467
+ function ot(i) {
445
468
  i.lifecycle !== "idle" && (i.lifecycle = "terminated");
446
469
  }
447
- function ot(i) {
470
+ function ct(i) {
448
471
  i.lifecycle = "terminated";
449
472
  }
450
- function ct(i) {
473
+ function at(i) {
451
474
  i.context = null, i.lifecycle = "idle", i.recreateInFlight = null;
452
475
  }
453
- function at(i, e, t) {
476
+ function lt(i, e, t) {
454
477
  if (i.recreateInFlight)
455
478
  return i.recreateInFlight;
456
479
  if (i.lifecycle !== "terminated" || !i.context || !e)
@@ -461,7 +484,7 @@ function at(i, e, t) {
461
484
  i.recreateInFlight = null;
462
485
  }), i.recreateInFlight;
463
486
  }
464
- const d = "Rokt", C = 181, lt = "selectPlacements", ut = "apps.roktecommerce.com", dt = 0.1, ht = "ThankYouPageJourney", gt = "rokt-launcher", ft = "rokt-thank-you-element", pt = "userIdentifiedInWorkspace", mt = 3, Et = 2, _t = "page_events", It = "page_view_attributes", yt = "mparticle_session_id", At = "mparticle_device_id", se = 500, Q = {
487
+ const d = "Rokt", K = 181, ut = "selectPlacements", dt = "apps.roktecommerce.com", ht = 0.1, gt = "ThankYouPageJourney", ft = "rokt-launcher", pt = "rokt-thank-you-element", mt = "userIdentifiedInWorkspace", Et = 3, _t = 2, It = "page_events", yt = "page_view_attributes", St = "mparticle_session_id", At = "mparticle_device_id", se = 500, Q = {
465
488
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
466
489
  UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
467
490
  IDENTITY_REQUEST: "IDENTITY_REQUEST",
@@ -470,7 +493,7 @@ const d = "Rokt", C = 181, lt = "selectPlacements", ut = "apps.roktecommerce.com
470
493
  ERROR: "ERROR",
471
494
  INFO: "INFO",
472
495
  WARNING: "WARNING"
473
- }, St = "apps.rokt-api.com", Pt = "/v1/log", bt = "/v1/errors", Rt = 10;
496
+ }, Pt = "apps.rokt-api.com", bt = "/v1/log", Rt = "/v1/errors", kt = 10;
474
497
  function a() {
475
498
  return window.mParticle;
476
499
  }
@@ -482,7 +505,7 @@ function ce(i) {
482
505
  return [G(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
483
506
  }
484
507
  function G(i) {
485
- const e = i !== void 0 ? i : St;
508
+ const e = i !== void 0 ? i : Pt;
486
509
  return e.includes("://") ? e.replace(/\/+$/, "") : ["https://", e].join("");
487
510
  }
488
511
  function ke(i, e, t) {
@@ -496,7 +519,7 @@ function ae(i, e, t) {
496
519
  const n = document.head || document.body, r = document.createElement("script");
497
520
  r.id = i, r.type = "text/javascript", r.src = e, r.async = !0, r.crossOrigin = "anonymous", r.fetchPriority = "high", t?.onLoad && (r.onload = t.onLoad), t?.onError && (r.onerror = t.onError), n.appendChild(r);
498
521
  }
499
- function K(i) {
522
+ function C(i) {
500
523
  if (!i)
501
524
  return [];
502
525
  try {
@@ -507,11 +530,11 @@ function K(i) {
507
530
  return [];
508
531
  }
509
532
  function le(i) {
510
- const e = i ? K(i) : [], t = [], n = [];
533
+ const e = i ? C(i) : [], t = [], n = [];
511
534
  let r = !1;
512
535
  for (let s = 0; s < e.length; s++) {
513
536
  const o = e[s].value;
514
- o === "thank-you-journey" ? (r = !0, n.push(ht)) : t.push(o);
537
+ o === "thank-you-journey" ? (r = !0, n.push(gt)) : t.push(o);
515
538
  }
516
539
  return {
517
540
  roktExtensionsQueryParams: t,
@@ -519,7 +542,7 @@ function le(i) {
519
542
  loadThankYouElement: r
520
543
  };
521
544
  }
522
- async function kt(i, e) {
545
+ async function vt(i, e) {
523
546
  const t = [];
524
547
  if (e)
525
548
  for (const n of i)
@@ -555,8 +578,8 @@ function de(i) {
555
578
  function he(i, e, t) {
556
579
  return a().generateHash([i, e, t].join(""));
557
580
  }
558
- function vt(i) {
559
- let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "3.6.2";
581
+ function wt(i) {
582
+ let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "3.7.0";
560
583
  return i && (n += "_" + i), n;
561
584
  }
562
585
  function W(i) {
@@ -569,23 +592,23 @@ function W(i) {
569
592
  }
570
593
  function ge(i, e) {
571
594
  const t = Ee(window.location.origin);
572
- if (b._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= dt)
595
+ if (b._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= ht)
573
596
  return;
574
597
  const r = window.__rokt_li_guid__;
575
598
  if (!r || i && i.includes("://") && !/^https:\/\//i.test(i))
576
599
  return;
577
600
  const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s), c = i ? G(i) : "https://apps.rokt.com";
578
601
  W(c + "/v1/wsdk-init/index.html?" + o), W(
579
- "https://" + ut + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
602
+ "https://" + dt + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
580
603
  );
581
604
  }
582
- function wt() {
605
+ function Tt() {
583
606
  return typeof window < "u" && !!window.location?.search?.toLowerCase().includes("mp_enable_logging=true");
584
607
  }
585
- function Tt() {
608
+ function Lt() {
586
609
  return typeof window < "u" ? window.location?.href : void 0;
587
610
  }
588
- function Lt() {
611
+ function Ot() {
589
612
  return typeof window < "u" ? window.navigator?.userAgent : void 0;
590
613
  }
591
614
  class ve {
@@ -594,14 +617,14 @@ class ve {
594
617
  }
595
618
  incrementAndCheck(e) {
596
619
  const n = (this._logCount[e] || 0) + 1;
597
- return this._logCount[e] = n, n > Rt;
620
+ return this._logCount[e] = n, n > kt;
598
621
  }
599
622
  }
600
623
  class F {
601
624
  constructor(e, t, n, r, s) {
602
625
  this._reporter = "mp-wsdk";
603
626
  const o = e.isLoggingEnabled;
604
- this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new ve(), this._isEnabled = wt() || o;
627
+ this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new ve(), this._isEnabled = Tt() || o;
605
628
  }
606
629
  send(e, t, n, r, s, o) {
607
630
  if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
@@ -613,8 +636,8 @@ class F {
613
636
  },
614
637
  severity: t,
615
638
  code: r || Q.UNKNOWN_ERROR,
616
- url: Tt(),
617
- deviceInfo: Lt(),
639
+ url: Lt(),
640
+ deviceInfo: Ot(),
618
641
  stackTrace: s,
619
642
  reporter: this._reporter,
620
643
  integration: this._integrationName
@@ -643,7 +666,7 @@ class F {
643
666
  }
644
667
  class fe {
645
668
  constructor(e, t, n, r, s) {
646
- this._transport = new F(e, t, n, r, s), this._errorUrl = ke(e?.errorUrl, e?.integrationDomain, bt);
669
+ this._transport = new F(e, t, n, r, s), this._errorUrl = ke(e?.errorUrl, e?.integrationDomain, Rt);
647
670
  }
648
671
  report(e) {
649
672
  if (!e) return;
@@ -658,7 +681,7 @@ class pe {
658
681
  n,
659
682
  r,
660
683
  s
661
- ), this._loggingUrl = ke(e?.loggingUrl, e?.integrationDomain, Pt), this._errorReportingService = t;
684
+ ), this._loggingUrl = ke(e?.loggingUrl, e?.integrationDomain, bt), this._errorReportingService = t;
662
685
  }
663
686
  log(e) {
664
687
  e && this._send(this._transport, e);
@@ -686,7 +709,7 @@ class pe {
686
709
  );
687
710
  }
688
711
  }
689
- function Ot(i) {
712
+ function Nt(i) {
690
713
  const e = z(window.location.href), t = i.EventAttributes?.title || document.title, n = Ye(), r = i.ActiveTimeOnSite;
691
714
  return {
692
715
  pageUrl: e,
@@ -699,7 +722,7 @@ function Ot(i) {
699
722
  }
700
723
  const _ = class _ {
701
724
  constructor() {
702
- this.name = d, this.id = C, this.moduleId = C, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null, this._launcherAttachState = it(), this.accountId = null, this._preselectState = Xe();
725
+ this.name = d, this.id = K, this.moduleId = K, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null, this._launcherAttachState = nt(), this.accountId = null, this._preselectState = Ze();
703
726
  }
704
727
  // ---- Private helpers ----
705
728
  getEventAttributeValue(e, t) {
@@ -730,7 +753,7 @@ const _ = class _ {
730
753
  const t = Object.keys(this.placementEventAttributeMappingLookup);
731
754
  for (let n = 0; n < t.length; n++) {
732
755
  const r = t[n], s = this.placementEventAttributeMappingLookup[r];
733
- if (A(s))
756
+ if (S(s))
734
757
  continue;
735
758
  let o = !0;
736
759
  for (let c = 0; c < s.length; c++)
@@ -745,7 +768,7 @@ const _ = class _ {
745
768
  let t;
746
769
  try {
747
770
  t = z(window.location.href);
748
- const n = te(), r = Ot(e);
771
+ const n = te(), r = Nt(e);
749
772
  n.push(r);
750
773
  const s = Math.min(n.length, Ie), o = De(n);
751
774
  if (o === 0) {
@@ -772,7 +795,7 @@ const _ = class _ {
772
795
  buildCacheMatchKeys(e) {
773
796
  if (!this.isPreselectionEnabled())
774
797
  return;
775
- const t = Be(this.accountId, e);
798
+ const t = Qe(this.accountId, e);
776
799
  if (t)
777
800
  return t.attributeKeys;
778
801
  }
@@ -790,7 +813,7 @@ const _ = class _ {
790
813
  };
791
814
  }
792
815
  flushPendingPreselectDispatches() {
793
- tt(this._preselectState, this.buildPreselectHost());
816
+ it(this._preselectState, this.buildPreselectHost());
794
817
  }
795
818
  isLauncherReadyToAttach() {
796
819
  return !!window.Rokt && U(window.Rokt.createLauncher);
@@ -815,13 +838,13 @@ const _ = class _ {
815
838
  if (!window.mParticle || typeof a().logEvent != "function" || !m(e))
816
839
  return;
817
840
  const t = a().EventType.Other;
818
- a().logEvent(lt, t, e);
841
+ a().logEvent(ut, t, e);
819
842
  }
820
843
  setRoktSessionId(e) {
821
844
  if (!(!e || typeof e != "string"))
822
845
  try {
823
846
  const t = a().getInstance();
824
- t && U(t.setIntegrationAttribute) && t.setIntegrationAttribute(C, {
847
+ t && U(t.setIntegrationAttribute) && t.setIntegrationAttribute(K, {
825
848
  roktSessionId: e
826
849
  });
827
850
  } catch {
@@ -836,7 +859,7 @@ const _ = class _ {
836
859
  return a()?.getDeviceId?.() || void 0;
837
860
  }
838
861
  attachLauncher(e, t, n = []) {
839
- nt(this._launcherAttachState, {
862
+ rt(this._launcherAttachState, {
840
863
  accountId: e,
841
864
  launcherOptions: t || {},
842
865
  legacyRoktExtensions: n
@@ -847,10 +870,10 @@ const _ = class _ {
847
870
  };
848
871
  let s;
849
872
  return this.isPartnerInLocalLauncherTestGroup() ? s = Promise.resolve(window.Rokt.createLocalLauncher(r)) : s = window.Rokt.createLauncher(r), s.then(async (o) => {
850
- await kt([...n], o), this.initRoktLauncher(o);
873
+ await vt([...n], o), this.initRoktLauncher(o);
851
874
  }).catch((o) => {
852
875
  const c = this._launcherAttachState.lifecycle === "attached";
853
- if (ot(this._launcherAttachState), !c) {
876
+ if (ct(this._launcherAttachState), !c) {
854
877
  const u = o instanceof Error ? o.message : String(o);
855
878
  this.loggingService?.log({
856
879
  message: `Rokt Kit: Failed to attach Rokt launcher: ${u}`,
@@ -861,14 +884,14 @@ const _ = class _ {
861
884
  });
862
885
  }
863
886
  recreateLauncherIfTerminated() {
864
- return at(
887
+ return lt(
865
888
  this._launcherAttachState,
866
889
  this.isLauncherReadyToAttach(),
867
890
  (e) => this.attachLauncher(e.accountId, e.launcherOptions, e.legacyRoktExtensions)
868
891
  );
869
892
  }
870
893
  initRoktLauncher(e) {
871
- window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e, rt(this._launcherAttachState);
894
+ window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e, st(this._launcherAttachState);
872
895
  const t = a().Rokt?.filters;
873
896
  t ? (this.filters = t, t.filteredUser ? this._workspaceSearchInFlightPromise = this.search(t.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, ge(this.domain, this.integrationName), a().Rokt.attachKit(this), this.flushPendingPreselectDispatches();
874
897
  }
@@ -908,9 +931,9 @@ const _ = class _ {
908
931
  init(e, t, n, r, s) {
909
932
  const o = e, c = o.accountId;
910
933
  this.accountId = c || null, this.userAttributes = y(s), this._onboardingExpProvider = o.onboardingExpProvider;
911
- const u = K(o.placementEventMapping);
934
+ const u = C(o.placementEventMapping);
912
935
  this.placementEventMappingLookup = ue(u);
913
- const l = K(
936
+ const l = C(
914
937
  o.placementEventAttributeMapping
915
938
  );
916
939
  this.placementEventAttributeMappingLookup = de(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = g(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
@@ -919,7 +942,7 @@ const _ = class _ {
919
942
  ), E = {
920
943
  ...a().Rokt?.launcherOptions || {}
921
944
  };
922
- this.integrationName = vt(E.integrationName), E.integrationName = this.integrationName, this.domain = f;
945
+ this.integrationName = wt(E.integrationName), E.integrationName = this.integrationName, this.domain = f;
923
946
  const w = {
924
947
  loggingUrl: o.loggingUrl,
925
948
  errorUrl: o.errorUrl,
@@ -953,7 +976,7 @@ const _ = class _ {
953
976
  generateThankYouElementScript: ce,
954
977
  extractRoktExtensionConfig: le,
955
978
  hashEventMessage: he,
956
- parseSettingsString: K,
979
+ parseSettingsString: C,
957
980
  generateMappedEventLookup: ue,
958
981
  generateMappedEventAttributeLookup: de,
959
982
  sendAdBlockMeasurementSignals: ge,
@@ -968,15 +991,15 @@ const _ = class _ {
968
991
  RateLimiter: ve,
969
992
  ErrorCodes: Q,
970
993
  WSDKErrorSeverity: P,
971
- resetLauncherAttachState: () => ct(this._launcherAttachState)
972
- }, this.attachLauncher(c, E), "Successfully initialized: " + d) : (N && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), ae(ft, ce(f), {
994
+ resetLauncherAttachState: () => at(this._launcherAttachState)
995
+ }, this.attachLauncher(c, E), "Successfully initialized: " + d) : (N && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), ae(pt, ce(f), {
973
996
  onLoad: () => {
974
997
  this._isThankYouElementLoaded = !0, this._thankYouElementOnLoadCallback && this._thankYouElementOnLoadCallback();
975
998
  },
976
999
  onError: (p) => {
977
1000
  console.error("Error loading Rokt Thank You Element script:", p);
978
1001
  }
979
- })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, E, v) : (ae(gt, oe(f, k), {
1002
+ })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, E, v) : (ae(ft, oe(f, k), {
980
1003
  onLoad: () => {
981
1004
  this.isLauncherReadyToAttach() ? this.attachLauncher(c, E, v) : console.error("Rokt object is not available after script load.");
982
1005
  },
@@ -986,9 +1009,9 @@ const _ = class _ {
986
1009
  }), this.captureTiming(_.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
987
1010
  }
988
1011
  process(e) {
989
- if (this.isTargetingDisabled() || (e.EventDataType === mt && (Fe(this.loggingService), this.capturePageView(e), Re(this._preselectState, this.buildPreselectHost(), e)), e.EventDataType === Et && (ie(), ne(), this.accountId && L(this.accountId))), !this.isKitReady())
1012
+ if (this.isTargetingDisabled() || (e.EventDataType === Et && (Fe(this.loggingService), this.capturePageView(e), Re(this._preselectState, this.buildPreselectHost(), e)), e.EventDataType === _t && (ie(), ne(), this.accountId && L(this.accountId))), !this.isKitReady())
990
1013
  return "Kit not ready for forwarder: " + d;
991
- if (U(a().Rokt?.setLocalSessionAttribute) && (A(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !A(this.placementEventMappingLookup))) {
1014
+ if (U(a().Rokt?.setLocalSessionAttribute) && (S(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !S(this.placementEventMappingLookup))) {
992
1015
  const t = he(e.EventDataType, e.EventCategory, e.EventName ?? "");
993
1016
  this.placementEventMappingLookup[String(t)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
994
1017
  }
@@ -1002,7 +1025,7 @@ const _ = class _ {
1002
1025
  window.Rokt.setExtensionData(e);
1003
1026
  }
1004
1027
  setUserAttribute(e, t) {
1005
- return me(e) || (this.userAttributes[e] = t), Qe(this.accountId, e) && this.flushPendingPreselectDispatches(), "Successfully set user attribute for forwarder: " + d;
1028
+ return me(e) || (this.userAttributes[e] = t), Xe(this.accountId, e) && this.flushPendingPreselectDispatches(), "Successfully set user attribute for forwarder: " + d;
1006
1029
  }
1007
1030
  removeUserAttribute(e) {
1008
1031
  return delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + d;
@@ -1105,10 +1128,10 @@ const _ = class _ {
1105
1128
  ...l,
1106
1129
  ...f,
1107
1130
  ...v,
1108
- ...N.length ? { [_t]: JSON.stringify(N) } : {},
1109
- ...E ? { [It]: E } : {},
1110
- ...this.userIdentifiedInWorkspace ? { [pt]: !0 } : {},
1111
- ...w ? { [yt]: w } : {},
1131
+ ...N.length ? { [It]: JSON.stringify(N) } : {},
1132
+ ...E ? { [yt]: E } : {},
1133
+ ...this.userIdentifiedInWorkspace ? { [mt]: !0 } : {},
1134
+ ...w ? { [St]: w } : {},
1112
1135
  ...I ? { [At]: I } : {},
1113
1136
  mpid: u
1114
1137
  }, p = this.buildCacheMatchKeys(typeof e.identifier == "string" ? e.identifier : void 0), we = {
@@ -1148,7 +1171,7 @@ const _ = class _ {
1148
1171
  * here would flip the kit to not-ready with no drain path for queued calls.
1149
1172
  */
1150
1173
  terminate() {
1151
- return this.isKitReady() ? (st(this._launcherAttachState), this.launcher.terminate()) : (console.error("Rokt Kit: Not initialized"), Promise.resolve());
1174
+ return this.isKitReady() ? (ot(this._launcherAttachState), this.launcher.terminate()) : (console.error("Rokt Kit: Not initialized"), Promise.resolve());
1152
1175
  }
1153
1176
  /**
1154
1177
  * Registers a callback to be invoked once rokt-thank-you-element.js becomes available.
@@ -1161,10 +1184,10 @@ _._allowedOriginHashes = [-553112570, 549508659], _.PERFORMANCE_MARKS = {
1161
1184
  RoktScriptAppended: "mp:RoktScriptAppended"
1162
1185
  }, _.EMAIL_SHA256_KEY = "emailsha256";
1163
1186
  let b = _;
1164
- function Nt() {
1165
- return C;
1187
+ function Ut() {
1188
+ return K;
1166
1189
  }
1167
- function Ut(i) {
1190
+ function Kt(i) {
1168
1191
  if (!i) {
1169
1192
  window.console.log("You must pass a config object to register the kit " + d);
1170
1193
  return;
@@ -1182,9 +1205,9 @@ function Ut(i) {
1182
1205
  typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
1183
1206
  name: d,
1184
1207
  constructor: b,
1185
- getId: Nt
1208
+ getId: Ut
1186
1209
  });
1187
1210
  export {
1188
- Ut as register
1211
+ Kt as register
1189
1212
  };
1190
1213
  //# sourceMappingURL=Rokt-Kit.esm.js.map
@@ -1,2 +1,2 @@
1
- var RoktKit=(function(j){"use strict";const Te=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Le=new Set(Te);function Z(i){return Le.has(i.toLowerCase())}function I(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];Z(s)||(e[s]=t[s])}return e}function f(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function N(i){return typeof i=="function"}function y(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function H(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const d="mp-rokt-kit",te="__rokt_ls_probe__";function V(){try{return window.localStorage.setItem(te,"1"),window.localStorage.removeItem(te),!0}catch{return!1}}const S=()=>window.localStorage;function W(i,e=S){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function ie(i,e,t=S){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Oe(i,e=S){try{e().removeItem(i)}catch{}}function k(i,e,t=S){const n=W(i,t);return f(n)?n[e]:void 0}function U(i,e,t,n=S){const r=W(i,n),s=f(r)?{...r}:{};return s[e]=t,ie(i,s,n)}function C(i,e,t=S){const n=W(i,t);if(!f(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Oe(i,t):ie(i,r,t)}const z="pageViews",K="utmParams",ne=25,Ne=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function re(i){return i.slice(-ne)}function se(){const i=k(d,z);return Array.isArray(i)?i:[]}function Ue(i){const e=re(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(U(d,z,n))return n.length}return 0}function oe(){C(d,z)}function Ce(i){const e=re(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=s&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Ke(i){if(k(d,K)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ne){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!U(d,K,t)){const r=V()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function De(){const i=k(d,K);return f(i)?i:null}function ce(){C(d,K)}function Me(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return H(e)}const $=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"],optionalAttributeKeys:["firstname","lastname"]},{accountId:"2550745407543340151",pathname:"/checkout",targetPageIdentifier:"RoktExperience",attributeKeys:["email","firstname","lastname","customertype","loyaltytier","paymenttype","ccbin"],optionalAttributeKeys:["loyaltytier","paymenttype","ccbin"]},{accountId:"3236704179315511296",pathname:"/check-out/pay",targetPageIdentifier:"confirmation_page",attributeKeys:["email","firstname","lastname","loyaltytier"],optionalAttributeKeys:["firstname","lastname","loyaltytier"]}],Fe=6e4;function xe(i){return f(i)&&typeof i.expiresAt=="number"&&f(i.attributes)}function Ye(i,e){return`activePreselect:${i}:${e}`}function Ge(i){const e=k(d,i);return xe(e)?e:null}function je(i,e){U(d,i,{expiresAt:Date.now()+Fe,attributes:e})}const He=5*6e4;function D(){return window.sessionStorage}function Ve(i){return f(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&f(i.attributes)&&g(i.mpid)}function q(i){return`pendingPreselect:${i}`}function We(i){const e=q(i),t=k(d,e,D);return Ve(t)?t.expiresAt<=Date.now()?(C(d,e,D),null):t:null}function ze(i,e,t,n,r){return U(d,q(i),{expiresAt:Date.now()+He,pathname:e,identifier:t,attributes:n,mpid:r},D)}function v(i){C(d,q(i),D)}function A(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function ae(i,e){if(i)return $.find(t=>t.accountId===i&&t.pathname===e)}function $e(i,e){if(!(!i||!g(e)))return $.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function qe(i,e){return i?$.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function Je(){return{pending:[]}}function J(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function B(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function le(i){const e=i?.getMPID?.();return e==null?null:String(e)}function ue(i,e){const t=new Set((i.optionalAttributeKeys??[]).map(n=>n.toLowerCase()));return i.attributeKeys.filter(n=>!t.has(n.toLowerCase())&&y(e[n]))}function de(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r={};for(const s of t.attributeKeys){const o=i.getEventAttributeValue(e,s),c=y(o)?i.userAttributes[s]??n[s]:o;y(c)||(r[s]=c)}return{collected:r,missingKeys:ue(t,r)}}function Be(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function he(i,e,t,n,r,s){const o=Ye(e,t),c=Ge(o),u=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&u){i.logPlacementDiagnostic(A("skipped","active_preselection"));return}je(o,r),i.logPlacementDiagnostic(A("fired",s)),Be(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function Qe(i,e){if(!e.accountId||!e.isKitReady())return;const t=We(e.accountId);if(!t)return;if(i.pending.some(o=>o.pathname===t.pathname)){v(e.accountId);return}if(!e.isPreselectionEnabled()){v(e.accountId);return}if(!B(e.filteredUser)||(v(e.accountId),le(e.filteredUser)!==t.mpid))return;const n=ae(e.accountId,t.pathname);if(!n||n.targetPageIdentifier!==t.identifier)return;const r=I(t.attributes),s=ue(n,r);if(s.length>0){for(const o of s)e.logPlacementDiagnostic(A("missed",`missing_persisted_attribute:${o}`));return}he(e,e.accountId,t.identifier,t.identifier,r,"recovered")}function ge(i,e,t,n=window.location.pathname){const r=ae(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],u=le(e.filteredUser);if(e.accountId&&u&&B(e.filteredUser)){const{collected:l,missingKeys:p}=de(e,t,r);if(p.length===0){const w=I(l);ze(e.accountId,n,r.targetPageIdentifier,w,u)||c.push(A("queued","persist_failed"))}}J(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!B(e.filteredUser)){e.logPlacementDiagnostic(A("missed","no_valid_identity")),J(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=de(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(A("missed",`missing_attribute:${c}`));J(i,{event:t,pathname:n});return}he(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function Xe(i,e,t=window.location.pathname){if(Qe(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),ge(i,e,r,s))})}function Ze(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function et(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function tt(i){i.lifecycle="attached"}function it(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function nt(i){i.lifecycle="terminated"}function rt(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function st(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const h="Rokt",M=181,ot="selectPlacements",ct="apps.roktecommerce.com",at=.1,lt="ThankYouPageJourney",ut="rokt-launcher",dt="rokt-thank-you-element",ht="userIdentifiedInWorkspace",gt=3,ft=2,pt="page_events",mt="page_view_attributes",Et="mparticle_session_id",_t="mparticle_device_id",fe=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},P={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},It="apps.rokt-api.com",yt="/v1/log",St="/v1/errors",At=10;function a(){return window.mParticle}function pe(i,e){const n=[F(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function me(i){return[F(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function F(i){const e=i!==void 0?i:It;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function Ee(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return F(r)+t}function _e(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function x(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function Ie(i){const e=i?x(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(lt)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Pt(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ye(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function Se(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function Ae(i,e,t){return a().generateHash([i,e,t].join(""))}function bt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.6.2";return i&&(n+="_"+i),n}function X(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function Pe(i,e){const t=ee(window.location.origin);if(b._allowedOriginHashes.indexOf(t)===-1||Math.random()>=at)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?F(i):"https://apps.rokt.com";X(c+"/v1/wsdk-init/index.html?"+o),X("https://"+ct+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Rt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function kt(){return typeof window<"u"?window.location?.href:void 0}function vt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class be{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>At}}class Y{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new be,this._isEnabled=Rt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:kt(),deviceInfo:vt(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const p=new Error("HTTP "+l.status+" from log endpoint");throw p.statusCode=l.status,p}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class Re{constructor(e,t,n,r,s){this._transport=new Y(e,t,n,r,s),this._errorUrl=Ee(e?.errorUrl,e?.integrationDomain,St)}report(e){if(!e)return;const t=e.severity||P.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class ke{constructor(e,t,n,r,s,o){this._transport=new Y(e,n,r,s,o),this._placementDiagnosticTransport=new Y(e,n,r,s),this._loggingUrl=Ee(e?.loggingUrl,e?.integrationDomain,yt),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,P.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?P.ERROR:P.WARNING})}})}}function wt(i){const e=H(window.location.href),t=i.EventAttributes?.title||document.title,n=Me(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const E=class E{constructor(){this.name=h,this.id=M,this.moduleId=M,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=Ze(),this.accountId=null,this._preselectState=Je()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(y(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=H(window.location.href);const n=se(),r=wt(e);n.push(r);const s=Math.min(n.length,ne),o=Ue(n);if(o===0){const c=V()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=V()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=$e(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){Xe(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&N(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[E.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!f(e))return;const t=a().EventType.Other;a().logEvent(ot,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&N(t.setIntegrationAttribute)&&t.setIntegrationAttribute(M,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(N(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){et(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await Pt([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(nt(this._launcherAttachState),!c){const u=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${u}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return st(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,tt(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,Pe(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=I(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=x(o.placementEventMapping);this.placementEventMappingLookup=ye(u);const l=x(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=Se(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:w,legacyRoktExtensions:T,loadThankYouElement:G}=Ie(o.roktExtensions),_={...a().Rokt?.launcherOptions||{}};this.integrationName=bt(_.integrationName),_.integrationName=this.integrationName,this.domain=p;const L={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},R=new Re(L,this.integrationName,window.__rokt_li_guid__,o.accountId),O=new ke(L,R,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=R,this.loggingService=O,this.isTargetingDisabled())try{oe(),ce()}catch(m){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:P.INFO,stackTrace:m instanceof Error?m.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(R),a()._registerLoggingService&&a()._registerLoggingService(O),n?(this.testHelpers={generateLauncherScript:pe,generateThankYouElementScript:me,extractRoktExtensionConfig:Ie,hashEventMessage:Ae,parseSettingsString:x,generateMappedEventLookup:ye,generateMappedEventAttributeLookup:Se,sendAdBlockMeasurementSignals:Pe,createAutoRemovedIframe:X,djb2:ee,setAllowedOriginHashes:m=>{E._allowedOriginHashes=m},ReportingTransport:Y,ErrorReportingService:Re,LoggingService:ke,RateLimiter:be,ErrorCodes:Q,WSDKErrorSeverity:P,resetLauncherAttachState:()=>rt(this._launcherAttachState)},this.attachLauncher(c,_),"Successfully initialized: "+h):(G&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),_e(dt,me(p),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:m=>{console.error("Error loading Rokt Thank You Element script:",m)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,_,T):(_e(ut,pe(p,w),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,_,T):console.error("Rokt object is not available after script load.")},onError:m=>{console.error("Error loading Rokt launcher script:",m)}}),this.captureTiming(E.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+h)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===gt&&(Ke(this.loggingService),this.capturePageView(e),ge(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===ft&&(oe(),ce(),this.accountId&&v(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+h;if(N(a().Rokt?.setLocalSessionAttribute)&&(y(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!y(this.placementEventMappingLookup))){const t=Ae(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+h}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return Z(e)||(this.userAttributes[e]=t),qe(this.accountId,e)&&this.flushPendingPreselectDispatches(),"Successfully set user attribute for forwarder: "+h}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+h}handleIdentityComplete(e,t){return this.userAttributes=I(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+h}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];g(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.accountId&&v(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,fe))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,fe))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...I(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=I(l);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},w=this.returnUserIdentities(c),T=this.returnLocalSessionAttributes(),G=Ce(se()),_=De(),L=this.readMpSessionId(),R=this.readMpDeviceId(),O={...w,...l,...p,...T,...G.length?{[pt]:JSON.stringify(G)}:{},..._?{[mt]:_}:{},...this.userIdentifiedInWorkspace?{[ht]:!0}:{},...L?{[Et]:L}:{},...R?{[_t]:R}:{},mpid:u},m=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),Ot={...e,attributes:O,...m!==void 0?{cacheMatchKeys:m}:{}},ve=this.launcher.selectPlacements(Ot),we=e.preselect===!0,Nt=()=>{we||this.logSelectPlacementsEvent(O)};return Promise.resolve(ve).then(Ut=>{if(!we)return Ut?.context?.sessionId?.then(Ct=>this.setRoktSessionId(Ct))}).catch(()=>{}).finally(Nt),ve}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(it(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};E._allowedOriginHashes=[-553112570,549508659],E.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},E.EMAIL_SHA256_KEY="emailsha256";let b=E;function Tt(){return M}function Lt(i){if(!i){window.console.log("You must pass a config object to register the kit "+h);return}if(!f(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}f(i.kits)?i.kits[h]={constructor:b}:(i.kits={},i.kits[h]={constructor:b}),window.console.log("Successfully registered "+h+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:h,constructor:b,getId:Tt}),j.register=Lt,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}),j})({});
1
+ var RoktKit=(function(j){"use strict";const Te=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Le=new Set(Te);function Z(i){return Le.has(i.toLowerCase())}function I(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];Z(s)||(e[s]=t[s])}return e}function f(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function N(i){return typeof i=="function"}function y(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function H(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const d="mp-rokt-kit",te="__rokt_ls_probe__";function V(){try{return window.localStorage.setItem(te,"1"),window.localStorage.removeItem(te),!0}catch{return!1}}const S=()=>window.localStorage;function W(i,e=S){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function ie(i,e,t=S){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Oe(i,e=S){try{e().removeItem(i)}catch{}}function k(i,e,t=S){const n=W(i,t);return f(n)?n[e]:void 0}function U(i,e,t,n=S){const r=W(i,n),s=f(r)?{...r}:{};return s[e]=t,ie(i,s,n)}function K(i,e,t=S){const n=W(i,t);if(!f(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Oe(i,t):ie(i,r,t)}const z="pageViews",C="utmParams",ne=25,Ne=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function re(i){return i.slice(-ne)}function se(){const i=k(d,z);return Array.isArray(i)?i:[]}function Ue(i){const e=re(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(U(d,z,n))return n.length}return 0}function oe(){K(d,z)}function Ke(i){const e=re(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=s&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Ce(i){if(k(d,C)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ne){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!U(d,C,t)){const r=V()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function De(){const i=k(d,C);return f(i)?i:null}function ce(){K(d,C)}function Me(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return H(e)}const $=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"],optionalAttributeKeys:["firstname","lastname"]},{accountId:"2550745407543340151",pathname:"/checkout",targetPageIdentifier:"RoktExperience",attributeKeys:["email","firstname","lastname","customertype","loyaltytier","paymenttype","ccbin"],optionalAttributeKeys:["loyaltytier","paymenttype","ccbin"]},{accountId:"3236704179315511296",pathname:"/check-out/pay",targetPageIdentifier:"confirmation_page",attributeKeys:["email","firstname","lastname","loyaltytier"],optionalAttributeKeys:["firstname","lastname","loyaltytier"]},{accountId:"2192288523645376337",pathname:"/checkout/*/review",targetPageIdentifier:"ppx-ad-view-prod",attributeKeys:["email","firstname","lastname"],optionalAttributeKeys:["email"]}],Fe=6e4;function xe(i){return f(i)&&typeof i.expiresAt=="number"&&f(i.attributes)}function Ye(i,e){return`activePreselect:${i}:${e}`}function Ge(i){const e=k(d,i);return xe(e)?e:null}function je(i,e){U(d,i,{expiresAt:Date.now()+Fe,attributes:e})}const He=5*6e4;function D(){return window.sessionStorage}function Ve(i){return f(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&f(i.attributes)&&g(i.mpid)}function q(i){return`pendingPreselect:${i}`}function We(i){const e=q(i),t=k(d,e,D);return Ve(t)?t.expiresAt<=Date.now()?(K(d,e,D),null):t:null}function ze(i,e,t,n,r){return U(d,q(i),{expiresAt:Date.now()+He,pathname:e,identifier:t,attributes:n,mpid:r},D)}function v(i){K(d,q(i),D)}function A(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function $e(i,e){if(!i.includes("*"))return i===e;const t=i.split("/"),n=e.split("/");return t.length!==n.length?!1:t.every((r,s)=>r==="*"?n[s]!=="":r===n[s])}function ae(i,e){if(i)return $.find(t=>t.accountId===i&&$e(t.pathname,e))}function qe(i,e){if(!(!i||!g(e)))return $.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function Je(i,e){return i?$.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function Be(){return{pending:[]}}function J(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function B(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function le(i){const e=i?.getMPID?.();return e==null?null:String(e)}function ue(i,e){const t=new Set((i.optionalAttributeKeys??[]).map(n=>n.toLowerCase()));return i.attributeKeys.filter(n=>!t.has(n.toLowerCase())&&y(e[n]))}function de(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r={};for(const s of t.attributeKeys){const o=i.getEventAttributeValue(e,s),c=y(o)?i.userAttributes[s]??n[s]:o;y(c)||(r[s]=c)}return{collected:r,missingKeys:ue(t,r)}}function Qe(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function he(i,e,t,n,r,s){const o=Ye(e,t),c=Ge(o),u=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&u){i.logPlacementDiagnostic(A("skipped","active_preselection"));return}je(o,r),i.logPlacementDiagnostic(A("fired",s)),Qe(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function Xe(i,e){if(!e.accountId||!e.isKitReady())return;const t=We(e.accountId);if(!t)return;if(i.pending.some(o=>o.pathname===t.pathname)){v(e.accountId);return}if(!e.isPreselectionEnabled()){v(e.accountId);return}if(!B(e.filteredUser)||(v(e.accountId),le(e.filteredUser)!==t.mpid))return;const n=ae(e.accountId,t.pathname);if(!n||n.targetPageIdentifier!==t.identifier)return;const r=I(t.attributes),s=ue(n,r);if(s.length>0){for(const o of s)e.logPlacementDiagnostic(A("missed",`missing_persisted_attribute:${o}`));return}he(e,e.accountId,t.identifier,t.identifier,r,"recovered")}function ge(i,e,t,n=window.location.pathname){const r=ae(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],u=le(e.filteredUser);if(e.accountId&&u&&B(e.filteredUser)){const{collected:l,missingKeys:p}=de(e,t,r);if(p.length===0){const w=I(l);ze(e.accountId,n,r.targetPageIdentifier,w,u)||c.push(A("queued","persist_failed"))}}J(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!B(e.filteredUser)){e.logPlacementDiagnostic(A("missed","no_valid_identity")),J(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=de(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(A("missed",`missing_attribute:${c}`));J(i,{event:t,pathname:n});return}he(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function Ze(i,e,t=window.location.pathname){if(Xe(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),ge(i,e,r,s))})}function et(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function tt(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function it(i){i.lifecycle="attached"}function nt(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function rt(i){i.lifecycle="terminated"}function st(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function ot(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const h="Rokt",M=181,ct="selectPlacements",at="apps.roktecommerce.com",lt=.1,ut="ThankYouPageJourney",dt="rokt-launcher",ht="rokt-thank-you-element",gt="userIdentifiedInWorkspace",ft=3,pt=2,mt="page_events",Et="page_view_attributes",_t="mparticle_session_id",It="mparticle_device_id",fe=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},P={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},yt="apps.rokt-api.com",St="/v1/log",At="/v1/errors",Pt=10;function a(){return window.mParticle}function pe(i,e){const n=[F(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function me(i){return[F(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function F(i){const e=i!==void 0?i:yt;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function Ee(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return F(r)+t}function _e(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function x(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function Ie(i){const e=i?x(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(ut)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function bt(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ye(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function Se(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function Ae(i,e,t){return a().generateHash([i,e,t].join(""))}function Rt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.7.0";return i&&(n+="_"+i),n}function X(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function Pe(i,e){const t=ee(window.location.origin);if(b._allowedOriginHashes.indexOf(t)===-1||Math.random()>=lt)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?F(i):"https://apps.rokt.com";X(c+"/v1/wsdk-init/index.html?"+o),X("https://"+at+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function kt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function vt(){return typeof window<"u"?window.location?.href:void 0}function wt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class be{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Pt}}class Y{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new be,this._isEnabled=kt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:vt(),deviceInfo:wt(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const p=new Error("HTTP "+l.status+" from log endpoint");throw p.statusCode=l.status,p}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class Re{constructor(e,t,n,r,s){this._transport=new Y(e,t,n,r,s),this._errorUrl=Ee(e?.errorUrl,e?.integrationDomain,At)}report(e){if(!e)return;const t=e.severity||P.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class ke{constructor(e,t,n,r,s,o){this._transport=new Y(e,n,r,s,o),this._placementDiagnosticTransport=new Y(e,n,r,s),this._loggingUrl=Ee(e?.loggingUrl,e?.integrationDomain,St),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,P.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?P.ERROR:P.WARNING})}})}}function Tt(i){const e=H(window.location.href),t=i.EventAttributes?.title||document.title,n=Me(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const E=class E{constructor(){this.name=h,this.id=M,this.moduleId=M,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=et(),this.accountId=null,this._preselectState=Be()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(y(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=H(window.location.href);const n=se(),r=Tt(e);n.push(r);const s=Math.min(n.length,ne),o=Ue(n);if(o===0){const c=V()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=V()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=qe(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){Ze(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&N(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[E.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!f(e))return;const t=a().EventType.Other;a().logEvent(ct,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&N(t.setIntegrationAttribute)&&t.setIntegrationAttribute(M,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(N(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){tt(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await bt([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(rt(this._launcherAttachState),!c){const u=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${u}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return ot(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,it(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,Pe(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=I(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=x(o.placementEventMapping);this.placementEventMappingLookup=ye(u);const l=x(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=Se(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:w,legacyRoktExtensions:T,loadThankYouElement:G}=Ie(o.roktExtensions),_={...a().Rokt?.launcherOptions||{}};this.integrationName=Rt(_.integrationName),_.integrationName=this.integrationName,this.domain=p;const L={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},R=new Re(L,this.integrationName,window.__rokt_li_guid__,o.accountId),O=new ke(L,R,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=R,this.loggingService=O,this.isTargetingDisabled())try{oe(),ce()}catch(m){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:P.INFO,stackTrace:m instanceof Error?m.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(R),a()._registerLoggingService&&a()._registerLoggingService(O),n?(this.testHelpers={generateLauncherScript:pe,generateThankYouElementScript:me,extractRoktExtensionConfig:Ie,hashEventMessage:Ae,parseSettingsString:x,generateMappedEventLookup:ye,generateMappedEventAttributeLookup:Se,sendAdBlockMeasurementSignals:Pe,createAutoRemovedIframe:X,djb2:ee,setAllowedOriginHashes:m=>{E._allowedOriginHashes=m},ReportingTransport:Y,ErrorReportingService:Re,LoggingService:ke,RateLimiter:be,ErrorCodes:Q,WSDKErrorSeverity:P,resetLauncherAttachState:()=>st(this._launcherAttachState)},this.attachLauncher(c,_),"Successfully initialized: "+h):(G&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),_e(ht,me(p),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:m=>{console.error("Error loading Rokt Thank You Element script:",m)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,_,T):(_e(dt,pe(p,w),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,_,T):console.error("Rokt object is not available after script load.")},onError:m=>{console.error("Error loading Rokt launcher script:",m)}}),this.captureTiming(E.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+h)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===ft&&(Ce(this.loggingService),this.capturePageView(e),ge(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===pt&&(oe(),ce(),this.accountId&&v(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+h;if(N(a().Rokt?.setLocalSessionAttribute)&&(y(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!y(this.placementEventMappingLookup))){const t=Ae(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+h}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return Z(e)||(this.userAttributes[e]=t),Je(this.accountId,e)&&this.flushPendingPreselectDispatches(),"Successfully set user attribute for forwarder: "+h}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+h}handleIdentityComplete(e,t){return this.userAttributes=I(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+h}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];g(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.accountId&&v(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,fe))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,fe))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...I(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=I(l);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},w=this.returnUserIdentities(c),T=this.returnLocalSessionAttributes(),G=Ke(se()),_=De(),L=this.readMpSessionId(),R=this.readMpDeviceId(),O={...w,...l,...p,...T,...G.length?{[mt]:JSON.stringify(G)}:{},..._?{[Et]:_}:{},...this.userIdentifiedInWorkspace?{[gt]:!0}:{},...L?{[_t]:L}:{},...R?{[It]:R}:{},mpid:u},m=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),Nt={...e,attributes:O,...m!==void 0?{cacheMatchKeys:m}:{}},ve=this.launcher.selectPlacements(Nt),we=e.preselect===!0,Ut=()=>{we||this.logSelectPlacementsEvent(O)};return Promise.resolve(ve).then(Kt=>{if(!we)return Kt?.context?.sessionId?.then(Ct=>this.setRoktSessionId(Ct))}).catch(()=>{}).finally(Ut),ve}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(nt(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};E._allowedOriginHashes=[-553112570,549508659],E.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},E.EMAIL_SHA256_KEY="emailsha256";let b=E;function Lt(){return M}function Ot(i){if(!i){window.console.log("You must pass a config object to register the kit "+h);return}if(!f(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}f(i.kits)?i.kits[h]={constructor:b}:(i.kits={},i.kits[h]={constructor:b}),window.console.log("Successfully registered "+h+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:h,constructor:b,getId:Lt}),j.register=Ot,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}),j})({});
2
2
  //# sourceMappingURL=Rokt-Kit.iife.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-rokt-kit",
3
- "version": "3.6.2",
3
+ "version": "3.7.0",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "module": "dist/Rokt-Kit.esm.js",