react-zeugma 6.2.1 → 6.3.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/README.md CHANGED
@@ -105,10 +105,6 @@ The context provider that sets up the drag-and-drop state machine, monitors acti
105
105
  | `renderDragOverlay` | `(activeId: string, type: 'pane' \| 'tab') => ReactNode` | No | Renders a custom cursor-following drag preview overlay. |
106
106
  | `renderWidget` | `(tabId: string) => ReactNode` | No | Render function mapping tab IDs to React elements. Used to render tab widgets inside portals. |
107
107
 
108
- > [!IMPORTANT]
109
- > **State & Mount Preservation Rule:**
110
- > Always render stateful components (like text editors, terminals, or any stateful views) inside the `renderWidget` callback. The `renderPane` callback is strictly for layout frame/chrome rendering and must render `paneProps.renderActiveTab()` directly. Wrapping `renderActiveTab()` with stateful components or passing active tab IDs as props inside `renderPane` will cause those wrappers to destroy and recreate their hooks/state when tabs are switched or dragged.
111
-
112
108
  ### `useZeugma(options)`
113
109
 
114
110
  A custom state hook that initializes and manages the recursive layout tree and handles drag-and-drop actions.
@@ -537,326 +533,3 @@ export interface ComputedSplitter {
537
533
  parentHeight: number
538
534
  }
