react-zeugma 6.8.0 → 6.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -227,17 +227,17 @@ import { Tabs } from 'react-zeugma'
227
227
 
228
228
  ##### Props
229
229
 
230
- | Property | Description | Type | Default |
231
- | -------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
232
- | `tabIds` | Array of tab IDs. | `string[]` | - |
233
- | `activeTabId` | The currently active tab ID. | `string` | - |
234
- | `locked` | Whether tab dragging/reordering is disabled. | `boolean` | `false` |
235
- | `tabsMetadata` | Metadata mapping associated with each tab in the pane. | `Record<string, Record<string, unknown>>` | - |
236
- | `selectTab` | Callback when a tab is selected. | `(id: string) => void` | - |
237
- | `removeTab` | Callback when a tab is closed. | `(id: string) => void` | - |
238
- | `classNames` | Custom class names for the container and tabs. | `{ container?: string; tab?: string \| ((tabId: string) => string) }` | - |
239
- | `styles` | Custom CSS style overrides for the container and tabs. | `{ container?: CSSProperties; tab?: CSSProperties \| ((tabId: string) => CSSProperties) }` | - |
240
- | `renderTab` | Render prop function called for each tab item. | `(props: { tabId: string; activeTabId: string; isDragging: boolean; isOver: boolean; metadata?: Record<string, unknown>; onSelect: () => void; onRemove: () => void }) => ReactNode` | - |
230
+ | Property | Description | Type | Default |
231
+ | -------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- |
232
+ | `tabIds` | Array of tab IDs. | `string[]` | - |
233
+ | `activeTabId` | The currently active tab ID. | `string` | - |
234
+ | `locked` | Whether tab dragging/reordering is disabled. | `boolean` | `false` |
235
+ | `tabsMetadata` | Metadata mapping associated with each tab in the pane. | `Record<string, Record<string, unknown>>` | - |
236
+ | `selectTab` | Callback when a tab is selected. | `(id: string) => void` | - |
237
+ | `removeTab` | Callback when a tab is closed. | `(id: string) => void` | - |
238
+ | `classNames` | Custom class names for the container and tabs. | `{ container?: string; tab?: string \| ((tabId: string) => string) }` | - |
239
+ | `styles` | Custom CSS style overrides for the container and tabs. | `{ container?: CSSProperties; tab?: CSSProperties \| ((tabId: string) => CSSProperties) }` | - |
240
+ | `renderTab` | Render prop function called for each tab item. | `(props: { tabId: string; activeTabId: string; isDragging: boolean; isOver: boolean; metadata?: Record<string, unknown>; onSelect: () => void; onRemove: () => void; isPoppedOut: boolean; popout: () => void; dock: () => void }) => ReactNode` | - |
241
241
 
242
242
  ---
243
243
 
@@ -313,6 +313,9 @@ const { layout, locked, setLocked, addTab, removePane, selectTab, findPaneById }
313
313
  | `findTabById` | Queries detailed tab location and state metadata. | `(tabId: string) => TabDetails \| null` |
314
314
  | `getTabMetadata` | Gets metadata for a tab ID. | `(tabId: string) => Record<string, unknown> \| undefined` |
315
315
  | `getActiveTabMetadata` | Gets metadata for the active tab in a pane. | `(paneId: string) => Record<string, unknown> \| undefined` |
316
+ | `poppedOutTabIds` | The list of tab/widget IDs that are currently open in a new window. | `string[]` |
317
+ | `popoutTab` | Popout the specified tab into a new window. | `(tabId: string) => void` |
318
+ | `dockTab` | Dock the specified tab back to the main layout. | `(tabId: string) => void` |
316
319
 
317
320
  ---
318
321
 
