import{r as n}from"./index-NdkWRN8K.js";function f(e,t){typeof e=="function"?e(t):e&&(e.current=t)}function F(...e){return n.useMemo(()=>e.every(t=>t==null)?null:t=>{e.forEach(r=>{f(r,t)})},e)}const o={};function d(e,t){const r=n.useRef(o);return r.current===o&&(r.current=e(t)),r}const h=[];function y(e){n.useEffect(e,h)}class i{constructor(){this.currentId=null,this.clear=()=>{this.currentId!==null&&(clearTimeout(this.currentId),this.currentId=null)},this.disposeEffect=()=>this.clear}static create(){return new i}start(t,r){this.clear(),this.currentId=setTimeout(()=>{this.currentId=null,r()},t)}}function V(){const e=d(i.create).current;return y(e.disposeEffect),e}let s=!0,a=!1;const m=new i,b={text:!0,search:!0,url:!0,tel:!0,email:!0,password:!0,number:!0,date:!0,month:!0,week:!0,time:!0,datetime:!0,"datetime-local":!0};function E(e){const{type:t,tagName:r}=e;return!!(r==="INPUT"&&b[t]&&!e.readOnly||r==="TEXTAREA"&&!e.readOnly||e.isContentEditable)}function p(e){e.metaKey||e.altKey||e.ctrlKey||(s=!0)}function c(){s=!1}function I(){this.visibilityState==="hidden"&&a&&(s=!0)}function T(e){e.addEventListener("keydown",p,!0),e.addEventListener("mousedown",c,!0),e.addEventListener("pointerdown",c,!0),e.addEventListener("touchstart",c,!0),e.addEventListener("visibilitychange",I,!0)}function w(e){const{target:t}=e;try{return t.matches(":focus-visible")}catch{}return s||E(t)}function v(){const e=n.useCallback(u=>{u!=null&&T(u.ownerDocument)},[]),t=n.useRef(!1);function r(){return t.current?(a=!0,m.start(100,()=>{a=!1}),t.current=!1,!0):!1}function l(u){return w(u)?(t.current=!0,!0):!1}return{isFocusVisibleRef:t,onFocus:l,onBlur:r,ref:e}}export{i as T,V as a,v as b,f as s,F as u};
