react-panel-layout 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/FloatingPanelFrame-D9Cp2al1.cjs +2 -0
  2. package/dist/FloatingPanelFrame-D9Cp2al1.cjs.map +1 -0
  3. package/dist/FloatingPanelFrame-lLg-Lpg7.js +95 -0
  4. package/dist/FloatingPanelFrame-lLg-Lpg7.js.map +1 -0
  5. package/dist/GridLayout-BQQ63eA1.cjs +2 -0
  6. package/dist/GridLayout-BQQ63eA1.cjs.map +1 -0
  7. package/dist/{GridLayout-tpSM0iM-.js → GridLayout-CJTKq7Mp.js} +465 -460
  8. package/dist/GridLayout-CJTKq7Mp.js.map +1 -0
  9. package/dist/PanelSystemContext.d.ts +9 -0
  10. package/dist/components/grid/GridLayerList.d.ts +3 -0
  11. package/dist/components/paneling/FloatingPanelFrame.d.ts +4 -0
  12. package/dist/config.cjs +1 -1
  13. package/dist/config.js +1 -1
  14. package/dist/constants/styles.d.ts +3 -1
  15. package/dist/floating.cjs +1 -1
  16. package/dist/floating.js +1 -1
  17. package/dist/hooks/ContentCacheContext.d.ts +59 -0
  18. package/dist/hooks/useContainerScroll.d.ts +23 -0
  19. package/dist/hooks/useContentCache.d.ts +67 -0
  20. package/dist/hooks/useDocumentScroll.d.ts +13 -0
  21. package/dist/hooks/useScrollContainer.d.ts +21 -0
  22. package/dist/index.cjs +2 -2
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.js +442 -440
  25. package/dist/index.js.map +1 -1
  26. package/dist/modules/pivot/types.d.ts +6 -0
  27. package/dist/pivot.cjs +1 -1
  28. package/dist/pivot.js +1 -1
  29. package/dist/sticky-header/StickyHeader.d.ts +53 -0
  30. package/dist/sticky-header/index.d.ts +7 -0
  31. package/dist/sticky-header/types.d.ts +50 -0
  32. package/dist/sticky-header.cjs +2 -0
  33. package/dist/sticky-header.cjs.map +1 -0
  34. package/dist/sticky-header.js +198 -0
  35. package/dist/sticky-header.js.map +1 -0
  36. package/dist/styles-CA2_zLZt.js +52 -0
  37. package/dist/{styles-DcG3aIFx.cjs.map → styles-CA2_zLZt.js.map} +1 -1
  38. package/dist/styles-PsqGOEJP.cjs +2 -0
  39. package/dist/styles-PsqGOEJP.cjs.map +1 -0
  40. package/dist/types.d.ts +12 -0
  41. package/dist/useIsomorphicLayoutEffect-DGRNF4Lf.cjs +2 -0
  42. package/dist/useIsomorphicLayoutEffect-DGRNF4Lf.cjs.map +1 -0
  43. package/dist/useIsomorphicLayoutEffect-DhmEnmZ_.js +6 -0
  44. package/dist/useIsomorphicLayoutEffect-DhmEnmZ_.js.map +1 -0
  45. package/dist/usePivot-7ctin_P_.cjs +2 -0
  46. package/dist/usePivot-7ctin_P_.cjs.map +1 -0
  47. package/dist/usePivot-CgQxB8rc.js +124 -0
  48. package/dist/usePivot-CgQxB8rc.js.map +1 -0
  49. package/package.json +6 -1
  50. package/dist/FloatingPanelFrame-DDT6aING.js +0 -66
  51. package/dist/FloatingPanelFrame-DDT6aING.js.map +0 -1
  52. package/dist/FloatingPanelFrame-DrYwgI9f.cjs +0 -2
  53. package/dist/FloatingPanelFrame-DrYwgI9f.cjs.map +0 -1
  54. package/dist/GridLayout-DC7fCmcI.cjs +0 -2
  55. package/dist/GridLayout-DC7fCmcI.cjs.map +0 -1
  56. package/dist/GridLayout-tpSM0iM-.js.map +0 -1
  57. package/dist/styles-DcG3aIFx.cjs +0 -2
  58. package/dist/styles-w0ZixggV.js +0 -51
  59. package/dist/styles-w0ZixggV.js.map +0 -1
  60. package/dist/usePivot-C8q0pMgW.cjs +0 -2
  61. package/dist/usePivot-C8q0pMgW.cjs.map +0 -1
  62. package/dist/usePivot-z9gumDf-.js +0 -97
  63. package/dist/usePivot-z9gumDf-.js.map +0 -1
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/components/resizer/HorizontalDivider.tsx","../src/modules/grid/useLayerDragHandle.ts","../src/modules/window/useFloatingState.ts","../src/modules/keybindings/KeybindingsProvider.tsx","../src/modules/panels/layout/adapter.ts","../src/modules/panels/rendering/RenderContext.tsx","../src/modules/panels/dom/DomRegistry.tsx","../src/components/panels/PanelGroupView.tsx","../src/modules/panels/interactions/dnd.ts","../src/utils/typedActions.ts","../src/modules/panels/interactions/InteractionsContext.tsx","../src/components/tabs/TabBarTab.tsx","../src/components/tabs/TabBar.tsx","../src/modules/panels/rendering/GroupContainer.tsx","../src/utils/CSSMatrix.ts","../src/components/panels/DropSuggestOverlay.tsx","../src/hooks/useClonedElementPreview.ts","../src/components/tabs/TabDragOverlay.tsx","../src/modules/panels/state/tree/logic.ts","../src/modules/panels/state/cleanup.ts","../src/modules/panels/state/groups/logic.ts","../src/modules/panels/state/focus/logic.ts","../src/modules/panels/index.ts","../src/modules/panels/state/groups/Context.tsx","../src/modules/panels/state/tree/Context.tsx","../src/modules/panels/state/focus/Context.tsx","../src/modules/panels/state/splitLimits.ts","../src/modules/panels/state/PanelSystemContext.tsx","../src/modules/panels/state/commands.ts","../src/modules/panels/keybindings/KeybindingsInstaller.tsx","../src/modules/panels/rendering/ContentRegistry.tsx","../src/modules/panels/rendering/RenderBridge.tsx","../src/modules/panels/state/PanelSplitHandles.tsx","../src/modules/panels/system/PanelSystem.tsx"],"sourcesContent":["/**\n * @file Horizontal divider component\n */\nimport * as React from \"react\";\nimport { useResizeDrag } from \"../../modules/resizer/useResizeDrag\";\nimport { HORIZONTAL_DIVIDER_WIDTH, COLOR_RESIZE_HANDLE_IDLE, COLOR_RESIZE_HANDLE_HOVER, COLOR_RESIZE_HANDLE_ACTIVE } from \"../../constants/styles\";\n\nexport type HorizontalDividerProps = {\n onResize: (deltaX: number) => void;\n /** Custom component for the divider */\n component?: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }>;\n /** Custom element for the divider */\n element?: React.ReactElement;\n};\n\nconst buildDividerStyle = (state: \"idle\" | \"hover\" | \"drag\"): React.CSSProperties => {\n const backgroundColor = state === \"drag\" ? COLOR_RESIZE_HANDLE_ACTIVE : state === \"hover\" ? COLOR_RESIZE_HANDLE_HOVER : COLOR_RESIZE_HANDLE_IDLE;\n return {\n width: HORIZONTAL_DIVIDER_WIDTH,\n cursor: \"col-resize\",\n position: \"relative\",\n userSelect: \"none\",\n backgroundColor,\n };\n};\n\nexport const HorizontalDivider: React.FC<HorizontalDividerProps> = ({ onResize, component: Component, element }) => {\n const { ref, isDragging, onPointerDown } = useResizeDrag<HTMLDivElement>({\n axis: \"x\",\n onResize: onResize,\n });\n const [hovered, setHovered] = React.useState(false);\n\n const dividerProps = {\n ref,\n style: buildDividerStyle(isDragging ? \"drag\" : hovered ? \"hover\" : \"idle\"),\n role: \"separator\" as const,\n \"aria-orientation\": \"vertical\" as const,\n \"data-dragging\": isDragging ? \"true\" : undefined,\n onPointerDown,\n onPointerEnter: () => setHovered(true),\n onPointerLeave: () => setHovered(false),\n };\n\n if (element) {\n return React.cloneElement(element, dividerProps);\n }\n if (Component) {\n return <Component {...dividerProps} />;\n }\n return <div {...dividerProps} />;\n};\n","/**\n * @file Hook for retrieving draggable handle props for the current layer.\n */\nimport * as React from \"react\";\nimport { useGridLayoutContext, type GridLayerHandleProps } from \"./GridLayoutContext\";\nimport { useLayerInstance } from \"./LayerInstanceContext\";\n\nexport const useLayerDragHandle = (): GridLayerHandleProps => {\n const { layerId } = useLayerInstance();\n const { getLayerHandleProps } = useGridLayoutContext();\n\n return React.useMemo(() => {\n return getLayerHandleProps(layerId);\n }, [getLayerHandleProps, layerId]);\n};\n\n","/**\n * @file Hook for managing floating window state (controlled/uncontrolled)\n * Pattern based on useDrawerState.ts\n */\nimport * as React from \"react\";\nimport type { LayerDefinition, WindowPosition, WindowSize } from \"../../types\";\n\ntype FloatingState = {\n position: WindowPosition;\n size: WindowSize;\n};\n\nconst DEFAULT_POSITION: WindowPosition = { left: 0, top: 0 };\nconst DEFAULT_SIZE: WindowSize = { width: 400, height: 300 };\n\nexport const useFloatingState = (layers: LayerDefinition[]) => {\n const [floatingStates, setFloatingStates] = React.useState<Record<string, FloatingState>>(() => {\n const initial: Record<string, FloatingState> = {};\n layers.forEach((layer) => {\n if (layer.floating) {\n const floating = layer.floating;\n initial[layer.id] = {\n position: floating.defaultPosition ?? DEFAULT_POSITION,\n size: floating.defaultSize ?? DEFAULT_SIZE,\n };\n }\n });\n return initial;\n });\n\n const layerMap = React.useMemo(() => {\n const map = new Map<string, LayerDefinition>();\n layers.forEach((layer) => map.set(layer.id, layer));\n return map;\n }, [layers]);\n\n const getPosition = React.useCallback(\n (layerId: string): WindowPosition => {\n const layer = layerMap.get(layerId);\n // Controlled mode: use position prop directly\n if (layer?.floating?.position !== undefined) {\n return layer.floating.position;\n }\n // Uncontrolled mode: use internal state\n return floatingStates[layerId]?.position ?? DEFAULT_POSITION;\n },\n [layerMap, floatingStates],\n );\n\n const getSize = React.useCallback(\n (layerId: string): WindowSize => {\n const layer = layerMap.get(layerId);\n // Controlled mode: use size prop directly\n if (layer?.floating?.size !== undefined) {\n return layer.floating.size;\n }\n // Uncontrolled mode: use internal state\n return floatingStates[layerId]?.size ?? DEFAULT_SIZE;\n },\n [layerMap, floatingStates],\n );\n\n const getZIndex = React.useCallback(\n (layerId: string): number | undefined => {\n const layer = layerMap.get(layerId);\n return layer?.floating?.zIndex;\n },\n [layerMap],\n );\n\n const updatePosition = React.useCallback(\n (layerId: string, position: WindowPosition) => {\n const layer = layerMap.get(layerId);\n if (!layer?.floating) {\n return;\n }\n\n // Update internal state only if uncontrolled\n if (layer.floating.position === undefined) {\n setFloatingStates((prev) => {\n const currentState = prev[layerId];\n if (!currentState) {\n return prev;\n }\n return {\n ...prev,\n [layerId]: { ...currentState, position },\n };\n });\n }\n\n // Always call callback\n layer.floating.onMove?.(position);\n },\n [layerMap],\n );\n\n const updateSize = React.useCallback(\n (layerId: string, size: WindowSize) => {\n const layer = layerMap.get(layerId);\n if (!layer?.floating) {\n return;\n }\n\n // Update internal state only if uncontrolled\n if (layer.floating.size === undefined) {\n setFloatingStates((prev) => {\n const currentState = prev[layerId];\n if (!currentState) {\n return prev;\n }\n return {\n ...prev,\n [layerId]: { ...currentState, size },\n };\n });\n }\n\n // Always call callback\n layer.floating.onResize?.(size);\n },\n [layerMap],\n );\n\n const close = React.useCallback(\n (layerId: string) => {\n const layer = layerMap.get(layerId);\n layer?.floating?.onClose?.();\n },\n [layerMap],\n );\n\n return {\n getPosition,\n getSize,\n getZIndex,\n updatePosition,\n updateSize,\n close,\n };\n};\n","/**\n * @file Central keybindings provider for PanelSystem.\n * Belongs to modules: distributes a single source of keybindings to UI.\n */\nimport * as React from \"react\";\nimport type { PanelCommands } from \"../panels/state/types\";\n\nexport type KeyCombo = string; // e.g., \"Mod-Shift-\\\\\", \"Mod-1\"\n\nexport type KeybindingsMap = Record<KeyCombo, (e: KeyboardEvent) => void>;\n\nexport type KeybindingsContextValue = {\n register: (combo: KeyCombo, handler: (e: KeyboardEvent) => void) => void;\n unregister: (combo: KeyCombo) => void;\n};\n\nconst KeybindingsContext = React.createContext<KeybindingsContextValue | null>(null);\n\nexport const useKeybindings = (): KeybindingsContextValue => {\n const ctx = React.useContext(KeybindingsContext);\n if (!ctx) {\n throw new Error(\"useKeybindings must be used within KeybindingsProvider\");\n }\n return ctx;\n};\n\nconst normalizeEventToCombo = (e: KeyboardEvent): KeyCombo => {\n const parts: string[] = [];\n if (e.metaKey) {\n parts.push(\"Mod\");\n }\n if (e.ctrlKey) {\n parts.push(\"Ctrl\");\n }\n if (e.altKey) {\n parts.push(\"Alt\");\n }\n if (e.shiftKey) {\n parts.push(\"Shift\");\n }\n const key = e.key.length === 1 ? e.key.toUpperCase() : e.key;\n parts.push(key);\n return parts.join(\"-\");\n};\n\nexport const KeybindingsProvider: React.FC<React.PropsWithChildren<{ configure?: (api: KeybindingsContextValue) => void }>> = ({ children, configure }) => {\n const handlersRef = React.useRef<KeybindingsMap>({});\n\n const register = React.useCallback((combo: KeyCombo, handler: (e: KeyboardEvent) => void): void => {\n handlersRef.current = { ...handlersRef.current, [combo]: handler };\n }, []);\n\n const unregister = React.useCallback((combo: KeyCombo): void => {\n const rest = { ...handlersRef.current };\n delete (rest as Record<string, unknown>)[combo];\n handlersRef.current = rest;\n }, []);\n\n React.useEffect(() => {\n const onKeyDown = (e: KeyboardEvent): void => {\n const combo = normalizeEventToCombo(e);\n const handler = handlersRef.current[combo];\n if (!handler) {\n return;\n }\n handler(e);\n };\n window.addEventListener(\"keydown\", onKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", onKeyDown);\n };\n }, []);\n\n const api: KeybindingsContextValue = React.useMemo(() => ({ register, unregister }), [register, unregister]);\n\n React.useEffect(() => {\n if (!configure) {\n return;\n }\n configure(api);\n }, [api, configure]);\n\n return <KeybindingsContext.Provider value={api}>{children}</KeybindingsContext.Provider>;\n};\n\nexport const registerDefaultBindings = (api: KeybindingsContextValue, commands: PanelCommands): void => {\n api.register(\"Mod-\\\\\", (e) => {\n e.preventDefault();\n commands.splitFocused(\"vertical\");\n });\n api.register(\"Mod-Shift-\\\\\", (e) => {\n e.preventDefault();\n commands.splitFocused(\"horizontal\");\n });\n\n for (const n of [1, 2, 3, 4, 5, 6, 7, 8, 9]) {\n api.register(`Mod-${String(n)}`, (e) => {\n e.preventDefault();\n commands.focusGroupIndex(n);\n });\n }\n\n api.register(\"Alt-ArrowRight\", (e) => {\n e.preventDefault();\n commands.focusNextGroup();\n });\n api.register(\"Alt-ArrowLeft\", (e) => {\n e.preventDefault();\n commands.focusPrevGroup();\n });\n};\n","/**\n * @file Adapters bridging panel-system model to existing GridLayout definitions.\n * Strategy: Use a 1x1 relative grid and place groups as absolute layers using computed rects.\n */\nimport type { LayerDefinition, PanelLayoutConfig } from \"../../../types\";\nimport type { GroupId, PanelSystemState, PanelTree } from \"../state/types\";\n\nexport type Rect = { x: number; y: number; w: number; h: number };\n\nconst isGroup = (node: PanelTree): node is Extract<PanelTree, { type: \"group\" }> => {\n return (node as { type: string }).type === \"group\";\n};\n\nexport const computeRects = (node: PanelTree, bounds: Rect = { x: 0, y: 0, w: 100, h: 100 }): Map<GroupId, Rect> => {\n const result = new Map<GroupId, Rect>();\n const walk = (n: PanelTree, rect: Rect): void => {\n if (isGroup(n)) {\n result.set(n.groupId, rect);\n return;\n }\n if (n.direction === \"vertical\") {\n const wA = rect.w * n.ratio;\n const wB = rect.w - wA;\n walk(n.a, { x: rect.x, y: rect.y, w: wA, h: rect.h });\n walk(n.b, { x: rect.x + wA, y: rect.y, w: wB, h: rect.h });\n return;\n }\n const hA = rect.h * n.ratio;\n const hB = rect.h - hA;\n walk(n.a, { x: rect.x, y: rect.y, w: rect.w, h: hA });\n walk(n.b, { x: rect.x, y: rect.y + hA, w: rect.w, h: hB });\n };\n walk(node, bounds);\n return result;\n};\n\nexport const buildGridForAbsolutePanels = (\n state: PanelSystemState,\n renderGroup: (groupId: GroupId) => React.ReactNode,\n): { config: PanelLayoutConfig; layers: LayerDefinition[] } => {\n const rects = computeRects(state.tree);\n\n const config: PanelLayoutConfig = {\n areas: [[\"root\"]],\n rows: [{ size: \"1fr\" }],\n columns: [{ size: \"1fr\" }],\n gap: \"0px\",\n style: { position: \"relative\" },\n };\n\n const layers: LayerDefinition[] = Array.from(rects.entries()).map(([groupId, r]) => {\n const style: React.CSSProperties = {\n position: \"absolute\",\n left: `${r.x}%`,\n top: `${r.y}%`,\n width: `${r.w}%`,\n height: `${r.h}%`,\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n };\n return {\n id: groupId,\n positionMode: \"absolute\",\n style,\n component: renderGroup(groupId),\n } satisfies LayerDefinition;\n });\n\n return { config, layers };\n};\n\nexport const buildGridFromRects = (\n state: PanelSystemState,\n renderGroup: (groupId: GroupId) => React.ReactNode,\n interactiveTracks: boolean,\n): { config: PanelLayoutConfig; layers: LayerDefinition[] } => {\n const rects = computeRects(state.tree);\n\n const xs = Array.from(new Set(Array.from(rects.values()).flatMap((r) => [r.x, r.x + r.w]))).sort((a, b) => a - b);\n const ys = Array.from(new Set(Array.from(rects.values()).flatMap((r) => [r.y, r.y + r.h]))).sort((a, b) => a - b);\n\n const colSizes = xs.slice(1).map((x, i) => `${x - xs[i]}fr`);\n const rowSizes = ys.slice(1).map((y, i) => `${y - ys[i]}fr`);\n\n const columns = colSizes.map((size) => ({ size, resizable: interactiveTracks }));\n const rows = rowSizes.map((size) => ({ size, resizable: interactiveTracks }));\n\n const areaForCell = (x0: number, x1: number, y0: number, y1: number): string => {\n for (const [gid, r] of rects.entries()) {\n const within = x0 >= r.x && x1 <= r.x + r.w && y0 >= r.y && y1 <= r.y + r.h;\n if (within) {\n return gid;\n }\n }\n return \".\";\n };\n\n const areas: string[][] = [];\n for (let ri = 0; ri < ys.length - 1; ri += 1) {\n const row: string[] = [];\n for (let ci = 0; ci < xs.length - 1; ci += 1) {\n row.push(areaForCell(xs[ci], xs[ci + 1], ys[ri], ys[ri + 1]));\n }\n areas.push(row);\n }\n\n const config: PanelLayoutConfig = {\n areas,\n rows,\n columns,\n gap: \"0px\",\n } as PanelLayoutConfig;\n\n const layers: LayerDefinition[] = Array.from(rects.keys()).map((groupId) => {\n return {\n id: groupId,\n gridArea: groupId,\n component: renderGroup(groupId),\n };\n });\n\n return { config, layers };\n};\n","/**\n * @file Panel render context providing per-group accessors and actions.\n */\nimport * as React from \"react\";\nimport type { GroupId, GroupModel, PanelId } from \"../state/types\";\n\nexport type PanelRenderContextValue = {\n getGroup: (id: GroupId) => GroupModel | null;\n getGroupContent: (id: GroupId) => React.ReactNode;\n onClickTab: (groupId: GroupId, tabId: PanelId) => void;\n onAddTab?: (groupId: GroupId) => void;\n onCloseTab?: (groupId: GroupId, tabId: PanelId) => void;\n onStartTabDrag: (tabId: PanelId, groupId: GroupId, e: React.PointerEvent) => void;\n onStartContentDrag: (groupId: GroupId, e: React.PointerEvent<HTMLDivElement>) => void;\n doubleClickToAdd?: boolean;\n registerContentContainer: (groupId: GroupId, element: HTMLElement | null) => void;\n};\n\nconst PanelRenderContext = React.createContext<PanelRenderContextValue | null>(null);\n\nexport const usePanelRenderContext = (): PanelRenderContextValue => {\n const ctx = React.useContext(PanelRenderContext);\n if (!ctx) {\n throw new Error(\"usePanelRenderContext must be used within PanelRenderProvider\");\n }\n return ctx;\n};\n\nexport const PanelRenderProvider: React.FC<React.PropsWithChildren<{ value: PanelRenderContextValue }>> = ({ value, children }) => {\n return <PanelRenderContext.Provider value={value}>{children}</PanelRenderContext.Provider>;\n};\n","/**\n * @file DOM registry for panel-system. React-first: components register their own refs\n * instead of global querySelectorAll scans.\n */\nimport * as React from \"react\";\nimport type { GroupId } from \"../state/types\";\n\nexport type RegisteredEls = {\n group: HTMLElement | null;\n tabbar: HTMLElement | null;\n content: HTMLElement | null;\n};\n\nexport type DomRegistryContextValue = {\n setGroupEl: (groupId: GroupId, el: HTMLElement | null) => void;\n setTabbarEl: (groupId: GroupId, el: HTMLElement | null) => void;\n setContentEl: (groupId: GroupId, el: HTMLElement | null) => void;\n getAll: () => Map<GroupId, RegisteredEls>;\n};\n\nconst DomRegistryContext = React.createContext<DomRegistryContextValue | null>(null);\n\nexport const useDomRegistry = (): DomRegistryContextValue => {\n const ctx = React.useContext(DomRegistryContext);\n if (!ctx) {\n throw new Error(\"useDomRegistry must be used within DomRegistryProvider\");\n }\n return ctx;\n};\n\nexport const DomRegistryProvider: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {\n const mapRef = React.useRef<Map<GroupId, RegisteredEls>>(new Map());\n\n const ensure = React.useCallback((groupId: GroupId): RegisteredEls => {\n const current = mapRef.current.get(groupId);\n if (current) {\n return current;\n }\n const next: RegisteredEls = { group: null, tabbar: null, content: null };\n mapRef.current.set(groupId, next);\n return next;\n }, []);\n\n const setGroupEl = React.useCallback(\n (groupId: GroupId, el: HTMLElement | null) => {\n const r = ensure(groupId);\n r.group = el;\n if (el === null) {\n const v = mapRef.current.get(groupId);\n const noOthers = v ? v.tabbar === null && v.content === null : false;\n if (noOthers) {\n mapRef.current.delete(groupId);\n }\n }\n },\n [ensure],\n );\n\n const setTabbarEl = React.useCallback(\n (groupId: GroupId, el: HTMLElement | null) => {\n const r = ensure(groupId);\n r.tabbar = el;\n if (el === null) {\n const v = mapRef.current.get(groupId);\n const noOthers = v ? v.group === null && v.content === null : false;\n if (noOthers) {\n mapRef.current.delete(groupId);\n }\n }\n },\n [ensure],\n );\n\n const setContentEl = React.useCallback(\n (groupId: GroupId, el: HTMLElement | null) => {\n const r = ensure(groupId);\n r.content = el;\n if (el === null) {\n const v = mapRef.current.get(groupId);\n const noOthers = v ? v.group === null && v.tabbar === null : false;\n if (noOthers) {\n mapRef.current.delete(groupId);\n }\n }\n },\n [ensure],\n );\n\n const getAll = React.useCallback(() => mapRef.current, []);\n\n const value = React.useMemo<DomRegistryContextValue>(() => ({ setGroupEl, setTabbarEl, setContentEl, getAll }), [setGroupEl, setTabbarEl, setContentEl, getAll]);\n\n return <DomRegistryContext.Provider value={value}>{children}</DomRegistryContext.Provider>;\n};\n","/**\n * @file Group view rendering for PanelSystem (tabbar + active content).\n */\nimport * as React from \"react\";\nimport type { PanelGroupRenderProps } from \"../../modules/panels/state/types\";\n\nexport type PanelGroupViewProps = PanelGroupRenderProps & {\n /** Custom component for the group container */\n component?: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }>;\n /** Custom element for the group container */\n element?: React.ReactElement;\n /** Custom component for the content container */\n contentComponent?: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }>;\n /** Custom element for the content container */\n contentElement?: React.ReactElement;\n};\n\nconst groupStyle: React.CSSProperties = {\n display: \"flex\",\n flexDirection: \"column\",\n width: \"100%\",\n height: \"100%\",\n};\n\nconst contentStyle: React.CSSProperties = {\n flex: \"1 1 auto\",\n minWidth: 0,\n minHeight: 0,\n position: \"relative\",\n overflow: \"hidden\",\n};\n\nfunction createContentNode(\n contentElement: React.ReactElement | undefined,\n ContentComponent: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }> | undefined,\n contentProps: React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> },\n content: React.ReactNode\n): React.ReactNode {\n if (contentElement) {\n return React.cloneElement(contentElement, contentProps, content);\n }\n if (ContentComponent) {\n return <ContentComponent {...contentProps}>{content}</ContentComponent>;\n }\n return <div {...contentProps}>{content}</div>;\n}\n\nfunction createGroupNode(\n element: React.ReactElement | undefined,\n GroupComponent: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }> | undefined,\n groupProps: React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> },\n groupContent: React.ReactNode\n): React.ReactNode {\n if (element) {\n return React.cloneElement(element, groupProps, groupContent);\n }\n if (GroupComponent) {\n return <GroupComponent {...groupProps}>{groupContent}</GroupComponent>;\n }\n return <div {...groupProps}>{groupContent}</div>;\n}\n\nconst RawPanelGroupView: React.FC<PanelGroupViewProps> = ({\n group,\n tabbar,\n content,\n onContentPointerDown,\n groupRef,\n contentRef,\n component: GroupComponent,\n element,\n contentComponent: ContentComponent,\n contentElement\n}) => {\n const groupProps = {\n ref: groupRef,\n style: groupStyle,\n \"data-group-id\": group.id,\n };\n\n const contentProps = {\n ref: contentRef,\n style: contentStyle,\n \"data-dnd-zone\": \"content\",\n onPointerDown: onContentPointerDown,\n };\n\n const contentNode = createContentNode(contentElement, ContentComponent, contentProps, content);\n\n const groupContent = (\n <>\n {tabbar}\n {contentNode}\n </>\n );\n\n return createGroupNode(element, GroupComponent, groupProps, groupContent);\n};\n\nexport const PanelGroupView = React.memo(RawPanelGroupView, (prev, next) => {\n if (prev.group.id !== next.group.id) {\n return false;\n }\n if (prev.group.activeTabId !== next.group.activeTabId) {\n return false;\n }\n if (prev.group.tabs.length !== next.group.tabs.length) {\n return false;\n }\n return prev.group.tabs === next.group.tabs;\n});\nPanelGroupView.displayName = \"PanelGroupView\";\n","/**\n * @file DnD utilities for panel interactions\n */\nimport type { DropZone } from \"../state/types\";\n\nexport const pickDropZone = (rect: DOMRectReadOnly, x: number, y: number): DropZone => {\n const left = rect.left;\n const top = rect.top;\n const width = rect.width;\n const height = rect.height;\n const localX = x - left;\n const localY = y - top;\n const thirdW = width / 3;\n const thirdH = height / 3;\n if (localX > thirdW && localX < width - thirdW && localY > thirdH && localY < height - thirdH) {\n return \"center\";\n }\n if (localX < localY && localX < width - localX && localY < height - localY) {\n return \"left\";\n }\n if (width - localX < localY && width - localX < localX && localY < height - localY) {\n return \"right\";\n }\n if (localY < localX && localY < height - localY && localX < width - localX) {\n return \"top\";\n }\n return \"bottom\";\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any -- Generic action helpers rely on 'any' to avoid over-constraining payload creators */\n/**\n * @file Utilities for defining typed action creators and reducer handler maps without external dependencies.\n */\n\nexport type AnyAction = { type: string };\n\nexport type AnyActionCreator = {\n (...args: any[]): AnyAction;\n readonly type: string;\n};\n\ntype PayloadCreator = (...args: any[]) => any;\n\ntype ActionFromPayload<Type extends string, Creator extends PayloadCreator> =\n ReturnType<Creator> extends undefined | void\n ? { type: Type }\n : { type: Type; payload: Exclude<ReturnType<Creator>, undefined> };\n\n/**\n * Creates a typed action creator with an attached literal `type` property.\n */\nexport function createAction<Type extends string>(type: Type): (() => { type: Type }) & { readonly type: Type };\nexport function createAction<Type extends string, Creator extends PayloadCreator>(\n type: Type,\n payloadCreator: Creator,\n): ((...args: Parameters<Creator>) => ActionFromPayload<Type, Creator>) & { readonly type: Type };\nexport function createAction<Type extends string, Creator extends PayloadCreator>(\n type: Type,\n payloadCreator?: Creator,\n) {\n if (!payloadCreator) {\n const actionCreator = (() => ({ type }) as const) as (() => { type: Type }) & { readonly type: Type };\n Object.defineProperty(actionCreator, \"type\", {\n value: type,\n writable: false,\n enumerable: true,\n });\n return actionCreator;\n }\n const actionCreator = ((...args: Parameters<Creator>) => {\n const payload = payloadCreator(...args);\n if (typeof payload === \"undefined\") {\n return { type } as const;\n }\n return { type, payload } as const;\n }) as ((...args: Parameters<Creator>) => ActionFromPayload<Type, Creator>) & { readonly type: Type };\n Object.defineProperty(actionCreator, \"type\", {\n value: type,\n writable: false,\n enumerable: true,\n });\n return actionCreator;\n}\n\nexport type ActionCreatorsMap = Record<string, AnyActionCreator>;\n\nexport type ActionUnion<Creators extends ActionCreatorsMap> = ReturnType<Creators[keyof Creators]>;\n\nexport type CaseReducer<State, Action extends AnyAction, Extra> = (state: State, action: Action, extra: Extra) => State;\n\nexport type BoundActionCreators<Creators extends ActionCreatorsMap> = {\n [Key in keyof Creators]: (...args: Parameters<Creators[Key]>) => ReturnType<Creators[Key]>;\n};\n\nexport const bindActionCreators = <Creators extends ActionCreatorsMap>(\n creators: Creators,\n dispatch: (action: ActionUnion<Creators>) => unknown,\n): BoundActionCreators<Creators> => {\n const bound = {} as BoundActionCreators<Creators>;\n (Object.keys(creators) as Array<keyof Creators>).forEach((key) => {\n const creator = creators[key];\n bound[key] = ((...args: Parameters<typeof creator>) => {\n const action = creator(...args);\n dispatch(action as ActionUnion<Creators>);\n return action;\n }) as BoundActionCreators<Creators>[keyof Creators];\n });\n return bound;\n};\n\nexport const createActionHandlerMap = <State, Creators extends ActionCreatorsMap, Extra = undefined>(\n creators: Creators,\n handlers: {\n [Key in keyof Creators]?: CaseReducer<State, ReturnType<Creators[Key]>, Extra>;\n },\n): Record<string, CaseReducer<State, ReturnType<Creators[keyof Creators]>, Extra>> => {\n const map: Record<string, CaseReducer<State, ReturnType<Creators[keyof Creators]>, Extra>> = {};\n\n (Object.keys(handlers) as Array<keyof Creators>).forEach((key) => {\n const handler = handlers[key];\n if (!handler) {\n return;\n }\n const creator = creators[key];\n if (!creator) {\n throw new Error(`Missing action creator for key \"${String(key)}\"`);\n }\n map[creator.type] = handler as CaseReducer<State, ReturnType<Creators[keyof Creators]>, Extra>;\n });\n\n return map;\n};\n","/**\n * @file Centralized panel interactions (DnD) using Context + reducer.\n * Handles content (panel area) split/move and tabbar reordering/cross-move.\n */\nimport * as React from \"react\";\nimport type { DropZone, GroupId, PanelId } from \"../state/types\";\nimport { pickDropZone } from \"./dnd\";\nimport { useDomRegistry } from \"../dom/DomRegistry\";\nimport { createAction, createActionHandlerMap } from \"../../../utils/typedActions\";\nimport { useEffectEvent } from \"../../../hooks/useEffectEvent\";\n\nexport type SuggestInfo = { rect: DOMRectReadOnly; zone: DropZone } | null;\n\n// Cached layout data for drag operations\ntype LayoutCache = {\n groups: Array<{ gid: GroupId; el: HTMLElement; rect: DOMRect }>;\n tabbars: Array<{ gid: GroupId; el: HTMLElement; rect: DOMRect }>;\n contents: Array<{ gid: GroupId; el: HTMLElement; rect: DOMRect }>;\n};\n\ntype Phase =\n | { kind: \"idle\" }\n | {\n kind: \"content\";\n startX: number;\n startY: number;\n fromGroupId: GroupId;\n tabId: PanelId;\n cache: LayoutCache;\n }\n | {\n kind: \"tab\";\n startX: number;\n startY: number;\n fromGroupId: GroupId;\n tabId: PanelId;\n cache: LayoutCache;\n };\n\ntype State = {\n phase: Phase;\n suggest: SuggestInfo;\n pointer: { x: number; y: number } | null;\n tabbarHover: { groupId: GroupId; index: number; rect: DOMRectReadOnly; insertX: number } | null;\n draggingTabElement: HTMLElement | null;\n};\n\nconst initialState: State = { phase: { kind: \"idle\" }, suggest: null, pointer: null, tabbarHover: null, draggingTabElement: null };\n\nconst actions = {\n startContent: createAction(\n \"START_CONTENT\",\n (payload: { x: number; y: number; groupId: GroupId; tabId: PanelId; cache: LayoutCache }) => payload,\n ),\n startTab: createAction(\n \"START_TAB\",\n (payload: { x: number; y: number; groupId: GroupId; tabId: PanelId; cache: LayoutCache; element: HTMLElement | null }) => payload,\n ),\n setSuggest: createAction(\"SET_SUGGEST\", (payload: SuggestInfo) => payload),\n setPointer: createAction(\"SET_POINTER\", (payload: { x: number; y: number } | null) => payload),\n setTabbarHover: createAction(\n \"SET_TABBAR_HOVER\",\n (payload: { groupId: GroupId; index: number; rect: DOMRectReadOnly; insertX: number } | null) => payload,\n ),\n reset: createAction(\"RESET\"),\n} as const;\n\nconst reducerHandlers = createActionHandlerMap<State, typeof actions, void>(actions, {\n startContent: (_state, action) => ({\n phase: {\n kind: \"content\",\n startX: action.payload.x,\n startY: action.payload.y,\n fromGroupId: action.payload.groupId,\n tabId: action.payload.tabId,\n cache: action.payload.cache,\n },\n suggest: null,\n pointer: null,\n tabbarHover: null,\n draggingTabElement: null,\n }),\n startTab: (_state, action) => ({\n phase: {\n kind: \"tab\",\n startX: action.payload.x,\n startY: action.payload.y,\n fromGroupId: action.payload.groupId,\n tabId: action.payload.tabId,\n cache: action.payload.cache,\n },\n suggest: null,\n pointer: null,\n tabbarHover: null,\n draggingTabElement: action.payload.element,\n }),\n setSuggest: (state, action) => ({ ...state, suggest: action.payload }),\n setPointer: (state, action) => ({ ...state, pointer: action.payload }),\n setTabbarHover: (state, action) => ({ ...state, tabbarHover: action.payload }),\n reset: () => initialState,\n});\n\ntype ReducerAction = ReturnType<(typeof actions)[keyof typeof actions]>;\n\nconst reducer = (state: State, action: ReducerAction): State => {\n const handler = reducerHandlers[action.type];\n if (!handler) {\n return state;\n }\n return handler(state, action, undefined);\n};\n\nexport type InteractionsContextValue = {\n suggest: SuggestInfo;\n onStartContentDrag: (groupId: GroupId, tabId: PanelId, e: React.PointerEvent<HTMLDivElement>) => void;\n onStartTabDrag: (tabId: PanelId, groupId: GroupId, e: React.PointerEvent) => void;\n isTabDragging: boolean;\n draggingTabId: PanelId | null;\n dragPointer: { x: number; y: number } | null;\n tabbarHover: { groupId: GroupId; index: number; rect: DOMRectReadOnly; insertX: number } | null;\n draggingTabElement: HTMLElement | null;\n};\n\nconst InteractionsContext = React.createContext<InteractionsContextValue | null>(null);\n\nexport const usePanelInteractions = (): InteractionsContextValue => {\n const ctx = React.useContext(InteractionsContext);\n if (!ctx) {\n throw new Error(\"usePanelInteractions must be used within InteractionsProvider\");\n }\n return ctx;\n};\n\nexport type InteractionsProviderProps = React.PropsWithChildren<{\n containerRef: React.RefObject<HTMLDivElement | null>;\n dragThresholdPx: number;\n onCommitContentDrop: (payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; zone: DropZone }) => void;\n onCommitTabDrop: (payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; targetIndex: number }) => void;\n isContentZoneAllowed?: (payload: { targetGroupId: GroupId; zone: DropZone }) => boolean;\n}>;\n\nexport const InteractionsProvider: React.FC<InteractionsProviderProps> = ({\n containerRef,\n dragThresholdPx,\n onCommitContentDrop,\n onCommitTabDrop,\n isContentZoneAllowed,\n children,\n}) => {\n const [state, dispatch] = React.useReducer(reducer, initialState);\n const dom = useDomRegistry();\n\n // Helper to capture current layout state\n const captureLayout = React.useCallback((): LayoutCache => {\n const all = Array.from(dom.getAll().entries());\n\n const groups = all\n .map(([gid, els]) => ({ gid, el: els.content ?? els.group }))\n .filter((it): it is { gid: GroupId; el: HTMLElement } => Boolean(it.el))\n .map((it) => ({ ...it, rect: it.el.getBoundingClientRect() }));\n\n const tabbars = all\n .map(([gid, els]) => ({ gid, el: els.tabbar }))\n .filter((it): it is { gid: GroupId; el: HTMLElement } => Boolean(it.el))\n .map((it) => ({ ...it, rect: it.el.getBoundingClientRect() }));\n\n const contents = all\n .map(([gid, els]) => ({ gid, el: els.content ?? els.group }))\n .filter((it): it is { gid: GroupId; el: HTMLElement } => Boolean(it.el))\n .map((it) => ({ ...it, rect: it.el.getBoundingClientRect() }));\n\n return { groups, tabbars, contents };\n }, [dom]);\n\n const onMove = useEffectEvent((ev: PointerEvent) => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n const x = ev.clientX;\n const y = ev.clientY;\n const phase = state.phase;\n if (phase.kind === \"idle\") {\n return;\n }\n const dx = Math.abs(x - phase.startX);\n const dy = Math.abs(y - phase.startY);\n if (dx < dragThresholdPx && dy < dragThresholdPx) {\n if (state.phase.kind === \"content\") {\n dispatch(actions.setSuggest(null));\n }\n dispatch(actions.setPointer(null));\n dispatch(actions.setTabbarHover(null));\n return;\n }\n dispatch(actions.setPointer({ x, y }));\n\n if (phase.kind === \"content\") {\n // Use cached groups\n const candidate = phase.cache.groups\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (!candidate) {\n dispatch(actions.setSuggest(null));\n return;\n }\n const zone = pickDropZone(candidate.rect, x, y);\n if (isContentZoneAllowed && !isContentZoneAllowed({ targetGroupId: candidate.gid, zone })) {\n dispatch(actions.setSuggest(null));\n return;\n }\n dispatch(actions.setSuggest({ rect: candidate.rect, zone }));\n return;\n }\n\n if (phase.kind === \"tab\") {\n // Use cached tabbars\n const tabbarHit = phase.cache.tabbars\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (tabbarHit) {\n // We still need to query buttons for exact insertion index, but we can optimize this too if needed.\n // For now, querying buttons inside the hit tabbar is acceptable as it's much smaller scope than global.\n // Optimization: We could cache button rects too, but they might change if tabs reorder during drag (if we implemented live reorder).\n // Assuming no live reorder for now as per original code.\n const tabButtons = Array.from(tabbarHit.el.querySelectorAll<HTMLButtonElement>(\"[role='tab']\"));\n const btnRects = tabButtons.map((b) => b.getBoundingClientRect());\n const centers = btnRects.map((r) => r.left + r.width / 2);\n const firstIdx = centers.findIndex((c) => x < c);\n const targetIndex = firstIdx === -1 ? centers.length : firstIdx;\n\n const computeInsertX = (): number => {\n if (btnRects.length === 0) {\n return tabbarHit.rect.left + 8;\n }\n if (targetIndex === 0) {\n return btnRects[0].left;\n }\n if (targetIndex === btnRects.length) {\n return btnRects[btnRects.length - 1].right;\n }\n return (btnRects[targetIndex - 1].right + btnRects[targetIndex].left) / 2;\n };\n const insertX = computeInsertX();\n dispatch(actions.setTabbarHover({ groupId: tabbarHit.gid, index: targetIndex, rect: tabbarHit.rect, insertX }));\n } else {\n dispatch(actions.setTabbarHover(null));\n }\n\n // Use cached contents for split/move\n const candidate = phase.cache.contents\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (!candidate) {\n dispatch(actions.setSuggest(null));\n return;\n }\n const zone = pickDropZone(candidate.rect, x, y);\n if (isContentZoneAllowed && !isContentZoneAllowed({ targetGroupId: candidate.gid, zone })) {\n dispatch(actions.setSuggest(null));\n return;\n }\n dispatch(actions.setSuggest({ rect: candidate.rect, zone }));\n }\n });\n\n const onUp = useEffectEvent((ev: PointerEvent) => {\n const container = containerRef.current;\n const snapshot = state;\n dispatch(actions.reset());\n if (!container) {\n return;\n }\n const x = ev.clientX;\n const y = ev.clientY;\n if (snapshot.phase.kind === \"idle\") {\n return;\n }\n const dx = Math.abs(x - snapshot.phase.startX);\n const dy = Math.abs(y - snapshot.phase.startY);\n if (dx < dragThresholdPx && dy < dragThresholdPx) {\n return;\n }\n\n if (snapshot.phase.kind === \"content\") {\n const hit = snapshot.phase.cache.groups\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (!hit) {\n return;\n }\n const targetGroupId = hit.gid ?? null;\n if (!targetGroupId) {\n return;\n }\n const zone = pickDropZone(hit.rect, x, y);\n if (isContentZoneAllowed && !isContentZoneAllowed({ targetGroupId: targetGroupId, zone })) {\n return;\n }\n onCommitContentDrop({ fromGroupId: snapshot.phase.fromGroupId, tabId: snapshot.phase.tabId, targetGroupId, zone });\n return;\n }\n\n if (snapshot.phase.kind === \"tab\") {\n const tabbarHit = snapshot.phase.cache.tabbars\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (tabbarHit) {\n const targetGroupId = tabbarHit.gid;\n if (!targetGroupId) {\n return;\n }\n const tabButtons = Array.from(tabbarHit.el.querySelectorAll<HTMLButtonElement>(\"[role='tab']\"));\n const centers = tabButtons.map((btn) => {\n const r = btn.getBoundingClientRect();\n return r.left + r.width / 2;\n });\n const firstIdx = centers.findIndex((c) => x < c);\n const targetIndex = firstIdx === -1 ? centers.length : firstIdx;\n onCommitTabDrop({ fromGroupId: snapshot.phase.fromGroupId, tabId: snapshot.phase.tabId, targetGroupId, targetIndex });\n return;\n }\n\n const contentHit = snapshot.phase.cache.contents\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (contentHit) {\n const targetGroupId = contentHit.gid ?? null;\n if (!targetGroupId) {\n return;\n }\n const zone = pickDropZone(contentHit.rect, x, y);\n if (isContentZoneAllowed && !isContentZoneAllowed({ targetGroupId, zone })) {\n return;\n }\n onCommitContentDrop({ fromGroupId: snapshot.phase.fromGroupId, tabId: snapshot.phase.tabId, targetGroupId, zone });\n }\n }\n });\n\n const onCancel = useEffectEvent(() => {\n dispatch(actions.reset());\n });\n\n React.useEffect(() => {\n if (state.phase.kind === \"idle\") {\n return;\n }\n\n window.addEventListener(\"pointermove\", onMove);\n window.addEventListener(\"pointerup\", onUp, { once: true });\n window.addEventListener(\"pointercancel\", onCancel, { once: true });\n\n return () => {\n window.removeEventListener(\"pointermove\", onMove);\n window.removeEventListener(\"pointerup\", onUp);\n window.removeEventListener(\"pointercancel\", onCancel);\n };\n }, [state.phase.kind]);\n\n const onStartContentDrag = React.useCallback((groupId: GroupId, tabId: PanelId, e: React.PointerEvent<HTMLDivElement>) => {\n if (e.button !== 0) {\n return;\n }\n e.currentTarget.setPointerCapture(e.pointerId);\n const cache = captureLayout();\n dispatch(actions.startContent({ x: e.clientX, y: e.clientY, groupId, tabId, cache }));\n }, [captureLayout]);\n\n const onStartTabDrag = React.useCallback((tabId: PanelId, groupId: GroupId, e: React.PointerEvent) => {\n if (e.button !== 0) {\n return;\n }\n const target = e.currentTarget as Element | null;\n if (target) {\n target.setPointerCapture(e.pointerId);\n }\n const cache = captureLayout();\n dispatch(actions.startTab({ x: e.clientX, y: e.clientY, groupId, tabId, cache, element: target as HTMLElement | null }));\n }, [captureLayout]);\n\n const value = React.useMemo<InteractionsContextValue>(() => ({\n suggest: state.suggest,\n isTabDragging: state.phase.kind === \"tab\",\n draggingTabId: state.phase.kind === \"tab\" ? state.phase.tabId : null,\n dragPointer: state.pointer,\n tabbarHover: state.tabbarHover,\n draggingTabElement: state.draggingTabElement,\n onStartContentDrag,\n onStartTabDrag,\n }), [state.suggest, state.pointer, state.tabbarHover, state.phase, state.draggingTabElement, onStartContentDrag, onStartTabDrag]);\n\n return <InteractionsContext.Provider value={value}>{children}</InteractionsContext.Provider>;\n};\n","/**\n * @file Tab button renderer for TabBar.\n */\nimport * as React from \"react\";\nimport type { TabBarProps } from \"./TabBar\";\n\ntype TabItem = TabBarProps[\"group\"][\"tabs\"][number];\n\ntype TabButtonProps = React.HTMLAttributes<HTMLDivElement> & {\n \"data-tab-id\": string;\n \"data-active\": \"true\" | \"false\";\n \"data-dragging\": \"true\" | \"false\";\n};\n\nexport type TabBarTabProps = {\n groupId: string;\n tab: TabItem;\n active: boolean;\n dragging: boolean;\n tabComponent?: TabBarProps[\"tabComponent\"];\n tabElement?: TabBarProps[\"tabElement\"];\n onClickTab: TabBarProps[\"onClickTab\"];\n onStartDrag: TabBarProps[\"onStartDrag\"];\n onCloseTab?: (groupId: string, tabId: string) => void;\n onDoubleClick?: (e: React.MouseEvent) => void;\n};\n\nconst tabStyle: React.CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n userSelect: \"none\",\n};\n\nexport const TabBarTab: React.FC<TabBarTabProps> = ({\n groupId,\n tab,\n active,\n dragging,\n onClickTab,\n onStartDrag,\n onCloseTab,\n tabComponent: TabComponent,\n tabElement,\n onDoubleClick,\n}) => {\n const handleClick = React.useEffectEvent(() => {\n onClickTab(tab.id);\n });\n\n const handlePointerDown = React.useEffectEvent((e: React.PointerEvent<HTMLDivElement>) => {\n if (!onStartDrag) {\n return;\n }\n if (e.button !== 0) {\n return;\n }\n onStartDrag(tab.id, groupId, e);\n });\n\n const renderCloseButton = (): React.ReactNode => {\n const hasClose = Boolean(onCloseTab);\n return (\n <React.Activity mode={hasClose ? \"visible\" : \"hidden\"}>\n <button\n type=\"button\"\n aria-label={`Close tab ${tab.title}`}\n onClick={(e) => {\n if (!onCloseTab) {\n return;\n }\n e.stopPropagation();\n onCloseTab(groupId, tab.id);\n }}\n style={{ marginLeft: 6 }}\n tabIndex={hasClose ? undefined : -1}\n disabled={!hasClose}\n aria-hidden={hasClose ? undefined : true}\n >\n ×\n </button>\n </React.Activity>\n );\n };\n\n const divProps: TabButtonProps = {\n role: \"tab\",\n \"aria-selected\": active,\n tabIndex: active ? 0 : -1,\n style: tabStyle,\n onClick: handleClick,\n onPointerDown: handlePointerDown,\n onDoubleClick,\n \"data-tab-id\": tab.id,\n \"data-active\": active ? \"true\" : \"false\",\n \"data-dragging\": dragging ? \"true\" : \"false\",\n children: (\n <>\n <span>{tab.title}</span>\n {renderCloseButton()}\n </>\n ),\n };\n\n const buttonProps: React.ButtonHTMLAttributes<HTMLButtonElement> = {\n type: \"button\",\n role: \"tab\",\n \"aria-selected\": active,\n tabIndex: active ? 0 : -1,\n style: tabStyle,\n onClick: () => {\n onClickTab(tab.id);\n },\n onPointerDown: (e: React.PointerEvent<HTMLButtonElement>) => {\n if (!onStartDrag) {\n return;\n }\n if (e.button !== 0) {\n return;\n }\n onStartDrag(tab.id, groupId, e);\n },\n onDoubleClick,\n children: <span>{tab.title}</span>,\n };\n\n if (tabElement) {\n return tabElement(buttonProps);\n }\n if (TabComponent) {\n return <TabComponent {...buttonProps} />;\n }\n return <div {...divProps} />;\n};\n","/**\n * @file Tab bar with drag handles (generic, not panel-specific).\n */\nimport * as React from \"react\";\nimport type { TabBarRenderProps } from \"../../modules/panels/state/types\";\nimport { usePanelInteractions } from \"../../modules/panels/interactions/InteractionsContext\";\nimport { useElementComponentWrapper } from \"../../hooks/useElementComponentWrapper\";\nimport { TabBarTab } from \"./TabBarTab\";\n\nexport type TabBarProps = TabBarRenderProps & {\n /** Custom component for the tabbar container */\n component?: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }>;\n /** Custom element for the tabbar container */\n element?: React.ReactElement<React.HTMLAttributes<HTMLDivElement>>;\n /** Custom component for individual tabs */\n tabComponent?: React.ComponentType<React.ButtonHTMLAttributes<HTMLButtonElement>>;\n /** Custom element factory for individual tabs */\n tabElement?: (props: React.ButtonHTMLAttributes<HTMLButtonElement>) => React.ReactElement;\n /** Request to add a new tab to this group */\n onAddTab?: (groupId: string) => void;\n /** Request to close/remove a tab */\n onCloseTab?: (groupId: string, tabId: string) => void;\n};\n\nconst tabbarStyle: React.CSSProperties = {\n display: \"flex\",\n alignItems: \"center\",\n};\n\nconst spacerStyle: React.CSSProperties = {\n flex: \"1 1 auto\",\n alignSelf: \"stretch\",\n};\n\nexport const TabBar: React.FC<TabBarProps> = ({\n group,\n onClickTab,\n onStartDrag,\n rootRef,\n component: ContainerComponent,\n element,\n tabComponent: TabComponent,\n tabElement,\n onAddTab,\n onCloseTab,\n doubleClickToAdd,\n}) => {\n const { isTabDragging, draggingTabId } = usePanelInteractions();\n const localRef = React.useRef<HTMLDivElement | null>(null);\n\n const setRefs = React.useCallback(\n (el: HTMLDivElement | null) => {\n localRef.current = el;\n if (!rootRef) {\n return;\n }\n if (typeof rootRef === \"function\") {\n rootRef(el);\n return;\n }\n try {\n // RefObject-like\n (rootRef as React.MutableRefObject<HTMLDivElement | null>).current = el;\n } catch {\n // ignore\n }\n },\n [rootRef],\n );\n\n const handleKeyDown = React.useEffectEvent((e: React.KeyboardEvent<HTMLDivElement>) => {\n const root = localRef.current ?? (e.currentTarget as HTMLDivElement | null);\n if (!root) {\n return;\n }\n const tabs = Array.from(root.querySelectorAll('[role=\"tab\"]')) as HTMLElement[];\n if (tabs.length === 0) {\n return;\n }\n\n const focusTabAt = (index: number) => {\n const clamped = Math.max(0, Math.min(index, tabs.length - 1));\n const el = tabs[clamped];\n if (!el) {\n return;\n }\n el.focus();\n };\n\n const activeEl = document.activeElement as HTMLElement | null;\n const currentIndex = activeEl ? tabs.indexOf(activeEl) : tabs.findIndex((el) => el.getAttribute(\"data-tab-id\") === group.activeTabId);\n\n if (e.key === \"ArrowRight\") {\n e.preventDefault();\n const next = currentIndex >= 0 ? currentIndex + 1 : 0;\n focusTabAt(next >= tabs.length ? 0 : next);\n return;\n }\n if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n const prev = currentIndex >= 0 ? currentIndex - 1 : tabs.length - 1;\n focusTabAt(prev < 0 ? tabs.length - 1 : prev);\n return;\n }\n if (e.key === \"Home\") {\n e.preventDefault();\n focusTabAt(0);\n return;\n }\n if (e.key === \"End\") {\n e.preventDefault();\n focusTabAt(tabs.length - 1);\n return;\n }\n\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n const el = currentIndex >= 0 ? tabs[currentIndex] : null;\n const id = el?.getAttribute(\"data-tab-id\") ?? null;\n if (id) {\n onClickTab(id);\n }\n return;\n }\n\n if (e.key === \"Delete\" || e.key === \"Backspace\") {\n if (onCloseTab) {\n e.preventDefault();\n const el = currentIndex >= 0 ? tabs[currentIndex] : null;\n const id = el?.getAttribute(\"data-tab-id\") ?? null;\n if (id) {\n onCloseTab(group.id, id);\n }\n }\n return;\n }\n\n const hasModifier = (e.ctrlKey ? 1 : 0) + (e.metaKey ? 1 : 0) > 0;\n const keyLower = typeof e.key === \"string\" ? e.key.toLowerCase() : \"\";\n if (hasModifier && keyLower === \"t\") {\n if (onAddTab) {\n e.preventDefault();\n onAddTab(group.id);\n }\n return;\n }\n });\n\n React.useEffect(() => {\n const root = localRef.current;\n if (!root) {\n return;\n }\n const active = root.querySelector(`[role=\"tab\"][data-tab-id=\"${group.activeTabId}\"]`) as HTMLElement | null;\n if (active === (document.activeElement as HTMLElement | null)) {\n return;\n }\n // Maintain roving focus: ensure active tab is in the natural focus if none inside has focus\n const containsFocus = root.contains(document.activeElement);\n if (!containsFocus && active) {\n active.focus();\n }\n }, [group.activeTabId]);\n\n const containerProps = {\n style: tabbarStyle,\n role: \"tablist\" as const,\n \"data-tabbar\": \"true\",\n \"data-group-id\": group.id,\n \"data-dragging\": isTabDragging ? \"true\" : \"false\",\n onKeyDown: handleKeyDown,\n };\n\n const Wrapper = useElementComponentWrapper({\n element,\n component: ContainerComponent,\n });\n\n const renderAddButton = (): React.ReactNode => {\n if (!onAddTab) {\n return null;\n }\n return (\n <button\n type=\"button\"\n aria-label=\"Add tab\"\n onClick={() => {\n onAddTab(group.id);\n }}\n >\n +\n </button>\n );\n };\n\n const handleTabbarDoubleClick = React.useCallback((): void => {\n if (doubleClickToAdd && onAddTab) {\n onAddTab(group.id);\n }\n }, [doubleClickToAdd, onAddTab, group.id]);\n\n return (\n <Wrapper {...containerProps} ref={setRefs} onDoubleClick={handleTabbarDoubleClick}>\n {group.tabs.map((tab, index) => (\n <TabBarTab\n key={`${group.id}:${tab.id}:${index}`}\n groupId={group.id}\n tab={tab}\n active={group.activeTabId === tab.id}\n dragging={draggingTabId === tab.id}\n onClickTab={onClickTab}\n onStartDrag={onStartDrag}\n onCloseTab={onCloseTab}\n tabComponent={TabComponent}\n tabElement={tabElement}\n onDoubleClick={(e) => e.stopPropagation()}\n />\n ))}\n <span style={spacerStyle} />\n {renderAddButton()}\n </Wrapper>\n );\n};\n","/**\n * @file Connected group container bridging panel contexts to the presentational view.\n */\nimport * as React from \"react\";\nimport type { GroupId, PanelGroupRenderProps, TabBarRenderProps } from \"../../panels/state/types\";\nimport { usePanelRenderContext } from \"../rendering/RenderContext\";\nimport { useDomRegistry } from \"../dom/DomRegistry\";\nimport { PanelGroupView } from \"../../../components/panels/PanelGroupView\";\nimport { TabBar } from \"../../../components/tabs/TabBar\";\n\nexport type ConnectedGroupContainerProps = {\n id: GroupId;\n TabBarComponent?: React.ComponentType<TabBarRenderProps>;\n PanelGroupComponent?: React.ComponentType<PanelGroupRenderProps>;\n};\n\nexport const GroupContainer: React.FC<ConnectedGroupContainerProps> = ({ id, TabBarComponent, PanelGroupComponent }) => {\n const { getGroup, getGroupContent, onClickTab, onAddTab, onCloseTab, onStartTabDrag, doubleClickToAdd, registerContentContainer } = usePanelRenderContext();\n const { setGroupEl, setTabbarEl, setContentEl } = useDomRegistry();\n const groupRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n setGroupEl(id, el);\n },\n [id, setGroupEl],\n );\n const contentRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n setContentEl(id, el);\n registerContentContainer(id, el);\n },\n [id, setContentEl, registerContentContainer],\n );\n const tabbarRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n setTabbarEl(id, el);\n },\n [id, setTabbarEl],\n );\n const group = getGroup(id);\n if (!group) {\n return null;\n }\n const content = getGroupContent(id);\n const TabBarImpl = TabBarComponent ?? TabBar;\n const PanelGroupImpl: React.ComponentType<PanelGroupRenderProps> = PanelGroupComponent ?? ((props) => <PanelGroupView {...props} />);\n return (\n <PanelGroupImpl\n group={group}\n tabbar={\n <TabBarImpl\n rootRef={tabbarRef}\n group={group}\n onClickTab={(tabId) => onClickTab(id, tabId)}\n onAddTab={onAddTab}\n onCloseTab={onCloseTab}\n onStartDrag={(tabId, groupId, e) => onStartTabDrag(tabId, groupId, e)}\n doubleClickToAdd={doubleClickToAdd}\n />\n }\n content={content}\n groupRef={groupRef}\n contentRef={contentRef}\n />\n );\n};\n","/**\n * @file CSSMatrix - Immutable 4x4 matrix for CSS 3D transforms\n *\n * Each operation returns a new instance, preserving the original matrix.\n *\n * @example\n * const mtrx = matrix().translate(0, 10);\n * const a = mtrx.rotateX(Math.PI / 2);\n * const b = mtrx.rotateY(Math.PI);\n * // a and b are independent transformations from mtrx\n */\n\n/**\n * Matrix type with transformation methods\n */\nexport type CSSMatrix = {\n readonly translate: (x?: number, y?: number, z?: number) => CSSMatrix;\n readonly translate3d: (x: number, y: number, z: number) => CSSMatrix;\n readonly translateX: (x: number) => CSSMatrix;\n readonly translateY: (y: number) => CSSMatrix;\n readonly translateZ: (z: number) => CSSMatrix;\n readonly scale: (x?: number, y?: number, z?: number) => CSSMatrix;\n readonly scale3d: (x: number, y: number, z: number) => CSSMatrix;\n readonly scaleX: (x: number) => CSSMatrix;\n readonly scaleY: (y: number) => CSSMatrix;\n readonly scaleZ: (z: number) => CSSMatrix;\n readonly rotateX: (angle: number) => CSSMatrix;\n readonly rotateY: (angle: number) => CSSMatrix;\n readonly rotateZ: (angle: number) => CSSMatrix;\n readonly rotate: (angle: number, x: number, y: number, z: number) => CSSMatrix;\n readonly rotate3d: (x: number, y: number, z: number, angle: number) => CSSMatrix;\n readonly skew: (angleX?: number, angleY?: number) => CSSMatrix;\n readonly skewX: (angle: number) => CSSMatrix;\n readonly skewY: (angle: number) => CSSMatrix;\n readonly perspective: (distance: number) => CSSMatrix;\n readonly toCSS: () => string;\n readonly toArray: () => readonly number[];\n readonly toString: () => string;\n};\n\n/**\n * Multiply two 4x4 matrices (a * b)\n * Matrices are in column-major order\n */\nconst multiplyMatrices = (a: readonly number[], b: readonly number[]): number[] => {\n const result = new Array(16);\n\n for (let col = 0; col < 4; col++) {\n for (let row = 0; row < 4; row++) {\n result[col * 4 + row] =\n a[0 * 4 + row] * b[col * 4 + 0] +\n a[1 * 4 + row] * b[col * 4 + 1] +\n a[2 * 4 + row] * b[col * 4 + 2] +\n a[3 * 4 + row] * b[col * 4 + 3];\n }\n }\n\n return result;\n};\n\n/**\n * Create a CSSMatrix object from raw values\n * Values are stored in column-major order (OpenGL/CSS convention)\n */\nconst createMatrix = (values: readonly number[]): CSSMatrix => {\n if (values.length !== 16) {\n throw new Error('Matrix must have exactly 16 values');\n }\n\n // Freeze the values to ensure immutability\n const m = Object.freeze([...values]);\n\n /**\n * Helper to create a new matrix by multiplying with a transform matrix\n */\n const applyTransform = (transformValues: number[]): CSSMatrix => {\n const result = multiplyMatrices(m, transformValues);\n return createMatrix(result);\n };\n\n return Object.freeze({\n translate: (x = 0, y = 0, z = 0) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n x, y, z, 1,\n ]);\n },\n\n translate3d: (x, y, z) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n x, y, z, 1,\n ]);\n },\n\n translateX: (x) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n x, 0, 0, 1,\n ]);\n },\n\n translateY: (y) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, y, 0, 1,\n ]);\n },\n\n translateZ: (z) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, z, 1,\n ]);\n },\n\n scale: (x = 1, y = 1, z = 1) => {\n return applyTransform([\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n scale3d: (x, y, z) => {\n return applyTransform([\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n scaleX: (x) => {\n return applyTransform([\n x, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n scaleY: (y) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n scaleZ: (z) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n rotateX: (angle) => {\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n return applyTransform([\n 1, 0, 0, 0,\n 0, c, s, 0,\n 0, -s, c, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n rotateY: (angle) => {\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n return applyTransform([\n c, 0, -s, 0,\n 0, 1, 0, 0,\n s, 0, c, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n rotateZ: (angle) => {\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n return applyTransform([\n c, s, 0, 0,\n -s, c, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n rotate: (angle, x, y, z) => {\n // Normalize the axis\n const len = Math.sqrt(x * x + y * y + z * z);\n if (len === 0) {\n return createMatrix(m);\n }\n\n x /= len;\n y /= len;\n z /= len;\n\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n const t = 1 - c;\n\n return applyTransform([\n t * x * x + c, t * x * y + s * z, t * x * z - s * y, 0,\n t * x * y - s * z, t * y * y + c, t * y * z + s * x, 0,\n t * x * z + s * y, t * y * z - s * x, t * z * z + c, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n rotate3d: (x, y, z, angle) => {\n // Normalize the axis\n const len = Math.sqrt(x * x + y * y + z * z);\n if (len === 0) {\n return createMatrix(m);\n }\n\n x /= len;\n y /= len;\n z /= len;\n\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n const t = 1 - c;\n\n return applyTransform([\n t * x * x + c, t * x * y + s * z, t * x * z - s * y, 0,\n t * x * y - s * z, t * y * y + c, t * y * z + s * x, 0,\n t * x * z + s * y, t * y * z - s * x, t * z * z + c, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n skew: (angleX = 0, angleY = 0) => {\n const tanX = Math.tan(angleX);\n const tanY = Math.tan(angleY);\n return applyTransform([\n 1, tanY, 0, 0,\n tanX, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n skewX: (angle) => {\n const tanX = Math.tan(angle);\n return applyTransform([\n 1, 0, 0, 0,\n tanX, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n skewY: (angle) => {\n const tanY = Math.tan(angle);\n return applyTransform([\n 1, tanY, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n perspective: (distance) => {\n if (distance === 0) {\n throw new Error('Perspective distance cannot be zero');\n }\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, -1 / distance,\n 0, 0, 0, 1,\n ]);\n },\n\n toCSS: () => {\n return `matrix3d(${m.join(', ')})`;\n },\n\n toArray: () => m,\n\n toString: () => {\n return [\n `[${m[0]}, ${m[4]}, ${m[8]}, ${m[12]}]`,\n `[${m[1]}, ${m[5]}, ${m[9]}, ${m[13]}]`,\n `[${m[2]}, ${m[6]}, ${m[10]}, ${m[14]}]`,\n `[${m[3]}, ${m[7]}, ${m[11]}, ${m[15]}]`,\n ].join('\\n');\n },\n });\n};\n\n/**\n * Factory function to create a new identity matrix\n */\nexport const matrix = (): CSSMatrix => {\n return createMatrix([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n};\n","/**\n * @file Overlay renderer and helpers for drop suggestion zones.\n */\nimport * as React from \"react\";\nimport type { DropZone } from \"../../modules/panels/state/types\";\nimport {\n DROP_SUGGEST_Z_INDEX,\n DROP_SUGGEST_BORDER_WIDTH,\n DROP_SUGGEST_BORDER_RADIUS,\n DROP_SUGGEST_BORDER_COLOR,\n DROP_SUGGEST_BG_COLOR,\n DROP_SUGGEST_PADDING_PX,\n} from \"../../constants/styles\";\nimport { clampNumber } from \"../../utils/math\";\nimport { matrix } from \"../../utils/CSSMatrix\";\n\nconst overlayStyle: React.CSSProperties = {\n position: \"fixed\",\n inset: 0,\n pointerEvents: \"none\",\n zIndex: DROP_SUGGEST_Z_INDEX,\n};\n\nconst suggestRectBaseStyle: React.CSSProperties = {\n position: \"absolute\",\n border: `${DROP_SUGGEST_BORDER_WIDTH} dashed ${DROP_SUGGEST_BORDER_COLOR}`,\n background: DROP_SUGGEST_BG_COLOR,\n borderRadius: DROP_SUGGEST_BORDER_RADIUS,\n transformOrigin: \"top left\",\n};\n\nexport type SuggestInfo = {\n rect: DOMRectReadOnly;\n zone: DropZone;\n};\n\nexport type DropSuggestOverlayProps = {\n suggest: SuggestInfo | null;\n};\n\nconst safeRatio = (value: number, base: number): number => {\n if (base <= 0) {\n return 0;\n }\n return clampNumber(value / base, 0);\n};\n\nconst buildZoneTransform = (rect: DOMRectReadOnly, zone: DropZone, pad: number): string => {\n const { width, height } = rect;\n const halfPad = pad / 2;\n const widthBase = width > 0 ? width : 1;\n const heightBase = height > 0 ? height : 1;\n\n const center = {\n translateX: pad,\n translateY: pad,\n scaleX: safeRatio(clampNumber(width - pad * 2, 0), widthBase),\n scaleY: safeRatio(clampNumber(height - pad * 2, 0), heightBase),\n };\n\n const left = {\n translateX: pad,\n translateY: pad,\n scaleX: safeRatio(clampNumber(width / 2 - pad * 1.5, 0), widthBase),\n scaleY: safeRatio(clampNumber(height - pad * 2, 0), heightBase),\n };\n\n const right = {\n translateX: width / 2 + halfPad,\n translateY: pad,\n scaleX: safeRatio(clampNumber(width / 2 - pad * 1.5, 0), widthBase),\n scaleY: safeRatio(clampNumber(height - pad * 2, 0), heightBase),\n };\n\n const top = {\n translateX: pad,\n translateY: pad,\n scaleX: safeRatio(clampNumber(width - pad * 2, 0), widthBase),\n scaleY: safeRatio(clampNumber(height / 2 - pad * 1.5, 0), heightBase),\n };\n\n const bottom = {\n translateX: pad,\n translateY: height / 2 + halfPad,\n scaleX: safeRatio(clampNumber(width - pad * 2, 0), widthBase),\n scaleY: safeRatio(clampNumber(height / 2 - pad * 1.5, 0), heightBase),\n };\n\n const zoneTransforms: Record<DropZone, typeof center> = {\n center,\n left,\n right,\n top,\n bottom,\n };\n\n const { translateX, translateY, scaleX, scaleY } = zoneTransforms[zone];\n return matrix()\n .translate(translateX, translateY, 0)\n .scale(scaleX, scaleY, 1)\n .toCSS();\n};\n\nconst buildSuggestStyle = (rect: DOMRectReadOnly, zone: DropZone): React.CSSProperties => {\n const pad = DROP_SUGGEST_PADDING_PX;\n return {\n ...suggestRectBaseStyle,\n left: rect.left,\n top: rect.top,\n width: rect.width,\n height: rect.height,\n transform: buildZoneTransform(rect, zone, pad),\n };\n};\n\nexport const DropSuggestOverlay: React.FC<DropSuggestOverlayProps> = ({ suggest }) => {\n if (!suggest) {\n return null;\n }\n\n const { rect, zone } = suggest;\n const style = buildSuggestStyle(rect, zone);\n\n return (\n <div style={overlayStyle}>\n <div style={style} />\n </div>\n );\n};\n\n// pickDropZone moved to modules/panels/runtime/dnd\n","/**\n * @file Clone a DOM element for preview while keeping SSR safe.\n * Provides the cloned element as HTML string plus its measured size.\n */\nimport * as React from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\nconst isBrowser = typeof window !== \"undefined\" && typeof document !== \"undefined\";\n\nexport const useClonedElementPreview = (\n sourceEl: HTMLElement | null,\n): { html: string | null; size: { width: number; height: number } | null } => {\n const [size, setSize] = React.useState<{ width: number; height: number } | null>(null);\n const [html, setHtml] = React.useState<string | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (!isBrowser || !sourceEl) {\n setSize(null);\n setHtml(null);\n return;\n }\n const rect = sourceEl.getBoundingClientRect();\n setSize({ width: rect.width, height: rect.height });\n setHtml(sourceEl.outerHTML);\n }, [sourceEl]);\n\n return { html, size };\n};\n","/**\n * @file Floating drag preview and insertion guide for tab dragging.\n */\nimport * as React from \"react\";\nimport { usePanelInteractions } from \"../../modules/panels/interactions/InteractionsContext\";\nimport {\n TAB_DRAG_OVERLAY_Z_INDEX,\n TAB_DRAG_PREVIEW_OFFSET_X,\n TAB_DRAG_PREVIEW_OFFSET_Y,\n TAB_DRAG_INSERT_GUIDE_WIDTH,\n TAB_DRAG_INSERT_GUIDE_BORDER_RADIUS,\n TAB_DRAG_INSERT_GUIDE_COLOR,\n TAB_DRAG_INSERT_GUIDE_SHADOW,\n} from \"../../constants/styles\";\nimport { useClonedElementPreview } from \"../../hooks/useClonedElementPreview\";\n\nconst overlayStyle: React.CSSProperties = {\n position: \"fixed\",\n inset: 0,\n pointerEvents: \"none\",\n zIndex: TAB_DRAG_OVERLAY_Z_INDEX,\n};\n\nconst insertGuideBaseStyle: React.CSSProperties = {\n position: \"absolute\",\n width: TAB_DRAG_INSERT_GUIDE_WIDTH,\n borderRadius: TAB_DRAG_INSERT_GUIDE_BORDER_RADIUS,\n background: TAB_DRAG_INSERT_GUIDE_COLOR,\n boxShadow: TAB_DRAG_INSERT_GUIDE_SHADOW,\n};\n\nexport const TabDragOverlay: React.FC = () => {\n const { isTabDragging, draggingTabId, dragPointer, tabbarHover, draggingTabElement } = usePanelInteractions();\n const { html: previewHtml, size: previewSize } = useClonedElementPreview(draggingTabElement);\n\n const hasPreview = dragPointer !== null && draggingTabId !== null;\n\n const previewBaseStyle = React.useMemo<React.CSSProperties | undefined>(() => {\n if (!hasPreview || !dragPointer) {\n return undefined;\n }\n return {\n position: \"absolute\",\n left: dragPointer.x,\n top: dragPointer.y,\n transform: `translate(${TAB_DRAG_PREVIEW_OFFSET_X}, ${TAB_DRAG_PREVIEW_OFFSET_Y})`,\n pointerEvents: \"none\",\n };\n }, [hasPreview, dragPointer]);\n\n const previewStyle = React.useMemo<React.CSSProperties | undefined>(() => {\n if (!previewBaseStyle || !draggingTabElement) {\n return undefined;\n }\n if (previewSize) {\n return { ...previewBaseStyle, width: previewSize.width, height: previewSize.height };\n }\n return previewBaseStyle;\n }, [previewBaseStyle, draggingTabElement, previewSize]);\n\n const guideStyle = React.useMemo<React.CSSProperties | undefined>(() => {\n if (!tabbarHover) {\n return undefined;\n }\n return {\n ...insertGuideBaseStyle,\n left: tabbarHover.insertX,\n top: tabbarHover.rect.top + 4,\n height: Math.max(0, tabbarHover.rect.height - 8),\n };\n }, [tabbarHover]);\n\n if (!isTabDragging) {\n return null;\n }\n\n return (\n <div style={overlayStyle}>\n <React.Activity mode={previewStyle ? \"visible\" : \"hidden\"}>\n <div style={previewStyle}>\n <div\n style={{ width: \"100%\", height: \"100%\", pointerEvents: \"none\" }}\n dangerouslySetInnerHTML={{ __html: previewHtml ?? \"\" }}\n />\n </div>\n </React.Activity>\n <React.Activity mode={guideStyle ? \"visible\" : \"hidden\"}>\n <div style={guideStyle} />\n </React.Activity>\n </div>\n );\n};\n","/**\n * @file Tree operations for panel-system (no registry or focus concerns).\n */\nimport type { GroupId, PanelTree, SplitDirection } from \"../types\";\nimport { clampNumber } from \"../../../../utils/math\";\n\nexport type PathSegment = \"a\" | \"b\";\nexport type NodePath = PathSegment[];\n\nexport const isGroup = (node: PanelTree): node is Extract<PanelTree, { type: \"group\" }> => {\n return (node as { type: string }).type === \"group\";\n};\n\nexport const collectGroupsInOrder = (node: PanelTree, acc: GroupId[] = []): GroupId[] => {\n if (isGroup(node)) {\n return [...acc, node.groupId];\n }\n const a = collectGroupsInOrder(node.a, acc);\n return collectGroupsInOrder(node.b, a);\n};\n\nexport const getAtPath = (root: PanelTree, path: NodePath): PanelTree => {\n return path.reduce<PanelTree>((node, key) => (isGroup(node) ? node : node[key]), root);\n};\n\nexport const setAtPath = (root: PanelTree, path: NodePath, value: PanelTree): PanelTree => {\n if (path.length === 0) {\n return value;\n }\n const [head, ...rest] = path;\n if (isGroup(root)) {\n // Invalid set; return original root\n return root;\n }\n const next = head === \"a\" ? { ...root, a: setAtPath(root.a, rest, value) } : { ...root, b: setAtPath(root.b, rest, value) };\n return next;\n};\n\n/**\n * Find split parent of a given group leaf. This function explicitly returns the path to the split node\n * and which side (\"a\" | \"b\") the target group occupies under that split. If there is no split parent\n * (i.e., the root is the leaf group), splitPath and side are null.\n */\nexport const findLeafParent = (\n node: PanelTree,\n groupId: GroupId,\n path: NodePath = [],\n): { splitPath: NodePath | null; side: PathSegment | null } | null => {\n if (isGroup(node)) {\n if (node.groupId === groupId) {\n return { splitPath: null, side: null };\n }\n return null;\n }\n // Search child A; if it is the group leaf, current node is parent and side is 'a'\n if (isGroup(node.a) && node.a.groupId === groupId) {\n return { splitPath: path, side: \"a\" };\n }\n // Search child B\n if (isGroup(node.b) && node.b.groupId === groupId) {\n return { splitPath: path, side: \"b\" };\n }\n // Recurse deeper\n const inA = findLeafParent(node.a, groupId, [...path, \"a\"]);\n if (inA) {\n return inA;\n }\n return findLeafParent(node.b, groupId, [...path, \"b\"]);\n};\n\n/**\n * Split the leaf group referenced by groupId into a split node, keeping the original group on side 'a'\n * and inserting a new group on side 'b'. Returns the new tree and the new group's id.\n * This function does not touch registries; only pure tree transformation.\n */\nexport const splitLeaf = (\n root: PanelTree,\n groupId: GroupId,\n direction: SplitDirection,\n createGroupId: () => GroupId,\n): { tree: PanelTree; newGroupId: GroupId } => {\n const newGroupId = createGroupId();\n const entry = findLeafParent(root, groupId);\n const replacement: PanelTree = {\n type: \"split\",\n direction,\n ratio: 0.5,\n a: { type: \"group\", groupId },\n b: { type: \"group\", groupId: newGroupId },\n } as const;\n\n if (!entry || entry.splitPath === null) {\n // Root is the leaf\n return { tree: replacement, newGroupId };\n }\n const parentPath = entry.splitPath;\n const parent = getAtPath(root, parentPath);\n if (isGroup(parent)) {\n // Should not happen; guard for safety\n return { tree: replacement, newGroupId };\n }\n const newParent = entry.side === \"a\" ? { ...parent, a: replacement } : { ...parent, b: replacement };\n const newTree = setAtPath(root, parentPath, newParent);\n return { tree: newTree, newGroupId };\n};\n\n/**\n * Remove the leaf group by collapsing it with its sibling. Returns the new tree and the survivor group id\n * (if any). If there is no split parent (single group), returns the original tree.\n */\nexport const closeLeaf = (root: PanelTree, groupId: GroupId): { tree: PanelTree; survivorGroupId: GroupId | null } => {\n const entry = findLeafParent(root, groupId);\n if (!entry || entry.splitPath === null) {\n // Single-group root\n return { tree: root, survivorGroupId: groupId };\n }\n const parentPath = entry.splitPath;\n const parent = getAtPath(root, parentPath);\n if (isGroup(parent)) {\n return { tree: root, survivorGroupId: groupId };\n }\n const survivor = entry.side === \"a\" ? parent.b : parent.a;\n const newTree = setAtPath(root, parentPath, survivor);\n const survivorId = isGroup(survivor) ? survivor.groupId : collectGroupsInOrder(survivor)[0] ?? null;\n return { tree: newTree, survivorGroupId: survivorId };\n};\n\n/**\n * Set split ratio at a specific split node path. Clamps ratio into (0.05 .. 0.95) to avoid zero-size panes.\n */\nexport const setSplitRatio = (root: PanelTree, splitPath: NodePath, ratio: number): PanelTree => {\n const node = getAtPath(root, splitPath);\n if (isGroup(node)) {\n return root;\n }\n const next = { ...node, ratio: clampNumber(ratio, 0.05, 0.95) } as PanelTree;\n return setAtPath(root, splitPath, next);\n};\n","/**\n * @file Cleanup utilities for PanelSystem state.\n * - Removes groups with no tabs and collapses the tree accordingly.\n */\nimport type { GroupId, PanelSystemState } from \"./types\";\nimport { closeLeaf, collectGroupsInOrder } from \"./tree/logic\";\n\n/**\n * Remove empty groups (tabs.length === 0) by collapsing corresponding leaves.\n * Keeps at least one group in the system.\n * Returns the same reference if no changes are necessary to help callers short-circuit updates.\n */\nexport const cleanupEmptyGroups = (state: PanelSystemState): PanelSystemState => {\n const allGroupIds = Object.keys(state.groups);\n const emptyIds = allGroupIds.filter((gid) => state.groups[gid]!.tabIds.length === 0);\n if (emptyIds.length === 0) {\n return state;\n }\n\n const removeIfEmpty = (acc: PanelSystemState, gid: GroupId): PanelSystemState => {\n const group = acc.groups[gid];\n if (!group || group.tabs.length > 0) {\n return acc;\n }\n const groupCount = Object.keys(acc.groups).length;\n if (groupCount <= 1) {\n return acc;\n }\n const { tree, survivorGroupId } = closeLeaf(acc.tree, gid);\n const { [gid]: _removed, ...restGroups } = acc.groups; void _removed;\n const groupOrder = collectGroupsInOrder(tree);\n const focusedGroupId = acc.focusedGroupId === gid ? (survivorGroupId ?? groupOrder[0] ?? null) : acc.focusedGroupId;\n return { ...acc, tree, groups: restGroups, groupOrder, focusedGroupId };\n };\n\n return state.groupOrder.reduce<PanelSystemState>((acc, gid) => removeIfEmpty(acc, gid as GroupId), state);\n};\n","/**\n * @file Group and tab registry operations (pure, no tree logic).\n */\nimport type { GroupId, GroupModel, PanelId, PanelSystemState, TabDefinition } from \"../types\";\n\nexport const createEmptyGroup = (id: GroupId): GroupModel => {\n return { id, tabIds: [], tabs: [], activeTabId: null };\n};\n\nexport const addTabToGroup = (state: PanelSystemState, groupId: GroupId, tab: TabDefinition, makeActive: boolean): PanelSystemState => {\n const groups = { ...state.groups };\n const group = groups[groupId];\n if (!group) {\n throw new Error(`Group ${groupId} does not exist.`);\n }\n const panels = { ...state.panels, [tab.id]: tab };\n const tabIds = [...group.tabIds, tab.id];\n const activeTabId = makeActive ? tab.id : group.activeTabId ?? tab.id;\n const tabs = tabIds.map((id) => panels[id]);\n const nextGroup: GroupModel = { ...group, tabIds, tabs, activeTabId };\n groups[groupId] = nextGroup;\n return { ...state, panels, groups };\n};\n\nexport const removeTabFromGroup = (state: PanelSystemState, groupId: GroupId, tabId: PanelId): PanelSystemState => {\n const groups = { ...state.groups };\n const group = groups[groupId];\n if (!group) {\n throw new Error(`Group ${groupId} does not exist.`);\n }\n const tabIds = group.tabIds.filter((id) => id !== tabId);\n const tabs = tabIds.map((id) => state.panels[id]);\n const activeTabId = group.activeTabId === tabId ? (tabIds[0] ?? null) : group.activeTabId;\n groups[groupId] = { ...group, tabIds, tabs, activeTabId };\n return { ...state, groups };\n};\n\nexport const moveTab = (state: PanelSystemState, fromGroupId: GroupId, toGroupId: GroupId, tabId: PanelId, makeActive: boolean): PanelSystemState => {\n const from = state.groups[fromGroupId];\n const to = state.groups[toGroupId];\n if (!from || !to) {\n throw new Error(\"moveTab: source or target group is missing.\");\n }\n const groups = { ...state.groups };\n const fromIds = from.tabIds.filter((id) => id !== tabId);\n const toIds = [...to.tabIds.filter((id) => id !== tabId), tabId];\n const fromActive = from.activeTabId === tabId ? (fromIds[0] ?? null) : from.activeTabId;\n groups[fromGroupId] = { ...from, tabIds: fromIds, tabs: fromIds.map((id) => state.panels[id]), activeTabId: fromActive };\n groups[toGroupId] = { ...to, tabIds: toIds, tabs: toIds.map((id) => state.panels[id]), activeTabId: makeActive ? tabId : to.activeTabId ?? tabId };\n return { ...state, groups };\n};\n\nexport const setActiveTab = (state: PanelSystemState, groupId: GroupId, tabId: PanelId): PanelSystemState => {\n const group = state.groups[groupId];\n if (!group) {\n throw new Error(`setActiveTab: group ${groupId} not found.`);\n }\n if (!group.tabIds.some((id) => id === tabId)) {\n throw new Error(`setActiveTab: tab ${tabId} not found in group ${groupId}.`);\n }\n const groups = { ...state.groups, [groupId]: { ...group, activeTabId: tabId } };\n return { ...state, groups, focusedGroupId: groupId };\n};\n\nexport const reorderTabWithinGroup = (state: PanelSystemState, groupId: GroupId, tabId: PanelId, toIndex: number): PanelSystemState => {\n const group = state.groups[groupId];\n if (!group) {\n throw new Error(`reorderTabWithinGroup: group ${groupId} not found.`);\n }\n const currentIndex = group.tabIds.findIndex((id) => id === tabId);\n if (currentIndex === -1) {\n throw new Error(`reorderTabWithinGroup: tab ${tabId} not in group ${groupId}.`);\n }\n const boundedIndex = Math.max(0, Math.min(toIndex, group.tabIds.length - 1));\n if (currentIndex === boundedIndex) {\n return state;\n }\n const ids = group.tabIds.slice();\n const [id] = ids.splice(currentIndex, 1);\n ids.splice(boundedIndex, 0, id);\n const tabs = ids.map((x) => state.panels[x]);\n const groups = { ...state.groups, [groupId]: { ...group, tabIds: ids, tabs } };\n return { ...state, groups };\n};\n\nexport const addTabToGroupAtIndex = (\n state: PanelSystemState,\n groupId: GroupId,\n tab: TabDefinition,\n index: number,\n makeActive: boolean,\n): PanelSystemState => {\n const group = state.groups[groupId];\n if (!group) {\n throw new Error(`addTabToGroupAtIndex: group ${groupId} not found.`);\n }\n const panels = { ...state.panels, [tab.id]: tab };\n const ids = group.tabIds.slice();\n const boundedIndex = Math.max(0, Math.min(index, ids.length));\n ids.splice(boundedIndex, 0, tab.id);\n const tabs = ids.map((id) => panels[id]);\n const activeTabId = makeActive ? tab.id : group.activeTabId ?? tab.id;\n const groups = { ...state.groups, [groupId]: { ...group, tabIds: ids, tabs, activeTabId } };\n return { ...state, panels, groups };\n};\n","/**\n * @file Focus and navigation helpers for panel-system.\n */\nimport type { GroupId, PanelSystemState } from \"../types\";\nimport { collectGroupsInOrder } from \"../tree/logic\";\n\nexport const setFocusedGroup = (state: PanelSystemState, groupId: GroupId): PanelSystemState => {\n if (!state.groups[groupId]) {\n throw new Error(`setFocusedGroup: group ${groupId} not found.`);\n }\n return { ...state, focusedGroupId: groupId };\n};\n\nexport const focusGroupIndex = (state: PanelSystemState, index1Based: number): PanelSystemState => {\n const idx = index1Based - 1;\n const id = state.groupOrder[idx];\n if (!id) {\n return state;\n }\n return setFocusedGroup(state, id);\n};\n\nexport const nextGroup = (state: PanelSystemState): PanelSystemState => {\n const order = state.groupOrder;\n const current = state.focusedGroupId;\n if (!current) {\n const first = order[0];\n if (!first) {\n return state;\n }\n return setFocusedGroup(state, first);\n }\n const idx = order.indexOf(current);\n const next = order[(idx + 1) % order.length];\n return setFocusedGroup(state, next);\n};\n\nexport const prevGroup = (state: PanelSystemState): PanelSystemState => {\n const order = state.groupOrder;\n const current = state.focusedGroupId;\n if (!current) {\n const last = order[order.length - 1];\n if (!last) {\n return state;\n }\n return setFocusedGroup(state, last);\n }\n const idx = order.indexOf(current);\n const prev = order[(idx - 1 + order.length) % order.length];\n return setFocusedGroup(state, prev);\n};\n\nexport const refreshGroupOrder = (state: PanelSystemState): PanelSystemState => {\n const groupOrder = collectGroupsInOrder(state.tree);\n return { ...state, groupOrder };\n};\n\n","/**\n * @file Public state operations aggregator (flattened under src/modules/panels).\n */\nexport type {\n PanelId,\n GroupId,\n SplitDirection,\n TabDefinition,\n GroupModel,\n PanelTree,\n PanelSystemState,\n DropZone,\n DraggingTab,\n PanelCommands,\n PanelSystemProps,\n PanelSplitLimits,\n} from \"./state/types\";\n\nexport { collectGroupsInOrder, splitLeaf, closeLeaf, isGroup, setSplitRatio } from \"./state/tree/logic\";\nexport { createEmptyGroup, addTabToGroup, removeTabFromGroup, moveTab, setActiveTab, reorderTabWithinGroup, addTabToGroupAtIndex } from \"./state/groups/logic\";\nexport { setFocusedGroup, focusGroupIndex, nextGroup, prevGroup, refreshGroupOrder } from \"./state/focus/logic\";\n\nimport type { GroupId as Gid, PanelSystemState as PState, SplitDirection as Dir, TabDefinition } from \"./state/types\";\nimport { splitLeaf, collectGroupsInOrder } from \"./state/tree/logic\";\nimport { createEmptyGroup } from \"./state/groups/logic\";\n\nexport type IdFactory = () => Gid;\n\nexport const splitGroup = (state: PState, groupId: Gid, direction: Dir, createGroupId: IdFactory): PState => {\n const { tree, newGroupId } = splitLeaf(state.tree, groupId, direction, createGroupId);\n const groups = { ...state.groups, [newGroupId]: createEmptyGroup(newGroupId) };\n const groupOrder = collectGroupsInOrder(tree);\n const focusedGroupId = newGroupId;\n return { ...state, tree, groups, groupOrder, focusedGroupId };\n};\n\nexport const buildInitialState = (tabs: TabDefinition[]): PState => {\n const groupId: Gid = \"g_1\";\n const tree = { type: \"group\", groupId } as const;\n const panels = Object.fromEntries(tabs.map((t) => [t.id, t]));\n const group = { id: groupId, tabIds: tabs.map((t) => t.id), tabs, activeTabId: tabs[0]?.id ?? null } as const;\n const groups = { [groupId]: group } as PState[\"groups\"];\n const groupOrder: Gid[] = [groupId];\n return { tree, panels, groups, groupOrder, focusedGroupId: groupId } as PState;\n};\n","/**\n * @file GroupsContext provides group/tab management actions for PanelSystem.\n * This context delegates to the root PanelSystemContext dispatch.\n */\nimport * as React from \"react\";\nimport type { GroupId, PanelId } from \"../types\";\n\nexport type GroupsActions = {\n setActiveTab: (groupId: GroupId, tabId: PanelId) => void;\n tabDrop: (payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; targetIndex: number }) => void;\n};\n\nconst GroupsContext = React.createContext<GroupsActions | null>(null);\n\nexport const useGroups = (): GroupsActions => {\n const ctx = React.useContext(GroupsContext);\n if (!ctx) {\n throw new Error(\"useGroups must be used within GroupsProvider\");\n }\n return ctx;\n};\n\nexport const GroupsProvider: React.FC<React.PropsWithChildren<{ value: GroupsActions }>> = ({ value, children }) => {\n return <GroupsContext.Provider value={value}>{children}</GroupsContext.Provider>;\n};\n","/**\n * @file TreeContext provides tree/split management actions for PanelSystem.\n * This context delegates to the root PanelSystemContext dispatch.\n */\nimport * as React from \"react\";\nimport type { NodePath } from \"./logic\";\n\nexport type TreeActions = {\n adjustSplitRatio: (payload: { path: NodePath; deltaRatio: number }) => void;\n};\n\nconst TreeContext = React.createContext<TreeActions | null>(null);\n\nexport const useTree = (): TreeActions => {\n const ctx = React.useContext(TreeContext);\n if (!ctx) {\n throw new Error(\"useTree must be used within TreeProvider\");\n }\n return ctx;\n};\n\nexport const TreeProvider: React.FC<React.PropsWithChildren<{ value: TreeActions }>> = ({ value, children }) => {\n return <TreeContext.Provider value={value}>{children}</TreeContext.Provider>;\n};\n","/**\n * @file FocusContext provides focus/navigation actions for PanelSystem.\n * This context delegates to the root PanelSystemContext dispatch.\n */\nimport * as React from \"react\";\n\nexport type FocusActions = {\n focusGroupIndex: (index1Based: number) => void;\n focusNextGroup: () => void;\n focusPrevGroup: () => void;\n};\n\nconst FocusContext = React.createContext<FocusActions | null>(null);\n\nexport const useFocus = (): FocusActions => {\n const ctx = React.useContext(FocusContext);\n if (!ctx) {\n throw new Error(\"useFocus must be used within FocusProvider\");\n }\n return ctx;\n};\n\nexport const FocusProvider: React.FC<React.PropsWithChildren<{ value: FocusActions }>> = ({ value, children }) => {\n return <FocusContext.Provider value={value}>{children}</FocusContext.Provider>;\n};\n","/**\n * @file Split-limit helpers for the panel system.\n */\nimport type { GroupId, PanelSplitLimits, PanelTree, SplitDirection } from \"./types\";\nimport { splitLeaf, isGroup } from \"./tree/logic\";\nimport { clampNumber, toFiniteNumberOr } from \"../../../utils/math\";\n\nexport type NormalizedSplitLimits = {\n rows: number;\n cols: number;\n};\n\nconst clampLimit = (value: number | undefined): number => {\n const finite = toFiniteNumberOr(value, Number.POSITIVE_INFINITY);\n return clampNumber(finite, 1);\n};\n\nconst isObjectLimits = (limits: PanelSplitLimits): limits is Record<string, unknown> =>\n typeof limits === \"object\" && limits !== null;\n\nconst isRowsColsLimits = (limits: PanelSplitLimits): limits is { rows?: number; cols?: number } => {\n if (!isObjectLimits(limits)) {\n return false;\n }\n if (\"rows\" in limits) {\n return true;\n }\n return \"cols\" in limits;\n};\n\nexport const normalizeSplitLimits = (limits?: PanelSplitLimits): NormalizedSplitLimits => {\n if (!limits) {\n return {\n rows: Number.POSITIVE_INFINITY,\n cols: Number.POSITIVE_INFINITY,\n };\n }\n if (typeof limits === \"number\") {\n const normalized = clampLimit(limits);\n return { rows: normalized, cols: normalized };\n }\n if (isRowsColsLimits(limits)) {\n return {\n rows: clampLimit(limits.rows),\n cols: clampLimit(limits.cols),\n };\n }\n const legacy = limits as { maxHorizontal?: number; maxVertical?: number };\n return {\n rows: clampLimit(legacy.maxHorizontal),\n cols: clampLimit(legacy.maxVertical),\n };\n};\n\nexport type SplitExtents = {\n horizontal: number;\n vertical: number;\n};\n\nexport const measureSplitExtents = (tree: PanelTree): SplitExtents => {\n if (isGroup(tree)) {\n return { horizontal: 1, vertical: 1 };\n }\n const a = measureSplitExtents(tree.a);\n const b = measureSplitExtents(tree.b);\n if (tree.direction === \"horizontal\") {\n return { horizontal: a.horizontal + b.horizontal, vertical: Math.max(a.vertical, b.vertical) };\n }\n return { horizontal: Math.max(a.horizontal, b.horizontal), vertical: a.vertical + b.vertical };\n};\n\nconst previewSplitTree = (tree: PanelTree, groupId: GroupId, direction: SplitDirection): PanelTree => {\n const { tree: preview } = splitLeaf(tree, groupId, direction, () => \"__preview__\");\n return preview;\n};\n\nexport const canSplitDirection = (tree: PanelTree, groupId: GroupId, direction: SplitDirection, limits: NormalizedSplitLimits): boolean => {\n if (!Number.isFinite(limits.rows) && !Number.isFinite(limits.cols)) {\n return true;\n }\n const preview = previewSplitTree(tree, groupId, direction);\n const extents = measureSplitExtents(preview);\n if (extents.horizontal > limits.rows) {\n return false;\n }\n if (extents.vertical > limits.cols) {\n return false;\n }\n return true;\n};\n","/**\n * @file Root PanelSystemContext that combines subdomain contexts (groups, tree, focus).\n * Provides unified state and dispatch while exposing domain-specific actions via subcontexts.\n */\nimport * as React from \"react\";\nimport type { DropZone, GroupId, PanelId, PanelSplitLimits, PanelSystemState, SplitDirection, TabDefinition } from \"./types\";\nimport { cleanupEmptyGroups } from \"./cleanup\";\nimport { addTabToGroup, addTabToGroupAtIndex, moveTab, removeTabFromGroup, setActiveTab } from \"./groups/logic\";\nimport { setFocusedGroup, focusGroupIndex as focusIdx, nextGroup, prevGroup } from \"./focus/logic\";\nimport { splitGroup } from \"../index\";\nimport { getAtPath, isGroup, setSplitRatio, type NodePath } from \"./tree/logic\";\nimport { bindActionCreators, createAction, createActionHandlerMap, type BoundActionCreators } from \"../../../utils/typedActions\";\nimport { GroupsProvider, type GroupsActions } from \"./groups/Context\";\nimport { TreeProvider, type TreeActions } from \"./tree/Context\";\nimport { FocusProvider, type FocusActions } from \"./focus/Context\";\nimport { canSplitDirection, normalizeSplitLimits, type NormalizedSplitLimits } from \"./splitLimits\";\n\ntype ReducerExtra = {\n createGroupId: () => GroupId;\n splitLimits: NormalizedSplitLimits;\n createPanelId?: () => PanelId;\n};\n\nconst actions = {\n splitFocused: createAction(\"panelState/splitFocused\", (direction: SplitDirection) => ({ direction })),\n focusGroupIndex: createAction(\"panelState/focusGroupIndex\", (index1Based: number) => ({ index1Based })),\n focusNextGroup: createAction(\"panelState/focusNextGroup\"),\n focusPrevGroup: createAction(\"panelState/focusPrevGroup\"),\n setActiveTab: createAction(\"panelState/setActiveTab\", (groupId: GroupId, tabId: PanelId) => ({ groupId, tabId })),\n addTab: createAction(\n \"panelState/addTab\",\n (payload: { groupId: GroupId; tab: TabDefinition; index?: number; makeActive?: boolean }) => payload,\n ),\n addNewTab: createAction(\n \"panelState/addNewTab\",\n (payload: { groupId: GroupId; title: string; index?: number; makeActive?: boolean }) => payload,\n ),\n removeTab: createAction(\"panelState/removeTab\", (groupId: GroupId, tabId: PanelId) => ({ groupId, tabId })),\n contentDrop: createAction(\n \"panelState/contentDrop\",\n (payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; zone: DropZone }) => payload,\n ),\n tabDrop: createAction(\n \"panelState/tabDrop\",\n (payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; targetIndex: number }) => payload,\n ),\n adjustSplitRatio: createAction(\"panelState/adjustSplitRatio\", (payload: { path: NodePath; deltaRatio: number }) => payload),\n} as const;\n\ntype PanelStateAction = ReturnType<(typeof actions)[keyof typeof actions]>;\ntype PanelStateActions = BoundActionCreators<typeof actions>;\n\nconst handleContentDrop = (\n state: PanelSystemState,\n payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; zone: DropZone },\n extra: ReducerExtra,\n): PanelSystemState => {\n const fromGroup = state.groups[payload.fromGroupId];\n const targetGroup = state.groups[payload.targetGroupId];\n if (!fromGroup || !targetGroup) {\n return state;\n }\n const tab = fromGroup.tabs.find((t) => t.id === payload.tabId);\n if (!tab) {\n return state;\n }\n if (payload.zone === \"center\" && payload.fromGroupId === payload.targetGroupId) {\n return setActiveTab(state, payload.fromGroupId, payload.tabId);\n }\n if (payload.zone === \"center\") {\n const moved = moveTab(state, payload.fromGroupId, payload.targetGroupId, payload.tabId, true);\n return setFocusedGroup(moved, payload.targetGroupId);\n }\n const direction: SplitDirection = payload.zone === \"left\" || payload.zone === \"right\" ? \"vertical\" : \"horizontal\";\n if (!canSplitDirection(state.tree, payload.targetGroupId, direction, extra.splitLimits)) {\n return state;\n }\n const newGroupId = extra.createGroupId();\n const afterSplit = splitGroup(state, payload.targetGroupId, direction, () => newGroupId);\n const destination = payload.zone === \"left\" || payload.zone === \"top\" ? payload.targetGroupId : newGroupId;\n const withTab = moveTab(afterSplit, payload.fromGroupId, destination, payload.tabId, true);\n return setFocusedGroup(withTab, destination);\n};\n\nconst handleTabDrop = (\n state: PanelSystemState,\n payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; targetIndex: number },\n): PanelSystemState => {\n const fromGroup = state.groups[payload.fromGroupId];\n const targetGroup = state.groups[payload.targetGroupId];\n if (!fromGroup || !targetGroup) {\n return state;\n }\n const tab = state.panels[payload.tabId];\n if (!tab) {\n return state;\n }\n if (payload.fromGroupId === payload.targetGroupId) {\n const filteredIds = fromGroup.tabIds.filter((id) => id !== payload.tabId);\n const insertIndex = Math.max(0, Math.min(payload.targetIndex, filteredIds.length));\n const nextTabIds = filteredIds.slice(0, insertIndex).concat([payload.tabId], filteredIds.slice(insertIndex));\n const nextTabs = nextTabIds.map((id) => state.panels[id]).filter(Boolean);\n const groups = { ...state.groups, [payload.fromGroupId]: { ...fromGroup, tabIds: nextTabIds, tabs: nextTabs } };\n return { ...state, groups };\n }\n const groups = { ...state.groups };\n const sourceIds = fromGroup.tabIds.filter((id) => id !== payload.tabId);\n const sourceTabs = sourceIds.map((id) => state.panels[id]);\n groups[payload.fromGroupId] = {\n ...fromGroup,\n tabIds: sourceIds,\n tabs: sourceTabs,\n activeTabId: fromGroup.activeTabId === payload.tabId ? sourceTabs[0]?.id ?? null : fromGroup.activeTabId,\n };\n const targetIdsBase = targetGroup.tabIds.filter((id) => id !== payload.tabId);\n const bounded = Math.max(0, Math.min(payload.targetIndex, targetIdsBase.length));\n const nextTargetIds = targetIdsBase.slice(0, bounded).concat([payload.tabId], targetIdsBase.slice(bounded));\n const targetTabs = nextTargetIds.map((id) => state.panels[id]).filter(Boolean);\n groups[payload.targetGroupId] = { ...targetGroup, tabIds: nextTargetIds, tabs: targetTabs, activeTabId: payload.tabId };\n return { ...state, groups, focusedGroupId: payload.targetGroupId };\n};\n\nconst handlers = createActionHandlerMap<PanelSystemState, typeof actions, ReducerExtra>(actions, {\n splitFocused: (state, action, extra) => {\n const gid = state.focusedGroupId ?? state.groupOrder[0] ?? null;\n if (!gid) {\n return state;\n }\n if (!canSplitDirection(state.tree, gid, action.payload.direction, extra.splitLimits)) {\n return state;\n }\n return splitGroup(state, gid, action.payload.direction, extra.createGroupId);\n },\n focusGroupIndex: (state, action) => focusIdx(state, action.payload.index1Based),\n focusNextGroup: (state) => nextGroup(state),\n focusPrevGroup: (state) => prevGroup(state),\n setActiveTab: (state, action) => setActiveTab(state, action.payload.groupId, action.payload.tabId),\n addTab: (state, action) => {\n const { groupId, tab, index, makeActive } = action.payload;\n if (typeof index === \"number\") {\n return addTabToGroupAtIndex(state, groupId, tab, index, makeActive ?? true);\n }\n return addTabToGroup(state, groupId, tab, makeActive ?? true);\n },\n addNewTab: (state, action, extra) => {\n if (!extra.createPanelId) {\n throw new Error(\"addNewTab requires PanelSystemProvider.createPanelId\");\n }\n const id = extra.createPanelId();\n const tab: TabDefinition = { id, title: action.payload.title, render: () => action.payload.title };\n const { groupId, index, makeActive } = action.payload;\n if (typeof index === \"number\") {\n return addTabToGroupAtIndex(state, groupId, tab, index, makeActive ?? true);\n }\n return addTabToGroup(state, groupId, tab, makeActive ?? true);\n },\n removeTab: (state, action) => removeTabFromGroup(state, action.payload.groupId, action.payload.tabId),\n contentDrop: (state, action, extra) => handleContentDrop(state, action.payload, extra),\n tabDrop: (state, action) => handleTabDrop(state, action.payload),\n adjustSplitRatio: (state, action) => {\n const node = getAtPath(state.tree, action.payload.path);\n if (isGroup(node)) {\n return state;\n }\n const nextTree = setSplitRatio(state.tree, action.payload.path, node.ratio + action.payload.deltaRatio);\n return { ...state, tree: nextTree };\n },\n});\n\nconst reducePanelState = (state: PanelSystemState, action: PanelStateAction, extra: ReducerExtra): PanelSystemState => {\n const handler = handlers[action.type];\n if (!handler) {\n return state;\n }\n const next = handler(state, action, extra);\n return cleanupEmptyGroups(next);\n};\n\nexport type PanelSystemContextValue = {\n state: PanelSystemState;\n dispatch: (action: PanelStateAction) => void;\n actions: PanelStateActions;\n};\n\nconst PanelSystemContext = React.createContext<PanelSystemContextValue | null>(null);\n\nexport const usePanelSystem = (): PanelSystemContextValue => {\n const ctx = React.useContext(PanelSystemContext);\n if (!ctx) {\n throw new Error(\"usePanelSystem must be used within PanelSystemProvider\");\n }\n return ctx;\n};\n\nexport type PanelSystemProviderProps = React.PropsWithChildren<{\n initialState: PanelSystemState;\n createGroupId: () => GroupId;\n createPanelId?: () => PanelId;\n state?: PanelSystemState;\n onStateChange?: (next: PanelSystemState) => void;\n splitLimits?: PanelSplitLimits;\n}>;\n\nexport const PanelSystemProvider: React.FC<PanelSystemProviderProps> = ({\n initialState,\n createGroupId,\n createPanelId,\n state: controlled,\n onStateChange,\n splitLimits,\n children,\n}) => {\n const initialSanitized = React.useMemo(() => cleanupEmptyGroups(initialState), [initialState]);\n const normalizedSplitLimits = React.useMemo(() => normalizeSplitLimits(splitLimits), [splitLimits]);\n const extraRef = React.useRef<ReducerExtra>({ createGroupId, splitLimits: normalizedSplitLimits, createPanelId });\n extraRef.current.createGroupId = createGroupId;\n extraRef.current.splitLimits = normalizedSplitLimits;\n extraRef.current.createPanelId = createPanelId;\n const [uncontrolled, baseDispatch] = React.useReducer(\n (prev: PanelSystemState, action: PanelStateAction) => reducePanelState(prev, action, extraRef.current),\n initialSanitized,\n );\n const derivedState = React.useMemo(\n () => (controlled ? cleanupEmptyGroups(controlled) : uncontrolled),\n [controlled, uncontrolled],\n );\n const stateRef = React.useRef<PanelSystemState>(derivedState);\n stateRef.current = derivedState;\n const isControlled = controlled !== undefined;\n\n const dispatch = React.useCallback(\n (action: PanelStateAction) => {\n if (isControlled) {\n const next = reducePanelState(stateRef.current, action, extraRef.current);\n onStateChange?.(next);\n return;\n }\n baseDispatch(action);\n },\n [isControlled, onStateChange, baseDispatch],\n );\n\n const boundActions = React.useMemo<PanelStateActions>(() => bindActionCreators(actions, dispatch), [dispatch]);\n\n const groupsActions = React.useMemo<GroupsActions>(\n () => ({\n setActiveTab: boundActions.setActiveTab,\n tabDrop: boundActions.tabDrop,\n }),\n [boundActions],\n );\n\n const treeActions = React.useMemo<TreeActions>(\n () => ({\n adjustSplitRatio: boundActions.adjustSplitRatio,\n }),\n [boundActions],\n );\n\n const focusActions = React.useMemo<FocusActions>(\n () => ({\n focusGroupIndex: boundActions.focusGroupIndex,\n focusNextGroup: boundActions.focusNextGroup,\n focusPrevGroup: boundActions.focusPrevGroup,\n }),\n [boundActions],\n );\n\n const value = React.useMemo<PanelSystemContextValue>(\n () => ({\n state: derivedState,\n dispatch,\n actions: boundActions,\n }),\n [derivedState, dispatch, boundActions],\n );\n\n return (\n <PanelSystemContext.Provider value={value}>\n <GroupsProvider value={groupsActions}>\n <TreeProvider value={treeActions}>\n <FocusProvider value={focusActions}>{children}</FocusProvider>\n </TreeProvider>\n </GroupsProvider>\n </PanelSystemContext.Provider>\n );\n};\n\nexport type { PanelStateAction, PanelStateActions };\n","/**\n * @file Hooks that expose commands and commit handlers for the panel system.\n */\nimport * as React from \"react\";\nimport type { DropZone, PanelCommands } from \"../state/types\";\nimport { usePanelState } from \"../state/StateContext\";\n\nexport const usePanelCommands = (): PanelCommands => {\n const { actions } = usePanelState();\n return React.useMemo<PanelCommands>(\n () => ({\n splitFocused: (direction) => {\n actions.splitFocused(direction);\n },\n focusGroupIndex: (n) => {\n actions.focusGroupIndex(n);\n },\n focusNextGroup: () => {\n actions.focusNextGroup();\n },\n focusPrevGroup: () => {\n actions.focusPrevGroup();\n },\n closeFocusedGroup: () => {\n // intentionally no-op for now\n },\n }),\n [actions],\n );\n};\n\nexport const useCommitHandlers = (): {\n onCommitContentDrop: (payload: { fromGroupId: string; tabId: string; targetGroupId: string; zone: DropZone }) => void;\n onCommitTabDrop: (payload: { fromGroupId: string; tabId: string; targetGroupId: string; targetIndex: number }) => void;\n} => {\n const { actions } = usePanelState();\n\n const onCommitContentDrop = React.useCallback(\n ({ fromGroupId, tabId, targetGroupId, zone }: { fromGroupId: string; tabId: string; targetGroupId: string; zone: DropZone }) => {\n actions.contentDrop({ fromGroupId, tabId, targetGroupId, zone });\n },\n [actions],\n );\n\n const onCommitTabDrop = React.useCallback(\n ({ fromGroupId, tabId, targetGroupId, targetIndex }: { fromGroupId: string; tabId: string; targetGroupId: string; targetIndex: number }) => {\n actions.tabDrop({ fromGroupId, tabId, targetGroupId, targetIndex });\n },\n [actions],\n );\n\n return { onCommitContentDrop, onCommitTabDrop };\n};\n","/**\n * @file Registers default keybindings using the single-source commands.\n */\nimport * as React from \"react\";\nimport { useKeybindings, registerDefaultBindings } from \"../../keybindings/KeybindingsProvider\";\nimport { usePanelCommands } from \"../state/commands\";\n\nexport const DefaultKeybindingsInstaller: React.FC = () => {\n const api = useKeybindings();\n const commands = usePanelCommands();\n React.useEffect(() => {\n registerDefaultBindings(api, commands);\n }, [api, commands]);\n return null;\n};\n","/**\n * @file Registry for panel content instances.\n * Manages component lifecycle to preserve state across tab switches and panel moves.\n *\n * ## Architecture\n *\n * This module solves the problem of preserving React component state when panels\n * move between different container elements (groups).\n *\n * ### The Problem\n * React portals remount their content when the container element changes.\n * This is React's intentional behavior, but it causes state loss when panels move.\n *\n * ### The Solution\n * 1. Create a stable wrapper element per panel (outside React's tree management)\n * 2. Use createPortal to render React content INTO the wrapper\n * 3. Move the wrapper between containers using appendChild\n *\n * This works because:\n * - React only manages content INSIDE the wrapper (via portal)\n * - React doesn't track the wrapper's position in DOM\n * - Moving the wrapper doesn't trigger React reconciliation\n *\n * ### DOM API Usage\n * - document.createElement: Creates wrapper element (once per panel)\n * - appendChild: Moves wrapper to target container\n * - removeChild: Cleans up wrapper on unmount\n *\n * These are the minimum DOM APIs required. React features handle everything else.\n */\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { PanelId, GroupId, TabDefinition } from \"../state/types\";\nimport { useIsomorphicLayoutEffect } from \"../../../hooks/useIsomorphicLayoutEffect\";\n\ntype PanelPlacement = {\n groupId: GroupId;\n isActive: boolean;\n};\n\ntype ContentRegistryContextValue = {\n registerContentContainer: (groupId: GroupId, element: HTMLElement | null) => void;\n};\n\nconst ContentRegistryContext = React.createContext<ContentRegistryContextValue | null>(null);\n\nexport const useContentRegistry = (): ContentRegistryContextValue => {\n const ctx = React.useContext(ContentRegistryContext);\n if (!ctx) {\n throw new Error(\"useContentRegistry must be used within ContentRegistryProvider\");\n }\n return ctx;\n};\n\n/**\n * Creates a wrapper element for panel content.\n * This element lives outside React's tree management so it can be moved freely.\n */\nconst createPanelWrapper = (panelId: PanelId): HTMLDivElement => {\n const wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"data-panel-wrapper\", panelId);\n wrapper.style.display = \"contents\";\n return wrapper;\n};\n\n/**\n * Hook to manage wrapper element lifecycle and positioning.\n *\n * Uses React.useState for lazy initialization (wrapper created once).\n * Uses useIsomorphicLayoutEffect for DOM manipulation (SSR-safe).\n */\nconst usePanelWrapper = (\n panelId: PanelId,\n containerElement: HTMLElement | null,\n isActive: boolean,\n): HTMLDivElement => {\n // Create wrapper once using React's lazy state initialization\n const [wrapper] = React.useState(() => createPanelWrapper(panelId));\n\n // Manage wrapper position and visibility\n useIsomorphicLayoutEffect(() => {\n wrapper.style.display = isActive ? \"contents\" : \"none\";\n\n if (containerElement && wrapper.parentElement !== containerElement) {\n containerElement.appendChild(wrapper);\n }\n\n return () => {\n wrapper.parentElement?.removeChild(wrapper);\n };\n }, [wrapper, containerElement, isActive]);\n\n return wrapper;\n};\n\n/**\n * Host component for panel content.\n * Uses createPortal to render React content into a stable wrapper element.\n */\ntype PanelContentHostProps = {\n panelId: PanelId;\n content: React.ReactNode;\n placement: PanelPlacement | null;\n containerElement: HTMLElement | null;\n};\n\nconst PanelContentHost: React.FC<PanelContentHostProps> = React.memo(\n ({ panelId, content, placement, containerElement }) => {\n const isActive = placement?.isActive ?? false;\n const wrapper = usePanelWrapper(panelId, containerElement, isActive);\n\n // Portal renders React content INTO the wrapper\n // React manages content lifecycle, not wrapper position\n return createPortal(\n <React.Activity mode={isActive ? \"visible\" : \"hidden\"}>\n {content}\n </React.Activity>,\n wrapper,\n );\n },\n);\nPanelContentHost.displayName = \"PanelContentHost\";\n\ntype ContentRegistryProviderProps = React.PropsWithChildren<{\n panels: Record<PanelId, TabDefinition>;\n placements: Record<PanelId, PanelPlacement>;\n}>;\n\n/**\n * Provider that manages panel content lifecycle.\n * Caches rendered content per panel to preserve React element identity.\n */\nexport const ContentRegistryProvider: React.FC<ContentRegistryProviderProps> = ({\n children,\n panels,\n placements,\n}) => {\n const [containers, setContainers] = React.useState<Map<GroupId, HTMLElement>>(new Map());\n const contentCacheRef = React.useRef<Map<PanelId, React.ReactNode>>(new Map());\n\n const registerContentContainer = React.useCallback((groupId: GroupId, element: HTMLElement | null): void => {\n setContainers((prev) => {\n const next = new Map(prev);\n if (element) {\n next.set(groupId, element);\n } else {\n next.delete(groupId);\n }\n return next;\n });\n }, []);\n\n const value = React.useMemo<ContentRegistryContextValue>(\n () => ({ registerContentContainer }),\n [registerContentContainer],\n );\n\n const getOrCreateContent = React.useCallback((panelId: PanelId, tab: TabDefinition): React.ReactNode => {\n const cached = contentCacheRef.current.get(panelId);\n if (cached) {\n return cached;\n }\n const newContent = tab.render(tab.id);\n contentCacheRef.current.set(panelId, newContent);\n return newContent;\n }, []);\n\n const panelIds = Object.keys(panels);\n\n return (\n <ContentRegistryContext.Provider value={value}>\n {children}\n {panelIds.map((panelId) => {\n const tab = panels[panelId];\n if (!tab) {\n return null;\n }\n const placement = placements[panelId] ?? null;\n const containerElement = placement ? containers.get(placement.groupId) ?? null : null;\n const content = getOrCreateContent(panelId, tab);\n return (\n <PanelContentHost\n key={panelId}\n panelId={panelId}\n content={content}\n placement={placement}\n containerElement={containerElement}\n />\n );\n })}\n </ContentRegistryContext.Provider>\n );\n};\n","/**\n * @file Bridge component that binds InteractionsContext to PanelRenderContext using panel state.\n */\nimport * as React from \"react\";\nimport { usePanelInteractions } from \"../interactions/InteractionsContext\";\nimport { PanelRenderProvider } from \"./RenderContext\";\nimport { usePanelState } from \"../state/StateContext\";\nimport { ContentRegistryProvider, useContentRegistry } from \"./ContentRegistry\";\nimport type { PanelId, GroupId } from \"../state/types\";\n\ntype PanelPlacement = {\n groupId: GroupId;\n isActive: boolean;\n};\n\nconst RenderBridgeInner: React.FC<React.PropsWithChildren<{ emptyContentComponent?: React.ComponentType; doubleClickToAdd?: boolean }>> = ({\n children,\n emptyContentComponent,\n doubleClickToAdd,\n}) => {\n const interactions = usePanelInteractions();\n const { state, actions } = usePanelState();\n const { registerContentContainer } = useContentRegistry();\n\n const DefaultEmpty: React.FC = React.useCallback(() => {\n return React.createElement(\"div\", { style: { color: \"#888\", fontSize: 12, padding: 12 } }, \"No tabs\");\n }, []);\n const Empty = emptyContentComponent ?? DefaultEmpty;\n\n const getGroup = React.useCallback(\n (id: string) => {\n const g = state.groups[id];\n if (!g) {\n return null;\n }\n const tabs = g.tabIds.map((tid) => state.panels[tid]).filter(Boolean);\n return { ...g, tabs };\n },\n [state.groups, state.panels],\n );\n\n const getGroupContent = React.useCallback(\n (id: string) => {\n const group = state.groups[id];\n if (!group || group.tabIds.length === 0) {\n return <Empty />;\n }\n // Content is rendered via Portal from ContentRegistry\n return null;\n },\n [state.groups, Empty],\n );\n\n const onClickTab = React.useCallback((gid: string, tabId: string) => {\n actions.setActiveTab(gid, tabId);\n }, [actions]);\n\n const onAddTab = React.useCallback((gid: string) => {\n actions.addNewTab({ groupId: gid, title: \"New Tab\", makeActive: true });\n }, [actions]);\n\n const onCloseTab = React.useCallback((gid: string, tabId: string) => {\n actions.removeTab(gid, tabId);\n }, [actions]);\n\n const onStartTabDrag = React.useCallback((tabId: string, groupId: string, e: React.PointerEvent) => {\n actions.setActiveTab(groupId, tabId);\n interactions.onStartTabDrag(tabId, groupId, e);\n }, [actions, interactions]);\n\n const onStartContentDrag = React.useCallback((groupId: string, e: React.PointerEvent<HTMLDivElement>) => {\n const g = state.groups[groupId];\n if (!g || !g.activeTabId) {\n return;\n }\n interactions.onStartContentDrag(groupId, g.activeTabId, e);\n }, [state.groups, interactions]);\n\n const value = React.useMemo(\n () => ({ getGroup, getGroupContent, onClickTab, onAddTab, onCloseTab, onStartTabDrag, onStartContentDrag, doubleClickToAdd, registerContentContainer }),\n [getGroup, getGroupContent, onClickTab, onAddTab, onCloseTab, onStartTabDrag, onStartContentDrag, doubleClickToAdd, registerContentContainer],\n );\n\n return <PanelRenderProvider value={value}>{children}</PanelRenderProvider>;\n};\n\nexport const RenderBridge: React.FC<React.PropsWithChildren<{ emptyContentComponent?: React.ComponentType; doubleClickToAdd?: boolean }>> = ({\n children,\n emptyContentComponent,\n doubleClickToAdd,\n}) => {\n const { state } = usePanelState();\n\n // Compute placements: which group each panel belongs to and if it's active\n const placements = React.useMemo(() => {\n const result: Record<PanelId, PanelPlacement> = {};\n for (const [groupId, group] of Object.entries(state.groups)) {\n for (const tabId of group.tabIds) {\n result[tabId] = {\n groupId,\n isActive: tabId === group.activeTabId,\n };\n }\n }\n return result;\n }, [state.groups]);\n\n return (\n <ContentRegistryProvider panels={state.panels} placements={placements}>\n <RenderBridgeInner emptyContentComponent={emptyContentComponent} doubleClickToAdd={doubleClickToAdd}>\n {children}\n </RenderBridgeInner>\n </ContentRegistryProvider>\n );\n};\n","/**\n * @file Connected split handles overlay.\n */\nimport * as React from \"react\";\nimport type { PanelTree } from \"../../panels/state/types\";\nimport type { NodePath, PathSegment } from \"../../panels/state/tree/logic\";\nimport { isGroup } from \"../../panels/state/tree/logic\";\nimport { usePanelState } from \"../../panels/state/StateContext\";\nimport { useTree } from \"../../panels/state/tree/Context\";\nimport { ResizeHandle } from \"../../../components/resizer/ResizeHandle\";\nimport { SPLIT_HANDLE_THICKNESS } from \"../../../constants/styles\";\nimport { useIsomorphicLayoutEffect } from \"../../../hooks/useIsomorphicLayoutEffect\";\n\ntype Rect = { x: number; y: number; w: number; h: number };\n\ntype Handle = {\n path: NodePath;\n direction: \"vertical\" | \"horizontal\";\n parentRect: Rect;\n linePos: number;\n};\n\nconst collectHandles = (node: PanelTree, path: NodePath, rect: Rect, acc: Handle[]): Handle[] => {\n if (isGroup(node)) {\n return acc;\n }\n const direction = node.direction;\n const linePos = direction === \"vertical\" ? rect.x + rect.w * node.ratio : rect.y + rect.h * node.ratio;\n acc.push({ path, direction, parentRect: rect, linePos });\n if (direction === \"vertical\") {\n const wA = rect.w * node.ratio;\n const wB = rect.w - wA;\n collectHandles(node.a, [...path, \"a\" as PathSegment], { x: rect.x, y: rect.y, w: wA, h: rect.h }, acc);\n collectHandles(node.b, [...path, \"b\" as PathSegment], { x: rect.x + wA, y: rect.y, w: wB, h: rect.h }, acc);\n return acc;\n }\n const hA = rect.h * node.ratio;\n const hB = rect.h - hA;\n collectHandles(node.a, [...path, \"a\" as PathSegment], { x: rect.x, y: rect.y, w: rect.w, h: hA }, acc);\n collectHandles(node.b, [...path, \"b\" as PathSegment], { x: rect.x, y: rect.y + hA, w: rect.w, h: hB }, acc);\n return acc;\n};\n\nexport type PanelSplitHandlesProps = { containerRef: React.RefObject<HTMLDivElement | null> };\n\nexport const PanelSplitHandles: React.FC<PanelSplitHandlesProps> = ({ containerRef }) => {\n const { state } = usePanelState();\n const { adjustSplitRatio } = useTree();\n\n const handles = React.useMemo(() => collectHandles(state.tree, [], { x: 0, y: 0, w: 100, h: 100 }, []), [state.tree]);\n\n // Measure container rect after layout to avoid reading stale geometry during render\n const [containerRect, setContainerRect] = React.useState<Pick<DOMRect, \"left\" | \"top\" | \"width\" | \"height\"> | null>(null);\n useIsomorphicLayoutEffect(() => {\n const el = containerRef.current;\n if (!el) {\n return;\n }\n const measure = (): void => {\n const r = el.getBoundingClientRect();\n setContainerRect({ left: r.left, top: r.top, width: r.width, height: r.height });\n };\n measure();\n function getResizeObserverCtor(): typeof ResizeObserver | null {\n try {\n const ctor = (window as { ResizeObserver?: typeof ResizeObserver }).ResizeObserver;\n return typeof ctor === \"function\" ? ctor : null;\n } catch {\n return null;\n }\n }\n const RO = getResizeObserverCtor();\n const ro: ResizeObserver | null = RO ? new RO(() => measure()) : null;\n if (ro) {\n ro.observe(el);\n }\n const onScroll = (): void => measure();\n window.addEventListener(\"scroll\", onScroll, true);\n return () => {\n window.removeEventListener(\"scroll\", onScroll, true);\n if (ro) {\n ro.disconnect();\n }\n };\n }, [containerRef, state.tree]);\n if (!containerRect) {\n return null;\n }\n\n const renderHandle = (handle: Handle, index: number): React.ReactNode => {\n // Compute viewport-fixed coordinates by adding container offsets\n const parentPx = {\n left: containerRect.left + (containerRect.width * handle.parentRect.x) / 100,\n top: containerRect.top + (containerRect.height * handle.parentRect.y) / 100,\n width: (containerRect.width * handle.parentRect.w) / 100,\n height: (containerRect.height * handle.parentRect.h) / 100,\n };\n\n const thickness = SPLIT_HANDLE_THICKNESS;\n\n if (handle.direction === \"vertical\") {\n const x = parentPx.left + (parentPx.width * (handle.linePos - handle.parentRect.x)) / handle.parentRect.w;\n const style: React.CSSProperties = {\n position: \"fixed\",\n left: `calc(${Math.round(x)}px - ${thickness} / 2)`,\n top: Math.round(parentPx.top),\n width: thickness,\n height: Math.round(parentPx.height),\n cursor: \"col-resize\",\n pointerEvents: \"auto\",\n };\n const onResize = (delta: number): void => {\n const parentWidth = (containerRect.width * handle.parentRect.w) / 100;\n const dRatio = parentWidth === 0 ? 0 : delta / parentWidth;\n adjustSplitRatio({ path: handle.path, deltaRatio: dRatio });\n };\n return (\n <div key={`split-${index}`} style={style}>\n <ResizeHandle direction=\"vertical\" onResize={onResize} />\n </div>\n );\n }\n\n const y = parentPx.top + (parentPx.height * (handle.linePos - handle.parentRect.y)) / handle.parentRect.h;\n const style: React.CSSProperties = {\n position: \"fixed\",\n left: Math.round(parentPx.left),\n top: `calc(${Math.round(y)}px - ${thickness} / 2)`,\n width: Math.round(parentPx.width),\n height: thickness,\n cursor: \"row-resize\",\n pointerEvents: \"auto\",\n };\n const onResize = (delta: number): void => {\n const parentHeight = (containerRect.height * handle.parentRect.h) / 100;\n const dRatio = parentHeight === 0 ? 0 : delta / parentHeight;\n adjustSplitRatio({ path: handle.path, deltaRatio: dRatio });\n };\n return (\n <div key={`split-${index}`} style={style}>\n <ResizeHandle direction=\"horizontal\" onResize={onResize} />\n </div>\n );\n };\n\n return <div style={{ position: \"fixed\", inset: 0, pointerEvents: \"none\" }}>{handles.map((h, idx) => renderHandle(h, idx))}</div>;\n};\n","/**\n * @file VSCode-like PanelSystem composed via module contexts and presentational components.\n */\nimport * as React from \"react\";\nimport type { DropZone, GroupId, PanelSystemProps, PanelSystemState } from \"../state/types\";\nimport { KeybindingsProvider } from \"../../keybindings/KeybindingsProvider\";\nimport { buildGridForAbsolutePanels, buildGridFromRects } from \"../layout/adapter\";\nimport { GridLayout } from \"../../../components/grid/GridLayout\";\nimport { GroupContainer } from \"../rendering/GroupContainer\";\nimport { InteractionsProvider, usePanelInteractions } from \"../interactions/InteractionsContext\";\nimport { DropSuggestOverlay } from \"../../../components/panels/DropSuggestOverlay\";\nimport { TabDragOverlay } from \"../../../components/tabs/TabDragOverlay\";\nimport { PanelStateProvider, usePanelState } from \"../state/StateContext\";\nimport { DefaultKeybindingsInstaller } from \"../keybindings/KeybindingsInstaller\";\nimport { useCommitHandlers } from \"../state/commands\";\nimport { RenderBridge } from \"../rendering/RenderBridge\";\nimport { DomRegistryProvider } from \"../dom/DomRegistry\";\nimport { PanelSplitHandles } from \"../state/PanelSplitHandles\";\nimport { canSplitDirection, normalizeSplitLimits, type NormalizedSplitLimits } from \"../state/splitLimits\";\n\nconst rootStyle: React.CSSProperties = {\n position: \"relative\",\n display: \"flex\",\n width: \"100%\",\n height: \"100%\",\n};\n\ntype PanelSystemContentProps = {\n containerRef: React.RefObject<HTMLDivElement | null>;\n layoutMode: PanelSystemProps[\"layoutMode\"];\n gridTracksInteractive?: boolean;\n dragThresholdPx: number;\n view?: PanelSystemProps[\"view\"];\n style?: React.CSSProperties;\n className?: string;\n tabBarComponent?: PanelSystemProps[\"tabBarComponent\"];\n panelGroupComponent?: PanelSystemProps[\"panelGroupComponent\"];\n splitLimits: NormalizedSplitLimits;\n emptyContentComponent?: PanelSystemProps[\"emptyContentComponent\"];\n doubleClickToAdd?: boolean;\n};\n\nconst GridLayoutRenderer = ({\n state,\n layoutMode,\n gridTracksInteractive,\n view,\n tabBarComponent,\n panelGroupComponent,\n}: {\n state: PanelSystemState;\n layoutMode: PanelSystemProps[\"layoutMode\"];\n gridTracksInteractive: PanelSystemProps[\"gridTracksInteractive\"];\n view: PanelSystemProps[\"view\"];\n tabBarComponent: PanelSystemProps[\"tabBarComponent\"];\n panelGroupComponent: PanelSystemProps[\"panelGroupComponent\"];\n}): React.ReactNode => {\n const renderGroup = (gid: GroupId): React.ReactNode => {\n if (view) {\n const ViewComponent = view;\n return <ViewComponent groupId={gid} />;\n }\n return <GroupContainer id={gid} TabBarComponent={tabBarComponent} PanelGroupComponent={panelGroupComponent} />;\n };\n if (layoutMode === \"grid\") {\n const grid = buildGridFromRects(state, renderGroup, Boolean(gridTracksInteractive));\n return <GridLayout config={grid.config} layers={grid.layers} />;\n }\n const grid = buildGridForAbsolutePanels(state, renderGroup);\n return <GridLayout config={grid.config} layers={grid.layers} />;\n};\n\nconst PanelSystemContent: React.FC<PanelSystemContentProps> = ({\n containerRef,\n layoutMode,\n gridTracksInteractive,\n dragThresholdPx,\n view,\n style,\n className,\n tabBarComponent,\n panelGroupComponent,\n splitLimits,\n emptyContentComponent,\n doubleClickToAdd,\n}) => {\n const { state } = usePanelState();\n const { onCommitContentDrop, onCommitTabDrop } = useCommitHandlers();\n\n const containerStyle = React.useMemo(() => ({ ...rootStyle, ...style }), [style]);\n\n const isZoneAllowed = React.useCallback(\n ({ targetGroupId, zone }: { targetGroupId: GroupId; zone: DropZone }): boolean => {\n if (zone === \"center\") {\n return true;\n }\n const direction = zone === \"left\" || zone === \"right\" ? \"vertical\" : \"horizontal\";\n return canSplitDirection(state.tree, targetGroupId, direction, splitLimits);\n },\n [state.tree, splitLimits],\n );\n\n return (\n <DomRegistryProvider>\n <InteractionsProvider\n containerRef={containerRef}\n dragThresholdPx={dragThresholdPx}\n onCommitContentDrop={onCommitContentDrop}\n onCommitTabDrop={onCommitTabDrop}\n isContentZoneAllowed={isZoneAllowed}\n >\n <RenderBridge emptyContentComponent={emptyContentComponent} doubleClickToAdd={doubleClickToAdd}>\n <div ref={containerRef} className={className} style={containerStyle}>\n <GridLayoutRenderer\n state={state}\n layoutMode={layoutMode}\n gridTracksInteractive={gridTracksInteractive}\n view={view}\n tabBarComponent={tabBarComponent}\n panelGroupComponent={panelGroupComponent}\n />\n </div>\n </RenderBridge>\n <PanelSplitHandles containerRef={containerRef} />\n <OverlayWithinProvider />\n </InteractionsProvider>\n </DomRegistryProvider>\n );\n};\n\nconst OverlayWithinProvider: React.FC = () => {\n const interactions = usePanelInteractions();\n return (\n <>\n <DropSuggestOverlay suggest={interactions.suggest} />\n <TabDragOverlay />\n </>\n );\n};\n\nexport const PanelSystem: React.FC<PanelSystemProps> = ({\n initialState,\n createGroupId,\n createPanelId,\n layoutMode,\n gridTracksInteractive,\n dragThresholdPx,\n view,\n emptyContentComponent,\n state: controlled,\n onStateChange,\n className,\n style,\n tabBarComponent,\n panelGroupComponent,\n splitLimits,\n doubleClickToAdd,\n}) => {\n if (!initialState) {\n throw new Error(\"PanelSystem requires initialState.\");\n }\n if (!createGroupId) {\n throw new Error(\"PanelSystem requires explicit createGroupId function.\");\n }\n if (!layoutMode) {\n throw new Error(\"PanelSystem requires explicit layoutMode ('absolute' | 'grid').\");\n }\n if (layoutMode === \"grid\" && gridTracksInteractive === undefined) {\n throw new Error(\"PanelSystem(layoutMode='grid') requires explicit 'gridTracksInteractive' flag.\");\n }\n if (dragThresholdPx === undefined) {\n throw new Error(\"PanelSystem requires explicit 'dragThresholdPx' value.\");\n }\n\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n const normalizedSplitLimits = React.useMemo(() => normalizeSplitLimits(splitLimits), [splitLimits]);\n\n return (\n <PanelStateProvider\n initialState={initialState}\n createGroupId={createGroupId}\n createPanelId={createPanelId}\n state={controlled}\n onStateChange={onStateChange}\n splitLimits={splitLimits}\n >\n <KeybindingsProvider>\n <DefaultKeybindingsInstaller />\n <PanelSystemContent\n containerRef={containerRef}\n layoutMode={layoutMode}\n gridTracksInteractive={gridTracksInteractive}\n dragThresholdPx={dragThresholdPx}\n view={view}\n style={style}\n className={className}\n tabBarComponent={tabBarComponent}\n panelGroupComponent={panelGroupComponent}\n splitLimits={normalizedSplitLimits}\n emptyContentComponent={emptyContentComponent}\n doubleClickToAdd={doubleClickToAdd}\n />\n </KeybindingsProvider>\n </PanelStateProvider>\n );\n};\n"],"names":["buildDividerStyle","state","HORIZONTAL_DIVIDER_WIDTH","COLOR_RESIZE_HANDLE_ACTIVE","COLOR_RESIZE_HANDLE_HOVER","COLOR_RESIZE_HANDLE_IDLE","HorizontalDivider","onResize","Component","element","ref","isDragging","onPointerDown","useResizeDrag","hovered","setHovered","React","dividerProps","jsx","useLayerDragHandle","layerId","useLayerInstance","getLayerHandleProps","useGridLayoutContext","DEFAULT_POSITION","DEFAULT_SIZE","useFloatingState","layers","floatingStates","setFloatingStates","initial","layer","floating","layerMap","map","getPosition","getSize","getZIndex","updatePosition","position","prev","currentState","updateSize","size","close","KeybindingsContext","useKeybindings","ctx","normalizeEventToCombo","e","parts","key","KeybindingsProvider","children","configure","handlersRef","register","combo","handler","unregister","rest","onKeyDown","api","registerDefaultBindings","commands","isGroup","node","computeRects","bounds","result","walk","n","rect","wA","wB","hA","hB","buildGridForAbsolutePanels","renderGroup","rects","config","groupId","r","style","buildGridFromRects","interactiveTracks","xs","a","b","ys","colSizes","x","i","rowSizes","y","columns","rows","areaForCell","x0","x1","y0","y1","gid","areas","ri","row","ci","PanelRenderContext","usePanelRenderContext","PanelRenderProvider","value","DomRegistryContext","useDomRegistry","DomRegistryProvider","mapRef","ensure","current","next","setGroupEl","el","v","setTabbarEl","setContentEl","getAll","groupStyle","contentStyle","createContentNode","contentElement","ContentComponent","contentProps","content","createGroupNode","GroupComponent","groupProps","groupContent","RawPanelGroupView","group","tabbar","onContentPointerDown","groupRef","contentRef","contentNode","jsxs","Fragment","PanelGroupView","pickDropZone","left","top","width","height","localX","localY","thirdW","thirdH","createAction","type","payloadCreator","actionCreator","args","payload","bindActionCreators","creators","dispatch","bound","creator","action","createActionHandlerMap","handlers","initialState","actions","reducerHandlers","_state","reducer","InteractionsContext","usePanelInteractions","InteractionsProvider","containerRef","dragThresholdPx","onCommitContentDrop","onCommitTabDrop","isContentZoneAllowed","dom","captureLayout","all","groups","els","it","tabbars","contents","onMove","useEffectEvent","ev","phase","dx","dy","candidate","zone","tabbarHit","btnRects","centers","firstIdx","c","targetIndex","insertX","onUp","container","snapshot","hit","targetGroupId","btn","contentHit","onCancel","onStartContentDrag","tabId","cache","onStartTabDrag","target","tabStyle","TabBarTab","tab","active","dragging","onClickTab","onStartDrag","onCloseTab","TabComponent","tabElement","onDoubleClick","handleClick","handlePointerDown","renderCloseButton","hasClose","divProps","buttonProps","tabbarStyle","spacerStyle","TabBar","rootRef","ContainerComponent","onAddTab","doubleClickToAdd","isTabDragging","draggingTabId","localRef","setRefs","handleKeyDown","root","tabs","focusTabAt","index","clamped","activeEl","currentIndex","id","hasModifier","keyLower","containerProps","Wrapper","useElementComponentWrapper","renderAddButton","handleTabbarDoubleClick","GroupContainer","TabBarComponent","PanelGroupComponent","getGroup","getGroupContent","registerContentContainer","tabbarRef","props","multiplyMatrices","col","createMatrix","values","m","applyTransform","transformValues","z","angle","len","s","t","angleX","angleY","tanX","tanY","distance","matrix","overlayStyle","DROP_SUGGEST_Z_INDEX","suggestRectBaseStyle","DROP_SUGGEST_BORDER_WIDTH","DROP_SUGGEST_BORDER_COLOR","DROP_SUGGEST_BG_COLOR","DROP_SUGGEST_BORDER_RADIUS","safeRatio","base","clampNumber","buildZoneTransform","pad","halfPad","widthBase","heightBase","center","right","bottom","zoneTransforms","translateX","translateY","scaleX","scaleY","buildSuggestStyle","DROP_SUGGEST_PADDING_PX","DropSuggestOverlay","suggest","isBrowser","useClonedElementPreview","sourceEl","setSize","html","setHtml","useIsomorphicLayoutEffect","TAB_DRAG_OVERLAY_Z_INDEX","insertGuideBaseStyle","TAB_DRAG_INSERT_GUIDE_WIDTH","TAB_DRAG_INSERT_GUIDE_BORDER_RADIUS","TAB_DRAG_INSERT_GUIDE_COLOR","TAB_DRAG_INSERT_GUIDE_SHADOW","TabDragOverlay","dragPointer","tabbarHover","draggingTabElement","previewHtml","previewSize","hasPreview","previewBaseStyle","TAB_DRAG_PREVIEW_OFFSET_X","TAB_DRAG_PREVIEW_OFFSET_Y","previewStyle","guideStyle","collectGroupsInOrder","acc","getAtPath","path","setAtPath","head","findLeafParent","inA","splitLeaf","direction","createGroupId","newGroupId","entry","replacement","parentPath","parent","newParent","closeLeaf","survivor","newTree","survivorId","setSplitRatio","splitPath","ratio","cleanupEmptyGroups","removeIfEmpty","tree","survivorGroupId","_removed","restGroups","groupOrder","focusedGroupId","createEmptyGroup","addTabToGroup","makeActive","panels","tabIds","activeTabId","nextGroup","removeTabFromGroup","moveTab","fromGroupId","toGroupId","from","to","fromIds","toIds","fromActive","setActiveTab","addTabToGroupAtIndex","ids","boundedIndex","setFocusedGroup","focusGroupIndex","index1Based","idx","order","first","prevGroup","last","splitGroup","buildInitialState","GroupsContext","GroupsProvider","TreeContext","useTree","TreeProvider","FocusContext","FocusProvider","clampLimit","finite","toFiniteNumberOr","isObjectLimits","limits","isRowsColsLimits","normalizeSplitLimits","normalized","legacy","measureSplitExtents","previewSplitTree","preview","canSplitDirection","extents","handleContentDrop","extra","fromGroup","targetGroup","moved","afterSplit","destination","withTab","handleTabDrop","filteredIds","insertIndex","nextTabIds","nextTabs","sourceIds","sourceTabs","targetIdsBase","bounded","nextTargetIds","targetTabs","focusIdx","nextTree","reducePanelState","PanelSystemContext","usePanelSystem","PanelSystemProvider","createPanelId","controlled","onStateChange","splitLimits","initialSanitized","normalizedSplitLimits","extraRef","uncontrolled","baseDispatch","derivedState","stateRef","isControlled","boundActions","groupsActions","treeActions","focusActions","usePanelCommands","usePanelState","useCommitHandlers","DefaultKeybindingsInstaller","ContentRegistryContext","useContentRegistry","createPanelWrapper","panelId","wrapper","usePanelWrapper","containerElement","isActive","PanelContentHost","placement","createPortal","ContentRegistryProvider","placements","containers","setContainers","contentCacheRef","getOrCreateContent","cached","newContent","panelIds","RenderBridgeInner","emptyContentComponent","interactions","DefaultEmpty","Empty","g","tid","RenderBridge","collectHandles","linePos","PanelSplitHandles","adjustSplitRatio","handles","containerRect","setContainerRect","measure","getResizeObserverCtor","ctor","RO","ro","onScroll","renderHandle","handle","parentPx","thickness","SPLIT_HANDLE_THICKNESS","ResizeHandle","delta","parentWidth","dRatio","parentHeight","h","rootStyle","GridLayoutRenderer","layoutMode","gridTracksInteractive","view","tabBarComponent","panelGroupComponent","grid","GridLayout","PanelSystemContent","className","containerStyle","isZoneAllowed","OverlayWithinProvider","PanelSystem","PanelStateProvider"],"mappings":";;;;;;;;AAeA,MAAMA,KAAoB,CAACC,OAElB;AAAA,EACL,OAAOC;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,iBANsBD,MAAU,SAASE,KAA6BF,MAAU,UAAUG,KAA4BC;AAMtH,IAISC,KAAsD,CAAC,EAAE,UAAAC,GAAU,WAAWC,GAAW,SAAAC,QAAc;AAClH,QAAM,EAAE,KAAAC,GAAK,YAAAC,GAAY,eAAAC,EAAA,IAAkBC,GAA8B;AAAA,IACvE,MAAM;AAAA,IACN,UAAAN;AAAA,EAAA,CACD,GACK,CAACO,GAASC,CAAU,IAAIC,EAAM,SAAS,EAAK,GAE5CC,IAAe;AAAA,IACnB,KAAAP;AAAA,IACA,OAAOV,GAAkBW,IAAa,SAASG,IAAU,UAAU,MAAM;AAAA,IACzE,MAAM;AAAA,IACN,oBAAoB;AAAA,IACpB,iBAAiBH,IAAa,SAAS;AAAA,IACvC,eAAAC;AAAA,IACA,gBAAgB,MAAMG,EAAW,EAAI;AAAA,IACrC,gBAAgB,MAAMA,EAAW,EAAK;AAAA,EAAA;AAGxC,SAAIN,IACKO,EAAM,aAAaP,GAASQ,CAAY,IAE7CT,IACK,gBAAAU,EAACV,GAAA,EAAW,GAAGS,EAAA,CAAc,IAE/B,gBAAAC,EAAC,OAAA,EAAK,GAAGD,EAAA,CAAc;AAChC,GC5CaE,KAAqB,MAA4B;AAC5D,QAAM,EAAE,SAAAC,EAAA,IAAYC,GAAA,GACd,EAAE,qBAAAC,EAAA,IAAwBC,GAAA;AA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,EAAM,OAA8B,IAAI,GACvDob,IAAwBpb,EAAM,QAAQ,MAAM8Y,GAAqBoC,CAAW,GAAG,CAACA,CAAW,CAAC;AAElG,SACE,gBAAAhb;AAAA,IAACogB;AAAAA,IAAA;AAAA,MACC,cAAA9W;AAAA,MACA,eAAAqL;AAAA,MACA,eAAAkG;AAAA,MACA,OAAOC;AAAA,MACP,eAAAC;AAAA,MACA,aAAAC;AAAA,MAEA,4BAAC9Y,IAAA,EACC,UAAA;AAAA,QAAA,gBAAAlC,EAACgc,IAAA,EAA4B;AAAA,QAC7B,gBAAAhc;AAAA,UAAC8f;AAAA,UAAA;AAAA,YACC,cAAAhW;AAAA,YACA,YAAAyV;AAAA,YACA,uBAAAC;AAAA,YACA,iBAAAzV;AAAA,YACA,MAAA0V;AAAA,YACA,OAAAxb;AAAA,YACA,WAAA8b;AAAA,YACA,iBAAAL;AAAA,YACA,qBAAAC;AAAA,YACA,aAAazE;AAAA,YACb,uBAAAoC;AAAA,YACA,kBAAAxP;AAAA,UAAA;AAAA,QAAA;AAAA,MACF,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"index.js","sources":["../src/components/resizer/HorizontalDivider.tsx","../src/modules/grid/useLayerDragHandle.ts","../src/modules/window/useFloatingState.ts","../src/modules/keybindings/KeybindingsProvider.tsx","../src/modules/panels/layout/adapter.ts","../src/modules/panels/rendering/RenderContext.tsx","../src/modules/panels/dom/DomRegistry.tsx","../src/components/panels/PanelGroupView.tsx","../src/modules/panels/interactions/dnd.ts","../src/utils/typedActions.ts","../src/modules/panels/interactions/InteractionsContext.tsx","../src/components/tabs/TabBarTab.tsx","../src/components/tabs/TabBar.tsx","../src/modules/panels/rendering/GroupContainer.tsx","../src/utils/CSSMatrix.ts","../src/components/panels/DropSuggestOverlay.tsx","../src/hooks/useClonedElementPreview.ts","../src/components/tabs/TabDragOverlay.tsx","../src/modules/panels/state/tree/logic.ts","../src/modules/panels/state/cleanup.ts","../src/modules/panels/state/groups/logic.ts","../src/modules/panels/state/focus/logic.ts","../src/modules/panels/index.ts","../src/modules/panels/state/groups/Context.tsx","../src/modules/panels/state/tree/Context.tsx","../src/modules/panels/state/focus/Context.tsx","../src/modules/panels/state/splitLimits.ts","../src/modules/panels/state/PanelSystemContext.tsx","../src/modules/panels/state/commands.ts","../src/modules/panels/keybindings/KeybindingsInstaller.tsx","../src/modules/panels/rendering/ContentRegistry.tsx","../src/modules/panels/rendering/RenderBridge.tsx","../src/modules/panels/state/PanelSplitHandles.tsx","../src/modules/panels/system/PanelSystem.tsx"],"sourcesContent":["/**\n * @file Horizontal divider component\n */\nimport * as React from \"react\";\nimport { useResizeDrag } from \"../../modules/resizer/useResizeDrag\";\nimport { HORIZONTAL_DIVIDER_WIDTH, COLOR_RESIZE_HANDLE_IDLE, COLOR_RESIZE_HANDLE_HOVER, COLOR_RESIZE_HANDLE_ACTIVE } from \"../../constants/styles\";\n\nexport type HorizontalDividerProps = {\n onResize: (deltaX: number) => void;\n /** Custom component for the divider */\n component?: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }>;\n /** Custom element for the divider */\n element?: React.ReactElement;\n};\n\nconst buildDividerStyle = (state: \"idle\" | \"hover\" | \"drag\"): React.CSSProperties => {\n const backgroundColor = state === \"drag\" ? COLOR_RESIZE_HANDLE_ACTIVE : state === \"hover\" ? COLOR_RESIZE_HANDLE_HOVER : COLOR_RESIZE_HANDLE_IDLE;\n return {\n width: HORIZONTAL_DIVIDER_WIDTH,\n cursor: \"col-resize\",\n position: \"relative\",\n userSelect: \"none\",\n backgroundColor,\n };\n};\n\nexport const HorizontalDivider: React.FC<HorizontalDividerProps> = ({ onResize, component: Component, element }) => {\n const { ref, isDragging, onPointerDown } = useResizeDrag<HTMLDivElement>({\n axis: \"x\",\n onResize: onResize,\n });\n const [hovered, setHovered] = React.useState(false);\n\n const dividerProps = {\n ref,\n style: buildDividerStyle(isDragging ? \"drag\" : hovered ? \"hover\" : \"idle\"),\n role: \"separator\" as const,\n \"aria-orientation\": \"vertical\" as const,\n \"data-dragging\": isDragging ? \"true\" : undefined,\n onPointerDown,\n onPointerEnter: () => setHovered(true),\n onPointerLeave: () => setHovered(false),\n };\n\n if (element) {\n return React.cloneElement(element, dividerProps);\n }\n if (Component) {\n return <Component {...dividerProps} />;\n }\n return <div {...dividerProps} />;\n};\n","/**\n * @file Hook for retrieving draggable handle props for the current layer.\n */\nimport * as React from \"react\";\nimport { useGridLayoutContext, type GridLayerHandleProps } from \"./GridLayoutContext\";\nimport { useLayerInstance } from \"./LayerInstanceContext\";\n\nexport const useLayerDragHandle = (): GridLayerHandleProps => {\n const { layerId } = useLayerInstance();\n const { getLayerHandleProps } = useGridLayoutContext();\n\n return React.useMemo(() => {\n return getLayerHandleProps(layerId);\n }, [getLayerHandleProps, layerId]);\n};\n\n","/**\n * @file Hook for managing floating window state (controlled/uncontrolled)\n * Pattern based on useDrawerState.ts\n */\nimport * as React from \"react\";\nimport type { LayerDefinition, WindowPosition, WindowSize } from \"../../types\";\n\ntype FloatingState = {\n position: WindowPosition;\n size: WindowSize;\n};\n\nconst DEFAULT_POSITION: WindowPosition = { left: 0, top: 0 };\nconst DEFAULT_SIZE: WindowSize = { width: 400, height: 300 };\n\nexport const useFloatingState = (layers: LayerDefinition[]) => {\n const [floatingStates, setFloatingStates] = React.useState<Record<string, FloatingState>>(() => {\n const initial: Record<string, FloatingState> = {};\n layers.forEach((layer) => {\n if (layer.floating) {\n const floating = layer.floating;\n initial[layer.id] = {\n position: floating.defaultPosition ?? DEFAULT_POSITION,\n size: floating.defaultSize ?? DEFAULT_SIZE,\n };\n }\n });\n return initial;\n });\n\n const layerMap = React.useMemo(() => {\n const map = new Map<string, LayerDefinition>();\n layers.forEach((layer) => map.set(layer.id, layer));\n return map;\n }, [layers]);\n\n const getPosition = React.useCallback(\n (layerId: string): WindowPosition => {\n const layer = layerMap.get(layerId);\n // Controlled mode: use position prop directly\n if (layer?.floating?.position !== undefined) {\n return layer.floating.position;\n }\n // Uncontrolled mode: use internal state\n return floatingStates[layerId]?.position ?? DEFAULT_POSITION;\n },\n [layerMap, floatingStates],\n );\n\n const getSize = React.useCallback(\n (layerId: string): WindowSize => {\n const layer = layerMap.get(layerId);\n // Controlled mode: use size prop directly\n if (layer?.floating?.size !== undefined) {\n return layer.floating.size;\n }\n // Uncontrolled mode: use internal state\n return floatingStates[layerId]?.size ?? DEFAULT_SIZE;\n },\n [layerMap, floatingStates],\n );\n\n const getZIndex = React.useCallback(\n (layerId: string): number | undefined => {\n const layer = layerMap.get(layerId);\n return layer?.floating?.zIndex;\n },\n [layerMap],\n );\n\n const updatePosition = React.useCallback(\n (layerId: string, position: WindowPosition) => {\n const layer = layerMap.get(layerId);\n if (!layer?.floating) {\n return;\n }\n\n // Update internal state only if uncontrolled\n if (layer.floating.position === undefined) {\n setFloatingStates((prev) => {\n const currentState = prev[layerId];\n if (!currentState) {\n return prev;\n }\n return {\n ...prev,\n [layerId]: { ...currentState, position },\n };\n });\n }\n\n // Always call callback\n layer.floating.onMove?.(position);\n },\n [layerMap],\n );\n\n const updateSize = React.useCallback(\n (layerId: string, size: WindowSize) => {\n const layer = layerMap.get(layerId);\n if (!layer?.floating) {\n return;\n }\n\n // Update internal state only if uncontrolled\n if (layer.floating.size === undefined) {\n setFloatingStates((prev) => {\n const currentState = prev[layerId];\n if (!currentState) {\n return prev;\n }\n return {\n ...prev,\n [layerId]: { ...currentState, size },\n };\n });\n }\n\n // Always call callback\n layer.floating.onResize?.(size);\n },\n [layerMap],\n );\n\n const close = React.useCallback(\n (layerId: string) => {\n const layer = layerMap.get(layerId);\n layer?.floating?.onClose?.();\n },\n [layerMap],\n );\n\n return {\n getPosition,\n getSize,\n getZIndex,\n updatePosition,\n updateSize,\n close,\n };\n};\n","/**\n * @file Central keybindings provider for PanelSystem.\n * Belongs to modules: distributes a single source of keybindings to UI.\n */\nimport * as React from \"react\";\nimport type { PanelCommands } from \"../panels/state/types\";\n\nexport type KeyCombo = string; // e.g., \"Mod-Shift-\\\\\", \"Mod-1\"\n\nexport type KeybindingsMap = Record<KeyCombo, (e: KeyboardEvent) => void>;\n\nexport type KeybindingsContextValue = {\n register: (combo: KeyCombo, handler: (e: KeyboardEvent) => void) => void;\n unregister: (combo: KeyCombo) => void;\n};\n\nconst KeybindingsContext = React.createContext<KeybindingsContextValue | null>(null);\n\nexport const useKeybindings = (): KeybindingsContextValue => {\n const ctx = React.useContext(KeybindingsContext);\n if (!ctx) {\n throw new Error(\"useKeybindings must be used within KeybindingsProvider\");\n }\n return ctx;\n};\n\nconst normalizeEventToCombo = (e: KeyboardEvent): KeyCombo => {\n const parts: string[] = [];\n if (e.metaKey) {\n parts.push(\"Mod\");\n }\n if (e.ctrlKey) {\n parts.push(\"Ctrl\");\n }\n if (e.altKey) {\n parts.push(\"Alt\");\n }\n if (e.shiftKey) {\n parts.push(\"Shift\");\n }\n const key = e.key.length === 1 ? e.key.toUpperCase() : e.key;\n parts.push(key);\n return parts.join(\"-\");\n};\n\nexport const KeybindingsProvider: React.FC<React.PropsWithChildren<{ configure?: (api: KeybindingsContextValue) => void }>> = ({ children, configure }) => {\n const handlersRef = React.useRef<KeybindingsMap>({});\n\n const register = React.useCallback((combo: KeyCombo, handler: (e: KeyboardEvent) => void): void => {\n handlersRef.current = { ...handlersRef.current, [combo]: handler };\n }, []);\n\n const unregister = React.useCallback((combo: KeyCombo): void => {\n const rest = { ...handlersRef.current };\n delete (rest as Record<string, unknown>)[combo];\n handlersRef.current = rest;\n }, []);\n\n React.useEffect(() => {\n const onKeyDown = (e: KeyboardEvent): void => {\n const combo = normalizeEventToCombo(e);\n const handler = handlersRef.current[combo];\n if (!handler) {\n return;\n }\n handler(e);\n };\n window.addEventListener(\"keydown\", onKeyDown);\n return () => {\n window.removeEventListener(\"keydown\", onKeyDown);\n };\n }, []);\n\n const api: KeybindingsContextValue = React.useMemo(() => ({ register, unregister }), [register, unregister]);\n\n React.useEffect(() => {\n if (!configure) {\n return;\n }\n configure(api);\n }, [api, configure]);\n\n return <KeybindingsContext.Provider value={api}>{children}</KeybindingsContext.Provider>;\n};\n\nexport const registerDefaultBindings = (api: KeybindingsContextValue, commands: PanelCommands): void => {\n api.register(\"Mod-\\\\\", (e) => {\n e.preventDefault();\n commands.splitFocused(\"vertical\");\n });\n api.register(\"Mod-Shift-\\\\\", (e) => {\n e.preventDefault();\n commands.splitFocused(\"horizontal\");\n });\n\n for (const n of [1, 2, 3, 4, 5, 6, 7, 8, 9]) {\n api.register(`Mod-${String(n)}`, (e) => {\n e.preventDefault();\n commands.focusGroupIndex(n);\n });\n }\n\n api.register(\"Alt-ArrowRight\", (e) => {\n e.preventDefault();\n commands.focusNextGroup();\n });\n api.register(\"Alt-ArrowLeft\", (e) => {\n e.preventDefault();\n commands.focusPrevGroup();\n });\n};\n","/**\n * @file Adapters bridging panel-system model to existing GridLayout definitions.\n * Strategy: Use a 1x1 relative grid and place groups as absolute layers using computed rects.\n */\nimport type { LayerDefinition, PanelLayoutConfig } from \"../../../types\";\nimport type { GroupId, PanelSystemState, PanelTree } from \"../state/types\";\n\nexport type Rect = { x: number; y: number; w: number; h: number };\n\nconst isGroup = (node: PanelTree): node is Extract<PanelTree, { type: \"group\" }> => {\n return (node as { type: string }).type === \"group\";\n};\n\nexport const computeRects = (node: PanelTree, bounds: Rect = { x: 0, y: 0, w: 100, h: 100 }): Map<GroupId, Rect> => {\n const result = new Map<GroupId, Rect>();\n const walk = (n: PanelTree, rect: Rect): void => {\n if (isGroup(n)) {\n result.set(n.groupId, rect);\n return;\n }\n if (n.direction === \"vertical\") {\n const wA = rect.w * n.ratio;\n const wB = rect.w - wA;\n walk(n.a, { x: rect.x, y: rect.y, w: wA, h: rect.h });\n walk(n.b, { x: rect.x + wA, y: rect.y, w: wB, h: rect.h });\n return;\n }\n const hA = rect.h * n.ratio;\n const hB = rect.h - hA;\n walk(n.a, { x: rect.x, y: rect.y, w: rect.w, h: hA });\n walk(n.b, { x: rect.x, y: rect.y + hA, w: rect.w, h: hB });\n };\n walk(node, bounds);\n return result;\n};\n\nexport const buildGridForAbsolutePanels = (\n state: PanelSystemState,\n renderGroup: (groupId: GroupId) => React.ReactNode,\n): { config: PanelLayoutConfig; layers: LayerDefinition[] } => {\n const rects = computeRects(state.tree);\n\n const config: PanelLayoutConfig = {\n areas: [[\"root\"]],\n rows: [{ size: \"1fr\" }],\n columns: [{ size: \"1fr\" }],\n gap: \"0px\",\n style: { position: \"relative\" },\n };\n\n const layers: LayerDefinition[] = Array.from(rects.entries()).map(([groupId, r]) => {\n const style: React.CSSProperties = {\n position: \"absolute\",\n left: `${r.x}%`,\n top: `${r.y}%`,\n width: `${r.w}%`,\n height: `${r.h}%`,\n overflow: \"hidden\",\n display: \"flex\",\n flexDirection: \"column\",\n };\n return {\n id: groupId,\n positionMode: \"absolute\",\n style,\n component: renderGroup(groupId),\n } satisfies LayerDefinition;\n });\n\n return { config, layers };\n};\n\nexport const buildGridFromRects = (\n state: PanelSystemState,\n renderGroup: (groupId: GroupId) => React.ReactNode,\n interactiveTracks: boolean,\n): { config: PanelLayoutConfig; layers: LayerDefinition[] } => {\n const rects = computeRects(state.tree);\n\n const xs = Array.from(new Set(Array.from(rects.values()).flatMap((r) => [r.x, r.x + r.w]))).sort((a, b) => a - b);\n const ys = Array.from(new Set(Array.from(rects.values()).flatMap((r) => [r.y, r.y + r.h]))).sort((a, b) => a - b);\n\n const colSizes = xs.slice(1).map((x, i) => `${x - xs[i]}fr`);\n const rowSizes = ys.slice(1).map((y, i) => `${y - ys[i]}fr`);\n\n const columns = colSizes.map((size) => ({ size, resizable: interactiveTracks }));\n const rows = rowSizes.map((size) => ({ size, resizable: interactiveTracks }));\n\n const areaForCell = (x0: number, x1: number, y0: number, y1: number): string => {\n for (const [gid, r] of rects.entries()) {\n const within = x0 >= r.x && x1 <= r.x + r.w && y0 >= r.y && y1 <= r.y + r.h;\n if (within) {\n return gid;\n }\n }\n return \".\";\n };\n\n const areas: string[][] = [];\n for (let ri = 0; ri < ys.length - 1; ri += 1) {\n const row: string[] = [];\n for (let ci = 0; ci < xs.length - 1; ci += 1) {\n row.push(areaForCell(xs[ci], xs[ci + 1], ys[ri], ys[ri + 1]));\n }\n areas.push(row);\n }\n\n const config: PanelLayoutConfig = {\n areas,\n rows,\n columns,\n gap: \"0px\",\n } as PanelLayoutConfig;\n\n const layers: LayerDefinition[] = Array.from(rects.keys()).map((groupId) => {\n return {\n id: groupId,\n gridArea: groupId,\n component: renderGroup(groupId),\n };\n });\n\n return { config, layers };\n};\n","/**\n * @file Panel render context providing per-group accessors and actions.\n */\nimport * as React from \"react\";\nimport type { GroupId, GroupModel, PanelId } from \"../state/types\";\n\nexport type PanelRenderContextValue = {\n getGroup: (id: GroupId) => GroupModel | null;\n getGroupContent: (id: GroupId) => React.ReactNode;\n onClickTab: (groupId: GroupId, tabId: PanelId) => void;\n onAddTab?: (groupId: GroupId) => void;\n onCloseTab?: (groupId: GroupId, tabId: PanelId) => void;\n onStartTabDrag: (tabId: PanelId, groupId: GroupId, e: React.PointerEvent) => void;\n onStartContentDrag: (groupId: GroupId, e: React.PointerEvent<HTMLDivElement>) => void;\n doubleClickToAdd?: boolean;\n registerContentContainer: (groupId: GroupId, element: HTMLElement | null) => void;\n};\n\nconst PanelRenderContext = React.createContext<PanelRenderContextValue | null>(null);\n\nexport const usePanelRenderContext = (): PanelRenderContextValue => {\n const ctx = React.useContext(PanelRenderContext);\n if (!ctx) {\n throw new Error(\"usePanelRenderContext must be used within PanelRenderProvider\");\n }\n return ctx;\n};\n\nexport const PanelRenderProvider: React.FC<React.PropsWithChildren<{ value: PanelRenderContextValue }>> = ({ value, children }) => {\n return <PanelRenderContext.Provider value={value}>{children}</PanelRenderContext.Provider>;\n};\n","/**\n * @file DOM registry for panel-system. React-first: components register their own refs\n * instead of global querySelectorAll scans.\n */\nimport * as React from \"react\";\nimport type { GroupId } from \"../state/types\";\n\nexport type RegisteredEls = {\n group: HTMLElement | null;\n tabbar: HTMLElement | null;\n content: HTMLElement | null;\n};\n\nexport type DomRegistryContextValue = {\n setGroupEl: (groupId: GroupId, el: HTMLElement | null) => void;\n setTabbarEl: (groupId: GroupId, el: HTMLElement | null) => void;\n setContentEl: (groupId: GroupId, el: HTMLElement | null) => void;\n getAll: () => Map<GroupId, RegisteredEls>;\n};\n\nconst DomRegistryContext = React.createContext<DomRegistryContextValue | null>(null);\n\nexport const useDomRegistry = (): DomRegistryContextValue => {\n const ctx = React.useContext(DomRegistryContext);\n if (!ctx) {\n throw new Error(\"useDomRegistry must be used within DomRegistryProvider\");\n }\n return ctx;\n};\n\nexport const DomRegistryProvider: React.FC<React.PropsWithChildren<unknown>> = ({ children }) => {\n const mapRef = React.useRef<Map<GroupId, RegisteredEls>>(new Map());\n\n const ensure = React.useCallback((groupId: GroupId): RegisteredEls => {\n const current = mapRef.current.get(groupId);\n if (current) {\n return current;\n }\n const next: RegisteredEls = { group: null, tabbar: null, content: null };\n mapRef.current.set(groupId, next);\n return next;\n }, []);\n\n const setGroupEl = React.useCallback(\n (groupId: GroupId, el: HTMLElement | null) => {\n const r = ensure(groupId);\n r.group = el;\n if (el === null) {\n const v = mapRef.current.get(groupId);\n const noOthers = v ? v.tabbar === null && v.content === null : false;\n if (noOthers) {\n mapRef.current.delete(groupId);\n }\n }\n },\n [ensure],\n );\n\n const setTabbarEl = React.useCallback(\n (groupId: GroupId, el: HTMLElement | null) => {\n const r = ensure(groupId);\n r.tabbar = el;\n if (el === null) {\n const v = mapRef.current.get(groupId);\n const noOthers = v ? v.group === null && v.content === null : false;\n if (noOthers) {\n mapRef.current.delete(groupId);\n }\n }\n },\n [ensure],\n );\n\n const setContentEl = React.useCallback(\n (groupId: GroupId, el: HTMLElement | null) => {\n const r = ensure(groupId);\n r.content = el;\n if (el === null) {\n const v = mapRef.current.get(groupId);\n const noOthers = v ? v.group === null && v.tabbar === null : false;\n if (noOthers) {\n mapRef.current.delete(groupId);\n }\n }\n },\n [ensure],\n );\n\n const getAll = React.useCallback(() => mapRef.current, []);\n\n const value = React.useMemo<DomRegistryContextValue>(() => ({ setGroupEl, setTabbarEl, setContentEl, getAll }), [setGroupEl, setTabbarEl, setContentEl, getAll]);\n\n return <DomRegistryContext.Provider value={value}>{children}</DomRegistryContext.Provider>;\n};\n","/**\n * @file Group view rendering for PanelSystem (tabbar + active content).\n */\nimport * as React from \"react\";\nimport type { PanelGroupRenderProps } from \"../../modules/panels/state/types\";\n\nexport type PanelGroupViewProps = PanelGroupRenderProps & {\n /** Custom component for the group container */\n component?: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }>;\n /** Custom element for the group container */\n element?: React.ReactElement;\n /** Custom component for the content container */\n contentComponent?: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }>;\n /** Custom element for the content container */\n contentElement?: React.ReactElement;\n};\n\nconst groupStyle: React.CSSProperties = {\n display: \"flex\",\n flexDirection: \"column\",\n width: \"100%\",\n height: \"100%\",\n};\n\nconst contentStyle: React.CSSProperties = {\n flex: \"1 1 auto\",\n minWidth: 0,\n minHeight: 0,\n position: \"relative\",\n overflow: \"hidden\",\n};\n\nfunction createContentNode(\n contentElement: React.ReactElement | undefined,\n ContentComponent: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }> | undefined,\n contentProps: React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> },\n content: React.ReactNode\n): React.ReactNode {\n if (contentElement) {\n return React.cloneElement(contentElement, contentProps, content);\n }\n if (ContentComponent) {\n return <ContentComponent {...contentProps}>{content}</ContentComponent>;\n }\n return <div {...contentProps}>{content}</div>;\n}\n\nfunction createGroupNode(\n element: React.ReactElement | undefined,\n GroupComponent: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }> | undefined,\n groupProps: React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> },\n groupContent: React.ReactNode\n): React.ReactNode {\n if (element) {\n return React.cloneElement(element, groupProps, groupContent);\n }\n if (GroupComponent) {\n return <GroupComponent {...groupProps}>{groupContent}</GroupComponent>;\n }\n return <div {...groupProps}>{groupContent}</div>;\n}\n\nconst RawPanelGroupView: React.FC<PanelGroupViewProps> = ({\n group,\n tabbar,\n content,\n onContentPointerDown,\n groupRef,\n contentRef,\n component: GroupComponent,\n element,\n contentComponent: ContentComponent,\n contentElement\n}) => {\n const groupProps = {\n ref: groupRef,\n style: groupStyle,\n \"data-group-id\": group.id,\n };\n\n const contentProps = {\n ref: contentRef,\n style: contentStyle,\n \"data-dnd-zone\": \"content\",\n onPointerDown: onContentPointerDown,\n };\n\n const contentNode = createContentNode(contentElement, ContentComponent, contentProps, content);\n\n const groupContent = (\n <>\n {tabbar}\n {contentNode}\n </>\n );\n\n return createGroupNode(element, GroupComponent, groupProps, groupContent);\n};\n\nexport const PanelGroupView = React.memo(RawPanelGroupView, (prev, next) => {\n if (prev.group.id !== next.group.id) {\n return false;\n }\n if (prev.group.activeTabId !== next.group.activeTabId) {\n return false;\n }\n if (prev.group.tabs.length !== next.group.tabs.length) {\n return false;\n }\n return prev.group.tabs === next.group.tabs;\n});\nPanelGroupView.displayName = \"PanelGroupView\";\n","/**\n * @file DnD utilities for panel interactions\n */\nimport type { DropZone } from \"../state/types\";\n\nexport const pickDropZone = (rect: DOMRectReadOnly, x: number, y: number): DropZone => {\n const left = rect.left;\n const top = rect.top;\n const width = rect.width;\n const height = rect.height;\n const localX = x - left;\n const localY = y - top;\n const thirdW = width / 3;\n const thirdH = height / 3;\n if (localX > thirdW && localX < width - thirdW && localY > thirdH && localY < height - thirdH) {\n return \"center\";\n }\n if (localX < localY && localX < width - localX && localY < height - localY) {\n return \"left\";\n }\n if (width - localX < localY && width - localX < localX && localY < height - localY) {\n return \"right\";\n }\n if (localY < localX && localY < height - localY && localX < width - localX) {\n return \"top\";\n }\n return \"bottom\";\n};\n","/* eslint-disable @typescript-eslint/no-explicit-any -- Generic action helpers rely on 'any' to avoid over-constraining payload creators */\n/**\n * @file Utilities for defining typed action creators and reducer handler maps without external dependencies.\n */\n\nexport type AnyAction = { type: string };\n\nexport type AnyActionCreator = {\n (...args: any[]): AnyAction;\n readonly type: string;\n};\n\ntype PayloadCreator = (...args: any[]) => any;\n\ntype ActionFromPayload<Type extends string, Creator extends PayloadCreator> =\n ReturnType<Creator> extends undefined | void\n ? { type: Type }\n : { type: Type; payload: Exclude<ReturnType<Creator>, undefined> };\n\n/**\n * Creates a typed action creator with an attached literal `type` property.\n */\nexport function createAction<Type extends string>(type: Type): (() => { type: Type }) & { readonly type: Type };\nexport function createAction<Type extends string, Creator extends PayloadCreator>(\n type: Type,\n payloadCreator: Creator,\n): ((...args: Parameters<Creator>) => ActionFromPayload<Type, Creator>) & { readonly type: Type };\nexport function createAction<Type extends string, Creator extends PayloadCreator>(\n type: Type,\n payloadCreator?: Creator,\n) {\n if (!payloadCreator) {\n const actionCreator = (() => ({ type }) as const) as (() => { type: Type }) & { readonly type: Type };\n Object.defineProperty(actionCreator, \"type\", {\n value: type,\n writable: false,\n enumerable: true,\n });\n return actionCreator;\n }\n const actionCreator = ((...args: Parameters<Creator>) => {\n const payload = payloadCreator(...args);\n if (typeof payload === \"undefined\") {\n return { type } as const;\n }\n return { type, payload } as const;\n }) as ((...args: Parameters<Creator>) => ActionFromPayload<Type, Creator>) & { readonly type: Type };\n Object.defineProperty(actionCreator, \"type\", {\n value: type,\n writable: false,\n enumerable: true,\n });\n return actionCreator;\n}\n\nexport type ActionCreatorsMap = Record<string, AnyActionCreator>;\n\nexport type ActionUnion<Creators extends ActionCreatorsMap> = ReturnType<Creators[keyof Creators]>;\n\nexport type CaseReducer<State, Action extends AnyAction, Extra> = (state: State, action: Action, extra: Extra) => State;\n\nexport type BoundActionCreators<Creators extends ActionCreatorsMap> = {\n [Key in keyof Creators]: (...args: Parameters<Creators[Key]>) => ReturnType<Creators[Key]>;\n};\n\nexport const bindActionCreators = <Creators extends ActionCreatorsMap>(\n creators: Creators,\n dispatch: (action: ActionUnion<Creators>) => unknown,\n): BoundActionCreators<Creators> => {\n const bound = {} as BoundActionCreators<Creators>;\n (Object.keys(creators) as Array<keyof Creators>).forEach((key) => {\n const creator = creators[key];\n bound[key] = ((...args: Parameters<typeof creator>) => {\n const action = creator(...args);\n dispatch(action as ActionUnion<Creators>);\n return action;\n }) as BoundActionCreators<Creators>[keyof Creators];\n });\n return bound;\n};\n\nexport const createActionHandlerMap = <State, Creators extends ActionCreatorsMap, Extra = undefined>(\n creators: Creators,\n handlers: {\n [Key in keyof Creators]?: CaseReducer<State, ReturnType<Creators[Key]>, Extra>;\n },\n): Record<string, CaseReducer<State, ReturnType<Creators[keyof Creators]>, Extra>> => {\n const map: Record<string, CaseReducer<State, ReturnType<Creators[keyof Creators]>, Extra>> = {};\n\n (Object.keys(handlers) as Array<keyof Creators>).forEach((key) => {\n const handler = handlers[key];\n if (!handler) {\n return;\n }\n const creator = creators[key];\n if (!creator) {\n throw new Error(`Missing action creator for key \"${String(key)}\"`);\n }\n map[creator.type] = handler as CaseReducer<State, ReturnType<Creators[keyof Creators]>, Extra>;\n });\n\n return map;\n};\n","/**\n * @file Centralized panel interactions (DnD) using Context + reducer.\n * Handles content (panel area) split/move and tabbar reordering/cross-move.\n */\nimport * as React from \"react\";\nimport type { DropZone, GroupId, PanelId } from \"../state/types\";\nimport { pickDropZone } from \"./dnd\";\nimport { useDomRegistry } from \"../dom/DomRegistry\";\nimport { createAction, createActionHandlerMap } from \"../../../utils/typedActions\";\nimport { useEffectEvent } from \"../../../hooks/useEffectEvent\";\n\nexport type SuggestInfo = { rect: DOMRectReadOnly; zone: DropZone } | null;\n\n// Cached layout data for drag operations\ntype LayoutCache = {\n groups: Array<{ gid: GroupId; el: HTMLElement; rect: DOMRect }>;\n tabbars: Array<{ gid: GroupId; el: HTMLElement; rect: DOMRect }>;\n contents: Array<{ gid: GroupId; el: HTMLElement; rect: DOMRect }>;\n};\n\ntype Phase =\n | { kind: \"idle\" }\n | {\n kind: \"content\";\n startX: number;\n startY: number;\n fromGroupId: GroupId;\n tabId: PanelId;\n cache: LayoutCache;\n }\n | {\n kind: \"tab\";\n startX: number;\n startY: number;\n fromGroupId: GroupId;\n tabId: PanelId;\n cache: LayoutCache;\n };\n\ntype State = {\n phase: Phase;\n suggest: SuggestInfo;\n pointer: { x: number; y: number } | null;\n tabbarHover: { groupId: GroupId; index: number; rect: DOMRectReadOnly; insertX: number } | null;\n draggingTabElement: HTMLElement | null;\n};\n\nconst initialState: State = { phase: { kind: \"idle\" }, suggest: null, pointer: null, tabbarHover: null, draggingTabElement: null };\n\nconst actions = {\n startContent: createAction(\n \"START_CONTENT\",\n (payload: { x: number; y: number; groupId: GroupId; tabId: PanelId; cache: LayoutCache }) => payload,\n ),\n startTab: createAction(\n \"START_TAB\",\n (payload: { x: number; y: number; groupId: GroupId; tabId: PanelId; cache: LayoutCache; element: HTMLElement | null }) => payload,\n ),\n setSuggest: createAction(\"SET_SUGGEST\", (payload: SuggestInfo) => payload),\n setPointer: createAction(\"SET_POINTER\", (payload: { x: number; y: number } | null) => payload),\n setTabbarHover: createAction(\n \"SET_TABBAR_HOVER\",\n (payload: { groupId: GroupId; index: number; rect: DOMRectReadOnly; insertX: number } | null) => payload,\n ),\n reset: createAction(\"RESET\"),\n} as const;\n\nconst reducerHandlers = createActionHandlerMap<State, typeof actions, void>(actions, {\n startContent: (_state, action) => ({\n phase: {\n kind: \"content\",\n startX: action.payload.x,\n startY: action.payload.y,\n fromGroupId: action.payload.groupId,\n tabId: action.payload.tabId,\n cache: action.payload.cache,\n },\n suggest: null,\n pointer: null,\n tabbarHover: null,\n draggingTabElement: null,\n }),\n startTab: (_state, action) => ({\n phase: {\n kind: \"tab\",\n startX: action.payload.x,\n startY: action.payload.y,\n fromGroupId: action.payload.groupId,\n tabId: action.payload.tabId,\n cache: action.payload.cache,\n },\n suggest: null,\n pointer: null,\n tabbarHover: null,\n draggingTabElement: action.payload.element,\n }),\n setSuggest: (state, action) => ({ ...state, suggest: action.payload }),\n setPointer: (state, action) => ({ ...state, pointer: action.payload }),\n setTabbarHover: (state, action) => ({ ...state, tabbarHover: action.payload }),\n reset: () => initialState,\n});\n\ntype ReducerAction = ReturnType<(typeof actions)[keyof typeof actions]>;\n\nconst reducer = (state: State, action: ReducerAction): State => {\n const handler = reducerHandlers[action.type];\n if (!handler) {\n return state;\n }\n return handler(state, action, undefined);\n};\n\nexport type InteractionsContextValue = {\n suggest: SuggestInfo;\n onStartContentDrag: (groupId: GroupId, tabId: PanelId, e: React.PointerEvent<HTMLDivElement>) => void;\n onStartTabDrag: (tabId: PanelId, groupId: GroupId, e: React.PointerEvent) => void;\n isTabDragging: boolean;\n draggingTabId: PanelId | null;\n dragPointer: { x: number; y: number } | null;\n tabbarHover: { groupId: GroupId; index: number; rect: DOMRectReadOnly; insertX: number } | null;\n draggingTabElement: HTMLElement | null;\n};\n\nconst InteractionsContext = React.createContext<InteractionsContextValue | null>(null);\n\nexport const usePanelInteractions = (): InteractionsContextValue => {\n const ctx = React.useContext(InteractionsContext);\n if (!ctx) {\n throw new Error(\"usePanelInteractions must be used within InteractionsProvider\");\n }\n return ctx;\n};\n\nexport type InteractionsProviderProps = React.PropsWithChildren<{\n containerRef: React.RefObject<HTMLDivElement | null>;\n dragThresholdPx: number;\n onCommitContentDrop: (payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; zone: DropZone }) => void;\n onCommitTabDrop: (payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; targetIndex: number }) => void;\n isContentZoneAllowed?: (payload: { targetGroupId: GroupId; zone: DropZone }) => boolean;\n}>;\n\nexport const InteractionsProvider: React.FC<InteractionsProviderProps> = ({\n containerRef,\n dragThresholdPx,\n onCommitContentDrop,\n onCommitTabDrop,\n isContentZoneAllowed,\n children,\n}) => {\n const [state, dispatch] = React.useReducer(reducer, initialState);\n const dom = useDomRegistry();\n\n // Helper to capture current layout state\n const captureLayout = React.useCallback((): LayoutCache => {\n const all = Array.from(dom.getAll().entries());\n\n const groups = all\n .map(([gid, els]) => ({ gid, el: els.content ?? els.group }))\n .filter((it): it is { gid: GroupId; el: HTMLElement } => Boolean(it.el))\n .map((it) => ({ ...it, rect: it.el.getBoundingClientRect() }));\n\n const tabbars = all\n .map(([gid, els]) => ({ gid, el: els.tabbar }))\n .filter((it): it is { gid: GroupId; el: HTMLElement } => Boolean(it.el))\n .map((it) => ({ ...it, rect: it.el.getBoundingClientRect() }));\n\n const contents = all\n .map(([gid, els]) => ({ gid, el: els.content ?? els.group }))\n .filter((it): it is { gid: GroupId; el: HTMLElement } => Boolean(it.el))\n .map((it) => ({ ...it, rect: it.el.getBoundingClientRect() }));\n\n return { groups, tabbars, contents };\n }, [dom]);\n\n const onMove = useEffectEvent((ev: PointerEvent) => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n const x = ev.clientX;\n const y = ev.clientY;\n const phase = state.phase;\n if (phase.kind === \"idle\") {\n return;\n }\n const dx = Math.abs(x - phase.startX);\n const dy = Math.abs(y - phase.startY);\n if (dx < dragThresholdPx && dy < dragThresholdPx) {\n if (state.phase.kind === \"content\") {\n dispatch(actions.setSuggest(null));\n }\n dispatch(actions.setPointer(null));\n dispatch(actions.setTabbarHover(null));\n return;\n }\n dispatch(actions.setPointer({ x, y }));\n\n if (phase.kind === \"content\") {\n // Use cached groups\n const candidate = phase.cache.groups\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (!candidate) {\n dispatch(actions.setSuggest(null));\n return;\n }\n const zone = pickDropZone(candidate.rect, x, y);\n if (isContentZoneAllowed && !isContentZoneAllowed({ targetGroupId: candidate.gid, zone })) {\n dispatch(actions.setSuggest(null));\n return;\n }\n dispatch(actions.setSuggest({ rect: candidate.rect, zone }));\n return;\n }\n\n if (phase.kind === \"tab\") {\n // Use cached tabbars\n const tabbarHit = phase.cache.tabbars\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (tabbarHit) {\n // We still need to query buttons for exact insertion index, but we can optimize this too if needed.\n // For now, querying buttons inside the hit tabbar is acceptable as it's much smaller scope than global.\n // Optimization: We could cache button rects too, but they might change if tabs reorder during drag (if we implemented live reorder).\n // Assuming no live reorder for now as per original code.\n const tabButtons = Array.from(tabbarHit.el.querySelectorAll<HTMLButtonElement>(\"[role='tab']\"));\n const btnRects = tabButtons.map((b) => b.getBoundingClientRect());\n const centers = btnRects.map((r) => r.left + r.width / 2);\n const firstIdx = centers.findIndex((c) => x < c);\n const targetIndex = firstIdx === -1 ? centers.length : firstIdx;\n\n const computeInsertX = (): number => {\n if (btnRects.length === 0) {\n return tabbarHit.rect.left + 8;\n }\n if (targetIndex === 0) {\n return btnRects[0].left;\n }\n if (targetIndex === btnRects.length) {\n return btnRects[btnRects.length - 1].right;\n }\n return (btnRects[targetIndex - 1].right + btnRects[targetIndex].left) / 2;\n };\n const insertX = computeInsertX();\n dispatch(actions.setTabbarHover({ groupId: tabbarHit.gid, index: targetIndex, rect: tabbarHit.rect, insertX }));\n } else {\n dispatch(actions.setTabbarHover(null));\n }\n\n // Use cached contents for split/move\n const candidate = phase.cache.contents\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (!candidate) {\n dispatch(actions.setSuggest(null));\n return;\n }\n const zone = pickDropZone(candidate.rect, x, y);\n if (isContentZoneAllowed && !isContentZoneAllowed({ targetGroupId: candidate.gid, zone })) {\n dispatch(actions.setSuggest(null));\n return;\n }\n dispatch(actions.setSuggest({ rect: candidate.rect, zone }));\n }\n });\n\n const onUp = useEffectEvent((ev: PointerEvent) => {\n const container = containerRef.current;\n const snapshot = state;\n dispatch(actions.reset());\n if (!container) {\n return;\n }\n const x = ev.clientX;\n const y = ev.clientY;\n if (snapshot.phase.kind === \"idle\") {\n return;\n }\n const dx = Math.abs(x - snapshot.phase.startX);\n const dy = Math.abs(y - snapshot.phase.startY);\n if (dx < dragThresholdPx && dy < dragThresholdPx) {\n return;\n }\n\n if (snapshot.phase.kind === \"content\") {\n const hit = snapshot.phase.cache.groups\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (!hit) {\n return;\n }\n const targetGroupId = hit.gid ?? null;\n if (!targetGroupId) {\n return;\n }\n const zone = pickDropZone(hit.rect, x, y);\n if (isContentZoneAllowed && !isContentZoneAllowed({ targetGroupId: targetGroupId, zone })) {\n return;\n }\n onCommitContentDrop({ fromGroupId: snapshot.phase.fromGroupId, tabId: snapshot.phase.tabId, targetGroupId, zone });\n return;\n }\n\n if (snapshot.phase.kind === \"tab\") {\n const tabbarHit = snapshot.phase.cache.tabbars\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (tabbarHit) {\n const targetGroupId = tabbarHit.gid;\n if (!targetGroupId) {\n return;\n }\n const tabButtons = Array.from(tabbarHit.el.querySelectorAll<HTMLButtonElement>(\"[role='tab']\"));\n const centers = tabButtons.map((btn) => {\n const r = btn.getBoundingClientRect();\n return r.left + r.width / 2;\n });\n const firstIdx = centers.findIndex((c) => x < c);\n const targetIndex = firstIdx === -1 ? centers.length : firstIdx;\n onCommitTabDrop({ fromGroupId: snapshot.phase.fromGroupId, tabId: snapshot.phase.tabId, targetGroupId, targetIndex });\n return;\n }\n\n const contentHit = snapshot.phase.cache.contents\n .find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);\n\n if (contentHit) {\n const targetGroupId = contentHit.gid ?? null;\n if (!targetGroupId) {\n return;\n }\n const zone = pickDropZone(contentHit.rect, x, y);\n if (isContentZoneAllowed && !isContentZoneAllowed({ targetGroupId, zone })) {\n return;\n }\n onCommitContentDrop({ fromGroupId: snapshot.phase.fromGroupId, tabId: snapshot.phase.tabId, targetGroupId, zone });\n }\n }\n });\n\n const onCancel = useEffectEvent(() => {\n dispatch(actions.reset());\n });\n\n React.useEffect(() => {\n if (state.phase.kind === \"idle\") {\n return;\n }\n\n window.addEventListener(\"pointermove\", onMove);\n window.addEventListener(\"pointerup\", onUp, { once: true });\n window.addEventListener(\"pointercancel\", onCancel, { once: true });\n\n return () => {\n window.removeEventListener(\"pointermove\", onMove);\n window.removeEventListener(\"pointerup\", onUp);\n window.removeEventListener(\"pointercancel\", onCancel);\n };\n }, [state.phase.kind]);\n\n const onStartContentDrag = React.useCallback((groupId: GroupId, tabId: PanelId, e: React.PointerEvent<HTMLDivElement>) => {\n if (e.button !== 0) {\n return;\n }\n e.currentTarget.setPointerCapture(e.pointerId);\n const cache = captureLayout();\n dispatch(actions.startContent({ x: e.clientX, y: e.clientY, groupId, tabId, cache }));\n }, [captureLayout]);\n\n const onStartTabDrag = React.useCallback((tabId: PanelId, groupId: GroupId, e: React.PointerEvent) => {\n if (e.button !== 0) {\n return;\n }\n const target = e.currentTarget as Element | null;\n if (target) {\n target.setPointerCapture(e.pointerId);\n }\n const cache = captureLayout();\n dispatch(actions.startTab({ x: e.clientX, y: e.clientY, groupId, tabId, cache, element: target as HTMLElement | null }));\n }, [captureLayout]);\n\n const value = React.useMemo<InteractionsContextValue>(() => ({\n suggest: state.suggest,\n isTabDragging: state.phase.kind === \"tab\",\n draggingTabId: state.phase.kind === \"tab\" ? state.phase.tabId : null,\n dragPointer: state.pointer,\n tabbarHover: state.tabbarHover,\n draggingTabElement: state.draggingTabElement,\n onStartContentDrag,\n onStartTabDrag,\n }), [state.suggest, state.pointer, state.tabbarHover, state.phase, state.draggingTabElement, onStartContentDrag, onStartTabDrag]);\n\n return <InteractionsContext.Provider value={value}>{children}</InteractionsContext.Provider>;\n};\n","/**\n * @file Tab button renderer for TabBar.\n */\nimport * as React from \"react\";\nimport type { TabBarProps } from \"./TabBar\";\n\ntype TabItem = TabBarProps[\"group\"][\"tabs\"][number];\n\ntype TabButtonProps = React.HTMLAttributes<HTMLDivElement> & {\n \"data-tab-id\": string;\n \"data-active\": \"true\" | \"false\";\n \"data-dragging\": \"true\" | \"false\";\n};\n\nexport type TabBarTabProps = {\n groupId: string;\n tab: TabItem;\n active: boolean;\n dragging: boolean;\n tabComponent?: TabBarProps[\"tabComponent\"];\n tabElement?: TabBarProps[\"tabElement\"];\n onClickTab: TabBarProps[\"onClickTab\"];\n onStartDrag: TabBarProps[\"onStartDrag\"];\n onCloseTab?: (groupId: string, tabId: string) => void;\n onDoubleClick?: (e: React.MouseEvent) => void;\n};\n\nconst tabStyle: React.CSSProperties = {\n display: \"inline-flex\",\n alignItems: \"center\",\n userSelect: \"none\",\n};\n\nexport const TabBarTab: React.FC<TabBarTabProps> = ({\n groupId,\n tab,\n active,\n dragging,\n onClickTab,\n onStartDrag,\n onCloseTab,\n tabComponent: TabComponent,\n tabElement,\n onDoubleClick,\n}) => {\n const handleClick = React.useEffectEvent(() => {\n onClickTab(tab.id);\n });\n\n const handlePointerDown = React.useEffectEvent((e: React.PointerEvent<HTMLDivElement>) => {\n if (!onStartDrag) {\n return;\n }\n if (e.button !== 0) {\n return;\n }\n onStartDrag(tab.id, groupId, e);\n });\n\n const renderCloseButton = (): React.ReactNode => {\n const hasClose = Boolean(onCloseTab);\n return (\n <React.Activity mode={hasClose ? \"visible\" : \"hidden\"}>\n <button\n type=\"button\"\n aria-label={`Close tab ${tab.title}`}\n onClick={(e) => {\n if (!onCloseTab) {\n return;\n }\n e.stopPropagation();\n onCloseTab(groupId, tab.id);\n }}\n style={{ marginLeft: 6 }}\n tabIndex={hasClose ? undefined : -1}\n disabled={!hasClose}\n aria-hidden={hasClose ? undefined : true}\n >\n ×\n </button>\n </React.Activity>\n );\n };\n\n const divProps: TabButtonProps = {\n role: \"tab\",\n \"aria-selected\": active,\n tabIndex: active ? 0 : -1,\n style: tabStyle,\n onClick: handleClick,\n onPointerDown: handlePointerDown,\n onDoubleClick,\n \"data-tab-id\": tab.id,\n \"data-active\": active ? \"true\" : \"false\",\n \"data-dragging\": dragging ? \"true\" : \"false\",\n children: (\n <>\n <span>{tab.title}</span>\n {renderCloseButton()}\n </>\n ),\n };\n\n const buttonProps: React.ButtonHTMLAttributes<HTMLButtonElement> = {\n type: \"button\",\n role: \"tab\",\n \"aria-selected\": active,\n tabIndex: active ? 0 : -1,\n style: tabStyle,\n onClick: () => {\n onClickTab(tab.id);\n },\n onPointerDown: (e: React.PointerEvent<HTMLButtonElement>) => {\n if (!onStartDrag) {\n return;\n }\n if (e.button !== 0) {\n return;\n }\n onStartDrag(tab.id, groupId, e);\n },\n onDoubleClick,\n children: <span>{tab.title}</span>,\n };\n\n if (tabElement) {\n return tabElement(buttonProps);\n }\n if (TabComponent) {\n return <TabComponent {...buttonProps} />;\n }\n return <div {...divProps} />;\n};\n","/**\n * @file Tab bar with drag handles (generic, not panel-specific).\n */\nimport * as React from \"react\";\nimport type { TabBarRenderProps } from \"../../modules/panels/state/types\";\nimport { usePanelInteractions } from \"../../modules/panels/interactions/InteractionsContext\";\nimport { useElementComponentWrapper } from \"../../hooks/useElementComponentWrapper\";\nimport { TabBarTab } from \"./TabBarTab\";\n\nexport type TabBarProps = TabBarRenderProps & {\n /** Custom component for the tabbar container */\n component?: React.ComponentType<React.HTMLAttributes<HTMLDivElement> & { ref?: React.Ref<HTMLDivElement> }>;\n /** Custom element for the tabbar container */\n element?: React.ReactElement<React.HTMLAttributes<HTMLDivElement>>;\n /** Custom component for individual tabs */\n tabComponent?: React.ComponentType<React.ButtonHTMLAttributes<HTMLButtonElement>>;\n /** Custom element factory for individual tabs */\n tabElement?: (props: React.ButtonHTMLAttributes<HTMLButtonElement>) => React.ReactElement;\n /** Request to add a new tab to this group */\n onAddTab?: (groupId: string) => void;\n /** Request to close/remove a tab */\n onCloseTab?: (groupId: string, tabId: string) => void;\n};\n\nconst tabbarStyle: React.CSSProperties = {\n display: \"flex\",\n alignItems: \"center\",\n};\n\nconst spacerStyle: React.CSSProperties = {\n flex: \"1 1 auto\",\n alignSelf: \"stretch\",\n};\n\nexport const TabBar: React.FC<TabBarProps> = ({\n group,\n onClickTab,\n onStartDrag,\n rootRef,\n component: ContainerComponent,\n element,\n tabComponent: TabComponent,\n tabElement,\n onAddTab,\n onCloseTab,\n doubleClickToAdd,\n}) => {\n const { isTabDragging, draggingTabId } = usePanelInteractions();\n const localRef = React.useRef<HTMLDivElement | null>(null);\n\n const setRefs = React.useCallback(\n (el: HTMLDivElement | null) => {\n localRef.current = el;\n if (!rootRef) {\n return;\n }\n if (typeof rootRef === \"function\") {\n rootRef(el);\n return;\n }\n try {\n // RefObject-like\n (rootRef as React.MutableRefObject<HTMLDivElement | null>).current = el;\n } catch {\n // ignore\n }\n },\n [rootRef],\n );\n\n const handleKeyDown = React.useEffectEvent((e: React.KeyboardEvent<HTMLDivElement>) => {\n const root = localRef.current ?? (e.currentTarget as HTMLDivElement | null);\n if (!root) {\n return;\n }\n const tabs = Array.from(root.querySelectorAll('[role=\"tab\"]')) as HTMLElement[];\n if (tabs.length === 0) {\n return;\n }\n\n const focusTabAt = (index: number) => {\n const clamped = Math.max(0, Math.min(index, tabs.length - 1));\n const el = tabs[clamped];\n if (!el) {\n return;\n }\n el.focus();\n };\n\n const activeEl = document.activeElement as HTMLElement | null;\n const currentIndex = activeEl ? tabs.indexOf(activeEl) : tabs.findIndex((el) => el.getAttribute(\"data-tab-id\") === group.activeTabId);\n\n if (e.key === \"ArrowRight\") {\n e.preventDefault();\n const next = currentIndex >= 0 ? currentIndex + 1 : 0;\n focusTabAt(next >= tabs.length ? 0 : next);\n return;\n }\n if (e.key === \"ArrowLeft\") {\n e.preventDefault();\n const prev = currentIndex >= 0 ? currentIndex - 1 : tabs.length - 1;\n focusTabAt(prev < 0 ? tabs.length - 1 : prev);\n return;\n }\n if (e.key === \"Home\") {\n e.preventDefault();\n focusTabAt(0);\n return;\n }\n if (e.key === \"End\") {\n e.preventDefault();\n focusTabAt(tabs.length - 1);\n return;\n }\n\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n const el = currentIndex >= 0 ? tabs[currentIndex] : null;\n const id = el?.getAttribute(\"data-tab-id\") ?? null;\n if (id) {\n onClickTab(id);\n }\n return;\n }\n\n if (e.key === \"Delete\" || e.key === \"Backspace\") {\n if (onCloseTab) {\n e.preventDefault();\n const el = currentIndex >= 0 ? tabs[currentIndex] : null;\n const id = el?.getAttribute(\"data-tab-id\") ?? null;\n if (id) {\n onCloseTab(group.id, id);\n }\n }\n return;\n }\n\n const hasModifier = (e.ctrlKey ? 1 : 0) + (e.metaKey ? 1 : 0) > 0;\n const keyLower = typeof e.key === \"string\" ? e.key.toLowerCase() : \"\";\n if (hasModifier && keyLower === \"t\") {\n if (onAddTab) {\n e.preventDefault();\n onAddTab(group.id);\n }\n return;\n }\n });\n\n React.useEffect(() => {\n const root = localRef.current;\n if (!root) {\n return;\n }\n const active = root.querySelector(`[role=\"tab\"][data-tab-id=\"${group.activeTabId}\"]`) as HTMLElement | null;\n if (active === (document.activeElement as HTMLElement | null)) {\n return;\n }\n // Maintain roving focus: ensure active tab is in the natural focus if none inside has focus\n const containsFocus = root.contains(document.activeElement);\n if (!containsFocus && active) {\n active.focus();\n }\n }, [group.activeTabId]);\n\n const containerProps = {\n style: tabbarStyle,\n role: \"tablist\" as const,\n \"data-tabbar\": \"true\",\n \"data-group-id\": group.id,\n \"data-dragging\": isTabDragging ? \"true\" : \"false\",\n onKeyDown: handleKeyDown,\n };\n\n const Wrapper = useElementComponentWrapper({\n element,\n component: ContainerComponent,\n });\n\n const renderAddButton = (): React.ReactNode => {\n if (!onAddTab) {\n return null;\n }\n return (\n <button\n type=\"button\"\n aria-label=\"Add tab\"\n onClick={() => {\n onAddTab(group.id);\n }}\n >\n +\n </button>\n );\n };\n\n const handleTabbarDoubleClick = React.useCallback((): void => {\n if (doubleClickToAdd && onAddTab) {\n onAddTab(group.id);\n }\n }, [doubleClickToAdd, onAddTab, group.id]);\n\n return (\n <Wrapper {...containerProps} ref={setRefs} onDoubleClick={handleTabbarDoubleClick}>\n {group.tabs.map((tab, index) => (\n <TabBarTab\n key={`${group.id}:${tab.id}:${index}`}\n groupId={group.id}\n tab={tab}\n active={group.activeTabId === tab.id}\n dragging={draggingTabId === tab.id}\n onClickTab={onClickTab}\n onStartDrag={onStartDrag}\n onCloseTab={onCloseTab}\n tabComponent={TabComponent}\n tabElement={tabElement}\n onDoubleClick={(e) => e.stopPropagation()}\n />\n ))}\n <span style={spacerStyle} />\n {renderAddButton()}\n </Wrapper>\n );\n};\n","/**\n * @file Connected group container bridging panel contexts to the presentational view.\n */\nimport * as React from \"react\";\nimport type { GroupId, PanelGroupRenderProps, TabBarRenderProps } from \"../../panels/state/types\";\nimport { usePanelRenderContext } from \"../rendering/RenderContext\";\nimport { useDomRegistry } from \"../dom/DomRegistry\";\nimport { PanelGroupView } from \"../../../components/panels/PanelGroupView\";\nimport { TabBar } from \"../../../components/tabs/TabBar\";\n\nexport type ConnectedGroupContainerProps = {\n id: GroupId;\n TabBarComponent?: React.ComponentType<TabBarRenderProps>;\n PanelGroupComponent?: React.ComponentType<PanelGroupRenderProps>;\n};\n\nexport const GroupContainer: React.FC<ConnectedGroupContainerProps> = ({ id, TabBarComponent, PanelGroupComponent }) => {\n const { getGroup, getGroupContent, onClickTab, onAddTab, onCloseTab, onStartTabDrag, doubleClickToAdd, registerContentContainer } = usePanelRenderContext();\n const { setGroupEl, setTabbarEl, setContentEl } = useDomRegistry();\n const groupRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n setGroupEl(id, el);\n },\n [id, setGroupEl],\n );\n const contentRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n setContentEl(id, el);\n registerContentContainer(id, el);\n },\n [id, setContentEl, registerContentContainer],\n );\n const tabbarRef = React.useCallback(\n (el: HTMLDivElement | null) => {\n setTabbarEl(id, el);\n },\n [id, setTabbarEl],\n );\n const group = getGroup(id);\n if (!group) {\n return null;\n }\n const content = getGroupContent(id);\n const TabBarImpl = TabBarComponent ?? TabBar;\n const PanelGroupImpl: React.ComponentType<PanelGroupRenderProps> = PanelGroupComponent ?? ((props) => <PanelGroupView {...props} />);\n return (\n <PanelGroupImpl\n group={group}\n tabbar={\n <TabBarImpl\n rootRef={tabbarRef}\n group={group}\n onClickTab={(tabId) => onClickTab(id, tabId)}\n onAddTab={onAddTab}\n onCloseTab={onCloseTab}\n onStartDrag={(tabId, groupId, e) => onStartTabDrag(tabId, groupId, e)}\n doubleClickToAdd={doubleClickToAdd}\n />\n }\n content={content}\n groupRef={groupRef}\n contentRef={contentRef}\n />\n );\n};\n","/**\n * @file CSSMatrix - Immutable 4x4 matrix for CSS 3D transforms\n *\n * Each operation returns a new instance, preserving the original matrix.\n *\n * @example\n * const mtrx = matrix().translate(0, 10);\n * const a = mtrx.rotateX(Math.PI / 2);\n * const b = mtrx.rotateY(Math.PI);\n * // a and b are independent transformations from mtrx\n */\n\n/**\n * Matrix type with transformation methods\n */\nexport type CSSMatrix = {\n readonly translate: (x?: number, y?: number, z?: number) => CSSMatrix;\n readonly translate3d: (x: number, y: number, z: number) => CSSMatrix;\n readonly translateX: (x: number) => CSSMatrix;\n readonly translateY: (y: number) => CSSMatrix;\n readonly translateZ: (z: number) => CSSMatrix;\n readonly scale: (x?: number, y?: number, z?: number) => CSSMatrix;\n readonly scale3d: (x: number, y: number, z: number) => CSSMatrix;\n readonly scaleX: (x: number) => CSSMatrix;\n readonly scaleY: (y: number) => CSSMatrix;\n readonly scaleZ: (z: number) => CSSMatrix;\n readonly rotateX: (angle: number) => CSSMatrix;\n readonly rotateY: (angle: number) => CSSMatrix;\n readonly rotateZ: (angle: number) => CSSMatrix;\n readonly rotate: (angle: number, x: number, y: number, z: number) => CSSMatrix;\n readonly rotate3d: (x: number, y: number, z: number, angle: number) => CSSMatrix;\n readonly skew: (angleX?: number, angleY?: number) => CSSMatrix;\n readonly skewX: (angle: number) => CSSMatrix;\n readonly skewY: (angle: number) => CSSMatrix;\n readonly perspective: (distance: number) => CSSMatrix;\n readonly toCSS: () => string;\n readonly toArray: () => readonly number[];\n readonly toString: () => string;\n};\n\n/**\n * Multiply two 4x4 matrices (a * b)\n * Matrices are in column-major order\n */\nconst multiplyMatrices = (a: readonly number[], b: readonly number[]): number[] => {\n const result = new Array(16);\n\n for (let col = 0; col < 4; col++) {\n for (let row = 0; row < 4; row++) {\n result[col * 4 + row] =\n a[0 * 4 + row] * b[col * 4 + 0] +\n a[1 * 4 + row] * b[col * 4 + 1] +\n a[2 * 4 + row] * b[col * 4 + 2] +\n a[3 * 4 + row] * b[col * 4 + 3];\n }\n }\n\n return result;\n};\n\n/**\n * Create a CSSMatrix object from raw values\n * Values are stored in column-major order (OpenGL/CSS convention)\n */\nconst createMatrix = (values: readonly number[]): CSSMatrix => {\n if (values.length !== 16) {\n throw new Error('Matrix must have exactly 16 values');\n }\n\n // Freeze the values to ensure immutability\n const m = Object.freeze([...values]);\n\n /**\n * Helper to create a new matrix by multiplying with a transform matrix\n */\n const applyTransform = (transformValues: number[]): CSSMatrix => {\n const result = multiplyMatrices(m, transformValues);\n return createMatrix(result);\n };\n\n return Object.freeze({\n translate: (x = 0, y = 0, z = 0) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n x, y, z, 1,\n ]);\n },\n\n translate3d: (x, y, z) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n x, y, z, 1,\n ]);\n },\n\n translateX: (x) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n x, 0, 0, 1,\n ]);\n },\n\n translateY: (y) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, y, 0, 1,\n ]);\n },\n\n translateZ: (z) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, z, 1,\n ]);\n },\n\n scale: (x = 1, y = 1, z = 1) => {\n return applyTransform([\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n scale3d: (x, y, z) => {\n return applyTransform([\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n scaleX: (x) => {\n return applyTransform([\n x, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n scaleY: (y) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n scaleZ: (z) => {\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n rotateX: (angle) => {\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n return applyTransform([\n 1, 0, 0, 0,\n 0, c, s, 0,\n 0, -s, c, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n rotateY: (angle) => {\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n return applyTransform([\n c, 0, -s, 0,\n 0, 1, 0, 0,\n s, 0, c, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n rotateZ: (angle) => {\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n return applyTransform([\n c, s, 0, 0,\n -s, c, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n rotate: (angle, x, y, z) => {\n // Normalize the axis\n const len = Math.sqrt(x * x + y * y + z * z);\n if (len === 0) {\n return createMatrix(m);\n }\n\n x /= len;\n y /= len;\n z /= len;\n\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n const t = 1 - c;\n\n return applyTransform([\n t * x * x + c, t * x * y + s * z, t * x * z - s * y, 0,\n t * x * y - s * z, t * y * y + c, t * y * z + s * x, 0,\n t * x * z + s * y, t * y * z - s * x, t * z * z + c, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n rotate3d: (x, y, z, angle) => {\n // Normalize the axis\n const len = Math.sqrt(x * x + y * y + z * z);\n if (len === 0) {\n return createMatrix(m);\n }\n\n x /= len;\n y /= len;\n z /= len;\n\n const c = Math.cos(angle);\n const s = Math.sin(angle);\n const t = 1 - c;\n\n return applyTransform([\n t * x * x + c, t * x * y + s * z, t * x * z - s * y, 0,\n t * x * y - s * z, t * y * y + c, t * y * z + s * x, 0,\n t * x * z + s * y, t * y * z - s * x, t * z * z + c, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n skew: (angleX = 0, angleY = 0) => {\n const tanX = Math.tan(angleX);\n const tanY = Math.tan(angleY);\n return applyTransform([\n 1, tanY, 0, 0,\n tanX, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n skewX: (angle) => {\n const tanX = Math.tan(angle);\n return applyTransform([\n 1, 0, 0, 0,\n tanX, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n skewY: (angle) => {\n const tanY = Math.tan(angle);\n return applyTransform([\n 1, tanY, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n },\n\n perspective: (distance) => {\n if (distance === 0) {\n throw new Error('Perspective distance cannot be zero');\n }\n return applyTransform([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, -1 / distance,\n 0, 0, 0, 1,\n ]);\n },\n\n toCSS: () => {\n return `matrix3d(${m.join(', ')})`;\n },\n\n toArray: () => m,\n\n toString: () => {\n return [\n `[${m[0]}, ${m[4]}, ${m[8]}, ${m[12]}]`,\n `[${m[1]}, ${m[5]}, ${m[9]}, ${m[13]}]`,\n `[${m[2]}, ${m[6]}, ${m[10]}, ${m[14]}]`,\n `[${m[3]}, ${m[7]}, ${m[11]}, ${m[15]}]`,\n ].join('\\n');\n },\n });\n};\n\n/**\n * Factory function to create a new identity matrix\n */\nexport const matrix = (): CSSMatrix => {\n return createMatrix([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1,\n ]);\n};\n","/**\n * @file Overlay renderer and helpers for drop suggestion zones.\n */\nimport * as React from \"react\";\nimport type { DropZone } from \"../../modules/panels/state/types\";\nimport {\n DROP_SUGGEST_Z_INDEX,\n DROP_SUGGEST_BORDER_WIDTH,\n DROP_SUGGEST_BORDER_RADIUS,\n DROP_SUGGEST_BORDER_COLOR,\n DROP_SUGGEST_BG_COLOR,\n DROP_SUGGEST_PADDING_PX,\n} from \"../../constants/styles\";\nimport { clampNumber } from \"../../utils/math\";\nimport { matrix } from \"../../utils/CSSMatrix\";\n\nconst overlayStyle: React.CSSProperties = {\n position: \"fixed\",\n inset: 0,\n pointerEvents: \"none\",\n zIndex: DROP_SUGGEST_Z_INDEX,\n};\n\nconst suggestRectBaseStyle: React.CSSProperties = {\n position: \"absolute\",\n border: `${DROP_SUGGEST_BORDER_WIDTH} dashed ${DROP_SUGGEST_BORDER_COLOR}`,\n background: DROP_SUGGEST_BG_COLOR,\n borderRadius: DROP_SUGGEST_BORDER_RADIUS,\n transformOrigin: \"top left\",\n};\n\nexport type SuggestInfo = {\n rect: DOMRectReadOnly;\n zone: DropZone;\n};\n\nexport type DropSuggestOverlayProps = {\n suggest: SuggestInfo | null;\n};\n\nconst safeRatio = (value: number, base: number): number => {\n if (base <= 0) {\n return 0;\n }\n return clampNumber(value / base, 0);\n};\n\nconst buildZoneTransform = (rect: DOMRectReadOnly, zone: DropZone, pad: number): string => {\n const { width, height } = rect;\n const halfPad = pad / 2;\n const widthBase = width > 0 ? width : 1;\n const heightBase = height > 0 ? height : 1;\n\n const center = {\n translateX: pad,\n translateY: pad,\n scaleX: safeRatio(clampNumber(width - pad * 2, 0), widthBase),\n scaleY: safeRatio(clampNumber(height - pad * 2, 0), heightBase),\n };\n\n const left = {\n translateX: pad,\n translateY: pad,\n scaleX: safeRatio(clampNumber(width / 2 - pad * 1.5, 0), widthBase),\n scaleY: safeRatio(clampNumber(height - pad * 2, 0), heightBase),\n };\n\n const right = {\n translateX: width / 2 + halfPad,\n translateY: pad,\n scaleX: safeRatio(clampNumber(width / 2 - pad * 1.5, 0), widthBase),\n scaleY: safeRatio(clampNumber(height - pad * 2, 0), heightBase),\n };\n\n const top = {\n translateX: pad,\n translateY: pad,\n scaleX: safeRatio(clampNumber(width - pad * 2, 0), widthBase),\n scaleY: safeRatio(clampNumber(height / 2 - pad * 1.5, 0), heightBase),\n };\n\n const bottom = {\n translateX: pad,\n translateY: height / 2 + halfPad,\n scaleX: safeRatio(clampNumber(width - pad * 2, 0), widthBase),\n scaleY: safeRatio(clampNumber(height / 2 - pad * 1.5, 0), heightBase),\n };\n\n const zoneTransforms: Record<DropZone, typeof center> = {\n center,\n left,\n right,\n top,\n bottom,\n };\n\n const { translateX, translateY, scaleX, scaleY } = zoneTransforms[zone];\n return matrix()\n .translate(translateX, translateY, 0)\n .scale(scaleX, scaleY, 1)\n .toCSS();\n};\n\nconst buildSuggestStyle = (rect: DOMRectReadOnly, zone: DropZone): React.CSSProperties => {\n const pad = DROP_SUGGEST_PADDING_PX;\n return {\n ...suggestRectBaseStyle,\n left: rect.left,\n top: rect.top,\n width: rect.width,\n height: rect.height,\n transform: buildZoneTransform(rect, zone, pad),\n };\n};\n\nexport const DropSuggestOverlay: React.FC<DropSuggestOverlayProps> = ({ suggest }) => {\n if (!suggest) {\n return null;\n }\n\n const { rect, zone } = suggest;\n const style = buildSuggestStyle(rect, zone);\n\n return (\n <div style={overlayStyle}>\n <div style={style} />\n </div>\n );\n};\n\n// pickDropZone moved to modules/panels/runtime/dnd\n","/**\n * @file Clone a DOM element for preview while keeping SSR safe.\n * Provides the cloned element as HTML string plus its measured size.\n */\nimport * as React from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\nconst isBrowser = typeof window !== \"undefined\" && typeof document !== \"undefined\";\n\nexport const useClonedElementPreview = (\n sourceEl: HTMLElement | null,\n): { html: string | null; size: { width: number; height: number } | null } => {\n const [size, setSize] = React.useState<{ width: number; height: number } | null>(null);\n const [html, setHtml] = React.useState<string | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (!isBrowser || !sourceEl) {\n setSize(null);\n setHtml(null);\n return;\n }\n const rect = sourceEl.getBoundingClientRect();\n setSize({ width: rect.width, height: rect.height });\n setHtml(sourceEl.outerHTML);\n }, [sourceEl]);\n\n return { html, size };\n};\n","/**\n * @file Floating drag preview and insertion guide for tab dragging.\n */\nimport * as React from \"react\";\nimport { usePanelInteractions } from \"../../modules/panels/interactions/InteractionsContext\";\nimport {\n TAB_DRAG_OVERLAY_Z_INDEX,\n TAB_DRAG_PREVIEW_OFFSET_X,\n TAB_DRAG_PREVIEW_OFFSET_Y,\n TAB_DRAG_INSERT_GUIDE_WIDTH,\n TAB_DRAG_INSERT_GUIDE_BORDER_RADIUS,\n TAB_DRAG_INSERT_GUIDE_COLOR,\n TAB_DRAG_INSERT_GUIDE_SHADOW,\n} from \"../../constants/styles\";\nimport { useClonedElementPreview } from \"../../hooks/useClonedElementPreview\";\n\nconst overlayStyle: React.CSSProperties = {\n position: \"fixed\",\n inset: 0,\n pointerEvents: \"none\",\n zIndex: TAB_DRAG_OVERLAY_Z_INDEX,\n};\n\nconst insertGuideBaseStyle: React.CSSProperties = {\n position: \"absolute\",\n width: TAB_DRAG_INSERT_GUIDE_WIDTH,\n borderRadius: TAB_DRAG_INSERT_GUIDE_BORDER_RADIUS,\n background: TAB_DRAG_INSERT_GUIDE_COLOR,\n boxShadow: TAB_DRAG_INSERT_GUIDE_SHADOW,\n};\n\nexport const TabDragOverlay: React.FC = () => {\n const { isTabDragging, draggingTabId, dragPointer, tabbarHover, draggingTabElement } = usePanelInteractions();\n const { html: previewHtml, size: previewSize } = useClonedElementPreview(draggingTabElement);\n\n const hasPreview = dragPointer !== null && draggingTabId !== null;\n\n const previewBaseStyle = React.useMemo<React.CSSProperties | undefined>(() => {\n if (!hasPreview || !dragPointer) {\n return undefined;\n }\n return {\n position: \"absolute\",\n left: dragPointer.x,\n top: dragPointer.y,\n transform: `translate(${TAB_DRAG_PREVIEW_OFFSET_X}, ${TAB_DRAG_PREVIEW_OFFSET_Y})`,\n pointerEvents: \"none\",\n };\n }, [hasPreview, dragPointer]);\n\n const previewStyle = React.useMemo<React.CSSProperties | undefined>(() => {\n if (!previewBaseStyle || !draggingTabElement) {\n return undefined;\n }\n if (previewSize) {\n return { ...previewBaseStyle, width: previewSize.width, height: previewSize.height };\n }\n return previewBaseStyle;\n }, [previewBaseStyle, draggingTabElement, previewSize]);\n\n const guideStyle = React.useMemo<React.CSSProperties | undefined>(() => {\n if (!tabbarHover) {\n return undefined;\n }\n return {\n ...insertGuideBaseStyle,\n left: tabbarHover.insertX,\n top: tabbarHover.rect.top + 4,\n height: Math.max(0, tabbarHover.rect.height - 8),\n };\n }, [tabbarHover]);\n\n if (!isTabDragging) {\n return null;\n }\n\n return (\n <div style={overlayStyle}>\n <React.Activity mode={previewStyle ? \"visible\" : \"hidden\"}>\n <div style={previewStyle}>\n <div\n style={{ width: \"100%\", height: \"100%\", pointerEvents: \"none\" }}\n dangerouslySetInnerHTML={{ __html: previewHtml ?? \"\" }}\n />\n </div>\n </React.Activity>\n <React.Activity mode={guideStyle ? \"visible\" : \"hidden\"}>\n <div style={guideStyle} />\n </React.Activity>\n </div>\n );\n};\n","/**\n * @file Tree operations for panel-system (no registry or focus concerns).\n */\nimport type { GroupId, PanelTree, SplitDirection } from \"../types\";\nimport { clampNumber } from \"../../../../utils/math\";\n\nexport type PathSegment = \"a\" | \"b\";\nexport type NodePath = PathSegment[];\n\nexport const isGroup = (node: PanelTree): node is Extract<PanelTree, { type: \"group\" }> => {\n return (node as { type: string }).type === \"group\";\n};\n\nexport const collectGroupsInOrder = (node: PanelTree, acc: GroupId[] = []): GroupId[] => {\n if (isGroup(node)) {\n return [...acc, node.groupId];\n }\n const a = collectGroupsInOrder(node.a, acc);\n return collectGroupsInOrder(node.b, a);\n};\n\nexport const getAtPath = (root: PanelTree, path: NodePath): PanelTree => {\n return path.reduce<PanelTree>((node, key) => (isGroup(node) ? node : node[key]), root);\n};\n\nexport const setAtPath = (root: PanelTree, path: NodePath, value: PanelTree): PanelTree => {\n if (path.length === 0) {\n return value;\n }\n const [head, ...rest] = path;\n if (isGroup(root)) {\n // Invalid set; return original root\n return root;\n }\n const next = head === \"a\" ? { ...root, a: setAtPath(root.a, rest, value) } : { ...root, b: setAtPath(root.b, rest, value) };\n return next;\n};\n\n/**\n * Find split parent of a given group leaf. This function explicitly returns the path to the split node\n * and which side (\"a\" | \"b\") the target group occupies under that split. If there is no split parent\n * (i.e., the root is the leaf group), splitPath and side are null.\n */\nexport const findLeafParent = (\n node: PanelTree,\n groupId: GroupId,\n path: NodePath = [],\n): { splitPath: NodePath | null; side: PathSegment | null } | null => {\n if (isGroup(node)) {\n if (node.groupId === groupId) {\n return { splitPath: null, side: null };\n }\n return null;\n }\n // Search child A; if it is the group leaf, current node is parent and side is 'a'\n if (isGroup(node.a) && node.a.groupId === groupId) {\n return { splitPath: path, side: \"a\" };\n }\n // Search child B\n if (isGroup(node.b) && node.b.groupId === groupId) {\n return { splitPath: path, side: \"b\" };\n }\n // Recurse deeper\n const inA = findLeafParent(node.a, groupId, [...path, \"a\"]);\n if (inA) {\n return inA;\n }\n return findLeafParent(node.b, groupId, [...path, \"b\"]);\n};\n\n/**\n * Split the leaf group referenced by groupId into a split node, keeping the original group on side 'a'\n * and inserting a new group on side 'b'. Returns the new tree and the new group's id.\n * This function does not touch registries; only pure tree transformation.\n */\nexport const splitLeaf = (\n root: PanelTree,\n groupId: GroupId,\n direction: SplitDirection,\n createGroupId: () => GroupId,\n): { tree: PanelTree; newGroupId: GroupId } => {\n const newGroupId = createGroupId();\n const entry = findLeafParent(root, groupId);\n const replacement: PanelTree = {\n type: \"split\",\n direction,\n ratio: 0.5,\n a: { type: \"group\", groupId },\n b: { type: \"group\", groupId: newGroupId },\n } as const;\n\n if (!entry || entry.splitPath === null) {\n // Root is the leaf\n return { tree: replacement, newGroupId };\n }\n const parentPath = entry.splitPath;\n const parent = getAtPath(root, parentPath);\n if (isGroup(parent)) {\n // Should not happen; guard for safety\n return { tree: replacement, newGroupId };\n }\n const newParent = entry.side === \"a\" ? { ...parent, a: replacement } : { ...parent, b: replacement };\n const newTree = setAtPath(root, parentPath, newParent);\n return { tree: newTree, newGroupId };\n};\n\n/**\n * Remove the leaf group by collapsing it with its sibling. Returns the new tree and the survivor group id\n * (if any). If there is no split parent (single group), returns the original tree.\n */\nexport const closeLeaf = (root: PanelTree, groupId: GroupId): { tree: PanelTree; survivorGroupId: GroupId | null } => {\n const entry = findLeafParent(root, groupId);\n if (!entry || entry.splitPath === null) {\n // Single-group root\n return { tree: root, survivorGroupId: groupId };\n }\n const parentPath = entry.splitPath;\n const parent = getAtPath(root, parentPath);\n if (isGroup(parent)) {\n return { tree: root, survivorGroupId: groupId };\n }\n const survivor = entry.side === \"a\" ? parent.b : parent.a;\n const newTree = setAtPath(root, parentPath, survivor);\n const survivorId = isGroup(survivor) ? survivor.groupId : collectGroupsInOrder(survivor)[0] ?? null;\n return { tree: newTree, survivorGroupId: survivorId };\n};\n\n/**\n * Set split ratio at a specific split node path. Clamps ratio into (0.05 .. 0.95) to avoid zero-size panes.\n */\nexport const setSplitRatio = (root: PanelTree, splitPath: NodePath, ratio: number): PanelTree => {\n const node = getAtPath(root, splitPath);\n if (isGroup(node)) {\n return root;\n }\n const next = { ...node, ratio: clampNumber(ratio, 0.05, 0.95) } as PanelTree;\n return setAtPath(root, splitPath, next);\n};\n","/**\n * @file Cleanup utilities for PanelSystem state.\n * - Removes groups with no tabs and collapses the tree accordingly.\n */\nimport type { GroupId, PanelSystemState } from \"./types\";\nimport { closeLeaf, collectGroupsInOrder } from \"./tree/logic\";\n\n/**\n * Remove empty groups (tabs.length === 0) by collapsing corresponding leaves.\n * Keeps at least one group in the system.\n * Returns the same reference if no changes are necessary to help callers short-circuit updates.\n */\nexport const cleanupEmptyGroups = (state: PanelSystemState): PanelSystemState => {\n const allGroupIds = Object.keys(state.groups);\n const emptyIds = allGroupIds.filter((gid) => state.groups[gid]!.tabIds.length === 0);\n if (emptyIds.length === 0) {\n return state;\n }\n\n const removeIfEmpty = (acc: PanelSystemState, gid: GroupId): PanelSystemState => {\n const group = acc.groups[gid];\n if (!group || group.tabs.length > 0) {\n return acc;\n }\n const groupCount = Object.keys(acc.groups).length;\n if (groupCount <= 1) {\n return acc;\n }\n const { tree, survivorGroupId } = closeLeaf(acc.tree, gid);\n const { [gid]: _removed, ...restGroups } = acc.groups; void _removed;\n const groupOrder = collectGroupsInOrder(tree);\n const focusedGroupId = acc.focusedGroupId === gid ? (survivorGroupId ?? groupOrder[0] ?? null) : acc.focusedGroupId;\n return { ...acc, tree, groups: restGroups, groupOrder, focusedGroupId };\n };\n\n return state.groupOrder.reduce<PanelSystemState>((acc, gid) => removeIfEmpty(acc, gid as GroupId), state);\n};\n","/**\n * @file Group and tab registry operations (pure, no tree logic).\n */\nimport type { GroupId, GroupModel, PanelId, PanelSystemState, TabDefinition } from \"../types\";\n\nexport const createEmptyGroup = (id: GroupId): GroupModel => {\n return { id, tabIds: [], tabs: [], activeTabId: null };\n};\n\nexport const addTabToGroup = (state: PanelSystemState, groupId: GroupId, tab: TabDefinition, makeActive: boolean): PanelSystemState => {\n const groups = { ...state.groups };\n const group = groups[groupId];\n if (!group) {\n throw new Error(`Group ${groupId} does not exist.`);\n }\n const panels = { ...state.panels, [tab.id]: tab };\n const tabIds = [...group.tabIds, tab.id];\n const activeTabId = makeActive ? tab.id : group.activeTabId ?? tab.id;\n const tabs = tabIds.map((id) => panels[id]);\n const nextGroup: GroupModel = { ...group, tabIds, tabs, activeTabId };\n groups[groupId] = nextGroup;\n return { ...state, panels, groups };\n};\n\nexport const removeTabFromGroup = (state: PanelSystemState, groupId: GroupId, tabId: PanelId): PanelSystemState => {\n const groups = { ...state.groups };\n const group = groups[groupId];\n if (!group) {\n throw new Error(`Group ${groupId} does not exist.`);\n }\n const tabIds = group.tabIds.filter((id) => id !== tabId);\n const tabs = tabIds.map((id) => state.panels[id]);\n const activeTabId = group.activeTabId === tabId ? (tabIds[0] ?? null) : group.activeTabId;\n groups[groupId] = { ...group, tabIds, tabs, activeTabId };\n return { ...state, groups };\n};\n\nexport const moveTab = (state: PanelSystemState, fromGroupId: GroupId, toGroupId: GroupId, tabId: PanelId, makeActive: boolean): PanelSystemState => {\n const from = state.groups[fromGroupId];\n const to = state.groups[toGroupId];\n if (!from || !to) {\n throw new Error(\"moveTab: source or target group is missing.\");\n }\n const groups = { ...state.groups };\n const fromIds = from.tabIds.filter((id) => id !== tabId);\n const toIds = [...to.tabIds.filter((id) => id !== tabId), tabId];\n const fromActive = from.activeTabId === tabId ? (fromIds[0] ?? null) : from.activeTabId;\n groups[fromGroupId] = { ...from, tabIds: fromIds, tabs: fromIds.map((id) => state.panels[id]), activeTabId: fromActive };\n groups[toGroupId] = { ...to, tabIds: toIds, tabs: toIds.map((id) => state.panels[id]), activeTabId: makeActive ? tabId : to.activeTabId ?? tabId };\n return { ...state, groups };\n};\n\nexport const setActiveTab = (state: PanelSystemState, groupId: GroupId, tabId: PanelId): PanelSystemState => {\n const group = state.groups[groupId];\n if (!group) {\n throw new Error(`setActiveTab: group ${groupId} not found.`);\n }\n if (!group.tabIds.some((id) => id === tabId)) {\n throw new Error(`setActiveTab: tab ${tabId} not found in group ${groupId}.`);\n }\n const groups = { ...state.groups, [groupId]: { ...group, activeTabId: tabId } };\n return { ...state, groups, focusedGroupId: groupId };\n};\n\nexport const reorderTabWithinGroup = (state: PanelSystemState, groupId: GroupId, tabId: PanelId, toIndex: number): PanelSystemState => {\n const group = state.groups[groupId];\n if (!group) {\n throw new Error(`reorderTabWithinGroup: group ${groupId} not found.`);\n }\n const currentIndex = group.tabIds.findIndex((id) => id === tabId);\n if (currentIndex === -1) {\n throw new Error(`reorderTabWithinGroup: tab ${tabId} not in group ${groupId}.`);\n }\n const boundedIndex = Math.max(0, Math.min(toIndex, group.tabIds.length - 1));\n if (currentIndex === boundedIndex) {\n return state;\n }\n const ids = group.tabIds.slice();\n const [id] = ids.splice(currentIndex, 1);\n ids.splice(boundedIndex, 0, id);\n const tabs = ids.map((x) => state.panels[x]);\n const groups = { ...state.groups, [groupId]: { ...group, tabIds: ids, tabs } };\n return { ...state, groups };\n};\n\nexport const addTabToGroupAtIndex = (\n state: PanelSystemState,\n groupId: GroupId,\n tab: TabDefinition,\n index: number,\n makeActive: boolean,\n): PanelSystemState => {\n const group = state.groups[groupId];\n if (!group) {\n throw new Error(`addTabToGroupAtIndex: group ${groupId} not found.`);\n }\n const panels = { ...state.panels, [tab.id]: tab };\n const ids = group.tabIds.slice();\n const boundedIndex = Math.max(0, Math.min(index, ids.length));\n ids.splice(boundedIndex, 0, tab.id);\n const tabs = ids.map((id) => panels[id]);\n const activeTabId = makeActive ? tab.id : group.activeTabId ?? tab.id;\n const groups = { ...state.groups, [groupId]: { ...group, tabIds: ids, tabs, activeTabId } };\n return { ...state, panels, groups };\n};\n","/**\n * @file Focus and navigation helpers for panel-system.\n */\nimport type { GroupId, PanelSystemState } from \"../types\";\nimport { collectGroupsInOrder } from \"../tree/logic\";\n\nexport const setFocusedGroup = (state: PanelSystemState, groupId: GroupId): PanelSystemState => {\n if (!state.groups[groupId]) {\n throw new Error(`setFocusedGroup: group ${groupId} not found.`);\n }\n return { ...state, focusedGroupId: groupId };\n};\n\nexport const focusGroupIndex = (state: PanelSystemState, index1Based: number): PanelSystemState => {\n const idx = index1Based - 1;\n const id = state.groupOrder[idx];\n if (!id) {\n return state;\n }\n return setFocusedGroup(state, id);\n};\n\nexport const nextGroup = (state: PanelSystemState): PanelSystemState => {\n const order = state.groupOrder;\n const current = state.focusedGroupId;\n if (!current) {\n const first = order[0];\n if (!first) {\n return state;\n }\n return setFocusedGroup(state, first);\n }\n const idx = order.indexOf(current);\n const next = order[(idx + 1) % order.length];\n return setFocusedGroup(state, next);\n};\n\nexport const prevGroup = (state: PanelSystemState): PanelSystemState => {\n const order = state.groupOrder;\n const current = state.focusedGroupId;\n if (!current) {\n const last = order[order.length - 1];\n if (!last) {\n return state;\n }\n return setFocusedGroup(state, last);\n }\n const idx = order.indexOf(current);\n const prev = order[(idx - 1 + order.length) % order.length];\n return setFocusedGroup(state, prev);\n};\n\nexport const refreshGroupOrder = (state: PanelSystemState): PanelSystemState => {\n const groupOrder = collectGroupsInOrder(state.tree);\n return { ...state, groupOrder };\n};\n\n","/**\n * @file Public state operations aggregator (flattened under src/modules/panels).\n */\nexport type {\n PanelId,\n GroupId,\n SplitDirection,\n TabDefinition,\n GroupModel,\n PanelTree,\n PanelSystemState,\n DropZone,\n DraggingTab,\n PanelCommands,\n PanelSystemProps,\n PanelSplitLimits,\n} from \"./state/types\";\n\nexport { collectGroupsInOrder, splitLeaf, closeLeaf, isGroup, setSplitRatio } from \"./state/tree/logic\";\nexport { createEmptyGroup, addTabToGroup, removeTabFromGroup, moveTab, setActiveTab, reorderTabWithinGroup, addTabToGroupAtIndex } from \"./state/groups/logic\";\nexport { setFocusedGroup, focusGroupIndex, nextGroup, prevGroup, refreshGroupOrder } from \"./state/focus/logic\";\n\nimport type { GroupId as Gid, PanelSystemState as PState, SplitDirection as Dir, TabDefinition } from \"./state/types\";\nimport { splitLeaf, collectGroupsInOrder } from \"./state/tree/logic\";\nimport { createEmptyGroup } from \"./state/groups/logic\";\n\nexport type IdFactory = () => Gid;\n\nexport const splitGroup = (state: PState, groupId: Gid, direction: Dir, createGroupId: IdFactory): PState => {\n const { tree, newGroupId } = splitLeaf(state.tree, groupId, direction, createGroupId);\n const groups = { ...state.groups, [newGroupId]: createEmptyGroup(newGroupId) };\n const groupOrder = collectGroupsInOrder(tree);\n const focusedGroupId = newGroupId;\n return { ...state, tree, groups, groupOrder, focusedGroupId };\n};\n\nexport const buildInitialState = (tabs: TabDefinition[]): PState => {\n const groupId: Gid = \"g_1\";\n const tree = { type: \"group\", groupId } as const;\n const panels = Object.fromEntries(tabs.map((t) => [t.id, t]));\n const group = { id: groupId, tabIds: tabs.map((t) => t.id), tabs, activeTabId: tabs[0]?.id ?? null } as const;\n const groups = { [groupId]: group } as PState[\"groups\"];\n const groupOrder: Gid[] = [groupId];\n return { tree, panels, groups, groupOrder, focusedGroupId: groupId } as PState;\n};\n","/**\n * @file GroupsContext provides group/tab management actions for PanelSystem.\n * This context delegates to the root PanelSystemContext dispatch.\n */\nimport * as React from \"react\";\nimport type { GroupId, PanelId } from \"../types\";\n\nexport type GroupsActions = {\n setActiveTab: (groupId: GroupId, tabId: PanelId) => void;\n tabDrop: (payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; targetIndex: number }) => void;\n};\n\nconst GroupsContext = React.createContext<GroupsActions | null>(null);\n\nexport const useGroups = (): GroupsActions => {\n const ctx = React.useContext(GroupsContext);\n if (!ctx) {\n throw new Error(\"useGroups must be used within GroupsProvider\");\n }\n return ctx;\n};\n\nexport const GroupsProvider: React.FC<React.PropsWithChildren<{ value: GroupsActions }>> = ({ value, children }) => {\n return <GroupsContext.Provider value={value}>{children}</GroupsContext.Provider>;\n};\n","/**\n * @file TreeContext provides tree/split management actions for PanelSystem.\n * This context delegates to the root PanelSystemContext dispatch.\n */\nimport * as React from \"react\";\nimport type { NodePath } from \"./logic\";\n\nexport type TreeActions = {\n adjustSplitRatio: (payload: { path: NodePath; deltaRatio: number }) => void;\n};\n\nconst TreeContext = React.createContext<TreeActions | null>(null);\n\nexport const useTree = (): TreeActions => {\n const ctx = React.useContext(TreeContext);\n if (!ctx) {\n throw new Error(\"useTree must be used within TreeProvider\");\n }\n return ctx;\n};\n\nexport const TreeProvider: React.FC<React.PropsWithChildren<{ value: TreeActions }>> = ({ value, children }) => {\n return <TreeContext.Provider value={value}>{children}</TreeContext.Provider>;\n};\n","/**\n * @file FocusContext provides focus/navigation actions for PanelSystem.\n * This context delegates to the root PanelSystemContext dispatch.\n */\nimport * as React from \"react\";\n\nexport type FocusActions = {\n focusGroupIndex: (index1Based: number) => void;\n focusNextGroup: () => void;\n focusPrevGroup: () => void;\n};\n\nconst FocusContext = React.createContext<FocusActions | null>(null);\n\nexport const useFocus = (): FocusActions => {\n const ctx = React.useContext(FocusContext);\n if (!ctx) {\n throw new Error(\"useFocus must be used within FocusProvider\");\n }\n return ctx;\n};\n\nexport const FocusProvider: React.FC<React.PropsWithChildren<{ value: FocusActions }>> = ({ value, children }) => {\n return <FocusContext.Provider value={value}>{children}</FocusContext.Provider>;\n};\n","/**\n * @file Split-limit helpers for the panel system.\n */\nimport type { GroupId, PanelSplitLimits, PanelTree, SplitDirection } from \"./types\";\nimport { splitLeaf, isGroup } from \"./tree/logic\";\nimport { clampNumber, toFiniteNumberOr } from \"../../../utils/math\";\n\nexport type NormalizedSplitLimits = {\n rows: number;\n cols: number;\n};\n\nconst clampLimit = (value: number | undefined): number => {\n const finite = toFiniteNumberOr(value, Number.POSITIVE_INFINITY);\n return clampNumber(finite, 1);\n};\n\nconst isObjectLimits = (limits: PanelSplitLimits): limits is Record<string, unknown> =>\n typeof limits === \"object\" && limits !== null;\n\nconst isRowsColsLimits = (limits: PanelSplitLimits): limits is { rows?: number; cols?: number } => {\n if (!isObjectLimits(limits)) {\n return false;\n }\n if (\"rows\" in limits) {\n return true;\n }\n return \"cols\" in limits;\n};\n\nexport const normalizeSplitLimits = (limits?: PanelSplitLimits): NormalizedSplitLimits => {\n if (!limits) {\n return {\n rows: Number.POSITIVE_INFINITY,\n cols: Number.POSITIVE_INFINITY,\n };\n }\n if (typeof limits === \"number\") {\n const normalized = clampLimit(limits);\n return { rows: normalized, cols: normalized };\n }\n if (isRowsColsLimits(limits)) {\n return {\n rows: clampLimit(limits.rows),\n cols: clampLimit(limits.cols),\n };\n }\n const legacy = limits as { maxHorizontal?: number; maxVertical?: number };\n return {\n rows: clampLimit(legacy.maxHorizontal),\n cols: clampLimit(legacy.maxVertical),\n };\n};\n\nexport type SplitExtents = {\n horizontal: number;\n vertical: number;\n};\n\nexport const measureSplitExtents = (tree: PanelTree): SplitExtents => {\n if (isGroup(tree)) {\n return { horizontal: 1, vertical: 1 };\n }\n const a = measureSplitExtents(tree.a);\n const b = measureSplitExtents(tree.b);\n if (tree.direction === \"horizontal\") {\n return { horizontal: a.horizontal + b.horizontal, vertical: Math.max(a.vertical, b.vertical) };\n }\n return { horizontal: Math.max(a.horizontal, b.horizontal), vertical: a.vertical + b.vertical };\n};\n\nconst previewSplitTree = (tree: PanelTree, groupId: GroupId, direction: SplitDirection): PanelTree => {\n const { tree: preview } = splitLeaf(tree, groupId, direction, () => \"__preview__\");\n return preview;\n};\n\nexport const canSplitDirection = (tree: PanelTree, groupId: GroupId, direction: SplitDirection, limits: NormalizedSplitLimits): boolean => {\n if (!Number.isFinite(limits.rows) && !Number.isFinite(limits.cols)) {\n return true;\n }\n const preview = previewSplitTree(tree, groupId, direction);\n const extents = measureSplitExtents(preview);\n if (extents.horizontal > limits.rows) {\n return false;\n }\n if (extents.vertical > limits.cols) {\n return false;\n }\n return true;\n};\n","/**\n * @file Root PanelSystemContext that combines subdomain contexts (groups, tree, focus).\n * Provides unified state and dispatch while exposing domain-specific actions via subcontexts.\n */\nimport * as React from \"react\";\nimport type { DropZone, GroupId, PanelId, PanelSplitLimits, PanelSystemState, SplitDirection, TabDefinition } from \"./types\";\nimport { cleanupEmptyGroups } from \"./cleanup\";\nimport { addTabToGroup, addTabToGroupAtIndex, moveTab, removeTabFromGroup, setActiveTab } from \"./groups/logic\";\nimport { setFocusedGroup, focusGroupIndex as focusIdx, nextGroup, prevGroup } from \"./focus/logic\";\nimport { splitGroup } from \"../index\";\nimport { getAtPath, isGroup, setSplitRatio, type NodePath } from \"./tree/logic\";\nimport { bindActionCreators, createAction, createActionHandlerMap, type BoundActionCreators } from \"../../../utils/typedActions\";\nimport { GroupsProvider, type GroupsActions } from \"./groups/Context\";\nimport { TreeProvider, type TreeActions } from \"./tree/Context\";\nimport { FocusProvider, type FocusActions } from \"./focus/Context\";\nimport { canSplitDirection, normalizeSplitLimits, type NormalizedSplitLimits } from \"./splitLimits\";\n\ntype ReducerExtra = {\n createGroupId: () => GroupId;\n splitLimits: NormalizedSplitLimits;\n createPanelId?: () => PanelId;\n};\n\nconst actions = {\n splitFocused: createAction(\"panelState/splitFocused\", (direction: SplitDirection) => ({ direction })),\n focusGroupIndex: createAction(\"panelState/focusGroupIndex\", (index1Based: number) => ({ index1Based })),\n focusNextGroup: createAction(\"panelState/focusNextGroup\"),\n focusPrevGroup: createAction(\"panelState/focusPrevGroup\"),\n setActiveTab: createAction(\"panelState/setActiveTab\", (groupId: GroupId, tabId: PanelId) => ({ groupId, tabId })),\n addTab: createAction(\n \"panelState/addTab\",\n (payload: { groupId: GroupId; tab: TabDefinition; index?: number; makeActive?: boolean }) => payload,\n ),\n addNewTab: createAction(\n \"panelState/addNewTab\",\n (payload: { groupId: GroupId; title: string; index?: number; makeActive?: boolean }) => payload,\n ),\n removeTab: createAction(\"panelState/removeTab\", (groupId: GroupId, tabId: PanelId) => ({ groupId, tabId })),\n contentDrop: createAction(\n \"panelState/contentDrop\",\n (payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; zone: DropZone }) => payload,\n ),\n tabDrop: createAction(\n \"panelState/tabDrop\",\n (payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; targetIndex: number }) => payload,\n ),\n adjustSplitRatio: createAction(\"panelState/adjustSplitRatio\", (payload: { path: NodePath; deltaRatio: number }) => payload),\n} as const;\n\ntype PanelStateAction = ReturnType<(typeof actions)[keyof typeof actions]>;\ntype PanelStateActions = BoundActionCreators<typeof actions>;\n\nconst handleContentDrop = (\n state: PanelSystemState,\n payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; zone: DropZone },\n extra: ReducerExtra,\n): PanelSystemState => {\n const fromGroup = state.groups[payload.fromGroupId];\n const targetGroup = state.groups[payload.targetGroupId];\n if (!fromGroup || !targetGroup) {\n return state;\n }\n const tab = fromGroup.tabs.find((t) => t.id === payload.tabId);\n if (!tab) {\n return state;\n }\n if (payload.zone === \"center\" && payload.fromGroupId === payload.targetGroupId) {\n return setActiveTab(state, payload.fromGroupId, payload.tabId);\n }\n if (payload.zone === \"center\") {\n const moved = moveTab(state, payload.fromGroupId, payload.targetGroupId, payload.tabId, true);\n return setFocusedGroup(moved, payload.targetGroupId);\n }\n const direction: SplitDirection = payload.zone === \"left\" || payload.zone === \"right\" ? \"vertical\" : \"horizontal\";\n if (!canSplitDirection(state.tree, payload.targetGroupId, direction, extra.splitLimits)) {\n return state;\n }\n const newGroupId = extra.createGroupId();\n const afterSplit = splitGroup(state, payload.targetGroupId, direction, () => newGroupId);\n const destination = payload.zone === \"left\" || payload.zone === \"top\" ? payload.targetGroupId : newGroupId;\n const withTab = moveTab(afterSplit, payload.fromGroupId, destination, payload.tabId, true);\n return setFocusedGroup(withTab, destination);\n};\n\nconst handleTabDrop = (\n state: PanelSystemState,\n payload: { fromGroupId: GroupId; tabId: PanelId; targetGroupId: GroupId; targetIndex: number },\n): PanelSystemState => {\n const fromGroup = state.groups[payload.fromGroupId];\n const targetGroup = state.groups[payload.targetGroupId];\n if (!fromGroup || !targetGroup) {\n return state;\n }\n const tab = state.panels[payload.tabId];\n if (!tab) {\n return state;\n }\n if (payload.fromGroupId === payload.targetGroupId) {\n const filteredIds = fromGroup.tabIds.filter((id) => id !== payload.tabId);\n const insertIndex = Math.max(0, Math.min(payload.targetIndex, filteredIds.length));\n const nextTabIds = filteredIds.slice(0, insertIndex).concat([payload.tabId], filteredIds.slice(insertIndex));\n const nextTabs = nextTabIds.map((id) => state.panels[id]).filter(Boolean);\n const groups = { ...state.groups, [payload.fromGroupId]: { ...fromGroup, tabIds: nextTabIds, tabs: nextTabs } };\n return { ...state, groups };\n }\n const groups = { ...state.groups };\n const sourceIds = fromGroup.tabIds.filter((id) => id !== payload.tabId);\n const sourceTabs = sourceIds.map((id) => state.panels[id]);\n groups[payload.fromGroupId] = {\n ...fromGroup,\n tabIds: sourceIds,\n tabs: sourceTabs,\n activeTabId: fromGroup.activeTabId === payload.tabId ? sourceTabs[0]?.id ?? null : fromGroup.activeTabId,\n };\n const targetIdsBase = targetGroup.tabIds.filter((id) => id !== payload.tabId);\n const bounded = Math.max(0, Math.min(payload.targetIndex, targetIdsBase.length));\n const nextTargetIds = targetIdsBase.slice(0, bounded).concat([payload.tabId], targetIdsBase.slice(bounded));\n const targetTabs = nextTargetIds.map((id) => state.panels[id]).filter(Boolean);\n groups[payload.targetGroupId] = { ...targetGroup, tabIds: nextTargetIds, tabs: targetTabs, activeTabId: payload.tabId };\n return { ...state, groups, focusedGroupId: payload.targetGroupId };\n};\n\nconst handlers = createActionHandlerMap<PanelSystemState, typeof actions, ReducerExtra>(actions, {\n splitFocused: (state, action, extra) => {\n const gid = state.focusedGroupId ?? state.groupOrder[0] ?? null;\n if (!gid) {\n return state;\n }\n if (!canSplitDirection(state.tree, gid, action.payload.direction, extra.splitLimits)) {\n return state;\n }\n return splitGroup(state, gid, action.payload.direction, extra.createGroupId);\n },\n focusGroupIndex: (state, action) => focusIdx(state, action.payload.index1Based),\n focusNextGroup: (state) => nextGroup(state),\n focusPrevGroup: (state) => prevGroup(state),\n setActiveTab: (state, action) => setActiveTab(state, action.payload.groupId, action.payload.tabId),\n addTab: (state, action) => {\n const { groupId, tab, index, makeActive } = action.payload;\n if (typeof index === \"number\") {\n return addTabToGroupAtIndex(state, groupId, tab, index, makeActive ?? true);\n }\n return addTabToGroup(state, groupId, tab, makeActive ?? true);\n },\n addNewTab: (state, action, extra) => {\n if (!extra.createPanelId) {\n throw new Error(\"addNewTab requires PanelSystemProvider.createPanelId\");\n }\n const id = extra.createPanelId();\n const tab: TabDefinition = { id, title: action.payload.title, render: () => action.payload.title };\n const { groupId, index, makeActive } = action.payload;\n if (typeof index === \"number\") {\n return addTabToGroupAtIndex(state, groupId, tab, index, makeActive ?? true);\n }\n return addTabToGroup(state, groupId, tab, makeActive ?? true);\n },\n removeTab: (state, action) => removeTabFromGroup(state, action.payload.groupId, action.payload.tabId),\n contentDrop: (state, action, extra) => handleContentDrop(state, action.payload, extra),\n tabDrop: (state, action) => handleTabDrop(state, action.payload),\n adjustSplitRatio: (state, action) => {\n const node = getAtPath(state.tree, action.payload.path);\n if (isGroup(node)) {\n return state;\n }\n const nextTree = setSplitRatio(state.tree, action.payload.path, node.ratio + action.payload.deltaRatio);\n return { ...state, tree: nextTree };\n },\n});\n\nconst reducePanelState = (state: PanelSystemState, action: PanelStateAction, extra: ReducerExtra): PanelSystemState => {\n const handler = handlers[action.type];\n if (!handler) {\n return state;\n }\n const next = handler(state, action, extra);\n return cleanupEmptyGroups(next);\n};\n\nexport type PanelSystemContextValue = {\n state: PanelSystemState;\n dispatch: (action: PanelStateAction) => void;\n actions: PanelStateActions;\n};\n\nconst PanelSystemContext = React.createContext<PanelSystemContextValue | null>(null);\n\nexport const usePanelSystem = (): PanelSystemContextValue => {\n const ctx = React.useContext(PanelSystemContext);\n if (!ctx) {\n throw new Error(\"usePanelSystem must be used within PanelSystemProvider\");\n }\n return ctx;\n};\n\nexport type PanelSystemProviderProps = React.PropsWithChildren<{\n initialState: PanelSystemState;\n createGroupId: () => GroupId;\n createPanelId?: () => PanelId;\n state?: PanelSystemState;\n onStateChange?: (next: PanelSystemState) => void;\n splitLimits?: PanelSplitLimits;\n}>;\n\nexport const PanelSystemProvider: React.FC<PanelSystemProviderProps> = ({\n initialState,\n createGroupId,\n createPanelId,\n state: controlled,\n onStateChange,\n splitLimits,\n children,\n}) => {\n const initialSanitized = React.useMemo(() => cleanupEmptyGroups(initialState), [initialState]);\n const normalizedSplitLimits = React.useMemo(() => normalizeSplitLimits(splitLimits), [splitLimits]);\n const extraRef = React.useRef<ReducerExtra>({ createGroupId, splitLimits: normalizedSplitLimits, createPanelId });\n extraRef.current.createGroupId = createGroupId;\n extraRef.current.splitLimits = normalizedSplitLimits;\n extraRef.current.createPanelId = createPanelId;\n const [uncontrolled, baseDispatch] = React.useReducer(\n (prev: PanelSystemState, action: PanelStateAction) => reducePanelState(prev, action, extraRef.current),\n initialSanitized,\n );\n const derivedState = React.useMemo(\n () => (controlled ? cleanupEmptyGroups(controlled) : uncontrolled),\n [controlled, uncontrolled],\n );\n const stateRef = React.useRef<PanelSystemState>(derivedState);\n stateRef.current = derivedState;\n const isControlled = controlled !== undefined;\n\n const dispatch = React.useCallback(\n (action: PanelStateAction) => {\n if (isControlled) {\n const next = reducePanelState(stateRef.current, action, extraRef.current);\n onStateChange?.(next);\n return;\n }\n baseDispatch(action);\n },\n [isControlled, onStateChange, baseDispatch],\n );\n\n const boundActions = React.useMemo<PanelStateActions>(() => bindActionCreators(actions, dispatch), [dispatch]);\n\n const groupsActions = React.useMemo<GroupsActions>(\n () => ({\n setActiveTab: boundActions.setActiveTab,\n tabDrop: boundActions.tabDrop,\n }),\n [boundActions],\n );\n\n const treeActions = React.useMemo<TreeActions>(\n () => ({\n adjustSplitRatio: boundActions.adjustSplitRatio,\n }),\n [boundActions],\n );\n\n const focusActions = React.useMemo<FocusActions>(\n () => ({\n focusGroupIndex: boundActions.focusGroupIndex,\n focusNextGroup: boundActions.focusNextGroup,\n focusPrevGroup: boundActions.focusPrevGroup,\n }),\n [boundActions],\n );\n\n const value = React.useMemo<PanelSystemContextValue>(\n () => ({\n state: derivedState,\n dispatch,\n actions: boundActions,\n }),\n [derivedState, dispatch, boundActions],\n );\n\n return (\n <PanelSystemContext.Provider value={value}>\n <GroupsProvider value={groupsActions}>\n <TreeProvider value={treeActions}>\n <FocusProvider value={focusActions}>{children}</FocusProvider>\n </TreeProvider>\n </GroupsProvider>\n </PanelSystemContext.Provider>\n );\n};\n\nexport type { PanelStateAction, PanelStateActions };\n","/**\n * @file Hooks that expose commands and commit handlers for the panel system.\n */\nimport * as React from \"react\";\nimport type { DropZone, PanelCommands } from \"../state/types\";\nimport { usePanelState } from \"../state/StateContext\";\n\nexport const usePanelCommands = (): PanelCommands => {\n const { actions } = usePanelState();\n return React.useMemo<PanelCommands>(\n () => ({\n splitFocused: (direction) => {\n actions.splitFocused(direction);\n },\n focusGroupIndex: (n) => {\n actions.focusGroupIndex(n);\n },\n focusNextGroup: () => {\n actions.focusNextGroup();\n },\n focusPrevGroup: () => {\n actions.focusPrevGroup();\n },\n closeFocusedGroup: () => {\n // intentionally no-op for now\n },\n }),\n [actions],\n );\n};\n\nexport const useCommitHandlers = (): {\n onCommitContentDrop: (payload: { fromGroupId: string; tabId: string; targetGroupId: string; zone: DropZone }) => void;\n onCommitTabDrop: (payload: { fromGroupId: string; tabId: string; targetGroupId: string; targetIndex: number }) => void;\n} => {\n const { actions } = usePanelState();\n\n const onCommitContentDrop = React.useCallback(\n ({ fromGroupId, tabId, targetGroupId, zone }: { fromGroupId: string; tabId: string; targetGroupId: string; zone: DropZone }) => {\n actions.contentDrop({ fromGroupId, tabId, targetGroupId, zone });\n },\n [actions],\n );\n\n const onCommitTabDrop = React.useCallback(\n ({ fromGroupId, tabId, targetGroupId, targetIndex }: { fromGroupId: string; tabId: string; targetGroupId: string; targetIndex: number }) => {\n actions.tabDrop({ fromGroupId, tabId, targetGroupId, targetIndex });\n },\n [actions],\n );\n\n return { onCommitContentDrop, onCommitTabDrop };\n};\n","/**\n * @file Registers default keybindings using the single-source commands.\n */\nimport * as React from \"react\";\nimport { useKeybindings, registerDefaultBindings } from \"../../keybindings/KeybindingsProvider\";\nimport { usePanelCommands } from \"../state/commands\";\n\nexport const DefaultKeybindingsInstaller: React.FC = () => {\n const api = useKeybindings();\n const commands = usePanelCommands();\n React.useEffect(() => {\n registerDefaultBindings(api, commands);\n }, [api, commands]);\n return null;\n};\n","/**\n * @file Registry for panel content instances.\n * Manages component lifecycle to preserve state across tab switches and panel moves.\n *\n * ## Architecture\n *\n * This module solves the problem of preserving React component state when panels\n * move between different container elements (groups).\n *\n * ### The Problem\n * React portals remount their content when the container element changes.\n * This is React's intentional behavior, but it causes state loss when panels move.\n *\n * ### The Solution\n * 1. Create a stable wrapper element per panel (outside React's tree management)\n * 2. Use createPortal to render React content INTO the wrapper\n * 3. Move the wrapper between containers using appendChild\n *\n * This works because:\n * - React only manages content INSIDE the wrapper (via portal)\n * - React doesn't track the wrapper's position in DOM\n * - Moving the wrapper doesn't trigger React reconciliation\n *\n * ### DOM API Usage\n * - document.createElement: Creates wrapper element (once per panel)\n * - appendChild: Moves wrapper to target container\n * - removeChild: Cleans up wrapper on unmount\n *\n * These are the minimum DOM APIs required. React features handle everything else.\n */\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { PanelId, GroupId, TabDefinition } from \"../state/types\";\nimport { useIsomorphicLayoutEffect } from \"../../../hooks/useIsomorphicLayoutEffect\";\nimport { useContentCache } from \"../../../hooks/useContentCache\";\n\ntype PanelPlacement = {\n groupId: GroupId;\n isActive: boolean;\n};\n\ntype ContentRegistryContextValue = {\n registerContentContainer: (groupId: GroupId, element: HTMLElement | null) => void;\n};\n\nconst ContentRegistryContext = React.createContext<ContentRegistryContextValue | null>(null);\n\nexport const useContentRegistry = (): ContentRegistryContextValue => {\n const ctx = React.useContext(ContentRegistryContext);\n if (!ctx) {\n throw new Error(\"useContentRegistry must be used within ContentRegistryProvider\");\n }\n return ctx;\n};\n\n/**\n * Creates a wrapper element for panel content.\n * This element lives outside React's tree management so it can be moved freely.\n */\nconst createPanelWrapper = (panelId: PanelId): HTMLDivElement => {\n const wrapper = document.createElement(\"div\");\n wrapper.setAttribute(\"data-panel-wrapper\", panelId);\n wrapper.style.display = \"contents\";\n return wrapper;\n};\n\n/**\n * Hook to manage wrapper element lifecycle and positioning.\n *\n * Uses React.useState for lazy initialization (wrapper created once).\n * Uses useIsomorphicLayoutEffect for DOM manipulation (SSR-safe).\n */\nconst usePanelWrapper = (\n panelId: PanelId,\n containerElement: HTMLElement | null,\n isActive: boolean,\n): HTMLDivElement => {\n // Create wrapper once using React's lazy state initialization\n const [wrapper] = React.useState(() => createPanelWrapper(panelId));\n\n // Manage wrapper position and visibility\n useIsomorphicLayoutEffect(() => {\n wrapper.style.display = isActive ? \"contents\" : \"none\";\n\n if (containerElement && wrapper.parentElement !== containerElement) {\n containerElement.appendChild(wrapper);\n }\n\n return () => {\n wrapper.parentElement?.removeChild(wrapper);\n };\n }, [wrapper, containerElement, isActive]);\n\n return wrapper;\n};\n\n/**\n * Host component for panel content.\n * Uses createPortal to render React content into a stable wrapper element.\n */\ntype PanelContentHostProps = {\n panelId: PanelId;\n content: React.ReactNode;\n placement: PanelPlacement | null;\n containerElement: HTMLElement | null;\n};\n\nconst PanelContentHost: React.FC<PanelContentHostProps> = React.memo(\n ({ panelId, content, placement, containerElement }) => {\n const isActive = placement?.isActive ?? false;\n const wrapper = usePanelWrapper(panelId, containerElement, isActive);\n\n // Portal renders React content INTO the wrapper\n // React manages content lifecycle, not wrapper position\n return createPortal(\n <React.Activity mode={isActive ? \"visible\" : \"hidden\"}>\n {content}\n </React.Activity>,\n wrapper,\n );\n },\n);\nPanelContentHost.displayName = \"PanelContentHost\";\n\ntype ContentRegistryProviderProps = React.PropsWithChildren<{\n panels: Record<PanelId, TabDefinition>;\n placements: Record<PanelId, PanelPlacement>;\n}>;\n\n/**\n * Provider that manages panel content lifecycle.\n * Caches rendered content per panel to preserve React element identity.\n */\nexport const ContentRegistryProvider: React.FC<ContentRegistryProviderProps> = ({\n children,\n panels,\n placements,\n}) => {\n const [containers, setContainers] = React.useState<Map<GroupId, HTMLElement>>(new Map());\n\n const registerContentContainer = React.useCallback((groupId: GroupId, element: HTMLElement | null): void => {\n setContainers((prev) => {\n const next = new Map(prev);\n if (element) {\n next.set(groupId, element);\n } else {\n next.delete(groupId);\n }\n return next;\n });\n }, []);\n\n const value = React.useMemo<ContentRegistryContextValue>(\n () => ({ registerContentContainer }),\n [registerContentContainer],\n );\n\n // Store panels in ref for stable resolveContent function\n const panelsRef = React.useRef(panels);\n panelsRef.current = panels;\n\n // Content resolver for useContentCache\n const resolveContent = React.useCallback((panelId: PanelId): React.ReactNode | null => {\n const tab = panelsRef.current[panelId];\n if (!tab) {\n return null;\n }\n return tab.render(tab.id);\n }, []);\n\n // Valid IDs for cache cleanup\n const validIds = React.useMemo(() => Object.keys(panels), [panels]);\n\n // Use shared content cache hook\n const { getCachedContent } = useContentCache({\n resolveContent,\n validIds,\n });\n\n const panelIds = Object.keys(panels);\n\n return (\n <ContentRegistryContext.Provider value={value}>\n {children}\n {panelIds.map((panelId) => {\n const tab = panels[panelId];\n if (!tab) {\n return null;\n }\n const placement = placements[panelId] ?? null;\n const containerElement = placement ? containers.get(placement.groupId) ?? null : null;\n const content = getCachedContent(panelId);\n return (\n <PanelContentHost\n key={panelId}\n panelId={panelId}\n content={content}\n placement={placement}\n containerElement={containerElement}\n />\n );\n })}\n </ContentRegistryContext.Provider>\n );\n};\n","/**\n * @file Bridge component that binds InteractionsContext to PanelRenderContext using panel state.\n */\nimport * as React from \"react\";\nimport { usePanelInteractions } from \"../interactions/InteractionsContext\";\nimport { PanelRenderProvider } from \"./RenderContext\";\nimport { usePanelState } from \"../state/StateContext\";\nimport { ContentRegistryProvider, useContentRegistry } from \"./ContentRegistry\";\nimport type { PanelId, GroupId } from \"../state/types\";\n\ntype PanelPlacement = {\n groupId: GroupId;\n isActive: boolean;\n};\n\nconst RenderBridgeInner: React.FC<React.PropsWithChildren<{ emptyContentComponent?: React.ComponentType; doubleClickToAdd?: boolean }>> = ({\n children,\n emptyContentComponent,\n doubleClickToAdd,\n}) => {\n const interactions = usePanelInteractions();\n const { state, actions } = usePanelState();\n const { registerContentContainer } = useContentRegistry();\n\n const DefaultEmpty: React.FC = React.useCallback(() => {\n return React.createElement(\"div\", { style: { color: \"#888\", fontSize: 12, padding: 12 } }, \"No tabs\");\n }, []);\n const Empty = emptyContentComponent ?? DefaultEmpty;\n\n const getGroup = React.useCallback(\n (id: string) => {\n const g = state.groups[id];\n if (!g) {\n return null;\n }\n const tabs = g.tabIds.map((tid) => state.panels[tid]).filter(Boolean);\n return { ...g, tabs };\n },\n [state.groups, state.panels],\n );\n\n const getGroupContent = React.useCallback(\n (id: string) => {\n const group = state.groups[id];\n if (!group || group.tabIds.length === 0) {\n return <Empty />;\n }\n // Content is rendered via Portal from ContentRegistry\n return null;\n },\n [state.groups, Empty],\n );\n\n const onClickTab = React.useCallback((gid: string, tabId: string) => {\n actions.setActiveTab(gid, tabId);\n }, [actions]);\n\n const onAddTab = React.useCallback((gid: string) => {\n actions.addNewTab({ groupId: gid, title: \"New Tab\", makeActive: true });\n }, [actions]);\n\n const onCloseTab = React.useCallback((gid: string, tabId: string) => {\n actions.removeTab(gid, tabId);\n }, [actions]);\n\n const onStartTabDrag = React.useCallback((tabId: string, groupId: string, e: React.PointerEvent) => {\n actions.setActiveTab(groupId, tabId);\n interactions.onStartTabDrag(tabId, groupId, e);\n }, [actions, interactions]);\n\n const onStartContentDrag = React.useCallback((groupId: string, e: React.PointerEvent<HTMLDivElement>) => {\n const g = state.groups[groupId];\n if (!g || !g.activeTabId) {\n return;\n }\n interactions.onStartContentDrag(groupId, g.activeTabId, e);\n }, [state.groups, interactions]);\n\n const value = React.useMemo(\n () => ({ getGroup, getGroupContent, onClickTab, onAddTab, onCloseTab, onStartTabDrag, onStartContentDrag, doubleClickToAdd, registerContentContainer }),\n [getGroup, getGroupContent, onClickTab, onAddTab, onCloseTab, onStartTabDrag, onStartContentDrag, doubleClickToAdd, registerContentContainer],\n );\n\n return <PanelRenderProvider value={value}>{children}</PanelRenderProvider>;\n};\n\nexport const RenderBridge: React.FC<React.PropsWithChildren<{ emptyContentComponent?: React.ComponentType; doubleClickToAdd?: boolean }>> = ({\n children,\n emptyContentComponent,\n doubleClickToAdd,\n}) => {\n const { state } = usePanelState();\n\n // Compute placements: which group each panel belongs to and if it's active\n const placements = React.useMemo(() => {\n const result: Record<PanelId, PanelPlacement> = {};\n for (const [groupId, group] of Object.entries(state.groups)) {\n for (const tabId of group.tabIds) {\n result[tabId] = {\n groupId,\n isActive: tabId === group.activeTabId,\n };\n }\n }\n return result;\n }, [state.groups]);\n\n return (\n <ContentRegistryProvider panels={state.panels} placements={placements}>\n <RenderBridgeInner emptyContentComponent={emptyContentComponent} doubleClickToAdd={doubleClickToAdd}>\n {children}\n </RenderBridgeInner>\n </ContentRegistryProvider>\n );\n};\n","/**\n * @file Connected split handles overlay.\n */\nimport * as React from \"react\";\nimport type { PanelTree } from \"../../panels/state/types\";\nimport type { NodePath, PathSegment } from \"../../panels/state/tree/logic\";\nimport { isGroup } from \"../../panels/state/tree/logic\";\nimport { usePanelState } from \"../../panels/state/StateContext\";\nimport { useTree } from \"../../panels/state/tree/Context\";\nimport { ResizeHandle } from \"../../../components/resizer/ResizeHandle\";\nimport { SPLIT_HANDLE_THICKNESS } from \"../../../constants/styles\";\nimport { useIsomorphicLayoutEffect } from \"../../../hooks/useIsomorphicLayoutEffect\";\n\ntype Rect = { x: number; y: number; w: number; h: number };\n\ntype Handle = {\n path: NodePath;\n direction: \"vertical\" | \"horizontal\";\n parentRect: Rect;\n linePos: number;\n};\n\nconst collectHandles = (node: PanelTree, path: NodePath, rect: Rect, acc: Handle[]): Handle[] => {\n if (isGroup(node)) {\n return acc;\n }\n const direction = node.direction;\n const linePos = direction === \"vertical\" ? rect.x + rect.w * node.ratio : rect.y + rect.h * node.ratio;\n acc.push({ path, direction, parentRect: rect, linePos });\n if (direction === \"vertical\") {\n const wA = rect.w * node.ratio;\n const wB = rect.w - wA;\n collectHandles(node.a, [...path, \"a\" as PathSegment], { x: rect.x, y: rect.y, w: wA, h: rect.h }, acc);\n collectHandles(node.b, [...path, \"b\" as PathSegment], { x: rect.x + wA, y: rect.y, w: wB, h: rect.h }, acc);\n return acc;\n }\n const hA = rect.h * node.ratio;\n const hB = rect.h - hA;\n collectHandles(node.a, [...path, \"a\" as PathSegment], { x: rect.x, y: rect.y, w: rect.w, h: hA }, acc);\n collectHandles(node.b, [...path, \"b\" as PathSegment], { x: rect.x, y: rect.y + hA, w: rect.w, h: hB }, acc);\n return acc;\n};\n\nexport type PanelSplitHandlesProps = { containerRef: React.RefObject<HTMLDivElement | null> };\n\nexport const PanelSplitHandles: React.FC<PanelSplitHandlesProps> = ({ containerRef }) => {\n const { state } = usePanelState();\n const { adjustSplitRatio } = useTree();\n\n const handles = React.useMemo(() => collectHandles(state.tree, [], { x: 0, y: 0, w: 100, h: 100 }, []), [state.tree]);\n\n // Measure container rect after layout to avoid reading stale geometry during render\n const [containerRect, setContainerRect] = React.useState<Pick<DOMRect, \"left\" | \"top\" | \"width\" | \"height\"> | null>(null);\n useIsomorphicLayoutEffect(() => {\n const el = containerRef.current;\n if (!el) {\n return;\n }\n const measure = (): void => {\n const r = el.getBoundingClientRect();\n setContainerRect({ left: r.left, top: r.top, width: r.width, height: r.height });\n };\n measure();\n function getResizeObserverCtor(): typeof ResizeObserver | null {\n try {\n const ctor = (window as { ResizeObserver?: typeof ResizeObserver }).ResizeObserver;\n return typeof ctor === \"function\" ? ctor : null;\n } catch {\n return null;\n }\n }\n const RO = getResizeObserverCtor();\n const ro: ResizeObserver | null = RO ? new RO(() => measure()) : null;\n if (ro) {\n ro.observe(el);\n }\n const onScroll = (): void => measure();\n window.addEventListener(\"scroll\", onScroll, true);\n return () => {\n window.removeEventListener(\"scroll\", onScroll, true);\n if (ro) {\n ro.disconnect();\n }\n };\n }, [containerRef, state.tree]);\n if (!containerRect) {\n return null;\n }\n\n const renderHandle = (handle: Handle, index: number): React.ReactNode => {\n // Compute viewport-fixed coordinates by adding container offsets\n const parentPx = {\n left: containerRect.left + (containerRect.width * handle.parentRect.x) / 100,\n top: containerRect.top + (containerRect.height * handle.parentRect.y) / 100,\n width: (containerRect.width * handle.parentRect.w) / 100,\n height: (containerRect.height * handle.parentRect.h) / 100,\n };\n\n const thickness = SPLIT_HANDLE_THICKNESS;\n\n if (handle.direction === \"vertical\") {\n const x = parentPx.left + (parentPx.width * (handle.linePos - handle.parentRect.x)) / handle.parentRect.w;\n const style: React.CSSProperties = {\n position: \"fixed\",\n left: `calc(${Math.round(x)}px - ${thickness} / 2)`,\n top: Math.round(parentPx.top),\n width: thickness,\n height: Math.round(parentPx.height),\n cursor: \"col-resize\",\n pointerEvents: \"auto\",\n };\n const onResize = (delta: number): void => {\n const parentWidth = (containerRect.width * handle.parentRect.w) / 100;\n const dRatio = parentWidth === 0 ? 0 : delta / parentWidth;\n adjustSplitRatio({ path: handle.path, deltaRatio: dRatio });\n };\n return (\n <div key={`split-${index}`} style={style}>\n <ResizeHandle direction=\"vertical\" onResize={onResize} />\n </div>\n );\n }\n\n const y = parentPx.top + (parentPx.height * (handle.linePos - handle.parentRect.y)) / handle.parentRect.h;\n const style: React.CSSProperties = {\n position: \"fixed\",\n left: Math.round(parentPx.left),\n top: `calc(${Math.round(y)}px - ${thickness} / 2)`,\n width: Math.round(parentPx.width),\n height: thickness,\n cursor: \"row-resize\",\n pointerEvents: \"auto\",\n };\n const onResize = (delta: number): void => {\n const parentHeight = (containerRect.height * handle.parentRect.h) / 100;\n const dRatio = parentHeight === 0 ? 0 : delta / parentHeight;\n adjustSplitRatio({ path: handle.path, deltaRatio: dRatio });\n };\n return (\n <div key={`split-${index}`} style={style}>\n <ResizeHandle direction=\"horizontal\" onResize={onResize} />\n </div>\n );\n };\n\n return <div style={{ position: \"fixed\", inset: 0, pointerEvents: \"none\" }}>{handles.map((h, idx) => renderHandle(h, idx))}</div>;\n};\n","/**\n * @file VSCode-like PanelSystem composed via module contexts and presentational components.\n */\nimport * as React from \"react\";\nimport type { DropZone, GroupId, PanelSystemProps, PanelSystemState } from \"../state/types\";\nimport { KeybindingsProvider } from \"../../keybindings/KeybindingsProvider\";\nimport { buildGridForAbsolutePanels, buildGridFromRects } from \"../layout/adapter\";\nimport { GridLayout } from \"../../../components/grid/GridLayout\";\nimport { GroupContainer } from \"../rendering/GroupContainer\";\nimport { InteractionsProvider, usePanelInteractions } from \"../interactions/InteractionsContext\";\nimport { DropSuggestOverlay } from \"../../../components/panels/DropSuggestOverlay\";\nimport { TabDragOverlay } from \"../../../components/tabs/TabDragOverlay\";\nimport { PanelStateProvider, usePanelState } from \"../state/StateContext\";\nimport { DefaultKeybindingsInstaller } from \"../keybindings/KeybindingsInstaller\";\nimport { useCommitHandlers } from \"../state/commands\";\nimport { RenderBridge } from \"../rendering/RenderBridge\";\nimport { DomRegistryProvider } from \"../dom/DomRegistry\";\nimport { PanelSplitHandles } from \"../state/PanelSplitHandles\";\nimport { canSplitDirection, normalizeSplitLimits, type NormalizedSplitLimits } from \"../state/splitLimits\";\n\nconst rootStyle: React.CSSProperties = {\n position: \"relative\",\n display: \"flex\",\n width: \"100%\",\n height: \"100%\",\n};\n\ntype PanelSystemContentProps = {\n containerRef: React.RefObject<HTMLDivElement | null>;\n layoutMode: PanelSystemProps[\"layoutMode\"];\n gridTracksInteractive?: boolean;\n dragThresholdPx: number;\n view?: PanelSystemProps[\"view\"];\n style?: React.CSSProperties;\n className?: string;\n tabBarComponent?: PanelSystemProps[\"tabBarComponent\"];\n panelGroupComponent?: PanelSystemProps[\"panelGroupComponent\"];\n splitLimits: NormalizedSplitLimits;\n emptyContentComponent?: PanelSystemProps[\"emptyContentComponent\"];\n doubleClickToAdd?: boolean;\n};\n\nconst GridLayoutRenderer = ({\n state,\n layoutMode,\n gridTracksInteractive,\n view,\n tabBarComponent,\n panelGroupComponent,\n}: {\n state: PanelSystemState;\n layoutMode: PanelSystemProps[\"layoutMode\"];\n gridTracksInteractive: PanelSystemProps[\"gridTracksInteractive\"];\n view: PanelSystemProps[\"view\"];\n tabBarComponent: PanelSystemProps[\"tabBarComponent\"];\n panelGroupComponent: PanelSystemProps[\"panelGroupComponent\"];\n}): React.ReactNode => {\n const renderGroup = (gid: GroupId): React.ReactNode => {\n if (view) {\n const ViewComponent = view;\n return <ViewComponent groupId={gid} />;\n }\n return <GroupContainer id={gid} TabBarComponent={tabBarComponent} PanelGroupComponent={panelGroupComponent} />;\n };\n if (layoutMode === \"grid\") {\n const grid = buildGridFromRects(state, renderGroup, Boolean(gridTracksInteractive));\n return <GridLayout config={grid.config} layers={grid.layers} />;\n }\n const grid = buildGridForAbsolutePanels(state, renderGroup);\n return <GridLayout config={grid.config} layers={grid.layers} />;\n};\n\nconst PanelSystemContent: React.FC<PanelSystemContentProps> = ({\n containerRef,\n layoutMode,\n gridTracksInteractive,\n dragThresholdPx,\n view,\n style,\n className,\n tabBarComponent,\n panelGroupComponent,\n splitLimits,\n emptyContentComponent,\n doubleClickToAdd,\n}) => {\n const { state } = usePanelState();\n const { onCommitContentDrop, onCommitTabDrop } = useCommitHandlers();\n\n const containerStyle = React.useMemo(() => ({ ...rootStyle, ...style }), [style]);\n\n const isZoneAllowed = React.useCallback(\n ({ targetGroupId, zone }: { targetGroupId: GroupId; zone: DropZone }): boolean => {\n if (zone === \"center\") {\n return true;\n }\n const direction = zone === \"left\" || zone === \"right\" ? \"vertical\" : \"horizontal\";\n return canSplitDirection(state.tree, targetGroupId, direction, splitLimits);\n },\n [state.tree, splitLimits],\n );\n\n return (\n <DomRegistryProvider>\n <InteractionsProvider\n containerRef={containerRef}\n dragThresholdPx={dragThresholdPx}\n onCommitContentDrop={onCommitContentDrop}\n onCommitTabDrop={onCommitTabDrop}\n isContentZoneAllowed={isZoneAllowed}\n >\n <RenderBridge emptyContentComponent={emptyContentComponent} doubleClickToAdd={doubleClickToAdd}>\n <div ref={containerRef} className={className} style={containerStyle}>\n <GridLayoutRenderer\n state={state}\n layoutMode={layoutMode}\n gridTracksInteractive={gridTracksInteractive}\n view={view}\n tabBarComponent={tabBarComponent}\n panelGroupComponent={panelGroupComponent}\n />\n </div>\n </RenderBridge>\n <PanelSplitHandles containerRef={containerRef} />\n <OverlayWithinProvider />\n </InteractionsProvider>\n </DomRegistryProvider>\n );\n};\n\nconst OverlayWithinProvider: React.FC = () => {\n const interactions = usePanelInteractions();\n return (\n <>\n <DropSuggestOverlay suggest={interactions.suggest} />\n <TabDragOverlay />\n </>\n );\n};\n\nexport const PanelSystem: React.FC<PanelSystemProps> = ({\n initialState,\n createGroupId,\n createPanelId,\n layoutMode,\n gridTracksInteractive,\n dragThresholdPx,\n view,\n emptyContentComponent,\n state: controlled,\n onStateChange,\n className,\n style,\n tabBarComponent,\n panelGroupComponent,\n splitLimits,\n doubleClickToAdd,\n}) => {\n if (!initialState) {\n throw new Error(\"PanelSystem requires initialState.\");\n }\n if (!createGroupId) {\n throw new Error(\"PanelSystem requires explicit createGroupId function.\");\n }\n if (!layoutMode) {\n throw new Error(\"PanelSystem requires explicit layoutMode ('absolute' | 'grid').\");\n }\n if (layoutMode === \"grid\" && gridTracksInteractive === undefined) {\n throw new Error(\"PanelSystem(layoutMode='grid') requires explicit 'gridTracksInteractive' flag.\");\n }\n if (dragThresholdPx === undefined) {\n throw new Error(\"PanelSystem requires explicit 'dragThresholdPx' value.\");\n }\n\n const containerRef = React.useRef<HTMLDivElement | null>(null);\n const normalizedSplitLimits = React.useMemo(() => normalizeSplitLimits(splitLimits), [splitLimits]);\n\n return (\n <PanelStateProvider\n initialState={initialState}\n createGroupId={createGroupId}\n createPanelId={createPanelId}\n state={controlled}\n onStateChange={onStateChange}\n splitLimits={splitLimits}\n >\n <KeybindingsProvider>\n <DefaultKeybindingsInstaller />\n <PanelSystemContent\n containerRef={containerRef}\n layoutMode={layoutMode}\n gridTracksInteractive={gridTracksInteractive}\n dragThresholdPx={dragThresholdPx}\n view={view}\n style={style}\n className={className}\n tabBarComponent={tabBarComponent}\n panelGroupComponent={panelGroupComponent}\n splitLimits={normalizedSplitLimits}\n emptyContentComponent={emptyContentComponent}\n doubleClickToAdd={doubleClickToAdd}\n />\n </KeybindingsProvider>\n </PanelStateProvider>\n );\n};\n"],"names":["buildDividerStyle","state","HORIZONTAL_DIVIDER_WIDTH","COLOR_RESIZE_HANDLE_ACTIVE","COLOR_RESIZE_HANDLE_HOVER","COLOR_RESIZE_HANDLE_IDLE","HorizontalDivider","onResize","Component","element","ref","isDragging","onPointerDown","useResizeDrag","hovered","setHovered","React","dividerProps","jsx","useLayerDragHandle","layerId","useLayerInstance","getLayerHandleProps","useGridLayoutContext","DEFAULT_POSITION","DEFAULT_SIZE","useFloatingState","layers","floatingStates","setFloatingStates","initial","layer","floating","layerMap","map","getPosition","getSize","getZIndex","updatePosition","position","prev","currentState","updateSize","size","close","KeybindingsContext","useKeybindings","ctx","normalizeEventToCombo","e","parts","key","KeybindingsProvider","children","configure","handlersRef","register","combo","handler","unregister","rest","onKeyDown","api","registerDefaultBindings","commands","isGroup","node","computeRects","bounds","result","walk","n","rect","wA","wB","hA","hB","buildGridForAbsolutePanels","renderGroup","rects","config","groupId","r","style","buildGridFromRects","interactiveTracks","xs","a","b","ys","colSizes","x","i","rowSizes","y","columns","rows","areaForCell","x0","x1","y0","y1","gid","areas","ri","row","ci","PanelRenderContext","usePanelRenderContext","PanelRenderProvider","value","DomRegistryContext","useDomRegistry","DomRegistryProvider","mapRef","ensure","current","next","setGroupEl","el","v","setTabbarEl","setContentEl","getAll","groupStyle","contentStyle","createContentNode","contentElement","ContentComponent","contentProps","content","createGroupNode","GroupComponent","groupProps","groupContent","RawPanelGroupView","group","tabbar","onContentPointerDown","groupRef","contentRef","contentNode","jsxs","Fragment","PanelGroupView","pickDropZone","left","top","width","height","localX","localY","thirdW","thirdH","createAction","type","payloadCreator","actionCreator","args","payload","bindActionCreators","creators","dispatch","bound","creator","action","createActionHandlerMap","handlers","initialState","actions","reducerHandlers","_state","reducer","InteractionsContext","usePanelInteractions","InteractionsProvider","containerRef","dragThresholdPx","onCommitContentDrop","onCommitTabDrop","isContentZoneAllowed","dom","captureLayout","all","groups","els","it","tabbars","contents","onMove","useEffectEvent","ev","phase","dx","dy","candidate","zone","tabbarHit","btnRects","centers","firstIdx","c","targetIndex","insertX","onUp","container","snapshot","hit","targetGroupId","btn","contentHit","onCancel","onStartContentDrag","tabId","cache","onStartTabDrag","target","tabStyle","TabBarTab","tab","active","dragging","onClickTab","onStartDrag","onCloseTab","TabComponent","tabElement","onDoubleClick","handleClick","handlePointerDown","renderCloseButton","hasClose","divProps","buttonProps","tabbarStyle","spacerStyle","TabBar","rootRef","ContainerComponent","onAddTab","doubleClickToAdd","isTabDragging","draggingTabId","localRef","setRefs","handleKeyDown","root","tabs","focusTabAt","index","clamped","activeEl","currentIndex","id","hasModifier","keyLower","containerProps","Wrapper","useElementComponentWrapper","renderAddButton","handleTabbarDoubleClick","GroupContainer","TabBarComponent","PanelGroupComponent","getGroup","getGroupContent","registerContentContainer","tabbarRef","props","multiplyMatrices","col","createMatrix","values","m","applyTransform","transformValues","z","angle","len","s","t","angleX","angleY","tanX","tanY","distance","matrix","overlayStyle","DROP_SUGGEST_Z_INDEX","suggestRectBaseStyle","DROP_SUGGEST_BORDER_WIDTH","DROP_SUGGEST_BORDER_COLOR","DROP_SUGGEST_BG_COLOR","DROP_SUGGEST_BORDER_RADIUS","safeRatio","base","clampNumber","buildZoneTransform","pad","halfPad","widthBase","heightBase","center","right","bottom","zoneTransforms","translateX","translateY","scaleX","scaleY","buildSuggestStyle","DROP_SUGGEST_PADDING_PX","DropSuggestOverlay","suggest","isBrowser","useClonedElementPreview","sourceEl","setSize","html","setHtml","useIsomorphicLayoutEffect","TAB_DRAG_OVERLAY_Z_INDEX","insertGuideBaseStyle","TAB_DRAG_INSERT_GUIDE_WIDTH","TAB_DRAG_INSERT_GUIDE_BORDER_RADIUS","TAB_DRAG_INSERT_GUIDE_COLOR","TAB_DRAG_INSERT_GUIDE_SHADOW","TabDragOverlay","dragPointer","tabbarHover","draggingTabElement","previewHtml","previewSize","hasPreview","previewBaseStyle","TAB_DRAG_PREVIEW_OFFSET_X","TAB_DRAG_PREVIEW_OFFSET_Y","previewStyle","guideStyle","collectGroupsInOrder","acc","getAtPath","path","setAtPath","head","findLeafParent","inA","splitLeaf","direction","createGroupId","newGroupId","entry","replacement","parentPath","parent","newParent","closeLeaf","survivor","newTree","survivorId","setSplitRatio","splitPath","ratio","cleanupEmptyGroups","removeIfEmpty","tree","survivorGroupId","_removed","restGroups","groupOrder","focusedGroupId","createEmptyGroup","addTabToGroup","makeActive","panels","tabIds","activeTabId","nextGroup","removeTabFromGroup","moveTab","fromGroupId","toGroupId","from","to","fromIds","toIds","fromActive","setActiveTab","addTabToGroupAtIndex","ids","boundedIndex","setFocusedGroup","focusGroupIndex","index1Based","idx","order","first","prevGroup","last","splitGroup","buildInitialState","GroupsContext","GroupsProvider","TreeContext","useTree","TreeProvider","FocusContext","FocusProvider","clampLimit","finite","toFiniteNumberOr","isObjectLimits","limits","isRowsColsLimits","normalizeSplitLimits","normalized","legacy","measureSplitExtents","previewSplitTree","preview","canSplitDirection","extents","handleContentDrop","extra","fromGroup","targetGroup","moved","afterSplit","destination","withTab","handleTabDrop","filteredIds","insertIndex","nextTabIds","nextTabs","sourceIds","sourceTabs","targetIdsBase","bounded","nextTargetIds","targetTabs","focusIdx","nextTree","reducePanelState","PanelSystemContext","usePanelSystem","PanelSystemProvider","createPanelId","controlled","onStateChange","splitLimits","initialSanitized","normalizedSplitLimits","extraRef","uncontrolled","baseDispatch","derivedState","stateRef","isControlled","boundActions","groupsActions","treeActions","focusActions","usePanelCommands","usePanelState","useCommitHandlers","DefaultKeybindingsInstaller","ContentRegistryContext","useContentRegistry","createPanelWrapper","panelId","wrapper","usePanelWrapper","containerElement","isActive","PanelContentHost","placement","createPortal","ContentRegistryProvider","placements","containers","setContainers","panelsRef","resolveContent","validIds","getCachedContent","useContentCache","panelIds","RenderBridgeInner","emptyContentComponent","interactions","DefaultEmpty","Empty","g","tid","RenderBridge","collectHandles","linePos","PanelSplitHandles","adjustSplitRatio","handles","containerRect","setContainerRect","measure","getResizeObserverCtor","ctor","RO","ro","onScroll","renderHandle","handle","parentPx","thickness","SPLIT_HANDLE_THICKNESS","ResizeHandle","delta","parentWidth","dRatio","parentHeight","h","rootStyle","GridLayoutRenderer","layoutMode","gridTracksInteractive","view","tabBarComponent","panelGroupComponent","grid","GridLayout","PanelSystemContent","className","containerStyle","isZoneAllowed","OverlayWithinProvider","PanelSystem","PanelStateProvider"],"mappings":";;;;;;;;;AAeA,MAAMA,KAAoB,CAACC,OAElB;AAAA,EACL,OAAOC;AAAA,EACP,Q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