/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/spatial-navigation-polyfill@1.3.1/polyfill/spatial-navigation-polyfill.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
!function(){if("navigate"in window)return;const t={37:"left",38:"up",39:"right",40:"down"};let e=null,n=null,o={element:null,rect:null},i=null;function a(){window.addEventListener("keydown",(o=>{const i=parent&&parent.__spatialNavigation__.keyMode||window.__spatialNavigation__.keyMode,a=document.activeElement,l=t[o.keyCode];if(9===o.keyCode&&(n=null),!(!i||"NONE"===i||"SHIFTARROW"===i&&!o.shiftKey||"ARROW"===i&&o.shiftKey||o.defaultPrevented)){let i={left:!0,up:!0,right:!0,down:!0};"INPUT"!==a.nodeName&&"TEXTAREA"!==a.nodeName||(i=function(e){const n=["email","date","month","number","time","week"],o=["password","text","search","tel","url",null],i=document.activeElement,a=i.selectionStart,r=i.selectionEnd,l={left:!1,up:!1,right:!1,down:!1},c=t[e.keyCode];if(void 0===c)return l;(!n.includes(i.getAttribute("type"))||"up"!==c&&"down"!==c)&&(o.includes(i.getAttribute("type"))||"TEXTAREA"===i.nodeName)?a===r&&(0===a&&(l.left=!0,l.up=!0),r===i.value.length&&(l.right=!0,l.down=!0)):l[c]=!0;return l}(o)),i[l]&&(o.preventDefault(),e=new Map,r(l),e=null,n=null)}})),document.addEventListener("mouseup",(t=>{n={x:t.clientX,y:t.clientY}})),window.addEventListener("focusin",(t=>{t.target!==window&&(o.element=t.target,o.rect=t.target.getBoundingClientRect())}))}function r(t){const e=function(){let t=document.activeElement;if(!t||t===document.body&&!document.querySelector(":focus")){if(o.element&&t!==o.element){const e=window.getComputedStyle(o.element,null),n=["hidden","collapse"];if(o.element.disabled||n.includes(e.getPropertyValue("visibility")))return t=o.element,t}t=document.documentElement}!o.element||0!==X(o.element).height&&0!==X(o.element).width||(i=o.rect);if(!A(t)){const e=h(t);if(e&&(e===window||"auto"===E(e)))return e}return t}();let a=e,r=null;n&&(r=document.elementFromPoint(n.x,n.y),null===r&&(r=document.body),_(r)&&!v(r)?n=null:a=v(r)?r:r.getSpatialNavigationContainer()),a!==document&&a!==document.documentElement||(a=document.body||document.documentElement);let d=null;if((v(a)||"BODY"===a.nodeName)&&"INPUT"!==a.nodeName){"IFRAME"===a.nodeName&&(a=a.contentDocument.documentElement),d=a;let n=null;if(document.activeElement===e||document.activeElement===document.body&&e===document.documentElement){if("scroll"===E(a)){if(c(a,t))return}else if("focus"===E(a)){if(n=a.spatialNavigationSearch(t,{container:a,candidates:u(a,{mode:"all"})}),l(n,t))return}else if("auto"===E(a)&&(n=a.spatialNavigationSearch(t,{container:a}),l(n,t)||c(a,t)))return}else d=d.getSpatialNavigationContainer()}d=a.getSpatialNavigationContainer();let s=d.parentElement?d.getSpatialNavigationContainer():null;if(s||window.location===window.parent.location||(s=window.parent.document.documentElement),"scroll"===E(d)){if(c(d,t))return}else"focus"===E(d)?N(a,d,s,t,"all"):"auto"===E(d)&&N(a,d,s,t,"visible")}function l(t,e){if(t){if(!y("beforefocus",t,null,e))return!0;const o=t.getSpatialNavigationContainer();return o!==window&&"focus"===E(o)?t.focus():t.focus({preventScroll:!0}),n=null,!0}return!1}function c(t,e){return C(t,e)&&!k(t,e)?(P(t,e),!0):!t.parentElement&&!T(t,e)&&(P(t.ownerDocument.documentElement,e),!0)}function u(t,e={mode:"visible"}){let n=[];if(t.childElementCount>0){t.parentElement||(t=t.getElementsByTagName("body")[0]||document.body);const e=t.children;for(const t of e)x(t)?n.push(t):_(t)?(n.push(t),!v(t)&&t.childElementCount&&(n=n.concat(u(t,{mode:"all"})))):t.childElementCount&&(n=n.concat(u(t,{mode:"all"})))}return"all"===e.mode?n:n.filter(I)}function d(t,e,n,o){const i=t;return o=o||i.getSpatialNavigationContainer(),m(i,n=!n||n.length<=0?u(o):n,e,o)}function s(t,e){const o=this;let a,r=[],l=[],c=function(t){const e=t.getSpatialNavigationContainer(),n=e.focusableAreas(),o=[];return n.forEach((e=>{t!==e&&R(e,t)&&o.push(e)})),o}(o);e||(e={});const s=o.getSpatialNavigationContainer();let m=u(s);const p=e.container||s;e.container&&s.contains(e.container)&&(m=m.concat(u(p)));const h=e.candidates&&e.candidates.length>0?e.candidates.filter((t=>p.contains(t))):m.filter((t=>p.contains(t)&&p!==t));if(h&&h.length>0){h.forEach((t=>{t!==o&&(o.contains(t)&&o!==t?r:l).push(t)}));let e=c.filter((t=>!r.includes(t))),s=h.filter((t=>v(t)&&R(o,t))).map((t=>t.focusableAreas())).flat().filter((t=>t!==o));if(r=r.concat(e).filter((t=>p.contains(t))),l=l.concat(s).filter((t=>p.contains(t))),l.length>0&&(l=d(o,t,l,p)),i&&(a=f(o,d(o,t,r,p),t)),r&&r.length>0&&"INPUT"!==o.nodeName&&(a=function(t,e,o){return g(t,e,o,n?H:L)}(o,r,t)),a=a||f(o,l,t),a&&x(a)){const e=u(a,{mode:"all"}),n=e.length>0?o.spatialNavigationSearch(t,{candidates:e,container:a}):null;n?a=n:_(a)||(h.splice(h.indexOf(a),1),a=h.length?o.spatialNavigationSearch(t,{candidates:h,container:p}):null)}return a}return null}function m(t,e,n,o){const a=t.getSpatialNavigationContainer();let r;return void 0===n?e:(r=a.parentElement&&o!==a&&!I(t)?X(a):i||X(t),!v(t)&&"BODY"!==t.nodeName||"INPUT"===t.nodeName?e.filter((e=>{const i=X(e),a="IFRAME"===e.nodeName?e.contentDocument.body:null;return o.contains(e)&&e!==t&&a!==t&&F(i,r,n)&&!D(r,i)})):e.filter((e=>{const i=X(e);return o.contains(e)&&(t.contains(e)&&D(r,i)&&e!==t||F(i,r,n))})))}function f(t,e,n){const o=t.getSpatialNavigationContainer(),a=getComputedStyle(o).getPropertyValue("--spatial-navigation-function"),r=i||X(t);let l,c;if("grid"===a)c=e.filter((t=>B(r,X(t),n))),c.length>0&&(e=c),l=q;else l=U;return g(t,e,n,l)}function g(t,e,n,o){let a=null;window.location===window.parent.location||"BODY"!==t.nodeName&&"HTML"!==t.nodeName?a=i||t.getBoundingClientRect():(a=window.frameElement.getBoundingClientRect(),a.x=0,a.y=0);let r=Number.POSITIVE_INFINITY,l=[];if(e)for(let t=0;t<e.length;t++){const i=o(a,X(e[t]),n);i<r?(r=i,l=[e[t]]):i===r&&l.push(e[t])}return 0===l.length?null:l.length>1&&o===q?g(t,l,n,Y):l[0]}function p(){let t=this;do{if(!t.parentElement){t=window.location!==window.parent.location?window.parent.document.documentElement:window.document.documentElement;break}t=t.parentElement}while(!v(t));return t}function h(t){let e=t;do{if(!e.parentElement){e=window.location!==window.parent.location?window.parent.document.documentElement:window.document.documentElement;break}e=e.parentElement}while(!S(e)||!I(e));return e!==document&&e!==document.documentElement||(e=window),e}function w(t={mode:"visible"}){const e=this.parentElement?this:document.body,n=Array.prototype.filter.call(e.getElementsByTagName("*"),_);return"all"===t.mode?n:n.filter(I)}function y(t,e,n,o){if(["beforefocus","notarget"].includes(t)){const i=new CustomEvent("nav"+t,{bubbles:!0,cancelable:!0,detail:{causedTarget:n,dir:o}});return e.dispatchEvent(i)}}function b(t,e){return t.style.getPropertyValue(`--${e}`).trim()}function E(t){return b(t,"spatial-navigation-action")||"auto"}function N(t,e,n,o,i){let a={candidates:u(e,{mode:i}),container:e};for(;n;){if(l(t.spatialNavigationSearch(o,a),o))return;if("visible"===i&&c(e,o))return;{if(!y("notarget",e,t,o))return;e===document||e===document.documentElement?window.location!==window.parent.location&&(e=(t=window.frameElement).ownerDocument.documentElement):e=n,a={candidates:u(e,{mode:i}),container:e};let r=e.getSpatialNavigationContainer();n=r!==e?r:null}}a={candidates:u(e,{mode:i}),container:e},!n&&e&&l(t.spatialNavigationSearch(o,a),o)||y("notarget",a.container,t,o)&&("auto"!==E(e)||"visible"!==i||c(e,o))}function P(t,e,n=0){if(t)switch(e){case"left":t.scrollLeft-=40+n;break;case"right":t.scrollLeft+=40+n;break;case"up":t.scrollTop-=40+n;break;case"down":t.scrollTop+=40+n}}function v(t){return!t.parentElement||"IFRAME"===t.nodeName||S(t)||function(t){return"contain"===b(t,"spatial-navigation-contain")}(t)}function x(t){return"delegable"===b(t,"spatial-navigation-contain")}function S(t){const e=window.getComputedStyle(t,null),n=e.getPropertyValue("overflow-x"),o=e.getPropertyValue("overflow-y");return!!("visible"!==n&&"clip"!==n&&M(t,"left")||"visible"!==o&&"clip"!==o&&M(t,"down"))}function C(t,e){if(t&&"object"==typeof t){if(e&&"string"==typeof e){if(M(t,e)){const n=window.getComputedStyle(t,null),o=n.getPropertyValue("overflow-x"),i=n.getPropertyValue("overflow-y");switch(e){case"left":case"right":return"visible"!==o&&"clip"!==o&&"hidden"!==o;case"up":case"down":return"visible"!==i&&"clip"!==i&&"hidden"!==i}}return!1}return"HTML"===t.nodeName||"BODY"===t.nodeName||S(t)&&M(t)}}function M(t,e){if(t&&"object"==typeof t){if(!e||"string"!=typeof e)return t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight;switch(e){case"left":case"right":return t.scrollWidth>t.clientWidth;case"up":case"down":return t.scrollHeight>t.clientHeight}return!1}}function T(t,e){let n=!1;switch(e){case"left":n=0===t.scrollLeft;break;case"right":n=t.scrollWidth-t.scrollLeft-t.clientWidth==0;break;case"up":n=0===t.scrollTop;break;case"down":n=t.scrollHeight-t.scrollTop-t.clientHeight==0}return n}function k(t,e){if(C(t,e)){const n=t.scrollTop,o=t.scrollLeft,i=t.scrollHeight-t.clientHeight,a=t.scrollWidth-t.clientWidth;switch(e){case"left":return 0===o;case"right":return Math.abs(o-a)<=1;case"up":return 0===n;case"down":return Math.abs(n-i)<=1}}return!1}function A(t){const e=t.getBoundingClientRect();let n=h(t),o=null;return o=n!==window?X(n):new DOMRect(0,0,window.innerWidth,window.innerHeight),!(!D(o,e)||!D(o,e))}function _(t){return!(t.tabIndex<0||function(t){return"A"===t.tagName&&null===t.getAttribute("href")&&null===t.getAttribute("tabIndex")}(t)||function(t){return!!["BUTTON","INPUT","SELECT","TEXTAREA","OPTGROUP","OPTION","FIELDSET"].includes(t.tagName)&&t.disabled}(t)||function(t){return t.inert&&!t.ownerDocument.documentElement.inert}(t)||!function(t){return!!O(t.parentElement)&&!(!O(t)||"0"===t.style.opacity||"0px"===window.getComputedStyle(t).height||"0px"===window.getComputedStyle(t).width)}(t))&&(!!(!t.parentElement||C(t)&&M(t)||t.tabIndex>=0)||void 0)}function I(t){return!t.parentElement||O(t)&&function(t){const e=X(t);if("IFRAME"!==t.nodeName&&(e.top<0||e.left<0||e.top>t.ownerDocument.documentElement.clientHeight||e.left>t.ownerDocument.documentElement.clientWidth))return!1;let n=parseInt(t.offsetWidth)/10,o=parseInt(t.offsetHeight)/10;n=isNaN(n)?1:n,o=isNaN(o)?1:o;const i={middle:[(e.left+e.right)/2,(e.top+e.bottom)/2],leftTop:[e.left+n,e.top+o],rightBottom:[e.right-n,e.bottom-o]};for(const e in i){const n=t.ownerDocument.elementFromPoint(...i[e]);if(t===n||t.contains(n))return!0}return!1}(t)}function R(t,e){const n=X(t),o=X(e||t.getSpatialNavigationContainer());return!(n.left<o.left||n.right>o.right||n.top<o.top||n.bottom>o.bottom)}function O(t){const e=window.getComputedStyle(t,null),n=e.getPropertyValue("visibility");return"none"!==e.getPropertyValue("display")&&!["hidden","collapse"].includes(n)}function D(t,e){const n=t.left<=e.right&&t.right>=e.right,o=t.left<=e.left&&t.right>=e.left,i=t.top<=e.top&&t.bottom>=e.top,a=t.top<=e.bottom&&t.bottom>=e.bottom;return(n||o)&&(i||a)}function F(t,e,n){switch(n){case"left":return V(e,t);case"right":return V(t,e);case"up":return W(e,t);case"down":return W(t,e);default:return!1}}function V(t,e){return t.left>=e.right||t.left>=e.left&&t.right>e.right&&t.bottom>e.top&&t.top<e.bottom}function W(t,e){return t.top>=e.bottom||t.top>=e.top&&t.bottom>e.bottom&&t.left<e.right&&t.right>e.left}function B(t,e,n){switch(n){case"left":case"right":return t.bottom>e.top&&t.top<e.bottom;case"up":case"down":return t.right>e.left&&t.left<e.right;default:return!1}}function H(t,e,o){const i=j(o,n,e),a=Math.abs(i.entryPoint.x-i.exitPoint.x),r=Math.abs(i.entryPoint.y-i.exitPoint.y);return Math.sqrt(Math.pow(a,2)+Math.pow(r,2))}function L(t,e,n){const o={left:"right",right:"left",up:"bottom",down:"top"}[n];return Math.abs(t[o]-e[o])}function U(t,e,n){let o=0,i=0;const a=j(n,t,e),r=Math.abs(a.entryPoint.x-a.exitPoint.x),l=Math.abs(a.entryPoint.y-a.exitPoint.y),c=Math.sqrt(Math.pow(r,2)+Math.pow(l,2));let u,d;const s=function(t,e){const n={width:0,height:0,area:0},o=[Math.max(t.left,e.left),Math.max(t.top,e.top)],i=[Math.min(t.right,e.right),Math.min(t.bottom,e.bottom)];n.width=Math.abs(o[0]-i[0]),n.height=Math.abs(o[1]-i[1]),o[0]>=i[0]||o[1]>=i[1]||(n.area=Math.sqrt(n.width*n.height));return n}(t,e),m=s.area;switch(n){case"left":case"right":B(t,e,n)?i=Math.min(s.height/t.height,1):o=t.height/2,u=30*(l+o),d=5*i;break;case"up":case"down":B(t,e,n)?i=Math.min(s.width/t.width,1):o=t.width/2,u=2*(r+o),d=5*i;break;default:u=0,d=0}return c+u-d-m}function Y(t,e,n){const o=j(n,t,e),i=Math.abs(o.entryPoint.x-o.exitPoint.x),a=Math.abs(o.entryPoint.y-o.exitPoint.y);return Math.sqrt(Math.pow(i,2)+Math.pow(a,2))}function q(t,e,n){const o=j(n,t,e);return"left"===n||"right"===n?Math.abs(o.entryPoint.x-o.exitPoint.x):Math.abs(o.entryPoint.y-o.exitPoint.y)}function j(t="down",e,o){const i={entryPoint:{x:0,y:0},exitPoint:{x:0,y:0}};if(n){switch(i.exitPoint=e,t){case"left":i.entryPoint.x=o.right;break;case"up":i.entryPoint.y=o.bottom;break;case"right":i.entryPoint.x=o.left;break;case"down":i.entryPoint.y=o.top}switch(t){case"left":case"right":n.y<=o.top?i.entryPoint.y=o.top:n.y<o.bottom?i.entryPoint.y=n.y:i.entryPoint.y=o.bottom;break;case"up":case"down":n.x<=o.left?i.entryPoint.x=o.left:n.x<o.right?i.entryPoint.x=n.x:i.entryPoint.x=o.right}}else{switch(t){case"left":i.exitPoint.x=e.left,i.entryPoint.x=o.right<e.left?o.right:e.left;break;case"up":i.exitPoint.y=e.top,i.entryPoint.y=o.bottom<e.top?o.bottom:e.top;break;case"right":i.exitPoint.x=e.right,i.entryPoint.x=o.left>e.right?o.left:e.right;break;case"down":i.exitPoint.y=e.bottom,i.entryPoint.y=o.top>e.bottom?o.top:e.bottom}switch(t){case"left":case"right":W(e,o)?(i.exitPoint.y=e.top,i.entryPoint.y=o.bottom<e.top?o.bottom:e.top):W(o,e)?(i.exitPoint.y=e.bottom,i.entryPoint.y=o.top>e.bottom?o.top:e.bottom):(i.exitPoint.y=Math.max(e.top,o.top),i.entryPoint.y=i.exitPoint.y);break;case"up":case"down":V(e,o)?(i.exitPoint.x=e.left,i.entryPoint.x=o.right<e.left?o.right:e.left):V(o,e)?(i.exitPoint.x=e.right,i.entryPoint.x=o.left>e.right?o.left:e.right):(i.exitPoint.x=Math.max(e.left,o.left),i.entryPoint.x=i.exitPoint.x)}}return i}function X(t){let n=e&&e.get(t);if(!n){const o=t.getBoundingClientRect();n={top:Number(o.top.toFixed(2)),right:Number(o.right.toFixed(2)),bottom:Number(o.bottom.toFixed(2)),left:Number(o.left.toFixed(2)),width:Number(o.width.toFixed(2)),height:Number(o.height.toFixed(2))},e&&e.set(t,n)}return n}function K(t){const e=window.__spatialNavigation__&&window.__spatialNavigation__.keyMode;window.__spatialNavigation__=!1===t?G():Object.assign(G(),function(){function t(t,e){return C(t,e)&&!k(t,e)||!t.parentElement&&!T(t,e)}function e(e,n,o,i){let a=n,r=null;if(a!==document&&a!==document.documentElement||(a=document.body||document.documentElement),(v(a)||"BODY"===a.nodeName)&&"INPUT"!==a.nodeName){"IFRAME"===a.nodeName&&(a=a.contentDocument.body);const n=u(a,i);if(Array.isArray(n)&&n.length>0)return e?d(a,o,n):a.spatialNavigationSearch(o,{candidates:n});if(t(a,o))return e?[]:a}let l=a.getSpatialNavigationContainer(),c=l.parentElement?l.getSpatialNavigationContainer():null;for(c||window.location===window.parent.location||(c=window.parent.document.documentElement);c;){const n=m(a,u(l,i),o,l);if(Array.isArray(n)&&n.length>0){if(r=a.spatialNavigationSearch(o,{candidates:n,container:l}),r)return e?n:r}else{if(t(l,o))return e?[]:a;if(l===document||l===document.documentElement){if(l=window.document.documentElement,window.location!==window.parent.location){if(a=window.frameElement,l=window.parent.document.documentElement,!l.parentElement){c=null;break}c=l.getSpatialNavigationContainer()}}else{if(_(l)&&(a=l),l=c,!l.parentElement){c=null;break}c=l.getSpatialNavigationContainer()}}}if(!c&&l){const t=m(a,u(l,i),o,l);if(Array.isArray(t)&&t.length>0&&(r=a.spatialNavigationSearch(o,{candidates:t,container:l}),r))return e?t:r}if(t(l,o))return r=a,r}return{isContainer:v,isScrollContainer:S,isVisibleInScroller:A,findCandidates:e.bind(null,!0),findNextTarget:e.bind(null,!1),getDistanceFromTarget:(t,e,n)=>(v(t)||"BODY"===t.nodeName)&&"INPUT"!==t.nodeName&&u(t).includes(e)?L(X(t),X(e),n):U(X(t),X(e),n)}}()),window.__spatialNavigation__.keyMode=e,Object.seal(window.__spatialNavigation__)}function G(){return{enableExperimentalAPIs:K,get keyMode(){return this._keymode?this._keymode:"ARROW"},set keyMode(t){this._keymode=["SHIFTARROW","ARROW","NONE"].includes(t)?t:"ARROW"},setStartingPoint:function(t,e){n=t&&e?{x:t,y:e}:null}}}window.navigate=r,window.Element.prototype.spatialNavigationSearch=s,window.Element.prototype.focusableAreas=w,window.Element.prototype.getSpatialNavigationContainer=p,window.CSS&&CSS.registerProperty&&(""===window.getComputedStyle(document.documentElement).getPropertyValue("--spatial-navigation-contain")&&CSS.registerProperty({name:"--spatial-navigation-contain",syntax:"auto | contain",inherits:!1,initialValue:"auto"}),""===window.getComputedStyle(document.documentElement).getPropertyValue("--spatial-navigation-action")&&CSS.registerProperty({name:"--spatial-navigation-action",syntax:"auto | focus | scroll",inherits:!1,initialValue:"auto"}),""===window.getComputedStyle(document.documentElement).getPropertyValue("--spatial-navigation-function")&&CSS.registerProperty({name:"--spatial-navigation-function",syntax:"normal | grid",inherits:!1,initialValue:"normal"})),K(!1),window.addEventListener("load",(()=>{a()}))}();
//# sourceMappingURL=/sm/f66fc02ba2816429b2e04d397988c513dc91939469bc2ccfd970ff60ae0816b7.map