@mrrocket/sdk 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/README.md +20 -0
- package/dist/browser/mrrocket-forms.js +1 -0
- package/dist/browser/mrrocket.js +1 -1
- package/dist/client.d.ts +7 -1
- package/dist/client.js +26 -0
- package/dist/client.js.map +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/core.js.map +1 -1
- package/dist/forms.d.ts +87 -0
- package/dist/forms.js +124 -0
- package/dist/forms.js.map +1 -0
- package/dist/react-native/index.d.cts +1 -1
- package/dist/react-native/index.d.ts +1 -1
- package/dist/react-native/index.js +1 -1
- package/dist/react-native/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
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.
|
|
5
|
+
## 0.12.0 (not published yet)
|
|
6
|
+
|
|
7
|
+
- **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.
|
|
8
|
+
- **Next.js:** new `forms` prop on `<CockpitProvider>`: `true` (default, marked forms), `"auto"` or `false`; the capture code is a dynamic import.
|
|
9
|
+
- **Script tag:** marked forms are captured with no new attribute; `data-forms="auto"` turns on auto-detection. The capture code is a seventh file, `sdk-forms.js` (`dist/browser/mrrocket-forms.js`, about 2 KB gzip), loaded only on pages with a form to capture; `sdk.js` stays within its 14.5 KB budget.
|
|
10
|
+
- New module `forms` with `fieldsOf`, `sendable`, `captures`, `watchForms` and `SENSITIVE`.
|
|
11
|
+
- Version reported in event batches: `0.12.0`.
|
|
12
|
+
|
|
13
|
+
## 0.11.0
|
|
6
14
|
|
|
7
15
|
- **Onboarding with waits and conditions:** a flow from MRRocket › Conversion › Onboarding may hold a **wait** ("1 day": the next step shows that long after the one before was done; a short wait comes back on its own, a long one at the next visit) and a **condition** that forks it into a Yes and a No path: "Did <event> happen?" (the person's events from MRRocket, plus what they did on this device) or "Is on <page>?" (the path when they reach it; `*` at the end for everything below). Decided once per person and kept with their progress; like a journey's branch it ends its line. New `$onboarding` actions: a wait records `shown` and `completed`, a condition `answered` with `answer: "yes" | "no"`. The config's `onboarding[].nodes` carries the whole flow; `steps` still holds what older versions may show (the steps before the first wait or condition). Apps have no page path, so "Is on <page>?" answers no there.
|
|
8
16
|
- **Tour steps point at any element:** a step's target may be a CSS selector (`#new-project`, `.toolbar > button:nth-of-type(2)`) as well as a `data-ck-target` name.
|
package/README.md
CHANGED
|
@@ -499,6 +499,26 @@ Also `data-messenger-greeting`, `-label`, `-position="bottom-left"`, and "false"
|
|
|
499
499
|
|
|
500
500
|
In React Native, `<MRRocketProvider messenger={{ launcher: true }}>` adds the bubble, `useMessenger().open()` opens it from your own button; a new answer shows as a banner at the top, with a light haptic when `expo-haptics` is installed. The provider also shows your live in-app survey (`surveys={false}` to switch off) and the feedback sheet (`useFeedback().open()`). With the person's consent (`replay`) and `react-native-view-shot` installed, the app also records sessions as screen pictures for Sessions: none while the keyboard is open, and `<MRRocketMask>` areas are painted black on the server before storing. Taps go to Heatmaps as clicks on the current screen; the provider then wraps the app in one `View` with `flex: 1` (`heatmaps={false}` to switch off).
|
|
501
501
|
|
|
502
|
+
## 19. Form leads (0.12.0)
|
|
503
|
+
|
|
504
|
+
A form on your site becomes a contact in MRRocket when someone submits it. Mark the form with its name, and (optional) the checkbox that asks for permission to email:
|
|
505
|
+
|
|
506
|
+
```html
|
|
507
|
+
<form data-mrrocket-form="Demo request">
|
|
508
|
+
<input type="email" name="email" required>
|
|
509
|
+
<input type="text" name="name">
|
|
510
|
+
<label><input type="checkbox" name="newsletter" data-mrrocket-consent> Email me product news</label>
|
|
511
|
+
<button type="submit">Request a demo</button>
|
|
512
|
+
</form>
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
- **What is sent** to `POST {host}/api/sdk/forms` (`sendBeacon`, so it survives the page leaving): the email (required), the name (a full-name field, or first and last), the other fields a person typed, the form's name, the page, the referrer and UTM, and whether the `data-mrrocket-consent` box was ticked. **Never** passwords, card fields, hidden fields, files, fields whose name looks sensitive (password, token, card, iban, ssn …) or anything inside `data-mrrocket-ignore`. At most 30 fields, 1,000 characters each.
|
|
516
|
+
- **In MRRocket** the contact gets the source "Form: Demo request", the fields on its timeline and the product as a lead. Consent is recorded as the contact's legal basis to email only when the box was ticked; without it the contact has no basis until you set one.
|
|
517
|
+
- **Linked to the visitor:** with analytics consent the lead carries the visitor id, and the SDK calls `identify(email)` if your code has not identified the person, so their visits before the form count for the contact.
|
|
518
|
+
- **Next.js:** on by default for marked forms (`forms={false}` switches it off). `forms="auto"` also captures any form with an email field, never one with a password field.
|
|
519
|
+
- **Script tag:** marked forms work as they are; the capture code (`sdk-forms.js`, about 2 KB gzip) loads only on pages with one. `data-forms="auto"` on the script tag captures any email form.
|
|
520
|
+
- **Not your form?** Typeform, Tally, Cal.com, Calendly, Webflow and Framer post to the product's lead webhook instead (MRRocket › Settings › Integrations › Leads and API).
|
|
521
|
+
|
|
502
522
|
## Privacy and consent
|
|
503
523
|
|
|
504
524
|
```tsx
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(){'use strict';var k=/pass(word|wd|code)?|pwd|secret|token|csrf|xsrf|nonce|captcha|honeypot|card|^cc([-_ ]|num|exp|$)|cvv|cvc|csc|expir|iban|(^|[^a-z])bic([^a-z]|$)|swift|routing|account[-_ ]?(no|num)|sort[-_ ]?code|(^|[^a-z])ssn([^a-z]|$)|social[-_ ]?sec|tax[-_ ]?id|vat[-_ ]?id|steuer|passport|(^|[^a-z])(pin|otp|pw)([^a-z]|$)|one[-_ ]?time|auth(?!or)|api[-_ ]?key|session|signature/i,h=new Set(["password","hidden","file","submit","button","reset","image"]),w=/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/,_=30,F=1e3,v=e=>e.toLowerCase().replace(/[\s_-]+/g,""),x=e=>{var n;if(e.ignored||h.has(e.type))return false;let t=((n=e.autocomplete)!=null?n:"").toLowerCase();return /^cc-|password|one-time-code/.test(t)?false:!k.test(e.name)},E=e=>e.type==="email"||/e-?mail/i.test(e.name)||e.autocomplete==="email",L=e=>{var u;let t=null,n=null,a=null,c=null,o,r={};for(let i of e){if(i.consent){o=(o!=null?o:false)||!i.unchecked;continue}if(!i.name||!x(i)||i.unchecked)continue;let s=i.value.trim().slice(0,F);if(!s)continue;let d=v(i.name),f=((u=i.autocomplete)!=null?u:"").toLowerCase();if(!t&&E(i)&&w.test(s)){t=s.toLowerCase();continue}if(!n&&(f==="name"||["name","fullname","yourname","contactname"].includes(d))){n=s.slice(0,100);continue}if(!a&&(f==="given-name"||["firstname","first","vorname","givenname","fname"].includes(d))){a=s.slice(0,60);continue}if(!c&&(f==="family-name"||["lastname","last","nachname","surname","familyname","lname"].includes(d))){c=s.slice(0,60);continue}let l=i.name.trim().slice(0,60);l in r?r[l]=`${r[l]}, ${s}`.slice(0,F):Object.keys(r).length<_&&(r[l]=s);}let m=n!=null?n:[a,c].filter(Boolean).join(" ")||null;return {email:t,name:m,fields:r,...o===void 0?{}:{consent:o}}},I=e=>(e.getAttribute("data-mrrocket-form")||e.getAttribute("name")||e.id||e.getAttribute("aria-label")||`Form on ${window.location.pathname}`).trim().slice(0,100),O=(e,t)=>e.closest("[data-mrrocket-ignore]")?false:e.hasAttribute("data-mrrocket-form")?true:t&&!!e.querySelector('input[type="email"], input[name*="email" i]')&&!e.querySelector('input[type="password"]'),M=e=>Array.from(e.elements).flatMap(t=>{var o;if(!(t instanceof HTMLInputElement||t instanceof HTMLSelectElement||t instanceof HTMLTextAreaElement))return [];if(t.disabled)return [];let n=t instanceof HTMLInputElement?t.type.toLowerCase():t instanceof HTMLSelectElement?"select":"textarea",a=n==="checkbox"||n==="radio",c=t instanceof HTMLSelectElement&&t.multiple?Array.from(t.selectedOptions,r=>r.value).join(", "):a&&t.value==="on"?"yes":t.value;return [{name:t.name||t.id||"",type:n,value:c,autocomplete:(o=t.getAttribute("autocomplete"))!=null?o:void 0,unchecked:a&&!t.checked,ignored:!!t.closest("[data-mrrocket-ignore]"),consent:t.hasAttribute("data-mrrocket-consent")}]}),b=e=>{var c;let t=window;(c=t.__mrrocketFormsOff)==null||c.call(t);let n=o=>{var l,p,g;let r=o.target;if(!(r instanceof HTMLFormElement)||!O(r,!!e.auto))return;let m=L(M(r));if(!m.email)return;let u=Object.fromEntries(Object.entries((p=(l=e.utm)==null?void 0:l.call(e))!=null?p:{}).filter(y=>typeof y[1]=="string"&&!!y[1])),i={key:e.apiKey,form:I(r),url:window.location.href.slice(0,500),title:document.title.slice(0,200)||void 0,referrer:((g=e.referrer)==null?void 0:g.call(e))||document.referrer||void 0,...Object.keys(u).length?{utm:u}:{},distinctId:e.distinctId(),...m},s=JSON.stringify(i),d=`${e.host}/api/sdk/forms`;"sendBeacon"in navigator&&navigator.sendBeacon(d,new Blob([s],{type:"text/plain"}))||fetch(d,{method:"POST",headers:{"content-type":"text/plain"},body:s,keepalive:true}).catch(()=>{}),e.tracking()&&!e.identified()&&e.identify(m.email,{email:m.email,...m.name?{name:m.name}:{}});};document.addEventListener("submit",n,true);let a=()=>{document.removeEventListener("submit",n,true),t.__mrrocketFormsOff===a&&delete t.__mrrocketFormsOff;};return t.__mrrocketFormsOff=a,a};window.__mrrocketForms={watchForms:b};})();
|
package/dist/browser/mrrocket.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){'use strict';var Zt=Object.defineProperty;var en=(e,t,r)=>t in e?Zt(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r;var he=(e,t,r)=>en(e,typeof t!="symbol"?t+"":t,r);var kt=e=>{let t=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);s<128?t+=1:s<2048?t+=2:s>=55296&&s<=56319&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(t+=4,r++):t+=3;}return t},tn=(e,t,r)=>{let s=`{"key":${JSON.stringify(e)},"sdk":${JSON.stringify(r)},"events":[`,c=kt(s)+2,a=[],f=[],C=[],v=c,k=()=>{f.length&&a.push({body:`${s}${f.join(",")}]}`,events:C}),f=[],C=[],v=c;};for(let E of t){let g=JSON.stringify(E),w=kt(g)+1;c+w>6e4||((f.length===100||v+w>6e4)&&k(),f.push(g),C.push(E),v+=w);}return k(),a},yt=(e,t,r)=>tn(e,t,r).map(s=>s.body);var xe=class{constructor(t=1e3,r=30,s=3){he(this,"windowMs",t);he(this,"radius",r);he(this,"count",s);he(this,"clicks",[]);he(this,"fired",false);}push(t,r,s){let c=this.clicks.filter(a=>s-a.t<=this.windowMs&&Math.hypot(a.x-t,a.y-r)<=this.radius);return c.length!==this.clicks.length&&(this.fired=false),this.clicks=[...c,{x:t,y:r,t:s}],this.clicks.length>=this.count&&!this.fired?(this.fired=true,true):false}};var nn='a[href],button,input,select,textarea,label,summary,[role="button"],[role="link"],[role="tab"],[role="menuitem"],[role="checkbox"],[role="switch"],[onclick],[data-ck-goal]',rn="[data-ck-mask]",on="[data-ck-block]",bt=/\d{4,}|^[a-z]{1,3}-[a-z0-9]{5,}$|^_|__|css-|^sc-|^jsx-/i,sn=e=>{let t=e.tagName.toLowerCase();if(e.id&&!bt.test(e.id)&&e.id.length<=40)return `${t}#${e.id}`;let r=typeof e.className=="string"?e.className.split(/\s+/).filter(a=>a&&!bt.test(a)&&a.length<=30&&!a.includes(":")):[],s=r.length?`${t}.${r.slice(0,2).join(".")}`:t,c=e.parentElement?[...e.parentElement.children].filter(a=>a.tagName===e.tagName):[];return c.length>1?`${s}:nth-of-type(${c.indexOf(e)+1})`:s},an=e=>{let t=[],r=e;for(;r&&t.length<3&&r.tagName&&r.tagName!=="BODY"&&r.tagName!=="HTML";){let s=sn(r);if(t.unshift(s),s.includes("#"))break;r=r.parentElement;}return t.join(" > ").slice(0,160)},$e=e=>(e!=null?e:"").replace(/\s+/g," ").trim().slice(0,40),cn=e=>{var r,s,c,a,f;if(e.closest(`${rn},${on}`))return "";let t=e.tagName.toLowerCase();if(t==="input"){let C=((r=e.getAttribute("type"))!=null?r:"text").toLowerCase();return $e(C==="submit"||C==="button"?(s=e.getAttribute("aria-label"))!=null?s:e.value:e.getAttribute("aria-label"))}return $e(t==="select"||t==="textarea"?e.getAttribute("aria-label"):(f=(a=(c=e.getAttribute("aria-label"))!=null?c:e.getAttribute("title"))!=null?a:e.innerText)!=null?f:e.textContent)},xt=e=>{var a,f;let t=e.target instanceof Element?e.target:null;if(!t)return null;let r=t.closest(nn),s=r!=null?r:t,c=document.documentElement;return {x:Math.round(e.clientX),y:Math.round(e.clientY+window.scrollY),vw:window.innerWidth,vh:window.innerHeight,docH:Math.max(c.scrollHeight,(f=(a=document.body)==null?void 0:a.scrollHeight)!=null?f:0),selector:an(s),label:r?cn(r):"",interactive:!!r}},Ct=()=>{var r,s;let e=document.documentElement,t=Math.max(e.scrollHeight,(s=(r=document.body)==null?void 0:r.scrollHeight)!=null?s:0);return t?Math.min(100,Math.round((window.scrollY+window.innerHeight)/t*100)):0};var Pe="0.11.0",ln=(e,t)=>{let r=t.trim().toLowerCase();for(let[s,c]of Object.entries(e))if(s.toLowerCase()===r)return c},dn=(e,t)=>{let r=e.trim().toLowerCase(),s=t.trim().toLowerCase();return s.startsWith("@")?r.endsWith(s):r===s},un=(e,t)=>{if(e.op==="in cohort")return false;let r=ln(t,e.property),s=r==null?"":String(r);if(e.op==="\u2265"){let a=Number(s),f=Number(e.values[0]);return s!==""&&Number.isFinite(a)&&Number.isFinite(f)&&a>=f}let c=s!==""&&e.values.some(a=>dn(s,a));return e.op==="is"||e.op==="in"?c:!c},fn=(e,t,r={})=>{var C;if(!e.on)return false;let s={id:t,...r},c=e.sets.length?e.sets.find(v=>v.conditions.every(k=>un(k,s))):{rollout:100};if(!c||Rt(`${e.key}:rollout:${t}`)*100>=c.rollout)return false;if(!((C=e.variants)!=null&&C.length))return true;let a=Rt(`${e.key}:variant:${t}`)*100,f=0;for(let v of e.variants)if(f+=v.split,a<f)return v.key;return e.variants[e.variants.length-1].key},Je=(e,t,r,s={})=>{var a;let c=(a=t==null?void 0:t.flags)==null?void 0:a.find(f=>f.key===e);return c?fn(c,r,s):false},pn=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],vt="ck_preview",Et="ck_embed",ce="ck_id",we="ck_sid";var gn=e=>{var r;let t={};for(let s of pn){let c=(r=e(s))==null?void 0:r.trim();c&&(t[s]=c.slice(0,150));}return t},_t=e=>{let t=new URLSearchParams(e);return gn(r=>t.get(r))};var mn=e=>{let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return (t>>>0)/4294967296},Rt=e=>{let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,(t>>>0)/4294967296},hn=(e,t)=>{var a,f,C,v;let r=(f=(a=e.variants[0])==null?void 0:a.id)!=null?f:"control";if(e.winner)return e.winner;if(e.status!=="running")return r;let s=mn(`${e.key}:${t}`),c=0;for(let k of e.variants)if(c+=k.weight,s<c)return k.id;return (v=(C=e.variants[e.variants.length-1])==null?void 0:C.id)!=null?v:r},St=e=>{let t=Array.isArray(e)?e[0]:e;if(!t)return {};let r={};for(let s of t.split(",")){let[c,a]=s.split(":");c&&a&&(r[c.trim()]=a.trim());}return r};var Re=(e,t,r,s)=>{if(s[e])return s[e];let c=t==null?void 0:t.experiments.find(a=>a.key===e);return c?hn(c,r):"control"},It=(e,t,r)=>{var c,a,f,C,v,k;let s={...(c=e==null?void 0:e.texts)!=null?c:{}};for(let E of (a=e==null?void 0:e.experiments)!=null?a:[]){let g=Re(E.key,e,t,r);g!==((C=(f=E.variants[0])==null?void 0:f.id)!=null?C:"control")&&Object.assign(s,(k=(v=E.variants.find(w=>w.id===g))==null?void 0:v.changes)!=null?k:{});}return s},Ce="ck_x",Me=e=>e.replace(/\/+$/,"")||"/",Ot=(e,t,r,s={})=>{var C,v;if(!e)return null;let c;try{c=new URL(t);}catch(k){return null}if(c.searchParams.has(Ce))return null;let a=Me(c.pathname),f=(k,E)=>{let g;try{g=new URL(k,c);}catch(w){return}if(!(!/^https?:$/.test(g.protocol)||g.origin===c.origin&&Me(g.pathname)===a))return c.searchParams.forEach((w,S)=>{g.searchParams.has(S)||g.searchParams.set(S,w);}),E&&g.searchParams.set(Ce,E),g.hash||(g.hash=c.hash),g.href};for(let k of (C=e.redirects)!=null?C:[]){let E=k.from&&Me(k.from)===a?f(k.to):void 0;if(E)return {to:E}}for(let k of e.experiments){if(!k.path||Me(k.path)!==a)continue;let E=k.status==="running"&&!k.winner;if(E&&r===null&&!s[k.key])return null;let g=Re(k.key,e,r!=null?r:"",s),w=(v=k.variants.find(M=>M.id===g))==null?void 0:v.url,S=w?f(w,E?`${k.key}:${g}`:void 0):void 0;return E?{to:S,experiment:k.key,variant:g}:S?{to:S}:null}return null},Ft=(e,t)=>{let[r,s]=(t!=null?t:"").split(":"),c=e==null?void 0:e.experiments.find(a=>a.key===r);return c&&c.variants.some(a=>a.id===s)?{experiment:r,variant:s}:null};var Ge=()=>typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():`ck_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;var ve=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e,wn=e=>{var t;if(e instanceof Error)return {type:e.name||"Error",message:ve(e.message||String(e),1e3),stack:e.stack?ve(e.stack,8192):void 0};if(typeof e=="string")return {type:"Error",message:ve(e,1e3)};try{return {type:"Error",message:ve((t=JSON.stringify(e))!=null?t:String(e),1e3)}}catch(r){return {type:"Error",message:String(e)}}},$t=e=>{let t=[],r=[],s=new Set,c=0,a=`${e.host}/api/sdk/errors`,f=(w=false)=>{for(;t.length;){let S=JSON.stringify({key:e.apiKey,errors:t.splice(0,4)});w&&typeof navigator!="undefined"&&"sendBeacon"in navigator&&navigator.sendBeacon(a,S)||fetch(a,{method:"POST",headers:{"content-type":"application/json"},body:S,keepalive:true}).then(A=>{!A.ok&&A.status!==429&&e.warn(`Error reports were rejected with ${A.status}. Check the public key and NEXT_PUBLIC_MRROCKET_HOST.`);}).catch(()=>{});}},C=(w,S="manual")=>{let M=e.context();if(!M.send||c>=20)return;let A=wn(w);if(/\/api\/sdk\/errors/.test(A.message))return;let N=`${A.type}:${A.message}`;s.has(N)||(s.add(N),c++,t.push({...A,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}:{}}));},v=w=>{var S;!w.error&&(!w.message||w.message==="Script error.")||C((S=w.error)!=null?S:new Error(w.message),"onerror");},k=w=>{var S;return C((S=w.reason)!=null?S:new Error("Unhandled promise rejection"),"onunhandledrejection")},E=()=>f(true);window.addEventListener("error",v),window.addEventListener("unhandledrejection",k),window.addEventListener("pagehide",E);let g=window.setInterval(()=>f(),2e3);return {capture:C,crumb:(w,S)=>{r.push({ts:Date.now(),type:w,message:ve(S,120)}),r.length>20&&r.shift();},stop:()=>{window.removeEventListener("error",v),window.removeEventListener("unhandledrejection",k),window.removeEventListener("pagehide",E),window.clearInterval(g),f(true);}}};var Ee="$cancel_flow",re="$onboarding",Qe="$inapp",kn={version:0,question:"",reasons:[],offers:{},confirm:{title:"Cancel your subscription?",body:"You keep access until the end of the billing period.",button:"Cancel subscription"},offersFor:"business"},yn="Something went wrong. Please try again.",Mt="mrrocket:onboarding",Ae=e=>e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),Pt=new Set(["signed_up","signup","sign_up","registered","account_created","user_signed_up"]),Ze=(e,t)=>{let r=Ae(e),s=Ae(t);return !r||!s?false:r===s||Pt.has(r)&&Pt.has(s)},bn=e=>/^(first (launch|visit|open|session|login|sign ?in|app open)|app (opened|launched)|on load|every visit|always)?$/i.test(e.trim()),xn=()=>`cf_${Math.random().toString(36).slice(2,10)}${Date.now().toString(36)}`;var Cn=e=>{let t=(e!=null?e:"").trim();return /^https?:\/\//i.test(t)||/^\/(?!\/)/.test(t)?t:void 0},le=e=>{var t;return (t=e.nodes)!=null?t:e.steps},Rn=e=>Math.max(0,e.amount)*(e.unit==="hours"?36e5:864e5),vn=(e,t)=>{let r=e.trim(),s=(t.split(/[?#]/)[0]||"/").replace(/\/+$/,"")||"/";if(!r)return false;if(r.endsWith("*")){let c=r.slice(0,-1).replace(/\/+$/,"");return !c||s===c||s.startsWith(`${c}/`)}return s===(r.replace(/\/+$/,"")||"/")},et=e=>e.flatMap(t=>t.kind==="condition"?[...et(t.yes),...et(t.no)]:t.kind==="wait"?[]:[t]),At=e=>{let t=null,r=null,s=null,c=[],a=false,f=null,C,v=null,k=new Map,E=new Set,g=new Set,w=new Set,S=e.auto!==false,M=new Set,A=()=>{var n,i;return (i=(n=e.now)==null?void 0:n.call(e))!=null?i:Date.now()},N=null,z=()=>{var n;return (n=t==null?void 0:t.onboarding)!=null?n:[]},Z=n=>n?z().find(i=>i.id===n):void 0,U=n=>{let i=k.get(n);return i||k.set(n,i={done:new Set,dismissed:false,answers:new Map,at:new Map,reached:new Map}),i},G=false,q=n=>{e.track(re,n),G=true;},oe=(n,i)=>{n.done.add(i),n.at.set(i,A());},Be=n=>{var i,l,m;if((i=n.page)!=null&&i.trim()){let p=(l=e.path)==null?void 0:l.call(e);return p===void 0?false:vn(n.page,p)}if((m=n.event)!=null&&m.trim()){if(!a)return;for(let p of M)if(Ze(n.event,p))return true;return false}return false},de=(n,i,l,m,p=0,_)=>{var I,b;for(let y=0;y<i.length;y++){let x=i[y];if(x.kind==="wait"){if(l.done.has(x.id)){_=(I=l.at.get(x.id))!=null?I:_;continue}let O=l.reached.get(x.id);if(O===void 0){if(!m)return {at:"pending"};O=_!=null?_:A(),l.reached.set(x.id,O),q({flow:n.id,step:x.id,kind:"wait",action:"shown"});}let V=O+Rn(x);if(A()<V)return {at:"wait",until:V};if(!m)return {at:"pending"};oe(l,x.id),q({flow:n.id,step:x.id,kind:"wait",action:"completed"}),_=V;continue}if(x.kind==="condition"){let O=l.answers.get(x.id);if(O===void 0){if(!m)return {at:"pending"};if(O=Be(x),O===void 0)return {at:"pending"};l.answers.set(x.id,O),q({flow:n.id,step:x.id,kind:"condition",action:"answered",answer:O?"yes":"no"});}return de(n,O?x.yes:x.no,l,m,p,_)}if(!l.done.has(x.id))return {at:"step",step:x,line:i,index:y,before:p};_=(b=l.at.get(x.id))!=null?b:_,p++;}return {at:"end"}},se=n=>{let i=k.get(n.id);return !!i&&(i.dismissed||de(n,le(n),i,false).at==="end")},ue=n=>`${Mt}:${n!=null?n:"visitor"}`,j=n=>`${Mt}:events:${n!=null?n:"visitor"}`,K=()=>{var l;G=false;let n=(l=e.storage)==null?void 0:l.call(e);if(!n)return;let i={};for(let[m,p]of k)i[m]={done:[...p.done],...p.dismissed?{dismissed:true}:{},...p.answers.size?{answers:Object.fromEntries([...p.answers].map(([_,I])=>[_,I?"yes":"no"]))}:{},...p.at.size?{at:Object.fromEntries(p.at)}:{},...p.reached.size?{reached:Object.fromEntries(p.reached)}:{}};try{n.set(ue(e.personId()),JSON.stringify(i)),M.size&&n.set(j(e.personId()),JSON.stringify([...M].slice(-200)));}catch(m){}},$=n=>{var i,l,m,p;for(let[_,I]of Object.entries(n!=null?n:{})){let b=U(_);for(let y of (i=I.done)!=null?i:[])b.done.add(y);I.dismissed&&(b.dismissed=true);for(let[y,x]of Object.entries((l=I.answers)!=null?l:{}))b.answers.has(y)||b.answers.set(y,x==="yes");for(let[y,x]of Object.entries((m=I.at)!=null?m:{}))typeof x=="number"&&!b.at.has(y)&&b.at.set(y,x);for(let[y,x]of Object.entries((p=I.reached)!=null?p:{}))typeof x=="number"&&(!b.reached.has(y)||x<b.reached.get(y))&&b.reached.set(y,x);}},Q=n=>{var l;N&&clearTimeout(N),N=null;let i=n-A();i>0&&i<=864e5&&(N=setTimeout(()=>(N=null,P()),i+50),(l=N.unref)==null||l.call(N));},fe=false,ie=()=>{fe=false;let n=Z(s);if(!n)return null;let i=U(n.id);if(i.dismissed)return null;let l=de(n,le(n),i,true);if(G&&K(),l.at==="wait"&&Q(l.until),fe=l.at==="wait"||l.at==="pending",l.at!=="step")return null;let{step:m,line:p,index:_}=l,I=O=>!!O&&O.kind!=="wait"&&O.kind!=="condition";if(m.kind==="checklist"){let O=_;for(;O>0&&I(p[O-1])&&p[O-1].kind==="checklist";)O--;let V=_;for(;V+1<p.length&&I(p[V+1])&&p[V+1].kind==="checklist";)V++;let pe=p.slice(O,V+1).filter(I);for(let Y of pe)!i.done.has(Y.id)&&!g.has(`s:${Y.id}`)&&(g.add(`s:${Y.id}`),e.track(re,{flow:n.id,step:Y.id,kind:"checklist",action:"shown"}));return {type:"checklist",flow:n,items:pe.map(Y=>({step:Y,done:i.done.has(Y.id)}))}}g.has(`s:${m.id}`)||(g.add(`s:${m.id}`),e.track(re,{flow:n.id,step:m.id,kind:m.kind,action:"shown"}));let b=p.slice(_+1),y=b.findIndex(O=>O.kind==="condition"),x=(y<0?b:b.slice(0,y)).filter(I).length;return {type:"step",flow:n,step:m,index:l.before,total:l.before+1+x,last:!x&&y<0}},ae=()=>{if(r){let l=r.reason?r.flow.offers[r.reason]:void 0;return {type:"cancel",screen:r.screen,flow:r.flow,reason:r.reason,offer:r.screen==="offer"?l:void 0,price:r.options.price,busy:r.busy,error:r.error,step:r.plain||r.screen==="survey"?1:r.screen==="offer"?2:3,steps:r.plain?1:3}}let n=ie();if(n)return n;s&&!fe&&(s=null);let i=c.find(l=>!E.has(l.id));return i?{type:"message",message:i}:null},P=()=>{let n=ae();(n==null?void 0:n.type)==="message"&&!g.has(`m:${n.message.id}`)&&(g.add(`m:${n.message.id}`),e.track(Qe,{message:n.message.id,journey:n.message.journey,action:"shown"}));for(let i of [...w])try{i();}catch(l){}},J=n=>s===n.id?true:s&&Z(s)&&!se(Z(s))?false:(s=n.id,e.track(re,{flow:n.id,action:"started"}),P(),true),ke=()=>{var i;if(!S||s||!a||!e.personId()&&!((i=e.storage)!=null&&i.call(e)))return;let n=z().find(l=>bn(l.trigger)&&le(l).length&&!se(l));n&&J(n);},Ie=()=>{let n=e.personId();v!==null&&v!==n&&(k.clear(),M.clear(),E.clear(),s=null,C=void 0),v=n;let i=(async()=>{var p,_,I;let l=(p=e.storage)==null?void 0:p.call(e);if(l)try{let b=await l.get(ue(n));b&&$(JSON.parse(b));let y=await l.get(j(n));if(y)for(let x of JSON.parse(y))typeof x=="string"&&M.add(x);}catch(b){}let m=z().length>0||!!(t!=null&&t.messages);if(n&&m&&C!==n){C=n;let b=await e.fetchInApp(n).catch(()=>null);if(b&&e.personId()===n){$(b.onboarding);for(let y of (_=b.events)!=null?_:[])typeof y=="string"&&M.add(Ae(y));c=((I=b.messages)!=null?I:[]).filter(y=>y&&y.id&&y.title);}}n||(c=[]),a=true,ke(),P();})();return f=i.finally(()=>{f===i&&(f=null);}),f},D=(n,i,l)=>{var p;let m=n.reason?n.flow.offers[n.reason]:void 0;return {outcome:i,run:n.run,...n.reason?{reason:n.reason,reasonLabel:(p=n.flow.reasons.find(_=>_.id===n.reason))==null?void 0:p.label}:{},...i==="saved"&&m?{offer:m}:{},...l!=null&&l.trim()?{comment:l.trim().slice(0,500)}:{}}},H=(n,i)=>{var l;e.track(Ee,{action:"finished",run:n.run,version:n.flow.version,outcome:i.outcome,customer:(l=n.options.customer)!=null?l:"consumer",...i.reason?{reason:i.reason}:{},...i.offer?{offer:i.offer.kind}:{},...i.comment?{comment:i.comment}:{}}),r===n&&(r=null),n.resolve(i),P();},W=(n,i,l)=>{if(n.busy)return;let m=D(n,i,l),p=i==="saved"?n.options.onSave:n.options.onCancel;n.busy=true,n.error=void 0,P(),Promise.resolve().then(()=>p==null?void 0:p(m)).then(()=>H(n,m),()=>{n.busy=false,n.error=yn,P();});};return {setConfig:n=>{t=n,s&&!Z(s)&&(s=null),P();},refresh:Ie,onEvent:n=>{var I;if(!n||n.startsWith("$"))return;let i=Ae(n),l=!!i&&!M.has(i);l&&M.add(i);let m=Z(s),p=false;if(m){let b=U(m.id);for(let y of et(le(m)))y.kind==="checklist"&&y.event&&!b.done.has(y.id)&&Ze(y.event,n)&&(oe(b,y.id),p=true,e.track(re,{flow:m.id,step:y.id,kind:y.kind,action:"completed"}));}if(p||l&&m?(K(),P()):l&&K(),!S||!e.personId()&&!((I=e.storage)!=null&&I.call(e)))return;let _=z().find(b=>le(b).length&&Ze(b.trigger,n)&&!se(b));_&&J(_);},openCancelFlow:(n={})=>{var I,b;if(r)return r.promise;let i=(I=t==null?void 0:t.cancelFlow)!=null?I:kn,l=n.customer!=="business"||i.reasons.length<2,m=()=>{},p=new Promise(y=>m=y),_={flow:i,options:n,plain:l,screen:l?"confirm":"survey",run:xn(),busy:false,resolve:m,promise:p};return r=_,e.track(Ee,{action:"shown",run:_.run,version:i.version,customer:(b=n.customer)!=null?b:"consumer",plain:l}),P(),p},startOnboarding:n=>{let i=n?Z(n):z().find(m=>le(m).length&&!se(m));if(!i||!le(i).length)return false;let l=U(i.id);return l.dismissed=false,J(i)},view:ae,subscribe:n=>(w.add(n),()=>w.delete(n)),cancel:{pick:n=>{!r||r.busy||!r.flow.reasons.some(i=>i.id===n)||(r.reason=n,r.error=void 0,P());},next:()=>{let n=r;!n||n.screen!=="survey"||!n.reason||(e.track(Ee,{action:"answered",run:n.run,version:n.flow.version,reason:n.reason}),n.screen=n.flow.offers[n.reason]?"offer":"confirm",P());},accept:n=>{let i=r;if(!i||i.screen!=="offer"||!i.reason)return;let l=i.flow.offers[i.reason];i.busy||e.track(Ee,{action:"offer",run:i.run,version:i.flow.version,reason:i.reason,offer:l==null?void 0:l.kind,outcome:"accepted"}),W(i,"saved",n);},decline:()=>{var i;let n=r;!n||n.screen!=="offer"||n.busy||(e.track(Ee,{action:"offer",run:n.run,version:n.flow.version,reason:n.reason,offer:n.reason?(i=n.flow.offers[n.reason])==null?void 0:i.kind:void 0,outcome:"declined"}),n.screen="confirm",n.error=void 0,P());},confirm:n=>{let i=r;!i||i.screen!=="confirm"||W(i,"cancelled",n);},close:()=>{var l,m;let n=r;if(!n||n.busy)return;let i=D(n,"kept");(m=(l=n.options).onClose)==null||m.call(l,i),H(n,i);}},onboarding:{next:()=>{let n=ie();(n==null?void 0:n.type)==="step"&&(oe(U(n.flow.id),n.step.id),e.track(re,{flow:n.flow.id,step:n.step.id,kind:n.step.kind,action:"completed"}),K(),P());},check:n=>{let i=ie();if((i==null?void 0:i.type)!=="checklist")return;let l=i.items.find(m=>m.step.id===n);!l||l.done||(oe(U(i.flow.id),n),e.track(re,{flow:i.flow.id,step:n,kind:"checklist",action:"completed"}),K(),P());},dismiss:()=>{let n=ie();!n||n.type!=="step"&&n.type!=="checklist"||(U(n.flow.id).dismissed=true,e.track(re,{flow:n.flow.id,...n.type==="step"?{step:n.step.id}:{},action:"dismissed"}),s=null,K(),P());}},message:{click:()=>{var l;let n=ae();if((n==null?void 0:n.type)!=="message")return;E.add(n.message.id),e.track(Qe,{message:n.message.id,journey:n.message.journey,action:"clicked"});let i=Cn(n.message.url);P(),i&&((l=e.openUrl)==null||l.call(e,i));},dismiss:()=>{let n=ae();(n==null?void 0:n.type)==="message"&&(E.add(n.message.id),e.track(Qe,{message:n.message.id,journey:n.message.journey,action:"dismissed"}),P());}}}};var En="ck_pick",_n="ck_origin",Le=e=>typeof CSS!="undefined"&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,t=>`\\${t}`),Sn=e=>[...e.classList].filter(t=>t.length<30&&!/\d{2,}|[_-][a-z0-9]{5,}$|^(is|has)-|hover|active|focus|open|selected|:|\[/.test(t)).slice(0,2),Lt=e=>{let t=e.ownerDocument,r=f=>{try{return t.querySelectorAll(f).length===1}catch(C){return false}},s=e.getAttribute("data-ck-target");if(s)return `[data-ck-target="${s.replace(/"/g,'\\"')}"]`;if(e.id&&!/\d{3,}/.test(e.id)&&r(`#${Le(e.id)}`))return `#${Le(e.id)}`;let c=[],a=e;for(;a&&a!==t.documentElement&&c.length<6;){if(a!==e&&a.id&&!/\d{3,}/.test(a.id)){c.unshift(`#${Le(a.id)}`);break}let f=a.tagName.toLowerCase(),C=Sn(a).map(w=>`.${Le(w)}`).join(""),v=a.parentElement,k=v?[...v.children].filter(w=>w.tagName===a.tagName):[],E=k.length>1?`:nth-of-type(${k.indexOf(a)+1})`:"";c.unshift(`${f}${C}${E}`);let g=c.join(" > ");if(r(g))return g;a=v;}return c.join(" > ")},Nt=()=>{var E;if(typeof window=="undefined"||window.top===window)return null;let e=new URLSearchParams(window.location.search);if(e.get(En)!=="1")return null;let t;try{t=new URL((E=e.get(_n))!=null?E:"").origin;}catch(g){return null}if(!/^https?:\/\//.test(t))return null;let r=g=>window.parent.postMessage(g,t),s=document.createElement("div");s.setAttribute("aria-hidden","true"),Object.assign(s.style,{position:"fixed",zIndex:"2147483647",pointerEvents:"none",border:"2px solid #0ea5e9",background:"rgba(14,165,233,.12)",borderRadius:"6px",transition:"all 60ms linear",display:"none"});let c=document.createElement("div");Object.assign(c.style,{position:"absolute",left:"-2px",bottom:"calc(100% + 4px)",font:"600 11px/1.4 system-ui, sans-serif",color:"#fff",background:"#0c4a6e",padding:"2px 6px",borderRadius:"4px",whiteSpace:"nowrap",maxWidth:"360px",overflow:"hidden",textOverflow:"ellipsis"}),s.appendChild(c),document.body.appendChild(s);let a=null,f=g=>{if(a=g&&g!==s&&!s.contains(g)?g:null,!a){s.style.display="none";return}let w=a.getBoundingClientRect();Object.assign(s.style,{display:"block",left:`${w.left-2}px`,top:`${w.top-2}px`,width:`${w.width+4}px`,height:`${w.height+4}px`}),c.textContent=Lt(a);},C=g=>f(document.elementFromPoint(g.clientX,g.clientY)),v=g=>{var S,M;g.preventDefault(),g.stopPropagation();let w=(S=document.elementFromPoint(g.clientX,g.clientY))!=null?S:a;!w||w===s||r({type:"mrrocket:picked",selector:Lt(w),text:((M=w.textContent)!=null?M:"").trim().replace(/\s+/g," ").slice(0,80)});},k=g=>{g.key==="Escape"&&r({type:"mrrocket:pick-cancel"});};return window.addEventListener("mousemove",C,true),window.addEventListener("click",v,true),window.addEventListener("keydown",k,true),r({type:"mrrocket:pick-ready"}),()=>{window.removeEventListener("mousemove",C,true),window.removeEventListener("click",v,true),window.removeEventListener("keydown",k,true),s.remove();}};var In={get:e=>{try{return window.localStorage.getItem(e)}catch(t){return null}},set:(e,t)=>{try{window.localStorage.setItem(e,t);}catch(r){}}},Tt=()=>{try{for(let e=window.localStorage.length-1;e>=0;e--){let t=window.localStorage.key(e);t!=null&&t.startsWith("mrrocket:onboarding")&&window.localStorage.removeItem(t);}}catch(e){}},Dt=e=>({track:e.track,personId:e.personId,auto:e.auto,storage:()=>e.canStore()?In:null,openUrl:t=>window.location.assign(t),path:()=>window.location.pathname,fetchInApp:async t=>{if(!e.apiKey)return null;let r=await fetch(`${e.host}/api/sdk/inapp?key=${encodeURIComponent(e.apiKey)}&distinctId=${encodeURIComponent(t)}`);return r.ok?await r.json():null}});var De="mrr_ref",Ue="mrr_ref",On="mrr_ref",Fn="mrr_click";var _e=/^[A-Za-z0-9_-]{1,64}$/;var $n=(e,t="ref")=>{let r=new URLSearchParams(e);return Mn(s=>r.get(s),t)},Mn=(e,t="ref")=>{let r=e(On);if(r&&_e.test(r)){let c=e(Fn);return {code:r,clickId:c&&_e.test(c)?c:null,direct:false}}let s=e(t);return s&&_e.test(s)?{code:s,clickId:null,direct:true}:null},Ut=e=>{var t;return `${e.code}.${(t=e.clickId)!=null?t:""}.${e.at}`},Ne=(e,t=60,r=Date.now())=>{if(!e)return null;let[s,c,a]=e.split("."),f=Number(a);return !s||!_e.test(s)||!Number.isFinite(f)||c&&!_e.test(c)||r-f>t*864e5||f>r+864e5?null:{code:s,clickId:c||null,at:f}};var T=null,je=()=>typeof document!="undefined",jt=e=>{var r;if(!je())return;let t=(r=document.cookie.split("; ").find(s=>s.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);try{return t?decodeURIComponent(t):void 0}catch(s){return t}},He=()=>{try{return typeof localStorage=="undefined"?null:localStorage}catch(e){return null}},tt=()=>{var e,t;return T||(je()?(t=Ne(jt(De),3650))!=null?t:Ne((e=He())==null?void 0:e.getItem(Ue),3650):null)};var Te=(e,t)=>{var c;if(!je())return;let r=Math.max(1,Math.round(t))*86400,s=typeof location!="undefined"&&location.protocol==="https:"?"; secure":"";document.cookie=`${De}=${encodeURIComponent(Ut(e))}; path=/; max-age=${r}; samesite=lax${s}`;try{(c=He())==null||c.setItem(Ue,Ut(e));}catch(a){}},Ke=()=>{var e;if(je()){document.cookie=`${De}=; path=/; max-age=0; samesite=lax`;try{(e=He())==null||e.removeItem(Ue);}catch(t){}}},Ht=()=>{T=null;},Kt=async e=>{var s,c,a;let t=$n(e.search,e.param),r=(s=e.now)!=null?s:Date.now();if(!t)return !T&&e.store&&(T=(a=Ne(jt(De),e.days,r))!=null?a:Ne((c=He())==null?void 0:c.getItem(Ue),e.days,r),T||Ke()),T;if(T={code:t.code,clickId:t.clickId,at:r},e.store&&Te(T,e.days),e.beacon)try{let f=await e.beacon({code:t.code,clickId:t.clickId});f&&T&&T.code===t.code&&!T.clickId&&(T={...T,clickId:f},e.store&&Te(T,e.days));}catch(f){}return T},Wt=e=>e==="$identify"||!e.startsWith("$");var nt=3600*24*365,qt=e=>{var r;if(typeof document=="undefined")return;let t=(r=document.cookie.split("; ").find(s=>s.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);if(t)try{return decodeURIComponent(t)}catch(s){return t}},We=(e,t,r)=>{let s=window.location.protocol==="https:"?"; secure":"";document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${r}; samesite=lax${s}`;},Se=e=>{document.cookie=`${e}=; path=/; max-age=0; samesite=lax`;},L={utm:{}},Bt=()=>{var e;return (e=L.id)!=null?e:L.id=Ge()},rt=(e,t)=>{if(e!=="cookies")return Bt();let r=qt(ce);if(r)return L.id=r;let s=Bt();return We(ce,s,nt),s},ot=e=>{var c;let t=Date.now(),r=L.session,s=(c=e?qt(we):void 0)!=null?c:r&&t-r.last<18e5?r.id:Ge();return L.session={id:s,last:t},e&&We(we,s,18e5/1e3),s},st=()=>{var r;let e=window.location.href;if(L.url===e)return;L.referrer=(r=L.url)!=null?r:document.referrer||void 0,L.url=e;let t=_t(window.location.search);Object.keys(t).length&&(L.utm=t);},Yt=()=>{let e=navigator,t=window;return e.doNotTrack==="1"||t.doNotTrack==="1"||e.globalPrivacyControl===true};var Ve=window,An=()=>{var e,t;return (t=(e=document.currentScript)!=null?e:document.querySelector('script[data-key][src*="sdk"]'))!=null?t:document.querySelector("script[data-key][src*='mrrocket']")},Xt=new Set,X=e=>{Xt.has(e)||(Xt.add(e),console.warn(`[MRRocket] ${e}`));},Ln=()=>{var pt,gt,mt,ht;let e=An(),t=o=>{var d;return (d=e==null?void 0:e.getAttribute(`data-${o}`))!=null?d:void 0},r=(o,d)=>{let u=t(o);return u===void 0?d:!["false","0","off","no"].includes(u.trim().toLowerCase())},s=(pt=e==null?void 0:e.src)!=null?pt:"",c="";try{c=s?new URL(s,window.location.href).origin:"";}catch(o){c="";}let a=((gt=t("key"))!=null?gt:"").trim(),f=((mt=t("api-host"))!=null?mt:c).trim().replace(/\/+$/,""),C=t("consent"),v=r("respect-dnt",false),k=r("heatmaps",true),E=r("errors",true),g=t("release"),w=t("attribution"),S=w==="always"||w==="off"?w:"consent",M=t("referral-param")||"ref",A={},N=(o,d)=>{var u;return (u=A[o])!=null?u:A[o]=new Promise((h,R)=>{var wt;let F=()=>Ve[d];if(F())return h(F());let B=(wt=t(`${o}-src`))!=null?wt:s?s.replace(/(\.min)?\.js(\?[^#]*)?(#.*)?$/,`-${o}$1.js?v=${Pe}`):"";if(!B)return R(new Error(o));let ne=document.createElement("script");ne.async=true,ne.src=B,ne.onload=()=>F()?h(F()):R(new Error(o)),ne.onerror=()=>R(new Error(o)),document.head.appendChild(ne);}).catch(h=>{throw A[o]=void 0,h})},z=t("theme"),Z={theme:z==="light"||z==="dark"?z:"auto",accent:t("accent")},U=new URLSearchParams(window.location.search),G=St(U.get(vt)),q=U.get(Et)==="1";q&&Nt();let oe=U.get(Ce);if(oe!==null){U.delete(Ce);let o=U.toString();history.replaceState(history.state,"",`${window.location.pathname}${o?`?${o}`:""}${window.location.hash}`);}let Be=Yt(),de=C==="cookies"||C==="off"?C:"cookieless",se=r("replay",false),ue="",j,K,$=null,Q=false,fe=false,ie=null,ae=null,P=window.location.pathname,J=[],ke=new Set,Ie=[],D=()=>v&&Be?"off":de,H=()=>!q&&D()!=="off",W=()=>j!=null?j:ue,ye=()=>D()==="cookies"?W():j;a||X('No public key. Add data-key="mrr_pub_\u2026" to the script tag; nothing is tracked until then.');let Oe=(o=false)=>{if(!J.length)return;if(!a){J.length=0;return}let d=`${f}/api/sdk/events`;for(let u of yt(a,J.splice(0),{v:Pe,errors:E,platform:"web"}))o&&"sendBeacon"in navigator&&navigator.sendBeacon(d,u)||fetch(d,{method:"POST",headers:{"content-type":"application/json"},body:u,keepalive:true}).then(R=>{R.ok||X(`Events were rejected with ${R.status}. Check data-key (MRRocket \u203A Settings \u203A Products).`);}).catch(()=>X(`Could not reach ${f||"this origin"} to send events. Check data-api-host.`));},n=null,i=null,l=(o,d,u=Date.now(),h)=>{if(!H())return;let R=Wt(o)?tt():null;J.push({event:o,props:R?{...d,$referral:{code:R.code,clickId:R.clickId}}:d,distinctId:ye(),sessionId:ot(D()==="cookies"),ts:u,url:h!=null?h:window.location.href,referrer:L.referrer,...L.utm,screen:{w:window.screen.width,h:window.screen.height}});},m=(o,d)=>{typeof o!="string"||!o||(l(o,d),H()&&(n==null||n.event(o)),p.onEvent(o));},p=At(Dt({host:f,apiKey:a,track:l,personId:()=>H()?j:void 0,canStore:()=>D()==="cookies",auto:r("onboarding",true)})),_=false;p.subscribe(()=>{_||!p.view()||q||(_=true,N("flows","__mrrocketFlows").then(o=>o.mountFlows(p,Z)).catch(()=>{_=false,X("The cancel flow and onboarding dialogs did not load. Check that sdk-flows.js is served next to sdk.js.");}));});let I=(o,d)=>{if(!H())return;let u=`${window.location.pathname}|${o}`;ke.has(u)||(ke.add(u),m("$exposure",{experiment:o,variant:d}));},b=()=>{let o=Ot($,window.location.href,W(),G);return o!=null&&o.to?(Oe(true),window.location.replace(o.to),true):(o!=null&&o.experiment&&I(o.experiment,o.variant),false)},y=()=>{if(!$)return;let o=document.querySelectorAll("[data-ck-text]");if(!o.length)return;let d=It($,W(),G),u=new Set;o.forEach(h=>{var B,ne;let R=h.dataset.ckText;if(!R)return;u.add(R),h.dataset.ckDefault===void 0&&(h.dataset.ckDefault=(B=h.textContent)!=null?B:"");let F=(ne=d[R])!=null?ne:h.dataset.ckDefault;h.textContent!==F&&(h.textContent=F);});for(let h of $.experiments)h.variants.some(R=>{var F;return Object.keys((F=R.changes)!=null?F:{}).some(B=>u.has(B))})&&I(h.key,Re(h.key,$,W(),G));},x=()=>{var o,d;return (d=(o=$==null?void 0:$.referral)==null?void 0:o.cookieDays)!=null?d:60},O=()=>S==="always"?D()!=="off":S==="consent"&&D()==="cookies",V=null,pe=false,Y=()=>{if(!Q||q)return;if(S==="off"||D()==="off"){Ht(),(S==="off"||pe)&&Ke();return}let o=window.location.href;V!==o&&(V=o,Kt({search:window.location.search,param:M,store:O(),days:x(),beacon:a?({code:d,clickId:u})=>fetch(`${f}/api/sdk/affiliate/click`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:a,code:d,clickId:u,url:o,referrer:document.referrer||void 0}),keepalive:true}).then(h=>h.ok?h.json():null).then(h=>{var R;return (R=h==null?void 0:h.clickId)!=null?R:null}):void 0}));},Jt=()=>{let o=O(),d=tt();o&&d?Te(d,x()):!o&&pe&&Ke(),pe=o;},it=0,at=false,ct=()=>{var h,R;let o=H()&&se&&!!($!=null&&$.replay)&&!!a;if(o===at)return;at=o;let d=++it;if(!o){n==null||n.stop(true),n=null;return}let u=(R=(h=$==null?void 0:$.replay)==null?void 0:h.sampleRate)!=null?R:.1;N("replay","__mrrocketReplay").then(F=>F.startReplay({host:f,apiKey:a,sessionId:ot(D()==="cookies"),distinctId:ye(),identified:!!j,sampleRate:u,warn:X})).then(F=>{d!==it?F==null||F.stop(true):n=F;}).catch(()=>X("Session recording could not start (the recorder did not load)."));},lt=r("messenger",false),ee=null,ge=o=>{q||a&&(ee!=null||(ee=N("messenger","__mrrocketMessenger").then(d=>{var F;let u=B=>t(`messenger-${B}`)===void 0?void 0:r(`messenger-${B}`,true),h=t("messenger-position"),R=(F=t("messenger-theme"))!=null?F:z;return d.mountMessenger({host:f,apiKey:a,distinctId:W,user:()=>K,launcher:lt,position:h==="bottom-left"||h==="bottom-right"?h:void 0,title:t("messenger-title"),greeting:t("messenger-greeting"),label:t("messenger-label"),askEmail:u("ask-email"),help:u("help"),sound:u("sound"),preview:u("preview"),theme:R==="light"||R==="dark"||R==="auto"?R:void 0,accent:t("accent")})})),ee.then(o).catch(()=>{ee=null,X("sdk-messenger.js did not load.");}));},qe=()=>{!fe||!H()||ae===window.location.pathname||(ae=window.location.pathname,m("$pageview",{path:window.location.pathname}));},te=null,dt=()=>{let o=te;k&&o&&o.max>0&&l("$scroll",{depth:o.max,docH:o.docH,vw:window.innerWidth,vh:window.innerHeight},Date.now(),o.url),te=null;},be=()=>{var R,F;if(!k||!H()||q)return;let o=document.documentElement,d=Math.max(o.scrollHeight,(F=(R=document.body)==null?void 0:R.scrollHeight)!=null?F:0),u=Ct(),h=window.location.href;(te==null?void 0:te.url)!==h?te={url:h,max:u,docH:d}:u>te.max&&(te={url:h,max:u,docH:d});},ut=()=>{let o=window.location.pathname;o!==P&&(P=o,!(Q&&b())&&(dt(),st(),n==null||n.page(o),i==null||i.crumb("navigation",o),qe(),Y(),window.setTimeout(()=>{be(),y();},0)));},ft=()=>{let o=D(),d=ie;ie=o,d==="cookies"&&o!=="cookies"&&(Se(ce),Se(we)),o==="off"&&(J.length=0,L.session=void 0),d==="cookies"&&o!=="cookies"&&Tt(),ue=rt(o),Jt(),Y(),ct(),qe(),be();},Fe={track:m,identify:(o,d)=>{if(typeof o!="string"||!o)return;let u=ye();j=o,l("$identify",{...d,id:o,...u&&u!==o?{previousId:u}:{}}),n==null||n.identify(o),D()==="cookies"&&We(ce,o,nt),K={...d,id:o},y(),Q&&p.refresh();},reset:()=>{j=void 0,K=void 0,ke.clear(),D()==="cookies"&&(Se(ce),Se(we)),L.id=void 0,L.session=void 0,ue=rt(D()),y(),Q&&p.refresh();},captureError:o=>i==null?void 0:i.capture(o,"manual"),setConsent:o=>{let{analytics:d,replay:u}=typeof o=="string"?{analytics:o,replay:void 0}:o!=null?o:{};if(d!==void 0&&d!=="cookieless"&&d!=="cookies"&&d!=="off"){X(`setConsent: "${String(d)}" is not a consent mode. Use "cookieless", "cookies" or "off".`);return}d==="off"&&(J.length=0),d&&(de=d),typeof u=="boolean"&&(se=u),ft(),Q&&p.refresh();},getFlag:o=>Je(o,$,W(),{...K})!==false,getFlagVariant:o=>{let d=Je(o,$,W(),{...K});return typeof d=="string"?d:null},getVariant:o=>{let d=Re(o,$,W(),G);return ($||G[o])&&I(o,d),d},ready:o=>{typeof o=="function"&&(Q?window.setTimeout(()=>o(Fe),0):Ie.push(o));},getDistinctId:W,cancelFlow:{open:o=>p.openCancelFlow(o)},onboarding:{start:o=>p.startOnboarding(o)},openCancelFlow:o=>p.openCancelFlow(o),startOnboarding:o=>p.startOnboarding(o),push:{subscribe:o=>{let d=H()?j:void 0;if(!d)return Promise.resolve({status:"not-signed-in"});let u=window.Notification,h=Promise.resolve(u&&u.permission==="default"&&(o==null?void 0:o.ask)!==false?u.requestPermission():u==null?void 0:u.permission);return N("push","__mrrocketPush").then(R=>R.subscribeWebPush({host:f,apiKey:a,distinctId:d,permission:h},o))},unsubscribe:()=>N("push","__mrrocketPush").then(o=>o.unsubscribeWebPush({host:f,apiKey:a,distinctId:j}))},messenger:{open:o=>ge(d=>d.open(o)),close:()=>{ee==null?void 0:ee.then(o=>o.close()).catch(()=>{});},toggle:()=>ge(o=>o.toggle())},openMessenger:()=>ge(o=>o.open()),version:Pe};st(),ft();let me=Ve.mrrocket,Gt=(ht=me==null?void 0:me.q)!=null?ht:[],Ye=me&&typeof me=="object"?me:{};Object.assign(Ye,Fe,{__loaded:true}),delete Ye.q,Ve.mrrocket=Ye;for(let[o,d]of Gt){let u=Fe[o];if(typeof u=="function")try{u(...Array.from(d!=null?d:[]));}catch(h){console.error(h);}}fe=true,qe(),E&&a&&!q&&(i=$t({host:f,apiKey:a,release:g,context:()=>{var o;return {send:H(),distinctId:ye(),sessionId:(o=L.session)==null?void 0:o.id}},warn:X}),i.crumb("navigation",window.location.pathname));for(let o of ["pushState","replaceState"]){let d=history[o];history[o]=function(...u){let h=d.apply(this,u);return ut(),h};}window.addEventListener("popstate",ut);let Qt=new xe;document.addEventListener("click",o=>{var F;o.target instanceof Element&&o.target.closest("[data-ck-messenger]")&&(o.preventDefault(),ge(B=>B.open()));let d=o.target instanceof Element?o.target.closest("[data-ck-goal]"):null;if(d!=null&&d.dataset.ckGoal&&m(d.dataset.ckGoal,{text:(F=d.textContent)==null?void 0:F.trim().slice(0,80)}),!H())return;let u=xt(o);if(!u)return;let h=Qt.push(u.x,u.y,Date.now());if((u.label||u.selector)&&(i==null||i.crumb("click",u.label||u.selector)),n==null||n.click(u,h),!k)return;let R={x:u.x,y:u.y,vw:u.vw,vh:u.vh,docH:u.docH,selector:u.selector,label:u.label,dead:!u.interactive};l("$click",R),h&&l("$rageclick",R);});let Xe=0;window.addEventListener("scroll",()=>{Xe||(Xe=window.requestAnimationFrame(()=>{Xe=0,be();}));},{passive:true}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>be()):be(),window.setInterval(()=>Oe(),2e3),window.addEventListener("pagehide",()=>{dt(),Oe(true);});let ze=()=>{if(Q=true,b())return;let o=Ft($,oe);o&&I(o.experiment,o.variant),document.documentElement.classList.remove("ck-hide"),Y(),ct(),p.setConfig($),p.refresh(),lt&&(document.body?ge():document.addEventListener("DOMContentLoaded",()=>ge())),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",y):y();for(let d of Ie.splice(0))try{d(Fe);}catch(u){console.error(u);}};a?fetch(`${f}/api/sdk/config?key=${encodeURIComponent(a)}`).then(o=>(o.ok||X(`Config request to ${f||"this origin"} answered ${o.status}. Check data-key and data-api-host.`),o.ok?o.json():null)).then(o=>{o&&Array.isArray(o.experiments)&&($=o),ze();}).catch(()=>{X(`Could not reach ${f||"this origin"}. Check data-api-host. The page keeps its own texts and flags stay off.`),ze();}):ze();},zt;typeof window!="undefined"&&typeof document!="undefined"&&!((zt=Ve.mrrocket)!=null&&zt.__loaded)&&Ln();
|
|
1
|
+
(function(){'use strict';var on=Object.defineProperty;var sn=(e,t,r)=>t in e?on(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r;var we=(e,t,r)=>sn(e,typeof t!="symbol"?t+"":t,r);var Ct=e=>{let t=0;for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);s<128?t+=1:s<2048?t+=2:s>=55296&&s<=56319&&r+1<e.length&&(e.charCodeAt(r+1)&64512)===56320?(t+=4,r++):t+=3;}return t},an=(e,t,r)=>{let s=`{"key":${JSON.stringify(e)},"sdk":${JSON.stringify(r)},"events":[`,c=Ct(s)+2,a=[],f=[],C=[],v=c,k=()=>{f.length&&a.push({body:`${s}${f.join(",")}]}`,events:C}),f=[],C=[],v=c;};for(let E of t){let g=JSON.stringify(E),w=Ct(g)+1;c+w>6e4||((f.length===100||v+w>6e4)&&k(),f.push(g),C.push(E),v+=w);}return k(),a},Rt=(e,t,r)=>an(e,t,r).map(s=>s.body);var xe=class{constructor(t=1e3,r=30,s=3){we(this,"windowMs",t);we(this,"radius",r);we(this,"count",s);we(this,"clicks",[]);we(this,"fired",false);}push(t,r,s){let c=this.clicks.filter(a=>s-a.t<=this.windowMs&&Math.hypot(a.x-t,a.y-r)<=this.radius);return c.length!==this.clicks.length&&(this.fired=false),this.clicks=[...c,{x:t,y:r,t:s}],this.clicks.length>=this.count&&!this.fired?(this.fired=true,true):false}};var cn='a[href],button,input,select,textarea,label,summary,[role="button"],[role="link"],[role="tab"],[role="menuitem"],[role="checkbox"],[role="switch"],[onclick],[data-ck-goal]',ln="[data-ck-mask]",dn="[data-ck-block]",vt=/\d{4,}|^[a-z]{1,3}-[a-z0-9]{5,}$|^_|__|css-|^sc-|^jsx-/i,un=e=>{let t=e.tagName.toLowerCase();if(e.id&&!vt.test(e.id)&&e.id.length<=40)return `${t}#${e.id}`;let r=typeof e.className=="string"?e.className.split(/\s+/).filter(a=>a&&!vt.test(a)&&a.length<=30&&!a.includes(":")):[],s=r.length?`${t}.${r.slice(0,2).join(".")}`:t,c=e.parentElement?[...e.parentElement.children].filter(a=>a.tagName===e.tagName):[];return c.length>1?`${s}:nth-of-type(${c.indexOf(e)+1})`:s},fn=e=>{let t=[],r=e;for(;r&&t.length<3&&r.tagName&&r.tagName!=="BODY"&&r.tagName!=="HTML";){let s=un(r);if(t.unshift(s),s.includes("#"))break;r=r.parentElement;}return t.join(" > ").slice(0,160)},$e=e=>(e!=null?e:"").replace(/\s+/g," ").trim().slice(0,40),pn=e=>{var r,s,c,a,f;if(e.closest(`${ln},${dn}`))return "";let t=e.tagName.toLowerCase();if(t==="input"){let C=((r=e.getAttribute("type"))!=null?r:"text").toLowerCase();return $e(C==="submit"||C==="button"?(s=e.getAttribute("aria-label"))!=null?s:e.value:e.getAttribute("aria-label"))}return $e(t==="select"||t==="textarea"?e.getAttribute("aria-label"):(f=(a=(c=e.getAttribute("aria-label"))!=null?c:e.getAttribute("title"))!=null?a:e.innerText)!=null?f:e.textContent)},Et=e=>{var a,f;let t=e.target instanceof Element?e.target:null;if(!t)return null;let r=t.closest(cn),s=r!=null?r:t,c=document.documentElement;return {x:Math.round(e.clientX),y:Math.round(e.clientY+window.scrollY),vw:window.innerWidth,vh:window.innerHeight,docH:Math.max(c.scrollHeight,(f=(a=document.body)==null?void 0:a.scrollHeight)!=null?f:0),selector:fn(s),label:r?pn(r):"",interactive:!!r}},_t=()=>{var r,s;let e=document.documentElement,t=Math.max(e.scrollHeight,(s=(r=document.body)==null?void 0:r.scrollHeight)!=null?s:0);return t?Math.min(100,Math.round((window.scrollY+window.innerHeight)/t*100)):0};var Pe="0.12.0",gn=(e,t)=>{let r=t.trim().toLowerCase();for(let[s,c]of Object.entries(e))if(s.toLowerCase()===r)return c},mn=(e,t)=>{let r=e.trim().toLowerCase(),s=t.trim().toLowerCase();return s.startsWith("@")?r.endsWith(s):r===s},hn=(e,t)=>{if(e.op==="in cohort")return false;let r=gn(t,e.property),s=r==null?"":String(r);if(e.op==="\u2265"){let a=Number(s),f=Number(e.values[0]);return s!==""&&Number.isFinite(a)&&Number.isFinite(f)&&a>=f}let c=s!==""&&e.values.some(a=>mn(s,a));return e.op==="is"||e.op==="in"?c:!c},wn=(e,t,r={})=>{var C;if(!e.on)return false;let s={id:t,...r},c=e.sets.length?e.sets.find(v=>v.conditions.every(k=>hn(k,s))):{rollout:100};if(!c||St(`${e.key}:rollout:${t}`)*100>=c.rollout)return false;if(!((C=e.variants)!=null&&C.length))return true;let a=St(`${e.key}:variant:${t}`)*100,f=0;for(let v of e.variants)if(f+=v.split,a<f)return v.key;return e.variants[e.variants.length-1].key},Qe=(e,t,r,s={})=>{var a;let c=(a=t==null?void 0:t.flags)==null?void 0:a.find(f=>f.key===e);return c?wn(c,r,s):false},kn=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],It="ck_preview",Ot="ck_embed",ce="ck_id",ke="ck_sid";var yn=e=>{var r;let t={};for(let s of kn){let c=(r=e(s))==null?void 0:r.trim();c&&(t[s]=c.slice(0,150));}return t},Ft=e=>{let t=new URLSearchParams(e);return yn(r=>t.get(r))};var bn=e=>{let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return (t>>>0)/4294967296},St=e=>{let t=2166136261;for(let r=0;r<e.length;r++)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,(t>>>0)/4294967296},xn=(e,t)=>{var a,f,C,v;let r=(f=(a=e.variants[0])==null?void 0:a.id)!=null?f:"control";if(e.winner)return e.winner;if(e.status!=="running")return r;let s=bn(`${e.key}:${t}`),c=0;for(let k of e.variants)if(c+=k.weight,s<c)return k.id;return (v=(C=e.variants[e.variants.length-1])==null?void 0:C.id)!=null?v:r},$t=e=>{let t=Array.isArray(e)?e[0]:e;if(!t)return {};let r={};for(let s of t.split(",")){let[c,a]=s.split(":");c&&a&&(r[c.trim()]=a.trim());}return r};var Re=(e,t,r,s)=>{if(s[e])return s[e];let c=t==null?void 0:t.experiments.find(a=>a.key===e);return c?xn(c,r):"control"},Mt=(e,t,r)=>{var c,a,f,C,v,k;let s={...(c=e==null?void 0:e.texts)!=null?c:{}};for(let E of (a=e==null?void 0:e.experiments)!=null?a:[]){let g=Re(E.key,e,t,r);g!==((C=(f=E.variants[0])==null?void 0:f.id)!=null?C:"control")&&Object.assign(s,(k=(v=E.variants.find(w=>w.id===g))==null?void 0:v.changes)!=null?k:{});}return s},Ce="ck_x",Me=e=>e.replace(/\/+$/,"")||"/",Pt=(e,t,r,s={})=>{var C,v;if(!e)return null;let c;try{c=new URL(t);}catch(k){return null}if(c.searchParams.has(Ce))return null;let a=Me(c.pathname),f=(k,E)=>{let g;try{g=new URL(k,c);}catch(w){return}if(!(!/^https?:$/.test(g.protocol)||g.origin===c.origin&&Me(g.pathname)===a))return c.searchParams.forEach((w,S)=>{g.searchParams.has(S)||g.searchParams.set(S,w);}),E&&g.searchParams.set(Ce,E),g.hash||(g.hash=c.hash),g.href};for(let k of (C=e.redirects)!=null?C:[]){let E=k.from&&Me(k.from)===a?f(k.to):void 0;if(E)return {to:E}}for(let k of e.experiments){if(!k.path||Me(k.path)!==a)continue;let E=k.status==="running"&&!k.winner;if(E&&r===null&&!s[k.key])return null;let g=Re(k.key,e,r!=null?r:"",s),w=(v=k.variants.find(M=>M.id===g))==null?void 0:v.url,S=w?f(w,E?`${k.key}:${g}`:void 0):void 0;return E?{to:S,experiment:k.key,variant:g}:S?{to:S}:null}return null},At=(e,t)=>{let[r,s]=(t!=null?t:"").split(":"),c=e==null?void 0:e.experiments.find(a=>a.key===r);return c&&c.variants.some(a=>a.id===s)?{experiment:r,variant:s}:null};var Ze=()=>typeof crypto!="undefined"&&"randomUUID"in crypto?crypto.randomUUID():`ck_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;var ve=(e,t)=>e.length>t?`${e.slice(0,t-1)}\u2026`:e,Cn=e=>{var t;if(e instanceof Error)return {type:e.name||"Error",message:ve(e.message||String(e),1e3),stack:e.stack?ve(e.stack,8192):void 0};if(typeof e=="string")return {type:"Error",message:ve(e,1e3)};try{return {type:"Error",message:ve((t=JSON.stringify(e))!=null?t:String(e),1e3)}}catch(r){return {type:"Error",message:String(e)}}},Lt=e=>{let t=[],r=[],s=new Set,c=0,a=`${e.host}/api/sdk/errors`,f=(w=false)=>{for(;t.length;){let S=JSON.stringify({key:e.apiKey,errors:t.splice(0,4)});w&&typeof navigator!="undefined"&&"sendBeacon"in navigator&&navigator.sendBeacon(a,S)||fetch(a,{method:"POST",headers:{"content-type":"application/json"},body:S,keepalive:true}).then(L=>{!L.ok&&L.status!==429&&e.warn(`Error reports were rejected with ${L.status}. Check the public key and NEXT_PUBLIC_MRROCKET_HOST.`);}).catch(()=>{});}},C=(w,S="manual")=>{let M=e.context();if(!M.send||c>=20)return;let L=Cn(w);if(/\/api\/sdk\/errors/.test(L.message))return;let N=`${L.type}:${L.message}`;s.has(N)||(s.add(N),c++,t.push({...L,mechanism:S,handled:S==="manual",url:window.location.href,ts:Date.now(),crumbs:r.slice(),...e.release?{release:e.release}:{},...M.distinctId?{distinctId:M.distinctId}:{},...M.sessionId?{sessionId:M.sessionId}:{}}));},v=w=>{var S;!w.error&&(!w.message||w.message==="Script error.")||C((S=w.error)!=null?S:new Error(w.message),"onerror");},k=w=>{var S;return C((S=w.reason)!=null?S:new Error("Unhandled promise rejection"),"onunhandledrejection")},E=()=>f(true);window.addEventListener("error",v),window.addEventListener("unhandledrejection",k),window.addEventListener("pagehide",E);let g=window.setInterval(()=>f(),2e3);return {capture:C,crumb:(w,S)=>{r.push({ts:Date.now(),type:w,message:ve(S,120)}),r.length>20&&r.shift();},stop:()=>{window.removeEventListener("error",v),window.removeEventListener("unhandledrejection",k),window.removeEventListener("pagehide",E),window.clearInterval(g),f(true);}}};var Ee="$cancel_flow",re="$onboarding",et="$inapp",Rn={version:0,question:"",reasons:[],offers:{},confirm:{title:"Cancel your subscription?",body:"You keep access until the end of the billing period.",button:"Cancel subscription"},offersFor:"business"},vn="Something went wrong. Please try again.",Nt="mrrocket:onboarding",Ae=e=>e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),Tt=new Set(["signed_up","signup","sign_up","registered","account_created","user_signed_up"]),tt=(e,t)=>{let r=Ae(e),s=Ae(t);return !r||!s?false:r===s||Tt.has(r)&&Tt.has(s)},En=e=>/^(first (launch|visit|open|session|login|sign ?in|app open)|app (opened|launched)|on load|every visit|always)?$/i.test(e.trim()),_n=()=>`cf_${Math.random().toString(36).slice(2,10)}${Date.now().toString(36)}`;var Sn=e=>{let t=(e!=null?e:"").trim();return /^https?:\/\//i.test(t)||/^\/(?!\/)/.test(t)?t:void 0},le=e=>{var t;return (t=e.nodes)!=null?t:e.steps},In=e=>Math.max(0,e.amount)*(e.unit==="hours"?36e5:864e5),On=(e,t)=>{let r=e.trim(),s=(t.split(/[?#]/)[0]||"/").replace(/\/+$/,"")||"/";if(!r)return false;if(r.endsWith("*")){let c=r.slice(0,-1).replace(/\/+$/,"");return !c||s===c||s.startsWith(`${c}/`)}return s===(r.replace(/\/+$/,"")||"/")},nt=e=>e.flatMap(t=>t.kind==="condition"?[...nt(t.yes),...nt(t.no)]:t.kind==="wait"?[]:[t]),Dt=e=>{let t=null,r=null,s=null,c=[],a=false,f=null,C,v=null,k=new Map,E=new Set,g=new Set,w=new Set,S=e.auto!==false,M=new Set,L=()=>{var n,i;return (i=(n=e.now)==null?void 0:n.call(e))!=null?i:Date.now()},N=null,z=()=>{var n;return (n=t==null?void 0:t.onboarding)!=null?n:[]},Z=n=>n?z().find(i=>i.id===n):void 0,H=n=>{let i=k.get(n);return i||k.set(n,i={done:new Set,dismissed:false,answers:new Map,at:new Map,reached:new Map}),i},G=false,K=n=>{e.track(re,n),G=true;},oe=(n,i)=>{n.done.add(i),n.at.set(i,L());},Be=n=>{var i,l,m;if((i=n.page)!=null&&i.trim()){let p=(l=e.path)==null?void 0:l.call(e);return p===void 0?false:On(n.page,p)}if((m=n.event)!=null&&m.trim()){if(!a)return;for(let p of M)if(tt(n.event,p))return true;return false}return false},de=(n,i,l,m,p=0,_)=>{var I,b;for(let y=0;y<i.length;y++){let x=i[y];if(x.kind==="wait"){if(l.done.has(x.id)){_=(I=l.at.get(x.id))!=null?I:_;continue}let O=l.reached.get(x.id);if(O===void 0){if(!m)return {at:"pending"};O=_!=null?_:L(),l.reached.set(x.id,O),K({flow:n.id,step:x.id,kind:"wait",action:"shown"});}let B=O+In(x);if(L()<B)return {at:"wait",until:B};if(!m)return {at:"pending"};oe(l,x.id),K({flow:n.id,step:x.id,kind:"wait",action:"completed"}),_=B;continue}if(x.kind==="condition"){let O=l.answers.get(x.id);if(O===void 0){if(!m)return {at:"pending"};if(O=Be(x),O===void 0)return {at:"pending"};l.answers.set(x.id,O),K({flow:n.id,step:x.id,kind:"condition",action:"answered",answer:O?"yes":"no"});}return de(n,O?x.yes:x.no,l,m,p,_)}if(!l.done.has(x.id))return {at:"step",step:x,line:i,index:y,before:p};_=(b=l.at.get(x.id))!=null?b:_,p++;}return {at:"end"}},se=n=>{let i=k.get(n.id);return !!i&&(i.dismissed||de(n,le(n),i,false).at==="end")},ue=n=>`${Nt}:${n!=null?n:"visitor"}`,j=n=>`${Nt}:events:${n!=null?n:"visitor"}`,W=()=>{var l;G=false;let n=(l=e.storage)==null?void 0:l.call(e);if(!n)return;let i={};for(let[m,p]of k)i[m]={done:[...p.done],...p.dismissed?{dismissed:true}:{},...p.answers.size?{answers:Object.fromEntries([...p.answers].map(([_,I])=>[_,I?"yes":"no"]))}:{},...p.at.size?{at:Object.fromEntries(p.at)}:{},...p.reached.size?{reached:Object.fromEntries(p.reached)}:{}};try{n.set(ue(e.personId()),JSON.stringify(i)),M.size&&n.set(j(e.personId()),JSON.stringify([...M].slice(-200)));}catch(m){}},$=n=>{var i,l,m,p;for(let[_,I]of Object.entries(n!=null?n:{})){let b=H(_);for(let y of (i=I.done)!=null?i:[])b.done.add(y);I.dismissed&&(b.dismissed=true);for(let[y,x]of Object.entries((l=I.answers)!=null?l:{}))b.answers.has(y)||b.answers.set(y,x==="yes");for(let[y,x]of Object.entries((m=I.at)!=null?m:{}))typeof x=="number"&&!b.at.has(y)&&b.at.set(y,x);for(let[y,x]of Object.entries((p=I.reached)!=null?p:{}))typeof x=="number"&&(!b.reached.has(y)||x<b.reached.get(y))&&b.reached.set(y,x);}},Q=n=>{var l;N&&clearTimeout(N),N=null;let i=n-L();i>0&&i<=864e5&&(N=setTimeout(()=>(N=null,P()),i+50),(l=N.unref)==null||l.call(N));},fe=false,ie=()=>{fe=false;let n=Z(s);if(!n)return null;let i=H(n.id);if(i.dismissed)return null;let l=de(n,le(n),i,true);if(G&&W(),l.at==="wait"&&Q(l.until),fe=l.at==="wait"||l.at==="pending",l.at!=="step")return null;let{step:m,line:p,index:_}=l,I=O=>!!O&&O.kind!=="wait"&&O.kind!=="condition";if(m.kind==="checklist"){let O=_;for(;O>0&&I(p[O-1])&&p[O-1].kind==="checklist";)O--;let B=_;for(;B+1<p.length&&I(p[B+1])&&p[B+1].kind==="checklist";)B++;let ge=p.slice(O,B+1).filter(I);for(let Y of ge)!i.done.has(Y.id)&&!g.has(`s:${Y.id}`)&&(g.add(`s:${Y.id}`),e.track(re,{flow:n.id,step:Y.id,kind:"checklist",action:"shown"}));return {type:"checklist",flow:n,items:ge.map(Y=>({step:Y,done:i.done.has(Y.id)}))}}g.has(`s:${m.id}`)||(g.add(`s:${m.id}`),e.track(re,{flow:n.id,step:m.id,kind:m.kind,action:"shown"}));let b=p.slice(_+1),y=b.findIndex(O=>O.kind==="condition"),x=(y<0?b:b.slice(0,y)).filter(I).length;return {type:"step",flow:n,step:m,index:l.before,total:l.before+1+x,last:!x&&y<0}},ae=()=>{if(r){let l=r.reason?r.flow.offers[r.reason]:void 0;return {type:"cancel",screen:r.screen,flow:r.flow,reason:r.reason,offer:r.screen==="offer"?l:void 0,price:r.options.price,busy:r.busy,error:r.error,step:r.plain||r.screen==="survey"?1:r.screen==="offer"?2:3,steps:r.plain?1:3}}let n=ie();if(n)return n;s&&!fe&&(s=null);let i=c.find(l=>!E.has(l.id));return i?{type:"message",message:i}:null},P=()=>{let n=ae();(n==null?void 0:n.type)==="message"&&!g.has(`m:${n.message.id}`)&&(g.add(`m:${n.message.id}`),e.track(et,{message:n.message.id,journey:n.message.journey,action:"shown"}));for(let i of [...w])try{i();}catch(l){}},J=n=>s===n.id?true:s&&Z(s)&&!se(Z(s))?false:(s=n.id,e.track(re,{flow:n.id,action:"started"}),P(),true),ye=()=>{var i;if(!S||s||!a||!e.personId()&&!((i=e.storage)!=null&&i.call(e)))return;let n=z().find(l=>En(l.trigger)&&le(l).length&&!se(l));n&&J(n);},Ie=()=>{let n=e.personId();v!==null&&v!==n&&(k.clear(),M.clear(),E.clear(),s=null,C=void 0),v=n;let i=(async()=>{var p,_,I;let l=(p=e.storage)==null?void 0:p.call(e);if(l)try{let b=await l.get(ue(n));b&&$(JSON.parse(b));let y=await l.get(j(n));if(y)for(let x of JSON.parse(y))typeof x=="string"&&M.add(x);}catch(b){}let m=z().length>0||!!(t!=null&&t.messages);if(n&&m&&C!==n){C=n;let b=await e.fetchInApp(n).catch(()=>null);if(b&&e.personId()===n){$(b.onboarding);for(let y of (_=b.events)!=null?_:[])typeof y=="string"&&M.add(Ae(y));c=((I=b.messages)!=null?I:[]).filter(y=>y&&y.id&&y.title);}}n||(c=[]),a=true,ye(),P();})();return f=i.finally(()=>{f===i&&(f=null);}),f},D=(n,i,l)=>{var p;let m=n.reason?n.flow.offers[n.reason]:void 0;return {outcome:i,run:n.run,...n.reason?{reason:n.reason,reasonLabel:(p=n.flow.reasons.find(_=>_.id===n.reason))==null?void 0:p.label}:{},...i==="saved"&&m?{offer:m}:{},...l!=null&&l.trim()?{comment:l.trim().slice(0,500)}:{}}},U=(n,i)=>{var l;e.track(Ee,{action:"finished",run:n.run,version:n.flow.version,outcome:i.outcome,customer:(l=n.options.customer)!=null?l:"consumer",...i.reason?{reason:i.reason}:{},...i.offer?{offer:i.offer.kind}:{},...i.comment?{comment:i.comment}:{}}),r===n&&(r=null),n.resolve(i),P();},V=(n,i,l)=>{if(n.busy)return;let m=D(n,i,l),p=i==="saved"?n.options.onSave:n.options.onCancel;n.busy=true,n.error=void 0,P(),Promise.resolve().then(()=>p==null?void 0:p(m)).then(()=>U(n,m),()=>{n.busy=false,n.error=vn,P();});};return {setConfig:n=>{t=n,s&&!Z(s)&&(s=null),P();},refresh:Ie,onEvent:n=>{var I;if(!n||n.startsWith("$"))return;let i=Ae(n),l=!!i&&!M.has(i);l&&M.add(i);let m=Z(s),p=false;if(m){let b=H(m.id);for(let y of nt(le(m)))y.kind==="checklist"&&y.event&&!b.done.has(y.id)&&tt(y.event,n)&&(oe(b,y.id),p=true,e.track(re,{flow:m.id,step:y.id,kind:y.kind,action:"completed"}));}if(p||l&&m?(W(),P()):l&&W(),!S||!e.personId()&&!((I=e.storage)!=null&&I.call(e)))return;let _=z().find(b=>le(b).length&&tt(b.trigger,n)&&!se(b));_&&J(_);},openCancelFlow:(n={})=>{var I,b;if(r)return r.promise;let i=(I=t==null?void 0:t.cancelFlow)!=null?I:Rn,l=n.customer!=="business"||i.reasons.length<2,m=()=>{},p=new Promise(y=>m=y),_={flow:i,options:n,plain:l,screen:l?"confirm":"survey",run:_n(),busy:false,resolve:m,promise:p};return r=_,e.track(Ee,{action:"shown",run:_.run,version:i.version,customer:(b=n.customer)!=null?b:"consumer",plain:l}),P(),p},startOnboarding:n=>{let i=n?Z(n):z().find(m=>le(m).length&&!se(m));if(!i||!le(i).length)return false;let l=H(i.id);return l.dismissed=false,J(i)},view:ae,subscribe:n=>(w.add(n),()=>w.delete(n)),cancel:{pick:n=>{!r||r.busy||!r.flow.reasons.some(i=>i.id===n)||(r.reason=n,r.error=void 0,P());},next:()=>{let n=r;!n||n.screen!=="survey"||!n.reason||(e.track(Ee,{action:"answered",run:n.run,version:n.flow.version,reason:n.reason}),n.screen=n.flow.offers[n.reason]?"offer":"confirm",P());},accept:n=>{let i=r;if(!i||i.screen!=="offer"||!i.reason)return;let l=i.flow.offers[i.reason];i.busy||e.track(Ee,{action:"offer",run:i.run,version:i.flow.version,reason:i.reason,offer:l==null?void 0:l.kind,outcome:"accepted"}),V(i,"saved",n);},decline:()=>{var i;let n=r;!n||n.screen!=="offer"||n.busy||(e.track(Ee,{action:"offer",run:n.run,version:n.flow.version,reason:n.reason,offer:n.reason?(i=n.flow.offers[n.reason])==null?void 0:i.kind:void 0,outcome:"declined"}),n.screen="confirm",n.error=void 0,P());},confirm:n=>{let i=r;!i||i.screen!=="confirm"||V(i,"cancelled",n);},close:()=>{var l,m;let n=r;if(!n||n.busy)return;let i=D(n,"kept");(m=(l=n.options).onClose)==null||m.call(l,i),U(n,i);}},onboarding:{next:()=>{let n=ie();(n==null?void 0:n.type)==="step"&&(oe(H(n.flow.id),n.step.id),e.track(re,{flow:n.flow.id,step:n.step.id,kind:n.step.kind,action:"completed"}),W(),P());},check:n=>{let i=ie();if((i==null?void 0:i.type)!=="checklist")return;let l=i.items.find(m=>m.step.id===n);!l||l.done||(oe(H(i.flow.id),n),e.track(re,{flow:i.flow.id,step:n,kind:"checklist",action:"completed"}),W(),P());},dismiss:()=>{let n=ie();!n||n.type!=="step"&&n.type!=="checklist"||(H(n.flow.id).dismissed=true,e.track(re,{flow:n.flow.id,...n.type==="step"?{step:n.step.id}:{},action:"dismissed"}),s=null,W(),P());}},message:{click:()=>{var l;let n=ae();if((n==null?void 0:n.type)!=="message")return;E.add(n.message.id),e.track(et,{message:n.message.id,journey:n.message.journey,action:"clicked"});let i=Sn(n.message.url);P(),i&&((l=e.openUrl)==null||l.call(e,i));},dismiss:()=>{let n=ae();(n==null?void 0:n.type)==="message"&&(E.add(n.message.id),e.track(et,{message:n.message.id,journey:n.message.journey,action:"dismissed"}),P());}}}};var Fn="ck_pick",$n="ck_origin",Le=e=>typeof CSS!="undefined"&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,t=>`\\${t}`),Mn=e=>[...e.classList].filter(t=>t.length<30&&!/\d{2,}|[_-][a-z0-9]{5,}$|^(is|has)-|hover|active|focus|open|selected|:|\[/.test(t)).slice(0,2),Ut=e=>{let t=e.ownerDocument,r=f=>{try{return t.querySelectorAll(f).length===1}catch(C){return false}},s=e.getAttribute("data-ck-target");if(s)return `[data-ck-target="${s.replace(/"/g,'\\"')}"]`;if(e.id&&!/\d{3,}/.test(e.id)&&r(`#${Le(e.id)}`))return `#${Le(e.id)}`;let c=[],a=e;for(;a&&a!==t.documentElement&&c.length<6;){if(a!==e&&a.id&&!/\d{3,}/.test(a.id)){c.unshift(`#${Le(a.id)}`);break}let f=a.tagName.toLowerCase(),C=Mn(a).map(w=>`.${Le(w)}`).join(""),v=a.parentElement,k=v?[...v.children].filter(w=>w.tagName===a.tagName):[],E=k.length>1?`:nth-of-type(${k.indexOf(a)+1})`:"";c.unshift(`${f}${C}${E}`);let g=c.join(" > ");if(r(g))return g;a=v;}return c.join(" > ")},jt=()=>{var E;if(typeof window=="undefined"||window.top===window)return null;let e=new URLSearchParams(window.location.search);if(e.get(Fn)!=="1")return null;let t;try{t=new URL((E=e.get($n))!=null?E:"").origin;}catch(g){return null}if(!/^https?:\/\//.test(t))return null;let r=g=>window.parent.postMessage(g,t),s=document.createElement("div");s.setAttribute("aria-hidden","true"),Object.assign(s.style,{position:"fixed",zIndex:"2147483647",pointerEvents:"none",border:"2px solid #0ea5e9",background:"rgba(14,165,233,.12)",borderRadius:"6px",transition:"all 60ms linear",display:"none"});let c=document.createElement("div");Object.assign(c.style,{position:"absolute",left:"-2px",bottom:"calc(100% + 4px)",font:"600 11px/1.4 system-ui, sans-serif",color:"#fff",background:"#0c4a6e",padding:"2px 6px",borderRadius:"4px",whiteSpace:"nowrap",maxWidth:"360px",overflow:"hidden",textOverflow:"ellipsis"}),s.appendChild(c),document.body.appendChild(s);let a=null,f=g=>{if(a=g&&g!==s&&!s.contains(g)?g:null,!a){s.style.display="none";return}let w=a.getBoundingClientRect();Object.assign(s.style,{display:"block",left:`${w.left-2}px`,top:`${w.top-2}px`,width:`${w.width+4}px`,height:`${w.height+4}px`}),c.textContent=Ut(a);},C=g=>f(document.elementFromPoint(g.clientX,g.clientY)),v=g=>{var S,M;g.preventDefault(),g.stopPropagation();let w=(S=document.elementFromPoint(g.clientX,g.clientY))!=null?S:a;!w||w===s||r({type:"mrrocket:picked",selector:Ut(w),text:((M=w.textContent)!=null?M:"").trim().replace(/\s+/g," ").slice(0,80)});},k=g=>{g.key==="Escape"&&r({type:"mrrocket:pick-cancel"});};return window.addEventListener("mousemove",C,true),window.addEventListener("click",v,true),window.addEventListener("keydown",k,true),r({type:"mrrocket:pick-ready"}),()=>{window.removeEventListener("mousemove",C,true),window.removeEventListener("click",v,true),window.removeEventListener("keydown",k,true),s.remove();}};var Pn={get:e=>{try{return window.localStorage.getItem(e)}catch(t){return null}},set:(e,t)=>{try{window.localStorage.setItem(e,t);}catch(r){}}},Ht=()=>{try{for(let e=window.localStorage.length-1;e>=0;e--){let t=window.localStorage.key(e);t!=null&&t.startsWith("mrrocket:onboarding")&&window.localStorage.removeItem(t);}}catch(e){}},Kt=e=>({track:e.track,personId:e.personId,auto:e.auto,storage:()=>e.canStore()?Pn:null,openUrl:t=>window.location.assign(t),path:()=>window.location.pathname,fetchInApp:async t=>{if(!e.apiKey)return null;let r=await fetch(`${e.host}/api/sdk/inapp?key=${encodeURIComponent(e.apiKey)}&distinctId=${encodeURIComponent(t)}`);return r.ok?await r.json():null}});var De="mrr_ref",Ue="mrr_ref",An="mrr_ref",Ln="mrr_click";var _e=/^[A-Za-z0-9_-]{1,64}$/;var Nn=(e,t="ref")=>{let r=new URLSearchParams(e);return Tn(s=>r.get(s),t)},Tn=(e,t="ref")=>{let r=e(An);if(r&&_e.test(r)){let c=e(Ln);return {code:r,clickId:c&&_e.test(c)?c:null,direct:false}}let s=e(t);return s&&_e.test(s)?{code:s,clickId:null,direct:true}:null},Wt=e=>{var t;return `${e.code}.${(t=e.clickId)!=null?t:""}.${e.at}`},Ne=(e,t=60,r=Date.now())=>{if(!e)return null;let[s,c,a]=e.split("."),f=Number(a);return !s||!_e.test(s)||!Number.isFinite(f)||c&&!_e.test(c)||r-f>t*864e5||f>r+864e5?null:{code:s,clickId:c||null,at:f}};var T=null,je=()=>typeof document!="undefined",Vt=e=>{var r;if(!je())return;let t=(r=document.cookie.split("; ").find(s=>s.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);try{return t?decodeURIComponent(t):void 0}catch(s){return t}},He=()=>{try{return typeof localStorage=="undefined"?null:localStorage}catch(e){return null}},rt=()=>{var e,t;return T||(je()?(t=Ne(Vt(De),3650))!=null?t:Ne((e=He())==null?void 0:e.getItem(Ue),3650):null)};var Te=(e,t)=>{var c;if(!je())return;let r=Math.max(1,Math.round(t))*86400,s=typeof location!="undefined"&&location.protocol==="https:"?"; secure":"";document.cookie=`${De}=${encodeURIComponent(Wt(e))}; path=/; max-age=${r}; samesite=lax${s}`;try{(c=He())==null||c.setItem(Ue,Wt(e));}catch(a){}},Ke=()=>{var e;if(je()){document.cookie=`${De}=; path=/; max-age=0; samesite=lax`;try{(e=He())==null||e.removeItem(Ue);}catch(t){}}},Bt=()=>{T=null;},qt=async e=>{var s,c,a;let t=Nn(e.search,e.param),r=(s=e.now)!=null?s:Date.now();if(!t)return !T&&e.store&&(T=(a=Ne(Vt(De),e.days,r))!=null?a:Ne((c=He())==null?void 0:c.getItem(Ue),e.days,r),T||Ke()),T;if(T={code:t.code,clickId:t.clickId,at:r},e.store&&Te(T,e.days),e.beacon)try{let f=await e.beacon({code:t.code,clickId:t.clickId});f&&T&&T.code===t.code&&!T.clickId&&(T={...T,clickId:f},e.store&&Te(T,e.days));}catch(f){}return T},Yt=e=>e==="$identify"||!e.startsWith("$");var ot=3600*24*365,Jt=e=>{var r;if(typeof document=="undefined")return;let t=(r=document.cookie.split("; ").find(s=>s.startsWith(`${e}=`)))==null?void 0:r.slice(e.length+1);if(t)try{return decodeURIComponent(t)}catch(s){return t}},We=(e,t,r)=>{let s=window.location.protocol==="https:"?"; secure":"";document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${r}; samesite=lax${s}`;},Se=e=>{document.cookie=`${e}=; path=/; max-age=0; samesite=lax`;},A={utm:{}},zt=()=>{var e;return (e=A.id)!=null?e:A.id=Ze()},st=(e,t)=>{if(e!=="cookies")return zt();let r=Jt(ce);if(r)return A.id=r;let s=zt();return We(ce,s,ot),s},it=e=>{var c;let t=Date.now(),r=A.session,s=(c=e?Jt(ke):void 0)!=null?c:r&&t-r.last<18e5?r.id:Ze();return A.session={id:s,last:t},e&&We(ke,s,18e5/1e3),s},at=()=>{var r;let e=window.location.href;if(A.url===e)return;A.referrer=(r=A.url)!=null?r:document.referrer||void 0,A.url=e;let t=Ft(window.location.search);Object.keys(t).length&&(A.utm=t);},Gt=()=>{let e=navigator,t=window;return e.doNotTrack==="1"||t.doNotTrack==="1"||e.globalPrivacyControl===true};var Ve=window,Un=()=>{var e,t;return (t=(e=document.currentScript)!=null?e:document.querySelector('script[data-key][src*="sdk"]'))!=null?t:document.querySelector("script[data-key][src*='mrrocket']")},Qt=new Set,X=e=>{Qt.has(e)||(Qt.add(e),console.warn(`[MRRocket] ${e}`));},jn=()=>{var wt,kt,yt,bt;let e=Un(),t=o=>{var d;return (d=e==null?void 0:e.getAttribute(`data-${o}`))!=null?d:void 0},r=(o,d)=>{let u=t(o);return u===void 0?d:!["false","0","off","no"].includes(u.trim().toLowerCase())},s=(wt=e==null?void 0:e.src)!=null?wt:"",c="";try{c=s?new URL(s,window.location.href).origin:"";}catch(o){c="";}let a=((kt=t("key"))!=null?kt:"").trim(),f=((yt=t("api-host"))!=null?yt:c).trim().replace(/\/+$/,""),C=t("consent"),v=r("respect-dnt",false),k=r("heatmaps",true),E=r("errors",true),g=t("release"),w=t("attribution"),S=w==="always"||w==="off"?w:"consent",M=t("referral-param")||"ref",L={},N=(o,d)=>{var u;return (u=L[o])!=null?u:L[o]=new Promise((h,R)=>{var xt;let F=()=>Ve[d];if(F())return h(F());let q=(xt=t(`${o}-src`))!=null?xt:s?s.replace(/(\.min)?\.js(\?[^#]*)?(#.*)?$/,`-${o}$1.js?v=${Pe}`):"";if(!q)return R(new Error(o));let ne=document.createElement("script");ne.async=true,ne.src=q,ne.onload=()=>F()?h(F()):R(new Error(o)),ne.onerror=()=>R(new Error(o)),document.head.appendChild(ne);}).catch(h=>{throw L[o]=void 0,h})},z=t("theme"),Z={theme:z==="light"||z==="dark"?z:"auto",accent:t("accent")},H=new URLSearchParams(window.location.search),G=$t(H.get(It)),K=H.get(Ot)==="1";K&&jt();let oe=H.get(Ce);if(oe!==null){H.delete(Ce);let o=H.toString();history.replaceState(history.state,"",`${window.location.pathname}${o?`?${o}`:""}${window.location.hash}`);}let Be=Gt(),de=C==="cookies"||C==="off"?C:"cookieless",se=r("replay",false),ue="",j,W,$=null,Q=false,fe=false,ie=null,ae=null,P=window.location.pathname,J=[],ye=new Set,Ie=[],D=()=>v&&Be?"off":de,U=()=>!K&&D()!=="off",V=()=>j!=null?j:ue,pe=()=>D()==="cookies"?V():j;a||X('No public key. Add data-key="mrr_pub_\u2026" to the script tag; nothing is tracked until then.');let Oe=(o=false)=>{if(!J.length)return;if(!a){J.length=0;return}let d=`${f}/api/sdk/events`;for(let u of Rt(a,J.splice(0),{v:Pe,errors:E,platform:"web"}))o&&"sendBeacon"in navigator&&navigator.sendBeacon(d,u)||fetch(d,{method:"POST",headers:{"content-type":"application/json"},body:u,keepalive:true}).then(R=>{R.ok||X(`Events were rejected with ${R.status}. Check data-key (MRRocket \u203A Settings \u203A Products).`);}).catch(()=>X(`Could not reach ${f||"this origin"} to send events. Check data-api-host.`));},n=null,i=null,l=(o,d,u=Date.now(),h)=>{if(!U())return;let R=Yt(o)?rt():null;J.push({event:o,props:R?{...d,$referral:{code:R.code,clickId:R.clickId}}:d,distinctId:pe(),sessionId:it(D()==="cookies"),ts:u,url:h!=null?h:window.location.href,referrer:A.referrer,...A.utm,screen:{w:window.screen.width,h:window.screen.height}});},m=(o,d)=>{typeof o!="string"||!o||(l(o,d),U()&&(n==null||n.event(o)),p.onEvent(o));},p=Dt(Kt({host:f,apiKey:a,track:l,personId:()=>U()?j:void 0,canStore:()=>D()==="cookies",auto:r("onboarding",true)})),_=false;p.subscribe(()=>{_||!p.view()||K||(_=true,N("flows","__mrrocketFlows").then(o=>o.mountFlows(p,Z)).catch(()=>{_=false,X("The cancel flow and onboarding dialogs did not load. Check that sdk-flows.js is served next to sdk.js.");}));});let I=(o,d)=>{if(!U())return;let u=`${window.location.pathname}|${o}`;ye.has(u)||(ye.add(u),m("$exposure",{experiment:o,variant:d}));},b=()=>{let o=Pt($,window.location.href,V(),G);return o!=null&&o.to?(Oe(true),window.location.replace(o.to),true):(o!=null&&o.experiment&&I(o.experiment,o.variant),false)},y=()=>{if(!$)return;let o=document.querySelectorAll("[data-ck-text]");if(!o.length)return;let d=Mt($,V(),G),u=new Set;o.forEach(h=>{var q,ne;let R=h.dataset.ckText;if(!R)return;u.add(R),h.dataset.ckDefault===void 0&&(h.dataset.ckDefault=(q=h.textContent)!=null?q:"");let F=(ne=d[R])!=null?ne:h.dataset.ckDefault;h.textContent!==F&&(h.textContent=F);});for(let h of $.experiments)h.variants.some(R=>{var F;return Object.keys((F=R.changes)!=null?F:{}).some(q=>u.has(q))})&&I(h.key,Re(h.key,$,V(),G));},x=()=>{var o,d;return (d=(o=$==null?void 0:$.referral)==null?void 0:o.cookieDays)!=null?d:60},O=()=>S==="always"?D()!=="off":S==="consent"&&D()==="cookies",B=null,ge=false,Y=()=>{if(!Q||K)return;if(S==="off"||D()==="off"){Bt(),(S==="off"||ge)&&Ke();return}let o=window.location.href;B!==o&&(B=o,qt({search:window.location.search,param:M,store:O(),days:x(),beacon:a?({code:d,clickId:u})=>fetch(`${f}/api/sdk/affiliate/click`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({key:a,code:d,clickId:u,url:o,referrer:document.referrer||void 0}),keepalive:true}).then(h=>h.ok?h.json():null).then(h=>{var R;return (R=h==null?void 0:h.clickId)!=null?R:null}):void 0}));},en=()=>{let o=O(),d=rt();o&&d?Te(d,x()):!o&&ge&&Ke(),ge=o;},ct=0,lt=false,dt=()=>{var h,R;let o=U()&&se&&!!($!=null&&$.replay)&&!!a;if(o===lt)return;lt=o;let d=++ct;if(!o){n==null||n.stop(true),n=null;return}let u=(R=(h=$==null?void 0:$.replay)==null?void 0:h.sampleRate)!=null?R:.1;N("replay","__mrrocketReplay").then(F=>F.startReplay({host:f,apiKey:a,sessionId:it(D()==="cookies"),distinctId:pe(),identified:!!j,sampleRate:u,warn:X})).then(F=>{d!==ct?F==null||F.stop(true):n=F;}).catch(()=>X("Session recording could not start (the recorder did not load)."));},ut=r("messenger",false),ee=null,me=o=>{K||a&&(ee!=null||(ee=N("messenger","__mrrocketMessenger").then(d=>{var F;let u=q=>t(`messenger-${q}`)===void 0?void 0:r(`messenger-${q}`,true),h=t("messenger-position"),R=(F=t("messenger-theme"))!=null?F:z;return d.mountMessenger({host:f,apiKey:a,distinctId:V,user:()=>W,launcher:ut,position:h==="bottom-left"||h==="bottom-right"?h:void 0,title:t("messenger-title"),greeting:t("messenger-greeting"),label:t("messenger-label"),askEmail:u("ask-email"),help:u("help"),sound:u("sound"),preview:u("preview"),theme:R==="light"||R==="dark"||R==="auto"?R:void 0,accent:t("accent")})})),ee.then(o).catch(()=>{ee=null,X("sdk-messenger.js did not load.");}));},ft=t("forms")==="auto",qe=false,Ye=()=>{qe||!a||K||!document.querySelector(ft?"form":"form[data-mrrocket-form]")||(qe=true,N("forms","__mrrocketForms").then(o=>o.watchForms({host:f,apiKey:a,auto:ft,distinctId:()=>U()?pe():void 0,identified:()=>!!j,identify:ht,tracking:U,referrer:()=>A.referrer,utm:()=>A.utm})).catch(()=>qe=false));},Xe=()=>{!fe||!U()||ae===window.location.pathname||(ae=window.location.pathname,m("$pageview",{path:window.location.pathname}));},te=null,pt=()=>{let o=te;k&&o&&o.max>0&&l("$scroll",{depth:o.max,docH:o.docH,vw:window.innerWidth,vh:window.innerHeight},Date.now(),o.url),te=null;},be=()=>{var R,F;if(!k||!U()||K)return;let o=document.documentElement,d=Math.max(o.scrollHeight,(F=(R=document.body)==null?void 0:R.scrollHeight)!=null?F:0),u=_t(),h=window.location.href;(te==null?void 0:te.url)!==h?te={url:h,max:u,docH:d}:u>te.max&&(te={url:h,max:u,docH:d});},gt=()=>{let o=window.location.pathname;o!==P&&(P=o,!(Q&&b())&&(pt(),at(),n==null||n.page(o),i==null||i.crumb("navigation",o),Xe(),Y(),window.setTimeout(()=>{be(),y(),Ye();},0)));},mt=()=>{let o=D(),d=ie;ie=o,d==="cookies"&&o!=="cookies"&&(Se(ce),Se(ke)),o==="off"&&(J.length=0,A.session=void 0),d==="cookies"&&o!=="cookies"&&Ht(),ue=st(o),en(),Y(),dt(),Xe(),be();},tn=o=>{let{analytics:d,replay:u}=typeof o=="string"?{analytics:o,replay:void 0}:o!=null?o:{};if(d!==void 0&&d!=="cookieless"&&d!=="cookies"&&d!=="off"){X(`setConsent: "${String(d)}" is not a consent mode. Use "cookieless", "cookies" or "off".`);return}d==="off"&&(J.length=0),d&&(de=d),typeof u=="boolean"&&(se=u),mt(),Q&&p.refresh();},ht=(o,d)=>{if(typeof o!="string"||!o)return;let u=pe();j=o,l("$identify",{...d,id:o,...u&&u!==o?{previousId:u}:{}}),n==null||n.identify(o),D()==="cookies"&&We(ce,o,ot),W={...d,id:o},y(),Q&&p.refresh();},Fe={track:m,identify:ht,reset:()=>{j=void 0,W=void 0,ye.clear(),D()==="cookies"&&(Se(ce),Se(ke)),A.id=void 0,A.session=void 0,ue=st(D()),y(),Q&&p.refresh();},captureError:o=>i==null?void 0:i.capture(o,"manual"),setConsent:tn,getFlag:o=>Qe(o,$,V(),{...W})!==false,getFlagVariant:o=>{let d=Qe(o,$,V(),{...W});return typeof d=="string"?d:null},getVariant:o=>{let d=Re(o,$,V(),G);return ($||G[o])&&I(o,d),d},ready:o=>{typeof o=="function"&&(Q?window.setTimeout(()=>o(Fe),0):Ie.push(o));},getDistinctId:V,cancelFlow:{open:o=>p.openCancelFlow(o)},onboarding:{start:o=>p.startOnboarding(o)},openCancelFlow:o=>p.openCancelFlow(o),startOnboarding:o=>p.startOnboarding(o),push:{subscribe:o=>{let d=U()?j:void 0;if(!d)return Promise.resolve({status:"not-signed-in"});let u=window.Notification,h=Promise.resolve(u&&u.permission==="default"&&(o==null?void 0:o.ask)!==false?u.requestPermission():u==null?void 0:u.permission);return N("push","__mrrocketPush").then(R=>R.subscribeWebPush({host:f,apiKey:a,distinctId:d,permission:h},o))},unsubscribe:()=>N("push","__mrrocketPush").then(o=>o.unsubscribeWebPush({host:f,apiKey:a,distinctId:j}))},messenger:{open:o=>me(d=>d.open(o)),close:()=>{ee==null?void 0:ee.then(o=>o.close()).catch(()=>{});},toggle:()=>me(o=>o.toggle())},openMessenger:()=>me(o=>o.open()),version:Pe};at(),mt();let he=Ve.mrrocket,nn=(bt=he==null?void 0:he.q)!=null?bt:[],ze=he&&typeof he=="object"?he:{};Object.assign(ze,Fe,{__loaded:true}),delete ze.q,Ve.mrrocket=ze;for(let[o,d]of nn){let u=Fe[o];if(typeof u=="function")try{u(...Array.from(d!=null?d:[]));}catch(h){console.error(h);}}fe=true,Xe(),E&&a&&!K&&(i=Lt({host:f,apiKey:a,release:g,context:()=>{var o;return {send:U(),distinctId:pe(),sessionId:(o=A.session)==null?void 0:o.id}},warn:X}),i.crumb("navigation",window.location.pathname));for(let o of ["pushState","replaceState"]){let d=history[o];history[o]=function(...u){let h=d.apply(this,u);return gt(),h};}window.addEventListener("popstate",gt);let rn=new xe;document.addEventListener("click",o=>{var F;o.target instanceof Element&&o.target.closest("[data-ck-messenger]")&&(o.preventDefault(),me(q=>q.open()));let d=o.target instanceof Element?o.target.closest("[data-ck-goal]"):null;if(d!=null&&d.dataset.ckGoal&&m(d.dataset.ckGoal,{text:(F=d.textContent)==null?void 0:F.trim().slice(0,80)}),!U())return;let u=Et(o);if(!u)return;let h=rn.push(u.x,u.y,Date.now());if((u.label||u.selector)&&(i==null||i.crumb("click",u.label||u.selector)),n==null||n.click(u,h),!k)return;let R={x:u.x,y:u.y,vw:u.vw,vh:u.vh,docH:u.docH,selector:u.selector,label:u.label,dead:!u.interactive};l("$click",R),h&&l("$rageclick",R);});let Je=0;window.addEventListener("scroll",()=>{Je||(Je=window.requestAnimationFrame(()=>{Je=0,be();}));},{passive:true}),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>be()):be(),window.setInterval(()=>Oe(),2e3),window.addEventListener("pagehide",()=>{pt(),Oe(true);});let Ge=()=>{if(Q=true,b())return;let o=At($,oe);o&&I(o.experiment,o.variant),document.documentElement.classList.remove("ck-hide"),Y(),dt(),p.setConfig($),p.refresh(),ut&&(document.body?me():document.addEventListener("DOMContentLoaded",()=>me())),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{y(),Ye();}):(y(),Ye());for(let d of Ie.splice(0))try{d(Fe);}catch(u){console.error(u);}};a?fetch(`${f}/api/sdk/config?key=${encodeURIComponent(a)}`).then(o=>(o.ok||X(`Config request to ${f||"this origin"} answered ${o.status}. Check data-key and data-api-host.`),o.ok?o.json():null)).then(o=>{o&&Array.isArray(o.experiments)&&($=o),Ge();}).catch(()=>{X(`Could not reach ${f||"this origin"}. Check data-api-host. The page keeps its own texts and flags stay off.`),Ge();}):Ge();},Zt;typeof window!="undefined"&&typeof document!="undefined"&&!((Zt=Ve.mrrocket)!=null&&Zt.__loaded)&&jn();
|
|
2
2
|
})();
|
package/dist/client.d.ts
CHANGED
|
@@ -58,6 +58,12 @@ export interface CockpitProviderProps {
|
|
|
58
58
|
onboarding?: boolean;
|
|
59
59
|
/** The look of the cancel flow, onboarding and message dialogs: `{ theme: "dark", accent: "#0f766e", className }`. */
|
|
60
60
|
appearance?: FlowsTheme;
|
|
61
|
+
/**
|
|
62
|
+
* Form leads (0.12.0): a submitted form marked `data-mrrocket-form` becomes a contact in MRRocket (default true).
|
|
63
|
+
* "auto" also captures any form with an email field (never one with a password field); false captures none. Only
|
|
64
|
+
* the email, the name and the other fields a person typed go out, never passwords, card or hidden fields (forms.ts).
|
|
65
|
+
*/
|
|
66
|
+
forms?: boolean | "auto";
|
|
61
67
|
children: ReactNode;
|
|
62
68
|
}
|
|
63
69
|
/**
|
|
@@ -67,7 +73,7 @@ export interface CockpitProviderProps {
|
|
|
67
73
|
* `preview` forces variants for this render, for example from the `ck_preview` search param on the server,
|
|
68
74
|
* so a Cockpit preview never flickers. Without it the provider reads the param itself after the first render.
|
|
69
75
|
*/
|
|
70
|
-
export declare const CockpitProvider: ({ apiKey: apiKeyProp, host: hostProp, preview: forced, embedded: embeddedProp, config: bootstrapConfig, distinctId: bootstrapId, consent: consentProp, respectDnt, replay: replayProp, heatmaps, surveys, errors, release, attribution, referralParam, onboarding, appearance, children, }: CockpitProviderProps) => import("react").JSX.Element;
|
|
76
|
+
export declare const CockpitProvider: ({ apiKey: apiKeyProp, host: hostProp, preview: forced, embedded: embeddedProp, config: bootstrapConfig, distinctId: bootstrapId, consent: consentProp, respectDnt, replay: replayProp, heatmaps, surveys, errors, release, attribution, referralParam, onboarding, appearance, forms, children, }: CockpitProviderProps) => import("react").JSX.Element;
|
|
71
77
|
/**
|
|
72
78
|
* `track`, `identify`, `captureError`, the consent mode, the replay consent and their setter, the visitor id and whether
|
|
73
79
|
* the experiments and flags have loaded. `setConsent("cookies")` sets the mode, `setConsent({ replay: true })` the
|
package/dist/client.js
CHANGED
|
@@ -63,6 +63,7 @@ var CockpitProvider = ({
|
|
|
63
63
|
referralParam = "ref",
|
|
64
64
|
onboarding = true,
|
|
65
65
|
appearance,
|
|
66
|
+
forms = true,
|
|
66
67
|
children
|
|
67
68
|
}) => {
|
|
68
69
|
const pathname = usePathname();
|
|
@@ -243,6 +244,31 @@ var CockpitProvider = ({
|
|
|
243
244
|
},
|
|
244
245
|
[record]
|
|
245
246
|
);
|
|
247
|
+
const identifyRef = useRef(identify);
|
|
248
|
+
identifyRef.current = identify;
|
|
249
|
+
useEffect(() => {
|
|
250
|
+
if (!forms || !apiKey || embedded || typeof window === "undefined") return;
|
|
251
|
+
let off;
|
|
252
|
+
let gone = false;
|
|
253
|
+
void import("./forms.js").then((m) => {
|
|
254
|
+
if (gone) return;
|
|
255
|
+
off = m.watchForms({
|
|
256
|
+
host,
|
|
257
|
+
apiKey,
|
|
258
|
+
auto: forms === "auto",
|
|
259
|
+
distinctId: () => live.current.tracking ? live.current.sendId : void 0,
|
|
260
|
+
identified: () => live.current.identified,
|
|
261
|
+
identify: (id, props) => identifyRef.current(id, props),
|
|
262
|
+
tracking: () => live.current.tracking,
|
|
263
|
+
referrer: () => page.referrer,
|
|
264
|
+
utm: () => page.utm
|
|
265
|
+
});
|
|
266
|
+
}).catch(() => void 0);
|
|
267
|
+
return () => {
|
|
268
|
+
gone = true;
|
|
269
|
+
off?.();
|
|
270
|
+
};
|
|
271
|
+
}, [forms, apiKey, host, embedded]);
|
|
246
272
|
useEffect(() => {
|
|
247
273
|
if (!visitor) return;
|
|
248
274
|
for (const run of early.current.splice(0)) run();
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport { Ctx, type CockpitContext, type CockpitUser, useCtx } from \"./context\";\nimport { Survey, forgetStoredDismissals } from \"./survey\";\nimport { RageDetector, clickInfo, seenDepth } from \"./capture\";\nimport type { ReplayHandle } from \"./replay\";\nimport { type ErrorCapture, startErrorCapture } from \"./errors\";\nimport {\n type AttributionMode,\n DEFAULT_REFERRAL_DAYS,\n captureReferral,\n carriesReferral,\n forgetStoredReferral,\n getReferral,\n resetReferral,\n storeReferral,\n} from \"./referral\";\nimport {\n type CockpitConfig,\n type CockpitEvent,\n type ConsentChoice,\n type ConsentMode,\n EMBED_PARAM,\n EXPOSURE_PARAM,\n ID_COOKIE,\n PREVIEW_PARAM,\n SDK_VERSION,\n SESSION_COOKIE,\n type VariantId,\n envKey,\n experimentsOfText,\n exposureFrom,\n flagFor,\n parsePreview,\n redirectFor,\n resolveHost,\n resolveVariant,\n textChanges,\n} from \"./core\";\nimport type { PushResult, WebPushOptions } from \"./push-web\";\nimport { bodies } from \"./batch\";\nimport { YEAR_S, deleteCookie, enterPage, page, privacySignal, touchSession, visitorId, writeCookie } from \"./web-state\";\nimport { type CancelFlowOptions, type CancelFlowResult, type FlowsController, createFlows } from \"./flows\";\nimport { startPicker } from \"./pick\";\nimport type { FlowsTheme } from \"./flows-ui\";\nimport { forgetFlowsStorage, webFlowsEnv } from \"./flows-web\";\n\n/** Tells the developer once, in the browser console, why the SDK is not reaching MRRocket (a wrong host or key is the usual cause). */\nconst warned = new Set<string>();\nconst warnOnce = (message: string) => {\n if (warned.has(message)) return;\n warned.add(message);\n console.warn(`[MRRocket] ${message}`);\n};\n\nexport interface CockpitProviderProps {\n /** The product's public key from Cockpit › Settings › SDK. Safe in the browser. Default: `NEXT_PUBLIC_MRROCKET_KEY`. */\n apiKey?: string;\n /** Where MRRocket runs, like `https://app.example.com`. Default: `NEXT_PUBLIC_MRROCKET_HOST`, else the page's own origin. */\n host?: string;\n preview?: Record<string, VariantId>;\n embedded?: boolean;\n /** Config fetched on the server, to render the right variant on the first paint. */\n config?: CockpitConfig;\n /** Your own id for this visitor, for example a signed-in user id. Keeps variants stable without cookies. */\n distinctId?: string;\n /**\n * \"cookieless\" (default) stores nothing in the browser, \"cookies\" keeps a visitor cookie for a year, \"off\" sends\n * nothing. The SDK does not remember the choice: set it on every page load, from the prop or setConsent().\n */\n consent?: ConsentMode;\n /** Send nothing when the browser asks not to be tracked (Do Not Track or Global Privacy Control). */\n respectDnt?: boolean;\n /**\n * The visitor's consent to session recordings, separate from analytics (default false). Recording also needs the\n * product to record (Cockpit › Sessions) and analytics not \"off\". Without it nothing is recorded or buffered.\n * Change it later with `setConsent({ replay })`.\n */\n replay?: boolean;\n /**\n * Clicks and scroll depth for Heatmaps (default true): where a click landed, a short selector and a link's or\n * button's label, never typed text. Sent under the normal analytics consent as `$click`, `$rageclick` and `$scroll`.\n */\n heatmaps?: boolean;\n /** Ask visitors the surveys you run in Cockpit. Set false to switch them off. */\n surveys?: boolean;\n /**\n * Error tracking for Build › Errors (default true): uncaught errors and unhandled promise rejections, with the page\n * and the last pages and clicks, under the normal analytics consent. Report errors you catch with\n * `useCockpit().captureError(error)`.\n */\n errors?: boolean;\n /** Your release (a version or a commit), so MRRocket can tell which release an error came with. */\n release?: string;\n /**\n * Affiliate referrals (`?ref=` links and MRRocket's tracked links). \"consent\" (default): stored in the first-party\n * `mrr_ref` cookie only while consent is \"cookies\", in memory otherwise. \"always\": stored whatever the consent (only\n * where your legal basis allows it). \"off\": referrals are ignored.\n */\n attribution?: AttributionMode;\n /** The query parameter of direct partner links, default `ref` (`https://your.site/?ref=maya`). */\n referralParam?: string;\n /**\n * Onboarding flows start on their own when the visitor does their trigger (default true). False: only\n * `useCockpit().startOnboarding()` starts one. In-app messages and `openCancelFlow` work either way.\n */\n onboarding?: boolean;\n /** The look of the cancel flow, onboarding and message dialogs: `{ theme: \"dark\", accent: \"#0f766e\", className }`. */\n appearance?: FlowsTheme;\n children: ReactNode;\n}\n\n/**\n * Put it once around your app, in `app/layout.tsx`. It loads your experiments, keeps each visitor in one variant,\n * records page views and sends your events to Cockpit in small batches.\n *\n * `preview` forces variants for this render, for example from the `ck_preview` search param on the server,\n * so a Cockpit preview never flickers. Without it the provider reads the param itself after the first render.\n */\nexport const CockpitProvider = ({\n apiKey: apiKeyProp,\n host: hostProp,\n preview: forced,\n embedded: embeddedProp,\n config: bootstrapConfig,\n distinctId: bootstrapId,\n consent: consentProp = \"cookieless\",\n respectDnt = false,\n replay: replayProp = false,\n heatmaps = true,\n surveys = true,\n errors = true,\n release,\n attribution = \"consent\",\n referralParam = \"ref\",\n onboarding = true,\n appearance,\n children,\n}: CockpitProviderProps) => {\n const pathname = usePathname();\n const apiKey = apiKeyProp ?? envKey() ?? \"\";\n const host = resolveHost(hostProp);\n const [config, setConfig] = useState<CockpitConfig | null>(bootstrapConfig ?? null);\n const [consent, setConsentState] = useState<ConsentMode>(consentProp);\n const [replayConsent, setReplayConsent] = useState(replayProp);\n const [mounted, setMounted] = useState(false);\n const [dnt, setDnt] = useState(false);\n // The visitor id and the consent mode it was made for; null until the browser has been read.\n const [visitor, setVisitor] = useState<{ mode: ConsentMode; id: string } | null>(null);\n const [identified, setIdentified] = useState<string | undefined>();\n const [urlPreview, setUrlPreview] = useState<Record<string, VariantId>>({});\n const [urlEmbedded, setUrlEmbedded] = useState(false);\n const [user, setUser] = useState<CockpitUser | undefined>();\n const [ready, setReady] = useState(!!bootstrapConfig);\n const queue = useRef<CockpitEvent[]>([]);\n // Calls from before the visitor was known (a child's effect runs before ours); replayed once it is.\n const early = useRef<(() => void)[]>([]);\n const exposed = useRef(new Set<string>());\n const lastPage = useRef<string | null>(null);\n\n const bootstrap = bootstrapId && bootstrapId !== \"anonymous\" ? bootstrapId : undefined;\n const preview = useMemo(() => ({ ...urlPreview, ...forced }), [urlPreview, forced]);\n const embedded = embeddedProp ?? urlEmbedded;\n const effectiveConsent: ConsentMode = respectDnt && dnt ? \"off\" : consent;\n const distinctId = identified ?? bootstrap ?? visitor?.id ?? \"anonymous\";\n const tracking = !embedded && effectiveConsent !== \"off\" && visitor?.mode === effectiveConsent;\n // Without cookies, events carry an id only after identify(); the server counts everyone else by its daily hash.\n const sendId = effectiveConsent === \"cookies\" ? distinctId : identified;\n\n // Preview flags and the browser's privacy signal, once, in the browser.\n useEffect(() => {\n const params = new URLSearchParams(window.location.search);\n setUrlPreview(parsePreview(params.get(PREVIEW_PARAM)));\n setUrlEmbedded(params.get(EMBED_PARAM) === \"1\");\n setDnt(privacySignal());\n setMounted(true);\n // Opened by MRRocket's onboarding editor to pick an element for a tour step (./pick.ts); only then, only in a frame.\n return params.get(EMBED_PARAM) === \"1\" ? (startPicker() ?? undefined) : undefined;\n }, []);\n\n const setConsent = useCallback((choice: ConsentChoice) => {\n const { analytics: mode, replay } = typeof choice === \"string\" ? { analytics: choice, replay: undefined } : choice;\n if (mode === \"off\") queue.current.length = 0;\n if (mode) setConsentState(mode);\n if (typeof replay === \"boolean\") setReplayConsent(replay);\n }, []);\n\n // Follow the `consent` and `replay` props when they change; setConsent() calls in between stay until they do.\n const lastProp = useRef(consentProp);\n useEffect(() => {\n if (lastProp.current === consentProp) return;\n lastProp.current = consentProp;\n setConsent(consentProp);\n }, [consentProp, setConsent]);\n const lastReplayProp = useRef(replayProp);\n useEffect(() => {\n if (lastReplayProp.current === replayProp) return;\n lastReplayProp.current = replayProp;\n setConsent({ replay: replayProp });\n }, [replayProp, setConsent]);\n\n // Storage follows consent. Leaving \"cookies\" deletes what the SDK stored; this page keeps its id in memory.\n const storedFor = useRef<ConsentMode | null>(null);\n useEffect(() => {\n if (!mounted) return;\n const before = storedFor.current;\n storedFor.current = effectiveConsent;\n if (before === \"cookies\" && effectiveConsent !== \"cookies\") {\n deleteCookie(ID_COOKIE);\n deleteCookie(SESSION_COOKIE);\n forgetStoredDismissals();\n forgetFlowsStorage();\n }\n if (effectiveConsent === \"off\") {\n queue.current.length = 0;\n page.session = undefined;\n }\n setVisitor({ mode: effectiveConsent, id: visitorId(effectiveConsent, !bootstrap) });\n }, [mounted, effectiveConsent, bootstrap]);\n\n // Experiments for this key. Without a key or when MRRocket is unreachable the page keeps control and carries on.\n useEffect(() => {\n if (!apiKey) warnOnce(\"No public key. Pass apiKey or set NEXT_PUBLIC_MRROCKET_KEY; nothing is tracked until then.\");\n if (bootstrapConfig || !apiKey) {\n setReady(true);\n return;\n }\n let live = true;\n fetch(`${host}/api/sdk/config?key=${encodeURIComponent(apiKey)}`)\n .then((r) => {\n if (!r.ok) warnOnce(`Config request to ${host || \"this origin\"} answered ${r.status}. Check the public key and NEXT_PUBLIC_MRROCKET_HOST.`);\n return r.ok ? r.json() : null;\n })\n .then((c: CockpitConfig | null) => {\n if (!live) return;\n if (c && Array.isArray(c.experiments)) setConfig(c);\n setReady(true);\n })\n .catch(() => {\n warnOnce(`Could not reach ${host || \"this origin\"}. Check NEXT_PUBLIC_MRROCKET_HOST. The page keeps working with control variants.`);\n if (live) setReady(true);\n });\n return () => {\n live = false;\n };\n }, [apiKey, host, bootstrapConfig]);\n\n const flush = useCallback(\n (beacon = false) => {\n if (!queue.current.length) return;\n if (!apiKey) {\n queue.current.length = 0;\n return;\n }\n const url = `${host}/api/sdk/events`;\n for (const body of bodies(apiKey, queue.current.splice(0), { v: SDK_VERSION, errors })) {\n const sent = beacon && typeof navigator !== \"undefined\" && \"sendBeacon\" in navigator && navigator.sendBeacon(url, body);\n if (!sent)\n fetch(url, { method: \"POST\", headers: { \"content-type\": \"application/json\" }, body, keepalive: true })\n .then((r) => {\n if (!r.ok) warnOnce(`Events were rejected with ${r.status}. Check the public key (Settings › SDK) and NEXT_PUBLIC_MRROCKET_HOST.`);\n })\n .catch(() => warnOnce(`Could not reach ${host || \"this origin\"} to send events. Check NEXT_PUBLIC_MRROCKET_HOST.`));\n }\n },\n [apiKey, host, errors],\n );\n\n useEffect(() => {\n const timer = window.setInterval(() => flush(), 2000);\n const leave = () => flush(true);\n window.addEventListener(\"pagehide\", leave);\n return () => {\n window.clearInterval(timer);\n window.removeEventListener(\"pagehide\", leave);\n flush(true);\n };\n }, [flush]);\n\n // The latest values for callbacks that must not change identity, so effects that use them run once.\n const live = useRef({ resolved: false, tracking, distinctId, sendId, persist: false, identified: false });\n live.current = { resolved: visitor !== null, tracking, distinctId, sendId, persist: visitor?.mode === \"cookies\", identified: !!identified };\n\n const record = useCallback((event: string, props: Record<string, unknown> | undefined, ts = Date.now(), url?: string) => {\n const now = live.current;\n if (!now.resolved) {\n early.current.push(() => record(event, props, ts, url));\n return;\n }\n // Previews in Cockpit never count, and nothing is sent without consent.\n if (!now.tracking) return;\n const referral = carriesReferral(event) ? getReferral() : null;\n queue.current.push({\n event,\n props: referral ? { ...props, $referral: { code: referral.code, clickId: referral.clickId } } : props,\n distinctId: now.sendId,\n sessionId: touchSession(now.persist),\n ts,\n url: url ?? window.location.href,\n referrer: page.referrer,\n ...page.utm,\n screen: { w: window.screen.width, h: window.screen.height },\n });\n }, []);\n\n // The running recorder, if this visit records (see the recording effect below).\n const replayer = useRef<ReplayHandle | null>(null);\n // Error tracking, while `errors` is on (see the effect below).\n const errorer = useRef<ErrorCapture | null>(null);\n\n // The cancel flow, onboarding and in-app messages (flows.ts): one controller for the provider's lifetime.\n const flowsRef = useRef<FlowsController | null>(null);\n const flows = (flowsRef.current ??= createFlows(\n webFlowsEnv({\n host,\n apiKey,\n track: (event, props) => record(event, props),\n personId: () => (live.current.tracking && live.current.identified ? live.current.distinctId : undefined),\n canStore: () => live.current.persist,\n auto: onboarding,\n }),\n ));\n\n const track = useCallback(\n (event: string, props?: Record<string, unknown>) => {\n record(event, props);\n if (live.current.tracking) replayer.current?.event(event);\n flows.onEvent(event);\n },\n [record, flows],\n );\n\n const identify = useCallback(\n (id: string, props?: Record<string, unknown>) => {\n const now = live.current;\n if (!now.resolved) {\n early.current.push(() => identify(id, props));\n return;\n }\n const previous = now.sendId;\n // From here on events carry this id in every mode; only \"cookies\" keeps it for the next visit.\n live.current = { ...now, distinctId: id, sendId: id, identified: true };\n record(\"$identify\", { ...props, id, ...(previous && previous !== id ? { previousId: previous } : {}) });\n replayer.current?.identify(id);\n if (now.persist) writeCookie(ID_COOKIE, id, YEAR_S);\n setIdentified(id);\n setUser({ id, ...(props as Omit<CockpitUser, \"id\">) });\n },\n [record],\n );\n\n // Replay what came in before the visitor was known: sent when tracking is on, dropped when it is not.\n useEffect(() => {\n if (!visitor) return;\n for (const run of early.current.splice(0)) run();\n }, [visitor]);\n\n // Affiliate referrals: read once the consent is known and the program's cookie days have loaded.\n const referralDays = config?.referral?.cookieDays ?? DEFAULT_REFERRAL_DAYS;\n const storeReferrals = attribution === \"always\" ? effectiveConsent !== \"off\" : attribution === \"consent\" && effectiveConsent === \"cookies\";\n const captured = useRef<string | null>(null);\n const storedReferral = useRef(false);\n useEffect(() => {\n if (!visitor || !ready || embedded) return;\n if (attribution === \"off\" || effectiveConsent === \"off\") {\n resetReferral();\n if (attribution === \"off\" || storedReferral.current) forgetStoredReferral();\n return;\n }\n const href = window.location.href;\n if (captured.current === href) return;\n captured.current = href;\n void captureReferral({\n search: window.location.search,\n param: referralParam,\n store: storeReferrals,\n days: referralDays,\n beacon: apiKey\n ? ({ code, clickId }) =>\n fetch(`${host}/api/sdk/affiliate/click`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ key: apiKey, code, clickId, url: href, referrer: document.referrer || undefined }),\n keepalive: true,\n })\n .then((r) => (r.ok ? (r.json() as Promise<{ clickId?: string | null }>) : null))\n .then((b) => b?.clickId ?? null)\n : undefined,\n });\n }, [visitor, ready, embedded, attribution, effectiveConsent, pathname, referralParam, storeReferrals, referralDays, apiKey, host]);\n\n // Consent given later keeps this page load's referral; consent withdrawn deletes what was stored.\n useEffect(() => {\n if (!mounted) return;\n const r = getReferral();\n if (storeReferrals && r) storeReferral(r, referralDays);\n else if (!storeReferrals && storedReferral.current) forgetStoredReferral();\n storedReferral.current = storeReferrals;\n }, [mounted, storeReferrals, referralDays]);\n\n // `tracking` is a dependency so that variants seen before consent are recorded once tracking starts.\n const expose = useCallback(\n (key: string, variant: VariantId) => {\n if (!tracking) return;\n const mark = `${pathname}|${key}`;\n if (exposed.current.has(mark)) return;\n exposed.current.add(mark);\n track(\"$exposure\", { experiment: key, variant });\n },\n [pathname, track, tracking],\n );\n\n // Redirects, once per page: a page redirect or a redirect test's variant sends the visitor on as soon as the config is\n // known (`experimentRedirect` in proxy.ts does it before the page renders, without a flash). A redirect test's\n // control stays and is recorded here; the page a variant lands on records it from `ck_x`, then drops the parameter.\n const decided = useRef<{ path: string; r: ReturnType<typeof redirectFor> } | null>(null);\n const arrived = useRef<string | null | undefined>(undefined);\n useEffect(() => {\n if (!ready || !visitor) return;\n if (decided.current?.path !== pathname) {\n const r = redirectFor(config, window.location.href, distinctId, preview);\n decided.current = { path: pathname, r };\n if (r?.to) {\n flush(true);\n window.location.replace(r.to);\n return;\n }\n }\n if (arrived.current === undefined) {\n const params = new URLSearchParams(window.location.search);\n arrived.current = params.get(EXPOSURE_PARAM);\n if (arrived.current !== null) {\n params.delete(EXPOSURE_PARAM);\n const q = params.toString();\n window.history.replaceState(window.history.state, \"\", `${window.location.pathname}${q ? `?${q}` : \"\"}${window.location.hash}`);\n }\n }\n if (!tracking) return;\n const r = decided.current.r;\n if (r?.experiment && !r.to) expose(r.experiment, r.variant!);\n const x = exposureFrom(config, arrived.current);\n if (x) expose(x.experiment, x.variant);\n arrived.current = null;\n }, [ready, visitor, pathname, config, distinctId, preview, tracking, expose, flush]);\n\n // The referrer and campaign of each page; before the page view below, so it already carries them.\n useEffect(() => {\n enterPage();\n replayer.current?.page(pathname);\n errorer.current?.crumb(\"navigation\", pathname);\n }, [pathname]);\n\n // Errors of the page for Build › Errors; sent only while tracking (consent, not a preview), like events.\n useEffect(() => {\n if (!errors || !apiKey || embedded) return;\n const capture = startErrorCapture({\n host,\n apiKey,\n release,\n context: () => ({ send: live.current.tracking, distinctId: live.current.sendId, sessionId: page.session?.id }),\n warn: warnOnce,\n });\n errorer.current = capture;\n capture.crumb(\"navigation\", window.location.pathname);\n return () => {\n capture.stop();\n if (errorer.current === capture) errorer.current = null;\n };\n }, [errors, apiKey, host, release, embedded]);\n\n const captureError = useCallback((error: unknown) => errorer.current?.capture(error, \"manual\"), []);\n\n // One page view per route change while tracking, so a later setConsent() records the current page right away\n // (a ref keeps React's dev double-run from counting twice).\n useEffect(() => {\n if (!tracking || lastPage.current === pathname) return;\n lastPage.current = pathname;\n // Exposures are remembered per path (\"/pricing|test\"), so nothing needs clearing here.\n track(\"$pageview\", { path: pathname });\n }, [pathname, tracking, track]);\n\n // Clicks on anything marked `data-ck-goal=\"signup_started\"` count as that goal. Every click also feeds Heatmaps\n // (`$click`, `$rageclick` on the third quick click on one spot) and, when this visit records, the recording.\n const rage = useRef(new RageDetector());\n useEffect(() => {\n const onClick = (e: MouseEvent) => {\n const el = (e.target as HTMLElement | null)?.closest<HTMLElement>(\"[data-ck-goal]\");\n if (el?.dataset.ckGoal) track(el.dataset.ckGoal, { text: el.textContent?.trim().slice(0, 80) });\n if (!live.current.tracking) return;\n const c = clickInfo(e);\n if (!c) return;\n const raged = rage.current.push(c.x, c.y, Date.now());\n if (c.label || c.selector) errorer.current?.crumb(\"click\", c.label || c.selector);\n replayer.current?.click(c, raged);\n if (!heatmaps) return;\n const props = { x: c.x, y: c.y, vw: c.vw, vh: c.vh, docH: c.docH, selector: c.selector, label: c.label, dead: !c.interactive };\n record(\"$click\", props);\n if (raged) record(\"$rageclick\", props);\n };\n document.addEventListener(\"click\", onClick);\n return () => document.removeEventListener(\"click\", onClick);\n }, [track, record, heatmaps]);\n\n // Scroll depth for Heatmaps: the deepest point seen on each page, sent when the page changes or hides.\n const depth = useRef<{ url: string; max: number; docH: number } | null>(null);\n useEffect(() => {\n if (!heatmaps || !tracking || embedded) return;\n const send = () => {\n const d = depth.current;\n if (d && d.max > 0) record(\"$scroll\", { depth: d.max, docH: d.docH, vw: window.innerWidth, vh: window.innerHeight }, Date.now(), d.url);\n depth.current = null;\n };\n const measure = () => {\n const doc = document.documentElement;\n const docH = Math.max(doc.scrollHeight, document.body?.scrollHeight ?? 0);\n const max = seenDepth();\n const href = window.location.href;\n if (depth.current?.url !== href) depth.current = { url: href, max, docH };\n else if (max > depth.current.max) depth.current = { url: href, max, docH };\n };\n measure();\n let frame = 0;\n const onScroll = () => {\n if (frame) return;\n frame = window.requestAnimationFrame(() => {\n frame = 0;\n measure();\n });\n };\n const onHide = () => {\n send();\n flush(true);\n };\n window.addEventListener(\"scroll\", onScroll, { passive: true });\n window.addEventListener(\"pagehide\", onHide);\n return () => {\n window.removeEventListener(\"scroll\", onScroll);\n window.removeEventListener(\"pagehide\", onHide);\n window.cancelAnimationFrame(frame);\n send();\n };\n }, [heatmaps, tracking, embedded, pathname, record, flush]);\n\n // Session recording: only with the visitor's replay consent, while tracking, and when the product records. The\n // recorder and rrweb are loaded here, lazily; withdrawing consent stops it and drops what was not sent.\n const replayConfig = config?.replay;\n const recording = tracking && replayConsent && !!replayConfig && !!apiKey;\n useEffect(() => {\n if (!recording || !replayConfig) return;\n let active = true;\n let handle: ReplayHandle | null = null;\n // `typeof window` is a build-time constant in Next.js: on the server this folds to null and the import (with\n // rrweb) never enters the server bundle.\n void (typeof window === \"undefined\" ? Promise.resolve(null) : import(\"./replay\"))\n .then((m) =>\n m?.startReplay({\n host,\n apiKey,\n sessionId: touchSession(live.current.persist),\n distinctId: live.current.sendId,\n identified: live.current.identified,\n sampleRate: replayConfig.sampleRate,\n warn: warnOnce,\n }),\n )\n .then((h) => {\n if (!active) h?.stop(true);\n else replayer.current = handle = h ?? null;\n })\n .catch(() => warnOnce(\"Session recording could not start (the recorder did not load).\"));\n return () => {\n active = false;\n handle?.stop(true);\n if (replayer.current === handle) replayer.current = null;\n };\n }, [recording, replayConfig, host, apiKey]);\n\n // The flows follow the config and the person: their messages and onboarding progress load once both are known.\n useEffect(() => {\n if (!ready || !visitor || embedded) return;\n flows.setConfig(config);\n void flows.refresh();\n }, [flows, ready, visitor, embedded, config, identified, tracking, effectiveConsent]);\n\n // The dialogs load the first time something is about to show (a dynamic import), and stay mounted after.\n const look = useRef(appearance);\n look.current = appearance;\n useEffect(() => {\n if (embedded) return;\n let unmount: (() => void) | null = null;\n let loading = false;\n let gone = false;\n const show = () => {\n if (unmount || loading || !flows.view()) return;\n loading = true;\n void (typeof window === \"undefined\" ? Promise.resolve(null) : import(\"./flows-ui\"))\n .then((m) => {\n if (!m || gone) return;\n unmount = m.mountFlows(flows, look.current);\n })\n .catch(() => warnOnce(\"The cancel flow and onboarding dialogs did not load.\"))\n .finally(() => {\n loading = false;\n });\n };\n const off = flows.subscribe(show);\n show();\n return () => {\n gone = true;\n off();\n unmount?.();\n };\n }, [flows, embedded]);\n\n const openCancelFlow = useCallback((options?: CancelFlowOptions) => flows.openCancelFlow(options), [flows]);\n const startOnboarding = useCallback((id?: string) => flows.startOnboarding(id), [flows]);\n\n // Web push (push-web.ts, a dynamic import on the first call). The permission is asked here, synchronously inside the\n // click that called it: Safari refuses one asked after an await.\n const subscribeToPush = useCallback(\n (options?: WebPushOptions): Promise<PushResult> => {\n if (typeof window === \"undefined\") return Promise.resolve({ status: \"unsupported\" });\n const now = live.current;\n const distinctId = now.tracking && now.identified ? now.distinctId : undefined;\n if (!distinctId) return Promise.resolve({ status: \"not-signed-in\" });\n const N = window.Notification;\n const permission = Promise.resolve(N && N.permission === \"default\" && options?.ask !== false ? N.requestPermission() : N?.permission);\n return import(\"./push-web\").then((m) => m.subscribeWebPush({ host, apiKey, distinctId, permission }, options));\n },\n [host, apiKey],\n );\n const unsubscribeFromPush = useCallback(\n () =>\n typeof window === \"undefined\"\n ? Promise.resolve(false)\n : import(\"./push-web\").then((m) => m.unsubscribeWebPush({ host, apiKey, distinctId: live.current.identified ? live.current.distinctId : undefined })),\n [host, apiKey],\n );\n\n const texts = useMemo(() => textChanges(config, distinctId, preview), [config, distinctId, preview]);\n\n const value = useMemo<CockpitContext>(\n () => ({\n apiKey,\n host,\n user,\n ready,\n distinctId,\n config,\n preview,\n embedded,\n consent,\n effectiveConsent,\n replayConsent,\n setConsent,\n texts,\n track,\n identify,\n expose,\n captureError,\n openCancelFlow,\n startOnboarding,\n subscribeToPush,\n unsubscribeFromPush,\n }),\n [\n apiKey,\n host,\n user,\n ready,\n distinctId,\n config,\n preview,\n embedded,\n consent,\n effectiveConsent,\n replayConsent,\n setConsent,\n texts,\n track,\n identify,\n expose,\n captureError,\n openCancelFlow,\n startOnboarding,\n subscribeToPush,\n unsubscribeFromPush,\n ],\n );\n return (\n <Ctx.Provider value={value}>\n {children}\n {surveys ? <Survey /> : null}\n </Ctx.Provider>\n );\n};\n\n/**\n * `track`, `identify`, `captureError`, the consent mode, the replay consent and their setter, the visitor id and whether\n * the experiments and flags have loaded. `setConsent(\"cookies\")` sets the mode, `setConsent({ replay: true })` the\n * replay consent.\n */\nexport const useCockpit = () => {\n const { track, identify, captureError, distinctId, ready, embedded, consent, replayConsent, setConsent, openCancelFlow, startOnboarding } = useCtx();\n return { track, identify, captureError, distinctId, ready, embedded, consent, replay: replayConsent, setConsent, openCancelFlow, startOnboarding };\n};\n\n/**\n * Push notifications from your Lifecycle journeys for the signed-in person (`identify` first). Call `subscribe()` from\n * a click: it asks the browser's permission and signs this browser up (your site hosts `/mrrocket-sw.js`). Call\n * `unsubscribe()` on sign-out. Resolves with `{ status: \"subscribed\" | \"denied\" | \"not-asked\" | \"unsupported\" |\n * \"not-signed-in\" | \"error\" }`.\n *\n * const push = usePush();\n * <button onClick={() => push.subscribe()}>Turn on notifications</button>\n */\nexport const usePush = (): { subscribe: (options?: WebPushOptions) => Promise<PushResult>; unsubscribe: () => Promise<boolean> } => {\n const { subscribeToPush, unsubscribeFromPush } = useCtx();\n return useMemo(() => ({ subscribe: subscribeToPush, unsubscribe: unsubscribeFromPush }), [subscribeToPush, unsubscribeFromPush]);\n};\n\n/**\n * A feature flag from MRRocket › Build › Feature flags: true while it is on for this visitor (its audience and rollout\n * in Production), false while it is off, unknown, or the flags have not loaded yet (`useCockpit().ready`). The person's\n * properties from `identify(id, props)` feed the audience conditions (\"Email\", \"Plan\" …).\n *\n * const newCheckout = useFlag(\"new-checkout\");\n */\nexport const useFlag = (key: string): boolean => useFlagValue(key) !== false;\n\n/** The variant of a multivariate flag for this visitor (\"control\", \"test\" …), or null while the flag is off. */\nexport const useFlagVariant = (key: string): string | null => {\n const v = useFlagValue(key);\n return typeof v === \"string\" ? v : null;\n};\n\nconst useFlagValue = (key: string) => {\n const { config, distinctId, user } = useCtx();\n return useMemo(() => flagFor(key, config, distinctId, { ...user }), [key, config, distinctId, user]);\n};\n\n/** The variant this visitor sees, for example `\"control\"` or `\"a\"`. Records the exposure. */\nexport const useVariant = (key: string): VariantId => {\n const { config, distinctId, preview, expose } = useCtx();\n const variant = resolveVariant(key, config, distinctId, preview);\n useEffect(() => {\n if (config || preview[key]) expose(key, variant);\n }, [config, preview, key, variant, expose]);\n return variant;\n};\n\n/** Renders the element for the visitor's variant; control when the variant has no element. */\nexport const Experiment = ({ name, variants }: { name: string; variants: Record<VariantId, ReactNode> & { control: ReactNode } }) => {\n const variant = useVariant(name);\n return <>{variants[variant] ?? variants.control}</>;\n};\n\n/**\n * A text that experiments may change without a deploy: Cockpit sends the new copy for `id` and this renders it.\n * Write your default as the children.\n */\nexport const Text = ({ id, children }: { id: string; children: string }) => {\n const { texts, config, distinctId, preview, expose } = useCtx();\n // Showing a text a running test changes is an exposure to that test, whichever variant the visitor has.\n useEffect(() => {\n for (const key of experimentsOfText(config, id)) expose(key, resolveVariant(key, config, distinctId, preview));\n }, [config, id, distinctId, preview, expose]);\n return <>{texts[id] ?? children}</>;\n};\n\n/**\n * The cancel flow you built in MRRocket › Churn › Cancel flow. Call `open` from your Cancel button: it shows the flow\n * and resolves with what the customer did. MRRocket never changes the subscription; your `onCancel` and `onSave` do.\n *\n * const cancelFlow = useCancelFlow();\n * <button onClick={() => cancelFlow.open({ customer: \"business\", onCancel: cancelSubscription, onSave: applyOffer })}>\n */\nexport const useCancelFlow = (): { open: (options?: CancelFlowOptions) => Promise<CancelFlowResult> } => {\n const { openCancelFlow } = useCtx();\n return useMemo(() => ({ open: openCancelFlow }), [openCancelFlow]);\n};\n"],"mappings":";;;AAEA,SAAyB,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAClF,SAAS,mBAAmB;AAC5B,SAAS,KAA4C,cAAc;AACnE,SAAS,QAAQ,8BAA8B;AAC/C,SAAS,cAAc,WAAW,iBAAiB;AAEnD,SAA4B,yBAAyB;AACrD;AAAA,EAEI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP;AAAA,EAKI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAS,cAAc;AACvB,SAAS,QAAQ,cAAc,WAAW,MAAM,eAAe,cAAc,WAAW,mBAAmB;AAC3G,SAA8E,mBAAmB;AACjG,SAAS,mBAAmB;AAE5B,SAAS,oBAAoB,mBAAmB;AAqoBxC,SAgEG,UA9DY,KAFf;AAloBR,IAAM,SAAS,oBAAI,IAAY;AAC/B,IAAM,WAAW,CAAC,YAAoB;AAClC,MAA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AAwC;AACxE,QAAM,EAAE,OAAO,QAAQ,YAAY,SAAS,OAAO,IAAI,OAAO;AAE9D,YAAU,MAAM;AACZ,eAAW,OAAO,kBAAkB,QAAQ,EAAE,EAAG,QAAO,KAAK,eAAe,KAAK,QAAQ,YAAY,OAAO,CAAC;AAAA,EACjH,GAAG,CAAC,QAAQ,IAAI,YAAY,SAAS,MAAM,CAAC;AAC5C,SAAO,gCAAG,gBAAM,EAAE,KAAK,UAAS;AACpC;AASO,IAAM,gBAAgB,MAA4E;AACrG,QAAM,EAAE,eAAe,IAAI,OAAO;AAClC,SAAO,QAAQ,OAAO,EAAE,MAAM,eAAe,IAAI,CAAC,cAAc,CAAC;AACrE;","names":["live","r","distinctId"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.tsx"],"sourcesContent":["\"use client\";\n\nimport { type ReactNode, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport { Ctx, type CockpitContext, type CockpitUser, useCtx } from \"./context\";\nimport { Survey, forgetStoredDismissals } from \"./survey\";\nimport { RageDetector, clickInfo, seenDepth } from \"./capture\";\nimport type { ReplayHandle } from \"./replay\";\nimport { type ErrorCapture, startErrorCapture } from \"./errors\";\nimport {\n type AttributionMode,\n DEFAULT_REFERRAL_DAYS,\n captureReferral,\n carriesReferral,\n forgetStoredReferral,\n getReferral,\n resetReferral,\n storeReferral,\n} from \"./referral\";\nimport {\n type CockpitConfig,\n type CockpitEvent,\n type ConsentChoice,\n type ConsentMode,\n EMBED_PARAM,\n EXPOSURE_PARAM,\n ID_COOKIE,\n PREVIEW_PARAM,\n SDK_VERSION,\n SESSION_COOKIE,\n type VariantId,\n envKey,\n experimentsOfText,\n exposureFrom,\n flagFor,\n parsePreview,\n redirectFor,\n resolveHost,\n resolveVariant,\n textChanges,\n} from \"./core\";\nimport type { PushResult, WebPushOptions } from \"./push-web\";\nimport { bodies } from \"./batch\";\nimport { YEAR_S, deleteCookie, enterPage, page, privacySignal, touchSession, visitorId, writeCookie } from \"./web-state\";\nimport { type CancelFlowOptions, type CancelFlowResult, type FlowsController, createFlows } from \"./flows\";\nimport { startPicker } from \"./pick\";\nimport type { FlowsTheme } from \"./flows-ui\";\nimport { forgetFlowsStorage, webFlowsEnv } from \"./flows-web\";\n\n/** Tells the developer once, in the browser console, why the SDK is not reaching MRRocket (a wrong host or key is the usual cause). */\nconst warned = new Set<string>();\nconst warnOnce = (message: string) => {\n if (warned.has(message)) return;\n warned.add(message);\n console.warn(`[MRRocket] ${message}`);\n};\n\nexport interface CockpitProviderProps {\n /** The product's public key from Cockpit › Settings › SDK. Safe in the browser. Default: `NEXT_PUBLIC_MRROCKET_KEY`. */\n apiKey?: string;\n /** Where MRRocket runs, like `https://app.example.com`. Default: `NEXT_PUBLIC_MRROCKET_HOST`, else the page's own origin. */\n host?: string;\n preview?: Record<string, VariantId>;\n embedded?: boolean;\n /** Config fetched on the server, to render the right variant on the first paint. */\n config?: CockpitConfig;\n /** Your own id for this visitor, for example a signed-in user id. Keeps variants stable without cookies. */\n distinctId?: string;\n /**\n * \"cookieless\" (default) stores nothing in the browser, \"cookies\" keeps a visitor cookie for a year, \"off\" sends\n * nothing. The SDK does not remember the choice: set it on every page load, from the prop or setConsent().\n */\n consent?: ConsentMode;\n /** Send nothing when the browser asks not to be tracked (Do Not Track or Global Privacy Control). */\n respectDnt?: boolean;\n /**\n * The visitor's consent to session recordings, separate from analytics (default false). Recording also needs the\n * product to record (Cockpit › Sessions) and analytics not \"off\". Without it nothing is recorded or buffered.\n * Change it later with `setConsent({ replay })`.\n */\n replay?: boolean;\n /**\n * Clicks and scroll depth for Heatmaps (default true): where a click landed, a short selector and a link's or\n * button's label, never typed text. Sent under the normal analytics consent as `$click`, `$rageclick` and `$scroll`.\n */\n heatmaps?: boolean;\n /** Ask visitors the surveys you run in Cockpit. Set false to switch them off. */\n surveys?: boolean;\n /**\n * Error tracking for Build › Errors (default true): uncaught errors and unhandled promise rejections, with the page\n * and the last pages and clicks, under the normal analytics consent. Report errors you catch with\n * `useCockpit().captureError(error)`.\n */\n errors?: boolean;\n /** Your release (a version or a commit), so MRRocket can tell which release an error came with. */\n release?: string;\n /**\n * Affiliate referrals (`?ref=` links and MRRocket's tracked links). \"consent\" (default): stored in the first-party\n * `mrr_ref` cookie only while consent is \"cookies\", in memory otherwise. \"always\": stored whatever the consent (only\n * where your legal basis allows it). \"off\": referrals are ignored.\n */\n attribution?: AttributionMode;\n /** The query parameter of direct partner links, default `ref` (`https://your.site/?ref=maya`). */\n referralParam?: string;\n /**\n * Onboarding flows start on their own when the visitor does their trigger (default true). False: only\n * `useCockpit().startOnboarding()` starts one. In-app messages and `openCancelFlow` work either way.\n */\n onboarding?: boolean;\n /** The look of the cancel flow, onboarding and message dialogs: `{ theme: \"dark\", accent: \"#0f766e\", className }`. */\n appearance?: FlowsTheme;\n /**\n * Form leads (0.12.0): a submitted form marked `data-mrrocket-form` becomes a contact in MRRocket (default true).\n * \"auto\" also captures any form with an email field (never one with a password field); false captures none. Only\n * the email, the name and the other fields a person typed go out, never passwords, card or hidden fields (forms.ts).\n */\n forms?: boolean | \"auto\";\n children: ReactNode;\n}\n\n/**\n * Put it once around your app, in `app/layout.tsx`. It loads your experiments, keeps each visitor in one variant,\n * records page views and sends your events to Cockpit in small batches.\n *\n * `preview` forces variants for this render, for example from the `ck_preview` search param on the server,\n * so a Cockpit preview never flickers. Without it the provider reads the param itself after the first render.\n */\nexport const CockpitProvider = ({\n apiKey: apiKeyProp,\n host: hostProp,\n preview: forced,\n embedded: embeddedProp,\n config: bootstrapConfig,\n distinctId: bootstrapId,\n consent: consentProp = \"cookieless\",\n respectDnt = false,\n replay: replayProp = false,\n heatmaps = true,\n surveys = true,\n errors = true,\n release,\n attribution = \"consent\",\n referralParam = \"ref\",\n onboarding = true,\n appearance,\n forms = true,\n children,\n}: CockpitProviderProps) => {\n const pathname = usePathname();\n const apiKey = apiKeyProp ?? envKey() ?? \"\";\n const host = resolveHost(hostProp);\n const [config, setConfig] = useState<CockpitConfig | null>(bootstrapConfig ?? null);\n const [consent, setConsentState] = useState<ConsentMode>(consentProp);\n const [replayConsent, setReplayConsent] = useState(replayProp);\n const [mounted, setMounted] = useState(false);\n const [dnt, setDnt] = useState(false);\n // The visitor id and the consent mode it was made for; null until the browser has been read.\n const [visitor, setVisitor] = useState<{ mode: ConsentMode; id: string } | null>(null);\n const [identified, setIdentified] = useState<string | undefined>();\n const [urlPreview, setUrlPreview] = useState<Record<string, VariantId>>({});\n const [urlEmbedded, setUrlEmbedded] = useState(false);\n const [user, setUser] = useState<CockpitUser | undefined>();\n const [ready, setReady] = useState(!!bootstrapConfig);\n const queue = useRef<CockpitEvent[]>([]);\n // Calls from before the visitor was known (a child's effect runs before ours); replayed once it is.\n const early = useRef<(() => void)[]>([]);\n const exposed = useRef(new Set<string>());\n const lastPage = useRef<string | null>(null);\n\n const bootstrap = bootstrapId && bootstrapId !== \"anonymous\" ? bootstrapId : undefined;\n const preview = useMemo(() => ({ ...urlPreview, ...forced }), [urlPreview, forced]);\n const embedded = embeddedProp ?? urlEmbedded;\n const effectiveConsent: ConsentMode = respectDnt && dnt ? \"off\" : consent;\n const distinctId = identified ?? bootstrap ?? visitor?.id ?? \"anonymous\";\n const tracking = !embedded && effectiveConsent !== \"off\" && visitor?.mode === effectiveConsent;\n // Without cookies, events carry an id only after identify(); the server counts everyone else by its daily hash.\n const sendId = effectiveConsent === \"cookies\" ? distinctId : identified;\n\n // Preview flags and the browser's privacy signal, once, in the browser.\n useEffect(() => {\n const params = new URLSearchParams(window.location.search);\n setUrlPreview(parsePreview(params.get(PREVIEW_PARAM)));\n setUrlEmbedded(params.get(EMBED_PARAM) === \"1\");\n setDnt(privacySignal());\n setMounted(true);\n // Opened by MRRocket's onboarding editor to pick an element for a tour step (./pick.ts); only then, only in a frame.\n return params.get(EMBED_PARAM) === \"1\" ? (startPicker() ?? undefined) : undefined;\n }, []);\n\n const setConsent = useCallback((choice: ConsentChoice) => {\n const { analytics: mode, replay } = typeof choice === \"string\" ? { analytics: choice, replay: undefined } : choice;\n if (mode === \"off\") queue.current.length = 0;\n if (mode) setConsentState(mode);\n if (typeof replay === \"boolean\") setReplayConsent(replay);\n }, []);\n\n // Follow the `consent` and `replay` props when they change; setConsent() calls in between stay until they do.\n const lastProp = useRef(consentProp);\n useEffect(() => {\n if (lastProp.current === consentProp) return;\n lastProp.current = consentProp;\n setConsent(consentProp);\n }, [consentProp, setConsent]);\n const lastReplayProp = useRef(replayProp);\n useEffect(() => {\n if (lastReplayProp.current === replayProp) return;\n lastReplayProp.current = replayProp;\n setConsent({ replay: replayProp });\n }, [replayProp, setConsent]);\n\n // Storage follows consent. Leaving \"cookies\" deletes what the SDK stored; this page keeps its id in memory.\n const storedFor = useRef<ConsentMode | null>(null);\n useEffect(() => {\n if (!mounted) return;\n const before = storedFor.current;\n storedFor.current = effectiveConsent;\n if (before === \"cookies\" && effectiveConsent !== \"cookies\") {\n deleteCookie(ID_COOKIE);\n deleteCookie(SESSION_COOKIE);\n forgetStoredDismissals();\n forgetFlowsStorage();\n }\n if (effectiveConsent === \"off\") {\n queue.current.length = 0;\n page.session = undefined;\n }\n setVisitor({ mode: effectiveConsent, id: visitorId(effectiveConsent, !bootstrap) });\n }, [mounted, effectiveConsent, bootstrap]);\n\n // Experiments for this key. Without a key or when MRRocket is unreachable the page keeps control and carries on.\n useEffect(() => {\n if (!apiKey) warnOnce(\"No public key. Pass apiKey or set NEXT_PUBLIC_MRROCKET_KEY; nothing is tracked until then.\");\n if (bootstrapConfig || !apiKey) {\n setReady(true);\n return;\n }\n let live = true;\n fetch(`${host}/api/sdk/config?key=${encodeURIComponent(apiKey)}`)\n .then((r) => {\n if (!r.ok) warnOnce(`Config request to ${host || \"this origin\"} answered ${r.status}. Check the public key and NEXT_PUBLIC_MRROCKET_HOST.`);\n return r.ok ? r.json() : null;\n })\n .then((c: CockpitConfig | null) => {\n if (!live) return;\n if (c && Array.isArray(c.experiments)) setConfig(c);\n setReady(true);\n })\n .catch(() => {\n warnOnce(`Could not reach ${host || \"this origin\"}. Check NEXT_PUBLIC_MRROCKET_HOST. The page keeps working with control variants.`);\n if (live) setReady(true);\n });\n return () => {\n live = false;\n };\n }, [apiKey, host, bootstrapConfig]);\n\n const flush = useCallback(\n (beacon = false) => {\n if (!queue.current.length) return;\n if (!apiKey) {\n queue.current.length = 0;\n return;\n }\n const url = `${host}/api/sdk/events`;\n for (const body of bodies(apiKey, queue.current.splice(0), { v: SDK_VERSION, errors })) {\n const sent = beacon && typeof navigator !== \"undefined\" && \"sendBeacon\" in navigator && navigator.sendBeacon(url, body);\n if (!sent)\n fetch(url, { method: \"POST\", headers: { \"content-type\": \"application/json\" }, body, keepalive: true })\n .then((r) => {\n if (!r.ok) warnOnce(`Events were rejected with ${r.status}. Check the public key (Settings › SDK) and NEXT_PUBLIC_MRROCKET_HOST.`);\n })\n .catch(() => warnOnce(`Could not reach ${host || \"this origin\"} to send events. Check NEXT_PUBLIC_MRROCKET_HOST.`));\n }\n },\n [apiKey, host, errors],\n );\n\n useEffect(() => {\n const timer = window.setInterval(() => flush(), 2000);\n const leave = () => flush(true);\n window.addEventListener(\"pagehide\", leave);\n return () => {\n window.clearInterval(timer);\n window.removeEventListener(\"pagehide\", leave);\n flush(true);\n };\n }, [flush]);\n\n // The latest values for callbacks that must not change identity, so effects that use them run once.\n const live = useRef({ resolved: false, tracking, distinctId, sendId, persist: false, identified: false });\n live.current = { resolved: visitor !== null, tracking, distinctId, sendId, persist: visitor?.mode === \"cookies\", identified: !!identified };\n\n const record = useCallback((event: string, props: Record<string, unknown> | undefined, ts = Date.now(), url?: string) => {\n const now = live.current;\n if (!now.resolved) {\n early.current.push(() => record(event, props, ts, url));\n return;\n }\n // Previews in Cockpit never count, and nothing is sent without consent.\n if (!now.tracking) return;\n const referral = carriesReferral(event) ? getReferral() : null;\n queue.current.push({\n event,\n props: referral ? { ...props, $referral: { code: referral.code, clickId: referral.clickId } } : props,\n distinctId: now.sendId,\n sessionId: touchSession(now.persist),\n ts,\n url: url ?? window.location.href,\n referrer: page.referrer,\n ...page.utm,\n screen: { w: window.screen.width, h: window.screen.height },\n });\n }, []);\n\n // The running recorder, if this visit records (see the recording effect below).\n const replayer = useRef<ReplayHandle | null>(null);\n // Error tracking, while `errors` is on (see the effect below).\n const errorer = useRef<ErrorCapture | null>(null);\n\n // The cancel flow, onboarding and in-app messages (flows.ts): one controller for the provider's lifetime.\n const flowsRef = useRef<FlowsController | null>(null);\n const flows = (flowsRef.current ??= createFlows(\n webFlowsEnv({\n host,\n apiKey,\n track: (event, props) => record(event, props),\n personId: () => (live.current.tracking && live.current.identified ? live.current.distinctId : undefined),\n canStore: () => live.current.persist,\n auto: onboarding,\n }),\n ));\n\n const track = useCallback(\n (event: string, props?: Record<string, unknown>) => {\n record(event, props);\n if (live.current.tracking) replayer.current?.event(event);\n flows.onEvent(event);\n },\n [record, flows],\n );\n\n const identify = useCallback(\n (id: string, props?: Record<string, unknown>) => {\n const now = live.current;\n if (!now.resolved) {\n early.current.push(() => identify(id, props));\n return;\n }\n const previous = now.sendId;\n // From here on events carry this id in every mode; only \"cookies\" keeps it for the next visit.\n live.current = { ...now, distinctId: id, sendId: id, identified: true };\n record(\"$identify\", { ...props, id, ...(previous && previous !== id ? { previousId: previous } : {}) });\n replayer.current?.identify(id);\n if (now.persist) writeCookie(ID_COOKIE, id, YEAR_S);\n setIdentified(id);\n setUser({ id, ...(props as Omit<CockpitUser, \"id\">) });\n },\n [record],\n );\n\n // Form leads (forms.ts, a dynamic import): one submit listener on the document while `forms` is on.\n const identifyRef = useRef(identify);\n identifyRef.current = identify;\n useEffect(() => {\n if (!forms || !apiKey || embedded || typeof window === \"undefined\") return;\n let off: (() => void) | undefined;\n let gone = false;\n void import(\"./forms\")\n .then((m) => {\n if (gone) return;\n off = m.watchForms({\n host,\n apiKey,\n auto: forms === \"auto\",\n distinctId: () => (live.current.tracking ? live.current.sendId : undefined),\n identified: () => live.current.identified,\n identify: (id, props) => identifyRef.current(id, props),\n tracking: () => live.current.tracking,\n referrer: () => page.referrer,\n utm: () => page.utm,\n });\n })\n .catch(() => undefined);\n return () => {\n gone = true;\n off?.();\n };\n }, [forms, apiKey, host, embedded]);\n\n // Replay what came in before the visitor was known: sent when tracking is on, dropped when it is not.\n useEffect(() => {\n if (!visitor) return;\n for (const run of early.current.splice(0)) run();\n }, [visitor]);\n\n // Affiliate referrals: read once the consent is known and the program's cookie days have loaded.\n const referralDays = config?.referral?.cookieDays ?? DEFAULT_REFERRAL_DAYS;\n const storeReferrals = attribution === \"always\" ? effectiveConsent !== \"off\" : attribution === \"consent\" && effectiveConsent === \"cookies\";\n const captured = useRef<string | null>(null);\n const storedReferral = useRef(false);\n useEffect(() => {\n if (!visitor || !ready || embedded) return;\n if (attribution === \"off\" || effectiveConsent === \"off\") {\n resetReferral();\n if (attribution === \"off\" || storedReferral.current) forgetStoredReferral();\n return;\n }\n const href = window.location.href;\n if (captured.current === href) return;\n captured.current = href;\n void captureReferral({\n search: window.location.search,\n param: referralParam,\n store: storeReferrals,\n days: referralDays,\n beacon: apiKey\n ? ({ code, clickId }) =>\n fetch(`${host}/api/sdk/affiliate/click`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ key: apiKey, code, clickId, url: href, referrer: document.referrer || undefined }),\n keepalive: true,\n })\n .then((r) => (r.ok ? (r.json() as Promise<{ clickId?: string | null }>) : null))\n .then((b) => b?.clickId ?? null)\n : undefined,\n });\n }, [visitor, ready, embedded, attribution, effectiveConsent, pathname, referralParam, storeReferrals, referralDays, apiKey, host]);\n\n // Consent given later keeps this page load's referral; consent withdrawn deletes what was stored.\n useEffect(() => {\n if (!mounted) return;\n const r = getReferral();\n if (storeReferrals && r) storeReferral(r, referralDays);\n else if (!storeReferrals && storedReferral.current) forgetStoredReferral();\n storedReferral.current = storeReferrals;\n }, [mounted, storeReferrals, referralDays]);\n\n // `tracking` is a dependency so that variants seen before consent are recorded once tracking starts.\n const expose = useCallback(\n (key: string, variant: VariantId) => {\n if (!tracking) return;\n const mark = `${pathname}|${key}`;\n if (exposed.current.has(mark)) return;\n exposed.current.add(mark);\n track(\"$exposure\", { experiment: key, variant });\n },\n [pathname, track, tracking],\n );\n\n // Redirects, once per page: a page redirect or a redirect test's variant sends the visitor on as soon as the config is\n // known (`experimentRedirect` in proxy.ts does it before the page renders, without a flash). A redirect test's\n // control stays and is recorded here; the page a variant lands on records it from `ck_x`, then drops the parameter.\n const decided = useRef<{ path: string; r: ReturnType<typeof redirectFor> } | null>(null);\n const arrived = useRef<string | null | undefined>(undefined);\n useEffect(() => {\n if (!ready || !visitor) return;\n if (decided.current?.path !== pathname) {\n const r = redirectFor(config, window.location.href, distinctId, preview);\n decided.current = { path: pathname, r };\n if (r?.to) {\n flush(true);\n window.location.replace(r.to);\n return;\n }\n }\n if (arrived.current === undefined) {\n const params = new URLSearchParams(window.location.search);\n arrived.current = params.get(EXPOSURE_PARAM);\n if (arrived.current !== null) {\n params.delete(EXPOSURE_PARAM);\n const q = params.toString();\n window.history.replaceState(window.history.state, \"\", `${window.location.pathname}${q ? `?${q}` : \"\"}${window.location.hash}`);\n }\n }\n if (!tracking) return;\n const r = decided.current.r;\n if (r?.experiment && !r.to) expose(r.experiment, r.variant!);\n const x = exposureFrom(config, arrived.current);\n if (x) expose(x.experiment, x.variant);\n arrived.current = null;\n }, [ready, visitor, pathname, config, distinctId, preview, tracking, expose, flush]);\n\n // The referrer and campaign of each page; before the page view below, so it already carries them.\n useEffect(() => {\n enterPage();\n replayer.current?.page(pathname);\n errorer.current?.crumb(\"navigation\", pathname);\n }, [pathname]);\n\n // Errors of the page for Build › Errors; sent only while tracking (consent, not a preview), like events.\n useEffect(() => {\n if (!errors || !apiKey || embedded) return;\n const capture = startErrorCapture({\n host,\n apiKey,\n release,\n context: () => ({ send: live.current.tracking, distinctId: live.current.sendId, sessionId: page.session?.id }),\n warn: warnOnce,\n });\n errorer.current = capture;\n capture.crumb(\"navigation\", window.location.pathname);\n return () => {\n capture.stop();\n if (errorer.current === capture) errorer.current = null;\n };\n }, [errors, apiKey, host, release, embedded]);\n\n const captureError = useCallback((error: unknown) => errorer.current?.capture(error, \"manual\"), []);\n\n // One page view per route change while tracking, so a later setConsent() records the current page right away\n // (a ref keeps React's dev double-run from counting twice).\n useEffect(() => {\n if (!tracking || lastPage.current === pathname) return;\n lastPage.current = pathname;\n // Exposures are remembered per path (\"/pricing|test\"), so nothing needs clearing here.\n track(\"$pageview\", { path: pathname });\n }, [pathname, tracking, track]);\n\n // Clicks on anything marked `data-ck-goal=\"signup_started\"` count as that goal. Every click also feeds Heatmaps\n // (`$click`, `$rageclick` on the third quick click on one spot) and, when this visit records, the recording.\n const rage = useRef(new RageDetector());\n useEffect(() => {\n const onClick = (e: MouseEvent) => {\n const el = (e.target as HTMLElement | null)?.closest<HTMLElement>(\"[data-ck-goal]\");\n if (el?.dataset.ckGoal) track(el.dataset.ckGoal, { text: el.textContent?.trim().slice(0, 80) });\n if (!live.current.tracking) return;\n const c = clickInfo(e);\n if (!c) return;\n const raged = rage.current.push(c.x, c.y, Date.now());\n if (c.label || c.selector) errorer.current?.crumb(\"click\", c.label || c.selector);\n replayer.current?.click(c, raged);\n if (!heatmaps) return;\n const props = { x: c.x, y: c.y, vw: c.vw, vh: c.vh, docH: c.docH, selector: c.selector, label: c.label, dead: !c.interactive };\n record(\"$click\", props);\n if (raged) record(\"$rageclick\", props);\n };\n document.addEventListener(\"click\", onClick);\n return () => document.removeEventListener(\"click\", onClick);\n }, [track, record, heatmaps]);\n\n // Scroll depth for Heatmaps: the deepest point seen on each page, sent when the page changes or hides.\n const depth = useRef<{ url: string; max: number; docH: number } | null>(null);\n useEffect(() => {\n if (!heatmaps || !tracking || embedded) return;\n const send = () => {\n const d = depth.current;\n if (d && d.max > 0) record(\"$scroll\", { depth: d.max, docH: d.docH, vw: window.innerWidth, vh: window.innerHeight }, Date.now(), d.url);\n depth.current = null;\n };\n const measure = () => {\n const doc = document.documentElement;\n const docH = Math.max(doc.scrollHeight, document.body?.scrollHeight ?? 0);\n const max = seenDepth();\n const href = window.location.href;\n if (depth.current?.url !== href) depth.current = { url: href, max, docH };\n else if (max > depth.current.max) depth.current = { url: href, max, docH };\n };\n measure();\n let frame = 0;\n const onScroll = () => {\n if (frame) return;\n frame = window.requestAnimationFrame(() => {\n frame = 0;\n measure();\n });\n };\n const onHide = () => {\n send();\n flush(true);\n };\n window.addEventListener(\"scroll\", onScroll, { passive: true });\n window.addEventListener(\"pagehide\", onHide);\n return () => {\n window.removeEventListener(\"scroll\", onScroll);\n window.removeEventListener(\"pagehide\", onHide);\n window.cancelAnimationFrame(frame);\n send();\n };\n }, [heatmaps, tracking, embedded, pathname, record, flush]);\n\n // Session recording: only with the visitor's replay consent, while tracking, and when the product records. The\n // recorder and rrweb are loaded here, lazily; withdrawing consent stops it and drops what was not sent.\n const replayConfig = config?.replay;\n const recording = tracking && replayConsent && !!replayConfig && !!apiKey;\n useEffect(() => {\n if (!recording || !replayConfig) return;\n let active = true;\n let handle: ReplayHandle | null = null;\n // `typeof window` is a build-time constant in Next.js: on the server this folds to null and the import (with\n // rrweb) never enters the server bundle.\n void (typeof window === \"undefined\" ? Promise.resolve(null) : import(\"./replay\"))\n .then((m) =>\n m?.startReplay({\n host,\n apiKey,\n sessionId: touchSession(live.current.persist),\n distinctId: live.current.sendId,\n identified: live.current.identified,\n sampleRate: replayConfig.sampleRate,\n warn: warnOnce,\n }),\n )\n .then((h) => {\n if (!active) h?.stop(true);\n else replayer.current = handle = h ?? null;\n })\n .catch(() => warnOnce(\"Session recording could not start (the recorder did not load).\"));\n return () => {\n active = false;\n handle?.stop(true);\n if (replayer.current === handle) replayer.current = null;\n };\n }, [recording, replayConfig, host, apiKey]);\n\n // The flows follow the config and the person: their messages and onboarding progress load once both are known.\n useEffect(() => {\n if (!ready || !visitor || embedded) return;\n flows.setConfig(config);\n void flows.refresh();\n }, [flows, ready, visitor, embedded, config, identified, tracking, effectiveConsent]);\n\n // The dialogs load the first time something is about to show (a dynamic import), and stay mounted after.\n const look = useRef(appearance);\n look.current = appearance;\n useEffect(() => {\n if (embedded) return;\n let unmount: (() => void) | null = null;\n let loading = false;\n let gone = false;\n const show = () => {\n if (unmount || loading || !flows.view()) return;\n loading = true;\n void (typeof window === \"undefined\" ? Promise.resolve(null) : import(\"./flows-ui\"))\n .then((m) => {\n if (!m || gone) return;\n unmount = m.mountFlows(flows, look.current);\n })\n .catch(() => warnOnce(\"The cancel flow and onboarding dialogs did not load.\"))\n .finally(() => {\n loading = false;\n });\n };\n const off = flows.subscribe(show);\n show();\n return () => {\n gone = true;\n off();\n unmount?.();\n };\n }, [flows, embedded]);\n\n const openCancelFlow = useCallback((options?: CancelFlowOptions) => flows.openCancelFlow(options), [flows]);\n const startOnboarding = useCallback((id?: string) => flows.startOnboarding(id), [flows]);\n\n // Web push (push-web.ts, a dynamic import on the first call). The permission is asked here, synchronously inside the\n // click that called it: Safari refuses one asked after an await.\n const subscribeToPush = useCallback(\n (options?: WebPushOptions): Promise<PushResult> => {\n if (typeof window === \"undefined\") return Promise.resolve({ status: \"unsupported\" });\n const now = live.current;\n const distinctId = now.tracking && now.identified ? now.distinctId : undefined;\n if (!distinctId) return Promise.resolve({ status: \"not-signed-in\" });\n const N = window.Notification;\n const permission = Promise.resolve(N && N.permission === \"default\" && options?.ask !== false ? N.requestPermission() : N?.permission);\n return import(\"./push-web\").then((m) => m.subscribeWebPush({ host, apiKey, distinctId, permission }, options));\n },\n [host, apiKey],\n );\n const unsubscribeFromPush = useCallback(\n () =>\n typeof window === \"undefined\"\n ? Promise.resolve(false)\n : import(\"./push-web\").then((m) => m.unsubscribeWebPush({ host, apiKey, distinctId: live.current.identified ? live.current.distinctId : undefined })),\n [host, apiKey],\n );\n\n const texts = useMemo(() => textChanges(config, distinctId, preview), [config, distinctId, preview]);\n\n const value = useMemo<CockpitContext>(\n () => ({\n apiKey,\n host,\n user,\n ready,\n distinctId,\n config,\n preview,\n embedded,\n consent,\n effectiveConsent,\n replayConsent,\n setConsent,\n texts,\n track,\n identify,\n expose,\n captureError,\n openCancelFlow,\n startOnboarding,\n subscribeToPush,\n unsubscribeFromPush,\n }),\n [\n apiKey,\n host,\n user,\n ready,\n distinctId,\n config,\n preview,\n embedded,\n consent,\n effectiveConsent,\n replayConsent,\n setConsent,\n texts,\n track,\n identify,\n expose,\n captureError,\n openCancelFlow,\n startOnboarding,\n subscribeToPush,\n unsubscribeFromPush,\n ],\n );\n return (\n <Ctx.Provider value={value}>\n {children}\n {surveys ? <Survey /> : null}\n </Ctx.Provider>\n );\n};\n\n/**\n * `track`, `identify`, `captureError`, the consent mode, the replay consent and their setter, the visitor id and whether\n * the experiments and flags have loaded. `setConsent(\"cookies\")` sets the mode, `setConsent({ replay: true })` the\n * replay consent.\n */\nexport const useCockpit = () => {\n const { track, identify, captureError, distinctId, ready, embedded, consent, replayConsent, setConsent, openCancelFlow, startOnboarding } = useCtx();\n return { track, identify, captureError, distinctId, ready, embedded, consent, replay: replayConsent, setConsent, openCancelFlow, startOnboarding };\n};\n\n/**\n * Push notifications from your Lifecycle journeys for the signed-in person (`identify` first). Call `subscribe()` from\n * a click: it asks the browser's permission and signs this browser up (your site hosts `/mrrocket-sw.js`). Call\n * `unsubscribe()` on sign-out. Resolves with `{ status: \"subscribed\" | \"denied\" | \"not-asked\" | \"unsupported\" |\n * \"not-signed-in\" | \"error\" }`.\n *\n * const push = usePush();\n * <button onClick={() => push.subscribe()}>Turn on notifications</button>\n */\nexport const usePush = (): { subscribe: (options?: WebPushOptions) => Promise<PushResult>; unsubscribe: () => Promise<boolean> } => {\n const { subscribeToPush, unsubscribeFromPush } = useCtx();\n return useMemo(() => ({ subscribe: subscribeToPush, unsubscribe: unsubscribeFromPush }), [subscribeToPush, unsubscribeFromPush]);\n};\n\n/**\n * A feature flag from MRRocket › Build › Feature flags: true while it is on for this visitor (its audience and rollout\n * in Production), false while it is off, unknown, or the flags have not loaded yet (`useCockpit().ready`). The person's\n * properties from `identify(id, props)` feed the audience conditions (\"Email\", \"Plan\" …).\n *\n * const newCheckout = useFlag(\"new-checkout\");\n */\nexport const useFlag = (key: string): boolean => useFlagValue(key) !== false;\n\n/** The variant of a multivariate flag for this visitor (\"control\", \"test\" …), or null while the flag is off. */\nexport const useFlagVariant = (key: string): string | null => {\n const v = useFlagValue(key);\n return typeof v === \"string\" ? v : null;\n};\n\nconst useFlagValue = (key: string) => {\n const { config, distinctId, user } = useCtx();\n return useMemo(() => flagFor(key, config, distinctId, { ...user }), [key, config, distinctId, user]);\n};\n\n/** The variant this visitor sees, for example `\"control\"` or `\"a\"`. Records the exposure. */\nexport const useVariant = (key: string): VariantId => {\n const { config, distinctId, preview, expose } = useCtx();\n const variant = resolveVariant(key, config, distinctId, preview);\n useEffect(() => {\n if (config || preview[key]) expose(key, variant);\n }, [config, preview, key, variant, expose]);\n return variant;\n};\n\n/** Renders the element for the visitor's variant; control when the variant has no element. */\nexport const Experiment = ({ name, variants }: { name: string; variants: Record<VariantId, ReactNode> & { control: ReactNode } }) => {\n const variant = useVariant(name);\n return <>{variants[variant] ?? variants.control}</>;\n};\n\n/**\n * A text that experiments may change without a deploy: Cockpit sends the new copy for `id` and this renders it.\n * Write your default as the children.\n */\nexport const Text = ({ id, children }: { id: string; children: string }) => {\n const { texts, config, distinctId, preview, expose } = useCtx();\n // Showing a text a running test changes is an exposure to that test, whichever variant the visitor has.\n useEffect(() => {\n for (const key of experimentsOfText(config, id)) expose(key, resolveVariant(key, config, distinctId, preview));\n }, [config, id, distinctId, preview, expose]);\n return <>{texts[id] ?? children}</>;\n};\n\n/**\n * The cancel flow you built in MRRocket › Churn › Cancel flow. Call `open` from your Cancel button: it shows the flow\n * and resolves with what the customer did. MRRocket never changes the subscription; your `onCancel` and `onSave` do.\n *\n * const cancelFlow = useCancelFlow();\n * <button onClick={() => cancelFlow.open({ customer: \"business\", onCancel: cancelSubscription, onSave: applyOffer })}>\n */\nexport const useCancelFlow = (): { open: (options?: CancelFlowOptions) => Promise<CancelFlowResult> } => {\n const { openCancelFlow } = useCtx();\n return useMemo(() => ({ open: openCancelFlow }), [openCancelFlow]);\n};\n"],"mappings":";;;AAEA,SAAyB,aAAa,WAAW,SAAS,QAAQ,gBAAgB;AAClF,SAAS,mBAAmB;AAC5B,SAAS,KAA4C,cAAc;AACnE,SAAS,QAAQ,8BAA8B;AAC/C,SAAS,cAAc,WAAW,iBAAiB;AAEnD,SAA4B,yBAAyB;AACrD;AAAA,EAEI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP;AAAA,EAKI;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEP,SAAS,cAAc;AACvB,SAAS,QAAQ,cAAc,WAAW,MAAM,eAAe,cAAc,WAAW,mBAAmB;AAC3G,SAA8E,mBAAmB;AACjG,SAAS,mBAAmB;AAE5B,SAAS,oBAAoB,mBAAmB;AAyqBxC,SAgEG,UA9DY,KAFf;AAtqBR,IAAM,SAAS,oBAAI,IAAY;AAC/B,IAAM,WAAW,CAAC,YAAoB;AAClC,MAAI,OAAO,IAAI,OAAO,EAAG;AACzB,SAAO,IAAI,OAAO;AAClB,UAAQ,KAAK,cAAc,OAAO,EAAE;AACxC;AAwEO,IAAM,kBAAkB,CAAC;AAAA,EAC5B,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,SAAS,cAAc;AAAA,EACvB,aAAa;AAAA,EACb,QAAQ,aAAa;AAAA,EACrB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,SAAS;AAAA,EACT;AAAA,EACA,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,aAAa;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