@hermeticor/sdk-cordova 0.4.5 → 0.4.6

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/dist/index.js CHANGED
@@ -16,7 +16,7 @@ export async function createCordovaClient(o) {
16
16
  const { firebase = g.FirebasePlugin, cordovaDevice = g.device, requestPushPermission = false, pushEnvironment = 'release', ...rest } = o;
17
17
  const platform = cordovaDevice?.platform.toLowerCase() === 'ios' ? 'ios' : 'android';
18
18
  const device = { ...(cordovaDevice?.model ? { deviceModel: cordovaDevice.model } : {}), osName: platform, ...(cordovaDevice?.version ? { osVersion: cordovaDevice.version } : {}), ...rest.device };
19
- const hm = createHybridClient({ ...rest, platform, device, sdkVersion: 'cordova-0.4.5' });
19
+ const hm = createHybridClient({ ...rest, platform, device, sdkVersion: 'cordova-0.4.6' });
20
20
  let allowed = false;
21
21
  const send = (token) => {
22
22
  if (!token)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hermeticor/sdk-cordova",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Hermetica for Cordova: events, consent, FCM push tokens, in-app messages",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -38,7 +38,7 @@
38
38
  "typecheck": "tsc -p tsconfig.json --noEmit"
39
39
  },
40
40
  "dependencies": {
41
- "@hermeticor/sdk-browser": "^0.4.5"
41
+ "@hermeticor/sdk-browser": "^0.4.6"
42
42
  },
43
43
  "devDependencies": {
44
44
  "esbuild": "^0.28.2",
package/plugin.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <!-- Lets `cordova plugin add @hermeticor/sdk-cordova` expose the SDK as window.HermeticaCordova (built into www/ by build.mjs). -->
3
- <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="hermetica-cordova" version="0.4.5">
3
+ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="hermetica-cordova" version="0.4.6">
4
4
  <name>Hermeticor</name>
5
5
  <description>Hermeticor SDK for Cordova: events, identity, consent, push tokens and in-app messages.</description>
6
6
  <license>MIT</license>
@@ -1 +1 @@
1
- "use strict";var pe=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var n in t)pe(e,n,{get:t[n],enumerable:!0})},He=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Re(t))!Ve.call(e,a)&&a!==n&&pe(e,a,{get:()=>t[a],enumerable:!(i=ze(t,a))||i.enumerable});return e};var Be=e=>He(pe({},"__esModule",{value:!0}),e);var Lt={};Ke(Lt,{createCordovaClient:()=>Pt});module.exports=Be(Lt);var Fe="a,button,[role=button],[data-hm-capture]",Je=e=>(e.textContent??"").replace(/\s+/g," ").trim().slice(0,60);function We(e,t=document){let n=[],i=o=>{let u=o.target instanceof Element?o.target.closest(Fe):null;if(!u||u.closest("[data-hm-no-capture]"))return;let p={tag:u.tagName.toLowerCase(),id:u.id||void 0,text:Je(u),href:u instanceof HTMLAnchorElement?u.href:void 0,path:location.pathname};e("element_click",p);let s=Date.now();n=[...n.filter(r=>s-r.at<1e3&&r.el===u),{el:u,at:s}],n.length===3&&e("rage_click",p)},a=()=>e("page_leave",{path:location.pathname});return t.addEventListener("click",i,!0),addEventListener("pagehide",a),()=>{t.removeEventListener("click",i,!0),removeEventListener("pagehide",a)}}var Qe=/^https:\/\/(?:www\.youtube(?:-nocookie)?\.com\/embed|player\.vimeo\.com\/video)\/([\w-]+)/,Ye=["video_ended","video_play","video_pause"],se=["play","pause","ended"];function Ge(e,t=document){let n=(s,r)=>e(s,{path:location.pathname,pageId:t.documentElement.dataset.hmPageId,...r}),i=s=>{let r=s.target;!(r instanceof HTMLVideoElement)||r.closest("[data-hm-no-capture]")||s.type==="pause"&&r.ended||n("video_"+s.type,{provider:"html5",src:(r.currentSrc||r.src).slice(0,300),seconds:Math.round(r.currentTime),duration:Math.round(r.duration)||void 0})},a=new Map,o=()=>t.querySelectorAll("iframe").forEach(s=>{let r=s.contentWindow,l=Qe.exec(s.src);if(!r||!l||a.has(r)||s.closest("[data-hm-no-capture]"))return;let b=s.src.includes("youtu");if(b&&!/[?&]enablejsapi=1/.test(s.src))return;a.set(r,{yt:b,id:l[1]});let y=d=>r.postMessage(JSON.stringify(d),new URL(s.src).origin);b?y({event:"listening",id:l[1],channel:"widget"}):se.forEach(d=>y({method:"addEventListener",value:d}))}),u=s=>{let r=s.source&&a.get(s.source);if(!r||!/youtube|vimeo/.test(s.origin))return;let l;try{l=typeof s.data=="string"?JSON.parse(s.data):s.data}catch{return}let b=r.yt?l.event==="onStateChange"?Ye[l.info]:void 0:se.includes(l.event)?"video_"+l.event:void 0;b&&n(b,{provider:r.yt?"youtube":"vimeo",videoId:r.id,seconds:Math.round(l.data?.seconds??0)||void 0})};se.forEach(s=>t.addEventListener(s,i,!0)),addEventListener("message",u),o();let p=new MutationObserver(o);return p.observe(t.documentElement,{childList:!0,subtree:!0}),()=>{se.forEach(s=>t.removeEventListener(s,i,!0)),removeEventListener("message",u),p.disconnect()}}var me=(e,t)=>new RegExp(`^${e.split("*").map(n=>n.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*")}$`).test(t),ge=e=>!!(e.audience?.listIds?.length||e.audience?.segmentIds?.length||e.hideKnownSubscribers||e.countries?.length||e.countriesExclude?.length);function Ze(e,t){if(e.hideKnownSubscribers&&(!t||t.subscriber))return!1;let n=[...(e.audience?.listIds??[]).map(a=>t?.lists[a]),...(e.audience?.segmentIds??[]).map(a=>t?.segments[a])];if(n.length){let a=n.some(o=>o===!0);if((e.audience?.mode??"show")==="show"?!a:a)return!1}let i=a=>a.some(o=>t?.countries[o]===!0);return!(e.countries?.length&&!i(e.countries)||e.countriesExclude?.length&&i(e.countriesExclude))}function Ue(e,t){if(t.submitted||e.frequencyDays!==void 0&&t.lastClosedAt!==void 0&&t.now-t.lastClosedAt<e.frequencyDays*864e5||e.device==="mobile"&&!t.mobile||e.device==="desktop"&&t.mobile||e.visitor==="new"&&t.returning||e.visitor==="returning"&&!t.returning||e.minPageViews&&t.pageViews<e.minPageViews||e.urlExclude?.some(n=>me(n,t.path))||e.urlInclude?.length&&!e.urlInclude.some(n=>me(n,t.path)))return!1;if(e.utm)for(let n of["source","medium","campaign"]){let i=e.utm[n];if(i&&(t.utm?.[n]??"").toLowerCase()!==i.toLowerCase())return!1}if(e.referrerInclude?.length&&!e.referrerInclude.some(n=>me(n.toLowerCase(),(t.referrer??"").toLowerCase())))return!1;if(e.cart){let n=t.cart??{value:0,items:0};if(e.cart.empty===!0&&n.items>0||e.cart.empty===!1&&n.items===0||e.cart.minValue!==void 0&&n.value<e.cart.minValue||e.cart.minItems!==void 0&&n.items<e.cart.minItems)return!1}return!(e.productPage==="only"&&!t.productPage||e.productPage==="never"&&t.productPage||ge(e)&&!Ze(e,t.flags))}function Ae(e){return e.querySelector('meta[property="og:type"][content="product" i], meta[property="og:type"][content="og:product" i], [itemtype*="schema.org/Product"]')?!0:[...e.querySelectorAll('script[type="application/ld+json"]')].some(t=>/"@type"\s*:\s*"Product"/.test(t.textContent??""))}function Xe(e,t,n){let i=[],a=!1,o=()=>{a=!0,i.forEach(r=>r())},u=()=>{a||(o(),n())},p=(r,l,b)=>{r.addEventListener(l,b,{passive:!0}),i.push(()=>r.removeEventListener(l,b))},s=t&&(e.exitIntent||e.inactivitySeconds!==void 0);if(e.delaySeconds===void 0&&e.scrollPercent===void 0&&!e.exitIntent&&e.inactivitySeconds===void 0)return u(),o;if(e.delaySeconds!==void 0){let r=setTimeout(u,e.delaySeconds*1e3);i.push(()=>clearTimeout(r))}if(e.scrollPercent!==void 0&&p(window,"scroll",()=>{(scrollY+innerHeight)/document.documentElement.scrollHeight*100>=e.scrollPercent&&u()}),e.exitIntent&&!t&&p(document,"mouseout",r=>{let l=r;!l.relatedTarget&&l.clientY<=0&&u()}),s){let r,l=()=>{clearTimeout(r),r=setTimeout(u,(e.inactivitySeconds??30)*1e3)};l();for(let b of["touchstart","scroll","keydown"])p(window,b,l);e.exitIntent&&e.mobileBackExit&&(history.pushState({hm:1},""),p(window,"popstate",u)),i.push(()=>clearTimeout(r))}return o}var et=".tab{position:fixed;z-index:2147483000;margin:0;box-shadow:0 2px 12px #0004}.skip{background:none;border:0;color:inherit;text-decoration:underline}.bar{position:fixed;left:0;right:0;z-index:2147483000}.bar.top{top:0}.bar.bottom{bottom:0}.bar .box{max-width:none;border-radius:0;display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:10px 48px 10px 16px}.bar .msg{margin:0}.bar form,.bar fieldset{display:flex;flex-wrap:wrap;align-items:center;gap:8px;flex:1}.bar label{margin:0}.bar button{margin:0}@media(max-width:600px){.bar .box,.bar form,.bar fieldset{flex-direction:column;align-items:stretch}}",ke={left:"left:0;top:50%",right:"right:0;top:50%",bottom:"bottom:0;left:50%",top_left:"top:16px;left:16px",top_right:"top:16px;right:16px",bottom_left:"bottom:16px;left:16px",bottom_right:"bottom:16px;right:16px"},tt=e=>ke[e??"right"]??ke.right,Oe=(e,t)=>e==="popup"||e==="flyout"?t:void 0;function nt(e,t){let n=document.body.style,i=t?"paddingTop":"paddingBottom",a=n[i],o=parseFloat(getComputedStyle(document.body)[i])||0;return n[i]=`${o+e.offsetHeight}px`,()=>{n[i]=a}}var it=/^#[0-9a-f]{3,8}$/i,$e={system:"system-ui,sans-serif",serif:"Georgia,serif",mono:"ui-monospace,monospace"},Se="hm_pv",rt={turnstile:["challenges.cloudflare.com/turnstile/v0","turnstile"],hcaptcha:["js.hcaptcha.com/1","hcaptcha"],recaptcha:["www.google.com/recaptcha","grecaptcha"],friendlycaptcha:["cdn.jsdelivr.net/npm/friendly-challenge@0.9.18","friendlyChallenge"]},be,ot=()=>be,qe,Ie=e=>{be={value:Math.max(0,Number(e.value)||0),items:Math.max(0,Math.floor(Number(e.items)||0))},qe?.()},oe=globalThis,at=e=>[e].flat().filter(t=>t!==void 0&&t!==!1&&t!=="").map(String),st=(e=[],t)=>e.every(n=>{let i=at(t[n.field]);return n.op==="filled"?!!i.length:n.op==="empty"?!i.length:n.op==="neq"?!i.includes(n.value):n.op==="contains"?i.some(a=>a.toLowerCase().includes(n.value.toLowerCase())):i.includes(n.value)});function lt(e){let t=(a,o)=>a&&it.test(a)?a:o,n=t(e?.primary,"#1f6feb"),i=e?.buttonStyle!=="outline";return`:host{all:initial}.box{font:15px/1.5 ${$e[e?.font??"system"]??$e.system};background:${t(e?.background,"#fff")};color:${t(e?.text,"#111")};padding:20px;border-radius:${Math.min(32,Number(e?.radius??8))|0}px;box-shadow:0 4px 24px #0004;max-width:min(92vw,400px);box-sizing:border-box}.pop{position:fixed;inset:0;display:grid;place-items:center;background:#0006;z-index:2147483000}.fly{position:fixed;right:16px;bottom:16px;z-index:2147483000}label{display:block;margin:10px 0}input:not([type=checkbox]):not([type=radio]),select{display:block;width:100%;box-sizing:border-box;padding:8px;margin-top:4px}fieldset{border:0;padding:0;margin:0}button{cursor:pointer;padding:9px 16px;border:2px solid ${n};border-radius:inherit;background:${i?n:"transparent"};color:${i?"#fff":n};margin:8px 8px 0 0}button.x{position:absolute;top:6px;right:10px;border:0;background:none;color:inherit;font-size:20px}.box{position:relative}.wheel{width:150px;height:150px;border-radius:50%;margin:8px auto;transition:transform 3s ease-out}.err{color:#b42318}.hp{position:absolute;left:-9999px}img{max-height:40px;display:block;margin-bottom:8px}${et}`}function g(e,t={},...n){let i=Object.assign(document.createElement(e),t);return i.append(...n),i}function dt(e,t){let n=!!e.required;if(e.type==="password")return g("label",{},e.label??"",g("input",{type:"password",name:e.key,required:n,autocomplete:"new-password"}));if(e.type==="company"){let o=`hm-co-${e.key}-${Math.random().toString(36).slice(2,8)}`,u=g("datalist",{id:o}),p=g("input",{type:"text",name:e.key,required:n,autocomplete:"organization"});p.setAttribute("list",o);let s;return p.addEventListener("input",()=>{clearTimeout(s);let r=p.value.trim();r.length<2||(s=setTimeout(()=>{t(r).then(l=>u.replaceChildren(...l.map(b=>g("option",{value:b}))))},250))}),g("label",{},e.label??"",p,u)}if(e.type==="freetext")return g(e.style==="heading"?"strong":"p",{},(e.text??"").replace(/<[^>]*>/g,""));if(e.type==="textarea")return g("label",{},e.label??"",g("textarea",{name:e.key,required:n}));if(e.type==="hidden")return g("input",{type:"hidden",name:e.key,value:e.value??""});if(e.type==="checkbox"||e.type.startsWith("consent_"))return g("label",{},g("input",{type:"checkbox",name:e.key,required:n}),` ${e.disclosureText??e.label??""} `,...e.privacyUrl?[g("a",{href:e.privacyUrl,target:"_blank",rel:"noopener noreferrer"},"Privacy policy")]:[]);if(e.type==="radio"||e.type==="checkbox_group"||e.type==="quiz"){let o=e.type==="checkbox_group"?"checkbox":"radio",u=e.type==="quiz"?(e.choices??[]).map(s=>s.label):e.options??[],p=(s,r)=>e.type==="quiz"?e.choices?.[r]?.display??s:s;return g("fieldset",{className:"grp"},g("legend",{},e.label??""),...u.map((s,r)=>g("label",{},g("input",{type:o,name:e.key,value:s,required:n&&o==="radio"}),` ${p(s,r)}`)))}if(e.type==="select")return g("label",{},e.label??"",g("select",{name:e.key,required:n},g("option",{value:""}),...(e.options??[]).map(o=>g("option",{},o))));let i={email:"email",phone:"tel",number:"number",rating:"number",date:"date",url:"url",datetime:"datetime-local",slider:"range",file:"file"}[e.type]??"text",a=e.type==="slider"?{min:e.min,max:e.max,step:e.step}:e.type==="rating"?{min:1,max:e.max}:{};return g("label",{},e.label??"",g("input",{type:i,name:e.key,required:n,...a}))}function he(e){var t;let n={};for(let i of e.querySelectorAll("[name]"))if(!(i.name==="website"||i.type==="file"||i.disabled||i.name.endsWith("-response")||i.name.endsWith("-solution"))){if(i.closest(".grp")){i.checked&&(i.type==="radio"?n[i.name]=i.value:(n[t=i.name]??(n[t]=[])).push(i.value));continue}n[i.name]=i.type==="checkbox"?i.checked:i.value}return n}var fe=e=>!!e&&/^https?:/.test(e)&&!!(location.href=e);function ct(e,t,n){let i=Object.fromEntries(e.outcomes.map(a=>[a.key,0]));for(let a of t)for(let[o,u]of Object.entries(a.choices?.find(p=>p.label===n[a.key])?.scores??{}))o in i&&(i[o]=i[o]+u*(a.weight??1));return e.outcomes.reduce((a,o)=>!a||i[o.key]>i[a.key]?o:a,void 0)}var ut=e=>e.querySelectorAll("input:not([type=hidden]),select,textarea").forEach(t=>{t.required=!1,t.type==="checkbox"||t.type==="radio"?t.checked=!1:t.value=""});function pt(e,t,n,i,a=!1){let o=e.definition,u=Date.now(),p={authorization:`Bearer ${n.siteKey}`},s=t.attachShadow({mode:"open"}),r=lt(o.theme);if("adoptedStyleSheets"in s&&typeof CSSStyleSheet<"u"){let f=new CSSStyleSheet;f.replaceSync(r),s.adoptedStyleSheets=[f]}else s.append(g("style",{},r));let l=0,b=g("p",{className:"err",role:"alert"}),y=[],d=async f=>{try{let v=await fetch(`${n.endpoint.replace(/\/$/,"")}/ingest/v1/forms/${e.id}/companies?q=${encodeURIComponent(f)}`,{headers:p});return v.ok?(await v.json()).items:[]}catch{return[]}},m=o.steps.map(f=>g("fieldset",{},...f.title?[g("strong",{},f.title)]:[],...f.fields.map(v=>{let k=dt(v,d);return y.push([v,k]),k}))),h=m.length-1,S=!!o.saveEachStep&&h>0,E="",C,N=new Set,P=f=>{h>0&&n.client.track("form_step",{formId:e.id,versionId:e.versionId,step:l,action:f})},J=g("div"),j=g("input",{name:"website",tabIndex:-1,autocomplete:"off"}),U=g("button",{type:"button"}),W=g("button",{type:"button"},"Back"),K=g("button",{type:"button",className:"skip"},"No thanks"),L=g("form",{noValidate:!1},...m,g("div",{className:"hp",ariaHidden:"true"},j),J,b,W,U,K),H=e.kind==="bar",A=g("div",{className:"box",role:H?"region":"dialog",ariaLabel:"Sign up"},...o.theme?.logoUrl&&o.theme.logoUrl.startsWith("https:")&&!H?[g("img",{src:o.theme.logoUrl,alt:""})]:[],...H&&o.bar?.text?[g("p",{className:"msg"},o.bar.text)]:[],L);e.kind==="popup"&&A.setAttribute("aria-modal","true");let O=o.captcha&&rt[o.captcha.provider],D="";if(O&&o.captcha?.provider==="friendlycaptcha"){let f=()=>new window.friendlyChallenge.WidgetInstance(J,{sitekey:o.captcha.siteKey,doneCallback:v=>D=v});window.friendlyChallenge?f():document.head.append(g("script",{src:`https://${O[0]}/widget.min.js`,async:!0,onload:f}))}else if(O&&o.captcha){let[f,v]=O,k=()=>oe[v].render(J,{sitekey:o.captcha.siteKey,callback:I=>D=I,"expired-callback":()=>D=""});oe[v]?.render?k():document.head.append(g("script",{src:`https://${f}/api.js?render=explicit`,async:!0,onload:()=>oe[v].ready?oe[v].ready(k):k()}))}let ee={},B=()=>{let f=(k,I)=>{k.hidden=!I,k.querySelectorAll("[name]").forEach(R=>R.disabled=!I)};y.forEach(([,k])=>f(k,!0));let v={...ee,...he(L)};for(let[k,I]of y)st(k.when,v)||(f(I,!1),delete v[k.key])};if(y.some(([f])=>f.when)&&(L.addEventListener("input",B),B()),o.countdown){let f=o.countdown,v=Date.parse(f.to),k=g("p"),I=()=>{let M=Math.max(0,(v-Date.now())/1e3|0);k.textContent=M?`${f.label} ${M/86400|0}d ${M/3600%24|0}h ${M/60%60|0}m ${M%60}s`:f.expiredText},R=setInterval(()=>{I(),t.isConnected||clearInterval(R)},1e3);I(),A.prepend(k)}e.kind!=="embed"&&A.prepend(g("button",{className:"x",type:"button",ariaLabel:"Close",onclick:()=>$(!1)},"\xD7"));let q=o.quiz?.emailCapture==="after"&&h>0?g("p",{className:"msg",role:"status"}):null;q&&m[h].prepend(q);let Q=()=>{if(m.forEach((v,k)=>v.hidden=k!==l),q&&l===h){let v=ct(o.quiz,y.map(([k])=>k),he(L));q.textContent=v?`${v.title}${v.text?` ${v.text}`:""}`:""}W.hidden=l===0||S,K.hidden=!o.steps[l]?.optional;let f=o.steps[l]?.submitLabel;U.textContent=f??(l===h?o.submitLabel??"Submit":"Next"),U.type=l===h||S?"submit":"button",N.has(l)||(N.add(l),P("reached"))},Y=()=>(m[l]?.querySelector("input:not([type=hidden]),select,textarea")??U).focus();U.addEventListener("click",()=>{if(l<h&&!S){let f=[...m[l].querySelectorAll("input,select")].find(v=>!v.checkValidity());f?f.reportValidity():(P("completed"),l++,Q(),Y())}}),W.addEventListener("click",()=>{l--,Q(),Y()}),K.addEventListener("click",()=>{P("skipped"),ut(m[l]),l<h?(l++,Q(),Y()):S&&C?re(C):L.requestSubmit()});let ie=f=>(f.type==="redirect"||f.type==="download")&&fe(f.url),re=f=>{let v=f.success;if(ie(v))return;let k=g("p",{role:"status"},`${v.text??"Thanks!"}${v.type==="coupon"&&v.code?` Code: ${v.code}`:""}${f.pendingConfirmation?" Check your email to confirm.":""}`),I=f.spin&&o.spin?g("div",{className:"wheel"}):null;if(I){let _=o.spin.segments.length;I.style.background=`conic-gradient(${Array.from({length:_},(X,V)=>`hsl(${V*360/_} 70% ${V%2?60:45}%) ${V*100/_}% ${(V+1)*100/_}%`)})`,k.hidden=!0,setTimeout(()=>{I.style.transform=`rotate(${1440-(f.spin.index+.5)/_*360}deg)`},50),setTimeout(()=>{k.hidden=!1},3100)}let R=g("button",{type:"button",onclick:()=>$(!0)},"Close"),M=(f.quiz?.products??[]).map(_=>g(_.url&&/^https?:/.test(_.url)?"a":"span",{className:"msg",..._.url&&/^https?:/.test(_.url)?{href:_.url}:{}},..._.imageUrl?.startsWith("https:")?[g("img",{src:_.imageUrl,alt:""})]:[],_.title));L.replaceChildren(...v.title?[g("strong",{},v.title)]:[],...I?[g("div",{},"\u25BC"),I]:[],k,...M,...e.kind==="embed"?[]:[R]),Z=!0,e.kind!=="embed"&&R.focus()};L.addEventListener("submit",async f=>{if(f.preventDefault(),O&&!D&&!(S&&l>0)){b.textContent="Please complete the captcha";return}U.disabled=!0;let v=k=>{b.textContent=o.failureText??k,U.disabled=!1,O&&!(S&&l>0)&&(D="",oe[O[1]]?.reset?.())};try{let k=n.client.anonymousId(),I=`${n.endpoint.replace(/\/$/,"")}/ingest/v1/forms/${e.id}`,R=S?m[l]:L,M=he(R);for(let V of R.querySelectorAll("input[type=file]")){if(!V.files?.[0])continue;let ce=new FormData;ce.append("field",V.name),ce.append("file",V.files[0]);let we=await fetch(`${I}/upload`,{method:"POST",headers:{...p,"idempotency-key":crypto.randomUUID()},body:ce}),ue=await we.json();if(!we.ok||!ue.url)return v(ue.error?.message??"Upload failed");M[V.name]=ue.url}let _=await fetch(`${I}/submit`,{method:"POST",headers:{...p,"content-type":"application/json","idempotency-key":crypto.randomUUID()},body:JSON.stringify({data:M,startedAt:u,website:j.value,...D?{captchaToken:D}:{},pageUrl:location.href,...k?{anonymousId:k}:{},...S?{step:l,...E?{stepToken:E}:{}}:{}})}),X=await _.json();if(!_.ok||!X.success){if(_.status>=500&&fe(o.redirects?.error))return;v(X.error?.message??"Something went wrong");return}if(P("completed"),S&&l<h&&X.stepToken){E=X.stepToken,C=X,Z=!0,ee={...ee,...M},l++,Q(),U.disabled=!1,Y();return}re(X)}catch{fe(o.redirects?.error)||v("Network error, please try again")}}),Q();let z=e.kind==="popup"?g("div",{className:"pop",onclick:f=>{f.target===z&&$(!1)}},A):e.kind==="flyout"?g("div",{className:"fly"},A):H?g("div",{className:`bar ${o.bar?.position==="top"?"top":"bottom"}`},A):A,G=Oe(e.kind,o.teaser),T=G?g("button",{type:"button",className:"tab",ariaLabel:`${G.text}: open the sign-up form`,onclick:()=>w(!0)},G.text):null;T&&(T.style.cssText=tt(G.side));let Z=!1,te=!1,ne=null,c=()=>{},x=f=>{f.key==="Escape"&&z.isConnected&&e.kind!=="embed"&&$(!1)};function w(f=e.kind==="popup"){z.isConnected||!t.isConnected||(ne=document.activeElement,T?.remove(),s.append(z),H&&(c=nt(z,o.bar?.position==="top")),e.kind!=="embed"&&document.addEventListener("keydown",x),te||(te=!0,n.client.formView(e.id,e.versionId)),f&&Y())}function $(f){document.removeEventListener("keydown",x),c();let v=ne;if(i(f||Z),T&&!(f||Z)){z.remove(),s.append(T),T.focus();return}t.remove(),v?.focus?.()}return T&&a?s.append(T):w(),()=>{te||w()}}async function mt(e){let t=[];try{let d=await fetch(`${e.endpoint.replace(/\/$/,"")}/ingest/v1/forms?v=${e.client.anonymousId()??crypto.randomUUID()}`,{headers:{authorization:`Bearer ${e.siteKey}`}});if(!d.ok)return;t=(await d.json()).forms}catch{return}let n=e.allowed(),i=n?Number(e.get(Se)??0):0,a=Me(e,n),o;if(t.some(d=>ge(d.targeting??{})))try{let d=e.client.anonymousId(),m=await fetch(`${e.endpoint.replace(/\/$/,"")}/ingest/v1/forms/visitor${d?`?aid=${encodeURIComponent(d)}`:""}`,{headers:{authorization:`Bearer ${e.siteKey}`}});m.ok&&(o=await m.json())}catch{}let u=matchMedia("(pointer:coarse)").matches||innerWidth<768,p=new Map,s=[],r=new Set,l="",b=()=>{l!==location.href&&(l=location.href,s.forEach(d=>d()),s=[],r=new Set,i++,n&&e.set(Se,String(i)),t.forEach(y))};qe=()=>t.forEach(d=>{d.targeting?.cart&&!r.has(d.id)&&y(d)});function y(d){let m=d.targeting??{},h=e.get(`hm_c_${d.id}`);if(p.has(d.id)||!Ue(m,{path:location.pathname,mobile:u,returning:i>1,pageViews:i,now:Date.now(),lastClosedAt:h?Number(h):void 0,submitted:e.get(`hm_s_${d.id}`)==="1",...a,cart:be,productPage:Ae(document),flags:o}))return;r.add(d.id);let S=C=>{let N=d.kind==="embed"?document.querySelector(`[data-hm-form="${d.id}"]`):document.body.appendChild(g("div"));!N||p.has(d.id)||p.set(d.id,pt(d,N,e,P=>{n&&(e.set(`hm_c_${d.id}`,String(Date.now())),P&&e.set(`hm_s_${d.id}`,"1")),P||e.client.track("form_dismiss",{formId:d.id,versionId:d.versionId})},C))},E=Oe(d.kind,d.definition.teaser);E?.show==="before_trigger"&&S(!0),s.push(Xe(d.kind==="embed"?{}:m,u,()=>{let C=p.get(d.id);C?C():S(!!E&&E.show!=="after_close")}))}for(let d of["pushState","replaceState"]){let m=history[d].bind(history);history[d]=(...h)=>{m(...h),b()}}addEventListener("popstate",b),b()}function Me(e,t){let n=t?e.get("hm_ft"):null;if(n)try{return JSON.parse(n)}catch{}let i=new URLSearchParams(location.search),a={};for(let p of["source","medium","campaign"]){let s=i.get(`utm_${p}`);s&&(a[p]=s.slice(0,100))}let o="";try{let p=document.referrer?new URL(document.referrer).hostname:"";o=p===location.hostname?"":p}catch{}let u={utm:a,referrer:o};return t&&e.set("hm_ft",JSON.stringify(u)),u}function ht(e){let t=e;return!t||typeof t.total_price!="number"||typeof t.item_count!="number"?null:{value:t.total_price/100,items:t.item_count}}async function ft(e,t,n=fetch){if(e==="shopify")try{let i=await n("/cart.js",{credentials:"same-origin",headers:{accept:"application/json"}}),a=i.ok?ht(await i.json()):null;a&&t(a)}catch{}}var yt={banner:"position:fixed;left:0;right:0;top:0;padding:12px 44px 12px 16px",modal:"position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);max-width:min(92vw,440px);padding:24px;border-radius:8px;box-shadow:0 4px 24px #0004",slide_in:"position:fixed;right:16px;bottom:16px;max-width:min(92vw,360px);padding:20px;border-radius:8px;box-shadow:0 4px 24px #0004"};async function gt(e){let t=e.endpoint.replace(/\/$/,""),n={authorization:`Bearer ${e.siteKey}`},i=e.client.anonymousId(),a=[];try{let m=await fetch(`${t}/ingest/v1/site-messages${i?`?aid=${encodeURIComponent(i)}`:""}`,{headers:n});m.ok&&(a=(await m.json()).messages)}catch{return}if(!a.length)return;let o;if(a.some(m=>ge(m.targeting??{})))try{let m=await fetch(`${t}/ingest/v1/forms/visitor${i?`?aid=${encodeURIComponent(i)}`:""}`,{headers:n});m.ok&&(o=await m.json())}catch{}let u=e.allowed(),p=u?Number(e.get("hm_pv")??1):1,s={path:location.pathname,mobile:matchMedia("(pointer:coarse)").matches||innerWidth<768,returning:p>1,pageViews:p,now:Date.now(),...Me(e,u),cart:ot(),productPage:Ae(document),flags:o},r=[...a].sort((m,h)=>Number(h.queued)-Number(m.queued)).find(m=>{let h=e.get(`hm_m_${m.id}`);return Ue(m.targeting??{},{...s,lastClosedAt:h?Number(h):void 0,submitted:!1})&&!(h&&m.targeting?.frequencyDays===void 0)});if(!r)return;let l=document.createElement("div"),b=l.attachShadow({mode:"open"}),y=document.createElement("div");if(y.setAttribute("role",r.style==="modal"?"dialog":"status"),y.style.cssText=`${yt[r.style]};background:#fff;color:#111;font:15px/1.5 system-ui,sans-serif;z-index:2147483000;box-sizing:border-box`,y.innerHTML=r.html,r.ctaLabel&&r.ctaUrl&&/^https?:\/\//.test(r.ctaUrl)){let m=Object.assign(document.createElement("a"),{href:r.ctaUrl,textContent:r.ctaLabel,rel:"noopener"});m.style.cssText="display:inline-block;margin-top:10px;padding:8px 14px;background:#1f6feb;color:#fff;border-radius:6px;text-decoration:none",y.append(m)}let d=Object.assign(document.createElement("button"),{type:"button",textContent:"\xD7",ariaLabel:"Close"});d.style.cssText="position:absolute;top:6px;right:10px;border:0;background:none;font-size:20px;cursor:pointer;color:inherit",d.addEventListener("click",()=>{l.remove(),e.allowed()&&e.set(`hm_m_${r.id}`,String(Date.now()))}),y.append(d),b.append(y),document.body.append(l),fetch(`${t}/ingest/v1/site-messages/${r.id}/shown`,{method:"POST",headers:{...n,"content-type":"application/json"},body:JSON.stringify(i?{aid:i}:{})}).catch(()=>{})}function bt(e){let t=new Map,n={get:i=>t.get(i)??null,set:(i,a)=>{t.set(i,a)},del:i=>{t.delete(i)}};try{if(e==="local"){let i=localStorage;return{get:a=>i.getItem(a),set:(a,o)=>i.setItem(a,o),del:a=>i.removeItem(a)}}if(e==="cookie")return{get:i=>document.cookie.split("; ").find(a=>a.startsWith(`${i}=`))?.slice(i.length+1)??null,set:(i,a)=>{document.cookie=`${i}=${a}; max-age=31536000; path=/; SameSite=Lax`},del:i=>{document.cookie=`${i}=; max-age=0; path=/`}}}catch{}return n}function vt(e,t,n){let i=o=>`${e.replace(/\/$/,"")}${o}`,a=o=>new Promise(u=>setTimeout(u,o));return{async send(o,u){for(let p=0,s=crypto.randomUUID();p<5;p++){try{let r=await fetch(i(o),{method:"POST",keepalive:!0,body:JSON.stringify(u),headers:{"content-type":"application/json",authorization:`Bearer ${t}`,"idempotency-key":s}});if(r.status<400)return!0;if(r.status<500&&r.status!==429){let l=await r.json().catch(()=>null);return n(Object.assign(new Error(l?.error?.message??`HTTP ${r.status}`),{status:r.status,code:l?.error?.code})),null}}catch(r){n(r)}await a(500*2**p+Math.random()*500)}return!1},get:o=>fetch(`${i(o)}?k=${encodeURIComponent(t)}`).then(u=>u.ok?u.json():null).catch(()=>null),post:(o,u)=>fetch(i(o),{method:"POST",body:JSON.stringify(u),headers:{"content-type":"application/json",authorization:`Bearer ${t}`}}).then(p=>p.json()),beacon:(o,u)=>navigator.sendBeacon?.(`${i(o)}?k=${encodeURIComponent(t)}`,new Blob([JSON.stringify(u)],{type:"text/plain"}))??!1}}var _e="0.4.5",Ee=50,De=50,le="hm_aid",Ce="hm_consent",xt="hm_queue:",wt=3e3,Pe=()=>crypto.randomUUID();function Le(e,t={}){return{mode:e.consentMode??t.consentMode??"require-consent",bufferUntilConsent:e.bufferUntilConsent??t.bufferUntilConsent??!1,stripQuery:e.stripQuery??t.stripQuery??!1,allowParams:e.allowParams??(t.allowParams?.length?t.allowParams:void 0),autoPageViews:e.autoPageViews??t.autoPageViews??!1,pageViewRoutes:e.pageViewRoutes??t.pageViewRoutes??[],identify:{email:!0,phone:!0,externalId:!0,...t.identify,...e.identify},maxSize:Math.min(e.batch?.maxSize??t.batchSize??20,De),flushMs:e.batch?.flushMs??t.flushMs??2e3,maxQueue:e.maxQueue??t.maxQueue??200,autocapture:e.autocapture??t.autocapture??!1,trackVideo:e.trackVideo??t.trackVideo??!1}}function kt(e,t){return e.length?e.some(n=>{if(n.endsWith("*"))return t.startsWith(n.slice(0,-1));let i=n.replace(/\/$/,"");return t===i||t.startsWith(`${i}/`)}):!0}function $t(e){let t=Le(e),n=bt(e.storage??"local"),i={},a=(c,x)=>(i[c]??[]).forEach(w=>w(x)),o=e.debug??!1,u=(...c)=>o&&console.debug("[hermetica]",...c),p=null,s=c=>{p=c,a("error",c)},r=vt(e.endpoint,e.siteKey,s),l=(()=>{try{return JSON.parse(n.get(Ce)??"null")}catch{return null}})(),b=()=>l??(t.mode==="require-consent"?{analytics:!1,marketing:!1}:{analytics:!0,marketing:!0}),y=b(),d=l!==null||t.mode!=="require-consent",m=!1,h=[],S,E=null,C=Promise.resolve(),N=[],P=(e.storage??"local")==="local"?n:null,J=`${xt}${e.siteKey}`,j=()=>{if(P)try{let c=d&&y.analytics?[...N,...h].slice(-t.maxQueue):[];c.length?P.set(J,JSON.stringify(c)):P.del(J)}catch{}},U=!e.remoteConfig,W=[],K=c=>{U?c():W.length<Ee&&W.push(c)},L=()=>(E??(E=n.get(le)),E||(E=Pe(),n.set(le,E)),E),H=(()=>{let c={};try{new URL(location.href).searchParams.forEach((x,w)=>{w.startsWith("utm_")&&(c[w.slice(4)]=x.slice(0,256))})}catch{}return c})(),A=c=>{if(!t.stripQuery&&!t.allowParams)return c;try{let x=new URL(c),w=new Set(t.allowParams??[]);for(let $ of Array.from(x.searchParams.keys()))w.has($)||x.searchParams.delete($);return x.hash="",x.href}catch{return c}},O=()=>({url:location.href,referrer:document.referrer,title:document.title,path:location.pathname}),D=c=>({page:{url:A(c.url),referrer:A(c.referrer),title:c.title},...Object.keys(H).length?{utm:H}:{}});function ee(c,x,w,$){if(d&&!y.analytics){u("dropped (analytics denied)",c);return}if(!d&&!t.bufferUntilConsent){u("dropped (consent not decided yet)",c);return}let f={name:c,properties:{...x,hm_sdk:_e,...globalThis.hmAd?.()},dedupeKey:Pe(),occurredAt:new Date().toISOString(),context:D($),...w};if(e.beforeSend){try{f=e.beforeSend(f)}catch(k){s(k),f=null}if(!f){u("dropped (beforeSend)",c);return}}h.push(f);let v=d?t.maxQueue:Ee;h.length>v&&h.splice(0,h.length-v),u("queued",f),d&&(j(),h.length>=t.maxSize?q():S??(S=setTimeout(()=>{q()},t.flushMs)))}let B=(c,x,w={})=>{let $=O();K(()=>ee(c,x,w,$))};function q(){if(clearTimeout(S),S=void 0,!d||!y.analytics||h.length===0)return C;let c=L(),x=h.splice(0,t.maxSize);N.push(...x);let w=x.map($=>({...$,anonymousId:c}));return C=C.then(async()=>{let $=await r.send("/ingest/v1/batch",{events:w,consent:y});N=N.filter(f=>!x.includes(f)),$?a("flush",w):$===!1&&(h.unshift(...w),h.splice(0,h.length-t.maxQueue),s(new Error("send failed"))),j(),$!==!1&&h.length&&q()}),C}let Q=()=>{if(!d||!y.analytics||h.length===0)return;let c=L(),x=[];for(;h.length;){let w=h.splice(0,De);r.beacon("/ingest/v1/batch",{events:w.map($=>({...$,anonymousId:c})),consent:y})||x.push(...w)}h=x,j()};typeof addEventListener=="function"&&addEventListener("pagehide",Q);let Y=(c={})=>B("page_view",c),ie=()=>{let c=O();K(()=>{t.autoPageViews&&kt(t.pageViewRoutes,c.path)&&ee("page_view",{},{},c)})};if(e.autoPageViews||e.remoteConfig&&e.autoPageViews!==!1){ie();for(let c of["pushState","replaceState"]){let x=history[c].bind(history);history[c]=(...w)=>{x(...w),ie()}}addEventListener("popstate",ie)}let re=()=>{t.autocapture&&typeof document<"u"&&We((c,x)=>B(c,x)),t.trackVideo&&typeof document<"u"&&Ge((c,x)=>B(c,x))},z=()=>({client:T,endpoint:e.endpoint,siteKey:e.siteKey,get:n.get,set:n.set,allowed:()=>d&&y.analytics}),G={start:async()=>{e.cart&&await ft(e.cart,Ie),await Promise.all([mt(z()),gt(z())])},setCart:Ie},T={forms:G,track:(c,x={},w={})=>B(c,x,{...w.value!==void 0?{value:w.value}:{},...w.currency?{currency:w.currency}:{},...w.dedupeKey?{dedupeKey:w.dedupeKey}:{}}),page:Y,formView:(c,x)=>B("form_view",{formId:c,...x?{versionId:x}:{}}),identify:(c,x={},w={})=>K(()=>{if(!y.marketing||d&&!y.analytics){u("identify skipped (no marketing consent)");return}let{email:$,phone:f,...v}=x,k={...c&&t.identify.externalId?{externalId:c}:{},...$&&t.identify.email?{email:$}:{},...f&&t.identify.phone?{phone:f}:{}};if(!Object.keys(k).length){u("identify skipped (identifiers not allowed for this site)");return}C.then(()=>r.send("/ingest/v1/identify",{anonymousId:L(),identifiers:k,traits:v,consent:y,...w.signature?{signature:w.signature}:{}}))}),subscribe:c=>r.send("/ingest/v1/subscribe",{...c,pageUrl:A(location.href),anonymousId:T.anonymousId()??void 0}),backInStock:c=>r.send("/ingest/v1/back-in-stock",c),consent:{get:()=>({...y}),update(c){y={...y,...c},d=!0,m=!0,n.set(Ce,JSON.stringify(y)),a("consent",{...y}),y.analytics?q():(h=[],N=[],E=null,n.del(le)),j()}},anonymousId:()=>d&&y.analytics?L():null,reset(){h=[],N=[],E=null,n.del(le),j()},flush:q,on(c,x){(i[c]??(i[c]=[])).push(x)},debug:{events:()=>[...h],lastError:()=>p,enable:()=>{o=!0},disable:()=>{o=!1},test:c=>r.post("/ingest/v1/test",{events:c??(h.length?h:[{name:"test_event",properties:{hm_sdk:_e},context:D(O())}]),consent:y})}};function Z(){if(!P)return;let c=[];try{c=JSON.parse(P.get(J)??"[]")}catch{}if(!Array.isArray(c)||!c.length||!d||!y.analytics){j();return}let x=new Set(h.map($=>$.dedupeKey)),w=c.filter($=>$&&typeof $.name=="string"&&typeof $.dedupeKey=="string"&&!x.has($.dedupeKey)&&x.add($.dedupeKey));h=[...w,...h].slice(-t.maxQueue),u("restored",w.length),S??(S=setTimeout(()=>{q()},t.flushMs))}let te=c=>K(()=>{t.mode!=="none"&&c&&T.consent.update({analytics:c.analytics===!0,marketing:c.marketing===!0})});if(e.consentSource!=="none"&&typeof addEventListener=="function"){addEventListener("hermetica:consent",x=>te(x.detail));let c=globalThis.CookieMunch;c?.hasResponse&&te({analytics:c.consent?.statistics,marketing:c.consent?.marketing})}let ne=c=>{if(!U){c&&(Object.assign(t,Le(e,c)),!m&&l===null&&(y=b(),d=t.mode!=="require-consent"),u("settings",t)),U=!0,Z(),re();for(let x of W.splice(0))x()}};return e.remoteConfig?(setTimeout(()=>ne(null),wt),r.get("/ingest/v1/config").then(c=>ne(c),()=>ne(null))):(Z(),re()),e.forms&&G.start(),T}var ye=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ae=e=>typeof e=="string"&&e?e:null,de=(e,t)=>t?{[e]:t}:{};function Te(e){if(!ye(e))return{};let t=[e];for(let n of[e.data,e.userInfo,e.notification,e.additionalData])ye(n)&&t.push(n,n.data,n.additionalData);return Object.assign({},...t.filter(ye))}function Ne(e,t,n){let i=e.identity(),a=e.device??{};return{data:{type:n,attributes:{token:t.token,platform:e.platform,vendor:t.vendor,enablement_status:t.enablementStatus??"AUTHORIZED",background:t.background??"AVAILABLE",device_metadata:{device_id:i.anonymousId??"",sdk_version:e.sdkVersion??"app-0.4.5",device_model:a.deviceModel??"",os_name:a.osName??e.platform,os_version:a.osVersion??"",app_name:a.appName??"",app_version:a.appVersion??"",app_build:a.appBuild??"",app_id:a.appId??"",environment:t.environment??"release"},profile:{data:{type:"profile",attributes:{...de("email",i.email),...de("phone_number",i.phoneNumber),...de("external_id",i.externalId),...de("anonymous_id",i.anonymousId)}}}}}}}function St(e){let t=o=>`${e.endpoint.replace(/\/$/,"")}${o}?company_id=${encodeURIComponent(e.siteKey)}`,n=e.retryMs??500;async function i(o,u){let p=crypto.randomUUID();for(let s=0;s<5;s++){try{let r=await fetch(t(o),{method:"POST",body:JSON.stringify(u),headers:{"content-type":"application/json",authorization:`Bearer ${e.siteKey}`,"idempotency-key":p}});if(r.status<500&&r.status!==429)return r.ok}catch{}s<4&&await new Promise(r=>setTimeout(r,n*2**s+Math.random()*n))}return!1}let a=o=>typeof o=="string"?o||null:ae(Te(o).hermetica_message_id);return{register:o=>i("/client/push-tokens",Ne(e,o,"push-token")),unregister:o=>i("/client/push-token-unregister",Ne(e,o,"push-token-unregister")),opened(o){let u=Te(o),p=ae(u.hermetica_message_id);return p&&e.track("$opened_push",{hermetica_message_id:p}),ae(u.deep_link)??ae(u.url)??ae(u.hermetica_url)},received(o){let u=a(o);return u&&e.track("$received_push",{hermetica_message_id:u}),!!u}}}var ve=e=>{try{let t=new URL(e,location.href);return t.protocol==="https:"||t.protocol==="http:"?t.href:null}catch{return null}};function It(e){let t=document.createElement("template");return t.innerHTML=e,t.content.querySelectorAll("script,style,iframe,object,embed,link,meta,base,form").forEach(n=>n.remove()),t.content.querySelectorAll("*").forEach(n=>{for(let i of Array.from(n.attributes))(i.name.startsWith("on")||(i.name==="href"||i.name==="src"||i.name==="action")&&!ve(i.value))&&n.removeAttribute(i.name)}),t.content}var F=(e,t,n)=>{let i=document.createElement(e);return i.style.cssText=t,n!==void 0&&(i.textContent=n),i};function _t(e,t){let n=e.style,i=e.layout==="banner_top"||e.layout==="banner_bottom",a=F("div",`position:fixed;z-index:2147483000;display:flex;${i?`left:0;right:0;${e.layout==="banner_top"?"top:0":"bottom:0"};`:`inset:0;background:rgba(0,0,0,.5);align-items:${e.layout==="bottom_sheet"?"flex-end":"center"};justify-content:center;`}`);a.setAttribute("data-hermetica-inapp",e.id);let o=e.layout==="fullscreen",u=e.layout==="bottom_sheet",p=F("div",`background:${n.background};color:${n.textColor};font:16px/1.4 system-ui,sans-serif;box-sizing:border-box;padding:20px;position:relative;${i?"width:100%;":o?"width:100%;height:100%;overflow:auto;":`width:min(92vw,420px);${u?`border-radius:${n.radius}px ${n.radius}px 0 0;width:min(100vw,520px);`:`border-radius:${n.radius}px;`}`}`);if(p.setAttribute("role","dialog"),p.setAttribute("aria-modal",String(!i)),e.content.html)p.append(It(e.content.html));else for(let s of e.content.blocks)if(s.type==="heading")p.append(F("h2","margin:0 0 8px;font-size:20px",s.text));else if(s.type==="text")p.append(F("p","margin:0 0 12px",s.text));else if(s.type==="image"&&s.url&&ve(s.url)){let r=F("img","max-width:100%;display:block;margin:0 0 12px");r.src=s.url,r.alt=s.alt??"",p.append(r)}else if(s.type==="buttons"){let r=F("div","display:flex;gap:8px;flex-wrap:wrap");for(let l of s.buttons??[]){let b=l.style!=="secondary",y=F("button",`cursor:pointer;padding:10px 16px;border-radius:${Math.min(n.radius,10)}px;font:inherit;border:1px solid ${n.accentColor};background:${b?n.accentColor:"transparent"};color:${b?"#fff":n.accentColor}`,l.label);y.addEventListener("click",()=>t.click(l)),r.append(y)}p.append(r)}if(n.dismissible){let s=F("button","position:absolute;top:8px;right:8px;border:0;background:transparent;color:inherit;font-size:20px;cursor:pointer","\xD7");s.setAttribute("aria-label","Close"),s.addEventListener("click",t.dismiss),p.append(s)}return a.append(p),a}function Et(e){let t=e.endpoint.replace(/\/$/,""),n={"content-type":"application/json",authorization:`Bearer ${e.siteKey}`},i=(()=>{try{return sessionStorage.getItem("hm_sid")??(sessionStorage.setItem("hm_sid",crypto.randomUUID()),sessionStorage.getItem("hm_sid"))}catch{return crypto.randomUUID()}})(),a=()=>({...e.identity?.(),anonymousId:e.anonymousId()??void 0}),o=new Set,u=(r,l,b)=>{fetch(`${t}/client/in-app-events?company_id=${encodeURIComponent(e.siteKey)}`,{method:"POST",keepalive:!0,headers:{...n,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({events:[{messageId:r.id,variant:r.variant,type:l,platform:e.platform??"web",sessionId:i,...b?{button:b}:{}}],profile:a()})}).catch(()=>{})};function p(r){if(o.has(r.id))return;o.add(r.id);let l=()=>b.remove(),b=_t(r,{dismiss:()=>{u(r,"dismiss"),l()},click:y=>{if(u(r,"click",y.label),l(),y.action==="dismiss"||!y.value||e.onAction?.(y.action,y.value,r)===!1||y.action==="event")return;let d=ve(y.value);d&&location.assign(d)}});document.body.append(b),u(r,"impression")}async function s(r={type:"page_url"}){let l=a();if(!l.anonymousId&&!l.externalId&&!l.email&&!l.phoneNumber)return[];let b=new URLSearchParams({company_id:e.siteKey,platform:e.platform??"web",trigger:r.type,session_id:i});"name"in r&&b.set("name",r.name),r.type==="page_url"&&b.set("url",r.url??location.href),r.type==="event"&&r.properties&&b.set("properties",JSON.stringify(r.properties)),l.externalId&&b.set("external_id",l.externalId),l.email&&b.set("email",l.email),l.phoneNumber&&b.set("phone_number",l.phoneNumber),l.anonymousId&&b.set("anonymous_id",l.anonymousId);let y=await fetch(`${t}/client/in-app-messages?${b}`,{headers:{authorization:n.authorization}}).catch(()=>null);if(!y?.ok)return[];let d=(await y.json()).items;return d[0]&&p(d[0]),d}return{trigger:s,display:p}}function je(e){let{platform:t,device:n,sdkVersion:i,inApp:a=!0,onDeepLink:o,...u}=e,p=$t(u),s={},r=null,l=()=>({...s,anonymousId:p.anonymousId()}),b=St({siteKey:e.siteKey,endpoint:e.endpoint,platform:t,identity:l,track:(m,h)=>p.track(m,h),...n?{device:n}:{},...i?{sdkVersion:i}:{}}),y=()=>{r&&b.register(r)},d=a&&typeof document<"u"?Et({siteKey:e.siteKey,endpoint:e.endpoint,platform:t,anonymousId:p.anonymousId,identity:()=>({...s}),onAction:(m,h,S)=>{if(m==="event")return p.track(h,{hermetica_message_id:S.id}),!1;if(o)return o(h),!1}}):null;return typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&p.flush()}),d&&d.trigger({type:"app_open"}),{...p,track(m,h={},S){p.track(m,h,S),d?.trigger({type:"event",name:m,properties:h})},identify(m,h={}){let S=h;m&&(s.externalId=m),typeof S.email=="string"&&(s.email=S.email),typeof S.phone=="string"&&(s.phoneNumber=S.phone),p.identify(m,h),y()},reset(){for(let m of Object.keys(s))delete s[m];p.reset(),y()},screen(m,h={}){p.page({screen:m,...h}),d?.trigger({type:"screen_view",name:m})},setProfile(m){Object.assign(s,m),y()},async setPushToken(m){return r=m,b.register(m)},async unregisterPushToken(){let m=r;return r=null,m?b.unregister(m):!0},handlePushOpened(m){let h=b.opened(m);return h&&o?.(h),h},handlePushReceived:m=>b.received(m)}}var Ct=()=>new Promise(e=>{if(globalThis.cordova===void 0)return e();document.addEventListener("deviceready",()=>e(),{once:!0})}),xe=e=>new Promise(t=>e(t,()=>t(!1)));async function Pt(e){await Ct();let t=globalThis,{firebase:n=t.FirebasePlugin,cordovaDevice:i=t.device,requestPushPermission:a=!1,pushEnvironment:o="release",...u}=e,p=i?.platform.toLowerCase()==="ios"?"ios":"android",s={...i?.model?{deviceModel:i.model}:{},osName:p,...i?.version?{osVersion:i.version}:{},...u.device},r=je({...u,platform:p,device:s,sdkVersion:"cordova-0.4.5"}),l=!1,b=d=>{if(!d)return;let m={token:d,vendor:"fcm",environment:o,enablementStatus:l?"AUTHORIZED":"DENIED"};r.setPushToken(m)};async function y(){return n?(l=await xe((d,m)=>n.hasPermission(d,m))||await xe((d,m)=>n.grantPermission(d,m)),n.getToken(b,()=>{}),l):!1}return n&&(n.onTokenRefresh(b,()=>{}),n.onMessageReceived(d=>{d.tap?r.handlePushOpened(d):r.handlePushReceived(d)},()=>{}),a?y():xe((d,m)=>n.hasPermission(d,m)).then(d=>{d&&y()})),{...r,enablePush:y}}
1
+ "use strict";var pe=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Ve=Object.prototype.hasOwnProperty;var Ke=(e,t)=>{for(var n in t)pe(e,n,{get:t[n],enumerable:!0})},He=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Re(t))!Ve.call(e,a)&&a!==n&&pe(e,a,{get:()=>t[a],enumerable:!(i=ze(t,a))||i.enumerable});return e};var Be=e=>He(pe({},"__esModule",{value:!0}),e);var Lt={};Ke(Lt,{createCordovaClient:()=>Pt});module.exports=Be(Lt);var Fe="a,button,[role=button],[data-hm-capture]",Je=e=>(e.textContent??"").replace(/\s+/g," ").trim().slice(0,60);function We(e,t=document){let n=[],i=o=>{let u=o.target instanceof Element?o.target.closest(Fe):null;if(!u||u.closest("[data-hm-no-capture]"))return;let p={tag:u.tagName.toLowerCase(),id:u.id||void 0,text:Je(u),href:u instanceof HTMLAnchorElement?u.href:void 0,path:location.pathname};e("element_click",p);let s=Date.now();n=[...n.filter(r=>s-r.at<1e3&&r.el===u),{el:u,at:s}],n.length===3&&e("rage_click",p)},a=()=>e("page_leave",{path:location.pathname});return t.addEventListener("click",i,!0),addEventListener("pagehide",a),()=>{t.removeEventListener("click",i,!0),removeEventListener("pagehide",a)}}var Qe=/^https:\/\/(?:www\.youtube(?:-nocookie)?\.com\/embed|player\.vimeo\.com\/video)\/([\w-]+)/,Ye=["video_ended","video_play","video_pause"],se=["play","pause","ended"];function Ge(e,t=document){let n=(s,r)=>e(s,{path:location.pathname,pageId:t.documentElement.dataset.hmPageId,...r}),i=s=>{let r=s.target;!(r instanceof HTMLVideoElement)||r.closest("[data-hm-no-capture]")||s.type==="pause"&&r.ended||n("video_"+s.type,{provider:"html5",src:(r.currentSrc||r.src).slice(0,300),seconds:Math.round(r.currentTime),duration:Math.round(r.duration)||void 0})},a=new Map,o=()=>t.querySelectorAll("iframe").forEach(s=>{let r=s.contentWindow,l=Qe.exec(s.src);if(!r||!l||a.has(r)||s.closest("[data-hm-no-capture]"))return;let b=s.src.includes("youtu");if(b&&!/[?&]enablejsapi=1/.test(s.src))return;a.set(r,{yt:b,id:l[1]});let y=d=>r.postMessage(JSON.stringify(d),new URL(s.src).origin);b?y({event:"listening",id:l[1],channel:"widget"}):se.forEach(d=>y({method:"addEventListener",value:d}))}),u=s=>{let r=s.source&&a.get(s.source);if(!r||!/youtube|vimeo/.test(s.origin))return;let l;try{l=typeof s.data=="string"?JSON.parse(s.data):s.data}catch{return}let b=r.yt?l.event==="onStateChange"?Ye[l.info]:void 0:se.includes(l.event)?"video_"+l.event:void 0;b&&n(b,{provider:r.yt?"youtube":"vimeo",videoId:r.id,seconds:Math.round(l.data?.seconds??0)||void 0})};se.forEach(s=>t.addEventListener(s,i,!0)),addEventListener("message",u),o();let p=new MutationObserver(o);return p.observe(t.documentElement,{childList:!0,subtree:!0}),()=>{se.forEach(s=>t.removeEventListener(s,i,!0)),removeEventListener("message",u),p.disconnect()}}var me=(e,t)=>new RegExp(`^${e.split("*").map(n=>n.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*")}$`).test(t),ge=e=>!!(e.audience?.listIds?.length||e.audience?.segmentIds?.length||e.hideKnownSubscribers||e.countries?.length||e.countriesExclude?.length);function Ze(e,t){if(e.hideKnownSubscribers&&(!t||t.subscriber))return!1;let n=[...(e.audience?.listIds??[]).map(a=>t?.lists[a]),...(e.audience?.segmentIds??[]).map(a=>t?.segments[a])];if(n.length){let a=n.some(o=>o===!0);if((e.audience?.mode??"show")==="show"?!a:a)return!1}let i=a=>a.some(o=>t?.countries[o]===!0);return!(e.countries?.length&&!i(e.countries)||e.countriesExclude?.length&&i(e.countriesExclude))}function Ue(e,t){if(t.submitted||e.frequencyDays!==void 0&&t.lastClosedAt!==void 0&&t.now-t.lastClosedAt<e.frequencyDays*864e5||e.device==="mobile"&&!t.mobile||e.device==="desktop"&&t.mobile||e.visitor==="new"&&t.returning||e.visitor==="returning"&&!t.returning||e.minPageViews&&t.pageViews<e.minPageViews||e.urlExclude?.some(n=>me(n,t.path))||e.urlInclude?.length&&!e.urlInclude.some(n=>me(n,t.path)))return!1;if(e.utm)for(let n of["source","medium","campaign"]){let i=e.utm[n];if(i&&(t.utm?.[n]??"").toLowerCase()!==i.toLowerCase())return!1}if(e.referrerInclude?.length&&!e.referrerInclude.some(n=>me(n.toLowerCase(),(t.referrer??"").toLowerCase())))return!1;if(e.cart){let n=t.cart??{value:0,items:0};if(e.cart.empty===!0&&n.items>0||e.cart.empty===!1&&n.items===0||e.cart.minValue!==void 0&&n.value<e.cart.minValue||e.cart.minItems!==void 0&&n.items<e.cart.minItems)return!1}return!(e.productPage==="only"&&!t.productPage||e.productPage==="never"&&t.productPage||ge(e)&&!Ze(e,t.flags))}function Ae(e){return e.querySelector('meta[property="og:type"][content="product" i], meta[property="og:type"][content="og:product" i], [itemtype*="schema.org/Product"]')?!0:[...e.querySelectorAll('script[type="application/ld+json"]')].some(t=>/"@type"\s*:\s*"Product"/.test(t.textContent??""))}function Xe(e,t,n){let i=[],a=!1,o=()=>{a=!0,i.forEach(r=>r())},u=()=>{a||(o(),n())},p=(r,l,b)=>{r.addEventListener(l,b,{passive:!0}),i.push(()=>r.removeEventListener(l,b))},s=t&&(e.exitIntent||e.inactivitySeconds!==void 0);if(e.delaySeconds===void 0&&e.scrollPercent===void 0&&!e.exitIntent&&e.inactivitySeconds===void 0)return u(),o;if(e.delaySeconds!==void 0){let r=setTimeout(u,e.delaySeconds*1e3);i.push(()=>clearTimeout(r))}if(e.scrollPercent!==void 0&&p(window,"scroll",()=>{(scrollY+innerHeight)/document.documentElement.scrollHeight*100>=e.scrollPercent&&u()}),e.exitIntent&&!t&&p(document,"mouseout",r=>{let l=r;!l.relatedTarget&&l.clientY<=0&&u()}),s){let r,l=()=>{clearTimeout(r),r=setTimeout(u,(e.inactivitySeconds??30)*1e3)};l();for(let b of["touchstart","scroll","keydown"])p(window,b,l);e.exitIntent&&e.mobileBackExit&&(history.pushState({hm:1},""),p(window,"popstate",u)),i.push(()=>clearTimeout(r))}return o}var et=".tab{position:fixed;z-index:2147483000;margin:0;box-shadow:0 2px 12px #0004}.skip{background:none;border:0;color:inherit;text-decoration:underline}.bar{position:fixed;left:0;right:0;z-index:2147483000}.bar.top{top:0}.bar.bottom{bottom:0}.bar .box{max-width:none;border-radius:0;display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:10px 48px 10px 16px}.bar .msg{margin:0}.bar form,.bar fieldset{display:flex;flex-wrap:wrap;align-items:center;gap:8px;flex:1}.bar label{margin:0}.bar button{margin:0}@media(max-width:600px){.bar .box,.bar form,.bar fieldset{flex-direction:column;align-items:stretch}}",ke={left:"left:0;top:50%",right:"right:0;top:50%",bottom:"bottom:0;left:50%",top_left:"top:16px;left:16px",top_right:"top:16px;right:16px",bottom_left:"bottom:16px;left:16px",bottom_right:"bottom:16px;right:16px"},tt=e=>ke[e??"right"]??ke.right,Oe=(e,t)=>e==="popup"||e==="flyout"?t:void 0;function nt(e,t){let n=document.body.style,i=t?"paddingTop":"paddingBottom",a=n[i],o=parseFloat(getComputedStyle(document.body)[i])||0;return n[i]=`${o+e.offsetHeight}px`,()=>{n[i]=a}}var it=/^#[0-9a-f]{3,8}$/i,$e={system:"system-ui,sans-serif",serif:"Georgia,serif",mono:"ui-monospace,monospace"},Se="hm_pv",rt={turnstile:["challenges.cloudflare.com/turnstile/v0","turnstile"],hcaptcha:["js.hcaptcha.com/1","hcaptcha"],recaptcha:["www.google.com/recaptcha","grecaptcha"],friendlycaptcha:["cdn.jsdelivr.net/npm/friendly-challenge@0.9.18","friendlyChallenge"]},be,ot=()=>be,qe,Ie=e=>{be={value:Math.max(0,Number(e.value)||0),items:Math.max(0,Math.floor(Number(e.items)||0))},qe?.()},oe=globalThis,at=e=>[e].flat().filter(t=>t!==void 0&&t!==!1&&t!=="").map(String),st=(e=[],t)=>e.every(n=>{let i=at(t[n.field]);return n.op==="filled"?!!i.length:n.op==="empty"?!i.length:n.op==="neq"?!i.includes(n.value):n.op==="contains"?i.some(a=>a.toLowerCase().includes(n.value.toLowerCase())):i.includes(n.value)});function lt(e){let t=(a,o)=>a&&it.test(a)?a:o,n=t(e?.primary,"#1f6feb"),i=e?.buttonStyle!=="outline";return`:host{all:initial}.box{font:15px/1.5 ${$e[e?.font??"system"]??$e.system};background:${t(e?.background,"#fff")};color:${t(e?.text,"#111")};padding:20px;border-radius:${Math.min(32,Number(e?.radius??8))|0}px;box-shadow:0 4px 24px #0004;max-width:min(92vw,400px);box-sizing:border-box}.pop{position:fixed;inset:0;display:grid;place-items:center;background:#0006;z-index:2147483000}.fly{position:fixed;right:16px;bottom:16px;z-index:2147483000}label{display:block;margin:10px 0}input:not([type=checkbox]):not([type=radio]),select{display:block;width:100%;box-sizing:border-box;padding:8px;margin-top:4px}fieldset{border:0;padding:0;margin:0}button{cursor:pointer;padding:9px 16px;border:2px solid ${n};border-radius:inherit;background:${i?n:"transparent"};color:${i?"#fff":n};margin:8px 8px 0 0}button.x{position:absolute;top:6px;right:10px;border:0;background:none;color:inherit;font-size:20px}.box{position:relative}.wheel{width:150px;height:150px;border-radius:50%;margin:8px auto;transition:transform 3s ease-out}.err{color:#b42318}.hp{position:absolute;left:-9999px}img{max-height:40px;display:block;margin-bottom:8px}${et}`}function g(e,t={},...n){let i=Object.assign(document.createElement(e),t);return i.append(...n),i}function dt(e,t){let n=!!e.required;if(e.type==="password")return g("label",{},e.label??"",g("input",{type:"password",name:e.key,required:n,autocomplete:"new-password"}));if(e.type==="company"){let o=`hm-co-${e.key}-${Math.random().toString(36).slice(2,8)}`,u=g("datalist",{id:o}),p=g("input",{type:"text",name:e.key,required:n,autocomplete:"organization"});p.setAttribute("list",o);let s;return p.addEventListener("input",()=>{clearTimeout(s);let r=p.value.trim();r.length<2||(s=setTimeout(()=>{t(r).then(l=>u.replaceChildren(...l.map(b=>g("option",{value:b}))))},250))}),g("label",{},e.label??"",p,u)}if(e.type==="freetext")return g(e.style==="heading"?"strong":"p",{},(e.text??"").replace(/<[^>]*>/g,""));if(e.type==="textarea")return g("label",{},e.label??"",g("textarea",{name:e.key,required:n}));if(e.type==="hidden")return g("input",{type:"hidden",name:e.key,value:e.value??""});if(e.type==="checkbox"||e.type.startsWith("consent_"))return g("label",{},g("input",{type:"checkbox",name:e.key,required:n}),` ${e.disclosureText??e.label??""} `,...e.privacyUrl?[g("a",{href:e.privacyUrl,target:"_blank",rel:"noopener noreferrer"},"Privacy policy")]:[]);if(e.type==="radio"||e.type==="checkbox_group"||e.type==="quiz"){let o=e.type==="checkbox_group"?"checkbox":"radio",u=e.type==="quiz"?(e.choices??[]).map(s=>s.label):e.options??[],p=(s,r)=>e.type==="quiz"?e.choices?.[r]?.display??s:s;return g("fieldset",{className:"grp"},g("legend",{},e.label??""),...u.map((s,r)=>g("label",{},g("input",{type:o,name:e.key,value:s,required:n&&o==="radio"}),` ${p(s,r)}`)))}if(e.type==="select")return g("label",{},e.label??"",g("select",{name:e.key,required:n},g("option",{value:""}),...(e.options??[]).map(o=>g("option",{},o))));let i={email:"email",phone:"tel",number:"number",rating:"number",date:"date",url:"url",datetime:"datetime-local",slider:"range",file:"file"}[e.type]??"text",a=e.type==="slider"?{min:e.min,max:e.max,step:e.step}:e.type==="rating"?{min:1,max:e.max}:{};return g("label",{},e.label??"",g("input",{type:i,name:e.key,required:n,...a}))}function he(e){var t;let n={};for(let i of e.querySelectorAll("[name]"))if(!(i.name==="website"||i.type==="file"||i.disabled||i.name.endsWith("-response")||i.name.endsWith("-solution"))){if(i.closest(".grp")){i.checked&&(i.type==="radio"?n[i.name]=i.value:(n[t=i.name]??(n[t]=[])).push(i.value));continue}n[i.name]=i.type==="checkbox"?i.checked:i.value}return n}var fe=e=>!!e&&/^https?:/.test(e)&&!!(location.href=e);function ct(e,t,n){let i=Object.fromEntries(e.outcomes.map(a=>[a.key,0]));for(let a of t)for(let[o,u]of Object.entries(a.choices?.find(p=>p.label===n[a.key])?.scores??{}))o in i&&(i[o]=i[o]+u*(a.weight??1));return e.outcomes.reduce((a,o)=>!a||i[o.key]>i[a.key]?o:a,void 0)}var ut=e=>e.querySelectorAll("input:not([type=hidden]),select,textarea").forEach(t=>{t.required=!1,t.type==="checkbox"||t.type==="radio"?t.checked=!1:t.value=""});function pt(e,t,n,i,a=!1){let o=e.definition,u=Date.now(),p={authorization:`Bearer ${n.siteKey}`},s=t.attachShadow({mode:"open"}),r=lt(o.theme);if("adoptedStyleSheets"in s&&typeof CSSStyleSheet<"u"){let f=new CSSStyleSheet;f.replaceSync(r),s.adoptedStyleSheets=[f]}else s.append(g("style",{},r));let l=0,b=g("p",{className:"err",role:"alert"}),y=[],d=async f=>{try{let v=await fetch(`${n.endpoint.replace(/\/$/,"")}/ingest/v1/forms/${e.id}/companies?q=${encodeURIComponent(f)}`,{headers:p});return v.ok?(await v.json()).items:[]}catch{return[]}},m=o.steps.map(f=>g("fieldset",{},...f.title?[g("strong",{},f.title)]:[],...f.fields.map(v=>{let k=dt(v,d);return y.push([v,k]),k}))),h=m.length-1,S=!!o.saveEachStep&&h>0,E="",C,N=new Set,P=f=>{h>0&&n.client.track("form_step",{formId:e.id,versionId:e.versionId,step:l,action:f})},J=g("div"),j=g("input",{name:"website",tabIndex:-1,autocomplete:"off"}),U=g("button",{type:"button"}),W=g("button",{type:"button"},"Back"),K=g("button",{type:"button",className:"skip"},"No thanks"),L=g("form",{noValidate:!1},...m,g("div",{className:"hp",ariaHidden:"true"},j),J,b,W,U,K),H=e.kind==="bar",A=g("div",{className:"box",role:H?"region":"dialog",ariaLabel:"Sign up"},...o.theme?.logoUrl&&o.theme.logoUrl.startsWith("https:")&&!H?[g("img",{src:o.theme.logoUrl,alt:""})]:[],...H&&o.bar?.text?[g("p",{className:"msg"},o.bar.text)]:[],L);e.kind==="popup"&&A.setAttribute("aria-modal","true");let O=o.captcha&&rt[o.captcha.provider],D="";if(O&&o.captcha?.provider==="friendlycaptcha"){let f=()=>new window.friendlyChallenge.WidgetInstance(J,{sitekey:o.captcha.siteKey,doneCallback:v=>D=v});window.friendlyChallenge?f():document.head.append(g("script",{src:`https://${O[0]}/widget.min.js`,async:!0,onload:f}))}else if(O&&o.captcha){let[f,v]=O,k=()=>oe[v].render(J,{sitekey:o.captcha.siteKey,callback:I=>D=I,"expired-callback":()=>D=""});oe[v]?.render?k():document.head.append(g("script",{src:`https://${f}/api.js?render=explicit`,async:!0,onload:()=>oe[v].ready?oe[v].ready(k):k()}))}let ee={},B=()=>{let f=(k,I)=>{k.hidden=!I,k.querySelectorAll("[name]").forEach(R=>R.disabled=!I)};y.forEach(([,k])=>f(k,!0));let v={...ee,...he(L)};for(let[k,I]of y)st(k.when,v)||(f(I,!1),delete v[k.key])};if(y.some(([f])=>f.when)&&(L.addEventListener("input",B),B()),o.countdown){let f=o.countdown,v=Date.parse(f.to),k=g("p"),I=()=>{let M=Math.max(0,(v-Date.now())/1e3|0);k.textContent=M?`${f.label} ${M/86400|0}d ${M/3600%24|0}h ${M/60%60|0}m ${M%60}s`:f.expiredText},R=setInterval(()=>{I(),t.isConnected||clearInterval(R)},1e3);I(),A.prepend(k)}e.kind!=="embed"&&A.prepend(g("button",{className:"x",type:"button",ariaLabel:"Close",onclick:()=>$(!1)},"\xD7"));let q=o.quiz?.emailCapture==="after"&&h>0?g("p",{className:"msg",role:"status"}):null;q&&m[h].prepend(q);let Q=()=>{if(m.forEach((v,k)=>v.hidden=k!==l),q&&l===h){let v=ct(o.quiz,y.map(([k])=>k),he(L));q.textContent=v?`${v.title}${v.text?` ${v.text}`:""}`:""}W.hidden=l===0||S,K.hidden=!o.steps[l]?.optional;let f=o.steps[l]?.submitLabel;U.textContent=f??(l===h?o.submitLabel??"Submit":"Next"),U.type=l===h||S?"submit":"button",N.has(l)||(N.add(l),P("reached"))},Y=()=>(m[l]?.querySelector("input:not([type=hidden]),select,textarea")??U).focus();U.addEventListener("click",()=>{if(l<h&&!S){let f=[...m[l].querySelectorAll("input,select")].find(v=>!v.checkValidity());f?f.reportValidity():(P("completed"),l++,Q(),Y())}}),W.addEventListener("click",()=>{l--,Q(),Y()}),K.addEventListener("click",()=>{P("skipped"),ut(m[l]),l<h?(l++,Q(),Y()):S&&C?re(C):L.requestSubmit()});let ie=f=>(f.type==="redirect"||f.type==="download")&&fe(f.url),re=f=>{let v=f.success;if(ie(v))return;let k=g("p",{role:"status"},`${v.text??"Thanks!"}${v.type==="coupon"&&v.code?` Code: ${v.code}`:""}${f.pendingConfirmation?" Check your email to confirm.":""}`),I=f.spin&&o.spin?g("div",{className:"wheel"}):null;if(I){let _=o.spin.segments.length;I.style.background=`conic-gradient(${Array.from({length:_},(X,V)=>`hsl(${V*360/_} 70% ${V%2?60:45}%) ${V*100/_}% ${(V+1)*100/_}%`)})`,k.hidden=!0,setTimeout(()=>{I.style.transform=`rotate(${1440-(f.spin.index+.5)/_*360}deg)`},50),setTimeout(()=>{k.hidden=!1},3100)}let R=g("button",{type:"button",onclick:()=>$(!0)},"Close"),M=(f.quiz?.products??[]).map(_=>g(_.url&&/^https?:/.test(_.url)?"a":"span",{className:"msg",..._.url&&/^https?:/.test(_.url)?{href:_.url}:{}},..._.imageUrl?.startsWith("https:")?[g("img",{src:_.imageUrl,alt:""})]:[],_.title));L.replaceChildren(...v.title?[g("strong",{},v.title)]:[],...I?[g("div",{},"\u25BC"),I]:[],k,...M,...e.kind==="embed"?[]:[R]),Z=!0,e.kind!=="embed"&&R.focus()};L.addEventListener("submit",async f=>{if(f.preventDefault(),O&&!D&&!(S&&l>0)){b.textContent="Please complete the captcha";return}U.disabled=!0;let v=k=>{b.textContent=o.failureText??k,U.disabled=!1,O&&!(S&&l>0)&&(D="",oe[O[1]]?.reset?.())};try{let k=n.client.anonymousId(),I=`${n.endpoint.replace(/\/$/,"")}/ingest/v1/forms/${e.id}`,R=S?m[l]:L,M=he(R);for(let V of R.querySelectorAll("input[type=file]")){if(!V.files?.[0])continue;let ce=new FormData;ce.append("field",V.name),ce.append("file",V.files[0]);let we=await fetch(`${I}/upload`,{method:"POST",headers:{...p,"idempotency-key":crypto.randomUUID()},body:ce}),ue=await we.json();if(!we.ok||!ue.url)return v(ue.error?.message??"Upload failed");M[V.name]=ue.url}let _=await fetch(`${I}/submit`,{method:"POST",headers:{...p,"content-type":"application/json","idempotency-key":crypto.randomUUID()},body:JSON.stringify({data:M,startedAt:u,website:j.value,...D?{captchaToken:D}:{},pageUrl:location.href,...k?{anonymousId:k}:{},...S?{step:l,...E?{stepToken:E}:{}}:{}})}),X=await _.json();if(!_.ok||!X.success){if(_.status>=500&&fe(o.redirects?.error))return;v(X.error?.message??"Something went wrong");return}if(P("completed"),S&&l<h&&X.stepToken){E=X.stepToken,C=X,Z=!0,ee={...ee,...M},l++,Q(),U.disabled=!1,Y();return}re(X)}catch{fe(o.redirects?.error)||v("Network error, please try again")}}),Q();let z=e.kind==="popup"?g("div",{className:"pop",onclick:f=>{f.target===z&&$(!1)}},A):e.kind==="flyout"?g("div",{className:"fly"},A):H?g("div",{className:`bar ${o.bar?.position==="top"?"top":"bottom"}`},A):A,G=Oe(e.kind,o.teaser),T=G?g("button",{type:"button",className:"tab",ariaLabel:`${G.text}: open the sign-up form`,onclick:()=>w(!0)},G.text):null;T&&(T.style.cssText=tt(G.side));let Z=!1,te=!1,ne=null,c=()=>{},x=f=>{f.key==="Escape"&&z.isConnected&&e.kind!=="embed"&&$(!1)};function w(f=e.kind==="popup"){z.isConnected||!t.isConnected||(ne=document.activeElement,T?.remove(),s.append(z),H&&(c=nt(z,o.bar?.position==="top")),e.kind!=="embed"&&document.addEventListener("keydown",x),te||(te=!0,n.client.formView(e.id,e.versionId)),f&&Y())}function $(f){document.removeEventListener("keydown",x),c();let v=ne;if(i(f||Z),T&&!(f||Z)){z.remove(),s.append(T),T.focus();return}t.remove(),v?.focus?.()}return T&&a?s.append(T):w(),()=>{te||w()}}async function mt(e){let t=[];try{let d=await fetch(`${e.endpoint.replace(/\/$/,"")}/ingest/v1/forms?v=${e.client.anonymousId()??crypto.randomUUID()}`,{headers:{authorization:`Bearer ${e.siteKey}`}});if(!d.ok)return;t=(await d.json()).forms}catch{return}let n=e.allowed(),i=n?Number(e.get(Se)??0):0,a=Me(e,n),o;if(t.some(d=>ge(d.targeting??{})))try{let d=e.client.anonymousId(),m=await fetch(`${e.endpoint.replace(/\/$/,"")}/ingest/v1/forms/visitor${d?`?aid=${encodeURIComponent(d)}`:""}`,{headers:{authorization:`Bearer ${e.siteKey}`}});m.ok&&(o=await m.json())}catch{}let u=matchMedia("(pointer:coarse)").matches||innerWidth<768,p=new Map,s=[],r=new Set,l="",b=()=>{l!==location.href&&(l=location.href,s.forEach(d=>d()),s=[],r=new Set,i++,n&&e.set(Se,String(i)),t.forEach(y))};qe=()=>t.forEach(d=>{d.targeting?.cart&&!r.has(d.id)&&y(d)});function y(d){let m=d.targeting??{},h=e.get(`hm_c_${d.id}`);if(p.has(d.id)||!Ue(m,{path:location.pathname,mobile:u,returning:i>1,pageViews:i,now:Date.now(),lastClosedAt:h?Number(h):void 0,submitted:e.get(`hm_s_${d.id}`)==="1",...a,cart:be,productPage:Ae(document),flags:o}))return;r.add(d.id);let S=C=>{let N=d.kind==="embed"?document.querySelector(`[data-hm-form="${d.id}"]`):document.body.appendChild(g("div"));!N||p.has(d.id)||p.set(d.id,pt(d,N,e,P=>{n&&(e.set(`hm_c_${d.id}`,String(Date.now())),P&&e.set(`hm_s_${d.id}`,"1")),P||e.client.track("form_dismiss",{formId:d.id,versionId:d.versionId})},C))},E=Oe(d.kind,d.definition.teaser);E?.show==="before_trigger"&&S(!0),s.push(Xe(d.kind==="embed"?{}:m,u,()=>{let C=p.get(d.id);C?C():S(!!E&&E.show!=="after_close")}))}for(let d of["pushState","replaceState"]){let m=history[d].bind(history);history[d]=(...h)=>{m(...h),b()}}addEventListener("popstate",b),b()}function Me(e,t){let n=t?e.get("hm_ft"):null;if(n)try{return JSON.parse(n)}catch{}let i=new URLSearchParams(location.search),a={};for(let p of["source","medium","campaign"]){let s=i.get(`utm_${p}`);s&&(a[p]=s.slice(0,100))}let o="";try{let p=document.referrer?new URL(document.referrer).hostname:"";o=p===location.hostname?"":p}catch{}let u={utm:a,referrer:o};return t&&e.set("hm_ft",JSON.stringify(u)),u}function ht(e){let t=e;return!t||typeof t.total_price!="number"||typeof t.item_count!="number"?null:{value:t.total_price/100,items:t.item_count}}async function ft(e,t,n=fetch){if(e==="shopify")try{let i=await n("/cart.js",{credentials:"same-origin",headers:{accept:"application/json"}}),a=i.ok?ht(await i.json()):null;a&&t(a)}catch{}}var yt={banner:"position:fixed;left:0;right:0;top:0;padding:12px 44px 12px 16px",modal:"position:fixed;left:50%;top:50%;transform:translate(-50%,-50%);max-width:min(92vw,440px);padding:24px;border-radius:8px;box-shadow:0 4px 24px #0004",slide_in:"position:fixed;right:16px;bottom:16px;max-width:min(92vw,360px);padding:20px;border-radius:8px;box-shadow:0 4px 24px #0004"};async function gt(e){let t=e.endpoint.replace(/\/$/,""),n={authorization:`Bearer ${e.siteKey}`},i=e.client.anonymousId(),a=[];try{let m=await fetch(`${t}/ingest/v1/site-messages${i?`?aid=${encodeURIComponent(i)}`:""}`,{headers:n});m.ok&&(a=(await m.json()).messages)}catch{return}if(!a.length)return;let o;if(a.some(m=>ge(m.targeting??{})))try{let m=await fetch(`${t}/ingest/v1/forms/visitor${i?`?aid=${encodeURIComponent(i)}`:""}`,{headers:n});m.ok&&(o=await m.json())}catch{}let u=e.allowed(),p=u?Number(e.get("hm_pv")??1):1,s={path:location.pathname,mobile:matchMedia("(pointer:coarse)").matches||innerWidth<768,returning:p>1,pageViews:p,now:Date.now(),...Me(e,u),cart:ot(),productPage:Ae(document),flags:o},r=[...a].sort((m,h)=>Number(h.queued)-Number(m.queued)).find(m=>{let h=e.get(`hm_m_${m.id}`);return Ue(m.targeting??{},{...s,lastClosedAt:h?Number(h):void 0,submitted:!1})&&!(h&&m.targeting?.frequencyDays===void 0)});if(!r)return;let l=document.createElement("div"),b=l.attachShadow({mode:"open"}),y=document.createElement("div");if(y.setAttribute("role",r.style==="modal"?"dialog":"status"),y.style.cssText=`${yt[r.style]};background:#fff;color:#111;font:15px/1.5 system-ui,sans-serif;z-index:2147483000;box-sizing:border-box`,y.innerHTML=r.html,r.ctaLabel&&r.ctaUrl&&/^https?:\/\//.test(r.ctaUrl)){let m=Object.assign(document.createElement("a"),{href:r.ctaUrl,textContent:r.ctaLabel,rel:"noopener"});m.style.cssText="display:inline-block;margin-top:10px;padding:8px 14px;background:#1f6feb;color:#fff;border-radius:6px;text-decoration:none",y.append(m)}let d=Object.assign(document.createElement("button"),{type:"button",textContent:"\xD7",ariaLabel:"Close"});d.style.cssText="position:absolute;top:6px;right:10px;border:0;background:none;font-size:20px;cursor:pointer;color:inherit",d.addEventListener("click",()=>{l.remove(),e.allowed()&&e.set(`hm_m_${r.id}`,String(Date.now()))}),y.append(d),b.append(y),document.body.append(l),fetch(`${t}/ingest/v1/site-messages/${r.id}/shown`,{method:"POST",headers:{...n,"content-type":"application/json"},body:JSON.stringify(i?{aid:i}:{})}).catch(()=>{})}function bt(e){let t=new Map,n={get:i=>t.get(i)??null,set:(i,a)=>{t.set(i,a)},del:i=>{t.delete(i)}};try{if(e==="local"){let i=localStorage;return{get:a=>i.getItem(a),set:(a,o)=>i.setItem(a,o),del:a=>i.removeItem(a)}}if(e==="cookie")return{get:i=>document.cookie.split("; ").find(a=>a.startsWith(`${i}=`))?.slice(i.length+1)??null,set:(i,a)=>{document.cookie=`${i}=${a}; max-age=31536000; path=/; SameSite=Lax`},del:i=>{document.cookie=`${i}=; max-age=0; path=/`}}}catch{}return n}function vt(e,t,n){let i=o=>`${e.replace(/\/$/,"")}${o}`,a=o=>new Promise(u=>setTimeout(u,o));return{async send(o,u){for(let p=0,s=crypto.randomUUID();p<5;p++){try{let r=await fetch(i(o),{method:"POST",keepalive:!0,body:JSON.stringify(u),headers:{"content-type":"application/json",authorization:`Bearer ${t}`,"idempotency-key":s}});if(r.status<400)return!0;if(r.status<500&&r.status!==429){let l=await r.json().catch(()=>null);return n(Object.assign(new Error(l?.error?.message??`HTTP ${r.status}`),{status:r.status,code:l?.error?.code})),null}}catch(r){n(r)}await a(500*2**p+Math.random()*500)}return!1},get:o=>fetch(`${i(o)}?k=${encodeURIComponent(t)}`).then(u=>u.ok?u.json():null).catch(()=>null),post:(o,u)=>fetch(i(o),{method:"POST",body:JSON.stringify(u),headers:{"content-type":"application/json",authorization:`Bearer ${t}`}}).then(p=>p.json()),beacon:(o,u)=>navigator.sendBeacon?.(`${i(o)}?k=${encodeURIComponent(t)}`,new Blob([JSON.stringify(u)],{type:"text/plain"}))??!1}}var _e="0.4.6",Ee=50,De=50,le="hm_aid",Ce="hm_consent",xt="hm_queue:",wt=3e3,Pe=()=>crypto.randomUUID();function Le(e,t={}){return{mode:e.consentMode??t.consentMode??"require-consent",bufferUntilConsent:e.bufferUntilConsent??t.bufferUntilConsent??!1,stripQuery:e.stripQuery??t.stripQuery??!1,allowParams:e.allowParams??(t.allowParams?.length?t.allowParams:void 0),autoPageViews:e.autoPageViews??t.autoPageViews??!1,pageViewRoutes:e.pageViewRoutes??t.pageViewRoutes??[],identify:{email:!0,phone:!0,externalId:!0,...t.identify,...e.identify},maxSize:Math.min(e.batch?.maxSize??t.batchSize??20,De),flushMs:e.batch?.flushMs??t.flushMs??2e3,maxQueue:e.maxQueue??t.maxQueue??200,autocapture:e.autocapture??t.autocapture??!1,trackVideo:e.trackVideo??t.trackVideo??!1}}function kt(e,t){return e.length?e.some(n=>{if(n.endsWith("*"))return t.startsWith(n.slice(0,-1));let i=n.replace(/\/$/,"");return t===i||t.startsWith(`${i}/`)}):!0}function $t(e){let t=Le(e),n=bt(e.storage??"local"),i={},a=(c,x)=>(i[c]??[]).forEach(w=>w(x)),o=e.debug??!1,u=(...c)=>o&&console.debug("[hermetica]",...c),p=null,s=c=>{p=c,a("error",c)},r=vt(e.endpoint,e.siteKey,s),l=(()=>{try{return JSON.parse(n.get(Ce)??"null")}catch{return null}})(),b=()=>l??(t.mode==="require-consent"?{analytics:!1,marketing:!1}:{analytics:!0,marketing:!0}),y=b(),d=l!==null||t.mode!=="require-consent",m=!1,h=[],S,E=null,C=Promise.resolve(),N=[],P=(e.storage??"local")==="local"?n:null,J=`${xt}${e.siteKey}`,j=()=>{if(P)try{let c=d&&y.analytics?[...N,...h].slice(-t.maxQueue):[];c.length?P.set(J,JSON.stringify(c)):P.del(J)}catch{}},U=!e.remoteConfig,W=[],K=c=>{U?c():W.length<Ee&&W.push(c)},L=()=>(E??(E=n.get(le)),E||(E=Pe(),n.set(le,E)),E),H=(()=>{let c={};try{new URL(location.href).searchParams.forEach((x,w)=>{w.startsWith("utm_")&&(c[w.slice(4)]=x.slice(0,256))})}catch{}return c})(),A=c=>{if(!t.stripQuery&&!t.allowParams)return c;try{let x=new URL(c),w=new Set(t.allowParams??[]);for(let $ of Array.from(x.searchParams.keys()))w.has($)||x.searchParams.delete($);return x.hash="",x.href}catch{return c}},O=()=>({url:location.href,referrer:document.referrer,title:document.title,path:location.pathname}),D=c=>({page:{url:A(c.url),referrer:A(c.referrer),title:c.title},...Object.keys(H).length?{utm:H}:{}});function ee(c,x,w,$){if(d&&!y.analytics){u("dropped (analytics denied)",c);return}if(!d&&!t.bufferUntilConsent){u("dropped (consent not decided yet)",c);return}let f={name:c,properties:{...x,hm_sdk:_e,...globalThis.hmAd?.()},dedupeKey:Pe(),occurredAt:new Date().toISOString(),context:D($),...w};if(e.beforeSend){try{f=e.beforeSend(f)}catch(k){s(k),f=null}if(!f){u("dropped (beforeSend)",c);return}}h.push(f);let v=d?t.maxQueue:Ee;h.length>v&&h.splice(0,h.length-v),u("queued",f),d&&(j(),h.length>=t.maxSize?q():S??(S=setTimeout(()=>{q()},t.flushMs)))}let B=(c,x,w={})=>{let $=O();K(()=>ee(c,x,w,$))};function q(){if(clearTimeout(S),S=void 0,!d||!y.analytics||h.length===0)return C;let c=L(),x=h.splice(0,t.maxSize);N.push(...x);let w=x.map($=>({...$,anonymousId:c}));return C=C.then(async()=>{let $=await r.send("/ingest/v1/batch",{events:w,consent:y});N=N.filter(f=>!x.includes(f)),$?a("flush",w):$===!1&&(h.unshift(...w),h.splice(0,h.length-t.maxQueue),s(new Error("send failed"))),j(),$!==!1&&h.length&&q()}),C}let Q=()=>{if(!d||!y.analytics||h.length===0)return;let c=L(),x=[];for(;h.length;){let w=h.splice(0,De);r.beacon("/ingest/v1/batch",{events:w.map($=>({...$,anonymousId:c})),consent:y})||x.push(...w)}h=x,j()};typeof addEventListener=="function"&&addEventListener("pagehide",Q);let Y=(c={})=>B("page_view",c),ie=()=>{let c=O();K(()=>{t.autoPageViews&&kt(t.pageViewRoutes,c.path)&&ee("page_view",{},{},c)})};if(e.autoPageViews||e.remoteConfig&&e.autoPageViews!==!1){ie();for(let c of["pushState","replaceState"]){let x=history[c].bind(history);history[c]=(...w)=>{x(...w),ie()}}addEventListener("popstate",ie)}let re=()=>{t.autocapture&&typeof document<"u"&&We((c,x)=>B(c,x)),t.trackVideo&&typeof document<"u"&&Ge((c,x)=>B(c,x))},z=()=>({client:T,endpoint:e.endpoint,siteKey:e.siteKey,get:n.get,set:n.set,allowed:()=>d&&y.analytics}),G={start:async()=>{e.cart&&await ft(e.cart,Ie),await Promise.all([mt(z()),gt(z())])},setCart:Ie},T={forms:G,track:(c,x={},w={})=>B(c,x,{...w.value!==void 0?{value:w.value}:{},...w.currency?{currency:w.currency}:{},...w.dedupeKey?{dedupeKey:w.dedupeKey}:{}}),page:Y,formView:(c,x)=>B("form_view",{formId:c,...x?{versionId:x}:{}}),identify:(c,x={},w={})=>K(()=>{if(!y.marketing||d&&!y.analytics){u("identify skipped (no marketing consent)");return}let{email:$,phone:f,...v}=x,k={...c&&t.identify.externalId?{externalId:c}:{},...$&&t.identify.email?{email:$}:{},...f&&t.identify.phone?{phone:f}:{}};if(!Object.keys(k).length){u("identify skipped (identifiers not allowed for this site)");return}C.then(()=>r.send("/ingest/v1/identify",{anonymousId:L(),identifiers:k,traits:v,consent:y,...w.signature?{signature:w.signature}:{}}))}),subscribe:c=>r.send("/ingest/v1/subscribe",{...c,pageUrl:A(location.href),anonymousId:T.anonymousId()??void 0}),backInStock:c=>r.send("/ingest/v1/back-in-stock",c),consent:{get:()=>({...y}),update(c){y={...y,...c},d=!0,m=!0,n.set(Ce,JSON.stringify(y)),a("consent",{...y}),y.analytics?q():(h=[],N=[],E=null,n.del(le)),j()}},anonymousId:()=>d&&y.analytics?L():null,reset(){h=[],N=[],E=null,n.del(le),j()},flush:q,on(c,x){(i[c]??(i[c]=[])).push(x)},debug:{events:()=>[...h],lastError:()=>p,enable:()=>{o=!0},disable:()=>{o=!1},test:c=>r.post("/ingest/v1/test",{events:c??(h.length?h:[{name:"test_event",properties:{hm_sdk:_e},context:D(O())}]),consent:y})}};function Z(){if(!P)return;let c=[];try{c=JSON.parse(P.get(J)??"[]")}catch{}if(!Array.isArray(c)||!c.length||!d||!y.analytics){j();return}let x=new Set(h.map($=>$.dedupeKey)),w=c.filter($=>$&&typeof $.name=="string"&&typeof $.dedupeKey=="string"&&!x.has($.dedupeKey)&&x.add($.dedupeKey));h=[...w,...h].slice(-t.maxQueue),u("restored",w.length),S??(S=setTimeout(()=>{q()},t.flushMs))}let te=c=>K(()=>{t.mode!=="none"&&c&&T.consent.update({analytics:c.analytics===!0,marketing:c.marketing===!0})});if(e.consentSource!=="none"&&typeof addEventListener=="function"){addEventListener("hermetica:consent",x=>te(x.detail));let c=globalThis.CookieMunch;c?.hasResponse&&te({analytics:c.consent?.statistics,marketing:c.consent?.marketing})}let ne=c=>{if(!U){c&&(Object.assign(t,Le(e,c)),!m&&l===null&&(y=b(),d=t.mode!=="require-consent"),u("settings",t)),U=!0,Z(),re();for(let x of W.splice(0))x()}};return e.remoteConfig?(setTimeout(()=>ne(null),wt),r.get("/ingest/v1/config").then(c=>ne(c),()=>ne(null))):(Z(),re()),e.forms&&G.start(),T}var ye=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ae=e=>typeof e=="string"&&e?e:null,de=(e,t)=>t?{[e]:t}:{};function Te(e){if(!ye(e))return{};let t=[e];for(let n of[e.data,e.userInfo,e.notification,e.additionalData])ye(n)&&t.push(n,n.data,n.additionalData);return Object.assign({},...t.filter(ye))}function Ne(e,t,n){let i=e.identity(),a=e.device??{};return{data:{type:n,attributes:{token:t.token,platform:e.platform,vendor:t.vendor,enablement_status:t.enablementStatus??"AUTHORIZED",background:t.background??"AVAILABLE",device_metadata:{device_id:i.anonymousId??"",sdk_version:e.sdkVersion??"app-0.4.6",device_model:a.deviceModel??"",os_name:a.osName??e.platform,os_version:a.osVersion??"",app_name:a.appName??"",app_version:a.appVersion??"",app_build:a.appBuild??"",app_id:a.appId??"",environment:t.environment??"release"},profile:{data:{type:"profile",attributes:{...de("email",i.email),...de("phone_number",i.phoneNumber),...de("external_id",i.externalId),...de("anonymous_id",i.anonymousId)}}}}}}}function St(e){let t=o=>`${e.endpoint.replace(/\/$/,"")}${o}?company_id=${encodeURIComponent(e.siteKey)}`,n=e.retryMs??500;async function i(o,u){let p=crypto.randomUUID();for(let s=0;s<5;s++){try{let r=await fetch(t(o),{method:"POST",body:JSON.stringify(u),headers:{"content-type":"application/json",authorization:`Bearer ${e.siteKey}`,"idempotency-key":p}});if(r.status<500&&r.status!==429)return r.ok}catch{}s<4&&await new Promise(r=>setTimeout(r,n*2**s+Math.random()*n))}return!1}let a=o=>typeof o=="string"?o||null:ae(Te(o).hermetica_message_id);return{register:o=>i("/client/push-tokens",Ne(e,o,"push-token")),unregister:o=>i("/client/push-token-unregister",Ne(e,o,"push-token-unregister")),opened(o){let u=Te(o),p=ae(u.hermetica_message_id);return p&&e.track("$opened_push",{hermetica_message_id:p}),ae(u.deep_link)??ae(u.url)??ae(u.hermetica_url)},received(o){let u=a(o);return u&&e.track("$received_push",{hermetica_message_id:u}),!!u}}}var ve=e=>{try{let t=new URL(e,location.href);return t.protocol==="https:"||t.protocol==="http:"?t.href:null}catch{return null}};function It(e){let t=document.createElement("template");return t.innerHTML=e,t.content.querySelectorAll("script,style,iframe,object,embed,link,meta,base,form").forEach(n=>n.remove()),t.content.querySelectorAll("*").forEach(n=>{for(let i of Array.from(n.attributes))(i.name.startsWith("on")||(i.name==="href"||i.name==="src"||i.name==="action")&&!ve(i.value))&&n.removeAttribute(i.name)}),t.content}var F=(e,t,n)=>{let i=document.createElement(e);return i.style.cssText=t,n!==void 0&&(i.textContent=n),i};function _t(e,t){let n=e.style,i=e.layout==="banner_top"||e.layout==="banner_bottom",a=F("div",`position:fixed;z-index:2147483000;display:flex;${i?`left:0;right:0;${e.layout==="banner_top"?"top:0":"bottom:0"};`:`inset:0;background:rgba(0,0,0,.5);align-items:${e.layout==="bottom_sheet"?"flex-end":"center"};justify-content:center;`}`);a.setAttribute("data-hermetica-inapp",e.id);let o=e.layout==="fullscreen",u=e.layout==="bottom_sheet",p=F("div",`background:${n.background};color:${n.textColor};font:16px/1.4 system-ui,sans-serif;box-sizing:border-box;padding:20px;position:relative;${i?"width:100%;":o?"width:100%;height:100%;overflow:auto;":`width:min(92vw,420px);${u?`border-radius:${n.radius}px ${n.radius}px 0 0;width:min(100vw,520px);`:`border-radius:${n.radius}px;`}`}`);if(p.setAttribute("role","dialog"),p.setAttribute("aria-modal",String(!i)),e.content.html)p.append(It(e.content.html));else for(let s of e.content.blocks)if(s.type==="heading")p.append(F("h2","margin:0 0 8px;font-size:20px",s.text));else if(s.type==="text")p.append(F("p","margin:0 0 12px",s.text));else if(s.type==="image"&&s.url&&ve(s.url)){let r=F("img","max-width:100%;display:block;margin:0 0 12px");r.src=s.url,r.alt=s.alt??"",p.append(r)}else if(s.type==="buttons"){let r=F("div","display:flex;gap:8px;flex-wrap:wrap");for(let l of s.buttons??[]){let b=l.style!=="secondary",y=F("button",`cursor:pointer;padding:10px 16px;border-radius:${Math.min(n.radius,10)}px;font:inherit;border:1px solid ${n.accentColor};background:${b?n.accentColor:"transparent"};color:${b?"#fff":n.accentColor}`,l.label);y.addEventListener("click",()=>t.click(l)),r.append(y)}p.append(r)}if(n.dismissible){let s=F("button","position:absolute;top:8px;right:8px;border:0;background:transparent;color:inherit;font-size:20px;cursor:pointer","\xD7");s.setAttribute("aria-label","Close"),s.addEventListener("click",t.dismiss),p.append(s)}return a.append(p),a}function Et(e){let t=e.endpoint.replace(/\/$/,""),n={"content-type":"application/json",authorization:`Bearer ${e.siteKey}`},i=(()=>{try{return sessionStorage.getItem("hm_sid")??(sessionStorage.setItem("hm_sid",crypto.randomUUID()),sessionStorage.getItem("hm_sid"))}catch{return crypto.randomUUID()}})(),a=()=>({...e.identity?.(),anonymousId:e.anonymousId()??void 0}),o=new Set,u=(r,l,b)=>{fetch(`${t}/client/in-app-events?company_id=${encodeURIComponent(e.siteKey)}`,{method:"POST",keepalive:!0,headers:{...n,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({events:[{messageId:r.id,variant:r.variant,type:l,platform:e.platform??"web",sessionId:i,...b?{button:b}:{}}],profile:a()})}).catch(()=>{})};function p(r){if(o.has(r.id))return;o.add(r.id);let l=()=>b.remove(),b=_t(r,{dismiss:()=>{u(r,"dismiss"),l()},click:y=>{if(u(r,"click",y.label),l(),y.action==="dismiss"||!y.value||e.onAction?.(y.action,y.value,r)===!1||y.action==="event")return;let d=ve(y.value);d&&location.assign(d)}});document.body.append(b),u(r,"impression")}async function s(r={type:"page_url"}){let l=a();if(!l.anonymousId&&!l.externalId&&!l.email&&!l.phoneNumber)return[];let b=new URLSearchParams({company_id:e.siteKey,platform:e.platform??"web",trigger:r.type,session_id:i});"name"in r&&b.set("name",r.name),r.type==="page_url"&&b.set("url",r.url??location.href),r.type==="event"&&r.properties&&b.set("properties",JSON.stringify(r.properties)),l.externalId&&b.set("external_id",l.externalId),l.email&&b.set("email",l.email),l.phoneNumber&&b.set("phone_number",l.phoneNumber),l.anonymousId&&b.set("anonymous_id",l.anonymousId);let y=await fetch(`${t}/client/in-app-messages?${b}`,{headers:{authorization:n.authorization}}).catch(()=>null);if(!y?.ok)return[];let d=(await y.json()).items;return d[0]&&p(d[0]),d}return{trigger:s,display:p}}function je(e){let{platform:t,device:n,sdkVersion:i,inApp:a=!0,onDeepLink:o,...u}=e,p=$t(u),s={},r=null,l=()=>({...s,anonymousId:p.anonymousId()}),b=St({siteKey:e.siteKey,endpoint:e.endpoint,platform:t,identity:l,track:(m,h)=>p.track(m,h),...n?{device:n}:{},...i?{sdkVersion:i}:{}}),y=()=>{r&&b.register(r)},d=a&&typeof document<"u"?Et({siteKey:e.siteKey,endpoint:e.endpoint,platform:t,anonymousId:p.anonymousId,identity:()=>({...s}),onAction:(m,h,S)=>{if(m==="event")return p.track(h,{hermetica_message_id:S.id}),!1;if(o)return o(h),!1}}):null;return typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&p.flush()}),d&&d.trigger({type:"app_open"}),{...p,track(m,h={},S){p.track(m,h,S),d?.trigger({type:"event",name:m,properties:h})},identify(m,h={}){let S=h;m&&(s.externalId=m),typeof S.email=="string"&&(s.email=S.email),typeof S.phone=="string"&&(s.phoneNumber=S.phone),p.identify(m,h),y()},reset(){for(let m of Object.keys(s))delete s[m];p.reset(),y()},screen(m,h={}){p.page({screen:m,...h}),d?.trigger({type:"screen_view",name:m})},setProfile(m){Object.assign(s,m),y()},async setPushToken(m){return r=m,b.register(m)},async unregisterPushToken(){let m=r;return r=null,m?b.unregister(m):!0},handlePushOpened(m){let h=b.opened(m);return h&&o?.(h),h},handlePushReceived:m=>b.received(m)}}var Ct=()=>new Promise(e=>{if(globalThis.cordova===void 0)return e();document.addEventListener("deviceready",()=>e(),{once:!0})}),xe=e=>new Promise(t=>e(t,()=>t(!1)));async function Pt(e){await Ct();let t=globalThis,{firebase:n=t.FirebasePlugin,cordovaDevice:i=t.device,requestPushPermission:a=!1,pushEnvironment:o="release",...u}=e,p=i?.platform.toLowerCase()==="ios"?"ios":"android",s={...i?.model?{deviceModel:i.model}:{},osName:p,...i?.version?{osVersion:i.version}:{},...u.device},r=je({...u,platform:p,device:s,sdkVersion:"cordova-0.4.6"}),l=!1,b=d=>{if(!d)return;let m={token:d,vendor:"fcm",environment:o,enablementStatus:l?"AUTHORIZED":"DENIED"};r.setPushToken(m)};async function y(){return n?(l=await xe((d,m)=>n.hasPermission(d,m))||await xe((d,m)=>n.grantPermission(d,m)),n.getToken(b,()=>{}),l):!1}return n&&(n.onTokenRefresh(b,()=>{}),n.onMessageReceived(d=>{d.tap?r.handlePushOpened(d):r.handlePushReceived(d)},()=>{}),a?y():xe((d,m)=>n.hasPermission(d,m)).then(d=>{d&&y()})),{...r,enablePush:y}}