web-push-notifications 3.104.0 → 3.104.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("preact"),require("preact/compat"),require("preact/jsx-runtime"));else if("function"==typeof define&&define.amd)define(["preact","preact/compat","preact/jsx-runtime"],t);else{var n="object"==typeof exports?t(require("preact"),require("preact/compat"),require("preact/jsx-runtime")):t(e.preact,e.preactCompat,e.jsxRuntime);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,(e,t,n)=>(()=>{"use strict";var o={524(t){t.exports=e},873(e){e.exports=t},247(e){e.exports=n}};const i={};function r(e){const t=i[e];if(void 0!==t)return t.exports;const n=i[e]={exports:{}};return o[e](n,n.exports,r),n.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};let s={};r.r(s),r.d(s,{WebPopupsWidget:()=>vo});const a=/^(https?:|mailto:|tel:)/i,c="#101828",l="#667085",u="#FFFFFF",d="#FFFFFF",p="#2970FF",h=c,m=l,f="#FFFFFF",g={h1:{fontSize:24,fontWeight:600,lineHeight:1.25},h2:{fontSize:18,fontWeight:600,lineHeight:1.3},h3:{fontSize:16,fontWeight:600,lineHeight:1.35},body:{fontSize:14,fontWeight:"normal",lineHeight:1.5},caption:{fontSize:12,fontWeight:"normal",lineHeight:1.4},eyebrow:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",lineHeight:1.4},icon:{fontSize:24,lineHeight:1.2}},b={h1:1,h2:1,h3:1,icon:1,eyebrow:.8,body:.9,caption:.75};function y(e,t,n){return n?function(e,t){if(t>=1)return e;const n=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(e)?.[1];if(!n)return e;const o=3===n.length?n.split("").map(e=>e+e).join(""):n,[i,r,s]=[0,2,4].map(e=>parseInt(o.slice(e,e+2),16));return`rgba(${i}, ${r}, ${s}, ${t})`}(t.textInverse,b[e]??1):"icon"!==e?"caption"===e||"eyebrow"===e?t.textSecondary:t.text:void 0}const v=["h1","h2","h3","icon"];function x(e){return"glyph"===e.type?"heading":"text"!==e.type?"action":v.includes(e.variant)?"heading":"text"}const k="8px 0 4px";function S(e,t){return{display:"block",boxSizing:"border-box",width:"100%",padding:"10px 25px",borderRadius:6,fontSize:14,fontWeight:600,fontFamily:"inherit",lineHeight:1.5,textAlign:"center",textDecoration:"none",cursor:"pointer",..."secondary"===e?{backgroundColor:t.surface,color:t.accent,border:`1px solid ${t.accent}`}:{backgroundColor:t.accent,color:t.onAccent,border:"none"}}}function w(e,t=e.border){return{display:"block",boxSizing:"border-box",width:"100%",padding:"10px 12px",borderRadius:6,fontSize:14,fontFamily:"inherit",lineHeight:1.5,backgroundColor:e.surface,color:e.surfaceText,border:`1px solid ${t}`,outline:"none"}}const C="Subscribe",j="Thanks for subscribing!",M="Please check your inbox and confirm your email.",P="Save",$="Thanks! Your choice is saved.",E="Send",F="Thanks for the feedback!";const R="Something went wrong. Please try again.",A=/^\S+@\S+\.\S+$/,I="Enter a valid email",q="Required",T="Required",L="Please accept the privacy policy",N="Submit",D=R,V="\n@keyframes pw-vpopup-fade { from { opacity: 0; } }\n@keyframes pw-vpopup-slide { from { opacity: 0; translate: 0 28px; } }\n@keyframes pw-vpopup-overlay { from { opacity: 0; } }\n@keyframes pw-vpopup-page { from { opacity: 0; } }\n",z={bell:"M6 10a6 6 0 0 1 12 0c0 4 1.5 5.5 2 6H4c.5-.5 2-2 2-6M10 20a2 2 0 0 0 4 0",gift:"M3 11h18v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM2.5 7h19v4h-19zM12 7v14M12 7c-1 0-3-.2-3.5-1a2 2 0 0 1 3.5-1 2 2 0 0 1 3.5 1c-.5.8-2.5 1-3.5 1z",cart:"M2 4h2.2l2.4 11.2A2 2 0 0 0 8.6 17H19M6 7h15l-2.2 7.5H8M10.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M19.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0",chart:"M3 21h18M7 21V11M12 21V6M17 21v-8",lock:"M5 11h14v10H5zM8 11V8a4 4 0 0 1 8 0v3",calendar:"M4 6h16v15H4zM4 10h16M9 3v4M15 3v4",check:"M4 13l5 5L20 6",star:"M12 3l2.9 5.9 6.5.9-4.7 4.6 1.1 6.5-5.8-3.1-5.8 3.1 1.1-6.5L2.6 9.8l6.5-.9z",clock:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0M12 7v5l4 2",tag:"M20.6 13.4l-7.2 7.2a2 2 0 0 1-2.8 0l-7-7A2 2 0 0 1 3 12.2V5a2 2 0 0 1 2-2h7.2a2 2 0 0 1 1.4.6l7 7a2 2 0 0 1 0 2.8zM9 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0",mail:"M3 6h18v12H3zM3 7l9 6 9-6",phone:"M7 2h10a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1M10 19h4",download:"M12 3v12M7 11l5 5 5-5M4 20h16",play:"M8 5l12 7-12 7z",shield:"M12 3l8 3v6c0 5-3.4 8.6-8 10-4.6-1.4-8-5-8-10V6z",sparkle:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM18 15l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1L15 18l2.1-.9z",percent:"M19 5L5 19M8.5 8.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0M20.5 15.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0",truck:"M2 7h12v10H2zM14 10h4l3 3v4h-7M8.5 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M20 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0",ticket:"M4 7h16v4a2 2 0 0 0 0 4v3H4v-3a2 2 0 0 0 0-4zM14 7v12",user:"M20 21a8 8 0 0 0-16 0M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0"},O=Object.keys(z),_=[24,32,48],B=["Vertical","Horizontal","Columns","Rows"],H=["normal","reverse"],W=["start","center","end","stretch"],U=["start","center","end","space-between"],K=["left","center","right"],Z=["default","inverse"],G=2e3,J={px:G,"%":100,em:125,rem:125},Y=/^(\d{1,4}(?:\.\d+)?)(px|%|em|rem)$/,Q={px:G,"%":100,fr:100},X=/^(\d{1,4}(?:\.\d+)?)(px|%|fr)$/,ee=["auto","min-content","max-content"];function te(e,t){return t.includes(e)?e:void 0}function ne(e){if("number"==typeof e&&Number.isFinite(e))return Math.min(Math.max(e,0),G);if("string"!=typeof e)return;const t=Y.exec(e.trim());if(!t)return;const[,n,o]=t;return`${Math.min(parseFloat(n),J[o])}${o}`}const oe=["top","right","bottom","left"];function ie(e){if(ee.includes(e))return e;const t=X.exec(e);if(!t)return;const[,n,o]=t;return`${Math.min(parseFloat(n),Q[o])}${o}`}function re(e){return"string"==typeof e&&e.length>0?e:void 0}function se(e){const t={},n=ne(e.gap);void 0!==n&&(t.gap=n);const o=function(e){const t=ne(e);if(void 0!==t)return t;if("object"!=typeof e||null===e)return;const n={};for(const t of oe){const o=ne(e[t]);void 0!==o&&(n[t]=o)}return Object.keys(n).length>0?n:void 0}(e.padding);void 0!==o&&(t.padding=o);const i=te(e.alignItems,W);i&&(t.alignItems=i);const r=te(e.justifyContent,U);r&&(t.justifyContent=r);const s=te(e.alignContent,U);s&&(t.alignContent=s);const a=re(e.backgroundImage);a&&(t.backgroundImage=a);const c=function(e){if("number"==typeof e)return Number.isInteger(e)&&e>=1&&e<=12?e:void 0;if("string"!=typeof e)return;const t=e.trim().split(/\s+/);if(t.length<1||t.length>12)return;const n=t.map(ie);return n.every(e=>void 0!==e)?n.join(" "):void 0}(e.sizes);return void 0!==c&&(t.sizes=c),t}function ae(e,t,n){if(t>10||n.nodes<=0)return null;if("object"!=typeof e||null===e)return null;n.nodes-=1;const o=e,i="object"==typeof o.props&&null!==o.props?o.props:{};if("Content"===o.type){const e=re(i.content);if(!e)return null;const t={type:"Content",props:{content:e}},n=te(i.align,K);n&&(t.props.align=n);const o=te(i.tone,Z);return o&&"default"!==o&&(t.props.tone=o),t}if("Image"===o.type){const e=re(i.image);if(!e)return null;return{type:"Image",props:{image:e}}}if(!Array.isArray(o.children))return null;const r=te(o.type,B)??"Vertical",s=[];for(const e of o.children){const o=ae(e,t+1,n);o&&s.push(o)}const a=se(i);return"reverse"===te(i.order,H)&&(s.reverse(),"string"==typeof a.sizes&&(a.sizes=a.sizes.split(" ").reverse().join(" "))),{type:r,props:a,children:s}}function ce(e){return ae(e,0,{nodes:100})}const le=/^[a-zA-Z][a-zA-Z0-9-]*$/,ue=/^\$([a-zA-Z][a-zA-Z0-9-]*)$/;function de(e,t){return e.includes("$")?e.split(/(\s+)/).map(e=>{const n=ue.exec(e)?.[1];return void 0!==n&&Object.prototype.hasOwnProperty.call(t,n)?t[n]:e}).join(""):e}function pe(e,t){return"object"!=typeof e||null===e||0===Object.keys(t).length?e:me(e,t,0)}const he=new Set(["content","image","backgroundImage"]);function me(e,t,n){if(n>10||"object"!=typeof e||null===e)return e;const o=e,i={...o};if("object"==typeof o.props&&null!==o.props){const e={...o.props};for(const[n,o]of Object.entries(e))if(!he.has(n))if("string"==typeof o)e[n]=de(o,t);else if("object"==typeof o&&null!==o&&!Array.isArray(o)){const i={...o};for(const[e,n]of Object.entries(i))"string"==typeof n&&(i[e]=de(n,t));e[n]=i}i.props=e}return Array.isArray(o.children)&&(i.children=o.children.map(e=>me(e,t,n+1))),i}function fe(e){return"number"==typeof e?`${e}px`:e}function ge(e,t){if("string"==typeof e)return e;return`repeat(${"number"==typeof e?e:Math.max(t,1)}, 1fr)`}function be(e=0){if(!(e>0))return null;const t=`rgba(16, 24, 40, ${Math.min(e,1)})`;return`linear-gradient(${t}, ${t})`}function ye(e,t=0){const n=`url(${JSON.stringify(e)})`,o=be(t);return{backgroundImage:o?`${o}, ${n}`:n,backgroundSize:"cover",backgroundPosition:"center"}}function ve(e,t,n=0){const o=e.props??{},i={display:"grid",minWidth:0};return"Horizontal"===e.type&&(i.gridAutoFlow="column"),"Columns"===e.type&&(i.gridTemplateColumns=ge(o.sizes,e.children.length)),"Rows"===e.type&&(i.gridTemplateRows=ge(o.sizes,e.children.length)),void 0!==o.gap&&(i.gap=fe(o.gap)),void 0!==o.padding&&(i.padding=function(e){if("number"==typeof e||"string"==typeof e)return fe(e);const t=e=>void 0===e?"0":fe(e);return`${t(e.top)} ${t(e.right)} ${t(e.bottom)} ${t(e.left)}`}(o.padding)),o.alignItems&&(i.alignItems=o.alignItems),o.justifyContent&&(i.justifyContent=o.justifyContent),o.alignContent&&(i.alignContent=o.alignContent),t&&Object.assign(i,ye(t,n)),i}const xe=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function ke(e){const t=xe.exec(e.trim())?.[1];if(!t)return null;const n=3===t.length?t.split("").map(e=>e+e).join(""):t;return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))}function Se([e,t,n]){return`#${[e,t,n].map(e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")).join("")}`}function we(e,t,n){let o=n;return o<0&&(o+=1),o>1&&(o-=1),o<1/6?e+6*(t-e)*o:o<.5?t:o<2/3?e+(t-e)*(2/3-o)*6:e}function Ce(e){return e>.5?.07+.86*(1-e):e}function je(e){return e<.5?.93-e*((.93-.5)/.5):e}function Me(e,t){const n=ke(e);if(!n)return e;const[o,i,r]=function([e,t,n]){const[o,i,r]=[e/255,t/255,n/255],s=Math.max(o,i,r),a=Math.min(o,i,r),c=(s+a)/2;if(s===a)return[0,0,c];const l=s-a;let u;return u=s===o?(i-r)/l+(i<r?6:0):s===i?(r-o)/l+2:(o-i)/l+4,[u/6,c>.5?l/(2-s-a):l/(s+a),c]}(n);return Se(function([e,t,n]){if(0===t){const e=255*n;return[e,e,e]}const o=n<.5?n*(1+t):n+t-n*t,i=2*n-o;return[255*we(i,o,e+1/3),255*we(i,o,e),255*we(i,o,e-1/3)]}([o,i,"fold"===t?Ce(r):je(r)]))}function Pe(e,t,n){const o=ke(e),i=ke(t);return o&&i?Se(o.map((e,t)=>e+(i[t]-e)*n)):e}function $e(e,t){const n=ke(e);if(!n||t>=1)return e;const[o,i,r]=n;return`rgba(${o}, ${i}, ${r}, ${t})`}function Ee(e){const t=ke(e);if(!t)return!1;const[n,o,i]=t;return(.299*n+.587*o+.114*i)/255>.6}function Fe(e){return{background:Me(e.background,"fold"),accent:e.accent,text:Me(e.text,"lift"),textSecondary:Me(e.textSecondary,"lift"),textInverse:e.textInverse}}function Re(e,t){return"light"===t?{surface:d,surfaceText:c,border:"#D0D5DD",onAccent:u,error:"#D92D20",chromeIcon:l}:{surface:Pe(e.background,e.text,.08),surfaceText:e.text,border:Pe(e.background,e.text,.24),onAccent:Ee(e.accent)?c:u,error:"#FDA29B",chromeIcon:e.textSecondary}}function Ae(e){return!0===e.dark?.enabled}function Ie(e,t="light"){return"dark"===t&&Ae(e)?"dark":"light"}function qe(e,t="light"){const n=Ie(e,t),o="dark"===n?(i=e.colors,r=e.dark,{...Fe(i),...r?.colors??{}}):e.colors;var i,r;return{...o,scheme:n,...Re(o,n)}}function Te(e,t="light"){return"dark"===t&&e.srcDark?e.srcDark:e.src}function Le(e,t="light"){return"light"===Ie(e,t)?{overlay:e.overlay,boxShadow:e.boxShadow}:{overlay:e.dark?.overlay??e.overlay,boxShadow:e.dark?.boxShadow??e.boxShadow}}const Ne=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/,De=new Map;function Ve(e){const t=De.get(e);if(t)return t;try{const t=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});return De.set(e,t),t}catch{return null}}function ze(e){return!e||null!==Ve(e)}function Oe(e,t){const n=t.formatToParts(new Date(e)),o=e=>Number(n.find(t=>t.type===e)?.value??"0");return Date.UTC(o("year"),o("month")-1,o("day"),o("hour")%24,o("minute"),o("second"))-e}const _e=864e5;const Be=new Map;function He(e,t){const n=`${e}|${t}`,o=Be.get(n);if(void 0!==o)return o;const i=function(e,t){const n=Ne.exec((e||"").trim());if(!n)return null;const[,o,i,r,s,a,c]=n.map(Number),l=Number.isNaN(c)?0:c;if(i<1||i>12||r<1||r>31)return null;if(s>23||a>59||l>59)return null;const u=Date.UTC(o,i-1,r,s,a,l),d=new Date(u);if(d.getUTCMonth()!==i-1||d.getUTCDate()!==r)return null;if(!t)return u;const p=Ve(t);if(!p)return null;const h=function(e,t){const n=[];for(const o of[e-_e,e,e+_e]){const e=Oe(o,t);n.includes(e)||n.push(e)}return n}(u,p),m=h.filter(e=>Oe(u-e,p)===e).map(e=>u-e);return m.length>0?Math.min(...m):u-Math.min(...h)}(e,t);return Be.size>100&&Be.clear(),Be.set(n,i),i}const We={en:{days:"Days",hours:"Hours",minutes:"Minutes",seconds:"Seconds"},ru:{days:"Дни",hours:"Часы",minutes:"Минуты",seconds:"Секунды"},de:{days:"Tage",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden"},es:{days:"Días",hours:"Horas",minutes:"Minutos",seconds:"Segundos"},fr:{days:"Jours",hours:"Heures",minutes:"Minutes",seconds:"Secondes"},pt:{days:"Dias",hours:"Horas",minutes:"Minutos",seconds:"Segundos"},ja:{days:"日",hours:"時間",minutes:"分",seconds:"秒"},ko:{days:"일",hours:"시간",minutes:"분",seconds:"초"},zh:{days:"天",hours:"小时",minutes:"分",seconds:"秒"},hi:{days:"दिन",hours:"घंटे",minutes:"मिनट",seconds:"सेकंड"},bn:{days:"দিন",hours:"ঘণ্টা",minutes:"মিনিট",seconds:"সেকেন্ড"},ar:{days:"أيام",hours:"ساعات",minutes:"دقائق",seconds:"ثوان"},he:{days:"ימים",hours:"שעות",minutes:"דקות",seconds:"שניות"},th:{days:"วัน",hours:"ชั่วโมง",minutes:"นาที",seconds:"วินาที"}};function Ue(e){const t=(e||"").trim();if(t)return t.startsWith("#")||t.startsWith("/")||t.startsWith("?")||a.test(t)?t:void 0}function Ke(e){return"_self"===e?{target:"_self"}:{target:"_blank",rel:"noreferrer"}}function Ze(e,t,n){const o="granted"===t?e.onGranted:e.onDenied;return"href"===o?.type&&function(e,t){const n="string"==typeof e.url?Ue(e.url):void 0;if(!n)return void t?.warn("Subscribe button: the link to open after the answer is empty or unsafe, it was not opened");if("_self"===e.target)return void window.location.assign(n);window.open(n,"_blank","noopener,noreferrer")}(o,n),"granted"===t||"close"===o?.type}const Ge=new Set(["STRONG","B","EM","I","U","BR","A"]);function Je(e,t,n){for(const o of Array.from(e.childNodes)){if(3===o.nodeType){t.appendChild(n.createTextNode(o.textContent??""));continue}if(1!==o.nodeType)continue;const e=o;if(!Ge.has(e.tagName)){Je(e,t,n);continue}const i=n.createElement(e.tagName.toLowerCase());if("A"===e.tagName){const t=Ue(e.getAttribute("href")??void 0);t&&i.setAttribute("href",t);const{target:n,rel:o}=Ke(e.getAttribute("target"));i.setAttribute("target",n),o&&i.setAttribute("rel",o)}t.appendChild(i),Je(e,i,n)}}function Ye(e){if(!e.includes("<"))return e;const t=(new DOMParser).parseFromString(e,"text/html"),n=t.createElement("div");return Je(t.body,n,t),n.innerHTML}function Qe(e){return"string"==typeof e&&e?e:void 0}function Xe(e,t){const n=e.dark;if("object"!=typeof n||null===n)return;const o=n,i="object"==typeof o.colors&&null!==o.colors?o.colors:{},r=Fe(t),s=function(e){if("object"!=typeof e||null===e)return;const t=e,n=Qe(t.color);if(!n)return;return{color:n,opacity:"number"==typeof t.opacity&&Number.isFinite(t.opacity)?Math.max(0,Math.min(1,t.opacity)):1}}(o.overlay);return{enabled:!0===o.enabled,colors:{background:Qe(i.background)??r.background,accent:Qe(i.accent)??r.accent,text:Qe(i.text)??r.text,textSecondary:Qe(i.textSecondary)??r.textSecondary,textInverse:Qe(i.textInverse)??r.textInverse},...s?{overlay:s}:{},...Qe(o.boxShadow)?{boxShadow:o.boxShadow}:{}}}function et(e){let t;try{t=JSON.parse(e)}catch{return null}if("object"!=typeof t||null===t)return null;const n=t;if(2!==n.version)return null;const o=n.params;if("object"!=typeof o||null===o)return null;if(!Array.isArray(o.pages)||0===o.pages.length)return null;const i=function(e){const t="object"==typeof e.colors&&null!==e.colors?e.colors:{};return{background:Qe(t.background)??Qe(e.background)??d,accent:Qe(t.accent)??Qe(e.accent)??p,text:Qe(t.text)??h,textSecondary:Qe(t.textSecondary)??m,textInverse:Qe(t.textInverse)??f}}(o),r=Xe(o,i);return{version:2,params:{...o,colors:i,...r?{dark:r}:{}}}}const tt=["cover","contain"];function nt(e){if("object"!=typeof e||null===e)return;const t=e,n=Ue("string"==typeof t.src?t.src:void 0);return n?{src:n,...!0===t.controls?{controls:!0}:{},...!1===t.loop?{loop:!1}:{}}:void 0}function ot(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;if("object"!=typeof n||null===n)continue;if("string"!=typeof n.key||!n.key)continue;if("string"!=typeof n.src)continue;const e=nt(n.video);t.push({key:n.key,label:"string"==typeof n.label?n.label:"",src:n.src,..."string"==typeof n.srcDark&&n.srcDark?{srcDark:n.srcDark}:{},...e?{video:e}:{},..."string"==typeof n.mediaId&&n.mediaId?{mediaId:n.mediaId}:{},..."string"==typeof n.mediaIdDark&&n.mediaIdDark?{mediaIdDark:n.mediaIdDark}:{},...tt.includes(n.fit)?{fit:n.fit}:{},..."number"==typeof n.blur&&Number.isFinite(n.blur)&&n.blur>0?{blur:Math.min(n.blur,100)}:{},..."number"==typeof n.dim&&Number.isFinite(n.dim)&&n.dim>0?{dim:Math.min(n.dim,1)}:{}})}return t}const it=["px","%","em","rem","fr"];function rt(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function st(e){if("object"!=typeof e||null===e)return;const t=e;if("text"===t.kind)return{kind:"text"};if("length"===t.kind||"percent"===t.kind){const e=rt(t.min),n=rt(t.max),o="length"===t.kind&&Array.isArray(t.units)?t.units.filter(e=>it.includes(e)):[],i="length"===t.kind?function(e){if("object"!=typeof e||null===e)return;const t={};for(const n of it){const o=e[n];if("object"!=typeof o||null===o)continue;const i=rt(o.min),r=rt(o.max);void 0===i&&void 0===r||(t[n]={...void 0!==i?{min:i}:{},...void 0!==r?{max:r}:{}})}return Object.keys(t).length>0?t:void 0}(t.ranges):void 0;return{kind:t.kind,...void 0!==e?{min:e}:{},...void 0!==n?{max:n}:{},...o.length>0?{units:o}:{},...i?{ranges:i}:{}}}if("select"===t.kind&&Array.isArray(t.options)){const e=[];for(const n of t.options){if(e.length>=20)break;"object"==typeof n&&null!==n&&("string"!=typeof n.value||n.value.length>64||e.push({value:n.value,label:"string"==typeof n.label?n.label:n.value}))}if(e.length>0)return{kind:"select",options:e}}}function at(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;if("object"!=typeof n||null===n)continue;if("string"!=typeof n.key||!le.test(n.key))continue;if("string"!=typeof n.value||n.value.length>64||n.value.includes("$"))continue;if(t.some(e=>e.key===n.key))continue;const e=st(n.control);t.push({key:n.key,label:"string"==typeof n.label?n.label:"",value:n.value,...e?{control:e}:{}})}return t}function ct(e){return Object.fromEntries(e.map(e=>[e.key,e.value]))}const lt=["email","firstName","lastName","phone","custom"],ut=["primary","secondary"];function dt(e){const t=[];if(Array.isArray(e))for(const n of e){if(t.length>=10)break;"object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key&&lt.includes(n.kind)&&(t.some(e=>e.key===n.key)||t.push({key:n.key,kind:n.kind,label:"string"==typeof n.label?n.label:"",placeholder:"string"==typeof n.placeholder?n.placeholder:"",required:"email"===n.kind||!0===n.required,..."custom"===n.kind&&"string"==typeof n.tag&&n.tag?{tag:n.tag}:{}})))}if(!t.some(e=>"email"===e.kind)){let e="field-email";for(;t.some(t=>t.key===e);)e=`${e}-1`;t.unshift({key:e,kind:"email",label:"Email",placeholder:"",required:!0})}return t.slice(0,10)}const pt=["checkbox","chips"],ht=["nps","stars","thumbs"],mt=["instant","button"],ft=["keep","hide-popup","page"],gt=/^[a-z]{2}$/i,bt=/^#[0-9a-fA-F]{6}$/,yt=500;function vt(e,t=120){return"string"==typeof e?e.trim().slice(0,t):""}function xt(e,t,n=120){return vt(e,n)||t}function kt(e){const t=vt(e,8);return gt.test(t)?t.toLowerCase():""}function St(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=12)break;if("object"!=typeof n||null===n)continue;const e=vt(n.value);if(!e)continue;if(t.some(t=>t.value===e))continue;const o=vt(n.tagValue);t.push({value:e,label:xt(n.label,e),...o?{tagValue:o}:{}})}return t}function wt(e,t){const n=e=>{const n=rt(e);return void 0===n||n<=0?0:Math.min(Math.floor(n),t)},o=n(e.min),i=n(e.max);return{min:o,max:i>0?Math.max(o,i):0}}function Ct(e){const t=[];for(const n of e){if(t.length>=50)break;if("object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key))if("text"!==n.type)if("button"!==n.type){if("timer"===n.type){const e=vt(n.timezone,64),o=ze(e)?e:"",i=vt(n.endTime,32);if(null===He(i,o))continue;const r=vt(n.expirePage),s=ft.includes(n.onExpire)?n.onExpire:"keep",a="page"!==s||r?s:"keep";t.push({type:"timer",key:n.key,endTime:i,timezone:o,language:kt(n.language),showLabels:!1!==n.showLabels,onExpire:a,..."page"===a?{expirePage:r}:{}});continue}if("choice"===n.type){const e=St(n.options),{min:o,max:i}=wt(n,e.length);t.push({type:"choice",key:n.key,control:pt.includes(n.control)?n.control:"checkbox",tagName:vt(n.tagName),options:e,min:o,max:i,submitLabel:xt(n.submitLabel,P),submitVariant:ut.includes(n.submitVariant)?n.submitVariant:"primary",successMessage:xt(n.successMessage,$,yt)});continue}if("rating"===n.type){const e="object"==typeof n.labels&&null!==n.labels?n.labels:{};t.push({type:"rating",key:n.key,scale:ht.includes(n.scale)?n.scale:"stars",labels:{low:vt(e.low),high:vt(e.high)},submitMode:mt.includes(n.submitMode)?n.submitMode:"instant",submitLabel:xt(n.submitLabel,E),eventName:vt(n.eventName),successMessage:xt(n.successMessage,F,yt)});continue}if("glyph"!==n.type)"email-input"!==n.type?"tag-input"!==n.type?"consent"!==n.type?"submit"!==n.type?"email-subscription-form"===n.type&&t.push({type:"email-subscription-form",key:n.key,formCode:"string"==typeof n.formCode?n.formCode:"",fields:dt(n.fields),submitLabel:"string"==typeof n.submitLabel&&n.submitLabel?n.submitLabel:C,submitVariant:ut.includes(n.submitVariant)?n.submitVariant:"primary",..."object"==typeof n.privacy&&null!==n.privacy&&"string"==typeof n.privacy.checkboxLabel?{privacy:{checkboxLabel:n.privacy.checkboxLabel,url:"string"==typeof n.privacy.url?n.privacy.url:"",linkLabel:"string"==typeof n.privacy.linkLabel?n.privacy.linkLabel:""}}:{},successMessage:"string"==typeof n.successMessage&&n.successMessage?n.successMessage:j,confirmEmailMessage:"string"==typeof n.confirmEmailMessage&&n.confirmEmailMessage?n.confirmEmailMessage:M}):t.push({type:"submit",key:n.key,variant:ut.includes(n.variant)?n.variant:"primary",label:xt(n.label,N),errorMessage:xt(n.errorMessage,D,yt)}):t.push({type:"consent",key:n.key,checkboxLabel:vt(n.checkboxLabel,yt),linkLabel:vt(n.linkLabel),url:vt(n.url,yt),requiredMessage:xt(n.requiredMessage,L)}):t.push({type:"tag-input",key:n.key,tagName:vt(n.tagName),label:vt(n.label),placeholder:vt(n.placeholder),required:!0===n.required,requiredMessage:xt(n.requiredMessage,T)}):t.push({type:"email-input",key:n.key,label:vt(n.label),placeholder:vt(n.placeholder),invalidMessage:xt(n.invalidMessage,I),requiredMessage:xt(n.requiredMessage,q)});else{if(!O.includes(n.name))continue;t.push({type:"glyph",key:n.key,name:n.name,size:_.includes(n.size)?n.size:_[0],color:"string"==typeof n.color&&bt.test(n.color)?n.color:""})}}else"object"==typeof n.action&&null!==n.action&&"string"==typeof n.action.type&&t.push(n);else"string"==typeof n.html&&t.push(n)}return t}function jt(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;"object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key&&Array.isArray(n.slots)&&t.push({key:n.key,label:"string"==typeof n.label?n.label:"",slots:Ct(n.slots)}))}return t}function Mt(e){return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.min(e,2e3):void 0}function Pt(e,t,n){if(null===e)return;let o;return o="stretch"===e?"stretch":Mt(e)??("stretch"===t?"stretch":Mt(t)),"width"===n&&"stretch"===o?void 0:o}function $t(e){const t=[];for(const n of e.pages){const o=at(n.values),i=ce(pe(n.layout,ct(o)));if(!i)continue;const r=Pt(n.width,e.width,"width"),s=Pt(n.height,e.height,"height");t.push({key:n.key,layout:i,images:ot(n.images),contents:jt(n.contents),...void 0!==r?{width:r}:{},...void 0!==s?{height:s}:{},..."success"===n.role?{role:"success"}:{}})}return t}function Et(e,t){return t.find(t=>t.key===e.startPage)??t[0]}function Ft(e){return`calc(100% - ${2*e.offset}px)`}function Rt(e){return Array.isArray(e?.slots)?{...e,slots:e.slots.filter(e=>!function(e){const t=e;return"button"===t?.type&&"close"===t.action?.type}(e))}:e}function At(e){return Array.isArray(e?.contents)?{...e,contents:e.contents.map(Rt)}:e}const It=new Set(["email-input","tag-input","consent"]),qt=new Set([...It,"submit"]);function Tt(e){return It.has(e.type)}function Lt(e,t){return`${e}/${t}`}function Nt(e,t){const{slot:n}=e;if("consent"===n.type)return t.checks[e.id]?void 0:n.requiredMessage;const o=(t.texts[e.id]??"").trim();return"tag-input"===n.type?n.required&&!o?n.requiredMessage:void 0:o?A.test(o)?void 0:n.invalidMessage:n.requiredMessage}function Dt(e,t){const n={};for(const o of e){const e=Nt(o,t);e&&(n[o.id]=e)}return n}const Vt="pushwoosh-web-popups",zt="[WebPopups]",Ot="data-pushwoosh-embedded-order",_t="keyValue",Bt="messages",Ht="inboxMessages";function Wt(e,t){return function(n){n.objectStoreNames.contains(e)||t(n)}}const Ut=[Wt(_t,function(e){e.createObjectStore(_t,{keyPath:"key"})}),Wt("log",function(e){const t=e.createObjectStore("log",{keyPath:"id",autoIncrement:!0});t.createIndex("environment","environment",{unique:!1}),t.createIndex("date","date",{unique:!1}),t.createIndex("type","type",{unique:!1})}),Wt(Bt,function(e){e.createObjectStore(Bt,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}),Wt(Ht,function(e){const t="status",n=e.createObjectStore(Ht,{keyPath:"inbox_id",autoIncrement:!1});n.createIndex(t,t,{unique:!1,multiEntry:!0}),n.createIndex("rt","rt",{unique:!1,multiEntry:!0})})];class Kt{get all(){return Ut}}class Zt{constructor(e,t=new Kt){this.db=e,this.migrationsBuilder=t}applyMigrations(){this.applyMigrationsPack(this.migrationsBuilder.all)}applyMigrationsPack(e){e.forEach(e=>{e(this.db)})}}function Gt(e,t){console.info("onversionchange",t),e.close()}let Jt;function Yt(e){return(Jt||(Jt=new Promise((e,t)=>{const n=indexedDB.open("PUSHWOOSH_SDK_STORE",7);n.onsuccess=n=>{const o=n.target.result;o.onversionchange=Gt.bind(null,o,t),e(o)},n.onerror=()=>t(n.error),n.onupgradeneeded=e=>{const n=e.target.result;n.onversionchange=Gt.bind(null,n,t),new Zt(n).applyMigrations()}})),Jt).then(t=>new Promise((n,o)=>e(t,n,o)))}class Qt{_add(e){return Yt((t,n,o)=>{const i=t.transaction([this.name],"readwrite").objectStore(this.name).add(e);i.onsuccess=()=>{n(e)},i.onerror=()=>{o(i.error)}}).then(e=>this.getAll().then(t=>{if(Array.isArray(t)){const n=t.map(e=>e.id).sort((e,t)=>e==t?0:e<t?1:-1);if(n.length>this.maxItems)return Promise.all(n.slice(this.maxItems).map(e=>this.delete(e))).then(()=>e)}return e}))}delete(e){return Yt((t,n,o)=>{const i=t.transaction([this.name],"readwrite").objectStore(this.name).delete(e);i.onsuccess=()=>{n(i.result)},i.onerror=()=>{o(i.error)}})}getAll(){return Yt((e,t,n)=>{const o=[],i=e.transaction(this.name).objectStore(this.name).openCursor();i.onsuccess=e=>{const n=e.target.result;n?(n.value&&o.push(n.value),n.continue()):t(o)},i.onerror=()=>{n(i.error)}})}}Xt=_t;var Xt;const en=new class extends Qt{constructor(){super(...arguments),this.name="log",this.maxItems=100,this.environment="undefined"!=typeof self&&self.registration?"worker":"browser"}add(e,t,n){const o={type:e,environment:this.environment,message:`${t}`,date:new Date};return t instanceof Error&&(o.stack=t.stack),n&&(o.additional=n),this._add(o)}},tn=(new class extends Qt{constructor(){super(...arguments),this.name=Bt,this.maxItems=25}add(e){return this._add({...e,date:new Date})}},{error:1,info:2,debug:3});let nn=3;const on={setLevel(e){tn[e]||(e="error"),nn=tn[e]},write(e,t,n){return"error"===e?this.error(t):this.info(t),en.add(e,t,n)}};function rn(e){return async({slotKey:t,tagName:n,values:o})=>{try{await e.api.setTags({[n]:{operation:"append",value:o}})}catch(e){throw on.error(e,`Failed to write web popup choice "${t}" to tag "${n}"`),e}}}function sn(e){return async({slotKey:t,eventName:n,score:o,scale:i})=>{try{await e.api.postEvent(n,{score:o,scale:i,slotKey:t})}catch(e){throw on.error(e,`Failed to post web popup rating "${t}" as event "${n}"`),e}}}function an(e){return async()=>{try{await e.subscribe()}catch(e){on.error(e,"Failed to subscribe from a web popup")}return e.driver?.getPermission()??"default"}}Object.keys(tn).forEach(e=>{const t=tn[e];on[e]=(...n)=>{t<=nn&&(console.groupCollapsed(e),console.info("",...n),console.trace("trace"),console.groupEnd())}});var cn=r(247),ln=r(524),un=r(873);const dn="(prefers-color-scheme: dark)";function pn(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia(dn).matches}function hn(e,t){const[n,o]=(0,un.useState)(()=>"auto"===e&&t&&pn()),i=[e,t],[r,s]=(0,un.useState)(null);return(null===r||i.some((e,t)=>e!==r[t]))&&(s(i),"auto"===e&&t&&o(pn())),(0,un.useEffect)(()=>{if("auto"!==e||!t||"undefined"==typeof window||"function"!=typeof window.matchMedia)return;const n=window.matchMedia(dn),i=e=>o(e.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[e,t]),"auto"!==e?e:n?"dark":"light"}const mn="data-pw-web-popup-inline",fn="data-pw-close",gn="data-pw-submit",bn={width:"100%"},yn=`[${mn}] img { max-height: 360px; object-fit: cover; }`,vn=(0,un.createContext)({pageKey:"",texts:{},checks:{},errors:{},phase:"idle",setText:()=>{},setCheck:()=>{},submit:()=>{},turnPage:(e,t)=>t(e),advance:()=>{}});function xn(e,t){return t in e?Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)):e}function kn(e,t,n,o){const i=(0,un.useMemo)(()=>$t(e),[e]),r=(0,un.useMemo)(()=>function(e){const t=[];for(const n of e)for(const e of n.contents)for(const o of e.slots)Tt(o)&&t.push({id:Lt(n.key,o.key),pageKey:n.key,slot:o});return t}(i),[i]),[s,a]=(0,un.useState)({}),[c,l]=(0,un.useState)({}),[u,d]=(0,un.useState)({}),[p,h]=(0,un.useState)("idle"),m=e=>i.findIndex(t=>t.key===e),f=()=>{const e=Dt(r.filter(e=>e.pageKey===t),{texts:s,checks:c});return d(e),0===Object.keys(e).length},g=()=>{o&&"submitting"!==p&&((()=>{const e=Dt(r,{texts:s,checks:c});d(e);const t=r.find(t=>t.id in e);return t&&n?.(t.pageKey),!t})()?(h("submitting"),Promise.resolve().then(()=>o(function(e,t){const n={tags:{},policyAccepted:!0};for(const o of e){const{slot:e}=o;if("consent"===e.type){n.policyAccepted=n.policyAccepted&&!0===t.checks[o.id];continue}const i=(t.texts[o.id]??"").trim();"email-input"!==e.type?i&&e.tagName&&(n.tags[e.tagName]=i):n.email=i}return n}(r,{texts:s,checks:c}))).then(e=>{if(h("idle"),"invalid-email"===e)return void(()=>{const e=r.find(e=>"email-input"===e.slot.type);"email-input"===e?.slot.type&&(d({[e.id]:e.slot.invalidMessage}),n?.(e.pageKey))})();const t=i.find(e=>"success"===e.role);t&&n?.(t.key)},()=>h("error"))):h("idle"))};return{pageKey:t,texts:s,checks:c,errors:u,phase:p,setText:(e,t)=>{a(n=>({...n,[e]:t})),d(t=>xn(t,e))},setCheck:(e,t)=>{l(n=>({...n,[e]:t})),d(t=>xn(t,e))},submit:g,turnPage:(e,n)=>{if("submitting"===p)return;const r=m(e),s=r>m(t);o&&s?"success"===i[r].role?g():f()&&n(e):n(e)},advance:()=>{if(!o||"submitting"===p)return;const e=i[m(t)+1];e&&"success"!==e.role?f()&&n?.(e.key):g()}}}const Sn={padding:"4px 0",textAlign:"left"};function wn({inverse:e,colors:t}){const n=y("caption",t,e);return{...g.caption,...n?{color:n}:{}}}function Cn(e){return{fontSize:12,lineHeight:1.4,color:e.error,paddingTop:2}}function jn(e){return{...wn(e),paddingBottom:4}}function Mn({slotKey:e,label:t,placeholder:n,inputType:o,autoComplete:i,look:r}){const s=(0,un.useContext)(vn),[a,c]=(0,un.useState)(!1),l=Lt(s.pageKey,e),u=s.errors[l];let d;return u?d=r.colors.error:a&&(d=r.colors.accent),(0,cn.jsxs)("div",{style:Sn,children:[t&&(0,cn.jsx)("div",{style:jn(r),children:t}),(0,cn.jsx)("input",{type:o,autoComplete:i,placeholder:n||void 0,value:s.texts[l]??"",disabled:"submitting"===s.phase,style:w(r.colors,d),onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:e=>s.setText(l,e.currentTarget.value),onKeyDown:e=>{"Enter"===e.key&&s.advance()}}),u&&(0,cn.jsx)("div",{style:Cn(r.colors),children:u})]})}function Pn({slot:e,...t}){return(0,cn.jsx)(Mn,{slotKey:e.key,label:e.label,placeholder:e.placeholder,inputType:"email",autoComplete:"email",look:t})}function $n({slot:e,...t}){return(0,cn.jsx)(Mn,{slotKey:e.key,label:e.label,placeholder:e.placeholder,inputType:"text",look:t})}const En={margin:"2px 0 0",flexShrink:0};function Fn(e){return{...wn(e),display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"}}function Rn({slot:e,...t}){const n=(0,un.useContext)(vn),o=Lt(n.pageKey,e.key),i=n.errors[o],r=Ue(e.url);return(0,cn.jsxs)("div",{style:Sn,children:[(0,cn.jsxs)("label",{style:Fn(t),children:[(0,cn.jsx)("input",{type:"checkbox",checked:!0===n.checks[o],disabled:"submitting"===n.phase,style:En,onChange:e=>n.setCheck(o,e.currentTarget.checked)}),(0,cn.jsxs)("span",{children:[e.checkboxLabel,r&&(0,cn.jsxs)(cn.Fragment,{children:[" ",(0,cn.jsx)("a",{href:r,...Ke(void 0),style:(s=t.colors,{color:s.accent}),children:e.linkLabel||e.url})]})]})]}),i&&(0,cn.jsx)("div",{style:Cn(t.colors),children:i})]});var s}const An={padding:k};function In(e,t,n){return{...S(e,t),...n?{opacity:.6,cursor:"default"}:{}}}function qn({slot:e,align:t,colors:n}){const o=(0,un.useContext)(vn),i="submitting"===o.phase;return(0,cn.jsxs)("div",{style:An,children:[(0,cn.jsx)("button",{type:"button",[gn]:"",disabled:i,style:In(e.variant,n,i),onClick:o.submit,children:e.label}),"error"===o.phase&&(0,cn.jsx)("div",{style:{...Cn(n),textAlign:t},children:e.errorMessage})]})}const Tn={none:void 0,fade:"pw-vpopup-fade 0.35s ease-out backwards",slide:"pw-vpopup-slide 0.35s ease-out backwards"};function Ln({slot:e,align:t,inverse:n,colors:o}){const i={...g[e.variant],textAlign:e.align??t},r=y(e.variant,o,n);return r&&(i.color=r),(0,cn.jsx)("div",{style:i,dangerouslySetInnerHTML:{__html:Ye(e.html)}})}function Nn({slot:e,colors:t,logger:n,onRequestClose:o,onPageChange:i,onRequestSubscribe:r,onSubscribeClose:s}){const a=(0,un.useContext)(vn),[c,l]=(0,un.useState)("idle"),u=S(e.variant,t),d={};if("close"===e.action.type)return(0,cn.jsx)("div",{style:d,children:(0,cn.jsx)("button",{type:"button",style:u,onClick:o,children:e.label})});if("page"===e.action.type){const t=e.action.page;return(0,cn.jsx)("div",{style:d,children:(0,cn.jsx)("button",{type:"button",style:u,onClick:()=>a.turnPage(t,i),children:e.label})})}if("subscribe"===e.action.type){const{action:t}=e,o="idle"!==c,i=()=>{r&&!o&&(l("asking"),r().then(e=>{"default"!==e?Ze(t,e,n)?s?.():l("denied"):l("idle")}).catch(()=>l("idle")))};return(0,cn.jsx)("div",{style:d,children:(0,cn.jsx)("button",{type:"button",disabled:o,style:{...u,...o?{opacity:.7}:{}},onClick:i,children:e.label})})}const p=Ue(e.action.url);return p?(0,cn.jsx)("div",{style:d,children:(0,cn.jsx)("a",{href:p,...Ke(e.action.target),style:u,children:e.label})}):(0,cn.jsx)("div",{style:d,children:(0,cn.jsx)("button",{type:"button",style:u,children:e.label})})}function Dn({message:e,align:t,inverse:n,colors:o}){const i=y("body",o,n);return(0,cn.jsx)("div",{style:{...g.body,padding:"4px 0",textAlign:t,...i?{color:i}:{}},children:e})}const Vn={email:"email",phone:"tel"},zn={email:"email",firstName:"given-name",lastName:"family-name",phone:"tel"},On="__privacy";function _n({slot:e,align:t,inverse:n,colors:o,onSubmitForm:i}){const[r,s]=(0,un.useState)({}),[a,c]=(0,un.useState)(!1),[l,u]=(0,un.useState)(null),[d,p]=(0,un.useState)({}),[h,m]=(0,un.useState)("idle"),f=y("caption",o,n),b={...g.caption,...f?{color:f}:{}},v={fontSize:12,lineHeight:1.4,color:o.error,paddingTop:2};if("success"===h||"confirm"===h)return(0,cn.jsx)(Dn,{message:"confirm"===h?e.confirmEmailMessage:e.successMessage,align:t,inverse:n,colors:o});const x="submitting"===h,C=e.privacy?Ue(e.privacy.url):void 0,j={...S(e.submitVariant,o),...x?{opacity:.6,cursor:"default"}:{}};return(0,cn.jsxs)("form",{noValidate:!0,style:{margin:0,textAlign:"left"},onSubmit:t=>{t.preventDefault(),(()=>{if(!i||!e.formCode||"submitting"===h)return;const t={};for(const n of e.fields){const e=(r[n.key]??"").trim();n.required&&!e?t[n.key]="Required":"email"===n.kind&&e&&!A.test(e)&&(t[n.key]="Enter a valid email")}if(e.privacy&&!a&&(t[On]="Please accept the privacy policy"),p(t),Object.keys(t).length>0)return;const n={email:"",policyAccepted:!e.privacy||a},o={};for(const t of e.fields){const e=(r[t.key]??"").trim();e&&("email"===t.kind?n.email=n.email||e:"firstName"===t.kind?n.firstName=e:"lastName"===t.kind?n.lastName=e:"phone"===t.kind?n.phone=e:o[t.tag||t.key]=e)}Object.keys(o).length>0&&(n.customFields=o),m("submitting"),Promise.resolve().then(()=>i(e.formCode,n)).then(e=>m("confirm-email"===e?"confirm":"success"),()=>m("error"))})()},children:[e.fields.map(e=>{const t=d[e.key];let n;return t?n=o.error:l===e.key&&(n=o.accent),(0,cn.jsxs)("div",{style:{padding:"4px 0"},children:[e.label&&(0,cn.jsx)("div",{style:{...b,paddingBottom:4},children:e.label}),(0,cn.jsx)("input",{type:Vn[e.kind]??"text",autoComplete:zn[e.kind],placeholder:e.placeholder||void 0,value:r[e.key]??"",disabled:x,style:w(o,n),onFocus:()=>u(e.key),onBlur:()=>u(t=>t===e.key?null:t),onChange:t=>{return n=e.key,o=t.currentTarget.value,s(e=>({...e,[n]:o})),void p(e=>e[n]?Object.fromEntries(Object.entries(e).filter(([e])=>e!==n)):e);var n,o}}),t&&(0,cn.jsx)("div",{style:v,children:t})]},e.key)}),e.privacy&&(0,cn.jsxs)("div",{style:{padding:"4px 0"},children:[(0,cn.jsxs)("label",{style:{...b,display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[(0,cn.jsx)("input",{type:"checkbox",checked:a,disabled:x,style:{margin:"2px 0 0",flexShrink:0},onChange:e=>{c(e.currentTarget.checked),p(e=>e[On]?Object.fromEntries(Object.entries(e).filter(([e])=>e!==On)):e)}}),(0,cn.jsxs)("span",{children:[e.privacy.checkboxLabel,C&&(0,cn.jsxs)(cn.Fragment,{children:[" ",(0,cn.jsx)("a",{href:C,...Ke(void 0),style:{color:o.accent},children:e.privacy.linkLabel||e.privacy.url})]})]})]}),d[On]&&(0,cn.jsx)("div",{style:v,children:d[On]})]}),(0,cn.jsx)("div",{style:{padding:k},children:(0,cn.jsx)("button",{type:"submit",disabled:x,style:j,children:e.submitLabel})}),"error"===h&&(0,cn.jsx)("div",{style:{...v,textAlign:t},children:R})]})}function Bn({value:e,label:t,digitStyle:n,labelStyle:o}){return(0,cn.jsxs)("div",{style:{minWidth:44},children:[(0,cn.jsx)("div",{style:n,children:String(e).padStart(2,"0")}),t?(0,cn.jsx)("div",{style:o,children:t}):null]})}function Hn({slot:e,align:t,inverse:n,colors:o,mode:i,onRequestClose:r,onPageChange:s}){const[a,c]=(0,un.useState)(()=>Date.now()),l=function(e,t,n){const o=He(e,t),i=null===o?0:Math.max(0,o-n),r=Math.floor(i/1e3);return{total:i,days:Math.floor(r/86400),hours:Math.floor(r/3600)%24,minutes:Math.floor(r/60)%60,seconds:r%60}}(e.endTime,e.timezone,a),u=0===l.total;(0,un.useEffect)(()=>{if("live"!==i||u)return;const e=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(e)},[i,u,e.endTime,e.timezone]),(0,un.useEffect)(()=>{"live"===i&&u&&("hide-popup"===e.onExpire?r?.():"page"===e.onExpire&&e.expirePage&&s(e.expirePage))},[i,u,e.onExpire,e.expirePage,r,s]);const d=y("h2",o,n),p=y("caption",o,n),h={fontSize:28,fontWeight:700,lineHeight:1.2,fontVariantNumeric:"tabular-nums",...d?{color:d}:{}},m={...g.caption,...p?{color:p}:{}},f=(b=e.language,We[b]??We.en);var b;const v=[{value:l.days,label:f.days},{value:l.hours,label:f.hours},{value:l.minutes,label:f.minutes},{value:l.seconds,label:f.seconds}];return(0,cn.jsx)("div",{style:{padding:"4px 0",textAlign:t},children:(0,cn.jsx)("div",{style:{display:"inline-flex",gap:12,textAlign:"center"},children:v.map(t=>(0,cn.jsx)(Bn,{value:t.value,label:e.showLabels?t.label:"",digitStyle:h,labelStyle:m},t.label||t.value))})})}function Wn({slot:e,align:t,inverse:n,colors:o,onSubmitChoice:i}){const[r,s]=(0,un.useState)([]),[a,c]=(0,un.useState)("idle"),[l,u]=(0,un.useState)("");if("success"===a)return(0,cn.jsx)(Dn,{message:e.successMessage,align:t,inverse:n,colors:o});const d=t=>{u(""),s(n=>n.includes(t)?n.filter(e=>e!==t):e.max>0&&n.length>=e.max?(u(`Pick up to ${e.max}`),n):[...n,t])},p="submitting"===a,h=y("body",o,n),m={...g.body,...h?{color:h}:{}};return(0,cn.jsxs)("div",{style:{padding:"4px 0"},children:["chips"===e.control?(0,cn.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,justifyContent:"center"===t?"center":"flex-start"},children:e.options.map(e=>{return(0,cn.jsx)("button",{type:"button","aria-pressed":r.includes(e.value),style:(t=r.includes(e.value),{padding:"6px 14px",borderRadius:999,border:`1px solid ${o.accent}`,backgroundColor:t?o.accent:"transparent",color:t?o.onAccent:o.accent,fontFamily:"inherit",fontSize:14,lineHeight:1.4,cursor:"pointer"}),onClick:()=>d(e.value),children:e.label},e.value);var t})}):(0,cn.jsx)("div",{style:{display:"grid",gap:6},children:e.options.map(e=>(0,cn.jsxs)("label",{style:{...m,display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[(0,cn.jsx)("input",{type:"checkbox",checked:r.includes(e.value),onChange:()=>d(e.value),style:{accentColor:o.accent,width:16,height:16,margin:0}}),e.label]},e.value))}),l?(0,cn.jsx)("div",{style:{...g.caption,color:o.error,paddingTop:4},children:l}):null,"error"===a?(0,cn.jsx)("div",{style:{...g.caption,color:o.error,paddingTop:4},children:R}):null,(0,cn.jsx)("div",{style:{padding:k},children:(0,cn.jsx)("button",{type:"button",style:{...S(e.submitVariant,o),...p?{opacity:.7}:{}},onClick:()=>{if(!i||!e.tagName||"submitting"===a)return;const t=Math.max(e.min,1);if(r.length<t)return void u(1===t?"Pick at least one":`Pick at least ${t}`);const n=e.options.filter(e=>r.includes(e.value)).map(e=>e.tagValue||e.value);u(""),c("submitting"),Promise.resolve().then(()=>i({slotKey:e.key,tagName:e.tagName,values:n})).then(()=>c("success"),()=>c("error"))},children:e.submitLabel})})]})}function Un({score:e,scale:t,selected:n,colors:o,onPick:i}){const r={display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,border:`1px solid ${o.accent}`,backgroundColor:n?o.accent:"transparent",color:n?o.onAccent:o.accent,fontFamily:"inherit",fontSize:14,lineHeight:1,cursor:"pointer"};if("nps"===t)return(0,cn.jsx)("button",{type:"button","aria-label":`Rate ${e}`,"aria-pressed":n,style:{...r,width:30,height:32,borderRadius:6},onClick:i,children:e});const s="thumbs"===t;let a=`Rate ${e}`;return s&&(a=1===e?"Thumbs up":"Thumbs down"),(0,cn.jsx)("button",{type:"button","aria-label":a,"aria-pressed":n,style:{...r,width:s?44:34,height:s?40:34,borderRadius:s?8:6},onClick:i,children:(0,cn.jsx)("svg",{width:s?22:20,height:s?22:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,cn.jsx)("path",{d:s?"M8 21V10l3.5-7A2 2 0 0 1 14 5v5h4.5a2 2 0 0 1 2 2.4l-1.3 6A2 2 0 0 1 17.2 21zM8 10H3.5v11H8":z.star,...s&&0===e?{transform:"rotate(180 12 12)"}:{}})})})}function Kn({slot:e,align:t,inverse:n,colors:o,onSubmitRating:i}){const[r,s]=(0,un.useState)(null),[a,c]=(0,un.useState)("idle");if("success"===a)return(0,cn.jsx)(Dn,{message:e.successMessage,align:t,inverse:n,colors:o});const l=t=>{i&&e.eventName&&"submitting"!==a&&(c("submitting"),Promise.resolve().then(()=>i({slotKey:e.key,eventName:e.eventName,score:t,scale:e.scale})).then(()=>c("success"),()=>c("error")))},u="nps"===(d=e.scale)?[0,1,2,3,4,5,6,7,8,9,10]:"stars"===d?[1,2,3,4,5]:[0,1];var d;const p=y("caption",o,n),h={...g.caption,...p?{color:p}:{}},m=t=>"stars"===e.scale?null!==r&&t<=r:r===t;return(0,cn.jsxs)("div",{style:{padding:"4px 0"},children:[(0,cn.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,justifyContent:"center"===t?"center":"flex-start"},children:u.map(t=>(0,cn.jsx)(Un,{score:t,scale:e.scale,selected:m(t),colors:o,onPick:()=>(t=>{"submitting"!==a&&(s(t),"instant"===e.submitMode&&l(t))})(t)},t))}),e.labels.low||e.labels.high?(0,cn.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:8,paddingTop:4},children:[(0,cn.jsx)("span",{style:h,children:e.labels.low}),(0,cn.jsx)("span",{style:h,children:e.labels.high})]}):null,"error"===a?(0,cn.jsx)("div",{style:{...g.caption,color:o.error,paddingTop:4},children:R}):null,"button"===e.submitMode?(0,cn.jsx)("div",{style:{padding:k},children:(0,cn.jsx)("button",{type:"button",style:{...S("primary",o),..."submitting"===a?{opacity:.7}:{}},onClick:()=>null===r?void 0:l(r),children:e.submitLabel})}):null]})}function Zn({slot:e,align:t,inverse:n,colors:o}){const i=e.color||(n?o.textInverse:o.accent);return(0,cn.jsx)("div",{style:{padding:"4px 0",textAlign:t,lineHeight:0},children:(0,cn.jsx)("svg",{width:e.size,height:e.size,viewBox:"0 0 24 24",fill:"none",stroke:i,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"inline-block"},children:(0,cn.jsx)("path",{d:z[e.name]})})})}function Gn({slot:e,align:t,inverse:n,colors:o,mode:i="live",onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:c,onSubmitRating:l,onRequestSubscribe:u,onSubscribeClose:d,logger:p}){const h=s??(()=>{});switch(e.type){case"text":return(0,cn.jsx)(Ln,{slot:e,align:t,inverse:n,colors:o});case"button":return(0,cn.jsx)(Nn,{slot:e,colors:o,onRequestClose:r,onPageChange:h,onRequestSubscribe:u,onSubscribeClose:d,logger:p});case"email-subscription-form":return(0,cn.jsx)(_n,{slot:e,align:t,inverse:n,colors:o,onSubmitForm:a});case"timer":return(0,cn.jsx)(Hn,{slot:e,align:t,inverse:n,colors:o,mode:i,onRequestClose:r,onPageChange:h});case"choice":return(0,cn.jsx)(Wn,{slot:e,align:t,inverse:n,colors:o,onSubmitChoice:c});case"rating":return(0,cn.jsx)(Kn,{slot:e,align:t,inverse:n,colors:o,onSubmitRating:l});case"glyph":return(0,cn.jsx)(Zn,{slot:e,align:t,inverse:n,colors:o});case"email-input":return(0,cn.jsx)(Pn,{slot:e,inverse:n,colors:o});case"tag-input":return(0,cn.jsx)($n,{slot:e,inverse:n,colors:o});case"consent":return(0,cn.jsx)(Rn,{slot:e,inverse:n,colors:o});case"submit":return(0,cn.jsx)(qn,{slot:e,align:t,colors:o})}}function Jn({node:e,page:t,colors:n,mode:o,leaf:i,onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:c,onSubmitRating:l,onRequestSubscribe:u,onSubscribeClose:d,logger:p}){const h=t.contents.find(t=>t.key===e.props.content);if(!h)return null;if(i?.renderZone)return(0,cn.jsx)("div",{style:{minWidth:0},children:i.renderZone(h,e)});const m=e.props.align??"left",f="inverse"===e.props.tone;return(0,cn.jsx)("div",{style:{minWidth:0},children:h.slots.map((e,t)=>{const i=h.slots[t-1],g=i?(b=x(i),"action"===(y=x(e))?"action"===b?6:16:"text"===y&&"heading"===b?4:8):0;var b,y;return(0,cn.jsx)("div",{style:g?{marginTop:g}:void 0,children:(0,cn.jsx)(Gn,{slot:e,align:m,inverse:f,colors:n,mode:o,onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:c,onSubmitRating:l,onRequestSubscribe:u,onSubscribeClose:d,logger:p})},e.key)})})}function Yn(e){return e?.video?Ue(e.video.src):void 0}function Qn({image:e,poster:t,src:n,style:o,mode:i}){return(0,cn.jsx)("video",{src:n,poster:t||void 0,style:o,autoPlay:"live"===i,muted:!0,playsInline:!0,preload:"metadata",loop:!1!==e.video?.loop,controls:!0===e.video?.controls})}function Xn({node:e,page:t,leaf:n,mode:o,scheme:i}){const r=t.images.find(t=>t.key===e.props.image);if(!r)return null;if(n?.renderImage)return(0,cn.jsx)(cn.Fragment,{children:n.renderImage(r,e)});const s=Yn(r),a=Te(r,i);if(!a&&!s)return null;const c={display:"block",width:"100%",minWidth:0};return r.fit?(c.height="100%",c.objectFit=r.fit):c.height="auto",r.blur&&(c.filter=`blur(${r.blur}px)`),s?(0,cn.jsx)(Qn,{image:r,poster:a,src:s,style:c,mode:o}):(0,cn.jsx)("img",{src:a,alt:"",style:c})}function eo({style:e,outer:t,inner:n,layer:o,children:i}){const{backgroundColor:r,...s}=e;return(0,cn.jsxs)("div",{style:{display:"grid",minWidth:0,backgroundColor:r,...t},children:[o,(0,cn.jsx)("div",{style:{...s,...n},children:i})]})}function to({node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitChoice:l,onSubmitRating:u,onRequestSubscribe:d,onSubscribeClose:p,logger:h}){if("Content"===e.type)return(0,cn.jsx)(Jn,{node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitChoice:l,onSubmitRating:u,onRequestSubscribe:d,onSubscribeClose:p,logger:h});if("Image"===e.type)return(0,cn.jsx)(Xn,{node:e,page:t,leaf:r,mode:o,scheme:i});const m=e.props?.backgroundImage,f=m?t.images.find(e=>e.key===m):void 0,g=f?.blur??0,b=f?.dim??0,y=Yn(f),v=f?Te(f,i):void 0,x=ve(e,g>0||y?void 0:v||void 0,b);m&&(x.backgroundColor="#1D2939");const k=e.children.map((e,m)=>(0,cn.jsx)(to,{node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitChoice:l,onSubmitRating:u,onRequestSubscribe:d,onSubscribeClose:p,logger:h},m));if(y&&f){const e=be(b);return(0,cn.jsx)(eo,{style:x,outer:{position:"relative",overflow:"hidden",...v?ye(v):{}},inner:{position:"relative",...e?{backgroundImage:e}:{}},layer:(0,cn.jsx)(Qn,{image:f,poster:v??"",src:y,mode:o,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",...g>0?{filter:`blur(${g}px)`}:{}}}),children:k})}return g>0?(0,cn.jsx)(eo,{style:x,outer:v?ye(v,b):void 0,inner:{backdropFilter:`blur(${g}px)`,WebkitBackdropFilter:`blur(${g}px)`},children:k}):(0,cn.jsx)("div",{style:x,children:k})}function no({page:e,params:t,mode:n="live",colorScheme:o="light",leafRenderers:i,animatePage:r=!1,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitFormValues:l,onSubmitChoice:u,onSubmitRating:d,onRequestSubscribe:p,onSubscribeClose:h,logger:m}){const f=kn(t,e.key,a,l),g=qe(t,o),b=Le(t,o),y={position:"relative",boxSizing:"border-box",overflow:"hidden",backgroundColor:g.background,colorScheme:g.scheme,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',color:g.text,borderRadius:t.borderRadius>0?t.borderRadius:void 0,boxShadow:b.boxShadow&&"none"!==b.boxShadow?b.boxShadow:void 0,transition:"height 300ms ease"};e.height&&(y.height="stretch"===e.height?"100%":e.height,y.overflowY="auto");const v={...r?{animation:"pw-vpopup-page 300ms ease-out backwards"}:{},..."stretch"===e.height?{display:"grid",minHeight:"100%"}:{}};return(0,cn.jsx)("div",{style:y,children:(0,cn.jsx)(vn.Provider,{value:f,children:(0,cn.jsx)("div",{style:v,children:(0,cn.jsx)(to,{node:e.layout,page:e,colors:g,mode:n,scheme:g.scheme,leaf:i,onRequestClose:s,onPageChange:a??(()=>{}),onSubmitForm:c,onSubmitChoice:u,onSubmitRating:d,onRequestSubscribe:p,onSubscribeClose:h,logger:m})},e.key)})})}function oo({colors:e,onRequestClose:t}){return(0,cn.jsx)("button",{type:"button","aria-label":"Close",[fn]:"",onClick:t,style:{position:"absolute",top:10,right:10,width:24,height:24,padding:0,border:"none",borderRadius:"50%",background:$e(e.surface,.92),boxShadow:"0 1px 3px rgba(16, 24, 40, 0.25)",color:e.chromeIcon,fontSize:13,lineHeight:1,cursor:"pointer"},children:"✕"})}function io(e,t,n){const{placement:o}=e,i={position:"fixed",boxSizing:"border-box",maxWidth:Ft(o),maxHeight:Ft(o),pointerEvents:"auto"};if(t){i.width=t;const e=o.h;"left"===e?i.left=o.offset:"right"===e?i.right=o.offset:i.left="50%"}else i.left=o.offset,i.right=o.offset;"stretch"===n?(i.top=o.offset,i.bottom=o.offset):"top"===o.v?i.top=o.offset:"bottom"===o.v?i.bottom=o.offset:i.top="50%";const r=t&&"center"===o.h?"-50%":"0",s="middle"===o.v&&"stretch"!==n?"-50%":"0";"0"===r&&"0"===s||(i.transform=`translate(${r}, ${s})`);const a=Tn[e.animation];return a&&(i.animation=a),i.transition="width 300ms ease",i}function ro({params:e,mode:t="live",colorScheme:n="auto",onRequestClose:o,onSubmitForm:i,onSubmitFormValues:r,onSubmitChoice:s,onSubmitRating:a,onRequestSubscribe:c,logger:l,leafRenderers:u}){const[d,p]=(0,un.useState)(null);(0,un.useEffect)(()=>{$t(e).forEach(e=>e.images.forEach(({src:e,srcDark:t})=>{[e,t].forEach(e=>{e&&((new Image).src=e)})}))},[e]);const h=hn(n,Ae(e)),m=$t(e);if(0===m.length)return null;const f=m.find(e=>e.key===d)??Et(e,m),g=null!==d;if("preview"===t)return(0,cn.jsxs)("div",{style:{position:"relative",width:f.width??"100%",transition:"width 300ms ease"},children:[(0,cn.jsx)("style",{children:V}),(0,cn.jsx)(no,{page:f,params:e,mode:t,colorScheme:h,leafRenderers:u,animatePage:g,onRequestClose:o,onPageChange:p,onSubmitForm:i,onSubmitFormValues:r,onSubmitChoice:s,onSubmitRating:a,onRequestSubscribe:c,onSubscribeClose:o,logger:l})]});const{overlay:b}=Le(e,h);return(0,cn.jsxs)(cn.Fragment,{children:[(0,cn.jsx)("style",{children:V}),b&&(0,cn.jsx)("div",{style:{position:"fixed",inset:0,backgroundColor:b.color,opacity:b.opacity,animation:"pw-vpopup-overlay 0.2s ease-out backwards",pointerEvents:"auto"},onClick:o}),(0,cn.jsxs)("div",{style:io(e,f.width,f.height),children:[(0,cn.jsx)(no,{page:f,params:e,mode:t,colorScheme:h,leafRenderers:u,animatePage:g,onRequestClose:o,onPageChange:p,onSubmitForm:i,onSubmitFormValues:r,onSubmitChoice:s,onSubmitRating:a,onRequestSubscribe:c,onSubscribeClose:o,logger:l}),(0,cn.jsx)(oo,{colors:qe(e,h),onRequestClose:o})]})]})}function so({params:e,mode:t="live",colorScheme:n="auto",logger:o,onSubmitForm:i,onSubmitFormValues:r,onSubmitChoice:s,onSubmitRating:a,onRequestSubscribe:c,onRequestRemove:l}){const[u,d]=(0,un.useState)(null),p=(0,un.useMemo)(()=>function(e){return Array.isArray(e?.pages)?{...e,pages:e.pages.map(At)}:e}(e),[e]),h=hn(n,Ae(p)),m=$t(p);if(0===m.length)return null;const f=m.find(e=>e.key===u)??Et(p,m);return(0,cn.jsxs)("div",{[mn]:"",style:bn,children:[(0,cn.jsx)("style",{children:yn}),(0,cn.jsx)(no,{page:f,params:p,mode:t,colorScheme:h,onPageChange:d,onSubmitForm:i,onSubmitFormValues:r,onSubmitChoice:s,onSubmitRating:a,onRequestSubscribe:c,onSubscribeClose:l,logger:o})]})}const ao={SUBMIT_FORM_RESULT_SUBSCRIBED:"subscribed",SUBMIT_FORM_RESULT_CONFIRM_EMAIL:"confirm-email",SUBMIT_FORM_RESULT_ALREADY_SUBSCRIBED:"already-subscribed"},co=(e,t)=>`https://subscription-form.svc-nue.pushwoosh.com/api/v1/forms/code/${encodeURIComponent(e)}${t}`,lo=async(e,t)=>{try{const n=await fetch(co(e,"/submit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,userId:t.email})});if(!n.ok)throw new Error(`Subscription form submit failed: HTTP ${n.status}`);const o=await n.json(),i=ao[o.result??""];if(!i)throw new Error(`Subscription form submit failed: unexpected result "${o.result}"`);return i}catch(t){throw on.error(t,`Failed to submit subscription form "${e}"`),t}},uo={warn:e=>on.error(zt,e)},po=e=>"EMBEDDED"===e.kind;class ho{constructor(e){this.blocks=new Map,this.viewed=new Set,this.autoSkipLogged=new Set,this.deps=e}syncWithPage(e,t){for(const n of e){if(!po(n.popup))continue;const{code:e}=n.popup;!1===this.blocks.get(e)?.host.isConnected&&this.remove(e),"api"!==this.blocks.get(e)?.trigger&&(this.deps.matchesPage(n.popup)?n.content&&t(n)&&this.place(n,n.content,"auto"):this.remove(e))}}show(e,t){return this.place(e,t,"api")}removeWhere(e){for(const[t,n]of[...this.blocks])e(n.entry)&&this.remove(t)}place(e,t,n){const{popup:o}=e,i=this.findContainer(o,n);if(!i)return this.remove(o.code),!1;const r=this.blocks.get(o.code);if(r?.element===i&&r.host.isConnected)return"api"===n&&(r.trigger="api"),!0;this.remove(o.code);const s=document.createElement("div");s.id=`${Vt}-embedded-${o.code}`,s.setAttribute(Ot,String(e.order)),s.style.width="100%",i.insertBefore(s,this.firstBlockAfter(i,e.order));const a=s.attachShadow({mode:"open"}),c=document.createElement("div");return a.appendChild(c),this.deps.render(c,t,e),this.blocks.set(o.code,{entry:e,element:i,host:s,container:c,trigger:n,observer:this.watchFirstView(e,t,s)}),this.reportShown(e,n),!0}firstBlockAfter(e,t){return Array.from(e.children).find(e=>e.hasAttribute(Ot)&&Number(e.getAttribute(Ot))>t)??null}remove(e){const t=this.blocks.get(e);t&&(this.blocks.delete(e),t.observer?.disconnect(),this.deps.unmount(t.container),t.host.remove())}findContainer(e,t){const{code:n,css_selector:o}=e;if(!o)return this.logSkip(n,t,`${zt} Embedded "${n}" has no css_selector; skipping`),null;try{const e=document.querySelector(o);return e||this.logSkip(n,t,`${zt} Embedded "${n}": nothing matches "${o}" on this page; skipping`),e}catch(e){return this.logSkip(n,t,`${zt} Embedded "${n}": invalid css_selector "${o}"; skipping`,e),null}}logSkip(e,t,...n){if("auto"===t){if(this.autoSkipLogged.has(e))return;this.autoSkipLogged.add(e)}on.debug(...n)}reportShown(e,t){const{code:n}=e.popup;this.deps.recordVisit(e),on.debug(`${zt} Embedded "${n}" rendered (trigger: ${t})`),this.deps.dispatchShown(n,t)}watchFirstView(e,t,n){if(this.viewed.has(e.popup.code))return null;if("function"!=typeof IntersectionObserver)return this.reportViewed(e.popup.code,t),null;const o=new IntersectionObserver(n=>{n.some(e=>e.isIntersecting)&&(o.disconnect(),this.reportViewed(e.popup.code,t))});return o.observe(n),o}reportViewed(e,t){this.viewed.has(e)||(this.viewed.add(e),this.deps.recordImpression(e),this.deps.recordFormViews(e,t))}}const mo={not_determined:"DEFAULT",granted_explicit:"GRANTED",denied:"DENIED",unsupported:"UNSUPPORTED"},fo=new Set(Object.values(mo));function go(e,t){const n=t.push_permission_status?.toUpperCase();return!n||!fo.has(n)||function(e){if("function"==typeof e.getPushPermissionStatus)try{return mo[e.getPushPermissionStatus()]}catch{return}}(e)===n}const bo=e=>{(0,ln.render)(null,e)};function yo(){const{pathname:e}=window.location;try{return decodeURIComponent(e).toLowerCase()}catch{return e.toLowerCase()}}class vo{constructor(e){this.isRecurringVisitor=!1,this.entries=new Map,this.contentEntries=new Map,this.queue=[],this.visible=null,this.drainTimeoutId=null,this.autoShowEnabled=!0,this.colorScheme="auto",this.isNavigationSubscribed=!1,this.openPopupsCount=0,this.bodyOverflowBeforeLock=null,this.readyPromise=new Promise(e=>{this.readyResolve=e}),this.pw=e,this.submitHandlers={onSubmitChoice:rn(e),onSubmitRating:sn(e),onRequestSubscribe:an(e)},this.embedded=new ho({matchesPage:e=>this.checkSoftCondition(e),render:(e,t,n)=>{this.listenForInteractions(e,n),((e,t,n,o="auto",i)=>{(0,ln.render)((0,cn.jsx)(so,{params:t,colorScheme:o,onSubmitForm:lo,onSubmitFormValues:n.onSubmitFormValues,onSubmitChoice:n.onSubmitChoice,onSubmitRating:n.onSubmitRating,onRequestSubscribe:n.onRequestSubscribe,onRequestRemove:i,logger:uo}),e)})(e,t,this.handlersFor(n),this.colorScheme,()=>this.embedded.removeWhere(e=>e===n))},unmount:bo,recordVisit:e=>this.recordVisit(e),recordImpression:e=>this.recordPopupShownEvent(e),recordFormViews:(e,t)=>this.recordSubscriptionFormViews(e,t),dispatchShown:(e,t)=>this.pw.dispatchEvent("show-web-popup",{code:e,trigger:t})}),e.moduleRegistry.webPopups=this}async run(){const{pw:e}=this;try{if(!1===e.initParams.webPopups?.enable)return void on.info(`${zt} switched off by webPopups.enable, skipping`);this.autoShowEnabled=!1!==e.initParams.webPopups?.autoShow,this.colorScheme=e.initParams.webPopups?.colorScheme??"auto";const t=await e.data.getFeatures();if(!1===t?.popup_forms?.enabled)return void on.debug(`${zt} application has no active popup forms, skipping automatic display`);await e.api.ensureDeviceRegistered(),this.isRecurringVisitor=await e.data.getIsRecurringVisitor();const n=await e.api.getPopupForms();on.debug(`${zt} Received ${n.length} popup(s) from server:`,n.map(e=>e.code)),n.forEach((e,t)=>{this.entries.set(e.code,this.createEntry("campaign",e,t))}),await Promise.allSettled(Array.from(this.entries.values()).map(async e=>{e.passedStrongConditions=this.checkStrongCondition(e.popup),e.passedFrequency=await this.checkCanBeShownByFrequencyCondition(e.popup).catch(()=>!1),this.shouldPrefetchContent(e)&&await this.ensureContent(e)}));const o=this.loadedCodes();on.debug(`${zt} ${o.length} popup(s) passed strong conditions and loaded:`,o),this.subscribeToNavigation(),this.subscribeToPushPermission(),this.renderForCurrentPage(),await e.data.setIsRecurringVisitor(!0)}finally{this.readyResolve(),e.dispatchEvent("web-popups-ready",{})}}async show(e){await this.readyPromise;const t=this.entries.get(e)??this.getContentEntry(e),n="campaign"===t.kind&&po(t.popup);if(!n&&this.visible?.code===e)return!0;if(!go(this.pw,t.popup))return on.debug(`${zt} show("${e}"): the visitor's push permission does not match the campaign`),!1;const o=await this.ensureContent(t);return o?"content"===t.kind&&$t(o).some(e=>e.contents.some(e=>e.slots.some(e=>qt.has(e.type))))?(on.error(new Error("Web popup form needs a campaign"),`${zt} show("${e}"): a form content is shown by a campaign only`),!1):n?this.embedded.show(t,o):this.visible?.code===e||!!this.checkNotExpired(t)&&(this.visible&&(on.debug(`${zt} show("${e}") preempting "${this.visible.code}"`),this.visible.close("preempted")),this.detachFromAutoPipeline(t),this.present(t,"api"),!0):(on.error(new Error("Web popup content unavailable"),`${zt} show("${e}"): content unavailable`),!1)}hide(e){return!!this.visible&&((void 0===e||this.visible.code===e)&&(this.visible.close("api"),!0))}hideAll(){const e=this.hide();return this.entries.forEach(e=>{"waiting"!==e.state&&"queued"!==e.state||(this.detachFromAutoPipeline(e),e.state="done")}),this.cancelScheduledDrain(),e}isVisible(e){return!!this.visible&&(void 0===e||this.visible.code===e)}getVisibleCode(){return this.visible?.code??null}getAvailableCodes(){return Array.from(this.entries.keys())}getState(){const e=[];return this.entries.forEach((t,n)=>{"waiting"===t.state&&e.push(n)}),{visible:this.getVisibleCode(),queued:[...this.queue],waiting:e,available:this.getAvailableCodes()}}createEntry(e,t,n){return{kind:e,popup:t,order:n,state:"idle",content:null,loading:null,passedStrongConditions:!1,passedFrequency:!1,timeoutId:null,visitRecorded:!1}}getContentEntry(e){let t=this.contentEntries.get(e);return t||(t=this.createEntry("content",{code:e,popup_form_content_code:e,device_type:"ALL",visitors_type:"ALL",matching_pages:[],delay:0,frequency:"EVERY_VISIT",trigger_type:"API"},-1),this.contentEntries.set(e,t)),t}ensureContent(e){return e.content?Promise.resolve(e.content):(e.loading||(e.loading=this.loadContent(e.popup).then(t=>(e.content=t,t)).catch(t=>(on.error(t,`${zt} Failed to load web popup "${e.popup.code}"`),null)).finally(()=>{e.content||(e.loading=null)})),e.loading)}async loadContent(e){const t=(e=>{const t=et(e);return t?0===$t(t.params).length?null:t.params:null})((await this.pw.api.getPopupFormContent(e.popup_form_content_code)).json);return t||(on.error(new Error("Unsupported popup content format"),`${zt} Web popup "${e.code}" content is not a supported {version, params} popup; skipping`),null)}shouldPrefetchContent(e){return e.passedStrongConditions&&(po(e.popup)||e.passedFrequency)}loadedCodes(){const e=[];return this.entries.forEach((t,n)=>{t.content&&e.push(n)}),e}renderForCurrentPage(){this.releaseUnmatchedPending();const e=[];this.entries.forEach((t,n)=>{this.canAutoDisplay(t)&&(this.armDelay(t),e.push(n))}),on.debug(`${zt} ${e.length} popup(s) selected for display on "${yo()}":`,e),this.drain(),this.embedded.syncWithPage(this.entries.values(),e=>this.isAutoEligible(e))}canAutoDisplay(e){return!po(e.popup)&&"idle"===e.state&&this.isAutoEligible(e)&&e.passedFrequency&&this.checkNotExpired(e)}isAutoEligible(e){return this.autoShowEnabled&&e.passedStrongConditions&&this.isAutoTrigger(e.popup)&&null!==e.content&&this.checkSoftCondition(e.popup)&&go(this.pw,e.popup)}isStillEligible(e){return this.checkSoftCondition(e.popup)&&go(this.pw,e.popup)&&this.checkNotExpired(e)}isAutoTrigger(e){const t=e.trigger_type;return!t||"PAGE_LOAD"===t}armDelay(e){const{popup:t}=e;on.debug(`${zt} Popup "${t.code}" armed for display in ${t.delay}s`),e.state="waiting",this.recordVisit(e),e.timeoutId=window.setTimeout(()=>{e.timeoutId=null,e.state="queued",this.insertIntoQueue(e),on.debug(`${zt} Popup "${t.code}" delay elapsed; queued at position ${this.queue.indexOf(t.code)+1} of ${this.queue.length}`),this.drain()},1e3*t.delay)}recordVisit(e){e.visitRecorded||(e.visitRecorded=!0,this.pw.api.recordPopupFormEvent(e.popup.code,1).catch(t=>{on.error(t,`${zt} Failed to record web popup visit event for "${e.popup.code}"`)}))}insertIntoQueue(e){const t=this.queue.findIndex(t=>{const n=this.entries.get(t);return!!n&&(n.popup.delay!==e.popup.delay?n.popup.delay>e.popup.delay:n.order>e.order)});-1!==t?this.queue.splice(t,0,e.popup.code):this.queue.push(e.popup.code)}releaseUnmatchedPending(){this.entries.forEach(e=>{"waiting"!==e.state&&"queued"!==e.state||this.isStillEligible(e)||(this.detachFromAutoPipeline(e),e.state="idle",on.debug(`${zt} Released popup "${e.popup.code}": page or push permission no longer matches, or its countdown passed`))})}detachFromAutoPipeline(e){null!==e.timeoutId&&(window.clearTimeout(e.timeoutId),e.timeoutId=null);const t=this.queue.indexOf(e.popup.code);-1!==t&&this.queue.splice(t,1)}drain(){if(this.visible||null!==this.drainTimeoutId)return;const e=this.queue.shift();if(void 0===e)return;const t=this.entries.get(e);if(t&&"queued"===t.state){if(!this.isStillEligible(t))return t.state="idle",void this.drain();if(!t.content)return t.state="done",void this.drain();on.debug(`${zt} Display slot free; showing "${e}"`),this.present(t,"auto")}else this.drain()}scheduleDrain(){null===this.drainTimeoutId&&(this.drainTimeoutId=window.setTimeout(()=>{this.drainTimeoutId=null,this.drain()},400))}cancelScheduledDrain(){null!==this.drainTimeoutId&&(window.clearTimeout(this.drainTimeoutId),this.drainTimeoutId=null)}present(e,t){this.cancelScheduledDrain();const{popup:n,content:o}=e;if(!o)return void(e.state="done");const i=document.createElement("div");i.id=`${Vt}-${n.code}`,i.style.position="fixed",i.style.inset="0",i.style.zIndex=String(2147483647),i.style.pointerEvents="none",document.body.appendChild(i);const r=i.attachShadow({mode:"open"}),s=document.createElement("div");r.appendChild(s),this.listenForInteractions(s,e);const a=!!o.overlay;a&&this.lockBodyScroll();let c=!1;const l=t=>{c||(c=!0,a&&this.unlockBodyScroll(),bo(s),i.remove(),this.visible?.code===n.code&&(this.visible=null),e.state="done",this.pw.dispatchEvent("hide-web-popup",{code:n.code,reason:t}),this.scheduleDrain())};this.visible={code:n.code,host:i,modal:a,close:l},e.state="visible",((e,t,n,o,i="auto")=>{(0,ln.render)((0,cn.jsx)(ro,{params:t,mode:"live",colorScheme:i,onRequestClose:n,onSubmitForm:lo,onSubmitFormValues:o.onSubmitFormValues,onSubmitChoice:o.onSubmitChoice,onSubmitRating:o.onSubmitRating,onRequestSubscribe:o.onRequestSubscribe,logger:uo}),e)})(s,o,()=>l("user"),this.handlersFor(e),this.colorScheme),this.recordSubscriptionFormViews(n.code,o),on.debug(`${zt} Popup "${n.code}" shown (trigger: ${t})`),"campaign"===e.kind&&(this.recordVisit(e),this.markAsShown(n).catch(e=>{on.error(e,`${zt} Failed to mark web popup "${n.code}" as shown`)})),this.pw.dispatchEvent("show-web-popup",{code:n.code,trigger:t})}handlersFor(e){return{...this.submitHandlers,onSubmitFormValues:(t=this.pw,n=e.popup.code,async e=>{try{const o=await t.api.submitPopupForm(n,e);if("OK"===o.result)return"ok";if("INVALID_EMAIL"===o.result)return"invalid-email";throw new Error(`Unexpected submitPopupForm result "${o.result}"`)}catch(e){throw on.error(e,`Failed to submit the form of web campaign "${n}"`),e}})};var t,n}recordSubscriptionFormViews(e,t){const n=function(e){const t=new Set;for(const n of e.pages)if(Array.isArray(n?.contents))for(const e of n.contents)if(Array.isArray(e?.slots))for(const n of e.slots)"object"==typeof n&&null!==n&&"email-subscription-form"===n.type&&"string"==typeof n.formCode&&n.formCode&&t.add(n.formCode);return[...t]}(t);0!==n.length&&this.pw.data.getHwid().then(e=>n.forEach(t=>((e,t)=>{fetch(co(e,"/view"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,userId:t,hwid:t})}).catch(t=>{on.error(t,`Failed to record subscription form view for "${e}"`)})})(t,e))).catch(t=>{on.error(t,`${zt} Failed to record subscription form views for web popup "${e}"`)})}lockBodyScroll(){0===this.openPopupsCount&&(this.bodyOverflowBeforeLock=document.body.style.overflow,document.body.style.overflow="hidden"),this.openPopupsCount+=1}unlockBodyScroll(){this.openPopupsCount=Math.max(0,this.openPopupsCount-1),0===this.openPopupsCount&&null!==this.bodyOverflowBeforeLock&&(document.body.style.overflow=this.bodyOverflowBeforeLock,this.bodyOverflowBeforeLock=null)}subscribeToNavigation(){if(this.isNavigationSubscribed)return;this.isNavigationSubscribed=!0;const e=()=>this.renderForCurrentPage(),t=window.navigation;if(t&&"function"==typeof t.addEventListener)return void t.addEventListener("currententrychange",e);window.addEventListener("popstate",e),window.addEventListener("hashchange",e);let n=window.location.href;window.setInterval(()=>{window.location.href!==n&&(n=window.location.href,e())},500)}subscribeToPushPermission(){const e=()=>this.releaseByPushPermission();"function"!=typeof this.pw.addSdkEventHandler?this.pw.addEventHandler("change-permission",e):this.pw.addSdkEventHandler("change-permission",e)}releaseByPushPermission(){this.releaseUnmatchedPending(),this.embedded.removeWhere(e=>!go(this.pw,e.popup))}checkStrongCondition(e){return this.checkCanBeShownByDeviceTypeCondition(e)&&this.checkCanBeShownByVisitorsTypeCondition(e)}checkSoftCondition(e){return this.checkCanBeShownByMatchingPagesCondition(e)}checkNotExpired(e){return!e.content||(!function(e,t){for(const n of e.pages)if(Array.isArray(n?.contents))for(const e of n.contents)if(Array.isArray(e?.slots))for(const n of e.slots){if("object"!=typeof n||null===n)continue;if("timer"!==n.type||"hide-popup"!==n.onExpire)continue;if("string"!=typeof n.endTime)continue;const e="string"==typeof n.timezone?n.timezone:"",o=He(n.endTime,e);if(null!==o&&o<=t)return!0}return!1}(e.content,Date.now())||(on.debug(`${zt} Popup "${e.popup.code}" not shown: its countdown has passed`),!1))}checkCanBeShownByDeviceTypeCondition(e){const{device_type:t}=e,n=this.pw.platformChecker.formFactor;return"ALL"===t||t===n}async checkCanBeShownByFrequencyCondition(e){const{frequency:t,code:n}=e;if("ONCE"===t){return!(await this.pw.data.getShownWebPopups()).includes(n)}return"ONCE_PER_SESSION"!==t||null===sessionStorage.getItem(this.getSessionStorageKey(n))}checkCanBeShownByMatchingPagesCondition(e){const{matching_pages:t,matching_page_rules:n,excluded_pages:o}=e,i=yo();return n&&n.length>0?n.some(e=>this.matchPageRule(i,e)):t&&t.length>0?t.some(e=>Boolean(e)&&e.toLowerCase()===i):!(o&&o.length>0)||!o.some(e=>this.matchPageRule(i,e))}matchPageRule(e,t){if(!t.path)return!1;const n=t.path.toLowerCase();switch(t.operator){case"EQUALS":return e===n;case"STARTS_WITH":return e.startsWith(n);default:return!1}}checkCanBeShownByVisitorsTypeCondition(e){const{visitors_type:t}=e;return"NEW"===t?!this.isRecurringVisitor:"RECURRING"!==t||this.isRecurringVisitor}recordPopupShownEvent(e){this.pw.api.recordPopupFormEvent(e,2).catch(t=>{on.error(t,`${zt} Failed to record web popup shown event for "${e}"`)})}listenForInteractions(e,t){"campaign"===t.kind&&function(e,t){e.addEventListener("click",e=>{const n=e.target instanceof Element?e.target.closest("a, button"):null;n&&!n.hasAttribute(fn)&&(n.hasAttribute(gn)||t())})}(e,()=>{this.pw.api.recordPopupFormEvent(t.popup.code,3).catch(e=>{on.error(e,`${zt} Failed to record web popup interaction for "${t.popup.code}"`)})})}async markAsShown(e){this.recordPopupShownEvent(e.code);const{frequency:t,code:n}=e;"ONCE"!==t?"ONCE_PER_SESSION"===t&&sessionStorage.setItem(this.getSessionStorageKey(n),"1"):await this.pw.data.addShownWebPopup(n)}getSessionStorageKey(e){return`${Vt}.shown.${e}`}}return s})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("preact"),require("preact/compat"),require("preact/jsx-runtime"));else if("function"==typeof define&&define.amd)define(["preact","preact/compat","preact/jsx-runtime"],t);else{var n="object"==typeof exports?t(require("preact"),require("preact/compat"),require("preact/jsx-runtime")):t(e.preact,e.preactCompat,e.jsxRuntime);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,(e,t,n)=>(()=>{"use strict";var o={524(t){t.exports=e},873(e){e.exports=t},247(e){e.exports=n}};const i={};function r(e){const t=i[e];if(void 0!==t)return t.exports;const n=i[e]={exports:{}};return o[e](n,n.exports,r),n.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};let s={};r.r(s),r.d(s,{WebPopupsWidget:()=>vo});const a=/^(https?:|mailto:|tel:)/i,c="#101828",l="#667085",u="#FFFFFF",d="#FFFFFF",p="#2970FF",h=c,m=l,f="#FFFFFF",g={h1:{fontSize:24,fontWeight:600,lineHeight:1.25},h2:{fontSize:18,fontWeight:600,lineHeight:1.3},h3:{fontSize:16,fontWeight:600,lineHeight:1.35},body:{fontSize:14,fontWeight:"normal",lineHeight:1.5},caption:{fontSize:12,fontWeight:"normal",lineHeight:1.4},eyebrow:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",lineHeight:1.4},icon:{fontSize:24,lineHeight:1.2}},b={h1:1,h2:1,h3:1,icon:1,eyebrow:.8,body:.9,caption:.75};function y(e,t,n){return n?function(e,t){if(t>=1)return e;const n=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(e)?.[1];if(!n)return e;const o=3===n.length?n.split("").map(e=>e+e).join(""):n,[i,r,s]=[0,2,4].map(e=>parseInt(o.slice(e,e+2),16));return`rgba(${i}, ${r}, ${s}, ${t})`}(t.textInverse,b[e]??1):"icon"!==e?"caption"===e||"eyebrow"===e?t.textSecondary:t.text:void 0}const v=["h1","h2","h3","icon"];function x(e){return"glyph"===e.type?"heading":"text"!==e.type?"action":v.includes(e.variant)?"heading":"text"}const k="8px 0 4px";function S(e,t){return{display:"block",boxSizing:"border-box",width:"100%",padding:"10px 25px",borderRadius:6,fontSize:14,fontWeight:600,fontFamily:"inherit",lineHeight:1.5,textAlign:"center",textDecoration:"none",cursor:"pointer",..."secondary"===e?{backgroundColor:t.surface,color:t.accent,border:`1px solid ${t.accent}`}:{backgroundColor:t.accent,color:t.onAccent,border:"none"}}}function w(e,t=e.border){return{display:"block",boxSizing:"border-box",width:"100%",padding:"10px 12px",borderRadius:6,fontSize:14,fontFamily:"inherit",lineHeight:1.5,backgroundColor:e.surface,color:e.surfaceText,border:`1px solid ${t}`,outline:"none"}}const j="Subscribe",C="Thanks for subscribing!",M="Please check your inbox and confirm your email.",P="Save",$="Thanks! Your choice is saved.",E="Send",F="Thanks for the feedback!";const R="Something went wrong. Please try again.",A=/^\S+@\S+\.\S+$/,I="Enter a valid email",q="Required",T="Required",L="Please accept the privacy policy",N="Submit",D=R,V="\n@keyframes pw-vpopup-fade { from { opacity: 0; } }\n@keyframes pw-vpopup-slide { from { opacity: 0; translate: 0 28px; } }\n@keyframes pw-vpopup-overlay { from { opacity: 0; } }\n@keyframes pw-vpopup-page { from { opacity: 0; } }\n",z={bell:"M6 10a6 6 0 0 1 12 0c0 4 1.5 5.5 2 6H4c.5-.5 2-2 2-6M10 20a2 2 0 0 0 4 0",gift:"M3 11h18v9a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1zM2.5 7h19v4h-19zM12 7v14M12 7c-1 0-3-.2-3.5-1a2 2 0 0 1 3.5-1 2 2 0 0 1 3.5 1c-.5.8-2.5 1-3.5 1z",cart:"M2 4h2.2l2.4 11.2A2 2 0 0 0 8.6 17H19M6 7h15l-2.2 7.5H8M10.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M19.5 20a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0",chart:"M3 21h18M7 21V11M12 21V6M17 21v-8",lock:"M5 11h14v10H5zM8 11V8a4 4 0 0 1 8 0v3",calendar:"M4 6h16v15H4zM4 10h16M9 3v4M15 3v4",check:"M4 13l5 5L20 6",star:"M12 3l2.9 5.9 6.5.9-4.7 4.6 1.1 6.5-5.8-3.1-5.8 3.1 1.1-6.5L2.6 9.8l6.5-.9z",clock:"M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0M12 7v5l4 2",tag:"M20.6 13.4l-7.2 7.2a2 2 0 0 1-2.8 0l-7-7A2 2 0 0 1 3 12.2V5a2 2 0 0 1 2-2h7.2a2 2 0 0 1 1.4.6l7 7a2 2 0 0 1 0 2.8zM9 8a1 1 0 1 1-2 0 1 1 0 0 1 2 0",mail:"M3 6h18v12H3zM3 7l9 6 9-6",phone:"M7 2h10a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1M10 19h4",download:"M12 3v12M7 11l5 5 5-5M4 20h16",play:"M8 5l12 7-12 7z",shield:"M12 3l8 3v6c0 5-3.4 8.6-8 10-4.6-1.4-8-5-8-10V6z",sparkle:"M12 3l1.8 5.2L19 10l-5.2 1.8L12 17l-1.8-5.2L5 10l5.2-1.8zM18 15l.9 2.1 2.1.9-2.1.9-.9 2.1-.9-2.1L15 18l2.1-.9z",percent:"M19 5L5 19M8.5 8.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0M20.5 15.5a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0",truck:"M2 7h12v10H2zM14 10h4l3 3v4h-7M8.5 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0M20 19a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0",ticket:"M4 7h16v4a2 2 0 0 0 0 4v3H4v-3a2 2 0 0 0 0-4zM14 7v12",user:"M20 21a8 8 0 0 0-16 0M16 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0"},O=Object.keys(z),_=[24,32,48],B=["Vertical","Horizontal","Columns","Rows"],H=["normal","reverse"],W=["start","center","end","stretch"],U=["start","center","end","space-between"],K=["left","center","right"],Z=["default","inverse"],G=2e3,J={px:G,"%":100,em:125,rem:125},Y=/^(\d{1,4}(?:\.\d+)?)(px|%|em|rem)$/,Q={px:G,"%":100,fr:100},X=/^(\d{1,4}(?:\.\d+)?)(px|%|fr)$/,ee=["auto","min-content","max-content"];function te(e,t){return t.includes(e)?e:void 0}function ne(e){if("number"==typeof e&&Number.isFinite(e))return Math.min(Math.max(e,0),G);if("string"!=typeof e)return;const t=Y.exec(e.trim());if(!t)return;const[,n,o]=t;return`${Math.min(parseFloat(n),J[o])}${o}`}const oe=["top","right","bottom","left"];function ie(e){if(ee.includes(e))return e;const t=X.exec(e);if(!t)return;const[,n,o]=t;return`${Math.min(parseFloat(n),Q[o])}${o}`}function re(e){return"string"==typeof e&&e.length>0?e:void 0}function se(e){const t={},n=ne(e.gap);void 0!==n&&(t.gap=n);const o=function(e){const t=ne(e);if(void 0!==t)return t;if("object"!=typeof e||null===e)return;const n={};for(const t of oe){const o=ne(e[t]);void 0!==o&&(n[t]=o)}return Object.keys(n).length>0?n:void 0}(e.padding);void 0!==o&&(t.padding=o);const i=te(e.alignItems,W);i&&(t.alignItems=i);const r=te(e.justifyContent,U);r&&(t.justifyContent=r);const s=te(e.alignContent,U);s&&(t.alignContent=s);const a=re(e.backgroundImage);a&&(t.backgroundImage=a);const c=function(e){if("number"==typeof e)return Number.isInteger(e)&&e>=1&&e<=12?e:void 0;if("string"!=typeof e)return;const t=e.trim().split(/\s+/);if(t.length<1||t.length>12)return;const n=t.map(ie);return n.every(e=>void 0!==e)?n.join(" "):void 0}(e.sizes);return void 0!==c&&(t.sizes=c),t}function ae(e,t,n){if(t>10||n.nodes<=0)return null;if("object"!=typeof e||null===e)return null;n.nodes-=1;const o=e,i="object"==typeof o.props&&null!==o.props?o.props:{};if("Content"===o.type){const e=re(i.content);if(!e)return null;const t={type:"Content",props:{content:e}},n=te(i.align,K);n&&(t.props.align=n);const o=te(i.tone,Z);return o&&"default"!==o&&(t.props.tone=o),t}if("Image"===o.type){const e=re(i.image);if(!e)return null;return{type:"Image",props:{image:e}}}if(!Array.isArray(o.children))return null;const r=te(o.type,B)??"Vertical",s=[];for(const e of o.children){const o=ae(e,t+1,n);o&&s.push(o)}const a=se(i);return"reverse"===te(i.order,H)&&(s.reverse(),"string"==typeof a.sizes&&(a.sizes=a.sizes.split(" ").reverse().join(" "))),{type:r,props:a,children:s}}function ce(e){return ae(e,0,{nodes:100})}const le=/^[a-zA-Z][a-zA-Z0-9-]*$/,ue=/^\$([a-zA-Z][a-zA-Z0-9-]*)$/;function de(e,t){return e.includes("$")?e.split(/(\s+)/).map(e=>{const n=ue.exec(e)?.[1];return void 0!==n&&Object.prototype.hasOwnProperty.call(t,n)?t[n]:e}).join(""):e}function pe(e,t){return"object"!=typeof e||null===e||0===Object.keys(t).length?e:me(e,t,0)}const he=new Set(["content","image","backgroundImage"]);function me(e,t,n){if(n>10||"object"!=typeof e||null===e)return e;const o=e,i={...o};if("object"==typeof o.props&&null!==o.props){const e={...o.props};for(const[n,o]of Object.entries(e))if(!he.has(n))if("string"==typeof o)e[n]=de(o,t);else if("object"==typeof o&&null!==o&&!Array.isArray(o)){const i={...o};for(const[e,n]of Object.entries(i))"string"==typeof n&&(i[e]=de(n,t));e[n]=i}i.props=e}return Array.isArray(o.children)&&(i.children=o.children.map(e=>me(e,t,n+1))),i}function fe(e){return"number"==typeof e?`${e}px`:e}function ge(e,t){if("string"==typeof e)return e;return`repeat(${"number"==typeof e?e:Math.max(t,1)}, 1fr)`}function be(e=0){if(!(e>0))return null;const t=`rgba(16, 24, 40, ${Math.min(e,1)})`;return`linear-gradient(${t}, ${t})`}function ye(e,t=0){const n=`url(${JSON.stringify(e)})`,o=be(t);return{backgroundImage:o?`${o}, ${n}`:n,backgroundSize:"cover",backgroundPosition:"center"}}function ve(e,t,n=0){const o=e.props??{},i={display:"grid",minWidth:0};return"Horizontal"===e.type&&(i.gridAutoFlow="column"),"Columns"===e.type&&(i.gridTemplateColumns=ge(o.sizes,e.children.length)),"Rows"===e.type&&(i.gridTemplateRows=ge(o.sizes,e.children.length)),void 0!==o.gap&&(i.gap=fe(o.gap)),void 0!==o.padding&&(i.padding=function(e){if("number"==typeof e||"string"==typeof e)return fe(e);const t=e=>void 0===e?"0":fe(e);return`${t(e.top)} ${t(e.right)} ${t(e.bottom)} ${t(e.left)}`}(o.padding)),o.alignItems&&(i.alignItems=o.alignItems),o.justifyContent&&(i.justifyContent=o.justifyContent),o.alignContent&&(i.alignContent=o.alignContent),t&&Object.assign(i,ye(t,n)),i}const xe=/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;function ke(e){const t=xe.exec(e.trim())?.[1];if(!t)return null;const n=3===t.length?t.split("").map(e=>e+e).join(""):t;return[0,2,4].map(e=>parseInt(n.slice(e,e+2),16))}function Se([e,t,n]){return`#${[e,t,n].map(e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")).join("")}`}function we(e,t,n){let o=n;return o<0&&(o+=1),o>1&&(o-=1),o<1/6?e+6*(t-e)*o:o<.5?t:o<2/3?e+(t-e)*(2/3-o)*6:e}function je(e){return e>.5?.07+.86*(1-e):e}function Ce(e){return e<.5?.93-e*((.93-.5)/.5):e}function Me(e,t){const n=ke(e);if(!n)return e;const[o,i,r]=function([e,t,n]){const[o,i,r]=[e/255,t/255,n/255],s=Math.max(o,i,r),a=Math.min(o,i,r),c=(s+a)/2;if(s===a)return[0,0,c];const l=s-a;let u;return u=s===o?(i-r)/l+(i<r?6:0):s===i?(r-o)/l+2:(o-i)/l+4,[u/6,c>.5?l/(2-s-a):l/(s+a),c]}(n);return Se(function([e,t,n]){if(0===t){const e=255*n;return[e,e,e]}const o=n<.5?n*(1+t):n+t-n*t,i=2*n-o;return[255*we(i,o,e+1/3),255*we(i,o,e),255*we(i,o,e-1/3)]}([o,i,"fold"===t?je(r):Ce(r)]))}function Pe(e,t,n){const o=ke(e),i=ke(t);return o&&i?Se(o.map((e,t)=>e+(i[t]-e)*n)):e}function $e(e,t){const n=ke(e);if(!n||t>=1)return e;const[o,i,r]=n;return`rgba(${o}, ${i}, ${r}, ${t})`}function Ee(e){const t=ke(e);if(!t)return!1;const[n,o,i]=t;return(.299*n+.587*o+.114*i)/255>.6}function Fe(e){return{background:Me(e.background,"fold"),accent:e.accent,text:Me(e.text,"lift"),textSecondary:Me(e.textSecondary,"lift"),textInverse:e.textInverse}}function Re(e,t){return"light"===t?{surface:d,surfaceText:c,border:"#D0D5DD",onAccent:u,error:"#D92D20",chromeIcon:l}:{surface:Pe(e.background,e.text,.08),surfaceText:e.text,border:Pe(e.background,e.text,.24),onAccent:Ee(e.accent)?c:u,error:"#FDA29B",chromeIcon:e.textSecondary}}function Ae(e){return!0===e.dark?.enabled}function Ie(e,t="light"){return"dark"===t&&Ae(e)?"dark":"light"}function qe(e,t="light"){const n=Ie(e,t),o="dark"===n?(i=e.colors,r=e.dark,{...Fe(i),...r?.colors??{}}):e.colors;var i,r;return{...o,scheme:n,...Re(o,n)}}function Te(e,t="light"){return"dark"===t&&e.srcDark?e.srcDark:e.src}function Le(e,t="light"){return"light"===Ie(e,t)?{overlay:e.overlay,boxShadow:e.boxShadow}:{overlay:e.dark?.overlay??e.overlay,boxShadow:e.dark?.boxShadow??e.boxShadow}}const Ne=/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?$/,De=new Map;function Ve(e){const t=De.get(e);if(t)return t;try{const t=new Intl.DateTimeFormat("en-US",{timeZone:e,hour12:!1,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});return De.set(e,t),t}catch{return null}}function ze(e){return!e||null!==Ve(e)}function Oe(e,t){const n=t.formatToParts(new Date(e)),o=e=>Number(n.find(t=>t.type===e)?.value??"0");return Date.UTC(o("year"),o("month")-1,o("day"),o("hour")%24,o("minute"),o("second"))-e}const _e=864e5;const Be=new Map;function He(e,t){const n=`${e}|${t}`,o=Be.get(n);if(void 0!==o)return o;const i=function(e,t){const n=Ne.exec((e||"").trim());if(!n)return null;const[,o,i,r,s,a,c]=n.map(Number),l=Number.isNaN(c)?0:c;if(i<1||i>12||r<1||r>31)return null;if(s>23||a>59||l>59)return null;const u=Date.UTC(o,i-1,r,s,a,l),d=new Date(u);if(d.getUTCMonth()!==i-1||d.getUTCDate()!==r)return null;if(!t)return u;const p=Ve(t);if(!p)return null;const h=function(e,t){const n=[];for(const o of[e-_e,e,e+_e]){const e=Oe(o,t);n.includes(e)||n.push(e)}return n}(u,p),m=h.filter(e=>Oe(u-e,p)===e).map(e=>u-e);return m.length>0?Math.min(...m):u-Math.min(...h)}(e,t);return Be.size>100&&Be.clear(),Be.set(n,i),i}const We={en:{days:"Days",hours:"Hours",minutes:"Minutes",seconds:"Seconds"},ru:{days:"Дни",hours:"Часы",minutes:"Минуты",seconds:"Секунды"},de:{days:"Tage",hours:"Stunden",minutes:"Minuten",seconds:"Sekunden"},es:{days:"Días",hours:"Horas",minutes:"Minutos",seconds:"Segundos"},fr:{days:"Jours",hours:"Heures",minutes:"Minutes",seconds:"Secondes"},pt:{days:"Dias",hours:"Horas",minutes:"Minutos",seconds:"Segundos"},ja:{days:"日",hours:"時間",minutes:"分",seconds:"秒"},ko:{days:"일",hours:"시간",minutes:"분",seconds:"초"},zh:{days:"天",hours:"小时",minutes:"分",seconds:"秒"},hi:{days:"दिन",hours:"घंटे",minutes:"मिनट",seconds:"सेकंड"},bn:{days:"দিন",hours:"ঘণ্টা",minutes:"মিনিট",seconds:"সেকেন্ড"},ar:{days:"أيام",hours:"ساعات",minutes:"دقائق",seconds:"ثوان"},he:{days:"ימים",hours:"שעות",minutes:"דקות",seconds:"שניות"},th:{days:"วัน",hours:"ชั่วโมง",minutes:"นาที",seconds:"วินาที"}};function Ue(e){const t=(e||"").trim();if(t)return t.startsWith("#")||t.startsWith("/")||t.startsWith("?")||a.test(t)?t:void 0}function Ke(e){return"_self"===e?{target:"_self"}:{target:"_blank",rel:"noreferrer"}}function Ze(e,t,n){const o="granted"===t?e.onGranted:e.onDenied;return"href"===o?.type&&function(e,t){const n="string"==typeof e.url?Ue(e.url):void 0;if(!n)return void t?.warn("Subscribe button: the link to open after the answer is empty or unsafe, it was not opened");if("_self"===e.target)return void window.location.assign(n);window.open(n,"_blank","noopener,noreferrer")}(o,n),"granted"===t||"close"===o?.type}const Ge=new Set(["STRONG","B","EM","I","U","BR","A"]);function Je(e,t,n){for(const o of Array.from(e.childNodes)){if(3===o.nodeType){t.appendChild(n.createTextNode(o.textContent??""));continue}if(1!==o.nodeType)continue;const e=o;if(!Ge.has(e.tagName)){Je(e,t,n);continue}const i=n.createElement(e.tagName.toLowerCase());if("A"===e.tagName){const t=Ue(e.getAttribute("href")??void 0);t&&i.setAttribute("href",t);const{target:n,rel:o}=Ke(e.getAttribute("target"));i.setAttribute("target",n),o&&i.setAttribute("rel",o)}t.appendChild(i),Je(e,i,n)}}function Ye(e){if(!e.includes("<"))return e;const t=(new DOMParser).parseFromString(e,"text/html"),n=t.createElement("div");return Je(t.body,n,t),n.innerHTML}function Qe(e){return"string"==typeof e&&e?e:void 0}function Xe(e,t){const n=e.dark;if("object"!=typeof n||null===n)return;const o=n,i="object"==typeof o.colors&&null!==o.colors?o.colors:{},r=Fe(t),s=function(e){if("object"!=typeof e||null===e)return;const t=e,n=Qe(t.color);if(!n)return;return{color:n,opacity:"number"==typeof t.opacity&&Number.isFinite(t.opacity)?Math.max(0,Math.min(1,t.opacity)):1}}(o.overlay);return{enabled:!0===o.enabled,colors:{background:Qe(i.background)??r.background,accent:Qe(i.accent)??r.accent,text:Qe(i.text)??r.text,textSecondary:Qe(i.textSecondary)??r.textSecondary,textInverse:Qe(i.textInverse)??r.textInverse},...s?{overlay:s}:{},...Qe(o.boxShadow)?{boxShadow:o.boxShadow}:{}}}function et(e){let t;try{t=JSON.parse(e)}catch{return null}if("object"!=typeof t||null===t)return null;const n=t;if(2!==n.version)return null;const o=n.params;if("object"!=typeof o||null===o)return null;if(!Array.isArray(o.pages)||0===o.pages.length)return null;const i=function(e){const t="object"==typeof e.colors&&null!==e.colors?e.colors:{};return{background:Qe(t.background)??Qe(e.background)??d,accent:Qe(t.accent)??Qe(e.accent)??p,text:Qe(t.text)??h,textSecondary:Qe(t.textSecondary)??m,textInverse:Qe(t.textInverse)??f}}(o),r=Xe(o,i);return{version:2,params:{...o,colors:i,...r?{dark:r}:{}}}}const tt=["cover","contain"];function nt(e){if("object"!=typeof e||null===e)return;const t=e,n=Ue("string"==typeof t.src?t.src:void 0);return n?{src:n,...!0===t.controls?{controls:!0}:{},...!1===t.loop?{loop:!1}:{}}:void 0}function ot(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;if("object"!=typeof n||null===n)continue;if("string"!=typeof n.key||!n.key)continue;if("string"!=typeof n.src)continue;const e=nt(n.video);t.push({key:n.key,label:"string"==typeof n.label?n.label:"",src:n.src,..."string"==typeof n.srcDark&&n.srcDark?{srcDark:n.srcDark}:{},...e?{video:e}:{},..."string"==typeof n.mediaId&&n.mediaId?{mediaId:n.mediaId}:{},..."string"==typeof n.mediaIdDark&&n.mediaIdDark?{mediaIdDark:n.mediaIdDark}:{},...tt.includes(n.fit)?{fit:n.fit}:{},..."number"==typeof n.blur&&Number.isFinite(n.blur)&&n.blur>0?{blur:Math.min(n.blur,100)}:{},..."number"==typeof n.dim&&Number.isFinite(n.dim)&&n.dim>0?{dim:Math.min(n.dim,1)}:{}})}return t}const it=["px","%","em","rem","fr"];function rt(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function st(e){if("object"!=typeof e||null===e)return;const t=e;if("text"===t.kind)return{kind:"text"};if("length"===t.kind||"percent"===t.kind){const e=rt(t.min),n=rt(t.max),o="length"===t.kind&&Array.isArray(t.units)?t.units.filter(e=>it.includes(e)):[],i="length"===t.kind?function(e){if("object"!=typeof e||null===e)return;const t={};for(const n of it){const o=e[n];if("object"!=typeof o||null===o)continue;const i=rt(o.min),r=rt(o.max);void 0===i&&void 0===r||(t[n]={...void 0!==i?{min:i}:{},...void 0!==r?{max:r}:{}})}return Object.keys(t).length>0?t:void 0}(t.ranges):void 0;return{kind:t.kind,...void 0!==e?{min:e}:{},...void 0!==n?{max:n}:{},...o.length>0?{units:o}:{},...i?{ranges:i}:{}}}if("select"===t.kind&&Array.isArray(t.options)){const e=[];for(const n of t.options){if(e.length>=20)break;"object"==typeof n&&null!==n&&("string"!=typeof n.value||n.value.length>64||e.push({value:n.value,label:"string"==typeof n.label?n.label:n.value}))}if(e.length>0)return{kind:"select",options:e}}}function at(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;if("object"!=typeof n||null===n)continue;if("string"!=typeof n.key||!le.test(n.key))continue;if("string"!=typeof n.value||n.value.length>64||n.value.includes("$"))continue;if(t.some(e=>e.key===n.key))continue;const e=st(n.control);t.push({key:n.key,label:"string"==typeof n.label?n.label:"",value:n.value,...e?{control:e}:{}})}return t}function ct(e){return Object.fromEntries(e.map(e=>[e.key,e.value]))}const lt=["email","firstName","lastName","phone","custom"],ut=["primary","secondary"];function dt(e){const t=[];if(Array.isArray(e))for(const n of e){if(t.length>=10)break;"object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key&&lt.includes(n.kind)&&(t.some(e=>e.key===n.key)||t.push({key:n.key,kind:n.kind,label:"string"==typeof n.label?n.label:"",placeholder:"string"==typeof n.placeholder?n.placeholder:"",required:"email"===n.kind||!0===n.required,..."custom"===n.kind&&"string"==typeof n.tag&&n.tag?{tag:n.tag}:{}})))}if(!t.some(e=>"email"===e.kind)){let e="field-email";for(;t.some(t=>t.key===e);)e=`${e}-1`;t.unshift({key:e,kind:"email",label:"Email",placeholder:"",required:!0})}return t.slice(0,10)}const pt=["checkbox","chips"],ht=["nps","stars","thumbs"],mt=["instant","button"],ft=["keep","hide-popup","page"],gt=/^[a-z]{2}$/i,bt=/^#[0-9a-fA-F]{6}$/,yt=500;function vt(e,t=120){return"string"==typeof e?e.trim().slice(0,t):""}function xt(e,t,n=120){return vt(e,n)||t}function kt(e){const t=vt(e,8);return gt.test(t)?t.toLowerCase():""}function St(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=12)break;if("object"!=typeof n||null===n)continue;const e=vt(n.value);if(!e)continue;if(t.some(t=>t.value===e))continue;const o=vt(n.tagValue);t.push({value:e,label:xt(n.label,e),...o?{tagValue:o}:{}})}return t}function wt(e,t){const n=e=>{const n=rt(e);return void 0===n||n<=0?0:Math.min(Math.floor(n),t)},o=n(e.min),i=n(e.max);return{min:o,max:i>0?Math.max(o,i):0}}function jt(e){const t=[];for(const n of e){if(t.length>=50)break;if("object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key))if("text"!==n.type)if("button"!==n.type){if("timer"===n.type){const e=vt(n.timezone,64),o=ze(e)?e:"",i=vt(n.endTime,32);if(null===He(i,o))continue;const r=vt(n.expirePage),s=ft.includes(n.onExpire)?n.onExpire:"keep",a="page"!==s||r?s:"keep";t.push({type:"timer",key:n.key,endTime:i,timezone:o,language:kt(n.language),showLabels:!1!==n.showLabels,onExpire:a,..."page"===a?{expirePage:r}:{}});continue}if("choice"===n.type){const e=St(n.options),{min:o,max:i}=wt(n,e.length);t.push({type:"choice",key:n.key,control:pt.includes(n.control)?n.control:"checkbox",tagName:vt(n.tagName),options:e,min:o,max:i,submitLabel:xt(n.submitLabel,P),submitVariant:ut.includes(n.submitVariant)?n.submitVariant:"primary",successMessage:xt(n.successMessage,$,yt)});continue}if("rating"===n.type){const e="object"==typeof n.labels&&null!==n.labels?n.labels:{};t.push({type:"rating",key:n.key,scale:ht.includes(n.scale)?n.scale:"stars",labels:{low:vt(e.low),high:vt(e.high)},submitMode:mt.includes(n.submitMode)?n.submitMode:"instant",submitLabel:xt(n.submitLabel,E),eventName:vt(n.eventName),successMessage:xt(n.successMessage,F,yt)});continue}if("glyph"!==n.type)"email-input"!==n.type?"tag-input"!==n.type?"consent"!==n.type?"submit"!==n.type?"email-subscription-form"===n.type&&t.push({type:"email-subscription-form",key:n.key,formCode:"string"==typeof n.formCode?n.formCode:"",fields:dt(n.fields),submitLabel:"string"==typeof n.submitLabel&&n.submitLabel?n.submitLabel:j,submitVariant:ut.includes(n.submitVariant)?n.submitVariant:"primary",..."object"==typeof n.privacy&&null!==n.privacy&&"string"==typeof n.privacy.checkboxLabel?{privacy:{checkboxLabel:n.privacy.checkboxLabel,url:"string"==typeof n.privacy.url?n.privacy.url:"",linkLabel:"string"==typeof n.privacy.linkLabel?n.privacy.linkLabel:""}}:{},successMessage:"string"==typeof n.successMessage&&n.successMessage?n.successMessage:C,confirmEmailMessage:"string"==typeof n.confirmEmailMessage&&n.confirmEmailMessage?n.confirmEmailMessage:M}):t.push({type:"submit",key:n.key,variant:ut.includes(n.variant)?n.variant:"primary",label:xt(n.label,N),errorMessage:xt(n.errorMessage,D,yt)}):t.push({type:"consent",key:n.key,checkboxLabel:vt(n.checkboxLabel,yt),linkLabel:vt(n.linkLabel),url:vt(n.url,yt),requiredMessage:xt(n.requiredMessage,L)}):t.push({type:"tag-input",key:n.key,tagName:vt(n.tagName),label:vt(n.label),placeholder:vt(n.placeholder),required:!0===n.required,requiredMessage:xt(n.requiredMessage,T)}):t.push({type:"email-input",key:n.key,label:vt(n.label),placeholder:vt(n.placeholder),invalidMessage:xt(n.invalidMessage,I),requiredMessage:xt(n.requiredMessage,q)});else{if(!O.includes(n.name))continue;t.push({type:"glyph",key:n.key,name:n.name,size:_.includes(n.size)?n.size:_[0],color:"string"==typeof n.color&&bt.test(n.color)?n.color:""})}}else"object"==typeof n.action&&null!==n.action&&"string"==typeof n.action.type&&t.push(n);else"string"==typeof n.html&&t.push(n)}return t}function Ct(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(t.length>=20)break;"object"==typeof n&&null!==n&&("string"==typeof n.key&&n.key&&Array.isArray(n.slots)&&t.push({key:n.key,label:"string"==typeof n.label?n.label:"",slots:jt(n.slots)}))}return t}function Mt(e){return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.min(e,2e3):void 0}function Pt(e,t,n){if(null===e)return;let o;return o="stretch"===e?"stretch":Mt(e)??("stretch"===t?"stretch":Mt(t)),"width"===n&&"stretch"===o?void 0:o}function $t(e){const t=[];for(const n of e.pages){const o=at(n.values),i=ce(pe(n.layout,ct(o)));if(!i)continue;const r=Pt(n.width,e.width,"width"),s=Pt(n.height,e.height,"height");t.push({key:n.key,layout:i,images:ot(n.images),contents:Ct(n.contents),...void 0!==r?{width:r}:{},...void 0!==s?{height:s}:{},..."success"===n.role?{role:"success"}:{}})}return t}function Et(e,t){return t.find(t=>t.key===e.startPage)??t[0]}function Ft(e){return`calc(100% - ${2*e.offset}px)`}function Rt(e){return Array.isArray(e?.slots)?{...e,slots:e.slots.filter(e=>!function(e){const t=e;return"button"===t?.type&&"close"===t.action?.type}(e))}:e}function At(e){return Array.isArray(e?.contents)?{...e,contents:e.contents.map(Rt)}:e}const It=new Set(["email-input","tag-input","consent"]),qt=new Set([...It,"submit"]);function Tt(e){return It.has(e.type)}function Lt(e,t){return`${e}/${t}`}function Nt(e,t){const{slot:n}=e;if("consent"===n.type)return t.checks[e.id]?void 0:n.requiredMessage;const o=(t.texts[e.id]??"").trim();return"tag-input"===n.type?n.required&&!o?n.requiredMessage:void 0:o?A.test(o)?void 0:n.invalidMessage:n.requiredMessage}function Dt(e,t){const n={};for(const o of e){const e=Nt(o,t);e&&(n[o.id]=e)}return n}const Vt="pushwoosh-web-popups",zt="[WebPopups]",Ot="data-pushwoosh-embedded-order",_t="keyValue",Bt="messages",Ht="inboxMessages";function Wt(e,t){return function(n){n.objectStoreNames.contains(e)||t(n)}}const Ut=[Wt(_t,function(e){e.createObjectStore(_t,{keyPath:"key"})}),Wt("log",function(e){const t=e.createObjectStore("log",{keyPath:"id",autoIncrement:!0});t.createIndex("environment","environment",{unique:!1}),t.createIndex("date","date",{unique:!1}),t.createIndex("type","type",{unique:!1})}),Wt(Bt,function(e){e.createObjectStore(Bt,{keyPath:"id",autoIncrement:!0}).createIndex("date","date",{unique:!1})}),Wt(Ht,function(e){const t="status",n=e.createObjectStore(Ht,{keyPath:"inbox_id",autoIncrement:!1});n.createIndex(t,t,{unique:!1,multiEntry:!0}),n.createIndex("rt","rt",{unique:!1,multiEntry:!0})})];class Kt{get all(){return Ut}}class Zt{constructor(e,t=new Kt){this.db=e,this.migrationsBuilder=t}applyMigrations(){this.applyMigrationsPack(this.migrationsBuilder.all)}applyMigrationsPack(e){e.forEach(e=>{e(this.db)})}}function Gt(e,t){console.info("onversionchange",t),e.close()}let Jt;function Yt(e){return(Jt||(Jt=new Promise((e,t)=>{const n=indexedDB.open("PUSHWOOSH_SDK_STORE",7);n.onsuccess=n=>{const o=n.target.result;o.onversionchange=Gt.bind(null,o,t),e(o)},n.onerror=()=>t(n.error),n.onupgradeneeded=e=>{const n=e.target.result;n.onversionchange=Gt.bind(null,n,t),new Zt(n).applyMigrations()}})),Jt).then(t=>new Promise((n,o)=>e(t,n,o)))}class Qt{_add(e){return Yt((t,n,o)=>{const i=t.transaction([this.name],"readwrite").objectStore(this.name).add(e);i.onsuccess=()=>{n(e)},i.onerror=()=>{o(i.error)}}).then(e=>this.getAll().then(t=>{if(Array.isArray(t)){const n=t.map(e=>e.id).sort((e,t)=>e==t?0:e<t?1:-1);if(n.length>this.maxItems)return Promise.all(n.slice(this.maxItems).map(e=>this.delete(e))).then(()=>e)}return e}))}delete(e){return Yt((t,n,o)=>{const i=t.transaction([this.name],"readwrite").objectStore(this.name).delete(e);i.onsuccess=()=>{n(i.result)},i.onerror=()=>{o(i.error)}})}getAll(){return Yt((e,t,n)=>{const o=[],i=e.transaction(this.name).objectStore(this.name).openCursor();i.onsuccess=e=>{const n=e.target.result;n?(n.value&&o.push(n.value),n.continue()):t(o)},i.onerror=()=>{n(i.error)}})}}Xt=_t;var Xt;const en=new class extends Qt{constructor(){super(...arguments),this.name="log",this.maxItems=100,this.environment="undefined"!=typeof self&&self.registration?"worker":"browser"}add(e,t,n){const o={type:e,environment:this.environment,message:`${t}`,date:new Date};return t instanceof Error&&(o.stack=t.stack),n&&(o.additional=n),this._add(o)}},tn=(new class extends Qt{constructor(){super(...arguments),this.name=Bt,this.maxItems=25}add(e){return this._add({...e,date:new Date})}},{error:1,info:2,debug:3});let nn=3;const on={setLevel(e){tn[e]||(e="error"),nn=tn[e]},write(e,t,n){return"error"===e?this.error(t):this.info(t),en.add(e,t,n)}};function rn(e){return async({slotKey:t,tagName:n,values:o})=>{try{await e.api.setTags({[n]:{operation:"append",value:o}})}catch(e){throw on.error(e,`Failed to write web popup choice "${t}" to tag "${n}"`),e}}}function sn(e){return async({slotKey:t,eventName:n,score:o,scale:i})=>{try{await e.api.postEvent(n,{score:o,scale:i,slotKey:t})}catch(e){throw on.error(e,`Failed to post web popup rating "${t}" as event "${n}"`),e}}}function an(e){return async()=>{try{await e.subscribe()}catch(e){on.error(e,"Failed to subscribe from a web popup")}return e.driver?.getPermission()??"default"}}Object.keys(tn).forEach(e=>{const t=tn[e];on[e]=(...n)=>{t<=nn&&(console.groupCollapsed(e),console.info("",...n),console.trace("trace"),console.groupEnd())}});var cn=r(247),ln=r(524),un=r(873);const dn="(prefers-color-scheme: dark)";function pn(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia(dn).matches}function hn(e,t){const[n,o]=(0,un.useState)(()=>"auto"===e&&t&&pn()),i=[e,t],[r,s]=(0,un.useState)(null);return(null===r||i.some((e,t)=>e!==r[t]))&&(s(i),"auto"===e&&t&&o(pn())),(0,un.useEffect)(()=>{if("auto"!==e||!t||"undefined"==typeof window||"function"!=typeof window.matchMedia)return;const n=window.matchMedia(dn),i=e=>o(e.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[e,t]),"auto"!==e?e:n?"dark":"light"}const mn="data-pw-web-popup-inline",fn="data-pw-close",gn="data-pw-submit",bn={width:"100%"},yn=`[${mn}] img { max-height: 360px; object-fit: cover; }`,vn=(0,un.createContext)({pageKey:"",texts:{},checks:{},errors:{},phase:"idle",setText:()=>{},setCheck:()=>{},submit:()=>{},turnPage:(e,t)=>t(e),advance:()=>{}});function xn(e,t){return t in e?Object.fromEntries(Object.entries(e).filter(([e])=>e!==t)):e}function kn(e,t,n,o){const i=(0,un.useMemo)(()=>$t(e),[e]),r=(0,un.useMemo)(()=>function(e){const t=[];for(const n of e)for(const e of n.contents)for(const o of e.slots)Tt(o)&&t.push({id:Lt(n.key,o.key),pageKey:n.key,slot:o});return t}(i),[i]),[s,a]=(0,un.useState)({}),[c,l]=(0,un.useState)({}),[u,d]=(0,un.useState)({}),[p,h]=(0,un.useState)("idle"),m=e=>i.findIndex(t=>t.key===e),f=()=>{const e=Dt(r.filter(e=>e.pageKey===t),{texts:s,checks:c});return d(e),0===Object.keys(e).length},g=()=>{o&&"submitting"!==p&&((()=>{const e=Dt(r,{texts:s,checks:c});d(e);const t=r.find(t=>t.id in e);return t&&n?.(t.pageKey),!t})()?(h("submitting"),Promise.resolve().then(()=>o(function(e,t){const n={tags:{},policyAccepted:!0};for(const o of e){const{slot:e}=o;if("consent"===e.type){n.policyAccepted=n.policyAccepted&&!0===t.checks[o.id];continue}const i=(t.texts[o.id]??"").trim();"email-input"!==e.type?i&&e.tagName&&(n.tags[e.tagName]=i):n.email=i}return n}(r,{texts:s,checks:c}))).then(e=>{if(h("idle"),"invalid-email"===e)return void(()=>{const e=r.find(e=>"email-input"===e.slot.type);"email-input"===e?.slot.type&&(d({[e.id]:e.slot.invalidMessage}),n?.(e.pageKey))})();const t=i.find(e=>"success"===e.role);t&&n?.(t.key)},()=>h("error"))):h("idle"))};return{pageKey:t,texts:s,checks:c,errors:u,phase:p,setText:(e,t)=>{a(n=>({...n,[e]:t})),d(t=>xn(t,e))},setCheck:(e,t)=>{l(n=>({...n,[e]:t})),d(t=>xn(t,e))},submit:g,turnPage:(e,n)=>{if("submitting"===p)return;const r=m(e),s=r>m(t);o&&s?"success"===i[r].role?g():f()&&n(e):n(e)},advance:()=>{if(!o||"submitting"===p)return;const e=i[m(t)+1];e&&"success"!==e.role?f()&&n?.(e.key):g()}}}const Sn={padding:"4px 0",textAlign:"left"};function wn({inverse:e,colors:t}){const n=y("caption",t,e);return{...g.caption,...n?{color:n}:{}}}function jn(e){return{fontSize:12,lineHeight:1.4,color:e.error,paddingTop:2}}function Cn(e){return{...wn(e),paddingBottom:4}}function Mn({slotKey:e,label:t,placeholder:n,inputType:o,autoComplete:i,look:r}){const s=(0,un.useContext)(vn),[a,c]=(0,un.useState)(!1),l=Lt(s.pageKey,e),u=s.errors[l];let d;return u?d=r.colors.error:a&&(d=r.colors.accent),(0,cn.jsxs)("div",{style:Sn,children:[t&&(0,cn.jsx)("div",{style:Cn(r),children:t}),(0,cn.jsx)("input",{type:o,autoComplete:i,placeholder:n||void 0,value:s.texts[l]??"",disabled:"submitting"===s.phase,style:w(r.colors,d),onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:e=>s.setText(l,e.currentTarget.value),onKeyDown:e=>{"Enter"===e.key&&s.advance()}}),u&&(0,cn.jsx)("div",{style:jn(r.colors),children:u})]})}function Pn({slot:e,...t}){return(0,cn.jsx)(Mn,{slotKey:e.key,label:e.label,placeholder:e.placeholder,inputType:"email",autoComplete:"email",look:t})}function $n({slot:e,...t}){return(0,cn.jsx)(Mn,{slotKey:e.key,label:e.label,placeholder:e.placeholder,inputType:"text",look:t})}const En={margin:"2px 0 0",flexShrink:0};function Fn(e){return{...wn(e),display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"}}function Rn({slot:e,...t}){const n=(0,un.useContext)(vn),o=Lt(n.pageKey,e.key),i=n.errors[o],r=Ue(e.url);return(0,cn.jsxs)("div",{style:Sn,children:[(0,cn.jsxs)("label",{style:Fn(t),children:[(0,cn.jsx)("input",{type:"checkbox",checked:!0===n.checks[o],disabled:"submitting"===n.phase,style:En,onChange:e=>n.setCheck(o,e.currentTarget.checked)}),(0,cn.jsxs)("span",{children:[e.checkboxLabel,r&&(0,cn.jsxs)(cn.Fragment,{children:[" ",(0,cn.jsx)("a",{href:r,...Ke(void 0),style:(s=t.colors,{color:s.accent}),children:e.linkLabel||e.url})]})]})]}),i&&(0,cn.jsx)("div",{style:jn(t.colors),children:i})]});var s}const An={padding:k};function In(e,t,n){return{...S(e,t),...n?{opacity:.6,cursor:"default"}:{}}}function qn({slot:e,align:t,colors:n}){const o=(0,un.useContext)(vn),i="submitting"===o.phase;return(0,cn.jsxs)("div",{style:An,children:[(0,cn.jsx)("button",{type:"button",[gn]:"",disabled:i,style:In(e.variant,n,i),onClick:o.submit,children:e.label}),"error"===o.phase&&(0,cn.jsx)("div",{style:{...jn(n),textAlign:t},children:e.errorMessage})]})}const Tn={none:void 0,fade:"pw-vpopup-fade 0.35s ease-out backwards",slide:"pw-vpopup-slide 0.35s ease-out backwards"};function Ln({slot:e,align:t,inverse:n,colors:o}){const i={...g[e.variant],textAlign:e.align??t},r=y(e.variant,o,n);return r&&(i.color=r),(0,cn.jsx)("div",{style:i,dangerouslySetInnerHTML:{__html:Ye(e.html)}})}function Nn({slot:e,colors:t,logger:n,onRequestClose:o,onPageChange:i,onRequestSubscribe:r,onSubscribeClose:s}){const a=(0,un.useContext)(vn),[c,l]=(0,un.useState)("idle"),u=S(e.variant,t),d={};if("close"===e.action.type)return(0,cn.jsx)("div",{style:d,children:(0,cn.jsx)("button",{type:"button",style:u,onClick:o,children:e.label})});if("page"===e.action.type){const t=e.action.page;return(0,cn.jsx)("div",{style:d,children:(0,cn.jsx)("button",{type:"button",style:u,onClick:()=>a.turnPage(t,i),children:e.label})})}if("subscribe"===e.action.type){const{action:t}=e,o="idle"!==c,i=()=>{r&&!o&&(l("asking"),r().then(e=>{"default"!==e?Ze(t,e,n)?s?.():l("denied"):l("idle")}).catch(()=>l("idle")))};return(0,cn.jsx)("div",{style:d,children:(0,cn.jsx)("button",{type:"button",disabled:o,style:{...u,...o?{opacity:.7}:{}},onClick:i,children:e.label})})}const p=Ue(e.action.url);return p?(0,cn.jsx)("div",{style:d,children:(0,cn.jsx)("a",{href:p,...Ke(e.action.target),style:u,children:e.label})}):(0,cn.jsx)("div",{style:d,children:(0,cn.jsx)("button",{type:"button",style:u,children:e.label})})}function Dn({message:e,align:t,inverse:n,colors:o}){const i=y("body",o,n);return(0,cn.jsx)("div",{style:{...g.body,padding:"4px 0",textAlign:t,...i?{color:i}:{}},children:e})}const Vn={email:"email",phone:"tel"},zn={email:"email",firstName:"given-name",lastName:"family-name",phone:"tel"},On="__privacy";function _n({slot:e,align:t,inverse:n,colors:o,onSubmitForm:i}){const[r,s]=(0,un.useState)({}),[a,c]=(0,un.useState)(!1),[l,u]=(0,un.useState)(null),[d,p]=(0,un.useState)({}),[h,m]=(0,un.useState)("idle"),f=y("caption",o,n),b={...g.caption,...f?{color:f}:{}},v={fontSize:12,lineHeight:1.4,color:o.error,paddingTop:2};if("success"===h||"confirm"===h)return(0,cn.jsx)(Dn,{message:"confirm"===h?e.confirmEmailMessage:e.successMessage,align:t,inverse:n,colors:o});const x="submitting"===h,j=e.privacy?Ue(e.privacy.url):void 0,C={...S(e.submitVariant,o),...x?{opacity:.6,cursor:"default"}:{}};return(0,cn.jsxs)("form",{noValidate:!0,style:{margin:0,textAlign:"left"},onSubmit:t=>{t.preventDefault(),(()=>{if(!i||!e.formCode||"submitting"===h)return;const t={};for(const n of e.fields){const e=(r[n.key]??"").trim();n.required&&!e?t[n.key]="Required":"email"===n.kind&&e&&!A.test(e)&&(t[n.key]="Enter a valid email")}if(e.privacy&&!a&&(t[On]="Please accept the privacy policy"),p(t),Object.keys(t).length>0)return;const n={email:"",policyAccepted:!e.privacy||a},o={};for(const t of e.fields){const e=(r[t.key]??"").trim();e&&("email"===t.kind?n.email=n.email||e:"firstName"===t.kind?n.firstName=e:"lastName"===t.kind?n.lastName=e:"phone"===t.kind?n.phone=e:o[t.tag||t.key]=e)}Object.keys(o).length>0&&(n.customFields=o),m("submitting"),Promise.resolve().then(()=>i(e.formCode,n)).then(e=>m("confirm-email"===e?"confirm":"success"),()=>m("error"))})()},children:[e.fields.map(e=>{const t=d[e.key];let n;return t?n=o.error:l===e.key&&(n=o.accent),(0,cn.jsxs)("div",{style:{padding:"4px 0"},children:[e.label&&(0,cn.jsx)("div",{style:{...b,paddingBottom:4},children:e.label}),(0,cn.jsx)("input",{type:Vn[e.kind]??"text",autoComplete:zn[e.kind],placeholder:e.placeholder||void 0,value:r[e.key]??"",disabled:x,style:w(o,n),onFocus:()=>u(e.key),onBlur:()=>u(t=>t===e.key?null:t),onChange:t=>{return n=e.key,o=t.currentTarget.value,s(e=>({...e,[n]:o})),void p(e=>e[n]?Object.fromEntries(Object.entries(e).filter(([e])=>e!==n)):e);var n,o}}),t&&(0,cn.jsx)("div",{style:v,children:t})]},e.key)}),e.privacy&&(0,cn.jsxs)("div",{style:{padding:"4px 0"},children:[(0,cn.jsxs)("label",{style:{...b,display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[(0,cn.jsx)("input",{type:"checkbox",checked:a,disabled:x,style:{margin:"2px 0 0",flexShrink:0},onChange:e=>{c(e.currentTarget.checked),p(e=>e[On]?Object.fromEntries(Object.entries(e).filter(([e])=>e!==On)):e)}}),(0,cn.jsxs)("span",{children:[e.privacy.checkboxLabel,j&&(0,cn.jsxs)(cn.Fragment,{children:[" ",(0,cn.jsx)("a",{href:j,...Ke(void 0),style:{color:o.accent},children:e.privacy.linkLabel||e.privacy.url})]})]})]}),d[On]&&(0,cn.jsx)("div",{style:v,children:d[On]})]}),(0,cn.jsx)("div",{style:{padding:k},children:(0,cn.jsx)("button",{type:"submit",disabled:x,style:C,children:e.submitLabel})}),"error"===h&&(0,cn.jsx)("div",{style:{...v,textAlign:t},children:R})]})}function Bn({value:e,label:t,digitStyle:n,labelStyle:o}){return(0,cn.jsxs)("div",{style:{minWidth:44},children:[(0,cn.jsx)("div",{style:n,children:String(e).padStart(2,"0")}),t?(0,cn.jsx)("div",{style:o,children:t}):null]})}function Hn({slot:e,align:t,inverse:n,colors:o,mode:i,onRequestClose:r,onPageChange:s}){const[a,c]=(0,un.useState)(()=>Date.now()),l=function(e,t,n){const o=He(e,t),i=null===o?0:Math.max(0,o-n),r=Math.floor(i/1e3);return{total:i,days:Math.floor(r/86400),hours:Math.floor(r/3600)%24,minutes:Math.floor(r/60)%60,seconds:r%60}}(e.endTime,e.timezone,a),u=0===l.total;(0,un.useEffect)(()=>{if("live"!==i||u)return;const e=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(e)},[i,u,e.endTime,e.timezone]),(0,un.useEffect)(()=>{"live"===i&&u&&("hide-popup"===e.onExpire?r?.():"page"===e.onExpire&&e.expirePage&&s(e.expirePage))},[i,u,e.onExpire,e.expirePage,r,s]);const d=y("h2",o,n),p=y("caption",o,n),h={fontSize:28,fontWeight:700,lineHeight:1.2,fontVariantNumeric:"tabular-nums",...d?{color:d}:{}},m={...g.caption,...p?{color:p}:{}},f=(b=e.language,We[b]??We.en);var b;const v=[{value:l.days,label:f.days},{value:l.hours,label:f.hours},{value:l.minutes,label:f.minutes},{value:l.seconds,label:f.seconds}];return(0,cn.jsx)("div",{style:{padding:"4px 0",textAlign:t},children:(0,cn.jsx)("div",{style:{display:"inline-flex",gap:12,textAlign:"center"},children:v.map(t=>(0,cn.jsx)(Bn,{value:t.value,label:e.showLabels?t.label:"",digitStyle:h,labelStyle:m},t.label||t.value))})})}function Wn({slot:e,align:t,inverse:n,colors:o,onSubmitChoice:i}){const[r,s]=(0,un.useState)([]),[a,c]=(0,un.useState)("idle"),[l,u]=(0,un.useState)("");if("success"===a)return(0,cn.jsx)(Dn,{message:e.successMessage,align:t,inverse:n,colors:o});const d=t=>{u(""),s(n=>n.includes(t)?n.filter(e=>e!==t):e.max>0&&n.length>=e.max?(u(`Pick up to ${e.max}`),n):[...n,t])},p="submitting"===a,h=y("body",o,n),m={...g.body,...h?{color:h}:{}};return(0,cn.jsxs)("div",{style:{padding:"4px 0"},children:["chips"===e.control?(0,cn.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,justifyContent:"center"===t?"center":"flex-start"},children:e.options.map(e=>{return(0,cn.jsx)("button",{type:"button","aria-pressed":r.includes(e.value),style:(t=r.includes(e.value),{padding:"6px 14px",borderRadius:999,border:`1px solid ${o.accent}`,backgroundColor:t?o.accent:"transparent",color:t?o.onAccent:o.accent,fontFamily:"inherit",fontSize:14,lineHeight:1.4,cursor:"pointer"}),onClick:()=>d(e.value),children:e.label},e.value);var t})}):(0,cn.jsx)("div",{style:{display:"grid",gap:6},children:e.options.map(e=>(0,cn.jsxs)("label",{style:{...m,display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[(0,cn.jsx)("input",{type:"checkbox",checked:r.includes(e.value),onChange:()=>d(e.value),style:{accentColor:o.accent,width:16,height:16,margin:0}}),e.label]},e.value))}),l?(0,cn.jsx)("div",{style:{...g.caption,color:o.error,paddingTop:4},children:l}):null,"error"===a?(0,cn.jsx)("div",{style:{...g.caption,color:o.error,paddingTop:4},children:R}):null,(0,cn.jsx)("div",{style:{padding:k},children:(0,cn.jsx)("button",{type:"button",style:{...S(e.submitVariant,o),...p?{opacity:.7}:{}},onClick:()=>{if(!i||!e.tagName||"submitting"===a)return;const t=Math.max(e.min,1);if(r.length<t)return void u(1===t?"Pick at least one":`Pick at least ${t}`);const n=e.options.filter(e=>r.includes(e.value)).map(e=>e.tagValue||e.value);u(""),c("submitting"),Promise.resolve().then(()=>i({slotKey:e.key,tagName:e.tagName,values:n})).then(()=>c("success"),()=>c("error"))},children:e.submitLabel})})]})}function Un({score:e,scale:t,selected:n,colors:o,onPick:i}){const r={display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0,border:`1px solid ${o.accent}`,backgroundColor:n?o.accent:"transparent",color:n?o.onAccent:o.accent,fontFamily:"inherit",fontSize:14,lineHeight:1,cursor:"pointer"};if("nps"===t)return(0,cn.jsx)("button",{type:"button","aria-label":`Rate ${e}`,"aria-pressed":n,style:{...r,width:30,height:32,borderRadius:6},onClick:i,children:e});const s="thumbs"===t;let a=`Rate ${e}`;return s&&(a=1===e?"Thumbs up":"Thumbs down"),(0,cn.jsx)("button",{type:"button","aria-label":a,"aria-pressed":n,style:{...r,width:s?44:34,height:s?40:34,borderRadius:s?8:6},onClick:i,children:(0,cn.jsx)("svg",{width:s?22:20,height:s?22:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:(0,cn.jsx)("path",{d:s?"M8 21V10l3.5-7A2 2 0 0 1 14 5v5h4.5a2 2 0 0 1 2 2.4l-1.3 6A2 2 0 0 1 17.2 21zM8 10H3.5v11H8":z.star,...s&&0===e?{transform:"rotate(180 12 12)"}:{}})})})}function Kn({slot:e,align:t,inverse:n,colors:o,onSubmitRating:i}){const[r,s]=(0,un.useState)(null),[a,c]=(0,un.useState)("idle");if("success"===a)return(0,cn.jsx)(Dn,{message:e.successMessage,align:t,inverse:n,colors:o});const l=t=>{i&&e.eventName&&"submitting"!==a&&(c("submitting"),Promise.resolve().then(()=>i({slotKey:e.key,eventName:e.eventName,score:t,scale:e.scale})).then(()=>c("success"),()=>c("error")))},u="nps"===(d=e.scale)?[0,1,2,3,4,5,6,7,8,9,10]:"stars"===d?[1,2,3,4,5]:[0,1];var d;const p=y("caption",o,n),h={...g.caption,...p?{color:p}:{}},m=t=>"stars"===e.scale?null!==r&&t<=r:r===t;return(0,cn.jsxs)("div",{style:{padding:"4px 0"},children:[(0,cn.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,justifyContent:"center"===t?"center":"flex-start"},children:u.map(t=>(0,cn.jsx)(Un,{score:t,scale:e.scale,selected:m(t),colors:o,onPick:()=>(t=>{"submitting"!==a&&(s(t),"instant"===e.submitMode&&l(t))})(t)},t))}),e.labels.low||e.labels.high?(0,cn.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",gap:8,paddingTop:4},children:[(0,cn.jsx)("span",{style:h,children:e.labels.low}),(0,cn.jsx)("span",{style:h,children:e.labels.high})]}):null,"error"===a?(0,cn.jsx)("div",{style:{...g.caption,color:o.error,paddingTop:4},children:R}):null,"button"===e.submitMode?(0,cn.jsx)("div",{style:{padding:k},children:(0,cn.jsx)("button",{type:"button",style:{...S("primary",o),..."submitting"===a?{opacity:.7}:{}},onClick:()=>null===r?void 0:l(r),children:e.submitLabel})}):null]})}function Zn({slot:e,align:t,inverse:n,colors:o}){const i=e.color||(n?o.textInverse:o.accent);return(0,cn.jsx)("div",{style:{padding:"4px 0",textAlign:t,lineHeight:0},children:(0,cn.jsx)("svg",{width:e.size,height:e.size,viewBox:"0 0 24 24",fill:"none",stroke:i,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{display:"inline-block"},children:(0,cn.jsx)("path",{d:z[e.name]})})})}function Gn({slot:e,align:t,inverse:n,colors:o,mode:i="live",onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:c,onSubmitRating:l,onRequestSubscribe:u,onSubscribeClose:d,logger:p}){const h=s??(()=>{});switch(e.type){case"text":return(0,cn.jsx)(Ln,{slot:e,align:t,inverse:n,colors:o});case"button":return(0,cn.jsx)(Nn,{slot:e,colors:o,onRequestClose:r,onPageChange:h,onRequestSubscribe:u,onSubscribeClose:d,logger:p});case"email-subscription-form":return(0,cn.jsx)(_n,{slot:e,align:t,inverse:n,colors:o,onSubmitForm:a});case"timer":return(0,cn.jsx)(Hn,{slot:e,align:t,inverse:n,colors:o,mode:i,onRequestClose:r,onPageChange:h});case"choice":return(0,cn.jsx)(Wn,{slot:e,align:t,inverse:n,colors:o,onSubmitChoice:c});case"rating":return(0,cn.jsx)(Kn,{slot:e,align:t,inverse:n,colors:o,onSubmitRating:l});case"glyph":return(0,cn.jsx)(Zn,{slot:e,align:t,inverse:n,colors:o});case"email-input":return(0,cn.jsx)(Pn,{slot:e,inverse:n,colors:o});case"tag-input":return(0,cn.jsx)($n,{slot:e,inverse:n,colors:o});case"consent":return(0,cn.jsx)(Rn,{slot:e,inverse:n,colors:o});case"submit":return(0,cn.jsx)(qn,{slot:e,align:t,colors:o})}}function Jn({node:e,page:t,colors:n,mode:o,leaf:i,onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:c,onSubmitRating:l,onRequestSubscribe:u,onSubscribeClose:d,logger:p}){const h=t.contents.find(t=>t.key===e.props.content);if(!h)return null;if(i?.renderZone)return(0,cn.jsx)("div",{style:{minWidth:0},children:i.renderZone(h,e)});const m=e.props.align??"left",f="inverse"===e.props.tone;return(0,cn.jsx)("div",{style:{minWidth:0},children:h.slots.map((e,t)=>{const i=h.slots[t-1],g=i?(b=x(i),"action"===(y=x(e))?"action"===b?6:16:"text"===y&&"heading"===b?4:8):0;var b,y;return(0,cn.jsx)("div",{style:g?{marginTop:g}:void 0,children:(0,cn.jsx)(Gn,{slot:e,align:m,inverse:f,colors:n,mode:o,onRequestClose:r,onPageChange:s,onSubmitForm:a,onSubmitChoice:c,onSubmitRating:l,onRequestSubscribe:u,onSubscribeClose:d,logger:p})},e.key)})})}function Yn(e){return e?.video?Ue(e.video.src):void 0}function Qn({image:e,poster:t,src:n,style:o,mode:i}){return(0,cn.jsx)("video",{src:n,poster:t||void 0,style:o,autoPlay:"live"===i,muted:!0,playsInline:!0,preload:"metadata",loop:!1!==e.video?.loop,controls:!0===e.video?.controls})}function Xn({node:e,page:t,leaf:n,mode:o,scheme:i}){const r=t.images.find(t=>t.key===e.props.image);if(!r)return null;if(n?.renderImage)return(0,cn.jsx)(cn.Fragment,{children:n.renderImage(r,e)});const s=Yn(r),a=Te(r,i);if(!a&&!s)return null;const c={display:"block",width:"100%",minWidth:0};return r.fit?(c.height="100%",c.objectFit=r.fit):c.height="auto",r.blur&&(c.filter=`blur(${r.blur}px)`),s?(0,cn.jsx)(Qn,{image:r,poster:a,src:s,style:c,mode:o}):(0,cn.jsx)("img",{src:a,alt:"",style:c})}function eo({style:e,outer:t,inner:n,layer:o,children:i}){const{backgroundColor:r,...s}=e;return(0,cn.jsxs)("div",{style:{display:"grid",minWidth:0,backgroundColor:r,...t},children:[o,(0,cn.jsx)("div",{style:{...s,...n},children:i})]})}function to({node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitChoice:l,onSubmitRating:u,onRequestSubscribe:d,onSubscribeClose:p,logger:h}){if("Content"===e.type)return(0,cn.jsx)(Jn,{node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitChoice:l,onSubmitRating:u,onRequestSubscribe:d,onSubscribeClose:p,logger:h});if("Image"===e.type)return(0,cn.jsx)(Xn,{node:e,page:t,leaf:r,mode:o,scheme:i});const m=e.props?.backgroundImage,f=m?t.images.find(e=>e.key===m):void 0,g=f?.blur??0,b=f?.dim??0,y=Yn(f),v=f?Te(f,i):void 0,x=ve(e,g>0||y?void 0:v||void 0,b);m&&(x.backgroundColor="#1D2939");const k=e.children.map((e,m)=>(0,cn.jsx)(to,{node:e,page:t,colors:n,mode:o,scheme:i,leaf:r,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitChoice:l,onSubmitRating:u,onRequestSubscribe:d,onSubscribeClose:p,logger:h},m));if(y&&f){const e=be(b);return(0,cn.jsx)(eo,{style:x,outer:{position:"relative",overflow:"hidden",...v?ye(v):{}},inner:{position:"relative",...e?{backgroundImage:e}:{}},layer:(0,cn.jsx)(Qn,{image:f,poster:v??"",src:y,mode:o,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover",...g>0?{filter:`blur(${g}px)`}:{}}}),children:k})}return g>0?(0,cn.jsx)(eo,{style:x,outer:v?ye(v,b):void 0,inner:{backdropFilter:`blur(${g}px)`,WebkitBackdropFilter:`blur(${g}px)`},children:k}):(0,cn.jsx)("div",{style:x,children:k})}function no({page:e,params:t,mode:n="live",colorScheme:o="light",leafRenderers:i,animatePage:r=!1,onRequestClose:s,onPageChange:a,onSubmitForm:c,onSubmitFormValues:l,onSubmitChoice:u,onSubmitRating:d,onRequestSubscribe:p,onSubscribeClose:h,logger:m}){const f=kn(t,e.key,a,l),g=qe(t,o),b=Le(t,o),y={position:"relative",boxSizing:"border-box",overflow:"hidden",backgroundColor:g.background,colorScheme:g.scheme,fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif',color:g.text,borderRadius:t.borderRadius>0?t.borderRadius:void 0,boxShadow:b.boxShadow&&"none"!==b.boxShadow?b.boxShadow:void 0,transition:"height 300ms ease"};e.height&&(y.height="stretch"===e.height?"100%":e.height,y.overflowY="auto");const v={...r?{animation:"pw-vpopup-page 300ms ease-out backwards"}:{},..."stretch"===e.height?{display:"grid",minHeight:"100%"}:{}};return(0,cn.jsx)("div",{style:y,children:(0,cn.jsx)(vn.Provider,{value:f,children:(0,cn.jsx)("div",{style:v,children:(0,cn.jsx)(to,{node:e.layout,page:e,colors:g,mode:n,scheme:g.scheme,leaf:i,onRequestClose:s,onPageChange:a??(()=>{}),onSubmitForm:c,onSubmitChoice:u,onSubmitRating:d,onRequestSubscribe:p,onSubscribeClose:h,logger:m})},e.key)})})}function oo({colors:e,onRequestClose:t}){return(0,cn.jsx)("button",{type:"button","aria-label":"Close",[fn]:"",onClick:t,style:{position:"absolute",top:10,right:10,width:24,height:24,padding:0,border:"none",borderRadius:"50%",background:$e(e.surface,.92),boxShadow:"0 1px 3px rgba(16, 24, 40, 0.25)",color:e.chromeIcon,fontSize:13,lineHeight:1,cursor:"pointer"},children:"✕"})}function io(e,t,n){const{placement:o}=e,i={position:"fixed",boxSizing:"border-box",maxWidth:Ft(o),maxHeight:Ft(o),pointerEvents:"auto"};if(t){i.width=t;const e=o.h;"left"===e?i.left=o.offset:"right"===e?i.right=o.offset:i.left="50%"}else i.left=o.offset,i.right=o.offset;"stretch"===n?(i.top=o.offset,i.bottom=o.offset):"top"===o.v?i.top=o.offset:"bottom"===o.v?i.bottom=o.offset:i.top="50%";const r=t&&"center"===o.h?"-50%":"0",s="middle"===o.v&&"stretch"!==n?"-50%":"0";"0"===r&&"0"===s||(i.transform=`translate(${r}, ${s})`);const a=Tn[e.animation];return a&&(i.animation=a),i.transition="width 300ms ease",i}function ro({params:e,mode:t="live",colorScheme:n="auto",onRequestClose:o,onSubmitForm:i,onSubmitFormValues:r,onSubmitChoice:s,onSubmitRating:a,onRequestSubscribe:c,logger:l,leafRenderers:u}){const[d,p]=(0,un.useState)(null);(0,un.useEffect)(()=>{$t(e).forEach(e=>e.images.forEach(({src:e,srcDark:t})=>{[e,t].forEach(e=>{e&&((new Image).src=e)})}))},[e]);const h=hn(n,Ae(e)),m=$t(e);if(0===m.length)return null;const f=m.find(e=>e.key===d)??Et(e,m),g=null!==d;if("preview"===t)return(0,cn.jsxs)("div",{style:{position:"relative",width:f.width??"100%",transition:"width 300ms ease"},children:[(0,cn.jsx)("style",{children:V}),(0,cn.jsx)(no,{page:f,params:e,mode:t,colorScheme:h,leafRenderers:u,animatePage:g,onRequestClose:o,onPageChange:p,onSubmitForm:i,onSubmitFormValues:r,onSubmitChoice:s,onSubmitRating:a,onRequestSubscribe:c,onSubscribeClose:o,logger:l})]});const{overlay:b}=Le(e,h);return(0,cn.jsxs)(cn.Fragment,{children:[(0,cn.jsx)("style",{children:V}),b&&(0,cn.jsx)("div",{style:{position:"fixed",inset:0,backgroundColor:b.color,opacity:b.opacity,animation:"pw-vpopup-overlay 0.2s ease-out backwards",pointerEvents:"auto"},onClick:o}),(0,cn.jsxs)("div",{style:io(e,f.width,f.height),children:[(0,cn.jsx)(no,{page:f,params:e,mode:t,colorScheme:h,leafRenderers:u,animatePage:g,onRequestClose:o,onPageChange:p,onSubmitForm:i,onSubmitFormValues:r,onSubmitChoice:s,onSubmitRating:a,onRequestSubscribe:c,onSubscribeClose:o,logger:l}),(0,cn.jsx)(oo,{colors:qe(e,h),onRequestClose:o})]})]})}function so({params:e,mode:t="live",colorScheme:n="auto",logger:o,onSubmitForm:i,onSubmitFormValues:r,onSubmitChoice:s,onSubmitRating:a,onRequestSubscribe:c,onRequestRemove:l}){const[u,d]=(0,un.useState)(null),p=(0,un.useMemo)(()=>function(e){return Array.isArray(e?.pages)?{...e,pages:e.pages.map(At)}:e}(e),[e]),h=hn(n,Ae(p)),m=$t(p);if(0===m.length)return null;const f=m.find(e=>e.key===u)??Et(p,m);return(0,cn.jsxs)("div",{[mn]:"",style:bn,children:[(0,cn.jsx)("style",{children:yn}),(0,cn.jsx)(no,{page:f,params:p,mode:t,colorScheme:h,onPageChange:d,onSubmitForm:i,onSubmitFormValues:r,onSubmitChoice:s,onSubmitRating:a,onRequestSubscribe:c,onSubscribeClose:l,logger:o})]})}const ao={SUBMIT_FORM_RESULT_SUBSCRIBED:"subscribed",SUBMIT_FORM_RESULT_CONFIRM_EMAIL:"confirm-email",SUBMIT_FORM_RESULT_ALREADY_SUBSCRIBED:"already-subscribed"},co=(e,t)=>`https://subscription-form.svc-nue.pushwoosh.com/api/v1/forms/code/${encodeURIComponent(e)}${t}`,lo=async(e,t)=>{try{const n=await fetch(co(e,"/submit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,userId:t.email})});if(!n.ok)throw new Error(`Subscription form submit failed: HTTP ${n.status}`);const o=await n.json(),i=ao[o.result??""];if(!i)throw new Error(`Subscription form submit failed: unexpected result "${o.result}"`);return i}catch(t){throw on.error(t,`Failed to submit subscription form "${e}"`),t}},uo={warn:e=>on.error(zt,e)},po=e=>"EMBEDDED"===e.kind;class ho{constructor(e){this.blocks=new Map,this.viewed=new Set,this.autoSkipLogged=new Set,this.deps=e}syncWithPage(e,t){for(const n of e){if(!po(n.popup))continue;const{code:e}=n.popup;!1===this.blocks.get(e)?.host.isConnected&&this.remove(e),"api"!==this.blocks.get(e)?.trigger&&(this.deps.matchesPage(n.popup)?n.content&&t(n)&&this.place(n,n.content,"auto"):this.remove(e))}}show(e,t){return this.place(e,t,"api")}removeWhere(e){for(const[t,n]of[...this.blocks])e(n.entry)&&this.remove(t)}place(e,t,n){const{popup:o}=e,i=this.findContainer(o,n);if(!i)return this.remove(o.code),!1;const r=this.blocks.get(o.code);if(r?.element===i&&r.host.isConnected)return"api"===n&&(r.trigger="api"),!0;this.remove(o.code);const s=document.createElement("div");s.id=`${Vt}-embedded-${o.code}`,s.setAttribute(Ot,String(e.order)),s.style.width="100%",i.insertBefore(s,this.firstBlockAfter(i,e.order));const a=s.attachShadow({mode:"open"}),c=document.createElement("div");return a.appendChild(c),this.deps.render(c,t,e),this.blocks.set(o.code,{entry:e,element:i,host:s,container:c,trigger:n,observer:this.watchFirstView(e,t,s)}),this.reportShown(e,n),!0}firstBlockAfter(e,t){return Array.from(e.children).find(e=>e.hasAttribute(Ot)&&Number(e.getAttribute(Ot))>t)??null}remove(e){const t=this.blocks.get(e);t&&(this.blocks.delete(e),t.observer?.disconnect(),this.deps.unmount(t.container),t.host.remove())}findContainer(e,t){const{code:n,css_selector:o}=e;if(!o)return this.logSkip(n,t,`${zt} Embedded "${n}" has no css_selector; skipping`),null;try{const e=document.querySelector(o);return e||this.logSkip(n,t,`${zt} Embedded "${n}": nothing matches "${o}" on this page; skipping`),e}catch(e){return this.logSkip(n,t,`${zt} Embedded "${n}": invalid css_selector "${o}"; skipping`,e),null}}logSkip(e,t,...n){if("auto"===t){if(this.autoSkipLogged.has(e))return;this.autoSkipLogged.add(e)}on.debug(...n)}reportShown(e,t){const{code:n}=e.popup;this.deps.recordVisit(e),on.debug(`${zt} Embedded "${n}" rendered (trigger: ${t})`),this.deps.dispatchShown(n,t)}watchFirstView(e,t,n){if(this.viewed.has(e.popup.code))return null;if("function"!=typeof IntersectionObserver)return this.reportViewed(e.popup.code,t),null;const o=new IntersectionObserver(n=>{n.some(e=>e.isIntersecting)&&(o.disconnect(),this.reportViewed(e.popup.code,t))});return o.observe(n),o}reportViewed(e,t){this.viewed.has(e)||(this.viewed.add(e),this.deps.recordImpression(e),this.deps.recordFormViews(e,t))}}const mo={not_determined:"DEFAULT",granted_explicit:"GRANTED",denied:"DENIED",unsupported:"UNSUPPORTED"},fo=new Set(Object.values(mo));function go(e,t){const n=t.push_permission_status?.toUpperCase();return!n||!fo.has(n)||function(e){if("function"==typeof e.getPushPermissionStatus)try{return mo[e.getPushPermissionStatus()]}catch{return}}(e)===n}const bo=e=>{(0,ln.render)(null,e)};function yo(){const{pathname:e}=window.location;try{return decodeURIComponent(e)}catch{return e}}class vo{constructor(e){this.isRecurringVisitor=!1,this.entries=new Map,this.contentEntries=new Map,this.queue=[],this.visible=null,this.drainTimeoutId=null,this.autoShowEnabled=!0,this.colorScheme="auto",this.isNavigationSubscribed=!1,this.openPopupsCount=0,this.bodyOverflowBeforeLock=null,this.readyPromise=new Promise(e=>{this.readyResolve=e}),this.pw=e,this.submitHandlers={onSubmitChoice:rn(e),onSubmitRating:sn(e),onRequestSubscribe:an(e)},this.embedded=new ho({matchesPage:e=>this.checkSoftCondition(e),render:(e,t,n)=>{this.listenForInteractions(e,n),((e,t,n,o="auto",i)=>{(0,ln.render)((0,cn.jsx)(so,{params:t,colorScheme:o,onSubmitForm:lo,onSubmitFormValues:n.onSubmitFormValues,onSubmitChoice:n.onSubmitChoice,onSubmitRating:n.onSubmitRating,onRequestSubscribe:n.onRequestSubscribe,onRequestRemove:i,logger:uo}),e)})(e,t,this.handlersFor(n),this.colorScheme,()=>this.embedded.removeWhere(e=>e===n))},unmount:bo,recordVisit:e=>this.recordVisit(e),recordImpression:e=>this.recordPopupShownEvent(e),recordFormViews:(e,t)=>this.recordSubscriptionFormViews(e,t),dispatchShown:(e,t)=>this.pw.dispatchEvent("show-web-popup",{code:e,trigger:t})}),e.moduleRegistry.webPopups=this}async run(){const{pw:e}=this;try{if(!1===e.initParams.webPopups?.enable)return void on.info(`${zt} switched off by webPopups.enable, skipping`);this.autoShowEnabled=!1!==e.initParams.webPopups?.autoShow,this.colorScheme=e.initParams.webPopups?.colorScheme??"auto";const t=await e.data.getFeatures();if(!1===t?.popup_forms?.enabled)return void on.debug(`${zt} application has no active popup forms, skipping automatic display`);await e.api.ensureDeviceRegistered(),this.isRecurringVisitor=await e.data.getIsRecurringVisitor();const n=await e.api.getPopupForms();on.debug(`${zt} Received ${n.length} popup(s) from server:`,n.map(e=>e.code)),n.forEach((e,t)=>{this.entries.set(e.code,this.createEntry("campaign",e,t))}),await Promise.allSettled(Array.from(this.entries.values()).map(async e=>{e.passedStrongConditions=this.checkStrongCondition(e.popup),e.passedFrequency=await this.checkCanBeShownByFrequencyCondition(e.popup).catch(()=>!1),this.shouldPrefetchContent(e)&&await this.ensureContent(e)}));const o=this.loadedCodes();on.debug(`${zt} ${o.length} popup(s) passed strong conditions and loaded:`,o),this.subscribeToNavigation(),this.subscribeToPushPermission(),this.renderForCurrentPage(),await e.data.setIsRecurringVisitor(!0)}finally{this.readyResolve(),e.dispatchEvent("web-popups-ready",{})}}async show(e){await this.readyPromise;const t=this.entries.get(e)??this.getContentEntry(e),n="campaign"===t.kind&&po(t.popup);if(!n&&this.visible?.code===e)return!0;if(!go(this.pw,t.popup))return on.debug(`${zt} show("${e}"): the visitor's push permission does not match the campaign`),!1;const o=await this.ensureContent(t);return o?"content"===t.kind&&$t(o).some(e=>e.contents.some(e=>e.slots.some(e=>qt.has(e.type))))?(on.error(new Error("Web popup form needs a campaign"),`${zt} show("${e}"): a form content is shown by a campaign only`),!1):n?this.embedded.show(t,o):this.visible?.code===e||!!this.checkNotExpired(t)&&(this.visible&&(on.debug(`${zt} show("${e}") preempting "${this.visible.code}"`),this.visible.close("preempted")),this.detachFromAutoPipeline(t),this.present(t,"api"),!0):(on.error(new Error("Web popup content unavailable"),`${zt} show("${e}"): content unavailable`),!1)}hide(e){return!!this.visible&&((void 0===e||this.visible.code===e)&&(this.visible.close("api"),!0))}hideAll(){const e=this.hide();return this.entries.forEach(e=>{"waiting"!==e.state&&"queued"!==e.state||(this.detachFromAutoPipeline(e),e.state="done")}),this.cancelScheduledDrain(),e}isVisible(e){return!!this.visible&&(void 0===e||this.visible.code===e)}getVisibleCode(){return this.visible?.code??null}getAvailableCodes(){return Array.from(this.entries.keys())}getState(){const e=[];return this.entries.forEach((t,n)=>{"waiting"===t.state&&e.push(n)}),{visible:this.getVisibleCode(),queued:[...this.queue],waiting:e,available:this.getAvailableCodes()}}createEntry(e,t,n){return{kind:e,popup:t,order:n,state:"idle",content:null,loading:null,passedStrongConditions:!1,passedFrequency:!1,timeoutId:null,visitRecorded:!1}}getContentEntry(e){let t=this.contentEntries.get(e);return t||(t=this.createEntry("content",{code:e,popup_form_content_code:e,device_type:"ALL",visitors_type:"ALL",matching_pages:[],delay:0,frequency:"EVERY_VISIT",trigger_type:"API"},-1),this.contentEntries.set(e,t)),t}ensureContent(e){return e.content?Promise.resolve(e.content):(e.loading||(e.loading=this.loadContent(e.popup).then(t=>(e.content=t,t)).catch(t=>(on.error(t,`${zt} Failed to load web popup "${e.popup.code}"`),null)).finally(()=>{e.content||(e.loading=null)})),e.loading)}async loadContent(e){const t=(e=>{const t=et(e);return t?0===$t(t.params).length?null:t.params:null})((await this.pw.api.getPopupFormContent(e.popup_form_content_code)).json);return t||(on.error(new Error("Unsupported popup content format"),`${zt} Web popup "${e.code}" content is not a supported {version, params} popup; skipping`),null)}shouldPrefetchContent(e){return e.passedStrongConditions&&(po(e.popup)||e.passedFrequency)}loadedCodes(){const e=[];return this.entries.forEach((t,n)=>{t.content&&e.push(n)}),e}renderForCurrentPage(){this.releaseUnmatchedPending();const e=[];this.entries.forEach((t,n)=>{this.canAutoDisplay(t)&&(this.armDelay(t),e.push(n))}),on.debug(`${zt} ${e.length} popup(s) selected for display on "${yo()}":`,e),this.drain(),this.embedded.syncWithPage(this.entries.values(),e=>this.isAutoEligible(e))}canAutoDisplay(e){return!po(e.popup)&&"idle"===e.state&&this.isAutoEligible(e)&&e.passedFrequency&&this.checkNotExpired(e)}isAutoEligible(e){return this.autoShowEnabled&&e.passedStrongConditions&&this.isAutoTrigger(e.popup)&&null!==e.content&&this.checkSoftCondition(e.popup)&&go(this.pw,e.popup)}isStillEligible(e){return this.checkSoftCondition(e.popup)&&go(this.pw,e.popup)&&this.checkNotExpired(e)}isAutoTrigger(e){const t=e.trigger_type;return!t||"PAGE_LOAD"===t}armDelay(e){const{popup:t}=e;on.debug(`${zt} Popup "${t.code}" armed for display in ${t.delay}s`),e.state="waiting",this.recordVisit(e),e.timeoutId=window.setTimeout(()=>{e.timeoutId=null,e.state="queued",this.insertIntoQueue(e),on.debug(`${zt} Popup "${t.code}" delay elapsed; queued at position ${this.queue.indexOf(t.code)+1} of ${this.queue.length}`),this.drain()},1e3*t.delay)}recordVisit(e){e.visitRecorded||(e.visitRecorded=!0,this.pw.api.recordPopupFormEvent(e.popup.code,1).catch(t=>{on.error(t,`${zt} Failed to record web popup visit event for "${e.popup.code}"`)}))}insertIntoQueue(e){const t=this.queue.findIndex(t=>{const n=this.entries.get(t);return!!n&&(n.popup.delay!==e.popup.delay?n.popup.delay>e.popup.delay:n.order>e.order)});-1!==t?this.queue.splice(t,0,e.popup.code):this.queue.push(e.popup.code)}releaseUnmatchedPending(){this.entries.forEach(e=>{"waiting"!==e.state&&"queued"!==e.state||this.isStillEligible(e)||(this.detachFromAutoPipeline(e),e.state="idle",on.debug(`${zt} Released popup "${e.popup.code}": page or push permission no longer matches, or its countdown passed`))})}detachFromAutoPipeline(e){null!==e.timeoutId&&(window.clearTimeout(e.timeoutId),e.timeoutId=null);const t=this.queue.indexOf(e.popup.code);-1!==t&&this.queue.splice(t,1)}drain(){if(this.visible||null!==this.drainTimeoutId)return;const e=this.queue.shift();if(void 0===e)return;const t=this.entries.get(e);if(t&&"queued"===t.state){if(!this.isStillEligible(t))return t.state="idle",void this.drain();if(!t.content)return t.state="done",void this.drain();on.debug(`${zt} Display slot free; showing "${e}"`),this.present(t,"auto")}else this.drain()}scheduleDrain(){null===this.drainTimeoutId&&(this.drainTimeoutId=window.setTimeout(()=>{this.drainTimeoutId=null,this.drain()},400))}cancelScheduledDrain(){null!==this.drainTimeoutId&&(window.clearTimeout(this.drainTimeoutId),this.drainTimeoutId=null)}present(e,t){this.cancelScheduledDrain();const{popup:n,content:o}=e;if(!o)return void(e.state="done");const i=document.createElement("div");i.id=`${Vt}-${n.code}`,i.style.position="fixed",i.style.inset="0",i.style.zIndex=String(2147483647),i.style.pointerEvents="none",document.body.appendChild(i);const r=i.attachShadow({mode:"open"}),s=document.createElement("div");r.appendChild(s),this.listenForInteractions(s,e);const a=!!o.overlay;a&&this.lockBodyScroll();let c=!1;const l=t=>{c||(c=!0,a&&this.unlockBodyScroll(),bo(s),i.remove(),this.visible?.code===n.code&&(this.visible=null),e.state="done",this.pw.dispatchEvent("hide-web-popup",{code:n.code,reason:t}),this.scheduleDrain())};this.visible={code:n.code,host:i,modal:a,close:l},e.state="visible",((e,t,n,o,i="auto")=>{(0,ln.render)((0,cn.jsx)(ro,{params:t,mode:"live",colorScheme:i,onRequestClose:n,onSubmitForm:lo,onSubmitFormValues:o.onSubmitFormValues,onSubmitChoice:o.onSubmitChoice,onSubmitRating:o.onSubmitRating,onRequestSubscribe:o.onRequestSubscribe,logger:uo}),e)})(s,o,()=>l("user"),this.handlersFor(e),this.colorScheme),this.recordSubscriptionFormViews(n.code,o),on.debug(`${zt} Popup "${n.code}" shown (trigger: ${t})`),"campaign"===e.kind&&(this.recordVisit(e),this.markAsShown(n).catch(e=>{on.error(e,`${zt} Failed to mark web popup "${n.code}" as shown`)})),this.pw.dispatchEvent("show-web-popup",{code:n.code,trigger:t})}handlersFor(e){return{...this.submitHandlers,onSubmitFormValues:(t=this.pw,n=e.popup.code,async e=>{try{const o=await t.api.submitPopupForm(n,e);if("OK"===o.result)return"ok";if("INVALID_EMAIL"===o.result)return"invalid-email";throw new Error(`Unexpected submitPopupForm result "${o.result}"`)}catch(e){throw on.error(e,`Failed to submit the form of web campaign "${n}"`),e}})};var t,n}recordSubscriptionFormViews(e,t){const n=function(e){const t=new Set;for(const n of e.pages)if(Array.isArray(n?.contents))for(const e of n.contents)if(Array.isArray(e?.slots))for(const n of e.slots)"object"==typeof n&&null!==n&&"email-subscription-form"===n.type&&"string"==typeof n.formCode&&n.formCode&&t.add(n.formCode);return[...t]}(t);0!==n.length&&this.pw.data.getHwid().then(e=>n.forEach(t=>((e,t)=>{fetch(co(e,"/view"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e,userId:t,hwid:t})}).catch(t=>{on.error(t,`Failed to record subscription form view for "${e}"`)})})(t,e))).catch(t=>{on.error(t,`${zt} Failed to record subscription form views for web popup "${e}"`)})}lockBodyScroll(){0===this.openPopupsCount&&(this.bodyOverflowBeforeLock=document.body.style.overflow,document.body.style.overflow="hidden"),this.openPopupsCount+=1}unlockBodyScroll(){this.openPopupsCount=Math.max(0,this.openPopupsCount-1),0===this.openPopupsCount&&null!==this.bodyOverflowBeforeLock&&(document.body.style.overflow=this.bodyOverflowBeforeLock,this.bodyOverflowBeforeLock=null)}subscribeToNavigation(){if(this.isNavigationSubscribed)return;this.isNavigationSubscribed=!0;const e=()=>this.renderForCurrentPage(),t=window.navigation;if(t&&"function"==typeof t.addEventListener)return void t.addEventListener("currententrychange",e);window.addEventListener("popstate",e),window.addEventListener("hashchange",e);let n=window.location.href;window.setInterval(()=>{window.location.href!==n&&(n=window.location.href,e())},500)}subscribeToPushPermission(){const e=()=>this.releaseByPushPermission();"function"!=typeof this.pw.addSdkEventHandler?this.pw.addEventHandler("change-permission",e):this.pw.addSdkEventHandler("change-permission",e)}releaseByPushPermission(){this.releaseUnmatchedPending(),this.embedded.removeWhere(e=>!go(this.pw,e.popup))}checkStrongCondition(e){return this.checkCanBeShownByDeviceTypeCondition(e)&&this.checkCanBeShownByVisitorsTypeCondition(e)}checkSoftCondition(e){return this.checkCanBeShownByMatchingPagesCondition(e)}checkNotExpired(e){return!e.content||(!function(e,t){for(const n of e.pages)if(Array.isArray(n?.contents))for(const e of n.contents)if(Array.isArray(e?.slots))for(const n of e.slots){if("object"!=typeof n||null===n)continue;if("timer"!==n.type||"hide-popup"!==n.onExpire)continue;if("string"!=typeof n.endTime)continue;const e="string"==typeof n.timezone?n.timezone:"",o=He(n.endTime,e);if(null!==o&&o<=t)return!0}return!1}(e.content,Date.now())||(on.debug(`${zt} Popup "${e.popup.code}" not shown: its countdown has passed`),!1))}checkCanBeShownByDeviceTypeCondition(e){const{device_type:t}=e,n=this.pw.platformChecker.formFactor;return"ALL"===t||t===n}async checkCanBeShownByFrequencyCondition(e){const{frequency:t,code:n}=e;if("ONCE"===t){return!(await this.pw.data.getShownWebPopups()).includes(n)}return"ONCE_PER_SESSION"!==t||null===sessionStorage.getItem(this.getSessionStorageKey(n))}checkCanBeShownByMatchingPagesCondition(e){const{matching_pages:t,matching_page_rules:n,excluded_pages:o}=e,i=yo();return n&&n.length>0?n.some(e=>this.matchPageRule(i,e)):t&&t.length>0?t.some(e=>Boolean(e)&&e===i):!(o&&o.length>0)||!o.some(e=>this.matchPageRule(i,e))}matchPageRule(e,t){if(!t.path)return!1;switch(t.operator){case"EQUALS":return e===t.path;case"STARTS_WITH":return e.startsWith(t.path);default:return!1}}checkCanBeShownByVisitorsTypeCondition(e){const{visitors_type:t}=e;return"NEW"===t?!this.isRecurringVisitor:"RECURRING"!==t||this.isRecurringVisitor}recordPopupShownEvent(e){this.pw.api.recordPopupFormEvent(e,2).catch(t=>{on.error(t,`${zt} Failed to record web popup shown event for "${e}"`)})}listenForInteractions(e,t){"campaign"===t.kind&&function(e,t){e.addEventListener("click",e=>{const n=e.target instanceof Element?e.target.closest("a, button"):null;n&&!n.hasAttribute(fn)&&(n.hasAttribute(gn)||t())})}(e,()=>{this.pw.api.recordPopupFormEvent(t.popup.code,3).catch(e=>{on.error(e,`${zt} Failed to record web popup interaction for "${t.popup.code}"`)})})}async markAsShown(e){this.recordPopupShownEvent(e.code);const{frequency:t,code:n}=e;"ONCE"!==t?"ONCE_PER_SESSION"===t&&sessionStorage.setItem(this.getSessionStorageKey(n),"1"):await this.pw.data.addShownWebPopup(n)}getSessionStorageKey(e){return`${Vt}.shown.${e}`}}return s})());
2
2
  //# sourceMappingURL=widget-web-popups.js.map