@a-multilayout-splitter/core 6.0.0-alpha.4 → 6.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Je=Object.defineProperty;var Ze=(t,e,n)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var te=(t,e,n)=>Ze(t,typeof e!="symbol"?e+"":e,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const H=require("react/jsx-runtime"),c=require("react");function Qe(t,e){e?(t.classList.add("a-split-hidden"),t.style.flexGrow="0",t.style.flexShrink="0",t.style.flexBasis="0"):(t.classList.remove("a-split-hidden"),t.style.flexGrow="",t.style.flexShrink="")}function ve(t,e,n={}){return new Promise(s=>{const l=n.duration||300;if(!n.animate){t.style.flexBasis=e,s();return}t.style.transition=`flex-basis ${l}ms ease`,t.offsetHeight,t.style.flexBasis=e,setTimeout(()=>{t.style.transition="",s()},l)})}function Ke(t){return{...t,collapsed:!t.collapsed}}function et(t,e){return t.findIndex(n=>n.id===e)}function Ce(t){return!t.collapsed}function tt(t){return t.filter(Ce)}function nt(t){return document.querySelector(`[data-pane-id="${t}"]`)}function rt(t,e,n){return Math.max(e,Math.min(n,t))}function st(t,e,n,s={}){return{id:t,size:e,content:n,collapsed:s.collapsed??!1,minSize:s.minSize??0,maxSize:s.maxSize??100}}function it(t,e){return{...t,size:e}}function at(t,e){return t.map(n=>{const s=e.get(n.id);return s?{...n,...s}:n})}function ot(t,e){return{...t,size:e.size,collapsed:e.collapsed}}function lt(t){return{id:t.id,size:t.size,collapsed:t.collapsed}}function Ee(t,e){return!0}function ne(t,e){return typeof e=="boolean"?e:Array.isArray(e)?e.length>0&&typeof e[0]=="boolean"?e[t-1]===!0:e.includes(t):!1}function re(t,e){return typeof e=="boolean"?e:Array.isArray(e)?e.length>0&&typeof e[0]=="boolean"?e[t-1]!==!1:e.includes(t):!0}function se(t,e){return typeof e=="boolean"?e:Array.isArray(e)?e.length>0&&typeof e[0]=="boolean"?e[t-1]===!0:e.includes(t):!1}function $e(t,e=[],n=[],s=[],l=[],w="split"){const[h,z]=c.useState(()=>c.Children.toArray(t).map((g,p)=>({id:`${w}-pane-${p}`,size:e[p]||"100%",collapsed:n[p]||!1,minSize:s[p]||0,maxSize:l[p]||100,content:g}))),C=c.useRef(t);c.useEffect(()=>{const o=c.Children.toArray(t),g=c.Children.toArray(C.current);o.length===h.length&&z(p=>{let r=!1;const i=p.map((a,u)=>{const S=o[u],A=g[u];return S!==A?(r=!0,{...a,content:S}):a});return r?i:p}),C.current=t},[t,h.length]);const P=c.useCallback(o=>{z(g=>{const p=o.position??g.length,r={id:`${w}-pane-${Date.now()}`,size:o.size,collapsed:o.collapsed||!1,minSize:o.minSize||0,maxSize:o.maxSize||100,content:o.content},i=[...g];return i.splice(p,0,r),ct(i,p,o.size)})},[w]),v=c.useCallback(o=>{z(g=>{if(o<0||o>=g.length)return g;const p=[...g],r=p.splice(o,1)[0];return r?ut(p,r.size):p})},[]),d=c.useCallback(o=>{z(g=>{if(o<0||o>=g.length)return g;const p=g[o];if(!p)return g;const r=[...g];r[o]={...p,collapsed:!p.collapsed};const i=document.querySelector(`[data-pane-id="${p.id}"]`);if(i){const a=r[o];(a==null?void 0:a.collapsed)??!1?(i.classList.add("a-split-hidden"),i.style.flexGrow="0"):(i.classList.remove("a-split-hidden"),i.style.flexGrow="")}return r})},[]),b=c.useCallback((o,g,p)=>{z(r=>{if(o<0||o>=r.length)return r;const i=r[o];if(!i)return r;const a=[...r];a[o]={...i,size:g,flexGrow:void 0};const u=document.querySelector(`[data-pane-id="${i.id}"]`);return u&&ve(u,g,p||{animate:!1}),a})},[]),m=c.useCallback(()=>h,[h]),E=c.useCallback(o=>{z(g=>{const p=[...o].sort((a,u)=>u-a);let r=[...g],i=0;if(p.forEach(a=>{if(a>=0&&a<r.length){const u=r.splice(a,1)[0];u&&(i+=parseFloat(u.size)||0)}}),r.length>0&&i>0){const a=i/r.length;r=r.map(u=>({...u,size:`${(parseFloat(u.size)||0)+a}%`}))}return r})},[]),D=c.useCallback((o,g)=>{z(p=>{if(o<0||o>=p.length||g<0||g>=p.length||o===g)return p;const r=[...p],i=r[o];return r[o]=r[g],r[g]=i,r})},[]),I=c.useCallback((o,g)=>{z(p=>{if(o<0||o>=p.length)return p;const r=p[o];if(!r||r.collapsed)return p;const i=g==null?void 0:g.direction;let a;i==="left"?a=o+1:i==="right"?a=o-1:a=o<p.length-1?o+1:o-1;const u=p.map((S,A)=>A===o?{...S,collapsed:!0,flexGrow:0}:A===a&&!S.collapsed?{...S,flexGrow:1}:S.collapsed?S:{...S,flexGrow:0});if(g!=null&&g.animate){const S=document.querySelector(`[data-pane-id="${r.id}"]`);S&&(S.style.transition=`flex-basis ${g.duration||300}ms ease`,setTimeout(()=>{S.style.transition=""},g.duration||300))}return u})},[]),M=c.useCallback((o,g)=>{z(p=>{if(o<0||o>=p.length)return p;const r=p[o];if(!r||!r.collapsed)return p;const i=p.filter(S=>!S.collapsed).length+1,a=p.length;let u=[...p];if(u[o]={...r,collapsed:!1,flexGrow:void 0},i===a)u=u.map(S=>({...S,flexGrow:void 0}));else{const S=g==null?void 0:g.direction;let A;if(S==="left"?A=o+1:S==="right"?A=o-1:A=o<p.length-1?o+1:o-1,A>=0&&A<u.length){const L=u[A];L&&L.flexGrow===1&&(u[A]={...L,flexGrow:void 0})}}if(g!=null&&g.animate){const S=document.querySelector(`[data-pane-id="${r.id}"]`);S&&(S.style.transition=`flex-basis ${g.duration||300}ms ease`,setTimeout(()=>{S.style.transition=""},g.duration||300))}return u})},[]),N=c.useCallback((o,g)=>{z(p=>{if(o<0||o>=p.length)return p;const r=p[o];if(!r)return p;const i=parseFloat(r.size)||0,a=Math.max(r.minSize||0,Math.min(r.maxSize||100,i+g)),u=[...p];u[o]={...r,size:`${a}%`};const S=document.querySelector(`[data-pane-id="${r.id}"]`);return S&&(S.style.flexBasis=`${a}%`),u})},[]);return{panes:h,addPane:P,removePane:v,togglePane:d,setPaneSize:b,getPaneState:m,removePanes:E,swapPanes:D,collapsePane:I,expandPane:M,resizePane:N}}function ct(t,e,n){const s=parseFloat(n);if(!n.includes("%"))return t;const h=t.filter((C,P)=>P!==e).reduce((C,P)=>C+parseFloat(P.size),0),z=(100-s)/h;return t.map((C,P)=>{if(P===e)return C;const d=parseFloat(C.size)*z;return{...C,size:C.size.includes("%")?`${d}%`:C.size}})}function ut(t,e){if(t.length===0)return t;const n=parseFloat(e);if(!e.includes("%"))return t;const l=n/t.length;return t.map(w=>{if(!w.size.includes("%"))return w;const z=parseFloat(w.size)+l;return{...w,size:`${z}%`}})}function ke(t,e){let n=null,s=0;return function(...w){const h=Date.now();h-s>=e?(t(...w),s=h):(n&&clearTimeout(n),n=setTimeout(()=>{t(...w),s=Date.now()},e-(h-s)))}}function Ie(t,e){let n=null;return function(...l){n&&clearTimeout(n),n=setTimeout(()=>{t(...l)},e)}}function Ae(t,e,n={}){const{onDragStart:s,onDragMove:l,onDragEnd:w}=n,h=c.useRef(null),z=c.useRef(null),C=c.useCallback((b,m)=>{var u,S;m.preventDefault(),m.stopPropagation();const E=m.target;if(E.closest("button")||E.tagName==="BUTTON")return;const D=t.current;if(!D)return;const I=Array.from(D.children),M=(b-1)*2,N=b*2,o=I[M],g=I[N];if(!o||!g||o.classList.contains("a-split-hidden")||g.classList.contains("a-split-hidden"))return;const p="touches"in m?((u=m.touches[0])==null?void 0:u.clientX)??0:m.clientX,r="touches"in m?((S=m.touches[0])==null?void 0:S.clientY)??0:m.clientY,i=Array.from(D.querySelectorAll(".a-split-handlebar")).filter(A=>A.parentElement===D);let a=0;i.forEach(A=>{const L=A,k=window.getComputedStyle(L);if(e==="horizontal"){const j=parseFloat(k.marginLeft)||0,_=parseFloat(k.marginRight)||0;a+=L.offsetWidth+j+_}else{const j=parseFloat(k.marginTop)||0,_=parseFloat(k.marginBottom)||0;a+=L.offsetHeight+j+_}}),h.current={active:!0,paneIndex:b,startX:p,startY:r,prevElement:o,nextElement:g,prevInitialWidth:o.offsetWidth,nextInitialWidth:g.offsetWidth,prevInitialHeight:o.offsetHeight,nextInitialHeight:g.offsetHeight,containerWidth:D.offsetWidth-(e==="horizontal"?a:0),containerHeight:D.offsetHeight-(e==="vertical"?a:0),minPrevSize:parseFloat(o.getAttribute("data-min-size")||"0"),maxPrevSize:parseFloat(o.getAttribute("data-max-size")||"100"),minNextSize:parseFloat(g.getAttribute("data-min-size")||"0"),maxNextSize:parseFloat(g.getAttribute("data-max-size")||"100")},z.current=null,s==null||s({paneIndex:b})},[t,s,e]),P=c.useCallback(b=>{var k,j;const m=h.current;if(!(m!=null&&m.active))return null;const E=e==="horizontal",D="touches"in b?((k=b.touches[0])==null?void 0:k.clientX)??0:b.clientX,I="touches"in b?((j=b.touches[0])==null?void 0:j.clientY)??0:b.clientY,M=E?D-m.startX:I-m.startY,N=E?m.containerWidth:m.containerHeight,o=E?m.prevInitialWidth:m.prevInitialHeight,g=E?m.nextInitialWidth:m.nextInitialHeight;let p=o+M,r=g-M;p<0&&(p=0),r<0&&(r=0);const i=p/N*100,a=r/N*100,u=i<=m.minPrevSize,S=i>=m.maxPrevSize,A=a<=m.minNextSize,L=a>=m.maxNextSize;return u||S||A||L?null:{prevSize:i,nextSize:a,prevSizePx:p,nextSizePx:r,state:m}},[e]),v=c.useCallback(ke(b=>{const m=P(b);if(!m)return;const{prevSize:E,nextSize:D,prevSizePx:I,nextSizePx:M,state:N}=m,{prevInitialWidth:o,prevInitialHeight:g}=N,p=e==="horizontal"?o:g;Math.abs(m.prevSizePx-p)<=1||(z.current={prevSize:E,nextSize:D},requestAnimationFrame(()=>{if(!N.prevElement||!N.nextElement)return;const r=N.prevElement.style.flexBasis.includes("%"),i=N.nextElement.style.flexBasis.includes("%");r?N.prevElement.style.flexBasis=`${E}%`:N.prevElement.style.flexBasis=`${I}px`,i?N.nextElement.style.flexBasis=`${D}%`:N.nextElement.style.flexBasis=`${M}px`}),l==null||l({paneIndex:N.paneIndex,prevSize:E,nextSize:D}))},16),[P,e,l]),d=c.useCallback(b=>{const m=h.current;if(!(m!=null&&m.active))return;const E=P(b);E&&(z.current={prevSize:E.prevSize,nextSize:E.nextSize});const D=z.current;D&&(w==null||w({paneIndex:m.paneIndex,prevSize:D.prevSize,nextSize:D.nextSize})),h.current=null,z.current=null},[P,w]);return c.useEffect(()=>{const b=v,m=d;return window.addEventListener("mousemove",b),window.addEventListener("mouseup",m),window.addEventListener("touchmove",b,{passive:!1}),window.addEventListener("touchend",m),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",m),window.removeEventListener("touchmove",b),window.removeEventListener("touchend",m)}},[v,d]),{handleMouseDown:C}}function De(t,e,n){const s=c.useCallback(Ie(h=>{if(t)try{const z=`${e}-${n}`,C=h.map(P=>({id:P.id,size:P.size,collapsed:P.collapsed}));localStorage.setItem(z,JSON.stringify(C))}catch(z){console.warn("Failed to save split state to localStorage:",z)}},300),[t,e,n]),l=c.useCallback(()=>{if(!t)return null;try{const h=`${e}-${n}`,z=localStorage.getItem(h);return z?JSON.parse(z):null}catch(h){return console.warn("Failed to load split state from localStorage:",h),null}},[t,e,n]),w=c.useCallback(()=>{if(t)try{const h=`${e}-${n}`;localStorage.removeItem(h)}catch(h){console.warn("Failed to clear split state from localStorage:",h)}},[t,e,n]);return{save:s,load:l,clear:w}}function Fe(t,e,n,s){const l=c.useRef(e),w=c.useRef(n);return l.current=e,w.current=n,c.useMemo(()=>({splitId:t,getState:()=>l.current(),dispatch:z=>w.current(z),getElement:()=>s.current,getPanes:()=>l.current().panes}),[t,s])}const He=c.createContext(0);function ie(){return c.useContext(He)}const Z=({level:t=0,children:e})=>H.jsx(He.Provider,{value:t,children:e});Z.displayName="NestingProvider";function dt(t){const e=n=>{const s=ie();return H.jsx(Z,{level:s+1,children:H.jsx(t,{...n})})};return e.displayName=`withNesting(${t.displayName||t.name||"Component"})`,e}const ae=({index:t,mode:e,disabled:n,lineBar:s,onMouseDown:l,onTouchStart:w,onCollapse:h,onExpand:z,renderCustom:C,leftPaneCollapsed:P=!1,rightPaneCollapsed:v=!1,explicitlyDisabled:d=!1})=>{if(C){const a={index:t,mode:e,disabled:n,lineBar:s,onMouseDown:l,onTouchStart:w||l,onCollapse:h,onExpand:z};return H.jsx("div",{className:"a-split-handlebar",onMouseDown:u=>!n&&l(u),onTouchStart:u=>!n&&(w?w(u):l(u)),children:C(a,t)})}const b=["a-split-handlebar",e==="horizontal"?"a-split-handlebar-horizontal":"a-split-handlebar-vertical",n?"a-split-handlebar-disabled":"",s?"a-split-handlebar-line":""].filter(Boolean).join(" "),m=a=>{a.stopPropagation(),v?z==null||z("right"):h==null||h("left")},E=a=>{a.stopPropagation(),P?z==null||z("left"):h==null||h("right")},D=!s&&!d,I=e==="horizontal",M=P&&!v,N=v&&!P,o=I?"M8 3L4 6L8 9":"M3 8L6 4L9 8",g=I?"M4 3L8 6L4 9":"M3 4L6 8L9 4",p=o,r=g,i=P||v;return H.jsx("div",{className:b,onMouseDown:a=>!n&&l(a),onTouchStart:a=>!n&&l(a),style:{cursor:n?"default":I?"col-resize":"row-resize"},children:D&&H.jsxs(H.Fragment,{children:[H.jsx("button",{className:`a-split-collapse-btn a-split-collapse-btn-${I?"left":"top"}${M?" hidden":""}`,onClick:m,"aria-label":v?`Expand ${I?"right":"bottom"} pane`:`Collapse ${I?"left":"top"} pane`,title:v?`Expand ${I?"right":"bottom"} pane`:`Collapse ${I?"left":"top"} pane`,children:H.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:H.jsx("path",{d:p,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),H.jsx("div",{className:`a-split-grip-icon${i?" hidden":""}`,"aria-hidden":"true",children:I?H.jsxs("svg",{width:"8",height:"24",viewBox:"0 0 8 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[H.jsx("circle",{cx:"4",cy:"4",r:"2.5",fill:"currentColor"}),H.jsx("circle",{cx:"4",cy:"12",r:"2.5",fill:"currentColor"}),H.jsx("circle",{cx:"4",cy:"20",r:"2.5",fill:"currentColor"})]}):H.jsxs("svg",{width:"24",height:"8",viewBox:"0 0 24 8",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[H.jsx("circle",{cx:"4",cy:"4",r:"2.5",fill:"currentColor"}),H.jsx("circle",{cx:"12",cy:"4",r:"2.5",fill:"currentColor"}),H.jsx("circle",{cx:"20",cy:"4",r:"2.5",fill:"currentColor"})]})}),H.jsx("button",{className:`a-split-collapse-btn a-split-collapse-btn-${I?"right":"bottom"}${N?" hidden":""}`,onClick:E,"aria-label":P?`Expand ${I?"left":"top"} pane`:`Collapse ${I?"right":"bottom"} pane`,title:P?`Expand ${I?"left":"top"} pane`:`Collapse ${I?"right":"bottom"} pane`,children:H.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:H.jsx("path",{d:r,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})})};ae.displayName="DragHandle";function ft(t,e){if(e.includes("vw")){const n=parseFloat(e);return t/100*window.innerWidth*(n/100)}if(e.includes("vh")){const n=parseFloat(e);return t/100*window.innerHeight*(n/100)}if(e.includes("px")){const n=parseFloat(e);return t/100*n}return e.includes("%")?(console.warn("Percentage reference not fully supported, assuming viewport"),t/100*window.innerWidth*(parseFloat(e)/100)):t/100*parseFloat(e)}function ht(t,e){if(e.includes("vw")){const n=parseFloat(e),s=window.innerWidth*(n/100);return t/s*100}if(e.includes("vh")){const n=parseFloat(e),s=window.innerHeight*(n/100);return t/s*100}if(e.includes("px")){const n=parseFloat(e);return t/n*100}if(e.includes("%")){console.warn("Percentage reference not fully supported, assuming viewport");const n=window.innerWidth*(parseFloat(e)/100);return t/n*100}return t/parseFloat(e)*100}function pt(t,e,n){const s=parseFloat(t);return t.includes("%")?n==="px"?`${s/100*e}px`:t:t.includes("px")?n==="%"?`${s/e*100}%`:t:n==="px"?`${s}px`:`${s/e*100}%`}function B(t){const e=parseFloat(t);return t.includes("%")?{value:e,unit:"%"}:t.includes("px")?{value:e,unit:"px"}:t.includes("vw")?{value:e,unit:"vw"}:t.includes("vh")?{value:e,unit:"vh"}:t.includes("fr")?{value:e,unit:"fr"}:{value:e,unit:"px"}}function gt(t,e){const n=B(t),s=B(e);return n.unit===s.unit}function mt(t,e,n,s){return`${Math.max(e,Math.min(n,t))}${s}`}function St(t){if(t.length===0)return{total:0,unit:"px"};const e=t[0];if(!e)return{total:0,unit:"px"};const n=B(e.size);let s=0;for(const l of t){const w=B(l.size);w.unit===n.unit||console.warn(`Mixed units detected: ${n.unit} and ${w.unit}. Results may be inaccurate.`),s+=w.value}return{total:s,unit:n.unit}}function zt(t,e){const n=[];if(t.length===0)return n.push("No panes defined"),{valid:!1,errors:n};const s=t.filter(l=>l.size.includes("%"));if(s.length>0){const l=s.reduce((w,h)=>w+parseFloat(h.size),0);l>100.1&&n.push(`Total percentage (${l}%) exceeds 100%`)}return t.forEach((l,w)=>{l.minSize<0&&n.push(`Pane ${w}: minSize cannot be negative`),l.maxSize<l.minSize&&n.push(`Pane ${w}: maxSize (${l.maxSize}) less than minSize (${l.minSize})`),l.maxSize>100&&n.push(`Pane ${w}: maxSize (${l.maxSize}%) exceeds 100%`)}),{valid:n.length===0,errors:n}}function Re(t,e){const n=B(t);switch(n.unit){case"%":return t;case"px":return t;case"vw":return`${n.value/100*window.innerWidth}px`;case"vh":return`${n.value/100*window.innerHeight}px`;case"fr":return"0";default:return`${n.value}px`}}function Ne(t,e=!1){if(e)return{flexGrow:0,flexShrink:0};const n=B(t.size);return n.unit==="%"?{flexGrow:1,flexShrink:1}:n.unit==="fr"?{flexGrow:n.value,flexShrink:1}:{flexGrow:0,flexShrink:0}}function wt(t,e,n){const s=B(t);return s.unit==="%"?s.value/100*e:s.unit==="px"?s.value:s.unit==="vw"?s.value/100*window.innerWidth:s.unit==="vh"?s.value/100*window.innerHeight:s.value}const xt=11;function bt(t,e,n=0){const s=t.offsetWidth,l=t.offsetHeight,w=e==="horizontal"?s:l,h=n*xt,z=w-h;return{width:s,height:l,primary:w,availableForPanes:z}}function yt(t){const e=t.filter(l=>l.size.includes("%"));if(e.length===0)return t;const n=e.reduce((l,w)=>l+parseFloat(w.size),0);if(Math.abs(n-100)<.01)return t;const s=100/n;return t.map(l=>{if(!l.size.includes("%"))return l;const h=parseFloat(l.size)*s;return{...l,size:`${h}%`}})}function Pt(t,e,n){const s=e+n;return!(s<t.minSize||s>t.maxSize)}function vt(t){return t==="horizontal"?"width":"height"}function Ct(t){return t==="horizontal"?"clientX":"clientY"}const oe=({id:t,size:e,collapsed:n,minSize:s,maxSize:l,mode:w,content:h,flexGrow:z})=>{const C=e||"100%",P={size:C},{flexGrow:v,flexShrink:d}=Ne(P,n),b=z!==void 0?z:v,m=n?"0":Re(C);return H.jsx("div",{"data-pane-id":t,"data-min-size":s,"data-max-size":l,className:`a-split-pane${n?" a-split-hidden":""}`,style:{flexBasis:m,flexGrow:b,flexShrink:d,overflow:n?"hidden":"auto"},children:h})};oe.displayName="Pane";class Le{constructor(e){te(this,"plugins",[]);te(this,"context");this.context=e}registerPlugins(e){this.plugins=e,this.plugins.forEach(n=>{n.onInit&&n.onInit(this.context)})}destroy(){this.plugins.forEach(e=>{e.onDestroy&&e.onDestroy(this.context)}),this.plugins=[]}onPaneAdd(e){this.plugins.forEach(n=>{n.onPaneAdd&&n.onPaneAdd(e,this.context)})}onPaneRemove(e){this.plugins.forEach(n=>{n.onPaneRemove&&n.onPaneRemove(e,this.context)})}onPaneCollapse(e){this.plugins.forEach(n=>{n.onPaneCollapse&&n.onPaneCollapse(e,this.context)})}onPaneExpand(e){this.plugins.forEach(n=>{n.onPaneExpand&&n.onPaneExpand(e,this.context)})}onDragStart(e){this.plugins.forEach(n=>{n.onDragStart&&n.onDragStart(e,this.context)})}onDragMove(e){let n=!0;for(const s of this.plugins)s.onDragMove&&s.onDragMove(e,this.context)===!1&&(n=!1);return n}onDragEnd(e){this.plugins.forEach(n=>{n.onDragEnd&&n.onDragEnd(e,this.context)})}onResize(e){this.plugins.forEach(n=>{n.onResize&&n.onResize(e,this.context)})}renderHandle(e){for(const n of this.plugins)if(n.renderHandle){const s=n.renderHandle(e,this.context);if(s)return s}return null}renderPane(e){for(const n of this.plugins)if(n.renderPane){const s=n.renderPane(e,this.context);if(s)return s}return null}getPlugins(){return this.plugins}getPlugin(e){return this.plugins.find(n=>n.name===e)}hasPlugin(e){return this.plugins.some(n=>n.name===e)}}const le=c.forwardRef((t,e)=>{const{id:n,mode:s="horizontal",initialSizes:l=[],minSizes:w=[],maxSizes:h=[],collapsed:z=[],disable:C=!1,visible:P=!0,lineBar:v=!1,renderBar:d,plugins:b=[],enableSessionStorage:m=!1,width:E=null,height:D=null,className:I="",style:M={},fixClass:N=!1,children:o,onDragging:g,onDragEnd:p,onLayoutChange:r}=t,i=c.useRef(`split-${Math.random().toString(36).slice(2,11)}`),a=n||i.current,u=c.useRef(null),S=c.useRef(null),A=ie(),L=!N&&A>2;c.useEffect(()=>{var y,x;if(typeof globalThis<"u"&&((x=(y=globalThis.process)==null?void 0:y.env)==null?void 0:x.NODE_ENV)!=="production"){if(l.length>0){const $=c.Children.toArray(o);l.length!==$.length&&console.warn(`[Split] initialSizes length (${l.length}) doesn't match children count (${$.length})`),l.forEach((R,G)=>{if(typeof R=="string"){const W=parseFloat(R);if(isNaN(W)&&console.warn(`[Split] Invalid size at index ${G}: "${R}". Expected format: "50%", "100px", etc.`),R.includes("%")){const J=parseFloat(R);(J<0||J>100)&&console.warn(`[Split] Size at index ${G} is out of range: "${R}". Percentage should be 0-100.`)}}});const F=l.reduce((R,G)=>typeof G=="string"&&G.includes("%")?R+parseFloat(G):R,0);F>100&&console.warn(`[Split] Total percentage (${F}%) exceeds 100%. Sizes will be normalized.`)}if((w.length>0||h.length>0)&&(w.forEach(($,F)=>{const R=h[F];R!==void 0&&$>R&&console.warn(`[Split] minSize (${$}) is greater than maxSize (${R}) at index ${F}`),($<0||$>100)&&console.warn(`[Split] minSize at index ${F} is out of range: ${$}. Should be 0-100.`)}),h.forEach(($,F)=>{($<0||$>100)&&console.warn(`[Split] maxSize at index ${F} is out of range: ${$}. Should be 0-100.`)})),z.length>0){const $=c.Children.toArray(o);z.length!==$.length&&console.warn(`[Split] collapsed length (${z.length}) doesn't match children count (${$.length})`)}}},[l,w,h,z,o]);const{panes:k,addPane:j,removePane:_,togglePane:q,setPaneSize:V,getPaneState:ce,removePanes:ue,swapPanes:de,collapsePane:X,expandPane:Y,resizePane:fe}=$e(o,l,z,w,h,a),[T,he]=c.useState(null);c.useEffect(()=>(T&&T.active?(document.body.classList.add("a-split-body-dragging"),document.body.classList.add(s==="horizontal"?"a-split-body-dragging-horizontal":"a-split-body-dragging-vertical")):(document.body.classList.remove("a-split-body-dragging"),document.body.classList.remove("a-split-body-dragging-horizontal"),document.body.classList.remove("a-split-body-dragging-vertical")),()=>{document.body.classList.remove("a-split-body-dragging"),document.body.classList.remove("a-split-body-dragging-horizontal"),document.body.classList.remove("a-split-body-dragging-vertical")}),[T,s]);const Be=c.useCallback(()=>({panes:k,mode:s,dragState:T}),[k,s,T]),qe=c.useCallback(f=>{switch(f.type){case"ADD_PANE":j(f.payload);break;case"REMOVE_PANE":_(f.payload);break;case"TOGGLE_PANE":q(f.payload);break;case"SET_PANE_SIZE":V(f.payload.index,f.payload.size);break;case"RESTORE_STATE":f.payload.panes.forEach((y,x)=>{V(x,y.size),y.collapsed&&q(x)});break;case"ADJUST_PANE_SIZE":if(f.payload&&(T==null?void 0:T.paneIndex)!=null){const y=T.paneIndex,x=k[y];if(x){const $=parseFloat(x.size),F=f.payload.direction==="grow"?f.payload.amount:-f.payload.amount,R=Math.max(x.minSize||0,Math.min(x.maxSize||100,$+F));V(y,`${R}%`)}}break}},[j,_,q,V,k,T]),pe=Fe(a,Be,qe,u);c.useEffect(()=>{if(b.length>0)return S.current=new Le(pe),S.current.registerPlugins(b),()=>{var f;(f=S.current)==null||f.destroy(),S.current=null}},[b,pe]);const Q=De(m,`split-state-${a}`,s);c.useEffect(()=>{const f=Q.load();f&&f.length===k.length&&f.forEach((y,x)=>{k[x]&&y.id===k[x].id&&(V(x,y.size),y.collapsed!==k[x].collapsed&&q(x))})},[]),c.useEffect(()=>{Q.save(k)},[k,Q]);const ge=c.useRef(!0),me=c.useRef(c.Children.count(o)),K=c.useRef(l);c.useEffect(()=>{if(!u.current||l.length===0)return;const f=c.Children.count(o),y=f!==me.current,x=l.length!==K.current.length||l.some(($,F)=>$!==K.current[F]);(ge.current||y||x)&&(l.forEach(($,F)=>{V(F,$)}),ge.current=!1,me.current=f,K.current=l)},[o,l]);const ee=c.useRef(z);c.useEffect(()=>{!u.current||!z.some((y,x)=>y!==ee.current[x])&&ee.current.length===z.length||(ee.current=z,z.forEach((y,x)=>{const $=k[x];$&&$.collapsed!==y&&(y?X(x):Y(x))}))},[z,k,X,Y]),c.useEffect(()=>{u.current&&k.forEach((f,y)=>{var $;const x=($=u.current)==null?void 0:$.querySelector(`[data-pane-id="${f.id}"]`);if(x){const F=w[y],R=h[y];F!==void 0&&x.setAttribute("data-min-size",String(w[y])),R!==void 0&&x.setAttribute("data-max-size",String(h[y]))}})},[w,h,k]),c.useEffect(()=>{if(!u.current)return;u.current.querySelectorAll(".a-split-handlebar").forEach((y,x)=>{const $=y,F=x+1;ne(F,C)?($.classList.add("a-split-handlebar-disabled"),$.style.cursor="default"):($.classList.remove("a-split-handlebar-disabled"),$.style.cursor=s==="horizontal"?"col-resize":"row-resize");const G=re(F,P);$.style.display=G?"":"none",se(F,v)?$.classList.add("a-split-handlebar-line"):$.classList.remove("a-split-handlebar-line")})},[C,P,v,s]);const{handleMouseDown:Se}=Ae(u,s,{onDragStart:f=>{var x;he({active:!0,paneIndex:f.paneIndex}),(x=S.current)==null||x.onDragStart(f);const y=k[f.paneIndex];y&&(r==null||r(f.paneIndex,y.id,"dragging",null))},onDragMove:f=>{var x;(((x=S.current)==null?void 0:x.onDragMove(f))??!0)&&(g==null||g(f.prevSize,f.nextSize,f.paneIndex))},onDragEnd:f=>{var x;V(f.paneIndex-1,`${f.prevSize}%`),V(f.paneIndex,`${f.nextSize}%`),he(null),(x=S.current)==null||x.onDragEnd(f),p==null||p(f.prevSize,f.nextSize,f.paneIndex);const y=k[f.paneIndex];y&&(r==null||r(f.paneIndex,y.id,"dragged",null))}}),Oe=c.useCallback((f,y)=>{var $;const x=y==="left"?f-1:f;if(x>=0&&x<k.length){X(x,{direction:y});const F=k[x];F&&(($=S.current)==null||$.onPaneCollapse({pane:F,index:x,direction:y}),r==null||r(x,F.id,"close",y))}},[k,X,r]),Xe=c.useCallback((f,y)=>{var $;const x=y==="left"?f-1:f;if(x>=0&&x<k.length){Y(x,{direction:y});const F=k[x];F&&(($=S.current)==null||$.onPaneExpand({pane:F,index:x,direction:y}),r==null||r(x,F.id,"open",y))}},[k,Y,r]);c.useImperativeHandle(e,()=>({addPane:j,removePane:_,togglePane:q,setPaneSize:V,getPaneState:ce,removePanes:ue,swapPanes:de,collapsePane:X,expandPane:Y,resizePane:fe,getSnapshot:()=>{const f=u.current,y=f?s==="horizontal"?f.offsetWidth:f.offsetHeight:0;return{panes:k.map(x=>({...x})),totalSize:y,mode:s,timestamp:Date.now()}},restore:f=>{if(f.mode!==s){console.warn(`Cannot restore snapshot with different mode. Current: ${s}, Snapshot: ${f.mode}`);return}f.panes.forEach((y,x)=>{k[x]&&(V(x,y.size),y.collapsed!==k[x].collapsed&&q(x))})}}),[j,_,q,V,ce,ue,de,X,Y,fe,k,s]);const Ye=c.useMemo(()=>({display:"flex",flexDirection:s==="horizontal"?"row":"column",width:E||"100%",height:D||"100%",overflow:"hidden",...M}),[s,E,D,M]),Ue=c.useMemo(()=>{const f=["a-split-container"];return s==="vertical"&&f.push("a-split-vertical"),(N||L)&&f.push("a-split-fix"),T!=null&&T.active&&f.push("a-split-dragging"),I&&f.push(I),f.join(" ")},[s,N,L,I,T==null?void 0:T.active]),We=()=>{const f=[];return k.forEach((y,x)=>{var F;const $=H.jsx(Z,{level:A+1,children:y.content});if(f.push(H.jsx(oe,{id:y.id,size:y.size,collapsed:y.collapsed,minSize:y.minSize,maxSize:y.maxSize,mode:s,content:$,flexGrow:y.flexGrow},y.id)),x<k.length-1){const R=x+1,G=k[x+1];if(!G)return;const W=Ee(),J=re(R,P),ze=se(R,v),we=y.collapsed||!1,xe=G.collapsed||!1,be=ne(R,C),ye=be||we||xe;if(J&&W){const Pe=(F=S.current)==null?void 0:F.renderHandle({index:R,mode:s,disabled:ye,lineBar:ze,onMouseDown:O=>Se(R,O)});Pe?f.push(H.jsx(c.Fragment,{children:Pe},`handlebar-${R}`)):f.push(H.jsx(ae,{index:R,mode:s,disabled:ye,lineBar:ze,explicitlyDisabled:be,onMouseDown:O=>Se(R,O),onCollapse:O=>Oe(R,O),onExpand:O=>Xe(R,O),renderCustom:d,leftPaneCollapsed:we,rightPaneCollapsed:xe},`handlebar-${R}`))}}}),f};return H.jsx("div",{ref:u,id:a,className:Ue,style:Ye,children:We()})});le.displayName="Split";function Et(t={}){const{mode:e="horizontal",initialPanes:n=[],initialSizes:s=[],minSizes:l=[],maxSizes:w=[],onPaneChange:h}=t,[z,C]=c.useState(()=>n.length>0?n:s.map((r,i)=>({id:`pane-${i}`,size:r,collapsed:!1,minSize:l[i]||0,maxSize:w[i]||100,content:null}))),[P]=c.useState(!1),v=c.useRef(!1),d=c.useCallback(r=>{C(i=>{const a=typeof r=="function"?r(i):r;return!v.current&&h&&h(a),a})},[h]),b=c.useCallback(r=>{d(i=>{const a=r.position??i.length,u={id:`pane-${Date.now()}`,size:r.size,collapsed:r.collapsed||!1,minSize:r.minSize||0,maxSize:r.maxSize||100,content:r.content},S=[...i];return S.splice(a,0,u),S})},[d]),m=c.useCallback(r=>{d(i=>{if(r<0||r>=i.length)return i;const a=[...i],u=a.splice(r,1)[0];if(u&&a.length>0){const A=(parseFloat(u.size)||0)/a.length;return a.map(L=>({...L,size:`${(parseFloat(L.size)||0)+A}%`}))}return a})},[d]),E=c.useCallback(r=>{d(i=>{const a=[...r].sort((A,L)=>L-A);let u=[...i],S=0;if(a.forEach(A=>{if(A>=0&&A<u.length){const L=u.splice(A,1)[0];L&&(S+=parseFloat(L.size)||0)}}),u.length>0&&S>0){const A=S/u.length;u=u.map(L=>({...L,size:`${(parseFloat(L.size)||0)+A}%`}))}return u})},[d]),D=c.useCallback(r=>{d(i=>{if(r<0||r>=i.length)return i;const a=i[r];if(!a)return i;const u=[...i];return u[r]={...a,collapsed:!a.collapsed},u})},[d]),I=c.useCallback(r=>{d(i=>{if(r<0||r>=i.length)return i;const a=i[r];if(!a||a.collapsed)return i;const u=[...i];return u[r]={...a,collapsed:!0},u})},[d]),M=c.useCallback(r=>{d(i=>{if(r<0||r>=i.length)return i;const a=i[r];if(!a||!a.collapsed)return i;const u=[...i];return u[r]={...a,collapsed:!1},u})},[d]),N=c.useCallback((r,i,a)=>{d(u=>{if(r<0||r>=u.length)return u;const S=u[r];if(!S)return u;const A=[...u];return A[r]={...S,size:i},A})},[d]),o=c.useCallback((r,i)=>{d(a=>{if(r<0||r>=a.length||i<0||i>=a.length||r===i)return a;const u=[...a],S=u[r];return u[r]=u[i],u[i]=S,u})},[d]),g=c.useCallback(()=>({panes:z.map(r=>({...r})),totalSize:0,mode:e,timestamp:Date.now()}),[z,e]),p=c.useCallback(r=>{if(r.mode!==e){console.warn(`Cannot restore snapshot with different mode. Current: ${e}, Snapshot: ${r.mode}`);return}v.current=!0,d(i=>r.panes.map((a,u)=>{const S=i.find(A=>A.id===a.id)||i[u];return{id:a.id,size:a.size,collapsed:a.collapsed,minSize:(S==null?void 0:S.minSize)??0,maxSize:(S==null?void 0:S.maxSize)??100,content:(S==null?void 0:S.content)??null}})),v.current=!1,h&&C(i=>(h(i),i))},[e,d,h]);return c.useMemo(()=>({panes:z,mode:e,isDragging:P,addPane:b,removePane:m,removePanes:E,togglePane:D,collapsePane:I,expandPane:M,setPaneSize:N,swapPanes:o,setPanes:d,getSnapshot:g,restore:p}),[z,e,P,b,m,E,D,I,M,N,o,d,g,p])}function $t(t){return t}function kt(t={}){const{storage:e="localStorage",key:n,debounceDelay:s=300}=t;let l=null;const w=v=>n||`a-multilayout-splitter:${v}`,h=()=>typeof window>"u"?null:e==="localStorage"?window.localStorage:window.sessionStorage,z=(v,d)=>{const b=h();if(b)try{const m=w(v),E=JSON.stringify({panes:d.panes.map(D=>({id:D.id,size:D.size,collapsed:D.collapsed})),mode:d.mode,timestamp:Date.now()});b.setItem(m,E)}catch(m){console.error("Failed to save split state:",m)}},C=v=>{const d=h();if(!d)return null;try{const b=w(v),m=d.getItem(b);return m?JSON.parse(m):null}catch(b){return console.error("Failed to load split state:",b),null}},P=(v,d)=>{l&&clearTimeout(l),l=setTimeout(()=>{z(v,d),l=null},s)};return{name:"persistence",version:"1.0.0",onInit(v){const d=C(v.splitId),b=d==null?void 0:d.panes;b&&b.length>0?setTimeout(()=>{v.getState().panes.length===b.length&&v.dispatch({type:"RESTORE_STATE",payload:{panes:b}})},0):setTimeout(()=>{const m=v.getState();z(v.splitId,m)},0)},onDragEnd(v,d){setTimeout(()=>{const b=d.getState();P(d.splitId,b)},0)},onPaneAdd(v,d){setTimeout(()=>{const b=d.getState();P(d.splitId,b)},0)},onPaneRemove(v,d){setTimeout(()=>{const b=d.getState();P(d.splitId,b)},0)},onPaneCollapse(v,d){setTimeout(()=>{const b=d.getState();P(d.splitId,b)},0)},onPaneExpand(v,d){setTimeout(()=>{const b=d.getState();P(d.splitId,b)},0)},onDestroy(){l&&(clearTimeout(l),l=null)}}}function It(t,e="localStorage"){const n=e==="localStorage"?window.localStorage:window.sessionStorage;try{const s=`a-multilayout-splitter:${t}`;n.removeItem(s)}catch(s){console.error("Failed to clear persisted state:",s)}}function At(t={}){const{enableArrowKeys:e=!0,enableNumberKeys:n=!0,stepSize:s=5,enableTabNavigation:l=!0}=t;let w=0,h=null;const z=(C,P)=>{if(!C)return;const d=C.querySelectorAll(".a-split-pane")[P];d&&(d.focus(),d.setAttribute("tabindex","0"),w=P)};return{name:"keyboard",version:"1.0.0",onInit(C){const P=C.getElement();if(!P)return;P.setAttribute("tabindex","0"),P.querySelectorAll(".a-split-pane").forEach((d,b)=>{d.setAttribute("tabindex",b===0?"0":"-1")}),h=d=>{const b=C.getState(),m=b.panes;if(e&&(d.key==="ArrowLeft"||d.key==="ArrowRight"||d.key==="ArrowUp"||d.key==="ArrowDown")){d.preventDefault();const E=b.mode==="horizontal",D=E&&d.key==="ArrowRight"||!E&&d.key==="ArrowDown",I=w,M=m[I],N=I<m.length-1?I+1:I-1,o=m[N];if(!M||!o)return;const g=parseFloat(M.size),p=parseFloat(o.size),r=D?s:-s;let i=g+r,a=p-r;const u=M.minSize||0,S=M.maxSize||100,A=o.minSize||0,L=o.maxSize||100;i=Math.max(u,Math.min(S,i)),a=Math.max(A,Math.min(L,a));const k=g+p;i+a!==k&&(i===u||i===S?a=k-i:i=k-a),C.dispatch({type:"SET_PANE_SIZE",payload:{index:I,size:`${i}%`}}),C.dispatch({type:"SET_PANE_SIZE",payload:{index:N,size:`${a}%`}})}if(n){const E=parseInt(d.key,10);if(!isNaN(E)&&E>=1&&E<=9){const D=E-1;D<m.length&&z(P,D)}}if(l&&d.key==="Tab"){d.preventDefault();let E=d.shiftKey?w-1:w+1;E<0?E=m.length-1:E>=m.length&&(E=0),z(P,E)}},P.addEventListener("keydown",h)},onDestroy(C){const P=C.getElement();P&&h&&(P.removeEventListener("keydown",h),h=null)}}}function Dt(t,e){return{name:"custom-handle",version:"1.0.0",renderHandle(n){return c.createElement(t,{...n,...e})}}}function Ft(t){return{name:"custom-handle-render",version:"1.0.0",renderHandle(e){return t(e)}}}const Me=c.createContext(null),Te=c.createContext(null),je=c.createContext(null);function Ht({id:t,mode:e="horizontal",enableSessionStorage:n=!1,storageKey:s=`split-state-${t}`,children:l,_panes:w=[],_addPane:h,_removePane:z,_togglePane:C,_setPaneSize:P,_getPaneState:v}){const d=c.useRef({isDragging:!1,activeHandlebar:null}),b=c.useMemo(()=>({id:t,mode:e,enableSessionStorage:n,storageKey:s}),[t,e,n,s]),m=c.useMemo(()=>({panes:w,isDragging:d.current.isDragging,activeHandlebar:d.current.activeHandlebar}),[w,d.current.isDragging,d.current.activeHandlebar]),E=c.useMemo(()=>({addPane:h||(()=>console.warn("addPane not available")),removePane:z||(()=>console.warn("removePane not available")),togglePane:C||(()=>console.warn("togglePane not available")),setPaneSize:P||(()=>console.warn("setPaneSize not available")),getPaneState:v||(()=>[]),setDragging:(D,I)=>{d.current.isDragging=D,d.current.activeHandlebar=I??null}}),[h,z,C,P,v]);return H.jsx(Me.Provider,{value:b,children:H.jsx(Te.Provider,{value:m,children:H.jsx(je.Provider,{value:E,children:l})})})}function Ve(){const t=c.useContext(Me);if(!t)throw new Error("useSplitConfig must be used within SplitProvider");return t}function U(){const t=c.useContext(Te);if(!t)throw new Error("useSplitState must be used within SplitProvider");return t}function Ge(){return c.useContext(je)}function Rt(){const t=Ge();if(!t)throw new Error("useSplit must be used within SplitProvider");return{config:Ve(),state:U(),actions:t}}function _e(t){const{panes:e}=U();return e[t]}function Nt(){const{panes:t}=U();return t.length}function Lt(){const{isDragging:t}=U();return t}function Mt(t){const e=_e(t);return(e==null?void 0:e.collapsed)??!1}function Tt(){const{panes:t}=U();return c.useMemo(()=>t.filter(e=>!e.collapsed),[t])}exports.DragHandle=ae;exports.NestingProvider=Z;exports.PaneComponent=oe;exports.PluginManager=Le;exports.Split=le;exports.SplitProvider=Ht;exports.animatePaneSize=ve;exports.applyCollapseState=Qe;exports.batchUpdatePanes=at;exports.calculateFlexBasis=Re;exports.calculateFlexValues=Ne;exports.calculateHandlebarPosition=wt;exports.calculateTotalSize=St;exports.canResize=Pt;exports.clampSize=mt;exports.clearPersistedState=It;exports.constrainSize=rt;exports.createPane=st;exports.createPlugin=$t;exports.customHandlePlugin=Dt;exports.customHandleRenderPlugin=Ft;exports.debounce=Ie;exports.default=le;exports.findPaneIndex=et;exports.getAxisProperty=vt;exports.getContainerDimensions=bt;exports.getCoordinateProperty=Ct;exports.getPaneElement=nt;exports.getVisiblePanes=tt;exports.haveSameUnit=gt;exports.isHandlebarDisabled=ne;exports.isHandlebarVisible=re;exports.isLineBarStyle=se;exports.isPaneVisible=Ce;exports.keyboardPlugin=At;exports.normalizePaneSizes=yt;exports.normalizeSize=pt;exports.parseSize=B;exports.percentageToPixel=ft;exports.persistencePlugin=kt;exports.pixelToPercentage=ht;exports.restorePaneState=ot;exports.serializePaneState=lt;exports.shouldShowHandlebar=Ee;exports.throttle=ke;exports.togglePaneCollapse=Ke;exports.updatePaneSize=it;exports.useDragHandler=Ae;exports.useIsCollapsed=Mt;exports.useIsDragging=Lt;exports.useNestingLevel=ie;exports.usePane=_e;exports.usePaneCount=Nt;exports.usePaneManager=$e;exports.usePersistence=De;exports.usePluginContext=Fe;exports.useSplit=Rt;exports.useSplitActions=Ge;exports.useSplitConfig=Ve;exports.useSplitController=Et;exports.useSplitState=U;exports.useVisiblePanes=Tt;exports.validatePaneSizes=zt;exports.withNesting=dt;
1
+ "use strict";var We=Object.defineProperty;var Ze=(t,e,n)=>e in t?We(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var te=(t,e,n)=>Ze(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("react/jsx-runtime"),l=require("react");function Qe(t,e){e?(t.classList.add("a-split-hidden"),t.style.flexGrow="0",t.style.flexShrink="0",t.style.flexBasis="0"):(t.classList.remove("a-split-hidden"),t.style.flexGrow="",t.style.flexShrink="")}function Pe(t,e,n={}){return new Promise(s=>{const u=n.duration||300;if(!n.animate){t.style.flexBasis=e,s();return}t.style.transition=`flex-basis ${u}ms ease`,t.offsetHeight,t.style.flexBasis=e,setTimeout(()=>{t.style.transition="",s()},u)})}function Ke(t){return{...t,collapsed:!t.collapsed}}function et(t,e){return t.findIndex(n=>n.id===e)}function ve(t){return!t.collapsed}function tt(t){return t.filter(ve)}function nt(t){return document.querySelector(`[data-pane-id="${t}"]`)}function rt(t,e,n){return Math.max(e,Math.min(n,t))}function st(t,e,n,s={}){return{id:t,size:e,content:n,collapsed:s.collapsed??!1,minSize:s.minSize??0,maxSize:s.maxSize??100}}function it(t,e){return{...t,size:e}}function at(t,e){return t.map(n=>{const s=e.get(n.id);return s?{...n,...s}:n})}function ot(t,e){return{...t,size:e.size,collapsed:e.collapsed}}function lt(t){return{id:t.id,size:t.size,collapsed:t.collapsed}}function Ce(t,e){return!0}function ne(t,e){return typeof e=="boolean"?e:Array.isArray(e)?e.length>0&&typeof e[0]=="boolean"?e[t-1]===!0:e.includes(t):!1}function re(t,e){return typeof e=="boolean"?e:Array.isArray(e)?e.length>0&&typeof e[0]=="boolean"?e[t-1]!==!1:e.includes(t):!0}function se(t,e){return typeof e=="boolean"?e:Array.isArray(e)?e.length>0&&typeof e[0]=="boolean"?e[t-1]===!0:e.includes(t):!1}function Ee(t,e=[],n=[],s=[],u=[],x="split"){const[g,z]=l.useState(()=>l.Children.toArray(t).map((p,h)=>({id:`${x}-pane-${h}`,size:e[h]||"100%",collapsed:n[h]||!1,minSize:s[h]||0,maxSize:u[h]||100,content:p}))),C=l.useRef(t);l.useEffect(()=>{const o=l.Children.toArray(t),p=l.Children.toArray(C.current);o.length===g.length&&z(h=>{let r=!1;const i=h.map((a,c)=>{const S=o[c],F=p[c];return S!==F?(r=!0,{...a,content:S}):a});return r?i:h}),C.current=t},[t,g.length]);const P=l.useCallback(o=>{z(p=>{const h=o.position??p.length,r={id:`${x}-pane-${Date.now()}`,size:o.size,collapsed:o.collapsed||!1,minSize:o.minSize||0,maxSize:o.maxSize||100,content:o.content},i=[...p];return i.splice(h,0,r),ct(i,h,o.size)})},[x]),v=l.useCallback(o=>{z(p=>{if(o<0||o>=p.length)return p;const h=[...p],r=h.splice(o,1)[0];return r?ut(h,r.size):h})},[]),d=l.useCallback(o=>{z(p=>{if(o<0||o>=p.length)return p;const h=p[o];if(!h)return p;const r=[...p];r[o]={...h,collapsed:!h.collapsed};const i=document.querySelector(`[data-pane-id="${h.id}"]`);if(i){const a=r[o];(a==null?void 0:a.collapsed)??!1?(i.classList.add("a-split-hidden"),i.style.flexGrow="0"):(i.classList.remove("a-split-hidden"),i.style.flexGrow="")}return r})},[]),b=l.useCallback((o,p,h)=>{z(r=>{if(o<0||o>=r.length)return r;const i=r[o];if(!i)return r;const a=[...r];a[o]={...i,size:p,flexGrow:void 0};const c=document.querySelector(`[data-pane-id="${i.id}"]`);return c&&Pe(c,p,h||{animate:!1}),a})},[]),m=l.useCallback(()=>g,[g]),E=l.useCallback(o=>{z(p=>{const h=[...o].sort((a,c)=>c-a);let r=[...p],i=0;if(h.forEach(a=>{if(a>=0&&a<r.length){const c=r.splice(a,1)[0];c&&(i+=parseFloat(c.size)||0)}}),r.length>0&&i>0){const a=i/r.length;r=r.map(c=>({...c,size:`${(parseFloat(c.size)||0)+a}%`}))}return r})},[]),A=l.useCallback((o,p)=>{z(h=>{if(o<0||o>=h.length||p<0||p>=h.length||o===p)return h;const r=[...h],i=r[o];return r[o]=r[p],r[p]=i,r})},[]),I=l.useCallback((o,p)=>{z(h=>{if(o<0||o>=h.length)return h;const r=h[o];if(!r||r.collapsed)return h;const i=p==null?void 0:p.direction;let a;i==="left"?a=o+1:i==="right"?a=o-1:a=o<h.length-1?o+1:o-1;const c=h.map((S,F)=>F===o?{...S,collapsed:!0,flexGrow:0}:F===a&&!S.collapsed?{...S,flexGrow:1}:S.collapsed?S:{...S,flexGrow:0});if(p!=null&&p.animate){const S=document.querySelector(`[data-pane-id="${r.id}"]`);S&&(S.style.transition=`flex-basis ${p.duration||300}ms ease`,setTimeout(()=>{S.style.transition=""},p.duration||300))}return c})},[]),T=l.useCallback((o,p)=>{z(h=>{if(o<0||o>=h.length)return h;const r=h[o];if(!r||!r.collapsed)return h;const i=h.filter(S=>!S.collapsed).length+1,a=h.length;let c=[...h];if(c[o]={...r,collapsed:!1,flexGrow:void 0},i===a)c=c.map(S=>({...S,flexGrow:void 0}));else{const S=p==null?void 0:p.direction;let F;if(S==="left"?F=o+1:S==="right"?F=o-1:F=o<h.length-1?o+1:o-1,F>=0&&F<c.length){const L=c[F];L&&L.flexGrow===1&&(c[F]={...L,flexGrow:void 0})}}if(p!=null&&p.animate){const S=document.querySelector(`[data-pane-id="${r.id}"]`);S&&(S.style.transition=`flex-basis ${p.duration||300}ms ease`,setTimeout(()=>{S.style.transition=""},p.duration||300))}return c})},[]),N=l.useCallback((o,p)=>{z(h=>{if(o<0||o>=h.length)return h;const r=h[o];if(!r)return h;const i=parseFloat(r.size)||0,a=Math.max(r.minSize||0,Math.min(r.maxSize||100,i+p)),c=[...h];c[o]={...r,size:`${a}%`};const S=document.querySelector(`[data-pane-id="${r.id}"]`);return S&&(S.style.flexBasis=`${a}%`),c})},[]);return{panes:g,addPane:P,removePane:v,togglePane:d,setPaneSize:b,getPaneState:m,removePanes:E,swapPanes:A,collapsePane:I,expandPane:T,resizePane:N}}function ct(t,e,n){const s=parseFloat(n);if(!n.includes("%"))return t;const g=t.filter((C,P)=>P!==e).reduce((C,P)=>C+parseFloat(P.size),0),z=(100-s)/g;return t.map((C,P)=>{if(P===e)return C;const d=parseFloat(C.size)*z;return{...C,size:C.size.includes("%")?`${d}%`:C.size}})}function ut(t,e){if(t.length===0)return t;const n=parseFloat(e);if(!e.includes("%"))return t;const u=n/t.length;return t.map(x=>{if(!x.size.includes("%"))return x;const z=parseFloat(x.size)+u;return{...x,size:`${z}%`}})}function $e(t,e){let n=null,s=0;return function(...x){const g=Date.now();g-s>=e?(t(...x),s=g):(n&&clearTimeout(n),n=setTimeout(()=>{t(...x),s=Date.now()},e-(g-s)))}}function ke(t,e){let n=null;return function(...u){n&&clearTimeout(n),n=setTimeout(()=>{t(...u)},e)}}function Ie(t,e,n={}){const{onDragStart:s,onDragMove:u,onDragEnd:x}=n,g=l.useRef(null),z=l.useRef(null),C=l.useCallback((b,m)=>{var c,S;m.preventDefault(),m.stopPropagation();const E=m.target;if(E.closest("button")||E.tagName==="BUTTON")return;const A=t.current;if(!A)return;const I=Array.from(A.children),T=(b-1)*2,N=b*2,o=I[T],p=I[N];if(!o||!p||o.classList.contains("a-split-hidden")||p.classList.contains("a-split-hidden"))return;const h="touches"in m?((c=m.touches[0])==null?void 0:c.clientX)??0:m.clientX,r="touches"in m?((S=m.touches[0])==null?void 0:S.clientY)??0:m.clientY,i=Array.from(A.querySelectorAll(".a-split-handlebar")).filter(F=>F.parentElement===A);let a=0;i.forEach(F=>{const L=F,k=window.getComputedStyle(L);if(e==="horizontal"){const j=parseFloat(k.marginLeft)||0,_=parseFloat(k.marginRight)||0;a+=L.offsetWidth+j+_}else{const j=parseFloat(k.marginTop)||0,_=parseFloat(k.marginBottom)||0;a+=L.offsetHeight+j+_}}),g.current={active:!0,paneIndex:b,startX:h,startY:r,prevElement:o,nextElement:p,prevInitialWidth:o.offsetWidth,nextInitialWidth:p.offsetWidth,prevInitialHeight:o.offsetHeight,nextInitialHeight:p.offsetHeight,containerWidth:A.offsetWidth-(e==="horizontal"?a:0),containerHeight:A.offsetHeight-(e==="vertical"?a:0),minPrevSize:parseFloat(o.getAttribute("data-min-size")||"0"),maxPrevSize:parseFloat(o.getAttribute("data-max-size")||"100"),minNextSize:parseFloat(p.getAttribute("data-min-size")||"0"),maxNextSize:parseFloat(p.getAttribute("data-max-size")||"100")},z.current=null,s==null||s({paneIndex:b})},[t,s,e]),P=l.useCallback(b=>{var k,j;const m=g.current;if(!(m!=null&&m.active))return null;const E=e==="horizontal",A="touches"in b?((k=b.touches[0])==null?void 0:k.clientX)??0:b.clientX,I="touches"in b?((j=b.touches[0])==null?void 0:j.clientY)??0:b.clientY,T=E?A-m.startX:I-m.startY,N=E?m.containerWidth:m.containerHeight,o=E?m.prevInitialWidth:m.prevInitialHeight,p=E?m.nextInitialWidth:m.nextInitialHeight;let h=o+T,r=p-T;h<0&&(h=0),r<0&&(r=0);const i=h/N*100,a=r/N*100,c=i<=m.minPrevSize,S=i>=m.maxPrevSize,F=a<=m.minNextSize,L=a>=m.maxNextSize;return c||S||F||L?null:{prevSize:i,nextSize:a,prevSizePx:h,nextSizePx:r,state:m}},[e]),v=l.useCallback($e(b=>{const m=P(b);if(!m)return;const{prevSize:E,nextSize:A,prevSizePx:I,nextSizePx:T,state:N}=m,{prevInitialWidth:o,prevInitialHeight:p}=N,h=e==="horizontal"?o:p;Math.abs(m.prevSizePx-h)<=1||(z.current={prevSize:E,nextSize:A},requestAnimationFrame(()=>{if(!N.prevElement||!N.nextElement)return;const r=N.prevElement.style.flexBasis.includes("%"),i=N.nextElement.style.flexBasis.includes("%");r?N.prevElement.style.flexBasis=`${E}%`:N.prevElement.style.flexBasis=`${I}px`,i?N.nextElement.style.flexBasis=`${A}%`:N.nextElement.style.flexBasis=`${T}px`}),u==null||u({paneIndex:N.paneIndex,prevSize:E,nextSize:A}))},16),[P,e,u]),d=l.useCallback(b=>{const m=g.current;if(!(m!=null&&m.active))return;const E=P(b);E&&(z.current={prevSize:E.prevSize,nextSize:E.nextSize});const A=z.current;A&&(x==null||x({paneIndex:m.paneIndex,prevSize:A.prevSize,nextSize:A.nextSize})),g.current=null,z.current=null},[P,x]);return l.useEffect(()=>{const b=v,m=d;return window.addEventListener("mousemove",b),window.addEventListener("mouseup",m),window.addEventListener("touchmove",b,{passive:!1}),window.addEventListener("touchend",m),()=>{window.removeEventListener("mousemove",b),window.removeEventListener("mouseup",m),window.removeEventListener("touchmove",b),window.removeEventListener("touchend",m)}},[v,d]),{handleMouseDown:C}}function Fe(t,e,n){const s=l.useCallback(ke(g=>{if(t)try{const z=`${e}-${n}`,C=g.map(P=>({id:P.id,size:P.size,collapsed:P.collapsed}));localStorage.setItem(z,JSON.stringify(C))}catch(z){console.warn("Failed to save split state to localStorage:",z)}},300),[t,e,n]),u=l.useCallback(()=>{if(!t)return null;try{const g=`${e}-${n}`,z=localStorage.getItem(g);return z?JSON.parse(z):null}catch(g){return console.warn("Failed to load split state from localStorage:",g),null}},[t,e,n]),x=l.useCallback(()=>{if(t)try{const g=`${e}-${n}`;localStorage.removeItem(g)}catch(g){console.warn("Failed to clear split state from localStorage:",g)}},[t,e,n]);return{save:s,load:u,clear:x}}function Ae(t,e,n,s){const u=l.useRef(e),x=l.useRef(n);return u.current=e,x.current=n,l.useMemo(()=>({splitId:t,getState:()=>u.current(),dispatch:z=>x.current(z),getElement:()=>s.current,getPanes:()=>u.current().panes}),[t,s])}const De=l.createContext(0);function ie(){return l.useContext(De)}const Z=({level:t=0,children:e})=>H.jsx(De.Provider,{value:t,children:e});Z.displayName="NestingProvider";function dt(t){const e=n=>{const s=ie();return H.jsx(Z,{level:s+1,children:H.jsx(t,{...n})})};return e.displayName=`withNesting(${t.displayName||t.name||"Component"})`,e}const ae=({index:t,mode:e,disabled:n,lineBar:s,onMouseDown:u,onTouchStart:x,onCollapse:g,onExpand:z,renderCustom:C,leftPaneCollapsed:P=!1,rightPaneCollapsed:v=!1,explicitlyDisabled:d=!1})=>{if(C){const a={index:t,mode:e,disabled:n,lineBar:s,onMouseDown:u,onTouchStart:x||u,onCollapse:g,onExpand:z};return H.jsx("div",{className:"a-split-handlebar",onMouseDown:c=>!n&&u(c),onTouchStart:c=>!n&&(x?x(c):u(c)),children:C(a,t)})}const b=["a-split-handlebar",e==="horizontal"?"a-split-handlebar-horizontal":"a-split-handlebar-vertical",n?"a-split-handlebar-disabled":"",s?"a-split-handlebar-line":""].filter(Boolean).join(" "),m=a=>{a.stopPropagation(),v?z==null||z("right"):g==null||g("left")},E=a=>{a.stopPropagation(),P?z==null||z("left"):g==null||g("right")},A=!s&&!d,I=e==="horizontal",T=P&&!v,N=v&&!P,o=I?"M8 3L4 6L8 9":"M3 8L6 4L9 8",p=I?"M4 3L8 6L4 9":"M3 4L6 8L9 4",h=o,r=p,i=P||v;return H.jsx("div",{className:b,onMouseDown:a=>!n&&u(a),onTouchStart:a=>!n&&u(a),style:{cursor:n?"default":I?"col-resize":"row-resize"},children:A&&H.jsxs(H.Fragment,{children:[H.jsx("button",{className:`a-split-collapse-btn a-split-collapse-btn-${I?"left":"top"}${T?" hidden":""}`,onClick:m,"aria-label":v?`Expand ${I?"right":"bottom"} pane`:`Collapse ${I?"left":"top"} pane`,title:v?`Expand ${I?"right":"bottom"} pane`:`Collapse ${I?"left":"top"} pane`,children:H.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:H.jsx("path",{d:h,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),H.jsx("div",{className:`a-split-grip-icon${i?" hidden":""}`,"aria-hidden":"true",children:I?H.jsxs("svg",{width:"8",height:"24",viewBox:"0 0 8 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[H.jsx("circle",{cx:"4",cy:"4",r:"2.5",fill:"currentColor"}),H.jsx("circle",{cx:"4",cy:"12",r:"2.5",fill:"currentColor"}),H.jsx("circle",{cx:"4",cy:"20",r:"2.5",fill:"currentColor"})]}):H.jsxs("svg",{width:"24",height:"8",viewBox:"0 0 24 8",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[H.jsx("circle",{cx:"4",cy:"4",r:"2.5",fill:"currentColor"}),H.jsx("circle",{cx:"12",cy:"4",r:"2.5",fill:"currentColor"}),H.jsx("circle",{cx:"20",cy:"4",r:"2.5",fill:"currentColor"})]})}),H.jsx("button",{className:`a-split-collapse-btn a-split-collapse-btn-${I?"right":"bottom"}${N?" hidden":""}`,onClick:E,"aria-label":P?`Expand ${I?"left":"top"} pane`:`Collapse ${I?"right":"bottom"} pane`,title:P?`Expand ${I?"left":"top"} pane`:`Collapse ${I?"right":"bottom"} pane`,children:H.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:H.jsx("path",{d:r,stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]})})};ae.displayName="DragHandle";function ft(t,e){if(e.includes("vw")){const n=parseFloat(e);return t/100*window.innerWidth*(n/100)}if(e.includes("vh")){const n=parseFloat(e);return t/100*window.innerHeight*(n/100)}if(e.includes("px")){const n=parseFloat(e);return t/100*n}return e.includes("%")?(console.warn("Percentage reference not fully supported, assuming viewport"),t/100*window.innerWidth*(parseFloat(e)/100)):t/100*parseFloat(e)}function ht(t,e){if(e.includes("vw")){const n=parseFloat(e),s=window.innerWidth*(n/100);return t/s*100}if(e.includes("vh")){const n=parseFloat(e),s=window.innerHeight*(n/100);return t/s*100}if(e.includes("px")){const n=parseFloat(e);return t/n*100}if(e.includes("%")){console.warn("Percentage reference not fully supported, assuming viewport");const n=window.innerWidth*(parseFloat(e)/100);return t/n*100}return t/parseFloat(e)*100}function pt(t,e,n){const s=parseFloat(t);return t.includes("%")?n==="px"?`${s/100*e}px`:t:t.includes("px")?n==="%"?`${s/e*100}%`:t:n==="px"?`${s}px`:`${s/e*100}%`}function B(t){const e=parseFloat(t);return t.includes("%")?{value:e,unit:"%"}:t.includes("px")?{value:e,unit:"px"}:t.includes("vw")?{value:e,unit:"vw"}:t.includes("vh")?{value:e,unit:"vh"}:t.includes("fr")?{value:e,unit:"fr"}:{value:e,unit:"px"}}function gt(t,e){const n=B(t),s=B(e);return n.unit===s.unit}function mt(t,e,n,s){return`${Math.max(e,Math.min(n,t))}${s}`}function St(t){if(t.length===0)return{total:0,unit:"px"};const e=t[0];if(!e)return{total:0,unit:"px"};const n=B(e.size);let s=0;for(const u of t){const x=B(u.size);x.unit===n.unit||console.warn(`Mixed units detected: ${n.unit} and ${x.unit}. Results may be inaccurate.`),s+=x.value}return{total:s,unit:n.unit}}function zt(t,e){const n=[];if(t.length===0)return n.push("No panes defined"),{valid:!1,errors:n};const s=t.filter(u=>u.size.includes("%"));if(s.length>0){const u=s.reduce((x,g)=>x+parseFloat(g.size),0);u>100.1&&n.push(`Total percentage (${u}%) exceeds 100%`)}return t.forEach((u,x)=>{u.minSize<0&&n.push(`Pane ${x}: minSize cannot be negative`),u.maxSize<u.minSize&&n.push(`Pane ${x}: maxSize (${u.maxSize}) less than minSize (${u.minSize})`),u.maxSize>100&&n.push(`Pane ${x}: maxSize (${u.maxSize}%) exceeds 100%`)}),{valid:n.length===0,errors:n}}function He(t,e){const n=B(t);switch(n.unit){case"%":return t;case"px":return t;case"vw":return`${n.value/100*window.innerWidth}px`;case"vh":return`${n.value/100*window.innerHeight}px`;case"fr":return"0";default:return`${n.value}px`}}function Re(t,e=!1){if(e)return{flexGrow:0,flexShrink:0};const n=B(t.size);return n.unit==="%"?{flexGrow:1,flexShrink:1}:n.unit==="fr"?{flexGrow:n.value,flexShrink:1}:{flexGrow:0,flexShrink:0}}function wt(t,e,n){const s=B(t);return s.unit==="%"?s.value/100*e:s.unit==="px"?s.value:s.unit==="vw"?s.value/100*window.innerWidth:s.unit==="vh"?s.value/100*window.innerHeight:s.value}function xt(t){const e=t.filter(u=>u.size.includes("%"));if(e.length===0)return t;const n=e.reduce((u,x)=>u+parseFloat(x.size),0);if(Math.abs(n-100)<.01)return t;const s=100/n;return t.map(u=>{if(!u.size.includes("%"))return u;const g=parseFloat(u.size)*s;return{...u,size:`${g}%`}})}function bt(t,e,n){const s=e+n;return!(s<t.minSize||s>t.maxSize)}function yt(t){return t==="horizontal"?"width":"height"}function Pt(t){return t==="horizontal"?"clientX":"clientY"}const oe=({id:t,size:e,collapsed:n,minSize:s,maxSize:u,mode:x,content:g,flexGrow:z})=>{const C=e||"100%",P={size:C},{flexGrow:v,flexShrink:d}=Re(P,n),b=z!==void 0?z:v,m=n?"0":He(C);return H.jsx("div",{"data-pane-id":t,"data-min-size":s,"data-max-size":u,className:`a-split-pane${n?" a-split-hidden":""}`,style:{flexBasis:m,flexGrow:b,flexShrink:d,overflow:n?"hidden":"auto"},children:g})};oe.displayName="Pane";class Ne{constructor(e){te(this,"plugins",[]);te(this,"context");this.context=e}registerPlugins(e){this.plugins=e,this.plugins.forEach(n=>{n.onInit&&n.onInit(this.context)})}destroy(){this.plugins.forEach(e=>{e.onDestroy&&e.onDestroy(this.context)}),this.plugins=[]}onPaneAdd(e){this.plugins.forEach(n=>{n.onPaneAdd&&n.onPaneAdd(e,this.context)})}onPaneRemove(e){this.plugins.forEach(n=>{n.onPaneRemove&&n.onPaneRemove(e,this.context)})}onPaneCollapse(e){this.plugins.forEach(n=>{n.onPaneCollapse&&n.onPaneCollapse(e,this.context)})}onPaneExpand(e){this.plugins.forEach(n=>{n.onPaneExpand&&n.onPaneExpand(e,this.context)})}onDragStart(e){this.plugins.forEach(n=>{n.onDragStart&&n.onDragStart(e,this.context)})}onDragMove(e){let n=!0;for(const s of this.plugins)s.onDragMove&&s.onDragMove(e,this.context)===!1&&(n=!1);return n}onDragEnd(e){this.plugins.forEach(n=>{n.onDragEnd&&n.onDragEnd(e,this.context)})}onResize(e){this.plugins.forEach(n=>{n.onResize&&n.onResize(e,this.context)})}renderHandle(e){for(const n of this.plugins)if(n.renderHandle){const s=n.renderHandle(e,this.context);if(s)return s}return null}renderPane(e){for(const n of this.plugins)if(n.renderPane){const s=n.renderPane(e,this.context);if(s)return s}return null}getPlugins(){return this.plugins}getPlugin(e){return this.plugins.find(n=>n.name===e)}hasPlugin(e){return this.plugins.some(n=>n.name===e)}}const Le=l.forwardRef((t,e)=>{const{id:n,mode:s="horizontal",initialSizes:u=[],minSizes:x=[],maxSizes:g=[],collapsed:z=[],disable:C=!1,visible:P=!0,lineBar:v=!1,renderBar:d,plugins:b=[],enablePersistence:m=!1,width:E=null,height:A=null,className:I="",style:T={},fixClass:N=!1,children:o,onDragging:p,onDragEnd:h,onLayoutChange:r}=t,i=l.useRef(`split-${Math.random().toString(36).slice(2,11)}`),a=n||i.current,c=l.useRef(null),S=l.useRef(null),F=ie(),L=!N&&F>2;l.useEffect(()=>{var y,w;if(typeof globalThis<"u"&&((w=(y=globalThis.process)==null?void 0:y.env)==null?void 0:w.NODE_ENV)!=="production"){if(u.length>0){const $=l.Children.toArray(o);u.length!==$.length&&console.warn(`[Split] initialSizes length (${u.length}) doesn't match children count (${$.length})`),u.forEach((R,G)=>{if(typeof R=="string"){const J=parseFloat(R);if(isNaN(J)&&console.warn(`[Split] Invalid size at index ${G}: "${R}". Expected format: "50%", "100px", etc.`),R.includes("%")){const W=parseFloat(R);(W<0||W>100)&&console.warn(`[Split] Size at index ${G} is out of range: "${R}". Percentage should be 0-100.`)}}});const D=u.reduce((R,G)=>typeof G=="string"&&G.includes("%")?R+parseFloat(G):R,0);D>100&&console.warn(`[Split] Total percentage (${D}%) exceeds 100%. Sizes will be normalized.`)}if((x.length>0||g.length>0)&&(x.forEach(($,D)=>{const R=g[D];R!==void 0&&$>R&&console.warn(`[Split] minSize (${$}) is greater than maxSize (${R}) at index ${D}`),($<0||$>100)&&console.warn(`[Split] minSize at index ${D} is out of range: ${$}. Should be 0-100.`)}),g.forEach(($,D)=>{($<0||$>100)&&console.warn(`[Split] maxSize at index ${D} is out of range: ${$}. Should be 0-100.`)})),z.length>0){const $=l.Children.toArray(o);z.length!==$.length&&console.warn(`[Split] collapsed length (${z.length}) doesn't match children count (${$.length})`)}}},[u,x,g,z,o]);const{panes:k,addPane:j,removePane:_,togglePane:q,setPaneSize:V,getPaneState:le,removePanes:ce,swapPanes:ue,collapsePane:X,expandPane:Y,resizePane:de}=Ee(o,u,z,x,g,a),[M,fe]=l.useState(null);l.useEffect(()=>(M&&M.active?(document.body.classList.add("a-split-body-dragging"),document.body.classList.add(s==="horizontal"?"a-split-body-dragging-horizontal":"a-split-body-dragging-vertical")):(document.body.classList.remove("a-split-body-dragging"),document.body.classList.remove("a-split-body-dragging-horizontal"),document.body.classList.remove("a-split-body-dragging-vertical")),()=>{document.body.classList.remove("a-split-body-dragging"),document.body.classList.remove("a-split-body-dragging-horizontal"),document.body.classList.remove("a-split-body-dragging-vertical")}),[M,s]);const Be=l.useCallback(()=>({panes:k,mode:s,dragState:M}),[k,s,M]),qe=l.useCallback(f=>{switch(f.type){case"ADD_PANE":j(f.payload);break;case"REMOVE_PANE":_(f.payload);break;case"TOGGLE_PANE":q(f.payload);break;case"SET_PANE_SIZE":V(f.payload.index,f.payload.size);break;case"RESTORE_STATE":f.payload.panes.forEach((y,w)=>{V(w,y.size),y.collapsed&&q(w)});break;case"ADJUST_PANE_SIZE":if(f.payload&&(M==null?void 0:M.paneIndex)!=null){const y=M.paneIndex,w=k[y];if(w){const $=parseFloat(w.size),D=f.payload.direction==="grow"?f.payload.amount:-f.payload.amount,R=Math.max(w.minSize||0,Math.min(w.maxSize||100,$+D));V(y,`${R}%`)}}break}},[j,_,q,V,k,M]),he=Ae(a,Be,qe,c);l.useEffect(()=>{if(b.length>0)return S.current=new Ne(he),S.current.registerPlugins(b),()=>{var f;(f=S.current)==null||f.destroy(),S.current=null}},[b,he]);const Q=Fe(m,`split-state-${a}`,s);l.useEffect(()=>{const f=Q.load();f&&f.length===k.length&&f.forEach((y,w)=>{k[w]&&y.id===k[w].id&&(V(w,y.size),y.collapsed!==k[w].collapsed&&q(w))})},[]),l.useEffect(()=>{Q.save(k)},[k,Q]);const pe=l.useRef(!0),ge=l.useRef(l.Children.count(o)),K=l.useRef(u);l.useEffect(()=>{if(!c.current||u.length===0)return;const f=l.Children.count(o),y=f!==ge.current,w=u.length!==K.current.length||u.some(($,D)=>$!==K.current[D]);(pe.current||y||w)&&(u.forEach(($,D)=>{V(D,$)}),pe.current=!1,ge.current=f,K.current=u)},[o,u]);const ee=l.useRef(z);l.useEffect(()=>{!c.current||!z.some((y,w)=>y!==ee.current[w])&&ee.current.length===z.length||(ee.current=z,z.forEach((y,w)=>{const $=k[w];$&&$.collapsed!==y&&(y?X(w):Y(w))}))},[z,k,X,Y]),l.useEffect(()=>{c.current&&k.forEach((f,y)=>{var $;const w=($=c.current)==null?void 0:$.querySelector(`[data-pane-id="${f.id}"]`);if(w){const D=x[y],R=g[y];D!==void 0&&w.setAttribute("data-min-size",String(x[y])),R!==void 0&&w.setAttribute("data-max-size",String(g[y]))}})},[x,g,k]),l.useEffect(()=>{if(!c.current)return;c.current.querySelectorAll(".a-split-handlebar").forEach((y,w)=>{const $=y,D=w+1;ne(D,C)?($.classList.add("a-split-handlebar-disabled"),$.style.cursor="default"):($.classList.remove("a-split-handlebar-disabled"),$.style.cursor=s==="horizontal"?"col-resize":"row-resize");const G=re(D,P);$.style.display=G?"":"none",se(D,v)?$.classList.add("a-split-handlebar-line"):$.classList.remove("a-split-handlebar-line")})},[C,P,v,s]);const{handleMouseDown:me}=Ie(c,s,{onDragStart:f=>{var w;fe({active:!0,paneIndex:f.paneIndex}),(w=S.current)==null||w.onDragStart(f);const y=k[f.paneIndex];y&&(r==null||r(f.paneIndex,y.id,"dragging",null))},onDragMove:f=>{var w;(((w=S.current)==null?void 0:w.onDragMove(f))??!0)&&(p==null||p(f.prevSize,f.nextSize,f.paneIndex))},onDragEnd:f=>{var w;V(f.paneIndex-1,`${f.prevSize}%`),V(f.paneIndex,`${f.nextSize}%`),fe(null),(w=S.current)==null||w.onDragEnd(f),h==null||h(f.prevSize,f.nextSize,f.paneIndex);const y=k[f.paneIndex];y&&(r==null||r(f.paneIndex,y.id,"dragged",null))}}),Oe=l.useCallback((f,y)=>{var $;const w=y==="left"?f-1:f;if(w>=0&&w<k.length){X(w,{direction:y});const D=k[w];D&&(($=S.current)==null||$.onPaneCollapse({pane:D,index:w,direction:y}),r==null||r(w,D.id,"close",y))}},[k,X,r]),Xe=l.useCallback((f,y)=>{var $;const w=y==="left"?f-1:f;if(w>=0&&w<k.length){Y(w,{direction:y});const D=k[w];D&&(($=S.current)==null||$.onPaneExpand({pane:D,index:w,direction:y}),r==null||r(w,D.id,"open",y))}},[k,Y,r]);l.useImperativeHandle(e,()=>({addPane:j,removePane:_,togglePane:q,setPaneSize:V,getPaneState:le,removePanes:ce,swapPanes:ue,collapsePane:X,expandPane:Y,resizePane:de,getSnapshot:()=>{const f=c.current,y=f?s==="horizontal"?f.offsetWidth:f.offsetHeight:0;return{panes:k.map(w=>({...w})),totalSize:y,mode:s,timestamp:Date.now()}},restore:f=>{if(f.mode!==s){console.warn(`Cannot restore snapshot with different mode. Current: ${s}, Snapshot: ${f.mode}`);return}f.panes.forEach((y,w)=>{k[w]&&(V(w,y.size),y.collapsed!==k[w].collapsed&&q(w))})}}),[j,_,q,V,le,ce,ue,X,Y,de,k,s]);const Ye=l.useMemo(()=>({display:"flex",flexDirection:s==="horizontal"?"row":"column",width:E||"100%",height:A||"100%",overflow:"hidden",...T}),[s,E,A,T]),Ue=l.useMemo(()=>{const f=["a-split-container"];return s==="vertical"&&f.push("a-split-vertical"),(N||L)&&f.push("a-split-fix"),M!=null&&M.active&&f.push("a-split-dragging"),I&&f.push(I),f.join(" ")},[s,N,L,I,M==null?void 0:M.active]),Je=()=>{const f=[];return k.forEach((y,w)=>{var D;const $=H.jsx(Z,{level:F+1,children:y.content});if(f.push(H.jsx(oe,{id:y.id,size:y.size,collapsed:y.collapsed,minSize:y.minSize,maxSize:y.maxSize,mode:s,content:$,flexGrow:y.flexGrow},y.id)),w<k.length-1){const R=w+1,G=k[w+1];if(!G)return;const J=Ce(),W=re(R,P),Se=se(R,v),ze=y.collapsed||!1,we=G.collapsed||!1,xe=ne(R,C),be=xe||ze||we;if(W&&J){const ye=(D=S.current)==null?void 0:D.renderHandle({index:R,mode:s,disabled:be,lineBar:Se,onMouseDown:O=>me(R,O)});ye?f.push(H.jsx(l.Fragment,{children:ye},`handlebar-${R}`)):f.push(H.jsx(ae,{index:R,mode:s,disabled:be,lineBar:Se,explicitlyDisabled:xe,onMouseDown:O=>me(R,O),onCollapse:O=>Oe(R,O),onExpand:O=>Xe(R,O),renderCustom:d,leftPaneCollapsed:ze,rightPaneCollapsed:we},`handlebar-${R}`))}}}),f};return H.jsx("div",{ref:c,id:a,className:Ue,style:Ye,children:Je()})});Le.displayName="Split";function vt(t={}){const{mode:e="horizontal",initialPanes:n=[],initialSizes:s=[],minSizes:u=[],maxSizes:x=[],onPaneChange:g}=t,[z,C]=l.useState(()=>n.length>0?n:s.map((r,i)=>({id:`pane-${i}`,size:r,collapsed:!1,minSize:u[i]||0,maxSize:x[i]||100,content:null}))),[P]=l.useState(!1),v=l.useRef(!1),d=l.useCallback(r=>{C(i=>{const a=typeof r=="function"?r(i):r;return!v.current&&g&&g(a),a})},[g]),b=l.useCallback(r=>{d(i=>{const a=r.position??i.length,c={id:`pane-${Date.now()}`,size:r.size,collapsed:r.collapsed||!1,minSize:r.minSize||0,maxSize:r.maxSize||100,content:r.content},S=[...i];return S.splice(a,0,c),S})},[d]),m=l.useCallback(r=>{d(i=>{if(r<0||r>=i.length)return i;const a=[...i],c=a.splice(r,1)[0];if(c&&a.length>0){const F=(parseFloat(c.size)||0)/a.length;return a.map(L=>({...L,size:`${(parseFloat(L.size)||0)+F}%`}))}return a})},[d]),E=l.useCallback(r=>{d(i=>{const a=[...r].sort((F,L)=>L-F);let c=[...i],S=0;if(a.forEach(F=>{if(F>=0&&F<c.length){const L=c.splice(F,1)[0];L&&(S+=parseFloat(L.size)||0)}}),c.length>0&&S>0){const F=S/c.length;c=c.map(L=>({...L,size:`${(parseFloat(L.size)||0)+F}%`}))}return c})},[d]),A=l.useCallback(r=>{d(i=>{if(r<0||r>=i.length)return i;const a=i[r];if(!a)return i;const c=[...i];return c[r]={...a,collapsed:!a.collapsed},c})},[d]),I=l.useCallback(r=>{d(i=>{if(r<0||r>=i.length)return i;const a=i[r];if(!a||a.collapsed)return i;const c=[...i];return c[r]={...a,collapsed:!0},c})},[d]),T=l.useCallback(r=>{d(i=>{if(r<0||r>=i.length)return i;const a=i[r];if(!a||!a.collapsed)return i;const c=[...i];return c[r]={...a,collapsed:!1},c})},[d]),N=l.useCallback((r,i,a)=>{d(c=>{if(r<0||r>=c.length)return c;const S=c[r];if(!S)return c;const F=[...c];return F[r]={...S,size:i},F})},[d]),o=l.useCallback((r,i)=>{d(a=>{if(r<0||r>=a.length||i<0||i>=a.length||r===i)return a;const c=[...a],S=c[r];return c[r]=c[i],c[i]=S,c})},[d]),p=l.useCallback(()=>({panes:z.map(r=>({...r})),totalSize:0,mode:e,timestamp:Date.now()}),[z,e]),h=l.useCallback(r=>{if(r.mode!==e){console.warn(`Cannot restore snapshot with different mode. Current: ${e}, Snapshot: ${r.mode}`);return}v.current=!0,d(i=>r.panes.map((a,c)=>{const S=i.find(F=>F.id===a.id)||i[c];return{id:a.id,size:a.size,collapsed:a.collapsed,minSize:(S==null?void 0:S.minSize)??0,maxSize:(S==null?void 0:S.maxSize)??100,content:(S==null?void 0:S.content)??null}})),v.current=!1,g&&C(i=>(g(i),i))},[e,d,g]);return l.useMemo(()=>({panes:z,mode:e,isDragging:P,addPane:b,removePane:m,removePanes:E,togglePane:A,collapsePane:I,expandPane:T,setPaneSize:N,swapPanes:o,setPanes:d,getSnapshot:p,restore:h}),[z,e,P,b,m,E,A,I,T,N,o,d,p,h])}function Ct(t){return t}function Et(t={}){const{storage:e="localStorage",key:n,debounceDelay:s=300}=t;let u=null;const x=v=>n||`a-multilayout-splitter:${v}`,g=()=>typeof window>"u"?null:e==="localStorage"?window.localStorage:window.sessionStorage,z=(v,d)=>{const b=g();if(b)try{const m=x(v),E=JSON.stringify({panes:d.panes.map(A=>({id:A.id,size:A.size,collapsed:A.collapsed})),mode:d.mode,timestamp:Date.now()});b.setItem(m,E)}catch(m){console.error("Failed to save split state:",m)}},C=v=>{const d=g();if(!d)return null;try{const b=x(v),m=d.getItem(b);return m?JSON.parse(m):null}catch(b){return console.error("Failed to load split state:",b),null}},P=(v,d)=>{u&&clearTimeout(u),u=setTimeout(()=>{z(v,d),u=null},s)};return{name:"persistence",version:"1.0.0",onInit(v){const d=C(v.splitId),b=d==null?void 0:d.panes;b&&b.length>0?setTimeout(()=>{v.getState().panes.length===b.length&&v.dispatch({type:"RESTORE_STATE",payload:{panes:b}})},0):setTimeout(()=>{const m=v.getState();z(v.splitId,m)},0)},onDragEnd(v,d){setTimeout(()=>{const b=d.getState();P(d.splitId,b)},0)},onPaneAdd(v,d){setTimeout(()=>{const b=d.getState();P(d.splitId,b)},0)},onPaneRemove(v,d){setTimeout(()=>{const b=d.getState();P(d.splitId,b)},0)},onPaneCollapse(v,d){setTimeout(()=>{const b=d.getState();P(d.splitId,b)},0)},onPaneExpand(v,d){setTimeout(()=>{const b=d.getState();P(d.splitId,b)},0)},onDestroy(){u&&(clearTimeout(u),u=null)}}}function $t(t,e="localStorage"){const n=e==="localStorage"?window.localStorage:window.sessionStorage;try{const s=`a-multilayout-splitter:${t}`;n.removeItem(s)}catch(s){console.error("Failed to clear persisted state:",s)}}function kt(t={}){const{enableArrowKeys:e=!0,enableNumberKeys:n=!0,stepSize:s=5,enableTabNavigation:u=!0}=t;let x=0,g=null;const z=(C,P)=>{if(!C)return;const d=C.querySelectorAll(".a-split-pane")[P];d&&(d.focus(),d.setAttribute("tabindex","0"),x=P)};return{name:"keyboard",version:"1.0.0",onInit(C){const P=C.getElement();if(!P)return;P.setAttribute("tabindex","0"),P.querySelectorAll(".a-split-pane").forEach((d,b)=>{d.setAttribute("tabindex",b===0?"0":"-1")}),g=d=>{const b=C.getState(),m=b.panes;if(e&&(d.key==="ArrowLeft"||d.key==="ArrowRight"||d.key==="ArrowUp"||d.key==="ArrowDown")){d.preventDefault();const E=b.mode==="horizontal",A=E&&d.key==="ArrowRight"||!E&&d.key==="ArrowDown",I=x,T=m[I],N=I<m.length-1?I+1:I-1,o=m[N];if(!T||!o)return;const p=parseFloat(T.size),h=parseFloat(o.size),r=A?s:-s;let i=p+r,a=h-r;const c=T.minSize||0,S=T.maxSize||100,F=o.minSize||0,L=o.maxSize||100;i=Math.max(c,Math.min(S,i)),a=Math.max(F,Math.min(L,a));const k=p+h;i+a!==k&&(i===c||i===S?a=k-i:i=k-a),C.dispatch({type:"SET_PANE_SIZE",payload:{index:I,size:`${i}%`}}),C.dispatch({type:"SET_PANE_SIZE",payload:{index:N,size:`${a}%`}})}if(n){const E=parseInt(d.key,10);if(!isNaN(E)&&E>=1&&E<=9){const A=E-1;A<m.length&&z(P,A)}}if(u&&d.key==="Tab"){d.preventDefault();let E=d.shiftKey?x-1:x+1;E<0?E=m.length-1:E>=m.length&&(E=0),z(P,E)}},P.addEventListener("keydown",g)},onDestroy(C){const P=C.getElement();P&&g&&(P.removeEventListener("keydown",g),g=null)}}}function It(t,e){return{name:"custom-handle",version:"1.0.0",renderHandle(n){return l.createElement(t,{...n,...e})}}}function Ft(t){return{name:"custom-handle-render",version:"1.0.0",renderHandle(e){return t(e)}}}const Te=l.createContext(null),Me=l.createContext(null),je=l.createContext(null);function At({id:t,mode:e="horizontal",enablePersistence:n=!1,storageKey:s=`split-state-${t}`,children:u,_panes:x=[],_addPane:g,_removePane:z,_togglePane:C,_setPaneSize:P,_getPaneState:v}){const d=l.useRef({isDragging:!1,activeHandlebar:null}),b=l.useMemo(()=>({id:t,mode:e,enablePersistence:n,storageKey:s}),[t,e,n,s]),m=l.useMemo(()=>({panes:x,isDragging:d.current.isDragging,activeHandlebar:d.current.activeHandlebar}),[x,d.current.isDragging,d.current.activeHandlebar]),E=l.useMemo(()=>({addPane:g||(()=>console.warn("addPane not available")),removePane:z||(()=>console.warn("removePane not available")),togglePane:C||(()=>console.warn("togglePane not available")),setPaneSize:P||(()=>console.warn("setPaneSize not available")),getPaneState:v||(()=>[]),setDragging:(A,I)=>{d.current.isDragging=A,d.current.activeHandlebar=I??null}}),[g,z,C,P,v]);return H.jsx(Te.Provider,{value:b,children:H.jsx(Me.Provider,{value:m,children:H.jsx(je.Provider,{value:E,children:u})})})}function Ve(){const t=l.useContext(Te);if(!t)throw new Error("useSplitConfig must be used within SplitProvider");return t}function U(){const t=l.useContext(Me);if(!t)throw new Error("useSplitState must be used within SplitProvider");return t}function Ge(){return l.useContext(je)}function Dt(){const t=Ge();if(!t)throw new Error("useSplit must be used within SplitProvider");return{config:Ve(),state:U(),actions:t}}function _e(t){const{panes:e}=U();return e[t]}function Ht(){const{panes:t}=U();return t.length}function Rt(){const{isDragging:t}=U();return t}function Nt(t){const e=_e(t);return(e==null?void 0:e.collapsed)??!1}function Lt(){const{panes:t}=U();return l.useMemo(()=>t.filter(e=>!e.collapsed),[t])}exports.DragHandle=ae;exports.NestingProvider=Z;exports.PaneComponent=oe;exports.PluginManager=Ne;exports.Split=Le;exports.SplitProvider=At;exports.animatePaneSize=Pe;exports.applyCollapseState=Qe;exports.batchUpdatePanes=at;exports.calculateFlexBasis=He;exports.calculateFlexValues=Re;exports.calculateHandlebarPosition=wt;exports.calculateTotalSize=St;exports.canResize=bt;exports.clampSize=mt;exports.clearPersistedState=$t;exports.constrainSize=rt;exports.createPane=st;exports.createPlugin=Ct;exports.customHandlePlugin=It;exports.customHandleRenderPlugin=Ft;exports.debounce=ke;exports.findPaneIndex=et;exports.getAxisProperty=yt;exports.getCoordinateProperty=Pt;exports.getPaneElement=nt;exports.getVisiblePanes=tt;exports.haveSameUnit=gt;exports.isHandlebarDisabled=ne;exports.isHandlebarVisible=re;exports.isLineBarStyle=se;exports.isPaneVisible=ve;exports.keyboardPlugin=kt;exports.normalizePaneSizes=xt;exports.normalizeSize=pt;exports.parseSize=B;exports.percentageToPixel=ft;exports.persistencePlugin=Et;exports.pixelToPercentage=ht;exports.restorePaneState=ot;exports.serializePaneState=lt;exports.shouldShowHandlebar=Ce;exports.throttle=$e;exports.togglePaneCollapse=Ke;exports.updatePaneSize=it;exports.useDragHandler=Ie;exports.useIsCollapsed=Nt;exports.useIsDragging=Rt;exports.useNestingLevel=ie;exports.usePane=_e;exports.usePaneCount=Ht;exports.usePaneManager=Ee;exports.usePersistence=Fe;exports.usePluginContext=Ae;exports.useSplit=Dt;exports.useSplitActions=Ge;exports.useSplitConfig=Ve;exports.useSplitController=vt;exports.useSplitState=U;exports.useVisiblePanes=Lt;exports.validatePaneSizes=zt;exports.withNesting=dt;
2
2
  //# sourceMappingURL=index.cjs.map