@mrrocket/sdk 0.15.0 → 0.16.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +36 -1
  3. package/dist/api-client.d.ts +5 -4
  4. package/dist/api-client.js +12 -8
  5. package/dist/api-client.js.map +1 -1
  6. package/dist/api.d.ts +4 -1
  7. package/dist/api.js +2 -1
  8. package/dist/api.js.map +1 -1
  9. package/dist/batch.d.ts +6 -4
  10. package/dist/batch.js +3 -3
  11. package/dist/batch.js.map +1 -1
  12. package/dist/browser/mrrocket-flows.js +2 -2
  13. package/dist/browser/mrrocket-forms.js +1 -1
  14. package/dist/browser/mrrocket-messenger.js +2 -2
  15. package/dist/browser/mrrocket-push.js +1 -1
  16. package/dist/browser/mrrocket-replay.js +3 -3
  17. package/dist/browser/mrrocket.js +1 -1
  18. package/dist/client.d.ts +10 -2
  19. package/dist/client.js +36 -15
  20. package/dist/client.js.map +1 -1
  21. package/dist/context.d.ts +5 -1
  22. package/dist/context.js.map +1 -1
  23. package/dist/core.d.ts +1 -1
  24. package/dist/core.js +1 -1
  25. package/dist/core.js.map +1 -1
  26. package/dist/errors.d.ts +5 -1
  27. package/dist/errors.js +8 -2
  28. package/dist/errors.js.map +1 -1
  29. package/dist/flows-web.d.ts +2 -0
  30. package/dist/flows-web.js +4 -1
  31. package/dist/flows-web.js.map +1 -1
  32. package/dist/flows.d.ts +10 -0
  33. package/dist/flows.js +2 -0
  34. package/dist/flows.js.map +1 -1
  35. package/dist/forms.d.ts +4 -0
  36. package/dist/forms.js +4 -1
  37. package/dist/forms.js.map +1 -1
  38. package/dist/identity.d.ts +42 -0
  39. package/dist/identity.js +24 -0
  40. package/dist/identity.js.map +1 -0
  41. package/dist/index.d.ts +2 -0
  42. package/dist/index.js.map +1 -1
  43. package/dist/messenger-ui.d.ts +2 -0
  44. package/dist/messenger-ui.js +2 -2
  45. package/dist/messenger-ui.js.map +1 -1
  46. package/dist/messenger.js +3 -2
  47. package/dist/messenger.js.map +1 -1
  48. package/dist/push-web.d.ts +2 -13
  49. package/dist/push-web.js +4 -2
  50. package/dist/push-web.js.map +1 -1
  51. package/dist/react-native/index.d.cts +61 -9
  52. package/dist/react-native/index.d.ts +61 -9
  53. package/dist/react-native/index.js +107 -28
  54. package/dist/react-native/index.js.map +1 -1
  55. package/dist/replay.d.ts +4 -1
  56. package/dist/replay.js +8 -2
  57. package/dist/replay.js.map +1 -1
  58. package/dist/server.d.ts +2 -0
  59. package/dist/server.js +2 -0
  60. package/dist/server.js.map +1 -1
  61. package/dist/user-hash.d.ts +27 -0
  62. package/dist/user-hash.js +24 -0
  63. package/dist/user-hash.js.map +1 -0
  64. package/package.json +5 -1
