@mrrocket/sdk 0.23.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,21 +2,27 @@
2
2
 
3
3
  All notable changes to this package. It follows semantic versioning; before 1.0 a minor version may change an API.
4
4
 
5
- ## 0.23.0 (not published yet)
5
+ ## 0.23.1 (not published yet)
6
6
 
7
- - `setConsent("off")` (or the `consent` prop turning off) while someone is signed in sends one `$consent_off` with their id and nothing else. MRRocket stores no event for it: it marks the person, so lists by rule stop sorting them by what they do. Anonymous visitors send nothing, as before.
7
+ - **Withdrawing consent now reaches MRRocket from the React provider.** In 0.23.0 `$consent_off` waited in the queue, and the provider's consent effect emptied the queue before anything was sent, so it never went out. It now goes at once, by beacon or `fetch` with `keepalive`, signed with `userHash`, and arrives even if the page closes right after. Everything else in the queue is still dropped. Nothing goes out for an anonymous visitor, a page that starts with consent off, or a browser's privacy signal. The script tag and React Native sent it correctly already.
8
+ - Version reported in event batches: `0.23.1`.
8
9
 
9
- ## 0.22.0 (not published yet)
10
+ ## 0.23.0
10
11
 
11
- - **Onboarding in your own code (web, script tag and React Native):** `useOnboardingReport(name, { order, type })` (script tag `mrrocket.onboarding.report(name, options)`) with `saw(step, title)`, `answered(question, answer, label)`, `done(step)` and `closed(step)`. Nothing to set up in MRRocket: the first report makes the item under Onboarding, marked "From your code". MRRocket shows who saw each step and what they answered, and keeps the answers on the contact. It follows the visitor's consent like any other event.
12
- - `useOnboarding(id)` for items already drawn by the app keeps working.
12
+ - `setConsent("off")` (or the `consent` prop turning off) while someone is signed in sends one `$consent_off` with their id and nothing else. MRRocket stores no event for it: it marks the person, so lists by rule stop sorting them by what they do. Anonymous visitors send nothing, as before. **In the React provider this did not work; see 0.23.1.**
13
13
  - **The messenger opens with what it knows (web and script tag):** a visitor's conversations and the Help and Updates tabs show at once from what the browser kept for that visitor, and the read brings them up to date. Home has no grey bar any more: what is still coming shows as the shape of its rows, and a tab appears only once there is something in it, so none shows and then goes away.
14
14
  - **The AI agent is named beside its answers (web, script tag and React Native):** an answer shows "Cass · AI agent" under it instead of a line at the end of its text. A custom agent name always keeps "AI agent" beside it. Older versions of the SDK keep the line.
15
15
  - **A slow or failed read of the chat is asked again soon** instead of at the panel's next 30 s turn, and whoever signs in after the page loaded gets their conversations at once.
16
16
  - **A message the team takes back leaves the count and the preview too (web, script tag and React Native):** an open chat already drops it at the next read, on any version; the launcher's count and preview card now do as well.
17
+ - Version reported in event batches: `0.23.0`.
18
+
19
+ ## 0.22.0
20
+
21
+ - **Onboarding in your own code (web, script tag and React Native):** `useOnboardingReport(name, { order, type })` (script tag `mrrocket.onboarding.report(name, options)`) with `saw(step, title)`, `answered(question, answer, label)`, `done(step)` and `closed(step)`. Nothing to set up in MRRocket: the first report makes the item under Onboarding, marked "From your code". MRRocket shows who saw each step and what they answered, and keeps the answers on the contact. It follows the visitor's consent like any other event.
22
+ - `useOnboarding(id)` for items already drawn by the app keeps working.
17
23
  - Version reported in event batches: `0.22.0`.
18
24
 
19
- ## 0.21.0 (not published yet, together with 0.20.0)
25
+ ## 0.21.0 (includes 0.20.0, which was never published on its own)
20
26
 
21
27
  - **Onboarding questions (web, script tag and React Native):** a number scale (`type: "scale"` with `min`, `max`, `lowLabel`, `highLabel`), an "Other" option where people type their own words (`other`, `otherLabel`; stored as `other:<words>`), and a Skip button on an optional question (`optional`, `skipLabel`; `onboarding.skip()` records `skipped: true`). An older app shows a scale as a text field, leaves "Other" out and offers no Skip.
22
28
  - **Dialogs animate only when they open (web and script tag):** picking an answer no longer replays the fade, so it stops looking like the page reloading. Questions, a modal and the cancel flow also stay still from slide to slide, as a paywall does; closing and opening again animates. A checklist and a banner stay still when they redraw; a tour's card still comes in at each step, since it moves to another element.
@@ -51,7 +57,7 @@ All notable changes to this package. It follows semantic versioning; before 1.0
51
57
  - **Instant send (web):** a message shows at once and reads "just now"; "Sending…" only when the server takes longer than 1.5 s. The next message can be typed and sent while one is on its way (they go out in order); one that fails comes back into the field with those after it. React Native shows "Sending…" after 1.5 s the same way. MRRocket now answers a send before running its rules and AI answers, so the wait is short anyway.
52
58
  - **The AI agent by name:** MRRocket's look now always sends `agentName` and `agentPhoto` (the Customer experience agent's own name and picture where the owner set none), and a reply that started as the agent's draft comes as `from: "ai"` even when a person pressed Send. Works with 0.17 and later, nothing to change.
53
59
 
54
- ## 0.17.0 (not published yet)
60
+ ## 0.17.0
55
61
 
56
62
  - **Onboarding as tours, checklists and modals:** MRRocket's onboarding items are now one type each and arrive as plain lists (no `nodes`). Older configs without the new fields behave as before.
57
63
  - **The bubble's side:** tour steps take `placement` (`"auto" | "top" | "bottom" | "left" | "right"`, type `TourPlacement`). Auto keeps the old placing (below, above when there is no room); a chosen side flips to the opposite one, then to any side with room. The card now has an arrow pointing at the element and is placed again once it has its real height (a picture loading too).
@@ -64,7 +70,7 @@ All notable changes to this package. It follows semantic versioning; before 1.0
64
70
  - `sdk.js` budget 16.25 KB gzip (was 15.75); `sdk-flows.js` grows by about 1.1 KB gzip (8.4 KB) for pictures, videos and the sides.
65
71
  - Version reported in event batches: `0.17.0`.
66
72
 
67
- ## 0.16.0 (not published yet)
73
+ ## 0.16.0
68
74
 
69
75
  - **Identity verification:** your server signs the user id with the product's server key and the SDK sends that signature as `userHash` with every request for the id, so someone who only knows a user's id can no longer read their support chat, register push for them or post feedback and events as them. Server: `userHash(userId, { serverKey? })` from `@mrrocket/sdk/next/server` (WebCrypto only; Node 18+, Edge, Workers; defaults to `MRROCKET_SERVER_KEY`, throws without a key). The formula for other backends: `hex(HMAC-SHA256(key = SHA-256(server key), message = user id))`.
70
76
  - **Client:** `identify(id, props, { hash })` in `useCockpit()`, `window.mrrocket.identify` and the React Native client; `<CockpitProvider userHash>` signs the `distinctId` prop from a server layout. The hash belongs to one id: dropped on `reset()` and on `identify` for another id without one; a value that is not 64 hex characters is never sent. React Native keeps it in memory only.
@@ -74,7 +80,7 @@ All notable changes to this package. It follows semantic versioning; before 1.0
74
80
  - `sdk.js` budget 15.75 KB gzip (was 15.25).
75
81
  - Version reported in event batches: `0.16.0`.
76
82
 
77
- ## 0.14.0 (not published yet)
83
+ ## 0.14.0
78
84
 
79
85
  - **Paywalls with pages:** a paywall from MRRocket › Conversion › Paywalls can have several pages (benefits, customer quotes, plans), served as the config's new `paywalls` per placement. `usePaywall().open(placement, { onPurchase, plans, onClose })` (Next.js and React Native, drawn by the provider), `mrrocket.paywall.open(…)` (script tag) show them one after another with Back and dots; the last page hands the chosen plan to `onPurchase`, where the app buys it (StoreKit/Play through RevenueCat or Adapty, Stripe Checkout). MRRocket never takes a payment; only after `onPurchase` resolves is the purchase recorded (`false`: the store sheet was cancelled, the paywall stays). Resolves with `{ outcome: "purchased" | "chosen" | "closed", plan, variant, index }`.
80
86
  - **Tests per page:** a running paywall test gives each person their variant's pages (`assign`) and records `$exposure` when the paywall opens. New event `$paywall {paywall, placement, variant, page, index, action: "page" | "purchased" | "closed"}`: each page once per opening, so MRRocket shows drop-off between pages; a `purchased` counts as a test's purchase conversion.
@@ -87,7 +93,7 @@ All notable changes to this package. It follows semantic versioning; before 1.0
87
93
  - Nothing changes in the browser: the script tag and the client bundle stay as they were.
88
94
  - Version reported in event batches: `0.13.0`.
89
95
 
90
- ## 0.12.0 (not published yet)
96
+ ## 0.12.0
91
97
 
92
98
  - **Form leads:** a submitted form marked `data-mrrocket-form="<name>"` becomes a contact in MRRocket (`POST /api/sdk/forms`, sent with `sendBeacon`). It sends the email, the name and the other fields a person typed, plus the form's name, page, referrer, UTM and the state of a checkbox marked `data-mrrocket-consent`; never passwords, card, hidden or file fields, fields whose name looks sensitive (`SENSITIVE`) or anything inside `data-mrrocket-ignore`. With analytics consent the lead carries the visitor id and the SDK calls `identify(email)` when your code has not identified the person yet, so their history carries over. Opt-in auto-detection captures any form with an email field and no password field.
93
99
  - **Next.js:** new `forms` prop on `<CockpitProvider>`: `true` (default, marked forms), `"auto"` or `false`; the capture code is a dynamic import.
