react-zeugma 4.0.0 → 4.1.0

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.d.cts CHANGED
@@ -133,9 +133,79 @@ interface ZeugmaProps extends ZeugmaController {
133
133
  /** Child nodes nested inside the Zeugma context, usually containing a <PaneTree> or similar layout viewer. */
134
134
  children: ReactNode;
135
135
  }
136
+ /**
137
+ * State context — holds reactive values that change during runtime.
138
+ * All consumers of this context will re-render when any of these values change.
139
+ */
140
+ interface ZeugmaStateValue {
141
+ /** The current active layout tree structure, or null if empty. */
142
+ layout: TreeNode | null;
143
+ /** Callback to update the layout tree. */
144
+ onLayoutChange: (newLayout: TreeNode | null, localOnly?: boolean) => void;
145
+ /** Renders the inner content of a pane given its unique ID. */
146
+ renderPane: (paneId: string) => ReactNode;
147
+ /** The ID of the pane currently being dragged, or null. */
148
+ activeId: string | null;
149
+ /** The ID of the pane currently targeted for dismiss/drag-out, or null. */
150
+ dismissIntentId: string | null;
151
+ /** Ref setter to measure and track the dashboard root container element. */
152
+ setContainerRef: (element: HTMLElement | null) => void;
153
+ /** The ID of the pane currently zoomed to fullscreen, or null. */
154
+ fullscreenPaneId: string | null;
155
+ /** Normalized or overridden CSS classes for custom layout styling. */
156
+ classNames: ZeugmaClassNames;
157
+ /** Callback triggered when a pane is closed/removed from the dashboard. */
158
+ onRemove?: (paneId: string) => void;
159
+ /** Callback triggered to toggle fullscreen status for a pane. */
160
+ onFullscreenChange?: (paneId: string | null) => void;
161
+ /** Threshold in pixels to snap layout resizers to adjacent edges. */
162
+ snapThreshold?: number;
163
+ /** Callback triggered when a split pane starts being resized. */
164
+ onResizeStart?: (currentNode: SplitNode) => void;
165
+ /** Callback triggered continuously during a split pane resize. */
166
+ onResize?: (currentNode: SplitNode, percentage: number) => void;
167
+ /** Callback triggered when a split pane resize action is completed. */
168
+ onResizeEnd?: (currentNode: SplitNode, percentage: number) => void;
169
+ /** Minimum split percentage allowed when resizing. */
170
+ minSplitPercentage?: number;
171
+ /** Maximum split percentage allowed when resizing. */
172
+ maxSplitPercentage?: number;
173
+ /** Whether the layout is globally locked. */
174
+ locked: boolean;
175
+ }
176
+ /**
177
+ * Actions context — holds stable dispatch functions with permanent identity.
178
+ * Consumers of only this context will never re-render from layout/drag state changes.
179
+ */
180
+ interface ZeugmaActionsValue {
181
+ /** Removes the specified pane from the layout tree and collapses its parent split. */
182
+ removePane: (paneId: string) => void;
183
+ /** Appends/inserts a pane at the bottom-rightmost leaf of the layout tree. */
184
+ addPane: (paneId: string) => void;
185
+ /** Splits a target pane with a new pane in the specified direction and side. */
186
+ splitPane: (targetId: string, direction: SplitDirection, splitType: 'left' | 'right' | 'top' | 'bottom', paneToAdd: string) => void;
187
+ /** Updates the split percentage of a specific split branch node. */
188
+ updateSplitPercentage: (currentNode: SplitNode, percentage: number) => void;
189
+ /** Stable callback to update metadata for a specific tab. */
190
+ updateTabMetadata: (tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined) => void;
191
+ /** Stable callback to update the locked status of a specific pane in the layout tree. */
192
+ updatePaneLock: (paneId: string, locked: boolean) => void;
193
+ /** Stable callback to activate a tab within a pane. */
194
+ selectTab: (paneId: string, tabId: string) => void;
195
+ /** Stable callback to merge a dragged tab/pane into another pane's tab list. */
196
+ mergeTab: (draggedTabId: string, targetPaneId: string) => void;
197
+ /** Stable callback to move/reorder a tab to another pane next to a target tab. */
198
+ moveTab: (draggedTabId: string, targetTabId: string, position?: 'before' | 'after') => void;
199
+ /** Stable callback to remove/close a specific tab from the layout. */
200
+ removeTab: (tabId: string) => void;
201
+ }
202
+ interface ZeugmaContextValue extends ZeugmaStateValue, ZeugmaActionsValue {
203
+ }
136
204
 
137
205
  declare function useZeugma(options: UseZeugmaOptions): ZeugmaController;
138
206
 
207
+ declare const useZeugmaContext: () => ZeugmaContextValue;
208
+
139
209
  declare const Zeugma: React.FC<ZeugmaProps>;
140
210
 