@@ -341,22 +344,25 @@ const {
341
344
 
342
345
  ##### Context Values
343
346
 
344
- | Property / Method | Description | Type |
345
- | ------------------- | --------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
346
- | `id` | The ID of the current pane. | `string` |
347
- | `tabIds` | List of tab IDs inside the pane. | `string[]` |
348
- | `activeTabId` | Currently active tab ID. | `string` |
349
- | `isDragging` | `true` if this pane is being dragged. | `boolean` |
350
- | `isFullscreen` | `true` if this pane is maximized. | `boolean` |
351
- | `toggleFullscreen` | Toggles maximized state for this pane. | `() => void` |
352
- | `remove` | Removes this pane from the layout tree. | `() => void` |
353
- | `selectTab` | Activates a tab within this pane. | `(tabId: string) => void` |
354
- | `removeTab` | Closes a tab from this pane. | `(tabId: string) => void` |
355
- | `metadata` | Active tab's custom metadata. | `Record<string, unknown> \| undefined` |
356
- | `updateMetadata` | Updates active tab's metadata. | `(updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
357
- | `locked` | Whether the pane or the dashboard is locked. | `boolean` |
358
- | `tabsMetadata` | Tab metadata mapping for all tabs inside this pane. | `Record<string, Record<string, unknown>> \| undefined` |
359
- | `updateTabMetadata` | Updates metadata for a specific tab in the pane. | `(tabId: string, updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
347
+ | Property / Method | Description | Type |
348
+ | ---------------------- | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
349
+ | `id` | The ID of the current pane. | `string` |
350
+ | `tabIds` | List of tab IDs inside the pane. | `string[]` |
351
+ | `activeTabId` | Currently active tab ID. | `string` |
352
+ | `isDragging` | `true` if this pane is being dragged. | `boolean` |
353
+ | `isFullscreen` | `true` if this pane is maximized. | `boolean` |
354
+ | `toggleFullscreen` | Toggles maximized state for this pane. | `() => void` |
355
+ | `remove` | Removes this pane from the layout tree. | `() => void` |
356
+ | `selectTab` | Activates a tab within this pane. | `(tabId: string) => void` |
357
+ | `removeTab` | Closes a tab from this pane. | `(tabId: string) => void` |
358
+ | `metadata` | Active tab's custom metadata. | `Record<string, unknown> \| undefined` |
359
+ | `updateMetadata` | Updates active tab's metadata. | `(updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
360
+ | `locked` | Whether the pane or the dashboard is locked. | `boolean` |
361
+ | `tabsMetadata` | Tab metadata mapping for all tabs inside this pane. | `Record<string, Record<string, unknown>> \| undefined` |
362
+ | `updateTabMetadata` | Updates metadata for a specific tab in the pane. | `(tabId: string, updater: (current: Record<string, unknown> \| undefined) => Record<string, unknown> \| undefined) => void` |
363
+ | `isActiveTabPoppedOut` | Whether the active tab is popped out into a new window. | `boolean` |
364
+ | `popoutTab` | Popout the active tab into a new window. | `(tabId?: string) => void` |
365
+ | `dockTab` | Dock the active tab back to the main layout. | `(tabId?: string) => void` |
360
366
 
361
367
  ---
362
368
 
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var Sn=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 Sn__default=/*#__PURE__*/_interopDefault(Sn);function dt({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 xt({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=`
2
2
  * {
3
3
  cursor: ${e} !important;
4
4
  user-select: none !important;
@@ -6,5 +6,6 @@
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 l=s=>{n(s);},a=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let s=document.getElementById("zeugma-global-cursor-style");s&&s.remove(),document.removeEventListener("pointermove",l),document.removeEventListener("pointerup",a),r();};document.addEventListener("pointermove",l),document.addEventListener("pointerup",a);}function Ie(e){try{return JSON.stringify(e)}catch{return ""}}var Ke=Sn.createContext(void 0),Qe=Sn.createContext(void 0),be=Sn.createContext(void 0),et=Sn.createContext(void 0),ae=()=>{let e=Sn.useContext(Ke);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},Ae=()=>{let e=Sn.useContext(Qe);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Oe=()=>{let e=Sn.useContext(et);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function pt(e){let t=Sn.useRef(null);return Sn.useEffect(()=>{if(!e){t.current=null;return}let n=o=>{t.current={x:o.clientX,y:o.clientY};},r=o=>{let l=o.touches[0]||o.changedTouches[0];l&&(t.current={x:l.clientX,y:l.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 ft(e){Sn.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function gt(){let[e,t]=Sn.useState({}),n=Sn.useRef({}),r=Sn.useRef(null),o=Sn.useRef({}),l=Sn.useRef(null),a=Sn.useRef(true);Sn.useEffect(()=>(a.current=true,()=>{a.current=false;}),[]);let s=Sn.useCallback((f,g,b)=>{a.current&&t(m=>{if(!g){if(b&&m[f]!==b||!m[f])return m;let x={...m};return delete x[f],x}return m[f]===g?m:{...m,[f]:g}});},[]),c=Sn.useCallback((f,g)=>{n.current[f]=g;},[]),u=Sn.useCallback(f=>{r.current=f;},[]),i=Sn.useCallback((f,g)=>{o.current[f]=g;},[]);return {portalTargets:e,registerPortalTarget:s,registerRenderCallback:c,renderCallbacksRef:n,registerRenderPane:u,renderPaneRef:r,registerTabHeader:i,tabHeadersRef:o,activeIdRef:l}}function dn(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 mt(e){return Sn.useMemo(()=>dn(e),[e])}function bt(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=Sn.useState(null),[l,a]=Sn.useState(null),s=Sn.useCallback(u=>{t&&t(u);},[t]),c=Sn.useCallback((u,i,f)=>{n&&n(u,i,f);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:l,setOverTabPosition:a,handleDragStartInternal:s,handleDragEndInternal:c}}function vt(e){let n=Sn.useContext(be)?.registerRenderPane;Sn.useEffect(()=>{n&&e&&n(e);},[n,e]);}function ue(){return "pane-"+Math.random().toString(36).substring(2,11)}function fe(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null: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 de(e,t){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let o=e.tabIds.filter(s=>s!==t);if(o.length===0)return null;let l=e.activeTabId;e.activeTabId===t&&(l=o[0]);let a={...e.tabsMetadata};return delete a[t],{...e,tabIds:o,activeTabId:l,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}let n=de(e.first,t),r=de(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function ye(e,t,n,r,o){if(e===null)return typeof o=="string"?{type:"pane",id:ue(),tabIds:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let l=typeof o=="string"?{type:"pane",id:ue(),tabIds:[o],activeTabId:o}:o,a=r==="left"||r==="top";return {type:"split",direction:n,first:a?l:e,second:a?e:l,splitPercentage:50}}return e}return {...e,first:ye(e.first,t,n,r,o)||e.first,second:ye(e.second,t,n,r,o)||e.second}}function pn(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 ht(e,t,n,r){if(e===null)return {type:"pane",id:ue(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};let o=t?ee(e,t):null;if(o&&o.type==="pane"){let s=function(c){if(c.type==="pane"&&c.id===t){let u=[...c.tabIds];u.includes(n)||u.push(n);let i=c.tabsMetadata;return r&&(i={...c.tabsMetadata,[n]:r}),{...c,tabIds:u,activeTabId:n,tabsMetadata:i}}return c.type==="split"?{...c,first:s(c.first),second:s(c.second)}:c};return s(e)}let l={type:"pane",id:ue(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};return pn(e,l)}function Te(e,t,n){return e===null?null:e===t?{...e,splitPercentage:n}:e.type==="split"?{...e,first:Te(e.first,t,n)||e.first,second:Te(e.second,t,n)||e.second}:e}function ee(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?ee(e.first,t)??ee(e.second,t):null}function B(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?B(e.first,t)??B(e.second,t):null}function Tt(e,t){return ee(e,t)??B(e,t)}function Pt(e,t){let n=B(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]}}function xt(e,t){return B(e,t)?.tabsMetadata?.[t]}function Rt(e,t){let n=ee(e,t);return n?.tabsMetadata?.[n.activeTabId]}function Fe(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let r=e.tabsMetadata||{},o=r[t],l=n(o),a={...r};return l===void 0?delete a[t]:a[t]=l,{...e,tabsMetadata:Object.keys(a).length>0?a:void 0}}return e}return e.type==="split"?{...e,first:Fe(e.first,t,n)??e.first,second:Fe(e.second,t,n)??e.second}:e}function Be(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:Be(e.first,t,n)??e.first,second:Be(e.second,t,n)??e.second}:e}function De(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:De(e.first,t,n)??e.first,second:De(e.second,t,n)??e.second}:e}function yt(e,t,n){if(e===null)return null;let o=B(e,t)?.tabsMetadata?.[t],l=de(e,t);if(l===null)return {type:"pane",id:ue(),tabIds:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function a(s){if(s.type==="pane"){if(s.id===n){let c=[...s.tabIds];c.includes(t)||c.push(t);let u={...s.tabsMetadata};return o&&(u[t]=o),{...s,tabIds:c,activeTabId:t,tabsMetadata:Object.keys(u).length>0?u:void 0}}return s}return s.type==="split"?{...s,first:a(s.first),second:a(s.second)}:s}return a(l)}function fn(e,t,n){if(e===null)return null;if(t===n)return e;let r=B(e,t),o=B(e,n);if(!r||!o)return e;let l=r.id,a=o.id,s=r.tabsMetadata?.[t],c=o.tabsMetadata?.[n];function u(i){if(i.type==="pane"){let f=false,g=[...i.tabIds],b=i.activeTabId,m=i.tabsMetadata?{...i.tabsMetadata}:{};if(l===a){if(i.id===l){let x=g.indexOf(t),M=g.indexOf(n);x!==-1&&M!==-1&&(g[x]=n,g[M]=t),b=t,f=true;}}else i.id===l&&(g=g.map(x=>x===t?n:x),b===t&&(b=n),delete m[t],c&&(m[n]=c),f=true),i.id===a&&(g=g.map(x=>x===n?t:x),b===n&&(b=t),delete m[n],s&&(m[t]=s),f=true);return f?{...i,tabIds:g,activeTabId:b,tabsMetadata:Object.keys(m).length>0?m:void 0}:i}return i.type==="split"?{...i,first:u(i.first),second:u(i.second)}:i}return u(e)}function Ne(e,t,n,r="before"){if(e===null)return null;if(t===n)return e;if(r==="center")return fn(e,t,n);let l=B(e,t)?.tabsMetadata?.[t],a=de(e,t);if(a===null)return {type:"pane",id:ue(),tabIds:[t],activeTabId:t,tabsMetadata:l?{[t]:l}:void 0};function s(c){if(c.type==="pane"){if(c.tabIds.includes(n)){let i=[...c.tabIds].filter(b=>b!==t),f=i.indexOf(n);f<0&&(f=0),r==="after"&&(f+=1),i.splice(f,0,t);let g={...c.tabsMetadata};return l&&(g[t]=l),{...c,tabIds:i,activeTabId:t,tabsMetadata:Object.keys(g).length>0?g:void 0}}return c}return c.type==="split"?{...c,first:s(c.first),second:s(c.second)}:c}return s(a)}function me(e,t=0,n=0,r=100,o=100,l="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:a,splitPercentage:s,first:c,second:u}=e,f={id:`splitter-${l}-${a}`,currentNode:e,direction:a,left:a==="row"?t+r*(s/100):t,top:a==="column"?n+o*(s/100):n,width:a==="row"?0:r,height:a==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:r,parentHeight:o},g={panes:[],splitters:[]},b={panes:[],splitters:[]};if(a==="row"){let m=r*(s/100);g=me(c,t,n,m,o,`${l}-L`),b=me(u,t+m,n,r-m,o,`${l}-R`);}else {let m=o*(s/100);g=me(c,t,n,r,m,`${l}-T`),b=me(u,t,n+m,r,o-m,`${l}-B`);}return {panes:[...g.panes,...b.panes],splitters:[f,...g.splitters,...b.splitters]}}function Dt(e,t,n,r="before"){if(e===null)return null;let o=ee(e,t);if(!o)return e;let l=o.tabIds,a=o.activeTabId,s=o.tabsMetadata||{},c=fe(e,t);if(c===null)return o;function u(i){if(i.type==="pane"){if(i.tabIds.includes(n)){let g=[...i.tabIds].filter(x=>!l.includes(x)),b=g.indexOf(n);b<0&&(b=0),r==="after"&&(b+=1),g.splice(b,0,...l);let m={...i.tabsMetadata};for(let x of l)s[x]&&(m[x]=s[x]);return {...i,tabIds:g,activeTabId:a,tabsMetadata:Object.keys(m).length>0?m:void 0}}return i}return i.type==="split"?{...i,first:u(i.first),second:u(i.second)}:i}return u(c)}function Ct(e,t,n,r){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!r)return -1;let a=e.indexOf(n);return r==="before"?a:a+1}function gn(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:l,locked:a=false}=e,[s,c]=Sn.useState(()=>n!==void 0?n:t??null),[u,i]=Sn.useState(()=>n!==void 0?n:t??null),[f,g]=Sn.useState(()=>Ie(n!==void 0?n:null)),[b,m]=Sn.useState(o||null),[x,M]=Sn.useState(a),[O,v]=Sn.useState(null),[k,D]=Sn.useState(null),[E,w]=Sn.useState(null),C=Sn.useRef(null),V=Sn.useCallback(d=>{C.current=d;},[]),A=Sn.useRef(s);A.current=s;let J=Sn.useRef(r);J.current=r;let U=Sn.useRef(l);U.current=l;let te=Sn.useCallback(d=>{m(d),U.current?.(d);},[]);if(Sn.useEffect(()=>{M(a);},[a]),Sn.useEffect(()=>{o!==void 0&&m(o);},[o]),n!==void 0){let d=Ie(n);d!==f&&(g(d),c(n),i(n));}let S=Sn.useCallback(d=>(...h)=>{let N=A.current,z=d(N,...h);Ie(N)!==Ie(z)&&(A.current=z,c(z),i(z),J.current?.(z));},[]),ne=Sn.useCallback(S((d,h)=>typeof h=="function"?h(d):h),[S]),re=Sn.useCallback(d=>{i(h=>typeof d=="function"?d(h):d);},[]),Z=Sn.useCallback(d=>{m(null),U.current?.(null),v(null),D(null),w(null),ne(d),i(()=>typeof d=="function"?d(A.current):d);},[ne]),j=Sn.useCallback(S((d,h)=>fe(d,h)),[S]),H=Sn.useCallback(S((d,h,N,z)=>{let F=de(d,h)??d;return ht(F,N,h,z)}),[S]),T=Sn.useCallback(S((d,h,N,z,F)=>{let K=ee(d,h)??B(d,h);if(!K)return d;let $=ee(d,F)??B(d,F)??{type:"pane",id:F,tabIds:[F],activeTabId:F},ie=fe(d,$.id);return ye(ie,K.id,N,z,$)}),[S]),I=Sn.useCallback(S((d,h,N)=>Te(d,h,N)),[S]),p=Sn.useCallback(S((d,h,N)=>Fe(d,h,N)),[S]),oe=Sn.useCallback(S((d,h,N)=>{let z=ee(d,h)??B(d,h);return z?Be(d,z.id,N):d}),[S]),P=Sn.useCallback(S((d,h,N)=>{let z=ee(d,h)??B(d,h);return z?De(d,z.id,N):d}),[S]),L=Sn.useCallback(S((d,h,N)=>{let z=ee(d,N)??B(d,N);return z?yt(d,h,z.id):d}),[S]),ce=Sn.useCallback(S((d,h,N,z)=>Ne(d,h,N,z)),[S]),Y=Sn.useCallback(S((d,h)=>de(d,h)),[S]),q=Sn.useCallback(d=>ee(A.current,d),[]),_=Sn.useCallback(d=>B(A.current,d),[]),G=Sn.useCallback(d=>Pt(A.current,d),[]),R=Sn.useCallback(d=>xt(A.current,d),[]),y=Sn.useCallback(d=>Rt(A.current,d),[]);return {layout:s,setLayout:Z,_internalSetLayout:re,renderingLayout:u,fullscreenPaneId:b,setFullscreenPaneId:te,locked:x,setLocked:M,activeId:O,setActiveId:v,activeType:k,setActiveType:D,dismissIntentId:E,setDismissIntentId:w,containerRef:C,setContainerRef:V,removePane:j,addTab:H,updateMetadata:p,updatePaneLock:oe,selectTab:P,mergeTab:L,moveTab:ce,removeTab:Y,splitPane:T,updateSplitPercentage:I,findPaneById:q,findPaneContainingTab:_,findTabById:G,getTabMetadata:R,getActiveTabMetadata:y}}var mn=()=>{let e=ae(),t=Ae();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}};var We=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Ue=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var wt=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((a,s)=>{let c=a.id.toString(),u=s.id.toString(),i=c.startsWith("tab-drop-"),f=u.startsWith("tab-drop-");if(i&&!f)return -1;if(!i&&f)return 1;let g=c.startsWith("drop-root-"),b=u.startsWith("drop-root-");return g&&!b?-1:!g&&b?1:0});if(n){let l=e.droppableContainers.filter(a=>a.id.toString().startsWith("tab-drop-"));return core.closestCenter({...e,droppableContainers:l})}return []};function Me(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 Mt(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:l,activeType:a,setActiveType:s,dismissIntentId:c,setDismissIntentId:u,setOverTabId:i,setOverTabPosition:f,containerRef:g,dragActivationDistance:b,enableDragToDismiss:m,dismissThreshold:x,onRemove:M,onDragStart:O,onDragEnd:v,onDismissIntentChange:k,removeTab:D,removePane:E}=e,w=Sn.useRef(null),C=pt(o),V=Sn.useRef(null),[A,J]=Sn.useState(false);return ft(A),{sensors:core.useSensors(core.useSensor(We,{activationConstraint:{distance:b}}),core.useSensor(Ue,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:wt,onDragStart:Z=>{let j=Z.active.id.toString(),H=j.startsWith("tab-header-"),T=H?j.substring(11):j;l(T),s(H?"tab":"pane"),i(null),f(null);let I=Z.activatorEvent;C.current=Me(I),m&&g.current?w.current=g.current.getBoundingClientRect():w.current=null;let p=t;if(H){let P=B(t,T);P&&(p=De(t,P.id,T)||t);}V.current=p;let oe=H?de(p,T):fe(p,T);n(oe),O&&O(T);},onDragMove:Z=>{let{over:j}=Z,H=j?.id.toString()||"",T=H.startsWith("drop-locked-");J(R=>R===T?R:T);let I=Z.active.id.toString(),p=I.startsWith("tab-header-"),oe=p?I.substring(11):I,P=H.match(/^tab-drop-(.+)$/);if(P&&j&&(p||a==="pane")){let[,R]=P;if(oe!==R){let y="before",se=j.rect,d=Z.activatorEvent,h=null;if(C.current)h=C.current.x;else {let N=Me(d);N&&(h=N.x+Z.delta.x);}if(h!==null){let N=se.left+se.width/2;h>N&&(y="after");}i(N=>N===R?N:R),f(N=>N===y?N:y);}else i(y=>y===null?y:null),f(y=>y===null?y:null);}else i(R=>R===null?R:null),f(R=>R===null?R:null);if(!m)return;let L=w.current;if(!L){c!==null&&(u(null),k?.(null));return}let ce=Z.activatorEvent,Y=null,q=null;if(C.current)Y=C.current.x,q=C.current.y;else {let R=Me(ce);R&&(Y=R.x+Z.delta.x,q=R.y+Z.delta.y);}let _=0;if(Y!==null&&q!==null){let R=0,y=0;Y<L.left?R=L.left-Y:Y>L.right&&(R=Y-L.right),q<L.top?y=L.top-q:q>L.bottom&&(y=q-L.bottom),_=Math.sqrt(R*R+y*y);}else {let R=Z.active.rect.current.translated;if(R){let y=R.left+R.width/2,se=R.top+R.height/2,d=0,h=0;y<L.left?d=L.left-y:y>L.right&&(d=y-L.right),se<L.top?h=L.top-se:se>L.bottom&&(h=se-L.bottom),_=Math.sqrt(d*d+h*h);}}_>x?c!==oe&&(u(oe),k?.(oe)):c!==null&&(u(null),k?.(null));},onDragEnd:Z=>{l(null),s(null),J(false),i(null),f(null);let{active:j,over:H}=Z,T=j.id.toString(),I=T.startsWith("tab-header-"),p=I?T.substring(11):T,oe=m&&c===p;u(null),k?.(null),w.current=null;let P=V.current||t;if(V.current=null,oe){M?M(p):I?D(p):E(p),v&&v(p,null,null);return}if(!H){n(P),v&&v(p,null,null);return}let L=H.id.toString();if(L.startsWith("drop-locked-")){n(P),v&&v(p,null,null);return}let ce=L.match(/^tab-drop-(.+)$/);if(ce){let[,F]=ce;if(I)if(p!==F){let K="before",$=H.rect,ie=Z.activatorEvent,Q=null;if(C.current)Q=C.current.x;else {let X=Me(ie);X&&(Q=X.x+Z.delta.x);}if(Q!==null){let X=$.left+$.width/2;Q>X&&(K="after");}let pe=Ne(P,p,F,K);r(pe),v&&v(p,F,{type:"move",position:"center"});}else n(P),v&&v(p,null,null);else {let K="before",$=H.rect,ie=Z.activatorEvent,Q=null;if(C.current)Q=C.current.x;else {let X=Me(ie);X&&(Q=X.x+Z.delta.x);}if(Q!==null){let X=$.left+$.width/2;Q>X&&(K="after");}let pe=Dt(P,p,F,K);r(pe),v&&v(p,F,{type:"move",position:"center"});}return}let Y=L.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(Y){let[,F,K]=Y,$=K;$==="start"&&($="left"),$==="end"&&($="right");let ie=I?de(P,p):fe(P,p),Q;if(I){let X=B(P,p)?.tabsMetadata?.[p];Q={type:"pane",id:ue(),tabIds:[p],activeTabId:p,tabsMetadata:X?{[p]:X}:void 0};}else Q=ee(P,p)??{type:"pane",id:ue(),tabIds:[p],activeTabId:p};if(ie===null)r(Q);else {let pe=$==="left"||$==="right",X=$==="left"||$==="top",he=50;F==="1/4"?he=X?25:75:F==="1/3"&&(he=X?100/3:200/3),r({type:"split",direction:pe?"row":"column",first:X?Q:ie,second:X?ie:Q,splitPercentage:he});}v&&v(p,"root",{type:"split",direction:$==="left"||$==="right"?"row":"column",position:$});return}let q=L.match(/^drop-(left|right|top|bottom|center)-(.+)$/);if(!q){n(P),v&&v(p,null,null);return}let[,_,G]=q;if(_==="center"){if(I){let F=ee(P,G);if(F&&F.activeTabId){let K=F.activeTabId,$=Ne(P,p,K,"center");r($),v&&v(p,G,{type:"move",position:"center"});}else n(P),v&&v(p,null,null);}else n(P),v&&v(p,null,null);return}let R=I?B(P,p):ee(P,p),y=R&&R.id===G,se=R&&R.tabIds.length===1;if(p===G||y&&se){n(P),v&&v(p,null,null);return}let d=_==="left"||_==="right"?"row":"column",h;if(I){let K=B(P,p)?.tabsMetadata?.[p];h={type:"pane",id:ue(),tabIds:[p],activeTabId:p,tabsMetadata:K?{[p]:K}:void 0};}else h=ee(P,p)??{type:"pane",id:ue(),tabIds:[p],activeTabId:p};let N=I?de(P,p):fe(P,p),z=ye(N,G,d,_,h);r(z),v&&v(p,G,{type:"split",direction:d,position:_});},onDragCancel:()=>{l(null),s(null),J(false),i(null),f(null),u(null),k?.(null),w.current=null;let Z=V.current||t;V.current=null,n(Z),Z!==t&&r(Z);}}}function Lt({persist:e,layout:t,setLayout:n}){let r=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[l,a]=Sn.useState(false);Sn.useEffect(()=>{if(r){let s=localStorage.getItem(o);if(s)try{let c=JSON.parse(s);c&&n(c);}catch(c){console.error("Failed to parse persisted zeugma layout",c);}}a(true);},[r,o,n]),Sn.useEffect(()=>{r&&l&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[r,o,t,l]);}var Zt=({activeId:e,render:t,className:n})=>{let r=Sn.useRef(null);return Sn.useEffect(()=>{let o=l=>{r.current&&(r.current.style.transform=`translate(${l.clientX+12}px, ${l.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 kt=Sn__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,[o,l]=Sn.useState(false),a=Sn.useRef(null);if(Sn.useEffect(()=>{l(true);},[]),Sn.useEffect(()=>{if(!o||!a.current)return;let c=a.current;if(t)t.appendChild(c);else {let u=document.getElementById("zeugma-hidden-portal-container");u||(u=document.createElement("div"),u.id="zeugma-hidden-portal-container",u.style.display="none",document.body.appendChild(u)),u.appendChild(c);}},[t,o]),Sn.useEffect(()=>()=>{a.current&&a.current.remove();},[]),!o)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 s=a.current;return !s||!n?null:reactDom.createPortal(n(e),s)},(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 zt=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:r,renderPaneRef:o,renderPane:l,tabHeadersRef:a,classNames:s})=>{if(r)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let c=o.current||l;if(c)return jsxRuntime.jsx("div",{className:s.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:c(e)})}else if(t==="tab"){let c=o.current||l;if(c)return jsxRuntime.jsx("div",{className:s.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:c(e)});let u=a.current[e];if(u){let i=s.tab?typeof s.tab=="function"?s.tab(e):s.tab:"";return jsxRuntime.jsx("div",{className:`${s.tabDragPreview||""} ${i}`.trim(),style:{display:"inline-flex",position:"relative",pointerEvents:"none",overflow:"hidden"},children:u({isDragging:true,isOver:false})})}}return jsxRuntime.jsx("div",{style:{pointerEvents:"none",overflow:"hidden",width:"100%",height:"100%"}})};function ot({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:l,layout:a,currentNode:s,onLayoutChange:c,onResizeStart:u,onResizeEnd:i,parentLeft:f,parentTop:g,parentWidth:b,parentHeight:m}){let{onResizeStart:x,onResize:M,onResizeEnd:O,minSplitPercentage:v=5,maxSplitPercentage:k=95,locked:D=false}=ae();return Sn.useCallback(E=>{if(D)return;E.preventDefault();let w=e.current;if(!w)return;u&&u(),x&&x(s);let C=w.getBoundingClientRect(),V=E.clientX,A=E.clientY,J=r,U=E.currentTarget,te=C.left+C.width*(f/100),S=C.top+C.height*(g/100),ne=C.width*(b/100),re=C.height*(m/100),j=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(T=>T!==U&&T.getAttribute("data-direction")===n).map(T=>{let I=T.getBoundingClientRect();return t?I.left+I.width/2:I.top+I.height/2}),H=J;dt({cursor:t?"col-resize":"row-resize",resizerEl:U,onMove:T=>{let I=t?(T.clientX-V)/ne*100:(T.clientY-A)/re*100,p=J+I,oe=t?te+(ne-o)*(p/100)+o/2:S+(re-o)*(p/100)+o/2,P=1/0,L=null;for(let _ of j){let G=Math.abs(oe-_);G<l&&G<P&&(P=G,L=_);}let ce=p;L!==null&&(ce=t?(L-o/2-te)/(ne-o)*100:(L-o/2-S)/(re-o)*100);let Y=Math.max(v,Math.min(k,ce));H=Y;let q=Te(a,s,Y);if(q){let{panes:_,splitters:G}=me(q),R=e.current;if(R){for(let y of _)R.style.setProperty(`--pane-left-${y.paneId}`,`${y.left}%`),R.style.setProperty(`--pane-top-${y.paneId}`,`${y.top}%`),R.style.setProperty(`--pane-width-${y.paneId}`,`${y.width}%`),R.style.setProperty(`--pane-height-${y.paneId}`,`${y.height}%`);for(let y of G)R.style.setProperty(`--splitter-pos-${y.id}`,`${y.direction==="row"?y.left:y.top}%`);}}M&&M(s,Y);},onEnd:()=>{let T=Te(a,s,H),I=e.current;if(I){let{panes:p,splitters:oe}=me(T);for(let P of p)I.style.removeProperty(`--pane-left-${P.paneId}`),I.style.removeProperty(`--pane-top-${P.paneId}`),I.style.removeProperty(`--pane-width-${P.paneId}`),I.style.removeProperty(`--pane-height-${P.paneId}`);for(let P of oe)I.style.removeProperty(`--splitter-pos-${P.id}`);}c(T),i&&i(),O&&O(s,H);}});},[e,t,n,r,o,l,a,s,c,u,i,x,M,O,v,k,f,g,b,m])}var $t=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:l,classNames:a,locked:s}=ae(),[c,u]=Sn.useState(false),{currentNode:i,direction:f,left:g,top:b,width:m,height:x,parentLeft:M,parentTop:O,parentWidth:v,parentHeight:k}=e,D=f==="row",E=ot({containerRef:r,isRow:D,direction:f,splitPercentage:i.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:i,onLayoutChange:l,onResizeStart:()=>u(true),onResizeEnd:()=>u(false),parentLeft:M,parentTop:O,parentWidth:v,parentHeight:k}),w=D?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${g}%) - ${t/2}px)`,top:`calc(${b}% + ${t/2}px)`,width:`${t}px`,height:`calc(${x}% - ${t}px)`,cursor:s?"default":"col-resize",pointerEvents:s?"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}, ${b}%) - ${t/2}px)`,width:`calc(${m}% - ${t}px)`,height:`${t}px`,cursor:s?"default":"row-resize",pointerEvents:s?"none":"auto",zIndex:10,userSelect:"none",touchAction:"none",boxSizing:"border-box"};return jsxRuntime.jsx("div",{className:a.resizer||"","data-direction":f,"data-resizing":c||void 0,style:w,onPointerDown:E,role:"separator","aria-valuenow":i.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},At=Sn__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 rt=({renderPane:e,tree:t,resizerSize:n,snapThreshold:r})=>{vt(e);let{renderingLayout:o,activeId:l,dismissIntentId:a,setContainerRef:s,fullscreenPaneId:c,snapThreshold:u,locked:i,classNames:f,resizerSize:g}=ae(),b=r!==void 0?r:u??8,m=n!==void 0?n:g??4,x=t!==void 0?t:o,M=Sn.useRef(null),{panes:O,splitters:v}=Sn.useMemo(()=>x?me(x):{panes:[],splitters:[]},[x]);if(!x&&t!==void 0)return null;let k=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[O.map(D=>{let E=c===D.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:E?"0%":`var(--pane-left-${D.paneId}, ${D.left}%)`,top:E?"0%":`var(--pane-top-${D.paneId}, ${D.top}%)`,width:E?"100%":`var(--pane-width-${D.paneId}, ${D.width}%)`,height:E?"100%":`var(--pane-height-${D.paneId}, ${D.height}%)`,overflow:"hidden",zIndex:E?20:1,display:c&&!E?"none":"block",padding:E?"0px":`${m/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(At,{paneId:D.paneId,renderPane:e})},D.paneId)}),!c&&v.map(D=>jsxRuntime.jsx($t,{splitter:D,resizerSize:m,snapThreshold:b,containerRef:M},D.id))]});if(t===void 0){let D=l!==null&&l===a,E=C=>{s(C),M.current=C;},w=`${f.dashboard||""} ${D&&f.dashboardDismissActive||""} ${i&&f.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:E,className:w,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[k(),l!==null&&!i&&jsxRuntime.jsx(Ft,{activeClassName:f.rootDropPreview??f.dropPreview})]})}return jsxRuntime.jsx("div",{ref:M,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:k()})};var Fn=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:l,resizerSize:a,dragActivationDistance:s=8,snapThreshold:c=8,minSplitPercentage:u=5,maxSplitPercentage:i=95,enableDragToDismiss:f=false,dismissThreshold:g=60,onRemove:b,onDragStart:m,onDragEnd:x,onResizeStart:M,onResize:O,onResizeEnd:v,onDismissIntentChange:k,persist:D=false}=e,E=t,{layout:w,setLayout:C,_internalSetLayout:V,renderingLayout:A,fullscreenPaneId:J,setFullscreenPaneId:U,locked:te,setLocked:S,findPaneById:ne,findPaneContainingTab:re,findTabById:Z,getTabMetadata:j,getActiveTabMetadata:H,activeId:T,setActiveId:I,activeType:p,setActiveType:oe,dismissIntentId:P,setDismissIntentId:L,containerRef:ce,setContainerRef:Y,removePane:q,addTab:_,updateMetadata:G,updatePaneLock:R,selectTab:y,mergeTab:se,removeTab:d,splitPane:h,updateSplitPercentage:N,moveTab:z}=E;Lt({persist:D,layout:w,setLayout:C});let{portalTargets:F,registerPortalTarget:K,registerRenderCallback:$,renderCallbacksRef:ie,registerRenderPane:Q,renderPaneRef:pe,registerTabHeader:X,tabHeadersRef:he,activeIdRef:we}=gt(),{overTabId:it,setOverTabId:Kt,overTabPosition:lt,setOverTabPosition:Qt,handleDragStartInternal:en,handleDragEndInternal:tn}=bt({onDragStart:m,onDragEnd:x}),nn=Mt({layout:w,_internalSetLayout:V,setLayout:C,activeId:T,setActiveId:I,activeType:p,setActiveType:oe,dismissIntentId:P,setDismissIntentId:L,setOverTabId:Kt,setOverTabPosition:Qt,containerRef:ce,dragActivationDistance:s,enableDragToDismiss:f,dismissThreshold:g,onRemove:b,onDragStart:en,onDragEnd:tn,onDismissIntentChange:k,removeTab:d,removePane:q}),je=Sn.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=Sn.useCallback((ge,ze)=>{v&&v(ge,ze);},[v]),on=Sn.useMemo(()=>({layout:w,renderingLayout:A,setLayout:C,activeId:T,activeType:p,dismissIntentId:P,setContainerRef:Y,fullscreenPaneId:J,classNames:je,onRemove:b,onFullscreenChange:U,snapThreshold:c,onResizeStart:M,onResize:O,onResizeEnd:ct,minSplitPercentage:u,maxSplitPercentage:i,locked:te,setLocked:S,findPaneById:ne,findPaneContainingTab:re,findTabById:Z,getTabMetadata:j,getActiveTabMetadata:H,renderPane:l,resizerSize:a}),[w,A,T,p,P,Y,J,je,b,U,c,M,O,u,i,C,ct,te,S,ne,re,Z,j,H,l,a]),rn=Sn.useMemo(()=>({overTabId:it,overTabPosition:lt}),[it,lt]),an=Sn.useMemo(()=>({removePane:q,addTab:_,updateMetadata:G,updatePaneLock:R,selectTab:y,mergeTab:se,removeTab:d,setFullscreenPaneId:U,setLocked:S,splitPane:h,updateSplitPercentage:N,moveTab:z}),[q,_,G,R,y,se,d,U,S,h,N,z]),sn=mt(w),ln=Sn.useMemo(()=>({registerPortalTarget:K,registerRenderCallback:$,renderCallbacksRef:ie,registerRenderPane:Q,renderPaneRef:pe,registerTabHeader:X,tabHeadersRef:he,activeIdRef:we}),[K,$,ie,Q,pe,X,he,we]);return we&&(we.current=T),jsxRuntime.jsx(Qe.Provider,{value:an,children:jsxRuntime.jsx(Ke.Provider,{value:on,children:jsxRuntime.jsx(et.Provider,{value:rn,children:jsxRuntime.jsxs(be.Provider,{value:ln,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...nn,children:n}),T&&p&&jsxRuntime.jsx(Zt,{activeId:T,render:ge=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:ge===P?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(zt,{activeId:ge,activeType:p,dismissIntentId:P,renderDragOverlay:r,renderPaneRef:pe,renderPane:l,tabHeadersRef:he,classNames:je})}),className:`${o.dragOverlay||""} ${T===P&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:sn.map(ge=>{let ze=F[ge],ut=Z(ge);return ut?jsxRuntime.jsx(kt,{tabDetails:ut,target:ze||null,renderWidget:ie.current[ge]},ge):null})})]})})})})},Bn=({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(rt,{renderPane:e,resizerSize:t,snapThreshold:n})},Vn=e=>{let{children:t,...n}=e,{controller:r}=e;if(!r)throw new Error("Zeugma component requires a controller.");return jsxRuntime.jsx(Fn,{...e,children:t!==void 0?t:jsxRuntime.jsx(Bn,{...n})})};var Xn={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"}}},Jn={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"}}},Yn=({id:e,fraction:t,edge:n,activeClassName:r})=>{let{setNodeRef:o,isOver:l}=core.useDroppable({id:e}),a={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...Jn[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:Xn[n][t]}),l&&jsxRuntime.jsx("div",{className:r,style:a})]})},Ft=({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(Yn,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var Je=Sn.createContext(null);var Kn={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"}},Qn={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"}},Ye=({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:Kn[t]}),o&&jsxRuntime.jsx("div",{className:n,style:Qn[t]})]})};var Vt=({children:e,className:t,style:n})=>{let r=Sn.useContext(Je);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...l}=r;return jsxRuntime.jsx("div",{className:t,style:{cursor:o?"default":"grab",userSelect:o?"auto":"none",touchAction:o?"auto":"none",...n},...o?{}:l,children:e})};var co=Sn.createContext(void 0);var ke=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:l,classNames:a={},fullscreenPaneId:s}=ae(),{overTabId:c}=Oe(),u=Sn.useContext(be);Sn.useEffect(()=>(u?.registerTabHeader&&u.registerTabHeader(e,n),()=>{u?.registerTabHeader&&u.activeIdRef?.current!==e&&u.registerTabHeader(e,()=>null);}),[e,n,u]);let i=Sn.useContext(at),f=t||l||(i?.locked??false)||s!==null,{attributes:g,listeners:b,setNodeRef:m,isDragging:x}=core.useDraggable({id:`tab-header-${e}`,disabled:f}),{setNodeRef:M,isOver:O}=core.useDroppable({id:`tab-drop-${e}`,disabled:f}),v=ne=>{m(ne),M(ne);},k=O&&c===e,D=i?.tabIds||[],E=D.indexOf(e),w=i?.activeTabId,V=E>0&&e!==w&&D[E-1]!==w?jsxRuntime.jsx("div",{className:a.tabSeparator}):null,A=i?i.activeTabId===e:false,J=i?.tabsMetadata?.[e],U=Sn.useCallback(()=>{i?.selectTab(e);},[i,e]),te=Sn.useCallback(()=>{i?.removeTab(e);},[i,e]),S=Sn.useMemo(()=>({tabId:e,isActive:A,isDragging:x,isOver:k,metadata:J,locked:f,selectTab:U,removeTab:te}),[e,A,x,k,J,f,U,te]);return jsxRuntime.jsx(co.Provider,{value:S,children:jsxRuntime.jsxs("div",{ref:v,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:f?"default":"grab",...o},...f?{}:b,...f?{}:g,children:[V,n({isDragging:x,isOver:k})]})})};var at=Sn.createContext(void 0);var Jt=(e,t)=>typeof e=="function"?e(t):e,st=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:l,renderTab:a,classNames:s,styles:c})=>{let u=Sn.useContext(qe),i=e??u?.tabIds??[],f=t??u?.activeTabId??"",g=n??u?.locked??false,b=r??u?.tabsMetadata,m=o??u?.selectTab??(()=>{}),x=l??u?.removeTab??(()=>{}),{classNames:M={},activeType:O}=ae(),{overTabId:v,overTabPosition:k}=Oe(),D=Sn.useMemo(()=>({tabIds:i,activeTabId:f,locked:g,tabsMetadata:b,selectTab:m,removeTab:x}),[i,f,g,b,m,x]),E=Ct(i,O,v,k);return jsxRuntime.jsx(at.Provider,{value:D,children:jsxRuntime.jsxs("div",{className:s?.container,style:{display:"flex",alignItems:"center",height:"100%",...c?.container},children:[i.map((w,C)=>{let V=b?.[w],A=Jt(s?.tab,w),J=Jt(c?.tab,w),U=C===E;return jsxRuntime.jsxs(Sn__default.default.Fragment,{children:[U&&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:C===0?"none":"translateX(-50%)"}})}),jsxRuntime.jsx(ke,{id:w,locked:g,className:A,style:J,children:({isDragging:te,isOver:S})=>a({id:w,paneId:u?.id??"",isActive:w===f,index:C,isDragging:te,isOver:S,metadata:V,onSelect:()=>m(w),onRemove:()=>x(w)})})]},w)}),E===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%)"}})})]})})};st.Tab=ke;var qt=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var qe=Sn.createContext(void 0),Gt=()=>{let e=Sn.useContext(qe);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},xo=({children:e,className:t,style:n})=>{let{activeTabId:r}=Gt(),{classNames:o}=ae(),l=Sn.useRef(null),a=Sn.useContext(be);if(!a)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:s,registerRenderCallback:c}=a,u=Sn.useMemo(()=>typeof e=="function"?e:()=>e,[e]);return c(r,u),Sn.useEffect(()=>{let i=l.current;return s(r,i),()=>{s(r,null,i);}},[r,s]),jsxRuntime.jsx("div",{ref:l,id:`zeugma-tab-target-${r}`,className:`${o.tabContentWrapper||""} ${t||""}`.trim(),style:{height:"100%",width:"100%",...n}})},Se=({id:e,children:t,style:n,locked:r=false})=>{let{layout:o,renderingLayout:l,activeId:a,activeType:s,classNames:c,fullscreenPaneId:u,onFullscreenChange:i,locked:f}=ae(),{removePane:g,updateMetadata:b,selectTab:m,removeTab:x}=Ae(),M=Sn.useMemo(()=>{if(s==="tab"&&e===a){let p=B(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:p?{[e]:p}:void 0}}return Tt(e===a?o:l,e)},[o,l,e,a,s]),O=M?.id??e,v=M?.tabIds??[e],k=M?.activeTabId??e,D=M?.tabsMetadata,E=D?.[e],w=M?.locked??false,C=r||w,V=f||C||u!==null,A=f||C||u!==null,J=a!==null&&a!==e&&(!v.includes(a)||v.length>1)&&!A,{attributes:U,listeners:te,setNodeRef:S}=core.useDraggable({id:e,disabled:V}),ne=a!==null&&v.includes(a),re=u===e,Z=Sn.useMemo(()=>({isDragging:ne,isFullscreen:re,toggleFullscreen:()=>i?.(re?null:e),remove:()=>{re&&i?.(null),g(O);},metadata:E,updateMetadata:T=>{b(e,T);},locked:V,tabIds:v,activeTabId:k,selectTab:T=>m(O,T),removeTab:T=>{re&&T===k&&i?.(null),x(T);},tabsMetadata:D,updateTabMetadata:(T,I)=>{b(T,I);}}),[ne,re,i,e,x,E,b,V,v,k,m,O,D]),j=Sn.useMemo(()=>V?{disabled:true}:{...te,...U},[te,U,V]),H=`${c.pane||""} ${C&&c.paneLocked||""}`.trim();return jsxRuntime.jsx(qe.Provider,{value:{id:e,...Z},children:jsxRuntime.jsx(Je.Provider,{value:j,children:jsxRuntime.jsxs("div",{ref:S,id:e,className:H,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,J&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:[["top","bottom","left","right"].map(T=>jsxRuntime.jsx(Ye,{id:`drop-${T}-${e}`,position:T,activeClassName:c.dropPreview},T)),s==="tab"&&jsxRuntime.jsx(Ye,{id:`drop-center-${e}`,position:"center",activeClassName:c.swapPreview??c.dropPreview})]}),a!==null&&a!==e&&A&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(Ye,{id:`drop-locked-${e}`,position:"full",activeClassName:c.lockedPreview||""})})]})})})};Se.Content=xo;Se.DragHandle=Vt;Se.Tabs=st;Se.Tab=ke;Se.Controls=qt;exports.Pane=Se;exports.PaneTree=rt;exports.Zeugma=Vn;exports.usePaneContext=Gt;exports.useResizer=ot;exports.useZeugma=gn;exports.useZeugmaContext=mn;//# sourceMappingURL=index.cjs.map
9
+ `,document.head.appendChild(o),t.setAttribute("data-resizing","true");let c=a=>{n(a);},s=()=>{document.body.classList.remove("zeugma-resizing"),t.removeAttribute("data-resizing");let a=document.getElementById("zeugma-global-cursor-style");a&&a.remove(),document.removeEventListener("pointermove",c),document.removeEventListener("pointerup",s),r();};document.addEventListener("pointermove",c),document.addEventListener("pointerup",s);}function ke(e){try{return JSON.stringify(e)}catch{return ""}}var st=ge.createContext(void 0),xe=ge.createContext(void 0),ye=ge.createContext(void 0),lt=ge.createContext(void 0),ae=()=>{let e=ge.useContext(st);if(!e)throw new Error("useZeugmaState must be used within a Zeugma provider");return e},Me=()=>{let e=ge.useContext(xe);if(!e)throw new Error("useZeugmaActions must be used within a Zeugma provider");return e},Ve=()=>{let e=ge.useContext(lt);if(!e)throw new Error("useZeugmaDrag must be used within a Zeugma provider");return e};function wt(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};},r=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",r,{passive:true}),()=>{window.removeEventListener("pointermove",n),window.removeEventListener("touchmove",r);}},[e]),t}function Dt(e){ge.useEffect(()=>(e?document.body.style.setProperty("cursor","not-allowed","important"):document.body.style.removeProperty("cursor"),()=>{document.body.style.removeProperty("cursor");}),[e]);}function Ct(){let[e,t]=ge.useState({}),[n,r]=ge.useState({}),o=ge.useRef({}),c=ge.useRef(null),s=ge.useRef({}),a=ge.useRef(null),l=ge.useRef(true);ge.useEffect(()=>(l.current=true,()=>{l.current=false;}),[]);let f=ge.useCallback((u,m,P)=>{l.current&&t(g=>{if(!m){if(P&&g[u]!==P||!g[u])return g;let S={...g};return delete S[u],S}return g[u]===m?g:{...g,[u]:m}});},[]),i=ge.useCallback((u,m)=>{l.current&&r(P=>{if(!m){if(!P[u])return P;let g={...P};return delete g[u],g}return P[u]===m?P:{...P,[u]:m}});},[]),h=ge.useCallback((u,m)=>{o.current[u]=m;},[]),T=ge.useCallback(u=>{c.current=u;},[]),b=ge.useCallback((u,m)=>{s.current[u]=m;},[]);return {portalTargets:ge.useMemo(()=>({...e,...n}),[e,n]),registerPortalTarget:f,registerPopoutTarget:i,registerRenderCallback:h,renderCallbacksRef:o,registerRenderPane:T,renderPaneRef:c,registerTabHeader:b,tabHeadersRef:s,activeIdRef:a}}function Sn(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 St(e){return ge.useMemo(()=>Sn(e),[e])}function Et(e){let{onDragStart:t,onDragEnd:n}=e,[r,o]=ge.useState(null),[c,s]=ge.useState(null),a=ge.useCallback(f=>{t&&t(f);},[t]),l=ge.useCallback((f,i,h)=>{n&&n(f,i,h);},[n]);return {overTabId:r,setOverTabId:o,overTabPosition:c,setOverTabPosition:s,handleDragStartInternal:a,handleDragEndInternal:l}}function Nt(e){let n=ge.useContext(ye)?.registerRenderPane;ge.useEffect(()=>{n&&e&&n(e);},[n,e]);}function de(){return "pane-"+Math.random().toString(36).substring(2,11)}function fe(e,t){if(e===null)return null;if(e.type==="pane")return e.id===t?null: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 pe(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 c=e.activeTabId;e.activeTabId===t&&(c=o[0]);let s={...e.tabsMetadata};return delete s[t],{...e,tabIds:o,activeTabId:c,tabsMetadata:Object.keys(s).length>0?s:void 0}}return e}let n=pe(e.first,t),r=pe(e.second,t);return n===null?r:r===null?n:{...e,first:n,second:r}}function Se(e,t,n,r,o){if(e===null)return typeof o=="string"?{type:"pane",id:de(),tabIds:[o],activeTabId:o}:o;if(e.type==="pane"){if(e.id===t){let c=typeof o=="string"?{type:"pane",id:de(),tabIds:[o],activeTabId:o}:o,s=r==="left"||r==="top";return {type:"split",direction:n,first:s?c:e,second:s?e:c,splitPercentage:50}}return e}return {...e,first:Se(e.first,t,n,r,o)||e.first,second:Se(e.second,t,n,r,o)||e.second}}function En(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 It(e,t,n,r){if(e===null)return {type:"pane",id:de(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};let o=t?ee(e,t):null;if(o&&o.type==="pane"){let a=function(l){if(l.type==="pane"&&l.id===t){let f=[...l.tabIds];f.includes(n)||f.push(n);let i=l.tabsMetadata;return r&&(i={...l.tabsMetadata,[n]:r}),{...l,tabIds:f,activeTabId:n,tabsMetadata:i}}return l.type==="split"?{...l,first:a(l.first),second:a(l.second)}:l};return a(e)}let c={type:"pane",id:de(),tabIds:[n],activeTabId:n,tabsMetadata:r?{[n]:r}:void 0};return En(e,c)}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 ee(e,t){return e===null?null:e.type==="pane"?e.id===t?e:null:e.type==="split"?ee(e.first,t)??ee(e.second,t):null}function W(e,t){return e===null?null:e.type==="pane"?e.tabIds.includes(t)?e:null:e.type==="split"?W(e.first,t)??W(e.second,t):null}function Lt(e,t){return ee(e,t)??W(e,t)}function kt(e,t){let n=W(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]}}function Mt(e,t){return W(e,t)?.tabsMetadata?.[t]}function zt(e,t){let n=ee(e,t);return n?.tabsMetadata?.[n.activeTabId]}function Ue(e,t,n){if(e===null)return null;if(e.type==="pane"){if(e.tabIds.includes(t)){let r=e.tabsMetadata||{},o=r[t],c=n(o),s={...r};return c===void 0?delete s[t]:s[t]=c,{...e,tabsMetadata:Object.keys(s).length>0?s:void 0}}return e}return e.type==="split"?{...e,first:Ue(e.first,t,n)??e.first,second:Ue(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 Ee(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:Ee(e.first,t,n)??e.first,second:Ee(e.second,t,n)??e.second}:e}function At(e,t,n){if(e===null)return null;let o=W(e,t)?.tabsMetadata?.[t],c=pe(e,t);if(c===null)return {type:"pane",id:de(),tabIds:[t],activeTabId:t,tabsMetadata:o?{[t]:o}:void 0};function s(a){if(a.type==="pane"){if(a.id===n){let l=[...a.tabIds];l.includes(t)||l.push(t);let f={...a.tabsMetadata};return o&&(f[t]=o),{...a,tabIds:l,activeTabId:t,tabsMetadata:Object.keys(f).length>0?f:void 0}}return a}return a.type==="split"?{...a,first:s(a.first),second:s(a.second)}:a}return s(c)}function Nn(e,t,n){if(e===null)return null;if(t===n)return e;let r=W(e,t),o=W(e,n);if(!r||!o)return e;let c=r.id,s=o.id,a=r.tabsMetadata?.[t],l=o.tabsMetadata?.[n];function f(i){if(i.type==="pane"){let h=false,T=[...i.tabIds],b=i.activeTabId,d=i.tabsMetadata?{...i.tabsMetadata}:{};if(c===s){if(i.id===c){let u=T.indexOf(t),m=T.indexOf(n);u!==-1&&m!==-1&&(T[u]=n,T[m]=t),b=t,h=true;}}else i.id===c&&(T=T.map(u=>u===t?n:u),b===t&&(b=n),delete d[t],l&&(d[n]=l),h=true),i.id===s&&(T=T.map(u=>u===n?t:u),b===n&&(b=t),delete d[n],a&&(d[t]=a),h=true);return h?{...i,tabIds:T,activeTabId:b,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 ze(e,t,n,r="before"){if(e===null)return null;if(t===n)return e;if(r==="center")return Nn(e,t,n);let c=W(e,t)?.tabsMetadata?.[t],s=pe(e,t);if(s===null)return {type:"pane",id:de(),tabIds:[t],activeTabId:t,tabsMetadata:c?{[t]:c}:void 0};function a(l){if(l.type==="pane"){if(l.tabIds.includes(n)){let i=[...l.tabIds].filter(b=>b!==t),h=i.indexOf(n);h<0&&(h=0),r==="after"&&(h+=1),i.splice(h,0,t);let T={...l.tabsMetadata};return c&&(T[t]=c),{...l,tabIds:i,activeTabId:t,tabsMetadata:Object.keys(T).length>0?T:void 0}}return l}return l.type==="split"?{...l,first:a(l.first),second:a(l.second)}:l}return a(s)}function ve(e,t=0,n=0,r=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:r,height:o,node:e}],splitters:[]};let{direction:s,splitPercentage:a,first:l,second:f}=e,h={id:`splitter-${c}-${s}`,currentNode:e,direction:s,left:s==="row"?t+r*(a/100):t,top:s==="column"?n+o*(a/100):n,width:s==="row"?0:r,height:s==="column"?0:o,parentLeft:t,parentTop:n,parentWidth:r,parentHeight:o},T={panes:[],splitters:[]},b={panes:[],splitters:[]};if(s==="row"){let d=r*(a/100);T=ve(l,t,n,d,o,`${c}-L`),b=ve(f,t+d,n,r-d,o,`${c}-R`);}else {let d=o*(a/100);T=ve(l,t,n,r,d,`${c}-T`),b=ve(f,t,n+d,r,o-d,`${c}-B`);}return {panes:[...T.panes,...b.panes],splitters:[h,...T.splitters,...b.splitters]}}function Zt(e,t,n,r="before"){if(e===null)return null;let o=ee(e,t);if(!o)return e;let c=o.tabIds,s=o.activeTabId,a=o.tabsMetadata||{},l=fe(e,t);if(l===null)return o;function f(i){if(i.type==="pane"){if(i.tabIds.includes(n)){let T=[...i.tabIds].filter(u=>!c.includes(u)),b=T.indexOf(n);b<0&&(b=0),r==="after"&&(b+=1),T.splice(b,0,...c);let d={...i.tabsMetadata};for(let u of c)a[u]&&(d[u]=a[u]);return {...i,tabIds:T,activeTabId:s,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(l)}function Ot(e,t,n,r){if(!((t==="tab"||t==="pane")&&n&&e.includes(n))||!r)return -1;let s=e.indexOf(n);return r==="before"?s:s+1}function In(e){let{initialLayout:t,layout:n,onChange:r,fullscreenPaneId:o,onFullscreenChange:c,locked:s=false}=e,[a,l]=ge.useState(()=>n!==void 0?n:t??null),[f,i]=ge.useState(()=>n!==void 0?n:t??null),[h,T]=ge.useState(()=>ke(n!==void 0?n:null)),[b,d]=ge.useState(o||null),[u,m]=ge.useState(s),[P,g]=ge.useState([]),[S,E]=ge.useState(null),[k,I]=ge.useState(null),[x,M]=ge.useState(null),F=ge.useRef(null),j=ge.useCallback(p=>{F.current=p;},[]),$=ge.useRef(a);$.current=a;let te=ge.useRef(r);te.current=r;let X=ge.useRef(c);X.current=c;let ne=ge.useCallback(p=>{d(p),X.current?.(p);},[]);if(ge.useEffect(()=>{m(s);},[s]),ge.useEffect(()=>{o!==void 0&&d(o);},[o]),n!==void 0){let p=ke(n);p!==h&&(T(p),l(n),i(n));}let N=ge.useCallback(p=>(...y)=>{let w=$.current,_=p(w,...y);ke(w)!==ke(_)&&($.current=_,l(_),i(_),te.current?.(_));},[]),A=ge.useCallback(N((p,y)=>typeof y=="function"?y(p):y),[N]),U=ge.useCallback(p=>{i(y=>typeof p=="function"?p(y):p);},[]),B=ge.useCallback(p=>{d(null),X.current?.(null),E(null),I(null),M(null),A(p),i(()=>typeof p=="function"?p($.current):p);},[A]),L=ge.useCallback(N((p,y)=>fe(p,y)),[N]),z=ge.useCallback(N((p,y,w,_)=>{let H=pe(p,y)??p;return It(H,w,y,_)}),[N]),v=ge.useCallback(N((p,y,w,_,H)=>{let se=ee(p,y)??W(p,y);if(!se)return p;let V=ee(p,H)??W(p,H)??{type:"pane",id:H,tabIds:[H],activeTabId:H},be=fe(p,V.id);return Se(be,se.id,w,_,V)}),[N]),Z=ge.useCallback(N((p,y,w)=>we(p,y,w)),[N]),R=ge.useCallback(N((p,y,w)=>Ue(p,y,w)),[N]),O=ge.useCallback(N((p,y,w)=>{let _=ee(p,y)??W(p,y);return _?je(p,_.id,w):p}),[N]),ce=ge.useCallback(N((p,y,w)=>{let _=ee(p,y)??W(p,y);return _?Ee(p,_.id,w):p}),[N]),J=ge.useCallback(N((p,y,w)=>{let _=ee(p,w)??W(p,w);return _?At(p,y,_.id):p}),[N]),Y=ge.useCallback(N((p,y,w,_)=>ze(p,y,w,_)),[N]),G=ge.useCallback(N((p,y)=>pe(p,y)),[N]),Q=ge.useCallback(p=>ee($.current,p),[]),D=ge.useCallback(p=>W($.current,p),[]),C=ge.useCallback(p=>kt($.current,p),[]),ie=ge.useCallback(p=>Mt($.current,p),[]),re=ge.useCallback(p=>zt($.current,p),[]),K=ge.useCallback(p=>{g(y=>y.includes(p)?y:[...y,p]);},[]),oe=ge.useCallback(p=>{g(y=>y.includes(p)?y.filter(w=>w!==p):y);},[]);return {layout:a,setLayout:B,_internalSetLayout:U,renderingLayout:f,fullscreenPaneId:b,setFullscreenPaneId:ne,locked:u,setLocked:m,poppedOutTabIds:P,activeId:S,setActiveId:E,activeType:k,setActiveType:I,dismissIntentId:x,setDismissIntentId:M,containerRef:F,setContainerRef:j,removePane:L,addTab:z,updateMetadata:R,updatePaneLock:O,selectTab:ce,mergeTab:J,moveTab:Y,removeTab:G,splitPane:v,updateSplitPercentage:Z,popoutTab:K,dockTab:oe,findPaneById:Q,findPaneContainingTab:D,findTabById:C,getTabMetadata:ie,getActiveTabMetadata:re}}var Ln=()=>{let e=ae(),t=Me();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 Je=class extends core.PointerSensor{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]},Ye=class extends core.TouchSensor{static activators=[{eventName:"onTouchStart",handler:({nativeEvent:t})=>!t.target?.closest(".drag-cancel")}]};var _t=e=>{let n=e.active.id.toString().startsWith("tab-header-"),o=core.pointerWithin(e);if(o.length>0)return [...o].sort((s,a)=>{let l=s.id.toString(),f=a.id.toString(),i=l.startsWith("tab-drop-"),h=f.startsWith("tab-drop-");if(i&&!h)return -1;if(!i&&h)return 1;let T=l.startsWith("drop-root-"),b=f.startsWith("drop-root-");return T&&!b?-1:!T&&b?1:0});if(n){let c=e.droppableContainers.filter(s=>s.id.toString().startsWith("tab-drop-"));return core.closestCenter({...e,droppableContainers:c})}return []};function Ae(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 Ft(e){let{layout:t,_internalSetLayout:n,setLayout:r,activeId:o,setActiveId:c,activeType:s,setActiveType:a,dismissIntentId:l,setDismissIntentId:f,setOverTabId:i,setOverTabPosition:h,containerRef:T,dragActivationDistance:b,enableDragToDismiss:d,dismissThreshold:u,onRemove:m,onDragStart:P,onDragEnd:g,onDismissIntentChange:S,removeTab:E,removePane:k}=e,I=ge.useRef(null),x=wt(o),M=ge.useRef(null),[F,j]=ge.useState(false);return Dt(F),{sensors:core.useSensors(core.useSensor(Je,{activationConstraint:{distance:b}}),core.useSensor(Ye,{activationConstraint:{delay:250,tolerance:5}})),collisionDetection:_t,onDragStart:A=>{let U=A.active.id.toString(),B=U.startsWith("tab-header-"),L=B?U.substring(11):U;c(L),a(B?"tab":"pane"),i(null),h(null);let z=A.activatorEvent;x.current=Ae(z),d&&T.current?I.current=T.current.getBoundingClientRect():I.current=null;let v=t;if(B){let R=W(t,L);R&&(v=Ee(t,R.id,L)||t);}M.current=v;let Z=B?pe(v,L):fe(v,L);n(Z),P&&P(L);},onDragMove:A=>{let{over:U}=A,B=U?.id.toString()||"",L=B.startsWith("drop-locked-");j(D=>D===L?D:L);let z=A.active.id.toString(),v=z.startsWith("tab-header-"),Z=v?z.substring(11):z,R=B.match(/^tab-drop-(.+)$/);if(R&&U&&(v||s==="pane")){let[,D]=R;if(Z!==D){let C="before",ie=U.rect,re=A.activatorEvent,K=null;if(x.current)K=x.current.x;else {let oe=Ae(re);oe&&(K=oe.x+A.delta.x);}if(K!==null){let oe=ie.left+ie.width/2;K>oe&&(C="after");}i(oe=>oe===D?oe:D),h(oe=>oe===C?oe:C);}else i(C=>C===null?C:null),h(C=>C===null?C:null);}else i(D=>D===null?D:null),h(D=>D===null?D:null);if(!d)return;let O=I.current;if(!O){l!==null&&(f(null),S?.(null));return}let ce=A.activatorEvent,J=null,Y=null;if(x.current)J=x.current.x,Y=x.current.y;else {let D=Ae(ce);D&&(J=D.x+A.delta.x,Y=D.y+A.delta.y);}let G=0;if(J!==null&&Y!==null){let D=0,C=0;J<O.left?D=O.left-J:J>O.right&&(D=J-O.right),Y<O.top?C=O.top-Y:Y>O.bottom&&(C=Y-O.bottom),G=Math.sqrt(D*D+C*C);}else {let D=A.active.rect.current.translated;if(D){let C=D.left+D.width/2,ie=D.top+D.height/2,re=0,K=0;C<O.left?re=O.left-C:C>O.right&&(re=C-O.right),ie<O.top?K=O.top-ie:ie>O.bottom&&(K=ie-O.bottom),G=Math.sqrt(re*re+K*K);}}G>u?l!==Z&&(f(Z),S?.(Z)):l!==null&&(f(null),S?.(null));},onDragEnd:A=>{c(null),a(null),j(false),i(null),h(null);let{active:U,over:B}=A,L=U.id.toString(),z=L.startsWith("tab-header-"),v=z?L.substring(11):L,Z=d&&l===v;f(null),S?.(null),I.current=null;let R=M.current||t;if(M.current=null,Z){m?m(v):z?E(v):k(v),g&&g(v,null,null);return}if(!B){n(R),g&&g(v,null,null);return}let O=B.id.toString();if(O.startsWith("drop-locked-")){n(R),g&&g(v,null,null);return}let ce=O.match(/^tab-drop-(.+)$/);if(ce){let[,p]=ce;if(z)if(v!==p){let y="before",w=B.rect,_=A.activatorEvent,H=null;if(x.current)H=x.current.x;else {let V=Ae(_);V&&(H=V.x+A.delta.x);}if(H!==null){let V=w.left+w.width/2;H>V&&(y="after");}let se=ze(R,v,p,y);r(se),g&&g(v,p,{type:"move",position:"center"});}else n(R),g&&g(v,null,null);else {let y="before",w=B.rect,_=A.activatorEvent,H=null;if(x.current)H=x.current.x;else {let V=Ae(_);V&&(H=V.x+A.delta.x);}if(H!==null){let V=w.left+w.width/2;H>V&&(y="after");}let se=Zt(R,v,p,y);r(se),g&&g(v,p,{type:"move",position:"center"});}return}let J=O.match(/^drop-root-(1\/4|1\/3)-(top|bottom|left|right|start|end)$/);if(J){let[,p,y]=J,w=y;w==="start"&&(w="left"),w==="end"&&(w="right");let _=z?pe(R,v):fe(R,v),H;if(z){let V=W(R,v)?.tabsMetadata?.[v];H={type:"pane",id:de(),tabIds:[v],activeTabId:v,tabsMetadata:V?{[v]:V}:void 0};}else H=ee(R,v)??{type:"pane",id:de(),tabIds:[v],activeTabId:v};if(_===null)r(H);else {let se=w==="left"||w==="right",V=w==="left"||w==="top",be=50;p==="1/4"?be=V?25:75:p==="1/3"&&(be=V?100/3:200/3),r({type:"split",direction:se?"row":"column",first:V?H:_,second:V?_:H,splitPercentage:be});}g&&g(v,"root",{type:"split",direction:w==="left"||w==="right"?"row":"column",position:w});return}let Y=O.match(/^drop-(left|right|top|bottom|center)-(.+)$/);if(!Y){n(R),g&&g(v,null,null);return}let[,G,Q]=Y;if(G==="center"){if(z){let p=ee(R,Q);if(p&&p.activeTabId){let y=p.activeTabId,w=ze(R,v,y,"center");r(w),g&&g(v,Q,{type:"move",position:"center"});}else n(R),g&&g(v,null,null);}else n(R),g&&g(v,null,null);return}let D=z?W(R,v):ee(R,v),C=D&&D.id===Q,ie=D&&D.tabIds.length===1;if(v===Q||C&&ie){n(R),g&&g(v,null,null);return}let re=G==="left"||G==="right"?"row":"column",K;if(z){let y=W(R,v)?.tabsMetadata?.[v];K={type:"pane",id:de(),tabIds:[v],activeTabId:v,tabsMetadata:y?{[v]:y}:void 0};}else K=ee(R,v)??{type:"pane",id:de(),tabIds:[v],activeTabId:v};let oe=z?pe(R,v):fe(R,v),Le=Se(oe,Q,re,G,K);r(Le),g&&g(v,Q,{type:"split",direction:re,position:G});},onDragCancel:()=>{c(null),a(null),j(false),i(null),h(null),f(null),S?.(null),I.current=null;let A=M.current||t;M.current=null,n(A),A!==t&&r(A);}}}function Wt({persist:e,layout:t,setLayout:n}){let r=typeof e=="object"?e.enabled!==false:!!e,o=typeof e=="object"&&e.key||"zeugma-layout",[c,s]=ge.useState(false);ge.useEffect(()=>{if(r){let a=localStorage.getItem(o);if(a)try{let l=JSON.parse(a);l&&n(l);}catch(l){console.error("Failed to parse persisted zeugma layout",l);}}s(true);},[r,o,n]),ge.useEffect(()=>{r&&c&&(t?localStorage.setItem(o,JSON.stringify(t)):localStorage.removeItem(o));},[r,o,t,c]);}var De=null,Ut=false,Te=new Set;function me(){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 Bn(){if(typeof window>"u"||Ut)return;Ut=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=me();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=me();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=me();return u&&u!==document?u.body.removeChild(d):o.call(document.body,d)};let c=document.body.insertBefore;document.body.insertBefore=function(d,u){let m=me();return m&&m!==document?m.body.insertBefore(d,u):c.call(document.body,d,u)};let s=document.body.replaceChild;document.body.replaceChild=function(d,u){let m=me();return m&&m!==document?m.body.replaceChild(d,u):s.call(document.body,d,u)};let a=document.addEventListener;document.addEventListener=function(d,u,m){let P=me();return P&&P!==document?P.addEventListener(d,u,m):a.call(document,d,u,m)};let l=document.removeEventListener;document.removeEventListener=function(d,u,m){l.call(document,d,u,m),Te.forEach(P=>{try{P.removeEventListener(d,u,m);}catch{}});};let f=window.addEventListener;window.addEventListener=function(d,u,m){let P=me();return P&&P!==document&&P.defaultView?P.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),Te.forEach(P=>{try{P.defaultView&&P.defaultView.removeEventListener(d,u,m);}catch{}});};let h=document.getElementById;document.getElementById=function(d){let u=me();if(u&&u!==document)return u.getElementById(d);let m=h.call(document,d);if(m)return m;for(let P of Te)try{let g=P.getElementById(d);if(g)return g}catch{}return null};let T=document.querySelector;document.querySelector=function(d){let u=me();if(u&&u!==document)return u.querySelector(d);let m=T.call(document,d);if(m)return m;for(let P of Te)try{let g=P.querySelector(d);if(g)return g}catch{}return null};let b=document.querySelectorAll;document.querySelectorAll=function(d){let u=me();if(u&&u!==document)return u.querySelectorAll(d);let m=b.call(document,d);if(m.length>0)return m;for(let P of Te)try{let g=P.querySelectorAll(d);if(g.length>0)return g}catch{}return m};}function jt(e){let{poppedOutTabIds:t,registerPopoutTarget:n,findTabById:r,dockTab:o}=e,c=ge.useRef({});ge.useEffect(()=>{let s=c.current;t.forEach(a=>{if(s[a]){try{s[a].focus();}catch{}return}Bn();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}s[a]=i,Te.add(i.document),i.document.title=f,i.document.head.innerHTML="",Array.from(document.querySelectorAll('style, link[rel="stylesheet"]')).forEach(x=>{let M=x.cloneNode(true);if(x.tagName.toLowerCase()==="link"){let F=x.href;F&&M.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($=>$.cssText).join(`
10
+ `);M.textContent=j;}}catch{}i.document.head.appendChild(M);}),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}`),T="";h&&(T=window.getComputedStyle(h).backgroundColor,(!T||T==="transparent"||T==="rgba(0, 0, 0, 0)")&&h.parentElement&&(T=window.getComputedStyle(h.parentElement).backgroundColor));let b=window.getComputedStyle(document.documentElement),d=window.getComputedStyle(document.body),u=d.backgroundColor,P=!u||u==="transparent"||u==="rgba(0, 0, 0, 0)"?b.backgroundColor:u,g=T&&T!=="transparent"&&T!=="rgba(0, 0, 0, 0)"?T:P&&P!=="transparent"&&P!=="rgba(0, 0, 0, 0)"?P:"#181b1f";i.document.documentElement.style.backgroundColor=g,i.document.body.style.backgroundColor=g,i.document.body.style.color=d.color||b.color,i.document.body.style.fontFamily=d.fontFamily||b.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 E=["pointerdown","mousedown","click","keydown","focus","touchstart"],k=x=>{De=x,globalThis.__zeugmaActivePopoutDocument=i.document,queueMicrotask(()=>{De===x&&(De=null,globalThis.__zeugmaActivePopoutDocument=null);});};E.forEach(x=>{i.addEventListener(x,k,true);});let I=()=>{Te.delete(i.document),o(a);};i.addEventListener("beforeunload",I),i.__zeugmaCleanup=()=>{E.forEach(x=>{i.removeEventListener(x,k,true);}),i.removeEventListener("beforeunload",I);};}),Object.keys(s).forEach(a=>{if(!t.includes(a)){let l=s[a];if(delete s[a],n?.(a,null),l){Te.delete(l.document);try{let f=l;f.__zeugmaCleanup&&f.__zeugmaCleanup(),f.close();}catch{}}}});},[t,n,r,o]),ge.useEffect(()=>()=>{let s=c.current;Object.keys(s).forEach(a=>{let l=s[a];if(l){Te.delete(l.document);try{let f=l;f.__zeugmaCleanup&&f.__zeugmaCleanup(),f.close();}catch{}}});},[]);}var Xt=({activeId:e,render:t,className:n})=>{let r=ge.useRef(null);return ge.useEffect(()=>{let o=c=>{r.current&&(r.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:r,className:n,style:{position:"fixed",top:0,left:0,zIndex:9999,pointerEvents:"none"},children:t(e)})};var Un=({popoutDoc:e,children:t})=>{let n=ge__default.default.useEffect,r=ge__default.default.useLayoutEffect,o=ge__default.default.useInsertionEffect;ge__default.default.useEffect=(c,s)=>n(()=>{window.__zeugmaActivePopoutDocument=e;try{let a=c();return typeof a=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return a()}finally{window.__zeugmaActivePopoutDocument=null;}}:a}finally{window.__zeugmaActivePopoutDocument=null;}},s),ge__default.default.useLayoutEffect=(c,s)=>r(()=>{window.__zeugmaActivePopoutDocument=e;try{let a=c();return typeof a=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return a()}finally{window.__zeugmaActivePopoutDocument=null;}}:a}finally{window.__zeugmaActivePopoutDocument=null;}},s),o&&(ge__default.default.useInsertionEffect=(c,s)=>o(()=>{window.__zeugmaActivePopoutDocument=e;try{let a=c();return typeof a=="function"?()=>{window.__zeugmaActivePopoutDocument=e;try{return a()}finally{window.__zeugmaActivePopoutDocument=null;}}:a}finally{window.__zeugmaActivePopoutDocument=null;}},s)),window.__zeugmaActivePopoutDocument=e;try{return jsxRuntime.jsx(jsxRuntime.Fragment,{children:t})}finally{window.__zeugmaActivePopoutDocument=null,ge__default.default.useEffect=n,ge__default.default.useLayoutEffect=r,o&&(ge__default.default.useInsertionEffect=o);}},Yt=ge__default.default.memo(({tabDetails:e,target:t,renderWidget:n})=>{let{id:r}=e,[o,c]=ge.useState(false),s=ge.useRef(null);if(ge.useEffect(()=>{c(true);},[]),ge.useEffect(()=>{if(!o||!s.current)return;let f=s.current;if(t)t.ownerDocument.adoptNode(f),t.appendChild(f);else {let i=document.getElementById("zeugma-hidden-portal-container");i||(i=document.createElement("div"),i.id="zeugma-hidden-portal-container",i.style.display="none",document.body.appendChild(i)),document.adoptNode(f),i.appendChild(f);}},[t,o]),ge.useEffect(()=>()=>{s.current&&s.current.remove();},[]),!o)return null;s.current||(s.current=document.createElement("div"),s.current.className=`zeugma-portal-wrapper-${r}`,s.current.style.width="100%",s.current.style.height="100%");let a=s.current;if(!a||!n)return null;let l=n(e);return t&&t.ownerDocument&&t.ownerDocument!==document?reactDom.createPortal(jsxRuntime.jsx(Un,{popoutDoc:t.ownerDocument,children:l}),a):reactDom.createPortal(l,a)},(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 Qt=({activeId:e,activeType:t,dismissIntentId:n,renderDragOverlay:r,renderPaneRef:o,renderPane:c,tabHeadersRef:s,classNames:a})=>{if(r)return jsxRuntime.jsx(jsxRuntime.Fragment,{children:r({type:t,id:e,isDismissing:e===n})});if(t==="pane"){let l=o.current||c;if(l)return jsxRuntime.jsx("div",{className:a.paneDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:l(e)})}else if(t==="tab"){let l=o.current||c;if(l)return jsxRuntime.jsx("div",{className:a.tabDragPreview||"",style:{pointerEvents:"none",width:"420px",height:"260px",overflow:"hidden"},children:l(e)});let f=s.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 ut({containerRef:e,isRow:t,direction:n,splitPercentage:r,resizerSize:o,snapThreshold:c,layout:s,currentNode:a,onLayoutChange:l,onResizeStart:f,onResizeEnd:i,parentLeft:h,parentTop:T,parentWidth:b,parentHeight:d}){let{onResizeStart:u,onResize:m,onResizeEnd:P,minSplitPercentage:g=5,maxSplitPercentage:S=95,locked:E=false}=ae();return ge.useCallback(k=>{if(E)return;k.preventDefault();let I=e.current;if(!I)return;f&&f(),u&&u(a);let x=I.getBoundingClientRect(),M=k.clientX,F=k.clientY,j=r,$=k.currentTarget,te=x.left+x.width*(h/100),X=x.top+x.height*(T/100),ne=x.width*(b/100),N=x.height*(d/100),U=Array.from(document.querySelectorAll('div[role="separator"][data-direction]')).filter(L=>L!==$&&L.getAttribute("data-direction")===n).map(L=>{let z=L.getBoundingClientRect();return t?z.left+z.width/2:z.top+z.height/2}),B=j;xt({cursor:t?"col-resize":"row-resize",resizerEl:$,onMove:L=>{let z=t?(L.clientX-M)/ne*100:(L.clientY-F)/N*100,v=j+z,Z=t?te+(ne-o)*(v/100)+o/2:X+(N-o)*(v/100)+o/2,R=1/0,O=null;for(let G of U){let Q=Math.abs(Z-G);Q<c&&Q<R&&(R=Q,O=G);}let ce=v;O!==null&&(ce=t?(O-o/2-te)/(ne-o)*100:(O-o/2-X)/(N-o)*100);let J=Math.max(g,Math.min(S,ce));B=J;let Y=we(s,a,J);if(Y){let{panes:G,splitters:Q}=ve(Y),D=e.current;if(D){for(let C of G)D.style.setProperty(`--pane-left-${C.paneId}`,`${C.left}%`),D.style.setProperty(`--pane-top-${C.paneId}`,`${C.top}%`),D.style.setProperty(`--pane-width-${C.paneId}`,`${C.width}%`),D.style.setProperty(`--pane-height-${C.paneId}`,`${C.height}%`);for(let C of Q)D.style.setProperty(`--splitter-pos-${C.id}`,`${C.direction==="row"?C.left:C.top}%`);}}m&&m(a,J);},onEnd:()=>{let L=we(s,a,B),z=e.current;if(z){let{panes:v,splitters:Z}=ve(L);for(let R of v)z.style.removeProperty(`--pane-left-${R.paneId}`),z.style.removeProperty(`--pane-top-${R.paneId}`),z.style.removeProperty(`--pane-width-${R.paneId}`),z.style.removeProperty(`--pane-height-${R.paneId}`);for(let R of Z)z.style.removeProperty(`--splitter-pos-${R.id}`);}l(L),i&&i(),P&&P(a,B);}});},[e,t,n,r,o,c,s,a,l,f,i,u,m,P,g,S,h,T,b,d])}var Kt=({splitter:e,resizerSize:t,snapThreshold:n,containerRef:r})=>{let{renderingLayout:o,setLayout:c,classNames:s,locked:a}=ae(),[l,f]=ge.useState(false),{currentNode:i,direction:h,left:T,top:b,width:d,height:u,parentLeft:m,parentTop:P,parentWidth:g,parentHeight:S}=e,E=h==="row",k=ut({containerRef:r,isRow:E,direction:h,splitPercentage:i.splitPercentage,resizerSize:t,snapThreshold:n,layout:o,currentNode:i,onLayoutChange:c,onResizeStart:()=>f(true),onResizeEnd:()=>f(false),parentLeft:m,parentTop:P,parentWidth:g,parentHeight:S}),I=E?{position:"absolute",left:`calc(var(--splitter-pos-${e.id}, ${T}%) - ${t/2}px)`,top:`calc(${b}% + ${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(${T}% + ${t/2}px)`,top:`calc(var(--splitter-pos-${e.id}, ${b}%) - ${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:s.resizer||"","data-direction":h,"data-resizing":l||void 0,style:I,onPointerDown:k,role:"separator","aria-valuenow":i.splitPercentage,"aria-valuemin":5,"aria-valuemax":95})},en=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 dt=({renderPane:e,tree:t,resizerSize:n,snapThreshold:r})=>{Nt(e);let{renderingLayout:o,activeId:c,dismissIntentId:s,setContainerRef:a,fullscreenPaneId:l,snapThreshold:f,locked:i,classNames:h,resizerSize:T}=ae(),b=r!==void 0?r:f??8,d=n!==void 0?n:T??4,u=t!==void 0?t:o,m=ge.useRef(null),{panes:P,splitters:g}=ge.useMemo(()=>u?ve(u):{panes:[],splitters:[]},[u]);if(!u&&t!==void 0)return null;let S=()=>jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[P.map(E=>{let k=l===E.paneId;return jsxRuntime.jsx("div",{style:{position:"absolute",left:k?"0%":`var(--pane-left-${E.paneId}, ${E.left}%)`,top:k?"0%":`var(--pane-top-${E.paneId}, ${E.top}%)`,width:k?"100%":`var(--pane-width-${E.paneId}, ${E.width}%)`,height:k?"100%":`var(--pane-height-${E.paneId}, ${E.height}%)`,overflow:"hidden",zIndex:k?20:1,display:l&&!k?"none":"block",padding:k?"0px":`${d/2}px`,boxSizing:"border-box"},children:jsxRuntime.jsx(en,{paneId:E.paneId,renderPane:e})},E.paneId)}),!l&&g.map(E=>jsxRuntime.jsx(Kt,{splitter:E,resizerSize:d,snapThreshold:b,containerRef:m},E.id))]});if(t===void 0){let E=c!==null&&c===s,k=x=>{a(x),m.current=x;},I=`${h.dashboard||""} ${E&&h.dashboardDismissActive||""} ${i&&h.dashboardLocked||""}`.trim();return jsxRuntime.jsxs("div",{ref:k,className:I,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[S(),c!==null&&!i&&jsxRuntime.jsx(on,{activeClassName:h.rootDropPreview??h.dropPreview})]})}return jsxRuntime.jsx("div",{ref:m,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:S()})};var oo=e=>{let{controller:t,children:n,renderDragOverlay:r,classNames:o={},renderPane:c,resizerSize:s,dragActivationDistance:a=8,snapThreshold:l=8,minSplitPercentage:f=5,maxSplitPercentage:i=95,enableDragToDismiss:h=false,dismissThreshold:T=60,onRemove:b,onDragStart:d,onDragEnd:u,onResizeStart:m,onResize:P,onResizeEnd:g,onDismissIntentChange:S,persist:E=false}=e,k=t,{layout:I,setLayout:x,_internalSetLayout:M,renderingLayout:F,fullscreenPaneId:j,setFullscreenPaneId:$,locked:te,setLocked:X,findPaneById:ne,findPaneContainingTab:N,findTabById:A,getTabMetadata:U,getActiveTabMetadata:B,activeId:L,setActiveId:z,activeType:v,setActiveType:Z,dismissIntentId:R,setDismissIntentId:O,containerRef:ce,setContainerRef:J,removePane:Y,addTab:G,updateMetadata:Q,updatePaneLock:D,selectTab:C,mergeTab:ie,removeTab:re,splitPane:K,updateSplitPercentage:oe,moveTab:Le,poppedOutTabIds:p=[],popoutTab:y,dockTab:w}=k;Wt({persist:E,layout:I,setLayout:x});let{portalTargets:_,registerPortalTarget:H,registerPopoutTarget:se,registerRenderCallback:V,renderCallbacksRef:be,registerRenderPane:nt,renderPaneRef:ot,registerTabHeader:bt,tabHeadersRef:rt,activeIdRef:Be}=Ct();jt({poppedOutTabIds:p,registerPopoutTarget:se,findTabById:A,dockTab:w});let vt=ge.useCallback(ue=>p.includes(ue),[p]),{overTabId:ht,setOverTabId:bn,overTabPosition:Tt,setOverTabPosition:vn,handleDragStartInternal:hn,handleDragEndInternal:Tn}=Et({onDragStart:d,onDragEnd:u}),Pn=Ft({layout:I,_internalSetLayout:M,setLayout:x,activeId:L,setActiveId:z,activeType:v,setActiveType:Z,dismissIntentId:R,setDismissIntentId:O,setOverTabId:bn,setOverTabPosition:vn,containerRef:ce,dragActivationDistance:a,enableDragToDismiss:h,dismissThreshold:T,onRemove:b,onDragStart:hn,onDragEnd:Tn,onDismissIntentChange:S,removeTab:re,removePane:Y}),at=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]),Pt=ge.useCallback((ue,He)=>{g&&g(ue,He);},[g]),yn=ge.useMemo(()=>({layout:I,renderingLayout:F,setLayout:x,activeId:L,activeType:v,dismissIntentId:R,setContainerRef:J,fullscreenPaneId:j,classNames:at,onRemove:b,onFullscreenChange:$,snapThreshold:l,onResizeStart:m,onResize:P,onResizeEnd:Pt,minSplitPercentage:f,maxSplitPercentage:i,locked:te,setLocked:X,findPaneById:ne,findPaneContainingTab:N,findTabById:A,getTabMetadata:U,getActiveTabMetadata:B,renderPane:c,resizerSize:s,poppedOutTabIds:p,isTabPoppedOut:vt}),[I,F,L,v,R,J,j,at,b,$,l,m,P,f,i,x,Pt,te,X,ne,N,A,U,B,c,s,p,vt]),xn=ge.useMemo(()=>({overTabId:ht,overTabPosition:Tt}),[ht,Tt]),Rn=ge.useMemo(()=>({removePane:Y,addTab:G,updateMetadata:Q,updatePaneLock:D,selectTab:C,mergeTab:ie,removeTab:re,setFullscreenPaneId:$,setLocked:X,splitPane:K,updateSplitPercentage:oe,moveTab:Le,popoutTab:y,dockTab:w}),[Y,G,Q,D,C,ie,re,$,X,K,oe,Le,y,w]),wn=St(I),Dn=ge.useMemo(()=>({registerPortalTarget:H,registerRenderCallback:V,renderCallbacksRef:be,registerRenderPane:nt,renderPaneRef:ot,registerTabHeader:bt,tabHeadersRef:rt,activeIdRef:Be,registerPopoutTarget:se}),[H,V,be,nt,ot,bt,rt,Be,se]);return Be&&(Be.current=L),jsxRuntime.jsx(xe.Provider,{value:Rn,children:jsxRuntime.jsx(st.Provider,{value:yn,children:jsxRuntime.jsx(lt.Provider,{value:xn,children:jsxRuntime.jsxs(ye.Provider,{value:Dn,children:[jsxRuntime.jsx(core.DndContext,{id:"zeugma-dnd-context",...Pn,children:n}),L&&v&&jsxRuntime.jsx(Xt,{activeId:L,render:ue=>jsxRuntime.jsx("div",{style:{transition:"transform 150ms cubic-bezier(0.2, 0, 0, 1)",transform:ue===R?"scale(0.8)":"scale(1)",transformOrigin:"top left"},children:jsxRuntime.jsx(Qt,{activeId:ue,activeType:v,dismissIntentId:R,renderDragOverlay:r,renderPaneRef:ot,renderPane:c,tabHeadersRef:rt,classNames:at})}),className:`${o.dragOverlay||""} ${L===R&&o.dismissPreview||""}`.trim()}),jsxRuntime.jsx("div",{id:"zeugma-portal-host",style:{display:"none"},children:wn.map(ue=>{let He=_[ue],yt=A(ue);return yt?jsxRuntime.jsx(Yt,{tabDetails:yt,target:He||null,renderWidget:be.current[ue]},ue):null})})]})})})})},ro=({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(dt,{renderPane:e,resizerSize:t,snapThreshold:n})},ao=e=>{let{children:t,...n}=e,{controller:r}=e;if(!r)throw new Error("Zeugma component requires a controller.");return jsxRuntime.jsx(oo,{...e,children:t!==void 0?t:jsxRuntime.jsx(ro,{...n})})};var lo={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"}}},co={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"}}},uo=({id:e,fraction:t,edge:n,activeClassName:r})=>{let{setNodeRef:o,isOver:c}=core.useDroppable({id:e}),s={position:"absolute",pointerEvents:"none",zIndex:101,boxSizing:"border-box",...co[n][t]};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{ref:o,style:lo[n][t]}),c&&jsxRuntime.jsx("div",{className:r,style:s})]})},on=({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(uo,{id:n.id,fraction:n.fraction,edge:n.edge,activeClassName:e},n.id))});var Qe=ge.createContext(null);var bo={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"}},vo={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"}},Ke=({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:bo[t]}),o&&jsxRuntime.jsx("div",{className:n,style:vo[t]})]})};var sn=({children:e,className:t,style:n})=>{let r=ge.useContext(Qe);if(!r)throw new Error("<DragHandle> must be used inside a <Pane>");let{disabled:o,...c}=r;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 So=ge.createContext(void 0);var _e=({id:e,locked:t=false,children:n,className:r,style:o})=>{let{locked:c,classNames:s={},fullscreenPaneId:a,poppedOutTabIds:l=[]}=ae(),f=ge.useContext(xe),{overTabId:i}=Ve(),h=ge.useContext(ye);ge.useEffect(()=>(h?.registerTabHeader&&h.registerTabHeader(e,n),()=>{h?.registerTabHeader&&h.activeIdRef?.current!==e&&h.registerTabHeader(e,()=>null);}),[e,n,h]);let T=l.includes(e),b=ge.useContext(ft),d=t||c||(b?.locked??false)||a!==null,{attributes:u,listeners:m,setNodeRef:P,isDragging:g}=core.useDraggable({id:`tab-header-${e}`,disabled:d}),{setNodeRef:S,isOver:E}=core.useDroppable({id:`tab-drop-${e}`,disabled:d}),k=U=>{P(U),S(U);},I=E&&i===e,x=b?.tabIds||[],M=x.indexOf(e),F=b?.activeTabId,$=M>0&&e!==F&&x[M-1]!==F?jsxRuntime.jsx("div",{className:s.tabSeparator}):null,te=b?b.activeTabId===e:false,X=b?.tabsMetadata?.[e],ne=ge.useCallback(()=>{b?.selectTab(e);},[b,e]),N=ge.useCallback(()=>{b?.removeTab(e);},[b,e]),A=ge.useMemo(()=>({tabId:e,isActive:te,isDragging:g,isOver:I,metadata:X,locked:d,selectTab:ne,removeTab:N,isPoppedOut:T,popoutTab:()=>f?.popoutTab(e),dockTab:()=>f?.dockTab(e)}),[e,te,g,I,X,d,ne,N,T,f]);return jsxRuntime.jsx(So.Provider,{value:A,children:jsxRuntime.jsxs("div",{ref:k,id:`tab-header-${e}`,className:r,style:{display:"inline-flex",position:"relative",cursor:d?"default":"grab",...o},...d?{}:m,...d?{}:u,children:[$,n({isDragging:g,isOver:I})]})})};var ft=ge.createContext(void 0);var dn=(e,t)=>typeof e=="function"?e(t):e,mt=({tabIds:e,activeTabId:t,locked:n,tabsMetadata:r,selectTab:o,removeTab:c,renderTab:s,classNames:a,styles:l})=>{let f=ge.useContext(et),i=e??f?.tabIds??[],h=t??f?.activeTabId??"",T=n??f?.locked??false,b=r??f?.tabsMetadata,d=o??f?.selectTab??(()=>{}),u=c??f?.removeTab??(()=>{}),{classNames:m={},activeType:P,poppedOutTabIds:g=[]}=ae(),S=ge.useContext(xe),{overTabId:E,overTabPosition:k}=Ve(),I=ge.useMemo(()=>({tabIds:i,activeTabId:h,locked:T,tabsMetadata:b,selectTab:d,removeTab:u}),[i,h,T,b,d,u]),x=Ot(i,P,E,k);return jsxRuntime.jsx(ft.Provider,{value:I,children:jsxRuntime.jsxs("div",{className:a?.container,style:{display:"flex",alignItems:"center",height:"100%",...l?.container},children:[i.map((M,F)=>{let j=b?.[M],$=dn(a?.tab,M),te=dn(l?.tab,M),X=F===x;return jsxRuntime.jsxs(ge__default.default.Fragment,{children:[X&&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:M,locked:T,className:$,style:te,children:({isDragging:ne,isOver:N})=>s({id:M,paneId:f?.id??"",isActive:M===h,index:F,isDragging:ne,isOver:N,metadata:j,onSelect:()=>d(M),onRemove:()=>u(M),isPoppedOut:g.includes(M),popout:()=>S?.popoutTab(M),dock:()=>S?.dockTab(M)})})]},M)}),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%)"}})})]})})};mt.Tab=_e;var fn=({className:e,style:t,children:n})=>jsxRuntime.jsx("div",{className:e,style:t,children:n});var et=ge.createContext(void 0),gn=()=>{let e=ge.useContext(et);if(!e)throw new Error("usePaneContext must be used within a Pane component");return e},Oo=({children:e,className:t,style:n})=>{let{activeTabId:r}=gn(),{classNames:o,isTabPoppedOut:c}=ae(),{dockTab:s}=Me(),a=ge.useRef(null),l=ge.useContext(ye);if(!l)throw new Error("PaneContent must be used within a Zeugma provider");let{registerPortalTarget:f,registerRenderCallback:i}=l,h=ge.useMemo(()=>typeof e=="function"?e:()=>e,[e]);i(r,h),ge.useEffect(()=>{let b=a.current;return f(r,b),()=>{f(r,null,b);}},[r,f]);let T=c(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:T&&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:()=>s(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:b=>{b.currentTarget.style.backgroundColor="#1d4ed8";},onMouseOut:b=>{b.currentTarget.style.backgroundColor="#2563eb";},children:"Dock Back"})]})})},Ie=({id:e,children:t,style:n,locked:r=false})=>{let{layout:o,renderingLayout:c,activeId:s,activeType:a,classNames:l,fullscreenPaneId:f,onFullscreenChange:i,locked:h,poppedOutTabIds:T=[]}=ae(),{removePane:b,updateMetadata:d,selectTab:u,removeTab:m,popoutTab:P,dockTab:g}=Me(),S=ge.useMemo(()=>{if(a==="tab"&&e===s){let O=W(o,e)?.tabsMetadata?.[e];return {type:"pane",id:e,tabIds:[e],activeTabId:e,tabsMetadata:O?{[e]:O}:void 0}}return Lt(e===s?o:c,e)},[o,c,e,s,a]),E=S?.id??e,k=S?.tabIds??[e],I=S?.activeTabId??e,x=S?.tabsMetadata,M=x?.[e],F=S?.locked??false,j=r||F,$=h||j||f!==null,te=h||j||f!==null,X=s!==null&&s!==e&&(!k.includes(s)||k.length>1)&&!te,{attributes:ne,listeners:N,setNodeRef:A}=core.useDraggable({id:e,disabled:$}),U=s!==null&&k.includes(s),B=f===e,L=ge.useMemo(()=>({isDragging:U,isFullscreen:B,toggleFullscreen:()=>i?.(B?null:e),remove:()=>{B&&i?.(null),b(E);},metadata:M,updateMetadata:Z=>{d(e,Z);},locked:$,tabIds:k,activeTabId:I,selectTab:Z=>u(E,Z),removeTab:Z=>{B&&Z===I&&i?.(null),m(Z);},tabsMetadata:x,updateTabMetadata:(Z,R)=>{d(Z,R);},isActiveTabPoppedOut:T.includes(I),popoutTab:Z=>P(Z||I),dockTab:Z=>g(Z||I)}),[U,B,i,e,m,M,d,$,k,I,u,E,x,T,P,g]),z=ge.useMemo(()=>$?{disabled:true}:{...N,...ne},[N,ne,$]),v=`${l.pane||""} ${j&&l.paneLocked||""}`.trim();return jsxRuntime.jsx(et.Provider,{value:{id:e,...L},children:jsxRuntime.jsx(Qe.Provider,{value:z,children:jsxRuntime.jsxs("div",{ref:A,id:e,className:v,style:{position:"relative",width:"100%",height:"100%",...n},children:[t,X&&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(Ke,{id:`drop-${Z}-${e}`,position:Z,activeClassName:l.dropPreview},Z)),a==="tab"&&jsxRuntime.jsx(Ke,{id:`drop-center-${e}`,position:"center",activeClassName:l.swapPreview??l.dropPreview})]}),s!==null&&s!==e&&te&&jsxRuntime.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:15,pointerEvents:"none"},children:jsxRuntime.jsx(Ke,{id:`drop-locked-${e}`,position:"full",activeClassName:l.lockedPreview||""})})]})})})};Ie.Content=Oo;Ie.DragHandle=sn;Ie.Tabs=mt;Ie.Tab=_e;Ie.Controls=fn;exports.Pane=Ie;exports.PaneTree=dt;exports.Zeugma=ao;exports.usePaneContext=gn;exports.useResizer=ut;exports.useZeugma=In;exports.useZeugmaContext=Ln;//# sourceMappingURL=index.cjs.map
10
11
  //# sourceMappingURL=index.cjs.map