import{s as k}from"./chunk-LvLJmgfZ.js";import{d as C,n as g,p as _,u as A}from"./useEvent-D91BmmQi.js";import{t as w}from"./react-Bj1aDYRI.js";import{t as E}from"./react-dom-CSu739Rf.js";import{t as O}from"./compiler-runtime-B3qBwwSJ.js";import{_ as S,m as D,t as H}from"./useEventListener-C0195JsF.js";import{g as N}from"./utils-BWBBpCkT.js";E();var s=k(w(),1),R=(0,s.createContext)(null);function T(e){let r=(0,s.useRef)({});return s.createElement(R.Provider,{value:r},e.children)}var j=(0,s.createContext)({isSelected:!1}),P=_({});function q(){return A(P)}function z(){let e=C(P);return{registerAction:g((r,o)=>{e(t=>({...t,[r]:o}))}),unregisterAction:g(r=>{e(o=>{let{[r]:t,...n}=o;return n})})}}var B=O();function F(e,r,o){let t=(0,B.c)(17),n;t[0]===o?n=t[1]:(n=o===void 0?{}:o,t[0]=o,t[1]=n);let{disabled:y}=n,i=y===void 0?!1:y,{registerAction:u,unregisterAction:f}=z(),x=A(N),l=r===S.NOOP,m;t[2]===r?m=t[3]:(m=a=>r(a),t[2]=r,t[3]=m);let c=g(m),p;t[4]!==r||t[5]!==i||t[6]!==x||t[7]!==e?(p=a=>{if(i||a.defaultPrevented)return;let h=x.getHotkey(e).key;D(h)(a)&&r(a)!==!1&&(a.preventDefault(),a.stopPropagation())},t[4]=r,t[5]=i,t[6]=x,t[7]=e,t[8]=p):p=t[8];let b=g(p);H(document,"keydown",b);let d,v;t[9]!==i||t[10]!==l||t[11]!==c||t[12]!==u||t[13]!==e||t[14]!==f?(d=()=>{if(!l&&!i)return u(e,c),()=>f(e)},v=[c,e,l,i,u,f],t[9]=i,t[10]=l,t[11]=c,t[12]=u,t[13]=e,t[14]=f,t[15]=d,t[16]=v):(d=t[15],v=t[16]),(0,s.useEffect)(d,v)}export{T as i,q as n,j as r,F as t};
