@cnv-vn/track 0.3.0-beta.11 → 0.3.0-beta.12
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.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @cnv-vn/track v0.3.0-beta.
|
|
2
|
+
* @cnv-vn/track v0.3.0-beta.12
|
|
3
3
|
* (c) 2026 CNV
|
|
4
4
|
* Released under the UNLICENSED license.
|
|
5
5
|
*/
|
|
6
|
-
var n,t;n=this,t=function(n){function t(n){try{n()}catch(n){}}function e(n,t){try{return n()}catch(n){return t}}function o(n){return n&&t(n),null}const r=["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 i(n){return!!n&&"object"==typeof n&&1===n.nodeType&&"A"===n.tagName}function c(n){const t=n.lastIndexOf("/");return-1===t?n:n.slice(t+1)}function l(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 a=200;function u(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>a?t.slice(0,a):t}function s(n){const t=!1!==n.caseInsensitive;if("regex"===n.mode)return{mode:"regex",needle:n.value,ci:t,re:w(n.value,t)};const e=n.value.normalize("NFC");return{mode:n.mode,needle:t?e.toLowerCase():e,ci:t,re:null}}function d(n,t){try{return n.matches(t)}catch(n){return!1}}function f(n){try{if("A"===n.tagName){const t=n.getAttribute("href");return t?_(t):null}const t=n.getAttribute("formaction");if(t)return _(t);const e=n.getAttribute("data-href");if(e)return _(e);const o=n.closest("form");if(o){const n=o.getAttribute("action");if(n)return _(n)}return null}catch(n){return null}}function p(n){return"regex"===n.mode?{mode:"regex",needle:n.value,re:w(n.value,!0)}:{mode:n.mode,needle:n.value.toLowerCase(),re:null}}function h(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:w(t,!1)}}function v(n,t){return"startsWith"===n.mode?0===t.indexOf(n.needle):!n.re||x(n.re,t)}const m=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,g=/\+?\d[\d\s().-]{7,}\d/g;function b(n){if(!n)return n;try{return n.replace(m,"[email]").replace(g,"[phone]")}catch(t){return n}}function y(n){return!!n&&"object"==typeof n&&1===n.nodeType}function _(n){try{return new URL(n,location.href).href}catch(t){return n}}function w(n,t){try{return!n||n.length>1e3?null:new RegExp(n,t?"i":"")}catch(n){return null}}function x(n,t){try{return n.test(t)}catch(n){return!1}}function k(n,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:A(r),selector:i.selector||null,text:i.text?s(i.text):null,dest:i.destinationUrl?p(i.destinationUrl):null,urlScope:r.urlScope?h(r.urlScope):null,dedupeWindowMs:S(c.dedupeWindowMs,S(t.dedupeWindowMs,500)),maxPerPageview:S(c.maxPerPageview,S(t.maxPerPageview,1/0)),samplingRate:I(S(c.samplingRate,S(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 u=M();function d(e){try{if(0!==e.button)return;const r=M();r!==u&&(u=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)y(n)&&t.push(n);return t}let o=n.target;for(;o;)y(o)&&t.push(o),o=o.parentNode}catch(n){}return t})(e);if(0===i.length)return;const s=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(n){return""}})();for(let r=0;r<o.length;r++){const u=o[r];if(u.urlScope&&!v(u.urlScope,s))continue;let d=null;for(let n=0;n<i.length;n++)if(C(u,i[n])){d=i[n];break}if(!d)continue;const f=u.rule.id;if((a.get(f)||0)>=u.maxPerPageview)return;const p=f+"#"+c(d),h=Date.now(),m=l.get(p);if(void 0!==m&&h-m<u.dedupeWindowMs)return;if(u.samplingRate<1&&Math.random()>=u.samplingRate)return;l.set(p,h),a.set(f,(a.get(f)||0)+1);const g=O(u.rule,d,e);return void t(()=>n.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 A(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 C(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:d(n,t)})(t,n.elementSpec))return!1;const e=n.rule.match;return!(n.selector&&!d(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=u(n);if("regex"===t.mode)return!!t.re&&x(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=f(n);if(!e)return!1;if("regex"===t.mode)return!!t.re&&x(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 O(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=b(u(t));n&&(o.text=n)}if(i.href){const n=f(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]=b(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=b(o.replace(/\s+/g," ").trim());return r.length>a?r.slice(0,a):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 S(n,t){return"number"!=typeof n||isNaN(n)?t:n}function I(n){return n<0?0:n>1?1:n}const E="__cnvPatched";function N(n){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let t=T();function e(){try{const e=T();if(e===t)return;t=e,n(e)}catch(n){}}const o=history.pushState,r=history.replaceState,i=!0===o[E],c=!0===r[E];if(!i){function u(...n){o.apply(this,n),e()}u[E]=!0,history.pushState=u}if(!c){function s(...n){r.apply(this,n),e()}s[E]=!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[E]&&(history.pushState=o),!c&&history.replaceState[E]&&(history.replaceState=r)}catch(n){}}}function T(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}const z=["q","s","query","search","keyword"],j={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},D={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};const R=2147483e3,B="#6C5CE7",F="#FFFFFF";function L(){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 P(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 U(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 V(n,t=20){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(n,0),2e3):t}function H(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 K(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:V(null==e?void 0:e.sideSpacing),bottomSpacingPx:V(null==e?void 0:e.bottomSpacing)}}function q(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 G(n){var t;(null!==(t=document.body)&&void 0!==t?t:document.documentElement).appendChild(n)}function Z(n,e){if("function"!=typeof MutationObserver)return()=>{};let o=0,r=!1;function i(){l.disconnect(),l.observe(document,{childList:!0}),document.documentElement&&l.observe(document.documentElement,{childList:!0}),document.body&&l.observe(document.body,{childList:!0})}function c(){r=!0,l.disconnect()}const l=new MutationObserver(()=>{r||(i(),!n.isConnected&&document.body&&(++o>5?c():(G(n),i(),e&&t(e))))});return i(),c}const W="cnv:panel:opened",Y="cnv:panel:closed";function J(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&&U(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 Q(n,o){if("undefined"==typeof document||"undefined"==typeof window)return()=>{};try{const{hostEl:n,shadow:r}=q("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=P(e.backgroundColor,B),n.style.color=P(e.textColor,F),n.style.borderRadius=(n=>{switch(n){case"SQUARE":return"2px";case"SHAVED":return"8px";case"ROUNDED":return"16px";default:return"999px"}})(e.buttonShape),J(t,e,!1)})(i,c,o);let a=!1;const u=()=>((n,t,o,r,i)=>{try{const c=L();if(((n,t)=>{if("DESKTOP_ONLY"===n.deviceVisibility&&t)return!0;if(n.hideOnHomepage&&e(()=>"/"===location.pathname||""===location.pathname,!1))return!0;const o=n.hideUrlConditions;if(o&&o.length>0){const n=e(()=>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}=K(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:R));const p=c?r.contentLayoutMobile:r.contentLayoutDesktop,h=!i&&"ICON_ONLY"!==p;t.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){}})(n,c,l,o,a),s=n=>{a!==n&&(a=n,t(()=>{J(c,o,n),i.setAttribute("aria-label",n?"Đóng":"Launcher"),u()}))},d=()=>s(!0),f=()=>s(!1);window.addEventListener(W,d),window.addEventListener(Y,f);const p=()=>{t(()=>window.dispatchEvent(new CustomEvent("cnv:launcher:click",{detail:{config:o}})))};i.addEventListener("click",p);let h=null;const v=()=>{t(()=>{G(n),h=Z(n,u),u()})};document.body?v():document.addEventListener("DOMContentLoaded",v,{once:!0});const m=e(()=>window.matchMedia("(max-width: 768px)"),null),g=()=>u(),b=m;m&&"function"==typeof m.addEventListener?m.addEventListener("change",g):m&&"function"==typeof b.addListener?b.addListener(g):window.addEventListener("resize",g);const y=N(u);return()=>{t(()=>{document.removeEventListener("DOMContentLoaded",v),i.removeEventListener("click",p),window.removeEventListener(W,d),window.removeEventListener(Y,f),m&&"function"==typeof m.removeEventListener?m.removeEventListener("change",g):m&&"function"==typeof b.removeListener?b.removeListener(g):window.removeEventListener("resize",g),h&&h(),n.remove()}),t(y)}}catch(n){return()=>{}}}function X(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 nn=(n,t)=>{let e=n;const o=tn[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=en.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=en.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=en.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=en.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=cn.getRSBlocks(n,t),r=ln();for(let t=0;t<e.length;t+=1){const o=e[t];r.put(o.getMode(),4),r.put(o.getLength(),en.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=en.getErrorCorrectPolynomial(u),d=rn(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=an(n);break;case"Alphanumeric":e=un(n);break;case"Byte":e=sn(n);break;case"Kanji":e=dn(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=cn.getRSBlocks(n,o),e=ln();for(let t=0;t<l.length;t++){const o=l[t];e.put(o.getMode(),4),e.put(o.getLength(),en.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=en.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 hn(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};nn.stringToBytes=n=>{const t=[];for(let e=0;e<n.length;e+=1){const o=n.charCodeAt(e);t.push(255&o)}return t},nn.createStringToBytes=(n,t)=>{const e=(()=>{const e=pn(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 tn={L:1,M:0,Q:3,H:2},en=(()=>{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=rn([1],0);for(let e=0;e<n;e+=1)t=t.multiply(rn([1,on.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})(),on=(()=>{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]}}})(),rn=(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){return e[n]},getLength(){return 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]^=on.gexp(on.glog(o.getAt(e))+on.glog(n.getAt(r)));return rn(t,0)},mod(n){if(o.getLength()-n.getLength()<0)return o;const t=on.glog(o.getAt(0))-on.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]^=on.gexp(on.glog(n.getAt(o))+t);return rn(e,0).mod(n)}};return o},cn=(()=>{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 tn.L:return n[4*(t-1)+0];case tn.M:return n[4*(t-1)+1];case tn.Q:return n[4*(t-1)+2];case tn.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}}})(),ln=()=>{const n=[];let t=0;const e={getBuffer(){return 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(){return 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},an=n=>{const t=n,e={getMode(){return 1},getLength(n){return 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},un=n=>{const t=n,e={getMode(){return 2},getLength(n){return 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},sn=n=>{const t=nn.stringToBytes(n);return{getMode(){return 4},getLength(n){return t.length},write(n){for(let e=0;e<t.length;e+=1)n.put(t[e],8)}}},dn=n=>{const t=nn.stringToBytes;(()=>{const n=t("友");if(2!=n.length||38726!=(n[0]<<8|n[1]))throw"sjis not supported."})();const e=t(n),o={getMode(){return 8},getLength(n){return~~(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},fn=()=>{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(){return 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},pn=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},hn=(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=fn(),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:()=>t,indexOf:t=>n[t],contains:t=>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=fn();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},vn="undefined"!=typeof window&&"undefined"!=typeof document;function mn(n){if(!vn)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 gn(n,t,e={}){var o,r,i;if(!vn)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,mn(n)===t}catch(n){return!1}}function bn(){if(!vn)return!1;try{const n="__cnv_probe__";return localStorage.setItem(n,"1"),localStorage.removeItem(n),!0}catch(n){return!1}}function yn(n){if(!bn())return null;try{return localStorage.getItem(n)}catch(n){return null}}function _n(n,t){if(!bn())return!1;try{return localStorage.setItem(n,t),!0}catch(n){return!1}}function wn(n){if(!bn())return!1;try{return localStorage.removeItem(n),!0}catch(n){return!1}}function xn(){if(!vn)return!1;try{const n="__cnv_probe__";return sessionStorage.setItem(n,"1"),sessionStorage.removeItem(n),!0}catch(n){return!1}}const kn="0123456789abcdef";function An(n){return kn[n>>>4&15]+kn[15&n]}function Cn(){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,An(n[0])+An(n[1])+An(n[2])+An(n[3])+"-"+An(n[4])+An(n[5])+"-"+An(n[6])+An(n[7])+"-"+An(n[8])+An(n[9])+"-"+An(n[10])+An(n[11])+An(n[12])+An(n[13])+An(n[14])+An(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 On=/^[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 Mn(n){return"string"==typeof n&&On.test(n)}const Sn=8e3,In=3e4,En=/^(https:|zalo:)/i;class Nn 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 Tn(n,t,e,o){return`${n}${t}?${new URLSearchParams(Object.assign({projectId:e},o)).toString()}`}function zn(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 jn(n){return{title:"string"==typeof n.title?n.title:void 0,description:"string"==typeof n.description?n.description:void 0,points:Bn(n.points),expPoints:Bn(n.expPoints),balanceAfter:Bn(n.balanceAfter),expBalanceAfter:Bn(n.expBalanceAfter),rankAfter:"string"==typeof n.rankAfter?n.rankAfter:void 0,createdAt:"string"==typeof n.createdAt?n.createdAt:void 0}}function Dn(n){return{campaignId:Bn(n.campaignId),rewardId:Bn(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:Bn(n.redeemPoints),redeemRemain:Bn(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 Rn(n,t){return n?"string"==typeof n.error&&n.error?n.error:t&&"string"==typeof n.code&&n.code?n.code:null:null}function Bn(n){return"number"==typeof n&&Number.isFinite(n)?n:void 0}function Fn(n){return{id:Bn(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:Bn(n.threshold),level:Bn(n.level),benefits:Array.isArray(n.benefits)?n.benefits.filter(n=>"string"==typeof n&&""!==n.trim()):[]}}function Ln(n){return{id:Bn(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:Bn(n.level),progressCurrent:Bn(n.progressCurrent),progressTarget:Bn(n.progressTarget),remaining:Bn(n.remaining),nextLevelName:"string"==typeof n.nextLevelName?n.nextLevelName:void 0,isHighestLevel:!0===n.isHighestLevel}}function Pn(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 Un(n,t){return X(this,void 0,void 0,function*(){var e,o,r;if(!n.projectId||!n.endpoint)throw new Nn("not-initialized");if(!n.zaloQrLoginEnabled)throw new Nn("disabled");if(!n.consentGranted)throw new Nn("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 X(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Sn):null;let i;try{i=yield fetch(Tn(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 Nn("network")}finally{r&&clearTimeout(r)}if(!i.ok)throw new Nn(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||!En.test(t.miniAppDeepLink)||"number"!=typeof t.expiresInSeconds||!Number.isFinite(t.expiresInSeconds)||t.expiresInSeconds<=0)throw new Nn("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 Nn("denied"))):"expired"===n.status&&v(()=>h(new Nn("expired")))},g=()=>{null!==a||c||(a=setInterval(()=>{fetch(Tn(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(Tn(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 Nn("expired")))},1e3*o)}),cancel(){c||(c=!0,f(),null==d||d(new Nn("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:()=>(s.cancel(),Un(n,t))}})}const $n="cnv:launcher:click",Vn="cnv:panel:identify",Hn="cnv-panel-card--leaving";function Kn(n){return"cnv_panel_session_"+(null!=n?n:"default")}function qn(n){const t=yn(Kn(n));return t?e(()=>{const n=JSON.parse(t);return n&&"string"==typeof n.token&&n.token&&"number"==typeof n.contactId&&"number"==typeof n.exp?n:null},null):null}function Gn(n,t){_n(Kn(n),JSON.stringify(t))}function Zn(n){wn(Kn(n))}function Wn(n){return"SQUARE"===n?"0px":"12px"}function Yn(n){const t=n.colors;return P(null==t?void 0:t.iconColor,P(null==t?void 0:t.buttonBg,P(null==t?void 0:t.bannerBg,B)))}function Jn(n,t){n.style.background=H(t,.12),n.style.color=t}const Qn='<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"/>',Xn='<path d="M9 6l6 6-6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',nt='<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"/>',tt='<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"/>',et='<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"/>',ot='<path d="M5 13l4.5 4.5L19 8" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/>',rt='<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"/>',it="#1E9E5B",ct="rgba(30, 158, 91, 0.12)",lt="#D64545",at="rgba(214, 69, 69, 0.10)",ut="#6B7280",st="rgba(107, 114, 128, 0.12)";function dt(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 ft(n,t){const e=document.createElement("div");return e.className="cnv-panel-chip",Jn(e,t),e.appendChild(dt(n,14)),e}function pt(n,t){const e=document.createElement("span");return e.className="cnv-panel-badge",Jn(e,t),e.textContent=n,e}const ht={POINTS:{label:"Điểm thưởng",icon:nt},REFERRAL:{label:"Giới thiệu bạn bè",icon:tt},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"/>'}},vt={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:rt,redeem:Qn,history:et},mt={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:nt,GIFT:Qn,USERS:tt,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:rt,CHECK:ot},gt={earn:{label:"Cách kiếm thêm điểm",icon:rt},redeem:{label:"Cách đổi điểm",icon:Qn}},bt="cnv-panel-reward__title--full",yt="Tham gia ngay",_t=[[gt.earn.label,"earn"],[gt.redeem.label,"redeem"]],wt=/\{\{\s*TenKhachHang\s*\}\}/gi,xt=/[\u0000-\u001F\u007F\u200B\u200E\u200F\u2028\u2029\u202A-\u202E\u2066-\u2069\uFEFF]/g;function kt(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 At(n,t){const o=(n=>{if("string"!=typeof n)return"bạn";const t=e(()=>n.normalize("NFC"),n).replace(xt," ").replace(/\s+/g," ").trim();if(!t)return"bạn";const o=Array.from(t);return o.length<=24?t:o.slice(0,24).join("").trimEnd()+"…"})(t);return(n||"").replace(wt,()=>o)}const Ct=[{key:"owned",label:"Ưu đãi của bạn"},{key:"redeem",label:"Đổi ưu đãi"}],Ot={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"},Mt={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"},St={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:Ot,MISSING_SERIAL:Ot,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"}},It={CODE_NOT_ISSUED:Mt,MISSING_VOUCHER:Mt,MISSING_SERIAL:Mt,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"}},Et={message:"Không đổi được ưu đãi lúc này. Bạn thử lại sau nhé.",action:"retry"},Nt={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"}},Tt={message:"Chưa lấy được mã lúc này. Bạn thử lại sau nhé.",action:"retry"},zt={other:"Chọn ưu đãi khác",retry:"Thử lại",owned:"Kiểm tra ưu đãi của bạn",none:""};function jt(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=Wn(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 Dt(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 Rt(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 Bt(n){const t=document.createElement("div");t.className="cnv-panel-vstack";const e=document.createElement("div");e.className="cnv-panel-zalo__qr",e.appendChild(Dt(180,180)),Rt(e,n),t.appendChild(e);const o=document.createElement("div");return o.className="cnv-panel-vstack",o.style.gap="6px",o.append(Dt(240,14),Dt(160,14)),t.appendChild(o),t.appendChild(Dt(120,14)),t}function Ft(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(dt(n,20));const c=document.createElement("div");return c.className="cnv-panel-zalo__title",c.textContent=o,r.append(i,c),r}function Lt(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 Pt(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 Ut(n){return n instanceof Nn?n.reason:null}function $t(n){switch(Ut(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 Vt(n,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=null,_=!1,w=null,x=null,k=!1,A=!1,C=!1,O=[],M=0,S=!1,I=null,E=null,N=null,T=!1,z=0,j=[],D=0,V=null,W=!1,Y=!1,J=Ct[0].key,Q=[],tn=0,en=0,on=!1,rn=null,cn=null,ln=!1,an=0,un=null,sn=null;function dn(n){const e="owned"===n?un:sn;e&&("owned"===n?un=null:sn=null,t(()=>e.abort()))}function fn(){return"undefined"!=typeof AbortController?new AbortController:null}let pn=null,hn=!1,vn=null,mn=0,gn=0,bn=0,yn=null,_n=null,wn=null;const xn=n=>{"Escape"===n.key&&Je()};function kn(n){return!k||n!==gn}function An(n,t){return e(()=>{const e=new CustomEvent(n,{detail:{action:t},cancelable:!0});return window.dispatchEvent(e),e.defaultPrevented},!1)}function On(n){An("cnv:panel:cta-click",n)}function Mn(n){return()=>{_&&n()}}function Sn(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=vt[t];if(i){const n=dt(i,20);n.style.color=Yn(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(dt(Xn,12,"cnv-panel-icon--chevron")),o.addEventListener("click",Mn(()=>{An("cnv:panel:menu-click",t)||("rewards"===t?(A=!0,J=Ct[0].key,pn=null,Re(),le(),Fn()):"history"===t?(C=!0,Re(),fe(),O.length||(M=0,de())):gt[t]&&(I=t,Re(),be()))})),o}function In(){var n,t,e,o;const i=jt(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=Wn(null===(n=r.shapes)||void 0===n?void 0:n.button),u.style.backgroundColor=P(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,B),u.style.color=P(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,F),u.appendChild(dt(Qn,15)),u.appendChild(document.createTextNode(((null==c?void 0:c.createAccountButtonText)||"").trim()||yt)),u.addEventListener("click",Mn(()=>{On("create-account"),Ge()})),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=P(null===(o=r.colors)||void 0===o?void 0:o.linkColor,B),n.appendChild(document.createTextNode(s)),n.appendChild(dt(Xn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",Mn(()=>{On("sign-in"),Ge()})),i.appendChild(n)}return i}function En(){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=Wn(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 Nn(){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=Wn(null===(n=r.shapes)||void 0===n?void 0:n.button),a.style.backgroundColor=P(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,B),a.style.color=P(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,F),a.appendChild(dt(Qn,15)),a.appendChild(document.createTextNode(((null==i?void 0:i.createAccountButtonText)||"").trim()||yt)),a.addEventListener("click",Mn(()=>{On("create-account"),Ge()})),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=P(null===(o=r.colors)||void 0===o?void 0:o.linkColor,B),n.appendChild(document.createTextNode(u)),n.appendChild(dt(Xn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",Mn(()=>{On("sign-in"),Ge()})),l.appendChild(n)}return l}function Tn(){var n;return null!==(n=null==N?void 0:N.points)&&void 0!==n?n:null==w?void 0:w.points}function zn(t=!1){if(!(null==w?void 0:w.isMember)||T)return;if(!t&&N&&Date.now()-z<3e4)return;const e=qn(n.projectId);if(!e)return;T=!0,dn("owned");const o=fn();un=o,_&&ze(),n.fetchRewardsSummary(e.token,1,o?o.signal:void 0).then(n=>{T=!1,o&&o.signal.aborted||(n?(N=n,z=Date.now(),j=n.rewards.slice(),D=1,_&&ze()):_&&ze())}).catch(()=>{T=!1,_&&ze()})}function jn(){return(Array.isArray(r.sections)?r.sections:[]).some(n=>"VIP"===n.type&&n.enabled)}function Dn(){const n=null==N?void 0:N.rewardsAvailableCount;return"number"==typeof n&&D?Math.max(0,n-j.length):0}function Rn(){if(Y||!Dn())return;const t=qn(n.projectId);if(!t)return;const e=D+1;Y=!0,A&&le(),n.fetchRewardsSummary(t.token,e).then(n=>{Y=!1,D=e,n&&(n.rewards.length&&(j=j.concat(n.rewards)),"number"==typeof n.rewardsAvailableCount&&N&&(N=Object.assign(Object.assign({},N),{rewardsAvailableCount:n.rewardsAvailableCount}))),A&&le()}).catch(()=>{Y=!1,A&&le()})}function Bn(n){if(J===n)return;const t=J;J=n,pn=null,rn=null,Ot(),dn(t),Re(),le(),Fn(!0)}function Fn(n=!1){if("redeem"===J){if(!n&&Q.length&&Date.now()-en<3e4)return;return tn=0,Q=[],void Ln()}zn(n)}function Ln(){if(on)return;const t=qn(n.projectId);if(!t)return;const e=tn+1;on=!0,dn("redeem");const o=fn();sn=o,A&&le(),n.fetchRedeemableRewards(t.token,e,o?o.signal:void 0).then(n=>{on=!1,tn=e,n&&(1===e&&(en=Date.now()),"number"==typeof n.total&&(c=n.total),"number"==typeof n.points&&(l=n.points),n.rewards.length&&(Q=Q.concat(n.rewards))),A&&le()}).catch(()=>{on=!1,A&&le()})}function Pn(){return null!=l?l:Tn()}function Un(){return null!==qn(n.projectId)}function Kn(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",Mn(Ge)),n.appendChild(r)}function nt(t,e=!1){const o=kt(t);if(hn||null===o)return;const r=qn(n.projectId);if(!r)return;if(An("cnv:panel:redeem-click","redeem-confirm"))return;const i=e&&vn?vn:Cn();vn=i;const c=++mn;hn=!0,pn={kind:"confirm",item:t},le(),n.redeemReward(r.token,o,i).then(n=>{var e;tt(c)&&(hn=!1),n.ok&&(vn=null,e=n.result,Mt(),l="number"==typeof e.pointsRemaining?e.pointsRemaining:void 0,zn()),A&&tt(c)&&(pn=n.ok?{kind:"success",item:t,result:n.result}:{kind:"error",code:n.code,item:t},le())}).catch(()=>{tt(c)&&(hn=!1),A&&tt(c)&&(Mt(),pn={kind:"error",code:"UNCONFIRMED",item:t},le())})}function tt(n){return n===mn}function rt(t){const e=t.redeemId;if(ln||"number"!=typeof e||e<=0)return;const o=qn(n.projectId);if(!o)return;const r=++an;ln=!0,cn={kind:"confirm",item:t},le(),n.useReward(o.token,e).then(n=>{const o=n.ok?wt(e,t,n.result):null;r===an&&(ln=!1),A&&r===an&&(o?(cn=null,rn=o):n.ok||(cn={kind:"error",code:n.code,item:t}),Re(),le())}).catch(()=>{r===an&&(ln=!1),A&&r===an&&(cn={kind:"error",code:"UNCONFIRMED",item:t},le())})}function wt(n,t,e){const o=j.findIndex(t=>t.redeemId===n),r=o>=0?j[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&&(j[o]=i),i}function xt(){pn=null,rn=null,hn=!1,mn++,Ot()}function Ot(){cn=null,ln=!1,an++}function Mt(){N=null,z=0,j=[],D=0,O=[],i=void 0,M=0,Q=[],c=void 0,tn=0,en=0}function Vt(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"),U(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(ne(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=Pt(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",Jn(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=Pt(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",Mn(()=>{if(!n.canUse)return rn=n,Re(),void le();Ht(n)})),t.appendChild(r),o.appendChild(t)}return o}function Ht(n){if(n.burnOnUse)return cn={kind:"confirm",item:n},Re(),void le();rt(n)}function Kt(n,t,e){const o=Ft(ln?et:Qn,ln?ut:t,ln?st:H(t,.12),e.title||"Ưu đãi"),r=document.createElement("div");r.className="cnv-panel-zalo__status",r.textContent=ln?"Đ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=ln,ln||c.addEventListener("click",Mn(()=>{cn=null,Re(),le()}));const l=document.createElement("button");l.type="button",l.className="cnv-panel-zalo__btn",l.textContent=ln?"Đang xử lý…":"Dùng ngay",l.disabled=ln,ln||(l.style.borderColor=t,l.style.color=t,l.addEventListener("click",Mn(()=>rt(e)))),i.append(c,l),n.appendChild(i)}function qt(n,t,e,o){const r=o&&Nt[o]||Tt,i="UNCONFIRMED"===o,c=Ft(i?et:Qn,i?ut:lt,i?st:at,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",Mn(()=>{cn=null,Re(),le()})),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",Mn(()=>rt(e))),a.appendChild(n)}n.appendChild(a)}function Gt(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",Mn(()=>{e.disabled||(e.disabled=!0,function(n){return X(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?it:t,e.style.color=n?it: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 Zt(n,t,e){const o=Ft(Qn,t,H(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=Pt(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=Pt(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",Mn(()=>{rn=null,Ht(e)})),o.appendChild(r),n.appendChild(o)}const c=document.createElement("div");c.className="cnv-panel-redeem__actions",e.canUse||c.appendChild(Gt(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",Mn(()=>{rn=null,Re(),le()})),c.appendChild(l),n.appendChild(c)}function Wt(n){const t=document.createElement("div");return t.className="cnv-panel-rtabs",t.setAttribute("role","tablist"),Ct.forEach(e=>{const o=e.key===J,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",Mn(()=>Bn(e.key))),t.appendChild(r)}),t}function Yt(n){return n.toLocaleString("vi-VN")+" điểm"}function Jt(n){return n>0?Yt(n):"Miễn phí"}function Qt(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 Xt(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,Qt(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 ne(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(dt('<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(bt)}),t.append(e,o),t}function te(n){if(null===kt(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=Pn();return"number"==typeof t&&t<n.redeemPoints?`Cần thêm ${Yt(n.redeemPoints-t)}`:null}function ee(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"),U(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(ne(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",Jn(o,e),o.textContent=n.discountValue,t.appendChild(o),i.appendChild(t)}const c=Pt(n.expiredAt);if(c){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=`HSD ${c}`,i.appendChild(n)}const l=te(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=Jt(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||hn,u.disabled||(u.style.borderColor=e,u.style.color=e,u.addEventListener("click",Mn(()=>{pn={kind:"confirm",item:n},Re(),le()}))),a.appendChild(u),o.appendChild(a),o}function oe(n,t){const e=Pn();if("number"==typeof e&&n.appendChild(Xt(e,t)),!Un())return void Kn(n,t,"Bạn cần đăng nhập để xem ưu đãi có thể đổi.");if(on&&!Q.length)return n.appendChild(Dt(200,12)),void n.appendChild(Dt(150,12));if(!Q.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",Q.forEach((n,e)=>o.appendChild(ee(n,e>0,t))),n.appendChild(o);const r="number"==typeof c&&tn?Math.max(0,c-Q.length):0;if(r>0||on){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more",t.disabled=on,t.textContent=on?"Đang tải…":`Xem thêm ${r} ưu đãi`,t.addEventListener("click",Mn(Ln)),n.appendChild(t)}}function re(n,t,e){const o=Ft(Qn,t,H(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=Jt(e.redeemPoints);n.textContent=r,Qt(n,r,20),o.appendChild(n);const i=Pn();if(e.redeemPoints>0&&"number"==typeof i){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=`Còn lại ${Yt(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=hn,hn||i.addEventListener("click",Mn(()=>{pn=null,le()}));const c=document.createElement("button");c.type="button",c.className="cnv-panel-zalo__btn",c.textContent=hn?"Đang đổi…":"Đổi",c.disabled=hn,hn||(c.style.borderColor=t,c.style.color=t,c.addEventListener("click",Mn(()=>nt(e)))),r.append(i,c),n.appendChild(r)}function ie(n,t,e,o){var r;const i=Ft(ot,it,ct,"Đổ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),o.burnOnUse||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 ${Yt(l)}`),"number"==typeof o.pointsRemaining&&a.push(`còn lại ${Yt(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),!o.burnOnUse&&!e.burnOnUse&&o.code){const e=document.createElement("div");e.className="cnv-panel-redeem__actions",e.appendChild(Gt(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",Mn(()=>Bn("owned")));const d=document.createElement("button");d.type="button",d.className="cnv-panel-zalo__btn",d.textContent="Đổi tiếp",d.addEventListener("click",Mn(()=>{pn=null,Re(),le(),"redeem"!==J||Q.length||(tn=0,Ln())})),u.append(d,s),n.appendChild(u)}function ce(n,t,e,o){var r;const i=((n,t)=>{var e;if(t){if(void 0!==(null===(e=kt(n))||void 0===e?void 0:e.redeemPoints)&&It[t])return It[t];if(St[t])return St[t]}return Et})(e,o),c="neutral"===i.tone,l=Ft(c?et:Qn,c?ut:lt,c?st:at,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=()=>{pn=null,Re(),le()},d=zt[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",Mn(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",Mn(()=>Bn("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",Mn(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",Mn(()=>nt(e,!i.retryWithNewKey))),u.appendChild(n)}}n.appendChild(u)}function le(){var n,t;if(!v)return;Fe(),Le(),Be(!0);const e=null!==(t=null===(n=v.querySelector(".cnv-panel-rlist"))||void 0===n?void 0:n.scrollTop)&&void 0!==t?t:0;v.textContent="";const o=Yn(r),i="redeem"===J?null!==pn:null!==cn||null!==rn,c=jt(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(ft(Qn,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,Wt(o)),c.appendChild(e),l=document.createElement("div"),l.className="cnv-panel-rlist",c.appendChild(l)}"redeem"===J?"confirm"===(null==pn?void 0:pn.kind)?re(c,o,pn.item):"success"===(null==pn?void 0:pn.kind)?ie(c,o,pn.item,pn.result):"error"===(null==pn?void 0:pn.kind)?ce(c,o,pn.item,pn.code):oe(l,o):"confirm"===(null==cn?void 0:cn.kind)?Kt(c,o,cn.item):"error"===(null==cn?void 0:cn.kind)?qt(c,o,cn.item,cn.code):rn?Zt(c,o,rn):ae(l,o),v.appendChild(c),e>0&&l!==c&&(l.scrollTop=e),v&&v.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(bt);const o=t.offsetHeight;t.classList.remove(bt),n.classList.toggle("cnv-panel-reward__name--clamped",o>e+1)})}function ae(n,t){if(!Un())return void Kn(n,t,"Bạn cần đăng nhập để xem ưu đãi của bạn.");if(T&&!j.length)return n.appendChild(Dt(200,12)),void n.appendChild(Dt(150,12));if(!j.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",j.forEach((n,o)=>e.appendChild(Vt(n,o>0,t))),n.appendChild(e);const o=Dn();if(o>0||Y){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more",t.disabled=Y,t.textContent=Y?"Đang tải…":`Xem thêm ${o} ưu đãi`,t.addEventListener("click",Rn),n.appendChild(t)}}function ue(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 se(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=mt[n.icon];i.appendChild(ft("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 de(){if(S)return;const t=qn(n.projectId);if(!t)return;const e=M+1;S=!0,C&&fe(),n.fetchPointHistory(t.token,e).then(n=>{S=!1,M=e,n&&("number"==typeof n.totalCount&&(i=n.totalCount),n.items.length&&(O=O.concat(n.items))),C&&fe()}).catch(()=>{S=!1,C&&fe()})}function fe(){if(!v)return;Fe(),Le(),Be(!0),v.textContent="";const n=Yn(r),t=jt(r);if(t.appendChild(ye({label:"Lịch sử hoạt động",icon:et},n)),!O.length&&S)t.appendChild(Dt(180,12)),t.appendChild(Dt(120,12));else if(O.length){const n=document.createElement("div");n.className="cnv-panel-history__list",O.forEach((t,e)=>n.appendChild(pe(t,e>0))),t.appendChild(n);const e="number"==typeof i&&M?Math.max(0,i-O.length):0;if(e>0||S){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn cnv-panel-reward__more",n.disabled=S,n.textContent=S?"Đang tải…":`Xem thêm ${e} hoạt động`,n.addEventListener("click",Mn(de)),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)}v.appendChild(t)}function pe(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(he(c));const l=[];"number"==typeof n.balanceAfter&&l.push("Điểm tích lũy: "+me(n.balanceAfter));const a=(n.rankAfter||"").trim();"number"==typeof n.expBalanceAfter?l.push("Điểm xét hạng: "+me(n.expBalanceAfter)+(a?" (Hạng "+a+")":"")):a&&l.push("Hạng "+a),l.length&&o.appendChild(he(l.join(" / ")));const u=ge(n.createdAt);u&&o.appendChild(he(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=ve(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=ve(n.expPoints)+" xét hạng",s.appendChild(t)}return s.childElementCount&&e.appendChild(s),e}function he(n){const t=document.createElement("div");return t.className="cnv-panel-history__meta",t.textContent=n,t}function ve(n){const t=Math.round(n);return(t>0?"+":"")+t.toLocaleString("vi-VN")}function me(n){return Math.round(n).toLocaleString("vi-VN")}function ge(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 be(){if(!v||!I)return;const n=gt[I];if(!n)return I=null,void Ne();const t=ue(I);Fe(),Le(),Be(!0),v.textContent="";const e=Yn(r),o=jt(r);if(o.appendChild(ye(n,e)),t.length){const r=document.createElement("div");r.className="cnv-panel-block__list",t.forEach((t,o)=>r.appendChild(se(t,o>0,e,n.icon))),o.appendChild(r)}else{const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent="redeem"===I?"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(v.appendChild(o),!De()){const n=En();n&&v.appendChild(n)}E=De()}function ye(n,t){const e=document.createElement("div");e.className="cnv-panel-section__head",e.appendChild(ft(n.icon,t));const o=document.createElement("div");return o.className="cnv-panel-section__title",o.textContent=n.label,e.appendChild(o),e}function _e(n){if(!(Array.isArray(r.sections)?r.sections:[]).some(n=>"POINTS"===n.type&&n.enabled))return null;const t=jt(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 _t.forEach((n,t)=>o.appendChild(Sn(n[0],n[1],t>0))),t.append(ye(ht.POINTS,n),e,o),t}function we(n){const t=Math.max(0,Math.round(n)).toLocaleString("vi-VN");return"SPENDING"===(null==V?void 0:V.applyFor)?t+"đ":t+" điểm"}function xe(n){const t=document.createElement("span");if(t.className="cnv-panel-tier__badge",U(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=P(n.colorCode,Yn(r)),t}function ke(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(xe(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 Ae(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 Ce(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 Oe(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 "+we(s)+" nữa để lên "+n.nextLevelName:"Còn "+we(s)+" nữa để lên hạng kế tiếp",c.append(l,u),c}function Me(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 Se(n,t){var e,o;const i=null!==(e=null==V?void 0:V.tiers)&&void 0!==e?e:[];if(!i.length)return null;const c=jt(r),l=document.createElement("div"),a=t?null==N?void 0:N.tier:void 0;if(null==a?void 0:a.name){const t=document.createElement("div");t.className="cnv-panel-tier__current",t.appendChild(xe(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=Oe(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}=Me(i,u),f=document.createElement("div");f.className="cnv-panel-tier__list",s>0&&f.appendChild(Ce(s,!1));for(let n=s;n<d;n++){const t=n===u;if(f.appendChild(ke(i[n],t)),t||u<0){const t=Ae(i[n].benefits);t&&f.appendChild(t)}}const p=Math.max(null!==(o=null==V?void 0:V.totalTiers)&&void 0!==o?o:i.length,i.length)-d;return p>0&&f.appendChild(Ce(p,!0)),l.appendChild(f),c.append(ye(ht.VIP,n),l),c}function Ie(n,t){const e=ht[n];if(!e||"string"!=typeof e.label)return null;if("VIP"===n)return Se(t,!0);const o=jt(r),i=ye(e,t),c=document.createElement("div");if("POINTS"!==n)return c.appendChild(pt("Sắp ra mắt",t)),o.append(i,c),o;const l=Tn();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(pt("Đang cập nhật",t));const a=null!==(u=null==N?void 0:N.rewardsAvailableCount)&&void 0!==u?u:null==w?void 0:w.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"],..._t,["Lịch sử hoạt động","history"]].forEach((n,t)=>c.appendChild(Sn(n[0],n[1],t>0))),o.append(i,c),o}function Ee(){if(!p||!h)return;const t=r.colors;s&&(s.style.backgroundColor="DARK"===r.theme?"#181C32":"#FFFFFF",s.style.color="DARK"===r.theme?"#FFFFFF":"#181C32");const e=p.parentElement;if(e&&(e.style.backgroundColor=P(null==t?void 0:t.bannerBg,B),e.style.color=P(null==t?void 0:t.bannerFont,F)),d&&(U(r.bannerImageUrl)?(d.src=r.bannerImageUrl,d.style.display="block"):(d.style.display="none",d.removeAttribute("src"))),f){const n=f.parentElement;U(r.brandIconUrl)?(f.src=r.brandIconUrl,n&&(n.style.display="flex",n.style.background=H(P(null==t?void 0:t.bannerFont,F),.18))):(n&&(n.style.display="none"),f.removeAttribute("src"))}const o=(null==w?void 0:w.isMember)?r.headerMember:r.headerVisitor,i=(null==w?void 0:w.isMember)?null===(c=qn(n.projectId))||void 0===c?void 0:c.fullName:null;var c;p.textContent=At((null==o?void 0:o.caption)||"",i),h.textContent=At((null==o?void 0:o.title)||"",i)}function Ne(){if(!v||k||A||C||I)return;Fe(),Le(),Be(!0),v.textContent="";const n=Yn(r);if(!(null==w?void 0:w.isMember)){let t=0;Te(In(),t++);const e=_e(n);e&&Te(e,t++);const o=jn()?Se(n,!1):null;return void(o&&Te(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=Ie(t.type,n);o&&Te(o,e++)})}function Te(n,t){n.style.animationDelay=40+55*t+"ms",v.appendChild(n)}function ze(){Ee(),I?E!==De()&&be():Ne()}function je(){dn("owned"),dn("redeem"),N=null,z=0,en=0,j=[],D=0,A=!1,Q=[],c=void 0,tn=0,l=void 0,vn=null,xt(),O=[],i=void 0,M=0,C=!1}function De(){return!!(null==w?void 0:w.isMember)}function Re(){if(!v)return;v.scrollTop=0;const n=v.querySelector(".cnv-panel-rlist");n&&(n.scrollTop=0)}function Be(n){s&&(s.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 Fe(){const n=k||A||C||null!==I;g&&(g.style.display=n?"inline-flex":"none"),m&&m.classList.toggle("cnv-panel-banner--sub",n)}function Le(){if(!s)return;const n=!De()&&null!==I;if(n&&!y)return y=Nn(),void s.insertBefore(y,b);!n&&y&&(y.remove(),y=null)}function Pe(){k&&($e(),k=!1),A=!1,xt(),C=!1,I=null,Re(),Ne()}function Ue(){yn=o(yn)}function $e(){_n=o(_n)}function Ve(n,t){Ue();const e=Date.now()+1e3*t.expiresInSeconds;yn=Lt(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 He(){if(k=!1,Ue(),$e(),x){const n=x;x=null,t(()=>n.cancel())}}function Ke(){const n=document.createElement("button");return n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Huỷ",n.addEventListener("click",()=>{He(),ze()}),n}function qe(n){var t;if(!v)return;Fe(),Le(),Be(!1),v.textContent="";const e=Yn(r),o=jt(r,"cnv-panel-zalo");if("loading"===n.phase)o.appendChild(Bt(e)),o.appendChild(Ke());else if("qr"===n.phase){const t=(n=>{try{const t=nn(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),Rt(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(dt(et,12));const l=document.createElement("span");c.appendChild(l),o.appendChild(c),Ve(l,n.session),o.appendChild(Ke())}else{o.style.position="relative",o.appendChild(Bt(e));const l=document.createElement("div");let a;if(l.className="cnv-panel-zalo__overlay",l.style.borderRadius=Wn(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=Ft(ot,it,ct,n.result.fullName?`Xin chào ${n.result.fullName}!`:"Đăng nhập thành công!");else{const t="expired"===n.reason;a=Ft(t?et:'<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?ut:lt,t?st:at,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",Mn(()=>Ge())),bn>=3){const t=Math.min(5+5*(bn-3),20);i=n,c=t,$e(),i.disabled=!0,_n=Lt(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;v.appendChild(o)}function Ge(){if(!v)return;He(),I=null,k=!0,Re();const e=++gn;qe({phase:"loading"}),n.loginWithZalo().then(o=>{kn(e)?t(()=>o.cancel()):(x=o,bn=0,qe({phase:"qr",session:o}),o.result.then(t=>{if(!kn(e)){if(Ue(),x=null,qe({phase:"success",result:t}),null!=t.contactId&&"string"==typeof t.panelSessionToken&&t.panelSessionToken&&"number"==typeof t.panelSessionExp){const e="number"==typeof t.panelSessionExpiresInMs&&t.panelSessionExpiresInMs>0?Date.now()+t.panelSessionExpiresInMs:t.panelSessionExp;Gn(n.projectId,{token:t.panelSessionToken,contactId:t.contactId,fullName:t.fullName,level:t.level,xp:t.xp,exp:e}),fo(e)}w={isMember:!0},zn(),setTimeout(()=>{kn(e)||(k=!1,ze())},1500)}}).catch(n=>{kn(e)||(Ue(),x=null,qe({phase:"error",message:$t(n),canRetry:!0,reason:Ut(n)}))}))}).catch(n=>{kn(e)||(bn+=1,qe({phase:"error",message:$t(n),canRetry:!0,reason:Ut(n)}))})}function Ze(n){var t,e,o;if(a)return;const i=q("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:R,y=null!==(e=$(l+600))&&void 0!==e?e:R;s=document.createElement("div"),s.className="cnv-panel-card",s.style.zIndex=String(y),s.addEventListener("animationend",n=>{"cnv-panel-out"===n.animationName&&Qe()}),s.style.borderRadius=Wn(null===(o=r.shapes)||void 0===o?void 0:o.container);const _=document.createElement("button");_.type="button",_.className="cnv-panel-close",_.setAttribute("aria-label","Đóng"),_.textContent="×",_.addEventListener("click",Je),g=document.createElement("button"),g.type="button",g.className="cnv-panel-back",g.setAttribute("aria-label","Quay lại"),g.appendChild(dt('<path d="M15 6l-6 6 6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',15)),g.addEventListener("click",Mn(Pe));const w=document.createElement("div");m=w,w.className="cnv-panel-banner",d=document.createElement("img"),d.className="cnv-panel-banner__img",d.alt="",f=document.createElement("img"),f.className="cnv-panel-banner__brandicon",f.alt="";const x=document.createElement("div");x.className="cnv-panel-banner__brandchip",x.appendChild(f),p=document.createElement("div"),p.className="cnv-panel-banner__caption",h=document.createElement("div"),h.className="cnv-panel-banner__title",w.append(d,x,p,h),v=document.createElement("div"),v.className="cnv-panel-body",s.append(_,g,w,v),b=We(),b&&s.appendChild(b),c.appendChild(s),G(a),u=Z(a)}function We(){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 Ye(n){if(!s)return;const{side:t,sideSpacingPx:e,bottomSpacingPx:o}=K(n,L());s.style.left="left"===t?e+"px":"auto",s.style.right="right"===t?e+"px":"auto";const r=o+48+24;s.style.bottom=r+"px",s.style.maxHeight=`calc(100vh - ${r+16}px)`,s.style.transformOrigin="left"===t?"left bottom":"right bottom"}function Je(){a&&_&&(_=!1,He(),A=!1,xt(),C=!1,I=null,document.removeEventListener("keydown",xn),no("cnv:panel:closed"),s&&!e(()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,!1)?(s.classList.add(Hn),wn=setTimeout(Qe,320)):Qe())}function Qe(){null!==wn&&(clearTimeout(wn),wn=null),null==s||s.classList.remove(Hn),null==a||a.style.setProperty("display","none")}function Xe(){null!==wn&&(clearTimeout(wn),wn=null),null==s||s.classList.remove(Hn)}function no(n){t(()=>window.dispatchEvent(new CustomEvent(n)))}const to=e=>{t(()=>{var t;const o=e.detail;var r;_?Je():(Ze(r=null!==(t=null==o?void 0:o.config)&&void 0!==t?t:null),a&&(Xe(),Ye(r),a.style.setProperty("display","block"),_=!0,ze(),zn(),!jn()||V||W||(W=!0,n.fetchPanelTiers().then(n=>{W=!1,n&&n.tiers.length&&(V=n,_&&ze())}).catch(()=>{W=!1})),document.addEventListener("keydown",xn),no("cnv:panel:opened")))})},eo=n=>{t(()=>{const t=n.detail;w=(null==t?void 0:t.isMember)?{isMember:!0,points:t.points,rewardsAvailableCount:t.rewardsAvailableCount}:{isMember:!1},w.isMember||je(),_&&ze(),_&&zn()})},oo=3e5,ro=15e3,io=6e4;let co=null,lo=!1,ao=!1;function uo(){null!==co&&(clearTimeout(co),co=null)}function so(n){uo(),ao||(co=e(()=>setTimeout(ho,Math.max(0,n)),null))}function fo(n){so(Math.max(ro,n-Date.now()-oo))}function po(){uo(),Zn(n.projectId),w={isMember:!1},je(),ze()}function ho(){if(uo(),ao||lo)return;const t=qn(n.projectId);t&&(Date.now()>t.exp?po():(lo=!0,n.refreshPanelSession(t.token).then(e=>{if(lo=!1,ao)return;const o=qn(n.projectId);if(!o)return;if(o.token!==t.token)return void fo(o.exp);if("ok"===e.kind)return Gn(n.projectId,Object.assign(Object.assign({},o),{token:e.token,exp:e.exp})),void fo(e.exp);if("unauthorized"===e.kind)return void po();const r=o.exp-Date.now();r<=0?po():so(Math.min(io,r))}).catch(()=>{if(lo=!1,ao)return;const n=t.exp-Date.now();n>0&&so(Math.min(io,n))})))}function vo(){if("visible"!==document.visibilityState)return;const t=qn(n.projectId);t&&(Date.now()>t.exp?po():t.exp-Date.now()<=oo?ho():fo(t.exp))}function mo(){const t=qn(n.projectId);t&&(Date.now()>t.exp?Zn(n.projectId):(fo(t.exp),w={isMember:!0},ze(),n.restorePanelSession(t.token).then(e=>{if(ao)return;if("unavailable"===e.kind)return;const o=qn(n.projectId);o&&o.token===t.token&&("ok"===e.kind?(w={isMember:!0},Gn(n.projectId,Object.assign(Object.assign({},o),{fullName:e.session.fullName,level:e.session.level,xp:e.session.xp}))):(uo(),Zn(n.projectId),w={isMember:!1},je()),ze())}).catch(()=>{})))}return window.addEventListener($n,to),window.addEventListener(Vn,eo),document.addEventListener("visibilitychange",vo),mo(),()=>{He(),ao=!0,t(()=>{window.removeEventListener($n,to),window.removeEventListener(Vn,eo),document.removeEventListener("visibilitychange",vo),uo(),document.removeEventListener("keydown",xn),Xe(),u&&u(),null==a||a.remove()})}}catch(go){return()=>{}}}const Ht={path:"/config",timeoutMs:4e3,ttlMs:3e5};function Kt(n,t){var e,o;const r=null!=t?t:Object.assign({enabled:!0},Ht);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 qt(n){return"_cnv_cfg_"+n}function Gt(n){const t=yn(qt(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 Zt(n,t,e){try{const o={etag:t,envelope:e,fetchedAt:Date.now()};_n(qt(n),JSON.stringify(o))}catch(n){}}function Wt(n){const t=Gt(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 Yt=["gclid","fbclid","ttclid","msclkid","dclid"],Jt=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function Qt(){const n=e(()=>window.location.href,"");let t="",o="",r="";if(n)try{const e=new URL(n);t=e.pathname,o=e.search,r=e.hash}catch(n){}return{url:n,path:t,search:o,hash:r,title:e(()=>document.title,""),referrer:e(()=>document.referrer,"")}}function Xt(n,t=!0){const o=e(()=>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 Jt){const e=r.get(n);e&&e.length>0&&(i[t]=e,c=!0)}if(t){const n={};for(const t of Yt){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 ne(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.11"}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 te(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 ee=256;function oe(n,t){if("string"!=typeof n)return;const e=n.trim();return e?e.length>t?e.slice(0,t):e:void 0}function re(n){return"_cnv_ft_"+n}function ie(n){const t=yn(re(n));if(!t)return null;const o=e(()=>(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=oe(t.source,ee);o&&(e.source=o);const r=oe(t.medium,ee);r&&(e.medium=r);const i=oe(t.name,ee);i&&(e.name=i);const c=oe(t.term,ee);c&&(e.term=c);const l=oe(t.content,ee);l&&(e.content=l);const a=oe(t.id,ee);a&&(e.id=a);const u=oe(t.referrer,1024);u&&(e.referrer=u);const s=oe(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=oe(e,ee),r=oe(o,ee);t&&r&&(n[t]=r)}Object.keys(n).length>0&&(e.clickIds=n)}return 1===Object.keys(e).length?null:e})(JSON.parse(t)),null);if(!o)return wn(re(n)),null;const r=Date.now()-o.ts;return r>63072e6||r<-864e5?(wn(re(n)),null):o}function ce(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 le="_cnv_cid";function ae(n={}){const t=mn(le),e=yn(le);let o=null;return Mn(t)?o=t:Mn(e)&&(o=e),o||(o=Cn()),ue(o,n),o}function ue(n,t={}){var e;gn(le,n,{domain:t.cookieDomain,maxAgeDays:null!==(e=t.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),_n(le,n)}const se="1.0";function de(){return(new Date).toISOString()}function fe(n,t){var e;const o=null!==(e=t.timestamp)&&void 0!==e?e:de(),r=Object.assign(Object.assign({},t.context),{projectId:t.projectId,schemaVersion:se}),i={type:n,messageId:Cn(),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 pe="_cnv_sid";function he(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!Mn(e)||!Number.isFinite(o)||o<=0?null:{id:e,lastActivity:o}}function ve(n={}){const t=Date.now(),e=(n=>{var t;return 6e4*(null!==(t=n.timeoutMinutes)&&void 0!==t?t:30)})(n),o=he(mn(pe)),r=he((n=>{if(!xn())return null;try{return sessionStorage.getItem(n)}catch(n){return null}})(pe));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:Cn(),lastActivity:t};return me(c,n),c.id}function me(n,t={}){var e;const o=(n=>`${n.id}.${n.lastActivity}`)(n),r=null!==(e=t.timeoutMinutes)&&void 0!==e?e:30;gn(pe,o,{domain:t.cookieDomain,maxAgeDays:r/1440,sameSite:"Lax"}),((n,t)=>{if(!xn())return!1;try{return sessionStorage.setItem(n,t),!0}catch(n){return!1}})(pe,o)}class ge{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&&be(t)>this.maxMessages;)t.shift();this.write(t),this.config.debug&&console.log("[cnv-track] retry queued",n.length,"buffered",be(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 be(this.read())}clear(){try{wn(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=yn(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?_n(this.storageKey,JSON.stringify(n)):wn(this.storageKey)}}function be(n){let t=0;for(const e of n)t+=e.length;return t}class ye{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 ge({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=de(),o={batch:n.map(n=>_e(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=_e(n,de());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 _e(n,t){return Object.assign(Object.assign({},n),{sentAt:t})}const we="_cnv_uid",xe="_cnv_traits";function ke(){return mn(we)||yn(we)}const Ae={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:Kt(void 0)},Ce={analytics:!0,marketing:!0};function Oe(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 Me="0.3.0-beta.11",Se="@cnv-vn/track",Ie=function(){let n=null,a=Object.assign({},Ae),u=Object.assign({},Ce),s=null,d=!1,f=null;function p(n,t){let e=null,r=null;return{apply(i,c){e&&null!==c&&c===r||(e=o(e),r=c,i&&(e=n(t(),i)))},dispose(){e=o(e),r=null}}}let h=null;const v=()=>h,m=p(k,v),g=p(Q,v),b=p(Vt,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=Kt(n.remoteConfig,a.remoteConfig)),t):t;var e}function _(){return s||(s=new ye({endpoint:a.endpoint,batchPath:a.batchPath,singlePath:a.singlePath,useBatch:a.useBatch,contentType:a.contentType,flushAt:a.flushAt,flushInterval:a.flushInterval,projectId:null!=n?n:"",debug:a.debug}),s)}function w(){var t;if(!n)return null;const o=((n={})=>{var t;const o={page:Qt(),screen:{width:e(()=>window.screen.width,0),height:e(()=>window.screen.height,0),density:e(()=>window.devicePixelRatio||1,1)},locale:e(()=>navigator.language||"",""),timezone:e(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:e(()=>navigator.userAgent||"",""),library:ne(n.library)},r=Xt(0,null===(t=n.allowAdTracking)||void 0===t||t);return r&&(o.campaign=r),o})({allowAdTracking:a.allowAdTracking});return u.analytics&&u.marketing||(o.consent=Object.assign({},u)),{anonymousId:ae({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),sessionId:ve({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),userId:null!==(t=ke())&&void 0!==t?t:void 0,context:o,projectId:n,integrations:Object.keys(a.integrations).length>0?a.integrations:void 0}}function x(n){a.debug&&console.warn(`[cnv-track] ${n}() called before init()`)}function A(n,t){try{const e=w();if(!e)return x("pageview");(n=>{const t=ie(n.projectId);t&&(n.context.firstTouch=ce(t,a.allowAdTracking))})(e);const o=((n,t,e)=>{const o=fe("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 O(n,t){try{if("string"!=typeof n||0===n.length)return;const e=w();if(!e)return x("track");const o=((n,t,e)=>{const o=fe("track",e);return o.event=n,o.properties=null!=t?t:{},o})(n,t,e);_().enqueue(o)}catch(n){}}function M(n,t){try{if("string"!=typeof n||0===n.length)return;((n,t,e={})=>{var o,r;if(n&&(gn(we,n,{domain:e.cookieDomain,maxAgeDays:null!==(o=e.cookieMaxAgeDays)&&void 0!==o?o:730,sameSite:"Lax"}),_n(we,n),null!=t)){const n=null!==(r=(()=>{const n=yn(xe);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{_n(xe,JSON.stringify(e))}catch(n){}}})(n,t,{cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays});const e=w();if(!e)return x("identify");const o=((n,t,e)=>{var o;const r=fe("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 n},get endpoint(){return a.endpoint},isZaloQrLoginEnabled(){return!!n&&Wt(n)},get consentGranted(){return u.analytics&&u.marketing},init(p,v){var w,x;try{if(!p||"string"!=typeof p)return;a=y(v),(null==v?void 0:v.consent)&&(u=Object.assign(Object.assign({},u),v.consent)),n=p,s&&s.destroy(),s=null,_(),d=!0,ae({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),ve({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),((n,t=!0,o)=>{const r=ie(n);if(r)return r;const i=Xt(0,t),c=(n=>{const t=e(()=>document.referrer,"");if(t){try{const o=new URL(t).host;if(o===e(()=>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 te(t)}})(o);if(!i&&!c)return null;const l=Object.assign(Object.assign({},null!=i?i:{}),{referrer:c,landingPage:te(e(()=>window.location.href,"")),ts:Date.now()});_n(re(n),JSON.stringify(l))})(p,a.allowAdTracking,a.cookieDomain),a.autoPageview&&A(),f=o(f);const I={page:(n,t)=>C(n,t),track:(n,t)=>O(n,t),loginWithZalo:t=>Un({projectId:n,endpoint:a.endpoint,zaloQrLoginEnabled:!!n&&Wt(n),consentGranted:u.analytics&&u.marketing,identify:M,alias:S,getUserId:ke,getAttribution(){const t=n?ie(n):null;return t?ce(t,a.allowAdTracking):null},getAnonymousId:()=>ae({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),getSessionId:()=>ve({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes})},t),projectId:n,restorePanelSession:t=>n?function(n,t,e){return X(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Sn):null;try{const r=yield fetch(Tn(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,n,t):Promise.resolve({kind:"unavailable"}),refreshPanelSession:t=>n?function(n,t,e){return X(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Sn):null;try{const r=yield fetch(Tn(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,n,t):Promise.resolve({kind:"unavailable"}),fetchRewardsSummary:(t,e,o)=>n?function(n,t,e){return X(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),In):null,l=zn(i,r);try{const r=Tn(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(Pn):[];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?Ln(t.tier):void 0}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,n,t,e,o):Promise.resolve(null),fetchPanelTiers:()=>n?function(n,t){return X(this,void 0,void 0,function*(){const e="undefined"!=typeof AbortController?new AbortController:null,o=e?setTimeout(()=>e.abort(),In):null;try{const o=yield fetch(Tn(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(Fn):[];return{applyFor:"SPENDING"===t.applyFor||"POINTS"===t.applyFor?t.applyFor:void 0,thresholdKind:"RELATIVE"===t.thresholdKind||"ABSOLUTE"===t.thresholdKind?t.thresholdKind:void 0,totalTiers:Bn(t.totalTiers),tiers:e}})(yield o.json()):null}catch(n){return null}finally{o&&clearTimeout(o)}})}(a.endpoint,n):Promise.resolve(null),fetchPointHistory:(t,e)=>n?function(n,t,e){return X(this,arguments,void 0,function*(n,t,e,o=1){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),In):null;try{const i=Tn(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(jn):[];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,n,t,e):Promise.resolve(null),fetchRedeemableRewards:(t,e,o)=>n?function(n,t,e){return X(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),In):null,l=zn(i,r);try{const r=Tn(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(Dn):[];return{points:Bn(t.points),total:Bn(t.total),rewards:e}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,n,t,e,o):Promise.resolve(null),redeemReward:(t,e,o)=>n?function(n,t,e,o,r){return X(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(Tn(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?Rn(a,!0):null};const u=Rn(a,!1);return u?{ok:!1,code:u}:{ok:!0,result:(l=a,l?{code:"string"==typeof l.code?l.code:void 0,pointsSpent:Bn(l.pointsSpent),pointsRemaining:Bn(l.pointsRemaining),transactionId:"string"==typeof l.transactionId?l.transactionId:void 0,burnOnUse:!0===l.burnOnUse}:{})}}catch(n){return{ok:!1,code:"UNCONFIRMED"}}finally{c&&clearTimeout(c)}var l})}(a.endpoint,n,t,e,o):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"}),useReward:(t,e)=>n?function(n,t,e,o){return X(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(Tn(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?Rn(c,!0):null};const l=Rn(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,n,t,e):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"})};if(h=I,a.autotrack){let n=a.autotrack;a.remoteConfig.enabled&&"object"==typeof n&&n.buttonTracking&&(n=Object.assign(Object.assign({},n),{buttonTracking:void 0})),f=function(n,e){const o=void 0===(a=e)||!1===a?Object.assign(Object.assign({},D),{searchParams:z}):!0===a?Object.assign(Object.assign({},j),{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;o.outboundClicks=!1,o.downloads=!1,o.scroll=!1,o.siteSearch=!1;const v=[];let m=null;function g(e){if(o.siteSearch)try{const r=null!=e?e:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(n){return""}})();if(r===m)return;m=r;const i=((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}})(r,o.searchParams);i&&t(()=>n.track("Site Searched",{query:i.query,param:i.param}))}catch(n){}}if(o.outboundClicks||o.downloads){const e=(n=>{var t;if("undefined"==typeof document)return()=>{};const e=new Set((null!==(t=n.downloadExtensions)&&void 0!==t?t:r).map(n=>n.toLowerCase())),o=!!n.onOutbound,a=!!n.onDownload;if(!o&&!a)return()=>{};function u(t){var r,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(i(n))return n;let e=n.target;for(;e;){if(i(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"),o=(n=>{const t=c(n),e=t.lastIndexOf(".");return e<=0||e===t.length-1?null:t.slice(e+1).toLowerCase()})(f.pathname);(t||o&&e.has(o))&&(p=!0,null===(r=n.onDownload)||void 0===r||r.call(n,{url:f.href,fileName:c(f.pathname),fileExtension:null!=o?o:"",text:l(s)}))}o&&!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:l(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:o.downloadExtensions,onOutbound:o.outboundClicks?e=>t(()=>n.track("Clicked",e)):void 0,onDownload:o.downloads?e=>t(()=>n.track("File Downloaded",e)):void 0});v.push(e)}o.buttonTracking&&o.buttonTracking.rules&&o.buttonTracking.rules.length>0&&v.push(k(n,o.buttonTracking));let b=null;if(o.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=>{t(()=>n.track("Scrolled",{percent:e}))}),v.push(()=>null==b?void 0:b.destroy())),o.spa){const e=[],o=N(o=>{const r=setTimeout(()=>{const o=e.indexOf(r);-1!==o&&e.splice(o,1),t(()=>n.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,n)}if(m.dispose(),g.dispose(),b.dispose(),a.remoteConfig.enabled&&n){const t=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)};t(null!==(x=null===(w=Gt(n))||void 0===w?void 0:w.envelope)&&void 0!==x?x:null),function(n){return X(this,void 0,void 0,function*(){if(!n.projectId)return{status:"error"};const t=Gt(n.projectId);if(t&&Date.now()-t.fetchedAt<n.ttlMs)return{status:"unchanged"};const e=yield function(n){return X(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&&Zt(n.projectId,t.etag,t.envelope),{status:"unchanged"}):e.envelope?(Zt(n.projectId,e.etag,e.envelope),{status:"updated",envelope:e.envelope}):{status:"error"}:{status:"error"}})}({endpoint:a.endpoint,path:a.remoteConfig.path,projectId:n,timeoutMs:a.remoteConfig.timeoutMs,ttlMs:a.remoteConfig.ttlMs}).then(n=>{"updated"===n.status&&t(n.envelope)}).catch(()=>{})}}catch(n){}},pageview:A,page:C,screen(n,t){},track:O,identify:M,alias:S,group(n,t){},reset(){try{((n={})=>{((n,t={})=>{var e;if(!vn)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===mn(n)}catch(n){return!1}})(we,{domain:n.cookieDomain}),wn(we),wn(xe)})({cookieDomain:a.cookieDomain}),((n={})=>{ue(Cn(),n)})({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),((n={})=>{me({id:Cn(),lastActivity:Date.now()},n)})({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),n&&(n=>{wn(re(n))})(n)}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=o(f),m.dispose(),g.dispose(),b.dispose(),h=null,s&&s.destroy(),s=null,d=!1,n=null,a=Object.assign({},Ae),u=Object.assign({},Ce)}}}();function Ee(n){return Un({projectId:Ie.projectId,endpoint:Ie.endpoint,zaloQrLoginEnabled:Ie.isZaloQrLoginEnabled(),consentGranted:Ie.consentGranted,identify:Ie.identify,alias:Ie.alias,getUserId:ke},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)Oe(n,e);return e.length},e.__loaded=!0;for(const t of o)Oe(n,t)})(Ie);const Ne=Object.assign(Ie,{version:Me,name:Se,schemaVersion:se,loginWithZalo:Ee});n.NAME=Se,n.SCHEMA_VERSION=se,n.VERSION=Me,n.ZaloQrLoginError=Nn,n.default=Ne,n.loginWithZalo=Ee,Object.defineProperty(n,"t",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).cnvTrack={});
|
|
6
|
+
var n,t;n=this,t=function(n){function t(n){try{n()}catch(n){}}function e(n,t){try{return n()}catch(n){return t}}function o(n){return n&&t(n),null}const r=["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 i(n){return!!n&&"object"==typeof n&&1===n.nodeType&&"A"===n.tagName}function c(n){const t=n.lastIndexOf("/");return-1===t?n:n.slice(t+1)}function l(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 a=200;function u(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>a?t.slice(0,a):t}function s(n){const t=!1!==n.caseInsensitive;if("regex"===n.mode)return{mode:"regex",needle:n.value,ci:t,re:w(n.value,t)};const e=n.value.normalize("NFC");return{mode:n.mode,needle:t?e.toLowerCase():e,ci:t,re:null}}function d(n,t){try{return n.matches(t)}catch(n){return!1}}function f(n){try{if("A"===n.tagName){const t=n.getAttribute("href");return t?_(t):null}const t=n.getAttribute("formaction");if(t)return _(t);const e=n.getAttribute("data-href");if(e)return _(e);const o=n.closest("form");if(o){const n=o.getAttribute("action");if(n)return _(n)}return null}catch(n){return null}}function p(n){return"regex"===n.mode?{mode:"regex",needle:n.value,re:w(n.value,!0)}:{mode:n.mode,needle:n.value.toLowerCase(),re:null}}function h(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:w(t,!1)}}function v(n,t){return"startsWith"===n.mode?0===t.indexOf(n.needle):!n.re||x(n.re,t)}const m=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,g=/\+?\d[\d\s().-]{7,}\d/g;function b(n){if(!n)return n;try{return n.replace(m,"[email]").replace(g,"[phone]")}catch(t){return n}}function y(n){return!!n&&"object"==typeof n&&1===n.nodeType}function _(n){try{return new URL(n,location.href).href}catch(t){return n}}function w(n,t){try{return!n||n.length>1e3?null:new RegExp(n,t?"i":"")}catch(n){return null}}function x(n,t){try{return n.test(t)}catch(n){return!1}}function k(n,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:A(r),selector:i.selector||null,text:i.text?s(i.text):null,dest:i.destinationUrl?p(i.destinationUrl):null,urlScope:r.urlScope?h(r.urlScope):null,dedupeWindowMs:S(c.dedupeWindowMs,S(t.dedupeWindowMs,500)),maxPerPageview:S(c.maxPerPageview,S(t.maxPerPageview,1/0)),samplingRate:I(S(c.samplingRate,S(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 u=M();function d(e){try{if(0!==e.button)return;const r=M();r!==u&&(u=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)y(n)&&t.push(n);return t}let o=n.target;for(;o;)y(o)&&t.push(o),o=o.parentNode}catch(n){}return t})(e);if(0===i.length)return;const s=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(n){return""}})();for(let r=0;r<o.length;r++){const u=o[r];if(u.urlScope&&!v(u.urlScope,s))continue;let d=null;for(let n=0;n<i.length;n++)if(C(u,i[n])){d=i[n];break}if(!d)continue;const f=u.rule.id;if((a.get(f)||0)>=u.maxPerPageview)return;const p=f+"#"+c(d),h=Date.now(),m=l.get(p);if(void 0!==m&&h-m<u.dedupeWindowMs)return;if(u.samplingRate<1&&Math.random()>=u.samplingRate)return;l.set(p,h),a.set(f,(a.get(f)||0)+1);const g=O(u.rule,d,e);return void t(()=>n.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 A(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 C(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:d(n,t)})(t,n.elementSpec))return!1;const e=n.rule.match;return!(n.selector&&!d(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=u(n);if("regex"===t.mode)return!!t.re&&x(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=f(n);if(!e)return!1;if("regex"===t.mode)return!!t.re&&x(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 O(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=b(u(t));n&&(o.text=n)}if(i.href){const n=f(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]=b(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=b(o.replace(/\s+/g," ").trim());return r.length>a?r.slice(0,a):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 S(n,t){return"number"!=typeof n||isNaN(n)?t:n}function I(n){return n<0?0:n>1?1:n}const E="__cnvPatched";function N(n){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let t=T();function e(){try{const e=T();if(e===t)return;t=e,n(e)}catch(n){}}const o=history.pushState,r=history.replaceState,i=!0===o[E],c=!0===r[E];if(!i){function u(...n){o.apply(this,n),e()}u[E]=!0,history.pushState=u}if(!c){function s(...n){r.apply(this,n),e()}s[E]=!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[E]&&(history.pushState=o),!c&&history.replaceState[E]&&(history.replaceState=r)}catch(n){}}}function T(){try{return"undefined"!=typeof location?location.href:""}catch(n){return""}}const z=["q","s","query","search","keyword"],j={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},D={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};const R=2147483e3,B="#6C5CE7",F="#FFFFFF";function L(){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 P(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 $(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 U(n){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(Math.trunc(n),0),2147483647):null}function V(n,t=20){return"number"==typeof n&&Number.isFinite(n)?Math.min(Math.max(n,0),2e3):t}function H(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 K(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:V(null==e?void 0:e.sideSpacing),bottomSpacingPx:V(null==e?void 0:e.bottomSpacing)}}function q(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 G(n){var t;(null!==(t=document.body)&&void 0!==t?t:document.documentElement).appendChild(n)}function Z(n,e){if("function"!=typeof MutationObserver)return()=>{};let o=0,r=!1;function i(){l.disconnect(),l.observe(document,{childList:!0}),document.documentElement&&l.observe(document.documentElement,{childList:!0}),document.body&&l.observe(document.body,{childList:!0})}function c(){r=!0,l.disconnect()}const l=new MutationObserver(()=>{r||(i(),!n.isConnected&&document.body&&(++o>5?c():(G(n),i(),e&&t(e))))});return i(),c}const W="cnv:panel:opened",Y="cnv:panel:closed";function J(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&&$(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 Q(n,o){if("undefined"==typeof document||"undefined"==typeof window)return()=>{};try{const{hostEl:n,shadow:r}=q("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=P(e.backgroundColor,B),n.style.color=P(e.textColor,F),n.style.borderRadius=(n=>{switch(n){case"SQUARE":return"2px";case"SHAVED":return"8px";case"ROUNDED":return"16px";default:return"999px"}})(e.buttonShape),J(t,e,!1)})(i,c,o);let a=!1;const u=()=>((n,t,o,r,i)=>{try{const c=L();if(((n,t)=>{if("DESKTOP_ONLY"===n.deviceVisibility&&t)return!0;if(n.hideOnHomepage&&e(()=>"/"===location.pathname||""===location.pathname,!1))return!0;const o=n.hideUrlConditions;if(o&&o.length>0){const n=e(()=>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}=K(r,c),s=r.useCustomZIndex?U(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:R));const p=c?r.contentLayoutMobile:r.contentLayoutDesktop,h=!i&&"ICON_ONLY"!==p;t.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){}})(n,c,l,o,a),s=n=>{a!==n&&(a=n,t(()=>{J(c,o,n),i.setAttribute("aria-label",n?"Đóng":"Launcher"),u()}))},d=()=>s(!0),f=()=>s(!1);window.addEventListener(W,d),window.addEventListener(Y,f);const p=()=>{t(()=>window.dispatchEvent(new CustomEvent("cnv:launcher:click",{detail:{config:o}})))};i.addEventListener("click",p);let h=null;const v=()=>{t(()=>{G(n),h=Z(n,u),u()})};document.body?v():document.addEventListener("DOMContentLoaded",v,{once:!0});const m=e(()=>window.matchMedia("(max-width: 768px)"),null),g=()=>u(),b=m;m&&"function"==typeof m.addEventListener?m.addEventListener("change",g):m&&"function"==typeof b.addListener?b.addListener(g):window.addEventListener("resize",g);const y=N(u);return()=>{t(()=>{document.removeEventListener("DOMContentLoaded",v),i.removeEventListener("click",p),window.removeEventListener(W,d),window.removeEventListener(Y,f),m&&"function"==typeof m.removeEventListener?m.removeEventListener("change",g):m&&"function"==typeof b.removeListener?b.removeListener(g):window.removeEventListener("resize",g),h&&h(),n.remove()}),t(y)}}catch(n){return()=>{}}}function X(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 nn=(n,t)=>{let e=n;const o=tn[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=en.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=en.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=en.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=en.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=cn.getRSBlocks(n,t),r=ln();for(let t=0;t<e.length;t+=1){const o=e[t];r.put(o.getMode(),4),r.put(o.getLength(),en.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=en.getErrorCorrectPolynomial(u),d=rn(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=an(n);break;case"Alphanumeric":e=un(n);break;case"Byte":e=sn(n);break;case"Kanji":e=dn(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=cn.getRSBlocks(n,o),e=ln();for(let t=0;t<l.length;t++){const o=l[t];e.put(o.getMode(),4),e.put(o.getLength(),en.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=en.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 hn(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};nn.stringToBytes=n=>{const t=[];for(let e=0;e<n.length;e+=1){const o=n.charCodeAt(e);t.push(255&o)}return t},nn.createStringToBytes=(n,t)=>{const e=(()=>{const e=pn(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 tn={L:1,M:0,Q:3,H:2},en=(()=>{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=rn([1],0);for(let e=0;e<n;e+=1)t=t.multiply(rn([1,on.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})(),on=(()=>{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]}}})(),rn=(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){return e[n]},getLength(){return 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]^=on.gexp(on.glog(o.getAt(e))+on.glog(n.getAt(r)));return rn(t,0)},mod(n){if(o.getLength()-n.getLength()<0)return o;const t=on.glog(o.getAt(0))-on.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]^=on.gexp(on.glog(n.getAt(o))+t);return rn(e,0).mod(n)}};return o},cn=(()=>{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 tn.L:return n[4*(t-1)+0];case tn.M:return n[4*(t-1)+1];case tn.Q:return n[4*(t-1)+2];case tn.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}}})(),ln=()=>{const n=[];let t=0;const e={getBuffer(){return 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(){return 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},an=n=>{const t=n,e={getMode(){return 1},getLength(n){return 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},un=n=>{const t=n,e={getMode(){return 2},getLength(n){return 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},sn=n=>{const t=nn.stringToBytes(n);return{getMode(){return 4},getLength(n){return t.length},write(n){for(let e=0;e<t.length;e+=1)n.put(t[e],8)}}},dn=n=>{const t=nn.stringToBytes;(()=>{const n=t("友");if(2!=n.length||38726!=(n[0]<<8|n[1]))throw"sjis not supported."})();const e=t(n),o={getMode(){return 8},getLength(n){return~~(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},fn=()=>{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(){return 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},pn=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},hn=(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=fn(),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:()=>t,indexOf:t=>n[t],contains:t=>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=fn();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},vn="undefined"!=typeof window&&"undefined"!=typeof document;function mn(n){if(!vn)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 gn(n,t,e={}){var o,r,i;if(!vn)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,mn(n)===t}catch(n){return!1}}function bn(){if(!vn)return!1;try{const n="__cnv_probe__";return localStorage.setItem(n,"1"),localStorage.removeItem(n),!0}catch(n){return!1}}function yn(n){if(!bn())return null;try{return localStorage.getItem(n)}catch(n){return null}}function _n(n,t){if(!bn())return!1;try{return localStorage.setItem(n,t),!0}catch(n){return!1}}function wn(n){if(!bn())return!1;try{return localStorage.removeItem(n),!0}catch(n){return!1}}function xn(){if(!vn)return!1;try{const n="__cnv_probe__";return sessionStorage.setItem(n,"1"),sessionStorage.removeItem(n),!0}catch(n){return!1}}const kn="0123456789abcdef";function An(n){return kn[n>>>4&15]+kn[15&n]}function Cn(){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,An(n[0])+An(n[1])+An(n[2])+An(n[3])+"-"+An(n[4])+An(n[5])+"-"+An(n[6])+An(n[7])+"-"+An(n[8])+An(n[9])+"-"+An(n[10])+An(n[11])+An(n[12])+An(n[13])+An(n[14])+An(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 On=/^[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 Mn(n){return"string"==typeof n&&On.test(n)}const Sn=8e3,In=3e4,En=/^(https:|zalo:)/i;class Nn 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 Tn(n,t,e,o){return`${n}${t}?${new URLSearchParams(Object.assign({projectId:e},o)).toString()}`}function zn(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 jn(n){return{title:"string"==typeof n.title?n.title:void 0,description:"string"==typeof n.description?n.description:void 0,points:Bn(n.points),expPoints:Bn(n.expPoints),balanceAfter:Bn(n.balanceAfter),expBalanceAfter:Bn(n.expBalanceAfter),rankAfter:"string"==typeof n.rankAfter?n.rankAfter:void 0,createdAt:"string"==typeof n.createdAt?n.createdAt:void 0}}function Dn(n){return{campaignId:Bn(n.campaignId),rewardId:Bn(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:Bn(n.redeemPoints),redeemRemain:Bn(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 Rn(n,t){return n?"string"==typeof n.error&&n.error?n.error:t&&"string"==typeof n.code&&n.code?n.code:null:null}function Bn(n){return"number"==typeof n&&Number.isFinite(n)?n:void 0}function Fn(n){return{id:Bn(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:Bn(n.threshold),level:Bn(n.level),benefits:Array.isArray(n.benefits)?n.benefits.filter(n=>"string"==typeof n&&""!==n.trim()):[]}}function Ln(n){return{id:Bn(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:Bn(n.level),progressCurrent:Bn(n.progressCurrent),progressTarget:Bn(n.progressTarget),remaining:Bn(n.remaining),nextLevelName:"string"==typeof n.nextLevelName?n.nextLevelName:void 0,isHighestLevel:!0===n.isHighestLevel}}function Pn(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 $n(n,t){return X(this,void 0,void 0,function*(){var e,o,r;if(!n.projectId||!n.endpoint)throw new Nn("not-initialized");if(!n.zaloQrLoginEnabled)throw new Nn("disabled");if(!n.consentGranted)throw new Nn("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 X(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Sn):null;let i;try{i=yield fetch(Tn(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 Nn("network")}finally{r&&clearTimeout(r)}if(!i.ok)throw new Nn(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||!En.test(t.miniAppDeepLink)||"number"!=typeof t.expiresInSeconds||!Number.isFinite(t.expiresInSeconds)||t.expiresInSeconds<=0)throw new Nn("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 Nn("denied"))):"expired"===n.status&&v(()=>h(new Nn("expired")))},g=()=>{null!==a||c||(a=setInterval(()=>{fetch(Tn(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(Tn(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 Nn("expired")))},1e3*o)}),cancel(){c||(c=!0,f(),null==d||d(new Nn("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:()=>(s.cancel(),$n(n,t))}})}const Un="cnv:launcher:click",Vn="cnv:panel:identify",Hn="cnv-panel-card--leaving";function Kn(n){return"cnv_panel_session_"+(null!=n?n:"default")}function qn(n){const t=yn(Kn(n));return t?e(()=>{const n=JSON.parse(t);return n&&"string"==typeof n.token&&n.token&&"number"==typeof n.contactId&&"number"==typeof n.exp?n:null},null):null}function Gn(n,t){_n(Kn(n),JSON.stringify(t))}function Zn(n){wn(Kn(n))}function Wn(n){return"SQUARE"===n?"0px":"12px"}function Yn(n){const t=n.colors;return P(null==t?void 0:t.iconColor,P(null==t?void 0:t.buttonBg,P(null==t?void 0:t.bannerBg,B)))}function Jn(n,t){n.style.background=H(t,.12),n.style.color=t}const Qn='<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"/>',Xn='<path d="M9 6l6 6-6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',nt='<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"/>',tt='<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"/>',et='<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"/>',ot='<path d="M5 13l4.5 4.5L19 8" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"/>',rt='<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"/>',it="#1E9E5B",ct="rgba(30, 158, 91, 0.12)",lt="#D64545",at="rgba(214, 69, 69, 0.10)",ut="#6B7280",st="rgba(107, 114, 128, 0.12)";function dt(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 ft(n,t){const e=document.createElement("div");return e.className="cnv-panel-chip",Jn(e,t),e.appendChild(dt(n,14)),e}function pt(n,t){const e=document.createElement("span");return e.className="cnv-panel-badge",Jn(e,t),e.textContent=n,e}const ht={POINTS:{label:"Điểm thưởng",icon:nt},REFERRAL:{label:"Giới thiệu bạn bè",icon:tt},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"/>'}},vt={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:rt,redeem:Qn,history:et},mt={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:nt,GIFT:Qn,USERS:tt,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:rt,CHECK:ot},gt={earn:{label:"Cách kiếm thêm điểm",icon:rt},redeem:{label:"Cách đổi điểm",icon:Qn}},bt="cnv-panel-reward__title--full",yt="Tham gia ngay",_t=[[gt.earn.label,"earn"],[gt.redeem.label,"redeem"]],wt=/\{\{\s*TenKhachHang\s*\}\}/gi,xt=/[\u0000-\u001F\u007F\u200B\u200E\u200F\u2028\u2029\u202A-\u202E\u2066-\u2069\uFEFF]/g;function kt(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 At(n,t){const o=(n=>{if("string"!=typeof n)return"bạn";const t=e(()=>n.normalize("NFC"),n).replace(xt," ").replace(/\s+/g," ").trim();if(!t)return"bạn";const o=Array.from(t);return o.length<=24?t:o.slice(0,24).join("").trimEnd()+"…"})(t);return(n||"").replace(wt,()=>o)}const Ct=[{key:"owned",label:"Ưu đãi của bạn"},{key:"redeem",label:"Đổi ưu đãi"}],Ot={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"},Mt={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"},St={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:Ot,MISSING_SERIAL:Ot,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"}},It={CODE_NOT_ISSUED:Mt,MISSING_VOUCHER:Mt,MISSING_SERIAL:Mt,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"}},Et={message:"Không đổi được ưu đãi lúc này. Bạn thử lại sau nhé.",action:"retry"},Nt={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"}},Tt={message:"Chưa lấy được mã lúc này. Bạn thử lại sau nhé.",action:"retry"},zt={other:"Chọn ưu đãi khác",retry:"Thử lại",owned:"Kiểm tra ưu đãi của bạn",none:""};function jt(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=Wn(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 Dt(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 Rt(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 Bt(n){const t=document.createElement("div");t.className="cnv-panel-vstack";const e=document.createElement("div");e.className="cnv-panel-zalo__qr",e.appendChild(Dt(180,180)),Rt(e,n),t.appendChild(e);const o=document.createElement("div");return o.className="cnv-panel-vstack",o.style.gap="6px",o.append(Dt(240,14),Dt(160,14)),t.appendChild(o),t.appendChild(Dt(120,14)),t}function Ft(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(dt(n,20));const c=document.createElement("div");return c.className="cnv-panel-zalo__title",c.textContent=o,r.append(i,c),r}function Lt(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 Pt(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 $t(n){return n instanceof Nn?n.reason:null}function Ut(n){switch($t(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 Vt(n,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=null,_=!1,w=null,x=null,k=!1,A=!1,C=!1,O=[],M=0,S=!1,I=null,E=null,N=null,T=!1,z=0,j=[],D=0,V=null,W=!1,Y=!1,J=Ct[0].key,Q=[],tn=0,en=0,on=!1,rn=null,cn=null,ln=!1,an=0,un=null,sn=null;function dn(n){const e="owned"===n?un:sn;e&&("owned"===n?un=null:sn=null,t(()=>e.abort()))}function fn(){return"undefined"!=typeof AbortController?new AbortController:null}let pn=null,hn=!1,vn=null,mn=0,gn=0,bn=0,yn=null,_n=null,wn=null;const xn=n=>{"Escape"===n.key&&Qe()};function kn(n){return!k||n!==gn}function An(n,t){return e(()=>{const e=new CustomEvent(n,{detail:{action:t},cancelable:!0});return window.dispatchEvent(e),e.defaultPrevented},!1)}function On(n){An("cnv:panel:cta-click",n)}function Mn(n){return()=>{_&&n()}}function Sn(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=vt[t];if(i){const n=dt(i,20);n.style.color=Yn(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(dt(Xn,12,"cnv-panel-icon--chevron")),o.addEventListener("click",Mn(()=>{An("cnv:panel:menu-click",t)||("rewards"===t?(A=!0,J=Ct[0].key,pn=null,Be(),le(),Fn()):"history"===t?(C=!0,Be(),fe(),O.length||(M=0,de())):gt[t]&&(I=t,Be(),be()))})),o}function In(){var n,t,e,o;const i=jt(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=Wn(null===(n=r.shapes)||void 0===n?void 0:n.button),u.style.backgroundColor=P(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,B),u.style.color=P(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,F),u.appendChild(dt(Qn,15)),u.appendChild(document.createTextNode(((null==c?void 0:c.createAccountButtonText)||"").trim()||yt)),u.addEventListener("click",Mn(()=>{On("create-account"),Ze()})),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=P(null===(o=r.colors)||void 0===o?void 0:o.linkColor,B),n.appendChild(document.createTextNode(s)),n.appendChild(dt(Xn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",Mn(()=>{On("sign-in"),Ze()})),i.appendChild(n)}return i}function En(){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=Wn(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 Nn(){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=Wn(null===(n=r.shapes)||void 0===n?void 0:n.button),a.style.backgroundColor=P(null===(t=r.colors)||void 0===t?void 0:t.buttonBg,B),a.style.color=P(null===(e=r.colors)||void 0===e?void 0:e.buttonFont,F),a.appendChild(dt(Qn,15)),a.appendChild(document.createTextNode(((null==i?void 0:i.createAccountButtonText)||"").trim()||yt)),a.addEventListener("click",Mn(()=>{On("create-account"),Ze()})),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=P(null===(o=r.colors)||void 0===o?void 0:o.linkColor,B),n.appendChild(document.createTextNode(u)),n.appendChild(dt(Xn,12,"cnv-panel-icon--chevron")),n.addEventListener("click",Mn(()=>{On("sign-in"),Ze()})),l.appendChild(n)}return l}function Tn(){var n;return null!==(n=null==N?void 0:N.points)&&void 0!==n?n:null==w?void 0:w.points}function zn(t=!1){if(!(null==w?void 0:w.isMember)||T)return;if(!t&&N&&Date.now()-z<3e4)return;const e=qn(n.projectId);if(!e)return;T=!0,dn("owned");const o=fn();un=o,_&&je(),n.fetchRewardsSummary(e.token,1,o?o.signal:void 0).then(n=>{T=!1,o&&o.signal.aborted||(n?(N=n,z=Date.now(),j=n.rewards.slice(),D=1,_&&je()):_&&je())}).catch(()=>{T=!1,_&&je()})}function jn(){return(Array.isArray(r.sections)?r.sections:[]).some(n=>"VIP"===n.type&&n.enabled)}function Dn(){const n=null==N?void 0:N.rewardsAvailableCount;return"number"==typeof n&&D?Math.max(0,n-j.length):0}function Rn(){if(Y||!Dn())return;const t=qn(n.projectId);if(!t)return;const e=D+1;Y=!0,A&&le(),n.fetchRewardsSummary(t.token,e).then(n=>{Y=!1,D=e,n&&(n.rewards.length&&(j=j.concat(n.rewards)),"number"==typeof n.rewardsAvailableCount&&N&&(N=Object.assign(Object.assign({},N),{rewardsAvailableCount:n.rewardsAvailableCount}))),A&&le()}).catch(()=>{Y=!1,A&&le()})}function Bn(n){if(J===n)return;const t=J;J=n,pn=null,rn=null,Ot(),dn(t),Be(),le(),Fn(!0)}function Fn(n=!1){if("redeem"===J){if(!n&&Q.length&&Date.now()-en<3e4)return;return tn=0,Q=[],void Ln()}zn(n)}function Ln(){if(on)return;const t=qn(n.projectId);if(!t)return;const e=tn+1;on=!0,dn("redeem");const o=fn();sn=o,A&&le(),n.fetchRedeemableRewards(t.token,e,o?o.signal:void 0).then(n=>{on=!1,tn=e,n&&(1===e&&(en=Date.now()),"number"==typeof n.total&&(c=n.total),"number"==typeof n.points&&(l=n.points),n.rewards.length&&(Q=Q.concat(n.rewards))),A&&le()}).catch(()=>{on=!1,A&&le()})}function Pn(){return null!=l?l:Tn()}function $n(){return null!==qn(n.projectId)}function Kn(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",Mn(Ze)),n.appendChild(r)}function nt(t,e=!1){const o=kt(t);if(hn||null===o)return;const r=qn(n.projectId);if(!r)return;if(An("cnv:panel:redeem-click","redeem-confirm"))return;const i=e&&vn?vn:Cn();vn=i;const c=++mn;hn=!0,pn={kind:"confirm",item:t},le(),n.redeemReward(r.token,o,i).then(n=>{var e;tt(c)&&(hn=!1),n.ok&&(vn=null,e=n.result,Mt(),l="number"==typeof e.pointsRemaining?e.pointsRemaining:void 0,zn()),A&&tt(c)&&(pn=n.ok?{kind:"success",item:t,result:n.result}:{kind:"error",code:n.code,item:t},le())}).catch(()=>{tt(c)&&(hn=!1),A&&tt(c)&&(Mt(),pn={kind:"error",code:"UNCONFIRMED",item:t},le())})}function tt(n){return n===mn}function rt(t){const e=t.redeemId;if(ln||"number"!=typeof e||e<=0)return;const o=qn(n.projectId);if(!o)return;const r=++an;ln=!0,cn={kind:"confirm",item:t},le(),n.useReward(o.token,e).then(n=>{const o=n.ok?wt(e,t,n.result):null;r===an&&(ln=!1),A&&r===an&&(o?(cn=null,rn=o):n.ok||(cn={kind:"error",code:n.code,item:t}),Be(),le())}).catch(()=>{r===an&&(ln=!1),A&&r===an&&(cn={kind:"error",code:"UNCONFIRMED",item:t},le())})}function wt(n,t,e){const o=j.findIndex(t=>t.redeemId===n),r=o>=0?j[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&&(j[o]=i),i}function xt(){pn=null,rn=null,hn=!1,mn++,Ot()}function Ot(){cn=null,ln=!1,an++}function Mt(){N=null,z=0,j=[],D=0,O=[],i=void 0,M=0,Q=[],c=void 0,tn=0,en=0}function Vt(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"),$(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(ne(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=Pt(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",Jn(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=Pt(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",Mn(()=>{if(!n.canUse)return rn=n,Be(),void le();Ht(n)})),t.appendChild(r),o.appendChild(t)}return o}function Ht(n){if(n.burnOnUse)return cn={kind:"confirm",item:n},Be(),void le();rt(n)}function Kt(n,t,e){const o=Ft(ln?et:Qn,ln?ut:t,ln?st:H(t,.12),e.title||"Ưu đãi"),r=document.createElement("div");r.className="cnv-panel-zalo__status",r.textContent=ln?"Đ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=ln,ln||c.addEventListener("click",Mn(()=>{cn=null,Be(),le()}));const l=document.createElement("button");l.type="button",l.className="cnv-panel-zalo__btn",l.textContent=ln?"Đang xử lý…":"Dùng ngay",l.disabled=ln,ln||(l.style.borderColor=t,l.style.color=t,l.addEventListener("click",Mn(()=>rt(e)))),i.append(c,l),n.appendChild(i)}function qt(n,t,e,o){const r=o&&Nt[o]||Tt,i="UNCONFIRMED"===o,c=Ft(i?et:Qn,i?ut:lt,i?st:at,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",Mn(()=>{cn=null,Be(),le()})),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",Mn(()=>rt(e))),a.appendChild(n)}n.appendChild(a)}function Gt(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",Mn(()=>{e.disabled||(e.disabled=!0,function(n){return X(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?it:t,e.style.color=n?it: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 Zt(n,t,e){const o=Ft(Qn,t,H(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=Pt(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=Pt(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",Mn(()=>{rn=null,Ht(e)})),o.appendChild(r),n.appendChild(o)}const c=document.createElement("div");c.className="cnv-panel-redeem__actions",e.canUse||c.appendChild(Gt(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",Mn(()=>{rn=null,Be(),le()})),c.appendChild(l),n.appendChild(c)}function Wt(n){const t=document.createElement("div");return t.className="cnv-panel-rtabs",t.setAttribute("role","tablist"),Ct.forEach(e=>{const o=e.key===J,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",Mn(()=>Bn(e.key))),t.appendChild(r)}),t}function Yt(n){return n.toLocaleString("vi-VN")+" điểm"}function Jt(n){return n>0?Yt(n):"Miễn phí"}function Qt(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 Xt(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,Qt(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 ne(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(dt('<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(bt)}),t.append(e,o),t}function te(n){if(null===kt(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=Pn();return"number"==typeof t&&t<n.redeemPoints?`Cần thêm ${Yt(n.redeemPoints-t)}`:null}function ee(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"),$(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(ne(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",Jn(o,e),o.textContent=n.discountValue,t.appendChild(o),i.appendChild(t)}const c=Pt(n.expiredAt);if(c){const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent=`HSD ${c}`,i.appendChild(n)}const l=te(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=Jt(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||hn,u.disabled||(u.style.borderColor=e,u.style.color=e,u.addEventListener("click",Mn(()=>{pn={kind:"confirm",item:n},Be(),le()}))),a.appendChild(u),o.appendChild(a),o}function oe(n,t){const e=Pn();if("number"==typeof e&&n.appendChild(Xt(e,t)),!$n())return void Kn(n,t,"Bạn cần đăng nhập để xem ưu đãi có thể đổi.");if(on&&!Q.length)return n.appendChild(Dt(200,12)),void n.appendChild(Dt(150,12));if(!Q.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",Q.forEach((n,e)=>o.appendChild(ee(n,e>0,t))),n.appendChild(o);const r="number"==typeof c&&tn?Math.max(0,c-Q.length):0;if(r>0||on){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more",t.disabled=on,t.textContent=on?"Đang tải…":`Xem thêm ${r} ưu đãi`,t.addEventListener("click",Mn(Ln)),n.appendChild(t)}}function re(n,t,e){const o=Ft(Qn,t,H(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=Jt(e.redeemPoints);n.textContent=r,Qt(n,r,20),o.appendChild(n);const i=Pn();if(e.redeemPoints>0&&"number"==typeof i){const n=document.createElement("div");n.className="cnv-panel-redeem__sub",n.textContent=`Còn lại ${Yt(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=hn,hn||i.addEventListener("click",Mn(()=>{pn=null,le()}));const c=document.createElement("button");c.type="button",c.className="cnv-panel-zalo__btn",c.textContent=hn?"Đang đổi…":"Đổi",c.disabled=hn,hn||(c.style.borderColor=t,c.style.color=t,c.addEventListener("click",Mn(()=>nt(e)))),r.append(i,c),n.appendChild(r)}function ie(n,t,e,o){var r;const i=Ft(ot,it,ct,"Đổ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),o.burnOnUse||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 ${Yt(l)}`),"number"==typeof o.pointsRemaining&&a.push(`còn lại ${Yt(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),!o.burnOnUse&&!e.burnOnUse&&o.code){const e=document.createElement("div");e.className="cnv-panel-redeem__actions",e.appendChild(Gt(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",Mn(()=>Bn("owned")));const d=document.createElement("button");d.type="button",d.className="cnv-panel-zalo__btn",d.textContent="Đổi tiếp",d.addEventListener("click",Mn(()=>{pn=null,Be(),le(),"redeem"!==J||Q.length||(tn=0,Ln())})),u.append(d,s),n.appendChild(u)}function ce(n,t,e,o){var r;const i=((n,t)=>{var e;if(t){if(void 0!==(null===(e=kt(n))||void 0===e?void 0:e.redeemPoints)&&It[t])return It[t];if(St[t])return St[t]}return Et})(e,o),c="neutral"===i.tone,l=Ft(c?et:Qn,c?ut:lt,c?st:at,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=()=>{pn=null,Be(),le()},d=zt[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",Mn(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",Mn(()=>Bn("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",Mn(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",Mn(()=>nt(e,!i.retryWithNewKey))),u.appendChild(n)}}n.appendChild(u)}function le(){var n,t;if(!v)return;Le(),Pe(),Fe(!0);const e=null!==(t=null===(n=v.querySelector(".cnv-panel-rlist"))||void 0===n?void 0:n.scrollTop)&&void 0!==t?t:0;v.textContent="";const o=Yn(r),i="redeem"===J?null!==pn:null!==cn||null!==rn,c=jt(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(ft(Qn,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,Wt(o)),c.appendChild(e),l=document.createElement("div"),l.className="cnv-panel-rlist",c.appendChild(l)}"redeem"===J?"confirm"===(null==pn?void 0:pn.kind)?re(c,o,pn.item):"success"===(null==pn?void 0:pn.kind)?ie(c,o,pn.item,pn.result):"error"===(null==pn?void 0:pn.kind)?ce(c,o,pn.item,pn.code):oe(l,o):"confirm"===(null==cn?void 0:cn.kind)?Kt(c,o,cn.item):"error"===(null==cn?void 0:cn.kind)?qt(c,o,cn.item,cn.code):rn?Zt(c,o,rn):ae(l,o),v.appendChild(c),e>0&&l!==c&&(l.scrollTop=e),v&&v.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(bt);const o=t.offsetHeight;t.classList.remove(bt),n.classList.toggle("cnv-panel-reward__name--clamped",o>e+1)})}function ae(n,t){if(!$n())return void Kn(n,t,"Bạn cần đăng nhập để xem ưu đãi của bạn.");if(T&&!j.length)return n.appendChild(Dt(200,12)),void n.appendChild(Dt(150,12));if(!j.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",j.forEach((n,o)=>e.appendChild(Vt(n,o>0,t))),n.appendChild(e);const o=Dn();if(o>0||Y){const t=document.createElement("button");t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-reward__more",t.disabled=Y,t.textContent=Y?"Đang tải…":`Xem thêm ${o} ưu đãi`,t.addEventListener("click",Rn),n.appendChild(t)}}function ue(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 se(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=mt[n.icon];i.appendChild(ft("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 de(){if(S)return;const t=qn(n.projectId);if(!t)return;const e=M+1;S=!0,C&&fe(),n.fetchPointHistory(t.token,e).then(n=>{S=!1,M=e,n&&("number"==typeof n.totalCount&&(i=n.totalCount),n.items.length&&(O=O.concat(n.items))),C&&fe()}).catch(()=>{S=!1,C&&fe()})}function fe(){if(!v)return;Le(),Pe(),Fe(!0),v.textContent="";const n=Yn(r),t=jt(r);if(t.appendChild(ye({label:"Lịch sử hoạt động",icon:et},n)),!O.length&&S)t.appendChild(Dt(180,12)),t.appendChild(Dt(120,12));else if(O.length){const n=document.createElement("div");n.className="cnv-panel-history__list",O.forEach((t,e)=>n.appendChild(pe(t,e>0))),t.appendChild(n);const e="number"==typeof i&&M?Math.max(0,i-O.length):0;if(e>0||S){const n=document.createElement("button");n.type="button",n.className="cnv-panel-zalo__btn cnv-panel-reward__more",n.disabled=S,n.textContent=S?"Đang tải…":`Xem thêm ${e} hoạt động`,n.addEventListener("click",Mn(de)),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)}v.appendChild(t)}function pe(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(he(c));const l=[];"number"==typeof n.balanceAfter&&l.push("Điểm tích lũy: "+me(n.balanceAfter));const a=(n.rankAfter||"").trim();"number"==typeof n.expBalanceAfter?l.push("Điểm xét hạng: "+me(n.expBalanceAfter)+(a?" (Hạng "+a+")":"")):a&&l.push("Hạng "+a),l.length&&o.appendChild(he(l.join(" / ")));const u=ge(n.createdAt);u&&o.appendChild(he(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=ve(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=ve(n.expPoints)+" xét hạng",s.appendChild(t)}return s.childElementCount&&e.appendChild(s),e}function he(n){const t=document.createElement("div");return t.className="cnv-panel-history__meta",t.textContent=n,t}function ve(n){const t=Math.round(n);return(t>0?"+":"")+t.toLocaleString("vi-VN")}function me(n){return Math.round(n).toLocaleString("vi-VN")}function ge(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 be(){if(!v||!I)return;const n=gt[I];if(!n)return I=null,void Ne();const t=ue(I);Le(),Pe(),Fe(!0),v.textContent="";const e=Yn(r),o=jt(r);if(o.appendChild(ye(n,e)),t.length){const r=document.createElement("div");r.className="cnv-panel-block__list",t.forEach((t,o)=>r.appendChild(se(t,o>0,e,n.icon))),o.appendChild(r)}else{const n=document.createElement("div");n.className="cnv-panel-reward__meta",n.textContent="redeem"===I?"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(v.appendChild(o),!Re()){const n=En();n&&v.appendChild(n)}E=Re()}function ye(n,t){const e=document.createElement("div");e.className="cnv-panel-section__head",e.appendChild(ft(n.icon,t));const o=document.createElement("div");return o.className="cnv-panel-section__title",o.textContent=n.label,e.appendChild(o),e}function _e(n){if(!(Array.isArray(r.sections)?r.sections:[]).some(n=>"POINTS"===n.type&&n.enabled))return null;const t=jt(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 _t.forEach((n,t)=>o.appendChild(Sn(n[0],n[1],t>0))),t.append(ye(ht.POINTS,n),e,o),t}function we(n){const t=Math.max(0,Math.round(n)).toLocaleString("vi-VN");return"SPENDING"===(null==V?void 0:V.applyFor)?t+"đ":t+" điểm"}function xe(n){const t=document.createElement("span");if(t.className="cnv-panel-tier__badge",$(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=P(n.colorCode,Yn(r)),t}function ke(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(xe(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 Ae(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 Ce(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 Oe(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 "+we(s)+" nữa để lên "+n.nextLevelName:"Còn "+we(s)+" nữa để lên hạng kế tiếp",c.append(l,u),c}function Me(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 Se(n,t){var e,o;const i=null!==(e=null==V?void 0:V.tiers)&&void 0!==e?e:[];if(!i.length)return null;const c=jt(r),l=document.createElement("div"),a=t?null==N?void 0:N.tier:void 0;if(null==a?void 0:a.name){const t=document.createElement("div");t.className="cnv-panel-tier__current",t.appendChild(xe(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=Oe(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}=Me(i,u),f=document.createElement("div");f.className="cnv-panel-tier__list",s>0&&f.appendChild(Ce(s,!1));for(let n=s;n<d;n++){const t=n===u;if(f.appendChild(ke(i[n],t)),t||u<0){const t=Ae(i[n].benefits);t&&f.appendChild(t)}}const p=Math.max(null!==(o=null==V?void 0:V.totalTiers)&&void 0!==o?o:i.length,i.length)-d;return p>0&&f.appendChild(Ce(p,!0)),l.appendChild(f),c.append(ye(ht.VIP,n),l),c}function Ie(n,t){const e=ht[n];if(!e||"string"!=typeof e.label)return null;if("VIP"===n)return Se(t,!0);const o=jt(r),i=ye(e,t),c=document.createElement("div");if("POINTS"!==n)return c.appendChild(pt("Sắp ra mắt",t)),o.append(i,c),o;const l=Tn();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(pt("Đang cập nhật",t));const a=null!==(u=null==N?void 0:N.rewardsAvailableCount)&&void 0!==u?u:null==w?void 0:w.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"],..._t,["Lịch sử hoạt động","history"]].forEach((n,t)=>c.appendChild(Sn(n[0],n[1],t>0))),o.append(i,c),o}function Ee(){if(!p||!h)return;const t=r.colors;s&&(s.style.backgroundColor="DARK"===r.theme?"#181C32":"#FFFFFF",s.style.color="DARK"===r.theme?"#FFFFFF":"#181C32");const e=p.parentElement;if(e&&(e.style.backgroundColor=P(null==t?void 0:t.bannerBg,B),e.style.color=P(null==t?void 0:t.bannerFont,F)),d&&($(r.bannerImageUrl)?(d.src=r.bannerImageUrl,d.style.display="block"):(d.style.display="none",d.removeAttribute("src"))),f){const n=f.parentElement;$(r.brandIconUrl)?(f.src=r.brandIconUrl,n&&(n.style.display="flex",n.style.background=H(P(null==t?void 0:t.bannerFont,F),.18))):(n&&(n.style.display="none"),f.removeAttribute("src"))}const o=(null==w?void 0:w.isMember)?r.headerMember:r.headerVisitor,i=(null==w?void 0:w.isMember)?null===(c=qn(n.projectId))||void 0===c?void 0:c.fullName:null;var c;p.textContent=At((null==o?void 0:o.caption)||"",i),h.textContent=At((null==o?void 0:o.title)||"",i)}function Ne(){if(!v||k||A||C||I)return;Le(),Pe(),Fe(!0),v.textContent="";const n=Yn(r);if(!(null==w?void 0:w.isMember)){let t=0;ze(In(),t++);const e=_e(n);e&&ze(e,t++);const o=jn()?Se(n,!1):null;return void(o&&ze(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=Ie(t.type,n);o&&ze(o,e++)}),$n()&&ze(Te(),e++)}function Te(){const n=document.createElement("div");n.className="cnv-panel-logout";const t=document.createElement("button");return t.type="button",t.className="cnv-panel-zalo__btn cnv-panel-logout__btn",t.textContent="Đăng xuất",t.addEventListener("click",Mn(vo)),n.appendChild(t),n}function ze(n,t){n.style.animationDelay=40+55*t+"ms",v.appendChild(n)}function je(){Ee(),I?E!==Re()&&be():Ne()}function De(){dn("owned"),dn("redeem"),N=null,z=0,en=0,j=[],D=0,A=!1,Q=[],c=void 0,tn=0,l=void 0,vn=null,xt(),O=[],i=void 0,M=0,C=!1}function Re(){return!!(null==w?void 0:w.isMember)}function Be(){if(!v)return;v.scrollTop=0;const n=v.querySelector(".cnv-panel-rlist");n&&(n.scrollTop=0)}function Fe(n){s&&(s.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 Le(){const n=k||A||C||null!==I;g&&(g.style.display=n?"inline-flex":"none"),m&&m.classList.toggle("cnv-panel-banner--sub",n)}function Pe(){if(!s)return;const n=!Re()&&null!==I;if(n&&!y)return y=Nn(),void s.insertBefore(y,b);!n&&y&&(y.remove(),y=null)}function $e(){k&&(Ve(),k=!1),A=!1,xt(),C=!1,I=null,Be(),Ne()}function Ue(){yn=o(yn)}function Ve(){_n=o(_n)}function He(n,t){Ue();const e=Date.now()+1e3*t.expiresInSeconds;yn=Lt(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 Ke(){if(k=!1,Ue(),Ve(),x){const n=x;x=null,t(()=>n.cancel())}}function qe(){const n=document.createElement("button");return n.type="button",n.className="cnv-panel-zalo__btn",n.textContent="Huỷ",n.addEventListener("click",()=>{Ke(),je()}),n}function Ge(n){var t;if(!v)return;Le(),Pe(),Fe(!1),v.textContent="";const e=Yn(r),o=jt(r,"cnv-panel-zalo");if("loading"===n.phase)o.appendChild(Bt(e)),o.appendChild(qe());else if("qr"===n.phase){const t=(n=>{try{const t=nn(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),Rt(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(dt(et,12));const l=document.createElement("span");c.appendChild(l),o.appendChild(c),He(l,n.session),o.appendChild(qe())}else{o.style.position="relative",o.appendChild(Bt(e));const l=document.createElement("div");let a;if(l.className="cnv-panel-zalo__overlay",l.style.borderRadius=Wn(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=Ft(ot,it,ct,n.result.fullName?`Xin chào ${n.result.fullName}!`:"Đăng nhập thành công!");else{const t="expired"===n.reason;a=Ft(t?et:'<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?ut:lt,t?st:at,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",Mn(()=>Ze())),bn>=3){const t=Math.min(5+5*(bn-3),20);i=n,c=t,Ve(),i.disabled=!0,_n=Lt(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;v.appendChild(o)}function Ze(){if(!v)return;Ke(),I=null,k=!0,Be();const e=++gn;Ge({phase:"loading"}),n.loginWithZalo().then(o=>{kn(e)?t(()=>o.cancel()):(x=o,bn=0,Ge({phase:"qr",session:o}),o.result.then(t=>{if(!kn(e)){if(Ue(),x=null,Ge({phase:"success",result:t}),null!=t.contactId&&"string"==typeof t.panelSessionToken&&t.panelSessionToken&&"number"==typeof t.panelSessionExp){const e="number"==typeof t.panelSessionExpiresInMs&&t.panelSessionExpiresInMs>0?Date.now()+t.panelSessionExpiresInMs:t.panelSessionExp;Gn(n.projectId,{token:t.panelSessionToken,contactId:t.contactId,fullName:t.fullName,level:t.level,xp:t.xp,exp:e}),po(e)}w={isMember:!0},zn(),setTimeout(()=>{kn(e)||(k=!1,je())},1500)}}).catch(n=>{kn(e)||(Ue(),x=null,Ge({phase:"error",message:Ut(n),canRetry:!0,reason:$t(n)}))}))}).catch(n=>{kn(e)||(bn+=1,Ge({phase:"error",message:Ut(n),canRetry:!0,reason:$t(n)}))})}function We(n){var t,e,o;if(a)return;const i=q("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-logout{display:flex;justify-content:center;padding:2px 0 10px;}.cnv-panel-logout__btn{height:32px;font-size:12px;font-weight:600;opacity:.72;}.cnv-panel-logout__btn:hover{opacity:1;}.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)?U(n.zIndex):null)&&void 0!==t?t:R,y=null!==(e=U(l+600))&&void 0!==e?e:R;s=document.createElement("div"),s.className="cnv-panel-card",s.style.zIndex=String(y),s.addEventListener("animationend",n=>{"cnv-panel-out"===n.animationName&&Xe()}),s.style.borderRadius=Wn(null===(o=r.shapes)||void 0===o?void 0:o.container);const _=document.createElement("button");_.type="button",_.className="cnv-panel-close",_.setAttribute("aria-label","Đóng"),_.textContent="×",_.addEventListener("click",Qe),g=document.createElement("button"),g.type="button",g.className="cnv-panel-back",g.setAttribute("aria-label","Quay lại"),g.appendChild(dt('<path d="M15 6l-6 6 6 6" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/>',15)),g.addEventListener("click",Mn($e));const w=document.createElement("div");m=w,w.className="cnv-panel-banner",d=document.createElement("img"),d.className="cnv-panel-banner__img",d.alt="",f=document.createElement("img"),f.className="cnv-panel-banner__brandicon",f.alt="";const x=document.createElement("div");x.className="cnv-panel-banner__brandchip",x.appendChild(f),p=document.createElement("div"),p.className="cnv-panel-banner__caption",h=document.createElement("div"),h.className="cnv-panel-banner__title",w.append(d,x,p,h),v=document.createElement("div"),v.className="cnv-panel-body",s.append(_,g,w,v),b=Ye(),b&&s.appendChild(b),c.appendChild(s),G(a),u=Z(a)}function Ye(){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 Je(n){if(!s)return;const{side:t,sideSpacingPx:e,bottomSpacingPx:o}=K(n,L());s.style.left="left"===t?e+"px":"auto",s.style.right="right"===t?e+"px":"auto";const r=o+48+24;s.style.bottom=r+"px",s.style.maxHeight=`calc(100vh - ${r+16}px)`,s.style.transformOrigin="left"===t?"left bottom":"right bottom"}function Qe(){a&&_&&(_=!1,Ke(),A=!1,xt(),C=!1,I=null,document.removeEventListener("keydown",xn),to("cnv:panel:closed"),s&&!e(()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,!1)?(s.classList.add(Hn),wn=setTimeout(Xe,320)):Xe())}function Xe(){null!==wn&&(clearTimeout(wn),wn=null),null==s||s.classList.remove(Hn),null==a||a.style.setProperty("display","none")}function no(){null!==wn&&(clearTimeout(wn),wn=null),null==s||s.classList.remove(Hn)}function to(n){t(()=>window.dispatchEvent(new CustomEvent(n)))}const eo=e=>{t(()=>{var t;const o=e.detail;var r;_?Qe():(We(r=null!==(t=null==o?void 0:o.config)&&void 0!==t?t:null),a&&(no(),Je(r),a.style.setProperty("display","block"),_=!0,je(),zn(),!jn()||V||W||(W=!0,n.fetchPanelTiers().then(n=>{W=!1,n&&n.tiers.length&&(V=n,_&&je())}).catch(()=>{W=!1})),document.addEventListener("keydown",xn),to("cnv:panel:opened")))})},oo=n=>{t(()=>{const t=n.detail;w=(null==t?void 0:t.isMember)?{isMember:!0,points:t.points,rewardsAvailableCount:t.rewardsAvailableCount}:{isMember:!1},w.isMember||De(),_&&je(),_&&zn()})},ro=3e5,io=15e3,co=6e4;let lo=null,ao=!1,uo=!1;function so(){null!==lo&&(clearTimeout(lo),lo=null)}function fo(n){so(),uo||(lo=e(()=>setTimeout(mo,Math.max(0,n)),null))}function po(n){fo(Math.max(io,n-Date.now()-ro))}function ho(){so(),Zn(n.projectId),w={isMember:!1},De(),je()}function vo(){const e=qn(n.projectId),o=n.revokePanelSession;e&&o&&t(()=>{o(e.token).catch(()=>{})}),ho()}function mo(){if(so(),uo||ao)return;const t=qn(n.projectId);t&&(Date.now()>t.exp?ho():(ao=!0,n.refreshPanelSession(t.token).then(e=>{if(ao=!1,uo)return;const o=qn(n.projectId);if(!o)return;if(o.token!==t.token)return void po(o.exp);if("ok"===e.kind)return Gn(n.projectId,Object.assign(Object.assign({},o),{token:e.token,exp:e.exp})),void po(e.exp);if("unauthorized"===e.kind)return void ho();const r=o.exp-Date.now();r<=0?ho():fo(Math.min(co,r))}).catch(()=>{if(ao=!1,uo)return;const n=t.exp-Date.now();n>0&&fo(Math.min(co,n))})))}function go(){if("visible"!==document.visibilityState)return;const t=qn(n.projectId);t&&(Date.now()>t.exp?ho():t.exp-Date.now()<=ro?mo():po(t.exp))}function bo(){const t=qn(n.projectId);t&&(Date.now()>t.exp?Zn(n.projectId):(po(t.exp),w={isMember:!0},je(),n.restorePanelSession(t.token).then(e=>{if(uo)return;if("unavailable"===e.kind)return;const o=qn(n.projectId);o&&o.token===t.token&&("ok"===e.kind?(w={isMember:!0},Gn(n.projectId,Object.assign(Object.assign({},o),{fullName:e.session.fullName,level:e.session.level,xp:e.session.xp}))):(so(),Zn(n.projectId),w={isMember:!1},De()),je())}).catch(()=>{})))}return window.addEventListener(Un,eo),window.addEventListener(Vn,oo),document.addEventListener("visibilitychange",go),bo(),()=>{Ke(),uo=!0,t(()=>{window.removeEventListener(Un,eo),window.removeEventListener(Vn,oo),document.removeEventListener("visibilitychange",go),so(),document.removeEventListener("keydown",xn),no(),u&&u(),null==a||a.remove()})}}catch(yo){return()=>{}}}const Ht={path:"/config",timeoutMs:4e3,ttlMs:3e5};function Kt(n,t){var e,o;const r=null!=t?t:Object.assign({enabled:!0},Ht);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 qt(n){return"_cnv_cfg_"+n}function Gt(n){const t=yn(qt(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 Zt(n,t,e){try{const o={etag:t,envelope:e,fetchedAt:Date.now()};_n(qt(n),JSON.stringify(o))}catch(n){}}function Wt(n){const t=Gt(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 Yt=["gclid","fbclid","ttclid","msclkid","dclid"],Jt=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function Qt(){const n=e(()=>window.location.href,"");let t="",o="",r="";if(n)try{const e=new URL(n);t=e.pathname,o=e.search,r=e.hash}catch(n){}return{url:n,path:t,search:o,hash:r,title:e(()=>document.title,""),referrer:e(()=>document.referrer,"")}}function Xt(n,t=!0){const o=e(()=>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 Jt){const e=r.get(n);e&&e.length>0&&(i[t]=e,c=!0)}if(t){const n={};for(const t of Yt){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 ne(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.12"}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 te(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 ee=256;function oe(n,t){if("string"!=typeof n)return;const e=n.trim();return e?e.length>t?e.slice(0,t):e:void 0}function re(n){return"_cnv_ft_"+n}function ie(n){const t=yn(re(n));if(!t)return null;const o=e(()=>(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=oe(t.source,ee);o&&(e.source=o);const r=oe(t.medium,ee);r&&(e.medium=r);const i=oe(t.name,ee);i&&(e.name=i);const c=oe(t.term,ee);c&&(e.term=c);const l=oe(t.content,ee);l&&(e.content=l);const a=oe(t.id,ee);a&&(e.id=a);const u=oe(t.referrer,1024);u&&(e.referrer=u);const s=oe(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=oe(e,ee),r=oe(o,ee);t&&r&&(n[t]=r)}Object.keys(n).length>0&&(e.clickIds=n)}return 1===Object.keys(e).length?null:e})(JSON.parse(t)),null);if(!o)return wn(re(n)),null;const r=Date.now()-o.ts;return r>63072e6||r<-864e5?(wn(re(n)),null):o}function ce(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 le="_cnv_cid";function ae(n={}){const t=mn(le),e=yn(le);let o=null;return Mn(t)?o=t:Mn(e)&&(o=e),o||(o=Cn()),ue(o,n),o}function ue(n,t={}){var e;gn(le,n,{domain:t.cookieDomain,maxAgeDays:null!==(e=t.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),_n(le,n)}const se="1.0";function de(){return(new Date).toISOString()}function fe(n,t){var e;const o=null!==(e=t.timestamp)&&void 0!==e?e:de(),r=Object.assign(Object.assign({},t.context),{projectId:t.projectId,schemaVersion:se}),i={type:n,messageId:Cn(),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 pe="_cnv_sid";function he(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!Mn(e)||!Number.isFinite(o)||o<=0?null:{id:e,lastActivity:o}}function ve(n={}){const t=Date.now(),e=(n=>{var t;return 6e4*(null!==(t=n.timeoutMinutes)&&void 0!==t?t:30)})(n),o=he(mn(pe)),r=he((n=>{if(!xn())return null;try{return sessionStorage.getItem(n)}catch(n){return null}})(pe));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:Cn(),lastActivity:t};return me(c,n),c.id}function me(n,t={}){var e;const o=(n=>`${n.id}.${n.lastActivity}`)(n),r=null!==(e=t.timeoutMinutes)&&void 0!==e?e:30;gn(pe,o,{domain:t.cookieDomain,maxAgeDays:r/1440,sameSite:"Lax"}),((n,t)=>{if(!xn())return!1;try{return sessionStorage.setItem(n,t),!0}catch(n){return!1}})(pe,o)}class ge{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&&be(t)>this.maxMessages;)t.shift();this.write(t),this.config.debug&&console.log("[cnv-track] retry queued",n.length,"buffered",be(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 be(this.read())}clear(){try{wn(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=yn(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?_n(this.storageKey,JSON.stringify(n)):wn(this.storageKey)}}function be(n){let t=0;for(const e of n)t+=e.length;return t}class ye{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 ge({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=de(),o={batch:n.map(n=>_e(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=_e(n,de());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 _e(n,t){return Object.assign(Object.assign({},n),{sentAt:t})}const we="_cnv_uid",xe="_cnv_traits";function ke(){return mn(we)||yn(we)}const Ae={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:Kt(void 0)},Ce={analytics:!0,marketing:!0};function Oe(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 Me="0.3.0-beta.12",Se="@cnv-vn/track",Ie=function(){let n=null,a=Object.assign({},Ae),u=Object.assign({},Ce),s=null,d=!1,f=null;function p(n,t){let e=null,r=null;return{apply(i,c){e&&null!==c&&c===r||(e=o(e),r=c,i&&(e=n(t(),i)))},dispose(){e=o(e),r=null}}}let h=null;const v=()=>h,m=p(k,v),g=p(Q,v),b=p(Vt,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=Kt(n.remoteConfig,a.remoteConfig)),t):t;var e}function _(){return s||(s=new ye({endpoint:a.endpoint,batchPath:a.batchPath,singlePath:a.singlePath,useBatch:a.useBatch,contentType:a.contentType,flushAt:a.flushAt,flushInterval:a.flushInterval,projectId:null!=n?n:"",debug:a.debug}),s)}function w(){var t;if(!n)return null;const o=((n={})=>{var t;const o={page:Qt(),screen:{width:e(()=>window.screen.width,0),height:e(()=>window.screen.height,0),density:e(()=>window.devicePixelRatio||1,1)},locale:e(()=>navigator.language||"",""),timezone:e(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:e(()=>navigator.userAgent||"",""),library:ne(n.library)},r=Xt(0,null===(t=n.allowAdTracking)||void 0===t||t);return r&&(o.campaign=r),o})({allowAdTracking:a.allowAdTracking});return u.analytics&&u.marketing||(o.consent=Object.assign({},u)),{anonymousId:ae({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),sessionId:ve({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),userId:null!==(t=ke())&&void 0!==t?t:void 0,context:o,projectId:n,integrations:Object.keys(a.integrations).length>0?a.integrations:void 0}}function x(n){a.debug&&console.warn(`[cnv-track] ${n}() called before init()`)}function A(n,t){try{const e=w();if(!e)return x("pageview");(n=>{const t=ie(n.projectId);t&&(n.context.firstTouch=ce(t,a.allowAdTracking))})(e);const o=((n,t,e)=>{const o=fe("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 O(n,t){try{if("string"!=typeof n||0===n.length)return;const e=w();if(!e)return x("track");const o=((n,t,e)=>{const o=fe("track",e);return o.event=n,o.properties=null!=t?t:{},o})(n,t,e);_().enqueue(o)}catch(n){}}function M(n,t){try{if("string"!=typeof n||0===n.length)return;((n,t,e={})=>{var o,r;if(n&&(gn(we,n,{domain:e.cookieDomain,maxAgeDays:null!==(o=e.cookieMaxAgeDays)&&void 0!==o?o:730,sameSite:"Lax"}),_n(we,n),null!=t)){const n=null!==(r=(()=>{const n=yn(xe);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{_n(xe,JSON.stringify(e))}catch(n){}}})(n,t,{cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays});const e=w();if(!e)return x("identify");const o=((n,t,e)=>{var o;const r=fe("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 n},get endpoint(){return a.endpoint},isZaloQrLoginEnabled(){return!!n&&Wt(n)},get consentGranted(){return u.analytics&&u.marketing},init(p,v){var w,x;try{if(!p||"string"!=typeof p)return;a=y(v),(null==v?void 0:v.consent)&&(u=Object.assign(Object.assign({},u),v.consent)),n=p,s&&s.destroy(),s=null,_(),d=!0,ae({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),ve({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),((n,t=!0,o)=>{const r=ie(n);if(r)return r;const i=Xt(0,t),c=(n=>{const t=e(()=>document.referrer,"");if(t){try{const o=new URL(t).host;if(o===e(()=>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 te(t)}})(o);if(!i&&!c)return null;const l=Object.assign(Object.assign({},null!=i?i:{}),{referrer:c,landingPage:te(e(()=>window.location.href,"")),ts:Date.now()});_n(re(n),JSON.stringify(l))})(p,a.allowAdTracking,a.cookieDomain),a.autoPageview&&A(),f=o(f);const I={page:(n,t)=>C(n,t),track:(n,t)=>O(n,t),loginWithZalo:t=>$n({projectId:n,endpoint:a.endpoint,zaloQrLoginEnabled:!!n&&Wt(n),consentGranted:u.analytics&&u.marketing,identify:M,alias:S,getUserId:ke,getAttribution(){const t=n?ie(n):null;return t?ce(t,a.allowAdTracking):null},getAnonymousId:()=>ae({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),getSessionId:()=>ve({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes})},t),projectId:n,restorePanelSession:t=>n?function(n,t,e){return X(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Sn):null;try{const r=yield fetch(Tn(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,n,t):Promise.resolve({kind:"unavailable"}),refreshPanelSession:t=>n?function(n,t,e){return X(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Sn):null;try{const r=yield fetch(Tn(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,n,t):Promise.resolve({kind:"unavailable"}),revokePanelSession:t=>n?function(n,t,e){return X(this,void 0,void 0,function*(){const o="undefined"!=typeof AbortController?new AbortController:null,r=o?setTimeout(()=>o.abort(),Sn):null;try{return(yield fetch(Tn(n,"/panel/session/revoke",t),{method:"POST",credentials:"omit",mode:"cors",keepalive:!0,headers:{Authorization:`Bearer ${e}`},signal:o?o.signal:void 0})).ok}catch(n){return!1}finally{r&&clearTimeout(r)}})}(a.endpoint,n,t):Promise.resolve(!1),fetchRewardsSummary:(t,e,o)=>n?function(n,t,e){return X(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),In):null,l=zn(i,r);try{const r=Tn(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(Pn):[];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?Ln(t.tier):void 0}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,n,t,e,o):Promise.resolve(null),fetchPanelTiers:()=>n?function(n,t){return X(this,void 0,void 0,function*(){const e="undefined"!=typeof AbortController?new AbortController:null,o=e?setTimeout(()=>e.abort(),In):null;try{const o=yield fetch(Tn(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(Fn):[];return{applyFor:"SPENDING"===t.applyFor||"POINTS"===t.applyFor?t.applyFor:void 0,thresholdKind:"RELATIVE"===t.thresholdKind||"ABSOLUTE"===t.thresholdKind?t.thresholdKind:void 0,totalTiers:Bn(t.totalTiers),tiers:e}})(yield o.json()):null}catch(n){return null}finally{o&&clearTimeout(o)}})}(a.endpoint,n):Promise.resolve(null),fetchPointHistory:(t,e)=>n?function(n,t,e){return X(this,arguments,void 0,function*(n,t,e,o=1){const r="undefined"!=typeof AbortController?new AbortController:null,i=r?setTimeout(()=>r.abort(),In):null;try{const i=Tn(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(jn):[];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,n,t,e):Promise.resolve(null),fetchRedeemableRewards:(t,e,o)=>n?function(n,t,e){return X(this,arguments,void 0,function*(n,t,e,o=1,r){const i="undefined"!=typeof AbortController?new AbortController:null,c=i?setTimeout(()=>i.abort(),In):null,l=zn(i,r);try{const r=Tn(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(Dn):[];return{points:Bn(t.points),total:Bn(t.total),rewards:e}})(yield l.json()):null}catch(n){return null}finally{c&&clearTimeout(c),l()}})}(a.endpoint,n,t,e,o):Promise.resolve(null),redeemReward:(t,e,o)=>n?function(n,t,e,o,r){return X(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(Tn(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?Rn(a,!0):null};const u=Rn(a,!1);return u?{ok:!1,code:u}:{ok:!0,result:(l=a,l?{code:"string"==typeof l.code?l.code:void 0,pointsSpent:Bn(l.pointsSpent),pointsRemaining:Bn(l.pointsRemaining),transactionId:"string"==typeof l.transactionId?l.transactionId:void 0,burnOnUse:!0===l.burnOnUse}:{})}}catch(n){return{ok:!1,code:"UNCONFIRMED"}}finally{c&&clearTimeout(c)}var l})}(a.endpoint,n,t,e,o):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"}),useReward:(t,e)=>n?function(n,t,e,o){return X(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(Tn(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?Rn(c,!0):null};const l=Rn(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,n,t,e):Promise.resolve({ok:!1,code:"NOT_INITIALIZED"})};if(h=I,a.autotrack){let n=a.autotrack;a.remoteConfig.enabled&&"object"==typeof n&&n.buttonTracking&&(n=Object.assign(Object.assign({},n),{buttonTracking:void 0})),f=function(n,e){const o=void 0===(a=e)||!1===a?Object.assign(Object.assign({},D),{searchParams:z}):!0===a?Object.assign(Object.assign({},j),{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;o.outboundClicks=!1,o.downloads=!1,o.scroll=!1,o.siteSearch=!1;const v=[];let m=null;function g(e){if(o.siteSearch)try{const r=null!=e?e:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(n){return""}})();if(r===m)return;m=r;const i=((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}})(r,o.searchParams);i&&t(()=>n.track("Site Searched",{query:i.query,param:i.param}))}catch(n){}}if(o.outboundClicks||o.downloads){const e=(n=>{var t;if("undefined"==typeof document)return()=>{};const e=new Set((null!==(t=n.downloadExtensions)&&void 0!==t?t:r).map(n=>n.toLowerCase())),o=!!n.onOutbound,a=!!n.onDownload;if(!o&&!a)return()=>{};function u(t){var r,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(i(n))return n;let e=n.target;for(;e;){if(i(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"),o=(n=>{const t=c(n),e=t.lastIndexOf(".");return e<=0||e===t.length-1?null:t.slice(e+1).toLowerCase()})(f.pathname);(t||o&&e.has(o))&&(p=!0,null===(r=n.onDownload)||void 0===r||r.call(n,{url:f.href,fileName:c(f.pathname),fileExtension:null!=o?o:"",text:l(s)}))}o&&!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:l(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:o.downloadExtensions,onOutbound:o.outboundClicks?e=>t(()=>n.track("Clicked",e)):void 0,onDownload:o.downloads?e=>t(()=>n.track("File Downloaded",e)):void 0});v.push(e)}o.buttonTracking&&o.buttonTracking.rules&&o.buttonTracking.rules.length>0&&v.push(k(n,o.buttonTracking));let b=null;if(o.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=>{t(()=>n.track("Scrolled",{percent:e}))}),v.push(()=>null==b?void 0:b.destroy())),o.spa){const e=[],o=N(o=>{const r=setTimeout(()=>{const o=e.indexOf(r);-1!==o&&e.splice(o,1),t(()=>n.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,n)}if(m.dispose(),g.dispose(),b.dispose(),a.remoteConfig.enabled&&n){const t=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)};t(null!==(x=null===(w=Gt(n))||void 0===w?void 0:w.envelope)&&void 0!==x?x:null),function(n){return X(this,void 0,void 0,function*(){if(!n.projectId)return{status:"error"};const t=Gt(n.projectId);if(t&&Date.now()-t.fetchedAt<n.ttlMs)return{status:"unchanged"};const e=yield function(n){return X(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&&Zt(n.projectId,t.etag,t.envelope),{status:"unchanged"}):e.envelope?(Zt(n.projectId,e.etag,e.envelope),{status:"updated",envelope:e.envelope}):{status:"error"}:{status:"error"}})}({endpoint:a.endpoint,path:a.remoteConfig.path,projectId:n,timeoutMs:a.remoteConfig.timeoutMs,ttlMs:a.remoteConfig.ttlMs}).then(n=>{"updated"===n.status&&t(n.envelope)}).catch(()=>{})}}catch(n){}},pageview:A,page:C,screen(n,t){},track:O,identify:M,alias:S,group(n,t){},reset(){try{((n={})=>{((n,t={})=>{var e;if(!vn)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===mn(n)}catch(n){return!1}})(we,{domain:n.cookieDomain}),wn(we),wn(xe)})({cookieDomain:a.cookieDomain}),((n={})=>{ue(Cn(),n)})({cookieDomain:a.cookieDomain,cookieMaxAgeDays:a.cookieMaxAgeDays}),((n={})=>{me({id:Cn(),lastActivity:Date.now()},n)})({cookieDomain:a.cookieDomain,timeoutMinutes:a.sessionTimeoutMinutes}),n&&(n=>{wn(re(n))})(n)}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=o(f),m.dispose(),g.dispose(),b.dispose(),h=null,s&&s.destroy(),s=null,d=!1,n=null,a=Object.assign({},Ae),u=Object.assign({},Ce)}}}();function Ee(n){return $n({projectId:Ie.projectId,endpoint:Ie.endpoint,zaloQrLoginEnabled:Ie.isZaloQrLoginEnabled(),consentGranted:Ie.consentGranted,identify:Ie.identify,alias:Ie.alias,getUserId:ke},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)Oe(n,e);return e.length},e.__loaded=!0;for(const t of o)Oe(n,t)})(Ie);const Ne=Object.assign(Ie,{version:Me,name:Se,schemaVersion:se,loginWithZalo:Ee});n.NAME=Se,n.SCHEMA_VERSION=se,n.VERSION=Me,n.ZaloQrLoginError=Nn,n.default=Ne,n.loginWithZalo=Ee,Object.defineProperty(n,"t",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).cnvTrack={});
|