@@ -1,2 +1,2 @@
1
- (function(){'use strict';var Un=Object.defineProperty;var Hn=(e,n,r)=>n in e?Un(e,n,{enumerable:true,configurable:true,writable:true,value:r}):e[n]=r;var Me=(e,n,r)=>Hn(e,typeof n!="symbol"?n+"":n,r);var Bt=e=>{let n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?n+=1:i<2048?n+=2:i>=55296&&i<=56319&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(n+=4,r++):n+=3;}return n},Dn=(e,n,r,i)=>{let d=`{"key":${JSON.stringify(e)},${i?`"userHash":${JSON.stringify(i)},`:""}"sdk":${JSON.stringify(r)},"events":[`,l=Bt(d)+2,m=[],v=[],_=[],w=l,O=()=>{v.length&&m.push({body:`${d}${v.join(",")}]}`,events:_}),v=[],_=[],w=l;};for(let k of n){let R=JSON.stringify(k),S=Bt(R)+1;l+S>6e4||((v.length===100||w+S>6e4)&&O(),v.push(R),_.push(k),w+=S);}return O(),m},Yt=(e,n,r,i)=>Dn(e,n,r,i).map(d=>d.body);var Ve=class{constructor(n=1e3,r=30,i=3){Me(this,"windowMs",n);Me(this,"radius",r);Me(this,"count",i);Me(this,"clicks",[]);Me(this,"fired",false);}push(n,r,i){let d=this.clicks.filter(l=>i-l.t<=this.windowMs&&Math.hypot(l.x-n,l.y-r)<=this.radius);return d.length!==this.clicks.length&&(this.fired=false),this.clicks=[...d,{x:n,y:r,t:i}],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]',jn="[data-ck-mask]",Vn="[data-ck-block]",Xt=/\d{4,}|^[a-z]{1,3}-[a-z0-9]{5,}$|^_|__|css-|^sc-|^jsx-/i,Kn=e=>{let n=e.tagName.toLowerCase();if(e.id&&!Xt.test(e.id)&&e.id.length<=40)return `${n}#${e.id}`;let r=typeof e.className=="string"?e.className.split(/\s+/).filter(l=>l&&!Xt.test(l)&&l.length<=30&&!l.includes(":")):[],i=r.length?`${n}.${r.slice(0,2).join(".")}`:n,d=e.parentElement?[...e.parentElement.children].filter(l=>l.tagName===e.tagName):[];return d.length>1?`${i}:nth-of-type(${d.indexOf(e)+1})`:i},qn=e=>{let n=[],r=e;for(;r&&n.length<3&&r.tagName&&r.tagName!=="BODY"&&r.tagName!=="HTML";){let i=Kn(r);if(n.unshift(i),i.includes("#"))break;r=r.parentElement;}return n.join(" > ").slice(0,160)},et=e=>(e!=null?e:"").replace(/\s+/g," ").trim().slice(0,40),Bn=e=>{var r,i,d,l,m;if(e.closest(`${jn},${Vn}`))return "";let n=e.tagName.toLowerCase();if(n==="input"){let v=((r=e.getAttribute("type"))!=null?r:"text").toLowerCase();return et(v==="submit"||v==="button"?(i=e.getAttribute("aria-label"))!=null?i:e.value:e.getAttribute("aria-label"))}return et(n==="select"||n==="textarea"?e.getAttribute("aria-label"):(m=(l=(d=e.getAttribute("aria-label"))!=null?d:e.getAttribute("title"))!=null?l:e.innerText)!=null?m:e.textContent)},Jt=e=>{var l,m;let n=e.target instanceof Element?e.target:null;if(!n)return null;let r=n.closest(Wn),i=r!=null?r:n,d=document.documentElement;return {x:Math.round(e.clientX),y:Math.round(e.clientY+window.scrollY),vw:window.innerWidth,vh:window.innerHeight,docH:Math.max(d.scrollHeight,(m=(l=document.body)==null?void 0:l.scrollHeight)!=null?m:0),selector:qn(i),label:r?Bn(r):"",interactive:!!r}},zt=()=>{var r,i;let e=document.documentElement,n=Math.max(e.scrollHeight,(i=(r=document.body)==null?void 0:r.scrollHeight)!=null?i:0);return n?Math.min(100,Math.round((window.scrollY+window.innerHeight)/n*100)):0};var nt="0.23.0",Yn=(e,n)=>{let r=n.trim().toLowerCase();for(let[i,d]of Object.entries(e))if(i.toLowerCase()===r)return d},Xn=(e,n)=>{let r=e.trim().toLowerCase(),i=n.trim().toLowerCase();return i.startsWith("@")?r.endsWith(i):r===i},Jn=(e,n)=>{if(e.op==="in cohort")return false;let r=Yn(n,e.property),i=r==null?"":String(r);if(e.op==="\u2265"){let l=Number(i),m=Number(e.values[0]);return i!==""&&Number.isFinite(l)&&Number.isFinite(m)&&l>=m}let d=i!==""&&e.values.some(l=>Xn(i,l));return e.op==="is"||e.op==="in"?d:!d},zn=(e,n,r={})=>{var v;if(!e.on)return false;let i={id:n,...r},d=e.sets.length?e.sets.find(_=>_.conditions.every(w=>Jn(w,i))):{rollout:100};if(!d||Gt(`${e.key}:rollout:${n}`)*100>=d.rollout)return false;if(!((v=e.variants)!=null&&v.length))return true;let l=Gt(`${e.key}:variant:${n}`)*100,m=0;for(let _ of e.variants)if(m+=_.split,l<m)return _.key;return e.variants[e.variants.length-1].key},vt=(e,n,r,i={})=>{var l;let d=(l=n==null?void 0:n.flags)==null?void 0:l.find(m=>m.key===e);return d?zn(d,r,i):false},Qt="$consent_off",Gn=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],Zt="ck_preview",en="ck_embed",Se="ck_id",Ae="ck_sid";var Qn=e=>{var r;let n={};for(let i of Gn){let d=(r=e(i))==null?void 0:r.trim();d&&(n[i]=d.slice(0,150));}return n},tn=e=>{let n=new URLSearchParams(e);return Qn(r=>n.get(r))};var Zn=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},Gt=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},er=(e,n)=>{var l,m,v,_;let r=(m=(l=e.variants[0])==null?void 0:l.id)!=null?m:"control";if(e.winner)return e.winner;if(e.status!=="running")return r;let i=Zn(`${e.key}:${n}`),d=0;for(let w of e.variants)if(d+=w.weight,i<d)return w.id;return (_=(v=e.variants[e.variants.length-1])==null?void 0:v.id)!=null?_:r},nn=e=>{let n=Array.isArray(e)?e[0]:e;if(!n)return {};let r={};for(let i of n.split(",")){let[d,l]=i.split(":");d&&l&&(r[d.trim()]=l.trim());}return r};var qe=(e,n,r,i)=>{if(i[e])return i[e];let d=n==null?void 0:n.experiments.find(l=>l.key===e);return d?er(d,r):"control"},rn=(e,n,r)=>{var d,l,m,v,_,w;let i={...(d=e==null?void 0:e.texts)!=null?d:{}};for(let O of (l=e==null?void 0:e.experiments)!=null?l:[]){let k=qe(O.key,e,n,r);k!==((v=(m=O.variants[0])==null?void 0:m.id)!=null?v:"control")&&Object.assign(i,(w=(_=O.variants.find(R=>R.id===k))==null?void 0:_.changes)!=null?w:{});}return i},Ke="ck_x",tt=e=>e.replace(/\/+$/,"")||"/",on=(e,n,r,i={})=>{var v,_;if(!e)return null;let d;try{d=new URL(n);}catch(w){return null}if(d.searchParams.has(Ke))return null;let l=tt(d.pathname),m=(w,O)=>{let k;try{k=new URL(w,d);}catch(R){return}if(!(!/^https?:$/.test(k.protocol)||k.origin===d.origin&&tt(k.pathname)===l))return d.searchParams.forEach((R,S)=>{k.searchParams.has(S)||k.searchParams.set(S,R);}),O&&k.searchParams.set(Ke,O),k.hash||(k.hash=d.hash),k.href};for(let w of (v=e.redirects)!=null?v:[]){let O=w.from&&tt(w.from)===l?m(w.to):void 0;if(O)return {to:O}}for(let w of e.experiments){if(!w.path||tt(w.path)!==l)continue;let O=w.status==="running"&&!w.winner;if(O&&r===null&&!i[w.key])return null;let k=qe(w.key,e,r!=null?r:"",i),R=(_=w.variants.find(M=>M.id===k))==null?void 0:_.url,S=R?m(R,O?`${w.key}:${k}`:void 0):void 0;return O?{to:S,experiment:w.key,variant:k}:S?{to:S}:null}return null},sn=(e,n)=>{let[r,i]=(n!=null?n:"").split(":"),d=e==null?void 0:e.experiments.find(l=>l.key===r);return d&&d.variants.some(l=>l.id===i)?{experiment:r,variant:i}:null};var Ot=()=>typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():`ck_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;var tr="401: sign the user id on your server with userHash(id) from @mrrocket/sdk/next/server and pass identify(id, props, { hash }).",Ne=(e,n=r=>console.warn(r))=>{let r=globalThis;e!==401||r.__mrrocketUnsigned||(r.__mrrocketUnsigned=true,n(`[MRRocket] ${tr}`));},an=(e,n,r,i=d=>console.warn(d))=>{let d=typeof r=="string"?r.trim().toLowerCase():"";return /^[0-9a-f]{64}$/.test(d)?{id:n,hash:d}:(d&&i("[MRRocket] identify: that hash is no userHash(id); not sent."),e&&e.id===n?e:null)},cn=(e,n)=>e&&n&&e.id===n?e.hash:void 0,dn=(e,n)=>e&&n.some(r=>r===e.id)&&n.every(r=>!r||r===e.id)?e.hash:void 0;var nr=8*1024,rr=20,or=20,sr=2e3,Be=(e,n)=>e.length>n?`${e.slice(0,n-1)}\u2026`:e,ir=e=>{var n;if(e instanceof Error)return {type:e.name||"Error",message:Be(e.message||String(e),1e3),stack:e.stack?Be(e.stack,nr):void 0};if(typeof e=="string")return {type:"Error",message:Be(e,1e3)};try{return {type:"Error",message:Be((n=JSON.stringify(e))!=null?n:String(e),1e3)}}catch(r){return {type:"Error",message:String(e)}}},ln=e=>{let n=[],r=[],i=new Set,d=0,l=`${e.host}/api/sdk/errors`,m=(R=false)=>{for(;n.length;){let S=n.splice(0,4),M=e.context(),X=M.distinctId&&M.userHash?{id:M.distinctId,hash:M.userHash}:null,T=dn(X,S.map(W=>W.distinctId)),J=JSON.stringify({key:e.apiKey,...T?{userHash:T}:{},errors:S});R&&typeof navigator!="undefined"&&"sendBeacon"in navigator&&navigator.sendBeacon(l,J)||fetch(l,{method:"POST",headers:{"content-type":"application/json"},body:J,keepalive:true}).then(W=>{W.status===401?Ne(401):!W.ok&&W.status!==429&&e.warn(`Error reports were rejected with ${W.status}. Check the public key and NEXT_PUBLIC_MRROCKET_HOST.`);}).catch(()=>{});}},v=(R,S="manual")=>{let M=e.context();if(!M.send||d>=rr)return;let X=ir(R);if(/\/api\/sdk\/errors/.test(X.message))return;let T=`${X.type}:${X.message}`;i.has(T)||(i.add(T),d++,n.push({...X,mechanism:S,handled:S==="manual",url:window.location.href,ts:Date.now(),crumbs:r.slice(),...e.release?{release:e.release}:{},...M.distinctId?{distinctId:M.distinctId}:{},...M.sessionId?{sessionId:M.sessionId}:{}}));},_=R=>{var S;!R.error&&(!R.message||R.message==="Script error.")||v((S=R.error)!=null?S:new Error(R.message),"onerror");},w=R=>{var S;return v((S=R.reason)!=null?S:new Error("Unhandled promise rejection"),"onunhandledrejection")},O=()=>m(true);window.addEventListener("error",_),window.addEventListener("unhandledrejection",w),window.addEventListener("pagehide",O);let k=window.setInterval(()=>m(),sr);return {capture:v,crumb:(R,S)=>{r.push({ts:Date.now(),type:R,message:Be(S,120)}),r.length>or&&r.shift();},stop:()=>{window.removeEventListener("error",_),window.removeEventListener("unhandledrejection",w),window.removeEventListener("pagehide",O),window.clearInterval(k),m(true);}}};var Et=globalThis,un,Q=(un=Et.__mrrocketI18n)!=null?un:Et.__mrrocketI18n={version:0,onWords:new Set,onLocale:new Set},_t=e=>{for(let n of [...e])try{n();}catch(r){}},Ye=e=>{var n;return ((n=Q.words)==null?void 0:n[e])||e};var fn=(e,n)=>{var i;let r=Q.lang===n&&JSON.stringify((i=Q.words)!=null?i:{})===JSON.stringify(e!=null?e:{});Q.words=e,Q.lang=n,!r&&(Q.version++,_t(Q.onWords));},ar=e=>{let n=e==null?void 0:e.trim().replace(/_/g,"-");if(n)try{return Intl.getCanonicalLocales(n)[0]}catch(r){return r instanceof RangeError?void 0:n}},St=e=>{let n=ar(e);n!==Q.locale&&(Q.locale=n,Q.version++,_t(Q.onWords),_t(Q.onLocale));};var rt=()=>{var e,n;return (n=(e=Q.locale)!=null?e:Q.device)!=null?n:typeof navigator!="undefined"&&navigator.language||void 0},ot=()=>{let e=rt();return e?`&lang=${encodeURIComponent(e)}`:""};var pn=e=>(Q.onLocale.add(e),()=>{Q.onLocale.delete(e);});var Xe="$cancel_flow",q="$onboarding",It="$inapp";var cr={version:0,question:"",reasons:[],offers:{},get confirm(){return {title:Ye("Cancel your subscription?"),body:Ye("You keep access until the end of the billing period."),button:Ye("Cancel subscription")}},offersFor:"business"},Ft="mrrocket:onboarding",de=e=>e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),gn=new Set(["signed_up","signup","sign_up","registered","account_created","user_signed_up"]),st=(e,n)=>{let r=de(e),i=de(n);return !r||!i?false:r===i||gn.has(r)&&gn.has(i)},mn=e=>/^(first (launch|visit|open|session|login|sign ?in|app open)|app (opened|launched)|on load|every visit|always)?$/i.test(e.trim());var wn=e=>e.trim().startsWith("/");var dr="Needs tracking code 0.18.0",ce=e=>{var n;return (n=e.when)!=null?n:e.trigger},it=e=>de(e)==="from_a_checklist"||de(e)==="from_your_code"||de(e)===de(dr),hn="after:",at=e=>{let n=(e!=null?e:"").trim();return n.toLowerCase().startsWith(hn)&&n.slice(hn.length).trim()||null},lr=e=>{var n;return (n=e.opens)!=null?n:e.startsTour?{kind:"tour",id:e.startsTour}:void 0},Ie="other:",ur=e=>{var i,d;let n=(i=e==null?void 0:e.min)!=null?i:0,r=(d=e==null?void 0:e.max)!=null?d:10;return Array.from({length:Math.max(0,Math.min(r-n,20)+1)},(l,m)=>n+m)},kn=(e,n)=>{var r;return !e||n==null?false:e.type==="choice"?e.other&&n.startsWith(Ie)?n.slice(Ie.length).trim().length>0:((r=e.options)!=null?r:[]).some(i=>i.id===n):e.type==="scale"?ur(e).some(i=>String(i)===n):n.trim().length>0&&n.length<=500},fr=(e,n)=>{var r,i,d;return (e==null?void 0:e.type)!=="choice"?n.trim():e.other&&n.startsWith(Ie)?n.slice(Ie.length).trim():(d=(i=(r=e.options)==null?void 0:r.find(l=>l.id===n))==null?void 0:i.label)!=null?d:n};var pr=()=>`cf_${Math.random().toString(36).slice(2,10)}${Date.now().toString(36)}`;var dt=e=>{let n=(e!=null?e:"").trim();return /^https?:\/\//i.test(n)||/^\/(?!\/)/.test(n)?n:void 0},ee=e=>{var n;return (n=e.nodes)!=null?n:e.steps},gr=e=>Math.max(0,e.amount)*(e.unit==="hours"?36e5:864e5),$t=(e,n)=>{let r=e.trim(),i=(n.split(/[?#]/)[0]||"/").replace(/\/+$/,"")||"/";if(!r)return false;if(r.endsWith("*")){let d=r.slice(0,-1).replace(/\/+$/,"");return !d||i===d||i.startsWith(`${d}/`)}return i===(r.replace(/\/+$/,"")||"/")},he=e=>e.flatMap(n=>n.kind==="condition"?[...he(n.yes),...he(n.no)]:n.kind==="wait"?[]:[n]),mr=(e,n=Date.now())=>e==null||e===""?NaN:Math.floor((n-new Date(e).getTime())/2630016e3),ct=e=>e==null?void 0:e.trim().toLowerCase(),wr=({when:e={}},n)=>(e.answer==null||ct(e.answer)===ct(n.answer))&&(e.plan==null||[e.plan].flat().some(r=>ct(r)===ct(n.plan)))&&!(n.months>=e.tenureUnder)&&!(n.months<e.tenureOver)&&(e.tenureUnder==null||n.months>=0)&&(e.tenureOver==null||n.months>=0),bn=e=>{let n=null,r=null,i=null,d=[],l=false,m=null,v,_=null,w=new Map,O=new Set,k=new Set,R=new Set,S=e.auto!==false,M=new Set,X=()=>{var t,o;return (o=(t=e.now)==null?void 0:t.call(e))!=null?o:Date.now()},T=null,J=null,z=new Map,W=new Map,ke=new Set,le=null,Ce=()=>{var t;return (t=n==null?void 0:n.onboarding)!=null?t:[]},Le=()=>Ce().filter(t=>t.shownBy!=="code"),j=t=>t?Ce().find(o=>o.id===t):void 0,B=t=>{let o=w.get(t);return o||w.set(t,o={done:new Set,dismissed:false,answers:new Map,at:new Map,reached:new Map}),o},Re=false,V=t=>{e.track(q,t),Re=true;},te=(t,o)=>{t.done.add(o),t.at.set(o,X());},ve=t=>{var o,a,c;if((o=t.page)!=null&&o.trim()){let u=(a=e.path)==null?void 0:a.call(e);return u===void 0?false:$t(t.page,u)}if((c=t.event)!=null&&c.trim()){if(!l)return;for(let u of M)if(st(t.event,u))return true;return false}return false},P=(t,o,a,c,u=0,g)=>{var b,y;for(let h=0;h<o.length;h++){let x=o[h];if(x.kind==="wait"){if(a.done.has(x.id)){g=(b=a.at.get(x.id))!=null?b:g;continue}let $=a.reached.get(x.id);if($===void 0){if(!c)return {at:"pending"};$=g!=null?g:X(),a.reached.set(x.id,$),V({flow:t.id,step:x.id,kind:"wait",action:"shown"});}let F=$+gr(x);if(X()<F)return {at:"wait",until:F};if(!c)return {at:"pending"};te(a,x.id),V({flow:t.id,step:x.id,kind:"wait",action:"completed"}),g=F;continue}if(x.kind==="condition"){let $=a.answers.get(x.id);if($===void 0){if(!c)return {at:"pending"};if($=ve(x),$===void 0)return {at:"pending"};a.answers.set(x.id,$),V({flow:t.id,step:x.id,kind:"condition",action:"answered",answer:$?"yes":"no"});}return P(t,$?x.yes:x.no,a,c,u,g)}if(!a.done.has(x.id))return {at:"step",step:x,line:o,index:h,before:u};g=(y=a.at.get(x.id))!=null?y:g,u++;}return {at:"end"}},ne=t=>{let o=w.get(t.id);return !!o&&(o.dismissed||P(t,ee(t),o,false).at==="end")},Te=t=>`${Ft}:${t!=null?t:"visitor"}`,Ue=t=>`${Ft}:events:${t!=null?t:"visitor"}`,He=t=>`${Ft}:answers:${t!=null?t:"visitor"}`,ge=t=>{if(!t.finish||t.finish==="none"||t.shownBy==="code"||ke.has(t.id))return;let o=w.get(t.id);!o||o.dismissed||P(t,ee(t),o,false).at!=="end"||(ke.add(t.id),le={kind:t.finish,key:`${t.id}:${X()}`});},U=()=>{var a;Re=false;let t=(a=e.storage)==null?void 0:a.call(e);if(!t)return;let o={};for(let[c,u]of w)o[c]={done:[...u.done],...u.dismissed?{dismissed:true}:{},...u.answers.size?{answers:Object.fromEntries([...u.answers].map(([g,b])=>[g,b?"yes":"no"]))}:{},...u.at.size?{at:Object.fromEntries(u.at)}:{},...u.reached.size?{reached:Object.fromEntries(u.reached)}:{}};try{t.set(Te(e.personId()),JSON.stringify(o)),z.size&&t.set(He(e.personId()),JSON.stringify(Object.fromEntries(z))),M.size&&t.set(Ue(e.personId()),JSON.stringify([...M].slice(-200)));}catch(c){}},Fe=t=>{var o,a,c,u;for(let[g,b]of Object.entries(t!=null?t:{})){let y=B(g);for(let h of (o=b.done)!=null?o:[])y.done.add(h);b.dismissed&&(y.dismissed=true);for(let[h,x]of Object.entries((a=b.answers)!=null?a:{}))y.answers.has(h)||y.answers.set(h,x==="yes");for(let[h,x]of Object.entries((c=b.at)!=null?c:{}))typeof x=="number"&&!y.at.has(h)&&y.at.set(h,x);for(let[h,x]of Object.entries((u=b.reached)!=null?u:{}))typeof x=="number"&&(!y.reached.has(h)||x<y.reached.get(h))&&y.reached.set(h,x);}},Ge=t=>{var a;T&&clearTimeout(T),T=null;let o=t-X();o>0&&o<=864e5&&(T=setTimeout(()=>(T=null,I()),o+50),(a=T.unref)==null||a.call(T));},Y=false,L=()=>{var $;Y=false;let t=j(i);if(!t)return null;let o=B(t.id);if(o.dismissed)return null;let a=P(t,ee(t),o,true);if(Re&&U(),a.at==="wait"&&Ge(a.until),Y=a.at==="wait"||a.at==="pending",a.at!=="step")return null;let{step:c,line:u,index:g}=a,b=F=>!!F&&F.kind!=="wait"&&F.kind!=="condition";if(c.kind==="checklist"){let F=g;for(;F>0&&b(u[F-1])&&u[F-1].kind==="checklist";)F--;let ie=g;for(;ie+1<u.length&&b(u[ie+1])&&u[ie+1].kind==="checklist";)ie++;let ue=u.slice(F,ie+1).filter(b);for(let fe of ue)!o.done.has(fe.id)&&!k.has(`s:${fe.id}`)&&(k.add(`s:${fe.id}`),e.track(q,{flow:t.id,step:fe.id,kind:"checklist",action:"shown"}));return {type:"checklist",flow:t,items:ue.map(fe=>{let K=lr(fe),_e=K&&(K.kind==="tour"||K.kind==="modal")&&K.id!==t.id?j(K.id):void 0,ye=_e&&_e.shownBy!=="code"&&ee(_e).length?_e:void 0,Qe=K&&(K.kind==="page"?K.target.trim():K.kind==="code"||ye)?K:void 0;return {step:fe,done:o.done.has(fe.id),...ye&&(K==null?void 0:K.kind)==="tour"?{tour:ye}:{},...Qe?{opens:Qe}:{},...ye?{target:ye}:{}}})}}k.has(`s:${c.id}`)||(k.add(`s:${c.id}`),e.track(q,{flow:t.id,step:c.id,kind:c.kind,action:"shown"}));let y=u.slice(g+1),h=y.findIndex(F=>F.kind==="condition"),x=(h<0?y:y.slice(0,h)).filter(b).length;return {type:"step",flow:t,step:c,index:a.before,total:a.before+1+x,last:!x&&h<0,...c.kind==="question"?{answer:($=W.get(c.id))!=null?$:c.question?z.get(c.question.key):void 0,back:a.before>0}:{}}},G=()=>{var a,c,u;if(r){let g=r,b=(a=g.flow.followUps)==null?void 0:a[g.reason],y=b?1:0,h=g.plain?1:3+y+((c=g.flow.second)!=null&&c[g.reason]?1:0);return {type:"cancel",screen:g.screen,flow:g.flow,reason:g.reason,...g.screen==="followup"&&b?{followUp:b,answer:g.answer}:{},offer:g.screen==="offer"?g.offer:void 0,...g.screen==="offer"?{round:g.round}:{},price:g.options.price,busy:g.busy,error:g.error,step:g.screen==="survey"?1:g.screen==="followup"?2:g.screen==="offer"?1+y+g.round:h,steps:h}}let t=L();if(t)return t;if(i&&!Y){let g=J,b=i;J=null,i=null;let y=g?j(g.flow):void 0;if(g&&y){let h=he(ee(y)).find(F=>F.id===g.step),x=B(y.id);h&&!h.event&&!((u=w.get(b))!=null&&u.dismissed)&&!x.done.has(h.id)&&(te(x,h.id),V({flow:y.id,step:h.id,kind:"checklist",action:"completed"}),ge(y)),i=y.id;let $=L();if($)return $;Y||(i=null);}else if(l){let h=j(b),x=h?ce(h):void 0;Promise.resolve().then(()=>se(x));}}let o=d.find(g=>!O.has(g.id));return o?{type:"message",message:o}:null},I=()=>{let t=G();(t==null?void 0:t.type)==="message"&&!k.has(`m:${t.message.id}`)&&(k.add(`m:${t.message.id}`),e.track(It,{message:t.message.id,journey:t.message.journey,action:"shown"}));for(let o of [...R])try{o();}catch(a){}},re=t=>i===t.id?true:i&&j(i)&&!ne(j(i))?false:(i=t.id,e.track(q,{flow:t.id,action:"started"}),I(),true),me=t=>t.audience==="answered"?!!t.answered&&z.get(t.answered.question)===t.answered.option:t.audience!=="signed_in"||!!e.personId(),H=t=>{let o=j(t);return !o||ne(o)},oe=(t,o=ce(t))=>{var u;let a=(u=e.path)==null?void 0:u.call(e),c=at(o);if(c)return H(c);if(it(o))return false;if(wn(o))return a!==void 0&&$t(o,a);if(mn(o))return true;for(let g of M)if(st(o,g))return true;return false},se=t=>{var u,g;if(!S||i||!l||!e.personId()&&!((u=e.storage)!=null&&u.call(e)))return;let o=(g=e.path)==null?void 0:g.call(e),a=t&&!it(t)?de(t):"",c=Le().find(b=>(at(ce(b))?H(at(ce(b))):wn(ce(b))?o!==void 0&&$t(ce(b),o):mn(ce(b))||!!a&&de(ce(b))===a)&&me(b)&&ee(b).length&&!ne(b));c&&re(c);},be=(t,o,a)=>{let c=B(a.id);c.done.clear(),c.at.clear(),c.dismissed=false,J={flow:t.id,step:o},i=a.id,e.track(q,{flow:a.id,action:"started",from:t.id}),U(),I();},$e=(t,o,a)=>{let c=o.question,u=c.type==="text"?a.trim().slice(0,500):a.startsWith(Ie)?Ie+a.slice(Ie.length).trim().slice(0,490):a;z.set(c.key,u),W.delete(o.id),te(B(t.id),o.id),e.track(q,{flow:t.id,step:o.id,kind:"question",action:"completed",question:c.key,answer:u,label:fr(c,u)}),ge(t),U();},N=t=>{U(),ne(t)&&Promise.resolve().then(()=>se()),I();},De=()=>{let t=e.personId();_!==null&&_!==t&&(w.clear(),M.clear(),z.clear(),W.clear(),O.clear(),i=null,J=null,v=void 0),_=t;let o=(async()=>{var u,g,b,y;let a=(u=e.storage)==null?void 0:u.call(e);if(a)try{let h=await a.get(Te(t));h&&Fe(JSON.parse(h));let x=await a.get(Ue(t));if(x)for(let F of JSON.parse(x))typeof F=="string"&&M.add(F);let $=await a.get(He(t));if($)for(let[F,ie]of Object.entries(JSON.parse($)))typeof ie=="string"&&z.set(F,ie);}catch(h){}let c=Ce().length>0||!!(n!=null&&n.messages);if(t&&c&&v!==t){v=t;let h=await e.fetchInApp(t).catch(()=>null);if(h&&e.personId()===t){Fe(h.onboarding);for(let x of (g=h.events)!=null?g:[])typeof x=="string"&&M.add(de(x));for(let[x,$]of Object.entries((b=h.answers)!=null?b:{}))typeof $=="string"&&!z.has(x)&&z.set(x,$);d=((y=h.messages)!=null?y:[]).filter(x=>x&&x.id&&x.title);}}t||(d=[]),l=true,se(),I();})();return m=o.finally(()=>{m===o&&(m=null);}),m},Oe=t=>t.round>1?{round:2}:t.rule>=0?{rule:t.rule}:{},Ee=t=>{var c,u,g,b;let o={answer:t.answer,plan:t.options.plan,months:mr(t.options.customerSince,(c=e.now)==null?void 0:c.call(e))},a=(g=(u=t.flow.rules)==null?void 0:u[t.reason])!=null?g:[];t.rule=a.findIndex(y=>wr(y,o)),t.offer=t.rule<0?t.flow.offers[t.reason]:(b=a[t.rule].offer)!=null?b:void 0,t.round=1,t.screen=t.offer?"offer":"confirm";},We=(t,o,a)=>{var u;let c=t.screen==="offer"?t.offer:void 0;return {outcome:o,run:t.run,...t.reason?{reason:t.reason,reasonLabel:(u=t.flow.reasons.find(g=>g.id===t.reason))==null?void 0:u.label}:{},...t.answer?{answer:t.answer}:{},...o==="saved"&&c?{offer:c}:{},...a!=null&&a.trim()?{comment:a.trim().slice(0,500)}:{}}},we=(t,o)=>{var a;e.track(Xe,{action:"finished",run:t.run,version:t.flow.version,outcome:o.outcome,customer:(a=t.options.customer)!=null?a:"consumer",...o.reason?{reason:o.reason}:{},...o.answer?{answer:o.answer}:{},...o.offer?{offer:o.offer.kind,...Oe(t)}:{},...o.comment?{comment:o.comment}:{}}),r===t&&(r=null),t.resolve(o),I();},je=(t,o,a)=>{if(t.busy)return;let c=We(t,o,a),u=o==="saved"?t.options.onSave:t.options.onCancel;t.busy=true,t.error=void 0,I(),Promise.resolve().then(()=>u==null?void 0:u(c)).then(()=>we(t,c),()=>{t.busy=false,t.error=Ye("Something went wrong. Please try again."),I();});};return {setConfig:t=>{n=t,i&&!j(i)&&(i=null),I();},refresh:De,onEvent:t=>{var y;if(t==="$pageview"&&se(),!t||t.startsWith("$"))return;let o=de(t),a=!!o&&!M.has(o);a&&M.add(o);let c=j(i),u=false,g=[...c?[c]:[],...Ce().filter(h=>h.shownBy==="code"&&h.id!==(c==null?void 0:c.id))];for(let h of g){let x=B(h.id),$=false;for(let F of he(ee(h)))F.kind==="checklist"&&F.event&&!x.done.has(F.id)&&st(F.event,t)&&(te(x,F.id),$=true,e.track(q,{flow:h.id,step:F.id,kind:F.kind,action:"completed"}));$&&(u=true,ge(h));}if(u||a&&(c||g.length)?(U(),I()):a&&U(),!S||!e.personId()&&!((y=e.storage)!=null&&y.call(e)))return;let b=Le().find(h=>ee(h).length&&!it(ce(h))&&st(ce(h),t)&&me(h)&&!ne(h));b&&re(b);},openCancelFlow:(t={})=>{var b,y;if(r)return r.promise;let o=(b=n==null?void 0:n.cancelFlow)!=null?b:cr,a=t.customer!=="business"||o.reasons.length<2,c=()=>{},u=new Promise(h=>c=h),g={flow:o,options:t,plain:a,screen:a?"confirm":"survey",round:1,run:pr(),busy:false,resolve:c,promise:u};return r=g,e.track(Xe,{action:"shown",run:g.run,version:o.version,customer:(y=t.customer)!=null?y:"consumer",plain:a}),I(),u},startOnboarding:t=>{let o=t?j(t):Le().find(c=>ee(c).length&&!it(ce(c))&&!at(ce(c))&&!ne(c));if(!o||!ee(o).length||o.shownBy==="code")return false;let a=B(o.id);return a.dismissed=false,re(o)},view:G,subscribe:t=>(R.add(t),()=>R.delete(t)),cancel:{pick:t=>{!r||r.busy||r.screen!=="survey"||!r.flow.reasons.some(o=>o.id===t)||(r.reason!==t&&(r.answer=void 0),r.reason=t,r.error=void 0,I());},answer:t=>{let o=r;if(!o||o.busy||o.screen!=="followup")return;let a=t.slice(0,500);o.answer=a.trim()?a:void 0,I();},next:()=>{var o,a;let t=r;if(!(!t||!t.reason)){if(t.screen==="survey")e.track(Xe,{action:"answered",run:t.run,version:t.flow.version,reason:t.reason}),(o=t.flow.followUps)!=null&&o[t.reason]?t.screen="followup":Ee(t);else if(t.screen==="followup")t.answer=(a=t.answer)==null?void 0:a.trim(),Ee(t);else return;I();}},accept:t=>{var a;let o=r;!o||o.screen!=="offer"||!o.reason||(o.busy||e.track(Xe,{action:"offer",run:o.run,version:o.flow.version,reason:o.reason,offer:(a=o.offer)==null?void 0:a.kind,...Oe(o),outcome:"accepted"}),je(o,"saved",t));},decline:()=>{var a,c;let t=r;if(!t||t.screen!=="offer"||t.busy)return;e.track(Xe,{action:"offer",run:t.run,version:t.flow.version,reason:t.reason,offer:(a=t.offer)==null?void 0:a.kind,...Oe(t),outcome:"declined"});let o=t.round===1&&t.reason?(c=t.flow.second)==null?void 0:c[t.reason]:void 0;o?(t.offer=o,t.rule=void 0,t.round=2):t.screen="confirm",t.error=void 0,I();},confirm:t=>{let o=r;!o||o.screen!=="confirm"||je(o,"cancelled",t);},close:()=>{var a,c;let t=r;if(!t||t.busy)return;let o=We(t,"kept");(c=(a=t.options).onClose)==null||c.call(a,o),we(t,o);}},onboarding:{next:()=>{var a,c;let t=L();if((t==null?void 0:t.type)!=="step")return;if(t.step.kind==="question"){let u=t.step.question,g=(a=W.get(t.step.id))!=null?a:u?z.get(u.key):void 0;if(!u||!kn(u,g))return;$e(t.flow,t.step,g),I();return}te(B(t.flow.id),t.step.id),e.track(q,{flow:t.flow.id,step:t.step.id,kind:t.step.kind,action:"completed"}),ge(t.flow),U(),I();let o=t.step.kind==="modal"?dt(t.step.url):void 0;o&&((c=e.openUrl)==null||c.call(e,o));},check:t=>{let o=L();if((o==null?void 0:o.type)!=="checklist")return;let a=o.items.find(c=>c.step.id===t);!a||a.done||(te(B(o.flow.id),t),e.track(q,{flow:o.flow.id,step:t,kind:"checklist",action:"completed"}),ge(o.flow),U(),I());},dismiss:()=>{let t=L();!t||t.type!=="step"&&t.type!=="checklist"||(B(t.flow.id).dismissed=true,e.track(q,{flow:t.flow.id,...t.type==="step"?{step:t.step.id}:{},action:"dismissed"}),i=J&&J.flow!==t.flow.id&&j(J.flow)?J.flow:null,J=null,U(),I());},startTour:t=>{var c;let o=L();if((o==null?void 0:o.type)!=="checklist")return false;let a=(c=o.items.find(u=>u.step.id===t))==null?void 0:c.target;return a?(be(o.flow,t,a),true):false},open:t=>{var u,g;let o=L();if((o==null?void 0:o.type)!=="checklist")return false;let a=o.items.find(b=>b.step.id===t),c=a==null?void 0:a.opens;return !a||!c?false:(e.track(q,{flow:o.flow.id,step:t,kind:"checklist",action:"opened",opens:c.kind}),(c.kind==="tour"||c.kind==="modal")&&a.target?(be(o.flow,t,a.target),true):(!a.done&&!a.step.event&&(te(B(o.flow.id),t),e.track(q,{flow:o.flow.id,step:t,kind:"checklist",action:"completed"}),ge(o.flow)),U(),I(),c.kind==="page"?(u=e.navigate)==null||u.call(e,c.target.trim()):(g=e.task)==null||g.call(e,t,o.flow),true))},answer:t=>{let o=L();(o==null?void 0:o.type)!=="step"||o.step.kind!=="question"||(W.set(o.step.id,String(t).slice(0,500)),I());},skip:()=>{let t=L(),o=(t==null?void 0:t.type)==="step"&&t.step.kind==="question"?t.step.question:void 0;(t==null?void 0:t.type)!=="step"||!(o!=null&&o.optional)||(W.delete(t.step.id),te(B(t.flow.id),t.step.id),e.track(q,{flow:t.flow.id,step:t.step.id,kind:"question",action:"completed",question:o.key,skipped:true}),ge(t.flow),U(),I());},back:()=>{let t=L();if((t==null?void 0:t.type)!=="step"||t.step.kind!=="question"||!t.back)return;let o=he(ee(t.flow)),a=o.findIndex(u=>u.id===t.step.id),c=B(t.flow.id);for(let u=a-1;u>=0;u--)if(c.done.has(o[u].id)){c.done.delete(o[u].id),c.at.delete(o[u].id);break}U(),I();},item:t=>{let o=j(t);if(!o)return null;let a=w.get(o.id),c=he(ee(o)).map(b=>{let y=b.question?z.get(b.question.key):void 0;return {...b,done:!!(a!=null&&a.done.has(b.id)),...y!==void 0?{answer:y}:{}}}),u=c.length>0&&c.every(b=>b.done),g=!!(a!=null&&a.dismissed);return {item:o,steps:c,done:u,dismissed:g,eligible:!u&&!g&&me(o)&&oe(o)}},seen:t=>{let o=j(t);if(!o||o.shownBy!=="code"||!l)return;k.has(`f:${o.id}`)||(k.add(`f:${o.id}`),e.track(q,{flow:o.id,action:"started"}));let a=w.get(o.id);for(let c of he(ee(o)))if(!(a!=null&&a.done.has(c.id))&&!k.has(`s:${c.id}`)&&(k.add(`s:${c.id}`),e.track(q,{flow:o.id,step:c.id,kind:c.kind,action:"shown"}),c.kind!=="checklist"))break},complete:(t,o)=>{let a=j(t),c=a&&he(ee(a)).find(g=>g.id===o);if(!a||!c||c.kind==="question")return;let u=B(a.id);u.done.has(c.id)||(te(u,c.id),e.track(q,{flow:a.id,step:c.id,kind:c.kind,action:"completed"}),N(a));},dismissItem:t=>{let o=j(t);if(!o)return;let a=B(o.id);a.dismissed||(a.dismissed=true,e.track(q,{flow:o.id,action:"dismissed"}),i===o.id&&(i=null),N(o));},answerItem:(t,o,a)=>{let c=j(t),u=c&&he(ee(c)).find(g=>{var b;return g.kind==="question"&&(g.id===o||((b=g.question)==null?void 0:b.key)===o)});!c||!(u!=null&&u.question)||!kn(u.question,a)||($e(c,u,a),N(c));}},finale:()=>le,accent:()=>n==null?void 0:n.onboardingAccent,answers:()=>Object.fromEntries(z),message:{click:()=>{var a;let t=G();if((t==null?void 0:t.type)!=="message")return;O.add(t.message.id),e.track(It,{message:t.message.id,journey:t.message.journey,action:"clicked"});let o=dt(t.message.url);I(),o&&((a=e.openUrl)==null||a.call(e,o));},dismiss:()=>{let t=G();(t==null?void 0:t.type)==="message"&&(O.add(t.message.id),e.track(It,{message:t.message.id,journey:t.message.journey,action:"dismissed"}),I());}}}};var hr={questions:"question",checklist:"checklist",tour:"tour"},yn=(e,n,r={})=>{var v,_;let i=(v=r.type)!=null?v:"questions",d=(_=hr[i])!=null?_:"question",l=new Set,m=w=>{var O;return e(q,{code:de(n),name:n,type:i,...(O=r.order)!=null&&O.length?{order:r.order}:{},...w})};return {saw:(w,O)=>{l.has(w)||(l.add(w),m({step:w,title:O,kind:d,action:"shown"}));},answered:(w,O,k)=>m({step:w,kind:"question",action:"completed",question:w,answer:O,label:k!=null?k:O}),done:w=>m({step:w,kind:d,action:"completed"}),closed:w=>m({...w?{step:w}:{},kind:d,action:"dismissed"})}};var kr="ck_pick",br="ck_origin",lt=e=>typeof CSS!="undefined"&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>`\\${n}`),yr=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),xn=e=>{let n=e.ownerDocument,r=m=>{try{return n.querySelectorAll(m).length===1}catch(v){return false}},i=e.getAttribute("data-ck-target");if(i)return `[data-ck-target="${i.replace(/"/g,'\\"')}"]`;if(e.id&&!/\d{3,}/.test(e.id)&&r(`#${lt(e.id)}`))return `#${lt(e.id)}`;let d=[],l=e;for(;l&&l!==n.documentElement&&d.length<6;){if(l!==e&&l.id&&!/\d{3,}/.test(l.id)){d.unshift(`#${lt(l.id)}`);break}let m=l.tagName.toLowerCase(),v=yr(l).map(R=>`.${lt(R)}`).join(""),_=l.parentElement,w=_?[..._.children].filter(R=>R.tagName===l.tagName):[],O=w.length>1?`:nth-of-type(${w.indexOf(l)+1})`:"";d.unshift(`${m}${v}${O}`);let k=d.join(" > ");if(r(k))return k;l=_;}return d.join(" > ")},Cn=()=>{var O;if(typeof window=="undefined"||window.top===window)return null;let e=new URLSearchParams(window.location.search);if(e.get(kr)!=="1")return null;let n;try{n=new URL((O=e.get(br))!=null?O:"").origin;}catch(k){return null}if(!/^https?:\/\//.test(n))return null;let r=k=>window.parent.postMessage(k,n),i=document.createElement("div");i.setAttribute("aria-hidden","true"),Object.assign(i.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 d=document.createElement("div");Object.assign(d.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"}),i.appendChild(d),document.body.appendChild(i);let l=null,m=k=>{if(l=k&&k!==i&&!i.contains(k)?k:null,!l){i.style.display="none";return}let R=l.getBoundingClientRect();Object.assign(i.style,{display:"block",left:`${R.left-2}px`,top:`${R.top-2}px`,width:`${R.width+4}px`,height:`${R.height+4}px`}),d.textContent=xn(l);},v=k=>m(document.elementFromPoint(k.clientX,k.clientY)),_=k=>{var S,M;k.preventDefault(),k.stopPropagation();let R=(S=document.elementFromPoint(k.clientX,k.clientY))!=null?S:l;!R||R===i||r({type:"mrrocket:picked",selector:xn(R),text:((M=R.textContent)!=null?M:"").trim().replace(/\s+/g," ").slice(0,80)});},w=k=>{k.key==="Escape"&&r({type:"mrrocket:pick-cancel"});};return window.addEventListener("mousemove",v,true),window.addEventListener("click",_,true),window.addEventListener("keydown",w,true),r({type:"mrrocket:pick-ready"}),()=>{window.removeEventListener("mousemove",v,true),window.removeEventListener("click",_,true),window.removeEventListener("keydown",w,true),i.remove();}};var xr={get:e=>{try{return window.localStorage.getItem(e)}catch(n){return null}},set:(e,n)=>{try{window.localStorage.setItem(e,n);}catch(r){}}},Rn=()=>{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){}},vn=e=>({track:e.track,personId:e.personId,auto:e.auto,storage:()=>e.canStore()?xr:null,openUrl:n=>window.location.assign(n),path:()=>window.location.pathname,navigate:n=>{var d;let r=(d=e.onNavigate)==null?void 0:d.call(e);if(r)return r(n);let i=dt(n);i&&window.location.assign(i);},task:(n,r)=>{var i,d;return (d=(i=e.onTask)==null?void 0:i.call(e))==null?void 0:d(n,r)},fetchInApp:async n=>{var d;if(!e.apiKey)return null;let r=(d=e.userHash)==null?void 0:d.call(e,n),i=await fetch(`${e.host}/api/sdk/inapp?key=${encodeURIComponent(e.apiKey)}&distinctId=${encodeURIComponent(n)}${r?`&userHash=${r}`:""}${ot()}`);return Ne(i.status),i.ok?await i.json():null}});var pt="mrr_ref",gt="mrr_ref",Cr="mrr_ref",Rr="mrr_click";var Je=/^[A-Za-z0-9_-]{1,64}$/;var vr=(e,n="ref")=>{let r=new URLSearchParams(e);return Or(i=>r.get(i),n)},Or=(e,n="ref")=>{let r=e(Cr);if(r&&Je.test(r)){let d=e(Rr);return {code:r,clickId:d&&Je.test(d)?d:null,direct:false}}let i=e(n);return i&&Je.test(i)?{code:i,clickId:null,direct:true}:null},On=e=>{var n;return `${e.code}.${(n=e.clickId)!=null?n:""}.${e.at}`},ut=(e,n=60,r=Date.now())=>{if(!e)return null;let[i,d,l]=e.split("."),m=Number(l);return !i||!Je.test(i)||!Number.isFinite(m)||d&&!Je.test(d)||r-m>n*864e5||m>r+864e5?null:{code:i,clickId:d||null,at:m}};var Z=null,mt=()=>typeof document!="undefined",En=e=>{var r;if(!mt())return;let n=(r=document.cookie.split("; ").find(i=>i.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);try{return n?decodeURIComponent(n):void 0}catch(i){return n}},wt=()=>{try{return typeof localStorage=="undefined"?null:localStorage}catch(e){return null}},Pt=()=>{var e,n;return Z||(mt()?(n=ut(En(pt),3650))!=null?n:ut((e=wt())==null?void 0:e.getItem(gt),3650):null)};var ft=(e,n)=>{var d;if(!mt())return;let r=Math.max(1,Math.round(n))*86400,i=typeof location!="undefined"&&location.protocol==="https:"?"; secure":"";document.cookie=`${pt}=${encodeURIComponent(On(e))}; path=/; max-age=${r}; samesite=lax${i}`;try{(d=wt())==null||d.setItem(gt,On(e));}catch(l){}},ht=()=>{var e;if(mt()){document.cookie=`${pt}=; path=/; max-age=0; samesite=lax`;try{(e=wt())==null||e.removeItem(gt);}catch(n){}}},_n=()=>{Z=null;},Sn=async e=>{var i,d,l;let n=vr(e.search,e.param),r=(i=e.now)!=null?i:Date.now();if(!n)return !Z&&e.store&&(Z=(l=ut(En(pt),e.days,r))!=null?l:ut((d=wt())==null?void 0:d.getItem(gt),e.days,r),Z||ht()),Z;if(Z={code:n.code,clickId:n.clickId,at:r},e.store&&ft(Z,e.days),e.beacon)try{let m=await e.beacon({code:n.code,clickId:n.clickId});m&&Z&&Z.code===n.code&&!Z.clickId&&(Z={...Z,clickId:m},e.store&&ft(Z,e.days));}catch(m){}return Z},In=e=>e==="$identify"||!e.startsWith("$");var Mt=3600*24*365,Pn=e=>{var r;if(typeof document=="undefined")return;let n=(r=document.cookie.split("; ").find(i=>i.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);if(n)try{return decodeURIComponent(n)}catch(i){return n}},kt=(e,n,r)=>{let i=window.location.protocol==="https:"?"; secure":"";document.cookie=`${e}=${encodeURIComponent(n)}; path=/; max-age=${r}; samesite=lax${i}`;},ze=e=>{document.cookie=`${e}=; path=/; max-age=0; samesite=lax`;},D={utm:{}},$n=()=>{var e;return (e=D.id)!=null?e:D.id=Ot()},At=(e,n)=>{if(e!=="cookies")return $n();let r=Pn(Se);if(r)return D.id=r;let i=$n();return kt(Se,i,Mt),i},Nt=e=>{var d;let n=Date.now(),r=D.session,i=(d=e?Pn(Ae):void 0)!=null?d:r&&n-r.last<18e5?r.id:Ot();return D.session={id:i,last:n},e&&kt(Ae,i,18e5/1e3),i},Lt=()=>{var r;let e=window.location.href;if(D.url===e)return;D.referrer=(r=D.url)!=null?r:document.referrer||void 0,D.url=e;let n=tn(window.location.search);Object.keys(n).length&&(D.utm=n);},Mn=()=>{let e=navigator,n=window;return e.doNotTrack==="1"||n.doNotTrack==="1"||e.globalPrivacyControl===true};var bt=window,_r=()=>{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,pe=e=>{An.has(e)||(An.add(e),console.warn(`[MRRocket] ${e}`));},Sr=()=>{var Wt,jt,Vt,Kt;let e=_r(),n=s=>{var f;return (f=e==null?void 0:e.getAttribute(`data-${s}`))!=null?f:void 0},r=(s,f)=>{let p=n(s);return p===void 0?f:!["false","0","off","no"].includes(p.trim().toLowerCase())},i=(Wt=e==null?void 0:e.src)!=null?Wt:"",d="";try{d=i?new URL(i,window.location.href).origin:"";}catch(s){d="";}n("locale")&&St(n("locale"));let l=((jt=n("key"))!=null?jt:"").trim(),m=((Vt=n("api-host"))!=null?Vt:d).trim().replace(/\/+$/,""),v=n("consent"),_=r("respect-dnt",false),w=r("heatmaps",true),O=r("errors",true),k=n("release"),R=n("attribution"),S=R==="always"||R==="off"?R:"consent",M=n("referral-param")||"ref",X={},T=(s,f)=>{var p;return (p=X[s])!=null?p:X[s]=new Promise((C,E)=>{var qt;let A=()=>bt[f];if(A())return C(A());let ae=(qt=n(`${s}-src`))!=null?qt:i?i.replace(/(\.min)?\.js(\?[^#]*)?(#.*)?$/,`-${s}$1.js?v=${nt}`):"";if(!ae)return E(new Error(s));let xe=document.createElement("script");xe.async=true,xe.src=ae,xe.onload=()=>A()?C(A()):E(new Error(s)),xe.onerror=()=>E(new Error(s)),document.head.appendChild(xe);}).catch(C=>{throw X[s]=void 0,C})},J=n("theme"),z={theme:J==="light"||J==="dark"?J:"auto",accent:n("accent")},W=new URLSearchParams(window.location.search),ke=nn(W.get(Zt)),le=W.get(en)==="1";le&&Cn();let Ce=W.get(Ke);if(Ce!==null){W.delete(Ke);let s=W.toString();history.replaceState(history.state,"",`${window.location.pathname}${s?`?${s}`:""}${window.location.hash}`);}let Le=Mn(),j=v==="cookies"||v==="off"?v:"cookieless",B=r("replay",false),Re="",V,te=null,ve,P=null,ne=false,Te=false,Ue=null,He=null,ge=window.location.pathname,U=[],Fe=new Set,Ge=[],Y=()=>_&&Le?"off":j,L=()=>!le&&Y()!=="off",G=()=>V!=null?V:Re,I=()=>Y()==="cookies"?G():V,re=s=>cn(te,s);l||pe('No public key. Add data-key="mrr_pub_\u2026" to the script tag; nothing is tracked until then.');let me=(s=false)=>{if(!U.length)return;if(!l){U.length=0;return}let f=`${m}/api/sdk/events`;for(let p of Yt(l,U.splice(0),{v:nt,errors:O,platform:"web"},re(I())))s&&"sendBeacon"in navigator&&navigator.sendBeacon(f,p)||fetch(f,{method:"POST",headers:{"content-type":"application/json"},body:p,keepalive:true}).then(E=>{E.status===401?Ne(401):E.ok||pe(`Events were rejected with ${E.status}. Check data-key (MRRocket \u203A Settings \u203A Products).`);}).catch(()=>pe(`Could not reach ${m||"this origin"} to send events. Check data-api-host.`));},H=null,oe=null,se=(s,f,p=Date.now(),C)=>{if(!L())return;let E=In(s)?Pt():null;U.push({event:s,props:E?{...f,$referral:{code:E.code,clickId:E.clickId}}:f,distinctId:I(),sessionId:Nt(Y()==="cookies"),ts:p,url:C!=null?C:window.location.href,referrer:D.referrer,...D.utm,screen:{w:window.screen.width,h:window.screen.height}});},be=(s,f)=>{typeof s!="string"||!s||(se(s,f),L()&&(H==null||H.event(s)),N.onEvent(s));},$e={},N=bn(vn({host:m,apiKey:l,track:se,personId:()=>L()?V:void 0,userHash:re,canStore:()=>Y()==="cookies",auto:r("onboarding",true),onNavigate:()=>$e.onNavigate,onTask:()=>$e.onTask})),De=false,Oe;N.subscribe(()=>{De||!N.view()||le||(De=true,T("flows","__mrrocketFlows").then(s=>s.mountFlows(N,z)).catch(()=>{De=false,pe("The cancel flow and onboarding dialogs did not load. Check that sdk-flows.js is served next to sdk.js.");}));});let Ee=(s,f)=>{if(!L())return;let p=`${window.location.pathname}|${s}`;Fe.has(p)||(Fe.add(p),be("$exposure",{experiment:s,variant:f}));},We=()=>{let s=on(P,window.location.href,G(),ke);return s!=null&&s.to?(me(true),window.location.replace(s.to),true):(s!=null&&s.experiment&&Ee(s.experiment,s.variant),false)},we=()=>{if(!P)return;let s=document.querySelectorAll("[data-ck-text]");if(!s.length)return;let f=rn(P,G(),ke),p=new Set;s.forEach(C=>{var ae,xe;let E=C.dataset.ckText;if(!E)return;p.add(E),C.dataset.ckDefault===void 0&&(C.dataset.ckDefault=(ae=C.textContent)!=null?ae:"");let A=(xe=f[E])!=null?xe:C.dataset.ckDefault;C.textContent!==A&&(C.textContent=A);});for(let C of P.experiments)C.variants.some(E=>{var A;return Object.keys((A=E.changes)!=null?A:{}).some(ae=>p.has(ae))})&&Ee(C.key,qe(C.key,P,G(),ke));},je=()=>{var s,f;return (f=(s=P==null?void 0:P.referral)==null?void 0:s.cookieDays)!=null?f:60},yt=()=>S==="always"?Y()!=="off":S==="consent"&&Y()==="cookies",xt=null,t=false,o=()=>{if(!ne||le)return;if(S==="off"||Y()==="off"){_n(),(S==="off"||t)&&ht();return}let s=window.location.href;xt!==s&&(xt=s,Sn({search:window.location.search,param:M,store:yt(),days:je(),beacon:l?({code:f,clickId:p})=>fetch(`${m}/api/sdk/affiliate/click`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:l,code:f,clickId:p,url:s,referrer:document.referrer||void 0}),keepalive:true}).then(C=>C.ok?C.json():null).then(C=>{var E;return (E=C==null?void 0:C.clickId)!=null?E:null}):void 0}));},a=()=>{let s=yt(),f=Pt();s&&f?ft(f,je()):!s&&t&&ht(),t=s;},c=0,u=false,g=()=>{var C,E;let s=L()&&B&&!!(P!=null&&P.replay)&&!!l;if(s===u)return;u=s;let f=++c;if(!s){H==null||H.stop(true),H=null;return}let p=(E=(C=P==null?void 0:P.replay)==null?void 0:C.sampleRate)!=null?E:.1;T("replay","__mrrocketReplay").then(A=>A.startReplay({host:m,apiKey:l,sessionId:Nt(Y()==="cookies"),distinctId:I(),identified:!!V,userHash:re(I()),sampleRate:p,warn:pe})).then(A=>{f!==c?A==null||A.stop(true):H=A;}).catch(()=>pe("Session recording could not start (the recorder did not load)."));},b=r("messenger",false),y=null,h=s=>{le||l&&(y!=null||(y=T("messenger","__mrrocketMessenger").then(f=>{var A;let p=ae=>n(`messenger-${ae}`)===void 0?void 0:r(`messenger-${ae}`,true),C=n("messenger-position"),E=(A=n("messenger-theme"))!=null?A:J;return f.mountMessenger({host:m,apiKey:l,distinctId:G,user:()=>ve,userHash:()=>re(G()),launcher:b,position:C,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:p("ask-email"),help:p("help"),sound:p("sound"),preview:p("preview"),theme:E==="light"||E==="dark"||E==="auto"?E:void 0,accent:n("accent")})})),y.then(s).catch(()=>{y=null,pe("sdk-messenger.js did not load.");}));},x=n("forms")==="auto",$=false,F=()=>{$||!l||le||!document.querySelector(x?"form":"form[data-mrrocket-form]")||($=true,T("forms","__mrrocketForms").then(s=>s.watchForms({host:m,apiKey:l,auto:x,distinctId:()=>L()?I():void 0,userHash:re,identified:()=>!!V,identify:Tt,tracking:L,referrer:()=>D.referrer,utm:()=>D.utm})).catch(()=>$=false));},ie=()=>{!Te||!L()||He===window.location.pathname||(He=window.location.pathname,be("$pageview",{path:window.location.pathname}));},ue=null,fe=()=>{let s=ue;w&&s&&s.max>0&&se("$scroll",{depth:s.max,docH:s.docH,vw:window.innerWidth,vh:window.innerHeight},Date.now(),s.url),ue=null;},K=()=>{var E,A;if(!w||!L()||le)return;let s=document.documentElement,f=Math.max(s.scrollHeight,(A=(E=document.body)==null?void 0:E.scrollHeight)!=null?A:0),p=zt(),C=window.location.href;(ue==null?void 0:ue.url)!==C?ue={url:C,max:p,docH:f}:p>ue.max&&(ue={url:C,max:p,docH:f});},_e=()=>{let s=window.location.pathname;s!==ge&&(ge=s,!(ne&&We())&&(fe(),Lt(),H==null||H.page(s),oe==null||oe.crumb("navigation",s),ie(),o(),window.setTimeout(()=>{K(),we(),F();},0)));},ye=()=>{let s=Y(),f=Ue;Ue=s,f==="cookies"&&s!=="cookies"&&(ze(Se),ze(Ae)),s==="off"&&(U.length=0,D.session=void 0),f==="cookies"&&s!=="cookies"&&Rn(),Re=At(s),a(),o(),g(),ie(),K();},Qe=s=>{let{analytics:f,replay:p}=typeof s=="string"?{analytics:s,replay:void 0}:s!=null?s:{};if(f!==void 0&&f!=="cookieless"&&f!=="cookies"&&f!=="off"){pe('setConsent: use "cookies", "cookieless" or "off".');return}f==="off"&&(U.length=0,V&&Y()!=="off"&&(U.push({event:Qt,distinctId:V,ts:Date.now()}),me(true))),f&&(j=f),typeof p=="boolean"&&(B=p),ye(),ne&&N.refresh();},Tt=(s,f,p)=>{if(typeof s!="string"||!s)return;let C=I();te=an(te,s,p==null?void 0:p.hash),V=s,se("$identify",{...f,id:s,...C&&C!==s?{previousId:C}:{}}),H==null||H.identify(s,re(s)),Y()==="cookies"&&kt(Se,s,Mt),ve={...f,id:s},we(),ne&&N.refresh(),y==null||y.then(E=>E.refresh());},Ze={track:be,identify:Tt,reset:()=>{me(),V=void 0,te=null,ve=void 0,Fe.clear(),Y()==="cookies"&&(ze(Se),ze(Ae)),D.id=void 0,D.session=void 0,Re=At(Y()),we(),ne&&N.refresh(),y==null||y.then(s=>s.refresh());},captureError:s=>oe==null?void 0:oe.capture(s,"manual"),setConsent:Qe,setLocale:St,currentLocale:rt,getFlag:s=>vt(s,P,G(),{...ve})!==false,getFlagVariant:s=>{let f=vt(s,P,G(),{...ve});return typeof f=="string"?f:null},getVariant:s=>{let f=qe(s,P,G(),ke);return (P||ke[s])&&Ee(s,f),f},ready:s=>{typeof s=="function"&&(ne?window.setTimeout(()=>s(Ze),0):Ge.push(s));},getDistinctId:G,cancelFlow:{open:s=>N.openCancelFlow(s)},onboarding:{start:s=>N.startOnboarding(s),get:s=>{let f=N.onboarding.item(s);return f&&!f.done&&!f.dismissed&&N.onboarding.seen(s),f},subscribe:s=>N.subscribe(()=>s()),complete:(s,f)=>N.onboarding.complete(s,f),dismiss:s=>N.onboarding.dismissItem(s),answer:(s,f,p)=>N.onboarding.answerItem(s,f,p),report:(s,f)=>yn(be,s,f),setHandlers:s=>{$e={onNavigate:typeof(s==null?void 0:s.onNavigate)=="function"?s.onNavigate:void 0,onTask:typeof(s==null?void 0:s.onTask)=="function"?s.onTask:void 0};}},openCancelFlow:s=>N.openCancelFlow(s),startOnboarding:s=>N.startOnboarding(s),paywall:{open:(s,f)=>(Oe!=null?Oe:Oe=T("flows","__mrrocketFlows").then(p=>p.paywallHost({config:()=>P,distinctId:G,track:se},z))).then(p=>p.open(s,f))},push:{subscribe:s=>{let f=L()?V:void 0;if(!f)return Promise.resolve({status:"not-signed-in"});let p=window.Notification,C=Promise.resolve(p&&p.permission==="default"&&(s==null?void 0:s.ask)!==false?p.requestPermission():p==null?void 0:p.permission);return T("push","__mrrocketPush").then(E=>E.subscribeWebPush({host:m,apiKey:l,distinctId:f,userHash:re(f),permission:C},s))},unsubscribe:()=>T("push","__mrrocketPush").then(s=>s.unsubscribeWebPush({host:m,apiKey:l,distinctId:V,userHash:re(V)}))},messenger:{open:s=>h(f=>f.open(s)),close:()=>{y==null?void 0:y.then(s=>s.close()).catch(()=>{});},toggle:()=>h(s=>s.toggle())},openMessenger:()=>h(s=>s.open()),version:nt};Lt(),ye();let Pe=bt.mrrocket,Ln=(Kt=Pe==null?void 0:Pe.q)!=null?Kt:[],Ct=Pe&&typeof Pe=="object"?Pe:{};Object.assign(Ct,Ze,{__loaded:true}),delete Ct.q,bt.mrrocket=Ct;for(let[s,f]of Ln){let p=Ze[s];if(typeof p=="function")try{p(...Array.from(f!=null?f:[]));}catch(C){console.error(C);}}Te=true,ie(),O&&l&&!le&&(oe=ln({host:m,apiKey:l,release:k,context:()=>{var s;return {send:L(),distinctId:I(),sessionId:(s=D.session)==null?void 0:s.id,userHash:re(I())}},warn:pe}),oe.crumb("navigation",window.location.pathname));for(let s of ["pushState","replaceState"]){let f=history[s];history[s]=function(...p){let C=f.apply(this,p);return _e(),C};}window.addEventListener("popstate",_e);let Tn=new Ve;document.addEventListener("click",s=>{var A;s.target instanceof Element&&s.target.closest("[data-ck-messenger]")&&(s.preventDefault(),h(ae=>ae.open()));let f=s.target instanceof Element?s.target.closest("[data-ck-goal]"):null;if(f!=null&&f.dataset.ckGoal&&be(f.dataset.ckGoal,{text:(A=f.textContent)==null?void 0:A.trim().slice(0,80)}),!L())return;let p=Jt(s);if(!p)return;let C=Tn.push(p.x,p.y,Date.now());if((p.label||p.selector)&&(oe==null||oe.crumb("click",p.label||p.selector)),H==null||H.click(p,C),!w)return;let E={x:p.x,y:p.y,vw:p.vw,vh:p.vh,docH:p.docH,selector:p.selector,label:p.label,dead:!p.interactive};se("$click",E),C&&se("$rageclick",E);});let Rt=0;window.addEventListener("scroll",()=>{Rt||(Rt=window.requestAnimationFrame(()=>{Rt=0,K();}));},{passive:true}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>K()):K(),window.setInterval(()=>me(),2e3),window.addEventListener("pagehide",()=>{fe(),me(true);});let Ut=()=>{if(ne=true,We())return;let s=sn(P,Ce);s&&Ee(s.experiment,s.variant),document.documentElement.classList.remove("ck-hide"),o(),g(),N.setConfig(P),N.refresh(),b&&(document.body?h():document.addEventListener("DOMContentLoaded",()=>h())),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{we(),F();}):(we(),F());for(let f of Ge.splice(0))try{f(Ze);}catch(p){console.error(p);}},Ht=0,Dt=s=>{let f=++Ht;return fetch(`${m}/api/sdk/config?key=${encodeURIComponent(l)}${ot()}`).then(p=>(p.ok||pe(`Config request to ${m||"this origin"} answered ${p.status}. Check data-key and data-api-host.`),p.ok?p.json():null)).then(p=>{p&&Array.isArray(p.experiments)&&f===Ht&&(P=p,fn(p.words,p.lang)),s();}).catch(()=>{pe(`Could not reach ${m||"this origin"}. Check data-api-host. The page keeps its own texts and flags stay off.`),s();})};l?(Dt(Ut),pn(()=>{Dt(()=>{N.setConfig(P),we();});})):Ut();},Nn;typeof window!="undefined"&&typeof document!="undefined"&&!((Nn=bt.mrrocket)!=null&&Nn.__loaded)&&Sr();
1
+ (function(){'use strict';var Un=Object.defineProperty;var Hn=(e,n,r)=>n in e?Un(e,n,{enumerable:true,configurable:true,writable:true,value:r}):e[n]=r;var Me=(e,n,r)=>Hn(e,typeof n!="symbol"?n+"":n,r);var Bt=e=>{let n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?n+=1:i<2048?n+=2:i>=55296&&i<=56319&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(n+=4,r++):n+=3;}return n},Dn=(e,n,r,i)=>{let d=`{"key":${JSON.stringify(e)},${i?`"userHash":${JSON.stringify(i)},`:""}"sdk":${JSON.stringify(r)},"events":[`,l=Bt(d)+2,m=[],v=[],_=[],w=l,O=()=>{v.length&&m.push({body:`${d}${v.join(",")}]}`,events:_}),v=[],_=[],w=l;};for(let k of n){let R=JSON.stringify(k),S=Bt(R)+1;l+S>6e4||((v.length===100||w+S>6e4)&&O(),v.push(R),_.push(k),w+=S);}return O(),m},Yt=(e,n,r,i)=>Dn(e,n,r,i).map(d=>d.body);var Ve=class{constructor(n=1e3,r=30,i=3){Me(this,"windowMs",n);Me(this,"radius",r);Me(this,"count",i);Me(this,"clicks",[]);Me(this,"fired",false);}push(n,r,i){let d=this.clicks.filter(l=>i-l.t<=this.windowMs&&Math.hypot(l.x-n,l.y-r)<=this.radius);return d.length!==this.clicks.length&&(this.fired=false),this.clicks=[...d,{x:n,y:r,t:i}],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]',jn="[data-ck-mask]",Vn="[data-ck-block]",Xt=/\d{4,}|^[a-z]{1,3}-[a-z0-9]{5,}$|^_|__|css-|^sc-|^jsx-/i,Kn=e=>{let n=e.tagName.toLowerCase();if(e.id&&!Xt.test(e.id)&&e.id.length<=40)return `${n}#${e.id}`;let r=typeof e.className=="string"?e.className.split(/\s+/).filter(l=>l&&!Xt.test(l)&&l.length<=30&&!l.includes(":")):[],i=r.length?`${n}.${r.slice(0,2).join(".")}`:n,d=e.parentElement?[...e.parentElement.children].filter(l=>l.tagName===e.tagName):[];return d.length>1?`${i}:nth-of-type(${d.indexOf(e)+1})`:i},qn=e=>{let n=[],r=e;for(;r&&n.length<3&&r.tagName&&r.tagName!=="BODY"&&r.tagName!=="HTML";){let i=Kn(r);if(n.unshift(i),i.includes("#"))break;r=r.parentElement;}return n.join(" > ").slice(0,160)},et=e=>(e!=null?e:"").replace(/\s+/g," ").trim().slice(0,40),Bn=e=>{var r,i,d,l,m;if(e.closest(`${jn},${Vn}`))return "";let n=e.tagName.toLowerCase();if(n==="input"){let v=((r=e.getAttribute("type"))!=null?r:"text").toLowerCase();return et(v==="submit"||v==="button"?(i=e.getAttribute("aria-label"))!=null?i:e.value:e.getAttribute("aria-label"))}return et(n==="select"||n==="textarea"?e.getAttribute("aria-label"):(m=(l=(d=e.getAttribute("aria-label"))!=null?d:e.getAttribute("title"))!=null?l:e.innerText)!=null?m:e.textContent)},Jt=e=>{var l,m;let n=e.target instanceof Element?e.target:null;if(!n)return null;let r=n.closest(Wn),i=r!=null?r:n,d=document.documentElement;return {x:Math.round(e.clientX),y:Math.round(e.clientY+window.scrollY),vw:window.innerWidth,vh:window.innerHeight,docH:Math.max(d.scrollHeight,(m=(l=document.body)==null?void 0:l.scrollHeight)!=null?m:0),selector:qn(i),label:r?Bn(r):"",interactive:!!r}},zt=()=>{var r,i;let e=document.documentElement,n=Math.max(e.scrollHeight,(i=(r=document.body)==null?void 0:r.scrollHeight)!=null?i:0);return n?Math.min(100,Math.round((window.scrollY+window.innerHeight)/n*100)):0};var nt="0.23.1",Yn=(e,n)=>{let r=n.trim().toLowerCase();for(let[i,d]of Object.entries(e))if(i.toLowerCase()===r)return d},Xn=(e,n)=>{let r=e.trim().toLowerCase(),i=n.trim().toLowerCase();return i.startsWith("@")?r.endsWith(i):r===i},Jn=(e,n)=>{if(e.op==="in cohort")return false;let r=Yn(n,e.property),i=r==null?"":String(r);if(e.op==="\u2265"){let l=Number(i),m=Number(e.values[0]);return i!==""&&Number.isFinite(l)&&Number.isFinite(m)&&l>=m}let d=i!==""&&e.values.some(l=>Xn(i,l));return e.op==="is"||e.op==="in"?d:!d},zn=(e,n,r={})=>{var v;if(!e.on)return false;let i={id:n,...r},d=e.sets.length?e.sets.find(_=>_.conditions.every(w=>Jn(w,i))):{rollout:100};if(!d||Gt(`${e.key}:rollout:${n}`)*100>=d.rollout)return false;if(!((v=e.variants)!=null&&v.length))return true;let l=Gt(`${e.key}:variant:${n}`)*100,m=0;for(let _ of e.variants)if(m+=_.split,l<m)return _.key;return e.variants[e.variants.length-1].key},vt=(e,n,r,i={})=>{var l;let d=(l=n==null?void 0:n.flags)==null?void 0:l.find(m=>m.key===e);return d?zn(d,r,i):false},Qt="$consent_off",Gn=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],Zt="ck_preview",en="ck_embed",Se="ck_id",Ae="ck_sid";var Qn=e=>{var r;let n={};for(let i of Gn){let d=(r=e(i))==null?void 0:r.trim();d&&(n[i]=d.slice(0,150));}return n},tn=e=>{let n=new URLSearchParams(e);return Qn(r=>n.get(r))};var Zn=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},Gt=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},er=(e,n)=>{var l,m,v,_;let r=(m=(l=e.variants[0])==null?void 0:l.id)!=null?m:"control";if(e.winner)return e.winner;if(e.status!=="running")return r;let i=Zn(`${e.key}:${n}`),d=0;for(let w of e.variants)if(d+=w.weight,i<d)return w.id;return (_=(v=e.variants[e.variants.length-1])==null?void 0:v.id)!=null?_:r},nn=e=>{let n=Array.isArray(e)?e[0]:e;if(!n)return {};let r={};for(let i of n.split(",")){let[d,l]=i.split(":");d&&l&&(r[d.trim()]=l.trim());}return r};var qe=(e,n,r,i)=>{if(i[e])return i[e];let d=n==null?void 0:n.experiments.find(l=>l.key===e);return d?er(d,r):"control"},rn=(e,n,r)=>{var d,l,m,v,_,w;let i={...(d=e==null?void 0:e.texts)!=null?d:{}};for(let O of (l=e==null?void 0:e.experiments)!=null?l:[]){let k=qe(O.key,e,n,r);k!==((v=(m=O.variants[0])==null?void 0:m.id)!=null?v:"control")&&Object.assign(i,(w=(_=O.variants.find(R=>R.id===k))==null?void 0:_.changes)!=null?w:{});}return i},Ke="ck_x",tt=e=>e.replace(/\/+$/,"")||"/",on=(e,n,r,i={})=>{var v,_;if(!e)return null;let d;try{d=new URL(n);}catch(w){return null}if(d.searchParams.has(Ke))return null;let l=tt(d.pathname),m=(w,O)=>{let k;try{k=new URL(w,d);}catch(R){return}if(!(!/^https?:$/.test(k.protocol)||k.origin===d.origin&&tt(k.pathname)===l))return d.searchParams.forEach((R,S)=>{k.searchParams.has(S)||k.searchParams.set(S,R);}),O&&k.searchParams.set(Ke,O),k.hash||(k.hash=d.hash),k.href};for(let w of (v=e.redirects)!=null?v:[]){let O=w.from&&tt(w.from)===l?m(w.to):void 0;if(O)return {to:O}}for(let w of e.experiments){if(!w.path||tt(w.path)!==l)continue;let O=w.status==="running"&&!w.winner;if(O&&r===null&&!i[w.key])return null;let k=qe(w.key,e,r!=null?r:"",i),R=(_=w.variants.find(M=>M.id===k))==null?void 0:_.url,S=R?m(R,O?`${w.key}:${k}`:void 0):void 0;return O?{to:S,experiment:w.key,variant:k}:S?{to:S}:null}return null},sn=(e,n)=>{let[r,i]=(n!=null?n:"").split(":"),d=e==null?void 0:e.experiments.find(l=>l.key===r);return d&&d.variants.some(l=>l.id===i)?{experiment:r,variant:i}:null};var Ot=()=>typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():`ck_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;var tr="401: sign the user id on your server with userHash(id) from @mrrocket/sdk/next/server and pass identify(id, props, { hash }).",Ne=(e,n=r=>console.warn(r))=>{let r=globalThis;e!==401||r.__mrrocketUnsigned||(r.__mrrocketUnsigned=true,n(`[MRRocket] ${tr}`));},an=(e,n,r,i=d=>console.warn(d))=>{let d=typeof r=="string"?r.trim().toLowerCase():"";return /^[0-9a-f]{64}$/.test(d)?{id:n,hash:d}:(d&&i("[MRRocket] identify: that hash is no userHash(id); not sent."),e&&e.id===n?e:null)},cn=(e,n)=>e&&n&&e.id===n?e.hash:void 0,dn=(e,n)=>e&&n.some(r=>r===e.id)&&n.every(r=>!r||r===e.id)?e.hash:void 0;var nr=8*1024,rr=20,or=20,sr=2e3,Be=(e,n)=>e.length>n?`${e.slice(0,n-1)}\u2026`:e,ir=e=>{var n;if(e instanceof Error)return {type:e.name||"Error",message:Be(e.message||String(e),1e3),stack:e.stack?Be(e.stack,nr):void 0};if(typeof e=="string")return {type:"Error",message:Be(e,1e3)};try{return {type:"Error",message:Be((n=JSON.stringify(e))!=null?n:String(e),1e3)}}catch(r){return {type:"Error",message:String(e)}}},ln=e=>{let n=[],r=[],i=new Set,d=0,l=`${e.host}/api/sdk/errors`,m=(R=false)=>{for(;n.length;){let S=n.splice(0,4),M=e.context(),X=M.distinctId&&M.userHash?{id:M.distinctId,hash:M.userHash}:null,T=dn(X,S.map(W=>W.distinctId)),J=JSON.stringify({key:e.apiKey,...T?{userHash:T}:{},errors:S});R&&typeof navigator!="undefined"&&"sendBeacon"in navigator&&navigator.sendBeacon(l,J)||fetch(l,{method:"POST",headers:{"content-type":"application/json"},body:J,keepalive:true}).then(W=>{W.status===401?Ne(401):!W.ok&&W.status!==429&&e.warn(`Error reports were rejected with ${W.status}. Check the public key and NEXT_PUBLIC_MRROCKET_HOST.`);}).catch(()=>{});}},v=(R,S="manual")=>{let M=e.context();if(!M.send||d>=rr)return;let X=ir(R);if(/\/api\/sdk\/errors/.test(X.message))return;let T=`${X.type}:${X.message}`;i.has(T)||(i.add(T),d++,n.push({...X,mechanism:S,handled:S==="manual",url:window.location.href,ts:Date.now(),crumbs:r.slice(),...e.release?{release:e.release}:{},...M.distinctId?{distinctId:M.distinctId}:{},...M.sessionId?{sessionId:M.sessionId}:{}}));},_=R=>{var S;!R.error&&(!R.message||R.message==="Script error.")||v((S=R.error)!=null?S:new Error(R.message),"onerror");},w=R=>{var S;return v((S=R.reason)!=null?S:new Error("Unhandled promise rejection"),"onunhandledrejection")},O=()=>m(true);window.addEventListener("error",_),window.addEventListener("unhandledrejection",w),window.addEventListener("pagehide",O);let k=window.setInterval(()=>m(),sr);return {capture:v,crumb:(R,S)=>{r.push({ts:Date.now(),type:R,message:Be(S,120)}),r.length>or&&r.shift();},stop:()=>{window.removeEventListener("error",_),window.removeEventListener("unhandledrejection",w),window.removeEventListener("pagehide",O),window.clearInterval(k),m(true);}}};var Et=globalThis,un,Q=(un=Et.__mrrocketI18n)!=null?un:Et.__mrrocketI18n={version:0,onWords:new Set,onLocale:new Set},_t=e=>{for(let n of [...e])try{n();}catch(r){}},Ye=e=>{var n;return ((n=Q.words)==null?void 0:n[e])||e};var fn=(e,n)=>{var i;let r=Q.lang===n&&JSON.stringify((i=Q.words)!=null?i:{})===JSON.stringify(e!=null?e:{});Q.words=e,Q.lang=n,!r&&(Q.version++,_t(Q.onWords));},ar=e=>{let n=e==null?void 0:e.trim().replace(/_/g,"-");if(n)try{return Intl.getCanonicalLocales(n)[0]}catch(r){return r instanceof RangeError?void 0:n}},St=e=>{let n=ar(e);n!==Q.locale&&(Q.locale=n,Q.version++,_t(Q.onWords),_t(Q.onLocale));};var rt=()=>{var e,n;return (n=(e=Q.locale)!=null?e:Q.device)!=null?n:typeof navigator!="undefined"&&navigator.language||void 0},ot=()=>{let e=rt();return e?`&lang=${encodeURIComponent(e)}`:""};var pn=e=>(Q.onLocale.add(e),()=>{Q.onLocale.delete(e);});var Xe="$cancel_flow",q="$onboarding",It="$inapp";var cr={version:0,question:"",reasons:[],offers:{},get confirm(){return {title:Ye("Cancel your subscription?"),body:Ye("You keep access until the end of the billing period."),button:Ye("Cancel subscription")}},offersFor:"business"},Ft="mrrocket:onboarding",de=e=>e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),gn=new Set(["signed_up","signup","sign_up","registered","account_created","user_signed_up"]),st=(e,n)=>{let r=de(e),i=de(n);return !r||!i?false:r===i||gn.has(r)&&gn.has(i)},mn=e=>/^(first (launch|visit|open|session|login|sign ?in|app open)|app (opened|launched)|on load|every visit|always)?$/i.test(e.trim());var wn=e=>e.trim().startsWith("/");var dr="Needs tracking code 0.18.0",ce=e=>{var n;return (n=e.when)!=null?n:e.trigger},it=e=>de(e)==="from_a_checklist"||de(e)==="from_your_code"||de(e)===de(dr),hn="after:",at=e=>{let n=(e!=null?e:"").trim();return n.toLowerCase().startsWith(hn)&&n.slice(hn.length).trim()||null},lr=e=>{var n;return (n=e.opens)!=null?n:e.startsTour?{kind:"tour",id:e.startsTour}:void 0},Ie="other:",ur=e=>{var i,d;let n=(i=e==null?void 0:e.min)!=null?i:0,r=(d=e==null?void 0:e.max)!=null?d:10;return Array.from({length:Math.max(0,Math.min(r-n,20)+1)},(l,m)=>n+m)},kn=(e,n)=>{var r;return !e||n==null?false:e.type==="choice"?e.other&&n.startsWith(Ie)?n.slice(Ie.length).trim().length>0:((r=e.options)!=null?r:[]).some(i=>i.id===n):e.type==="scale"?ur(e).some(i=>String(i)===n):n.trim().length>0&&n.length<=500},fr=(e,n)=>{var r,i,d;return (e==null?void 0:e.type)!=="choice"?n.trim():e.other&&n.startsWith(Ie)?n.slice(Ie.length).trim():(d=(i=(r=e.options)==null?void 0:r.find(l=>l.id===n))==null?void 0:i.label)!=null?d:n};var pr=()=>`cf_${Math.random().toString(36).slice(2,10)}${Date.now().toString(36)}`;var dt=e=>{let n=(e!=null?e:"").trim();return /^https?:\/\//i.test(n)||/^\/(?!\/)/.test(n)?n:void 0},ee=e=>{var n;return (n=e.nodes)!=null?n:e.steps},gr=e=>Math.max(0,e.amount)*(e.unit==="hours"?36e5:864e5),$t=(e,n)=>{let r=e.trim(),i=(n.split(/[?#]/)[0]||"/").replace(/\/+$/,"")||"/";if(!r)return false;if(r.endsWith("*")){let d=r.slice(0,-1).replace(/\/+$/,"");return !d||i===d||i.startsWith(`${d}/`)}return i===(r.replace(/\/+$/,"")||"/")},he=e=>e.flatMap(n=>n.kind==="condition"?[...he(n.yes),...he(n.no)]:n.kind==="wait"?[]:[n]),mr=(e,n=Date.now())=>e==null||e===""?NaN:Math.floor((n-new Date(e).getTime())/2630016e3),ct=e=>e==null?void 0:e.trim().toLowerCase(),wr=({when:e={}},n)=>(e.answer==null||ct(e.answer)===ct(n.answer))&&(e.plan==null||[e.plan].flat().some(r=>ct(r)===ct(n.plan)))&&!(n.months>=e.tenureUnder)&&!(n.months<e.tenureOver)&&(e.tenureUnder==null||n.months>=0)&&(e.tenureOver==null||n.months>=0),bn=e=>{let n=null,r=null,i=null,d=[],l=false,m=null,v,_=null,w=new Map,O=new Set,k=new Set,R=new Set,S=e.auto!==false,M=new Set,X=()=>{var t,o;return (o=(t=e.now)==null?void 0:t.call(e))!=null?o:Date.now()},T=null,J=null,z=new Map,W=new Map,ke=new Set,le=null,Ce=()=>{var t;return (t=n==null?void 0:n.onboarding)!=null?t:[]},Le=()=>Ce().filter(t=>t.shownBy!=="code"),j=t=>t?Ce().find(o=>o.id===t):void 0,B=t=>{let o=w.get(t);return o||w.set(t,o={done:new Set,dismissed:false,answers:new Map,at:new Map,reached:new Map}),o},Re=false,V=t=>{e.track(q,t),Re=true;},te=(t,o)=>{t.done.add(o),t.at.set(o,X());},ve=t=>{var o,a,c;if((o=t.page)!=null&&o.trim()){let u=(a=e.path)==null?void 0:a.call(e);return u===void 0?false:$t(t.page,u)}if((c=t.event)!=null&&c.trim()){if(!l)return;for(let u of M)if(st(t.event,u))return true;return false}return false},P=(t,o,a,c,u=0,g)=>{var b,y;for(let h=0;h<o.length;h++){let x=o[h];if(x.kind==="wait"){if(a.done.has(x.id)){g=(b=a.at.get(x.id))!=null?b:g;continue}let $=a.reached.get(x.id);if($===void 0){if(!c)return {at:"pending"};$=g!=null?g:X(),a.reached.set(x.id,$),V({flow:t.id,step:x.id,kind:"wait",action:"shown"});}let F=$+gr(x);if(X()<F)return {at:"wait",until:F};if(!c)return {at:"pending"};te(a,x.id),V({flow:t.id,step:x.id,kind:"wait",action:"completed"}),g=F;continue}if(x.kind==="condition"){let $=a.answers.get(x.id);if($===void 0){if(!c)return {at:"pending"};if($=ve(x),$===void 0)return {at:"pending"};a.answers.set(x.id,$),V({flow:t.id,step:x.id,kind:"condition",action:"answered",answer:$?"yes":"no"});}return P(t,$?x.yes:x.no,a,c,u,g)}if(!a.done.has(x.id))return {at:"step",step:x,line:o,index:h,before:u};g=(y=a.at.get(x.id))!=null?y:g,u++;}return {at:"end"}},ne=t=>{let o=w.get(t.id);return !!o&&(o.dismissed||P(t,ee(t),o,false).at==="end")},Te=t=>`${Ft}:${t!=null?t:"visitor"}`,Ue=t=>`${Ft}:events:${t!=null?t:"visitor"}`,He=t=>`${Ft}:answers:${t!=null?t:"visitor"}`,ge=t=>{if(!t.finish||t.finish==="none"||t.shownBy==="code"||ke.has(t.id))return;let o=w.get(t.id);!o||o.dismissed||P(t,ee(t),o,false).at!=="end"||(ke.add(t.id),le={kind:t.finish,key:`${t.id}:${X()}`});},U=()=>{var a;Re=false;let t=(a=e.storage)==null?void 0:a.call(e);if(!t)return;let o={};for(let[c,u]of w)o[c]={done:[...u.done],...u.dismissed?{dismissed:true}:{},...u.answers.size?{answers:Object.fromEntries([...u.answers].map(([g,b])=>[g,b?"yes":"no"]))}:{},...u.at.size?{at:Object.fromEntries(u.at)}:{},...u.reached.size?{reached:Object.fromEntries(u.reached)}:{}};try{t.set(Te(e.personId()),JSON.stringify(o)),z.size&&t.set(He(e.personId()),JSON.stringify(Object.fromEntries(z))),M.size&&t.set(Ue(e.personId()),JSON.stringify([...M].slice(-200)));}catch(c){}},Fe=t=>{var o,a,c,u;for(let[g,b]of Object.entries(t!=null?t:{})){let y=B(g);for(let h of (o=b.done)!=null?o:[])y.done.add(h);b.dismissed&&(y.dismissed=true);for(let[h,x]of Object.entries((a=b.answers)!=null?a:{}))y.answers.has(h)||y.answers.set(h,x==="yes");for(let[h,x]of Object.entries((c=b.at)!=null?c:{}))typeof x=="number"&&!y.at.has(h)&&y.at.set(h,x);for(let[h,x]of Object.entries((u=b.reached)!=null?u:{}))typeof x=="number"&&(!y.reached.has(h)||x<y.reached.get(h))&&y.reached.set(h,x);}},Ge=t=>{var a;T&&clearTimeout(T),T=null;let o=t-X();o>0&&o<=864e5&&(T=setTimeout(()=>(T=null,I()),o+50),(a=T.unref)==null||a.call(T));},Y=false,L=()=>{var $;Y=false;let t=j(i);if(!t)return null;let o=B(t.id);if(o.dismissed)return null;let a=P(t,ee(t),o,true);if(Re&&U(),a.at==="wait"&&Ge(a.until),Y=a.at==="wait"||a.at==="pending",a.at!=="step")return null;let{step:c,line:u,index:g}=a,b=F=>!!F&&F.kind!=="wait"&&F.kind!=="condition";if(c.kind==="checklist"){let F=g;for(;F>0&&b(u[F-1])&&u[F-1].kind==="checklist";)F--;let ie=g;for(;ie+1<u.length&&b(u[ie+1])&&u[ie+1].kind==="checklist";)ie++;let ue=u.slice(F,ie+1).filter(b);for(let fe of ue)!o.done.has(fe.id)&&!k.has(`s:${fe.id}`)&&(k.add(`s:${fe.id}`),e.track(q,{flow:t.id,step:fe.id,kind:"checklist",action:"shown"}));return {type:"checklist",flow:t,items:ue.map(fe=>{let K=lr(fe),_e=K&&(K.kind==="tour"||K.kind==="modal")&&K.id!==t.id?j(K.id):void 0,ye=_e&&_e.shownBy!=="code"&&ee(_e).length?_e:void 0,Qe=K&&(K.kind==="page"?K.target.trim():K.kind==="code"||ye)?K:void 0;return {step:fe,done:o.done.has(fe.id),...ye&&(K==null?void 0:K.kind)==="tour"?{tour:ye}:{},...Qe?{opens:Qe}:{},...ye?{target:ye}:{}}})}}k.has(`s:${c.id}`)||(k.add(`s:${c.id}`),e.track(q,{flow:t.id,step:c.id,kind:c.kind,action:"shown"}));let y=u.slice(g+1),h=y.findIndex(F=>F.kind==="condition"),x=(h<0?y:y.slice(0,h)).filter(b).length;return {type:"step",flow:t,step:c,index:a.before,total:a.before+1+x,last:!x&&h<0,...c.kind==="question"?{answer:($=W.get(c.id))!=null?$:c.question?z.get(c.question.key):void 0,back:a.before>0}:{}}},G=()=>{var a,c,u;if(r){let g=r,b=(a=g.flow.followUps)==null?void 0:a[g.reason],y=b?1:0,h=g.plain?1:3+y+((c=g.flow.second)!=null&&c[g.reason]?1:0);return {type:"cancel",screen:g.screen,flow:g.flow,reason:g.reason,...g.screen==="followup"&&b?{followUp:b,answer:g.answer}:{},offer:g.screen==="offer"?g.offer:void 0,...g.screen==="offer"?{round:g.round}:{},price:g.options.price,busy:g.busy,error:g.error,step:g.screen==="survey"?1:g.screen==="followup"?2:g.screen==="offer"?1+y+g.round:h,steps:h}}let t=L();if(t)return t;if(i&&!Y){let g=J,b=i;J=null,i=null;let y=g?j(g.flow):void 0;if(g&&y){let h=he(ee(y)).find(F=>F.id===g.step),x=B(y.id);h&&!h.event&&!((u=w.get(b))!=null&&u.dismissed)&&!x.done.has(h.id)&&(te(x,h.id),V({flow:y.id,step:h.id,kind:"checklist",action:"completed"}),ge(y)),i=y.id;let $=L();if($)return $;Y||(i=null);}else if(l){let h=j(b),x=h?ce(h):void 0;Promise.resolve().then(()=>se(x));}}let o=d.find(g=>!O.has(g.id));return o?{type:"message",message:o}:null},I=()=>{let t=G();(t==null?void 0:t.type)==="message"&&!k.has(`m:${t.message.id}`)&&(k.add(`m:${t.message.id}`),e.track(It,{message:t.message.id,journey:t.message.journey,action:"shown"}));for(let o of [...R])try{o();}catch(a){}},re=t=>i===t.id?true:i&&j(i)&&!ne(j(i))?false:(i=t.id,e.track(q,{flow:t.id,action:"started"}),I(),true),me=t=>t.audience==="answered"?!!t.answered&&z.get(t.answered.question)===t.answered.option:t.audience!=="signed_in"||!!e.personId(),H=t=>{let o=j(t);return !o||ne(o)},oe=(t,o=ce(t))=>{var u;let a=(u=e.path)==null?void 0:u.call(e),c=at(o);if(c)return H(c);if(it(o))return false;if(wn(o))return a!==void 0&&$t(o,a);if(mn(o))return true;for(let g of M)if(st(o,g))return true;return false},se=t=>{var u,g;if(!S||i||!l||!e.personId()&&!((u=e.storage)!=null&&u.call(e)))return;let o=(g=e.path)==null?void 0:g.call(e),a=t&&!it(t)?de(t):"",c=Le().find(b=>(at(ce(b))?H(at(ce(b))):wn(ce(b))?o!==void 0&&$t(ce(b),o):mn(ce(b))||!!a&&de(ce(b))===a)&&me(b)&&ee(b).length&&!ne(b));c&&re(c);},be=(t,o,a)=>{let c=B(a.id);c.done.clear(),c.at.clear(),c.dismissed=false,J={flow:t.id,step:o},i=a.id,e.track(q,{flow:a.id,action:"started",from:t.id}),U(),I();},$e=(t,o,a)=>{let c=o.question,u=c.type==="text"?a.trim().slice(0,500):a.startsWith(Ie)?Ie+a.slice(Ie.length).trim().slice(0,490):a;z.set(c.key,u),W.delete(o.id),te(B(t.id),o.id),e.track(q,{flow:t.id,step:o.id,kind:"question",action:"completed",question:c.key,answer:u,label:fr(c,u)}),ge(t),U();},N=t=>{U(),ne(t)&&Promise.resolve().then(()=>se()),I();},De=()=>{let t=e.personId();_!==null&&_!==t&&(w.clear(),M.clear(),z.clear(),W.clear(),O.clear(),i=null,J=null,v=void 0),_=t;let o=(async()=>{var u,g,b,y;let a=(u=e.storage)==null?void 0:u.call(e);if(a)try{let h=await a.get(Te(t));h&&Fe(JSON.parse(h));let x=await a.get(Ue(t));if(x)for(let F of JSON.parse(x))typeof F=="string"&&M.add(F);let $=await a.get(He(t));if($)for(let[F,ie]of Object.entries(JSON.parse($)))typeof ie=="string"&&z.set(F,ie);}catch(h){}let c=Ce().length>0||!!(n!=null&&n.messages);if(t&&c&&v!==t){v=t;let h=await e.fetchInApp(t).catch(()=>null);if(h&&e.personId()===t){Fe(h.onboarding);for(let x of (g=h.events)!=null?g:[])typeof x=="string"&&M.add(de(x));for(let[x,$]of Object.entries((b=h.answers)!=null?b:{}))typeof $=="string"&&!z.has(x)&&z.set(x,$);d=((y=h.messages)!=null?y:[]).filter(x=>x&&x.id&&x.title);}}t||(d=[]),l=true,se(),I();})();return m=o.finally(()=>{m===o&&(m=null);}),m},Oe=t=>t.round>1?{round:2}:t.rule>=0?{rule:t.rule}:{},Ee=t=>{var c,u,g,b;let o={answer:t.answer,plan:t.options.plan,months:mr(t.options.customerSince,(c=e.now)==null?void 0:c.call(e))},a=(g=(u=t.flow.rules)==null?void 0:u[t.reason])!=null?g:[];t.rule=a.findIndex(y=>wr(y,o)),t.offer=t.rule<0?t.flow.offers[t.reason]:(b=a[t.rule].offer)!=null?b:void 0,t.round=1,t.screen=t.offer?"offer":"confirm";},We=(t,o,a)=>{var u;let c=t.screen==="offer"?t.offer:void 0;return {outcome:o,run:t.run,...t.reason?{reason:t.reason,reasonLabel:(u=t.flow.reasons.find(g=>g.id===t.reason))==null?void 0:u.label}:{},...t.answer?{answer:t.answer}:{},...o==="saved"&&c?{offer:c}:{},...a!=null&&a.trim()?{comment:a.trim().slice(0,500)}:{}}},we=(t,o)=>{var a;e.track(Xe,{action:"finished",run:t.run,version:t.flow.version,outcome:o.outcome,customer:(a=t.options.customer)!=null?a:"consumer",...o.reason?{reason:o.reason}:{},...o.answer?{answer:o.answer}:{},...o.offer?{offer:o.offer.kind,...Oe(t)}:{},...o.comment?{comment:o.comment}:{}}),r===t&&(r=null),t.resolve(o),I();},je=(t,o,a)=>{if(t.busy)return;let c=We(t,o,a),u=o==="saved"?t.options.onSave:t.options.onCancel;t.busy=true,t.error=void 0,I(),Promise.resolve().then(()=>u==null?void 0:u(c)).then(()=>we(t,c),()=>{t.busy=false,t.error=Ye("Something went wrong. Please try again."),I();});};return {setConfig:t=>{n=t,i&&!j(i)&&(i=null),I();},refresh:De,onEvent:t=>{var y;if(t==="$pageview"&&se(),!t||t.startsWith("$"))return;let o=de(t),a=!!o&&!M.has(o);a&&M.add(o);let c=j(i),u=false,g=[...c?[c]:[],...Ce().filter(h=>h.shownBy==="code"&&h.id!==(c==null?void 0:c.id))];for(let h of g){let x=B(h.id),$=false;for(let F of he(ee(h)))F.kind==="checklist"&&F.event&&!x.done.has(F.id)&&st(F.event,t)&&(te(x,F.id),$=true,e.track(q,{flow:h.id,step:F.id,kind:F.kind,action:"completed"}));$&&(u=true,ge(h));}if(u||a&&(c||g.length)?(U(),I()):a&&U(),!S||!e.personId()&&!((y=e.storage)!=null&&y.call(e)))return;let b=Le().find(h=>ee(h).length&&!it(ce(h))&&st(ce(h),t)&&me(h)&&!ne(h));b&&re(b);},openCancelFlow:(t={})=>{var b,y;if(r)return r.promise;let o=(b=n==null?void 0:n.cancelFlow)!=null?b:cr,a=t.customer!=="business"||o.reasons.length<2,c=()=>{},u=new Promise(h=>c=h),g={flow:o,options:t,plain:a,screen:a?"confirm":"survey",round:1,run:pr(),busy:false,resolve:c,promise:u};return r=g,e.track(Xe,{action:"shown",run:g.run,version:o.version,customer:(y=t.customer)!=null?y:"consumer",plain:a}),I(),u},startOnboarding:t=>{let o=t?j(t):Le().find(c=>ee(c).length&&!it(ce(c))&&!at(ce(c))&&!ne(c));if(!o||!ee(o).length||o.shownBy==="code")return false;let a=B(o.id);return a.dismissed=false,re(o)},view:G,subscribe:t=>(R.add(t),()=>R.delete(t)),cancel:{pick:t=>{!r||r.busy||r.screen!=="survey"||!r.flow.reasons.some(o=>o.id===t)||(r.reason!==t&&(r.answer=void 0),r.reason=t,r.error=void 0,I());},answer:t=>{let o=r;if(!o||o.busy||o.screen!=="followup")return;let a=t.slice(0,500);o.answer=a.trim()?a:void 0,I();},next:()=>{var o,a;let t=r;if(!(!t||!t.reason)){if(t.screen==="survey")e.track(Xe,{action:"answered",run:t.run,version:t.flow.version,reason:t.reason}),(o=t.flow.followUps)!=null&&o[t.reason]?t.screen="followup":Ee(t);else if(t.screen==="followup")t.answer=(a=t.answer)==null?void 0:a.trim(),Ee(t);else return;I();}},accept:t=>{var a;let o=r;!o||o.screen!=="offer"||!o.reason||(o.busy||e.track(Xe,{action:"offer",run:o.run,version:o.flow.version,reason:o.reason,offer:(a=o.offer)==null?void 0:a.kind,...Oe(o),outcome:"accepted"}),je(o,"saved",t));},decline:()=>{var a,c;let t=r;if(!t||t.screen!=="offer"||t.busy)return;e.track(Xe,{action:"offer",run:t.run,version:t.flow.version,reason:t.reason,offer:(a=t.offer)==null?void 0:a.kind,...Oe(t),outcome:"declined"});let o=t.round===1&&t.reason?(c=t.flow.second)==null?void 0:c[t.reason]:void 0;o?(t.offer=o,t.rule=void 0,t.round=2):t.screen="confirm",t.error=void 0,I();},confirm:t=>{let o=r;!o||o.screen!=="confirm"||je(o,"cancelled",t);},close:()=>{var a,c;let t=r;if(!t||t.busy)return;let o=We(t,"kept");(c=(a=t.options).onClose)==null||c.call(a,o),we(t,o);}},onboarding:{next:()=>{var a,c;let t=L();if((t==null?void 0:t.type)!=="step")return;if(t.step.kind==="question"){let u=t.step.question,g=(a=W.get(t.step.id))!=null?a:u?z.get(u.key):void 0;if(!u||!kn(u,g))return;$e(t.flow,t.step,g),I();return}te(B(t.flow.id),t.step.id),e.track(q,{flow:t.flow.id,step:t.step.id,kind:t.step.kind,action:"completed"}),ge(t.flow),U(),I();let o=t.step.kind==="modal"?dt(t.step.url):void 0;o&&((c=e.openUrl)==null||c.call(e,o));},check:t=>{let o=L();if((o==null?void 0:o.type)!=="checklist")return;let a=o.items.find(c=>c.step.id===t);!a||a.done||(te(B(o.flow.id),t),e.track(q,{flow:o.flow.id,step:t,kind:"checklist",action:"completed"}),ge(o.flow),U(),I());},dismiss:()=>{let t=L();!t||t.type!=="step"&&t.type!=="checklist"||(B(t.flow.id).dismissed=true,e.track(q,{flow:t.flow.id,...t.type==="step"?{step:t.step.id}:{},action:"dismissed"}),i=J&&J.flow!==t.flow.id&&j(J.flow)?J.flow:null,J=null,U(),I());},startTour:t=>{var c;let o=L();if((o==null?void 0:o.type)!=="checklist")return false;let a=(c=o.items.find(u=>u.step.id===t))==null?void 0:c.target;return a?(be(o.flow,t,a),true):false},open:t=>{var u,g;let o=L();if((o==null?void 0:o.type)!=="checklist")return false;let a=o.items.find(b=>b.step.id===t),c=a==null?void 0:a.opens;return !a||!c?false:(e.track(q,{flow:o.flow.id,step:t,kind:"checklist",action:"opened",opens:c.kind}),(c.kind==="tour"||c.kind==="modal")&&a.target?(be(o.flow,t,a.target),true):(!a.done&&!a.step.event&&(te(B(o.flow.id),t),e.track(q,{flow:o.flow.id,step:t,kind:"checklist",action:"completed"}),ge(o.flow)),U(),I(),c.kind==="page"?(u=e.navigate)==null||u.call(e,c.target.trim()):(g=e.task)==null||g.call(e,t,o.flow),true))},answer:t=>{let o=L();(o==null?void 0:o.type)!=="step"||o.step.kind!=="question"||(W.set(o.step.id,String(t).slice(0,500)),I());},skip:()=>{let t=L(),o=(t==null?void 0:t.type)==="step"&&t.step.kind==="question"?t.step.question:void 0;(t==null?void 0:t.type)!=="step"||!(o!=null&&o.optional)||(W.delete(t.step.id),te(B(t.flow.id),t.step.id),e.track(q,{flow:t.flow.id,step:t.step.id,kind:"question",action:"completed",question:o.key,skipped:true}),ge(t.flow),U(),I());},back:()=>{let t=L();if((t==null?void 0:t.type)!=="step"||t.step.kind!=="question"||!t.back)return;let o=he(ee(t.flow)),a=o.findIndex(u=>u.id===t.step.id),c=B(t.flow.id);for(let u=a-1;u>=0;u--)if(c.done.has(o[u].id)){c.done.delete(o[u].id),c.at.delete(o[u].id);break}U(),I();},item:t=>{let o=j(t);if(!o)return null;let a=w.get(o.id),c=he(ee(o)).map(b=>{let y=b.question?z.get(b.question.key):void 0;return {...b,done:!!(a!=null&&a.done.has(b.id)),...y!==void 0?{answer:y}:{}}}),u=c.length>0&&c.every(b=>b.done),g=!!(a!=null&&a.dismissed);return {item:o,steps:c,done:u,dismissed:g,eligible:!u&&!g&&me(o)&&oe(o)}},seen:t=>{let o=j(t);if(!o||o.shownBy!=="code"||!l)return;k.has(`f:${o.id}`)||(k.add(`f:${o.id}`),e.track(q,{flow:o.id,action:"started"}));let a=w.get(o.id);for(let c of he(ee(o)))if(!(a!=null&&a.done.has(c.id))&&!k.has(`s:${c.id}`)&&(k.add(`s:${c.id}`),e.track(q,{flow:o.id,step:c.id,kind:c.kind,action:"shown"}),c.kind!=="checklist"))break},complete:(t,o)=>{let a=j(t),c=a&&he(ee(a)).find(g=>g.id===o);if(!a||!c||c.kind==="question")return;let u=B(a.id);u.done.has(c.id)||(te(u,c.id),e.track(q,{flow:a.id,step:c.id,kind:c.kind,action:"completed"}),N(a));},dismissItem:t=>{let o=j(t);if(!o)return;let a=B(o.id);a.dismissed||(a.dismissed=true,e.track(q,{flow:o.id,action:"dismissed"}),i===o.id&&(i=null),N(o));},answerItem:(t,o,a)=>{let c=j(t),u=c&&he(ee(c)).find(g=>{var b;return g.kind==="question"&&(g.id===o||((b=g.question)==null?void 0:b.key)===o)});!c||!(u!=null&&u.question)||!kn(u.question,a)||($e(c,u,a),N(c));}},finale:()=>le,accent:()=>n==null?void 0:n.onboardingAccent,answers:()=>Object.fromEntries(z),message:{click:()=>{var a;let t=G();if((t==null?void 0:t.type)!=="message")return;O.add(t.message.id),e.track(It,{message:t.message.id,journey:t.message.journey,action:"clicked"});let o=dt(t.message.url);I(),o&&((a=e.openUrl)==null||a.call(e,o));},dismiss:()=>{let t=G();(t==null?void 0:t.type)==="message"&&(O.add(t.message.id),e.track(It,{message:t.message.id,journey:t.message.journey,action:"dismissed"}),I());}}}};var hr={questions:"question",checklist:"checklist",tour:"tour"},yn=(e,n,r={})=>{var v,_;let i=(v=r.type)!=null?v:"questions",d=(_=hr[i])!=null?_:"question",l=new Set,m=w=>{var O;return e(q,{code:de(n),name:n,type:i,...(O=r.order)!=null&&O.length?{order:r.order}:{},...w})};return {saw:(w,O)=>{l.has(w)||(l.add(w),m({step:w,title:O,kind:d,action:"shown"}));},answered:(w,O,k)=>m({step:w,kind:"question",action:"completed",question:w,answer:O,label:k!=null?k:O}),done:w=>m({step:w,kind:d,action:"completed"}),closed:w=>m({...w?{step:w}:{},kind:d,action:"dismissed"})}};var kr="ck_pick",br="ck_origin",lt=e=>typeof CSS!="undefined"&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,n=>`\\${n}`),yr=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),xn=e=>{let n=e.ownerDocument,r=m=>{try{return n.querySelectorAll(m).length===1}catch(v){return false}},i=e.getAttribute("data-ck-target");if(i)return `[data-ck-target="${i.replace(/"/g,'\\"')}"]`;if(e.id&&!/\d{3,}/.test(e.id)&&r(`#${lt(e.id)}`))return `#${lt(e.id)}`;let d=[],l=e;for(;l&&l!==n.documentElement&&d.length<6;){if(l!==e&&l.id&&!/\d{3,}/.test(l.id)){d.unshift(`#${lt(l.id)}`);break}let m=l.tagName.toLowerCase(),v=yr(l).map(R=>`.${lt(R)}`).join(""),_=l.parentElement,w=_?[..._.children].filter(R=>R.tagName===l.tagName):[],O=w.length>1?`:nth-of-type(${w.indexOf(l)+1})`:"";d.unshift(`${m}${v}${O}`);let k=d.join(" > ");if(r(k))return k;l=_;}return d.join(" > ")},Cn=()=>{var O;if(typeof window=="undefined"||window.top===window)return null;let e=new URLSearchParams(window.location.search);if(e.get(kr)!=="1")return null;let n;try{n=new URL((O=e.get(br))!=null?O:"").origin;}catch(k){return null}if(!/^https?:\/\//.test(n))return null;let r=k=>window.parent.postMessage(k,n),i=document.createElement("div");i.setAttribute("aria-hidden","true"),Object.assign(i.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 d=document.createElement("div");Object.assign(d.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"}),i.appendChild(d),document.body.appendChild(i);let l=null,m=k=>{if(l=k&&k!==i&&!i.contains(k)?k:null,!l){i.style.display="none";return}let R=l.getBoundingClientRect();Object.assign(i.style,{display:"block",left:`${R.left-2}px`,top:`${R.top-2}px`,width:`${R.width+4}px`,height:`${R.height+4}px`}),d.textContent=xn(l);},v=k=>m(document.elementFromPoint(k.clientX,k.clientY)),_=k=>{var S,M;k.preventDefault(),k.stopPropagation();let R=(S=document.elementFromPoint(k.clientX,k.clientY))!=null?S:l;!R||R===i||r({type:"mrrocket:picked",selector:xn(R),text:((M=R.textContent)!=null?M:"").trim().replace(/\s+/g," ").slice(0,80)});},w=k=>{k.key==="Escape"&&r({type:"mrrocket:pick-cancel"});};return window.addEventListener("mousemove",v,true),window.addEventListener("click",_,true),window.addEventListener("keydown",w,true),r({type:"mrrocket:pick-ready"}),()=>{window.removeEventListener("mousemove",v,true),window.removeEventListener("click",_,true),window.removeEventListener("keydown",w,true),i.remove();}};var xr={get:e=>{try{return window.localStorage.getItem(e)}catch(n){return null}},set:(e,n)=>{try{window.localStorage.setItem(e,n);}catch(r){}}},Rn=()=>{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){}},vn=e=>({track:e.track,personId:e.personId,auto:e.auto,storage:()=>e.canStore()?xr:null,openUrl:n=>window.location.assign(n),path:()=>window.location.pathname,navigate:n=>{var d;let r=(d=e.onNavigate)==null?void 0:d.call(e);if(r)return r(n);let i=dt(n);i&&window.location.assign(i);},task:(n,r)=>{var i,d;return (d=(i=e.onTask)==null?void 0:i.call(e))==null?void 0:d(n,r)},fetchInApp:async n=>{var d;if(!e.apiKey)return null;let r=(d=e.userHash)==null?void 0:d.call(e,n),i=await fetch(`${e.host}/api/sdk/inapp?key=${encodeURIComponent(e.apiKey)}&distinctId=${encodeURIComponent(n)}${r?`&userHash=${r}`:""}${ot()}`);return Ne(i.status),i.ok?await i.json():null}});var pt="mrr_ref",gt="mrr_ref",Cr="mrr_ref",Rr="mrr_click";var Je=/^[A-Za-z0-9_-]{1,64}$/;var vr=(e,n="ref")=>{let r=new URLSearchParams(e);return Or(i=>r.get(i),n)},Or=(e,n="ref")=>{let r=e(Cr);if(r&&Je.test(r)){let d=e(Rr);return {code:r,clickId:d&&Je.test(d)?d:null,direct:false}}let i=e(n);return i&&Je.test(i)?{code:i,clickId:null,direct:true}:null},On=e=>{var n;return `${e.code}.${(n=e.clickId)!=null?n:""}.${e.at}`},ut=(e,n=60,r=Date.now())=>{if(!e)return null;let[i,d,l]=e.split("."),m=Number(l);return !i||!Je.test(i)||!Number.isFinite(m)||d&&!Je.test(d)||r-m>n*864e5||m>r+864e5?null:{code:i,clickId:d||null,at:m}};var Z=null,mt=()=>typeof document!="undefined",En=e=>{var r;if(!mt())return;let n=(r=document.cookie.split("; ").find(i=>i.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);try{return n?decodeURIComponent(n):void 0}catch(i){return n}},wt=()=>{try{return typeof localStorage=="undefined"?null:localStorage}catch(e){return null}},Pt=()=>{var e,n;return Z||(mt()?(n=ut(En(pt),3650))!=null?n:ut((e=wt())==null?void 0:e.getItem(gt),3650):null)};var ft=(e,n)=>{var d;if(!mt())return;let r=Math.max(1,Math.round(n))*86400,i=typeof location!="undefined"&&location.protocol==="https:"?"; secure":"";document.cookie=`${pt}=${encodeURIComponent(On(e))}; path=/; max-age=${r}; samesite=lax${i}`;try{(d=wt())==null||d.setItem(gt,On(e));}catch(l){}},ht=()=>{var e;if(mt()){document.cookie=`${pt}=; path=/; max-age=0; samesite=lax`;try{(e=wt())==null||e.removeItem(gt);}catch(n){}}},_n=()=>{Z=null;},Sn=async e=>{var i,d,l;let n=vr(e.search,e.param),r=(i=e.now)!=null?i:Date.now();if(!n)return !Z&&e.store&&(Z=(l=ut(En(pt),e.days,r))!=null?l:ut((d=wt())==null?void 0:d.getItem(gt),e.days,r),Z||ht()),Z;if(Z={code:n.code,clickId:n.clickId,at:r},e.store&&ft(Z,e.days),e.beacon)try{let m=await e.beacon({code:n.code,clickId:n.clickId});m&&Z&&Z.code===n.code&&!Z.clickId&&(Z={...Z,clickId:m},e.store&&ft(Z,e.days));}catch(m){}return Z},In=e=>e==="$identify"||!e.startsWith("$");var Mt=3600*24*365,Pn=e=>{var r;if(typeof document=="undefined")return;let n=(r=document.cookie.split("; ").find(i=>i.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);if(n)try{return decodeURIComponent(n)}catch(i){return n}},kt=(e,n,r)=>{let i=window.location.protocol==="https:"?"; secure":"";document.cookie=`${e}=${encodeURIComponent(n)}; path=/; max-age=${r}; samesite=lax${i}`;},ze=e=>{document.cookie=`${e}=; path=/; max-age=0; samesite=lax`;},D={utm:{}},$n=()=>{var e;return (e=D.id)!=null?e:D.id=Ot()},At=(e,n)=>{if(e!=="cookies")return $n();let r=Pn(Se);if(r)return D.id=r;let i=$n();return kt(Se,i,Mt),i},Nt=e=>{var d;let n=Date.now(),r=D.session,i=(d=e?Pn(Ae):void 0)!=null?d:r&&n-r.last<18e5?r.id:Ot();return D.session={id:i,last:n},e&&kt(Ae,i,18e5/1e3),i},Lt=()=>{var r;let e=window.location.href;if(D.url===e)return;D.referrer=(r=D.url)!=null?r:document.referrer||void 0,D.url=e;let n=tn(window.location.search);Object.keys(n).length&&(D.utm=n);},Mn=()=>{let e=navigator,n=window;return e.doNotTrack==="1"||n.doNotTrack==="1"||e.globalPrivacyControl===true};var bt=window,_r=()=>{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,pe=e=>{An.has(e)||(An.add(e),console.warn(`[MRRocket] ${e}`));},Sr=()=>{var Wt,jt,Vt,Kt;let e=_r(),n=s=>{var f;return (f=e==null?void 0:e.getAttribute(`data-${s}`))!=null?f:void 0},r=(s,f)=>{let p=n(s);return p===void 0?f:!["false","0","off","no"].includes(p.trim().toLowerCase())},i=(Wt=e==null?void 0:e.src)!=null?Wt:"",d="";try{d=i?new URL(i,window.location.href).origin:"";}catch(s){d="";}n("locale")&&St(n("locale"));let l=((jt=n("key"))!=null?jt:"").trim(),m=((Vt=n("api-host"))!=null?Vt:d).trim().replace(/\/+$/,""),v=n("consent"),_=r("respect-dnt",false),w=r("heatmaps",true),O=r("errors",true),k=n("release"),R=n("attribution"),S=R==="always"||R==="off"?R:"consent",M=n("referral-param")||"ref",X={},T=(s,f)=>{var p;return (p=X[s])!=null?p:X[s]=new Promise((C,E)=>{var qt;let A=()=>bt[f];if(A())return C(A());let ae=(qt=n(`${s}-src`))!=null?qt:i?i.replace(/(\.min)?\.js(\?[^#]*)?(#.*)?$/,`-${s}$1.js?v=${nt}`):"";if(!ae)return E(new Error(s));let xe=document.createElement("script");xe.async=true,xe.src=ae,xe.onload=()=>A()?C(A()):E(new Error(s)),xe.onerror=()=>E(new Error(s)),document.head.appendChild(xe);}).catch(C=>{throw X[s]=void 0,C})},J=n("theme"),z={theme:J==="light"||J==="dark"?J:"auto",accent:n("accent")},W=new URLSearchParams(window.location.search),ke=nn(W.get(Zt)),le=W.get(en)==="1";le&&Cn();let Ce=W.get(Ke);if(Ce!==null){W.delete(Ke);let s=W.toString();history.replaceState(history.state,"",`${window.location.pathname}${s?`?${s}`:""}${window.location.hash}`);}let Le=Mn(),j=v==="cookies"||v==="off"?v:"cookieless",B=r("replay",false),Re="",V,te=null,ve,P=null,ne=false,Te=false,Ue=null,He=null,ge=window.location.pathname,U=[],Fe=new Set,Ge=[],Y=()=>_&&Le?"off":j,L=()=>!le&&Y()!=="off",G=()=>V!=null?V:Re,I=()=>Y()==="cookies"?G():V,re=s=>cn(te,s);l||pe('No public key. Add data-key="mrr_pub_\u2026" to the script tag; nothing is tracked until then.');let me=(s=false)=>{if(!U.length)return;if(!l){U.length=0;return}let f=`${m}/api/sdk/events`;for(let p of Yt(l,U.splice(0),{v:nt,errors:O,platform:"web"},re(I())))s&&"sendBeacon"in navigator&&navigator.sendBeacon(f,p)||fetch(f,{method:"POST",headers:{"content-type":"application/json"},body:p,keepalive:true}).then(E=>{E.status===401?Ne(401):E.ok||pe(`Events were rejected with ${E.status}. Check data-key (MRRocket \u203A Settings \u203A Products).`);}).catch(()=>pe(`Could not reach ${m||"this origin"} to send events. Check data-api-host.`));},H=null,oe=null,se=(s,f,p=Date.now(),C)=>{if(!L())return;let E=In(s)?Pt():null;U.push({event:s,props:E?{...f,$referral:{code:E.code,clickId:E.clickId}}:f,distinctId:I(),sessionId:Nt(Y()==="cookies"),ts:p,url:C!=null?C:window.location.href,referrer:D.referrer,...D.utm,screen:{w:window.screen.width,h:window.screen.height}});},be=(s,f)=>{typeof s!="string"||!s||(se(s,f),L()&&(H==null||H.event(s)),N.onEvent(s));},$e={},N=bn(vn({host:m,apiKey:l,track:se,personId:()=>L()?V:void 0,userHash:re,canStore:()=>Y()==="cookies",auto:r("onboarding",true),onNavigate:()=>$e.onNavigate,onTask:()=>$e.onTask})),De=false,Oe;N.subscribe(()=>{De||!N.view()||le||(De=true,T("flows","__mrrocketFlows").then(s=>s.mountFlows(N,z)).catch(()=>{De=false,pe("The cancel flow and onboarding dialogs did not load. Check that sdk-flows.js is served next to sdk.js.");}));});let Ee=(s,f)=>{if(!L())return;let p=`${window.location.pathname}|${s}`;Fe.has(p)||(Fe.add(p),be("$exposure",{experiment:s,variant:f}));},We=()=>{let s=on(P,window.location.href,G(),ke);return s!=null&&s.to?(me(true),window.location.replace(s.to),true):(s!=null&&s.experiment&&Ee(s.experiment,s.variant),false)},we=()=>{if(!P)return;let s=document.querySelectorAll("[data-ck-text]");if(!s.length)return;let f=rn(P,G(),ke),p=new Set;s.forEach(C=>{var ae,xe;let E=C.dataset.ckText;if(!E)return;p.add(E),C.dataset.ckDefault===void 0&&(C.dataset.ckDefault=(ae=C.textContent)!=null?ae:"");let A=(xe=f[E])!=null?xe:C.dataset.ckDefault;C.textContent!==A&&(C.textContent=A);});for(let C of P.experiments)C.variants.some(E=>{var A;return Object.keys((A=E.changes)!=null?A:{}).some(ae=>p.has(ae))})&&Ee(C.key,qe(C.key,P,G(),ke));},je=()=>{var s,f;return (f=(s=P==null?void 0:P.referral)==null?void 0:s.cookieDays)!=null?f:60},yt=()=>S==="always"?Y()!=="off":S==="consent"&&Y()==="cookies",xt=null,t=false,o=()=>{if(!ne||le)return;if(S==="off"||Y()==="off"){_n(),(S==="off"||t)&&ht();return}let s=window.location.href;xt!==s&&(xt=s,Sn({search:window.location.search,param:M,store:yt(),days:je(),beacon:l?({code:f,clickId:p})=>fetch(`${m}/api/sdk/affiliate/click`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:l,code:f,clickId:p,url:s,referrer:document.referrer||void 0}),keepalive:true}).then(C=>C.ok?C.json():null).then(C=>{var E;return (E=C==null?void 0:C.clickId)!=null?E:null}):void 0}));},a=()=>{let s=yt(),f=Pt();s&&f?ft(f,je()):!s&&t&&ht(),t=s;},c=0,u=false,g=()=>{var C,E;let s=L()&&B&&!!(P!=null&&P.replay)&&!!l;if(s===u)return;u=s;let f=++c;if(!s){H==null||H.stop(true),H=null;return}let p=(E=(C=P==null?void 0:P.replay)==null?void 0:C.sampleRate)!=null?E:.1;T("replay","__mrrocketReplay").then(A=>A.startReplay({host:m,apiKey:l,sessionId:Nt(Y()==="cookies"),distinctId:I(),identified:!!V,userHash:re(I()),sampleRate:p,warn:pe})).then(A=>{f!==c?A==null||A.stop(true):H=A;}).catch(()=>pe("Session recording could not start (the recorder did not load)."));},b=r("messenger",false),y=null,h=s=>{le||l&&(y!=null||(y=T("messenger","__mrrocketMessenger").then(f=>{var A;let p=ae=>n(`messenger-${ae}`)===void 0?void 0:r(`messenger-${ae}`,true),C=n("messenger-position"),E=(A=n("messenger-theme"))!=null?A:J;return f.mountMessenger({host:m,apiKey:l,distinctId:G,user:()=>ve,userHash:()=>re(G()),launcher:b,position:C,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:p("ask-email"),help:p("help"),sound:p("sound"),preview:p("preview"),theme:E==="light"||E==="dark"||E==="auto"?E:void 0,accent:n("accent")})})),y.then(s).catch(()=>{y=null,pe("sdk-messenger.js did not load.");}));},x=n("forms")==="auto",$=false,F=()=>{$||!l||le||!document.querySelector(x?"form":"form[data-mrrocket-form]")||($=true,T("forms","__mrrocketForms").then(s=>s.watchForms({host:m,apiKey:l,auto:x,distinctId:()=>L()?I():void 0,userHash:re,identified:()=>!!V,identify:Tt,tracking:L,referrer:()=>D.referrer,utm:()=>D.utm})).catch(()=>$=false));},ie=()=>{!Te||!L()||He===window.location.pathname||(He=window.location.pathname,be("$pageview",{path:window.location.pathname}));},ue=null,fe=()=>{let s=ue;w&&s&&s.max>0&&se("$scroll",{depth:s.max,docH:s.docH,vw:window.innerWidth,vh:window.innerHeight},Date.now(),s.url),ue=null;},K=()=>{var E,A;if(!w||!L()||le)return;let s=document.documentElement,f=Math.max(s.scrollHeight,(A=(E=document.body)==null?void 0:E.scrollHeight)!=null?A:0),p=zt(),C=window.location.href;(ue==null?void 0:ue.url)!==C?ue={url:C,max:p,docH:f}:p>ue.max&&(ue={url:C,max:p,docH:f});},_e=()=>{let s=window.location.pathname;s!==ge&&(ge=s,!(ne&&We())&&(fe(),Lt(),H==null||H.page(s),oe==null||oe.crumb("navigation",s),ie(),o(),window.setTimeout(()=>{K(),we(),F();},0)));},ye=()=>{let s=Y(),f=Ue;Ue=s,f==="cookies"&&s!=="cookies"&&(ze(Se),ze(Ae)),s==="off"&&(U.length=0,D.session=void 0),f==="cookies"&&s!=="cookies"&&Rn(),Re=At(s),a(),o(),g(),ie(),K();},Qe=s=>{let{analytics:f,replay:p}=typeof s=="string"?{analytics:s,replay:void 0}:s!=null?s:{};if(f!==void 0&&f!=="cookieless"&&f!=="cookies"&&f!=="off"){pe('setConsent: use "cookies", "cookieless" or "off".');return}f==="off"&&(U.length=0,V&&Y()!=="off"&&(U.push({event:Qt,distinctId:V,ts:Date.now()}),me(true))),f&&(j=f),typeof p=="boolean"&&(B=p),ye(),ne&&N.refresh();},Tt=(s,f,p)=>{if(typeof s!="string"||!s)return;let C=I();te=an(te,s,p==null?void 0:p.hash),V=s,se("$identify",{...f,id:s,...C&&C!==s?{previousId:C}:{}}),H==null||H.identify(s,re(s)),Y()==="cookies"&&kt(Se,s,Mt),ve={...f,id:s},we(),ne&&N.refresh(),y==null||y.then(E=>E.refresh());},Ze={track:be,identify:Tt,reset:()=>{me(),V=void 0,te=null,ve=void 0,Fe.clear(),Y()==="cookies"&&(ze(Se),ze(Ae)),D.id=void 0,D.session=void 0,Re=At(Y()),we(),ne&&N.refresh(),y==null||y.then(s=>s.refresh());},captureError:s=>oe==null?void 0:oe.capture(s,"manual"),setConsent:Qe,setLocale:St,currentLocale:rt,getFlag:s=>vt(s,P,G(),{...ve})!==false,getFlagVariant:s=>{let f=vt(s,P,G(),{...ve});return typeof f=="string"?f:null},getVariant:s=>{let f=qe(s,P,G(),ke);return (P||ke[s])&&Ee(s,f),f},ready:s=>{typeof s=="function"&&(ne?window.setTimeout(()=>s(Ze),0):Ge.push(s));},getDistinctId:G,cancelFlow:{open:s=>N.openCancelFlow(s)},onboarding:{start:s=>N.startOnboarding(s),get:s=>{let f=N.onboarding.item(s);return f&&!f.done&&!f.dismissed&&N.onboarding.seen(s),f},subscribe:s=>N.subscribe(()=>s()),complete:(s,f)=>N.onboarding.complete(s,f),dismiss:s=>N.onboarding.dismissItem(s),answer:(s,f,p)=>N.onboarding.answerItem(s,f,p),report:(s,f)=>yn(be,s,f),setHandlers:s=>{$e={onNavigate:typeof(s==null?void 0:s.onNavigate)=="function"?s.onNavigate:void 0,onTask:typeof(s==null?void 0:s.onTask)=="function"?s.onTask:void 0};}},openCancelFlow:s=>N.openCancelFlow(s),startOnboarding:s=>N.startOnboarding(s),paywall:{open:(s,f)=>(Oe!=null?Oe:Oe=T("flows","__mrrocketFlows").then(p=>p.paywallHost({config:()=>P,distinctId:G,track:se},z))).then(p=>p.open(s,f))},push:{subscribe:s=>{let f=L()?V:void 0;if(!f)return Promise.resolve({status:"not-signed-in"});let p=window.Notification,C=Promise.resolve(p&&p.permission==="default"&&(s==null?void 0:s.ask)!==false?p.requestPermission():p==null?void 0:p.permission);return T("push","__mrrocketPush").then(E=>E.subscribeWebPush({host:m,apiKey:l,distinctId:f,userHash:re(f),permission:C},s))},unsubscribe:()=>T("push","__mrrocketPush").then(s=>s.unsubscribeWebPush({host:m,apiKey:l,distinctId:V,userHash:re(V)}))},messenger:{open:s=>h(f=>f.open(s)),close:()=>{y==null?void 0:y.then(s=>s.close()).catch(()=>{});},toggle:()=>h(s=>s.toggle())},openMessenger:()=>h(s=>s.open()),version:nt};Lt(),ye();let Pe=bt.mrrocket,Ln=(Kt=Pe==null?void 0:Pe.q)!=null?Kt:[],Ct=Pe&&typeof Pe=="object"?Pe:{};Object.assign(Ct,Ze,{__loaded:true}),delete Ct.q,bt.mrrocket=Ct;for(let[s,f]of Ln){let p=Ze[s];if(typeof p=="function")try{p(...Array.from(f!=null?f:[]));}catch(C){console.error(C);}}Te=true,ie(),O&&l&&!le&&(oe=ln({host:m,apiKey:l,release:k,context:()=>{var s;return {send:L(),distinctId:I(),sessionId:(s=D.session)==null?void 0:s.id,userHash:re(I())}},warn:pe}),oe.crumb("navigation",window.location.pathname));for(let s of ["pushState","replaceState"]){let f=history[s];history[s]=function(...p){let C=f.apply(this,p);return _e(),C};}window.addEventListener("popstate",_e);let Tn=new Ve;document.addEventListener("click",s=>{var A;s.target instanceof Element&&s.target.closest("[data-ck-messenger]")&&(s.preventDefault(),h(ae=>ae.open()));let f=s.target instanceof Element?s.target.closest("[data-ck-goal]"):null;if(f!=null&&f.dataset.ckGoal&&be(f.dataset.ckGoal,{text:(A=f.textContent)==null?void 0:A.trim().slice(0,80)}),!L())return;let p=Jt(s);if(!p)return;let C=Tn.push(p.x,p.y,Date.now());if((p.label||p.selector)&&(oe==null||oe.crumb("click",p.label||p.selector)),H==null||H.click(p,C),!w)return;let E={x:p.x,y:p.y,vw:p.vw,vh:p.vh,docH:p.docH,selector:p.selector,label:p.label,dead:!p.interactive};se("$click",E),C&&se("$rageclick",E);});let Rt=0;window.addEventListener("scroll",()=>{Rt||(Rt=window.requestAnimationFrame(()=>{Rt=0,K();}));},{passive:true}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>K()):K(),window.setInterval(()=>me(),2e3),window.addEventListener("pagehide",()=>{fe(),me(true);});let Ut=()=>{if(ne=true,We())return;let s=sn(P,Ce);s&&Ee(s.experiment,s.variant),document.documentElement.classList.remove("ck-hide"),o(),g(),N.setConfig(P),N.refresh(),b&&(document.body?h():document.addEventListener("DOMContentLoaded",()=>h())),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{we(),F();}):(we(),F());for(let f of Ge.splice(0))try{f(Ze);}catch(p){console.error(p);}},Ht=0,Dt=s=>{let f=++Ht;return fetch(`${m}/api/sdk/config?key=${encodeURIComponent(l)}${ot()}`).then(p=>(p.ok||pe(`Config request to ${m||"this origin"} answered ${p.status}. Check data-key and data-api-host.`),p.ok?p.json():null)).then(p=>{p&&Array.isArray(p.experiments)&&f===Ht&&(P=p,fn(p.words,p.lang)),s();}).catch(()=>{pe(`Could not reach ${m||"this origin"}. Check data-api-host. The page keeps its own texts and flags stay off.`),s();})};l?(Dt(Ut),pn(()=>{Dt(()=>{N.setConfig(P),we();});})):Ut();},Nn;typeof window!="undefined"&&typeof document!="undefined"&&!((Nn=bt.mrrocket)!=null&&Nn.__loaded)&&Sr();
2
2
  })();
