veo-sdk 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{builder-PPLIAUCM.mjs → builder-5F2EFT4X.mjs} +4 -4
- package/dist/{builder-PPLIAUCM.mjs.map → builder-5F2EFT4X.mjs.map} +1 -1
- package/dist/builder.cjs +42 -11
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.mjs +4 -4
- package/dist/{chunk-3JEAPZ6A.mjs → chunk-72YH2GXC.mjs} +3 -3
- package/dist/{chunk-3JEAPZ6A.mjs.map → chunk-72YH2GXC.mjs.map} +1 -1
- package/dist/{chunk-SZCIXA5X.mjs → chunk-CMPOHTUM.mjs} +44 -13
- package/dist/chunk-CMPOHTUM.mjs.map +1 -0
- package/dist/{chunk-DU6I4ZU2.mjs → chunk-YEKCBVNJ.mjs} +3 -3
- package/dist/{chunk-DU6I4ZU2.mjs.map → chunk-YEKCBVNJ.mjs.map} +1 -1
- package/dist/index.cjs +52 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +7 -6
- package/dist/index.mjs.map +1 -1
- package/dist/veo-builder.js +18 -18
- package/dist/veo-builder.js.map +1 -1
- package/dist/veo-guides.js +6 -6
- package/dist/veo-guides.js.map +1 -1
- package/dist/veo.js +2 -2
- package/dist/veo.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-SZCIXA5X.mjs.map +0 -1
package/dist/veo.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var veo=(function(exports){'use strict';var D="0.0.1";var J="https://veo-backend-production-8c78.up.railway.app";function f(r){let e=r?.apiUrl;if(typeof e=="string"&&e.trim())return e;let t=globalThis.__VEO_API_URL__;return typeof t=="string"&&t.trim()?t:J}function c(){return typeof window<"u"}function d(){return typeof document<"u"}function O(){try{if(typeof localStorage>"u")return !1;let r="__veo_test__";return localStorage.setItem(r,"1"),localStorage.removeItem(r),!0}catch{return false}}function Z(){return typeof navigator<"u"&&typeof navigator.sendBeacon=="function"}var S="veoBuilder",ee="veoBuilderOrigin",te="veoBuilderPanel",re="veoBuilderPanelPath",ne="veoGuide";var De="veoPreview",oe="veo:preview_token";function Oe(){try{return window.sessionStorage}catch{return null}}function V(){if(!c())return null;let r=null;try{let t=new URLSearchParams(window.location.search).get(De);r=t||null;}catch{r=null;}let e=Oe();if(r){try{e?.setItem(oe,r);}catch{}return r}try{return e?.getItem(oe)||null}catch{return null}}function ie(){return V()!==null}var $="veo:builder_ctx",se="veo:builder_ctx:",Ve=1800*1e3;function N(){try{return window.sessionStorage}catch{return null}}function ae(){try{return window.localStorage}catch{return null}}function $e(r){return se+(r||"default")}function Ne(r){try{N()?.setItem($,JSON.stringify(r));}catch{}try{let e={...r,savedAt:Date.now()};ae()?.setItem($e(r.guide),JSON.stringify(e));}catch{}}function Be(){let r=ae();if(!r)return null;let e=null;try{for(let o=0;o<r.length;o++){let i=r.key(o);if(!i?.startsWith(se))continue;let s=r.getItem(i);if(!s)continue;let a=null;try{a=JSON.parse(s);}catch{continue}if(typeof a?.savedAt!="number"||Date.now()-a.savedAt>Ve){try{r.removeItem(i);}catch{}continue}(!e||a.savedAt>e.savedAt)&&(e=a);}}catch{return null}if(!e)return null;let{savedAt:t,...n}=e;return n}function Ke(){try{let r=new URLSearchParams(window.location.search);if(r.get(S))return r;let e=window.location.hash.replace(/^#/,"");return e.includes(`${S}=`)?new URLSearchParams(e):r}catch{return null}}function ue(){if(!c())return null;let r=Ke(),e=r?.get(S);if(e){let n={token:e,origin:r?.get(ee)??null,panel:r?.get(te)==="1",guide:r?.get(ne)??null,panelPath:r?.get(re)??null};return Ne(n),n}if(ie())return null;try{let n=N()?.getItem($);if(n)return JSON.parse(n)}catch{}let t=Be();if(t)try{N()?.setItem($,JSON.stringify(t));}catch{}return t}function le(){return ue()?.token??null}function y(){return ue()!==null}function ce(r){if(!c()||!d()||le()===null||(r.apiKey&&r.apiUrl&&(window.__veoBuilder={apiKey:r.apiKey,apiUrl:r.apiUrl}),window.veoBuilder))return;let e=r.builderUrl??He();if(e){if(document.querySelector(`script[src="${e}"]`))return;let t=document.createElement("script");t.src=e,t.async=true,r.debug&&t.addEventListener("error",()=>console.error("[veo] no pude cargar",e)),document.head.appendChild(t);return}if(r.loadBuilder){r.loadBuilder().catch(t=>{r.debug&&console.error("[veo] no pude cargar el builder (import din\xE1mico)",t);});return}r.debug&&console.warn("[veo] builder mode pedido pero no pude resolver la URL de veo-builder.js");}function He(){let r=document.querySelectorAll("script[src]");for(let e of Array.from(r))if(/\bveo(\.min)?\.js(\?.*)?$/.test(e.src))return e.src.replace(/\bveo(\.min)?\.js/,"veo-builder$1.js");return null}var de=null;function pe(r){return de??(de=Ge(r)),de}function Ge(r){return new Promise(e=>{if(!c()||!d()){e(null);return}let t=window;if(t.veoGuides){e(t.veoGuides);return}let n=r.guidesUrl??qe();if(!n){r.debug&&console.warn("[veo] no pude resolver la URL de veo-guides.js"),e(null);return}let o=()=>e(t.veoGuides??null),i=document.querySelector(`script[src="${n}"]`);if(i){i.addEventListener("load",o),i.addEventListener("error",()=>e(null));return}let s=document.createElement("script");s.src=n,s.async=true,s.addEventListener("load",o),s.addEventListener("error",()=>{r.debug&&console.error("[veo] no pude cargar",n),e(null);}),document.head.appendChild(s);})}function qe(){let r=document.querySelectorAll("script[src]");for(let e of Array.from(r))if(/\bveo(\.min)?\.js(\?.*)?$/.test(e.src))return e.src.replace(/\bveo(\.min)?\.js/,"veo-guides$1.js");return null}function ze(r){return r}var he={enabled:true,captureClicks:true,captureSubmits:true,captureChanges:true,maskAllInputs:true,maskAllText:false,throttleMs:100,maxTextLength:200,captureElementMetadata:true,captureAncestors:5,captureClickQuality:true},me=10,fe=["[data-veo-ignore]",".veo-ignore",'input[type="password"]','input[type="email"]','input[type="tel"]','input[type="hidden"]','[autocomplete="cc-number"]','[autocomplete="cc-csc"]','[autocomplete="cc-exp"]','[autocomplete="cc-name"]','[name*="password" i]','[name*="ssn" i]','[name*="credit" i]','[name*="card" i]','[id*="password" i]','[id*="ssn" i]'],ge=["value","data-credit-card","data-ssn","data-password"],ve=["id","name","type","role","href","data-action","data-veo-tag","data-testid","aria-label","aria-labelledby"],ye=[/^css-[a-z0-9]{4,}$/i,/^_[a-z0-9]+_[a-z0-9]{4,}_\d+$/,/^[a-z]{2,4}-[a-z0-9]{6,}$/i,/^[a-f0-9]{6,}$/i,/^sc-[a-z0-9]+$/i];function We(r){return ye.some(e=>e.test(r))}function w(r){return Array.from(r.classList).filter(e=>!We(e)&&e.length<64)}var je=["data-testid","data-test","data-cy","name","aria-label","placeholder","alt","title","href","role","type"],Fe=100;function B(r){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(r):r.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g,"\\$&")}function we(r){return r.replace(/[\\"]/g,"\\$&")}function Xe(r,e){for(let t of je){let n=r.getAttribute(t);if(n&&n.length>0&&n.length<=Fe)return `${e}[${t}="${we(n)}"]`}return null}function Ye(r){let e=r.tagName.toLowerCase(),t=r.getAttribute("data-veo-tag");if(t)return `${e}[data-veo-tag="${we(t)}"]`;if(r.id){let s=w(r),a=s.length>0?`.${s.map(B).join(".")}`:"";return `${e}#${B(r.id)}${a}`}let n=Xe(r,e);if(n)return n;let o=w(r),i=o.length>0?`.${o.map(B).join(".")}`:"";return `${e}${i}`}function A(r,e=5){let t=[],n=r,o=0;for(;n&&n!==document.documentElement&&o<=e;)t.unshift(Ye(n)),n=n.parentElement,o++;return t.join(" > ")}var Qe=new Set(["input","textarea","select","option","label"]),Je=200,Ze=3e3,et={reactionWindowMs:1e3,errorWindowMs:2e3,rageClicks:3,rageWindowMs:1e3,rageClicksSlow:5,rageWindowSlowMs:3e3,maxPerElement:50};function Ee(r){let e;if(r instanceof Error)e=`${r.name}: ${r.message}`;else if(typeof r=="string")e=r;else try{e=JSON.stringify(r)??String(r);}catch{e=String(r);}return e.slice(0,Je)}var T=class{constructor(e,t={}){this.emit=e;this.installed=false;this.cleanups=[];this.netCount=0;this.navCount=0;this.focusCount=0;this.unloading=false;this.errors=[];this.history=new Map;this.bursts=new Map;this.emitted=new Map;this.opts={...et,...t};}install(){if(this.installed||!c())return;this.installed=true;let e=(t,n,o=true)=>{window.addEventListener(t,n,o),this.cleanups.push(()=>window.removeEventListener(t,n,o));};e("error",t=>{let n=t;this.pushError("error",n.error??n.message??"error");}),e("unhandledrejection",t=>{this.pushError("unhandledrejection",t.reason??"rejection");}),e("popstate",()=>this.navCount++),e("hashchange",()=>this.navCount++),e("focusin",()=>this.focusCount++),e("pagehide",()=>{this.unloading=true;}),e("beforeunload",()=>{this.unloading=true;}),this.patchHistory(),this.patchConsole(),this.patchFetch(),this.patchXhr();}destroy(){for(let e of this.cleanups)e();this.cleanups=[];for(let e of this.bursts.values())window.clearTimeout(e.timer);this.bursts.clear(),this.history.clear(),this.installed=false;}onClick(e,t){if(!this.installed)return;let n=Date.now(),o={at:n,reacted:false};this.remember(e,o),this.observeReaction(e,o,t),this.observeErrors(e,n),this.trackRage(e,n);}observeReaction(e,t,n){let o=this.netCount,i=this.navCount,s=this.focusCount,a=window.location.href,l=this.isDeadExempt(e,n),u=null;typeof MutationObserver<"u"&&(u=new MutationObserver(()=>{t.reacted=true,u?.disconnect(),u=null;}),u.observe(document.documentElement,{childList:true,attributes:true,characterData:true,subtree:true})),window.setTimeout(()=>{u?.disconnect();let p=t.reacted||this.unloading||this.netCount!==o||this.navCount!==i||this.focusCount!==s||window.location.href!==a;t.reacted=p,!p&&!l&&this.report("$dead_click",e,{});},this.opts.reactionWindowMs);}isDeadExempt(e,t){if(t&&(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey)||t&&typeof t.button=="number"&&t.button!==0)return true;let n=e.tagName.toLowerCase();if(Qe.has(n)||e.closest('[contenteditable=""],[contenteditable="true"]'))return true;let o=e.closest("a");if(o){if(o.target==="_blank"||o.hasAttribute("download"))return true;let i=o.getAttribute("href")??"";if(/^(mailto|tel|sms):/i.test(i))return true}return false}observeErrors(e,t){let n=t+this.opts.errorWindowMs,o=()=>{let i=this.errors.find(s=>s.at>=t&&s.at<=n);if(i){this.report("$click_error",e,{$error_source:i.source,$error_message:i.message});return}Date.now()<n&&window.setTimeout(o,250);};window.setTimeout(o,250);}pushError(e,t){let n=Ee(t);if(n.startsWith("[veo]"))return;this.errors.push({at:Date.now(),source:e,message:n});let o=Date.now()-this.opts.errorWindowMs-1e3;for(;this.errors.length>0&&this.errors[0].at<o;)this.errors.shift();this.errors.length>50&&this.errors.splice(0,this.errors.length-50);}remember(e,t){let n=this.history.get(e)??[],o=t.at-Ze,i=n.filter(s=>s.at>=o);if(i.push(t),this.history.set(e,i),this.history.size>100)for(let[s,a]of this.history)a.every(l=>l.at<o)&&this.history.delete(s);}trackRage(e,t){let n=this.history.get(e)??[],o=n.filter(u=>u.at>=t-this.opts.rageWindowMs).length,i=n.filter(u=>u.at>=t-this.opts.rageWindowSlowMs).length,s=this.bursts.get(e),a=o>=this.opts.rageClicks||i>=this.opts.rageClicksSlow;if(!s&&!a)return;let l=s??{startedAt:(n.find(u=>u.at>=t-this.opts.rageWindowSlowMs)??{at:t}).at,count:0,timer:0};l.count=n.filter(u=>u.at>=l.startedAt).length,window.clearTimeout(l.timer),l.timer=window.setTimeout(()=>{this.bursts.delete(e);let u=(this.history.get(e)??[]).filter(p=>p.at>=l.startedAt);this.report("$rage_click",e,{$click_count:Math.max(u.length,l.count),$reacted_clicks:u.filter(p=>p.reacted).length});},this.opts.reactionWindowMs+50),this.bursts.set(e,l);}report(e,t,n){let o=A(t,5),i=this.emitted.get(o)??{$dead_click:0,$rage_click:0,$click_error:0};if(!(i[e]>=this.opts.maxPerElement)){i[e]++,this.emitted.set(o,i);try{this.emit(e,t,n);}catch{}}}patchHistory(){let e=window.history;if(!e)return;let t=e.pushState,n=e.replaceState,o=this;e.pushState=function(...i){return o.navCount++,t.apply(this,i)},e.replaceState=function(...i){return o.navCount++,n.apply(this,i)},this.cleanups.push(()=>{e.pushState=t,e.replaceState=n;});}patchConsole(){let e=console.error,t=this;console.error=function(...n){try{t.pushError("console",n.map(Ee).join(" "));}catch{}return e.apply(this,n)},this.cleanups.push(()=>{console.error=e;});}patchFetch(){if(typeof window.fetch!="function")return;let e=window.fetch,t=this;window.fetch=function(...n){t.netCount++;let o=e.apply(this,n);return o&&typeof o.then=="function"&&o.then(i=>{i&&i.status>=500&&t.pushError("fetch",`${i.status} ${i.url}`);},i=>t.pushError("fetch",i)),o},this.cleanups.push(()=>{window.fetch=e;});}patchXhr(){let e=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype:null;if(!e)return;let t=e.send,n=this;e.send=function(...o){n.netCount++;try{this.addEventListener("loadend",()=>{this.status>=500&&n.pushError("xhr",`${this.status} ${this.responseURL}`);});}catch{}return t.apply(this,o)},this.cleanups.push(()=>{e.send=t;});}};function _(r,e=[]){let t=[...fe,...e],n=r;for(;n&&n!==document.documentElement;){for(let o of t)try{if(n.matches(o))return !0}catch{}n=n.parentElement;}return false}function be(r){let e=r.toLowerCase();return ge.includes(e)||/password|secret|token|ssn|credit/i.test(r)}function Se(r,e,t){if(t)return "";let n=r.tagName.toLowerCase();if(n==="input"||n==="textarea")return "";let i=((r instanceof HTMLElement?r.innerText:"")||r.textContent||"").trim().replace(/\s+/g," ");return i.length>e?`${i.slice(0,e)}\u2026`:i}function tt(r){let e={};for(let t of ve){let n=r.getAttribute(t);n!==null&&!be(t)&&n.length<256&&(e[t]=n);}return e}function rt(r,e){let t=r.getBoundingClientRect();return {tag:r.tagName.toLowerCase(),id:r.id||null,classes:w(r),text:Se(r,e.maxTextLength,e.maskAllText),attributes:e.captureElementMetadata?tt(r):{},position:{x:Math.round(t.left+window.scrollX),y:Math.round(t.top+window.scrollY),w:Math.round(t.width),h:Math.round(t.height)}}}function nt(r,e){let t=[],n=r.parentElement,o=0;for(;n&&n!==document.documentElement&&o<e;)t.push({tag:n.tagName.toLowerCase(),id:n.id||null,classes:w(n),veoTag:n.getAttribute("data-veo-tag")||null}),n=n.parentElement,o++;return t}function K(r,e,t){return {$event_type:r,$element:rt(e,t),$ancestors:nt(e,t.captureAncestors),$selector_path:A(e,t.captureAncestors),$page_url:window.location.href,$page_path:window.location.pathname}}var I=class{constructor(e){this.windowMs=e;this.lastFired=new WeakMap;}shouldFire(e){let t=Date.now(),n=this.lastFired.get(e)??0;return t-n<this.windowMs?false:(this.lastFired.set(e,t),true)}};var C=class{constructor(e,t){this.client=e;this.cleanups=[];this.quality=null;let n=he;this.config={enabled:t.enabled??n.enabled,captureClicks:t.captureClicks??n.captureClicks,captureSubmits:t.captureSubmits??n.captureSubmits,captureChanges:t.captureChanges??n.captureChanges,maskAllInputs:t.maskAllInputs??n.maskAllInputs,maskAllText:t.maskAllText??n.maskAllText,blockSelectors:t.blockSelectors??[],throttleMs:t.throttleMs??n.throttleMs,maxTextLength:t.maxTextLength??n.maxTextLength,captureElementMetadata:t.captureElementMetadata??n.captureElementMetadata,captureAncestors:Math.min(t.captureAncestors??n.captureAncestors,me),captureClickQuality:t.captureClickQuality??n.captureClickQuality},this.throttle=new I(this.config.throttleMs);}install(){!d()||!this.config.enabled||(this.config.captureClicks&&this.config.captureClickQuality&&(this.quality=new T((e,t,n)=>{let o=K("click",t,this.config);this.client.track(e,{...o,...n});}),this.quality.install()),this.config.captureClicks&&this.attach("click",e=>this.handleClick(e)),this.config.captureSubmits&&this.attach("submit",e=>this.handleSubmit(e),true),this.config.captureChanges&&this.attach("change",e=>this.handleChange(e),true));}destroy(){for(let e of this.cleanups)e();this.cleanups=[],this.quality?.destroy(),this.quality=null;}attach(e,t,n=false){let o=i=>{if(i.isTrusted)try{t(i);}catch{}};document.addEventListener(e,o,n),this.cleanups.push(()=>document.removeEventListener(e,o,n));}handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=this.findMeaningfulAncestor(t);n&&(_(n,this.config.blockSelectors)||(this.quality?.onClick(n,e),this.throttle.shouldFire(n)&&this.emit("click",n)));}handleSubmit(e){let t=e.target;!(t instanceof Element)||t.tagName.toLowerCase()!=="form"||_(t,this.config.blockSelectors)||this.throttle.shouldFire(t)&&this.emit("submit",t);}handleChange(e){let t=e.target;if(!(t instanceof Element))return;let n=t.tagName.toLowerCase();n!=="select"&&n!=="input"&&n!=="textarea"||t instanceof HTMLInputElement&&t.type!=="checkbox"&&t.type!=="radio"||_(t,this.config.blockSelectors)||this.throttle.shouldFire(t)&&this.emit("change",t);}findMeaningfulAncestor(e){let t=e,n=0;for(;t&&t!==document.documentElement&&n<5;){let o=t.tagName.toLowerCase();if(o==="button"||o==="a"||o==="input"||o==="select"||o==="textarea"||t.hasAttribute("data-veo-tag")||t.hasAttribute("role")||t.hasAttribute("onclick")||t instanceof HTMLElement&&t.style.cursor==="pointer")return t;t=t.parentElement,n++;}return null}emit(e,t){let n=K(e,t,this.config);this.client.track("$autocapture",n);}};function H(r={}){let e=null;return {name:"autocapture",install(t){e=new C(t,r),e.install();},destroy(){e?.destroy(),e=null;}}}function G(){return {name:"spa-router",install(r){if(!c())return;r.pageview();let e=()=>{queueMicrotask(()=>r.pageview());},t=window.history.pushState,n=window.history.replaceState;window.history.pushState=function(...o){t.apply(this,o),e();},window.history.replaceState=function(...o){n.apply(this,o),e();},window.addEventListener("popstate",e),window.addEventListener("hashchange",e);}}}var ot="veo_theme_",_e=1440*60*1e3,Ae=4e3,it=4;function Te(r){try{let e=localStorage.getItem(r),t=e?JSON.parse(e):null;return t&&typeof t=="object"?t:{}}catch{return {}}}function st(r,e){try{localStorage.setItem(r,JSON.stringify(e));}catch{}}function at(r,e){let t=[r.documentElement.className,r.documentElement.dataset.theme,r.documentElement.dataset.mode,r.body?.className].join(" ").toLowerCase();return /\bdark\b/.test(t)?"dark":/\blight\b/.test(t)?"light":e?"dark":"light"}function ut(r,e,t){let n=r[e];return n!==void 0&&t-n.at<_e}function lt(r,e,t,n){let o=r[e];return !o||o.hash!==t||n-o.at>=_e}function Ie(r){let e=`${ot}${r.apiKey.slice(-16)||"default"}`,t=null,n=null,o=false,i=0,s=async()=>{if(o||i>=it)return;let l=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,u=at(document,l);if(!ut(Te(e),u,Date.now())){i++;try{let p=await r.loadDetector();if(!p||o)return;let h=p.detectTheme();if(!h)return;let X=p.snapshotHash(h),v=Te(e),Le=Date.now(),Y=()=>{let Q={hash:X,at:Date.now()};v[h.mode]=Q,v[u]=v[u]&&u!==h.mode?v[u]:Q,st(e,v);};if(!lt(v,h.mode,X,Le)){Y();return}r.debug&&console.log("[veo] theme snapshot",h),(await fetch(`${r.apiUrl}/v1/workspaces/theme-snapshot`,{method:"POST",headers:{"X-Api-Key":r.apiKey,"Content-Type":"application/json"},body:JSON.stringify(h),credentials:"omit"})).ok&&Y();}catch(p){r.debug&&console.warn("[veo] theme detect failed",p);}}},a=l=>{n&&clearTimeout(n),n=setTimeout(()=>{n=null;let u=window.requestIdleCallback;typeof u=="function"?u(()=>{s();}):s();},l);};return {name:"theme-detect",install(){!c()||!d()||(document.readyState==="complete"?a(Ae):window.addEventListener("load",()=>a(Ae),{once:true}),typeof MutationObserver=="function"&&(t=new MutationObserver(()=>a(1500)),t.observe(document.documentElement,{attributes:true,attributeFilter:["class","data-theme","data-mode"]})));},destroy(){o=true,t?.disconnect(),n&&clearTimeout(n);}}}function g(){let e=Date.now().toString(16).padStart(12,"0"),t=new Uint8Array(10);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(t);else for(let o=0;o<t.length;o++)t[o]=Math.floor(Math.random()*256);t[0]=(t[0]??0)&15|112,t[2]=(t[2]??0)&63|128;let n=Array.from(t,o=>o.toString(16).padStart(2,"0")).join("");return [e.slice(0,8),e.slice(8,12),n.slice(0,4),n.slice(4,8),n.slice(8,20)].join("-")}var k=class{constructor(e){this.config=e;this.buffer=[];this.timer=null;this.flushing=false;this.retryCount=0;this.retryTimer=null;this.startTimer();}add(e){this.buffer.push(e),this.buffer.length>=this.config.batchSize&&this.flush();}async flush(){if(this.flushing||this.buffer.length===0)return;this.flushing=true;let e=this.buffer.splice(0,this.buffer.length);try{await this.config.transport.send("/v1/events",{events:e}),this.retryCount=0;}catch(t){this.buffer.unshift(...e),this.scheduleRetry(),this.config.onError?.(t);}finally{this.flushing=false;}}flushBeacon(){if(this.buffer.length===0)return;let e=this.buffer.splice(0,this.buffer.length);this.config.transport.sendBeacon("/v1/events",{events:e})||this.buffer.unshift(...e);}destroy(){this.timer&&clearInterval(this.timer),this.retryTimer&&clearTimeout(this.retryTimer),this.timer=null,this.retryTimer=null;}startTimer(){this.timer=setInterval(()=>{this.flush();},this.config.flushIntervalMs);}scheduleRetry(){let e=this.config.maxRetries??3;if(this.retryCount>=e){this.retryCount=0;return}this.retryCount++;let t=Math.min(1e3*2**(this.retryCount-1),3e4),n=t/2+Math.random()*(t/2);this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{this.flush();},n);}};var Ce="anonymous_user_id",q="end_user_id",P="session_id",E="session_last_active",ke=1800*1e3,x=class{constructor(e){this.storage=e;this._endUserId=null;this._anonymousId=this.loadOrCreateAnonymousId(),this._sessionId=this.loadOrCreateSession(),this._endUserId=this.storage.get(q);}get anonymousId(){return this._anonymousId}get sessionId(){return this._sessionId}get endUserId(){return this._endUserId}get effectiveUserId(){return this._endUserId??this._anonymousId}setEndUserId(e){this._endUserId=e,this.storage.set(q,e);}touch(){let e=this.storage.get(E),t=Date.now();e&&t-Number.parseInt(e,10)>ke&&(this._sessionId=g(),this.storage.set(P,this._sessionId)),this.storage.set(E,String(t));}reset(){this._endUserId=null,this.storage.remove(q),this._sessionId=g(),this.storage.set(P,this._sessionId),this.storage.set(E,String(Date.now()));}loadOrCreateAnonymousId(){let e=this.storage.get(Ce);return e||(e=g(),this.storage.set(Ce,e)),e}loadOrCreateSession(){let e=this.storage.get(P),t=this.storage.get(E);if(e&&t&&Date.now()-Number.parseInt(t,10)<ke)return e;let n=g();return this.storage.set(P,n),this.storage.set(E,String(Date.now())),n}};var m="veo:",ct=365*24*60*60*1e3,R=class{get(e){return localStorage.getItem(m+e)}set(e,t){try{localStorage.setItem(m+e,t);}catch{}}remove(e){localStorage.removeItem(m+e);}clear(){let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(m)&&e.push(n);}for(let t of e)localStorage.removeItem(t);}};function Pe(){let r=document.cookie;return r===""?[]:r.split("; ")}var M=class{get(e){let t=`${m}${e}=`;for(let n of Pe())if(n.startsWith(t))return decodeURIComponent(n.slice(t.length));return null}set(e,t,n){let o=Math.floor((n?.ttlMs??ct)/1e3),i=typeof location<"u"&&location.protocol==="https:"?"; Secure":"";document.cookie=`${m}${e}=${encodeURIComponent(t)}; Path=/; Max-Age=${o}; SameSite=Lax${i}`;}remove(e){document.cookie=`${m}${e}=; Path=/; Max-Age=0; SameSite=Lax`;}clear(){for(let e of Pe()){let t=e.indexOf("="),n=t===-1?e:e.slice(0,t);n.startsWith(m)&&this.remove(n.slice(m.length));}}},U=class{constructor(){this.store=new Map;}get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t);}remove(e){this.store.delete(e);}clear(){this.store.clear();}};function xe(r="localStorage"){return r==="localStorage"&&O()?new R:r==="cookie"&&d()?new M:r==="memory"?new U:O()?new R:d()?new M:new U}var z=class extends Error{constructor(t,n){super(t);this.statusCode=n;this.name="TransportError";}},L=class{constructor(e){this.config=e;}async send(e,t){let n=`${this.config.apiUrl}${e}`,o=new AbortController,i=this.config.timeoutMs??1e4,s=setTimeout(()=>o.abort(new DOMException(`Veo request timeout (${i}ms)`,"TimeoutError")),i);try{let a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":this.config.apiKey,"X-Sdk-Version":this.config.sdkVersion},body:JSON.stringify(t),signal:o.signal});if(!a.ok)throw new z(`HTTP ${a.status}`,a.status);return await a.json()}finally{clearTimeout(s);}}sendBeacon(e,t){if(!Z())return false;let n=new URL(`${this.config.apiUrl}${e}`);n.searchParams.set("key",this.config.apiKey),n.searchParams.set("v",this.config.sdkVersion);let o=new Blob([JSON.stringify(t)],{type:"application/json"});return navigator.sendBeacon(n.toString(),o)}};var W="organization_id",Re="end_user_id",j="identify_signature";function F(r){return r===null||typeof r!="object"?JSON.stringify(r)??"null":Array.isArray(r)?`[${r.map(F).join(",")}]`:`{${Object.keys(r).sort().map(t=>`${JSON.stringify(t)}:${F(r[t])}`).join(",")}}`}var b=class{constructor(e){this.config=e;this.plugins=[];this.currentOrganizationId=null;this.listeners={pageview:new Set,identify:new Set};if(!e.apiKey)throw new Error("apiKey is required");this.storage=xe(e.storage??"localStorage"),this.session=new x(this.storage),this.transport=new L({apiKey:e.apiKey,apiUrl:f(e).replace(/\/$/,""),sdkVersion:D}),this.queue=new k({transport:this.transport,flushIntervalMs:e.flushInterval??5e3,batchSize:e.flushBatchSize??20,onError:o=>{e.debug&&console.error("[veo] flush error:",o);}});let t=this.storage.get(Re);t&&this.session.setEndUserId(t);let n=this.storage.get(W);n&&(this.currentOrganizationId=n),this.setupUnloadHandlers(),e.debug&&console.log("[veo] initialized",{anonymousId:this.session.anonymousId,sessionId:this.session.sessionId,endUserId:this.session.endUserId});}identify(e){let{visitor:t,organization:n}=e,o=F({id:t.id,traits:t.traits??{},org:n?{id:n.id,attributes:n.attributes??{}}:null});if(this.session.endUserId===t.id&&this.storage.get(j)===o){this.config.debug&&console.debug("[veo] identify: sin cambios, omitido");return}let i=this.session.endUserId===null?this.session.anonymousId:void 0;this.session.setEndUserId(t.id),n&&(this.currentOrganizationId=n.id,this.storage.set(W,n.id));let a={endUser:{id:t.id,traits:t.traits??{},...i!==void 0?{anonymousId:i}:{}},...n?{organization:{id:n.id,attributes:n.attributes??{}}}:{}};this.transport.send("/v1/identify",a).catch(l=>{this.config.debug&&console.error("[veo] identify failed:",l);}),this.enqueue({actionType:"identify",actionProperties:{traits:t.traits,organizationAttributes:n?.attributes}}),this.storage.set(j,o),this.emit("identify",{endUserId:t.id,sessionId:this.session.sessionId});}track(e,t){if(!e||typeof e!="string"){this.config.debug&&console.error("[veo] track: name is required");return}this.enqueue({actionType:"track",actionName:e,...t!==void 0?{actionProperties:t}:{}});}pageview(e){if(!d())return;let t=window.location.href,n=e??window.location.pathname;this.enqueue({actionType:"pageview",pageUrl:t,pagePath:n,pageTitle:document.title,pageReferrer:document.referrer}),this.emit("pageview",{url:t,path:n,sessionId:this.session.sessionId,endUserId:this.session.endUserId});}reset(){this.session.reset(),this.currentOrganizationId=null,this.storage.remove(W),this.storage.remove(Re),this.storage.remove(j);}flush(){return this.queue.flush()}use(e){return this.plugins.push(e),e.install(this),this}getEndUserId(){return this.session.endUserId}getAnonymousId(){return this.session.anonymousId}getSessionId(){return this.session.sessionId}on(e,t){return this.listeners[e].add(t),()=>{this.listeners[e].delete(t);}}emit(e,t){for(let n of this.listeners[e])try{n(t);}catch(o){this.config.debug&&console.error(`[veo] listener for '${e}' failed:`,o);}}enqueue(e){this.session.touch();let t=this.currentOrganizationId??void 0,n=e.pageUrl??(c()?window.location.href:void 0),o=e.pagePath??(c()?window.location.pathname:void 0),i=e.pageTitle??(d()?document.title:void 0),s=e.pageReferrer??(d()?document.referrer:void 0),a={actionId:g(),endUserId:this.session.effectiveUserId,sessionId:this.session.sessionId,actionType:e.actionType,occurredAt:new Date().toISOString(),...t!==void 0?{organizationId:t}:{},...e.actionName!==void 0?{actionName:e.actionName}:{},...n!==void 0?{pageUrl:n}:{},...o!==void 0?{pagePath:o}:{},...i!==void 0?{pageTitle:i}:{},...s!==void 0?{pageReferrer:s}:{},...e.actionProperties!==void 0?{actionProperties:e.actionProperties}:{}};this.queue.add(a);}setupUnloadHandlers(){c()&&(window.addEventListener("pagehide",()=>this.queue.flushBeacon()),window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.queue.flushBeacon();}));}};function Me(r,e,t,n){let o=new b(r);if(o.use(G()),r.autocapture!==false){let i=typeof r.autocapture=="object"?r.autocapture:{};o.use(H(i));}if(r.detectTheme!==false&&n&&!y()&&o.use(Ie({apiUrl:f(r),apiKey:r.apiKey,loadDetector:n,...r.debug!==void 0?{debug:r.debug}:{}})),e(o),typeof window<"u"){let s=window.veo?._q??[];window.veo=o;for(let a of s){let[l,u]=a;if(l==="init")continue;let p=o[l];if(typeof p=="function")try{p.apply(o,Array.from(u));}catch(h){r.debug&&console.error("[veo] drain error:",h);}}ce({...r.builderUrl!==void 0?{builderUrl:r.builderUrl}:{},...r.debug!==void 0?{debug:r.debug}:{},...r.apiKey!==void 0?{apiKey:r.apiKey}:{},apiUrl:f(r),...{}});}return o}function Ue(r){if(!c()||!d())return Promise.resolve(null);let e=window;if(e.veoTheme)return Promise.resolve(e.veoTheme);let t=r.themeUrl??ht();return t?new Promise(n=>{let o=document.createElement("script");o.src=t,o.async=true,o.addEventListener("load",()=>n(e.veoTheme??null)),o.addEventListener("error",()=>{r.debug&&console.error("[veo] no pude cargar",t),n(null);}),document.head.appendChild(o);}):(r.debug&&console.warn("[veo] no pude resolver la URL de veo-theme.js"),Promise.resolve(null))}function ht(){let r=document.querySelectorAll("script[src]");for(let e of Array.from(r))if(/\bveo(\.min)?\.js(\?.*)?$/.test(e.src))return e.src.replace(/\bveo(\.min)?\.js/,"veo-theme$1.js");return null}function Vr(r){let e=f(r);return Me(r,t=>{let n=()=>pe({...r.guidesUrl!==void 0?{guidesUrl:r.guidesUrl}:{},...r.debug!==void 0?{debug:r.debug}:{}}),o=V();r.guides===true&&!y()&&o===null&&n().then(i=>{i&&t.use(i.guidesPlugin({apiUrl:e,apiKey:r.apiKey,...r.debug!==void 0?{debug:r.debug}:{}}));}),o!==null&&n().then(i=>i?.runPreviewMode({apiKey:r.apiKey,apiUrl:e,token:o,...r.debug!==void 0?{debug:r.debug}:{}})),t.preview=i=>{let s=null,a=n().then(l=>l?(s=l.previewGuide(i),s.ready):{rendered:false});return {close:()=>s?.close(),ready:a,host:()=>s?.host()??null}},t.closePreview=()=>{n().then(i=>i?.closeGuidePreview());};},void 0,()=>Ue({...r.themeUrl!==void 0?{themeUrl:r.themeUrl}:{},...r.debug!==void 0?{debug:r.debug}:{}}))}
|
|
2
|
-
exports.Client=b;exports.SDK_VERSION=
|
|
1
|
+
var veo=(function(exports){'use strict';var S="0.6.4";var J="https://veo-backend-production-8c78.up.railway.app";function f(r){let e=r?.apiUrl;if(typeof e=="string"&&e.trim())return e;let t=globalThis.__VEO_API_URL__;return typeof t=="string"&&t.trim()?t:J}function c(){return typeof window<"u"}function d(){return typeof document<"u"}function D(){try{if(typeof localStorage>"u")return !1;let r="__veo_test__";return localStorage.setItem(r,"1"),localStorage.removeItem(r),!0}catch{return false}}function Z(){return typeof navigator<"u"&&typeof navigator.sendBeacon=="function"}var A="veoBuilder",ee="veoBuilderOrigin",te="veoBuilderPanel",re="veoBuilderPanelPath",ne="veoGuide";var Oe="veoPreview",oe="veo:preview_token";function De(){try{return window.sessionStorage}catch{return null}}function V(){if(!c())return null;let r=null;try{let t=new URLSearchParams(window.location.search).get(Oe);r=t||null;}catch{r=null;}let e=De();if(r){try{e?.setItem(oe,r);}catch{}return r}try{return e?.getItem(oe)||null}catch{return null}}function ie(){return V()!==null}var $="veo:builder_ctx",se="veo:builder_ctx:",Ve=1800*1e3;function N(){try{return window.sessionStorage}catch{return null}}function ae(){try{return window.localStorage}catch{return null}}function $e(r){return se+(r||"default")}function Ne(r){try{N()?.setItem($,JSON.stringify(r));}catch{}try{let e={...r,savedAt:Date.now()};ae()?.setItem($e(r.guide),JSON.stringify(e));}catch{}}function Be(){let r=ae();if(!r)return null;let e=null;try{for(let o=0;o<r.length;o++){let i=r.key(o);if(!i?.startsWith(se))continue;let s=r.getItem(i);if(!s)continue;let a=null;try{a=JSON.parse(s);}catch{continue}if(typeof a?.savedAt!="number"||Date.now()-a.savedAt>Ve){try{r.removeItem(i);}catch{}continue}(!e||a.savedAt>e.savedAt)&&(e=a);}}catch{return null}if(!e)return null;let{savedAt:t,...n}=e;return n}function Ke(){try{let r=new URLSearchParams(window.location.search);if(r.get(A))return r;let e=window.location.hash.replace(/^#/,"");return e.includes(`${A}=`)?new URLSearchParams(e):r}catch{return null}}function ue(){if(!c())return null;let r=Ke(),e=r?.get(A);if(e){let n={token:e,origin:r?.get(ee)??null,panel:r?.get(te)==="1",guide:r?.get(ne)??null,panelPath:r?.get(re)??null};return Ne(n),n}if(ie())return null;try{let n=N()?.getItem($);if(n)return JSON.parse(n)}catch{}let t=Be();if(t)try{N()?.setItem($,JSON.stringify(t));}catch{}return t}function le(){return ue()?.token??null}function y(){return ue()!==null}function ce(r){if(!c()||!d()||le()===null||(r.apiKey&&r.apiUrl&&(window.__veoBuilder={apiKey:r.apiKey,apiUrl:r.apiUrl}),window.veoBuilder))return;let e=r.builderUrl??He();if(e){if(document.querySelector(`script[src="${e}"]`))return;let t=document.createElement("script");t.src=e,t.async=true,r.debug&&t.addEventListener("error",()=>console.error("[veo] no pude cargar",e)),document.head.appendChild(t);return}if(r.loadBuilder){r.loadBuilder().catch(t=>{r.debug&&console.error("[veo] no pude cargar el builder (import din\xE1mico)",t);});return}r.debug&&console.warn("[veo] builder mode pedido pero no pude resolver la URL de veo-builder.js");}function He(){let r=document.querySelectorAll("script[src]");for(let e of Array.from(r))if(/\bveo(\.min)?\.js(\?.*)?$/.test(e.src))return e.src.replace(/\bveo(\.min)?\.js/,"veo-builder$1.js");return null}var de=null;function pe(r){return de??(de=Ge(r)),de}function Ge(r){return new Promise(e=>{if(!c()||!d()){e(null);return}let t=window;if(t.veoGuides){e(t.veoGuides);return}let n=r.guidesUrl??qe();if(!n){r.debug&&console.warn("[veo] no pude resolver la URL de veo-guides.js"),e(null);return}let o=()=>e(t.veoGuides??null),i=document.querySelector(`script[src="${n}"]`);if(i){i.addEventListener("load",o),i.addEventListener("error",()=>e(null));return}let s=document.createElement("script");s.src=n,s.async=true,s.addEventListener("load",o),s.addEventListener("error",()=>{r.debug&&console.error("[veo] no pude cargar",n),e(null);}),document.head.appendChild(s);})}function qe(){let r=document.querySelectorAll("script[src]");for(let e of Array.from(r))if(/\bveo(\.min)?\.js(\?.*)?$/.test(e.src))return e.src.replace(/\bveo(\.min)?\.js/,"veo-guides$1.js");return null}function ze(r){return r}var he={enabled:true,captureClicks:true,captureSubmits:true,captureChanges:true,maskAllInputs:true,maskAllText:false,throttleMs:100,maxTextLength:200,captureElementMetadata:true,captureAncestors:5,captureClickQuality:true},me=10,fe=["[data-veo-ignore]",".veo-ignore",'input[type="password"]','input[type="email"]','input[type="tel"]','input[type="hidden"]','[autocomplete="cc-number"]','[autocomplete="cc-csc"]','[autocomplete="cc-exp"]','[autocomplete="cc-name"]','[name*="password" i]','[name*="ssn" i]','[name*="credit" i]','[name*="card" i]','[id*="password" i]','[id*="ssn" i]'],ge=["value","data-credit-card","data-ssn","data-password"],ve=["id","name","type","role","href","data-action","data-veo-tag","data-testid","aria-label","aria-labelledby"],ye=[/^css-[a-z0-9]{4,}$/i,/^_[a-z0-9]+_[a-z0-9]{4,}_\d+$/,/^[a-z]{2,4}-[a-z0-9]{6,}$/i,/^[a-f0-9]{6,}$/i,/^sc-[a-z0-9]+$/i];function We(r){return ye.some(e=>e.test(r))}function w(r){return Array.from(r.classList).filter(e=>!We(e)&&e.length<64)}var je=["data-testid","data-test","data-cy","name","aria-label","placeholder","alt","title","href","role","type"],Fe=100;function B(r){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(r):r.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g,"\\$&")}function we(r){return r.replace(/[\\"]/g,"\\$&")}function Xe(r,e){for(let t of je){let n=r.getAttribute(t);if(n&&n.length>0&&n.length<=Fe)return `${e}[${t}="${we(n)}"]`}return null}function Ye(r){let e=r.tagName.toLowerCase(),t=r.getAttribute("data-veo-tag");if(t)return `${e}[data-veo-tag="${we(t)}"]`;if(r.id){let s=w(r),a=s.length>0?`.${s.map(B).join(".")}`:"";return `${e}#${B(r.id)}${a}`}let n=Xe(r,e);if(n)return n;let o=w(r),i=o.length>0?`.${o.map(B).join(".")}`:"";return `${e}${i}`}function _(r,e=5){let t=[],n=r,o=0;for(;n&&n!==document.documentElement&&o<=e;)t.unshift(Ye(n)),n=n.parentElement,o++;return t.join(" > ")}var Qe=new Set(["input","textarea","select","option","label"]),Je=200,Ze=3e3,et={reactionWindowMs:1e3,errorWindowMs:2e3,rageClicks:3,rageWindowMs:1e3,rageClicksSlow:5,rageWindowSlowMs:3e3,maxPerElement:50};function Ee(r){let e;if(r instanceof Error)e=`${r.name}: ${r.message}`;else if(typeof r=="string")e=r;else try{e=JSON.stringify(r)??String(r);}catch{e=String(r);}return e.slice(0,Je)}var T=class{constructor(e,t={}){this.emit=e;this.installed=false;this.cleanups=[];this.netCount=0;this.navCount=0;this.focusCount=0;this.unloading=false;this.errors=[];this.history=new Map;this.bursts=new Map;this.emitted=new Map;this.opts={...et,...t};}install(){if(this.installed||!c())return;this.installed=true;let e=(t,n,o=true)=>{window.addEventListener(t,n,o),this.cleanups.push(()=>window.removeEventListener(t,n,o));};e("error",t=>{let n=t;this.pushError("error",n.error??n.message??"error");}),e("unhandledrejection",t=>{this.pushError("unhandledrejection",t.reason??"rejection");}),e("popstate",()=>this.navCount++),e("hashchange",()=>this.navCount++),e("focusin",()=>this.focusCount++),e("pagehide",()=>{this.unloading=true;}),e("beforeunload",()=>{this.unloading=true;}),this.patchHistory(),this.patchConsole(),this.patchFetch(),this.patchXhr();}destroy(){for(let e of this.cleanups)e();this.cleanups=[];for(let e of this.bursts.values())window.clearTimeout(e.timer);this.bursts.clear(),this.history.clear(),this.installed=false;}onClick(e,t){if(!this.installed)return;let n=Date.now(),o={at:n,reacted:false};this.remember(e,o),this.observeReaction(e,o,t),this.observeErrors(e,n),this.trackRage(e,n);}observeReaction(e,t,n){let o=this.netCount,i=this.navCount,s=this.focusCount,a=window.location.href,l=this.isDeadExempt(e,n),u=null;typeof MutationObserver<"u"&&(u=new MutationObserver(()=>{t.reacted=true,u?.disconnect(),u=null;}),u.observe(document.documentElement,{childList:true,attributes:true,characterData:true,subtree:true})),window.setTimeout(()=>{u?.disconnect();let p=t.reacted||this.unloading||this.netCount!==o||this.navCount!==i||this.focusCount!==s||window.location.href!==a;t.reacted=p,!p&&!l&&this.report("$dead_click",e,{});},this.opts.reactionWindowMs);}isDeadExempt(e,t){if(t&&(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey)||t&&typeof t.button=="number"&&t.button!==0)return true;let n=e.tagName.toLowerCase();if(Qe.has(n)||e.closest('[contenteditable=""],[contenteditable="true"]'))return true;let o=e.closest("a");if(o){if(o.target==="_blank"||o.hasAttribute("download"))return true;let i=o.getAttribute("href")??"";if(/^(mailto|tel|sms):/i.test(i))return true}return false}observeErrors(e,t){let n=t+this.opts.errorWindowMs,o=()=>{let i=this.errors.find(s=>s.at>=t&&s.at<=n);if(i){this.report("$click_error",e,{$error_source:i.source,$error_message:i.message});return}Date.now()<n&&window.setTimeout(o,250);};window.setTimeout(o,250);}pushError(e,t){let n=Ee(t);if(n.startsWith("[veo]"))return;this.errors.push({at:Date.now(),source:e,message:n});let o=Date.now()-this.opts.errorWindowMs-1e3;for(;this.errors.length>0&&this.errors[0].at<o;)this.errors.shift();this.errors.length>50&&this.errors.splice(0,this.errors.length-50);}remember(e,t){let n=this.history.get(e)??[],o=t.at-Ze,i=n.filter(s=>s.at>=o);if(i.push(t),this.history.set(e,i),this.history.size>100)for(let[s,a]of this.history)a.every(l=>l.at<o)&&this.history.delete(s);}trackRage(e,t){let n=this.history.get(e)??[],o=n.filter(u=>u.at>=t-this.opts.rageWindowMs).length,i=n.filter(u=>u.at>=t-this.opts.rageWindowSlowMs).length,s=this.bursts.get(e),a=o>=this.opts.rageClicks||i>=this.opts.rageClicksSlow;if(!s&&!a)return;let l=s??{startedAt:(n.find(u=>u.at>=t-this.opts.rageWindowSlowMs)??{at:t}).at,count:0,timer:0};l.count=n.filter(u=>u.at>=l.startedAt).length,window.clearTimeout(l.timer),l.timer=window.setTimeout(()=>{this.bursts.delete(e);let u=(this.history.get(e)??[]).filter(p=>p.at>=l.startedAt);this.report("$rage_click",e,{$click_count:Math.max(u.length,l.count),$reacted_clicks:u.filter(p=>p.reacted).length});},this.opts.reactionWindowMs+50),this.bursts.set(e,l);}report(e,t,n){let o=_(t,5),i=this.emitted.get(o)??{$dead_click:0,$rage_click:0,$click_error:0};if(!(i[e]>=this.opts.maxPerElement)){i[e]++,this.emitted.set(o,i);try{this.emit(e,t,n);}catch{}}}patchHistory(){let e=window.history;if(!e)return;let t=e.pushState,n=e.replaceState,o=this;e.pushState=function(...i){return o.navCount++,t.apply(this,i)},e.replaceState=function(...i){return o.navCount++,n.apply(this,i)},this.cleanups.push(()=>{e.pushState=t,e.replaceState=n;});}patchConsole(){let e=console.error,t=this;console.error=function(...n){try{t.pushError("console",n.map(Ee).join(" "));}catch{}return e.apply(this,n)},this.cleanups.push(()=>{console.error=e;});}patchFetch(){if(typeof window.fetch!="function")return;let e=window.fetch,t=this;window.fetch=function(...n){t.netCount++;let o=e.apply(this,n);return o&&typeof o.then=="function"&&o.then(i=>{i&&i.status>=500&&t.pushError("fetch",`${i.status} ${i.url}`);},i=>t.pushError("fetch",i)),o},this.cleanups.push(()=>{window.fetch=e;});}patchXhr(){let e=typeof XMLHttpRequest<"u"?XMLHttpRequest.prototype:null;if(!e)return;let t=e.send,n=this;e.send=function(...o){n.netCount++;try{this.addEventListener("loadend",()=>{this.status>=500&&n.pushError("xhr",`${this.status} ${this.responseURL}`);});}catch{}return t.apply(this,o)},this.cleanups.push(()=>{e.send=t;});}};function I(r,e=[]){let t=[...fe,...e],n=r;for(;n&&n!==document.documentElement;){for(let o of t)try{if(n.matches(o))return !0}catch{}n=n.parentElement;}return false}function be(r){let e=r.toLowerCase();return ge.includes(e)||/password|secret|token|ssn|credit/i.test(r)}function Se(r,e,t){if(t)return "";let n=r.tagName.toLowerCase();if(n==="input"||n==="textarea")return "";let i=((r instanceof HTMLElement?r.innerText:"")||r.textContent||"").trim().replace(/\s+/g," ");return i.length>e?`${i.slice(0,e)}\u2026`:i}function tt(r){let e={};for(let t of ve){let n=r.getAttribute(t);n!==null&&!be(t)&&n.length<256&&(e[t]=n);}return e}function rt(r,e){let t=r.getBoundingClientRect();return {tag:r.tagName.toLowerCase(),id:r.id||null,classes:w(r),text:Se(r,e.maxTextLength,e.maskAllText),attributes:e.captureElementMetadata?tt(r):{},position:{x:Math.round(t.left+window.scrollX),y:Math.round(t.top+window.scrollY),w:Math.round(t.width),h:Math.round(t.height)}}}function nt(r,e){let t=[],n=r.parentElement,o=0;for(;n&&n!==document.documentElement&&o<e;)t.push({tag:n.tagName.toLowerCase(),id:n.id||null,classes:w(n),veoTag:n.getAttribute("data-veo-tag")||null}),n=n.parentElement,o++;return t}function K(r,e,t){return {$event_type:r,$element:rt(e,t),$ancestors:nt(e,t.captureAncestors),$selector_path:_(e,t.captureAncestors),$page_url:window.location.href,$page_path:window.location.pathname}}var C=class{constructor(e){this.windowMs=e;this.lastFired=new WeakMap;}shouldFire(e){let t=Date.now(),n=this.lastFired.get(e)??0;return t-n<this.windowMs?false:(this.lastFired.set(e,t),true)}};var k=class{constructor(e,t){this.client=e;this.cleanups=[];this.quality=null;let n=he;this.config={enabled:t.enabled??n.enabled,captureClicks:t.captureClicks??n.captureClicks,captureSubmits:t.captureSubmits??n.captureSubmits,captureChanges:t.captureChanges??n.captureChanges,maskAllInputs:t.maskAllInputs??n.maskAllInputs,maskAllText:t.maskAllText??n.maskAllText,blockSelectors:t.blockSelectors??[],throttleMs:t.throttleMs??n.throttleMs,maxTextLength:t.maxTextLength??n.maxTextLength,captureElementMetadata:t.captureElementMetadata??n.captureElementMetadata,captureAncestors:Math.min(t.captureAncestors??n.captureAncestors,me),captureClickQuality:t.captureClickQuality??n.captureClickQuality},this.throttle=new C(this.config.throttleMs);}install(){!d()||!this.config.enabled||(this.config.captureClicks&&this.config.captureClickQuality&&(this.quality=new T((e,t,n)=>{let o=K("click",t,this.config);this.client.track(e,{...o,...n});}),this.quality.install()),this.config.captureClicks&&this.attach("click",e=>this.handleClick(e)),this.config.captureSubmits&&this.attach("submit",e=>this.handleSubmit(e),true),this.config.captureChanges&&this.attach("change",e=>this.handleChange(e),true));}destroy(){for(let e of this.cleanups)e();this.cleanups=[],this.quality?.destroy(),this.quality=null;}attach(e,t,n=false){let o=i=>{if(i.isTrusted)try{t(i);}catch{}};document.addEventListener(e,o,n),this.cleanups.push(()=>document.removeEventListener(e,o,n));}handleClick(e){let t=e.target;if(!(t instanceof Element))return;let n=this.findMeaningfulAncestor(t);n&&(I(n,this.config.blockSelectors)||(this.quality?.onClick(n,e),this.throttle.shouldFire(n)&&this.emit("click",n)));}handleSubmit(e){let t=e.target;!(t instanceof Element)||t.tagName.toLowerCase()!=="form"||I(t,this.config.blockSelectors)||this.throttle.shouldFire(t)&&this.emit("submit",t);}handleChange(e){let t=e.target;if(!(t instanceof Element))return;let n=t.tagName.toLowerCase();n!=="select"&&n!=="input"&&n!=="textarea"||t instanceof HTMLInputElement&&t.type!=="checkbox"&&t.type!=="radio"||I(t,this.config.blockSelectors)||this.throttle.shouldFire(t)&&this.emit("change",t);}findMeaningfulAncestor(e){let t=e,n=0;for(;t&&t!==document.documentElement&&n<5;){let o=t.tagName.toLowerCase();if(o==="button"||o==="a"||o==="input"||o==="select"||o==="textarea"||t.hasAttribute("data-veo-tag")||t.hasAttribute("role")||t.hasAttribute("onclick")||t instanceof HTMLElement&&t.style.cursor==="pointer")return t;t=t.parentElement,n++;}return null}emit(e,t){let n=K(e,t,this.config);this.client.track("$autocapture",n);}};function H(r={}){let e=null;return {name:"autocapture",install(t){e=new k(t,r),e.install();},destroy(){e?.destroy(),e=null;}}}function G(){return {name:"spa-router",install(r){if(!c())return;r.pageview();let e=()=>{queueMicrotask(()=>r.pageview());},t=window.history.pushState,n=window.history.replaceState;window.history.pushState=function(...o){t.apply(this,o),e();},window.history.replaceState=function(...o){n.apply(this,o),e();},window.addEventListener("popstate",e),window.addEventListener("hashchange",e);}}}var ot="veo_theme_",Te=1440*60*1e3,Ae=4e3,it=4;function _e(r){try{let e=localStorage.getItem(r),t=e?JSON.parse(e):null;return t&&typeof t=="object"?t:{}}catch{return {}}}function st(r,e){try{localStorage.setItem(r,JSON.stringify(e));}catch{}}function at(r,e){let t=[r.documentElement.className,r.documentElement.dataset.theme,r.documentElement.dataset.mode,r.body?.className].join(" ").toLowerCase();return /\bdark\b/.test(t)?"dark":/\blight\b/.test(t)?"light":e?"dark":"light"}function ut(r,e,t){let n=r[e];return n!==void 0&&t-n.at<Te}function lt(r,e,t,n){let o=r[e];return !o||o.hash!==t||n-o.at>=Te}function Ie(r){let e=`${ot}${r.apiKey.slice(-16)||"default"}`,t=null,n=null,o=false,i=0,s=async()=>{if(o||i>=it)return;let l=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches,u=at(document,l);if(!ut(_e(e),u,Date.now())){i++;try{let p=await r.loadDetector();if(!p||o)return;let h=p.detectTheme();if(!h)return;let X=p.snapshotHash(h),v=_e(e),Le=Date.now(),Y=()=>{let Q={hash:X,at:Date.now()};v[h.mode]=Q,v[u]=v[u]&&u!==h.mode?v[u]:Q,st(e,v);};if(!lt(v,h.mode,X,Le)){Y();return}r.debug&&console.log("[veo] theme snapshot",h),(await fetch(`${r.apiUrl}/v1/workspaces/theme-snapshot`,{method:"POST",headers:{"X-Api-Key":r.apiKey,"Content-Type":"application/json"},body:JSON.stringify(h),credentials:"omit"})).ok&&Y();}catch(p){r.debug&&console.warn("[veo] theme detect failed",p);}}},a=l=>{n&&clearTimeout(n),n=setTimeout(()=>{n=null;let u=window.requestIdleCallback;typeof u=="function"?u(()=>{s();}):s();},l);};return {name:"theme-detect",install(){!c()||!d()||(document.readyState==="complete"?a(Ae):window.addEventListener("load",()=>a(Ae),{once:true}),typeof MutationObserver=="function"&&(t=new MutationObserver(()=>a(1500)),t.observe(document.documentElement,{attributes:true,attributeFilter:["class","data-theme","data-mode"]})));},destroy(){o=true,t?.disconnect(),n&&clearTimeout(n);}}}function g(){let e=Date.now().toString(16).padStart(12,"0"),t=new Uint8Array(10);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(t);else for(let o=0;o<t.length;o++)t[o]=Math.floor(Math.random()*256);t[0]=(t[0]??0)&15|112,t[2]=(t[2]??0)&63|128;let n=Array.from(t,o=>o.toString(16).padStart(2,"0")).join("");return [e.slice(0,8),e.slice(8,12),n.slice(0,4),n.slice(4,8),n.slice(8,20)].join("-")}var P=class{constructor(e){this.config=e;this.buffer=[];this.timer=null;this.flushing=false;this.retryCount=0;this.retryTimer=null;this.startTimer();}add(e){this.buffer.push(e),this.buffer.length>=this.config.batchSize&&this.flush();}async flush(){if(this.flushing||this.buffer.length===0)return;this.flushing=true;let e=this.buffer.splice(0,this.buffer.length);try{await this.config.transport.send("/v1/events",{events:e}),this.retryCount=0;}catch(t){this.buffer.unshift(...e),this.scheduleRetry(),this.config.onError?.(t);}finally{this.flushing=false;}}flushBeacon(){if(this.buffer.length===0)return;let e=this.buffer.splice(0,this.buffer.length);this.config.transport.sendBeacon("/v1/events",{events:e})||this.buffer.unshift(...e);}destroy(){this.timer&&clearInterval(this.timer),this.retryTimer&&clearTimeout(this.retryTimer),this.timer=null,this.retryTimer=null;}startTimer(){this.timer=setInterval(()=>{this.flush();},this.config.flushIntervalMs);}scheduleRetry(){let e=this.config.maxRetries??3;if(this.retryCount>=e){this.retryCount=0;return}this.retryCount++;let t=Math.min(1e3*2**(this.retryCount-1),3e4),n=t/2+Math.random()*(t/2);this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{this.flush();},n);}};var Ce="anonymous_user_id",q="end_user_id",x="session_id",E="session_last_active",ke=1800*1e3,R=class{constructor(e){this.storage=e;this._endUserId=null;this._anonymousId=this.loadOrCreateAnonymousId(),this._sessionId=this.loadOrCreateSession(),this._endUserId=this.storage.get(q);}get anonymousId(){return this._anonymousId}get sessionId(){return this._sessionId}get endUserId(){return this._endUserId}get effectiveUserId(){return this._endUserId??this._anonymousId}setEndUserId(e){this._endUserId=e,this.storage.set(q,e);}touch(){let e=this.storage.get(E),t=Date.now();e&&t-Number.parseInt(e,10)>ke&&(this._sessionId=g(),this.storage.set(x,this._sessionId)),this.storage.set(E,String(t));}reset(){this._endUserId=null,this.storage.remove(q),this._sessionId=g(),this.storage.set(x,this._sessionId),this.storage.set(E,String(Date.now()));}loadOrCreateAnonymousId(){let e=this.storage.get(Ce);return e||(e=g(),this.storage.set(Ce,e)),e}loadOrCreateSession(){let e=this.storage.get(x),t=this.storage.get(E);if(e&&t&&Date.now()-Number.parseInt(t,10)<ke)return e;let n=g();return this.storage.set(x,n),this.storage.set(E,String(Date.now())),n}};var m="veo:",ct=365*24*60*60*1e3,M=class{get(e){return localStorage.getItem(m+e)}set(e,t){try{localStorage.setItem(m+e,t);}catch{}}remove(e){localStorage.removeItem(m+e);}clear(){let e=[];for(let t=0;t<localStorage.length;t++){let n=localStorage.key(t);n?.startsWith(m)&&e.push(n);}for(let t of e)localStorage.removeItem(t);}};function Pe(){let r=document.cookie;return r===""?[]:r.split("; ")}var U=class{get(e){let t=`${m}${e}=`;for(let n of Pe())if(n.startsWith(t))return decodeURIComponent(n.slice(t.length));return null}set(e,t,n){let o=Math.floor((n?.ttlMs??ct)/1e3),i=typeof location<"u"&&location.protocol==="https:"?"; Secure":"";document.cookie=`${m}${e}=${encodeURIComponent(t)}; Path=/; Max-Age=${o}; SameSite=Lax${i}`;}remove(e){document.cookie=`${m}${e}=; Path=/; Max-Age=0; SameSite=Lax`;}clear(){for(let e of Pe()){let t=e.indexOf("="),n=t===-1?e:e.slice(0,t);n.startsWith(m)&&this.remove(n.slice(m.length));}}},L=class{constructor(){this.store=new Map;}get(e){return this.store.get(e)??null}set(e,t){this.store.set(e,t);}remove(e){this.store.delete(e);}clear(){this.store.clear();}};function xe(r="localStorage"){return r==="localStorage"&&D()?new M:r==="cookie"&&d()?new U:r==="memory"?new L:D()?new M:d()?new U:new L}var z=class extends Error{constructor(t,n){super(t);this.statusCode=n;this.name="TransportError";}},O=class{constructor(e){this.config=e;}async send(e,t){let n=`${this.config.apiUrl}${e}`,o=new AbortController,i=this.config.timeoutMs??1e4,s=setTimeout(()=>o.abort(new DOMException(`Veo request timeout (${i}ms)`,"TimeoutError")),i);try{let a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Api-Key":this.config.apiKey,"X-Sdk-Version":this.config.sdkVersion},body:JSON.stringify(t),signal:o.signal});if(!a.ok)throw new z(`HTTP ${a.status}`,a.status);return await a.json()}finally{clearTimeout(s);}}sendBeacon(e,t){if(!Z())return false;let n=new URL(`${this.config.apiUrl}${e}`);n.searchParams.set("key",this.config.apiKey),n.searchParams.set("v",this.config.sdkVersion);let o=new Blob([JSON.stringify(t)],{type:"application/json"});return navigator.sendBeacon(n.toString(),o)}};var W="organization_id",Re="end_user_id",j="identify_signature";function F(r){return r===null||typeof r!="object"?JSON.stringify(r)??"null":Array.isArray(r)?`[${r.map(F).join(",")}]`:`{${Object.keys(r).sort().map(t=>`${JSON.stringify(t)}:${F(r[t])}`).join(",")}}`}var b=class{constructor(e){this.config=e;this.version=S;this.plugins=[];this.currentOrganizationId=null;this.listeners={pageview:new Set,identify:new Set};if(!e.apiKey)throw new Error("apiKey is required");this.storage=xe(e.storage??"localStorage"),this.session=new R(this.storage),this.transport=new O({apiKey:e.apiKey,apiUrl:f(e).replace(/\/$/,""),sdkVersion:S}),this.queue=new P({transport:this.transport,flushIntervalMs:e.flushInterval??5e3,batchSize:e.flushBatchSize??20,onError:o=>{e.debug&&console.error("[veo] flush error:",o);}});let t=this.storage.get(Re);t&&this.session.setEndUserId(t);let n=this.storage.get(W);n&&(this.currentOrganizationId=n),this.setupUnloadHandlers(),e.debug&&console.log("[veo] initialized",{anonymousId:this.session.anonymousId,sessionId:this.session.sessionId,endUserId:this.session.endUserId});}identify(e){let{visitor:t,organization:n}=e,o=F({id:t.id,traits:t.traits??{},org:n?{id:n.id,attributes:n.attributes??{}}:null});if(this.session.endUserId===t.id&&this.storage.get(j)===o){this.config.debug&&console.debug("[veo] identify: sin cambios, omitido");return}let i=this.session.endUserId===null?this.session.anonymousId:void 0;this.session.setEndUserId(t.id),n&&(this.currentOrganizationId=n.id,this.storage.set(W,n.id));let a={endUser:{id:t.id,traits:t.traits??{},...i!==void 0?{anonymousId:i}:{}},...n?{organization:{id:n.id,attributes:n.attributes??{}}}:{}};this.transport.send("/v1/identify",a).catch(l=>{this.config.debug&&console.error("[veo] identify failed:",l);}),this.enqueue({actionType:"identify",actionProperties:{traits:t.traits,organizationAttributes:n?.attributes}}),this.storage.set(j,o),this.emit("identify",{endUserId:t.id,sessionId:this.session.sessionId});}track(e,t){if(!e||typeof e!="string"){this.config.debug&&console.error("[veo] track: name is required");return}this.enqueue({actionType:"track",actionName:e,...t!==void 0?{actionProperties:t}:{}});}pageview(e){if(!d())return;let t=window.location.href,n=e??window.location.pathname;this.enqueue({actionType:"pageview",pageUrl:t,pagePath:n,pageTitle:document.title,pageReferrer:document.referrer}),this.emit("pageview",{url:t,path:n,sessionId:this.session.sessionId,endUserId:this.session.endUserId});}reset(){this.session.reset(),this.currentOrganizationId=null,this.storage.remove(W),this.storage.remove(Re),this.storage.remove(j);}flush(){return this.queue.flush()}use(e){return this.plugins.push(e),e.install(this),this}getEndUserId(){return this.session.endUserId}getAnonymousId(){return this.session.anonymousId}getSessionId(){return this.session.sessionId}on(e,t){return this.listeners[e].add(t),()=>{this.listeners[e].delete(t);}}emit(e,t){for(let n of this.listeners[e])try{n(t);}catch(o){this.config.debug&&console.error(`[veo] listener for '${e}' failed:`,o);}}enqueue(e){this.session.touch();let t=this.currentOrganizationId??void 0,n=e.pageUrl??(c()?window.location.href:void 0),o=e.pagePath??(c()?window.location.pathname:void 0),i=e.pageTitle??(d()?document.title:void 0),s=e.pageReferrer??(d()?document.referrer:void 0),a={actionId:g(),endUserId:this.session.effectiveUserId,sessionId:this.session.sessionId,actionType:e.actionType,occurredAt:new Date().toISOString(),...t!==void 0?{organizationId:t}:{},...e.actionName!==void 0?{actionName:e.actionName}:{},...n!==void 0?{pageUrl:n}:{},...o!==void 0?{pagePath:o}:{},...i!==void 0?{pageTitle:i}:{},...s!==void 0?{pageReferrer:s}:{},...e.actionProperties!==void 0?{actionProperties:e.actionProperties}:{}};this.queue.add(a);}setupUnloadHandlers(){c()&&(window.addEventListener("pagehide",()=>this.queue.flushBeacon()),window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&this.queue.flushBeacon();}));}};function Me(r,e,t,n){let o=new b(r);if(o.use(G()),r.autocapture!==false){let i=typeof r.autocapture=="object"?r.autocapture:{};o.use(H(i));}if(r.detectTheme!==false&&n&&!y()&&o.use(Ie({apiUrl:f(r),apiKey:r.apiKey,loadDetector:n,...r.debug!==void 0?{debug:r.debug}:{}})),e(o),typeof window<"u"){let s=window.veo?._q??[];window.veo=o;for(let a of s){let[l,u]=a;if(l==="init")continue;let p=o[l];if(typeof p=="function")try{p.apply(o,Array.from(u));}catch(h){r.debug&&console.error("[veo] drain error:",h);}}ce({...r.builderUrl!==void 0?{builderUrl:r.builderUrl}:{},...r.debug!==void 0?{debug:r.debug}:{},...r.apiKey!==void 0?{apiKey:r.apiKey}:{},apiUrl:f(r),...{}});}return o}function Ue(r){if(!c()||!d())return Promise.resolve(null);let e=window;if(e.veoTheme)return Promise.resolve(e.veoTheme);let t=r.themeUrl??ht();return t?new Promise(n=>{let o=document.createElement("script");o.src=t,o.async=true,o.addEventListener("load",()=>n(e.veoTheme??null)),o.addEventListener("error",()=>{r.debug&&console.error("[veo] no pude cargar",t),n(null);}),document.head.appendChild(o);}):(r.debug&&console.warn("[veo] no pude resolver la URL de veo-theme.js"),Promise.resolve(null))}function ht(){let r=document.querySelectorAll("script[src]");for(let e of Array.from(r))if(/\bveo(\.min)?\.js(\?.*)?$/.test(e.src))return e.src.replace(/\bveo(\.min)?\.js/,"veo-theme$1.js");return null}function Vr(r){let e=f(r);return Me(r,t=>{let n=()=>pe({...r.guidesUrl!==void 0?{guidesUrl:r.guidesUrl}:{},...r.debug!==void 0?{debug:r.debug}:{}}),o=V();r.guides===true&&!y()&&o===null&&n().then(i=>{i&&t.use(i.guidesPlugin({apiUrl:e,apiKey:r.apiKey,...r.debug!==void 0?{debug:r.debug}:{}}));}),o!==null&&n().then(i=>i?.runPreviewMode({apiKey:r.apiKey,apiUrl:e,token:o,...r.debug!==void 0?{debug:r.debug}:{}})),t.preview=i=>{let s=null,a=n().then(l=>l?(s=l.previewGuide(i),s.ready):{rendered:false});return {close:()=>s?.close(),ready:a,host:()=>s?.host()??null}},t.closePreview=()=>{n().then(i=>i?.closeGuidePreview());};},void 0,()=>Ue({...r.themeUrl!==void 0?{themeUrl:r.themeUrl}:{},...r.debug!==void 0?{debug:r.debug}:{}}))}
|
|
2
|
+
exports.Client=b;exports.SDK_VERSION=S;exports.autocapturePlugin=H;exports.definePlugin=ze;exports.init=Vr;exports.spaRouterPlugin=G;return exports;})({});//# sourceMappingURL=veo.js.map
|
|
3
3
|
//# sourceMappingURL=veo.js.map
|