@@ -1,2 +1,2 @@
1
- (function(){'use strict';var an=Object.defineProperty;var cn=(e,n,r)=>n in e?an(e,n,{enumerable:true,configurable:true,writable:true,value:r}):e[n]=r;var be=(e,n,r)=>cn(e,typeof n!="symbol"?n+"":n,r);var Et=e=>{let n=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);s<128?n+=1:s<2048?n+=2:s>=55296&&s<=56319&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(n+=4,r++):n+=3;}return n},ln=(e,n,r)=>{let s=`{"key":${JSON.stringify(e)},"sdk":${JSON.stringify(r)},"events":[`,l=Et(s)+2,c=[],p=[],R=[],E=l,h=()=>{p.length&&c.push({body:`${s}${p.join(",")}]}`,events:R}),p=[],R=[],E=l;};for(let S of n){let m=JSON.stringify(S),w=Et(m)+1;l+w>6e4||((p.length===100||E+w>6e4)&&h(),p.push(m),R.push(S),E+=w);}return h(),c},_t=(e,n,r)=>ln(e,n,r).map(s=>s.body);var ve=class{constructor(n=1e3,r=30,s=3){be(this,"windowMs",n);be(this,"radius",r);be(this,"count",s);be(this,"clicks",[]);be(this,"fired",false);}push(n,r,s){let l=this.clicks.filter(c=>s-c.t<=this.windowMs&&Math.hypot(c.x-n,c.y-r)<=this.radius);return l.length!==this.clicks.length&&(this.fired=false),this.clicks=[...l,{x:n,y:r,t:s}],this.clicks.length>=this.count&&!this.fired?(this.fired=true,true):false}};var dn='a[href],button,input,select,textarea,label,summary,[role="button"],[role="link"],[role="tab"],[role="menuitem"],[role="checkbox"],[role="switch"],[onclick],[data-ck-goal]',un="[data-ck-mask]",fn="[data-ck-block]",St=/\d{4,}|^[a-z]{1,3}-[a-z0-9]{5,}$|^_|__|css-|^sc-|^jsx-/i,pn=e=>{let n=e.tagName.toLowerCase();if(e.id&&!St.test(e.id)&&e.id.length<=40)return `${n}#${e.id}`;let r=typeof e.className=="string"?e.className.split(/\s+/).filter(c=>c&&!St.test(c)&&c.length<=30&&!c.includes(":")):[],s=r.length?`${n}.${r.slice(0,2).join(".")}`:n,l=e.parentElement?[...e.parentElement.children].filter(c=>c.tagName===e.tagName):[];return l.length>1?`${s}:nth-of-type(${l.indexOf(e)+1})`:s},gn=e=>{let n=[],r=e;for(;r&&n.length<3&&r.tagName&&r.tagName!=="BODY"&&r.tagName!=="HTML";){let s=pn(r);if(n.unshift(s),s.includes("#"))break;r=r.parentElement;}return n.join(" > ").slice(0,160)},$e=e=>(e!=null?e:"").replace(/\s+/g," ").trim().slice(0,40),mn=e=>{var r,s,l,c,p;if(e.closest(`${un},${fn}`))return "";let n=e.tagName.toLowerCase();if(n==="input"){let R=((r=e.getAttribute("type"))!=null?r:"text").toLowerCase();return $e(R==="submit"||R==="button"?(s=e.getAttribute("aria-label"))!=null?s:e.value:e.getAttribute("aria-label"))}return $e(n==="select"||n==="textarea"?e.getAttribute("aria-label"):(p=(c=(l=e.getAttribute("aria-label"))!=null?l:e.getAttribute("title"))!=null?c:e.innerText)!=null?p:e.textContent)},Ot=e=>{var c,p;let n=e.target instanceof Element?e.target:null;if(!n)return null;let r=n.closest(dn),s=r!=null?r:n,l=document.documentElement;return {x:Math.round(e.clientX),y:Math.round(e.clientY+window.scrollY),vw:window.innerWidth,vh:window.innerHeight,docH:Math.max(l.scrollHeight,(p=(c=document.body)==null?void 0:c.scrollHeight)!=null?p:0),selector:gn(s),label:r?mn(r):"",interactive:!!r}},It=()=>{var r,s;let e=document.documentElement,n=Math.max(e.scrollHeight,(s=(r=document.body)==null?void 0:r.scrollHeight)!=null?s:0);return n?Math.min(100,Math.round((window.scrollY+window.innerHeight)/n*100)):0};var Ne="0.15.0",wn=(e,n)=>{let r=n.trim().toLowerCase();for(let[s,l]of Object.entries(e))if(s.toLowerCase()===r)return l},hn=(e,n)=>{let r=e.trim().toLowerCase(),s=n.trim().toLowerCase();return s.startsWith("@")?r.endsWith(s):r===s},kn=(e,n)=>{if(e.op==="in cohort")return false;let r=wn(n,e.property),s=r==null?"":String(r);if(e.op==="\u2265"){let c=Number(s),p=Number(e.values[0]);return s!==""&&Number.isFinite(c)&&Number.isFinite(p)&&c>=p}let l=s!==""&&e.values.some(c=>hn(s,c));return e.op==="is"||e.op==="in"?l:!l},yn=(e,n,r={})=>{var R;if(!e.on)return false;let s={id:n,...r},l=e.sets.length?e.sets.find(E=>E.conditions.every(h=>kn(h,s))):{rollout:100};if(!l||Ft(`${e.key}:rollout:${n}`)*100>=l.rollout)return false;if(!((R=e.variants)!=null&&R.length))return true;let c=Ft(`${e.key}:variant:${n}`)*100,p=0;for(let E of e.variants)if(p+=E.split,c<p)return E.key;return e.variants[e.variants.length-1].key},tt=(e,n,r,s={})=>{var c;let l=(c=n==null?void 0:n.flags)==null?void 0:c.find(p=>p.key===e);return l?yn(l,r,s):false},bn=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],Pt="ck_preview",Mt="ck_embed",ue="ck_id",Ce="ck_sid";var Cn=e=>{var r;let n={};for(let s of bn){let l=(r=e(s))==null?void 0:r.trim();l&&(n[s]=l.slice(0,150));}return n},$t=e=>{let n=new URLSearchParams(e);return Cn(r=>n.get(r))};var xn=e=>{let n=2166136261;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return (n>>>0)/4294967296},Ft=e=>{let n=2166136261;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return n^=n>>>16,n=Math.imul(n,2246822507),n^=n>>>13,n=Math.imul(n,3266489909),n^=n>>>16,(n>>>0)/4294967296},Rn=(e,n)=>{var c,p,R,E;let r=(p=(c=e.variants[0])==null?void 0:c.id)!=null?p:"control";if(e.winner)return e.winner;if(e.status!=="running")return r;let s=xn(`${e.key}:${n}`),l=0;for(let h of e.variants)if(l+=h.weight,s<l)return h.id;return (E=(R=e.variants[e.variants.length-1])==null?void 0:R.id)!=null?E:r},At=e=>{let n=Array.isArray(e)?e[0]:e;if(!n)return {};let r={};for(let s of n.split(",")){let[l,c]=s.split(":");l&&c&&(r[l.trim()]=c.trim());}return r};var _e=(e,n,r,s)=>{if(s[e])return s[e];let l=n==null?void 0:n.experiments.find(c=>c.key===e);return l?Rn(l,r):"control"},Nt=(e,n,r)=>{var l,c,p,R,E,h;let s={...(l=e==null?void 0:e.texts)!=null?l:{}};for(let S of (c=e==null?void 0:e.experiments)!=null?c:[]){let m=_e(S.key,e,n,r);m!==((R=(p=S.variants[0])==null?void 0:p.id)!=null?R:"control")&&Object.assign(s,(h=(E=S.variants.find(w=>w.id===m))==null?void 0:E.changes)!=null?h:{});}return s},Ee="ck_x",Ae=e=>e.replace(/\/+$/,"")||"/",Lt=(e,n,r,s={})=>{var R,E;if(!e)return null;let l;try{l=new URL(n);}catch(h){return null}if(l.searchParams.has(Ee))return null;let c=Ae(l.pathname),p=(h,S)=>{let m;try{m=new URL(h,l);}catch(w){return}if(!(!/^https?:$/.test(m.protocol)||m.origin===l.origin&&Ae(m.pathname)===c))return l.searchParams.forEach((w,O)=>{m.searchParams.has(O)||m.searchParams.set(O,w);}),S&&m.searchParams.set(Ee,S),m.hash||(m.hash=l.hash),m.href};for(let h of (R=e.redirects)!=null?R:[]){let S=h.from&&Ae(h.from)===c?p(h.to):void 0;if(S)return {to:S}}for(let h of e.experiments){if(!h.path||Ae(h.path)!==c)continue;let S=h.status==="running"&&!h.winner;if(S&&r===null&&!s[h.key])return null;let m=_e(h.key,e,r!=null?r:"",s),w=(E=h.variants.find(M=>M.id===m))==null?void 0:E.url,O=w?p(w,S?`${h.key}:${m}`:void 0):void 0;return S?{to:O,experiment:h.key,variant:m}:O?{to:O}:null}return null},Tt=(e,n)=>{let[r,s]=(n!=null?n:"").split(":"),l=e==null?void 0:e.experiments.find(c=>c.key===r);return l&&l.variants.some(c=>c.id===s)?{experiment:r,variant:s}:null};var nt=()=>typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():`ck_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;var Se=(e,n)=>e.length>n?`${e.slice(0,n-1)}\u2026`:e,vn=e=>{var n;if(e instanceof Error)return {type:e.name||"Error",message:Se(e.message||String(e),1e3),stack:e.stack?Se(e.stack,8192):void 0};if(typeof e=="string")return {type:"Error",message:Se(e,1e3)};try{return {type:"Error",message:Se((n=JSON.stringify(e))!=null?n:String(e),1e3)}}catch(r){return {type:"Error",message:String(e)}}},Ut=e=>{let n=[],r=[],s=new Set,l=0,c=`${e.host}/api/sdk/errors`,p=(w=false)=>{for(;n.length;){let O=JSON.stringify({key:e.apiKey,errors:n.splice(0,4)});w&&typeof navigator!="undefined"&&"sendBeacon"in navigator&&navigator.sendBeacon(c,O)||fetch(c,{method:"POST",headers:{"content-type":"application/json"},body:O,keepalive:true}).then(L=>{!L.ok&&L.status!==429&&e.warn(`Error reports were rejected with ${L.status}. Check the public key and NEXT_PUBLIC_MRROCKET_HOST.`);}).catch(()=>{});}},R=(w,O="manual")=>{let M=e.context();if(!M.send||l>=20)return;let L=vn(w);if(/\/api\/sdk\/errors/.test(L.message))return;let N=`${L.type}:${L.message}`;s.has(N)||(s.add(N),l++,n.push({...L,mechanism:O,handled:O==="manual",url:window.location.href,ts:Date.now(),crumbs:r.slice(),...e.release?{release:e.release}:{},...M.distinctId?{distinctId:M.distinctId}:{},...M.sessionId?{sessionId:M.sessionId}:{}}));},E=w=>{var O;!w.error&&(!w.message||w.message==="Script error.")||R((O=w.error)!=null?O:new Error(w.message),"onerror");},h=w=>{var O;return R((O=w.reason)!=null?O:new Error("Unhandled promise rejection"),"onunhandledrejection")},S=()=>p(true);window.addEventListener("error",E),window.addEventListener("unhandledrejection",h),window.addEventListener("pagehide",S);let m=window.setInterval(()=>p(),2e3);return {capture:R,crumb:(w,O)=>{r.push({ts:Date.now(),type:w,message:Se(O,120)}),r.length>20&&r.shift();},stop:()=>{window.removeEventListener("error",E),window.removeEventListener("unhandledrejection",h),window.removeEventListener("pagehide",S),window.clearInterval(m),p(true);}}};var Oe="$cancel_flow",ie="$onboarding",rt="$inapp",En={version:0,question:"",reasons:[],offers:{},confirm:{title:"Cancel your subscription?",body:"You keep access until the end of the billing period.",button:"Cancel subscription"},offersFor:"business"},_n="Something went wrong. Please try again.",Dt="mrrocket:onboarding",Te=e=>e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),jt=new Set(["signed_up","signup","sign_up","registered","account_created","user_signed_up"]),ot=(e,n)=>{let r=Te(e),s=Te(n);return !r||!s?false:r===s||jt.has(r)&&jt.has(s)},Sn=e=>/^(first (launch|visit|open|session|login|sign ?in|app open)|app (opened|launched)|on load|every visit|always)?$/i.test(e.trim()),On=()=>`cf_${Math.random().toString(36).slice(2,10)}${Date.now().toString(36)}`;var In=e=>{let n=(e!=null?e:"").trim();return /^https?:\/\//i.test(n)||/^\/(?!\/)/.test(n)?n:void 0},fe=e=>{var n;return (n=e.nodes)!=null?n:e.steps},Fn=e=>Math.max(0,e.amount)*(e.unit==="hours"?36e5:864e5),Pn=(e,n)=>{let r=e.trim(),s=(n.split(/[?#]/)[0]||"/").replace(/\/+$/,"")||"/";if(!r)return false;if(r.endsWith("*")){let l=r.slice(0,-1).replace(/\/+$/,"");return !l||s===l||s.startsWith(`${l}/`)}return s===(r.replace(/\/+$/,"")||"/")},st=e=>e.flatMap(n=>n.kind==="condition"?[...st(n.yes),...st(n.no)]:n.kind==="wait"?[]:[n]),Mn=(e,n=Date.now())=>e==null||e===""?NaN:Math.floor((n-new Date(e).getTime())/2630016e3),Le=e=>e==null?void 0:e.trim().toLowerCase(),$n=({when:e={}},n)=>(e.answer==null||Le(e.answer)===Le(n.answer))&&(e.plan==null||[e.plan].flat().some(r=>Le(r)===Le(n.plan)))&&!(n.months>=e.tenureUnder)&&!(n.months<e.tenureOver)&&(e.tenureUnder==null||n.months>=0)&&(e.tenureOver==null||n.months>=0),Ht=e=>{let n=null,r=null,s=null,l=[],c=false,p=null,R,E=null,h=new Map,S=new Set,m=new Set,w=new Set,O=e.auto!==false,M=new Set,L=()=>{var t,i;return (i=(t=e.now)==null?void 0:t.call(e))!=null?i:Date.now()},N=null,J=()=>{var t;return (t=n==null?void 0:n.onboarding)!=null?t:[]},Q=t=>t?J().find(i=>i.id===t):void 0,K=t=>{let i=h.get(t);return i||h.set(t,i={done:new Set,dismissed:false,answers:new Map,at:new Map,reached:new Map}),i},Z=false,B=t=>{e.track(ie,t),Z=true;},ae=(t,i)=>{t.done.add(i),t.at.set(i,L());},Xe=t=>{var i,a,g;if((i=t.page)!=null&&i.trim()){let d=(a=e.path)==null?void 0:a.call(e);return d===void 0?false:Pn(t.page,d)}if((g=t.event)!=null&&g.trim()){if(!c)return;for(let d of M)if(ot(t.event,d))return true;return false}return false},pe=(t,i,a,g,d=0,C)=>{var _,k;for(let b=0;b<i.length;b++){let x=i[b];if(x.kind==="wait"){if(a.done.has(x.id)){C=(_=a.at.get(x.id))!=null?_:C;continue}let I=a.reached.get(x.id);if(I===void 0){if(!g)return {at:"pending"};I=C!=null?C:L(),a.reached.set(x.id,I),B({flow:t.id,step:x.id,kind:"wait",action:"shown"});}let V=I+Fn(x);if(L()<V)return {at:"wait",until:V};if(!g)return {at:"pending"};ae(a,x.id),B({flow:t.id,step:x.id,kind:"wait",action:"completed"}),C=V;continue}if(x.kind==="condition"){let I=a.answers.get(x.id);if(I===void 0){if(!g)return {at:"pending"};if(I=Xe(x),I===void 0)return {at:"pending"};a.answers.set(x.id,I),B({flow:t.id,step:x.id,kind:"condition",action:"answered",answer:I?"yes":"no"});}return pe(t,I?x.yes:x.no,a,g,d,C)}if(!a.done.has(x.id))return {at:"step",step:x,line:i,index:b,before:d};C=(k=a.at.get(x.id))!=null?k:C,d++;}return {at:"end"}},ce=t=>{let i=h.get(t.id);return !!i&&(i.dismissed||pe(t,fe(t),i,false).at==="end")},ge=t=>`${Dt}:${t!=null?t:"visitor"}`,H=t=>`${Dt}:events:${t!=null?t:"visitor"}`,q=()=>{var a;Z=false;let t=(a=e.storage)==null?void 0:a.call(e);if(!t)return;let i={};for(let[g,d]of h)i[g]={done:[...d.done],...d.dismissed?{dismissed:true}:{},...d.answers.size?{answers:Object.fromEntries([...d.answers].map(([C,_])=>[C,_?"yes":"no"]))}:{},...d.at.size?{at:Object.fromEntries(d.at)}:{},...d.reached.size?{reached:Object.fromEntries(d.reached)}:{}};try{t.set(ge(e.personId()),JSON.stringify(i)),M.size&&t.set(H(e.personId()),JSON.stringify([...M].slice(-200)));}catch(g){}},P=t=>{var i,a,g,d;for(let[C,_]of Object.entries(t!=null?t:{})){let k=K(C);for(let b of (i=_.done)!=null?i:[])k.done.add(b);_.dismissed&&(k.dismissed=true);for(let[b,x]of Object.entries((a=_.answers)!=null?a:{}))k.answers.has(b)||k.answers.set(b,x==="yes");for(let[b,x]of Object.entries((g=_.at)!=null?g:{}))typeof x=="number"&&!k.at.has(b)&&k.at.set(b,x);for(let[b,x]of Object.entries((d=_.reached)!=null?d:{}))typeof x=="number"&&(!k.reached.has(b)||x<k.reached.get(b))&&k.reached.set(b,x);}},ee=t=>{var a;N&&clearTimeout(N),N=null;let i=t-L();i>0&&i<=864e5&&(N=setTimeout(()=>(N=null,$()),i+50),(a=N.unref)==null||a.call(N));},me=false,le=()=>{me=false;let t=Q(s);if(!t)return null;let i=K(t.id);if(i.dismissed)return null;let a=pe(t,fe(t),i,true);if(Z&&q(),a.at==="wait"&&ee(a.until),me=a.at==="wait"||a.at==="pending",a.at!=="step")return null;let{step:g,line:d,index:C}=a,_=I=>!!I&&I.kind!=="wait"&&I.kind!=="condition";if(g.kind==="checklist"){let I=C;for(;I>0&&_(d[I-1])&&d[I-1].kind==="checklist";)I--;let V=C;for(;V+1<d.length&&_(d[V+1])&&d[V+1].kind==="checklist";)V++;let he=d.slice(I,V+1).filter(_);for(let te of he)!i.done.has(te.id)&&!m.has(`s:${te.id}`)&&(m.add(`s:${te.id}`),e.track(ie,{flow:t.id,step:te.id,kind:"checklist",action:"shown"}));return {type:"checklist",flow:t,items:he.map(te=>({step:te,done:i.done.has(te.id)}))}}m.has(`s:${g.id}`)||(m.add(`s:${g.id}`),e.track(ie,{flow:t.id,step:g.id,kind:g.kind,action:"shown"}));let k=d.slice(C+1),b=k.findIndex(I=>I.kind==="condition"),x=(b<0?k:k.slice(0,b)).filter(_).length;return {type:"step",flow:t,step:g,index:a.before,total:a.before+1+x,last:!x&&b<0}},de=()=>{var a,g;if(r){let d=r,C=(a=d.flow.followUps)==null?void 0:a[d.reason],_=C?1:0,k=d.plain?1:3+_+((g=d.flow.second)!=null&&g[d.reason]?1:0);return {type:"cancel",screen:d.screen,flow:d.flow,reason:d.reason,...d.screen==="followup"&&C?{followUp:C,answer:d.answer}:{},offer:d.screen==="offer"?d.offer:void 0,...d.screen==="offer"?{round:d.round}:{},price:d.options.price,busy:d.busy,error:d.error,step:d.screen==="survey"?1:d.screen==="followup"?2:d.screen==="offer"?1+_+d.round:k,steps:k}}let t=le();if(t)return t;s&&!me&&(s=null);let i=l.find(d=>!S.has(d.id));return i?{type:"message",message:i}:null},$=()=>{let t=de();(t==null?void 0:t.type)==="message"&&!m.has(`m:${t.message.id}`)&&(m.add(`m:${t.message.id}`),e.track(rt,{message:t.message.id,journey:t.message.journey,action:"shown"}));for(let i of [...w])try{i();}catch(a){}},G=t=>s===t.id?true:s&&Q(s)&&!ce(Q(s))?false:(s=t.id,e.track(ie,{flow:t.id,action:"started"}),$(),true),xe=()=>{var i;if(!O||s||!c||!e.personId()&&!((i=e.storage)!=null&&i.call(e)))return;let t=J().find(a=>Sn(a.trigger)&&fe(a).length&&!ce(a));t&&G(t);},Pe=()=>{let t=e.personId();E!==null&&E!==t&&(h.clear(),M.clear(),S.clear(),s=null,R=void 0),E=t;let i=(async()=>{var d,C,_;let a=(d=e.storage)==null?void 0:d.call(e);if(a)try{let k=await a.get(ge(t));k&&P(JSON.parse(k));let b=await a.get(H(t));if(b)for(let x of JSON.parse(b))typeof x=="string"&&M.add(x);}catch(k){}let g=J().length>0||!!(n!=null&&n.messages);if(t&&g&&R!==t){R=t;let k=await e.fetchInApp(t).catch(()=>null);if(k&&e.personId()===t){P(k.onboarding);for(let b of (C=k.events)!=null?C:[])typeof b=="string"&&M.add(Te(b));l=((_=k.messages)!=null?_:[]).filter(b=>b&&b.id&&b.title);}}t||(l=[]),c=true,xe(),$();})();return p=i.finally(()=>{p===i&&(p=null);}),p},U=t=>t.round>1?{round:2}:t.rule>=0?{rule:t.rule}:{},j=t=>{var g,d,C,_;let i={answer:t.answer,plan:t.options.plan,months:Mn(t.options.customerSince,(g=e.now)==null?void 0:g.call(e))},a=(C=(d=t.flow.rules)==null?void 0:d[t.reason])!=null?C:[];t.rule=a.findIndex(k=>$n(k,i)),t.offer=t.rule<0?t.flow.offers[t.reason]:(_=a[t.rule].offer)!=null?_:void 0,t.round=1,t.screen=t.offer?"offer":"confirm";},W=(t,i,a)=>{var d;let g=t.screen==="offer"?t.offer:void 0;return {outcome:i,run:t.run,...t.reason?{reason:t.reason,reasonLabel:(d=t.flow.reasons.find(C=>C.id===t.reason))==null?void 0:d.label}:{},...t.answer?{answer:t.answer}:{},...i==="saved"&&g?{offer:g}:{},...a!=null&&a.trim()?{comment:a.trim().slice(0,500)}:{}}},ne=(t,i)=>{var a;e.track(Oe,{action:"finished",run:t.run,version:t.flow.version,outcome:i.outcome,customer:(a=t.options.customer)!=null?a:"consumer",...i.reason?{reason:i.reason}:{},...i.answer?{answer:i.answer}:{},...i.offer?{offer:i.offer.kind,...U(t)}:{},...i.comment?{comment:i.comment}:{}}),r===t&&(r=null),t.resolve(i),$();},we=(t,i,a)=>{if(t.busy)return;let g=W(t,i,a),d=i==="saved"?t.options.onSave:t.options.onCancel;t.busy=true,t.error=void 0,$(),Promise.resolve().then(()=>d==null?void 0:d(g)).then(()=>ne(t,g),()=>{t.busy=false,t.error=_n,$();});};return {setConfig:t=>{n=t,s&&!Q(s)&&(s=null),$();},refresh:Pe,onEvent:t=>{var _;if(!t||t.startsWith("$"))return;let i=Te(t),a=!!i&&!M.has(i);a&&M.add(i);let g=Q(s),d=false;if(g){let k=K(g.id);for(let b of st(fe(g)))b.kind==="checklist"&&b.event&&!k.done.has(b.id)&&ot(b.event,t)&&(ae(k,b.id),d=true,e.track(ie,{flow:g.id,step:b.id,kind:b.kind,action:"completed"}));}if(d||a&&g?(q(),$()):a&&q(),!O||!e.personId()&&!((_=e.storage)!=null&&_.call(e)))return;let C=J().find(k=>fe(k).length&&ot(k.trigger,t)&&!ce(k));C&&G(C);},openCancelFlow:(t={})=>{var _,k;if(r)return r.promise;let i=(_=n==null?void 0:n.cancelFlow)!=null?_:En,a=t.customer!=="business"||i.reasons.length<2,g=()=>{},d=new Promise(b=>g=b),C={flow:i,options:t,plain:a,screen:a?"confirm":"survey",round:1,run:On(),busy:false,resolve:g,promise:d};return r=C,e.track(Oe,{action:"shown",run:C.run,version:i.version,customer:(k=t.customer)!=null?k:"consumer",plain:a}),$(),d},startOnboarding:t=>{let i=t?Q(t):J().find(g=>fe(g).length&&!ce(g));if(!i||!fe(i).length)return false;let a=K(i.id);return a.dismissed=false,G(i)},view:de,subscribe:t=>(w.add(t),()=>w.delete(t)),cancel:{pick:t=>{!r||r.busy||r.screen!=="survey"||!r.flow.reasons.some(i=>i.id===t)||(r.reason!==t&&(r.answer=void 0),r.reason=t,r.error=void 0,$());},answer:t=>{let i=r;if(!i||i.busy||i.screen!=="followup")return;let a=t.slice(0,500);i.answer=a.trim()?a:void 0,$();},next:()=>{var i,a;let t=r;if(!(!t||!t.reason)){if(t.screen==="survey")e.track(Oe,{action:"answered",run:t.run,version:t.flow.version,reason:t.reason}),(i=t.flow.followUps)!=null&&i[t.reason]?t.screen="followup":j(t);else if(t.screen==="followup")t.answer=(a=t.answer)==null?void 0:a.trim(),j(t);else return;$();}},accept:t=>{var a;let i=r;!i||i.screen!=="offer"||!i.reason||(i.busy||e.track(Oe,{action:"offer",run:i.run,version:i.flow.version,reason:i.reason,offer:(a=i.offer)==null?void 0:a.kind,...U(i),outcome:"accepted"}),we(i,"saved",t));},decline:()=>{var a,g;let t=r;if(!t||t.screen!=="offer"||t.busy)return;e.track(Oe,{action:"offer",run:t.run,version:t.flow.version,reason:t.reason,offer:(a=t.offer)==null?void 0:a.kind,...U(t),outcome:"declined"});let i=t.round===1&&t.reason?(g=t.flow.second)==null?void 0:g[t.reason]:void 0;i?(t.offer=i,t.rule=void 0,t.round=2):t.screen="confirm",t.error=void 0,$();},confirm:t=>{let i=r;!i||i.screen!=="confirm"||we(i,"cancelled",t);},close:()=>{var a,g;let t=r;if(!t||t.busy)return;let i=W(t,"kept");(g=(a=t.options).onClose)==null||g.call(a,i),ne(t,i);}},onboarding:{next:()=>{let t=le();(t==null?void 0:t.type)==="step"&&(ae(K(t.flow.id),t.step.id),e.track(ie,{flow:t.flow.id,step:t.step.id,kind:t.step.kind,action:"completed"}),q(),$());},check:t=>{let i=le();if((i==null?void 0:i.type)!=="checklist")return;let a=i.items.find(g=>g.step.id===t);!a||a.done||(ae(K(i.flow.id),t),e.track(ie,{flow:i.flow.id,step:t,kind:"checklist",action:"completed"}),q(),$());},dismiss:()=>{let t=le();!t||t.type!=="step"&&t.type!=="checklist"||(K(t.flow.id).dismissed=true,e.track(ie,{flow:t.flow.id,...t.type==="step"?{step:t.step.id}:{},action:"dismissed"}),s=null,q(),$());}},message:{click:()=>{var a;let t=de();if((t==null?void 0:t.type)!=="message")return;S.add(t.message.id),e.track(rt,{message:t.message.id,journey:t.message.journey,action:"clicked"});let i=In(t.message.url);$(),i&&((a=e.openUrl)==null||a.call(e,i));},dismiss:()=>{let t=de();(t==null?void 0:t.type)==="message"&&(S.add(t.message.id),e.track(rt,{message:t.message.id,journey:t.message.journey,action:"dismissed"}),$());}}}};var An="ck_pick",Nn="ck_origin",Ue=e=>typeof CSS!="undefined"&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>`\\${n}`),Ln=e=>[...e.classList].filter(n=>n.length<30&&!/\d{2,}|[_-][a-z0-9]{5,}$|^(is|has)-|hover|active|focus|open|selected|:|\[/.test(n)).slice(0,2),Kt=e=>{let n=e.ownerDocument,r=p=>{try{return n.querySelectorAll(p).length===1}catch(R){return false}},s=e.getAttribute("data-ck-target");if(s)return `[data-ck-target="${s.replace(/"/g,'\\"')}"]`;if(e.id&&!/\d{3,}/.test(e.id)&&r(`#${Ue(e.id)}`))return `#${Ue(e.id)}`;let l=[],c=e;for(;c&&c!==n.documentElement&&l.length<6;){if(c!==e&&c.id&&!/\d{3,}/.test(c.id)){l.unshift(`#${Ue(c.id)}`);break}let p=c.tagName.toLowerCase(),R=Ln(c).map(w=>`.${Ue(w)}`).join(""),E=c.parentElement,h=E?[...E.children].filter(w=>w.tagName===c.tagName):[],S=h.length>1?`:nth-of-type(${h.indexOf(c)+1})`:"";l.unshift(`${p}${R}${S}`);let m=l.join(" > ");if(r(m))return m;c=E;}return l.join(" > ")},Wt=()=>{var S;if(typeof window=="undefined"||window.top===window)return null;let e=new URLSearchParams(window.location.search);if(e.get(An)!=="1")return null;let n;try{n=new URL((S=e.get(Nn))!=null?S:"").origin;}catch(m){return null}if(!/^https?:\/\//.test(n))return null;let r=m=>window.parent.postMessage(m,n),s=document.createElement("div");s.setAttribute("aria-hidden","true"),Object.assign(s.style,{position:"fixed",zIndex:"2147483647",pointerEvents:"none",border:"2px solid #0ea5e9",background:"rgba(14,165,233,.12)",borderRadius:"6px",transition:"all 60ms linear",display:"none"});let l=document.createElement("div");Object.assign(l.style,{position:"absolute",left:"-2px",bottom:"calc(100% + 4px)",font:"600 11px/1.4 system-ui, sans-serif",color:"#fff",background:"#0c4a6e",padding:"2px 6px",borderRadius:"4px",whiteSpace:"nowrap",maxWidth:"360px",overflow:"hidden",textOverflow:"ellipsis"}),s.appendChild(l),document.body.appendChild(s);let c=null,p=m=>{if(c=m&&m!==s&&!s.contains(m)?m:null,!c){s.style.display="none";return}let w=c.getBoundingClientRect();Object.assign(s.style,{display:"block",left:`${w.left-2}px`,top:`${w.top-2}px`,width:`${w.width+4}px`,height:`${w.height+4}px`}),l.textContent=Kt(c);},R=m=>p(document.elementFromPoint(m.clientX,m.clientY)),E=m=>{var O,M;m.preventDefault(),m.stopPropagation();let w=(O=document.elementFromPoint(m.clientX,m.clientY))!=null?O:c;!w||w===s||r({type:"mrrocket:picked",selector:Kt(w),text:((M=w.textContent)!=null?M:"").trim().replace(/\s+/g," ").slice(0,80)});},h=m=>{m.key==="Escape"&&r({type:"mrrocket:pick-cancel"});};return window.addEventListener("mousemove",R,true),window.addEventListener("click",E,true),window.addEventListener("keydown",h,true),r({type:"mrrocket:pick-ready"}),()=>{window.removeEventListener("mousemove",R,true),window.removeEventListener("click",E,true),window.removeEventListener("keydown",h,true),s.remove();}};var Tn={get:e=>{try{return window.localStorage.getItem(e)}catch(n){return null}},set:(e,n)=>{try{window.localStorage.setItem(e,n);}catch(r){}}},Vt=()=>{try{for(let e=window.localStorage.length-1;e>=0;e--){let n=window.localStorage.key(e);n!=null&&n.startsWith("mrrocket:onboarding")&&window.localStorage.removeItem(n);}}catch(e){}},Bt=e=>({track:e.track,personId:e.personId,auto:e.auto,storage:()=>e.canStore()?Tn:null,openUrl:n=>window.location.assign(n),path:()=>window.location.pathname,fetchInApp:async n=>{if(!e.apiKey)return null;let r=await fetch(`${e.host}/api/sdk/inapp?key=${encodeURIComponent(e.apiKey)}&distinctId=${encodeURIComponent(n)}`);return r.ok?await r.json():null}});var He="mrr_ref",Ke="mrr_ref",Un="mrr_ref",Dn="mrr_click";var Ie=/^[A-Za-z0-9_-]{1,64}$/;var jn=(e,n="ref")=>{let r=new URLSearchParams(e);return Hn(s=>r.get(s),n)},Hn=(e,n="ref")=>{let r=e(Un);if(r&&Ie.test(r)){let l=e(Dn);return {code:r,clickId:l&&Ie.test(l)?l:null,direct:false}}let s=e(n);return s&&Ie.test(s)?{code:s,clickId:null,direct:true}:null},qt=e=>{var n;return `${e.code}.${(n=e.clickId)!=null?n:""}.${e.at}`},De=(e,n=60,r=Date.now())=>{if(!e)return null;let[s,l,c]=e.split("."),p=Number(c);return !s||!Ie.test(s)||!Number.isFinite(p)||l&&!Ie.test(l)||r-p>n*864e5||p>r+864e5?null:{code:s,clickId:l||null,at:p}};var D=null,We=()=>typeof document!="undefined",Yt=e=>{var r;if(!We())return;let n=(r=document.cookie.split("; ").find(s=>s.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);try{return n?decodeURIComponent(n):void 0}catch(s){return n}},Ve=()=>{try{return typeof localStorage=="undefined"?null:localStorage}catch(e){return null}},it=()=>{var e,n;return D||(We()?(n=De(Yt(He),3650))!=null?n:De((e=Ve())==null?void 0:e.getItem(Ke),3650):null)};var je=(e,n)=>{var l;if(!We())return;let r=Math.max(1,Math.round(n))*86400,s=typeof location!="undefined"&&location.protocol==="https:"?"; secure":"";document.cookie=`${He}=${encodeURIComponent(qt(e))}; path=/; max-age=${r}; samesite=lax${s}`;try{(l=Ve())==null||l.setItem(Ke,qt(e));}catch(c){}},Be=()=>{var e;if(We()){document.cookie=`${He}=; path=/; max-age=0; samesite=lax`;try{(e=Ve())==null||e.removeItem(Ke);}catch(n){}}},Xt=()=>{D=null;},zt=async e=>{var s,l,c;let n=jn(e.search,e.param),r=(s=e.now)!=null?s:Date.now();if(!n)return !D&&e.store&&(D=(c=De(Yt(He),e.days,r))!=null?c:De((l=Ve())==null?void 0:l.getItem(Ke),e.days,r),D||Be()),D;if(D={code:n.code,clickId:n.clickId,at:r},e.store&&je(D,e.days),e.beacon)try{let p=await e.beacon({code:n.code,clickId:n.clickId});p&&D&&D.code===n.code&&!D.clickId&&(D={...D,clickId:p},e.store&&je(D,e.days));}catch(p){}return D},Jt=e=>e==="$identify"||!e.startsWith("$");var at=3600*24*365,Zt=e=>{var r;if(typeof document=="undefined")return;let n=(r=document.cookie.split("; ").find(s=>s.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);if(n)try{return decodeURIComponent(n)}catch(s){return n}},qe=(e,n,r)=>{let s=window.location.protocol==="https:"?"; secure":"";document.cookie=`${e}=${encodeURIComponent(n)}; path=/; max-age=${r}; samesite=lax${s}`;},Fe=e=>{document.cookie=`${e}=; path=/; max-age=0; samesite=lax`;},A={utm:{}},Qt=()=>{var e;return (e=A.id)!=null?e:A.id=nt()},ct=(e,n)=>{if(e!=="cookies")return Qt();let r=Zt(ue);if(r)return A.id=r;let s=Qt();return qe(ue,s,at),s},lt=e=>{var l;let n=Date.now(),r=A.session,s=(l=e?Zt(Ce):void 0)!=null?l:r&&n-r.last<18e5?r.id:nt();return A.session={id:s,last:n},e&&qe(Ce,s,18e5/1e3),s},dt=()=>{var r;let e=window.location.href;if(A.url===e)return;A.referrer=(r=A.url)!=null?r:document.referrer||void 0,A.url=e;let n=$t(window.location.search);Object.keys(n).length&&(A.utm=n);},en=()=>{let e=navigator,n=window;return e.doNotTrack==="1"||n.doNotTrack==="1"||e.globalPrivacyControl===true};var Ye=window,Wn=()=>{var e,n;return (n=(e=document.currentScript)!=null?e:document.querySelector('script[data-key][src*="sdk"]'))!=null?n:document.querySelector("script[data-key][src*='mrrocket']")},tn=new Set,z=e=>{tn.has(e)||(tn.add(e),console.warn(`[MRRocket] ${e}`));},Vn=()=>{var bt,Ct,xt,Rt;let e=Wn(),n=o=>{var u;return (u=e==null?void 0:e.getAttribute(`data-${o}`))!=null?u:void 0},r=(o,u)=>{let f=n(o);return f===void 0?u:!["false","0","off","no"].includes(f.trim().toLowerCase())},s=(bt=e==null?void 0:e.src)!=null?bt:"",l="";try{l=s?new URL(s,window.location.href).origin:"";}catch(o){l="";}let c=((Ct=n("key"))!=null?Ct:"").trim(),p=((xt=n("api-host"))!=null?xt:l).trim().replace(/\/+$/,""),R=n("consent"),E=r("respect-dnt",false),h=r("heatmaps",true),S=r("errors",true),m=n("release"),w=n("attribution"),O=w==="always"||w==="off"?w:"consent",M=n("referral-param")||"ref",L={},N=(o,u)=>{var f;return (f=L[o])!=null?f:L[o]=new Promise((y,v)=>{var vt;let F=()=>Ye[u];if(F())return y(F());let X=(vt=n(`${o}-src`))!=null?vt:s?s.replace(/(\.min)?\.js(\?[^#]*)?(#.*)?$/,`-${o}$1.js?v=${Ne}`):"";if(!X)return v(new Error(o));let se=document.createElement("script");se.async=true,se.src=X,se.onload=()=>F()?y(F()):v(new Error(o)),se.onerror=()=>v(new Error(o)),document.head.appendChild(se);}).catch(y=>{throw L[o]=void 0,y})},J=n("theme"),Q={theme:J==="light"||J==="dark"?J:"auto",accent:n("accent")},K=new URLSearchParams(window.location.search),Z=At(K.get(Pt)),B=K.get(Mt)==="1";B&&Wt();let ae=K.get(Ee);if(ae!==null){K.delete(Ee);let o=K.toString();history.replaceState(history.state,"",`${window.location.pathname}${o?`?${o}`:""}${window.location.hash}`);}let Xe=en(),pe=R==="cookies"||R==="off"?R:"cookieless",ce=r("replay",false),ge="",H,q,P=null,ee=false,me=false,le=null,de=null,$=window.location.pathname,G=[],xe=new Set,Pe=[],U=()=>E&&Xe?"off":pe,j=()=>!B&&U()!=="off",W=()=>H!=null?H:ge,ne=()=>U()==="cookies"?W():H;c||z('No public key. Add data-key="mrr_pub_\u2026" to the script tag; nothing is tracked until then.');let we=(o=false)=>{if(!G.length)return;if(!c){G.length=0;return}let u=`${p}/api/sdk/events`;for(let f of _t(c,G.splice(0),{v:Ne,errors:S,platform:"web"}))o&&"sendBeacon"in navigator&&navigator.sendBeacon(u,f)||fetch(u,{method:"POST",headers:{"content-type":"application/json"},body:f,keepalive:true}).then(v=>{v.ok||z(`Events were rejected with ${v.status}. Check data-key (MRRocket \u203A Settings \u203A Products).`);}).catch(()=>z(`Could not reach ${p||"this origin"} to send events. Check data-api-host.`));},T=null,Y=null,t=(o,u,f=Date.now(),y)=>{if(!j())return;let v=Jt(o)?it():null;G.push({event:o,props:v?{...u,$referral:{code:v.code,clickId:v.clickId}}:u,distinctId:ne(),sessionId:lt(U()==="cookies"),ts:f,url:y!=null?y:window.location.href,referrer:A.referrer,...A.utm,screen:{w:window.screen.width,h:window.screen.height}});},i=(o,u)=>{typeof o!="string"||!o||(t(o,u),j()&&(T==null||T.event(o)),a.onEvent(o));},a=Ht(Bt({host:p,apiKey:c,track:t,personId:()=>j()?H:void 0,canStore:()=>U()==="cookies",auto:r("onboarding",true)})),g=false,d;a.subscribe(()=>{g||!a.view()||B||(g=true,N("flows","__mrrocketFlows").then(o=>o.mountFlows(a,Q)).catch(()=>{g=false,z("The cancel flow and onboarding dialogs did not load. Check that sdk-flows.js is served next to sdk.js.");}));});let C=(o,u)=>{if(!j())return;let f=`${window.location.pathname}|${o}`;xe.has(f)||(xe.add(f),i("$exposure",{experiment:o,variant:u}));},_=()=>{let o=Lt(P,window.location.href,W(),Z);return o!=null&&o.to?(we(true),window.location.replace(o.to),true):(o!=null&&o.experiment&&C(o.experiment,o.variant),false)},k=()=>{if(!P)return;let o=document.querySelectorAll("[data-ck-text]");if(!o.length)return;let u=Nt(P,W(),Z),f=new Set;o.forEach(y=>{var X,se;let v=y.dataset.ckText;if(!v)return;f.add(v),y.dataset.ckDefault===void 0&&(y.dataset.ckDefault=(X=y.textContent)!=null?X:"");let F=(se=u[v])!=null?se:y.dataset.ckDefault;y.textContent!==F&&(y.textContent=F);});for(let y of P.experiments)y.variants.some(v=>{var F;return Object.keys((F=v.changes)!=null?F:{}).some(X=>f.has(X))})&&C(y.key,_e(y.key,P,W(),Z));},b=()=>{var o,u;return (u=(o=P==null?void 0:P.referral)==null?void 0:o.cookieDays)!=null?u:60},x=()=>O==="always"?U()!=="off":O==="consent"&&U()==="cookies",I=null,V=false,he=()=>{if(!ee||B)return;if(O==="off"||U()==="off"){Xt(),(O==="off"||V)&&Be();return}let o=window.location.href;I!==o&&(I=o,zt({search:window.location.search,param:M,store:x(),days:b(),beacon:c?({code:u,clickId:f})=>fetch(`${p}/api/sdk/affiliate/click`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:c,code:u,clickId:f,url:o,referrer:document.referrer||void 0}),keepalive:true}).then(y=>y.ok?y.json():null).then(y=>{var v;return (v=y==null?void 0:y.clickId)!=null?v:null}):void 0}));},te=()=>{let o=x(),u=it();o&&u?je(u,b()):!o&&V&&Be(),V=o;},ut=0,ft=false,pt=()=>{var y,v;let o=j()&&ce&&!!(P!=null&&P.replay)&&!!c;if(o===ft)return;ft=o;let u=++ut;if(!o){T==null||T.stop(true),T=null;return}let f=(v=(y=P==null?void 0:P.replay)==null?void 0:y.sampleRate)!=null?v:.1;N("replay","__mrrocketReplay").then(F=>F.startReplay({host:p,apiKey:c,sessionId:lt(U()==="cookies"),distinctId:ne(),identified:!!H,sampleRate:f,warn:z})).then(F=>{u!==ut?F==null||F.stop(true):T=F;}).catch(()=>z("Session recording could not start (the recorder did not load)."));},gt=r("messenger",false),re=null,ke=o=>{B||c&&(re!=null||(re=N("messenger","__mrrocketMessenger").then(u=>{var F;let f=X=>n(`messenger-${X}`)===void 0?void 0:r(`messenger-${X}`,true),y=n("messenger-position"),v=(F=n("messenger-theme"))!=null?F:J;return u.mountMessenger({host:p,apiKey:c,distinctId:W,user:()=>q,launcher:gt,position:y,corners:n("messenger-corners"),header:n("messenger-header"),font:n("messenger-font"),title:n("messenger-title"),greeting:n("messenger-greeting"),label:n("messenger-label"),askEmail:f("ask-email"),help:f("help"),sound:f("sound"),preview:f("preview"),theme:v==="light"||v==="dark"||v==="auto"?v:void 0,accent:n("accent")})})),re.then(o).catch(()=>{re=null,z("sdk-messenger.js did not load.");}));},mt=n("forms")==="auto",ze=false,Je=()=>{ze||!c||B||!document.querySelector(mt?"form":"form[data-mrrocket-form]")||(ze=true,N("forms","__mrrocketForms").then(o=>o.watchForms({host:p,apiKey:c,auto:mt,distinctId:()=>j()?ne():void 0,identified:()=>!!H,identify:yt,tracking:j,referrer:()=>A.referrer,utm:()=>A.utm})).catch(()=>ze=false));},Ge=()=>{!me||!j()||de===window.location.pathname||(de=window.location.pathname,i("$pageview",{path:window.location.pathname}));},oe=null,wt=()=>{let o=oe;h&&o&&o.max>0&&t("$scroll",{depth:o.max,docH:o.docH,vw:window.innerWidth,vh:window.innerHeight},Date.now(),o.url),oe=null;},Re=()=>{var v,F;if(!h||!j()||B)return;let o=document.documentElement,u=Math.max(o.scrollHeight,(F=(v=document.body)==null?void 0:v.scrollHeight)!=null?F:0),f=It(),y=window.location.href;(oe==null?void 0:oe.url)!==y?oe={url:y,max:f,docH:u}:f>oe.max&&(oe={url:y,max:f,docH:u});},ht=()=>{let o=window.location.pathname;o!==$&&($=o,!(ee&&_())&&(wt(),dt(),T==null||T.page(o),Y==null||Y.crumb("navigation",o),Ge(),he(),window.setTimeout(()=>{Re(),k(),Je();},0)));},kt=()=>{let o=U(),u=le;le=o,u==="cookies"&&o!=="cookies"&&(Fe(ue),Fe(Ce)),o==="off"&&(G.length=0,A.session=void 0),u==="cookies"&&o!=="cookies"&&Vt(),ge=ct(o),te(),he(),pt(),Ge(),Re();},rn=o=>{let{analytics:u,replay:f}=typeof o=="string"?{analytics:o,replay:void 0}:o!=null?o:{};if(u!==void 0&&u!=="cookieless"&&u!=="cookies"&&u!=="off"){z(`setConsent: "${String(u)}" is not a consent mode. Use "cookieless", "cookies" or "off".`);return}u==="off"&&(G.length=0),u&&(pe=u),typeof f=="boolean"&&(ce=f),kt(),ee&&a.refresh();},yt=(o,u)=>{if(typeof o!="string"||!o)return;let f=ne();H=o,t("$identify",{...u,id:o,...f&&f!==o?{previousId:f}:{}}),T==null||T.identify(o),U()==="cookies"&&qe(ue,o,at),q={...u,id:o},k(),ee&&a.refresh();},Me={track:i,identify:yt,reset:()=>{H=void 0,q=void 0,xe.clear(),U()==="cookies"&&(Fe(ue),Fe(Ce)),A.id=void 0,A.session=void 0,ge=ct(U()),k(),ee&&a.refresh();},captureError:o=>Y==null?void 0:Y.capture(o,"manual"),setConsent:rn,getFlag:o=>tt(o,P,W(),{...q})!==false,getFlagVariant:o=>{let u=tt(o,P,W(),{...q});return typeof u=="string"?u:null},getVariant:o=>{let u=_e(o,P,W(),Z);return (P||Z[o])&&C(o,u),u},ready:o=>{typeof o=="function"&&(ee?window.setTimeout(()=>o(Me),0):Pe.push(o));},getDistinctId:W,cancelFlow:{open:o=>a.openCancelFlow(o)},onboarding:{start:o=>a.startOnboarding(o)},openCancelFlow:o=>a.openCancelFlow(o),startOnboarding:o=>a.startOnboarding(o),paywall:{open:(o,u)=>(d!=null?d:d=N("flows","__mrrocketFlows").then(f=>f.paywallHost({config:()=>P,distinctId:W,track:t},Q))).then(f=>f.open(o,u))},push:{subscribe:o=>{let u=j()?H:void 0;if(!u)return Promise.resolve({status:"not-signed-in"});let f=window.Notification,y=Promise.resolve(f&&f.permission==="default"&&(o==null?void 0:o.ask)!==false?f.requestPermission():f==null?void 0:f.permission);return N("push","__mrrocketPush").then(v=>v.subscribeWebPush({host:p,apiKey:c,distinctId:u,permission:y},o))},unsubscribe:()=>N("push","__mrrocketPush").then(o=>o.unsubscribeWebPush({host:p,apiKey:c,distinctId:H}))},messenger:{open:o=>ke(u=>u.open(o)),close:()=>{re==null?void 0:re.then(o=>o.close()).catch(()=>{});},toggle:()=>ke(o=>o.toggle())},openMessenger:()=>ke(o=>o.open()),version:Ne};dt(),kt();let ye=Ye.mrrocket,on=(Rt=ye==null?void 0:ye.q)!=null?Rt:[],Qe=ye&&typeof ye=="object"?ye:{};Object.assign(Qe,Me,{__loaded:true}),delete Qe.q,Ye.mrrocket=Qe;for(let[o,u]of on){let f=Me[o];if(typeof f=="function")try{f(...Array.from(u!=null?u:[]));}catch(y){console.error(y);}}me=true,Ge(),S&&c&&!B&&(Y=Ut({host:p,apiKey:c,release:m,context:()=>{var o;return {send:j(),distinctId:ne(),sessionId:(o=A.session)==null?void 0:o.id}},warn:z}),Y.crumb("navigation",window.location.pathname));for(let o of ["pushState","replaceState"]){let u=history[o];history[o]=function(...f){let y=u.apply(this,f);return ht(),y};}window.addEventListener("popstate",ht);let sn=new ve;document.addEventListener("click",o=>{var F;o.target instanceof Element&&o.target.closest("[data-ck-messenger]")&&(o.preventDefault(),ke(X=>X.open()));let u=o.target instanceof Element?o.target.closest("[data-ck-goal]"):null;if(u!=null&&u.dataset.ckGoal&&i(u.dataset.ckGoal,{text:(F=u.textContent)==null?void 0:F.trim().slice(0,80)}),!j())return;let f=Ot(o);if(!f)return;let y=sn.push(f.x,f.y,Date.now());if((f.label||f.selector)&&(Y==null||Y.crumb("click",f.label||f.selector)),T==null||T.click(f,y),!h)return;let v={x:f.x,y:f.y,vw:f.vw,vh:f.vh,docH:f.docH,selector:f.selector,label:f.label,dead:!f.interactive};t("$click",v),y&&t("$rageclick",v);});let Ze=0;window.addEventListener("scroll",()=>{Ze||(Ze=window.requestAnimationFrame(()=>{Ze=0,Re();}));},{passive:true}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Re()):Re(),window.setInterval(()=>we(),2e3),window.addEventListener("pagehide",()=>{wt(),we(true);});let et=()=>{if(ee=true,_())return;let o=Tt(P,ae);o&&C(o.experiment,o.variant),document.documentElement.classList.remove("ck-hide"),he(),pt(),a.setConfig(P),a.refresh(),gt&&(document.body?ke():document.addEventListener("DOMContentLoaded",()=>ke())),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{k(),Je();}):(k(),Je());for(let u of Pe.splice(0))try{u(Me);}catch(f){console.error(f);}};c?fetch(`${p}/api/sdk/config?key=${encodeURIComponent(c)}`).then(o=>(o.ok||z(`Config request to ${p||"this origin"} answered ${o.status}. Check data-key and data-api-host.`),o.ok?o.json():null)).then(o=>{o&&Array.isArray(o.experiments)&&(P=o),et();}).catch(()=>{z(`Could not reach ${p||"this origin"}. Check data-api-host. The page keeps its own texts and flags stay off.`),et();}):et();},nn;typeof window!="undefined"&&typeof document!="undefined"&&!((nn=Ye.mrrocket)!=null&&nn.__loaded)&&Vn();
1
+ (function(){'use strict';var pn=Object.defineProperty;var gn=(e,n,r)=>n in e?pn(e,n,{enumerable:true,configurable:true,writable:true,value:r}):e[n]=r;var ye=(e,n,r)=>gn(e,typeof n!="symbol"?n+"":n,r);var St=e=>{let n=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);s<128?n+=1:s<2048?n+=2:s>=55296&&s<=56319&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(n+=4,r++):n+=3;}return n},mn=(e,n,r,s)=>{let a=`{"key":${JSON.stringify(e)},${s?`"userHash":${JSON.stringify(s)},`:""}"sdk":${JSON.stringify(r)},"events":[`,c=St(a)+2,p=[],R=[],S=[],h=c,O=()=>{R.length&&p.push({body:`${a}${R.join(",")}]}`,events:S}),R=[],S=[],h=c;};for(let m of n){let k=JSON.stringify(m),E=St(k)+1;c+E>6e4||((R.length===100||h+E>6e4)&&O(),R.push(k),S.push(m),h+=E);}return O(),p},Ot=(e,n,r,s)=>mn(e,n,r,s).map(a=>a.body);var _e=class{constructor(n=1e3,r=30,s=3){ye(this,"windowMs",n);ye(this,"radius",r);ye(this,"count",s);ye(this,"clicks",[]);ye(this,"fired",false);}push(n,r,s){let a=this.clicks.filter(c=>s-c.t<=this.windowMs&&Math.hypot(c.x-n,c.y-r)<=this.radius);return a.length!==this.clicks.length&&(this.fired=false),this.clicks=[...a,{x:n,y:r,t:s}],this.clicks.length>=this.count&&!this.fired?(this.fired=true,true):false}};var wn='a[href],button,input,select,textarea,label,summary,[role="button"],[role="link"],[role="tab"],[role="menuitem"],[role="checkbox"],[role="switch"],[onclick],[data-ck-goal]',hn="[data-ck-mask]",kn="[data-ck-block]",It=/\d{4,}|^[a-z]{1,3}-[a-z0-9]{5,}$|^_|__|css-|^sc-|^jsx-/i,yn=e=>{let n=e.tagName.toLowerCase();if(e.id&&!It.test(e.id)&&e.id.length<=40)return `${n}#${e.id}`;let r=typeof e.className=="string"?e.className.split(/\s+/).filter(c=>c&&!It.test(c)&&c.length<=30&&!c.includes(":")):[],s=r.length?`${n}.${r.slice(0,2).join(".")}`:n,a=e.parentElement?[...e.parentElement.children].filter(c=>c.tagName===e.tagName):[];return a.length>1?`${s}:nth-of-type(${a.indexOf(e)+1})`:s},bn=e=>{let n=[],r=e;for(;r&&n.length<3&&r.tagName&&r.tagName!=="BODY"&&r.tagName!=="HTML";){let s=yn(r);if(n.unshift(s),s.includes("#"))break;r=r.parentElement;}return n.join(" > ").slice(0,160)},Ae=e=>(e!=null?e:"").replace(/\s+/g," ").trim().slice(0,40),xn=e=>{var r,s,a,c,p;if(e.closest(`${hn},${kn}`))return "";let n=e.tagName.toLowerCase();if(n==="input"){let R=((r=e.getAttribute("type"))!=null?r:"text").toLowerCase();return Ae(R==="submit"||R==="button"?(s=e.getAttribute("aria-label"))!=null?s:e.value:e.getAttribute("aria-label"))}return Ae(n==="select"||n==="textarea"?e.getAttribute("aria-label"):(p=(c=(a=e.getAttribute("aria-label"))!=null?a:e.getAttribute("title"))!=null?c:e.innerText)!=null?p:e.textContent)},Ft=e=>{var c,p;let n=e.target instanceof Element?e.target:null;if(!n)return null;let r=n.closest(wn),s=r!=null?r:n,a=document.documentElement;return {x:Math.round(e.clientX),y:Math.round(e.clientY+window.scrollY),vw:window.innerWidth,vh:window.innerHeight,docH:Math.max(a.scrollHeight,(p=(c=document.body)==null?void 0:c.scrollHeight)!=null?p:0),selector:bn(s),label:r?xn(r):"",interactive:!!r}},$t=()=>{var r,s;let e=document.documentElement,n=Math.max(e.scrollHeight,(s=(r=document.body)==null?void 0:r.scrollHeight)!=null?s:0);return n?Math.min(100,Math.round((window.scrollY+window.innerHeight)/n*100)):0};var Le="0.16.0",Cn=(e,n)=>{let r=n.trim().toLowerCase();for(let[s,a]of Object.entries(e))if(s.toLowerCase()===r)return a},Rn=(e,n)=>{let r=e.trim().toLowerCase(),s=n.trim().toLowerCase();return s.startsWith("@")?r.endsWith(s):r===s},vn=(e,n)=>{if(e.op==="in cohort")return false;let r=Cn(n,e.property),s=r==null?"":String(r);if(e.op==="\u2265"){let c=Number(s),p=Number(e.values[0]);return s!==""&&Number.isFinite(c)&&Number.isFinite(p)&&c>=p}let a=s!==""&&e.values.some(c=>Rn(s,c));return e.op==="is"||e.op==="in"?a:!a},En=(e,n,r={})=>{var R;if(!e.on)return false;let s={id:n,...r},a=e.sets.length?e.sets.find(S=>S.conditions.every(h=>vn(h,s))):{rollout:100};if(!a||Pt(`${e.key}:rollout:${n}`)*100>=a.rollout)return false;if(!((R=e.variants)!=null&&R.length))return true;let c=Pt(`${e.key}:variant:${n}`)*100,p=0;for(let S of e.variants)if(p+=S.split,c<p)return S.key;return e.variants[e.variants.length-1].key},rt=(e,n,r,s={})=>{var c;let a=(c=n==null?void 0:n.flags)==null?void 0:c.find(p=>p.key===e);return a?En(a,r,s):false},_n=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],Mt="ck_preview",At="ck_embed",ue="ck_id",be="ck_sid";var Sn=e=>{var r;let n={};for(let s of _n){let a=(r=e(s))==null?void 0:r.trim();a&&(n[s]=a.slice(0,150));}return n},Nt=e=>{let n=new URLSearchParams(e);return Sn(r=>n.get(r))};var On=e=>{let n=2166136261;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return (n>>>0)/4294967296},Pt=e=>{let n=2166136261;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return n^=n>>>16,n=Math.imul(n,2246822507),n^=n>>>13,n=Math.imul(n,3266489909),n^=n>>>16,(n>>>0)/4294967296},In=(e,n)=>{var c,p,R,S;let r=(p=(c=e.variants[0])==null?void 0:c.id)!=null?p:"control";if(e.winner)return e.winner;if(e.status!=="running")return r;let s=On(`${e.key}:${n}`),a=0;for(let h of e.variants)if(a+=h.weight,s<a)return h.id;return (S=(R=e.variants[e.variants.length-1])==null?void 0:R.id)!=null?S:r},Lt=e=>{let n=Array.isArray(e)?e[0]:e;if(!n)return {};let r={};for(let s of n.split(",")){let[a,c]=s.split(":");a&&c&&(r[a.trim()]=c.trim());}return r};var Oe=(e,n,r,s)=>{if(s[e])return s[e];let a=n==null?void 0:n.experiments.find(c=>c.key===e);return a?In(a,r):"control"},Tt=(e,n,r)=>{var a,c,p,R,S,h;let s={...(a=e==null?void 0:e.texts)!=null?a:{}};for(let O of (c=e==null?void 0:e.experiments)!=null?c:[]){let m=Oe(O.key,e,n,r);m!==((R=(p=O.variants[0])==null?void 0:p.id)!=null?R:"control")&&Object.assign(s,(h=(S=O.variants.find(k=>k.id===m))==null?void 0:S.changes)!=null?h:{});}return s},Se="ck_x",Ne=e=>e.replace(/\/+$/,"")||"/",Ut=(e,n,r,s={})=>{var R,S;if(!e)return null;let a;try{a=new URL(n);}catch(h){return null}if(a.searchParams.has(Se))return null;let c=Ne(a.pathname),p=(h,O)=>{let m;try{m=new URL(h,a);}catch(k){return}if(!(!/^https?:$/.test(m.protocol)||m.origin===a.origin&&Ne(m.pathname)===c))return a.searchParams.forEach((k,E)=>{m.searchParams.has(E)||m.searchParams.set(E,k);}),O&&m.searchParams.set(Se,O),m.hash||(m.hash=a.hash),m.href};for(let h of (R=e.redirects)!=null?R:[]){let O=h.from&&Ne(h.from)===c?p(h.to):void 0;if(O)return {to:O}}for(let h of e.experiments){if(!h.path||Ne(h.path)!==c)continue;let O=h.status==="running"&&!h.winner;if(O&&r===null&&!s[h.key])return null;let m=Oe(h.key,e,r!=null?r:"",s),k=(S=h.variants.find(I=>I.id===m))==null?void 0:S.url,E=k?p(k,O?`${h.key}:${m}`:void 0):void 0;return O?{to:E,experiment:h.key,variant:m}:E?{to:E}:null}return null},Ht=(e,n)=>{let[r,s]=(n!=null?n:"").split(":"),a=e==null?void 0:e.experiments.find(c=>c.key===r);return a&&a.variants.some(c=>c.id===s)?{experiment:r,variant:s}:null};var ot=()=>typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():`ck_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;var Fn="401: sign the user id on your server with userHash(id) from @mrrocket/sdk/next/server and pass identify(id, props, { hash }).",xe=(e,n=r=>console.warn(r))=>{let r=globalThis;e!==401||r.__mrrocketUnsigned||(r.__mrrocketUnsigned=true,n(`[MRRocket] ${Fn}`));},Dt=(e,n,r,s=a=>console.warn(a))=>{let a=typeof r=="string"?r.trim().toLowerCase():"";return /^[0-9a-f]{64}$/.test(a)?{id:n,hash:a}:(a&&s("[MRRocket] identify: that hash is no userHash(id); not sent."),e&&e.id===n?e:null)},jt=(e,n)=>e&&n&&e.id===n?e.hash:void 0,Wt=(e,n)=>e&&n.some(r=>r===e.id)&&n.every(r=>!r||r===e.id)?e.hash:void 0;var $n=8*1024,Pn=20,Mn=20,An=2e3,Ie=(e,n)=>e.length>n?`${e.slice(0,n-1)}\u2026`:e,Nn=e=>{var n;if(e instanceof Error)return {type:e.name||"Error",message:Ie(e.message||String(e),1e3),stack:e.stack?Ie(e.stack,$n):void 0};if(typeof e=="string")return {type:"Error",message:Ie(e,1e3)};try{return {type:"Error",message:Ie((n=JSON.stringify(e))!=null?n:String(e),1e3)}}catch(r){return {type:"Error",message:String(e)}}},Kt=e=>{let n=[],r=[],s=new Set,a=0,c=`${e.host}/api/sdk/errors`,p=(k=false)=>{for(;n.length;){let E=n.splice(0,4),I=e.context(),T=I.distinctId&&I.userHash?{id:I.distinctId,hash:I.userHash}:null,M=Wt(T,E.map(N=>N.distinctId)),K=JSON.stringify({key:e.apiKey,...M?{userHash:M}:{},errors:E});k&&typeof navigator!="undefined"&&"sendBeacon"in navigator&&navigator.sendBeacon(c,K)||fetch(c,{method:"POST",headers:{"content-type":"application/json"},body:K,keepalive:true}).then(N=>{N.status===401?xe(401):!N.ok&&N.status!==429&&e.warn(`Error reports were rejected with ${N.status}. Check the public key and NEXT_PUBLIC_MRROCKET_HOST.`);}).catch(()=>{});}},R=(k,E="manual")=>{let I=e.context();if(!I.send||a>=Pn)return;let T=Nn(k);if(/\/api\/sdk\/errors/.test(T.message))return;let M=`${T.type}:${T.message}`;s.has(M)||(s.add(M),a++,n.push({...T,mechanism:E,handled:E==="manual",url:window.location.href,ts:Date.now(),crumbs:r.slice(),...e.release?{release:e.release}:{},...I.distinctId?{distinctId:I.distinctId}:{},...I.sessionId?{sessionId:I.sessionId}:{}}));},S=k=>{var E;!k.error&&(!k.message||k.message==="Script error.")||R((E=k.error)!=null?E:new Error(k.message),"onerror");},h=k=>{var E;return R((E=k.reason)!=null?E:new Error("Unhandled promise rejection"),"onunhandledrejection")},O=()=>p(true);window.addEventListener("error",S),window.addEventListener("unhandledrejection",h),window.addEventListener("pagehide",O);let m=window.setInterval(()=>p(),An);return {capture:R,crumb:(k,E)=>{r.push({ts:Date.now(),type:k,message:Ie(E,120)}),r.length>Mn&&r.shift();},stop:()=>{window.removeEventListener("error",S),window.removeEventListener("unhandledrejection",h),window.removeEventListener("pagehide",O),window.clearInterval(m),p(true);}}};var Fe="$cancel_flow",ie="$onboarding",st="$inapp";var Ln={version:0,question:"",reasons:[],offers:{},confirm:{title:"Cancel your subscription?",body:"You keep access until the end of the billing period.",button:"Cancel subscription"},offersFor:"business"},Tn="Something went wrong. Please try again.",Vt="mrrocket:onboarding",Ue=e=>e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),Bt=new Set(["signed_up","signup","sign_up","registered","account_created","user_signed_up"]),it=(e,n)=>{let r=Ue(e),s=Ue(n);return !r||!s?false:r===s||Bt.has(r)&&Bt.has(s)},Un=e=>/^(first (launch|visit|open|session|login|sign ?in|app open)|app (opened|launched)|on load|every visit|always)?$/i.test(e.trim()),Hn=()=>`cf_${Math.random().toString(36).slice(2,10)}${Date.now().toString(36)}`;var Dn=e=>{let n=(e!=null?e:"").trim();return /^https?:\/\//i.test(n)||/^\/(?!\/)/.test(n)?n:void 0},fe=e=>{var n;return (n=e.nodes)!=null?n:e.steps},jn=e=>Math.max(0,e.amount)*(e.unit==="hours"?36e5:864e5),Wn=(e,n)=>{let r=e.trim(),s=(n.split(/[?#]/)[0]||"/").replace(/\/+$/,"")||"/";if(!r)return false;if(r.endsWith("*")){let a=r.slice(0,-1).replace(/\/+$/,"");return !a||s===a||s.startsWith(`${a}/`)}return s===(r.replace(/\/+$/,"")||"/")},at=e=>e.flatMap(n=>n.kind==="condition"?[...at(n.yes),...at(n.no)]:n.kind==="wait"?[]:[n]),Kn=(e,n=Date.now())=>e==null||e===""?NaN:Math.floor((n-new Date(e).getTime())/2630016e3),Te=e=>e==null?void 0:e.trim().toLowerCase(),Vn=({when:e={}},n)=>(e.answer==null||Te(e.answer)===Te(n.answer))&&(e.plan==null||[e.plan].flat().some(r=>Te(r)===Te(n.plan)))&&!(n.months>=e.tenureUnder)&&!(n.months<e.tenureOver)&&(e.tenureUnder==null||n.months>=0)&&(e.tenureOver==null||n.months>=0),qt=e=>{let n=null,r=null,s=null,a=[],c=false,p=null,R,S=null,h=new Map,O=new Set,m=new Set,k=new Set,E=e.auto!==false,I=new Set,T=()=>{var t,i;return (i=(t=e.now)==null?void 0:t.call(e))!=null?i:Date.now()},M=null,K=()=>{var t;return (t=n==null?void 0:n.onboarding)!=null?t:[]},Q=t=>t?K().find(i=>i.id===t):void 0,N=t=>{let i=h.get(t);return i||h.set(t,i={done:new Set,dismissed:false,answers:new Map,at:new Map,reached:new Map}),i},ee=false,V=t=>{e.track(ie,t),ee=true;},ae=(t,i)=>{t.done.add(i),t.at.set(i,T());},ze=t=>{var i,l,g;if((i=t.page)!=null&&i.trim()){let d=(l=e.path)==null?void 0:l.call(e);return d===void 0?false:Wn(t.page,d)}if((g=t.event)!=null&&g.trim()){if(!c)return;for(let d of I)if(it(t.event,d))return true;return false}return false},pe=(t,i,l,g,d=0,C)=>{var _,y;for(let b=0;b<i.length;b++){let x=i[b];if(x.kind==="wait"){if(l.done.has(x.id)){C=(_=l.at.get(x.id))!=null?_:C;continue}let F=l.reached.get(x.id);if(F===void 0){if(!g)return {at:"pending"};F=C!=null?C:T(),l.reached.set(x.id,F),V({flow:t.id,step:x.id,kind:"wait",action:"shown"});}let B=F+jn(x);if(T()<B)return {at:"wait",until:B};if(!g)return {at:"pending"};ae(l,x.id),V({flow:t.id,step:x.id,kind:"wait",action:"completed"}),C=B;continue}if(x.kind==="condition"){let F=l.answers.get(x.id);if(F===void 0){if(!g)return {at:"pending"};if(F=ze(x),F===void 0)return {at:"pending"};l.answers.set(x.id,F),V({flow:t.id,step:x.id,kind:"condition",action:"answered",answer:F?"yes":"no"});}return pe(t,F?x.yes:x.no,l,g,d,C)}if(!l.done.has(x.id))return {at:"step",step:x,line:i,index:b,before:d};C=(y=l.at.get(x.id))!=null?y:C,d++;}return {at:"end"}},ce=t=>{let i=h.get(t.id);return !!i&&(i.dismissed||pe(t,fe(t),i,false).at==="end")},ge=t=>`${Vt}:${t!=null?t:"visitor"}`,H=t=>`${Vt}:events:${t!=null?t:"visitor"}`,Y=()=>{var l;ee=false;let t=(l=e.storage)==null?void 0:l.call(e);if(!t)return;let i={};for(let[g,d]of h)i[g]={done:[...d.done],...d.dismissed?{dismissed:true}:{},...d.answers.size?{answers:Object.fromEntries([...d.answers].map(([C,_])=>[C,_?"yes":"no"]))}:{},...d.at.size?{at:Object.fromEntries(d.at)}:{},...d.reached.size?{reached:Object.fromEntries(d.reached)}:{}};try{t.set(ge(e.personId()),JSON.stringify(i)),I.size&&t.set(H(e.personId()),JSON.stringify([...I].slice(-200)));}catch(g){}},te=t=>{var i,l,g,d;for(let[C,_]of Object.entries(t!=null?t:{})){let y=N(C);for(let b of (i=_.done)!=null?i:[])y.done.add(b);_.dismissed&&(y.dismissed=true);for(let[b,x]of Object.entries((l=_.answers)!=null?l:{}))y.answers.has(b)||y.answers.set(b,x==="yes");for(let[b,x]of Object.entries((g=_.at)!=null?g:{}))typeof x=="number"&&!y.at.has(b)&&y.at.set(b,x);for(let[b,x]of Object.entries((d=_.reached)!=null?d:{}))typeof x=="number"&&(!y.reached.has(b)||x<y.reached.get(b))&&y.reached.set(b,x);}},P=t=>{var l;M&&clearTimeout(M),M=null;let i=t-T();i>0&&i<=864e5&&(M=setTimeout(()=>(M=null,A()),i+50),(l=M.unref)==null||l.call(M));},X=false,le=()=>{X=false;let t=Q(s);if(!t)return null;let i=N(t.id);if(i.dismissed)return null;let l=pe(t,fe(t),i,true);if(ee&&Y(),l.at==="wait"&&P(l.until),X=l.at==="wait"||l.at==="pending",l.at!=="step")return null;let{step:g,line:d,index:C}=l,_=F=>!!F&&F.kind!=="wait"&&F.kind!=="condition";if(g.kind==="checklist"){let F=C;for(;F>0&&_(d[F-1])&&d[F-1].kind==="checklist";)F--;let B=C;for(;B+1<d.length&&_(d[B+1])&&d[B+1].kind==="checklist";)B++;let ve=d.slice(F,B+1).filter(_);for(let J of ve)!i.done.has(J.id)&&!m.has(`s:${J.id}`)&&(m.add(`s:${J.id}`),e.track(ie,{flow:t.id,step:J.id,kind:"checklist",action:"shown"}));return {type:"checklist",flow:t,items:ve.map(J=>({step:J,done:i.done.has(J.id)}))}}m.has(`s:${g.id}`)||(m.add(`s:${g.id}`),e.track(ie,{flow:t.id,step:g.id,kind:g.kind,action:"shown"}));let y=d.slice(C+1),b=y.findIndex(F=>F.kind==="condition"),x=(b<0?y:y.slice(0,b)).filter(_).length;return {type:"step",flow:t,step:g,index:l.before,total:l.before+1+x,last:!x&&b<0}},de=()=>{var l,g;if(r){let d=r,C=(l=d.flow.followUps)==null?void 0:l[d.reason],_=C?1:0,y=d.plain?1:3+_+((g=d.flow.second)!=null&&g[d.reason]?1:0);return {type:"cancel",screen:d.screen,flow:d.flow,reason:d.reason,...d.screen==="followup"&&C?{followUp:C,answer:d.answer}:{},offer:d.screen==="offer"?d.offer:void 0,...d.screen==="offer"?{round:d.round}:{},price:d.options.price,busy:d.busy,error:d.error,step:d.screen==="survey"?1:d.screen==="followup"?2:d.screen==="offer"?1+_+d.round:y,steps:y}}let t=le();if(t)return t;s&&!X&&(s=null);let i=a.find(d=>!O.has(d.id));return i?{type:"message",message:i}:null},A=()=>{let t=de();(t==null?void 0:t.type)==="message"&&!m.has(`m:${t.message.id}`)&&(m.add(`m:${t.message.id}`),e.track(st,{message:t.message.id,journey:t.message.journey,action:"shown"}));for(let i of [...k])try{i();}catch(l){}},me=t=>s===t.id?true:s&&Q(s)&&!ce(Q(s))?false:(s=t.id,e.track(ie,{flow:t.id,action:"started"}),A(),true),ne=()=>{var i;if(!E||s||!c||!e.personId()&&!((i=e.storage)!=null&&i.call(e)))return;let t=K().find(l=>Un(l.trigger)&&fe(l).length&&!ce(l));t&&me(t);},Ce=()=>{let t=e.personId();S!==null&&S!==t&&(h.clear(),I.clear(),O.clear(),s=null,R=void 0),S=t;let i=(async()=>{var d,C,_;let l=(d=e.storage)==null?void 0:d.call(e);if(l)try{let y=await l.get(ge(t));y&&te(JSON.parse(y));let b=await l.get(H(t));if(b)for(let x of JSON.parse(b))typeof x=="string"&&I.add(x);}catch(y){}let g=K().length>0||!!(n!=null&&n.messages);if(t&&g&&R!==t){R=t;let y=await e.fetchInApp(t).catch(()=>null);if(y&&e.personId()===t){te(y.onboarding);for(let b of (C=y.events)!=null?C:[])typeof b=="string"&&I.add(Ue(b));a=((_=y.messages)!=null?_:[]).filter(b=>b&&b.id&&b.title);}}t||(a=[]),c=true,ne(),A();})();return p=i.finally(()=>{p===i&&(p=null);}),p},we=t=>t.round>1?{round:2}:t.rule>=0?{rule:t.rule}:{},D=t=>{var g,d,C,_;let i={answer:t.answer,plan:t.options.plan,months:Kn(t.options.customerSince,(g=e.now)==null?void 0:g.call(e))},l=(C=(d=t.flow.rules)==null?void 0:d[t.reason])!=null?C:[];t.rule=l.findIndex(y=>Vn(y,i)),t.offer=t.rule<0?t.flow.offers[t.reason]:(_=l[t.rule].offer)!=null?_:void 0,t.round=1,t.screen=t.offer?"offer":"confirm";},j=(t,i,l)=>{var d;let g=t.screen==="offer"?t.offer:void 0;return {outcome:i,run:t.run,...t.reason?{reason:t.reason,reasonLabel:(d=t.flow.reasons.find(C=>C.id===t.reason))==null?void 0:d.label}:{},...t.answer?{answer:t.answer}:{},...i==="saved"&&g?{offer:g}:{},...l!=null&&l.trim()?{comment:l.trim().slice(0,500)}:{}}},W=(t,i)=>{var l;e.track(Fe,{action:"finished",run:t.run,version:t.flow.version,outcome:i.outcome,customer:(l=t.options.customer)!=null?l:"consumer",...i.reason?{reason:i.reason}:{},...i.answer?{answer:i.answer}:{},...i.offer?{offer:i.offer.kind,...we(t)}:{},...i.comment?{comment:i.comment}:{}}),r===t&&(r=null),t.resolve(i),A();},z=(t,i,l)=>{if(t.busy)return;let g=j(t,i,l),d=i==="saved"?t.options.onSave:t.options.onCancel;t.busy=true,t.error=void 0,A(),Promise.resolve().then(()=>d==null?void 0:d(g)).then(()=>W(t,g),()=>{t.busy=false,t.error=Tn,A();});};return {setConfig:t=>{n=t,s&&!Q(s)&&(s=null),A();},refresh:Ce,onEvent:t=>{var _;if(!t||t.startsWith("$"))return;let i=Ue(t),l=!!i&&!I.has(i);l&&I.add(i);let g=Q(s),d=false;if(g){let y=N(g.id);for(let b of at(fe(g)))b.kind==="checklist"&&b.event&&!y.done.has(b.id)&&it(b.event,t)&&(ae(y,b.id),d=true,e.track(ie,{flow:g.id,step:b.id,kind:b.kind,action:"completed"}));}if(d||l&&g?(Y(),A()):l&&Y(),!E||!e.personId()&&!((_=e.storage)!=null&&_.call(e)))return;let C=K().find(y=>fe(y).length&&it(y.trigger,t)&&!ce(y));C&&me(C);},openCancelFlow:(t={})=>{var _,y;if(r)return r.promise;let i=(_=n==null?void 0:n.cancelFlow)!=null?_:Ln,l=t.customer!=="business"||i.reasons.length<2,g=()=>{},d=new Promise(b=>g=b),C={flow:i,options:t,plain:l,screen:l?"confirm":"survey",round:1,run:Hn(),busy:false,resolve:g,promise:d};return r=C,e.track(Fe,{action:"shown",run:C.run,version:i.version,customer:(y=t.customer)!=null?y:"consumer",plain:l}),A(),d},startOnboarding:t=>{let i=t?Q(t):K().find(g=>fe(g).length&&!ce(g));if(!i||!fe(i).length)return false;let l=N(i.id);return l.dismissed=false,me(i)},view:de,subscribe:t=>(k.add(t),()=>k.delete(t)),cancel:{pick:t=>{!r||r.busy||r.screen!=="survey"||!r.flow.reasons.some(i=>i.id===t)||(r.reason!==t&&(r.answer=void 0),r.reason=t,r.error=void 0,A());},answer:t=>{let i=r;if(!i||i.busy||i.screen!=="followup")return;let l=t.slice(0,500);i.answer=l.trim()?l:void 0,A();},next:()=>{var i,l;let t=r;if(!(!t||!t.reason)){if(t.screen==="survey")e.track(Fe,{action:"answered",run:t.run,version:t.flow.version,reason:t.reason}),(i=t.flow.followUps)!=null&&i[t.reason]?t.screen="followup":D(t);else if(t.screen==="followup")t.answer=(l=t.answer)==null?void 0:l.trim(),D(t);else return;A();}},accept:t=>{var l;let i=r;!i||i.screen!=="offer"||!i.reason||(i.busy||e.track(Fe,{action:"offer",run:i.run,version:i.flow.version,reason:i.reason,offer:(l=i.offer)==null?void 0:l.kind,...we(i),outcome:"accepted"}),z(i,"saved",t));},decline:()=>{var l,g;let t=r;if(!t||t.screen!=="offer"||t.busy)return;e.track(Fe,{action:"offer",run:t.run,version:t.flow.version,reason:t.reason,offer:(l=t.offer)==null?void 0:l.kind,...we(t),outcome:"declined"});let i=t.round===1&&t.reason?(g=t.flow.second)==null?void 0:g[t.reason]:void 0;i?(t.offer=i,t.rule=void 0,t.round=2):t.screen="confirm",t.error=void 0,A();},confirm:t=>{let i=r;!i||i.screen!=="confirm"||z(i,"cancelled",t);},close:()=>{var l,g;let t=r;if(!t||t.busy)return;let i=j(t,"kept");(g=(l=t.options).onClose)==null||g.call(l,i),W(t,i);}},onboarding:{next:()=>{let t=le();(t==null?void 0:t.type)==="step"&&(ae(N(t.flow.id),t.step.id),e.track(ie,{flow:t.flow.id,step:t.step.id,kind:t.step.kind,action:"completed"}),Y(),A());},check:t=>{let i=le();if((i==null?void 0:i.type)!=="checklist")return;let l=i.items.find(g=>g.step.id===t);!l||l.done||(ae(N(i.flow.id),t),e.track(ie,{flow:i.flow.id,step:t,kind:"checklist",action:"completed"}),Y(),A());},dismiss:()=>{let t=le();!t||t.type!=="step"&&t.type!=="checklist"||(N(t.flow.id).dismissed=true,e.track(ie,{flow:t.flow.id,...t.type==="step"?{step:t.step.id}:{},action:"dismissed"}),s=null,Y(),A());}},message:{click:()=>{var l;let t=de();if((t==null?void 0:t.type)!=="message")return;O.add(t.message.id),e.track(st,{message:t.message.id,journey:t.message.journey,action:"clicked"});let i=Dn(t.message.url);A(),i&&((l=e.openUrl)==null||l.call(e,i));},dismiss:()=>{let t=de();(t==null?void 0:t.type)==="message"&&(O.add(t.message.id),e.track(st,{message:t.message.id,journey:t.message.journey,action:"dismissed"}),A());}}}};var Bn="ck_pick",qn="ck_origin",He=e=>typeof CSS!="undefined"&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>`\\${n}`),Yn=e=>[...e.classList].filter(n=>n.length<30&&!/\d{2,}|[_-][a-z0-9]{5,}$|^(is|has)-|hover|active|focus|open|selected|:|\[/.test(n)).slice(0,2),Yt=e=>{let n=e.ownerDocument,r=p=>{try{return n.querySelectorAll(p).length===1}catch(R){return false}},s=e.getAttribute("data-ck-target");if(s)return `[data-ck-target="${s.replace(/"/g,'\\"')}"]`;if(e.id&&!/\d{3,}/.test(e.id)&&r(`#${He(e.id)}`))return `#${He(e.id)}`;let a=[],c=e;for(;c&&c!==n.documentElement&&a.length<6;){if(c!==e&&c.id&&!/\d{3,}/.test(c.id)){a.unshift(`#${He(c.id)}`);break}let p=c.tagName.toLowerCase(),R=Yn(c).map(k=>`.${He(k)}`).join(""),S=c.parentElement,h=S?[...S.children].filter(k=>k.tagName===c.tagName):[],O=h.length>1?`:nth-of-type(${h.indexOf(c)+1})`:"";a.unshift(`${p}${R}${O}`);let m=a.join(" > ");if(r(m))return m;c=S;}return a.join(" > ")},Xt=()=>{var O;if(typeof window=="undefined"||window.top===window)return null;let e=new URLSearchParams(window.location.search);if(e.get(Bn)!=="1")return null;let n;try{n=new URL((O=e.get(qn))!=null?O:"").origin;}catch(m){return null}if(!/^https?:\/\//.test(n))return null;let r=m=>window.parent.postMessage(m,n),s=document.createElement("div");s.setAttribute("aria-hidden","true"),Object.assign(s.style,{position:"fixed",zIndex:"2147483647",pointerEvents:"none",border:"2px solid #0ea5e9",background:"rgba(14,165,233,.12)",borderRadius:"6px",transition:"all 60ms linear",display:"none"});let a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:"-2px",bottom:"calc(100% + 4px)",font:"600 11px/1.4 system-ui, sans-serif",color:"#fff",background:"#0c4a6e",padding:"2px 6px",borderRadius:"4px",whiteSpace:"nowrap",maxWidth:"360px",overflow:"hidden",textOverflow:"ellipsis"}),s.appendChild(a),document.body.appendChild(s);let c=null,p=m=>{if(c=m&&m!==s&&!s.contains(m)?m:null,!c){s.style.display="none";return}let k=c.getBoundingClientRect();Object.assign(s.style,{display:"block",left:`${k.left-2}px`,top:`${k.top-2}px`,width:`${k.width+4}px`,height:`${k.height+4}px`}),a.textContent=Yt(c);},R=m=>p(document.elementFromPoint(m.clientX,m.clientY)),S=m=>{var E,I;m.preventDefault(),m.stopPropagation();let k=(E=document.elementFromPoint(m.clientX,m.clientY))!=null?E:c;!k||k===s||r({type:"mrrocket:picked",selector:Yt(k),text:((I=k.textContent)!=null?I:"").trim().replace(/\s+/g," ").slice(0,80)});},h=m=>{m.key==="Escape"&&r({type:"mrrocket:pick-cancel"});};return window.addEventListener("mousemove",R,true),window.addEventListener("click",S,true),window.addEventListener("keydown",h,true),r({type:"mrrocket:pick-ready"}),()=>{window.removeEventListener("mousemove",R,true),window.removeEventListener("click",S,true),window.removeEventListener("keydown",h,true),s.remove();}};var Xn={get:e=>{try{return window.localStorage.getItem(e)}catch(n){return null}},set:(e,n)=>{try{window.localStorage.setItem(e,n);}catch(r){}}},zt=()=>{try{for(let e=window.localStorage.length-1;e>=0;e--){let n=window.localStorage.key(e);n!=null&&n.startsWith("mrrocket:onboarding")&&window.localStorage.removeItem(n);}}catch(e){}},Jt=e=>({track:e.track,personId:e.personId,auto:e.auto,storage:()=>e.canStore()?Xn:null,openUrl:n=>window.location.assign(n),path:()=>window.location.pathname,fetchInApp:async n=>{var a;if(!e.apiKey)return null;let r=(a=e.userHash)==null?void 0:a.call(e,n),s=await fetch(`${e.host}/api/sdk/inapp?key=${encodeURIComponent(e.apiKey)}&distinctId=${encodeURIComponent(n)}${r?`&userHash=${r}`:""}`);return xe(s.status),s.ok?await s.json():null}});var We="mrr_ref",Ke="mrr_ref",zn="mrr_ref",Jn="mrr_click";var $e=/^[A-Za-z0-9_-]{1,64}$/;var Gn=(e,n="ref")=>{let r=new URLSearchParams(e);return Qn(s=>r.get(s),n)},Qn=(e,n="ref")=>{let r=e(zn);if(r&&$e.test(r)){let a=e(Jn);return {code:r,clickId:a&&$e.test(a)?a:null,direct:false}}let s=e(n);return s&&$e.test(s)?{code:s,clickId:null,direct:true}:null},Gt=e=>{var n;return `${e.code}.${(n=e.clickId)!=null?n:""}.${e.at}`},De=(e,n=60,r=Date.now())=>{if(!e)return null;let[s,a,c]=e.split("."),p=Number(c);return !s||!$e.test(s)||!Number.isFinite(p)||a&&!$e.test(a)||r-p>n*864e5||p>r+864e5?null:{code:s,clickId:a||null,at:p}};var U=null,Ve=()=>typeof document!="undefined",Qt=e=>{var r;if(!Ve())return;let n=(r=document.cookie.split("; ").find(s=>s.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);try{return n?decodeURIComponent(n):void 0}catch(s){return n}},Be=()=>{try{return typeof localStorage=="undefined"?null:localStorage}catch(e){return null}},ct=()=>{var e,n;return U||(Ve()?(n=De(Qt(We),3650))!=null?n:De((e=Be())==null?void 0:e.getItem(Ke),3650):null)};var je=(e,n)=>{var a;if(!Ve())return;let r=Math.max(1,Math.round(n))*86400,s=typeof location!="undefined"&&location.protocol==="https:"?"; secure":"";document.cookie=`${We}=${encodeURIComponent(Gt(e))}; path=/; max-age=${r}; samesite=lax${s}`;try{(a=Be())==null||a.setItem(Ke,Gt(e));}catch(c){}},qe=()=>{var e;if(Ve()){document.cookie=`${We}=; path=/; max-age=0; samesite=lax`;try{(e=Be())==null||e.removeItem(Ke);}catch(n){}}},Zt=()=>{U=null;},en=async e=>{var s,a,c;let n=Gn(e.search,e.param),r=(s=e.now)!=null?s:Date.now();if(!n)return !U&&e.store&&(U=(c=De(Qt(We),e.days,r))!=null?c:De((a=Be())==null?void 0:a.getItem(Ke),e.days,r),U||qe()),U;if(U={code:n.code,clickId:n.clickId,at:r},e.store&&je(U,e.days),e.beacon)try{let p=await e.beacon({code:n.code,clickId:n.clickId});p&&U&&U.code===n.code&&!U.clickId&&(U={...U,clickId:p},e.store&&je(U,e.days));}catch(p){}return U},tn=e=>e==="$identify"||!e.startsWith("$");var lt=3600*24*365,on=e=>{var r;if(typeof document=="undefined")return;let n=(r=document.cookie.split("; ").find(s=>s.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);if(n)try{return decodeURIComponent(n)}catch(s){return n}},Ye=(e,n,r)=>{let s=window.location.protocol==="https:"?"; secure":"";document.cookie=`${e}=${encodeURIComponent(n)}; path=/; max-age=${r}; samesite=lax${s}`;},Pe=e=>{document.cookie=`${e}=; path=/; max-age=0; samesite=lax`;},L={utm:{}},rn=()=>{var e;return (e=L.id)!=null?e:L.id=ot()},dt=(e,n)=>{if(e!=="cookies")return rn();let r=on(ue);if(r)return L.id=r;let s=rn();return Ye(ue,s,lt),s},ut=e=>{var a;let n=Date.now(),r=L.session,s=(a=e?on(be):void 0)!=null?a:r&&n-r.last<18e5?r.id:ot();return L.session={id:s,last:n},e&&Ye(be,s,18e5/1e3),s},ft=()=>{var r;let e=window.location.href;if(L.url===e)return;L.referrer=(r=L.url)!=null?r:document.referrer||void 0,L.url=e;let n=Nt(window.location.search);Object.keys(n).length&&(L.utm=n);},sn=()=>{let e=navigator,n=window;return e.doNotTrack==="1"||n.doNotTrack==="1"||e.globalPrivacyControl===true};var Xe=window,er=()=>{var e,n;return (n=(e=document.currentScript)!=null?e:document.querySelector('script[data-key][src*="sdk"]'))!=null?n:document.querySelector("script[data-key][src*='mrrocket']")},an=new Set,G=e=>{an.has(e)||(an.add(e),console.warn(`[MRRocket] ${e}`));},tr=()=>{var Ct,Rt,vt,Et;let e=er(),n=o=>{var u;return (u=e==null?void 0:e.getAttribute(`data-${o}`))!=null?u:void 0},r=(o,u)=>{let f=n(o);return f===void 0?u:!["false","0","off","no"].includes(f.trim().toLowerCase())},s=(Ct=e==null?void 0:e.src)!=null?Ct:"",a="";try{a=s?new URL(s,window.location.href).origin:"";}catch(o){a="";}let c=((Rt=n("key"))!=null?Rt:"").trim(),p=((vt=n("api-host"))!=null?vt:a).trim().replace(/\/+$/,""),R=n("consent"),S=r("respect-dnt",false),h=r("heatmaps",true),O=r("errors",true),m=n("release"),k=n("attribution"),E=k==="always"||k==="off"?k:"consent",I=n("referral-param")||"ref",T={},M=(o,u)=>{var f;return (f=T[o])!=null?f:T[o]=new Promise((w,v)=>{var _t;let $=()=>Xe[u];if($())return w($());let q=(_t=n(`${o}-src`))!=null?_t:s?s.replace(/(\.min)?\.js(\?[^#]*)?(#.*)?$/,`-${o}$1.js?v=${Le}`):"";if(!q)return v(new Error(o));let se=document.createElement("script");se.async=true,se.src=q,se.onload=()=>$()?w($()):v(new Error(o)),se.onerror=()=>v(new Error(o)),document.head.appendChild(se);}).catch(w=>{throw T[o]=void 0,w})},K=n("theme"),Q={theme:K==="light"||K==="dark"?K:"auto",accent:n("accent")},N=new URLSearchParams(window.location.search),ee=Lt(N.get(Mt)),V=N.get(At)==="1";V&&Xt();let ae=N.get(Se);if(ae!==null){N.delete(Se);let o=N.toString();history.replaceState(history.state,"",`${window.location.pathname}${o?`?${o}`:""}${window.location.hash}`);}let ze=sn(),pe=R==="cookies"||R==="off"?R:"cookieless",ce=r("replay",false),ge="",H,Y=null,te,P=null,X=false,le=false,de=null,A=null,me=window.location.pathname,ne=[],Ce=new Set,we=[],D=()=>S&&ze?"off":pe,j=()=>!V&&D()!=="off",W=()=>H!=null?H:ge,z=()=>D()==="cookies"?W():H,Z=o=>jt(Y,o);c||G('No public key. Add data-key="mrr_pub_\u2026" to the script tag; nothing is tracked until then.');let Re=(o=false)=>{if(!ne.length)return;if(!c){ne.length=0;return}let u=`${p}/api/sdk/events`;for(let f of Ot(c,ne.splice(0),{v:Le,errors:O,platform:"web"},Z(z())))o&&"sendBeacon"in navigator&&navigator.sendBeacon(u,f)||fetch(u,{method:"POST",headers:{"content-type":"application/json"},body:f,keepalive:true}).then(v=>{v.status===401?xe(401):v.ok||G(`Events were rejected with ${v.status}. Check data-key (MRRocket \u203A Settings \u203A Products).`);}).catch(()=>G(`Could not reach ${p||"this origin"} to send events. Check data-api-host.`));},t=null,i=null,l=(o,u,f=Date.now(),w)=>{if(!j())return;let v=tn(o)?ct():null;ne.push({event:o,props:v?{...u,$referral:{code:v.code,clickId:v.clickId}}:u,distinctId:z(),sessionId:ut(D()==="cookies"),ts:f,url:w!=null?w:window.location.href,referrer:L.referrer,...L.utm,screen:{w:window.screen.width,h:window.screen.height}});},g=(o,u)=>{typeof o!="string"||!o||(l(o,u),j()&&(t==null||t.event(o)),d.onEvent(o));},d=qt(Jt({host:p,apiKey:c,track:l,personId:()=>j()?H:void 0,userHash:Z,canStore:()=>D()==="cookies",auto:r("onboarding",true)})),C=false,_;d.subscribe(()=>{C||!d.view()||V||(C=true,M("flows","__mrrocketFlows").then(o=>o.mountFlows(d,Q)).catch(()=>{C=false,G("The cancel flow and onboarding dialogs did not load. Check that sdk-flows.js is served next to sdk.js.");}));});let y=(o,u)=>{if(!j())return;let f=`${window.location.pathname}|${o}`;Ce.has(f)||(Ce.add(f),g("$exposure",{experiment:o,variant:u}));},b=()=>{let o=Ut(P,window.location.href,W(),ee);return o!=null&&o.to?(Re(true),window.location.replace(o.to),true):(o!=null&&o.experiment&&y(o.experiment,o.variant),false)},x=()=>{if(!P)return;let o=document.querySelectorAll("[data-ck-text]");if(!o.length)return;let u=Tt(P,W(),ee),f=new Set;o.forEach(w=>{var q,se;let v=w.dataset.ckText;if(!v)return;f.add(v),w.dataset.ckDefault===void 0&&(w.dataset.ckDefault=(q=w.textContent)!=null?q:"");let $=(se=u[v])!=null?se:w.dataset.ckDefault;w.textContent!==$&&(w.textContent=$);});for(let w of P.experiments)w.variants.some(v=>{var $;return Object.keys(($=v.changes)!=null?$:{}).some(q=>f.has(q))})&&y(w.key,Oe(w.key,P,W(),ee));},F=()=>{var o,u;return (u=(o=P==null?void 0:P.referral)==null?void 0:o.cookieDays)!=null?u:60},B=()=>E==="always"?D()!=="off":E==="consent"&&D()==="cookies",ve=null,J=false,Je=()=>{if(!X||V)return;if(E==="off"||D()==="off"){Zt(),(E==="off"||J)&&qe();return}let o=window.location.href;ve!==o&&(ve=o,en({search:window.location.search,param:I,store:B(),days:F(),beacon:c?({code:u,clickId:f})=>fetch(`${p}/api/sdk/affiliate/click`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:c,code:u,clickId:f,url:o,referrer:document.referrer||void 0}),keepalive:true}).then(w=>w.ok?w.json():null).then(w=>{var v;return (v=w==null?void 0:w.clickId)!=null?v:null}):void 0}));},ln=()=>{let o=B(),u=ct();o&&u?je(u,F()):!o&&J&&qe(),J=o;},pt=0,gt=false,mt=()=>{var w,v;let o=j()&&ce&&!!(P!=null&&P.replay)&&!!c;if(o===gt)return;gt=o;let u=++pt;if(!o){t==null||t.stop(true),t=null;return}let f=(v=(w=P==null?void 0:P.replay)==null?void 0:w.sampleRate)!=null?v:.1;M("replay","__mrrocketReplay").then($=>$.startReplay({host:p,apiKey:c,sessionId:ut(D()==="cookies"),distinctId:z(),identified:!!H,userHash:Z(z()),sampleRate:f,warn:G})).then($=>{u!==pt?$==null||$.stop(true):t=$;}).catch(()=>G("Session recording could not start (the recorder did not load)."));},wt=r("messenger",false),re=null,he=o=>{V||c&&(re!=null||(re=M("messenger","__mrrocketMessenger").then(u=>{var $;let f=q=>n(`messenger-${q}`)===void 0?void 0:r(`messenger-${q}`,true),w=n("messenger-position"),v=($=n("messenger-theme"))!=null?$:K;return u.mountMessenger({host:p,apiKey:c,distinctId:W,user:()=>te,userHash:()=>Z(W()),launcher:wt,position:w,corners:n("messenger-corners"),header:n("messenger-header"),font:n("messenger-font"),title:n("messenger-title"),greeting:n("messenger-greeting"),label:n("messenger-label"),askEmail:f("ask-email"),help:f("help"),sound:f("sound"),preview:f("preview"),theme:v==="light"||v==="dark"||v==="auto"?v:void 0,accent:n("accent")})})),re.then(o).catch(()=>{re=null,G("sdk-messenger.js did not load.");}));},ht=n("forms")==="auto",Ge=false,Qe=()=>{Ge||!c||V||!document.querySelector(ht?"form":"form[data-mrrocket-form]")||(Ge=true,M("forms","__mrrocketForms").then(o=>o.watchForms({host:p,apiKey:c,auto:ht,distinctId:()=>j()?z():void 0,userHash:Z,identified:()=>!!H,identify:xt,tracking:j,referrer:()=>L.referrer,utm:()=>L.utm})).catch(()=>Ge=false));},Ze=()=>{!le||!j()||A===window.location.pathname||(A=window.location.pathname,g("$pageview",{path:window.location.pathname}));},oe=null,kt=()=>{let o=oe;h&&o&&o.max>0&&l("$scroll",{depth:o.max,docH:o.docH,vw:window.innerWidth,vh:window.innerHeight},Date.now(),o.url),oe=null;},Ee=()=>{var v,$;if(!h||!j()||V)return;let o=document.documentElement,u=Math.max(o.scrollHeight,($=(v=document.body)==null?void 0:v.scrollHeight)!=null?$:0),f=$t(),w=window.location.href;(oe==null?void 0:oe.url)!==w?oe={url:w,max:f,docH:u}:f>oe.max&&(oe={url:w,max:f,docH:u});},yt=()=>{let o=window.location.pathname;o!==me&&(me=o,!(X&&b())&&(kt(),ft(),t==null||t.page(o),i==null||i.crumb("navigation",o),Ze(),Je(),window.setTimeout(()=>{Ee(),x(),Qe();},0)));},bt=()=>{let o=D(),u=de;de=o,u==="cookies"&&o!=="cookies"&&(Pe(ue),Pe(be)),o==="off"&&(ne.length=0,L.session=void 0),u==="cookies"&&o!=="cookies"&&zt(),ge=dt(o),ln(),Je(),mt(),Ze(),Ee();},dn=o=>{let{analytics:u,replay:f}=typeof o=="string"?{analytics:o,replay:void 0}:o!=null?o:{};if(u!==void 0&&u!=="cookieless"&&u!=="cookies"&&u!=="off"){G(`setConsent: "${String(u)}" is not a consent mode. Use "cookieless", "cookies" or "off".`);return}u==="off"&&(ne.length=0),u&&(pe=u),typeof f=="boolean"&&(ce=f),bt(),X&&d.refresh();},xt=(o,u,f)=>{if(typeof o!="string"||!o)return;let w=z();Y=Dt(Y,o,f==null?void 0:f.hash),H=o,l("$identify",{...u,id:o,...w&&w!==o?{previousId:w}:{}}),t==null||t.identify(o,Z(o)),D()==="cookies"&&Ye(ue,o,lt),te={...u,id:o},x(),X&&d.refresh();},Me={track:g,identify:xt,reset:()=>{Re(),H=void 0,Y=null,te=void 0,Ce.clear(),D()==="cookies"&&(Pe(ue),Pe(be)),L.id=void 0,L.session=void 0,ge=dt(D()),x(),X&&d.refresh();},captureError:o=>i==null?void 0:i.capture(o,"manual"),setConsent:dn,getFlag:o=>rt(o,P,W(),{...te})!==false,getFlagVariant:o=>{let u=rt(o,P,W(),{...te});return typeof u=="string"?u:null},getVariant:o=>{let u=Oe(o,P,W(),ee);return (P||ee[o])&&y(o,u),u},ready:o=>{typeof o=="function"&&(X?window.setTimeout(()=>o(Me),0):we.push(o));},getDistinctId:W,cancelFlow:{open:o=>d.openCancelFlow(o)},onboarding:{start:o=>d.startOnboarding(o)},openCancelFlow:o=>d.openCancelFlow(o),startOnboarding:o=>d.startOnboarding(o),paywall:{open:(o,u)=>(_!=null?_:_=M("flows","__mrrocketFlows").then(f=>f.paywallHost({config:()=>P,distinctId:W,track:l},Q))).then(f=>f.open(o,u))},push:{subscribe:o=>{let u=j()?H:void 0;if(!u)return Promise.resolve({status:"not-signed-in"});let f=window.Notification,w=Promise.resolve(f&&f.permission==="default"&&(o==null?void 0:o.ask)!==false?f.requestPermission():f==null?void 0:f.permission);return M("push","__mrrocketPush").then(v=>v.subscribeWebPush({host:p,apiKey:c,distinctId:u,userHash:Z(u),permission:w},o))},unsubscribe:()=>M("push","__mrrocketPush").then(o=>o.unsubscribeWebPush({host:p,apiKey:c,distinctId:H,userHash:Z(H)}))},messenger:{open:o=>he(u=>u.open(o)),close:()=>{re==null?void 0:re.then(o=>o.close()).catch(()=>{});},toggle:()=>he(o=>o.toggle())},openMessenger:()=>he(o=>o.open()),version:Le};ft(),bt();let ke=Xe.mrrocket,un=(Et=ke==null?void 0:ke.q)!=null?Et:[],et=ke&&typeof ke=="object"?ke:{};Object.assign(et,Me,{__loaded:true}),delete et.q,Xe.mrrocket=et;for(let[o,u]of un){let f=Me[o];if(typeof f=="function")try{f(...Array.from(u!=null?u:[]));}catch(w){console.error(w);}}le=true,Ze(),O&&c&&!V&&(i=Kt({host:p,apiKey:c,release:m,context:()=>{var o;return {send:j(),distinctId:z(),sessionId:(o=L.session)==null?void 0:o.id,userHash:Z(z())}},warn:G}),i.crumb("navigation",window.location.pathname));for(let o of ["pushState","replaceState"]){let u=history[o];history[o]=function(...f){let w=u.apply(this,f);return yt(),w};}window.addEventListener("popstate",yt);let fn=new _e;document.addEventListener("click",o=>{var $;o.target instanceof Element&&o.target.closest("[data-ck-messenger]")&&(o.preventDefault(),he(q=>q.open()));let u=o.target instanceof Element?o.target.closest("[data-ck-goal]"):null;if(u!=null&&u.dataset.ckGoal&&g(u.dataset.ckGoal,{text:($=u.textContent)==null?void 0:$.trim().slice(0,80)}),!j())return;let f=Ft(o);if(!f)return;let w=fn.push(f.x,f.y,Date.now());if((f.label||f.selector)&&(i==null||i.crumb("click",f.label||f.selector)),t==null||t.click(f,w),!h)return;let v={x:f.x,y:f.y,vw:f.vw,vh:f.vh,docH:f.docH,selector:f.selector,label:f.label,dead:!f.interactive};l("$click",v),w&&l("$rageclick",v);});let tt=0;window.addEventListener("scroll",()=>{tt||(tt=window.requestAnimationFrame(()=>{tt=0,Ee();}));},{passive:true}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Ee()):Ee(),window.setInterval(()=>Re(),2e3),window.addEventListener("pagehide",()=>{kt(),Re(true);});let nt=()=>{if(X=true,b())return;let o=Ht(P,ae);o&&y(o.experiment,o.variant),document.documentElement.classList.remove("ck-hide"),Je(),mt(),d.setConfig(P),d.refresh(),wt&&(document.body?he():document.addEventListener("DOMContentLoaded",()=>he())),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{x(),Qe();}):(x(),Qe());for(let u of we.splice(0))try{u(Me);}catch(f){console.error(f);}};c?fetch(`${p}/api/sdk/config?key=${encodeURIComponent(c)}`).then(o=>(o.ok||G(`Config request to ${p||"this origin"} answered ${o.status}. Check data-key and data-api-host.`),o.ok?o.json():null)).then(o=>{o&&Array.isArray(o.experiments)&&(P=o),nt();}).catch(()=>{G(`Could not reach ${p||"this origin"}. Check data-api-host. The page keeps its own texts and flags stay off.`),nt();}):nt();},cn;typeof window!="undefined"&&typeof document!="undefined"&&!((cn=Xe.mrrocket)!=null&&cn.__loaded)&&tr();
2
2
  })();