package/dist/client.js CHANGED
@@ -120,16 +120,38 @@ var CockpitProvider = ({
120
120
  setMounted(true);
121
121
  return params.get(EMBED_PARAM) === "1" ? startPicker() ?? void 0 : void 0;
122
122
  }, []);
123
- const setConsent = useCallback((choice) => {
124
- const { analytics: mode, replay } = typeof choice === "string" ? { analytics: choice, replay: void 0 } : choice;
125
- if (mode === "off") {
126
- queue.current.length = 0;
127
- const now = live.current;
128
- if (now.tracking && now.identified && now.sendId) queue.current.push({ event: CONSENT_OFF_EVENT, distinctId: now.sendId, ts: Date.now() });
129
- }
130
- if (mode) setConsentState(mode);
131
- if (typeof replay === "boolean") setReplayConsent(replay);
132
- }, []);
123
+ const sendNow = useCallback(
124
+ (events, beacon, hash) => {
125
+ if (!apiKey) return;
126
+ const url = `${host}/api/sdk/events`;
127
+ for (const body of bodies(apiKey, events, { v: SDK_VERSION, errors }, hash)) {
128
+ const sent = beacon && typeof navigator !== "undefined" && "sendBeacon" in navigator && navigator.sendBeacon(url, body);
129
+ if (!sent)
130
+ fetch(url, { method: "POST", headers: { "content-type": "application/json" }, body, keepalive: true }).then((r) => {
131
+ if (r.status === 401) warnUnsigned(401);
132
+ else if (!r.ok) warnOnce(`Events were rejected with ${r.status}. Check the public key (Settings \u203A SDK) and NEXT_PUBLIC_MRROCKET_HOST.`);
133
+ }).catch(() => warnOnce(`Could not reach ${host || "this origin"} to send events. Check NEXT_PUBLIC_MRROCKET_HOST.`));
134
+ }
135
+ },
136
+ [apiKey, host, errors]
137
+ );
138
+ const setConsent = useCallback(
139
+ (choice) => {
140
+ const { analytics: mode, replay } = typeof choice === "string" ? { analytics: choice, replay: void 0 } : choice;
141
+ if (mode === "off") {
142
+ queue.current.length = 0;
143
+ const now = live.current;
144
+ const who = now.identified ? now.sendId : bootstrap;
145
+ if (now.tracking && who) {
146
+ live.current = { ...now, tracking: false };
147
+ sendNow([{ event: CONSENT_OFF_EVENT, distinctId: who, ts: Date.now() }], true, hashOf(who));
148
+ }
149
+ }
150
+ if (mode) setConsentState(mode);
151
+ if (typeof replay === "boolean") setReplayConsent(replay);
152
+ },
153
+ [bootstrap, hashOf, sendNow]
154
+ );
133
155
  const lastProp = useRef(consentProp);
