Files
yoapuesto/wp-content/plugins/yabe-webfont/assets/dist/assets/getPseudoElementBounds-VHBO4Fpp.js
T

1 line
8.2 KiB
JavaScript

import{r as e}from"./rolldown-runtime-hePW80VL.js";import{F as t,S as n,W as r,c as i,l as a,y as o}from"./button-BhAQo6Sy.js";import{A as s,E as ee,_ as c,x as l}from"./api-Bb85n68L.js";import{Ct as u,Dt as d,L as f,R as p,St as m,_t as h,at as g,bt as _,dt as v,gt as y,ht as b,lt as te,mt as x,xt as S,yt as ne}from"./usePositioner-BR1Prb1t.js";import{l as re}from"./useAnchoredPopupScrollLock-ufKQIYDq.js";import{a as ie,c as ae,d as C,f as oe,i as w,l as T,o as se,p as ce,s as E,u as le}from"./input-DbQb1wvc.js";var D=e(r(),1),O=`Escape`;function ue(e){return u&&e.movementX===0&&e.movementY===0}function k(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function A(e,t){return k(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function de(e,t,n){return k(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function fe(e,t,n){return k(t,n?e===b:e===y,e===x)}function pe(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===O:k(t,n?e===y:e===b,e===h)}function j(e,t){let{listRef:r,activeIndex:o,onNavigate:u=()=>{},enabled:d=!0,selectedIndex:m=null,allowEscape:h=!1,loopFocus:y=!1,nested:b=!1,rtl:x=!1,virtual:T=!1,focusItemOnOpen:E=`auto`,focusItemOnHover:O=!0,openOnArrowKeyDown:k=!0,disabledIndices:j=void 0,orientation:M=`vertical`,parentOrientation:N,id:me,resetOnPointerLeave:he=!0,externalTree:ge,grid:_e}=t,ve=_e!=null,P=`rootStore`in e?e.rootStore:e,F=P.useState(`open`),I=P.useState(`floatingElement`),L=P.useState(`domReferenceElement`),ye=P.context.dataRef,be=te(I),xe=v(L),R=g(be),Se=f(),z=p(ge),B=D.useRef(E),V=D.useRef(m??-1),H=D.useRef(null),U=D.useRef(!0),W=a(e=>{u(V.current===-1?null:V.current,e)}),G=D.useRef(!!I),Ce=D.useRef(F),K=D.useRef(!1),q=D.useRef(!1),we=D.useRef(null),Te=g(j),J=g(F),Y=g(m),Ee=g(he),De=c(),Oe=c(),ke=a(()=>{function e(e){T?z?.events.emit(`virtualfocus`,e):we.current=re(e,{sync:K.current,preventScroll:!0})}let t=r.current[V.current],n=q.current;t&&e(t),(K.current?e=>e():e=>De.request(e))(()=>{let i=r.current[V.current]||t;i&&(t||e(i),Ne&&(n||!U.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});i(()=>{ye.current.orientation=M},[ye,M]),i(()=>{d&&(F&&I?(V.current=m??-1,B.current&&m!=null&&(q.current=!0,W())):G.current&&(V.current=-1,W()))},[d,F,I,m,W]),i(()=>{if(d){if(!F){K.current=!1;return}if(I)if(o==null){if(K.current=!1,Y.current!=null)return;if(G.current&&(V.current=-1,ke()),(!Ce.current||!G.current)&&B.current&&(H.current!=null||B.current===!0&&H.current==null)){let e=0,t=()=>{r.current[0]==null?(e<2&&(e?e=>Oe.request(e):queueMicrotask)(t),e+=1):(V.current=H.current==null||de(H.current,M,x)||b?se(r):ie(r),H.current=null,W())};t()}}else ae(r.current,o)||(V.current=o,ke(),q.current=!1)}},[d,F,I,o,Y,b,r,M,x,W,ke,Oe]),i(()=>{if(!d||I||!z||T||!G.current)return;let e=z.nodesRef.current,t=e.find(e=>e.id===Se)?.context?.elements.floating,n=le(ce(L??t??null)),r=e.some(e=>e.context&&C(e.context.elements.floating,n));t&&!r&&U.current&&t.focus({preventScroll:!0})},[d,I,L,z,Se,T]),i(()=>{Ce.current=F,G.current=!!I}),i(()=>{F||(H.current=null,B.current=E)},[F,E]);let Ae=o!=null,je=a(e=>{if(!J.current)return;let t=r.current.indexOf(e.currentTarget);t!==-1&&(V.current!==t||o!==t)&&(V.current=t,W(e))}),X=a(()=>N??z?.nodesRef.current.find(e=>e.id===Se)?.context?.dataRef?.current.orientation),Me=a(()=>se(r,Te.current)),Z=a(e=>{if(U.current=!1,K.current=!0,e.which===229||!J.current&&e.currentTarget===R.current)return;if(b&&pe(e.key,M,x,ve)){A(e.key,X())||S(e),P.setOpen(!1,l(s,e.nativeEvent)),n(L)&&(T?z?.events.emit(`virtualfocus`,L):L.focus());return}let t=V.current,i=se(r,j),a=ie(r,j);if(xe||(e.key===`Home`&&(S(e),V.current=i,W(e)),e.key===`End`&&(S(e),V.current=a,W(e))),_e!=null){let t=_e(e,V.current,r,M,y,x,j,i,a);if(t!=null&&(V.current=t,W(e)),M===`both`)return}if(A(e.key,M)){if(S(e),F&&!T&&le(e.currentTarget.ownerDocument)===e.currentTarget){V.current=de(e.key,M,x)?i:a,W(e);return}de(e.key,M,x)?y?t>=a?h&&t!==r.current.length?V.current=-1:(K.current=!1,V.current=i):V.current=w(r.current,{startingIndex:t,disabledIndices:j}):V.current=Math.min(a,w(r.current,{startingIndex:t,disabledIndices:j})):y?t<=i?h&&t!==-1?V.current=r.current.length:(K.current=!1,V.current=a):V.current=w(r.current,{startingIndex:t,decrement:!0,disabledIndices:j}):V.current=Math.max(i,w(r.current,{startingIndex:t,decrement:!0,disabledIndices:j})),ae(r.current,V.current)&&(V.current=-1),W(e)}}),Ne=D.useMemo(()=>({onFocus(e){K.current=!0,je(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){ue(e)||(K.current=!0,q.current=!1,O&&je(e))},onPointerLeave(e){if(!J.current||!U.current||e.pointerType===`touch`)return;K.current=!0;let t=e.relatedTarget;if(!(!O||r.current.includes(t))&&Ee.current&&(we.current?.(),we.current=null,V.current=-1,W(e),!T)){let e=R.current,t=le(ce(e));e&&C(e,t)&&e.focus({preventScroll:!0})}}}),[je,J,R,O,r,W,Ee,T]),Q=D.useMemo(()=>T&&F&&Ae&&{"aria-activedescendant":`${me}-${o}`},[T,F,Ae,me,o]),Pe=D.useMemo(()=>({"aria-orientation":M===`both`?void 0:M,...xe?{}:Q,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&F&&!T){let t=oe(e.nativeEvent);if(t&&!C(R.current,t))return;S(e),P.setOpen(!1,l(ee,e.nativeEvent)),n(L)&&L.focus();return}Z(e)},onPointerMove(e){ue(e)||(U.current=!0)}}),[Q,Z,R,M,xe,P,F,T,L]),$=D.useMemo(()=>{function e(e){P.setOpen(!0,l(s,e.nativeEvent,e.currentTarget))}function t(e){E===`auto`&&ne(e.nativeEvent)&&(B.current=!T)}function n(e){B.current=E,E===`auto`&&_(e.nativeEvent)&&(B.current=!0)}return{onKeyDown(t){let n=P.select(`open`);U.current=!1;let r=t.key.startsWith(`Arrow`),i=fe(t.key,X(),x),a=A(t.key,M),o=(b?i:a)||t.key===`Enter`||t.key.trim()===``;if(T&&n)return Z(t);if(!(!n&&!k&&r)){if(o){let e=A(t.key,X());H.current=b&&e?null:t.key}if(b){i&&(S(t),n?(V.current=Me(),W(t)):e(t));return}a&&(Y.current!=null&&(V.current=Y.current),S(t),!n&&k?e(t):Z(t),n&&W(t))}},onFocus(e){P.select(`open`)&&!T&&(V.current=-1,W(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[Z,E,Me,b,W,P,k,M,X,x,Y,T]),Fe=D.useMemo(()=>({...Q,...$}),[Q,$]);return D.useMemo(()=>d?{reference:Fe,floating:Pe,item:Ne,trigger:$}:{},[d,Fe,Pe,$,Ne])}function M(e,n){let{listRef:r,elementsRef:o,activeIndex:s,onMatch:ee,disabledIndices:c,onTyping:l,enabled:u=!0,resetMs:f=750,selectedIndex:p=null}=n,m=`rootStore`in e?e.rootStore:e,h=m.useState(`open`),g=d(),_=D.useRef(``),v=D.useRef(p??s??-1),y=D.useRef(null),b=a(e=>{function n(e){return o?.current[e]}function i(e){let r=n(e);return r&&!E(r)||r?.matches(`:disabled`)?!1:c==null||!T(t,e,c)}function a(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,a=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(!(!e[n]?.toLowerCase().startsWith(a)||!i(n)))return n}return-1}let u=r.current;if(_.current.length>0&&e.key===` `&&(S(e),l?.(!0)),_.current.length>0&&_.current[0]!==` `&&a(u,_.current)===-1&&e.key!==` `&&l?.(!1),u==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;h&&e.key!==` `&&(S(e),l?.(!0));let d=_.current===``;d&&(v.current=p??s??-1),u.every((e,t)=>e&&i(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&_.current===e.key&&(_.current=``,v.current=y.current),_.current+=e.key,g.start(f,()=>{_.current=``,v.current=y.current,l?.(!1)});let m=((d?p??s??-1:v.current)??0)+1,b=a(u,_.current,m);b===-1?e.key!==` `&&(_.current=``,l?.(!1)):(ee?.(b),y.current=b)}),te=a(e=>{let t=e.relatedTarget,n=m.select(`domReferenceElement`),r=m.select(`floatingElement`);C(n,t)||C(r,t)||(g.clear(),_.current=``,v.current=y.current,l?.(!1))});i(()=>{!h&&p!==null||(g.clear(),y.current=null,_.current!==``&&(_.current=``))},[h,p,g]);let x=D.useMemo(()=>({onKeyDown:b,onBlur:te}),[b,te]);return D.useMemo(()=>u?{reference:x,floating:x}:{},[u,x])}var N=5;function me(e,t){let n=he(t);return e.clientX>=n.left-N&&e.clientX<=n.right+N&&e.clientY>=n.top-N&&e.clientY<=n.bottom+N}function he(e){let t=e.getBoundingClientRect(),n=o(e);if(m)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,s=parseFloat(r.height)||0,ee=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,ee),u=Math.max(t.height,s,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}export{M as n,j as r,me as t};