js.foresight 0.0.13 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ type ForesightManagerProps = {
|
|
|
74
74
|
*/
|
|
75
75
|
declare class ForesightManager {
|
|
76
76
|
private static manager;
|
|
77
|
-
private
|
|
77
|
+
private elements;
|
|
78
78
|
private isSetup;
|
|
79
79
|
private debugMode;
|
|
80
80
|
private debugger;
|
|
@@ -166,7 +166,6 @@ declare class ForesightManager {
|
|
|
166
166
|
* @returns True if the line segment intersects the rectangle, false otherwise.
|
|
167
167
|
*/
|
|
168
168
|
private lineSegmentIntersectsRect;
|
|
169
|
-
private isMouseInExpandedArea;
|
|
170
169
|
private handleMouseMove;
|
|
171
170
|
private handleResizeOrScroll;
|
|
172
171
|
private setupGlobalListeners;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.debugLinkOverlays=new Map,this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.debugControlsContainer=null,this.debugStyleElement=null,this.foresightManagerInstance=e}return e.prototype.initialize=function(e,t,i,n){var o=this;"undefined"!=typeof window&&(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 {\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 blue;\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: orange; background-color: rgba(255, 0, 0, 0.1);\n }\n .jsforesight-link-overlay.trajectory-hit {\n border-color: lime; 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.5);\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 orange; 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 { /* Added style for 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; /* Above link overlays */\n white-space: nowrap;\n pointer-events: none;\n }\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;\n }\n .jsforesight-debugger-title-container {\n display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px;\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 ',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.createDebugControls(t),e.forEach((function(e,t){o.createOrUpdateLinkOverlay(t,e)})),this.updateTrajectoryVisuals(i,n,t.enableMousePrediction))},e.prototype.cleanup=function(){var e;null===(e=this.shadowHost)||void 0===e||e.remove(),this.shadowHost=null,this.shadowRoot=null,this.debugLinkOverlays.forEach((function(e){e.linkOverlay.remove(),e.expandedOverlay.remove(),e.nameLabel.remove()})),this.debugLinkOverlays.clear()},e.prototype.createOrUpdateLinkOverlay=function(e,t){if(this.debugContainer&&this.shadowRoot){var i=this.debugLinkOverlays.get(e);if(!i){var n=document.createElement("div");n.className="jsforesight-link-overlay",this.debugContainer.appendChild(n);var o=document.createElement("div");o.className="jsforesight-expanded-overlay",this.debugContainer.appendChild(o);var r=document.createElement("div");r.className="jsforesight-name-label",this.debugContainer.appendChild(r),i={linkOverlay:n,expandedOverlay:o,nameLabel:r},this.debugLinkOverlays.set(e,i)}var s=i.linkOverlay,a=i.expandedOverlay,l=i.nameLabel,d=e.getBoundingClientRect();s.style.left="".concat(d.left,"px"),s.style.top="".concat(d.top,"px"),s.style.width="".concat(d.width,"px"),s.style.height="".concat(d.height,"px"),s.classList.toggle("trajectory-hit",t.isTrajectoryHit),s.classList.toggle("active",t.isHovering),t.elementBounds.expandedRect?(a.style.left="".concat(t.elementBounds.expandedRect.left,"px"),a.style.top="".concat(t.elementBounds.expandedRect.top,"px"),a.style.width="".concat(t.elementBounds.expandedRect.right-t.elementBounds.expandedRect.left,"px"),a.style.height="".concat(t.elementBounds.expandedRect.bottom-t.elementBounds.expandedRect.top,"px"),a.style.display="block"):a.style.display="none",t.name&&"Unnamed"!==t.name?(l.textContent=t.name,l.style.display="block",l.style.left="".concat(d.left,"px"),l.style.top="".concat(d.top-22,"px")):l.style.display="none"}},e.prototype.removeLinkOverlay=function(e){var t=this.debugLinkOverlays.get(e);t&&(t.linkOverlay.remove(),t.expandedOverlay.remove(),t.nameLabel.remove(),this.debugLinkOverlays.delete(e))},e.prototype.updateAllLinkVisuals=function(e){var t=this;if(this.shadowRoot&&this.debugContainer){var i=new Set(e.keys());this.debugLinkOverlays.forEach((function(e,n){i.has(n)||t.removeLinkOverlay(n)})),e.forEach((function(e,i){t.createOrUpdateLinkOverlay(i,e)}))}},e.prototype.updateTrajectoryVisuals=function(e,t,i){if(this.shadowRoot&&this.debugContainer&&(this.debugPredictedMouseIndicator&&(this.debugPredictedMouseIndicator.style.left="".concat((null==t?void 0:t.x)||0,"px"),this.debugPredictedMouseIndicator.style.top="".concat((null==t?void 0:t.y)||0,"px"),this.debugPredictedMouseIndicator.style.display=i&&t?"block":"none"),this.debugTrajectoryLine))if(i&&e&&t){var n=t.x-e.x,o=t.y-e.y,r=Math.sqrt(n*n+o*o),s=180*Math.atan2(o,n)/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"},e.prototype.createDebugControls=function(e){var t=this;if(this.shadowRoot){this.debugControlsContainer=document.createElement("div"),this.debugControlsContainer.id="jsforesight-debug-controls",this.shadowRoot.appendChild(this.debugControlsContainer),this.debugControlsContainer.innerHTML='\n <div class="jsforesight-debugger-title-container">\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 <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" '.concat(e.enableMousePrediction?"checked":"",'>\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" value="').concat(e.positionHistorySize,'">\n <span id="jsforesight-history-value">').concat(e.positionHistorySize,'</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" value="').concat(e.trajectoryPredictionTime,'">\n <span id="jsforesight-prediction-value">').concat(e.trajectoryPredictionTime,'</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" value="').concat(e.resizeScrollThrottleDelay,'">\n <span id="jsforesight-throttle-value">').concat(e.resizeScrollThrottleDelay,"</span>\n </div>\n ");var i=this.debugControlsContainer.querySelector("#jsforesight-trajectory-enabled");i.addEventListener("change",(function(){t.foresightManagerInstance.alterGlobalSettings({enableMousePrediction:i.checked})}));var n=this.debugControlsContainer.querySelector("#jsforesight-history-size"),o=this.debugControlsContainer.querySelector("#jsforesight-history-value");n.addEventListener("input",(function(){var e=parseInt(n.value);o.textContent=e.toString(),t.foresightManagerInstance.alterGlobalSettings({positionHistorySize:e})}));var r=this.debugControlsContainer.querySelector("#jsforesight-prediction-time"),s=this.debugControlsContainer.querySelector("#jsforesight-prediction-value");r.addEventListener("input",(function(){var e=parseInt(r.value);s.textContent=e.toString(),t.foresightManagerInstance.alterGlobalSettings({trajectoryPredictionTime:e})}));var a=this.debugControlsContainer.querySelector("#jsforesight-throttle-delay"),l=this.debugControlsContainer.querySelector("#jsforesight-throttle-value");a.addEventListener("input",(function(){var e=parseInt(a.value);l.textContent=e.toString(),t.foresightManagerInstance.alterGlobalSettings({resizeScrollThrottleDelay:e})}))}},e.prototype.updateControlsState=function(e){if(this.debugControlsContainer){var t=this.debugControlsContainer.querySelector("#jsforesight-trajectory-enabled");t&&(t.checked=e.enableMousePrediction);var i=this.debugControlsContainer.querySelector("#jsforesight-history-size"),n=this.debugControlsContainer.querySelector("#jsforesight-history-value");i&&n&&(i.value=e.positionHistorySize.toString(),n.textContent=e.positionHistorySize.toString());var o=this.debugControlsContainer.querySelector("#jsforesight-prediction-time"),r=this.debugControlsContainer.querySelector("#jsforesight-prediction-value");o&&r&&(o.value=e.trajectoryPredictionTime.toString(),r.textContent=e.trajectoryPredictionTime.toString());var s=this.debugControlsContainer.querySelector("#jsforesight-throttle-delay"),a=this.debugControlsContainer.querySelector("#jsforesight-throttle-value");s&&a&&(s.value=e.resizeScrollThrottleDelay.toString(),a.textContent=e.resizeScrollThrottleDelay.toString())}},e}(),i=function(){function i(){var t=this;this.links=new Map,this.isSetup=!1,this.debugMode=!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},this.positions=[],this.currentPoint={x:0,y:0},this.predictedPoint={x:0,y:0},this.lastResizeScrollCallTimestamp=0,this.resizeScrollThrottleTimeoutId=null,this.normalizeHitSlop=function(e){return"number"==typeof e?{top:e,left:e,right:e,bottom:e}:e},this.predictMousePosition=function(e){var i={point:e,time:performance.now()},n=e.x,o=e.y;if(t.positions.push(i),t.positions.length>t.globalSettings.positionHistorySize&&t.positions.shift(),t.positions.length<2)return{x:n,y:o};var r=t.positions[0],s=t.positions[t.positions.length-1],a=(s.time-r.time)/1e3;if(0===a)return{x:n,y:o};var l=(s.point.x-r.point.x)/a,d=(s.point.y-r.point.y)/a,c=t.globalSettings.trajectoryPredictionTime/1e3;return{x:n+l*c,y:o+d*c}},this.isMouseInExpandedArea=function(e,t,i){var n=t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom;return n&&!i?{isHoveringInArea:!0,shouldRunCallback:!0}:{isHoveringInArea:n,shouldRunCallback:!1}},this.handleMouseMove=function(i){t.currentPoint={x:i.clientX,y:i.clientY},t.predictedPoint=t.globalSettings.enableMousePrediction?t.predictMousePosition(t.currentPoint):t.currentPoint;var n=[];t.links.forEach((function(i,o){if(i.elementBounds.expandedRect){var r=t.isMouseInExpandedArea(i.elementBounds.expandedRect,t.currentPoint,i.isHovering),s=r.isHoveringInArea,a=r.shouldRunCallback,l=!1;t.globalSettings.enableMousePrediction&&!s&&t.lineSegmentIntersectsRect(t.currentPoint,t.predictedPoint,i.elementBounds.expandedRect)&&(i.isTrajectoryHit||(i.callback(),t.links.set(o,e(e({},i),{isTrajectoryHit:!0,trajectoryHitTime:performance.now(),isHovering:s})),l=!0)),i.isHovering!==s&&(t.links.set(o,e(e({},i),{isHovering:s,isTrajectoryHit:t.links.get(o).isTrajectoryHit,trajectoryHitTime:t.links.get(o).trajectoryHitTime})),l=!0),l&&n.push(o),a&&(!i.isTrajectoryHit||i.isTrajectoryHit&&!t.globalSettings.enableMousePrediction)&&i.callback()}})),t.debugMode&&t.debugger&&(n.forEach((function(e){var i=t.links.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.globalSettings.defaultHitSlop=this.normalizeHitSlop(this.globalSettings.defaultHitSlop),setInterval(this.checkTrajectoryHitExpiration.bind(this),100)}return i.initialize=function(e){return i.manager?e&&(console.warn("ForesightManager is already initialized. Use alterGlobalSettings to update settings. Make sure to not put the ForesightManager.initialize() in a place that rerenders often."),i.manager.alterGlobalSettings(e)):(i.manager=new i,e?i.manager.alterGlobalSettings(e):i.manager.globalSettings.debug&&i.manager.turnOnDebugMode()),i.manager.debugMode=i.manager.globalSettings.debug,i.manager},Object.defineProperty(i,"instance",{get:function(){return i.manager?i.manager:this.initialize()},enumerable:!1,configurable:!0}),i.prototype.checkTrajectoryHitExpiration=function(){var t=this,i=performance.now(),n=!1,o=[];this.links.forEach((function(r,s){r.isTrajectoryHit&&i-r.trajectoryHitTime>100&&(t.links.set(s,e(e({},r),{isTrajectoryHit:!1})),n=!0,o.push(s))})),n&&this.debugMode&&this.debugger&&o.forEach((function(e){var i=t.links.get(e);i&&t.debugger&&t.debugger.createOrUpdateLinkOverlay(e,i)}))},i.prototype.register=function(e,t,i,n){var o=this,r=i?this.normalizeHitSlop(i):this.globalSettings.defaultHitSlop,s=e.getBoundingClientRect(),a={callback:t,elementBounds:{expandedRect:this.getExpandedRect(s,r),originalRect:s,hitSlop:r},isHovering:!1,isTrajectoryHit:!1,trajectoryHitTime:0,name:null!=n?n:"Unnamed"};if(this.links.set(e,a),this.setupGlobalListeners(),this.debugMode&&this.debugger){var l=this.links.get(e);l&&this.debugger.createOrUpdateLinkOverlay(e,l)}return function(){return o.unregister(e)}},i.prototype.unregister=function(e){this.links.delete(e),this.debugMode&&this.debugger&&this.debugger.removeLinkOverlay(e),0===this.links.size&&this.isSetup&&this.removeGlobalListeners()},i.prototype.alterGlobalSettings=function(e){var t=!1;void 0!==(null==e?void 0:e.enableMousePrediction)&&this.globalSettings.enableMousePrediction!==e.enableMousePrediction&&(this.globalSettings.enableMousePrediction=e.enableMousePrediction,t=!0,this.globalSettings.enableMousePrediction?this.predictedPoint=this.predictMousePosition(this.currentPoint):this.predictedPoint=this.currentPoint),void 0!==(null==e?void 0:e.debug)&&this.globalSettings.debug!==e.debug&&(this.globalSettings.debug=e.debug,this.globalSettings.debug?this.turnOnDebugMode():this.debugger&&(this.debugger.cleanup(),this.debugger=null),this.debugMode=this.globalSettings.debug),t&&this.globalSettings.debug&&this.debugger&&(this.debugger.updateControlsState(this.globalSettings),this.debugger.updateTrajectoryVisuals(this.currentPoint,this.predictedPoint,this.globalSettings.enableMousePrediction))},i.prototype.turnOnDebugMode=function(){this.debugMode=!0,this.debugger?(this.debugger.updateControlsState(this.globalSettings),this.debugger.updateTrajectoryVisuals(this.currentPoint,this.predictedPoint,this.globalSettings.enableMousePrediction)):(this.debugger=new t(this),this.debugger.initialize(this.links,this.globalSettings,this.currentPoint,this.predictedPoint))},i.prototype.getExpandedRect=function(e,t){return{left:e.left-t.left,right:e.right+t.right,top:e.top-t.top,bottom:e.bottom+t.bottom}},i.prototype.updateExpandedRect=function(t,i){var n=this.links.get(t);if(n){var o=this.getExpandedRect(t.getBoundingClientRect(),i);if(JSON.stringify(o)!==JSON.stringify(n.elementBounds.expandedRect)&&this.links.set(t,e(e({},n),{elementBounds:e(e({},n.elementBounds),{expandedRect:o})})),this.debugMode&&this.debugger){var r=this.links.get(t);r&&this.debugger.createOrUpdateLinkOverlay(t,r)}}},i.prototype.updateAllRects=function(){var e=this;this.links.forEach((function(t,i){e.updateExpandedRect(i,t.elementBounds.hitSlop)}))},i.prototype.lineSegmentIntersectsRect=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)))},i.prototype.setupGlobalListeners=function(){this.isSetup||(document.addEventListener("mousemove",this.handleMouseMove),window.addEventListener("resize",this.handleResizeOrScroll),window.addEventListener("scroll",this.handleResizeOrScroll),this.isSetup=!0)},i.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.isSetup=!1},i}();exports.ForesightManager=i;
|
|
1
|
+
"use strict";var e=function(){return e=Object.assign||function(e){for(var t,i=1,o=arguments.length;i<o;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t=function(){function t(e){this.shadowHost=null,this.shadowRoot=null,this.debugContainer=null,this.debugLinkOverlays=new Map,this.debugPredictedMouseIndicator=null,this.debugTrajectoryLine=null,this.debugControlsContainer=null,this.debugStyleElement=null,this.currentGlobalSettings=null,this.lastElementData=new Map,this.foresightManagerInstance=e}return t.prototype.initialize=function(t,i,o,n){var r=this;"undefined"!=typeof window&&(this.cleanup(),this.currentGlobalSettings=e({},i),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 {\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 blue;\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: orange; background-color: rgba(255, 0, 0, 0.1);\n }\n .jsforesight-link-overlay.trajectory-hit {\n border-color: lime; 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.5);\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 orange; 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-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;\n }\n .jsforesight-debugger-title-container {\n display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px;\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-prefetch-indicator {\n position: absolute;\n background-color: black;\n color: white;\n padding: 3px 6px; /* Smaller padding */\n font-size: 10px; /* Smaller font */\n font-family: Arial, sans-serif;\n font-weight: bold;\n border-radius: 4px; /* Slightly smaller radius */\n z-index: 10002;\n white-space: nowrap;\n pointer-events: none;\n opacity: 1;\n transition: transform 0.6s cubic-bezier(0.15, 0.5, 0.35, 1), /* Shorter duration */\n opacity 0.6s cubic-bezier(0.4, 0, 0.8, 1); /* Shorter duration */\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.createDebugControls(i),this.lastElementData.clear(),t.forEach((function(e,t){r.createOrUpdateLinkOverlay(t,e)})),this.updateTrajectoryVisuals(o,n,i.enableMousePrediction))},t.prototype.cleanup=function(){var e;null===(e=this.shadowHost)||void 0===e||e.remove(),this.shadowHost=null,this.shadowRoot=null,this.debugLinkOverlays.forEach((function(e){e.linkOverlay.remove(),e.expandedOverlay.remove(),e.nameLabel.remove()})),this.debugLinkOverlays.clear(),this.lastElementData.clear(),this.debugContainer&&this.debugContainer.querySelectorAll(".jsforesight-prefetch-indicator").forEach((function(e){return e.remove()}))},t.prototype.showPrefetchAnimation=function(e){if(this.debugContainer){var t=e.getBoundingClientRect();if(0!==t.width||0!==t.height){var i=document.createElement("div");i.className="jsforesight-prefetch-indicator",i.textContent="Prefetched",this.debugContainer.appendChild(i);var o=t.left+t.width/2,n=t.top+t.height/2,r=80*(Math.random()-.5),s=-50-30*Math.random();i.style.left="".concat(o,"px"),i.style.top="".concat(n,"px"),i.style.opacity="1",i.style.transform="translate(-50%, -50%) translate(0px, 0px) scale(0.7)",i.offsetWidth,i.style.opacity="0",i.style.transform="translate(-50%, -50%) translate(".concat(r,"px, ").concat(s,"px) scale(1)"),setTimeout((function(){i.remove()}),800)}}},t.prototype.createOrUpdateLinkOverlay=function(e,t){if(this.debugContainer&&this.shadowRoot){if(this.currentGlobalSettings){var i=this.lastElementData.get(e),o=!1,n=t.isTrajectoryHit&&(!i||!i.isTrajectoryHit),r=t.isHovering&&(!i||!i.isHovering);(n||r&&(!t.isTrajectoryHit||t.isTrajectoryHit&&!this.currentGlobalSettings.enableMousePrediction))&&(o=!0),o&&this.showPrefetchAnimation(e)}this.lastElementData.set(e,{isHovering:t.isHovering,isTrajectoryHit:t.isTrajectoryHit});var s=this.debugLinkOverlays.get(e);if(!s){var a=document.createElement("div");a.className="jsforesight-link-overlay",this.debugContainer.appendChild(a);var l=document.createElement("div");l.className="jsforesight-expanded-overlay",this.debugContainer.appendChild(l);var d=document.createElement("div");d.className="jsforesight-name-label",this.debugContainer.appendChild(d),s={linkOverlay:a,expandedOverlay:l,nameLabel:d},this.debugLinkOverlays.set(e,s)}var c=s.linkOverlay,h=s.expandedOverlay,g=s.nameLabel,u=e.getBoundingClientRect();c.style.left="".concat(u.left,"px"),c.style.top="".concat(u.top,"px"),c.style.width="".concat(u.width,"px"),c.style.height="".concat(u.height,"px"),c.classList.toggle("trajectory-hit",t.isTrajectoryHit),c.classList.toggle("active",t.isHovering),t.elementBounds.expandedRect?(h.style.left="".concat(t.elementBounds.expandedRect.left,"px"),h.style.top="".concat(t.elementBounds.expandedRect.top,"px"),h.style.width="".concat(t.elementBounds.expandedRect.right-t.elementBounds.expandedRect.left,"px"),h.style.height="".concat(t.elementBounds.expandedRect.bottom-t.elementBounds.expandedRect.top,"px"),h.style.display="block"):h.style.display="none",t.name&&"Unnamed"!==t.name?(g.textContent=t.name,g.style.display="block",g.style.left="".concat(u.left,"px"),g.style.top="".concat(u.top-22,"px")):g.style.display="none"}},t.prototype.removeLinkOverlay=function(e){var t=this.debugLinkOverlays.get(e);t&&(t.linkOverlay.remove(),t.expandedOverlay.remove(),t.nameLabel.remove(),this.debugLinkOverlays.delete(e)),this.lastElementData.delete(e)},t.prototype.updateAllLinkVisuals=function(e){var t=this;if(this.shadowRoot&&this.debugContainer){var i=new Set(e.keys());this.debugLinkOverlays.forEach((function(e,o){i.has(o)||t.removeLinkOverlay(o)})),e.forEach((function(e,i){t.createOrUpdateLinkOverlay(i,e)}))}},t.prototype.updateTrajectoryVisuals=function(e,t,i){if(this.shadowRoot&&this.debugContainer&&(this.debugPredictedMouseIndicator&&(this.debugPredictedMouseIndicator.style.left="".concat((null==t?void 0:t.x)||0,"px"),this.debugPredictedMouseIndicator.style.top="".concat((null==t?void 0:t.y)||0,"px"),this.debugPredictedMouseIndicator.style.display=i&&t?"block":"none"),this.debugTrajectoryLine))if(i&&e&&t){var o=t.x-e.x,n=t.y-e.y,r=Math.sqrt(o*o+n*n),s=180*Math.atan2(n,o)/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"},t.prototype.createDebugControls=function(e){var t=this;if(this.shadowRoot){this.debugControlsContainer=document.createElement("div"),this.debugControlsContainer.id="jsforesight-debug-controls",this.shadowRoot.appendChild(this.debugControlsContainer),this.debugControlsContainer.innerHTML='\n <div class="jsforesight-debugger-title-container">\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 <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" '.concat(e.enableMousePrediction?"checked":"",'>\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" value="').concat(e.positionHistorySize,'">\n <span id="jsforesight-history-value">').concat(e.positionHistorySize,'</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" value="').concat(e.trajectoryPredictionTime,'">\n <span id="jsforesight-prediction-value">').concat(e.trajectoryPredictionTime,'</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" value="').concat(e.resizeScrollThrottleDelay,'">\n <span id="jsforesight-throttle-value">').concat(e.resizeScrollThrottleDelay,"</span>\n </div>\n ");var i=this.debugControlsContainer.querySelector("#jsforesight-trajectory-enabled");i.addEventListener("change",(function(){t.foresightManagerInstance.alterGlobalSettings({enableMousePrediction:i.checked})}));var o=this.debugControlsContainer.querySelector("#jsforesight-history-size"),n=this.debugControlsContainer.querySelector("#jsforesight-history-value");o.addEventListener("input",(function(){var e=parseInt(o.value);n.textContent=e.toString(),t.foresightManagerInstance.alterGlobalSettings({positionHistorySize:e})}));var r=this.debugControlsContainer.querySelector("#jsforesight-prediction-time"),s=this.debugControlsContainer.querySelector("#jsforesight-prediction-value");r.addEventListener("input",(function(){var e=parseInt(r.value);s.textContent=e.toString(),t.foresightManagerInstance.alterGlobalSettings({trajectoryPredictionTime:e})}));var a=this.debugControlsContainer.querySelector("#jsforesight-throttle-delay"),l=this.debugControlsContainer.querySelector("#jsforesight-throttle-value");a.addEventListener("input",(function(){var e=parseInt(a.value);l.textContent=e.toString(),t.foresightManagerInstance.alterGlobalSettings({resizeScrollThrottleDelay:e})}))}},t.prototype.updateControlsState=function(t){if(this.currentGlobalSettings=e({},t),this.debugControlsContainer){var i=this.debugControlsContainer.querySelector("#jsforesight-trajectory-enabled");i&&(i.checked=t.enableMousePrediction);var o=this.debugControlsContainer.querySelector("#jsforesight-history-size"),n=this.debugControlsContainer.querySelector("#jsforesight-history-value");o&&n&&(o.value=t.positionHistorySize.toString(),n.textContent=t.positionHistorySize.toString());var r=this.debugControlsContainer.querySelector("#jsforesight-prediction-time"),s=this.debugControlsContainer.querySelector("#jsforesight-prediction-value");r&&s&&(r.value=t.trajectoryPredictionTime.toString(),s.textContent=t.trajectoryPredictionTime.toString());var a=this.debugControlsContainer.querySelector("#jsforesight-throttle-delay"),l=this.debugControlsContainer.querySelector("#jsforesight-throttle-value");a&&l&&(a.value=t.resizeScrollThrottleDelay.toString(),l.textContent=t.resizeScrollThrottleDelay.toString())}},t}(),i=function(){function i(){var t=this;this.elements=new Map,this.isSetup=!1,this.debugMode=!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},this.positions=[],this.currentPoint={x:0,y:0},this.predictedPoint={x:0,y:0},this.lastResizeScrollCallTimestamp=0,this.resizeScrollThrottleTimeoutId=null,this.normalizeHitSlop=function(e){return"number"==typeof e?{top:e,left:e,right:e,bottom:e}:e},this.predictMousePosition=function(e){var i={point:e,time:performance.now()},o=e.x,n=e.y;if(t.positions.push(i),t.positions.length>t.globalSettings.positionHistorySize&&t.positions.shift(),t.positions.length<2)return{x:o,y:n};var r=t.positions[0],s=t.positions[t.positions.length-1],a=(s.time-r.time)/1e3;if(0===a)return{x:o,y:n};var l=(s.point.x-r.point.x)/a,d=(s.point.y-r.point.y)/a,c=t.globalSettings.trajectoryPredictionTime/1e3;return{x:o+l*c,y:n+d*c}},this.handleMouseMove=function(i){t.currentPoint={x:i.clientX,y:i.clientY},t.predictedPoint=t.globalSettings.enableMousePrediction?t.predictMousePosition(t.currentPoint):t.currentPoint;var o=[];t.elements.forEach((function(i,n){var r=e({},i),s=!1,a=r.isHovering,l=r.isTrajectoryHit,d=r.trajectoryHitTime,c=r.elementBounds.expandedRect,h=t.currentPoint.x>=c.left&&t.currentPoint.x<=c.right&&t.currentPoint.y>=c.top&&t.currentPoint.y<=c.bottom,g=!1;if(!t.globalSettings.enableMousePrediction||h||r.isTrajectoryHit||t.lineSegmentIntersectsRect(t.currentPoint,t.predictedPoint,c)&&(g=!0),g&&(r.callback(),s=!0,l=!0,d=performance.now()),h&&!r.isHovering){var u=!r.isTrajectoryHit||r.isTrajectoryHit&&!t.globalSettings.enableMousePrediction;!s&&u&&r.callback()}a=h;var p=e(e({},r),{isHovering:a,isTrajectoryHit:l,trajectoryHitTime:d});(p.isHovering!==r.isHovering||p.isTrajectoryHit!==r.isTrajectoryHit||p.isTrajectoryHit&&p.trajectoryHitTime!==r.trajectoryHitTime)&&(t.elements.set(n,p),o.push(n))})),t.debugMode&&t.debugger&&(o.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,o=t.globalSettings.resizeScrollThrottleDelay;i>=o?(t.updateAllRects(),t.lastResizeScrollCallTimestamp=e,t.resizeScrollThrottleTimeoutId=null):t.resizeScrollThrottleTimeoutId=setTimeout((function(){t.updateAllRects(),t.lastResizeScrollCallTimestamp=performance.now(),t.resizeScrollThrottleTimeoutId=null}),o-i)},this.globalSettings.defaultHitSlop=this.normalizeHitSlop(this.globalSettings.defaultHitSlop),setInterval(this.checkTrajectoryHitExpiration.bind(this),100)}return i.initialize=function(e){return i.manager?e&&(console.warn("ForesightManager is already initialized. Use alterGlobalSettings to update settings. Make sure to not put the ForesightManager.initialize() in a place that rerenders often."),i.manager.alterGlobalSettings(e)):(i.manager=new i,e?i.manager.alterGlobalSettings(e):i.manager.globalSettings.debug&&i.manager.turnOnDebugMode()),i.manager.debugMode=i.manager.globalSettings.debug,i.manager},Object.defineProperty(i,"instance",{get:function(){return i.manager?i.manager:this.initialize()},enumerable:!1,configurable:!0}),i.prototype.checkTrajectoryHitExpiration=function(){var t=this,i=performance.now(),o=!1,n=[];this.elements.forEach((function(r,s){r.isTrajectoryHit&&i-r.trajectoryHitTime>200&&(t.elements.set(s,e(e({},r),{isTrajectoryHit:!1})),o=!0,n.push(s))})),o&&this.debugMode&&this.debugger&&n.forEach((function(e){var i=t.elements.get(e);i&&t.debugger&&t.debugger.createOrUpdateLinkOverlay(e,i)}))},i.prototype.register=function(e,t,i,o){var n=this,r=i?this.normalizeHitSlop(i):this.globalSettings.defaultHitSlop,s=e.getBoundingClientRect(),a={callback:t,elementBounds:{expandedRect:this.getExpandedRect(s,r),originalRect:s,hitSlop:r},isHovering:!1,isTrajectoryHit:!1,trajectoryHitTime:0,name:null!=o?o:"Unnamed"};if(this.elements.set(e,a),this.setupGlobalListeners(),this.debugMode&&this.debugger){var l=this.elements.get(e);l&&this.debugger.createOrUpdateLinkOverlay(e,l)}return function(){return n.unregister(e)}},i.prototype.unregister=function(e){console.log("Unregistering element:",e),this.elements.delete(e),this.debugMode&&this.debugger&&this.debugger.removeLinkOverlay(e),0===this.elements.size&&this.isSetup&&this.removeGlobalListeners()},i.prototype.alterGlobalSettings=function(e){var t=this,i=!1;void 0!==(null==e?void 0:e.positionHistorySize)&&this.globalSettings.positionHistorySize!==e.positionHistorySize&&(this.globalSettings.positionHistorySize=e.positionHistorySize,i=!0),void 0!==(null==e?void 0:e.trajectoryPredictionTime)&&this.globalSettings.trajectoryPredictionTime!==e.trajectoryPredictionTime&&(this.globalSettings.trajectoryPredictionTime=e.trajectoryPredictionTime,i=!0),void 0!==(null==e?void 0:e.enableMousePrediction)&&this.globalSettings.enableMousePrediction!==e.enableMousePrediction&&(this.globalSettings.enableMousePrediction=e.enableMousePrediction,i=!0,this.globalSettings.enableMousePrediction?this.predictedPoint=this.predictMousePosition(this.currentPoint):this.predictedPoint=this.currentPoint),void 0!==(null==e?void 0:e.defaultHitSlop)&&JSON.stringify(this.globalSettings.defaultHitSlop)!==JSON.stringify(this.normalizeHitSlop(e.defaultHitSlop))&&(this.globalSettings.defaultHitSlop=this.normalizeHitSlop(e.defaultHitSlop),i=!0,this.elements.forEach((function(e,i){t.updateExpandedRect(i,e.elementBounds.hitSlop)}))),void 0!==(null==e?void 0:e.resizeScrollThrottleDelay)&&this.globalSettings.resizeScrollThrottleDelay!==e.resizeScrollThrottleDelay&&(this.globalSettings.resizeScrollThrottleDelay=e.resizeScrollThrottleDelay,i=!0),void 0!==(null==e?void 0:e.debug)&&this.globalSettings.debug!==e.debug&&(this.globalSettings.debug=e.debug,i=!0,this.globalSettings.debug?this.turnOnDebugMode():this.debugger&&(this.debugger.cleanup(),this.debugger=null),this.debugMode=this.globalSettings.debug),i&&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,i){t.debugger.createOrUpdateLinkOverlay(i,e)})))},i.prototype.turnOnDebugMode=function(){this.debugMode=!0,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 t(this),this.debugger.initialize(this.elements,this.globalSettings,this.currentPoint,this.predictedPoint))},i.prototype.getExpandedRect=function(e,t){return{left:e.left-t.left,right:e.right+t.right,top:e.top-t.top,bottom:e.bottom+t.bottom}},i.prototype.updateExpandedRect=function(t,i){var o=this.elements.get(t);if(o){var n=t.getBoundingClientRect(),r=this.getExpandedRect(n,i);if(JSON.stringify(r)===JSON.stringify(o.elementBounds.expandedRect)&&JSON.stringify(n)===JSON.stringify(o.elementBounds.originalRect)||this.elements.set(t,e(e({},o),{elementBounds:e(e({},o.elementBounds),{originalRect:n,expandedRect:r})})),this.debugMode&&this.debugger){var s=this.elements.get(t);s&&this.debugger.createOrUpdateLinkOverlay(t,s)}}},i.prototype.updateAllRects=function(){var e=this;this.elements.forEach((function(t,i){e.updateExpandedRect(i,t.elementBounds.hitSlop)}))},i.prototype.lineSegmentIntersectsRect=function(e,t,i){var o=0,n=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>n)return!1;i>o&&(o=i)}else{if(i<o)return!1;i<n&&(n=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)&&o<=n)))},i.prototype.setupGlobalListeners=function(){this.isSetup||(document.addEventListener("mousemove",this.handleMouseMove),window.addEventListener("resize",this.handleResizeOrScroll),window.addEventListener("scroll",this.handleResizeOrScroll),this.isSetup=!0)},i.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.isSetup=!1},i}();exports.ForesightManager=i;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js.foresight",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "Predicts mouse trajectory to trigger actions as users approach elements, enabling anticipatory UI updates or pre-loading. Made with vanilla javascript and usable in every framework.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|