js.foresight 2.1.5 → 2.2.0

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/index.d.ts CHANGED
@@ -22,16 +22,43 @@ type ElementBounds = {
22
22
  /** The expanded rectangle, including hitSlop, used for interaction detection. */
23
23
  expandedRect: Rect;
24
24
  /** The original bounding rectangle of the element, as returned by `getBoundingClientRect()`. */
25
- originalRect?: DOMRectReadOnly;
25
+ originalRect?: DOMRectReadOnly | undefined;
26
26
  /** The hit slop values applied to this element. */
27
27
  hitSlop: Exclude<HitSlop, number>;
28
28
  };
29
29
  type DebuggerSettings = {
30
- /** If the control panel should be minimized on default @default false */
30
+ /**
31
+ * Determines if the debugger control panel should be initialized in a minimized state.
32
+ *
33
+ * @link https://foresightjs.com/docs/getting_started/debug
34
+ *
35
+ * @default false
36
+ */
31
37
  isControlPanelDefaultMinimized?: boolean;
32
- /** If we should show the name tags above elements @default false */
38
+ /**
39
+ * Determines if name tags should be displayed visually above each registered element.
40
+ * This is a helpful visual aid for identifying which elements are being tracked.
41
+ *
42
+ * @link https://foresightjs.com/docs/getting_started/debug
43
+ *
44
+ * @default false
45
+ */
33
46
  showNameTags?: boolean;
47
+ /**
48
+ * Specifies the default sorting order for the list of registered elements in the debugger panel.
49
+ * - `'visibility'`: Sorts elements by their viewport visibility (visible elements first),
50
+ * with a secondary documentOrder sort.
51
+ * - `'documentOrder'`: Sorts elements based on their order of appearance in the
52
+ * document's structure (matching the HTML source).
53
+ *
54
+ * @link https://foresightjs.com/docs/getting_started/debug
55
+ *
56
+ * @default 'visibility'
57
+ *
58
+ */
59
+ sortElementList?: SortElementList;
34
60
  };
61
+ type SortElementList = "documentOrder" | "visibility" | "insertionOrder";
35
62
  /**
36
63
  * Represents trajectory hit related data for a foresight element.
37
64
  */
@@ -82,22 +109,31 @@ type TabCallbackCounts = {
82
109
  reverse: number;
83
110
  forwards: number;
84
111
  };
112
+ type ScrollDirection = "down" | "up" | "left" | "right" | "none";
113
+ type ScrollCallbackCounts = Record<`${Exclude<ScrollDirection, "none">}`, number>;
85
114
  type CallbackHits = {
86
115
  total: number;
87
116
  mouse: MouseCallbackCounts;
88
117
  tab: TabCallbackCounts;
118
+ scroll: ScrollCallbackCounts;
89
119
  };
120
+ /**
121
+ * Snapshot of the current ForesightManager state
122
+ */
90
123
  type ForesightManagerData = {
91
124
  registeredElements: Map<ForesightElement, ForesightElementData>;
92
125
  globalSettings: Readonly<ForesightManagerSettings>;
93
126
  globalCallbackHits: Readonly<CallbackHits>;
94
- positionObserverElements: Map<Element, IntersectionObserverEntry> | undefined;
95
127
  };
