js.foresight 1.1.8 → 2.0.1

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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![npm downloads](https://img.shields.io/npm/dt/js.foresight.svg)](https://www.npmjs.com/package/js.foresight)
6
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
- ForesightJS is an free and open-source JavaScript library that predicts user intent by analyzing mouse movements and trajectories. It allows developers to prefetch data based on user intent instead of the classic on-click or on-hover.
8
+ ForesightJS is a lightweight JavaScript library with full TypeScript support that predicts user intent based on mouse movements and keyboard navigation. By analyzing cursor trajectory and tab sequences, it anticipates which elements a user is likely to interact with, allowing developers to trigger actions before the actual hover or click occurs (for example prefetching).
9
9
 
10
10
  ### [ForesightJS docs (with interactive demo)](https://foresightjs.com/)
11
11
 
@@ -15,44 +15,30 @@ _In the GIF above, [debug mode](https://foresightjs.com/docs/debug) is on. Norma
15
15
  ## Download
16
16
 
17
17
  ```bash
18
+ pnpm add js.foresight
19
+ # or
18
20
  npm install js.foresight
19
21
  # or
20
22
  yarn add js.foresight
21
- # or
22
- pnpm add js.foresight
23
23
  ```
24
24
 
25
- ## Why Use ForesightJS?
25
+ ## Which problems does ForesightJS solve??
26
26
 
27
27
  ### Problem 1: On-Hover Prefetching is Too Late
28
28
 
29
- Traditional hover-based interactions have built-in delays:
30
-
31
- - Prefetching only starts after the user hovers over an element
32
- - The 200-300ms between intent (moving toward a button) and hover is wasted
29
+ Traditional hover-based prefetching only starts after the user hovers over an element. This wastes the 100-200ms between user intent (moving toward a button) and the actual hover event.
33
30
 
34
31
  ### Problem 2: Viewport-Based Prefetching is Wasteful
35
32
 
36
- Many modern frameworks (like Next.js) automatically prefetch resources for all links that enter the viewport:
37
-
38
- - Simply scrolling up and down the Next.js homepage can trigger **1.59MB** of unnecessary prefetch requests
39
- - Every visible link initiates prefetching, regardless of user intent
33
+ Many modern frameworks (like Next.js) automatically prefetch resources for all links that enter the viewport. This means every visible link is getting prefetched even though the user is most likely not going to interact with it. Simply scrolling up and down the Next.js homepage can trigger 1.59MB of unnecessary prefetch requests.
40
34
 
41
- ### The ForesightJS Solution
35
+ ### Problem 3: Routers don't take keyboard users into consideration
42
36
 
43
- ForesightJS solves both problems by:
37
+ Many routers prefetch either based on viewport or hover and leave keyboard users prefetching on click. This means keyboard users get slower page loads since prefetching only happens after they click.
44
38
 
45
- - **Predicting interactions before they happen** based on mouse trajectory analysis
46
- - **Triggering actions only for elements the user is likely to interact with**
47
- - **Starting prefetching 80-150ms earlier** than hover-based solutions
48
- - **Reducing unnecessary requests** compared to viewport-based solutions
49
-
50
- ## Core Features
39
+ ### The ForesightJS Solution
51
40
 
52
- - **Mouse Trajectory Prediction**: Calculates where a user's cursor is heading
53
- - **Expandable Hit Areas**: Custom "hit slop" areas around elements to detect intent earlier
54
- - **Framework Agnostic**: Works with any front-end framework
55
- - **Debug Visualization**: Built-in visual debugger for development
41
+ ForesightJS sits between viewport and hover prefetching. By predicting which element the user will interact with next, it can prefetch before hover without wasting resources like viewport prefetching. To make these predictions, it analyzes mouse movement to predict where the cursor is headed and tracks keyboard navigation by monitoring how many tab stops away the user is from registered elements.
56
42
 
57
43
  ## Basic Usage Example
58
44
 
@@ -98,3 +84,11 @@ ForesightJS can be used bare-bones but also can be configured. For all configura
98
84
  ## Debugging visualization
99
85
 
100
86
  ForesightJS includes a [Visual Debugging](https://foresightjs.com/docs/debugging) system that helps you understand and tune how foresight is working in your application. This is particularly helpful when setting up ForesightJS for the first time or when fine-tuning for specific UI components.
87
+
88
+ ## How does ForesightJS work?
89
+
90
+ ForesightJS analyzes mouse movements and keyboard navigation to predict user intent. For a detailed technical explanation of its prediction algorithms and internal architecture, see the **[Behind the Scenes documentation](https://foresightjs.com/docs/behind-the-scenes)**.
91
+
92
+ # Contributing
93
+
94
+ Please see the [contributing guidelines](/CONTRIBUTING.md)
package/dist/index.d.ts CHANGED
@@ -65,12 +65,16 @@ type BaseForesightManagerProps = {
65
65
  /**
66
66
  * Number of mouse positions to keep in history for trajectory calculation.
67
67
  * A higher number might lead to smoother but slightly delayed predictions.
68
+ *
69
+ * **This value is clamped between 2 and 50.**
68
70
  * @default 8
69
71
  */
70
72
  positionHistorySize: number;
71
73
  /**
72
74
  * How far ahead (in milliseconds) to predict the mouse trajectory.
73
75
  * A larger value means the prediction extends further into the future. (meaning it will trigger callbacks sooner)
76
+ *
77
+ * **This value is clamped between 10 and 200.**
74
78
  * @default 80
75
79
  */
76
80
  trajectoryPredictionTime: number;
@@ -80,14 +84,28 @@ type BaseForesightManagerProps = {
80
84
  * @default true
81
85
  */
82
86
  enableMousePrediction: boolean;
87
+ /**
88
+ * Toggles whether keyboard prediction is on
89
+ * @default true
90
+ */
91
+ enableTabPrediction: boolean;
92
+ /**
93
+ * Tab stops away from an element to trigger callback. Only works when @argument enableTabPrediction is true
94
+ *
95
+ * **This value is clamped between 0 and 20.**
96
+ * @default 3
97
+ */
98
+ tabOffset: number;
83
99
  /**
84
100
  * Whether to show visual debugging information on the screen.
85
- * This includes overlays for elements, hit slop areas, and the predicted mouse path.
101
+ * This includes overlays for elements, hit slop areas, the predicted mouse path and a debug control panel.
86
102
  * @default false
87
103
  */
88
104
  debug: boolean;
89
105
  /**
90
106
  * Amount of time in ms the element bounds get recalculated on scroll/resize of the page.
107
+ *
108
+ * **This value is clamped between 0 and 500.**
91
109
  * @default 50
92
110
  */
93
111
  resizeScrollThrottleDelay: number;
@@ -137,9 +155,10 @@ declare class ForesightManager {
137
155
  private lastResizeScrollCallTimestamp;
138
156
  private resizeScrollThrottleTimeoutId;
139
157
  private domObserver;
140
- private lastDomMutationRectsUpdateTimestamp;
141
158
  private domMutationRectsUpdateTimeoutId;
142
159
  private elementResizeObserver;
160
+ private lastKeyDown;
161
+ private globalListenersController;
143
162
  private constructor();
144
163
  static initialize(props?: Partial<UpdateForsightManagerProps>): ForesightManager;
145
164
  static get instance(): ForesightManager;
@@ -153,8 +172,17 @@ declare class ForesightManager {
153
172
  private handleMouseMove;
154
173
  private handleResizeOrScroll;
155
174
  private handleElementResize;
175
+ /**
176
+ * Detects when registered elements are removed from the DOM and automatically unregisters them to prevent stale references.
177
+ *
178
+ * @param mutationsList - Array of MutationRecord objects describing the DOM changes
179
+ *
180
+ */
156
181
  private handleDomMutations;
157
- private setupGlobalListeners;
182
+ private handleKeyDown;
183
+ private handleFocusIn;
184
+ private callCallback;
185
+ private initializeGlobalListeners;
158
186
  private removeGlobalListeners;
159
187
  }
160
188
 
package/dist/index.js CHANGED
@@ -1,2 +1,7 @@
1
- "use strict";var e=function(){return e=Object.assign||function(e){for(var t,i=1,n=arguments.length;i<n;i++)for(var o in t=arguments[i])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t=function(){function e(e){this.shadowRoot=null,this.controlsContainer=null,this.elementListContainer=null,this.elementCountSpan=null,this.elementListItems=new Map,this.trajectoryEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.throttleDelaySlider=null,this.throttleValueSpan=null,this.minimizeButton=null,this.debuggerSection=null,this.isMinimized=!1,this.foresightManagerInstance=e}return e.prototype.initialize=function(e,t,i){this.shadowRoot=e,this._createDOM(),i.isControlPanelDefaultMinimized&&(this.isMinimized=!0),this.controlsContainer&&(this.shadowRoot.appendChild(this.controlsContainer),this._queryDOMElements(),this._setupEventListeners(),this.updateControlsState(t),this.refreshElementList(),this._applyMinimizedStateVisuals())},e.prototype._createDOM=function(){this.controlsContainer=document.createElement("div"),this.controlsContainer.id="jsforesight-debug-controls";this.controlsContainer.innerHTML='\n <div class="jsforesight-debugger-title-container">\n <button class="jsforesight-minimize-button">-</button>\n <h3>Foresight Debugger</h3>\n <span class="jsforesight-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\n <div class="jsforesight-debugger-section">\n <h4>Session Settings</h4>\n <div class="control-row">\n <label for="jsforesight-trajectory-enabled">\n Enable Mouse Prediction\n <span class="jsforesight-info-icon" title="Toggles mouse movement prediction. If disabled, only direct hovers trigger actions.">i</span>\n </label>\n <input type="checkbox" id="jsforesight-trajectory-enabled">\n </div>\n <div class="control-row">\n <label for="jsforesight-history-size">\n History Size\n <span class="jsforesight-info-icon" title="Number of past mouse positions for velocity calculation (Min: 2, Max: 20). Higher values smooth predictions but add latency.">i</span>\n </label>\n <input type="range" id="jsforesight-history-size" min="2" max="20">\n <span id="jsforesight-history-value"></span>\n </div>\n <div class="control-row">\n <label for="jsforesight-prediction-time">\n Prediction Time (ms)\n <span class="jsforesight-info-icon" title="How far (ms) to project trajectory (Min: 10, Max: 500). Larger values detect intent sooner.">i</span>\n </label>\n <input type="range" id="jsforesight-prediction-time" min="10" max="500" step="10">\n <span id="jsforesight-prediction-value"></span>\n </div>\n <div class="control-row">\n <label for="jsforesight-throttle-delay">\n Scroll/Resize Throttle (ms)\n <span class="jsforesight-info-icon" title="Delay (ms) for recalculating element positions on resize/scroll (Min: 0, Max: 500). Higher values improve performance during rapid events.">i</span>\n </label>\n <input type="range" id="jsforesight-throttle-delay" min="0" max="500" step="10">\n <span id="jsforesight-throttle-value"></span>\n </div>\n \n <div class="jsforesight-debugger-section">\n <h4>Registered Elements (<span id="jsforesight-element-count">0</span>)</h4>\n <div id="jsforesight-element-list-items-container" class="jsforesight-element-list">\n <em>Initializing...</em>\n </div>\n </div>\n </div>\n '},e.prototype._queryDOMElements=function(){this.controlsContainer&&(this.trajectoryEnabledCheckbox=this.controlsContainer.querySelector("#jsforesight-trajectory-enabled"),this.historySizeSlider=this.controlsContainer.querySelector("#jsforesight-history-size"),this.historyValueSpan=this.controlsContainer.querySelector("#jsforesight-history-value"),this.predictionTimeSlider=this.controlsContainer.querySelector("#jsforesight-prediction-time"),this.predictionValueSpan=this.controlsContainer.querySelector("#jsforesight-prediction-value"),this.throttleDelaySlider=this.controlsContainer.querySelector("#jsforesight-throttle-delay"),this.throttleValueSpan=this.controlsContainer.querySelector("#jsforesight-throttle-value"),this.elementListContainer=this.controlsContainer.querySelector("#jsforesight-element-list-items-container"),this.elementCountSpan=this.controlsContainer.querySelector("#jsforesight-element-count"),this.minimizeButton=this.controlsContainer.querySelector(".jsforesight-minimize-button"),this.debuggerSection=this.controlsContainer.querySelector(".jsforesight-debugger-section"))},e.prototype._setupEventListeners=function(){var e,t,i,n,o,r=this;null===(e=this.trajectoryEnabledCheckbox)||void 0===e||e.addEventListener("change",(function(e){r.foresightManagerInstance.alterGlobalSettings({enableMousePrediction:e.target.checked})})),null===(t=this.historySizeSlider)||void 0===t||t.addEventListener("input",(function(e){var t=parseInt(e.target.value);r.historyValueSpan&&(r.historyValueSpan.textContent=t.toString()),r.foresightManagerInstance.alterGlobalSettings({positionHistorySize:t})})),null===(i=this.predictionTimeSlider)||void 0===i||i.addEventListener("input",(function(e){var t=parseInt(e.target.value);r.predictionValueSpan&&(r.predictionValueSpan.textContent=t.toString()),r.foresightManagerInstance.alterGlobalSettings({trajectoryPredictionTime:t})})),null===(n=this.throttleDelaySlider)||void 0===n||n.addEventListener("input",(function(e){var t=parseInt(e.target.value);r.throttleValueSpan&&(r.throttleValueSpan.textContent=t.toString()),r.foresightManagerInstance.alterGlobalSettings({resizeScrollThrottleDelay:t})})),null===(o=this.minimizeButton)||void 0===o||o.addEventListener("click",(function(){r.isMinimized=!r.isMinimized,r._applyMinimizedStateVisuals()}))},e.prototype._applyMinimizedStateVisuals=function(){this.minimizeButton&&this.debuggerSection&&this.controlsContainer&&(this.isMinimized?(this.debuggerSection.style.display="none",this.minimizeButton.textContent="+"):(this.debuggerSection.style.display="",this.minimizeButton.textContent="-"))},e.prototype.updateControlsState=function(e){this.trajectoryEnabledCheckbox&&(this.trajectoryEnabledCheckbox.checked=e.enableMousePrediction),this.historySizeSlider&&this.historyValueSpan&&(this.historySizeSlider.value=e.positionHistorySize.toString(),this.historyValueSpan.textContent=e.positionHistorySize.toString()),this.predictionTimeSlider&&this.predictionValueSpan&&(this.predictionTimeSlider.value=e.trajectoryPredictionTime.toString(),this.predictionValueSpan.textContent=e.trajectoryPredictionTime.toString()),this.throttleDelaySlider&&this.throttleValueSpan&&(this.throttleDelaySlider.value=e.resizeScrollThrottleDelay.toString(),this.throttleValueSpan.textContent=e.resizeScrollThrottleDelay.toString())},e.prototype.refreshElementList=function(){var e=this;if(this.elementListContainer){this.elementListContainer.innerHTML="",this.elementListItems.clear();var t=this.foresightManagerInstance.elements;this.elementCountSpan&&(this.elementCountSpan.textContent=t.size.toString()),0!==t.size?t.forEach((function(t,i){var n=document.createElement("div");n.className="jsforesight-element-list-item",e._updateListItemContent(n,t),e.elementListContainer.appendChild(n),e.elementListItems.set(i,n)})):this.elementListContainer.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);var i=t.unregisterOnCallback?"Single":"Multi",n=t.unregisterOnCallback?"Callback triggers once, then element unregisters.":"Callback can trigger multiple times.";e.innerHTML="\n ".concat('<span class="status-indicator"></span>','\n <span class="element-name" title="').concat(t.name||"Unnamed Element",'">').concat(t.name||"Unnamed Element",'</span>\n <span class="hit-behavior" title="').concat(n,'">').concat(i,'</span>\n <span class="element-details">(H: ').concat(t.isHovering?"Y":"N",", T: ").concat(t.trajectoryHitData.isTrajectoryHit?"Y":"N",")</span>\n ")},e.prototype.cleanup=function(){var e;null===(e=this.controlsContainer)||void 0===e||e.remove(),this.controlsContainer=null,this.elementListContainer=null,this.elementCountSpan=null,this.elementListItems.clear(),this.minimizeButton=null,this.debuggerSection=null},e}(),i=function(){return window.matchMedia("(pointer: coarse)").matches&&navigator.maxTouchPoints>0},n=function(){function e(e){this.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.debugLinkOverlays=new Map,this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.debugStyleElement=null,this.controlPanel=null,this.lastElementData=new Map,this.foresightManagerInstance=e,this.controlPanel=new t(this.foresightManagerInstance)}return e.prototype.initialize=function(e,t,n,o){var r,s=this;"undefined"==typeof window||i()||(this.cleanup(),this.shadowHost=document.createElement("div"),this.shadowHost.id="jsforesight-debugger-shadow-host",this.shadowHost.style.pointerEvents="none",document.body.appendChild(this.shadowHost),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"}),this.debugStyleElement=document.createElement("style"),this.debugStyleElement.textContent='\n #jsforesight-debug-container { /* For on-page overlays */\n position: fixed; top: 0; left: 0; width: 100%; height: 100%;\n pointer-events: none; z-index: 9999;\n }\n .jsforesight-link-overlay {\n position: absolute; border: 2px solid transparent;\n background-color: rgba(0, 0, 255, 0.1); box-sizing: border-box;\n transition: opacity 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;\n }\n .jsforesight-link-overlay.active {\n border-color: oklch(83.7% 0.128 66.29); background-color: rgba(255, 0, 0, 0.1);\n }\n .jsforesight-link-overlay.trajectory-hit {\n border-color: oklch(89.7% 0.196 126.665); background-color: rgba(0, 255, 0, 0.3);\n box-shadow: 0 0 10px rgba(0, 255, 0, 0.8);\n }\n .jsforesight-expanded-overlay {\n position: absolute; border: 1px dashed rgba(0, 0, 255, 0.3);\n background-color: rgba(0, 0, 255, 0.05); box-sizing: border-box;\n }\n .jsforesight-mouse-predicted {\n position: absolute; width: 20px; height: 20px; border-radius: 50%;\n border: 2px solid oklch(83.7% 0.128 66.29); background-color: rgba(255, 165, 0, 0.3);\n transform: translate(-50%, -50%); z-index: 10000;\n }\n .jsforesight-trajectory-line {\n position: absolute; height: 2px; background-color: rgba(255, 100, 0, 0.5);\n transform-origin: left center; z-index: 9999;\n }\n .jsforesight-name-label {\n position: absolute;\n background-color: rgba(0, 0, 0, 0.75);\n color: white;\n padding: 3px 6px;\n font-size: 11px;\n font-family: Arial, sans-serif;\n border-radius: 3px;\n z-index: 10001;\n white-space: nowrap;\n pointer-events: none;\n }\n /* Styles for #jsforesight-debug-controls and its children are still needed here */\n #jsforesight-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 min-width: 300px; max-width: 350px;\n }\n .jsforesight-debugger-title-container {\n display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px;\n }\n .jsforesight-minimize-button{\n background: none; border: none; color: white;\n font-size: 22px; cursor: pointer; padding: 0;\n position: absolute; top: 10px; left: 15px;\n }\n .jsforesight-debugger-title-container h3 { margin: 0; font-size: 15px; }\n #jsforesight-debug-controls label { display: flex; align-items: center; gap: 5px; cursor: pointer; }\n #jsforesight-debug-controls input[type="range"] { flex-grow: 1; margin: 0 5px; cursor: pointer;}\n #jsforesight-debug-controls input[type="checkbox"] { margin-right: 5px; cursor: pointer; }\n #jsforesight-debug-controls .control-row { display: flex; align-items: center; justify-content: space-between; }\n #jsforesight-debug-controls .control-row label { flex-basis: auto; }\n #jsforesight-debug-controls .control-row span:not(.jsforesight-info-icon) { min-width: 30px; text-align: right; }\n .jsforesight-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;\n font-size: 10px; font-style: italic; font-weight: bold;\n font-family: \'Georgia\', serif;\n cursor: help; user-select: none;\n flex-shrink: 0;\n }\n .jsforesight-debugger-section {\n display: flex; flex-direction: column; gap: 6px;\n border-top: 1px solid #444;\n }\n .jsforesight-debugger-section h4 {\n margin: 5px 0 2px 0;\n font-size: 14px;\n font-weight: bold;\n }\n .jsforesight-element-list {\n max-height: 150px;\n overflow-y: auto;\n background-color: rgba(20, 20, 20, 0.5);\n border-radius: 3px;\n padding: 5px;\n font-size: 12px;\n }\n .jsforesight-element-list-item {\n padding: 4px 6px;\n margin-bottom: 3px;\n border-radius: 2px;\n display: flex;\n align-items: center;\n gap: 6px;\n background-color: rgba(50,50,50,0.7);\n transition: background-color 0.2s ease;\n }\n .jsforesight-element-list-item:last-child {\n margin-bottom: 0;\n }\n .jsforesight-element-list-item .status-indicator {\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background-color: #777;\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 8px;\n }\n .jsforesight-element-list-item.hovering .status-indicator {\n background-color: oklch(83.7% 0.128 66.29 / 0.7);\n }\n .jsforesight-element-list-item.trajectory-hit .status-indicator {\n background-color: oklch(89.7% 0.196 126.665 / 0.7);\n }\n .jsforesight-element-list-item.hovering.trajectory-hit .status-indicator {\n background: linear-gradient(45deg, oklch(89.7% 0.196 126.665 / 0.7) 50%, oklch(83.7% 0.128 66.29 / 0.7) 50%);\n }\n .jsforesight-element-list-item .element-name {\n flex-grow: 1;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n }\n .jsforesight-element-list-item .element-details {\n font-size: 10px;\n color: #ccc;\n flex-shrink: 0;\n }\n .jsforesight-element-list-item .hit-behavior {\n font-size: 10px;\n color: #b0b0b0;\n margin-right: 5px;\n padding: 1px 3px;\n border-radius: 2px;\n background-color: rgba(0,0,0,0.2);\n flex-shrink: 0;\n }\n ',this.shadowRoot.appendChild(this.debugStyleElement),this.debugContainer=document.createElement("div"),this.debugContainer.id="jsforesight-debug-container",this.shadowRoot.appendChild(this.debugContainer),this.debugPredictedMouseIndicator=document.createElement("div"),this.debugPredictedMouseIndicator.className="jsforesight-mouse-predicted",this.debugContainer.appendChild(this.debugPredictedMouseIndicator),this.debugTrajectoryLine=document.createElement("div"),this.debugTrajectoryLine.className="jsforesight-trajectory-line",this.debugContainer.appendChild(this.debugTrajectoryLine),this.shadowRoot&&(null===(r=this.controlPanel)||void 0===r||r.initialize(this.shadowRoot,t,t.debuggerSettings)),e.forEach((function(e,t){s.createOrUpdateLinkOverlay(t,e)})),this.updateTrajectoryVisuals(n,o,t.enableMousePrediction))},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.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.debugLinkOverlays.clear(),this.lastElementData.clear(),this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.debugStyleElement=null},e.prototype.createOrUpdateLinkOverlay=function(e,t){var i;if(this.debugContainer&&this.shadowRoot){this.lastElementData.set(e,{isHovering:t.isHovering,isTrajectoryHit:t.trajectoryHitData.isTrajectoryHit});var n=this.debugLinkOverlays.get(e);if(!n){var o=document.createElement("div");o.className="jsforesight-link-overlay",this.debugContainer.appendChild(o);var r=document.createElement("div");r.className="jsforesight-expanded-overlay",this.debugContainer.appendChild(r);var s=document.createElement("div");s.className="jsforesight-name-label",this.debugContainer.appendChild(s),n={linkOverlay:o,expandedOverlay:r,nameLabel:s},this.debugLinkOverlays.set(e,n)}var a=n.linkOverlay,l=n.expandedOverlay,c=n.nameLabel,d=e.getBoundingClientRect();a.style.left="".concat(d.left,"px"),a.style.top="".concat(d.top,"px"),a.style.width="".concat(d.width,"px"),a.style.height="".concat(d.height,"px"),a.classList.toggle("trajectory-hit",t.trajectoryHitData.isTrajectoryHit),a.classList.toggle("active",t.isHovering),t.elementBounds.expandedRect?(l.style.left="".concat(t.elementBounds.expandedRect.left,"px"),l.style.top="".concat(t.elementBounds.expandedRect.top,"px"),l.style.width="".concat(t.elementBounds.expandedRect.right-t.elementBounds.expandedRect.left,"px"),l.style.height="".concat(t.elementBounds.expandedRect.bottom-t.elementBounds.expandedRect.top,"px"),l.style.display="block"):l.style.display="none",t.name&&"Unnamed"!==t.name?(c.textContent=t.name,c.style.display="block",c.style.left="".concat(d.left,"px"),c.style.top="".concat(d.top-22,"px")):c.style.display="none",null===(i=this.controlPanel)||void 0===i||i.refreshElementList()}},e.prototype.removeLinkOverlay=function(e){var t,i=this.debugLinkOverlays.get(e);i&&(i.linkOverlay.remove(),i.expandedOverlay.remove(),i.nameLabel.remove(),this.debugLinkOverlays.delete(e)),this.lastElementData.delete(e),null===(t=this.controlPanel)||void 0===t||t.refreshElementList()},e.prototype.refreshDisplayedElements=function(){var e,t=this,i=new Set(this.foresightManagerInstance.elements.keys());this.foresightManagerInstance.elements.forEach((function(e,i){t.createOrUpdateLinkOverlay(i,e)})),Array.from(this.debugLinkOverlays.keys()).filter((function(e){return!i.has(e)})).forEach((function(e){var i=t.debugLinkOverlays.get(e);null==i||i.linkOverlay.remove(),null==i||i.expandedOverlay.remove(),null==i||i.nameLabel.remove(),t.debugLinkOverlays.delete(e),t.lastElementData.delete(e)})),null===(e=this.controlPanel)||void 0===e||e.refreshElementList()},e.prototype.updateAllLinkVisuals=function(e){this.shadowRoot&&this.debugContainer&&this.refreshDisplayedElements()},e.prototype.updateTrajectoryVisuals=function(e,t,i){if(this.shadowRoot&&this.debugContainer){var n=this.foresightManagerInstance.elements.size>0,o=i&&n;if(this.debugPredictedMouseIndicator&&(this.debugPredictedMouseIndicator.style.left="".concat(t.x,"px"),this.debugPredictedMouseIndicator.style.top="".concat(t.y,"px"),this.debugPredictedMouseIndicator.style.display="block"),this.debugTrajectoryLine)if(o&&e&&t){var r=t.x-e.x,s=t.y-e.y;if(Math.abs(r)<.1&&Math.abs(s)<.1)return void(this.debugTrajectoryLine.style.display="none");var a=Math.sqrt(r*r+s*s),l=180*Math.atan2(s,r)/Math.PI;this.debugTrajectoryLine.style.left="".concat(e.x,"px"),this.debugTrajectoryLine.style.top="".concat(e.y,"px"),this.debugTrajectoryLine.style.width="".concat(a,"px"),this.debugTrajectoryLine.style.transform="translateY(-50%) rotate(".concat(l,"deg)"),this.debugTrajectoryLine.style.display="block"}else this.debugTrajectoryLine.style.display="none"}},e.prototype.updateControlsState=function(e){var t;null===(t=this.controlPanel)||void 0===t||t.updateControlsState(e)},e}();function o(e,t,i,n){var o={point:e,time:performance.now()},r=e.x,s=e.y;if(t.push(o),t.length>i&&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=n/1e3;return{x:r+(l.point.x-a.point.x)/c*d,y:s+(l.point.y-a.point.y)/c*d}}function r(e){return"number"==typeof e?{top:e,left:e,right:e,bottom:e}:e}function s(e,t){return{left:e.left-t.left,right:e.right+t.right,top:e.top-t.top,bottom:e.bottom+t.bottom}}function a(e,t){return e&&t?e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom:e===t}var l=function(){function t(){var t=this;this.elements=new Map,this.isSetup=!1,this.debugger=null,this.globalSettings={debug:!1,enableMousePrediction:!0,positionHistorySize:8,trajectoryPredictionTime:80,defaultHitSlop:{top:0,left:0,right:0,bottom:0},resizeScrollThrottleDelay:50,debuggerSettings:{isControlPanelDefaultMinimized:!1}},this.positions=[],this.currentPoint={x:0,y:0},this.predictedPoint={x:0,y:0},this.lastResizeScrollCallTimestamp=0,this.resizeScrollThrottleTimeoutId=null,this.domObserver=null,this.lastDomMutationRectsUpdateTimestamp=0,this.domMutationRectsUpdateTimeoutId=null,this.elementResizeObserver=null,this.handleMouseMove=function(i){t.updatePointerState(i);var n=null;t.debugger&&(n=[]);var o=[];t.elements.forEach((function(i,r){if(t.elements.has(r)){var s,a,l={isHovering:i.isHovering,trajectoryHitData:i.trajectoryHitData},c=!1,d=i.isHovering,h=i.trajectoryHitData.isTrajectoryHit,u=i.trajectoryHitData.trajectoryHitTime,g=i.elementBounds.expandedRect,p=(s=t.currentPoint,a=g,s.x>=a.left&&s.x<=a.right&&s.y>=a.top&&s.y<=a.bottom),m=!1;if(!t.globalSettings.enableMousePrediction||p||i.trajectoryHitData.isTrajectoryHit||function(e,t,i){var n=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 i=t/e;if(e<0){if(i>o)return!1;i>n&&(n=i)}else{if(i<n)return!1;i<o&&(o=i)}}return!0};return!!a(-r,e.x-i.left)&&!!a(r,i.right-e.x)&&!!a(-s,e.y-i.top)&&!!a(s,i.bottom-e.y)&&n<=o}(t.currentPoint,t.predictedPoint,g)&&(m=!0),m&&(h=!0,u=performance.now(),c=!0,i.callback()),p&&!i.isHovering){var y=!i.trajectoryHitData.isTrajectoryHit||i.trajectoryHitData.isTrajectoryHit&&!t.globalSettings.enableMousePrediction;!c&&y&&(c=!0,i.callback())}if(d=p,c&&i.unregisterOnCallback&&o.push(r),(d!==l.isHovering||h!==l.trajectoryHitData.isTrajectoryHit||h&&u!==l.trajectoryHitData.trajectoryHitTime)&&t.elements.has(r)){var b=e(e({},i),{isHovering:d,trajectoryHitData:{isTrajectoryHit:h,trajectoryHitTime:u,trajectoryHitExpirationTimeoutId:l.trajectoryHitData.trajectoryHitExpirationTimeoutId}});b.trajectoryHitData.isTrajectoryHit&&!l.trajectoryHitData.isTrajectoryHit?(b.trajectoryHitData.trajectoryHitExpirationTimeoutId&&clearTimeout(b.trajectoryHitData.trajectoryHitExpirationTimeoutId),b.trajectoryHitData.trajectoryHitExpirationTimeoutId=setTimeout((function(){var i=t.elements.get(r);if(i&&i.trajectoryHitData.isTrajectoryHit&&i.trajectoryHitData.trajectoryHitTime===b.trajectoryHitData.trajectoryHitTime){var n=e(e({},i),{trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitExpirationTimeoutId:void 0,trajectoryHitTime:i.trajectoryHitData.trajectoryHitTime}});t.elements.set(r,n),t.debugger&&t.debugger.createOrUpdateLinkOverlay(r,n)}}),200)):!b.trajectoryHitData.isTrajectoryHit&&l.trajectoryHitData.isTrajectoryHit&&b.trajectoryHitData.trajectoryHitExpirationTimeoutId&&(clearTimeout(b.trajectoryHitData.trajectoryHitExpirationTimeoutId),b.trajectoryHitData.trajectoryHitExpirationTimeoutId=void 0),t.elements.set(r,b),n&&n.push(r)}}})),o.length>0&&o.forEach((function(e){var i;t.elements.has(e)&&(null===(i=t.elements.get(e))||void 0===i||i.name,t.unregister(e))})),t.debugger&&(null==n||n.forEach((function(e){var i=t.elements.get(e);i&&t.debugger.createOrUpdateLinkOverlay(e,i)})),t.debugger.updateTrajectoryVisuals(t.currentPoint,t.predictedPoint,t.globalSettings.enableMousePrediction))},this.handleResizeOrScroll=function(){t.resizeScrollThrottleTimeoutId&&clearTimeout(t.resizeScrollThrottleTimeoutId);var e=performance.now(),i=e-t.lastResizeScrollCallTimestamp,n=t.globalSettings.resizeScrollThrottleDelay;i>=n?(t.updateAllRects(),t.lastResizeScrollCallTimestamp=e,t.resizeScrollThrottleTimeoutId=null):t.resizeScrollThrottleTimeoutId=setTimeout((function(){t.updateAllRects(),t.lastResizeScrollCallTimestamp=performance.now(),t.resizeScrollThrottleTimeoutId=null}),n-i)},this.handleElementResize=function(e){for(var i=0,n=e;i<n.length;i++){var o=n[i].target;t.elements.get(o)&&t.updateExpandedRect(o)}},this.handleDomMutations=function(e){for(var i=!1,n=0,o=e;n<o.length;n++){var r=o[n];if("childList"===r.type&&r.removedNodes.length>0)for(var s=0,a=Array.from(t.elements.keys());s<a.length;s++){var l=a[s];l.isConnected||t.elements.has(l)&&t.unregister(l)}"childList"!==r.type&&("attributes"!==r.type||"style"!==r.attributeName&&"class"!==r.attributeName)||(i=!0)}if(i&&t.elements.size>0){t.domMutationRectsUpdateTimeoutId&&clearTimeout(t.domMutationRectsUpdateTimeoutId);var c=performance.now(),d=t.globalSettings.resizeScrollThrottleDelay,h=c-t.lastDomMutationRectsUpdateTimestamp;h>=d?(t.updateAllRects(),t.lastDomMutationRectsUpdateTimestamp=c,t.domMutationRectsUpdateTimeoutId=null):t.domMutationRectsUpdateTimeoutId=setTimeout((function(){t.updateAllRects(),t.lastDomMutationRectsUpdateTimestamp=performance.now(),t.domMutationRectsUpdateTimeoutId=null}),d-h)}}}return t.initialize=function(e){return t.manager?e&&t.manager.alterGlobalSettings(e):(t.manager=new t,e?t.manager.alterGlobalSettings(e):t.manager.globalSettings.debug&&t.manager.turnOnDebugMode()),t.manager},Object.defineProperty(t,"instance",{get:function(){return t.manager?t.manager:this.initialize()},enumerable:!1,configurable:!0}),t.prototype.register=function(e){var t=this,n=e.element,o=e.callback,a=e.hitSlop,l=e.unregisterOnCallback,c=e.name;if(i())return{isTouchDevice:!0,unregister:function(){}};var d=a?r(a):this.globalSettings.defaultHitSlop,h=n.getBoundingClientRect(),u=null==l||l,g={callback:o,elementBounds:{expandedRect:s(h,d),originalRect:h,hitSlop:d},isHovering:!1,trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitTime:0,trajectoryHitExpirationTimeoutId:void 0},name:null!=c?c:"",unregisterOnCallback:u};if(this.elements.set(n,g),this.isSetup||this.setupGlobalListeners(),this.elementResizeObserver&&this.elementResizeObserver.observe(n),this.debugger){var p=this.elements.get(n);p&&this.debugger.createOrUpdateLinkOverlay(n,p),this.debugger.refreshDisplayedElements()}return{isTouchDevice:!1,unregister:function(){return t.unregister(n)}}},t.prototype.unregister=function(e){if(this.elements.has(e)){var t=this.elements.get(e);(null==t?void 0:t.trajectoryHitData.trajectoryHitExpirationTimeoutId)&&clearTimeout(t.trajectoryHitData.trajectoryHitExpirationTimeoutId),this.elementResizeObserver&&this.elementResizeObserver.unobserve(e),this.elements.delete(e),this.debugger&&(this.debugger.removeLinkOverlay(e),this.debugger.refreshDisplayedElements()),0===this.elements.size&&this.isSetup&&this.removeGlobalListeners()}else console.warn("Attempted to unregister element not found:",e)},t.prototype.alterGlobalSettings=function(t){var i,n=this,s=!1;if(void 0!==(null==t?void 0:t.positionHistorySize)&&this.globalSettings.positionHistorySize!==t.positionHistorySize&&(this.globalSettings.positionHistorySize=t.positionHistorySize,s=!0),void 0!==(null==t?void 0:t.trajectoryPredictionTime)&&this.globalSettings.trajectoryPredictionTime!==t.trajectoryPredictionTime&&(this.globalSettings.trajectoryPredictionTime=t.trajectoryPredictionTime,s=!0),void 0!==(null==t?void 0:t.enableMousePrediction)&&this.globalSettings.enableMousePrediction!==t.enableMousePrediction&&(this.globalSettings.enableMousePrediction=t.enableMousePrediction,s=!0,this.globalSettings.enableMousePrediction?this.predictedPoint=o(this.currentPoint,this.positions,this.globalSettings.positionHistorySize,this.globalSettings.trajectoryPredictionTime):(this.predictedPoint=this.currentPoint,this.elements.forEach((function(t,i){if(t.trajectoryHitData.isTrajectoryHit){t.trajectoryHitData.trajectoryHitExpirationTimeoutId&&clearTimeout(t.trajectoryHitData.trajectoryHitExpirationTimeoutId);var o=e(e({},t),{trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitTime:0,trajectoryHitExpirationTimeoutId:void 0}});n.elements.set(i,o),n.debugger&&n.debugger.createOrUpdateLinkOverlay(i,o)}})))),void 0!==(null===(i=null==t?void 0:t.debuggerSettings)||void 0===i?void 0:i.isControlPanelDefaultMinimized)&&(this.globalSettings.debuggerSettings.isControlPanelDefaultMinimized=t.debuggerSettings.isControlPanelDefaultMinimized,s=!0),void 0!==(null==t?void 0:t.defaultHitSlop)){var l=r(t.defaultHitSlop);a(this.globalSettings.defaultHitSlop,l)||(this.globalSettings.defaultHitSlop=l,s=!0,this.elements.forEach((function(e,t){n.updateExpandedRect(t)})))}void 0!==(null==t?void 0:t.resizeScrollThrottleDelay)&&this.globalSettings.resizeScrollThrottleDelay!==t.resizeScrollThrottleDelay&&(this.globalSettings.resizeScrollThrottleDelay=t.resizeScrollThrottleDelay,s=!0),void 0!==(null==t?void 0:t.debug)&&this.globalSettings.debug!==t.debug&&(this.globalSettings.debug=t.debug,s=!0,this.globalSettings.debug?this.turnOnDebugMode():this.debugger&&(this.debugger.cleanup(),this.debugger=null)),s&&this.globalSettings.debug&&this.debugger&&(this.debugger.updateControlsState(this.globalSettings),this.debugger.updateTrajectoryVisuals(this.currentPoint,this.predictedPoint,this.globalSettings.enableMousePrediction),this.elements.forEach((function(e,t){n.debugger.createOrUpdateLinkOverlay(t,e)})),this.debugger.refreshDisplayedElements())},t.prototype.turnOnDebugMode=function(){this.debugger?(this.debugger.updateControlsState(this.globalSettings),this.debugger.updateAllLinkVisuals(this.elements),this.debugger.updateTrajectoryVisuals(this.currentPoint,this.predictedPoint,this.globalSettings.enableMousePrediction)):(this.debugger=new n(this),this.debugger.initialize(this.elements,this.globalSettings,this.currentPoint,this.predictedPoint))},t.prototype.updateExpandedRect=function(t){var i=this.elements.get(t);if(i){var n=t.getBoundingClientRect(),o=s(n,i.elementBounds.hitSlop);if(!a(o,i.elementBounds.expandedRect)&&(this.elements.set(t,e(e({},i),{elementBounds:e(e({},i.elementBounds),{originalRect:n,expandedRect:o})})),this.debugger)){var r=this.elements.get(t);r&&this.debugger.createOrUpdateLinkOverlay(t,r)}}},t.prototype.updateAllRects=function(){var e=this;this.elements.forEach((function(t,i){e.updateExpandedRect(i)}))},t.prototype.updatePointerState=function(t){this.currentPoint={x:t.clientX,y:t.clientY},this.predictedPoint=this.globalSettings.enableMousePrediction?o(this.currentPoint,this.positions,this.globalSettings.positionHistorySize,this.globalSettings.trajectoryPredictionTime):e({},this.currentPoint)},t.prototype.setupGlobalListeners=function(){var e=this;this.isSetup||(document.addEventListener("mousemove",this.handleMouseMove),window.addEventListener("resize",this.handleResizeOrScroll),window.addEventListener("scroll",this.handleResizeOrScroll),this.domObserver||(this.domObserver=new MutationObserver(this.handleDomMutations)),this.domObserver.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}),this.elementResizeObserver||(this.elementResizeObserver=new ResizeObserver(this.handleElementResize),this.elements.forEach((function(t,i){return e.elementResizeObserver.observe(i)}))),this.isSetup=!0)},t.prototype.removeGlobalListeners=function(){document.removeEventListener("mousemove",this.handleMouseMove),window.removeEventListener("resize",this.handleResizeOrScroll),window.removeEventListener("scroll",this.handleResizeOrScroll),this.resizeScrollThrottleTimeoutId&&(clearTimeout(this.resizeScrollThrottleTimeoutId),this.resizeScrollThrottleTimeoutId=null),this.domMutationRectsUpdateTimeoutId&&(clearTimeout(this.domMutationRectsUpdateTimeoutId),this.domMutationRectsUpdateTimeoutId=null),this.domObserver&&this.domObserver.disconnect(),this.elementResizeObserver&&this.elementResizeObserver.disconnect(),this.isSetup=!1},t}();exports.ForesightManager=l;
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;
2
+ /*!
3
+ * tabbable 6.2.0
4
+ * @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
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)},y=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)},f=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)),y(o)},v=2e3,S='<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>',x=function(){function e(e){this.shadowRoot=null,this.controlsContainer=null,this.elementListItemsContainer=null,this.elementCountSpan=null,this.elementListItems=new Map,this.controlPanelStyleElement=null,this.trajectoryEnabledCheckbox=null,this.tabEnabledCheckbox=null,this.historySizeSlider=null,this.historyValueSpan=null,this.predictionTimeSlider=null,this.predictionValueSpan=null,this.throttleDelaySlider=null,this.throttleValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=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.initialize=function(e,t){this.shadowRoot=e,this.createDOM(),t.isControlPanelDefaultMinimized&&(this.isContainerMinimized=!0),this.controlsContainer&&this.shadowRoot&&(this.controlPanelStyleElement=document.createElement("style"),this.controlPanelStyleElement.textContent=this.getStyles(),this.controlPanelStyleElement.id="debug-control-panel",this.shadowRoot.appendChild(this.controlPanelStyleElement),this.shadowRoot.appendChild(this.controlsContainer),this.queryDOMElements(),this.originalSectionStates(),this.setupEventListeners(),this.refreshElementList(),this.applyMinimizedStateVisuals())},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.controlsContainer&&(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.throttleDelaySlider=this.controlsContainer.querySelector("#throttle-delay"),this.throttleValueSpan=this.controlsContainer.querySelector("#throttle-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.elementCountSpan=this.controlsContainer.querySelector("#element-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,o,r,s,a,l,c,d,u,h=this;if(this.copySettingsButton){var g=null!==(t=null===(e=this.trajectoryEnabledCheckbox)||void 0===e?void 0:e.checked)&&void 0!==t&&t,p=null!==(i=null===(n=this.tabEnabledCheckbox)||void 0===n?void 0:n.checked)&&void 0!==i&&i,b=parseInt(null!==(r=null===(o=this.historySizeSlider)||void 0===o?void 0:o.value)&&void 0!==r?r:"8",10),m=parseInt(null!==(a=null===(s=this.predictionTimeSlider)||void 0===s?void 0:s.value)&&void 0!==a?a:"80",10),y=parseInt(null!==(c=null===(l=this.throttleDelaySlider)||void 0===l?void 0:l.value)&&void 0!==c?c:"50",10),f=parseInt(null!==(u=null===(d=this.tabOffsetSlider)||void 0===d?void 0:d.value)&&void 0!==u?u:"2",10),v={debug:!0,debuggerSettings:{isControlPanelDefaultMinimized:this.isContainerMinimized},enableMousePrediction:g,enableTabPrediction:p,positionHistorySize:b,resizeScrollThrottleDelay:y,tabOffset:f,trajectoryPredictionTime:m},x="ForesightManager.initialize({\n";x+=" debug: ".concat(v.debug,",\n"),x+=" debuggerSettings: {\n",x+=" isControlPanelDefaultMinimized: ".concat(v.debuggerSettings.isControlPanelDefaultMinimized,",\n"),x+=" },\n",x+=" enableMousePrediction: ".concat(v.enableMousePrediction,",\n"),x+=" enableTabPrediction: ".concat(v.enableTabPrediction,",\n"),x+=" positionHistorySize: ".concat(v.positionHistorySize,",\n"),x+=" resizeScrollThrottleDelay: ".concat(v.resizeScrollThrottleDelay,",\n"),x+=" tabOffset: ".concat(v.tabOffset,",\n"),x+=" trajectoryPredictionTime: ".concat(v.trajectoryPredictionTime,",\n"),x+="})",navigator.clipboard.writeText(x).then((function(){h.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>',h.copyTimeoutId&&clearTimeout(h.copyTimeoutId),h.copyTimeoutId=setTimeout((function(){h.copySettingsButton&&(h.copySettingsButton.innerHTML=S),h.copyTimeoutId=null}),3e3)})).catch((function(e){console.error("Foresight Debugger: Could not copy settings to clipboard",e)}))}},e.prototype.setupEventListeners=function(){var e,t,n,i,o,r,s,a,l=this;null===(e=this.trajectoryEnabledCheckbox)||void 0===e||e.addEventListener("change",(function(e){l.foresightManagerInstance.alterGlobalSettings({enableMousePrediction:e.target.checked})})),null===(t=this.tabEnabledCheckbox)||void 0===t||t.addEventListener("change",(function(e){l.foresightManagerInstance.alterGlobalSettings({enableTabPrediction:e.target.checked})})),null===(n=this.historySizeSlider)||void 0===n||n.addEventListener("input",(function(e){var t=parseInt(e.target.value,10);l.historyValueSpan&&(l.historyValueSpan.textContent="".concat(t," points")),l.foresightManagerInstance.alterGlobalSettings({positionHistorySize:t})})),null===(i=this.predictionTimeSlider)||void 0===i||i.addEventListener("input",(function(e){var t=parseInt(e.target.value,10);l.predictionValueSpan&&(l.predictionValueSpan.textContent="".concat(t," ms")),l.foresightManagerInstance.alterGlobalSettings({trajectoryPredictionTime:t})})),null===(o=this.throttleDelaySlider)||void 0===o||o.addEventListener("input",(function(e){var t=parseInt(e.target.value,10);l.throttleValueSpan&&(l.throttleValueSpan.textContent="".concat(t," ms")),l.foresightManagerInstance.alterGlobalSettings({resizeScrollThrottleDelay:t})})),null===(r=this.tabOffsetSlider)||void 0===r||r.addEventListener("input",(function(e){var t=parseInt(e.target.value,10);l.tabOffsetValueSpan&&(l.tabOffsetValueSpan.textContent="".concat(t," tabs")),l.foresightManagerInstance.alterGlobalSettings({tabOffset:t})})),null===(s=this.containerMinimizeButton)||void 0===s||s.addEventListener("click",(function(){l.isContainerMinimized=!l.isContainerMinimized,l.applyMinimizedStateVisuals()})),null===(a=this.copySettingsButton)||void 0===a||a.addEventListener("click",this.handleCopySettings.bind(this));var c=function(e,t){var n=null==e?void 0:e.querySelector(".debugger-section-header");null==n||n.addEventListener("click",(function(n){n.stopPropagation(),l.toggleMinimizeSection(e,l[t]=!l[t])}))};this.controlsContainer&&(c(this.controlsContainer.querySelector(".mouse-settings-section"),"isMouseSettingsMinimized"),c(this.controlsContainer.querySelector(".keyboard-settings-section"),"isKeyboardSettingsMinimized"),c(this.controlsContainer.querySelector(".general-settings-section"),"isGeneralSettingsMinimized"),c(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.controlsContainer&&(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.applyMinimizedStateVisuals=function(){this.controlsContainer&&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){this.trajectoryEnabledCheckbox&&(this.trajectoryEnabledCheckbox.checked=e.enableMousePrediction),this.tabEnabledCheckbox&&(this.tabEnabledCheckbox.checked=e.enableTabPrediction),this.historySizeSlider&&this.historyValueSpan&&(this.historySizeSlider.value=e.positionHistorySize.toString(),this.historyValueSpan.textContent="".concat(e.positionHistorySize," points")),this.predictionTimeSlider&&this.predictionValueSpan&&(this.predictionTimeSlider.value=e.trajectoryPredictionTime.toString(),this.predictionValueSpan.textContent="".concat(e.trajectoryPredictionTime," ms")),this.throttleDelaySlider&&this.throttleValueSpan&&(this.throttleDelaySlider.value=e.resizeScrollThrottleDelay.toString(),this.throttleValueSpan.textContent="".concat(e.resizeScrollThrottleDelay," ms")),this.tabOffsetSlider&&this.tabOffsetValueSpan&&(this.tabOffsetSlider.value=e.tabOffset.toString(),this.tabOffsetValueSpan.textContent="".concat(e.tabOffset," tabs"))},e.prototype.refreshElementList=function(){var e=this;if(this.elementListItemsContainer){this.elementListItemsContainer.innerHTML="",this.elementListItems.clear();var t=this.foresightManagerInstance.elements;this.elementCountSpan&&(this.elementCountSpan.textContent=t.size.toString()),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);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)}e.innerHTML="\n ".concat('<span class="status-indicator"></span>','\n <span class="element-name" title="').concat(t.name||"Unnamed Element",'">').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\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.elementListItemsContainer=null,this.controlPanelStyleElement=null,this.elementCountSpan=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.throttleDelaySlider=null,this.throttleValueSpan=null,this.tabOffsetSlider=null,this.tabOffsetValueSpan=null,this.copySettingsButton=null},e.prototype.createDOM=function(){this.controlsContainer=document.createElement("div"),this.controlsContainer.id="debug-controls",this.controlsContainer.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(S,'\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).">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.">i</span>\n </label>\n <input type="range" id="history-size" min="').concat(2,'" max="').concat(50,'">\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 ms in the future to calculate the mouse trajectory. Larger values detect intent sooner.">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 tabs away from an registered element (works with reversed shift-tabs).">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.">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="throttle-delay">\n Scroll/Resize Throttle\n <span class="info-icon" title="Delay (ms) for recalculating element positions on resize/scroll. Higher values improve performance during rapid events.">i</span>\n </label>\n <input type="range" id="throttle-delay" min="').concat(0,'" max="').concat(500,'" step="10">\n <span id="throttle-value"></span>\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>Registered Elements (<span id="element-count">0</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.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: 380px;\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 .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(161,"px;\n max-height: ").concat(161,"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(149,"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;\n font-size: 11px; \n overflow: hidden;\n }\n .element-list-item .status-indicator {\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background-color: #777;\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 8px;\n }\n .element-list-item.hovering .status-indicator {\n background-color: oklch(83.7% 0.128 66.29 / 0.7);\n }\n .element-list-item.trajectory-hit .status-indicator {\n background-color: oklch(89.7% 0.196 126.665 / 0.7);\n }\n .element-list-item.hovering.trajectory-hit .status-indicator {\n background: linear-gradient(45deg, oklch(89.7% 0.196 126.665 / 0.7) 50%, oklch(83.7% 0.128 66.29 / 0.7) 50%);\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 .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}(),w=function(){return window.matchMedia("(pointer: coarse)").matches&&navigator.maxTouchPoints>0},C=function(){function e(e){this.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.debugLinkOverlays=new Map,this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.debuggerStyleElement=null,this.debugCallbackIndicator=null,this.controlPanel=null,this.lastElementData=new Map,document.querySelectorAll("#jsforesight-debugger-shadow-host").forEach((function(e){return e.remove()})),this.foresightManagerInstance=e,this.controlPanel=new x(this.foresightManagerInstance)}return e.getInstance=function(t){return e.debuggerInstance||(e.debuggerInstance=new e(t)),e.debuggerInstance},e.prototype.initialize=function(e,t,n,i){var o=this;if("undefined"==typeof window||w())this.shadowHost&&this.cleanup();else{if(this.shadowHost)return console.warn("ForesightDebugger already initialized."),this.updateControlsState(t),this.updateTrajectoryVisuals(n,i,t.enableMousePrediction),void this.refreshDisplayedElements();this.shadowHost=document.createElement("div"),this.shadowHost.id="jsforesight-debugger-shadow-host",this.shadowHost.style.pointerEvents="none",document.body.appendChild(this.shadowHost),this.shadowRoot=this.shadowHost.attachShadow({mode:"open"}),this.debuggerStyleElement=document.createElement("style"),this.debuggerStyleElement.id="debug-container",this.debuggerStyleElement.textContent="\n #jsforesight-debug-container { \n position: fixed; top: 0; left: 0; width: 100%; height: 100%;\n pointer-events: none; z-index: 9999;\n }\n .jsforesight-link-overlay {\n position: absolute; border: 2px solid transparent;\n background-color: rgba(0, 0, 255, 0.1); box-sizing: border-box;\n transition: opacity 0.2s ease, border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;\n }\n .jsforesight-link-overlay.active {\n border-color: oklch(83.7% 0.128 66.29); background-color: rgba(255, 0, 0, 0.1);\n }\n .jsforesight-link-overlay.trajectory-hit {\n border-color: oklch(89.7% 0.196 126.665); background-color: rgba(0, 255, 0, 0.3);\n box-shadow: 0 0 10px rgba(0, 255, 0, 0.8);\n }\n .jsforesight-expanded-overlay {\n position: absolute; border: 1px dashed rgba(0, 0, 255, 0.3);\n background-color: rgba(0, 0, 255, 0.05); box-sizing: border-box;\n }\n .jsforesight-mouse-predicted {\n position: absolute; width: 20px; height: 20px; border-radius: 50%;\n border: 2px solid oklch(83.7% 0.128 66.29); background-color: rgba(255, 165, 0, 0.3);\n transform: translate(-50%, -50%); z-index: 10000;\n }\n .jsforesight-trajectory-line {\n position: absolute; height: 2px; background-color: rgba(255, 100, 0, 0.5);\n transform-origin: left center; z-index: 9999;\n }\n .jsforesight-name-label {\n position: absolute;\n background-color: rgba(0, 0, 0, 0.75);\n color: white;\n padding: 3px 6px;\n font-size: 11px;\n font-family: Arial, sans-serif;\n border-radius: 3px;\n z-index: 10001;\n white-space: nowrap;\n pointer-events: none;\n }\n .jsforesight-callback-indicator {\n position: absolute;\n border: 4px solid oklch(60% 0.1 270); \n border-radius: 5px;\n box-sizing: border-box;\n pointer-events: none;\n opacity: 0;\n transition: opacity 0.3s ease-out;\n z-index: 10002;\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 transform: scale(1);\n opacity: 1;\n }\n 100% {\n transform: scale(1.1);\n opacity: 0;\n }\n }\n ",this.shadowRoot.appendChild(this.debuggerStyleElement),this.debugContainer=document.createElement("div"),this.debugContainer.id="jsforesight-debug-container",this.shadowRoot.appendChild(this.debugContainer),this.debugPredictedMouseIndicator=document.createElement("div"),this.debugPredictedMouseIndicator.className="jsforesight-mouse-predicted",this.debugContainer.appendChild(this.debugPredictedMouseIndicator),this.debugTrajectoryLine=document.createElement("div"),this.debugTrajectoryLine.className="jsforesight-trajectory-line",this.debugContainer.appendChild(this.debugTrajectoryLine),this.debugCallbackIndicator=document.createElement("div"),this.debugCallbackIndicator.className="jsforesight-callback-indicator",this.debugContainer.appendChild(this.debugCallbackIndicator),this.shadowRoot&&this.controlPanel&&this.controlPanel.initialize(this.shadowRoot,t.debuggerSettings),e.forEach((function(e,t){o.createOrUpdateLinkOverlay(t,e)})),this.updateTrajectoryVisuals(n,i,t.enableMousePrediction)}},e.prototype.cleanup=function(){var t,n;null===(t=this.controlPanel)||void 0===t||t.cleanup(),null===(n=this.shadowHost)||void 0===n||n.remove(),this.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.debugLinkOverlays.clear(),this.lastElementData.clear(),this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.debuggerStyleElement=null,this.debugCallbackIndicator=null,e.debuggerInstance=void 0},e.prototype.createOrUpdateLinkOverlay=function(e,t){var n;if(this.debugContainer&&this.shadowRoot){this.lastElementData.set(e,{isHovering:t.isHovering,isTrajectoryHit:t.trajectoryHitData.isTrajectoryHit});var i=this.debugLinkOverlays.get(e);if(!i){var o=document.createElement("div");o.className="jsforesight-link-overlay",this.debugContainer.appendChild(o);var r=document.createElement("div");r.className="jsforesight-expanded-overlay",this.debugContainer.appendChild(r);var s=document.createElement("div");s.className="jsforesight-name-label",this.debugContainer.appendChild(s),i={linkOverlay:o,expandedOverlay:r,nameLabel:s},this.debugLinkOverlays.set(e,i)}var a=i.linkOverlay,l=i.expandedOverlay,c=i.nameLabel,d=e.getBoundingClientRect();a.style.left="".concat(d.left,"px"),a.style.top="".concat(d.top,"px"),a.style.width="".concat(d.width,"px"),a.style.height="".concat(d.height,"px"),a.classList.toggle("trajectory-hit",t.trajectoryHitData.isTrajectoryHit),a.classList.toggle("active",t.isHovering),t.elementBounds.expandedRect?(l.style.left="".concat(t.elementBounds.expandedRect.left,"px"),l.style.top="".concat(t.elementBounds.expandedRect.top,"px"),l.style.width="".concat(t.elementBounds.expandedRect.right-t.elementBounds.expandedRect.left,"px"),l.style.height="".concat(t.elementBounds.expandedRect.bottom-t.elementBounds.expandedRect.top,"px"),l.style.display="block"):l.style.display="none",t.name&&"Unnamed"!==t.name?(c.textContent=t.name,c.style.display="block",c.style.left="".concat(d.left,"px"),c.style.top="".concat(d.top-22,"px")):c.style.display="none",null===(n=this.controlPanel)||void 0===n||n.refreshElementList()}},e.prototype.removeLinkOverlay=function(e){var t,n=this.debugLinkOverlays.get(e);n&&(n.linkOverlay.remove(),n.expandedOverlay.remove(),n.nameLabel.remove(),this.debugLinkOverlays.delete(e)),this.lastElementData.delete(e),null===(t=this.controlPanel)||void 0===t||t.refreshElementList()},e.prototype.refreshDisplayedElements=function(){var e,t=this;if(this.shadowRoot&&this.debugContainer){var n=new Set(this.foresightManagerInstance.elements.keys());this.foresightManagerInstance.elements.forEach((function(e,n){t.createOrUpdateLinkOverlay(n,e)})),Array.from(this.debugLinkOverlays.keys()).filter((function(e){return!n.has(e)})).forEach((function(e){var n=t.debugLinkOverlays.get(e);null==n||n.linkOverlay.remove(),null==n||n.expandedOverlay.remove(),null==n||n.nameLabel.remove(),t.debugLinkOverlays.delete(e),t.lastElementData.delete(e)})),null===(e=this.controlPanel)||void 0===e||e.refreshElementList()}},e.prototype.updateAllLinkVisuals=function(){this.shadowRoot&&this.debugContainer&&this.refreshDisplayedElements()},e.prototype.updateTrajectoryVisuals=function(e,t,n){if(this.shadowRoot&&this.debugContainer&&(this.debugPredictedMouseIndicator&&(this.debugPredictedMouseIndicator.style.left="".concat(t.x,"px"),this.debugPredictedMouseIndicator.style.top="".concat(t.y,"px"),this.debugPredictedMouseIndicator.style.display=n?"block":"none"),this.debugTrajectoryLine))if(n&&e&&t){var i=t.x-e.x,o=t.y-e.y;if(n&&(Math.abs(i)>1||Math.abs(o)>1)){var r=Math.sqrt(i*i+o*o),s=180*Math.atan2(o,i)/Math.PI;this.debugTrajectoryLine.style.left="".concat(e.x,"px"),this.debugTrajectoryLine.style.top="".concat(e.y,"px"),this.debugTrajectoryLine.style.width="".concat(r,"px"),this.debugTrajectoryLine.style.transform="translateY(-50%) rotate(".concat(s,"deg)"),this.debugTrajectoryLine.style.display="block"}else this.debugTrajectoryLine.style.display="none"}else this.debugTrajectoryLine.style.display="none"},e.prototype.updateControlsState=function(e){var t;null===(t=this.controlPanel)||void 0===t||t.updateControlsState(e)},e.prototype.getAllElementData=function(){return this.foresightManagerInstance.elements},e.prototype.showCallbackPopup=function(e){var t=this;this.debugContainer&&this.shadowRoot&&this.debugCallbackIndicator&&(this.debugCallbackIndicator.style.left="".concat(e.left,"px"),this.debugCallbackIndicator.style.top="".concat(e.top,"px"),this.debugCallbackIndicator.style.width="".concat(e.right-e.left,"px"),this.debugCallbackIndicator.style.height="".concat(e.bottom-e.top,"px"),this.debugCallbackIndicator.classList.remove("animate"),requestAnimationFrame((function(){t.debugCallbackIndicator.classList.add("animate")})))},e}();function k(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}}function T(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 z(e,t){if("number"==typeof e){var n=T(e,0,v,t,"hitslop");return{top:n,left:n,right:n,bottom:n}}return{top:T(e.top,0,v,t,"hitslop - top"),left:T(e.left,0,v,t,"hitslop - left"),right:T(e.right,0,v,t,"hitslop - right"),bottom:T(e.bottom,0,v,t,"hitslop - bottom")}}function j(e,t){return{left:e.left-t.left,right:e.right+t.right,top:e.top-t.top,bottom:e.bottom+t.bottom}}function E(e,t){return e&&t?e.left===t.left&&e.right===t.right&&e.top===t.top&&e.bottom===t.bottom:e===t}var M=function(){function t(){var t=this;this.elements=new Map,this.isSetup=!1,this.debugger=null,this.globalSettings={debug:!1,enableMousePrediction:!0,positionHistorySize:8,trajectoryPredictionTime:80,defaultHitSlop:{top:0,left:0,right:0,bottom:0},resizeScrollThrottleDelay:50,debuggerSettings:{isControlPanelDefaultMinimized:!1},enableTabPrediction:!0,tabOffset:2},this.positions=[],this.currentPoint={x:0,y:0},this.predictedPoint={x:0,y:0},this.lastResizeScrollCallTimestamp=0,this.resizeScrollThrottleTimeoutId=null,this.domObserver=null,this.domMutationRectsUpdateTimeoutId=null,this.elementResizeObserver=null,this.lastKeyDown=null,this.globalListenersController=null,this.handleMouseMove=function(n){t.updatePointerState(n);var i=null;t.debugger&&(i=[]),t.elements.forEach((function(n,o){if(t.elements.has(o)){var r,s,a={isHovering:n.isHovering,trajectoryHitData:n.trajectoryHitData},l=!1,c=n.isHovering,d=n.trajectoryHitData.isTrajectoryHit,u=n.trajectoryHitData.trajectoryHitTime,h=n.elementBounds.expandedRect,g=(r=t.currentPoint,s=h,r.x>=s.left&&r.x<=s.right&&r.y>=s.top&&r.y<=s.bottom),p=!1;if(!t.globalSettings.enableMousePrediction||g||n.trajectoryHitData.isTrajectoryHit||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}(t.currentPoint,t.predictedPoint,h)&&(p=!0),p&&(d=!0,u=performance.now(),l=!0,t.callCallback(n,o)),g&&!n.isHovering){var b=!n.trajectoryHitData.isTrajectoryHit||n.trajectoryHitData.isTrajectoryHit&&!t.globalSettings.enableMousePrediction;!l&&b&&(l=!0,t.callCallback(n,o))}if(((c=g)!==a.isHovering||d!==a.trajectoryHitData.isTrajectoryHit||d&&u!==a.trajectoryHitData.trajectoryHitTime)&&t.elements.has(o)){var m=e(e({},n),{isHovering:c,trajectoryHitData:{isTrajectoryHit:d,trajectoryHitTime:u,trajectoryHitExpirationTimeoutId:a.trajectoryHitData.trajectoryHitExpirationTimeoutId}});m.trajectoryHitData.isTrajectoryHit&&!a.trajectoryHitData.isTrajectoryHit?(m.trajectoryHitData.trajectoryHitExpirationTimeoutId&&clearTimeout(m.trajectoryHitData.trajectoryHitExpirationTimeoutId),m.trajectoryHitData.trajectoryHitExpirationTimeoutId=setTimeout((function(){var n=t.elements.get(o);if(n&&n.trajectoryHitData.isTrajectoryHit&&n.trajectoryHitData.trajectoryHitTime===m.trajectoryHitData.trajectoryHitTime){var i=e(e({},n),{trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitExpirationTimeoutId:void 0,trajectoryHitTime:n.trajectoryHitData.trajectoryHitTime}});t.elements.set(o,i),t.debugger&&t.debugger.createOrUpdateLinkOverlay(o,i)}}),200)):!m.trajectoryHitData.isTrajectoryHit&&a.trajectoryHitData.isTrajectoryHit&&m.trajectoryHitData.trajectoryHitExpirationTimeoutId&&(clearTimeout(m.trajectoryHitData.trajectoryHitExpirationTimeoutId),m.trajectoryHitData.trajectoryHitExpirationTimeoutId=void 0),t.elements.set(o,m),i&&i.push(o)}}})),t.debugger&&(null==i||i.forEach((function(e){var n=t.elements.get(e);n&&t.debugger.createOrUpdateLinkOverlay(e,n)})),t.debugger.updateTrajectoryVisuals(t.currentPoint,t.predictedPoint,t.globalSettings.enableMousePrediction))},this.handleResizeOrScroll=function(){t.resizeScrollThrottleTimeoutId&&clearTimeout(t.resizeScrollThrottleTimeoutId);var e=performance.now(),n=e-t.lastResizeScrollCallTimestamp,i=t.globalSettings.resizeScrollThrottleDelay;n>=i?(t.updateAllRects(),t.lastResizeScrollCallTimestamp=e,t.resizeScrollThrottleTimeoutId=null):t.resizeScrollThrottleTimeoutId=setTimeout((function(){t.updateAllRects(),t.lastResizeScrollCallTimestamp=performance.now(),t.resizeScrollThrottleTimeoutId=null}),i-n)},this.handleElementResize=function(e){for(var n=0,i=e;n<i.length;n++){var o=i[n].target;t.elements.get(o)&&t.updateExpandedRect(o)}},this.handleDomMutations=function(e){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.elements.has(a)&&t.unregister(a)}}},this.handleKeyDown=function(e){"Tab"===e.key?t.lastKeyDown=e:t.lastKeyDown=null},this.handleFocusIn=function(e){if(t.lastKeyDown&&t.globalSettings.enableTabPrediction){var n=e.target;if(n instanceof HTMLElement){var i=f(document.documentElement),o=i.findIndex((function(e){return e===n})),r=t.lastKeyDown.shiftKey?-t.globalSettings.tabOffset:t.globalSettings.tabOffset;t.lastKeyDown=null;for(var s=[],a=0;a<i.length;a++){var l=i[a];(r>0?a>=o&&a<=o+r:a<=o&&a>=o+r)&&t.elements.has(l)&&s.push(l)}s.forEach((function(e){t.callCallback(t.elements.get(e),e)}))}}}}return t.initialize=function(e){return t.manager?e&&t.manager.alterGlobalSettings(e):(t.manager=new t,e?t.manager.alterGlobalSettings(e):t.manager.globalSettings.debug&&t.manager.turnOnDebugMode()),t.manager},Object.defineProperty(t,"instance",{get:function(){return t.manager?t.manager:this.initialize()},enumerable:!1,configurable:!0}),t.prototype.register=function(e){var t=this,n=e.element,i=e.callback,o=e.hitSlop,r=e.unregisterOnCallback,s=e.name;if(w())return{isTouchDevice:!0,unregister:function(){}};var a=o?z(o,this.globalSettings.debug):this.globalSettings.defaultHitSlop,l=n.getBoundingClientRect(),c=null==r||r,d={callback:i,elementBounds:{expandedRect:j(l,a),originalRect:l,hitSlop:a},isHovering:!1,trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitTime:0,trajectoryHitExpirationTimeoutId:void 0},name:null!=s?s:"",unregisterOnCallback:c};if(this.elements.set(n,d),this.isSetup||this.initializeGlobalListeners(),this.elementResizeObserver&&this.elementResizeObserver.observe(n),this.debugger){var u=this.elements.get(n);u&&this.debugger.createOrUpdateLinkOverlay(n,u),this.debugger.refreshDisplayedElements()}return{isTouchDevice:!1,unregister:function(){return t.unregister(n)}}},t.prototype.unregister=function(e){if(this.elements.has(e)){var t=this.elements.get(e);(null==t?void 0:t.trajectoryHitData.trajectoryHitExpirationTimeoutId)&&clearTimeout(t.trajectoryHitData.trajectoryHitExpirationTimeoutId),this.elementResizeObserver&&this.elementResizeObserver.unobserve(e),this.elements.delete(e),this.debugger&&(this.debugger.removeLinkOverlay(e),this.debugger.refreshDisplayedElements()),0===this.elements.size&&this.isSetup&&(this.debugger?console.log("%cForesightJS: All elements have successfully triggered their callbacks. ForesightJS would typically perform cleanup actions now, but these are currently skipped while in debug mode.","color: #28a745; font-weight: bold;"):this.removeGlobalListeners())}},t.prototype.alterGlobalSettings=function(t){var n,i=this,o=!1;if(void 0!==(null==t?void 0:t.positionHistorySize)&&this.globalSettings.positionHistorySize!==t.positionHistorySize&&(this.globalSettings.positionHistorySize=T(t.positionHistorySize,2,50,this.globalSettings.debug,"positionHistorySize"),o=!0),void 0!==(null==t?void 0:t.trajectoryPredictionTime)&&this.globalSettings.trajectoryPredictionTime!==t.trajectoryPredictionTime&&(this.globalSettings.trajectoryPredictionTime=T(t.trajectoryPredictionTime,10,200,this.globalSettings.debug,"trajectoryPredictionTime"),o=!0),void 0!==(null==t?void 0:t.enableTabPrediction)&&this.globalSettings.enableTabPrediction!==t.enableTabPrediction&&(this.globalSettings.enableTabPrediction=t.enableTabPrediction,o=!0),void 0!==(null==t?void 0:t.tabOffset)&&this.globalSettings.tabOffset!==t.tabOffset&&(this.globalSettings.tabOffset=T(t.tabOffset,0,20,this.globalSettings.debug,"tabOffset"),o=!0),void 0!==(null==t?void 0:t.enableMousePrediction)&&this.globalSettings.enableMousePrediction!==t.enableMousePrediction&&(this.globalSettings.enableMousePrediction=t.enableMousePrediction,o=!0,this.globalSettings.enableMousePrediction?this.predictedPoint=k(this.currentPoint,this.positions,this.globalSettings.positionHistorySize,this.globalSettings.trajectoryPredictionTime):(this.predictedPoint=this.currentPoint,this.elements.forEach((function(t,n){if(t.trajectoryHitData.isTrajectoryHit){t.trajectoryHitData.trajectoryHitExpirationTimeoutId&&clearTimeout(t.trajectoryHitData.trajectoryHitExpirationTimeoutId);var o=e(e({},t),{trajectoryHitData:{isTrajectoryHit:!1,trajectoryHitTime:0,trajectoryHitExpirationTimeoutId:void 0}});i.elements.set(n,o),i.debugger&&i.debugger.createOrUpdateLinkOverlay(n,o)}})))),void 0!==(null===(n=null==t?void 0:t.debuggerSettings)||void 0===n?void 0:n.isControlPanelDefaultMinimized)&&(this.globalSettings.debuggerSettings.isControlPanelDefaultMinimized=t.debuggerSettings.isControlPanelDefaultMinimized,o=!0),void 0!==(null==t?void 0:t.defaultHitSlop)){var r=z(t.defaultHitSlop,this.globalSettings.debug);E(this.globalSettings.defaultHitSlop,r)||(this.globalSettings.defaultHitSlop=r,o=!0,this.elements.forEach((function(e,t){i.updateExpandedRect(t)})))}void 0!==(null==t?void 0:t.resizeScrollThrottleDelay)&&this.globalSettings.resizeScrollThrottleDelay!==t.resizeScrollThrottleDelay&&(this.globalSettings.resizeScrollThrottleDelay=T(t.resizeScrollThrottleDelay,0,500,this.globalSettings.debug,"resizeScrollThrottleDelay"),o=!0),void 0!==(null==t?void 0:t.debug)&&this.globalSettings.debug!==t.debug&&(this.globalSettings.debug=t.debug,o=!0,this.globalSettings.debug?this.turnOnDebugMode():this.debugger&&(this.debugger.cleanup(),this.debugger=null)),o&&this.globalSettings.debug&&this.debugger&&(this.debugger.updateControlsState(this.globalSettings),this.debugger.updateTrajectoryVisuals(this.currentPoint,this.predictedPoint,this.globalSettings.enableMousePrediction),this.elements.forEach((function(e,t){i.debugger.createOrUpdateLinkOverlay(t,e)})),this.debugger.refreshDisplayedElements())},t.prototype.turnOnDebugMode=function(){this.debugger?(this.debugger.updateControlsState(this.globalSettings),this.debugger.updateAllLinkVisuals(),this.debugger.updateTrajectoryVisuals(this.currentPoint,this.predictedPoint,this.globalSettings.enableMousePrediction)):(this.debugger=C.getInstance(this),this.debugger.initialize(this.elements,this.globalSettings,this.currentPoint,this.predictedPoint))},t.prototype.updateExpandedRect=function(t){var n=this.elements.get(t);if(n){var i=t.getBoundingClientRect(),o=j(i,n.elementBounds.hitSlop);if(!E(o,n.elementBounds.expandedRect)&&(this.elements.set(t,e(e({},n),{elementBounds:e(e({},n.elementBounds),{originalRect:i,expandedRect:o})})),this.debugger)){var r=this.elements.get(t);r&&this.debugger.createOrUpdateLinkOverlay(t,r)}}},t.prototype.updateAllRects=function(){var e=this;this.elements.forEach((function(t,n){e.updateExpandedRect(n)}))},t.prototype.updatePointerState=function(t){this.currentPoint={x:t.clientX,y:t.clientY},this.predictedPoint=this.globalSettings.enableMousePrediction?k(this.currentPoint,this.positions,this.globalSettings.positionHistorySize,this.globalSettings.trajectoryPredictionTime):e({},this.currentPoint)},t.prototype.callCallback=function(e,t){e&&(e.callback(),this.debugger&&this.debugger.showCallbackPopup(e.elementBounds.expandedRect),e.unregisterOnCallback&&this.unregister(t))},t.prototype.initializeGlobalListeners=function(){var e=this;if(!this.isSetup){this.globalListenersController=new AbortController;var t=this.globalListenersController.signal;document.addEventListener("mousemove",this.handleMouseMove,{signal:t}),window.addEventListener("resize",this.handleResizeOrScroll,{signal:t}),window.addEventListener("scroll",this.handleResizeOrScroll,{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:!0}),this.elementResizeObserver=new ResizeObserver(this.handleElementResize),this.elements.forEach((function(t,n){return e.elementResizeObserver.observe(n)})),this.isSetup=!0}},t.prototype.removeGlobalListeners=function(){var e,t,n;null===(e=this.globalListenersController)||void 0===e||e.abort(),this.globalListenersController=null,null===(t=this.domObserver)||void 0===t||t.disconnect(),null===(n=this.elementResizeObserver)||void 0===n||n.disconnect(),this.resizeScrollThrottleTimeoutId&&(clearTimeout(this.resizeScrollThrottleTimeoutId),this.resizeScrollThrottleTimeoutId=null),this.domMutationRectsUpdateTimeoutId&&(clearTimeout(this.domMutationRectsUpdateTimeoutId),this.domMutationRectsUpdateTimeoutId=null),this.isSetup=!1},t}();exports.ForesightManager=M;
2
7
  //# sourceMappingURL=index.js.map