react-zeugma 6.9.1 → 6.9.2

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
@@ -96,29 +96,29 @@ import { Zeugma } from 'react-zeugma'
96
96
 
97
97
  ##### Props
98
98
 
99
- | Property | Description | Type | Default |
100
- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
101
- | `controller` | The layout state controller returned by `useZeugma(options)`. | `ZeugmaController` | - |
102
- | `children` | Children components rendered inside the context provider. | `ReactNode` | - |
103
- | `renderPane` | Callback function to map active pane IDs to custom pane structures. Required in standalone mode (without children) and must not be passed in provider mode. | `(paneId: string) => ReactNode` | - |
104
- | `renderDragOverlay` | Custom overlay renderer function for the drag-under-cursor preview. | `(active: DragOverlayActiveItem) => ReactNode` | - |
105
- | `classNames` | CSS class name mapping overrides for custom dashboard and overlay styling. | `ZeugmaClassNames` | - |
106
- | `resizerSize` | Thickness of the split resizer bars in pixels. | `number` | `4` |
107
- | `dragActivationDistance` | Minimum pointer drag distance (in pixels) required to activate dragging. | `number` | `8` |
108
- | `snapThreshold` | Threshold in pixels to snap layout resizers to adjacent edges. | `number` | `8` |
109
- | `minSplitPercentage` | Minimum split limit percentage allowed for resized panes. | `number` | `5` |
110
- | `maxSplitPercentage` | Maximum split limit percentage allowed for resized panes. | `number` | `95` |
111
- | `enableDragToDismiss` | Enables drag-out-to-dismiss gesture for widgets. | `boolean` | `false` |
112
- | `dismissThreshold` | Distance in pixels outside container bounds required to trigger dismissal. | `number` | `60` |
113
- | `onRemove` | Callback triggered when a pane is removed. | `(paneId: string) => void` | - |
114
- | `onDragStart` | Callback triggered when a drag gesture begins. | `(activeId: string) => void` | - |
115
- | `onDragEnd` | Callback triggered when a drag gesture ends, containing active pane, target pane, and action metadata. | `(activeId: string, overId: string \| null, dropAction: { type: 'split' \| 'move'; direction?: SplitDirection; position?: 'top' \| 'bottom' \| 'left' \| 'right' \| 'center' } \| null) => void` | - |
116
- | `onResizeStart` | Callback triggered when resizing begins. | `(currentNode: SplitNode) => void` | - |
117
- | `onResize` | Callback triggered during pane resizing. | `(currentNode: SplitNode, percentage: number) => void` | - |
118
- | `onResizeEnd` | Callback triggered when pane resizing completes. | `(currentNode: SplitNode, percentage: number) => void` | - |
119
- | `onDismissIntentChange` | Callback triggered when drag-out dismiss intent changes. | `(paneId: string \| null) => void` | - |
120
- | `persist` | Layout persistence configuration in localStorage. If true, uses default options. | `boolean \| ZeugmaPersistOptions` | `false` |
121
- | `renderPopoutWrapper` | Custom wrapper to inject context or style managers (e.g. `styled-components`' `StyleSheetManager` or `antd`'s `StyleProvider`/`ConfigProvider`) into popout windows. | `(props: { tabId: string; document: Document; window: Window; children: React.ReactNode }) => React.ReactNode` | - |
99
+ | Property | Description | Type | Default |
100
+ | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
101
+ | `controller` | The layout state controller returned by `useZeugma(options)`. | `ZeugmaController` | - |
102
+ | `children` | Children components rendered inside the context provider. | `ReactNode` | - |
103
+ | `renderPane` | Callback function to map active pane IDs to custom pane structures. Required in standalone mode (without children) and must not be passed in provider mode. | `(paneId: string) => ReactNode` | - |
104
+ | `renderDragOverlay` | Custom overlay renderer function for the drag-under-cursor preview. | `(active: DragOverlayActiveItem) => ReactNode` | - |
105
+ | `classNames` | CSS class name mapping overrides for custom dashboard and overlay styling. | `ZeugmaClassNames` | - |
106
+ | `resizerSize` | Thickness of the split resizer bars in pixels. | `number` | `4` |
107
+ | `dragActivationDistance` | Minimum pointer drag distance (in pixels) required to activate dragging. | `number` | `8` |
108
+ | `snapThreshold` | Threshold in pixels to snap layout resizers to adjacent edges. | `number` | `8` |
109
+ | `minSplitPercentage` | Minimum split limit percentage allowed for resized panes. | `number` | `5` |
110
+ | `maxSplitPercentage` | Maximum split limit percentage allowed for resized panes. | `number` | `95` |
111
+ | `enableDragToDismiss` | Enables drag-out-to-dismiss gesture for widgets. | `boolean` | `false` |
112
+ | `dismissThreshold` | Distance in pixels outside container bounds required to trigger dismissal. | `number` | `60` |
113
+ | `onRemove` | Callback triggered when a pane is removed. | `(paneId: string) => void` | - |
114
+ | `onDragStart` | Callback triggered when a drag gesture begins. | `(activeId: string) => void` | - |
115
+ | `onDragEnd` | Callback triggered when a drag gesture ends, containing active pane, target pane, and action metadata. | `(activeId: string, overId: string \| null, dropAction: { type: 'split' \| 'move'; direction?: SplitDirection; position?: 'top' \| 'bottom' \| 'left' \| 'right' \| 'center' } \| null) => void` | - |
116
+ | `onResizeStart` | Callback triggered when resizing begins. | `(currentNode: SplitNode) => void` | - |
117
+ | `onResize` | Callback triggered during pane resizing. | `(currentNode: SplitNode, percentage: number) => void` | - |
118
+ | `onResizeEnd` | Callback triggered when pane resizing completes. | `(currentNode: SplitNode, percentage: number) => void` | - |
119
+ | `onDismissIntentChange` | Callback triggered when drag-out dismiss intent changes. | `(paneId: string \| null) => void` | - |
120
+ | `persist` | Layout persistence configuration in localStorage. If true, uses default options. | `boolean \| ZeugmaPersistOptions` | `false` |
121
+ | `renderPopoutWrapper` | **[Experimental]** Custom wrapper to inject context or style managers (e.g. `styled-components`' `StyleSheetManager` or `antd`'s `StyleProvider`/`ConfigProvider`) into popout windows. | `(props: { tabId: string; document: Document; window: Window; children: React.ReactNode }) => React.ReactNode` | - |
122
122
 
123
123
  ##### `ZeugmaPersistOptions`
124
124
 
@@ -145,7 +145,7 @@ interface TabDetails {
145
145
  index: number
146
146
  /** Custom metadata associated with this tab. */
147
147
  metadata?: Record<string, unknown>
148
- /** Force-remount the component during window transitions instead of adopting the DOM node. */
148
+ /** **[Experimental]** Force-remount the component during window transitions instead of adopting the DOM node. */
149
149
  remountOnPopout?: boolean
150
150
  }