96
128
  type BaseForesightManagerSettings = {
97
129
  /**
98
130
  * Number of mouse positions to keep in history for trajectory calculation.
99
131
  * A higher number might lead to smoother but slightly delayed predictions.
100
132
  *
133
+ *
134
+ * @link https://foresightjs.com/docs/getting_started/config#available-global-settings
135
+ *
136
+ *
101
137
  * **This value is clamped between 2 and 30.**
102
138
  * @default 8
103
139
  */
@@ -106,6 +142,8 @@ type BaseForesightManagerSettings = {
106
142
  * How far ahead (in milliseconds) to predict the mouse trajectory.
107
143
  * A larger value means the prediction extends further into the future. (meaning it will trigger callbacks sooner)
108
144
  *
145
+ * @link https://foresightjs.com/docs/getting_started/config#available-global-settings
146
+ *
109
147
  * **This value is clamped between 10 and 200.**
110
148
  * @default 120
111
149
  */
@@ -113,14 +151,32 @@ type BaseForesightManagerSettings = {
113
151
  /**
114
152
  * Whether to enable mouse trajectory prediction.
115
153
  * If false, only direct hover/interaction is considered.
154
+ * @link https://foresightjs.com/docs/getting_started/config#available-global-settings
116
155
  * @default true
117
156
  */
118
157
  enableMousePrediction: boolean;
119
158
  /**
120
159
  * Toggles whether keyboard prediction is on
160
+ *
161
+ * @link https://foresightjs.com/docs/getting_started/config#available-global-settings
121
162
  * @default true
122
163
  */
123
164
  enableTabPrediction: boolean;
165
+ /**
166
+ * Sets the pixel distance to check from the mouse position in the scroll direction.
167
+ *
168
+ * @link https://foresightjs.com/docs/getting_started/config#available-global-settings
169
+ *
170
+ * **This value is clamped between 30 and 300.**
171
+ * @default 150
172
+ */
173
+ scrollMargin: number;
174
+ /**
175
+ * Toggles whether scroll prediction is on
176
+ * @link https://foresightjs.com/docs/getting_started/config#available-global-settings
177
+ * @default true
178
+ */
179
+ enableScrollPrediction: boolean;
124
180
  /**
125
181
  * Tab stops away from an element to trigger callback. Only works when @argument enableTabPrediction is true
126
182
  *
@@ -151,13 +207,21 @@ type BaseForesightManagerSettings = {
151
207
  };
152
208
  /**
153
209
  * Configuration options for the ForesightManager
210
+ * @link https://foresightjs.com/docs/getting_started/config#available-global-settings
154
211
  */
155
212
  type ForesightManagerSettings = BaseForesightManagerSettings & {
156
213
  defaultHitSlop: Exclude<HitSlop, number>;
157
214
  };
215
+ /**
216
+ * Update options for the ForesightManager
217
+ * @link https://foresightjs.com/docs/getting_started/config#available-global-settings
218
+ */
158
219
  type UpdateForsightManagerSettings = BaseForesightManagerSettings & {
159
220
  defaultHitSlop: HitSlop;
160
221
  };
222
+ /**
223
+ * Type used to register elements to the foresight manager
224
+ */
161
225
  type ForesightRegisterOptions = {
162
226
  element: ForesightElement;
163
227
  callback: ForesightCallback;
@@ -165,7 +229,18 @@ type ForesightRegisterOptions = {
165
229
  unregisterOnCallback?: boolean;
166
230
  name?: string;
167
231
  };
232
+ /**
233
+ * Usefull for if you want to create a custom button component in a modern framework (for example React).
234
+ * And you want to have the ForesightRegisterOptions used in ForesightManager.instance.register({})
235
+ * without the element as the element will be the ref of the component.
236
+ *
237
+ * @link https://foresightjs.com/docs/getting_started/typescript#foresightregisteroptionswithoutelement
238
+ */
168
239
  type ForesightRegisterOptionsWithoutElement = Omit<ForesightRegisterOptions, "element">;
240
+ /**
241
+ * Fully invisible "slop" around the element.
242
+ * Basically increases the hover hitbox
243
+ */
169
244
  type HitSlop = Rect | number;
170
245
 
171
246
  /**
@@ -194,6 +269,10 @@ declare class ForesightManager {
194
269
  private _globalCallbackHits;
195
270
  private _globalSettings;
196
271
  private trajectoryPositions;
272
+ private tabbableElementsCache;
273
+ private lastFocusedIndex;
274
+ private predictedScrollPoint;
275
+ private scrollDirection;
197
276
  private domObserver;
198
277
  private positionObserver;
199
278
  private lastKeyDown;
@@ -256,6 +335,7 @@ declare class ForesightManager {
256
335
  */
257
336
  private forceUpdateElementBounds;
258
337
  private updateElementBounds;
338
+ private handleScrollPrefetch;
259
339
  private handlePositionChange;
260
340
  private initializeGlobalListeners;
261
341
  private removeGlobalListeners;
package/dist/index.js CHANGED
@@ -1,23 +1,7 @@
1
- "use strict";var e=function(){return e=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;
1
+ "use strict";var t=function(){return t=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},t.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;
2
2
  /*!
3
3
  * tabbable 6.2.0
4
4
  * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
5
5
  */
6
- var t=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"].join(","),n="undefined"==typeof Element,i=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,o=!n&&Element.prototype.getRootNode?function(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},r=function e(t,n){var i;void 0===n&&(n=!0);var o=null==t||null===(i=t.getAttribute)||void 0===i?void 0:i.call(t,"inert");return""===o||"true"===o||n&&t&&e(t.parentNode)},s=function e(n,o,s){for(var a=[],l=Array.from(n);l.length;){var c=l.shift();if(!r(c,!1))if("SLOT"===c.tagName){var d=c.assignedElements(),u=e(d.length?d:c.children,!0,s);s.flatten?a.push.apply(a,u):a.push({scopeParent:c,candidates:u})}else{i.call(c,t)&&s.filter(c)&&(o||!n.includes(c))&&a.push(c);var h=c.shadowRoot||"function"==typeof s.getShadowRoot&&s.getShadowRoot(c),g=!r(h,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(c));if(h&&g){var p=e(!0===h?c.children:h.children,!0,s);s.flatten?a.push.apply(a,p):a.push({scopeParent:c,candidates:p})}else l.unshift.apply(l,c.children)}}return a},a=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},l=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!a(e)?0:e.tabIndex},c=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},d=function(e){return"INPUT"===e.tagName},u=function(e){return function(e){return d(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||o(e),i=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=i(window.CSS.escape(e.name));else try{t=i(e.name)}catch(e){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",e.message),!1}var r=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!r||r===e}(e)},h=function(e){var t=e.getBoundingClientRect(),n=t.width,i=t.height;return 0===n&&0===i},g=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var s=i.call(e,"details>summary:first-of-type")?e.parentElement:e;if(i.call(s,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return h(e)}else{if("function"==typeof r){for(var a=e;e;){var l=e.parentElement,c=o(e);if(l&&!l.shadowRoot&&!0===r(l))return h(e);e=e.assignedSlot?e.assignedSlot:l||c===e.ownerDocument?l:c.host}e=a}if(function(e){var t,n,i,r,s=e&&o(e),a=null===(t=s)||void 0===t?void 0:t.host,l=!1;if(s&&s!==e)for(l=!!(null!==(n=a)&&void 0!==n&&null!==(i=n.ownerDocument)&&void 0!==i&&i.contains(a)||null!=e&&null!==(r=e.ownerDocument)&&void 0!==r&&r.contains(e));!l&&a;){var c,d,u;l=!(null===(d=a=null===(c=s=o(a))||void 0===c?void 0:c.host)||void 0===d||null===(u=d.ownerDocument)||void 0===u||!u.contains(a))}return l}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},p=function(e,t){return!(t.disabled||r(t)||function(e){return d(e)&&"hidden"===e.type}(t)||g(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var o=t.children.item(n);if("LEGEND"===o.tagName)return!!i.call(t,"fieldset[disabled] *")||!o.contains(e)}return!0}t=t.parentElement}return!1}(t))},b=function(e,t){return!(u(t)||l(t)<0||!p(e,t))},m=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},f=function e(t){var n=[],i=[];return t.forEach((function(t,o){var r=!!t.scopeParent,s=r?t.scopeParent:t,c=function(e,t){var n=l(e);return n<0&&t&&!a(e)?0:n}(s,r),d=r?e(t.candidates):s;0===c?r?n.push.apply(n,d):n.push(s):i.push({documentOrder:o,tabIndex:c,item:t,isScope:r,content:d})})),i.sort(c).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)},y=function(e,n){var o;return o=(n=n||{}).getShadowRoot?s([e],n.includeContainer,{filter:b.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:m}):function(e,n,o){if(r(e))return[];var s=Array.prototype.slice.apply(e.querySelectorAll(t));return n&&i.call(e,t)&&s.unshift(e),s.filter(o)}(e,n.includeContainer,b.bind(null,n)),f(o)},v="ms",S="points",x="tabs",w=2e3,C=!1,k=!0;var E=function(e,t){void 0===t&&(t=2);var n=" ".repeat(t);if("object"==typeof e&&null!==e&&!Array.isArray(e)){var i=Object.entries(e);if(0===i.length)return"{}";var o=i.map((function(e){var i=e[0],o=e[1];return"".concat(n," ").concat(i,": ").concat(E(o,t+2))})).join(",\n");return"{\n".concat(o,"\n").concat(n,"}")}return"string"==typeof e?"'".concat(e,"'"):"boolean"==typeof e||"number"==typeof e?String(e):null===e?"null":void 0===e?"undefined":Array.isArray(e)?JSON.stringify(e):String(e)};function T(e,t,n){var i=document.createElement(e);return n.id&&(i.id=n.id),n.className&&(i.className=n.className),n.data&&i.setAttribute("data-value",n.data),t.appendChild(i)}function j(e,t,n){var i=document.createElement("style");return i.textContent=e,i.id=n,t.appendChild(i)}var M='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>',z=function(){function e(e){this.elementListItemsContainer=null,this.elementCountSpan=null,this.callbackCountSpan=null,this.elementListItems=new Map,this.trajectoryEnabledCheckbox=null,this.tabEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.showNameTagsCheckbox=null,this.containerMinimizeButton=null,this.allSettingsSectionsContainer=null,this.debuggerElementsSection=null,this.isContainerMinimized=!1,this.isMouseSettingsMinimized=!0,this.isKeyboardSettingsMinimized=!0,this.isGeneralSettingsMinimized=!0,this.isElementsListMinimized=!0,this.SESSION_STORAGE_KEY="jsforesightDebuggerSectionStates",this.copySettingsButton=null,this.copyTimeoutId=null,this.foresightManagerInstance=e}return e.prototype._setupDOMAndListeners=function(e,t){var n;this.controlsContainer||(this.shadowRoot=e,this.isContainerMinimized=null!==(n=t.isControlPanelDefaultMinimized)&&void 0!==n?n:C,this.controlsContainer=this.createControlContainer(),this.shadowRoot.appendChild(this.controlsContainer),this.controlPanelStyleElement=j(this.getStyles(),this.shadowRoot,"debug-control-panel"),this.queryDOMElements(),this.originalSectionStates(),this.setupEventListeners(),this.refreshElementList(),this.updateContainerVisibilityState())},e.initialize=function(t,n,i){e.isInitiated||(e.debuggerControlPanelInstance=new e(t));var o=e.debuggerControlPanelInstance;return o._setupDOMAndListeners(n,i),o},Object.defineProperty(e,"isInitiated",{get:function(){return!!e.debuggerControlPanelInstance},enumerable:!1,configurable:!0}),e.prototype.loadSectionStatesFromSessionStorage=function(){var e,t,n,i,o=sessionStorage.getItem(this.SESSION_STORAGE_KEY),r={};return o&&(r=JSON.parse(o)),this.isMouseSettingsMinimized=null===(e=r.mouse)||void 0===e||e,this.isKeyboardSettingsMinimized=null===(t=r.keyboard)||void 0===t||t,this.isGeneralSettingsMinimized=null===(n=r.general)||void 0===n||n,this.isElementsListMinimized=null!==(i=r.elements)&&void 0!==i&&i,r},e.prototype.saveSectionStatesToSessionStorage=function(){var e={mouse:this.isMouseSettingsMinimized,keyboard:this.isKeyboardSettingsMinimized,general:this.isGeneralSettingsMinimized,elements:this.isElementsListMinimized};try{sessionStorage.setItem(this.SESSION_STORAGE_KEY,JSON.stringify(e))}catch(e){console.error("Foresight Debugger: Could not save section states to session storage.",e)}},e.prototype.queryDOMElements=function(){this.trajectoryEnabledCheckbox=this.controlsContainer.querySelector("#trajectory-enabled"),this.tabEnabledCheckbox=this.controlsContainer.querySelector("#tab-enabled"),this.historySizeSlider=this.controlsContainer.querySelector("#history-size"),this.historyValueSpan=this.controlsContainer.querySelector("#history-value"),this.predictionTimeSlider=this.controlsContainer.querySelector("#prediction-time"),this.predictionValueSpan=this.controlsContainer.querySelector("#prediction-value"),this.tabOffsetSlider=this.controlsContainer.querySelector("#tab-offset"),this.tabOffsetValueSpan=this.controlsContainer.querySelector("#tab-offset-value"),this.elementListItemsContainer=this.controlsContainer.querySelector("#element-list-items-container"),this.showNameTagsCheckbox=this.controlsContainer.querySelector("#toggle-name-tags"),this.elementCountSpan=this.controlsContainer.querySelector("#element-count"),this.callbackCountSpan=this.controlsContainer.querySelector("#callback-count"),this.containerMinimizeButton=this.controlsContainer.querySelector(".minimize-button"),this.allSettingsSectionsContainer=this.controlsContainer.querySelector(".all-settings-sections-container"),this.debuggerElementsSection=this.controlsContainer.querySelector(".debugger-elements"),this.copySettingsButton=this.controlsContainer.querySelector(".copy-settings-button")},e.prototype.handleCopySettings=function(){var e,t,n,i=this;this.copySettingsButton&&navigator.clipboard.writeText((e=this.foresightManagerInstance.getManagerData.globalSettings,t="ForesightManager.initialize",n=Object.entries(e).filter((function(e){var t=e[0];return"resizeScrollThrottleDelay"!==String(t)})).map((function(e){var t=e[0],n=e[1];return" ".concat(String(t),": ").concat(E(n))})).join(",\n"),"".concat(t,"({\n").concat(n,"\n})"))).then((function(){i.copySettingsButton.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',i.copyTimeoutId&&clearTimeout(i.copyTimeoutId),i.copyTimeoutId=setTimeout((function(){i.copySettingsButton&&(i.copySettingsButton.innerHTML=M),i.copyTimeoutId=null}),3e3)})).catch((function(e){console.error("Foresight Debugger: Could not copy settings to clipboard",e)}))},e.prototype.createInputEventListener=function(e,t,n,i){var o=this;e&&t&&e.addEventListener("input",(function(e){var r,s=parseInt(e.target.value,10);t.textContent="".concat(s," ").concat(n),o.foresightManagerInstance.alterGlobalSettings(((r={})[i]=s,r))}))},e.prototype.createChangeEventListener=function(e,t){var n=this;e&&e.addEventListener("change",(function(e){var i;"name-tag"===t?n.foresightManagerInstance.alterGlobalSettings({debuggerSettings:{showNameTags:e.target.checked}}):n.foresightManagerInstance.alterGlobalSettings(((i={})[t]=e.target.checked,i))}))},e.prototype.createSectionVisibilityToggleEventListener=function(e,t){var n=this,i=null==e?void 0:e.querySelector(".debugger-section-header");null==i||i.addEventListener("click",(function(i){i.stopPropagation(),n.toggleMinimizeSection(e,n[t]=!n[t])}))},e.prototype.setupEventListeners=function(){var e,t,n=this;this.createChangeEventListener(this.trajectoryEnabledCheckbox,"enableMousePrediction"),this.createChangeEventListener(this.tabEnabledCheckbox,"enableTabPrediction"),this.createChangeEventListener(this.showNameTagsCheckbox,"name-tag"),this.createInputEventListener(this.historySizeSlider,this.historyValueSpan,S,"positionHistorySize"),this.createInputEventListener(this.predictionTimeSlider,this.predictionValueSpan,v,"trajectoryPredictionTime"),this.createInputEventListener(this.tabOffsetSlider,this.tabOffsetValueSpan,x,"tabOffset"),null===(e=this.containerMinimizeButton)||void 0===e||e.addEventListener("click",(function(){n.isContainerMinimized=!n.isContainerMinimized,n.updateContainerVisibilityState()})),null===(t=this.copySettingsButton)||void 0===t||t.addEventListener("click",this.handleCopySettings.bind(this)),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".mouse-settings-section"),"isMouseSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".keyboard-settings-section"),"isKeyboardSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".general-settings-section"),"isGeneralSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".debugger-elements"),"isElementsListMinimized")},e.prototype.toggleMinimizeSection=function(e,t){if(e){var n=e.querySelector(".debugger-section-content"),i=e.querySelector(".section-minimize-button");n&&i&&(t?(n.style.display="none",i.textContent="+"):(n.style.display="flex",i.textContent="-")),this.saveSectionStatesToSessionStorage()}},e.prototype.originalSectionStates=function(){var e,t,n,i,o=this.loadSectionStatesFromSessionStorage();this.toggleMinimizeSection(this.controlsContainer.querySelector(".mouse-settings-section"),null===(e=o.mouse)||void 0===e||e),this.toggleMinimizeSection(this.controlsContainer.querySelector(".keyboard-settings-section"),null===(t=o.keyboard)||void 0===t||t),this.toggleMinimizeSection(this.controlsContainer.querySelector(".general-settings-section"),null===(n=o.general)||void 0===n||n),this.toggleMinimizeSection(this.controlsContainer.querySelector(".debugger-elements"),null!==(i=o.elements)&&void 0!==i&&i)},e.prototype.updateContainerVisibilityState=function(){this.containerMinimizeButton&&(this.isContainerMinimized?(this.controlsContainer.classList.add("minimized"),this.containerMinimizeButton.textContent="+",this.allSettingsSectionsContainer&&(this.allSettingsSectionsContainer.style.display="none"),this.debuggerElementsSection&&(this.debuggerElementsSection.style.display="none"),this.copySettingsButton&&(this.copySettingsButton.style.display="none")):(this.controlsContainer.classList.remove("minimized"),this.containerMinimizeButton.textContent="-",this.allSettingsSectionsContainer&&(this.allSettingsSectionsContainer.style.display=""),this.debuggerElementsSection&&(this.debuggerElementsSection.style.display=""),this.copySettingsButton&&(this.copySettingsButton.style.display="")))},e.prototype.updateControlsState=function(e){var t;this.trajectoryEnabledCheckbox&&(this.trajectoryEnabledCheckbox.checked=e.enableMousePrediction),this.tabEnabledCheckbox&&(this.tabEnabledCheckbox.checked=e.enableTabPrediction),this.showNameTagsCheckbox&&(this.showNameTagsCheckbox.checked=null!==(t=e.debuggerSettings.showNameTags)&&void 0!==t?t:k),this.historySizeSlider&&this.historyValueSpan&&(this.historySizeSlider.value=e.positionHistorySize.toString(),this.historyValueSpan.textContent="".concat(e.positionHistorySize," ").concat(S)),this.predictionTimeSlider&&this.predictionValueSpan&&(this.predictionTimeSlider.value=e.trajectoryPredictionTime.toString(),this.predictionValueSpan.textContent="".concat(e.trajectoryPredictionTime," ").concat(v)),this.tabOffsetSlider&&this.tabOffsetValueSpan&&(this.tabOffsetSlider.value=e.tabOffset.toString(),this.tabOffsetValueSpan.textContent="".concat(e.tabOffset," ").concat(x))},e.prototype.refreshRegisteredElementCountDisplay=function(e){if(this.elementCountSpan&&this.callbackCountSpan){var t=0;e.forEach((function(e){e.isIntersectingWithViewport&&t++}));var n=e.size,i=this.foresightManagerInstance.getManagerData.globalCallbackHits,o=i.tab,r=i.mouse,s=i.total;this.elementCountSpan.textContent="Visible: ".concat(t,"/").concat(n," ~ "),this.elementCountSpan.title="Total registered elements: ".concat(n,", visible in viewport: ").concat(t,", not in viewport: ").concat(n-t),this.callbackCountSpan.textContent="Mouse: ".concat(r.hover+r.trajectory," Tab: ").concat(o.forwards+o.reverse),this.callbackCountSpan.title="Total callbacks executed: Mouse Trajectory: ".concat(r.trajectory,", Mouse Hover: ").concat(r.hover,", Tab Forwards: ").concat(o.forwards,", Tab Reverse: ").concat(o.reverse,", total: ").concat(s)}},e.prototype.refreshElementList=function(){var e=this;if(this.elementListItemsContainer){this.elementListItemsContainer.innerHTML="",this.elementListItems.clear();var t=this.foresightManagerInstance.registeredElements;this.refreshRegisteredElementCountDisplay(t),0!==t.size?t.forEach((function(t,n){var i=document.createElement("div");i.className="element-list-item",e.updateListItemContent(i,t),e.elementListItemsContainer.appendChild(i),e.elementListItems.set(n,i)})):this.elementListItemsContainer.innerHTML="<em>No elements registered.</em>"}},e.prototype.updateListItemContent=function(e,t){e.classList.toggle("hovering",t.isHovering),e.classList.toggle("trajectory-hit",t.trajectoryHitData.isTrajectoryHit),e.classList.toggle("not-in-viewport",!t.isIntersectingWithViewport),e.title=t.isIntersectingWithViewport?"".concat(t.name||"Element"," - is in viewport and being tracked by observers"):"".concat(t.name||"Element"," - is not in viewport and not being tracked by observers");var n=t.unregisterOnCallback?"Single":"Multi",i=t.unregisterOnCallback?"Callback triggers once, then element unregisters.":"Callback can trigger multiple times.",o="N/A",r="Hit Slop: Not defined";if(t.elementBounds.hitSlop){var s=t.elementBounds.hitSlop,a=s.top,l=s.right,c=s.bottom,d=s.left;o="T:".concat(a," R:").concat(l," B:").concat(c," L:").concat(d),r="Hit Slop (px): Top: ".concat(a,", Right: ").concat(l,", Bottom: ").concat(c,", Left: ").concat(d)}var u=t.isIntersectingWithViewport?"👁️":"🚫";e.innerHTML='\n <span class="viewport-indicator"">'.concat(u,'</span>\n <span class="element-name">').concat(t.name||"Unnamed Element",'</span>\n <span class="hit-slop" title="').concat(r,'">').concat(o,'</span>\n <span class="hit-behavior" title="').concat(i,'">').concat(n,"</span>\n ")},e.prototype.cleanup=function(){var e,t;null===(e=this.controlsContainer)||void 0===e||e.remove(),null===(t=this.controlPanelStyleElement)||void 0===t||t.remove(),this.copyTimeoutId&&(clearTimeout(this.copyTimeoutId),this.copyTimeoutId=null),this.controlsContainer=null,this.controlPanelStyleElement=null,this.elementListItemsContainer=null,this.elementCountSpan=null,this.callbackCountSpan=null,this.elementListItems.clear(),this.containerMinimizeButton=null,this.allSettingsSectionsContainer=null,this.debuggerElementsSection=null,this.trajectoryEnabledCheckbox=null,this.tabEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.showNameTagsCheckbox=null,this.copySettingsButton=null},e.prototype.createControlContainer=function(){var e=document.createElement("div");return e.id="debug-controls",e.innerHTML='\n <div class="debugger-title-container">\n <button class="minimize-button">-</button>\n <div class="title-group">\n <h2>Foresight Debugger</h2>\n <span class="info-icon" title="Changes made here are for the current session only and won\'t persist. Update initial values in the ForesightManager.initialize() props for permanent changes.">i</span>\n </div>\n <button class="copy-settings-button" title="Copy current settings to clipboard">\n '.concat(M,'\n </button>\n </div>\n\n <div class="all-settings-sections-container">\n <div class="debugger-section mouse-settings-section">\n <div class="debugger-section-header mouse-settings-header">\n <h3>Mouse Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content mouse-settings-content">\n <div class="control-row">\n <label for="trajectory-enabled">\n Enable Mouse Prediction\n <span class="info-icon" title="Toggles mouse movement prediction. If disabled, only direct hovers trigger actions (or tab if enabled). - enableMousePrediction">i</span>\n </label>\n <input type="checkbox" id="trajectory-enabled">\n </div>\n <div class="control-row">\n <label for="history-size">\n History Size\n <span class="info-icon" title="Number of past mouse positions to use for velocity calculation. Higher values smooth predictions but add latency. - positionHistorySize">i</span>\n </label>\n <input type="range" id="history-size" min="').concat(2,'" max="').concat(30,'">\n <span id="history-value"></span>\n </div>\n <div class="control-row">\n <label for="prediction-time">\n Prediction Time\n <span class="info-icon" title="How many ').concat(v,' in the future to calculate the mouse trajectory. Larger value detects elements sooner. - trajectoryPredictionTime">i</span>\n </label>\n <input type="range" id="prediction-time" min="').concat(10,'" max="').concat(200,'" step="10">\n <span id="prediction-value"></span>\n </div>\n </div>\n </div>\n\n <div class="debugger-section keyboard-settings-section">\n <div class="debugger-section-header keyboard-settings-header">\n <h3>Keyboard Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content keyboard-settings-content">\n <div class="control-row">\n <label for="tab-enabled">\n Enable Tab Prediction\n <span class="info-icon" title="With tab prediction the callback will be executed when the user is tabOffset amount of ').concat(x,' away from an registered element (works with reversed shift-tabs) - enableTabPrediction.">i</span>\n </label>\n <input type="checkbox" id="tab-enabled">\n </div>\n <div class="control-row">\n <label for="tab-offset">\n Tab Prediction Offset\n <span class="info-icon" title="Number of next/previous tabbable elements to consider for prediction when using the Tab key - tabOffset.">i</span>\n </label>\n <input type="range" id="tab-offset" min="').concat(0,'" max="').concat(20,'" step="1">\n <span id="tab-offset-value"></span>\n </div>\n </div>\n </div>\n\n <div class="debugger-section general-settings-section">\n <div class="debugger-section-header general-settings-header">\n <h3>General Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content general-settings-content">\n <div class="control-row">\n <label for="toggle-name-tags">\n Show Name Tags\n <span class="info-icon" title="Toggles name tags, purely for debugging. - showNameTags">i</span>\n </label>\n <input type="checkbox" id="toggle-name-tags">\n </div>\n </div>\n </div>\n </div>\n\n <div class="debugger-section debugger-elements">\n <div class="debugger-section-header elements-list-header">\n <h3>Elements <span id="element-count"></span> <span id="callback-count"></span></h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content element-list">\n <div id="element-list-items-container">\n <em>Initializing...</em>\n </div>\n </div>\n </div>\n '),e},e.prototype.getStyles=function(){return'\n #debug-controls {\n position: fixed; bottom: 10px; right: 10px;\n background-color: rgba(0, 0, 0, 0.75); color: white; padding: 12px;\n border-radius: 5px; font-family: Arial, sans-serif; font-size: 13px;\n z-index: 10001; pointer-events: auto; display: flex; flex-direction: column; gap: 8px;\n width: 400px;\n transition: width 0.3s ease, height 0.3s ease;\n }\n #debug-controls.minimized {\n width: 220px;\n overflow: hidden;\n padding: 12px 0; \n }\n #debug-controls.minimized .debugger-title-container {\n justify-content: flex-start; \n padding-left: 10px; \n padding-right: 10px;\n gap: 10px; \n }\n #debug-controls.minimized .debugger-title-container h2 {\n display: inline;\n font-size: 14px;\n margin: 0;\n white-space: nowrap;\n }\n #debug-controls.minimized .info-icon {\n display: none;\n }\n\n #element-count,#callback-count {\n font-size: 12px;\n color: #9e9e9e;\n }\n\n\n\n .debugger-title-container {\n display: flex;\n align-items: center;\n justify-content: space-between; \n padding: 0 0px; \n }\n .title-group { \n display: flex;\n align-items: center;\n gap: 8px; \n\n }\n .minimize-button {\n background: none; border: none; color: white;\n font-size: 22px; cursor: pointer;\n line-height: 1;\n }\n .debugger-title-container h2 { margin: 0; font-size: 15px; }\n\n .copy-settings-button {\n background: none; border: none; color: white;\n cursor: pointer; padding: 0;\n display: flex; align-items: center; justify-content: center;\n }\n .copy-settings-button svg {\n width: 16px; height: 16px;\n stroke: white;\n }\n\n .all-settings-sections-container {\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n\n .debugger-section-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-top: 5px;\n margin-bottom: 2px;\n padding-bottom: 2px;\n border-bottom: 1px solid #444;\n cursor: pointer;\n }\n .debugger-section-header h3 {\n margin: 0;\n font-size: 14px;\n font-weight: bold;\n color: #b0c4de;\n }\n\n .section-minimize-button {\n background: none;\n border: none;\n color: white;\n font-size: 18px;\n cursor: pointer;\n padding: 0;\n line-height: 1;\n }\n\n #debug-controls .control-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n }\n #debug-controls label {\n display: flex;\n align-items: center;\n gap: 5px;\n cursor: pointer;\n }\n #debug-controls .control-row:has(input[type="checkbox"]) label {\n flex-grow: 1;\n }\n #debug-controls .control-row input[type="checkbox"] {\n appearance: none; -webkit-appearance: none; -moz-appearance: none;\n position: relative; width: 40px; height: 18px;\n background-color: #555; border-radius: 10px; cursor: pointer;\n outline: none; transition: background-color 0.2s ease;\n vertical-align: middle; flex-shrink: 0; margin: 0;\n }\n #debug-controls .control-row input[type="checkbox"]::before {\n content: ""; position: absolute; width: 14px; height: 14px;\n border-radius: 50%; background-color: white; top: 2px; left: 2px;\n transition: transform 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.4);\n }\n #debug-controls .control-row input[type="checkbox"]:checked {\n background-color: #b0c4de;\n }\n #debug-controls .control-row input[type="checkbox"]:checked::before {\n transform: translateX(22px);\n }\n #debug-controls .control-row:has(input[type="range"]) label {\n flex-basis: 170px; flex-shrink: 0;\n }\n #debug-controls input[type="range"] {\n flex-grow: 1; margin: 0; cursor: pointer; -webkit-appearance: none;\n appearance: none; background: transparent; height: 18px; vertical-align: middle;\n }\n #debug-controls input[type="range"]::-webkit-slider-runnable-track {\n height: 6px; background: #555; border-radius: 3px;\n }\n #debug-controls input[type="range"]::-moz-range-track {\n height: 6px; background: #555; border-radius: 3px;\n }\n #debug-controls input[type="range"]::-webkit-slider-thumb {\n -webkit-appearance: none; appearance: none; margin-top: -5px;\n background: #b0c4de; height: 16px; width: 16px;\n border-radius: 50%; border: 1px solid #333;\n }\n #debug-controls input[type="range"]::-moz-range-thumb {\n background: #b0c4de; height: 16px; width: 16px;\n border-radius: 50%; border: 1px solid #333; border: none;\n }\n #debug-controls .control-row:has(input[type="range"]) span:not(.info-icon) {\n width: 55px; min-width: 55px; text-align: right; flex-shrink: 0;\n }\n .info-icon {\n display: inline-flex; align-items: center; justify-content: center;\n width: 16px; height: 16px; border-radius: 50%;\n background-color: #555; color: white; font-size: 10px;\n font-style: italic; font-weight: bold; font-family: \'Georgia\', serif;\n cursor: help; user-select: none; flex-shrink: 0;\n }\n .debugger-section {\n display: flex; flex-direction: column; gap: 6px;\n }\n .debugger-section-content {\n display: none; flex-direction: column; gap: 8px;\n }\n\n /* Element List Styles */\n .element-list { /* Scroll container */\n min-height: '.concat(237,"px;\n max-height: ").concat(237,"px; \n overflow-y: auto;\n background-color: rgba(20, 20, 20, 0.5);\n border-radius: 3px;\n padding: 0;\n display: flex;\n }\n\n /* Modern Scrollbar Styling */\n .element-list::-webkit-scrollbar {\n width: 8px; \n }\n .element-list::-webkit-scrollbar-track {\n background: rgba(30, 30, 30, 0.5); \n border-radius: 4px;\n }\n .element-list::-webkit-scrollbar-thumb {\n background-color: rgba(176, 196, 222, 0.5); \n border-radius: 4px; \n border: 2px solid rgba(0, 0, 0, 0.2); \n }\n .element-list::-webkit-scrollbar-thumb:hover {\n background-color: rgba(176, 196, 222, 0.7);\n }\n /* Firefox scrollbar styling */\n .element-list {\n scrollbar-width: thin;\n scrollbar-color: rgba(176, 196, 222, 0.5) rgba(30, 30, 30, 0.5);\n }\n\n\n #element-list-items-container { \n display: flex;\n flex-wrap: wrap;\n gap: ").concat(3,"px;\n padding: ").concat(6,"px;\n min-height: ").concat(225,"px;\n box-sizing: border-box;\n align-content: flex-start;\n }\n #element-list-items-container > em {\n flex-basis: 100%;\n text-align: center;\n padding: 10px 0;\n font-style: italic;\n color: #ccc;\n font-size: 12px;\n }\n .element-list-item {\n flex-basis: calc((100% - (").concat(0," * ").concat(3,"px)) / ").concat(1,");\n flex-grow: 0;\n flex-shrink: 0;\n height: ").concat(35,"px;\n box-sizing: border-box;\n padding: 3px 5px;\n border-radius: 2px;\n display: flex;\n align-items: center;\n gap: 5px;\n background-color: rgba(50,50,50,0.7);\n transition: background-color 0.2s ease, opacity 0.2s ease;\n font-size: 11px; \n overflow: hidden;\n }\n \n /* Viewport intersection styling */\n .element-list-item.not-in-viewport {\n opacity: 0.4;\n }\n \n .element-list-item .element-name {\n flex-grow: 1;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: 12px; \n font-weight: bold;\n }\n .element-list-item .viewport-indicator {\n font-size: 12px;\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n }\n .element-list-item .hit-behavior,\n .element-list-item .hit-slop {\n font-size: 10px; \n color: #b0b0b0;\n padding: 2px 5px; \n border-radius: 3px; \n background-color: rgba(0,0,0,0.2);\n flex-shrink: 0;\n }\n ")},e}(),P=function(){return window.matchMedia("(pointer: coarse)").matches&&navigator.maxTouchPoints>0};function I(e,t,n){var i=e.expandedOverlay,o=e.nameLabel,r=t.elementBounds.expandedRect,s=r.right-r.left,a=r.bottom-r.top;i.style.width="".concat(s,"px"),i.style.height="".concat(a,"px"),i.style.transform="translate(".concat(r.left,"px, ").concat(r.top,"px)"),i.style.display="block",o.textContent=t.name,""!==t.name&&n?(o.style.display="block",o.style.transform="translate(".concat(r.left,"px, ").concat(r.top-25,"px)")):o.style.display="none"}var O=function(){function e(e){this.debugElementOverlays=new Map,this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.lastElementData=new Map,this.foresightManagerInstance=e}return e.prototype._setupDOM=function(){this.shadowHost||(this.shadowHost=T("div",document.body,{id:"jsforesight-debugger-shadow-host"}),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"}),this.debugContainer=T("div",this.shadowRoot,{id:"jsforesight-debug-container"}),this.debugPredictedMouseIndicator=T("div",this.debugContainer,{className:"jsforesight-mouse-predicted"}),this.debugTrajectoryLine=T("div",this.debugContainer,{className:"jsforesight-trajectory-line"}),this.controlPanel=z.initialize(this.foresightManagerInstance,this.shadowRoot,this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings),j(L,this.shadowRoot,"screen-visuals"))},Object.defineProperty(e,"isInitiated",{get:function(){return!!e.debuggerInstance},enumerable:!1,configurable:!0}),e.initialize=function(t,n){if(document.querySelectorAll("#jsforesight-debugger-shadow-host").forEach((function(e){return e.remove()})),"undefined"==typeof window||P())return null;e.isInitiated||(e.debuggerInstance=new e(t));var i=e.debuggerInstance;return i.shadowHost||i._setupDOM(),i.updateTrajectoryVisuals(n,t.getManagerData.globalSettings.enableMousePrediction),i},e.prototype.createElementOverlays=function(e){var t={expandedOverlay:T("div",this.debugContainer,{className:"jsforesight-expanded-overlay",data:e.name}),nameLabel:T("div",this.debugContainer,{className:"jsforesight-name-label"})};return this.debugElementOverlays.set(e.element,t),t},e.prototype.createOrUpdateElementOverlay=function(e){var t;if(this.debugContainer&&this.shadowRoot){this.lastElementData.set(e.element,{isHovering:e.isHovering,isTrajectoryHit:e.trajectoryHitData.isTrajectoryHit});var n=this.debugElementOverlays.get(e.element);n||(n=this.createElementOverlays(e)),I(n,e,null!==(t=this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==t?t:k),this.controlPanel.refreshElementList()}},e.prototype.toggleNameTagVisibility=function(){var e=this;this.foresightManagerInstance.registeredElements.forEach((function(t){var n,i=e.debugElementOverlays.get(t.element);i&&I(i,t,null!==(n=e.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==n?n:k)}))},e.prototype.removeElement=function(e){var t,n=this.debugElementOverlays.get(e);n&&(n.expandedOverlay.remove(),n.nameLabel.remove(),this.debugElementOverlays.delete(e)),this.lastElementData.delete(e),null===(t=this.controlPanel)||void 0===t||t.refreshElementList()},e.prototype.updateTrajectoryVisuals=function(e,t){if(this.shadowRoot&&this.debugContainer&&this.debugPredictedMouseIndicator&&this.debugTrajectoryLine){var n=e.predictedPoint,i=e.currentPoint;if(this.debugPredictedMouseIndicator.style.transform="translate(".concat(n.x,"px, ").concat(n.y,"px) translate(-50%, -50%)"),this.debugPredictedMouseIndicator.style.display=t?"block":"none",0!==n.x||0!==n.y)if(t){var o=n.x-i.x,r=n.y-i.y,s=Math.sqrt(o*o+r*r),a=180*Math.atan2(r,o)/Math.PI;this.debugTrajectoryLine.style.transform="translate(".concat(i.x,"px, ").concat(i.y,"px) rotate(").concat(a,"deg)"),this.debugTrajectoryLine.style.width="".concat(s,"px"),this.debugTrajectoryLine.style.display="block"}else this.debugTrajectoryLine.style.display="none";else this.debugPredictedMouseIndicator.style.display="none"}},e.prototype.updateControlsState=function(e){var t,n;null===(t=this.controlPanel)||void 0===t||t.updateControlsState(e),null===(n=this.controlPanel)||void 0===n||n.refreshElementList()},e.prototype.refreshDebuggerElementList=function(){var e;null===(e=this.controlPanel)||void 0===e||e.refreshElementList()},e.prototype.showCallbackAnimation=function(e){var t=this.debugElementOverlays.get(e.element);if(t){t.animation&&(clearTimeout(t.animation.timeoutId),t.animation.overlay.remove());var n=T("div",this.debugContainer,{className:"jsforesight-callback-indicator"}),i=e.elementBounds.expandedRect,o=i.left,r=i.top,s=i.right-o,a=i.bottom-r;n.style.display="block",n.style.translate="".concat(o,"px ").concat(r,"px"),n.style.width="".concat(s,"px"),n.style.height="".concat(a,"px"),requestAnimationFrame((function(){n.classList.add("animate")}));var l=setTimeout((function(){t.animation&&(t.animation.overlay.remove(),t.animation=void 0)}),400);t.animation={overlay:n,startTime:Date.now(),duration:400,timeoutId:l}}},e.prototype.cleanup=function(){var e,t;null===(e=this.controlPanel)||void 0===e||e.cleanup(),null===(t=this.shadowHost)||void 0===t||t.remove(),this.debugElementOverlays.clear(),this.lastElementData.clear(),this.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.controlPanel=null},e}(),L='\n #jsforesight-debug-container { \n position: fixed; top: 0; left: 0; width: 100%; height: 100%;\n pointer-events: none; z-index: 9999;\n }\n\n .jsforesight-expanded-overlay, \n .jsforesight-name-label, \n .jsforesight-callback-indicator,\n .jsforesight-mouse-predicted,\n .jsforesight-trajectory-line {\n position: absolute;\n top: 0;\n left: 0;\n will-change: transform; \n }\n .jsforesight-expanded-overlay {\n border: 1px dashed rgba(100, 116, 139, 0.4);\n background-color: rgba(100, 116, 139, 0.05);\n box-sizing: border-box;\n border-radius: 8px;\n }\n .jsforesight-mouse-predicted {\n width: 20px;\n height: 20px;\n border-radius: 50%;\n border: 2px solid #6b98e1;\n background-color: rgba(176, 196, 222, 0.3);\n z-index: 10000;\n /* transform is now set dynamically via JS for performance */\n }\n .jsforesight-trajectory-line {\n height: 2px;\n background-color: #6b98e1;\n transform-origin: left center;\n z-index: 9999;\n border-radius: 1px;\n /* width and transform are set dynamically via JS for performance */\n }\n .jsforesight-name-label {\n background-color: rgba(27, 31, 35, 0.85);\n backdrop-filter: blur(4px);\n color: white;\n padding: 4px 8px;\n font-size: 11px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";\n border-radius: 4px;\n z-index: 10001;\n white-space: nowrap;\n pointer-events: none;\n }\n .jsforesight-callback-indicator {\n border: 4px solid oklch(65% 0.22 280); \n border-radius: 8px;\n box-sizing: border-box;\n pointer-events: none;\n opacity: 0;\n z-index: 10002;\n display: none; \n }\n .jsforesight-callback-indicator.animate {\n animation: jsforesight-callback-pulse 0.4s ease-out forwards;\n }\n\n @keyframes jsforesight-callback-pulse {\n 0% {\n scale: 1;\n opacity: 1;\n box-shadow: 0 0 15px oklch(65% 0.22 280 / 0.7);\n }\n 100% {\n scale: 1.1; \n opacity: 0;\n box-shadow: 0 0 25px oklch(65% 0.22 280 / 0);\n }\n }\n ';function H(e,t,n,i,o){return i&&(e<t?console.warn('ForesightJS: "'.concat(o,'" value ').concat(e," is below minimum bound ").concat(t,", clamping to ").concat(t)):e>n&&console.warn('ForesightJS: "'.concat(o,'" value ').concat(e," is above maximum bound ").concat(n,", clamping to ").concat(n))),Math.min(Math.max(e,t),n)}function _(e,t,n){var i=0,o=1,r=t.x-e.x,s=t.y-e.y,a=function(e,t){if(0===e){if(t<0)return!1}else{var n=t/e;if(e<0){if(n>o)return!1;n>i&&(i=n)}else{if(n<i)return!1;n<o&&(o=n)}}return!0};return!!a(-r,e.x-n.left)&&(!!a(r,n.right-e.x)&&(!!a(-s,e.y-n.top)&&(!!a(s,n.bottom-e.y)&&i<=o)))}function D(e,t){if("number"==typeof e){var n=H(e,0,w,t,"hitslop");return{top:n,left:n,right:n,bottom:n}}return{top:H(e.top,0,w,t,"hitslop - top"),left:H(e.left,0,w,t,"hitslop - left"),right:H(e.right,0,w,t,"hitslop - right"),bottom:H(e.bottom,0,w,t,"hitslop - bottom")}}function N(e,t){return{left:e.left-t.left,right:e.right+t.right,top:e.top-t.top,bottom:e.bottom+t.bottom}}function R(e,t){return e&&t?e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom:e===t}function B(e,t){return e.x>=t.left&&e.x<=t.right&&e.y>=t.top&&e.y<=t.bottom}function A(e,t){return void 0!==e&&t!==e}const V=e=>(e=>(e=>null!=e&&"object"==typeof e||!1)(e)&&"number"==typeof e.nodeType&&[1,2,3,4,5,6,7,8,9,10,11].some((t=>e.nodeType===t))||!1)(e)&&1===e.nodeType||!1;const q=["all","intersecting","update"],F="PositionObserver Error";var G=class{entries;static version="1.1.0";_t;_r;_cm;_w;_h;_rm;_th;_c;constructor(e,t){if("function"!=typeof e)throw new Error(`${F}: ${e} is not a function.`);this.entries=new Map,this._c=e,this._t=0;const n=V(t?.root)?t.root:document?.documentElement;this._r=n,this._rm=t?.rootMargin,this._th=t?.threshold,
7
- /* istanbul ignore next @preserve */
8
- this._cm=q.indexOf(t?.callbackMode||"intersecting"),this._w=n.clientWidth,this._h=n.clientHeight}observe=e=>{if(console.log("here"),!V(e))throw new Error(`${F}: ${e} is not an instance of Element.`);
9
- /* istanbul ignore else @preserve - a guard must be set */this._r.contains(e)&&this._n(e).then((t=>{
10
- /* istanbul ignore else @preserve - don't allow duplicate entries */
11
- t.boundingClientRect&&!this.getEntry(e)&&this.entries.set(e,t)
12
- /* istanbul ignore else @preserve */,this._t||(this._t=requestAnimationFrame(this._rc))}))};unobserve=e=>{
13
- /* istanbul ignore else @preserve */
14
- this.entries.has(e)&&this.entries.delete(e)};_rc=()=>{
15
- /* istanbul ignore if @preserve - a guard must be set */
16
- if(!this.entries.size)return void(this._t=0);const{clientWidth:e,clientHeight:t}=this._r,n=new Promise((n=>{const i=[];this.entries.forEach((({target:n,boundingClientRect:o,isIntersecting:r})=>{
17
- /* istanbul ignore if @preserve - a guard must be set when target has been removed */
18
- this._r.contains(n)&&this._n(n).then((s=>{
19
- /* istanbul ignore if @preserve - make sure to only count visible entries */
20
- if(!s.isIntersecting){if(1===this._cm)return;if(2===this._cm)return void(r&&(this.entries.set(n,s),i.push(s)))}const{left:a,top:l}=s.boundingClientRect;
21
- /* istanbul ignore else @preserve - only schedule entries that changed position */o.top===l&&o.left===a&&this._w===e&&this._h===t||(this.entries.set(n,s),i.push(s))}))})),this._w=e,this._h=t,n(i)}));this._t=requestAnimationFrame((async()=>{const e=await n;
22
- /* istanbul ignore else @preserve */e.length&&this._c(e,this),this._rc()}))};_n=e=>new Promise((t=>{new IntersectionObserver((([e],n)=>{n.disconnect(),t(e)}),{threshold:this._th,rootMargin:this._rm}).observe(e)}));getEntry=e=>this.entries.get(e);disconnect=()=>{cancelAnimationFrame(this._t),this.entries.clear(),this._t=0}},U=function(){function t(){var e=this;this.elements=new Map,this.isSetup=!1,this.debugger=null,this._globalCallbackHits={mouse:{hover:0,trajectory:0},tab:{forwards:0,reverse:0},total:0},this._globalSettings={debug:false,enableMousePrediction:true,positionHistorySize:8,trajectoryPredictionTime:120,defaultHitSlop:{top:0,left:0,right:0,bottom:0},resizeScrollThrottleDelay:0,debuggerSettings:{isControlPanelDefaultMinimized:C,showNameTags:k},enableTabPrediction:true,tabOffset:2,onAnyCallbackFired:function(e,t){}},this.trajectoryPositions={positions:[],currentPoint:{x:0,y:0},predictedPoint:{x:0,y:0}},this.domObserver=null,this.positionObserver=null,this.lastKeyDown=null,this.globalListenersController=null,this.handleMouseMove=function(t){e.updatePointerState(t),e.elements.forEach((function(t){t.isIntersectingWithViewport&&(t.unregisterOnCallback?e.handleSingleCallbackInteraction(t):e.handleMultiCallbackInteraction(t))})),e.debugger&&e.debugger.updateTrajectoryVisuals(e.trajectoryPositions,e._globalSettings.enableMousePrediction)},this.handleDomMutations=function(t){for(var n=0,i=t;n<i.length;n++){var o=i[n];if("childList"===o.type&&o.removedNodes.length>0)for(var r=0,s=Array.from(e.elements.keys());r<s.length;r++){var a=s[r];a.isConnected||e.unregister(a)}}},this.handleKeyDown=function(t){"Tab"===t.key?e.lastKeyDown=t:e.lastKeyDown=null},this.handleFocusIn=function(t){if(e.lastKeyDown&&e._globalSettings.enableTabPrediction){var n=t.target;if(n instanceof HTMLElement){var i=y(document.documentElement),o=i.findIndex((function(e){return e===n})),r=e.lastKeyDown.shiftKey,s=r?-e._globalSettings.tabOffset:e._globalSettings.tabOffset;e.lastKeyDown=null;for(var a=[],l=0;l<i.length;l++){var c=i[l];(s>0?l>=o&&l<=o+s:l<=o&&l>=o+s)&&e.elements.has(c)&&a.push(i[l])}a.forEach((function(t){e.callCallback(e.elements.get(t),{kind:"tab",subType:r?"reverse":"forwards"})}))}}},this.handlePositionChange=function(t){for(var n,i=0,o=t;i<o.length;i++){var r=o[i],s=e.elements.get(r.target);if(s){var a=s.isIntersectingWithViewport,l=r.isIntersecting;s.isIntersectingWithViewport=l,l?(e.updateElementBounds(r.boundingClientRect,s),B(e.trajectoryPositions.currentPoint,null==s?void 0:s.elementBounds.expandedRect)&&e.callCallback(s,{kind:"mouse",subType:"hover"})):e._globalSettings.debug&&a&&(null===(n=e.debugger)||void 0===n||n.removeElement(r.target))}}}}return t.initialize=function(e){return this.isInitiated||(t.manager=new t),void 0!==e&&t.manager.alterGlobalSettings(e),t.manager},Object.defineProperty(t.prototype,"getManagerData",{get:function(){var e;return{registeredElements:this.elements,globalSettings:this._globalSettings,globalCallbackHits:this._globalCallbackHits,positionObserverElements:null===(e=this.positionObserver)||void 0===e?void 0:e.entries}},enumerable:!1,configurable:!0}),Object.defineProperty(t,"isInitiated",{get:function(){return!!t.manager},enumerable:!1,configurable:!0}),Object.defineProperty(t,"instance",{get:function(){return this.initialize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"registeredElements",{get:function(){return this.elements},enumerable:!1,configurable:!0}),t.prototype.register=function(e){var t,n,i=this,o=e.element,r=e.callback,s=e.hitSlop,a=e.unregisterOnCallback,l=e.name;if(P())return{isTouchDevice:!0,unregister:function(){}};if(this.elements.has(o))return{isTouchDevice:!1,unregister:function(){return i.unregister(o)}};this.isSetup||this.initializeGlobalListeners();var c=s?D(s,this._globalSettings.debug):this._globalSettings.defaultHitSlop,d=o.getBoundingClientRect(),u={element:o,callback:r,callbackHits:{mouse:{hover:0,trajectory:0},tab:{forwards:0,reverse:0},total:0},elementBounds:{originalRect:d,expandedRect:N(d,c),hitSlop:c},isHovering:!1,trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitTime:0,trajectoryHitExpirationTimeoutId:void 0},name:null!==(t=null!=l?l:o.id)&&void 0!==t?t:"",unregisterOnCallback:null==a||a,isIntersectingWithViewport:!0};return this.elements.set(o,u),null===(n=this.positionObserver)||void 0===n||n.observe(o),this.debugger&&this.debugger.createOrUpdateElementOverlay(u),{isTouchDevice:!1,unregister:function(){return i.unregister(o)}}},t.prototype.unregister=function(e){var t;if(this.elements.has(e)){var n=this.elements.get(e);(null==n?void 0:n.trajectoryHitData.trajectoryHitExpirationTimeoutId)&&clearTimeout(n.trajectoryHitData.trajectoryHitExpirationTimeoutId),null===(t=this.positionObserver)||void 0===t||t.unobserve(e),this.elements.delete(e),this.debugger&&this.debugger.removeElement(e),0===this.elements.size&&this.isSetup&&this.removeGlobalListeners()}},t.prototype.updateNumericSettings=function(e,t,n,i){return!!A(e,this._globalSettings[t])&&(this._globalSettings[t]=H(e,n,i,this._globalSettings.debug,t),!0)},t.prototype.updateBooleanSetting=function(e,t){return!!A(e,this._globalSettings[t])&&(this._globalSettings[t]=e,!0)},t.prototype.alterGlobalSettings=function(e){var t,n,i=this._globalSettings.positionHistorySize,o=this.updateNumericSettings(null==e?void 0:e.positionHistorySize,"positionHistorySize",2,30);o&&this._globalSettings.positionHistorySize<i&&this.trajectoryPositions.positions.length>this._globalSettings.positionHistorySize&&(this.trajectoryPositions.positions=this.trajectoryPositions.positions.slice(this.trajectoryPositions.positions.length-this._globalSettings.positionHistorySize));var r=this.updateNumericSettings(null==e?void 0:e.trajectoryPredictionTime,"trajectoryPredictionTime",10,200),s=this.updateNumericSettings(null==e?void 0:e.tabOffset,"tabOffset",0,20);void 0!==(null==e?void 0:e.resizeScrollThrottleDelay)&&console.warn("resizeScrollThrottleDelay is deprecated and will be removed in V3.0.0 of ForesightJS");var a=this.updateBooleanSetting(null==e?void 0:e.enableMousePrediction,"enableMousePrediction"),l=this.updateBooleanSetting(null==e?void 0:e.enableTabPrediction,"enableTabPrediction");void 0!==(null==e?void 0:e.onAnyCallbackFired)&&(this._globalSettings.onAnyCallbackFired=e.onAnyCallbackFired);var c=!1;void 0!==(null===(t=null==e?void 0:e.debuggerSettings)||void 0===t?void 0:t.isControlPanelDefaultMinimized)&&(this._globalSettings.debuggerSettings.isControlPanelDefaultMinimized=e.debuggerSettings.isControlPanelDefaultMinimized,c=!0),void 0!==(null===(n=null==e?void 0:e.debuggerSettings)||void 0===n?void 0:n.showNameTags)&&(this._globalSettings.debuggerSettings.showNameTags=e.debuggerSettings.showNameTags,c=!0,this.debugger&&this.debugger.toggleNameTagVisibility());var d=!1;if(void 0!==(null==e?void 0:e.defaultHitSlop)){var u=D(e.defaultHitSlop,this._globalSettings.debug);R(this._globalSettings.defaultHitSlop,u)||(this._globalSettings.defaultHitSlop=u,d=!0,this.forceUpdateAllElementBounds())}var h=!1;void 0!==(null==e?void 0:e.debug)&&this._globalSettings.debug!==e.debug&&"undefined"!=typeof window&&"undefined"!=typeof document&&(this._globalSettings.debug=e.debug,h=!0,this._globalSettings.debug?this.turnOnDebugMode():this.debugger&&(this.debugger.cleanup(),this.debugger=null)),(o||r||s||a||l||c||d||h)&&this.debugger&&this.debugger.updateControlsState(this._globalSettings)},t.prototype.turnOnDebugMode=function(){var e=this;this.debugger?this.debugger.updateControlsState(this._globalSettings):(this.debugger=O.initialize(t.instance,this.trajectoryPositions),this.elements.forEach((function(t){var n;null===(n=e.debugger)||void 0===n||n.createOrUpdateElementOverlay(t)})))},t.prototype.forceUpdateAllElementBounds=function(){var e=this;this.elements.forEach((function(t,n){var i=e.elements.get(n);i&&i.isIntersectingWithViewport&&e.forceUpdateElementBounds(i)}))},t.prototype.updatePointerState=function(t){this.trajectoryPositions.currentPoint={x:t.clientX,y:t.clientY},this.trajectoryPositions.predictedPoint=this._globalSettings.enableMousePrediction?function(e,t,n,i){var o={point:e,time:performance.now()},r=e.x,s=e.y;if(t.push(o),t.length>n&&t.shift(),t.length<2)return{x:r,y:s};var a=t[0],l=t[t.length-1],c=(l.time-a.time)/1e3;if(0===c)return{x:r,y:s};var d=i/1e3;return{x:r+(l.point.x-a.point.x)/c*d,y:s+(l.point.y-a.point.y)/c*d}}(this.trajectoryPositions.currentPoint,this.trajectoryPositions.positions,this._globalSettings.positionHistorySize,this._globalSettings.trajectoryPredictionTime):e({},this.trajectoryPositions.currentPoint)},t.prototype.handleSingleCallbackInteraction=function(e){var t=e.elementBounds.expandedRect;if(this._globalSettings.enableMousePrediction)_(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,t)&&this.callCallback(e,{kind:"mouse",subType:"trajectory"});else if(B(this.trajectoryPositions.currentPoint,t))return void this.callCallback(e,{kind:"mouse",subType:"hover"})},t.prototype.handleMultiCallbackInteraction=function(t){var n=this,i=t.elementBounds.expandedRect,o=B(this.trajectoryPositions.currentPoint,i),r=o&&!t.isHovering,s=this._globalSettings.enableMousePrediction&&!o&&!t.trajectoryHitData.isTrajectoryHit&&_(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,i);if((r||s)&&this.callCallback(t,{kind:"mouse",subType:r?"hover":"trajectory"}),o!==t.isHovering||s){var a=e(e({},t),{isHovering:o,trajectoryHitData:e(e({},t.trajectoryHitData),{isTrajectoryHit:s,trajectoryHitTime:s?performance.now():t.trajectoryHitData.trajectoryHitTime})});s&&(a.trajectoryHitData.trajectoryHitExpirationTimeoutId&&clearTimeout(a.trajectoryHitData.trajectoryHitExpirationTimeoutId),a.trajectoryHitData.trajectoryHitExpirationTimeoutId=setTimeout((function(){var e,i=n.elements.get(t.element);i&&i.trajectoryHitData.trajectoryHitTime===a.trajectoryHitData.trajectoryHitTime&&(i.trajectoryHitData.isTrajectoryHit=!1,null===(e=n.debugger)||void 0===e||e.createOrUpdateElementOverlay(i))}),200)),this.elements.set(t.element,a)}},t.prototype.updateHitCounters=function(e,t){switch(t.kind){case"mouse":e.callbackHits.mouse[t.subType]++,this._globalCallbackHits.mouse[t.subType]++;break;case"tab":e.callbackHits.tab[t.subType]++,this._globalCallbackHits.tab[t.subType]++}e.callbackHits.total++,this._globalCallbackHits.total++},t.prototype.callCallback=function(e,t){e&&(this.updateHitCounters(e,t),e.callback(),this._globalSettings.onAnyCallbackFired(e,this.getManagerData),this.debugger&&(this.debugger.showCallbackAnimation(e),this.debugger.refreshDebuggerElementList()),e.unregisterOnCallback&&this.unregister(e.element))},t.prototype.forceUpdateElementBounds=function(t){var n=t.element.getBoundingClientRect(),i=N(n,t.elementBounds.hitSlop);if(!R(i,t.elementBounds.expandedRect)&&(this.elements.set(t.element,e(e({},t),{elementBounds:e(e({},t.elementBounds),{originalRect:n,expandedRect:i})})),this.debugger)){var o=this.elements.get(t.element);o&&this.debugger.createOrUpdateElementOverlay(o)}},t.prototype.updateElementBounds=function(t,n){var i=N(t,n.elementBounds.hitSlop);if(this.elements.set(n.element,e(e({},n),{elementBounds:e(e({},n.elementBounds),{originalRect:t,expandedRect:i})})),this.debugger){var o=this.elements.get(n.element);o&&this.debugger.createOrUpdateElementOverlay(o)}},t.prototype.initializeGlobalListeners=function(){if(!this.isSetup&&"undefined"!=typeof window&&"undefined"!=typeof document){this.globalListenersController=new AbortController;var e=this.globalListenersController.signal;document.addEventListener("mousemove",this.handleMouseMove,{signal:e}),document.addEventListener("keydown",this.handleKeyDown,{signal:e}),document.addEventListener("focusin",this.handleFocusIn,{signal:e}),this.domObserver=new MutationObserver(this.handleDomMutations),this.domObserver.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1}),this.positionObserver=new G(this.handlePositionChange,{callbackMode:"update",rootMargin:"20px"}),this.isSetup=!0}},t.prototype.removeGlobalListeners=function(){var e,t,n;this.isSetup=!1,this.debugger?console.log("%cForesightJS: All elements have successfully been unregistered. ForesightJS would typically perform cleanup events now, but these are currently skipped while in debug mode. Observers are cleared up.","color: #28a745; font-weight: bold;"):(null===(e=this.globalListenersController)||void 0===e||e.abort(),this.globalListenersController=null),null===(t=this.domObserver)||void 0===t||t.disconnect(),this.domObserver=null,null===(n=this.positionObserver)||void 0===n||n.disconnect(),this.positionObserver=null},t}();exports.ForesightManager=U;
6
+ var e=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"].join(","),n="undefined"==typeof Element,i=n?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,o=!n&&Element.prototype.getRootNode?function(t){var e;return null==t||null===(e=t.getRootNode)||void 0===e?void 0:e.call(t)}:function(t){return null==t?void 0:t.ownerDocument},r=function t(e,n){var i;void 0===n&&(n=!0);var o=null==e||null===(i=e.getAttribute)||void 0===i?void 0:i.call(e,"inert");return""===o||"true"===o||n&&e&&t(e.parentNode)},s=function t(n,o,s){for(var a=[],l=Array.from(n);l.length;){var c=l.shift();if(!r(c,!1))if("SLOT"===c.tagName){var d=c.assignedElements(),u=t(d.length?d:c.children,!0,s);s.flatten?a.push.apply(a,u):a.push({scopeParent:c,candidates:u})}else{i.call(c,e)&&s.filter(c)&&(o||!n.includes(c))&&a.push(c);var h=c.shadowRoot||"function"==typeof s.getShadowRoot&&s.getShadowRoot(c),g=!r(h,!1)&&(!s.shadowRootFilter||s.shadowRootFilter(c));if(h&&g){var p=t(!0===h?c.children:h.children,!0,s);s.flatten?a.push.apply(a,p):a.push({scopeParent:c,candidates:p})}else l.unshift.apply(l,c.children)}}return a},a=function(t){return!isNaN(parseInt(t.getAttribute("tabindex"),10))},l=function(t){if(!t)throw new Error("No node provided");return t.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(t.tagName)||function(t){var e,n=null==t||null===(e=t.getAttribute)||void 0===e?void 0:e.call(t,"contenteditable");return""===n||"true"===n}(t))&&!a(t)?0:t.tabIndex},c=function(t,e){return t.tabIndex===e.tabIndex?t.documentOrder-e.documentOrder:t.tabIndex-e.tabIndex},d=function(t){return"INPUT"===t.tagName},u=function(t){return function(t){return d(t)&&"radio"===t.type}(t)&&!function(t){if(!t.name)return!0;var e,n=t.form||o(t),i=function(t){return n.querySelectorAll('input[type="radio"][name="'+t+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)e=i(window.CSS.escape(t.name));else try{e=i(t.name)}catch(t){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",t.message),!1}var r=function(t,e){for(var n=0;n<t.length;n++)if(t[n].checked&&t[n].form===e)return t[n]}(e,t.form);return!r||r===t}(t)},h=function(t){var e=t.getBoundingClientRect(),n=e.width,i=e.height;return 0===n&&0===i},g=function(t,e){var n=e.displayCheck,r=e.getShadowRoot;if("hidden"===getComputedStyle(t).visibility)return!0;var s=i.call(t,"details>summary:first-of-type")?t.parentElement:t;if(i.call(s,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return h(t)}else{if("function"==typeof r){for(var a=t;t;){var l=t.parentElement,c=o(t);if(l&&!l.shadowRoot&&!0===r(l))return h(t);t=t.assignedSlot?t.assignedSlot:l||c===t.ownerDocument?l:c.host}t=a}if(function(t){var e,n,i,r,s=t&&o(t),a=null===(e=s)||void 0===e?void 0:e.host,l=!1;if(s&&s!==t)for(l=!!(null!==(n=a)&&void 0!==n&&null!==(i=n.ownerDocument)&&void 0!==i&&i.contains(a)||null!=t&&null!==(r=t.ownerDocument)&&void 0!==r&&r.contains(t));!l&&a;){var c,d,u;l=!(null===(d=a=null===(c=s=o(a))||void 0===c?void 0:c.host)||void 0===d||null===(u=d.ownerDocument)||void 0===u||!u.contains(a))}return l}(t))return!t.getClientRects().length;if("legacy-full"!==n)return!0}return!1},p=function(t,e){return!(e.disabled||r(e)||function(t){return d(t)&&"hidden"===t.type}(e)||g(e,t)||function(t){return"DETAILS"===t.tagName&&Array.prototype.slice.apply(t.children).some((function(t){return"SUMMARY"===t.tagName}))}(e)||function(t){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(t.tagName))for(var e=t.parentElement;e;){if("FIELDSET"===e.tagName&&e.disabled){for(var n=0;n<e.children.length;n++){var o=e.children.item(n);if("LEGEND"===o.tagName)return!!i.call(e,"fieldset[disabled] *")||!o.contains(t)}return!0}e=e.parentElement}return!1}(e))},b=function(t,e){return!(u(e)||l(e)<0||!p(t,e))},m=function(t){var e=parseInt(t.getAttribute("tabindex"),10);return!!(isNaN(e)||e>=0)},f=function t(e){var n=[],i=[];return e.forEach((function(e,o){var r=!!e.scopeParent,s=r?e.scopeParent:e,c=function(t,e){var n=l(t);return n<0&&e&&!a(t)?0:n}(s,r),d=r?t(e.candidates):s;0===c?r?n.push.apply(n,d):n.push(s):i.push({documentOrder:o,tabIndex:c,item:e,isScope:r,content:d})})),i.sort(c).reduce((function(t,e){return e.isScope?t.push.apply(t,e.content):t.push(e.content),t}),[]).concat(n)},v=function(t,n){var o;return o=(n=n||{}).getShadowRoot?s([t],n.includeContainer,{filter:b.bind(null,n),flatten:!1,getShadowRoot:n.getShadowRoot,shadowRootFilter:m}):function(t,n,o){if(r(t))return[];var s=Array.prototype.slice.apply(t.querySelectorAll(e));return n&&i.call(t,e)&&s.unshift(t),s.filter(o)}(t,n.includeContainer,b.bind(null,n)),f(o)},y="ms",S="points",x="tabs",w=2e3,C=!1,k=!0;var E=function(t,e){void 0===e&&(e=2);var n=" ".repeat(e);if("object"==typeof t&&null!==t&&!Array.isArray(t)){var i=Object.entries(t);if(0===i.length)return"{}";var o=i.map((function(t){var i=t[0],o=t[1];return"".concat(n," ").concat(i,": ").concat(E(o,e+2))})).join(",\n");return"{\n".concat(o,"\n").concat(n,"}")}return"string"==typeof t?"'".concat(t,"'"):"boolean"==typeof t||"number"==typeof t?String(t):null===t?"null":void 0===t?"undefined":Array.isArray(t)?JSON.stringify(t):String(t)};function M(t,e,n){var i=document.createElement(t);return n.id&&(i.id=n.id),n.className&&(i.className=n.className),n.data&&i.setAttribute("data-value",n.data),e.appendChild(i)}function O(t,e,n){var i=document.createElement("style");return i.textContent=t,i.id=n,e.appendChild(i)}var j=function(t){return t?"👁️":"🚫"},T='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>',P="<em>No elements registered.</em>",I=function(){function t(t){this.elementListItemsContainer=null,this.elementCountSpan=null,this.callbackCountSpan=null,this.elementListItems=new Map,this.trajectoryEnabledCheckbox=null,this.tabEnabledCheckbox=null,this.scrollEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.scrollMarginSlider=null,this.scrollMarginValueSpan=null,this.showNameTagsCheckbox=null,this.sortOptionsPopup=null,this.sortButton=null,this.containerMinimizeButton=null,this.allSettingsSectionsContainer=null,this.debuggerElementsSection=null,this.isContainerMinimized=!1,this.isMouseSettingsMinimized=!0,this.isKeyboardSettingsMinimized=!0,this.isScrollSettingsMinimized=!0,this.isGeneralSettingsMinimized=!0,this.SESSION_STORAGE_KEY="jsforesightDebuggerSectionStates",this.copySettingsButton=null,this.copyTimeoutId=null,this.closeSortDropdownHandler=null,this.foresightManagerInstance=t}return t.prototype._setupDOMAndListeners=function(t,e){var n;this.controlsContainer||(this.shadowRoot=t,this.isContainerMinimized=null!==(n=e.isControlPanelDefaultMinimized)&&void 0!==n?n:C,this.controlsContainer=this.createControlContainer(),this.shadowRoot.appendChild(this.controlsContainer),this.controlPanelStyleElement=O(this.getStyles(),this.shadowRoot,"debug-control-panel"),this.queryDOMElements(),this.originalSectionStates(),this.setupEventListeners(),this.updateContainerVisibilityState())},t.initialize=function(e,n,i){t.isInitiated||(t.debuggerControlPanelInstance=new t(e));var o=t.debuggerControlPanelInstance;return o._setupDOMAndListeners(n,i),o},Object.defineProperty(t,"isInitiated",{get:function(){return!!t.debuggerControlPanelInstance},enumerable:!1,configurable:!0}),t.prototype.loadSectionStatesFromSessionStorage=function(){var t,e,n,i,o=sessionStorage.getItem(this.SESSION_STORAGE_KEY),r={};return o&&(r=JSON.parse(o)),this.isMouseSettingsMinimized=null===(t=r.mouse)||void 0===t||t,this.isKeyboardSettingsMinimized=null===(e=r.keyboard)||void 0===e||e,this.isScrollSettingsMinimized=null===(n=r.scroll)||void 0===n||n,this.isGeneralSettingsMinimized=null===(i=r.general)||void 0===i||i,r},t.prototype.saveSectionStatesToSessionStorage=function(){var t={mouse:this.isMouseSettingsMinimized,keyboard:this.isKeyboardSettingsMinimized,scroll:this.isScrollSettingsMinimized,general:this.isGeneralSettingsMinimized};try{sessionStorage.setItem(this.SESSION_STORAGE_KEY,JSON.stringify(t))}catch(t){console.error("Foresight Debugger: Could not save section states to session storage.",t)}},t.prototype.queryDOMElements=function(){this.trajectoryEnabledCheckbox=this.controlsContainer.querySelector("#trajectory-enabled"),this.tabEnabledCheckbox=this.controlsContainer.querySelector("#tab-enabled"),this.scrollEnabledCheckbox=this.controlsContainer.querySelector("#scroll-enabled"),this.historySizeSlider=this.controlsContainer.querySelector("#history-size"),this.historyValueSpan=this.controlsContainer.querySelector("#history-value"),this.predictionTimeSlider=this.controlsContainer.querySelector("#prediction-time"),this.predictionValueSpan=this.controlsContainer.querySelector("#prediction-value"),this.tabOffsetSlider=this.controlsContainer.querySelector("#tab-offset"),this.tabOffsetValueSpan=this.controlsContainer.querySelector("#tab-offset-value"),this.scrollMarginSlider=this.controlsContainer.querySelector("#scroll-margin"),this.scrollMarginValueSpan=this.controlsContainer.querySelector("#scroll-margin-value"),this.elementListItemsContainer=this.controlsContainer.querySelector("#element-list-items-container"),this.showNameTagsCheckbox=this.controlsContainer.querySelector("#toggle-name-tags"),this.sortOptionsPopup=this.controlsContainer.querySelector("#sort-options-popup"),this.sortButton=this.controlsContainer.querySelector(".sort-button"),this.elementCountSpan=this.controlsContainer.querySelector("#element-count"),this.callbackCountSpan=this.controlsContainer.querySelector("#callback-count"),this.containerMinimizeButton=this.controlsContainer.querySelector(".minimize-button"),this.allSettingsSectionsContainer=this.controlsContainer.querySelector(".all-settings-sections-container"),this.debuggerElementsSection=this.controlsContainer.querySelector(".debugger-elements"),this.copySettingsButton=this.controlsContainer.querySelector(".copy-settings-button")},t.prototype.handleCopySettings=function(){var t,e,n,i=this;this.copySettingsButton&&navigator.clipboard.writeText((t=this.foresightManagerInstance.getManagerData.globalSettings,e="ForesightManager.initialize",n=Object.entries(t).filter((function(t){var e=t[0];return"resizeScrollThrottleDelay"!==String(e)})).map((function(t){var e=t[0],n=t[1];return" ".concat(String(e),": ").concat(E(n))})).join(",\n"),"".concat(e,"({\n").concat(n,"\n})"))).then((function(){i.copySettingsButton.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg>',i.copyTimeoutId&&clearTimeout(i.copyTimeoutId),i.copyTimeoutId=setTimeout((function(){i.copySettingsButton&&(i.copySettingsButton.innerHTML=T),i.copyTimeoutId=null}),3e3)})).catch((function(t){console.error("Foresight Debugger: Could not copy settings to clipboard",t)}))},t.prototype.createInputEventListener=function(t,e,n,i){var o=this;t&&e&&t.addEventListener("input",(function(t){var r,s=parseInt(t.target.value,10);e.textContent="".concat(s," ").concat(n),o.foresightManagerInstance.alterGlobalSettings(((r={})[i]=s,r))}))},t.prototype.createChangeEventListener=function(t,e){var n=this;t&&t.addEventListener("change",(function(t){var i;"name-tag"===e?n.foresightManagerInstance.alterGlobalSettings({debuggerSettings:{showNameTags:t.target.checked}}):n.foresightManagerInstance.alterGlobalSettings(((i={})[e]=t.target.checked,i))}))},t.prototype.createSectionVisibilityToggleEventListener=function(t,e){var n=this,i=null==t?void 0:t.querySelector(".debugger-section-header");null==i||i.addEventListener("click",(function(i){i.stopPropagation(),n.toggleMinimizeSection(t,n[e]=!n[e])}))},t.prototype.setupEventListeners=function(){var t,e,n,i,o=this;this.createChangeEventListener(this.trajectoryEnabledCheckbox,"enableMousePrediction"),this.createChangeEventListener(this.tabEnabledCheckbox,"enableTabPrediction"),this.createChangeEventListener(this.scrollEnabledCheckbox,"enableScrollPrediction"),this.createChangeEventListener(this.showNameTagsCheckbox,"name-tag"),this.createInputEventListener(this.historySizeSlider,this.historyValueSpan,S,"positionHistorySize"),this.createInputEventListener(this.predictionTimeSlider,this.predictionValueSpan,y,"trajectoryPredictionTime"),this.createInputEventListener(this.tabOffsetSlider,this.tabOffsetValueSpan,x,"tabOffset"),this.createInputEventListener(this.scrollMarginSlider,this.scrollMarginValueSpan,"px","scrollMargin"),null===(t=this.sortButton)||void 0===t||t.addEventListener("click",(function(t){var e;t.stopPropagation(),null===(e=o.sortOptionsPopup)||void 0===e||e.classList.toggle("active")})),null===(e=this.sortOptionsPopup)||void 0===e||e.addEventListener("click",(function(t){var e,n=t.target.closest("[data-sort]");if(n){var i=n.dataset.sort;o.foresightManagerInstance.alterGlobalSettings({debuggerSettings:{sortElementList:i}}),console.log("here"),o.sortAndReorderElements(),o.updateSortOptionUI(i),null===(e=o.sortOptionsPopup)||void 0===e||e.classList.remove("active")}})),this.closeSortDropdownHandler=function(t){var e,n;(null===(e=o.sortOptionsPopup)||void 0===e?void 0:e.classList.contains("active"))&&!(null===(n=o.sortButton)||void 0===n?void 0:n.contains(t.target))&&o.sortOptionsPopup.classList.remove("active")},document.addEventListener("click",this.closeSortDropdownHandler),null===(n=this.containerMinimizeButton)||void 0===n||n.addEventListener("click",(function(){o.isContainerMinimized=!o.isContainerMinimized,o.updateContainerVisibilityState()})),null===(i=this.copySettingsButton)||void 0===i||i.addEventListener("click",this.handleCopySettings.bind(this)),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".mouse-settings-section"),"isMouseSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".keyboard-settings-section"),"isKeyboardSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".scroll-settings-section"),"isScrollSettingsMinimized"),this.createSectionVisibilityToggleEventListener(this.controlsContainer.querySelector(".general-settings-section"),"isGeneralSettingsMinimized")},t.prototype.toggleMinimizeSection=function(t,e){if(t){var n=t.querySelector(".debugger-section-content"),i=t.querySelector(".section-minimize-button");n&&i&&(e?(n.style.display="none",i.textContent="+"):(n.style.display="flex",i.textContent="-")),this.saveSectionStatesToSessionStorage()}},t.prototype.originalSectionStates=function(){var t,e,n,i,o,r=this.loadSectionStatesFromSessionStorage();this.toggleMinimizeSection(this.controlsContainer.querySelector(".mouse-settings-section"),null===(t=r.mouse)||void 0===t||t),this.toggleMinimizeSection(this.controlsContainer.querySelector(".keyboard-settings-section"),null===(e=r.keyboard)||void 0===e||e),this.toggleMinimizeSection(this.controlsContainer.querySelector(".scroll-settings-section"),null===(n=r.scroll)||void 0===n||n),this.toggleMinimizeSection(this.controlsContainer.querySelector(".general-settings-section"),null===(i=r.general)||void 0===i||i);var s=null===(o=this.debuggerElementsSection)||void 0===o?void 0:o.querySelector(".debugger-section-content");s&&(s.style.display="flex")},t.prototype.updateContainerVisibilityState=function(){this.containerMinimizeButton&&(this.isContainerMinimized?(this.controlsContainer.classList.add("minimized"),this.containerMinimizeButton.textContent="+",this.allSettingsSectionsContainer&&(this.allSettingsSectionsContainer.style.display="none"),this.debuggerElementsSection&&(this.debuggerElementsSection.style.display="none"),this.copySettingsButton&&(this.copySettingsButton.style.display="none")):(this.controlsContainer.classList.remove("minimized"),this.containerMinimizeButton.textContent="-",this.allSettingsSectionsContainer&&(this.allSettingsSectionsContainer.style.display=""),this.debuggerElementsSection&&(this.debuggerElementsSection.style.display=""),this.copySettingsButton&&(this.copySettingsButton.style.display="")))},t.prototype.updateSortOptionUI=function(t){var e;null===(e=this.sortOptionsPopup)||void 0===e||e.querySelectorAll("[data-sort]").forEach((function(e){var n=e;n.dataset.sort===t?n.classList.add("active-sort-option"):n.classList.remove("active-sort-option")}))},t.prototype.updateControlsState=function(t){var e,n;this.trajectoryEnabledCheckbox&&(this.trajectoryEnabledCheckbox.checked=t.enableMousePrediction),this.tabEnabledCheckbox&&(this.tabEnabledCheckbox.checked=t.enableTabPrediction),this.scrollEnabledCheckbox&&(this.scrollEnabledCheckbox.checked=t.enableScrollPrediction),this.showNameTagsCheckbox&&(this.showNameTagsCheckbox.checked=null!==(e=t.debuggerSettings.showNameTags)&&void 0!==e?e:k),this.updateSortOptionUI(null!==(n=t.debuggerSettings.sortElementList)&&void 0!==n?n:"visibility"),this.historySizeSlider&&this.historyValueSpan&&(this.historySizeSlider.value=t.positionHistorySize.toString(),this.historyValueSpan.textContent="".concat(t.positionHistorySize," ").concat(S)),this.predictionTimeSlider&&this.predictionValueSpan&&(this.predictionTimeSlider.value=t.trajectoryPredictionTime.toString(),this.predictionValueSpan.textContent="".concat(t.trajectoryPredictionTime," ").concat(y)),this.tabOffsetSlider&&this.tabOffsetValueSpan&&(this.tabOffsetSlider.value=t.tabOffset.toString(),this.tabOffsetValueSpan.textContent="".concat(t.tabOffset," ").concat(x)),this.scrollMarginSlider&&this.scrollMarginValueSpan&&(this.scrollMarginSlider.value=t.scrollMargin.toString(),this.scrollMarginValueSpan.textContent="".concat(t.scrollMargin," ").concat("px"))},t.prototype.refreshRegisteredElementCountDisplay=function(t){if(this.elementCountSpan&&this.callbackCountSpan){var e=0;t.forEach((function(t){t.isIntersectingWithViewport&&e++}));var n=t.size,i=this.foresightManagerInstance.getManagerData.globalCallbackHits,o=i.tab,r=i.mouse,s=i.scroll,a=i.total;this.elementCountSpan.textContent="Visible: ".concat(e,"/").concat(n," ~ "),this.elementCountSpan.title=["Element Visibility Status","━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Visible in Viewport: ".concat(e),"Not in Viewport: ".concat(n-e),"Total Registered Elements: ".concat(n),"","Note: Only elements visible in the viewport","are actively tracked by intersection observers."].join("\n"),this.callbackCountSpan.textContent="Mouse: ".concat(r.hover+r.trajectory," Tab: ").concat(o.forwards+o.reverse," Scroll: ").concat(s.down+s.left+s.right+s.up),this.callbackCountSpan.title=["Callback Execution Stats","━━━━━━━━━━━━━━━━━━━━━━━━","Mouse Callbacks"," • Trajectory: ".concat(r.trajectory)," • Hover: ".concat(r.hover)," • Subtotal: ".concat(r.hover+r.trajectory),"","Keyboard Callbacks:"," • Tab Forward: ".concat(o.forwards)," • Tab Reverse: ".concat(o.reverse)," • Subtotal: ".concat(o.forwards+o.reverse),"","Scroll Callbacks:"," • Up: ".concat(s.up," | Down: ").concat(s.down)," • Left: ".concat(s.left," | Right: ").concat(s.right)," • Subtotal: ".concat(s.up+s.down+s.left+s.right),"","Total Callbacks: "+a].join("\n")}},t.prototype.removeElementFromList=function(t){if(this.elementListItemsContainer){var e=this.elementListItems.get(t.element);if(e){e.remove(),this.elementListItems.delete(t.element);var n=this.foresightManagerInstance.registeredElements;this.refreshRegisteredElementCountDisplay(n),0===this.elementListItems.size&&(this.elementListItemsContainer.innerHTML=P)}}},t.prototype.updateElementVisibilityStatus=function(t){if(this.elementListItemsContainer){var e=this.elementListItems.get(t.element);if(e){e.classList.toggle("not-in-viewport",!t.isIntersectingWithViewport);var n=e.querySelector(".intersecting-indicator");if(n){var i=j(t.isIntersectingWithViewport);n.textContent=i}this.refreshRegisteredElementCountDisplay(this.foresightManagerInstance.registeredElements),this.sortAndReorderElements()}else this.addElementToList(t)}},t.prototype.sortAndReorderElements=function(){var t,e=this;if(this.elementListItemsContainer){var n=null!==(t=this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.sortElementList)&&void 0!==t?t:"visibility",i=Array.from(this.foresightManagerInstance.registeredElements.values());if("insertionOrder"!==n){var o=function(t,e){var n=t.element.compareDocumentPosition(e.element);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0};"visibility"===n?i.sort((function(t,e){return t.isIntersectingWithViewport!==e.isIntersectingWithViewport?t.isIntersectingWithViewport?-1:1:o(t,e)})):"documentOrder"===n&&i.sort(o)}var r=document.createDocumentFragment();i.length&&(i.forEach((function(t){var n=e.elementListItems.get(t.element);n&&r.appendChild(n)})),this.elementListItemsContainer.innerHTML="",this.elementListItemsContainer.appendChild(r))}},t.prototype.addElementToList=function(t,e){if(void 0===e&&(e=!0),this.elementListItemsContainer&&(this.elementListItemsContainer.innerHTML===P&&(this.elementListItemsContainer.innerHTML=""),!this.elementListItems.has(t.element))){var n=document.createElement("div");n.className="element-list-item",this.updateListItemContent(n,t),this.elementListItemsContainer.appendChild(n),this.elementListItems.set(t.element,n),this.refreshRegisteredElementCountDisplay(this.foresightManagerInstance.registeredElements),e&&this.sortAndReorderElements()}},t.prototype.updateListItemContent=function(t,e){var n=j(e.isIntersectingWithViewport);t.classList.toggle("not-in-viewport",!e.isIntersectingWithViewport);var i=e.unregisterOnCallback?"Single":"Multi",o="N/A";if(e.elementBounds.hitSlop){var r=e.elementBounds.hitSlop,s=r.top,a=r.right,l=r.bottom,c=r.left;o="T:".concat(s," R:").concat(a," B:").concat(l," L:").concat(c)}var d=["".concat(e.name||"Unnamed Element"),"━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Viewport Status:",e.isIntersectingWithViewport?" ✓ In viewport - actively tracked by observers":" ✗ Not in viewport - not being tracked","","Hit Behavior:",e.unregisterOnCallback?" • Single: Callback triggers once":" • Multi: Callback can trigger multiple times","","Hit Slop:",e.elementBounds.hitSlop?[" Top: ".concat(e.elementBounds.hitSlop.top,"px, Bottom: ").concat(e.elementBounds.hitSlop.bottom,"px ")," Right: ".concat(e.elementBounds.hitSlop.right,"px, Left: ").concat(e.elementBounds.hitSlop.left,"px")].join("\n"):" • Not defined - using element's natural boundaries",""].join("\n");t.title=d,t.innerHTML='\n <span class="intersecting-indicator">'.concat(n,'</span>\n <span class="element-name">').concat(e.name||"Unnamed Element",'</span>\n <span class="hit-slop">').concat(o,'</span>\n <span class="hit-behavior">').concat(i,"</span>\n ")},t.prototype.cleanup=function(){var t,e;null===(t=this.controlsContainer)||void 0===t||t.remove(),null===(e=this.controlPanelStyleElement)||void 0===e||e.remove(),this.copyTimeoutId&&(clearTimeout(this.copyTimeoutId),this.copyTimeoutId=null),this.closeSortDropdownHandler&&(document.removeEventListener("click",this.closeSortDropdownHandler),this.closeSortDropdownHandler=null),this.controlsContainer=null,this.controlPanelStyleElement=null,this.elementListItemsContainer=null,this.elementCountSpan=null,this.callbackCountSpan=null,this.elementListItems.clear(),this.containerMinimizeButton=null,this.allSettingsSectionsContainer=null,this.debuggerElementsSection=null,this.trajectoryEnabledCheckbox=null,this.tabEnabledCheckbox=null,this.scrollEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.scrollMarginSlider=null,this.scrollMarginValueSpan=null,this.showNameTagsCheckbox=null,this.sortOptionsPopup=null,this.sortButton=null,this.copySettingsButton=null},t.prototype.createControlContainer=function(){var t=document.createElement("div");return t.id="debug-controls",t.innerHTML='\n <div class="debugger-title-container">\n <button class="minimize-button">-</button>\n <div class="title-group">\n <h2>Foresight Debugger</h2>\n <span class="info-icon" title="'.concat(["Foresight Debugger Information","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Session-Only Changes:","All adjustments made here apply only to the","current browser session and won't persist.","","Permanent Configuration:","To make lasting changes, update the initial","values in your ForesightManager.initialize().","","You can copy the current debugger settings","with the button on the right"].join("\n"),'">i</span>\n </div>\n <button class="copy-settings-button" title="').concat(["Copy Settings to Clipboard","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Copies the current configuration as a","formatted method call that you can paste","directly into your code."].join("\n"),'">\n ').concat(T,'\n </button>\n </div>\n\n <div class="all-settings-sections-container">\n <div class="debugger-section mouse-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>Mouse Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content mouse-settings-content">\n <div class="control-row">\n <label for="trajectory-enabled">\n Enable Mouse Prediction\n <span class="info-icon" title="').concat(["Mouse Prediction Control","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","When enabled: Predicts mouse movement","trajectory and triggers callbacks before","the cursor reaches the target element.","","When disabled: Only direct hover events","trigger actions (next to tab/scroll).","","Property: enableMousePrediction"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="trajectory-enabled">\n </div>\n <div class="control-row">\n <label for="history-size">\n History Size\n <span class="info-icon" title="').concat(["Position History","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Controls how many past mouse positions","are stored for velocity calculations.","","Higher values:"," • More accurate trajectory predictions"," • Smoother movement detection"," • Slightly increased processing overhead","","Lower values:"," • Faster response to direction changes"," • Less memory usage"," • May be less accurate for fast movements","","Property: positionHistorySize"].join("\n"),'">i</span>\n </label>\n <input type="range" id="history-size" min="').concat(2,'" max="').concat(30,'">\n <span id="history-value"></span>\n </div>\n <div class="control-row">\n <label for="prediction-time">\n Prediction Time\n <span class="info-icon" title="').concat(["Trajectory Prediction Time","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","How far into the future (in ".concat(y,")"),"to calculate the mouse trajectory path.","","Larger values:"," • Elements are detected sooner"," • More time for preloading/preparation"," • May trigger false positives for curved paths","","Smaller values:"," • More precise targeting"," • Reduced false positive rate"," • Less time for preparation","","Property: trajectoryPredictionTime"].join("\n"),'">i</span>\n </label>\n <input type="range" id="prediction-time" min="').concat(10,'" max="').concat(200,'" step="10">\n <span id="prediction-value"></span>\n </div>\n </div>\n </div>\n\n <div class="debugger-section keyboard-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>Keyboard Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content keyboard-settings-content">\n <div class="control-row">\n <label for="tab-enabled">\n Enable Tab Prediction\n <span class="info-icon" title="').concat(["Tab Navigation Prediction","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","When enabled: Callbacks are executed when","the user is ".concat(this.foresightManagerInstance.getManagerData.globalSettings.tabOffset," (tabOffset) ").concat(x," away from"),"a registered element during tab navigation.","","(works with Shift+Tab too).","","Property: enableTabPrediction"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="tab-enabled">\n </div>\n <div class="control-row">\n <label for="tab-offset">\n Tab Offset\n <span class="info-icon" title="').concat(["Tab Offset","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Number of tabbable elements to look ahead","when predicting tab navigation targets.","","How it works:"," • Tracks the current focused element"," • Looks ahead by the specified offset"," • Triggers callbacks for registered elements"," within that range","","Property: tabOffset"].join("\n"),'">i</span>\n </label>\n <input type="range" id="tab-offset" min="').concat(0,'" max="').concat(20,'" step="1">\n <span id="tab-offset-value"></span>\n </div>\n </div>\n </div>\n\n <div class="debugger-section scroll-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>Scroll Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content scroll-settings-content">\n <div class="control-row">\n <label for="scroll-enabled">\n Enable Scroll Prediction\n <span class="info-icon" title="').concat(["Scroll Prediction","━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Enables predictive scrolling based on mouse","position and scroll direction.","","When enabled, calculates scroll direction from","mouse movement and triggers callbacks for","elements that intersect the predicted path.","","Property: enableScrollPrediction"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="scroll-enabled">\n </div>\n <div class="control-row">\n <label for="scroll-margin">\n Scroll Margin\n <span class="info-icon" title="').concat(["Scroll Margin","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sets the pixel distance to check from the","mouse position in the scroll direction.","","Higher values check further ahead, allowing","earlier detection of elements that will come","into view during scrolling.","","Property: scrollMargin"].join("\n"),'">i</span>\n </label>\n <input type="range" id="scroll-margin" min="').concat(30,'" max="').concat(300,'" step="10">\n <span id="scroll-margin-value"></span>\n </div>\n </div>\n\n <div class="debugger-section general-settings-section">\n <div class="debugger-section-header collapsible">\n <h3>General Settings</h3>\n <button class="section-minimize-button">-</button>\n </div>\n <div class="debugger-section-content general-settings-content">\n <div class="control-row">\n <label for="toggle-name-tags">\n Show Name Tags\n <span class="info-icon" title="').concat(["Visual Debug Name Tags","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","When enabled: Displays name tags over","each registered element in debug mode.","","Property: debuggerSettings.showNameTags"].join("\n"),'">i</span>\n </label>\n <input type="checkbox" id="toggle-name-tags">\n </div>\n </div>\n </div>\n </div>\n\n <div class="debugger-section debugger-elements">\n <div class="debugger-section-header elements-list-header">\n <h3>Elements <span id="element-count"></span> <span id="callback-count"></span></h3>\n <div class="header-controls">\n <div class="sort-control-container">\n <button class="sort-button" title="Change element list sort order">\n ').concat('<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"></polygon></svg>','\n </button>\n <div id="sort-options-popup">\n <button\n data-sort="visibility"\n title="').concat(["Sort by Visibility","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sorts elements by their viewport visibility","(visible elements first), with a secondary","sort by their order in the document.","","Property: debuggerSettings.sortElementList","Value: 'visibility'"].join("\n"),'"\n>\n Visibility\n</button>\n<button\n data-sort="documentOrder"\n title="').concat(["Sort by Document Order","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sorts elements based on their order of","appearance in the document's structure","(matching the HTML source).","","Property: debuggerSettings.sortElementList","Value: 'documentOrder'"].join("\n"),'"\n>\n Document Order\n</button>\n<button\n data-sort="insertionOrder"\n title="').concat(["Sort by Insertion Order","━━━━━━━━━━━━━━━━━━━━━━━━━━━━━","Sorts elements based on the order they","were registered with the ForesightManager.","","Property: debuggerSettings.sortElementList","Value: 'insertionOrder'"].join("\n"),'"\n>\n Insertion Order\n</button>\n </div>\n </div>\n </div>\n </div>\n <div class="debugger-section-content element-list">\n <div id="element-list-items-container">\n </div>\n </div>\n </div>\n '),t},t.prototype.getStyles=function(){return'\n #debug-controls {\n position: fixed; bottom: 10px; right: 10px;\n background-color: rgba(0, 0, 0, 0.90); color: white; padding: 12px;\n border-radius: 5px; font-family: Arial, sans-serif; font-size: 13px;\n z-index: 10001; pointer-events: auto; display: flex; flex-direction: column; gap: 8px;\n width: 400px;\n transition: width 0.3s ease, height 0.3s ease;\n }\n #debug-controls.minimized {\n width: 220px;\n overflow: hidden;\n padding: 12px 0; \n }\n #debug-controls.minimized .debugger-title-container {\n justify-content: flex-start; \n padding-left: 10px; \n padding-right: 10px;\n gap: 10px; \n }\n #debug-controls.minimized .debugger-title-container h2 {\n display: inline;\n font-size: 14px;\n margin: 0;\n white-space: nowrap;\n }\n #debug-controls.minimized .info-icon {\n display: none;\n }\n\n #element-count,#callback-count {\n font-size: 12px;\n color: #9e9e9e;\n }\n\n .debugger-title-container {\n display: flex;\n align-items: center;\n justify-content: space-between; \n padding: 0 0px; \n }\n .title-group { \n display: flex;\n align-items: center;\n gap: 8px; \n\n }\n .minimize-button {\n background: none; border: none; color: white;\n font-size: 22px; cursor: pointer;\n line-height: 1;\n }\n .debugger-title-container h2 { margin: 0; font-size: 15px; }\n\n .copy-settings-button {\n background: none; border: none; color: white;\n cursor: pointer; padding: 0;\n display: flex; align-items: center; justify-content: center;\n }\n .copy-settings-button svg {\n width: 16px; height: 16px;\n stroke: white;\n }\n\n .all-settings-sections-container {\n display: flex;\n flex-direction: column;\n gap: 8px;\n }\n\n .debugger-section-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-top: 5px;\n margin-bottom: 2px;\n padding-bottom: 2px;\n border-bottom: 1px solid #444;\n }\n .debugger-section-header.collapsible {\n cursor: pointer;\n }\n .debugger-section-header h3 {\n margin: 0;\n font-size: 14px;\n font-weight: bold;\n color: #b0c4de;\n flex-grow: 1;\n }\n\n .section-minimize-button {\n background: none;\n border: none;\n color: white;\n font-size: 18px;\n cursor: pointer;\n padding: 0;\n line-height: 1;\n }\n\n #debug-controls .control-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n }\n #debug-controls label {\n display: flex;\n align-items: center;\n gap: 5px;\n cursor: pointer;\n }\n #debug-controls .control-row:has(input[type="checkbox"]) label {\n flex-grow: 1;\n }\n #debug-controls .control-row input[type="checkbox"] {\n appearance: none; -webkit-appearance: none; -moz-appearance: none;\n position: relative; width: 40px; height: 18px;\n background-color: #555; border-radius: 10px; cursor: pointer;\n outline: none; transition: background-color 0.2s ease;\n vertical-align: middle; flex-shrink: 0; margin: 0;\n }\n #debug-controls .control-row input[type="checkbox"]::before {\n content: ""; position: absolute; width: 14px; height: 14px;\n border-radius: 50%; background-color: white; top: 2px; left: 2px;\n transition: transform 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.4);\n }\n #debug-controls .control-row input[type="checkbox"]:checked {\n background-color: #b0c4de;\n }\n #debug-controls .control-row input[type="checkbox"]:checked::before {\n transform: translateX(22px);\n }\n #debug-controls .control-row:has(input[type="range"]) label {\n flex-basis: 170px; flex-shrink: 0;\n }\n #debug-controls input[type="range"] {\n flex-grow: 1; margin: 0; cursor: pointer; -webkit-appearance: none;\n appearance: none; background: transparent; height: 18px; vertical-align: middle;\n }\n #debug-controls input[type="range"]::-webkit-slider-runnable-track {\n height: 6px; background: #555; border-radius: 3px;\n }\n #debug-controls input[type="range"]::-moz-range-track {\n height: 6px; background: #555; border-radius: 3px;\n }\n #debug-controls input[type="range"]::-webkit-slider-thumb {\n -webkit-appearance: none; appearance: none; margin-top: -5px;\n background: #b0c4de; height: 16px; width: 16px;\n border-radius: 50%; border: 1px solid #333;\n }\n #debug-controls input[type="range"]::-moz-range-thumb {\n background: #b0c4de; height: 16px; width: 16px;\n border-radius: 50%; border: 1px solid #333; border: none;\n }\n #debug-controls .control-row:has(input[type="range"]) span:not(.info-icon) {\n width: 55px; min-width: 55px; text-align: right; flex-shrink: 0;\n }\n .info-icon {\n display: inline-flex; align-items: center; justify-content: center;\n width: 16px; height: 16px; border-radius: 50%;\n background-color: #555; color: white; font-size: 10px;\n font-style: italic; font-weight: bold; font-family: \'Georgia\', serif;\n cursor: help; user-select: none; flex-shrink: 0;\n }\n .debugger-section {\n display: flex; flex-direction: column; gap: 6px;\n }\n .debugger-section-content {\n display: none; flex-direction: column; gap: 8px;\n }\n\n /* Element List Styles */\n .elements-list-header { cursor: default; }\n .header-controls {\n display: flex;\n align-items: center;\n gap: 8px;\n }\n .sort-control-container {\n position: relative;\n }\n .sort-button {\n background: none; border: none; color: white; cursor: pointer;\n padding: 0; display: flex; align-items: center; justify-content: center;\n }\n .sort-button svg {\n width: 16px; height: 16px; stroke: #b0c4de; transition: stroke 0.2s;\n }\n .sort-button:hover svg { stroke: white; }\n \n #sort-options-popup {\n position: absolute;\n bottom: calc(100% + 5px);\n right: -5px;\n z-index: 10;\n display: none;\n flex-direction: column;\n gap: 4px;\n background-color: #3a3a3a;\n border: 1px solid #555;\n border-radius: 4px;\n padding: 3px;\n width: 200px;\n box-shadow: 0 4px 8px rgba(0,0,0,0.3);\n }\n #sort-options-popup.active {\n display: flex;\n }\n #sort-options-popup button {\n background: none; border: none; color: #ccc;\n font-size: 12px; text-align: left; padding: 5px 8px;\n cursor: pointer; border-radius: 3px;\n transition: background-color 0.2s, color 0.2s;\n display: flex;\n align-items: center;\n height: 26px;\n }\n #sort-options-popup button:hover {\n background-color: #555;\n color: white;\n }\n #sort-options-popup button.active-sort-option {\n color: #b0c4de;\n font-weight: bold;\n }\n #sort-options-popup button.active-sort-option::before {\n content: \'✓\';\n margin-right: 6px;\n width: 10px;\n }\n #sort-options-popup button::before {\n content: \'\';\n margin-right: 6px;\n width: 10px;\n }\n\n .element-list { /* Scroll container */\n min-height: '.concat(237,"px;\n max-height: ").concat(237,"px; \n overflow-y: auto;\n background-color: rgba(20, 20, 20, 0.5);\n border-radius: 3px;\n padding: 0;\n display: flex;\n }\n\n /* Modern Scrollbar Styling */\n .element-list::-webkit-scrollbar { width: 8px; }\n .element-list::-webkit-scrollbar-track { background: rgba(30, 30, 30, 0.5); border-radius: 4px; }\n .element-list::-webkit-scrollbar-thumb { background-color: rgba(176, 196, 222, 0.5); border-radius: 4px; border: 2px solid rgba(0, 0, 0, 0.2); }\n .element-list::-webkit-scrollbar-thumb:hover { background-color: rgba(176, 196, 222, 0.7); }\n .element-list { scrollbar-width: thin; scrollbar-color: rgba(176, 196, 222, 0.5) rgba(30, 30, 30, 0.5); }\n\n #element-list-items-container { \n display: flex;\n flex-wrap: wrap;\n gap: ").concat(3,"px;\n padding: ").concat(6,"px;\n min-height: ").concat(225,"px;\n box-sizing: border-box;\n align-content: flex-start;\n }\n #element-list-items-container > em {\n flex-basis: 100%;\n text-align: center;\n padding: 10px 0;\n font-style: italic;\n color: #ccc;\n font-size: 12px;\n }\n .element-list-item {\n flex-basis: calc((100% - (").concat(0," * ").concat(3,"px)) / ").concat(1,");\n flex-grow: 0;\n flex-shrink: 0;\n height: ").concat(35,"px;\n box-sizing: border-box;\n padding: 3px 5px;\n border-radius: 2px;\n display: flex;\n align-items: center;\n gap: 5px;\n background-color: rgba(50,50,50,0.7);\n transition: background-color 0.2s ease, opacity 0.2s ease;\n font-size: 11px; \n overflow: hidden;\n }\n \n /* Viewport intersection styling */\n .element-list-item.not-in-viewport { opacity: 0.4; }\n \n .element-list-item .element-name {\n flex-grow: 1;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n font-size: 12px; \n font-weight: bold;\n }\n .element-list-item .intersecting-indicator {\n font-size: 12px;\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 16px;\n height: 16px;\n }\n .element-list-item .hit-behavior,\n .element-list-item .hit-slop {\n font-size: 10px; \n color: #b0b0b0;\n padding: 2px 5px; \n border-radius: 3px; \n background-color: rgba(0,0,0,0.2);\n flex-shrink: 0;\n }\n ")},t}(),z=function(){return window.matchMedia("(pointer: coarse)").matches&&navigator.maxTouchPoints>0};function L(t,e,n){var i=t.expandedOverlay,o=t.nameLabel,r=e.elementBounds.expandedRect,s=r.right-r.left,a=r.bottom-r.top;i.style.width="".concat(s,"px"),i.style.height="".concat(a,"px"),i.style.transform="translate3d(".concat(r.left,"px, ").concat(r.top,"px, 0)"),i.style.display="block",o.textContent=e.name,""!==e.name&&n?(o.style.display="block",o.style.transform="translate3d(".concat(r.left,"px, ").concat(r.top-25,"px, 0)")):o.style.display="none"}var R=class{static intersect(t,e){const n=Math.max(t.left,e.left),i=Math.min(t.right,e.right),o=Math.max(t.top,e.top),r=Math.min(t.bottom,e.bottom),s=Math.max(0,i-n),a=Math.max(0,r-o);return new DOMRect(n,o,s,a)}static clip(t,e){const n={...t.toJSON(),top:t.top+e.top,left:t.left+e.left,bottom:t.bottom-e.bottom,right:t.right-e.right};return n.width=n.right-n.left,n.height=n.bottom-n.top,n}static clipOffsets(t,e){return{top:e.top-t.top,left:e.left-t.left,bottom:t.bottom-e.bottom,right:t.right-e.right}}static equals(t,e){return null==t||null==e?t===e:t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}static sizeEqual(t,e){return Math.round(t.width)===Math.round(e.width)&&Math.round(t.height)===Math.round(e.height)}};function D(t,e){const n=Math.max(t.width,3),i=Math.max(t.height,3),o=t.top-e.top- -1,r=t.left-e.left- -1,s=e.right-t.left-n- -1,a=e.bottom-t.top-i- -1;return`${-Math.round(o)}px ${-Math.round(s)}px ${-Math.round(a)}px ${-Math.round(r)}px`}var B=[...Array.from({length:1e3},((t,e)=>e/1e3)),1],H=class{constructor(t,e,n){this.#t=e,this.#e=n,this.#n=n.clientRect,this.#i(t)}#t;#o=void 0;#e;#n;#r=void 0;get visibleRect(){const t=this.#e.clip;return t?R.clip(this.#n,t):this.#n}get isIntersecting(){const{width:t,height:e}=this.visibleRect;return t>0&&e>0}#i(t){const{root:e,rootBounds:n}=this.#e,{visibleRect:i}=this;this.#o?.disconnect(),this.#o=new IntersectionObserver(this.#s,{root:e,rootMargin:D(i,n),threshold:B}),this.#o.observe(t)}#s=t=>{if(!this.#o)return;const e=t[t.length-1];if(e){const{intersectionRatio:t,boundingClientRect:n}=e,i=this.#n;this.#n=n;const o=this.#r,r=!R.equals(n,i);if(t!==this.#r||r){const i=this.#e.rootBounds,s=R.intersect(n,i),a=s.width>0&&s.height>0;if(!a)return;this.#r=t,(null!=o||r)&&(this.#t(new N(e.target,n,e.intersectionRect,a,i),this),this.#i(e.target))}}};disconnect(){this.#o?.disconnect()}},N=class{constructor(t,e,n,i,o){this.target=t,this.boundingClientRect=e,this.intersectionRect=n,this.isIntersecting=i,this.rootBounds=o}},V=class{constructor(t,e){const n=function(t){return!t||function(t){return t.nodeType===Node.DOCUMENT_NODE}(t)?t?.defaultView??window:t}(t);if(function(t){return _(t)&&t.nodeType===Node.ELEMENT_NODE}(n)){const t=n.ownerDocument??document;this.rootBounds=n.getBoundingClientRect(),this.#a=new ResizeObserver((t=>{for(const n of t){const[{inlineSize:t,blockSize:i}]=n.borderBoxSize;if(R.sizeEqual(this.rootBounds,{width:t,height:i}))continue;const o=n.target.getBoundingClientRect();this.rootBounds=o,e(o,this)}})),this.#a.observe(n),t.addEventListener("scroll",(t=>{t.target&&t.target!==n&&_(t.target)&&t.target.contains(n)&&(this.rootBounds=n.getBoundingClientRect(),e(this.rootBounds,this))}),{capture:!0,passive:!0,signal:this.#l.signal})}else{const t=n.visualViewport??n;this.rootBounds=A(n);const i=()=>{const t=A(n);R.equals(this.rootBounds,t)||(this.rootBounds=t,e(t,this))};t.addEventListener("resize",i,{signal:this.#l.signal})}}#a;#l=new AbortController;rootBounds;disconnect(){this.#a?.disconnect(),this.#l.abort()}};function A(t){const e=t.visualViewport?.width??t.innerWidth,n=t.visualViewport?.height??t.innerHeight;return new DOMRect(0,0,e,n)}function _(t){return"nodeType"in t}var q=class{constructor(t,e){this.#e=e,this.#t=e=>{const n=[];for(const t of e){const e=this.intersections.get(t.target);this.intersections.set(t.target,t),e?.isIntersecting===t.isIntersecting&&R.equals(e?.intersectionRect,t.intersectionRect)||n.push(t)}n.length>0&&t(n,this)}}#t;#c=new Map;#e;intersections=new WeakMap;observe(t){const e=t.ownerDocument;if(!e)return;let n=this.#c.get(e);n||(n=new IntersectionObserver(this.#t,{...this.#e,threshold:B}),this.#c.set(e,n)),n.observe(t)}unobserve(t){const e=t.ownerDocument;if(!e)return;const n=this.#c.get(e);n&&(n.unobserve(t),this.intersections.delete(t))}disconnect(){for(const t of this.#c.values())t.disconnect();this.#c.clear()}},F=class{constructor(t,e){this.#t=t,this.#e=e,this.#d=new V(e?.root,this.#u),this.#h=new q(this.#g,e),this.#a=new ResizeObserver(this.#p)}#t;#e;#b=new Map;#a;#m=new WeakMap;#d;#h;observe(t){this.#h.observe(t)}unobserve(t){t?(this.#b.get(t)?.disconnect(),this.#h.unobserve(t)):this.disconnect()}disconnect(){for(const t of this.#b.values())t.disconnect();this.#a.disconnect(),this.#d.disconnect(),this.#h.disconnect()}#f(t){const e=[];for(const n of t){const{target:t}=n;W(n,this.#m.get(t))||(this.#m.set(t,n),e.push(n))}e.length>0&&this.#t(e)}#u=t=>{const e=[];for(const[n]of this.#b){const i=n.getBoundingClientRect(),o=this.#v(n,i);e.push(new U(n,i,o.visibleRect,o.isIntersecting,t))}this.#f(e)};#v(t,e){const n=this.#h;this.#b.get(t)?.disconnect();const i=new H(t,this.#y,{clientRect:e,root:this.#e?.root,rootBounds:this.#d.rootBounds,get clip(){const e=n.intersections.get(t);if(!e)return;const{intersectionRect:i,boundingClientRect:o}=e;return R.clipOffsets(o,i)}});return this.#b.set(t,i),i}#g=t=>{const e=[];for(const n of t){const{target:t,isIntersecting:i,boundingClientRect:o}=n;i?(this.#v(t,o),this.#a.observe(t)):(this.#b.get(t)?.disconnect(),this.#b.delete(t),this.#a.unobserve(t));const r=this.#b.get(t);e.push(new U(t,o,r?.visibleRect??n.intersectionRect,i,this.#d.rootBounds))}this.#f(e)};#y=(t,e)=>{this.#f([new U(t.target,t.boundingClientRect,e.visibleRect,t.isIntersecting,this.#d.rootBounds)])};#p=t=>{const e=[];for(const n of t){const{target:t,borderBoxSize:i}=n,o=this.#m.get(t);if(o){const[{inlineSize:t,blockSize:e}]=i;if(R.sizeEqual(o.boundingClientRect,{width:t,height:e}))continue}const r=t.getBoundingClientRect(),s=this.#v(t,r);e.push(new U(t,r,s.visibleRect,this.#h.intersections.get(t)?.isIntersecting??!1,this.#d.rootBounds))}this.#f(e)}},U=class{constructor(t,e,n,i,o){this.target=t,this.boundingClientRect=e,this.intersectionRect=n,this.isIntersecting=i,this.rootBounds=o}};function W(t,e){return null!=e&&(t.target===e.target&&t.isIntersecting===e.isIntersecting&&R.equals(t.boundingClientRect,e.boundingClientRect)&&R.equals(t.intersectionRect,e.intersectionRect))}var G=function(){function t(t){var e=this;this.callbackAnimations=new Map,this.debugElementOverlays=new Map,this.predictedMouseIndicator=null,this.mouseTrajectoryLine=null,this.scrollTrajectoryLine=null,this.animationPositionObserver=null,this.handleAnimationPositionChange=function(t){for(var n=0,i=t;n<i.length;n++){var o=i[n],r=e.callbackAnimations.get(o.target);if(r){var s=o.boundingClientRect,a=r.hitSlop,l=r.overlay,c=s.left-a.left,d=s.top-a.top,u=s.width+a.left+a.right,h=s.height+a.top+a.bottom;l.style.transform="translate3d(".concat(c,"px, ").concat(d,"px, 0)"),l.style.width="".concat(u,"px"),l.style.height="".concat(h,"px")}}},this.foresightManagerInstance=t}return t.prototype._setupDOM=function(){this.shadowHost||(this.shadowHost=M("div",document.body,{id:"jsforesight-debugger-shadow-host"}),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"}),this.debugContainer=M("div",this.shadowRoot,{id:"jsforesight-debug-container"}),this.predictedMouseIndicator=M("div",this.debugContainer,{className:"jsforesight-mouse-predicted"}),this.mouseTrajectoryLine=M("div",this.debugContainer,{className:"jsforesight-trajectory-line"}),this.scrollTrajectoryLine=M("div",this.debugContainer,{className:"jsforesight-scroll-trajectory-line"}),this.controlPanel=I.initialize(this.foresightManagerInstance,this.shadowRoot,this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings),O(K,this.shadowRoot,"screen-visuals"),this.animationPositionObserver=new F(this.handleAnimationPositionChange))},Object.defineProperty(t,"isInitiated",{get:function(){return!!t.debuggerInstance},enumerable:!1,configurable:!0}),t.initialize=function(e,n){if(document.querySelectorAll("#jsforesight-debugger-shadow-host").forEach((function(t){return t.remove()})),"undefined"==typeof window||z())return null;t.isInitiated||(t.debuggerInstance=new t(e));var i=t.debuggerInstance;return i.shadowHost||i._setupDOM(),i.updateMouseTrajectoryVisuals(n,e.getManagerData.globalSettings.enableMousePrediction),i},t.prototype.createElementOverlays=function(t){var e={expandedOverlay:M("div",this.debugContainer,{className:"jsforesight-expanded-overlay",data:t.name}),nameLabel:M("div",this.debugContainer,{className:"jsforesight-name-label"})};return this.debugElementOverlays.set(t.element,e),e},t.prototype.createOrUpdateElementOverlay=function(t){var e;if(this.debugContainer&&this.shadowRoot){var n=this.debugElementOverlays.get(t.element);n||(n=this.createElementOverlays(t)),L(n,t,null!==(e=this.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==e?e:k)}},t.prototype.toggleNameTagVisibility=function(){var t=this;this.foresightManagerInstance.registeredElements.forEach((function(e){var n,i=t.debugElementOverlays.get(e.element);i&&L(i,e,null!==(n=t.foresightManagerInstance.getManagerData.globalSettings.debuggerSettings.showNameTags)&&void 0!==n?n:k)}))},t.prototype.removeElement=function(t){var e;this.removeElementOverlay(t),null===(e=this.controlPanel)||void 0===e||e.removeElementFromList(t)},t.prototype.removeElementOverlay=function(t){var e=this.debugElementOverlays.get(t.element);e&&(e.expandedOverlay.remove(),e.nameLabel.remove(),this.debugElementOverlays.delete(t.element))},t.prototype.addElement=function(t,e){void 0===e&&(e=!0),this.createOrUpdateElementOverlay(t),this.controlPanel.addElementToList(t,e)},t.prototype.updateMouseTrajectoryVisuals=function(t,e){if(this.shadowRoot&&this.debugContainer&&this.predictedMouseIndicator&&this.mouseTrajectoryLine){var n=t.predictedPoint,i=t.currentPoint;if(this.predictedMouseIndicator.style.transform="translate3d(".concat(n.x,"px, ").concat(n.y,"px, 0) translate3d(-50%, -50%, 0)"),this.predictedMouseIndicator.style.display=e?"block":"none",0!==n.x||0!==n.y)if(e){var o=n.x-i.x,r=n.y-i.y,s=Math.sqrt(o*o+r*r),a=180*Math.atan2(r,o)/Math.PI;this.mouseTrajectoryLine.style.transform="translate3d(".concat(i.x,"px, ").concat(i.y,"px, 0) rotate(").concat(a,"deg)"),this.mouseTrajectoryLine.style.width="".concat(s,"px"),this.mouseTrajectoryLine.style.display="block"}else this.mouseTrajectoryLine.style.display="none";else this.predictedMouseIndicator.style.display="none"}},t.prototype.updateScrollTrajectoryVisuals=function(t,e){if(this.scrollTrajectoryLine){var n=e.x-t.x,i=e.y-t.y,o=Math.sqrt(n*n+i*i),r=180*Math.atan2(i,n)/Math.PI;this.scrollTrajectoryLine.style.transform="translate3d(".concat(t.x,"px, ").concat(t.y,"px, 0) rotate(").concat(r,"deg)"),this.scrollTrajectoryLine.style.width="".concat(o,"px"),this.scrollTrajectoryLine.style.display="block"}},t.prototype.hideScrollTrajectoryVisuals=function(){this.scrollTrajectoryLine&&(this.scrollTrajectoryLine.style.display="none")},t.prototype.updateControlsState=function(t){var e;null===(e=this.controlPanel)||void 0===e||e.updateControlsState(t)},t.prototype.updateElementVisibilityStatus=function(t){var e;null===(e=this.controlPanel)||void 0===e||e.updateElementVisibilityStatus(t)},t.prototype.removeElementFromList=function(t){var e;null===(e=this.controlPanel)||void 0===e||e.removeElementFromList(t)},t.prototype.showCallbackAnimation=function(t){var e,n,i=this,o=t.element,r=t.elementBounds,s=this.callbackAnimations.get(o);s&&(clearTimeout(s.timeoutId),s.overlay.remove(),null===(e=this.animationPositionObserver)||void 0===e||e.unobserve(o),this.callbackAnimations.delete(o));var a=M("div",this.debugContainer,{className:"jsforesight-callback-indicator"}),l=r.expandedRect,c=l.left,d=l.top,u=l.right-c,h=l.bottom-d;a.style.display="block",a.style.transform="translate3d(".concat(c,"px, ").concat(d,"px, 0)"),a.style.width="".concat(u,"px"),a.style.height="".concat(h,"px"),a.classList.add("animate");var g=setTimeout((function(){var t;a.remove(),i.callbackAnimations.delete(o),null===(t=i.animationPositionObserver)||void 0===t||t.unobserve(o)}),500);this.callbackAnimations.set(o,{hitSlop:t.elementBounds.hitSlop,overlay:a,timeoutId:g}),null===(n=this.animationPositionObserver)||void 0===n||n.observe(o)},t.prototype.cleanup=function(){var t,e;null===(t=this.controlPanel)||void 0===t||t.cleanup(),null===(e=this.shadowHost)||void 0===e||e.remove(),this.debugElementOverlays.clear(),this.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.predictedMouseIndicator=null,this.mouseTrajectoryLine=null,this.scrollTrajectoryLine=null,this.controlPanel=null},t}(),K='\n #jsforesight-debug-container { \n position: fixed; top: 0; left: 0; width: 100%; height: 100%;\n pointer-events: none; z-index: 9999;\n }\n\n .jsforesight-expanded-overlay, \n .jsforesight-name-label, \n .jsforesight-callback-indicator,\n .jsforesight-mouse-predicted,\n .jsforesight-scroll-trajectory-line,\n .jsforesight-trajectory-line {\n position: absolute;\n top: 0;\n left: 0;\n will-change: transform; \n }\n .jsforesight-expanded-overlay {\n border: 1px dashed rgba(100, 116, 139, 0.4);\n background-color: rgba(100, 116, 139, 0.05);\n box-sizing: border-box;\n border-radius: 8px;\n }\n .jsforesight-mouse-predicted {\n width: 20px;\n height: 20px;\n border-radius: 50%;\n border: 2px solid #6b98e1;\n background-color: rgba(176, 196, 222, 0.3);\n z-index: 10000;\n /* transform is now set dynamically via JS for performance */\n }\n .jsforesight-trajectory-line {\n height: 2px;\n background-color: #6b98e1;\n transform-origin: left center;\n z-index: 9999;\n border-radius: 1px;\n /* width and transform are set dynamically via JS for performance */\n }\n .jsforesight-name-label {\n background-color: rgba(27, 31, 35, 0.85);\n backdrop-filter: blur(4px);\n color: white;\n padding: 4px 8px;\n font-size: 11px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";\n border-radius: 4px;\n z-index: 10001;\n white-space: nowrap;\n pointer-events: none;\n }\n .jsforesight-callback-indicator {\n border: 4px solid oklch(65% 0.22 280); \n border-radius: 8px;\n box-sizing: border-box;\n pointer-events: none;\n opacity: 0;\n z-index: 10002;\n display: none; \n }\n .jsforesight-callback-indicator.animate {\n animation: jsforesight-callback-pulse 0.5s ease-out forwards;\n }\n \n .jsforesight-scroll-trajectory-line {\n height: 2px;\n background: repeating-linear-gradient(\n 90deg,\n oklch(68% 0.18 145) 0px,\n oklch(68% 0.18 145) 6px,\n transparent 6px,\n transparent 10px\n );\n transform-origin: left center;\n z-index: 9999;\n border-radius: 1px;\n display: none;\n animation: scroll-dash-flow 1.8s linear infinite;\n position: relative;\n }\n\n .jsforesight-scroll-trajectory-line::after {\n content: \'\';\n position: absolute;\n right: -2px;\n top: 50%;\n transform: translateY(-50%);\n width: 6px;\n height: 6px;\n background: oklch(68% 0.18 145);\n border-radius: 50%;\n animation: scroll-escape-squeeze 2.2s ease-in-out infinite;\n }\n\n @keyframes scroll-dash-flow {\n 0% { background-position: 0px 0px; }\n 100% { background-position: 10px 0px; }\n }\n\n @keyframes scroll-escape-squeeze {\n 0%, 100% { \n transform: translateY(-50%) scale(1);\n right: -2px;\n }\n 25% {\n transform: translateY(-50%) scaleX(1.3) scaleY(0.7);\n right: -3px;\n }\n 50% {\n transform: translateY(-50%) scaleX(0.8) scaleY(1.2);\n right: -1px;\n }\n 75% {\n transform: translateY(-50%) scaleX(1.2) scaleY(0.8);\n right: -3px;\n }\n }\n\n \n @keyframes jsforesight-callback-pulse {\n 0% {\n opacity: 1;\n box-shadow: 0 0 15px oklch(65% 0.22 280 / 0.7);\n }\n 100% {\n opacity: 0;\n box-shadow: 0 0 25px oklch(65% 0.22 280 / 0);\n }\n }\n ';function Y(t,e,n,i,o){return i&&(t<e?console.warn('ForesightJS: "'.concat(o,'" value ').concat(t," is below minimum bound ").concat(e,", clamping to ").concat(e)):t>n&&console.warn('ForesightJS: "'.concat(o,'" value ').concat(t," is above maximum bound ").concat(n,", clamping to ").concat(n))),Math.min(Math.max(t,e),n)}function J(t,e,n){var i=0,o=1,r=e.x-t.x,s=e.y-t.y,a=function(t,e){if(0===t){if(e<0)return!1}else{var n=e/t;if(t<0){if(n>o)return!1;n>i&&(i=n)}else{if(n<i)return!1;n<o&&(o=n)}}return!0};return!!a(-r,t.x-n.left)&&(!!a(r,n.right-t.x)&&(!!a(-s,t.y-n.top)&&(!!a(s,n.bottom-t.y)&&i<=o)))}function X(t,e){if("number"==typeof t){var n=Y(t,0,w,e,"hitslop");return{top:n,left:n,right:n,bottom:n}}return{top:Y(t.top,0,w,e,"hitslop - top"),left:Y(t.left,0,w,e,"hitslop - left"),right:Y(t.right,0,w,e,"hitslop - right"),bottom:Y(t.bottom,0,w,e,"hitslop - bottom")}}function $(t,e){return{left:t.left-e.left,right:t.right+e.right,top:t.top-e.top,bottom:t.bottom+e.bottom}}function Q(t,e){return t&&e?t.left===e.left&&t.right===e.right&&t.top===e.top&&t.bottom===e.bottom:t===e}function Z(t,e){return t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom}function tt(t,e){return void 0!==t&&e!==t}var et=function(){function e(){var t=this;this.elements=new Map,this.isSetup=!1,this.debugger=null,this._globalCallbackHits={mouse:{hover:0,trajectory:0},tab:{forwards:0,reverse:0},scroll:{down:0,left:0,right:0,up:0},total:0},this._globalSettings={debug:false,enableMousePrediction:true,enableScrollPrediction:true,positionHistorySize:8,trajectoryPredictionTime:120,scrollMargin:150,defaultHitSlop:{top:0,left:0,right:0,bottom:0},resizeScrollThrottleDelay:0,debuggerSettings:{isControlPanelDefaultMinimized:C,showNameTags:k,sortElementList:"visibility"},enableTabPrediction:true,tabOffset:2,onAnyCallbackFired:function(t,e){}},this.trajectoryPositions={positions:[],currentPoint:{x:0,y:0},predictedPoint:{x:0,y:0}},this.tabbableElementsCache=[],this.lastFocusedIndex=null,this.predictedScrollPoint=null,this.scrollDirection=null,this.domObserver=null,this.positionObserver=null,this.lastKeyDown=null,this.globalListenersController=null,this.handleMouseMove=function(e){t.updatePointerState(e),t.elements.forEach((function(e){e.isIntersectingWithViewport&&(e.unregisterOnCallback?t.handleSingleCallbackInteraction(e):t.handleMultiCallbackInteraction(e))})),t.debugger&&(t.debugger.hideScrollTrajectoryVisuals(),t.debugger.updateMouseTrajectoryVisuals(t.trajectoryPositions,t._globalSettings.enableMousePrediction))},this.handleDomMutations=function(e){e.length&&(t.tabbableElementsCache=[],t.lastFocusedIndex=null);for(var n=0,i=e;n<i.length;n++){var o=i[n];if("childList"===o.type&&o.removedNodes.length>0)for(var r=0,s=Array.from(t.elements.keys());r<s.length;r++){var a=s[r];a.isConnected||t.unregister(a)}}},this.handleKeyDown=function(e){"Tab"===e.key&&(t.lastKeyDown=e)},this.handleFocusIn=function(e){if(t.lastKeyDown&&t._globalSettings.enableTabPrediction){var n=e.target;if(n instanceof HTMLElement){t.tabbableElementsCache.length||(t.tabbableElementsCache=v(document.documentElement),t._globalSettings.debug&&console.log("ForesightJS: Recomputed tabbable elements cache because of DOM change"));var i=t.lastKeyDown.shiftKey,o=function(t,e,n,i){if(null!==e){var o=t?e-1:e+1;if(o>=0&&o<n.length&&n[o]===i)return o}return n.findIndex((function(t){return t===i}))}(i,t.lastFocusedIndex,t.tabbableElementsCache,n);t.lastFocusedIndex=o,t.lastKeyDown=null;for(var r=[],s=0;s<=t._globalSettings.tabOffset;s++)if(i){var a=t.tabbableElementsCache[o-s];t.elements.has(a)&&r.push(a)}else{a=t.tabbableElementsCache[o+s];t.elements.has(a)&&r.push(a)}r.forEach((function(e){t.callCallback(t.elements.get(e),{kind:"tab",subType:i?"reverse":"forwards"})}))}}},this.handlePositionChange=function(e){for(var n,i,o=0,r=e;o<r.length;o++){var s=r[o],a=t.elements.get(s.target);if(a){var l=a.isIntersectingWithViewport,c=s.isIntersecting;a.isIntersectingWithViewport=c,l!==c&&(null===(n=t.debugger)||void 0===n||n.updateElementVisibilityStatus(a)),c?(t.updateElementBounds(s.boundingClientRect,a),t.handleScrollPrefetch(a,s.boundingClientRect)):t._globalSettings.debug&&l&&(null===(i=t.debugger)||void 0===i||i.removeElementOverlay(a))}}t.scrollDirection=null,t.predictedScrollPoint=null}}return e.initialize=function(t){return this.isInitiated||(e.manager=new e),void 0!==t&&e.manager.alterGlobalSettings(t),e.manager},Object.defineProperty(e.prototype,"getManagerData",{get:function(){return{registeredElements:this.elements,globalSettings:this._globalSettings,globalCallbackHits:this._globalCallbackHits}},enumerable:!1,configurable:!0}),Object.defineProperty(e,"isInitiated",{get:function(){return!!e.manager},enumerable:!1,configurable:!0}),Object.defineProperty(e,"instance",{get:function(){return this.initialize()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"registeredElements",{get:function(){return this.elements},enumerable:!1,configurable:!0}),e.prototype.register=function(t){var e,n,i=this,o=t.element,r=t.callback,s=t.hitSlop,a=t.unregisterOnCallback,l=t.name;if(z())return{isTouchDevice:!0,unregister:function(){}};if(this.elements.has(o))return{isTouchDevice:!1,unregister:function(){return i.unregister(o)}};this.isSetup||this.initializeGlobalListeners();var c=s?X(s,this._globalSettings.debug):this._globalSettings.defaultHitSlop,d={element:o,callback:r,callbackHits:{mouse:{hover:0,trajectory:0},tab:{forwards:0,reverse:0},scroll:{down:0,left:0,right:0,up:0},total:0},elementBounds:{originalRect:void 0,expandedRect:{top:0,left:0,right:0,bottom:0},hitSlop:c},isHovering:!1,trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitTime:0,trajectoryHitExpirationTimeoutId:void 0},name:null!==(e=null!=l?l:o.id)&&void 0!==e?e:"",unregisterOnCallback:null==a||a,isIntersectingWithViewport:!0};return this.elements.set(o,d),null===(n=this.positionObserver)||void 0===n||n.observe(o),this.debugger&&this.debugger.addElement(d),{isTouchDevice:!1,unregister:function(){return i.unregister(o)}}},e.prototype.unregister=function(t){var e;if(this.elements.has(t)){var n=this.elements.get(t);(null==n?void 0:n.trajectoryHitData.trajectoryHitExpirationTimeoutId)&&clearTimeout(n.trajectoryHitData.trajectoryHitExpirationTimeoutId),null===(e=this.positionObserver)||void 0===e||e.unobserve(t),this.elements.delete(t),this.debugger&&n&&this.debugger.removeElement(n),0===this.elements.size&&this.isSetup&&this.removeGlobalListeners()}},e.prototype.updateNumericSettings=function(t,e,n,i){return!!tt(t,this._globalSettings[e])&&(this._globalSettings[e]=Y(t,n,i,this._globalSettings.debug,e),!0)},e.prototype.updateBooleanSetting=function(t,e){return!!tt(t,this._globalSettings[e])&&(this._globalSettings[e]=t,!0)},e.prototype.alterGlobalSettings=function(t){var e,n,i,o=this._globalSettings.positionHistorySize,r=this.updateNumericSettings(null==t?void 0:t.positionHistorySize,"positionHistorySize",2,30);r&&this._globalSettings.positionHistorySize<o&&this.trajectoryPositions.positions.length>this._globalSettings.positionHistorySize&&(this.trajectoryPositions.positions=this.trajectoryPositions.positions.slice(this.trajectoryPositions.positions.length-this._globalSettings.positionHistorySize));var s=this.updateNumericSettings(null==t?void 0:t.trajectoryPredictionTime,"trajectoryPredictionTime",10,200),a=this.updateNumericSettings(null==t?void 0:t.scrollMargin,"scrollMargin",30,300),l=this.updateNumericSettings(null==t?void 0:t.tabOffset,"tabOffset",0,20);void 0!==(null==t?void 0:t.resizeScrollThrottleDelay)&&console.warn("resizeScrollThrottleDelay is deprecated and will be removed in V3.0.0 of ForesightJS");var c=this.updateBooleanSetting(null==t?void 0:t.enableMousePrediction,"enableMousePrediction"),d=this.updateBooleanSetting(null==t?void 0:t.enableScrollPrediction,"enableScrollPrediction"),u=this.updateBooleanSetting(null==t?void 0:t.enableTabPrediction,"enableTabPrediction");void 0!==(null==t?void 0:t.onAnyCallbackFired)&&(this._globalSettings.onAnyCallbackFired=t.onAnyCallbackFired);var h=!1;void 0!==(null===(e=null==t?void 0:t.debuggerSettings)||void 0===e?void 0:e.isControlPanelDefaultMinimized)&&(this._globalSettings.debuggerSettings.isControlPanelDefaultMinimized=t.debuggerSettings.isControlPanelDefaultMinimized,h=!0),void 0!==(null===(n=null==t?void 0:t.debuggerSettings)||void 0===n?void 0:n.showNameTags)&&(this._globalSettings.debuggerSettings.showNameTags=t.debuggerSettings.showNameTags,h=!0,this.debugger&&this.debugger.toggleNameTagVisibility()),void 0!==(null===(i=null==t?void 0:t.debuggerSettings)||void 0===i?void 0:i.sortElementList)&&(this._globalSettings.debuggerSettings.sortElementList=t.debuggerSettings.sortElementList,h=!0,this.debugger);var g=!1;if(void 0!==(null==t?void 0:t.defaultHitSlop)){var p=X(t.defaultHitSlop,this._globalSettings.debug);Q(this._globalSettings.defaultHitSlop,p)||(this._globalSettings.defaultHitSlop=p,g=!0,this.forceUpdateAllElementBounds())}var b=!1;void 0!==(null==t?void 0:t.debug)&&this._globalSettings.debug!==t.debug&&"undefined"!=typeof window&&"undefined"!=typeof document&&(this._globalSettings.debug=t.debug,b=!0,this._globalSettings.debug?this.turnOnDebugMode():this.debugger&&(this.debugger.cleanup(),this.debugger=null)),(r||s||l||c||u||d||h||g||a||b)&&this.debugger&&this.debugger.updateControlsState(this._globalSettings)},e.prototype.turnOnDebugMode=function(){var t=this;if(this.debugger)this.debugger.updateControlsState(this._globalSettings);else{this.debugger=G.initialize(e.instance,this.trajectoryPositions);var n=Array.from(this.elements.values());n.forEach((function(e,i){var o,r=i===n.length-1;null===(o=t.debugger)||void 0===o||o.addElement(e,r)}))}},e.prototype.forceUpdateAllElementBounds=function(){var t=this;this.elements.forEach((function(e,n){var i=t.elements.get(n);i&&i.isIntersectingWithViewport&&t.forceUpdateElementBounds(i)}))},e.prototype.updatePointerState=function(e){this.trajectoryPositions.currentPoint={x:e.clientX,y:e.clientY},this.trajectoryPositions.predictedPoint=this._globalSettings.enableMousePrediction?function(t,e,n,i){var o={point:t,time:performance.now()},r=t.x,s=t.y;if(e.push(o),e.length>n&&e.shift(),e.length<2)return{x:r,y:s};var a=e[0],l=e[e.length-1],c=(l.time-a.time)/1e3;if(0===c)return{x:r,y:s};var d=i/1e3;return{x:r+(l.point.x-a.point.x)/c*d,y:s+(l.point.y-a.point.y)/c*d}}(this.trajectoryPositions.currentPoint,this.trajectoryPositions.positions,this._globalSettings.positionHistorySize,this._globalSettings.trajectoryPredictionTime):t({},this.trajectoryPositions.currentPoint)},e.prototype.handleSingleCallbackInteraction=function(t){var e=t.elementBounds.expandedRect;if(this._globalSettings.enableMousePrediction)J(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,e)&&this.callCallback(t,{kind:"mouse",subType:"trajectory"});else if(Z(this.trajectoryPositions.currentPoint,e))return void this.callCallback(t,{kind:"mouse",subType:"hover"})},e.prototype.handleMultiCallbackInteraction=function(e){var n=this,i=e.elementBounds.expandedRect,o=Z(this.trajectoryPositions.currentPoint,i),r=o&&!e.isHovering,s=this._globalSettings.enableMousePrediction&&!o&&!e.trajectoryHitData.isTrajectoryHit&&J(this.trajectoryPositions.currentPoint,this.trajectoryPositions.predictedPoint,i);if((r||s)&&this.callCallback(e,{kind:"mouse",subType:r?"hover":"trajectory"}),o!==e.isHovering||s){var a=t(t({},e),{isHovering:o,trajectoryHitData:t(t({},e.trajectoryHitData),{isTrajectoryHit:s,trajectoryHitTime:s?performance.now():e.trajectoryHitData.trajectoryHitTime})});s&&(a.trajectoryHitData.trajectoryHitExpirationTimeoutId&&clearTimeout(a.trajectoryHitData.trajectoryHitExpirationTimeoutId),a.trajectoryHitData.trajectoryHitExpirationTimeoutId=setTimeout((function(){var t,i=n.elements.get(e.element);i&&i.trajectoryHitData.trajectoryHitTime===a.trajectoryHitData.trajectoryHitTime&&(i.trajectoryHitData.isTrajectoryHit=!1,null===(t=n.debugger)||void 0===t||t.createOrUpdateElementOverlay(i))}),200)),this.elements.set(e.element,a)}},e.prototype.updateHitCounters=function(t,e){switch(e.kind){case"mouse":t.callbackHits.mouse[e.subType]++,this._globalCallbackHits.mouse[e.subType]++;break;case"tab":t.callbackHits.tab[e.subType]++,this._globalCallbackHits.tab[e.subType]++;break;case"scroll":t.callbackHits.scroll[e.subType]++,this._globalCallbackHits.scroll[e.subType]++}t.callbackHits.total++,this._globalCallbackHits.total++},e.prototype.callCallback=function(t,e){t&&(this.updateHitCounters(t,e),t.callback(),this._globalSettings.onAnyCallbackFired(t,this.getManagerData),this.debugger&&this.debugger.showCallbackAnimation(t),t.unregisterOnCallback&&this.unregister(t.element))},e.prototype.forceUpdateElementBounds=function(e){var n=e.element.getBoundingClientRect(),i=$(n,e.elementBounds.hitSlop);if(!Q(i,e.elementBounds.expandedRect)&&(this.elements.set(e.element,t(t({},e),{elementBounds:t(t({},e.elementBounds),{originalRect:n,expandedRect:i})})),this.debugger)){var o=this.elements.get(e.element);o&&this.debugger.createOrUpdateElementOverlay(o)}},e.prototype.updateElementBounds=function(e,n){if(this.elements.set(n.element,t(t({},n),{elementBounds:t(t({},n.elementBounds),{originalRect:e,expandedRect:$(e,n.elementBounds.hitSlop)})})),this.debugger){var i=this.elements.get(n.element);i&&this.debugger.createOrUpdateElementOverlay(i)}},e.prototype.handleScrollPrefetch=function(t,e){var n,i;if(this._globalSettings.enableScrollPrediction){if(!t.elementBounds.originalRect)return;if(this.scrollDirection=null!==(n=this.scrollDirection)&&void 0!==n?n:function(t,e){var n=e.top-t.top,i=e.left-t.left;return n<-1?"down":n>1?"up":i<-1?"right":i>1?"left":"none"}(t.elementBounds.originalRect,e),"none"===this.scrollDirection)return;this.predictedScrollPoint=null!==(i=this.predictedScrollPoint)&&void 0!==i?i:function(t,e,n){var i={x:t.x,y:t.y};switch(e){case"down":i.y+=n;break;case"up":i.y-=n;break;case"left":i.x-=n;break;case"right":i.x+=n}return i}(this.trajectoryPositions.currentPoint,this.scrollDirection,this._globalSettings.scrollMargin),J(this.trajectoryPositions.currentPoint,this.predictedScrollPoint,null==t?void 0:t.elementBounds.expandedRect)&&this.callCallback(t,{kind:"scroll",subType:this.scrollDirection}),this.debugger&&this.debugger.updateScrollTrajectoryVisuals(this.trajectoryPositions.currentPoint,this.predictedScrollPoint)}else Z(this.trajectoryPositions.currentPoint,t.elementBounds.expandedRect)&&this.callCallback(t,{kind:"mouse",subType:"hover"})},e.prototype.initializeGlobalListeners=function(){if(!this.isSetup&&"undefined"!=typeof window&&"undefined"!=typeof document){this.globalListenersController=new AbortController;var t=this.globalListenersController.signal;document.addEventListener("mousemove",this.handleMouseMove,{signal:t}),document.addEventListener("keydown",this.handleKeyDown,{signal:t}),document.addEventListener("focusin",this.handleFocusIn,{signal:t}),this.domObserver=new MutationObserver(this.handleDomMutations),this.domObserver.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1}),this.positionObserver=new F(this.handlePositionChange),this.isSetup=!0}},e.prototype.removeGlobalListeners=function(){var t,e,n;this.isSetup=!1,this.debugger?console.log("ForesightJS: All elements have successfully been unregistered. ForesightJS would typically perform cleanup events now, but these are currently skipped while in debug mode. Observers are cleared up."):(null===(t=this.globalListenersController)||void 0===t||t.abort(),this.globalListenersController=null),null===(e=this.domObserver)||void 0===e||e.disconnect(),this.domObserver=null,null===(n=this.positionObserver)||void 0===n||n.disconnect(),this.positionObserver=null},e}();exports.ForesightManager=et;
23
7
  //# sourceMappingURL=index.js.map