Anvil/assets/MainMenu-D_vXKozu.js

2 lines
18 KiB
JavaScript
Raw Normal View History

2024-07-08 12:23:04 +02:00
import{u as rn,S as Kt,c as Xt,a as Yt,d as m,e as $,m as v,v as sn,n as Jt,b as g,t as x,f as h}from"./index-D5xIMA44.js";import{a as n,b as l,f as r,h as c,k as o,p as S,d as f,l as s,i as ft,m as e}from"./lifecycle-u0QeOdKt.js";import"./XPro-CcJiQdsL.js";import"./runtime-_7zi23uk.js";import{P as Zt,k as en,l as tn,B as an,R as ln,i as Wt,m as on,n as Lt,o as fn,p as un,G as cn,q as dn,r as pn,s as mn,L as $n,t as vn,u as gn,v as xn}from"./ZoomOut24-DVPD-K2C.js";import{w as hn}from"./index-Chhuq4i3.js";import{O as wn}from"./OverlayAvatar-rzKeWOS7.js";const bn=hn(void 0);function Cn(w,t){const{computePosition:y,autoUpdate:H,offset:G,shift:E,flip:z,arrow:te,size:D,autoPlacement:X,hide:O,inline:T}=rn(bn),P={open:!1,autoUpdateCleanup:()=>{}},U=':is(a[href], button, input, textarea, select, details, [tabindex]):not([tabindex="-1"])';let p;const C="https://www.skeleton.dev/utilities/popups";let i,F;function M(){i=document.querySelector(`[data-popup="${t.target}"]`)??document.createElement("div"),F=i.querySelector(".arrow")??document.createElement("div")}M();function J(){var V,_,ne,Z,k,q,ee,j;if(!i)throw new Error(`The data-popup="${t.target}" element was not found. ${C}`);if(!y)throw new Error(`Floating UI 'computePosition' not found for data-popup="${t.target}". ${C}`);if(!G)throw new Error(`Floating UI 'offset' not found for data-popup="${t.target}". ${C}`);if(!E)throw new Error(`Floating UI 'shift' not found for data-popup="${t.target}". ${C}`);if(!z)throw new Error(`Floating UI 'flip' not found for data-popup="${t.target}". ${C}`);if(!te)throw new Error(`Floating UI 'arrow' not found for data-popup="${t.target}". ${C}`);const u=[];D&&u.push(D((V=t.middleware)==null?void 0:V.size)),X&&u.push(X((_=t.middleware)==null?void 0:_.autoPlacement)),O&&u.push(O((ne=t.middleware)==null?void 0:ne.hide)),T&&u.push(T((Z=t.middleware)==null?void 0:Z.inline)),y(w,i,{placement:t.placement??"bottom",middleware:[G(((k=t.middleware)==null?void 0:k.offset)??8),E(((q=t.middleware)==null?void 0:q.shift)??{padding:8}),z((ee=t.middleware)==null?void 0:ee.flip),te(((j=t.middleware)==null?void 0:j.arrow)??{element:F||null}),...u]}).then(({x:we,y:d,placement:L,middlewareData:B})=>{if(Object.assign(i.style,{left:`${we}px`,top:`${d}px`}),F){const{x:Q,y:W}=B.arrow,de={top:"bottom",right:"left",bottom:"top",left:"right"}[L.split("-")[0]];Object.assign(F.style,{left:Q!=null?`${Q}px`:"",top:W!=null?`${W}px`:"",right:"",bottom:"",[de]:"-4px"})}})}function N(){i&&(P.open=!0,t.state&&t.state({state:P.open}),J(),i.style.display="block",i.style.opacity="1",i.style.pointerEvents="auto",i.removeAttribute("inert"),P.autoUpdateCleanup=H(w,i,J),p=Array.from(i==null?void 0:i.querySelectorAll(U)))}function A(u){if(!i)return;const V=parseFloat(window.getComputedStyle(i).transitionDuration.replace("s",""))*1e3;setTimeout(()=>{P.open=!1,t.state&&t.state({state:P.open}),i.style.opacity="0",i.setAttribute("inert",""),P.autoUpdateCleanup&&P.autoUpdateCleanup(),u&&u()},V)}function Y(){P.open===!1?N():A()}function b(u){if(P.open===!1||w.contains(u.target))return;if(i&&i.contains(u.target)===!1){A();return}const V=t.closeQuery===void 0?"a[href], button":t.closeQuery;if(V==="")return;const _=i==null?void 0:i.querySelectorAll(V);_==null||_.forEach(ne=>{ne.contains(u.target)&&A()})}const I=u=>{if(P.open===!1)return;const V=u.key;if(V==="Escape"){u.preventDefault(),w.focus(),A();return}p=Array.from(i==null?void 0:i.querySelectorAll(U)),P.open&&document.activeElement===w&&(V==="ArrowDown"||V==="Tab")&&U.length>0&&p.length>0&&(u.preventDefault(),p[0].focus())};switch(t.event){case"click":w.addEventListener("click",Y,!0),window.addEventListener("click",b,!0);break;case"hover":w.addEventListener("mouseover",N,!0),w.addEventListener("mouseleave",()=>A(),!0);break;case"focus-blur":w.addEventListener("focus",Y,!0),w.addEventListener("blur",()=>A(),!0);break;case"focus-click":w.addEventListener("focus",N,!0),window.addEventListener("click",b,!0);break;default:throw new Error(`Event value of '${t.event}' is not supported. ${C}`)}return window.addEventListener("keydown",I,!0),J(),{update