141
211
  interface UseResizerProps {
@@ -363,4 +433,4 @@ interface DragSessionConfig {
363
433
  }
364
434
  declare function createDragSession({ cursor, resizerEl, onMove, onEnd }: DragSessionConfig): void;
365
435
 
366
- export { type ComputedPane, type ComputedSplitter, DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD, DragHandle, type DragHandleProps, type DragSessionConfig, Pane, type PaneNode, type PaneProps, type PaneRenderProps, PaneTree, ResizableContainer, type ResizableContainerProps, type SplitDirection, type SplitNode, Tab, type TabProps, type TabRenderProps, type TreeNode, type UseZeugmaOptions, Zeugma, type ZeugmaClassNames, type ZeugmaController, type ZeugmaProps, addPane, computeLayout, createDragSession, findPane, generateUniqueId, mergeTab, moveTab, removePane, removeTab, selectTab, splitPane, updatePaneLock, updateSplitPercentage, updateTabMetadata, useResizer, useZeugma };
436
+ export { type ComputedPane, type ComputedSplitter, DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD, DragHandle, type DragHandleProps, type DragSessionConfig, Pane, type PaneNode, type PaneProps, type PaneRenderProps, PaneTree, ResizableContainer, type ResizableContainerProps, type SplitDirection, type SplitNode, Tab, type TabProps, type TabRenderProps, type TreeNode, type UseZeugmaOptions, Zeugma, type ZeugmaClassNames, type ZeugmaContextValue, type ZeugmaController, type ZeugmaProps, addPane, computeLayout, createDragSession, findPane, generateUniqueId, mergeTab, moveTab, removePane, removeTab, selectTab, splitPane, updatePaneLock, updateSplitPercentage, updateTabMetadata, useResizer, useZeugma, useZeugmaContext };
package/dist/index.d.ts CHANGED
@@ -133,9 +133,79 @@ interface ZeugmaProps extends ZeugmaController {
133
133
  /** Child nodes nested inside the Zeugma context, usually containing a <PaneTree> or similar layout viewer. */
134
134
  children: ReactNode;
135
135
  }
136
+ /**
137
+ * State context — holds reactive values that change during runtime.
138
+ * All consumers of this context will re-render when any of these values change.
139
+ */
140
+ interface ZeugmaStateValue {
141
+ /** The current active layout tree structure, or null if empty. */
142
+ layout: TreeNode | null;
143
+ /** Callback to update the layout tree. */
144
+ onLayoutChange: (newLayout: TreeNode | null, localOnly?: boolean) => void;
145
+ /** Renders the inner content of a pane given its unique ID. */
146
+ renderPane: (paneId: string) => ReactNode;
147
+ /** The ID of the pane currently being dragged, or null. */
148
+ activeId: string | null;
149
+ /** The ID of the pane currently targeted for dismiss/drag-out, or null. */
150
+ dismissIntentId: string | null;
151
+ /** Ref setter to measure and track the dashboard root container element. */
152
+ setContainerRef: (element: HTMLElement | null) => void;
153
+ /** The ID of the pane currently zoomed to fullscreen, or null. */
154
+ fullscreenPaneId: string | null;
155
+ /** Normalized or overridden CSS classes for custom layout styling. */
156
+ classNames: ZeugmaClassNames;
157
+ /** Callback triggered when a pane is closed/removed from the dashboard. */
158
+ onRemove?: (paneId: string) => void;
159
+ /** Callback triggered to toggle fullscreen status for a pane. */
160
+ onFullscreenChange?: (paneId: string | null) => void;
161
+ /** Threshold in pixels to snap layout resizers to adjacent edges. */
162
+ snapThreshold?: number;
163
+ /** Callback triggered when a split pane starts being resized. */
164
+ onResizeStart?: (currentNode: SplitNode) => void;
165
+ /** Callback triggered continuously during a split pane resize. */
166
+ onResize?: (currentNode: SplitNode, percentage: number) => void;
167
+ /** Callback triggered when a split pane resize action is completed. */
168
+ onResizeEnd?: (currentNode: SplitNode, percentage: number) => void;
169
+ /** Minimum split percentage allowed when resizing. */
170
+ minSplitPercentage?: number;
171
+ /** Maximum split percentage allowed when resizing. */
172
+ maxSplitPercentage?: number;
173
+ /** Whether the layout is globally locked. */
174
+ locked: boolean;
175
+ }
176
+ /**
177
+ * Actions context — holds stable dispatch functions with permanent identity.
178
+ * Consumers of only this context will never re-render from layout/drag state changes.
179
+ */
180
+ interface ZeugmaActionsValue {
181
+ /** Removes the specified pane from the layout tree and collapses its parent split. */
182
+ removePane: (paneId: string) => void;
183
+ /** Appends/inserts a pane at the bottom-rightmost leaf of the layout tree. */
184
+ addPane: (paneId: string) => void;
185
+ /** Splits a target pane with a new pane in the specified direction and side. */
186
+ splitPane: (targetId: string, direction: SplitDirection, splitType: 'left' | 'right' | 'top' | 'bottom', paneToAdd: string) => void;
187
+ /** Updates the split percentage of a specific split branch node. */
188
+ updateSplitPercentage: (currentNode: SplitNode, percentage: number) => void;
189
+ /** Stable callback to update metadata for a specific tab. */
190
+ updateTabMetadata: (tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined) => void;
191
+ /** Stable callback to update the locked status of a specific pane in the layout tree. */
192
+ updatePaneLock: (paneId: string, locked: boolean) => void;
193
+ /** Stable callback to activate a tab within a pane. */
194
+ selectTab: (paneId: string, tabId: string) => void;
195
+ /** Stable callback to merge a dragged tab/pane into another pane's tab list. */
196
+ mergeTab: (draggedTabId: string, targetPaneId: string) => void;
197
+ /** Stable callback to move/reorder a tab to another pane next to a target tab. */
198
+ moveTab: (draggedTabId: string, targetTabId: string, position?: 'before' | 'after') => void;
199
+ /** Stable callback to remove/close a specific tab from the layout. */
200
+ removeTab: (tabId: string) => void;
201
+ }
202
+ interface ZeugmaContextValue extends ZeugmaStateValue, ZeugmaActionsValue {
203
+ }
136
204
 
137
205
  declare function useZeugma(options: UseZeugmaOptions): ZeugmaController;
138
206
 
207
+ declare const useZeugmaContext: () => ZeugmaContextValue;
208
+
139
209
  declare const Zeugma: React.FC<ZeugmaProps>;
140
210
 
141
211
  interface UseResizerProps {
@@ -363,4 +433,4 @@ interface DragSessionConfig {
363
433
  }
364
434
  declare function createDragSession({ cursor, resizerEl, onMove, onEnd }: DragSessionConfig): void;
365
435
 
366
- export { type ComputedPane, type ComputedSplitter, DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD, DragHandle, type DragHandleProps, type DragSessionConfig, Pane, type PaneNode, type PaneProps, type PaneRenderProps, PaneTree, ResizableContainer, type ResizableContainerProps, type SplitDirection, type SplitNode, Tab, type TabProps, type TabRenderProps, type TreeNode, type UseZeugmaOptions, Zeugma, type ZeugmaClassNames, type ZeugmaController, type ZeugmaProps, addPane, computeLayout, createDragSession, findPane, generateUniqueId, mergeTab, moveTab, removePane, removeTab, selectTab, splitPane, updatePaneLock, updateSplitPercentage, updateTabMetadata, useResizer, useZeugma };
436
+ export { type ComputedPane, type ComputedSplitter, DEFAULT_DRAG_ACTIVATION_DISTANCE, DEFAULT_RESIZER_SIZE, DEFAULT_SNAP_THRESHOLD, DragHandle, type DragHandleProps, type DragSessionConfig, Pane, type PaneNode, type PaneProps, type PaneRenderProps, PaneTree, ResizableContainer, type ResizableContainerProps, type SplitDirection, type SplitNode, Tab, type TabProps, type TabRenderProps, type TreeNode, type UseZeugmaOptions, Zeugma, type ZeugmaClassNames, type ZeugmaContextValue, type ZeugmaController, type ZeugmaProps, addPane, computeLayout, createDragSession, findPane, generateUniqueId, mergeTab, moveTab, removePane, removeTab, selectTab, splitPane, updatePaneLock, updateSplitPercentage, updateTabMetadata, useResizer, useZeugma, useZeugmaContext };
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import en,{createContext,useState,useRef,useCallback,useEffect,useMemo,useContext}from'react';import {createPortal}from'react-dom';import {useSensors,useSensor,pointerWithin,closestCenter,DndContext,useDraggable,useDroppable,PointerSensor,TouchSensor}from'@dnd-kit/core';import {jsx,Fragment,jsxs}from'react/jsx-runtime';var ze=createContext(void 0),Ie=createContext(void 0);var oe=()=>{let e=useContext(ze);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},nt=()=>{let e=useContext(Ie);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e};function rt(e){let t=useRef(null);return useEffect(()=>{if(!e){t.current=null;return}let r=n=>{t.current={x:n.clientX,y:n.clientY};},o=n=>{let s=n.touches[0]||n.changedTouches[0];s&&(t.current={x:s.clientX,y:s.clientY});};return window.addEventListener("pointermove",r,{passive:true}),window.addEventListener("touchmove",o,{passive:true}),()=>{window.removeEventListener("pointermove",r),window.removeEventListener("touchmove",o);}},[e]),t}function ot(e){useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function st(){let[e,t]=useState({}),r=useCallback((o,n)=>{t(s=>s[o]===n?s:{...s,[o]:n});},[]);return {portalTargets:e,registerPortalTarget:r}}var $e=createContext(void 0);var Ht=8,Zt=8,An=4;function ie(){return "pane-"+Math.random().toString(36).substring(2,11)}function be(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let r=be(e.first,t),o=be(e.second,t);return r===null?o:o===null?r:{...e,first:r,second:o}}function de(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let n=e.tabs.filter(a=>a!==t);if(n.length===0)return null;let s=e.activeTabId;e.activeTabId===t&&(s=n[0]);let i={...e.tabsMetadata};return delete i[t],{...e,tabs:n,activeTabId:s,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}let r=de(e.first,t),o=de(e.second,t);return r===null?o:o===null?r:{...e,first:r,second:o}}function ye(e,t,r,o,n){if(e===null)return typeof n=="string"?{type:"pane",id:ie(),tabs:[n],activeTabId:n}:n;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){let s=typeof n=="string"?{type:"pane",id:ie(),tabs:[n],activeTabId:n}:n,i=o==="left"||o==="top";return {type:"split",direction:r,first:i?s:e,second:i?e:s,splitPercentage:50}}return e}return {...e,first:ye(e.first,t,r,o,n)||e.first,second:ye(e.second,t,r,o,n)||e.second}}function it(e,t){if(e===null)return {type:"pane",id:ie(),tabs:[t],activeTabId:t};function r(o,n){return o.type==="pane"?{type:"split",direction:n==="row"?"column":"row",splitPercentage:50,first:o,second:{type:"pane",id:ie(),tabs:[t],activeTabId:t}}:{...o,second:r(o.second,o.direction)}}return r(e,null)}function ve(e,t,r){return e===null?null:e===t?{...e,splitPercentage:r}:e.type==="split"?{...e,first:ve(e.first,t,r)||e.first,second:ve(e.second,t,r)||e.second}:e}function q(e,t){return e===null?null:e.type==="pane"?e.id===t||e.tabs.includes(t)?e:null:q(e.first,t)??q(e.second,t)}function ke(e,t,r){if(e===null)return null;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){let o=e.tabsMetadata||{},n=o[t],s=r(n),i={...o};return s===void 0?delete i[t]:i[t]=s,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return {...e,first:ke(e.first,t,r)??e.first,second:ke(e.second,t,r)??e.second}}function He(e,t,r){if(e===null)return null;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){if(r===false){let{locked:o,...n}=e;return n}return {...e,locked:r}}return e}return {...e,first:He(e.first,t,r)??e.first,second:He(e.second,t,r)??e.second}}function Ze(e,t,r){return e===null?null:e.type==="pane"?e.id===t||e.tabs.includes(t)?{...e,activeTabId:r}:e:{...e,first:Ze(e.first,t,r)??e.first,second:Ze(e.second,t,r)??e.second}}function at(e,t,r){if(e===null)return null;let n=q(e,t)?.tabsMetadata?.[t],s=de(e,t);if(s===null)return {type:"pane",id:ie(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0};function i(a){if(a.type==="pane"){if(a.id===r||a.tabs.includes(r)){let l=[...a.tabs];l.includes(t)||l.push(t);let y={...a.tabsMetadata};return n&&(y[t]=n),{...a,tabs:l,activeTabId:t,tabsMetadata:Object.keys(y).length>0?y:void 0}}return a}return {...a,first:i(a.first),second:i(a.second)}}return i(s)}function lt(e,t,r,o="before"){if(e===null)return null;let s=q(e,t)?.tabsMetadata?.[t],i=de(e,t);if(i===null)return {type:"pane",id:ie(),tabs:[t],activeTabId:t,tabsMetadata:s?{[t]:s}:void 0};function a(l){if(l.type==="pane"){if(l.id===r||l.tabs.includes(r)){let D=[...l.tabs].filter(T=>T!==t),c=D.indexOf(r);c<0&&(c=0),o==="after"&&(c+=1),D.splice(c,0,t);let x={...l.tabsMetadata};return s&&(x[t]=s),{...l,tabs:D,activeTabId:t,tabsMetadata:Object.keys(x).length>0?x:void 0}}return l}return {...l,first:a(l.first),second:a(l.second)}}return a(i)}function se(e,t=0,r=0,o=100,n=100,s="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:r,width:o,height:n,node:e}],splitters:[]};let{direction:i,splitPercentage:a,first:l,second:y}=e,c={id:`splitter-${s}-${i}`,currentNode:e,direction:i,left:i==="row"?t+o*(a/100):t,top:i==="column"?r+n*(a/100):r,width:i==="row"?0:o,height:i==="column"?0:n,parentLeft:t,parentTop:r,parentWidth:o,parentHeight:n},x={panes:[],splitters:[]},T={panes:[],splitters:[]};if(i==="row"){let v=o*(a/100);x=se(l,t,r,v,n,`${s}-L`),T=se(y,t+v,r,o-v,n,`${s}-R`);}else {let v=n*(a/100);x=se(l,t,r,o,v,`${s}-T`),T=se(y,t,r+v,o,n-v,`${s}-B`);}return {panes:[...x.panes,...T.panes],splitters:[c,...x.splitters,...T.splitters]}}function At(e){let{initialLayout:t,onChange:r,fullscreenPaneId:o,onFullscreenChange:n,locked:s=false,dragActivationDistance:i=8,snapThreshold:a=8,minSplitPercentage:l=5,maxSplitPercentage:y=95,enableDragToDismiss:D=false,dismissThreshold:c=60,onRemove:x,onDragStart:T,onDragEnd:v,onResizeStart:R,onResize:E,onResizeEnd:L,onDismissIntentChange:p}=e,[b,f]=useState(t),[z,A]=useState(o||null),[I,V]=useState(s),[w,K]=useState(null),[h,F]=useState(null),[Y,O]=useState(null),m=useRef(null),$=useCallback(u=>{m.current=u;},[]),_=useCallback(u=>{A(u),n?.(u);},[n]);useEffect(()=>{V(s);},[s]),useEffect(()=>{o!==void 0&&A(o);},[o]);let k=useRef(true);useEffect(()=>{if(k.current){k.current=false;return}r?.(b);},[b,r]);let N=useCallback(u=>{f(S=>be(S,u));},[]),d=useCallback(u=>{f(S=>it(S,u));},[]),B=useCallback((u,S,P,te)=>{f(Re=>{let _e=q(Re,te)??{type:"pane",id:te,tabs:[te],activeTabId:te},Ye=be(Re,te);return ye(Ye,u,S,P,_e)});},[]),ae=useCallback((u,S)=>{f(P=>ve(P,u,S));},[]),W=useCallback((u,S)=>{f(P=>ke(P,u,S));},[]),ee=useCallback((u,S)=>{f(P=>He(P,u,S));},[]),le=useCallback((u,S)=>{f(P=>Ze(P,u,S));},[]),fe=useCallback((u,S)=>{f(P=>at(P,u,S));},[]),me=useCallback((u,S,P)=>{f(te=>lt(te,u,S,P));},[]),j=useCallback(u=>{f(S=>de(S,u));},[]);return {layout:b,setLayout:f,fullscreenPaneId:z,setFullscreenPaneId:_,locked:I,setLocked:V,activeId:w,setActiveId:K,activeType:h,setActiveType:F,dismissIntentId:Y,setDismissIntentId:O,containerRef:m,setContainerRef:$,dragActivationDistance:i,snapThreshold:a,minSplitPercentage:l,maxSplitPercentage:y,enableDragToDismiss:D,dismissThreshold:c,onRemove:x,onDragStart:T,onDragEnd:v,onResizeStart:R,onResize:E,onResizeEnd:L,onDismissIntentChange:p,removePane:N,addPane:d,splitPane:B,updateSplitPercentage:ae,updateTabMetadata:W,updatePaneLock:ee,selectTab:le,mergeTab:fe,moveTab:me,removeTab:j}}var ut=({activeId:e,render:t,className:r})=>{let o=useRef(null);return useEffect(()=>{let n=s=>{o.current&&(o.current.style.transform=`translate(${s.clientX+12}px, ${s.clientY+12}px)`);};return document.addEventListener("pointermove",n),()=>document.removeEventListener("pointermove",n)},[]),jsx("div",{ref:o,className:r,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var Ae=class extends PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Fe=class extends TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};function qe(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return {x:e.clientX,y:e.clientY};if(typeof TouchEvent<"u"&&e instanceof TouchEvent){let t=e.touches[0]||e.changedTouches[0];if(t)return {x:t.clientX,y:t.clientY}}return null}var Kt=e=>{let{renderPane:t,renderWidget:r,renderDragOverlay:o,classNames:n={},children:s,layout:i,setLayout:a,fullscreenPaneId:l,setFullscreenPaneId:y,locked:D,activeId:c,setActiveId:x,activeType:T,setActiveType:v,dismissIntentId:R,setDismissIntentId:E,containerRef:L,setContainerRef:p,dragActivationDistance:b,snapThreshold:f,minSplitPercentage:z,maxSplitPercentage:A,enableDragToDismiss:I,dismissThreshold:V,onRemove:w,onDragStart:K,onDragEnd:h,onResizeStart:F,onResize:Y,onResizeEnd:O,onDismissIntentChange:m,removePane:$,addPane:_,splitPane:k,updateSplitPercentage:N,updateTabMetadata:d,updatePaneLock:B,selectTab:ae,mergeTab:W,moveTab:ee,removeTab:le}=e,{portalTargets:fe,registerPortalTarget:me}=st(),j=useRef(null),u=rt(c),[S,P]=useState(false);ot(S);let te=useCallback(g=>t(g),[t]),Re=useMemo(()=>n,[n.pane,n.paneLocked,n.dropPreview,n.dragOverlay,n.resizer,n.dismissPreview,n.dashboardLocked,n.lockedPreview]),_e=useSensors(useSensor(Ae,{activationConstraint:{distance:b}}),useSensor(Fe,{activationConstraint:{delay:250,tolerance:5}})),Ye=useCallback(g=>{let H=pointerWithin(g);if(H.length>0)return H;if(g.active.id.toString().startsWith("tab-header-")){let ne=g.droppableContainers.filter(J=>J.id.toString().startsWith("tab-drop-"));return closestCenter({...g,droppableContainers:ne})}return []},[]),Rt=g=>{let H=g.active.id.toString(),U=H.startsWith("tab-header-"),ne=U?H.substring(11):H;x(ne),v(U?"tab":"pane");let J=g.activatorEvent;u.current=qe(J),I&&L.current?j.current=L.current.getBoundingClientRect():j.current=null,K&&K(ne);},St=g=>{let{over:H}=g,ne=(H?.id.toString()||"").startsWith("drop-locked-");if(P(ne),!I)return;let J=g.active.id.toString(),Se=J.startsWith("tab-header-")?J.substring(11):J,M=j.current;if(!M){R!==null&&(E(null),m?.(null));return}let we=g.activatorEvent,re=null,X=null;if(u.current)re=u.current.x,X=u.current.y;else {let Z=qe(we);Z&&(re=Z.x+g.delta.x,X=Z.y+g.delta.y);}let ce=0;if(re!==null&&X!==null){let Z=0,Q=0;re<M.left?Z=M.left-re:re>M.right&&(Z=re-M.right),X<M.top?Q=M.top-X:X>M.bottom&&(Q=X-M.bottom),ce=Math.sqrt(Z*Z+Q*Q);}else {let Z=g.active.rect.current.translated;if(Z){let Q=Z.left+Z.width/2,ge=Z.top+Z.height/2,ue=0,Pe=0;Q<M.left?ue=M.left-Q:Q>M.right&&(ue=Q-M.right),ge<M.top?Pe=M.top-ge:ge>M.bottom&&(Pe=ge-M.bottom),ce=Math.sqrt(ue*ue+Pe*Pe);}}ce>V?R!==Se&&(E(Se),m?.(Se)):R!==null&&(E(null),m?.(null));},Dt=g=>{x(null),v(null),P(false);let{active:H,over:U}=g,ne=H.id.toString(),J=ne.startsWith("tab-header-"),C=J?ne.substring(11):ne,Se=I&&R===C;if(E(null),m?.(null),j.current=null,Se){w?w(C):le(C),h&&h(C,null,null);return}if(!U){h&&h(C,null,null);return}let M=U.id.toString();if(M.startsWith("drop-locked-")){h&&h(C,null,null);return}let we=M.match(/^tab-drop-(.+)$/);if(we){let[,Ne]=we;if(C!==Ne){let Ee="before",Je=U.rect,Lt=g.activatorEvent,Me=null;if(u.current)Me=u.current.x;else {let Le=qe(Lt);Le&&(Me=Le.x+g.delta.x);}if(Me!==null){let Le=Je.left+Je.width/2;Me>Le&&(Ee="after");}ee(C,Ne,Ee);}h&&h(C,Ne,{type:"swap",position:"center"});return}let re=M.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!re){h&&h(C,null,null);return}let[,X,ce]=re,De=q(i,C),Z=De&&De.id===ce,Q=De&&De.tabs.length===1;if(C===ce||Z&&Q){h&&h(C,null,null);return}let ge=X==="left"||X==="right"?"row":"column",ue;if(J){let Ee=q(i,C)?.tabsMetadata?.[C];ue={type:"pane",id:ie(),tabs:[C],activeTabId:C,tabsMetadata:Ee?{[C]:Ee}:void 0};}else ue=q(i,C)??{type:"pane",id:ie(),tabs:[C],activeTabId:C};let Pe=J?de(i,C):be(i,C),Mt=ye(Pe,ce,ge,X,ue);a(Mt),h&&h(C,ce,{type:"split",direction:ge,position:X});},je=useCallback((g,H)=>{O&&O(g,H);},[O]),Et=useMemo(()=>({layout:i,onLayoutChange:g=>a(g),renderPane:te,activeId:c,dismissIntentId:R,setContainerRef:p,fullscreenPaneId:l,classNames:Re,onRemove:w,onFullscreenChange:y,snapThreshold:f,onResizeStart:F,onResize:Y,onResizeEnd:je,minSplitPercentage:z,maxSplitPercentage:A,locked:D}),[i,c,R,p,l,Re,w,y,f,F,Y,z,A,a,te,je,D]),Ct=useMemo(()=>({removePane:$,addPane:_,splitPane:k,updateSplitPercentage:N,updateTabMetadata:d,updatePaneLock:B,selectTab:ae,mergeTab:W,moveTab:ee,removeTab:le}),[$,_,k,N,d,B,ae,W,ee,le]),wt=useMemo(()=>{let g=[];function H(U){U&&(U.type==="pane"?g.push(...U.tabs):(H(U.first),H(U.second)));}return H(i),g},[i]),Nt=useMemo(()=>({registerPortalTarget:me}),[me]);return jsx(Ie.Provider,{value:Ct,children:jsx(ze.Provider,{value:Et,children:jsxs($e.Provider,{value:Nt,children:[jsx(DndContext,{id:"zeugma-dnd-context",sensors:_e,collisionDetection:Ye,onDragStart:Rt,onDragMove:St,onDragEnd:Dt,children:s}),c&&T&&o&&jsx(ut,{activeId:c,render:g=>o(g,T),className:`${n.dragOverlay||""} ${c===R?n.dismissPreview||"zeugma-dismiss-preview":""}`.trim()}),jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:wt.map(g=>jsx(jt,{tabId:g,target:fe[g]||null,renderWidget:r},g))})]})})})},jt=({tabId:e,target:t,renderWidget:r})=>{let o=useRef(null);!o.current&&typeof window<"u"&&(o.current=document.createElement("div"),o.current.className=`zeugma-portal-wrapper-${e}`,o.current.style.width="100%",o.current.style.height="100%");let n=o.current;return useEffect(()=>{if(n)if(t)t.appendChild(n);else {let s=document.getElementById("zeugma-hidden-portal-container");s||(s=document.createElement("div"),s.id="zeugma-hidden-portal-container",s.style.display="none",document.body.appendChild(s)),s.appendChild(n);}},[t,n]),useEffect(()=>()=>{o.current&&o.current.remove();},[]),!n||!r?null:createPortal(r(e),n)};function Oe({cursor:e,resizerEl:t,onMove:r,onEnd:o}){document.body.classList.add("zeugma-resizing");let n=document.createElement("style");n.id="zeugma-global-cursor-style",n.textContent=`
1
+ import tn,{createContext,useState,useRef,useCallback,useEffect,useMemo,useContext}from'react';import {createPortal}from'react-dom';import {useSensors,useSensor,pointerWithin,closestCenter,DndContext,useDraggable,useDroppable,PointerSensor,TouchSensor}from'@dnd-kit/core';import {jsx,Fragment,jsxs}from'react/jsx-runtime';var ze=createContext(void 0),Ie=createContext(void 0);var ee=()=>{let e=useContext(ze);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},$e=()=>{let e=useContext(Ie);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e};function st(e){let t=useRef(null);return useEffect(()=>{if(!e){t.current=null;return}let r=n=>{t.current={x:n.clientX,y:n.clientY};},s=n=>{let o=n.touches[0]||n.changedTouches[0];o&&(t.current={x:o.clientX,y:o.clientY});};return window.addEventListener("pointermove",r,{passive:true}),window.addEventListener("touchmove",s,{passive:true}),()=>{window.removeEventListener("pointermove",r),window.removeEventListener("touchmove",s);}},[e]),t}function it(e){useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function at(){let[e,t]=useState({}),r=useRef(true);useEffect(()=>(r.current=true,()=>{r.current=false;}),[]);let s=useCallback((n,o)=>{setTimeout(()=>{r.current&&t(i=>i[n]===o?i:{...i,[n]:o});},0);},[]);return {portalTargets:e,registerPortalTarget:s}}var ke=createContext(void 0);var Ht=8,At=8,Fn=4;function ie(){return "pane-"+Math.random().toString(36).substring(2,11)}function be(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let r=be(e.first,t),s=be(e.second,t);return r===null?s:s===null?r:{...e,first:r,second:s}}function de(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let n=e.tabs.filter(a=>a!==t);if(n.length===0)return null;let o=e.activeTabId;e.activeTabId===t&&(o=n[0]);let i={...e.tabsMetadata};return delete i[t],{...e,tabs:n,activeTabId:o,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}let r=de(e.first,t),s=de(e.second,t);return r===null?s:s===null?r:{...e,first:r,second:s}}function ye(e,t,r,s,n){if(e===null)return typeof n=="string"?{type:"pane",id:ie(),tabs:[n],activeTabId:n}:n;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){let o=typeof n=="string"?{type:"pane",id:ie(),tabs:[n],activeTabId:n}:n,i=s==="left"||s==="top";return {type:"split",direction:r,first:i?o:e,second:i?e:o,splitPercentage:50}}return e}return {...e,first:ye(e.first,t,r,s,n)||e.first,second:ye(e.second,t,r,s,n)||e.second}}function lt(e,t){if(e===null)return {type:"pane",id:ie(),tabs:[t],activeTabId:t};function r(s,n){return s.type==="pane"?{type:"split",direction:n==="row"?"column":"row",splitPercentage:50,first:s,second:{type:"pane",id:ie(),tabs:[t],activeTabId:t}}:{...s,second:r(s.second,s.direction)}}return r(e,null)}function ve(e,t,r){return e===null?null:e===t?{...e,splitPercentage:r}:e.type==="split"?{...e,first:ve(e.first,t,r)||e.first,second:ve(e.second,t,r)||e.second}:e}function q(e,t){return e===null?null:e.type==="pane"?e.id===t||e.tabs.includes(t)?e:null:q(e.first,t)??q(e.second,t)}function Ze(e,t,r){if(e===null)return null;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){let s=e.tabsMetadata||{},n=s[t],o=r(n),i={...s};return o===void 0?delete i[t]:i[t]=o,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return {...e,first:Ze(e.first,t,r)??e.first,second:Ze(e.second,t,r)??e.second}}function He(e,t,r){if(e===null)return null;if(e.type==="pane"){if(e.id===t||e.tabs.includes(t)){if(r===false){let{locked:s,...n}=e;return n}return {...e,locked:r}}return e}return {...e,first:He(e.first,t,r)??e.first,second:He(e.second,t,r)??e.second}}function Ae(e,t,r){return e===null?null:e.type==="pane"?e.id===t||e.tabs.includes(t)?{...e,activeTabId:r}:e:{...e,first:Ae(e.first,t,r)??e.first,second:Ae(e.second,t,r)??e.second}}function ct(e,t,r){if(e===null)return null;let n=q(e,t)?.tabsMetadata?.[t],o=de(e,t);if(o===null)return {type:"pane",id:ie(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0};function i(a){if(a.type==="pane"){if(a.id===r||a.tabs.includes(r)){let l=[...a.tabs];l.includes(t)||l.push(t);let y={...a.tabsMetadata};return n&&(y[t]=n),{...a,tabs:l,activeTabId:t,tabsMetadata:Object.keys(y).length>0?y:void 0}}return a}return {...a,first:i(a.first),second:i(a.second)}}return i(o)}function ut(e,t,r,s="before"){if(e===null)return null;let o=q(e,t)?.tabsMetadata?.[t],i=de(e,t);if(i===null)return {type:"pane",id:ie(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(l){if(l.type==="pane"){if(l.id===r||l.tabs.includes(r)){let D=[...l.tabs].filter(x=>x!==t),c=D.indexOf(r);c<0&&(c=0),s==="after"&&(c+=1),D.splice(c,0,t);let T={...l.tabsMetadata};return o&&(T[t]=o),{...l,tabs:D,activeTabId:t,tabsMetadata:Object.keys(T).length>0?T:void 0}}return l}return {...l,first:a(l.first),second:a(l.second)}}return a(i)}function se(e,t=0,r=0,s=100,n=100,o="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:r,width:s,height:n,node:e}],splitters:[]};let{direction:i,splitPercentage:a,first:l,second:y}=e,c={id:`splitter-${o}-${i}`,currentNode:e,direction:i,left:i==="row"?t+s*(a/100):t,top:i==="column"?r+n*(a/100):r,width:i==="row"?0:s,height:i==="column"?0:n,parentLeft:t,parentTop:r,parentWidth:s,parentHeight:n},T={panes:[],splitters:[]},x={panes:[],splitters:[]};if(i==="row"){let v=s*(a/100);T=se(l,t,r,v,n,`${o}-L`),x=se(y,t+v,r,s-v,n,`${o}-R`);}else {let v=n*(a/100);T=se(l,t,r,s,v,`${o}-T`),x=se(y,t,r+v,s,n-v,`${o}-B`);}return {panes:[...T.panes,...x.panes],splitters:[c,...T.splitters,...x.splitters]}}function Ft(e){let{initialLayout:t,onChange:r,fullscreenPaneId:s,onFullscreenChange:n,locked:o=false,dragActivationDistance:i=8,snapThreshold:a=8,minSplitPercentage:l=5,maxSplitPercentage:y=95,enableDragToDismiss:D=false,dismissThreshold:c=60,onRemove:T,onDragStart:x,onDragEnd:v,onResizeStart:R,onResize:E,onResizeEnd:L,onDismissIntentChange:p}=e,[b,f]=useState(t),[z,A]=useState(s||null),[I,V]=useState(o),[w,K]=useState(null),[h,F]=useState(null),[Y,O]=useState(null),m=useRef(null),$=useCallback(u=>{m.current=u;},[]),_=useCallback(u=>{A(u),n?.(u);},[n]);useEffect(()=>{V(o);},[o]),useEffect(()=>{s!==void 0&&A(s);},[s]);let k=useRef(true);useEffect(()=>{if(k.current){k.current=false;return}r?.(b);},[b,r]);let N=useCallback(u=>{f(S=>be(S,u));},[]),d=useCallback(u=>{f(S=>lt(S,u));},[]),B=useCallback((u,S,P,ne)=>{f(Re=>{let Ye=q(Re,ne)??{type:"pane",id:ne,tabs:[ne],activeTabId:ne},Be=be(Re,ne);return ye(Be,u,S,P,Ye)});},[]),ae=useCallback((u,S)=>{f(P=>ve(P,u,S));},[]),W=useCallback((u,S)=>{f(P=>Ze(P,u,S));},[]),te=useCallback((u,S)=>{f(P=>He(P,u,S));},[]),le=useCallback((u,S)=>{f(P=>Ae(P,u,S));},[]),fe=useCallback((u,S)=>{f(P=>ct(P,u,S));},[]),me=useCallback((u,S,P)=>{f(ne=>ut(ne,u,S,P));},[]),j=useCallback(u=>{f(S=>de(S,u));},[]);return {layout:b,setLayout:f,fullscreenPaneId:z,setFullscreenPaneId:_,locked:I,setLocked:V,activeId:w,setActiveId:K,activeType:h,setActiveType:F,dismissIntentId:Y,setDismissIntentId:O,containerRef:m,setContainerRef:$,dragActivationDistance:i,snapThreshold:a,minSplitPercentage:l,maxSplitPercentage:y,enableDragToDismiss:D,dismissThreshold:c,onRemove:T,onDragStart:x,onDragEnd:v,onResizeStart:R,onResize:E,onResizeEnd:L,onDismissIntentChange:p,removePane:N,addPane:d,splitPane:B,updateSplitPercentage:ae,updateTabMetadata:W,updatePaneLock:te,selectTab:le,mergeTab:fe,moveTab:me,removeTab:j}}var Ot=()=>{let e=ee(),t=$e();return {...e,...t}};var pt=({activeId:e,render:t,className:r})=>{let s=useRef(null);return useEffect(()=>{let n=o=>{s.current&&(s.current.style.transform=`translate(${o.clientX+12}px, ${o.clientY+12}px)`);};return document.addEventListener("pointermove",n),()=>document.removeEventListener("pointermove",n)},[]),jsx("div",{ref:s,className:r,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var Fe=class extends PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Oe=class extends TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};function je(e){if(e instanceof MouseEvent||e instanceof PointerEvent)return {x:e.clientX,y:e.clientY};if(typeof TouchEvent<"u"&&e instanceof TouchEvent){let t=e.touches[0]||e.changedTouches[0];if(t)return {x:t.clientX,y:t.clientY}}return null}var jt=e=>{let{renderPane:t,renderWidget:r,renderDragOverlay:s,classNames:n={},children:o,layout:i,setLayout:a,fullscreenPaneId:l,setFullscreenPaneId:y,locked:D,activeId:c,setActiveId:T,activeType:x,setActiveType:v,dismissIntentId:R,setDismissIntentId:E,containerRef:L,setContainerRef:p,dragActivationDistance:b,snapThreshold:f,minSplitPercentage:z,maxSplitPercentage:A,enableDragToDismiss:I,dismissThreshold:V,onRemove:w,onDragStart:K,onDragEnd:h,onResizeStart:F,onResize:Y,onResizeEnd:O,onDismissIntentChange:m,removePane:$,addPane:_,splitPane:k,updateSplitPercentage:N,updateTabMetadata:d,updatePaneLock:B,selectTab:ae,mergeTab:W,moveTab:te,removeTab:le}=e,{portalTargets:fe,registerPortalTarget:me}=at(),j=useRef(null),u=st(c),[S,P]=useState(false);it(S);let ne=useCallback(g=>t(g),[t]),Re=useMemo(()=>n,[n.pane,n.paneLocked,n.dropPreview,n.dragOverlay,n.resizer,n.dismissPreview,n.dashboardLocked,n.lockedPreview]),Ye=useSensors(useSensor(Fe,{activationConstraint:{distance:b}}),useSensor(Oe,{activationConstraint:{delay:250,tolerance:5}})),Be=useCallback(g=>{let Z=pointerWithin(g);if(Z.length>0)return Z;if(g.active.id.toString().startsWith("tab-header-")){let re=g.droppableContainers.filter(J=>J.id.toString().startsWith("tab-drop-"));return closestCenter({...g,droppableContainers:re})}return []},[]),Dt=g=>{let Z=g.active.id.toString(),U=Z.startsWith("tab-header-"),re=U?Z.substring(11):Z;T(re),v(U?"tab":"pane");let J=g.activatorEvent;u.current=je(J),I&&L.current?j.current=L.current.getBoundingClientRect():j.current=null,K&&K(re);},Et=g=>{let{over:Z}=g,re=(Z?.id.toString()||"").startsWith("drop-locked-");if(P(re),!I)return;let J=g.active.id.toString(),Se=J.startsWith("tab-header-")?J.substring(11):J,M=j.current;if(!M){R!==null&&(E(null),m?.(null));return}let we=g.activatorEvent,oe=null,X=null;if(u.current)oe=u.current.x,X=u.current.y;else {let H=je(we);H&&(oe=H.x+g.delta.x,X=H.y+g.delta.y);}let ce=0;if(oe!==null&&X!==null){let H=0,Q=0;oe<M.left?H=M.left-oe:oe>M.right&&(H=oe-M.right),X<M.top?Q=M.top-X:X>M.bottom&&(Q=X-M.bottom),ce=Math.sqrt(H*H+Q*Q);}else {let H=g.active.rect.current.translated;if(H){let Q=H.left+H.width/2,ge=H.top+H.height/2,ue=0,Pe=0;Q<M.left?ue=M.left-Q:Q>M.right&&(ue=Q-M.right),ge<M.top?Pe=M.top-ge:ge>M.bottom&&(Pe=ge-M.bottom),ce=Math.sqrt(ue*ue+Pe*Pe);}}ce>V?R!==Se&&(E(Se),m?.(Se)):R!==null&&(E(null),m?.(null));},Ct=g=>{T(null),v(null),P(false);let{active:Z,over:U}=g,re=Z.id.toString(),J=re.startsWith("tab-header-"),C=J?re.substring(11):re,Se=I&&R===C;if(E(null),m?.(null),j.current=null,Se){w?w(C):le(C),h&&h(C,null,null);return}if(!U){h&&h(C,null,null);return}let M=U.id.toString();if(M.startsWith("drop-locked-")){h&&h(C,null,null);return}let we=M.match(/^tab-drop-(.+)$/);if(we){let[,Ne]=we;if(C!==Ne){let Ee="before",tt=U.rect,It=g.activatorEvent,Me=null;if(u.current)Me=u.current.x;else {let Le=je(It);Le&&(Me=Le.x+g.delta.x);}if(Me!==null){let Le=tt.left+tt.width/2;Me>Le&&(Ee="after");}te(C,Ne,Ee);}h&&h(C,Ne,{type:"swap",position:"center"});return}let oe=M.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!oe){h&&h(C,null,null);return}let[,X,ce]=oe,De=q(i,C),H=De&&De.id===ce,Q=De&&De.tabs.length===1;if(C===ce||H&&Q){h&&h(C,null,null);return}let ge=X==="left"||X==="right"?"row":"column",ue;if(J){let Ee=q(i,C)?.tabsMetadata?.[C];ue={type:"pane",id:ie(),tabs:[C],activeTabId:C,tabsMetadata:Ee?{[C]:Ee}:void 0};}else ue=q(i,C)??{type:"pane",id:ie(),tabs:[C],activeTabId:C};let Pe=J?de(i,C):be(i,C),zt=ye(Pe,ce,ge,X,ue);a(zt),h&&h(C,ce,{type:"split",direction:ge,position:X});},et=useCallback((g,Z)=>{O&&O(g,Z);},[O]),wt=useMemo(()=>({layout:i,onLayoutChange:g=>a(g),renderPane:ne,activeId:c,dismissIntentId:R,setContainerRef:p,fullscreenPaneId:l,classNames:Re,onRemove:w,onFullscreenChange:y,snapThreshold:f,onResizeStart:F,onResize:Y,onResizeEnd:et,minSplitPercentage:z,maxSplitPercentage:A,locked:D}),[i,c,R,p,l,Re,w,y,f,F,Y,z,A,a,ne,et,D]),Nt=useMemo(()=>({removePane:$,addPane:_,splitPane:k,updateSplitPercentage:N,updateTabMetadata:d,updatePaneLock:B,selectTab:ae,mergeTab:W,moveTab:te,removeTab:le}),[$,_,k,N,d,B,ae,W,te,le]),Mt=useMemo(()=>{let g=[];function Z(U){U&&(U.type==="pane"?g.push(...U.tabs):(Z(U.first),Z(U.second)));}return Z(i),g},[i]),Lt=useMemo(()=>({registerPortalTarget:me}),[me]);return jsx(Ie.Provider,{value:Nt,children:jsx(ze.Provider,{value:wt,children:jsxs(ke.Provider,{value:Lt,children:[jsx(DndContext,{id:"zeugma-dnd-context",sensors:Ye,collisionDetection:Be,onDragStart:Dt,onDragMove:Et,onDragEnd:Ct,children:o}),c&&x&&s&&jsx(pt,{activeId:c,render:g=>s(g,x),className:`${n.dragOverlay||""} ${c===R?n.dismissPreview||"zeugma-dismiss-preview":""}`.trim()}),jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:Mt.map(g=>jsx(Jt,{tabId:g,target:fe[g]||null,renderWidget:r},g))})]})})})},Jt=({tabId:e,target:t,renderWidget:r})=>{let[s,n]=useState(false),o=useRef(null);if(useEffect(()=>{n(true);},[]),useEffect(()=>{if(!s||!o.current)return;let a=o.current;if(t)t.appendChild(a);else {let l=document.getElementById("zeugma-hidden-portal-container");l||(l=document.createElement("div"),l.id="zeugma-hidden-portal-container",l.style.display="none",document.body.appendChild(l)),l.appendChild(a);}},[t,s]),useEffect(()=>()=>{o.current&&o.current.remove();},[]),!s)return null;o.current||(o.current=document.createElement("div"),o.current.className=`zeugma-portal-wrapper-${e}`,o.current.style.width="100%",o.current.style.height="100%");let i=o.current;return !i||!r?null:createPortal(r(e),i)};function Ve({cursor:e,resizerEl:t,onMove:r,onEnd:s}){document.body.classList.add("zeugma-resizing");let n=document.createElement("style");n.id="zeugma-global-cursor-style",n.textContent=`
2
2
  * {
3
3
  cursor: ${e} !important;
4
4
  user-select: none !important;
5
5
  }
6
- `,document.head.appendChild(n),t.setAttribute("data-resizing","true");let s=a=>{r(a);},i=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let a=document.getElementById("zeugma-global-cursor-style");a&&a.remove(),document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",i),o();};document.addEventListener("pointermove",s),document.addEventListener("pointerup",i);}function Ge({containerRef:e,isRow:t,direction:r,splitPercentage:o,resizerSize:n,snapThreshold:s,layout:i,currentNode:a,onLayoutChange:l,onResizeStart:y,onResizeEnd:D,parentLeft:c,parentTop:x,parentWidth:T,parentHeight:v}){let{onResizeStart:R,onResize:E,onResizeEnd:L,minSplitPercentage:p=5,maxSplitPercentage:b=95,locked:f=false}=oe();return useCallback(z=>{if(f)return;z.preventDefault();let A=e.current;if(!A)return;y&&y(),R&&R(a);let I=A.getBoundingClientRect(),V=z.clientX,w=z.clientY,K=o,h=z.currentTarget,F=I.left+I.width*(c/100),Y=I.top+I.height*(x/100),O=I.width*(T/100),m=I.height*(v/100),_=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(N=>N!==h&&N.getAttribute("data-direction")===r).map(N=>{let d=N.getBoundingClientRect();return t?d.left+d.width/2:d.top+d.height/2}),k=K;Oe({cursor:t?"col-resize":"row-resize",resizerEl:h,onMove:N=>{let d=t?(N.clientX-V)/O*100:(N.clientY-w)/m*100,B=K+d,ae=t?F+(O-n)*(B/100)+n/2:Y+(m-n)*(B/100)+n/2,W=1/0,ee=null;for(let j of _){let u=Math.abs(ae-j);u<s&&u<W&&(W=u,ee=j);}let le=B;ee!==null&&(le=t?(ee-n/2-F)/(O-n)*100:(ee-n/2-Y)/(m-n)*100);let fe=Math.max(p,Math.min(b,le));k=fe;let me=ve(i,a,fe);if(me){let{panes:j,splitters:u}=se(me),S=e.current;if(S){for(let P of j)S.style.setProperty(`--pane-left-${P.paneId}`,`${P.left}%`),S.style.setProperty(`--pane-top-${P.paneId}`,`${P.top}%`),S.style.setProperty(`--pane-width-${P.paneId}`,`${P.width}%`),S.style.setProperty(`--pane-height-${P.paneId}`,`${P.height}%`);for(let P of u)S.style.setProperty(`--splitter-pos-${P.id}`,`${P.direction==="row"?P.left:P.top}%`);}}E&&E(a,fe);},onEnd:()=>{let N=ve(i,a,k),d=e.current;if(d){let{panes:B,splitters:ae}=se(N);for(let W of B)d.style.removeProperty(`--pane-left-${W.paneId}`),d.style.removeProperty(`--pane-top-${W.paneId}`),d.style.removeProperty(`--pane-width-${W.paneId}`),d.style.removeProperty(`--pane-height-${W.paneId}`);for(let W of ae)d.style.removeProperty(`--splitter-pos-${W.id}`);}l(N),D&&D(),L&&L(a,k);}});},[e,t,r,o,n,s,i,a,l,y,D,R,E,L,p,b,c,x,T,v])}var on=({splitter:e,resizerSize:t,snapThreshold:r,containerRef:o})=>{let{layout:n,onLayoutChange:s,classNames:i,locked:a}=oe(),[l,y]=useState(false),{currentNode:D,direction:c,left:x,top:T,width:v,height:R,parentLeft:E,parentTop:L,parentWidth:p,parentHeight:b}=e,f=c==="row",z=Ge({containerRef:o,isRow:f,direction:c,splitPercentage:D.splitPercentage,resizerSize:t,snapThreshold:r,layout:n,currentNode:D,onLayoutChange:s,onResizeStart:()=>y(true),onResizeEnd:()=>y(false),parentLeft:E,parentTop:L,parentWidth:p,parentHeight:b}),A=f?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${x}%) - ${t/2}px)`,top:`calc(${T}% + ${t/2}px)`,width:`${t}px`,height:`calc(${R}% - ${t}px)`,cursor:a?"default":"col-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${x}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${T}%) - ${t/2}px)`,width:`calc(${v}% - ${t}px)`,height:`${t}px`,cursor:a?"default":"row-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsx("div",{className:`zeugma-resizer ${i.resizer||""}`.trim(),"data-direction":c,"data-resizing":l||void 0,style:A,onPointerDown:z,role:"separator","aria-valuenow":D.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},sn=en.memo(({paneId:e,renderPane:t})=>jsx(Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),an=({tree:e,resizerSize:t=4,snapThreshold:r})=>{let{layout:o,renderPane:n,activeId:s,dismissIntentId:i,setContainerRef:a,fullscreenPaneId:l,snapThreshold:y,locked:D,classNames:c}=oe(),x=r!==void 0?r:y??8,T=e!==void 0?e:o,v=useRef(null),{panes:R,splitters:E}=useMemo(()=>T?se(T):{panes:[],splitters:[]},[T]);if(!T)return null;let L=()=>jsxs(Fragment,{children:[R.map(p=>{let b=l===p.paneId;return jsx("div",{style:{position:"absolute",left:b?"0%":`var(--pane-left-${p.paneId}, ${p.left}%)`,top:b?"0%":`var(--pane-top-${p.paneId}, ${p.top}%)`,width:b?"100%":`var(--pane-width-${p.paneId}, ${p.width}%)`,height:b?"100%":`var(--pane-height-${p.paneId}, ${p.height}%)`,overflow:"hidden",zIndex:b?20:1,display:l&&!b?"none":"block",padding:b?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsx(sn,{paneId:p.paneId,renderPane:n})},p.paneId)}),!l&&E.map(p=>jsx(on,{splitter:p,resizerSize:t,snapThreshold:x,containerRef:v},p.id))]});if(e===void 0){let p=s!==null&&s===i,b=z=>{a(z),v.current=z;},f=`zeugma-dashboard-root ${p?"zeugma-dashboard-dismiss-active":""} ${D?c.dashboardLocked||"zeugma-dashboard-locked":""}`.trim();return jsx("div",{ref:b,className:f,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:L()})}return jsx("div",{ref:v,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:L()})};var ht="zeugma-height:",dn="default-pane";function pn(e){try{let t=localStorage.getItem(ht+e);if(t!==null){let r=Number(t);if(Number.isFinite(r)&&r>0)return r}}catch{}return null}function vt(e,t){try{localStorage.setItem(ht+e,String(Math.round(t)));}catch{}}var Pt=({children:e,active:t=true,height:r,onHeightChange:o,minHeight:n=100,maxHeight:s=1/0,persist:i,localStorageKey:a,resizerHeight:l=6,className:y,resizerClassName:D})=>{let c=i?a||dn:null,x=()=>{let f=(c?pn(c):null)??r??400;return Ve(f,n,s)},[T,v]=useState(x),R=useRef(null),E=c?T:r??T,L=useRef(r);useEffect(()=>{if(r!==void 0&&r!==L.current){let f=Ve(r,n,s);v(f),c&&vt(c,f);}L.current=r;},[r,n,s,c]);let p=useCallback(()=>s,[s]),b=useCallback(f=>{f.preventDefault();let z=f.clientY,A=E,I=p(),V=f.currentTarget,w=yt(R.current),K=w?w.scrollTop:0,h=z,F=null,Y=(m,$)=>{let _=$-K,N=m-z+_,d=Ve(A+N,n,I);return R.current&&(R.current.style.height=`${d}px`),d},O=()=>{if(!w)return;let m=w===document.documentElement||w===document.body?{top:0,bottom:window.innerHeight}:w.getBoundingClientRect(),$=40,_=10,k=0;h>m.bottom-$?k=Math.min(1,(h-(m.bottom-$))/$)*_:h<m.top+$&&(k=-Math.min(1,(m.top+$-h)/$)*_),k!==0&&(w.scrollTop+=k,Y(h,w.scrollTop)),F=requestAnimationFrame(O);};F=requestAnimationFrame(O),Oe({cursor:"row-resize",resizerEl:V,onMove:m=>{h=m.clientY,w&&Y(h,w.scrollTop);},onEnd:()=>{F!==null&&cancelAnimationFrame(F);let m=A;R.current&&(m=R.current.getBoundingClientRect().height),m=Ve(m,n,I),v(m),o&&o(m),c&&vt(c,m);}});},[E,n,p,o,c]);return t?jsxs("div",{ref:R,className:`zeugma-resizable-container ${y||""}`.trim(),style:{height:`${E}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsx("div",{style:{height:`calc(100% - ${l}px)`,overflow:"hidden"},children:e}),jsx("div",{className:`zeugma-resizable-handle ${D||""}`.trim(),style:{height:`${l}px`,cursor:"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:b,role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(E),"aria-valuemin":n,"aria-valuemax":s===1/0?void 0:s})]}):jsx("div",{className:`zeugma-resizable-container disabled ${y||""}`.trim(),style:{height:"100%",position:"relative",overflow:"hidden",boxSizing:"border-box"},children:jsx("div",{style:{height:"100%",overflow:"hidden"},children:e})})};function Ve(e,t,r){return Math.max(t,Math.min(r,e))}function yt(e){if(typeof window>"u"||!e)return null;let t=e.parentElement;if(!t)return document.documentElement;let o=window.getComputedStyle(t).overflowY;return o==="auto"||o==="scroll"?t:yt(t)}var Ue=createContext(null);var yn={top:{position:"absolute",top:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},Tn={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},Tt=({id:e,position:t,activeClassName:r})=>{let{setNodeRef:o,isOver:n}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:o,style:yn[t]}),n&&jsx("div",{className:r,style:Tn[t]})]})},xn=({id:e,children:t,style:r,locked:o=false})=>{let{layout:n,activeId:s,classNames:i,fullscreenPaneId:a,onFullscreenChange:l,locked:y}=oe(),{removePane:D,updateTabMetadata:c,selectTab:x,removeTab:T}=nt(),v=useContext($e);if(!v)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:R}=v,E=useMemo(()=>q(n,e),[n,e]),L=E?.id??e,p=E?.tabs??[e],b=E?.activeTabId??e,f=E?.tabsMetadata,z=f?.[e],A=E?.locked??false,I=o||A,V=y||I,w=y||I,K=s!==null&&s!==e&&(!p.includes(s)||p.length>1)&&!w,{attributes:h,listeners:F,setNodeRef:Y}=useDraggable({id:e,disabled:V}),O=s!==null&&p.includes(s),m=a===e,$=useCallback(()=>jsx("div",{id:`zeugma-tab-target-${b}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[b]);useEffect(()=>{let d=document.getElementById(`zeugma-tab-target-${b}`);return R(b,d),()=>{R(b,null);}},[b,R]);let _=useMemo(()=>({isDragging:O,isFullscreen:m,toggleFullscreen:()=>l?.(m?null:e),remove:()=>{m&&l?.(null),D(L);},metadata:z,updateMetadata:d=>{c(e,d);},locked:V,tabs:p,activeTabId:b,selectTab:d=>x(L,d),removeTab:d=>{m&&d===b&&l?.(null),T(d);},tabsMetadata:f,updateTabMetadata:(d,B)=>{c(d,B);},renderActiveTab:$}),[O,m,l,e,T,z,c,V,p,b,x,L,f,$]),k=useMemo(()=>V?{disabled:true}:{...F,...h},[F,h,V]),N=`${i.pane||""} ${I?i.paneLocked||"zeugma-pane-locked":""}`.trim();return jsx(Ue.Provider,{value:k,children:jsxs("div",{ref:Y,className:N,style:{position:"relative",width:"100%",height:"100%",...r},children:[t(_),K&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(d=>jsx(Tt,{id:`drop-${d}-${e}`,position:d,activeClassName:i.dropPreview},d))}),s!==null&&s!==e&&w&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsx(Tt,{id:`drop-locked-${e}`,position:"full",activeClassName:i.lockedPreview||"zeugma-locked-preview"})})]})})};var Dn=({children:e,className:t,style:r})=>{let o=useContext(Ue);if(!o)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:n,...s}=o;return jsx("div",{className:t,style:{cursor:n?"default":"grab",userSelect:n?"auto":"none",touchAction:n?"auto":"none",...r},...n?{}:s,children:e})};var Nn=({id:e,locked:t=false,children:r,className:o,style:n})=>{let{locked:s}=oe(),i=t||s,{attributes:a,listeners:l,setNodeRef:y,isDragging:D}=useDraggable({id:`tab-header-${e}`,disabled:i}),{setNodeRef:c,isOver:x}=useDroppable({id:`tab-drop-${e}`,disabled:i});return jsx("div",{ref:v=>{y(v),c(v);},className:o,style:{display:"inline-flex",cursor:i?"default":"grab",...n},...i?{}:l,...i?{}:a,children:r({isDragging:D,isOver:x})})};export{Zt as DEFAULT_DRAG_ACTIVATION_DISTANCE,An as DEFAULT_RESIZER_SIZE,Ht as DEFAULT_SNAP_THRESHOLD,Dn as DragHandle,xn as Pane,an as PaneTree,Pt as ResizableContainer,Nn as Tab,Kt as Zeugma,it as addPane,se as computeLayout,Oe as createDragSession,q as findPane,ie as generateUniqueId,at as mergeTab,lt as moveTab,be as removePane,de as removeTab,Ze as selectTab,ye as splitPane,He as updatePaneLock,ve as updateSplitPercentage,ke as updateTabMetadata,Ge as useResizer,At as useZeugma};//# sourceMappingURL=index.js.map
6
+ `,document.head.appendChild(n),t.setAttribute("data-resizing","true");let o=a=>{r(a);},i=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let a=document.getElementById("zeugma-global-cursor-style");a&&a.remove(),document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i),s();};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i);}function Je({containerRef:e,isRow:t,direction:r,splitPercentage:s,resizerSize:n,snapThreshold:o,layout:i,currentNode:a,onLayoutChange:l,onResizeStart:y,onResizeEnd:D,parentLeft:c,parentTop:T,parentWidth:x,parentHeight:v}){let{onResizeStart:R,onResize:E,onResizeEnd:L,minSplitPercentage:p=5,maxSplitPercentage:b=95,locked:f=false}=ee();return useCallback(z=>{if(f)return;z.preventDefault();let A=e.current;if(!A)return;y&&y(),R&&R(a);let I=A.getBoundingClientRect(),V=z.clientX,w=z.clientY,K=s,h=z.currentTarget,F=I.left+I.width*(c/100),Y=I.top+I.height*(T/100),O=I.width*(x/100),m=I.height*(v/100),_=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(N=>N!==h&&N.getAttribute("data-direction")===r).map(N=>{let d=N.getBoundingClientRect();return t?d.left+d.width/2:d.top+d.height/2}),k=K;Ve({cursor:t?"col-resize":"row-resize",resizerEl:h,onMove:N=>{let d=t?(N.clientX-V)/O*100:(N.clientY-w)/m*100,B=K+d,ae=t?F+(O-n)*(B/100)+n/2:Y+(m-n)*(B/100)+n/2,W=1/0,te=null;for(let j of _){let u=Math.abs(ae-j);u<o&&u<W&&(W=u,te=j);}let le=B;te!==null&&(le=t?(te-n/2-F)/(O-n)*100:(te-n/2-Y)/(m-n)*100);let fe=Math.max(p,Math.min(b,le));k=fe;let me=ve(i,a,fe);if(me){let{panes:j,splitters:u}=se(me),S=e.current;if(S){for(let P of j)S.style.setProperty(`--pane-left-${P.paneId}`,`${P.left}%`),S.style.setProperty(`--pane-top-${P.paneId}`,`${P.top}%`),S.style.setProperty(`--pane-width-${P.paneId}`,`${P.width}%`),S.style.setProperty(`--pane-height-${P.paneId}`,`${P.height}%`);for(let P of u)S.style.setProperty(`--splitter-pos-${P.id}`,`${P.direction==="row"?P.left:P.top}%`);}}E&&E(a,fe);},onEnd:()=>{let N=ve(i,a,k),d=e.current;if(d){let{panes:B,splitters:ae}=se(N);for(let W of B)d.style.removeProperty(`--pane-left-${W.paneId}`),d.style.removeProperty(`--pane-top-${W.paneId}`),d.style.removeProperty(`--pane-width-${W.paneId}`),d.style.removeProperty(`--pane-height-${W.paneId}`);for(let W of ae)d.style.removeProperty(`--splitter-pos-${W.id}`);}l(N),D&&D(),L&&L(a,k);}});},[e,t,r,s,n,o,i,a,l,y,D,R,E,L,p,b,c,T,x,v])}var sn=({splitter:e,resizerSize:t,snapThreshold:r,containerRef:s})=>{let{layout:n,onLayoutChange:o,classNames:i,locked:a}=ee(),[l,y]=useState(false),{currentNode:D,direction:c,left:T,top:x,width:v,height:R,parentLeft:E,parentTop:L,parentWidth:p,parentHeight:b}=e,f=c==="row",z=Je({containerRef:s,isRow:f,direction:c,splitPercentage:D.splitPercentage,resizerSize:t,snapThreshold:r,layout:n,currentNode:D,onLayoutChange:o,onResizeStart:()=>y(true),onResizeEnd:()=>y(false),parentLeft:E,parentTop:L,parentWidth:p,parentHeight:b}),A=f?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${T}%) - ${t/2}px)`,top:`calc(${x}% + ${t/2}px)`,width:`${t}px`,height:`calc(${R}% - ${t}px)`,cursor:a?"default":"col-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${T}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${x}%) - ${t/2}px)`,width:`calc(${v}% - ${t}px)`,height:`${t}px`,cursor:a?"default":"row-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsx("div",{className:`zeugma-resizer ${i.resizer||""}`.trim(),"data-direction":c,"data-resizing":l||void 0,style:A,onPointerDown:z,role:"separator","aria-valuenow":D.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},an=tn.memo(({paneId:e,renderPane:t})=>jsx(Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),ln=({tree:e,resizerSize:t=4,snapThreshold:r})=>{let{layout:s,renderPane:n,activeId:o,dismissIntentId:i,setContainerRef:a,fullscreenPaneId:l,snapThreshold:y,locked:D,classNames:c}=ee(),T=r!==void 0?r:y??8,x=e!==void 0?e:s,v=useRef(null),{panes:R,splitters:E}=useMemo(()=>x?se(x):{panes:[],splitters:[]},[x]);if(!x)return null;let L=()=>jsxs(Fragment,{children:[R.map(p=>{let b=l===p.paneId;return jsx("div",{style:{position:"absolute",left:b?"0%":`var(--pane-left-${p.paneId}, ${p.left}%)`,top:b?"0%":`var(--pane-top-${p.paneId}, ${p.top}%)`,width:b?"100%":`var(--pane-width-${p.paneId}, ${p.width}%)`,height:b?"100%":`var(--pane-height-${p.paneId}, ${p.height}%)`,overflow:"hidden",zIndex:b?20:1,display:l&&!b?"none":"block",padding:b?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsx(an,{paneId:p.paneId,renderPane:n})},p.paneId)}),!l&&E.map(p=>jsx(sn,{splitter:p,resizerSize:t,snapThreshold:T,containerRef:v},p.id))]});if(e===void 0){let p=o!==null&&o===i,b=z=>{a(z),v.current=z;},f=`zeugma-dashboard-root ${p?"zeugma-dashboard-dismiss-active":""} ${D?c.dashboardLocked||"zeugma-dashboard-locked":""}`.trim();return jsx("div",{ref:b,className:f,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:L()})}return jsx("div",{ref:v,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:L()})};var yt="zeugma-height:",pn="default-pane";function fn(e){try{let t=localStorage.getItem(yt+e);if(t!==null){let r=Number(t);if(Number.isFinite(r)&&r>0)return r}}catch{}return null}function Pt(e,t){try{localStorage.setItem(yt+e,String(Math.round(t)));}catch{}}var xt=({children:e,active:t=true,height:r,onHeightChange:s,minHeight:n=100,maxHeight:o=1/0,persist:i,localStorageKey:a,resizerHeight:l=6,className:y,resizerClassName:D})=>{let c=i?a||pn:null,T=()=>{let f=(c?fn(c):null)??r??400;return We(f,n,o)},[x,v]=useState(T),R=useRef(null),E=c?x:r??x,L=useRef(r);useEffect(()=>{if(r!==void 0&&r!==L.current){let f=We(r,n,o);v(f),c&&Pt(c,f);}L.current=r;},[r,n,o,c]);let p=useCallback(()=>o,[o]),b=useCallback(f=>{f.preventDefault();let z=f.clientY,A=E,I=p(),V=f.currentTarget,w=Tt(R.current),K=w?w.scrollTop:0,h=z,F=null,Y=(m,$)=>{let _=$-K,N=m-z+_,d=We(A+N,n,I);return R.current&&(R.current.style.height=`${d}px`),d},O=()=>{if(!w)return;let m=w===document.documentElement||w===document.body?{top:0,bottom:window.innerHeight}:w.getBoundingClientRect(),$=40,_=10,k=0;h>m.bottom-$?k=Math.min(1,(h-(m.bottom-$))/$)*_:h<m.top+$&&(k=-Math.min(1,(m.top+$-h)/$)*_),k!==0&&(w.scrollTop+=k,Y(h,w.scrollTop)),F=requestAnimationFrame(O);};F=requestAnimationFrame(O),Ve({cursor:"row-resize",resizerEl:V,onMove:m=>{h=m.clientY,w&&Y(h,w.scrollTop);},onEnd:()=>{F!==null&&cancelAnimationFrame(F);let m=A;R.current&&(m=R.current.getBoundingClientRect().height),m=We(m,n,I),v(m),s&&s(m),c&&Pt(c,m);}});},[E,n,p,s,c]);return t?jsxs("div",{ref:R,className:`zeugma-resizable-container ${y||""}`.trim(),style:{height:`${E}px`,position:"relative",overflow:"hidden",boxSizing:"border-box"},children:[jsx("div",{style:{height:`calc(100% - ${l}px)`,overflow:"hidden"},children:e}),jsx("div",{className:`zeugma-resizable-handle ${D||""}`.trim(),style:{height:`${l}px`,cursor:"row-resize",position:"relative",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box",flexShrink:0},onPointerDown:b,role:"separator","aria-orientation":"horizontal","aria-valuenow":Math.round(E),"aria-valuemin":n,"aria-valuemax":o===1/0?void 0:o})]}):jsx("div",{className:`zeugma-resizable-container disabled ${y||""}`.trim(),style:{height:"100%",position:"relative",overflow:"hidden",boxSizing:"border-box"},children:jsx("div",{style:{height:"100%",overflow:"hidden"},children:e})})};function We(e,t,r){return Math.max(t,Math.min(r,e))}function Tt(e){if(typeof window>"u"||!e)return null;let t=e.parentElement;if(!t)return document.documentElement;let s=window.getComputedStyle(t).overflowY;return s==="auto"||s==="scroll"?t:Tt(t)}var _e=createContext(null);var xn={top:{position:"absolute",top:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:"25%",width:"50%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"25%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},Tn={top:{position:"absolute",top:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},bottom:{position:"absolute",bottom:0,left:0,right:0,height:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},left:{position:"absolute",top:0,bottom:0,left:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},right:{position:"absolute",top:0,bottom:0,right:0,width:"50%",zIndex:21,pointerEvents:"none",boxSizing:"border-box"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},Rt=({id:e,position:t,activeClassName:r})=>{let{setNodeRef:s,isOver:n}=useDroppable({id:e});return jsxs(Fragment,{children:[jsx("div",{ref:s,style:xn[t]}),n&&jsx("div",{className:r,style:Tn[t]})]})},Rn=({id:e,children:t,style:r,locked:s=false})=>{let{layout:n,activeId:o,classNames:i,fullscreenPaneId:a,onFullscreenChange:l,locked:y}=ee(),{removePane:D,updateTabMetadata:c,selectTab:T,removeTab:x}=$e(),v=useContext(ke);if(!v)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:R}=v,E=useMemo(()=>q(n,e),[n,e]),L=E?.id??e,p=E?.tabs??[e],b=E?.activeTabId??e,f=E?.tabsMetadata,z=f?.[e],A=E?.locked??false,I=s||A,V=y||I,w=y||I,K=o!==null&&o!==e&&(!p.includes(o)||p.length>1)&&!w,{attributes:h,listeners:F,setNodeRef:Y}=useDraggable({id:e,disabled:V}),O=o!==null&&p.includes(o),m=a===e,$=useCallback(()=>jsx("div",{id:`zeugma-tab-target-${b}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[b]);useEffect(()=>{let d=document.getElementById(`zeugma-tab-target-${b}`);return R(b,d),()=>{R(b,null);}},[b,R]);let _=useMemo(()=>({isDragging:O,isFullscreen:m,toggleFullscreen:()=>l?.(m?null:e),remove:()=>{m&&l?.(null),D(L);},metadata:z,updateMetadata:d=>{c(e,d);},locked:V,tabs:p,activeTabId:b,selectTab:d=>T(L,d),removeTab:d=>{m&&d===b&&l?.(null),x(d);},tabsMetadata:f,updateTabMetadata:(d,B)=>{c(d,B);},renderActiveTab:$}),[O,m,l,e,x,z,c,V,p,b,T,L,f,$]),k=useMemo(()=>V?{disabled:true}:{...F,...h},[F,h,V]),N=`${i.pane||""} ${I?i.paneLocked||"zeugma-pane-locked":""}`.trim();return jsx(_e.Provider,{value:k,children:jsxs("div",{ref:Y,className:N,style:{position:"relative",width:"100%",height:"100%",...r},children:[t(_),K&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(d=>jsx(Rt,{id:`drop-${d}-${e}`,position:d,activeClassName:i.dropPreview},d))}),o!==null&&o!==e&&w&&jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsx(Rt,{id:`drop-locked-${e}`,position:"full",activeClassName:i.lockedPreview||"zeugma-locked-preview"})})]})})};var En=({children:e,className:t,style:r})=>{let s=useContext(_e);if(!s)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:n,...o}=s;return jsx("div",{className:t,style:{cursor:n?"default":"grab",userSelect:n?"auto":"none",touchAction:n?"auto":"none",...r},...n?{}:o,children:e})};var Mn=({id:e,locked:t=false,children:r,className:s,style:n})=>{let{locked:o}=ee(),i=t||o,{attributes:a,listeners:l,setNodeRef:y,isDragging:D}=useDraggable({id:`tab-header-${e}`,disabled:i}),{setNodeRef:c,isOver:T}=useDroppable({id:`tab-drop-${e}`,disabled:i});return jsx("div",{ref:v=>{y(v),c(v);},className:s,style:{display:"inline-flex",cursor:i?"default":"grab",...n},...i?{}:l,...i?{}:a,children:r({isDragging:D,isOver:T})})};export{At as DEFAULT_DRAG_ACTIVATION_DISTANCE,Fn as DEFAULT_RESIZER_SIZE,Ht as DEFAULT_SNAP_THRESHOLD,En as DragHandle,Rn as Pane,ln as PaneTree,xt as ResizableContainer,Mn as Tab,jt as Zeugma,lt as addPane,se as computeLayout,Ve as createDragSession,q as findPane,ie as generateUniqueId,ct as mergeTab,ut as moveTab,be as removePane,de as removeTab,Ae as selectTab,ye as splitPane,He as updatePaneLock,ve as updateSplitPercentage,Ze as updateTabMetadata,Je as useResizer,Ft as useZeugma,Ot as useZeugmaContext};//# sourceMappingURL=index.js.map
7
7
  //# sourceMappingURL=index.js.map