@manototh/do11y 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/do11y.js +66 -47
- package/dist/do11y.min.js +1 -1
- package/package.json +1 -1
package/dist/do11y.js
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
const EVENT_TOC_CLICK = "browser.do11y.toc_click";
|
|
67
67
|
const EVENT_FEEDBACK = "browser.do11y.feedback";
|
|
68
68
|
const EVENT_EXPAND_COLLAPSE = "browser.do11y.expand_collapse";
|
|
69
|
-
const VERSION = "0.1.
|
|
69
|
+
const VERSION = "0.1.2";
|
|
70
70
|
const _alreadyLoaded = !!window.__do11yInitialized;
|
|
71
71
|
window.__do11yInitialized = true;
|
|
72
72
|
const _isInIframe = window.self !== window.top;
|
|
@@ -117,7 +117,9 @@
|
|
|
117
117
|
navigationSelector: null,
|
|
118
118
|
footerSelector: null,
|
|
119
119
|
contentSelector: null,
|
|
120
|
-
useOtelBrowserInstrumentations: false
|
|
120
|
+
useOtelBrowserInstrumentations: false,
|
|
121
|
+
testRunId: void 0,
|
|
122
|
+
testFramework: void 0
|
|
121
123
|
};
|
|
122
124
|
const FRAMEWORK_PRESETS = {
|
|
123
125
|
mintlify: {
|
|
@@ -127,9 +129,9 @@
|
|
|
127
129
|
navigationSelector: "nav, [role=\"navigation\"], #navbar, #sidebar, [class*=\"nav\"], [class*=\"sidebar\"]",
|
|
128
130
|
footerSelector: "footer, [role=\"contentinfo\"], [class*=\"footer\"]",
|
|
129
131
|
contentSelector: "main, article, [role=\"main\"], [class*=\"content\"]",
|
|
130
|
-
tabContainerSelector: "[role=\"tablist\"], [class*=\"tab\"]",
|
|
132
|
+
tabContainerSelector: "tabs, [role=\"tablist\"], [class*=\"tab\"]",
|
|
131
133
|
tocSelector: "#table-of-contents, [data-testid=\"table-of-contents\"], [class*=\"table-of-contents\"], [class*=\"toc\"]",
|
|
132
|
-
feedbackSelector: "[class*=\"feedback\"], [class*=\"helpful\"]"
|
|
134
|
+
feedbackSelector: "feedback-toolbar, #feedback-thumbs-up, #feedback-thumbs-down, [class*=\"feedback\"], [class*=\"helpful\"]"
|
|
133
135
|
},
|
|
134
136
|
docusaurus: {
|
|
135
137
|
searchSelector: ".DocSearch, .DocSearch-Button",
|
|
@@ -571,6 +573,8 @@
|
|
|
571
573
|
...getBrowserContext(),
|
|
572
574
|
...eventData
|
|
573
575
|
};
|
|
576
|
+
if (config.testRunId) event._testRunId = config.testRunId;
|
|
577
|
+
if (config.testFramework) event._testFramework = config.testFramework;
|
|
574
578
|
if (config.debug) console.log("[Do11y] Event queued:", eventName, event);
|
|
575
579
|
if (config.destination === "otlp" && _otelLogger) {
|
|
576
580
|
_otelLogger.emit({
|
|
@@ -788,6 +792,8 @@
|
|
|
788
792
|
/**
|
|
789
793
|
* Synchronous flush used on `beforeunload`. For OTLP mode the SDK
|
|
790
794
|
* handles flush on its own; for HTTP/Supabase we use fetch with keepalive.
|
|
795
|
+
* sendBeacon is not used because Supabase requires custom headers
|
|
796
|
+
* (apikey, Authorization) which sendBeacon does not support.
|
|
791
797
|
*/
|
|
792
798
|
function flushSync() {
|
|
793
799
|
if (config.destination === "otlp") return;
|
|
@@ -1002,6 +1008,7 @@
|
|
|
1002
1008
|
[ATTR_DO11Y_REFERRER_CATEGORY]: session.referrerCategory,
|
|
1003
1009
|
[ATTR_DO11Y_AI_PLATFORM]: session.aiPlatform
|
|
1004
1010
|
});
|
|
1011
|
+
flush();
|
|
1005
1012
|
}
|
|
1006
1013
|
function setupEngagementTracking() {
|
|
1007
1014
|
document.addEventListener("visibilitychange", () => {
|
|
@@ -1061,21 +1068,39 @@
|
|
|
1061
1068
|
const id = entry.target.getAttribute("data-do11y-section-id");
|
|
1062
1069
|
if (!id) return;
|
|
1063
1070
|
if (entry.isIntersecting) {
|
|
1064
|
-
if (!sectionTimers[id])
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1071
|
+
if (!sectionTimers[id]) {
|
|
1072
|
+
const timer = {
|
|
1073
|
+
start: Date.now(),
|
|
1074
|
+
reported: false,
|
|
1075
|
+
timeoutId: null
|
|
1076
|
+
};
|
|
1077
|
+
timer.timeoutId = setTimeout(() => {
|
|
1078
|
+
if (sectionTimers[id] && !sectionTimers[id].reported) {
|
|
1079
|
+
const heading = entry.target.textContent?.trim() ?? "";
|
|
1080
|
+
queueEvent(EVENT_SECTION_VISIBLE, {
|
|
1081
|
+
[ATTR_DO11Y_SECTION_HEADING]: sanitizeText(heading, 100),
|
|
1082
|
+
[ATTR_DO11Y_SECTION_HEADING_LEVEL]: parseInt(entry.target.tagName.charAt(1), 10),
|
|
1083
|
+
[ATTR_DO11Y_SECTION_VISIBLE_SECONDS]: Math.round(threshold / 1e3)
|
|
1084
|
+
});
|
|
1085
|
+
sectionTimers[id].reported = true;
|
|
1086
|
+
}
|
|
1087
|
+
}, threshold);
|
|
1088
|
+
sectionTimers[id] = timer;
|
|
1089
|
+
}
|
|
1068
1090
|
} else {
|
|
1069
|
-
if (sectionTimers[id]
|
|
1070
|
-
|
|
1071
|
-
if (
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1091
|
+
if (sectionTimers[id]) {
|
|
1092
|
+
if (sectionTimers[id].timeoutId) clearTimeout(sectionTimers[id].timeoutId);
|
|
1093
|
+
if (!sectionTimers[id].reported) {
|
|
1094
|
+
const elapsed = Date.now() - sectionTimers[id].start;
|
|
1095
|
+
if (elapsed >= threshold) {
|
|
1096
|
+
const heading = entry.target.textContent?.trim() ?? "";
|
|
1097
|
+
queueEvent(EVENT_SECTION_VISIBLE, {
|
|
1098
|
+
[ATTR_DO11Y_SECTION_HEADING]: sanitizeText(heading, 100),
|
|
1099
|
+
[ATTR_DO11Y_SECTION_HEADING_LEVEL]: parseInt(entry.target.tagName.charAt(1), 10),
|
|
1100
|
+
[ATTR_DO11Y_SECTION_VISIBLE_SECONDS]: Math.round(elapsed / 1e3)
|
|
1101
|
+
});
|
|
1102
|
+
sectionTimers[id].reported = true;
|
|
1103
|
+
}
|
|
1079
1104
|
}
|
|
1080
1105
|
}
|
|
1081
1106
|
delete sectionTimers[id];
|
|
@@ -1098,6 +1123,7 @@
|
|
|
1098
1123
|
Object.keys(sectionTimers).forEach((id) => {
|
|
1099
1124
|
const timer = sectionTimers[id];
|
|
1100
1125
|
if (timer && !timer.reported) {
|
|
1126
|
+
if (timer.timeoutId) clearTimeout(timer.timeoutId);
|
|
1101
1127
|
const elapsed = now - timer.start;
|
|
1102
1128
|
if (elapsed >= threshold) {
|
|
1103
1129
|
const escapedId = typeof CSS !== "undefined" && typeof CSS.escape === "function" ? CSS.escape(id) : id.replace(/["\\]/g, "\\$&");
|
|
@@ -1207,9 +1233,10 @@
|
|
|
1207
1233
|
});
|
|
1208
1234
|
}
|
|
1209
1235
|
let mutationObserver = null;
|
|
1236
|
+
let pathPollId = null;
|
|
1210
1237
|
function init() {
|
|
1211
1238
|
if (window.Do11yConfig && typeof window.Do11yConfig === "object") {
|
|
1212
|
-
for (const key in
|
|
1239
|
+
for (const key in config) if (Object.prototype.hasOwnProperty.call(window.Do11yConfig, key)) config[key] = window.Do11yConfig[key];
|
|
1213
1240
|
}
|
|
1214
1241
|
const metaDestination = document.querySelector("meta[name=\"do11y-destination\"]");
|
|
1215
1242
|
if (metaDestination) {
|
|
@@ -1278,38 +1305,26 @@
|
|
|
1278
1305
|
setupFeedbackTracking();
|
|
1279
1306
|
setupExpandCollapseTracking();
|
|
1280
1307
|
let lastPath = window.location.pathname;
|
|
1281
|
-
|
|
1282
|
-
if (window.location.pathname
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1308
|
+
const handlePathChange = () => {
|
|
1309
|
+
if (window.location.pathname === lastPath) return;
|
|
1310
|
+
lastPath = window.location.pathname;
|
|
1311
|
+
emitPageExit();
|
|
1312
|
+
trackedScrollDepths = /* @__PURE__ */ new Set();
|
|
1313
|
+
pageLoadTime = Date.now();
|
|
1314
|
+
lastActivityTime = Date.now();
|
|
1315
|
+
totalActiveTime = 0;
|
|
1316
|
+
isPageVisible = true;
|
|
1317
|
+
trackPageView();
|
|
1318
|
+
observeHeadings();
|
|
1319
|
+
checkScrollDepth();
|
|
1320
|
+
};
|
|
1321
|
+
mutationObserver = new MutationObserver(handlePathChange);
|
|
1295
1322
|
mutationObserver.observe(document.body, {
|
|
1296
1323
|
childList: true,
|
|
1297
1324
|
subtree: true
|
|
1298
1325
|
});
|
|
1299
|
-
window.addEventListener("popstate",
|
|
1300
|
-
|
|
1301
|
-
lastPath = window.location.pathname;
|
|
1302
|
-
emitPageExit();
|
|
1303
|
-
trackedScrollDepths = /* @__PURE__ */ new Set();
|
|
1304
|
-
pageLoadTime = Date.now();
|
|
1305
|
-
lastActivityTime = Date.now();
|
|
1306
|
-
totalActiveTime = 0;
|
|
1307
|
-
isPageVisible = true;
|
|
1308
|
-
trackPageView();
|
|
1309
|
-
observeHeadings();
|
|
1310
|
-
checkScrollDepth();
|
|
1311
|
-
}
|
|
1312
|
-
});
|
|
1326
|
+
window.addEventListener("popstate", handlePathChange);
|
|
1327
|
+
pathPollId = window.setInterval(handlePathChange, 200);
|
|
1313
1328
|
Object.freeze(config);
|
|
1314
1329
|
if (config.debug) console.log("[Do11y] Initialized successfully");
|
|
1315
1330
|
}
|
|
@@ -1327,6 +1342,10 @@
|
|
|
1327
1342
|
clearTimeout(flushTimeout);
|
|
1328
1343
|
flushTimeout = null;
|
|
1329
1344
|
}
|
|
1345
|
+
if (pathPollId !== null) {
|
|
1346
|
+
clearInterval(pathPollId);
|
|
1347
|
+
pathPollId = null;
|
|
1348
|
+
}
|
|
1330
1349
|
flushSync();
|
|
1331
1350
|
}
|
|
1332
1351
|
if (!_alreadyLoaded && !_isInIframe) if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", init);
|
package/dist/do11y.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){let e=`browser.do11y.referrer_category`,t=`browser.do11y.ai_platform`,n=`browser.do11y.scroll.threshold`,r=`browser.do11y.scroll.percent`,i=`browser.do11y.section.heading`,a=`browser.do11y.section.heading_level`,o=`browser.do11y.section.visible_seconds`,s=`browser.do11y.expand.summary`,c=`browser.do11y.expand.action`,l=`browser.do11y.expand.section`,u=`browser.do11y.scroll_depth`,d=`browser.do11y.search_opened`,f=`browser.do11y.section_visible`,p=`browser.do11y.expand_collapse`,m=`0.1.1`,h=!!window.__do11yInitialized;window.__do11yInitialized=!0;let g=window.self!==window.top;g&&!h&&(window.__do11yInitialized=!1);let _={destination:`supabase`,supabaseUrl:``,supabaseKey:``,supabaseTable:`do11y_events`,endpoint:``,headers:{},bodyTransform:void 0,otelSdkEndpoint:``,otelSdkHeaders:{},otelSdkServiceName:`do11y`,otelSdkResourceAttributes:{},otelSdkCdnUrl:`https://esm.sh/`,debug:!1,flushInterval:5e3,maxBatchSize:10,trackOutboundLinks:!0,trackInternalLinks:!0,trackScrollDepth:!0,scrollThresholds:[25,50,75,90],allowedDomains:null,respectDNT:!0,maxRetries:2,retryDelay:1e3,rateLimitMs:100,framework:`mintlify`,trackSectionVisibility:!0,sectionVisibleThreshold:3,trackTabSwitches:!0,trackTocClicks:!0,trackExpandCollapse:!0,trackFeedback:!0,tabContainerSelector:null,tocSelector:null,feedbackSelector:null,searchSelector:null,copyButtonSelector:null,codeBlockSelector:null,navigationSelector:null,footerSelector:null,contentSelector:null,useOtelBrowserInstrumentations:!1},v={mintlify:{searchSelector:`#search-bar-entry, #search-bar-entry-mobile, [class*="search"]`,copyButtonSelector:`button[class*="copy"], button[aria-label*="copy" i]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], #navbar, #sidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`[role="tablist"], [class*="tab"]`,tocSelector:`#table-of-contents, [data-testid="table-of-contents"], [class*="table-of-contents"], [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},docusaurus:{searchSelector:`.DocSearch, .DocSearch-Button`,copyButtonSelector:`button.clean-btn[aria-label*="copy" i], button[class*="copyButton"]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .navbar, .sidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`.tabs[role="tablist"], [class*="tabs"]`,tocSelector:`.table-of-contents, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},nextra:{searchSelector:`.nextra-search input, input[placeholder*="search" i], button[aria-label*="search" i]`,copyButtonSelector:`button[class*="copy"], button[aria-label*="copy" i], button[title*="copy" i]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`[role="tablist"], [class*="tab"]`,tocSelector:`.nextra-toc, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},"mkdocs-material":{searchSelector:`.md-search__input`,copyButtonSelector:`.md-clipboard, .md-code__button[title="Copy to clipboard"]`,codeBlockSelector:`pre, code, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .md-nav, .md-sidebar`,footerSelector:`footer, [role="contentinfo"], .md-footer`,contentSelector:`main, article, [role="main"], .md-content`,tabContainerSelector:`.tabbed-labels, .md-typeset .tabbed-set`,tocSelector:`.md-sidebar--secondary .md-nav, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},vitepress:{searchSelector:`.VPNavBarSearch button, .VPNavBarSearchButton, #local-search`,copyButtonSelector:`button.copy, .vp-code-copy, button.copy[title*="Copy"]`,codeBlockSelector:`div[class*="language-"], pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .VPNav, .VPSidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], .VPFooter, [class*="footer"]`,contentSelector:`main, article, [role="main"], .VPContent, [class*="content"]`,tabContainerSelector:`.vp-code-group .tabs, [role="tablist"]`,tocSelector:`.VPDocAsideOutline, .VPLocalNavOutlineDropdown, a.outline-link`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},starlight:{searchSelector:`site-search button[data-open-modal], sl-doc-search .DocSearch-Button, button[aria-label*="search" i]`,copyButtonSelector:`.expressive-code .copy button, .copy button[data-code]`,codeBlockSelector:`.expressive-code pre, pre`,navigationSelector:`nav, [role="navigation"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, .sl-markdown-content, [role="main"]`,tabContainerSelector:`starlight-tabs [role="tablist"], [role="tablist"]`,tocSelector:`.right-sidebar-panel, starlight-toc, mobile-starlight-toc`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},docsy:{searchSelector:`.td-search input, .td-search__input, #docsearch-0, #docsearch-1`,copyButtonSelector:`button[aria-label*="copy" i], button[title*="copy" i], .td-click-to-copy`,codeBlockSelector:`.highlight, pre.chroma, pre`,navigationSelector:`nav, [role="navigation"], .td-sidebar, .td-navbar, [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], .td-footer, [class*="footer"]`,contentSelector:`main, article, [role="main"], .td-content, [class*="content"]`,tabContainerSelector:`.nav-tabs[role="tablist"], [role="tablist"], .tab-content`,tocSelector:`.td-toc, nav[id="TableOfContents"], [class*="toc"]`,feedbackSelector:`.feedback--answer, [class*="feedback"], [class*="helpful"]`}},y=[`searchSelector`,`copyButtonSelector`,`codeBlockSelector`,`navigationSelector`,`footerSelector`,`contentSelector`,`tabContainerSelector`,`tocSelector`,`feedbackSelector`];function ee(){let e=v[_.framework];e?y.forEach(t=>{_[t]||(_[t]=e[t])}):_.framework!==`custom`&&_.debug&&console.warn(`[Do11y] Unknown framework "${_.framework}". Falling back to generic selectors. Supported: `+Object.keys(v).join(`, `)+`, custom`);let t=v.mintlify;t&&y.forEach(e=>{_[e]||(_[e]=t[e])})}function b(){if(_.respectDNT&&(navigator.doNotTrack===`1`||navigator.doNotTrack===`yes`||window.doNotTrack===`1`))return _.debug&&console.log(`[Do11y] Disabled: Do Not Track is enabled`),!0;if(_.allowedDomains&&_.allowedDomains.length>0){let e=window.location.hostname;if(!_.allowedDomains.some(t=>e===t||e.endsWith(`.`+t)))return _.debug&&console.log(`[Do11y] Disabled: Domain not allowed:`,e),!0}return!1}function x(e){if(!e||typeof e!=`string`)return null;try{return document.querySelector(e),e}catch{return _.debug&&console.warn(`[Do11y] Invalid CSS selector rejected:`,e),null}}function S(e){if(typeof e.className==`string`)return e.className;let t=e.className;return t&&typeof t.baseVal==`string`?t.baseVal:``}function C(e){let t=e.match(/(?:^|\s)language-([\w-]+)(?:\s|$)/);return t?t[1]:null}function te(e){if(!e)return`unknown`;let t=e;for(let e=0;t&&e<12;e++,t=t.parentElement){for(let e of[`language`,`data-language`,`data-lang`,`data-code-lang`]){let n=t.getAttribute(e);if(n)return n}let e=C(S(t));if(e)return e;let n=t.querySelector(`:scope > span.lang`)?.textContent?.trim();if(n)return n;let r=t.querySelector(`[data-language], [data-lang], [data-code-lang], [class*="language-"], [language]`);if(r){let e=r.getAttribute(`language`)??r.getAttribute(`data-language`)??r.getAttribute(`data-lang`)??r.getAttribute(`data-code-lang`)??C(S(r));if(e)return e}}return`unknown`}function ne(e){if(e.startsWith(`#`))return e;let t=e.indexOf(`#`);if(t===-1)return null;let n=e.slice(0,t);return!n||n===window.location.pathname||n===`${window.location.pathname}${window.location.search}`?e.slice(t):null}function re(e){let t=x(_.tocSelector)??`.table-of-contents, .VPDocAsideOutline, .VPLocalNavOutlineDropdown, [class*="toc"], [class*="TableOfContents"], [class*="page-outline"], .right-sidebar-panel, starlight-toc`,n=e.closest(t);return n?((n===e||n.tagName===`A`)&&(n=e.closest(`.VPDocAsideOutline, .VPLocalNavOutlineDropdown, nav, aside, .right-sidebar-panel, starlight-toc`)??n.parentElement),n):null}function w(e,t){if(!e||typeof e!=`string`)return null;let n=t??100,r=e;return r=r.replace(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,`[email]`),r=r.replace(/\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g,`[phone]`),r=r.replace(/\b\d{3}-\d{2}-\d{4}\b/g,`[redacted]`),r=r.replace(/\b(?:\d[ -]?){13,19}\b/g,`[card]`),r=r.replace(/eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,`[token]`),r=r.replace(/\bxa[a-z]{2}-[A-Za-z0-9_-]{20,}/g,`[token]`),r=r.replace(/\b[0-9a-fA-F]{32,}\b/g,`[redacted]`),r.trim().substring(0,n)}function ie(){if(window.crypto&&typeof window.crypto.randomUUID==`function`)return window.crypto.randomUUID();if(window.crypto&&typeof window.crypto.getRandomValues==`function`){let e=new Uint8Array(16);window.crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.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)}return`no-crypto-00-0000-0000-000000000000`}function ae(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.startTime==`string`&&Array.isArray(t.pageSequence)&&typeof t.pageCount==`number`}function T(){let e=null;try{let t=sessionStorage.getItem(`do11y_session`);if(t){let n=JSON.parse(t);ae(n)&&(e=n)}}catch{}return e||(e={id:ie(),startTime:new Date().toISOString(),pageSequence:[],pageCount:0,referrerCategory:null,aiPlatform:null},E(e)),e}function E(e){try{sessionStorage.setItem(`do11y_session`,JSON.stringify(e))}catch{}}function oe(e){let t=T();return t.pageCount++,t.pageSequence.push({path:e,timestamp:new Date().toISOString(),index:t.pageCount}),t.pageSequence.length>50&&(t.pageSequence=t.pageSequence.slice(-50)),E(t),t}function se(){return{"browser.do11y.viewport_category":ce(),"browser.family":le(),"device.type":ue(),"browser.language":(navigator.language||``).split(`-`)[0]||`unknown`,"browser.do11y.timezone_offset":new Date().getTimezoneOffset()/60}}function ce(){let e=window.innerWidth;return e<640?`mobile`:e<1024?`tablet`:e<1440?`desktop`:`large-desktop`}function le(){let e=navigator.userAgent;return e.includes(`Firefox`)?`Firefox`:e.includes(`Edg`)?`Edge`:e.includes(`Chrome`)?`Chrome`:e.includes(`Safari`)?`Safari`:`Other`}function ue(){let e=navigator.userAgent;return/Mobile|Android|iPhone|iPad/.test(e)?/iPad|Tablet/.test(e)?`tablet`:`mobile`:`desktop`}let de=[{match:`chatgpt`,platform:`ChatGPT`},{match:`chat.com`,platform:`ChatGPT`},{match:`openai`,platform:`ChatGPT`},{match:`perplexity`,platform:`Perplexity`},{match:`claude.ai`,platform:`Claude`},{match:`anthropic`,platform:`Claude`},{match:`gemini`,platform:`Gemini`},{match:`copilot`,platform:`Copilot`},{match:`deepseek`,platform:`DeepSeek`},{match:`meta.ai`,platform:`Meta AI`},{match:`grok`,platform:`Grok`},{match:`x.ai`,platform:`Grok`},{match:`mistral`,platform:`Mistral`},{match:`you.com`,platform:`You.com`},{match:`phind`,platform:`Phind`}];function fe(e){if(!e||e===`direct`)return{referrerCategory:`direct`,aiPlatform:null};if(e===`internal`)return{referrerCategory:`internal`,aiPlatform:null};if(e===`unknown`)return{referrerCategory:`unknown`,aiPlatform:null};let t=e.toLowerCase();for(let e of de)if(t.indexOf(e.match)!==-1)return{referrerCategory:`ai`,aiPlatform:e.platform};return/google\.|bing\.|baidu\.|yandex\.|duckduckgo\.|yahoo\./.test(t)?{referrerCategory:`search-engine`,aiPlatform:null}:/github\.|gitlab\.|bitbucket\./.test(t)?{referrerCategory:`code-host`,aiPlatform:null}:/stackoverflow\.|stackexchange\.|reddit\.|news\.ycombinator\./.test(t)?{referrerCategory:`community`,aiPlatform:null}:/twitter\.|x\.com|linkedin\.|facebook\.|threads\.net/.test(t)?{referrerCategory:`social`,aiPlatform:null}:{referrerCategory:`other`,aiPlatform:null}}function pe(){try{if(!document.referrer)return`direct`;let e=new URL(document.referrer);return e.hostname===window.location.hostname?`internal`:e.hostname}catch{return`unknown`}}function me(){return{"url.path":window.location.pathname,"url.fragment":window.location.hash||null,"url.query":window.location.search?`has_params`:null,"browser.do11y.page_title":w(document.title,150)}}let D=[],O=null,k={},A=!1;function j(e,t){if(A)return;let n=Date.now();if(_.rateLimitMs>0&&k[e]&&n-k[e]<_.rateLimitMs){_.debug&&console.log(`[Do11y] Rate limited:`,e);return}k[e]=n;let r=T(),i={_time:new Date().toISOString(),eventName:e,"browser.do11y.version":m,"session.id":r.id,"browser.do11y.session_page_count":r.pageCount,...me(),...se(),...t};if(_.debug&&console.log(`[Do11y] Event queued:`,e,i),_.destination===`otlp`&&M){M.emit({eventName:e,severityNumber:9,attributes:i,body:``});return}D.push(i),D.length>100&&(D=D.slice(-100),_.debug&&console.warn(`[Do11y] Event queue capped at 100 events`)),D.length>=_.maxBatchSize?F():he()}function he(){O||=setTimeout(F,_.flushInterval)}let M=null;function ge(e){try{let t=new URL(e);return!(t.protocol!==`https:`||!t.hostname.endsWith(`.supabase.co`))}catch{return!1}}function _e(e){try{let t=new URL(e);if(t.protocol!==`https:`)return!1;let n=t.hostname;return!(n===`localhost`||n===`127.0.0.1`||n===`::1`||/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/.test(n))}catch{return!1}}function N(){return _.destination===`supabase`?_.supabaseUrl?ge(_.supabaseUrl)?!_.supabaseKey||typeof _.supabaseKey!=`string`||_.supabaseKey.length<10?(_.debug&&console.warn(`[Do11y] Invalid or missing Supabase publishable key`),!1):/^[a-zA-Z0-9_-]+$/.test(_.supabaseTable)?!0:(_.debug&&console.warn(`[Do11y] Invalid table name`),!1):(_.debug&&console.warn(`[Do11y] Invalid Supabase URL. Must be https://<project>.supabase.co`),!1):(_.debug&&console.warn(`[Do11y] No Supabase URL configured`),!1):_.destination===`http`?_.endpoint?_e(_.endpoint)?!0:(_.debug&&console.warn(`[Do11y] Invalid HTTP endpoint. Must be HTTPS and not a private address.`),!1):(_.debug&&console.warn(`[Do11y] No HTTP endpoint configured`),!1):_.destination===`otlp`?_.otelSdkEndpoint?(ve().catch(e=>{_.debug&&console.warn(`[Do11y] OTel SDK initialization failed:`,e)}),!0):(_.debug&&console.warn(`[Do11y] No OTLP endpoint configured`),!1):(_.debug&&console.warn(`[Do11y] Unknown destination:`,_.destination),!1)}async function ve(){if(M)return;let e=_.otelSdkCdnUrl.replace(/\/+$/,``)+`/`,t=await import(`${e}@opentelemetry/api-logs`),n=await import(`${e}@opentelemetry/sdk-logs`),r=await import(`${e}@opentelemetry/exporter-logs-otlp-http`),i={"service.name":_.otelSdkServiceName||`do11y`,"service.version":m,"telemetry.sdk.name":`do11y`,"telemetry.sdk.language":`webjs`,"telemetry.sdk.version":m,..._.otelSdkResourceAttributes},a=new n.LoggerProvider({resource:{attributes:i},processors:[new n.BatchLogRecordProcessor({exporter:new r.OTLPLogExporter({url:_.otelSdkEndpoint.replace(/\/$/,``)+`/v1/logs`,headers:_.otelSdkHeaders})})]});t.logs.setGlobalLoggerProvider(a),M=a.getLogger(`do11y`),_.debug&&console.log(`[Do11y] OTel SDK initialized with endpoint:`,_.otelSdkEndpoint)}function P(e){if(_.destination===`supabase`){let t=_.supabaseUrl.replace(/\/$/,``)+`/rest/v1/`+_.supabaseTable,n=_.bodyTransform??(e=>e.map(e=>({payload:e})));return{url:t,headers:{apikey:_.supabaseKey,Authorization:`Bearer `+_.supabaseKey,"Content-Type":`application/json`,Prefer:`return=minimal`},body:JSON.stringify(n(e))}}let t=_.bodyTransform??(e=>e);return{url:_.endpoint,headers:{"Content-Type":`application/json`,..._.headers},body:JSON.stringify(t(e))}}function F(e){if(O&&=(clearTimeout(O),null),D.length===0||!N())return;let t=typeof e==`number`?e:_.maxRetries,n=D.slice();D=[],be(P(n),n,t)}function ye(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function be(e,t,n){let r=ye(e.url);_.debug&&r&&console.log(`[Do11y] Cross-origin request to`,new URL(e.url).origin,`- requires CORS headers on the server`),fetch(e.url,{method:`POST`,headers:e.headers,body:e.body,keepalive:!0,mode:r?`cors`:`same-origin`}).then(e=>{if(e.ok){_.debug&&console.log(`[Do11y] Flushed`,t.length,`events`);return}if(n>0&&(e.status>=500||e.status===429)){_.debug&&console.log(`[Do11y] Retrying after error:`,e.status),D=t.concat(D),setTimeout(()=>{F(n-1)},_.retryDelay*(_.maxRetries-n+1));return}_.debug&&e.text().then(t=>{let n=`[Do11y] Ingest failed: ${e.status}`;e.status===0&&e.type===`opaque`?console.error(n,`- CORS error: server did not return Access-Control-Allow-Origin`):console.error(n,t)}).catch(()=>{})}).catch(e=>{if(n>0){if(_.debug){let t=r?` (this may be a CORS issue — try using an OTel Collector proxy)`:``;console.log(`[Do11y] Network error, retrying:`,e.message+t)}D=t.concat(D),setTimeout(()=>{F(n-1)},_.retryDelay*(_.maxRetries-n+1))}else _.debug&&console.error(`[Do11y] Failed to send events:`,e.message)})}function xe(){if(_.destination===`otlp`||D.length===0||!N())return;let e=D;D=[];let t=P(e);try{fetch(t.url,{method:`POST`,headers:t.headers,body:t.body,keepalive:!0})}catch{}_.debug&&console.log(`[Do11y] Sync flushed`,e.length,`events`)}function I(){K=!1;let n=oe(window.location.pathname),r=pe(),i=fe(r);n.pageCount===1&&(n.referrerCategory=i.referrerCategory,n.aiPlatform=i.aiPlatform,E(n)),j(`browser.do11y.page_view`,{"browser.do11y.referrer_domain":r,[e]:i.referrerCategory,[t]:i.aiPlatform,"browser.do11y.is_first_page":n.pageCount===1,"browser.do11y.previous_path":n.pageSequence.length>1?n.pageSequence[n.pageSequence.length-2].path:null})}function Se(){document.addEventListener(`click`,e=>{let t=e.target.closest(`a`);if(!t)return;let n=t.getAttribute(`href`);if(!n)return;let r=`other`,i=null;try{if(n.startsWith(`#`))r=`anchor`;else if(n.startsWith(`/`)||n.startsWith(`./`)||n.startsWith(`../`))r=`internal`;else if(n.startsWith(`http`)){let e=new URL(n);e.hostname===window.location.hostname?r=`internal`:(r=`external`,i=e.hostname)}else n.startsWith(`mailto:`)&&(r=`email`)}catch{}r===`internal`&&!_.trackInternalLinks||r===`external`&&!_.trackOutboundLinks||(j(`browser.do11y.link_click`,{"browser.do11y.link.type":r,"browser.do11y.link.target_url":n,"browser.do11y.link.target_domain":i,"browser.do11y.link.text":w(t.textContent,100),"browser.do11y.link.context":Ce(t),"browser.do11y.link.section":w(L(t),100),"browser.do11y.link.index":we(t,n)}),F())},!0)}function Ce(e){return e.closest(_.navigationSelector)?`navigation`:e.closest(_.footerSelector)?`footer`:e.closest(_.contentSelector)?`content`:`other`}function L(e){let t=e;for(;t&&t!==document.body;){let e=t.previousElementSibling;for(;e;){if(/^H[1-6]$/.test(e.tagName))return e.textContent?.trim().substring(0,100)??null;let t=e.querySelectorAll(`h1, h2, h3, h4, h5, h6`);if(t.length>0)return t[t.length-1].textContent?.trim().substring(0,100)??null;e=e.previousElementSibling}t=t.parentElement}return null}function we(e,t){if(typeof CSS>`u`||typeof CSS.escape!=`function`)return 1;try{let n=document.querySelectorAll(`a[href="`+CSS.escape(t)+`"]`);for(let t=0;t<n.length;t++)if(n[t]===e)return t+1}catch{}return 1}let R=new Set,z=null;function B(e){let t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let e=window.getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function Te(){if(!_.trackScrollDepth)return;if(_.contentSelector){let e=document.querySelector(_.contentSelector);e&&(z=B(e))}let e=!1;function t(){e||=(window.requestAnimationFrame(()=>{V(),e=!1}),!0)}if(window.addEventListener(`scroll`,t),z&&(z.addEventListener(`scroll`,t),_.debug)){let e=z;console.log(`[do11y] Using container-based scroll tracking:`,e.className||e.tagName)}V()}function V(){let e,t,i;z&&z.scrollHeight>z.clientHeight?(e=z.scrollTop,t=z.scrollHeight,i=z.clientHeight):(e=window.scrollY||document.documentElement.scrollTop,t=document.documentElement.scrollHeight,i=window.innerHeight);let a=t-i;if(a<=0){_.scrollThresholds.forEach(e=>{R.has(e)||(R.add(e),j(u,{[n]:e,[r]:100}))});return}let o=Math.round(e/a*100);_.scrollThresholds.forEach(e=>{o>=e&&!R.has(e)&&(R.add(e),j(u,{[n]:e,[r]:o}))})}let H=Date.now(),U=Date.now(),W=0,G=!0,K=!1;function q(){if(K)return;K=!0,G&&(W+=Date.now()-U);let n=Date.now()-H,r=n>0?W/n:0,i=0;R.forEach(e=>{e>i&&(i=e)}),Z();let a=T();j(`browser.do11y.page_exit`,{"browser.do11y.page_exit.total_time_seconds":Math.round(n/1e3),"browser.do11y.page_exit.active_time_seconds":Math.round(W/1e3),"browser.do11y.page_exit.engagement_ratio":Math.round(r*100)/100,"browser.do11y.page_exit.max_scroll_depth":i,[e]:a.referrerCategory,[t]:a.aiPlatform})}function Ee(){document.addEventListener(`visibilitychange`,()=>{document.hidden?G&&=(W+=Date.now()-U,!1):(U=Date.now(),G=!0)}),window.addEventListener(`beforeunload`,()=>{q(),Fe()})}function De(){document.addEventListener(`click`,e=>{e.target.closest(_.searchSelector)&&j(d,{})},!0),document.addEventListener(`keydown`,e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&j(d,{"browser.do11y.search.trigger":`keyboard`})})}function Oe(e){if(!e)return 1;try{let t=document.querySelectorAll(_.codeBlockSelector);for(let n=0;n<t.length;n++)if(t[n]===e)return n+1}catch{}return 1}function ke(){document.addEventListener(`click`,e=>{let t=e.target.closest(_.copyButtonSelector);if(t){let e=t.closest(`[class*="language-"], [language]`)??t.closest(_.codeBlockSelector)??t.closest(`.expressive-code`)?.querySelector(`pre`)??t.closest(`div, section`)?.querySelector(`pre`)??t.parentElement?.querySelector(`pre`)??null,n=te((e?e.tagName===`PRE`?e.querySelector(`code`):e.querySelector(`code[class*="language-"], code[language]`)??e.querySelector(`code`):null)??e??t);j(`browser.do11y.code_copied`,{"browser.do11y.code.language":n,"browser.do11y.code.section":w(L(e??t),100),"browser.do11y.code.index":Oe(e)})}},!0)}let J=null,Y={};function Ae(){if(!_.trackSectionVisibility||typeof IntersectionObserver>`u`)return;let e=_.sectionVisibleThreshold*1e3;J=new IntersectionObserver(t=>{t.forEach(t=>{let n=t.target.getAttribute(`data-do11y-section-id`);if(n)if(t.isIntersecting)Y[n]||(Y[n]={start:Date.now(),reported:!1});else{if(Y[n]&&!Y[n].reported){let r=Date.now()-Y[n].start;if(r>=e){let e=t.target.textContent?.trim()??``;j(f,{[i]:w(e,100),[a]:parseInt(t.target.tagName.charAt(1),10),[o]:Math.round(r/1e3)}),Y[n].reported=!0}}delete Y[n]}})},{threshold:.5}),X()}function X(){J&&document.querySelectorAll(`h2, h3`).forEach((e,t)=>{e.setAttribute(`data-do11y-section-id`,`section-`+t),J.observe(e)})}function Z(){if(!J)return;let e=Date.now(),t=_.sectionVisibleThreshold*1e3;Object.keys(Y).forEach(n=>{let r=Y[n];if(r&&!r.reported){let s=e-r.start;if(s>=t){let e=typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(n):n.replace(/["\\]/g,`\\$&`),t=document.querySelector(`[data-do11y-section-id="`+e+`"]`);t&&j(f,{[i]:w(t.textContent?.trim()??``,100),[a]:parseInt(t.tagName.charAt(1),10),[o]:Math.round(s/1e3)})}}}),Y={}}function je(){_.trackTabSwitches&&document.addEventListener(`click`,e=>{let t=`[role="tab"], .tabs button, .tabs a, .tabbed-labels label`,n=x(_.tabContainerSelector);n&&(t+=`, `+n+` button, `+n+` a, `+n+` label`);let r=e.target.closest(t);if(!r||r.getAttribute(`aria-selected`)===`true`||r.classList.contains(`active`)||r.classList.contains(`is-active`))return;let i=w(r.textContent,50);if(!i)return;let a=w(L(r),100);j(`browser.do11y.tab_switch`,{"browser.do11y.tab.label":i,"browser.do11y.tab.group":a,"browser.do11y.tab.is_default":!1})})}function Me(){_.trackTocClicks&&document.addEventListener(`click`,e=>{let t=e.target.closest(`a`);if(!t)return;let n=re(t);if(!n)return;let r=t.getAttribute(`href`),i=r?ne(r):null;if(!i)return;let a=w(t.textContent,100),o=null;try{let e=i.slice(1),t=document.getElementById(e);t&&/^H[1-6]$/.test(t.tagName)&&(o=parseInt(t.tagName.charAt(1),10))}catch{}let s=n.querySelectorAll(`a[href*="#"]`),c=1;for(let e=0;e<s.length;e++)if(s[e]===t){c=e+1;break}j(`browser.do11y.toc_click`,{"browser.do11y.toc.heading":a,"browser.do11y.toc.heading_level":o,"browser.do11y.toc.position":c})},!0)}function Ne(){_.trackFeedback&&document.addEventListener(`click`,e=>{let t=e.target.closest(`button, [role="button"], a`);if(!t||!t.closest(x(_.feedbackSelector)??`[class*="feedback"], [class*="helpful"], [class*="rating"], [class*="was-this"], [data-feedback]`))return;let n=(t.textContent??``).trim().toLowerCase(),r=(t.getAttribute(`aria-label`)??``).toLowerCase(),i=(t.getAttribute(`title`)??``).toLowerCase(),a=t.getAttribute(`data-value`)??t.getAttribute(`data-md-value`)??t.getAttribute(`data-feedback`),o=a&&/^[\w\s.,!?-]{1,50}$/.test(a)?a:null,s=null;o?s=o:/\byes\b|👍|thumbs.?up|helpful/i.test(n+` `+r+` `+i)?s=`yes`:/\bno\b|👎|thumbs.?down|not.?helpful/i.test(n+` `+r+` `+i)&&(s=`no`),s&&j(`browser.do11y.feedback`,{"browser.do11y.feedback.rating":s})})}function Pe(){_.trackExpandCollapse&&(document.addEventListener(`toggle`,e=>{let t=e.target;if(t.tagName!==`DETAILS`)return;let n=t.querySelector(`summary`),r=w(n?n.textContent:``,100);j(p,{[s]:r,[c]:t.open?`expand`:`collapse`,[l]:w(L(t),100)})},!0),document.addEventListener(`click`,e=>{let t=e.target.closest(`[aria-expanded], [class*="accordion"] button, [class*="collapsible"] button`);if(!t||t.closest(`details`)||t.closest(`nav, [role="navigation"], header`))return;let n=t.getAttribute(`aria-expanded`)===`true`;j(p,{[s]:w(t.textContent,100),[c]:n?`collapse`:`expand`,[l]:w(L(t),100)})}))}let Q=null;function $(){if(window.Do11yConfig&&typeof window.Do11yConfig==`object`)for(let e in window.Do11yConfig)Object.prototype.hasOwnProperty.call(window.Do11yConfig,e)&&Object.prototype.hasOwnProperty.call(_,e)&&(_[e]=window.Do11yConfig[e]);let e=document.querySelector(`meta[name="do11y-destination"]`);if(e){let t=e.getAttribute(`content`);(t===`supabase`||t===`http`||t===`otlp`)&&(_.destination=t)}let t=document.querySelector(`meta[name="do11y-url"]`);t&&(_.supabaseUrl=t.getAttribute(`content`)??_.supabaseUrl);let n=document.querySelector(`meta[name="do11y-key"]`);n&&(_.supabaseKey=n.getAttribute(`content`)??_.supabaseKey);let r=document.querySelector(`meta[name="do11y-table"]`);r&&(_.supabaseTable=r.getAttribute(`content`)??_.supabaseTable);let i=document.querySelector(`meta[name="do11y-endpoint"]`);i&&(_.endpoint=i.getAttribute(`content`)??_.endpoint);let a=document.querySelector(`meta[name="do11y-otlp-endpoint"]`);a&&(_.otelSdkEndpoint=a.getAttribute(`content`)??_.otelSdkEndpoint);let o=document.querySelector(`meta[name="do11y-otlp-headers"]`);if(o)try{let e=JSON.parse(o.getAttribute(`content`)??`{}`);typeof e==`object`&&e&&(_.otelSdkHeaders=e)}catch{}let s=document.querySelector(`meta[name="do11y-debug"]`);s&&s.getAttribute(`content`)===`true`&&(_.debug=!0);let c=document.querySelector(`meta[name="do11y-domains"]`);if(c){let e=c.getAttribute(`content`);e&&(_.allowedDomains=e.split(`,`).map(e=>e.trim()))}let l=document.querySelector(`meta[name="do11y-framework"]`);l&&(_.framework=l.getAttribute(`content`)??_.framework);let u=document.querySelector(`meta[name="do11y-use-otel-instrumentations"]`);if(u&&u.getAttribute(`content`)===`true`&&(_.useOtelBrowserInstrumentations=!0),ee(),_.debug){let e=_.destination===`supabase`?!!_.supabaseKey:_.destination===`otlp`?!!_.otelSdkEndpoint:!!_.endpoint;console.log(`[Do11y] Initializing with config:`,{destination:_.destination,hasCredentials:e,framework:_.framework,allowedDomains:_.allowedDomains,respectDNT:_.respectDNT})}if(b()){A=!0,_.debug&&console.log(`[Do11y] Tracking disabled`);return}(_.destination===`supabase`?_.supabaseKey:_.destination===`otlp`?_.otelSdkEndpoint:_.endpoint)||_.debug&&(console.warn(`[Do11y] No destination configured. Events will not be sent.`),_.destination===`supabase`?console.warn(`[Do11y] Add <meta name="do11y-url"> and <meta name="do11y-key"> to enable.`):_.destination===`otlp`?console.warn(`[Do11y] Add <meta name="do11y-otlp-endpoint"> to enable.`):console.warn(`[Do11y] Add <meta name="do11y-endpoint"> to enable.`)),I(),Se(),Te(),Ee(),De(),ke(),Ae(),je(),Me(),Ne(),Pe();let d=window.location.pathname;Q=new MutationObserver(()=>{window.location.pathname!==d&&(d=window.location.pathname,q(),R=new Set,H=Date.now(),U=Date.now(),W=0,G=!0,I(),X(),V())}),Q.observe(document.body,{childList:!0,subtree:!0}),window.addEventListener(`popstate`,()=>{window.location.pathname!==d&&(d=window.location.pathname,q(),R=new Set,H=Date.now(),U=Date.now(),W=0,G=!0,I(),X(),V())}),Object.freeze(_),_.debug&&console.log(`[Do11y] Initialized successfully`)}function Fe(){Q&&=(Q.disconnect(),null),J&&=(Z(),J.disconnect(),null),O&&=(clearTimeout(O),null),xe()}!h&&!g&&(document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,$):$()),window.Do11y=window.Do11y??{getConfig:()=>({destination:_.destination,hasCredentials:_.destination===`supabase`?!!_.supabaseKey:_.destination===`otlp`?!!_.otelSdkEndpoint:!!_.endpoint,isDisabled:A,allowedDomains:_.allowedDomains,respectDNT:_.respectDNT}),flush:F,isEnabled:()=>A?!1:_.destination===`supabase`?!!_.supabaseKey:_.destination===`otlp`?!!_.otelSdkEndpoint:!!_.endpoint,getQueueSize:()=>D.length,version:m}})();
|
|
1
|
+
(function(){let e=`browser.do11y.referrer_category`,t=`browser.do11y.ai_platform`,n=`browser.do11y.scroll.threshold`,r=`browser.do11y.scroll.percent`,i=`browser.do11y.section.heading`,a=`browser.do11y.section.heading_level`,o=`browser.do11y.section.visible_seconds`,s=`browser.do11y.expand.summary`,c=`browser.do11y.expand.action`,l=`browser.do11y.expand.section`,u=`browser.do11y.scroll_depth`,d=`browser.do11y.search_opened`,f=`browser.do11y.section_visible`,p=`browser.do11y.expand_collapse`,m=`0.1.2`,h=!!window.__do11yInitialized;window.__do11yInitialized=!0;let g=window.self!==window.top;g&&!h&&(window.__do11yInitialized=!1);let _={destination:`supabase`,supabaseUrl:``,supabaseKey:``,supabaseTable:`do11y_events`,endpoint:``,headers:{},bodyTransform:void 0,otelSdkEndpoint:``,otelSdkHeaders:{},otelSdkServiceName:`do11y`,otelSdkResourceAttributes:{},otelSdkCdnUrl:`https://esm.sh/`,debug:!1,flushInterval:5e3,maxBatchSize:10,trackOutboundLinks:!0,trackInternalLinks:!0,trackScrollDepth:!0,scrollThresholds:[25,50,75,90],allowedDomains:null,respectDNT:!0,maxRetries:2,retryDelay:1e3,rateLimitMs:100,framework:`mintlify`,trackSectionVisibility:!0,sectionVisibleThreshold:3,trackTabSwitches:!0,trackTocClicks:!0,trackExpandCollapse:!0,trackFeedback:!0,tabContainerSelector:null,tocSelector:null,feedbackSelector:null,searchSelector:null,copyButtonSelector:null,codeBlockSelector:null,navigationSelector:null,footerSelector:null,contentSelector:null,useOtelBrowserInstrumentations:!1,testRunId:void 0,testFramework:void 0},v={mintlify:{searchSelector:`#search-bar-entry, #search-bar-entry-mobile, [class*="search"]`,copyButtonSelector:`button[class*="copy"], button[aria-label*="copy" i]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], #navbar, #sidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`tabs, [role="tablist"], [class*="tab"]`,tocSelector:`#table-of-contents, [data-testid="table-of-contents"], [class*="table-of-contents"], [class*="toc"]`,feedbackSelector:`feedback-toolbar, #feedback-thumbs-up, #feedback-thumbs-down, [class*="feedback"], [class*="helpful"]`},docusaurus:{searchSelector:`.DocSearch, .DocSearch-Button`,copyButtonSelector:`button.clean-btn[aria-label*="copy" i], button[class*="copyButton"]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .navbar, .sidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`.tabs[role="tablist"], [class*="tabs"]`,tocSelector:`.table-of-contents, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},nextra:{searchSelector:`.nextra-search input, input[placeholder*="search" i], button[aria-label*="search" i]`,copyButtonSelector:`button[class*="copy"], button[aria-label*="copy" i], button[title*="copy" i]`,codeBlockSelector:`pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, article, [role="main"], [class*="content"]`,tabContainerSelector:`[role="tablist"], [class*="tab"]`,tocSelector:`.nextra-toc, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},"mkdocs-material":{searchSelector:`.md-search__input`,copyButtonSelector:`.md-clipboard, .md-code__button[title="Copy to clipboard"]`,codeBlockSelector:`pre, code, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .md-nav, .md-sidebar`,footerSelector:`footer, [role="contentinfo"], .md-footer`,contentSelector:`main, article, [role="main"], .md-content`,tabContainerSelector:`.tabbed-labels, .md-typeset .tabbed-set`,tocSelector:`.md-sidebar--secondary .md-nav, [class*="toc"]`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},vitepress:{searchSelector:`.VPNavBarSearch button, .VPNavBarSearchButton, #local-search`,copyButtonSelector:`button.copy, .vp-code-copy, button.copy[title*="Copy"]`,codeBlockSelector:`div[class*="language-"], pre, [class*="code"]`,navigationSelector:`nav, [role="navigation"], .VPNav, .VPSidebar, [class*="nav"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], .VPFooter, [class*="footer"]`,contentSelector:`main, article, [role="main"], .VPContent, [class*="content"]`,tabContainerSelector:`.vp-code-group .tabs, [role="tablist"]`,tocSelector:`.VPDocAsideOutline, .VPLocalNavOutlineDropdown, a.outline-link`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},starlight:{searchSelector:`site-search button[data-open-modal], sl-doc-search .DocSearch-Button, button[aria-label*="search" i]`,copyButtonSelector:`.expressive-code .copy button, .copy button[data-code]`,codeBlockSelector:`.expressive-code pre, pre`,navigationSelector:`nav, [role="navigation"], [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], [class*="footer"]`,contentSelector:`main, .sl-markdown-content, [role="main"]`,tabContainerSelector:`starlight-tabs [role="tablist"], [role="tablist"]`,tocSelector:`.right-sidebar-panel, starlight-toc, mobile-starlight-toc`,feedbackSelector:`[class*="feedback"], [class*="helpful"]`},docsy:{searchSelector:`.td-search input, .td-search__input, #docsearch-0, #docsearch-1`,copyButtonSelector:`button[aria-label*="copy" i], button[title*="copy" i], .td-click-to-copy`,codeBlockSelector:`.highlight, pre.chroma, pre`,navigationSelector:`nav, [role="navigation"], .td-sidebar, .td-navbar, [class*="sidebar"]`,footerSelector:`footer, [role="contentinfo"], .td-footer, [class*="footer"]`,contentSelector:`main, article, [role="main"], .td-content, [class*="content"]`,tabContainerSelector:`.nav-tabs[role="tablist"], [role="tablist"], .tab-content`,tocSelector:`.td-toc, nav[id="TableOfContents"], [class*="toc"]`,feedbackSelector:`.feedback--answer, [class*="feedback"], [class*="helpful"]`}},y=[`searchSelector`,`copyButtonSelector`,`codeBlockSelector`,`navigationSelector`,`footerSelector`,`contentSelector`,`tabContainerSelector`,`tocSelector`,`feedbackSelector`];function ee(){let e=v[_.framework];e?y.forEach(t=>{_[t]||(_[t]=e[t])}):_.framework!==`custom`&&_.debug&&console.warn(`[Do11y] Unknown framework "${_.framework}". Falling back to generic selectors. Supported: `+Object.keys(v).join(`, `)+`, custom`);let t=v.mintlify;t&&y.forEach(e=>{_[e]||(_[e]=t[e])})}function te(){if(_.respectDNT&&(navigator.doNotTrack===`1`||navigator.doNotTrack===`yes`||window.doNotTrack===`1`))return _.debug&&console.log(`[Do11y] Disabled: Do Not Track is enabled`),!0;if(_.allowedDomains&&_.allowedDomains.length>0){let e=window.location.hostname;if(!_.allowedDomains.some(t=>e===t||e.endsWith(`.`+t)))return _.debug&&console.log(`[Do11y] Disabled: Domain not allowed:`,e),!0}return!1}function b(e){if(!e||typeof e!=`string`)return null;try{return document.querySelector(e),e}catch{return _.debug&&console.warn(`[Do11y] Invalid CSS selector rejected:`,e),null}}function x(e){if(typeof e.className==`string`)return e.className;let t=e.className;return t&&typeof t.baseVal==`string`?t.baseVal:``}function S(e){let t=e.match(/(?:^|\s)language-([\w-]+)(?:\s|$)/);return t?t[1]:null}function C(e){if(!e)return`unknown`;let t=e;for(let e=0;t&&e<12;e++,t=t.parentElement){for(let e of[`language`,`data-language`,`data-lang`,`data-code-lang`]){let n=t.getAttribute(e);if(n)return n}let e=S(x(t));if(e)return e;let n=t.querySelector(`:scope > span.lang`)?.textContent?.trim();if(n)return n;let r=t.querySelector(`[data-language], [data-lang], [data-code-lang], [class*="language-"], [language]`);if(r){let e=r.getAttribute(`language`)??r.getAttribute(`data-language`)??r.getAttribute(`data-lang`)??r.getAttribute(`data-code-lang`)??S(x(r));if(e)return e}}return`unknown`}function ne(e){if(e.startsWith(`#`))return e;let t=e.indexOf(`#`);if(t===-1)return null;let n=e.slice(0,t);return!n||n===window.location.pathname||n===`${window.location.pathname}${window.location.search}`?e.slice(t):null}function re(e){let t=b(_.tocSelector)??`.table-of-contents, .VPDocAsideOutline, .VPLocalNavOutlineDropdown, [class*="toc"], [class*="TableOfContents"], [class*="page-outline"], .right-sidebar-panel, starlight-toc`,n=e.closest(t);return n?((n===e||n.tagName===`A`)&&(n=e.closest(`.VPDocAsideOutline, .VPLocalNavOutlineDropdown, nav, aside, .right-sidebar-panel, starlight-toc`)??n.parentElement),n):null}function w(e,t){if(!e||typeof e!=`string`)return null;let n=t??100,r=e;return r=r.replace(/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,`[email]`),r=r.replace(/\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g,`[phone]`),r=r.replace(/\b\d{3}-\d{2}-\d{4}\b/g,`[redacted]`),r=r.replace(/\b(?:\d[ -]?){13,19}\b/g,`[card]`),r=r.replace(/eyJ[A-Za-z0-9_-]+\.eyJ[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,`[token]`),r=r.replace(/\bxa[a-z]{2}-[A-Za-z0-9_-]{20,}/g,`[token]`),r=r.replace(/\b[0-9a-fA-F]{32,}\b/g,`[redacted]`),r.trim().substring(0,n)}function ie(){if(window.crypto&&typeof window.crypto.randomUUID==`function`)return window.crypto.randomUUID();if(window.crypto&&typeof window.crypto.getRandomValues==`function`){let e=new Uint8Array(16);window.crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.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)}return`no-crypto-00-0000-0000-000000000000`}function ae(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.startTime==`string`&&Array.isArray(t.pageSequence)&&typeof t.pageCount==`number`}function T(){let e=null;try{let t=sessionStorage.getItem(`do11y_session`);if(t){let n=JSON.parse(t);ae(n)&&(e=n)}}catch{}return e||(e={id:ie(),startTime:new Date().toISOString(),pageSequence:[],pageCount:0,referrerCategory:null,aiPlatform:null},E(e)),e}function E(e){try{sessionStorage.setItem(`do11y_session`,JSON.stringify(e))}catch{}}function oe(e){let t=T();return t.pageCount++,t.pageSequence.push({path:e,timestamp:new Date().toISOString(),index:t.pageCount}),t.pageSequence.length>50&&(t.pageSequence=t.pageSequence.slice(-50)),E(t),t}function se(){return{"browser.do11y.viewport_category":ce(),"browser.family":le(),"device.type":ue(),"browser.language":(navigator.language||``).split(`-`)[0]||`unknown`,"browser.do11y.timezone_offset":new Date().getTimezoneOffset()/60}}function ce(){let e=window.innerWidth;return e<640?`mobile`:e<1024?`tablet`:e<1440?`desktop`:`large-desktop`}function le(){let e=navigator.userAgent;return e.includes(`Firefox`)?`Firefox`:e.includes(`Edg`)?`Edge`:e.includes(`Chrome`)?`Chrome`:e.includes(`Safari`)?`Safari`:`Other`}function ue(){let e=navigator.userAgent;return/Mobile|Android|iPhone|iPad/.test(e)?/iPad|Tablet/.test(e)?`tablet`:`mobile`:`desktop`}let de=[{match:`chatgpt`,platform:`ChatGPT`},{match:`chat.com`,platform:`ChatGPT`},{match:`openai`,platform:`ChatGPT`},{match:`perplexity`,platform:`Perplexity`},{match:`claude.ai`,platform:`Claude`},{match:`anthropic`,platform:`Claude`},{match:`gemini`,platform:`Gemini`},{match:`copilot`,platform:`Copilot`},{match:`deepseek`,platform:`DeepSeek`},{match:`meta.ai`,platform:`Meta AI`},{match:`grok`,platform:`Grok`},{match:`x.ai`,platform:`Grok`},{match:`mistral`,platform:`Mistral`},{match:`you.com`,platform:`You.com`},{match:`phind`,platform:`Phind`}];function fe(e){if(!e||e===`direct`)return{referrerCategory:`direct`,aiPlatform:null};if(e===`internal`)return{referrerCategory:`internal`,aiPlatform:null};if(e===`unknown`)return{referrerCategory:`unknown`,aiPlatform:null};let t=e.toLowerCase();for(let e of de)if(t.indexOf(e.match)!==-1)return{referrerCategory:`ai`,aiPlatform:e.platform};return/google\.|bing\.|baidu\.|yandex\.|duckduckgo\.|yahoo\./.test(t)?{referrerCategory:`search-engine`,aiPlatform:null}:/github\.|gitlab\.|bitbucket\./.test(t)?{referrerCategory:`code-host`,aiPlatform:null}:/stackoverflow\.|stackexchange\.|reddit\.|news\.ycombinator\./.test(t)?{referrerCategory:`community`,aiPlatform:null}:/twitter\.|x\.com|linkedin\.|facebook\.|threads\.net/.test(t)?{referrerCategory:`social`,aiPlatform:null}:{referrerCategory:`other`,aiPlatform:null}}function pe(){try{if(!document.referrer)return`direct`;let e=new URL(document.referrer);return e.hostname===window.location.hostname?`internal`:e.hostname}catch{return`unknown`}}function me(){return{"url.path":window.location.pathname,"url.fragment":window.location.hash||null,"url.query":window.location.search?`has_params`:null,"browser.do11y.page_title":w(document.title,150)}}let D=[],O=null,k={},A=!1;function j(e,t){if(A)return;let n=Date.now();if(_.rateLimitMs>0&&k[e]&&n-k[e]<_.rateLimitMs){_.debug&&console.log(`[Do11y] Rate limited:`,e);return}k[e]=n;let r=T(),i={_time:new Date().toISOString(),eventName:e,"browser.do11y.version":m,"session.id":r.id,"browser.do11y.session_page_count":r.pageCount,...me(),...se(),...t};if(_.testRunId&&(i._testRunId=_.testRunId),_.testFramework&&(i._testFramework=_.testFramework),_.debug&&console.log(`[Do11y] Event queued:`,e,i),_.destination===`otlp`&&M){M.emit({eventName:e,severityNumber:9,attributes:i,body:``});return}D.push(i),D.length>100&&(D=D.slice(-100),_.debug&&console.warn(`[Do11y] Event queue capped at 100 events`)),D.length>=_.maxBatchSize?F():he()}function he(){O||=setTimeout(F,_.flushInterval)}let M=null;function ge(e){try{let t=new URL(e);return!(t.protocol!==`https:`||!t.hostname.endsWith(`.supabase.co`))}catch{return!1}}function _e(e){try{let t=new URL(e);if(t.protocol!==`https:`)return!1;let n=t.hostname;return!(n===`localhost`||n===`127.0.0.1`||n===`::1`||/^(10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.)/.test(n))}catch{return!1}}function N(){return _.destination===`supabase`?_.supabaseUrl?ge(_.supabaseUrl)?!_.supabaseKey||typeof _.supabaseKey!=`string`||_.supabaseKey.length<10?(_.debug&&console.warn(`[Do11y] Invalid or missing Supabase publishable key`),!1):/^[a-zA-Z0-9_-]+$/.test(_.supabaseTable)?!0:(_.debug&&console.warn(`[Do11y] Invalid table name`),!1):(_.debug&&console.warn(`[Do11y] Invalid Supabase URL. Must be https://<project>.supabase.co`),!1):(_.debug&&console.warn(`[Do11y] No Supabase URL configured`),!1):_.destination===`http`?_.endpoint?_e(_.endpoint)?!0:(_.debug&&console.warn(`[Do11y] Invalid HTTP endpoint. Must be HTTPS and not a private address.`),!1):(_.debug&&console.warn(`[Do11y] No HTTP endpoint configured`),!1):_.destination===`otlp`?_.otelSdkEndpoint?(ve().catch(e=>{_.debug&&console.warn(`[Do11y] OTel SDK initialization failed:`,e)}),!0):(_.debug&&console.warn(`[Do11y] No OTLP endpoint configured`),!1):(_.debug&&console.warn(`[Do11y] Unknown destination:`,_.destination),!1)}async function ve(){if(M)return;let e=_.otelSdkCdnUrl.replace(/\/+$/,``)+`/`,t=await import(`${e}@opentelemetry/api-logs`),n=await import(`${e}@opentelemetry/sdk-logs`),r=await import(`${e}@opentelemetry/exporter-logs-otlp-http`),i={"service.name":_.otelSdkServiceName||`do11y`,"service.version":m,"telemetry.sdk.name":`do11y`,"telemetry.sdk.language":`webjs`,"telemetry.sdk.version":m,..._.otelSdkResourceAttributes},a=new n.LoggerProvider({resource:{attributes:i},processors:[new n.BatchLogRecordProcessor({exporter:new r.OTLPLogExporter({url:_.otelSdkEndpoint.replace(/\/$/,``)+`/v1/logs`,headers:_.otelSdkHeaders})})]});t.logs.setGlobalLoggerProvider(a),M=a.getLogger(`do11y`),_.debug&&console.log(`[Do11y] OTel SDK initialized with endpoint:`,_.otelSdkEndpoint)}function P(e){if(_.destination===`supabase`){let t=_.supabaseUrl.replace(/\/$/,``)+`/rest/v1/`+_.supabaseTable,n=_.bodyTransform??(e=>e.map(e=>({payload:e})));return{url:t,headers:{apikey:_.supabaseKey,Authorization:`Bearer `+_.supabaseKey,"Content-Type":`application/json`,Prefer:`return=minimal`},body:JSON.stringify(n(e))}}let t=_.bodyTransform??(e=>e);return{url:_.endpoint,headers:{"Content-Type":`application/json`,..._.headers},body:JSON.stringify(t(e))}}function F(e){if(O&&=(clearTimeout(O),null),D.length===0||!N())return;let t=typeof e==`number`?e:_.maxRetries,n=D.slice();D=[],be(P(n),n,t)}function ye(e){try{return new URL(e).origin!==window.location.origin}catch{return!1}}function be(e,t,n){let r=ye(e.url);_.debug&&r&&console.log(`[Do11y] Cross-origin request to`,new URL(e.url).origin,`- requires CORS headers on the server`),fetch(e.url,{method:`POST`,headers:e.headers,body:e.body,keepalive:!0,mode:r?`cors`:`same-origin`}).then(e=>{if(e.ok){_.debug&&console.log(`[Do11y] Flushed`,t.length,`events`);return}if(n>0&&(e.status>=500||e.status===429)){_.debug&&console.log(`[Do11y] Retrying after error:`,e.status),D=t.concat(D),setTimeout(()=>{F(n-1)},_.retryDelay*(_.maxRetries-n+1));return}_.debug&&e.text().then(t=>{let n=`[Do11y] Ingest failed: ${e.status}`;e.status===0&&e.type===`opaque`?console.error(n,`- CORS error: server did not return Access-Control-Allow-Origin`):console.error(n,t)}).catch(()=>{})}).catch(e=>{if(n>0){if(_.debug){let t=r?` (this may be a CORS issue — try using an OTel Collector proxy)`:``;console.log(`[Do11y] Network error, retrying:`,e.message+t)}D=t.concat(D),setTimeout(()=>{F(n-1)},_.retryDelay*(_.maxRetries-n+1))}else _.debug&&console.error(`[Do11y] Failed to send events:`,e.message)})}function xe(){if(_.destination===`otlp`||D.length===0||!N())return;let e=D;D=[];let t=P(e);try{fetch(t.url,{method:`POST`,headers:t.headers,body:t.body,keepalive:!0})}catch{}_.debug&&console.log(`[Do11y] Sync flushed`,e.length,`events`)}function I(){G=!1;let n=oe(window.location.pathname),r=pe(),i=fe(r);n.pageCount===1&&(n.referrerCategory=i.referrerCategory,n.aiPlatform=i.aiPlatform,E(n)),j(`browser.do11y.page_view`,{"browser.do11y.referrer_domain":r,[e]:i.referrerCategory,[t]:i.aiPlatform,"browser.do11y.is_first_page":n.pageCount===1,"browser.do11y.previous_path":n.pageSequence.length>1?n.pageSequence[n.pageSequence.length-2].path:null})}function Se(){document.addEventListener(`click`,e=>{let t=e.target.closest(`a`);if(!t)return;let n=t.getAttribute(`href`);if(!n)return;let r=`other`,i=null;try{if(n.startsWith(`#`))r=`anchor`;else if(n.startsWith(`/`)||n.startsWith(`./`)||n.startsWith(`../`))r=`internal`;else if(n.startsWith(`http`)){let e=new URL(n);e.hostname===window.location.hostname?r=`internal`:(r=`external`,i=e.hostname)}else n.startsWith(`mailto:`)&&(r=`email`)}catch{}r===`internal`&&!_.trackInternalLinks||r===`external`&&!_.trackOutboundLinks||(j(`browser.do11y.link_click`,{"browser.do11y.link.type":r,"browser.do11y.link.target_url":n,"browser.do11y.link.target_domain":i,"browser.do11y.link.text":w(t.textContent,100),"browser.do11y.link.context":Ce(t),"browser.do11y.link.section":w(L(t),100),"browser.do11y.link.index":we(t,n)}),F())},!0)}function Ce(e){return e.closest(_.navigationSelector)?`navigation`:e.closest(_.footerSelector)?`footer`:e.closest(_.contentSelector)?`content`:`other`}function L(e){let t=e;for(;t&&t!==document.body;){let e=t.previousElementSibling;for(;e;){if(/^H[1-6]$/.test(e.tagName))return e.textContent?.trim().substring(0,100)??null;let t=e.querySelectorAll(`h1, h2, h3, h4, h5, h6`);if(t.length>0)return t[t.length-1].textContent?.trim().substring(0,100)??null;e=e.previousElementSibling}t=t.parentElement}return null}function we(e,t){if(typeof CSS>`u`||typeof CSS.escape!=`function`)return 1;try{let n=document.querySelectorAll(`a[href="`+CSS.escape(t)+`"]`);for(let t=0;t<n.length;t++)if(n[t]===e)return t+1}catch{}return 1}let R=new Set,z=null;function Te(e){let t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let e=window.getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function Ee(){if(!_.trackScrollDepth)return;if(_.contentSelector){let e=document.querySelector(_.contentSelector);e&&(z=Te(e))}let e=!1;function t(){e||=(window.requestAnimationFrame(()=>{B(),e=!1}),!0)}if(window.addEventListener(`scroll`,t),z&&(z.addEventListener(`scroll`,t),_.debug)){let e=z;console.log(`[do11y] Using container-based scroll tracking:`,e.className||e.tagName)}B()}function B(){let e,t,i;z&&z.scrollHeight>z.clientHeight?(e=z.scrollTop,t=z.scrollHeight,i=z.clientHeight):(e=window.scrollY||document.documentElement.scrollTop,t=document.documentElement.scrollHeight,i=window.innerHeight);let a=t-i;if(a<=0){_.scrollThresholds.forEach(e=>{R.has(e)||(R.add(e),j(u,{[n]:e,[r]:100}))});return}let o=Math.round(e/a*100);_.scrollThresholds.forEach(e=>{o>=e&&!R.has(e)&&(R.add(e),j(u,{[n]:e,[r]:o}))})}let V=Date.now(),H=Date.now(),U=0,W=!0,G=!1;function K(){if(G)return;G=!0,W&&(U+=Date.now()-H);let n=Date.now()-V,r=n>0?U/n:0,i=0;R.forEach(e=>{e>i&&(i=e)}),X();let a=T();j(`browser.do11y.page_exit`,{"browser.do11y.page_exit.total_time_seconds":Math.round(n/1e3),"browser.do11y.page_exit.active_time_seconds":Math.round(U/1e3),"browser.do11y.page_exit.engagement_ratio":Math.round(r*100)/100,"browser.do11y.page_exit.max_scroll_depth":i,[e]:a.referrerCategory,[t]:a.aiPlatform}),F()}function De(){document.addEventListener(`visibilitychange`,()=>{document.hidden?W&&=(U+=Date.now()-H,!1):(H=Date.now(),W=!0)}),window.addEventListener(`beforeunload`,()=>{K(),Ie()})}function Oe(){document.addEventListener(`click`,e=>{e.target.closest(_.searchSelector)&&j(d,{})},!0),document.addEventListener(`keydown`,e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&j(d,{"browser.do11y.search.trigger":`keyboard`})})}function ke(e){if(!e)return 1;try{let t=document.querySelectorAll(_.codeBlockSelector);for(let n=0;n<t.length;n++)if(t[n]===e)return n+1}catch{}return 1}function Ae(){document.addEventListener(`click`,e=>{let t=e.target.closest(_.copyButtonSelector);if(t){let e=t.closest(`[class*="language-"], [language]`)??t.closest(_.codeBlockSelector)??t.closest(`.expressive-code`)?.querySelector(`pre`)??t.closest(`div, section`)?.querySelector(`pre`)??t.parentElement?.querySelector(`pre`)??null,n=C((e?e.tagName===`PRE`?e.querySelector(`code`):e.querySelector(`code[class*="language-"], code[language]`)??e.querySelector(`code`):null)??e??t);j(`browser.do11y.code_copied`,{"browser.do11y.code.language":n,"browser.do11y.code.section":w(L(e??t),100),"browser.do11y.code.index":ke(e)})}},!0)}let q=null,J={};function je(){if(!_.trackSectionVisibility||typeof IntersectionObserver>`u`)return;let e=_.sectionVisibleThreshold*1e3;q=new IntersectionObserver(t=>{t.forEach(t=>{let n=t.target.getAttribute(`data-do11y-section-id`);if(n)if(t.isIntersecting){if(!J[n]){let r={start:Date.now(),reported:!1,timeoutId:null};r.timeoutId=setTimeout(()=>{if(J[n]&&!J[n].reported){let r=t.target.textContent?.trim()??``;j(f,{[i]:w(r,100),[a]:parseInt(t.target.tagName.charAt(1),10),[o]:Math.round(e/1e3)}),J[n].reported=!0}},e),J[n]=r}}else{if(J[n]&&(J[n].timeoutId&&clearTimeout(J[n].timeoutId),!J[n].reported)){let r=Date.now()-J[n].start;if(r>=e){let e=t.target.textContent?.trim()??``;j(f,{[i]:w(e,100),[a]:parseInt(t.target.tagName.charAt(1),10),[o]:Math.round(r/1e3)}),J[n].reported=!0}}delete J[n]}})},{threshold:.5}),Y()}function Y(){q&&document.querySelectorAll(`h2, h3`).forEach((e,t)=>{e.setAttribute(`data-do11y-section-id`,`section-`+t),q.observe(e)})}function X(){if(!q)return;let e=Date.now(),t=_.sectionVisibleThreshold*1e3;Object.keys(J).forEach(n=>{let r=J[n];if(r&&!r.reported){r.timeoutId&&clearTimeout(r.timeoutId);let s=e-r.start;if(s>=t){let e=typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(n):n.replace(/["\\]/g,`\\$&`),t=document.querySelector(`[data-do11y-section-id="`+e+`"]`);t&&j(f,{[i]:w(t.textContent?.trim()??``,100),[a]:parseInt(t.tagName.charAt(1),10),[o]:Math.round(s/1e3)})}}}),J={}}function Me(){_.trackTabSwitches&&document.addEventListener(`click`,e=>{let t=`[role="tab"], .tabs button, .tabs a, .tabbed-labels label`,n=b(_.tabContainerSelector);n&&(t+=`, `+n+` button, `+n+` a, `+n+` label`);let r=e.target.closest(t);if(!r||r.getAttribute(`aria-selected`)===`true`||r.classList.contains(`active`)||r.classList.contains(`is-active`))return;let i=w(r.textContent,50);if(!i)return;let a=w(L(r),100);j(`browser.do11y.tab_switch`,{"browser.do11y.tab.label":i,"browser.do11y.tab.group":a,"browser.do11y.tab.is_default":!1})})}function Ne(){_.trackTocClicks&&document.addEventListener(`click`,e=>{let t=e.target.closest(`a`);if(!t)return;let n=re(t);if(!n)return;let r=t.getAttribute(`href`),i=r?ne(r):null;if(!i)return;let a=w(t.textContent,100),o=null;try{let e=i.slice(1),t=document.getElementById(e);t&&/^H[1-6]$/.test(t.tagName)&&(o=parseInt(t.tagName.charAt(1),10))}catch{}let s=n.querySelectorAll(`a[href*="#"]`),c=1;for(let e=0;e<s.length;e++)if(s[e]===t){c=e+1;break}j(`browser.do11y.toc_click`,{"browser.do11y.toc.heading":a,"browser.do11y.toc.heading_level":o,"browser.do11y.toc.position":c})},!0)}function Pe(){_.trackFeedback&&document.addEventListener(`click`,e=>{let t=e.target.closest(`button, [role="button"], a`);if(!t||!t.closest(b(_.feedbackSelector)??`[class*="feedback"], [class*="helpful"], [class*="rating"], [class*="was-this"], [data-feedback]`))return;let n=(t.textContent??``).trim().toLowerCase(),r=(t.getAttribute(`aria-label`)??``).toLowerCase(),i=(t.getAttribute(`title`)??``).toLowerCase(),a=t.getAttribute(`data-value`)??t.getAttribute(`data-md-value`)??t.getAttribute(`data-feedback`),o=a&&/^[\w\s.,!?-]{1,50}$/.test(a)?a:null,s=null;o?s=o:/\byes\b|👍|thumbs.?up|helpful/i.test(n+` `+r+` `+i)?s=`yes`:/\bno\b|👎|thumbs.?down|not.?helpful/i.test(n+` `+r+` `+i)&&(s=`no`),s&&j(`browser.do11y.feedback`,{"browser.do11y.feedback.rating":s})})}function Fe(){_.trackExpandCollapse&&(document.addEventListener(`toggle`,e=>{let t=e.target;if(t.tagName!==`DETAILS`)return;let n=t.querySelector(`summary`),r=w(n?n.textContent:``,100);j(p,{[s]:r,[c]:t.open?`expand`:`collapse`,[l]:w(L(t),100)})},!0),document.addEventListener(`click`,e=>{let t=e.target.closest(`[aria-expanded], [class*="accordion"] button, [class*="collapsible"] button`);if(!t||t.closest(`details`)||t.closest(`nav, [role="navigation"], header`))return;let n=t.getAttribute(`aria-expanded`)===`true`;j(p,{[s]:w(t.textContent,100),[c]:n?`collapse`:`expand`,[l]:w(L(t),100)})}))}let Z=null,Q=null;function $(){if(window.Do11yConfig&&typeof window.Do11yConfig==`object`)for(let e in _)Object.prototype.hasOwnProperty.call(window.Do11yConfig,e)&&(_[e]=window.Do11yConfig[e]);let e=document.querySelector(`meta[name="do11y-destination"]`);if(e){let t=e.getAttribute(`content`);(t===`supabase`||t===`http`||t===`otlp`)&&(_.destination=t)}let t=document.querySelector(`meta[name="do11y-url"]`);t&&(_.supabaseUrl=t.getAttribute(`content`)??_.supabaseUrl);let n=document.querySelector(`meta[name="do11y-key"]`);n&&(_.supabaseKey=n.getAttribute(`content`)??_.supabaseKey);let r=document.querySelector(`meta[name="do11y-table"]`);r&&(_.supabaseTable=r.getAttribute(`content`)??_.supabaseTable);let i=document.querySelector(`meta[name="do11y-endpoint"]`);i&&(_.endpoint=i.getAttribute(`content`)??_.endpoint);let a=document.querySelector(`meta[name="do11y-otlp-endpoint"]`);a&&(_.otelSdkEndpoint=a.getAttribute(`content`)??_.otelSdkEndpoint);let o=document.querySelector(`meta[name="do11y-otlp-headers"]`);if(o)try{let e=JSON.parse(o.getAttribute(`content`)??`{}`);typeof e==`object`&&e&&(_.otelSdkHeaders=e)}catch{}let s=document.querySelector(`meta[name="do11y-debug"]`);s&&s.getAttribute(`content`)===`true`&&(_.debug=!0);let c=document.querySelector(`meta[name="do11y-domains"]`);if(c){let e=c.getAttribute(`content`);e&&(_.allowedDomains=e.split(`,`).map(e=>e.trim()))}let l=document.querySelector(`meta[name="do11y-framework"]`);l&&(_.framework=l.getAttribute(`content`)??_.framework);let u=document.querySelector(`meta[name="do11y-use-otel-instrumentations"]`);if(u&&u.getAttribute(`content`)===`true`&&(_.useOtelBrowserInstrumentations=!0),ee(),_.debug){let e=_.destination===`supabase`?!!_.supabaseKey:_.destination===`otlp`?!!_.otelSdkEndpoint:!!_.endpoint;console.log(`[Do11y] Initializing with config:`,{destination:_.destination,hasCredentials:e,framework:_.framework,allowedDomains:_.allowedDomains,respectDNT:_.respectDNT})}if(te()){A=!0,_.debug&&console.log(`[Do11y] Tracking disabled`);return}(_.destination===`supabase`?_.supabaseKey:_.destination===`otlp`?_.otelSdkEndpoint:_.endpoint)||_.debug&&(console.warn(`[Do11y] No destination configured. Events will not be sent.`),_.destination===`supabase`?console.warn(`[Do11y] Add <meta name="do11y-url"> and <meta name="do11y-key"> to enable.`):_.destination===`otlp`?console.warn(`[Do11y] Add <meta name="do11y-otlp-endpoint"> to enable.`):console.warn(`[Do11y] Add <meta name="do11y-endpoint"> to enable.`)),I(),Se(),Ee(),De(),Oe(),Ae(),je(),Me(),Ne(),Pe(),Fe();let d=window.location.pathname,f=()=>{window.location.pathname!==d&&(d=window.location.pathname,K(),R=new Set,V=Date.now(),H=Date.now(),U=0,W=!0,I(),Y(),B())};Z=new MutationObserver(f),Z.observe(document.body,{childList:!0,subtree:!0}),window.addEventListener(`popstate`,f),Q=window.setInterval(f,200),Object.freeze(_),_.debug&&console.log(`[Do11y] Initialized successfully`)}function Ie(){Z&&=(Z.disconnect(),null),q&&=(X(),q.disconnect(),null),O&&=(clearTimeout(O),null),Q!==null&&(clearInterval(Q),Q=null),xe()}!h&&!g&&(document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,$):$()),window.Do11y=window.Do11y??{getConfig:()=>({destination:_.destination,hasCredentials:_.destination===`supabase`?!!_.supabaseKey:_.destination===`otlp`?!!_.otelSdkEndpoint:!!_.endpoint,isDisabled:A,allowedDomains:_.allowedDomains,respectDNT:_.respectDNT}),flush:F,isEnabled:()=>A?!1:_.destination===`supabase`?!!_.supabaseKey:_.destination===`otlp`?!!_.otelSdkEndpoint:!!_.endpoint,getQueueSize:()=>D.length,version:m}})();
|