@mrrocket/sdk 0.14.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 (70) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +45 -4
  3. package/dist/api-client.d.ts +67 -5
  4. package/dist/api-client.js +39 -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 +202 -46
  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-ui.js +48 -1
  30. package/dist/flows-ui.js.map +1 -1
  31. package/dist/flows-web.d.ts +2 -0
  32. package/dist/flows-web.js +4 -1
  33. package/dist/flows-web.js.map +1 -1
  34. package/dist/flows.d.ts +61 -1
  35. package/dist/flows.js +64 -21
  36. package/dist/flows.js.map +1 -1
  37. package/dist/forms.d.ts +4 -0
  38. package/dist/forms.js +4 -1
  39. package/dist/forms.js.map +1 -1
  40. package/dist/identity.d.ts +42 -0
  41. package/dist/identity.js +24 -0
  42. package/dist/identity.js.map +1 -0
  43. package/dist/index.d.ts +2 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/messenger-ui.d.ts +21 -6
  46. package/dist/messenger-ui.js +334 -80
  47. package/dist/messenger-ui.js.map +1 -1
  48. package/dist/messenger.d.ts +11 -3
  49. package/dist/messenger.js +9 -5
  50. package/dist/messenger.js.map +1 -1
  51. package/dist/push-web.d.ts +2 -13
  52. package/dist/push-web.js +4 -2
  53. package/dist/push-web.js.map +1 -1
  54. package/dist/react-native/index.d.cts +162 -14
  55. package/dist/react-native/index.d.ts +162 -14
  56. package/dist/react-native/index.js +552 -207
  57. package/dist/react-native/index.js.map +1 -1
  58. package/dist/replay.d.ts +4 -1
  59. package/dist/replay.js +8 -2
  60. package/dist/replay.js.map +1 -1
  61. package/dist/server.d.ts +2 -0
  62. package/dist/server.js +2 -0
  63. package/dist/server.js.map +1 -1
  64. package/dist/styles-css.d.ts +1 -1
  65. package/dist/styles-css.js +200 -44
  66. package/dist/styles-css.js.map +1 -1
  67. package/dist/user-hash.d.ts +27 -0
  68. package/dist/user-hash.js +24 -0
  69. package/dist/user-hash.js.map +1 -0
  70. package/package.json +9 -1