151
151
  ```
@@ -310,32 +310,32 @@ const { layout, locked, setLocked, addTab, removePane, selectTab, findPaneById }
310
310
 
311
311
  ##### Context Values
312
312
 
313
- | Property / Method | Description | Type |
314
- | ----------------------- | ---------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
315
- | `layout` | The current active layout tree structure. | `TreeNode \| null` |
316
- | `fullscreenPaneId` | The ID of the maximized fullscreen pane. | `string \| null` |
317
- | `locked` | Whether the dashboard layout is globally locked. | `boolean` |
318
- | `setLayout` | React state setter to update the layout tree. | `Dispatch<SetStateAction<TreeNode \| null>>` |
319
- | `setFullscreenPaneId` | Updates the active fullscreen pane ID. | `(paneId: string \| null) => void` |
320
- | `setLocked` | Updates the global layout lock state. | `Dispatch<SetStateAction<boolean>>` |
321
- | `removePane` | Removes a pane and collapses the split. | `(paneId: string) => void` |
322
- | `addTab` | Adds a tab to a pane, or splits/creates one if target is omitted. | `(tabId: string, targetPaneId?: string, metadata?: Record<string, unknown>) => void` |
323
- | `updateMetadata` | Mutates a specific tab's metadata. | `(id: string, updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
324
- | `updatePaneLock` | Toggles the lock status of a specific pane. | `(paneId: string, locked: boolean) => void` |
325
- | `selectTab` | Focuses/activates a tab within a pane. | `(paneId: string, tabId: string) => void` |
326
- | `mergeTab` | Programmatically drags and drops a tab from one pane to another. | `(draggedTabId: string, targetPaneId: string) => void` |
327
- | `removeTab` | Programmatically closes a tab. | `(tabId: string) => void` |
328
- | `splitPane` | Programmatically splits a pane node and adds a new one. | `(targetId: string, direction: SplitDirection, splitType: 'left' \| 'right' \| 'top' \| 'bottom', paneToAdd: string) => void` |
329
- | `updateSplitPercentage` | Updates a SplitNode percentage. | `(currentNode: SplitNode, percentage: number) => void` |
330
- | `moveTab` | Reorders a tab next to another, or swaps them if position is 'center'. | `(draggedTabId: string, targetTabId: string, position?: 'before' \| 'after' \| 'center') => void` |
331
- | `findPaneById` | Queries a PaneNode by its unique ID. | `(paneId: string) => PaneNode \| null` |
332
- | `findPaneContainingTab` | Queries the parent PaneNode of a tab ID. | `(tabId: string) => PaneNode \| null` |
333
- | `findTabById` | Queries detailed tab location and state metadata. | `(tabId: string) => TabDetails \| null` |
334
- | `getTabMetadata` | Gets metadata for a tab ID. | `(tabId: string) => Record<string, unknown> \| undefined` |
335
- | `getActiveTabMetadata` | Gets metadata for the active tab in a pane. | `(paneId: string) => Record<string, unknown> \| undefined` |
336
- | `poppedOutTabIds` | The list of tab/widget IDs that are currently open in a new window. | `string[]` |
337
- | `popoutTab` | Popout the specified tab into a new window. | `(tabId: string) => void` |
338
- | `dockTab` | Dock the specified tab back to the main layout. | `(tabId: string) => void` |
313
+ | Property / Method | Description | Type |
314
+ | ----------------------- | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
315
+ | `layout` | The current active layout tree structure. | `TreeNode \| null` |
316
+ | `fullscreenPaneId` | The ID of the maximized fullscreen pane. | `string \| null` |
317
+ | `locked` | Whether the dashboard layout is globally locked. | `boolean` |
318
+ | `setLayout` | React state setter to update the layout tree. | `Dispatch<SetStateAction<TreeNode \| null>>` |
319
+ | `setFullscreenPaneId` | Updates the active fullscreen pane ID. | `(paneId: string \| null) => void` |
320
+ | `setLocked` | Updates the global layout lock state. | `Dispatch<SetStateAction<boolean>>` |
321
+ | `removePane` | Removes a pane and collapses the split. | `(paneId: string) => void` |
322
+ | `addTab` | Adds a tab to a pane, or splits/creates one if target is omitted. | `(tabId: string, targetPaneId?: string, metadata?: Record<string, unknown>) => void` |
323
+ | `updateMetadata` | Mutates a specific tab's metadata. | `(id: string, updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
324
+ | `updatePaneLock` | Toggles the lock status of a specific pane. | `(paneId: string, locked: boolean) => void` |
325
+ | `selectTab` | Focuses/activates a tab within a pane. | `(paneId: string, tabId: string) => void` |
326
+ | `mergeTab` | Programmatically drags and drops a tab from one pane to another. | `(draggedTabId: string, targetPaneId: string) => void` |
327
+ | `removeTab` | Programmatically closes a tab. | `(tabId: string) => void` |
328
+ | `splitPane` | Programmatically splits a pane node and adds a new one. | `(targetId: string, direction: SplitDirection, splitType: 'left' \| 'right' \| 'top' \| 'bottom', paneToAdd: string) => void` |
329
+ | `updateSplitPercentage` | Updates a SplitNode percentage. | `(currentNode: SplitNode, percentage: number) => void` |
330
+ | `moveTab` | Reorders a tab next to another, or swaps them if position is 'center'. | `(draggedTabId: string, targetTabId: string, position?: 'before' \| 'after' \| 'center') => void` |
331
+ | `findPaneById` | Queries a PaneNode by its unique ID. | `(paneId: string) => PaneNode \| null` |
332
+ | `findPaneContainingTab` | Queries the parent PaneNode of a tab ID. | `(tabId: string) => PaneNode \| null` |
333
+ | `findTabById` | Queries detailed tab location and state metadata. | `(tabId: string) => TabDetails \| null` |
334
+ | `getTabMetadata` | Gets metadata for a tab ID. | `(tabId: string) => Record<string, unknown> \| undefined` |
335
+ | `getActiveTabMetadata` | Gets metadata for the active tab in a pane. | `(paneId: string) => Record<string, unknown> \| undefined` |
336
+ | `poppedOutTabIds` | **[Experimental]** The list of tab/widget IDs that are currently open in a new window. | `string[]` |
337
+ | `popoutTab` | **[Experimental]** Popout the specified tab into a new window. | `(tabId: string) => void` |
338
+ | `dockTab` | **[Experimental]** Dock the specified tab back to the main layout. | `(tabId: string) => void` |
339
339
 
340
340
  ---
341
341
 
@@ -364,25 +364,25 @@ const {
364
364
 
365
365
  ##### Context Values
366
366
 
367
- | Property / Method | Description | Type |
368
- | ---------------------- | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
369
- | `id` | The ID of the current pane. | `string` |
370
- | `tabIds` | List of tab IDs inside the pane. | `string[]` |
371
- | `activeTabId` | Currently active tab ID. | `string` |
372
- | `isDragging` | `true` if this pane is being dragged. | `boolean` |
373
- | `isFullscreen` | `true` if this pane is maximized. | `boolean` |
374
- | `toggleFullscreen` | Toggles maximized state for this pane. | `() => void` |
375
- | `remove` | Removes this pane from the layout tree. | `() => void` |
376
- | `selectTab` | Activates a tab within this pane. | `(tabId: string) => void` |
377
- | `removeTab` | Closes a tab from this pane. | `(tabId: string) => void` |
378
- | `metadata` | Active tab's custom metadata. | `Record<string, unknown> \| undefined` |
379
- | `updateMetadata` | Updates active tab's metadata. | `(updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
380
- | `locked` | Whether the pane or the dashboard is locked. | `boolean` |
381
- | `tabsMetadata` | Tab metadata mapping for all tabs inside this pane. | `Record<string, Record<string, unknown>> \| undefined` |
382
- | `updateTabMetadata` | Updates metadata for a specific tab in the pane. | `(tabId: string, updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
383
- | `isActiveTabPoppedOut` | Whether the active tab is popped out into a new window. | `boolean` |
384
- | `popoutTab` | Popout the active tab into a new window. | `(tabId?: string) => void` |
385
- | `dockTab` | Dock the active tab back to the main layout. | `(tabId?: string) => void` |
367
+ | Property / Method | Description | Type |
368
+ | ---------------------- | -------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
369
+ | `id` | The ID of the current pane. | `string` |
370
+ | `tabIds` | List of tab IDs inside the pane. | `string[]` |
371
+ | `activeTabId` | Currently active tab ID. | `string` |
372
+ | `isDragging` | `true` if this pane is being dragged. | `boolean` |
373
+ | `isFullscreen` | `true` if this pane is maximized. | `boolean` |
374
+ | `toggleFullscreen` | Toggles maximized state for this pane. | `() => void` |
375
+ | `remove` | Removes this pane from the layout tree. | `() => void` |
376
+ | `selectTab` | Activates a tab within this pane. | `(tabId: string) => void` |
377
+ | `removeTab` | Closes a tab from this pane. | `(tabId: string) => void` |
378
+ | `metadata` | Active tab's custom metadata. | `Record<string, unknown> \| undefined` |
379
+ | `updateMetadata` | Updates active tab's metadata. | `(updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
380
+ | `locked` | Whether the pane or the dashboard is locked. | `boolean` |
381
+ | `tabsMetadata` | Tab metadata mapping for all tabs inside this pane. | `Record<string, Record<string, unknown>> \| undefined` |
382
+ | `updateTabMetadata` | Updates metadata for a specific tab in the pane. | `(tabId: string, updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
383
+ | `isActiveTabPoppedOut` | **[Experimental]** Whether the active tab is popped out into a new window. | `boolean` |
384
+ | `popoutTab` | **[Experimental]** Popout the active tab into a new window. | `(tabId?: string) => void` |
385
+ | `dockTab` | **[Experimental]** Dock the active tab back to the main layout. | `(tabId?: string) => void` |
386
386
 
387
387
  ---
388
388
 
@@ -498,7 +498,10 @@ const parentPane = findPaneContainingTab(currentTree, 'new-file.js')
498
498
 
499
499
  ---
500
500
 
501
- ## Popout Window Styling (CSS-in-JS support)
501
+ ## Popout Window Styling (Experimental)
502
+
503
+ > [!WARNING]
504
+ > Popout window capabilities (opening tabs in separate browser windows via `window.open` and React portals) are **experimental** and may experience limitations or browser warnings depending on popup blockers, iframe restrictions, and context cleanup in third-party libraries. Use with caution in production.
502
505
 
503
506
  When using CSS-in-JS libraries like `styled-components` or `antd` (Ant Design) inside your widgets, dynamic styles and modals/portals are injected into the main document's `head`/`body` by default. In popped-out tabs, these styles will not apply because they render inside a separate window.
504
507
 
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var me=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 me__default=/*#__PURE__*/_interopDefault(me);function Ct({cursor:e,resizerEl:t,onMove:n,onEnd:r}){document.body.classList.add("zeugma-resizing");let o=document.createElement("style");o.id="zeugma-global-cursor-style",o.textContent=`
1
+ 'use strict';var ge=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 ge__default=/*#__PURE__*/_interopDefault(ge);function Nt({cursor:e,resizerEl:t,onMove:n,onEnd:a}){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;
@@ -6,6 +6,7 @@
6
6
  .zeugma-resizing *:not([role="separator"]) {
7
7
  pointer-events: none !important;
8
8
  }
9
- `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let s=a=>{n(a);},l=()=>{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",l),r();};document.addEventListener("pointermove",s),document.addEventListener("pointerup",l);}function Me(e){try{return JSON.stringify(e)}catch{return ""}}var ct=me.createContext(void 0),xe=me.createContext(void 0),ye=me.createContext(void 0),ut=me.createContext(void 0),re=()=>{let e=me.useContext(ct);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},ze=()=>{let e=me.useContext(xe);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},qe=()=>{let e=me.useContext(ut);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function St(e){let t=me.useRef(null);return me.useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},r=o=>{let s=o.touches[0]||o.changedTouches[0];s&&(t.current={x:s.clientX,y:s.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",r,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",r);}},[e]),t}function Nt(e){me.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function It(){let[e,t]=me.useState({}),[n,r]=me.useState({}),o=me.useRef({}),s=me.useRef(null),l=me.useRef({}),a=me.useRef(null),c=me.useRef(true);me.useEffect(()=>(c.current=true,()=>{c.current=false;}),[]);let f=me.useCallback((u,m,y)=>{c.current&&t(b=>{if(!m){if(y&&b[u]!==y||!b[u])return b;let S={...b};return delete S[u],S}return b[u]===m?b:{...b,[u]:m}});},[]),i=me.useCallback((u,m)=>{c.current&&r(y=>{if(!m){if(!y[u])return y;let b={...y};return delete b[u],b}return y[u]===m?y:{...y,[u]:m}});},[]),h=me.useCallback((u,m)=>{o.current[u]=m;},[]),v=me.useCallback(u=>{s.current=u;},[]),g=me.useCallback((u,m)=>{l.current[u]=m;},[]);return {portalTargets:me.useMemo(()=>({...e,...n}),[e,n]),registerPortalTarget:f,registerPopoutTarget:i,registerRenderCallback:h,renderCallbacksRef:o,registerRenderPane:v,renderPaneRef:s,registerTabHeader:g,tabHeadersRef:l,activeIdRef:a}}function Ln(e){let t=new Set;function n(r){r&&(r.type==="pane"?r.tabIds.forEach(o=>{t.add(o);}):r.type==="split"&&(n(r.first),n(r.second)));}return n(e),Array.from(t).sort()}function Lt(e){return me.useMemo(()=>Ln(e),[e])}function kt(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=me.useState(null),[s,l]=me.useState(null),a=me.useCallback(f=>{t&&t(f);},[t]),c=me.useCallback((f,i,h)=>{n&&n(f,i,h);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:s,setOverTabPosition:l,handleDragStartInternal:a,handleDragEndInternal:c}}function Mt(e){let n=me.useContext(ye)?.registerRenderPane;me.useEffect(()=>{n&&e&&n(e);},[n,e]);}function pe(){return "pane-"+Math.random().toString(36).substring(2,11)}function ge(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null:e;let n=ge(e.first,t),r=ge(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function fe(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let o=e.tabIds.filter(a=>a!==t);if(o.length===0)return null;let s=e.activeTabId;e.activeTabId===t&&(s=o[0]);let l={...e.tabsMetadata};return delete l[t],{...e,tabIds:o,activeTabId:s,tabsMetadata:Object.keys(l).length>0?l:void 0}}return e}let n=fe(e.first,t),r=fe(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function Ee(e,t,n,r,o){if(e===null)return typeof o=="string"?{type:"pane",id:pe(),tabIds:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let s=typeof o=="string"?{type:"pane",id:pe(),tabIds:[o],activeTabId:o}:o,l=r==="left"||r==="top";return {type:"split",direction:n,first:l?s:e,second:l?e:s,splitPercentage:50}}return e}return {...e,first:Ee(e.first,t,n,r,o)||e.first,second:Ee(e.second,t,n,r,o)||e.second}}function kn(e,t){if(e===null)return t;function n(r,o){return r.type==="pane"?{type:"split",direction:o==="row"?"column":"row",splitPercentage:50,first:r,second:t}:{...r,second:n(r.second,r.direction)}}return n(e,null)}function zt(e,t,n,r){if(e===null)return {type:"pane",id:pe(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};let o=t?te(e,t):null;if(o&&o.type==="pane"){let a=function(c){if(c.type==="pane"&&c.id===t){let f=[...c.tabIds];f.includes(n)||f.push(n);let i=c.tabsMetadata;return r&&(i={...c.tabsMetadata,[n]:r}),{...c,tabIds:f,activeTabId:n,tabsMetadata:i}}return c.type==="split"?{...c,first:a(c.first),second:a(c.second)}:c};return a(e)}let s={type:"pane",id:pe(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};return kn(e,s)}function we(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:we(e.first,t,n)||e.first,second:we(e.second,t,n)||e.second}:e}function te(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?te(e.first,t)??te(e.second,t):null}function q(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?q(e.first,t)??q(e.second,t):null}function At(e,t){return te(e,t)??q(e,t)}function Zt(e,t){let n=q(e,t);if(!n)return null;let r=n.tabIds.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:r,metadata:n.tabsMetadata?.[t],remountOnPopout:n.tabsMetadata?.[t]?.remountOnPopout}}function Ot(e,t){return q(e,t)?.tabsMetadata?.[t]}function $t(e,t){let n=te(e,t);return n?.tabsMetadata?.[n.activeTabId]}function Xe(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let r=e.tabsMetadata||{},o=r[t],s=n(o),l={...r};return s===void 0?delete l[t]:l[t]=s,{...e,tabsMetadata:Object.keys(l).length>0?l:void 0}}return e}return e.type==="split"?{...e,first:Xe(e.first,t,n)??e.first,second:Xe(e.second,t,n)??e.second}:e}function Je(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:r,...o}=e;return o}return {...e,locked:n}}return e}return e.type==="split"?{...e,first:Je(e.first,t,n)??e.first,second:Je(e.second,t,n)??e.second}:e}function Se(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:Se(e.first,t,n)??e.first,second:Se(e.second,t,n)??e.second}:e}function Ht(e,t,n){if(e===null)return null;let o=q(e,t)?.tabsMetadata?.[t],s=fe(e,t);if(s===null)return {type:"pane",id:pe(),tabIds:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function l(a){if(a.type==="pane"){if(a.id===n){let c=[...a.tabIds];c.includes(t)||c.push(t);let f={...a.tabsMetadata};return o&&(f[t]=o),{...a,tabIds:c,activeTabId:t,tabsMetadata:Object.keys(f).length>0?f:void 0}}return a}return a.type==="split"?{...a,first:l(a.first),second:l(a.second)}:a}return l(s)}function Mn(e,t,n){if(e===null)return null;if(t===n)return e;let r=q(e,t),o=q(e,n);if(!r||!o)return e;let s=r.id,l=o.id,a=r.tabsMetadata?.[t],c=o.tabsMetadata?.[n];function f(i){if(i.type==="pane"){let h=false,v=[...i.tabIds],g=i.activeTabId,d=i.tabsMetadata?{...i.tabsMetadata}:{};if(s===l){if(i.id===s){let u=v.indexOf(t),m=v.indexOf(n);u!==-1&&m!==-1&&(v[u]=n,v[m]=t),g=t,h=true;}}else i.id===s&&(v=v.map(u=>u===t?n:u),g===t&&(g=n),delete d[t],c&&(d[n]=c),h=true),i.id===l&&(v=v.map(u=>u===n?t:u),g===n&&(g=t),delete d[n],a&&(d[t]=a),h=true);return h?{...i,tabIds:v,activeTabId:g,tabsMetadata:Object.keys(d).length>0?d:void 0}:i}return i.type==="split"?{...i,first:f(i.first),second:f(i.second)}:i}return f(e)}function Ae(e,t,n,r="before"){if(e===null)return null;if(t===n)return e;if(r==="center")return Mn(e,t,n);let s=q(e,t)?.tabsMetadata?.[t],l=fe(e,t);if(l===null)return {type:"pane",id:pe(),tabIds:[t],activeTabId:t,tabsMetadata:s?{[t]:s}:void 0};function a(c){if(c.type==="pane"){if(c.tabIds.includes(n)){let i=[...c.tabIds].filter(g=>g!==t),h=i.indexOf(n);h<0&&(h=0),r==="after"&&(h+=1),i.splice(h,0,t);let v={...c.tabsMetadata};return s&&(v[t]=s),{...c,tabIds:i,activeTabId:t,tabsMetadata:Object.keys(v).length>0?v:void 0}}return c}return c.type==="split"?{...c,first:a(c.first),second:a(c.second)}:c}return a(l)}function ve(e,t=0,n=0,r=100,o=100,s="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:r,height:o,node:e}],splitters:[]};let{direction:l,splitPercentage:a,first:c,second:f}=e,h={id:`splitter-${s}-${l}`,currentNode:e,direction:l,left:l==="row"?t+r*(a/100):t,top:l==="column"?n+o*(a/100):n,width:l==="row"?0:r,height:l==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:r,parentHeight:o},v={panes:[],splitters:[]},g={panes:[],splitters:[]};if(l==="row"){let d=r*(a/100);v=ve(c,t,n,d,o,`${s}-L`),g=ve(f,t+d,n,r-d,o,`${s}-R`);}else {let d=o*(a/100);v=ve(c,t,n,r,d,`${s}-T`),g=ve(f,t,n+d,r,o-d,`${s}-B`);}return {panes:[...v.panes,...g.panes],splitters:[h,...v.splitters,...g.splitters]}}function _t(e,t,n,r="before"){if(e===null)return null;let o=te(e,t);if(!o)return e;let s=o.tabIds,l=o.activeTabId,a=o.tabsMetadata||{},c=ge(e,t);if(c===null)return o;function f(i){if(i.type==="pane"){if(i.tabIds.includes(n)){let v=[...i.tabIds].filter(u=>!s.includes(u)),g=v.indexOf(n);g<0&&(g=0),r==="after"&&(g+=1),v.splice(g,0,...s);let d={...i.tabsMetadata};for(let u of s)a[u]&&(d[u]=a[u]);return {...i,tabIds:v,activeTabId:l,tabsMetadata:Object.keys(d).length>0?d:void 0}}return i}return i.type==="split"?{...i,first:f(i.first),second:f(i.second)}:i}return f(c)}function Bt(e,t,n,r){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!r)return -1;let l=e.indexOf(n);return r==="before"?l:l+1}function zn(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:s,locked:l=false}=e,[a,c]=me.useState(()=>n!==void 0?n:t??null),[f,i]=me.useState(()=>n!==void 0?n:t??null),[h,v]=me.useState(()=>Me(n!==void 0?n:null)),[g,d]=me.useState(o||null),[u,m]=me.useState(l),[y,b]=me.useState([]),[S,N]=me.useState(null),[z,A]=me.useState(null),[x,L]=me.useState(null),F=me.useRef(null),j=me.useCallback(p=>{F.current=p;},[]),H=me.useRef(a);H.current=a;let J=me.useRef(r);J.current=r;let ne=me.useRef(s);ne.current=s;let Y=me.useCallback(p=>{d(p),ne.current?.(p);},[]);if(me.useEffect(()=>{m(l);},[l]),me.useEffect(()=>{o!==void 0&&d(o);},[o]),n!==void 0){let p=Me(n);p!==h&&(v(p),c(n),i(n));}let k=me.useCallback(p=>(...P)=>{let R=H.current,O=p(R,...P);Me(R)!==Me(O)&&(H.current=O,c(O),i(O),J.current?.(O));},[]),Z=me.useCallback(k((p,P)=>typeof P=="function"?P(p):P),[k]),V=me.useCallback(p=>{i(P=>typeof p=="function"?p(P):p);},[]),_=me.useCallback(p=>{d(null),ne.current?.(null),N(null),A(null),L(null),Z(p),i(()=>typeof p=="function"?p(H.current):p);},[Z]),$=me.useCallback(k((p,P)=>ge(p,P)),[k]),C=me.useCallback(k((p,P,R,O)=>{let B=fe(p,P)??p;return zt(B,R,P,O)}),[k]),T=me.useCallback(k((p,P,R,O,B)=>{let le=te(p,P)??q(p,P);if(!le)return p;let W=te(p,B)??q(p,B)??{type:"pane",id:B,tabIds:[B],activeTabId:B},Pe=ge(p,W.id);return Ee(Pe,le.id,R,O,W)}),[k]),M=me.useCallback(k((p,P,R)=>we(p,P,R)),[k]),w=me.useCallback(k((p,P,R)=>Xe(p,P,R)),[k]),I=me.useCallback(k((p,P,R)=>{let O=te(p,P)??q(p,P);return O?Je(p,O.id,R):p}),[k]),ue=me.useCallback(k((p,P,R)=>{let O=te(p,P)??q(p,P);return O?Se(p,O.id,R):p}),[k]),Q=me.useCallback(k((p,P,R)=>{let O=te(p,R)??q(p,R);return O?Ht(p,P,O.id):p}),[k]),K=me.useCallback(k((p,P,R,O)=>Ae(p,P,R,O)),[k]),X=me.useCallback(k((p,P)=>fe(p,P)),[k]),ee=me.useCallback(p=>te(H.current,p),[]),D=me.useCallback(p=>q(H.current,p),[]),E=me.useCallback(p=>Zt(H.current,p),[]),ae=me.useCallback(p=>Ot(H.current,p),[]),ie=me.useCallback(p=>$t(H.current,p),[]),G=me.useCallback(p=>{b(P=>P.includes(p)?P:[...P,p]);},[]),oe=me.useCallback(p=>{b(P=>P.includes(p)?P.filter(R=>R!==p):P);},[]);return {layout:a,setLayout:_,_internalSetLayout:V,renderingLayout:f,fullscreenPaneId:g,setFullscreenPaneId:Y,locked:u,setLocked:m,poppedOutTabIds:y,activeId:S,setActiveId:N,activeType:z,setActiveType:A,dismissIntentId:x,setDismissIntentId:L,containerRef:F,setContainerRef:j,removePane:$,addTab:C,updateMetadata:w,updatePaneLock:I,selectTab:ue,mergeTab:Q,moveTab:K,removeTab:X,splitPane:T,updateSplitPercentage:M,popoutTab:G,dockTab:oe,findPaneById:ee,findPaneContainingTab:D,findTabById:E,getTabMetadata:ae,getActiveTabMetadata:ie}}var An=()=>{let e=re(),t=ze();return {layout:e.layout,setLayout:e.setLayout,fullscreenPaneId:e.fullscreenPaneId,setFullscreenPaneId:t.setFullscreenPaneId,locked:e.locked,setLocked:t.setLocked,removePane:t.removePane,addTab:t.addTab,updateMetadata:t.updateMetadata,updatePaneLock:t.updatePaneLock,selectTab:t.selectTab,mergeTab:t.mergeTab,removeTab:t.removeTab,splitPane:t.splitPane,updateSplitPercentage:t.updateSplitPercentage,moveTab:t.moveTab,findPaneById:e.findPaneById,findPaneContainingTab:e.findPaneContainingTab,findTabById:e.findTabById,getTabMetadata:e.getTabMetadata,getActiveTabMetadata:e.getActiveTabMetadata,poppedOutTabIds:e.poppedOutTabIds,popoutTab:t.popoutTab,dockTab:t.dockTab}};var Ge=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Qe=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var Vt=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((l,a)=>{let c=l.id.toString(),f=a.id.toString(),i=c.startsWith("tab-drop-"),h=f.startsWith("tab-drop-");if(i&&!h)return -1;if(!i&&h)return 1;let v=c.startsWith("drop-root-"),g=f.startsWith("drop-root-");return v&&!g?-1:!v&&g?1:0});if(n){let s=e.droppableContainers.filter(l=>l.id.toString().startsWith("tab-drop-"));return core.closestCenter({...e,droppableContainers:s})}return []};function Ze(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 Ut(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:s,activeType:l,setActiveType:a,dismissIntentId:c,setDismissIntentId:f,setOverTabId:i,setOverTabPosition:h,containerRef:v,dragActivationDistance:g,enableDragToDismiss:d,dismissThreshold:u,onRemove:m,onDragStart:y,onDragEnd:b,onDismissIntentChange:S,removeTab:N,removePane:z}=e,A=me.useRef(null),x=St(o),L=me.useRef(null),[F,j]=me.useState(false);return Nt(F),{sensors:core.useSensors(core.useSensor(Ge,{activationConstraint:{distance:g}}),core.useSensor(Qe,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:Vt,onDragStart:Z=>{let V=Z.active.id.toString(),_=V.startsWith("tab-header-"),$=_?V.substring(11):V;s($),a(_?"tab":"pane"),i(null),h(null);let C=Z.activatorEvent;x.current=Ze(C),d&&v.current?A.current=v.current.getBoundingClientRect():A.current=null;let T=t;if(_){let w=q(t,$);w&&(T=Se(t,w.id,$)||t);}L.current=T;let M=_?fe(T,$):ge(T,$);n(M),y&&y($);},onDragMove:Z=>{let{over:V}=Z,_=V?.id.toString()||"",$=_.startsWith("drop-locked-");j(D=>D===$?D:$);let C=Z.active.id.toString(),T=C.startsWith("tab-header-"),M=T?C.substring(11):C,w=_.match(/^tab-drop-(.+)$/);if(w&&V&&(T||l==="pane")){let[,D]=w;if(M!==D){let E="before",ae=V.rect,ie=Z.activatorEvent,G=null;if(x.current)G=x.current.x;else {let oe=Ze(ie);oe&&(G=oe.x+Z.delta.x);}if(G!==null){let oe=ae.left+ae.width/2;G>oe&&(E="after");}i(oe=>oe===D?oe:D),h(oe=>oe===E?oe:E);}else i(E=>E===null?E:null),h(E=>E===null?E:null);}else i(D=>D===null?D:null),h(D=>D===null?D:null);if(!d)return;let I=A.current;if(!I){c!==null&&(f(null),S?.(null));return}let ue=Z.activatorEvent,Q=null,K=null;if(x.current)Q=x.current.x,K=x.current.y;else {let D=Ze(ue);D&&(Q=D.x+Z.delta.x,K=D.y+Z.delta.y);}let X=0;if(Q!==null&&K!==null){let D=0,E=0;Q<I.left?D=I.left-Q:Q>I.right&&(D=Q-I.right),K<I.top?E=I.top-K:K>I.bottom&&(E=K-I.bottom),X=Math.sqrt(D*D+E*E);}else {let D=Z.active.rect.current.translated;if(D){let E=D.left+D.width/2,ae=D.top+D.height/2,ie=0,G=0;E<I.left?ie=I.left-E:E>I.right&&(ie=E-I.right),ae<I.top?G=I.top-ae:ae>I.bottom&&(G=ae-I.bottom),X=Math.sqrt(ie*ie+G*G);}}X>u?c!==M&&(f(M),S?.(M)):c!==null&&(f(null),S?.(null));},onDragEnd:Z=>{s(null),a(null),j(false),i(null),h(null);let{active:V,over:_}=Z,$=V.id.toString(),C=$.startsWith("tab-header-"),T=C?$.substring(11):$,M=d&&c===T;f(null),S?.(null),A.current=null;let w=L.current||t;if(L.current=null,M){m?m(T):C?N(T):z(T),b&&b(T,null,null);return}if(!_){n(w),b&&b(T,null,null);return}let I=_.id.toString();if(I.startsWith("drop-locked-")){n(w),b&&b(T,null,null);return}let ue=I.match(/^tab-drop-(.+)$/);if(ue){let[,p]=ue;if(C)if(T!==p){let P="before",R=_.rect,O=Z.activatorEvent,B=null;if(x.current)B=x.current.x;else {let W=Ze(O);W&&(B=W.x+Z.delta.x);}if(B!==null){let W=R.left+R.width/2;B>W&&(P="after");}let le=Ae(w,T,p,P);r(le),b&&b(T,p,{type:"move",position:"center"});}else n(w),b&&b(T,null,null);else {let P="before",R=_.rect,O=Z.activatorEvent,B=null;if(x.current)B=x.current.x;else {let W=Ze(O);W&&(B=W.x+Z.delta.x);}if(B!==null){let W=R.left+R.width/2;B>W&&(P="after");}let le=_t(w,T,p,P);r(le),b&&b(T,p,{type:"move",position:"center"});}return}let Q=I.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(Q){let[,p,P]=Q,R=P;R==="start"&&(R="left"),R==="end"&&(R="right");let O=C?fe(w,T):ge(w,T),B;if(C){let W=q(w,T)?.tabsMetadata?.[T];B={type:"pane",id:pe(),tabIds:[T],activeTabId:T,tabsMetadata:W?{[T]:W}:void 0};}else B=te(w,T)??{type:"pane",id:pe(),tabIds:[T],activeTabId:T};if(O===null)r(B);else {let le=R==="left"||R==="right",W=R==="left"||R==="top",Pe=50;p==="1/4"?Pe=W?25:75:p==="1/3"&&(Pe=W?100/3:200/3),r({type:"split",direction:le?"row":"column",first:W?B:O,second:W?O:B,splitPercentage:Pe});}b&&b(T,"root",{type:"split",direction:R==="left"||R==="right"?"row":"column",position:R});return}let K=I.match(/^drop-(left|right|top|bottom|center)-(.+)$/);if(!K){n(w),b&&b(T,null,null);return}let[,X,ee]=K;if(X==="center"){if(C){let p=te(w,ee);if(p&&p.activeTabId){let P=p.activeTabId,R=Ae(w,T,P,"center");r(R),b&&b(T,ee,{type:"move",position:"center"});}else n(w),b&&b(T,null,null);}else n(w),b&&b(T,null,null);return}let D=C?q(w,T):te(w,T),E=D&&D.id===ee,ae=D&&D.tabIds.length===1;if(T===ee||E&&ae){n(w),b&&b(T,null,null);return}let ie=X==="left"||X==="right"?"row":"column",G;if(C){let P=q(w,T)?.tabsMetadata?.[T];G={type:"pane",id:pe(),tabIds:[T],activeTabId:T,tabsMetadata:P?{[T]:P}:void 0};}else G=te(w,T)??{type:"pane",id:pe(),tabIds:[T],activeTabId:T};let oe=C?fe(w,T):ge(w,T),ke=Ee(oe,ee,ie,X,G);r(ke),b&&b(T,ee,{type:"split",direction:ie,position:X});},onDragCancel:()=>{s(null),a(null),j(false),i(null),h(null),f(null),S?.(null),A.current=null;let Z=L.current||t;L.current=null,n(Z),Z!==t&&r(Z);}}}function Xt({persist:e,layout:t,setLayout:n}){let r=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[s,l]=me.useState(false);me.useEffect(()=>{if(r){let a=localStorage.getItem(o);if(a)try{let c=JSON.parse(a);c&&n(c);}catch(c){console.error("Failed to parse persisted zeugma layout",c);}}l(true);},[r,o,n]),me.useEffect(()=>{r&&s&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[r,o,t,s]);}var De=null,Yt=false,se=new Set,Ne=null;function Wn(){typeof window>"u"||Ne||(Ne=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.tagName.toLowerCase()==="style"||n.tagName.toLowerCase()==="link")&&se.forEach(r=>{try{let o=n.cloneNode(!0);if(o.tagName.toLowerCase()==="link"){let s=n.href;s&&o.setAttribute("href",s);}r.head.appendChild(o);}catch(o){console.warn("Failed to mirror style node to popout:",o);}});});});}),Ne.observe(document.head,{childList:true}));}function dt(){Ne&&(Ne.disconnect(),Ne=null);}var Gt=e=>{typeof requestAnimationFrame<"u"?requestAnimationFrame(e):setTimeout(e,0);};function be(){if(typeof window>"u")return document;if(De&&De.target){let t=De.target.ownerDocument;if(t&&t!==document)return t}let e=window.event;if(e&&e.target){let n=e.target.ownerDocument;if(n&&n!==document)return n}return window.__zeugmaActivePopoutDocument?window.__zeugmaActivePopoutDocument:document}function qn(){if(typeof window>"u"||Yt)return;Yt=true;let e=()=>{De=null,globalThis.__zeugmaActivePopoutDocument=null;};["pointerdown","mousedown","click","keydown","focus","touchstart"].forEach(d=>{window.addEventListener(d,e,true);});let n=document.createElement;document.createElement=function(d,u){let m=be();return m&&m!==document?m.createElement(d,u):n.call(document,d,u)};let r=document.body.appendChild;document.body.appendChild=function(d){let u=be();return u&&u!==document?u.body.appendChild(d):r.call(document.body,d)};let o=document.body.removeChild;document.body.removeChild=function(d){let u=be();return u&&u!==document?u.body.removeChild(d):o.call(document.body,d)};let s=document.body.insertBefore;document.body.insertBefore=function(d,u){let m=be();return m&&m!==document?m.body.insertBefore(d,u):s.call(document.body,d,u)};let l=document.body.replaceChild;document.body.replaceChild=function(d,u){let m=be();return m&&m!==document?m.body.replaceChild(d,u):l.call(document.body,d,u)};let a=document.addEventListener;document.addEventListener=function(d,u,m){let y=be();return y&&y!==document?y.addEventListener(d,u,m):a.call(document,d,u,m)};let c=document.removeEventListener;document.removeEventListener=function(d,u,m){c.call(document,d,u,m),se.forEach(y=>{try{y.removeEventListener(d,u,m);}catch{}});};let f=window.addEventListener;window.addEventListener=function(d,u,m){let y=be();return y&&y!==document&&y.defaultView?y.defaultView.addEventListener(d,u,m):f.call(window,d,u,m)};let i=window.removeEventListener;window.removeEventListener=function(d,u,m){i.call(window,d,u,m),se.forEach(y=>{try{y.defaultView&&y.defaultView.removeEventListener(d,u,m);}catch{}});};let h=document.getElementById;document.getElementById=function(d){let u=be();if(u&&u!==document)return u.getElementById(d);let m=h.call(document,d);if(m)return m;for(let y of se)try{let b=y.getElementById(d);if(b)return b}catch{}return null};let v=document.querySelector;document.querySelector=function(d){let u=be();if(u&&u!==document)return u.querySelector(d);let m=v.call(document,d);if(m)return m;for(let y of se)try{let b=y.querySelector(d);if(b)return b}catch{}return null};let g=document.querySelectorAll;document.querySelectorAll=function(d){let u=be();if(u&&u!==document)return u.querySelectorAll(d);let m=g.call(document,d);if(m.length>0)return m;for(let y of se)try{let b=y.querySelectorAll(d);if(b.length>0)return b}catch{}return m};}function Qt(e){let{poppedOutTabIds:t,registerPopoutTarget:n,findTabById:r,dockTab:o}=e,s=me.useRef({});me.useEffect(()=>{let l=s.current;t.forEach(a=>{if(l[a]){try{l[a].focus();}catch{}return}qn();let f=r(a)?.metadata?.title||`Tab ${a}`,i=window.open("",`zeugma-popout-${a}`,"width=800,height=600");if(!i){console.warn("Failed to open popout window. Check popup blocker."),o(a);return}l[a]=i,se.add(i.document),Wn(),i.document.title=f,i.document.head.innerHTML="",Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).forEach(x=>{let L=x.cloneNode(true);if(x.tagName.toLowerCase()==="link"){let F=x.href;F&&L.setAttribute("href",F);}else if(x.tagName.toLowerCase()==="style")try{let F=x.sheet?.cssRules;if(F&&F.length>0){let j=Array.from(F).map(H=>H.cssText).join(`
10
- `);L.textContent=j;}}catch{}i.document.head.appendChild(L);}),i.document.documentElement.className=document.documentElement.className,i.document.body.className=document.body.className,i.document.body.style.margin="0",i.document.body.style.padding="0",i.document.body.style.height="100vh",i.document.body.style.overflow="hidden";let h=document.getElementById(`zeugma-tab-target-${a}`),v="";h&&(v=window.getComputedStyle(h).backgroundColor,(!v||v==="transparent"||v==="rgba(0, 0, 0, 0)")&&h.parentElement&&(v=window.getComputedStyle(h.parentElement).backgroundColor));let g=window.getComputedStyle(document.documentElement),d=window.getComputedStyle(document.body),u=d.backgroundColor,y=!u||u==="transparent"||u==="rgba(0, 0, 0, 0)"?g.backgroundColor:u,b=v&&v!=="transparent"&&v!=="rgba(0, 0, 0, 0)"?v:y&&y!=="transparent"&&y!=="rgba(0, 0, 0, 0)"?y:"#181b1f";i.document.documentElement.style.backgroundColor=b,i.document.body.style.backgroundColor=b,i.document.body.style.color=d.color||g.color,i.document.body.style.fontFamily=d.fontFamily||g.fontFamily;let S=i.document.createElement("div");S.id=`zeugma-popout-container-${a}`,S.className="grafana-panel h-full w-full overflow-hidden",S.style.width="100%",S.style.height="100%",S.style.border="none",i.document.body.appendChild(S),n?.(a,S);let N=["pointerdown","mousedown","click","keydown","focus","touchstart"],z=x=>{De=x,globalThis.__zeugmaActivePopoutDocument=i.document,queueMicrotask(()=>{De===x&&(De=null,globalThis.__zeugmaActivePopoutDocument=null);});};N.forEach(x=>{i.addEventListener(x,z,true);});let A=()=>{se.delete(i.document),se.size===0&&dt(),o(a);};i.addEventListener("beforeunload",A),i.__zeugmaCleanup=()=>{N.forEach(x=>{i.removeEventListener(x,z,true);}),i.removeEventListener("beforeunload",A);};}),Object.keys(l).forEach(a=>{if(!t.includes(a)){let c=l[a];if(delete l[a],n?.(a,null),c){se.delete(c.document),se.size===0&&dt();try{let f=c;f.__zeugmaCleanup&&f.__zeugmaCleanup(),Gt(()=>{try{f.close();}catch{}});}catch{}}}});},[t,n,r,o]),me.useEffect(()=>()=>{let l=s.current;Object.keys(l).forEach(a=>{let c=l[a];if(c){se.delete(c.document);try{let f=c;f.__zeugmaCleanup&&f.__zeugmaCleanup(),Gt(()=>{try{f.close();}catch{}});}catch{}}}),se.size===0&&dt();},[]);}var Kt=({activeId:e,render:t,className:n})=>{let r=me.useRef(null);return me.useEffect(()=>{let o=s=>{r.current&&(r.current.style.transform=`translate(${s.clientX+12}px, ${s.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsxRuntime.jsx("div",{ref:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var Qn=({popoutDoc:e,children:t})=>{if(e===document)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t});let n=me__default.default.useEffect,r=me__default.default.useLayoutEffect,o=me__default.default.useInsertionEffect;me__default.default.useEffect=(s,l)=>n(()=>{window.__zeugmaActivePopoutDocument=e;try{let a=s();return typeof a=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return a()}finally{window.__zeugmaActivePopoutDocument=null;}}:a}finally{window.__zeugmaActivePopoutDocument=null;}},l),me__default.default.useLayoutEffect=(s,l)=>r(()=>{window.__zeugmaActivePopoutDocument=e;try{let a=s();return typeof a=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return a()}finally{window.__zeugmaActivePopoutDocument=null;}}:a}finally{window.__zeugmaActivePopoutDocument=null;}},l),o&&(me__default.default.useInsertionEffect=(s,l)=>o(()=>{window.__zeugmaActivePopoutDocument=e;try{let a=s();return typeof a=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return a()}finally{window.__zeugmaActivePopoutDocument=null;}}:a}finally{window.__zeugmaActivePopoutDocument=null;}},l)),window.__zeugmaActivePopoutDocument=e;try{return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t})}finally{window.__zeugmaActivePopoutDocument=null,me__default.default.useEffect=n,me__default.default.useLayoutEffect=r,o&&(me__default.default.useInsertionEffect=o);}},tn=me__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,{renderPopoutWrapper:o}=re(),[s,l]=me.useState(false),a=me.useRef(null);if(me.useEffect(()=>{l(true);},[]),me.useEffect(()=>{if(!s||!a.current)return;let v=a.current;if(t)t.ownerDocument.adoptNode(v),t.appendChild(v);else {let g=document.getElementById("zeugma-hidden-portal-container");g||(g=document.createElement("div"),g.id="zeugma-hidden-portal-container",g.style.display="none",document.body.appendChild(g)),document.adoptNode(v),g.appendChild(v);}},[t,s]),me.useEffect(()=>()=>{a.current&&a.current.remove();},[]),!s)return null;a.current||(a.current=document.createElement("div"),a.current.className=`zeugma-portal-wrapper-${r}`,a.current.style.width="100%",a.current.style.height="100%");let c=a.current;if(!c||!n)return null;let f=!!(t&&t.ownerDocument&&t.ownerDocument!==document),i=e.remountOnPopout?f?"-popped":"-docked":"",h=jsxRuntime.jsx(me__default.default.Fragment,{children:n(e)},`${r}${i}`);return f&&t&&t.ownerDocument&&o&&(h=o({tabId:r,document:t.ownerDocument,window:t.ownerDocument.defaultView||window,children:h})),reactDom.createPortal(jsxRuntime.jsx(Qn,{popoutDoc:f&&t?t.ownerDocument:document,children:h}),c)},(e,t)=>e.target===t.target&&e.renderWidget===t.renderWidget&&e.tabDetails.id===t.tabDetails.id&&e.tabDetails.paneId===t.tabDetails.paneId&&e.tabDetails.isActive===t.tabDetails.isActive&&e.tabDetails.index===t.tabDetails.index&&e.tabDetails.metadata===t.tabDetails.metadata);var nn=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:r,renderPaneRef:o,renderPane:s,tabHeadersRef:l,classNames:a})=>{if(r)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let c=o.current||s;if(c)return jsxRuntime.jsx("div",{className:a.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:c(e)})}else if(t==="tab"){let c=o.current||s;if(c)return jsxRuntime.jsx("div",{className:a.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:c(e)});let f=l.current[e];if(f){let i=a.tab?typeof a.tab=="function"?a.tab(e):a.tab:"";return jsxRuntime.jsx("div",{className:`${a.tabDragPreview||""} ${i}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden"},children:f({isDragging:true,isOver:false})})}}return jsxRuntime.jsx("div",{style:{pointerEvents:"none",overflow:"hidden",width:"100%",height:"100%"}})};function ft({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:s,layout:l,currentNode:a,onLayoutChange:c,onResizeStart:f,onResizeEnd:i,parentLeft:h,parentTop:v,parentWidth:g,parentHeight:d}){let{onResizeStart:u,onResize:m,onResizeEnd:y,minSplitPercentage:b=5,maxSplitPercentage:S=95,locked:N=false}=re();return me.useCallback(z=>{if(N)return;z.preventDefault();let A=e.current;if(!A)return;f&&f(),u&&u(a);let x=A.getBoundingClientRect(),L=z.clientX,F=z.clientY,j=r,H=z.currentTarget,J=x.left+x.width*(h/100),ne=x.top+x.height*(v/100),Y=x.width*(g/100),k=x.height*(d/100),V=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter($=>$!==H&&$.getAttribute("data-direction")===n).map($=>{let C=$.getBoundingClientRect();return t?C.left+C.width/2:C.top+C.height/2}),_=j;Ct({cursor:t?"col-resize":"row-resize",resizerEl:H,onMove:$=>{let C=t?($.clientX-L)/Y*100:($.clientY-F)/k*100,T=j+C,M=t?J+(Y-o)*(T/100)+o/2:ne+(k-o)*(T/100)+o/2,w=1/0,I=null;for(let X of V){let ee=Math.abs(M-X);ee<s&&ee<w&&(w=ee,I=X);}let ue=T;I!==null&&(ue=t?(I-o/2-J)/(Y-o)*100:(I-o/2-ne)/(k-o)*100);let Q=Math.max(b,Math.min(S,ue));_=Q;let K=we(l,a,Q);if(K){let{panes:X,splitters:ee}=ve(K),D=e.current;if(D){for(let E of X)D.style.setProperty(`--pane-left-${E.paneId}`,`${E.left}%`),D.style.setProperty(`--pane-top-${E.paneId}`,`${E.top}%`),D.style.setProperty(`--pane-width-${E.paneId}`,`${E.width}%`),D.style.setProperty(`--pane-height-${E.paneId}`,`${E.height}%`);for(let E of ee)D.style.setProperty(`--splitter-pos-${E.id}`,`${E.direction==="row"?E.left:E.top}%`);}}m&&m(a,Q);},onEnd:()=>{let $=we(l,a,_),C=e.current;if(C){let{panes:T,splitters:M}=ve($);for(let w of T)C.style.removeProperty(`--pane-left-${w.paneId}`),C.style.removeProperty(`--pane-top-${w.paneId}`),C.style.removeProperty(`--pane-width-${w.paneId}`),C.style.removeProperty(`--pane-height-${w.paneId}`);for(let w of M)C.style.removeProperty(`--splitter-pos-${w.id}`);}c($),i&&i(),y&&y(a,_);}});},[e,t,n,r,o,s,l,a,c,f,i,u,m,y,b,S,h,v,g,d])}var on=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:s,classNames:l,locked:a}=re(),[c,f]=me.useState(false),{currentNode:i,direction:h,left:v,top:g,width:d,height:u,parentLeft:m,parentTop:y,parentWidth:b,parentHeight:S}=e,N=h==="row",z=ft({containerRef:r,isRow:N,direction:h,splitPercentage:i.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:i,onLayoutChange:s,onResizeStart:()=>f(true),onResizeEnd:()=>f(false),parentLeft:m,parentTop:y,parentWidth:b,parentHeight:S}),A=N?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${v}%) - ${t/2}px)`,top:`calc(${g}% + ${t/2}px)`,width:`${t}px`,height:`calc(${u}% - ${t}px)`,cursor:a?"default":"col-resize",pointerEvents:a?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${v}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${g}%) - ${t/2}px)`,width:`calc(${d}% - ${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:l.resizer||"","data-direction":h,"data-resizing":c||void 0,style:A,onPointerDown:z,role:"separator","aria-valuenow":i.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},rn=me__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane);var mt=({renderPane:e,tree:t,resizerSize:n,snapThreshold:r})=>{Mt(e);let{renderingLayout:o,activeId:s,dismissIntentId:l,setContainerRef:a,fullscreenPaneId:c,snapThreshold:f,locked:i,classNames:h,resizerSize:v}=re(),g=r!==void 0?r:f??8,d=n!==void 0?n:v??4,u=t!==void 0?t:o,m=me.useRef(null),{panes:y,splitters:b}=me.useMemo(()=>u?ve(u):{panes:[],splitters:[]},[u]);if(!u&&t!==void 0)return null;let S=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[y.map(N=>{let z=c===N.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:z?"0%":`var(--pane-left-${N.paneId}, ${N.left}%)`,top:z?"0%":`var(--pane-top-${N.paneId}, ${N.top}%)`,width:z?"100%":`var(--pane-width-${N.paneId}, ${N.width}%)`,height:z?"100%":`var(--pane-height-${N.paneId}, ${N.height}%)`,overflow:"hidden",zIndex:z?20:1,display:c&&!z?"none":"block",padding:z?"0px":`${d/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(rn,{paneId:N.paneId,renderPane:e})},N.paneId)}),!c&&b.map(N=>jsxRuntime.jsx(on,{splitter:N,resizerSize:d,snapThreshold:g,containerRef:m},N.id))]});if(t===void 0){let N=s!==null&&s===l,z=x=>{a(x),m.current=x;},A=`${h.dashboard||""} ${N&&h.dashboardDismissActive||""} ${i&&h.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:z,className:A,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[S(),s!==null&&!i&&jsxRuntime.jsx(ln,{activeClassName:h.rootDropPreview??h.dropPreview})]})}return jsxRuntime.jsx("div",{ref:m,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:S()})};var lo=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:s,resizerSize:l,dragActivationDistance:a=8,snapThreshold:c=8,minSplitPercentage:f=5,maxSplitPercentage:i=95,enableDragToDismiss:h=false,dismissThreshold:v=60,onRemove:g,onDragStart:d,onDragEnd:u,onResizeStart:m,onResize:y,onResizeEnd:b,onDismissIntentChange:S,persist:N=false,renderPopoutWrapper:z}=e,A=t,{layout:x,setLayout:L,_internalSetLayout:F,renderingLayout:j,fullscreenPaneId:H,setFullscreenPaneId:J,locked:ne,setLocked:Y,findPaneById:k,findPaneContainingTab:Z,findTabById:V,getTabMetadata:_,getActiveTabMetadata:$,activeId:C,setActiveId:T,activeType:M,setActiveType:w,dismissIntentId:I,setDismissIntentId:ue,containerRef:Q,setContainerRef:K,removePane:X,addTab:ee,updateMetadata:D,updatePaneLock:E,selectTab:ae,mergeTab:ie,removeTab:G,splitPane:oe,updateSplitPercentage:ke,moveTab:p,poppedOutTabIds:P=[],popoutTab:R,dockTab:O}=A;Xt({persist:N,layout:x,setLayout:L});let{portalTargets:B,registerPortalTarget:le,registerPopoutTarget:W,registerRenderCallback:Pe,renderCallbacksRef:Be,registerRenderPane:Tt,renderPaneRef:at,registerTabHeader:Pt,tabHeadersRef:it,activeIdRef:Fe}=It();Qt({poppedOutTabIds:P,registerPopoutTarget:W,findTabById:V,dockTab:O});let yt=me.useCallback(de=>P.includes(de),[P]),{overTabId:xt,setOverTabId:Pn,overTabPosition:Rt,setOverTabPosition:yn,handleDragStartInternal:xn,handleDragEndInternal:Rn}=kt({onDragStart:d,onDragEnd:u}),wn=Ut({layout:x,_internalSetLayout:F,setLayout:L,activeId:C,setActiveId:T,activeType:M,setActiveType:w,dismissIntentId:I,setDismissIntentId:ue,setOverTabId:Pn,setOverTabPosition:yn,containerRef:Q,dragActivationDistance:a,enableDragToDismiss:h,dismissThreshold:v,onRemove:g,onDragStart:xn,onDragEnd:Rn,onDismissIntentChange:S,removeTab:G,removePane:X}),st=me.useMemo(()=>o,[o.dashboard,o.dashboardDismissActive,o.pane,o.paneLocked,o.dropPreview,o.rootDropPreview,o.dragOverlay,o.paneDragPreview,o.tabDragPreview,o.resizer,o.dismissPreview,o.dashboardLocked,o.lockedPreview,o.tabDropPreview,o.tabSeparator,o.tabsContainer,o.tab,o.paneContainer,o.paneHeader,o.paneControls,o.paneButton,o.tabCloseButton,o.dragHandle]),wt=me.useCallback((de,Ve)=>{b&&b(de,Ve);},[b]),Dn=me.useMemo(()=>({layout:x,renderingLayout:j,setLayout:L,activeId:C,activeType:M,dismissIntentId:I,setContainerRef:K,fullscreenPaneId:H,classNames:st,onRemove:g,onFullscreenChange:J,snapThreshold:c,onResizeStart:m,onResize:y,onResizeEnd:wt,minSplitPercentage:f,maxSplitPercentage:i,locked:ne,setLocked:Y,findPaneById:k,findPaneContainingTab:Z,findTabById:V,getTabMetadata:_,getActiveTabMetadata:$,renderPane:s,resizerSize:l,poppedOutTabIds:P,isTabPoppedOut:yt,renderPopoutWrapper:z}),[x,j,C,M,I,K,H,st,g,J,c,m,y,f,i,L,wt,ne,Y,k,Z,V,_,$,s,l,P,yt,z]),Cn=me.useMemo(()=>({overTabId:xt,overTabPosition:Rt}),[xt,Rt]),En=me.useMemo(()=>({removePane:X,addTab:ee,updateMetadata:D,updatePaneLock:E,selectTab:ae,mergeTab:ie,removeTab:G,setFullscreenPaneId:J,setLocked:Y,splitPane:oe,updateSplitPercentage:ke,moveTab:p,popoutTab:R,dockTab:O}),[X,ee,D,E,ae,ie,G,J,Y,oe,ke,p,R,O]),Sn=Lt(x),Nn=me.useMemo(()=>({registerPortalTarget:le,registerRenderCallback:Pe,renderCallbacksRef:Be,registerRenderPane:Tt,renderPaneRef:at,registerTabHeader:Pt,tabHeadersRef:it,activeIdRef:Fe,registerPopoutTarget:W}),[le,Pe,Be,Tt,at,Pt,it,Fe,W]);return Fe&&(Fe.current=C),jsxRuntime.jsx(xe.Provider,{value:En,children:jsxRuntime.jsx(ct.Provider,{value:Dn,children:jsxRuntime.jsx(ut.Provider,{value:Cn,children:jsxRuntime.jsxs(ye.Provider,{value:Nn,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...wn,children:n}),C&&M&&jsxRuntime.jsx(Kt,{activeId:C,render:de=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:de===I?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(nn,{activeId:de,activeType:M,dismissIntentId:I,renderDragOverlay:r,renderPaneRef:at,renderPane:s,tabHeadersRef:it,classNames:st})}),className:`${o.dragOverlay||""} ${C===I&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:Sn.map(de=>{let Ve=B[de],Dt=V(de);return Dt?jsxRuntime.jsx(tn,{tabDetails:Dt,target:Ve||null,renderWidget:Be.current[de]},de):null})})]})})})})},co=({renderPane:e,resizerSize:t,snapThreshold:n})=>{if(!e)throw new Error("Zeugma component requires a renderPane prop when used as a standalone renderer.");return jsxRuntime.jsx(mt,{renderPane:e,resizerSize:t,snapThreshold:n})},uo=e=>{let{children:t,...n}=e,{controller:r}=e;if(!r)throw new Error("Zeugma component requires a controller.");return jsxRuntime.jsx(lo,{...e,children:t!==void 0?t:jsxRuntime.jsx(co,{...n})})};var mo={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"}}},go={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"}}},bo=({id:e,fraction:t,edge:n,activeClassName:r})=>{let{setNodeRef:o,isOver:s}=core.useDroppable({id:e}),l={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...go[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:mo[n][t]}),s&&jsxRuntime.jsx("div",{className:r,style:l})]})},ln=({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(bo,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var tt=me.createContext(null);var yo={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"},center:{position:"absolute",top:"25%",left:"25%",width:"50%",height:"50%",zIndex:22,pointerEvents:"auto"}},xo={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"},center:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},nt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:r,isOver:o}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:r,style:yo[t]}),o&&jsxRuntime.jsx("div",{className:n,style:xo[t]})]})};var dn=({children:e,className:t,style:n})=>{let r=me.useContext(tt);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...s}=r;return jsxRuntime.jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:s,children:e})};var ko=me.createContext(void 0);var _e=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:s,classNames:l={},fullscreenPaneId:a,poppedOutTabIds:c=[]}=re(),f=me.useContext(xe),{overTabId:i}=qe(),h=me.useContext(ye);me.useEffect(()=>(h?.registerTabHeader&&h.registerTabHeader(e,n),()=>{h?.registerTabHeader&&h.activeIdRef?.current!==e&&h.registerTabHeader(e,()=>null);}),[e,n,h]);let v=c.includes(e),g=me.useContext(bt),d=t||s||(g?.locked??false)||a!==null,{attributes:u,listeners:m,setNodeRef:y,isDragging:b}=core.useDraggable({id:`tab-header-${e}`,disabled:d}),{setNodeRef:S,isOver:N}=core.useDroppable({id:`tab-drop-${e}`,disabled:d}),z=V=>{y(V),S(V);},A=N&&i===e,x=g?.tabIds||[],L=x.indexOf(e),F=g?.activeTabId,H=L>0&&e!==F&&x[L-1]!==F?jsxRuntime.jsx("div",{className:l.tabSeparator}):null,J=g?g.activeTabId===e:false,ne=g?.tabsMetadata?.[e],Y=me.useCallback(()=>{g?.selectTab(e);},[g,e]),k=me.useCallback(()=>{g?.removeTab(e);},[g,e]),Z=me.useMemo(()=>({tabId:e,isActive:J,isDragging:b,isOver:A,metadata:ne,locked:d,selectTab:Y,removeTab:k,isPoppedOut:v,popoutTab:()=>f?.popoutTab(e),dockTab:()=>f?.dockTab(e)}),[e,J,b,A,ne,d,Y,k,v,f]);return jsxRuntime.jsx(ko.Provider,{value:Z,children:jsxRuntime.jsxs("div",{ref:z,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:d?"default":"grab",...o},...d?{}:m,...d?{}:u,children:[H,n({isDragging:b,isOver:A})]})})};var bt=me.createContext(void 0);var gn=(e,t)=>typeof e=="function"?e(t):e,vt=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:s,renderTab:l,classNames:a,styles:c})=>{let f=me.useContext(ot),i=e??f?.tabIds??[],h=t??f?.activeTabId??"",v=n??f?.locked??false,g=r??f?.tabsMetadata,d=o??f?.selectTab??(()=>{}),u=s??f?.removeTab??(()=>{}),{classNames:m={},activeType:y,poppedOutTabIds:b=[]}=re(),S=me.useContext(xe),{overTabId:N,overTabPosition:z}=qe(),A=me.useMemo(()=>({tabIds:i,activeTabId:h,locked:v,tabsMetadata:g,selectTab:d,removeTab:u}),[i,h,v,g,d,u]),x=Bt(i,y,N,z);return jsxRuntime.jsx(bt.Provider,{value:A,children:jsxRuntime.jsxs("div",{className:a?.container,style:{display:"flex",alignItems:"center",height:"100%",...c?.container},children:[i.map((L,F)=>{let j=g?.[L],H=gn(a?.tab,L),J=gn(c?.tab,L),ne=F===x;return jsxRuntime.jsxs(me__default.default.Fragment,{children:[ne&&m.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:m.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:F===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(_e,{id:L,locked:v,className:H,style:J,children:({isDragging:Y,isOver:k})=>l({id:L,paneId:f?.id??"",isActive:L===h,index:F,isDragging:Y,isOver:k,metadata:j,onSelect:()=>d(L),onRemove:()=>u(L),isPoppedOut:b.includes(L),popout:()=>S?.popoutTab(L),dock:()=>S?.dockTab(L)})})]},L)}),x===i.length&&m.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:m.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};vt.Tab=_e;var vn=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var ot=me.createContext(void 0),Tn=()=>{let e=me.useContext(ot);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},Fo=({children:e,className:t,style:n})=>{let{activeTabId:r}=Tn(),{classNames:o,isTabPoppedOut:s}=re(),{dockTab:l}=ze(),a=me.useRef(null),c=me.useContext(ye);if(!c)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:f,registerRenderCallback:i}=c,h=me.useMemo(()=>typeof e=="function"?e:()=>e,[e]);i(r,h),me.useEffect(()=>{let g=a.current;return f(r,g),()=>{f(r,null,g);}},[r,f]);let v=s(r);return jsxRuntime.jsx("div",{ref:a,id:`zeugma-tab-target-${r}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",position:"relative",...n},children:v&&jsxRuntime.jsxs("div",{className:"zeugma-popout-placeholder",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"12px",padding:"24px",textAlign:"center",backgroundColor:"#161719",color:"#94a3b8",fontSize:"13px",fontWeight:500},children:[jsxRuntime.jsx("div",{children:"This panel is open in a new window"}),jsxRuntime.jsx("button",{onClick:()=>l(r),style:{padding:"6px 12px",fontSize:"11px",fontWeight:600,borderRadius:"4px",backgroundColor:"#2563eb",color:"#ffffff",border:"none",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"},onMouseOver:g=>{g.currentTarget.style.backgroundColor="#1d4ed8";},onMouseOut:g=>{g.currentTarget.style.backgroundColor="#2563eb";},children:"Dock Back"})]})})},Le=({id:e,children:t,style:n,locked:r=false})=>{let{layout:o,renderingLayout:s,activeId:l,activeType:a,classNames:c,fullscreenPaneId:f,onFullscreenChange:i,locked:h,poppedOutTabIds:v=[]}=re(),{removePane:g,updateMetadata:d,selectTab:u,removeTab:m,popoutTab:y,dockTab:b}=ze(),S=me.useMemo(()=>{if(a==="tab"&&e===l){let I=q(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:I?{[e]:I}:void 0}}return At(e===l?o:s,e)},[o,s,e,l,a]),N=S?.id??e,z=S?.tabIds??[e],A=S?.activeTabId??e,x=S?.tabsMetadata,L=x?.[e],F=S?.locked??false,j=r||F,H=h||j||f!==null,J=h||j||f!==null,ne=l!==null&&l!==e&&(!z.includes(l)||z.length>1)&&!J,{attributes:Y,listeners:k,setNodeRef:Z}=core.useDraggable({id:e,disabled:H}),V=l!==null&&z.includes(l),_=f===e,$=me.useMemo(()=>({isDragging:V,isFullscreen:_,toggleFullscreen:()=>i?.(_?null:e),remove:()=>{_&&i?.(null),g(N);},metadata:L,updateMetadata:M=>{d(e,M);},locked:H,tabIds:z,activeTabId:A,selectTab:M=>u(N,M),removeTab:M=>{_&&M===A&&i?.(null),m(M);},tabsMetadata:x,updateTabMetadata:(M,w)=>{d(M,w);},isActiveTabPoppedOut:v.includes(A),popoutTab:M=>y(M||A),dockTab:M=>b(M||A)}),[V,_,i,e,m,L,d,H,z,A,u,N,x,v,y,b]),C=me.useMemo(()=>H?{disabled:true}:{...k,...Y},[k,Y,H]),T=`${c.pane||""} ${j&&c.paneLocked||""}`.trim();return jsxRuntime.jsx(ot.Provider,{value:{id:e,...$},children:jsxRuntime.jsx(tt.Provider,{value:C,children:jsxRuntime.jsxs("div",{ref:Z,id:e,className:T,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,ne&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(M=>jsxRuntime.jsx(nt,{id:`drop-${M}-${e}`,position:M,activeClassName:c.dropPreview},M)),a==="tab"&&jsxRuntime.jsx(nt,{id:`drop-center-${e}`,position:"center",activeClassName:c.swapPreview??c.dropPreview})]}),l!==null&&l!==e&&J&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(nt,{id:`drop-locked-${e}`,position:"full",activeClassName:c.lockedPreview||""})})]})})})};Le.Content=Fo;Le.DragHandle=dn;Le.Tabs=vt;Le.Tab=_e;Le.Controls=vn;exports.Pane=Le;exports.PaneTree=mt;exports.Zeugma=uo;exports.usePaneContext=Tn;exports.useResizer=ft;exports.useZeugma=zn;exports.useZeugmaContext=An;//# sourceMappingURL=index.cjs.map
9
+ `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let c=i=>{n(i);},u=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let i=document.getElementById("zeugma-global-cursor-style");i&&i.remove(),document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",u),a();};document.addEventListener("pointermove",c),document.addEventListener("pointerup",u);}function Ae(e){try{return JSON.stringify(e)}catch{return ""}}var dt=ge.createContext(void 0),we=ge.createContext(void 0),Pe=ge.createContext(void 0),pt=ge.createContext(void 0),re=()=>{let e=ge.useContext(dt);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},ze=()=>{let e=ge.useContext(we);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Ue=()=>{let e=ge.useContext(pt);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function Lt(e){let t=ge.useRef(null);return ge.useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},a=o=>{let c=o.touches[0]||o.changedTouches[0];c&&(t.current={x:c.clientX,y:c.clientY});};return window.addEventListener("pointermove",n,{passive:true}),window.addEventListener("touchmove",a,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",a);}},[e]),t}function Mt(e){ge.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function kt(){let[e,t]=ge.useState({}),[n,a]=ge.useState({}),o=ge.useRef({}),c=ge.useRef(null),u=ge.useRef({}),i=ge.useRef(null),d=ge.useRef(true);ge.useEffect(()=>(d.current=true,()=>{d.current=false;}),[]);let f=ge.useCallback((T,x,L)=>{d.current&&t(h=>{if(!x){if(L&&h[T]!==L||!h[T])return h;let H={...h};return delete H[T],H}return h[T]===x?h:{...h,[T]:x}});},[]),s=ge.useCallback((T,x)=>{d.current&&a(L=>{if(!x){if(!L[T])return L;let h={...L};return delete h[T],h}return L[T]===x?L:{...L,[T]:x}});},[]),b=ge.useCallback((T,x)=>{o.current[T]=x;},[]),g=ge.useCallback(T=>{c.current=T;},[]),m=ge.useCallback((T,x)=>{u.current[T]=x;},[]);return {portalTargets:ge.useMemo(()=>({...e,...n}),[e,n]),registerPortalTarget:f,registerPopoutTarget:s,registerRenderCallback:b,renderCallbacksRef:o,registerRenderPane:g,renderPaneRef:c,registerTabHeader:m,tabHeadersRef:u,activeIdRef:i}}function An(e){let t=new Set;function n(a){a&&(a.type==="pane"?a.tabIds.forEach(o=>{t.add(o);}):a.type==="split"&&(n(a.first),n(a.second)));}return n(e),Array.from(t).sort()}function Ot(e){return ge.useMemo(()=>An(e),[e])}function At(e){let{onDragStart:t,onDragEnd:n}=e,[a,o]=ge.useState(null),[c,u]=ge.useState(null),i=ge.useCallback(f=>{t&&t(f);},[t]),d=ge.useCallback((f,s,b)=>{n&&n(f,s,b);},[n]);return {overTabId:a,setOverTabId:o,overTabPosition:c,setOverTabPosition:u,handleDragStartInternal:i,handleDragEndInternal:d}}function zt(e){let n=ge.useContext(Pe)?.registerRenderPane;ge.useEffect(()=>{n&&e&&n(e);},[n,e]);}function pe(){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),a=be(e.second,t);return n===null?a:a===null?n:{...e,first:n,second:a}}function fe(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let o=e.tabIds.filter(i=>i!==t);if(o.length===0)return null;let c=e.activeTabId;e.activeTabId===t&&(c=o[0]);let u={...e.tabsMetadata};return delete u[t],{...e,tabIds:o,activeTabId:c,tabsMetadata:Object.keys(u).length>0?u:void 0}}return e}let n=fe(e.first,t),a=fe(e.second,t);return n===null?a:a===null?n:{...e,first:n,second:a}}function Se(e,t,n,a,o){if(e===null)return typeof o=="string"?{type:"pane",id:pe(),tabIds:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let c=typeof o=="string"?{type:"pane",id:pe(),tabIds:[o],activeTabId:o}:o,u=a==="left"||a==="top";return {type:"split",direction:n,first:u?c:e,second:u?e:c,splitPercentage:50}}return e}return {...e,first:Se(e.first,t,n,a,o)||e.first,second:Se(e.second,t,n,a,o)||e.second}}function zn(e,t){if(e===null)return t;function n(a,o){return a.type==="pane"?{type:"split",direction:o==="row"?"column":"row",splitPercentage:50,first:a,second:t}:{...a,second:n(a.second,a.direction)}}return n(e,null)}function Zt(e,t,n,a){if(e===null)return {type:"pane",id:pe(),tabIds:[n],activeTabId:n,tabsMetadata:a?{[n]:a}:void 0};let o=t?te(e,t):null;if(o&&o.type==="pane"){let i=function(d){if(d.type==="pane"&&d.id===t){let f=[...d.tabIds];f.includes(n)||f.push(n);let s=d.tabsMetadata;return a&&(s={...d.tabsMetadata,[n]:a}),{...d,tabIds:f,activeTabId:n,tabsMetadata:s}}return d.type==="split"?{...d,first:i(d.first),second:i(d.second)}:d};return i(e)}let c={type:"pane",id:pe(),tabIds:[n],activeTabId:n,tabsMetadata:a?{[n]:a}:void 0};return zn(e,c)}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 te(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?te(e.first,t)??te(e.second,t):null}function U(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?U(e.first,t)??U(e.second,t):null}function Ht(e,t){return te(e,t)??U(e,t)}function $t(e,t){let n=U(e,t);if(!n)return null;let a=n.tabIds.indexOf(t);return {id:t,paneId:n.id,isActive:n.activeTabId===t,index:a,metadata:n.tabsMetadata?.[t],remountOnPopout:n.tabsMetadata?.[t]?.remountOnPopout}}function _t(e,t){return U(e,t)?.tabsMetadata?.[t]}function Bt(e,t){let n=te(e,t);return n?.tabsMetadata?.[n.activeTabId]}function Je(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let a=e.tabsMetadata||{},o=a[t],c=n(o),u={...a};return c===void 0?delete u[t]:u[t]=c,{...e,tabsMetadata:Object.keys(u).length>0?u:void 0}}return e}return e.type==="split"?{...e,first:Je(e.first,t,n)??e.first,second:Je(e.second,t,n)??e.second}:e}function Ge(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.id===t){if(n===false){let{locked:a,...o}=e;return o}return {...e,locked:n}}return e}return e.type==="split"?{...e,first:Ge(e.first,t,n)??e.first,second:Ge(e.second,t,n)??e.second}:e}function Ne(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:Ne(e.first,t,n)??e.first,second:Ne(e.second,t,n)??e.second}:e}function Ft(e,t,n){if(e===null)return null;let o=U(e,t)?.tabsMetadata?.[t],c=fe(e,t);if(c===null)return {type:"pane",id:pe(),tabIds:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function u(i){if(i.type==="pane"){if(i.id===n){let d=[...i.tabIds];d.includes(t)||d.push(t);let f={...i.tabsMetadata};return o&&(f[t]=o),{...i,tabIds:d,activeTabId:t,tabsMetadata:Object.keys(f).length>0?f:void 0}}return i}return i.type==="split"?{...i,first:u(i.first),second:u(i.second)}:i}return u(c)}function Zn(e,t,n){if(e===null)return null;if(t===n)return e;let a=U(e,t),o=U(e,n);if(!a||!o)return e;let c=a.id,u=o.id,i=a.tabsMetadata?.[t],d=o.tabsMetadata?.[n];function f(s){if(s.type==="pane"){let b=false,g=[...s.tabIds],m=s.activeTabId,y=s.tabsMetadata?{...s.tabsMetadata}:{};if(c===u){if(s.id===c){let T=g.indexOf(t),x=g.indexOf(n);T!==-1&&x!==-1&&(g[T]=n,g[x]=t),m=t,b=true;}}else s.id===c&&(g=g.map(T=>T===t?n:T),m===t&&(m=n),delete y[t],d&&(y[n]=d),b=true),s.id===u&&(g=g.map(T=>T===n?t:T),m===n&&(m=t),delete y[n],i&&(y[t]=i),b=true);return b?{...s,tabIds:g,activeTabId:m,tabsMetadata:Object.keys(y).length>0?y:void 0}:s}return s.type==="split"?{...s,first:f(s.first),second:f(s.second)}:s}return f(e)}function Ze(e,t,n,a="before"){if(e===null)return null;if(t===n)return e;if(a==="center")return Zn(e,t,n);let c=U(e,t)?.tabsMetadata?.[t],u=fe(e,t);if(u===null)return {type:"pane",id:pe(),tabIds:[t],activeTabId:t,tabsMetadata:c?{[t]:c}:void 0};function i(d){if(d.type==="pane"){if(d.tabIds.includes(n)){let s=[...d.tabIds].filter(m=>m!==t),b=s.indexOf(n);b<0&&(b=0),a==="after"&&(b+=1),s.splice(b,0,t);let g={...d.tabsMetadata};return c&&(g[t]=c),{...d,tabIds:s,activeTabId:t,tabsMetadata:Object.keys(g).length>0?g:void 0}}return d}return d.type==="split"?{...d,first:i(d.first),second:i(d.second)}:d}return i(u)}function ve(e,t=0,n=0,a=100,o=100,c="root"){if(e===null)return {panes:[],splitters:[]};if(e.type==="pane")return {panes:[{paneId:e.id,left:t,top:n,width:a,height:o,node:e}],splitters:[]};let{direction:u,splitPercentage:i,first:d,second:f}=e,b={id:`splitter-${c}-${u}`,currentNode:e,direction:u,left:u==="row"?t+a*(i/100):t,top:u==="column"?n+o*(i/100):n,width:u==="row"?0:a,height:u==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:a,parentHeight:o},g={panes:[],splitters:[]},m={panes:[],splitters:[]};if(u==="row"){let y=a*(i/100);g=ve(d,t,n,y,o,`${c}-L`),m=ve(f,t+y,n,a-y,o,`${c}-R`);}else {let y=o*(i/100);g=ve(d,t,n,a,y,`${c}-T`),m=ve(f,t,n+y,a,o-y,`${c}-B`);}return {panes:[...g.panes,...m.panes],splitters:[b,...g.splitters,...m.splitters]}}function Vt(e,t,n,a="before"){if(e===null)return null;let o=te(e,t);if(!o)return e;let c=o.tabIds,u=o.activeTabId,i=o.tabsMetadata||{},d=be(e,t);if(d===null)return o;function f(s){if(s.type==="pane"){if(s.tabIds.includes(n)){let g=[...s.tabIds].filter(T=>!c.includes(T)),m=g.indexOf(n);m<0&&(m=0),a==="after"&&(m+=1),g.splice(m,0,...c);let y={...s.tabsMetadata};for(let T of c)i[T]&&(y[T]=i[T]);return {...s,tabIds:g,activeTabId:u,tabsMetadata:Object.keys(y).length>0?y:void 0}}return s}return s.type==="split"?{...s,first:f(s.first),second:f(s.second)}:s}return f(d)}function Wt(e,t,n,a){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!a)return -1;let u=e.indexOf(n);return a==="before"?u:u+1}function Hn(e){let{initialLayout:t,layout:n,onChange:a,fullscreenPaneId:o,onFullscreenChange:c,locked:u=false}=e,[i,d]=ge.useState(()=>n!==void 0?n:t??null),[f,s]=ge.useState(()=>n!==void 0?n:t??null),[b,g]=ge.useState(()=>Ae(n!==void 0?n:null)),[m,y]=ge.useState(o||null),[T,x]=ge.useState(u),[L,h]=ge.useState([]),[H,D]=ge.useState(null),[O,Z]=ge.useState(null),[r,l]=ge.useState(null),v=ge.useRef(null),R=ge.useCallback(p=>{v.current=p;},[]),M=ge.useRef(i);M.current=i;let q=ge.useRef(a);q.current=a;let ne=ge.useRef(c);ne.current=c;let J=ge.useCallback(p=>{y(p),ne.current?.(p);},[]);if(ge.useEffect(()=>{x(u);},[u]),ge.useEffect(()=>{o!==void 0&&y(o);},[o]),n!==void 0){let p=Ae(n);p!==b&&(g(p),d(n),s(n));}let A=ge.useCallback(p=>(...w)=>{let E=M.current,_=p(E,...w);Ae(E)!==Ae(_)&&(M.current=_,d(_),s(_),q.current?.(_));},[]),$=ge.useCallback(A((p,w)=>typeof w=="function"?w(p):w),[A]),W=ge.useCallback(p=>{s(w=>typeof p=="function"?p(w):p);},[]),F=ge.useCallback(p=>{y(null),ne.current?.(null),D(null),Z(null),l(null),$(p),s(()=>typeof p=="function"?p(M.current):p);},[$]),B=ge.useCallback(A((p,w)=>be(p,w)),[A]),N=ge.useCallback(A((p,w,E,_)=>{let V=fe(p,w)??p;return Zt(V,E,w,_)}),[A]),P=ge.useCallback(A((p,w,E,_,V)=>{let le=te(p,w)??U(p,w);if(!le)return p;let j=te(p,V)??U(p,V)??{type:"pane",id:V,tabIds:[V],activeTabId:V},Te=be(p,j.id);return Se(Te,le.id,E,_,j)}),[A]),z=ge.useCallback(A((p,w,E)=>xe(p,w,E)),[A]),C=ge.useCallback(A((p,w,E)=>Je(p,w,E)),[A]),k=ge.useCallback(A((p,w,E)=>{let _=te(p,w)??U(p,w);return _?Ge(p,_.id,E):p}),[A]),ue=ge.useCallback(A((p,w,E)=>{let _=te(p,w)??U(p,w);return _?Ne(p,_.id,E):p}),[A]),Q=ge.useCallback(A((p,w,E)=>{let _=te(p,E)??U(p,E);return _?Ft(p,w,_.id):p}),[A]),K=ge.useCallback(A((p,w,E,_)=>Ze(p,w,E,_)),[A]),Y=ge.useCallback(A((p,w)=>fe(p,w)),[A]),ee=ge.useCallback(p=>te(M.current,p),[]),S=ge.useCallback(p=>U(M.current,p),[]),I=ge.useCallback(p=>$t(M.current,p),[]),ie=ge.useCallback(p=>_t(M.current,p),[]),se=ge.useCallback(p=>Bt(M.current,p),[]),G=ge.useCallback(p=>{h(w=>w.includes(p)?w:[...w,p]);},[]),oe=ge.useCallback(p=>{h(w=>w.includes(p)?w.filter(E=>E!==p):w);},[]);return {layout:i,setLayout:F,_internalSetLayout:W,renderingLayout:f,fullscreenPaneId:m,setFullscreenPaneId:J,locked:T,setLocked:x,poppedOutTabIds:L,activeId:H,setActiveId:D,activeType:O,setActiveType:Z,dismissIntentId:r,setDismissIntentId:l,containerRef:v,setContainerRef:R,removePane:B,addTab:N,updateMetadata:C,updatePaneLock:k,selectTab:ue,mergeTab:Q,moveTab:K,removeTab:Y,splitPane:P,updateSplitPercentage:z,popoutTab:G,dockTab:oe,findPaneById:ee,findPaneContainingTab:S,findTabById:I,getTabMetadata:ie,getActiveTabMetadata:se}}var $n=()=>{let e=re(),t=ze();return {layout:e.layout,setLayout:e.setLayout,fullscreenPaneId:e.fullscreenPaneId,setFullscreenPaneId:t.setFullscreenPaneId,locked:e.locked,setLocked:t.setLocked,removePane:t.removePane,addTab:t.addTab,updateMetadata:t.updateMetadata,updatePaneLock:t.updatePaneLock,selectTab:t.selectTab,mergeTab:t.mergeTab,removeTab:t.removeTab,splitPane:t.splitPane,updateSplitPercentage:t.updateSplitPercentage,moveTab:t.moveTab,findPaneById:e.findPaneById,findPaneContainingTab:e.findPaneContainingTab,findTabById:e.findTabById,getTabMetadata:e.getTabMetadata,getActiveTabMetadata:e.getActiveTabMetadata,poppedOutTabIds:e.poppedOutTabIds,popoutTab:t.popoutTab,dockTab:t.dockTab}};var Ke=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},et=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var qt=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((u,i)=>{let d=u.id.toString(),f=i.id.toString(),s=d.startsWith("tab-drop-"),b=f.startsWith("tab-drop-");if(s&&!b)return -1;if(!s&&b)return 1;let g=d.startsWith("drop-root-"),m=f.startsWith("drop-root-");return g&&!m?-1:!g&&m?1:0});if(n){let c=e.droppableContainers.filter(u=>u.id.toString().startsWith("tab-drop-"));return core.closestCenter({...e,droppableContainers:c})}return []};function He(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 Yt(e){let{layout:t,_internalSetLayout:n,setLayout:a,activeId:o,setActiveId:c,activeType:u,setActiveType:i,dismissIntentId:d,setDismissIntentId:f,setOverTabId:s,setOverTabPosition:b,containerRef:g,dragActivationDistance:m,enableDragToDismiss:y,dismissThreshold:T,onRemove:x,onDragStart:L,onDragEnd:h,onDismissIntentChange:H,removeTab:D,removePane:O}=e,Z=ge.useRef(null),r=Lt(o),l=ge.useRef(null),[v,R]=ge.useState(false);return Mt(v),{sensors:core.useSensors(core.useSensor(Ke,{activationConstraint:{distance:m}}),core.useSensor(et,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:qt,onDragStart:$=>{let W=$.active.id.toString(),F=W.startsWith("tab-header-"),B=F?W.substring(11):W;c(B),i(F?"tab":"pane"),s(null),b(null);let N=$.activatorEvent;r.current=He(N),y&&g.current?Z.current=g.current.getBoundingClientRect():Z.current=null;let P=t;if(F){let C=U(t,B);C&&(P=Ne(t,C.id,B)||t);}l.current=P;let z=F?fe(P,B):be(P,B);n(z),L&&L(B);},onDragMove:$=>{let{over:W}=$,F=W?.id.toString()||"",B=F.startsWith("drop-locked-");R(S=>S===B?S:B);let N=$.active.id.toString(),P=N.startsWith("tab-header-"),z=P?N.substring(11):N,C=F.match(/^tab-drop-(.+)$/);if(C&&W&&(P||u==="pane")){let[,S]=C;if(z!==S){let I="before",ie=W.rect,se=$.activatorEvent,G=null;if(r.current)G=r.current.x;else {let oe=He(se);oe&&(G=oe.x+$.delta.x);}if(G!==null){let oe=ie.left+ie.width/2;G>oe&&(I="after");}s(oe=>oe===S?oe:S),b(oe=>oe===I?oe:I);}else s(I=>I===null?I:null),b(I=>I===null?I:null);}else s(S=>S===null?S:null),b(S=>S===null?S:null);if(!y)return;let k=Z.current;if(!k){d!==null&&(f(null),H?.(null));return}let ue=$.activatorEvent,Q=null,K=null;if(r.current)Q=r.current.x,K=r.current.y;else {let S=He(ue);S&&(Q=S.x+$.delta.x,K=S.y+$.delta.y);}let Y=0;if(Q!==null&&K!==null){let S=0,I=0;Q<k.left?S=k.left-Q:Q>k.right&&(S=Q-k.right),K<k.top?I=k.top-K:K>k.bottom&&(I=K-k.bottom),Y=Math.sqrt(S*S+I*I);}else {let S=$.active.rect.current.translated;if(S){let I=S.left+S.width/2,ie=S.top+S.height/2,se=0,G=0;I<k.left?se=k.left-I:I>k.right&&(se=I-k.right),ie<k.top?G=k.top-ie:ie>k.bottom&&(G=ie-k.bottom),Y=Math.sqrt(se*se+G*G);}}Y>T?d!==z&&(f(z),H?.(z)):d!==null&&(f(null),H?.(null));},onDragEnd:$=>{c(null),i(null),R(false),s(null),b(null);let{active:W,over:F}=$,B=W.id.toString(),N=B.startsWith("tab-header-"),P=N?B.substring(11):B,z=y&&d===P;f(null),H?.(null),Z.current=null;let C=l.current||t;if(l.current=null,z){x?x(P):N?D(P):O(P),h&&h(P,null,null);return}if(!F){n(C),h&&h(P,null,null);return}let k=F.id.toString();if(k.startsWith("drop-locked-")){n(C),h&&h(P,null,null);return}let ue=k.match(/^tab-drop-(.+)$/);if(ue){let[,p]=ue;if(N)if(P!==p){let w="before",E=F.rect,_=$.activatorEvent,V=null;if(r.current)V=r.current.x;else {let j=He(_);j&&(V=j.x+$.delta.x);}if(V!==null){let j=E.left+E.width/2;V>j&&(w="after");}let le=Ze(C,P,p,w);a(le),h&&h(P,p,{type:"move",position:"center"});}else n(C),h&&h(P,null,null);else {let w="before",E=F.rect,_=$.activatorEvent,V=null;if(r.current)V=r.current.x;else {let j=He(_);j&&(V=j.x+$.delta.x);}if(V!==null){let j=E.left+E.width/2;V>j&&(w="after");}let le=Vt(C,P,p,w);a(le),h&&h(P,p,{type:"move",position:"center"});}return}let Q=k.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(Q){let[,p,w]=Q,E=w;E==="start"&&(E="left"),E==="end"&&(E="right");let _=N?fe(C,P):be(C,P),V;if(N){let j=U(C,P)?.tabsMetadata?.[P];V={type:"pane",id:pe(),tabIds:[P],activeTabId:P,tabsMetadata:j?{[P]:j}:void 0};}else V=te(C,P)??{type:"pane",id:pe(),tabIds:[P],activeTabId:P};if(_===null)a(V);else {let le=E==="left"||E==="right",j=E==="left"||E==="top",Te=50;p==="1/4"?Te=j?25:75:p==="1/3"&&(Te=j?100/3:200/3),a({type:"split",direction:le?"row":"column",first:j?V:_,second:j?_:V,splitPercentage:Te});}h&&h(P,"root",{type:"split",direction:E==="left"||E==="right"?"row":"column",position:E});return}let K=k.match(/^drop-(left|right|top|bottom|center)-(.+)$/);if(!K){n(C),h&&h(P,null,null);return}let[,Y,ee]=K;if(Y==="center"){if(N){let p=te(C,ee);if(p&&p.activeTabId){let w=p.activeTabId,E=Ze(C,P,w,"center");a(E),h&&h(P,ee,{type:"move",position:"center"});}else n(C),h&&h(P,null,null);}else n(C),h&&h(P,null,null);return}let S=N?U(C,P):te(C,P),I=S&&S.id===ee,ie=S&&S.tabIds.length===1;if(P===ee||I&&ie){n(C),h&&h(P,null,null);return}let se=Y==="left"||Y==="right"?"row":"column",G;if(N){let w=U(C,P)?.tabsMetadata?.[P];G={type:"pane",id:pe(),tabIds:[P],activeTabId:P,tabsMetadata:w?{[P]:w}:void 0};}else G=te(C,P)??{type:"pane",id:pe(),tabIds:[P],activeTabId:P};let oe=N?fe(C,P):be(C,P),Oe=Se(oe,ee,se,Y,G);a(Oe),h&&h(P,ee,{type:"split",direction:se,position:Y});},onDragCancel:()=>{c(null),i(null),R(false),s(null),b(null),f(null),H?.(null),Z.current=null;let $=l.current||t;l.current=null,n($),$!==t&&a($);}}}function Gt({persist:e,layout:t,setLayout:n}){let a=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[c,u]=ge.useState(false);ge.useEffect(()=>{if(a){let i=localStorage.getItem(o);if(i)try{let d=JSON.parse(i);d&&n(d);}catch(d){console.error("Failed to parse persisted zeugma layout",d);}}u(true);},[a,o,n]),ge.useEffect(()=>{a&&c&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[a,o,t,c]);}var Ee=null,Kt=false,ae=new Set,De=new Set,Ie=null;function Xn(){typeof window>"u"||Ie||(Ie=new MutationObserver(e=>{e.forEach(t=>{t.addedNodes.forEach(n=>{n instanceof HTMLElement&&(n.tagName.toLowerCase()==="style"||n.tagName.toLowerCase()==="link")&&ae.forEach(a=>{try{let o=n.cloneNode(!0);if(o.tagName.toLowerCase()==="link"){let c=n.href;c&&o.setAttribute("href",c);}a.head.appendChild(o);}catch(o){console.warn("Failed to mirror style node to popout:",o);}});});});}),Ie.observe(document.head,{childList:true}));}function ft(){Ie&&(Ie.disconnect(),Ie=null);}var Le=null;function Yn(){typeof window>"u"||Le||(Le=new MutationObserver(e=>{e.forEach(t=>{if(t.type==="attributes"&&t.attributeName){let n=document.documentElement.getAttribute(t.attributeName);ae.forEach(a=>{try{a&&a.documentElement&&(n!==null?a.documentElement.setAttribute(t.attributeName,n):a.documentElement.removeAttribute(t.attributeName));}catch(o){console.warn("Failed to sync documentElement attribute:",o);}});}});}),Le.observe(document.documentElement,{attributes:true}));}function mt(){Le&&(Le.disconnect(),Le=null);}var en=e=>{typeof requestAnimationFrame<"u"?requestAnimationFrame(e):setTimeout(e,0);};function me(){if(typeof window>"u")return document;if(Ee&&Ee.target){let t=Ee.target.ownerDocument;if(t&&t!==document)return t}let e=window.event;if(e&&e.target){let n=e.target.ownerDocument;if(n&&n!==document)return n}return window.__zeugmaActivePopoutDocument?window.__zeugmaActivePopoutDocument:document}function tn(){if(typeof window>"u"||Kt)return;Kt=true;let e=(r,l)=>{if(!r||!l)return false;try{let v=Object.getPrototypeOf(r);for(;v;){if(v===l)return !0;v=Object.getPrototypeOf(v);}}catch{}return false},t=(r,l)=>{try{Object.defineProperty(r,Symbol.hasInstance,{value:function(v){return v?e(v,r.prototype)?!0:l(v):!1},configurable:!0,writable:!0});}catch(v){console.warn("Failed to patch Symbol.hasInstance on",r,v);}};typeof Node<"u"&&t(Node,r=>typeof r.nodeType=="number"&&typeof r.nodeName=="string"),typeof Element<"u"&&t(Element,r=>r.nodeType===1),typeof HTMLElement<"u"&&t(HTMLElement,r=>r.nodeType===1&&typeof r.style=="object"),typeof HTMLBodyElement<"u"&&t(HTMLBodyElement,r=>r.nodeType===1&&r.tagName==="BODY"),typeof HTMLHtmlElement<"u"&&t(HTMLHtmlElement,r=>r.nodeType===1&&r.tagName==="HTML"),typeof HTMLInputElement<"u"&&t(HTMLInputElement,r=>r.nodeType===1&&r.tagName==="INPUT"),typeof HTMLTextAreaElement<"u"&&t(HTMLTextAreaElement,r=>r.nodeType===1&&r.tagName==="TEXTAREA"),typeof ShadowRoot<"u"&&t(ShadowRoot,r=>r.nodeType===11&&r.host!==void 0),typeof SVGElement<"u"&&t(SVGElement,r=>r.nodeType===1&&typeof r.getBBox=="function"),typeof Document<"u"&&t(Document,r=>r.nodeType===9),typeof Window<"u"&&t(Window,r=>r&&typeof r.document=="object"&&typeof r.location=="object");let n=Document.prototype,a=Object.getOwnPropertyDescriptor(n,"body"),o=Object.getOwnPropertyDescriptor(n,"documentElement"),c=Object.getOwnPropertyDescriptor(n,"head"),u=Object.getOwnPropertyDescriptor(n,"activeElement"),i=Object.getOwnPropertyDescriptor(n,"defaultView"),d=Object.getOwnPropertyDescriptor(n,"scrollingElement");Object.defineProperties(document,{body:{get(){let r=me();return r&&r!==document?r.body:a?.get?.call(document)||document.body},configurable:true},documentElement:{get(){let r=me();return r&&r!==document?r.documentElement:o?.get?.call(document)||document.documentElement},configurable:true},head:{get(){let r=me();return r&&r!==document?r.head:c?.get?.call(document)||document.head},configurable:true},activeElement:{get(){let r=me();return r&&r!==document?r.activeElement:u?.get?.call(document)||document.activeElement},configurable:true},defaultView:{get(){let r=me();return r&&r!==document?r.defaultView:i?.get?.call(document)||document.defaultView},configurable:true},scrollingElement:{get(){let r=me();return r&&r!==document?r.scrollingElement:d?.get?.call(document)||document.scrollingElement},configurable:true}});let f=Window.prototype,s=["innerWidth","innerHeight","pageXOffset","pageYOffset","scrollX","scrollY","screenX","screenY","outerWidth","outerHeight","devicePixelRatio"],b={};s.forEach(r=>{let l=Object.getOwnPropertyDescriptor(f,r)||Object.getOwnPropertyDescriptor(window,r);l&&l.get&&(b[r]=l.get);}),s.forEach(r=>{Object.defineProperty(window,r,{get(){let l=me();if(l&&l!==document&&l.defaultView)try{return l.defaultView[r]}catch{}let v=b[r];return v?v.call(window):window[r]},configurable:true});});let g=Node.prototype.contains;Node.prototype.contains=function(r){if(!r)return false;if(g.call(this,r))return true;if(this===document||this===document.body||this===document.documentElement)for(let l of ae)try{if(l.contains(r))return !0}catch{}return false};let m=()=>{Ee=null,globalThis.__zeugmaActivePopoutDocument=null;};["pointerdown","mousedown","click","keydown","focus","touchstart"].forEach(r=>{window.addEventListener(r,m,true);});let T=document.createElement;document.createElement=function(r,l){let v=me();return v&&v!==document?v.createElement(r,l):T.call(document,r,l)};let x=document.addEventListener;document.addEventListener=function(r,l,v){De.add({target:"document",type:r,listener:l,options:v}),x.call(document,r,l,v),ae.forEach(R=>{try{R.addEventListener(r,l,v);}catch{}});};let L=document.removeEventListener;document.removeEventListener=function(r,l,v){for(let R of De)if(R.target==="document"&&R.type===r&&R.listener===l){De.delete(R);break}L.call(document,r,l,v),ae.forEach(R=>{try{R.removeEventListener(r,l,v);}catch{}});};let h=window.addEventListener;window.addEventListener=function(r,l,v){De.add({target:"window",type:r,listener:l,options:v}),h.call(window,r,l,v),ae.forEach(R=>{try{R.defaultView&&R.defaultView.addEventListener(r,l,v);}catch{}});};let H=window.removeEventListener;window.removeEventListener=function(r,l,v){for(let R of De)if(R.target==="window"&&R.type===r&&R.listener===l){De.delete(R);break}H.call(window,r,l,v),ae.forEach(R=>{try{R.defaultView&&R.defaultView.removeEventListener(r,l,v);}catch{}});};let D=document.getElementById;document.getElementById=function(r){let l=me();if(l&&l!==document)return l.getElementById(r);let v=D.call(document,r);if(v)return v;for(let R of ae)try{let M=R.getElementById(r);if(M)return M}catch{}return null};let O=document.querySelector;document.querySelector=function(r){let l=me();if(l&&l!==document)return l.querySelector(r);let v=O.call(document,r);if(v)return v;for(let R of ae)try{let M=R.querySelector(r);if(M)return M}catch{}return null};let Z=document.querySelectorAll;document.querySelectorAll=function(r){let l=me();if(l&&l!==document)return l.querySelectorAll(r);let v=Z.call(document,r);if(v.length>0)return v;for(let R of ae)try{let M=R.querySelectorAll(r);if(M.length>0)return M}catch{}return v};}function nn(e){let{poppedOutTabIds:t,registerPopoutTarget:n,findTabById:a,dockTab:o}=e,c=ge.useRef({});ge.useEffect(()=>{let u=c.current;t.forEach(i=>{if(u[i]){try{u[i].focus();}catch{}return}tn();let f=a(i)?.metadata?.title||`Tab ${i}`,s=window.open("",`zeugma-popout-${i}`,"width=800,height=600");if(!s){console.warn("Failed to open popout window. Check popup blocker."),o(i);return}u[i]=s,ae.add(s.document),De.forEach(l=>{try{l.target==="window"?s.addEventListener(l.type,l.listener,l.options):s.document.addEventListener(l.type,l.listener,l.options);}catch{}}),Xn(),Yn(),s.document.title=f,s.document.head.innerHTML="";try{let l=s.document.createElement("base");l.setAttribute("href",window.location.origin+"/"),s.document.head.appendChild(l);}catch{}if(Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).forEach(l=>{let v=l.cloneNode(true);if(l.tagName.toLowerCase()==="link"){let R=l.href;R&&v.setAttribute("href",R);}else if(l.tagName.toLowerCase()==="style")try{let R=l.sheet?.cssRules;if(R&&R.length>0){let M=Array.from(R).map(q=>q.cssText).join(`
10
+ `);v.textContent=M;}}catch{}s.document.head.appendChild(v);}),typeof document.adoptedStyleSheets<"u"&&typeof s.document.adoptedStyleSheets<"u")try{let l=Array.from(document.adoptedStyleSheets).map(v=>{try{let R=new s.CSSStyleSheet,M=Array.from(v.cssRules).map(q=>q.cssText).join(`
11
+ `);return R.replaceSync(M),R}catch{return null}}).filter(v=>v!==null);s.document.adoptedStyleSheets=l;}catch(l){console.warn("Failed to copy adoptedStyleSheets:",l);}s.document.documentElement.className=document.documentElement.className,s.document.body.className=document.body.className,Array.from(document.documentElement.attributes).forEach(l=>{s.document.documentElement.setAttribute(l.name,l.value);}),s.document.body.style.margin="0",s.document.body.style.padding="0",s.document.body.style.height="100vh",s.document.body.style.overflow="hidden";let b=document.getElementById(`zeugma-tab-target-${i}`),g="";b&&(g=window.getComputedStyle(b).backgroundColor,(!g||g==="transparent"||g==="rgba(0, 0, 0, 0)")&&b.parentElement&&(g=window.getComputedStyle(b.parentElement).backgroundColor));let m=window.getComputedStyle(document.documentElement),y=window.getComputedStyle(document.body),T=y.backgroundColor,L=!T||T==="transparent"||T==="rgba(0, 0, 0, 0)"?m.backgroundColor:T,h=g&&g!=="transparent"&&g!=="rgba(0, 0, 0, 0)"?g:L&&L!=="transparent"&&L!=="rgba(0, 0, 0, 0)"?L:"#181b1f";document.documentElement.getAttribute("data-theme")||(s.document.documentElement.style.backgroundColor=h,s.document.body.style.backgroundColor=h),s.document.body.style.color=y.color||m.color,s.document.body.style.fontFamily=y.fontFamily||m.fontFamily;let D=s.document.createElement("div");D.id=`zeugma-popout-container-${i}`,D.className="grafana-panel h-full w-full overflow-hidden",D.style.width="100%",D.style.height="100%",D.style.border="none",s.document.body.appendChild(D),n?.(i,D);let O=["pointerdown","mousedown","click","keydown","focus","touchstart"],Z=l=>{Ee=l,globalThis.__zeugmaActivePopoutDocument=s.document,setTimeout(()=>{Ee===l&&(Ee=null,globalThis.__zeugmaActivePopoutDocument=null);},0);};O.forEach(l=>{s.addEventListener(l,Z,true);});let r=()=>{ae.delete(s.document),ae.size===0&&(ft(),mt()),o(i);};s.addEventListener("beforeunload",r),s.__zeugmaCleanup=()=>{O.forEach(l=>{s.removeEventListener(l,Z,true);}),s.removeEventListener("beforeunload",r);};}),Object.keys(u).forEach(i=>{if(!t.includes(i)){let d=u[i];if(delete u[i],n?.(i,null),d){ae.delete(d.document),ae.size===0&&(ft(),mt());try{let f=d;f.__zeugmaCleanup&&f.__zeugmaCleanup(),en(()=>{try{f.close();}catch{}});}catch{}}}});},[t,n,a,o]),ge.useEffect(()=>()=>{let u=c.current;Object.keys(u).forEach(i=>{let d=u[i];if(d){ae.delete(d.document);try{let f=d;f.__zeugmaCleanup&&f.__zeugmaCleanup(),en(()=>{try{f.close();}catch{}});}catch{}}}),ae.size===0&&(ft(),mt());},[]);}typeof window<"u"&&tn();var on=({activeId:e,render:t,className:n})=>{let a=ge.useRef(null);return ge.useEffect(()=>{let o=c=>{a.current&&(a.current.style.transform=`translate(${c.clientX+12}px, ${c.clientY+12}px)`);};return document.addEventListener("pointermove",o),()=>document.removeEventListener("pointermove",o)},[]),jsxRuntime.jsx("div",{ref:a,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var no=({popoutDoc:e,children:t})=>{if(e===document)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t});let n=ge__default.default.useEffect,a=ge__default.default.useLayoutEffect,o=ge__default.default.useInsertionEffect;ge__default.default.useEffect=(c,u)=>n(()=>{window.__zeugmaActivePopoutDocument=e;try{let i=c();return typeof i=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return i()}finally{window.__zeugmaActivePopoutDocument=null;}}:i}finally{window.__zeugmaActivePopoutDocument=null;}},u),ge__default.default.useLayoutEffect=(c,u)=>a(()=>{window.__zeugmaActivePopoutDocument=e;try{let i=c();return typeof i=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return i()}finally{window.__zeugmaActivePopoutDocument=null;}}:i}finally{window.__zeugmaActivePopoutDocument=null;}},u),o&&(ge__default.default.useInsertionEffect=(c,u)=>o(()=>{window.__zeugmaActivePopoutDocument=e;try{let i=c();return typeof i=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return i()}finally{window.__zeugmaActivePopoutDocument=null;}}:i}finally{window.__zeugmaActivePopoutDocument=null;}},u)),window.__zeugmaActivePopoutDocument=e;try{return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t})}finally{window.__zeugmaActivePopoutDocument=null,ge__default.default.useEffect=n,ge__default.default.useLayoutEffect=a,o&&(ge__default.default.useInsertionEffect=o);}},an=ge__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:a}=e,{renderPopoutWrapper:o}=re(),[c,u]=ge.useState(false),i=ge.useRef(null);if(ge.useEffect(()=>{u(true);},[]),ge.useEffect(()=>{if(!c||!i.current)return;let m=i.current;if(t)t.ownerDocument.adoptNode(m),t.appendChild(m);else {let y=document.getElementById("zeugma-hidden-portal-container");y||(y=document.createElement("div"),y.id="zeugma-hidden-portal-container",y.style.display="none",document.body.appendChild(y)),document.adoptNode(m),y.appendChild(m);}},[t,c]),ge.useEffect(()=>()=>{i.current&&i.current.remove();},[]),!c)return null;let d=t?t.ownerDocument:document;i.current&&i.current.ownerDocument!==d&&(i.current.remove(),i.current=null),i.current||(i.current=d.createElement("div"),i.current.className=`zeugma-portal-wrapper-${a}`,i.current.style.width="100%",i.current.style.height="100%");let f=i.current;if(!f||!n)return null;let s=!!(t&&t.ownerDocument&&t.ownerDocument!==document),b=e.remountOnPopout?s?"-popped":"-docked":"",g=jsxRuntime.jsx(ge__default.default.Fragment,{children:n(e)},`${a}${b}`);return s&&t&&t.ownerDocument&&o&&(g=o({tabId:a,document:t.ownerDocument,window:t.ownerDocument.defaultView||window,children:g})),reactDom.createPortal(jsxRuntime.jsx(no,{popoutDoc:s&&t?t.ownerDocument:document,children:g}),f)},(e,t)=>e.target===t.target&&e.renderWidget===t.renderWidget&&e.tabDetails.id===t.tabDetails.id&&e.tabDetails.paneId===t.tabDetails.paneId&&e.tabDetails.isActive===t.tabDetails.isActive&&e.tabDetails.index===t.tabDetails.index&&e.tabDetails.metadata===t.tabDetails.metadata);var sn=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:a,renderPaneRef:o,renderPane:c,tabHeadersRef:u,classNames:i})=>{if(a)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:a({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let d=o.current||c;if(d)return jsxRuntime.jsx("div",{className:i.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:d(e)})}else if(t==="tab"){let d=o.current||c;if(d)return jsxRuntime.jsx("div",{className:i.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:d(e)});let f=u.current[e];if(f){let s=i.tab?typeof i.tab=="function"?i.tab(e):i.tab:"";return jsxRuntime.jsx("div",{className:`${i.tabDragPreview||""} ${s}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden"},children:f({isDragging:true,isOver:false})})}}return jsxRuntime.jsx("div",{style:{pointerEvents:"none",overflow:"hidden",width:"100%",height:"100%"}})};function bt({containerRef:e,isRow:t,direction:n,splitPercentage:a,resizerSize:o,snapThreshold:c,layout:u,currentNode:i,onLayoutChange:d,onResizeStart:f,onResizeEnd:s,parentLeft:b,parentTop:g,parentWidth:m,parentHeight:y}){let{onResizeStart:T,onResize:x,onResizeEnd:L,minSplitPercentage:h=5,maxSplitPercentage:H=95,locked:D=false}=re();return ge.useCallback(O=>{if(D)return;O.preventDefault();let Z=e.current;if(!Z)return;f&&f(),T&&T(i);let r=Z.getBoundingClientRect(),l=O.clientX,v=O.clientY,R=a,M=O.currentTarget,q=r.left+r.width*(b/100),ne=r.top+r.height*(g/100),J=r.width*(m/100),A=r.height*(y/100),W=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(B=>B!==M&&B.getAttribute("data-direction")===n).map(B=>{let N=B.getBoundingClientRect();return t?N.left+N.width/2:N.top+N.height/2}),F=R;Nt({cursor:t?"col-resize":"row-resize",resizerEl:M,onMove:B=>{let N=t?(B.clientX-l)/J*100:(B.clientY-v)/A*100,P=R+N,z=t?q+(J-o)*(P/100)+o/2:ne+(A-o)*(P/100)+o/2,C=1/0,k=null;for(let Y of W){let ee=Math.abs(z-Y);ee<c&&ee<C&&(C=ee,k=Y);}let ue=P;k!==null&&(ue=t?(k-o/2-q)/(J-o)*100:(k-o/2-ne)/(A-o)*100);let Q=Math.max(h,Math.min(H,ue));F=Q;let K=xe(u,i,Q);if(K){let{panes:Y,splitters:ee}=ve(K),S=e.current;if(S){for(let I of Y)S.style.setProperty(`--pane-left-${I.paneId}`,`${I.left}%`),S.style.setProperty(`--pane-top-${I.paneId}`,`${I.top}%`),S.style.setProperty(`--pane-width-${I.paneId}`,`${I.width}%`),S.style.setProperty(`--pane-height-${I.paneId}`,`${I.height}%`);for(let I of ee)S.style.setProperty(`--splitter-pos-${I.id}`,`${I.direction==="row"?I.left:I.top}%`);}}x&&x(i,Q);},onEnd:()=>{let B=xe(u,i,F),N=e.current;if(N){let{panes:P,splitters:z}=ve(B);for(let C of P)N.style.removeProperty(`--pane-left-${C.paneId}`),N.style.removeProperty(`--pane-top-${C.paneId}`),N.style.removeProperty(`--pane-width-${C.paneId}`),N.style.removeProperty(`--pane-height-${C.paneId}`);for(let C of z)N.style.removeProperty(`--splitter-pos-${C.id}`);}d(B),s&&s(),L&&L(i,F);}});},[e,t,n,a,o,c,u,i,d,f,s,T,x,L,h,H,b,g,m,y])}var ln=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:a})=>{let{renderingLayout:o,setLayout:c,classNames:u,locked:i}=re(),[d,f]=ge.useState(false),{currentNode:s,direction:b,left:g,top:m,width:y,height:T,parentLeft:x,parentTop:L,parentWidth:h,parentHeight:H}=e,D=b==="row",O=bt({containerRef:a,isRow:D,direction:b,splitPercentage:s.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:s,onLayoutChange:c,onResizeStart:()=>f(true),onResizeEnd:()=>f(false),parentLeft:x,parentTop:L,parentWidth:h,parentHeight:H}),Z=D?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${g}%) - ${t/2}px)`,top:`calc(${m}% + ${t/2}px)`,width:`${t}px`,height:`calc(${T}% - ${t}px)`,cursor:i?"default":"col-resize",pointerEvents:i?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"}:{position:"absolute",left:`calc(${g}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${m}%) - ${t/2}px)`,width:`calc(${y}% - ${t}px)`,height:`${t}px`,cursor:i?"default":"row-resize",pointerEvents:i?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:u.resizer||"","data-direction":b,"data-resizing":d||void 0,style:Z,onPointerDown:O,role:"separator","aria-valuenow":s.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},cn=ge__default.default.memo(({paneId:e,renderPane:t})=>jsxRuntime.jsx(jsxRuntime.Fragment,{children:t(e)}),(e,t)=>e.paneId===t.paneId&&e.renderPane===t.renderPane);var vt=({renderPane:e,tree:t,resizerSize:n,snapThreshold:a})=>{zt(e);let{renderingLayout:o,activeId:c,dismissIntentId:u,setContainerRef:i,fullscreenPaneId:d,snapThreshold:f,locked:s,classNames:b,resizerSize:g}=re(),m=a!==void 0?a:f??8,y=n!==void 0?n:g??4,T=t!==void 0?t:o,x=ge.useRef(null),{panes:L,splitters:h}=ge.useMemo(()=>T?ve(T):{panes:[],splitters:[]},[T]);if(!T&&t!==void 0)return null;let H=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[L.map(D=>{let O=d===D.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:O?"0%":`var(--pane-left-${D.paneId}, ${D.left}%)`,top:O?"0%":`var(--pane-top-${D.paneId}, ${D.top}%)`,width:O?"100%":`var(--pane-width-${D.paneId}, ${D.width}%)`,height:O?"100%":`var(--pane-height-${D.paneId}, ${D.height}%)`,overflow:"hidden",zIndex:O?20:1,display:d&&!O?"none":"block",padding:O?"0px":`${y/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(cn,{paneId:D.paneId,renderPane:e})},D.paneId)}),!d&&h.map(D=>jsxRuntime.jsx(ln,{splitter:D,resizerSize:y,snapThreshold:m,containerRef:x},D.id))]});if(t===void 0){let D=c!==null&&c===u,O=r=>{i(r),x.current=r;},Z=`${b.dashboard||""} ${D&&b.dashboardDismissActive||""} ${s&&b.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:O,className:Z,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[H(),c!==null&&!s&&jsxRuntime.jsx(pn,{activeClassName:b.rootDropPreview??b.dropPreview})]})}return jsxRuntime.jsx("div",{ref:x,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:H()})};var fo=e=>{let{controller:t,children:n,renderDragOverlay:a,classNames:o={},renderPane:c,resizerSize:u,dragActivationDistance:i=8,snapThreshold:d=8,minSplitPercentage:f=5,maxSplitPercentage:s=95,enableDragToDismiss:b=false,dismissThreshold:g=60,onRemove:m,onDragStart:y,onDragEnd:T,onResizeStart:x,onResize:L,onResizeEnd:h,onDismissIntentChange:H,persist:D=false,renderPopoutWrapper:O}=e,Z=t,{layout:r,setLayout:l,_internalSetLayout:v,renderingLayout:R,fullscreenPaneId:M,setFullscreenPaneId:q,locked:ne,setLocked:J,findPaneById:A,findPaneContainingTab:$,findTabById:W,getTabMetadata:F,getActiveTabMetadata:B,activeId:N,setActiveId:P,activeType:z,setActiveType:C,dismissIntentId:k,setDismissIntentId:ue,containerRef:Q,setContainerRef:K,removePane:Y,addTab:ee,updateMetadata:S,updatePaneLock:I,selectTab:ie,mergeTab:se,removeTab:G,splitPane:oe,updateSplitPercentage:Oe,moveTab:p,poppedOutTabIds:w=[],popoutTab:E,dockTab:_}=Z;Gt({persist:D,layout:r,setLayout:l});let{portalTargets:V,registerPortalTarget:le,registerPopoutTarget:j,registerRenderCallback:Te,renderCallbacksRef:Ve,registerRenderPane:wt,renderPaneRef:st,registerTabHeader:Rt,tabHeadersRef:lt,activeIdRef:We}=kt();nn({poppedOutTabIds:w,registerPopoutTarget:j,findTabById:W,dockTab:_});let xt=ge.useCallback(de=>w.includes(de),[w]),{overTabId:Dt,setOverTabId:xn,overTabPosition:Et,setOverTabPosition:Dn,handleDragStartInternal:En,handleDragEndInternal:Cn}=At({onDragStart:y,onDragEnd:T}),Sn=Yt({layout:r,_internalSetLayout:v,setLayout:l,activeId:N,setActiveId:P,activeType:z,setActiveType:C,dismissIntentId:k,setDismissIntentId:ue,setOverTabId:xn,setOverTabPosition:Dn,containerRef:Q,dragActivationDistance:i,enableDragToDismiss:b,dismissThreshold:g,onRemove:m,onDragStart:En,onDragEnd:Cn,onDismissIntentChange:H,removeTab:G,removePane:Y}),ct=ge.useMemo(()=>o,[o.dashboard,o.dashboardDismissActive,o.pane,o.paneLocked,o.dropPreview,o.rootDropPreview,o.dragOverlay,o.paneDragPreview,o.tabDragPreview,o.resizer,o.dismissPreview,o.dashboardLocked,o.lockedPreview,o.tabDropPreview,o.tabSeparator,o.tabsContainer,o.tab,o.paneContainer,o.paneHeader,o.paneControls,o.paneButton,o.tabCloseButton,o.dragHandle]),Ct=ge.useCallback((de,je)=>{h&&h(de,je);},[h]),Nn=ge.useMemo(()=>({layout:r,renderingLayout:R,setLayout:l,activeId:N,activeType:z,dismissIntentId:k,setContainerRef:K,fullscreenPaneId:M,classNames:ct,onRemove:m,onFullscreenChange:q,snapThreshold:d,onResizeStart:x,onResize:L,onResizeEnd:Ct,minSplitPercentage:f,maxSplitPercentage:s,locked:ne,setLocked:J,findPaneById:A,findPaneContainingTab:$,findTabById:W,getTabMetadata:F,getActiveTabMetadata:B,renderPane:c,resizerSize:u,poppedOutTabIds:w,isTabPoppedOut:xt,renderPopoutWrapper:O}),[r,R,N,z,k,K,M,ct,m,q,d,x,L,f,s,l,Ct,ne,J,A,$,W,F,B,c,u,w,xt,O]),In=ge.useMemo(()=>({overTabId:Dt,overTabPosition:Et}),[Dt,Et]),Ln=ge.useMemo(()=>({removePane:Y,addTab:ee,updateMetadata:S,updatePaneLock:I,selectTab:ie,mergeTab:se,removeTab:G,setFullscreenPaneId:q,setLocked:J,splitPane:oe,updateSplitPercentage:Oe,moveTab:p,popoutTab:E,dockTab:_}),[Y,ee,S,I,ie,se,G,q,J,oe,Oe,p,E,_]),Mn=Ot(r),kn=ge.useMemo(()=>({registerPortalTarget:le,registerRenderCallback:Te,renderCallbacksRef:Ve,registerRenderPane:wt,renderPaneRef:st,registerTabHeader:Rt,tabHeadersRef:lt,activeIdRef:We,registerPopoutTarget:j}),[le,Te,Ve,wt,st,Rt,lt,We,j]);return We&&(We.current=N),jsxRuntime.jsx(we.Provider,{value:Ln,children:jsxRuntime.jsx(dt.Provider,{value:Nn,children:jsxRuntime.jsx(pt.Provider,{value:In,children:jsxRuntime.jsxs(Pe.Provider,{value:kn,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...Sn,children:n}),N&&z&&jsxRuntime.jsx(on,{activeId:N,render:de=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:de===k?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(sn,{activeId:de,activeType:z,dismissIntentId:k,renderDragOverlay:a,renderPaneRef:st,renderPane:c,tabHeadersRef:lt,classNames:ct})}),className:`${o.dragOverlay||""} ${N===k&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:Mn.map(de=>{let je=V[de],St=W(de);return St?jsxRuntime.jsx(an,{tabDetails:St,target:je||null,renderWidget:Ve.current[de]},de):null})})]})})})})},mo=({renderPane:e,resizerSize:t,snapThreshold:n})=>{if(!e)throw new Error("Zeugma component requires a renderPane prop when used as a standalone renderer.");return jsxRuntime.jsx(vt,{renderPane:e,resizerSize:t,snapThreshold:n})},go=e=>{let{children:t,...n}=e,{controller:a}=e;if(!a)throw new Error("Zeugma component requires a controller.");return jsxRuntime.jsx(fo,{...e,children:t!==void 0?t:jsxRuntime.jsx(mo,{...n})})};var ho={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"}}},yo={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"}}},To=({id:e,fraction:t,edge:n,activeClassName:a})=>{let{setNodeRef:o,isOver:c}=core.useDroppable({id:e}),u={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...yo[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:ho[n][t]}),c&&jsxRuntime.jsx("div",{className:a,style:u})]})},pn=({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(To,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var ot=ge.createContext(null);var Do={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"},center:{position:"absolute",top:"25%",left:"25%",width:"50%",height:"50%",zIndex:22,pointerEvents:"auto"}},Eo={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"},center:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:21,pointerEvents:"none",boxSizing:"border-box"}},rt=({id:e,position:t,activeClassName:n})=>{let{setNodeRef:a,isOver:o}=core.useDroppable({id:e});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:a,style:Do[t]}),o&&jsxRuntime.jsx("div",{className:n,style:Eo[t]})]})};var gn=({children:e,className:t,style:n})=>{let a=ge.useContext(ot);if(!a)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...c}=a;return jsxRuntime.jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:c,children:e})};var zo=ge.createContext(void 0);var Fe=({id:e,locked:t=false,children:n,className:a,style:o})=>{let{locked:c,classNames:u={},fullscreenPaneId:i,poppedOutTabIds:d=[]}=re(),f=ge.useContext(we),{overTabId:s}=Ue(),b=ge.useContext(Pe);ge.useEffect(()=>(b?.registerTabHeader&&b.registerTabHeader(e,n),()=>{b?.registerTabHeader&&b.activeIdRef?.current!==e&&b.registerTabHeader(e,()=>null);}),[e,n,b]);let g=d.includes(e),m=ge.useContext(yt),y=t||c||(m?.locked??false)||i!==null,{attributes:T,listeners:x,setNodeRef:L,isDragging:h}=core.useDraggable({id:`tab-header-${e}`,disabled:y}),{setNodeRef:H,isOver:D}=core.useDroppable({id:`tab-drop-${e}`,disabled:y}),O=W=>{L(W),H(W);},Z=D&&s===e,r=m?.tabIds||[],l=r.indexOf(e),v=m?.activeTabId,M=l>0&&e!==v&&r[l-1]!==v?jsxRuntime.jsx("div",{className:u.tabSeparator}):null,q=m?m.activeTabId===e:false,ne=m?.tabsMetadata?.[e],J=ge.useCallback(()=>{m?.selectTab(e);},[m,e]),A=ge.useCallback(()=>{m?.removeTab(e);},[m,e]),$=ge.useMemo(()=>({tabId:e,isActive:q,isDragging:h,isOver:Z,metadata:ne,locked:y,selectTab:J,removeTab:A,isPoppedOut:g,popoutTab:()=>f?.popoutTab(e),dockTab:()=>f?.dockTab(e)}),[e,q,h,Z,ne,y,J,A,g,f]);return jsxRuntime.jsx(zo.Provider,{value:$,children:jsxRuntime.jsxs("div",{ref:O,id:`tab-header-${e}`,className:a,style:{display:"inline-flex",position:"relative",cursor:y?"default":"grab",...o},...y?{}:x,...y?{}:T,children:[M,n({isDragging:h,isOver:Z})]})})};var yt=ge.createContext(void 0);var yn=(e,t)=>typeof e=="function"?e(t):e,Tt=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:a,selectTab:o,removeTab:c,renderTab:u,classNames:i,styles:d})=>{let f=ge.useContext(at),s=e??f?.tabIds??[],b=t??f?.activeTabId??"",g=n??f?.locked??false,m=a??f?.tabsMetadata,y=o??f?.selectTab??(()=>{}),T=c??f?.removeTab??(()=>{}),{classNames:x={},activeType:L,poppedOutTabIds:h=[]}=re(),H=ge.useContext(we),{overTabId:D,overTabPosition:O}=Ue(),Z=ge.useMemo(()=>({tabIds:s,activeTabId:b,locked:g,tabsMetadata:m,selectTab:y,removeTab:T}),[s,b,g,m,y,T]),r=Wt(s,L,D,O);return jsxRuntime.jsx(yt.Provider,{value:Z,children:jsxRuntime.jsxs("div",{className:i?.container,style:{display:"flex",alignItems:"center",height:"100%",...d?.container},children:[s.map((l,v)=>{let R=m?.[l],M=yn(i?.tab,l),q=yn(d?.tab,l),ne=v===r;return jsxRuntime.jsxs(ge__default.default.Fragment,{children:[ne&&x.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:x.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:v===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(Fe,{id:l,locked:g,className:M,style:q,children:({isDragging:J,isOver:A})=>u({id:l,paneId:f?.id??"",isActive:l===b,index:v,isDragging:J,isOver:A,metadata:R,onSelect:()=>y(l),onRemove:()=>T(l),isPoppedOut:h.includes(l),popout:()=>H?.popoutTab(l),dock:()=>H?.dockTab(l)})})]},l)}),r===s.length&&x.tabDropPreview&&jsxRuntime.jsx("div",{style:{position:"relative",height:"100%",width:0,zIndex:10},children:jsxRuntime.jsx("div",{className:x.tabDropPreview,style:{position:"absolute",top:0,bottom:0,transform:"translateX(-100%)"}})})]})})};Tt.Tab=Fe;var Pn=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var at=ge.createContext(void 0),Rn=()=>{let e=ge.useContext(at);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},qo=({children:e,className:t,style:n})=>{let{activeTabId:a}=Rn(),{classNames:o,isTabPoppedOut:c}=re(),{dockTab:u}=ze(),i=ge.useRef(null),d=ge.useContext(Pe);if(!d)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:f,registerRenderCallback:s}=d,b=ge.useMemo(()=>typeof e=="function"?e:()=>e,[e]);s(a,b),ge.useEffect(()=>{let m=i.current;return f(a,m),()=>{f(a,null,m);}},[a,f]);let g=c(a);return jsxRuntime.jsx("div",{ref:i,id:`zeugma-tab-target-${a}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",position:"relative",...n},children:g&&jsxRuntime.jsxs("div",{className:"zeugma-popout-placeholder",style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"12px",padding:"24px",textAlign:"center",backgroundColor:"#161719",color:"#94a3b8",fontSize:"13px",fontWeight:500},children:[jsxRuntime.jsx("div",{children:"This panel is open in a new window"}),jsxRuntime.jsx("button",{onClick:()=>u(a),style:{padding:"6px 12px",fontSize:"11px",fontWeight:600,borderRadius:"4px",backgroundColor:"#2563eb",color:"#ffffff",border:"none",cursor:"pointer",boxShadow:"0 1px 3px rgba(0,0,0,0.1)"},onMouseOver:m=>{m.currentTarget.style.backgroundColor="#1d4ed8";},onMouseOut:m=>{m.currentTarget.style.backgroundColor="#2563eb";},children:"Dock Back"})]})})},ke=({id:e,children:t,style:n,locked:a=false})=>{let{layout:o,renderingLayout:c,activeId:u,activeType:i,classNames:d,fullscreenPaneId:f,onFullscreenChange:s,locked:b,poppedOutTabIds:g=[]}=re(),{removePane:m,updateMetadata:y,selectTab:T,removeTab:x,popoutTab:L,dockTab:h}=ze(),H=ge.useMemo(()=>{if(i==="tab"&&e===u){let k=U(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:k?{[e]:k}:void 0}}return Ht(e===u?o:c,e)},[o,c,e,u,i]),D=H?.id??e,O=H?.tabIds??[e],Z=H?.activeTabId??e,r=H?.tabsMetadata,l=r?.[e],v=H?.locked??false,R=a||v,M=b||R||f!==null,q=b||R||f!==null,ne=u!==null&&u!==e&&(!O.includes(u)||O.length>1)&&!q,{attributes:J,listeners:A,setNodeRef:$}=core.useDraggable({id:e,disabled:M}),W=u!==null&&O.includes(u),F=f===e,B=ge.useMemo(()=>({isDragging:W,isFullscreen:F,toggleFullscreen:()=>s?.(F?null:e),remove:()=>{F&&s?.(null),m(D);},metadata:l,updateMetadata:z=>{y(e,z);},locked:M,tabIds:O,activeTabId:Z,selectTab:z=>T(D,z),removeTab:z=>{F&&z===Z&&s?.(null),x(z);},tabsMetadata:r,updateTabMetadata:(z,C)=>{y(z,C);},isActiveTabPoppedOut:g.includes(Z),popoutTab:z=>L(z||Z),dockTab:z=>h(z||Z)}),[W,F,s,e,x,l,y,M,O,Z,T,D,r,g,L,h]),N=ge.useMemo(()=>M?{disabled:true}:{...A,...J},[A,J,M]),P=`${d.pane||""} ${R&&d.paneLocked||""}`.trim();return jsxRuntime.jsx(at.Provider,{value:{id:e,...B},children:jsxRuntime.jsx(ot.Provider,{value:N,children:jsxRuntime.jsxs("div",{ref:$,id:e,className:P,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,ne&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(z=>jsxRuntime.jsx(rt,{id:`drop-${z}-${e}`,position:z,activeClassName:d.dropPreview},z)),i==="tab"&&jsxRuntime.jsx(rt,{id:`drop-center-${e}`,position:"center",activeClassName:d.swapPreview??d.dropPreview})]}),u!==null&&u!==e&&q&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(rt,{id:`drop-locked-${e}`,position:"full",activeClassName:d.lockedPreview||""})})]})})})};ke.Content=qo;ke.DragHandle=gn;ke.Tabs=Tt;ke.Tab=Fe;ke.Controls=Pn;exports.Pane=ke;exports.PaneTree=vt;exports.Zeugma=go;exports.usePaneContext=Rn;exports.useResizer=bt;exports.useZeugma=Hn;exports.useZeugmaContext=$n;//# sourceMappingURL=index.cjs.map
11
12
  //# sourceMappingURL=index.cjs.map