@lucida-analytics/browser 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +7 -2
- package/dist/autocapture.d.ts +1 -1
- package/dist/autocapture.js +1 -1
- package/dist/{client-DTogLMYz.d.ts → client-C9F2fWI4.d.ts} +2 -2
- package/dist/consent.d.ts +2 -2
- package/dist/core.d.ts +3 -3
- package/dist/core.js +3 -3
- package/dist/correlate.d.ts +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/heatmaps.d.ts +1 -1
- package/dist/heatmaps.js +1 -1
- package/dist/host-headers.d.ts +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.js +2 -2
- package/dist/inspector.d.ts +1 -1
- package/dist/lucida.js +2 -2
- package/dist/recommendations.d.ts +1 -1
- package/dist/{static/v0/recorder-TZCDQIZN.js → recorder-AJ7XX7OZ.js} +4 -4
- package/dist/replay.d.ts +2 -2
- package/dist/replay.js +1 -1
- package/dist/static/v0/autocapture.js +1 -1
- package/dist/static/v0/core.js +3 -3
- package/dist/static/v0/heatmaps.js +1 -1
- package/dist/static/v0/index.js +2 -2
- package/dist/static/v0/lucida.js +2 -2
- package/dist/static/v0/manifest.json +8 -8
- package/dist/static/{v0.1.10/recorder-TZCDQIZN.js → v0/recorder-AJ7XX7OZ.js} +4 -4
- package/dist/static/v0/replay.js +1 -1
- package/dist/static/v0.1.12/autocapture.js +1 -0
- package/dist/static/v0.1.12/core.js +3 -0
- package/dist/static/v0.1.12/heatmaps.js +1 -0
- package/dist/static/v0.1.12/index.js +3 -0
- package/dist/static/v0.1.12/lucida.js +3 -0
- package/dist/static/{v0.1.10 → v0.1.12}/manifest.json +8 -8
- package/dist/{recorder-TZCDQIZN.js → static/v0.1.12/recorder-AJ7XX7OZ.js} +4 -4
- package/dist/static/{v0.1.10 → v0.1.12}/replay.js +1 -1
- package/dist/toolbar.d.ts +1 -1
- package/dist/{types-B_CVJeLI.d.ts → types-Chfj1wdu.d.ts} +9 -2
- package/dist/webmcp.d.ts +1 -1
- package/package.json +1 -1
- package/storage.json +2 -2
- package/dist/static/v0.1.10/autocapture.js +0 -1
- package/dist/static/v0.1.10/core.js +0 -3
- package/dist/static/v0.1.10/heatmaps.js +0 -1
- package/dist/static/v0.1.10/index.js +0 -3
- package/dist/static/v0.1.10/lucida.js +0 -3
- /package/dist/static/{v0.1.10 → v0.1.12}/banner-TXLAMTQM.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/chunk-AWIQCFGN.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/chunk-B722OERZ.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/chunk-EFNCQJI3.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/chunk-IXDYCBAD.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/chunk-UPPUYIIH.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/consent.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/correlate.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/early-access.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/experiments.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/flags.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/forms.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/guides.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/host-headers.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/inspector.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/modules-FANMZRDJ.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/persistent-G2OR2L2N.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/recommendations.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/toolbar.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/validation-S6TYVWAI.js +0 -0
- /package/dist/static/{v0.1.10 → v0.1.12}/webmcp.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Built from the git history of `sdks/browser` and its version bumps. Dates are the bump commit dates.
|
|
4
4
|
|
|
5
|
+
## 0.1.12 (2026-11-17)
|
|
6
|
+
|
|
7
|
+
Added:
|
|
8
|
+
- `urlPrivacy.pathRules` (`[{match, replace}]`, applied in order with `String.replace` semantics) and `urlPrivacy.maskPathIds` (UUID, ULID, long digit, long hex and long mixed-alphanumeric segments become `:id`). Both apply to every URL the SDK sends: `$current_url`, `$referrer`, `$initial_*`, `$pathname`, replay meta URLs and autocapture hrefs (`$elements_chain`, `$elements`).
|
|
9
|
+
- `assetHost` accepts a path on this site (`/dashboard/lucida`), resolved against the page URL; a trailing slash is dropped.
|
|
10
|
+
|
|
11
|
+
Docs:
|
|
12
|
+
- README: where the npm package ships the classic script, and self-hosting rules.
|
|
13
|
+
- Confirmed in `consent: { mode: "opt_in" }` (without `geo`) no request and no storage write happens before consent is granted; a test pins it.
|
|
14
|
+
|
|
15
|
+
## 0.1.11 (2026-11-16)
|
|
16
|
+
|
|
17
|
+
Fixed:
|
|
18
|
+
- With `autocapture: { captureText: false }`, `$elements_chain` no longer carries text-bearing attributes (`aria-label`, `aria-description`, `title`, `alt`, `placeholder`, `value`, `label`). Tag, classes, id, nth-child, nth-of-type, href, `name`, `type`, `role` and `data-lc-*` are kept.
|
|
19
|
+
|
|
5
20
|
## 0.1.10 (2026-11-15)
|
|
6
21
|
|
|
7
22
|
Fixed:
|
package/README.md
CHANGED
|
@@ -227,13 +227,16 @@ inside `[data-lc-unmask]` or the unmask list (a mask selector inside still wins)
|
|
|
227
227
|
All writes stay behind consent.
|
|
228
228
|
- **Runtime config**: `client.setConfig(partial)` merges options one level deep; per-event options (debug, autocapture
|
|
229
229
|
options, hooks, sampling, denylist, rate limit, persisted properties) apply at once.
|
|
230
|
-
- **URL privacy**: well-known sensitive query params (`password`, `token`, `key`, `code`, `email`, ... see the quickstart) are always masked as `<masked>` in every URL sent and in replay; `urlPrivacy: {maskParams, maskCampaignParams, stripHash}` adds to that.
|
|
230
|
+
- **URL privacy**: well-known sensitive query params (`password`, `token`, `key`, `code`, `email`, ... see the quickstart) are always masked as `<masked>` in every URL sent and in replay; `urlPrivacy: {maskParams, maskCampaignParams, stripHash, pathRules, maskPathIds}` adds to that. `pathRules: [{match, replace}]` rewrites the URL path in order (`String.replace` semantics; a string `match` is a regex source, a RegExp needs `g` to replace every match), `maskPathIds: true` turns id-like segments (UUID, ULID, 4+ digits, 16+ hex, 20+ mixed alphanumeric with a digit) into `:id`. Both apply to `$current_url`, `$referrer`, `$initial_*`, `$pathname`, replay URLs and autocapture hrefs.
|
|
231
231
|
- **Delivery**: `assetHost` (default: the host `lucida.js` was loaded from) + `modules: ["replay", ...]` (classic script only) load versioned modules from
|
|
232
232
|
`<assetHost>/static/v<version>/`; `nonce` goes on every injected `<style>`; `extension: true` (auto on extension pages) for
|
|
233
233
|
Manifest V3. See docs/guides/sdk-pinning.md, csp.md and browser-extension.md.
|
|
234
234
|
- **Cookies**: `cookie: {secure, expiryDays, crossSubdomain, domain}`. `crossSubdomain` probes for the broadest parent domain
|
|
235
235
|
the browser accepts (on first write, which is after consent); all cookie writes stay behind consent.
|
|
236
236
|
- **Pageleave**: `capturePageleave: true | false | "if_capture_pageview"` (default).
|
|
237
|
+
- **Autocapture text**: with `captureText: false` element text is dropped and so are the text-bearing attributes
|
|
238
|
+
(`aria-label`, `aria-description`, `title`, `alt`, `placeholder`, `value`, `label`). `$elements_chain` keeps only tag,
|
|
239
|
+
classes, id, nth-child, nth-of-type, href, `name`, `type`, `role` and `data-lc-*` attributes (minus `attributeIgnore`).
|
|
237
240
|
- **Autocapture**: `elementAllowlist: ["a", "button"]`, `attributeIgnore: ["data-*", "title", "href"]`,
|
|
238
241
|
`maskAllAttributes` + `attributeAllowlist` (every attribute value in `$elements` reads `***` except the allowlist),
|
|
239
242
|
`urlIgnorelist: ["/admin", /\/checkout\//]` (autocapture off on those pages), `contentEditable` (default on: an edited
|
|
@@ -255,6 +258,7 @@ Derived from `git log -S` on `sdks/browser/src` and the version bump commits (se
|
|
|
255
258
|
|---|---|
|
|
256
259
|
| `cookieMunchConsent` | 0.1.1 |
|
|
257
260
|
| `urlPrivacy`, default sensitive-param masking | 0.1.1 |
|
|
261
|
+
| `urlPrivacy.pathRules`, `urlPrivacy.maskPathIds`, `assetHost` as a path | 0.1.12 |
|
|
258
262
|
| consent precedence (project `consent_mode`, geo default) | 0.1.5 |
|
|
259
263
|
| `exposeGlobal`, server no-op client, `hasOptedIn()`, `onConsent()`, Watchtower session stamp | 0.1.6 |
|
|
260
264
|
| Watchtower error and vital hooks (`$exception_seen`, `$web_vitals`) | 0.1.7 |
|
|
@@ -303,8 +307,9 @@ release is in `/static/v<version>/manifest.json`; `lucida init --framework html`
|
|
|
303
307
|
- **`modules`** (init config, names only): `replay`, `heatmaps`, `forms`, `toolbar`, `guides`, `inspector`, `experiments`,
|
|
304
308
|
`early-access`, `consent`. Each loads from `<assetHost>/static/v<this script's version>/<name>.js` before the client
|
|
305
309
|
starts; one that fails to load is skipped. Not loaded in extension mode.
|
|
306
|
-
- **`assetHost`, `uiHost`** default to the origin the script was loaded from (set `assetHost
|
|
310
|
+
- **`assetHost`, `uiHost`** default to the origin the script was loaded from (set `assetHost`, an absolute URL or a path on this site, only when the files are hosted
|
|
307
311
|
elsewhere, `uiHost` only when replay links should point elsewhere). `apiHost` is where events go, default `https://capture.lucidace.com`.
|
|
312
|
+
- **Self-hosting the classic script**: the npm package ships it under `dist/static/v<version>/` (`lucida.js`, the lazy modules and `manifest.json` with the SRI hashes). A self-hosted copy must keep the `/static/v<version>/` layout, because modules load next to `lucida.js`; set `assetHost` (an absolute URL, or a path on your site such as `/dashboard/lucida`) when serving from somewhere other than the page that loads the script.
|
|
308
313
|
- **`modules: ["consent"]`** adds `client.consent.showBanner()` and follows Cookie Munch: once `CookieMunch.hasResponse` it maps
|
|
309
314
|
`statistics` to analytics + replay and `marketing` to marketing, and follows its change events. Use it with `consent: { mode: "opt_in" }`.
|
|
310
315
|
- **Integrity**: with a `manifest.json` next to the script (releases from 0.1.5 on publish one; 0.1.1 to 0.1.4 have none; keys are the served file names relative to `/static/v<ver>/`: `{version, files: {"lucida.js":
|
package/dist/autocapture.d.ts
CHANGED
package/dist/autocapture.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var ve=(e,t)=>()=>(e&&(t=e(e=0)),t);function Ke(e){return e.startsWith("re:")?e.slice(3):e.split("*").map(t=>t.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*")}function j(e,t){return!!e?.some(n=>{try{return new RegExp(Ke(n),"i").test(t)}catch{return!1}})}var pe=ve(()=>{"use strict"});var be='[data-lc-region="article"]';function K(e,t,n){if(t.articles===!1)return()=>{};let o;e.loadConfig().then(m=>{typeof m?.article_selector=="string"&&(o=m.article_selector)});let i=()=>{for(let m of[t.articleSelector,o,be])if(m)try{let g=document.querySelector(m);if(g)return g}catch{}return null},s=location.href,u=location.pathname,c=null,a=0,l=!1,r=()=>{if(c??=i(),!c)return;let m=c.getBoundingClientRect();if(m.height<=0)return;let g=Math.round(Math.min(100,Math.max(0,(window.innerHeight-m.top)/m.height*100)));a=Math.max(a,g);let v=c.querySelector("h1,h2");v&&v.getBoundingClientRect().bottom<0&&(l=!0)},p=()=>{!c||!n()||(r(),e.client.capture("$article_read",{$article_id:(c.getAttribute("data-lc-article-id")??"").trim().slice(0,200)||u,$article_depth:a,$article_finished:a>=90,$article_headline_exit:!l&&a<25}),c=null)},d=()=>{p(),c=null,a=0,l=!1,s=location.href,u=location.pathname},f=()=>location.href!==s?d():r(),h=new MutationObserver(f);return h.observe(document.documentElement,{childList:!0,subtree:!0}),window.addEventListener("scroll",f,{passive:!0}),e.onUnload(p),r(),()=>{h.disconnect(),window.removeEventListener("scroll",f)}}var T="data-lc-content",Ee="data-lc-content-piece",we="data-lc-content-target";var O=(e,t)=>(e.getAttribute(t)??"").trim().slice(0,200);function G(e,t,n){if(t.contentBlocks===!1||typeof IntersectionObserver>"u")return()=>{};let o=new WeakSet,i=r=>{let p={$content_name:O(r,T)},d=O(r,Ee),f=O(r,we);return d&&(p.$content_piece=d),f&&(p.$content_target=f),p},s=location.href,u=new IntersectionObserver(r=>{for(let p of r)!p.isIntersecting||o.has(p.target)||!n()||(o.add(p.target),e.client.capture("$content_impression",i(p.target)))},{threshold:.5}),c=r=>r.querySelectorAll(`[${T}]`).forEach(p=>u.observe(p));c(document);let a=new MutationObserver(()=>{location.href!==s&&(s=location.href,u.disconnect(),document.querySelectorAll(`[${T}]`).forEach(r=>o.delete(r))),c(document)});a.observe(document.documentElement,{childList:!0,subtree:!0});let l=r=>{let p=r.target?.closest?.(`[${T}]`);p&&n()&&e.client.capture("$content_interaction",{...i(p),$content_interaction_type:"click"})};return document.addEventListener("click",l,!0),()=>{u.disconnect(),a.disconnect(),document.removeEventListener("click",l,!0)}}var ke=new Set(["input","textarea","select","option"]),xe=["name","type","role","aria-label","title","alt","placeholder"],Ce=/(?:\d[ -]?){9,}/;function Re(e){if(ke.has(e.tagName.toLowerCase())||e.isContentEditable)return;let t="";for(let n of Array.from(e.childNodes))n.nodeType===3&&(t+=n.textContent??"");if(t=t.replace(/\s+/g," ").trim(),!(!t||Ce.test(t)))return t.slice(0,255)}function Y(e){if(!e?.length)return()=>!1;let t=e.map(n=>n.toLowerCase());return n=>t.some(o=>o.endsWith("*")?n.startsWith(o.slice(0,-1)):n===o)}var B="***";function w(e){let t={};for(let n=e,o=0;n&&o<10;n=n.parentElement,o++)for(let i of Array.from(n.attributes)){let s=i.name.startsWith("data-lc-attr-")?i.name.slice(13):"";s&&!(s in t)&&!s.startsWith("$")&&(t[s]=i.value.slice(0,255))}return t}function Se(e,t,n,o){let i=e.parentElement,s=i?Array.from(i.children):[e],u={tag_name:e.tagName.toLowerCase(),nth_child:s.indexOf(e)+1,nth_of_type:s.filter(r=>r.tagName===e.tagName).indexOf(e)+1},c=(e.getAttribute("class")??"").split(/\s+/).filter(Boolean);c.length&&!n("class")&&(u.classes=c),e.id&&!n("id")&&(u.attr__id=o("id",e.id));let a=e.getAttribute("href");a&&!n("href")&&(u.href=o("href",a.slice(0,1024)));let l={};for(let r of Array.from(e.attributes))(r.name.startsWith("data-lc-")||xe.includes(r.name))&&!n(r.name)&&(l[r.name]=o(r.name,r.value.slice(0,255)));if(Object.keys(l).length&&(u.attrs=l),t){let r=Re(e);r&&(u.text=r)}return u}function k(e,t,n,o,i={}){let s=[],u=Y(o),c=Y(i.allow),a=i.maskAll?(r,p)=>c(r)?p:B:(r,p)=>p,l=t;for(let r=e;r&&s.length<10;r=r.parentElement)s.push(Se(r,l,u,a)),(r===n||!n)&&(l=!1);return s}var $=e=>e.replace(/(["\\])/g,"\\$1");function x(e){return e.map(t=>{let n=t.tag_name+(t.classes?"."+t.classes.join("."):"")+":";t.attr__id&&(n+=`attr__id="${$(t.attr__id)}"`),t.href&&(n+=`href="${$(t.href)}"`),t.text&&(n+=`text="${$(t.text)}"`);for(let[o,i]of Object.entries(t.attrs??{}))n+=`attr__${o}="${$(i)}"`;return n+`nth-child="${t.nth_child}"nth-of-type="${t.nth_of_type}"`}).join(";")}var b=[],Ae=/^[+\-−–‹›<>«»←→↑↓▲▼▶◀^ˇ˄˅]$/,Me=/\b(increase|decrease|increment|decrement|plus|minus|add one|remove one|next|prev|previous|scroll (left|right))\b/i,Te=/(^|[-_\s])(stepper|spinner|quantity|qty|increment|decrement|inc|dec|plus|minus|carousel|slider|swiper|slick|glide|splide|arrow|next|prev)([-_\s]|$)/i,$e="button,[role=button],a,input[type=button],input[type=submit],[role=spinbutton]";function z(e,t=[]){if(t.length&&e.closest(t.join(","))||e.closest("input[type=number],[role=spinbutton],[role=slider]"))return!0;let n=e.closest($e)??e,o=`${n.getAttribute("aria-label")??""} ${n.getAttribute("title")??""}`;if(Ae.test((n.textContent??"").trim())||Me.test(o))return!0;for(let i=n,s=0;i&&s<3;i=i.parentElement,s++)if(Te.test(i.getAttribute("class")??""))return!0;return!1}var Le=()=>typeof getSelection=="function"?(getSelection()?.toString()??"")!=="":!1;function V(e,t=Date.now(),n={},o){if(o&&n.ignoreSelectors?.length&&o.closest(n.ignoreSelectors.join(",")))return{};if(o&&n.suppressSteppers!==!1&&z(o,n.stepperSelectors))return{};if(n.ignoreTextSelection!==!1&&Le())return{};let i=n.windowMs??1e3,s=n.radiusPx??30;for(b.length&&t<b[b.length-1].t&&(b.length=0),b.push({t,x:e.clientX,y:e.clientY});b.length&&t-b[0].t>i;)b.shift();let u=b.filter(c=>Math.hypot(c.x-e.clientX,c.y-e.clientY)<=s).length;return u>=(n.count??3)?{$rageclick:!0,$rageclick_count:u}:{}}function Q(e,t,n=700){if(typeof MutationObserver>"u")return;let o=!1,i=new MutationObserver(()=>o=!0);i.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let s=()=>{o=!0};window.addEventListener("scroll",s,{capture:!0,passive:!0}),document.addEventListener("selectionchange",s);let u=()=>{i.disconnect(),window.removeEventListener("scroll",s,{capture:!0}),document.removeEventListener("selectionchange",s)},c=setTimeout(()=>{u(),!o&&document.visibilityState!=="hidden"&&e.client.capture("$deadclick_hint",{$selector:t,$no_mutation_ms:n})},n);e.onUnload(()=>{clearTimeout(c),u()})}var Z=/^[A-Za-z_][\w-]*$/,Oe=5;function J(e){let t=[];for(let n=e;n&&t.length<Oe;n=n.parentElement){let o=n.tagName.toLowerCase();if(n.id&&Z.test(n.id)){t.unshift(`${o}#${n.id}`);break}let i=(n.getAttribute("class")??"").split(/\s+/).filter(s=>Z.test(s)).slice(0,2);t.unshift(o+i.map(s=>`.${s}`).join(""))}return t.join(" ")}function ee(e,t,n,o,i={}){let s={$selector:J(n),$el_interactive:o};(t.clientX||t.clientY||t.detail)&&(s.$click_x=Math.round(t.clientX+(window.scrollX||0)),s.$click_y=Math.round(t.clientY+(window.scrollY||0))),i.rageClicks!==!1&&!n.closest(".lc-no-rageclick,[data-lc-no-rageclick]")&&Object.assign(s,V(t,Date.now(),i.rageClicks||{},n));let u=i.deadClicks;!o&&t.isTrusted&&u!==!1&&!(u?.ignoreSelectors?.length&&n.closest(u.ignoreSelectors.join(",")))&&Q(e,s.$selector,u?.waitMs);for(let c of e.clickExtras)Object.assign(s,c(t,n));return s}var He="a,button,input,select,textarea,label,summary,[role=button],[role=link],[data-lc-capture]",Ie="[data-lc-ignore]",H=e=>e.some(t=>typeof t=="string"?location.href.includes(t):t.test(location.href)),Pe=e=>!e?.length||H(e),I=e=>({maskAll:e.maskAllAttributes,allow:e.attributeAllowlist}),C=(e,t)=>!!e.closest(Ie)||!!(t.denySelectors?.length&&e.closest(t.denySelectors.join(",")));function te(e,t,n,o=()=>!0){let i=t.events??["click","change","submit"],s=0,u=l=>{let r=l.target;!n()||!o()||l.isComposing||!(r instanceof Element)||C(r,t)||r instanceof HTMLInputElement&&r.type==="password"||(s+=1)},c=l=>r=>{if(!n()||l!=="click"&&!o())return;let p=r.target;if(!(p instanceof Element)||C(p,t)||t.allowSelectors?.length&&!p.closest(t.allowSelectors.join(","))||t.elementAllowlist?.length&&!p.closest(t.elementAllowlist.join(","))||!Pe(t.urlAllowlist)||l==="change"&&!/^(input|select|textarea)$/i.test(p.tagName)||p instanceof HTMLInputElement&&p.type==="password")return;let d=p.closest(He);if(l==="click"&&!d&&!t.allowSelectors?.length)return;let f=k(p,t.captureText??!0,d??void 0,t.attributeIgnore,I(t)),h=f.find(g=>g.text)?.text,m=s;s=0,e.client.capture("$autocapture",{...w(p),$event_type:l,...m>0?{$keystroke_count:m}:{},$elements:f,$elements_chain:x(f),...h?{$el_text:h}:{},...l==="click"?ee(e,r,p,!!d,t):{}})};e.autocaptureClicks=i.includes("click");let a=i.map(l=>[l,c(l)]);for(let[l,r]of a)document.addEventListener(l,r,!0);return document.addEventListener("keydown",u,!0),()=>{for(let[l,r]of a)document.removeEventListener(l,r,!0);document.removeEventListener("keydown",u,!0)}}var je='[contenteditable]:not([contenteditable="false"])',ne="input,textarea,select",Ne=255;function re(e){return e.replace(/\d(?:[ -]?\d){5,}/g,"***").replace(/[^\s@]+@[^\s@]+\.[^\s@]+/g,"***").replace(/\s+/g," ").trim().slice(0,Ne)}var We=e=>e?e instanceof Element?e:e.parentElement:null;function oe(e,t,n,o=()=>!0){let i=t.events??["click","change","submit"],s=t.contentEditable!==!1&&i.includes("change"),u=new WeakSet,c=d=>{let f=k(d,!1,d,t.attributeIgnore,I(t));return{...w(d),$elements:f,$elements_chain:x(f)}},a=d=>{let f=d instanceof Element?d.closest(je):null;return f&&!C(f,t)?f:null},l=d=>{let f=n()&&o()?a(d.target):null;f&&u.add(f)},r=d=>{let f=a(d.target);!f||!u.has(f)||d.relatedTarget instanceof Node&&f.contains(d.relatedTarget)||(u.delete(f),n()&&o()&&e.client.capture("$autocapture",{$event_type:"change",$el_contenteditable:!0,...c(f)}))},p=d=>{if(!n()||!t.copyCut)return;let f=typeof getSelection=="function"?getSelection():null,h=d.target instanceof Element?d.target:null,m=We(f?.anchorNode)??h;if(!m||C(m,t)||m.closest(ne)||h?.closest(ne))return;let g=t.captureCopiedText?re(f?.toString()??""):"";e.client.capture("$copy_autocapture",{$copy_type:d.type,...c(m),...g?{$selected_content:g}:{}})};return s&&(document.addEventListener("input",l,!0),document.addEventListener("focusout",r,!0)),document.addEventListener("copy",p,!0),document.addEventListener("cut",p,!0),()=>{document.removeEventListener("input",l,!0),document.removeEventListener("focusout",r,!0),document.removeEventListener("copy",p,!0),document.removeEventListener("cut",p,!0)}}var De="[data-lc-ignore]",ie=["pdf","zip","gz","tar","rar","7z","doc","docx","xls","xlsx","ppt","pptx","csv","epub","dmg","exe","msi","pkg","apk","iso","mp3","mp4","mov"],ae=["q","s","search","query"],se=e=>e.origin+e.pathname;function le(e,t,n){let o=Array.isArray(t.fileDownloads)?t.fileDownloads.map(s=>s.toLowerCase()):ie,i=[];if(t.outboundLinks!==!1||t.fileDownloads!==!1){let s=u=>{let c=u.target instanceof Element?u.target.closest("a[href]"):null;if(!c||!n()||c.closest(De))return;let a;try{a=new URL(c.href,location.href)}catch{return}if(a.protocol!=="http:"&&a.protocol!=="https:")return;let l=decodeURIComponent(a.pathname.split("/").pop()??""),r=l.includes(".")?l.split(".").pop().toLowerCase():"";t.fileDownloads!==!1&&(c.hasAttribute("download")||o.includes(r))?e.client.capture("$file_download",{$url:se(a),$file_name:l,$file_extension:r}):t.outboundLinks!==!1&&a.host!==location.host&&e.client.capture("$outbound_click",{$url:se(a),$outbound_host:a.host})};document.addEventListener("click",s,!0),i.push(()=>document.removeEventListener("click",s,!0))}if(t.siteSearch!==!1){let s=typeof t.siteSearch=="object"&&t.siteSearch.params?t.siteSearch.params:ae,u=!0;i.push(()=>{u=!1}),e.onCapture(c=>{if(!u||c.event!=="$pageview"||!n())return;let a=new URLSearchParams(location.search);for(let l of s){let r=a.get(l)?.trim();if(r)return void e.client.capture("$site_search",{$search_term:r.slice(0,200),$search_param:l})}})}return()=>i.forEach(s=>s())}function Ue(e,t={}){e.capture("$page_not_found",{$status:404,...t})}var Xe=[25,50,75],Fe="data-lc-media-title";function P(e){let t=e.currentSrc||e.src;if(!t||t.startsWith("blob:")||t.startsWith("data:"))return"";try{let n=new URL(t,location.href);return`${n.origin}${n.pathname}`}catch{return""}}var qe=e=>(e.getAttribute(Fe)??e.getAttribute("title")??e.getAttribute("aria-label")??"").trim().slice(0,200);function ce(e,t,n){if(t.media===!1)return()=>{};let o=new WeakMap,i=a=>{let l={$media_type:a instanceof HTMLVideoElement?"video":"audio",$media_src:P(a)},r=qe(a);return r&&(l.$media_title=r),Number.isFinite(a.duration)&&(l.$media_duration=Math.round(a.duration)),l},s=a=>{let l=P(a);if(!l)return null;let r=o.get(a);return(!r||r.src!==l)&&o.set(a,r={src:l,played:!1,reached:new Set,done:!1}),r},u=a=>{let l=a.target;if(!(l instanceof HTMLMediaElement)||!n())return;let r=s(l);if(r)if(a.type==="play"){if(r.done&&Object.assign(r,{played:!1,reached:new Set,done:!1}),r.played)return;r.played=!0,e.client.capture("$media_play",i(l))}else if(a.type==="timeupdate"){if(!r.played||r.done||!Number.isFinite(l.duration)||l.duration<=0)return;let p=l.currentTime/l.duration*100;for(let d of Xe)p>=d&&!r.reached.has(d)&&(r.reached.add(d),e.client.capture("$media_progress",{...i(l),$media_progress:d}))}else a.type==="ended"&&r.played&&!r.done&&(r.done=!0,e.client.capture("$media_complete",i(l)))},c=["play","timeupdate","ended"];return c.forEach(a=>document.addEventListener(a,u,!0)),()=>c.forEach(a=>document.removeEventListener(a,u,!0))}function ue(e=()=>performance.now()){let t=()=>document.visibilityState!=="hidden",n=0,o=t()?e():null,i=()=>{t()?o===null&&(o=e()):(o!==null&&(n+=e()-o),o=null)};return document.addEventListener("visibilitychange",i),{read:()=>Math.round(n+(o===null?0:e()-o)),reset:()=>{n=0,o=t()?e():null},stop:()=>document.removeEventListener("visibilitychange",i)}}pe();var de=255,Ge=new Set(["input","textarea","select","option"]),Ye="[data-lc-mask],.lc-mask,[data-lc-no-capture],.lc-no-capture,[data-lc-block]",Be=new Set(["value","password","autocomplete"]),ze=/(?:\d[ -]?){9,}/,R=new WeakMap,N=new WeakMap;function fe(e,t){let n=N.get(e);if(n)return new Promise(o=>{let i=setTimeout(o,t);n.then(()=>(clearTimeout(i),o()))})}function me(e){return Array.isArray(e)?e.filter(t=>{if(!t||typeof t!="object")return!1;let n=t;return typeof n.name=="string"&&n.name!==""&&!n.name.startsWith("$")&&typeof n.selector=="string"&&(n.source==="text"||n.source==="attribute"&&typeof n.attribute=="string")&&Array.isArray(n.events)}):[]}function Ve(e){if(!e||Ge.has(e.tagName.toLowerCase())||e.isContentEditable)return!1;try{return!e.closest(Ye)}catch{return!1}}function Qe(e,t){if(e.source==="attribute"){let o=(e.attribute??"").toLowerCase();if(!o||Be.has(o)||o.startsWith("on"))return;let i=t.getAttribute(o);return i===null?void 0:i.slice(0,de)}let n=(t.textContent??"").replace(/\s+/g," ").trim();if(!(!n||ze.test(n)))return n.slice(0,de)}function W(e,t,n,o=location.href){let i={};for(let s of e){if(!s.events.includes(t)||s.url&&!j([s.url],o))continue;let u=null;try{u=s.scope==="target"?t==="click"&&n?n.closest(s.selector):null:document.querySelector(s.selector)}catch{continue}if(!Ve(u))continue;let c=Qe(s,u);c!==void 0&&(i[s.name]=c)}return i}function ge(e){let t=!0,n=e.loadConfig().then(o=>{t&&R.set(e,me(o?.snapshot_properties)),N.delete(e)});return N.set(e,n),e.clickExtras.push((o,i)=>t?W(R.get(e)??[],"click",i):{}),()=>{t=!1,R.delete(e)}}function he(e){let t=R.get(e);return t?.length?W(t,"pageview"):{}}function ye(e){return!!R.get(e)?.some(t=>t.events.includes("pageview"))}var Ze=e=>{try{return new URL(e).pathname}catch{return e}};function Je(e){for(let t of e===void 0?[]:Array.isArray(e)?e:[e])try{let n=document.querySelector(t);if(n)return n}catch{}}function _e(e){let t=0,n=0,o=()=>{let i=Je(e),s=document.documentElement,u=i?i.scrollHeight:Math.max(s.scrollHeight,document.body?.scrollHeight??0),c=i?i.scrollTop:window.scrollY||window.pageYOffset||0,a=Math.min(u,c+(i?i.clientHeight:window.innerHeight));a>t&&(t=a,n=u>0?Math.min(100,Math.round(a/u*100)):0)};return o(),window.addEventListener("scroll",o,{passive:!0,capture:!0}),window.addEventListener("resize",o,{passive:!0}),{read:()=>({pct:n,px:t}),stop:()=>{window.removeEventListener("scroll",o,{capture:!0}),window.removeEventListener("resize",o)}}}var et=800,tt=e=>e.core.hasConsent("analytics")||e.core.consent.resolving;function nt(e){return e==="history"?{path:!0,search:!0}:e==="hash"?{path:!0,search:!0,hash:!0}:typeof e=="object"?e:void 0}function rt(e,t,n){try{let o=new URL(e),i=new URL(t);return!!(n.path&&o.pathname!==i.pathname||n.search&&o.search!==i.search||n.hash&&o.hash!==i.hash)}catch{return e!==t}}function L(e,t,n={}){let o=n.views??!0,i=n.leave??!0,s=nt(t),u=e.config.scrollRoot,c=location.href,a=c,l=Date.now(),r=_e(u),p=ue(),d,f=()=>{if(!i||d===c)return;d=c;let{pct:y,px:E}=r.read();e.client.capture("$pageleave",{$current_url:c,$scroll_depth:y,$scroll_depth_px:E,$engagement_time_ms:p.read()})},h=!1,m=(y,E={})=>{if(!o)return;let{core:_}=e;if(!_.hasConsent("analytics")&&!_.anonymousOnReject&&!(_.consent.pending&&_.consent.queueBeforeConsent)){if(!h){h=!0;let A=()=>{h&&(h=!1,m())};e.whenConsented(A),_.onChange(M=>{M==="consent"&&_.anonymousOnReject&&A()})}return}e.client.capture("$pageview",{...he(e),...y===void 0?{}:{$referrer:y},...E})},g,v=()=>{let y=g;g=void 0,y?.()},S=y=>{if(location.href===a)return;let E=a;if(a=location.href,!s||!rt(E,a,s))return;let _=c;f(),r.stop();let A=new Date(l);c=location.href,l=Date.now(),r=_e(u),p.reset();let M={$navigation_type:y,$prev_pageview_pathname:Ze(_),$prev_pageview_duration:Math.round((l-A.getTime())/100)/10};ye(e)?setTimeout(()=>m(_,M),0):(v(),g=()=>m(_,M),queueMicrotask(v))};e.onUnload(f);let D=tt(e)?fe(e,et):void 0;if(D?(g=()=>m(),e.onUnload(v),D.then(v)):m(),!s)return()=>(r.stop(),p.stop());let{pushState:U,replaceState:X}=history;history.pushState=function(...y){v(),U.apply(this,y),S("pushState")},history.replaceState=function(...y){v(),X.apply(this,y),S("replaceState")};let F=()=>S("popstate"),q=()=>S("hashchange");return window.addEventListener("popstate",F),s.hash&&window.addEventListener("hashchange",q),()=>{window.removeEventListener("hashchange",q),history.pushState=U,history.replaceState=X,window.removeEventListener("popstate",F),r.stop(),p.stop()}}var Wt=e=>{let t=[],n=e.config.autocapture,o=!1,i=!1;if(n!==!1){let c=typeof n=="object"?n:{},a=()=>!o&&!(c.urlIgnorelist?.length&&H(c.urlIgnorelist)),l=()=>!i;t.push(te(e,c,a,l),oe(e,c,a,l),le(e,c,a),G(e,c,a),K(e,c,a),ce(e,c,a),ge(e)),n===void 0&&e.loadConfig().then(r=>o=r?.autocapture===!1),e.loadConfig().then(r=>i=r?.autocapture_inputs===!1)}let s=e.config.capturePageview??"history",u=e.config.capturePageleave??"if_capture_pageview";return s!==!1&&u!==!1?t.push(L(e,s)):s!==!1?t.push(L(e,s,{leave:!1})):u===!0&&t.push(L(e,"history",{views:!1})),()=>t.forEach(c=>c())};export{ie as DOWNLOAD_EXTENSIONS,B as MASKED,ae as SEARCH_PARAMS,w as attrProps,Wt as autocapture,k as buildChain,x as chainToString,J as cssSelector,z as isStepper,re as maskCopied,P as mediaSrc,W as readSnapshot,me as snapshotRules,Ue as tag404};
|
|
1
|
+
var ve=(e,t)=>()=>(e&&(t=e(e=0)),t);function Ge(e){return e.startsWith("re:")?e.slice(3):e.split("*").map(t=>t.replace(/[.+?^${}()|[\]\\]/g,"\\$&")).join(".*")}function j(e,t){return!!e?.some(n=>{try{return new RegExp(Ge(n),"i").test(t)}catch{return!1}})}var pe=ve(()=>{"use strict"});var be='[data-lc-region="article"]';function K(e,t,n){if(t.articles===!1)return()=>{};let r;e.loadConfig().then(m=>{typeof m?.article_selector=="string"&&(r=m.article_selector)});let i=()=>{for(let m of[t.articleSelector,r,be])if(m)try{let g=document.querySelector(m);if(g)return g}catch{}return null},s=location.href,p=location.pathname,l=null,a=0,c=!1,o=()=>{if(l??=i(),!l)return;let m=l.getBoundingClientRect();if(m.height<=0)return;let g=Math.round(Math.min(100,Math.max(0,(window.innerHeight-m.top)/m.height*100)));a=Math.max(a,g);let v=l.querySelector("h1,h2");v&&v.getBoundingClientRect().bottom<0&&(c=!0)},u=()=>{!l||!n()||(o(),e.client.capture("$article_read",{$article_id:(l.getAttribute("data-lc-article-id")??"").trim().slice(0,200)||p,$article_depth:a,$article_finished:a>=90,$article_headline_exit:!c&&a<25}),l=null)},d=()=>{u(),l=null,a=0,c=!1,s=location.href,p=location.pathname},f=()=>location.href!==s?d():o(),h=new MutationObserver(f);return h.observe(document.documentElement,{childList:!0,subtree:!0}),window.addEventListener("scroll",f,{passive:!0}),e.onUnload(u),o(),()=>{h.disconnect(),window.removeEventListener("scroll",f)}}var T="data-lc-content",Ee="data-lc-content-piece",we="data-lc-content-target";var O=(e,t)=>(e.getAttribute(t)??"").trim().slice(0,200);function G(e,t,n){if(t.contentBlocks===!1||typeof IntersectionObserver>"u")return()=>{};let r=new WeakSet,i=o=>{let u={$content_name:O(o,T)},d=O(o,Ee),f=O(o,we);return d&&(u.$content_piece=d),f&&(u.$content_target=f),u},s=location.href,p=new IntersectionObserver(o=>{for(let u of o)!u.isIntersecting||r.has(u.target)||!n()||(r.add(u.target),e.client.capture("$content_impression",i(u.target)))},{threshold:.5}),l=o=>o.querySelectorAll(`[${T}]`).forEach(u=>p.observe(u));l(document);let a=new MutationObserver(()=>{location.href!==s&&(s=location.href,p.disconnect(),document.querySelectorAll(`[${T}]`).forEach(o=>r.delete(o))),l(document)});a.observe(document.documentElement,{childList:!0,subtree:!0});let c=o=>{let u=o.target?.closest?.(`[${T}]`);u&&n()&&e.client.capture("$content_interaction",{...i(u),$content_interaction_type:"click"})};return document.addEventListener("click",c,!0),()=>{p.disconnect(),a.disconnect(),document.removeEventListener("click",c,!0)}}var ke=new Set(["input","textarea","select","option"]),xe=["name","type","role","aria-label","title","alt","placeholder"],Ce=new Set(["aria-label","aria-description","title","alt","placeholder","value","label"]),Re=/(?:\d[ -]?){9,}/;function Se(e){if(ke.has(e.tagName.toLowerCase())||e.isContentEditable)return;let t="";for(let n of Array.from(e.childNodes))n.nodeType===3&&(t+=n.textContent??"");if(t=t.replace(/\s+/g," ").trim(),!(!t||Re.test(t)))return t.slice(0,255)}function Y(e){if(!e?.length)return()=>!1;let t=e.map(n=>n.toLowerCase());return n=>t.some(r=>r.endsWith("*")?n.startsWith(r.slice(0,-1)):n===r)}var B="***";function w(e){let t={};for(let n=e,r=0;n&&r<10;n=n.parentElement,r++)for(let i of Array.from(n.attributes)){let s=i.name.startsWith("data-lc-attr-")?i.name.slice(13):"";s&&!(s in t)&&!s.startsWith("$")&&(t[s]=i.value.slice(0,255))}return t}function Ae(e,t,n,r,i){let s=e.parentElement,p=s?Array.from(s.children):[e],l={tag_name:e.tagName.toLowerCase(),nth_child:p.indexOf(e)+1,nth_of_type:p.filter(u=>u.tagName===e.tagName).indexOf(e)+1},a=(e.getAttribute("class")??"").split(/\s+/).filter(Boolean);a.length&&!r("class")&&(l.classes=a),e.id&&!r("id")&&(l.attr__id=i("id",e.id));let c=e.getAttribute("href");c&&!r("href")&&(l.href=i("href",c.slice(0,1024)));let o={};for(let u of Array.from(e.attributes))(u.name.startsWith("data-lc-")||xe.includes(u.name))&&!r(u.name)&&(n||!Ce.has(u.name))&&(o[u.name]=i(u.name,u.value.slice(0,255)));if(Object.keys(o).length&&(l.attrs=o),t){let u=Se(e);u&&(l.text=u)}return l}function k(e,t,n,r,i={}){let s=[],p=Y(r),l=Y(i.allow),a=i.maskAll?(o,u)=>l(o)?u:B:(o,u)=>u,c=t;for(let o=e;o&&s.length<10;o=o.parentElement)s.push(Ae(o,c,t,p,a)),(o===n||!n)&&(c=!1);return s}var $=e=>e.replace(/(["\\])/g,"\\$1");function x(e){return e.map(t=>{let n=t.tag_name+(t.classes?"."+t.classes.join("."):"")+":";t.attr__id&&(n+=`attr__id="${$(t.attr__id)}"`),t.href&&(n+=`href="${$(t.href)}"`),t.text&&(n+=`text="${$(t.text)}"`);for(let[r,i]of Object.entries(t.attrs??{}))n+=`attr__${r}="${$(i)}"`;return n+`nth-child="${t.nth_child}"nth-of-type="${t.nth_of_type}"`}).join(";")}var b=[],Me=/^[+\-−–‹›<>«»←→↑↓▲▼▶◀^ˇ˄˅]$/,Te=/\b(increase|decrease|increment|decrement|plus|minus|add one|remove one|next|prev|previous|scroll (left|right))\b/i,$e=/(^|[-_\s])(stepper|spinner|quantity|qty|increment|decrement|inc|dec|plus|minus|carousel|slider|swiper|slick|glide|splide|arrow|next|prev)([-_\s]|$)/i,Le="button,[role=button],a,input[type=button],input[type=submit],[role=spinbutton]";function z(e,t=[]){if(t.length&&e.closest(t.join(","))||e.closest("input[type=number],[role=spinbutton],[role=slider]"))return!0;let n=e.closest(Le)??e,r=`${n.getAttribute("aria-label")??""} ${n.getAttribute("title")??""}`;if(Me.test((n.textContent??"").trim())||Te.test(r))return!0;for(let i=n,s=0;i&&s<3;i=i.parentElement,s++)if($e.test(i.getAttribute("class")??""))return!0;return!1}var Oe=()=>typeof getSelection=="function"?(getSelection()?.toString()??"")!=="":!1;function V(e,t=Date.now(),n={},r){if(r&&n.ignoreSelectors?.length&&r.closest(n.ignoreSelectors.join(",")))return{};if(r&&n.suppressSteppers!==!1&&z(r,n.stepperSelectors))return{};if(n.ignoreTextSelection!==!1&&Oe())return{};let i=n.windowMs??1e3,s=n.radiusPx??30;for(b.length&&t<b[b.length-1].t&&(b.length=0),b.push({t,x:e.clientX,y:e.clientY});b.length&&t-b[0].t>i;)b.shift();let p=b.filter(l=>Math.hypot(l.x-e.clientX,l.y-e.clientY)<=s).length;return p>=(n.count??3)?{$rageclick:!0,$rageclick_count:p}:{}}function Q(e,t,n=700){if(typeof MutationObserver>"u")return;let r=!1,i=new MutationObserver(()=>r=!0);i.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let s=()=>{r=!0};window.addEventListener("scroll",s,{capture:!0,passive:!0}),document.addEventListener("selectionchange",s);let p=()=>{i.disconnect(),window.removeEventListener("scroll",s,{capture:!0}),document.removeEventListener("selectionchange",s)},l=setTimeout(()=>{p(),!r&&document.visibilityState!=="hidden"&&e.client.capture("$deadclick_hint",{$selector:t,$no_mutation_ms:n})},n);e.onUnload(()=>{clearTimeout(l),p()})}var Z=/^[A-Za-z_][\w-]*$/,He=5;function J(e){let t=[];for(let n=e;n&&t.length<He;n=n.parentElement){let r=n.tagName.toLowerCase();if(n.id&&Z.test(n.id)){t.unshift(`${r}#${n.id}`);break}let i=(n.getAttribute("class")??"").split(/\s+/).filter(s=>Z.test(s)).slice(0,2);t.unshift(r+i.map(s=>`.${s}`).join(""))}return t.join(" ")}function ee(e,t,n,r,i={}){let s={$selector:J(n),$el_interactive:r};(t.clientX||t.clientY||t.detail)&&(s.$click_x=Math.round(t.clientX+(window.scrollX||0)),s.$click_y=Math.round(t.clientY+(window.scrollY||0))),i.rageClicks!==!1&&!n.closest(".lc-no-rageclick,[data-lc-no-rageclick]")&&Object.assign(s,V(t,Date.now(),i.rageClicks||{},n));let p=i.deadClicks;!r&&t.isTrusted&&p!==!1&&!(p?.ignoreSelectors?.length&&n.closest(p.ignoreSelectors.join(",")))&&Q(e,s.$selector,p?.waitMs);for(let l of e.clickExtras)Object.assign(s,l(t,n));return s}var Ie="a,button,input,select,textarea,label,summary,[role=button],[role=link],[data-lc-capture]",Pe="[data-lc-ignore]",H=e=>e.some(t=>typeof t=="string"?location.href.includes(t):t.test(location.href)),je=e=>!e?.length||H(e),I=e=>({maskAll:e.maskAllAttributes,allow:e.attributeAllowlist}),C=(e,t)=>!!e.closest(Pe)||!!(t.denySelectors?.length&&e.closest(t.denySelectors.join(",")));function te(e,t,n,r=()=>!0){let i=t.events??["click","change","submit"],s=0,p=c=>{let o=c.target;!n()||!r()||c.isComposing||!(o instanceof Element)||C(o,t)||o instanceof HTMLInputElement&&o.type==="password"||(s+=1)},l=c=>o=>{if(!n()||c!=="click"&&!r())return;let u=o.target;if(!(u instanceof Element)||C(u,t)||t.allowSelectors?.length&&!u.closest(t.allowSelectors.join(","))||t.elementAllowlist?.length&&!u.closest(t.elementAllowlist.join(","))||!je(t.urlAllowlist)||c==="change"&&!/^(input|select|textarea)$/i.test(u.tagName)||u instanceof HTMLInputElement&&u.type==="password")return;let d=u.closest(Ie);if(c==="click"&&!d&&!t.allowSelectors?.length)return;let f=k(u,t.captureText??!0,d??void 0,t.attributeIgnore,I(t)),h=f.find(g=>g.text)?.text,m=s;s=0,e.client.capture("$autocapture",{...w(u),$event_type:c,...m>0?{$keystroke_count:m}:{},$elements:f,$elements_chain:x(f),...h?{$el_text:h}:{},...c==="click"?ee(e,o,u,!!d,t):{}})};e.autocaptureClicks=i.includes("click");let a=i.map(c=>[c,l(c)]);for(let[c,o]of a)document.addEventListener(c,o,!0);return document.addEventListener("keydown",p,!0),()=>{for(let[c,o]of a)document.removeEventListener(c,o,!0);document.removeEventListener("keydown",p,!0)}}var Ne='[contenteditable]:not([contenteditable="false"])',ne="input,textarea,select",We=255;function re(e){return e.replace(/\d(?:[ -]?\d){5,}/g,"***").replace(/[^\s@]+@[^\s@]+\.[^\s@]+/g,"***").replace(/\s+/g," ").trim().slice(0,We)}var De=e=>e?e instanceof Element?e:e.parentElement:null;function oe(e,t,n,r=()=>!0){let i=t.events??["click","change","submit"],s=t.contentEditable!==!1&&i.includes("change"),p=new WeakSet,l=d=>{let f=k(d,!1,d,t.attributeIgnore,I(t));return{...w(d),$elements:f,$elements_chain:x(f)}},a=d=>{let f=d instanceof Element?d.closest(Ne):null;return f&&!C(f,t)?f:null},c=d=>{let f=n()&&r()?a(d.target):null;f&&p.add(f)},o=d=>{let f=a(d.target);!f||!p.has(f)||d.relatedTarget instanceof Node&&f.contains(d.relatedTarget)||(p.delete(f),n()&&r()&&e.client.capture("$autocapture",{$event_type:"change",$el_contenteditable:!0,...l(f)}))},u=d=>{if(!n()||!t.copyCut)return;let f=typeof getSelection=="function"?getSelection():null,h=d.target instanceof Element?d.target:null,m=De(f?.anchorNode)??h;if(!m||C(m,t)||m.closest(ne)||h?.closest(ne))return;let g=t.captureCopiedText?re(f?.toString()??""):"";e.client.capture("$copy_autocapture",{$copy_type:d.type,...l(m),...g?{$selected_content:g}:{}})};return s&&(document.addEventListener("input",c,!0),document.addEventListener("focusout",o,!0)),document.addEventListener("copy",u,!0),document.addEventListener("cut",u,!0),()=>{document.removeEventListener("input",c,!0),document.removeEventListener("focusout",o,!0),document.removeEventListener("copy",u,!0),document.removeEventListener("cut",u,!0)}}var Ue="[data-lc-ignore]",ie=["pdf","zip","gz","tar","rar","7z","doc","docx","xls","xlsx","ppt","pptx","csv","epub","dmg","exe","msi","pkg","apk","iso","mp3","mp4","mov"],ae=["q","s","search","query"],se=e=>e.origin+e.pathname;function le(e,t,n){let r=Array.isArray(t.fileDownloads)?t.fileDownloads.map(s=>s.toLowerCase()):ie,i=[];if(t.outboundLinks!==!1||t.fileDownloads!==!1){let s=p=>{let l=p.target instanceof Element?p.target.closest("a[href]"):null;if(!l||!n()||l.closest(Ue))return;let a;try{a=new URL(l.href,location.href)}catch{return}if(a.protocol!=="http:"&&a.protocol!=="https:")return;let c=decodeURIComponent(a.pathname.split("/").pop()??""),o=c.includes(".")?c.split(".").pop().toLowerCase():"";t.fileDownloads!==!1&&(l.hasAttribute("download")||r.includes(o))?e.client.capture("$file_download",{$url:se(a),$file_name:c,$file_extension:o}):t.outboundLinks!==!1&&a.host!==location.host&&e.client.capture("$outbound_click",{$url:se(a),$outbound_host:a.host})};document.addEventListener("click",s,!0),i.push(()=>document.removeEventListener("click",s,!0))}if(t.siteSearch!==!1){let s=typeof t.siteSearch=="object"&&t.siteSearch.params?t.siteSearch.params:ae,p=!0;i.push(()=>{p=!1}),e.onCapture(l=>{if(!p||l.event!=="$pageview"||!n())return;let a=new URLSearchParams(location.search);for(let c of s){let o=a.get(c)?.trim();if(o)return void e.client.capture("$site_search",{$search_term:o.slice(0,200),$search_param:c})}})}return()=>i.forEach(s=>s())}function Xe(e,t={}){e.capture("$page_not_found",{$status:404,...t})}var Fe=[25,50,75],qe="data-lc-media-title";function P(e){let t=e.currentSrc||e.src;if(!t||t.startsWith("blob:")||t.startsWith("data:"))return"";try{let n=new URL(t,location.href);return`${n.origin}${n.pathname}`}catch{return""}}var Ke=e=>(e.getAttribute(qe)??e.getAttribute("title")??e.getAttribute("aria-label")??"").trim().slice(0,200);function ce(e,t,n){if(t.media===!1)return()=>{};let r=new WeakMap,i=a=>{let c={$media_type:a instanceof HTMLVideoElement?"video":"audio",$media_src:P(a)},o=Ke(a);return o&&(c.$media_title=o),Number.isFinite(a.duration)&&(c.$media_duration=Math.round(a.duration)),c},s=a=>{let c=P(a);if(!c)return null;let o=r.get(a);return(!o||o.src!==c)&&r.set(a,o={src:c,played:!1,reached:new Set,done:!1}),o},p=a=>{let c=a.target;if(!(c instanceof HTMLMediaElement)||!n())return;let o=s(c);if(o)if(a.type==="play"){if(o.done&&Object.assign(o,{played:!1,reached:new Set,done:!1}),o.played)return;o.played=!0,e.client.capture("$media_play",i(c))}else if(a.type==="timeupdate"){if(!o.played||o.done||!Number.isFinite(c.duration)||c.duration<=0)return;let u=c.currentTime/c.duration*100;for(let d of Fe)u>=d&&!o.reached.has(d)&&(o.reached.add(d),e.client.capture("$media_progress",{...i(c),$media_progress:d}))}else a.type==="ended"&&o.played&&!o.done&&(o.done=!0,e.client.capture("$media_complete",i(c)))},l=["play","timeupdate","ended"];return l.forEach(a=>document.addEventListener(a,p,!0)),()=>l.forEach(a=>document.removeEventListener(a,p,!0))}function ue(e=()=>performance.now()){let t=()=>document.visibilityState!=="hidden",n=0,r=t()?e():null,i=()=>{t()?r===null&&(r=e()):(r!==null&&(n+=e()-r),r=null)};return document.addEventListener("visibilitychange",i),{read:()=>Math.round(n+(r===null?0:e()-r)),reset:()=>{n=0,r=t()?e():null},stop:()=>document.removeEventListener("visibilitychange",i)}}pe();var de=255,Ye=new Set(["input","textarea","select","option"]),Be="[data-lc-mask],.lc-mask,[data-lc-no-capture],.lc-no-capture,[data-lc-block]",ze=new Set(["value","password","autocomplete"]),Ve=/(?:\d[ -]?){9,}/,R=new WeakMap,N=new WeakMap;function fe(e,t){let n=N.get(e);if(n)return new Promise(r=>{let i=setTimeout(r,t);n.then(()=>(clearTimeout(i),r()))})}function me(e){return Array.isArray(e)?e.filter(t=>{if(!t||typeof t!="object")return!1;let n=t;return typeof n.name=="string"&&n.name!==""&&!n.name.startsWith("$")&&typeof n.selector=="string"&&(n.source==="text"||n.source==="attribute"&&typeof n.attribute=="string")&&Array.isArray(n.events)}):[]}function Qe(e){if(!e||Ye.has(e.tagName.toLowerCase())||e.isContentEditable)return!1;try{return!e.closest(Be)}catch{return!1}}function Ze(e,t){if(e.source==="attribute"){let r=(e.attribute??"").toLowerCase();if(!r||ze.has(r)||r.startsWith("on"))return;let i=t.getAttribute(r);return i===null?void 0:i.slice(0,de)}let n=(t.textContent??"").replace(/\s+/g," ").trim();if(!(!n||Ve.test(n)))return n.slice(0,de)}function W(e,t,n,r=location.href){let i={};for(let s of e){if(!s.events.includes(t)||s.url&&!j([s.url],r))continue;let p=null;try{p=s.scope==="target"?t==="click"&&n?n.closest(s.selector):null:document.querySelector(s.selector)}catch{continue}if(!Qe(p))continue;let l=Ze(s,p);l!==void 0&&(i[s.name]=l)}return i}function ge(e){let t=!0,n=e.loadConfig().then(r=>{t&&R.set(e,me(r?.snapshot_properties)),N.delete(e)});return N.set(e,n),e.clickExtras.push((r,i)=>t?W(R.get(e)??[],"click",i):{}),()=>{t=!1,R.delete(e)}}function he(e){let t=R.get(e);return t?.length?W(t,"pageview"):{}}function ye(e){return!!R.get(e)?.some(t=>t.events.includes("pageview"))}var Je=e=>{try{return new URL(e).pathname}catch{return e}};function et(e){for(let t of e===void 0?[]:Array.isArray(e)?e:[e])try{let n=document.querySelector(t);if(n)return n}catch{}}function _e(e){let t=0,n=0,r=()=>{let i=et(e),s=document.documentElement,p=i?i.scrollHeight:Math.max(s.scrollHeight,document.body?.scrollHeight??0),l=i?i.scrollTop:window.scrollY||window.pageYOffset||0,a=Math.min(p,l+(i?i.clientHeight:window.innerHeight));a>t&&(t=a,n=p>0?Math.min(100,Math.round(a/p*100)):0)};return r(),window.addEventListener("scroll",r,{passive:!0,capture:!0}),window.addEventListener("resize",r,{passive:!0}),{read:()=>({pct:n,px:t}),stop:()=>{window.removeEventListener("scroll",r,{capture:!0}),window.removeEventListener("resize",r)}}}var tt=800,nt=e=>e.core.hasConsent("analytics")||e.core.consent.resolving;function rt(e){return e==="history"?{path:!0,search:!0}:e==="hash"?{path:!0,search:!0,hash:!0}:typeof e=="object"?e:void 0}function ot(e,t,n){try{let r=new URL(e),i=new URL(t);return!!(n.path&&r.pathname!==i.pathname||n.search&&r.search!==i.search||n.hash&&r.hash!==i.hash)}catch{return e!==t}}function L(e,t,n={}){let r=n.views??!0,i=n.leave??!0,s=rt(t),p=e.config.scrollRoot,l=location.href,a=l,c=Date.now(),o=_e(p),u=ue(),d,f=()=>{if(!i||d===l)return;d=l;let{pct:y,px:E}=o.read();e.client.capture("$pageleave",{$current_url:l,$scroll_depth:y,$scroll_depth_px:E,$engagement_time_ms:u.read()})},h=!1,m=(y,E={})=>{if(!r)return;let{core:_}=e;if(!_.hasConsent("analytics")&&!_.anonymousOnReject&&!(_.consent.pending&&_.consent.queueBeforeConsent)){if(!h){h=!0;let A=()=>{h&&(h=!1,m())};e.whenConsented(A),_.onChange(M=>{M==="consent"&&_.anonymousOnReject&&A()})}return}e.client.capture("$pageview",{...he(e),...y===void 0?{}:{$referrer:y},...E})},g,v=()=>{let y=g;g=void 0,y?.()},S=y=>{if(location.href===a)return;let E=a;if(a=location.href,!s||!ot(E,a,s))return;let _=l;f(),o.stop();let A=new Date(c);l=location.href,c=Date.now(),o=_e(p),u.reset();let M={$navigation_type:y,$prev_pageview_pathname:Je(_),$prev_pageview_duration:Math.round((c-A.getTime())/100)/10};ye(e)?setTimeout(()=>m(_,M),0):(v(),g=()=>m(_,M),queueMicrotask(v))};e.onUnload(f);let D=nt(e)?fe(e,tt):void 0;if(D?(g=()=>m(),e.onUnload(v),D.then(v)):m(),!s)return()=>(o.stop(),u.stop());let{pushState:U,replaceState:X}=history;history.pushState=function(...y){v(),U.apply(this,y),S("pushState")},history.replaceState=function(...y){v(),X.apply(this,y),S("replaceState")};let F=()=>S("popstate"),q=()=>S("hashchange");return window.addEventListener("popstate",F),s.hash&&window.addEventListener("hashchange",q),()=>{window.removeEventListener("hashchange",q),history.pushState=U,history.replaceState=X,window.removeEventListener("popstate",F),o.stop(),u.stop()}}var Dt=e=>{let t=[],n=e.config.autocapture,r=!1,i=!1;if(n!==!1){let l=typeof n=="object"?n:{},a=()=>!r&&!(l.urlIgnorelist?.length&&H(l.urlIgnorelist)),c=()=>!i;t.push(te(e,l,a,c),oe(e,l,a,c),le(e,l,a),G(e,l,a),K(e,l,a),ce(e,l,a),ge(e)),n===void 0&&e.loadConfig().then(o=>r=o?.autocapture===!1),e.loadConfig().then(o=>i=o?.autocapture_inputs===!1)}let s=e.config.capturePageview??"history",p=e.config.capturePageleave??"if_capture_pageview";return s!==!1&&p!==!1?t.push(L(e,s)):s!==!1?t.push(L(e,s,{leave:!1})):p===!0&&t.push(L(e,"history",{views:!1})),()=>t.forEach(l=>l())};export{ie as DOWNLOAD_EXTENSIONS,B as MASKED,ae as SEARCH_PARAMS,w as attrProps,Dt as autocapture,k as buildChain,x as chainToString,J as cssSelector,z as isStepper,re as maskCopied,P as mediaSrc,W as readSnapshot,me as snapshotRules,Xe as tag404};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as BrowserConfig, M as Module, e as Client } from './types-
|
|
1
|
+
import { d as BrowserConfig, M as Module, e as Client } from './types-Chfj1wdu.js';
|
|
2
2
|
|
|
3
|
-
declare const LIB_VERSION = "0.1.
|
|
3
|
+
declare const LIB_VERSION = "0.1.12";
|
|
4
4
|
declare const DEFAULT_HOST = "https://capture.lucidace.com";
|
|
5
5
|
/** Build a client from the shared core plus the given modules (pass none for the smallest bundle). */
|
|
6
6
|
declare function createClient(apiKey: string, config?: BrowserConfig, modules?: Module[]): Client;
|
package/dist/consent.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { M as Module, H as Host, C as ConsentSource } from './types-
|
|
2
|
-
export { B as BannerOptions, a as BannerPosition, b as BannerTexts, c as ConsentUi } from './types-
|
|
1
|
+
import { M as Module, H as Host, C as ConsentSource } from './types-Chfj1wdu.js';
|
|
2
|
+
export { B as BannerOptions, a as BannerPosition, b as BannerTexts, c as ConsentUi } from './types-Chfj1wdu.js';
|
|
3
3
|
import { ConsentState } from '@lucida-analytics/sdk-core';
|
|
4
4
|
|
|
5
5
|
type Update = {
|
package/dist/core.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as BrowserConfig, e as Client } from './types-
|
|
2
|
-
export { F as FlagValue, H as Host, M as Module, P as Persistence } from './types-
|
|
3
|
-
export { c as createClient } from './client-
|
|
1
|
+
import { d as BrowserConfig, e as Client } from './types-Chfj1wdu.js';
|
|
2
|
+
export { F as FlagValue, H as Host, M as Module, P as Persistence } from './types-Chfj1wdu.js';
|
|
3
|
+
export { c as createClient } from './client-C9F2fWI4.js';
|
|
4
4
|
import '@lucida-analytics/sdk-core';
|
|
5
5
|
|
|
6
6
|
/** Core-only client: capture, identity, sessions, consent, transport. No autocapture, no flags. */
|
package/dist/core.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var J="lc_consent";function ye(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 me=["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 me)typeof r[i]=="boolean"&&(this.state[i]=r[i]);this.decided=me.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 me)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,A=0;function Ke(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=Ke(2);A=((i[0]??0)<<8|(i[1]??0))&1023}else A++,A>4095&&(Q++,A=0);let e=Ke(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|A>>8,t[7]=A&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 Ge="lc_identity",X=class{constructor(e,t,s=!1,r=!1){this.storage=e;this.cookieless=s;let i=e.get(Ge),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(Ge,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 Ye(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(!Ye(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 ve="lc_session";function Je(n,e,t){return typeof n=="number"&&Number.isInteger(n)&&n>=e&&n<=t?n*6e4:void 0}var Ft=6e4,Nt=10*36e5,Bt=24*36e5,Ut=/^([0-9a-f]{8})-?([0-9a-f]{4})-7[0-9a-f]{3}-/i;function qt(n,e){let t=Ut.exec(n);if(!t)return!0;let s=parseInt(t[1]+t[2],16);return s-e<=6e4&&e-s<=Bt}var ee=class{constructor(e,t={}){this.storage=e;this.o=t;this.idleMs=Math.min(Nt,Math.max(Ft,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=Je(e.session_idle_minutes,1,600)??this.idleMs),this.o.maxMs===void 0&&(this.maxMs=Je(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(ve);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&&qt(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(ve,JSON.stringify(r)),{sessionId:r.id,windowId:this.windowId,isNew:u}}startedAt(){return this.read()?.start}reset(){this.storage.remove(ve)}};function Qe(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=Qe(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=Qe(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 Ht(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:Ht(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(ye(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 Xe(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:
|
|
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=Xe(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 be(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 _e(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 Se(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 T={started:"$ai_conversation_started",message:"$ai_message",feedback:"$ai_feedback",ended:"$ai_conversation_ended",outcome:"$ai_outcome"},Wt=["resolved","unresolved","escalated","abandoned","error"],Vt=4e3,zt=2e3,et=["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"],tt=["thanks","thank you","great","perfect","awesome","helpful","that worked","works now","solved","exactly"],W=n=>Array.from(n),ke=(n,e)=>W(n).slice(0,e).join(""),Kt=0xcbf29ce484222325n,Gt=0x100000001b3n,Yt=0xffffffffffffffffn,Jt=new TextEncoder;function Qt(n){let e=Kt;for(let t of Jt.encode(n))e=(e^BigInt(t))*Gt&Yt;return e}function nt(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=Qt(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 st(n){let t=` ${n.toLowerCase().replace(/’/g,"'").replace(/[.,!?;:]/g," ").replace(/\s+/g," ").trim()} `,s=0;for(let i of et)t.includes(` ${i} `)&&(s++,t=t.split(` ${i} `).join(" "));let r=tt.filter(i=>t.includes(` ${i} `)).length;return s>r?-1:r>s?1:0}var rt=n=>W(n).filter(e=>e>="0"&&e<="9").map(Number);function Xt(n){let e=rt(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 Ze=String.raw`[\p{Alphabetic}\p{M}\p{Nd}\p{Pc}\p{Join_Control}]`,Zt=[[new RegExp(String.raw`(?<!${Ze})\p{Nd}(?:[ -]?\p{Nd}){12,18}(?!${Ze})`,"gu"),Xt],[/[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,en]];function en(n){let e=rt(n).length;return e>=10&&e<=15}var tn=n=>W(n).map(e=>/\s/u.test(e)?e:"*").join("");function xe(n){let e=n;for(let[t,s]of Zt)e=e.replace(t,r=>s(r)?tn(r):r);return e===n?void 0:e}function ot(n){if(typeof n!="string")return;let e=n.toLowerCase();return/^[0-9a-f]{32}$/.test(e)?e:void 0}var it=n=>typeof n=="string"&&Wt.includes(n)?n:void 0,q=(n,e)=>typeof n=="string"&&n?ke(n,e):void 0;function nn(n,e,t){let s=ke(e,t),r=xe(s);return r===void 0?{[n]:s}:{[n]:r,$ai_text_redacted:!0}}function at(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=nt(e);i!==void 0&&(r.$ai_text_hash=i),r.$ai_sentiment=st(e)}return s?{...r,...nn("$ai_text",e,Vt)}:r}function ct(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=ke(n.comment,zt);s.$ai_feedback_comment=xe(r)??r}return n.messageIndex!==void 0&&(s.$ai_message_index=n.messageIndex),s}function we(n,e){let t=it(n),s=q(e,64);return{...t?{$ai_outcome:t}:{},...s?{$ai_resolution:s}:{}}}function sn(){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 lt(n={}){let e={$ai_conversation_id:n.conversationId||sn()},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",ot(n.traceId)),e}var H=class{next=0;common;emit;captureText;constructor(e,t={},s=!1){this.emit=e,this.captureText=s,this.common=lt(t)}get id(){return this.common.$ai_conversation_id}send(e,t){this.emit(e,{...this.common,...t})}start(){return this.send(T.started,{}),this}message(e,t,s={}){let r=s.index??this.next,i=at(e,t,r,this.captureText);return i?(this.next=r+1,this.send(T.message,i),!0):!1}feedback(e){let t=ct(e,this.captureText);return t?(this.send(T.feedback,t),!0):!1}end(e,t){this.send(T.ended,we(e,t))}outcome(e,t){let s=we(e,t);return s.$ai_outcome?(this.send(T.outcome,s),!0):!1}};var rn=["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 dt(n,e=[]){let t=n.toLowerCase();return e.some(s=>s&&t.includes(s.toLowerCase()))?!0:rn.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"],ut="lc_click_ids";function pt(n,e=90,t=Date.now){let s,r=()=>{try{return JSON.parse(n.get(ut)??"{}")}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(ut,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 on(){return Array.from(document.querySelectorAll("meta[http-equiv]")).filter(n=>n.getAttribute("http-equiv")?.toLowerCase()==="content-security-policy").map(n=>n.getAttribute("content")??"")}function an(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 gt(n,e){if(typeof document>"u")return()=>{};!e&&on().some(an)&&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 cn=(n,e)=>n.slice(0,e);function ft(n){try{let e=new URL(n);return e.protocol==="data:"||e.protocol==="blob:"?e.protocol:e.origin+e.pathname}catch{return cn(n,64)}}function ht(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:ft(a.blockedURI??""),$csp_source_file:a.sourceFile?ft(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 ln=["chrome-extension:","moz-extension:","safari-web-extension:","ms-browser-extension:"],mt=()=>typeof location<"u"&&ln.includes(location.protocol);function dn(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 yt(n,e,t,s){if(!s)return{transport:n,fetch:e};let r=i=>dn(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 un="__LUCIDA_DEVTOOLS_HOOK__";function vt(n,e,t){let s=globalThis[un];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 pn(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 fn=["ref","referral","via","aff"];function bt(n){if(!n)return;let e=Array.isArray(n)?{params:n}:{params:n.params??fn,...n.category?{category:n.category}:{}};return e.params.length?e:void 0}function _t(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 St(){let n=new URLSearchParams(location.search),e=V.map(t=>n.get(t)??"");return e.some(Boolean)?e.join("|"):void 0}function gn(n){try{return n?new URL(n).hostname:""}catch{return""}}var hn=()=>location.href.replace(/([?&])__lc_toolbar=[^&#]*&?/,"$1").replace(/[?&]$/,"");function mn(){let n=location.hash;return n.length>1?location.pathname+n.split("?")[0]:location.pathname}function wt(n,e,t=[],s=!1){let r={$current_url:hn(),$host:location.host,$pathname:s?mn():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=pn(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:gn(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 kt(n,e,t=globalThis){e&&(t[typeof e=="string"?e:"lucida"]=n,typeof CustomEvent=="function"&&t.dispatchEvent?.(new CustomEvent("lucida:ready",{detail:n})))}var M=()=>{},Ce=()=>Promise.resolve(),xt={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:()=>M,onFlags:()=>M,onIntervention:()=>M,onConsent:()=>M,flush:Ce,shutdown:Ce,reloadFlags:Ce,loadToolbar:()=>Promise.resolve(!1),recommendations:n=>Promise.resolve({placement:n,strategy:"",items:[],shown:M,clicked:M})};function Ct(n){return new Proxy(()=>{},{get:(e,t)=>{if(!(typeof t!="string"||t==="then"))return n&&Object.hasOwn(xt,t)?xt[t]:Ct(!1)}})}var Pt=()=>Ct(!0);var $t="_lcid";var yn=(n,e)=>e.some(t=>{let s=t.replace(/^\./,"").toLowerCase();return n.toLowerCase()===s||n.toLowerCase().endsWith(`.${s}`)});function vn(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 It(n){if(!n?.length)return;let e=new URL(location.href),t=e.searchParams.get($t);if(t!==null){e.searchParams.delete($t),history.replaceState(history.state,"",e.toString());try{if(document.referrer&&!yn(new URL(document.referrer).hostname,n))return}catch{return}return vn(t)}}function Ot(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 Pe="<masked>",bn=["password","passwd","pwd","pass","token","access_token","refresh_token","id_token","secret","client_secret","api_key","apikey","key","auth","authorization","code","otp","email","ssn"],_n=["$current_url","$referrer","$initial_referrer","$initial_current_url","$last_current_url"],Et=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function Sn(n,e){let t=n,s=[...bn,...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(Et).join("|")})=[^&]*`,"gi"),`$1$2=${Pe}`)+a}return e.stripHash&&(t=t.replace(/#.*$/,"")),t}function Rt(n){let e=new RegExp(`^\\$(initial_|last_)?(${[...V,...O].map(Et).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]=Pe:i==="$click_ids"&&a&&typeof a=="object"&&((r??={...s})[i]=Object.fromEntries(Object.keys(a).map(u=>[u,Pe])));for(let i of _n){let a=(r??s)[i];if(typeof a!="string")continue;let u=Sn(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 wn(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 kn(n,e=Math.random){return t=>n>=1?t:n<=0||e()>=n?null:{...t,properties:{...t.properties,$sample_rate:n}}}function xn(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 $e="lc_person_identified",re="lc_pending_set_once",At=new Set(["$identify","$create_alias","$groupidentify"]),Tt="$$client_ingestion_warning",Cn=6e4,Ie=class{constructor(e,t){this.mode=e;this.storage=t;this.identified=t.get($e)==="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($e,"1"))}personless(e){return this.mode==="always"?!1:(this.mode==="never"||!this.identified)&&!At.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($e),this.storage.remove(re)}};function Pn(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?wn(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 $n(n){let e=n.beforeSend?Array.isArray(n.beforeSend)?n.beforeSend:[n.beforeSend]:[];return[Rt(n.urlPrivacy??{}),...n.propertyDenylist?.length?[xn(n.propertyDenylist)]:[],...n.sampleRate!==void 0?[kn(n.sampleRate)]:[],...e]}function Mt(n,e,t,s=Date.now){let r=new Ie(e.personProfiles??"always",n.storage),i,a,u=0,p=-1/0,h=()=>{u+=1,!(s()-p<Cn)&&(p=s(),queueMicrotask(()=>{let m=u;u=0,n.capture(Tt,{$$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?Ot(i):void 0),Pn({hooks:$n(e),person:r,limit:m.event===Tt?void 0:a,log:t,onLimited:h},m))),r}var Oe=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)}},In=365,On=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(" ")),En=new Set("co com net org edu gov gob go ac or ne ltd plc sch mil nom".split(" "));function Rn(n){let e=n.toLowerCase().split(".");for(let t=1;t<e.length-1;t++)if(On.has(e.slice(t).join("."))||t===e.length-2&&e[t+1].length===2&&En.has(e[t]))return e.slice(t-1).join(".")}function An(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 Rn(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?An():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??In)*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{}}},j=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{}}},Ee=class extends j{constructor(){super("localStorage")}},Tn=["lc_identity","lc_session","lc_device_id","lc_consent","lc_person_identified"],Re=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()}},Ae=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 Oe;let s=ae(e),r=n==="cookie"?new oe(t):n==="localStorage+cookie"?new Re(new oe(t),new Ee,i=>Tn.some(a=>i===a+s)):new j(n);return new Ae(r,s)}function jt(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 Mn(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 Dt(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 Mn(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 Te={send:async()=>({status:200})};var jn="lucida-browser",Dn="0.1.10",Me="lc_internal",Ln=3e3,Lt="https://capture.lucidace.com",je=n=>!!n&&typeof n=="object"&&Object.getPrototypeOf(n)===Object.prototype;function De(n,e={},t=[]){if(typeof window>"u"||typeof navigator>"u")return Pt();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??Lt).replace(/\/+$/,""),a=Object.fromEntries(Object.entries(e).map(([o,c])=>[o,je(c)?{...c}:c]));a.apiHost=i;let u=e.extension??mt(),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=>yt(o,_,m,e.rewritePath),g=$(Te).fetch,v=e.consent?.respectDnt,b=navigator.globalPrivacyControl===!0,S=(e.respectDnt??v)===!0&&navigator.doNotTrack==="1"||(e.respectGpc??v)===!0&&b,Le=e.blockBots!==!1&&typeof navigator<"u"&&dt(navigator.userAgent??"",e.blockedUserAgents),k=!!e.disabled||Le;Le&&r("bot user agent: capture disabled");let le,de=$(e.transport??Dt(_,{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 j(h==="sessionStorage"?"sessionStorage":"localStorage"),()=>l.hasConsent("analytics"));de=le=_e(de,o,{key:`lc_offline${ae(n)}`,isOnline:()=>navigator.onLine!==!1})}let z=k?void 0:It(e.crossDomains),ue=ce(k?"memory":h,n,e.cookie),K=(e.storageWriteDelayMs??0)>0?new ie(ue,e.storageWriteDelayMs):void 0,Fe=z?.sessionId??e.bootstrap?.sessionId,pe,G=!1,Ne,Be=new Map,Ue,fe=[],l=new B({apiKey:n,apiHost:i,transport:k?Te: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:jn,version:Dn},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,...Fe?{bootstrapId:Fe}:{}},enrich:(o,c)=>{let d=wt(o,c,a.customCampaignParams,e.capturePageview==="hash");if(i!==Lt&&(d.properties={...d.properties,$lib_custom_api_host:i}),fe.length){let C=l.sessionId;for(let R of fe)d.properties={...d.properties,...R(C)}}if(o==="$pageview"){let C=l.sessionId;if(C!==Ne){let R=bt(e.referralParams);if(R&&(!R.category||Be.get(R.category)===!0)){Ne=C;let he=_t(R.params);he&&(d.properties={...d.properties,$referral_code:he},d.$set_once={...d.$set_once,initial_referral_code:he})}}}let y=Ue?.()??{},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={...Se(pe.all()),...d.properties}),G?{...d,properties:{...d.properties,$internal:!0}}:d},campaignKey:St,log:r});G=l.storage.get(Me)==="1",e.clickIds!==!1&&(Ue=pt(l.storage,e.clickIds?.expiryDays));let x=Mt(l,a,r);e.bootstrap?.isIdentified&&x.markIdentified();let D=o=>x.blocksPersonWrites?(r(`personProfiles=never: ${o} ignored`),!0):!1;k||l.onChange(o=>{o!=="consent"||l.hasConsent("analytics")||l.consentStatus()!=="denied"||(K?.flush(),jt(ue,n,e.consent?.storageKey||J))});let ge=new Set;l.onChange(o=>{o==="consent"&&[...ge].forEach(c=>c())});let qe=[],E=[gt(r,e.nonce)],He=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())}),He=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())})},We,f={core:l,client:void 0,config:a,flagStorage:He,apiKey:n,log:r,fetch:g,onUnload:o=>{qe.push(o)},whenConsented:Y,onCapture:o=>l.onCaptured(o),eventExtras:fe,clickExtras:[],flagPersonProps:[],categoryGrants:Be,loadConfig:()=>We??=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))}))},Ve=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));We=c,Ve=new Promise(d=>{let y=setTimeout(()=>(l.resolveConsent("opt_in"),d()),Ln);c.then(w=>{clearTimeout(y),w?l.applyRemote(w):o?l.resolveConsent("opt_in"):l.applyRemote({}),d()})})}let ze=be(l,{apiHost:i,apiKey:n,fetch:g,whenConsented:Y,log:r,disabled:k});E.push(()=>ze.stop());let L={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)=>{D("identify")||(x.markIdentified(),l.identify(o,c,d))},alias:(o,c)=>{D("alias")||(x.markIdentified(),l.alias(o,c))},reset:o=>{l.reset({resetDeviceId:!!o,reuseAnonymousId:!!e.reuseAnonymousId}),x.reset()},createPersonProfile:()=>{D("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];je(w)&&je(y)?Object.assign(w,y):c[d]=y}"debug"in o&&(s=!!o.debug)},setPersonProperties:(o,c)=>{!o&&!c||D("setPersonProperties")||(x.markIdentified(),l.capture("$set",{},{...o?{$set:o}:{},...c?{$set_once:c}:{}}))},unsetPersonProperties:o=>{!o.length||D("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(Me,"1"):l.storage.remove(Me)},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=>ze.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)=>L.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:()=>Ve.then(()=>l.flush()),shutdown:async()=>{for(let o of E)o();K?.flush(),await l.shutdown()}};if(f.client=L,!k){let o=()=>{for(let d of qe)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(ht((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(),vt(f,L,i)}return kt(L,e.exposeGlobal),r("initialised",{apiHost:i,consent:l.getConsent()}),L}function sr(n,e={}){return De(n,e)}export{De as createClient,sr as init};
|
|
1
|
+
var J="lc_consent";function ye(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 me=["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 o of me)typeof r[o]=="boolean"&&(this.state[o]=r[o]);this.decided=me.some(o=>typeof r[o]=="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 me)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,A=0;function Ge(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 o=Ge(2);A=((o[0]??0)<<8|(o[1]??0))&1023}else A++,A>4095&&(Q++,A=0);let e=Ge(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|A>>8,t[7]=A&255,t[8]=128|(e[0]??0)&63;for(let o=1;o<8;o++)t[8+o]=e[o]??0;let r=Array.from(t,o=>o.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 Ye="lc_identity",X=class{constructor(e,t,s=!1,r=!1){this.storage=e;this.cookieless=s;let o=e.get(Ye),a;try{a=o?JSON.parse(o):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(Ye,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 Je(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 o=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=o,o}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(!Je(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 o=Math.max(N(this.attempt++,this.o.backoff),Math.min(r??0,6e4));this.o.log?.("retry in",o,"ms"),this.arm(o)}clear(){this.items=[],this.disarm()}async shutdown(){await this.flush(),this.closed=!0,this.disarm()}};var ve="lc_session";function Qe(n,e,t){return typeof n=="number"&&Number.isInteger(n)&&n>=e&&n<=t?n*6e4:void 0}var Nt=6e4,Bt=10*36e5,Ut=24*36e5,qt=/^([0-9a-f]{8})-?([0-9a-f]{4})-7[0-9a-f]{3}-/i;function Ht(n,e){let t=qt.exec(n);if(!t)return!0;let s=parseInt(t[1]+t[2],16);return s-e<=6e4&&e-s<=Ut}var ee=class{constructor(e,t={}){this.storage=e;this.o=t;this.idleMs=Math.min(Bt,Math.max(Nt,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=Qe(e.session_idle_minutes,1,600)??this.idleMs),this.o.maxMs===void 0&&(this.maxMs=Qe(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(ve);return e?JSON.parse(e):void 0}catch{return}}touch(e,t){let s=this.clock.now(),r=this.read(),o=!!(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||o||a;return(u||!r)&&(r={id:!r&&this.bootstrapId&&Ht(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(ve,JSON.stringify(r)),{sessionId:r.id,windowId:this.windowId,isNew:u}}startedAt(){return this.read()?.start}reset(){this.storage.remove(ve)}};function Xe(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=Xe(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=Xe(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 Wt(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"),o=!r&&(this.anonymousOnReject||this.consent.anonymous),a=this.consent.pending&&(this.consent.queueBeforeConsent||this.consent.resolving);if(!r&&!o&&!a){this.c.log?.("dropped (no consent)",e);return}if(o&&(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=o?{}:{...p?.$set,...s.$set,...e==="$consent_updated"&&h?{$consent:this.consent.get()}:{}},_=o?{}:{...p?.$set_once,...s.$set_once},$=this.groupState.all(),g=o?"":this.identity.distinctId,v={uuid:P(this.clock.now()),event:e,...g?{distinct_id:g}:{},timestamp:Wt(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:_}:{},...!o&&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 w of this.captureListeners)w(b);return r||o?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(ye(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 o={...r};delete o.distinct_id,delete o.$set,delete o.$set_once,delete o.$unset,this.queue.enqueue(o)}}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 Ze(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 o="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"?o=_??"":m==="data"?u.push(_??""):m==="id"&&(a=_)}u.length&&n(a===void 0?{event:o,data:u.join(`
|
|
2
|
+
`)}:{event:o,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 o=Ze(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";o(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 be(n,e){let t=new Set,{whenConsented:s,disabled:r,...o}=e,a=new se({...o,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 _e(n,e,t={}){let s=t.key??"lc_offline",r=t.maxBatches??50,o=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,w)=>b+w.body.length,0);for(;g.length>r||v>o&&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 w=await n.send(g,v,b);return w.status!==0?w:(_([{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,w]of g.entries())if((await n.send(w.url,w.body)).status===0){v.push(...g.slice(b));break}v.length&&_(v)})().finally(()=>{p=void 0}),p}};return $}function we(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 T={started:"$ai_conversation_started",message:"$ai_message",feedback:"$ai_feedback",ended:"$ai_conversation_ended",outcome:"$ai_outcome"},zt=["resolved","unresolved","escalated","abandoned","error"],Vt=4e3,Kt=2e3,tt=["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"],nt=["thanks","thank you","great","perfect","awesome","helpful","that worked","works now","solved","exactly"],W=n=>Array.from(n),ke=(n,e)=>W(n).slice(0,e).join(""),Gt=0xcbf29ce484222325n,Yt=0x100000001b3n,Jt=0xffffffffffffffffn,Qt=new TextEncoder;function Xt(n){let e=Gt;for(let t of Qt.encode(n))e=(e^BigInt(t))*Yt&Jt;return e}function st(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 o=Xt(r);for(let a=0;a<64;a++)t[a]=(t[a]??0)+((o>>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 rt(n){let t=` ${n.toLowerCase().replace(/’/g,"'").replace(/[.,!?;:]/g," ").replace(/\s+/g," ").trim()} `,s=0;for(let o of tt)t.includes(` ${o} `)&&(s++,t=t.split(` ${o} `).join(" "));let r=nt.filter(o=>t.includes(` ${o} `)).length;return s>r?-1:r>s?1:0}var ot=n=>W(n).filter(e=>e>="0"&&e<="9").map(Number);function Zt(n){let e=ot(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 et=String.raw`[\p{Alphabetic}\p{M}\p{Nd}\p{Pc}\p{Join_Control}]`,en=[[new RegExp(String.raw`(?<!${et})\p{Nd}(?:[ -]?\p{Nd}){12,18}(?!${et})`,"gu"),Zt],[/[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,tn]];function tn(n){let e=ot(n).length;return e>=10&&e<=15}var nn=n=>W(n).map(e=>/\s/u.test(e)?e:"*").join("");function xe(n){let e=n;for(let[t,s]of en)e=e.replace(t,r=>s(r)?nn(r):r);return e===n?void 0:e}function it(n){if(typeof n!="string")return;let e=n.toLowerCase();return/^[0-9a-f]{32}$/.test(e)?e:void 0}var at=n=>typeof n=="string"&&zt.includes(n)?n:void 0,q=(n,e)=>typeof n=="string"&&n?ke(n,e):void 0;function sn(n,e,t){let s=ke(e,t),r=xe(s);return r===void 0?{[n]:s}:{[n]:r,$ai_text_redacted:!0}}function ct(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 o=st(e);o!==void 0&&(r.$ai_text_hash=o),r.$ai_sentiment=rt(e)}return s?{...r,...sn("$ai_text",e,Vt)}:r}function lt(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=ke(n.comment,Kt);s.$ai_feedback_comment=xe(r)??r}return n.messageIndex!==void 0&&(s.$ai_message_index=n.messageIndex),s}function Se(n,e){let t=at(n),s=q(e,64);return{...t?{$ai_outcome:t}:{},...s?{$ai_resolution:s}:{}}}function rn(){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 dt(n={}){let e={$ai_conversation_id:n.conversationId||rn()},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",it(n.traceId)),e}var H=class{next=0;common;emit;captureText;constructor(e,t={},s=!1){this.emit=e,this.captureText=s,this.common=dt(t)}get id(){return this.common.$ai_conversation_id}send(e,t){this.emit(e,{...this.common,...t})}start(){return this.send(T.started,{}),this}message(e,t,s={}){let r=s.index??this.next,o=ct(e,t,r,this.captureText);return o?(this.next=r+1,this.send(T.message,o),!0):!1}feedback(e){let t=lt(e,this.captureText);return t?(this.send(T.feedback,t),!0):!1}end(e,t){this.send(T.ended,Se(e,t))}outcome(e,t){let s=Se(e,t);return s.$ai_outcome?(this.send(T.outcome,s),!0):!1}};var on=["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 ut(n,e=[]){let t=n.toLowerCase();return e.some(s=>s&&t.includes(s.toLowerCase()))?!0:on.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"],pt="lc_click_ids";function ft(n,e=90,t=Date.now){let s,r=()=>{try{return JSON.parse(n.get(pt)??"{}")}catch{return{}}};return()=>{let o=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&&(o[h]={v:m.slice(0,512),t:t()},p=!0)}p&&n.set(pt,JSON.stringify(o))}let a={};for(let u of O){let p=o[u];p&&t()-p.t<e*864e5&&(a[u]=p.v)}return a}}function an(){return Array.from(document.querySelectorAll("meta[http-equiv]")).filter(n=>n.getAttribute("http-equiv")?.toLowerCase()==="content-security-policy").map(n=>n.getAttribute("content")??"")}function cn(n){let e=new Map;for(let s of n.split(";")){let[r,...o]=s.trim().toLowerCase().split(/\s+/);r&&!e.has(r)&&e.set(r,o)}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 ht(n,e){if(typeof document>"u")return()=>{};!e&&an().some(cn)&&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 ln=(n,e)=>n.slice(0,e);function gt(n){try{let e=new URL(n);return e.protocol==="data:"||e.protocol==="blob:"?e.protocol:e.origin+e.pathname}catch{return ln(n,64)}}function mt(n,e={}){if(typeof document>"u")return()=>{};let t=e.maxPerPage??20,s=new Set,r=o=>{let a=o,u={$csp_directive:a.effectiveDirective??a.violatedDirective,$csp_blocked_uri:gt(a.blockedURI??""),$csp_source_file:a.sourceFile?gt(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 dn=["chrome-extension:","moz-extension:","safari-web-extension:","ms-browser-extension:"],yt=()=>typeof location<"u"&&dn.includes(location.protocol);function un(n,e,t){let s=e.find(a=>n.startsWith(`${a}/`));if(!s)return n;let r=n.slice(s.length),o=r.search(/[?#]/);return s+t(o<0?r:r.slice(0,o))+(o<0?"":r.slice(o))}function vt(n,e,t,s){if(!s)return{transport:n,fetch:e};let r=o=>un(o,t,s);return{transport:{send:(o,a,u)=>n.send(r(o),a,u)},fetch:((o,a)=>e(typeof o=="string"?r(o):o instanceof URL?r(o.href):o,a))}}var pn="__LUCIDA_DEVTOOLS_HOOK__";function bt(n,e,t){let s=globalThis[pn];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 z=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function fn(n){let e={},t=new URLSearchParams(location.search);for(let s of[...z,...O,...n]){let r=t.get(s);r&&(e[`$${s}`]=r)}return e}var gn=["ref","referral","via","aff"];function _t(n){if(!n)return;let e=Array.isArray(n)?{params:n}:{params:n.params??gn,...n.category?{category:n.category}:{}};return e.params.length?e:void 0}function wt(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 St(){let n=new URLSearchParams(location.search),e=z.map(t=>n.get(t)??"");return e.some(Boolean)?e.join("|"):void 0}function hn(n){try{return n?new URL(n).hostname:""}catch{return""}}var mn=()=>location.href.replace(/([?&])__lc_toolbar=[^&#]*&?/,"$1").replace(/[?&]$/,"");function yn(){let n=location.hash;return n.length>1?location.pathname+n.split("?")[0]:location.pathname}function kt(n,e,t=[],s=!1){let r={$current_url:mn(),$host:location.host,$pathname:s?yn():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 o=fn(t);Object.assign(r,o);let a=e.$current_url??location.href,u=e.$referrer??document.referrer,p={$initial_referrer:u||"$direct",$initial_referring_domain:hn(u)||"$direct",$initial_current_url:a};for(let[h,m]of Object.entries(o))p[`$initial_${h.slice(1)}`]=m;return{properties:r,$set_once:p}}function xt(n,e,t=globalThis){e&&(t[typeof e=="string"?e:"lucida"]=n,typeof CustomEvent=="function"&&t.dispatchEvent?.(new CustomEvent("lucida:ready",{detail:n})))}var M=()=>{},Ce=()=>Promise.resolve(),Ct={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:()=>M,onFlags:()=>M,onIntervention:()=>M,onConsent:()=>M,flush:Ce,shutdown:Ce,reloadFlags:Ce,loadToolbar:()=>Promise.resolve(!1),recommendations:n=>Promise.resolve({placement:n,strategy:"",items:[],shown:M,clicked:M})};function Pt(n){return new Proxy(()=>{},{get:(e,t)=>{if(!(typeof t!="string"||t==="then"))return n&&Object.hasOwn(Ct,t)?Ct[t]:Pt(!1)}})}var $t=()=>Pt(!0);var It="_lcid";var vn=(n,e)=>e.some(t=>{let s=t.replace(/^\./,"").toLowerCase();return n.toLowerCase()===s||n.toLowerCase().endsWith(`.${s}`)});function bn(n,e=Date.now()){let t=n.lastIndexOf("."),[s="",r]=n.slice(t+1).split("_",2),o=/^[0-9a-z]+$/.test(s)?parseInt(s,36):NaN,a=n.slice(0,t);if(t>0&&a.length<=200&&o<=e+5e3&&e-o<=12e4)return r&&/^[\w-]{1,64}$/.test(r)?{distinctId:a,sessionId:r}:{distinctId:a}}function Ot(n){if(!n?.length)return;let e=new URL(location.href),t=e.searchParams.get(It);if(t!==null){e.searchParams.delete(It),history.replaceState(history.state,"",e.toString());try{if(document.referrer&&!vn(new URL(document.referrer).hostname,n))return}catch{return}return bn(t)}}function Et(n,e=Date.now){let t=n.eventsPerSecond??10,s=n.burst??100,r=s,o=e();return()=>{let a=e();return r=Math.min(s,r+(a-o)/1e3*t),o=a,r<1?!1:(r-=1,!0)}}var $e="<masked>",_n=["password","passwd","pwd","pass","token","access_token","refresh_token","id_token","secret","client_secret","api_key","apikey","key","auth","authorization","code","otp","email","ssn"],wn=["$pathname","$current_url","$referrer","$initial_referrer","$initial_current_url","$last_current_url"],Sn=[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,/^[0-9a-hjkmnp-tv-z]{26}$/i,/^\d{4,}$/,/^[0-9a-f]{16,}$/i,/^(?=.*\d)[a-z0-9_-]{20,}$/i],Rt=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function kn(n,e){let t=n;for(let s of e.pathRules??[])try{t=t.replace(typeof s.match=="string"?new RegExp(s.match):s.match,s.replace)}catch{}return e.maskPathIds?t.split("/").map(s=>Sn.some(r=>r.test(s))?":id":s).join("/"):t}function Pe(n,e){let t=n;if(e.pathRules?.length||e.maskPathIds){let r=/^((?:[a-z][a-z0-9+.-]*:)?\/\/[^/?#]*)?([^?#]*)([\s\S]*)$/i.exec(t);r&&(t=(r[1]??"")+kn(r[2],e)+r[3])}let s=[..._n,...e.maskParams??[],...e.maskCampaignParams?[...z,...O]:[]];if(s.length){let r=t.indexOf("#"),o=r<0?t:t.slice(0,r),a=r<0?"":t.slice(r);t=o.replace(new RegExp(`([?&])(${s.map(Rt).join("|")})=[^&]*`,"gi"),`$1$2=${$e}`)+a}return e.stripHash&&(t=t.replace(/#.*$/,"")),t}function At(n){let e=new RegExp(`^\\$(initial_|last_)?(${[...z,...O].map(Rt).join("|")})$`),t=s=>{let r;if(n.maskCampaignParams)for(let[o,a]of Object.entries(s))typeof a=="string"&&e.test(o)?(r??={...s})[o]=$e:o==="$click_ids"&&a&&typeof a=="object"&&((r??={...s})[o]=Object.fromEntries(Object.keys(a).map(u=>[u,$e])));for(let o of wn){let a=(r??s)[o];if(typeof a!="string")continue;let u=Pe(a,n);u!==a&&((r??={...s})[o]=u)}if(typeof s.$elements_chain=="string"){let o=s.$elements_chain.replace(/href="((?:[^"\\]|\\.)*)"/g,(a,u)=>`href="${Pe(u,n)}"`);o!==s.$elements_chain&&((r??={...s}).$elements_chain=o)}return Array.isArray(s.$elements)&&((r??={...s}).$elements=s.$elements.map(o=>typeof o?.href=="string"?{...o,href:Pe(o.href,n)}:o)),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 xn(n,e,t){let s=e;for(let r of n)try{let o=r(s);if(o==null)return null;if(typeof o!="object"||typeof o.event!="string")return t("beforeSend hook returned a non-event, dropping:",typeof o),null;s=o}catch(o){return t("beforeSend hook threw, dropping event:",o),null}return s}function Cn(n,e=Math.random){return t=>n>=1?t:n<=0||e()>=n?null:{...t,properties:{...t.properties,$sample_rate:n}}}function Pn(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 Ie="lc_person_identified",re="lc_pending_set_once",Tt=new Set(["$identify","$create_alias","$groupidentify"]),Mt="$$client_ingestion_warning",$n=6e4,Oe=class{constructor(e,t){this.mode=e;this.storage=t;this.identified=t.get(Ie)==="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(Ie,"1"))}personless(e){return this.mode==="always"?!1:(this.mode==="never"||!this.identified)&&!Tt.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(Ie),this.storage.remove(re)}};function In(n,e){let t=e,s;if(n.person.personless(e.event)){n.person.stash(e.$set_once);let{$set:o,$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?xn(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 On(n){let e=n.beforeSend?Array.isArray(n.beforeSend)?n.beforeSend:[n.beforeSend]:[];return[At(n.urlPrivacy??{}),...n.propertyDenylist?.length?[Pn(n.propertyDenylist)]:[],...n.sampleRate!==void 0?[Cn(n.sampleRate)]:[],...e]}function jt(n,e,t,s=Date.now){let r=new Oe(e.personProfiles??"always",n.storage),o,a,u=0,p=-1/0,h=()=>{u+=1,!(s()-p<$n)&&(p=s(),queueMicrotask(()=>{let m=u;u=0,n.capture(Mt,{$$client_ingestion_warning_message:`client rate limit dropped ${m} event(s)`,$dropped_count:m})}))};return n.setFilter(m=>(e.rateLimit!==o&&(o=e.rateLimit,a=o?Et(o):void 0),In({hooks:On(e),person:r,limit:m.event===Mt?void 0:a,log:t,onLimited:h},m))),r}var Ee=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)}},En=365,Rn=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(" ")),An=new Set("co com net org edu gov gob go ac or ne ltd plc sch mil nom".split(" "));function Tn(n){let e=n.toLowerCase().split(".");for(let t=1;t<e.length-1;t++)if(Rn.has(e.slice(t).join("."))||t===e.length-2&&e[t+1].length===2&&An.has(e[t]))return e.slice(t-1).join(".")}function Mn(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 Tn(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?Mn():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??En)*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{}}},j=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{}}},Re=class extends j{constructor(){super("localStorage")}},jn=["lc_identity","lc_session","lc_device_id","lc_consent","lc_person_identified"],Ae=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()}},Te=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 Ee;let s=ae(e),r=n==="cookie"?new oe(t):n==="localStorage+cookie"?new Ae(new oe(t),new Re,o=>jn.some(a=>o===a+s)):new j(n);return new Te(r,s)}function Dt(n,e,t){let s=ae(e),r=new Set;try{for(let o of document.cookie.split("; "))r.add(o.split("=")[0]);for(let o of[globalThis.localStorage,globalThis.sessionStorage])for(let a=0;a<o.length;a++)r.add(o.key(a))}catch{}for(let o of r)if(!(!o.startsWith("lc_")||!o.endsWith(s)||o===t+s)){n.remove(o.slice(0,-s.length));try{localStorage.removeItem(o),sessionStorage.removeItem(o)}catch{}}}async function Dn(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 Lt(n,e={}){let t=e.compress??!0,s=(r,o)=>(e.onError?.({url:r,status:o}),{status:o});return{async send(r,o,a){if(a?.beacon&&!e.disableBeacon&&typeof navigator<"u"&&navigator.sendBeacon)return navigator.sendBeacon(r,new Blob([o],{type:"text/plain"}))?{status:200}:s(r,0);try{let u=t&&o.length>=1024?await Dn(o):void 0,p=await n(u?`${r}${r.includes("?")?"&":"?"}compression=gzip`:r,{method:"POST",body:u??o,headers:{...e.headers,"Content-Type":"text/plain;charset=UTF-8"},credentials:"omit",keepalive:(u?.length??o.length)<6e4});return p.status>=400?s(r,p.status):{status:p.status}}catch{return s(r,0)}}}}var Me={send:async()=>({status:200})};var Ln="lucida-browser",Fn="0.1.12",je="lc_internal",Nn=3e3,Ft="https://capture.lucidace.com",De=n=>!!n&&typeof n=="object"&&Object.getPrototypeOf(n)===Object.prototype;function Le(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),r=(...i)=>{s&&console.debug("[lucida]",...i)},o=(e.apiHost??Ft).replace(/\/+$/,""),a=Object.fromEntries(Object.entries(e).map(([i,c])=>[i,De(c)?{...c}:c]));a.apiHost=o;let u=e.extension??yt(),p=i=>u&&(i==="cookie"||i==="localStorage+cookie")?e.extensionPersistence??"localStorage":i,h=p(e.cookieless==="always"?"none":e.persistence??"cookie"),m=[o,...e.flagsApiHost?[e.flagsApiHost.replace(/\/+$/,"")]:[]],_=e.fetch??((...i)=>fetch(...i)),$=i=>vt(i,_,m,e.rewritePath),g=$(Me).fetch,v=e.consent?.respectDnt,b=navigator.globalPrivacyControl===!0,w=(e.respectDnt??v)===!0&&navigator.doNotTrack==="1"||(e.respectGpc??v)===!0&&b,Fe=e.blockBots!==!1&&typeof navigator<"u"&&ut(navigator.userAgent??"",e.blockedUserAgents),k=!!e.disabled||Fe;Fe&&r("bot user agent: capture disabled");let le,de=$(e.transport??Lt(_,{headers:a.requestHeaders,onError:e.onRequestError,disableBeacon:e.disableBeacon})).transport;if(!e.transport&&e.offlineQueue!==!1&&h!=="memory"&&h!=="none"){let i=new I(new j(h==="sessionStorage"?"sessionStorage":"localStorage"),()=>l.hasConsent("analytics"));de=le=_e(de,i,{key:`lc_offline${ae(n)}`,isOnline:()=>navigator.onLine!==!1})}let V=k?void 0:Ot(e.crossDomains),ue=ce(k?"memory":h,n,e.cookie),K=(e.storageWriteDelayMs??0)>0?new ie(ue,e.storageWriteDelayMs):void 0,Ne=V?.sessionId??e.bootstrap?.sessionId,pe,G=!1,Be,Ue=new Map,qe,fe=[],l=new B({apiKey:n,apiHost:o,transport:k?Me:de,storage:K??ue,...e.consentPersistence&&!k?{consentStorage:ce(p(e.consentPersistence),n,e.cookie)}:{},persistProperty:i=>!a.persistedProperties||a.persistedProperties.includes(i),...h==="none"?{cookieless:!0}:{},library:{name:Ln,version:Fn},consent:{...e.cookieless==="on_reject"?{cookielessOnReject:!0}:{},...e.consent,...!k&&(e.consent?.geo||e.consent?.mode!=="opt_in")?{awaitRemote:!0}:{},respectDnt:!0,dnt:w},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,...Ne?{bootstrapId:Ne}:{}},enrich:(i,c)=>{let d=kt(i,c,a.customCampaignParams,e.capturePageview==="hash");if(o!==Ft&&(d.properties={...d.properties,$lib_custom_api_host:o}),fe.length){let C=l.sessionId;for(let R of fe)d.properties={...d.properties,...R(C)}}if(i==="$pageview"){let C=l.sessionId;if(C!==Be){let R=_t(e.referralParams);if(R&&(!R.category||Ue.get(R.category)===!0)){Be=C;let he=wt(R.params);he&&(d.properties={...d.properties,$referral_code:he},d.$set_once={...d.$set_once,initial_referral_code:he})}}}let y=qe?.()??{},S=Object.keys(y);return S.length&&(d.properties={...d.properties,$click_ids:y},i==="$pageview"&&(d.$set_once={...Object.fromEntries(S.map(C=>[`$initial_${C}`,y[C]])),...d.$set_once},d.$set=Object.fromEntries(S.map(C=>[`$last_${C}`,y[C]])))),a.sendFeatureFlags!==!1&&i!=="$snapshot"&&pe&&(d.properties={...we(pe.all()),...d.properties}),G?{...d,properties:{...d.properties,$internal:!0}}:d},campaignKey:St,log:r});G=l.storage.get(je)==="1",e.clickIds!==!1&&(qe=ft(l.storage,e.clickIds?.expiryDays));let x=jt(l,a,r);e.bootstrap?.isIdentified&&x.markIdentified();let D=i=>x.blocksPersonWrites?(r(`personProfiles=never: ${i} ignored`),!0):!1;k||l.onChange(i=>{i!=="consent"||l.hasConsent("analytics")||l.consentStatus()!=="denied"||(K?.flush(),Dt(ue,n,e.consent?.storageKey||J))});let ge=new Set;l.onChange(i=>{i==="consent"&&[...ge].forEach(c=>c())});let He=[],E=[ht(r,e.nonce)],We=l.storage;if(e.flagPersistence&&!k){let i=new I(ce(p(e.flagPersistence),n,e.cookie),()=>l.hasConsent("analytics"));l.onChange(c=>{c==="consent"&&(l.hasConsent("analytics")?i.flushBuffered():i.discardBuffered())}),We=i}let Y=i=>{if(k)return;if(l.hasConsent("analytics"))return i();let c=!1;l.onChange(d=>{!c&&d==="consent"&&l.hasConsent("analytics")&&(c=!0,i())})},ze,f={core:l,client:void 0,config:a,flagStorage:We,apiKey:n,log:r,fetch:g,onUnload:i=>{He.push(i)},whenConsented:Y,onCapture:i=>l.onCaptured(i),eventExtras:fe,clickExtras:[],flagPersonProps:[],categoryGrants:Ue,loadConfig:()=>ze??=new Promise(i=>Y(()=>{g(`${o}/v1/config?api_key=${encodeURIComponent(n)}`).then(c=>c.ok?c.json():null).then(c=>(c&&l.applyRemote(c),c)).then(i,()=>i(null))}))},Ve=Promise.resolve();if(l.consent.resolving){let i=!1,c=g(`${o}/v1/config?api_key=${encodeURIComponent(n)}`,{credentials:"omit"}).then(d=>(i=d.status>=500,d.ok?d.json():null)).catch(()=>(i=!0,null));ze=c,Ve=new Promise(d=>{let y=setTimeout(()=>(l.resolveConsent("opt_in"),d()),Nn);c.then(S=>{clearTimeout(y),S?l.applyRemote(S):i?l.resolveConsent("opt_in"):l.applyRemote({}),d()})})}let Ke=be(l,{apiHost:o,apiKey:n,fetch:g,whenConsented:Y,log:r,disabled:k});E.push(()=>Ke.stop());let L={get distinctId(){return l.distinctId},capture:(i,c,d)=>{l.capture(i,c,d?.timestamp!==void 0?{timestamp:d.timestamp}:{})&&(d?.sendInstantly||d?.transport)&&l.flush(d.transport==="beacon"?{beacon:!0}:{})},identify:(i,c,d)=>{D("identify")||(x.markIdentified(),l.identify(i,c,d))},alias:(i,c)=>{D("alias")||(x.markIdentified(),l.alias(i,c))},reset:i=>{l.reset({resetDeviceId:!!i,reuseAnonymousId:!!e.reuseAnonymousId}),x.reset()},createPersonProfile:()=>{D("createPersonProfile")||x.isProfile||(x.markIdentified(),l.capture("$set",{}))},setConfig:i=>{let c=a;for(let[d,y]of Object.entries(i)){let S=c[d];De(S)&&De(y)?Object.assign(S,y):c[d]=y}"debug"in i&&(s=!!i.debug)},setPersonProperties:(i,c)=>{!i&&!c||D("setPersonProperties")||(x.markIdentified(),l.capture("$set",{},{...i?{$set:i}:{},...c?{$set_once:c}:{}}))},unsetPersonProperties:i=>{!i.length||D("unsetPersonProperties")||(x.markIdentified(),l.capture("$set",{},{$unset:i}))},getDistinctId:()=>l.distinctId,getSessionId:()=>l.sessionId,onSessionId:i=>l.onSessionId(c=>i(c)),getProperty:i=>l.getProperty(i),hasOptedOut:()=>l.consentStatus()==="denied",hasOptedIn:()=>l.consentStatus()==="granted",onConsent:i=>(ge.add(i),()=>{ge.delete(i)}),getReplayUrl:i=>{let d=`${(e.uiHost??o).replace(/\/+$/,"")}/replays/${encodeURIComponent(l.sessionId)}`,y=l.sessionStart;return!i?.withTimestamp||y===void 0?d:`${d}?t=${Math.max(0,Math.round((Date.now()-y)/1e3-(i.timestampLookBackSeconds??10)))}`},debug:(i=!0)=>{s=i},featureView:(i,c)=>{l.capture("$feature_view",{...c,$feature_flag:i},{$set:{[`$feature_view/${i}`]:!0}})},featureInteraction:(i,c)=>{l.capture("$feature_interaction",{...c,$feature_flag:i},{$set:{[`$feature_interaction/${i}`]:!0}})},updateFlags:(i,c,d)=>f.flags?.update(i,c,d?.merge??!0),register:i=>l.register(i),registerOnce:i=>l.registerOnce(i),unregister:i=>l.unregister(i),group:(i,c,d)=>{x.markIdentified(),l.group(i,c,d)},optIn:(i=["analytics","replay"])=>l.setConsent({analytics:i.includes("analytics"),replay:i.includes("replay"),marketing:i.includes("marketing")}),optOut:()=>l.optOut(),optOutInternal:(i=!0)=>{G=i,i?l.storage.set(je,"1"):l.storage.remove(je)},get isInternal(){return G},setConsent:i=>l.setConsent(i),getConsent:()=>l.getConsent(),getConsentStatus:i=>l.getConsentStatus(i),consentStatus:()=>l.consentStatus(),getFlag:i=>f.flags?.get(i),getFlagPayload:i=>f.flags?.payload(i),getFlagResult:(i,c)=>f.flags?.result(i,c)??U(i,void 0,void 0,"not_found"),getLayerParam:(i,c,d)=>f.flags?.layerParam(i,c)??d,isFeatureEnabled:i=>{let c=f.flags?.get(i);return c!==void 0&&c!==!1},onFlags:i=>f.flags?.onChange(i)??(()=>{}),onIntervention:i=>Ke.on(i),reloadFlags:()=>f.flags?.reload()??Promise.resolve(),getAllFlags:()=>f.flags?.all()??{},overrideFlags:(i,c)=>f.flags?.override(i,c),setPersonPropertiesForFlags:(i,c)=>f.flags?.setPersonProperties(i,c),resetPersonPropertiesForFlags:()=>f.flags?.resetPersonProperties(),setGroupPropertiesForFlags:(i,c)=>f.flags?.setGroupProperties(i,c),resetGroupPropertiesForFlags:()=>f.flags?.resetGroupProperties(),setContext:(i,c,d)=>f.flags?.setContext(i,c,d),clearContext:i=>f.flags?.clearContext(i),guides:{showChangelog:()=>f.guides?.showChangelog()??0,show:i=>f.guides?.show(i)??!1,reset:i=>f.guides?.reset(i)},ai:{startConversation:i=>new H((c,d)=>L.capture(c,d),i,a.ai?.captureText===!0).start()},earlyAccess:{list:()=>f.earlyAccess?.list()??Promise.resolve([]),optIn:i=>f.earlyAccess?.optIn(i),optOut:i=>f.earlyAccess?.optOut(i)},replay:{start:i=>f.replay?.start(i)??Promise.resolve(),stop:()=>f.replay?.stop(),pause:()=>f.replay?.pause(),resume:()=>f.replay?.resume(),tag:i=>f.replay?.tag(i),isRecording:()=>f.replay?.isRecording()??!1},consent:{showBanner:i=>f.consentUi?.showBanner(i)??Promise.resolve(null),hideBanner:()=>f.consentUi?.hideBanner()},loadToolbar:i=>f.toolbar?.load(typeof i=="string"?i:i.token)??Promise.resolve(!1),activateExperiment:i=>f.experiments?.activate(i),recommendations:(i,c)=>f.recs?.get(i,c)??Promise.resolve({placement:i,strategy:"",items:[],shown(){},clicked(){}}),flush:()=>Ve.then(()=>l.flush()),shutdown:async()=>{for(let i of E)i();K?.flush(),await l.shutdown()}};if(f.client=L,!k){let i=()=>{for(let d of He)d();K?.flush(),l.flush({beacon:!0})};window.addEventListener("pagehide",i);let c=()=>{document.visibilityState==="hidden"&&l.flush({beacon:!0})};if(document.addEventListener("visibilitychange",c),E.push(()=>{window.removeEventListener("pagehide",i),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(mt((y,S)=>{l.capture(y,S)},d))}for(let d of t){let y=d(f);y&&E.push(y)}pe=f.flags,t.length||f.loadConfig(),bt(f,L,o)}return xt(L,e.exposeGlobal),r("initialised",{apiHost:o,consent:l.getConsent()}),L}function or(n,e={}){return Le(n,e)}export{Le as createClient,or as init};
|
package/dist/correlate.d.ts
CHANGED
package/dist/early-access.d.ts
CHANGED
package/dist/experiments.d.ts
CHANGED
package/dist/flags.d.ts
CHANGED
package/dist/forms.d.ts
CHANGED
package/dist/guides.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as GuideStep, f as GuideAutomation, g as Guide, h as GuideTokens, M as Module } from './types-
|
|
1
|
+
import { G as GuideStep, f as GuideAutomation, g as Guide, h as GuideTokens, M as Module } from './types-Chfj1wdu.js';
|
|
2
2
|
import '@lucida-analytics/sdk-core';
|
|
3
3
|
|
|
4
4
|
/** `POST /v1/guides/answer` response. */
|
package/dist/heatmaps.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Props } from '@lucida-analytics/sdk-core';
|
|
2
|
-
import { M as Module } from './types-
|
|
2
|
+
import { M as Module } from './types-Chfj1wdu.js';
|
|
3
3
|
|
|
4
4
|
type ViewportBucket = "mobile" | "tablet" | "desktop";
|
|
5
5
|
declare function viewportBucket(width: number): ViewportBucket;
|