134
156
  useEffect(() => {
135
157
  if (lastProp.current === consentProp) return;
@@ -198,17 +220,9 @@ var CockpitProvider = ({
198
220
  queue.current.length = 0;
199
221
  return;
200
222
  }
201
- const url = `${host}/api/sdk/events`;
202
- for (const body of bodies(apiKey, queue.current.splice(0), { v: SDK_VERSION, errors }, hashOf(live.current.sendId))) {
203
- const sent = beacon && typeof navigator !== "undefined" && "sendBeacon" in navigator && navigator.sendBeacon(url, body);
204
- if (!sent)
205
- fetch(url, { method: "POST", headers: { "content-type": "application/json" }, body, keepalive: true }).then((r) => {
206
- if (r.status === 401) warnUnsigned(401);
207
- else if (!r.ok) warnOnce(`Events were rejected with ${r.status}. Check the public key (Settings \u203A SDK) and NEXT_PUBLIC_MRROCKET_HOST.`);
208
- }).catch(() => warnOnce(`Could not reach ${host || "this origin"} to send events. Check NEXT_PUBLIC_MRROCKET_HOST.`));
209
- }
223
+ sendNow(queue.current.splice(0), beacon, hashOf(live.current.sendId));
210
224
  },
211
- [apiKey, host, errors, hashOf]
225
+ [apiKey, hashOf, sendNow]
212
226
  );
213
227
  useEffect(() => {
214
228
  const timer = window.setInterval(() => flush(), 2e3);