@@ -1,2 +1,2 @@
1
- (function(){'use strict';var sn=Object.defineProperty;var an=(e,t,r)=>t in e?sn(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r;var we=(e,t,r)=>an(e,typeof t!="symbol"?t+"":t,r);var Rt=e=>{let t=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);s<128?t+=1:s<2048?t+=2:s>=55296&&s<=56319&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(t+=4,r++):t+=3;}return t},cn=(e,t,r)=>{let s=`{"key":${JSON.stringify(e)},"sdk":${JSON.stringify(r)},"events":[`,c=Rt(s)+2,a=[],f=[],C=[],v=c,k=()=>{f.length&&a.push({body:`${s}${f.join(",")}]}`,events:C}),f=[],C=[],v=c;};for(let E of t){let g=JSON.stringify(E),h=Rt(g)+1;c+h>6e4||((f.length===100||v+h>6e4)&&k(),f.push(g),C.push(E),v+=h);}return k(),a},vt=(e,t,r)=>cn(e,t,r).map(s=>s.body);var xe=class{constructor(t=1e3,r=30,s=3){we(this,"windowMs",t);we(this,"radius",r);we(this,"count",s);we(this,"clicks",[]);we(this,"fired",false);}push(t,r,s){let c=this.clicks.filter(a=>s-a.t<=this.windowMs&&Math.hypot(a.x-t,a.y-r)<=this.radius);return c.length!==this.clicks.length&&(this.fired=false),this.clicks=[...c,{x:t,y:r,t:s}],this.clicks.length>=this.count&&!this.fired?(this.fired=true,true):false}};var ln='a[href],button,input,select,textarea,label,summary,[role="button"],[role="link"],[role="tab"],[role="menuitem"],[role="checkbox"],[role="switch"],[onclick],[data-ck-goal]',dn="[data-ck-mask]",un="[data-ck-block]",Et=/\d{4,}|^[a-z]{1,3}-[a-z0-9]{5,}$|^_|__|css-|^sc-|^jsx-/i,fn=e=>{let t=e.tagName.toLowerCase();if(e.id&&!Et.test(e.id)&&e.id.length<=40)return `${t}#${e.id}`;let r=typeof e.className=="string"?e.className.split(/\s+/).filter(a=>a&&!Et.test(a)&&a.length<=30&&!a.includes(":")):[],s=r.length?`${t}.${r.slice(0,2).join(".")}`:t,c=e.parentElement?[...e.parentElement.children].filter(a=>a.tagName===e.tagName):[];return c.length>1?`${s}:nth-of-type(${c.indexOf(e)+1})`:s},pn=e=>{let t=[],r=e;for(;r&&t.length<3&&r.tagName&&r.tagName!=="BODY"&&r.tagName!=="HTML";){let s=fn(r);if(t.unshift(s),s.includes("#"))break;r=r.parentElement;}return t.join(" > ").slice(0,160)},Pe=e=>(e!=null?e:"").replace(/\s+/g," ").trim().slice(0,40),gn=e=>{var r,s,c,a,f;if(e.closest(`${dn},${un}`))return "";let t=e.tagName.toLowerCase();if(t==="input"){let C=((r=e.getAttribute("type"))!=null?r:"text").toLowerCase();return Pe(C==="submit"||C==="button"?(s=e.getAttribute("aria-label"))!=null?s:e.value:e.getAttribute("aria-label"))}return Pe(t==="select"||t==="textarea"?e.getAttribute("aria-label"):(f=(a=(c=e.getAttribute("aria-label"))!=null?c:e.getAttribute("title"))!=null?a:e.innerText)!=null?f:e.textContent)},_t=e=>{var a,f;let t=e.target instanceof Element?e.target:null;if(!t)return null;let r=t.closest(ln),s=r!=null?r:t,c=document.documentElement;return {x:Math.round(e.clientX),y:Math.round(e.clientY+window.scrollY),vw:window.innerWidth,vh:window.innerHeight,docH:Math.max(c.scrollHeight,(f=(a=document.body)==null?void 0:a.scrollHeight)!=null?f:0),selector:pn(s),label:r?gn(r):"",interactive:!!r}},St=()=>{var r,s;let e=document.documentElement,t=Math.max(e.scrollHeight,(s=(r=document.body)==null?void 0:r.scrollHeight)!=null?s:0);return t?Math.min(100,Math.round((window.scrollY+window.innerHeight)/t*100)):0};var Me="0.14.0",mn=(e,t)=>{let r=t.trim().toLowerCase();for(let[s,c]of Object.entries(e))if(s.toLowerCase()===r)return c},wn=(e,t)=>{let r=e.trim().toLowerCase(),s=t.trim().toLowerCase();return s.startsWith("@")?r.endsWith(s):r===s},hn=(e,t)=>{if(e.op==="in cohort")return false;let r=mn(t,e.property),s=r==null?"":String(r);if(e.op==="\u2265"){let a=Number(s),f=Number(e.values[0]);return s!==""&&Number.isFinite(a)&&Number.isFinite(f)&&a>=f}let c=s!==""&&e.values.some(a=>wn(s,a));return e.op==="is"||e.op==="in"?c:!c},kn=(e,t,r={})=>{var C;if(!e.on)return false;let s={id:t,...r},c=e.sets.length?e.sets.find(v=>v.conditions.every(k=>hn(k,s))):{rollout:100};if(!c||It(`${e.key}:rollout:${t}`)*100>=c.rollout)return false;if(!((C=e.variants)!=null&&C.length))return true;let a=It(`${e.key}:variant:${t}`)*100,f=0;for(let v of e.variants)if(f+=v.split,a<f)return v.key;return e.variants[e.variants.length-1].key},Ze=(e,t,r,s={})=>{var a;let c=(a=t==null?void 0:t.flags)==null?void 0:a.find(f=>f.key===e);return c?kn(c,r,s):false},yn=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],Ot="ck_preview",Ft="ck_embed",ce="ck_id",he="ck_sid";var bn=e=>{var r;let t={};for(let s of yn){let c=(r=e(s))==null?void 0:r.trim();c&&(t[s]=c.slice(0,150));}return t},Pt=e=>{let t=new URLSearchParams(e);return bn(r=>t.get(r))};var xn=e=>{let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return (t>>>0)/4294967296},It=e=>{let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,(t>>>0)/4294967296},Cn=(e,t)=>{var a,f,C,v;let r=(f=(a=e.variants[0])==null?void 0:a.id)!=null?f:"control";if(e.winner)return e.winner;if(e.status!=="running")return r;let s=xn(`${e.key}:${t}`),c=0;for(let k of e.variants)if(c+=k.weight,s<c)return k.id;return (v=(C=e.variants[e.variants.length-1])==null?void 0:C.id)!=null?v:r},$t=e=>{let t=Array.isArray(e)?e[0]:e;if(!t)return {};let r={};for(let s of t.split(",")){let[c,a]=s.split(":");c&&a&&(r[c.trim()]=a.trim());}return r};var Re=(e,t,r,s)=>{if(s[e])return s[e];let c=t==null?void 0:t.experiments.find(a=>a.key===e);return c?Cn(c,r):"control"},Mt=(e,t,r)=>{var c,a,f,C,v,k;let s={...(c=e==null?void 0:e.texts)!=null?c:{}};for(let E of (a=e==null?void 0:e.experiments)!=null?a:[]){let g=Re(E.key,e,t,r);g!==((C=(f=E.variants[0])==null?void 0:f.id)!=null?C:"control")&&Object.assign(s,(k=(v=E.variants.find(h=>h.id===g))==null?void 0:v.changes)!=null?k:{});}return s},Ce="ck_x",$e=e=>e.replace(/\/+$/,"")||"/",At=(e,t,r,s={})=>{var C,v;if(!e)return null;let c;try{c=new URL(t);}catch(k){return null}if(c.searchParams.has(Ce))return null;let a=$e(c.pathname),f=(k,E)=>{let g;try{g=new URL(k,c);}catch(h){return}if(!(!/^https?:$/.test(g.protocol)||g.origin===c.origin&&$e(g.pathname)===a))return c.searchParams.forEach((h,S)=>{g.searchParams.has(S)||g.searchParams.set(S,h);}),E&&g.searchParams.set(Ce,E),g.hash||(g.hash=c.hash),g.href};for(let k of (C=e.redirects)!=null?C:[]){let E=k.from&&$e(k.from)===a?f(k.to):void 0;if(E)return {to:E}}for(let k of e.experiments){if(!k.path||$e(k.path)!==a)continue;let E=k.status==="running"&&!k.winner;if(E&&r===null&&!s[k.key])return null;let g=Re(k.key,e,r!=null?r:"",s),h=(v=k.variants.find($=>$.id===g))==null?void 0:v.url,S=h?f(h,E?`${k.key}:${g}`:void 0):void 0;return E?{to:S,experiment:k.key,variant:g}:S?{to:S}:null}return null},Nt=(e,t)=>{let[r,s]=(t!=null?t:"").split(":"),c=e==null?void 0:e.experiments.find(a=>a.key===r);return c&&c.variants.some(a=>a.id===s)?{experiment:r,variant:s}:null};var et=()=>typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():`ck_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;var ve=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e,Rn=e=>{var t;if(e instanceof Error)return {type:e.name||"Error",message:ve(e.message||String(e),1e3),stack:e.stack?ve(e.stack,8192):void 0};if(typeof e=="string")return {type:"Error",message:ve(e,1e3)};try{return {type:"Error",message:ve((t=JSON.stringify(e))!=null?t:String(e),1e3)}}catch(r){return {type:"Error",message:String(e)}}},Lt=e=>{let t=[],r=[],s=new Set,c=0,a=`${e.host}/api/sdk/errors`,f=(h=false)=>{for(;t.length;){let S=JSON.stringify({key:e.apiKey,errors:t.splice(0,4)});h&&typeof navigator!="undefined"&&"sendBeacon"in navigator&&navigator.sendBeacon(a,S)||fetch(a,{method:"POST",headers:{"content-type":"application/json"},body:S,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(()=>{});}},C=(h,S="manual")=>{let $=e.context();if(!$.send||c>=20)return;let L=Rn(h);if(/\/api\/sdk\/errors/.test(L.message))return;let N=`${L.type}:${L.message}`;s.has(N)||(s.add(N),c++,t.push({...L,mechanism:S,handled:S==="manual",url:window.location.href,ts:Date.now(),crumbs:r.slice(),...e.release?{release:e.release}:{},...$.distinctId?{distinctId:$.distinctId}:{},...$.sessionId?{sessionId:$.sessionId}:{}}));},v=h=>{var S;!h.error&&(!h.message||h.message==="Script error.")||C((S=h.error)!=null?S:new Error(h.message),"onerror");},k=h=>{var S;return C((S=h.reason)!=null?S:new Error("Unhandled promise rejection"),"onunhandledrejection")},E=()=>f(true);window.addEventListener("error",v),window.addEventListener("unhandledrejection",k),window.addEventListener("pagehide",E);let g=window.setInterval(()=>f(),2e3);return {capture:C,crumb:(h,S)=>{r.push({ts:Date.now(),type:h,message:ve(S,120)}),r.length>20&&r.shift();},stop:()=>{window.removeEventListener("error",v),window.removeEventListener("unhandledrejection",k),window.removeEventListener("pagehide",E),window.clearInterval(g),f(true);}}};var Ee="$cancel_flow",re="$onboarding",tt="$inapp",vn={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"},En="Something went wrong. Please try again.",Tt="mrrocket:onboarding",Ae=e=>e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),Dt=new Set(["signed_up","signup","sign_up","registered","account_created","user_signed_up"]),nt=(e,t)=>{let r=Ae(e),s=Ae(t);return !r||!s?false:r===s||Dt.has(r)&&Dt.has(s)},_n=e=>/^(first (launch|visit|open|session|login|sign ?in|app open)|app (opened|launched)|on load|every visit|always)?$/i.test(e.trim()),Sn=()=>`cf_${Math.random().toString(36).slice(2,10)}${Date.now().toString(36)}`;var In=e=>{let t=(e!=null?e:"").trim();return /^https?:\/\//i.test(t)||/^\/(?!\/)/.test(t)?t:void 0},le=e=>{var t;return (t=e.nodes)!=null?t:e.steps},On=e=>Math.max(0,e.amount)*(e.unit==="hours"?36e5:864e5),Fn=(e,t)=>{let r=e.trim(),s=(t.split(/[?#]/)[0]||"/").replace(/\/+$/,"")||"/";if(!r)return false;if(r.endsWith("*")){let c=r.slice(0,-1).replace(/\/+$/,"");return !c||s===c||s.startsWith(`${c}/`)}return s===(r.replace(/\/+$/,"")||"/")},rt=e=>e.flatMap(t=>t.kind==="condition"?[...rt(t.yes),...rt(t.no)]:t.kind==="wait"?[]:[t]),Ut=e=>{let t=null,r=null,s=null,c=[],a=false,f=null,C,v=null,k=new Map,E=new Set,g=new Set,h=new Set,S=e.auto!==false,$=new Set,L=()=>{var n,i;return (i=(n=e.now)==null?void 0:n.call(e))!=null?i:Date.now()},N=null,z=()=>{var n;return (n=t==null?void 0:t.onboarding)!=null?n:[]},G=n=>n?z().find(i=>i.id===n):void 0,H=n=>{let i=k.get(n);return i||k.set(n,i={done:new Set,dismissed:false,answers:new Map,at:new Map,reached:new Map}),i},Q=false,W=n=>{e.track(re,n),Q=true;},oe=(n,i)=>{n.done.add(i),n.at.set(i,L());},Be=n=>{var i,l,m;if((i=n.page)!=null&&i.trim()){let p=(l=e.path)==null?void 0:l.call(e);return p===void 0?false:Fn(n.page,p)}if((m=n.event)!=null&&m.trim()){if(!a)return;for(let p of $)if(nt(n.event,p))return true;return false}return false},de=(n,i,l,m,p=0,_)=>{var I,b;for(let y=0;y<i.length;y++){let x=i[y];if(x.kind==="wait"){if(l.done.has(x.id)){_=(I=l.at.get(x.id))!=null?I:_;continue}let O=l.reached.get(x.id);if(O===void 0){if(!m)return {at:"pending"};O=_!=null?_:L(),l.reached.set(x.id,O),W({flow:n.id,step:x.id,kind:"wait",action:"shown"});}let B=O+On(x);if(L()<B)return {at:"wait",until:B};if(!m)return {at:"pending"};oe(l,x.id),W({flow:n.id,step:x.id,kind:"wait",action:"completed"}),_=B;continue}if(x.kind==="condition"){let O=l.answers.get(x.id);if(O===void 0){if(!m)return {at:"pending"};if(O=Be(x),O===void 0)return {at:"pending"};l.answers.set(x.id,O),W({flow:n.id,step:x.id,kind:"condition",action:"answered",answer:O?"yes":"no"});}return de(n,O?x.yes:x.no,l,m,p,_)}if(!l.done.has(x.id))return {at:"step",step:x,line:i,index:y,before:p};_=(b=l.at.get(x.id))!=null?b:_,p++;}return {at:"end"}},se=n=>{let i=k.get(n.id);return !!i&&(i.dismissed||de(n,le(n),i,false).at==="end")},ue=n=>`${Tt}:${n!=null?n:"visitor"}`,j=n=>`${Tt}:events:${n!=null?n:"visitor"}`,V=()=>{var l;Q=false;let n=(l=e.storage)==null?void 0:l.call(e);if(!n)return;let i={};for(let[m,p]of k)i[m]={done:[...p.done],...p.dismissed?{dismissed:true}:{},...p.answers.size?{answers:Object.fromEntries([...p.answers].map(([_,I])=>[_,I?"yes":"no"]))}:{},...p.at.size?{at:Object.fromEntries(p.at)}:{},...p.reached.size?{reached:Object.fromEntries(p.reached)}:{}};try{n.set(ue(e.personId()),JSON.stringify(i)),$.size&&n.set(j(e.personId()),JSON.stringify([...$].slice(-200)));}catch(m){}},P=n=>{var i,l,m,p;for(let[_,I]of Object.entries(n!=null?n:{})){let b=H(_);for(let y of (i=I.done)!=null?i:[])b.done.add(y);I.dismissed&&(b.dismissed=true);for(let[y,x]of Object.entries((l=I.answers)!=null?l:{}))b.answers.has(y)||b.answers.set(y,x==="yes");for(let[y,x]of Object.entries((m=I.at)!=null?m:{}))typeof x=="number"&&!b.at.has(y)&&b.at.set(y,x);for(let[y,x]of Object.entries((p=I.reached)!=null?p:{}))typeof x=="number"&&(!b.reached.has(y)||x<b.reached.get(y))&&b.reached.set(y,x);}},Z=n=>{var l;N&&clearTimeout(N),N=null;let i=n-L();i>0&&i<=864e5&&(N=setTimeout(()=>(N=null,M()),i+50),(l=N.unref)==null||l.call(N));},fe=false,ie=()=>{fe=false;let n=G(s);if(!n)return null;let i=H(n.id);if(i.dismissed)return null;let l=de(n,le(n),i,true);if(Q&&V(),l.at==="wait"&&Z(l.until),fe=l.at==="wait"||l.at==="pending",l.at!=="step")return null;let{step:m,line:p,index:_}=l,I=O=>!!O&&O.kind!=="wait"&&O.kind!=="condition";if(m.kind==="checklist"){let O=_;for(;O>0&&I(p[O-1])&&p[O-1].kind==="checklist";)O--;let B=_;for(;B+1<p.length&&I(p[B+1])&&p[B+1].kind==="checklist";)B++;let ye=p.slice(O,B+1).filter(I);for(let Y of ye)!i.done.has(Y.id)&&!g.has(`s:${Y.id}`)&&(g.add(`s:${Y.id}`),e.track(re,{flow:n.id,step:Y.id,kind:"checklist",action:"shown"}));return {type:"checklist",flow:n,items:ye.map(Y=>({step:Y,done:i.done.has(Y.id)}))}}g.has(`s:${m.id}`)||(g.add(`s:${m.id}`),e.track(re,{flow:n.id,step:m.id,kind:m.kind,action:"shown"}));let b=p.slice(_+1),y=b.findIndex(O=>O.kind==="condition"),x=(y<0?b:b.slice(0,y)).filter(I).length;return {type:"step",flow:n,step:m,index:l.before,total:l.before+1+x,last:!x&&y<0}},ae=()=>{if(r){let l=r.reason?r.flow.offers[r.reason]:void 0;return {type:"cancel",screen:r.screen,flow:r.flow,reason:r.reason,offer:r.screen==="offer"?l:void 0,price:r.options.price,busy:r.busy,error:r.error,step:r.plain||r.screen==="survey"?1:r.screen==="offer"?2:3,steps:r.plain?1:3}}let n=ie();if(n)return n;s&&!fe&&(s=null);let i=c.find(l=>!E.has(l.id));return i?{type:"message",message:i}:null},M=()=>{let n=ae();(n==null?void 0:n.type)==="message"&&!g.has(`m:${n.message.id}`)&&(g.add(`m:${n.message.id}`),e.track(tt,{message:n.message.id,journey:n.message.journey,action:"shown"}));for(let i of [...h])try{i();}catch(l){}},J=n=>s===n.id?true:s&&G(s)&&!se(G(s))?false:(s=n.id,e.track(re,{flow:n.id,action:"started"}),M(),true),ke=()=>{var i;if(!S||s||!a||!e.personId()&&!((i=e.storage)!=null&&i.call(e)))return;let n=z().find(l=>_n(l.trigger)&&le(l).length&&!se(l));n&&J(n);},Ie=()=>{let n=e.personId();v!==null&&v!==n&&(k.clear(),$.clear(),E.clear(),s=null,C=void 0),v=n;let i=(async()=>{var p,_,I;let l=(p=e.storage)==null?void 0:p.call(e);if(l)try{let b=await l.get(ue(n));b&&P(JSON.parse(b));let y=await l.get(j(n));if(y)for(let x of JSON.parse(y))typeof x=="string"&&$.add(x);}catch(b){}let m=z().length>0||!!(t!=null&&t.messages);if(n&&m&&C!==n){C=n;let b=await e.fetchInApp(n).catch(()=>null);if(b&&e.personId()===n){P(b.onboarding);for(let y of (_=b.events)!=null?_:[])typeof y=="string"&&$.add(Ae(y));c=((I=b.messages)!=null?I:[]).filter(y=>y&&y.id&&y.title);}}n||(c=[]),a=true,ke(),M();})();return f=i.finally(()=>{f===i&&(f=null);}),f},D=(n,i,l)=>{var p;let m=n.reason?n.flow.offers[n.reason]:void 0;return {outcome:i,run:n.run,...n.reason?{reason:n.reason,reasonLabel:(p=n.flow.reasons.find(_=>_.id===n.reason))==null?void 0:p.label}:{},...i==="saved"&&m?{offer:m}:{},...l!=null&&l.trim()?{comment:l.trim().slice(0,500)}:{}}},U=(n,i)=>{var l;e.track(Ee,{action:"finished",run:n.run,version:n.flow.version,outcome:i.outcome,customer:(l=n.options.customer)!=null?l:"consumer",...i.reason?{reason:i.reason}:{},...i.offer?{offer:i.offer.kind}:{},...i.comment?{comment:i.comment}:{}}),r===n&&(r=null),n.resolve(i),M();},K=(n,i,l)=>{if(n.busy)return;let m=D(n,i,l),p=i==="saved"?n.options.onSave:n.options.onCancel;n.busy=true,n.error=void 0,M(),Promise.resolve().then(()=>p==null?void 0:p(m)).then(()=>U(n,m),()=>{n.busy=false,n.error=En,M();});};return {setConfig:n=>{t=n,s&&!G(s)&&(s=null),M();},refresh:Ie,onEvent:n=>{var I;if(!n||n.startsWith("$"))return;let i=Ae(n),l=!!i&&!$.has(i);l&&$.add(i);let m=G(s),p=false;if(m){let b=H(m.id);for(let y of rt(le(m)))y.kind==="checklist"&&y.event&&!b.done.has(y.id)&&nt(y.event,n)&&(oe(b,y.id),p=true,e.track(re,{flow:m.id,step:y.id,kind:y.kind,action:"completed"}));}if(p||l&&m?(V(),M()):l&&V(),!S||!e.personId()&&!((I=e.storage)!=null&&I.call(e)))return;let _=z().find(b=>le(b).length&&nt(b.trigger,n)&&!se(b));_&&J(_);},openCancelFlow:(n={})=>{var I,b;if(r)return r.promise;let i=(I=t==null?void 0:t.cancelFlow)!=null?I:vn,l=n.customer!=="business"||i.reasons.length<2,m=()=>{},p=new Promise(y=>m=y),_={flow:i,options:n,plain:l,screen:l?"confirm":"survey",run:Sn(),busy:false,resolve:m,promise:p};return r=_,e.track(Ee,{action:"shown",run:_.run,version:i.version,customer:(b=n.customer)!=null?b:"consumer",plain:l}),M(),p},startOnboarding:n=>{let i=n?G(n):z().find(m=>le(m).length&&!se(m));if(!i||!le(i).length)return false;let l=H(i.id);return l.dismissed=false,J(i)},view:ae,subscribe:n=>(h.add(n),()=>h.delete(n)),cancel:{pick:n=>{!r||r.busy||!r.flow.reasons.some(i=>i.id===n)||(r.reason=n,r.error=void 0,M());},next:()=>{let n=r;!n||n.screen!=="survey"||!n.reason||(e.track(Ee,{action:"answered",run:n.run,version:n.flow.version,reason:n.reason}),n.screen=n.flow.offers[n.reason]?"offer":"confirm",M());},accept:n=>{let i=r;if(!i||i.screen!=="offer"||!i.reason)return;let l=i.flow.offers[i.reason];i.busy||e.track(Ee,{action:"offer",run:i.run,version:i.flow.version,reason:i.reason,offer:l==null?void 0:l.kind,outcome:"accepted"}),K(i,"saved",n);},decline:()=>{var i;let n=r;!n||n.screen!=="offer"||n.busy||(e.track(Ee,{action:"offer",run:n.run,version:n.flow.version,reason:n.reason,offer:n.reason?(i=n.flow.offers[n.reason])==null?void 0:i.kind:void 0,outcome:"declined"}),n.screen="confirm",n.error=void 0,M());},confirm:n=>{let i=r;!i||i.screen!=="confirm"||K(i,"cancelled",n);},close:()=>{var l,m;let n=r;if(!n||n.busy)return;let i=D(n,"kept");(m=(l=n.options).onClose)==null||m.call(l,i),U(n,i);}},onboarding:{next:()=>{let n=ie();(n==null?void 0:n.type)==="step"&&(oe(H(n.flow.id),n.step.id),e.track(re,{flow:n.flow.id,step:n.step.id,kind:n.step.kind,action:"completed"}),V(),M());},check:n=>{let i=ie();if((i==null?void 0:i.type)!=="checklist")return;let l=i.items.find(m=>m.step.id===n);!l||l.done||(oe(H(i.flow.id),n),e.track(re,{flow:i.flow.id,step:n,kind:"checklist",action:"completed"}),V(),M());},dismiss:()=>{let n=ie();!n||n.type!=="step"&&n.type!=="checklist"||(H(n.flow.id).dismissed=true,e.track(re,{flow:n.flow.id,...n.type==="step"?{step:n.step.id}:{},action:"dismissed"}),s=null,V(),M());}},message:{click:()=>{var l;let n=ae();if((n==null?void 0:n.type)!=="message")return;E.add(n.message.id),e.track(tt,{message:n.message.id,journey:n.message.journey,action:"clicked"});let i=In(n.message.url);M(),i&&((l=e.openUrl)==null||l.call(e,i));},dismiss:()=>{let n=ae();(n==null?void 0:n.type)==="message"&&(E.add(n.message.id),e.track(tt,{message:n.message.id,journey:n.message.journey,action:"dismissed"}),M());}}}};var Pn="ck_pick",$n="ck_origin",Ne=e=>typeof CSS!="undefined"&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,t=>`\\${t}`),Mn=e=>[...e.classList].filter(t=>t.length<30&&!/\d{2,}|[_-][a-z0-9]{5,}$|^(is|has)-|hover|active|focus|open|selected|:|\[/.test(t)).slice(0,2),jt=e=>{let t=e.ownerDocument,r=f=>{try{return t.querySelectorAll(f).length===1}catch(C){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(`#${Ne(e.id)}`))return `#${Ne(e.id)}`;let c=[],a=e;for(;a&&a!==t.documentElement&&c.length<6;){if(a!==e&&a.id&&!/\d{3,}/.test(a.id)){c.unshift(`#${Ne(a.id)}`);break}let f=a.tagName.toLowerCase(),C=Mn(a).map(h=>`.${Ne(h)}`).join(""),v=a.parentElement,k=v?[...v.children].filter(h=>h.tagName===a.tagName):[],E=k.length>1?`:nth-of-type(${k.indexOf(a)+1})`:"";c.unshift(`${f}${C}${E}`);let g=c.join(" > ");if(r(g))return g;a=v;}return c.join(" > ")},Ht=()=>{var E;if(typeof window=="undefined"||window.top===window)return null;let e=new URLSearchParams(window.location.search);if(e.get(Pn)!=="1")return null;let t;try{t=new URL((E=e.get($n))!=null?E:"").origin;}catch(g){return null}if(!/^https?:\/\//.test(t))return null;let r=g=>window.parent.postMessage(g,t),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 c=document.createElement("div");Object.assign(c.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(c),document.body.appendChild(s);let a=null,f=g=>{if(a=g&&g!==s&&!s.contains(g)?g:null,!a){s.style.display="none";return}let h=a.getBoundingClientRect();Object.assign(s.style,{display:"block",left:`${h.left-2}px`,top:`${h.top-2}px`,width:`${h.width+4}px`,height:`${h.height+4}px`}),c.textContent=jt(a);},C=g=>f(document.elementFromPoint(g.clientX,g.clientY)),v=g=>{var S,$;g.preventDefault(),g.stopPropagation();let h=(S=document.elementFromPoint(g.clientX,g.clientY))!=null?S:a;!h||h===s||r({type:"mrrocket:picked",selector:jt(h),text:(($=h.textContent)!=null?$:"").trim().replace(/\s+/g," ").slice(0,80)});},k=g=>{g.key==="Escape"&&r({type:"mrrocket:pick-cancel"});};return window.addEventListener("mousemove",C,true),window.addEventListener("click",v,true),window.addEventListener("keydown",k,true),r({type:"mrrocket:pick-ready"}),()=>{window.removeEventListener("mousemove",C,true),window.removeEventListener("click",v,true),window.removeEventListener("keydown",k,true),s.remove();}};var An={get:e=>{try{return window.localStorage.getItem(e)}catch(t){return null}},set:(e,t)=>{try{window.localStorage.setItem(e,t);}catch(r){}}},Kt=()=>{try{for(let e=window.localStorage.length-1;e>=0;e--){let t=window.localStorage.key(e);t!=null&&t.startsWith("mrrocket:onboarding")&&window.localStorage.removeItem(t);}}catch(e){}},Wt=e=>({track:e.track,personId:e.personId,auto:e.auto,storage:()=>e.canStore()?An:null,openUrl:t=>window.location.assign(t),path:()=>window.location.pathname,fetchInApp:async t=>{if(!e.apiKey)return null;let r=await fetch(`${e.host}/api/sdk/inapp?key=${encodeURIComponent(e.apiKey)}&distinctId=${encodeURIComponent(t)}`);return r.ok?await r.json():null}});var De="mrr_ref",Ue="mrr_ref",Nn="mrr_ref",Ln="mrr_click";var _e=/^[A-Za-z0-9_-]{1,64}$/;var Tn=(e,t="ref")=>{let r=new URLSearchParams(e);return Dn(s=>r.get(s),t)},Dn=(e,t="ref")=>{let r=e(Nn);if(r&&_e.test(r)){let c=e(Ln);return {code:r,clickId:c&&_e.test(c)?c:null,direct:false}}let s=e(t);return s&&_e.test(s)?{code:s,clickId:null,direct:true}:null},Vt=e=>{var t;return `${e.code}.${(t=e.clickId)!=null?t:""}.${e.at}`},Le=(e,t=60,r=Date.now())=>{if(!e)return null;let[s,c,a]=e.split("."),f=Number(a);return !s||!_e.test(s)||!Number.isFinite(f)||c&&!_e.test(c)||r-f>t*864e5||f>r+864e5?null:{code:s,clickId:c||null,at:f}};var T=null,je=()=>typeof document!="undefined",Bt=e=>{var r;if(!je())return;let t=(r=document.cookie.split("; ").find(s=>s.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);try{return t?decodeURIComponent(t):void 0}catch(s){return t}},He=()=>{try{return typeof localStorage=="undefined"?null:localStorage}catch(e){return null}},ot=()=>{var e,t;return T||(je()?(t=Le(Bt(De),3650))!=null?t:Le((e=He())==null?void 0:e.getItem(Ue),3650):null)};var Te=(e,t)=>{var c;if(!je())return;let r=Math.max(1,Math.round(t))*86400,s=typeof location!="undefined"&&location.protocol==="https:"?"; secure":"";document.cookie=`${De}=${encodeURIComponent(Vt(e))}; path=/; max-age=${r}; samesite=lax${s}`;try{(c=He())==null||c.setItem(Ue,Vt(e));}catch(a){}},Ke=()=>{var e;if(je()){document.cookie=`${De}=; path=/; max-age=0; samesite=lax`;try{(e=He())==null||e.removeItem(Ue);}catch(t){}}},qt=()=>{T=null;},Yt=async e=>{var s,c,a;let t=Tn(e.search,e.param),r=(s=e.now)!=null?s:Date.now();if(!t)return !T&&e.store&&(T=(a=Le(Bt(De),e.days,r))!=null?a:Le((c=He())==null?void 0:c.getItem(Ue),e.days,r),T||Ke()),T;if(T={code:t.code,clickId:t.clickId,at:r},e.store&&Te(T,e.days),e.beacon)try{let f=await e.beacon({code:t.code,clickId:t.clickId});f&&T&&T.code===t.code&&!T.clickId&&(T={...T,clickId:f},e.store&&Te(T,e.days));}catch(f){}return T},Xt=e=>e==="$identify"||!e.startsWith("$");var st=3600*24*365,Gt=e=>{var r;if(typeof document=="undefined")return;let t=(r=document.cookie.split("; ").find(s=>s.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);if(t)try{return decodeURIComponent(t)}catch(s){return t}},We=(e,t,r)=>{let s=window.location.protocol==="https:"?"; secure":"";document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${r}; samesite=lax${s}`;},Se=e=>{document.cookie=`${e}=; path=/; max-age=0; samesite=lax`;},A={utm:{}},Jt=()=>{var e;return (e=A.id)!=null?e:A.id=et()},it=(e,t)=>{if(e!=="cookies")return Jt();let r=Gt(ce);if(r)return A.id=r;let s=Jt();return We(ce,s,st),s},at=e=>{var c;let t=Date.now(),r=A.session,s=(c=e?Gt(he):void 0)!=null?c:r&&t-r.last<18e5?r.id:et();return A.session={id:s,last:t},e&&We(he,s,18e5/1e3),s},ct=()=>{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 t=Pt(window.location.search);Object.keys(t).length&&(A.utm=t);},Qt=()=>{let e=navigator,t=window;return e.doNotTrack==="1"||t.doNotTrack==="1"||e.globalPrivacyControl===true};var Ve=window,jn=()=>{var e,t;return (t=(e=document.currentScript)!=null?e:document.querySelector('script[data-key][src*="sdk"]'))!=null?t:document.querySelector("script[data-key][src*='mrrocket']")},Zt=new Set,X=e=>{Zt.has(e)||(Zt.add(e),console.warn(`[MRRocket] ${e}`));},Hn=()=>{var kt,yt,bt,xt;let e=jn(),t=o=>{var d;return (d=e==null?void 0:e.getAttribute(`data-${o}`))!=null?d:void 0},r=(o,d)=>{let u=t(o);return u===void 0?d:!["false","0","off","no"].includes(u.trim().toLowerCase())},s=(kt=e==null?void 0:e.src)!=null?kt:"",c="";try{c=s?new URL(s,window.location.href).origin:"";}catch(o){c="";}let a=((yt=t("key"))!=null?yt:"").trim(),f=((bt=t("api-host"))!=null?bt:c).trim().replace(/\/+$/,""),C=t("consent"),v=r("respect-dnt",false),k=r("heatmaps",true),E=r("errors",true),g=t("release"),h=t("attribution"),S=h==="always"||h==="off"?h:"consent",$=t("referral-param")||"ref",L={},N=(o,d)=>{var u;return (u=L[o])!=null?u:L[o]=new Promise((w,R)=>{var Ct;let F=()=>Ve[d];if(F())return w(F());let q=(Ct=t(`${o}-src`))!=null?Ct:s?s.replace(/(\.min)?\.js(\?[^#]*)?(#.*)?$/,`-${o}$1.js?v=${Me}`):"";if(!q)return R(new Error(o));let ne=document.createElement("script");ne.async=true,ne.src=q,ne.onload=()=>F()?w(F()):R(new Error(o)),ne.onerror=()=>R(new Error(o)),document.head.appendChild(ne);}).catch(w=>{throw L[o]=void 0,w})},z=t("theme"),G={theme:z==="light"||z==="dark"?z:"auto",accent:t("accent")},H=new URLSearchParams(window.location.search),Q=$t(H.get(Ot)),W=H.get(Ft)==="1";W&&Ht();let oe=H.get(Ce);if(oe!==null){H.delete(Ce);let o=H.toString();history.replaceState(history.state,"",`${window.location.pathname}${o?`?${o}`:""}${window.location.hash}`);}let Be=Qt(),de=C==="cookies"||C==="off"?C:"cookieless",se=r("replay",false),ue="",j,V,P=null,Z=false,fe=false,ie=null,ae=null,M=window.location.pathname,J=[],ke=new Set,Ie=[],D=()=>v&&Be?"off":de,U=()=>!W&&D()!=="off",K=()=>j!=null?j:ue,pe=()=>D()==="cookies"?K():j;a||X('No public key. Add data-key="mrr_pub_\u2026" to the script tag; nothing is tracked until then.');let Oe=(o=false)=>{if(!J.length)return;if(!a){J.length=0;return}let d=`${f}/api/sdk/events`;for(let u of vt(a,J.splice(0),{v:Me,errors:E,platform:"web"}))o&&"sendBeacon"in navigator&&navigator.sendBeacon(d,u)||fetch(d,{method:"POST",headers:{"content-type":"application/json"},body:u,keepalive:true}).then(R=>{R.ok||X(`Events were rejected with ${R.status}. Check data-key (MRRocket \u203A Settings \u203A Products).`);}).catch(()=>X(`Could not reach ${f||"this origin"} to send events. Check data-api-host.`));},n=null,i=null,l=(o,d,u=Date.now(),w)=>{if(!U())return;let R=Xt(o)?ot():null;J.push({event:o,props:R?{...d,$referral:{code:R.code,clickId:R.clickId}}:d,distinctId:pe(),sessionId:at(D()==="cookies"),ts:u,url:w!=null?w:window.location.href,referrer:A.referrer,...A.utm,screen:{w:window.screen.width,h:window.screen.height}});},m=(o,d)=>{typeof o!="string"||!o||(l(o,d),U()&&(n==null||n.event(o)),p.onEvent(o));},p=Ut(Wt({host:f,apiKey:a,track:l,personId:()=>U()?j:void 0,canStore:()=>D()==="cookies",auto:r("onboarding",true)})),_=false,I;p.subscribe(()=>{_||!p.view()||W||(_=true,N("flows","__mrrocketFlows").then(o=>o.mountFlows(p,G)).catch(()=>{_=false,X("The cancel flow and onboarding dialogs did not load. Check that sdk-flows.js is served next to sdk.js.");}));});let b=(o,d)=>{if(!U())return;let u=`${window.location.pathname}|${o}`;ke.has(u)||(ke.add(u),m("$exposure",{experiment:o,variant:d}));},y=()=>{let o=At(P,window.location.href,K(),Q);return o!=null&&o.to?(Oe(true),window.location.replace(o.to),true):(o!=null&&o.experiment&&b(o.experiment,o.variant),false)},x=()=>{if(!P)return;let o=document.querySelectorAll("[data-ck-text]");if(!o.length)return;let d=Mt(P,K(),Q),u=new Set;o.forEach(w=>{var q,ne;let R=w.dataset.ckText;if(!R)return;u.add(R),w.dataset.ckDefault===void 0&&(w.dataset.ckDefault=(q=w.textContent)!=null?q:"");let F=(ne=d[R])!=null?ne:w.dataset.ckDefault;w.textContent!==F&&(w.textContent=F);});for(let w of P.experiments)w.variants.some(R=>{var F;return Object.keys((F=R.changes)!=null?F:{}).some(q=>u.has(q))})&&b(w.key,Re(w.key,P,K(),Q));},O=()=>{var o,d;return (d=(o=P==null?void 0:P.referral)==null?void 0:o.cookieDays)!=null?d:60},B=()=>S==="always"?D()!=="off":S==="consent"&&D()==="cookies",ye=null,Y=false,qe=()=>{if(!Z||W)return;if(S==="off"||D()==="off"){qt(),(S==="off"||Y)&&Ke();return}let o=window.location.href;ye!==o&&(ye=o,Yt({search:window.location.search,param:$,store:B(),days:O(),beacon:a?({code:d,clickId:u})=>fetch(`${f}/api/sdk/affiliate/click`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:a,code:d,clickId:u,url:o,referrer:document.referrer||void 0}),keepalive:true}).then(w=>w.ok?w.json():null).then(w=>{var R;return (R=w==null?void 0:w.clickId)!=null?R:null}):void 0}));},tn=()=>{let o=B(),d=ot();o&&d?Te(d,O()):!o&&Y&&Ke(),Y=o;},lt=0,dt=false,ut=()=>{var w,R;let o=U()&&se&&!!(P!=null&&P.replay)&&!!a;if(o===dt)return;dt=o;let d=++lt;if(!o){n==null||n.stop(true),n=null;return}let u=(R=(w=P==null?void 0:P.replay)==null?void 0:w.sampleRate)!=null?R:.1;N("replay","__mrrocketReplay").then(F=>F.startReplay({host:f,apiKey:a,sessionId:at(D()==="cookies"),distinctId:pe(),identified:!!j,sampleRate:u,warn:X})).then(F=>{d!==lt?F==null||F.stop(true):n=F;}).catch(()=>X("Session recording could not start (the recorder did not load)."));},ft=r("messenger",false),ee=null,ge=o=>{W||a&&(ee!=null||(ee=N("messenger","__mrrocketMessenger").then(d=>{var F;let u=q=>t(`messenger-${q}`)===void 0?void 0:r(`messenger-${q}`,true),w=t("messenger-position"),R=(F=t("messenger-theme"))!=null?F:z;return d.mountMessenger({host:f,apiKey:a,distinctId:K,user:()=>V,launcher:ft,position:w==="bottom-left"||w==="bottom-right"?w:void 0,title:t("messenger-title"),greeting:t("messenger-greeting"),label:t("messenger-label"),askEmail:u("ask-email"),help:u("help"),sound:u("sound"),preview:u("preview"),theme:R==="light"||R==="dark"||R==="auto"?R:void 0,accent:t("accent")})})),ee.then(o).catch(()=>{ee=null,X("sdk-messenger.js did not load.");}));},pt=t("forms")==="auto",Ye=false,Xe=()=>{Ye||!a||W||!document.querySelector(pt?"form":"form[data-mrrocket-form]")||(Ye=true,N("forms","__mrrocketForms").then(o=>o.watchForms({host:f,apiKey:a,auto:pt,distinctId:()=>U()?pe():void 0,identified:()=>!!j,identify:ht,tracking:U,referrer:()=>A.referrer,utm:()=>A.utm})).catch(()=>Ye=false));},ze=()=>{!fe||!U()||ae===window.location.pathname||(ae=window.location.pathname,m("$pageview",{path:window.location.pathname}));},te=null,gt=()=>{let o=te;k&&o&&o.max>0&&l("$scroll",{depth:o.max,docH:o.docH,vw:window.innerWidth,vh:window.innerHeight},Date.now(),o.url),te=null;},be=()=>{var R,F;if(!k||!U()||W)return;let o=document.documentElement,d=Math.max(o.scrollHeight,(F=(R=document.body)==null?void 0:R.scrollHeight)!=null?F:0),u=St(),w=window.location.href;(te==null?void 0:te.url)!==w?te={url:w,max:u,docH:d}:u>te.max&&(te={url:w,max:u,docH:d});},mt=()=>{let o=window.location.pathname;o!==M&&(M=o,!(Z&&y())&&(gt(),ct(),n==null||n.page(o),i==null||i.crumb("navigation",o),ze(),qe(),window.setTimeout(()=>{be(),x(),Xe();},0)));},wt=()=>{let o=D(),d=ie;ie=o,d==="cookies"&&o!=="cookies"&&(Se(ce),Se(he)),o==="off"&&(J.length=0,A.session=void 0),d==="cookies"&&o!=="cookies"&&Kt(),ue=it(o),tn(),qe(),ut(),ze(),be();},nn=o=>{let{analytics:d,replay:u}=typeof o=="string"?{analytics:o,replay:void 0}:o!=null?o:{};if(d!==void 0&&d!=="cookieless"&&d!=="cookies"&&d!=="off"){X(`setConsent: "${String(d)}" is not a consent mode. Use "cookieless", "cookies" or "off".`);return}d==="off"&&(J.length=0),d&&(de=d),typeof u=="boolean"&&(se=u),wt(),Z&&p.refresh();},ht=(o,d)=>{if(typeof o!="string"||!o)return;let u=pe();j=o,l("$identify",{...d,id:o,...u&&u!==o?{previousId:u}:{}}),n==null||n.identify(o),D()==="cookies"&&We(ce,o,st),V={...d,id:o},x(),Z&&p.refresh();},Fe={track:m,identify:ht,reset:()=>{j=void 0,V=void 0,ke.clear(),D()==="cookies"&&(Se(ce),Se(he)),A.id=void 0,A.session=void 0,ue=it(D()),x(),Z&&p.refresh();},captureError:o=>i==null?void 0:i.capture(o,"manual"),setConsent:nn,getFlag:o=>Ze(o,P,K(),{...V})!==false,getFlagVariant:o=>{let d=Ze(o,P,K(),{...V});return typeof d=="string"?d:null},getVariant:o=>{let d=Re(o,P,K(),Q);return (P||Q[o])&&b(o,d),d},ready:o=>{typeof o=="function"&&(Z?window.setTimeout(()=>o(Fe),0):Ie.push(o));},getDistinctId:K,cancelFlow:{open:o=>p.openCancelFlow(o)},onboarding:{start:o=>p.startOnboarding(o)},openCancelFlow:o=>p.openCancelFlow(o),startOnboarding:o=>p.startOnboarding(o),paywall:{open:(o,d)=>(I!=null?I:I=N("flows","__mrrocketFlows").then(u=>u.paywallHost({config:()=>P,distinctId:K,track:l},G))).then(u=>u.open(o,d))},push:{subscribe:o=>{let d=U()?j:void 0;if(!d)return Promise.resolve({status:"not-signed-in"});let u=window.Notification,w=Promise.resolve(u&&u.permission==="default"&&(o==null?void 0:o.ask)!==false?u.requestPermission():u==null?void 0:u.permission);return N("push","__mrrocketPush").then(R=>R.subscribeWebPush({host:f,apiKey:a,distinctId:d,permission:w},o))},unsubscribe:()=>N("push","__mrrocketPush").then(o=>o.unsubscribeWebPush({host:f,apiKey:a,distinctId:j}))},messenger:{open:o=>ge(d=>d.open(o)),close:()=>{ee==null?void 0:ee.then(o=>o.close()).catch(()=>{});},toggle:()=>ge(o=>o.toggle())},openMessenger:()=>ge(o=>o.open()),version:Me};ct(),wt();let me=Ve.mrrocket,rn=(xt=me==null?void 0:me.q)!=null?xt:[],Je=me&&typeof me=="object"?me:{};Object.assign(Je,Fe,{__loaded:true}),delete Je.q,Ve.mrrocket=Je;for(let[o,d]of rn){let u=Fe[o];if(typeof u=="function")try{u(...Array.from(d!=null?d:[]));}catch(w){console.error(w);}}fe=true,ze(),E&&a&&!W&&(i=Lt({host:f,apiKey:a,release:g,context:()=>{var o;return {send:U(),distinctId:pe(),sessionId:(o=A.session)==null?void 0:o.id}},warn:X}),i.crumb("navigation",window.location.pathname));for(let o of ["pushState","replaceState"]){let d=history[o];history[o]=function(...u){let w=d.apply(this,u);return mt(),w};}window.addEventListener("popstate",mt);let on=new xe;document.addEventListener("click",o=>{var F;o.target instanceof Element&&o.target.closest("[data-ck-messenger]")&&(o.preventDefault(),ge(q=>q.open()));let d=o.target instanceof Element?o.target.closest("[data-ck-goal]"):null;if(d!=null&&d.dataset.ckGoal&&m(d.dataset.ckGoal,{text:(F=d.textContent)==null?void 0:F.trim().slice(0,80)}),!U())return;let u=_t(o);if(!u)return;let w=on.push(u.x,u.y,Date.now());if((u.label||u.selector)&&(i==null||i.crumb("click",u.label||u.selector)),n==null||n.click(u,w),!k)return;let R={x:u.x,y:u.y,vw:u.vw,vh:u.vh,docH:u.docH,selector:u.selector,label:u.label,dead:!u.interactive};l("$click",R),w&&l("$rageclick",R);});let Ge=0;window.addEventListener("scroll",()=>{Ge||(Ge=window.requestAnimationFrame(()=>{Ge=0,be();}));},{passive:true}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>be()):be(),window.setInterval(()=>Oe(),2e3),window.addEventListener("pagehide",()=>{gt(),Oe(true);});let Qe=()=>{if(Z=true,y())return;let o=Nt(P,oe);o&&b(o.experiment,o.variant),document.documentElement.classList.remove("ck-hide"),qe(),ut(),p.setConfig(P),p.refresh(),ft&&(document.body?ge():document.addEventListener("DOMContentLoaded",()=>ge())),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{x(),Xe();}):(x(),Xe());for(let d of Ie.splice(0))try{d(Fe);}catch(u){console.error(u);}};a?fetch(`${f}/api/sdk/config?key=${encodeURIComponent(a)}`).then(o=>(o.ok||X(`Config request to ${f||"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),Qe();}).catch(()=>{X(`Could not reach ${f||"this origin"}. Check data-api-host. The page keeps its own texts and flags stay off.`),Qe();}):Qe();},en;typeof window!="undefined"&&typeof document!="undefined"&&!((en=Ve.mrrocket)!=null&&en.__loaded)&&Hn();
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,