@lucida-analytics/browser 0.1.6 → 0.1.8
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/CHANGELOG.md +55 -0
- package/README.md +39 -6
- package/dist/autocapture.d.ts +1 -1
- package/dist/{banner-7LEREYUH.js → banner-TXLAMTQM.js} +1 -1
- package/dist/{static/v0.1.6/chunk-FUE3SDQU.js → chunk-B722OERZ.js} +1 -1
- package/dist/chunk-IXDYCBAD.js +1 -0
- package/dist/{client-pxkkaWtR.d.ts → client-BBmHQqm1.d.ts} +2 -2
- package/dist/consent.d.ts +15 -8
- package/dist/consent.js +1 -1
- package/dist/core.d.ts +3 -3
- package/dist/core.js +3 -3
- package/dist/correlate.d.ts +2 -2
- package/dist/correlate.js +1 -1
- package/dist/early-access.d.ts +1 -1
- package/dist/experiments.d.ts +1 -1
- package/dist/flags.d.ts +1 -1
- package/dist/forms.d.ts +1 -1
- package/dist/guides.d.ts +1 -1
- package/dist/guides.js +1 -1
- package/dist/heatmaps.d.ts +1 -1
- package/dist/host-headers.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/inspector.d.ts +1 -1
- package/dist/lucida.js +2 -2
- package/dist/{persistent-SLVINN5A.js → persistent-G2OR2L2N.js} +1 -1
- package/dist/recommendations.d.ts +1 -1
- package/dist/{recorder-4WIMQCLR.js → recorder-7BHG7KAJ.js} +4 -4
- package/dist/replay.d.ts +2 -2
- package/dist/replay.js +1 -1
- package/dist/static/v0/{banner-7LEREYUH.js → banner-TXLAMTQM.js} +1 -1
- package/dist/static/v0/{chunk-FUE3SDQU.js → chunk-B722OERZ.js} +1 -1
- package/dist/static/v0/chunk-IXDYCBAD.js +1 -0
- package/dist/static/v0/consent.js +1 -1
- package/dist/static/v0/core.js +3 -3
- package/dist/static/v0/correlate.js +1 -1
- package/dist/static/v0/guides.js +1 -1
- package/dist/static/v0/index.js +3 -3
- package/dist/static/v0/lucida.js +2 -2
- package/dist/static/v0/manifest.json +13 -13
- package/dist/static/v0/{persistent-SLVINN5A.js → persistent-G2OR2L2N.js} +1 -1
- package/dist/static/{v0.1.6/recorder-4WIMQCLR.js → v0/recorder-7BHG7KAJ.js} +4 -4
- package/dist/static/v0/replay.js +1 -1
- package/dist/static/v0/toolbar.js +4 -4
- package/dist/static/v0/{validation-HGJXZ553.js → validation-S6TYVWAI.js} +1 -1
- package/dist/static/{v0.1.6/banner-7LEREYUH.js → v0.1.8/banner-TXLAMTQM.js} +1 -1
- package/dist/{chunk-FUE3SDQU.js → static/v0.1.8/chunk-B722OERZ.js} +1 -1
- package/dist/static/v0.1.8/chunk-IXDYCBAD.js +1 -0
- package/dist/static/v0.1.8/consent.js +1 -0
- package/dist/static/v0.1.8/core.js +3 -0
- package/dist/static/v0.1.8/correlate.js +1 -0
- package/dist/static/{v0.1.6 → v0.1.8}/guides.js +1 -1
- package/dist/static/v0.1.8/index.js +3 -0
- package/dist/static/v0.1.8/lucida.js +3 -0
- package/dist/static/v0.1.8/manifest.json +28 -0
- package/dist/static/{v0.1.6/persistent-SLVINN5A.js → v0.1.8/persistent-G2OR2L2N.js} +1 -1
- package/dist/static/{v0/recorder-4WIMQCLR.js → v0.1.8/recorder-7BHG7KAJ.js} +4 -4
- package/dist/static/{v0.1.6 → v0.1.8}/replay.js +1 -1
- package/dist/static/{v0.1.6 → v0.1.8}/toolbar.js +4 -4
- package/dist/static/{v0.1.6/validation-HGJXZ553.js → v0.1.8/validation-S6TYVWAI.js} +1 -1
- package/dist/toolbar.d.ts +1 -1
- package/dist/toolbar.js +4 -4
- package/dist/{types-QPJGHOv0.d.ts → types-Tl9ypGho.d.ts} +8 -4
- package/dist/{validation-HGJXZ553.js → validation-S6TYVWAI.js} +1 -1
- package/dist/webmcp.d.ts +1 -1
- package/package.json +3 -2
- package/storage.json +4 -2
- package/dist/chunk-536QABLP.js +0 -1
- package/dist/static/v0/chunk-536QABLP.js +0 -1
- package/dist/static/v0.1.6/chunk-536QABLP.js +0 -1
- package/dist/static/v0.1.6/consent.js +0 -1
- package/dist/static/v0.1.6/core.js +0 -3
- package/dist/static/v0.1.6/correlate.js +0 -1
- package/dist/static/v0.1.6/index.js +0 -3
- package/dist/static/v0.1.6/lucida.js +0 -3
- package/dist/static/v0.1.6/manifest.json +0 -28
- /package/dist/static/{v0.1.6 → v0.1.8}/autocapture.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/chunk-AWIQCFGN.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/chunk-EFNCQJI3.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/chunk-UPPUYIIH.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/early-access.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/experiments.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/flags.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/forms.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/heatmaps.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/host-headers.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/inspector.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/modules-FANMZRDJ.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/recommendations.js +0 -0
- /package/dist/static/{v0.1.6 → v0.1.8}/webmcp.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as A}from"./chunk-
|
|
1
|
+
import{b as A}from"./chunk-IXDYCBAD.js";import"./chunk-EFNCQJI3.js";var C={title:"Your privacy",body:"We use cookies and similar technologies to measure and improve this site. Choose what you allow.",acceptAll:"Accept all",rejectAll:"Reject all",save:"Save choices",categories:{analytics:"Analytics",replay:"Session replay",marketing:"Marketing"}},j=["analytics","replay","marketing"],O="button, input, [href], [tabindex]:not([tabindex='-1'])",w={bottom:{left:"0",right:"0",bottom:"0"},top:{left:"0",right:"0",top:"0"},center:{top:"50%",left:"50%",transform:"translate(-50%,-50%)","max-width":"28rem"},"bottom-left":{left:"1rem",bottom:"1rem","max-width":"24rem"},"bottom-right":{right:"1rem",bottom:"1rem","max-width":"24rem"}},l=(e,t={},...s)=>{let c=Object.assign(document.createElement(e),t);return c.append(...s),c},h;function P(){h?.close()}function S(e){if(!e)return{};let t=(e.categories??[]).filter(a=>!a.required&&j.includes(a.id)),s=Object.fromEntries(t.map(a=>[a.id,a.label])),c={title:e.title,body:e.body,acceptAll:e.accept_label,rejectAll:e.decline_label,save:e.customize_label,categories:s},d=e.position?.replace("_","-");return{texts:Object.fromEntries(Object.entries(c).filter(([,a])=>a!==void 0)),...t.length?{categories:t.map(a=>a.id)}:{},...d&&d in w?{position:d}:{}}}async function H(e){try{let t=await e.fetch(`${e.config.apiHost}/v1/config?api_key=${encodeURIComponent(e.apiKey)}`,{credentials:"omit"});return t.ok?S((await t.json()).consent_banner):{}}catch{return{}}}async function _(e,t={}){if(!t.remote)return B(e,t);let s=await H(e);return B(e,{...s,...t,texts:{...s.texts,...t.texts,categories:{...s.texts?.categories,...t.texts?.categories}}})}function B(e,t){P();let s={...C,...t.texts,categories:{...C.categories,...t.texts?.categories}},c=t.categories??j,d=e.core.getConsent(),a=t.position??"bottom",m=`lc-consent-${Math.random().toString(36).slice(2,8)}`,L=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,M=document.activeElement,v=c.map(o=>{let i=l("input",{type:"checkbox",id:`${m}-${o}`,checked:d[o]});return{c:o,input:i,row:l("label",{htmlFor:i.id},i,document.createTextNode(` ${s.categories[o]}`))}}),p=(o,i)=>{let u=l("button",{type:"button",textContent:o});return u.style.cssText=`padding:.5rem 1rem;margin:.25rem .5rem .25rem 0;border:1px solid #1f2937;border-radius:.375rem;cursor:pointer;font:inherit;background:${i?"#1f2937":"#fff"};color:${i?"#fff":"#1f2937"}`,u},g=p(s.acceptAll,!0),k=p(s.rejectAll,!0),T=p(s.save,!1),n=l("div",{role:"dialog",id:m},l("h2",{id:`${m}-t`,textContent:s.title}),l("p",{id:`${m}-d`,textContent:s.body}),...c.length>1?v.map(o=>o.row):[],l("div",{},g,k,...c.length>1?[T]:[]));n.setAttribute("aria-modal","true"),n.setAttribute("aria-labelledby",`${m}-t`),n.setAttribute("aria-describedby",`${m}-d`),n.setAttribute("data-lc-ignore",""),n.style.cssText="position:fixed;z-index:2147483000;box-sizing:border-box;padding:1rem 1.25rem;background:#fff;color:#111827;font:14px/1.4 system-ui,sans-serif;box-shadow:0 0 .75rem rgba(0,0,0,.3);display:block";for(let[o,i]of Object.entries(w[a]))n.style.setProperty(o,i);for(let o of n.querySelectorAll("h2"))o.style.cssText="margin:0 0 .5rem;font-size:1.1rem";for(let o of n.querySelectorAll("label"))o.style.cssText="display:block;margin:.25rem 0";return L||(n.style.opacity="0",n.style.transition="opacity .2s",requestAnimationFrame(()=>n.style.opacity="1")),new Promise(o=>{let i=r=>{document.removeEventListener("keydown",E,!0),n.remove(),h=void 0,M?.focus?.(),r&&A(e,r,"banner",t.version?{version:t.version}:{}),o(r?e.core.getConsent():null)},u=r=>Object.fromEntries(c.map(f=>[f,r])),E=r=>{if(r.key==="Escape")return void i(null);if(r.key!=="Tab")return;let f=[...n.querySelectorAll(O)],y=f[0],b=f[f.length-1],x=document.activeElement;if(!n.contains(x))(r.shiftKey?b:y).focus();else if(r.shiftKey&&x===y)b.focus();else if(!r.shiftKey&&x===b)y.focus();else return;r.preventDefault()};g.onclick=()=>i(u(!0)),k.onclick=()=>i(u(!1)),T.onclick=()=>i(Object.fromEntries(v.map(r=>[r.c,r.input.checked]))),document.addEventListener("keydown",E,!0),document.body.append(n),h={root:n,close:()=>i(null)},g.focus()})}export{S as fromRemote,P as hideBanner,_ as showBanner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function oe(e,t){if(!e.url)return!0;if(e.url_match==="exact")return t===e.url;if(e.url_match==="regex")try{return new RegExp(e.url).test(t)}catch{return!1}return t.includes(e.url)}function S(e,t){let n=t?.[e.key];if(e.op==="exists")return n!=null;if(n==null)return e.op==="neq";let[o,s]=[String(n),String(e.value??"")];return e.op==="eq"?o===s:e.op==="neq"?o!==s:o.includes(s)}var ie=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function re(e,t){try{let n=new Intl.DateTimeFormat("en-US",{timeZone:t,weekday:"short",hour:"numeric",hourCycle:"h23"}).formatToParts(e),o=s=>n.find(u=>u.type===s)?.value??"";return{day:ie.indexOf(o("weekday")),h:Number(o("hour"))%24}}catch{return{day:new Date(e).getDay(),h:new Date(e).getHours()}}}function se(e,t){if(e.start&&t<Date.parse(e.start)||e.end&&t>=Date.parse(e.end))return!1;let{day:n,h:o}=e.timezone?re(t,e.timezone):{day:new Date(t).getDay(),h:new Date(t).getHours()};return e.days?.length&&!e.days.includes(n)?!1:!e.hours||o>=(e.hours.from??0)&&o<(e.hours.to??24)}function ae(e,t,n){let o=e.per_days?n-e.per_days*864e5:0;return t.filter(s=>s>=o).length<(e.max_views??1)}function le(e,t){let n=e.split("*").map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp("^"+n+"$").test(t)}function ce(e,t){if(!e||!t?.length)return!1;let n=e;try{n=new URL(e).pathname||e}catch{}return t.some(o=>typeof o=="string"&&o!==""&&le(o,o.startsWith("/")?n:e))}function Se(e,t){let n=e.conditions;return!(ce(t.url,n.exclude_url_patterns)||!oe(n,t.url)||n.flag_key&&!t.flags(n.flag_key)||n.flag_key&&n.flag_variant&&String(t.flagValue?.(n.flag_key))!==n.flag_variant||n.wait_days&&t.lastShownMs!==void 0&&t.nowMs-t.lastShownMs<n.wait_days*864e5||n.devices?.length&&t.device&&!n.devices.includes(t.device)||n.person_filters?.some(o=>!S(o,t.person))||n.group_filters?.some(o=>!S(o,t.groups?.[o.group_type??""]))||n.seen_guides?.some(o=>!t.seen?.(o))||n.not_seen_guides?.some(o=>t.seen?.(o))||n.schedule&&!se(n.schedule,t.nowMs)||n.frequency&&!ae(n.frequency,t.views??[],t.nowMs)||n.sample_pct!==void 0&&n.sample_pct>0&&n.sample_pct<100&&t.random()*100>=n.sample_pct)}function j(e,t){let n=document.createElement("style");return t&&n.setAttribute("nonce",t),n.textContent=e,n}var ue=e=>{if(typeof e!="string"||!e)return!1;try{return!!document.querySelector(e)}catch{return!1}};function F(e,t){let n=()=>typeof e.value=="string"&&t.present?t.present(e.value):ue(e.value);if(e.op==="element_present")return n();if(e.op==="element_absent")return!n();if(e.op==="flag_on"||e.op==="flag_off"){let o=typeof e.value=="string"&&!!t.flag?.(e.value);return e.op==="flag_on"?o:!o}return S({key:e.key,op:e.op,value:e.value},t.person)}function de(e){return e.matches("input[type=password],[data-lc-mask],.lc-mask,[autocomplete^=cc-]")?!0:!!e.closest("[data-lc-mask],.lc-mask")}var pe="input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),textarea";function U(e,t=document){if(!e.selector||e.selector.length>500)return"invalid";let n;try{n=t.querySelector(e.selector)}catch{return"invalid"}if(!n)return"missing";if(de(n))return"refused";if(e.action==="click")n.click();else if(e.action==="focus")n.focus();else if(e.action==="fill"){if(typeof e.value!="string"||e.value.length>200||!n.matches(pe))return"refused";let o=n instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,s=Object.getOwnPropertyDescriptor(o,"value")?.set;s?s.call(n,e.value):n.value=e.value,n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}))}else return"invalid";return"done"}var fe=()=>{try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}};function K(e=["#e5484d","#30a46c","#0090ff","#f5d90a","#8e4ec6"]){if(typeof document>"u"||fe())return;let t=document.createElement("canvas");t.setAttribute("data-lc-ignore",""),t.setAttribute("aria-hidden","true"),t.width=innerWidth,t.height=innerHeight,t.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:2147483001";let n=t.getContext("2d");if(!n)return;document.body.append(t);let o=Array.from({length:120},(a,r)=>({x:innerWidth/2,y:innerHeight/3,vx:(Math.random()-.5)*12,vy:Math.random()*-10-2,color:e[r%e.length]})),s=Date.now()+1500,u=()=>{n.clearRect(0,0,t.width,t.height);for(let a of o)a.x+=a.vx,a.y+=a.vy,a.vy+=.35,n.fillStyle=a.color,n.fillRect(a.x,a.y,6,4);Date.now()<s?requestAnimationFrame(u):t.remove()};requestAnimationFrame(u)}var me=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,be=/^[\w\s,'"-]{1,100}$/,W={none:"none",sm:"0 1px 4px rgba(0,0,0,.15)",lg:"0 8px 32px rgba(0,0,0,.3)"};function ve(e,t=ye()){if(!e?.dark?.tokens)return!1;let n=e.theme_mode??"auto";return n==="dark"||n==="auto"&&t}function ye(){try{return typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches}catch{return!1}}function V(e,t){let n={...e?.font_family?{font:e.font_family}:{},...e?.tokens};return ve(e,t)?{...n,...e?.dark?.tokens}:n}function X(e,t){let n=o=>typeof o=="string"&&me.test(o);n(t?.background)&&(e.style.background=t.background),n(t?.text)&&(e.style.color=t.text),n(t?.accent)&&(e.style.setProperty("--a",t.accent),e.style.setProperty("--at","#fff")),typeof t?.radius=="number"&&t.radius>=0&&t.radius<=32&&(e.style.borderRadius=`${t.radius}px`),typeof t?.font=="string"&&be.test(t.font)&&(e.style.fontFamily=t.font),t?.shadow&&t.shadow in W&&(e.style.boxShadow=W[t.shadow]),typeof t?.button_radius=="number"&&t.button_radius>=0&&t.button_radius<=32&&e.style.setProperty("--br",`${t.button_radius}px`),n(t?.secondary)&&e.style.setProperty("--s",t.secondary),n(t?.secondary_text)&&e.style.setProperty("--st",t.secondary_text)}var Y=".cd{display:flex;gap:6px;justify-content:center;margin:8px 0}.cd button{width:10px;height:10px;min-width:0;padding:0;margin:0;border-radius:50%;background:#ccc;border:0}.cd button[aria-current=true]{background:var(--a,#111)}.cn{display:flex;justify-content:space-between}",A=(e,t,n)=>{let o=document.createElement("button");return o.type="button",o.textContent=e,n&&o.setAttribute("aria-label",n),o.onclick=t,o};function J(e){let t=document.createElement("div"),n=document.createElement("div");n.className="cd",n.setAttribute("role","tablist");for(let u=0;u<e.count;u++){let a=A("",()=>e.to(u),`Slide ${u+1} of ${e.count}`);a.setAttribute("role","tab"),a.setAttribute("aria-current",String(u===e.index)),n.append(a)}let o=document.createElement("div");o.className="cn";let s=e.index===e.count-1;return o.append(e.index>0?A("Back",()=>e.to(e.index-1)):A("Skip",e.dismiss),A(s?"Done":"Next",()=>s?e.complete():e.to(e.index+1))),t.append(n,o),t}function Q(e,t){let n,o=a=>{n=a.clientX},s=a=>{if(n===void 0)return;let r=a.clientX-n;n=void 0;let y=t();r<-40&&y.index<y.count-1?y.to(y.index+1):r>40&&y.index>0&&y.to(y.index-1)},u=a=>{let r=t();a.key==="ArrowRight"&&r.index<r.count-1?r.to(r.index+1):a.key==="ArrowLeft"&&r.index>0&&r.to(r.index-1)};return e.addEventListener("pointerdown",o),e.addEventListener("pointerup",s),e.addEventListener("keydown",u),()=>{e.removeEventListener("pointerdown",o),e.removeEventListener("pointerup",s),e.removeEventListener("keydown",u)}}function ge(e,t,n=!0,o=!1){if(e==="banner")return[{label:"Dismiss",action:"dismiss"}];let s=n?[]:[{label:"Back",action:"back"}];return o||s.push({label:t?"Done":"Next",action:"next"}),[...s,{label:"Dismiss",action:"dismiss"}]}function he(e){for(let t of[e.selector,...e.fallback_selectors??[]])if(t)try{let n=document.querySelector(t);if(n)return n}catch{}return null}var ke=".g{position:fixed;z-index:2147483000;background:#fff;color:#111;border:1px solid #ccc;border-radius:8px;padding:14px;font:14px system-ui;max-width:320px;box-shadow:0 4px 16px rgba(0,0,0,.2)}.m{top:50%;left:50%;transform:translate(-50%,-50%)}.bn{top:0;left:0;right:0;max-width:none;border-radius:0}.bb{top:auto;bottom:0}.p{right:16px;bottom:16px}.o{position:fixed;inset:0;z-index:2146999999;background:rgba(0,0,0,.4)}button{margin:2px;padding:4px 10px;cursor:pointer;background:var(--a,buttonface);color:var(--at,buttontext);border:1px solid #bbb;border-radius:var(--br,4px)}button+button{background:var(--s,buttonface);color:var(--st,buttontext)}h2{margin:0 0 6px;font-size:16px}p{margin:0 0 8px}li{margin:4px 0}.so{top:0;bottom:0;right:0;max-width:360px;border-radius:0;overflow:auto;animation:s .2s}.so.sl{right:auto;left:0}@keyframes s{from{transform:translateX(30px);opacity:0}}@media (prefers-reduced-motion:reduce){.so{animation:none}}.in{position:static;box-shadow:none;max-width:none;margin:8px 0}img,video,iframe{display:block;width:100%;max-width:100%;border:0;margin:0 0 8px;border-radius:4px}iframe{aspect-ratio:16/9}",xe=ke+Y,we=["www.youtube-nocookie.com","www.youtube.com","player.vimeo.com","www.loom.com","fast.wistia.net"],_e="button,[href],input,textarea,select,[tabindex]:not([tabindex='-1'])";function v(e,t,n){let o=document.createElement(e);return t!==void 0&&(o.textContent=t),n&&(o.className=n),o}function Ee(e){let t;try{t=new URL(e.url)}catch{return null}if(t.protocol!=="https:")return null;if(e.type==="image")return Object.assign(v("img"),{src:t.href,alt:e.alt??"",loading:"lazy"});if(e.type==="video")return Object.assign(v("video"),{src:t.href,controls:!0,preload:"metadata"});if(e.type!=="embed"||!we.includes(t.host))return null;let n=Object.assign(v("iframe"),{src:t.href,title:e.alt??"Video",allowFullscreen:!0,referrerPolicy:"no-referrer"});return n.setAttribute("sandbox","allow-scripts allow-same-origin allow-presentation"),n}function Me(e,t,n){e.addEventListener("keydown",o=>{if(o.key==="Escape")return n();if(o.key!=="Tab")return;let s=[...e.querySelectorAll(_e)];if(!s.length)return;let u=s[0],a=s[s.length-1],r=t.activeElement;o.shiftKey&&r===u?(o.preventDefault(),a.focus()):!o.shiftKey&&r===a&&(o.preventDefault(),u.focus())})}function Te(e,t,n="bottom"){let o=t.getBoundingClientRect(),s=e.offsetWidth||280,u=e.offsetHeight||120,a=o.left,r=o.bottom+8;n==="top"?r=o.top-u-8:n==="left"?(a=o.left-s-8,r=o.top):n==="right"&&(a=o.right+8,r=o.top);let y=(x,w)=>Math.max(8,Math.min(x,w-8));e.style.left=`${y(a,window.innerWidth-s)}px`,e.style.top=`${y(r,window.innerHeight-u)}px`}function Ne(e,t,n,o={}){let s=document.createElement("div");s.setAttribute("data-lc-ignore","");let u=s.attachShadow({mode:"open"});u.append(j(xe,o.nonce));let a=document.activeElement,r=Math.min(Math.max(o.start??0,0),e.steps.length-1),y=!1,x,w=[],h=[],H=()=>{for(let i of h)i();h=[]},D=()=>{},d=v("div",void 0,"g"),_=()=>{y||(y=!0,H(),D(),s.remove(),a?.focus?.(),n())},L=i=>{t.dismissed(r,e.steps[r]?.id??"",i),_()},k=()=>L(),M=()=>{t.completed(),_(),e.steps.at(-1)?.confetti&&K()},R=i=>(o.resolveTarget??he)(i),$=i=>{let l=i?.goto?void 0:e.steps[r]?.branch?.find(m=>F(m,{...o.person?{person:o.person}:{},...o.flag?{flag:o.flag}:{},...o.present?{present:o.present}:{}})),p=i?.goto??l?.goto,c=p==="end"?e.steps.length:p?e.steps.findIndex(m=>m.id===p):-1;w.push(r),r=c>r?c:r+1,C()},C=()=>{let i=e.steps[r];if(!i)return M();if(t.progress?.(i.id),i.url&&!location.href.includes(i.url))return _();I()},O=i=>{i<0||i>=e.steps.length||i===r||(r=i,C())},Z=()=>{let i=w.pop();i!==void 0&&(r=i,C())},P=i=>{if(i.action==="next"||i.action==="start_tour")$(i);else if(i.action==="back")Z();else if(i.action==="dismiss")k();else if(i.action==="snooze"){let l=Math.min(Math.max(Math.round(i.snooze_hours??24),1),720);t.snoozed?.(e.steps[r]?.id??"",l),L("snooze")}else i.action==="link"&&i.url&&/^https?:\/\//i.test(i.url)?window.open(i.url,"_blank","noopener,noreferrer"):i.action==="event"&&i.event&&t.event(i.event)},ee=(i,l)=>{let p=v("div"),c=i.buttons?.length?i.buttons:ge(e.kind,l,w.length===0,i.advance==="click"||i.advance==="input");for(let m of c){let g=v("button",m.label);g.type="button",g.onclick=()=>P(m),p.append(g)}return p},te=i=>[...i.title?[v("h2",i.title)]:[],...i.body?[v("p",i.body)]:[],...(i.media??[]).flatMap(l=>Ee(l)??[])],T=new Set(o.checked),N=new Map;function G(i,l,p){let c=N.get(l.id);c&&!c.hasAttribute("data-done")&&(c.setAttribute("data-done",""),c.setAttribute("aria-pressed","true"),c.textContent=`\u2713 ${l.title??l.id}`),!(!p||T.has(l.id)&&c?.hasAttribute("data-reported"))&&(c?.setAttribute("data-reported",""),T.add(l.id),t.step(i,l.id),T.size>=e.steps.length&&M())}let ne=()=>{let i=v("ul");for(let[p,c]of e.steps.entries()){let m=v("li"),g=v("button",`${c.title??c.id}`);if(g.type="button",g.setAttribute("aria-pressed","false"),N.set(c.id,g),T.has(c.id)&&(G(p,c,!1),g.setAttribute("data-reported","")),g.onclick=()=>{if(e.kind==="checklist")G(p,c,!0);else if(e.kind==="resource_center"){t.step(p,c.id);let f=c.buttons?.find(b=>b.action==="link");f&&P(f)}},c.module){let f={library:o.library??[],launch:b=>(_(),o.launch?.(b)),opened:()=>t.step(p,c.id),...o.assist?{assist:o.assist}:{}};import("./modules-FANMZRDJ.js").then(b=>m.append(b.renderModule(c,f))),i.append(m);continue}m.append(g),c.body&&m.append(v("p",c.body)),i.append(m)}d.append(v("h2",e.name),i);let l=v("button",e.kind==="resource_center"?"Close":"Dismiss");l.type="button",l.onclick=k,d.append(l)};function I(){H(),d.replaceChildren(),d.style.visibility="";let i=e.steps[r];if(!i)return;let l=e.kind==="carousel";if(e.kind==="checklist"||e.kind==="resource_center")ne();else{let f={index:r,count:e.steps.length,to:O,complete:M,dismiss:k};d.append(...te(i),l?J(f):ee(i,r===e.steps.length-1)),t.step(r,i.id)}d.setAttribute("role",e.kind==="banner"||e.kind==="inline"?"region":"dialog"),d.setAttribute("aria-label",i?.title??e.name),l&&d.setAttribute("aria-roledescription","carousel");let p={modal:"m",carousel:"m",banner:`bn${i.placement==="bottom"?" bb":""}`,slideout:`so${e.appearance?.side==="left"?" sl":""}`,inline:"in"};if(d.className=`g ${p[e.kind]??"p"}`,X(d,V(e.appearance)),(e.kind==="modal"||l)&&d.setAttribute("aria-modal","true"),l&&h.push(Q(d,()=>({index:r,count:e.steps.length,to:O,complete:M,dismiss:k}))),i.auto_close_s&&i.auto_close_s>0){let f=setTimeout(()=>L("auto_close"),Math.min(i.auto_close_s,600)*1e3);h.push(()=>clearTimeout(f))}if(i.automation&&o.automate!==!1){let f=i.automation,b=setTimeout(()=>t.automated?.(i.id,U(f)));h.push(()=>clearTimeout(b))}let c=(e.kind==="tooltip"||e.kind==="tour")&&!!(i.selector||i.fallback_selectors?.length),m=f=>{d.style.visibility="",d.classList.remove("p"),Te(d,f,i.placement);let b=i.advance==="click"?"click":i.advance==="input"?"change":null;if(!b)return;let E=()=>$();f.addEventListener(b,E,{once:!0}),h.push(()=>f.removeEventListener(b,E))},g=c?R(i):null;if(g)m(g);else if(c){d.style.visibility="hidden";let f=Date.now()+Math.min(Math.max(i.wait_ms??3e3,0),15e3),b=setInterval(()=>{let E=R(i);E?(clearInterval(b),m(E)):Date.now()>=f&&(clearInterval(b),d.style.visibility="",t.targetMissing?.(i.id,i.selector??i.fallback_selectors?.[0]??""))},150);h.push(()=>clearInterval(b))}e.kind!=="inline"&&d.querySelector("button")?.focus()}Me(d,u,k);let B=e.kind==="modal"||e.kind==="carousel",q=e.appearance?.dismiss_on_outside_click??B;if(e.appearance?.overlay??B)x=v("div",void 0,"o"),q&&(x.onclick=k),u.append(x);else if(q&&e.kind!=="inline"){let i=p=>{p.composedPath().includes(s)||k()},l=setTimeout(()=>document.addEventListener("click",i,!0));D=()=>(clearTimeout(l),document.removeEventListener("click",i,!0))}u.append(d);let z=e.kind==="inline"&&e.steps[0]?.selector?document.querySelector(e.steps[0].selector):null;return z?z.after(s):document.body.append(s),t.shown(),I(),Object.assign(_,{markDone(i){let l=e.steps.findIndex(p=>p.id===i);e.kind==="checklist"&&l>=0&&!y&&G(l,e.steps[l],!0)}})}export{Se as a,j as b,F as c,de as d,U as e,V as f,X as g,ge as h,he as i,Te as j,Ne as k};
|
|
1
|
+
function oe(e,t){if(!e.url)return!0;if(e.url_match==="exact")return t===e.url;if(e.url_match==="regex")try{return new RegExp(e.url).test(t)}catch{return!1}return t.includes(e.url)}function S(e,t){let n=t?.[e.key];if(e.op==="exists")return n!=null;if(n==null)return e.op==="neq";let[o,s]=[String(n),String(e.value??"")];return e.op==="eq"?o===s:e.op==="neq"?o!==s:o.includes(s)}var ie=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function re(e,t){try{let n=new Intl.DateTimeFormat("en-US",{timeZone:t,weekday:"short",hour:"numeric",hourCycle:"h23"}).formatToParts(e),o=s=>n.find(u=>u.type===s)?.value??"";return{day:ie.indexOf(o("weekday")),h:Number(o("hour"))%24}}catch{return{day:new Date(e).getDay(),h:new Date(e).getHours()}}}function se(e,t){if(e.start&&t<Date.parse(e.start)||e.end&&t>=Date.parse(e.end))return!1;let{day:n,h:o}=e.timezone?re(t,e.timezone):{day:new Date(t).getDay(),h:new Date(t).getHours()};return e.days?.length&&!e.days.includes(n)?!1:!e.hours||o>=(e.hours.from??0)&&o<(e.hours.to??24)}function ae(e,t,n){let o=e.per_days?n-e.per_days*864e5:0;return t.filter(s=>s>=o).length<(e.max_views??1)}function le(e,t){let n=e.split("*").map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp("^"+n+"$").test(t)}function ce(e,t){if(!e||!t?.length)return!1;let n=e;try{n=new URL(e).pathname||e}catch{}return t.some(o=>typeof o=="string"&&o!==""&&le(o,o.startsWith("/")?n:e))}function Se(e,t){let n=e.conditions;return!(ce(t.url,n.exclude_url_patterns)||!oe(n,t.url)||n.flag_key&&!t.flags(n.flag_key)||n.flag_key&&n.flag_variant&&String(t.flagValue?.(n.flag_key))!==n.flag_variant||n.wait_days&&t.lastShownMs!==void 0&&t.nowMs-t.lastShownMs<n.wait_days*864e5||n.devices?.length&&t.device&&!n.devices.includes(t.device)||n.person_filters?.some(o=>!S(o,t.person))||n.group_filters?.some(o=>!S(o,t.groups?.[o.group_type??""]))||n.seen_guides?.some(o=>!t.seen?.(o))||n.not_seen_guides?.some(o=>t.seen?.(o))||n.schedule&&!se(n.schedule,t.nowMs)||n.frequency&&!ae(n.frequency,t.views??[],t.nowMs)||n.sample_pct!==void 0&&n.sample_pct>0&&n.sample_pct<100&&t.random()*100>=n.sample_pct)}function j(e,t){let n=document.createElement("style");return t&&n.setAttribute("nonce",t),n.textContent=e,n}var ue=e=>{if(typeof e!="string"||!e)return!1;try{return!!document.querySelector(e)}catch{return!1}};function F(e,t){let n=()=>typeof e.value=="string"&&t.present?t.present(e.value):ue(e.value);if(e.op==="element_present")return n();if(e.op==="element_absent")return!n();if(e.op==="flag_on"||e.op==="flag_off"){let o=typeof e.value=="string"&&!!t.flag?.(e.value);return e.op==="flag_on"?o:!o}return S({key:e.key,op:e.op,value:e.value},t.person)}function de(e){return e.matches("input[type=password],[data-lc-mask],.lc-mask,[autocomplete^=cc-]")?!0:!!e.closest("[data-lc-mask],.lc-mask")}var pe="input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),textarea";function U(e,t=document){if(!e.selector||e.selector.length>500)return"invalid";let n;try{n=t.querySelector(e.selector)}catch{return"invalid"}if(!n)return"missing";if(de(n))return"refused";if(e.action==="click")n.click();else if(e.action==="focus")n.focus();else if(e.action==="fill"){if(typeof e.value!="string"||e.value.length>200||!n.matches(pe))return"refused";let o=n instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,s=Object.getOwnPropertyDescriptor(o,"value")?.set;s?s.call(n,e.value):n.value=e.value,n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}))}else return"invalid";return"done"}var fe=()=>{try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}};function K(e=["#e5484d","#30a46c","#0090ff","#f5d90a","#8e4ec6"]){if(typeof document>"u"||fe())return;let t=document.createElement("canvas");t.setAttribute("data-lc-ignore",""),t.setAttribute("aria-hidden","true"),t.width=innerWidth,t.height=innerHeight,t.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:2147483001";let n=t.getContext("2d");if(!n)return;document.body.append(t);let o=Array.from({length:120},(a,r)=>({x:innerWidth/2,y:innerHeight/3,vx:(Math.random()-.5)*12,vy:Math.random()*-10-2,color:e[r%e.length]})),s=Date.now()+1500,u=()=>{n.clearRect(0,0,t.width,t.height);for(let a of o)a.x+=a.vx,a.y+=a.vy,a.vy+=.35,n.fillStyle=a.color,n.fillRect(a.x,a.y,6,4);Date.now()<s?requestAnimationFrame(u):t.remove()};requestAnimationFrame(u)}var me=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,be=/^[\w\s,'"-]{1,100}$/,W={none:"none",sm:"0 1px 4px rgba(0,0,0,.15)",lg:"0 8px 32px rgba(0,0,0,.3)"};function ye(e,t=ve()){if(!e?.dark?.tokens)return!1;let n=e.theme_mode??"auto";return n==="dark"||n==="auto"&&t}function ve(){try{return typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches}catch{return!1}}function V(e,t){let n={...e?.font_family?{font:e.font_family}:{},...e?.tokens};return ye(e,t)?{...n,...e?.dark?.tokens}:n}function X(e,t){let n=o=>typeof o=="string"&&me.test(o);n(t?.background)&&(e.style.background=t.background),n(t?.text)&&(e.style.color=t.text),n(t?.accent)&&(e.style.setProperty("--a",t.accent),e.style.setProperty("--at","#fff")),typeof t?.radius=="number"&&t.radius>=0&&t.radius<=32&&(e.style.borderRadius=`${t.radius}px`),typeof t?.font=="string"&&be.test(t.font)&&(e.style.fontFamily=t.font),t?.shadow&&t.shadow in W&&(e.style.boxShadow=W[t.shadow]),typeof t?.button_radius=="number"&&t.button_radius>=0&&t.button_radius<=32&&e.style.setProperty("--br",`${t.button_radius}px`),n(t?.secondary)&&e.style.setProperty("--s",t.secondary),n(t?.secondary_text)&&e.style.setProperty("--st",t.secondary_text)}var Y=".cd{display:flex;gap:6px;justify-content:center;margin:8px 0}.cd button{width:10px;height:10px;min-width:0;padding:0;margin:0;border-radius:50%;background:#ccc;border:0}.cd button[aria-current=true]{background:var(--a,#111)}.cn{display:flex;justify-content:space-between}",A=(e,t,n)=>{let o=document.createElement("button");return o.type="button",o.textContent=e,n&&o.setAttribute("aria-label",n),o.onclick=t,o};function J(e){let t=document.createElement("div"),n=document.createElement("div");n.className="cd",n.setAttribute("role","tablist");for(let u=0;u<e.count;u++){let a=A("",()=>e.to(u),`Slide ${u+1} of ${e.count}`);a.setAttribute("role","tab"),a.setAttribute("aria-current",String(u===e.index)),n.append(a)}let o=document.createElement("div");o.className="cn";let s=e.index===e.count-1;return o.append(e.index>0?A("Back",()=>e.to(e.index-1)):A("Skip",e.dismiss),A(s?"Done":"Next",()=>s?e.complete():e.to(e.index+1))),t.append(n,o),t}function Q(e,t){let n,o=a=>{n=a.clientX},s=a=>{if(n===void 0)return;let r=a.clientX-n;n=void 0;let v=t();r<-40&&v.index<v.count-1?v.to(v.index+1):r>40&&v.index>0&&v.to(v.index-1)},u=a=>{let r=t();a.key==="ArrowRight"&&r.index<r.count-1?r.to(r.index+1):a.key==="ArrowLeft"&&r.index>0&&r.to(r.index-1)};return e.addEventListener("pointerdown",o),e.addEventListener("pointerup",s),e.addEventListener("keydown",u),()=>{e.removeEventListener("pointerdown",o),e.removeEventListener("pointerup",s),e.removeEventListener("keydown",u)}}function ge(e,t,n=!0,o=!1){if(e==="banner")return[{label:"Dismiss",action:"dismiss"}];let s=n?[]:[{label:"Back",action:"back"}];return o||s.push({label:t?"Done":"Next",action:"next"}),[...s,{label:"Dismiss",action:"dismiss"}]}function he(e){for(let t of[e.selector,...e.fallback_selectors??[]])if(t)try{let n=document.querySelector(t);if(n)return n}catch{}return null}var ke=".g{position:fixed;z-index:2147483000;background:#fff;color:#111;border:1px solid #ccc;border-radius:8px;padding:14px;font:14px system-ui;max-width:320px;box-shadow:0 4px 16px rgba(0,0,0,.2)}.m{top:50%;left:50%;transform:translate(-50%,-50%)}.bn{top:0;left:0;right:0;max-width:none;border-radius:0}.bb{top:auto;bottom:0}.p{right:16px;bottom:16px}.o{position:fixed;inset:0;z-index:2146999999;background:rgba(0,0,0,.4)}button{margin:2px;padding:4px 10px;cursor:pointer;background:var(--a,buttonface);color:var(--at,buttontext);border:1px solid #bbb;border-radius:var(--br,4px)}button+button{background:var(--s,buttonface);color:var(--st,buttontext)}h2{margin:0 0 6px;font-size:16px}p{margin:0 0 8px}li{margin:4px 0}.so{top:0;bottom:0;right:0;max-width:360px;border-radius:0;overflow:auto;animation:s .2s}.so.sl{right:auto;left:0}@keyframes s{from{transform:translateX(30px);opacity:0}}@media (prefers-reduced-motion:reduce){.so{animation:none}}.in{position:static;box-shadow:none;max-width:none;margin:8px 0}img,video,iframe{display:block;width:100%;max-width:100%;border:0;margin:0 0 8px;border-radius:4px}iframe{aspect-ratio:16/9}",xe=ke+Y,we=["www.youtube-nocookie.com","www.youtube.com","player.vimeo.com","www.loom.com","fast.wistia.net"],_e="button,[href],input,textarea,select,[tabindex]:not([tabindex='-1'])";function y(e,t,n){let o=document.createElement(e);return t!==void 0&&(o.textContent=t),n&&(o.className=n),o}function Ee(e){let t;try{t=new URL(e.url)}catch{return null}if(t.protocol!=="https:")return null;if(e.type==="image")return Object.assign(y("img"),{src:t.href,alt:e.alt??"",loading:"lazy"});if(e.type==="video")return Object.assign(y("video"),{src:t.href,controls:!0,preload:"metadata"});if(e.type!=="embed"||!we.includes(t.host))return null;let n=Object.assign(y("iframe"),{src:t.href,title:e.alt??"Video",allowFullscreen:!0,referrerPolicy:"no-referrer"});return n.setAttribute("sandbox","allow-scripts allow-same-origin allow-presentation"),n}function Me(e,t,n){e.addEventListener("keydown",o=>{if(o.key==="Escape")return n();if(o.key!=="Tab")return;let s=[...e.querySelectorAll(_e)];if(!s.length)return;let u=s[0],a=s[s.length-1],r=t.activeElement;o.shiftKey&&r===u?(o.preventDefault(),a.focus()):!o.shiftKey&&r===a&&(o.preventDefault(),u.focus())})}function Te(e,t,n="bottom"){let o=t.getBoundingClientRect(),s=e.offsetWidth||280,u=e.offsetHeight||120,a=o.left,r=o.bottom+8;n==="top"?r=o.top-u-8:n==="left"?(a=o.left-s-8,r=o.top):n==="right"&&(a=o.right+8,r=o.top);let v=(x,w)=>Math.max(8,Math.min(x,w-8));e.style.left=`${v(a,window.innerWidth-s)}px`,e.style.top=`${v(r,window.innerHeight-u)}px`}function Ne(e,t,n,o={}){let s=document.createElement("div");s.setAttribute("data-lc-ignore","");let u=s.attachShadow({mode:"open"});u.append(j(xe,o.nonce));let a=document.activeElement,r=Math.min(Math.max(o.start??0,0),e.steps.length-1),v=!1,x,w=[],h=[],H=()=>{for(let i of h)i();h=[]},D=()=>{},d=y("div",void 0,"g"),_=()=>{v||(v=!0,H(),D(),s.remove(),a?.focus?.(),n())},L=i=>{t.dismissed(r,e.steps[r]?.id??"",i),_()},k=()=>L(),M=()=>{t.completed(),_(),e.steps.at(-1)?.confetti&&K()},R=i=>(o.resolveTarget??he)(i),$=i=>{let l=i?.goto?void 0:e.steps[r]?.branch?.find(m=>F(m,{...o.person?{person:o.person}:{},...o.flag?{flag:o.flag}:{},...o.present?{present:o.present}:{}})),p=i?.goto??l?.goto,c=p==="end"?e.steps.length:p?e.steps.findIndex(m=>m.id===p):-1;w.push(r),r=c>r?c:r+1,C()},C=()=>{let i=e.steps[r];if(!i)return M();if(t.progress?.(i.id),i.url&&!location.href.includes(i.url))return _();I()},O=i=>{i<0||i>=e.steps.length||i===r||(r=i,C())},Z=()=>{let i=w.pop();i!==void 0&&(r=i,C())},P=i=>{if(i.action==="next"||i.action==="start_tour")$(i);else if(i.action==="back")Z();else if(i.action==="dismiss")k();else if(i.action==="snooze"){let l=Math.min(Math.max(Math.round(i.snooze_hours??24),1),720);t.snoozed?.(e.steps[r]?.id??"",l),L("snooze")}else i.action==="link"&&i.url&&/^https?:\/\//i.test(i.url)?window.open(i.url,"_blank","noopener,noreferrer"):i.action==="event"&&i.event&&t.event(i.event)},ee=(i,l)=>{let p=y("div"),c=i.buttons?.length?i.buttons:ge(e.kind,l,w.length===0,i.advance==="click"||i.advance==="input");for(let m of c){let g=y("button",m.label);g.type="button",g.onclick=()=>P(m),p.append(g)}return p},te=i=>[...i.title?[y("h2",i.title)]:[],...i.body?[y("p",i.body)]:[],...(i.media??[]).flatMap(l=>Ee(l)??[])],T=new Set(o.checked),N=new Map;function G(i,l,p){let c=N.get(l.id);c&&!c.hasAttribute("data-done")&&(c.setAttribute("data-done",""),c.setAttribute("aria-pressed","true"),c.textContent=`\u2713 ${l.title??l.id}`),!(!p||T.has(l.id)&&c?.hasAttribute("data-reported"))&&(c?.setAttribute("data-reported",""),T.add(l.id),t.step(i,l.id),T.size>=e.steps.length&&M())}let ne=()=>{let i=y("ul");for(let[p,c]of e.steps.entries()){let m=y("li"),g=y("button",`${c.title??c.id}`);if(g.type="button",g.setAttribute("aria-pressed","false"),N.set(c.id,g),T.has(c.id)&&(G(p,c,!1),g.setAttribute("data-reported","")),g.onclick=()=>{if(e.kind==="checklist")G(p,c,!0);else if(e.kind==="resource_center"){t.step(p,c.id);let f=c.buttons?.find(b=>b.action==="link");f&&P(f)}},c.module){let f={library:o.library??[],launch:b=>(_(),o.launch?.(b)),opened:()=>t.step(p,c.id),...o.assist?{assist:o.assist}:{}};import("./modules-FANMZRDJ.js").then(b=>m.append(b.renderModule(c,f))),i.append(m);continue}m.append(g),c.body&&m.append(y("p",c.body)),i.append(m)}d.append(y("h2",e.name),i);let l=y("button",e.kind==="resource_center"?"Close":"Dismiss");l.type="button",l.onclick=k,d.append(l)};function I(){H(),d.replaceChildren(),d.style.visibility="";let i=e.steps[r];if(!i)return;let l=e.kind==="carousel";if(e.kind==="checklist"||e.kind==="resource_center")ne();else{let f={index:r,count:e.steps.length,to:O,complete:M,dismiss:k};d.append(...te(i),l?J(f):ee(i,r===e.steps.length-1)),t.step(r,i.id)}d.setAttribute("role",e.kind==="banner"||e.kind==="inline"?"region":"dialog"),d.setAttribute("aria-label",i?.title??e.name),l&&d.setAttribute("aria-roledescription","carousel");let p={modal:"m",carousel:"m",banner:`bn${i.placement==="bottom"?" bb":""}`,slideout:`so${e.appearance?.side==="left"?" sl":""}`,inline:"in"};if(d.className=`g ${p[e.kind]??"p"}`,X(d,V(e.appearance)),(e.kind==="modal"||l)&&d.setAttribute("aria-modal","true"),l&&h.push(Q(d,()=>({index:r,count:e.steps.length,to:O,complete:M,dismiss:k}))),i.auto_close_s&&i.auto_close_s>0){let f=setTimeout(()=>L("auto_close"),Math.min(i.auto_close_s,600)*1e3);h.push(()=>clearTimeout(f))}if(i.automation&&o.automate!==!1){let f=i.automation,b=setTimeout(()=>t.automated?.(i.id,U(f)));h.push(()=>clearTimeout(b))}let c=(e.kind==="tooltip"||e.kind==="tour")&&!!(i.selector||i.fallback_selectors?.length),m=f=>{d.style.visibility="",d.classList.remove("p"),Te(d,f,i.placement);let b=i.advance==="click"?"click":i.advance==="input"?"change":null;if(!b)return;let E=()=>$();f.addEventListener(b,E,{once:!0}),h.push(()=>f.removeEventListener(b,E))},g=c?R(i):null;if(g)m(g);else if(c){d.style.visibility="hidden";let f=Date.now()+Math.min(Math.max(i.wait_ms??3e3,0),15e3),b=setInterval(()=>{let E=R(i);E?(clearInterval(b),m(E)):Date.now()>=f&&(clearInterval(b),d.style.visibility="",t.targetMissing?.(i.id,i.selector??i.fallback_selectors?.[0]??""))},150);h.push(()=>clearInterval(b))}e.kind!=="inline"&&d.querySelector("button")?.focus()}Me(d,u,k);let B=e.kind==="modal"||e.kind==="carousel",q=e.appearance?.dismiss_on_outside_click??B;if(e.appearance?.overlay??B)x=y("div",void 0,"o"),q&&(x.onclick=k),u.append(x);else if(q&&e.kind!=="inline"){let i=p=>{p.composedPath().includes(s)||k()},l=setTimeout(()=>document.addEventListener("click",i,!0));D=()=>(clearTimeout(l),document.removeEventListener("click",i,!0))}u.append(d);let z=e.kind==="inline"&&e.steps[0]?.selector?document.querySelector(e.steps[0].selector):null;return z?z.after(s):document.body.append(s),t.shown(),I(),Object.assign(_,{markDone(i){let l=e.steps.findIndex(p=>p.id===i);e.kind==="checklist"&&l>=0&&!v&&G(l,e.steps[l],!0)}})}export{Se as a,j as b,F as c,de as d,U as e,V as f,X as g,ge as h,he as i,Te as j,Ne as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r}from"./chunk-EFNCQJI3.js";var a="$consent_updated",l="lc_consent",s="lc_distinct_id";function f(e,o){try{let t=`; Path=/; SameSite=Lax${location.protocol==="https:"?"; Secure":""}`;document.cookie=`${l}=${e?"granted":"denied"}; Max-Age=31536000${t}`,e&&o?document.cookie=`${s}=${encodeURIComponent(o)}; Max-Age=31536000${t}`:e||(document.cookie=`${s}=; Max-Age=0${t}`)}catch{}}function u(e,o,t,n={}){let d=JSON.stringify(e.core.getConsent());e.client.setConsent(o);let i=e.core.getConsent();if(n.cookie&&f(i.analytics,e.core.identity.isIdentified?void 0:e.core.distinctId),n.onlyIfChanged&&JSON.stringify(i)===d)return;let c={categories:i,source:t,version:n.version??e.config.consent?.policyVersion??"1",...n.receiptId?{consent_receipt_id:n.receiptId}:{}};if(e.core.hasConsent("analytics"))e.client.capture(a,c);else if(e.config.consent?.logBeacon&&!e.config.disabled){let p=JSON.stringify({api_key:e.apiKey,batch:[{uuid:r(Date.now()),event:a,timestamp:new Date().toISOString(),properties:{...c,$lib:"lucida-browser"}}],sent_at:new Date().toISOString()});e.fetch(`${e.config.apiHost}/v1/batch`,{method:"POST",body:p,keepalive:!0,credentials:"omit",headers:{"Content-Type":"text/plain"}}).catch(()=>{})}}export{a,u as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as I,b as c}from"./chunk-IXDYCBAD.js";import"./chunk-EFNCQJI3.js";var a={onlyIfChanged:!0,cookie:!0};function m(n){if(n.gdprApplies===!1)return;let e=n.purpose?.consents??{},t=!!e[1]&&!!e[7];return{analytics:t,replay:t&&!!e[8],marketing:!!e[1]&&!!e[4]}}function g(n){let e=i=>i in n?n[i]==="granted":void 0,t={},s=e("analytics_storage");s!==void 0&&(t.analytics=t.replay=s);let o=e("ad_storage"),r=e("ad_user_data");return o!==void 0&&(t.marketing=o&&r!==!1),t}function v(n){let e=typeof n=="string"?n.split(","):n,t=e.includes("C0002");return{analytics:t,replay:t,marketing:e.includes("C0004")}}function y(n){return{analytics:!!n.statistics,replay:!!n.statistics,marketing:!!n.marketing}}function w(n,e){return{analytics:!!n.statistics,replay:e?!!n[e]:!!n.statistics,marketing:!!n.marketing}}var M=n=>{let e,s=u(()=>{let o=window.__tcfapi;return typeof o!="function"?!1:(o("addEventListener",2,(r,i)=>{if(!i||r.eventStatus!=="tcloaded"&&r.eventStatus!=="useractioncomplete")return;e=r.listenerId;let d=m(r);d&&c(n,d,"tcf",a)}),!0)});return()=>{s();let o=window.__tcfapi;e!==void 0&&typeof o=="function"&&o("removeEventListener",2,()=>{},e)}},O=n=>{let e=window,t=e.dataLayer??=[],s=r=>{let i=r;i&&typeof i=="object"&&i[0]==="consent"&&(i[1]==="default"||i[1]==="update")&&i[2]&&typeof i[2]=="object"&&c(n,g(i[2]),"gcm",a)};t.forEach(s);let o=t.push;return t.push=function(...r){return r.forEach(s),o.apply(this,r)},()=>{t.push=o}},U=n=>{let e=o=>{(typeof o=="string"||Array.isArray(o))&&c(n,v(o),"onetrust",a)},t=window,s=o=>e(o.detail??t.OnetrustActiveGroups);return window.addEventListener("OneTrustGroupsUpdated",s),e(t.OnetrustActiveGroups),()=>window.removeEventListener("OneTrustGroupsUpdated",s)},x=n=>{let e=window,t=()=>{let o=e.Cookiebot;o?.consent&&o.hasResponse!==!1&&c(n,y(o.consent),"cookiebot",a)},s=["CookiebotOnConsentReady","CookiebotOnAccept","CookiebotOnDecline"];for(let o of s)window.addEventListener(o,t);return t(),()=>s.forEach(o=>window.removeEventListener(o,t))};function k(n){let e=n.ANALYTICS==="ACCEPT";return{analytics:e,replay:e,marketing:n.MARKETING==="ACCEPT"}}function u(n){if(n())return()=>{};let e=0,t=setInterval(()=>(n()||++e>40)&&clearInterval(t),250);return()=>clearInterval(t)}var f=["osano-cm-initialized","osano-cm-consent-saved","osano-cm-consent-changed"],_=n=>{let e,t=o=>{let r=o&&typeof o=="object"&&Object.keys(o).length?o:e?.getConsent?.();r&&Object.keys(r).length&&c(n,k(r),"osano",a)},s=u(()=>{if(e=window.Osano?.cm,!e)return!1;for(let o of f)e.addEventListener?.(o,t);return t(e.getConsent?.()),!0});return()=>{s();for(let o of f)e?.removeEventListener?.(o,t)}};function b(n,e="Lucida"){let t=n.find(r=>r.name.toLowerCase()===e.toLowerCase());if(!t)return;let s=t.consent?.status===!0,o=n.filter(r=>r.categorySlug==="marketing");return{analytics:s,replay:s,marketing:o.length>0&&o.every(r=>r.consent?.status===!0)}}var l=["UC_UI_INITIALIZED","UC_UI_CMP_EVENT","ucEvent","UC_CONSENT"];function h(n="Lucida"){return e=>{let t=()=>{let i=window.UC_UI?.getServicesBaseInfo?.();if(!i)return!1;let d=b(i,n);return d?c(e,d,"usercentrics",a):e.log(`usercentrics: no service named "${n}"; consent left unchanged`),!0},s=()=>{t()};for(let r of l)window.addEventListener(r,s);let o=u(t);return()=>{o();for(let r of l)window.removeEventListener(r,s)}}}var L=h(),C=["CookieMunchOnConsentReady","CookieMunchOnChange"];function S(n,e){let t=e?.detail??{};for(let s of[t.receiptId,t.consentReceiptId,t.consentId,t.ledgerId,n.receiptId,n.consentReceiptId,n.consentId,n.ledgerId])if(typeof s=="string"&&s)return s.slice(0,128)}function E(n={}){return e=>{let t=s=>{let o=window.CookieMunch;if(!o?.consent||o.hasResponse!==!0)return;let r=S(o,s);c(e,w(o.consent,n.replayCategory),"cookiemunch",{...a,...r?{receiptId:r}:{}})};for(let s of C)window.addEventListener(s,t);return t(),()=>C.forEach(s=>window.removeEventListener(s,t))}}var p=E();var T=n=>{n.consentUi={showBanner:async e=>(await import("./banner-TXLAMTQM.js")).showBanner(n,e),hideBanner:()=>{import("./banner-TXLAMTQM.js").then(e=>e.hideBanner())}}};var j=n=>(T(n),p(n));export{I as CONSENT_EVENT,c as applyConsent,T as consentBanner,j as consentModule,E as cookieMunchBridge,p as cookieMunchConsent,w as cookieMunchToConsent,x as cookiebotConsent,y as cookiebotToConsent,O as gcmConsent,g as gcmToConsent,U as oneTrustConsent,v as oneTrustToConsent,_ as osanoConsent,k as osanoToConsent,M as tcfConsent,m as tcfToConsent,h as usercentricsBridge,L as usercentricsConsent,b as usercentricsToConsent};
|
package/dist/static/v0/core.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var Y="lc_consent";function he(n,e,t){return e==="opt_in"?"opt_in":t==="opt_in"||t==="opt_out"||t==="cookieless"?t:e==="opt_out"?n:void 0}var ge=["analytics","replay","marketing"],L=class{constructor(e){this.o=e;this.modeNow=e.mode??"opt_out",this.queueBeforeConsent=e.queueBeforeConsent??!1;let t=this.opens();this.state={analytics:t,replay:t,marketing:t},this.key=e.storageKey||Y;let s=e.storage.get(this.key);if(s)try{let o=JSON.parse(s);for(let i of ge)typeof o[i]=="boolean"&&(this.state[i]=o[i]);this.decided=ge.some(i=>typeof o[i]=="boolean")}catch{}this.waiting=!!e.awaitRemote&&!this.decided,this.waiting&&(this.state={analytics:!1,replay:!1,marketing:!1})}o;modeNow;queueBeforeConsent;state;decided=!1;waiting;geoCookieless=!1;key;listeners=[];opens(){return this.modeNow==="opt_out"&&!(this.o.respectDnt&&this.o.dnt)}get mode(){return this.modeNow}get resolving(){return this.waiting}get anonymous(){return this.geoCookieless&&!this.decided}resolve(e){if(!this.waiting)return this.state.analytics;this.waiting=!1,(e==="opt_in"||e==="opt_out")&&(this.modeNow=e),this.geoCookieless=e==="cookieless";let t=!this.geoCookieless&&this.opens();return this.state={analytics:t,replay:t,marketing:t},t}get(){return{...this.state}}has(e){return this.state[e]}status(e="analytics"){return this.decided?this.state[e]?"granted":"denied":"pending"}get pending(){return this.waiting||this.modeNow==="opt_in"&&!this.state.analytics}set(e){let t=this.get();for(let s of ge)e[s]!==void 0&&(this.state[s]=e[s]);this.decided=!0,this.waiting=!1,this.o.storage.set(this.key,JSON.stringify(this.state));for(let s of this.listeners)s(this.get(),t)}onChange(e){this.listeners.push(e)}},$=class{constructor(e,t){this.inner=e;this.allowed=t}inner;allowed;mem=new Map;get(e){return this.mem.has(e)?this.mem.get(e)??null:this.inner.get(e)}set(e,t){this.allowed()?this.inner.set(e,t):this.mem.set(e,t)}remove(e){this.allowed()?this.inner.remove(e):this.mem.set(e,null)}flushBuffered(){for(let[e,t]of this.mem)t===null?this.inner.remove(e):this.inner.set(e,t);this.mem.clear()}discardBuffered(){this.mem.clear()}};var J=0,R=0;function He(n){let e=new Uint8Array(n),t=globalThis.crypto;if(t?.getRandomValues)t.getRandomValues(e);else for(let s=0;s<n;s++)e[s]=Math.floor(Math.random()*256);return e}function C(n=Date.now()){if(n>J){J=n;let i=He(2);R=((i[0]??0)<<8|(i[1]??0))&1023}else R++,R>4095&&(J++,R=0);let e=He(8),t=new Uint8Array(16),s=J;t[0]=Math.floor(s/2**40)&255,t[1]=Math.floor(s/2**32)&255,t[2]=Math.floor(s/2**24)&255,t[3]=Math.floor(s/2**16)&255,t[4]=Math.floor(s/2**8)&255,t[5]=s&255,t[6]=112|R>>8,t[7]=R&255,t[8]=128|(e[0]??0)&63;for(let i=1;i<8;i++)t[8+i]=e[i]??0;let o=Array.from(t,i=>i.toString(16).padStart(2,"0")).join("");return`${o.slice(0,8)}-${o.slice(8,12)}-${o.slice(12,16)}-${o.slice(16,20)}-${o.slice(20)}`}var We="lc_identity",Q=class{constructor(e,t,s=!1,o=!1){this.storage=e;this.cookieless=s;let i=e.get(We),a;try{a=i?JSON.parse(i):void 0}catch{a=void 0}if(a?.distinct_id)this.s=a;else if(s)this.s={distinct_id:"",anon_id:"",identified:!1};else{let d=t??C();this.s={distinct_id:d,anon_id:d,identified:o&&!!t},this.save()}}storage;cookieless;s;save(){this.storage.set(We,JSON.stringify(this.s))}get distinctId(){return this.s.distinct_id}get priorAnonId(){return this.s.identified&&this.s.anon_id&&this.s.anon_id!==this.s.distinct_id?this.s.anon_id:void 0}get isIdentified(){return this.s.identified}identify(e){if(!e||e===this.s.distinct_id)return e&&!this.s.identified&&(this.s.identified=!0,this.save()),{event:null};let t=this.s.distinct_id,s=!this.s.identified;return this.s={...this.s,distinct_id:e,identified:!0},this.save(),s&&t?{event:"$identify",anonDistinctId:t}:{event:"$identify"}}aliasProps(e,t){return{alias:e,distinct_id:t??this.s.distinct_id}}reset(e=!1){if(this.cookieless){this.s={distinct_id:"",anon_id:"",identified:!1};return}let t=e&&this.s.anon_id||C();this.s={distinct_id:t,anon_id:t,identified:!1},this.save()}};function F(n,e={}){let t=Math.min(e.maxMs??3e4,(e.baseMs??1e3)*2**n);return Math.round(t*(.5+.5*(e.random??Math.random)()))}function Ve(n){return n===0||n===408||n===429||n>=500}var X=class{constructor(e){this.o=e;this.flushAt=e.flushAt??20,this.intervalMs=e.flushIntervalMs??5e3,this.maxSize=e.maxQueueSize??1e3,this.maxRetries=e.maxRetries??5,this.batchMax=Math.max(1,Math.min(e.maxBatchSize??1e3,1e3))}o;items=[];timer;attempt=0;inflight;closed=!1;warned404=!1;flushAt;intervalMs;maxSize;maxRetries;batchMax;get size(){return this.items.length}enqueue(e){this.closed||(this.items.push(e),this.items.length>this.maxSize&&this.o.onDrop?.(this.items.splice(0,this.items.length-this.maxSize),"queue_full"),this.items.length>=this.flushAt?this.flush():this.arm(this.intervalMs))}arm(e){this.timer===void 0&&(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},e))}disarm(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0}flush(e={}){if(this.disarm(),this.inflight)return this.inflight.then(()=>this.items.length?this.flush(e):void 0);if(!this.items.length)return Promise.resolve();let t=this.items.splice(0,this.batchMax),s=(this.o.clock??Date).now(),o=JSON.stringify({api_key:this.o.apiKey,batch:t,sent_at:new Date(s).toISOString()});this.o.log?.("send batch",t.length);let i=this.o.transport.send(this.o.url,o,e.beacon?{beacon:!0}:{}).then(a=>a,()=>({status:0,retryAfterMs:void 0})).then(a=>this.settle(t,a.status,!!e.beacon,a.retryAfterMs)).finally(()=>{this.inflight=void 0});return this.inflight=i,i}settle(e,t,s,o){if(t>=200&&t<300){this.attempt=0,this.items.length>=this.flushAt?this.flush():this.items.length&&this.arm(this.intervalMs);return}if(!Ve(t)||s||this.attempt>=this.maxRetries){t===404&&!this.warned404&&(this.warned404=!0,console.warn(`[lucida] ${this.o.url} returned 404, so events are being dropped. apiHost is probably wrong: use https://capture.lucidace.com (or your own capture host), not the app host.`)),this.o.onDrop?.(e,`status_${t}`),this.attempt=0;return}this.items.unshift(...e);let i=Math.max(F(this.attempt++,this.o.backoff),Math.min(o??0,6e4));this.o.log?.("retry in",i,"ms"),this.arm(i)}clear(){this.items=[],this.disarm()}async shutdown(){await this.flush(),this.closed=!0,this.disarm()}};var me="lc_session";function ze(n,e,t){return typeof n=="number"&&Number.isInteger(n)&&n>=e&&n<=t?n*6e4:void 0}var Tt=6e4,Mt=10*36e5,jt=24*36e5,Dt=/^([0-9a-f]{8})-?([0-9a-f]{4})-7[0-9a-f]{3}-/i;function Lt(n,e){let t=Dt.exec(n);if(!t)return!0;let s=parseInt(t[1]+t[2],16);return s-e<=6e4&&e-s<=jt}var Z=class{constructor(e,t={}){this.storage=e;this.o=t;this.idleMs=Math.min(Mt,Math.max(Tt,t.idleMs??30*6e4)),this.maxMs=t.maxMs??24*36e5,this.newOn=t.newOnEvents??[],this.clock=t.clock??{now:()=>Date.now()},this.bootstrapId=t.bootstrapId}storage;o;windowId=C();idleMs;maxMs;newOn;clock;bootstrapId;configure(e){this.o.idleMs===void 0&&(this.idleMs=ze(e.session_idle_minutes,1,600)??this.idleMs),this.o.maxMs===void 0&&(this.maxMs=ze(e.session_max_minutes,5,10080)??this.maxMs),this.o.newOnEvents===void 0&&Array.isArray(e.session_new_on_events)&&(this.newOn=e.session_new_on_events.filter(t=>typeof t=="string"&&t!==""))}read(){try{let e=this.storage.get(me);return e?JSON.parse(e):void 0}catch{return}}touch(e,t){let s=this.clock.now(),o=this.read(),i=!!(o?.campaign&&e&&o.campaign!==e),a=t!==void 0&&this.newOn.includes(t),d=!o||Math.abs(s-o.last)>this.idleMs||Math.abs(s-o.start)>this.maxMs||i||a;return(d||!o)&&(o={id:!o&&this.bootstrapId&&Lt(this.bootstrapId,s)?this.bootstrapId:C(s),start:s,last:s}),this.bootstrapId=void 0,o.last=s,e&&(o.campaign=e),this.storage.set(me,JSON.stringify(o)),{sessionId:o.id,windowId:this.windowId,isNew:d}}startedAt(){return this.read()?.start}reset(){this.storage.remove(me)}};function Ke(n,e){let t=n.get(e);if(t)try{return JSON.parse(t)}catch{return}}var ee=class{constructor(e,t="lc_props",s){this.storage=e;this.key=t;this.persist=s;this.p=Ke(e,t)??{}}storage;key;persist;p;save(){let e=this.persist;this.storage.set(this.key,JSON.stringify(e?Object.fromEntries(Object.entries(this.p).filter(([t])=>e(t))):this.p))}register(e){Object.assign(this.p,e),this.save()}registerOnce(e){for(let[t,s]of Object.entries(e))t in this.p||(this.p[t]=s);this.save()}unregister(e){delete this.p[e],this.save()}all(){return{...this.p}}clear(){this.p={},this.storage.remove(this.key)}},te=class{constructor(e){this.storage=e;this.g=Ke(e,"lc_groups")??{}}storage;g;set(e,t){this.g[e]=t,this.storage.set("lc_groups",JSON.stringify(this.g))}all(){return Object.keys(this.g).length?{...this.g}:void 0}clear(){this.g={},this.storage.remove("lc_groups")}};function Ft(n,e){let t=new Date(n??e);return(Number.isNaN(t.getTime())?new Date(e):t).toISOString()}var N=class{constructor(e){this.c=e;this.clock=e.clock??{now:()=>Date.now()},this.consent=new L({...e.consent,storage:e.consentStorage??e.storage}),this.gated=new $(e.storage,()=>this.consent.has("analytics")),this.storage=this.gated,this.identity=new Q(this.gated,e.bootstrapDistinctId,e.cookieless,e.bootstrapIdentified),this.session=new Z(this.gated,{clock:this.clock,...e.session}),this.props=new ee(this.gated,void 0,e.persistProperty),this.groupState=new te(this.gated),this.queue=new X({transport:e.transport,url:`${e.apiHost.replace(/\/+$/,"")}/v1/batch`,apiKey:e.apiKey,clock:this.clock,...e.log?{log:e.log}:{},...e.onDrop?{onDrop:e.onDrop}:{},...e.queue})}c;consent;identity;session;queue;storage;gated;props;groupState;clock;device;pre=[];listeners=[];captureListeners=[];sessionListeners=[];lastSession="";filter;get anonDistinctId(){return this.identity.priorAnonId}get distinctId(){return this.identity.distinctId}get deviceId(){return this.c.cookieless?"":(this.device||(this.device=this.gated.get("lc_device_id")||C(),this.gated.set("lc_device_id",this.device)),this.device)}get groups(){return this.groupState.all()}get sessionId(){return this.touchSession().sessionId}touchSession(e){let t=this.session.touch(this.c.campaignKey?.(),e);if(t.sessionId!==this.lastSession){this.lastSession=t.sessionId;for(let s of this.sessionListeners)s(t.sessionId,t.windowId)}return t}onSessionId(e){return this.sessionListeners.push(e),()=>{this.sessionListeners.splice(this.sessionListeners.indexOf(e),1)}}get sessionStart(){return this.session.startedAt()}getProperty(e){return this.props.all()[e]}setFilter(e){this.filter=e}onChange(e){this.listeners.push(e)}onCaptured(e){this.captureListeners.push(e)}emit(e){for(let t of this.listeners)t(e)}consentStatus(){return this.consent.status()}get anonymousOnReject(){return!!this.c.consent?.cookielessOnReject&&this.consent.status()==="denied"}capture(e,t={},s={}){let o=this.consent.has("analytics"),i=!o&&(this.anonymousOnReject||this.consent.anonymous),a=this.consent.pending&&(this.consent.queueBeforeConsent||this.consent.resolving);if(!o&&!i&&!a){this.c.log?.("dropped (no consent)",e);return}if(i&&(e==="$identify"||e==="$create_alias")){this.c.log?.("withheld (declined, anonymous mode)",e);return}let d=this.touchSession(e),p=this.c.enrich?.(e,t),h=this.consent.status()!=="pending",m=i?{}:{...p?.$set,...s.$set,...e==="$consent_updated"&&h?{$consent:this.consent.get()}:{}},_=i?{}:{...p?.$set_once,...s.$set_once},P=this.groupState.all(),g=i?"":this.identity.distinctId,v={uuid:C(this.clock.now()),event:e,...g?{distinct_id:g}:{},timestamp:Ft(s.timestamp,this.clock.now()),properties:{...this.props.all(),...p?.properties,...t,$session_id:d.sessionId,$window_id:d.windowId,$lib:this.c.library.name,$lib_version:this.c.library.version,...h?{$consent:this.consent.get()}:{}},...Object.keys(m).length?{$set:m}:{},...Object.keys(_).length?{$set_once:_}:{},...!i&&s.$unset?.length?{$unset:s.$unset}:{},...P?{$groups:P}:{}},b=this.filter?this.filter(v):v;if(!b){this.c.log?.("dropped (policy)",e);return}this.c.log?.("capture",e,b),this.c.onCapture?.(b);for(let S of this.captureListeners)S(b);return o||i?this.queue.enqueue(b):this.pre.length<(this.c.queue?.maxQueueSize??1e3)&&this.pre.push(b),b}identify(e,t,s){let o=this.identity.identify(e);(o.event||t||s)&&this.capture("$identify",o.anonDistinctId?{$anon_distinct_id:o.anonDistinctId}:{},{...t?{$set:t}:{},...s?{$set_once:s}:{}}),this.emit("identify")}alias(e,t){this.capture("$create_alias",this.identity.aliasProps(e,t))}reset(e={}){this.identity.reset(e.reuseAnonymousId),e.resetDeviceId&&(this.device=void 0,this.gated.remove("lc_device_id")),this.props.clear(),this.groupState.clear(),this.session.reset(),this.lastSession="",this.emit("reset")}register(e){this.props.register(e)}registerOnce(e){this.props.registerOnce(e)}unregister(e){this.props.unregister(e)}group(e,t,s){this.groupState.set(e,t),this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:s??{}}),this.emit("group")}getConsent(){return this.consent.get()}getConsentStatus(e="analytics"){return this.consent.status(e)}hasConsent(e){return this.consent.has(e)}setConsent(e){let t=this.consent.has("analytics"),s=e.analytics??t;if(t&&!s&&(this.capture("$opt_out"),this.queue.flush()),!t&&s&&(this.anonymousOnReject||this.consent.anonymous)&&this.queue.flush(),this.consent.set(e),!t&&s){this.gated.flushBuffered();for(let o of this.pre.splice(0))this.queue.enqueue(o);this.capture("$opt_in")}else t&&!s&&this.queue.clear();s||(this.pre.length=0),this.emit("consent")}applyRemote(e){this.session.configure(e),this.resolveConsent(he(this.consent.mode,e.consent_mode,e.consent_default))}resolveConsent(e){if(!this.consent.resolving)return;let t=this.consent.resolve(e),s=this.pre.splice(0);if(t){this.gated.flushBuffered();for(let o of s)this.queue.enqueue(o)}else if(this.consent.anonymous){this.gated.discardBuffered();for(let o of s){if(o.event==="$identify"||o.event==="$create_alias")continue;let i={...o};delete i.distinct_id,delete i.$set,delete i.$set_once,delete i.$unset,this.queue.enqueue(i)}}else this.consent.queueBeforeConsent&&this.pre.push(...s);this.emit("consent")}optIn(){this.setConsent({analytics:!0,replay:!0,marketing:!0})}optOut(){this.setConsent({analytics:!1,replay:!1,marketing:!1})}flush(e){return this.queue.flush(e)}shutdown(){return this.queue.shutdown()}};function Ge(n){let e="";return t=>{for(e+=t;;){let s=/\r?\n\r?\n/.exec(e);if(!s)return;let o=e.slice(0,s.index);e=e.slice(s.index+s[0].length);let i="message",a,d=[];for(let p of o.split(/\r?\n/)){if(p.startsWith(":"))continue;let h=p.indexOf(":"),[m,_]=h<0?[p,""]:[p.slice(0,h),p.slice(h+1).replace(/^ /,"")];m==="event"?i=_??"":m==="data"?d.push(_??""):m==="id"&&(a=_)}d.length&&n(a===void 0?{event:i,data:d.join(`
|
|
2
|
-
`)}:{event:i,data:
|
|
3
|
-
`),id:a})}}}var ne=class{constructor(e){this.o=e}o;ctl;stopped=!0;timer;cursor=0;gen=0;polling=!1;start(){this.stopped&&(this.stopped=!1,this.loop(++this.gen))}stop(){this.stopped=!0,this.gen++,this.ctl?.abort(),this.timer&&clearTimeout(this.timer)}restart(){let e=!this.stopped;this.stop(),this.cursor=0,e&&this.start()}live(e){return!this.stopped&&e===this.gen}deliver(e){if(e.seq>this.cursor){this.cursor=e.seq;try{this.o.onIntervention(e)}catch(t){this.o.log?.("onIntervention threw",t)}}}url(e){let t=`distinct_id=${encodeURIComponent(this.o.distinctId())}${this.cursor?`&cursor=${this.cursor}`:""}`;return`${this.o.apiHost}${e}?${t}`}sleep(e){return new Promise(t=>{this.timer=setTimeout(t,e),this.timer.unref?.()})}async loop(e){let t=0;for(;this.live(e);){let s;try{let o=await this.connectOnce(e);if(o==="gone")return this.stop();o==="poll"?(t=0,s=this.o.pollMs??15e3):(o==="streamed"&&(t=0),s=F(t++,this.o.backoff))}catch(o){this.live(e)&&this.o.log?.("intervention stream error",o),s=F(t++,this.o.backoff)}if(!this.live(e))return;await this.sleep(s)}}async connectOnce(e){if(this.polling)return this.pollOnce(e);this.ctl=new AbortController;let t={Authorization:`Bearer ${this.o.apiKey}`,Accept:"text/event-stream"},s=await this.o.fetch(this.url("/v1/interventions/stream"),{headers:t,signal:this.ctl.signal});if(s.status===404)return"gone";if(!s.ok)return"failed";let o=s.body;if(!o||typeof TextDecoderStream>"u")return this.ctl.abort(),this.polling=!0,this.pollOnce(e);let i=Ge(d=>{if(!(d.event!=="intervention"||!this.live(e)))try{this.deliver(JSON.parse(d.data))}catch{this.o.log?.("bad intervention payload")}}),a=o.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:d,value:p}=await a.read();if(d)return"streamed";i(p)}}async pollOnce(e){this.ctl=new AbortController;let t=await this.o.fetch(this.url("/v1/interventions"),{headers:{Authorization:`Bearer ${this.o.apiKey}`},signal:this.ctl.signal});if(t.status===404)return"gone";if(!t.ok)return"failed";let s=await t.json();if(this.live(e))for(let o of s.data??[])this.deliver(o);return"poll"}};function ye(n,e){let t=new Set,{whenConsented:s,disabled:o,...i}=e,a=new ne({...i,distinctId:()=>n.distinctId,onIntervention:p=>{for(let h of[...t])h(p)}}),d=!1;return n.onChange(p=>{d&&((p==="identify"||p==="reset")&&a.restart(),p==="consent"&&(n.hasConsent("analytics")?a.start():a.stop()))}),{on(p){return t.add(p),!d&&!o&&(d=!0,s(()=>a.start())),()=>{t.delete(p)}},stop:()=>a.stop()}}function ve(n,e,t={}){let s=t.key??"lc_offline",o=t.maxBatches??50,i=t.maxBytes??1e6,a=t.isOnline??(()=>!0),d,p,h=()=>{try{let g=JSON.parse(e.get(s)??"[]");return Array.isArray(g)?g:[]}catch{return[]}},m=g=>{let v=g.reduce((b,S)=>b+S.body.length,0);for(;g.length>o||v>i&&g.length>1;)v-=g.shift().body.length;g.length?e.set(s,JSON.stringify(g)):e.remove(s)},_=g=>{m([...h(),...g]),d??=setTimeout(()=>{d=void 0,P.drain()},t.retryMs??3e4)},P={async send(g,v,b){if(!a())return _([{url:g,body:v}]),{status:200};let S=await n.send(g,v,b);return S.status!==0?S:(_([{url:g,body:v}]),{status:200})},drain(){return p??=(async()=>{let g=h();if(!g.length||!a())return;e.remove(s);let v=[];for(let[b,S]of g.entries())if((await n.send(S.url,S.body)).status===0){v.push(...g.slice(b));break}v.length&&_(v)})().finally(()=>{p=void 0}),p}};return P}function be(n){let e=Object.keys(n);if(e.length===0)return{};let t={};for(let s of e)t[`$feature/${s}`]=n[s];return t.$active_feature_flags=e.filter(s=>n[s]!==!1).sort(),t}function B(n,e,t,s){return{key:n,value:e,enabled:e!==void 0&&e!==!1,...typeof e=="string"?{variant:e}:{},...t!==void 0?{payload:t}:{},reason:e===void 0?"not_found":s}}var A={started:"$ai_conversation_started",message:"$ai_message",feedback:"$ai_feedback",ended:"$ai_conversation_ended",outcome:"$ai_outcome"},Nt=["resolved","unresolved","escalated","abandoned","error"],Bt=4e3,Ut=2e3,Je=["wrong","useless","not helpful","unhelpful","doesn't work","does not work","didn't help","did not help","not what i asked","that's not it","stupid","terrible","awful","frustrating","frustrated","annoying","worst","hate","incorrect","nonsense","confusing","makes no sense","real person","human agent","talk to a human","speak to a human","wtf","ugh"],Qe=["thanks","thank you","great","perfect","awesome","helpful","that worked","works now","solved","exactly"],H=n=>Array.from(n),Se=(n,e)=>H(n).slice(0,e).join(""),qt=0xcbf29ce484222325n,Ht=0x100000001b3n,Wt=0xffffffffffffffffn,Vt=new TextEncoder;function zt(n){let e=qt;for(let t of Vt.encode(n))e=(e^BigInt(t))*Ht&Wt;return e}function Xe(n){let e=(n.toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]).filter(o=>H(o).length>=2);if(!e.length)return;let t=new Array(64).fill(0);for(let o of e){let i=zt(o);for(let a=0;a<64;a++)t[a]=(t[a]??0)+((i>>BigInt(a)&1n)===1n?1:-1)}let s=0n;for(let o=0;o<64;o++)(t[o]??0)>0&&(s|=1n<<BigInt(o));return s.toString(16).padStart(16,"0")}function Ze(n){let t=` ${n.toLowerCase().replace(/’/g,"'").replace(/[.,!?;:]/g," ").replace(/\s+/g," ").trim()} `,s=0;for(let i of Je)t.includes(` ${i} `)&&(s++,t=t.split(` ${i} `).join(" "));let o=Qe.filter(i=>t.includes(` ${i} `)).length;return s>o?-1:o>s?1:0}var et=n=>H(n).filter(e=>e>="0"&&e<="9").map(Number);function Kt(n){let e=et(n);if(e.length<13||e.length>19)return!1;let t=0;return e.reverse().forEach((s,o)=>t+=o%2===1?s>4?s*2-9:s*2:s),t%10===0}var Ye=String.raw`[\p{Alphabetic}\p{M}\p{Nd}\p{Pc}\p{Join_Control}]`,Gt=[[new RegExp(String.raw`(?<!${Ye})\p{Nd}(?:[ -]?\p{Nd}){12,18}(?!${Ye})`,"gu"),Kt],[/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/g,()=>!0],[/\+?\p{Nd}[\p{Nd}\s().-]{7,}\p{Nd}/gu,Yt]];function Yt(n){let e=et(n).length;return e>=10&&e<=15}var Jt=n=>H(n).map(e=>/\s/u.test(e)?e:"*").join("");function we(n){let e=n;for(let[t,s]of Gt)e=e.replace(t,o=>s(o)?Jt(o):o);return e===n?void 0:e}function tt(n){if(typeof n!="string")return;let e=n.toLowerCase();return/^[0-9a-f]{32}$/.test(e)?e:void 0}var nt=n=>typeof n=="string"&&Nt.includes(n)?n:void 0,U=(n,e)=>typeof n=="string"&&n?Se(n,e):void 0;function Qt(n,e,t){let s=Se(e,t),o=we(s);return o===void 0?{[n]:s}:{[n]:o,$ai_text_redacted:!0}}function st(n,e,t,s){if(n!=="user"&&n!=="assistant")return;let o={$ai_role:n,$ai_message_index:t,$ai_text_length:H(e).length};if(n==="user"){let i=Xe(e);i!==void 0&&(o.$ai_text_hash=i),o.$ai_sentiment=Ze(e)}return s?{...o,...Qt("$ai_text",e,Bt)}:o}function ot(n,e){let t=n.value;if(n.kind==="thumbs"&&t!==1&&t!==-1||n.kind==="rating"&&!(Number.isInteger(t)&&t>=1&&t<=5)||n.kind!=="thumbs"&&n.kind!=="rating"&&n.kind!=="comment")return;let s={$ai_feedback_kind:n.kind};if(n.kind!=="comment"&&(s.$ai_feedback_value=t),n.comment&&e){let o=Se(n.comment,Ut);s.$ai_feedback_comment=we(o)??o}return n.messageIndex!==void 0&&(s.$ai_message_index=n.messageIndex),s}function _e(n,e){let t=nt(n),s=U(e,64);return{...t?{$ai_outcome:t}:{},...s?{$ai_resolution:s}:{}}}function Xt(){let n=globalThis.crypto,e=new Uint8Array(16);if(n?.getRandomValues)n.getRandomValues(e);else for(let s=0;s<16;s++)e[s]=Math.floor(Math.random()*256);e[6]=(e[6]??0)&15|64,e[8]=(e[8]??0)&63|128;let t=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function rt(n={}){let e={$ai_conversation_id:n.conversationId||Xt()},t=(s,o)=>{o!==void 0&&(e[s]=o)};return t("$ai_agent_name",U(n.agentName,128)),t("$ai_agent_version",U(n.agentVersion,64)),t("$ai_topic",U(n.topic,128)),t("$ai_use_case",U(n.useCase,128)),t("$ai_trace_id",tt(n.traceId)),e}var q=class{next=0;common;emit;captureText;constructor(e,t={},s=!1){this.emit=e,this.captureText=s,this.common=rt(t)}get id(){return this.common.$ai_conversation_id}send(e,t){this.emit(e,{...this.common,...t})}start(){return this.send(A.started,{}),this}message(e,t,s={}){let o=s.index??this.next,i=st(e,t,o,this.captureText);return i?(this.next=o+1,this.send(A.message,i),!0):!1}feedback(e){let t=ot(e,this.captureText);return t?(this.send(A.feedback,t),!0):!1}end(e,t){this.send(A.ended,_e(e,t))}outcome(e,t){let s=_e(e,t);return s.$ai_outcome?(this.send(A.outcome,s),!0):!1}};var Zt=["bot","crawl","spider","slurp","headlesschrome","phantomjs","puppeteer","playwright","lighthouse","pingdom","uptimerobot","facebookexternalhit","preview","scrapy","python-requests","go-http-client","cypress","lightpanda","hubspot","nessus","prerender","deepscan","screaming frog","sitebulb","turnitin","ia_archiver","chatgpt-user","app.hypefactors.com","google favicon","google web preview","-google","googleother","googleweblight","google-read-aloud","google-inspectiontool","google-hoteladsverifier","google-cloudvertexbot"];function it(n,e=[]){let t=n.toLowerCase();return e.some(s=>s&&t.includes(s.toLowerCase()))?!0:Zt.some(s=>t.includes(s))&&!/\bcubot\b/.test(t)}var O=["gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","igshid","msclkid","ttclid","li_fat_id","twclid","mc_cid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],at="lc_click_ids";function ct(n,e=90,t=Date.now){let s,o=()=>{try{return JSON.parse(n.get(at)??"{}")}catch{return{}}};return()=>{let i=o();if(location.search!==s){s=location.search;let d=new URLSearchParams(s),p=!1;for(let h of O){let m=d.get(h);m&&(i[h]={v:m.slice(0,512),t:t()},p=!0)}p&&n.set(at,JSON.stringify(i))}let a={};for(let d of O){let p=i[d];p&&t()-p.t<e*864e5&&(a[d]=p.v)}return a}}function en(){return Array.from(document.querySelectorAll("meta[http-equiv]")).filter(n=>n.getAttribute("http-equiv")?.toLowerCase()==="content-security-policy").map(n=>n.getAttribute("content")??"")}function tn(n){let e=new Map;for(let s of n.split(";")){let[o,...i]=s.trim().toLowerCase().split(/\s+/);o&&!e.has(o)&&e.set(o,i)}let t=e.get("style-src-elem")??e.get("style-src")??e.get("default-src");return!!t&&!(t.includes("'unsafe-inline'")&&!t.some(s=>s.startsWith("'nonce-")||s.startsWith("'sha")))}function dt(n,e){if(typeof document>"u")return()=>{};!e&&en().some(tn)&&n("CSP hint: this page's Content-Security-Policy blocks inline <style>; set the `nonce` option so guides and the experiment veil render (docs/guides/csp.md)");let t=s=>{let o=s;/^style-src/.test(o.effectiveDirective??"")&&o.blockedURI==="inline"&&n(`CSP hint: an inline style was blocked by ${o.effectiveDirective}${e?" (check that `nonce` matches the page's nonce)":"; set the `nonce` option"}`)};return document.addEventListener("securitypolicyviolation",t),()=>document.removeEventListener("securitypolicyviolation",t)}var nn=(n,e)=>n.slice(0,e);function lt(n){try{let e=new URL(n);return e.protocol==="data:"||e.protocol==="blob:"?e.protocol:e.origin+e.pathname}catch{return nn(n,64)}}function ut(n,e={}){if(typeof document>"u")return()=>{};let t=e.maxPerPage??20,s=new Set,o=i=>{let a=i,d={$csp_directive:a.effectiveDirective??a.violatedDirective,$csp_blocked_uri:lt(a.blockedURI??""),$csp_source_file:a.sourceFile?lt(a.sourceFile):void 0,$csp_line:a.lineNumber||void 0,$csp_column:a.columnNumber||void 0,$csp_disposition:a.disposition},p=[d.$csp_directive,d.$csp_blocked_uri,d.$csp_source_file,d.$csp_line].join("|");s.has(p)||s.size>=t||(s.add(p),n("$csp_violation",Object.fromEntries(Object.entries(d).filter(([,h])=>h!==void 0))))};return document.addEventListener("securitypolicyviolation",o),()=>document.removeEventListener("securitypolicyviolation",o)}var sn=["chrome-extension:","moz-extension:","safari-web-extension:","ms-browser-extension:"],pt=()=>typeof location<"u"&&sn.includes(location.protocol);function on(n,e,t){let s=e.find(a=>n.startsWith(`${a}/`));if(!s)return n;let o=n.slice(s.length),i=o.search(/[?#]/);return s+t(i<0?o:o.slice(0,i))+(i<0?"":o.slice(i))}function ft(n,e,t,s){if(!s)return{transport:n,fetch:e};let o=i=>on(i,t,s);return{transport:{send:(i,a,d)=>n.send(o(i),a,d)},fetch:((i,a)=>e(typeof i=="string"?o(i):i instanceof URL?o(i.href):i,a))}}var rn="__LUCIDA_DEVTOOLS_HOOK__";function gt(n,e,t){let s=globalThis[rn];if(!(!s||typeof s.emit!="function"||typeof s.attach!="function")){n.onCapture(o=>{try{s.emit(o)}catch{}});try{s.attach({projectKeyPrefix:n.apiKey.slice(0,8),apiHost:t,distinctId:()=>e.distinctId,loadToolbar:o=>e.loadToolbar(o),startReplay:async()=>n.replay?(await n.replay.start(!0),n.replay.isRecording()):!1,replayUrl:()=>e.getReplayUrl()})}catch{}}}var W=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function an(n){let e={},t=new URLSearchParams(location.search);for(let s of[...W,...O,...n]){let o=t.get(s);o&&(e[`$${s}`]=o)}return e}function ht(){let n=new URLSearchParams(location.search),e=W.map(t=>n.get(t)??"");return e.some(Boolean)?e.join("|"):void 0}function cn(n){try{return n?new URL(n).hostname:""}catch{return""}}var ln=()=>location.href.replace(/([?&])__lc_toolbar=[^&#]*&?/,"$1").replace(/[?&]$/,"");function dn(){let n=location.hash;return n.length>1?location.pathname+n.split("?")[0]:location.pathname}function mt(n,e,t=[],s=!1){let o={$current_url:ln(),$host:location.host,$pathname:s?dn():location.pathname,$referrer:document.referrer,$title:document.title,$screen_width:screen.width,$screen_height:screen.height,$viewport_width:window.innerWidth,$viewport_height:window.innerHeight,$browser_language:navigator.language,$timezone:Intl.DateTimeFormat().resolvedOptions().timeZone};if(navigator.maxTouchPoints>1&&(o.$touch_points=navigator.maxTouchPoints),n!=="$pageview")return{properties:o};let i=an(t);Object.assign(o,i);let a=e.$current_url??location.href,d=e.$referrer??document.referrer,p={$initial_referrer:d||"$direct",$initial_referring_domain:cn(d)||"$direct",$initial_current_url:a};for(let[h,m]of Object.entries(i))p[`$initial_${h.slice(1)}`]=m;return{properties:o,$set_once:p}}function yt(n,e,t=globalThis){e&&(t[typeof e=="string"?e:"lucida"]=n,typeof CustomEvent=="function"&&t.dispatchEvent?.(new CustomEvent("lucida:ready",{detail:n})))}var T=()=>{},ke=()=>Promise.resolve(),vt={isInternal:!1,hasOptedOut:()=>!1,hasOptedIn:()=>!1,consentStatus:()=>"pending",getConsentStatus:()=>"pending",getConsent:()=>({analytics:!1,replay:!1,marketing:!1}),getAllFlags:()=>({}),isFeatureEnabled:()=>!1,getFlagResult:n=>B(n,void 0,void 0,"not_found"),getReplayUrl:()=>"",onSessionId:()=>T,onFlags:()=>T,onIntervention:()=>T,onConsent:()=>T,flush:ke,shutdown:ke,reloadFlags:ke,loadToolbar:()=>Promise.resolve(!1),recommendations:n=>Promise.resolve({placement:n,strategy:"",items:[],shown:T,clicked:T})};function bt(n){return new Proxy(()=>{},{get:(e,t)=>{if(!(typeof t!="string"||t==="then"))return n&&Object.hasOwn(vt,t)?vt[t]:bt(!1)}})}var _t=()=>bt(!0);var St="_lcid";var un=(n,e)=>e.some(t=>{let s=t.replace(/^\./,"").toLowerCase();return n.toLowerCase()===s||n.toLowerCase().endsWith(`.${s}`)});function pn(n,e=Date.now()){let t=n.lastIndexOf("."),[s="",o]=n.slice(t+1).split("_",2),i=/^[0-9a-z]+$/.test(s)?parseInt(s,36):NaN,a=n.slice(0,t);if(t>0&&a.length<=200&&i<=e+5e3&&e-i<=12e4)return o&&/^[\w-]{1,64}$/.test(o)?{distinctId:a,sessionId:o}:{distinctId:a}}function wt(n){if(!n?.length)return;let e=new URL(location.href),t=e.searchParams.get(St);if(t!==null){e.searchParams.delete(St),history.replaceState(history.state,"",e.toString());try{if(document.referrer&&!un(new URL(document.referrer).hostname,n))return}catch{return}return pn(t)}}function kt(n,e=Date.now){let t=n.eventsPerSecond??10,s=n.burst??100,o=s,i=e();return()=>{let a=e();return o=Math.min(s,o+(a-i)/1e3*t),i=a,o<1?!1:(o-=1,!0)}}var xe="<masked>",fn=["password","passwd","pwd","pass","token","access_token","refresh_token","id_token","secret","client_secret","api_key","apikey","key","auth","authorization","code","otp","email","ssn"],gn=["$current_url","$referrer","$initial_referrer","$initial_current_url","$last_current_url"],xt=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function hn(n,e){let t=n,s=[...fn,...e.maskParams??[],...e.maskCampaignParams?[...W,...O]:[]];if(s.length){let o=t.indexOf("#"),i=o<0?t:t.slice(0,o),a=o<0?"":t.slice(o);t=i.replace(new RegExp(`([?&])(${s.map(xt).join("|")})=[^&]*`,"gi"),`$1$2=${xe}`)+a}return e.stripHash&&(t=t.replace(/#.*$/,"")),t}function Ct(n){let e=new RegExp(`^\\$(initial_|last_)?(${[...W,...O].map(xt).join("|")})$`),t=s=>{let o;if(n.maskCampaignParams)for(let[i,a]of Object.entries(s))typeof a=="string"&&e.test(i)?(o??={...s})[i]=xe:i==="$click_ids"&&a&&typeof a=="object"&&((o??={...s})[i]=Object.fromEntries(Object.keys(a).map(d=>[d,xe])));for(let i of gn){let a=(o??s)[i];if(typeof a!="string")continue;let d=hn(a,n);d!==a&&((o??={...s})[i]=d)}return o??s};return s=>({...s,properties:t(s.properties),...s.$set?{$set:t(s.$set)}:{},...s.$set_once?{$set_once:t(s.$set_once)}:{}})}function mn(n,e,t){let s=e;for(let o of n)try{let i=o(s);if(i==null)return null;if(typeof i!="object"||typeof i.event!="string")return t("beforeSend hook returned a non-event, dropping:",typeof i),null;s=i}catch(i){return t("beforeSend hook threw, dropping event:",i),null}return s}function yn(n,e=Math.random){return t=>n>=1?t:n<=0||e()>=n?null:{...t,properties:{...t.properties,$sample_rate:n}}}function vn(n){let e=new Set(n),t=s=>Object.fromEntries(Object.entries(s).filter(([o])=>!e.has(o)));return s=>({...s,properties:t(s.properties),...s.$set?{$set:t(s.$set)}:{},...s.$set_once?{$set_once:t(s.$set_once)}:{}})}var Ce="lc_person_identified",se="lc_pending_set_once",Pt=new Set(["$identify","$create_alias","$groupidentify"]),$t="$$client_ingestion_warning",bn=6e4,Pe=class{constructor(e,t){this.mode=e;this.storage=t;this.identified=t.get(Ce)==="1";try{this.pending=JSON.parse(t.get(se)??"{}")}catch{this.pending={}}}mode;storage;identified;pending;get blocksPersonWrites(){return this.mode==="never"}get isProfile(){return this.mode==="always"||this.mode==="identified_only"&&this.identified}markIdentified(){this.mode!=="identified_only"||this.identified||(this.identified=!0,this.storage.set(Ce,"1"))}personless(e){return this.mode==="always"?!1:(this.mode==="never"||!this.identified)&&!Pt.has(e)}stash(e){if(this.mode!=="identified_only"||!e)return;let t=Object.entries(e).filter(([s])=>!(s in this.pending));t.length&&(this.pending={...this.pending,...Object.fromEntries(t)},this.storage.set(se,JSON.stringify(this.pending)))}take(){if(!Object.keys(this.pending).length)return;let e=this.pending;return this.pending={},this.storage.remove(se),e}reset(){this.identified=!1,this.pending={},this.storage.remove(Ce),this.storage.remove(se)}};function _n(n,e){let t=e,s;if(n.person.personless(e.event)){n.person.stash(e.$set_once);let{$set:i,$set_once:a,$unset:d,...p}=e;t={...p,properties:{...e.properties,$process_person_profile:!1}}}else(s=n.person.take())&&(t={...e,$set_once:{...e.$set_once,...s}});let o=n.hooks.length?mn(n.hooks,t,n.log):t;return o&&n.limit&&!n.limit()&&(n.log("rate limited, dropped",o.event),n.onLimited?.(),o=null),!o&&s&&n.person.stash(s),o}function Sn(n){let e=n.beforeSend?Array.isArray(n.beforeSend)?n.beforeSend:[n.beforeSend]:[];return[Ct(n.urlPrivacy??{}),...n.propertyDenylist?.length?[vn(n.propertyDenylist)]:[],...n.sampleRate!==void 0?[yn(n.sampleRate)]:[],...e]}function It(n,e,t,s=Date.now){let o=new Pe(e.personProfiles??"always",n.storage),i,a,d=0,p=-1/0,h=()=>{d+=1,!(s()-p<bn)&&(p=s(),queueMicrotask(()=>{let m=d;d=0,n.capture($t,{$$client_ingestion_warning_message:`client rate limit dropped ${m} event(s)`,$dropped_count:m})}))};return n.setFilter(m=>(e.rateLimit!==i&&(i=e.rateLimit,a=i?kt(i):void 0),_n({hooks:Sn(e),person:o,limit:m.event===$t?void 0:a,log:t,onLimited:h},m))),o}var $e=class{m=new Map;get(e){return this.m.get(e)??null}set(e,t){this.m.set(e,t)}remove(e){this.m.delete(e)}},wn=365,kn=new Set("co.uk org.uk ac.uk gov.uk me.uk ltd.uk plc.uk net.uk com.au net.au org.au edu.au gov.au co.nz org.nz net.nz co.jp ne.jp or.jp ac.jp go.jp co.kr or.kr com.cn net.cn org.cn com.hk com.tw com.sg com.my co.in net.in org.in co.id co.th com.ph com.vn com.br net.br org.br com.ar com.mx com.co com.pe com.tr com.ua com.pl co.za co.il com.eg com.sa com.ng co.ke github.io gitlab.io vercel.app netlify.app herokuapp.com pages.dev workers.dev web.app firebaseapp.com azurewebsites.net cloudfront.net appspot.com onrender.com fly.dev glitch.me repl.co blogspot.com wordpress.com myshopify.com vercel.dev netlify.com surge.sh render.com railway.app koyeb.app deno.dev ngrok.io ngrok-free.app trycloudflare.com cloudfunctions.net run.app s3.amazonaws.com elasticbeanstalk.com azurestaticapps.net wixsite.com webflow.io framer.app bubbleapps.io".split(" ")),xn=new Set("co com net org edu gov gob go ac or ne ltd plc sch mil nom".split(" "));function Cn(n){let e=n.toLowerCase().split(".");for(let t=1;t<e.length-1;t++)if(kn.has(e.slice(t).join("."))||t===e.length-2&&e[t+1].length===2&&xn.has(e[t]))return e.slice(t-1).join(".")}function Pn(n=location.hostname){if(/^[\d.]+$/.test(n)||n.includes(":"))return;let e=n.split(".");for(let t=e.length-2;t>=0;t--){let s=e.slice(t).join(".");if(document.cookie=`__lc_probe=1; Domain=${s}; Path=/; Max-Age=10; SameSite=Lax`,document.cookie.includes("__lc_probe=1"))return document.cookie=`__lc_probe=; Domain=${s}; Path=/; Max-Age=0`,s}return Cn(n)}var oe=class{constructor(e={}){this.o=e}o;domain=null;attr(){if(this.domain===null)try{this.domain=this.o.domain??(this.o.crossSubdomain?Pn():void 0)}catch{this.domain=void 0}return this.domain?`; Domain=${this.domain}`:""}held=new Map;read(e){try{for(let t of document.cookie.split("; ")){let s=t.indexOf("=");if(t.slice(0,s)===e)return decodeURIComponent(t.slice(s+1))}}catch{}return null}get(e){return this.read(e)??this.held.get(e)??null}set(e,t){let s=this.o.secure??location.protocol==="https:"?"; Secure":"",o=Math.round((this.o.expiryDays??wn)*86400);try{document.cookie=`${e}=${encodeURIComponent(t)}; Max-Age=${o}; Path=/${this.attr()}; SameSite=Lax${s}`}catch{}this.read(e)===t?this.held.delete(e):this.held.set(e,t)}remove(e){this.held.delete(e);try{document.cookie=`${e}=; Max-Age=0; Path=/${this.attr()}; SameSite=Lax`}catch{}}},M=class{constructor(e="localStorage"){this.kind=e}kind;store(){try{return globalThis[this.kind]}catch{return}}get(e){try{return this.store()?.getItem(e)??null}catch{return null}}set(e,t){try{this.store()?.setItem(e,t)}catch{}}remove(e){try{this.store()?.removeItem(e)}catch{}}},Ie=class extends M{constructor(){super("localStorage")}},$n=["lc_identity","lc_session","lc_device_id","lc_consent","lc_person_identified"],Oe=class{constructor(e,t,s){this.cookie=e;this.local=t;this.cookieKeys=s}cookie;local;cookieKeys;get(e){let[t,s]=this.cookieKeys(e)?[this.cookie,this.local]:[this.local,this.cookie];return t.get(e)??s.get(e)}set(e,t){this.local.set(e,t),this.cookieKeys(e)?this.cookie.set(e,t):this.cookie.remove(e)}remove(e){this.local.remove(e),this.cookie.remove(e)}},re=class{constructor(e,t){this.inner=e;this.delayMs=t}inner;delayMs;pending=new Map;timer;get(e){return this.pending.has(e)?this.pending.get(e)??null:this.inner.get(e)}set(e,t){this.queue(e,t)}remove(e){this.queue(e,null)}queue(e,t){this.pending.set(e,t),this.timer??=setTimeout(()=>this.flush(),this.delayMs)}flush(){clearTimeout(this.timer),this.timer=void 0;for(let[e,t]of this.pending)t===null?this.inner.remove(e):this.inner.set(e,t);this.pending.clear()}},Ee=class{constructor(e,t){this.inner=e;this.suffix=t}inner;suffix;get(e){return this.inner.get(e+this.suffix)}set(e,t){this.inner.set(e+this.suffix,t)}remove(e){this.inner.remove(e+this.suffix)}},ie=n=>`_${n.replace(/\W/g,"").slice(-8)}`;function ae(n,e,t){if(n==="memory"||n==="none")return new $e;let s=ie(e),o=n==="cookie"?new oe(t):n==="localStorage+cookie"?new Oe(new oe(t),new Ie,i=>$n.some(a=>i===a+s)):new M(n);return new Ee(o,s)}function Ot(n,e,t){let s=ie(e),o=new Set;try{for(let i of document.cookie.split("; "))o.add(i.split("=")[0]);for(let i of[globalThis.localStorage,globalThis.sessionStorage])for(let a=0;a<i.length;a++)o.add(i.key(a))}catch{}for(let i of o)if(!(!i.startsWith("lc_")||!i.endsWith(s)||i===t+s)){n.remove(i.slice(0,-s.length));try{localStorage.removeItem(i),sessionStorage.removeItem(i)}catch{}}}async function In(n){if(!(typeof CompressionStream>"u"||typeof Response>"u"))try{let e=new Response(n).body?.pipeThrough(new CompressionStream("gzip"));return e?new Uint8Array(await new Response(e).arrayBuffer()):void 0}catch{return}}function Et(n,e={}){let t=e.compress??!0,s=(o,i)=>(e.onError?.({url:o,status:i}),{status:i});return{async send(o,i,a){if(a?.beacon&&!e.disableBeacon&&typeof navigator<"u"&&navigator.sendBeacon)return navigator.sendBeacon(o,new Blob([i],{type:"text/plain"}))?{status:200}:s(o,0);try{let d=t&&i.length>=1024?await In(i):void 0,p=await n(d?`${o}${o.includes("?")?"&":"?"}compression=gzip`:o,{method:"POST",body:d??i,headers:{...e.headers,"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",keepalive:(d?.length??i.length)<6e4});return p.status>=400?s(o,p.status):{status:p.status}}catch{return s(o,0)}}}}var Re={send:async()=>({status:200})};var On="lucida-browser",En="0.1.6",Ae="lc_internal",Rn=3e3,Rt="https://capture.lucidace.com",Te=n=>!!n&&typeof n=="object"&&Object.getPrototypeOf(n)===Object.prototype;function Me(n,e={},t=[]){if(typeof window>"u"||typeof navigator>"u")return _t();let s=!!e.debug||typeof location<"u"&&/[?&]__(lc|lucida)_debug=(1|true)/.test(location.search),o=(...r)=>{s&&console.debug("[lucida]",...r)},i=(e.apiHost??Rt).replace(/\/+$/,""),a=Object.fromEntries(Object.entries(e).map(([r,c])=>[r,Te(c)?{...c}:c]));a.apiHost=i;let d=e.extension??pt(),p=r=>d&&(r==="cookie"||r==="localStorage+cookie")?e.extensionPersistence??"localStorage":r,h=p(e.cookieless==="always"?"none":e.persistence??"cookie"),m=[i,...e.flagsApiHost?[e.flagsApiHost.replace(/\/+$/,"")]:[]],_=e.fetch??((...r)=>fetch(...r)),P=r=>ft(r,_,m,e.rewritePath),g=P(Re).fetch,v=e.consent?.respectDnt,b=navigator.globalPrivacyControl===!0,S=(e.respectDnt??v)===!0&&navigator.doNotTrack==="1"||(e.respectGpc??v)===!0&&b,je=e.blockBots!==!1&&typeof navigator<"u"&&it(navigator.userAgent??"",e.blockedUserAgents),k=!!e.disabled||je;je&&o("bot user agent: capture disabled");let ce,le=P(e.transport??Et(_,{headers:a.requestHeaders,onError:e.onRequestError,disableBeacon:e.disableBeacon})).transport;if(!e.transport&&e.offlineQueue!==!1&&h!=="memory"&&h!=="none"){let r=new $(new M(h==="sessionStorage"?"sessionStorage":"localStorage"),()=>l.hasConsent("analytics"));le=ce=ve(le,r,{key:`lc_offline${ie(n)}`,isOnline:()=>navigator.onLine!==!1})}let V=k?void 0:wt(e.crossDomains),de=ae(k?"memory":h,n,e.cookie),z=(e.storageWriteDelayMs??0)>0?new re(de,e.storageWriteDelayMs):void 0,De=V?.sessionId??e.bootstrap?.sessionId,ue,K=!1,Le,pe=[],l=new N({apiKey:n,apiHost:i,transport:k?Re:le,storage:z??de,...e.consentPersistence&&!k?{consentStorage:ae(p(e.consentPersistence),n,e.cookie)}:{},persistProperty:r=>!a.persistedProperties||a.persistedProperties.includes(r),...h==="none"?{cookieless:!0}:{},library:{name:On,version:En},consent:{...e.cookieless==="on_reject"?{cookielessOnReject:!0}:{},...e.consent,...!k&&(e.consent?.geo||e.consent?.mode!=="opt_in")?{awaitRemote:!0}:{},respectDnt:!0,dnt:S},queue:{...e.flushAt?{flushAt:e.flushAt}:{},...e.flushIntervalMs?{flushIntervalMs:e.flushIntervalMs}:{}},...V||e.bootstrap?.distinctId?{bootstrapDistinctId:V?.distinctId??e.bootstrap?.distinctId}:{},...e.bootstrap?.isIdentified&&!V?{bootstrapIdentified:!0}:{},session:{...e.session,...De?{bootstrapId:De}:{}},enrich:(r,c)=>{let u=mt(r,c,a.customCampaignParams,e.capturePageview==="hash");if(i!==Rt&&(u.properties={...u.properties,$lib_custom_api_host:i}),pe.length){let I=l.sessionId;for(let At of pe)u.properties={...u.properties,...At(I)}}let y=Le?.()??{},w=Object.keys(y);return w.length&&(u.properties={...u.properties,$click_ids:y},r==="$pageview"&&(u.$set_once={...Object.fromEntries(w.map(I=>[`$initial_${I}`,y[I]])),...u.$set_once},u.$set=Object.fromEntries(w.map(I=>[`$last_${I}`,y[I]])))),a.sendFeatureFlags!==!1&&r!=="$snapshot"&&ue&&(u.properties={...be(ue.all()),...u.properties}),K?{...u,properties:{...u.properties,$internal:!0}}:u},campaignKey:ht,log:o});K=l.storage.get(Ae)==="1",e.clickIds!==!1&&(Le=ct(l.storage,e.clickIds?.expiryDays));let x=It(l,a,o);e.bootstrap?.isIdentified&&x.markIdentified();let j=r=>x.blocksPersonWrites?(o(`personProfiles=never: ${r} ignored`),!0):!1;k||l.onChange(r=>{r!=="consent"||l.hasConsent("analytics")||l.consentStatus()!=="denied"||(z?.flush(),Ot(de,n,e.consent?.storageKey||Y))});let fe=new Set;l.onChange(r=>{r==="consent"&&[...fe].forEach(c=>c())});let Fe=[],E=[dt(o,e.nonce)],Ne=l.storage;if(e.flagPersistence&&!k){let r=new $(ae(p(e.flagPersistence),n,e.cookie),()=>l.hasConsent("analytics"));l.onChange(c=>{c==="consent"&&(l.hasConsent("analytics")?r.flushBuffered():r.discardBuffered())}),Ne=r}let G=r=>{if(k)return;if(l.hasConsent("analytics"))return r();let c=!1;l.onChange(u=>{!c&&u==="consent"&&l.hasConsent("analytics")&&(c=!0,r())})},Be,f={core:l,client:void 0,config:a,flagStorage:Ne,apiKey:n,log:o,fetch:g,onUnload:r=>{Fe.push(r)},whenConsented:G,onCapture:r=>l.onCaptured(r),eventExtras:pe,clickExtras:[],flagPersonProps:[],loadConfig:()=>Be??=new Promise(r=>G(()=>{g(`${i}/v1/config?api_key=${encodeURIComponent(n)}`).then(c=>c.ok?c.json():null).then(c=>(c&&l.applyRemote(c),c)).then(r,()=>r(null))}))},Ue=Promise.resolve();if(l.consent.resolving){let r=!1,c=g(`${i}/v1/config?api_key=${encodeURIComponent(n)}`,{credentials:"omit"}).then(u=>(r=u.status>=500,u.ok?u.json():null)).catch(()=>(r=!0,null));Be=c,Ue=new Promise(u=>{let y=setTimeout(()=>(l.resolveConsent("opt_in"),u()),Rn);c.then(w=>{clearTimeout(y),w?l.applyRemote(w):r?l.resolveConsent("opt_in"):l.applyRemote({}),u()})})}let qe=ye(l,{apiHost:i,apiKey:n,fetch:g,whenConsented:G,log:o,disabled:k});E.push(()=>qe.stop());let D={get distinctId(){return l.distinctId},capture:(r,c,u)=>{l.capture(r,c,u?.timestamp!==void 0?{timestamp:u.timestamp}:{})&&(u?.sendInstantly||u?.transport)&&l.flush(u.transport==="beacon"?{beacon:!0}:{})},identify:(r,c,u)=>{j("identify")||(x.markIdentified(),l.identify(r,c,u))},alias:(r,c)=>{j("alias")||(x.markIdentified(),l.alias(r,c))},reset:r=>{l.reset({resetDeviceId:!!r,reuseAnonymousId:!!e.reuseAnonymousId}),x.reset()},createPersonProfile:()=>{j("createPersonProfile")||x.isProfile||(x.markIdentified(),l.capture("$set",{}))},setConfig:r=>{let c=a;for(let[u,y]of Object.entries(r)){let w=c[u];Te(w)&&Te(y)?Object.assign(w,y):c[u]=y}"debug"in r&&(s=!!r.debug)},setPersonProperties:(r,c)=>{!r&&!c||j("setPersonProperties")||(x.markIdentified(),l.capture("$set",{},{...r?{$set:r}:{},...c?{$set_once:c}:{}}))},unsetPersonProperties:r=>{!r.length||j("unsetPersonProperties")||(x.markIdentified(),l.capture("$set",{},{$unset:r}))},getDistinctId:()=>l.distinctId,getSessionId:()=>l.sessionId,onSessionId:r=>l.onSessionId(c=>r(c)),getProperty:r=>l.getProperty(r),hasOptedOut:()=>l.consentStatus()==="denied",hasOptedIn:()=>l.consentStatus()==="granted",onConsent:r=>(fe.add(r),()=>{fe.delete(r)}),getReplayUrl:r=>{let u=`${(e.uiHost??i).replace(/\/+$/,"")}/replays/${encodeURIComponent(l.sessionId)}`,y=l.sessionStart;return!r?.withTimestamp||y===void 0?u:`${u}?t=${Math.max(0,Math.round((Date.now()-y)/1e3-(r.timestampLookBackSeconds??10)))}`},debug:(r=!0)=>{s=r},featureView:(r,c)=>{l.capture("$feature_view",{...c,$feature_flag:r},{$set:{[`$feature_view/${r}`]:!0}})},featureInteraction:(r,c)=>{l.capture("$feature_interaction",{...c,$feature_flag:r},{$set:{[`$feature_interaction/${r}`]:!0}})},updateFlags:(r,c,u)=>f.flags?.update(r,c,u?.merge??!0),register:r=>l.register(r),registerOnce:r=>l.registerOnce(r),unregister:r=>l.unregister(r),group:(r,c,u)=>{x.markIdentified(),l.group(r,c,u)},optIn:(r=["analytics","replay"])=>l.setConsent({analytics:r.includes("analytics"),replay:r.includes("replay"),marketing:r.includes("marketing")}),optOut:()=>l.optOut(),optOutInternal:(r=!0)=>{K=r,r?l.storage.set(Ae,"1"):l.storage.remove(Ae)},get isInternal(){return K},setConsent:r=>l.setConsent(r),getConsent:()=>l.getConsent(),getConsentStatus:r=>l.getConsentStatus(r),consentStatus:()=>l.consentStatus(),getFlag:r=>f.flags?.get(r),getFlagPayload:r=>f.flags?.payload(r),getFlagResult:(r,c)=>f.flags?.result(r,c)??B(r,void 0,void 0,"not_found"),getLayerParam:(r,c,u)=>f.flags?.layerParam(r,c)??u,isFeatureEnabled:r=>{let c=f.flags?.get(r);return c!==void 0&&c!==!1},onFlags:r=>f.flags?.onChange(r)??(()=>{}),onIntervention:r=>qe.on(r),reloadFlags:()=>f.flags?.reload()??Promise.resolve(),getAllFlags:()=>f.flags?.all()??{},overrideFlags:(r,c)=>f.flags?.override(r,c),setPersonPropertiesForFlags:(r,c)=>f.flags?.setPersonProperties(r,c),resetPersonPropertiesForFlags:()=>f.flags?.resetPersonProperties(),setGroupPropertiesForFlags:(r,c)=>f.flags?.setGroupProperties(r,c),resetGroupPropertiesForFlags:()=>f.flags?.resetGroupProperties(),setContext:(r,c,u)=>f.flags?.setContext(r,c,u),clearContext:r=>f.flags?.clearContext(r),guides:{showChangelog:()=>f.guides?.showChangelog()??0,show:r=>f.guides?.show(r)??!1,reset:r=>f.guides?.reset(r)},ai:{startConversation:r=>new q((c,u)=>D.capture(c,u),r,a.ai?.captureText===!0).start()},earlyAccess:{list:()=>f.earlyAccess?.list()??Promise.resolve([]),optIn:r=>f.earlyAccess?.optIn(r),optOut:r=>f.earlyAccess?.optOut(r)},replay:{start:r=>f.replay?.start(r)??Promise.resolve(),stop:()=>f.replay?.stop(),pause:()=>f.replay?.pause(),resume:()=>f.replay?.resume(),tag:r=>f.replay?.tag(r),isRecording:()=>f.replay?.isRecording()??!1},consent:{showBanner:r=>f.consentUi?.showBanner(r)??Promise.resolve(null),hideBanner:()=>f.consentUi?.hideBanner()},loadToolbar:r=>f.toolbar?.load(typeof r=="string"?r:r.token)??Promise.resolve(!1),activateExperiment:r=>f.experiments?.activate(r),recommendations:(r,c)=>f.recs?.get(r,c)??Promise.resolve({placement:r,strategy:"",items:[],shown(){},clicked(){}}),flush:()=>Ue.then(()=>l.flush()),shutdown:async()=>{for(let r of E)r();z?.flush(),await l.shutdown()}};if(f.client=D,!k){let r=()=>{for(let u of Fe)u();z?.flush(),l.flush({beacon:!0})};window.addEventListener("pagehide",r);let c=()=>{document.visibilityState==="hidden"&&l.flush({beacon:!0})};if(document.addEventListener("visibilitychange",c),E.push(()=>{window.removeEventListener("pagehide",r),document.removeEventListener("visibilitychange",c)}),ce){let u=()=>{ce.drain()};window.addEventListener("online",u),E.push(()=>window.removeEventListener("online",u)),G(u)}if(e.captureCspViolations){let u=typeof e.captureCspViolations=="object"?e.captureCspViolations:{};E.push(ut((y,w)=>{l.capture(y,w)},u))}for(let u of t){let y=u(f);y&&E.push(y)}ue=f.flags,t.length||f.loadConfig(),gt(f,D,i)}return yt(D,e.exposeGlobal),o("initialised",{apiHost:i,consent:l.getConsent()}),D}function Qs(n,e={}){return Me(n,e)}export{Me as createClient,Qs as init};
|
|
1
|
+
var J="lc_consent";function me(n,e,t){return e==="opt_in"?"opt_in":t==="opt_in"||t==="opt_out"||t==="cookieless"?t:e==="opt_out"?n:void 0}var he=["analytics","replay","marketing"],F=class{constructor(e){this.o=e;this.modeNow=e.mode??"opt_out",this.queueBeforeConsent=e.queueBeforeConsent??!1;let t=this.opens();this.state={analytics:t,replay:t,marketing:t},this.key=e.storageKey||J;let s=e.storage.get(this.key);if(s)try{let r=JSON.parse(s);for(let i of he)typeof r[i]=="boolean"&&(this.state[i]=r[i]);this.decided=he.some(i=>typeof r[i]=="boolean")}catch{}this.waiting=!!e.awaitRemote&&!this.decided,this.waiting&&(this.state={analytics:!1,replay:!1,marketing:!1})}o;modeNow;queueBeforeConsent;state;decided=!1;waiting;geoCookieless=!1;key;listeners=[];opens(){return this.modeNow==="opt_out"&&!(this.o.respectDnt&&this.o.dnt)}get mode(){return this.modeNow}get resolving(){return this.waiting}get anonymous(){return this.geoCookieless&&!this.decided}resolve(e){if(!this.waiting)return this.state.analytics;this.waiting=!1,(e==="opt_in"||e==="opt_out")&&(this.modeNow=e),this.geoCookieless=e==="cookieless";let t=!this.geoCookieless&&this.opens();return this.state={analytics:t,replay:t,marketing:t},t}get(){return{...this.state}}has(e){return this.state[e]}status(e="analytics"){return this.decided?this.state[e]?"granted":"denied":"pending"}get pending(){return this.waiting||this.modeNow==="opt_in"&&!this.state.analytics}set(e){let t=this.get();for(let s of he)e[s]!==void 0&&(this.state[s]=e[s]);this.decided=!0,this.waiting=!1,this.o.storage.set(this.key,JSON.stringify(this.state));for(let s of this.listeners)s(this.get(),t)}onChange(e){this.listeners.push(e)}},I=class{constructor(e,t){this.inner=e;this.allowed=t}inner;allowed;mem=new Map;get(e){return this.mem.has(e)?this.mem.get(e)??null:this.inner.get(e)}set(e,t){this.allowed()?this.inner.set(e,t):this.mem.set(e,t)}remove(e){this.allowed()?this.inner.remove(e):this.mem.set(e,null)}flushBuffered(){for(let[e,t]of this.mem)t===null?this.inner.remove(e):this.inner.set(e,t);this.mem.clear()}discardBuffered(){this.mem.clear()}};var Q=0,R=0;function Ve(n){let e=new Uint8Array(n),t=globalThis.crypto;if(t?.getRandomValues)t.getRandomValues(e);else for(let s=0;s<n;s++)e[s]=Math.floor(Math.random()*256);return e}function P(n=Date.now()){if(n>Q){Q=n;let i=Ve(2);R=((i[0]??0)<<8|(i[1]??0))&1023}else R++,R>4095&&(Q++,R=0);let e=Ve(8),t=new Uint8Array(16),s=Q;t[0]=Math.floor(s/2**40)&255,t[1]=Math.floor(s/2**32)&255,t[2]=Math.floor(s/2**24)&255,t[3]=Math.floor(s/2**16)&255,t[4]=Math.floor(s/2**8)&255,t[5]=s&255,t[6]=112|R>>8,t[7]=R&255,t[8]=128|(e[0]??0)&63;for(let i=1;i<8;i++)t[8+i]=e[i]??0;let r=Array.from(t,i=>i.toString(16).padStart(2,"0")).join("");return`${r.slice(0,8)}-${r.slice(8,12)}-${r.slice(12,16)}-${r.slice(16,20)}-${r.slice(20)}`}var ze="lc_identity",X=class{constructor(e,t,s=!1,r=!1){this.storage=e;this.cookieless=s;let i=e.get(ze),a;try{a=i?JSON.parse(i):void 0}catch{a=void 0}if(a?.distinct_id)this.s=a;else if(s)this.s={distinct_id:"",anon_id:"",identified:!1};else{let u=t??P();this.s={distinct_id:u,anon_id:u,identified:r&&!!t},this.save()}}storage;cookieless;s;save(){this.storage.set(ze,JSON.stringify(this.s))}get distinctId(){return this.s.distinct_id}get priorAnonId(){return this.s.identified&&this.s.anon_id&&this.s.anon_id!==this.s.distinct_id?this.s.anon_id:void 0}get isIdentified(){return this.s.identified}identify(e){if(!e||e===this.s.distinct_id)return e&&!this.s.identified&&(this.s.identified=!0,this.save()),{event:null};let t=this.s.distinct_id,s=!this.s.identified;return this.s={...this.s,distinct_id:e,identified:!0},this.save(),s&&t?{event:"$identify",anonDistinctId:t}:{event:"$identify"}}aliasProps(e,t){return{alias:e,distinct_id:t??this.s.distinct_id}}reset(e=!1){if(this.cookieless){this.s={distinct_id:"",anon_id:"",identified:!1};return}let t=e&&this.s.anon_id||P();this.s={distinct_id:t,anon_id:t,identified:!1},this.save()}};function N(n,e={}){let t=Math.min(e.maxMs??3e4,(e.baseMs??1e3)*2**n);return Math.round(t*(.5+.5*(e.random??Math.random)()))}function Ke(n){return n===0||n===408||n===429||n>=500}var Z=class{constructor(e){this.o=e;this.flushAt=e.flushAt??20,this.intervalMs=e.flushIntervalMs??5e3,this.maxSize=e.maxQueueSize??1e3,this.maxRetries=e.maxRetries??5,this.batchMax=Math.max(1,Math.min(e.maxBatchSize??1e3,1e3))}o;items=[];timer;attempt=0;inflight;closed=!1;warned404=!1;flushAt;intervalMs;maxSize;maxRetries;batchMax;get size(){return this.items.length}enqueue(e){this.closed||(this.items.push(e),this.items.length>this.maxSize&&this.o.onDrop?.(this.items.splice(0,this.items.length-this.maxSize),"queue_full"),this.items.length>=this.flushAt?this.flush():this.arm(this.intervalMs))}arm(e){this.timer===void 0&&(this.timer=setTimeout(()=>{this.timer=void 0,this.flush()},e))}disarm(){this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0}flush(e={}){if(this.disarm(),this.inflight)return this.inflight.then(()=>this.items.length?this.flush(e):void 0);if(!this.items.length)return Promise.resolve();let t=this.items.splice(0,this.batchMax),s=(this.o.clock??Date).now(),r=JSON.stringify({api_key:this.o.apiKey,batch:t,sent_at:new Date(s).toISOString()});this.o.log?.("send batch",t.length);let i=this.o.transport.send(this.o.url,r,e.beacon?{beacon:!0}:{}).then(a=>a,()=>({status:0,retryAfterMs:void 0})).then(a=>this.settle(t,a.status,!!e.beacon,a.retryAfterMs)).finally(()=>{this.inflight=void 0});return this.inflight=i,i}settle(e,t,s,r){if(t>=200&&t<300){this.attempt=0,this.items.length>=this.flushAt?this.flush():this.items.length&&this.arm(this.intervalMs);return}if(!Ke(t)||s||this.attempt>=this.maxRetries){t===404&&!this.warned404&&(this.warned404=!0,console.warn(`[lucida] ${this.o.url} returned 404, so events are being dropped. apiHost is probably wrong: use https://capture.lucidace.com (or your own capture host), not the app host.`)),this.o.onDrop?.(e,`status_${t}`),this.attempt=0;return}this.items.unshift(...e);let i=Math.max(N(this.attempt++,this.o.backoff),Math.min(r??0,6e4));this.o.log?.("retry in",i,"ms"),this.arm(i)}clear(){this.items=[],this.disarm()}async shutdown(){await this.flush(),this.closed=!0,this.disarm()}};var ye="lc_session";function Ge(n,e,t){return typeof n=="number"&&Number.isInteger(n)&&n>=e&&n<=t?n*6e4:void 0}var Dt=6e4,Lt=10*36e5,Ft=24*36e5,Nt=/^([0-9a-f]{8})-?([0-9a-f]{4})-7[0-9a-f]{3}-/i;function Bt(n,e){let t=Nt.exec(n);if(!t)return!0;let s=parseInt(t[1]+t[2],16);return s-e<=6e4&&e-s<=Ft}var ee=class{constructor(e,t={}){this.storage=e;this.o=t;this.idleMs=Math.min(Lt,Math.max(Dt,t.idleMs??30*6e4)),this.maxMs=t.maxMs??24*36e5,this.newOn=t.newOnEvents??[],this.clock=t.clock??{now:()=>Date.now()},this.bootstrapId=t.bootstrapId}storage;o;windowId=P();idleMs;maxMs;newOn;clock;bootstrapId;configure(e){this.o.idleMs===void 0&&(this.idleMs=Ge(e.session_idle_minutes,1,600)??this.idleMs),this.o.maxMs===void 0&&(this.maxMs=Ge(e.session_max_minutes,5,10080)??this.maxMs),this.o.newOnEvents===void 0&&Array.isArray(e.session_new_on_events)&&(this.newOn=e.session_new_on_events.filter(t=>typeof t=="string"&&t!==""))}read(){try{let e=this.storage.get(ye);return e?JSON.parse(e):void 0}catch{return}}touch(e,t){let s=this.clock.now(),r=this.read(),i=!!(r?.campaign&&e&&r.campaign!==e),a=t!==void 0&&this.newOn.includes(t),u=!r||Math.abs(s-r.last)>this.idleMs||Math.abs(s-r.start)>this.maxMs||i||a;return(u||!r)&&(r={id:!r&&this.bootstrapId&&Bt(this.bootstrapId,s)?this.bootstrapId:P(s),start:s,last:s}),this.bootstrapId=void 0,r.last=s,e&&(r.campaign=e),this.storage.set(ye,JSON.stringify(r)),{sessionId:r.id,windowId:this.windowId,isNew:u}}startedAt(){return this.read()?.start}reset(){this.storage.remove(ye)}};function Ye(n,e){let t=n.get(e);if(t)try{return JSON.parse(t)}catch{return}}var te=class{constructor(e,t="lc_props",s){this.storage=e;this.key=t;this.persist=s;this.p=Ye(e,t)??{}}storage;key;persist;p;save(){let e=this.persist;this.storage.set(this.key,JSON.stringify(e?Object.fromEntries(Object.entries(this.p).filter(([t])=>e(t))):this.p))}register(e){Object.assign(this.p,e),this.save()}registerOnce(e){for(let[t,s]of Object.entries(e))t in this.p||(this.p[t]=s);this.save()}unregister(e){delete this.p[e],this.save()}all(){return{...this.p}}clear(){this.p={},this.storage.remove(this.key)}},ne=class{constructor(e){this.storage=e;this.g=Ye(e,"lc_groups")??{}}storage;g;set(e,t){this.g[e]=t,this.storage.set("lc_groups",JSON.stringify(this.g))}all(){return Object.keys(this.g).length?{...this.g}:void 0}clear(){this.g={},this.storage.remove("lc_groups")}};function Ut(n,e){let t=new Date(n??e);return(Number.isNaN(t.getTime())?new Date(e):t).toISOString()}var B=class{constructor(e){this.c=e;this.clock=e.clock??{now:()=>Date.now()},this.consent=new F({...e.consent,storage:e.consentStorage??e.storage}),this.gated=new I(e.storage,()=>this.consent.has("analytics")),this.storage=this.gated,this.identity=new X(this.gated,e.bootstrapDistinctId,e.cookieless,e.bootstrapIdentified),this.session=new ee(this.gated,{clock:this.clock,...e.session}),this.props=new te(this.gated,void 0,e.persistProperty),this.groupState=new ne(this.gated),this.queue=new Z({transport:e.transport,url:`${e.apiHost.replace(/\/+$/,"")}/v1/batch`,apiKey:e.apiKey,clock:this.clock,...e.log?{log:e.log}:{},...e.onDrop?{onDrop:e.onDrop}:{},...e.queue})}c;consent;identity;session;queue;storage;gated;props;groupState;clock;device;pre=[];listeners=[];captureListeners=[];sessionListeners=[];lastSession="";filter;get anonDistinctId(){return this.identity.priorAnonId}get distinctId(){return this.identity.distinctId}get deviceId(){return this.c.cookieless?"":(this.device||(this.device=this.gated.get("lc_device_id")||P(),this.gated.set("lc_device_id",this.device)),this.device)}get groups(){return this.groupState.all()}get sessionId(){return this.touchSession().sessionId}touchSession(e){let t=this.session.touch(this.c.campaignKey?.(),e);if(t.sessionId!==this.lastSession){this.lastSession=t.sessionId;for(let s of this.sessionListeners)s(t.sessionId,t.windowId)}return t}onSessionId(e){return this.sessionListeners.push(e),()=>{this.sessionListeners.splice(this.sessionListeners.indexOf(e),1)}}get sessionStart(){return this.session.startedAt()}getProperty(e){return this.props.all()[e]}setFilter(e){this.filter=e}onChange(e){this.listeners.push(e)}onCaptured(e){this.captureListeners.push(e)}emit(e){for(let t of this.listeners)t(e)}consentStatus(){return this.consent.status()}get anonymousOnReject(){return!!this.c.consent?.cookielessOnReject&&this.consent.status()==="denied"}capture(e,t={},s={}){let r=this.consent.has("analytics"),i=!r&&(this.anonymousOnReject||this.consent.anonymous),a=this.consent.pending&&(this.consent.queueBeforeConsent||this.consent.resolving);if(!r&&!i&&!a){this.c.log?.("dropped (no consent)",e);return}if(i&&(e==="$identify"||e==="$create_alias")){this.c.log?.("withheld (declined, anonymous mode)",e);return}let u=this.touchSession(e),p=this.c.enrich?.(e,t),h=this.consent.status()!=="pending",m=i?{}:{...p?.$set,...s.$set,...e==="$consent_updated"&&h?{$consent:this.consent.get()}:{}},_=i?{}:{...p?.$set_once,...s.$set_once},$=this.groupState.all(),g=i?"":this.identity.distinctId,v={uuid:P(this.clock.now()),event:e,...g?{distinct_id:g}:{},timestamp:Ut(s.timestamp,this.clock.now()),properties:{...this.props.all(),...p?.properties,...t,$session_id:u.sessionId,$window_id:u.windowId,$lib:this.c.library.name,$lib_version:this.c.library.version,...h?{$consent:this.consent.get()}:{}},...Object.keys(m).length?{$set:m}:{},...Object.keys(_).length?{$set_once:_}:{},...!i&&s.$unset?.length?{$unset:s.$unset}:{},...$?{$groups:$}:{}},b=this.filter?this.filter(v):v;if(!b){this.c.log?.("dropped (policy)",e);return}this.c.log?.("capture",e,b),this.c.onCapture?.(b);for(let S of this.captureListeners)S(b);return r||i?this.queue.enqueue(b):this.pre.length<(this.c.queue?.maxQueueSize??1e3)&&this.pre.push(b),b}identify(e,t,s){let r=this.identity.identify(e);(r.event||t||s)&&this.capture("$identify",r.anonDistinctId?{$anon_distinct_id:r.anonDistinctId}:{},{...t?{$set:t}:{},...s?{$set_once:s}:{}}),this.emit("identify")}alias(e,t){this.capture("$create_alias",this.identity.aliasProps(e,t))}reset(e={}){this.identity.reset(e.reuseAnonymousId),e.resetDeviceId&&(this.device=void 0,this.gated.remove("lc_device_id")),this.props.clear(),this.groupState.clear(),this.session.reset(),this.lastSession="",this.emit("reset")}register(e){this.props.register(e)}registerOnce(e){this.props.registerOnce(e)}unregister(e){this.props.unregister(e)}group(e,t,s){this.groupState.set(e,t),this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:s??{}}),this.emit("group")}getConsent(){return this.consent.get()}getConsentStatus(e="analytics"){return this.consent.status(e)}hasConsent(e){return this.consent.has(e)}setConsent(e){let t=this.consent.has("analytics"),s=e.analytics??t;if(t&&!s&&(this.capture("$opt_out"),this.queue.flush()),!t&&s&&(this.anonymousOnReject||this.consent.anonymous)&&this.queue.flush(),this.consent.set(e),!t&&s){this.gated.flushBuffered();for(let r of this.pre.splice(0))this.queue.enqueue(r);this.capture("$opt_in")}else t&&!s&&this.queue.clear();s||(this.pre.length=0),this.emit("consent")}applyRemote(e){this.session.configure(e),this.resolveConsent(me(this.consent.mode,e.consent_mode,e.consent_default))}resolveConsent(e){if(!this.consent.resolving)return;let t=this.consent.resolve(e),s=this.pre.splice(0);if(t){this.gated.flushBuffered();for(let r of s)this.queue.enqueue(r)}else if(this.consent.anonymous){this.gated.discardBuffered();for(let r of s){if(r.event==="$identify"||r.event==="$create_alias")continue;let i={...r};delete i.distinct_id,delete i.$set,delete i.$set_once,delete i.$unset,this.queue.enqueue(i)}}else this.consent.queueBeforeConsent&&this.pre.push(...s);this.emit("consent")}optIn(){this.setConsent({analytics:!0,replay:!0,marketing:!0})}optOut(){this.setConsent({analytics:!1,replay:!1,marketing:!1})}flush(e){return this.queue.flush(e)}shutdown(){return this.queue.shutdown()}};function Je(n){let e="";return t=>{for(e+=t;;){let s=/\r?\n\r?\n/.exec(e);if(!s)return;let r=e.slice(0,s.index);e=e.slice(s.index+s[0].length);let i="message",a,u=[];for(let p of r.split(/\r?\n/)){if(p.startsWith(":"))continue;let h=p.indexOf(":"),[m,_]=h<0?[p,""]:[p.slice(0,h),p.slice(h+1).replace(/^ /,"")];m==="event"?i=_??"":m==="data"?u.push(_??""):m==="id"&&(a=_)}u.length&&n(a===void 0?{event:i,data:u.join(`
|
|
2
|
+
`)}:{event:i,data:u.join(`
|
|
3
|
+
`),id:a})}}}var se=class{constructor(e){this.o=e}o;ctl;stopped=!0;timer;cursor=0;gen=0;polling=!1;start(){this.stopped&&(this.stopped=!1,this.loop(++this.gen))}stop(){this.stopped=!0,this.gen++,this.ctl?.abort(),this.timer&&clearTimeout(this.timer)}restart(){let e=!this.stopped;this.stop(),this.cursor=0,e&&this.start()}live(e){return!this.stopped&&e===this.gen}deliver(e){if(e.seq>this.cursor){this.cursor=e.seq;try{this.o.onIntervention(e)}catch(t){this.o.log?.("onIntervention threw",t)}}}url(e){let t=`distinct_id=${encodeURIComponent(this.o.distinctId())}${this.cursor?`&cursor=${this.cursor}`:""}`;return`${this.o.apiHost}${e}?${t}`}sleep(e){return new Promise(t=>{this.timer=setTimeout(t,e),this.timer.unref?.()})}async loop(e){let t=0;for(;this.live(e);){let s;try{let r=await this.connectOnce(e);if(r==="gone")return this.stop();r==="poll"?(t=0,s=this.o.pollMs??15e3):(r==="streamed"&&(t=0),s=N(t++,this.o.backoff))}catch(r){this.live(e)&&this.o.log?.("intervention stream error",r),s=N(t++,this.o.backoff)}if(!this.live(e))return;await this.sleep(s)}}async connectOnce(e){if(this.polling)return this.pollOnce(e);this.ctl=new AbortController;let t={Authorization:`Bearer ${this.o.apiKey}`,Accept:"text/event-stream"},s=await this.o.fetch(this.url("/v1/interventions/stream"),{headers:t,signal:this.ctl.signal});if(s.status===404)return"gone";if(!s.ok)return"failed";let r=s.body;if(!r||typeof TextDecoderStream>"u")return this.ctl.abort(),this.polling=!0,this.pollOnce(e);let i=Je(u=>{if(!(u.event!=="intervention"||!this.live(e)))try{this.deliver(JSON.parse(u.data))}catch{this.o.log?.("bad intervention payload")}}),a=r.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:u,value:p}=await a.read();if(u)return"streamed";i(p)}}async pollOnce(e){this.ctl=new AbortController;let t=await this.o.fetch(this.url("/v1/interventions"),{headers:{Authorization:`Bearer ${this.o.apiKey}`},signal:this.ctl.signal});if(t.status===404)return"gone";if(!t.ok)return"failed";let s=await t.json();if(this.live(e))for(let r of s.data??[])this.deliver(r);return"poll"}};function ve(n,e){let t=new Set,{whenConsented:s,disabled:r,...i}=e,a=new se({...i,distinctId:()=>n.distinctId,onIntervention:p=>{for(let h of[...t])h(p)}}),u=!1;return n.onChange(p=>{u&&((p==="identify"||p==="reset")&&a.restart(),p==="consent"&&(n.hasConsent("analytics")?a.start():a.stop()))}),{on(p){return t.add(p),!u&&!r&&(u=!0,s(()=>a.start())),()=>{t.delete(p)}},stop:()=>a.stop()}}function be(n,e,t={}){let s=t.key??"lc_offline",r=t.maxBatches??50,i=t.maxBytes??1e6,a=t.isOnline??(()=>!0),u,p,h=()=>{try{let g=JSON.parse(e.get(s)??"[]");return Array.isArray(g)?g:[]}catch{return[]}},m=g=>{let v=g.reduce((b,S)=>b+S.body.length,0);for(;g.length>r||v>i&&g.length>1;)v-=g.shift().body.length;g.length?e.set(s,JSON.stringify(g)):e.remove(s)},_=g=>{m([...h(),...g]),u??=setTimeout(()=>{u=void 0,$.drain()},t.retryMs??3e4)},$={async send(g,v,b){if(!a())return _([{url:g,body:v}]),{status:200};let S=await n.send(g,v,b);return S.status!==0?S:(_([{url:g,body:v}]),{status:200})},drain(){return p??=(async()=>{let g=h();if(!g.length||!a())return;e.remove(s);let v=[];for(let[b,S]of g.entries())if((await n.send(S.url,S.body)).status===0){v.push(...g.slice(b));break}v.length&&_(v)})().finally(()=>{p=void 0}),p}};return $}function _e(n){let e=Object.keys(n);if(e.length===0)return{};let t={};for(let s of e)t[`$feature/${s}`]=n[s];return t.$active_feature_flags=e.filter(s=>n[s]!==!1).sort(),t}function U(n,e,t,s){return{key:n,value:e,enabled:e!==void 0&&e!==!1,...typeof e=="string"?{variant:e}:{},...t!==void 0?{payload:t}:{},reason:e===void 0?"not_found":s}}var A={started:"$ai_conversation_started",message:"$ai_message",feedback:"$ai_feedback",ended:"$ai_conversation_ended",outcome:"$ai_outcome"},qt=["resolved","unresolved","escalated","abandoned","error"],Ht=4e3,Wt=2e3,Xe=["wrong","useless","not helpful","unhelpful","doesn't work","does not work","didn't help","did not help","not what i asked","that's not it","stupid","terrible","awful","frustrating","frustrated","annoying","worst","hate","incorrect","nonsense","confusing","makes no sense","real person","human agent","talk to a human","speak to a human","wtf","ugh"],Ze=["thanks","thank you","great","perfect","awesome","helpful","that worked","works now","solved","exactly"],W=n=>Array.from(n),we=(n,e)=>W(n).slice(0,e).join(""),Vt=0xcbf29ce484222325n,zt=0x100000001b3n,Kt=0xffffffffffffffffn,Gt=new TextEncoder;function Yt(n){let e=Vt;for(let t of Gt.encode(n))e=(e^BigInt(t))*zt&Kt;return e}function et(n){let e=(n.toLowerCase().match(/[\p{L}\p{N}]+/gu)??[]).filter(r=>W(r).length>=2);if(!e.length)return;let t=new Array(64).fill(0);for(let r of e){let i=Yt(r);for(let a=0;a<64;a++)t[a]=(t[a]??0)+((i>>BigInt(a)&1n)===1n?1:-1)}let s=0n;for(let r=0;r<64;r++)(t[r]??0)>0&&(s|=1n<<BigInt(r));return s.toString(16).padStart(16,"0")}function tt(n){let t=` ${n.toLowerCase().replace(/’/g,"'").replace(/[.,!?;:]/g," ").replace(/\s+/g," ").trim()} `,s=0;for(let i of Xe)t.includes(` ${i} `)&&(s++,t=t.split(` ${i} `).join(" "));let r=Ze.filter(i=>t.includes(` ${i} `)).length;return s>r?-1:r>s?1:0}var nt=n=>W(n).filter(e=>e>="0"&&e<="9").map(Number);function Jt(n){let e=nt(n);if(e.length<13||e.length>19)return!1;let t=0;return e.reverse().forEach((s,r)=>t+=r%2===1?s>4?s*2-9:s*2:s),t%10===0}var Qe=String.raw`[\p{Alphabetic}\p{M}\p{Nd}\p{Pc}\p{Join_Control}]`,Qt=[[new RegExp(String.raw`(?<!${Qe})\p{Nd}(?:[ -]?\p{Nd}){12,18}(?!${Qe})`,"gu"),Jt],[/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}/g,()=>!0],[/\+?\p{Nd}[\p{Nd}\s().-]{7,}\p{Nd}/gu,Xt]];function Xt(n){let e=nt(n).length;return e>=10&&e<=15}var Zt=n=>W(n).map(e=>/\s/u.test(e)?e:"*").join("");function ke(n){let e=n;for(let[t,s]of Qt)e=e.replace(t,r=>s(r)?Zt(r):r);return e===n?void 0:e}function st(n){if(typeof n!="string")return;let e=n.toLowerCase();return/^[0-9a-f]{32}$/.test(e)?e:void 0}var rt=n=>typeof n=="string"&&qt.includes(n)?n:void 0,q=(n,e)=>typeof n=="string"&&n?we(n,e):void 0;function en(n,e,t){let s=we(e,t),r=ke(s);return r===void 0?{[n]:s}:{[n]:r,$ai_text_redacted:!0}}function ot(n,e,t,s){if(n!=="user"&&n!=="assistant")return;let r={$ai_role:n,$ai_message_index:t,$ai_text_length:W(e).length};if(n==="user"){let i=et(e);i!==void 0&&(r.$ai_text_hash=i),r.$ai_sentiment=tt(e)}return s?{...r,...en("$ai_text",e,Ht)}:r}function it(n,e){let t=n.value;if(n.kind==="thumbs"&&t!==1&&t!==-1||n.kind==="rating"&&!(Number.isInteger(t)&&t>=1&&t<=5)||n.kind!=="thumbs"&&n.kind!=="rating"&&n.kind!=="comment")return;let s={$ai_feedback_kind:n.kind};if(n.kind!=="comment"&&(s.$ai_feedback_value=t),n.comment&&e){let r=we(n.comment,Wt);s.$ai_feedback_comment=ke(r)??r}return n.messageIndex!==void 0&&(s.$ai_message_index=n.messageIndex),s}function Se(n,e){let t=rt(n),s=q(e,64);return{...t?{$ai_outcome:t}:{},...s?{$ai_resolution:s}:{}}}function tn(){let n=globalThis.crypto,e=new Uint8Array(16);if(n?.getRandomValues)n.getRandomValues(e);else for(let s=0;s<16;s++)e[s]=Math.floor(Math.random()*256);e[6]=(e[6]??0)&15|64,e[8]=(e[8]??0)&63|128;let t=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function at(n={}){let e={$ai_conversation_id:n.conversationId||tn()},t=(s,r)=>{r!==void 0&&(e[s]=r)};return t("$ai_agent_name",q(n.agentName,128)),t("$ai_agent_version",q(n.agentVersion,64)),t("$ai_topic",q(n.topic,128)),t("$ai_use_case",q(n.useCase,128)),t("$ai_trace_id",st(n.traceId)),e}var H=class{next=0;common;emit;captureText;constructor(e,t={},s=!1){this.emit=e,this.captureText=s,this.common=at(t)}get id(){return this.common.$ai_conversation_id}send(e,t){this.emit(e,{...this.common,...t})}start(){return this.send(A.started,{}),this}message(e,t,s={}){let r=s.index??this.next,i=ot(e,t,r,this.captureText);return i?(this.next=r+1,this.send(A.message,i),!0):!1}feedback(e){let t=it(e,this.captureText);return t?(this.send(A.feedback,t),!0):!1}end(e,t){this.send(A.ended,Se(e,t))}outcome(e,t){let s=Se(e,t);return s.$ai_outcome?(this.send(A.outcome,s),!0):!1}};var nn=["bot","crawl","spider","slurp","headlesschrome","phantomjs","puppeteer","playwright","lighthouse","pingdom","uptimerobot","facebookexternalhit","preview","scrapy","python-requests","go-http-client","cypress","lightpanda","hubspot","nessus","prerender","deepscan","screaming frog","sitebulb","turnitin","ia_archiver","chatgpt-user","app.hypefactors.com","google favicon","google web preview","-google","googleother","googleweblight","google-read-aloud","google-inspectiontool","google-hoteladsverifier","google-cloudvertexbot"];function ct(n,e=[]){let t=n.toLowerCase();return e.some(s=>s&&t.includes(s.toLowerCase()))?!0:nn.some(s=>t.includes(s))&&!/\bcubot\b/.test(t)}var O=["gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","igshid","msclkid","ttclid","li_fat_id","twclid","mc_cid","rdt_cid","epik","qclid","sccid","oppref","bfcid","irclid","_kx"],lt="lc_click_ids";function dt(n,e=90,t=Date.now){let s,r=()=>{try{return JSON.parse(n.get(lt)??"{}")}catch{return{}}};return()=>{let i=r();if(location.search!==s){s=location.search;let u=new URLSearchParams(s),p=!1;for(let h of O){let m=u.get(h);m&&(i[h]={v:m.slice(0,512),t:t()},p=!0)}p&&n.set(lt,JSON.stringify(i))}let a={};for(let u of O){let p=i[u];p&&t()-p.t<e*864e5&&(a[u]=p.v)}return a}}function sn(){return Array.from(document.querySelectorAll("meta[http-equiv]")).filter(n=>n.getAttribute("http-equiv")?.toLowerCase()==="content-security-policy").map(n=>n.getAttribute("content")??"")}function rn(n){let e=new Map;for(let s of n.split(";")){let[r,...i]=s.trim().toLowerCase().split(/\s+/);r&&!e.has(r)&&e.set(r,i)}let t=e.get("style-src-elem")??e.get("style-src")??e.get("default-src");return!!t&&!(t.includes("'unsafe-inline'")&&!t.some(s=>s.startsWith("'nonce-")||s.startsWith("'sha")))}function pt(n,e){if(typeof document>"u")return()=>{};!e&&sn().some(rn)&&n("CSP hint: this page's Content-Security-Policy blocks inline <style>; set the `nonce` option so guides and the experiment veil render (see the Content Security Policy help page)");let t=s=>{let r=s;/^style-src/.test(r.effectiveDirective??"")&&r.blockedURI==="inline"&&n(`CSP hint: an inline style was blocked by ${r.effectiveDirective}${e?" (check that `nonce` matches the page's nonce)":"; set the `nonce` option"}`)};return document.addEventListener("securitypolicyviolation",t),()=>document.removeEventListener("securitypolicyviolation",t)}var on=(n,e)=>n.slice(0,e);function ut(n){try{let e=new URL(n);return e.protocol==="data:"||e.protocol==="blob:"?e.protocol:e.origin+e.pathname}catch{return on(n,64)}}function ft(n,e={}){if(typeof document>"u")return()=>{};let t=e.maxPerPage??20,s=new Set,r=i=>{let a=i,u={$csp_directive:a.effectiveDirective??a.violatedDirective,$csp_blocked_uri:ut(a.blockedURI??""),$csp_source_file:a.sourceFile?ut(a.sourceFile):void 0,$csp_line:a.lineNumber||void 0,$csp_column:a.columnNumber||void 0,$csp_disposition:a.disposition},p=[u.$csp_directive,u.$csp_blocked_uri,u.$csp_source_file,u.$csp_line].join("|");s.has(p)||s.size>=t||(s.add(p),n("$csp_violation",Object.fromEntries(Object.entries(u).filter(([,h])=>h!==void 0))))};return document.addEventListener("securitypolicyviolation",r),()=>document.removeEventListener("securitypolicyviolation",r)}var an=["chrome-extension:","moz-extension:","safari-web-extension:","ms-browser-extension:"],gt=()=>typeof location<"u"&&an.includes(location.protocol);function cn(n,e,t){let s=e.find(a=>n.startsWith(`${a}/`));if(!s)return n;let r=n.slice(s.length),i=r.search(/[?#]/);return s+t(i<0?r:r.slice(0,i))+(i<0?"":r.slice(i))}function ht(n,e,t,s){if(!s)return{transport:n,fetch:e};let r=i=>cn(i,t,s);return{transport:{send:(i,a,u)=>n.send(r(i),a,u)},fetch:((i,a)=>e(typeof i=="string"?r(i):i instanceof URL?r(i.href):i,a))}}var ln="__LUCIDA_DEVTOOLS_HOOK__";function mt(n,e,t){let s=globalThis[ln];if(!(!s||typeof s.emit!="function"||typeof s.attach!="function")){n.onCapture(r=>{try{s.emit(r)}catch{}});try{s.attach({projectKeyPrefix:n.apiKey.slice(0,8),apiHost:t,distinctId:()=>e.distinctId,loadToolbar:r=>e.loadToolbar(r),startReplay:async()=>n.replay?(await n.replay.start(!0),n.replay.isRecording()):!1,replayUrl:()=>e.getReplayUrl()})}catch{}}}var V=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function dn(n){let e={},t=new URLSearchParams(location.search);for(let s of[...V,...O,...n]){let r=t.get(s);r&&(e[`$${s}`]=r)}return e}var yt=["ref","referral","via","aff"];function vt(n){let e=new URLSearchParams(location.search);for(let t of n){let s=e.get(t);if(s)return s.slice(0,256)}}function bt(){let n=new URLSearchParams(location.search),e=V.map(t=>n.get(t)??"");return e.some(Boolean)?e.join("|"):void 0}function un(n){try{return n?new URL(n).hostname:""}catch{return""}}var pn=()=>location.href.replace(/([?&])__lc_toolbar=[^&#]*&?/,"$1").replace(/[?&]$/,"");function fn(){let n=location.hash;return n.length>1?location.pathname+n.split("?")[0]:location.pathname}function _t(n,e,t=[],s=!1){let r={$current_url:pn(),$host:location.host,$pathname:s?fn():location.pathname,$referrer:document.referrer,$title:document.title,$screen_width:screen.width,$screen_height:screen.height,$viewport_width:window.innerWidth,$viewport_height:window.innerHeight,$browser_language:navigator.language,$timezone:Intl.DateTimeFormat().resolvedOptions().timeZone};if(navigator.maxTouchPoints>1&&(r.$touch_points=navigator.maxTouchPoints),n!=="$pageview")return{properties:r};let i=dn(t);Object.assign(r,i);let a=e.$current_url??location.href,u=e.$referrer??document.referrer,p={$initial_referrer:u||"$direct",$initial_referring_domain:un(u)||"$direct",$initial_current_url:a};for(let[h,m]of Object.entries(i))p[`$initial_${h.slice(1)}`]=m;return{properties:r,$set_once:p}}function St(n,e,t=globalThis){e&&(t[typeof e=="string"?e:"lucida"]=n,typeof CustomEvent=="function"&&t.dispatchEvent?.(new CustomEvent("lucida:ready",{detail:n})))}var T=()=>{},xe=()=>Promise.resolve(),wt={isInternal:!1,hasOptedOut:()=>!1,hasOptedIn:()=>!1,consentStatus:()=>"pending",getConsentStatus:()=>"pending",getConsent:()=>({analytics:!1,replay:!1,marketing:!1}),getAllFlags:()=>({}),isFeatureEnabled:()=>!1,getFlagResult:n=>U(n,void 0,void 0,"not_found"),getReplayUrl:()=>"",onSessionId:()=>T,onFlags:()=>T,onIntervention:()=>T,onConsent:()=>T,flush:xe,shutdown:xe,reloadFlags:xe,loadToolbar:()=>Promise.resolve(!1),recommendations:n=>Promise.resolve({placement:n,strategy:"",items:[],shown:T,clicked:T})};function kt(n){return new Proxy(()=>{},{get:(e,t)=>{if(!(typeof t!="string"||t==="then"))return n&&Object.hasOwn(wt,t)?wt[t]:kt(!1)}})}var xt=()=>kt(!0);var Ct="_lcid";var gn=(n,e)=>e.some(t=>{let s=t.replace(/^\./,"").toLowerCase();return n.toLowerCase()===s||n.toLowerCase().endsWith(`.${s}`)});function hn(n,e=Date.now()){let t=n.lastIndexOf("."),[s="",r]=n.slice(t+1).split("_",2),i=/^[0-9a-z]+$/.test(s)?parseInt(s,36):NaN,a=n.slice(0,t);if(t>0&&a.length<=200&&i<=e+5e3&&e-i<=12e4)return r&&/^[\w-]{1,64}$/.test(r)?{distinctId:a,sessionId:r}:{distinctId:a}}function Pt(n){if(!n?.length)return;let e=new URL(location.href),t=e.searchParams.get(Ct);if(t!==null){e.searchParams.delete(Ct),history.replaceState(history.state,"",e.toString());try{if(document.referrer&&!gn(new URL(document.referrer).hostname,n))return}catch{return}return hn(t)}}function $t(n,e=Date.now){let t=n.eventsPerSecond??10,s=n.burst??100,r=s,i=e();return()=>{let a=e();return r=Math.min(s,r+(a-i)/1e3*t),i=a,r<1?!1:(r-=1,!0)}}var Ce="<masked>",mn=["password","passwd","pwd","pass","token","access_token","refresh_token","id_token","secret","client_secret","api_key","apikey","key","auth","authorization","code","otp","email","ssn"],yn=["$current_url","$referrer","$initial_referrer","$initial_current_url","$last_current_url"],It=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function vn(n,e){let t=n,s=[...mn,...e.maskParams??[],...e.maskCampaignParams?[...V,...O]:[]];if(s.length){let r=t.indexOf("#"),i=r<0?t:t.slice(0,r),a=r<0?"":t.slice(r);t=i.replace(new RegExp(`([?&])(${s.map(It).join("|")})=[^&]*`,"gi"),`$1$2=${Ce}`)+a}return e.stripHash&&(t=t.replace(/#.*$/,"")),t}function Ot(n){let e=new RegExp(`^\\$(initial_|last_)?(${[...V,...O].map(It).join("|")})$`),t=s=>{let r;if(n.maskCampaignParams)for(let[i,a]of Object.entries(s))typeof a=="string"&&e.test(i)?(r??={...s})[i]=Ce:i==="$click_ids"&&a&&typeof a=="object"&&((r??={...s})[i]=Object.fromEntries(Object.keys(a).map(u=>[u,Ce])));for(let i of yn){let a=(r??s)[i];if(typeof a!="string")continue;let u=vn(a,n);u!==a&&((r??={...s})[i]=u)}return r??s};return s=>({...s,properties:t(s.properties),...s.$set?{$set:t(s.$set)}:{},...s.$set_once?{$set_once:t(s.$set_once)}:{}})}function bn(n,e,t){let s=e;for(let r of n)try{let i=r(s);if(i==null)return null;if(typeof i!="object"||typeof i.event!="string")return t("beforeSend hook returned a non-event, dropping:",typeof i),null;s=i}catch(i){return t("beforeSend hook threw, dropping event:",i),null}return s}function _n(n,e=Math.random){return t=>n>=1?t:n<=0||e()>=n?null:{...t,properties:{...t.properties,$sample_rate:n}}}function Sn(n){let e=new Set(n),t=s=>Object.fromEntries(Object.entries(s).filter(([r])=>!e.has(r)));return s=>({...s,properties:t(s.properties),...s.$set?{$set:t(s.$set)}:{},...s.$set_once?{$set_once:t(s.$set_once)}:{}})}var Pe="lc_person_identified",re="lc_pending_set_once",Et=new Set(["$identify","$create_alias","$groupidentify"]),Rt="$$client_ingestion_warning",wn=6e4,$e=class{constructor(e,t){this.mode=e;this.storage=t;this.identified=t.get(Pe)==="1";try{this.pending=JSON.parse(t.get(re)??"{}")}catch{this.pending={}}}mode;storage;identified;pending;get blocksPersonWrites(){return this.mode==="never"}get isProfile(){return this.mode==="always"||this.mode==="identified_only"&&this.identified}markIdentified(){this.mode!=="identified_only"||this.identified||(this.identified=!0,this.storage.set(Pe,"1"))}personless(e){return this.mode==="always"?!1:(this.mode==="never"||!this.identified)&&!Et.has(e)}stash(e){if(this.mode!=="identified_only"||!e)return;let t=Object.entries(e).filter(([s])=>!(s in this.pending));t.length&&(this.pending={...this.pending,...Object.fromEntries(t)},this.storage.set(re,JSON.stringify(this.pending)))}take(){if(!Object.keys(this.pending).length)return;let e=this.pending;return this.pending={},this.storage.remove(re),e}reset(){this.identified=!1,this.pending={},this.storage.remove(Pe),this.storage.remove(re)}};function kn(n,e){let t=e,s;if(n.person.personless(e.event)){n.person.stash(e.$set_once);let{$set:i,$set_once:a,$unset:u,...p}=e;t={...p,properties:{...e.properties,$process_person_profile:!1}}}else(s=n.person.take())&&(t={...e,$set_once:{...e.$set_once,...s}});let r=n.hooks.length?bn(n.hooks,t,n.log):t;return r&&n.limit&&!n.limit()&&(n.log("rate limited, dropped",r.event),n.onLimited?.(),r=null),!r&&s&&n.person.stash(s),r}function xn(n){let e=n.beforeSend?Array.isArray(n.beforeSend)?n.beforeSend:[n.beforeSend]:[];return[Ot(n.urlPrivacy??{}),...n.propertyDenylist?.length?[Sn(n.propertyDenylist)]:[],...n.sampleRate!==void 0?[_n(n.sampleRate)]:[],...e]}function At(n,e,t,s=Date.now){let r=new $e(e.personProfiles??"always",n.storage),i,a,u=0,p=-1/0,h=()=>{u+=1,!(s()-p<wn)&&(p=s(),queueMicrotask(()=>{let m=u;u=0,n.capture(Rt,{$$client_ingestion_warning_message:`client rate limit dropped ${m} event(s)`,$dropped_count:m})}))};return n.setFilter(m=>(e.rateLimit!==i&&(i=e.rateLimit,a=i?$t(i):void 0),kn({hooks:xn(e),person:r,limit:m.event===Rt?void 0:a,log:t,onLimited:h},m))),r}var Ie=class{m=new Map;get(e){return this.m.get(e)??null}set(e,t){this.m.set(e,t)}remove(e){this.m.delete(e)}},Cn=365,Pn=new Set("co.uk org.uk ac.uk gov.uk me.uk ltd.uk plc.uk net.uk com.au net.au org.au edu.au gov.au co.nz org.nz net.nz co.jp ne.jp or.jp ac.jp go.jp co.kr or.kr com.cn net.cn org.cn com.hk com.tw com.sg com.my co.in net.in org.in co.id co.th com.ph com.vn com.br net.br org.br com.ar com.mx com.co com.pe com.tr com.ua com.pl co.za co.il com.eg com.sa com.ng co.ke github.io gitlab.io vercel.app netlify.app herokuapp.com pages.dev workers.dev web.app firebaseapp.com azurewebsites.net cloudfront.net appspot.com onrender.com fly.dev glitch.me repl.co blogspot.com wordpress.com myshopify.com vercel.dev netlify.com surge.sh render.com railway.app koyeb.app deno.dev ngrok.io ngrok-free.app trycloudflare.com cloudfunctions.net run.app s3.amazonaws.com elasticbeanstalk.com azurestaticapps.net wixsite.com webflow.io framer.app bubbleapps.io".split(" ")),$n=new Set("co com net org edu gov gob go ac or ne ltd plc sch mil nom".split(" "));function In(n){let e=n.toLowerCase().split(".");for(let t=1;t<e.length-1;t++)if(Pn.has(e.slice(t).join("."))||t===e.length-2&&e[t+1].length===2&&$n.has(e[t]))return e.slice(t-1).join(".")}function On(n=location.hostname){if(/^[\d.]+$/.test(n)||n.includes(":"))return;let e=n.split(".");for(let t=e.length-2;t>=0;t--){let s=e.slice(t).join(".");if(document.cookie=`__lc_probe=1; Domain=${s}; Path=/; Max-Age=10; SameSite=Lax`,document.cookie.includes("__lc_probe=1"))return document.cookie=`__lc_probe=; Domain=${s}; Path=/; Max-Age=0`,s}return In(n)}var oe=class{constructor(e={}){this.o=e}o;domain=null;attr(){if(this.domain===null)try{this.domain=this.o.domain??(this.o.crossSubdomain?On():void 0)}catch{this.domain=void 0}return this.domain?`; Domain=${this.domain}`:""}held=new Map;read(e){try{for(let t of document.cookie.split("; ")){let s=t.indexOf("=");if(t.slice(0,s)===e)return decodeURIComponent(t.slice(s+1))}}catch{}return null}get(e){return this.read(e)??this.held.get(e)??null}set(e,t){let s=this.o.secure??location.protocol==="https:"?"; Secure":"",r=Math.round((this.o.expiryDays??Cn)*86400);try{document.cookie=`${e}=${encodeURIComponent(t)}; Max-Age=${r}; Path=/${this.attr()}; SameSite=Lax${s}`}catch{}this.read(e)===t?this.held.delete(e):this.held.set(e,t)}remove(e){this.held.delete(e);try{document.cookie=`${e}=; Max-Age=0; Path=/${this.attr()}; SameSite=Lax`}catch{}}},M=class{constructor(e="localStorage"){this.kind=e}kind;store(){try{return globalThis[this.kind]}catch{return}}get(e){try{return this.store()?.getItem(e)??null}catch{return null}}set(e,t){try{this.store()?.setItem(e,t)}catch{}}remove(e){try{this.store()?.removeItem(e)}catch{}}},Oe=class extends M{constructor(){super("localStorage")}},En=["lc_identity","lc_session","lc_device_id","lc_consent","lc_person_identified"],Ee=class{constructor(e,t,s){this.cookie=e;this.local=t;this.cookieKeys=s}cookie;local;cookieKeys;get(e){let[t,s]=this.cookieKeys(e)?[this.cookie,this.local]:[this.local,this.cookie];return t.get(e)??s.get(e)}set(e,t){this.local.set(e,t),this.cookieKeys(e)?this.cookie.set(e,t):this.cookie.remove(e)}remove(e){this.local.remove(e),this.cookie.remove(e)}},ie=class{constructor(e,t){this.inner=e;this.delayMs=t}inner;delayMs;pending=new Map;timer;get(e){return this.pending.has(e)?this.pending.get(e)??null:this.inner.get(e)}set(e,t){this.queue(e,t)}remove(e){this.queue(e,null)}queue(e,t){this.pending.set(e,t),this.timer??=setTimeout(()=>this.flush(),this.delayMs)}flush(){clearTimeout(this.timer),this.timer=void 0;for(let[e,t]of this.pending)t===null?this.inner.remove(e):this.inner.set(e,t);this.pending.clear()}},Re=class{constructor(e,t){this.inner=e;this.suffix=t}inner;suffix;get(e){return this.inner.get(e+this.suffix)}set(e,t){this.inner.set(e+this.suffix,t)}remove(e){this.inner.remove(e+this.suffix)}},ae=n=>`_${n.replace(/\W/g,"").slice(-8)}`;function ce(n,e,t){if(n==="memory"||n==="none")return new Ie;let s=ae(e),r=n==="cookie"?new oe(t):n==="localStorage+cookie"?new Ee(new oe(t),new Oe,i=>En.some(a=>i===a+s)):new M(n);return new Re(r,s)}function Tt(n,e,t){let s=ae(e),r=new Set;try{for(let i of document.cookie.split("; "))r.add(i.split("=")[0]);for(let i of[globalThis.localStorage,globalThis.sessionStorage])for(let a=0;a<i.length;a++)r.add(i.key(a))}catch{}for(let i of r)if(!(!i.startsWith("lc_")||!i.endsWith(s)||i===t+s)){n.remove(i.slice(0,-s.length));try{localStorage.removeItem(i),sessionStorage.removeItem(i)}catch{}}}async function Rn(n){if(!(typeof CompressionStream>"u"||typeof Response>"u"))try{let e=new Response(n).body?.pipeThrough(new CompressionStream("gzip"));return e?new Uint8Array(await new Response(e).arrayBuffer()):void 0}catch{return}}function Mt(n,e={}){let t=e.compress??!0,s=(r,i)=>(e.onError?.({url:r,status:i}),{status:i});return{async send(r,i,a){if(a?.beacon&&!e.disableBeacon&&typeof navigator<"u"&&navigator.sendBeacon)return navigator.sendBeacon(r,new Blob([i],{type:"text/plain"}))?{status:200}:s(r,0);try{let u=t&&i.length>=1024?await Rn(i):void 0,p=await n(u?`${r}${r.includes("?")?"&":"?"}compression=gzip`:r,{method:"POST",body:u??i,headers:{...e.headers,"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",keepalive:(u?.length??i.length)<6e4});return p.status>=400?s(r,p.status):{status:p.status}}catch{return s(r,0)}}}}var Ae={send:async()=>({status:200})};var An="lucida-browser",Tn="0.1.8",Te="lc_internal",Mn=3e3,jt="https://capture.lucidace.com",Me=n=>!!n&&typeof n=="object"&&Object.getPrototypeOf(n)===Object.prototype;function je(n,e={},t=[]){if(typeof window>"u"||typeof navigator>"u")return xt();let s=!!e.debug||typeof location<"u"&&/[?&]__(lc|lucida)_debug=(1|true)/.test(location.search),r=(...o)=>{s&&console.debug("[lucida]",...o)},i=(e.apiHost??jt).replace(/\/+$/,""),a=Object.fromEntries(Object.entries(e).map(([o,c])=>[o,Me(c)?{...c}:c]));a.apiHost=i;let u=e.extension??gt(),p=o=>u&&(o==="cookie"||o==="localStorage+cookie")?e.extensionPersistence??"localStorage":o,h=p(e.cookieless==="always"?"none":e.persistence??"cookie"),m=[i,...e.flagsApiHost?[e.flagsApiHost.replace(/\/+$/,"")]:[]],_=e.fetch??((...o)=>fetch(...o)),$=o=>ht(o,_,m,e.rewritePath),g=$(Ae).fetch,v=e.consent?.respectDnt,b=navigator.globalPrivacyControl===!0,S=(e.respectDnt??v)===!0&&navigator.doNotTrack==="1"||(e.respectGpc??v)===!0&&b,De=e.blockBots!==!1&&typeof navigator<"u"&&ct(navigator.userAgent??"",e.blockedUserAgents),k=!!e.disabled||De;De&&r("bot user agent: capture disabled");let le,de=$(e.transport??Mt(_,{headers:a.requestHeaders,onError:e.onRequestError,disableBeacon:e.disableBeacon})).transport;if(!e.transport&&e.offlineQueue!==!1&&h!=="memory"&&h!=="none"){let o=new I(new M(h==="sessionStorage"?"sessionStorage":"localStorage"),()=>l.hasConsent("analytics"));de=le=be(de,o,{key:`lc_offline${ae(n)}`,isOnline:()=>navigator.onLine!==!1})}let z=k?void 0:Pt(e.crossDomains),ue=ce(k?"memory":h,n,e.cookie),K=(e.storageWriteDelayMs??0)>0?new ie(ue,e.storageWriteDelayMs):void 0,Le=z?.sessionId??e.bootstrap?.sessionId,pe,G=!1,Fe,Ne,fe=[],l=new B({apiKey:n,apiHost:i,transport:k?Ae:de,storage:K??ue,...e.consentPersistence&&!k?{consentStorage:ce(p(e.consentPersistence),n,e.cookie)}:{},persistProperty:o=>!a.persistedProperties||a.persistedProperties.includes(o),...h==="none"?{cookieless:!0}:{},library:{name:An,version:Tn},consent:{...e.cookieless==="on_reject"?{cookielessOnReject:!0}:{},...e.consent,...!k&&(e.consent?.geo||e.consent?.mode!=="opt_in")?{awaitRemote:!0}:{},respectDnt:!0,dnt:S},queue:{...e.flushAt?{flushAt:e.flushAt}:{},...e.flushIntervalMs?{flushIntervalMs:e.flushIntervalMs}:{}},...z||e.bootstrap?.distinctId?{bootstrapDistinctId:z?.distinctId??e.bootstrap?.distinctId}:{},...e.bootstrap?.isIdentified&&!z?{bootstrapIdentified:!0}:{},session:{...e.session,...Le?{bootstrapId:Le}:{}},enrich:(o,c)=>{let d=_t(o,c,a.customCampaignParams,e.capturePageview==="hash");if(i!==jt&&(d.properties={...d.properties,$lib_custom_api_host:i}),fe.length){let C=l.sessionId;for(let L of fe)d.properties={...d.properties,...L(C)}}if(o==="$pageview"){let C=l.sessionId;if(C!==Fe){Fe=C;let L=vt(e.referralParams??yt);L&&(d.properties={...d.properties,$referral_code:L},d.$set_once={...d.$set_once,initial_referral_code:L})}}let y=Ne?.()??{},w=Object.keys(y);return w.length&&(d.properties={...d.properties,$click_ids:y},o==="$pageview"&&(d.$set_once={...Object.fromEntries(w.map(C=>[`$initial_${C}`,y[C]])),...d.$set_once},d.$set=Object.fromEntries(w.map(C=>[`$last_${C}`,y[C]])))),a.sendFeatureFlags!==!1&&o!=="$snapshot"&&pe&&(d.properties={..._e(pe.all()),...d.properties}),G?{...d,properties:{...d.properties,$internal:!0}}:d},campaignKey:bt,log:r});G=l.storage.get(Te)==="1",e.clickIds!==!1&&(Ne=dt(l.storage,e.clickIds?.expiryDays));let x=At(l,a,r);e.bootstrap?.isIdentified&&x.markIdentified();let j=o=>x.blocksPersonWrites?(r(`personProfiles=never: ${o} ignored`),!0):!1;k||l.onChange(o=>{o!=="consent"||l.hasConsent("analytics")||l.consentStatus()!=="denied"||(K?.flush(),Tt(ue,n,e.consent?.storageKey||J))});let ge=new Set;l.onChange(o=>{o==="consent"&&[...ge].forEach(c=>c())});let Be=[],E=[pt(r,e.nonce)],Ue=l.storage;if(e.flagPersistence&&!k){let o=new I(ce(p(e.flagPersistence),n,e.cookie),()=>l.hasConsent("analytics"));l.onChange(c=>{c==="consent"&&(l.hasConsent("analytics")?o.flushBuffered():o.discardBuffered())}),Ue=o}let Y=o=>{if(k)return;if(l.hasConsent("analytics"))return o();let c=!1;l.onChange(d=>{!c&&d==="consent"&&l.hasConsent("analytics")&&(c=!0,o())})},qe,f={core:l,client:void 0,config:a,flagStorage:Ue,apiKey:n,log:r,fetch:g,onUnload:o=>{Be.push(o)},whenConsented:Y,onCapture:o=>l.onCaptured(o),eventExtras:fe,clickExtras:[],flagPersonProps:[],loadConfig:()=>qe??=new Promise(o=>Y(()=>{g(`${i}/v1/config?api_key=${encodeURIComponent(n)}`).then(c=>c.ok?c.json():null).then(c=>(c&&l.applyRemote(c),c)).then(o,()=>o(null))}))},He=Promise.resolve();if(l.consent.resolving){let o=!1,c=g(`${i}/v1/config?api_key=${encodeURIComponent(n)}`,{credentials:"omit"}).then(d=>(o=d.status>=500,d.ok?d.json():null)).catch(()=>(o=!0,null));qe=c,He=new Promise(d=>{let y=setTimeout(()=>(l.resolveConsent("opt_in"),d()),Mn);c.then(w=>{clearTimeout(y),w?l.applyRemote(w):o?l.resolveConsent("opt_in"):l.applyRemote({}),d()})})}let We=ve(l,{apiHost:i,apiKey:n,fetch:g,whenConsented:Y,log:r,disabled:k});E.push(()=>We.stop());let D={get distinctId(){return l.distinctId},capture:(o,c,d)=>{l.capture(o,c,d?.timestamp!==void 0?{timestamp:d.timestamp}:{})&&(d?.sendInstantly||d?.transport)&&l.flush(d.transport==="beacon"?{beacon:!0}:{})},identify:(o,c,d)=>{j("identify")||(x.markIdentified(),l.identify(o,c,d))},alias:(o,c)=>{j("alias")||(x.markIdentified(),l.alias(o,c))},reset:o=>{l.reset({resetDeviceId:!!o,reuseAnonymousId:!!e.reuseAnonymousId}),x.reset()},createPersonProfile:()=>{j("createPersonProfile")||x.isProfile||(x.markIdentified(),l.capture("$set",{}))},setConfig:o=>{let c=a;for(let[d,y]of Object.entries(o)){let w=c[d];Me(w)&&Me(y)?Object.assign(w,y):c[d]=y}"debug"in o&&(s=!!o.debug)},setPersonProperties:(o,c)=>{!o&&!c||j("setPersonProperties")||(x.markIdentified(),l.capture("$set",{},{...o?{$set:o}:{},...c?{$set_once:c}:{}}))},unsetPersonProperties:o=>{!o.length||j("unsetPersonProperties")||(x.markIdentified(),l.capture("$set",{},{$unset:o}))},getDistinctId:()=>l.distinctId,getSessionId:()=>l.sessionId,onSessionId:o=>l.onSessionId(c=>o(c)),getProperty:o=>l.getProperty(o),hasOptedOut:()=>l.consentStatus()==="denied",hasOptedIn:()=>l.consentStatus()==="granted",onConsent:o=>(ge.add(o),()=>{ge.delete(o)}),getReplayUrl:o=>{let d=`${(e.uiHost??i).replace(/\/+$/,"")}/replays/${encodeURIComponent(l.sessionId)}`,y=l.sessionStart;return!o?.withTimestamp||y===void 0?d:`${d}?t=${Math.max(0,Math.round((Date.now()-y)/1e3-(o.timestampLookBackSeconds??10)))}`},debug:(o=!0)=>{s=o},featureView:(o,c)=>{l.capture("$feature_view",{...c,$feature_flag:o},{$set:{[`$feature_view/${o}`]:!0}})},featureInteraction:(o,c)=>{l.capture("$feature_interaction",{...c,$feature_flag:o},{$set:{[`$feature_interaction/${o}`]:!0}})},updateFlags:(o,c,d)=>f.flags?.update(o,c,d?.merge??!0),register:o=>l.register(o),registerOnce:o=>l.registerOnce(o),unregister:o=>l.unregister(o),group:(o,c,d)=>{x.markIdentified(),l.group(o,c,d)},optIn:(o=["analytics","replay"])=>l.setConsent({analytics:o.includes("analytics"),replay:o.includes("replay"),marketing:o.includes("marketing")}),optOut:()=>l.optOut(),optOutInternal:(o=!0)=>{G=o,o?l.storage.set(Te,"1"):l.storage.remove(Te)},get isInternal(){return G},setConsent:o=>l.setConsent(o),getConsent:()=>l.getConsent(),getConsentStatus:o=>l.getConsentStatus(o),consentStatus:()=>l.consentStatus(),getFlag:o=>f.flags?.get(o),getFlagPayload:o=>f.flags?.payload(o),getFlagResult:(o,c)=>f.flags?.result(o,c)??U(o,void 0,void 0,"not_found"),getLayerParam:(o,c,d)=>f.flags?.layerParam(o,c)??d,isFeatureEnabled:o=>{let c=f.flags?.get(o);return c!==void 0&&c!==!1},onFlags:o=>f.flags?.onChange(o)??(()=>{}),onIntervention:o=>We.on(o),reloadFlags:()=>f.flags?.reload()??Promise.resolve(),getAllFlags:()=>f.flags?.all()??{},overrideFlags:(o,c)=>f.flags?.override(o,c),setPersonPropertiesForFlags:(o,c)=>f.flags?.setPersonProperties(o,c),resetPersonPropertiesForFlags:()=>f.flags?.resetPersonProperties(),setGroupPropertiesForFlags:(o,c)=>f.flags?.setGroupProperties(o,c),resetGroupPropertiesForFlags:()=>f.flags?.resetGroupProperties(),setContext:(o,c,d)=>f.flags?.setContext(o,c,d),clearContext:o=>f.flags?.clearContext(o),guides:{showChangelog:()=>f.guides?.showChangelog()??0,show:o=>f.guides?.show(o)??!1,reset:o=>f.guides?.reset(o)},ai:{startConversation:o=>new H((c,d)=>D.capture(c,d),o,a.ai?.captureText===!0).start()},earlyAccess:{list:()=>f.earlyAccess?.list()??Promise.resolve([]),optIn:o=>f.earlyAccess?.optIn(o),optOut:o=>f.earlyAccess?.optOut(o)},replay:{start:o=>f.replay?.start(o)??Promise.resolve(),stop:()=>f.replay?.stop(),pause:()=>f.replay?.pause(),resume:()=>f.replay?.resume(),tag:o=>f.replay?.tag(o),isRecording:()=>f.replay?.isRecording()??!1},consent:{showBanner:o=>f.consentUi?.showBanner(o)??Promise.resolve(null),hideBanner:()=>f.consentUi?.hideBanner()},loadToolbar:o=>f.toolbar?.load(typeof o=="string"?o:o.token)??Promise.resolve(!1),activateExperiment:o=>f.experiments?.activate(o),recommendations:(o,c)=>f.recs?.get(o,c)??Promise.resolve({placement:o,strategy:"",items:[],shown(){},clicked(){}}),flush:()=>He.then(()=>l.flush()),shutdown:async()=>{for(let o of E)o();K?.flush(),await l.shutdown()}};if(f.client=D,!k){let o=()=>{for(let d of Be)d();K?.flush(),l.flush({beacon:!0})};window.addEventListener("pagehide",o);let c=()=>{document.visibilityState==="hidden"&&l.flush({beacon:!0})};if(document.addEventListener("visibilitychange",c),E.push(()=>{window.removeEventListener("pagehide",o),document.removeEventListener("visibilitychange",c)}),le){let d=()=>{le.drain()};window.addEventListener("online",d),E.push(()=>window.removeEventListener("online",d)),Y(d)}if(e.captureCspViolations){let d=typeof e.captureCspViolations=="object"?e.captureCspViolations:{};E.push(ft((y,w)=>{l.capture(y,w)},d))}for(let d of t){let y=d(f);y&&E.push(y)}pe=f.flags,t.length||f.loadConfig(),mt(f,D,i)}return St(D,e.exposeGlobal),r("initialised",{apiHost:i,consent:l.getConsent()}),D}function er(n,e={}){return je(n,e)}export{je as createClient,er as init};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function g(n){let s=window.fetch;window.fetch=function(i,c){let f=i instanceof Request?i.url:String(i),t=new Headers(c?.headers??(i instanceof Request?i.headers:void 0)),r=[...t.entries()].join("|");return n(f,t),[...t.entries()].join("|")===r?s.call(this,i,c):s.call(this,i,{...c,headers:t})};let e=XMLHttpRequest.prototype,{open:o,send:a}=e,d=new WeakMap;return e.open=function(i,c,...f){return d.set(this,String(c)),o.call(this,i,c,...f)},e.send=function(i){let c=d.get(this);if(c){let f=new Headers;n(c,f),f.forEach((t,r)=>this.setRequestHeader(r,t))}return a.call(this,i)},()=>{window.fetch=s,e.open=o,e.send=a}}var h={good:0,"needs-improvement":1,poor:2},m=["good","needs-improvement","poor"],v={LCP:"lcp_ms",INP:"inp_ms",CLS:"cls",FCP:"fcp_ms",TTFB:"ttfb_ms"};function _(n,s){let e=()=>n.config.watchtower?.client??globalThis.watchtower,o,a=()=>{let d=e();o||typeof d?.on!="function"||(o=s(d))};return a(),window.addEventListener("watchtower:ready",a),()=>(window.removeEventListener("watchtower:ready",a),o?.())}function w(n){let s,e=!1;return n.whenConsented(()=>{e||(s=_(n,o=>L(n,o)))}),()=>(e=!0,s?.())}function L(n,s){let e=new Map,o=new Set,a=t=>{let r=e.get(t);e.delete(t),!(!r||o.has(t))&&(o.add(t),n.client.capture("$web_vitals",{...r.props,rating_worst:m[r.worst]}))},d=t=>{n.client.capture("$exception_seen",{wt_event_id:t.event_id,wt_trace_id:t.trace_id,message:String(t.message??"").slice(0,300),handled:t.handled,...t.issue_id?{wt_issue_id:t.issue_id}:{}})},i=t=>{let r=v[t.name];if(!r||o.has(t.navigation_id))return;for(let p of[...e.keys()])p!==t.navigation_id&&a(p);let u=e.get(t.navigation_id)??{props:{$current_url:t.url},worst:0,final:new Set};e.set(t.navigation_id,u),u.props[r]=t.value,u.worst=Math.max(u.worst,h[t.rating]??0),t.final&&u.final.add(t.name),u.final.size===5&&a(t.navigation_id)},c=t=>r=>{try{t(r)}catch{}},f=[s.on?.("error",c(d)),s.on?.("vital",c(i))];return n.onUnload(()=>[...e.keys()].forEach(a)),()=>f.forEach(t=>t?.())}var l="lucida.session_id";function R(n,s){return[...(n??"").split(",").map(o=>o.trim()).filter(o=>o&&!o.startsWith(`${l}=`)),`${l}=${encodeURIComponent(s)}`].join(",")}function y(n,s=[]){let e;try{e=new URL(n,location.href)}catch{return!1}return e.origin===location.origin||s.some(o=>typeof o=="string"?e.origin===o:o.test(e.href))}var S=n=>{let s=n.config.watchtower,{core:e}=n,o=k(n),a=w(n),d=()=>(o?.(),a());if(!s?.correlate)return d;let i=e.sessionId;n.onCapture(t=>i=String(t.properties.$session_id??i));let c=t=>e.hasConsent("analytics")&&!t.startsWith(n.config.apiHost)&&y(t,s.origins),f=g((t,r)=>{c(t)&&r.set("baggage",R(r.get("baggage"),i))});return()=>(f(),d())};function k(n){let s=n.config.watchtower?.client??globalThis.watchtower;if(typeof s?.setAttribute!="function")return;let{core:e}=n,o=a=>{e.hasConsent("analytics")&&s.setAttribute(l,a)};return n.whenConsented(()=>o(e.sessionId)),e.onSessionId(o)}export{y as correlatable,S as correlate,k as stampSession,R as withBaggage};
|
package/dist/static/v0/guides.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as I}from"./chunk-AWIQCFGN.js";import{a as ee,c as Ge,d as $e,e as C,f as Ee,h as te,i as ne,k as A}from"./chunk-FUE3SDQU.js";function ie(t,i){let n=2166136261;for(let s of`${i}:${t}`)n=Math.imul(n^s.codePointAt(0),16777619);return n^=n>>>16,n=Math.imul(n,2246822507),n^=n>>>13,n=Math.imul(n,3266489909),n^=n>>>16,(n>>>0)/2**32}function oe(t,i,n){let s=t.conditions.ab_group;if(!s)return t;let r=i.filter(o=>o.conditions.ab_group===s).sort((o,a)=>o.id<a.id?-1:1),u=r.reduce((o,a)=>o+(a.conditions.ab_weight??1),0),c=ie(n,`ab:${s}`)*u;for(let o of r)if(c-=o.conditions.ab_weight??1,c<0)return o;return r[r.length-1]}function se(t,i){let n=t.conditions,s=n.holdout_pct??0,r=n.holdout_scope==="variant"?t.id:n.ab_group??t.id;return s>0&&ie(i,`holdout:${r}`)*100<s}function re(t,i,n,s){let r=t.filter(o=>o.kind==="banner"&&o.steps[0]);if(!r.length)return;let u={id:"changelog",name:"What's new",kind:"resource_center",steps:r.map(o=>({id:o.id,title:o.steps[0].title??o.name,...o.steps[0].body?{body:o.steps[0].body}:{}})),conditions:{}},c=()=>{};return A(u,{shown:i,step:c,completed:c,dismissed:c,event:c},n,s?{nonce:s}:{})}function xe(t,i){for(let n of t){let s=n?.toLowerCase().replace("_","-");if(!s)continue;if(i.has(s))return s;let r=s.split("-")[0];if(i.has(r))return r}}function de(t,i){let n=new Set;for(let c of t.steps)for(let o of Object.keys(c.i18n??{}))n.add(o.toLowerCase());for(let c of Object.keys(t.appearance?.i18n??{}))n.add(c.toLowerCase());let s=xe(i,n);if(!s)return t;let r=c=>{let o=Object.keys(c??{}).find(a=>a.toLowerCase()===s);return o===void 0?void 0:c[o]},u=t.steps.map((c,o)=>{let a=r(c.i18n);if(!a)return c;let h=a.buttons,v=h&&(c.buttons??te(t.kind,o===t.steps.length-1)).map((g,l)=>({...g,label:h[l]??g.label}));return{...c,...a.title!==void 0?{title:a.title}:{},...a.body!==void 0?{body:a.body}:{},...v?{buttons:v}:{}}});return{...t,name:r(t.appearance?.i18n)?.name??t.name,steps:u}}function ce(t){let i=(s,r)=>{try{return JSON.parse(t.get(s)??"null")??r}catch{return r}},n=s=>({get:r=>i(s,{})[r],set(r,u){let c=i(s,{});u===void 0?delete c[r]:c[r]=u,t.set(s,JSON.stringify(c))}});return{views:n("lc_guide_views"),tour:n("lc_guide_progress"),checked:n("lc_guide_checked"),dismissed:n("lc_guide_dismissed"),held:n("lc_guide_holdout"),snoozed:n("lc_guide_snoozed")}}var M="lc_guide_seen",le=["lc_guide_views","lc_guide_progress","lc_guide_checked","lc_guide_dismissed","lc_guide_holdout","lc_guide_snoozed"],F=[M,...le],Me=2e3,N=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{},ae=t=>Array.isArray(t)?t:[],D=(t,i)=>[...new Set([...ae(t),...ae(i)])];function Oe(t,i){let n={[M]:D(t[M],i[M])};for(let s of le){let r=N(t[s]),u=N(i[s]),c={};for(let o of new Set([...Object.keys(r),...Object.keys(u)]))s==="lc_guide_checked"?c[o]=D(r[o],u[o]):s==="lc_guide_views"?c[o]=D(r[o],u[o]).sort((a,h)=>a-h).slice(-50):s==="lc_guide_progress"?c[o]=r[o]??u[o]:c[o]=Math.max(Number(r[o])||0,Number(u[o])||0);n[s]=c}return n}var ue=t=>Object.fromEntries(F.map(i=>{try{return[i,JSON.parse(t.get(i)??"null")]}catch{return[i,null]}}));function fe(t,i){let{core:n}=t,s,r=!1,u=async a=>{let h=await t.fetch(`${t.config.apiHost}/v1/guide-state`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",body:JSON.stringify({api_key:t.apiKey,distinct_id:n.distinctId,...a?{state:a}:{}})});if(!h.ok)throw new Error(`status ${h.status}`);return N((await h.json()).state)},c=()=>t.config.guides?.syncState!==!1&&!!n.distinctId&&n.hasConsent("analytics"),o=()=>{s=void 0,c()&&u(ue(i)).catch(a=>t.log("guide state push failed",a))};return{async pull(){if(c())try{let a=Oe(ue(i),await u());for(let[h,v]of Object.entries(a))i.set(h,JSON.stringify(v));r=!0,o()}catch(a){t.log("guide state pull failed",a)}},touch(){r&&!s&&(s=setTimeout(o,Me))},stop(){s&&clearTimeout(s)}}}var z="lc_guide";function pe(t,i,n,s){let{core:r}=t;return{async ask(u){try{let c=await t.fetch(`${t.config.apiHost}/v1/guides/answer?api_key=${encodeURIComponent(t.apiKey)}`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",body:JSON.stringify({api_key:t.apiKey,query:u.slice(0,500),distinct_id:r.distinctId||r.sessionId,url:location.href.slice(0,2e3),...s?{locale:s.slice(0,35)}:{}})});if(c.status===503)return"unavailable";if(!c.ok)return null;let o=await c.json();return{answer:typeof o.answer=="string"?o.answer:"",citations:Array.isArray(o.citations)?o.citations.filter(a=>a&&typeof a.url=="string"):[],guide_ids:Array.isArray(o.guide_ids)?o.guide_ids.filter(a=>typeof a=="string"):[]}}catch(c){return t.log("guide answer failed",c),null}},searched({query:u,results:c,answered:o,feedback:a}){r.capture("$guide_search",{$guide_id:i.id,guide_id:i.id,query_length:u.length,results:c,answered:o,...a?{feedback:a}:{},...n()?{query:u.slice(0,500)}:{}})}}}function ge(){if(typeof location>"u"||typeof history>"u")return null;try{let t=new URL(location.href),i=t.searchParams.get(z);return i?(t.searchParams.delete(z),history.replaceState(history.state,"",t.toString()),i.slice(0,100)):null}catch{return null}}var q="lc:guide",me=["shown","step","completed","dismissed","event","progress","snoozed","targetMissing"],K=new Set(["tooltip","modal","banner","tour","checklist","resource_center","announcement","slideout","carousel"]),ye=t=>!!t&&typeof t=="object"&&t.lc===q&&typeof t.key=="string",Ae=t=>{if(!t)return null;let i=t.getBoundingClientRect();return{x:i.left,y:i.top,width:i.width,height:i.height}};function he(){try{return window.top!==window}catch{return!0}}function Te(){let t=0,i=0,n=window;for(;n.parent!==window.top&&n.parent!==n;){let s;try{s=n.frameElement}catch{return null}if(!s)return null;let r=s.getBoundingClientRect();t+=r.left+s.clientLeft,i+=r.top+s.clientTop,n=n.parent}return{x:t,y:i}}var Pe=0;function ke(t,i,n,s,r){let u=window.top,c=`${Date.now().toString(36)}-${++Pe}`,o=!1,a=m=>{try{u?.postMessage({...m,lc:q,key:c},r)}catch{}},h=t.steps.filter(m=>m.selector||m.fallback_selectors?.length),v=[...new Set(t.steps.flatMap(m=>(m.branch??[]).filter(y=>y.op==="element_present"||y.op==="element_absent").map(y=>String(y.value))))],g=()=>{let m={},y=Te();for(let k of h){let _=y?Ae(ne(k)):null;m[k.id]=_&&y?{..._,x:_.x+y.x,y:_.y+y.y}:null}let $={};for(let k of v)try{$[k]=!!document.querySelector(k)}catch{$[k]=!1}a({op:"rects",rects:m,present:$})},l=m=>{if(m.source!==u||m.origin!==r||!ye(m.data)||m.data.key!==c)return;let y=m.data;if(y.op==="closed")return O(!1);if(y.op!=="hook"||!me.includes(y.name)||!Array.isArray(y.args))return;let $=i[y.name];if($?.(...y.args),y.name==="step"){let k=t.steps.find(_=>_.id===y.args[1]);k?.automation&&s.automate!==!1&&i.automated?.(k.id,C(k.automation))}};addEventListener("message",l);let G=h.length||v.length?setInterval(g,200):void 0;addEventListener("scroll",g,!0),addEventListener("resize",g);let O=m=>{o||(o=!0,G&&clearInterval(G),removeEventListener("message",l),removeEventListener("scroll",g,!0),removeEventListener("resize",g),m&&a({op:"close"}),n())};return a({op:"render",guide:t,...s.start?{start:s.start}:{},...s.checked?{checked:s.checked}:{}}),(h.length||v.length)&&g(),Object.assign(()=>O(!0),{markDone:m=>a({op:"mark",stepId:m})})}function He(t){let i=[...document.querySelectorAll("iframe")];for(let n=t;n;n=n.parent===n?null:n.parent){let s=i.find(r=>r.contentWindow===n);if(s)return s}return null}function Ie(t,i){let n=()=>{let r=t.getBoundingClientRect();return new DOMRect(r.left+t.clientLeft+i.x,r.top+t.clientTop+i.y,i.width,i.height)},s=()=>{};return{getBoundingClientRect:n,addEventListener:s,removeEventListener:s}}function _e(t,i){let n=new Set(t.map(u=>u.replace(/\/+$/,""))),s=new Map,r=u=>{if(!n.has(u.origin)||!ye(u.data))return;let c=He(u.source);if(!c)return;let o=u.data,a=`${u.origin}|${o.key}`,h=g=>{try{u.source.postMessage({...g,lc:q,key:o.key},u.origin)}catch{}},v=s.get(a);if(o.op==="rects"&&v)v.rects=o.rects&&typeof o.rects=="object"?o.rects:{},v.present=o.present&&typeof o.present=="object"?o.present:{};else if(o.op==="close")v?.handle();else if(o.op==="mark")v?.handle.markDone(String(o.stepId));else if(o.op==="render"&&!v){let g=o.guide;if(!g||typeof g.id!="string"||typeof g.name!="string"||!Array.isArray(g.steps)||!K.has(g.kind))return;let l=g.kind==="banner"?()=>{}:I();if(!l)return h({op:"closed"});let G=k=>(..._)=>h({op:"hook",name:k,args:_}),O=Object.fromEntries(me.map(k=>[k,G(k)])),m={rects:{},present:{},release:l,handle:void 0};s.set(a,m);let $={resolveTarget:k=>{let _=m.rects[k.id];return _&&typeof _.x=="number"?Ie(c,_):null},present:k=>m.present[k]===!0,automate:!1,...i?{nonce:i}:{},...typeof o.start=="number"?{start:o.start}:{},...Array.isArray(o.checked)?{checked:o.checked}:{}};m.handle=A(g,O,()=>{s.delete(a),l(),h({op:"closed"})},$)}};return addEventListener("message",r),()=>{removeEventListener("message",r);for(let u of[...s.values()])u.handle()}}var we="lc_guide_last",ve=new Set(["hotspot","beacon","badge","launcher"]),Le=()=>{try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t?`&tz=${encodeURIComponent(t)}`:""}catch{return""}},J=new Set([...ve,"form_validation"]),U=t=>J.has(t.kind)||t.kind==="inline",je=new Set(["tour","checklist"]),Ce=30*6e4,De=()=>{let t=innerWidth;return t<640?"mobile":t<1024?"tablet":"desktop"},ct=t=>{let{core:i}=t,n=[],s=!1,r=new Set,u=new Map,c=ge(),o=!1,a={get:e=>i.storage.get(e),set(e,d){i.storage.set(e,d),F.includes(e)&&h.touch()},remove:e=>i.storage.remove(e)},h=fe(t,i.storage),v=()=>JSON.parse(a.get(M)??"[]"),g=new Set(v()),l=ce(a),G=new Set,O=[],m=t.config.localFlagsContext,y={...m?.person_properties},$={...m?.group_properties},k=e=>{let d=t.flags?.get(e);return d!==void 0&&d!==!1},_=(e,d={})=>({$guide_id:e.id,$guide_kind:e.kind,...d}),W=()=>i.distinctId||i.sessionId,B=new Set,P=(e,d=!1)=>{if(e.preview){let f=()=>{};return{shown:f,step:f,completed:f,dismissed:f,event:f}}let w=J.has(e.kind),b=f=>({guide_id:e.id,step_id:f,$guide_step_id:f}),S=()=>{l.tour.set(e.id,void 0),l.checked.set(e.id,void 0),w&&l.dismissed.set(e.id,Date.now())};return{shown(){let f=Date.now(),p=l.views.get(e.id)??[],R=w&&(p.at(-1)??0)>f-Ce;g.add(e.id),l.snoozed.get(e.id)&&l.snoozed.set(e.id,void 0),a.set(M,JSON.stringify([...g])),i.storage.set(we,String(f)),e.kind==="checklist"&&!l.checked.get(e.id)&&l.checked.set(e.id,[]),!(R||d)&&(l.views.set(e.id,[...p,f].slice(-50)),i.capture("$guide_shown",_(e)))},step:(f,p)=>{e.kind==="checklist"&&l.checked.set(e.id,[...new Set([...l.checked.get(e.id)??[],p])]),i.capture("$guide_step",_(e,{$guide_step_id:p,$guide_step_index:f}))},progress:f=>e.kind==="tour"&&l.tour.set(e.id,f),completed:()=>(S(),i.capture("$guide_completed",_(e))),dismissed:(f,p,R)=>{R!=="snooze"&&S(),i.capture("$guide_dismissed",_(e,{$guide_step_id:p,$guide_step_index:f,...R?{reason:R}:{}}))},event:f=>t.client.capture(f,{$guide_id:e.id}),snoozed:(f,p)=>l.snoozed.set(e.id,Date.now()+p*36e5),targetMissing:(f,p)=>i.capture("$guide_target_missing",_(e,{...b(f),selector:p})),validationFailed:(f,p)=>i.capture("$guide_validation_failed",_(e,{...b(f),rule:p})),automated:(f,p)=>p!=="done"&&t.log(`guide ${e.id} step ${f}: automation ${p}`)}},T=(e,d=0)=>{let w=ve.has(e.kind),b=U(e)?()=>{}:I();if(!b)return void r.delete(e.id);let S=de(e,[t.config.guides?.locale,y.locale,navigator.language]),f=H=>{let L=n.find(Re=>Re.id===H);L&&!r.has(L.id)&&(r.add(L.id),T(L))},p={start:d,person:y,checked:l.checked.get(e.id)??[],library:n,launch:f,flag:k,...t.config.nonce?{nonce:t.config.nonce}:{},...e.kind==="resource_center"&&!e.preview?{assist:pe(t,e,()=>o,t.config.guides?.locale??navigator.language)}:{}},R=d>0||e.kind==="checklist"&&l.checked.get(e.id)!==void 0,E=()=>{G.delete(x),u.delete(e.id),b(),r.delete(e.id)},x=()=>{};if(w){import("./persistent-SLVINN5A.js").then(H=>{x=H.renderPersistent(S,P(e,R),E,p),s?x():G.add(x)});return}if(e.kind==="form_validation"){import("./validation-HGJXZ553.js").then(H=>{x=H.renderValidation(S,P(e,R),E,p),s?x():G.add(x)});return}let Z=t.config.guides?.renderInTop,X=Z&&K.has(e.kind)&&he()?ke(S,P(e,R),E,p,Z):A(S,P(e,R),E,p);x=X,u.set(e.id,X),G.add(x)},j=(e,d=!1)=>{let w=J.has(e.kind),b=e.conditions,S=e.steps[0]?.selector;if(e.kind==="inline"&&!(S&&document.querySelector(S)))return!1;if(e.preview)return!B.has(e.id)&&(B.add(e.id),!0);let f=l.views.get(e.id)??[],p=l.snoozed.get(e.id);if(!d&&p&&p>Date.now()||!d&&(w?l.dismissed.get(e.id):g.has(e.id)&&!b.frequency&&!p))return!1;let R={url:location.href,flags:k,flagValue:E=>t.flags?.get(E),lastShownMs:e.queued?void 0:Number(i.storage.get(we))||void 0,nowMs:Date.now(),random:e.queued?()=>0:Math.random,person:y,groups:$,device:De(),seen:E=>g.has(E),views:w?[]:f};return!ee(e,R)||oe(e,n,W())!==e?!1:e.held_out||se(e,W())?(l.held.get(e.id)||(l.held.set(e.id,Date.now()),i.capture("$guide_holdout",_(e,b.ab_group?{$guide_group:b.ab_group}:{}))),!1):!0},be=()=>{let e=c?n.find(d=>d.id===c):void 0;c=null,!(!e||r.has(e.id)||t.config.guides?.render===!1||!j(e,!0))&&(r.add(e.id),T(e))},Y=()=>{if(!(t.config.guides?.render===!1||typeof document>"u")){for(let e of n){if(r.has(e.id)||!je.has(e.kind))continue;let d=e.kind==="tour"?e.steps.findIndex(b=>b.id===l.tour.get(e.id)):l.checked.get(e.id)?0:-1,w=e.steps[d];if(!(d<0||!w||w.url&&!location.href.includes(w.url)))return r.add(e.id),T(e,d)}for(let e of n)r.has(e.id)||!U(e)||!j(e)||(r.add(e.id),T(e));for(let e of[...n.filter(d=>d.queued),...n.filter(d=>!d.queued)])if(!(r.has(e.id)||U(e)||!j(e))){r.add(e.id),O.push(setTimeout(()=>T(e),e.queued?0:(e.conditions.delay_seconds??0)*1e3));return}}},Se=e=>{for(let d of n)if(!(d.kind!=="checklist"||!r.has(d.id)&&!l.checked.get(d.id)))for(let[w,b]of d.steps.entries()){let S=b.complete_on;if(!S||S.event!==e.event||!Object.entries(S.props??{}).every(([R,E])=>e.properties[R]===E))continue;let f=l.checked.get(d.id)??[];if(f.includes(b.id))continue;let p=u.get(d.id);p?p.markDone(b.id):(l.checked.set(d.id,[...f,b.id]),i.capture("$guide_step",_(d,{$guide_step_id:b.id,$guide_step_index:w,$guide_auto:!0})),f.length+1>=d.steps.length&&P(d).completed())}},V=()=>{let e=t.fetch(`${t.config.apiHost}/v1/guides?api_key=${encodeURIComponent(t.apiKey)}${i.distinctId?`&distinct_id=${encodeURIComponent(i.distinctId)}`:""}${Le()}&url=${encodeURIComponent(location.origin+location.pathname)}`,{credentials:"omit"}).then(d=>d.ok?d.json():Promise.reject(new Error(`status ${d.status}`)));Promise.all([e,h.pull()]).then(([d])=>{for(let w of v())g.add(w);n=d.guides??[],o=d.settings?.guide_search_capture_query===!0,be(),Y()}).catch(d=>t.log("guides fetch failed",d))};t.guides={showChangelog(){if(typeof document>"u")return 0;let e=I();if(!e)return 0;let d=re(n,()=>i.capture("$changelog_viewed"),()=>(G.delete(d),e()),t.config.nonce);return d?(G.add(d),n.filter(w=>w.kind==="banner").length):(e(),0)},show(e){let d=n.find(w=>w.id===e);return!d||r.has(d.id)||typeof document>"u"||t.config.guides?.render===!1?!1:(r.add(d.id),T(d),r.has(d.id))},reset(e){g.delete(e),a.set(M,JSON.stringify([...g]));for(let d of[l.views,l.dismissed,l.tour,l.checked,l.held])d.set(e,void 0)}},t.whenConsented(V);let Q=t.config.guides?.frameOrigins;return Q?.length&&typeof document<"u"&&G.add(_e(Q,t.config.nonce)),t.onCapture(e=>{if(e.event==="$identify"&&V(),e.$set&&Object.assign(y,e.$set),e.event==="$groupidentify"){let d=String(e.properties.$group_type);$[d]={...$[d],...e.properties.$group_set}}e.event==="$pageview"?Y():e.event.startsWith("$guide_")||Se(e)}),()=>{s=!0,h.stop();for(let e of O)clearTimeout(e);for(let e of[...G])e()}};export{z as PERMALINK_PARAM,Ge as branchOk,ct as guides,A as renderGuide,Ee as resolveTokens,C as runAutomation,$e as sensitive};
|
|
1
|
+
import{a as I}from"./chunk-AWIQCFGN.js";import{a as ee,c as Ge,d as $e,e as C,f as Ee,h as te,i as ne,k as A}from"./chunk-B722OERZ.js";function ie(t,i){let n=2166136261;for(let s of`${i}:${t}`)n=Math.imul(n^s.codePointAt(0),16777619);return n^=n>>>16,n=Math.imul(n,2246822507),n^=n>>>13,n=Math.imul(n,3266489909),n^=n>>>16,(n>>>0)/2**32}function oe(t,i,n){let s=t.conditions.ab_group;if(!s)return t;let r=i.filter(o=>o.conditions.ab_group===s).sort((o,a)=>o.id<a.id?-1:1),u=r.reduce((o,a)=>o+(a.conditions.ab_weight??1),0),c=ie(n,`ab:${s}`)*u;for(let o of r)if(c-=o.conditions.ab_weight??1,c<0)return o;return r[r.length-1]}function se(t,i){let n=t.conditions,s=n.holdout_pct??0,r=n.holdout_scope==="variant"?t.id:n.ab_group??t.id;return s>0&&ie(i,`holdout:${r}`)*100<s}function re(t,i,n,s){let r=t.filter(o=>o.kind==="banner"&&o.steps[0]);if(!r.length)return;let u={id:"changelog",name:"What's new",kind:"resource_center",steps:r.map(o=>({id:o.id,title:o.steps[0].title??o.name,...o.steps[0].body?{body:o.steps[0].body}:{}})),conditions:{}},c=()=>{};return A(u,{shown:i,step:c,completed:c,dismissed:c,event:c},n,s?{nonce:s}:{})}function xe(t,i){for(let n of t){let s=n?.toLowerCase().replace("_","-");if(!s)continue;if(i.has(s))return s;let r=s.split("-")[0];if(i.has(r))return r}}function de(t,i){let n=new Set;for(let c of t.steps)for(let o of Object.keys(c.i18n??{}))n.add(o.toLowerCase());for(let c of Object.keys(t.appearance?.i18n??{}))n.add(c.toLowerCase());let s=xe(i,n);if(!s)return t;let r=c=>{let o=Object.keys(c??{}).find(a=>a.toLowerCase()===s);return o===void 0?void 0:c[o]},u=t.steps.map((c,o)=>{let a=r(c.i18n);if(!a)return c;let h=a.buttons,v=h&&(c.buttons??te(t.kind,o===t.steps.length-1)).map((g,l)=>({...g,label:h[l]??g.label}));return{...c,...a.title!==void 0?{title:a.title}:{},...a.body!==void 0?{body:a.body}:{},...v?{buttons:v}:{}}});return{...t,name:r(t.appearance?.i18n)?.name??t.name,steps:u}}function ce(t){let i=(s,r)=>{try{return JSON.parse(t.get(s)??"null")??r}catch{return r}},n=s=>({get:r=>i(s,{})[r],set(r,u){let c=i(s,{});u===void 0?delete c[r]:c[r]=u,t.set(s,JSON.stringify(c))}});return{views:n("lc_guide_views"),tour:n("lc_guide_progress"),checked:n("lc_guide_checked"),dismissed:n("lc_guide_dismissed"),held:n("lc_guide_holdout"),snoozed:n("lc_guide_snoozed")}}var M="lc_guide_seen",le=["lc_guide_views","lc_guide_progress","lc_guide_checked","lc_guide_dismissed","lc_guide_holdout","lc_guide_snoozed"],F=[M,...le],Me=2e3,N=t=>t&&typeof t=="object"&&!Array.isArray(t)?t:{},ae=t=>Array.isArray(t)?t:[],D=(t,i)=>[...new Set([...ae(t),...ae(i)])];function Oe(t,i){let n={[M]:D(t[M],i[M])};for(let s of le){let r=N(t[s]),u=N(i[s]),c={};for(let o of new Set([...Object.keys(r),...Object.keys(u)]))s==="lc_guide_checked"?c[o]=D(r[o],u[o]):s==="lc_guide_views"?c[o]=D(r[o],u[o]).sort((a,h)=>a-h).slice(-50):s==="lc_guide_progress"?c[o]=r[o]??u[o]:c[o]=Math.max(Number(r[o])||0,Number(u[o])||0);n[s]=c}return n}var ue=t=>Object.fromEntries(F.map(i=>{try{return[i,JSON.parse(t.get(i)??"null")]}catch{return[i,null]}}));function fe(t,i){let{core:n}=t,s,r=!1,u=async a=>{let h=await t.fetch(`${t.config.apiHost}/v1/guide-state`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",body:JSON.stringify({api_key:t.apiKey,distinct_id:n.distinctId,...a?{state:a}:{}})});if(!h.ok)throw new Error(`status ${h.status}`);return N((await h.json()).state)},c=()=>t.config.guides?.syncState!==!1&&!!n.distinctId&&n.hasConsent("analytics"),o=()=>{s=void 0,c()&&u(ue(i)).catch(a=>t.log("guide state push failed",a))};return{async pull(){if(c())try{let a=Oe(ue(i),await u());for(let[h,v]of Object.entries(a))i.set(h,JSON.stringify(v));r=!0,o()}catch(a){t.log("guide state pull failed",a)}},touch(){r&&!s&&(s=setTimeout(o,Me))},stop(){s&&clearTimeout(s)}}}var z="lc_guide";function pe(t,i,n,s){let{core:r}=t;return{async ask(u){try{let c=await t.fetch(`${t.config.apiHost}/v1/guides/answer?api_key=${encodeURIComponent(t.apiKey)}`,{method:"POST",headers:{"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",body:JSON.stringify({api_key:t.apiKey,query:u.slice(0,500),distinct_id:r.distinctId||r.sessionId,url:location.href.slice(0,2e3),...s?{locale:s.slice(0,35)}:{}})});if(c.status===503)return"unavailable";if(!c.ok)return null;let o=await c.json();return{answer:typeof o.answer=="string"?o.answer:"",citations:Array.isArray(o.citations)?o.citations.filter(a=>a&&typeof a.url=="string"):[],guide_ids:Array.isArray(o.guide_ids)?o.guide_ids.filter(a=>typeof a=="string"):[]}}catch(c){return t.log("guide answer failed",c),null}},searched({query:u,results:c,answered:o,feedback:a}){r.capture("$guide_search",{$guide_id:i.id,guide_id:i.id,query_length:u.length,results:c,answered:o,...a?{feedback:a}:{},...n()?{query:u.slice(0,500)}:{}})}}}function ge(){if(typeof location>"u"||typeof history>"u")return null;try{let t=new URL(location.href),i=t.searchParams.get(z);return i?(t.searchParams.delete(z),history.replaceState(history.state,"",t.toString()),i.slice(0,100)):null}catch{return null}}var q="lc:guide",me=["shown","step","completed","dismissed","event","progress","snoozed","targetMissing"],K=new Set(["tooltip","modal","banner","tour","checklist","resource_center","announcement","slideout","carousel"]),ye=t=>!!t&&typeof t=="object"&&t.lc===q&&typeof t.key=="string",Ae=t=>{if(!t)return null;let i=t.getBoundingClientRect();return{x:i.left,y:i.top,width:i.width,height:i.height}};function he(){try{return window.top!==window}catch{return!0}}function Te(){let t=0,i=0,n=window;for(;n.parent!==window.top&&n.parent!==n;){let s;try{s=n.frameElement}catch{return null}if(!s)return null;let r=s.getBoundingClientRect();t+=r.left+s.clientLeft,i+=r.top+s.clientTop,n=n.parent}return{x:t,y:i}}var Pe=0;function ke(t,i,n,s,r){let u=window.top,c=`${Date.now().toString(36)}-${++Pe}`,o=!1,a=m=>{try{u?.postMessage({...m,lc:q,key:c},r)}catch{}},h=t.steps.filter(m=>m.selector||m.fallback_selectors?.length),v=[...new Set(t.steps.flatMap(m=>(m.branch??[]).filter(y=>y.op==="element_present"||y.op==="element_absent").map(y=>String(y.value))))],g=()=>{let m={},y=Te();for(let k of h){let _=y?Ae(ne(k)):null;m[k.id]=_&&y?{..._,x:_.x+y.x,y:_.y+y.y}:null}let $={};for(let k of v)try{$[k]=!!document.querySelector(k)}catch{$[k]=!1}a({op:"rects",rects:m,present:$})},l=m=>{if(m.source!==u||m.origin!==r||!ye(m.data)||m.data.key!==c)return;let y=m.data;if(y.op==="closed")return O(!1);if(y.op!=="hook"||!me.includes(y.name)||!Array.isArray(y.args))return;let $=i[y.name];if($?.(...y.args),y.name==="step"){let k=t.steps.find(_=>_.id===y.args[1]);k?.automation&&s.automate!==!1&&i.automated?.(k.id,C(k.automation))}};addEventListener("message",l);let G=h.length||v.length?setInterval(g,200):void 0;addEventListener("scroll",g,!0),addEventListener("resize",g);let O=m=>{o||(o=!0,G&&clearInterval(G),removeEventListener("message",l),removeEventListener("scroll",g,!0),removeEventListener("resize",g),m&&a({op:"close"}),n())};return a({op:"render",guide:t,...s.start?{start:s.start}:{},...s.checked?{checked:s.checked}:{}}),(h.length||v.length)&&g(),Object.assign(()=>O(!0),{markDone:m=>a({op:"mark",stepId:m})})}function He(t){let i=[...document.querySelectorAll("iframe")];for(let n=t;n;n=n.parent===n?null:n.parent){let s=i.find(r=>r.contentWindow===n);if(s)return s}return null}function Ie(t,i){let n=()=>{let r=t.getBoundingClientRect();return new DOMRect(r.left+t.clientLeft+i.x,r.top+t.clientTop+i.y,i.width,i.height)},s=()=>{};return{getBoundingClientRect:n,addEventListener:s,removeEventListener:s}}function _e(t,i){let n=new Set(t.map(u=>u.replace(/\/+$/,""))),s=new Map,r=u=>{if(!n.has(u.origin)||!ye(u.data))return;let c=He(u.source);if(!c)return;let o=u.data,a=`${u.origin}|${o.key}`,h=g=>{try{u.source.postMessage({...g,lc:q,key:o.key},u.origin)}catch{}},v=s.get(a);if(o.op==="rects"&&v)v.rects=o.rects&&typeof o.rects=="object"?o.rects:{},v.present=o.present&&typeof o.present=="object"?o.present:{};else if(o.op==="close")v?.handle();else if(o.op==="mark")v?.handle.markDone(String(o.stepId));else if(o.op==="render"&&!v){let g=o.guide;if(!g||typeof g.id!="string"||typeof g.name!="string"||!Array.isArray(g.steps)||!K.has(g.kind))return;let l=g.kind==="banner"?()=>{}:I();if(!l)return h({op:"closed"});let G=k=>(..._)=>h({op:"hook",name:k,args:_}),O=Object.fromEntries(me.map(k=>[k,G(k)])),m={rects:{},present:{},release:l,handle:void 0};s.set(a,m);let $={resolveTarget:k=>{let _=m.rects[k.id];return _&&typeof _.x=="number"?Ie(c,_):null},present:k=>m.present[k]===!0,automate:!1,...i?{nonce:i}:{},...typeof o.start=="number"?{start:o.start}:{},...Array.isArray(o.checked)?{checked:o.checked}:{}};m.handle=A(g,O,()=>{s.delete(a),l(),h({op:"closed"})},$)}};return addEventListener("message",r),()=>{removeEventListener("message",r);for(let u of[...s.values()])u.handle()}}var we="lc_guide_last",ve=new Set(["hotspot","beacon","badge","launcher"]),Le=()=>{try{let t=Intl.DateTimeFormat().resolvedOptions().timeZone;return t?`&tz=${encodeURIComponent(t)}`:""}catch{return""}},J=new Set([...ve,"form_validation"]),U=t=>J.has(t.kind)||t.kind==="inline",je=new Set(["tour","checklist"]),Ce=30*6e4,De=()=>{let t=innerWidth;return t<640?"mobile":t<1024?"tablet":"desktop"},ct=t=>{let{core:i}=t,n=[],s=!1,r=new Set,u=new Map,c=ge(),o=!1,a={get:e=>i.storage.get(e),set(e,d){i.storage.set(e,d),F.includes(e)&&h.touch()},remove:e=>i.storage.remove(e)},h=fe(t,i.storage),v=()=>JSON.parse(a.get(M)??"[]"),g=new Set(v()),l=ce(a),G=new Set,O=[],m=t.config.localFlagsContext,y={...m?.person_properties},$={...m?.group_properties},k=e=>{let d=t.flags?.get(e);return d!==void 0&&d!==!1},_=(e,d={})=>({$guide_id:e.id,$guide_kind:e.kind,...d}),W=()=>i.distinctId||i.sessionId,B=new Set,P=(e,d=!1)=>{if(e.preview){let f=()=>{};return{shown:f,step:f,completed:f,dismissed:f,event:f}}let w=J.has(e.kind),b=f=>({guide_id:e.id,step_id:f,$guide_step_id:f}),S=()=>{l.tour.set(e.id,void 0),l.checked.set(e.id,void 0),w&&l.dismissed.set(e.id,Date.now())};return{shown(){let f=Date.now(),p=l.views.get(e.id)??[],R=w&&(p.at(-1)??0)>f-Ce;g.add(e.id),l.snoozed.get(e.id)&&l.snoozed.set(e.id,void 0),a.set(M,JSON.stringify([...g])),i.storage.set(we,String(f)),e.kind==="checklist"&&!l.checked.get(e.id)&&l.checked.set(e.id,[]),!(R||d)&&(l.views.set(e.id,[...p,f].slice(-50)),i.capture("$guide_shown",_(e)))},step:(f,p)=>{e.kind==="checklist"&&l.checked.set(e.id,[...new Set([...l.checked.get(e.id)??[],p])]),i.capture("$guide_step",_(e,{$guide_step_id:p,$guide_step_index:f}))},progress:f=>e.kind==="tour"&&l.tour.set(e.id,f),completed:()=>(S(),i.capture("$guide_completed",_(e))),dismissed:(f,p,R)=>{R!=="snooze"&&S(),i.capture("$guide_dismissed",_(e,{$guide_step_id:p,$guide_step_index:f,...R?{reason:R}:{}}))},event:f=>t.client.capture(f,{$guide_id:e.id}),snoozed:(f,p)=>l.snoozed.set(e.id,Date.now()+p*36e5),targetMissing:(f,p)=>i.capture("$guide_target_missing",_(e,{...b(f),selector:p})),validationFailed:(f,p)=>i.capture("$guide_validation_failed",_(e,{...b(f),rule:p})),automated:(f,p)=>p!=="done"&&t.log(`guide ${e.id} step ${f}: automation ${p}`)}},T=(e,d=0)=>{let w=ve.has(e.kind),b=U(e)?()=>{}:I();if(!b)return void r.delete(e.id);let S=de(e,[t.config.guides?.locale,y.locale,navigator.language]),f=H=>{let L=n.find(Re=>Re.id===H);L&&!r.has(L.id)&&(r.add(L.id),T(L))},p={start:d,person:y,checked:l.checked.get(e.id)??[],library:n,launch:f,flag:k,...t.config.nonce?{nonce:t.config.nonce}:{},...e.kind==="resource_center"&&!e.preview?{assist:pe(t,e,()=>o,t.config.guides?.locale??navigator.language)}:{}},R=d>0||e.kind==="checklist"&&l.checked.get(e.id)!==void 0,E=()=>{G.delete(x),u.delete(e.id),b(),r.delete(e.id)},x=()=>{};if(w){import("./persistent-G2OR2L2N.js").then(H=>{x=H.renderPersistent(S,P(e,R),E,p),s?x():G.add(x)});return}if(e.kind==="form_validation"){import("./validation-S6TYVWAI.js").then(H=>{x=H.renderValidation(S,P(e,R),E,p),s?x():G.add(x)});return}let Z=t.config.guides?.renderInTop,X=Z&&K.has(e.kind)&&he()?ke(S,P(e,R),E,p,Z):A(S,P(e,R),E,p);x=X,u.set(e.id,X),G.add(x)},j=(e,d=!1)=>{let w=J.has(e.kind),b=e.conditions,S=e.steps[0]?.selector;if(e.kind==="inline"&&!(S&&document.querySelector(S)))return!1;if(e.preview)return!B.has(e.id)&&(B.add(e.id),!0);let f=l.views.get(e.id)??[],p=l.snoozed.get(e.id);if(!d&&p&&p>Date.now()||!d&&(w?l.dismissed.get(e.id):g.has(e.id)&&!b.frequency&&!p))return!1;let R={url:location.href,flags:k,flagValue:E=>t.flags?.get(E),lastShownMs:e.queued?void 0:Number(i.storage.get(we))||void 0,nowMs:Date.now(),random:e.queued?()=>0:Math.random,person:y,groups:$,device:De(),seen:E=>g.has(E),views:w?[]:f};return!ee(e,R)||oe(e,n,W())!==e?!1:e.held_out||se(e,W())?(l.held.get(e.id)||(l.held.set(e.id,Date.now()),i.capture("$guide_holdout",_(e,b.ab_group?{$guide_group:b.ab_group}:{}))),!1):!0},be=()=>{let e=c?n.find(d=>d.id===c):void 0;c=null,!(!e||r.has(e.id)||t.config.guides?.render===!1||!j(e,!0))&&(r.add(e.id),T(e))},Y=()=>{if(!(t.config.guides?.render===!1||typeof document>"u")){for(let e of n){if(r.has(e.id)||!je.has(e.kind))continue;let d=e.kind==="tour"?e.steps.findIndex(b=>b.id===l.tour.get(e.id)):l.checked.get(e.id)?0:-1,w=e.steps[d];if(!(d<0||!w||w.url&&!location.href.includes(w.url)))return r.add(e.id),T(e,d)}for(let e of n)r.has(e.id)||!U(e)||!j(e)||(r.add(e.id),T(e));for(let e of[...n.filter(d=>d.queued),...n.filter(d=>!d.queued)])if(!(r.has(e.id)||U(e)||!j(e))){r.add(e.id),O.push(setTimeout(()=>T(e),e.queued?0:(e.conditions.delay_seconds??0)*1e3));return}}},Se=e=>{for(let d of n)if(!(d.kind!=="checklist"||!r.has(d.id)&&!l.checked.get(d.id)))for(let[w,b]of d.steps.entries()){let S=b.complete_on;if(!S||S.event!==e.event||!Object.entries(S.props??{}).every(([R,E])=>e.properties[R]===E))continue;let f=l.checked.get(d.id)??[];if(f.includes(b.id))continue;let p=u.get(d.id);p?p.markDone(b.id):(l.checked.set(d.id,[...f,b.id]),i.capture("$guide_step",_(d,{$guide_step_id:b.id,$guide_step_index:w,$guide_auto:!0})),f.length+1>=d.steps.length&&P(d).completed())}},V=()=>{let e=t.fetch(`${t.config.apiHost}/v1/guides?api_key=${encodeURIComponent(t.apiKey)}${i.distinctId?`&distinct_id=${encodeURIComponent(i.distinctId)}`:""}${Le()}&url=${encodeURIComponent(location.origin+location.pathname)}`,{credentials:"omit"}).then(d=>d.ok?d.json():Promise.reject(new Error(`status ${d.status}`)));Promise.all([e,h.pull()]).then(([d])=>{for(let w of v())g.add(w);n=d.guides??[],o=d.settings?.guide_search_capture_query===!0,be(),Y()}).catch(d=>t.log("guides fetch failed",d))};t.guides={showChangelog(){if(typeof document>"u")return 0;let e=I();if(!e)return 0;let d=re(n,()=>i.capture("$changelog_viewed"),()=>(G.delete(d),e()),t.config.nonce);return d?(G.add(d),n.filter(w=>w.kind==="banner").length):(e(),0)},show(e){let d=n.find(w=>w.id===e);return!d||r.has(d.id)||typeof document>"u"||t.config.guides?.render===!1?!1:(r.add(d.id),T(d),r.has(d.id))},reset(e){g.delete(e),a.set(M,JSON.stringify([...g]));for(let d of[l.views,l.dismissed,l.tour,l.checked,l.held])d.set(e,void 0)}},t.whenConsented(V);let Q=t.config.guides?.frameOrigins;return Q?.length&&typeof document<"u"&&G.add(_e(Q,t.config.nonce)),t.onCapture(e=>{if(e.event==="$identify"&&V(),e.$set&&Object.assign(y,e.$set),e.event==="$groupidentify"){let d=String(e.properties.$group_type);$[d]={...$[d],...e.properties.$group_set}}e.event==="$pageview"?Y():e.event.startsWith("$guide_")||Se(e)}),()=>{s=!0,h.stop();for(let e of O)clearTimeout(e);for(let e of[...G])e()}};export{z as PERMALINK_PARAM,Ge as branchOk,ct as guides,A as renderGuide,Ee as resolveTokens,C as runAutomation,$e as sensitive};
|