(function(U,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],a):(U=typeof globalThis<"u"?globalThis:U||self,a(U.resplit={},U.React))})(this,function(U,a){"use strict";var xe={exports:{}},fe={};/** * @license React * react-jsx-runtime.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ie;function rt(){if(Ie)return fe;Ie=1;var i=a,s=Symbol.for("react.element"),u=Symbol.for("react.fragment"),p=Object.prototype.hasOwnProperty,C=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,S={key:!0,ref:!0,__self:!0,__source:!0};function x(k,R,_){var y,f={},z=null,g=null;_!==void 0&&(z=""+_),R.key!==void 0&&(z=""+R.key),R.ref!==void 0&&(g=R.ref);for(y in R)p.call(R,y)&&!S.hasOwnProperty(y)&&(f[y]=R[y]);if(k&&k.defaultProps)for(y in R=k.defaultProps,R)f[y]===void 0&&(f[y]=R[y]);return{$$typeof:s,type:k,key:z,ref:g,props:f,_owner:C.current}}return fe.Fragment=u,fe.jsx=x,fe.jsxs=x,fe}var de={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var ze;function ot(){return ze||(ze=1,process.env.NODE_ENV!=="production"&&function(){var i=a,s=Symbol.for("react.element"),u=Symbol.for("react.portal"),p=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),x=Symbol.for("react.provider"),k=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),y=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),G=Symbol.iterator,K="@@iterator";function L(e){if(e===null||typeof e!="object")return null;var t=G&&e[G]||e[K];return typeof t=="function"?t:null}var D=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function P(e){{for(var t=arguments.length,n=new Array(t>1?t-1:0),c=1;c=1&&T>=0&&d[w]!==I[T];)T--;for(;w>=1&&T>=0;w--,T--)if(d[w]!==I[T]){if(w!==1||T!==1)do if(w--,T--,T<0||d[w]!==I[T]){var W=` `+d[w].replace(" at new "," at ");return e.displayName&&W.includes("")&&(W=W.replace("",e.displayName)),typeof e=="function"&&ne.set(e,W),W}while(w>=1&&T>=0);break}}}finally{Q=!1,A.current=E,V(),Error.prepareStackTrace=b}var ue=e?e.displayName||e.name:"",nt=ue?j(ue):"";return typeof e=="function"&&ne.set(e,nt),nt}function N(e,t,n){return Z(e,!1)}function le(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function re(e,t,n){if(e==null)return"";if(typeof e=="function")return Z(e,le(e));if(typeof e=="string")return j(e);switch(e){case _:return j("Suspense");case y:return j("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case R:return N(e.render);case f:return re(e.type,t,n);case z:{var c=e,b=c._payload,E=c._init;try{return re(E(b),t,n)}catch{}}}return""}var q=Object.prototype.hasOwnProperty,be={},ye=D.ReactDebugCurrentFrame;function J(e){if(e){var t=e._owner,n=re(e.type,e._source,t?t.type:null);ye.setExtraStackFrame(n)}else ye.setExtraStackFrame(null)}function Et(e,t,n,c,b){{var E=Function.call.bind(q);for(var v in e)if(E(e,v)){var d=void 0;try{if(typeof e[v]!="function"){var I=Error((c||"React class")+": "+n+" type `"+v+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[v]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw I.name="Invariant Violation",I}d=e[v](t,v,c,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(w){d=w}d&&!(d instanceof Error)&&(J(b),P("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",c||"React class",n,v,typeof d),J(null)),d instanceof Error&&!(d.message in be)&&(be[d.message]=!0,J(b),P("Failed %s type: %s",n,d.message),J(null))}}}var Rt=Array.isArray;function Oe(e){return Rt(e)}function gt(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,n=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function Ct(e){try{return He(e),!1}catch{return!0}}function He(e){return""+e}function Je(e){if(Ct(e))return P("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",gt(e)),He(e)}var Ee=D.ReactCurrentOwner,_t={key:!0,ref:!0,__self:!0,__source:!0},Ke,Ze,je;je={};function St(e){if(q.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Pt(e){if(q.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function wt(e,t){if(typeof e.ref=="string"&&Ee.current&&t&&Ee.current.stateNode!==t){var n=M(Ee.current.type);je[n]||(P('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',M(Ee.current.type),e.ref),je[n]=!0)}}function xt(e,t){{var n=function(){Ke||(Ke=!0,P("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function Tt(e,t){{var n=function(){Ze||(Ze=!0,P("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",t))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var kt=function(e,t,n,c,b,E,v){var d={$$typeof:s,type:e,key:t,ref:n,props:v,_owner:E};return d._store={},Object.defineProperty(d._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(d,"_self",{configurable:!1,enumerable:!1,writable:!1,value:c}),Object.defineProperty(d,"_source",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.freeze&&(Object.freeze(d.props),Object.freeze(d)),d};function Ot(e,t,n,c,b){{var E,v={},d=null,I=null;n!==void 0&&(Je(n),d=""+n),Pt(t)&&(Je(t.key),d=""+t.key),St(t)&&(I=t.ref,wt(t,b));for(E in t)q.call(t,E)&&!_t.hasOwnProperty(E)&&(v[E]=t[E]);if(e&&e.defaultProps){var w=e.defaultProps;for(E in w)v[E]===void 0&&(v[E]=w[E])}if(d||I){var T=typeof e=="function"?e.displayName||e.name||"Unknown":e;d&&xt(v,T),I&&Tt(v,T)}return kt(e,d,I,b,c,Ee.current,v)}}var Ae=D.ReactCurrentOwner,Xe=D.ReactDebugCurrentFrame;function ce(e){if(e){var t=e._owner,n=re(e.type,e._source,t?t.type:null);Xe.setExtraStackFrame(n)}else Xe.setExtraStackFrame(null)}var De;De=!1;function Fe(e){return typeof e=="object"&&e!==null&&e.$$typeof===s}function Qe(){{if(Ae.current){var e=M(Ae.current.type);if(e)return` Check the render method of \``+e+"`."}return""}}function jt(e){{if(e!==void 0){var t=e.fileName.replace(/^.*[\\\/]/,""),n=e.lineNumber;return` Check your code at `+t+":"+n+"."}return""}}var qe={};function At(e){{var t=Qe();if(!t){var n=typeof e=="string"?e:e.displayName||e.name;n&&(t=` Check the top-level render call using <`+n+">.")}return t}}function $e(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=At(t);if(qe[n])return;qe[n]=!0;var c="";e&&e._owner&&e._owner!==Ae.current&&(c=" It was passed a child from "+M(e._owner.type)+"."),ce(e),P('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,c),ce(null)}}function et(e,t){{if(typeof e!="object")return;if(Oe(e))for(var n=0;n",d=" Did you accidentally export a JSX literal instead of a component?"):w=typeof e,P("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",w,d)}var T=Ot(e,t,n,b,E);if(T==null)return T;if(v){var W=t.children;if(W!==void 0)if(c)if(Oe(W)){for(var ue=0;uei.forEach(u=>it(u,s))}const ge=a.forwardRef((i,s)=>{const{children:u,...p}=i,C=a.Children.toArray(u),S=C.find(ct);if(S){const x=S.props.children,k=C.map(R=>R===S?a.Children.count(x)>1?a.Children.only(null):a.isValidElement(x)?x.props.children:null:R);return a.createElement(Te,Re({},p,{ref:s}),a.isValidElement(x)?a.cloneElement(x,void 0,k):null)}return a.createElement(Te,Re({},p,{ref:s}),u)});ge.displayName="Slot";const Te=a.forwardRef((i,s)=>{const{children:u,...p}=i;return a.isValidElement(u)?a.cloneElement(u,{...ut(p,u.props),ref:s?st(s,u.ref):u.ref}):a.Children.count(u)>1?a.Children.only(null):null});Te.displayName="SlotClone";const lt=({children:i})=>a.createElement(a.Fragment,null,i);function ct(i){return a.isValidElement(i)&&i.type===lt}function ut(i,s){const u={...s};for(const p in s){const C=i[p],S=s[p];/^on[A-Z]/.test(p)?C&&S?u[p]=(...k)=>{S(...k),C(...k)}:C&&(u[p]=C):p==="style"?u[p]={...C,...S}:p==="className"&&(u[p]=[C,S].filter(Boolean).join(" "))}return{...i,...u}}const Ne=a.createContext(void 0),ft=()=>{const i=a.useContext(Ne);if(!i)throw new Error("useResplitContext must be used within a ResplitRoot");return i},Le=a.createContext(void 0),Me=()=>{const i=a.useContext(Le);if(!i)throw new Error("useRootContext must be used within an RootContext.Provider");return i},dt={horizontal:"gridTemplateColumns",vertical:"gridTemplateRows"},Ve={horizontal:"col-resize",vertical:"row-resize"},pt="10px",vt="0fr",mt="0fr",$=i=>Number(i.replace("fr","")),Ye=i=>Number(i.replace("px","")),ht=(i,s)=>`${i/s}fr`,We=i=>i.includes("px"),Ce=(i,s)=>We(i)?ht(Ye(i),s):i,ke=typeof window>"u"?a.useEffect:a.useLayoutEffect;function bt(i){return s=>{i.forEach(u=>{typeof u=="function"?u(s):u!=null&&(u.current=s)})}}const Ue=a.forwardRef(function({direction:s="horizontal",children:u,style:p,asChild:C=!1,...S},x){const k=a.useId(),R=C?ge:"div",_=a.useRef(null),y=a.useRef(null),[f,z]=a.useState({}),g=a.useCallback(o=>{var r;return(r=y.current)==null?void 0:r.querySelector(`:scope > [data-resplit-order="${o}"]`)},[]),G=a.useCallback(o=>{var r;return(r=y.current)==null?void 0:r.style.getPropertyValue(`--resplit-${o}`)},[]),K=a.useCallback(o=>{const r=G(o);return r?We(r)?Ye(r):$(r):0},[G]),L=a.useCallback((o,r)=>{var m;if((m=y.current)==null||m.style.setProperty(`--resplit-${o}`,r),f[o].type==="pane"){const h=g(o+1);h==null||h.setAttribute("aria-valuenow",String($(r).toFixed(2)))}},[f,g]),D=a.useCallback(o=>{var r;return((r=g(o))==null?void 0:r.getAttribute("data-resplit-is-min"))==="true"},[g]),P=a.useCallback((o,r)=>{var l;return(l=g(o))==null?void 0:l.setAttribute("data-resplit-is-min",String(r))},[g]),oe=a.useCallback(o=>{var r;return((r=g(o))==null?void 0:r.getAttribute("data-resplit-is-collapsed"))==="true"},[g]),ee=a.useCallback((o,r)=>{var l;return(l=g(o))==null?void 0:l.setAttribute("data-resplit-is-collapsed",String(r))},[g]),ae=a.useCallback(()=>{var o,r;return(s==="horizontal"?(o=y.current)==null?void 0:o.offsetWidth:(r=y.current)==null?void 0:r.offsetHeight)||0},[s]),ve=a.useCallback((o,r)=>{let l=o,m=f[l];for(;l>=0&&l{var be,ye;const l=r>0,m=r<0,{index:h,pane:F}=m?ve(o-1,-1):{index:o-1,pane:f[o-1]},{index:O,pane:V}=l?ve(o+1,1):{index:o+1,pane:f[o+1]};if(!F||!V)return;const A=ae(),Y=F.options.current;let j=K(h)+r;const Q=$(Ce(Y.minSize,A)),ne=j<=Q,he=!!Y.collapsible&&j<=Q/2,Z=V.options.current;let N=K(O)-r;const le=$(Ce(Z.minSize,A)),re=N<=le,q=!!Z.collapsible&&N<=le/2;if(he||q){if(he){const J=$(Ce(Y.collapsedSize,A));N=N+j-J,j=J}if(q){const J=$(Ce(Z.collapsedSize,A));j=j+N-J,N=J}}else ne&&(N=N+(j-Q),j=Q),re&&(j=j+(N-le),N=le);L(h,`${j}fr`),P(h,ne),ee(h,he),(be=Y.onResize)==null||be.call(Y,`${j}fr`),L(O,`${N}fr`),P(O,re),ee(O,q),(ye=Z.onResize)==null||ye.call(Z,`${N}fr`)},[f,ve,K,ae,L,P,ee]),ie=a.useCallback(o=>{if(_.current===null)return;const r=g(_.current);if(!r)return;const l=Object.entries(f).reduce((V,[A,Y])=>V+(Y.type==="splitter"?K(Number(A)):0),0),m=ae()-l,h=r.getBoundingClientRect(),O=(s==="horizontal"?o.clientX-h.left:o.clientY-h.top)/m;O&&B(_.current,O)},[f,s,g,K,ae,B]),se=a.useCallback(()=>{var m,h,F,O,V,A;const o=_.current;if(o===null)return;(m=y.current)==null||m.setAttribute("data-resplit-resizing","false"),o!==null&&((h=g(o))==null||h.setAttribute("data-resplit-active","false"));const r=f[o-1];r.type==="pane"&&((O=(F=r.options.current).onResizeEnd)==null||O.call(F,G(o-1)));const l=f[o+1];l.type==="pane"&&((A=(V=l.options.current).onResizeEnd)==null||A.call(V,G(o+1))),_.current=null,document.documentElement.style.cursor="",document.documentElement.style.pointerEvents="",document.documentElement.style.userSelect="",window.removeEventListener("mouseup",se),window.removeEventListener("mousemove",ie)},[f,g,G,ie]),_e=a.useCallback(o=>()=>{var m,h,F,O,V,A;_.current=o,(m=y.current)==null||m.setAttribute("data-resplit-resizing","true"),_.current!==null&&((h=g(_.current))==null||h.setAttribute("data-resplit-active","true"));const r=f[o-1];r.type==="pane"&&((O=(F=r.options.current).onResizeStart)==null||O.call(F));const l=f[o+1];l.type==="pane"&&((A=(V=l.options.current).onResizeStart)==null||A.call(V)),document.documentElement.style.cursor=Ve[s],document.documentElement.style.pointerEvents="none",document.documentElement.style.userSelect="none",window.addEventListener("mouseup",se),window.addEventListener("mousemove",ie)},[s,f,g,se,ie]),Se=a.useCallback(o=>r=>{const l=s==="horizontal",m=s==="vertical";if(r.key==="ArrowLeft"&&l||r.key==="ArrowUp"&&m)B(o,-.01);else if(r.key==="ArrowRight"&&l||r.key==="ArrowDown"&&m)B(o,.01);else if(r.key==="Home")B(o,-1);else if(r.key==="End")B(o,1);else if(r.key==="Enter")if(D(o-1)){const h=f[o-1].options.current.initialSize||"1fr";B(o,$(h))}else B(o,-1)},[s,f,B,D]),me=a.useCallback((o,r)=>{z(l=>({...l,[o]:{type:"pane",options:r}}))},[]),M=a.useCallback((o,r)=>{z(l=>({...l,[o]:{type:"splitter",options:r}}))},[]),H=a.useCallback(o=>{o.forEach((r,l)=>{var F,O;const m=l*2;L(m,r),P(m,f[m].options.current.minSize===r),ee(m,f[m].options.current.collapsedSize===r);const h=f[m];h.type==="pane"&&((O=(F=h.options.current).onResize)==null||O.call(F,r))})},[f,L,P,ee]),te=Object.keys(f).length;ke(()=>{const o=Object.values(f).filter(r=>r.type==="pane").length;Object.keys(f).forEach(r=>{const l=Number(r),m=f[l];if(m.type==="pane"){const h=D(l)?"0fr":m.options.current.initialSize||`${1/o}fr`;L(l,h)}else L(l,m.options.current.size)})},[te]);const Pe=a.useMemo(()=>({id:k,direction:s,registerPane:me,registerSplitter:M,handleSplitterMouseDown:_e,handleSplitterKeyDown:Se}),[k,s,me,M,_e,Se]),we=a.useMemo(()=>({isPaneMinSize:D,isPaneCollapsed:oe,setPaneSizes:H}),[D,oe,H]);return pe(Le.Provider,{value:Pe,children:pe(Ne.Provider,{value:we,children:pe(R,{ref:bt([y,x]),"data-resplit-direction":s,"data-resplit-resizing":!1,style:{display:"grid",overflow:"hidden",[dt[s]]:Object.keys(f).reduce((o,r)=>{const l=`minmax(0, var(--resplit-${r}))`;return o?`${o} ${l}`:`${l}`},""),...p},...S,children:u})})})}),Be=a.forwardRef(function({children:s,order:u,minSize:p=vt,collapsible:C=!1,collapsedSize:S=mt,initialSize:x,asChild:k=!1,onResize:R,onResizeStart:_,onResizeEnd:y,...f},z){const g=k?ge:"div",{id:G,registerPane:K}=Me(),L=a.useRef({minSize:p,initialSize:x,collapsedSize:S,collapsible:C,onResize:R,onResizeStart:_,onResizeEnd:y});return ke(()=>{K(String(u),L)},[]),a.useEffect(()=>{L.current={minSize:p,initialSize:x,collapsedSize:S,collapsible:C,onResize:R,onResizeStart:_,onResizeEnd:y}},[p,x,S,C,R,_,y]),pe(g,{id:`resplit-${G}-${u}`,"data-resplit-order":u,"data-resplit-is-min":!1,"data-resplit-is-collapsed":!1,ref:z,...f,children:s})}),Ge=a.forwardRef(function({children:s,order:u,size:p=pt,asChild:C=!1,...S},x){const k=C?ge:"div",{id:R,direction:_,registerSplitter:y,handleSplitterMouseDown:f,handleSplitterKeyDown:z}=Me(),g=a.useRef({size:p});return ke(()=>{y(String(u),g)},[]),a.useEffect(()=>{g.current={size:p}},[p]),pe(k,{role:"separator",tabIndex:0,"aria-orientation":_,"aria-valuemin":0,"aria-valuemax":1,"aria-valuenow":1,"aria-controls":`resplit-${R}-${u-1}`,"data-resplit-order":u,"data-resplit-active":!1,style:{cursor:Ve[_]},onMouseDown:f(u),onKeyDown:z(u),ref:x,...S,children:s})}),yt={Root:Ue,Pane:Be,Splitter:Ge};U.Resplit=yt,U.ResplitPane=Be,U.ResplitRoot=Ue,U.ResplitSplitter=Ge,U.useResplitContext=ft,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"})});