539
535
  ```
540
-
541
- ---
542
-
543
- ## SKILL.md
544
-
545
- Below is the comprehensive developer skill configuration for integrations, tree manipulation, and styling patterns within `react-zeugma`. Copy or download it for AI agents or reference.
546
-
547
- ````markdown
548
- ---
549
- name: react-zeugma
550
- description: Integrate, configure, style, and programmatically manipulate dashboard layouts using the react-zeugma package.
551
- ---
552
-
553
- # Skill: Using react-zeugma
554
-
555
- `react-zeugma` is a recursive drag-and-drop dashboard layout engine for React. It combines tree-based pane splitting (similar to `react-mosaic`) with a declarative, state-driven API (similar to `react-grid-layout`), built using `@dnd-kit/core`.
556
-
557
- ---
558
-
559
- ## 1. Data Model (Tree Nodes)
560
-
561
- The entire dashboard layout is represented as a serializable recursive tree structure.
562
-
563
- ### Types & Interface
564
-
565
- ```ts
566
- export type SplitDirection = 'row' | 'column'
567
-
568
- export interface SplitNode {
569
- type: 'split'
570
- direction: SplitDirection
571
- first: TreeNode
572
- second: TreeNode
573
- splitPercentage: number // 0 to 100
574
- }
575
-
576
- export interface PaneNode {
577
- type: 'pane'
578
- id: string
579
- tabs: string[]
580
- activeTabId: string
581
- locked?: boolean
582
- tabsMetadata?: Record<string, Record<string, unknown>>
583
- }
584
-
585
- export type TreeNode = SplitNode | PaneNode
586
-
587
- export interface TabDetails {
588
- id: string
589
- paneId: string
590
- isActive: boolean
591
- index: number
592
- metadata: Record<string, unknown> | undefined
593
- }
594
- ```
595
-
596
- - **`PaneNode` (Leaf):** Represents a single content pane. It must have a unique `paneId`.
597
- - **`SplitNode` (Branch):** Splits its area horizontally (`column`) or vertically (`row`) into two child `TreeNode` nodes (`first` and `second`), based on `splitPercentage`.
598
-
599
- ---
600
-
601
- ## 2. Core Components
602
-
603
- ### `<Zeugma>`
604
-
605
- The root context provider. It handles the drag-and-drop event loop and coordinates the layout state.
606
-
607
- #### Props
608
-
609
- - `...controllerProps: ZeugmaController` — The controller properties returned by the `useZeugma` hook (typically passed via `{...zeugma}`).
610
- - `renderPane: (paneId: string) => ReactNode` — Callback to render the contents of a pane given its ID.
611
- - `renderDragOverlay?: (activeId: string, type: 'pane' | 'tab') => ReactNode` — (Optional) Renders a custom cursor-following drag preview.
612
- - `classNames?: ZeugmaClassNames` — (Optional) CSS class overrides for styling various layout elements.
613
- - `renderWidget?: (tabId: string) => ReactNode` — (Optional) Render function mapping tab IDs to React elements. Used to render tab widgets inside portals.
614
-
615
- > [!IMPORTANT]
616
- > **State & Mount Preservation Rule:**
617
- > Stateful components must be returned by `renderWidget` to leverage the library's portal-based mount preservation. Do not wrap `paneProps.renderActiveTab()` with stateful components or pass active tab IDs as props inside `renderPane`, as this will cause those components and their hooks to unmount and remount when the pane's active tab changes.
618
-
619
- ### `useZeugma(options)`
620
-
621
- A custom hook to manage the dashboard layout state.
622
-
623
- #### Options
624
-
625
- - `initialLayout: TreeNode | null` — Initial layout tree structure.
626
- - `locked?: boolean` — Whether the layout is globally locked.
627
- - `dragActivationDistance?: number` — Minimum pointer drag distance (in pixels) required to activate dragging (defaults to `8`).
628
- - `snapThreshold?: number` — Threshold in pixels to snap layout resizers to adjacent edges (defaults to `8`).
629
- - `minSplitPercentage?: number` — Minimum resizing limit percentage (defaults to `5`).
630
- - `maxSplitPercentage?: number` — Maximum resizing limit percentage (defaults to `95`).
631
- - `enableDragToDismiss?: boolean` — Whether to enable drag-out-to-dismiss (defaults to `false`).
632
- - `dismissThreshold?: number` — Distance in pixels outside container bounds required to trigger dismissal (defaults to `60`).
633
- - `onRemove?: (paneId: string) => void` — Callback when a pane is removed.
634
- - `onDragStart?: (activeId: string) => void` — Callback when dragging starts.
635
- - `onDragEnd?: (activeId: string, overId: string | null, dropAction: any) => void` — Callback when dragging ends.
636
- - `onResizeStart?: (currentNode: SplitNode) => void` — Callback when resizing starts.
637
- - `onResize?: (currentNode: SplitNode, percentage: number) => void` — Callback during resizing.
638
- - `onResizeEnd?: (currentNode: SplitNode, percentage: number) => void` — Callback when resizing ends.
639
- - `onDismissIntentChange?: (paneId: string | null) => void` — Callback when drag-out intent changes.
640
-
641
- ### `useZeugmaContext()`
642
-
643
- A context consumer hook that retrieves the parent `<Zeugma>` controller state and actions.
644
-
645
- ```ts
646
- const { layout, layoutBeforeDrag, addPane, removeTab } = useZeugmaContext()
647
- ```
648
-
649
- ### `<PaneTree>`
650
-
651
- Recursively renders the split nodes and pane nodes. Must be placed inside `<Zeugma>`.
652
-
653
- #### Props
654
-
655
- - `tree?: TreeNode | null` — (Optional) Custom subtree to render. Defaults to the provider's root `layout`.
656
- - `resizerSize?: number` — (Optional) Thickness of the split resizer bars in pixels. Defaults to `4`.
657
-
658
- ### `<Pane>`
659
-
660
- Wraps the contents of an individual pane. It sets up draggable and droppable zones.
661
-
662
- #### Props
663
-
664
- - `id: string` — The unique ID corresponding to a `PaneNode`'s `paneId`.
665
- - `children: (props: PaneRenderProps) => ReactNode` — Render prop function.
666
-
667
- #### `PaneRenderProps`
668
-
669
- ```ts
670
- interface PaneRenderProps {
671
- isDragging: boolean
672
- isFullscreen: boolean
673
- toggleFullscreen: () => void
674
- remove: () => void
675
- metadata: Record<string, unknown> | undefined
676
- updateMetadata: (
677
- updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined,
678
- ) => void
679
- tabs: string[]
680
- activeTabId: string
681
- selectTab: (tabId: string) => void
682
- removeTab: (tabId: string) => void
683
- tabsMetadata: Record<string, Record<string, unknown>> | undefined
684
- updateTabMetadata: (
685
- tabId: string,
686
- updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined,
687
- ) => void
688
- renderActiveTab: () => ReactNode
689
- }
690
- ```
691
-
692
- ### `<Tabs>`
693
-
694
- Renders a list of tabs inside a pane, wrapping the internal drag-and-drop mechanics.
695
-
696
- #### Props
697
-
698
- - `tabs: string[]` — The list of tab IDs.
699
- - `activeTabId: string` — The currently active tab ID.
700
- - `locked?: boolean` — Whether dragging is disabled (defaults to `false`).
701
- - `tabsMetadata?: Record<string, Record<string, unknown>>` — Metadata for the tabs.
702
- - `selectTab: (id: string) => void` — Callback when a tab is selected.
703
- - `removeTab: (id: string) => void` — Callback when a tab is closed.
704
- - `classNames?: { container?: string; tab?: string | ((tabId: string) => string) }` — Custom class names.
705
- - `styles?: { container?: React.CSSProperties; tab?: React.CSSProperties | ((tabId: string) => React.CSSProperties) }` — Custom styles.
706
- - `renderTab: (props: { tabId: string; activeTabId: string; isDragging: boolean; isOver: boolean; metadata?: Record<string, unknown>; selectTab: (id: string) => void; removeTab: (id: string) => void; }) => React.ReactNode` — Render prop function.
707
-
708
- ### `<DragHandle>`
709
-
710
- Defines the interactive drag region inside a `<Pane>`. **Must be placed inside a `<Pane>` component.**
711
-
712
- #### Props
713
-
714
- - `children: React.ReactNode` — Element(s) that function as the drag handle (e.g., pane header).
715
- - `className?: string`
716
- - `style?: React.CSSProperties`
717
-
718
- ## 3. Programmatic State Utilities
719
-
720
- Import these helpers from `react-zeugma/utils` to manipulate or query the tree layout programmatically in your state handlers:
721
-
722
- - **`removePane(tree: TreeNode | null, idToRemove: string): TreeNode | null`**
723
- Removes a pane from the tree and collapses the leftover sibling split node.
724
- - **`splitPane(tree: TreeNode | null, targetId: string, direction: SplitDirection, splitType: 'left' | 'right' | 'top' | 'bottom', paneToAdd: string): TreeNode | null`**
725
- Splits a specific target pane by nesting it under a new `SplitNode` along with a new pane.
726
- - **`updateTabMetadata(tree: TreeNode | null, tabId: string, updater: (current: Record<string, unknown> | undefined) => Record<string, unknown> | undefined): TreeNode | null`**
727
- Updates the metadata of a specific tab.
728
- - **`findPaneById(tree: TreeNode | null, paneId: string): PaneNode | null`**
729
- Recursively searches the layout tree and returns the target `PaneNode` if found, or `null` otherwise.
730
- - **`findPaneContainingTab(tree: TreeNode | null, tabId: string): PaneNode | null`**
731
- Recursively searches the layout tree and returns the `PaneNode` containing the specified `tabId`.
732
- - **`findTabById(tree: TreeNode | null, tabId: string): TabDetails | null`**
733
- Searches the layout tree for the given `tabId` and returns computed details (parent `paneId`, `isActive`, `index`, and custom `metadata`).
734
- - **`calculateTabDropIndex(tabs: string[], activeType: string | null, overTabId: string | null, overTabPosition: 'before' | 'after' | null): number`**
735
- Calculates the target insertion index for a dragged tab within a list of tabs. Returns `-1` if the drop target is not in the list.
736
-
737
- ---
738
-
739
- ## 4. Basic Integration Recipe
740
-
741
- ```tsx
742
- import { useZeugma, Zeugma, PaneTree, Pane, DragHandle, TreeNode } from 'react-zeugma'
743
-
744
- const initialLayout: TreeNode = {
745
- type: 'split',
746
- direction: 'row',
747
- splitPercentage: 50,
748
- first: { type: 'pane', id: 'sidebar', tabs: ['sidebar'], activeTabId: 'sidebar' },
749
- second: { type: 'pane', id: 'main', tabs: ['main'], activeTabId: 'main' },
750
- }
751
-
752
- function CustomPane({ id }: { id: string }) {
753
- return (
754
- <Pane id={id}>
755
- {({ isDragging, isFullscreen, toggleFullscreen, remove }) => (
756
- <div style={{ height: '100%', border: '1px solid #ccc', opacity: isDragging ? 0.5 : 1 }}>
757
- <div style={{ display: 'flex', background: '#eee', padding: 8 }}>
758
- <DragHandle style={{ flex: 1 }}>
759
- <strong>Header: {id}</strong>
760
- </DragHandle>
761
- <button onClick={toggleFullscreen}>
762
- {isFullscreen ? 'Exit Fullscreen' : 'Fullscreen'}
763
- </button>
764
- <button onClick={remove}>Close</button>
765
- </div>
766
- <div style={{ padding: 16 }}>Content for {id}</div>
767
- </div>
768
- )}
769
- </Pane>
770
- )
771
- }
772
-
773
- export default function App() {
774
- const zeugma = useZeugma({
775
- initialLayout,
776
- })
777
-
778
- return (
779
- <Zeugma {...zeugma} renderPane={(id) => <CustomPane id={id} />}>
780
- <div style={{ width: '100vw', height: '100vh' }}>
781
- <PaneTree />
782
- </div>
783
- </Zeugma>
784
- )
785
- }
786
- ```
787
-
788
- ---
789
-
790
- ## 5. Styling Customization
791
-
792
- `react-zeugma` is style-agnostic and relies on class name configuration for visual states. Define classes in your styling framework and pass them via the `classNames` prop on `<Zeugma>`:
793
-
794
- > [!IMPORTANT]
795
- > Starting from version `4.1.2`, `react-zeugma` is 100% headless and does not apply any internal default CSS fallback classes (such as `zeugma-resizer`, `zeugma-locked-preview`, etc.). All layout visual states must be styled by providing custom class names via the `classNames` configuration object.
796
-
797
- ```ts
798
- interface ZeugmaClassNames {
799
- dashboard?: string // Applied to the root dashboard container
800
- dashboardDismissActive?: string // Applied to root container when dismiss intent is active
801
- dashboardLocked?: string // Applied to root container when dashboard is globally locked
802
- pane?: string // Applied to the outer wrapper of <Pane>
803
- paneLocked?: string // Applied to the pane container when locked
804
- dropPreview?: string // Applied to the preview box when hovering over edge dropzones
805
- dragOverlay?: string // Applied to the cursor-following drag preview portal
806
- resizer?: string // Applied to the drag-to-resize split bar
807
- dismissPreview?: string // Applied to the background dismiss zone indicator during a drag-out dismiss gesture
808
- lockedPreview?: string // Applied to drop zone indicator when hovering over a locked pane
809
- tabDropPreview?: string // Applied to the drop placeholder line element during tab drags
810
- tabSeparator?: string // Applied to the separator line between non-active adjacent tabs
811
- }
812
- ```
813
-
814
- ### Tab Drop Preview Customization
815
-
816
- When dragging a tab, the library automatically calculates the target insertion index and renders a placeholder indicator line at that position within the tabs list (between adjacent tabs or at the list boundaries).
817
-
818
- To style this indicator line, configure a custom CSS class name via `classNames.tabDropPreview`.
819
-
820
- Use this single class name in your CSS to customize the color and size (width) of the placeholder indicator line:
821
-
822
- ```css
823
- /* Custom tab drop placeholder styling */
824
- .my-tab-preview {
825
- background-color: #6366f1 !important; /* change color */
826
- width: 3px !important; /* change width/size */
827
- }
828
- ```
829
-
830
- ### CSS Example:
831
-
832
- ```css
833
- /* Custom resizer style */
834
- .my-resizer {
835
- background-color: #e2e8f0;
836
- transition: background-color 0.2s;
837
- }
838
- .my-resizer:hover {
839
- background-color: #3b82f6;
840
- }
841
-
842
- /* Edge drop previews */
843
- ```
844
-
845
- ---
846
-
847
- ## The Story of Zeugma
848
-
849
- _Zeugma_ is an ancient city of Commagene, located in modern-day **Gaziantep, Turkey**. Positioned along a critical crossing point of the Euphrates river, Zeugma became a central hub of trade and cultural exchanges.
850
-
851
- During modern excavation efforts, archeologists discovered some of the most breathtaking Greco-Roman mosaic panels in history, now housed inside the **Zeugma Mosaic Museum** in Gaziantep. The famous _"Gypsy Girl" (Çingene Kızı)_ mosaic, with her hauntingly detailed eyes, has become a global icon of the city.
852
-
853
- > _"We chose the name Zeugma because of this ancient craftsmanship. Mosaics are assembled from hundreds of tiny, individual tesserae tiles to form a magnificent, cohesive picture. In the same spirit, react-zeugma lets you build beautiful, customized application workspaces from simple, individual components. Many tiles, one masterpiece."_
854
-
855
- ---
856
-
857
- ## Links
858
-
859
- - [GitHub Repository](https://github.com/react-zeugma/react-zeugma)
860
- - [npm Package](https://www.npmjs.com/package/react-zeugma)
861
- - [Contributing Guide](https://github.com/react-zeugma/react-zeugma/blob/master/CONTRIBUTING.md)
862
- ````
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict';var _t=require('react'),core=require('@dnd-kit/core'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var _t__default=/*#__PURE__*/_interopDefault(_t);function tt(e){let t=_t.useRef(null);return _t.useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},s=o=>{let r=o.touches[0]||o.changedTouches[0];r&&(t.current={x:r.clientX,y:r.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",s,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",s);}},[e]),t}function nt(e){_t.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function ot(){let[e,t]=_t.useState({}),n=_t.useRef(true);_t.useEffect(()=>(n.current=true,()=>{n.current=false;}),[]);let s=_t.useCallback((o,r)=>{n.current&&t(a=>a[o]===r?a:{...a,[o]:r});},[]);return {portalTargets:e,registerPortalTarget:s}}var Lt=8,It=8,On=4;function de(){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 n=be(e.first,t),s=be(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function fe(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let o=e.tabs.filter(l=>l!==t);if(o.length===0)return null;let r=e.activeTabId;e.activeTabId===t&&(r=o[0]);let a={...e.tabsMetadata};return delete a[t],{...e,tabs:o,activeTabId:r,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}let n=fe(e.first,t),s=fe(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function Re(e,t,n,s,o){if(e===null)return typeof o=="string"?{type:"pane",id:de(),tabs:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let r=typeof o=="string"?{type:"pane",id:de(),tabs:[o],activeTabId:o}:o,a=s==="left"||s==="top";return {type:"split",direction:n,first:a?r:e,second:a?e:r,splitPercentage:50}}return e}return {...e,first:Re(e.first,t,n,s,o)||e.first,second:Re(e.second,t,n,s,o)||e.second}}function rt(e,t,n){if(e===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0};function s(o,r){return o.type==="pane"?{type:"split",direction:r==="row"?"column":"row",splitPercentage:50,first:o,second:{type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:n?{[t]:n}:void 0}}:{...o,second:s(o.second,o.direction)}}return s(e,null)}function xe(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:xe(e.first,t,n)||e.first,second:xe(e.second,t,n)||e.second}:e}function j(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:j(e.first,t)??j(e.second,t)}function V(e,t){return e===null?null:e.type==="pane"?e.tabs.includes(t)?e:null:V(e.first,t)??V(e.second,t)}function st(e,t){let n=V(e,t);if(!n)return null;let s=n.tabs.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:s,metadata:n.tabsMetadata?.[t]}}function Ee(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let s=e.tabsMetadata||{},o=s[t],r=n(o),a={...s};return r===void 0?delete a[t]:a[t]=r,{...e,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}return {...e,first:Ee(e.first,t,n)??e.first,second:Ee(e.second,t,n)??e.second}}function Le(e,t,n,s){if(e===null)return null;if(e.type==="pane"){if(e.id===t){let o=[...e.tabs];o.includes(n)||o.push(n);let r=e.tabsMetadata;return s&&(r={...e.tabsMetadata,[n]:s}),{...e,tabs:o,activeTabId:n,tabsMetadata:r}}return e}return {...e,first:Le(e.first,t,n,s)||e.first,second:Le(e.second,t,n,s)||e.second}}function Ie(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:s,...o}=e;return o}return {...e,locked:n}}return e}return {...e,first:Ie(e.first,t,n)??e.first,second:Ie(e.second,t,n)??e.second}}function ye(e,t,n){return e===null?null:e.type==="pane"?e.id===t?e.activeTabId===n?e:{...e,activeTabId:n}:e:{...e,first:ye(e.first,t,n)??e.first,second:ye(e.second,t,n)??e.second}}function it(e,t,n){if(e===null)return null;let o=V(e,t)?.tabsMetadata?.[t],r=fe(e,t);if(r===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(l){if(l.type==="pane"){if(l.id===n){let d=[...l.tabs];d.includes(t)||d.push(t);let p={...l.tabsMetadata};return o&&(p[t]=o),{...l,tabs:d,activeTabId:t,tabsMetadata:Object.keys(p).length>0?p:void 0}}return l}return {...l,first:a(l.first),second:a(l.second)}}return a(r)}function Me(e,t,n,s="before"){if(e===null)return null;let r=V(e,t)?.tabsMetadata?.[t],a=fe(e,t);if(a===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:r?{[t]:r}:void 0};function l(d){if(d.type==="pane"){if(d.tabs.includes(n)){let g=[...d.tabs].filter(w=>w!==t),x=g.indexOf(n);x<0&&(x=0),s==="after"&&(x+=1),g.splice(x,0,t);let R={...d.tabsMetadata};return r&&(R[t]=r),{...d,tabs:g,activeTabId:t,tabsMetadata:Object.keys(R).length>0?R:void 0}}return d}return {...d,first:l(d.first),second:l(d.second)}}return l(a)}function ge(e,t=0,n=0,s=100,o=100,r="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:s,height:o,node:e}],splitters:[]};let{direction:a,splitPercentage:l,first:d,second:p}=e,x={id:`splitter-${r}-${a}`,currentNode:e,direction:a,left:a==="row"?t+s*(l/100):t,top:a==="column"?n+o*(l/100):n,width:a==="row"?0:s,height:a==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:s,parentHeight:o},R={panes:[],splitters:[]},w={panes:[],splitters:[]};if(a==="row"){let P=s*(l/100);R=ge(d,t,n,P,o,`${r}-L`),w=ge(p,t+P,n,s-P,o,`${r}-R`);}else {let P=o*(l/100);R=ge(d,t,n,s,P,`${r}-T`),w=ge(p,t,n+P,s,o-P,`${r}-B`);}return {panes:[...R.panes,...w.panes],splitters:[x,...R.splitters,...w.splitters]}}function at(e,t,n,s){if(!(t==="tab"&&n&&e.includes(n))||!s)return -1;let a=e.indexOf(n);return s==="before"?a:a+1}function Ne(e){try{return JSON.stringify(e)}catch{return ""}}function Mt(e){let{initialLayout:t,layout:n,onChange:s,fullscreenPaneId:o,onFullscreenChange:r,locked:a=false,dragActivationDistance:l=8,snapThreshold:d=8,minSplitPercentage:p=5,maxSplitPercentage:g=95,enableDragToDismiss:x=false,dismissThreshold:R=60,onRemove:w,onDragStart:P,onDragEnd:k,onResizeStart:I,onResize:M,onResizeEnd:u,onDismissIntentChange:T}=e,[N,E]=_t.useState(()=>n!==void 0?n:t??null),[A,J]=_t.useState(()=>Ne(n!==void 0?n:null)),[q,W]=_t.useState(o||null),[ee,te]=_t.useState(a),[ie,ne]=_t.useState(null),[le,C]=_t.useState(null),[O,$]=_t.useState(null),[z,y]=_t.useState(null),i=_t.useRef(null),h=_t.useCallback(c=>{i.current=c;},[]),v=_t.useRef(N);v.current=N;let b=_t.useRef(s);b.current=s;let U=_t.useRef(r);U.current=r;let B=_t.useCallback(c=>{W(c),U.current?.(c);},[]);if(_t.useEffect(()=>{te(a);},[a]),_t.useEffect(()=>{o!==void 0&&W(o);},[o]),n!==void 0){let c=Ne(n);c!==A&&(J(c),E(n));}let f=_t.useCallback(c=>(...S)=>{let H=v.current,F=c(H,...S);Ne(H)!==Ne(F)&&(v.current=F,E(F),b.current?.(F));},[]),G=_t.useCallback(f((c,S)=>typeof S=="function"?S(c):S),[f]),m=_t.useCallback(f((c,S)=>be(c,S)),[f]),D=_t.useCallback(f((c,S,H)=>rt(c,S,H)),[f]),Z=_t.useCallback(f((c,S,H,F)=>{let pe=j(c,S)??V(c,S);if(!pe)return c;let we=V(c,H),We=we&&we.id===pe.id?c:fe(c,H)??c;return Le(We,pe.id,H,F)}),[f]),oe=_t.useCallback(f((c,S,H,F,pe)=>{let we=j(c,S)??V(c,S);if(!we)return c;let je=j(c,pe)??V(c,pe)??{type:"pane",id:pe,tabs:[pe],activeTabId:pe},We=be(c,pe);return Re(We,we.id,H,F,je)}),[f]),K=_t.useCallback(f((c,S,H)=>xe(c,S,H)),[f]),Q=_t.useCallback(f((c,S,H)=>Ee(c,S,H)),[f]),Se=_t.useCallback(f((c,S,H)=>{let F=j(c,S)??V(c,S);return F?Ie(c,F.id,H):c}),[f]),ce=_t.useCallback(f((c,S,H)=>{let F=j(c,S)??V(c,S);return F?ye(c,F.id,H):c}),[f]),ue=_t.useCallback(f((c,S,H)=>{let F=j(c,H)??V(c,H);return F?it(c,S,F.id):c}),[f]),L=_t.useCallback(f((c,S,H,F)=>Me(c,S,H,F)),[f]),re=_t.useCallback(f((c,S)=>fe(c,S)),[f]),X=_t.useCallback(c=>j(v.current,c),[]),me=_t.useCallback(c=>V(v.current,c),[]),se=_t.useCallback(c=>st(v.current,c),[]);return {layout:N,setLayout:G,layoutBeforeDrag:ie,setLayoutBeforeDrag:ne,fullscreenPaneId:q,setFullscreenPaneId:B,locked:ee,setLocked:te,activeId:le,setActiveId:C,activeType:O,setActiveType:$,dismissIntentId:z,setDismissIntentId:y,containerRef:i,setContainerRef:h,dragActivationDistance:l,snapThreshold:d,minSplitPercentage:p,maxSplitPercentage:g,enableDragToDismiss:x,dismissThreshold:R,onRemove:w,onDragStart:P,onDragEnd:k,onResizeStart:I,onResize:M,onResizeEnd:u,onDismissIntentChange:T,removePane:m,addPane:D,addTab:Z,splitPane:oe,updateSplitPercentage:K,updateTabMetadata:Q,updatePaneLock:Se,selectTab:ce,mergeTab:ue,moveTab:L,removeTab:re,findPaneById:X,findPaneContainingTab:me,findTabById:se}}function ct({cursor:e,resizerEl:t,onMove:n,onEnd:s}){document.body.classList.add("zeugma-resizing");let o=document.createElement("style");o.id="zeugma-global-cursor-style",o.textContent=`
1
+ 'use strict';var qt=require('react'),core=require('@dnd-kit/core'),jsxRuntime=require('react/jsx-runtime'),reactDom=require('react-dom');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var qt__default=/*#__PURE__*/_interopDefault(qt);function nt(e){let t=qt.useRef(null);return qt.useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},s=o=>{let r=o.touches[0]||o.changedTouches[0];r&&(t.current={x:r.clientX,y:r.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",s,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",s);}},[e]),t}function ot(e){qt.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function rt(){let[e,t]=qt.useState({}),n=qt.useRef(true);qt.useEffect(()=>(n.current=true,()=>{n.current=false;}),[]);let s=qt.useCallback((o,r)=>{n.current&&t(i=>i[o]===r?i:{...i,[o]:r});},[]);return {portalTargets:e,registerPortalTarget:s}}var kt=8,$t=8,Qn=4;function de(){return "pane-"+Math.random().toString(36).substring(2,11)}function be(e,t){if(e===null)return null;if(e.type==="pane"||e.type==="widget")return e.id===t?null:e;let n=be(e.first,t),s=be(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function pe(e,t){if(e===null)return null;if(e.type==="widget")return e;if(e.type==="pane"){if(e.tabs.includes(t)){let o=e.tabs.filter(a=>a!==t);if(o.length===0)return null;let r=e.activeTabId;e.activeTabId===t&&(r=o[0]);let i={...e.tabsMetadata};return delete i[t],{...e,tabs:o,activeTabId:r,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}let n=pe(e.first,t),s=pe(e.second,t);return n===null?s:s===null?n:{...e,first:n,second:s}}function Pe(e,t,n,s,o){if(e===null)return typeof o=="string"?{type:"pane",id:de(),tabs:[o],activeTabId:o}:o;if(e.type==="pane"||e.type==="widget"){if(e.id===t){let r=typeof o=="string"?{type:"pane",id:de(),tabs:[o],activeTabId:o}:o,i=s==="left"||s==="top";return {type:"split",direction:n,first:i?r:e,second:i?e:r,splitPercentage:50}}return e}return {...e,first:Pe(e.first,t,n,s,o)||e.first,second:Pe(e.second,t,n,s,o)||e.second}}function st(e,t){if(e===null)return t;function n(s,o){return s.type==="pane"||s.type==="widget"?{type:"split",direction:o==="row"?"column":"row",splitPercentage:50,first:s,second:t}:{...s,second:n(s.second,s.direction)}}return n(e,null)}function it(e,t,n){return st(e,{type:"widget",id:t,metadata:n})}function at(e,t,n,s){if(e===null)return {type:"pane",id:de(),tabs:[n],activeTabId:n,tabsMetadata:s?{[n]:s}:void 0};let o=t?ne(e,t):null;if(o&&o.type==="pane"){let a=function(c){if(c.type==="pane"&&c.id===t){let p=[...c.tabs];p.includes(n)||p.push(n);let f=c.tabsMetadata;return s&&(f={...c.tabsMetadata,[n]:s}),{...c,tabs:p,activeTabId:n,tabsMetadata:f}}return c.type==="split"?{...c,first:a(c.first),second:a(c.second)}:c};return a(e)}let r={type:"pane",id:de(),tabs:[n],activeTabId:n,tabsMetadata:s?{[n]:s}:void 0};return st(e,r)}function ve(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:ve(e.first,t,n)||e.first,second:ve(e.second,t,n)||e.second}:e}function ne(e,t){return e===null?null:e.type==="pane"||e.type==="widget"?e.id===t?e:null:e.type==="split"?ne(e.first,t)??ne(e.second,t):null}function ee(e,t){return e===null?null:e.type==="pane"?e.tabs.includes(t)?e:null:e.type==="split"?ee(e.first,t)??ee(e.second,t):null}function lt(e,t){let n=ee(e,t);if(!n)return null;let s=n.tabs.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:s,metadata:n.tabsMetadata?.[t]}}function ke(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabs.includes(t)){let s=e.tabsMetadata||{},o=s[t],r=n(o),i={...s};return r===void 0?delete i[t]:i[t]=r,{...e,tabsMetadata:Object.keys(i).length>0?i:void 0}}return e}return e.type==="widget"?e.id===t?{...e,metadata:n(e.metadata)}:e:e.type==="split"?{...e,first:ke(e.first,t,n)??e.first,second:ke(e.second,t,n)??e.second}:e}function $e(e,t,n){if(e===null)return null;if(e.type==="pane"||e.type==="widget"){if(e.id===t){if(n===false){let{locked:s,...o}=e;return o}return {...e,locked:n}}return e}return e.type==="split"?{...e,first:$e(e.first,t,n)??e.first,second:$e(e.second,t,n)??e.second}:e}function ye(e,t,n){return e===null?null:e.type==="pane"?e.id===t?e.activeTabId===n?e:{...e,activeTabId:n}:e:e.type==="split"?{...e,first:ye(e.first,t,n)??e.first,second:ye(e.second,t,n)??e.second}:e}function ct(e,t,n){if(e===null)return null;let o=ee(e,t)?.tabsMetadata?.[t],r=pe(e,t);if(r===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function i(a){if(a.type==="pane"){if(a.id===n){let c=[...a.tabs];c.includes(t)||c.push(t);let p={...a.tabsMetadata};return o&&(p[t]=o),{...a,tabs:c,activeTabId:t,tabsMetadata:Object.keys(p).length>0?p:void 0}}return a}return a.type==="widget"?a:a.type==="split"?{...a,first:i(a.first),second:i(a.second)}:a}return i(r)}function ze(e,t,n,s="before"){if(e===null)return null;let r=ee(e,t)?.tabsMetadata?.[t],i=pe(e,t);if(i===null)return {type:"pane",id:de(),tabs:[t],activeTabId:t,tabsMetadata:r?{[t]:r}:void 0};function a(c){if(c.type==="pane"){if(c.tabs.includes(n)){let f=[...c.tabs].filter(w=>w!==t),h=f.indexOf(n);h<0&&(h=0),s==="after"&&(h+=1),f.splice(h,0,t);let R={...c.tabsMetadata};return r&&(R[t]=r),{...c,tabs:f,activeTabId:t,tabsMetadata:Object.keys(R).length>0?R:void 0}}return c}return c.type==="widget"?c:c.type==="split"?{...c,first:a(c.first),second:a(c.second)}:c}return a(i)}function fe(e,t=0,n=0,s=100,o=100,r="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane"||e.type==="widget")return {panes:[{paneId:e.id,left:t,top:n,width:s,height:o,node:e}],splitters:[]};let{direction:i,splitPercentage:a,first:c,second:p}=e,h={id:`splitter-${r}-${i}`,currentNode:e,direction:i,left:i==="row"?t+s*(a/100):t,top:i==="column"?n+o*(a/100):n,width:i==="row"?0:s,height:i==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:s,parentHeight:o},R={panes:[],splitters:[]},w={panes:[],splitters:[]};if(i==="row"){let x=s*(a/100);R=fe(c,t,n,x,o,`${r}-L`),w=fe(p,t+x,n,s-x,o,`${r}-R`);}else {let x=o*(a/100);R=fe(c,t,n,s,x,`${r}-T`),w=fe(p,t,n+x,s,o-x,`${r}-B`);}return {panes:[...R.panes,...w.panes],splitters:[h,...R.splitters,...w.splitters]}}function ut(e,t,n,s){if(!(t==="tab"&&n&&e.includes(n))||!s)return -1;let i=e.indexOf(n);return s==="before"?i:i+1}function Ze(e){try{return JSON.stringify(e)}catch{return ""}}function zt(e){let{initialLayout:t,layout:n,onChange:s,fullscreenPaneId:o,onFullscreenChange:r,locked:i=false,dragActivationDistance:a=8,snapThreshold:c=8,minSplitPercentage:p=5,maxSplitPercentage:f=95,enableDragToDismiss:h=false,dismissThreshold:R=60,onRemove:w,onDragStart:x,onDragEnd:E,onResizeStart:M,onResize:N,onResizeEnd:u,onDismissIntentChange:T}=e,[L,C]=qt.useState(()=>n!==void 0?n:t??null),[z,_]=qt.useState(()=>Ze(n!==void 0?n:null)),[U,F]=qt.useState(o||null),[q,G]=qt.useState(i),[oe,K]=qt.useState(null),[le,g]=qt.useState(null),[Z,A]=qt.useState(null),[H,D]=qt.useState(null),l=qt.useRef(null),P=qt.useCallback(d=>{l.current=d;},[]),y=qt.useRef(L);y.current=L;let v=qt.useRef(s);v.current=s;let X=qt.useRef(r);X.current=r;let O=qt.useCallback(d=>{F(d),X.current?.(d);},[]);if(qt.useEffect(()=>{G(i);},[i]),qt.useEffect(()=>{o!==void 0&&F(o);},[o]),n!==void 0){let d=Ze(n);d!==z&&(_(d),C(n));}let m=qt.useCallback(d=>(...I)=>{let V=y.current,Y=d(V,...I);Ze(V)!==Ze(Y)&&(y.current=Y,C(Y),v.current?.(Y));},[]),B=qt.useCallback(m((d,I)=>typeof I=="function"?I(d):I),[m]),Q=B,b=qt.useCallback(d=>{F(null),X.current?.(null),K(null),g(null),A(null),D(null),B(d);},[B]),S=qt.useCallback(m((d,I)=>be(d,I)),[m]),$=qt.useCallback(m((d,I,V)=>it(d,I,V)),[m]),se=qt.useCallback(m((d,I,V,Y)=>{let me=pe(d,I)??d;return at(me,V,I,Y)}),[m]),j=qt.useCallback(m((d,I,V,Y,me)=>{let et=ne(d,I)??ee(d,I);if(!et)return d;let Et=ne(d,me)??ee(d,me)??{type:"pane",id:me,tabs:[me],activeTabId:me},It=be(d,me);return Pe(It,et.id,V,Y,Et)}),[m]),te=qt.useCallback(m((d,I,V)=>ve(d,I,V)),[m]),Ie=qt.useCallback(m((d,I,V)=>ke(d,I,V)),[m]),ce=qt.useCallback(m((d,I,V)=>{let Y=ne(d,I)??ee(d,I);return Y?$e(d,Y.id,V):d}),[m]),ue=qt.useCallback(m((d,I,V)=>{let Y=ne(d,I)??ee(d,I);return Y?ye(d,Y.id,V):d}),[m]),k=qt.useCallback(m((d,I,V)=>{let Y=ne(d,V)??ee(d,V);return Y?ct(d,I,Y.id):d}),[m]),ie=qt.useCallback(m((d,I,V,Y)=>ze(d,I,V,Y)),[m]),W=qt.useCallback(m((d,I)=>pe(d,I)),[m]),ge=qt.useCallback(d=>ne(y.current,d),[]),ae=qt.useCallback(d=>ee(y.current,d),[]),Me=qt.useCallback(d=>lt(y.current,d),[]);return {layout:L,setLayout:b,_internalSetLayout:Q,layoutBeforeDrag:oe,setLayoutBeforeDrag:K,fullscreenPaneId:U,setFullscreenPaneId:O,locked:q,setLocked:G,activeId:le,setActiveId:g,activeType:Z,setActiveType:A,dismissIntentId:H,setDismissIntentId:D,containerRef:l,setContainerRef:P,dragActivationDistance:a,snapThreshold:c,minSplitPercentage:p,maxSplitPercentage:f,enableDragToDismiss:h,dismissThreshold:R,onRemove:w,onDragStart:x,onDragEnd:E,onResizeStart:M,onResize:N,onResizeEnd:u,onDismissIntentChange:T,removePane:S,addWidget:$,addTab:se,splitPane:j,updateSplitPercentage:te,updateMetadata:Ie,updatePaneLock:ce,selectTab:ue,mergeTab:k,moveTab:ie,removeTab:W,findPaneById:ge,findPaneContainingTab:ae,findTabById:Me}}function pt({cursor:e,resizerEl:t,onMove:n,onEnd:s}){document.body.classList.add("zeugma-resizing");let o=document.createElement("style");o.id="zeugma-global-cursor-style",o.textContent=`
2
2
  * {
3
3
  cursor: ${e} !important;
4
4
  user-select: none !important;
5
5
  }
6
- `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let r=l=>{n(l);},a=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let l=document.getElementById("zeugma-global-cursor-style");l&&l.remove(),document.removeEventListener("pointermove",r),document.removeEventListener("pointerup",a),s();};document.addEventListener("pointermove",r),document.addEventListener("pointerup",a);}var Xe=_t.createContext(void 0),Ye=_t.createContext(void 0),$e=_t.createContext(void 0),Je=_t.createContext(void 0),ae=()=>{let e=_t.useContext(Xe);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},ze=()=>{let e=_t.useContext(Ye);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Ae=()=>{let e=_t.useContext(Je);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};var Zt=()=>{let e=ae(),t=ze();return {...e,...t}};var He=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Oe=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};function Be(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}function dt(e){let{layout:t,setLayout:n,layoutBeforeDrag:s,setLayoutBeforeDrag:o,activeId:r,setActiveId:a,setActiveType:l,dismissIntentId:d,setDismissIntentId:p,setOverTabId:g,setOverTabPosition:x,containerRef:R,dragActivationDistance:w,enableDragToDismiss:P,dismissThreshold:k,onRemove:I,onDragStart:M,onDragEnd:u,onDismissIntentChange:T,removeTab:N}=e,E=_t.useRef(null),A=tt(r),[J,q]=_t.useState(false);nt(J);let W=core.useSensors(core.useSensor(He,{activationConstraint:{distance:w}}),core.useSensor(Oe,{activationConstraint:{delay:250,tolerance:5}})),ee=_t.useCallback(C=>{let $=C.active.id.toString().startsWith("tab-header-"),z=core.pointerWithin(C),y=$?z:z.filter(i=>!i.id.toString().startsWith("tab-drop-"));if(y.length>0)return [...y].sort((h,v)=>{let b=h.id.toString(),U=v.id.toString();if($){let _=b.startsWith("tab-drop-"),G=U.startsWith("tab-drop-");if(_&&!G)return -1;if(!_&&G)return 1}let B=b.startsWith("drop-root-"),f=U.startsWith("drop-root-");return B&&!f?-1:!B&&f?1:0});if($){let i=C.droppableContainers.filter(h=>h.id.toString().startsWith("tab-drop-"));return core.closestCenter({...C,droppableContainers:i})}return []},[]);return {sensors:W,collisionDetection:ee,onDragStart:C=>{let O=C.active.id.toString(),$=O.startsWith("tab-header-"),z=$?O.substring(11):O;a(z),l($?"tab":"pane"),g(null),x(null);let y=C.activatorEvent;A.current=Be(y),P&&R.current?E.current=R.current.getBoundingClientRect():E.current=null;let i=t;if($){let h=V(t,z);h&&(i=ye(t,h.id,z)||t);}o(i),$&&i!==t&&n(i),M&&M(z);},onDragMove:C=>{let{over:O}=C,$=O?.id.toString()||"",z=$.startsWith("drop-locked-");q(m=>m===z?m:z);let y=C.active.id.toString(),i=y.startsWith("tab-header-"),h=i?y.substring(11):y,v=$.match(/^tab-drop-(.+)$/);if(v&&O&&i){let[,m]=v;if(h!==m){let D="before",Z=O.rect,oe=C.activatorEvent,K=null;if(A.current)K=A.current.x;else {let Q=Be(oe);Q&&(K=Q.x+C.delta.x);}if(K!==null){let Q=Z.left+Z.width/2;K>Q&&(D="after");}g(Q=>Q===m?Q:m),x(Q=>Q===D?Q:D);}else g(D=>D===null?D:null),x(D=>D===null?D:null);}else g(m=>m===null?m:null),x(m=>m===null?m:null);if(!P)return;let b=E.current;if(!b){d!==null&&(p(null),T?.(null));return}let U=C.activatorEvent,B=null,f=null;if(A.current)B=A.current.x,f=A.current.y;else {let m=Be(U);m&&(B=m.x+C.delta.x,f=m.y+C.delta.y);}let _=0;if(B!==null&&f!==null){let m=0,D=0;B<b.left?m=b.left-B:B>b.right&&(m=B-b.right),f<b.top?D=b.top-f:f>b.bottom&&(D=f-b.bottom),_=Math.sqrt(m*m+D*D);}else {let m=C.active.rect.current.translated;if(m){let D=m.left+m.width/2,Z=m.top+m.height/2,oe=0,K=0;D<b.left?oe=b.left-D:D>b.right&&(oe=D-b.right),Z<b.top?K=b.top-Z:Z>b.bottom&&(K=Z-b.bottom),_=Math.sqrt(oe*oe+K*K);}}_>k?d!==h&&(p(h),T?.(h)):d!==null&&(p(null),T?.(null));},onDragEnd:C=>{a(null),l(null),q(false),g(null),x(null);let{active:O,over:$}=C,z=O.id.toString(),y=z.startsWith("tab-header-"),i=y?z.substring(11):z,h=P&&d===i;p(null),T?.(null),E.current=null;let v=s||t;if(o(null),h){I?I(i):N(i),u&&u(i,null,null);return}if(!$){n(v),u&&u(i,null,null);return}let b=$.id.toString();if(b.startsWith("drop-locked-")){n(v),u&&u(i,null,null);return}let U=b.match(/^tab-drop-(.+)$/);if(U){if(!y){n(v),u&&u(i,null,null);return}let[,ce]=U;if(i!==ce){let ue="before",L=$.rect,re=C.activatorEvent,X=null;if(A.current)X=A.current.x;else {let se=Be(re);se&&(X=se.x+C.delta.x);}if(X!==null){let se=L.left+L.width/2;X>se&&(ue="after");}let me=Me(v,i,ce,ue);n(me),u&&u(i,ce,{type:"move",position:"center"});}else n(v),u&&u(i,null,null);return}let B=b.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(B){let[,ce,ue]=B,L=ue;L==="start"&&(L="left"),L==="end"&&(L="right");let re=y?fe(v,i):be(v,i),X;if(y){let se=V(v,i)?.tabsMetadata?.[i];X={type:"pane",id:de(),tabs:[i],activeTabId:i,tabsMetadata:se?{[i]:se}:void 0};}else X=j(v,i)??{type:"pane",id:de(),tabs:[i],activeTabId:i};if(re===null)n(X);else {let me=L==="left"||L==="right",se=L==="left"||L==="top",c=50;ce==="1/4"?c=se?25:75:ce==="1/3"&&(c=se?100/3:200/3),n({type:"split",direction:me?"row":"column",first:se?X:re,second:se?re:X,splitPercentage:c});}u&&u(i,"root",{type:"split",direction:L==="left"||L==="right"?"row":"column",position:L});return}let f=b.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!f){n(v),u&&u(i,null,null);return}let[,_,G]=f,m=y?V(v,i):j(v,i),D=m&&m.id===G,Z=m&&m.tabs.length===1;if(i===G||D&&Z){n(v),u&&u(i,null,null);return}let oe=_==="left"||_==="right"?"row":"column",K;if(y){let ue=V(v,i)?.tabsMetadata?.[i];K={type:"pane",id:de(),tabs:[i],activeTabId:i,tabsMetadata:ue?{[i]:ue}:void 0};}else K=j(v,i)??{type:"pane",id:de(),tabs:[i],activeTabId:i};let Q=y?fe(v,i):be(v,i),Se=Re(Q,G,oe,_,K);n(Se),u&&u(i,G,{type:"split",direction:oe,position:_});},onDragCancel:()=>{a(null),l(null),q(false),g(null),x(null),p(null),T?.(null),E.current=null,s!==null&&(n(s),o(null));}}}var pt=({activeId:e,render:t,className:n})=>{let s=_t.useRef(null);return _t.useEffect(()=>{let o=r=>{s.current&&(s.current.style.transform=`translate(${r.clientX+12}px, ${r.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsxRuntime.jsx("div",{ref:s,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var ft=_t__default.default.memo(({tabId:e,target:t,renderWidget:n})=>{let[s,o]=_t.useState(false),r=_t.useRef(null);if(_t.useEffect(()=>{o(true);},[]),_t.useEffect(()=>{if(!s||!r.current)return;let l=r.current;if(t)t.appendChild(l);else {let d=document.getElementById("zeugma-hidden-portal-container");d||(d=document.createElement("div"),d.id="zeugma-hidden-portal-container",d.style.display="none",document.body.appendChild(d)),d.appendChild(l);}},[t,s]),_t.useEffect(()=>()=>{r.current&&r.current.remove();},[]),!s)return null;r.current||(r.current=document.createElement("div"),r.current.className=`zeugma-portal-wrapper-${e}`,r.current.style.width="100%",r.current.style.height="100%");let a=r.current;return !a||!n?null:reactDom.createPortal(n(e),a)});var Gt=e=>{let t=e,{renderPane:n,renderWidget:s,renderDragOverlay:o,classNames:r={},children:a,layout:l,setLayout:d,fullscreenPaneId:p,setFullscreenPaneId:g,locked:x,setLocked:R,findPaneById:w,findPaneContainingTab:P,findTabById:k,activeId:I,activeType:M,dismissIntentId:u,setContainerRef:T,layoutBeforeDrag:N,snapThreshold:E,minSplitPercentage:A,maxSplitPercentage:J,onRemove:q,onResizeStart:W,onResize:ee,onResizeEnd:te,removePane:ie,addPane:ne,addTab:le,updateTabMetadata:C,updatePaneLock:O,selectTab:$,mergeTab:z,removeTab:y,splitPane:i,updateSplitPercentage:h,moveTab:v}=t,{portalTargets:b,registerPortalTarget:U}=ot(),[B,f]=_t.useState(null),[_,G]=_t.useState(null),m=dt({...t,setOverTabId:f,setOverTabPosition:G}),D=_t.useCallback(L=>n(L),[n]),Z=_t.useMemo(()=>r,[r.dashboard,r.dashboardDismissActive,r.pane,r.paneLocked,r.dropPreview,r.rootDropPreview,r.dragOverlay,r.resizer,r.dismissPreview,r.dashboardLocked,r.lockedPreview,r.tabDropPreview,r.tabSeparator]),oe=_t.useCallback((L,re)=>{te&&te(L,re);},[te]),K=_t.useMemo(()=>({layout:l,setLayout:d,renderPane:D,activeId:I,activeType:M,dismissIntentId:u,setContainerRef:T,fullscreenPaneId:p,classNames:Z,onRemove:q,onFullscreenChange:g,snapThreshold:E,onResizeStart:W,onResize:ee,onResizeEnd:oe,minSplitPercentage:A,maxSplitPercentage:J,locked:x,setLocked:R,findPaneById:w,findPaneContainingTab:P,findTabById:k}),[l,I,M,u,T,p,Z,q,g,E,W,ee,A,J,d,D,oe,x,R,w,P,k]),Q=_t.useMemo(()=>({overTabId:B,overTabPosition:_}),[B,_]),Se=_t.useMemo(()=>({removePane:ie,addPane:ne,addTab:le,updateTabMetadata:C,updatePaneLock:O,selectTab:$,mergeTab:z,removeTab:y,setFullscreenPaneId:g,setLocked:R,splitPane:i,updateSplitPercentage:h,moveTab:v}),[ie,ne,le,C,O,$,z,y,g,R,i,h,v]),ce=_t.useMemo(()=>{let L=new Set;function re(X){X&&(X.type==="pane"?X.tabs.forEach(me=>{L.add(me);}):(re(X.first),re(X.second)));}return re(l),N&&re(N),Array.from(L).sort()},[l,I,N]),ue=_t.useMemo(()=>({registerPortalTarget:U}),[U]);return jsxRuntime.jsx(Ye.Provider,{value:Se,children:jsxRuntime.jsx(Xe.Provider,{value:K,children:jsxRuntime.jsx(Je.Provider,{value:Q,children:jsxRuntime.jsxs($e.Provider,{value:ue,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...m,children:a}),I&&M&&o&&jsxRuntime.jsx(pt,{activeId:I,render:L=>o(L,M),className:`${r.dragOverlay||""} ${I===u&&r.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:ce.map(L=>jsxRuntime.jsx(ft,{tabId:L,target:b[L]||null,renderWidget:s},L))})]})})})})};var jt={top:{"1/4":{position:"absolute",top:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",top:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},bottom:{"1/4":{position:"absolute",bottom:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",bottom:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},left:{"1/4":{position:"absolute",left:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",left:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}},right:{"1/4":{position:"absolute",right:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",right:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}}},en={top:{"1/4":{top:0,left:0,width:"100%",height:"60px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"},"1/3":{top:0,left:0,width:"100%",height:"96px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"}},bottom:{"1/4":{bottom:0,left:0,width:"100%",height:"60px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{bottom:0,left:0,width:"100%",height:"96px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"}},left:{"1/4":{left:0,top:0,width:"60px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},"1/3":{left:0,top:0,width:"96px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"}},right:{"1/4":{right:0,top:0,width:"60px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{right:0,top:0,width:"96px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"}}},tn=({id:e,fraction:t,edge:n,activeClassName:s})=>{let{setNodeRef:o,isOver:r}=core.useDroppable({id:e}),a={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...en[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:jt[n][t]}),r&&jsxRuntime.jsx("div",{className:s,style:a})]})},bt=({activeClassName:e})=>jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/4-top",fraction:"1/4",edge:"top"},{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/4-bottom",fraction:"1/4",edge:"bottom"},{id:"drop-root-1/3-bottom",fraction:"1/3",edge:"bottom"},{id:"drop-root-1/4-left",fraction:"1/4",edge:"left"},{id:"drop-root-1/3-left",fraction:"1/3",edge:"left"},{id:"drop-root-1/4-right",fraction:"1/4",edge:"right"},{id:"drop-root-1/3-right",fraction:"1/3",edge:"right"}].map(n=>jsxRuntime.jsx(tn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});function Ge({containerRef:e,isRow:t,direction:n,splitPercentage:s,resizerSize:o,snapThreshold:r,layout:a,currentNode:l,onLayoutChange:d,onResizeStart:p,onResizeEnd:g,parentLeft:x,parentTop:R,parentWidth:w,parentHeight:P}){let{onResizeStart:k,onResize:I,onResizeEnd:M,minSplitPercentage:u=5,maxSplitPercentage:T=95,locked:N=false}=ae();return _t.useCallback(E=>{if(N)return;E.preventDefault();let A=e.current;if(!A)return;p&&p(),k&&k(l);let J=A.getBoundingClientRect(),q=E.clientX,W=E.clientY,ee=s,te=E.currentTarget,ie=J.left+J.width*(x/100),ne=J.top+J.height*(R/100),le=J.width*(w/100),C=J.height*(P/100),$=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(y=>y!==te&&y.getAttribute("data-direction")===n).map(y=>{let i=y.getBoundingClientRect();return t?i.left+i.width/2:i.top+i.height/2}),z=ee;ct({cursor:t?"col-resize":"row-resize",resizerEl:te,onMove:y=>{let i=t?(y.clientX-q)/le*100:(y.clientY-W)/C*100,h=ee+i,v=t?ie+(le-o)*(h/100)+o/2:ne+(C-o)*(h/100)+o/2,b=1/0,U=null;for(let G of $){let m=Math.abs(v-G);m<r&&m<b&&(b=m,U=G);}let B=h;U!==null&&(B=t?(U-o/2-ie)/(le-o)*100:(U-o/2-ne)/(C-o)*100);let f=Math.max(u,Math.min(T,B));z=f;let _=xe(a,l,f);if(_){let{panes:G,splitters:m}=ge(_),D=e.current;if(D){for(let Z of G)D.style.setProperty(`--pane-left-${Z.paneId}`,`${Z.left}%`),D.style.setProperty(`--pane-top-${Z.paneId}`,`${Z.top}%`),D.style.setProperty(`--pane-width-${Z.paneId}`,`${Z.width}%`),D.style.setProperty(`--pane-height-${Z.paneId}`,`${Z.height}%`);for(let Z of m)D.style.setProperty(`--splitter-pos-${Z.id}`,`${Z.direction==="row"?Z.left:Z.top}%`);}}I&&I(l,f);},onEnd:()=>{let y=xe(a,l,z),i=e.current;if(i){let{panes:h,splitters:v}=ge(y);for(let b of h)i.style.removeProperty(`--pane-left-${b.paneId}`),i.style.removeProperty(`--pane-top-${b.paneId}`),i.style.removeProperty(`--pane-width-${b.paneId}`),i.style.removeProperty(`--pane-height-${b.paneId}`);for(let b of v)i.style.removeProperty(`--splitter-pos-${b.id}`);}d(y),g&&g(),M&&M(l,z);}});},[e,t,n,s,o,r,a,l,d,p,g,k,I,M,u,T,x,R,w,P])}var un=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:s})=>{let{layout:o,setLayout:r,classNames:a,locked:l}=ae(),[d,p]=_t.useState(false),{currentNode:g,direction:x,left:R,top:w,width:P,height:k,parentLeft:I,parentTop:M,parentWidth:u,parentHeight:T}=e,N=x==="row",E=Ge({containerRef:s,isRow:N,direction:x,splitPercentage:g.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:g,onLayoutChange:r,onResizeStart:()=>p(true),onResizeEnd:()=>p(false),parentLeft:I,parentTop:M,parentWidth:u,parentHeight:T}),A=N?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${R}%) - ${t/2}px)`,top:`calc(${w}% + ${t/2}px)`,width:`${t}px`,height:`calc(${k}% - ${t}px)`,cursor:l?"default":"col-resize",pointerEvents:l?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${R}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${w}%) - ${t/2}px)`,width:`calc(${P}% - ${t}px)`,height:`${t}px`,cursor:l?"default":"row-resize",pointerEvents:l?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:a.resizer||"","data-direction":x,"data-resizing":d||void 0,style:A,onPointerDown:E,role:"separator","aria-valuenow":g.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},dn=_t__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),pn=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:s,renderPane:o,activeId:r,dismissIntentId:a,setContainerRef:l,fullscreenPaneId:d,snapThreshold:p,locked:g,classNames:x}=ae(),R=n!==void 0?n:p??8,w=e!==void 0?e:s,P=_t.useRef(null),{panes:k,splitters:I}=_t.useMemo(()=>w?ge(w):{panes:[],splitters:[]},[w]);if(!w)return null;let M=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[k.map(u=>{let T=d===u.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:T?"0%":`var(--pane-left-${u.paneId}, ${u.left}%)`,top:T?"0%":`var(--pane-top-${u.paneId}, ${u.top}%)`,width:T?"100%":`var(--pane-width-${u.paneId}, ${u.width}%)`,height:T?"100%":`var(--pane-height-${u.paneId}, ${u.height}%)`,overflow:"hidden",zIndex:T?20:1,display:d&&!T?"none":"block",padding:T?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(dn,{paneId:u.paneId,renderPane:o})},u.paneId)}),!d&&I.map(u=>jsxRuntime.jsx(un,{splitter:u,resizerSize:t,snapThreshold:R,containerRef:P},u.id))]});if(e===void 0){let u=r!==null&&r===a,T=E=>{l(E),P.current=E;},N=`${x.dashboard||""} ${u&&x.dashboardDismissActive||""} ${g&&x.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:T,className:N,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[M(),r!==null&&!g&&jsxRuntime.jsx(bt,{activeClassName:x.rootDropPreview??x.dropPreview})]})}return jsxRuntime.jsx("div",{ref:P,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:M()})};var Ve=_t.createContext(null);var Tn={top:{position:"absolute",top:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},full:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:20,pointerEvents:"auto",cursor:"not-allowed"}},Pn={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"}},xt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:s,isOver:o}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:s,style:Tn[t]}),o&&jsxRuntime.jsx("div",{className:n,style:Pn[t]})]})},Rn=({id:e,children:t,style:n,locked:s=false})=>{let o=_t.useRef(null),{layout:r,activeId:a,classNames:l,fullscreenPaneId:d,onFullscreenChange:p,locked:g}=ae(),{removePane:x,updateTabMetadata:R,selectTab:w,removeTab:P}=ze(),k=_t.useContext($e);if(!k)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:I}=k,M=_t.useMemo(()=>j(r,e),[r,e]),u=M?.id??e,T=M?.tabs??[e],N=M?.activeTabId??e,E=M?.tabsMetadata,A=E?.[e],J=M?.locked??false,q=s||J,W=g||q,ee=g||q,te=a!==null&&a!==e&&(!T.includes(a)||T.length>1)&&!ee,{attributes:ie,listeners:ne,setNodeRef:le}=core.useDraggable({id:e,disabled:W}),C=a!==null&&T.includes(a),O=d===e,$=_t.useCallback(()=>jsxRuntime.jsx("div",{ref:o,id:`zeugma-tab-target-${N}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[N]);_t.useEffect(()=>{let h=o.current;return I(N,h),()=>{I(N,null);}},[N,I]);let z=_t.useMemo(()=>({isDragging:C,isFullscreen:O,toggleFullscreen:()=>p?.(O?null:e),remove:()=>{O&&p?.(null),x(u);},metadata:A,updateMetadata:h=>{R(e,h);},locked:W,tabs:T,activeTabId:N,selectTab:h=>w(u,h),removeTab:h=>{O&&h===N&&p?.(null),P(h);},tabsMetadata:E,updateTabMetadata:(h,v)=>{R(h,v);},renderActiveTab:$}),[C,O,p,e,P,A,R,W,T,N,w,u,E,$]),y=_t.useMemo(()=>W?{disabled:true}:{...ne,...ie},[ne,ie,W]),i=`${l.pane||""} ${q&&l.paneLocked||""}`.trim();return jsxRuntime.jsx(Ve.Provider,{value:y,children:jsxRuntime.jsxs("div",{ref:le,className:i,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(z),te&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(h=>jsxRuntime.jsx(xt,{id:`drop-${h}-${e}`,position:h,activeClassName:l.dropPreview},h))}),a!==null&&a!==e&&ee&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(xt,{id:`drop-locked-${e}`,position:"full",activeClassName:l.lockedPreview||""})})]})})};var Cn=({children:e,className:t,style:n})=>{let s=_t.useContext(Ve);if(!s)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...r}=s;return jsxRuntime.jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:r,children:e})};var Dt=_t.createContext(void 0),In=()=>{let e=_t.useContext(Dt);if(!e)throw new Error("useTabContext must be used within a Tab component");return e},Ct=({id:e,locked:t=false,children:n,className:s,style:o})=>{let{locked:r,classNames:a={},activeType:l}=ae(),{overTabId:d}=Ae(),p=_t.useContext(Qe),g=t||r||(p?.locked??false),{attributes:x,listeners:R,setNodeRef:w,isDragging:P}=core.useDraggable({id:`tab-header-${e}`,disabled:g}),{setNodeRef:k,isOver:I}=core.useDroppable({id:`tab-drop-${e}`,disabled:g||l==="pane"}),M=ne=>{w(ne),k(ne);},u=I&&d===e,T=p?.tabs||[],N=T.indexOf(e),E=p?.activeTabId,J=N>0&&e!==E&&T[N-1]!==E?jsxRuntime.jsx("div",{className:a.tabSeparator}):null,q=p?p.activeTabId===e:false,W=p?.tabsMetadata?.[e],ee=_t.useCallback(()=>{p?.selectTab(e);},[p,e]),te=_t.useCallback(()=>{p?.removeTab(e);},[p,e]),ie=_t.useMemo(()=>({tabId:e,isActive:q,isDragging:P,isOver:u,metadata:W,locked:g,selectTab:ee,removeTab:te}),[e,q,P,u,W,g,ee,te]);return jsxRuntime.jsx(Dt.Provider,{value:ie,children:jsxRuntime.jsxs("div",{ref:M,className:s,style:{display:"inline-flex",position:"relative",cursor:g?"default":"grab",...o},...g?{}:R,...g?{}:x,children:[J,n({isDragging:P,isOver:u})]})})};var Qe=_t.createContext(void 0);var St=(e,t)=>typeof e=="function"?e(t):e,zn=({tabs:e,activeTabId:t,locked:n=false,tabsMetadata:s,selectTab:o,removeTab:r,renderTab:a,classNames:l,styles:d})=>{let{classNames:p={},activeType:g}=ae(),{overTabId:x,overTabPosition:R}=Ae(),w=_t.useMemo(()=>({tabs:e,activeTabId:t,locked:n,tabsMetadata:s,selectTab:o,removeTab:r}),[e,t,n,s,o,r]),P=at(e,g,x,R);return jsxRuntime.jsx(Qe.Provider,{value:w,children:jsxRuntime.jsxs("div",{className:l?.container,style:{display:"flex",alignItems:"center",height:"100%",...d?.container},children:[e.map((k,I)=>{let M=s?.[k],u=St(l?.tab,k),T=St(d?.tab,k),N=I===P;return jsxRuntime.jsxs(_t__default.default.Fragment,{children:[N&&p.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:p.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:I===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(Ct,{id:k,locked:n,className:u,style:T,children:({isDragging:E,isOver:A})=>a({tabId:k,activeTabId:t,isDragging:E,isOver:A,metadata:M,selectTab:o,removeTab:r})})]},k)}),P===e.length&&p.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:p.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=It;exports.DEFAULT_RESIZER_SIZE=On;exports.DEFAULT_SNAP_THRESHOLD=Lt;exports.DragHandle=Cn;exports.Pane=Rn;exports.PaneTree=pn;exports.PortalRegistryContext=$e;exports.Tabs=zn;exports.Zeugma=Gt;exports.ZeugmaActionsContext=Ye;exports.ZeugmaDragContext=Je;exports.ZeugmaStateContext=Xe;exports.createDragSession=ct;exports.safeJsonStringify=Ne;exports.useResizer=Ge;exports.useTabContext=In;exports.useZeugma=Mt;exports.useZeugmaActions=ze;exports.useZeugmaContext=Zt;exports.useZeugmaDrag=Ae;exports.useZeugmaState=ae;//# sourceMappingURL=index.cjs.map
6
+ `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let r=a=>{n(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",r),document.removeEventListener("pointerup",i),s();};document.addEventListener("pointermove",r),document.addEventListener("pointerup",i);}var Xe=qt.createContext(void 0),Ye=qt.createContext(void 0),Re=qt.createContext(void 0),Je=qt.createContext(void 0),re=()=>{let e=qt.useContext(Xe);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},De=()=>{let e=qt.useContext(Ye);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Fe=()=>{let e=qt.useContext(Je);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};var At=()=>{let e=re(),t=De();return {...e,...t}};var Oe=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Be=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};function We(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}function gt(e){let{layout:t,_internalSetLayout:n,layoutBeforeDrag:s,setLayoutBeforeDrag:o,activeId:r,setActiveId:i,setActiveType:a,dismissIntentId:c,setDismissIntentId:p,setOverTabId:f,setOverTabPosition:h,containerRef:R,dragActivationDistance:w,enableDragToDismiss:x,dismissThreshold:E,onRemove:M,onDragStart:N,onDragEnd:u,onDismissIntentChange:T,removeTab:L}=e,C=qt.useRef(null),z=nt(r),[_,U]=qt.useState(false);ot(_);let F=core.useSensors(core.useSensor(Oe,{activationConstraint:{distance:w}}),core.useSensor(Be,{activationConstraint:{delay:250,tolerance:5}})),q=qt.useCallback(g=>{let A=g.active.id.toString().startsWith("tab-header-"),H=core.pointerWithin(g),D=A?H:H.filter(l=>!l.id.toString().startsWith("tab-drop-"));if(D.length>0)return [...D].sort((P,y)=>{let v=P.id.toString(),X=y.id.toString();if(A){let B=v.startsWith("tab-drop-"),Q=X.startsWith("tab-drop-");if(B&&!Q)return -1;if(!B&&Q)return 1}let O=v.startsWith("drop-root-"),m=X.startsWith("drop-root-");return O&&!m?-1:!O&&m?1:0});if(A){let l=g.droppableContainers.filter(P=>P.id.toString().startsWith("tab-drop-"));return core.closestCenter({...g,droppableContainers:l})}return []},[]);return {sensors:F,collisionDetection:q,onDragStart:g=>{let Z=g.active.id.toString(),A=Z.startsWith("tab-header-"),H=A?Z.substring(11):Z;i(H),a(A?"tab":"pane"),f(null),h(null);let D=g.activatorEvent;z.current=We(D),x&&R.current?C.current=R.current.getBoundingClientRect():C.current=null;let l=t;if(A){let P=ee(t,H);P&&(l=ye(t,P.id,H)||t);}o(l),A&&l!==t&&n(l),N&&N(H);},onDragMove:g=>{let{over:Z}=g,A=Z?.id.toString()||"",H=A.startsWith("drop-locked-");U(b=>b===H?b:H);let D=g.active.id.toString(),l=D.startsWith("tab-header-"),P=l?D.substring(11):D,y=A.match(/^tab-drop-(.+)$/);if(y&&Z&&l){let[,b]=y;if(P!==b){let S="before",$=Z.rect,se=g.activatorEvent,j=null;if(z.current)j=z.current.x;else {let te=We(se);te&&(j=te.x+g.delta.x);}if(j!==null){let te=$.left+$.width/2;j>te&&(S="after");}f(te=>te===b?te:b),h(te=>te===S?te:S);}else f(S=>S===null?S:null),h(S=>S===null?S:null);}else f(b=>b===null?b:null),h(b=>b===null?b:null);if(!x)return;let v=C.current;if(!v){c!==null&&(p(null),T?.(null));return}let X=g.activatorEvent,O=null,m=null;if(z.current)O=z.current.x,m=z.current.y;else {let b=We(X);b&&(O=b.x+g.delta.x,m=b.y+g.delta.y);}let B=0;if(O!==null&&m!==null){let b=0,S=0;O<v.left?b=v.left-O:O>v.right&&(b=O-v.right),m<v.top?S=v.top-m:m>v.bottom&&(S=m-v.bottom),B=Math.sqrt(b*b+S*S);}else {let b=g.active.rect.current.translated;if(b){let S=b.left+b.width/2,$=b.top+b.height/2,se=0,j=0;S<v.left?se=v.left-S:S>v.right&&(se=S-v.right),$<v.top?j=v.top-$:$>v.bottom&&(j=$-v.bottom),B=Math.sqrt(se*se+j*j);}}B>E?c!==P&&(p(P),T?.(P)):c!==null&&(p(null),T?.(null));},onDragEnd:g=>{i(null),a(null),U(false),f(null),h(null);let{active:Z,over:A}=g,H=Z.id.toString(),D=H.startsWith("tab-header-"),l=D?H.substring(11):H,P=x&&c===l;p(null),T?.(null),C.current=null;let y=s||t;if(o(null),P){M?M(l):L(l),u&&u(l,null,null);return}if(!A){n(y),u&&u(l,null,null);return}let v=A.id.toString();if(v.startsWith("drop-locked-")){n(y),u&&u(l,null,null);return}let X=v.match(/^tab-drop-(.+)$/);if(X){if(!D){n(y),u&&u(l,null,null);return}let[,ce]=X;if(l!==ce){let ue="before",k=A.rect,ie=g.activatorEvent,W=null;if(z.current)W=z.current.x;else {let ae=We(ie);ae&&(W=ae.x+g.delta.x);}if(W!==null){let ae=k.left+k.width/2;W>ae&&(ue="after");}let ge=ze(y,l,ce,ue);n(ge),u&&u(l,ce,{type:"move",position:"center"});}else n(y),u&&u(l,null,null);return}let O=v.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(O){let[,ce,ue]=O,k=ue;k==="start"&&(k="left"),k==="end"&&(k="right");let ie=D?pe(y,l):be(y,l),W;if(D){let ae=ee(y,l)?.tabsMetadata?.[l];W={type:"pane",id:de(),tabs:[l],activeTabId:l,tabsMetadata:ae?{[l]:ae}:void 0};}else W=ne(y,l)??{type:"pane",id:de(),tabs:[l],activeTabId:l};if(ie===null)n(W);else {let ge=k==="left"||k==="right",ae=k==="left"||k==="top",Me=50;ce==="1/4"?Me=ae?25:75:ce==="1/3"&&(Me=ae?100/3:200/3),n({type:"split",direction:ge?"row":"column",first:ae?W:ie,second:ae?ie:W,splitPercentage:Me});}u&&u(l,"root",{type:"split",direction:k==="left"||k==="right"?"row":"column",position:k});return}let m=v.match(/^drop-(left|right|top|bottom)-(.+)$/);if(!m){n(y),u&&u(l,null,null);return}let[,B,Q]=m,b=D?ee(y,l):ne(y,l),S=b&&b.id===Q,$=b&&(b.type==="widget"||b.tabs.length===1);if(l===Q||S&&$){n(y),u&&u(l,null,null);return}let se=B==="left"||B==="right"?"row":"column",j;if(D){let ue=ee(y,l)?.tabsMetadata?.[l];j={type:"pane",id:de(),tabs:[l],activeTabId:l,tabsMetadata:ue?{[l]:ue}:void 0};}else j=ne(y,l)??{type:"pane",id:de(),tabs:[l],activeTabId:l};let te=D?pe(y,l):be(y,l),Ie=Pe(te,Q,se,B,j);n(Ie),u&&u(l,Q,{type:"split",direction:se,position:B});},onDragCancel:()=>{i(null),a(null),U(false),f(null),h(null),p(null),T?.(null),C.current=null,s!==null&&(n(s),o(null));}}}var mt=({activeId:e,render:t,className:n})=>{let s=qt.useRef(null);return qt.useEffect(()=>{let o=r=>{s.current&&(s.current.style.transform=`translate(${r.clientX+12}px, ${r.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsxRuntime.jsx("div",{ref:s,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var bt=qt__default.default.memo(({tabId:e,target:t,renderWidget:n})=>{let[s,o]=qt.useState(false),r=qt.useRef(null);if(qt.useEffect(()=>{o(true);},[]),qt.useEffect(()=>{if(!s||!r.current)return;let a=r.current;if(t)t.appendChild(a);else {let c=document.getElementById("zeugma-hidden-portal-container");c||(c=document.createElement("div"),c.id="zeugma-hidden-portal-container",c.style.display="none",document.body.appendChild(c)),c.appendChild(a);}},[t,s]),qt.useEffect(()=>()=>{r.current&&r.current.remove();},[]),!s)return null;r.current||(r.current=document.createElement("div"),r.current.className=`zeugma-portal-wrapper-${e}`,r.current.style.width="100%",r.current.style.height="100%");let i=r.current;return !i||!n?null:reactDom.createPortal(n(e),i)});var en=e=>{let t=e,{renderPane:n,renderWidget:s,renderDragOverlay:o,classNames:r={},children:i,layout:a,setLayout:c,fullscreenPaneId:p,setFullscreenPaneId:f,locked:h,setLocked:R,findPaneById:w,findPaneContainingTab:x,findTabById:E,activeId:M,activeType:N,dismissIntentId:u,setContainerRef:T,layoutBeforeDrag:L,snapThreshold:C,minSplitPercentage:z,maxSplitPercentage:_,onRemove:U,onResizeStart:F,onResize:q,onResizeEnd:G,removePane:oe,addWidget:K,addTab:le,updateMetadata:g,updatePaneLock:Z,selectTab:A,mergeTab:H,removeTab:D,splitPane:l,updateSplitPercentage:P,moveTab:y}=t,{portalTargets:v,registerPortalTarget:X}=rt(),[O,m]=qt.useState(null),[B,Q]=qt.useState(null),b=gt({...t,setOverTabId:m,setOverTabPosition:Q}),S=qt.useCallback(k=>n(k),[n]),$=qt.useMemo(()=>r,[r.dashboard,r.dashboardDismissActive,r.pane,r.paneLocked,r.dropPreview,r.rootDropPreview,r.dragOverlay,r.resizer,r.dismissPreview,r.dashboardLocked,r.lockedPreview,r.tabDropPreview,r.tabSeparator]),se=qt.useCallback((k,ie)=>{G&&G(k,ie);},[G]),j=qt.useMemo(()=>({layout:a,setLayout:c,renderPane:S,activeId:M,activeType:N,dismissIntentId:u,setContainerRef:T,fullscreenPaneId:p,classNames:$,onRemove:U,onFullscreenChange:f,snapThreshold:C,onResizeStart:F,onResize:q,onResizeEnd:se,minSplitPercentage:z,maxSplitPercentage:_,locked:h,setLocked:R,findPaneById:w,findPaneContainingTab:x,findTabById:E}),[a,M,N,u,T,p,$,U,f,C,F,q,z,_,c,S,se,h,R,w,x,E]),te=qt.useMemo(()=>({overTabId:O,overTabPosition:B}),[O,B]),Ie=qt.useMemo(()=>({removePane:oe,addWidget:K,addTab:le,updateMetadata:g,updatePaneLock:Z,selectTab:A,mergeTab:H,removeTab:D,setFullscreenPaneId:f,setLocked:R,splitPane:l,updateSplitPercentage:P,moveTab:y}),[oe,K,le,g,Z,A,H,D,f,R,l,P,y]),ce=qt.useMemo(()=>{let k=new Set;function ie(W){W&&(W.type==="pane"?W.tabs.forEach(ge=>{k.add(ge);}):W.type==="widget"?k.add(W.id):W.type==="split"&&(ie(W.first),ie(W.second)));}return ie(a),L&&ie(L),Array.from(k).sort()},[a,M,L]),ue=qt.useMemo(()=>({registerPortalTarget:X}),[X]);return jsxRuntime.jsx(Ye.Provider,{value:Ie,children:jsxRuntime.jsx(Xe.Provider,{value:j,children:jsxRuntime.jsx(Je.Provider,{value:te,children:jsxRuntime.jsxs(Re.Provider,{value:ue,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...b,children:i}),M&&N&&o&&jsxRuntime.jsx(mt,{activeId:M,render:k=>o(k,N),className:`${r.dragOverlay||""} ${M===u&&r.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:ce.map(k=>jsxRuntime.jsx(bt,{tabId:k,target:v[k]||null,renderWidget:s},k))})]})})})})};var on={top:{"1/4":{position:"absolute",top:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",top:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},bottom:{"1/4":{position:"absolute",bottom:0,left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",bottom:"24px",left:0,width:"100%",height:"24px",zIndex:100,pointerEvents:"auto"}},left:{"1/4":{position:"absolute",left:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",left:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}},right:{"1/4":{position:"absolute",right:0,top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"},"1/3":{position:"absolute",right:"24px",top:"48px",width:"24px",height:"calc(100% - 96px)",zIndex:100,pointerEvents:"auto"}}},rn={top:{"1/4":{top:0,left:0,width:"100%",height:"60px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"},"1/3":{top:0,left:0,width:"100%",height:"96px",borderBottomLeftRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderTopRightRadius:"0px"}},bottom:{"1/4":{bottom:0,left:0,width:"100%",height:"60px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{bottom:0,left:0,width:"100%",height:"96px",borderTopLeftRadius:"12px",borderTopRightRadius:"12px",borderBottomLeftRadius:"0px",borderBottomRightRadius:"0px"}},left:{"1/4":{left:0,top:0,width:"60px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},"1/3":{left:0,top:0,width:"96px",height:"100%",borderTopRightRadius:"12px",borderBottomRightRadius:"12px",borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"}},right:{"1/4":{right:0,top:0,width:"60px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"},"1/3":{right:0,top:0,width:"96px",height:"100%",borderTopLeftRadius:"12px",borderBottomLeftRadius:"12px",borderTopRightRadius:"0px",borderBottomRightRadius:"0px"}}},sn=({id:e,fraction:t,edge:n,activeClassName:s})=>{let{setNodeRef:o,isOver:r}=core.useDroppable({id:e}),i={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...rn[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:on[n][t]}),r&&jsxRuntime.jsx("div",{className:s,style:i})]})},xt=({activeClassName:e})=>jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:99,pointerEvents:"none"},children:[{id:"drop-root-1/4-top",fraction:"1/4",edge:"top"},{id:"drop-root-1/3-top",fraction:"1/3",edge:"top"},{id:"drop-root-1/4-bottom",fraction:"1/4",edge:"bottom"},{id:"drop-root-1/3-bottom",fraction:"1/3",edge:"bottom"},{id:"drop-root-1/4-left",fraction:"1/4",edge:"left"},{id:"drop-root-1/3-left",fraction:"1/3",edge:"left"},{id:"drop-root-1/4-right",fraction:"1/4",edge:"right"},{id:"drop-root-1/3-right",fraction:"1/3",edge:"right"}].map(n=>jsxRuntime.jsx(sn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});function Ge({containerRef:e,isRow:t,direction:n,splitPercentage:s,resizerSize:o,snapThreshold:r,layout:i,currentNode:a,onLayoutChange:c,onResizeStart:p,onResizeEnd:f,parentLeft:h,parentTop:R,parentWidth:w,parentHeight:x}){let{onResizeStart:E,onResize:M,onResizeEnd:N,minSplitPercentage:u=5,maxSplitPercentage:T=95,locked:L=false}=re();return qt.useCallback(C=>{if(L)return;C.preventDefault();let z=e.current;if(!z)return;p&&p(),E&&E(a);let _=z.getBoundingClientRect(),U=C.clientX,F=C.clientY,q=s,G=C.currentTarget,oe=_.left+_.width*(h/100),K=_.top+_.height*(R/100),le=_.width*(w/100),g=_.height*(x/100),A=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(D=>D!==G&&D.getAttribute("data-direction")===n).map(D=>{let l=D.getBoundingClientRect();return t?l.left+l.width/2:l.top+l.height/2}),H=q;pt({cursor:t?"col-resize":"row-resize",resizerEl:G,onMove:D=>{let l=t?(D.clientX-U)/le*100:(D.clientY-F)/g*100,P=q+l,y=t?oe+(le-o)*(P/100)+o/2:K+(g-o)*(P/100)+o/2,v=1/0,X=null;for(let Q of A){let b=Math.abs(y-Q);b<r&&b<v&&(v=b,X=Q);}let O=P;X!==null&&(O=t?(X-o/2-oe)/(le-o)*100:(X-o/2-K)/(g-o)*100);let m=Math.max(u,Math.min(T,O));H=m;let B=ve(i,a,m);if(B){let{panes:Q,splitters:b}=fe(B),S=e.current;if(S){for(let $ of Q)S.style.setProperty(`--pane-left-${$.paneId}`,`${$.left}%`),S.style.setProperty(`--pane-top-${$.paneId}`,`${$.top}%`),S.style.setProperty(`--pane-width-${$.paneId}`,`${$.width}%`),S.style.setProperty(`--pane-height-${$.paneId}`,`${$.height}%`);for(let $ of b)S.style.setProperty(`--splitter-pos-${$.id}`,`${$.direction==="row"?$.left:$.top}%`);}}M&&M(a,m);},onEnd:()=>{let D=ve(i,a,H),l=e.current;if(l){let{panes:P,splitters:y}=fe(D);for(let v of P)l.style.removeProperty(`--pane-left-${v.paneId}`),l.style.removeProperty(`--pane-top-${v.paneId}`),l.style.removeProperty(`--pane-width-${v.paneId}`),l.style.removeProperty(`--pane-height-${v.paneId}`);for(let v of y)l.style.removeProperty(`--splitter-pos-${v.id}`);}c(D),f&&f(),N&&N(a,H);}});},[e,t,n,s,o,r,i,a,c,p,f,E,M,N,u,T,h,R,w,x])}var gn=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:s})=>{let{layout:o,setLayout:r,classNames:i,locked:a}=re(),[c,p]=qt.useState(false),{currentNode:f,direction:h,left:R,top:w,width:x,height:E,parentLeft:M,parentTop:N,parentWidth:u,parentHeight:T}=e,L=h==="row",C=Ge({containerRef:s,isRow:L,direction:h,splitPercentage:f.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:f,onLayoutChange:r,onResizeStart:()=>p(true),onResizeEnd:()=>p(false),parentLeft:M,parentTop:N,parentWidth:u,parentHeight:T}),z=L?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${R}%) - ${t/2}px)`,top:`calc(${w}% + ${t/2}px)`,width:`${t}px`,height:`calc(${E}% - ${t}px)`,cursor:a?"default":"col-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${R}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${w}%) - ${t/2}px)`,width:`calc(${x}% - ${t}px)`,height:`${t}px`,cursor:a?"default":"row-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:i.resizer||"","data-direction":h,"data-resizing":c||void 0,style:z,onPointerDown:C,role:"separator","aria-valuenow":f.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},mn=qt__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane),bn=({tree:e,resizerSize:t=4,snapThreshold:n})=>{let{layout:s,renderPane:o,activeId:r,dismissIntentId:i,setContainerRef:a,fullscreenPaneId:c,snapThreshold:p,locked:f,classNames:h}=re(),R=n!==void 0?n:p??8,w=e!==void 0?e:s,x=qt.useRef(null),{panes:E,splitters:M}=qt.useMemo(()=>w?fe(w):{panes:[],splitters:[]},[w]);if(!w)return null;let N=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[E.map(u=>{let T=c===u.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:T?"0%":`var(--pane-left-${u.paneId}, ${u.left}%)`,top:T?"0%":`var(--pane-top-${u.paneId}, ${u.top}%)`,width:T?"100%":`var(--pane-width-${u.paneId}, ${u.width}%)`,height:T?"100%":`var(--pane-height-${u.paneId}, ${u.height}%)`,overflow:"hidden",zIndex:T?20:1,display:c&&!T?"none":"block",padding:T?"0px":`${t/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(mn,{paneId:u.paneId,renderPane:o})},u.paneId)}),!c&&M.map(u=>jsxRuntime.jsx(gn,{splitter:u,resizerSize:t,snapThreshold:R,containerRef:x},u.id))]});if(e===void 0){let u=r!==null&&r===i,T=C=>{a(C),x.current=C;},L=`${h.dashboard||""} ${u&&h.dashboardDismissActive||""} ${f&&h.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:T,className:L,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[N(),r!==null&&!f&&jsxRuntime.jsx(xt,{activeClassName:h.rootDropPreview??h.dropPreview})]})}return jsxRuntime.jsx("div",{ref:x,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:N()})};var Ce=qt.createContext(null);var xn={top:{position:"absolute",top:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},bottom:{position:"absolute",bottom:0,left:0,width:"100%",height:"25%",zIndex:20,pointerEvents:"auto"},left:{position:"absolute",top:"25%",left:0,width:"50%",height:"50%",zIndex:20,pointerEvents:"auto"},right:{position:"absolute",top:"25%",right:0,width:"50%",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"}},Se=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:s,isOver:o}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:s,style:xn[t]}),o&&jsxRuntime.jsx("div",{className:n,style:Tn[t]})]})};var Nn=({id:e,children:t,style:n,locked:s=false})=>{let o=qt.useRef(null),{layout:r,activeId:i,classNames:a,fullscreenPaneId:c,onFullscreenChange:p,locked:f}=re(),{removePane:h,updateMetadata:R,selectTab:w,removeTab:x}=De(),E=qt.useContext(Re);if(!E)throw new Error("Pane must be used within a Zeugma provider");let{registerPortalTarget:M}=E,N=qt.useMemo(()=>ne(r,e),[r,e]),u=N?.id??e,T=N?.tabs??[e],L=N?.activeTabId??e,C=N?.tabsMetadata,z=C?.[e],_=N?.locked??false,U=s||_,F=f||U,q=f||U,G=i!==null&&i!==e&&(!T.includes(i)||T.length>1)&&!q,{attributes:oe,listeners:K,setNodeRef:le}=core.useDraggable({id:e,disabled:F}),g=i!==null&&T.includes(i),Z=c===e,A=qt.useCallback(()=>jsxRuntime.jsx("div",{ref:o,id:`zeugma-tab-target-${L}`,className:"zeugma-tab-content-wrapper",style:{height:"100%",width:"100%"}}),[L]);qt.useEffect(()=>{let P=o.current;return M(L,P),()=>{M(L,null);}},[L,M]);let H=qt.useMemo(()=>({isDragging:g,isFullscreen:Z,toggleFullscreen:()=>p?.(Z?null:e),remove:()=>{Z&&p?.(null),h(u);},metadata:z,updateMetadata:P=>{R(e,P);},locked:F,tabs:T,activeTabId:L,selectTab:P=>w(u,P),removeTab:P=>{Z&&P===L&&p?.(null),x(P);},tabsMetadata:C,updateTabMetadata:(P,y)=>{R(P,y);},renderActiveTab:A}),[g,Z,p,e,x,z,R,F,T,L,w,u,C,A]),D=qt.useMemo(()=>F?{disabled:true}:{...K,...oe},[K,oe,F]),l=`${a.pane||""} ${U&&a.paneLocked||""}`.trim();return jsxRuntime.jsx(Ce.Provider,{value:D,children:jsxRuntime.jsxs("div",{ref:le,className:l,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(H),G&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(P=>jsxRuntime.jsx(Se,{id:`drop-${P}-${e}`,position:P,activeClassName:a.dropPreview},P))}),i!==null&&i!==e&&q&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(Se,{id:`drop-locked-${e}`,position:"full",activeClassName:a.lockedPreview||""})})]})})};var In=({children:e,className:t,style:n})=>{let s=qt.useContext(Ce);if(!s)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...r}=s;return jsxRuntime.jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:r,children:e})};var Ct=qt.createContext(void 0),An=()=>{let e=qt.useContext(Ct);if(!e)throw new Error("useTabContext must be used within a Tab component");return e},St=({id:e,locked:t=false,children:n,className:s,style:o})=>{let{locked:r,classNames:i={},activeType:a}=re(),{overTabId:c}=Fe(),p=qt.useContext(Qe),f=t||r||(p?.locked??false),{attributes:h,listeners:R,setNodeRef:w,isDragging:x}=core.useDraggable({id:`tab-header-${e}`,disabled:f}),{setNodeRef:E,isOver:M}=core.useDroppable({id:`tab-drop-${e}`,disabled:f||a==="pane"}),N=K=>{w(K),E(K);},u=M&&c===e,T=p?.tabs||[],L=T.indexOf(e),C=p?.activeTabId,_=L>0&&e!==C&&T[L-1]!==C?jsxRuntime.jsx("div",{className:i.tabSeparator}):null,U=p?p.activeTabId===e:false,F=p?.tabsMetadata?.[e],q=qt.useCallback(()=>{p?.selectTab(e);},[p,e]),G=qt.useCallback(()=>{p?.removeTab(e);},[p,e]),oe=qt.useMemo(()=>({tabId:e,isActive:U,isDragging:x,isOver:u,metadata:F,locked:f,selectTab:q,removeTab:G}),[e,U,x,u,F,f,q,G]);return jsxRuntime.jsx(Ct.Provider,{value:oe,children:jsxRuntime.jsxs("div",{ref:N,className:s,style:{display:"inline-flex",position:"relative",cursor:f?"default":"grab",...o},...f?{}:R,...f?{}:h,children:[_,n({isDragging:x,isOver:u})]})})};var Qe=qt.createContext(void 0);var Nt=(e,t)=>typeof e=="function"?e(t):e,Wn=({tabs:e,activeTabId:t,locked:n=false,tabsMetadata:s,selectTab:o,removeTab:r,renderTab:i,classNames:a,styles:c})=>{let{classNames:p={},activeType:f}=re(),{overTabId:h,overTabPosition:R}=Fe(),w=qt.useMemo(()=>({tabs:e,activeTabId:t,locked:n,tabsMetadata:s,selectTab:o,removeTab:r}),[e,t,n,s,o,r]),x=ut(e,f,h,R);return jsxRuntime.jsx(Qe.Provider,{value:w,children:jsxRuntime.jsxs("div",{className:a?.container,style:{display:"flex",alignItems:"center",height:"100%",...c?.container},children:[e.map((E,M)=>{let N=s?.[E],u=Nt(a?.tab,E),T=Nt(c?.tab,E),L=M===x;return jsxRuntime.jsxs(qt__default.default.Fragment,{children:[L&&p.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:p.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:M===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(St,{id:E,locked:n,className:u,style:T,children:({isDragging:C,isOver:z})=>i({tabId:E,activeTabId:t,isDragging:C,isOver:z,metadata:N,selectTab:o,removeTab:r})})]},E)}),x===e.length&&p.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:p.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};var Jn=({id:e,children:t,style:n,locked:s=false})=>{let o=qt.useRef(null),{layout:r,activeId:i,classNames:a,fullscreenPaneId:c,onFullscreenChange:p,locked:f}=re(),{removePane:h,updateMetadata:R}=De(),w=qt.useContext(Re);if(!w)throw new Error("Widget must be used within a Zeugma provider");let{registerPortalTarget:x}=w,E=qt.useMemo(()=>{if(!r)return null;if(r.type!=="split"&&r.id===e)return r;function g(Z){return Z?Z.type!=="split"&&Z.id===e?Z:Z.type==="split"?g(Z.first)??g(Z.second):null:null}return g(r)},[r,e]),M=E?.locked??false,N=s||M,u=f||N,T=f||N,L=i!==null&&i!==e&&!T,{attributes:C,listeners:z,setNodeRef:_}=core.useDraggable({id:e,disabled:u}),U=i===e,F=c===e,q=qt.useCallback(()=>jsxRuntime.jsx("div",{ref:o,id:`zeugma-widget-target-${e}`,className:"zeugma-widget-content-wrapper",style:{height:"100%",width:"100%"}}),[e]);qt.useEffect(()=>{let g=o.current;return x(e,g),()=>{x(e,null);}},[e,x]);let G=E&&"metadata"in E?E.metadata:void 0,oe=qt.useMemo(()=>({isDragging:U,isFullscreen:F,toggleFullscreen:()=>p?.(F?null:e),remove:()=>{F&&p?.(null),h(e);},metadata:G,updateMetadata:g=>{R(e,g);},locked:u,renderActiveWidget:q}),[U,F,p,e,h,G,R,u,q]),K=qt.useMemo(()=>u?{disabled:true}:{...z,...C},[z,C,u]),le=`${a.pane||""} ${N&&a.paneLocked||""}`.trim();return jsxRuntime.jsx(Ce.Provider,{value:K,children:jsxRuntime.jsxs("div",{ref:_,className:le,style:{position:"relative",width:"100%",height:"100%",...n},children:[t(oe),L&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:["top","bottom","left","right"].map(g=>jsxRuntime.jsx(Se,{id:`drop-${g}-${e}`,position:g,activeClassName:a.dropPreview},g))}),i!==null&&i!==e&&T&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(Se,{id:`drop-locked-${e}`,position:"full",activeClassName:a.lockedPreview||""})})]})})};exports.DEFAULT_DRAG_ACTIVATION_DISTANCE=$t;exports.DEFAULT_RESIZER_SIZE=Qn;exports.DEFAULT_SNAP_THRESHOLD=kt;exports.DragHandle=In;exports.Pane=Nn;exports.PaneTree=bn;exports.PortalRegistryContext=Re;exports.Tabs=Wn;exports.Widget=Jn;exports.Zeugma=en;exports.ZeugmaActionsContext=Ye;exports.ZeugmaDragContext=Je;exports.ZeugmaStateContext=Xe;exports.createDragSession=pt;exports.safeJsonStringify=Ze;exports.useResizer=Ge;exports.useTabContext=An;exports.useZeugma=zt;exports.useZeugmaActions=De;exports.useZeugmaContext=At;exports.useZeugmaDrag=Fe;exports.useZeugmaState=re;//# sourceMappingURL=index.cjs.map
7
7
  //# sourceMappingURL=index.cjs.map