package/dist/client.d.ts CHANGED
@@ -5,6 +5,7 @@ import type { PushResult, WebPushOptions } from "./push-web.js";
5
5
  import { type CancelFlowOptions, type CancelFlowResult } from "./flows.js";
6
6
  import type { FlowsTheme } from "./flows-ui.js";
7
7
  import { type PaywallOptions, type PaywallResult } from "./paywall.js";
8
+ import { type IdentifyOptions } from "./identity.js";
8
9
  export interface CockpitProviderProps {
9
10
  /** The product's public key from Cockpit › Settings › SDK. Safe in the browser. Default: `NEXT_PUBLIC_MRROCKET_KEY`. */
10
11
  apiKey?: string;
@@ -16,6 +17,13 @@ export interface CockpitProviderProps {
16
17
  config?: CockpitConfig;
17
18
  /** Your own id for this visitor, for example a signed-in user id. Keeps variants stable without cookies. */
18
19
  distinctId?: string;
20
+ /**
21
+ * The identity hash of `distinctId` (0.16.0): `await userHash(user.id)` from `@mrrocket/sdk/next/server`, made in
22
+ * the server layout that knows the user. Sent with every request for that id, so MRRocket knows it is really them
23
+ * (needed with MRRocket › Settings › Products › Sign-in › "Only signed users"). In the browser pass it to
24
+ * `identify(id, props, { hash })` instead.
25
+ */
26
+ userHash?: string;
19
27
  /**
20
28
  * "cookieless" (default) stores nothing in the browser, "cookies" keeps a visitor cookie for a year, "off" sends
21
29
  * nothing. The SDK does not remember the choice: set it on every page load, from the prop or setConsent().
@@ -74,7 +82,7 @@ export interface CockpitProviderProps {
74
82
  * `preview` forces variants for this render, for example from the `ck_preview` search param on the server,
75
83
  * so a Cockpit preview never flickers. Without it the provider reads the param itself after the first render.
76
84
  */
77
- export declare const CockpitProvider: ({ apiKey: apiKeyProp, host: hostProp, preview: forced, embedded: embeddedProp, config: bootstrapConfig, distinctId: bootstrapId, consent: consentProp, respectDnt, replay: replayProp, heatmaps, surveys, errors, release, attribution, referralParam, onboarding, appearance, forms, children, }: CockpitProviderProps) => import("react").JSX.Element;
85
+ export declare const CockpitProvider: ({ apiKey: apiKeyProp, host: hostProp, preview: forced, embedded: embeddedProp, config: bootstrapConfig, distinctId: bootstrapId, userHash: bootstrapHash, consent: consentProp, respectDnt, replay: replayProp, heatmaps, surveys, errors, release, attribution, referralParam, onboarding, appearance, forms, children, }: CockpitProviderProps) => import("react").JSX.Element;
78
86
  /**
79
87
  * `track`, `identify`, `captureError`, the consent mode, the replay consent and their setter, the visitor id and whether
80
88
  * the experiments and flags have loaded. `setConsent("cookies")` sets the mode, `setConsent({ replay: true })` the
@@ -82,7 +90,7 @@ export declare const CockpitProvider: ({ apiKey: apiKeyProp, host: hostProp, pre
82
90
  */
83
91
  export declare const useCockpit: () => {
84
92
  track: (event: string, props?: Record<string, unknown>) => void;
85
- identify: (id: string, props?: Record<string, unknown>) => void;
93
+ identify: (id: string, props?: Record<string, unknown>, options?: IdentifyOptions) => void;
86
94
  captureError: (error: unknown) => void;
87
95
  distinctId: string;
88
96
  ready: boolean;
package/dist/client.js CHANGED
@@ -39,6 +39,7 @@ import { createFlows } from "./flows.js";
39
39
  import { startPicker } from "./pick.js";
40
40
  import { forgetFlowsStorage, webFlowsEnv } from "./flows-web.js";
41
41
  import { createPaywallHost } from "./paywall.js";
42
+ import { hashFor, nextSigned, warnUnsigned } from "./identity.js";
42
43
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
43
44
  var warned = /* @__PURE__ */ new Set();
44
45
  var warnOnce = (message) => {
@@ -53,6 +54,7 @@ var CockpitProvider = ({
53
54
  embedded: embeddedProp,
54
55
  config: bootstrapConfig,
55
56
  distinctId: bootstrapId,
57
+ userHash: bootstrapHash,
56
58
  consent: consentProp = "cookieless",
57
59
  respectDnt = false,
58
60
  replay: replayProp = false,
@@ -81,17 +83,24 @@ var CockpitProvider = ({
81
83
  const [urlEmbedded, setUrlEmbedded] = useState(false);
82
84
  const [user, setUser] = useState();
83
85
  const [ready, setReady] = useState(!!bootstrapConfig);
86
+ const [signed, setSigned] = useState(null);
87
+ const signedRef = useRef(null);
84
88
  const queue = useRef([]);
85
89
  const early = useRef([]);
86
90
  const exposed = useRef(/* @__PURE__ */ new Set());
87
91
  const lastPage = useRef(null);
88
92
  const bootstrap = bootstrapId && bootstrapId !== "anonymous" ? bootstrapId : void 0;
93
+ const bootSigned = useMemo(() => bootstrap && bootstrapHash ? nextSigned(null, bootstrap, bootstrapHash) : null, [bootstrap, bootstrapHash]);
94
+ const bootSignedRef = useRef(bootSigned);
95
+ bootSignedRef.current = bootSigned;
96
+ const hashOf = useCallback((id) => hashFor(signedRef.current, id) ?? hashFor(bootSignedRef.current, id), []);
89
97
  const preview = useMemo(() => ({ ...urlPreview, ...forced }), [urlPreview, forced]);
90
98
  const embedded = embeddedProp ?? urlEmbedded;
91
99
  const effectiveConsent = respectDnt && dnt ? "off" : consent;
92
100
  const distinctId = identified ?? bootstrap ?? visitor?.id ?? "anonymous";
93
101
  const tracking = !embedded && effectiveConsent !== "off" && visitor?.mode === effectiveConsent;
94
102
  const sendId = effectiveConsent === "cookies" ? distinctId : identified;
103
+ const userHash = hashFor(signed, distinctId) ?? hashFor(bootSigned, distinctId);
95
104
  useEffect(() => {
96
105
  const params = new URLSearchParams(window.location.search);
97
106
  setUrlPreview(parsePreview(params.get(PREVIEW_PARAM)));
@@ -165,15 +174,16 @@ var CockpitProvider = ({
165
174
  return;
166
175
  }
167
176
  const url = `${host}/api/sdk/events`;
168
- for (const body of bodies(apiKey, queue.current.splice(0), { v: SDK_VERSION, errors })) {
177
+ for (const body of bodies(apiKey, queue.current.splice(0), { v: SDK_VERSION, errors }, hashOf(live.current.sendId))) {
169
178
  const sent = beacon && typeof navigator !== "undefined" && "sendBeacon" in navigator && navigator.sendBeacon(url, body);
170
179
  if (!sent)
171
180
  fetch(url, { method: "POST", headers: { "content-type": "application/json" }, body, keepalive: true }).then((r) => {
172
- if (!r.ok) warnOnce(`Events were rejected with ${r.status}. Check the public key (Settings \u203A SDK) and NEXT_PUBLIC_MRROCKET_HOST.`);
181
+ if (r.status === 401) warnUnsigned(401);
182
+ else if (!r.ok) warnOnce(`Events were rejected with ${r.status}. Check the public key (Settings \u203A SDK) and NEXT_PUBLIC_MRROCKET_HOST.`);
173
183
  }).catch(() => warnOnce(`Could not reach ${host || "this origin"} to send events. Check NEXT_PUBLIC_MRROCKET_HOST.`));
174
184
  }
175
185
  },
176
- [apiKey, host, errors]
186
+ [apiKey, host, errors, hashOf]
177
187
  );
178
188
  useEffect(() => {
179
189
  const timer = window.setInterval(() => flush(), 2e3);
@@ -216,6 +226,7 @@ var CockpitProvider = ({
216
226
  apiKey,
217
227
  track: (event, props) => record(event, props),
218
228
  personId: () => live.current.tracking && live.current.identified ? live.current.distinctId : void 0,
229
+ userHash: hashOf,
219
230
  canStore: () => live.current.persist,
220
231
  auto: onboarding
221
232
  })
@@ -235,21 +246,23 @@ var CockpitProvider = ({
235
246
  [record, flows]
236
247
  );
237
248
  const identify = useCallback(
238
- (id, props) => {
249
+ (id, props, options) => {
239
250
  const now = live.current;
240
251
  if (!now.resolved) {
241
- early.current.push(() => identify(id, props));
252
+ early.current.push(() => identify(id, props, options));
242
253
  return;
243
254
  }
244
255
  const previous = now.sendId;
256
+ signedRef.current = nextSigned(signedRef.current ?? bootSignedRef.current, id, options?.hash);
257
+ setSigned(signedRef.current);
245
258
  live.current = { ...now, distinctId: id, sendId: id, identified: true };
246
259
  record("$identify", { ...props, id, ...previous && previous !== id ? { previousId: previous } : {} });
247
- replayer.current?.identify(id);
260
+ replayer.current?.identify(id, hashOf(id));
248
261
  if (now.persist) writeCookie(ID_COOKIE, id, YEAR_S);
249
262
  setIdentified(id);
250
263
  setUser({ id, ...props });
251
264
  },
252
- [record]
265
+ [record, hashOf]
253
266
  );
254
267
  const identifyRef = useRef(identify);
255
268
  identifyRef.current = identify;
@@ -264,6 +277,7 @@ var CockpitProvider = ({
264
277
  apiKey,
265
278
  auto: forms === "auto",
266
279
  distinctId: () => live.current.tracking ? live.current.sendId : void 0,
280
+ userHash: hashOf,
267
281
  identified: () => live.current.identified,
268
282
  identify: (id, props) => identifyRef.current(id, props),
269
283
  tracking: () => live.current.tracking,
@@ -275,7 +289,7 @@ var CockpitProvider = ({
275
289
  gone = true;
276
290
  off?.();
277
291
  };
278
- }, [forms, apiKey, host, embedded]);
292
+ }, [forms, apiKey, host, embedded, hashOf]);
279
293
  useEffect(() => {
280
294
  if (!visitor) return;
281
295
  for (const run of early.current.splice(0)) run();
@@ -364,7 +378,7 @@ var CockpitProvider = ({
364
378
  host,
365
379
  apiKey,
366
380
  release,
367
- context: () => ({ send: live.current.tracking, distinctId: live.current.sendId, sessionId: page.session?.id }),
381
+ context: () => ({ send: live.current.tracking, distinctId: live.current.sendId, sessionId: page.session?.id, userHash: hashOf(live.current.sendId) }),
368
382
  warn: warnOnce
369
383
  });
370
384
  errorer.current = capture;
@@ -373,7 +387,7 @@ var CockpitProvider = ({
373
387
  capture.stop();
374
388
  if (errorer.current === capture) errorer.current = null;
375
389
  };
376
- }, [errors, apiKey, host, release, embedded]);
390
+ }, [errors, apiKey, host, release, embedded, hashOf]);
377
391
  const captureError = useCallback((error) => errorer.current?.capture(error, "manual"), []);
378
392
  useEffect(() => {
379
393
  if (!tracking || lastPage.current === pathname) return;
@@ -450,6 +464,7 @@ var CockpitProvider = ({
450
464
  sessionId: touchSession(live.current.persist),
451
465
  distinctId: live.current.sendId,
452
466
  identified: live.current.identified,
467
+ userHash: hashOf(live.current.sendId),
453
468
  sampleRate: replayConfig.sampleRate,
454
469
  warn: warnOnce
455
470
  })
@@ -462,7 +477,7 @@ var CockpitProvider = ({
462
477
  handle?.stop(true);
463
478
  if (replayer.current === handle) replayer.current = null;
464
479
  };
465
- }, [recording, replayConfig, host, apiKey]);
480
+ }, [recording, replayConfig, host, apiKey, hashOf]);
466
481
  useEffect(() => {
467
482
  if (!ready || !visitor || embedded) return;
468
483
  flows.setConfig(config);
@@ -511,13 +526,17 @@ var CockpitProvider = ({
511
526
  if (!distinctId2) return Promise.resolve({ status: "not-signed-in" });
512
527
  const N = window.Notification;
513
528
  const permission = Promise.resolve(N && N.permission === "default" && options?.ask !== false ? N.requestPermission() : N?.permission);
514
- return import("./push-web.js").then((m) => m.subscribeWebPush({ host, apiKey, distinctId: distinctId2, permission }, options));
529
+ return import("./push-web.js").then((m) => m.subscribeWebPush({ host, apiKey, distinctId: distinctId2, userHash: hashOf(distinctId2), permission }, options));
515
530
  },
516
- [host, apiKey]
531
+ [host, apiKey, hashOf]
517
532
  );
518
533
  const unsubscribeFromPush = useCallback(
519
- () => typeof window === "undefined" ? Promise.resolve(false) : import("./push-web.js").then((m) => m.unsubscribeWebPush({ host, apiKey, distinctId: live.current.identified ? live.current.distinctId : void 0 })),
520
- [host, apiKey]
534
+ () => {
535
+ if (typeof window === "undefined") return Promise.resolve(false);
536
+ const distinctId2 = live.current.identified ? live.current.distinctId : void 0;
537
+ return import("./push-web.js").then((m) => m.unsubscribeWebPush({ host, apiKey, distinctId: distinctId2, userHash: hashOf(distinctId2) }));
538
+ },
539
+ [host, apiKey, hashOf]
521
540
  );
522
541
  const texts = useMemo(() => textChanges(config, distinctId, preview), [config, distinctId, preview]);
523
542
  const value = useMemo(
@@ -527,6 +546,7 @@ var CockpitProvider = ({
527
546
  user,
528
547
  ready,
529
548
  distinctId,
549
+ userHash,
530
550
  config,
531
551
  preview,
532
552
  embedded,
@@ -551,6 +571,7 @@ var CockpitProvider = ({
551
571
  user,
552
572
  ready,
553
573
  distinctId,
574
+ userHash,
554
575
  config,
555
576
  preview,
556
577
  embedded,