@cnv-vn/track 0.3.0-beta.8 → 0.3.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cnv-track.esm.js +2 -2
- package/dist/cnv-track.min.js +2 -2
- package/dist/cnv-track.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/cnv-track.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cnv-vn/track v0.3.0-beta.
|
|
2
|
+
* @cnv-vn/track v0.3.0-beta.9
|
|
3
3
|
* (c) 2026 CNV
|
|
4
4
|
* Released under the UNLICENSED license.
|
|
5
5
|
*/
|
|
6
|
-
function n(n){try{n()}catch(n){}}function t(n,t){try{return n()}catch(n){return t}}function e(t){return t&&n(t),null}const o=["pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","rtf","zip","rar","7z","tar","gz","mp3","mp4","mov","wav","avi","mkv","dmg","exe","pkg","apk","msi","svg"];function r(n){return!!n&&"object"==typeof n&&1===n.nodeType&&"A"===n.tagName}function i(n){const t=n.lastIndexOf("/");return-1===t?n:n.slice(t+1)}function c(n){var t,e,o;let r=(null!==(t=n.textContent)&&void 0!==t?t:"").trim();return r||(r=(null!==(e=n.getAttribute("aria-label"))&&void 0!==e?e:"").trim()),r||(r=(null!==(o=n.getAttribute("title"))&&void 0!==o?o:"").trim()),r.length>200?r.slice(0,200):r}const l=200;function a(n){let t="";try{t=(n.textContent||"").replace(/\s+/g," ").trim(),t||(t=(n.getAttribute("aria-label")||"").trim()),t||(t=(n.getAttribute("title")||"").trim()),t=t.normalize("NFC")}catch(n){return""}return t.length>l?t.slice(0,l):t}function u(n){const t=!1!==n.caseInsensitive;if("regex"===n.mode)return{mode:"regex",needle:n.value,ci:t,re:_(n.value,t)};const e=n.value.normalize("NFC");return{mode:n.mode,needle:t?e.toLowerCase():e,ci:t,re:null}}function s(n,t){try{return n.matches(t)}catch(n){return!1}}function d(n){try{if("A"===n.tagName){const t=n.getAttribute("href");return t?y(t):null}const t=n.getAttribute("formaction");if(t)return y(t);const e=n.getAttribute("data-href");if(e)return y(e);const o=n.closest("form");if(o){const n=o.getAttribute("action");if(n)return y(n)}return null}catch(n){return null}}function f(n){return"regex"===n.mode?{mode:"regex",needle:n.value,re:_(n.value,!0)}:{mode:n.mode,needle:n.value.toLowerCase(),re:null}}function p(n){if("startsWith"===n.mode)return{mode:"startsWith",needle:n.value,re:null};const t="glob"===n.mode?"^"+n.value.replace(/[.+^${}()|[\]\\?]/g,"\\$&").replace(/\*/g,".*")+"$":n.value;return{mode:n.mode,needle:n.value,re:_(t,!1)}}function h(n,t){return"startsWith"===n.mode?0===t.indexOf(n.needle):!n.re||w(n.re,t)}const v=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,m=/\+?\d[\d\s().-]{7,}\d/g;function g(n){if(!n)return n;try{return n.replace(v,"[email]").replace(m,"[phone]")}catch(t){return n}}function b(n){return!!n&&"object"==typeof n&&1===n.nodeType}function y(n){try{return new URL(n,location.href).href}catch(t){return n}}function _(n,t){try{return!n||n.length>1e3?null:new RegExp(n,t?"i":"")}catch(n){return null}}function w(n,t){try{return n.test(t)}catch(n){return!1}}function x(t,e){if("undefined"==typeof document)return()=>{};const o=(n=>{const t=n.globalThrottle||{},e=[],o=n.rules||[];for(let n=0;n<o.length;n++){const r=o[n];if(!r||!1===r.enabled)continue;if(!r.match||!r.event)continue;const i=r.match,c=r.throttle||{};e.push({rule:r,elementSpec:k(r),selector:i.selector||null,text:i.text?u(i.text):null,dest:i.destinationUrl?f(i.destinationUrl):null,urlScope:r.urlScope?p(r.urlScope):null,dedupeWindowMs:O(c.dedupeWindowMs,O(t.dedupeWindowMs,500)),maxPerPageview:O(c.maxPerPageview,O(t.maxPerPageview,1/0)),samplingRate:S(O(c.samplingRate,O(t.samplingRate,1)))})}return e.sort((n,t)=>(n.rule.priority||0)-(t.rule.priority||0)),e})(e);if(0===o.length)return()=>{};const r=new WeakMap;let i=0;const c=n=>{let t=r.get(n);return void 0===t&&(t=++i,r.set(n,t)),String(t)},l=new Map,a=new Map;let s=M();function d(e){try{if(0!==e.button)return;const r=M();r!==s&&(s=r,a.clear(),l.clear());const i=(n=>{const t=[];try{const e="function"==typeof n.composedPath?n.composedPath():[];if(e&&e.length>0){for(const n of e)b(n)&&t.push(n);return t}let o=n.target;for(;o;)b(o)&&t.push(o),o=o.parentNode}catch(n){}return t})(e);if(0===i.length)return;const u=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(n){return""}})();for(let r=0;r<o.length;r++){const s=o[r];if(s.urlScope&&!h(s.urlScope,u))continue;let d=null;for(let n=0;n<i.length;n++)if(A(s,i[n])){d=i[n];break}if(!d)continue;const f=s.rule.id;if((a.get(f)||0)>=s.maxPerPageview)return;const p=f+"#"+c(d),v=Date.now(),m=l.get(p);if(void 0!==m&&v-m<s.dedupeWindowMs)return;if(s.samplingRate<1&&Math.random()>=s.samplingRate)return;l.set(p,v),a.set(f,(a.get(f)||0)+1);const g=C(s.rule,d,e);return void n(()=>t.track("clicked",g))}}catch(n){}}try{document.addEventListener("click",d,!0)}catch(n){return()=>{}}return()=>{try{document.removeEventListener("click",d,!0)}catch(n){}l.clear(),a.clear()}}function k(n){const t=n.match;return t.element?t.element:t.selector||t.id||t.dataAttr||t.classes&&t.classes.length>0||t.destinationUrl?"any":void 0}function A(n,t){if(!((n,t)=>{if(!t)return(n=>{const t=n.tagName;if("BUTTON"===t||"A"===t)return!0;if("INPUT"===t){const t=(n.getAttribute("type")||"").toLowerCase();return"submit"===t||"button"===t||"reset"===t}return"button"===n.getAttribute("role")})(n);if("any"===t)return!0;if("button"===t){const t=n.tagName;if("BUTTON"===t)return!0;if("INPUT"===t){const t=(n.getAttribute("type")||"").toLowerCase();return"submit"===t||"button"===t||"reset"===t}return"button"===n.getAttribute("role")}return"link"===t?"A"===n.tagName:s(n,t)})(t,n.elementSpec))return!1;const e=n.rule.match;return!(n.selector&&!s(t,n.selector)||void 0!==e.id&&!((n,t)=>n.id===t)(t,e.id)||e.classes&&e.classes.length>0&&!((n,t)=>{try{for(let e=0;e<t.length;e++)if(!n.classList.contains(t[e]))return!1;return!0}catch(n){return!1}})(t,e.classes)||e.dataAttr&&!((n,t,e)=>{try{return!!n.hasAttribute(t)&&(void 0===e||n.getAttribute(t)===e)}catch(n){return!1}})(t,e.dataAttr.name,e.dataAttr.value)||n.text&&!((n,t)=>{const e=a(n);if("regex"===t.mode)return!!t.re&&w(t.re,e);const o=t.ci?e.toLowerCase():e;return"exact"===t.mode?o===t.needle:"startsWith"===t.mode?0===o.indexOf(t.needle):-1!==o.indexOf(t.needle)})(t,n.text)||n.dest&&!((n,t)=>{const e=d(n);if(!e)return!1;if("regex"===t.mode)return!!t.re&&w(t.re,e);if("domain"===t.mode)try{return new URL(e).host.toLowerCase()===t.needle}catch(n){return!1}const o=e.toLowerCase();return"exact"===t.mode?o===t.needle:"startsWith"===t.mode?0===o.indexOf(t.needle):-1!==o.indexOf(t.needle)})(t,n.dest))}function C(n,t,e){const o={},r=n.event.staticProps;if(r)for(const n of Object.keys(r))o[n]=r[n];const i=n.capture;if(i)try{if(i.text){const n=g(a(t));n&&(o.text=n)}if(i.href){const n=d(t);n&&(o.href=n)}if(i.elementId&&t.id&&(o.element_id=t.id),i.classes&&(o.element_classes=Array.from(t.classList)),i.dataAttrs&&i.dataAttrs.length>0)for(let n=0;n<i.dataAttrs.length;n++){const e=i.dataAttrs[n],r=t.getAttribute(e);null!==r&&(o[e]=g(r))}if(i.valueFrom){const n=((n,t)=>{try{const e=n.querySelector(t.selector)||(n.parentElement?n.parentElement.querySelector(t.selector):null);if(!e)return null;const o=t.attr?e.getAttribute(t.attr):e.textContent||"";if(null===o)return null;const r=g(o.replace(/\s+/g," ").trim());return r.length>l?r.slice(0,l):r}catch(n){return null}})(t,i.valueFrom);null!==n&&(o[i.valueFrom.as]=n)}i.selectorPath&&(o.selector_path=((n,t=5)=>{try{const e=[];let o=n,r=0;for(;o&&1===o.nodeType&&r<t;){let n=o.tagName.toLowerCase();if(o.id){e.unshift(n+"#"+o.id);break}const t=Array.from(o.classList).slice(0,2).join(".");t&&(n+="."+t),e.unshift(n),o=o.parentElement,r++}return e.join(" > ")}catch(n){return""}})(t)),i.position&&(o.x=e.clientX,o.y=e.clientY)}catch(n){}return o.rule_id=n.id,n.name&&(o.rule_name=n.name),n.event&&n.event.name&&(o.event_name=n.event.name),o.tag=t.tagName.toLowerCase(),o}function M(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}function O(n,t){return"number"!=typeof n||isNaN(n)?t:n}function S(n){return n<0?0:n>1?1:n}const I="__cnvPatched";function E(n){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let t=N();function e(){try{const e=N();if(e===t)return;t=e,n(e)}catch(n){}}const o=history.pushState,r=history.replaceState,i=!0===o[I],c=!0===r[I];if(!i){function u(...n){o.apply(this,n),e()}u[I]=!0,history.pushState=u}if(!c){function s(...n){r.apply(this,n),e()}s[I]=!0,history.replaceState=s}const l=()=>e(),a=()=>e();try{window.addEventListener("popstate",l),window.addEventListener("hashchange",a)}catch(d){}return()=>{try{window.removeEventListener("popstate",l),window.removeEventListener("hashchange",a)}catch(n){}try{!i&&history.pushState[I]&&(history.pushState=o),!c&&history.replaceState[I]&&(history.replaceState=r)}catch(n){}}}function N(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}const z=["q","s","query","search","keyword"],T={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},D={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};const j=2147483e3,R="#6C5CE7",B="#FFFFFF";function F(){try{return"undefined"!=typeof window&&"function"==typeof window.matchMedia?window.matchMedia("(max-width: 768px)").matches:"undefined"!=typeof window&&"number"==typeof window.innerWidth&&window.innerWidth<=768}catch(n){return!1}}function L(n,t){return(n=>"string"==typeof n&&/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(n))(n)?n:t}function P(n){if("string"!=typeof n||0===n.trim().length)return!1;try{const t="undefined"!=typeof location?location.href:void 0,e=new URL(n,t);return"https:"===e.protocol||"http:"===e.protocol||"data:"===e.protocol&&/^data:image\//i.test(n.trim())}catch(n){return!1}}function $(n){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(Math.trunc(n),0),2147483647):null}function U(n,t=20){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(n,0),2e3):t}function V(n,t){const e=n.replace("#",""),o=3===e.length?e.replace(/(.)/g,"$1$1"):e;return`rgba(${parseInt(o.slice(0,2),16)}, ${parseInt(o.slice(2,4),16)}, ${parseInt(o.slice(4,6),16)}, ${t})`}function H(n,t){const e=t?null==n?void 0:n.placementMobile:null==n?void 0:n.placementDesktop;return{side:"LEFT"===(null==e?void 0:e.position)?"left":"right",sideSpacingPx:U(null==e?void 0:e.sideSpacing),bottomSpacingPx:U(null==e?void 0:e.bottomSpacing)}}function K(n,t){const e=document.createElement("div");e.setAttribute(n,"");const o=e.attachShadow({mode:"open"}),r=document.createElement("style");return r.textContent=t,o.appendChild(r),{hostEl:e,shadow:o}}function q(n){var t;(null!==(t=document.body)&&void 0!==t?t:document.documentElement).appendChild(n)}const G="cnv:panel:opened",Z="cnv:panel:closed";function W(n,t,e){if(e)n.innerHTML='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none"><path d="M6 6l12 12M18 6 6 18" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/></svg>';else if("CUSTOM"===t.iconType&&P(t.customIconUrl)){n.innerHTML="";const e=document.createElement("img");e.src=t.customIconUrl,e.alt="",n.appendChild(e)}else n.innerHTML=(n=>{switch(n){case"BAG_HEART":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7 8V6a5 5 0 0 1 10 0v2" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="M4.5 8h15l-1 12.5a1.5 1.5 0 0 1-1.5 1.4H7a1.5 1.5 0 0 1-1.5-1.4L4.5 8Z" fill="currentColor"/><path d="M12 12.8c1-1.4 3.6-1 3.6 1 0 1.7-2.2 2.9-3.6 3.9-1.4-1-3.6-2.2-3.6-3.9 0-2 2.6-2.4 3.6-1Z" fill="#fff"/></svg>';case"TAG":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.6 3.4 20 10.8a2 2 0 0 1 0 2.8l-6.4 6.4a2 2 0 0 1-2.8 0L3.4 12.6A2 2 0 0 1 2.8 11l.6-6.2A2 2 0 0 1 5.2 3l6.2-.6a2 2 0 0 1 1.2.4Z" fill="currentColor"/><circle cx="8" cy="8" r="1.6" fill="#fff"/></svg>';case"STAR":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2.5l2.9 6 6.6.7-4.9 4.5 1.3 6.5L12 16.9l-5.9 3.3 1.3-6.5-4.9-4.5 6.6-.7L12 2.5Z" fill="currentColor"/></svg>';case"GIFT":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect x="3.5" y="9.5" width="17" height="10" rx="1.2" fill="currentColor"/><rect x="2.5" y="6.5" width="19" height="3.5" rx="1" fill="currentColor"/><rect x="11" y="6.5" width="2" height="13" fill="#fff"/><path d="M12 6.5c0-2 -2-3.5-3.6-3.5S6 4.3 6 5.4c0 .9.8 1.1 1.6 1.1H12Z" fill="currentColor"/><path d="M12 6.5c0-2 2-3.5 3.6-3.5S18 4.3 18 5.4c0 .9-.8 1.1-1.6 1.1H12Z" fill="currentColor"/></svg>';default:return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3 9.5 7 12l5-6 5 6 4-2.5-1.6 9.5a1.5 1.5 0 0 1-1.5 1.3H6.1a1.5 1.5 0 0 1-1.5-1.3L3 9.5Z" fill="currentColor"/></svg>'}})(t.iconPreset)}function Y(e,o){if("undefined"==typeof document||"undefined"==typeof window)return()=>{};try{const{hostEl:e,shadow:r}=K("data-cnv-launcher",':host{all:initial;}.cnv-launcher-fab{display:inline-flex;align-items:center;gap:8px;height:48px;padding:0 18px;border:none;cursor:pointer;box-shadow:0 6px 18px rgba(0,0,0,.18);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;font-size:14px;font-weight:600;line-height:1;white-space:nowrap;transition:transform .18s cubic-bezier(.16,1,.3,1),box-shadow .18s ease;animation:cnv-fab-in .32s cubic-bezier(.16,1,.3,1);}.cnv-launcher-fab:hover{transform:translateY(-2px);box-shadow:0 10px 26px rgba(0,0,0,.24);}.cnv-launcher-fab:active{transform:translateY(0) scale(.96);}.cnv-launcher-fab__icon{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;flex-shrink:0;}.cnv-launcher-fab__icon svg,.cnv-launcher-fab__icon img{width:20px;height:20px;object-fit:contain;animation:cnv-fab-icon-in .28s cubic-bezier(.16,1,.3,1);}@keyframes cnv-fab-in{from{opacity:0;transform:translateY(10px) scale(.9);}to{opacity:1;transform:none;}}@keyframes cnv-fab-icon-in{from{opacity:0;transform:rotate(-90deg) scale(.4);}to{opacity:1;transform:none;}}@media (prefers-reduced-motion:reduce){.cnv-launcher-fab,.cnv-launcher-fab__icon svg,.cnv-launcher-fab__icon img{animation:none !important;transition:none !important;}}'),i=document.createElement("button");i.type="button",i.className="cnv-launcher-fab",i.setAttribute("aria-label","Launcher");const c=document.createElement("span");c.className="cnv-launcher-fab__icon";const l=document.createElement("span");l.className="cnv-launcher-fab__text",i.appendChild(c),i.appendChild(l),r.appendChild(i),((n,t,e)=>{n.style.backgroundColor=L(e.backgroundColor,R),n.style.color=L(e.textColor,B),n.style.borderRadius=(n=>{switch(n){case"SQUARE":return"2px";case"SHAVED":return"8px";case"ROUNDED":return"16px";default:return"999px"}})(e.buttonShape),W(t,e,!1)})(i,c,o);let a=!1;const u=()=>((n,e,o,r,i)=>{try{const c=F();if(((n,e)=>{if("DESKTOP_ONLY"===n.deviceVisibility&&e)return!0;if(n.hideOnHomepage&&t(()=>"/"===location.pathname||""===location.pathname,!1))return!0;const o=n.hideUrlConditions;if(o&&o.length>0){const n=t(()=>location.pathname+location.search,"");if(o.some(t=>"string"==typeof t&&t.length>0&&n.includes(t)))return!0}return!1})(r,c))return void n.style.setProperty("display","none");n.style.removeProperty("display");const{side:l,sideSpacingPx:a,bottomSpacingPx:u}=H(r,c),s=r.useCustomZIndex?$(r.zIndex):null,d=r.addImportantRule?"important":"",f=(t,e)=>n.style.setProperty(t,e,d);f("position","fixed"),f("bottom",u+"px"),f("left","left"===l?a+"px":"auto"),f("right","right"===l?a+"px":"auto"),f("z-index",String(null!=s?s:j));const p=c?r.contentLayoutMobile:r.contentLayoutDesktop,h=!i&&"ICON_ONLY"!==p;e.style.display=i||"TEXT_ONLY"!==p?"inline-flex":"none",o.style.display=h?"inline":"none",h&&(o.textContent=(c?r.buttonTextMobile:r.buttonTextDesktop)||"")}catch(n){}})(e,c,l,o,a),s=t=>{a!==t&&(a=t,n(()=>{W(c,o,t),i.setAttribute("aria-label",t?"Đóng":"Launcher"),u()}))},d=()=>s(!0),f=()=>s(!1);window.addEventListener(G,d),window.addEventListener(Z,f);const p=()=>{n(()=>window.dispatchEvent(new CustomEvent("cnv:launcher:click",{detail:{config:o}})))};i.addEventListener("click",p);const h=()=>{n(()=>{q(e),u()})};document.body?h():document.addEventListener("DOMContentLoaded",h,{once:!0});const v=t(()=>window.matchMedia("(max-width: 768px)"),null),m=()=>u(),g=v;v&&"function"==typeof v.addEventListener?v.addEventListener("change",m):v&&"function"==typeof g.addListener?g.addListener(m):window.addEventListener("resize",m);const b=E(u);return()=>{n(()=>{document.removeEventListener("DOMContentLoaded",h),i.removeEventListener("click",p),window.removeEventListener(G,d),window.removeEventListener(Z,f),v&&"function"==typeof v.removeEventListener?v.removeEventListener("change",m):v&&"function"==typeof g.removeListener?g.removeListener(m):window.removeEventListener("resize",m),e.remove()}),n(b)}}catch(n){return()=>{}}}function J(n,t,e,o){return new(e||(e=Promise))((r,i)=>{function c(n){try{a(o.next(n))}catch(n){i(n)}}function l(n){try{a(o.throw(n))}catch(n){i(n)}}function a(n){var t;n.done?r(n.value):(t=n.value,t instanceof e?t:new e(n=>{n(t)})).then(c,l)}a((o=o.apply(n,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Q=(n,t)=>{let e=n;const o=X[t];let r=null,i=0,c=null;const l=[],a={},u=(n,t)=>{i=4*e+17,r=(n=>{const t=new Array(n);for(let e=0;e<n;e+=1){t[e]=new Array(n);for(let o=0;o<n;o+=1)t[e][o]=null}return t})(i),s(0,0),s(i-7,0),s(0,i-7),f(),d(),h(n,t),e>=7&&p(n),null==c&&(c=m(e,o,l)),v(c,t)},s=(n,t)=>{for(let e=-1;e<=7;e+=1)if(!(n+e<=-1||i<=n+e))for(let o=-1;o<=7;o+=1)t+o<=-1||i<=t+o||(r[n+e][t+o]=0<=e&&e<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==e||6==e)||2<=e&&e<=4&&2<=o&&o<=4)},d=()=>{for(let n=8;n<i-8;n+=1)null==r[n][6]&&(r[n][6]=n%2==0);for(let n=8;n<i-8;n+=1)null==r[6][n]&&(r[6][n]=n%2==0)},f=()=>{const n=nn.getPatternPosition(e);for(let t=0;t<n.length;t+=1)for(let e=0;e<n.length;e+=1){const o=n[t],i=n[e];if(null==r[o][i])for(let n=-2;n<=2;n+=1)for(let t=-2;t<=2;t+=1)r[o+n][i+t]=-2==n||2==n||-2==t||2==t||0==n&&0==t}},p=n=>{const t=nn.getBCHTypeNumber(e);for(let e=0;e<18;e+=1){const o=!n&&1==(t>>e&1);r[Math.floor(e/3)][e%3+i-8-3]=o}for(let e=0;e<18;e+=1){const o=!n&&1==(t>>e&1);r[e%3+i-8-3][Math.floor(e/3)]=o}},h=(n,t)=>{const e=nn.getBCHTypeInfo(o<<3|t);for(let t=0;t<15;t+=1){const o=!n&&1==(e>>t&1);t<6?r[t][8]=o:t<8?r[t+1][8]=o:r[i-15+t][8]=o}for(let t=0;t<15;t+=1){const o=!n&&1==(e>>t&1);t<8?r[8][i-t-1]=o:t<9?r[8][15-t-1+1]=o:r[8][15-t-1]=o}r[i-8][8]=!n},v=(n,t)=>{let e=-1,o=i-1,c=7,l=0;const a=nn.getMaskFunction(t);for(let t=i-1;t>0;t-=2)for(6==t&&(t-=1);;){for(let e=0;e<2;e+=1)if(null==r[o][t-e]){let i=!1;l<n.length&&(i=1==(n[l]>>>c&1)),a(o,t-e)&&(i=!i),r[o][t-e]=i,c-=1,-1==c&&(l+=1,c=7)}if(o+=e,o<0||i<=o){o-=e,e=-e;break}}},m=(n,t,e)=>{const o=on.getRSBlocks(n,t),r=rn();for(let t=0;t<e.length;t+=1){const o=e[t];r.put(o.getMode(),4),r.put(o.getLength(),nn.getLengthInBits(o.getMode(),n)),o.write(r)}let i=0;for(let n=0;n<o.length;n+=1)i+=o[n].dataCount;if(r.getLengthInBits()>8*i)throw"code length overflow. ("+r.getLengthInBits()+">"+8*i+")";for(r.getLengthInBits()+4<=8*i&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(!1);for(;!(r.getLengthInBits()>=8*i||(r.put(236,8),r.getLengthInBits()>=8*i));)r.put(17,8);return((n,t)=>{let e=0,o=0,r=0;const i=new Array(t.length),c=new Array(t.length);for(let l=0;l<t.length;l+=1){const a=t[l].dataCount,u=t[l].totalCount-a;o=Math.max(o,a),r=Math.max(r,u),i[l]=new Array(a);for(let t=0;t<i[l].length;t+=1)i[l][t]=255&n.getBuffer()[t+e];e+=a;const s=nn.getErrorCorrectPolynomial(u),d=en(i[l],s.getLength()-1).mod(s);c[l]=new Array(s.getLength()-1);for(let n=0;n<c[l].length;n+=1){const t=n+d.getLength()-c[l].length;c[l][n]=t>=0?d.getAt(t):0}}let l=0;for(let n=0;n<t.length;n+=1)l+=t[n].totalCount;const a=new Array(l);let u=0;for(let n=0;n<o;n+=1)for(let e=0;e<t.length;e+=1)n<i[e].length&&(a[u]=i[e][n],u+=1);for(let n=0;n<r;n+=1)for(let e=0;e<t.length;e+=1)n<c[e].length&&(a[u]=c[e][n],u+=1);return a})(r,o)};a.addData=(n,t)=>{let e=null;switch(t=t||"Byte"){case"Numeric":e=cn(n);break;case"Alphanumeric":e=ln(n);break;case"Byte":e=an(n);break;case"Kanji":e=un(n);break;default:throw"mode:"+t}l.push(e),c=null},a.isDark=(n,t)=>{if(n<0||i<=n||t<0||i<=t)throw n+","+t;return r[n][t]},a.getModuleCount=()=>i,a.make=()=>{if(e<1){let n=1;for(;n<40;n++){const t=on.getRSBlocks(n,o),e=rn();for(let t=0;t<l.length;t++){const o=l[t];e.put(o.getMode(),4),e.put(o.getLength(),nn.getLengthInBits(o.getMode(),n)),o.write(e)}let r=0;for(let n=0;n<t.length;n++)r+=t[n].dataCount;if(e.getLengthInBits()<=8*r)break}e=n}u(!1,(()=>{let n=0,t=0;for(let e=0;e<8;e+=1){u(!0,e);const o=nn.getLostPoint(a);(0==e||n>o)&&(n=o,t=e)}return t})())},a.createTableTag=(n,t)=>{n=n||2;let e="";e+='<table style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: "+(t=void 0===t?4*n:t)+"px;",e+='">',e+="<tbody>";for(let t=0;t<a.getModuleCount();t+=1){e+="<tr>";for(let o=0;o<a.getModuleCount();o+=1)e+='<td style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: 0px;",e+=" width: "+n+"px;",e+=" height: "+n+"px;",e+=" background-color: ",e+=a.isDark(t,o)?"#000000":"#ffffff",e+=";",e+='"/>';e+="</tr>"}return e+="</tbody>",e+="</table>",e},a.createSvgTag=function(n,t,e,o){let r={};"object"==typeof arguments[0]&&(r=arguments[0],n=r.cellSize,t=r.margin,e=r.alt,o=r.title),n=n||2,t=void 0===t?4*n:t,(e="string"==typeof e?{text:e}:e||{}).text=e.text||null,e.id=e.text?e.id||"qrcode-description":null,(o="string"==typeof o?{text:o}:o||{}).text=o.text||null,o.id=o.text?o.id||"qrcode-title":null;const i=a.getModuleCount()*n+2*t;let c,l,u,s,d,f="";for(d="l"+n+",0 0,"+n+" -"+n+",0 0,-"+n+"z ",f+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',f+=r.scalable?"":' width="'+i+'px" height="'+i+'px"',f+=' viewBox="0 0 '+i+" "+i+'" ',f+=' preserveAspectRatio="xMinYMin meet"',f+=o.text||e.text?' role="img" aria-labelledby="'+g([o.id,e.id].join(" ").trim())+'"':"",f+=">",f+=o.text?'<title id="'+g(o.id)+'">'+g(o.text)+"</title>":"",f+=e.text?'<description id="'+g(e.id)+'">'+g(e.text)+"</description>":"",f+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',f+='<path d="',u=0;u<a.getModuleCount();u+=1)for(s=u*n+t,c=0;c<a.getModuleCount();c+=1)a.isDark(u,c)&&(l=c*n+t,f+="M"+l+","+s+d);return f+='" stroke="transparent" fill="black"/>',f+="</svg>",f},a.createDataURL=(n,t)=>{n=n||2,t=void 0===t?4*n:t;const e=a.getModuleCount()*n+2*t,o=t,r=e-t;return fn(e,e,(t,e)=>{if(o<=t&&t<r&&o<=e&&e<r){const r=Math.floor((t-o)/n),i=Math.floor((e-o)/n);return a.isDark(i,r)?0:1}return 1})},a.createImgTag=(n,t,e)=>{n=n||2,t=void 0===t?4*n:t;const o=a.getModuleCount()*n+2*t;let r="";return r+="<img",r+=' src="',r+=a.createDataURL(n,t),r+='"',r+=' width="',r+=o,r+='"',r+=' height="',r+=o,r+='"',e&&(r+=' alt="',r+=g(e),r+='"'),r+="/>",r};const g=n=>{let t="";for(let e=0;e<n.length;e+=1){const o=n.charAt(e);switch(o){case"<":t+="<";break;case">":t+=">";break;case"&":t+="&";break;case'"':t+=""";break;default:t+=o}}return t};return a.createASCII=(n,t)=>{if((n=n||1)<2)return(n=>{n=void 0===n?2:n;const t=1*a.getModuleCount()+2*n,e=n,o=t-n;let r,i,c,l,u;const s={"██":"█","█ ":"▀"," █":"▄"," ":" "},d={"██":"▀","█ ":"▀"," █":" "," ":" "};let f="";for(r=0;r<t;r+=2){for(c=Math.floor((r-e)/1),l=Math.floor((r+1-e)/1),i=0;i<t;i+=1)u="█",e<=i&&i<o&&e<=r&&r<o&&a.isDark(c,Math.floor((i-e)/1))&&(u=" "),e<=i&&i<o&&e<=r+1&&r+1<o&&a.isDark(l,Math.floor((i-e)/1))?u+=" ":u+="█",f+=n<1&&r+1>=o?d[u]:s[u];f+="\n"}return t%2&&n>0?f.substring(0,f.length-t-1)+Array(t+1).join("▀"):f.substring(0,f.length-1)})(t);n-=1,t=void 0===t?2*n:t;const e=a.getModuleCount()*n+2*t,o=t,r=e-t;let i,c,l,u;const s=Array(n+1).join("██"),d=Array(n+1).join(" ");let f="",p="";for(i=0;i<e;i+=1){for(l=Math.floor((i-o)/n),p="",c=0;c<e;c+=1)u=1,o<=c&&c<r&&o<=i&&i<r&&a.isDark(l,Math.floor((c-o)/n))&&(u=0),p+=u?s:d;for(l=0;l<n;l+=1)f+=p+"\n"}return f.substring(0,f.length-1)},a.renderTo2dContext=(n,t)=>{t=t||2;const e=a.getModuleCount();for(let o=0;o<e;o++)for(let r=0;r<e;r++)n.fillStyle=a.isDark(o,r)?"black":"white",n.fillRect(r*t,o*t,t,t)},a};Q.stringToBytes=n=>{const t=[];for(let e=0;e<n.length;e+=1){const o=n.charCodeAt(e);t.push(255&o)}return t},Q.createStringToBytes=(n,t)=>{const e=(()=>{const e=dn(n),o=()=>{const n=e.read();if(-1==n)throw"eof";return n};let r=0;const i={};for(;;){const n=e.read();if(-1==n)break;const t=o(),c=o(),l=o();i[String.fromCharCode(n<<8|t)]=c<<8|l,r+=1}if(r!=t)throw r+" != "+t;return i})(),o="?".charCodeAt(0);return n=>{const t=[];for(let r=0;r<n.length;r+=1){const i=n.charCodeAt(r);if(i<128)t.push(i);else{const i=e[n.charAt(r)];"number"==typeof i?(255&i)==i?t.push(i):(t.push(i>>>8),t.push(255&i)):t.push(o)}}return t}};const X={L:1,M:0,Q:3,H:2},nn=(()=>{const n=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,e=7973,o={},r=n=>{let t=0;for(;0!=n;)t+=1,n>>>=1;return t};return o.getBCHTypeInfo=n=>{let e=n<<10;for(;r(e)-r(t)>=0;)e^=t<<r(e)-r(t);return 21522^(n<<10|e)},o.getBCHTypeNumber=n=>{let t=n<<12;for(;r(t)-r(e)>=0;)t^=e<<r(t)-r(e);return n<<12|t},o.getPatternPosition=t=>n[t-1],o.getMaskFunction=n=>{switch(n){case 0:return(n,t)=>(n+t)%2==0;case 1:return(n,t)=>n%2==0;case 2:return(n,t)=>t%3==0;case 3:return(n,t)=>(n+t)%3==0;case 4:return(n,t)=>(Math.floor(n/2)+Math.floor(t/3))%2==0;case 5:return(n,t)=>n*t%2+n*t%3==0;case 6:return(n,t)=>(n*t%2+n*t%3)%2==0;case 7:return(n,t)=>(n*t%3+(n+t)%2)%2==0;default:throw"bad maskPattern:"+n}},o.getErrorCorrectPolynomial=n=>{let t=en([1],0);for(let e=0;e<n;e+=1)t=t.multiply(en([1,tn.gexp(e)],0));return t},o.getLengthInBits=(n,t)=>{if(1<=t&&t<10)switch(n){case 1:return 10;case 2:return 9;case 4:case 8:return 8;default:throw"mode:"+n}else if(t<27)switch(n){case 1:return 12;case 2:return 11;case 4:return 16;case 8:return 10;default:throw"mode:"+n}else{if(!(t<41))throw"type:"+t;switch(n){case 1:return 14;case 2:return 13;case 4:return 16;case 8:return 12;default:throw"mode:"+n}}},o.getLostPoint=n=>{const t=n.getModuleCount();let e=0;for(let o=0;o<t;o+=1)for(let r=0;r<t;r+=1){let i=0;const c=n.isDark(o,r);for(let e=-1;e<=1;e+=1)if(!(o+e<0||t<=o+e))for(let l=-1;l<=1;l+=1)r+l<0||t<=r+l||0==e&&0==l||c==n.isDark(o+e,r+l)&&(i+=1);i>5&&(e+=3+i-5)}for(let o=0;o<t-1;o+=1)for(let r=0;r<t-1;r+=1){let t=0;n.isDark(o,r)&&(t+=1),n.isDark(o+1,r)&&(t+=1),n.isDark(o,r+1)&&(t+=1),n.isDark(o+1,r+1)&&(t+=1),0!=t&&4!=t||(e+=3)}for(let o=0;o<t;o+=1)for(let r=0;r<t-6;r+=1)n.isDark(o,r)&&!n.isDark(o,r+1)&&n.isDark(o,r+2)&&n.isDark(o,r+3)&&n.isDark(o,r+4)&&!n.isDark(o,r+5)&&n.isDark(o,r+6)&&(e+=40);for(let o=0;o<t;o+=1)for(let r=0;r<t-6;r+=1)n.isDark(r,o)&&!n.isDark(r+1,o)&&n.isDark(r+2,o)&&n.isDark(r+3,o)&&n.isDark(r+4,o)&&!n.isDark(r+5,o)&&n.isDark(r+6,o)&&(e+=40);let o=0;for(let e=0;e<t;e+=1)for(let r=0;r<t;r+=1)n.isDark(r,e)&&(o+=1);return e+=Math.abs(100*o/t/t-50)/5*10,e},o})(),tn=(()=>{const n=new Array(256),t=new Array(256);for(let t=0;t<8;t+=1)n[t]=1<<t;for(let t=8;t<256;t+=1)n[t]=n[t-4]^n[t-5]^n[t-6]^n[t-8];for(let e=0;e<255;e+=1)t[n[e]]=e;return{glog(n){if(n<1)throw"glog("+n+")";return t[n]},gexp(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return n[t]}}})(),en=(n,t)=>{if(void 0===n.length)throw n.length+"/"+t;const e=(()=>{let e=0;for(;e<n.length&&0==n[e];)e+=1;const o=new Array(n.length-e+t);for(let t=0;t<n.length-e;t+=1)o[t]=n[t+e];return o})(),o={getAt:n=>e[n],getLength:()=>e.length,multiply(n){const t=new Array(o.getLength()+n.getLength()-1);for(let e=0;e<o.getLength();e+=1)for(let r=0;r<n.getLength();r+=1)t[e+r]^=tn.gexp(tn.glog(o.getAt(e))+tn.glog(n.getAt(r)));return en(t,0)},mod(n){if(o.getLength()-n.getLength()<0)return o;const t=tn.glog(o.getAt(0))-tn.glog(n.getAt(0)),e=new Array(o.getLength());for(let n=0;n<o.getLength();n+=1)e[n]=o.getAt(n);for(let o=0;o<n.getLength();o+=1)e[o]^=tn.gexp(tn.glog(n.getAt(o))+t);return en(e,0).mod(n)}};return o},on=(()=>{const n=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=(n,t)=>{const e={};return e.totalCount=n,e.dataCount=t,e};return{getRSBlocks(e,o){const r=((t,e)=>{switch(e){case X.L:return n[4*(t-1)+0];case X.M:return n[4*(t-1)+1];case X.Q:return n[4*(t-1)+2];case X.H:return n[4*(t-1)+3];default:return}})(e,o);if(void 0===r)throw"bad rs block @ typeNumber:"+e+"/errorCorrectionLevel:"+o;const i=r.length/3,c=[];for(let n=0;n<i;n+=1){const e=r[3*n+0],o=r[3*n+1],i=r[3*n+2];for(let n=0;n<e;n+=1)c.push(t(o,i))}return c}}})(),rn=()=>{const n=[];let t=0;const e={getBuffer:()=>n,getAt(t){const e=Math.floor(t/8);return 1==(n[e]>>>7-t%8&1)},put(n,t){for(let o=0;o<t;o+=1)e.putBit(1==(n>>>t-o-1&1))},getLengthInBits:()=>t,putBit(e){const o=Math.floor(t/8);n.length<=o&&n.push(0),e&&(n[o]|=128>>>t%8),t+=1}};return e},cn=n=>{const t=n,e={getMode:()=>1,getLength:n=>t.length,write(n){const e=t;let r=0;for(;r+2<e.length;)n.put(o(e.substring(r,r+3)),10),r+=3;r<e.length&&(e.length-r==1?n.put(o(e.substring(r,r+1)),4):e.length-r==2&&n.put(o(e.substring(r,r+2)),7))}},o=n=>{let t=0;for(let e=0;e<n.length;e+=1)t=10*t+r(n.charAt(e));return t},r=n=>{if("0"<=n&&n<="9")return n.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+n};return e},ln=n=>{const t=n,e={getMode:()=>2,getLength:n=>t.length,write(n){const e=t;let r=0;for(;r+1<e.length;)n.put(45*o(e.charAt(r))+o(e.charAt(r+1)),11),r+=2;r<e.length&&n.put(o(e.charAt(r)),6)}},o=n=>{if("0"<=n&&n<="9")return n.charCodeAt(0)-"0".charCodeAt(0);if("A"<=n&&n<="Z")return n.charCodeAt(0)-"A".charCodeAt(0)+10;switch(n){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+n}};return e},an=n=>{const t=Q.stringToBytes(n);return{getMode:()=>4,getLength:n=>t.length,write(n){for(let e=0;e<t.length;e+=1)n.put(t[e],8)}}},un=n=>{const t=Q.stringToBytes;(()=>{const n=t("友");if(2!=n.length||38726!=(n[0]<<8|n[1]))throw"sjis not supported."})();const e=t(n),o={getMode:()=>8,getLength:n=>~~(e.length/2),write(n){const t=e;let o=0;for(;o+1<t.length;){let e=(255&t[o])<<8|255&t[o+1];if(33088<=e&&e<=40956)e-=33088;else{if(!(57408<=e&&e<=60351))throw"illegal char at "+(o+1)+"/"+e;e-=49472}e=192*(e>>>8&255)+(255&e),n.put(e,13),o+=2}if(o<t.length)throw"illegal char at "+(o+1)}};return o},sn=()=>{const n=[],t={writeByte(t){n.push(255&t)},writeShort(n){t.writeByte(n),t.writeByte(n>>>8)},writeBytes(n,e,o){e=e||0,o=o||n.length;for(let r=0;r<o;r+=1)t.writeByte(n[r+e])},writeString(n){for(let e=0;e<n.length;e+=1)t.writeByte(n.charCodeAt(e))},toByteArray:()=>n,toString(){let t="";t+="[";for(let e=0;e<n.length;e+=1)e>0&&(t+=","),t+=n[e];return t+="]",t}};return t},dn=n=>{const t=n;let e=0,o=0,r=0;const i={read(){for(;r<8;){if(e>=t.length){if(0==r)return-1;throw"unexpected end of file./"+r}const n=t.charAt(e);if(e+=1,"="==n)return r=0,-1;n.match(/^\s$/)||(o=o<<6|c(n.charCodeAt(0)),r+=6)}const n=o>>>r-8&255;return r-=8,n}},c=n=>{if(65<=n&&n<=90)return n-65;if(97<=n&&n<=122)return n-97+26;if(48<=n&&n<=57)return n-48+52;if(43==n)return 62;if(47==n)return 63;throw"c:"+n};return i},fn=(n,t,e)=>{const o=((n,t)=>{const e=n,o=t,r=new Array(n*t),i={setPixel(n,t,o){r[t*e+n]=o},write(n){n.writeString("GIF87a"),n.writeShort(e),n.writeShort(o),n.writeByte(128),n.writeByte(0),n.writeByte(0),n.writeByte(0),n.writeByte(0),n.writeByte(0),n.writeByte(255),n.writeByte(255),n.writeByte(255),n.writeString(","),n.writeShort(0),n.writeShort(0),n.writeShort(e),n.writeShort(o),n.writeByte(0);const t=c(2);n.writeByte(2);let r=0;for(;t.length-r>255;)n.writeByte(255),n.writeBytes(t,r,255),r+=255;n.writeByte(t.length-r),n.writeBytes(t,r,t.length-r),n.writeByte(0),n.writeString(";")}},c=n=>{const t=1<<n,e=1+(1<<n);let o=n+1;const i=l();for(let n=0;n<t;n+=1)i.add(String.fromCharCode(n));i.add(String.fromCharCode(t)),i.add(String.fromCharCode(e));const c=sn(),a=(n=>{const t=n;let e=0,o=0;return{write(n,r){if(n>>>r!=0)throw"length over";for(;e+r>=8;)t.writeByte(255&(n<<e|o)),r-=8-e,n>>>=8-e,o=0,e=0;o|=n<<e,e+=r},flush(){e>0&&t.writeByte(o)}}})(c);a.write(t,o);let u=0,s=String.fromCharCode(r[u]);for(u+=1;u<r.length;){const n=String.fromCharCode(r[u]);u+=1,i.contains(s+n)?s+=n:(a.write(i.indexOf(s),o),i.size()<4095&&(i.size()==1<<o&&(o+=1),i.add(s+n)),s=n)}return a.write(i.indexOf(s),o),a.write(e,o),a.flush(),c.toByteArray()},l=()=>{const n={};let t=0;const e={add(o){if(e.contains(o))throw"dup key:"+o;n[o]=t,t+=1},size(){return t},indexOf(t){return n[t]},contains(t){return void 0!==n[t]}};return e};return i})(n,t);for(let r=0;r<t;r+=1)for(let t=0;t<n;t+=1)o.setPixel(t,r,e(t,r));const r=sn();o.write(r);const i=(()=>{let n=0,t=0,e=0,o="";const r={},i=n=>{o+=String.fromCharCode(c(63&n))},c=n=>{if(n<0)throw"n:"+n;if(n<26)return 65+n;if(n<52)return n-26+97;if(n<62)return n-52+48;if(62==n)return 43;if(63==n)return 47;throw"n:"+n};return r.writeByte=o=>{for(n=n<<8|255&o,t+=8,e+=1;t>=6;)i(n>>>t-6),t-=6},r.flush=()=>{if(t>0&&(i(n<<6-t),n=0,t=0),e%3!=0){const n=3-e%3;for(let t=0;t<n;t+=1)o+="="}},r.toString=()=>o,r})(),c=r.toByteArray();for(let n=0;n<c.length;n+=1)i.writeByte(c[n]);return i.flush(),"data:image/gif;base64,"+i},pn="undefined"!=typeof window&&"undefined"!=typeof document;function hn(n){if(!pn)return null;try{const t=document.cookie;if(!t)return null;const e=encodeURIComponent(n),o=t.split(";");for(let t=0;t<o.length;t++){const r=o[t].indexOf("=");if(r<0)continue;const i=o[t].slice(0,r).trim();if(i===e||i===n)try{return decodeURIComponent(o[t].slice(r+1))}catch(n){return o[t].slice(r+1)}}return null}catch(n){return null}}function vn(n,t,e={}){var o,r,i;if(!pn)return!1;try{let c=`${encodeURIComponent(n)}=${encodeURIComponent(t)}`;if(c+=`; path=${null!==(o=e.path)&&void 0!==o?o:"/"}`,e.domain&&(c+=`; domain=${e.domain}`),"number"==typeof e.maxAgeDays){const n=Math.floor(86400*e.maxAgeDays);c+=`; max-age=${n}`,c+=`; expires=${new Date(Date.now()+1e3*n).toUTCString()}`}return c+=`; SameSite=${null!==(r=e.sameSite)&&void 0!==r?r:"Lax"}`,(null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol)&&(c+="; Secure"),document.cookie=c,hn(n)===t}catch(n){return!1}}function mn(){if(!pn)return!1;try{const n="__cnv_probe__";return localStorage.setItem(n,"1"),localStorage.removeItem(n),!0}catch(n){return!1}}function gn(n){if(!mn())return null;try{return localStorage.getItem(n)}catch(n){return null}}function bn(n,t){if(!mn())return!1;try{return localStorage.setItem(n,t),!0}catch(n){return!1}}function yn(n){if(!mn())return!1;try{return localStorage.removeItem(n),!0}catch(n){return!1}}function _n(){if(!pn)return!1;try{const n="__cnv_probe__";return sessionStorage.setItem(n,"1"),sessionStorage.removeItem(n),!0}catch(n){return!1}}const wn="0123456789abcdef";function xn(n){return wn[n>>>4&15]+wn[15&n]}function kn(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues){const n=new Uint8Array(16);return crypto.getRandomValues(n),n[6]=15&n[6]|64,n[8]=63&n[8]|128,xn(n[0])+xn(n[1])+xn(n[2])+xn(n[3])+"-"+xn(n[4])+xn(n[5])+"-"+xn(n[6])+xn(n[7])+"-"+xn(n[8])+xn(n[9])+"-"+xn(n[10])+xn(n[11])+xn(n[12])+xn(n[13])+xn(n[14])+xn(n[15])}}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const t=16*Math.random()|0;return("x"===n?t:3&t|8).toString(16)})}const An=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Cn(n){return"string"==typeof n&&An.test(n)}const Mn=8e3,On=3e4,Sn=/^(https:|zalo:)/i;class In extends Error{constructor(n){super(`loginWithZalo() thất bại: ${n}`),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:n}),this.name="ZaloQrLoginError"}}function En(n,t,e,o){return`${n}${t}?${new URLSearchParams(Object.assign({projectId:e},o)).toString()}`}function Nn(n,t){if(!n||!t)return()=>{};if(t.aborted)return n.abort(),()=>{};const e=()=>n.abort();return t.addEventListener("abort",e),()=>t.removeEventListener("abort",e)}function zn(n){return{title:"string"==typeof n.title?n.title:void 0,description:"string"==typeof n.description?n.description:void 0,points:jn(n.points),expPoints:jn(n.expPoints),balanceAfter:jn(n.balanceAfter),expBalanceAfter:jn(n.expBalanceAfter),rankAfter:"string"==typeof n.rankAfter?n.rankAfter:void 0,createdAt:"string"==typeof n.createdAt?n.createdAt:void 0}}function Tn(n){return{campaignId:jn(n.campaignId),rewardId:jn(n.rewardId),title:"string"==typeof n.title?n.title:void 0,imageUrl:"string"==typeof n.imageUrl?n.imageUrl:void 0,discountValue:"string"==typeof n.discountValue?n.discountValue:void 0,redeemPoints:jn(n.redeemPoints),redeemRemain:jn(n.redeemRemain),expiredAt:"string"==typeof n.expiredAt?n.expiredAt:void 0,stock:"boolean"==typeof n.stock?n.stock:void 0,burnOnUse:!0===n.burnOnUse}}function Dn(n,t){return n?"string"==typeof n.error&&n.error?n.error:t&&"string"==typeof n.code&&n.code?n.code:null:null}function jn(n){return"number"==typeof n&&Number.isFinite(n)?n:void 0}function Rn(n){return{id:jn(n.id),name:"string"==typeof n.name?n.name:void 0,iconUrl:"string"==typeof n.iconUrl?n.iconUrl:void 0,colorCode:"string"==typeof n.colorCode?n.colorCode:void 0,threshold:jn(n.threshold),level:jn(n.level),benefits:Array.isArray(n.benefits)?n.benefits.filter(n=>"string"==typeof n&&""!==n.trim()):[]}}function Bn(n){return{id:jn(n.id),name:"string"==typeof n.name?n.name:void 0,iconUrl:"string"==typeof n.iconUrl?n.iconUrl:void 0,colorCode:"string"==typeof n.colorCode?n.colorCode:void 0,level:jn(n.level),progressCurrent:jn(n.progressCurrent),progressTarget:jn(n.progressTarget),remaining:jn(n.remaining),nextLevelName:"string"==typeof n.nextLevelName?n.nextLevelName:void 0,isHighestLevel:!0===n.isHighestLevel}}function Fn(n){return{title:"string"==typeof n.title?n.title:void 0,imageUrl:"string"==typeof n.imageUrl?n.imageUrl:void 0,code:"string"==typeof n.code?n.code:void 0,discountValue:"string"==typeof n.discountValue?n.discountValue:void 0,channelLabel:"string"==typeof n.channelLabel?n.channelLabel:void 0,expiredAt:"string"==typeof n.expiredAt?n.expiredAt:void 0,useRemain:"number"==typeof n.useRemain&&Number.isFinite(n.useRemain)?n.useRemain:void 0,redeemId:"number"==typeof n.redeemId&&Number.isFinite(n.redeemId)?n.redeemId:void 0,usedAt:"string"==typeof n.usedAt?n.usedAt:void 0,canUse:!0===n.canUse,burnOnUse:!0===n.burnOnUse}}function Ln(n,t){return J(this,void 0,void 0,function*(){var e,o,r;if(!n.projectId||!n.endpoint)throw new In("not-initialized");if(!n.zaloQrLoginEnabled)throw new In("disabled");if(!n.consentGranted)throw new In("consent-required");const i={preferSse:null===(e=null==t?void 0:t.preferSse)||void 0===e||e,pollIntervalMs:null!==(o=null==t?void 0:t.pollIntervalMs)&&void 0!==o?o:2e3,autoIdentify:null===(r=null==t?void 0:t.autoIdentify)||void 0===r||r},c=n.projectId,l=n.endpoint,a=(()=>{const n="undefined"!=typeof crypto?crypto:void 0;if(n&&"function"==typeof n.getRandomValues)try{const t=new Uint8Array(24);n.getRandomValues(t);let e="";for(let n=0;n<t.length;n+=1)e+=String.fromCharCode(t[n]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(n){return}})(),u=yield function(n,t,e){return J(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Mn):null;let i;try{i=yield fetch(En(n,"/zalo-qr/session",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:o?o.signal:void 0})}catch(n){throw new In("network")}finally{r&&clearTimeout(r)}if(!i.ok)throw new In(401===(c=i.status)?"invalid-project-key":403===c?"project-suspended":"network");var c;return(n=>{const t=n;if(!t||"string"!=typeof t.sessionToken||!t.sessionToken||"string"!=typeof t.miniAppDeepLink||!Sn.test(t.miniAppDeepLink)||"number"!=typeof t.expiresInSeconds||!Number.isFinite(t.expiresInSeconds)||t.expiresInSeconds<=0)throw new In("network");return{sessionToken:t.sessionToken,miniAppDeepLink:t.miniAppDeepLink,expiresInSeconds:t.expiresInSeconds}})(yield i.json())})}(l,c,Object.assign(Object.assign({},(n=>{var t,e,o;const r={};try{const i=null===(t=n.getAnonymousId)||void 0===t?void 0:t.call(n);i&&(r.anonymousId=i);const c=null===(e=n.getSessionId)||void 0===e?void 0:e.call(n);c&&(r.sessionId=c);const l=null===(o=n.getAttribution)||void 0===o?void 0:o.call(n);l&&(r.attribution=l)}catch(n){}return r})(n)),a?{pollSecret:a}:{})),s=((n,t,e,o,r,i)=>{let c=!1,l=null,a=null,u=null,s=null,d=null;const f=()=>{l&&(l.close(),l=null),null!==a&&(clearInterval(a),a=null),null!==u&&(clearTimeout(u),u=null),null!==s&&(clearTimeout(s),s=null)};return{promise:new Promise((p,h)=>{d=h;const v=n=>{c||(c=!0,f(),n())},m=n=>{"success"===n.status?v(()=>p((n=>({contactId:n.contactId,fullName:n.fullName,level:n.level,xp:n.xp,panelSessionToken:n.panelSessionToken,panelSessionExp:n.panelSessionExp,panelSessionExpiresInMs:"number"==typeof n.panelSessionExpiresInMs?n.panelSessionExpiresInMs:void 0}))(n))):"denied"===n.status?v(()=>h(new In("denied"))):"expired"===n.status&&v(()=>h(new In("expired")))},g=()=>{null!==a||c||(a=setInterval(()=>{fetch(En(n,"/zalo-qr/status",t,{sessionToken:e}),{method:"GET",credentials:"omit",mode:"cors",headers:i?{"X-Poll-Secret":i}:void 0}).then(n=>404===n.status?m({status:"expired"}):n.ok?n.json().then(n=>m(n)):void 0).catch(()=>{})},r.pollIntervalMs))};if(r.preferSse&&"undefined"!=typeof EventSource)try{l=new EventSource(En(n,"/zalo-qr/stream",t,i?{sessionToken:e,pollSecret:i}:{sessionToken:e})),l.addEventListener("success",n=>{try{m(JSON.parse(n.data))}catch(n){}}),l.addEventListener("denied",()=>m({status:"denied"})),l.onerror=()=>{null!==s||c||(s=setTimeout(()=>{s=null,c||(l&&(l.close(),l=null),g())},3e3))}}catch(n){g()}else g();u=setTimeout(()=>{v(()=>h(new In("expired")))},1e3*o)}),cancel(){c||(c=!0,f(),null==d||d(new In("cancelled")))}}})(l,c,u.sessionToken,u.expiresInSeconds,i,a),d=s.promise.then(t=>{try{if(i.autoIdentify&&null!=t.contactId){const e=String(t.contactId),o=n.getUserId();null!=o&&o!==e?n.alias(e,o):n.identify(e,Object.assign(Object.assign(Object.assign({},t.fullName?{name:t.fullName}:{}),t.level?{level:t.level}:{}),null!=t.xp?{xp:t.xp}:{}))}}catch(n){}return t});return{sessionToken:u.sessionToken,qrPayload:u.miniAppDeepLink,expiresInSeconds:u.expiresInSeconds,result:d,cancel:s.cancel,retry(){return s.cancel(),Ln(n,t)}}})}const Pn="cnv:launcher:click",$n="cnv:panel:identify",Un="cnv-panel-card--leaving";function Vn(n){return"cnv_panel_session_"+(null!=n?n:"default")}function Hn(n){const e=gn(Vn(n));return e?t(()=>{const n=JSON.parse(e);return n&&"string"==typeof n.token&&n.token&&"number"==typeof n.contactId&&"number"==typeof n.exp?n:null},null):null}function Kn(n,t){bn(Vn(n),JSON.stringify(t))}function qn(n){yn(Vn(n))}function Gn(n){return"SQUARE"===n?"0px":"12px"}function Zn(n){const t=n.colors;return L(null==t?void 0:t.iconColor,L(null==t?void 0:t.buttonBg,L(null==t?void 0:t.bannerBg,R)))}function Wn(n,t){n.style.background=V(t,.12),n.style.color=t}const Yn='<path d="M20 12v9H4v-9M2 7h20v5H2V7Zm10 0V4a2.5 2.5 0 0 0-5 0v3h5Zm0 0V4a2.5 2.5 0 0 1 5 0v3h-5Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/>',Jn='<path d="M9 6l6 6-6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',Qn='<path d="M12 2.5l2.9 6.3 6.9.8-5.1 4.7 1.4 6.8L12 17.8 5.9 21.1l1.4-6.8-5.1-4.7 6.9-.8L12 2.5Z" fill="currentColor"/>',Xn='<circle cx="9" cy="8" r="3.2" stroke="currentColor" stroke-width="1.8"/><path d="M2.5 20c0-3.6 2.9-6 6.5-6s6.5 2.4 6.5 6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>',nt='<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.8"/><path d="M12 7v5l3.5 2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>',tt='<path d="M5 13l4.5 4.5L19 8" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/>',et='<circle cx="11" cy="4.6" r="2.3" fill="currentColor"/><rect x="2.2" y="10" width="3" height="6.4" rx="1.5" fill="currentColor"/><path d="M7.4 12.2c2 0 3.4.6 4.6 1.8h2.2a1.6 1.6 0 1 1 0 3.2h-3.4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><path d="M7.4 12.2v7c3.2 1.2 6.2.5 9-2l3.2-2.9a1.7 1.7 0 0 0-2.2-2.6l-3 2.3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>',ot="#1E9E5B",rt="rgba(30, 158, 91, 0.12)",it="#D64545",ct="rgba(214, 69, 69, 0.10)",lt="#6B7280",at="rgba(107, 114, 128, 0.12)";function ut(n,t,e){const o=document.createElement("span");return o.className=e?"cnv-panel-icon "+e:"cnv-panel-icon",o.innerHTML=`<svg viewBox="0 0 24 24" fill="none" width="${t}" height="${t}">${n}</svg>`,o}function st(n,t){const e=document.createElement("div");return e.className="cnv-panel-chip",Wn(e,t),e.appendChild(ut(n,14)),e}function dt(n,t){const e=document.createElement("span");return e.className="cnv-panel-badge",Wn(e,t),e.textContent=n,e}const ft={POINTS:{label:"Điểm thưởng",icon:Qn},REFERRAL:{label:"Giới thiệu bạn bè",icon:Xn},VIP:{label:"Hạng thành viên (VIP)",icon:'<path d="M3 8l3.2 3 3.6-5.4L12 3l2.2 2.6L17.8 11 21 8l-1.6 10H4.6L3 8Z" fill="currentColor"/>'}},pt={rewards:'<path d="M3 9V6.4c0-.8.6-1.4 1.4-1.4h15.2c.8 0 1.4.6 1.4 1.4V9a3 3 0 0 0 0 6v2.6c0 .8-.6 1.4-1.4 1.4H4.4c-.8 0-1.4-.6-1.4-1.4V15a3 3 0 0 0 0-6Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M14.6 5.6v12.8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-dasharray="2.2 2.6"/>',earn:et,redeem:Yn,history:nt},ht={ORDER:'<path d="M4.4 8h15.2l-1.1 12.3H5.5L4.4 8Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M8.7 8V6.3a3.3 3.3 0 0 1 6.6 0V8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>',STAR:Qn,GIFT:Yn,USERS:Xn,CAKE:'<path d="M3.6 20.6h16.8v-5.1c0-1-.8-1.9-1.9-1.9H5.5c-1 0-1.9.8-1.9 1.9v5.1Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M12 13.6V9.7" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><circle cx="12" cy="7.5" r="1.8" fill="currentColor"/>',SHARE:'<circle cx="17.8" cy="5.6" r="2.6" stroke="currentColor" stroke-width="1.8"/><circle cx="6.2" cy="12" r="2.6" stroke="currentColor" stroke-width="1.8"/><circle cx="17.8" cy="18.4" r="2.6" stroke="currentColor" stroke-width="1.8"/><path d="M15.5 6.9 8.5 10.7M8.5 13.3l7 3.8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>',COIN:et,CHECK:tt},vt={earn:{label:"Cách kiếm thêm điểm",icon:et},redeem:{label:"Cách đổi điểm",icon:Yn}},mt="cnv-panel-reward__title--full",gt="Tham gia ngay",bt=[[vt.earn.label,"earn"],[vt.redeem.label,"redeem"]],yt=/\{\{\s*TenKhachHang\s*\}\}/gi,_t=/[\u0000-\u001F\u007F\u200B\u200E\u200F\u2028\u2029\u202A-\u202E\u2066-\u2069\uFEFF]/g;function wt(n){return"number"==typeof n.campaignId&&n.campaignId>0?Object.assign({campaignId:n.campaignId},"number"==typeof n.redeemPoints&&n.redeemPoints>0?{redeemPoints:n.redeemPoints}:{}):"number"==typeof n.rewardId&&n.rewardId>0?{rewardId:n.rewardId}:null}function xt(n,e){const o=(n=>{if("string"!=typeof n)return"bạn";const e=t(()=>n.normalize("NFC"),n).replace(_t," ").replace(/\s+/g," ").trim();if(!e)return"bạn";const o=Array.from(e);return o.length<=24?e:o.slice(0,24).join("").trimEnd()+"…"})(e);return(n||"").replace(yt,()=>o)}const kt=[{key:"owned",label:"Ưu đãi của bạn"},{key:"redeem",label:"Đổi ưu đãi"}],At={message:'Lượt đổi đã được ghi nhận nhưng mã chưa phát kịp. Bạn mở tab "Ưu đãi của bạn" rồi bấm "Sử dụng" để lấy mã nhé.',action:"owned",heading:"Ưu đãi đã là của bạn",tone:"neutral"},Ct={message:'Điểm đã được trừ và ưu đãi đã là của bạn, chỉ chưa có mã. Bạn mở tab "Ưu đãi của bạn" rồi bấm "Sử dụng" để lấy mã nhé.',action:"owned",heading:"Ưu đãi đã là của bạn",tone:"neutral"},Mt={INSUFFICIENT_POINTS:{message:"Bạn không đủ điểm để đổi ưu đãi này.",action:"other"},REDEMPTION_LIMIT_EXCEEDED:{message:"Bạn đã đổi ưu đãi này đủ số lượt cho phép.",action:"other"},REWARD_OUT_OF_STOCK:{message:"Ưu đãi này vừa hết. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_EXPIRED:{message:"Ưu đãi này đã hết hạn.",action:"other"},PRICE_CHANGED:{message:"Giá đổi của ưu đãi vừa thay đổi. Bạn tải lại danh sách rồi đổi lại nhé.",action:"other"},POINT_HOLD_FAILED:{message:"Chưa trừ được điểm của bạn. Bạn thử lại nhé.",action:"retry",retryWithNewKey:!0},POINT_REFUNDED:{message:"Đổi ưu đãi không thành công, điểm của bạn đã được hoàn lại. Bạn thử lại nhé.",action:"retry",retryWithNewKey:!0},POINT_STUCK:{message:"Đổi ưu đãi không thành công. Điểm của bạn đang được kiểm tra, bạn liên hệ shop nhé.",action:"none"},CAMPAIGN_NOT_STARTED:{message:"Ưu đãi chưa tới thời gian áp dụng. Bạn quay lại sau nhé.",action:"other"},REWARD_NOT_PUBLISHED:{message:"Ưu đãi chưa được mở. Bạn quay lại sau nhé.",action:"other"},NOT_POINT_CAMPAIGN:{message:"Ưu đãi này không đổi bằng điểm. Bạn tải lại danh sách nhé.",action:"other"},REDEEM_IN_PROGRESS:{message:'Lượt đổi của bạn đang được xử lý. Bạn đợi một chút rồi kiểm tra ở tab "Ưu đãi của bạn" nhé.',action:"owned"},IDEMPOTENCY_UNAVAILABLE:{message:"Hệ thống đang bận, chưa đổi được. Bạn thử lại sau ít phút nhé.",action:"other"},CAMPAIGN_NOT_FOUND:{message:"Không tìm thấy ưu đãi này. Bạn tải lại danh sách nhé.",action:"other"},CAMPAIGN_INACTIVE:{message:"Ưu đãi này vừa được shop tạm dừng.",action:"other"},CAMPAIGN_EXPIRED:{message:"Ưu đãi này đã hết hạn.",action:"other"},INVALID_CAMPAIGN:{message:"Ưu đãi này đang thiếu thông tin cấu hình. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_NO_DISCOUNT:{message:"Ưu đãi này chưa sẵn sàng. Bạn chọn ưu đãi khác nhé.",action:"other"},OUT_OF_CODES:{message:"Ưu đãi này đã hết mã. Bạn chọn ưu đãi khác nhé.",action:"other"},DISCOUNT_UNAVAILABLE:{message:"Ưu đãi này không còn dùng được. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_UNAVAILABLE:{message:"Ưu đãi này hiện không khả dụng.",action:"other"},NOT_SELF_REDEEMABLE:{message:"Ưu đãi này không tự đổi được. Bạn liên hệ shop nhé.",action:"other"},NOT_FREE:{message:"Ưu đãi này không phải ưu đãi tặng. Bạn tải lại danh sách nhé.",action:"other"},REDEEM_LIMIT_REACHED:{message:"Bạn đã đổi ưu đãi này đủ số lượt cho phép.",action:"other"},ALREADY_REDEEMED:{message:'Bạn đã nhận ưu đãi này rồi. Mã nằm ở tab "Ưu đãi của bạn".',action:"owned"},CODE_NOT_ISSUED:{message:"Đã ghi nhận lượt đổi nhưng mã chưa phát kịp. Bạn thử lại nhé.",action:"retry"},NOT_REDEEMED:{message:"Bạn chưa đổi ưu đãi này.",action:"other"},LOYALTY_SERVICE_UNAVAILABLE:{message:"Hệ thống điểm đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},VENDOR_ERROR:{message:"Nhà cung cấp ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},MISSING_VOUCHER:At,MISSING_SERIAL:At,INVALID_REQUEST:{message:"Ưu đãi này đang lỗi dữ liệu nên không đổi được. Bạn chọn ưu đãi khác nhé.",action:"other"},INVALID_TENANT:{message:"Chương trình ưu đãi của shop đang lỗi cấu hình. Bạn liên hệ shop nhé.",action:"none"},REDEEM_FAILED:{message:"Đổi ưu đãi không thành công. Bạn thử lại sau ít phút nhé.",action:"retry"},SERVICE_UNAVAILABLE:{message:"Hệ thống ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry",retryWithNewKey:!0},SESSION_CHECK_UNAVAILABLE:{message:"Chưa kiểm tra được phiên đăng nhập của bạn. Bạn thử lại sau ít phút nhé.",action:"retry"},invalid_session:{message:"Phiên đăng nhập đã hết. Bạn đăng nhập lại nhé.",action:"none"},UNCONFIRMED:{message:'Chưa xác nhận được kết quả. Điểm có thể đã được trừ — bạn kiểm tra ở tab "Ưu đãi của bạn" trước khi đổi lại nhé.',action:"owned",heading:"Chưa xác nhận được",tone:"neutral"}},Ot={CODE_NOT_ISSUED:Ct,MISSING_VOUCHER:Ct,MISSING_SERIAL:Ct,OUT_OF_CODES:{message:"Ưu đãi đã hết mã, điểm của bạn đã bị trừ. Bạn liên hệ shop để được hỗ trợ nhé.",action:"none"}},St={message:"Không đổi được ưu đãi lúc này. Bạn thử lại sau nhé.",action:"retry"},It={USE_LIMIT_REACHED:{message:"Ưu đãi này đã hết lượt sử dụng.",action:"back"},NOT_REDEEMED:{message:"Ưu đãi này không còn trong danh sách của bạn.",action:"back"},CAMPAIGN_NOT_FOUND:{message:"Không tìm thấy ưu đãi này nữa.",action:"back"},CODE_NOT_ISSUED:{message:"Chưa lấy được mã cho ưu đãi này. Bạn thử lại nhé.",action:"retry"},OUT_OF_CODES:{message:"Ưu đãi này đã hết mã. Bạn liên hệ shop nhé.",action:"back"},DISCOUNT_UNAVAILABLE:{message:"Ưu đãi này không còn dùng được. Bạn liên hệ shop nhé.",action:"back"},REWARD_NO_DISCOUNT:{message:"Ưu đãi này chưa sẵn sàng để lấy mã. Bạn liên hệ shop nhé.",action:"back"},INVALID_CAMPAIGN:{message:"Ưu đãi này đang thiếu thông tin cấu hình. Bạn liên hệ shop nhé.",action:"back"},UNCONFIRMED:{message:"Chưa xác nhận được. Bạn thử lại nhé.",action:"retry"},SERVICE_UNAVAILABLE:{message:"Hệ thống ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},SESSION_CHECK_UNAVAILABLE:{message:"Hệ thống đang bận, chưa lấy được mã. Bạn thử lại sau ít phút nhé.",action:"retry"},USE_FAILED:{message:"Chưa dùng được ưu đãi này. Bạn thử lại sau ít phút nhé.",action:"retry"},INVALID_REQUEST:{message:"Yêu cầu không hợp lệ. Bạn quay lại danh sách rồi thử lại nhé.",action:"back"},INVALID_REWARD:{message:"Không xác định được ưu đãi cần dùng. Bạn quay lại danh sách nhé.",action:"back"},INVALID_TENANT:{message:"Chương trình ưu đãi của shop đang lỗi cấu hình. Bạn liên hệ shop nhé.",action:"back"},invalid_session:{message:"Phiên đăng nhập đã hết. Bạn đăng nhập lại nhé.",action:"back"}},Et={message:"Chưa lấy được mã lúc này. Bạn thử lại sau nhé.",action:"retry"},Nt={other:"Chọn ưu đãi khác",retry:"Thử lại",owned:"Kiểm tra ưu đãi của bạn",none:""};function zt(n,t){var e;const o=document.createElement("div");var r,i;return o.className=t?"cnv-panel-card__section "+t:"cnv-panel-card__section",o.style.borderRadius=Gn(null===(e=n.shapes)||void 0===e?void 0:e.card),(r=o).style.backgroundColor="DARK"===(i=n.theme)?"#3F4254":"#FFFFFF",r.style.boxShadow="DARK"===i?"none":"0 2px 4px rgba(15, 42, 81, 0.04)",o}function Tt(n,t){const e=document.createElement("div");return e.className="cnv-panel-zalo__skeleton",e.style.width=n+"px",e.style.height=t+"px",e}function Dt(n,t){const e=document.createElement("div");e.className="cnv-panel-zalo__corner tl",e.style.borderColor=t;const o=document.createElement("div");o.className="cnv-panel-zalo__corner br",o.style.borderColor=t,n.append(e,o)}function jt(n){const t=document.createElement("div");t.className="cnv-panel-vstack";const e=document.createElement("div");e.className="cnv-panel-zalo__qr",e.appendChild(Tt(180,180)),Dt(e,n),t.appendChild(e);const o=document.createElement("div");return o.className="cnv-panel-vstack",o.style.gap="6px",o.append(Tt(240,14),Tt(160,14)),t.appendChild(o),t.appendChild(Tt(120,14)),t}function Rt(n,t,e,o){const r=document.createElement("div");r.className="cnv-panel-zalo__overlay-bubble";const i=document.createElement("div");i.className="cnv-panel-bubble-icon",i.style.background=e,i.style.color=t,i.appendChild(ut(n,20));const c=document.createElement("div");return c.className="cnv-panel-zalo__title",c.textContent=o,r.append(i,c),r}function Bt(n,t,e){let o=n,r=null;const i=()=>{null!==r&&(clearInterval(r),r=null)};return!0===t(o)||(r=setInterval(()=>{o-=1,(!0===t(o)||o<=0)&&(i(),e&&e())},1e3)),i}function Ft(n){if(!n)return null;const t=Date.parse(n);if(!Number.isFinite(t))return null;const e=new Date(t),o=n=>String(n).padStart(2,"0");return`${o(e.getDate())}/${o(e.getMonth()+1)}/${e.getFullYear()}`}function Lt(n){return n instanceof In?n.reason:null}function Pt(n){switch(Lt(n)){case"disabled":return"Đăng nhập bằng Zalo hiện đang tắt.";case"consent-required":return"Cần đồng ý thu thập dữ liệu để đăng nhập bằng Zalo.";case"expired":return"Mã QR đã hết hạn.";case"denied":return"Đăng nhập đã bị từ chối.";case"cancelled":return"Đã huỷ đăng nhập.";default:return"Vui lòng thử lại giúp mình nhé."}}function $t(o,r){if("undefined"==typeof document||"undefined"==typeof window)return()=>{};try{let i,c,l,a=null,u=null,s=null,d=null,f=null,p=null,h=null,v=null,m=null,g=null,b=null,y=!1,_=null,w=null,x=!1,k=!1,A=!1,C=[],M=0,O=!1,S=null,I=null,E=null,N=!1,z=0,T=[],D=0,U=null,G=!1,Z=!1,W=kt[0].key,Y=[],X=0,nn=0,tn=!1,en=null,on=null,rn=!1,cn=0,ln=null,an=null;function un(t){const e="owned"===t?ln:an;e&&("owned"===t?ln=null:an=null,n(()=>e.abort()))}function sn(){return"undefined"!=typeof AbortController?new AbortController:null}let dn=null,fn=!1,pn=null,hn=0,vn=0,mn=0,gn=null,bn=null,yn=null;const _n=n=>{"Escape"===n.key&&We()};function wn(n){return!x||n!==vn}function xn(n,e){return t(()=>{const t=new CustomEvent(n,{detail:{action:e},cancelable:!0});return window.dispatchEvent(t),t.defaultPrevented},!1)}function An(n){xn("cnv:panel:cta-click",n)}function Cn(n){return()=>{y&&n()}}function Mn(n,t,e){const o=document.createElement("div");o.className="cnv-panel-section__row",e&&(o.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2");const i=pt[t];if(i){const n=ut(i,20);n.style.color=Zn(r),o.appendChild(n)}const c=document.createElement("span");return c.className="cnv-panel-section__row-label",c.textContent=n,o.appendChild(c),o.appendChild(ut(Jn,12,"cnv-panel-icon--chevron")),o.addEventListener("click",Cn(()=>{xn("cnv:panel:menu-click",t)||("rewards"===t?(k=!0,W=kt[0].key,dn=null,De(),ie(),Rn()):"history"===t?(A=!0,De(),se(),C.length||(M=0,ue())):vt[t]&&(S=t,De(),me()))})),o}function On(){var n,t,e,o;const i=zt(r,"cnv-panel-cta"),c=r.accountCreationCta,l=document.createElement("div");l.className="cnv-panel-cta__title",l.textContent=(null==c?void 0:c.title)||"";const a=document.createElement("div");a.className="cnv-panel-cta__desc",a.textContent=(null==c?void 0:c.description)||"";const u=document.createElement("button");u.type="button",u.className="cnv-panel-cta__btn",u.style.borderRadius=Gn(null===(n=r.shapes)||void 0===n?void 0:n.button),u.style.backgroundColor=L(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,R),u.style.color=L(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,B),u.appendChild(ut(Yn,15)),u.appendChild(document.createTextNode(((null==c?void 0:c.createAccountButtonText)||"").trim()||gt)),u.addEventListener("click",Cn(()=>{An("create-account"),Ke()})),i.append(l,a,u);const s=((null==c?void 0:c.signInLinkText)||"").trim();if(s){const n=document.createElement("div");n.className="cnv-panel-cta__signin",n.style.color=L(null===(o=r.colors)||void 0===o?void 0:o.linkColor,R),n.appendChild(document.createTextNode(s)),n.appendChild(ut(Jn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",Cn(()=>{An("sign-in"),Ke()})),i.appendChild(n)}return i}function Sn(){var n;const t=r.accountCreationCta,e=((null==t?void 0:t.description)||"").trim()||((null==t?void 0:t.title)||"").trim();if(!e)return null;const o="DARK"===r.theme,i=document.createElement("div");return i.className="cnv-panel-card__section cnv-panel-join-hint",i.style.borderRadius=Gn(null===(n=r.shapes)||void 0===n?void 0:n.card),i.style.backgroundColor=o?"#2A2E44":"#F1F1F4",i.style.color=o?"rgba(255,255,255,.72)":"rgba(24,28,50,.66)",i.textContent=e,i}function In(){var n,t,e,o;const i=r.accountCreationCta,c="DARK"===r.theme,l=document.createElement("div");l.className="cnv-panel-joinbar",l.style.backgroundColor=c?"#181C32":"#FFFFFF",l.style.borderTop=c?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2";const a=document.createElement("button");a.type="button",a.className="cnv-panel-cta__btn",a.style.borderRadius=Gn(null===(n=r.shapes)||void 0===n?void 0:n.button),a.style.backgroundColor=L(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,R),a.style.color=L(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,B),a.appendChild(ut(Yn,15)),a.appendChild(document.createTextNode(((null==i?void 0:i.createAccountButtonText)||"").trim()||gt)),a.addEventListener("click",Cn(()=>{An("create-account"),Ke()})),l.appendChild(a);const u=((null==i?void 0:i.signInLinkText)||"").trim();if(u){const n=document.createElement("div");n.className="cnv-panel-cta__signin",n.style.color=L(null===(o=r.colors)||void 0===o?void 0:o.linkColor,R),n.appendChild(document.createTextNode(u)),n.appendChild(ut(Jn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",Cn(()=>{An("sign-in"),Ke()})),l.appendChild(n)}return l}function En(){var n;return null!==(n=null==E?void 0:E.points)&&void 0!==n?n:null==_?void 0:_.points}function Nn(n=!1){if(!(null==_?void 0:_.isMember)||N)return;if(!n&&E&&Date.now()-z<3e4)return;const t=Hn(o.projectId);if(!t)return;N=!0,un("owned");const e=sn();ln=e,y&&Ne(),o.fetchRewardsSummary(t.token,1,e?e.signal:void 0).then(n=>{N=!1,e&&e.signal.aborted||(n?(E=n,z=Date.now(),T=n.rewards.slice(),D=1,y&&Ne()):y&&Ne())}).catch(()=>{N=!1,y&&Ne()})}function zn(){return(Array.isArray(r.sections)?r.sections:[]).some(n=>"VIP"===n.type&&n.enabled)}function Tn(){const n=null==E?void 0:E.rewardsAvailableCount;return"number"==typeof n&&D?Math.max(0,n-T.length):0}function Dn(){if(Z||!Tn())return;const n=Hn(o.projectId);if(!n)return;const t=D+1;Z=!0,k&&ie(),o.fetchRewardsSummary(n.token,t).then(n=>{Z=!1,D=t,n&&(n.rewards.length&&(T=T.concat(n.rewards)),"number"==typeof n.rewardsAvailableCount&&E&&(E=Object.assign(Object.assign({},E),{rewardsAvailableCount:n.rewardsAvailableCount}))),k&&ie()}).catch(()=>{Z=!1,k&&ie()})}function jn(n){if(W===n)return;const t=W;W=n,dn=null,en=null,At(),un(t),De(),ie(),Rn(!0)}function Rn(n=!1){if("redeem"===W){if(!n&&Y.length&&Date.now()-nn<3e4)return;return X=0,Y=[],void Bn()}Nn(n)}function Bn(){if(tn)return;const n=Hn(o.projectId);if(!n)return;const t=X+1;tn=!0,un("redeem");const e=sn();an=e,k&&ie(),o.fetchRedeemableRewards(n.token,t,e?e.signal:void 0).then(n=>{tn=!1,X=t,n&&(1===t&&(nn=Date.now()),"number"==typeof n.total&&(c=n.total),"number"==typeof n.points&&(l=n.points),n.rewards.length&&(Y=Y.concat(n.rewards))),k&&ie()}).catch(()=>{tn=!1,k&&ie()})}function Fn(){return null!=l?l:En()}function Ln(){return null!==Hn(o.projectId)}function Vn(n,t,e){const o=document.createElement("div");o.className="cnv-panel-reward__meta",o.textContent=e,n.appendChild(o);const r=document.createElement("button");r.type="button",r.className="cnv-panel-zalo__btn cnv-panel-reward__more",r.textContent="Đăng nhập bằng Zalo",r.style.borderColor=t,r.style.color=t,r.addEventListener("click",Cn(Ke)),n.appendChild(r)}function Qn(n,t=!1){const e=wt(n);if(fn||null===e)return;const r=Hn(o.projectId);if(!r)return;if(xn("cnv:panel:redeem-click","redeem-confirm"))return;const i=t&&pn?pn:kn();pn=i;const c=++hn;fn=!0,dn={kind:"confirm",item:n},ie(),o.redeemReward(r.token,e,i).then(t=>{var e;Xn(c)&&(fn=!1),t.ok&&(pn=null,e=t.result,Ct(),l="number"==typeof e.pointsRemaining?e.pointsRemaining:void 0,Nn()),k&&Xn(c)&&(dn=t.ok?{kind:"success",item:n,result:t.result}:{kind:"error",code:t.code,item:n},ie())}).catch(()=>{Xn(c)&&(fn=!1),k&&Xn(c)&&(Ct(),dn={kind:"error",code:"UNCONFIRMED",item:n},ie())})}function Xn(n){return n===hn}function et(n){const t=n.redeemId;if(rn||"number"!=typeof t||t<=0)return;const e=Hn(o.projectId);if(!e)return;const r=++cn;rn=!0,on={kind:"confirm",item:n},ie(),o.useReward(e.token,t).then(e=>{const o=e.ok?yt(t,n,e.result):null;r===cn&&(rn=!1),k&&r===cn&&(o?(on=null,en=o):e.ok||(on={kind:"error",code:e.code,item:n}),De(),ie())}).catch(()=>{r===cn&&(rn=!1),k&&r===cn&&(on={kind:"error",code:"UNCONFIRMED",item:n},ie())})}function yt(n,t,e){const o=T.findIndex(t=>t.redeemId===n),r=o>=0?T[o]:t,i=Object.assign(Object.assign({},r),{code:e.code,usedAt:e.usedAt||r.usedAt,expiredAt:e.expiredAt||r.expiredAt,canUse:!1});return o>=0&&(T[o]=i),i}function _t(){dn=null,en=null,fn=!1,hn++,At()}function At(){on=null,rn=!1,cn++}function Ct(){E=null,z=0,T=[],D=0,C=[],i=void 0,M=0,Y=[],c=void 0,X=0,nn=0}function $t(n,t,e){const o=document.createElement("div");if(o.className="cnv-panel-reward",t&&(o.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2"),P(n.imageUrl)){const t=document.createElement("img");t.className="cnv-panel-reward__thumb",t.src=n.imageUrl,t.alt="",t.loading="lazy",t.decoding="async",t.addEventListener("error",()=>t.remove()),o.appendChild(t)}const i=document.createElement("div");i.className="cnv-panel-reward__main",i.appendChild(Qt(n.title||"Ưu đãi"));const c="number"==typeof n.useRemain&&n.useRemain>1,l=!!n.usedAt;if(n.discountValue||c||l){const t=document.createElement("div");if(t.className="cnv-panel-reward__tags",l){const e=document.createElement("span");e.className="cnv-panel-reward__uses";const o=Ft(n.usedAt);e.textContent=o?`Đã dùng ${o}`:"Đã dùng",t.appendChild(e)}if(n.discountValue){const o=document.createElement("span");o.className="cnv-panel-reward__value",Wn(o,e),o.textContent=n.discountValue,t.appendChild(o)}if(c){const e=document.createElement("span");e.className="cnv-panel-reward__uses",e.textContent=`Còn ${n.useRemain} lượt`,t.appendChild(e)}i.appendChild(t)}const a=Ft(n.expiredAt);if(a){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=`HSD ${a}`,i.appendChild(n)}if(o.appendChild(i),n.code||n.canUse){const t=document.createElement("div");t.className="cnv-panel-reward__side";const r=document.createElement("button");r.type="button",r.className="cnv-panel-zalo__btn cnv-panel-reward__cta cnv-panel-reward__show",r.textContent=n.canUse?"Sử dụng":"Xem mã",r.style.borderColor=e,r.style.color=e,r.addEventListener("click",Cn(()=>{if(!n.canUse)return en=n,De(),void ie();Ut(n)})),t.appendChild(r),o.appendChild(t)}return o}function Ut(n){if(n.burnOnUse)return on={kind:"confirm",item:n},De(),void ie();et(n)}function Vt(n,t,e){const o=Rt(rn?nt:Yn,rn?lt:t,rn?at:V(t,.12),e.title||"Ưu đãi"),r=document.createElement("div");r.className="cnv-panel-zalo__status",r.textContent=rn?"Đang lấy mã…":"Mã sẽ không còn hiệu lực sau khi ấn dùng ngay. Bạn có chắc muốn dùng ngay không?",o.appendChild(r),n.appendChild(o);const i=document.createElement("div");i.className="cnv-panel-redeem__actions";const c=document.createElement("button");c.type="button",c.className="cnv-panel-zalo__btn",c.textContent="Hủy",c.disabled=rn,rn||c.addEventListener("click",Cn(()=>{on=null,De(),ie()}));const l=document.createElement("button");l.type="button",l.className="cnv-panel-zalo__btn",l.textContent=rn?"Đang xử lý…":"Dùng ngay",l.disabled=rn,rn||(l.style.borderColor=t,l.style.color=t,l.addEventListener("click",Cn(()=>et(e)))),i.append(c,l),n.appendChild(i)}function Ht(n,t,e,o){const r=o&&It[o]||Et,i="UNCONFIRMED"===o,c=Rt(i?nt:Yn,i?lt:it,i?at:ct,i?"Chưa xác nhận được":"Chưa dùng được ưu đãi");if(e.title){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.title,c.appendChild(n)}const l=document.createElement("div");l.className="cnv-panel-zalo__status",l.textContent=r.message,l.setAttribute("role","alert"),c.appendChild(l),n.appendChild(c);const a=document.createElement("div");a.className="cnv-panel-redeem__actions";const u=document.createElement("button");if(u.type="button",u.className="cnv-panel-zalo__btn",u.textContent="Về danh sách",u.addEventListener("click",Cn(()=>{on=null,De(),ie()})),a.appendChild(u),"retry"===r.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Thử lại",n.style.borderColor=t,n.style.color=t,n.addEventListener("click",Cn(()=>et(e))),a.appendChild(n)}n.appendChild(a)}function Kt(n,t){const e=document.createElement("button");return e.type="button",e.className="cnv-panel-zalo__btn",e.textContent="Sao chép mã",e.style.borderColor=t,e.style.color=t,e.addEventListener("click",Cn(()=>{e.disabled||(e.disabled=!0,function(n){return J(this,void 0,void 0,function*(){if(!n)return!1;try{if(navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return yield navigator.clipboard.writeText(n),!0}catch(n){}let t=null;try{return t=document.createElement("textarea"),t.value=n,t.setAttribute("readonly",""),t.style.cssText="position:fixed;top:-1000px;left:-1000px;opacity:0;pointer-events:none;",document.body.appendChild(t),t.select(),t.setSelectionRange(0,n.length),document.execCommand("copy")}catch(n){return!1}finally{t&&t.parentNode&&t.parentNode.removeChild(t)}})}(n).then(n=>{e.isConnected&&(e.textContent=n?"Đã chép":"Không chép được",e.style.borderColor=n?ot:t,e.style.color=n?ot:t,window.setTimeout(()=>{e.isConnected&&(e.textContent="Sao chép mã",e.style.borderColor=t,e.style.color=t,e.disabled=!1)},1600))}))})),e}function qt(n,t,e){const o=Rt(Yn,t,V(t,.12),e.title||"Ưu đãi");if(e.discountValue){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.discountValue,o.appendChild(n)}if(e.canUse){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Bấm "Dùng ngay" để hiện mã.',o.appendChild(n)}else{const n=document.createElement("div");n.className="cnv-panel-reward__code cnv-panel-reward__code--big",n.textContent=e.code,o.appendChild(n)}if(e.usedAt){const n=document.createElement("span");n.className="cnv-panel-reward__uses";const t=Ft(e.usedAt);n.textContent=t?`Đã dùng ${t}`:"Đã dùng",o.appendChild(n)}if(e.channelLabel){const n=document.createElement("div");n.className="cnv-panel-reward__channel",n.textContent=e.channelLabel,o.appendChild(n)}const r=[],i=Ft(e.expiredAt);if(i&&r.push(`HSD ${i}`),"number"==typeof e.useRemain&&e.useRemain>1&&r.push(`Còn ${e.useRemain} lượt`),r.length){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=r.join(" · "),o.appendChild(n)}if(n.appendChild(o),e.canUse){const o=document.createElement("div");o.className="cnv-panel-redeem__actions";const r=document.createElement("button");r.type="button",r.className="cnv-panel-zalo__btn",r.textContent="Dùng ngay",r.style.borderColor=t,r.style.color=t,r.addEventListener("click",Cn(()=>{en=null,Ut(e)})),o.appendChild(r),n.appendChild(o)}const c=document.createElement("div");c.className="cnv-panel-redeem__actions",e.canUse||c.appendChild(Kt(e.code,t));const l=document.createElement("button");l.type="button",l.className="cnv-panel-zalo__btn",l.textContent="Quay lại",l.addEventListener("click",Cn(()=>{en=null,De(),ie()})),c.appendChild(l),n.appendChild(c)}function Gt(n){const t=document.createElement("div");return t.className="cnv-panel-rtabs",t.setAttribute("role","tablist"),kt.forEach(e=>{const o=e.key===W,r=document.createElement("button");r.type="button",r.className="cnv-panel-rtab"+(o?" cnv-panel-rtab--on":""),r.setAttribute("role","tab"),r.setAttribute("aria-selected",o?"true":"false"),r.textContent=e.label,o&&(r.style.borderBottomColor=n,r.style.color=n),r.addEventListener("click",Cn(()=>jn(e.key))),t.appendChild(r)}),t}function Zt(n){return n.toLocaleString("vi-VN")+" điểm"}function Wt(n){return n>0?Zt(n):"Miễn phí"}function Yt(n,t,e){t.length>15?n.style.fontSize=Math.round(.62*e)+"px":t.length>11&&(n.style.fontSize=Math.round(.77*e)+"px")}function Jt(n,t){const e=document.createElement("div");e.className="cnv-panel-balance";const o=document.createElement("div");o.className="cnv-panel-balance__label",o.textContent="Điểm của bạn";const r=document.createElement("div");r.className="cnv-panel-balance__row";const i=document.createElement("div");i.className="cnv-panel-balance__num",i.style.color=t;const c=n.toLocaleString("vi-VN");i.textContent=c,Yt(i,c,26);const l=document.createElement("div");return l.className="cnv-panel-balance__unit",l.textContent="điểm",r.append(i,l),e.append(o,r),e}function Qt(n){const t=document.createElement("div");t.className="cnv-panel-reward__name";const e=document.createElement("div");e.className="cnv-panel-reward__title",e.textContent=n,e.title=n;const o=document.createElement("button");return o.type="button",o.className="cnv-panel-reward__info",o.setAttribute("aria-label","Xem đầy đủ tên ưu đãi"),o.appendChild(ut('<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.8"/><path d="M12 10.6v6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><circle cx="12" cy="7.6" r="1.1" fill="currentColor"/>',14)),o.addEventListener("click",()=>{e.classList.toggle(mt)}),t.append(e,o),t}function Xt(n){if(null===wt(n)||"number"!=typeof n.redeemPoints)return"Chưa thể đổi ưu đãi này";if(!1===n.stock)return"Đã hết hàng";if("number"==typeof n.redeemRemain&&n.redeemRemain<=0)return"Bạn đã đạt giới hạn đổi";const t=Fn();return"number"==typeof t&&t<n.redeemPoints?`Cần thêm ${Zt(n.redeemPoints-t)}`:null}function ne(n,t,e){const o=document.createElement("div");if(o.className="cnv-panel-reward",t&&(o.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2"),P(n.imageUrl)){const t=document.createElement("img");t.className="cnv-panel-reward__thumb",t.src=n.imageUrl,t.alt="",t.loading="lazy",t.decoding="async",t.addEventListener("error",()=>t.remove()),o.appendChild(t)}const i=document.createElement("div");if(i.className="cnv-panel-reward__main",i.appendChild(Qt(n.title||"Ưu đãi")),n.discountValue){const t=document.createElement("div");t.className="cnv-panel-reward__tags";const o=document.createElement("span");o.className="cnv-panel-reward__value",Wn(o,e),o.textContent=n.discountValue,t.appendChild(o),i.appendChild(t)}const c=Ft(n.expiredAt);if(c){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=`HSD ${c}`,i.appendChild(n)}const l=Xt(n);if(l){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=l,i.appendChild(n)}o.appendChild(i);const a=document.createElement("div");if(a.className="cnv-panel-reward__side","number"==typeof n.redeemPoints){const t=document.createElement("div");t.className="cnv-panel-reward__price",t.style.color=e,t.textContent=Wt(n.redeemPoints),a.appendChild(t)}const u=document.createElement("button");return u.type="button",u.className="cnv-panel-zalo__btn cnv-panel-reward__cta",u.textContent="Đổi",u.disabled=null!==l||fn,u.disabled||(u.style.borderColor=e,u.style.color=e,u.addEventListener("click",Cn(()=>{dn={kind:"confirm",item:n},De(),ie()}))),a.appendChild(u),o.appendChild(a),o}function te(n,t){const e=Fn();if("number"==typeof e&&n.appendChild(Jt(e,t)),!Ln())return void Vn(n,t,"Bạn cần đăng nhập để xem ưu đãi có thể đổi.");if(tn&&!Y.length)return n.appendChild(Tt(200,12)),void n.appendChild(Tt(150,12));if(!Y.length){const t=document.createElement("div");return t.className="cnv-panel-reward__meta",t.textContent="Hiện chưa có ưu đãi nào để đổi.",void n.appendChild(t)}const o=document.createElement("div");o.className="cnv-panel-reward__list",Y.forEach((n,e)=>o.appendChild(ne(n,e>0,t))),n.appendChild(o);const r="number"==typeof c&&X?Math.max(0,c-Y.length):0;if(r>0||tn){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more",t.disabled=tn,t.textContent=tn?"Đang tải…":`Xem thêm ${r} ưu đãi`,t.addEventListener("click",Cn(Bn)),n.appendChild(t)}}function ee(n,t,e){const o=Rt(Yn,t,V(t,.12),e.title||"Ưu đãi");if("number"==typeof e.redeemPoints){const n=document.createElement("div");n.className="cnv-panel-redeem__cost",n.style.color=t;const r=Wt(e.redeemPoints);n.textContent=r,Yt(n,r,20),o.appendChild(n);const i=Fn();if(e.redeemPoints>0&&"number"==typeof i){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=`Còn lại ${Zt(i-e.redeemPoints)}`,o.appendChild(n)}}n.appendChild(o);const r=document.createElement("div");r.className="cnv-panel-redeem__actions";const i=document.createElement("button");i.type="button",i.className="cnv-panel-zalo__btn",i.textContent="Hủy",i.disabled=fn,fn||i.addEventListener("click",Cn(()=>{dn=null,ie()}));const c=document.createElement("button");c.type="button",c.className="cnv-panel-zalo__btn",c.textContent=fn?"Đang đổi…":"Đổi",c.disabled=fn,fn||(c.style.borderColor=t,c.style.color=t,c.addEventListener("click",Cn(()=>Qn(e)))),r.append(i,c),n.appendChild(r)}function oe(n,t,e,o){var r;const i=Rt(tt,ot,rt,"Đổi thành công"),c=document.createElement("div");if(c.className="cnv-panel-redeem__sub",c.textContent=e.title||"Ưu đãi",i.appendChild(c),e.burnOnUse){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Mã đã sẵn sàng trong "Ưu đãi của bạn" — bấm Sử dụng khi bạn dùng nhé.',i.appendChild(n)}else if(o.code){const n=document.createElement("div");n.className="cnv-panel-reward__code",n.textContent=o.code,i.appendChild(n)}else{const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Chưa có mã ngay — bạn kiểm tra ở tab "Ưu đãi của bạn" nhé.',i.appendChild(n)}const l=null!==(r=o.pointsSpent)&&void 0!==r?r:e.redeemPoints,a=[];if("number"==typeof l&&l>0&&a.push(`Đã dùng ${Zt(l)}`),"number"==typeof o.pointsRemaining&&a.push(`còn lại ${Zt(o.pointsRemaining)}`),a.length){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=a.join(" · "),i.appendChild(n)}if(o.transactionId){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=`Mã giao dịch ${o.transactionId}`,i.appendChild(n)}if(n.appendChild(i),!e.burnOnUse&&o.code){const e=document.createElement("div");e.className="cnv-panel-redeem__actions",e.appendChild(Kt(o.code,t)),n.appendChild(e)}const u=document.createElement("div");u.className="cnv-panel-redeem__actions";const s=document.createElement("button");s.type="button",s.className="cnv-panel-zalo__btn",s.textContent="Ưu đãi của bạn",s.addEventListener("click",Cn(()=>jn("owned")));const d=document.createElement("button");d.type="button",d.className="cnv-panel-zalo__btn",d.textContent="Đổi tiếp",d.addEventListener("click",Cn(()=>{dn=null,De(),ie(),"redeem"!==W||Y.length||(X=0,Bn())})),u.append(d,s),n.appendChild(u)}function re(n,t,e,o){var r;const i=((n,t)=>{var e;if(t){if(void 0!==(null===(e=wt(n))||void 0===e?void 0:e.redeemPoints)&&Ot[t])return Ot[t];if(Mt[t])return Mt[t]}return St})(e,o),c="neutral"===i.tone,l=Rt(c?nt:Yn,c?lt:it,c?at:ct,null!==(r=i.heading)&&void 0!==r?r:"Không đổi được ưu đãi");if(e.title){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.title,l.appendChild(n)}const a=document.createElement("div");a.className="cnv-panel-zalo__status",a.textContent=i.message,a.setAttribute("role","alert"),l.appendChild(a),n.appendChild(l);const u=document.createElement("div");u.className="cnv-panel-redeem__actions";const s=()=>{dn=null,De(),ie()},d=Nt[i.action];if("other"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.addEventListener("click",Cn(s)),u.appendChild(n)}else if("owned"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.addEventListener("click",Cn(()=>jn("owned"))),u.appendChild(n)}else{const n=document.createElement("button");if(n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Về danh sách",n.addEventListener("click",Cn(s)),u.appendChild(n),"retry"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.style.borderColor=t,n.style.color=t,n.addEventListener("click",Cn(()=>Qn(e,!i.retryWithNewKey))),u.appendChild(n)}}n.appendChild(u)}function ie(){if(!h)return;Re(),Be(),je(!0),h.textContent="";const n=Zn(r),t="redeem"===W?null!==dn:null!==on||null!==en,e=zt(r,t?"cnv-panel-phase":"cnv-panel-rcard");let o=e;if(!t){const t=document.createElement("div");t.className="cnv-panel-section__head",t.appendChild(st(Yn,n));const r=document.createElement("div");r.className="cnv-panel-section__title",r.textContent="Ưu đãi",t.appendChild(r);const i=document.createElement("div");i.className="cnv-panel-rhead",i.append(t,Gt(n)),e.appendChild(i),o=document.createElement("div"),o.className="cnv-panel-rlist",e.appendChild(o)}"redeem"===W?"confirm"===(null==dn?void 0:dn.kind)?ee(e,n,dn.item):"success"===(null==dn?void 0:dn.kind)?oe(e,n,dn.item,dn.result):"error"===(null==dn?void 0:dn.kind)?re(e,n,dn.item,dn.code):te(o,n):"confirm"===(null==on?void 0:on.kind)?Vt(e,n,on.item):"error"===(null==on?void 0:on.kind)?Ht(e,n,on.item,on.code):en?qt(e,n,en):ce(o,n),h.appendChild(e),h&&h.querySelectorAll(".cnv-panel-reward__name").forEach(n=>{const t=n.querySelector(".cnv-panel-reward__title");if(!t)return;if(t.clientWidth<=0)return;const e=t.offsetHeight;t.classList.add(mt);const o=t.offsetHeight;t.classList.remove(mt),n.classList.toggle("cnv-panel-reward__name--clamped",o>e+1)})}function ce(n,t){if(!Ln())return void Vn(n,t,"Bạn cần đăng nhập để xem ưu đãi của bạn.");if(N&&!T.length)return n.appendChild(Tt(200,12)),void n.appendChild(Tt(150,12));if(!T.length){const t=document.createElement("div");return t.className="cnv-panel-reward__meta",t.textContent="Bạn chưa có ưu đãi nào.",void n.appendChild(t)}const e=document.createElement("div");e.className="cnv-panel-reward__list",T.forEach((n,o)=>e.appendChild($t(n,o>0,t))),n.appendChild(e);const o=Tn();if(o>0||Z){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more",t.disabled=Z,t.textContent=Z?"Đang tải…":`Xem thêm ${o} ưu đãi`,t.addEventListener("click",Dn),n.appendChild(t)}}function le(n){const t="earn"===n?r.earnBlocks:"redeem"===n?r.redeemBlocks:null;return Array.isArray(t)?t.filter(n=>n&&"string"==typeof n.title&&""!==n.title.trim()).slice(0,12):[]}function ae(n,t,e,o){const i=document.createElement("div");i.className="cnv-panel-block",t&&(i.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2");const c=ht[n.icon];i.appendChild(st("string"==typeof c?c:o,e));const l=document.createElement("div");l.className="cnv-panel-block__main";const a=document.createElement("div");a.className="cnv-panel-block__title",a.textContent=n.title.trim(),l.appendChild(a);const u="string"==typeof n.description?n.description.trim():"";if(u){const n=document.createElement("div");n.className="cnv-panel-block__desc",n.textContent=u,l.appendChild(n)}return i.appendChild(l),i}function ue(){if(O)return;const n=Hn(o.projectId);if(!n)return;const t=M+1;O=!0,A&&se(),o.fetchPointHistory(n.token,t).then(n=>{O=!1,M=t,n&&("number"==typeof n.totalCount&&(i=n.totalCount),n.items.length&&(C=C.concat(n.items))),A&&se()}).catch(()=>{O=!1,A&&se()})}function se(){if(!h)return;Re(),Be(),je(!0),h.textContent="";const n=Zn(r),t=zt(r);if(t.appendChild(ge({label:"Lịch sử hoạt động",icon:nt},n)),!C.length&&O)t.appendChild(Tt(180,12)),t.appendChild(Tt(120,12));else if(C.length){const n=document.createElement("div");n.className="cnv-panel-history__list",C.forEach((t,e)=>n.appendChild(de(t,e>0))),t.appendChild(n);const e="number"==typeof i&&M?Math.max(0,i-C.length):0;if(e>0||O){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn cnv-panel-reward__more",n.disabled=O,n.textContent=O?"Đang tải…":`Xem thêm ${e} hoạt động`,n.addEventListener("click",Cn(ue)),t.appendChild(n)}}else{const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent="Chưa có hoạt động nào.",t.appendChild(n)}h.appendChild(t)}function de(n,t){const e=document.createElement("div");e.className="cnv-panel-history__row",t&&(e.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2");const o=document.createElement("div");o.className="cnv-panel-history__main";const i=document.createElement("div");i.className="cnv-panel-history__title",i.textContent=(n.title||"").trim()||"Hoạt động",o.appendChild(i);const c=(n.description||"").trim();c&&o.appendChild(fe(c));const l=[];"number"==typeof n.balanceAfter&&l.push("Điểm tích lũy: "+he(n.balanceAfter));const a=(n.rankAfter||"").trim();"number"==typeof n.expBalanceAfter?l.push("Điểm xét hạng: "+he(n.expBalanceAfter)+(a?" (Hạng "+a+")":"")):a&&l.push("Hạng "+a),l.length&&o.appendChild(fe(l.join(" / ")));const u=ve(n.createdAt);u&&o.appendChild(fe(u)),e.appendChild(o);const s=document.createElement("div");if(s.className="cnv-panel-history__amounts","number"==typeof n.points){const t=document.createElement("div");t.className="cnv-panel-history__points",t.textContent=pe(n.points)+" điểm",s.appendChild(t)}if("number"==typeof n.expPoints&&0!==n.expPoints){const t=document.createElement("div");t.className="cnv-panel-history__exp",t.textContent=pe(n.expPoints)+" xét hạng",s.appendChild(t)}return s.childElementCount&&e.appendChild(s),e}function fe(n){const t=document.createElement("div");return t.className="cnv-panel-history__meta",t.textContent=n,t}function pe(n){const t=Math.round(n);return(t>0?"+":"")+t.toLocaleString("vi-VN")}function he(n){return Math.round(n).toLocaleString("vi-VN")}function ve(n){if(!n)return null;const t=new Date(n);return Number.isNaN(t.getTime())?null:t.toLocaleDateString("vi-VN")+" "+t.toLocaleTimeString("vi-VN",{hour:"2-digit",minute:"2-digit"})}function me(){if(!h||!S)return;const n=vt[S];if(!n)return S=null,void Ie();const t=le(S);Re(),Be(),je(!0),h.textContent="";const e=Zn(r),o=zt(r);if(o.appendChild(ge(n,e)),t.length){const r=document.createElement("div");r.className="cnv-panel-block__list",t.forEach((t,o)=>r.appendChild(ae(t,o>0,e,n.icon))),o.appendChild(r)}else{const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent="redeem"===S?"Shop chưa cập nhật cách đổi điểm. Bạn quay lại sau nhé.":"Shop chưa cập nhật cách kiếm thêm điểm. Bạn quay lại sau nhé.",o.appendChild(n)}if(h.appendChild(o),!Te()){const n=Sn();n&&h.appendChild(n)}I=Te()}function ge(n,t){const e=document.createElement("div");e.className="cnv-panel-section__head",e.appendChild(st(n.icon,t));const o=document.createElement("div");return o.className="cnv-panel-section__title",o.textContent=n.label,e.appendChild(o),e}function be(n){if(!(Array.isArray(r.sections)?r.sections:[]).some(n=>"POINTS"===n.type&&n.enabled))return null;const t=zt(r),e=document.createElement("div");e.className="cnv-panel-section__desc",e.textContent="Kiếm điểm từ nhiều hoạt động, rồi đổi điểm lấy những ưu đãi hấp dẫn.";const o=document.createElement("div");return bt.forEach((n,t)=>o.appendChild(Mn(n[0],n[1],t>0))),t.append(ge(ft.POINTS,n),e,o),t}function ye(n){const t=Math.max(0,Math.round(n)).toLocaleString("vi-VN");return"SPENDING"===(null==U?void 0:U.applyFor)?t+"đ":t+" điểm"}function _e(n){const t=document.createElement("span");if(t.className="cnv-panel-tier__badge",P(n.iconUrl)){const e=document.createElement("img");return e.className="cnv-panel-tier__badge-img",e.alt="",e.src=n.iconUrl,t.appendChild(e),t}return t.style.backgroundColor=L(n.colorCode,Zn(r)),t}function we(n,t){var e,o;const r=document.createElement("div");r.className="cnv-panel-tier__row",t&&r.classList.add("cnv-panel-tier__row--current"),r.appendChild(_e(n));const i=document.createElement("span");return i.className="cnv-panel-tier__name",i.textContent=t?(null!==(e=n.name)&&void 0!==e?e:"")+" — bạn đang ở đây":null!==(o=n.name)&&void 0!==o?o:"",r.appendChild(i),r}function xe(n){const t=n.filter(n=>"string"==typeof n&&""!==n.trim());if(!t.length)return null;const e=document.createElement("ul");return e.className="cnv-panel-tier__benefits",t.forEach(n=>{const t=document.createElement("li");t.textContent=n.trim(),e.appendChild(t)}),e}function ke(n,t){const e=document.createElement("div");return e.className="cnv-panel-tier__more",e.textContent="…và "+n+(t?" hạng cao hơn":" hạng thấp hơn"),e}function Ae(n,t){var e;const o=n.progressTarget,i=null!==(e=n.progressCurrent)&&void 0!==e?e:0;if("number"!=typeof o||o<=0)return null;const c=document.createElement("div");c.className="cnv-panel-tier__progress";const l=document.createElement("div");l.className="cnv-panel-tier__bar",l.style.backgroundColor="DARK"===r.theme?"rgba(255,255,255,.16)":"rgba(24,28,50,.10)";const a=document.createElement("div");a.className="cnv-panel-tier__fill",a.style.backgroundColor=t,a.style.width=Math.max(0,Math.min(100,i/o*100)).toFixed(1)+"%",l.appendChild(a);const u=document.createElement("div");u.className="cnv-panel-tier__hint";const s="number"==typeof n.remaining?n.remaining:o-i;return u.textContent=n.nextLevelName?"Còn "+ye(s)+" nữa để lên "+n.nextLevelName:"Còn "+ye(s)+" nữa để lên hạng kế tiếp",c.append(l,u),c}function Ce(n,t){if(t<0)return{from:0,to:Math.min(n.length,4)};const e=Math.max(0,t-1);return{from:e,to:Math.min(n.length,e+4)}}function Me(n,t){var e,o;const i=null!==(e=null==U?void 0:U.tiers)&&void 0!==e?e:[];if(!i.length)return null;const c=zt(r),l=document.createElement("div"),a=t?null==E?void 0:E.tier:void 0;if(null==a?void 0:a.name){const t=document.createElement("div");t.className="cnv-panel-tier__current",t.appendChild(_e(a));const e=document.createElement("span");e.className="cnv-panel-tier__current-name",e.style.color=n,e.textContent=a.name,t.appendChild(e),l.appendChild(t);const o=Ae(a,n);if(o)l.appendChild(o);else if(a.isHighestLevel){const n=document.createElement("div");n.className="cnv-panel-tier__hint",n.textContent="Bạn đang ở hạng cao nhất.",l.appendChild(n)}}else if(!t){const n=document.createElement("div");n.className="cnv-panel-section__desc",n.textContent="Mua càng nhiều, hạng càng cao, quyền lợi càng nhiều.",l.appendChild(n)}const u=null!=(null==a?void 0:a.id)?i.findIndex(n=>n.id===a.id):-1,{from:s,to:d}=Ce(i,u),f=document.createElement("div");f.className="cnv-panel-tier__list",s>0&&f.appendChild(ke(s,!1));for(let n=s;n<d;n++){const t=n===u;if(f.appendChild(we(i[n],t)),t||u<0){const t=xe(i[n].benefits);t&&f.appendChild(t)}}const p=Math.max(null!==(o=null==U?void 0:U.totalTiers)&&void 0!==o?o:i.length,i.length)-d;return p>0&&f.appendChild(ke(p,!0)),l.appendChild(f),c.append(ge(ft.VIP,n),l),c}function Oe(n,t){const e=ft[n];if(!e||"string"!=typeof e.label)return null;if("VIP"===n)return Me(t,!0);const o=zt(r),i=ge(e,t),c=document.createElement("div");if("POINTS"!==n)return c.appendChild(dt("Sắp ra mắt",t)),o.append(i,c),o;const l=En();if("number"==typeof l&&Number.isFinite(l)){const n=document.createElement("div");n.className="cnv-panel-section__points",n.style.color=t;const e=l.toLocaleString("vi-VN");n.textContent=e,e.length>15&&(n.style.fontSize="20px"),c.appendChild(n)}else c.appendChild(dt("Đang cập nhật",t));const a=null!==(u=null==E?void 0:E.rewardsAvailableCount)&&void 0!==u?u:null==_?void 0:_.rewardsAvailableCount;var u;return[["number"==typeof a?`Ưu đãi của bạn — ${a} ưu đãi khả dụng`:"Ưu đãi của bạn","rewards"],...bt,["Lịch sử hoạt động","history"]].forEach((n,t)=>c.appendChild(Mn(n[0],n[1],t>0))),o.append(i,c),o}function Se(){if(!f||!p)return;const n=r.colors;u&&(u.style.backgroundColor="DARK"===r.theme?"#181C32":"#FFFFFF",u.style.color="DARK"===r.theme?"#FFFFFF":"#181C32");const t=f.parentElement;if(t&&(t.style.backgroundColor=L(null==n?void 0:n.bannerBg,R),t.style.color=L(null==n?void 0:n.bannerFont,B)),s&&(P(r.bannerImageUrl)?(s.src=r.bannerImageUrl,s.style.display="block"):(s.style.display="none",s.removeAttribute("src"))),d){const t=d.parentElement;P(r.brandIconUrl)?(d.src=r.brandIconUrl,t&&(t.style.display="flex",t.style.background=V(L(null==n?void 0:n.bannerFont,B),.18))):(t&&(t.style.display="none"),d.removeAttribute("src"))}const e=(null==_?void 0:_.isMember)?r.headerMember:r.headerVisitor,i=(null==_?void 0:_.isMember)?null===(c=Hn(o.projectId))||void 0===c?void 0:c.fullName:null;var c;f.textContent=xt((null==e?void 0:e.caption)||"",i),p.textContent=xt((null==e?void 0:e.title)||"",i)}function Ie(){if(!h||x||k||A||S)return;Re(),Be(),je(!0),h.textContent="";const n=Zn(r);if(!(null==_?void 0:_.isMember)){let t=0;Ee(On(),t++);const e=be(n);e&&Ee(e,t++);const o=zn()?Me(n,!1):null;return void(o&&Ee(o,t++))}const t=Array.isArray(r.sections)?[...r.sections]:[];let e=0;t.filter(n=>n.enabled&&"string"==typeof n.type).sort((n,t)=>{var e,o;return(null!==(e=n.order)&&void 0!==e?e:0)-(null!==(o=t.order)&&void 0!==o?o:0)}).forEach(t=>{const o=Oe(t.type,n);o&&Ee(o,e++)})}function Ee(n,t){n.style.animationDelay=40+55*t+"ms",h.appendChild(n)}function Ne(){Se(),S?I!==Te()&&me():Ie()}function ze(){un("owned"),un("redeem"),E=null,z=0,nn=0,T=[],D=0,k=!1,Y=[],c=void 0,X=0,l=void 0,pn=null,_t(),C=[],i=void 0,M=0,A=!1}function Te(){return!!(null==_?void 0:_.isMember)}function De(){h&&(h.scrollTop=0)}function je(n){u&&(u.style.backgroundImage=n?((n,t)=>{if(!n||"NONE"===n)return"none";const e=((n,t)=>{switch(n){case"WAVES":return`<svg xmlns="http://www.w3.org/2000/svg" width="48" height="24" viewBox="0 0 48 24"><path d="M0 12c6 0 6 8 12 8s6-8 12-8 6 8 12 8 6-8 12-8" fill="none" stroke="${t}" stroke-width="2"/></svg>`;case"CUBES":return`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><rect x="4" y="4" width="14" height="14" fill="none" stroke="${t}" stroke-width="2"/><rect x="22" y="22" width="14" height="14" fill="none" stroke="${t}" stroke-width="2"/></svg>`;case"FUN":return`<svg xmlns="http://www.w3.org/2000/svg" width="44" height="44" viewBox="0 0 44 44"><circle cx="8" cy="10" r="2.4" fill="${t}"/><path d="M30 6l1.6 3.4 3.6.4-2.6 2.6.7 3.7-3.3-1.8-3.3 1.8.7-3.7-2.6-2.6 3.6-.4z" fill="${t}"/><circle cx="34" cy="34" r="2.4" fill="${t}"/><circle cx="10" cy="34" r="1.8" fill="${t}"/></svg>`;case"GEOMETRIC":return`<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path d="M8 36 16 12l8 24Z" fill="none" stroke="${t}" stroke-width="2"/><circle cx="36" cy="14" r="6" fill="none" stroke="${t}" stroke-width="2"/></svg>`;case"CROSS_HATCHING":return`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0 24 24M0 24 24 0" stroke="${t}" stroke-width="1.4"/></svg>`;default:return""}})(n,t?"rgba(255,255,255,0.16)":"rgba(17,17,17,0.10)");return e?`url("data:image/svg+xml,${encodeURIComponent(e)}")`:"none"})(r.wallpaper,"DARK"===r.theme):"none")}function Re(){const n=x||k||A||null!==S;m&&(m.style.display=n?"inline-flex":"none"),v&&v.classList.toggle("cnv-panel-banner--sub",n)}function Be(){if(!u)return;const n=!Te()&&null!==S;if(n&&!b)return b=In(),void u.insertBefore(b,g);!n&&b&&(b.remove(),b=null)}function Fe(){x&&(Pe(),x=!1),k=!1,_t(),A=!1,S=null,De(),Ie()}function Le(){gn=e(gn)}function Pe(){bn=e(bn)}function $e(n,t){Le();const e=Date.now()+1e3*t.expiresInSeconds;gn=Bt(t.expiresInSeconds,()=>{const t=Math.max(0,Math.round((e-Date.now())/1e3)),o=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");return n.textContent=`Hết hạn sau ${o}:${r}`,t<=0})}function Ue(){if(x=!1,Le(),Pe(),w){const t=w;w=null,n(()=>t.cancel())}}function Ve(){const n=document.createElement("button");return n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Huỷ",n.addEventListener("click",()=>{Ue(),Ne()}),n}function He(n){var t;if(!h)return;Re(),Be(),je(!1),h.textContent="";const e=Zn(r),o=zt(r,"cnv-panel-zalo");if("loading"===n.phase)o.appendChild(jt(e)),o.appendChild(Ve());else if("qr"===n.phase){const t=(n=>{try{const t=Q(0,"M");t.addData(n),t.make();const e=t.getModuleCount(),o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox",`0 0 ${e} ${e}`),o.setAttribute("width",String(180)),o.setAttribute("height",String(180));const r=document.createElementNS("http://www.w3.org/2000/svg","rect");r.setAttribute("width",String(e)),r.setAttribute("height",String(e)),r.setAttribute("fill","#fff"),o.appendChild(r);let i="";for(let n=0;n<e;n++)for(let o=0;o<e;o++)t.isDark(n,o)&&(i+=`M${o} ${n}h1v1h-1z`);const c=document.createElementNS("http://www.w3.org/2000/svg","path");return c.setAttribute("d",i),c.setAttribute("fill","#000"),o.appendChild(c),o}catch(n){return null}})(n.session.qrPayload);if(t){const n=document.createElement("div");n.className="cnv-panel-zalo__qr cnv-panel-zalo__qr--white",n.appendChild(t),Dt(n,e),o.appendChild(n)}const r=document.createElement("div");r.className="cnv-panel-zalo__status",r.appendChild(document.createTextNode("Mở "));const i=document.createElement("b");i.style.color=e,i.textContent="Zalo",r.appendChild(i),r.appendChild(document.createTextNode(" trên điện thoại và quét mã để đăng nhập")),o.appendChild(r);const c=document.createElement("div");c.className="cnv-panel-zalo__timer",c.appendChild(ut(nt,12));const l=document.createElement("span");c.appendChild(l),o.appendChild(c),$e(l,n.session),o.appendChild(Ve())}else{o.style.position="relative",o.appendChild(jt(e));const l=document.createElement("div");let a;if(l.className="cnv-panel-zalo__overlay",l.style.borderRadius=Gn(null===(t=r.shapes)||void 0===t?void 0:t.card),l.style.background="DARK"===r.theme?"rgba(63, 66, 84, 0.94)":"rgba(255, 255, 255, 0.94)","success"===n.phase)a=Rt(tt,ot,rt,n.result.fullName?`Xin chào ${n.result.fullName}!`:"Đăng nhập thành công!");else{const t="expired"===n.reason;a=Rt(t?nt:'<path d="M2 8.5a17 17 0 0 1 20 0M5.5 12.3a11.6 11.6 0 0 1 13 0M9 16a6 6 0 0 1 6 0M3 3l18 18" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>',t?lt:it,t?at:ct,t?"Mã QR đã hết hạn":"Có lỗi xảy ra");const o=document.createElement("div");if(o.className="cnv-panel-zalo__status",o.textContent=t?'Bấm "Thử lại" để lấy mã mới.':n.message,a.appendChild(o),n.canRetry){const n=document.createElement("button");if(n.type="button",n.className="cnv-panel-zalo__btn",n.style.backgroundColor=e,n.style.borderColor=e,n.style.color="#fff",n.textContent="Thử lại",n.addEventListener("click",Cn(()=>Ke())),mn>=3){const t=Math.min(5+5*(mn-3),20);i=n,c=t,Pe(),i.disabled=!0,bn=Bt(c,n=>{n>0&&(i.textContent=`Thử lại (${n}s)`)},()=>{i.disabled=!1,i.textContent="Thử lại"})}a.appendChild(n)}}l.appendChild(a),o.appendChild(l)}var i,c;h.appendChild(o)}function Ke(){if(!h)return;Ue(),S=null,x=!0,De();const t=++vn;He({phase:"loading"}),o.loginWithZalo().then(e=>{wn(t)?n(()=>e.cancel()):(w=e,mn=0,He({phase:"qr",session:e}),e.result.then(n=>{if(!wn(t)){if(Le(),w=null,He({phase:"success",result:n}),null!=n.contactId&&"string"==typeof n.panelSessionToken&&n.panelSessionToken&&"number"==typeof n.panelSessionExp){const t="number"==typeof n.panelSessionExpiresInMs&&n.panelSessionExpiresInMs>0?Date.now()+n.panelSessionExpiresInMs:n.panelSessionExp;Kn(o.projectId,{token:n.panelSessionToken,contactId:n.contactId,fullName:n.fullName,level:n.level,xp:n.xp,exp:t}),uo(t)}_={isMember:!0},Nn(),setTimeout(()=>{wn(t)||(x=!1,Ne())},1500)}}).catch(n=>{wn(t)||(Le(),w=null,He({phase:"error",message:Pt(n),canRetry:!0,reason:Lt(n)}))}))}).catch(n=>{wn(t)||(mn+=1,He({phase:"error",message:Pt(n),canRetry:!0,reason:Lt(n)}))})}function qe(n){var t,e,o;if(a)return;const i=K("data-cnv-panel",':host{all:initial;}.cnv-panel-card{position:fixed;display:flex;flex-direction:column;background-repeat:repeat;width:min(360px,calc(100vw - 32px));height:600px;max-height:calc(100vh - 32px);overflow:hidden;box-shadow:0 20px 44px rgba(24,28,50,.22),0 4px 10px rgba(24,28,50,.12);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.4;animation:cnv-panel-in .34s cubic-bezier(.16,1,.3,1) both;}.cnv-panel-card--leaving{animation:cnv-panel-out .18s cubic-bezier(.4,0,1,1) both;pointer-events:none;}@keyframes cnv-panel-in{from{opacity:0;transform:translateY(14px) scale(.92);}to{opacity:1;transform:none;}}@keyframes cnv-panel-out{from{opacity:1;transform:none;}to{opacity:0;transform:translateY(10px) scale(.96);}}@keyframes cnv-panel-bubble-in{from{opacity:0;transform:translateY(4px) scale(.97);}to{opacity:1;transform:none;}}@keyframes cnv-panel-rise{from{opacity:0;transform:translateY(10px);}to{opacity:1;transform:none;}}@media (prefers-reduced-motion:reduce){.cnv-panel-card,.cnv-panel-card--leaving,.cnv-panel-card__section,.cnv-panel-zalo__overlay-bubble{animation:none !important;}}.cnv-panel-close{position:absolute;z-index:2;top:10px;right:10px;width:26px;height:26px;border:none;border-radius:999px;background:rgba(0,0,0,.18);color:#fff;cursor:pointer;font-size:16px;display:inline-flex;align-items:center;justify-content:center;line-height:1;padding:0;transition:background .15s;}.cnv-panel-close:hover{background:rgba(0,0,0,.3);}.cnv-panel-back{position:absolute;z-index:2;top:10px;left:10px;width:26px;height:26px;border:none;border-radius:999px;background:rgba(0,0,0,.18);color:#fff;cursor:pointer;padding:0;display:none;align-items:center;justify-content:center;transition:background .15s;}.cnv-panel-back:hover{background:rgba(0,0,0,.3);}.cnv-panel-banner{position:relative;flex:0 0 auto;padding:20px 20px 54px;min-height:160px;margin-bottom:-54px;box-sizing:border-box;overflow:hidden;}.cnv-panel-banner--sub{padding-left:44px;}.cnv-panel-banner__img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:.35;display:none;}.cnv-panel-banner__brandchip{position:relative;width:34px;height:34px;border-radius:10px;margin:0 0 10px;display:none;align-items:center;justify-content:center;overflow:hidden;}.cnv-panel-banner__brandicon{width:100%;height:100%;object-fit:cover;display:block;}.cnv-panel-banner__caption{position:relative;font-size:11.5px;opacity:.85;}.cnv-panel-banner__title{position:relative;font-size:26px;font-weight:800;line-height:1.24;margin-top:3px;}.cnv-panel-body{flex:1 1 auto;min-height:0;overflow:hidden auto;overscroll-behavior:contain;padding:16px;display:flex;flex-direction:column;gap:12px;position:relative;z-index:1;scrollbar-width:none;-ms-overflow-style:none;}.cnv-panel-body::-webkit-scrollbar{width:0;height:0;display:none;}.cnv-panel-footer{flex:0 0 auto;padding:11px 16px;display:flex;align-items:center;justify-content:center;gap:4px;font-size:11.5px;font-weight:500;}.cnv-panel-footer__brand{font-weight:800;}.cnv-panel-card__section{padding:16px;box-sizing:border-box;animation:cnv-panel-rise .34s cubic-bezier(.16,1,.3,1) both;}.cnv-panel-phase{flex:1 0 auto;display:flex;flex-direction:column;justify-content:center;}.cnv-panel-phase .cnv-panel-zalo__status{max-width:none;}.cnv-panel-chip{width:26px;height:26px;border-radius:8px;display:flex;align-items:center;justify-content:center;flex-shrink:0;}.cnv-panel-section__head{display:flex;align-items:center;gap:8px;margin-bottom:10px;}.cnv-panel-cta{text-align:center;}.cnv-panel-cta__title{font-size:15px;font-weight:800;margin-bottom:5px;}.cnv-panel-cta__desc{font-size:12.5px;line-height:1.5;opacity:.72;margin-bottom:14px;}.cnv-panel-history__row{display:flex;align-items:flex-start;gap:10px;padding:10px 0;}.cnv-panel-history__main{flex:1;min-width:0;}.cnv-panel-history__title{font-size:13px;font-weight:700;line-height:1.35;}.cnv-panel-history__meta{font-size:11.5px;line-height:1.45;opacity:.66;margin-top:2px;}.cnv-panel-history__amounts{flex:0 0 auto;text-align:right;}.cnv-panel-history__points{font-size:12.5px;font-weight:800;font-variant-numeric:tabular-nums;white-space:nowrap;}.cnv-panel-history__exp{font-size:11px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;opacity:.66;margin-top:2px;}.cnv-panel-join-hint{padding:13px 16px;text-align:center;font-size:12.5px;line-height:1.5;font-weight:600;}.cnv-panel-joinbar{flex:0 0 auto;padding:12px 16px;}.cnv-panel-cta__btn{display:flex;align-items:center;justify-content:center;gap:6px;width:100%;height:40px;border:none;font-weight:700;cursor:pointer;margin-bottom:10px;font-size:13.5px;transition:filter .15s,transform .15s cubic-bezier(.16,1,.3,1);}.cnv-panel-cta__btn:hover{filter:brightness(1.06);transform:translateY(-1px);}.cnv-panel-cta__btn:active{transform:translateY(0) scale(.985);}.cnv-panel-cta__signin{display:flex;align-items:center;justify-content:center;gap:4px;font-size:12.5px;text-align:center;cursor:pointer;font-weight:700;}@media (max-height:560px){.cnv-panel-banner{min-height:96px;margin-bottom:-38px;padding:14px 16px 38px;}.cnv-panel-banner--sub{padding-left:44px;}.cnv-panel-banner__title{font-size:20px;}.cnv-panel-body{padding:12px;gap:8px;}.cnv-panel-joinbar{padding:8px 12px;}.cnv-panel-cta__btn{height:34px;margin-bottom:6px;}.cnv-panel-footer{padding:6px 12px;}}.cnv-panel-icon{display:inline-flex;flex-shrink:0;}.cnv-panel-icon--chevron{transition:transform .15s;}.cnv-panel-cta__signin:hover .cnv-panel-icon--chevron{transform:translateX(2px);}.cnv-panel-section__title{font-size:11.5px;font-weight:800;text-transform:uppercase;letter-spacing:.04em;opacity:.68;}.cnv-panel-section__points{font-size:28px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1;margin-bottom:6px;}.cnv-panel-section__desc{font-size:12.5px;line-height:1.5;opacity:.72;margin-bottom:4px;}.cnv-panel-section__row{font-size:12.5px;display:flex;align-items:center;gap:10px;padding:10px 0;cursor:pointer;}.cnv-panel-section__row-label{flex:1;min-width:0;}.cnv-panel-section__row:hover .cnv-panel-icon--chevron{transform:translateX(2px);}.cnv-panel-badge{display:inline-flex;align-items:center;font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.03em;padding:3px 8px;border-radius:999px;}.cnv-panel-tier__current{display:flex;align-items:center;gap:8px;margin-bottom:10px;}.cnv-panel-tier__current-name{font-size:19px;font-weight:800;line-height:1.2;}.cnv-panel-tier__badge{flex:0 0 auto;width:18px;height:18px;border-radius:999px;overflow:hidden;display:inline-flex;align-items:center;justify-content:center;}.cnv-panel-tier__badge-img{width:100%;height:100%;object-fit:cover;display:block;}.cnv-panel-tier__progress{margin-bottom:8px;}.cnv-panel-tier__bar{height:6px;border-radius:999px;overflow:hidden;}.cnv-panel-tier__fill{height:100%;border-radius:999px;transition:width .35s ease;}.cnv-panel-tier__hint{font-size:12px;line-height:1.5;opacity:.72;}.cnv-panel-tier__list{}.cnv-panel-tier__row{display:flex;align-items:center;gap:8px;font-size:12.5px;padding:7px 0;}.cnv-panel-tier__row--current{font-weight:800;}.cnv-panel-tier__name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.cnv-panel-tier__benefits{margin:0 0 6px 26px;padding:0 0 0 14px;font-size:12px;line-height:1.55;opacity:.72;}.cnv-panel-tier__more{font-size:11.5px;padding:5px 0 5px 26px;opacity:.58;}.cnv-panel-zalo{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;text-align:center;min-height:346px;}.cnv-panel-vstack{display:flex;flex-direction:column;align-items:center;gap:8px;}.cnv-panel-zalo__qr{position:relative;padding:10px;border-radius:12px;}.cnv-panel-zalo__qr--white{background:#fff;}.cnv-panel-zalo__qr svg{display:block;}.cnv-panel-zalo__corner{position:absolute;width:16px;height:16px;border:3px solid;border-radius:5px 0 0 0;}.cnv-panel-zalo__corner.tl{top:-3px;left:-3px;border-right:none;border-bottom:none;}.cnv-panel-zalo__corner.br{bottom:-3px;right:-3px;border-left:none;border-top:none;border-radius:0 0 5px 0;}.cnv-panel-zalo__title{font-size:14px;font-weight:800;}.cnv-panel-zalo__status{font-size:12.5px;font-weight:500;line-height:1.45;max-width:250px;}.cnv-panel-zalo__timer{font-size:11.5px;font-weight:700;opacity:.7;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center;gap:5px;}.cnv-panel-reward__list{}.cnv-panel-reward{padding:10px 0;display:flex;gap:10px;align-items:flex-start;}.cnv-panel-reward__main{min-width:0;flex:1;}.cnv-panel-reward__thumb{width:44px;height:44px;flex:none;border-radius:8px;object-fit:cover;background:rgba(127,127,127,.12);}.cnv-panel-reward__title{font-size:13px;font-weight:700;line-height:1.4;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;}.cnv-panel-reward__title--full{display:block;-webkit-line-clamp:none;overflow:visible;}.cnv-panel-reward__name{display:flex;align-items:flex-start;gap:4px;}.cnv-panel-reward__name>.cnv-panel-reward__title{flex:1 1 auto;min-width:0;}.cnv-panel-reward__info{display:none;flex:none;padding:0;margin-top:1px;border:none;background:transparent;color:inherit;opacity:.45;cursor:pointer;line-height:0;}.cnv-panel-reward__info:hover{opacity:.85;}.cnv-panel-reward__name--clamped .cnv-panel-reward__info{display:inline-flex;}.cnv-panel-reward__tags{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px;}.cnv-panel-reward__value{font-size:12px;font-weight:800;padding:3px 8px;border-radius:999px;white-space:nowrap;}.cnv-panel-reward__uses{font-size:11.5px;font-weight:600;padding:3px 8px;border-radius:999px;background:rgba(127,127,127,.14);white-space:nowrap;}.cnv-panel-reward__code{font-size:13px;font-weight:800;letter-spacing:.06em;margin-top:6px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;user-select:all;}.cnv-panel-reward__meta{font-size:11.5px;opacity:.7;margin-top:4px;line-height:1.45;}.cnv-panel-reward__code--big{font-size:20px;margin-top:10px;}.cnv-panel-reward__channel{font-size:12px;opacity:.8;margin-top:6px;line-height:1.45;}.cnv-panel-reward__show{width:auto;white-space:nowrap;}.cnv-panel-reward__more{width:100%;margin-top:10px;}.cnv-panel-balance{padding:2px 0 8px;}.cnv-panel-balance__label{font-size:11.5px;opacity:.66;margin-bottom:2px;}.cnv-panel-balance__row{display:flex;align-items:baseline;gap:6px;flex-wrap:wrap;}.cnv-panel-balance__num{font-size:26px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1;}.cnv-panel-balance__unit{font-size:12.5px;font-weight:700;opacity:.7;}.cnv-panel-rtabs{display:flex;gap:2px;margin:2px 0 2px;border-bottom:1px solid rgba(127,127,127,.22);}.cnv-panel-rcard{flex:0 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden;}.cnv-panel-rhead{flex:0 0 auto;}.cnv-panel-rlist{flex:1 1 auto;min-height:0;overflow:hidden auto;overscroll-behavior:contain;scrollbar-width:none;-ms-overflow-style:none;}.cnv-panel-rlist::-webkit-scrollbar{width:0;height:0;display:none;}.cnv-panel-rtab{flex:1;padding:9px 6px;margin-bottom:-1px;background:transparent;border:none;border-bottom:2px solid transparent;color:inherit;cursor:pointer;font-size:12.5px;font-weight:700;opacity:.6;transition:opacity .15s;font-family:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.cnv-panel-rtab:hover{opacity:.85;}.cnv-panel-rtab--on{opacity:1;font-weight:800;}.cnv-panel-reward__side{flex:0 0 auto;max-width:45%;display:flex;flex-direction:column;align-items:flex-end;gap:6px;}.cnv-panel-reward__price{font-size:12.5px;font-weight:800;font-variant-numeric:tabular-nums;text-align:right;}.cnv-panel-reward__cta{height:30px;padding:0 12px;font-size:12px;}.cnv-panel-redeem__cost{font-size:20px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1.1;}.cnv-panel-redeem__sub{font-size:11.5px;opacity:.66;line-height:1.45;}.cnv-panel-redeem__actions{display:flex;gap:8px;margin-top:12px;justify-content:center;}.cnv-panel-redeem__actions .cnv-panel-zalo__btn{flex:1;}.cnv-panel-redeem__actions .cnv-panel-zalo__btn:only-child{flex:0 0 auto;}.cnv-panel-block__list{}.cnv-panel-block{padding:11px 0;display:flex;gap:10px;align-items:flex-start;}.cnv-panel-block .cnv-panel-chip{margin-top:1px;}.cnv-panel-block__main{min-width:0;flex:1;}.cnv-panel-block__title{font-size:13px;font-weight:700;line-height:1.4;}.cnv-panel-block__desc{font-size:12px;line-height:1.5;opacity:.72;margin-top:3px;white-space:pre-line;}.cnv-panel-zalo__btn{height:36px;padding:0 16px;border:1px solid rgba(127,127,127,.3);border-radius:10px;background:transparent;color:inherit;font-size:12.5px;font-weight:700;cursor:pointer;transition:filter .15s;}.cnv-panel-zalo__btn:hover:not(:disabled){filter:brightness(1.1);}.cnv-panel-zalo__btn:disabled{opacity:.5;cursor:not-allowed;}.cnv-panel-zalo__overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:16px;}.cnv-panel-zalo__overlay-bubble{display:flex;flex-direction:column;align-items:center;gap:10px;text-align:center;padding:0 8px;max-width:100%;animation:cnv-panel-bubble-in .2s ease;}.cnv-panel-bubble-icon{width:40px;height:40px;border-radius:999px;display:flex;align-items:center;justify-content:center;box-shadow:inset 0 0 0 1px rgba(127,127,127,.22);}.cnv-panel-zalo__skeleton{border-radius:6px;background:rgba(127,127,127,.15);background-image:linear-gradient( 90deg,rgba(127,127,127,.15) 25%,rgba(127,127,127,.32) 37%,rgba(127,127,127,.15) 63% );background-size:400% 100%;animation:cnv-panel-shimmer 1.4s ease infinite;}@keyframes cnv-panel-shimmer{0%{background-position:100% 50%;}100%{background-position:0% 50%;}}@media (prefers-reduced-motion:reduce){.cnv-panel-zalo__skeleton{animation:none;}}');a=i.hostEl;const c=i.shadow;a.style.setProperty("display","none");const l=null!==(t=(null==n?void 0:n.useCustomZIndex)?$(n.zIndex):null)&&void 0!==t?t:j,b=null!==(e=$(l+600))&&void 0!==e?e:j;u=document.createElement("div"),u.className="cnv-panel-card",u.style.zIndex=String(b),u.addEventListener("animationend",n=>{"cnv-panel-out"===n.animationName&&Ye()}),u.style.borderRadius=Gn(null===(o=r.shapes)||void 0===o?void 0:o.container);const y=document.createElement("button");y.type="button",y.className="cnv-panel-close",y.setAttribute("aria-label","Đóng"),y.textContent="×",y.addEventListener("click",We),m=document.createElement("button"),m.type="button",m.className="cnv-panel-back",m.setAttribute("aria-label","Quay lại"),m.appendChild(ut('<path d="M15 6l-6 6 6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',15)),m.addEventListener("click",Cn(Fe));const _=document.createElement("div");v=_,_.className="cnv-panel-banner",s=document.createElement("img"),s.className="cnv-panel-banner__img",s.alt="",d=document.createElement("img"),d.className="cnv-panel-banner__brandicon",d.alt="";const w=document.createElement("div");w.className="cnv-panel-banner__brandchip",w.appendChild(d),f=document.createElement("div"),f.className="cnv-panel-banner__caption",p=document.createElement("div"),p.className="cnv-panel-banner__title",_.append(s,w,f,p),h=document.createElement("div"),h.className="cnv-panel-body",u.append(y,m,_,h),g=Ge(),g&&u.appendChild(g),c.appendChild(u),q(a)}function Ge(){if(r.hideBranding)return null;const n="DARK"===r.theme,t=document.createElement("div");t.className="cnv-panel-footer",t.style.backgroundColor=n?"#181C32":"#FFFFFF",t.style.borderTop=n?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2",t.style.color=n?"rgba(255,255,255,.62)":"rgba(24,28,50,.58)",t.appendChild(document.createTextNode("Cung cấp bởi "));const e=document.createElement("span");return e.className="cnv-panel-footer__brand",e.textContent="CNV CDP",t.appendChild(e),t}function Ze(n){if(!u)return;const{side:t,sideSpacingPx:e,bottomSpacingPx:o}=H(n,F());u.style.left="left"===t?e+"px":"auto",u.style.right="right"===t?e+"px":"auto";const r=o+48+24;u.style.bottom=r+"px",u.style.maxHeight=`calc(100vh - ${r+16}px)`,u.style.transformOrigin="left"===t?"left bottom":"right bottom"}function We(){a&&y&&(y=!1,Ue(),k=!1,_t(),A=!1,S=null,document.removeEventListener("keydown",_n),Qe("cnv:panel:closed"),u&&!t(()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,!1)?(u.classList.add(Un),yn=setTimeout(Ye,320)):Ye())}function Ye(){null!==yn&&(clearTimeout(yn),yn=null),null==u||u.classList.remove(Un),null==a||a.style.setProperty("display","none")}function Je(){null!==yn&&(clearTimeout(yn),yn=null),null==u||u.classList.remove(Un)}function Qe(t){n(()=>window.dispatchEvent(new CustomEvent(t)))}const Xe=t=>{n(()=>{var n;const e=t.detail;var r;y?We():(qe(r=null!==(n=null==e?void 0:e.config)&&void 0!==n?n:null),a&&(Je(),Ze(r),a.style.setProperty("display","block"),y=!0,Ne(),Nn(),!zn()||U||G||(G=!0,o.fetchPanelTiers().then(n=>{G=!1,n&&n.tiers.length&&(U=n,y&&Ne())}).catch(()=>{G=!1})),document.addEventListener("keydown",_n),Qe("cnv:panel:opened")))})},no=t=>{n(()=>{const n=t.detail;_=(null==n?void 0:n.isMember)?{isMember:!0,points:n.points,rewardsAvailableCount:n.rewardsAvailableCount}:{isMember:!1},_.isMember||ze(),y&&Ne(),y&&Nn()})},to=3e5,eo=15e3,oo=6e4;let ro=null,io=!1,co=!1;function lo(){null!==ro&&(clearTimeout(ro),ro=null)}function ao(n){lo(),co||(ro=t(()=>setTimeout(fo,Math.max(0,n)),null))}function uo(n){ao(Math.max(eo,n-Date.now()-to))}function so(){lo(),qn(o.projectId),_={isMember:!1},ze(),Ne()}function fo(){if(lo(),co||io)return;const n=Hn(o.projectId);n&&(Date.now()>n.exp?so():(io=!0,o.refreshPanelSession(n.token).then(t=>{if(io=!1,co)return;const e=Hn(o.projectId);if(!e)return;if(e.token!==n.token)return void uo(e.exp);if("ok"===t.kind)return Kn(o.projectId,Object.assign(Object.assign({},e),{token:t.token,exp:t.exp})),void uo(t.exp);if("unauthorized"===t.kind)return void so();const r=e.exp-Date.now();r<=0?so():ao(Math.min(oo,r))}).catch(()=>{if(io=!1,co)return;const t=n.exp-Date.now();t>0&&ao(Math.min(oo,t))})))}function po(){if("visible"!==document.visibilityState)return;const n=Hn(o.projectId);n&&(Date.now()>n.exp?so():n.exp-Date.now()<=to?fo():uo(n.exp))}function ho(){const n=Hn(o.projectId);n&&(Date.now()>n.exp?qn(o.projectId):(uo(n.exp),_={isMember:!0},Ne(),o.restorePanelSession(n.token).then(t=>{if(co)return;if("unavailable"===t.kind)return;const e=Hn(o.projectId);e&&e.token===n.token&&("ok"===t.kind?(_={isMember:!0},Kn(o.projectId,Object.assign(Object.assign({},e),{fullName:t.session.fullName,level:t.session.level,xp:t.session.xp}))):(lo(),qn(o.projectId),_={isMember:!1},ze()),Ne())}).catch(()=>{})))}return window.addEventListener(Pn,Xe),window.addEventListener($n,no),document.addEventListener("visibilitychange",po),ho(),()=>{Ue(),co=!0,n(()=>{window.removeEventListener(Pn,Xe),window.removeEventListener($n,no),document.removeEventListener("visibilitychange",po),lo(),document.removeEventListener("keydown",_n),Je(),null==a||a.remove()})}}catch(vo){return()=>{}}}const Ut={path:"/config",timeoutMs:4e3,ttlMs:3e5};function Vt(n,t){var e,o;const r=null!=t?t:Object.assign({enabled:!0},Ut);return void 0===n?Object.assign({},r):!0===n?Object.assign(Object.assign({},r),{enabled:!0}):!1===n?Object.assign(Object.assign({},r),{enabled:!1}):{enabled:null===(e=n.enabled)||void 0===e||e,path:null!==(o=n.path)&&void 0!==o?o:r.path,timeoutMs:"number"==typeof n.timeoutMs?n.timeoutMs:r.timeoutMs,ttlMs:"number"==typeof n.ttlMs?n.ttlMs:r.ttlMs}}function Ht(n){return"_cnv_cfg_"+n}function Kt(n){const t=gn(Ht(n));if(!t)return null;try{const n=JSON.parse(t);return n&&"object"==typeof n&&n.envelope?n:null}catch(n){return null}}function qt(n,t,e){try{const o={etag:t,envelope:e,fetchedAt:Date.now()};bn(Ht(n),JSON.stringify(o))}catch(n){}}function Gt(n){const t=Kt(n);return!t||!1!==(null===(o=null==(e=t.envelope)?void 0:e.zaloQrLogin)||void 0===o?void 0:o.enabled);var e,o}const Zt=["gclid","fbclid","ttclid","msclkid","dclid"],Wt=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function Yt(){const n=t(()=>window.location.href,"");let e="",o="",r="";if(n)try{const t=new URL(n);e=t.pathname,o=t.search,r=t.hash}catch(n){}return{url:n,path:e,search:o,hash:r,title:t(()=>document.title,""),referrer:t(()=>document.referrer,"")}}function Jt(n,e=!0){const o=t(()=>window.location.search,"");if(!o)return;let r;try{r=new URLSearchParams(o)}catch(n){return}const i={};let c=!1;for(const[n,t]of Wt){const e=r.get(n);e&&e.length>0&&(i[t]=e,c=!0)}if(e){const n={};for(const t of Zt){const e=r.get(t);e&&e.length>0&&(n[t]=e)}Object.keys(n).length>0&&(i.clickIds=n,c=!0)}return c?i:void 0}function Qt(n){var t,e;let o="@cnv-vn/track",r="0.0.0-dev";try{o="@cnv-vn/track"}catch(n){}try{r="0.3.0-beta.8"}catch(n){}return{name:null!==(t=null==n?void 0:n.name)&&void 0!==t?t:o,version:null!==(e=null==n?void 0:n.version)&&void 0!==e?e:r}}function Xt(n){if(n)try{const t=new URL(n);if("http:"!==t.protocol&&"https:"!==t.protocol)return;return t.origin+t.pathname}catch(n){return}}const ne=256;function te(n,t){if("string"!=typeof n)return;const e=n.trim();return e?e.length>t?e.slice(0,t):e:void 0}function ee(n){return"_cnv_ft_"+n}function oe(n){const e=gn(ee(n));if(!e)return null;const o=t(()=>(n=>{if(!n||"object"!=typeof n)return null;const t=n;if("number"!=typeof t.ts||!Number.isFinite(t.ts))return null;const e={ts:t.ts},o=te(t.source,ne);o&&(e.source=o);const r=te(t.medium,ne);r&&(e.medium=r);const i=te(t.name,ne);i&&(e.name=i);const c=te(t.term,ne);c&&(e.term=c);const l=te(t.content,ne);l&&(e.content=l);const a=te(t.id,ne);a&&(e.id=a);const u=te(t.referrer,1024);u&&(e.referrer=u);const s=te(t.landingPage,1024);if(s&&(e.landingPage=s),t.clickIds&&"object"==typeof t.clickIds){const n={};for(const[e,o]of Object.entries(t.clickIds)){if(Object.keys(n).length>=8)break;const t=te(e,ne),r=te(o,ne);t&&r&&(n[t]=r)}Object.keys(n).length>0&&(e.clickIds=n)}return 1===Object.keys(e).length?null:e})(JSON.parse(e)),null);if(!o)return yn(ee(n)),null;const r=Date.now()-o.ts;return r>63072e6||r<-864e5?(yn(ee(n)),null):o}function re(n,t=!0){const e={first_seen_at:n.ts};return n.source&&(e.utm_source=n.source),n.medium&&(e.utm_medium=n.medium),n.name&&(e.utm_campaign=n.name),n.term&&(e.utm_term=n.term),n.content&&(e.utm_content=n.content),n.id&&(e.utm_id=n.id),n.clickIds&&t&&(e.click_ids=n.clickIds),n.referrer&&(e.referrer=n.referrer),n.landingPage&&(e.landing_page=n.landingPage),e}const ie="_cnv_cid";function ce(n={}){const t=hn(ie),e=gn(ie);let o=null;return Cn(t)?o=t:Cn(e)&&(o=e),o||(o=kn()),le(o,n),o}function le(n,t={}){var e;vn(ie,n,{domain:t.cookieDomain,maxAgeDays:null!==(e=t.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),bn(ie,n)}const ae="1.0";function ue(){return(new Date).toISOString()}function se(n,t){var e;const o=null!==(e=t.timestamp)&&void 0!==e?e:ue(),r=Object.assign(Object.assign({},t.context),{projectId:t.projectId,schemaVersion:ae}),i={type:n,messageId:kn(),anonymousId:t.anonymousId,timestamp:o,originalTimestamp:o,context:r};return t.userId&&(i.userId=t.userId),t.sessionId&&(i.sessionId=t.sessionId),t.integrations&&(i.integrations=t.integrations),i}const de="_cnv_sid";function fe(n){if(!n)return null;const t=n.lastIndexOf(".");if(t<0)return null;const e=n.slice(0,t),o=Number(n.slice(t+1));return!Cn(e)||!Number.isFinite(o)||o<=0?null:{id:e,lastActivity:o}}function pe(n={}){const t=Date.now(),e=(n=>{var t;return 6e4*(null!==(t=n.timeoutMinutes)&&void 0!==t?t:30)})(n),o=fe(hn(de)),r=fe((n=>{if(!_n())return null;try{return sessionStorage.getItem(n)}catch(n){return null}})(de));let i=null;for(const n of[o,r])n&&(t-n.lastActivity>e||(!i||n.lastActivity>i.lastActivity)&&(i=n));const c=i?{id:i.id,lastActivity:t}:{id:kn(),lastActivity:t};return he(c,n),c.id}function he(n,t={}){var e;const o=(n=>`${n.id}.${n.lastActivity}`)(n),r=null!==(e=t.timeoutMinutes)&&void 0!==e?e:30;vn(de,o,{domain:t.cookieDomain,maxAgeDays:r/1440,sameSite:"Lax"}),((n,t)=>{if(!_n())return!1;try{return sessionStorage.setItem(n,t),!0}catch(n){return!1}})(de,o)}class ve{constructor(n){var t,e;Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"storageKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"flushing",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"onlineHandler",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.storageKey=null!==(t=n.storageKey)&&void 0!==t?t:"_cnv_rq",this.maxMessages=null!==(e=n.maxMessages)&&void 0!==e?e:100,this.installOnlineListener()}stash(n){if(n&&0!==n.length)try{const t=this.read();for(t.push(n);t.length>1&&me(t)>this.maxMessages;)t.shift();this.write(t),this.config.debug&&console.log("[cnv-track] retry queued",n.length,"buffered",me(t))}catch(n){}}flush(){if(this.flushing||"undefined"!=typeof navigator&&!1===navigator.onLine)return Promise.resolve();const n=this.read();if(0===n.length)return Promise.resolve();this.flushing=!0,this.write([]);const t=()=>{this.flushing=!1};return n.reduce((n,t)=>n.then(()=>this.config.resend(t)),Promise.resolve()).then(t,t)}size(){return me(this.read())}clear(){try{yn(this.storageKey)}catch(n){}}destroy(){if(this.onlineHandler){try{window.removeEventListener("online",this.onlineHandler)}catch(n){}this.onlineHandler=null}}installOnlineListener(){if("undefined"==typeof window)return;const n=()=>{this.flush()};try{window.addEventListener("online",n),this.onlineHandler=n}catch(n){}}read(){const n=gn(this.storageKey);if(!n)return[];try{const t=JSON.parse(n);return Array.isArray(t)?t.filter(n=>Array.isArray(n)&&n.length>0):[]}catch(n){return[]}}write(n){0!==n.length?bn(this.storageKey,JSON.stringify(n)):yn(this.storageKey)}}function me(n){let t=0;for(const e of n)t+=e.length;return t}class ge{constructor(n){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"timer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"retryQueue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.retryQueue=new ve({debug:n.debug,resend:n=>this.send(n)}),this.installPageLifecycleHandlers(),this.retryQueue.flush()}setConfig(n){this.config=Object.assign(Object.assign({},this.config),n)}enqueue(n){this.destroyed||(this.buffer.push(n),this.buffer.length>=this.config.flushAt?this.flush():this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.flush()},this.config.flushInterval)))}flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),0===this.buffer.length)return Promise.resolve();const n=this.buffer;return this.buffer=[],this.send(n)}bufferedCount(){return this.buffer.length}destroy(){this.destroyed||(this.destroyed=!0,this.timer&&(clearTimeout(this.timer),this.timer=null),this.uninstallPageLifecycleHandlers(),this.retryQueue.destroy())}send(n){try{return this.config.useBatch?this.sendBatch(n):Promise.all(n.map(n=>this.sendSingle(n))).then(()=>{})}catch(n){return this.config.debug&&console.warn("[cnv-track] send failed synchronously; dropped batch",n),Promise.resolve()}}sendBatch(n){var t;const e=ue(),o={batch:n.map(n=>be(n,e)),context:Object.assign(Object.assign({},null!==(t=this.config.batchContext)&&void 0!==t?t:{}),{projectId:this.config.projectId,sentAt:e}),sentAt:e};return this.post(this.batchUrl(),o,n)}sendSingle(n){const t=be(n,ue());return this.post(this.singleUrl(n.type),t,[n])}batchUrl(){return this.config.endpoint+this.config.batchPath+"?projectId="+encodeURIComponent(this.config.projectId)}singleUrl(n){const t=this.config.singlePath.replace("{type}",n);return this.config.endpoint+t+"?projectId="+encodeURIComponent(this.config.projectId)}post(n,t,e){const o=JSON.stringify(t),r=((n,t)=>{try{return new Blob([n],{type:t})}catch(n){return null}})(o,this.config.contentType),i=r?r.size:(n=>{try{return new Blob([n]).size}catch(t){return n.length}})(o),c=i>65536?null:e;return c&&"undefined"!=typeof navigator&&!1===navigator.onLine?(this.retryQueue.stash(c),this.config.debug&&console.log("[cnv-track] offline; queued for retry",n),Promise.resolve()):r&&this.sendViaBeacon(n,r)?(this.config.debug&&console.log("[cnv-track] beacon",n),Promise.resolve()):this.sendViaFetch(n,o,c)}sendViaBeacon(n,t){if("undefined"==typeof navigator||"function"!=typeof navigator.sendBeacon)return!1;if(t.size>65536)return!1;try{return navigator.sendBeacon(n,t)}catch(n){return!1}}sendViaFetch(n,t,e){return"function"!=typeof fetch?(this.config.debug&&console.warn("[cnv-track] no transport available; queued for retry"),e&&this.retryQueue.stash(e),Promise.resolve()):fetch(n,{method:"POST",headers:{"Content-Type":this.config.contentType},body:t,keepalive:!0,credentials:"omit",mode:"cors"}).then(t=>{this.config.debug&&console.log("[cnv-track] fetch flushed",n,t.status)}).catch(t=>{this.config.debug&&console.warn("[cnv-track] flush failed; queued for retry",n,t),e&&this.retryQueue.stash(e)})}installPageLifecycleHandlers(){if("undefined"==typeof window||"undefined"==typeof document)return;const n=()=>{this.flush()},t=()=>{"hidden"===document.visibilityState&&this.flush()};try{window.addEventListener("pagehide",n),document.addEventListener("visibilitychange",t),this.handlers={pagehide:n,visibility:t}}catch(n){}}uninstallPageLifecycleHandlers(){if(this.handlers){try{window.removeEventListener("pagehide",this.handlers.pagehide),document.removeEventListener("visibilitychange",this.handlers.visibility)}catch(n){}this.handlers=null}}}function be(n,t){return Object.assign(Object.assign({},n),{sentAt:t})}const ye="_cnv_uid",_e="_cnv_traits";function we(){return hn(ye)||gn(ye)}const xe={endpoint:"https://tracking.cnvcdp.com/js/v1",batchPath:"/batch",singlePath:"/{type}",useBatch:!0,contentType:"text/plain",debug:!1,allowAdTracking:!0,cookieMaxAgeDays:730,sessionTimeoutMinutes:30,flushAt:20,flushInterval:5e3,autoPageview:!0,autotrack:!1,integrations:{},remoteConfig:Vt(void 0)},ke={analytics:!0,marketing:!0};function Ae(n,t){if(!Array.isArray(t)||0===t.length)return;const e=t;try{switch(e[0]){case"init":n.init(e[1],e[2]);break;case"pageview":n.pageview(e[1],e[2]);break;case"page":n.page(e[1],e[2]);break;case"screen":n.screen(e[1],e[2]);break;case"track":n.track(e[1],e[2]);break;case"identify":n.identify(e[1],e[2]);break;case"alias":n.alias(e[1],e[2]);break;case"group":n.group(e[1],e[2]);break;case"reset":n.reset();break;case"flush":n.flush();break;case"consent":n.consent(e[1]);break;case"set":n.set(e[1])}}catch(n){}}const Ce="0.3.0-beta.8",Me="@cnv-vn/track",Oe=function(){let l=null,a=Object.assign({},xe),u=Object.assign({},ke),s=null,d=!1,f=null;function p(n,t){let o=null,r=null;return{apply(i,c){o&&null!==c&&c===r||(o=e(o),r=c,i&&(o=n(t(),i)))},dispose(){o=e(o),r=null}}}let h=null;const v=()=>h,m=p(x,v),g=p(Y,v),b=p($t,v);function y(n){const t=Object.assign({},a);return n?(void 0!==n.endpoint&&(t.endpoint=(e=n.endpoint).endsWith("/")?e.slice(0,-1):e),void 0!==n.batchPath&&(t.batchPath=n.batchPath),void 0!==n.singlePath&&(t.singlePath=n.singlePath),void 0!==n.useBatch&&(t.useBatch=n.useBatch),void 0!==n.contentType&&(t.contentType=n.contentType),void 0!==n.debug&&(t.debug=n.debug),void 0!==n.allowAdTracking&&(t.allowAdTracking=n.allowAdTracking),void 0!==n.cookieDomain&&(t.cookieDomain=n.cookieDomain),void 0!==n.cookieMaxAgeDays&&(t.cookieMaxAgeDays=n.cookieMaxAgeDays),void 0!==n.sessionTimeoutMinutes&&(t.sessionTimeoutMinutes=n.sessionTimeoutMinutes),void 0!==n.flushAt&&(t.flushAt=n.flushAt),void 0!==n.flushInterval&&(t.flushInterval=n.flushInterval),void 0!==n.autoPageview&&(t.autoPageview=n.autoPageview),void 0!==n.autotrack&&(t.autotrack=n.autotrack),void 0!==n.integrations&&(t.integrations=n.integrations),void 0!==n.remoteConfig&&(t.remoteConfig=Vt(n.remoteConfig,a.remoteConfig)),t):t;var e}function _(){return s||(s=new ge({endpoint:a.endpoint,batchPath:a.batchPath,singlePath:a.singlePath,useBatch:a.useBatch,contentType:a.contentType,flushAt:a.flushAt,flushInterval:a.flushInterval,projectId:null!=l?l:"",debug:a.debug}),s)}function w(){var n;if(!l)return null;const e=((n={})=>{var e;const o={page:Yt(),screen:{width:t(()=>window.screen.width,0),height:t(()=>window.screen.height,0),density:t(()=>window.devicePixelRatio||1,1)},locale:t(()=>navigator.language||"",""),timezone:t(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:t(()=>navigator.userAgent||"",""),library:Qt(n.library)},r=Jt(0,null===(e=n.allowAdTracking)||void 0===e||e);return r&&(o.campaign=r),o})({allowAdTracking:a.allowAdTracking});return u.analytics&&u.marketing||(e.consent=Object.assign({},u)),{anonymousId:ce({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),sessionId:pe({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),userId:null!==(n=we())&&void 0!==n?n:void 0,context:e,projectId:l,integrations:Object.keys(a.integrations).length>0?a.integrations:void 0}}function k(n){a.debug&&console.warn(`[cnv-track] ${n}() called before init()`)}function A(n,t){try{const e=w();if(!e)return k("pageview");(n=>{const t=oe(n.projectId);t&&(n.context.firstTouch=re(t,a.allowAdTracking))})(e);const o=((n,t,e)=>{const o=se("page",e);return n&&(o.name=n),o.properties=null!=t?t:{},o})(n,((n,t)=>{const e={};return n&&(n.url&&(e.url=n.url),n.path&&(e.path=n.path),n.title&&(e.title=n.title),n.referrer&&(e.referrer=n.referrer),n.search&&(e.search=n.search)),Object.assign(Object.assign({},e),null!=t?t:{})})(e.context.page,t),e);_().enqueue(o)}catch(n){}}function C(n,t){A(n,t)}function M(n,t){try{if("string"!=typeof n||0===n.length)return;const e=w();if(!e)return k("track");const o=((n,t,e)=>{const o=se("track",e);return o.event=n,o.properties=null!=t?t:{},o})(n,t,e);_().enqueue(o)}catch(n){}}function O(n,t){try{if("string"!=typeof n||0===n.length)return;((n,t,e={})=>{var o,r;if(n&&(vn(ye,n,{domain:e.cookieDomain,maxAgeDays:null!==(o=e.cookieMaxAgeDays)&&void 0!==o?o:730,sameSite:"Lax"}),bn(ye,n),null!=t)){const n=null!==(r=(()=>{const n=gn(_e);if(!n)return null;try{const t=JSON.parse(n);return t&&"object"==typeof t&&!Array.isArray(t)?t:null}catch(n){return null}})())&&void 0!==r?r:{},e=Object.assign(Object.assign({},n),t);try{bn(_e,JSON.stringify(e))}catch(n){}}})(n,t,{cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays});const e=w();if(!e)return k("identify");const o=((n,t,e)=>{var o;const r=se("identify",e);return n&&(r.userId=n),r.traits=null!==(o=t)&&void 0!==o?o:{},r})(n,t,e);_().enqueue(o)}catch(n){}}function S(n,t){}return{get initialized(){return d},get projectId(){return l},get endpoint(){return a.endpoint},isZaloQrLoginEnabled:()=>!!l&&Gt(l),get consentGranted(){return u.analytics&&u.marketing},init(p,v){var w,k;try{if(!p||"string"!=typeof p)return;a=y(v),(null==v?void 0:v.consent)&&(u=Object.assign(Object.assign({},u),v.consent)),l=p,s&&s.destroy(),s=null,_(),d=!0,ce({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),pe({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),((n,e=!0,o)=>{const r=oe(n);if(r)return r;const i=Jt(0,e),c=(n=>{const e=t(()=>document.referrer,"");if(e){try{const o=new URL(e).host;if(o===t(()=>window.location.host,""))return;const r=n?n.replace(/^\./,"").toLowerCase():"";if(r){const n=o.toLowerCase();if(n===r||n.endsWith("."+r))return}}catch(n){return}return Xt(e)}})(o);if(!i&&!c)return null;const l=Object.assign(Object.assign({},null!=i?i:{}),{referrer:c,landingPage:Xt(t(()=>window.location.href,"")),ts:Date.now()});bn(ee(n),JSON.stringify(l))})(p,a.allowAdTracking,a.cookieDomain),a.autoPageview&&A(),f=e(f);const I={page(n,t){return C(n,t)},track(n,t){return M(n,t)},loginWithZalo(n){return Ln({projectId:l,endpoint:a.endpoint,zaloQrLoginEnabled:!!l&&Gt(l),consentGranted:u.analytics&&u.marketing,identify:O,alias:S,getUserId:we,getAttribution(){const n=l?oe(l):null;return n?re(n,a.allowAdTracking):null},getAnonymousId(){return ce({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays})},getSessionId(){return pe({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes})}},n)},projectId:l,restorePanelSession(n){return l?function(n,t,e){return J(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Mn):null;try{const r=yield fetch(En(n,"/panel/session",t),{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0});if(401===r.status||403===r.status)return{kind:"unauthorized"};if(!r.ok)return{kind:"unavailable"};const i=yield r.json();return i&&"number"==typeof i.contactId?{kind:"ok",session:{contactId:i.contactId,fullName:"string"==typeof i.fullName?i.fullName:void 0,level:"string"==typeof i.level?i.level:void 0,xp:"number"==typeof i.xp?i.xp:void 0}}:{kind:"unavailable"}}catch(n){return{kind:"unavailable"}}finally{r&&clearTimeout(r)}})}(a.endpoint,l,n):Promise.resolve({kind:"unavailable"})},refreshPanelSession(n){return l?function(n,t,e){return J(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Mn):null;try{const r=yield fetch(En(n,"/panel/session/refresh",t),{method:"POST",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0});if(401===r.status||403===r.status)return{kind:"unauthorized"};if(!r.ok)return{kind:"unavailable"};const l=yield r.json();return l&&"string"==typeof l.panelSessionToken&&l.panelSessionToken&&"number"==typeof l.panelSessionExp?{kind:"ok",token:l.panelSessionToken,exp:(i=l.panelSessionExpiresInMs,c=l.panelSessionExp,"number"==typeof i&&i>0?Date.now()+i:c)}:{kind:"unavailable"}}catch(n){return{kind:"unavailable"}}finally{r&&clearTimeout(r)}var i,c})}(a.endpoint,l,n):Promise.resolve({kind:"unavailable"})},fetchRewardsSummary(n,t,e){return l?function(n,t,e){return J(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),On):null,l=Nn(i,r);try{const r=En(n,"/panel/rewards-summary",t),c=o>1?`${r}${r.includes("?")?"&":"?"}page=${o}`:r,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:i?i.signal:void 0});return l.ok?(n=>{if(!n||"object"!=typeof n)return null;const t=n,e=Array.isArray(t.rewards)?t.rewards.filter(n=>!!n&&"object"==typeof n).map(Fn):[];return{points:"number"==typeof t.points&&Number.isFinite(t.points)?t.points:void 0,rewardsAvailableCount:"number"==typeof t.rewardsAvailableCount&&Number.isFinite(t.rewardsAvailableCount)?t.rewardsAvailableCount:void 0,rewards:e,tier:t.tier&&"object"==typeof t.tier?Bn(t.tier):void 0}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,l,n,t,e):Promise.resolve(null)},fetchPanelTiers(){return l?function(n,t){return J(this,void 0,void 0,function*(){const e="undefined"!=typeof AbortController?new AbortController:null,o=e?setTimeout(()=>e.abort(),On):null;try{const o=yield fetch(En(n,"/panel/tiers",t),{method:"GET",credentials:"omit",mode:"cors",signal:e?e.signal:void 0});return o.ok?(n=>{if(!n||"object"!=typeof n)return null;const t=n,e=Array.isArray(t.tiers)?t.tiers.filter(n=>!!n&&"object"==typeof n).map(Rn):[];return{applyFor:"SPENDING"===t.applyFor||"POINTS"===t.applyFor?t.applyFor:void 0,thresholdKind:"RELATIVE"===t.thresholdKind||"ABSOLUTE"===t.thresholdKind?t.thresholdKind:void 0,totalTiers:jn(t.totalTiers),tiers:e}})(yield o.json()):null}catch(n){return null}finally{o&&clearTimeout(o)}})}(a.endpoint,l):Promise.resolve(null)},fetchPointHistory(n,t){return l?function(n,t,e){return J(this,arguments,void 0,function*(n,t,e,o=1){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),On):null;try{const i=En(n,"/panel/point-history",t),c=o>1?`${i}${i.includes("?")?"&":"?"}page=${o}`:i,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:r?r.signal:void 0});return l.ok?(n=>{if(!n||"object"!=typeof n)return null;const t=n,e=Array.isArray(t.items)?t.items.filter(n=>!!n&&"object"==typeof n).map(zn):[];return{totalCount:"number"==typeof t.totalCount&&Number.isFinite(t.totalCount)?t.totalCount:void 0,items:e}})(yield l.json()):null}catch(n){return null}finally{i&&clearTimeout(i)}})}(a.endpoint,l,n,t):Promise.resolve(null)},fetchRedeemableRewards(n,t,e){return l?function(n,t,e){return J(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),On):null,l=Nn(i,r);try{const r=En(n,"/panel/redeemable-rewards",t),c=o>1?`${r}${r.includes("?")?"&":"?"}page=${o}`:r,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:i?i.signal:void 0});return l.ok?(n=>{if(!n||"object"!=typeof n)return null;const t=n,e=Array.isArray(t.rewards)?t.rewards.filter(n=>!!n&&"object"==typeof n).map(Tn):[];return{points:jn(t.points),total:jn(t.total),rewards:e}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,l,n,t,e):Promise.resolve(null)},redeemReward(n,t,e){return l?function(n,t,e,o,r){return J(this,void 0,void 0,function*(){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),25e3):null;try{const c=yield fetch(En(n,"/panel/redeem",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"Idempotency-Key":r},body:JSON.stringify(null!=o.campaignId?null!=o.redeemPoints&&o.redeemPoints>0?{campaignId:o.campaignId,redeemPoints:o.redeemPoints}:{campaignId:o.campaignId}:{rewardId:o.rewardId}),signal:i?i.signal:void 0}),a=yield c.json().then(n=>n&&"object"==typeof n?n:null).catch(()=>null);if(!c.ok)return{ok:!1,code:a?Dn(a,!0):null};const u=Dn(a,!1);return u?{ok:!1,code:u}:{ok:!0,result:(l=a,l?{code:"string"==typeof l.code?l.code:void 0,pointsSpent:jn(l.pointsSpent),pointsRemaining:jn(l.pointsRemaining),transactionId:"string"==typeof l.transactionId?l.transactionId:void 0}:{})}}catch(n){return{ok:!1,code:"UNCONFIRMED"}}finally{c&&clearTimeout(c)}var l})}(a.endpoint,l,n,t,e):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"})},useReward(n,t){return l?function(n,t,e,o){return J(this,void 0,void 0,function*(){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),25e3):null;try{const i=yield fetch(En(n,"/panel/rewards/use",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({redeemId:o}),signal:r?r.signal:void 0}),c=yield i.json().then(n=>n&&"object"==typeof n?n:null).catch(()=>null);if(!i.ok)return{ok:!1,code:c?Dn(c,!0):null};const l=Dn(c,!1);if(l)return{ok:!1,code:l};const a=c&&"string"==typeof c.code&&c.code?c.code:null;return a?{ok:!0,result:{code:a,usedAt:c&&"string"==typeof c.usedAt?c.usedAt:void 0,expiredAt:c&&"string"==typeof c.expiredAt?c.expiredAt:void 0}}:{ok:!1,code:"CODE_NOT_ISSUED"}}catch(n){return{ok:!1,code:"UNCONFIRMED"}}finally{i&&clearTimeout(i)}})}(a.endpoint,l,n,t):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"})}};if(h=I,a.autotrack){let t=a.autotrack;a.remoteConfig.enabled&&"object"==typeof t&&t.buttonTracking&&(t=Object.assign(Object.assign({},t),{buttonTracking:void 0})),f=function(t,e){const l=void 0===(a=e)||!1===a?Object.assign(Object.assign({},D),{searchParams:z}):!0===a?Object.assign(Object.assign({},T),{searchParams:z}):{spa:null===(u=a.spa)||void 0===u||u,outboundClicks:null===(s=a.outboundClicks)||void 0===s||s,scroll:null===(d=a.scroll)||void 0===d||d,downloads:null===(f=a.downloads)||void 0===f||f,siteSearch:null===(p=a.siteSearch)||void 0===p||p,downloadExtensions:a.downloadExtensions,searchParams:null!==(h=a.searchParams)&&void 0!==h?h:z,buttonTracking:a.buttonTracking};var a,u,s,d,f,p,h;l.outboundClicks=!1,l.downloads=!1,l.scroll=!1,l.siteSearch=!1;const v=[];let m=null;function g(e){if(l.siteSearch)try{const o=null!=e?e:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(n){return""}})();if(o===m)return;m=o;const r=((n,t=z)=>{try{if(!n){if("undefined"==typeof location)return null;n=location.href}const e=n instanceof URL?n:new URL(n,(()=>{try{return"undefined"!=typeof location?location.href:"http://localhost/"}catch(n){return"http://localhost/"}})());if(!e.search)return null;for(const n of t){const t=e.searchParams.get(n);if(null===t)continue;const o=t.trim();if(0!==o.length)return{query:o,param:n}}return null}catch(n){return null}})(o,l.searchParams);r&&n(()=>t.track("Site Searched",{query:r.query,param:r.param}))}catch(n){}}if(l.outboundClicks||l.downloads){const e=(n=>{var t;if("undefined"==typeof document)return()=>{};const e=new Set((null!==(t=n.downloadExtensions)&&void 0!==t?t:o).map(n=>n.toLowerCase())),l=!!n.onOutbound,a=!!n.onDownload;if(!l&&!a)return()=>{};function u(t){var o,u;try{if(0!==t.button)return;if(t.defaultPrevented)return;const s=(n=>{const t="function"==typeof n.composedPath?n.composedPath():[];if(t.length>0)for(const n of t)if(r(n))return n;let e=n.target;for(;e;){if(r(e))return e;e=e.parentNode}return null})(t);if(!s)return;const d=s.getAttribute("href");if(!d)return;if(/^(javascript:|mailto:|tel:|sms:)/i.test(d))return;if(d.startsWith("#"))return;const f=(n=>{try{return new URL(n,location.href)}catch(n){return null}})(d);if(!f)return;let p=!1;if(a){const t=s.hasAttribute("download"),r=(n=>{const t=i(n),e=t.lastIndexOf(".");return e<=0||e===t.length-1?null:t.slice(e+1).toLowerCase()})(f.pathname);(t||r&&e.has(r))&&(p=!0,null===(o=n.onDownload)||void 0===o||o.call(n,{url:f.href,fileName:i(f.pathname),fileExtension:null!=r?r:"",text:c(s)}))}l&&!p&&f.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(n){return""}})()&&f.host&&(null===(u=n.onOutbound)||void 0===u||u.call(n,{url:f.href,host:f.host,text:c(s),target:s.target||"_self"}))}catch(n){}}try{document.addEventListener("click",u,!0)}catch(n){return()=>{}}return()=>{try{document.removeEventListener("click",u,!0)}catch(n){}}})({downloadExtensions:l.downloadExtensions,onOutbound:l.outboundClicks?e=>n(()=>t.track("Clicked",e)):void 0,onDownload:l.downloads?e=>n(()=>t.track("File Downloaded",e)):void 0});v.push(e)}l.buttonTracking&&l.buttonTracking.rules&&l.buttonTracking.rules.length>0&&v.push(x(t,l.buttonTracking));let b=null;if(l.scroll&&(b=(n=>{if("undefined"==typeof window||"undefined"==typeof document)return{destroy(){},reset(){}};let t=!1,e=null,o=!1;function r(){if(e=null,!o&&!t)try{const e=document.documentElement,o=document.body,r=Math.max(e?e.scrollHeight:0,o?o.scrollHeight:0),i=Math.max(e?e.clientHeight:0,window.innerHeight||0);if(r<=i)return t=!0,c(),void n(90);((window.scrollY||(e?e.scrollTop:0)||0)+i)/r>=.9&&(t=!0,c(),n(90))}catch(n){}}function i(){if(null===e)try{e=window.requestAnimationFrame(r)}catch(n){r()}}function c(){try{window.removeEventListener("scroll",i),null!==e&&window.cancelAnimationFrame(e),e=null}catch(n){}}try{window.addEventListener("scroll",i,{passive:!0})}catch(n){try{window.addEventListener("scroll",i)}catch(n){}}try{window.requestAnimationFrame(r)}catch(n){r()}return{destroy(){o=!0,c()},reset(){if(!o){t=!1;try{window.addEventListener("scroll",i,{passive:!0})}catch(n){try{window.addEventListener("scroll",i)}catch(n){}}try{window.requestAnimationFrame(r)}catch(n){r()}}}}})(e=>{n(()=>t.track("Scrolled",{percent:e}))}),v.push(()=>null==b?void 0:b.destroy())),l.spa){const e=[],o=E(o=>{const r=setTimeout(()=>{const o=e.indexOf(r);-1!==o&&e.splice(o,1),n(()=>t.page())},0);e.push(r),null==b||b.reset(),g(o)});v.push(()=>{for(let n=0;n<e.length;n++)clearTimeout(e[n]);e.length=0,o()})}return g(),()=>{for(;v.length>0;){const n=v.pop();try{null==n||n()}catch(n){}}m=null}}(I,t)}if(m.dispose(),g.dispose(),b.dispose(),a.remoteConfig.enabled&&l){const n=n=>{var t,e,o,r;m.apply((n=>{const t=null==n?void 0:n.buttonTracking;if(!t||!1===t.enabled)return null;const e=Array.isArray(t.rules)?t.rules:[];return 0===e.length?null:{rules:e,globalThrottle:t.globalThrottle}})(n),null),g.apply((n=>{var t;const e=null===(t=null==n?void 0:n.launcher)||void 0===t?void 0:t.config;return e?"NONE"===e.deviceVisibility?null:e:null})(n),null!==(e=null===(t=null==n?void 0:n.launcher)||void 0===t?void 0:t.version)&&void 0!==e?e:null),b.apply((n=>{var t;const e=null===(t=null==n?void 0:n.panel)||void 0===t?void 0:t.config;return null!=e?e:null})(n),null!==(r=null===(o=null==n?void 0:n.panel)||void 0===o?void 0:o.version)&&void 0!==r?r:null)};n(null!==(k=null===(w=Kt(l))||void 0===w?void 0:w.envelope)&&void 0!==k?k:null),function(n){return J(this,void 0,void 0,function*(){if(!n.projectId)return{status:"error"};const t=Kt(n.projectId);if(t&&Date.now()-t.fetchedAt<n.ttlMs)return{status:"unchanged"};const e=yield function(n){return J(this,void 0,void 0,function*(){var t;if("function"!=typeof fetch)return null;const e=n.endpoint+n.path+"?projectId="+encodeURIComponent(n.projectId),o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),n.timeoutMs):null;try{const r={};n.etag&&(r["If-None-Match"]=n.etag);const i=yield fetch(e,{method:"GET",headers:r,credentials:"omit",mode:"cors",cache:"no-store",signal:o?o.signal:void 0});if(304===i.status)return{envelope:null,etag:null!==(t=n.etag)&&void 0!==t?t:"",notModified:!0};if(!i.ok)return null;const c=i.headers&&"function"==typeof i.headers.get?i.headers.get("ETag"):null;return{envelope:yield i.json(),etag:null!=c?c:"",notModified:!1}}catch(n){return null}finally{r&&clearTimeout(r)}})}({endpoint:n.endpoint,path:n.path,projectId:n.projectId,timeoutMs:n.timeoutMs,etag:null==t?void 0:t.etag});return e?e.notModified?(t&&qt(n.projectId,t.etag,t.envelope),{status:"unchanged"}):e.envelope?(qt(n.projectId,e.etag,e.envelope),{status:"updated",envelope:e.envelope}):{status:"error"}:{status:"error"}})}({endpoint:a.endpoint,path:a.remoteConfig.path,projectId:l,timeoutMs:a.remoteConfig.timeoutMs,ttlMs:a.remoteConfig.ttlMs}).then(t=>{"updated"===t.status&&n(t.envelope)}).catch(()=>{})}}catch(n){}},pageview:A,page:C,screen(n,t){},track:M,identify:O,alias:S,group(n,t){},reset(){try{((n={})=>{((n,t={})=>{var e;if(!pn)return!1;try{let o=`${encodeURIComponent(n)}=`;return o+=`; path=${null!==(e=t.path)&&void 0!==e?e:"/"}`,t.domain&&(o+=`; domain=${t.domain}`),o+="; max-age=0",o+="; expires=Thu, 01 Jan 1970 00:00:00 GMT",document.cookie=o,null===hn(n)}catch(n){return!1}})(ye,{domain:n.cookieDomain}),yn(ye),yn(_e)})({cookieDomain:a.cookieDomain}),((n={})=>{le(kn(),n)})({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),((n={})=>{he({id:kn(),lastActivity:Date.now()},n)})({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),l&&(n=>{yn(ee(n))})(l)}catch(n){}},flush(){try{s&&s.flush()}catch(n){}},consent(n){try{u=Object.assign(Object.assign({},u),n)}catch(n){}},set(n){try{a=y(n),n.consent&&(u=Object.assign(Object.assign({},u),n.consent)),s&&s.setConfig({endpoint:a.endpoint,batchPath:a.batchPath,singlePath:a.singlePath,useBatch:a.useBatch,contentType:a.contentType,flushAt:a.flushAt,flushInterval:a.flushInterval,debug:a.debug})}catch(n){}},destroy(){f=e(f),m.dispose(),g.dispose(),b.dispose(),h=null,s&&s.destroy(),s=null,d=!1,l=null,a=Object.assign({},xe),u=Object.assign({},ke)}}}();function Se(n){return Ln({projectId:Oe.projectId,endpoint:Oe.endpoint,zaloQrLoginEnabled:Oe.isZaloQrLoginEnabled(),consentGranted:Oe.consentGranted,identify:Oe.identify,alias:Oe.alias,getUserId:we},n)}"undefined"!=typeof window&&(n=>{if("undefined"==typeof window)return()=>{};const t=window.cnvQ;if(t&&t.__loaded)return()=>{};const e=window.cnvQ=null!=t?t:[],o=e.splice(0,e.length);e.push.bind(e),e.push=(...t)=>{for(const e of t)Ae(n,e);return e.length},e.__loaded=!0;for(const t of o)Ae(n,t)})(Oe);const Ie=Object.assign(Oe,{version:Ce,name:Me,schemaVersion:ae,loginWithZalo:Se});export{Me as NAME,ae as SCHEMA_VERSION,Ce as VERSION,In as ZaloQrLoginError,Ie as default,Se as loginWithZalo};
|
|
6
|
+
function n(n){try{n()}catch(n){}}function t(n,t){try{return n()}catch(n){return t}}function e(t){return t&&n(t),null}const o=["pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","rtf","zip","rar","7z","tar","gz","mp3","mp4","mov","wav","avi","mkv","dmg","exe","pkg","apk","msi","svg"];function r(n){return!!n&&"object"==typeof n&&1===n.nodeType&&"A"===n.tagName}function i(n){const t=n.lastIndexOf("/");return-1===t?n:n.slice(t+1)}function c(n){var t,e,o;let r=(null!==(t=n.textContent)&&void 0!==t?t:"").trim();return r||(r=(null!==(e=n.getAttribute("aria-label"))&&void 0!==e?e:"").trim()),r||(r=(null!==(o=n.getAttribute("title"))&&void 0!==o?o:"").trim()),r.length>200?r.slice(0,200):r}const l=200;function a(n){let t="";try{t=(n.textContent||"").replace(/\s+/g," ").trim(),t||(t=(n.getAttribute("aria-label")||"").trim()),t||(t=(n.getAttribute("title")||"").trim()),t=t.normalize("NFC")}catch(n){return""}return t.length>l?t.slice(0,l):t}function u(n){const t=!1!==n.caseInsensitive;if("regex"===n.mode)return{mode:"regex",needle:n.value,ci:t,re:_(n.value,t)};const e=n.value.normalize("NFC");return{mode:n.mode,needle:t?e.toLowerCase():e,ci:t,re:null}}function s(n,t){try{return n.matches(t)}catch(n){return!1}}function d(n){try{if("A"===n.tagName){const t=n.getAttribute("href");return t?y(t):null}const t=n.getAttribute("formaction");if(t)return y(t);const e=n.getAttribute("data-href");if(e)return y(e);const o=n.closest("form");if(o){const n=o.getAttribute("action");if(n)return y(n)}return null}catch(n){return null}}function f(n){return"regex"===n.mode?{mode:"regex",needle:n.value,re:_(n.value,!0)}:{mode:n.mode,needle:n.value.toLowerCase(),re:null}}function p(n){if("startsWith"===n.mode)return{mode:"startsWith",needle:n.value,re:null};const t="glob"===n.mode?"^"+n.value.replace(/[.+^${}()|[\]\\?]/g,"\\$&").replace(/\*/g,".*")+"$":n.value;return{mode:n.mode,needle:n.value,re:_(t,!1)}}function h(n,t){return"startsWith"===n.mode?0===t.indexOf(n.needle):!n.re||w(n.re,t)}const v=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,m=/\+?\d[\d\s().-]{7,}\d/g;function g(n){if(!n)return n;try{return n.replace(v,"[email]").replace(m,"[phone]")}catch(t){return n}}function b(n){return!!n&&"object"==typeof n&&1===n.nodeType}function y(n){try{return new URL(n,location.href).href}catch(t){return n}}function _(n,t){try{return!n||n.length>1e3?null:new RegExp(n,t?"i":"")}catch(n){return null}}function w(n,t){try{return n.test(t)}catch(n){return!1}}function x(t,e){if("undefined"==typeof document)return()=>{};const o=(n=>{const t=n.globalThrottle||{},e=[],o=n.rules||[];for(let n=0;n<o.length;n++){const r=o[n];if(!r||!1===r.enabled)continue;if(!r.match||!r.event)continue;const i=r.match,c=r.throttle||{};e.push({rule:r,elementSpec:k(r),selector:i.selector||null,text:i.text?u(i.text):null,dest:i.destinationUrl?f(i.destinationUrl):null,urlScope:r.urlScope?p(r.urlScope):null,dedupeWindowMs:O(c.dedupeWindowMs,O(t.dedupeWindowMs,500)),maxPerPageview:O(c.maxPerPageview,O(t.maxPerPageview,1/0)),samplingRate:S(O(c.samplingRate,O(t.samplingRate,1)))})}return e.sort((n,t)=>(n.rule.priority||0)-(t.rule.priority||0)),e})(e);if(0===o.length)return()=>{};const r=new WeakMap;let i=0;const c=n=>{let t=r.get(n);return void 0===t&&(t=++i,r.set(n,t)),String(t)},l=new Map,a=new Map;let s=M();function d(e){try{if(0!==e.button)return;const r=M();r!==s&&(s=r,a.clear(),l.clear());const i=(n=>{const t=[];try{const e="function"==typeof n.composedPath?n.composedPath():[];if(e&&e.length>0){for(const n of e)b(n)&&t.push(n);return t}let o=n.target;for(;o;)b(o)&&t.push(o),o=o.parentNode}catch(n){}return t})(e);if(0===i.length)return;const u=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(n){return""}})();for(let r=0;r<o.length;r++){const s=o[r];if(s.urlScope&&!h(s.urlScope,u))continue;let d=null;for(let n=0;n<i.length;n++)if(A(s,i[n])){d=i[n];break}if(!d)continue;const f=s.rule.id;if((a.get(f)||0)>=s.maxPerPageview)return;const p=f+"#"+c(d),v=Date.now(),m=l.get(p);if(void 0!==m&&v-m<s.dedupeWindowMs)return;if(s.samplingRate<1&&Math.random()>=s.samplingRate)return;l.set(p,v),a.set(f,(a.get(f)||0)+1);const g=C(s.rule,d,e);return void n(()=>t.track("clicked",g))}}catch(n){}}try{document.addEventListener("click",d,!0)}catch(n){return()=>{}}return()=>{try{document.removeEventListener("click",d,!0)}catch(n){}l.clear(),a.clear()}}function k(n){const t=n.match;return t.element?t.element:t.selector||t.id||t.dataAttr||t.classes&&t.classes.length>0||t.destinationUrl?"any":void 0}function A(n,t){if(!((n,t)=>{if(!t)return(n=>{const t=n.tagName;if("BUTTON"===t||"A"===t)return!0;if("INPUT"===t){const t=(n.getAttribute("type")||"").toLowerCase();return"submit"===t||"button"===t||"reset"===t}return"button"===n.getAttribute("role")})(n);if("any"===t)return!0;if("button"===t){const t=n.tagName;if("BUTTON"===t)return!0;if("INPUT"===t){const t=(n.getAttribute("type")||"").toLowerCase();return"submit"===t||"button"===t||"reset"===t}return"button"===n.getAttribute("role")}return"link"===t?"A"===n.tagName:s(n,t)})(t,n.elementSpec))return!1;const e=n.rule.match;return!(n.selector&&!s(t,n.selector)||void 0!==e.id&&!((n,t)=>n.id===t)(t,e.id)||e.classes&&e.classes.length>0&&!((n,t)=>{try{for(let e=0;e<t.length;e++)if(!n.classList.contains(t[e]))return!1;return!0}catch(n){return!1}})(t,e.classes)||e.dataAttr&&!((n,t,e)=>{try{return!!n.hasAttribute(t)&&(void 0===e||n.getAttribute(t)===e)}catch(n){return!1}})(t,e.dataAttr.name,e.dataAttr.value)||n.text&&!((n,t)=>{const e=a(n);if("regex"===t.mode)return!!t.re&&w(t.re,e);const o=t.ci?e.toLowerCase():e;return"exact"===t.mode?o===t.needle:"startsWith"===t.mode?0===o.indexOf(t.needle):-1!==o.indexOf(t.needle)})(t,n.text)||n.dest&&!((n,t)=>{const e=d(n);if(!e)return!1;if("regex"===t.mode)return!!t.re&&w(t.re,e);if("domain"===t.mode)try{return new URL(e).host.toLowerCase()===t.needle}catch(n){return!1}const o=e.toLowerCase();return"exact"===t.mode?o===t.needle:"startsWith"===t.mode?0===o.indexOf(t.needle):-1!==o.indexOf(t.needle)})(t,n.dest))}function C(n,t,e){const o={},r=n.event.staticProps;if(r)for(const n of Object.keys(r))o[n]=r[n];const i=n.capture;if(i)try{if(i.text){const n=g(a(t));n&&(o.text=n)}if(i.href){const n=d(t);n&&(o.href=n)}if(i.elementId&&t.id&&(o.element_id=t.id),i.classes&&(o.element_classes=Array.from(t.classList)),i.dataAttrs&&i.dataAttrs.length>0)for(let n=0;n<i.dataAttrs.length;n++){const e=i.dataAttrs[n],r=t.getAttribute(e);null!==r&&(o[e]=g(r))}if(i.valueFrom){const n=((n,t)=>{try{const e=n.querySelector(t.selector)||(n.parentElement?n.parentElement.querySelector(t.selector):null);if(!e)return null;const o=t.attr?e.getAttribute(t.attr):e.textContent||"";if(null===o)return null;const r=g(o.replace(/\s+/g," ").trim());return r.length>l?r.slice(0,l):r}catch(n){return null}})(t,i.valueFrom);null!==n&&(o[i.valueFrom.as]=n)}i.selectorPath&&(o.selector_path=((n,t=5)=>{try{const e=[];let o=n,r=0;for(;o&&1===o.nodeType&&r<t;){let n=o.tagName.toLowerCase();if(o.id){e.unshift(n+"#"+o.id);break}const t=Array.from(o.classList).slice(0,2).join(".");t&&(n+="."+t),e.unshift(n),o=o.parentElement,r++}return e.join(" > ")}catch(n){return""}})(t)),i.position&&(o.x=e.clientX,o.y=e.clientY)}catch(n){}return o.rule_id=n.id,n.name&&(o.rule_name=n.name),n.event&&n.event.name&&(o.event_name=n.event.name),o.tag=t.tagName.toLowerCase(),o}function M(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}function O(n,t){return"number"!=typeof n||isNaN(n)?t:n}function S(n){return n<0?0:n>1?1:n}const I="__cnvPatched";function E(n){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let t=N();function e(){try{const e=N();if(e===t)return;t=e,n(e)}catch(n){}}const o=history.pushState,r=history.replaceState,i=!0===o[I],c=!0===r[I];if(!i){function u(...n){o.apply(this,n),e()}u[I]=!0,history.pushState=u}if(!c){function s(...n){r.apply(this,n),e()}s[I]=!0,history.replaceState=s}const l=()=>e(),a=()=>e();try{window.addEventListener("popstate",l),window.addEventListener("hashchange",a)}catch(d){}return()=>{try{window.removeEventListener("popstate",l),window.removeEventListener("hashchange",a)}catch(n){}try{!i&&history.pushState[I]&&(history.pushState=o),!c&&history.replaceState[I]&&(history.replaceState=r)}catch(n){}}}function N(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}const z=["q","s","query","search","keyword"],T={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},D={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};const j=2147483e3,R="#6C5CE7",B="#FFFFFF";function F(){try{return"undefined"!=typeof window&&"function"==typeof window.matchMedia?window.matchMedia("(max-width: 768px)").matches:"undefined"!=typeof window&&"number"==typeof window.innerWidth&&window.innerWidth<=768}catch(n){return!1}}function L(n,t){return(n=>"string"==typeof n&&/^#([0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(n))(n)?n:t}function P(n){if("string"!=typeof n||0===n.trim().length)return!1;try{const t="undefined"!=typeof location?location.href:void 0,e=new URL(n,t);return"https:"===e.protocol||"http:"===e.protocol||"data:"===e.protocol&&/^data:image\//i.test(n.trim())}catch(n){return!1}}function $(n){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(Math.trunc(n),0),2147483647):null}function U(n,t=20){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(n,0),2e3):t}function V(n,t){const e=n.replace("#",""),o=3===e.length?e.replace(/(.)/g,"$1$1"):e;return`rgba(${parseInt(o.slice(0,2),16)}, ${parseInt(o.slice(2,4),16)}, ${parseInt(o.slice(4,6),16)}, ${t})`}function H(n,t){const e=t?null==n?void 0:n.placementMobile:null==n?void 0:n.placementDesktop;return{side:"LEFT"===(null==e?void 0:e.position)?"left":"right",sideSpacingPx:U(null==e?void 0:e.sideSpacing),bottomSpacingPx:U(null==e?void 0:e.bottomSpacing)}}function K(n,t){const e=document.createElement("div");e.setAttribute(n,"");const o=e.attachShadow({mode:"open"}),r=document.createElement("style");return r.textContent=t,o.appendChild(r),{hostEl:e,shadow:o}}function q(n){var t;(null!==(t=document.body)&&void 0!==t?t:document.documentElement).appendChild(n)}const G="cnv:panel:opened",Z="cnv:panel:closed";function W(n,t,e){if(e)n.innerHTML='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none"><path d="M6 6l12 12M18 6 6 18" stroke="currentColor" stroke-width="2.4" stroke-linecap="round"/></svg>';else if("CUSTOM"===t.iconType&&P(t.customIconUrl)){n.innerHTML="";const e=document.createElement("img");e.src=t.customIconUrl,e.alt="",n.appendChild(e)}else n.innerHTML=(n=>{switch(n){case"BAG_HEART":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M7 8V6a5 5 0 0 1 10 0v2" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="M4.5 8h15l-1 12.5a1.5 1.5 0 0 1-1.5 1.4H7a1.5 1.5 0 0 1-1.5-1.4L4.5 8Z" fill="currentColor"/><path d="M12 12.8c1-1.4 3.6-1 3.6 1 0 1.7-2.2 2.9-3.6 3.9-1.4-1-3.6-2.2-3.6-3.9 0-2 2.6-2.4 3.6-1Z" fill="#fff"/></svg>';case"TAG":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.6 3.4 20 10.8a2 2 0 0 1 0 2.8l-6.4 6.4a2 2 0 0 1-2.8 0L3.4 12.6A2 2 0 0 1 2.8 11l.6-6.2A2 2 0 0 1 5.2 3l6.2-.6a2 2 0 0 1 1.2.4Z" fill="currentColor"/><circle cx="8" cy="8" r="1.6" fill="#fff"/></svg>';case"STAR":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 2.5l2.9 6 6.6.7-4.9 4.5 1.3 6.5L12 16.9l-5.9 3.3 1.3-6.5-4.9-4.5 6.6-.7L12 2.5Z" fill="currentColor"/></svg>';case"GIFT":return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><rect x="3.5" y="9.5" width="17" height="10" rx="1.2" fill="currentColor"/><rect x="2.5" y="6.5" width="19" height="3.5" rx="1" fill="currentColor"/><rect x="11" y="6.5" width="2" height="13" fill="#fff"/><path d="M12 6.5c0-2 -2-3.5-3.6-3.5S6 4.3 6 5.4c0 .9.8 1.1 1.6 1.1H12Z" fill="currentColor"/><path d="M12 6.5c0-2 2-3.5 3.6-3.5S18 4.3 18 5.4c0 .9-.8 1.1-1.6 1.1H12Z" fill="currentColor"/></svg>';default:return'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3 9.5 7 12l5-6 5 6 4-2.5-1.6 9.5a1.5 1.5 0 0 1-1.5 1.3H6.1a1.5 1.5 0 0 1-1.5-1.3L3 9.5Z" fill="currentColor"/></svg>'}})(t.iconPreset)}function Y(e,o){if("undefined"==typeof document||"undefined"==typeof window)return()=>{};try{const{hostEl:e,shadow:r}=K("data-cnv-launcher",':host{all:initial;}.cnv-launcher-fab{display:inline-flex;align-items:center;gap:8px;height:48px;padding:0 18px;border:none;cursor:pointer;box-shadow:0 6px 18px rgba(0,0,0,.18);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;font-size:14px;font-weight:600;line-height:1;white-space:nowrap;transition:transform .18s cubic-bezier(.16,1,.3,1),box-shadow .18s ease;animation:cnv-fab-in .32s cubic-bezier(.16,1,.3,1);}.cnv-launcher-fab:hover{transform:translateY(-2px);box-shadow:0 10px 26px rgba(0,0,0,.24);}.cnv-launcher-fab:active{transform:translateY(0) scale(.96);}.cnv-launcher-fab__icon{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;flex-shrink:0;}.cnv-launcher-fab__icon svg,.cnv-launcher-fab__icon img{width:20px;height:20px;object-fit:contain;animation:cnv-fab-icon-in .28s cubic-bezier(.16,1,.3,1);}@keyframes cnv-fab-in{from{opacity:0;transform:translateY(10px) scale(.9);}to{opacity:1;transform:none;}}@keyframes cnv-fab-icon-in{from{opacity:0;transform:rotate(-90deg) scale(.4);}to{opacity:1;transform:none;}}@media (prefers-reduced-motion:reduce){.cnv-launcher-fab,.cnv-launcher-fab__icon svg,.cnv-launcher-fab__icon img{animation:none !important;transition:none !important;}}'),i=document.createElement("button");i.type="button",i.className="cnv-launcher-fab",i.setAttribute("aria-label","Launcher");const c=document.createElement("span");c.className="cnv-launcher-fab__icon";const l=document.createElement("span");l.className="cnv-launcher-fab__text",i.appendChild(c),i.appendChild(l),r.appendChild(i),((n,t,e)=>{n.style.backgroundColor=L(e.backgroundColor,R),n.style.color=L(e.textColor,B),n.style.borderRadius=(n=>{switch(n){case"SQUARE":return"2px";case"SHAVED":return"8px";case"ROUNDED":return"16px";default:return"999px"}})(e.buttonShape),W(t,e,!1)})(i,c,o);let a=!1;const u=()=>((n,e,o,r,i)=>{try{const c=F();if(((n,e)=>{if("DESKTOP_ONLY"===n.deviceVisibility&&e)return!0;if(n.hideOnHomepage&&t(()=>"/"===location.pathname||""===location.pathname,!1))return!0;const o=n.hideUrlConditions;if(o&&o.length>0){const n=t(()=>location.pathname+location.search,"");if(o.some(t=>"string"==typeof t&&t.length>0&&n.includes(t)))return!0}return!1})(r,c))return void n.style.setProperty("display","none");n.style.removeProperty("display");const{side:l,sideSpacingPx:a,bottomSpacingPx:u}=H(r,c),s=r.useCustomZIndex?$(r.zIndex):null,d=r.addImportantRule?"important":"",f=(t,e)=>n.style.setProperty(t,e,d);f("position","fixed"),f("bottom",u+"px"),f("left","left"===l?a+"px":"auto"),f("right","right"===l?a+"px":"auto"),f("z-index",String(null!=s?s:j));const p=c?r.contentLayoutMobile:r.contentLayoutDesktop,h=!i&&"ICON_ONLY"!==p;e.style.display=i||"TEXT_ONLY"!==p?"inline-flex":"none",o.style.display=h?"inline":"none",h&&(o.textContent=(c?r.buttonTextMobile:r.buttonTextDesktop)||"")}catch(n){}})(e,c,l,o,a),s=t=>{a!==t&&(a=t,n(()=>{W(c,o,t),i.setAttribute("aria-label",t?"Đóng":"Launcher"),u()}))},d=()=>s(!0),f=()=>s(!1);window.addEventListener(G,d),window.addEventListener(Z,f);const p=()=>{n(()=>window.dispatchEvent(new CustomEvent("cnv:launcher:click",{detail:{config:o}})))};i.addEventListener("click",p);const h=()=>{n(()=>{q(e),u()})};document.body?h():document.addEventListener("DOMContentLoaded",h,{once:!0});const v=t(()=>window.matchMedia("(max-width: 768px)"),null),m=()=>u(),g=v;v&&"function"==typeof v.addEventListener?v.addEventListener("change",m):v&&"function"==typeof g.addListener?g.addListener(m):window.addEventListener("resize",m);const b=E(u);return()=>{n(()=>{document.removeEventListener("DOMContentLoaded",h),i.removeEventListener("click",p),window.removeEventListener(G,d),window.removeEventListener(Z,f),v&&"function"==typeof v.removeEventListener?v.removeEventListener("change",m):v&&"function"==typeof g.removeListener?g.removeListener(m):window.removeEventListener("resize",m),e.remove()}),n(b)}}catch(n){return()=>{}}}function J(n,t,e,o){return new(e||(e=Promise))((r,i)=>{function c(n){try{a(o.next(n))}catch(n){i(n)}}function l(n){try{a(o.throw(n))}catch(n){i(n)}}function a(n){var t;n.done?r(n.value):(t=n.value,t instanceof e?t:new e(n=>{n(t)})).then(c,l)}a((o=o.apply(n,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Q=(n,t)=>{let e=n;const o=X[t];let r=null,i=0,c=null;const l=[],a={},u=(n,t)=>{i=4*e+17,r=(n=>{const t=new Array(n);for(let e=0;e<n;e+=1){t[e]=new Array(n);for(let o=0;o<n;o+=1)t[e][o]=null}return t})(i),s(0,0),s(i-7,0),s(0,i-7),f(),d(),h(n,t),e>=7&&p(n),null==c&&(c=m(e,o,l)),v(c,t)},s=(n,t)=>{for(let e=-1;e<=7;e+=1)if(!(n+e<=-1||i<=n+e))for(let o=-1;o<=7;o+=1)t+o<=-1||i<=t+o||(r[n+e][t+o]=0<=e&&e<=6&&(0==o||6==o)||0<=o&&o<=6&&(0==e||6==e)||2<=e&&e<=4&&2<=o&&o<=4)},d=()=>{for(let n=8;n<i-8;n+=1)null==r[n][6]&&(r[n][6]=n%2==0);for(let n=8;n<i-8;n+=1)null==r[6][n]&&(r[6][n]=n%2==0)},f=()=>{const n=nn.getPatternPosition(e);for(let t=0;t<n.length;t+=1)for(let e=0;e<n.length;e+=1){const o=n[t],i=n[e];if(null==r[o][i])for(let n=-2;n<=2;n+=1)for(let t=-2;t<=2;t+=1)r[o+n][i+t]=-2==n||2==n||-2==t||2==t||0==n&&0==t}},p=n=>{const t=nn.getBCHTypeNumber(e);for(let e=0;e<18;e+=1){const o=!n&&1==(t>>e&1);r[Math.floor(e/3)][e%3+i-8-3]=o}for(let e=0;e<18;e+=1){const o=!n&&1==(t>>e&1);r[e%3+i-8-3][Math.floor(e/3)]=o}},h=(n,t)=>{const e=nn.getBCHTypeInfo(o<<3|t);for(let t=0;t<15;t+=1){const o=!n&&1==(e>>t&1);t<6?r[t][8]=o:t<8?r[t+1][8]=o:r[i-15+t][8]=o}for(let t=0;t<15;t+=1){const o=!n&&1==(e>>t&1);t<8?r[8][i-t-1]=o:t<9?r[8][15-t-1+1]=o:r[8][15-t-1]=o}r[i-8][8]=!n},v=(n,t)=>{let e=-1,o=i-1,c=7,l=0;const a=nn.getMaskFunction(t);for(let t=i-1;t>0;t-=2)for(6==t&&(t-=1);;){for(let e=0;e<2;e+=1)if(null==r[o][t-e]){let i=!1;l<n.length&&(i=1==(n[l]>>>c&1)),a(o,t-e)&&(i=!i),r[o][t-e]=i,c-=1,-1==c&&(l+=1,c=7)}if(o+=e,o<0||i<=o){o-=e,e=-e;break}}},m=(n,t,e)=>{const o=on.getRSBlocks(n,t),r=rn();for(let t=0;t<e.length;t+=1){const o=e[t];r.put(o.getMode(),4),r.put(o.getLength(),nn.getLengthInBits(o.getMode(),n)),o.write(r)}let i=0;for(let n=0;n<o.length;n+=1)i+=o[n].dataCount;if(r.getLengthInBits()>8*i)throw"code length overflow. ("+r.getLengthInBits()+">"+8*i+")";for(r.getLengthInBits()+4<=8*i&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(!1);for(;!(r.getLengthInBits()>=8*i||(r.put(236,8),r.getLengthInBits()>=8*i));)r.put(17,8);return((n,t)=>{let e=0,o=0,r=0;const i=new Array(t.length),c=new Array(t.length);for(let l=0;l<t.length;l+=1){const a=t[l].dataCount,u=t[l].totalCount-a;o=Math.max(o,a),r=Math.max(r,u),i[l]=new Array(a);for(let t=0;t<i[l].length;t+=1)i[l][t]=255&n.getBuffer()[t+e];e+=a;const s=nn.getErrorCorrectPolynomial(u),d=en(i[l],s.getLength()-1).mod(s);c[l]=new Array(s.getLength()-1);for(let n=0;n<c[l].length;n+=1){const t=n+d.getLength()-c[l].length;c[l][n]=t>=0?d.getAt(t):0}}let l=0;for(let n=0;n<t.length;n+=1)l+=t[n].totalCount;const a=new Array(l);let u=0;for(let n=0;n<o;n+=1)for(let e=0;e<t.length;e+=1)n<i[e].length&&(a[u]=i[e][n],u+=1);for(let n=0;n<r;n+=1)for(let e=0;e<t.length;e+=1)n<c[e].length&&(a[u]=c[e][n],u+=1);return a})(r,o)};a.addData=(n,t)=>{let e=null;switch(t=t||"Byte"){case"Numeric":e=cn(n);break;case"Alphanumeric":e=ln(n);break;case"Byte":e=an(n);break;case"Kanji":e=un(n);break;default:throw"mode:"+t}l.push(e),c=null},a.isDark=(n,t)=>{if(n<0||i<=n||t<0||i<=t)throw n+","+t;return r[n][t]},a.getModuleCount=()=>i,a.make=()=>{if(e<1){let n=1;for(;n<40;n++){const t=on.getRSBlocks(n,o),e=rn();for(let t=0;t<l.length;t++){const o=l[t];e.put(o.getMode(),4),e.put(o.getLength(),nn.getLengthInBits(o.getMode(),n)),o.write(e)}let r=0;for(let n=0;n<t.length;n++)r+=t[n].dataCount;if(e.getLengthInBits()<=8*r)break}e=n}u(!1,(()=>{let n=0,t=0;for(let e=0;e<8;e+=1){u(!0,e);const o=nn.getLostPoint(a);(0==e||n>o)&&(n=o,t=e)}return t})())},a.createTableTag=(n,t)=>{n=n||2;let e="";e+='<table style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: "+(t=void 0===t?4*n:t)+"px;",e+='">',e+="<tbody>";for(let t=0;t<a.getModuleCount();t+=1){e+="<tr>";for(let o=0;o<a.getModuleCount();o+=1)e+='<td style="',e+=" border-width: 0px; border-style: none;",e+=" border-collapse: collapse;",e+=" padding: 0px; margin: 0px;",e+=" width: "+n+"px;",e+=" height: "+n+"px;",e+=" background-color: ",e+=a.isDark(t,o)?"#000000":"#ffffff",e+=";",e+='"/>';e+="</tr>"}return e+="</tbody>",e+="</table>",e},a.createSvgTag=function(n,t,e,o){let r={};"object"==typeof arguments[0]&&(r=arguments[0],n=r.cellSize,t=r.margin,e=r.alt,o=r.title),n=n||2,t=void 0===t?4*n:t,(e="string"==typeof e?{text:e}:e||{}).text=e.text||null,e.id=e.text?e.id||"qrcode-description":null,(o="string"==typeof o?{text:o}:o||{}).text=o.text||null,o.id=o.text?o.id||"qrcode-title":null;const i=a.getModuleCount()*n+2*t;let c,l,u,s,d,f="";for(d="l"+n+",0 0,"+n+" -"+n+",0 0,-"+n+"z ",f+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',f+=r.scalable?"":' width="'+i+'px" height="'+i+'px"',f+=' viewBox="0 0 '+i+" "+i+'" ',f+=' preserveAspectRatio="xMinYMin meet"',f+=o.text||e.text?' role="img" aria-labelledby="'+g([o.id,e.id].join(" ").trim())+'"':"",f+=">",f+=o.text?'<title id="'+g(o.id)+'">'+g(o.text)+"</title>":"",f+=e.text?'<description id="'+g(e.id)+'">'+g(e.text)+"</description>":"",f+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',f+='<path d="',u=0;u<a.getModuleCount();u+=1)for(s=u*n+t,c=0;c<a.getModuleCount();c+=1)a.isDark(u,c)&&(l=c*n+t,f+="M"+l+","+s+d);return f+='" stroke="transparent" fill="black"/>',f+="</svg>",f},a.createDataURL=(n,t)=>{n=n||2,t=void 0===t?4*n:t;const e=a.getModuleCount()*n+2*t,o=t,r=e-t;return fn(e,e,(t,e)=>{if(o<=t&&t<r&&o<=e&&e<r){const r=Math.floor((t-o)/n),i=Math.floor((e-o)/n);return a.isDark(i,r)?0:1}return 1})},a.createImgTag=(n,t,e)=>{n=n||2,t=void 0===t?4*n:t;const o=a.getModuleCount()*n+2*t;let r="";return r+="<img",r+=' src="',r+=a.createDataURL(n,t),r+='"',r+=' width="',r+=o,r+='"',r+=' height="',r+=o,r+='"',e&&(r+=' alt="',r+=g(e),r+='"'),r+="/>",r};const g=n=>{let t="";for(let e=0;e<n.length;e+=1){const o=n.charAt(e);switch(o){case"<":t+="<";break;case">":t+=">";break;case"&":t+="&";break;case'"':t+=""";break;default:t+=o}}return t};return a.createASCII=(n,t)=>{if((n=n||1)<2)return(n=>{n=void 0===n?2:n;const t=1*a.getModuleCount()+2*n,e=n,o=t-n;let r,i,c,l,u;const s={"██":"█","█ ":"▀"," █":"▄"," ":" "},d={"██":"▀","█ ":"▀"," █":" "," ":" "};let f="";for(r=0;r<t;r+=2){for(c=Math.floor((r-e)/1),l=Math.floor((r+1-e)/1),i=0;i<t;i+=1)u="█",e<=i&&i<o&&e<=r&&r<o&&a.isDark(c,Math.floor((i-e)/1))&&(u=" "),e<=i&&i<o&&e<=r+1&&r+1<o&&a.isDark(l,Math.floor((i-e)/1))?u+=" ":u+="█",f+=n<1&&r+1>=o?d[u]:s[u];f+="\n"}return t%2&&n>0?f.substring(0,f.length-t-1)+Array(t+1).join("▀"):f.substring(0,f.length-1)})(t);n-=1,t=void 0===t?2*n:t;const e=a.getModuleCount()*n+2*t,o=t,r=e-t;let i,c,l,u;const s=Array(n+1).join("██"),d=Array(n+1).join(" ");let f="",p="";for(i=0;i<e;i+=1){for(l=Math.floor((i-o)/n),p="",c=0;c<e;c+=1)u=1,o<=c&&c<r&&o<=i&&i<r&&a.isDark(l,Math.floor((c-o)/n))&&(u=0),p+=u?s:d;for(l=0;l<n;l+=1)f+=p+"\n"}return f.substring(0,f.length-1)},a.renderTo2dContext=(n,t)=>{t=t||2;const e=a.getModuleCount();for(let o=0;o<e;o++)for(let r=0;r<e;r++)n.fillStyle=a.isDark(o,r)?"black":"white",n.fillRect(r*t,o*t,t,t)},a};Q.stringToBytes=n=>{const t=[];for(let e=0;e<n.length;e+=1){const o=n.charCodeAt(e);t.push(255&o)}return t},Q.createStringToBytes=(n,t)=>{const e=(()=>{const e=dn(n),o=()=>{const n=e.read();if(-1==n)throw"eof";return n};let r=0;const i={};for(;;){const n=e.read();if(-1==n)break;const t=o(),c=o(),l=o();i[String.fromCharCode(n<<8|t)]=c<<8|l,r+=1}if(r!=t)throw r+" != "+t;return i})(),o="?".charCodeAt(0);return n=>{const t=[];for(let r=0;r<n.length;r+=1){const i=n.charCodeAt(r);if(i<128)t.push(i);else{const i=e[n.charAt(r)];"number"==typeof i?(255&i)==i?t.push(i):(t.push(i>>>8),t.push(255&i)):t.push(o)}}return t}};const X={L:1,M:0,Q:3,H:2},nn=(()=>{const n=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],t=1335,e=7973,o={},r=n=>{let t=0;for(;0!=n;)t+=1,n>>>=1;return t};return o.getBCHTypeInfo=n=>{let e=n<<10;for(;r(e)-r(t)>=0;)e^=t<<r(e)-r(t);return 21522^(n<<10|e)},o.getBCHTypeNumber=n=>{let t=n<<12;for(;r(t)-r(e)>=0;)t^=e<<r(t)-r(e);return n<<12|t},o.getPatternPosition=t=>n[t-1],o.getMaskFunction=n=>{switch(n){case 0:return(n,t)=>(n+t)%2==0;case 1:return(n,t)=>n%2==0;case 2:return(n,t)=>t%3==0;case 3:return(n,t)=>(n+t)%3==0;case 4:return(n,t)=>(Math.floor(n/2)+Math.floor(t/3))%2==0;case 5:return(n,t)=>n*t%2+n*t%3==0;case 6:return(n,t)=>(n*t%2+n*t%3)%2==0;case 7:return(n,t)=>(n*t%3+(n+t)%2)%2==0;default:throw"bad maskPattern:"+n}},o.getErrorCorrectPolynomial=n=>{let t=en([1],0);for(let e=0;e<n;e+=1)t=t.multiply(en([1,tn.gexp(e)],0));return t},o.getLengthInBits=(n,t)=>{if(1<=t&&t<10)switch(n){case 1:return 10;case 2:return 9;case 4:case 8:return 8;default:throw"mode:"+n}else if(t<27)switch(n){case 1:return 12;case 2:return 11;case 4:return 16;case 8:return 10;default:throw"mode:"+n}else{if(!(t<41))throw"type:"+t;switch(n){case 1:return 14;case 2:return 13;case 4:return 16;case 8:return 12;default:throw"mode:"+n}}},o.getLostPoint=n=>{const t=n.getModuleCount();let e=0;for(let o=0;o<t;o+=1)for(let r=0;r<t;r+=1){let i=0;const c=n.isDark(o,r);for(let e=-1;e<=1;e+=1)if(!(o+e<0||t<=o+e))for(let l=-1;l<=1;l+=1)r+l<0||t<=r+l||0==e&&0==l||c==n.isDark(o+e,r+l)&&(i+=1);i>5&&(e+=3+i-5)}for(let o=0;o<t-1;o+=1)for(let r=0;r<t-1;r+=1){let t=0;n.isDark(o,r)&&(t+=1),n.isDark(o+1,r)&&(t+=1),n.isDark(o,r+1)&&(t+=1),n.isDark(o+1,r+1)&&(t+=1),0!=t&&4!=t||(e+=3)}for(let o=0;o<t;o+=1)for(let r=0;r<t-6;r+=1)n.isDark(o,r)&&!n.isDark(o,r+1)&&n.isDark(o,r+2)&&n.isDark(o,r+3)&&n.isDark(o,r+4)&&!n.isDark(o,r+5)&&n.isDark(o,r+6)&&(e+=40);for(let o=0;o<t;o+=1)for(let r=0;r<t-6;r+=1)n.isDark(r,o)&&!n.isDark(r+1,o)&&n.isDark(r+2,o)&&n.isDark(r+3,o)&&n.isDark(r+4,o)&&!n.isDark(r+5,o)&&n.isDark(r+6,o)&&(e+=40);let o=0;for(let e=0;e<t;e+=1)for(let r=0;r<t;r+=1)n.isDark(r,e)&&(o+=1);return e+=Math.abs(100*o/t/t-50)/5*10,e},o})(),tn=(()=>{const n=new Array(256),t=new Array(256);for(let t=0;t<8;t+=1)n[t]=1<<t;for(let t=8;t<256;t+=1)n[t]=n[t-4]^n[t-5]^n[t-6]^n[t-8];for(let e=0;e<255;e+=1)t[n[e]]=e;return{glog(n){if(n<1)throw"glog("+n+")";return t[n]},gexp(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return n[t]}}})(),en=(n,t)=>{if(void 0===n.length)throw n.length+"/"+t;const e=(()=>{let e=0;for(;e<n.length&&0==n[e];)e+=1;const o=new Array(n.length-e+t);for(let t=0;t<n.length-e;t+=1)o[t]=n[t+e];return o})(),o={getAt:n=>e[n],getLength:()=>e.length,multiply(n){const t=new Array(o.getLength()+n.getLength()-1);for(let e=0;e<o.getLength();e+=1)for(let r=0;r<n.getLength();r+=1)t[e+r]^=tn.gexp(tn.glog(o.getAt(e))+tn.glog(n.getAt(r)));return en(t,0)},mod(n){if(o.getLength()-n.getLength()<0)return o;const t=tn.glog(o.getAt(0))-tn.glog(n.getAt(0)),e=new Array(o.getLength());for(let n=0;n<o.getLength();n+=1)e[n]=o.getAt(n);for(let o=0;o<n.getLength();o+=1)e[o]^=tn.gexp(tn.glog(n.getAt(o))+t);return en(e,0).mod(n)}};return o},on=(()=>{const n=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=(n,t)=>{const e={};return e.totalCount=n,e.dataCount=t,e};return{getRSBlocks(e,o){const r=((t,e)=>{switch(e){case X.L:return n[4*(t-1)+0];case X.M:return n[4*(t-1)+1];case X.Q:return n[4*(t-1)+2];case X.H:return n[4*(t-1)+3];default:return}})(e,o);if(void 0===r)throw"bad rs block @ typeNumber:"+e+"/errorCorrectionLevel:"+o;const i=r.length/3,c=[];for(let n=0;n<i;n+=1){const e=r[3*n+0],o=r[3*n+1],i=r[3*n+2];for(let n=0;n<e;n+=1)c.push(t(o,i))}return c}}})(),rn=()=>{const n=[];let t=0;const e={getBuffer:()=>n,getAt(t){const e=Math.floor(t/8);return 1==(n[e]>>>7-t%8&1)},put(n,t){for(let o=0;o<t;o+=1)e.putBit(1==(n>>>t-o-1&1))},getLengthInBits:()=>t,putBit(e){const o=Math.floor(t/8);n.length<=o&&n.push(0),e&&(n[o]|=128>>>t%8),t+=1}};return e},cn=n=>{const t=n,e={getMode:()=>1,getLength:n=>t.length,write(n){const e=t;let r=0;for(;r+2<e.length;)n.put(o(e.substring(r,r+3)),10),r+=3;r<e.length&&(e.length-r==1?n.put(o(e.substring(r,r+1)),4):e.length-r==2&&n.put(o(e.substring(r,r+2)),7))}},o=n=>{let t=0;for(let e=0;e<n.length;e+=1)t=10*t+r(n.charAt(e));return t},r=n=>{if("0"<=n&&n<="9")return n.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+n};return e},ln=n=>{const t=n,e={getMode:()=>2,getLength:n=>t.length,write(n){const e=t;let r=0;for(;r+1<e.length;)n.put(45*o(e.charAt(r))+o(e.charAt(r+1)),11),r+=2;r<e.length&&n.put(o(e.charAt(r)),6)}},o=n=>{if("0"<=n&&n<="9")return n.charCodeAt(0)-"0".charCodeAt(0);if("A"<=n&&n<="Z")return n.charCodeAt(0)-"A".charCodeAt(0)+10;switch(n){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+n}};return e},an=n=>{const t=Q.stringToBytes(n);return{getMode:()=>4,getLength:n=>t.length,write(n){for(let e=0;e<t.length;e+=1)n.put(t[e],8)}}},un=n=>{const t=Q.stringToBytes;(()=>{const n=t("友");if(2!=n.length||38726!=(n[0]<<8|n[1]))throw"sjis not supported."})();const e=t(n),o={getMode:()=>8,getLength:n=>~~(e.length/2),write(n){const t=e;let o=0;for(;o+1<t.length;){let e=(255&t[o])<<8|255&t[o+1];if(33088<=e&&e<=40956)e-=33088;else{if(!(57408<=e&&e<=60351))throw"illegal char at "+(o+1)+"/"+e;e-=49472}e=192*(e>>>8&255)+(255&e),n.put(e,13),o+=2}if(o<t.length)throw"illegal char at "+(o+1)}};return o},sn=()=>{const n=[],t={writeByte(t){n.push(255&t)},writeShort(n){t.writeByte(n),t.writeByte(n>>>8)},writeBytes(n,e,o){e=e||0,o=o||n.length;for(let r=0;r<o;r+=1)t.writeByte(n[r+e])},writeString(n){for(let e=0;e<n.length;e+=1)t.writeByte(n.charCodeAt(e))},toByteArray:()=>n,toString(){let t="";t+="[";for(let e=0;e<n.length;e+=1)e>0&&(t+=","),t+=n[e];return t+="]",t}};return t},dn=n=>{const t=n;let e=0,o=0,r=0;const i={read(){for(;r<8;){if(e>=t.length){if(0==r)return-1;throw"unexpected end of file./"+r}const n=t.charAt(e);if(e+=1,"="==n)return r=0,-1;n.match(/^\s$/)||(o=o<<6|c(n.charCodeAt(0)),r+=6)}const n=o>>>r-8&255;return r-=8,n}},c=n=>{if(65<=n&&n<=90)return n-65;if(97<=n&&n<=122)return n-97+26;if(48<=n&&n<=57)return n-48+52;if(43==n)return 62;if(47==n)return 63;throw"c:"+n};return i},fn=(n,t,e)=>{const o=((n,t)=>{const e=n,o=t,r=new Array(n*t),i={setPixel(n,t,o){r[t*e+n]=o},write(n){n.writeString("GIF87a"),n.writeShort(e),n.writeShort(o),n.writeByte(128),n.writeByte(0),n.writeByte(0),n.writeByte(0),n.writeByte(0),n.writeByte(0),n.writeByte(255),n.writeByte(255),n.writeByte(255),n.writeString(","),n.writeShort(0),n.writeShort(0),n.writeShort(e),n.writeShort(o),n.writeByte(0);const t=c(2);n.writeByte(2);let r=0;for(;t.length-r>255;)n.writeByte(255),n.writeBytes(t,r,255),r+=255;n.writeByte(t.length-r),n.writeBytes(t,r,t.length-r),n.writeByte(0),n.writeString(";")}},c=n=>{const t=1<<n,e=1+(1<<n);let o=n+1;const i=l();for(let n=0;n<t;n+=1)i.add(String.fromCharCode(n));i.add(String.fromCharCode(t)),i.add(String.fromCharCode(e));const c=sn(),a=(n=>{const t=n;let e=0,o=0;return{write(n,r){if(n>>>r!=0)throw"length over";for(;e+r>=8;)t.writeByte(255&(n<<e|o)),r-=8-e,n>>>=8-e,o=0,e=0;o|=n<<e,e+=r},flush(){e>0&&t.writeByte(o)}}})(c);a.write(t,o);let u=0,s=String.fromCharCode(r[u]);for(u+=1;u<r.length;){const n=String.fromCharCode(r[u]);u+=1,i.contains(s+n)?s+=n:(a.write(i.indexOf(s),o),i.size()<4095&&(i.size()==1<<o&&(o+=1),i.add(s+n)),s=n)}return a.write(i.indexOf(s),o),a.write(e,o),a.flush(),c.toByteArray()},l=()=>{const n={};let t=0;const e={add(o){if(e.contains(o))throw"dup key:"+o;n[o]=t,t+=1},size(){return t},indexOf(t){return n[t]},contains(t){return void 0!==n[t]}};return e};return i})(n,t);for(let r=0;r<t;r+=1)for(let t=0;t<n;t+=1)o.setPixel(t,r,e(t,r));const r=sn();o.write(r);const i=(()=>{let n=0,t=0,e=0,o="";const r={},i=n=>{o+=String.fromCharCode(c(63&n))},c=n=>{if(n<0)throw"n:"+n;if(n<26)return 65+n;if(n<52)return n-26+97;if(n<62)return n-52+48;if(62==n)return 43;if(63==n)return 47;throw"n:"+n};return r.writeByte=o=>{for(n=n<<8|255&o,t+=8,e+=1;t>=6;)i(n>>>t-6),t-=6},r.flush=()=>{if(t>0&&(i(n<<6-t),n=0,t=0),e%3!=0){const n=3-e%3;for(let t=0;t<n;t+=1)o+="="}},r.toString=()=>o,r})(),c=r.toByteArray();for(let n=0;n<c.length;n+=1)i.writeByte(c[n]);return i.flush(),"data:image/gif;base64,"+i},pn="undefined"!=typeof window&&"undefined"!=typeof document;function hn(n){if(!pn)return null;try{const t=document.cookie;if(!t)return null;const e=encodeURIComponent(n),o=t.split(";");for(let t=0;t<o.length;t++){const r=o[t].indexOf("=");if(r<0)continue;const i=o[t].slice(0,r).trim();if(i===e||i===n)try{return decodeURIComponent(o[t].slice(r+1))}catch(n){return o[t].slice(r+1)}}return null}catch(n){return null}}function vn(n,t,e={}){var o,r,i;if(!pn)return!1;try{let c=`${encodeURIComponent(n)}=${encodeURIComponent(t)}`;if(c+=`; path=${null!==(o=e.path)&&void 0!==o?o:"/"}`,e.domain&&(c+=`; domain=${e.domain}`),"number"==typeof e.maxAgeDays){const n=Math.floor(86400*e.maxAgeDays);c+=`; max-age=${n}`,c+=`; expires=${new Date(Date.now()+1e3*n).toUTCString()}`}return c+=`; SameSite=${null!==(r=e.sameSite)&&void 0!==r?r:"Lax"}`,(null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol)&&(c+="; Secure"),document.cookie=c,hn(n)===t}catch(n){return!1}}function mn(){if(!pn)return!1;try{const n="__cnv_probe__";return localStorage.setItem(n,"1"),localStorage.removeItem(n),!0}catch(n){return!1}}function gn(n){if(!mn())return null;try{return localStorage.getItem(n)}catch(n){return null}}function bn(n,t){if(!mn())return!1;try{return localStorage.setItem(n,t),!0}catch(n){return!1}}function yn(n){if(!mn())return!1;try{return localStorage.removeItem(n),!0}catch(n){return!1}}function _n(){if(!pn)return!1;try{const n="__cnv_probe__";return sessionStorage.setItem(n,"1"),sessionStorage.removeItem(n),!0}catch(n){return!1}}const wn="0123456789abcdef";function xn(n){return wn[n>>>4&15]+wn[15&n]}function kn(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues){const n=new Uint8Array(16);return crypto.getRandomValues(n),n[6]=15&n[6]|64,n[8]=63&n[8]|128,xn(n[0])+xn(n[1])+xn(n[2])+xn(n[3])+"-"+xn(n[4])+xn(n[5])+"-"+xn(n[6])+xn(n[7])+"-"+xn(n[8])+xn(n[9])+"-"+xn(n[10])+xn(n[11])+xn(n[12])+xn(n[13])+xn(n[14])+xn(n[15])}}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const t=16*Math.random()|0;return("x"===n?t:3&t|8).toString(16)})}const An=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Cn(n){return"string"==typeof n&&An.test(n)}const Mn=8e3,On=3e4,Sn=/^(https:|zalo:)/i;class In extends Error{constructor(n){super(`loginWithZalo() thất bại: ${n}`),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:n}),this.name="ZaloQrLoginError"}}function En(n,t,e,o){return`${n}${t}?${new URLSearchParams(Object.assign({projectId:e},o)).toString()}`}function Nn(n,t){if(!n||!t)return()=>{};if(t.aborted)return n.abort(),()=>{};const e=()=>n.abort();return t.addEventListener("abort",e),()=>t.removeEventListener("abort",e)}function zn(n){return{title:"string"==typeof n.title?n.title:void 0,description:"string"==typeof n.description?n.description:void 0,points:jn(n.points),expPoints:jn(n.expPoints),balanceAfter:jn(n.balanceAfter),expBalanceAfter:jn(n.expBalanceAfter),rankAfter:"string"==typeof n.rankAfter?n.rankAfter:void 0,createdAt:"string"==typeof n.createdAt?n.createdAt:void 0}}function Tn(n){return{campaignId:jn(n.campaignId),rewardId:jn(n.rewardId),title:"string"==typeof n.title?n.title:void 0,imageUrl:"string"==typeof n.imageUrl?n.imageUrl:void 0,discountValue:"string"==typeof n.discountValue?n.discountValue:void 0,redeemPoints:jn(n.redeemPoints),redeemRemain:jn(n.redeemRemain),expiredAt:"string"==typeof n.expiredAt?n.expiredAt:void 0,stock:"boolean"==typeof n.stock?n.stock:void 0,burnOnUse:!0===n.burnOnUse}}function Dn(n,t){return n?"string"==typeof n.error&&n.error?n.error:t&&"string"==typeof n.code&&n.code?n.code:null:null}function jn(n){return"number"==typeof n&&Number.isFinite(n)?n:void 0}function Rn(n){return{id:jn(n.id),name:"string"==typeof n.name?n.name:void 0,iconUrl:"string"==typeof n.iconUrl?n.iconUrl:void 0,colorCode:"string"==typeof n.colorCode?n.colorCode:void 0,threshold:jn(n.threshold),level:jn(n.level),benefits:Array.isArray(n.benefits)?n.benefits.filter(n=>"string"==typeof n&&""!==n.trim()):[]}}function Bn(n){return{id:jn(n.id),name:"string"==typeof n.name?n.name:void 0,iconUrl:"string"==typeof n.iconUrl?n.iconUrl:void 0,colorCode:"string"==typeof n.colorCode?n.colorCode:void 0,level:jn(n.level),progressCurrent:jn(n.progressCurrent),progressTarget:jn(n.progressTarget),remaining:jn(n.remaining),nextLevelName:"string"==typeof n.nextLevelName?n.nextLevelName:void 0,isHighestLevel:!0===n.isHighestLevel}}function Fn(n){return{title:"string"==typeof n.title?n.title:void 0,imageUrl:"string"==typeof n.imageUrl?n.imageUrl:void 0,code:"string"==typeof n.code?n.code:void 0,discountValue:"string"==typeof n.discountValue?n.discountValue:void 0,channelLabel:"string"==typeof n.channelLabel?n.channelLabel:void 0,expiredAt:"string"==typeof n.expiredAt?n.expiredAt:void 0,useRemain:"number"==typeof n.useRemain&&Number.isFinite(n.useRemain)?n.useRemain:void 0,redeemId:"number"==typeof n.redeemId&&Number.isFinite(n.redeemId)?n.redeemId:void 0,usedAt:"string"==typeof n.usedAt?n.usedAt:void 0,canUse:!0===n.canUse,burnOnUse:!0===n.burnOnUse}}function Ln(n,t){return J(this,void 0,void 0,function*(){var e,o,r;if(!n.projectId||!n.endpoint)throw new In("not-initialized");if(!n.zaloQrLoginEnabled)throw new In("disabled");if(!n.consentGranted)throw new In("consent-required");const i={preferSse:null===(e=null==t?void 0:t.preferSse)||void 0===e||e,pollIntervalMs:null!==(o=null==t?void 0:t.pollIntervalMs)&&void 0!==o?o:2e3,autoIdentify:null===(r=null==t?void 0:t.autoIdentify)||void 0===r||r},c=n.projectId,l=n.endpoint,a=(()=>{const n="undefined"!=typeof crypto?crypto:void 0;if(n&&"function"==typeof n.getRandomValues)try{const t=new Uint8Array(24);n.getRandomValues(t);let e="";for(let n=0;n<t.length;n+=1)e+=String.fromCharCode(t[n]);return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(n){return}})(),u=yield function(n,t,e){return J(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Mn):null;let i;try{i=yield fetch(En(n,"/zalo-qr/session",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:o?o.signal:void 0})}catch(n){throw new In("network")}finally{r&&clearTimeout(r)}if(!i.ok)throw new In(401===(c=i.status)?"invalid-project-key":403===c?"project-suspended":"network");var c;return(n=>{const t=n;if(!t||"string"!=typeof t.sessionToken||!t.sessionToken||"string"!=typeof t.miniAppDeepLink||!Sn.test(t.miniAppDeepLink)||"number"!=typeof t.expiresInSeconds||!Number.isFinite(t.expiresInSeconds)||t.expiresInSeconds<=0)throw new In("network");return{sessionToken:t.sessionToken,miniAppDeepLink:t.miniAppDeepLink,expiresInSeconds:t.expiresInSeconds}})(yield i.json())})}(l,c,Object.assign(Object.assign({},(n=>{var t,e,o;const r={};try{const i=null===(t=n.getAnonymousId)||void 0===t?void 0:t.call(n);i&&(r.anonymousId=i);const c=null===(e=n.getSessionId)||void 0===e?void 0:e.call(n);c&&(r.sessionId=c);const l=null===(o=n.getAttribution)||void 0===o?void 0:o.call(n);l&&(r.attribution=l)}catch(n){}return r})(n)),a?{pollSecret:a}:{})),s=((n,t,e,o,r,i)=>{let c=!1,l=null,a=null,u=null,s=null,d=null;const f=()=>{l&&(l.close(),l=null),null!==a&&(clearInterval(a),a=null),null!==u&&(clearTimeout(u),u=null),null!==s&&(clearTimeout(s),s=null)};return{promise:new Promise((p,h)=>{d=h;const v=n=>{c||(c=!0,f(),n())},m=n=>{"success"===n.status?v(()=>p((n=>({contactId:n.contactId,fullName:n.fullName,level:n.level,xp:n.xp,panelSessionToken:n.panelSessionToken,panelSessionExp:n.panelSessionExp,panelSessionExpiresInMs:"number"==typeof n.panelSessionExpiresInMs?n.panelSessionExpiresInMs:void 0}))(n))):"denied"===n.status?v(()=>h(new In("denied"))):"expired"===n.status&&v(()=>h(new In("expired")))},g=()=>{null!==a||c||(a=setInterval(()=>{fetch(En(n,"/zalo-qr/status",t,{sessionToken:e}),{method:"GET",credentials:"omit",mode:"cors",headers:i?{"X-Poll-Secret":i}:void 0}).then(n=>404===n.status?m({status:"expired"}):n.ok?n.json().then(n=>m(n)):void 0).catch(()=>{})},r.pollIntervalMs))};if(r.preferSse&&"undefined"!=typeof EventSource)try{l=new EventSource(En(n,"/zalo-qr/stream",t,i?{sessionToken:e,pollSecret:i}:{sessionToken:e})),l.addEventListener("success",n=>{try{m(JSON.parse(n.data))}catch(n){}}),l.addEventListener("denied",()=>m({status:"denied"})),l.onerror=()=>{null!==s||c||(s=setTimeout(()=>{s=null,c||(l&&(l.close(),l=null),g())},3e3))}}catch(n){g()}else g();u=setTimeout(()=>{v(()=>h(new In("expired")))},1e3*o)}),cancel(){c||(c=!0,f(),null==d||d(new In("cancelled")))}}})(l,c,u.sessionToken,u.expiresInSeconds,i,a),d=s.promise.then(t=>{try{if(i.autoIdentify&&null!=t.contactId){const e=String(t.contactId),o=n.getUserId();null!=o&&o!==e?n.alias(e,o):n.identify(e,Object.assign(Object.assign(Object.assign({},t.fullName?{name:t.fullName}:{}),t.level?{level:t.level}:{}),null!=t.xp?{xp:t.xp}:{}))}}catch(n){}return t});return{sessionToken:u.sessionToken,qrPayload:u.miniAppDeepLink,expiresInSeconds:u.expiresInSeconds,result:d,cancel:s.cancel,retry(){return s.cancel(),Ln(n,t)}}})}const Pn="cnv:launcher:click",$n="cnv:panel:identify",Un="cnv-panel-card--leaving";function Vn(n){return"cnv_panel_session_"+(null!=n?n:"default")}function Hn(n){const e=gn(Vn(n));return e?t(()=>{const n=JSON.parse(e);return n&&"string"==typeof n.token&&n.token&&"number"==typeof n.contactId&&"number"==typeof n.exp?n:null},null):null}function Kn(n,t){bn(Vn(n),JSON.stringify(t))}function qn(n){yn(Vn(n))}function Gn(n){return"SQUARE"===n?"0px":"12px"}function Zn(n){const t=n.colors;return L(null==t?void 0:t.iconColor,L(null==t?void 0:t.buttonBg,L(null==t?void 0:t.bannerBg,R)))}function Wn(n,t){n.style.background=V(t,.12),n.style.color=t}const Yn='<path d="M20 12v9H4v-9M2 7h20v5H2V7Zm10 0V4a2.5 2.5 0 0 0-5 0v3h5Zm0 0V4a2.5 2.5 0 0 1 5 0v3h-5Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/>',Jn='<path d="M9 6l6 6-6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',Qn='<path d="M12 2.5l2.9 6.3 6.9.8-5.1 4.7 1.4 6.8L12 17.8 5.9 21.1l1.4-6.8-5.1-4.7 6.9-.8L12 2.5Z" fill="currentColor"/>',Xn='<circle cx="9" cy="8" r="3.2" stroke="currentColor" stroke-width="1.8"/><path d="M2.5 20c0-3.6 2.9-6 6.5-6s6.5 2.4 6.5 6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>',nt='<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.8"/><path d="M12 7v5l3.5 2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>',tt='<path d="M5 13l4.5 4.5L19 8" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/>',et='<circle cx="11" cy="4.6" r="2.3" fill="currentColor"/><rect x="2.2" y="10" width="3" height="6.4" rx="1.5" fill="currentColor"/><path d="M7.4 12.2c2 0 3.4.6 4.6 1.8h2.2a1.6 1.6 0 1 1 0 3.2h-3.4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/><path d="M7.4 12.2v7c3.2 1.2 6.2.5 9-2l3.2-2.9a1.7 1.7 0 0 0-2.2-2.6l-3 2.3" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>',ot="#1E9E5B",rt="rgba(30, 158, 91, 0.12)",it="#D64545",ct="rgba(214, 69, 69, 0.10)",lt="#6B7280",at="rgba(107, 114, 128, 0.12)";function ut(n,t,e){const o=document.createElement("span");return o.className=e?"cnv-panel-icon "+e:"cnv-panel-icon",o.innerHTML=`<svg viewBox="0 0 24 24" fill="none" width="${t}" height="${t}">${n}</svg>`,o}function st(n,t){const e=document.createElement("div");return e.className="cnv-panel-chip",Wn(e,t),e.appendChild(ut(n,14)),e}function dt(n,t){const e=document.createElement("span");return e.className="cnv-panel-badge",Wn(e,t),e.textContent=n,e}const ft={POINTS:{label:"Điểm thưởng",icon:Qn},REFERRAL:{label:"Giới thiệu bạn bè",icon:Xn},VIP:{label:"Hạng thành viên (VIP)",icon:'<path d="M3 8l3.2 3 3.6-5.4L12 3l2.2 2.6L17.8 11 21 8l-1.6 10H4.6L3 8Z" fill="currentColor"/>'}},pt={rewards:'<path d="M3 9V6.4c0-.8.6-1.4 1.4-1.4h15.2c.8 0 1.4.6 1.4 1.4V9a3 3 0 0 0 0 6v2.6c0 .8-.6 1.4-1.4 1.4H4.4c-.8 0-1.4-.6-1.4-1.4V15a3 3 0 0 0 0-6Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M14.6 5.6v12.8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-dasharray="2.2 2.6"/>',earn:et,redeem:Yn,history:nt},ht={ORDER:'<path d="M4.4 8h15.2l-1.1 12.3H5.5L4.4 8Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M8.7 8V6.3a3.3 3.3 0 0 1 6.6 0V8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>',STAR:Qn,GIFT:Yn,USERS:Xn,CAKE:'<path d="M3.6 20.6h16.8v-5.1c0-1-.8-1.9-1.9-1.9H5.5c-1 0-1.9.8-1.9 1.9v5.1Z" stroke="currentColor" stroke-width="1.8" stroke-linejoin="round"/><path d="M12 13.6V9.7" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><circle cx="12" cy="7.5" r="1.8" fill="currentColor"/>',SHARE:'<circle cx="17.8" cy="5.6" r="2.6" stroke="currentColor" stroke-width="1.8"/><circle cx="6.2" cy="12" r="2.6" stroke="currentColor" stroke-width="1.8"/><circle cx="17.8" cy="18.4" r="2.6" stroke="currentColor" stroke-width="1.8"/><path d="M15.5 6.9 8.5 10.7M8.5 13.3l7 3.8" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>',COIN:et,CHECK:tt},vt={earn:{label:"Cách kiếm thêm điểm",icon:et},redeem:{label:"Cách đổi điểm",icon:Yn}},mt="cnv-panel-reward__title--full",gt="Tham gia ngay",bt=[[vt.earn.label,"earn"],[vt.redeem.label,"redeem"]],yt=/\{\{\s*TenKhachHang\s*\}\}/gi,_t=/[\u0000-\u001F\u007F\u200B\u200E\u200F\u2028\u2029\u202A-\u202E\u2066-\u2069\uFEFF]/g;function wt(n){return"number"==typeof n.campaignId&&n.campaignId>0?Object.assign({campaignId:n.campaignId},"number"==typeof n.redeemPoints&&n.redeemPoints>0?{redeemPoints:n.redeemPoints}:{}):"number"==typeof n.rewardId&&n.rewardId>0?{rewardId:n.rewardId}:null}function xt(n,e){const o=(n=>{if("string"!=typeof n)return"bạn";const e=t(()=>n.normalize("NFC"),n).replace(_t," ").replace(/\s+/g," ").trim();if(!e)return"bạn";const o=Array.from(e);return o.length<=24?e:o.slice(0,24).join("").trimEnd()+"…"})(e);return(n||"").replace(yt,()=>o)}const kt=[{key:"owned",label:"Ưu đãi của bạn"},{key:"redeem",label:"Đổi ưu đãi"}],At={message:'Lượt đổi đã được ghi nhận nhưng mã chưa phát kịp. Bạn mở tab "Ưu đãi của bạn" rồi bấm "Sử dụng" để lấy mã nhé.',action:"owned",heading:"Ưu đãi đã là của bạn",tone:"neutral"},Ct={message:'Điểm đã được trừ và ưu đãi đã là của bạn, chỉ chưa có mã. Bạn mở tab "Ưu đãi của bạn" rồi bấm "Sử dụng" để lấy mã nhé.',action:"owned",heading:"Ưu đãi đã là của bạn",tone:"neutral"},Mt={INSUFFICIENT_POINTS:{message:"Bạn không đủ điểm để đổi ưu đãi này.",action:"other"},REDEMPTION_LIMIT_EXCEEDED:{message:"Bạn đã đổi ưu đãi này đủ số lượt cho phép.",action:"other"},REWARD_OUT_OF_STOCK:{message:"Ưu đãi này vừa hết. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_EXPIRED:{message:"Ưu đãi này đã hết hạn.",action:"other"},PRICE_CHANGED:{message:"Giá đổi của ưu đãi vừa thay đổi. Bạn tải lại danh sách rồi đổi lại nhé.",action:"other"},POINT_HOLD_FAILED:{message:"Chưa trừ được điểm của bạn. Bạn thử lại nhé.",action:"retry",retryWithNewKey:!0},POINT_REFUNDED:{message:"Đổi ưu đãi không thành công, điểm của bạn đã được hoàn lại. Bạn thử lại nhé.",action:"retry",retryWithNewKey:!0},POINT_STUCK:{message:"Đổi ưu đãi không thành công. Điểm của bạn đang được kiểm tra, bạn liên hệ shop nhé.",action:"none"},CAMPAIGN_NOT_STARTED:{message:"Ưu đãi chưa tới thời gian áp dụng. Bạn quay lại sau nhé.",action:"other"},REWARD_NOT_PUBLISHED:{message:"Ưu đãi chưa được mở. Bạn quay lại sau nhé.",action:"other"},NOT_POINT_CAMPAIGN:{message:"Ưu đãi này không đổi bằng điểm. Bạn tải lại danh sách nhé.",action:"other"},REDEEM_IN_PROGRESS:{message:'Lượt đổi của bạn đang được xử lý. Bạn đợi một chút rồi kiểm tra ở tab "Ưu đãi của bạn" nhé.',action:"owned"},IDEMPOTENCY_UNAVAILABLE:{message:"Hệ thống đang bận, chưa đổi được. Bạn thử lại sau ít phút nhé.",action:"other"},CAMPAIGN_NOT_FOUND:{message:"Không tìm thấy ưu đãi này. Bạn tải lại danh sách nhé.",action:"other"},CAMPAIGN_INACTIVE:{message:"Ưu đãi này vừa được shop tạm dừng.",action:"other"},CAMPAIGN_EXPIRED:{message:"Ưu đãi này đã hết hạn.",action:"other"},INVALID_CAMPAIGN:{message:"Ưu đãi này đang thiếu thông tin cấu hình. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_NO_DISCOUNT:{message:"Ưu đãi này chưa sẵn sàng. Bạn chọn ưu đãi khác nhé.",action:"other"},OUT_OF_CODES:{message:"Ưu đãi này đã hết mã. Bạn chọn ưu đãi khác nhé.",action:"other"},DISCOUNT_UNAVAILABLE:{message:"Ưu đãi này không còn dùng được. Bạn chọn ưu đãi khác nhé.",action:"other"},REWARD_UNAVAILABLE:{message:"Ưu đãi này hiện không khả dụng.",action:"other"},NOT_SELF_REDEEMABLE:{message:"Ưu đãi này không tự đổi được. Bạn liên hệ shop nhé.",action:"other"},NOT_FREE:{message:"Ưu đãi này không phải ưu đãi tặng. Bạn tải lại danh sách nhé.",action:"other"},REDEEM_LIMIT_REACHED:{message:"Bạn đã đổi ưu đãi này đủ số lượt cho phép.",action:"other"},ALREADY_REDEEMED:{message:'Bạn đã nhận ưu đãi này rồi. Mã nằm ở tab "Ưu đãi của bạn".',action:"owned"},CODE_NOT_ISSUED:{message:"Đã ghi nhận lượt đổi nhưng mã chưa phát kịp. Bạn thử lại nhé.",action:"retry"},NOT_REDEEMED:{message:"Bạn chưa đổi ưu đãi này.",action:"other"},LOYALTY_SERVICE_UNAVAILABLE:{message:"Hệ thống điểm đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},VENDOR_ERROR:{message:"Nhà cung cấp ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},MISSING_VOUCHER:At,MISSING_SERIAL:At,INVALID_REQUEST:{message:"Ưu đãi này đang lỗi dữ liệu nên không đổi được. Bạn chọn ưu đãi khác nhé.",action:"other"},INVALID_TENANT:{message:"Chương trình ưu đãi của shop đang lỗi cấu hình. Bạn liên hệ shop nhé.",action:"none"},REDEEM_FAILED:{message:"Đổi ưu đãi không thành công. Bạn thử lại sau ít phút nhé.",action:"retry"},SERVICE_UNAVAILABLE:{message:"Hệ thống ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry",retryWithNewKey:!0},SESSION_CHECK_UNAVAILABLE:{message:"Chưa kiểm tra được phiên đăng nhập của bạn. Bạn thử lại sau ít phút nhé.",action:"retry"},invalid_session:{message:"Phiên đăng nhập đã hết. Bạn đăng nhập lại nhé.",action:"none"},UNCONFIRMED:{message:'Chưa xác nhận được kết quả. Điểm có thể đã được trừ — bạn kiểm tra ở tab "Ưu đãi của bạn" trước khi đổi lại nhé.',action:"owned",heading:"Chưa xác nhận được",tone:"neutral"}},Ot={CODE_NOT_ISSUED:Ct,MISSING_VOUCHER:Ct,MISSING_SERIAL:Ct,OUT_OF_CODES:{message:"Ưu đãi đã hết mã, điểm của bạn đã bị trừ. Bạn liên hệ shop để được hỗ trợ nhé.",action:"none"}},St={message:"Không đổi được ưu đãi lúc này. Bạn thử lại sau nhé.",action:"retry"},It={USE_LIMIT_REACHED:{message:"Ưu đãi này đã hết lượt sử dụng.",action:"back"},NOT_REDEEMED:{message:"Ưu đãi này không còn trong danh sách của bạn.",action:"back"},CAMPAIGN_NOT_FOUND:{message:"Không tìm thấy ưu đãi này nữa.",action:"back"},CODE_NOT_ISSUED:{message:"Chưa lấy được mã cho ưu đãi này. Bạn thử lại nhé.",action:"retry"},OUT_OF_CODES:{message:"Ưu đãi này đã hết mã. Bạn liên hệ shop nhé.",action:"back"},DISCOUNT_UNAVAILABLE:{message:"Ưu đãi này không còn dùng được. Bạn liên hệ shop nhé.",action:"back"},REWARD_NO_DISCOUNT:{message:"Ưu đãi này chưa sẵn sàng để lấy mã. Bạn liên hệ shop nhé.",action:"back"},INVALID_CAMPAIGN:{message:"Ưu đãi này đang thiếu thông tin cấu hình. Bạn liên hệ shop nhé.",action:"back"},UNCONFIRMED:{message:"Chưa xác nhận được. Bạn thử lại nhé.",action:"retry"},SERVICE_UNAVAILABLE:{message:"Hệ thống ưu đãi đang bận. Bạn thử lại sau ít phút nhé.",action:"retry"},SESSION_CHECK_UNAVAILABLE:{message:"Hệ thống đang bận, chưa lấy được mã. Bạn thử lại sau ít phút nhé.",action:"retry"},USE_FAILED:{message:"Chưa dùng được ưu đãi này. Bạn thử lại sau ít phút nhé.",action:"retry"},INVALID_REQUEST:{message:"Yêu cầu không hợp lệ. Bạn quay lại danh sách rồi thử lại nhé.",action:"back"},INVALID_REWARD:{message:"Không xác định được ưu đãi cần dùng. Bạn quay lại danh sách nhé.",action:"back"},INVALID_TENANT:{message:"Chương trình ưu đãi của shop đang lỗi cấu hình. Bạn liên hệ shop nhé.",action:"back"},invalid_session:{message:"Phiên đăng nhập đã hết. Bạn đăng nhập lại nhé.",action:"back"}},Et={message:"Chưa lấy được mã lúc này. Bạn thử lại sau nhé.",action:"retry"},Nt={other:"Chọn ưu đãi khác",retry:"Thử lại",owned:"Kiểm tra ưu đãi của bạn",none:""};function zt(n,t){var e;const o=document.createElement("div");var r,i;return o.className=t?"cnv-panel-card__section "+t:"cnv-panel-card__section",o.style.borderRadius=Gn(null===(e=n.shapes)||void 0===e?void 0:e.card),(r=o).style.backgroundColor="DARK"===(i=n.theme)?"#3F4254":"#FFFFFF",r.style.boxShadow="DARK"===i?"none":"0 2px 4px rgba(15, 42, 81, 0.04)",o}function Tt(n,t){const e=document.createElement("div");return e.className="cnv-panel-zalo__skeleton",e.style.width=n+"px",e.style.height=t+"px",e}function Dt(n,t){const e=document.createElement("div");e.className="cnv-panel-zalo__corner tl",e.style.borderColor=t;const o=document.createElement("div");o.className="cnv-panel-zalo__corner br",o.style.borderColor=t,n.append(e,o)}function jt(n){const t=document.createElement("div");t.className="cnv-panel-vstack";const e=document.createElement("div");e.className="cnv-panel-zalo__qr",e.appendChild(Tt(180,180)),Dt(e,n),t.appendChild(e);const o=document.createElement("div");return o.className="cnv-panel-vstack",o.style.gap="6px",o.append(Tt(240,14),Tt(160,14)),t.appendChild(o),t.appendChild(Tt(120,14)),t}function Rt(n,t,e,o){const r=document.createElement("div");r.className="cnv-panel-zalo__overlay-bubble";const i=document.createElement("div");i.className="cnv-panel-bubble-icon",i.style.background=e,i.style.color=t,i.appendChild(ut(n,20));const c=document.createElement("div");return c.className="cnv-panel-zalo__title",c.textContent=o,r.append(i,c),r}function Bt(n,t,e){let o=n,r=null;const i=()=>{null!==r&&(clearInterval(r),r=null)};return!0===t(o)||(r=setInterval(()=>{o-=1,(!0===t(o)||o<=0)&&(i(),e&&e())},1e3)),i}function Ft(n){if(!n)return null;const t=Date.parse(n);if(!Number.isFinite(t))return null;const e=new Date(t),o=n=>String(n).padStart(2,"0");return`${o(e.getDate())}/${o(e.getMonth()+1)}/${e.getFullYear()}`}function Lt(n){return n instanceof In?n.reason:null}function Pt(n){switch(Lt(n)){case"disabled":return"Đăng nhập bằng Zalo hiện đang tắt.";case"consent-required":return"Cần đồng ý thu thập dữ liệu để đăng nhập bằng Zalo.";case"expired":return"Mã QR đã hết hạn.";case"denied":return"Đăng nhập đã bị từ chối.";case"cancelled":return"Đã huỷ đăng nhập.";default:return"Vui lòng thử lại giúp mình nhé."}}function $t(o,r){if("undefined"==typeof document||"undefined"==typeof window)return()=>{};try{let i,c,l,a=null,u=null,s=null,d=null,f=null,p=null,h=null,v=null,m=null,g=null,b=null,y=!1,_=null,w=null,x=!1,k=!1,A=!1,C=[],M=0,O=!1,S=null,I=null,E=null,N=!1,z=0,T=[],D=0,U=null,G=!1,Z=!1,W=kt[0].key,Y=[],X=0,nn=0,tn=!1,en=null,on=null,rn=!1,cn=0,ln=null,an=null;function un(t){const e="owned"===t?ln:an;e&&("owned"===t?ln=null:an=null,n(()=>e.abort()))}function sn(){return"undefined"!=typeof AbortController?new AbortController:null}let dn=null,fn=!1,pn=null,hn=0,vn=0,mn=0,gn=null,bn=null,yn=null;const _n=n=>{"Escape"===n.key&&We()};function wn(n){return!x||n!==vn}function xn(n,e){return t(()=>{const t=new CustomEvent(n,{detail:{action:e},cancelable:!0});return window.dispatchEvent(t),t.defaultPrevented},!1)}function An(n){xn("cnv:panel:cta-click",n)}function Cn(n){return()=>{y&&n()}}function Mn(n,t,e){const o=document.createElement("div");o.className="cnv-panel-section__row",e&&(o.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2");const i=pt[t];if(i){const n=ut(i,20);n.style.color=Zn(r),o.appendChild(n)}const c=document.createElement("span");return c.className="cnv-panel-section__row-label",c.textContent=n,o.appendChild(c),o.appendChild(ut(Jn,12,"cnv-panel-icon--chevron")),o.addEventListener("click",Cn(()=>{xn("cnv:panel:menu-click",t)||("rewards"===t?(k=!0,W=kt[0].key,dn=null,De(),ie(),Rn()):"history"===t?(A=!0,De(),se(),C.length||(M=0,ue())):vt[t]&&(S=t,De(),me()))})),o}function On(){var n,t,e,o;const i=zt(r,"cnv-panel-cta"),c=r.accountCreationCta,l=document.createElement("div");l.className="cnv-panel-cta__title",l.textContent=(null==c?void 0:c.title)||"";const a=document.createElement("div");a.className="cnv-panel-cta__desc",a.textContent=(null==c?void 0:c.description)||"";const u=document.createElement("button");u.type="button",u.className="cnv-panel-cta__btn",u.style.borderRadius=Gn(null===(n=r.shapes)||void 0===n?void 0:n.button),u.style.backgroundColor=L(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,R),u.style.color=L(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,B),u.appendChild(ut(Yn,15)),u.appendChild(document.createTextNode(((null==c?void 0:c.createAccountButtonText)||"").trim()||gt)),u.addEventListener("click",Cn(()=>{An("create-account"),Ke()})),i.append(l,a,u);const s=((null==c?void 0:c.signInLinkText)||"").trim();if(s){const n=document.createElement("div");n.className="cnv-panel-cta__signin",n.style.color=L(null===(o=r.colors)||void 0===o?void 0:o.linkColor,R),n.appendChild(document.createTextNode(s)),n.appendChild(ut(Jn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",Cn(()=>{An("sign-in"),Ke()})),i.appendChild(n)}return i}function Sn(){var n;const t=r.accountCreationCta,e=((null==t?void 0:t.description)||"").trim()||((null==t?void 0:t.title)||"").trim();if(!e)return null;const o="DARK"===r.theme,i=document.createElement("div");return i.className="cnv-panel-card__section cnv-panel-join-hint",i.style.borderRadius=Gn(null===(n=r.shapes)||void 0===n?void 0:n.card),i.style.backgroundColor=o?"#2A2E44":"#F1F1F4",i.style.color=o?"rgba(255,255,255,.72)":"rgba(24,28,50,.66)",i.textContent=e,i}function In(){var n,t,e,o;const i=r.accountCreationCta,c="DARK"===r.theme,l=document.createElement("div");l.className="cnv-panel-joinbar",l.style.backgroundColor=c?"#181C32":"#FFFFFF",l.style.borderTop=c?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2";const a=document.createElement("button");a.type="button",a.className="cnv-panel-cta__btn",a.style.borderRadius=Gn(null===(n=r.shapes)||void 0===n?void 0:n.button),a.style.backgroundColor=L(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,R),a.style.color=L(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,B),a.appendChild(ut(Yn,15)),a.appendChild(document.createTextNode(((null==i?void 0:i.createAccountButtonText)||"").trim()||gt)),a.addEventListener("click",Cn(()=>{An("create-account"),Ke()})),l.appendChild(a);const u=((null==i?void 0:i.signInLinkText)||"").trim();if(u){const n=document.createElement("div");n.className="cnv-panel-cta__signin",n.style.color=L(null===(o=r.colors)||void 0===o?void 0:o.linkColor,R),n.appendChild(document.createTextNode(u)),n.appendChild(ut(Jn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",Cn(()=>{An("sign-in"),Ke()})),l.appendChild(n)}return l}function En(){var n;return null!==(n=null==E?void 0:E.points)&&void 0!==n?n:null==_?void 0:_.points}function Nn(n=!1){if(!(null==_?void 0:_.isMember)||N)return;if(!n&&E&&Date.now()-z<3e4)return;const t=Hn(o.projectId);if(!t)return;N=!0,un("owned");const e=sn();ln=e,y&&Ne(),o.fetchRewardsSummary(t.token,1,e?e.signal:void 0).then(n=>{N=!1,e&&e.signal.aborted||(n?(E=n,z=Date.now(),T=n.rewards.slice(),D=1,y&&Ne()):y&&Ne())}).catch(()=>{N=!1,y&&Ne()})}function zn(){return(Array.isArray(r.sections)?r.sections:[]).some(n=>"VIP"===n.type&&n.enabled)}function Tn(){const n=null==E?void 0:E.rewardsAvailableCount;return"number"==typeof n&&D?Math.max(0,n-T.length):0}function Dn(){if(Z||!Tn())return;const n=Hn(o.projectId);if(!n)return;const t=D+1;Z=!0,k&&ie(),o.fetchRewardsSummary(n.token,t).then(n=>{Z=!1,D=t,n&&(n.rewards.length&&(T=T.concat(n.rewards)),"number"==typeof n.rewardsAvailableCount&&E&&(E=Object.assign(Object.assign({},E),{rewardsAvailableCount:n.rewardsAvailableCount}))),k&&ie()}).catch(()=>{Z=!1,k&&ie()})}function jn(n){if(W===n)return;const t=W;W=n,dn=null,en=null,At(),un(t),De(),ie(),Rn(!0)}function Rn(n=!1){if("redeem"===W){if(!n&&Y.length&&Date.now()-nn<3e4)return;return X=0,Y=[],void Bn()}Nn(n)}function Bn(){if(tn)return;const n=Hn(o.projectId);if(!n)return;const t=X+1;tn=!0,un("redeem");const e=sn();an=e,k&&ie(),o.fetchRedeemableRewards(n.token,t,e?e.signal:void 0).then(n=>{tn=!1,X=t,n&&(1===t&&(nn=Date.now()),"number"==typeof n.total&&(c=n.total),"number"==typeof n.points&&(l=n.points),n.rewards.length&&(Y=Y.concat(n.rewards))),k&&ie()}).catch(()=>{tn=!1,k&&ie()})}function Fn(){return null!=l?l:En()}function Ln(){return null!==Hn(o.projectId)}function Vn(n,t,e){const o=document.createElement("div");o.className="cnv-panel-reward__meta",o.textContent=e,n.appendChild(o);const r=document.createElement("button");r.type="button",r.className="cnv-panel-zalo__btn cnv-panel-reward__more",r.textContent="Đăng nhập bằng Zalo",r.style.borderColor=t,r.style.color=t,r.addEventListener("click",Cn(Ke)),n.appendChild(r)}function Qn(n,t=!1){const e=wt(n);if(fn||null===e)return;const r=Hn(o.projectId);if(!r)return;if(xn("cnv:panel:redeem-click","redeem-confirm"))return;const i=t&&pn?pn:kn();pn=i;const c=++hn;fn=!0,dn={kind:"confirm",item:n},ie(),o.redeemReward(r.token,e,i).then(t=>{var e;Xn(c)&&(fn=!1),t.ok&&(pn=null,e=t.result,Ct(),l="number"==typeof e.pointsRemaining?e.pointsRemaining:void 0,Nn()),k&&Xn(c)&&(dn=t.ok?{kind:"success",item:n,result:t.result}:{kind:"error",code:t.code,item:n},ie())}).catch(()=>{Xn(c)&&(fn=!1),k&&Xn(c)&&(Ct(),dn={kind:"error",code:"UNCONFIRMED",item:n},ie())})}function Xn(n){return n===hn}function et(n){const t=n.redeemId;if(rn||"number"!=typeof t||t<=0)return;const e=Hn(o.projectId);if(!e)return;const r=++cn;rn=!0,on={kind:"confirm",item:n},ie(),o.useReward(e.token,t).then(e=>{const o=e.ok?yt(t,n,e.result):null;r===cn&&(rn=!1),k&&r===cn&&(o?(on=null,en=o):e.ok||(on={kind:"error",code:e.code,item:n}),De(),ie())}).catch(()=>{r===cn&&(rn=!1),k&&r===cn&&(on={kind:"error",code:"UNCONFIRMED",item:n},ie())})}function yt(n,t,e){const o=T.findIndex(t=>t.redeemId===n),r=o>=0?T[o]:t,i=Object.assign(Object.assign({},r),{code:e.code,usedAt:e.usedAt||r.usedAt,expiredAt:e.expiredAt||r.expiredAt,canUse:!1});return o>=0&&(T[o]=i),i}function _t(){dn=null,en=null,fn=!1,hn++,At()}function At(){on=null,rn=!1,cn++}function Ct(){E=null,z=0,T=[],D=0,C=[],i=void 0,M=0,Y=[],c=void 0,X=0,nn=0}function $t(n,t,e){const o=document.createElement("div");if(o.className="cnv-panel-reward",t&&(o.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2"),P(n.imageUrl)){const t=document.createElement("img");t.className="cnv-panel-reward__thumb",t.src=n.imageUrl,t.alt="",t.loading="lazy",t.decoding="async",t.addEventListener("error",()=>t.remove()),o.appendChild(t)}const i=document.createElement("div");i.className="cnv-panel-reward__main",i.appendChild(Qt(n.title||"Ưu đãi"));const c="number"==typeof n.useRemain&&n.useRemain>1,l=!!n.usedAt;if(n.discountValue||c||l){const t=document.createElement("div");if(t.className="cnv-panel-reward__tags",l){const e=document.createElement("span");e.className="cnv-panel-reward__uses";const o=Ft(n.usedAt);e.textContent=o?`Đã dùng ${o}`:"Đã dùng",t.appendChild(e)}if(n.discountValue){const o=document.createElement("span");o.className="cnv-panel-reward__value",Wn(o,e),o.textContent=n.discountValue,t.appendChild(o)}if(c){const e=document.createElement("span");e.className="cnv-panel-reward__uses",e.textContent=`Còn ${n.useRemain} lượt`,t.appendChild(e)}i.appendChild(t)}const a=Ft(n.expiredAt);if(a){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=`HSD ${a}`,i.appendChild(n)}if(o.appendChild(i),n.code||n.canUse){const t=document.createElement("div");t.className="cnv-panel-reward__side";const r=document.createElement("button");r.type="button",r.className="cnv-panel-zalo__btn cnv-panel-reward__cta cnv-panel-reward__show",r.textContent=n.canUse?"Sử dụng":"Xem mã",r.style.borderColor=e,r.style.color=e,r.addEventListener("click",Cn(()=>{if(!n.canUse)return en=n,De(),void ie();Ut(n)})),t.appendChild(r),o.appendChild(t)}return o}function Ut(n){if(n.burnOnUse)return on={kind:"confirm",item:n},De(),void ie();et(n)}function Vt(n,t,e){const o=Rt(rn?nt:Yn,rn?lt:t,rn?at:V(t,.12),e.title||"Ưu đãi"),r=document.createElement("div");r.className="cnv-panel-zalo__status",r.textContent=rn?"Đang lấy mã…":"Mã sẽ không còn hiệu lực sau khi ấn dùng ngay. Bạn có chắc muốn dùng ngay không?",o.appendChild(r),n.appendChild(o);const i=document.createElement("div");i.className="cnv-panel-redeem__actions";const c=document.createElement("button");c.type="button",c.className="cnv-panel-zalo__btn",c.textContent="Hủy",c.disabled=rn,rn||c.addEventListener("click",Cn(()=>{on=null,De(),ie()}));const l=document.createElement("button");l.type="button",l.className="cnv-panel-zalo__btn",l.textContent=rn?"Đang xử lý…":"Dùng ngay",l.disabled=rn,rn||(l.style.borderColor=t,l.style.color=t,l.addEventListener("click",Cn(()=>et(e)))),i.append(c,l),n.appendChild(i)}function Ht(n,t,e,o){const r=o&&It[o]||Et,i="UNCONFIRMED"===o,c=Rt(i?nt:Yn,i?lt:it,i?at:ct,i?"Chưa xác nhận được":"Chưa dùng được ưu đãi");if(e.title){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.title,c.appendChild(n)}const l=document.createElement("div");l.className="cnv-panel-zalo__status",l.textContent=r.message,l.setAttribute("role","alert"),c.appendChild(l),n.appendChild(c);const a=document.createElement("div");a.className="cnv-panel-redeem__actions";const u=document.createElement("button");if(u.type="button",u.className="cnv-panel-zalo__btn",u.textContent="Về danh sách",u.addEventListener("click",Cn(()=>{on=null,De(),ie()})),a.appendChild(u),"retry"===r.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Thử lại",n.style.borderColor=t,n.style.color=t,n.addEventListener("click",Cn(()=>et(e))),a.appendChild(n)}n.appendChild(a)}function Kt(n,t){const e=document.createElement("button");return e.type="button",e.className="cnv-panel-zalo__btn",e.textContent="Sao chép mã",e.style.borderColor=t,e.style.color=t,e.addEventListener("click",Cn(()=>{e.disabled||(e.disabled=!0,function(n){return J(this,void 0,void 0,function*(){if(!n)return!1;try{if(navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return yield navigator.clipboard.writeText(n),!0}catch(n){}let t=null;try{return t=document.createElement("textarea"),t.value=n,t.setAttribute("readonly",""),t.style.cssText="position:fixed;top:-1000px;left:-1000px;opacity:0;pointer-events:none;",document.body.appendChild(t),t.select(),t.setSelectionRange(0,n.length),document.execCommand("copy")}catch(n){return!1}finally{t&&t.parentNode&&t.parentNode.removeChild(t)}})}(n).then(n=>{e.isConnected&&(e.textContent=n?"Đã chép":"Không chép được",e.style.borderColor=n?ot:t,e.style.color=n?ot:t,window.setTimeout(()=>{e.isConnected&&(e.textContent="Sao chép mã",e.style.borderColor=t,e.style.color=t,e.disabled=!1)},1600))}))})),e}function qt(n,t,e){const o=Rt(Yn,t,V(t,.12),e.title||"Ưu đãi");if(e.discountValue){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.discountValue,o.appendChild(n)}if(e.canUse){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Bấm "Dùng ngay" để hiện mã.',o.appendChild(n)}else{const n=document.createElement("div");n.className="cnv-panel-reward__code cnv-panel-reward__code--big",n.textContent=e.code,o.appendChild(n)}if(e.usedAt){const n=document.createElement("span");n.className="cnv-panel-reward__uses";const t=Ft(e.usedAt);n.textContent=t?`Đã dùng ${t}`:"Đã dùng",o.appendChild(n)}if(e.channelLabel){const n=document.createElement("div");n.className="cnv-panel-reward__channel",n.textContent=e.channelLabel,o.appendChild(n)}const r=[],i=Ft(e.expiredAt);if(i&&r.push(`HSD ${i}`),"number"==typeof e.useRemain&&e.useRemain>1&&r.push(`Còn ${e.useRemain} lượt`),r.length){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=r.join(" · "),o.appendChild(n)}if(n.appendChild(o),e.canUse){const o=document.createElement("div");o.className="cnv-panel-redeem__actions";const r=document.createElement("button");r.type="button",r.className="cnv-panel-zalo__btn",r.textContent="Dùng ngay",r.style.borderColor=t,r.style.color=t,r.addEventListener("click",Cn(()=>{en=null,Ut(e)})),o.appendChild(r),n.appendChild(o)}const c=document.createElement("div");c.className="cnv-panel-redeem__actions",e.canUse||c.appendChild(Kt(e.code,t));const l=document.createElement("button");l.type="button",l.className="cnv-panel-zalo__btn",l.textContent="Quay lại",l.addEventListener("click",Cn(()=>{en=null,De(),ie()})),c.appendChild(l),n.appendChild(c)}function Gt(n){const t=document.createElement("div");return t.className="cnv-panel-rtabs",t.setAttribute("role","tablist"),kt.forEach(e=>{const o=e.key===W,r=document.createElement("button");r.type="button",r.className="cnv-panel-rtab"+(o?" cnv-panel-rtab--on":""),r.setAttribute("role","tab"),r.setAttribute("aria-selected",o?"true":"false"),r.textContent=e.label,o&&(r.style.borderBottomColor=n,r.style.color=n),r.addEventListener("click",Cn(()=>jn(e.key))),t.appendChild(r)}),t}function Zt(n){return n.toLocaleString("vi-VN")+" điểm"}function Wt(n){return n>0?Zt(n):"Miễn phí"}function Yt(n,t,e){t.length>15?n.style.fontSize=Math.round(.62*e)+"px":t.length>11&&(n.style.fontSize=Math.round(.77*e)+"px")}function Jt(n,t){const e=document.createElement("div");e.className="cnv-panel-balance";const o=document.createElement("div");o.className="cnv-panel-balance__label",o.textContent="Điểm của bạn";const r=document.createElement("div");r.className="cnv-panel-balance__row";const i=document.createElement("div");i.className="cnv-panel-balance__num",i.style.color=t;const c=n.toLocaleString("vi-VN");i.textContent=c,Yt(i,c,26);const l=document.createElement("div");return l.className="cnv-panel-balance__unit",l.textContent="điểm",r.append(i,l),e.append(o,r),e}function Qt(n){const t=document.createElement("div");t.className="cnv-panel-reward__name";const e=document.createElement("div");e.className="cnv-panel-reward__title",e.textContent=n,e.title=n;const o=document.createElement("button");return o.type="button",o.className="cnv-panel-reward__info",o.setAttribute("aria-label","Xem đầy đủ tên ưu đãi"),o.appendChild(ut('<circle cx="12" cy="12" r="9" stroke="currentColor" stroke-width="1.8"/><path d="M12 10.6v6" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><circle cx="12" cy="7.6" r="1.1" fill="currentColor"/>',14)),o.addEventListener("click",()=>{e.classList.toggle(mt)}),t.append(e,o),t}function Xt(n){if(null===wt(n)||"number"!=typeof n.redeemPoints)return"Chưa thể đổi ưu đãi này";if(!1===n.stock)return"Đã hết hàng";if("number"==typeof n.redeemRemain&&n.redeemRemain<=0)return"Bạn đã đạt giới hạn đổi";const t=Fn();return"number"==typeof t&&t<n.redeemPoints?`Cần thêm ${Zt(n.redeemPoints-t)}`:null}function ne(n,t,e){const o=document.createElement("div");if(o.className="cnv-panel-reward",t&&(o.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2"),P(n.imageUrl)){const t=document.createElement("img");t.className="cnv-panel-reward__thumb",t.src=n.imageUrl,t.alt="",t.loading="lazy",t.decoding="async",t.addEventListener("error",()=>t.remove()),o.appendChild(t)}const i=document.createElement("div");if(i.className="cnv-panel-reward__main",i.appendChild(Qt(n.title||"Ưu đãi")),n.discountValue){const t=document.createElement("div");t.className="cnv-panel-reward__tags";const o=document.createElement("span");o.className="cnv-panel-reward__value",Wn(o,e),o.textContent=n.discountValue,t.appendChild(o),i.appendChild(t)}const c=Ft(n.expiredAt);if(c){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=`HSD ${c}`,i.appendChild(n)}const l=Xt(n);if(l){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=l,i.appendChild(n)}o.appendChild(i);const a=document.createElement("div");if(a.className="cnv-panel-reward__side","number"==typeof n.redeemPoints){const t=document.createElement("div");t.className="cnv-panel-reward__price",t.style.color=e,t.textContent=Wt(n.redeemPoints),a.appendChild(t)}const u=document.createElement("button");return u.type="button",u.className="cnv-panel-zalo__btn cnv-panel-reward__cta",u.textContent="Đổi",u.disabled=null!==l||fn,u.disabled||(u.style.borderColor=e,u.style.color=e,u.addEventListener("click",Cn(()=>{dn={kind:"confirm",item:n},De(),ie()}))),a.appendChild(u),o.appendChild(a),o}function te(n,t){const e=Fn();if("number"==typeof e&&n.appendChild(Jt(e,t)),!Ln())return void Vn(n,t,"Bạn cần đăng nhập để xem ưu đãi có thể đổi.");if(tn&&!Y.length)return n.appendChild(Tt(200,12)),void n.appendChild(Tt(150,12));if(!Y.length){const t=document.createElement("div");return t.className="cnv-panel-reward__meta",t.textContent="Hiện chưa có ưu đãi nào để đổi.",void n.appendChild(t)}const o=document.createElement("div");o.className="cnv-panel-reward__list",Y.forEach((n,e)=>o.appendChild(ne(n,e>0,t))),n.appendChild(o);const r="number"==typeof c&&X?Math.max(0,c-Y.length):0;if(r>0||tn){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more",t.disabled=tn,t.textContent=tn?"Đang tải…":`Xem thêm ${r} ưu đãi`,t.addEventListener("click",Cn(Bn)),n.appendChild(t)}}function ee(n,t,e){const o=Rt(Yn,t,V(t,.12),e.title||"Ưu đãi");if("number"==typeof e.redeemPoints){const n=document.createElement("div");n.className="cnv-panel-redeem__cost",n.style.color=t;const r=Wt(e.redeemPoints);n.textContent=r,Yt(n,r,20),o.appendChild(n);const i=Fn();if(e.redeemPoints>0&&"number"==typeof i){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=`Còn lại ${Zt(i-e.redeemPoints)}`,o.appendChild(n)}}n.appendChild(o);const r=document.createElement("div");r.className="cnv-panel-redeem__actions";const i=document.createElement("button");i.type="button",i.className="cnv-panel-zalo__btn",i.textContent="Hủy",i.disabled=fn,fn||i.addEventListener("click",Cn(()=>{dn=null,ie()}));const c=document.createElement("button");c.type="button",c.className="cnv-panel-zalo__btn",c.textContent=fn?"Đang đổi…":"Đổi",c.disabled=fn,fn||(c.style.borderColor=t,c.style.color=t,c.addEventListener("click",Cn(()=>Qn(e)))),r.append(i,c),n.appendChild(r)}function oe(n,t,e,o){var r;const i=Rt(tt,ot,rt,"Đổi thành công"),c=document.createElement("div");if(c.className="cnv-panel-redeem__sub",c.textContent=e.title||"Ưu đãi",i.appendChild(c),e.burnOnUse){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Mã đã sẵn sàng trong "Ưu đãi của bạn" — bấm Sử dụng khi bạn dùng nhé.',i.appendChild(n)}else if(o.code){const n=document.createElement("div");n.className="cnv-panel-reward__code",n.textContent=o.code,i.appendChild(n)}else{const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent='Chưa có mã ngay — bạn kiểm tra ở tab "Ưu đãi của bạn" nhé.',i.appendChild(n)}const l=null!==(r=o.pointsSpent)&&void 0!==r?r:e.redeemPoints,a=[];if("number"==typeof l&&l>0&&a.push(`Đã dùng ${Zt(l)}`),"number"==typeof o.pointsRemaining&&a.push(`còn lại ${Zt(o.pointsRemaining)}`),a.length){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=a.join(" · "),i.appendChild(n)}if(o.transactionId){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=`Mã giao dịch ${o.transactionId}`,i.appendChild(n)}if(n.appendChild(i),!e.burnOnUse&&o.code){const e=document.createElement("div");e.className="cnv-panel-redeem__actions",e.appendChild(Kt(o.code,t)),n.appendChild(e)}const u=document.createElement("div");u.className="cnv-panel-redeem__actions";const s=document.createElement("button");s.type="button",s.className="cnv-panel-zalo__btn",s.textContent="Ưu đãi của bạn",s.addEventListener("click",Cn(()=>jn("owned")));const d=document.createElement("button");d.type="button",d.className="cnv-panel-zalo__btn",d.textContent="Đổi tiếp",d.addEventListener("click",Cn(()=>{dn=null,De(),ie(),"redeem"!==W||Y.length||(X=0,Bn())})),u.append(d,s),n.appendChild(u)}function re(n,t,e,o){var r;const i=((n,t)=>{var e;if(t){if(void 0!==(null===(e=wt(n))||void 0===e?void 0:e.redeemPoints)&&Ot[t])return Ot[t];if(Mt[t])return Mt[t]}return St})(e,o),c="neutral"===i.tone,l=Rt(c?nt:Yn,c?lt:it,c?at:ct,null!==(r=i.heading)&&void 0!==r?r:"Không đổi được ưu đãi");if(e.title){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=e.title,l.appendChild(n)}const a=document.createElement("div");a.className="cnv-panel-zalo__status",a.textContent=i.message,a.setAttribute("role","alert"),l.appendChild(a),n.appendChild(l);const u=document.createElement("div");u.className="cnv-panel-redeem__actions";const s=()=>{dn=null,De(),ie()},d=Nt[i.action];if("other"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.addEventListener("click",Cn(s)),u.appendChild(n)}else if("owned"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.addEventListener("click",Cn(()=>jn("owned"))),u.appendChild(n)}else{const n=document.createElement("button");if(n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Về danh sách",n.addEventListener("click",Cn(s)),u.appendChild(n),"retry"===i.action){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn",n.textContent=d,n.style.borderColor=t,n.style.color=t,n.addEventListener("click",Cn(()=>Qn(e,!i.retryWithNewKey))),u.appendChild(n)}}n.appendChild(u)}function ie(){var n,t;if(!h)return;Re(),Be(),je(!0);const e=null!==(t=null===(n=h.querySelector(".cnv-panel-rlist"))||void 0===n?void 0:n.scrollTop)&&void 0!==t?t:0;h.textContent="";const o=Zn(r),i="redeem"===W?null!==dn:null!==on||null!==en,c=zt(r,i?"cnv-panel-phase":"cnv-panel-rcard");let l=c;if(!i){const n=document.createElement("div");n.className="cnv-panel-section__head",n.appendChild(st(Yn,o));const t=document.createElement("div");t.className="cnv-panel-section__title",t.textContent="Ưu đãi",n.appendChild(t);const e=document.createElement("div");e.className="cnv-panel-rhead",e.append(n,Gt(o)),c.appendChild(e),l=document.createElement("div"),l.className="cnv-panel-rlist",c.appendChild(l)}"redeem"===W?"confirm"===(null==dn?void 0:dn.kind)?ee(c,o,dn.item):"success"===(null==dn?void 0:dn.kind)?oe(c,o,dn.item,dn.result):"error"===(null==dn?void 0:dn.kind)?re(c,o,dn.item,dn.code):te(l,o):"confirm"===(null==on?void 0:on.kind)?Vt(c,o,on.item):"error"===(null==on?void 0:on.kind)?Ht(c,o,on.item,on.code):en?qt(c,o,en):ce(l,o),h.appendChild(c),e>0&&l!==c&&(l.scrollTop=e),h&&h.querySelectorAll(".cnv-panel-reward__name").forEach(n=>{const t=n.querySelector(".cnv-panel-reward__title");if(!t)return;if(t.clientWidth<=0)return;const e=t.offsetHeight;t.classList.add(mt);const o=t.offsetHeight;t.classList.remove(mt),n.classList.toggle("cnv-panel-reward__name--clamped",o>e+1)})}function ce(n,t){if(!Ln())return void Vn(n,t,"Bạn cần đăng nhập để xem ưu đãi của bạn.");if(N&&!T.length)return n.appendChild(Tt(200,12)),void n.appendChild(Tt(150,12));if(!T.length){const t=document.createElement("div");return t.className="cnv-panel-reward__meta",t.textContent="Bạn chưa có ưu đãi nào.",void n.appendChild(t)}const e=document.createElement("div");e.className="cnv-panel-reward__list",T.forEach((n,o)=>e.appendChild($t(n,o>0,t))),n.appendChild(e);const o=Tn();if(o>0||Z){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more",t.disabled=Z,t.textContent=Z?"Đang tải…":`Xem thêm ${o} ưu đãi`,t.addEventListener("click",Dn),n.appendChild(t)}}function le(n){const t="earn"===n?r.earnBlocks:"redeem"===n?r.redeemBlocks:null;return Array.isArray(t)?t.filter(n=>n&&"string"==typeof n.title&&""!==n.title.trim()).slice(0,12):[]}function ae(n,t,e,o){const i=document.createElement("div");i.className="cnv-panel-block",t&&(i.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2");const c=ht[n.icon];i.appendChild(st("string"==typeof c?c:o,e));const l=document.createElement("div");l.className="cnv-panel-block__main";const a=document.createElement("div");a.className="cnv-panel-block__title",a.textContent=n.title.trim(),l.appendChild(a);const u="string"==typeof n.description?n.description.trim():"";if(u){const n=document.createElement("div");n.className="cnv-panel-block__desc",n.textContent=u,l.appendChild(n)}return i.appendChild(l),i}function ue(){if(O)return;const n=Hn(o.projectId);if(!n)return;const t=M+1;O=!0,A&&se(),o.fetchPointHistory(n.token,t).then(n=>{O=!1,M=t,n&&("number"==typeof n.totalCount&&(i=n.totalCount),n.items.length&&(C=C.concat(n.items))),A&&se()}).catch(()=>{O=!1,A&&se()})}function se(){if(!h)return;Re(),Be(),je(!0),h.textContent="";const n=Zn(r),t=zt(r);if(t.appendChild(ge({label:"Lịch sử hoạt động",icon:nt},n)),!C.length&&O)t.appendChild(Tt(180,12)),t.appendChild(Tt(120,12));else if(C.length){const n=document.createElement("div");n.className="cnv-panel-history__list",C.forEach((t,e)=>n.appendChild(de(t,e>0))),t.appendChild(n);const e="number"==typeof i&&M?Math.max(0,i-C.length):0;if(e>0||O){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn cnv-panel-reward__more",n.disabled=O,n.textContent=O?"Đang tải…":`Xem thêm ${e} hoạt động`,n.addEventListener("click",Cn(ue)),t.appendChild(n)}}else{const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent="Chưa có hoạt động nào.",t.appendChild(n)}h.appendChild(t)}function de(n,t){const e=document.createElement("div");e.className="cnv-panel-history__row",t&&(e.style.borderTop="DARK"===r.theme?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2");const o=document.createElement("div");o.className="cnv-panel-history__main";const i=document.createElement("div");i.className="cnv-panel-history__title",i.textContent=(n.title||"").trim()||"Hoạt động",o.appendChild(i);const c=(n.description||"").trim();c&&o.appendChild(fe(c));const l=[];"number"==typeof n.balanceAfter&&l.push("Điểm tích lũy: "+he(n.balanceAfter));const a=(n.rankAfter||"").trim();"number"==typeof n.expBalanceAfter?l.push("Điểm xét hạng: "+he(n.expBalanceAfter)+(a?" (Hạng "+a+")":"")):a&&l.push("Hạng "+a),l.length&&o.appendChild(fe(l.join(" / ")));const u=ve(n.createdAt);u&&o.appendChild(fe(u)),e.appendChild(o);const s=document.createElement("div");if(s.className="cnv-panel-history__amounts","number"==typeof n.points){const t=document.createElement("div");t.className="cnv-panel-history__points",t.textContent=pe(n.points)+" điểm",s.appendChild(t)}if("number"==typeof n.expPoints&&0!==n.expPoints){const t=document.createElement("div");t.className="cnv-panel-history__exp",t.textContent=pe(n.expPoints)+" xét hạng",s.appendChild(t)}return s.childElementCount&&e.appendChild(s),e}function fe(n){const t=document.createElement("div");return t.className="cnv-panel-history__meta",t.textContent=n,t}function pe(n){const t=Math.round(n);return(t>0?"+":"")+t.toLocaleString("vi-VN")}function he(n){return Math.round(n).toLocaleString("vi-VN")}function ve(n){if(!n)return null;const t=new Date(n);return Number.isNaN(t.getTime())?null:t.toLocaleDateString("vi-VN")+" "+t.toLocaleTimeString("vi-VN",{hour:"2-digit",minute:"2-digit"})}function me(){if(!h||!S)return;const n=vt[S];if(!n)return S=null,void Ie();const t=le(S);Re(),Be(),je(!0),h.textContent="";const e=Zn(r),o=zt(r);if(o.appendChild(ge(n,e)),t.length){const r=document.createElement("div");r.className="cnv-panel-block__list",t.forEach((t,o)=>r.appendChild(ae(t,o>0,e,n.icon))),o.appendChild(r)}else{const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent="redeem"===S?"Shop chưa cập nhật cách đổi điểm. Bạn quay lại sau nhé.":"Shop chưa cập nhật cách kiếm thêm điểm. Bạn quay lại sau nhé.",o.appendChild(n)}if(h.appendChild(o),!Te()){const n=Sn();n&&h.appendChild(n)}I=Te()}function ge(n,t){const e=document.createElement("div");e.className="cnv-panel-section__head",e.appendChild(st(n.icon,t));const o=document.createElement("div");return o.className="cnv-panel-section__title",o.textContent=n.label,e.appendChild(o),e}function be(n){if(!(Array.isArray(r.sections)?r.sections:[]).some(n=>"POINTS"===n.type&&n.enabled))return null;const t=zt(r),e=document.createElement("div");e.className="cnv-panel-section__desc",e.textContent="Kiếm điểm từ nhiều hoạt động, rồi đổi điểm lấy những ưu đãi hấp dẫn.";const o=document.createElement("div");return bt.forEach((n,t)=>o.appendChild(Mn(n[0],n[1],t>0))),t.append(ge(ft.POINTS,n),e,o),t}function ye(n){const t=Math.max(0,Math.round(n)).toLocaleString("vi-VN");return"SPENDING"===(null==U?void 0:U.applyFor)?t+"đ":t+" điểm"}function _e(n){const t=document.createElement("span");if(t.className="cnv-panel-tier__badge",P(n.iconUrl)){const e=document.createElement("img");return e.className="cnv-panel-tier__badge-img",e.alt="",e.src=n.iconUrl,t.appendChild(e),t}return t.style.backgroundColor=L(n.colorCode,Zn(r)),t}function we(n,t){var e,o;const r=document.createElement("div");r.className="cnv-panel-tier__row",t&&r.classList.add("cnv-panel-tier__row--current"),r.appendChild(_e(n));const i=document.createElement("span");return i.className="cnv-panel-tier__name",i.textContent=t?(null!==(e=n.name)&&void 0!==e?e:"")+" — bạn đang ở đây":null!==(o=n.name)&&void 0!==o?o:"",r.appendChild(i),r}function xe(n){const t=n.filter(n=>"string"==typeof n&&""!==n.trim());if(!t.length)return null;const e=document.createElement("ul");return e.className="cnv-panel-tier__benefits",t.forEach(n=>{const t=document.createElement("li");t.textContent=n.trim(),e.appendChild(t)}),e}function ke(n,t){const e=document.createElement("div");return e.className="cnv-panel-tier__more",e.textContent="…và "+n+(t?" hạng cao hơn":" hạng thấp hơn"),e}function Ae(n,t){var e;const o=n.progressTarget,i=null!==(e=n.progressCurrent)&&void 0!==e?e:0;if("number"!=typeof o||o<=0)return null;const c=document.createElement("div");c.className="cnv-panel-tier__progress";const l=document.createElement("div");l.className="cnv-panel-tier__bar",l.style.backgroundColor="DARK"===r.theme?"rgba(255,255,255,.16)":"rgba(24,28,50,.10)";const a=document.createElement("div");a.className="cnv-panel-tier__fill",a.style.backgroundColor=t,a.style.width=Math.max(0,Math.min(100,i/o*100)).toFixed(1)+"%",l.appendChild(a);const u=document.createElement("div");u.className="cnv-panel-tier__hint";const s="number"==typeof n.remaining?n.remaining:o-i;return u.textContent=n.nextLevelName?"Còn "+ye(s)+" nữa để lên "+n.nextLevelName:"Còn "+ye(s)+" nữa để lên hạng kế tiếp",c.append(l,u),c}function Ce(n,t){if(t<0)return{from:0,to:Math.min(n.length,4)};const e=Math.max(0,t-1);return{from:e,to:Math.min(n.length,e+4)}}function Me(n,t){var e,o;const i=null!==(e=null==U?void 0:U.tiers)&&void 0!==e?e:[];if(!i.length)return null;const c=zt(r),l=document.createElement("div"),a=t?null==E?void 0:E.tier:void 0;if(null==a?void 0:a.name){const t=document.createElement("div");t.className="cnv-panel-tier__current",t.appendChild(_e(a));const e=document.createElement("span");e.className="cnv-panel-tier__current-name",e.style.color=n,e.textContent=a.name,t.appendChild(e),l.appendChild(t);const o=Ae(a,n);if(o)l.appendChild(o);else if(a.isHighestLevel){const n=document.createElement("div");n.className="cnv-panel-tier__hint",n.textContent="Bạn đang ở hạng cao nhất.",l.appendChild(n)}}else if(!t){const n=document.createElement("div");n.className="cnv-panel-section__desc",n.textContent="Mua càng nhiều, hạng càng cao, quyền lợi càng nhiều.",l.appendChild(n)}const u=null!=(null==a?void 0:a.id)?i.findIndex(n=>n.id===a.id):-1,{from:s,to:d}=Ce(i,u),f=document.createElement("div");f.className="cnv-panel-tier__list",s>0&&f.appendChild(ke(s,!1));for(let n=s;n<d;n++){const t=n===u;if(f.appendChild(we(i[n],t)),t||u<0){const t=xe(i[n].benefits);t&&f.appendChild(t)}}const p=Math.max(null!==(o=null==U?void 0:U.totalTiers)&&void 0!==o?o:i.length,i.length)-d;return p>0&&f.appendChild(ke(p,!0)),l.appendChild(f),c.append(ge(ft.VIP,n),l),c}function Oe(n,t){const e=ft[n];if(!e||"string"!=typeof e.label)return null;if("VIP"===n)return Me(t,!0);const o=zt(r),i=ge(e,t),c=document.createElement("div");if("POINTS"!==n)return c.appendChild(dt("Sắp ra mắt",t)),o.append(i,c),o;const l=En();if("number"==typeof l&&Number.isFinite(l)){const n=document.createElement("div");n.className="cnv-panel-section__points",n.style.color=t;const e=l.toLocaleString("vi-VN");n.textContent=e,e.length>15&&(n.style.fontSize="20px"),c.appendChild(n)}else c.appendChild(dt("Đang cập nhật",t));const a=null!==(u=null==E?void 0:E.rewardsAvailableCount)&&void 0!==u?u:null==_?void 0:_.rewardsAvailableCount;var u;return[["number"==typeof a?`Ưu đãi của bạn — ${a} ưu đãi khả dụng`:"Ưu đãi của bạn","rewards"],...bt,["Lịch sử hoạt động","history"]].forEach((n,t)=>c.appendChild(Mn(n[0],n[1],t>0))),o.append(i,c),o}function Se(){if(!f||!p)return;const n=r.colors;u&&(u.style.backgroundColor="DARK"===r.theme?"#181C32":"#FFFFFF",u.style.color="DARK"===r.theme?"#FFFFFF":"#181C32");const t=f.parentElement;if(t&&(t.style.backgroundColor=L(null==n?void 0:n.bannerBg,R),t.style.color=L(null==n?void 0:n.bannerFont,B)),s&&(P(r.bannerImageUrl)?(s.src=r.bannerImageUrl,s.style.display="block"):(s.style.display="none",s.removeAttribute("src"))),d){const t=d.parentElement;P(r.brandIconUrl)?(d.src=r.brandIconUrl,t&&(t.style.display="flex",t.style.background=V(L(null==n?void 0:n.bannerFont,B),.18))):(t&&(t.style.display="none"),d.removeAttribute("src"))}const e=(null==_?void 0:_.isMember)?r.headerMember:r.headerVisitor,i=(null==_?void 0:_.isMember)?null===(c=Hn(o.projectId))||void 0===c?void 0:c.fullName:null;var c;f.textContent=xt((null==e?void 0:e.caption)||"",i),p.textContent=xt((null==e?void 0:e.title)||"",i)}function Ie(){if(!h||x||k||A||S)return;Re(),Be(),je(!0),h.textContent="";const n=Zn(r);if(!(null==_?void 0:_.isMember)){let t=0;Ee(On(),t++);const e=be(n);e&&Ee(e,t++);const o=zn()?Me(n,!1):null;return void(o&&Ee(o,t++))}const t=Array.isArray(r.sections)?[...r.sections]:[];let e=0;t.filter(n=>n.enabled&&"string"==typeof n.type).sort((n,t)=>{var e,o;return(null!==(e=n.order)&&void 0!==e?e:0)-(null!==(o=t.order)&&void 0!==o?o:0)}).forEach(t=>{const o=Oe(t.type,n);o&&Ee(o,e++)})}function Ee(n,t){n.style.animationDelay=40+55*t+"ms",h.appendChild(n)}function Ne(){Se(),S?I!==Te()&&me():Ie()}function ze(){un("owned"),un("redeem"),E=null,z=0,nn=0,T=[],D=0,k=!1,Y=[],c=void 0,X=0,l=void 0,pn=null,_t(),C=[],i=void 0,M=0,A=!1}function Te(){return!!(null==_?void 0:_.isMember)}function De(){if(!h)return;h.scrollTop=0;const n=h.querySelector(".cnv-panel-rlist");n&&(n.scrollTop=0)}function je(n){u&&(u.style.backgroundImage=n?((n,t)=>{if(!n||"NONE"===n)return"none";const e=((n,t)=>{switch(n){case"WAVES":return`<svg xmlns="http://www.w3.org/2000/svg" width="48" height="24" viewBox="0 0 48 24"><path d="M0 12c6 0 6 8 12 8s6-8 12-8 6 8 12 8 6-8 12-8" fill="none" stroke="${t}" stroke-width="2"/></svg>`;case"CUBES":return`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><rect x="4" y="4" width="14" height="14" fill="none" stroke="${t}" stroke-width="2"/><rect x="22" y="22" width="14" height="14" fill="none" stroke="${t}" stroke-width="2"/></svg>`;case"FUN":return`<svg xmlns="http://www.w3.org/2000/svg" width="44" height="44" viewBox="0 0 44 44"><circle cx="8" cy="10" r="2.4" fill="${t}"/><path d="M30 6l1.6 3.4 3.6.4-2.6 2.6.7 3.7-3.3-1.8-3.3 1.8.7-3.7-2.6-2.6 3.6-.4z" fill="${t}"/><circle cx="34" cy="34" r="2.4" fill="${t}"/><circle cx="10" cy="34" r="1.8" fill="${t}"/></svg>`;case"GEOMETRIC":return`<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path d="M8 36 16 12l8 24Z" fill="none" stroke="${t}" stroke-width="2"/><circle cx="36" cy="14" r="6" fill="none" stroke="${t}" stroke-width="2"/></svg>`;case"CROSS_HATCHING":return`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0 24 24M0 24 24 0" stroke="${t}" stroke-width="1.4"/></svg>`;default:return""}})(n,t?"rgba(255,255,255,0.16)":"rgba(17,17,17,0.10)");return e?`url("data:image/svg+xml,${encodeURIComponent(e)}")`:"none"})(r.wallpaper,"DARK"===r.theme):"none")}function Re(){const n=x||k||A||null!==S;m&&(m.style.display=n?"inline-flex":"none"),v&&v.classList.toggle("cnv-panel-banner--sub",n)}function Be(){if(!u)return;const n=!Te()&&null!==S;if(n&&!b)return b=In(),void u.insertBefore(b,g);!n&&b&&(b.remove(),b=null)}function Fe(){x&&(Pe(),x=!1),k=!1,_t(),A=!1,S=null,De(),Ie()}function Le(){gn=e(gn)}function Pe(){bn=e(bn)}function $e(n,t){Le();const e=Date.now()+1e3*t.expiresInSeconds;gn=Bt(t.expiresInSeconds,()=>{const t=Math.max(0,Math.round((e-Date.now())/1e3)),o=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");return n.textContent=`Hết hạn sau ${o}:${r}`,t<=0})}function Ue(){if(x=!1,Le(),Pe(),w){const t=w;w=null,n(()=>t.cancel())}}function Ve(){const n=document.createElement("button");return n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Huỷ",n.addEventListener("click",()=>{Ue(),Ne()}),n}function He(n){var t;if(!h)return;Re(),Be(),je(!1),h.textContent="";const e=Zn(r),o=zt(r,"cnv-panel-zalo");if("loading"===n.phase)o.appendChild(jt(e)),o.appendChild(Ve());else if("qr"===n.phase){const t=(n=>{try{const t=Q(0,"M");t.addData(n),t.make();const e=t.getModuleCount(),o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("viewBox",`0 0 ${e} ${e}`),o.setAttribute("width",String(180)),o.setAttribute("height",String(180));const r=document.createElementNS("http://www.w3.org/2000/svg","rect");r.setAttribute("width",String(e)),r.setAttribute("height",String(e)),r.setAttribute("fill","#fff"),o.appendChild(r);let i="";for(let n=0;n<e;n++)for(let o=0;o<e;o++)t.isDark(n,o)&&(i+=`M${o} ${n}h1v1h-1z`);const c=document.createElementNS("http://www.w3.org/2000/svg","path");return c.setAttribute("d",i),c.setAttribute("fill","#000"),o.appendChild(c),o}catch(n){return null}})(n.session.qrPayload);if(t){const n=document.createElement("div");n.className="cnv-panel-zalo__qr cnv-panel-zalo__qr--white",n.appendChild(t),Dt(n,e),o.appendChild(n)}const r=document.createElement("div");r.className="cnv-panel-zalo__status",r.appendChild(document.createTextNode("Mở "));const i=document.createElement("b");i.style.color=e,i.textContent="Zalo",r.appendChild(i),r.appendChild(document.createTextNode(" trên điện thoại và quét mã để đăng nhập")),o.appendChild(r);const c=document.createElement("div");c.className="cnv-panel-zalo__timer",c.appendChild(ut(nt,12));const l=document.createElement("span");c.appendChild(l),o.appendChild(c),$e(l,n.session),o.appendChild(Ve())}else{o.style.position="relative",o.appendChild(jt(e));const l=document.createElement("div");let a;if(l.className="cnv-panel-zalo__overlay",l.style.borderRadius=Gn(null===(t=r.shapes)||void 0===t?void 0:t.card),l.style.background="DARK"===r.theme?"rgba(63, 66, 84, 0.94)":"rgba(255, 255, 255, 0.94)","success"===n.phase)a=Rt(tt,ot,rt,n.result.fullName?`Xin chào ${n.result.fullName}!`:"Đăng nhập thành công!");else{const t="expired"===n.reason;a=Rt(t?nt:'<path d="M2 8.5a17 17 0 0 1 20 0M5.5 12.3a11.6 11.6 0 0 1 13 0M9 16a6 6 0 0 1 6 0M3 3l18 18" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/>',t?lt:it,t?at:ct,t?"Mã QR đã hết hạn":"Có lỗi xảy ra");const o=document.createElement("div");if(o.className="cnv-panel-zalo__status",o.textContent=t?'Bấm "Thử lại" để lấy mã mới.':n.message,a.appendChild(o),n.canRetry){const n=document.createElement("button");if(n.type="button",n.className="cnv-panel-zalo__btn",n.style.backgroundColor=e,n.style.borderColor=e,n.style.color="#fff",n.textContent="Thử lại",n.addEventListener("click",Cn(()=>Ke())),mn>=3){const t=Math.min(5+5*(mn-3),20);i=n,c=t,Pe(),i.disabled=!0,bn=Bt(c,n=>{n>0&&(i.textContent=`Thử lại (${n}s)`)},()=>{i.disabled=!1,i.textContent="Thử lại"})}a.appendChild(n)}}l.appendChild(a),o.appendChild(l)}var i,c;h.appendChild(o)}function Ke(){if(!h)return;Ue(),S=null,x=!0,De();const t=++vn;He({phase:"loading"}),o.loginWithZalo().then(e=>{wn(t)?n(()=>e.cancel()):(w=e,mn=0,He({phase:"qr",session:e}),e.result.then(n=>{if(!wn(t)){if(Le(),w=null,He({phase:"success",result:n}),null!=n.contactId&&"string"==typeof n.panelSessionToken&&n.panelSessionToken&&"number"==typeof n.panelSessionExp){const t="number"==typeof n.panelSessionExpiresInMs&&n.panelSessionExpiresInMs>0?Date.now()+n.panelSessionExpiresInMs:n.panelSessionExp;Kn(o.projectId,{token:n.panelSessionToken,contactId:n.contactId,fullName:n.fullName,level:n.level,xp:n.xp,exp:t}),uo(t)}_={isMember:!0},Nn(),setTimeout(()=>{wn(t)||(x=!1,Ne())},1500)}}).catch(n=>{wn(t)||(Le(),w=null,He({phase:"error",message:Pt(n),canRetry:!0,reason:Lt(n)}))}))}).catch(n=>{wn(t)||(mn+=1,He({phase:"error",message:Pt(n),canRetry:!0,reason:Lt(n)}))})}function qe(n){var t,e,o;if(a)return;const i=K("data-cnv-panel",':host{all:initial;}.cnv-panel-card{position:fixed;display:flex;flex-direction:column;background-repeat:repeat;width:min(360px,calc(100vw - 32px));height:600px;max-height:calc(100vh - 32px);overflow:hidden;box-shadow:0 20px 44px rgba(24,28,50,.22),0 4px 10px rgba(24,28,50,.12);font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;font-size:14px;line-height:1.4;animation:cnv-panel-in .34s cubic-bezier(.16,1,.3,1) both;}.cnv-panel-card--leaving{animation:cnv-panel-out .18s cubic-bezier(.4,0,1,1) both;pointer-events:none;}@keyframes cnv-panel-in{from{opacity:0;transform:translateY(14px) scale(.92);}to{opacity:1;transform:none;}}@keyframes cnv-panel-out{from{opacity:1;transform:none;}to{opacity:0;transform:translateY(10px) scale(.96);}}@keyframes cnv-panel-bubble-in{from{opacity:0;transform:translateY(4px) scale(.97);}to{opacity:1;transform:none;}}@keyframes cnv-panel-rise{from{opacity:0;transform:translateY(10px);}to{opacity:1;transform:none;}}@media (prefers-reduced-motion:reduce){.cnv-panel-card,.cnv-panel-card--leaving,.cnv-panel-card__section,.cnv-panel-zalo__overlay-bubble{animation:none !important;}}.cnv-panel-close{position:absolute;z-index:2;top:10px;right:10px;width:26px;height:26px;border:none;border-radius:999px;background:rgba(0,0,0,.18);color:#fff;cursor:pointer;font-size:16px;display:inline-flex;align-items:center;justify-content:center;line-height:1;padding:0;transition:background .15s;}.cnv-panel-close:hover{background:rgba(0,0,0,.3);}.cnv-panel-back{position:absolute;z-index:2;top:10px;left:10px;width:26px;height:26px;border:none;border-radius:999px;background:rgba(0,0,0,.18);color:#fff;cursor:pointer;padding:0;display:none;align-items:center;justify-content:center;transition:background .15s;}.cnv-panel-back:hover{background:rgba(0,0,0,.3);}.cnv-panel-banner{position:relative;flex:0 0 auto;padding:20px 20px 54px;min-height:160px;margin-bottom:-54px;box-sizing:border-box;overflow:hidden;}.cnv-panel-banner--sub{padding-left:44px;}.cnv-panel-banner__img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:.35;display:none;}.cnv-panel-banner__brandchip{position:relative;width:34px;height:34px;border-radius:10px;margin:0 0 10px;display:none;align-items:center;justify-content:center;overflow:hidden;}.cnv-panel-banner__brandicon{width:100%;height:100%;object-fit:cover;display:block;}.cnv-panel-banner__caption{position:relative;font-size:11.5px;opacity:.85;}.cnv-panel-banner__title{position:relative;font-size:26px;font-weight:800;line-height:1.24;margin-top:3px;}.cnv-panel-body{flex:1 1 auto;min-height:0;overflow:hidden auto;overscroll-behavior:contain;padding:16px;display:flex;flex-direction:column;gap:12px;position:relative;z-index:1;scrollbar-width:none;-ms-overflow-style:none;}.cnv-panel-body::-webkit-scrollbar{width:0;height:0;display:none;}.cnv-panel-footer{flex:0 0 auto;padding:11px 16px;display:flex;align-items:center;justify-content:center;gap:4px;font-size:11.5px;font-weight:500;}.cnv-panel-footer__brand{font-weight:800;}.cnv-panel-card__section{padding:16px;box-sizing:border-box;animation:cnv-panel-rise .34s cubic-bezier(.16,1,.3,1) both;}.cnv-panel-phase{flex:1 0 auto;display:flex;flex-direction:column;justify-content:center;}.cnv-panel-phase .cnv-panel-zalo__status{max-width:none;}.cnv-panel-chip{width:26px;height:26px;border-radius:8px;display:flex;align-items:center;justify-content:center;flex-shrink:0;}.cnv-panel-section__head{display:flex;align-items:center;gap:8px;margin-bottom:10px;}.cnv-panel-cta{text-align:center;}.cnv-panel-cta__title{font-size:15px;font-weight:800;margin-bottom:5px;}.cnv-panel-cta__desc{font-size:12.5px;line-height:1.5;opacity:.72;margin-bottom:14px;}.cnv-panel-history__row{display:flex;align-items:flex-start;gap:10px;padding:10px 0;}.cnv-panel-history__main{flex:1;min-width:0;}.cnv-panel-history__title{font-size:13px;font-weight:700;line-height:1.35;}.cnv-panel-history__meta{font-size:11.5px;line-height:1.45;opacity:.66;margin-top:2px;}.cnv-panel-history__amounts{flex:0 0 auto;text-align:right;}.cnv-panel-history__points{font-size:12.5px;font-weight:800;font-variant-numeric:tabular-nums;white-space:nowrap;}.cnv-panel-history__exp{font-size:11px;font-weight:700;font-variant-numeric:tabular-nums;white-space:nowrap;opacity:.66;margin-top:2px;}.cnv-panel-join-hint{padding:13px 16px;text-align:center;font-size:12.5px;line-height:1.5;font-weight:600;}.cnv-panel-joinbar{flex:0 0 auto;padding:12px 16px;}.cnv-panel-cta__btn{display:flex;align-items:center;justify-content:center;gap:6px;width:100%;height:40px;border:none;font-weight:700;cursor:pointer;margin-bottom:10px;font-size:13.5px;transition:filter .15s,transform .15s cubic-bezier(.16,1,.3,1);}.cnv-panel-cta__btn:hover{filter:brightness(1.06);transform:translateY(-1px);}.cnv-panel-cta__btn:active{transform:translateY(0) scale(.985);}.cnv-panel-cta__signin{display:flex;align-items:center;justify-content:center;gap:4px;font-size:12.5px;text-align:center;cursor:pointer;font-weight:700;}@media (max-height:560px){.cnv-panel-banner{min-height:96px;margin-bottom:-38px;padding:14px 16px 38px;}.cnv-panel-banner--sub{padding-left:44px;}.cnv-panel-banner__title{font-size:20px;}.cnv-panel-body{padding:12px;gap:8px;}.cnv-panel-joinbar{padding:8px 12px;}.cnv-panel-cta__btn{height:34px;margin-bottom:6px;}.cnv-panel-footer{padding:6px 12px;}}.cnv-panel-icon{display:inline-flex;flex-shrink:0;}.cnv-panel-icon--chevron{transition:transform .15s;}.cnv-panel-cta__signin:hover .cnv-panel-icon--chevron{transform:translateX(2px);}.cnv-panel-section__title{font-size:11.5px;font-weight:800;text-transform:uppercase;letter-spacing:.04em;opacity:.68;}.cnv-panel-section__points{font-size:28px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1;margin-bottom:6px;}.cnv-panel-section__desc{font-size:12.5px;line-height:1.5;opacity:.72;margin-bottom:4px;}.cnv-panel-section__row{font-size:12.5px;display:flex;align-items:center;gap:10px;padding:10px 0;cursor:pointer;}.cnv-panel-section__row-label{flex:1;min-width:0;}.cnv-panel-section__row:hover .cnv-panel-icon--chevron{transform:translateX(2px);}.cnv-panel-badge{display:inline-flex;align-items:center;font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.03em;padding:3px 8px;border-radius:999px;}.cnv-panel-tier__current{display:flex;align-items:center;gap:8px;margin-bottom:10px;}.cnv-panel-tier__current-name{font-size:19px;font-weight:800;line-height:1.2;}.cnv-panel-tier__badge{flex:0 0 auto;width:18px;height:18px;border-radius:999px;overflow:hidden;display:inline-flex;align-items:center;justify-content:center;}.cnv-panel-tier__badge-img{width:100%;height:100%;object-fit:cover;display:block;}.cnv-panel-tier__progress{margin-bottom:8px;}.cnv-panel-tier__bar{height:6px;border-radius:999px;overflow:hidden;}.cnv-panel-tier__fill{height:100%;border-radius:999px;transition:width .35s ease;}.cnv-panel-tier__hint{font-size:12px;line-height:1.5;opacity:.72;}.cnv-panel-tier__list{}.cnv-panel-tier__row{display:flex;align-items:center;gap:8px;font-size:12.5px;padding:7px 0;}.cnv-panel-tier__row--current{font-weight:800;}.cnv-panel-tier__name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.cnv-panel-tier__benefits{margin:0 0 6px 26px;padding:0 0 0 14px;font-size:12px;line-height:1.55;opacity:.72;}.cnv-panel-tier__more{font-size:11.5px;padding:5px 0 5px 26px;opacity:.58;}.cnv-panel-zalo{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;text-align:center;min-height:346px;}.cnv-panel-vstack{display:flex;flex-direction:column;align-items:center;gap:8px;}.cnv-panel-zalo__qr{position:relative;padding:10px;border-radius:12px;}.cnv-panel-zalo__qr--white{background:#fff;}.cnv-panel-zalo__qr svg{display:block;}.cnv-panel-zalo__corner{position:absolute;width:16px;height:16px;border:3px solid;border-radius:5px 0 0 0;}.cnv-panel-zalo__corner.tl{top:-3px;left:-3px;border-right:none;border-bottom:none;}.cnv-panel-zalo__corner.br{bottom:-3px;right:-3px;border-left:none;border-top:none;border-radius:0 0 5px 0;}.cnv-panel-zalo__title{font-size:14px;font-weight:800;}.cnv-panel-zalo__status{font-size:12.5px;font-weight:500;line-height:1.45;max-width:250px;}.cnv-panel-zalo__timer{font-size:11.5px;font-weight:700;opacity:.7;font-variant-numeric:tabular-nums;display:inline-flex;align-items:center;gap:5px;}.cnv-panel-reward__list{}.cnv-panel-reward{padding:10px 0;display:flex;gap:10px;align-items:flex-start;}.cnv-panel-reward__main{min-width:0;flex:1;}.cnv-panel-reward__thumb{width:44px;height:44px;flex:none;border-radius:8px;object-fit:cover;background:rgba(127,127,127,.12);}.cnv-panel-reward__title{font-size:13px;font-weight:700;line-height:1.4;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden;}.cnv-panel-reward__title--full{display:block;-webkit-line-clamp:none;overflow:visible;}.cnv-panel-reward__name{display:flex;align-items:flex-start;gap:4px;}.cnv-panel-reward__name>.cnv-panel-reward__title{flex:1 1 auto;min-width:0;}.cnv-panel-reward__info{display:none;flex:none;padding:0;margin-top:1px;border:none;background:transparent;color:inherit;opacity:.45;cursor:pointer;line-height:0;}.cnv-panel-reward__info:hover{opacity:.85;}.cnv-panel-reward__name--clamped .cnv-panel-reward__info{display:inline-flex;}.cnv-panel-reward__tags{display:flex;flex-wrap:wrap;gap:6px;margin-top:6px;}.cnv-panel-reward__value{font-size:12px;font-weight:800;padding:3px 8px;border-radius:999px;white-space:nowrap;}.cnv-panel-reward__uses{font-size:11.5px;font-weight:600;padding:3px 8px;border-radius:999px;background:rgba(127,127,127,.14);white-space:nowrap;}.cnv-panel-reward__code{font-size:13px;font-weight:800;letter-spacing:.06em;margin-top:6px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;user-select:all;}.cnv-panel-reward__meta{font-size:11.5px;opacity:.7;margin-top:4px;line-height:1.45;}.cnv-panel-reward__code--big{font-size:20px;margin-top:10px;}.cnv-panel-reward__channel{font-size:12px;opacity:.8;margin-top:6px;line-height:1.45;}.cnv-panel-reward__show{width:auto;white-space:nowrap;}.cnv-panel-reward__more{width:100%;margin-top:10px;}.cnv-panel-balance{padding:2px 0 8px;}.cnv-panel-balance__label{font-size:11.5px;opacity:.66;margin-bottom:2px;}.cnv-panel-balance__row{display:flex;align-items:baseline;gap:6px;flex-wrap:wrap;}.cnv-panel-balance__num{font-size:26px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1;}.cnv-panel-balance__unit{font-size:12.5px;font-weight:700;opacity:.7;}.cnv-panel-rtabs{display:flex;gap:2px;margin:2px 0 2px;border-bottom:1px solid rgba(127,127,127,.22);}.cnv-panel-rcard{flex:0 1 auto;min-height:0;display:flex;flex-direction:column;overflow:hidden;}.cnv-panel-rhead{flex:0 0 auto;}.cnv-panel-rlist{flex:1 1 auto;min-height:0;overflow:hidden auto;overscroll-behavior:contain;scrollbar-width:none;-ms-overflow-style:none;}.cnv-panel-rlist::-webkit-scrollbar{width:0;height:0;display:none;}.cnv-panel-rtab{flex:1;padding:9px 6px;margin-bottom:-1px;background:transparent;border:none;border-bottom:2px solid transparent;color:inherit;cursor:pointer;font-size:12.5px;font-weight:700;opacity:.6;transition:opacity .15s;font-family:inherit;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.cnv-panel-rtab:hover{opacity:.85;}.cnv-panel-rtab--on{opacity:1;font-weight:800;}.cnv-panel-reward__side{flex:0 0 auto;max-width:45%;display:flex;flex-direction:column;align-items:flex-end;gap:6px;}.cnv-panel-reward__price{font-size:12.5px;font-weight:800;font-variant-numeric:tabular-nums;text-align:right;}.cnv-panel-reward__cta{height:30px;padding:0 12px;font-size:12px;}.cnv-panel-redeem__cost{font-size:20px;font-weight:800;font-variant-numeric:tabular-nums;line-height:1.1;}.cnv-panel-redeem__sub{font-size:11.5px;opacity:.66;line-height:1.45;}.cnv-panel-redeem__actions{display:flex;gap:8px;margin-top:12px;justify-content:center;}.cnv-panel-redeem__actions .cnv-panel-zalo__btn{flex:1;}.cnv-panel-redeem__actions .cnv-panel-zalo__btn:only-child{flex:0 0 auto;}.cnv-panel-block__list{}.cnv-panel-block{padding:11px 0;display:flex;gap:10px;align-items:flex-start;}.cnv-panel-block .cnv-panel-chip{margin-top:1px;}.cnv-panel-block__main{min-width:0;flex:1;}.cnv-panel-block__title{font-size:13px;font-weight:700;line-height:1.4;}.cnv-panel-block__desc{font-size:12px;line-height:1.5;opacity:.72;margin-top:3px;white-space:pre-line;}.cnv-panel-zalo__btn{height:36px;padding:0 16px;border:1px solid rgba(127,127,127,.3);border-radius:10px;background:transparent;color:inherit;font-size:12.5px;font-weight:700;cursor:pointer;transition:filter .15s;}.cnv-panel-zalo__btn:hover:not(:disabled){filter:brightness(1.1);}.cnv-panel-zalo__btn:disabled{opacity:.5;cursor:not-allowed;}.cnv-panel-zalo__overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:16px;}.cnv-panel-zalo__overlay-bubble{display:flex;flex-direction:column;align-items:center;gap:10px;text-align:center;padding:0 8px;max-width:100%;animation:cnv-panel-bubble-in .2s ease;}.cnv-panel-bubble-icon{width:40px;height:40px;border-radius:999px;display:flex;align-items:center;justify-content:center;box-shadow:inset 0 0 0 1px rgba(127,127,127,.22);}.cnv-panel-zalo__skeleton{border-radius:6px;background:rgba(127,127,127,.15);background-image:linear-gradient( 90deg,rgba(127,127,127,.15) 25%,rgba(127,127,127,.32) 37%,rgba(127,127,127,.15) 63% );background-size:400% 100%;animation:cnv-panel-shimmer 1.4s ease infinite;}@keyframes cnv-panel-shimmer{0%{background-position:100% 50%;}100%{background-position:0% 50%;}}@media (prefers-reduced-motion:reduce){.cnv-panel-zalo__skeleton{animation:none;}}');a=i.hostEl;const c=i.shadow;a.style.setProperty("display","none");const l=null!==(t=(null==n?void 0:n.useCustomZIndex)?$(n.zIndex):null)&&void 0!==t?t:j,b=null!==(e=$(l+600))&&void 0!==e?e:j;u=document.createElement("div"),u.className="cnv-panel-card",u.style.zIndex=String(b),u.addEventListener("animationend",n=>{"cnv-panel-out"===n.animationName&&Ye()}),u.style.borderRadius=Gn(null===(o=r.shapes)||void 0===o?void 0:o.container);const y=document.createElement("button");y.type="button",y.className="cnv-panel-close",y.setAttribute("aria-label","Đóng"),y.textContent="×",y.addEventListener("click",We),m=document.createElement("button"),m.type="button",m.className="cnv-panel-back",m.setAttribute("aria-label","Quay lại"),m.appendChild(ut('<path d="M15 6l-6 6 6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',15)),m.addEventListener("click",Cn(Fe));const _=document.createElement("div");v=_,_.className="cnv-panel-banner",s=document.createElement("img"),s.className="cnv-panel-banner__img",s.alt="",d=document.createElement("img"),d.className="cnv-panel-banner__brandicon",d.alt="";const w=document.createElement("div");w.className="cnv-panel-banner__brandchip",w.appendChild(d),f=document.createElement("div"),f.className="cnv-panel-banner__caption",p=document.createElement("div"),p.className="cnv-panel-banner__title",_.append(s,w,f,p),h=document.createElement("div"),h.className="cnv-panel-body",u.append(y,m,_,h),g=Ge(),g&&u.appendChild(g),c.appendChild(u),q(a)}function Ge(){if(r.hideBranding)return null;const n="DARK"===r.theme,t=document.createElement("div");t.className="cnv-panel-footer",t.style.backgroundColor=n?"#181C32":"#FFFFFF",t.style.borderTop=n?"1px solid rgba(255,255,255,.12)":"1px solid #F1F1F2",t.style.color=n?"rgba(255,255,255,.62)":"rgba(24,28,50,.58)",t.appendChild(document.createTextNode("Cung cấp bởi "));const e=document.createElement("span");return e.className="cnv-panel-footer__brand",e.textContent="CNV CDP",t.appendChild(e),t}function Ze(n){if(!u)return;const{side:t,sideSpacingPx:e,bottomSpacingPx:o}=H(n,F());u.style.left="left"===t?e+"px":"auto",u.style.right="right"===t?e+"px":"auto";const r=o+48+24;u.style.bottom=r+"px",u.style.maxHeight=`calc(100vh - ${r+16}px)`,u.style.transformOrigin="left"===t?"left bottom":"right bottom"}function We(){a&&y&&(y=!1,Ue(),k=!1,_t(),A=!1,S=null,document.removeEventListener("keydown",_n),Qe("cnv:panel:closed"),u&&!t(()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,!1)?(u.classList.add(Un),yn=setTimeout(Ye,320)):Ye())}function Ye(){null!==yn&&(clearTimeout(yn),yn=null),null==u||u.classList.remove(Un),null==a||a.style.setProperty("display","none")}function Je(){null!==yn&&(clearTimeout(yn),yn=null),null==u||u.classList.remove(Un)}function Qe(t){n(()=>window.dispatchEvent(new CustomEvent(t)))}const Xe=t=>{n(()=>{var n;const e=t.detail;var r;y?We():(qe(r=null!==(n=null==e?void 0:e.config)&&void 0!==n?n:null),a&&(Je(),Ze(r),a.style.setProperty("display","block"),y=!0,Ne(),Nn(),!zn()||U||G||(G=!0,o.fetchPanelTiers().then(n=>{G=!1,n&&n.tiers.length&&(U=n,y&&Ne())}).catch(()=>{G=!1})),document.addEventListener("keydown",_n),Qe("cnv:panel:opened")))})},no=t=>{n(()=>{const n=t.detail;_=(null==n?void 0:n.isMember)?{isMember:!0,points:n.points,rewardsAvailableCount:n.rewardsAvailableCount}:{isMember:!1},_.isMember||ze(),y&&Ne(),y&&Nn()})},to=3e5,eo=15e3,oo=6e4;let ro=null,io=!1,co=!1;function lo(){null!==ro&&(clearTimeout(ro),ro=null)}function ao(n){lo(),co||(ro=t(()=>setTimeout(fo,Math.max(0,n)),null))}function uo(n){ao(Math.max(eo,n-Date.now()-to))}function so(){lo(),qn(o.projectId),_={isMember:!1},ze(),Ne()}function fo(){if(lo(),co||io)return;const n=Hn(o.projectId);n&&(Date.now()>n.exp?so():(io=!0,o.refreshPanelSession(n.token).then(t=>{if(io=!1,co)return;const e=Hn(o.projectId);if(!e)return;if(e.token!==n.token)return void uo(e.exp);if("ok"===t.kind)return Kn(o.projectId,Object.assign(Object.assign({},e),{token:t.token,exp:t.exp})),void uo(t.exp);if("unauthorized"===t.kind)return void so();const r=e.exp-Date.now();r<=0?so():ao(Math.min(oo,r))}).catch(()=>{if(io=!1,co)return;const t=n.exp-Date.now();t>0&&ao(Math.min(oo,t))})))}function po(){if("visible"!==document.visibilityState)return;const n=Hn(o.projectId);n&&(Date.now()>n.exp?so():n.exp-Date.now()<=to?fo():uo(n.exp))}function ho(){const n=Hn(o.projectId);n&&(Date.now()>n.exp?qn(o.projectId):(uo(n.exp),_={isMember:!0},Ne(),o.restorePanelSession(n.token).then(t=>{if(co)return;if("unavailable"===t.kind)return;const e=Hn(o.projectId);e&&e.token===n.token&&("ok"===t.kind?(_={isMember:!0},Kn(o.projectId,Object.assign(Object.assign({},e),{fullName:t.session.fullName,level:t.session.level,xp:t.session.xp}))):(lo(),qn(o.projectId),_={isMember:!1},ze()),Ne())}).catch(()=>{})))}return window.addEventListener(Pn,Xe),window.addEventListener($n,no),document.addEventListener("visibilitychange",po),ho(),()=>{Ue(),co=!0,n(()=>{window.removeEventListener(Pn,Xe),window.removeEventListener($n,no),document.removeEventListener("visibilitychange",po),lo(),document.removeEventListener("keydown",_n),Je(),null==a||a.remove()})}}catch(vo){return()=>{}}}const Ut={path:"/config",timeoutMs:4e3,ttlMs:3e5};function Vt(n,t){var e,o;const r=null!=t?t:Object.assign({enabled:!0},Ut);return void 0===n?Object.assign({},r):!0===n?Object.assign(Object.assign({},r),{enabled:!0}):!1===n?Object.assign(Object.assign({},r),{enabled:!1}):{enabled:null===(e=n.enabled)||void 0===e||e,path:null!==(o=n.path)&&void 0!==o?o:r.path,timeoutMs:"number"==typeof n.timeoutMs?n.timeoutMs:r.timeoutMs,ttlMs:"number"==typeof n.ttlMs?n.ttlMs:r.ttlMs}}function Ht(n){return"_cnv_cfg_"+n}function Kt(n){const t=gn(Ht(n));if(!t)return null;try{const n=JSON.parse(t);return n&&"object"==typeof n&&n.envelope?n:null}catch(n){return null}}function qt(n,t,e){try{const o={etag:t,envelope:e,fetchedAt:Date.now()};bn(Ht(n),JSON.stringify(o))}catch(n){}}function Gt(n){const t=Kt(n);return!t||!1!==(null===(o=null==(e=t.envelope)?void 0:e.zaloQrLogin)||void 0===o?void 0:o.enabled);var e,o}const Zt=["gclid","fbclid","ttclid","msclkid","dclid"],Wt=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function Yt(){const n=t(()=>window.location.href,"");let e="",o="",r="";if(n)try{const t=new URL(n);e=t.pathname,o=t.search,r=t.hash}catch(n){}return{url:n,path:e,search:o,hash:r,title:t(()=>document.title,""),referrer:t(()=>document.referrer,"")}}function Jt(n,e=!0){const o=t(()=>window.location.search,"");if(!o)return;let r;try{r=new URLSearchParams(o)}catch(n){return}const i={};let c=!1;for(const[n,t]of Wt){const e=r.get(n);e&&e.length>0&&(i[t]=e,c=!0)}if(e){const n={};for(const t of Zt){const e=r.get(t);e&&e.length>0&&(n[t]=e)}Object.keys(n).length>0&&(i.clickIds=n,c=!0)}return c?i:void 0}function Qt(n){var t,e;let o="@cnv-vn/track",r="0.0.0-dev";try{o="@cnv-vn/track"}catch(n){}try{r="0.3.0-beta.9"}catch(n){}return{name:null!==(t=null==n?void 0:n.name)&&void 0!==t?t:o,version:null!==(e=null==n?void 0:n.version)&&void 0!==e?e:r}}function Xt(n){if(n)try{const t=new URL(n);if("http:"!==t.protocol&&"https:"!==t.protocol)return;return t.origin+t.pathname}catch(n){return}}const ne=256;function te(n,t){if("string"!=typeof n)return;const e=n.trim();return e?e.length>t?e.slice(0,t):e:void 0}function ee(n){return"_cnv_ft_"+n}function oe(n){const e=gn(ee(n));if(!e)return null;const o=t(()=>(n=>{if(!n||"object"!=typeof n)return null;const t=n;if("number"!=typeof t.ts||!Number.isFinite(t.ts))return null;const e={ts:t.ts},o=te(t.source,ne);o&&(e.source=o);const r=te(t.medium,ne);r&&(e.medium=r);const i=te(t.name,ne);i&&(e.name=i);const c=te(t.term,ne);c&&(e.term=c);const l=te(t.content,ne);l&&(e.content=l);const a=te(t.id,ne);a&&(e.id=a);const u=te(t.referrer,1024);u&&(e.referrer=u);const s=te(t.landingPage,1024);if(s&&(e.landingPage=s),t.clickIds&&"object"==typeof t.clickIds){const n={};for(const[e,o]of Object.entries(t.clickIds)){if(Object.keys(n).length>=8)break;const t=te(e,ne),r=te(o,ne);t&&r&&(n[t]=r)}Object.keys(n).length>0&&(e.clickIds=n)}return 1===Object.keys(e).length?null:e})(JSON.parse(e)),null);if(!o)return yn(ee(n)),null;const r=Date.now()-o.ts;return r>63072e6||r<-864e5?(yn(ee(n)),null):o}function re(n,t=!0){const e={first_seen_at:n.ts};return n.source&&(e.utm_source=n.source),n.medium&&(e.utm_medium=n.medium),n.name&&(e.utm_campaign=n.name),n.term&&(e.utm_term=n.term),n.content&&(e.utm_content=n.content),n.id&&(e.utm_id=n.id),n.clickIds&&t&&(e.click_ids=n.clickIds),n.referrer&&(e.referrer=n.referrer),n.landingPage&&(e.landing_page=n.landingPage),e}const ie="_cnv_cid";function ce(n={}){const t=hn(ie),e=gn(ie);let o=null;return Cn(t)?o=t:Cn(e)&&(o=e),o||(o=kn()),le(o,n),o}function le(n,t={}){var e;vn(ie,n,{domain:t.cookieDomain,maxAgeDays:null!==(e=t.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),bn(ie,n)}const ae="1.0";function ue(){return(new Date).toISOString()}function se(n,t){var e;const o=null!==(e=t.timestamp)&&void 0!==e?e:ue(),r=Object.assign(Object.assign({},t.context),{projectId:t.projectId,schemaVersion:ae}),i={type:n,messageId:kn(),anonymousId:t.anonymousId,timestamp:o,originalTimestamp:o,context:r};return t.userId&&(i.userId=t.userId),t.sessionId&&(i.sessionId=t.sessionId),t.integrations&&(i.integrations=t.integrations),i}const de="_cnv_sid";function fe(n){if(!n)return null;const t=n.lastIndexOf(".");if(t<0)return null;const e=n.slice(0,t),o=Number(n.slice(t+1));return!Cn(e)||!Number.isFinite(o)||o<=0?null:{id:e,lastActivity:o}}function pe(n={}){const t=Date.now(),e=(n=>{var t;return 6e4*(null!==(t=n.timeoutMinutes)&&void 0!==t?t:30)})(n),o=fe(hn(de)),r=fe((n=>{if(!_n())return null;try{return sessionStorage.getItem(n)}catch(n){return null}})(de));let i=null;for(const n of[o,r])n&&(t-n.lastActivity>e||(!i||n.lastActivity>i.lastActivity)&&(i=n));const c=i?{id:i.id,lastActivity:t}:{id:kn(),lastActivity:t};return he(c,n),c.id}function he(n,t={}){var e;const o=(n=>`${n.id}.${n.lastActivity}`)(n),r=null!==(e=t.timeoutMinutes)&&void 0!==e?e:30;vn(de,o,{domain:t.cookieDomain,maxAgeDays:r/1440,sameSite:"Lax"}),((n,t)=>{if(!_n())return!1;try{return sessionStorage.setItem(n,t),!0}catch(n){return!1}})(de,o)}class ve{constructor(n){var t,e;Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"storageKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"flushing",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"onlineHandler",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.storageKey=null!==(t=n.storageKey)&&void 0!==t?t:"_cnv_rq",this.maxMessages=null!==(e=n.maxMessages)&&void 0!==e?e:100,this.installOnlineListener()}stash(n){if(n&&0!==n.length)try{const t=this.read();for(t.push(n);t.length>1&&me(t)>this.maxMessages;)t.shift();this.write(t),this.config.debug&&console.log("[cnv-track] retry queued",n.length,"buffered",me(t))}catch(n){}}flush(){if(this.flushing||"undefined"!=typeof navigator&&!1===navigator.onLine)return Promise.resolve();const n=this.read();if(0===n.length)return Promise.resolve();this.flushing=!0,this.write([]);const t=()=>{this.flushing=!1};return n.reduce((n,t)=>n.then(()=>this.config.resend(t)),Promise.resolve()).then(t,t)}size(){return me(this.read())}clear(){try{yn(this.storageKey)}catch(n){}}destroy(){if(this.onlineHandler){try{window.removeEventListener("online",this.onlineHandler)}catch(n){}this.onlineHandler=null}}installOnlineListener(){if("undefined"==typeof window)return;const n=()=>{this.flush()};try{window.addEventListener("online",n),this.onlineHandler=n}catch(n){}}read(){const n=gn(this.storageKey);if(!n)return[];try{const t=JSON.parse(n);return Array.isArray(t)?t.filter(n=>Array.isArray(n)&&n.length>0):[]}catch(n){return[]}}write(n){0!==n.length?bn(this.storageKey,JSON.stringify(n)):yn(this.storageKey)}}function me(n){let t=0;for(const e of n)t+=e.length;return t}class ge{constructor(n){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"buffer",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"timer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"destroyed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"retryQueue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.retryQueue=new ve({debug:n.debug,resend:n=>this.send(n)}),this.installPageLifecycleHandlers(),this.retryQueue.flush()}setConfig(n){this.config=Object.assign(Object.assign({},this.config),n)}enqueue(n){this.destroyed||(this.buffer.push(n),this.buffer.length>=this.config.flushAt?this.flush():this.timer||(this.timer=setTimeout(()=>{this.timer=null,this.flush()},this.config.flushInterval)))}flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),0===this.buffer.length)return Promise.resolve();const n=this.buffer;return this.buffer=[],this.send(n)}bufferedCount(){return this.buffer.length}destroy(){this.destroyed||(this.destroyed=!0,this.timer&&(clearTimeout(this.timer),this.timer=null),this.uninstallPageLifecycleHandlers(),this.retryQueue.destroy())}send(n){try{return this.config.useBatch?this.sendBatch(n):Promise.all(n.map(n=>this.sendSingle(n))).then(()=>{})}catch(n){return this.config.debug&&console.warn("[cnv-track] send failed synchronously; dropped batch",n),Promise.resolve()}}sendBatch(n){var t;const e=ue(),o={batch:n.map(n=>be(n,e)),context:Object.assign(Object.assign({},null!==(t=this.config.batchContext)&&void 0!==t?t:{}),{projectId:this.config.projectId,sentAt:e}),sentAt:e};return this.post(this.batchUrl(),o,n)}sendSingle(n){const t=be(n,ue());return this.post(this.singleUrl(n.type),t,[n])}batchUrl(){return this.config.endpoint+this.config.batchPath+"?projectId="+encodeURIComponent(this.config.projectId)}singleUrl(n){const t=this.config.singlePath.replace("{type}",n);return this.config.endpoint+t+"?projectId="+encodeURIComponent(this.config.projectId)}post(n,t,e){const o=JSON.stringify(t),r=((n,t)=>{try{return new Blob([n],{type:t})}catch(n){return null}})(o,this.config.contentType),i=r?r.size:(n=>{try{return new Blob([n]).size}catch(t){return n.length}})(o),c=i>65536?null:e;return c&&"undefined"!=typeof navigator&&!1===navigator.onLine?(this.retryQueue.stash(c),this.config.debug&&console.log("[cnv-track] offline; queued for retry",n),Promise.resolve()):r&&this.sendViaBeacon(n,r)?(this.config.debug&&console.log("[cnv-track] beacon",n),Promise.resolve()):this.sendViaFetch(n,o,c)}sendViaBeacon(n,t){if("undefined"==typeof navigator||"function"!=typeof navigator.sendBeacon)return!1;if(t.size>65536)return!1;try{return navigator.sendBeacon(n,t)}catch(n){return!1}}sendViaFetch(n,t,e){return"function"!=typeof fetch?(this.config.debug&&console.warn("[cnv-track] no transport available; queued for retry"),e&&this.retryQueue.stash(e),Promise.resolve()):fetch(n,{method:"POST",headers:{"Content-Type":this.config.contentType},body:t,keepalive:!0,credentials:"omit",mode:"cors"}).then(t=>{this.config.debug&&console.log("[cnv-track] fetch flushed",n,t.status)}).catch(t=>{this.config.debug&&console.warn("[cnv-track] flush failed; queued for retry",n,t),e&&this.retryQueue.stash(e)})}installPageLifecycleHandlers(){if("undefined"==typeof window||"undefined"==typeof document)return;const n=()=>{this.flush()},t=()=>{"hidden"===document.visibilityState&&this.flush()};try{window.addEventListener("pagehide",n),document.addEventListener("visibilitychange",t),this.handlers={pagehide:n,visibility:t}}catch(n){}}uninstallPageLifecycleHandlers(){if(this.handlers){try{window.removeEventListener("pagehide",this.handlers.pagehide),document.removeEventListener("visibilitychange",this.handlers.visibility)}catch(n){}this.handlers=null}}}function be(n,t){return Object.assign(Object.assign({},n),{sentAt:t})}const ye="_cnv_uid",_e="_cnv_traits";function we(){return hn(ye)||gn(ye)}const xe={endpoint:"https://tracking.cnvcdp.com/js/v1",batchPath:"/batch",singlePath:"/{type}",useBatch:!0,contentType:"text/plain",debug:!1,allowAdTracking:!0,cookieMaxAgeDays:730,sessionTimeoutMinutes:30,flushAt:20,flushInterval:5e3,autoPageview:!0,autotrack:!1,integrations:{},remoteConfig:Vt(void 0)},ke={analytics:!0,marketing:!0};function Ae(n,t){if(!Array.isArray(t)||0===t.length)return;const e=t;try{switch(e[0]){case"init":n.init(e[1],e[2]);break;case"pageview":n.pageview(e[1],e[2]);break;case"page":n.page(e[1],e[2]);break;case"screen":n.screen(e[1],e[2]);break;case"track":n.track(e[1],e[2]);break;case"identify":n.identify(e[1],e[2]);break;case"alias":n.alias(e[1],e[2]);break;case"group":n.group(e[1],e[2]);break;case"reset":n.reset();break;case"flush":n.flush();break;case"consent":n.consent(e[1]);break;case"set":n.set(e[1])}}catch(n){}}const Ce="0.3.0-beta.9",Me="@cnv-vn/track",Oe=function(){let l=null,a=Object.assign({},xe),u=Object.assign({},ke),s=null,d=!1,f=null;function p(n,t){let o=null,r=null;return{apply(i,c){o&&null!==c&&c===r||(o=e(o),r=c,i&&(o=n(t(),i)))},dispose(){o=e(o),r=null}}}let h=null;const v=()=>h,m=p(x,v),g=p(Y,v),b=p($t,v);function y(n){const t=Object.assign({},a);return n?(void 0!==n.endpoint&&(t.endpoint=(e=n.endpoint).endsWith("/")?e.slice(0,-1):e),void 0!==n.batchPath&&(t.batchPath=n.batchPath),void 0!==n.singlePath&&(t.singlePath=n.singlePath),void 0!==n.useBatch&&(t.useBatch=n.useBatch),void 0!==n.contentType&&(t.contentType=n.contentType),void 0!==n.debug&&(t.debug=n.debug),void 0!==n.allowAdTracking&&(t.allowAdTracking=n.allowAdTracking),void 0!==n.cookieDomain&&(t.cookieDomain=n.cookieDomain),void 0!==n.cookieMaxAgeDays&&(t.cookieMaxAgeDays=n.cookieMaxAgeDays),void 0!==n.sessionTimeoutMinutes&&(t.sessionTimeoutMinutes=n.sessionTimeoutMinutes),void 0!==n.flushAt&&(t.flushAt=n.flushAt),void 0!==n.flushInterval&&(t.flushInterval=n.flushInterval),void 0!==n.autoPageview&&(t.autoPageview=n.autoPageview),void 0!==n.autotrack&&(t.autotrack=n.autotrack),void 0!==n.integrations&&(t.integrations=n.integrations),void 0!==n.remoteConfig&&(t.remoteConfig=Vt(n.remoteConfig,a.remoteConfig)),t):t;var e}function _(){return s||(s=new ge({endpoint:a.endpoint,batchPath:a.batchPath,singlePath:a.singlePath,useBatch:a.useBatch,contentType:a.contentType,flushAt:a.flushAt,flushInterval:a.flushInterval,projectId:null!=l?l:"",debug:a.debug}),s)}function w(){var n;if(!l)return null;const e=((n={})=>{var e;const o={page:Yt(),screen:{width:t(()=>window.screen.width,0),height:t(()=>window.screen.height,0),density:t(()=>window.devicePixelRatio||1,1)},locale:t(()=>navigator.language||"",""),timezone:t(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:t(()=>navigator.userAgent||"",""),library:Qt(n.library)},r=Jt(0,null===(e=n.allowAdTracking)||void 0===e||e);return r&&(o.campaign=r),o})({allowAdTracking:a.allowAdTracking});return u.analytics&&u.marketing||(e.consent=Object.assign({},u)),{anonymousId:ce({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),sessionId:pe({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),userId:null!==(n=we())&&void 0!==n?n:void 0,context:e,projectId:l,integrations:Object.keys(a.integrations).length>0?a.integrations:void 0}}function k(n){a.debug&&console.warn(`[cnv-track] ${n}() called before init()`)}function A(n,t){try{const e=w();if(!e)return k("pageview");(n=>{const t=oe(n.projectId);t&&(n.context.firstTouch=re(t,a.allowAdTracking))})(e);const o=((n,t,e)=>{const o=se("page",e);return n&&(o.name=n),o.properties=null!=t?t:{},o})(n,((n,t)=>{const e={};return n&&(n.url&&(e.url=n.url),n.path&&(e.path=n.path),n.title&&(e.title=n.title),n.referrer&&(e.referrer=n.referrer),n.search&&(e.search=n.search)),Object.assign(Object.assign({},e),null!=t?t:{})})(e.context.page,t),e);_().enqueue(o)}catch(n){}}function C(n,t){A(n,t)}function M(n,t){try{if("string"!=typeof n||0===n.length)return;const e=w();if(!e)return k("track");const o=((n,t,e)=>{const o=se("track",e);return o.event=n,o.properties=null!=t?t:{},o})(n,t,e);_().enqueue(o)}catch(n){}}function O(n,t){try{if("string"!=typeof n||0===n.length)return;((n,t,e={})=>{var o,r;if(n&&(vn(ye,n,{domain:e.cookieDomain,maxAgeDays:null!==(o=e.cookieMaxAgeDays)&&void 0!==o?o:730,sameSite:"Lax"}),bn(ye,n),null!=t)){const n=null!==(r=(()=>{const n=gn(_e);if(!n)return null;try{const t=JSON.parse(n);return t&&"object"==typeof t&&!Array.isArray(t)?t:null}catch(n){return null}})())&&void 0!==r?r:{},e=Object.assign(Object.assign({},n),t);try{bn(_e,JSON.stringify(e))}catch(n){}}})(n,t,{cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays});const e=w();if(!e)return k("identify");const o=((n,t,e)=>{var o;const r=se("identify",e);return n&&(r.userId=n),r.traits=null!==(o=t)&&void 0!==o?o:{},r})(n,t,e);_().enqueue(o)}catch(n){}}function S(n,t){}return{get initialized(){return d},get projectId(){return l},get endpoint(){return a.endpoint},isZaloQrLoginEnabled:()=>!!l&&Gt(l),get consentGranted(){return u.analytics&&u.marketing},init(p,v){var w,k;try{if(!p||"string"!=typeof p)return;a=y(v),(null==v?void 0:v.consent)&&(u=Object.assign(Object.assign({},u),v.consent)),l=p,s&&s.destroy(),s=null,_(),d=!0,ce({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),pe({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),((n,e=!0,o)=>{const r=oe(n);if(r)return r;const i=Jt(0,e),c=(n=>{const e=t(()=>document.referrer,"");if(e){try{const o=new URL(e).host;if(o===t(()=>window.location.host,""))return;const r=n?n.replace(/^\./,"").toLowerCase():"";if(r){const n=o.toLowerCase();if(n===r||n.endsWith("."+r))return}}catch(n){return}return Xt(e)}})(o);if(!i&&!c)return null;const l=Object.assign(Object.assign({},null!=i?i:{}),{referrer:c,landingPage:Xt(t(()=>window.location.href,"")),ts:Date.now()});bn(ee(n),JSON.stringify(l))})(p,a.allowAdTracking,a.cookieDomain),a.autoPageview&&A(),f=e(f);const I={page(n,t){return C(n,t)},track(n,t){return M(n,t)},loginWithZalo(n){return Ln({projectId:l,endpoint:a.endpoint,zaloQrLoginEnabled:!!l&&Gt(l),consentGranted:u.analytics&&u.marketing,identify:O,alias:S,getUserId:we,getAttribution(){const n=l?oe(l):null;return n?re(n,a.allowAdTracking):null},getAnonymousId(){return ce({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays})},getSessionId(){return pe({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes})}},n)},projectId:l,restorePanelSession(n){return l?function(n,t,e){return J(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Mn):null;try{const r=yield fetch(En(n,"/panel/session",t),{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0});if(401===r.status||403===r.status)return{kind:"unauthorized"};if(!r.ok)return{kind:"unavailable"};const i=yield r.json();return i&&"number"==typeof i.contactId?{kind:"ok",session:{contactId:i.contactId,fullName:"string"==typeof i.fullName?i.fullName:void 0,level:"string"==typeof i.level?i.level:void 0,xp:"number"==typeof i.xp?i.xp:void 0}}:{kind:"unavailable"}}catch(n){return{kind:"unavailable"}}finally{r&&clearTimeout(r)}})}(a.endpoint,l,n):Promise.resolve({kind:"unavailable"})},refreshPanelSession(n){return l?function(n,t,e){return J(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Mn):null;try{const r=yield fetch(En(n,"/panel/session/refresh",t),{method:"POST",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0});if(401===r.status||403===r.status)return{kind:"unauthorized"};if(!r.ok)return{kind:"unavailable"};const l=yield r.json();return l&&"string"==typeof l.panelSessionToken&&l.panelSessionToken&&"number"==typeof l.panelSessionExp?{kind:"ok",token:l.panelSessionToken,exp:(i=l.panelSessionExpiresInMs,c=l.panelSessionExp,"number"==typeof i&&i>0?Date.now()+i:c)}:{kind:"unavailable"}}catch(n){return{kind:"unavailable"}}finally{r&&clearTimeout(r)}var i,c})}(a.endpoint,l,n):Promise.resolve({kind:"unavailable"})},fetchRewardsSummary(n,t,e){return l?function(n,t,e){return J(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),On):null,l=Nn(i,r);try{const r=En(n,"/panel/rewards-summary",t),c=o>1?`${r}${r.includes("?")?"&":"?"}page=${o}`:r,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:i?i.signal:void 0});return l.ok?(n=>{if(!n||"object"!=typeof n)return null;const t=n,e=Array.isArray(t.rewards)?t.rewards.filter(n=>!!n&&"object"==typeof n).map(Fn):[];return{points:"number"==typeof t.points&&Number.isFinite(t.points)?t.points:void 0,rewardsAvailableCount:"number"==typeof t.rewardsAvailableCount&&Number.isFinite(t.rewardsAvailableCount)?t.rewardsAvailableCount:void 0,rewards:e,tier:t.tier&&"object"==typeof t.tier?Bn(t.tier):void 0}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,l,n,t,e):Promise.resolve(null)},fetchPanelTiers(){return l?function(n,t){return J(this,void 0,void 0,function*(){const e="undefined"!=typeof AbortController?new AbortController:null,o=e?setTimeout(()=>e.abort(),On):null;try{const o=yield fetch(En(n,"/panel/tiers",t),{method:"GET",credentials:"omit",mode:"cors",signal:e?e.signal:void 0});return o.ok?(n=>{if(!n||"object"!=typeof n)return null;const t=n,e=Array.isArray(t.tiers)?t.tiers.filter(n=>!!n&&"object"==typeof n).map(Rn):[];return{applyFor:"SPENDING"===t.applyFor||"POINTS"===t.applyFor?t.applyFor:void 0,thresholdKind:"RELATIVE"===t.thresholdKind||"ABSOLUTE"===t.thresholdKind?t.thresholdKind:void 0,totalTiers:jn(t.totalTiers),tiers:e}})(yield o.json()):null}catch(n){return null}finally{o&&clearTimeout(o)}})}(a.endpoint,l):Promise.resolve(null)},fetchPointHistory(n,t){return l?function(n,t,e){return J(this,arguments,void 0,function*(n,t,e,o=1){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),On):null;try{const i=En(n,"/panel/point-history",t),c=o>1?`${i}${i.includes("?")?"&":"?"}page=${o}`:i,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:r?r.signal:void 0});return l.ok?(n=>{if(!n||"object"!=typeof n)return null;const t=n,e=Array.isArray(t.items)?t.items.filter(n=>!!n&&"object"==typeof n).map(zn):[];return{totalCount:"number"==typeof t.totalCount&&Number.isFinite(t.totalCount)?t.totalCount:void 0,items:e}})(yield l.json()):null}catch(n){return null}finally{i&&clearTimeout(i)}})}(a.endpoint,l,n,t):Promise.resolve(null)},fetchRedeemableRewards(n,t,e){return l?function(n,t,e){return J(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),On):null,l=Nn(i,r);try{const r=En(n,"/panel/redeemable-rewards",t),c=o>1?`${r}${r.includes("?")?"&":"?"}page=${o}`:r,l=yield fetch(c,{method:"GET",credentials:"omit",mode:"cors",headers:{Authorization:`Bearer ${e}`},signal:i?i.signal:void 0});return l.ok?(n=>{if(!n||"object"!=typeof n)return null;const t=n,e=Array.isArray(t.rewards)?t.rewards.filter(n=>!!n&&"object"==typeof n).map(Tn):[];return{points:jn(t.points),total:jn(t.total),rewards:e}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,l,n,t,e):Promise.resolve(null)},redeemReward(n,t,e){return l?function(n,t,e,o,r){return J(this,void 0,void 0,function*(){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),25e3):null;try{const c=yield fetch(En(n,"/panel/redeem",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`,"Idempotency-Key":r},body:JSON.stringify(null!=o.campaignId?null!=o.redeemPoints&&o.redeemPoints>0?{campaignId:o.campaignId,redeemPoints:o.redeemPoints}:{campaignId:o.campaignId}:{rewardId:o.rewardId}),signal:i?i.signal:void 0}),a=yield c.json().then(n=>n&&"object"==typeof n?n:null).catch(()=>null);if(!c.ok)return{ok:!1,code:a?Dn(a,!0):null};const u=Dn(a,!1);return u?{ok:!1,code:u}:{ok:!0,result:(l=a,l?{code:"string"==typeof l.code?l.code:void 0,pointsSpent:jn(l.pointsSpent),pointsRemaining:jn(l.pointsRemaining),transactionId:"string"==typeof l.transactionId?l.transactionId:void 0}:{})}}catch(n){return{ok:!1,code:"UNCONFIRMED"}}finally{c&&clearTimeout(c)}var l})}(a.endpoint,l,n,t,e):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"})},useReward(n,t){return l?function(n,t,e,o){return J(this,void 0,void 0,function*(){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),25e3):null;try{const i=yield fetch(En(n,"/panel/rewards/use",t),{method:"POST",credentials:"omit",mode:"cors",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({redeemId:o}),signal:r?r.signal:void 0}),c=yield i.json().then(n=>n&&"object"==typeof n?n:null).catch(()=>null);if(!i.ok)return{ok:!1,code:c?Dn(c,!0):null};const l=Dn(c,!1);if(l)return{ok:!1,code:l};const a=c&&"string"==typeof c.code&&c.code?c.code:null;return a?{ok:!0,result:{code:a,usedAt:c&&"string"==typeof c.usedAt?c.usedAt:void 0,expiredAt:c&&"string"==typeof c.expiredAt?c.expiredAt:void 0}}:{ok:!1,code:"CODE_NOT_ISSUED"}}catch(n){return{ok:!1,code:"UNCONFIRMED"}}finally{i&&clearTimeout(i)}})}(a.endpoint,l,n,t):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"})}};if(h=I,a.autotrack){let t=a.autotrack;a.remoteConfig.enabled&&"object"==typeof t&&t.buttonTracking&&(t=Object.assign(Object.assign({},t),{buttonTracking:void 0})),f=function(t,e){const l=void 0===(a=e)||!1===a?Object.assign(Object.assign({},D),{searchParams:z}):!0===a?Object.assign(Object.assign({},T),{searchParams:z}):{spa:null===(u=a.spa)||void 0===u||u,outboundClicks:null===(s=a.outboundClicks)||void 0===s||s,scroll:null===(d=a.scroll)||void 0===d||d,downloads:null===(f=a.downloads)||void 0===f||f,siteSearch:null===(p=a.siteSearch)||void 0===p||p,downloadExtensions:a.downloadExtensions,searchParams:null!==(h=a.searchParams)&&void 0!==h?h:z,buttonTracking:a.buttonTracking};var a,u,s,d,f,p,h;l.outboundClicks=!1,l.downloads=!1,l.scroll=!1,l.siteSearch=!1;const v=[];let m=null;function g(e){if(l.siteSearch)try{const o=null!=e?e:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(n){return""}})();if(o===m)return;m=o;const r=((n,t=z)=>{try{if(!n){if("undefined"==typeof location)return null;n=location.href}const e=n instanceof URL?n:new URL(n,(()=>{try{return"undefined"!=typeof location?location.href:"http://localhost/"}catch(n){return"http://localhost/"}})());if(!e.search)return null;for(const n of t){const t=e.searchParams.get(n);if(null===t)continue;const o=t.trim();if(0!==o.length)return{query:o,param:n}}return null}catch(n){return null}})(o,l.searchParams);r&&n(()=>t.track("Site Searched",{query:r.query,param:r.param}))}catch(n){}}if(l.outboundClicks||l.downloads){const e=(n=>{var t;if("undefined"==typeof document)return()=>{};const e=new Set((null!==(t=n.downloadExtensions)&&void 0!==t?t:o).map(n=>n.toLowerCase())),l=!!n.onOutbound,a=!!n.onDownload;if(!l&&!a)return()=>{};function u(t){var o,u;try{if(0!==t.button)return;if(t.defaultPrevented)return;const s=(n=>{const t="function"==typeof n.composedPath?n.composedPath():[];if(t.length>0)for(const n of t)if(r(n))return n;let e=n.target;for(;e;){if(r(e))return e;e=e.parentNode}return null})(t);if(!s)return;const d=s.getAttribute("href");if(!d)return;if(/^(javascript:|mailto:|tel:|sms:)/i.test(d))return;if(d.startsWith("#"))return;const f=(n=>{try{return new URL(n,location.href)}catch(n){return null}})(d);if(!f)return;let p=!1;if(a){const t=s.hasAttribute("download"),r=(n=>{const t=i(n),e=t.lastIndexOf(".");return e<=0||e===t.length-1?null:t.slice(e+1).toLowerCase()})(f.pathname);(t||r&&e.has(r))&&(p=!0,null===(o=n.onDownload)||void 0===o||o.call(n,{url:f.href,fileName:i(f.pathname),fileExtension:null!=r?r:"",text:c(s)}))}l&&!p&&f.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(n){return""}})()&&f.host&&(null===(u=n.onOutbound)||void 0===u||u.call(n,{url:f.href,host:f.host,text:c(s),target:s.target||"_self"}))}catch(n){}}try{document.addEventListener("click",u,!0)}catch(n){return()=>{}}return()=>{try{document.removeEventListener("click",u,!0)}catch(n){}}})({downloadExtensions:l.downloadExtensions,onOutbound:l.outboundClicks?e=>n(()=>t.track("Clicked",e)):void 0,onDownload:l.downloads?e=>n(()=>t.track("File Downloaded",e)):void 0});v.push(e)}l.buttonTracking&&l.buttonTracking.rules&&l.buttonTracking.rules.length>0&&v.push(x(t,l.buttonTracking));let b=null;if(l.scroll&&(b=(n=>{if("undefined"==typeof window||"undefined"==typeof document)return{destroy(){},reset(){}};let t=!1,e=null,o=!1;function r(){if(e=null,!o&&!t)try{const e=document.documentElement,o=document.body,r=Math.max(e?e.scrollHeight:0,o?o.scrollHeight:0),i=Math.max(e?e.clientHeight:0,window.innerHeight||0);if(r<=i)return t=!0,c(),void n(90);((window.scrollY||(e?e.scrollTop:0)||0)+i)/r>=.9&&(t=!0,c(),n(90))}catch(n){}}function i(){if(null===e)try{e=window.requestAnimationFrame(r)}catch(n){r()}}function c(){try{window.removeEventListener("scroll",i),null!==e&&window.cancelAnimationFrame(e),e=null}catch(n){}}try{window.addEventListener("scroll",i,{passive:!0})}catch(n){try{window.addEventListener("scroll",i)}catch(n){}}try{window.requestAnimationFrame(r)}catch(n){r()}return{destroy(){o=!0,c()},reset(){if(!o){t=!1;try{window.addEventListener("scroll",i,{passive:!0})}catch(n){try{window.addEventListener("scroll",i)}catch(n){}}try{window.requestAnimationFrame(r)}catch(n){r()}}}}})(e=>{n(()=>t.track("Scrolled",{percent:e}))}),v.push(()=>null==b?void 0:b.destroy())),l.spa){const e=[],o=E(o=>{const r=setTimeout(()=>{const o=e.indexOf(r);-1!==o&&e.splice(o,1),n(()=>t.page())},0);e.push(r),null==b||b.reset(),g(o)});v.push(()=>{for(let n=0;n<e.length;n++)clearTimeout(e[n]);e.length=0,o()})}return g(),()=>{for(;v.length>0;){const n=v.pop();try{null==n||n()}catch(n){}}m=null}}(I,t)}if(m.dispose(),g.dispose(),b.dispose(),a.remoteConfig.enabled&&l){const n=n=>{var t,e,o,r;m.apply((n=>{const t=null==n?void 0:n.buttonTracking;if(!t||!1===t.enabled)return null;const e=Array.isArray(t.rules)?t.rules:[];return 0===e.length?null:{rules:e,globalThrottle:t.globalThrottle}})(n),null),g.apply((n=>{var t;const e=null===(t=null==n?void 0:n.launcher)||void 0===t?void 0:t.config;return e?"NONE"===e.deviceVisibility?null:e:null})(n),null!==(e=null===(t=null==n?void 0:n.launcher)||void 0===t?void 0:t.version)&&void 0!==e?e:null),b.apply((n=>{var t;const e=null===(t=null==n?void 0:n.panel)||void 0===t?void 0:t.config;return null!=e?e:null})(n),null!==(r=null===(o=null==n?void 0:n.panel)||void 0===o?void 0:o.version)&&void 0!==r?r:null)};n(null!==(k=null===(w=Kt(l))||void 0===w?void 0:w.envelope)&&void 0!==k?k:null),function(n){return J(this,void 0,void 0,function*(){if(!n.projectId)return{status:"error"};const t=Kt(n.projectId);if(t&&Date.now()-t.fetchedAt<n.ttlMs)return{status:"unchanged"};const e=yield function(n){return J(this,void 0,void 0,function*(){var t;if("function"!=typeof fetch)return null;const e=n.endpoint+n.path+"?projectId="+encodeURIComponent(n.projectId),o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),n.timeoutMs):null;try{const r={};n.etag&&(r["If-None-Match"]=n.etag);const i=yield fetch(e,{method:"GET",headers:r,credentials:"omit",mode:"cors",cache:"no-store",signal:o?o.signal:void 0});if(304===i.status)return{envelope:null,etag:null!==(t=n.etag)&&void 0!==t?t:"",notModified:!0};if(!i.ok)return null;const c=i.headers&&"function"==typeof i.headers.get?i.headers.get("ETag"):null;return{envelope:yield i.json(),etag:null!=c?c:"",notModified:!1}}catch(n){return null}finally{r&&clearTimeout(r)}})}({endpoint:n.endpoint,path:n.path,projectId:n.projectId,timeoutMs:n.timeoutMs,etag:null==t?void 0:t.etag});return e?e.notModified?(t&&qt(n.projectId,t.etag,t.envelope),{status:"unchanged"}):e.envelope?(qt(n.projectId,e.etag,e.envelope),{status:"updated",envelope:e.envelope}):{status:"error"}:{status:"error"}})}({endpoint:a.endpoint,path:a.remoteConfig.path,projectId:l,timeoutMs:a.remoteConfig.timeoutMs,ttlMs:a.remoteConfig.ttlMs}).then(t=>{"updated"===t.status&&n(t.envelope)}).catch(()=>{})}}catch(n){}},pageview:A,page:C,screen(n,t){},track:M,identify:O,alias:S,group(n,t){},reset(){try{((n={})=>{((n,t={})=>{var e;if(!pn)return!1;try{let o=`${encodeURIComponent(n)}=`;return o+=`; path=${null!==(e=t.path)&&void 0!==e?e:"/"}`,t.domain&&(o+=`; domain=${t.domain}`),o+="; max-age=0",o+="; expires=Thu, 01 Jan 1970 00:00:00 GMT",document.cookie=o,null===hn(n)}catch(n){return!1}})(ye,{domain:n.cookieDomain}),yn(ye),yn(_e)})({cookieDomain:a.cookieDomain}),((n={})=>{le(kn(),n)})({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),((n={})=>{he({id:kn(),lastActivity:Date.now()},n)})({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),l&&(n=>{yn(ee(n))})(l)}catch(n){}},flush(){try{s&&s.flush()}catch(n){}},consent(n){try{u=Object.assign(Object.assign({},u),n)}catch(n){}},set(n){try{a=y(n),n.consent&&(u=Object.assign(Object.assign({},u),n.consent)),s&&s.setConfig({endpoint:a.endpoint,batchPath:a.batchPath,singlePath:a.singlePath,useBatch:a.useBatch,contentType:a.contentType,flushAt:a.flushAt,flushInterval:a.flushInterval,debug:a.debug})}catch(n){}},destroy(){f=e(f),m.dispose(),g.dispose(),b.dispose(),h=null,s&&s.destroy(),s=null,d=!1,l=null,a=Object.assign({},xe),u=Object.assign({},ke)}}}();function Se(n){return Ln({projectId:Oe.projectId,endpoint:Oe.endpoint,zaloQrLoginEnabled:Oe.isZaloQrLoginEnabled(),consentGranted:Oe.consentGranted,identify:Oe.identify,alias:Oe.alias,getUserId:we},n)}"undefined"!=typeof window&&(n=>{if("undefined"==typeof window)return()=>{};const t=window.cnvQ;if(t&&t.__loaded)return()=>{};const e=window.cnvQ=null!=t?t:[],o=e.splice(0,e.length);e.push.bind(e),e.push=(...t)=>{for(const e of t)Ae(n,e);return e.length},e.__loaded=!0;for(const t of o)Ae(n,t)})(Oe);const Ie=Object.assign(Oe,{version:Ce,name:Me,schemaVersion:ae,loginWithZalo:Se});export{Me as NAME,ae as SCHEMA_VERSION,Ce as VERSION,In as ZaloQrLoginError,Ie as default,Se as loginWithZalo};
|