@cnv-vn/track 0.2.0-alpha.5 → 0.2.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @cnv-vn/track v0.2.0-alpha.5
2
+ * @cnv-vn/track v0.2.0-alpha.7
3
3
  * (c) 2026 CNV
4
4
  * Released under the UNLICENSED license.
5
5
  */
6
- const t=["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 n(t){return!!t&&"object"==typeof t&&1===t.nodeType&&"A"===t.tagName}function e(t){const n=t.lastIndexOf("/");return-1===n?t:t.slice(n+1)}function r(t){var n,e,r;let o=(null!==(n=t.textContent)&&void 0!==n?n:"").trim();return o||(o=(null!==(e=t.getAttribute("aria-label"))&&void 0!==e?e:"").trim()),o||(o=(null!==(r=t.getAttribute("title"))&&void 0!==r?r:"").trim()),o.length>200?o.slice(0,200):o}const o=200;function i(t){let n="";try{n=(t.textContent||"").replace(/\s+/g," ").trim(),n||(n=(t.getAttribute("aria-label")||"").trim()),n||(n=(t.getAttribute("title")||"").trim())}catch(t){return""}return n.length>o?n.slice(0,o):n}function c(t){const n=!1!==t.caseInsensitive;return"regex"===t.mode?{mode:"regex",needle:t.value,ci:n,re:p(t.value,n)}:{mode:t.mode,needle:n?t.value.toLowerCase():t.value,ci:n,re:null}}function u(t,n){try{return t.matches(n)}catch(t){return!1}}function s(t){try{if("A"===t.tagName){const n=t.getAttribute("href");return n?m(n):null}const n=t.getAttribute("formaction");if(n)return m(n);const e=t.getAttribute("data-href");if(e)return m(e);const r=t.closest("form");if(r){const t=r.getAttribute("action");if(t)return m(t)}return null}catch(t){return null}}function a(t){return"regex"===t.mode?{mode:"regex",needle:t.value,re:p(t.value,!0)}:{mode:t.mode,needle:t.value.toLowerCase(),re:null}}function l(t){if("startsWith"===t.mode)return{mode:"startsWith",needle:t.value,re:null};const n="glob"===t.mode?"^"+t.value.replace(/[.+^${}()|[\]\\?]/g,"\\$&").replace(/\*/g,".*")+"$":t.value;return{mode:t.mode,needle:t.value,re:p(n,!1)}}function f(t,n){return"startsWith"===t.mode?0===n.indexOf(t.needle):!t.re||b(t.re,n)}const d=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,h=/\+?\d[\d\s().-]{7,}\d/g;function y(t){if(!t)return t;try{return t.replace(d,"[email]").replace(h,"[phone]")}catch(n){return t}}function v(t){return!!t&&"object"==typeof t&&1===t.nodeType}function m(t){try{return new URL(t,location.href).href}catch(n){return t}}function p(t,n){try{return!t||t.length>1e3?null:new RegExp(t,n?"i":"")}catch(t){return null}}function b(t,n){try{return t.test(n)}catch(t){return!1}}function g(t){const n=t.match;return n.element?n.element:n.selector||n.id||n.dataAttr||n.classes&&n.classes.length>0||n.destinationUrl?"any":void 0}function w(t,n){if(!((t,n)=>{if(!n)return(t=>{const n=t.tagName;if("BUTTON"===n||"A"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")})(t);if("any"===n)return!0;if("button"===n){const n=t.tagName;if("BUTTON"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")}return"link"===n?"A"===t.tagName:u(t,n)})(n,t.elementSpec))return!1;const e=t.rule.match;return!(t.selector&&!u(n,t.selector)||void 0!==e.id&&!((t,n)=>t.id===n)(n,e.id)||e.classes&&e.classes.length>0&&!((t,n)=>{try{for(let e=0;e<n.length;e++)if(!t.classList.contains(n[e]))return!1;return!0}catch(t){return!1}})(n,e.classes)||e.dataAttr&&!((t,n,e)=>{try{return!!t.hasAttribute(n)&&(void 0===e||t.getAttribute(n)===e)}catch(t){return!1}})(n,e.dataAttr.name,e.dataAttr.value)||t.text&&!((t,n)=>{const e=i(t);if("regex"===n.mode)return!!n.re&&b(n.re,e);const r=n.ci?e.toLowerCase():e;return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.text)||t.dest&&!((t,n)=>{const e=s(t);if(!e)return!1;if("regex"===n.mode)return!!n.re&&b(n.re,e);if("domain"===n.mode)try{return new URL(e).host.toLowerCase()===n.needle}catch(t){return!1}const r=e.toLowerCase();return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.dest))}function x(t,n,e){const r={},c=t.event.staticProps;if(c)for(const t of Object.keys(c))r[t]=c[t];const u=t.capture;if(u)try{if(u.text){const t=y(i(n));t&&(r.text=t)}if(u.href){const t=s(n);t&&(r.href=t)}if(u.elementId&&n.id&&(r.element_id=n.id),u.classes&&(r.element_classes=Array.from(n.classList)),u.dataAttrs&&u.dataAttrs.length>0)for(let t=0;t<u.dataAttrs.length;t++){const e=u.dataAttrs[t],o=n.getAttribute(e);null!==o&&(r[e]=y(o))}if(u.valueFrom){const t=((t,n)=>{try{const e=t.querySelector(n.selector)||(t.parentElement?t.parentElement.querySelector(n.selector):null);if(!e)return null;const r=n.attr?e.getAttribute(n.attr):e.textContent||"";if(null===r)return null;const i=y(r.replace(/\s+/g," ").trim());return i.length>o?i.slice(0,o):i}catch(t){return null}})(n,u.valueFrom);null!==t&&(r[u.valueFrom.as]=t)}u.selectorPath&&(r.selector_path=((t,n=5)=>{try{const e=[];let r=t,o=0;for(;r&&1===r.nodeType&&o<n;){let t=r.tagName.toLowerCase();if(r.id){e.unshift(t+"#"+r.id);break}const n=Array.from(r.classList).slice(0,2).join(".");n&&(t+="."+n),e.unshift(t),r=r.parentElement,o++}return e.join(" > ")}catch(t){return""}})(n)),u.position&&(r.x=e.clientX,r.y=e.clientY)}catch(t){}return r.rule_id=t.id,t.name&&(r.rule_name=t.name),r.tag=n.tagName.toLowerCase(),r}function k(t){try{t()}catch(t){}}function j(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}function O(t,n){return"number"!=typeof t||isNaN(t)?n:t}function A(t){return t<0?0:t>1?1:t}const S="__cnvPatched";function _(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}const P=["q","s","query","search","keyword"],I={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},D={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};function T(t){try{t()}catch(t){}}const U=["gclid","fbclid","ttclid","msclkid","dclid"],M=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function $(t,n){try{return t()}catch(t){return n}}function R(){const t=$(()=>window.location.href,"");let n="",e="",r="";if(t)try{const o=new URL(t);n=o.pathname,e=o.search,r=o.hash}catch(t){}return{url:t,path:n,search:e,hash:r,title:$(()=>document.title,""),referrer:$(()=>document.referrer,"")}}function C(t){var n,e;let r="@cnv-vn/track",o="0.0.0-dev";try{r="@cnv-vn/track"}catch(t){}try{o="0.2.0-alpha.5"}catch(t){}return{name:null!==(n=null==t?void 0:t.name)&&void 0!==n?n:r,version:null!==(e=null==t?void 0:t.version)&&void 0!==e?e:o}}const L="0123456789abcdef";function N(t){return L[t>>>4&15]+L[15&t]}function q(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues){const t=new Uint8Array(16);return crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128,N(t[0])+N(t[1])+N(t[2])+N(t[3])+"-"+N(t[4])+N(t[5])+"-"+N(t[6])+N(t[7])+"-"+N(t[8])+N(t[9])+"-"+N(t[10])+N(t[11])+N(t[12])+N(t[13])+N(t[14])+N(t[15])}}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=16*Math.random()|0;return("x"===t?n:3&n|8).toString(16)})}const B=/^[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 z(t){return"string"==typeof t&&B.test(t)}const W="undefined"!=typeof window&&"undefined"!=typeof document;function J(t){if(!W)return null;try{const n=document.cookie;if(!n)return null;const e=encodeURIComponent(t),r=n.split(";");for(let n=0;n<r.length;n++){const o=r[n].indexOf("=");if(o<0)continue;const i=r[n].slice(0,o).trim();if(i===e||i===t)try{return decodeURIComponent(r[n].slice(o+1))}catch(t){return r[n].slice(o+1)}}return null}catch(t){return null}}function E(t,n,e={}){var r,o,i;if(!W)return!1;try{let c=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(c+=`; path=${null!==(r=e.path)&&void 0!==r?r:"/"}`,e.domain&&(c+=`; domain=${e.domain}`),"number"==typeof e.maxAgeDays){const t=Math.floor(86400*e.maxAgeDays);c+=`; max-age=${t}`,c+=`; expires=${new Date(Date.now()+1e3*t).toUTCString()}`}return c+=`; SameSite=${null!==(o=e.sameSite)&&void 0!==o?o:"Lax"}`,(null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol)&&(c+="; Secure"),document.cookie=c,J(t)===n}catch(t){return!1}}function V(){if(!W)return!1;try{const t="__cnv_probe__";return localStorage.setItem(t,"1"),localStorage.removeItem(t),!0}catch(t){return!1}}function H(t){if(!V())return null;try{return localStorage.getItem(t)}catch(t){return null}}function Z(t,n){if(!V())return!1;try{return localStorage.setItem(t,n),!0}catch(t){return!1}}function F(t){if(!V())return!1;try{return localStorage.removeItem(t),!0}catch(t){return!1}}function G(){if(!W)return!1;try{const t="__cnv_probe__";return sessionStorage.setItem(t,"1"),sessionStorage.removeItem(t),!0}catch(t){return!1}}const K="_cnv_cid";function Q(t={}){const n=J(K),e=H(K);let r=null;return z(n)?r=n:z(e)&&(r=e),r||(r=q()),X(r,t),r}function X(t,n={}){var e;E(K,t,{domain:n.cookieDomain,maxAgeDays:null!==(e=n.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),Z(K,t)}const Y="1.0";function tt(){return(new Date).toISOString()}function nt(t,n){var e;const r=null!==(e=n.timestamp)&&void 0!==e?e:tt(),o=Object.assign(Object.assign({},n.context),{projectId:n.projectId,schemaVersion:Y}),i={type:t,messageId:q(),anonymousId:n.anonymousId,timestamp:r,originalTimestamp:r,context:o};return n.userId&&(i.userId=n.userId),n.sessionId&&(i.sessionId=n.sessionId),n.integrations&&(i.integrations=n.integrations),i}const et="_cnv_sid";function rt(t){if(!t)return null;const n=t.lastIndexOf(".");if(n<0)return null;const e=t.slice(0,n),r=Number(t.slice(n+1));return!z(e)||!Number.isFinite(r)||r<=0?null:{id:e,lastActivity:r}}function ot(t={}){const n=Date.now(),e=(t=>{var n;return 6e4*(null!==(n=t.timeoutMinutes)&&void 0!==n?n:30)})(t),r=rt(J(et)),o=rt((t=>{if(!G())return null;try{return sessionStorage.getItem(t)}catch(t){return null}})(et));let i=null;for(const t of[r,o])t&&(n-t.lastActivity>e||(!i||t.lastActivity>i.lastActivity)&&(i=t));const c=i?{id:i.id,lastActivity:n}:{id:q(),lastActivity:n};return it(c,t),c.id}function it(t,n={}){var e;const r=(t=>`${t.id}.${t.lastActivity}`)(t),o=null!==(e=n.timeoutMinutes)&&void 0!==e?e:30;E(et,r,{domain:n.cookieDomain,maxAgeDays:o/1440,sameSite:"Lax"}),((t,n)=>{if(!G())return!1;try{return sessionStorage.setItem(t,n),!0}catch(t){return!1}})(et,r)}class ct{constructor(t){var n,e;Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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!==(n=t.storageKey)&&void 0!==n?n:"_cnv_rq",this.maxMessages=null!==(e=t.maxMessages)&&void 0!==e?e:100,this.installOnlineListener()}stash(t){if(t&&0!==t.length)try{const n=this.read();for(n.push(t);n.length>1&&ut(n)>this.maxMessages;)n.shift();this.write(n),this.config.debug&&console.log("[cnv-track] retry queued",t.length,"buffered",ut(n))}catch(t){}}flush(){if(this.flushing||"undefined"!=typeof navigator&&!1===navigator.onLine)return Promise.resolve();const t=this.read();if(0===t.length)return Promise.resolve();this.flushing=!0,this.write([]);const n=()=>{this.flushing=!1};return t.reduce((t,n)=>t.then(()=>this.config.resend(n)),Promise.resolve()).then(n,n)}size(){return ut(this.read())}clear(){try{F(this.storageKey)}catch(t){}}destroy(){if(this.onlineHandler){try{window.removeEventListener("online",this.onlineHandler)}catch(t){}this.onlineHandler=null}}installOnlineListener(){if("undefined"==typeof window)return;const t=()=>{this.flush()};try{window.addEventListener("online",t),this.onlineHandler=t}catch(t){}}read(){const t=H(this.storageKey);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(t=>Array.isArray(t)&&t.length>0):[]}catch(t){return[]}}write(t){0!==t.length?Z(this.storageKey,JSON.stringify(t)):F(this.storageKey)}}function ut(t){let n=0;for(const e of t)n+=e.length;return n}class st{constructor(t){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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 ct({debug:t.debug,resend:t=>this.send(t)}),this.installPageLifecycleHandlers(),this.retryQueue.flush()}setConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}enqueue(t){this.destroyed||(this.buffer.push(t),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 t=this.buffer;return this.buffer=[],this.send(t)}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(t){try{return this.config.useBatch?this.sendBatch(t):Promise.all(t.map(t=>this.sendSingle(t))).then(()=>{})}catch(t){return this.config.debug&&console.warn("[cnv-track] send failed synchronously; dropped batch",t),Promise.resolve()}}sendBatch(t){var n;const e=tt(),r={batch:t.map(t=>at(t,e)),context:Object.assign(Object.assign({},null!==(n=this.config.batchContext)&&void 0!==n?n:{}),{projectId:this.config.projectId,sentAt:e}),sentAt:e};return this.post(this.batchUrl(),r,t)}sendSingle(t){const n=at(t,tt());return this.post(this.singleUrl(t.type),n,[t])}batchUrl(){return this.config.endpoint+this.config.batchPath+"?projectId="+encodeURIComponent(this.config.projectId)}singleUrl(t){const n=this.config.singlePath.replace("{type}",t);return this.config.endpoint+n+"?projectId="+encodeURIComponent(this.config.projectId)}post(t,n,e){const r=JSON.stringify(n),o=((t,n)=>{try{return new Blob([t],{type:n})}catch(t){return null}})(r,this.config.contentType),i=o?o.size:(t=>{try{return new Blob([t]).size}catch(n){return t.length}})(r),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",t),Promise.resolve()):o&&this.sendViaBeacon(t,o)?(this.config.debug&&console.log("[cnv-track] beacon",t),Promise.resolve()):this.sendViaFetch(t,r,c)}sendViaBeacon(t,n){if("undefined"==typeof navigator||"function"!=typeof navigator.sendBeacon)return!1;if(n.size>65536)return!1;try{return navigator.sendBeacon(t,n)}catch(t){return!1}}sendViaFetch(t,n,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(t,{method:"POST",headers:{"Content-Type":this.config.contentType},body:n,keepalive:!0,credentials:"omit",mode:"cors"}).then(n=>{this.config.debug&&console.log("[cnv-track] fetch flushed",t,n.status)}).catch(n=>{this.config.debug&&console.warn("[cnv-track] flush failed; queued for retry",t,n),e&&this.retryQueue.stash(e)})}installPageLifecycleHandlers(){if("undefined"==typeof window||"undefined"==typeof document)return;const t=()=>{this.flush()},n=()=>{"hidden"===document.visibilityState&&this.flush()};try{window.addEventListener("pagehide",t),document.addEventListener("visibilitychange",n),this.handlers={pagehide:t,visibility:n}}catch(t){}}uninstallPageLifecycleHandlers(){if(this.handlers){try{window.removeEventListener("pagehide",this.handlers.pagehide),document.removeEventListener("visibilitychange",this.handlers.visibility)}catch(t){}this.handlers=null}}}function at(t,n){return Object.assign(Object.assign({},t),{sentAt:n})}const lt="_cnv_uid",ft="_cnv_traits",dt={endpoint:"http://localhost:8090/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:{}},ht={analytics:!0,marketing:!0};function yt(t,n){if(!Array.isArray(n)||0===n.length)return;const e=n;try{switch(e[0]){case"init":t.init(e[1],e[2]);break;case"pageview":t.pageview(e[1],e[2]);break;case"page":t.page(e[1],e[2]);break;case"screen":t.screen(e[1],e[2]);break;case"track":t.track(e[1],e[2]);break;case"identify":t.identify(e[1],e[2]);break;case"alias":t.alias(e[1],e[2]);break;case"group":t.group(e[1],e[2]);break;case"reset":t.reset();break;case"flush":t.flush();break;case"consent":t.consent(e[1]);break;case"set":t.set(e[1])}}catch(t){}}const vt="0.2.0-alpha.5",mt="@cnv-vn/track",pt=(()=>{let o=null,i=Object.assign({},dt),u=Object.assign({},ht),s=null,d=!1,h=null;function y(t){const n=Object.assign({},i);return t?(void 0!==t.endpoint&&(n.endpoint=(e=t.endpoint).endsWith("/")?e.slice(0,-1):e),void 0!==t.batchPath&&(n.batchPath=t.batchPath),void 0!==t.singlePath&&(n.singlePath=t.singlePath),void 0!==t.useBatch&&(n.useBatch=t.useBatch),void 0!==t.contentType&&(n.contentType=t.contentType),void 0!==t.debug&&(n.debug=t.debug),void 0!==t.allowAdTracking&&(n.allowAdTracking=t.allowAdTracking),void 0!==t.cookieDomain&&(n.cookieDomain=t.cookieDomain),void 0!==t.cookieMaxAgeDays&&(n.cookieMaxAgeDays=t.cookieMaxAgeDays),void 0!==t.sessionTimeoutMinutes&&(n.sessionTimeoutMinutes=t.sessionTimeoutMinutes),void 0!==t.flushAt&&(n.flushAt=t.flushAt),void 0!==t.flushInterval&&(n.flushInterval=t.flushInterval),void 0!==t.autoPageview&&(n.autoPageview=t.autoPageview),void 0!==t.autotrack&&(n.autotrack=t.autotrack),void 0!==t.integrations&&(n.integrations=t.integrations),n):n;var e}function m(){return s||(s=new st({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,projectId:null!=o?o:"",debug:i.debug}),s)}function p(){var t;if(!o)return null;const n=((t={})=>{var n;const e={page:R(),screen:{width:$(()=>window.screen.width,0),height:$(()=>window.screen.height,0),density:$(()=>window.devicePixelRatio||1,1)},locale:$(()=>navigator.language||"",""),timezone:$(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:$(()=>navigator.userAgent||"",""),library:C(t.library)},r=((t,n=!0)=>{const e=$(()=>window.location.search,"");if(!e)return;let r;try{r=new URLSearchParams(e)}catch(t){return}const o={};let i=!1;for(const[t,n]of M){const e=r.get(t);e&&e.length>0&&(o[n]=e,i=!0)}if(n){const t={};for(const n of U){const e=r.get(n);e&&e.length>0&&(t[n]=e)}Object.keys(t).length>0&&(o.clickIds=t,i=!0)}return i?o:void 0})(0,null===(n=t.allowAdTracking)||void 0===n||n);return r&&(e.campaign=r),e})({allowAdTracking:i.allowAdTracking});return u.analytics&&u.marketing||(n.consent=Object.assign({},u)),{anonymousId:Q({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),sessionId:ot({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),userId:null!==(t=J(lt)||H(lt))&&void 0!==t?t:void 0,context:n,projectId:o,integrations:Object.keys(i.integrations).length>0?i.integrations:void 0}}function b(t){i.debug&&console.warn(`[cnv-track] ${t}() called before init()`)}function L(t,n){try{const e=p();if(!e)return b("pageview");const r=((t,n,e)=>{const r=nt("page",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(null!=t?t:(()=>{try{return"undefined"!=typeof document&&document.title||void 0}catch(t){return}})(),n,e);m().enqueue(r)}catch(t){}}function N(t,n){L(t,n)}function B(t,n){try{if("string"!=typeof t||0===t.length)return;const e=p();if(!e)return b("track");const r=((t,n,e)=>{const r=nt("track",e);return r.event=t,r.properties=null!=n?n:{},r})(t,n,e);m().enqueue(r)}catch(t){}}return{get initialized(){return d},get projectId(){return o},init(p,b){try{if(!p||"string"!=typeof p)return;if(i=y(b),(null==b?void 0:b.consent)&&(u=Object.assign(Object.assign({},u),b.consent)),o=p,s&&s.destroy(),s=null,m(),d=!0,Q({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),ot({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),i.autoPageview&&L(),h){try{h()}catch(t){}h=null}i.autotrack&&(h=function(o,i){const u=void 0===(s=i)||!1===s?Object.assign(Object.assign({},D),{searchParams:P}):!0===s?Object.assign(Object.assign({},I),{searchParams:P}):{spa:null===(d=s.spa)||void 0===d||d,outboundClicks:null===(h=s.outboundClicks)||void 0===h||h,scroll:null===(y=s.scroll)||void 0===y||y,downloads:null===(m=s.downloads)||void 0===m||m,siteSearch:null===(p=s.siteSearch)||void 0===p||p,downloadExtensions:s.downloadExtensions,searchParams:null!==(b=s.searchParams)&&void 0!==b?b:P,buttonTracking:s.buttonTracking};var s,d,h,y,m,p,b;const U=[];let M=null;function $(t){if(u.siteSearch)try{const n=null!=t?t:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(t){return""}})();if(n===M)return;M=n;const e=((t,n=P)=>{try{if(!t){if("undefined"==typeof location)return null;t=location.href}const e=t instanceof URL?t:new URL(t,(()=>{try{return"undefined"!=typeof location?location.href:"http://localhost/"}catch(t){return"http://localhost/"}})());if(!e.search)return null;for(const t of n){const n=e.searchParams.get(t);if(null===n)continue;const r=n.trim();if(0!==r.length)return{query:r,param:t}}return null}catch(t){return null}})(n,u.searchParams);e&&T(()=>o.track("Site Searched",{query:e.query,param:e.param}))}catch(t){}}if(u.outboundClicks||u.downloads){const i=(o=>{var i;if("undefined"==typeof document)return()=>{};const c=new Set((null!==(i=o.downloadExtensions)&&void 0!==i?i:t).map(t=>t.toLowerCase())),u=!!o.onOutbound,s=!!o.onDownload;if(!u&&!s)return()=>{};function a(t){var i,a;try{if(0!==t.button)return;if(t.defaultPrevented)return;const l=(t=>{const e="function"==typeof t.composedPath?t.composedPath():[];if(e.length>0)for(const t of e)if(n(t))return t;let r=t.target;for(;r;){if(n(r))return r;r=r.parentNode}return null})(t);if(!l)return;const f=l.getAttribute("href");if(!f)return;if(/^(javascript:|mailto:|tel:|sms:)/i.test(f))return;if(f.startsWith("#"))return;const d=(t=>{try{return new URL(t,location.href)}catch(t){return null}})(f);if(!d)return;let h=!1;if(s){const t=l.hasAttribute("download"),n=(t=>{const n=e(t),r=n.lastIndexOf(".");return r<=0||r===n.length-1?null:n.slice(r+1).toLowerCase()})(d.pathname);(t||n&&c.has(n))&&(h=!0,null===(i=o.onDownload)||void 0===i||i.call(o,{url:d.href,fileName:e(d.pathname),fileExtension:null!=n?n:"",text:r(l)}))}u&&!h&&d.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(t){return""}})()&&d.host&&(null===(a=o.onOutbound)||void 0===a||a.call(o,{url:d.href,host:d.host,text:r(l),target:l.target||"_self"}))}catch(t){}}try{document.addEventListener("click",a,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",a,!0)}catch(t){}}})({downloadExtensions:u.downloadExtensions,onOutbound:u.outboundClicks?t=>T(()=>o.track("Outbound Link Clicked",t)):void 0,onDownload:u.downloads?t=>T(()=>o.track("File Downloaded",t)):void 0});U.push(i)}u.buttonTracking&&u.buttonTracking.rules&&u.buttonTracking.rules.length>0&&U.push(((t,n)=>{if("undefined"==typeof document)return()=>{};const e=(t=>{const n=t.globalThrottle||{},e=[],r=t.rules||[];for(let t=0;t<r.length;t++){const o=r[t];if(!o||!1===o.enabled)continue;if(!o.match||!o.event||!o.event.name)continue;const i=o.match,u=o.throttle||{};e.push({rule:o,elementSpec:g(o),selector:i.selector||null,text:i.text?c(i.text):null,dest:i.destinationUrl?a(i.destinationUrl):null,urlScope:o.urlScope?l(o.urlScope):null,dedupeWindowMs:O(u.dedupeWindowMs,O(n.dedupeWindowMs,500)),maxPerPageview:O(u.maxPerPageview,O(n.maxPerPageview,1/0)),samplingRate:A(O(u.samplingRate,O(n.samplingRate,1)))})}return e.sort((t,n)=>(t.rule.priority||0)-(n.rule.priority||0)),e})(n);if(0===e.length)return()=>{};const r=new WeakMap;let o=0;const i=t=>{let n=r.get(t);return void 0===n&&(n=++o,r.set(t,n)),String(n)},u=new Map,s=new Map;let d=j();function h(n){try{if(0!==n.button)return;const r=j();r!==d&&(d=r,s.clear(),u.clear());const o=(t=>{const n=[];try{const e="function"==typeof t.composedPath?t.composedPath():[];if(e&&e.length>0){for(const t of e)v(t)&&n.push(t);return n}let r=t.target;for(;r;)v(r)&&n.push(r),r=r.parentNode}catch(t){}return n})(n);if(0===o.length)return;const c=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(t){return""}})();for(let r=0;r<e.length;r++){const a=e[r];if(a.urlScope&&!f(a.urlScope,c))continue;let l=null;for(let t=0;t<o.length;t++)if(w(a,o[t])){l=o[t];break}if(!l)continue;const d=a.rule.id;if((s.get(d)||0)>=a.maxPerPageview)return;const h=d+"#"+i(l),y=Date.now(),v=u.get(h);if(void 0!==v&&y-v<a.dedupeWindowMs)return;if(a.samplingRate<1&&Math.random()>=a.samplingRate)return;u.set(h,y),s.set(d,(s.get(d)||0)+1);const m=a.rule.event.name||"Button Clicked",p=x(a.rule,l,n);return void k(()=>t.track(m,p))}}catch(t){}}try{document.addEventListener("click",h,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",h,!0)}catch(t){}u.clear(),s.clear()}})(o,u.buttonTracking));let R=null;if(u.scroll&&(R=(t=>{if("undefined"==typeof window||"undefined"==typeof document)return{destroy(){},reset(){}};let n=!1,e=null,r=!1;function o(){if(e=null,!r&&!n)try{const e=document.documentElement,r=document.body,o=Math.max(e?e.scrollHeight:0,r?r.scrollHeight:0),i=Math.max(e?e.clientHeight:0,window.innerHeight||0);if(o<=i)return n=!0,c(),void t(90);((window.scrollY||(e?e.scrollTop:0)||0)+i)/o>=.9&&(n=!0,c(),t(90))}catch(t){}}function i(){if(null===e)try{e=window.requestAnimationFrame(o)}catch(t){o()}}function c(){try{window.removeEventListener("scroll",i),null!==e&&window.cancelAnimationFrame(e),e=null}catch(t){}}try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}return{destroy(){r=!0,c()},reset(){if(!r){n=!1;try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}}}}})(t=>{T(()=>o.track("Scrolled",{percent:t}))}),U.push(()=>null==R?void 0:R.destroy())),u.spa){const t=function(){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let t=_();function n(){try{const n=_();if(n===t)return;t=n,(t=>{T(()=>o.page()),null==R||R.reset(),$(t)})(n)}catch(t){}}const e=history.pushState,r=history.replaceState,i=!0===e[S],c=!0===r[S];if(!i){function a(...t){e.apply(this,t),n()}a[S]=!0,history.pushState=a}if(!c){function l(...t){r.apply(this,t),n()}l[S]=!0,history.replaceState=l}const u=()=>n(),s=()=>n();try{window.addEventListener("popstate",u),window.addEventListener("hashchange",s)}catch(f){}return()=>{try{window.removeEventListener("popstate",u),window.removeEventListener("hashchange",s)}catch(t){}try{!i&&history.pushState[S]&&(history.pushState=e),!c&&history.replaceState[S]&&(history.replaceState=r)}catch(t){}}}();U.push(t)}return $(),()=>{for(;U.length>0;){const t=U.pop();try{null==t||t()}catch(t){}}M=null}}({page(t,n){return N(t,n)},track(t,n){return B(t,n)}},i.autotrack))}catch(t){}},pageview:L,page:N,screen(t,n){try{const e=p();if(!e)return b("screen");const r=((t,n,e)=>{const r=nt("screen",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(t,n,e);m().enqueue(r)}catch(t){}},track:B,identify(t,n){try{if("string"!=typeof t||0===t.length)return;((t,n,e={})=>{var r,o;if(t&&(E(lt,t,{domain:e.cookieDomain,maxAgeDays:null!==(r=e.cookieMaxAgeDays)&&void 0!==r?r:730,sameSite:"Lax"}),Z(lt,t),null!=n)){const t=null!==(o=(()=>{const t=H(ft);if(!t)return null;try{const n=JSON.parse(t);return n&&"object"==typeof n&&!Array.isArray(n)?n:null}catch(t){return null}})())&&void 0!==o?o:{},e=Object.assign(Object.assign({},t),n);try{Z(ft,JSON.stringify(e))}catch(t){}}})(t,n,{cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays});const e=p();if(!e)return b("identify");const r=((t,n,e)=>{var r;const o=nt("identify",e);return t&&(o.userId=t),o.traits=null!==(r=n)&&void 0!==r?r:{},o})(t,n,e);m().enqueue(r)}catch(t){}},alias(t,n){try{if("string"!=typeof t||0===t.length)return;const e=p();if(!e)return b("alias");const r=((t,n,e)=>{const r=nt("alias",e);return t&&(r.userId=t),r.previousId=null!=n?n:e.anonymousId,r})(t,n,e);m().enqueue(r)}catch(t){}},group(t,n){try{if("string"!=typeof t||0===t.length)return;const e=p();if(!e)return b("group");const r=((t,n,e)=>{const r=nt("group",e);return r.groupId=t,r.traits=null!=n?n:{},r})(t,n,e);m().enqueue(r)}catch(t){}},reset(){try{((t={})=>{((t,n={})=>{var e;if(!W)return!1;try{let r=`${encodeURIComponent(t)}=`;return r+=`; path=${null!==(e=n.path)&&void 0!==e?e:"/"}`,n.domain&&(r+=`; domain=${n.domain}`),r+="; max-age=0",r+="; expires=Thu, 01 Jan 1970 00:00:00 GMT",document.cookie=r,null===J(t)}catch(t){return!1}})(lt,{domain:t.cookieDomain}),F(lt),F(ft)})({cookieDomain:i.cookieDomain}),((t={})=>{X(q(),t)})({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),((t={})=>{it({id:q(),lastActivity:Date.now()},t)})({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes})}catch(t){}},flush(){try{s&&s.flush()}catch(t){}},consent(t){try{u=Object.assign(Object.assign({},u),t)}catch(t){}},set(t){try{i=y(t),t.consent&&(u=Object.assign(Object.assign({},u),t.consent)),s&&s.setConfig({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,debug:i.debug})}catch(t){}},destroy(){if(h){try{h()}catch(t){}h=null}s&&s.destroy(),s=null,d=!1,o=null,i=Object.assign({},dt),u=Object.assign({},ht)}}})();"undefined"!=typeof window&&(t=>{if("undefined"==typeof window)return()=>{};const n=window.cnvQ;if(n&&n.__loaded)return()=>{};const e=window.cnvQ=null!=n?n:[],r=e.splice(0,e.length);e.push.bind(e),e.push=(...n)=>{for(const e of n)yt(t,e);return e.length},e.__loaded=!0;for(const n of r)yt(t,n)})(pt);const bt=Object.assign(pt,{version:vt,name:mt,schemaVersion:Y});export{mt as NAME,Y as SCHEMA_VERSION,vt as VERSION,bt as default};
6
+ const t=["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 n(t){return!!t&&"object"==typeof t&&1===t.nodeType&&"A"===t.tagName}function e(t){const n=t.lastIndexOf("/");return-1===n?t:t.slice(n+1)}function r(t){var n,e,r;let o=(null!==(n=t.textContent)&&void 0!==n?n:"").trim();return o||(o=(null!==(e=t.getAttribute("aria-label"))&&void 0!==e?e:"").trim()),o||(o=(null!==(r=t.getAttribute("title"))&&void 0!==r?r:"").trim()),o.length>200?o.slice(0,200):o}const o=200;function i(t){let n="";try{n=(t.textContent||"").replace(/\s+/g," ").trim(),n||(n=(t.getAttribute("aria-label")||"").trim()),n||(n=(t.getAttribute("title")||"").trim()),n=n.normalize("NFC")}catch(t){return""}return n.length>o?n.slice(0,o):n}function c(t){const n=!1!==t.caseInsensitive;if("regex"===t.mode)return{mode:"regex",needle:t.value,ci:n,re:b(t.value,n)};const e=t.value.normalize("NFC");return{mode:t.mode,needle:n?e.toLowerCase():e,ci:n,re:null}}function u(t,n){try{return t.matches(n)}catch(t){return!1}}function l(t){try{if("A"===t.tagName){const n=t.getAttribute("href");return n?p(n):null}const n=t.getAttribute("formaction");if(n)return p(n);const e=t.getAttribute("data-href");if(e)return p(e);const r=t.closest("form");if(r){const t=r.getAttribute("action");if(t)return p(t)}return null}catch(t){return null}}function s(t){return"regex"===t.mode?{mode:"regex",needle:t.value,re:b(t.value,!0)}:{mode:t.mode,needle:t.value.toLowerCase(),re:null}}function a(t){if("startsWith"===t.mode)return{mode:"startsWith",needle:t.value,re:null};const n="glob"===t.mode?"^"+t.value.replace(/[.+^${}()|[\]\\?]/g,"\\$&").replace(/\*/g,".*")+"$":t.value;return{mode:t.mode,needle:t.value,re:b(n,!1)}}function f(t,n){return"startsWith"===t.mode?0===n.indexOf(t.needle):!t.re||m(t.re,n)}const d=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,h=/\+?\d[\d\s().-]{7,}\d/g;function y(t){if(!t)return t;try{return t.replace(d,"[email]").replace(h,"[phone]")}catch(n){return t}}function v(t){return!!t&&"object"==typeof t&&1===t.nodeType}function p(t){try{return new URL(t,location.href).href}catch(n){return t}}function b(t,n){try{return!t||t.length>1e3?null:new RegExp(t,n?"i":"")}catch(t){return null}}function m(t,n){try{return t.test(n)}catch(t){return!1}}function g(t,n){if("undefined"==typeof document)return()=>{};const e=(t=>{const n=t.globalThrottle||{},e=[],r=t.rules||[];for(let t=0;t<r.length;t++){const o=r[t];if(!o||!1===o.enabled)continue;if(!o.match||!o.event||!o.event.name)continue;const i=o.match,u=o.throttle||{};e.push({rule:o,elementSpec:w(o),selector:i.selector||null,text:i.text?c(i.text):null,dest:i.destinationUrl?s(i.destinationUrl):null,urlScope:o.urlScope?a(o.urlScope):null,dedupeWindowMs:A(u.dedupeWindowMs,A(n.dedupeWindowMs,500)),maxPerPageview:A(u.maxPerPageview,A(n.maxPerPageview,1/0)),samplingRate:S(A(u.samplingRate,A(n.samplingRate,1)))})}return e.sort((t,n)=>(t.rule.priority||0)-(n.rule.priority||0)),e})(n);if(0===e.length)return()=>{};const r=new WeakMap;let o=0;const i=t=>{let n=r.get(t);return void 0===n&&(n=++o,r.set(t,n)),String(n)},u=new Map,l=new Map;let d=O();function h(n){try{if(0!==n.button)return;const r=O();r!==d&&(d=r,l.clear(),u.clear());const o=(t=>{const n=[];try{const e="function"==typeof t.composedPath?t.composedPath():[];if(e&&e.length>0){for(const t of e)v(t)&&n.push(t);return n}let r=t.target;for(;r;)v(r)&&n.push(r),r=r.parentNode}catch(t){}return n})(n);if(0===o.length)return;const c=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(t){return""}})();for(let r=0;r<e.length;r++){const s=e[r];if(s.urlScope&&!f(s.urlScope,c))continue;let a=null;for(let t=0;t<o.length;t++)if(x(s,o[t])){a=o[t];break}if(!a)continue;const d=s.rule.id;if((l.get(d)||0)>=s.maxPerPageview)return;const h=d+"#"+i(a),y=Date.now(),v=u.get(h);if(void 0!==v&&y-v<s.dedupeWindowMs)return;if(s.samplingRate<1&&Math.random()>=s.samplingRate)return;u.set(h,y),l.set(d,(l.get(d)||0)+1);const p=s.rule.event.name||"Button Clicked",b=j(s.rule,a,n);return void k(()=>t.track(p,b))}}catch(t){}}try{document.addEventListener("click",h,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",h,!0)}catch(t){}u.clear(),l.clear()}}function w(t){const n=t.match;return n.element?n.element:n.selector||n.id||n.dataAttr||n.classes&&n.classes.length>0||n.destinationUrl?"any":void 0}function x(t,n){if(!((t,n)=>{if(!n)return(t=>{const n=t.tagName;if("BUTTON"===n||"A"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")})(t);if("any"===n)return!0;if("button"===n){const n=t.tagName;if("BUTTON"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")}return"link"===n?"A"===t.tagName:u(t,n)})(n,t.elementSpec))return!1;const e=t.rule.match;return!(t.selector&&!u(n,t.selector)||void 0!==e.id&&!((t,n)=>t.id===n)(n,e.id)||e.classes&&e.classes.length>0&&!((t,n)=>{try{for(let e=0;e<n.length;e++)if(!t.classList.contains(n[e]))return!1;return!0}catch(t){return!1}})(n,e.classes)||e.dataAttr&&!((t,n,e)=>{try{return!!t.hasAttribute(n)&&(void 0===e||t.getAttribute(n)===e)}catch(t){return!1}})(n,e.dataAttr.name,e.dataAttr.value)||t.text&&!((t,n)=>{const e=i(t);if("regex"===n.mode)return!!n.re&&m(n.re,e);const r=n.ci?e.toLowerCase():e;return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.text)||t.dest&&!((t,n)=>{const e=l(t);if(!e)return!1;if("regex"===n.mode)return!!n.re&&m(n.re,e);if("domain"===n.mode)try{return new URL(e).host.toLowerCase()===n.needle}catch(t){return!1}const r=e.toLowerCase();return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.dest))}function j(t,n,e){const r={},c=t.event.staticProps;if(c)for(const t of Object.keys(c))r[t]=c[t];const u=t.capture;if(u)try{if(u.text){const t=y(i(n));t&&(r.text=t)}if(u.href){const t=l(n);t&&(r.href=t)}if(u.elementId&&n.id&&(r.element_id=n.id),u.classes&&(r.element_classes=Array.from(n.classList)),u.dataAttrs&&u.dataAttrs.length>0)for(let t=0;t<u.dataAttrs.length;t++){const e=u.dataAttrs[t],o=n.getAttribute(e);null!==o&&(r[e]=y(o))}if(u.valueFrom){const t=((t,n)=>{try{const e=t.querySelector(n.selector)||(t.parentElement?t.parentElement.querySelector(n.selector):null);if(!e)return null;const r=n.attr?e.getAttribute(n.attr):e.textContent||"";if(null===r)return null;const i=y(r.replace(/\s+/g," ").trim());return i.length>o?i.slice(0,o):i}catch(t){return null}})(n,u.valueFrom);null!==t&&(r[u.valueFrom.as]=t)}u.selectorPath&&(r.selector_path=((t,n=5)=>{try{const e=[];let r=t,o=0;for(;r&&1===r.nodeType&&o<n;){let t=r.tagName.toLowerCase();if(r.id){e.unshift(t+"#"+r.id);break}const n=Array.from(r.classList).slice(0,2).join(".");n&&(t+="."+n),e.unshift(t),r=r.parentElement,o++}return e.join(" > ")}catch(t){return""}})(n)),u.position&&(r.x=e.clientX,r.y=e.clientY)}catch(t){}return r.rule_id=t.id,t.name&&(r.rule_name=t.name),r.tag=n.tagName.toLowerCase(),r}function k(t){try{t()}catch(t){}}function O(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}function A(t,n){return"number"!=typeof t||isNaN(t)?n:t}function S(t){return t<0?0:t>1?1:t}const _="__cnvPatched";function T(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}const I=["q","s","query","search","keyword"],M={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},P={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};function D(t){try{t()}catch(t){}}function U(t,n,e,r){return new(e||(e=Promise))((o,i)=>{function c(t){try{l(r.next(t))}catch(t){i(t)}}function u(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(t=>{t(n)})).then(c,u)}l((r=r.apply(t,n||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const C="undefined"!=typeof window&&"undefined"!=typeof document;function N(t){if(!C)return null;try{const n=document.cookie;if(!n)return null;const e=encodeURIComponent(t),r=n.split(";");for(let n=0;n<r.length;n++){const o=r[n].indexOf("=");if(o<0)continue;const i=r[n].slice(0,o).trim();if(i===e||i===t)try{return decodeURIComponent(r[n].slice(o+1))}catch(t){return r[n].slice(o+1)}}return null}catch(t){return null}}function R(t,n,e={}){var r,o,i;if(!C)return!1;try{let c=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(c+=`; path=${null!==(r=e.path)&&void 0!==r?r:"/"}`,e.domain&&(c+=`; domain=${e.domain}`),"number"==typeof e.maxAgeDays){const t=Math.floor(86400*e.maxAgeDays);c+=`; max-age=${t}`,c+=`; expires=${new Date(Date.now()+1e3*t).toUTCString()}`}return c+=`; SameSite=${null!==(o=e.sameSite)&&void 0!==o?o:"Lax"}`,(null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol)&&(c+="; Secure"),document.cookie=c,N(t)===n}catch(t){return!1}}function $(){if(!C)return!1;try{const t="__cnv_probe__";return localStorage.setItem(t,"1"),localStorage.removeItem(t),!0}catch(t){return!1}}function L(t){if(!$())return null;try{return localStorage.getItem(t)}catch(t){return null}}function q(t,n){if(!$())return!1;try{return localStorage.setItem(t,n),!0}catch(t){return!1}}function B(t){if(!$())return!1;try{return localStorage.removeItem(t),!0}catch(t){return!1}}function z(){if(!C)return!1;try{const t="__cnv_probe__";return sessionStorage.setItem(t,"1"),sessionStorage.removeItem(t),!0}catch(t){return!1}}const E={path:"/config",timeoutMs:4e3,ttlMs:3e5};function J(t,n){var e,r;const o=null!=n?n:Object.assign({enabled:!0},E);return void 0===t?Object.assign({},o):!0===t?Object.assign(Object.assign({},o),{enabled:!0}):!1===t?Object.assign(Object.assign({},o),{enabled:!1}):{enabled:null===(e=t.enabled)||void 0===e||e,path:null!==(r=t.path)&&void 0!==r?r:o.path,timeoutMs:"number"==typeof t.timeoutMs?t.timeoutMs:o.timeoutMs,ttlMs:"number"==typeof t.ttlMs?t.ttlMs:o.ttlMs}}function W(t){return"_cnv_cfg_"+t}function F(t){const n=L(W(t));if(!n)return null;try{const t=JSON.parse(n);return t&&"object"==typeof t&&t.envelope?t:null}catch(t){return null}}function V(t,n,e){try{const r={etag:n,envelope:e,fetchedAt:Date.now()};q(W(t),JSON.stringify(r))}catch(t){}}function H(t){const n=null==t?void 0:t.buttonTracking;if(!n||!1===n.enabled)return null;const e=Array.isArray(n.rules)?n.rules:[];return 0===e.length?null:{rules:e,globalThrottle:n.globalThrottle}}const Z=["gclid","fbclid","ttclid","msclkid","dclid"],G=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function K(t,n){try{return t()}catch(t){return n}}function Q(){const t=K(()=>window.location.href,"");let n="",e="",r="";if(t)try{const o=new URL(t);n=o.pathname,e=o.search,r=o.hash}catch(t){}return{url:t,path:n,search:e,hash:r,title:K(()=>document.title,""),referrer:K(()=>document.referrer,"")}}function X(t){var n,e;let r="@cnv-vn/track",o="0.0.0-dev";try{r="@cnv-vn/track"}catch(t){}try{o="0.2.0-alpha.7"}catch(t){}return{name:null!==(n=null==t?void 0:t.name)&&void 0!==n?n:r,version:null!==(e=null==t?void 0:t.version)&&void 0!==e?e:o}}const Y="0123456789abcdef";function tt(t){return Y[t>>>4&15]+Y[15&t]}function nt(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues){const t=new Uint8Array(16);return crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128,tt(t[0])+tt(t[1])+tt(t[2])+tt(t[3])+"-"+tt(t[4])+tt(t[5])+"-"+tt(t[6])+tt(t[7])+"-"+tt(t[8])+tt(t[9])+"-"+tt(t[10])+tt(t[11])+tt(t[12])+tt(t[13])+tt(t[14])+tt(t[15])}}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=16*Math.random()|0;return("x"===t?n:3&n|8).toString(16)})}const et=/^[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 rt(t){return"string"==typeof t&&et.test(t)}const ot="_cnv_cid";function it(t={}){const n=N(ot),e=L(ot);let r=null;return rt(n)?r=n:rt(e)&&(r=e),r||(r=nt()),ct(r,t),r}function ct(t,n={}){var e;R(ot,t,{domain:n.cookieDomain,maxAgeDays:null!==(e=n.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),q(ot,t)}const ut="1.0";function lt(){return(new Date).toISOString()}function st(t,n){var e;const r=null!==(e=n.timestamp)&&void 0!==e?e:lt(),o=Object.assign(Object.assign({},n.context),{projectId:n.projectId,schemaVersion:ut}),i={type:t,messageId:nt(),anonymousId:n.anonymousId,timestamp:r,originalTimestamp:r,context:o};return n.userId&&(i.userId=n.userId),n.sessionId&&(i.sessionId=n.sessionId),n.integrations&&(i.integrations=n.integrations),i}const at="_cnv_sid";function ft(t){if(!t)return null;const n=t.lastIndexOf(".");if(n<0)return null;const e=t.slice(0,n),r=Number(t.slice(n+1));return!rt(e)||!Number.isFinite(r)||r<=0?null:{id:e,lastActivity:r}}function dt(t={}){const n=Date.now(),e=(t=>{var n;return 6e4*(null!==(n=t.timeoutMinutes)&&void 0!==n?n:30)})(t),r=ft(N(at)),o=ft((t=>{if(!z())return null;try{return sessionStorage.getItem(t)}catch(t){return null}})(at));let i=null;for(const t of[r,o])t&&(n-t.lastActivity>e||(!i||t.lastActivity>i.lastActivity)&&(i=t));const c=i?{id:i.id,lastActivity:n}:{id:nt(),lastActivity:n};return ht(c,t),c.id}function ht(t,n={}){var e;const r=(t=>`${t.id}.${t.lastActivity}`)(t),o=null!==(e=n.timeoutMinutes)&&void 0!==e?e:30;R(at,r,{domain:n.cookieDomain,maxAgeDays:o/1440,sameSite:"Lax"}),((t,n)=>{if(!z())return!1;try{return sessionStorage.setItem(t,n),!0}catch(t){return!1}})(at,r)}class yt{constructor(t){var n,e;Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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!==(n=t.storageKey)&&void 0!==n?n:"_cnv_rq",this.maxMessages=null!==(e=t.maxMessages)&&void 0!==e?e:100,this.installOnlineListener()}stash(t){if(t&&0!==t.length)try{const n=this.read();for(n.push(t);n.length>1&&vt(n)>this.maxMessages;)n.shift();this.write(n),this.config.debug&&console.log("[cnv-track] retry queued",t.length,"buffered",vt(n))}catch(t){}}flush(){if(this.flushing||"undefined"!=typeof navigator&&!1===navigator.onLine)return Promise.resolve();const t=this.read();if(0===t.length)return Promise.resolve();this.flushing=!0,this.write([]);const n=()=>{this.flushing=!1};return t.reduce((t,n)=>t.then(()=>this.config.resend(n)),Promise.resolve()).then(n,n)}size(){return vt(this.read())}clear(){try{B(this.storageKey)}catch(t){}}destroy(){if(this.onlineHandler){try{window.removeEventListener("online",this.onlineHandler)}catch(t){}this.onlineHandler=null}}installOnlineListener(){if("undefined"==typeof window)return;const t=()=>{this.flush()};try{window.addEventListener("online",t),this.onlineHandler=t}catch(t){}}read(){const t=L(this.storageKey);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(t=>Array.isArray(t)&&t.length>0):[]}catch(t){return[]}}write(t){0!==t.length?q(this.storageKey,JSON.stringify(t)):B(this.storageKey)}}function vt(t){let n=0;for(const e of t)n+=e.length;return n}class pt{constructor(t){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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 yt({debug:t.debug,resend:t=>this.send(t)}),this.installPageLifecycleHandlers(),this.retryQueue.flush()}setConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}enqueue(t){this.destroyed||(this.buffer.push(t),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 t=this.buffer;return this.buffer=[],this.send(t)}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(t){try{return this.config.useBatch?this.sendBatch(t):Promise.all(t.map(t=>this.sendSingle(t))).then(()=>{})}catch(t){return this.config.debug&&console.warn("[cnv-track] send failed synchronously; dropped batch",t),Promise.resolve()}}sendBatch(t){var n;const e=lt(),r={batch:t.map(t=>bt(t,e)),context:Object.assign(Object.assign({},null!==(n=this.config.batchContext)&&void 0!==n?n:{}),{projectId:this.config.projectId,sentAt:e}),sentAt:e};return this.post(this.batchUrl(),r,t)}sendSingle(t){const n=bt(t,lt());return this.post(this.singleUrl(t.type),n,[t])}batchUrl(){return this.config.endpoint+this.config.batchPath+"?projectId="+encodeURIComponent(this.config.projectId)}singleUrl(t){const n=this.config.singlePath.replace("{type}",t);return this.config.endpoint+n+"?projectId="+encodeURIComponent(this.config.projectId)}post(t,n,e){const r=JSON.stringify(n),o=((t,n)=>{try{return new Blob([t],{type:n})}catch(t){return null}})(r,this.config.contentType),i=o?o.size:(t=>{try{return new Blob([t]).size}catch(n){return t.length}})(r),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",t),Promise.resolve()):o&&this.sendViaBeacon(t,o)?(this.config.debug&&console.log("[cnv-track] beacon",t),Promise.resolve()):this.sendViaFetch(t,r,c)}sendViaBeacon(t,n){if("undefined"==typeof navigator||"function"!=typeof navigator.sendBeacon)return!1;if(n.size>65536)return!1;try{return navigator.sendBeacon(t,n)}catch(t){return!1}}sendViaFetch(t,n,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(t,{method:"POST",headers:{"Content-Type":this.config.contentType},body:n,keepalive:!0,credentials:"omit",mode:"cors"}).then(n=>{this.config.debug&&console.log("[cnv-track] fetch flushed",t,n.status)}).catch(n=>{this.config.debug&&console.warn("[cnv-track] flush failed; queued for retry",t,n),e&&this.retryQueue.stash(e)})}installPageLifecycleHandlers(){if("undefined"==typeof window||"undefined"==typeof document)return;const t=()=>{this.flush()},n=()=>{"hidden"===document.visibilityState&&this.flush()};try{window.addEventListener("pagehide",t),document.addEventListener("visibilitychange",n),this.handlers={pagehide:t,visibility:n}}catch(t){}}uninstallPageLifecycleHandlers(){if(this.handlers){try{window.removeEventListener("pagehide",this.handlers.pagehide),document.removeEventListener("visibilitychange",this.handlers.visibility)}catch(t){}this.handlers=null}}}function bt(t,n){return Object.assign(Object.assign({},t),{sentAt:n})}const mt="_cnv_uid",gt="_cnv_traits",wt={endpoint:"http://localhost:8090/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:J(void 0)},xt={analytics:!0,marketing:!0};function jt(t,n){if(!Array.isArray(n)||0===n.length)return;const e=n;try{switch(e[0]){case"init":t.init(e[1],e[2]);break;case"pageview":t.pageview(e[1],e[2]);break;case"page":t.page(e[1],e[2]);break;case"screen":t.screen(e[1],e[2]);break;case"track":t.track(e[1],e[2]);break;case"identify":t.identify(e[1],e[2]);break;case"alias":t.alias(e[1],e[2]);break;case"group":t.group(e[1],e[2]);break;case"reset":t.reset();break;case"flush":t.flush();break;case"consent":t.consent(e[1]);break;case"set":t.set(e[1])}}catch(t){}}const kt="0.2.0-alpha.7",Ot="@cnv-vn/track",At=function(){let o=null,i=Object.assign({},wt),c=Object.assign({},xt),u=null,l=!1,s=null,a=null;function f(t){const n=Object.assign({},i);return t?(void 0!==t.endpoint&&(n.endpoint=(e=t.endpoint).endsWith("/")?e.slice(0,-1):e),void 0!==t.batchPath&&(n.batchPath=t.batchPath),void 0!==t.singlePath&&(n.singlePath=t.singlePath),void 0!==t.useBatch&&(n.useBatch=t.useBatch),void 0!==t.contentType&&(n.contentType=t.contentType),void 0!==t.debug&&(n.debug=t.debug),void 0!==t.allowAdTracking&&(n.allowAdTracking=t.allowAdTracking),void 0!==t.cookieDomain&&(n.cookieDomain=t.cookieDomain),void 0!==t.cookieMaxAgeDays&&(n.cookieMaxAgeDays=t.cookieMaxAgeDays),void 0!==t.sessionTimeoutMinutes&&(n.sessionTimeoutMinutes=t.sessionTimeoutMinutes),void 0!==t.flushAt&&(n.flushAt=t.flushAt),void 0!==t.flushInterval&&(n.flushInterval=t.flushInterval),void 0!==t.autoPageview&&(n.autoPageview=t.autoPageview),void 0!==t.autotrack&&(n.autotrack=t.autotrack),void 0!==t.integrations&&(n.integrations=t.integrations),void 0!==t.remoteConfig&&(n.remoteConfig=J(t.remoteConfig,i.remoteConfig)),n):n;var e}function d(){return u||(u=new pt({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,projectId:null!=o?o:"",debug:i.debug}),u)}function h(){var t;if(!o)return null;const n=((t={})=>{var n;const e={page:Q(),screen:{width:K(()=>window.screen.width,0),height:K(()=>window.screen.height,0),density:K(()=>window.devicePixelRatio||1,1)},locale:K(()=>navigator.language||"",""),timezone:K(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:K(()=>navigator.userAgent||"",""),library:X(t.library)},r=((t,n=!0)=>{const e=K(()=>window.location.search,"");if(!e)return;let r;try{r=new URLSearchParams(e)}catch(t){return}const o={};let i=!1;for(const[t,n]of G){const e=r.get(t);e&&e.length>0&&(o[n]=e,i=!0)}if(n){const t={};for(const n of Z){const e=r.get(n);e&&e.length>0&&(t[n]=e)}Object.keys(t).length>0&&(o.clickIds=t,i=!0)}return i?o:void 0})(0,null===(n=t.allowAdTracking)||void 0===n||n);return r&&(e.campaign=r),e})({allowAdTracking:i.allowAdTracking});return c.analytics&&c.marketing||(n.consent=Object.assign({},c)),{anonymousId:it({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),sessionId:dt({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),userId:null!==(t=N(mt)||L(mt))&&void 0!==t?t:void 0,context:n,projectId:o,integrations:Object.keys(i.integrations).length>0?i.integrations:void 0}}function y(t){i.debug&&console.warn(`[cnv-track] ${t}() called before init()`)}function v(t,n){try{const e=h();if(!e)return y("pageview");const r=((t,n,e)=>{const r=st("page",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(t,((t,n)=>{const e={};return t&&(t.url&&(e.url=t.url),t.path&&(e.path=t.path),t.title&&(e.title=t.title),t.referrer&&(e.referrer=t.referrer),t.search&&(e.search=t.search)),Object.assign(Object.assign({},e),null!=n?n:{})})(e.context.page,n),e);d().enqueue(r)}catch(t){}}function p(t,n){v(t,n)}function b(t,n){try{if("string"!=typeof t||0===t.length)return;const e=h();if(!e)return y("track");const r=((t,n,e)=>{const r=st("track",e);return r.event=t,r.properties=null!=n?n:{},r})(t,n,e);d().enqueue(r)}catch(t){}}return{get initialized(){return l},get projectId(){return o},init(h,y){try{if(!h||"string"!=typeof h)return;if(i=f(y),(null==y?void 0:y.consent)&&(c=Object.assign(Object.assign({},c),y.consent)),o=h,u&&u.destroy(),u=null,d(),l=!0,it({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),dt({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),i.autoPageview&&v(),s){try{s()}catch(t){}s=null}const m={page(t,n){return p(t,n)},track(t,n){return b(t,n)}};if(i.autotrack){let o=i.autotrack;i.remoteConfig.enabled&&"object"==typeof o&&o.buttonTracking&&(o=Object.assign(Object.assign({},o),{buttonTracking:void 0})),s=function(o,i){const c=void 0===(u=i)||!1===u?Object.assign(Object.assign({},P),{searchParams:I}):!0===u?Object.assign(Object.assign({},M),{searchParams:I}):{spa:null===(l=u.spa)||void 0===l||l,outboundClicks:null===(s=u.outboundClicks)||void 0===s||s,scroll:null===(a=u.scroll)||void 0===a||a,downloads:null===(f=u.downloads)||void 0===f||f,siteSearch:null===(d=u.siteSearch)||void 0===d||d,downloadExtensions:u.downloadExtensions,searchParams:null!==(h=u.searchParams)&&void 0!==h?h:I,buttonTracking:u.buttonTracking};var u,l,s,a,f,d,h;const y=[];let v=null;function p(t){if(c.siteSearch)try{const n=null!=t?t:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(t){return""}})();if(n===v)return;v=n;const e=((t,n=I)=>{try{if(!t){if("undefined"==typeof location)return null;t=location.href}const e=t instanceof URL?t:new URL(t,(()=>{try{return"undefined"!=typeof location?location.href:"http://localhost/"}catch(t){return"http://localhost/"}})());if(!e.search)return null;for(const t of n){const n=e.searchParams.get(t);if(null===n)continue;const r=n.trim();if(0!==r.length)return{query:r,param:t}}return null}catch(t){return null}})(n,c.searchParams);e&&D(()=>o.track("Site Searched",{query:e.query,param:e.param}))}catch(t){}}if(c.outboundClicks||c.downloads){const i=(o=>{var i;if("undefined"==typeof document)return()=>{};const c=new Set((null!==(i=o.downloadExtensions)&&void 0!==i?i:t).map(t=>t.toLowerCase())),u=!!o.onOutbound,l=!!o.onDownload;if(!u&&!l)return()=>{};function s(t){var i,s;try{if(0!==t.button)return;if(t.defaultPrevented)return;const a=(t=>{const e="function"==typeof t.composedPath?t.composedPath():[];if(e.length>0)for(const t of e)if(n(t))return t;let r=t.target;for(;r;){if(n(r))return r;r=r.parentNode}return null})(t);if(!a)return;const f=a.getAttribute("href");if(!f)return;if(/^(javascript:|mailto:|tel:|sms:)/i.test(f))return;if(f.startsWith("#"))return;const d=(t=>{try{return new URL(t,location.href)}catch(t){return null}})(f);if(!d)return;let h=!1;if(l){const t=a.hasAttribute("download"),n=(t=>{const n=e(t),r=n.lastIndexOf(".");return r<=0||r===n.length-1?null:n.slice(r+1).toLowerCase()})(d.pathname);(t||n&&c.has(n))&&(h=!0,null===(i=o.onDownload)||void 0===i||i.call(o,{url:d.href,fileName:e(d.pathname),fileExtension:null!=n?n:"",text:r(a)}))}u&&!h&&d.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(t){return""}})()&&d.host&&(null===(s=o.onOutbound)||void 0===s||s.call(o,{url:d.href,host:d.host,text:r(a),target:a.target||"_self"}))}catch(t){}}try{document.addEventListener("click",s,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",s,!0)}catch(t){}}})({downloadExtensions:c.downloadExtensions,onOutbound:c.outboundClicks?t=>D(()=>o.track("Outbound Link Clicked",t)):void 0,onDownload:c.downloads?t=>D(()=>o.track("File Downloaded",t)):void 0});y.push(i)}c.buttonTracking&&c.buttonTracking.rules&&c.buttonTracking.rules.length>0&&y.push(g(o,c.buttonTracking));let b=null;if(c.scroll&&(b=(t=>{if("undefined"==typeof window||"undefined"==typeof document)return{destroy(){},reset(){}};let n=!1,e=null,r=!1;function o(){if(e=null,!r&&!n)try{const e=document.documentElement,r=document.body,o=Math.max(e?e.scrollHeight:0,r?r.scrollHeight:0),i=Math.max(e?e.clientHeight:0,window.innerHeight||0);if(o<=i)return n=!0,c(),void t(90);((window.scrollY||(e?e.scrollTop:0)||0)+i)/o>=.9&&(n=!0,c(),t(90))}catch(t){}}function i(){if(null===e)try{e=window.requestAnimationFrame(o)}catch(t){o()}}function c(){try{window.removeEventListener("scroll",i),null!==e&&window.cancelAnimationFrame(e),e=null}catch(t){}}try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}return{destroy(){r=!0,c()},reset(){if(!r){n=!1;try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}}}}})(t=>{D(()=>o.track("Scrolled",{percent:t}))}),y.push(()=>null==b?void 0:b.destroy())),c.spa){const t=[],n=function(){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let n=T();function e(){try{const e=T();if(e===n)return;n=e,(n=>{const e=setTimeout(()=>{const n=t.indexOf(e);-1!==n&&t.splice(n,1),D(()=>o.page())},0);t.push(e),null==b||b.reset(),p(n)})(e)}catch(t){}}const r=history.pushState,i=history.replaceState,c=!0===r[_],u=!0===i[_];if(!c){function a(...t){r.apply(this,t),e()}a[_]=!0,history.pushState=a}if(!u){function f(...t){i.apply(this,t),e()}f[_]=!0,history.replaceState=f}const l=()=>e(),s=()=>e();try{window.addEventListener("popstate",l),window.addEventListener("hashchange",s)}catch(d){}return()=>{try{window.removeEventListener("popstate",l),window.removeEventListener("hashchange",s)}catch(t){}try{!c&&history.pushState[_]&&(history.pushState=r),!u&&history.replaceState[_]&&(history.replaceState=i)}catch(t){}}}();y.push(()=>{for(let n=0;n<t.length;n++)clearTimeout(t[n]);t.length=0,n()})}return p(),()=>{for(;y.length>0;){const t=y.pop();try{null==t||t()}catch(t){}}v=null}}(m,o)}if(a){try{a()}catch(t){}a=null}if(i.remoteConfig.enabled&&o){const t=t=>{if(a){try{a()}catch(t){}a=null}t&&t.rules&&t.rules.length>0&&(a=g(m,t))},n=(t=>{const n=F(t);return n?H(n.envelope):null})(o);n&&t(n),function(t){return U(this,void 0,void 0,function*(){if(!t.projectId)return{status:"error"};const n=F(t.projectId);if(n&&Date.now()-n.fetchedAt<t.ttlMs)return{status:"unchanged"};const e=yield function(t){return U(this,void 0,void 0,function*(){var n;if("function"!=typeof fetch)return null;const e=t.endpoint+t.path+"?projectId="+encodeURIComponent(t.projectId),r="undefined"!=typeof AbortController?new AbortController:null,o=r?setTimeout(()=>r.abort(),t.timeoutMs):null;try{const o={};t.etag&&(o["If-None-Match"]=t.etag);const i=yield fetch(e,{method:"GET",headers:o,credentials:"omit",mode:"cors",signal:r?r.signal:void 0});if(304===i.status)return{envelope:null,etag:null!==(n=t.etag)&&void 0!==n?n:"",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(t){return null}finally{o&&clearTimeout(o)}})}({endpoint:t.endpoint,path:t.path,projectId:t.projectId,timeoutMs:t.timeoutMs,etag:null==n?void 0:n.etag});return e?e.notModified?(n&&V(t.projectId,n.etag,n.envelope),{status:"unchanged"}):e.envelope?(V(t.projectId,e.etag,e.envelope),{status:"updated",buttonTracking:H(e.envelope)}):{status:"error"}:{status:"error"}})}({endpoint:i.endpoint,path:i.remoteConfig.path,projectId:o,timeoutMs:i.remoteConfig.timeoutMs,ttlMs:i.remoteConfig.ttlMs}).then(n=>{"updated"===n.status&&t(n.buttonTracking)}).catch(()=>{})}}catch(t){}},pageview:v,page:p,screen(t,n){try{const e=h();if(!e)return y("screen");const r=((t,n,e)=>{const r=st("screen",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(t,n,e);d().enqueue(r)}catch(t){}},track:b,identify(t,n){try{if("string"!=typeof t||0===t.length)return;((t,n,e={})=>{var r,o;if(t&&(R(mt,t,{domain:e.cookieDomain,maxAgeDays:null!==(r=e.cookieMaxAgeDays)&&void 0!==r?r:730,sameSite:"Lax"}),q(mt,t),null!=n)){const t=null!==(o=(()=>{const t=L(gt);if(!t)return null;try{const n=JSON.parse(t);return n&&"object"==typeof n&&!Array.isArray(n)?n:null}catch(t){return null}})())&&void 0!==o?o:{},e=Object.assign(Object.assign({},t),n);try{q(gt,JSON.stringify(e))}catch(t){}}})(t,n,{cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays});const e=h();if(!e)return y("identify");const r=((t,n,e)=>{var r;const o=st("identify",e);return t&&(o.userId=t),o.traits=null!==(r=n)&&void 0!==r?r:{},o})(t,n,e);d().enqueue(r)}catch(t){}},alias(t,n){try{if("string"!=typeof t||0===t.length)return;const e=h();if(!e)return y("alias");const r=((t,n,e)=>{const r=st("alias",e);return t&&(r.userId=t),r.previousId=null!=n?n:e.anonymousId,r})(t,n,e);d().enqueue(r)}catch(t){}},group(t,n){try{if("string"!=typeof t||0===t.length)return;const e=h();if(!e)return y("group");const r=((t,n,e)=>{const r=st("group",e);return r.groupId=t,r.traits=null!=n?n:{},r})(t,n,e);d().enqueue(r)}catch(t){}},reset(){try{((t={})=>{((t,n={})=>{var e;if(!C)return!1;try{let r=`${encodeURIComponent(t)}=`;return r+=`; path=${null!==(e=n.path)&&void 0!==e?e:"/"}`,n.domain&&(r+=`; domain=${n.domain}`),r+="; max-age=0",r+="; expires=Thu, 01 Jan 1970 00:00:00 GMT",document.cookie=r,null===N(t)}catch(t){return!1}})(mt,{domain:t.cookieDomain}),B(mt),B(gt)})({cookieDomain:i.cookieDomain}),((t={})=>{ct(nt(),t)})({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),((t={})=>{ht({id:nt(),lastActivity:Date.now()},t)})({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes})}catch(t){}},flush(){try{u&&u.flush()}catch(t){}},consent(t){try{c=Object.assign(Object.assign({},c),t)}catch(t){}},set(t){try{i=f(t),t.consent&&(c=Object.assign(Object.assign({},c),t.consent)),u&&u.setConfig({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,debug:i.debug})}catch(t){}},destroy(){if(s){try{s()}catch(t){}s=null}if(a){try{a()}catch(t){}a=null}u&&u.destroy(),u=null,l=!1,o=null,i=Object.assign({},wt),c=Object.assign({},xt)}}}();"undefined"!=typeof window&&(t=>{if("undefined"==typeof window)return()=>{};const n=window.cnvQ;if(n&&n.__loaded)return()=>{};const e=window.cnvQ=null!=n?n:[],r=e.splice(0,e.length);e.push.bind(e),e.push=(...n)=>{for(const e of n)jt(t,e);return e.length},e.__loaded=!0;for(const n of r)jt(t,n)})(At);const St=Object.assign(At,{version:kt,name:Ot,schemaVersion:ut});export{Ot as NAME,ut as SCHEMA_VERSION,kt as VERSION,St as default};
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @cnv-vn/track v0.2.0-alpha.5
2
+ * @cnv-vn/track v0.2.0-alpha.7
3
3
  * (c) 2026 CNV
4
4
  * Released under the UNLICENSED license.
5
5
  */
6
- !function(t){const n=["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 e(t){return!!t&&"object"==typeof t&&1===t.nodeType&&"A"===t.tagName}function r(t){const n=t.lastIndexOf("/");return-1===n?t:t.slice(n+1)}function o(t){var n,e,r;let o=(null!==(n=t.textContent)&&void 0!==n?n:"").trim();return o||(o=(null!==(e=t.getAttribute("aria-label"))&&void 0!==e?e:"").trim()),o||(o=(null!==(r=t.getAttribute("title"))&&void 0!==r?r:"").trim()),o.length>200?o.slice(0,200):o}const i=200;function c(t){let n="";try{n=(t.textContent||"").replace(/\s+/g," ").trim(),n||(n=(t.getAttribute("aria-label")||"").trim()),n||(n=(t.getAttribute("title")||"").trim())}catch(t){return""}return n.length>i?n.slice(0,i):n}function u(t){const n=!1!==t.caseInsensitive;return"regex"===t.mode?{mode:"regex",needle:t.value,ci:n,re:b(t.value,n)}:{mode:t.mode,needle:n?t.value.toLowerCase():t.value,ci:n,re:null}}function s(t,n){try{return t.matches(n)}catch(t){return!1}}function a(t){try{if("A"===t.tagName){const n=t.getAttribute("href");return n?p(n):null}const n=t.getAttribute("formaction");if(n)return p(n);const e=t.getAttribute("data-href");if(e)return p(e);const r=t.closest("form");if(r){const t=r.getAttribute("action");if(t)return p(t)}return null}catch(t){return null}}function l(t){return"regex"===t.mode?{mode:"regex",needle:t.value,re:b(t.value,!0)}:{mode:t.mode,needle:t.value.toLowerCase(),re:null}}function f(t){if("startsWith"===t.mode)return{mode:"startsWith",needle:t.value,re:null};const n="glob"===t.mode?"^"+t.value.replace(/[.+^${}()|[\]\\?]/g,"\\$&").replace(/\*/g,".*")+"$":t.value;return{mode:t.mode,needle:t.value,re:b(n,!1)}}function d(t,n){return"startsWith"===t.mode?0===n.indexOf(t.needle):!t.re||g(t.re,n)}const h=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,y=/\+?\d[\d\s().-]{7,}\d/g;function v(t){if(!t)return t;try{return t.replace(h,"[email]").replace(y,"[phone]")}catch(n){return t}}function m(t){return!!t&&"object"==typeof t&&1===t.nodeType}function p(t){try{return new URL(t,location.href).href}catch(n){return t}}function b(t,n){try{return!t||t.length>1e3?null:new RegExp(t,n?"i":"")}catch(t){return null}}function g(t,n){try{return t.test(n)}catch(t){return!1}}function w(t){const n=t.match;return n.element?n.element:n.selector||n.id||n.dataAttr||n.classes&&n.classes.length>0||n.destinationUrl?"any":void 0}function x(t,n){if(!((t,n)=>{if(!n)return(t=>{const n=t.tagName;if("BUTTON"===n||"A"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")})(t);if("any"===n)return!0;if("button"===n){const n=t.tagName;if("BUTTON"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")}return"link"===n?"A"===t.tagName:s(t,n)})(n,t.elementSpec))return!1;const e=t.rule.match;return!(t.selector&&!s(n,t.selector)||void 0!==e.id&&!((t,n)=>t.id===n)(n,e.id)||e.classes&&e.classes.length>0&&!((t,n)=>{try{for(let e=0;e<n.length;e++)if(!t.classList.contains(n[e]))return!1;return!0}catch(t){return!1}})(n,e.classes)||e.dataAttr&&!((t,n,e)=>{try{return!!t.hasAttribute(n)&&(void 0===e||t.getAttribute(n)===e)}catch(t){return!1}})(n,e.dataAttr.name,e.dataAttr.value)||t.text&&!((t,n)=>{const e=c(t);if("regex"===n.mode)return!!n.re&&g(n.re,e);const r=n.ci?e.toLowerCase():e;return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.text)||t.dest&&!((t,n)=>{const e=a(t);if(!e)return!1;if("regex"===n.mode)return!!n.re&&g(n.re,e);if("domain"===n.mode)try{return new URL(e).host.toLowerCase()===n.needle}catch(t){return!1}const r=e.toLowerCase();return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.dest))}function k(t,n,e){const r={},o=t.event.staticProps;if(o)for(const t of Object.keys(o))r[t]=o[t];const u=t.capture;if(u)try{if(u.text){const t=v(c(n));t&&(r.text=t)}if(u.href){const t=a(n);t&&(r.href=t)}if(u.elementId&&n.id&&(r.element_id=n.id),u.classes&&(r.element_classes=Array.from(n.classList)),u.dataAttrs&&u.dataAttrs.length>0)for(let t=0;t<u.dataAttrs.length;t++){const e=u.dataAttrs[t],o=n.getAttribute(e);null!==o&&(r[e]=v(o))}if(u.valueFrom){const t=((t,n)=>{try{const e=t.querySelector(n.selector)||(t.parentElement?t.parentElement.querySelector(n.selector):null);if(!e)return null;const r=n.attr?e.getAttribute(n.attr):e.textContent||"";if(null===r)return null;const o=v(r.replace(/\s+/g," ").trim());return o.length>i?o.slice(0,i):o}catch(t){return null}})(n,u.valueFrom);null!==t&&(r[u.valueFrom.as]=t)}u.selectorPath&&(r.selector_path=((t,n=5)=>{try{const e=[];let r=t,o=0;for(;r&&1===r.nodeType&&o<n;){let t=r.tagName.toLowerCase();if(r.id){e.unshift(t+"#"+r.id);break}const n=Array.from(r.classList).slice(0,2).join(".");n&&(t+="."+n),e.unshift(t),r=r.parentElement,o++}return e.join(" > ")}catch(t){return""}})(n)),u.position&&(r.x=e.clientX,r.y=e.clientY)}catch(t){}return r.rule_id=t.id,t.name&&(r.rule_name=t.name),r.tag=n.tagName.toLowerCase(),r}function j(t){try{t()}catch(t){}}function O(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}function A(t,n){return"number"!=typeof t||isNaN(t)?n:t}function S(t){return t<0?0:t>1?1:t}const _="__cnvPatched";function P(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}const I=["q","s","query","search","keyword"],D={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},M={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};function T(t){try{t()}catch(t){}}const U=["gclid","fbclid","ttclid","msclkid","dclid"],$=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function R(t,n){try{return t()}catch(t){return n}}function C(){const t=R(()=>window.location.href,"");let n="",e="",r="";if(t)try{const o=new URL(t);n=o.pathname,e=o.search,r=o.hash}catch(t){}return{url:t,path:n,search:e,hash:r,title:R(()=>document.title,""),referrer:R(()=>document.referrer,"")}}function L(t){var n,e;let r="@cnv-vn/track",o="0.0.0-dev";try{r="@cnv-vn/track"}catch(t){}try{o="0.2.0-alpha.5"}catch(t){}return{name:null!==(n=null==t?void 0:t.name)&&void 0!==n?n:r,version:null!==(e=null==t?void 0:t.version)&&void 0!==e?e:o}}const N="0123456789abcdef";function q(t){return N[t>>>4&15]+N[15&t]}function B(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues){const t=new Uint8Array(16);return crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128,q(t[0])+q(t[1])+q(t[2])+q(t[3])+"-"+q(t[4])+q(t[5])+"-"+q(t[6])+q(t[7])+"-"+q(t[8])+q(t[9])+"-"+q(t[10])+q(t[11])+q(t[12])+q(t[13])+q(t[14])+q(t[15])}}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=16*Math.random()|0;return("x"===t?n:3&n|8).toString(16)})}const z=/^[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 W(t){return"string"==typeof t&&z.test(t)}const J="undefined"!=typeof window&&"undefined"!=typeof document;function E(t){if(!J)return null;try{const n=document.cookie;if(!n)return null;const e=encodeURIComponent(t),r=n.split(";");for(let n=0;n<r.length;n++){const o=r[n].indexOf("=");if(o<0)continue;const i=r[n].slice(0,o).trim();if(i===e||i===t)try{return decodeURIComponent(r[n].slice(o+1))}catch(t){return r[n].slice(o+1)}}return null}catch(t){return null}}function V(t,n,e={}){var r,o,i;if(!J)return!1;try{let c=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(c+=`; path=${null!==(r=e.path)&&void 0!==r?r:"/"}`,e.domain&&(c+=`; domain=${e.domain}`),"number"==typeof e.maxAgeDays){const t=Math.floor(86400*e.maxAgeDays);c+=`; max-age=${t}`,c+=`; expires=${new Date(Date.now()+1e3*t).toUTCString()}`}return c+=`; SameSite=${null!==(o=e.sameSite)&&void 0!==o?o:"Lax"}`,(null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol)&&(c+="; Secure"),document.cookie=c,E(t)===n}catch(t){return!1}}function H(){if(!J)return!1;try{const t="__cnv_probe__";return localStorage.setItem(t,"1"),localStorage.removeItem(t),!0}catch(t){return!1}}function Z(t){if(!H())return null;try{return localStorage.getItem(t)}catch(t){return null}}function F(t,n){if(!H())return!1;try{return localStorage.setItem(t,n),!0}catch(t){return!1}}function G(t){if(!H())return!1;try{return localStorage.removeItem(t),!0}catch(t){return!1}}function K(){if(!J)return!1;try{const t="__cnv_probe__";return sessionStorage.setItem(t,"1"),sessionStorage.removeItem(t),!0}catch(t){return!1}}const Q="_cnv_cid";function X(t={}){const n=E(Q),e=Z(Q);let r=null;return W(n)?r=n:W(e)&&(r=e),r||(r=B()),Y(r,t),r}function Y(t,n={}){var e;V(Q,t,{domain:n.cookieDomain,maxAgeDays:null!==(e=n.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),F(Q,t)}const tt="1.0";function nt(){return(new Date).toISOString()}function et(t,n){var e;const r=null!==(e=n.timestamp)&&void 0!==e?e:nt(),o=Object.assign(Object.assign({},n.context),{projectId:n.projectId,schemaVersion:tt}),i={type:t,messageId:B(),anonymousId:n.anonymousId,timestamp:r,originalTimestamp:r,context:o};return n.userId&&(i.userId=n.userId),n.sessionId&&(i.sessionId=n.sessionId),n.integrations&&(i.integrations=n.integrations),i}const rt="_cnv_sid";function ot(t){if(!t)return null;const n=t.lastIndexOf(".");if(n<0)return null;const e=t.slice(0,n),r=Number(t.slice(n+1));return!W(e)||!Number.isFinite(r)||r<=0?null:{id:e,lastActivity:r}}function it(t={}){const n=Date.now(),e=(t=>{var n;return 6e4*(null!==(n=t.timeoutMinutes)&&void 0!==n?n:30)})(t),r=ot(E(rt)),o=ot((t=>{if(!K())return null;try{return sessionStorage.getItem(t)}catch(t){return null}})(rt));let i=null;for(const t of[r,o])t&&(n-t.lastActivity>e||(!i||t.lastActivity>i.lastActivity)&&(i=t));const c=i?{id:i.id,lastActivity:n}:{id:B(),lastActivity:n};return ct(c,t),c.id}function ct(t,n={}){var e;const r=(t=>`${t.id}.${t.lastActivity}`)(t),o=null!==(e=n.timeoutMinutes)&&void 0!==e?e:30;V(rt,r,{domain:n.cookieDomain,maxAgeDays:o/1440,sameSite:"Lax"}),((t,n)=>{if(!K())return!1;try{return sessionStorage.setItem(t,n),!0}catch(t){return!1}})(rt,r)}class ut{constructor(t){var n,e;Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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!==(n=t.storageKey)&&void 0!==n?n:"_cnv_rq",this.maxMessages=null!==(e=t.maxMessages)&&void 0!==e?e:100,this.installOnlineListener()}stash(t){if(t&&0!==t.length)try{const n=this.read();for(n.push(t);n.length>1&&st(n)>this.maxMessages;)n.shift();this.write(n),this.config.debug&&console.log("[cnv-track] retry queued",t.length,"buffered",st(n))}catch(t){}}flush(){if(this.flushing||"undefined"!=typeof navigator&&!1===navigator.onLine)return Promise.resolve();const t=this.read();if(0===t.length)return Promise.resolve();this.flushing=!0,this.write([]);const n=()=>{this.flushing=!1};return t.reduce((t,n)=>t.then(()=>this.config.resend(n)),Promise.resolve()).then(n,n)}size(){return st(this.read())}clear(){try{G(this.storageKey)}catch(t){}}destroy(){if(this.onlineHandler){try{window.removeEventListener("online",this.onlineHandler)}catch(t){}this.onlineHandler=null}}installOnlineListener(){if("undefined"==typeof window)return;const t=()=>{this.flush()};try{window.addEventListener("online",t),this.onlineHandler=t}catch(t){}}read(){const t=Z(this.storageKey);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(t=>Array.isArray(t)&&t.length>0):[]}catch(t){return[]}}write(t){0!==t.length?F(this.storageKey,JSON.stringify(t)):G(this.storageKey)}}function st(t){let n=0;for(const e of t)n+=e.length;return n}class at{constructor(t){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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 ut({debug:t.debug,resend:t=>this.send(t)}),this.installPageLifecycleHandlers(),this.retryQueue.flush()}setConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}enqueue(t){this.destroyed||(this.buffer.push(t),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 t=this.buffer;return this.buffer=[],this.send(t)}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(t){try{return this.config.useBatch?this.sendBatch(t):Promise.all(t.map(t=>this.sendSingle(t))).then(()=>{})}catch(t){return this.config.debug&&console.warn("[cnv-track] send failed synchronously; dropped batch",t),Promise.resolve()}}sendBatch(t){var n;const e=nt(),r={batch:t.map(t=>lt(t,e)),context:Object.assign(Object.assign({},null!==(n=this.config.batchContext)&&void 0!==n?n:{}),{projectId:this.config.projectId,sentAt:e}),sentAt:e};return this.post(this.batchUrl(),r,t)}sendSingle(t){const n=lt(t,nt());return this.post(this.singleUrl(t.type),n,[t])}batchUrl(){return this.config.endpoint+this.config.batchPath+"?projectId="+encodeURIComponent(this.config.projectId)}singleUrl(t){const n=this.config.singlePath.replace("{type}",t);return this.config.endpoint+n+"?projectId="+encodeURIComponent(this.config.projectId)}post(t,n,e){const r=JSON.stringify(n),o=((t,n)=>{try{return new Blob([t],{type:n})}catch(t){return null}})(r,this.config.contentType),i=o?o.size:(t=>{try{return new Blob([t]).size}catch(n){return t.length}})(r),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",t),Promise.resolve()):o&&this.sendViaBeacon(t,o)?(this.config.debug&&console.log("[cnv-track] beacon",t),Promise.resolve()):this.sendViaFetch(t,r,c)}sendViaBeacon(t,n){if("undefined"==typeof navigator||"function"!=typeof navigator.sendBeacon)return!1;if(n.size>65536)return!1;try{return navigator.sendBeacon(t,n)}catch(t){return!1}}sendViaFetch(t,n,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(t,{method:"POST",headers:{"Content-Type":this.config.contentType},body:n,keepalive:!0,credentials:"omit",mode:"cors"}).then(n=>{this.config.debug&&console.log("[cnv-track] fetch flushed",t,n.status)}).catch(n=>{this.config.debug&&console.warn("[cnv-track] flush failed; queued for retry",t,n),e&&this.retryQueue.stash(e)})}installPageLifecycleHandlers(){if("undefined"==typeof window||"undefined"==typeof document)return;const t=()=>{this.flush()},n=()=>{"hidden"===document.visibilityState&&this.flush()};try{window.addEventListener("pagehide",t),document.addEventListener("visibilitychange",n),this.handlers={pagehide:t,visibility:n}}catch(t){}}uninstallPageLifecycleHandlers(){if(this.handlers){try{window.removeEventListener("pagehide",this.handlers.pagehide),document.removeEventListener("visibilitychange",this.handlers.visibility)}catch(t){}this.handlers=null}}}function lt(t,n){return Object.assign(Object.assign({},t),{sentAt:n})}const ft="_cnv_uid",dt="_cnv_traits",ht={endpoint:"http://localhost:8090/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:{}},yt={analytics:!0,marketing:!0};function vt(t,n){if(!Array.isArray(n)||0===n.length)return;const e=n;try{switch(e[0]){case"init":t.init(e[1],e[2]);break;case"pageview":t.pageview(e[1],e[2]);break;case"page":t.page(e[1],e[2]);break;case"screen":t.screen(e[1],e[2]);break;case"track":t.track(e[1],e[2]);break;case"identify":t.identify(e[1],e[2]);break;case"alias":t.alias(e[1],e[2]);break;case"group":t.group(e[1],e[2]);break;case"reset":t.reset();break;case"flush":t.flush();break;case"consent":t.consent(e[1]);break;case"set":t.set(e[1])}}catch(t){}}const mt="0.2.0-alpha.5",pt="@cnv-vn/track",bt=(()=>{let t=null,i=Object.assign({},ht),c=Object.assign({},yt),s=null,a=!1,h=null;function y(t){const n=Object.assign({},i);return t?(void 0!==t.endpoint&&(n.endpoint=(e=t.endpoint).endsWith("/")?e.slice(0,-1):e),void 0!==t.batchPath&&(n.batchPath=t.batchPath),void 0!==t.singlePath&&(n.singlePath=t.singlePath),void 0!==t.useBatch&&(n.useBatch=t.useBatch),void 0!==t.contentType&&(n.contentType=t.contentType),void 0!==t.debug&&(n.debug=t.debug),void 0!==t.allowAdTracking&&(n.allowAdTracking=t.allowAdTracking),void 0!==t.cookieDomain&&(n.cookieDomain=t.cookieDomain),void 0!==t.cookieMaxAgeDays&&(n.cookieMaxAgeDays=t.cookieMaxAgeDays),void 0!==t.sessionTimeoutMinutes&&(n.sessionTimeoutMinutes=t.sessionTimeoutMinutes),void 0!==t.flushAt&&(n.flushAt=t.flushAt),void 0!==t.flushInterval&&(n.flushInterval=t.flushInterval),void 0!==t.autoPageview&&(n.autoPageview=t.autoPageview),void 0!==t.autotrack&&(n.autotrack=t.autotrack),void 0!==t.integrations&&(n.integrations=t.integrations),n):n;var e}function v(){return s||(s=new at({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,projectId:null!=t?t:"",debug:i.debug}),s)}function p(){var n;if(!t)return null;const e=((t={})=>{var n;const e={page:C(),screen:{width:R(()=>window.screen.width,0),height:R(()=>window.screen.height,0),density:R(()=>window.devicePixelRatio||1,1)},locale:R(()=>navigator.language||"",""),timezone:R(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:R(()=>navigator.userAgent||"",""),library:L(t.library)},r=((t,n=!0)=>{const e=R(()=>window.location.search,"");if(!e)return;let r;try{r=new URLSearchParams(e)}catch(t){return}const o={};let i=!1;for(const[t,n]of $){const e=r.get(t);e&&e.length>0&&(o[n]=e,i=!0)}if(n){const t={};for(const n of U){const e=r.get(n);e&&e.length>0&&(t[n]=e)}Object.keys(t).length>0&&(o.clickIds=t,i=!0)}return i?o:void 0})(0,null===(n=t.allowAdTracking)||void 0===n||n);return r&&(e.campaign=r),e})({allowAdTracking:i.allowAdTracking});return c.analytics&&c.marketing||(e.consent=Object.assign({},c)),{anonymousId:X({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),sessionId:it({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),userId:null!==(n=E(ft)||Z(ft))&&void 0!==n?n:void 0,context:e,projectId:t,integrations:Object.keys(i.integrations).length>0?i.integrations:void 0}}function b(t){i.debug&&console.warn(`[cnv-track] ${t}() called before init()`)}function g(t,n){try{const e=p();if(!e)return b("pageview");const r=((t,n,e)=>{const r=et("page",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(null!=t?t:(()=>{try{return"undefined"!=typeof document&&document.title||void 0}catch(t){return}})(),n,e);v().enqueue(r)}catch(t){}}function N(t,n){g(t,n)}function q(t,n){try{if("string"!=typeof t||0===t.length)return;const e=p();if(!e)return b("track");const r=((t,n,e)=>{const r=et("track",e);return r.event=t,r.properties=null!=n?n:{},r})(t,n,e);v().enqueue(r)}catch(t){}}return{get initialized(){return a},get projectId(){return t},init(p,b){try{if(!p||"string"!=typeof p)return;if(i=y(b),(null==b?void 0:b.consent)&&(c=Object.assign(Object.assign({},c),b.consent)),t=p,s&&s.destroy(),s=null,v(),a=!0,X({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),it({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),i.autoPageview&&g(),h){try{h()}catch(t){}h=null}i.autotrack&&(h=function(t,i){const c=void 0===(s=i)||!1===s?Object.assign(Object.assign({},M),{searchParams:I}):!0===s?Object.assign(Object.assign({},D),{searchParams:I}):{spa:null===(a=s.spa)||void 0===a||a,outboundClicks:null===(h=s.outboundClicks)||void 0===h||h,scroll:null===(y=s.scroll)||void 0===y||y,downloads:null===(v=s.downloads)||void 0===v||v,siteSearch:null===(p=s.siteSearch)||void 0===p||p,downloadExtensions:s.downloadExtensions,searchParams:null!==(b=s.searchParams)&&void 0!==b?b:I,buttonTracking:s.buttonTracking};var s,a,h,y,v,p,b;const g=[];let U=null;function $(n){if(c.siteSearch)try{const e=null!=n?n:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(t){return""}})();if(e===U)return;U=e;const r=((t,n=I)=>{try{if(!t){if("undefined"==typeof location)return null;t=location.href}const e=t instanceof URL?t:new URL(t,(()=>{try{return"undefined"!=typeof location?location.href:"http://localhost/"}catch(t){return"http://localhost/"}})());if(!e.search)return null;for(const t of n){const n=e.searchParams.get(t);if(null===n)continue;const r=n.trim();if(0!==r.length)return{query:r,param:t}}return null}catch(t){return null}})(e,c.searchParams);r&&T(()=>t.track("Site Searched",{query:r.query,param:r.param}))}catch(t){}}if(c.outboundClicks||c.downloads){const i=(t=>{var i;if("undefined"==typeof document)return()=>{};const c=new Set((null!==(i=t.downloadExtensions)&&void 0!==i?i:n).map(t=>t.toLowerCase())),u=!!t.onOutbound,s=!!t.onDownload;if(!u&&!s)return()=>{};function a(n){var i,a;try{if(0!==n.button)return;if(n.defaultPrevented)return;const l=(t=>{const n="function"==typeof t.composedPath?t.composedPath():[];if(n.length>0)for(const t of n)if(e(t))return t;let r=t.target;for(;r;){if(e(r))return r;r=r.parentNode}return null})(n);if(!l)return;const f=l.getAttribute("href");if(!f)return;if(/^(javascript:|mailto:|tel:|sms:)/i.test(f))return;if(f.startsWith("#"))return;const d=(t=>{try{return new URL(t,location.href)}catch(t){return null}})(f);if(!d)return;let h=!1;if(s){const n=l.hasAttribute("download"),e=(t=>{const n=r(t),e=n.lastIndexOf(".");return e<=0||e===n.length-1?null:n.slice(e+1).toLowerCase()})(d.pathname);(n||e&&c.has(e))&&(h=!0,null===(i=t.onDownload)||void 0===i||i.call(t,{url:d.href,fileName:r(d.pathname),fileExtension:null!=e?e:"",text:o(l)}))}u&&!h&&d.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(t){return""}})()&&d.host&&(null===(a=t.onOutbound)||void 0===a||a.call(t,{url:d.href,host:d.host,text:o(l),target:l.target||"_self"}))}catch(t){}}try{document.addEventListener("click",a,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",a,!0)}catch(t){}}})({downloadExtensions:c.downloadExtensions,onOutbound:c.outboundClicks?n=>T(()=>t.track("Outbound Link Clicked",n)):void 0,onDownload:c.downloads?n=>T(()=>t.track("File Downloaded",n)):void 0});g.push(i)}c.buttonTracking&&c.buttonTracking.rules&&c.buttonTracking.rules.length>0&&g.push(((t,n)=>{if("undefined"==typeof document)return()=>{};const e=(t=>{const n=t.globalThrottle||{},e=[],r=t.rules||[];for(let t=0;t<r.length;t++){const o=r[t];if(!o||!1===o.enabled)continue;if(!o.match||!o.event||!o.event.name)continue;const i=o.match,c=o.throttle||{};e.push({rule:o,elementSpec:w(o),selector:i.selector||null,text:i.text?u(i.text):null,dest:i.destinationUrl?l(i.destinationUrl):null,urlScope:o.urlScope?f(o.urlScope):null,dedupeWindowMs:A(c.dedupeWindowMs,A(n.dedupeWindowMs,500)),maxPerPageview:A(c.maxPerPageview,A(n.maxPerPageview,1/0)),samplingRate:S(A(c.samplingRate,A(n.samplingRate,1)))})}return e.sort((t,n)=>(t.rule.priority||0)-(n.rule.priority||0)),e})(n);if(0===e.length)return()=>{};const r=new WeakMap;let o=0;const i=t=>{let n=r.get(t);return void 0===n&&(n=++o,r.set(t,n)),String(n)},c=new Map,s=new Map;let a=O();function h(n){try{if(0!==n.button)return;const r=O();r!==a&&(a=r,s.clear(),c.clear());const o=(t=>{const n=[];try{const e="function"==typeof t.composedPath?t.composedPath():[];if(e&&e.length>0){for(const t of e)m(t)&&n.push(t);return n}let r=t.target;for(;r;)m(r)&&n.push(r),r=r.parentNode}catch(t){}return n})(n);if(0===o.length)return;const u=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(t){return""}})();for(let r=0;r<e.length;r++){const a=e[r];if(a.urlScope&&!d(a.urlScope,u))continue;let l=null;for(let t=0;t<o.length;t++)if(x(a,o[t])){l=o[t];break}if(!l)continue;const f=a.rule.id;if((s.get(f)||0)>=a.maxPerPageview)return;const h=f+"#"+i(l),y=Date.now(),v=c.get(h);if(void 0!==v&&y-v<a.dedupeWindowMs)return;if(a.samplingRate<1&&Math.random()>=a.samplingRate)return;c.set(h,y),s.set(f,(s.get(f)||0)+1);const m=a.rule.event.name||"Button Clicked",p=k(a.rule,l,n);return void j(()=>t.track(m,p))}}catch(t){}}try{document.addEventListener("click",h,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",h,!0)}catch(t){}c.clear(),s.clear()}})(t,c.buttonTracking));let R=null;if(c.scroll&&(R=(t=>{if("undefined"==typeof window||"undefined"==typeof document)return{destroy(){},reset(){}};let n=!1,e=null,r=!1;function o(){if(e=null,!r&&!n)try{const e=document.documentElement,r=document.body,o=Math.max(e?e.scrollHeight:0,r?r.scrollHeight:0),i=Math.max(e?e.clientHeight:0,window.innerHeight||0);if(o<=i)return n=!0,c(),void t(90);((window.scrollY||(e?e.scrollTop:0)||0)+i)/o>=.9&&(n=!0,c(),t(90))}catch(t){}}function i(){if(null===e)try{e=window.requestAnimationFrame(o)}catch(t){o()}}function c(){try{window.removeEventListener("scroll",i),null!==e&&window.cancelAnimationFrame(e),e=null}catch(t){}}try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}return{destroy(){r=!0,c()},reset(){if(!r){n=!1;try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}}}}})(n=>{T(()=>t.track("Scrolled",{percent:n}))}),g.push(()=>null==R?void 0:R.destroy())),c.spa){const n=function(){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let n=P();function e(){try{const e=P();if(e===n)return;n=e,(n=>{T(()=>t.page()),null==R||R.reset(),$(n)})(e)}catch(t){}}const r=history.pushState,o=history.replaceState,i=!0===r[_],c=!0===o[_];if(!i){function a(...t){r.apply(this,t),e()}a[_]=!0,history.pushState=a}if(!c){function l(...t){o.apply(this,t),e()}l[_]=!0,history.replaceState=l}const u=()=>e(),s=()=>e();try{window.addEventListener("popstate",u),window.addEventListener("hashchange",s)}catch(f){}return()=>{try{window.removeEventListener("popstate",u),window.removeEventListener("hashchange",s)}catch(t){}try{!i&&history.pushState[_]&&(history.pushState=r),!c&&history.replaceState[_]&&(history.replaceState=o)}catch(t){}}}();g.push(n)}return $(),()=>{for(;g.length>0;){const t=g.pop();try{null==t||t()}catch(t){}}U=null}}({page(t,n){return N(t,n)},track(t,n){return q(t,n)}},i.autotrack))}catch(t){}},pageview:g,page:N,screen(t,n){try{const e=p();if(!e)return b("screen");const r=((t,n,e)=>{const r=et("screen",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(t,n,e);v().enqueue(r)}catch(t){}},track:q,identify(t,n){try{if("string"!=typeof t||0===t.length)return;((t,n,e={})=>{var r,o;if(t&&(V(ft,t,{domain:e.cookieDomain,maxAgeDays:null!==(r=e.cookieMaxAgeDays)&&void 0!==r?r:730,sameSite:"Lax"}),F(ft,t),null!=n)){const t=null!==(o=(()=>{const t=Z(dt);if(!t)return null;try{const n=JSON.parse(t);return n&&"object"==typeof n&&!Array.isArray(n)?n:null}catch(t){return null}})())&&void 0!==o?o:{},e=Object.assign(Object.assign({},t),n);try{F(dt,JSON.stringify(e))}catch(t){}}})(t,n,{cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays});const e=p();if(!e)return b("identify");const r=((t,n,e)=>{var r;const o=et("identify",e);return t&&(o.userId=t),o.traits=null!==(r=n)&&void 0!==r?r:{},o})(t,n,e);v().enqueue(r)}catch(t){}},alias(t,n){try{if("string"!=typeof t||0===t.length)return;const e=p();if(!e)return b("alias");const r=((t,n,e)=>{const r=et("alias",e);return t&&(r.userId=t),r.previousId=null!=n?n:e.anonymousId,r})(t,n,e);v().enqueue(r)}catch(t){}},group(t,n){try{if("string"!=typeof t||0===t.length)return;const e=p();if(!e)return b("group");const r=((t,n,e)=>{const r=et("group",e);return r.groupId=t,r.traits=null!=n?n:{},r})(t,n,e);v().enqueue(r)}catch(t){}},reset(){try{((t={})=>{((t,n={})=>{var e;if(!J)return!1;try{let r=`${encodeURIComponent(t)}=`;return r+=`; path=${null!==(e=n.path)&&void 0!==e?e:"/"}`,n.domain&&(r+=`; domain=${n.domain}`),r+="; max-age=0",r+="; expires=Thu, 01 Jan 1970 00:00:00 GMT",document.cookie=r,null===E(t)}catch(t){return!1}})(ft,{domain:t.cookieDomain}),G(ft),G(dt)})({cookieDomain:i.cookieDomain}),((t={})=>{Y(B(),t)})({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),((t={})=>{ct({id:B(),lastActivity:Date.now()},t)})({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes})}catch(t){}},flush(){try{s&&s.flush()}catch(t){}},consent(t){try{c=Object.assign(Object.assign({},c),t)}catch(t){}},set(t){try{i=y(t),t.consent&&(c=Object.assign(Object.assign({},c),t.consent)),s&&s.setConfig({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,debug:i.debug})}catch(t){}},destroy(){if(h){try{h()}catch(t){}h=null}s&&s.destroy(),s=null,a=!1,t=null,i=Object.assign({},ht),c=Object.assign({},yt)}}})();"undefined"!=typeof window&&(t=>{if("undefined"==typeof window)return()=>{};const n=window.cnvQ;if(n&&n.__loaded)return()=>{};const e=window.cnvQ=null!=n?n:[],r=e.splice(0,e.length);e.push.bind(e),e.push=(...n)=>{for(const e of n)vt(t,e);return e.length},e.__loaded=!0;for(const n of r)vt(t,n)})(bt);const gt=Object.assign(bt,{version:mt,name:pt,schemaVersion:tt});t.NAME=pt,t.SCHEMA_VERSION=tt,t.VERSION=mt,t.default=gt,Object.defineProperty(t,"t",{value:!0})}(this.cnvTrack=this.cnvTrack||{});
6
+ !function(t){const n=["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 e(t){return!!t&&"object"==typeof t&&1===t.nodeType&&"A"===t.tagName}function r(t){const n=t.lastIndexOf("/");return-1===n?t:t.slice(n+1)}function o(t){var n,e,r;let o=(null!==(n=t.textContent)&&void 0!==n?n:"").trim();return o||(o=(null!==(e=t.getAttribute("aria-label"))&&void 0!==e?e:"").trim()),o||(o=(null!==(r=t.getAttribute("title"))&&void 0!==r?r:"").trim()),o.length>200?o.slice(0,200):o}const i=200;function c(t){let n="";try{n=(t.textContent||"").replace(/\s+/g," ").trim(),n||(n=(t.getAttribute("aria-label")||"").trim()),n||(n=(t.getAttribute("title")||"").trim()),n=n.normalize("NFC")}catch(t){return""}return n.length>i?n.slice(0,i):n}function u(t){const n=!1!==t.caseInsensitive;if("regex"===t.mode)return{mode:"regex",needle:t.value,ci:n,re:m(t.value,n)};const e=t.value.normalize("NFC");return{mode:t.mode,needle:n?e.toLowerCase():e,ci:n,re:null}}function l(t,n){try{return t.matches(n)}catch(t){return!1}}function s(t){try{if("A"===t.tagName){const n=t.getAttribute("href");return n?b(n):null}const n=t.getAttribute("formaction");if(n)return b(n);const e=t.getAttribute("data-href");if(e)return b(e);const r=t.closest("form");if(r){const t=r.getAttribute("action");if(t)return b(t)}return null}catch(t){return null}}function a(t){return"regex"===t.mode?{mode:"regex",needle:t.value,re:m(t.value,!0)}:{mode:t.mode,needle:t.value.toLowerCase(),re:null}}function f(t){if("startsWith"===t.mode)return{mode:"startsWith",needle:t.value,re:null};const n="glob"===t.mode?"^"+t.value.replace(/[.+^${}()|[\]\\?]/g,"\\$&").replace(/\*/g,".*")+"$":t.value;return{mode:t.mode,needle:t.value,re:m(n,!1)}}function d(t,n){return"startsWith"===t.mode?0===n.indexOf(t.needle):!t.re||g(t.re,n)}const h=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,y=/\+?\d[\d\s().-]{7,}\d/g;function v(t){if(!t)return t;try{return t.replace(h,"[email]").replace(y,"[phone]")}catch(n){return t}}function p(t){return!!t&&"object"==typeof t&&1===t.nodeType}function b(t){try{return new URL(t,location.href).href}catch(n){return t}}function m(t,n){try{return!t||t.length>1e3?null:new RegExp(t,n?"i":"")}catch(t){return null}}function g(t,n){try{return t.test(n)}catch(t){return!1}}function w(t,n){if("undefined"==typeof document)return()=>{};const e=(t=>{const n=t.globalThrottle||{},e=[],r=t.rules||[];for(let t=0;t<r.length;t++){const o=r[t];if(!o||!1===o.enabled)continue;if(!o.match||!o.event||!o.event.name)continue;const i=o.match,c=o.throttle||{};e.push({rule:o,elementSpec:x(o),selector:i.selector||null,text:i.text?u(i.text):null,dest:i.destinationUrl?a(i.destinationUrl):null,urlScope:o.urlScope?f(o.urlScope):null,dedupeWindowMs:S(c.dedupeWindowMs,S(n.dedupeWindowMs,500)),maxPerPageview:S(c.maxPerPageview,S(n.maxPerPageview,1/0)),samplingRate:_(S(c.samplingRate,S(n.samplingRate,1)))})}return e.sort((t,n)=>(t.rule.priority||0)-(n.rule.priority||0)),e})(n);if(0===e.length)return()=>{};const r=new WeakMap;let o=0;const i=t=>{let n=r.get(t);return void 0===n&&(n=++o,r.set(t,n)),String(n)},c=new Map,l=new Map;let s=A();function h(n){try{if(0!==n.button)return;const r=A();r!==s&&(s=r,l.clear(),c.clear());const o=(t=>{const n=[];try{const e="function"==typeof t.composedPath?t.composedPath():[];if(e&&e.length>0){for(const t of e)p(t)&&n.push(t);return n}let r=t.target;for(;r;)p(r)&&n.push(r),r=r.parentNode}catch(t){}return n})(n);if(0===o.length)return;const u=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(t){return""}})();for(let r=0;r<e.length;r++){const s=e[r];if(s.urlScope&&!d(s.urlScope,u))continue;let a=null;for(let t=0;t<o.length;t++)if(j(s,o[t])){a=o[t];break}if(!a)continue;const f=s.rule.id;if((l.get(f)||0)>=s.maxPerPageview)return;const h=f+"#"+i(a),y=Date.now(),v=c.get(h);if(void 0!==v&&y-v<s.dedupeWindowMs)return;if(s.samplingRate<1&&Math.random()>=s.samplingRate)return;c.set(h,y),l.set(f,(l.get(f)||0)+1);const p=s.rule.event.name||"Button Clicked",b=k(s.rule,a,n);return void O(()=>t.track(p,b))}}catch(t){}}try{document.addEventListener("click",h,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",h,!0)}catch(t){}c.clear(),l.clear()}}function x(t){const n=t.match;return n.element?n.element:n.selector||n.id||n.dataAttr||n.classes&&n.classes.length>0||n.destinationUrl?"any":void 0}function j(t,n){if(!((t,n)=>{if(!n)return(t=>{const n=t.tagName;if("BUTTON"===n||"A"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")})(t);if("any"===n)return!0;if("button"===n){const n=t.tagName;if("BUTTON"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")}return"link"===n?"A"===t.tagName:l(t,n)})(n,t.elementSpec))return!1;const e=t.rule.match;return!(t.selector&&!l(n,t.selector)||void 0!==e.id&&!((t,n)=>t.id===n)(n,e.id)||e.classes&&e.classes.length>0&&!((t,n)=>{try{for(let e=0;e<n.length;e++)if(!t.classList.contains(n[e]))return!1;return!0}catch(t){return!1}})(n,e.classes)||e.dataAttr&&!((t,n,e)=>{try{return!!t.hasAttribute(n)&&(void 0===e||t.getAttribute(n)===e)}catch(t){return!1}})(n,e.dataAttr.name,e.dataAttr.value)||t.text&&!((t,n)=>{const e=c(t);if("regex"===n.mode)return!!n.re&&g(n.re,e);const r=n.ci?e.toLowerCase():e;return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.text)||t.dest&&!((t,n)=>{const e=s(t);if(!e)return!1;if("regex"===n.mode)return!!n.re&&g(n.re,e);if("domain"===n.mode)try{return new URL(e).host.toLowerCase()===n.needle}catch(t){return!1}const r=e.toLowerCase();return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.dest))}function k(t,n,e){const r={},o=t.event.staticProps;if(o)for(const t of Object.keys(o))r[t]=o[t];const u=t.capture;if(u)try{if(u.text){const t=v(c(n));t&&(r.text=t)}if(u.href){const t=s(n);t&&(r.href=t)}if(u.elementId&&n.id&&(r.element_id=n.id),u.classes&&(r.element_classes=Array.from(n.classList)),u.dataAttrs&&u.dataAttrs.length>0)for(let t=0;t<u.dataAttrs.length;t++){const e=u.dataAttrs[t],o=n.getAttribute(e);null!==o&&(r[e]=v(o))}if(u.valueFrom){const t=((t,n)=>{try{const e=t.querySelector(n.selector)||(t.parentElement?t.parentElement.querySelector(n.selector):null);if(!e)return null;const r=n.attr?e.getAttribute(n.attr):e.textContent||"";if(null===r)return null;const o=v(r.replace(/\s+/g," ").trim());return o.length>i?o.slice(0,i):o}catch(t){return null}})(n,u.valueFrom);null!==t&&(r[u.valueFrom.as]=t)}u.selectorPath&&(r.selector_path=((t,n=5)=>{try{const e=[];let r=t,o=0;for(;r&&1===r.nodeType&&o<n;){let t=r.tagName.toLowerCase();if(r.id){e.unshift(t+"#"+r.id);break}const n=Array.from(r.classList).slice(0,2).join(".");n&&(t+="."+n),e.unshift(t),r=r.parentElement,o++}return e.join(" > ")}catch(t){return""}})(n)),u.position&&(r.x=e.clientX,r.y=e.clientY)}catch(t){}return r.rule_id=t.id,t.name&&(r.rule_name=t.name),r.tag=n.tagName.toLowerCase(),r}function O(t){try{t()}catch(t){}}function A(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}function S(t,n){return"number"!=typeof t||isNaN(t)?n:t}function _(t){return t<0?0:t>1?1:t}const M="__cnvPatched";function T(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}const I=["q","s","query","search","keyword"],P={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},D={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};function U(t){try{t()}catch(t){}}function C(t,n,e,r){return new(e||(e=Promise))((o,i)=>{function c(t){try{l(r.next(t))}catch(t){i(t)}}function u(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(t=>{t(n)})).then(c,u)}l((r=r.apply(t,n||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const N="undefined"!=typeof window&&"undefined"!=typeof document;function R(t){if(!N)return null;try{const n=document.cookie;if(!n)return null;const e=encodeURIComponent(t),r=n.split(";");for(let n=0;n<r.length;n++){const o=r[n].indexOf("=");if(o<0)continue;const i=r[n].slice(0,o).trim();if(i===e||i===t)try{return decodeURIComponent(r[n].slice(o+1))}catch(t){return r[n].slice(o+1)}}return null}catch(t){return null}}function $(t,n,e={}){var r,o,i;if(!N)return!1;try{let c=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(c+=`; path=${null!==(r=e.path)&&void 0!==r?r:"/"}`,e.domain&&(c+=`; domain=${e.domain}`),"number"==typeof e.maxAgeDays){const t=Math.floor(86400*e.maxAgeDays);c+=`; max-age=${t}`,c+=`; expires=${new Date(Date.now()+1e3*t).toUTCString()}`}return c+=`; SameSite=${null!==(o=e.sameSite)&&void 0!==o?o:"Lax"}`,(null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol)&&(c+="; Secure"),document.cookie=c,R(t)===n}catch(t){return!1}}function L(){if(!N)return!1;try{const t="__cnv_probe__";return localStorage.setItem(t,"1"),localStorage.removeItem(t),!0}catch(t){return!1}}function q(t){if(!L())return null;try{return localStorage.getItem(t)}catch(t){return null}}function B(t,n){if(!L())return!1;try{return localStorage.setItem(t,n),!0}catch(t){return!1}}function z(t){if(!L())return!1;try{return localStorage.removeItem(t),!0}catch(t){return!1}}function E(){if(!N)return!1;try{const t="__cnv_probe__";return sessionStorage.setItem(t,"1"),sessionStorage.removeItem(t),!0}catch(t){return!1}}const J={path:"/config",timeoutMs:4e3,ttlMs:3e5};function W(t,n){var e,r;const o=null!=n?n:Object.assign({enabled:!0},J);return void 0===t?Object.assign({},o):!0===t?Object.assign(Object.assign({},o),{enabled:!0}):!1===t?Object.assign(Object.assign({},o),{enabled:!1}):{enabled:null===(e=t.enabled)||void 0===e||e,path:null!==(r=t.path)&&void 0!==r?r:o.path,timeoutMs:"number"==typeof t.timeoutMs?t.timeoutMs:o.timeoutMs,ttlMs:"number"==typeof t.ttlMs?t.ttlMs:o.ttlMs}}function F(t){return"_cnv_cfg_"+t}function V(t){const n=q(F(t));if(!n)return null;try{const t=JSON.parse(n);return t&&"object"==typeof t&&t.envelope?t:null}catch(t){return null}}function H(t,n,e){try{const r={etag:n,envelope:e,fetchedAt:Date.now()};B(F(t),JSON.stringify(r))}catch(t){}}function Z(t){const n=null==t?void 0:t.buttonTracking;if(!n||!1===n.enabled)return null;const e=Array.isArray(n.rules)?n.rules:[];return 0===e.length?null:{rules:e,globalThrottle:n.globalThrottle}}const G=["gclid","fbclid","ttclid","msclkid","dclid"],K=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function Q(t,n){try{return t()}catch(t){return n}}function X(){const t=Q(()=>window.location.href,"");let n="",e="",r="";if(t)try{const o=new URL(t);n=o.pathname,e=o.search,r=o.hash}catch(t){}return{url:t,path:n,search:e,hash:r,title:Q(()=>document.title,""),referrer:Q(()=>document.referrer,"")}}function Y(t){var n,e;let r="@cnv-vn/track",o="0.0.0-dev";try{r="@cnv-vn/track"}catch(t){}try{o="0.2.0-alpha.7"}catch(t){}return{name:null!==(n=null==t?void 0:t.name)&&void 0!==n?n:r,version:null!==(e=null==t?void 0:t.version)&&void 0!==e?e:o}}const tt="0123456789abcdef";function nt(t){return tt[t>>>4&15]+tt[15&t]}function et(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues){const t=new Uint8Array(16);return crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128,nt(t[0])+nt(t[1])+nt(t[2])+nt(t[3])+"-"+nt(t[4])+nt(t[5])+"-"+nt(t[6])+nt(t[7])+"-"+nt(t[8])+nt(t[9])+"-"+nt(t[10])+nt(t[11])+nt(t[12])+nt(t[13])+nt(t[14])+nt(t[15])}}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=16*Math.random()|0;return("x"===t?n:3&n|8).toString(16)})}const rt=/^[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 ot(t){return"string"==typeof t&&rt.test(t)}const it="_cnv_cid";function ct(t={}){const n=R(it),e=q(it);let r=null;return ot(n)?r=n:ot(e)&&(r=e),r||(r=et()),ut(r,t),r}function ut(t,n={}){var e;$(it,t,{domain:n.cookieDomain,maxAgeDays:null!==(e=n.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),B(it,t)}const lt="1.0";function st(){return(new Date).toISOString()}function at(t,n){var e;const r=null!==(e=n.timestamp)&&void 0!==e?e:st(),o=Object.assign(Object.assign({},n.context),{projectId:n.projectId,schemaVersion:lt}),i={type:t,messageId:et(),anonymousId:n.anonymousId,timestamp:r,originalTimestamp:r,context:o};return n.userId&&(i.userId=n.userId),n.sessionId&&(i.sessionId=n.sessionId),n.integrations&&(i.integrations=n.integrations),i}const ft="_cnv_sid";function dt(t){if(!t)return null;const n=t.lastIndexOf(".");if(n<0)return null;const e=t.slice(0,n),r=Number(t.slice(n+1));return!ot(e)||!Number.isFinite(r)||r<=0?null:{id:e,lastActivity:r}}function ht(t={}){const n=Date.now(),e=(t=>{var n;return 6e4*(null!==(n=t.timeoutMinutes)&&void 0!==n?n:30)})(t),r=dt(R(ft)),o=dt((t=>{if(!E())return null;try{return sessionStorage.getItem(t)}catch(t){return null}})(ft));let i=null;for(const t of[r,o])t&&(n-t.lastActivity>e||(!i||t.lastActivity>i.lastActivity)&&(i=t));const c=i?{id:i.id,lastActivity:n}:{id:et(),lastActivity:n};return yt(c,t),c.id}function yt(t,n={}){var e;const r=(t=>`${t.id}.${t.lastActivity}`)(t),o=null!==(e=n.timeoutMinutes)&&void 0!==e?e:30;$(ft,r,{domain:n.cookieDomain,maxAgeDays:o/1440,sameSite:"Lax"}),((t,n)=>{if(!E())return!1;try{return sessionStorage.setItem(t,n),!0}catch(t){return!1}})(ft,r)}class vt{constructor(t){var n,e;Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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!==(n=t.storageKey)&&void 0!==n?n:"_cnv_rq",this.maxMessages=null!==(e=t.maxMessages)&&void 0!==e?e:100,this.installOnlineListener()}stash(t){if(t&&0!==t.length)try{const n=this.read();for(n.push(t);n.length>1&&pt(n)>this.maxMessages;)n.shift();this.write(n),this.config.debug&&console.log("[cnv-track] retry queued",t.length,"buffered",pt(n))}catch(t){}}flush(){if(this.flushing||"undefined"!=typeof navigator&&!1===navigator.onLine)return Promise.resolve();const t=this.read();if(0===t.length)return Promise.resolve();this.flushing=!0,this.write([]);const n=()=>{this.flushing=!1};return t.reduce((t,n)=>t.then(()=>this.config.resend(n)),Promise.resolve()).then(n,n)}size(){return pt(this.read())}clear(){try{z(this.storageKey)}catch(t){}}destroy(){if(this.onlineHandler){try{window.removeEventListener("online",this.onlineHandler)}catch(t){}this.onlineHandler=null}}installOnlineListener(){if("undefined"==typeof window)return;const t=()=>{this.flush()};try{window.addEventListener("online",t),this.onlineHandler=t}catch(t){}}read(){const t=q(this.storageKey);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(t=>Array.isArray(t)&&t.length>0):[]}catch(t){return[]}}write(t){0!==t.length?B(this.storageKey,JSON.stringify(t)):z(this.storageKey)}}function pt(t){let n=0;for(const e of t)n+=e.length;return n}class bt{constructor(t){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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 vt({debug:t.debug,resend:t=>this.send(t)}),this.installPageLifecycleHandlers(),this.retryQueue.flush()}setConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}enqueue(t){this.destroyed||(this.buffer.push(t),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 t=this.buffer;return this.buffer=[],this.send(t)}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(t){try{return this.config.useBatch?this.sendBatch(t):Promise.all(t.map(t=>this.sendSingle(t))).then(()=>{})}catch(t){return this.config.debug&&console.warn("[cnv-track] send failed synchronously; dropped batch",t),Promise.resolve()}}sendBatch(t){var n;const e=st(),r={batch:t.map(t=>mt(t,e)),context:Object.assign(Object.assign({},null!==(n=this.config.batchContext)&&void 0!==n?n:{}),{projectId:this.config.projectId,sentAt:e}),sentAt:e};return this.post(this.batchUrl(),r,t)}sendSingle(t){const n=mt(t,st());return this.post(this.singleUrl(t.type),n,[t])}batchUrl(){return this.config.endpoint+this.config.batchPath+"?projectId="+encodeURIComponent(this.config.projectId)}singleUrl(t){const n=this.config.singlePath.replace("{type}",t);return this.config.endpoint+n+"?projectId="+encodeURIComponent(this.config.projectId)}post(t,n,e){const r=JSON.stringify(n),o=((t,n)=>{try{return new Blob([t],{type:n})}catch(t){return null}})(r,this.config.contentType),i=o?o.size:(t=>{try{return new Blob([t]).size}catch(n){return t.length}})(r),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",t),Promise.resolve()):o&&this.sendViaBeacon(t,o)?(this.config.debug&&console.log("[cnv-track] beacon",t),Promise.resolve()):this.sendViaFetch(t,r,c)}sendViaBeacon(t,n){if("undefined"==typeof navigator||"function"!=typeof navigator.sendBeacon)return!1;if(n.size>65536)return!1;try{return navigator.sendBeacon(t,n)}catch(t){return!1}}sendViaFetch(t,n,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(t,{method:"POST",headers:{"Content-Type":this.config.contentType},body:n,keepalive:!0,credentials:"omit",mode:"cors"}).then(n=>{this.config.debug&&console.log("[cnv-track] fetch flushed",t,n.status)}).catch(n=>{this.config.debug&&console.warn("[cnv-track] flush failed; queued for retry",t,n),e&&this.retryQueue.stash(e)})}installPageLifecycleHandlers(){if("undefined"==typeof window||"undefined"==typeof document)return;const t=()=>{this.flush()},n=()=>{"hidden"===document.visibilityState&&this.flush()};try{window.addEventListener("pagehide",t),document.addEventListener("visibilitychange",n),this.handlers={pagehide:t,visibility:n}}catch(t){}}uninstallPageLifecycleHandlers(){if(this.handlers){try{window.removeEventListener("pagehide",this.handlers.pagehide),document.removeEventListener("visibilitychange",this.handlers.visibility)}catch(t){}this.handlers=null}}}function mt(t,n){return Object.assign(Object.assign({},t),{sentAt:n})}const gt="_cnv_uid",wt="_cnv_traits",xt={endpoint:"http://localhost:8090/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:W(void 0)},jt={analytics:!0,marketing:!0};function kt(t,n){if(!Array.isArray(n)||0===n.length)return;const e=n;try{switch(e[0]){case"init":t.init(e[1],e[2]);break;case"pageview":t.pageview(e[1],e[2]);break;case"page":t.page(e[1],e[2]);break;case"screen":t.screen(e[1],e[2]);break;case"track":t.track(e[1],e[2]);break;case"identify":t.identify(e[1],e[2]);break;case"alias":t.alias(e[1],e[2]);break;case"group":t.group(e[1],e[2]);break;case"reset":t.reset();break;case"flush":t.flush();break;case"consent":t.consent(e[1]);break;case"set":t.set(e[1])}}catch(t){}}const Ot="0.2.0-alpha.7",At="@cnv-vn/track",St=function(){let t=null,i=Object.assign({},xt),c=Object.assign({},jt),u=null,l=!1,s=null,a=null;function f(t){const n=Object.assign({},i);return t?(void 0!==t.endpoint&&(n.endpoint=(e=t.endpoint).endsWith("/")?e.slice(0,-1):e),void 0!==t.batchPath&&(n.batchPath=t.batchPath),void 0!==t.singlePath&&(n.singlePath=t.singlePath),void 0!==t.useBatch&&(n.useBatch=t.useBatch),void 0!==t.contentType&&(n.contentType=t.contentType),void 0!==t.debug&&(n.debug=t.debug),void 0!==t.allowAdTracking&&(n.allowAdTracking=t.allowAdTracking),void 0!==t.cookieDomain&&(n.cookieDomain=t.cookieDomain),void 0!==t.cookieMaxAgeDays&&(n.cookieMaxAgeDays=t.cookieMaxAgeDays),void 0!==t.sessionTimeoutMinutes&&(n.sessionTimeoutMinutes=t.sessionTimeoutMinutes),void 0!==t.flushAt&&(n.flushAt=t.flushAt),void 0!==t.flushInterval&&(n.flushInterval=t.flushInterval),void 0!==t.autoPageview&&(n.autoPageview=t.autoPageview),void 0!==t.autotrack&&(n.autotrack=t.autotrack),void 0!==t.integrations&&(n.integrations=t.integrations),void 0!==t.remoteConfig&&(n.remoteConfig=W(t.remoteConfig,i.remoteConfig)),n):n;var e}function d(){return u||(u=new bt({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,projectId:null!=t?t:"",debug:i.debug}),u)}function h(){var n;if(!t)return null;const e=((t={})=>{var n;const e={page:X(),screen:{width:Q(()=>window.screen.width,0),height:Q(()=>window.screen.height,0),density:Q(()=>window.devicePixelRatio||1,1)},locale:Q(()=>navigator.language||"",""),timezone:Q(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:Q(()=>navigator.userAgent||"",""),library:Y(t.library)},r=((t,n=!0)=>{const e=Q(()=>window.location.search,"");if(!e)return;let r;try{r=new URLSearchParams(e)}catch(t){return}const o={};let i=!1;for(const[t,n]of K){const e=r.get(t);e&&e.length>0&&(o[n]=e,i=!0)}if(n){const t={};for(const n of G){const e=r.get(n);e&&e.length>0&&(t[n]=e)}Object.keys(t).length>0&&(o.clickIds=t,i=!0)}return i?o:void 0})(0,null===(n=t.allowAdTracking)||void 0===n||n);return r&&(e.campaign=r),e})({allowAdTracking:i.allowAdTracking});return c.analytics&&c.marketing||(e.consent=Object.assign({},c)),{anonymousId:ct({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),sessionId:ht({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),userId:null!==(n=R(gt)||q(gt))&&void 0!==n?n:void 0,context:e,projectId:t,integrations:Object.keys(i.integrations).length>0?i.integrations:void 0}}function y(t){i.debug&&console.warn(`[cnv-track] ${t}() called before init()`)}function v(t,n){try{const e=h();if(!e)return y("pageview");const r=((t,n,e)=>{const r=at("page",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(t,((t,n)=>{const e={};return t&&(t.url&&(e.url=t.url),t.path&&(e.path=t.path),t.title&&(e.title=t.title),t.referrer&&(e.referrer=t.referrer),t.search&&(e.search=t.search)),Object.assign(Object.assign({},e),null!=n?n:{})})(e.context.page,n),e);d().enqueue(r)}catch(t){}}function p(t,n){v(t,n)}function b(t,n){try{if("string"!=typeof t||0===t.length)return;const e=h();if(!e)return y("track");const r=((t,n,e)=>{const r=at("track",e);return r.event=t,r.properties=null!=n?n:{},r})(t,n,e);d().enqueue(r)}catch(t){}}return{get initialized(){return l},get projectId(){return t},init(h,y){try{if(!h||"string"!=typeof h)return;if(i=f(y),(null==y?void 0:y.consent)&&(c=Object.assign(Object.assign({},c),y.consent)),t=h,u&&u.destroy(),u=null,d(),l=!0,ct({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),ht({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),i.autoPageview&&v(),s){try{s()}catch(t){}s=null}const m={page(t,n){return p(t,n)},track(t,n){return b(t,n)}};if(i.autotrack){let t=i.autotrack;i.remoteConfig.enabled&&"object"==typeof t&&t.buttonTracking&&(t=Object.assign(Object.assign({},t),{buttonTracking:void 0})),s=function(t,i){const c=void 0===(u=i)||!1===u?Object.assign(Object.assign({},D),{searchParams:I}):!0===u?Object.assign(Object.assign({},P),{searchParams:I}):{spa:null===(l=u.spa)||void 0===l||l,outboundClicks:null===(s=u.outboundClicks)||void 0===s||s,scroll:null===(a=u.scroll)||void 0===a||a,downloads:null===(f=u.downloads)||void 0===f||f,siteSearch:null===(d=u.siteSearch)||void 0===d||d,downloadExtensions:u.downloadExtensions,searchParams:null!==(h=u.searchParams)&&void 0!==h?h:I,buttonTracking:u.buttonTracking};var u,l,s,a,f,d,h;const y=[];let v=null;function p(n){if(c.siteSearch)try{const e=null!=n?n:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(t){return""}})();if(e===v)return;v=e;const r=((t,n=I)=>{try{if(!t){if("undefined"==typeof location)return null;t=location.href}const e=t instanceof URL?t:new URL(t,(()=>{try{return"undefined"!=typeof location?location.href:"http://localhost/"}catch(t){return"http://localhost/"}})());if(!e.search)return null;for(const t of n){const n=e.searchParams.get(t);if(null===n)continue;const r=n.trim();if(0!==r.length)return{query:r,param:t}}return null}catch(t){return null}})(e,c.searchParams);r&&U(()=>t.track("Site Searched",{query:r.query,param:r.param}))}catch(t){}}if(c.outboundClicks||c.downloads){const i=(t=>{var i;if("undefined"==typeof document)return()=>{};const c=new Set((null!==(i=t.downloadExtensions)&&void 0!==i?i:n).map(t=>t.toLowerCase())),u=!!t.onOutbound,l=!!t.onDownload;if(!u&&!l)return()=>{};function s(n){var i,s;try{if(0!==n.button)return;if(n.defaultPrevented)return;const a=(t=>{const n="function"==typeof t.composedPath?t.composedPath():[];if(n.length>0)for(const t of n)if(e(t))return t;let r=t.target;for(;r;){if(e(r))return r;r=r.parentNode}return null})(n);if(!a)return;const f=a.getAttribute("href");if(!f)return;if(/^(javascript:|mailto:|tel:|sms:)/i.test(f))return;if(f.startsWith("#"))return;const d=(t=>{try{return new URL(t,location.href)}catch(t){return null}})(f);if(!d)return;let h=!1;if(l){const n=a.hasAttribute("download"),e=(t=>{const n=r(t),e=n.lastIndexOf(".");return e<=0||e===n.length-1?null:n.slice(e+1).toLowerCase()})(d.pathname);(n||e&&c.has(e))&&(h=!0,null===(i=t.onDownload)||void 0===i||i.call(t,{url:d.href,fileName:r(d.pathname),fileExtension:null!=e?e:"",text:o(a)}))}u&&!h&&d.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(t){return""}})()&&d.host&&(null===(s=t.onOutbound)||void 0===s||s.call(t,{url:d.href,host:d.host,text:o(a),target:a.target||"_self"}))}catch(t){}}try{document.addEventListener("click",s,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",s,!0)}catch(t){}}})({downloadExtensions:c.downloadExtensions,onOutbound:c.outboundClicks?n=>U(()=>t.track("Outbound Link Clicked",n)):void 0,onDownload:c.downloads?n=>U(()=>t.track("File Downloaded",n)):void 0});y.push(i)}c.buttonTracking&&c.buttonTracking.rules&&c.buttonTracking.rules.length>0&&y.push(w(t,c.buttonTracking));let b=null;if(c.scroll&&(b=(t=>{if("undefined"==typeof window||"undefined"==typeof document)return{destroy(){},reset(){}};let n=!1,e=null,r=!1;function o(){if(e=null,!r&&!n)try{const e=document.documentElement,r=document.body,o=Math.max(e?e.scrollHeight:0,r?r.scrollHeight:0),i=Math.max(e?e.clientHeight:0,window.innerHeight||0);if(o<=i)return n=!0,c(),void t(90);((window.scrollY||(e?e.scrollTop:0)||0)+i)/o>=.9&&(n=!0,c(),t(90))}catch(t){}}function i(){if(null===e)try{e=window.requestAnimationFrame(o)}catch(t){o()}}function c(){try{window.removeEventListener("scroll",i),null!==e&&window.cancelAnimationFrame(e),e=null}catch(t){}}try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}return{destroy(){r=!0,c()},reset(){if(!r){n=!1;try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}}}}})(n=>{U(()=>t.track("Scrolled",{percent:n}))}),y.push(()=>null==b?void 0:b.destroy())),c.spa){const n=[],e=function(){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let e=T();function r(){try{const r=T();if(r===e)return;e=r,(e=>{const r=setTimeout(()=>{const e=n.indexOf(r);-1!==e&&n.splice(e,1),U(()=>t.page())},0);n.push(r),null==b||b.reset(),p(e)})(r)}catch(t){}}const o=history.pushState,i=history.replaceState,c=!0===o[M],u=!0===i[M];if(!c){function a(...t){o.apply(this,t),r()}a[M]=!0,history.pushState=a}if(!u){function f(...t){i.apply(this,t),r()}f[M]=!0,history.replaceState=f}const l=()=>r(),s=()=>r();try{window.addEventListener("popstate",l),window.addEventListener("hashchange",s)}catch(d){}return()=>{try{window.removeEventListener("popstate",l),window.removeEventListener("hashchange",s)}catch(t){}try{!c&&history.pushState[M]&&(history.pushState=o),!u&&history.replaceState[M]&&(history.replaceState=i)}catch(t){}}}();y.push(()=>{for(let t=0;t<n.length;t++)clearTimeout(n[t]);n.length=0,e()})}return p(),()=>{for(;y.length>0;){const t=y.pop();try{null==t||t()}catch(t){}}v=null}}(m,t)}if(a){try{a()}catch(t){}a=null}if(i.remoteConfig.enabled&&t){const n=t=>{if(a){try{a()}catch(t){}a=null}t&&t.rules&&t.rules.length>0&&(a=w(m,t))},e=(t=>{const n=V(t);return n?Z(n.envelope):null})(t);e&&n(e),function(t){return C(this,void 0,void 0,function*(){if(!t.projectId)return{status:"error"};const n=V(t.projectId);if(n&&Date.now()-n.fetchedAt<t.ttlMs)return{status:"unchanged"};const e=yield function(t){return C(this,void 0,void 0,function*(){var n;if("function"!=typeof fetch)return null;const e=t.endpoint+t.path+"?projectId="+encodeURIComponent(t.projectId),r="undefined"!=typeof AbortController?new AbortController:null,o=r?setTimeout(()=>r.abort(),t.timeoutMs):null;try{const o={};t.etag&&(o["If-None-Match"]=t.etag);const i=yield fetch(e,{method:"GET",headers:o,credentials:"omit",mode:"cors",signal:r?r.signal:void 0});if(304===i.status)return{envelope:null,etag:null!==(n=t.etag)&&void 0!==n?n:"",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(t){return null}finally{o&&clearTimeout(o)}})}({endpoint:t.endpoint,path:t.path,projectId:t.projectId,timeoutMs:t.timeoutMs,etag:null==n?void 0:n.etag});return e?e.notModified?(n&&H(t.projectId,n.etag,n.envelope),{status:"unchanged"}):e.envelope?(H(t.projectId,e.etag,e.envelope),{status:"updated",buttonTracking:Z(e.envelope)}):{status:"error"}:{status:"error"}})}({endpoint:i.endpoint,path:i.remoteConfig.path,projectId:t,timeoutMs:i.remoteConfig.timeoutMs,ttlMs:i.remoteConfig.ttlMs}).then(t=>{"updated"===t.status&&n(t.buttonTracking)}).catch(()=>{})}}catch(t){}},pageview:v,page:p,screen(t,n){try{const e=h();if(!e)return y("screen");const r=((t,n,e)=>{const r=at("screen",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(t,n,e);d().enqueue(r)}catch(t){}},track:b,identify(t,n){try{if("string"!=typeof t||0===t.length)return;((t,n,e={})=>{var r,o;if(t&&($(gt,t,{domain:e.cookieDomain,maxAgeDays:null!==(r=e.cookieMaxAgeDays)&&void 0!==r?r:730,sameSite:"Lax"}),B(gt,t),null!=n)){const t=null!==(o=(()=>{const t=q(wt);if(!t)return null;try{const n=JSON.parse(t);return n&&"object"==typeof n&&!Array.isArray(n)?n:null}catch(t){return null}})())&&void 0!==o?o:{},e=Object.assign(Object.assign({},t),n);try{B(wt,JSON.stringify(e))}catch(t){}}})(t,n,{cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays});const e=h();if(!e)return y("identify");const r=((t,n,e)=>{var r;const o=at("identify",e);return t&&(o.userId=t),o.traits=null!==(r=n)&&void 0!==r?r:{},o})(t,n,e);d().enqueue(r)}catch(t){}},alias(t,n){try{if("string"!=typeof t||0===t.length)return;const e=h();if(!e)return y("alias");const r=((t,n,e)=>{const r=at("alias",e);return t&&(r.userId=t),r.previousId=null!=n?n:e.anonymousId,r})(t,n,e);d().enqueue(r)}catch(t){}},group(t,n){try{if("string"!=typeof t||0===t.length)return;const e=h();if(!e)return y("group");const r=((t,n,e)=>{const r=at("group",e);return r.groupId=t,r.traits=null!=n?n:{},r})(t,n,e);d().enqueue(r)}catch(t){}},reset(){try{((t={})=>{((t,n={})=>{var e;if(!N)return!1;try{let r=`${encodeURIComponent(t)}=`;return r+=`; path=${null!==(e=n.path)&&void 0!==e?e:"/"}`,n.domain&&(r+=`; domain=${n.domain}`),r+="; max-age=0",r+="; expires=Thu, 01 Jan 1970 00:00:00 GMT",document.cookie=r,null===R(t)}catch(t){return!1}})(gt,{domain:t.cookieDomain}),z(gt),z(wt)})({cookieDomain:i.cookieDomain}),((t={})=>{ut(et(),t)})({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),((t={})=>{yt({id:et(),lastActivity:Date.now()},t)})({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes})}catch(t){}},flush(){try{u&&u.flush()}catch(t){}},consent(t){try{c=Object.assign(Object.assign({},c),t)}catch(t){}},set(t){try{i=f(t),t.consent&&(c=Object.assign(Object.assign({},c),t.consent)),u&&u.setConfig({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,debug:i.debug})}catch(t){}},destroy(){if(s){try{s()}catch(t){}s=null}if(a){try{a()}catch(t){}a=null}u&&u.destroy(),u=null,l=!1,t=null,i=Object.assign({},xt),c=Object.assign({},jt)}}}();"undefined"!=typeof window&&(t=>{if("undefined"==typeof window)return()=>{};const n=window.cnvQ;if(n&&n.__loaded)return()=>{};const e=window.cnvQ=null!=n?n:[],r=e.splice(0,e.length);e.push.bind(e),e.push=(...n)=>{for(const e of n)kt(t,e);return e.length},e.__loaded=!0;for(const n of r)kt(t,n)})(St);const _t=Object.assign(St,{version:Ot,name:At,schemaVersion:lt});t.NAME=At,t.SCHEMA_VERSION=lt,t.VERSION=Ot,t.default=_t,Object.defineProperty(t,"t",{value:!0})}(this.cnvTrack=this.cnvTrack||{});
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @cnv-vn/track v0.2.0-alpha.5
2
+ * @cnv-vn/track v0.2.0-alpha.7
3
3
  * (c) 2026 CNV
4
4
  * Released under the UNLICENSED license.
5
5
  */
6
- var t,n;t=this,n=function(t){const n=["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 e(t){return!!t&&"object"==typeof t&&1===t.nodeType&&"A"===t.tagName}function r(t){const n=t.lastIndexOf("/");return-1===n?t:t.slice(n+1)}function o(t){var n,e,r;let o=(null!==(n=t.textContent)&&void 0!==n?n:"").trim();return o||(o=(null!==(e=t.getAttribute("aria-label"))&&void 0!==e?e:"").trim()),o||(o=(null!==(r=t.getAttribute("title"))&&void 0!==r?r:"").trim()),o.length>200?o.slice(0,200):o}const i=200;function c(t){let n="";try{n=(t.textContent||"").replace(/\s+/g," ").trim(),n||(n=(t.getAttribute("aria-label")||"").trim()),n||(n=(t.getAttribute("title")||"").trim())}catch(t){return""}return n.length>i?n.slice(0,i):n}function u(t){const n=!1!==t.caseInsensitive;return"regex"===t.mode?{mode:"regex",needle:t.value,ci:n,re:b(t.value,n)}:{mode:t.mode,needle:n?t.value.toLowerCase():t.value,ci:n,re:null}}function s(t,n){try{return t.matches(n)}catch(t){return!1}}function a(t){try{if("A"===t.tagName){const n=t.getAttribute("href");return n?m(n):null}const n=t.getAttribute("formaction");if(n)return m(n);const e=t.getAttribute("data-href");if(e)return m(e);const r=t.closest("form");if(r){const t=r.getAttribute("action");if(t)return m(t)}return null}catch(t){return null}}function l(t){return"regex"===t.mode?{mode:"regex",needle:t.value,re:b(t.value,!0)}:{mode:t.mode,needle:t.value.toLowerCase(),re:null}}function f(t){if("startsWith"===t.mode)return{mode:"startsWith",needle:t.value,re:null};const n="glob"===t.mode?"^"+t.value.replace(/[.+^${}()|[\]\\?]/g,"\\$&").replace(/\*/g,".*")+"$":t.value;return{mode:t.mode,needle:t.value,re:b(n,!1)}}function d(t,n){return"startsWith"===t.mode?0===n.indexOf(t.needle):!t.re||g(t.re,n)}const h=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,y=/\+?\d[\d\s().-]{7,}\d/g;function v(t){if(!t)return t;try{return t.replace(h,"[email]").replace(y,"[phone]")}catch(n){return t}}function p(t){return!!t&&"object"==typeof t&&1===t.nodeType}function m(t){try{return new URL(t,location.href).href}catch(n){return t}}function b(t,n){try{return!t||t.length>1e3?null:new RegExp(t,n?"i":"")}catch(t){return null}}function g(t,n){try{return t.test(n)}catch(t){return!1}}function w(t){const n=t.match;return n.element?n.element:n.selector||n.id||n.dataAttr||n.classes&&n.classes.length>0||n.destinationUrl?"any":void 0}function x(t,n){if(!((t,n)=>{if(!n)return(t=>{const n=t.tagName;if("BUTTON"===n||"A"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")})(t);if("any"===n)return!0;if("button"===n){const n=t.tagName;if("BUTTON"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")}return"link"===n?"A"===t.tagName:s(t,n)})(n,t.elementSpec))return!1;const e=t.rule.match;return!(t.selector&&!s(n,t.selector)||void 0!==e.id&&!((t,n)=>t.id===n)(n,e.id)||e.classes&&e.classes.length>0&&!((t,n)=>{try{for(let e=0;e<n.length;e++)if(!t.classList.contains(n[e]))return!1;return!0}catch(t){return!1}})(n,e.classes)||e.dataAttr&&!((t,n,e)=>{try{return!!t.hasAttribute(n)&&(void 0===e||t.getAttribute(n)===e)}catch(t){return!1}})(n,e.dataAttr.name,e.dataAttr.value)||t.text&&!((t,n)=>{const e=c(t);if("regex"===n.mode)return!!n.re&&g(n.re,e);const r=n.ci?e.toLowerCase():e;return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.text)||t.dest&&!((t,n)=>{const e=a(t);if(!e)return!1;if("regex"===n.mode)return!!n.re&&g(n.re,e);if("domain"===n.mode)try{return new URL(e).host.toLowerCase()===n.needle}catch(t){return!1}const r=e.toLowerCase();return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.dest))}function k(t,n,e){const r={},o=t.event.staticProps;if(o)for(const t of Object.keys(o))r[t]=o[t];const u=t.capture;if(u)try{if(u.text){const t=v(c(n));t&&(r.text=t)}if(u.href){const t=a(n);t&&(r.href=t)}if(u.elementId&&n.id&&(r.element_id=n.id),u.classes&&(r.element_classes=Array.from(n.classList)),u.dataAttrs&&u.dataAttrs.length>0)for(let t=0;t<u.dataAttrs.length;t++){const e=u.dataAttrs[t],o=n.getAttribute(e);null!==o&&(r[e]=v(o))}if(u.valueFrom){const t=((t,n)=>{try{const e=t.querySelector(n.selector)||(t.parentElement?t.parentElement.querySelector(n.selector):null);if(!e)return null;const r=n.attr?e.getAttribute(n.attr):e.textContent||"";if(null===r)return null;const o=v(r.replace(/\s+/g," ").trim());return o.length>i?o.slice(0,i):o}catch(t){return null}})(n,u.valueFrom);null!==t&&(r[u.valueFrom.as]=t)}u.selectorPath&&(r.selector_path=((t,n=5)=>{try{const e=[];let r=t,o=0;for(;r&&1===r.nodeType&&o<n;){let t=r.tagName.toLowerCase();if(r.id){e.unshift(t+"#"+r.id);break}const n=Array.from(r.classList).slice(0,2).join(".");n&&(t+="."+n),e.unshift(t),r=r.parentElement,o++}return e.join(" > ")}catch(t){return""}})(n)),u.position&&(r.x=e.clientX,r.y=e.clientY)}catch(t){}return r.rule_id=t.id,t.name&&(r.rule_name=t.name),r.tag=n.tagName.toLowerCase(),r}function j(t){try{t()}catch(t){}}function O(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}function A(t,n){return"number"!=typeof t||isNaN(t)?n:t}function S(t){return t<0?0:t>1?1:t}const _="__cnvPatched";function P(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}const I=["q","s","query","search","keyword"],D={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},T={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};function M(t){try{t()}catch(t){}}const U=["gclid","fbclid","ttclid","msclkid","dclid"],$=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function R(t,n){try{return t()}catch(t){return n}}function C(){const t=R(()=>window.location.href,"");let n="",e="",r="";if(t)try{const o=new URL(t);n=o.pathname,e=o.search,r=o.hash}catch(t){}return{url:t,path:n,search:e,hash:r,title:R(()=>document.title,""),referrer:R(()=>document.referrer,"")}}function L(t){var n,e;let r="@cnv-vn/track",o="0.0.0-dev";try{r="@cnv-vn/track"}catch(t){}try{o="0.2.0-alpha.5"}catch(t){}return{name:null!==(n=null==t?void 0:t.name)&&void 0!==n?n:r,version:null!==(e=null==t?void 0:t.version)&&void 0!==e?e:o}}const N="0123456789abcdef";function q(t){return N[t>>>4&15]+N[15&t]}function B(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues){const t=new Uint8Array(16);return crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128,q(t[0])+q(t[1])+q(t[2])+q(t[3])+"-"+q(t[4])+q(t[5])+"-"+q(t[6])+q(t[7])+"-"+q(t[8])+q(t[9])+"-"+q(t[10])+q(t[11])+q(t[12])+q(t[13])+q(t[14])+q(t[15])}}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=16*Math.random()|0;return("x"===t?n:3&n|8).toString(16)})}const z=/^[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 W(t){return"string"==typeof t&&z.test(t)}const J="undefined"!=typeof window&&"undefined"!=typeof document;function E(t){if(!J)return null;try{const n=document.cookie;if(!n)return null;const e=encodeURIComponent(t),r=n.split(";");for(let n=0;n<r.length;n++){const o=r[n].indexOf("=");if(o<0)continue;const i=r[n].slice(0,o).trim();if(i===e||i===t)try{return decodeURIComponent(r[n].slice(o+1))}catch(t){return r[n].slice(o+1)}}return null}catch(t){return null}}function V(t,n,e={}){var r,o,i;if(!J)return!1;try{let c=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(c+=`; path=${null!==(r=e.path)&&void 0!==r?r:"/"}`,e.domain&&(c+=`; domain=${e.domain}`),"number"==typeof e.maxAgeDays){const t=Math.floor(86400*e.maxAgeDays);c+=`; max-age=${t}`,c+=`; expires=${new Date(Date.now()+1e3*t).toUTCString()}`}return c+=`; SameSite=${null!==(o=e.sameSite)&&void 0!==o?o:"Lax"}`,(null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol)&&(c+="; Secure"),document.cookie=c,E(t)===n}catch(t){return!1}}function H(){if(!J)return!1;try{const t="__cnv_probe__";return localStorage.setItem(t,"1"),localStorage.removeItem(t),!0}catch(t){return!1}}function Z(t){if(!H())return null;try{return localStorage.getItem(t)}catch(t){return null}}function F(t,n){if(!H())return!1;try{return localStorage.setItem(t,n),!0}catch(t){return!1}}function G(t){if(!H())return!1;try{return localStorage.removeItem(t),!0}catch(t){return!1}}function K(){if(!J)return!1;try{const t="__cnv_probe__";return sessionStorage.setItem(t,"1"),sessionStorage.removeItem(t),!0}catch(t){return!1}}const Q="_cnv_cid";function X(t={}){const n=E(Q),e=Z(Q);let r=null;return W(n)?r=n:W(e)&&(r=e),r||(r=B()),Y(r,t),r}function Y(t,n={}){var e;V(Q,t,{domain:n.cookieDomain,maxAgeDays:null!==(e=n.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),F(Q,t)}const tt="1.0";function nt(){return(new Date).toISOString()}function et(t,n){var e;const r=null!==(e=n.timestamp)&&void 0!==e?e:nt(),o=Object.assign(Object.assign({},n.context),{projectId:n.projectId,schemaVersion:tt}),i={type:t,messageId:B(),anonymousId:n.anonymousId,timestamp:r,originalTimestamp:r,context:o};return n.userId&&(i.userId=n.userId),n.sessionId&&(i.sessionId=n.sessionId),n.integrations&&(i.integrations=n.integrations),i}const rt="_cnv_sid";function ot(t){if(!t)return null;const n=t.lastIndexOf(".");if(n<0)return null;const e=t.slice(0,n),r=Number(t.slice(n+1));return!W(e)||!Number.isFinite(r)||r<=0?null:{id:e,lastActivity:r}}function it(t={}){const n=Date.now(),e=(t=>{var n;return 6e4*(null!==(n=t.timeoutMinutes)&&void 0!==n?n:30)})(t),r=ot(E(rt)),o=ot((t=>{if(!K())return null;try{return sessionStorage.getItem(t)}catch(t){return null}})(rt));let i=null;for(const t of[r,o])t&&(n-t.lastActivity>e||(!i||t.lastActivity>i.lastActivity)&&(i=t));const c=i?{id:i.id,lastActivity:n}:{id:B(),lastActivity:n};return ct(c,t),c.id}function ct(t,n={}){var e;const r=(t=>`${t.id}.${t.lastActivity}`)(t),o=null!==(e=n.timeoutMinutes)&&void 0!==e?e:30;V(rt,r,{domain:n.cookieDomain,maxAgeDays:o/1440,sameSite:"Lax"}),((t,n)=>{if(!K())return!1;try{return sessionStorage.setItem(t,n),!0}catch(t){return!1}})(rt,r)}class ut{constructor(t){var n,e;Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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!==(n=t.storageKey)&&void 0!==n?n:"_cnv_rq",this.maxMessages=null!==(e=t.maxMessages)&&void 0!==e?e:100,this.installOnlineListener()}stash(t){if(t&&0!==t.length)try{const n=this.read();for(n.push(t);n.length>1&&st(n)>this.maxMessages;)n.shift();this.write(n),this.config.debug&&console.log("[cnv-track] retry queued",t.length,"buffered",st(n))}catch(t){}}flush(){if(this.flushing||"undefined"!=typeof navigator&&!1===navigator.onLine)return Promise.resolve();const t=this.read();if(0===t.length)return Promise.resolve();this.flushing=!0,this.write([]);const n=()=>{this.flushing=!1};return t.reduce((t,n)=>t.then(()=>this.config.resend(n)),Promise.resolve()).then(n,n)}size(){return st(this.read())}clear(){try{G(this.storageKey)}catch(t){}}destroy(){if(this.onlineHandler){try{window.removeEventListener("online",this.onlineHandler)}catch(t){}this.onlineHandler=null}}installOnlineListener(){if("undefined"==typeof window)return;const t=()=>{this.flush()};try{window.addEventListener("online",t),this.onlineHandler=t}catch(t){}}read(){const t=Z(this.storageKey);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(t=>Array.isArray(t)&&t.length>0):[]}catch(t){return[]}}write(t){0!==t.length?F(this.storageKey,JSON.stringify(t)):G(this.storageKey)}}function st(t){let n=0;for(const e of t)n+=e.length;return n}class at{constructor(t){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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 ut({debug:t.debug,resend:t=>this.send(t)}),this.installPageLifecycleHandlers(),this.retryQueue.flush()}setConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}enqueue(t){this.destroyed||(this.buffer.push(t),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 t=this.buffer;return this.buffer=[],this.send(t)}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(t){try{return this.config.useBatch?this.sendBatch(t):Promise.all(t.map(t=>this.sendSingle(t))).then(()=>{})}catch(t){return this.config.debug&&console.warn("[cnv-track] send failed synchronously; dropped batch",t),Promise.resolve()}}sendBatch(t){var n;const e=nt(),r={batch:t.map(t=>lt(t,e)),context:Object.assign(Object.assign({},null!==(n=this.config.batchContext)&&void 0!==n?n:{}),{projectId:this.config.projectId,sentAt:e}),sentAt:e};return this.post(this.batchUrl(),r,t)}sendSingle(t){const n=lt(t,nt());return this.post(this.singleUrl(t.type),n,[t])}batchUrl(){return this.config.endpoint+this.config.batchPath+"?projectId="+encodeURIComponent(this.config.projectId)}singleUrl(t){const n=this.config.singlePath.replace("{type}",t);return this.config.endpoint+n+"?projectId="+encodeURIComponent(this.config.projectId)}post(t,n,e){const r=JSON.stringify(n),o=((t,n)=>{try{return new Blob([t],{type:n})}catch(t){return null}})(r,this.config.contentType),i=o?o.size:(t=>{try{return new Blob([t]).size}catch(n){return t.length}})(r),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",t),Promise.resolve()):o&&this.sendViaBeacon(t,o)?(this.config.debug&&console.log("[cnv-track] beacon",t),Promise.resolve()):this.sendViaFetch(t,r,c)}sendViaBeacon(t,n){if("undefined"==typeof navigator||"function"!=typeof navigator.sendBeacon)return!1;if(n.size>65536)return!1;try{return navigator.sendBeacon(t,n)}catch(t){return!1}}sendViaFetch(t,n,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(t,{method:"POST",headers:{"Content-Type":this.config.contentType},body:n,keepalive:!0,credentials:"omit",mode:"cors"}).then(n=>{this.config.debug&&console.log("[cnv-track] fetch flushed",t,n.status)}).catch(n=>{this.config.debug&&console.warn("[cnv-track] flush failed; queued for retry",t,n),e&&this.retryQueue.stash(e)})}installPageLifecycleHandlers(){if("undefined"==typeof window||"undefined"==typeof document)return;const t=()=>{this.flush()},n=()=>{"hidden"===document.visibilityState&&this.flush()};try{window.addEventListener("pagehide",t),document.addEventListener("visibilitychange",n),this.handlers={pagehide:t,visibility:n}}catch(t){}}uninstallPageLifecycleHandlers(){if(this.handlers){try{window.removeEventListener("pagehide",this.handlers.pagehide),document.removeEventListener("visibilitychange",this.handlers.visibility)}catch(t){}this.handlers=null}}}function lt(t,n){return Object.assign(Object.assign({},t),{sentAt:n})}const ft="_cnv_uid",dt="_cnv_traits",ht={endpoint:"http://localhost:8090/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:{}},yt={analytics:!0,marketing:!0};function vt(t,n){if(!Array.isArray(n)||0===n.length)return;const e=n;try{switch(e[0]){case"init":t.init(e[1],e[2]);break;case"pageview":t.pageview(e[1],e[2]);break;case"page":t.page(e[1],e[2]);break;case"screen":t.screen(e[1],e[2]);break;case"track":t.track(e[1],e[2]);break;case"identify":t.identify(e[1],e[2]);break;case"alias":t.alias(e[1],e[2]);break;case"group":t.group(e[1],e[2]);break;case"reset":t.reset();break;case"flush":t.flush();break;case"consent":t.consent(e[1]);break;case"set":t.set(e[1])}}catch(t){}}const pt="0.2.0-alpha.5",mt="@cnv-vn/track",bt=(()=>{let t=null,i=Object.assign({},ht),c=Object.assign({},yt),s=null,a=!1,h=null;function y(t){const n=Object.assign({},i);return t?(void 0!==t.endpoint&&(n.endpoint=(e=t.endpoint).endsWith("/")?e.slice(0,-1):e),void 0!==t.batchPath&&(n.batchPath=t.batchPath),void 0!==t.singlePath&&(n.singlePath=t.singlePath),void 0!==t.useBatch&&(n.useBatch=t.useBatch),void 0!==t.contentType&&(n.contentType=t.contentType),void 0!==t.debug&&(n.debug=t.debug),void 0!==t.allowAdTracking&&(n.allowAdTracking=t.allowAdTracking),void 0!==t.cookieDomain&&(n.cookieDomain=t.cookieDomain),void 0!==t.cookieMaxAgeDays&&(n.cookieMaxAgeDays=t.cookieMaxAgeDays),void 0!==t.sessionTimeoutMinutes&&(n.sessionTimeoutMinutes=t.sessionTimeoutMinutes),void 0!==t.flushAt&&(n.flushAt=t.flushAt),void 0!==t.flushInterval&&(n.flushInterval=t.flushInterval),void 0!==t.autoPageview&&(n.autoPageview=t.autoPageview),void 0!==t.autotrack&&(n.autotrack=t.autotrack),void 0!==t.integrations&&(n.integrations=t.integrations),n):n;var e}function v(){return s||(s=new at({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,projectId:null!=t?t:"",debug:i.debug}),s)}function m(){var n;if(!t)return null;const e=((t={})=>{var n;const e={page:C(),screen:{width:R(()=>window.screen.width,0),height:R(()=>window.screen.height,0),density:R(()=>window.devicePixelRatio||1,1)},locale:R(()=>navigator.language||"",""),timezone:R(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:R(()=>navigator.userAgent||"",""),library:L(t.library)},r=((t,n=!0)=>{const e=R(()=>window.location.search,"");if(!e)return;let r;try{r=new URLSearchParams(e)}catch(t){return}const o={};let i=!1;for(const[t,n]of $){const e=r.get(t);e&&e.length>0&&(o[n]=e,i=!0)}if(n){const t={};for(const n of U){const e=r.get(n);e&&e.length>0&&(t[n]=e)}Object.keys(t).length>0&&(o.clickIds=t,i=!0)}return i?o:void 0})(0,null===(n=t.allowAdTracking)||void 0===n||n);return r&&(e.campaign=r),e})({allowAdTracking:i.allowAdTracking});return c.analytics&&c.marketing||(e.consent=Object.assign({},c)),{anonymousId:X({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),sessionId:it({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),userId:null!==(n=E(ft)||Z(ft))&&void 0!==n?n:void 0,context:e,projectId:t,integrations:Object.keys(i.integrations).length>0?i.integrations:void 0}}function b(t){i.debug&&console.warn(`[cnv-track] ${t}() called before init()`)}function g(t,n){try{const e=m();if(!e)return b("pageview");const r=((t,n,e)=>{const r=et("page",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(null!=t?t:(()=>{try{return"undefined"!=typeof document&&document.title||void 0}catch(t){return}})(),n,e);v().enqueue(r)}catch(t){}}function N(t,n){g(t,n)}function q(t,n){try{if("string"!=typeof t||0===t.length)return;const e=m();if(!e)return b("track");const r=((t,n,e)=>{const r=et("track",e);return r.event=t,r.properties=null!=n?n:{},r})(t,n,e);v().enqueue(r)}catch(t){}}return{get initialized(){return a},get projectId(){return t},init(m,b){try{if(!m||"string"!=typeof m)return;if(i=y(b),(null==b?void 0:b.consent)&&(c=Object.assign(Object.assign({},c),b.consent)),t=m,s&&s.destroy(),s=null,v(),a=!0,X({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),it({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),i.autoPageview&&g(),h){try{h()}catch(t){}h=null}i.autotrack&&(h=function(t,i){const c=void 0===(s=i)||!1===s?Object.assign(Object.assign({},T),{searchParams:I}):!0===s?Object.assign(Object.assign({},D),{searchParams:I}):{spa:null===(a=s.spa)||void 0===a||a,outboundClicks:null===(h=s.outboundClicks)||void 0===h||h,scroll:null===(y=s.scroll)||void 0===y||y,downloads:null===(v=s.downloads)||void 0===v||v,siteSearch:null===(m=s.siteSearch)||void 0===m||m,downloadExtensions:s.downloadExtensions,searchParams:null!==(b=s.searchParams)&&void 0!==b?b:I,buttonTracking:s.buttonTracking};var s,a,h,y,v,m,b;const g=[];let U=null;function $(n){if(c.siteSearch)try{const e=null!=n?n:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(t){return""}})();if(e===U)return;U=e;const r=((t,n=I)=>{try{if(!t){if("undefined"==typeof location)return null;t=location.href}const e=t instanceof URL?t:new URL(t,(()=>{try{return"undefined"!=typeof location?location.href:"http://localhost/"}catch(t){return"http://localhost/"}})());if(!e.search)return null;for(const t of n){const n=e.searchParams.get(t);if(null===n)continue;const r=n.trim();if(0!==r.length)return{query:r,param:t}}return null}catch(t){return null}})(e,c.searchParams);r&&M(()=>t.track("Site Searched",{query:r.query,param:r.param}))}catch(t){}}if(c.outboundClicks||c.downloads){const i=(t=>{var i;if("undefined"==typeof document)return()=>{};const c=new Set((null!==(i=t.downloadExtensions)&&void 0!==i?i:n).map(t=>t.toLowerCase())),u=!!t.onOutbound,s=!!t.onDownload;if(!u&&!s)return()=>{};function a(n){var i,a;try{if(0!==n.button)return;if(n.defaultPrevented)return;const l=(t=>{const n="function"==typeof t.composedPath?t.composedPath():[];if(n.length>0)for(const t of n)if(e(t))return t;let r=t.target;for(;r;){if(e(r))return r;r=r.parentNode}return null})(n);if(!l)return;const f=l.getAttribute("href");if(!f)return;if(/^(javascript:|mailto:|tel:|sms:)/i.test(f))return;if(f.startsWith("#"))return;const d=(t=>{try{return new URL(t,location.href)}catch(t){return null}})(f);if(!d)return;let h=!1;if(s){const n=l.hasAttribute("download"),e=(t=>{const n=r(t),e=n.lastIndexOf(".");return e<=0||e===n.length-1?null:n.slice(e+1).toLowerCase()})(d.pathname);(n||e&&c.has(e))&&(h=!0,null===(i=t.onDownload)||void 0===i||i.call(t,{url:d.href,fileName:r(d.pathname),fileExtension:null!=e?e:"",text:o(l)}))}u&&!h&&d.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(t){return""}})()&&d.host&&(null===(a=t.onOutbound)||void 0===a||a.call(t,{url:d.href,host:d.host,text:o(l),target:l.target||"_self"}))}catch(t){}}try{document.addEventListener("click",a,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",a,!0)}catch(t){}}})({downloadExtensions:c.downloadExtensions,onOutbound:c.outboundClicks?n=>M(()=>t.track("Outbound Link Clicked",n)):void 0,onDownload:c.downloads?n=>M(()=>t.track("File Downloaded",n)):void 0});g.push(i)}c.buttonTracking&&c.buttonTracking.rules&&c.buttonTracking.rules.length>0&&g.push(((t,n)=>{if("undefined"==typeof document)return()=>{};const e=(t=>{const n=t.globalThrottle||{},e=[],r=t.rules||[];for(let t=0;t<r.length;t++){const o=r[t];if(!o||!1===o.enabled)continue;if(!o.match||!o.event||!o.event.name)continue;const i=o.match,c=o.throttle||{};e.push({rule:o,elementSpec:w(o),selector:i.selector||null,text:i.text?u(i.text):null,dest:i.destinationUrl?l(i.destinationUrl):null,urlScope:o.urlScope?f(o.urlScope):null,dedupeWindowMs:A(c.dedupeWindowMs,A(n.dedupeWindowMs,500)),maxPerPageview:A(c.maxPerPageview,A(n.maxPerPageview,1/0)),samplingRate:S(A(c.samplingRate,A(n.samplingRate,1)))})}return e.sort((t,n)=>(t.rule.priority||0)-(n.rule.priority||0)),e})(n);if(0===e.length)return()=>{};const r=new WeakMap;let o=0;const i=t=>{let n=r.get(t);return void 0===n&&(n=++o,r.set(t,n)),String(n)},c=new Map,s=new Map;let a=O();function h(n){try{if(0!==n.button)return;const r=O();r!==a&&(a=r,s.clear(),c.clear());const o=(t=>{const n=[];try{const e="function"==typeof t.composedPath?t.composedPath():[];if(e&&e.length>0){for(const t of e)p(t)&&n.push(t);return n}let r=t.target;for(;r;)p(r)&&n.push(r),r=r.parentNode}catch(t){}return n})(n);if(0===o.length)return;const u=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(t){return""}})();for(let r=0;r<e.length;r++){const a=e[r];if(a.urlScope&&!d(a.urlScope,u))continue;let l=null;for(let t=0;t<o.length;t++)if(x(a,o[t])){l=o[t];break}if(!l)continue;const f=a.rule.id;if((s.get(f)||0)>=a.maxPerPageview)return;const h=f+"#"+i(l),y=Date.now(),v=c.get(h);if(void 0!==v&&y-v<a.dedupeWindowMs)return;if(a.samplingRate<1&&Math.random()>=a.samplingRate)return;c.set(h,y),s.set(f,(s.get(f)||0)+1);const p=a.rule.event.name||"Button Clicked",m=k(a.rule,l,n);return void j(()=>t.track(p,m))}}catch(t){}}try{document.addEventListener("click",h,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",h,!0)}catch(t){}c.clear(),s.clear()}})(t,c.buttonTracking));let R=null;if(c.scroll&&(R=(t=>{if("undefined"==typeof window||"undefined"==typeof document)return{destroy(){},reset(){}};let n=!1,e=null,r=!1;function o(){if(e=null,!r&&!n)try{const e=document.documentElement,r=document.body,o=Math.max(e?e.scrollHeight:0,r?r.scrollHeight:0),i=Math.max(e?e.clientHeight:0,window.innerHeight||0);if(o<=i)return n=!0,c(),void t(90);((window.scrollY||(e?e.scrollTop:0)||0)+i)/o>=.9&&(n=!0,c(),t(90))}catch(t){}}function i(){if(null===e)try{e=window.requestAnimationFrame(o)}catch(t){o()}}function c(){try{window.removeEventListener("scroll",i),null!==e&&window.cancelAnimationFrame(e),e=null}catch(t){}}try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}return{destroy(){r=!0,c()},reset(){if(!r){n=!1;try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}}}}})(n=>{M(()=>t.track("Scrolled",{percent:n}))}),g.push(()=>null==R?void 0:R.destroy())),c.spa){const n=function(){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let n=P();function e(){try{const e=P();if(e===n)return;n=e,(n=>{M(()=>t.page()),null==R||R.reset(),$(n)})(e)}catch(t){}}const r=history.pushState,o=history.replaceState,i=!0===r[_],c=!0===o[_];if(!i){function a(...t){r.apply(this,t),e()}a[_]=!0,history.pushState=a}if(!c){function l(...t){o.apply(this,t),e()}l[_]=!0,history.replaceState=l}const u=()=>e(),s=()=>e();try{window.addEventListener("popstate",u),window.addEventListener("hashchange",s)}catch(f){}return()=>{try{window.removeEventListener("popstate",u),window.removeEventListener("hashchange",s)}catch(t){}try{!i&&history.pushState[_]&&(history.pushState=r),!c&&history.replaceState[_]&&(history.replaceState=o)}catch(t){}}}();g.push(n)}return $(),()=>{for(;g.length>0;){const t=g.pop();try{null==t||t()}catch(t){}}U=null}}({page:(t,n)=>N(t,n),track:(t,n)=>q(t,n)},i.autotrack))}catch(t){}},pageview:g,page:N,screen(t,n){try{const e=m();if(!e)return b("screen");const r=((t,n,e)=>{const r=et("screen",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(t,n,e);v().enqueue(r)}catch(t){}},track:q,identify(t,n){try{if("string"!=typeof t||0===t.length)return;((t,n,e={})=>{var r,o;if(t&&(V(ft,t,{domain:e.cookieDomain,maxAgeDays:null!==(r=e.cookieMaxAgeDays)&&void 0!==r?r:730,sameSite:"Lax"}),F(ft,t),null!=n)){const t=null!==(o=(()=>{const t=Z(dt);if(!t)return null;try{const n=JSON.parse(t);return n&&"object"==typeof n&&!Array.isArray(n)?n:null}catch(t){return null}})())&&void 0!==o?o:{},e=Object.assign(Object.assign({},t),n);try{F(dt,JSON.stringify(e))}catch(t){}}})(t,n,{cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays});const e=m();if(!e)return b("identify");const r=((t,n,e)=>{var r;const o=et("identify",e);return t&&(o.userId=t),o.traits=null!==(r=n)&&void 0!==r?r:{},o})(t,n,e);v().enqueue(r)}catch(t){}},alias(t,n){try{if("string"!=typeof t||0===t.length)return;const e=m();if(!e)return b("alias");const r=((t,n,e)=>{const r=et("alias",e);return t&&(r.userId=t),r.previousId=null!=n?n:e.anonymousId,r})(t,n,e);v().enqueue(r)}catch(t){}},group(t,n){try{if("string"!=typeof t||0===t.length)return;const e=m();if(!e)return b("group");const r=((t,n,e)=>{const r=et("group",e);return r.groupId=t,r.traits=null!=n?n:{},r})(t,n,e);v().enqueue(r)}catch(t){}},reset(){try{((t={})=>{((t,n={})=>{var e;if(!J)return!1;try{let r=`${encodeURIComponent(t)}=`;return r+=`; path=${null!==(e=n.path)&&void 0!==e?e:"/"}`,n.domain&&(r+=`; domain=${n.domain}`),r+="; max-age=0",r+="; expires=Thu, 01 Jan 1970 00:00:00 GMT",document.cookie=r,null===E(t)}catch(t){return!1}})(ft,{domain:t.cookieDomain}),G(ft),G(dt)})({cookieDomain:i.cookieDomain}),((t={})=>{Y(B(),t)})({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),((t={})=>{ct({id:B(),lastActivity:Date.now()},t)})({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes})}catch(t){}},flush(){try{s&&s.flush()}catch(t){}},consent(t){try{c=Object.assign(Object.assign({},c),t)}catch(t){}},set(t){try{i=y(t),t.consent&&(c=Object.assign(Object.assign({},c),t.consent)),s&&s.setConfig({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,debug:i.debug})}catch(t){}},destroy(){if(h){try{h()}catch(t){}h=null}s&&s.destroy(),s=null,a=!1,t=null,i=Object.assign({},ht),c=Object.assign({},yt)}}})();"undefined"!=typeof window&&(t=>{if("undefined"==typeof window)return()=>{};const n=window.cnvQ;if(n&&n.__loaded)return()=>{};const e=window.cnvQ=null!=n?n:[],r=e.splice(0,e.length);e.push.bind(e),e.push=(...n)=>{for(const e of n)vt(t,e);return e.length},e.__loaded=!0;for(const n of r)vt(t,n)})(bt);const gt=Object.assign(bt,{version:pt,name:mt,schemaVersion:tt});t.NAME=mt,t.SCHEMA_VERSION=tt,t.VERSION=pt,t.default=gt,Object.defineProperty(t,"t",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).cnvTrack={});
6
+ var t,n;t=this,n=function(t){const n=["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 e(t){return!!t&&"object"==typeof t&&1===t.nodeType&&"A"===t.tagName}function r(t){const n=t.lastIndexOf("/");return-1===n?t:t.slice(n+1)}function o(t){var n,e,r;let o=(null!==(n=t.textContent)&&void 0!==n?n:"").trim();return o||(o=(null!==(e=t.getAttribute("aria-label"))&&void 0!==e?e:"").trim()),o||(o=(null!==(r=t.getAttribute("title"))&&void 0!==r?r:"").trim()),o.length>200?o.slice(0,200):o}const i=200;function c(t){let n="";try{n=(t.textContent||"").replace(/\s+/g," ").trim(),n||(n=(t.getAttribute("aria-label")||"").trim()),n||(n=(t.getAttribute("title")||"").trim()),n=n.normalize("NFC")}catch(t){return""}return n.length>i?n.slice(0,i):n}function u(t){const n=!1!==t.caseInsensitive;if("regex"===t.mode)return{mode:"regex",needle:t.value,ci:n,re:m(t.value,n)};const e=t.value.normalize("NFC");return{mode:t.mode,needle:n?e.toLowerCase():e,ci:n,re:null}}function l(t,n){try{return t.matches(n)}catch(t){return!1}}function s(t){try{if("A"===t.tagName){const n=t.getAttribute("href");return n?b(n):null}const n=t.getAttribute("formaction");if(n)return b(n);const e=t.getAttribute("data-href");if(e)return b(e);const r=t.closest("form");if(r){const t=r.getAttribute("action");if(t)return b(t)}return null}catch(t){return null}}function a(t){return"regex"===t.mode?{mode:"regex",needle:t.value,re:m(t.value,!0)}:{mode:t.mode,needle:t.value.toLowerCase(),re:null}}function f(t){if("startsWith"===t.mode)return{mode:"startsWith",needle:t.value,re:null};const n="glob"===t.mode?"^"+t.value.replace(/[.+^${}()|[\]\\?]/g,"\\$&").replace(/\*/g,".*")+"$":t.value;return{mode:t.mode,needle:t.value,re:m(n,!1)}}function d(t,n){return"startsWith"===t.mode?0===n.indexOf(t.needle):!t.re||g(t.re,n)}const h=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,y=/\+?\d[\d\s().-]{7,}\d/g;function v(t){if(!t)return t;try{return t.replace(h,"[email]").replace(y,"[phone]")}catch(n){return t}}function p(t){return!!t&&"object"==typeof t&&1===t.nodeType}function b(t){try{return new URL(t,location.href).href}catch(n){return t}}function m(t,n){try{return!t||t.length>1e3?null:new RegExp(t,n?"i":"")}catch(t){return null}}function g(t,n){try{return t.test(n)}catch(t){return!1}}function w(t,n){if("undefined"==typeof document)return()=>{};const e=(t=>{const n=t.globalThrottle||{},e=[],r=t.rules||[];for(let t=0;t<r.length;t++){const o=r[t];if(!o||!1===o.enabled)continue;if(!o.match||!o.event||!o.event.name)continue;const i=o.match,c=o.throttle||{};e.push({rule:o,elementSpec:x(o),selector:i.selector||null,text:i.text?u(i.text):null,dest:i.destinationUrl?a(i.destinationUrl):null,urlScope:o.urlScope?f(o.urlScope):null,dedupeWindowMs:S(c.dedupeWindowMs,S(n.dedupeWindowMs,500)),maxPerPageview:S(c.maxPerPageview,S(n.maxPerPageview,1/0)),samplingRate:_(S(c.samplingRate,S(n.samplingRate,1)))})}return e.sort((t,n)=>(t.rule.priority||0)-(n.rule.priority||0)),e})(n);if(0===e.length)return()=>{};const r=new WeakMap;let o=0;const i=t=>{let n=r.get(t);return void 0===n&&(n=++o,r.set(t,n)),String(n)},c=new Map,l=new Map;let s=A();function h(n){try{if(0!==n.button)return;const r=A();r!==s&&(s=r,l.clear(),c.clear());const o=(t=>{const n=[];try{const e="function"==typeof t.composedPath?t.composedPath():[];if(e&&e.length>0){for(const t of e)p(t)&&n.push(t);return n}let r=t.target;for(;r;)p(r)&&n.push(r),r=r.parentNode}catch(t){}return n})(n);if(0===o.length)return;const u=(()=>{try{return"undefined"!=typeof location?location.pathname+location.search:""}catch(t){return""}})();for(let r=0;r<e.length;r++){const s=e[r];if(s.urlScope&&!d(s.urlScope,u))continue;let a=null;for(let t=0;t<o.length;t++)if(j(s,o[t])){a=o[t];break}if(!a)continue;const f=s.rule.id;if((l.get(f)||0)>=s.maxPerPageview)return;const h=f+"#"+i(a),y=Date.now(),v=c.get(h);if(void 0!==v&&y-v<s.dedupeWindowMs)return;if(s.samplingRate<1&&Math.random()>=s.samplingRate)return;c.set(h,y),l.set(f,(l.get(f)||0)+1);const p=s.rule.event.name||"Button Clicked",b=k(s.rule,a,n);return void O(()=>t.track(p,b))}}catch(t){}}try{document.addEventListener("click",h,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",h,!0)}catch(t){}c.clear(),l.clear()}}function x(t){const n=t.match;return n.element?n.element:n.selector||n.id||n.dataAttr||n.classes&&n.classes.length>0||n.destinationUrl?"any":void 0}function j(t,n){if(!((t,n)=>{if(!n)return(t=>{const n=t.tagName;if("BUTTON"===n||"A"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")})(t);if("any"===n)return!0;if("button"===n){const n=t.tagName;if("BUTTON"===n)return!0;if("INPUT"===n){const n=(t.getAttribute("type")||"").toLowerCase();return"submit"===n||"button"===n||"reset"===n}return"button"===t.getAttribute("role")}return"link"===n?"A"===t.tagName:l(t,n)})(n,t.elementSpec))return!1;const e=t.rule.match;return!(t.selector&&!l(n,t.selector)||void 0!==e.id&&!((t,n)=>t.id===n)(n,e.id)||e.classes&&e.classes.length>0&&!((t,n)=>{try{for(let e=0;e<n.length;e++)if(!t.classList.contains(n[e]))return!1;return!0}catch(t){return!1}})(n,e.classes)||e.dataAttr&&!((t,n,e)=>{try{return!!t.hasAttribute(n)&&(void 0===e||t.getAttribute(n)===e)}catch(t){return!1}})(n,e.dataAttr.name,e.dataAttr.value)||t.text&&!((t,n)=>{const e=c(t);if("regex"===n.mode)return!!n.re&&g(n.re,e);const r=n.ci?e.toLowerCase():e;return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.text)||t.dest&&!((t,n)=>{const e=s(t);if(!e)return!1;if("regex"===n.mode)return!!n.re&&g(n.re,e);if("domain"===n.mode)try{return new URL(e).host.toLowerCase()===n.needle}catch(t){return!1}const r=e.toLowerCase();return"exact"===n.mode?r===n.needle:"startsWith"===n.mode?0===r.indexOf(n.needle):-1!==r.indexOf(n.needle)})(n,t.dest))}function k(t,n,e){const r={},o=t.event.staticProps;if(o)for(const t of Object.keys(o))r[t]=o[t];const u=t.capture;if(u)try{if(u.text){const t=v(c(n));t&&(r.text=t)}if(u.href){const t=s(n);t&&(r.href=t)}if(u.elementId&&n.id&&(r.element_id=n.id),u.classes&&(r.element_classes=Array.from(n.classList)),u.dataAttrs&&u.dataAttrs.length>0)for(let t=0;t<u.dataAttrs.length;t++){const e=u.dataAttrs[t],o=n.getAttribute(e);null!==o&&(r[e]=v(o))}if(u.valueFrom){const t=((t,n)=>{try{const e=t.querySelector(n.selector)||(t.parentElement?t.parentElement.querySelector(n.selector):null);if(!e)return null;const r=n.attr?e.getAttribute(n.attr):e.textContent||"";if(null===r)return null;const o=v(r.replace(/\s+/g," ").trim());return o.length>i?o.slice(0,i):o}catch(t){return null}})(n,u.valueFrom);null!==t&&(r[u.valueFrom.as]=t)}u.selectorPath&&(r.selector_path=((t,n=5)=>{try{const e=[];let r=t,o=0;for(;r&&1===r.nodeType&&o<n;){let t=r.tagName.toLowerCase();if(r.id){e.unshift(t+"#"+r.id);break}const n=Array.from(r.classList).slice(0,2).join(".");n&&(t+="."+n),e.unshift(t),r=r.parentElement,o++}return e.join(" > ")}catch(t){return""}})(n)),u.position&&(r.x=e.clientX,r.y=e.clientY)}catch(t){}return r.rule_id=t.id,t.name&&(r.rule_name=t.name),r.tag=n.tagName.toLowerCase(),r}function O(t){try{t()}catch(t){}}function A(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}function S(t,n){return"number"!=typeof t||isNaN(t)?n:t}function _(t){return t<0?0:t>1?1:t}const T="__cnvPatched";function M(){try{return"undefined"!=typeof location?location.href:""}catch(t){return""}}const I=["q","s","query","search","keyword"],P={spa:!0,outboundClicks:!0,scroll:!0,downloads:!0,siteSearch:!0},D={spa:!1,outboundClicks:!1,scroll:!1,downloads:!1,siteSearch:!1};function U(t){try{t()}catch(t){}}function C(t,n,e,r){return new(e||(e=Promise))((o,i)=>{function c(t){try{l(r.next(t))}catch(t){i(t)}}function u(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e(t=>{t(n)})).then(c,u)}l((r=r.apply(t,n||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const N="undefined"!=typeof window&&"undefined"!=typeof document;function R(t){if(!N)return null;try{const n=document.cookie;if(!n)return null;const e=encodeURIComponent(t),r=n.split(";");for(let n=0;n<r.length;n++){const o=r[n].indexOf("=");if(o<0)continue;const i=r[n].slice(0,o).trim();if(i===e||i===t)try{return decodeURIComponent(r[n].slice(o+1))}catch(t){return r[n].slice(o+1)}}return null}catch(t){return null}}function $(t,n,e={}){var r,o,i;if(!N)return!1;try{let c=`${encodeURIComponent(t)}=${encodeURIComponent(n)}`;if(c+=`; path=${null!==(r=e.path)&&void 0!==r?r:"/"}`,e.domain&&(c+=`; domain=${e.domain}`),"number"==typeof e.maxAgeDays){const t=Math.floor(86400*e.maxAgeDays);c+=`; max-age=${t}`,c+=`; expires=${new Date(Date.now()+1e3*t).toUTCString()}`}return c+=`; SameSite=${null!==(o=e.sameSite)&&void 0!==o?o:"Lax"}`,(null!==(i=e.secure)&&void 0!==i?i:"undefined"!=typeof location&&"https:"===location.protocol)&&(c+="; Secure"),document.cookie=c,R(t)===n}catch(t){return!1}}function L(){if(!N)return!1;try{const t="__cnv_probe__";return localStorage.setItem(t,"1"),localStorage.removeItem(t),!0}catch(t){return!1}}function q(t){if(!L())return null;try{return localStorage.getItem(t)}catch(t){return null}}function B(t,n){if(!L())return!1;try{return localStorage.setItem(t,n),!0}catch(t){return!1}}function z(t){if(!L())return!1;try{return localStorage.removeItem(t),!0}catch(t){return!1}}function E(){if(!N)return!1;try{const t="__cnv_probe__";return sessionStorage.setItem(t,"1"),sessionStorage.removeItem(t),!0}catch(t){return!1}}const J={path:"/config",timeoutMs:4e3,ttlMs:3e5};function W(t,n){var e,r;const o=null!=n?n:Object.assign({enabled:!0},J);return void 0===t?Object.assign({},o):!0===t?Object.assign(Object.assign({},o),{enabled:!0}):!1===t?Object.assign(Object.assign({},o),{enabled:!1}):{enabled:null===(e=t.enabled)||void 0===e||e,path:null!==(r=t.path)&&void 0!==r?r:o.path,timeoutMs:"number"==typeof t.timeoutMs?t.timeoutMs:o.timeoutMs,ttlMs:"number"==typeof t.ttlMs?t.ttlMs:o.ttlMs}}function F(t){return"_cnv_cfg_"+t}function V(t){const n=q(F(t));if(!n)return null;try{const t=JSON.parse(n);return t&&"object"==typeof t&&t.envelope?t:null}catch(t){return null}}function H(t,n,e){try{const r={etag:n,envelope:e,fetchedAt:Date.now()};B(F(t),JSON.stringify(r))}catch(t){}}function Z(t){const n=null==t?void 0:t.buttonTracking;if(!n||!1===n.enabled)return null;const e=Array.isArray(n.rules)?n.rules:[];return 0===e.length?null:{rules:e,globalThrottle:n.globalThrottle}}const G=["gclid","fbclid","ttclid","msclkid","dclid"],K=[["utm_source","source"],["utm_medium","medium"],["utm_campaign","name"],["utm_term","term"],["utm_content","content"],["utm_id","id"]];function Q(t,n){try{return t()}catch(t){return n}}function X(){const t=Q(()=>window.location.href,"");let n="",e="",r="";if(t)try{const o=new URL(t);n=o.pathname,e=o.search,r=o.hash}catch(t){}return{url:t,path:n,search:e,hash:r,title:Q(()=>document.title,""),referrer:Q(()=>document.referrer,"")}}function Y(t){var n,e;let r="@cnv-vn/track",o="0.0.0-dev";try{r="@cnv-vn/track"}catch(t){}try{o="0.2.0-alpha.7"}catch(t){}return{name:null!==(n=null==t?void 0:t.name)&&void 0!==n?n:r,version:null!==(e=null==t?void 0:t.version)&&void 0!==e?e:o}}const tt="0123456789abcdef";function nt(t){return tt[t>>>4&15]+tt[15&t]}function et(){if("undefined"!=typeof crypto){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();if("function"==typeof crypto.getRandomValues){const t=new Uint8Array(16);return crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128,nt(t[0])+nt(t[1])+nt(t[2])+nt(t[3])+"-"+nt(t[4])+nt(t[5])+"-"+nt(t[6])+nt(t[7])+"-"+nt(t[8])+nt(t[9])+"-"+nt(t[10])+nt(t[11])+nt(t[12])+nt(t[13])+nt(t[14])+nt(t[15])}}return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const n=16*Math.random()|0;return("x"===t?n:3&n|8).toString(16)})}const rt=/^[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 ot(t){return"string"==typeof t&&rt.test(t)}const it="_cnv_cid";function ct(t={}){const n=R(it),e=q(it);let r=null;return ot(n)?r=n:ot(e)&&(r=e),r||(r=et()),ut(r,t),r}function ut(t,n={}){var e;$(it,t,{domain:n.cookieDomain,maxAgeDays:null!==(e=n.cookieMaxAgeDays)&&void 0!==e?e:730,sameSite:"Lax"}),B(it,t)}const lt="1.0";function st(){return(new Date).toISOString()}function at(t,n){var e;const r=null!==(e=n.timestamp)&&void 0!==e?e:st(),o=Object.assign(Object.assign({},n.context),{projectId:n.projectId,schemaVersion:lt}),i={type:t,messageId:et(),anonymousId:n.anonymousId,timestamp:r,originalTimestamp:r,context:o};return n.userId&&(i.userId=n.userId),n.sessionId&&(i.sessionId=n.sessionId),n.integrations&&(i.integrations=n.integrations),i}const ft="_cnv_sid";function dt(t){if(!t)return null;const n=t.lastIndexOf(".");if(n<0)return null;const e=t.slice(0,n),r=Number(t.slice(n+1));return!ot(e)||!Number.isFinite(r)||r<=0?null:{id:e,lastActivity:r}}function ht(t={}){const n=Date.now(),e=(t=>{var n;return 6e4*(null!==(n=t.timeoutMinutes)&&void 0!==n?n:30)})(t),r=dt(R(ft)),o=dt((t=>{if(!E())return null;try{return sessionStorage.getItem(t)}catch(t){return null}})(ft));let i=null;for(const t of[r,o])t&&(n-t.lastActivity>e||(!i||t.lastActivity>i.lastActivity)&&(i=t));const c=i?{id:i.id,lastActivity:n}:{id:et(),lastActivity:n};return yt(c,t),c.id}function yt(t,n={}){var e;const r=(t=>`${t.id}.${t.lastActivity}`)(t),o=null!==(e=n.timeoutMinutes)&&void 0!==e?e:30;$(ft,r,{domain:n.cookieDomain,maxAgeDays:o/1440,sameSite:"Lax"}),((t,n)=>{if(!E())return!1;try{return sessionStorage.setItem(t,n),!0}catch(t){return!1}})(ft,r)}class vt{constructor(t){var n,e;Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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!==(n=t.storageKey)&&void 0!==n?n:"_cnv_rq",this.maxMessages=null!==(e=t.maxMessages)&&void 0!==e?e:100,this.installOnlineListener()}stash(t){if(t&&0!==t.length)try{const n=this.read();for(n.push(t);n.length>1&&pt(n)>this.maxMessages;)n.shift();this.write(n),this.config.debug&&console.log("[cnv-track] retry queued",t.length,"buffered",pt(n))}catch(t){}}flush(){if(this.flushing||"undefined"!=typeof navigator&&!1===navigator.onLine)return Promise.resolve();const t=this.read();if(0===t.length)return Promise.resolve();this.flushing=!0,this.write([]);const n=()=>{this.flushing=!1};return t.reduce((t,n)=>t.then(()=>this.config.resend(n)),Promise.resolve()).then(n,n)}size(){return pt(this.read())}clear(){try{z(this.storageKey)}catch(t){}}destroy(){if(this.onlineHandler){try{window.removeEventListener("online",this.onlineHandler)}catch(t){}this.onlineHandler=null}}installOnlineListener(){if("undefined"==typeof window)return;const t=()=>{this.flush()};try{window.addEventListener("online",t),this.onlineHandler=t}catch(t){}}read(){const t=q(this.storageKey);if(!t)return[];try{const n=JSON.parse(t);return Array.isArray(n)?n.filter(t=>Array.isArray(t)&&t.length>0):[]}catch(t){return[]}}write(t){0!==t.length?B(this.storageKey,JSON.stringify(t)):z(this.storageKey)}}function pt(t){let n=0;for(const e of t)n+=e.length;return n}class bt{constructor(t){Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:t}),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 vt({debug:t.debug,resend:t=>this.send(t)}),this.installPageLifecycleHandlers(),this.retryQueue.flush()}setConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}enqueue(t){this.destroyed||(this.buffer.push(t),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 t=this.buffer;return this.buffer=[],this.send(t)}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(t){try{return this.config.useBatch?this.sendBatch(t):Promise.all(t.map(t=>this.sendSingle(t))).then(()=>{})}catch(t){return this.config.debug&&console.warn("[cnv-track] send failed synchronously; dropped batch",t),Promise.resolve()}}sendBatch(t){var n;const e=st(),r={batch:t.map(t=>mt(t,e)),context:Object.assign(Object.assign({},null!==(n=this.config.batchContext)&&void 0!==n?n:{}),{projectId:this.config.projectId,sentAt:e}),sentAt:e};return this.post(this.batchUrl(),r,t)}sendSingle(t){const n=mt(t,st());return this.post(this.singleUrl(t.type),n,[t])}batchUrl(){return this.config.endpoint+this.config.batchPath+"?projectId="+encodeURIComponent(this.config.projectId)}singleUrl(t){const n=this.config.singlePath.replace("{type}",t);return this.config.endpoint+n+"?projectId="+encodeURIComponent(this.config.projectId)}post(t,n,e){const r=JSON.stringify(n),o=((t,n)=>{try{return new Blob([t],{type:n})}catch(t){return null}})(r,this.config.contentType),i=o?o.size:(t=>{try{return new Blob([t]).size}catch(n){return t.length}})(r),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",t),Promise.resolve()):o&&this.sendViaBeacon(t,o)?(this.config.debug&&console.log("[cnv-track] beacon",t),Promise.resolve()):this.sendViaFetch(t,r,c)}sendViaBeacon(t,n){if("undefined"==typeof navigator||"function"!=typeof navigator.sendBeacon)return!1;if(n.size>65536)return!1;try{return navigator.sendBeacon(t,n)}catch(t){return!1}}sendViaFetch(t,n,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(t,{method:"POST",headers:{"Content-Type":this.config.contentType},body:n,keepalive:!0,credentials:"omit",mode:"cors"}).then(n=>{this.config.debug&&console.log("[cnv-track] fetch flushed",t,n.status)}).catch(n=>{this.config.debug&&console.warn("[cnv-track] flush failed; queued for retry",t,n),e&&this.retryQueue.stash(e)})}installPageLifecycleHandlers(){if("undefined"==typeof window||"undefined"==typeof document)return;const t=()=>{this.flush()},n=()=>{"hidden"===document.visibilityState&&this.flush()};try{window.addEventListener("pagehide",t),document.addEventListener("visibilitychange",n),this.handlers={pagehide:t,visibility:n}}catch(t){}}uninstallPageLifecycleHandlers(){if(this.handlers){try{window.removeEventListener("pagehide",this.handlers.pagehide),document.removeEventListener("visibilitychange",this.handlers.visibility)}catch(t){}this.handlers=null}}}function mt(t,n){return Object.assign(Object.assign({},t),{sentAt:n})}const gt="_cnv_uid",wt="_cnv_traits",xt={endpoint:"http://localhost:8090/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:W(void 0)},jt={analytics:!0,marketing:!0};function kt(t,n){if(!Array.isArray(n)||0===n.length)return;const e=n;try{switch(e[0]){case"init":t.init(e[1],e[2]);break;case"pageview":t.pageview(e[1],e[2]);break;case"page":t.page(e[1],e[2]);break;case"screen":t.screen(e[1],e[2]);break;case"track":t.track(e[1],e[2]);break;case"identify":t.identify(e[1],e[2]);break;case"alias":t.alias(e[1],e[2]);break;case"group":t.group(e[1],e[2]);break;case"reset":t.reset();break;case"flush":t.flush();break;case"consent":t.consent(e[1]);break;case"set":t.set(e[1])}}catch(t){}}const Ot="0.2.0-alpha.7",At="@cnv-vn/track",St=function(){let t=null,i=Object.assign({},xt),c=Object.assign({},jt),u=null,l=!1,s=null,a=null;function f(t){const n=Object.assign({},i);return t?(void 0!==t.endpoint&&(n.endpoint=(e=t.endpoint).endsWith("/")?e.slice(0,-1):e),void 0!==t.batchPath&&(n.batchPath=t.batchPath),void 0!==t.singlePath&&(n.singlePath=t.singlePath),void 0!==t.useBatch&&(n.useBatch=t.useBatch),void 0!==t.contentType&&(n.contentType=t.contentType),void 0!==t.debug&&(n.debug=t.debug),void 0!==t.allowAdTracking&&(n.allowAdTracking=t.allowAdTracking),void 0!==t.cookieDomain&&(n.cookieDomain=t.cookieDomain),void 0!==t.cookieMaxAgeDays&&(n.cookieMaxAgeDays=t.cookieMaxAgeDays),void 0!==t.sessionTimeoutMinutes&&(n.sessionTimeoutMinutes=t.sessionTimeoutMinutes),void 0!==t.flushAt&&(n.flushAt=t.flushAt),void 0!==t.flushInterval&&(n.flushInterval=t.flushInterval),void 0!==t.autoPageview&&(n.autoPageview=t.autoPageview),void 0!==t.autotrack&&(n.autotrack=t.autotrack),void 0!==t.integrations&&(n.integrations=t.integrations),void 0!==t.remoteConfig&&(n.remoteConfig=W(t.remoteConfig,i.remoteConfig)),n):n;var e}function d(){return u||(u=new bt({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,projectId:null!=t?t:"",debug:i.debug}),u)}function h(){var n;if(!t)return null;const e=((t={})=>{var n;const e={page:X(),screen:{width:Q(()=>window.screen.width,0),height:Q(()=>window.screen.height,0),density:Q(()=>window.devicePixelRatio||1,1)},locale:Q(()=>navigator.language||"",""),timezone:Q(()=>Intl.DateTimeFormat().resolvedOptions().timeZone||"",""),userAgent:Q(()=>navigator.userAgent||"",""),library:Y(t.library)},r=((t,n=!0)=>{const e=Q(()=>window.location.search,"");if(!e)return;let r;try{r=new URLSearchParams(e)}catch(t){return}const o={};let i=!1;for(const[t,n]of K){const e=r.get(t);e&&e.length>0&&(o[n]=e,i=!0)}if(n){const t={};for(const n of G){const e=r.get(n);e&&e.length>0&&(t[n]=e)}Object.keys(t).length>0&&(o.clickIds=t,i=!0)}return i?o:void 0})(0,null===(n=t.allowAdTracking)||void 0===n||n);return r&&(e.campaign=r),e})({allowAdTracking:i.allowAdTracking});return c.analytics&&c.marketing||(e.consent=Object.assign({},c)),{anonymousId:ct({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),sessionId:ht({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),userId:null!==(n=R(gt)||q(gt))&&void 0!==n?n:void 0,context:e,projectId:t,integrations:Object.keys(i.integrations).length>0?i.integrations:void 0}}function y(t){i.debug&&console.warn(`[cnv-track] ${t}() called before init()`)}function v(t,n){try{const e=h();if(!e)return y("pageview");const r=((t,n,e)=>{const r=at("page",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(t,((t,n)=>{const e={};return t&&(t.url&&(e.url=t.url),t.path&&(e.path=t.path),t.title&&(e.title=t.title),t.referrer&&(e.referrer=t.referrer),t.search&&(e.search=t.search)),Object.assign(Object.assign({},e),null!=n?n:{})})(e.context.page,n),e);d().enqueue(r)}catch(t){}}function p(t,n){v(t,n)}function b(t,n){try{if("string"!=typeof t||0===t.length)return;const e=h();if(!e)return y("track");const r=((t,n,e)=>{const r=at("track",e);return r.event=t,r.properties=null!=n?n:{},r})(t,n,e);d().enqueue(r)}catch(t){}}return{get initialized(){return l},get projectId(){return t},init(h,y){try{if(!h||"string"!=typeof h)return;if(i=f(y),(null==y?void 0:y.consent)&&(c=Object.assign(Object.assign({},c),y.consent)),t=h,u&&u.destroy(),u=null,d(),l=!0,ct({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),ht({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes}),i.autoPageview&&v(),s){try{s()}catch(t){}s=null}const m={page:(t,n)=>p(t,n),track:(t,n)=>b(t,n)};if(i.autotrack){let t=i.autotrack;i.remoteConfig.enabled&&"object"==typeof t&&t.buttonTracking&&(t=Object.assign(Object.assign({},t),{buttonTracking:void 0})),s=function(t,i){const c=void 0===(u=i)||!1===u?Object.assign(Object.assign({},D),{searchParams:I}):!0===u?Object.assign(Object.assign({},P),{searchParams:I}):{spa:null===(l=u.spa)||void 0===l||l,outboundClicks:null===(s=u.outboundClicks)||void 0===s||s,scroll:null===(a=u.scroll)||void 0===a||a,downloads:null===(f=u.downloads)||void 0===f||f,siteSearch:null===(d=u.siteSearch)||void 0===d||d,downloadExtensions:u.downloadExtensions,searchParams:null!==(h=u.searchParams)&&void 0!==h?h:I,buttonTracking:u.buttonTracking};var u,l,s,a,f,d,h;const y=[];let v=null;function p(n){if(c.siteSearch)try{const e=null!=n?n:(()=>{try{return"undefined"!=typeof location?location.href:""}catch(t){return""}})();if(e===v)return;v=e;const r=((t,n=I)=>{try{if(!t){if("undefined"==typeof location)return null;t=location.href}const e=t instanceof URL?t:new URL(t,(()=>{try{return"undefined"!=typeof location?location.href:"http://localhost/"}catch(t){return"http://localhost/"}})());if(!e.search)return null;for(const t of n){const n=e.searchParams.get(t);if(null===n)continue;const r=n.trim();if(0!==r.length)return{query:r,param:t}}return null}catch(t){return null}})(e,c.searchParams);r&&U(()=>t.track("Site Searched",{query:r.query,param:r.param}))}catch(t){}}if(c.outboundClicks||c.downloads){const i=(t=>{var i;if("undefined"==typeof document)return()=>{};const c=new Set((null!==(i=t.downloadExtensions)&&void 0!==i?i:n).map(t=>t.toLowerCase())),u=!!t.onOutbound,l=!!t.onDownload;if(!u&&!l)return()=>{};function s(n){var i,s;try{if(0!==n.button)return;if(n.defaultPrevented)return;const a=(t=>{const n="function"==typeof t.composedPath?t.composedPath():[];if(n.length>0)for(const t of n)if(e(t))return t;let r=t.target;for(;r;){if(e(r))return r;r=r.parentNode}return null})(n);if(!a)return;const f=a.getAttribute("href");if(!f)return;if(/^(javascript:|mailto:|tel:|sms:)/i.test(f))return;if(f.startsWith("#"))return;const d=(t=>{try{return new URL(t,location.href)}catch(t){return null}})(f);if(!d)return;let h=!1;if(l){const n=a.hasAttribute("download"),e=(t=>{const n=r(t),e=n.lastIndexOf(".");return e<=0||e===n.length-1?null:n.slice(e+1).toLowerCase()})(d.pathname);(n||e&&c.has(e))&&(h=!0,null===(i=t.onDownload)||void 0===i||i.call(t,{url:d.href,fileName:r(d.pathname),fileExtension:null!=e?e:"",text:o(a)}))}u&&!h&&d.host!==(()=>{try{return"undefined"!=typeof location?location.hostname:""}catch(t){return""}})()&&d.host&&(null===(s=t.onOutbound)||void 0===s||s.call(t,{url:d.href,host:d.host,text:o(a),target:a.target||"_self"}))}catch(t){}}try{document.addEventListener("click",s,!0)}catch(t){return()=>{}}return()=>{try{document.removeEventListener("click",s,!0)}catch(t){}}})({downloadExtensions:c.downloadExtensions,onOutbound:c.outboundClicks?n=>U(()=>t.track("Outbound Link Clicked",n)):void 0,onDownload:c.downloads?n=>U(()=>t.track("File Downloaded",n)):void 0});y.push(i)}c.buttonTracking&&c.buttonTracking.rules&&c.buttonTracking.rules.length>0&&y.push(w(t,c.buttonTracking));let b=null;if(c.scroll&&(b=(t=>{if("undefined"==typeof window||"undefined"==typeof document)return{destroy(){},reset(){}};let n=!1,e=null,r=!1;function o(){if(e=null,!r&&!n)try{const e=document.documentElement,r=document.body,o=Math.max(e?e.scrollHeight:0,r?r.scrollHeight:0),i=Math.max(e?e.clientHeight:0,window.innerHeight||0);if(o<=i)return n=!0,c(),void t(90);((window.scrollY||(e?e.scrollTop:0)||0)+i)/o>=.9&&(n=!0,c(),t(90))}catch(t){}}function i(){if(null===e)try{e=window.requestAnimationFrame(o)}catch(t){o()}}function c(){try{window.removeEventListener("scroll",i),null!==e&&window.cancelAnimationFrame(e),e=null}catch(t){}}try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}return{destroy(){r=!0,c()},reset(){if(!r){n=!1;try{window.addEventListener("scroll",i,{passive:!0})}catch(t){try{window.addEventListener("scroll",i)}catch(t){}}try{window.requestAnimationFrame(o)}catch(t){o()}}}}})(n=>{U(()=>t.track("Scrolled",{percent:n}))}),y.push(()=>null==b?void 0:b.destroy())),c.spa){const n=[],e=function(){if("undefined"==typeof window||"undefined"==typeof history)return()=>{};let e=M();function r(){try{const r=M();if(r===e)return;e=r,(e=>{const r=setTimeout(()=>{const e=n.indexOf(r);-1!==e&&n.splice(e,1),U(()=>t.page())},0);n.push(r),null==b||b.reset(),p(e)})(r)}catch(t){}}const o=history.pushState,i=history.replaceState,c=!0===o[T],u=!0===i[T];if(!c){function a(...t){o.apply(this,t),r()}a[T]=!0,history.pushState=a}if(!u){function f(...t){i.apply(this,t),r()}f[T]=!0,history.replaceState=f}const l=()=>r(),s=()=>r();try{window.addEventListener("popstate",l),window.addEventListener("hashchange",s)}catch(d){}return()=>{try{window.removeEventListener("popstate",l),window.removeEventListener("hashchange",s)}catch(t){}try{!c&&history.pushState[T]&&(history.pushState=o),!u&&history.replaceState[T]&&(history.replaceState=i)}catch(t){}}}();y.push(()=>{for(let t=0;t<n.length;t++)clearTimeout(n[t]);n.length=0,e()})}return p(),()=>{for(;y.length>0;){const t=y.pop();try{null==t||t()}catch(t){}}v=null}}(m,t)}if(a){try{a()}catch(t){}a=null}if(i.remoteConfig.enabled&&t){const n=t=>{if(a){try{a()}catch(t){}a=null}t&&t.rules&&t.rules.length>0&&(a=w(m,t))},e=(t=>{const n=V(t);return n?Z(n.envelope):null})(t);e&&n(e),function(t){return C(this,void 0,void 0,function*(){if(!t.projectId)return{status:"error"};const n=V(t.projectId);if(n&&Date.now()-n.fetchedAt<t.ttlMs)return{status:"unchanged"};const e=yield function(t){return C(this,void 0,void 0,function*(){var n;if("function"!=typeof fetch)return null;const e=t.endpoint+t.path+"?projectId="+encodeURIComponent(t.projectId),r="undefined"!=typeof AbortController?new AbortController:null,o=r?setTimeout(()=>r.abort(),t.timeoutMs):null;try{const o={};t.etag&&(o["If-None-Match"]=t.etag);const i=yield fetch(e,{method:"GET",headers:o,credentials:"omit",mode:"cors",signal:r?r.signal:void 0});if(304===i.status)return{envelope:null,etag:null!==(n=t.etag)&&void 0!==n?n:"",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(t){return null}finally{o&&clearTimeout(o)}})}({endpoint:t.endpoint,path:t.path,projectId:t.projectId,timeoutMs:t.timeoutMs,etag:null==n?void 0:n.etag});return e?e.notModified?(n&&H(t.projectId,n.etag,n.envelope),{status:"unchanged"}):e.envelope?(H(t.projectId,e.etag,e.envelope),{status:"updated",buttonTracking:Z(e.envelope)}):{status:"error"}:{status:"error"}})}({endpoint:i.endpoint,path:i.remoteConfig.path,projectId:t,timeoutMs:i.remoteConfig.timeoutMs,ttlMs:i.remoteConfig.ttlMs}).then(t=>{"updated"===t.status&&n(t.buttonTracking)}).catch(()=>{})}}catch(t){}},pageview:v,page:p,screen(t,n){try{const e=h();if(!e)return y("screen");const r=((t,n,e)=>{const r=at("screen",e);return t&&(r.name=t),r.properties=null!=n?n:{},r})(t,n,e);d().enqueue(r)}catch(t){}},track:b,identify(t,n){try{if("string"!=typeof t||0===t.length)return;((t,n,e={})=>{var r,o;if(t&&($(gt,t,{domain:e.cookieDomain,maxAgeDays:null!==(r=e.cookieMaxAgeDays)&&void 0!==r?r:730,sameSite:"Lax"}),B(gt,t),null!=n)){const t=null!==(o=(()=>{const t=q(wt);if(!t)return null;try{const n=JSON.parse(t);return n&&"object"==typeof n&&!Array.isArray(n)?n:null}catch(t){return null}})())&&void 0!==o?o:{},e=Object.assign(Object.assign({},t),n);try{B(wt,JSON.stringify(e))}catch(t){}}})(t,n,{cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays});const e=h();if(!e)return y("identify");const r=((t,n,e)=>{var r;const o=at("identify",e);return t&&(o.userId=t),o.traits=null!==(r=n)&&void 0!==r?r:{},o})(t,n,e);d().enqueue(r)}catch(t){}},alias(t,n){try{if("string"!=typeof t||0===t.length)return;const e=h();if(!e)return y("alias");const r=((t,n,e)=>{const r=at("alias",e);return t&&(r.userId=t),r.previousId=null!=n?n:e.anonymousId,r})(t,n,e);d().enqueue(r)}catch(t){}},group(t,n){try{if("string"!=typeof t||0===t.length)return;const e=h();if(!e)return y("group");const r=((t,n,e)=>{const r=at("group",e);return r.groupId=t,r.traits=null!=n?n:{},r})(t,n,e);d().enqueue(r)}catch(t){}},reset(){try{((t={})=>{((t,n={})=>{var e;if(!N)return!1;try{let r=`${encodeURIComponent(t)}=`;return r+=`; path=${null!==(e=n.path)&&void 0!==e?e:"/"}`,n.domain&&(r+=`; domain=${n.domain}`),r+="; max-age=0",r+="; expires=Thu, 01 Jan 1970 00:00:00 GMT",document.cookie=r,null===R(t)}catch(t){return!1}})(gt,{domain:t.cookieDomain}),z(gt),z(wt)})({cookieDomain:i.cookieDomain}),((t={})=>{ut(et(),t)})({cookieDomain:i.cookieDomain,cookieMaxAgeDays:i.cookieMaxAgeDays}),((t={})=>{yt({id:et(),lastActivity:Date.now()},t)})({cookieDomain:i.cookieDomain,timeoutMinutes:i.sessionTimeoutMinutes})}catch(t){}},flush(){try{u&&u.flush()}catch(t){}},consent(t){try{c=Object.assign(Object.assign({},c),t)}catch(t){}},set(t){try{i=f(t),t.consent&&(c=Object.assign(Object.assign({},c),t.consent)),u&&u.setConfig({endpoint:i.endpoint,batchPath:i.batchPath,singlePath:i.singlePath,useBatch:i.useBatch,contentType:i.contentType,flushAt:i.flushAt,flushInterval:i.flushInterval,debug:i.debug})}catch(t){}},destroy(){if(s){try{s()}catch(t){}s=null}if(a){try{a()}catch(t){}a=null}u&&u.destroy(),u=null,l=!1,t=null,i=Object.assign({},xt),c=Object.assign({},jt)}}}();"undefined"!=typeof window&&(t=>{if("undefined"==typeof window)return()=>{};const n=window.cnvQ;if(n&&n.__loaded)return()=>{};const e=window.cnvQ=null!=n?n:[],r=e.splice(0,e.length);e.push.bind(e),e.push=(...n)=>{for(const e of n)kt(t,e);return e.length},e.__loaded=!0;for(const n of r)kt(t,n)})(St);const _t=Object.assign(St,{version:Ot,name:At,schemaVersion:lt});t.NAME=At,t.SCHEMA_VERSION=lt,t.VERSION=Ot,t.default=_t,Object.defineProperty(t,"t",{value:!0})},"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).cnvTrack={});
@@ -251,6 +251,31 @@ interface SDKOptions {
251
251
  consent?: Partial<ContextConsent>;
252
252
  /** Per-call integrations override. */
253
253
  integrations?: Record<string, JSONValue>;
254
+ /**
255
+ * Remote config — tự nạp button-tracking rules từ Tracking Gateway
256
+ * (`GET {endpoint}{path}?projectId=`) lúc `init`. Rule do dashboard CDP quản
257
+ * lý (single source of truth); SDK chỉ đọc + cache (localStorage + ETag) và
258
+ * fail-open. **Mặc định on** — SDK tự nạp rules mà không cần khai báo. Pass
259
+ * `false` để tắt, hoặc object để tinh chỉnh. Xem {@link RemoteConfigOptions}.
260
+ */
261
+ remoteConfig?: boolean | RemoteConfigOptions;
262
+ }
263
+ /**
264
+ * Tùy chọn cho remote-config fetch. Nguồn rule là dashboard CDP — SDK chỉ tải
265
+ * bản đã publish qua `GET {endpoint}{path}?projectId=` rồi cache lại.
266
+ */
267
+ interface RemoteConfigOptions {
268
+ /** Bật/tắt. Mặc định `true` khi truyền object. */
269
+ enabled?: boolean;
270
+ /** Path nối sau `endpoint` để lấy config. Mặc định `/config`. */
271
+ path?: string;
272
+ /** Timeout cho request fetch config (ms). Mặc định 4000. */
273
+ timeoutMs?: number;
274
+ /**
275
+ * Cửa sổ "còn tươi" của cache localStorage (ms): trong khoảng này SDK dùng
276
+ * thẳng cache, không gọi mạng. Mặc định 300000 (khớp `max-age=300` server).
277
+ */
278
+ ttlMs?: number;
254
279
  }
255
280
  /**
256
281
  * Granular toggles for the built-in autotrack instrumentation. Every feature
@@ -442,6 +467,27 @@ interface ThrottleSpec {
442
467
  /** Probability 0..1 an eligible click is recorded. Default 1. */
443
468
  samplingRate?: number;
444
469
  }
470
+ /**
471
+ * Envelope trả về từ `GET /v1/config` (remote config). SDK parse trực tiếp; chỉ
472
+ * dùng phần `buttonTracking`, các field nội bộ khác (nếu có) được bỏ qua.
473
+ */
474
+ interface RemoteConfigEnvelope {
475
+ /** Tăng mỗi lần publish; cũng là giá trị `ETag` để cache-bust. */
476
+ version: number;
477
+ /** Phiên bản schema rule, ví dụ `"1.0"`. */
478
+ schemaVersion?: string;
479
+ /** ISO timestamp lần publish gần nhất. */
480
+ updatedAt?: string;
481
+ /** Cấu hình button-tracking đã publish. */
482
+ buttonTracking?: {
483
+ /** `false` ⇒ tắt button-tracking (SDK gỡ listener). */
484
+ enabled?: boolean;
485
+ /** Danh sách rule (giống schema inline {@link ClickRule}). */
486
+ rules?: ClickRule[];
487
+ /** Throttle mặc định cho rule không tự đặt. */
488
+ globalThrottle?: ThrottleSpec;
489
+ };
490
+ }
445
491
  /**
446
492
  * Each entry in `window.cnvQ` is a tuple `[methodName, ...args]`.
447
493
  * The async snippet seeds the queue as a plain Array; once the SDK loads,
@@ -579,4 +625,4 @@ declare const cnvTrack: Runtime & {
579
625
  };
580
626
 
581
627
  export { NAME, SCHEMA_VERSION, VERSION, cnvTrack as default };
582
- export type { AutotrackOptions, ButtonTrackingOptions, CaptureSpec, ClickEventSpec, ClickMatch, ClickRule, ContextCampaign, ContextConsent, ContextLibrary, ContextPage, ContextScreen, DataAttrMatch, DestinationMatch, JSONValue, MessageType, PayloadContext, QueuedCommand, SDKOptions, SegmentBatchRequest, SegmentMessage, TextMatch, ThrottleSpec, UrlMatch, UserTraits };
628
+ export type { AutotrackOptions, ButtonTrackingOptions, CaptureSpec, ClickEventSpec, ClickMatch, ClickRule, ContextCampaign, ContextConsent, ContextLibrary, ContextPage, ContextScreen, DataAttrMatch, DestinationMatch, JSONValue, MessageType, PayloadContext, QueuedCommand, RemoteConfigEnvelope, RemoteConfigOptions, SDKOptions, SegmentBatchRequest, SegmentMessage, TextMatch, ThrottleSpec, UrlMatch, UserTraits };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cnv-vn/track",
3
- "version": "0.2.0-alpha.5",
3
+ "version": "0.2.0-alpha.7",
4
4
  "description": "CNV Tracking SDK — lightweight, async-first web analytics tracker (<20KB gzipped).",
5
5
  "keywords": [
6
6
  "analytics",
@@ -53,6 +53,7 @@
53
53
  "node": ">=18"
54
54
  },
55
55
  "scripts": {
56
+ "prepare": "git config core.hooksPath .githooks || true",
56
57
  "build": "rollup -c",
57
58
  "build:watch": "rollup -c -w",
58
59
  "build:analyze": "cross-env ANALYZE=true rollup -c",
@@ -71,7 +72,8 @@
71
72
  "test:watch": "vitest",
72
73
  "test:coverage": "vitest run --coverage",
73
74
  "smoke": "node scripts/smoke-dist.mjs",
74
- "verify": "npm run type-check && npm run type-check:tests && npm run lint && npm run format:check && npm run test && npm run build && npm run size && npm run size:snippet && npm run smoke"
75
+ "verify": "npm run type-check && npm run type-check:tests && npm run lint && npm run format:check && npm run test && npm run build && npm run size && npm run size:snippet && npm run smoke",
76
+ "verify:fix": "npm run format && npm run verify"
75
77
  },
76
78
  "devDependencies": {
77
79
  "@rollup/plugin-commonjs": "^28.0.2",