Beautiful, AI-native markdown IDE and LLM wiki
TypeScript 2nd-brainagent-skillsclaudecodexcompany-braindocsknowledge-knowledge-baseknowledge-managementllmllm-wikillm-wiki-karpathymarkdownmarkdown-editormdmdxnotespkmsecond-brainskills
fix(open-knowledge): stop side panels getting stuck in a non-resizable state (PRD-7735) (#3177)
serafin-garciadcf4b79f18be
diff --git a/.changeset/panel-resize-stuck.md b/.changeset/panel-resize-stuck.mdnew file mode 100644index 000000000..ac7a79a42--- /dev/null+++ b/.changeset/panel-resize-stuck.md@@ -0,0 +1,9 @@+---+"@inkeep/open-knowledge": patch+---++Side panels no longer get stuck in a non-resizable state. Two separate faults could wedge them, both triggered by a drag that the browser ended with a cancel rather than a release — which happens when a scroll or zoom gesture takes over, or the system invalidates the pointer mid-drag.++The document panel and agents column tracked whether a drag was in flight but only ever cleared that flag on pointer release. After a cancelled drag the flag stayed set, and while it was set the layout correction that opens, closes and re-pins the right rail refused to run — so the document-panel toggle, ⌥⌘B, the avatar-click expand and the sticky panel widths all silently stopped working. The bottom terminal dock had the same gap, where a stuck flag instead made every later resize look like a user drag: the dock could hide itself unprompted and overwrite its saved height. Both handles now end a drag on cancel as well as release, restore the panel widths when a gesture is aborted rather than committing a drag-to-close the user never finished, and detach cleanly if the panel unmounts mid-drag.++Separately, a fault in the resizable-panels library could wedge things harder: after an error while a panel was mounting, every panel in the window could stop responding to drags until a full reload. A bundled patch now lets the library recover from that on its own, without the reload.diff --git a/packages/app/src/components/EditorArea.dom.test.tsx b/packages/app/src/components/EditorArea.dom.test.tsxindex 912a82484..bc868aca0 100644--- a/packages/app/src/components/EditorArea.dom.test.tsx+++ b/packages/app/src/components/EditorArea.dom.test.tsx@@ -497,6 +497,132 @@ describe('EditorArea right-rail layout assert on agents-column mount/unmount', (});expect(visibleChanges).toHaveLength(0);});++ // A drag ends on `pointerup` OR `pointercancel`, and a cancelled pointer+ // fires NO pointerup — once the browser suppresses a pointer stream (touch+ // pan/zoom/scroll takeover, or the OS invalidating the pointer) no further+ // events arrive for that pointerId. The handles used to bind only+ // `pointerup`, so a cancelled gesture left the drag flag set forever, and+ // `assertRightRailLayout` bails while either flag is set — silently+ // disabling the doc-panel toggle, ⌥⌘B, the avatar-click expand and the+ // sticky-width re-pin.+ test('a pointercancel-terminated drag still clears the flag that gates the layout assert', async () => {+ setViewportWidth(1400);+ const view = render(<EditorArea {...baseProps} agentsVisible />);+ const handle = screen.getByTestId('resizable-handle');+ act(() => {+ fireEvent.pointerDown(handle);+ });+ act(() => {+ fireEvent.pointerCancel(window);+ });+ // Drop the assert the cancel itself issues (it restores the rail pins) so+ // what follows can only come from the panel-set change.+ groupSetLayoutCalls = [];++ groupLayout = { 'editor-main': 45, 'doc-panel': 25, 'agents-column': 30 };+ view.rerender(<EditorArea {...baseProps} agentsVisible={false} />);+ await act(async () => {});+ expect(groupSetLayoutCalls.length).toBeGreaterThan(0);+ });++ test('a pointercancel restores the rail pins rather than committing a drag-to-close', async () => {+ setViewportWidth(1400);+ const visibleChanges: boolean[] = [];+ render(+ <EditorArea+ {...baseProps}+ agentsVisible+ onAgentsVisibleChange={(visible: boolean) => {+ visibleChanges.push(visible);+ }}+ />,+ );+ // What the group holds mid-drag: the editor plus the column the drag has+ // been shrinking. The assert needs a live panel-ID set to correct against.+ groupLayout = { 'editor-main': 70, 'agents-column': 30 };+ const handle = screen.getByTestId('resizable-handle');+ act(() => {+ fireEvent.pointerDown(handle);+ });+ // The drag had snapped the column shut, but the gesture was aborted rather+ // than released — the user never committed to closing it.+ panelIsCollapsed = true;+ act(() => {+ fireEvent.pointerCancel(window);+ });+ expect(visibleChanges).toHaveLength(0);+ // The column would otherwise sit at zero width while still counting as+ // visible: no reveal tab, no handle, no way back. The abort re-pins it.+ expect(groupSetLayoutCalls.at(-1)?.['agents-column']).toBeCloseTo(pctOf(480), 3);+ });++ // Unmounting mid-drag is the third drag-termination path (alongside release+ // and cancel) and the one with no natural trigger in the other tests: a+ // view-kind switch tears the subtree down while the pointer is still held.+ // Without the unmount detach, the still-registered `pointerup` would run+ // `onCommit` against a torn-down subtree and hide the agents panel the user+ // never asked to close.+ test('a drag interrupted by unmount does not commit a drag-to-close afterwards', async () => {+ setViewportWidth(1400);+ const visibleChanges: boolean[] = [];+ const view = render(+ <EditorArea+ {...baseProps}+ agentsVisible+ onAgentsVisibleChange={(visible: boolean) => {+ visibleChanges.push(visible);+ }}+ />,+ );+ const handle = screen.getByTestId('resizable-handle');+ act(() => {+ fireEvent.pointerDown(handle, { pointerId: 1 });+ });+ // The drag had snapped the column shut — so a surviving listener WOULD+ // commit the hide, which is what makes this assertion meaningful.+ panelIsCollapsed = true;+ act(() => {+ view.unmount();+ });+ act(() => {+ fireEvent.pointerUp(window, { pointerId: 1 });+ });+ expect(visibleChanges).toHaveLength(0);+ });++ // The drag-end listeners live on `window`, so every pointer on the page+ // reaches them. A second touch taken over by the browser for scrolling fires+ // `pointercancel` for ITS pointerId while this drag is still live; unscoped,+ // that would end the drag and re-pin the rail mid-gesture.+ test('a different pointer cancelling does not end an in-flight drag', async () => {+ setViewportWidth(1400);+ const view = render(<EditorArea {...baseProps} agentsVisible />);+ const handle = screen.getByTestId('resizable-handle');+ act(() => {+ fireEvent.pointerDown(handle, { pointerId: 1 });+ });+ groupSetLayoutCalls = [];+ groupLayout = { 'editor-main': 70, 'agents-column': 30 };++ // A second, unrelated pointer is cancelled by the browser.+ act(() => {+ fireEvent.pointerCancel(window, { pointerId: 2 });+ });+ expect(groupSetLayoutCalls).toHaveLength(0);++ // The drag is still live, so the panel-set change must still be suppressed+ // (the assert bails while a drag flag is set) — proving the flag survived.+ view.rerender(<EditorArea {...baseProps} agentsVisible={false} />);+ await act(async () => {});+ expect(groupSetLayoutCalls).toHaveLength(0);++ // The originating pointer still ends it.+ act(() => {+ fireEvent.pointerCancel(window, { pointerId: 1 });+ });+ expect(groupSetLayoutCalls.length).toBeGreaterThan(0);+ });});// Exactly ONE panel advertises itself with a persistent edge tab, and EditorAreadiff --git a/packages/app/src/components/EditorArea.tsx b/packages/app/src/components/EditorArea.tsxindex d556cddf5..98c5b3c4a 100644--- a/packages/app/src/components/EditorArea.tsx+++ b/packages/app/src/components/EditorArea.tsx@@ -642,34 +642,44 @@ function EditorAreaInner({if (isDraggingDocHandleRef.current || isDraggingAgentsHandleRef.current) return;const group = groupRef.current;if (group == null) return;- // The imperative handles throw once their group/panel has unregistered,- // and this can run from a deferred microtask racing a view-kind remount —- // a torn-down group just means there is no layout left to correct.+ // Only the library reads are guarded. The imperative handles throw once+ // their group/panel has unregistered, and this can run from a deferred+ // microtask racing a view-kind remount — a torn-down group just means+ // there is no layout left to correct. The layout math between the guards+ // is ours: swallowing its errors would hide a real bug behind the same+ // silent no-op.+ let containerPx: number | null;+ let layout: Record<string, number>;try {- const containerPx = resolveGroupPxWidth();- if (containerPx == null) return;- const layout = group.getLayout();- const ids = Object.keys(layout);- if (ids.length === 0) return;- const residualId = ids.find((id) => !RIGHT_PANEL_IDS.has(id));- if (residualId == null) return;- const pinnedPx: Record<string, number> = {};- if ('doc-panel' in layout) {- pinnedPx['doc-panel'] = docCollapsed ? 0 : docPanelWidthPxRef.current;- }- if ('agents-column' in layout) {- pinnedPx['agents-column'] = agentsWidthPxRef.current;- }- if (Object.keys(pinnedPx).length === 0) return;- const next = computeStickyRepinLayout({- currentLayout: layout,- containerPx,- pinnedPx,- residualId,- });- if (next !== layout) group.setLayout(next);+ containerPx = resolveGroupPxWidth();+ layout = group.getLayout();} catch {- // Group or panel unregistered mid-flight — nothing to assert against.+ return;+ }+ if (containerPx == null) return;+ const ids = Object.keys(layout);+ if (ids.length === 0) return;+ const residualId = ids.find((id) => !RIGHT_PANEL_IDS.has(id));+ if (residualId == null) return;+ const pinnedPx: Record<string, number> = {};+ if ('doc-panel' in layout) {+ pinnedPx['doc-panel'] = docCollapsed ? 0 : docPanelWidthPxRef.current;+ }+ if ('agents-column' in layout) {+ pinnedPx['agents-column'] = agentsWidthPxRef.current;+ }+ if (Object.keys(pinnedPx).length === 0) return;+ const next = computeStickyRepinLayout({+ currentLayout: layout,+ containerPx,+ pinnedPx,+ residualId,+ });+ if (next === layout) return;+ try {+ group.setLayout(next);+ } catch {+ // Unregistered between the read and the write.}}@@ -683,6 +693,73 @@ function EditorAreaInner({assertRightRailLayoutRef.current = assertRightRailLayout;});+ // Drag-end plumbing shared by the doc-panel and agents-column handles.+ //+ // A drag ends on `pointerup` OR `pointercancel`. A cancelled pointer fires+ // NO pointerup — once the browser suppresses a pointer stream (touch+ // pan/zoom/scroll takeover, or the OS invalidating the pointer) no further+ // events arrive for that pointerId. Binding only `pointerup` leaves the drag+ // flag set, and `assertRightRailLayout` bails while either flag is set — so+ // the doc-panel toggle, ⌥⌘B, the avatar-click expand and the sticky-width+ // re-pin all silently stop working, and `onResize` starts misreading re-pins+ // as user drags and overwriting the persisted width.+ //+ // Deliberately NOT bound: `lostpointercapture`. react-resizable-panels+ // re-acquires capture on every pointermove that lacks it, so capture loss is+ // routine mid-drag; treating it as a drag end would clear the flag under a+ // live drag — the race the flag exists to prevent. A separator that unmounts+ // mid-drag is already covered without it: capture releases implicitly and+ // the eventual pointerup retargets by hit-test and still reaches `window`.+ //+ // `onCommit` runs only on a real release: an aborted gesture must not commit+ // a drag-to-close.+ //+ // Both listeners are scoped to the `pointerId` that started the drag. A+ // second touch elsewhere on the page can be taken over by the browser for+ // scrolling, which fires `pointercancel` for THAT pointer while this drag is+ // still live; unscoped, it would end the drag and re-pin the rail mid-gesture+ // (the panel visibly snapping to its persisted width). Mirrors the existing+ // scoping in GraphView's pointer-drag handler.+ const endHandleDragRef = useRef<(() => void) | null>(null);+ function trackHandleDrag(+ pointerId: number,+ setDragging: (dragging: boolean) => void,+ draggingRef: { current: boolean },+ onCommit?: () => void,+ ) {+ // A prior gesture that never saw a release would otherwise leave its own+ // flag set forever. Clears whichever handle owned it, not just this one.+ endHandleDragRef.current?.();+ setDragging(true);+ draggingRef.current = true;+ function end() {+ window.removeEventListener('pointerup', onPointerUp);+ window.removeEventListener('pointercancel', onPointerCancel);+ endHandleDragRef.current = null;+ setDragging(false);+ draggingRef.current = false;+ }+ function onPointerUp(event: PointerEvent) {+ if (event.pointerId !== pointerId) return;+ end();+ onCommit?.();+ }+ function onPointerCancel(event: PointerEvent) {+ if (event.pointerId !== pointerId) return;+ end();+ // Restore both rail pins. A column the aborted drag had snapped shut+ // would otherwise sit at zero width while still counting as visible —+ // no reveal tab, no handle, no way back.+ assertRightRailLayoutRef.current(isCollapsedRef.current);+ }+ endHandleDragRef.current = end;+ window.addEventListener('pointerup', onPointerUp);+ window.addEventListener('pointercancel', onPointerCancel);+ }+ // Unmounting mid-drag (a view-kind switch under an active drag) would strand+ // both window listeners on a component React has already torn down.+ useEffect(() => () => endHandleDragRef.current?.(), []);+// Expand the doc panel from a non-toggle path (tab request, avatar click,// width-threshold crossing). Same routing rule as togglePanel: with the// agents column mounted, go through the full-layout assert so the width@@ -1322,15 +1399,8 @@ function EditorAreaInner({// under embedded AI-editor hosts whose own container chrome sits at// the iframe edge.disabled={isCollapsed}- onPointerDown={() => {- setIsDraggingDocHandle(true);- isDraggingDocHandleRef.current = true;- const handleUp = () => {- setIsDraggingDocHandle(false);- isDraggingDocHandleRef.current = false;- window.removeEventListener('pointerup', handleUp);- };- window.addEventListener('pointerup', handleUp);+ onPointerDown={(event) => {+ trackHandleDrag(event.pointerId, setIsDraggingDocHandle, isDraggingDocHandleRef);}}/><ResizablePanel@@ -1526,22 +1596,21 @@ function EditorAreaInner({<><ResizableHandlewithHandle- onPointerDown={() => {- setIsDraggingAgentsHandle(true);- isDraggingAgentsHandleRef.current = true;- const handleUp = () => {- setIsDraggingAgentsHandle(false);- isDraggingAgentsHandleRef.current = false;- window.removeEventListener('pointerup', handleUp);- // Drag-to-close: releasing with the column snapped shut hides the- // agents panel (unmounting the column), mirroring the doc panel's- // drag-to-close affordance. Deferred to pointerup — hiding- // mid-drag would unmount the separator under the active drag.- if (agentsColumnPanelRef.current?.isCollapsed()) {- onAgentsVisibleChange?.(false);- }- };- window.addEventListener('pointerup', handleUp);+ onPointerDown={(event) => {+ trackHandleDrag(+ event.pointerId,+ setIsDraggingAgentsHandle,+ isDraggingAgentsHandleRef,+ () => {+ // Drag-to-close: releasing with the column snapped shut hides the+ // agents panel (unmounting the column), mirroring the doc panel's+ // drag-to-close affordance. Deferred to the release — hiding+ // mid-drag would unmount the separator under the active drag.+ if (agentsColumnPanelRef.current?.isCollapsed()) {+ onAgentsVisibleChange?.(false);+ }+ },+ );}}/><ResizablePaneldiff --git a/packages/app/src/components/TerminalDock.dom.test.tsx b/packages/app/src/components/TerminalDock.dom.test.tsxindex bcf1749d9..1ee4b082b 100644--- a/packages/app/src/components/TerminalDock.dom.test.tsx+++ b/packages/app/src/components/TerminalDock.dom.test.tsx@@ -16,7 +16,7 @@*/import type { TerminalCli } from '@inkeep/open-knowledge-core';-import { act, cleanup, render, screen, waitFor, within } from '@testing-library/react';+import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react';import userEvent from '@testing-library/user-event';import { useEffect, useRef, useState } from 'react';import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';@@ -1184,6 +1184,69 @@ describe('TerminalDock multi-session', () => {}});+ // A drag ends on `pointerup` OR `pointercancel`, and a cancelled pointer+ // fires NO pointerup — once the browser suppresses a pointer stream (touch+ // pan/zoom/scroll takeover, or the OS invalidating the pointer) no further+ // events arrive for that pointerId. The handle used to bind only+ // `pointerup`, so an aborted gesture left `isDraggingRef` set: every later+ // imperative or observer-driven resize then read as a user drag, firing+ // `onVisibleChange` spuriously, overwriting the persisted height, and+ // suppressing the stranded-dock guard.+ test('a pointercancel-terminated drag stops later resizes reading as user drags', () => {+ const view = renderDock(true);+ const handle = screen.getByTestId('terminal-resize-handle');+ act(() => {+ fireEvent.pointerDown(handle);+ });+ act(() => {+ fireEvent.pointerCancel(window);+ });+ view.onVisibleChange.mockClear();++ // An imperative replay (the `visible` effect re-applying the persisted+ // height) reports a collapsed panel. Read as a user drag this would hide+ // the dock the user never asked to close.+ act(() => {+ terminalPanelProps?.onResize?.({ asPercentage: 0, inPixels: 0 });+ });+ expect(view.onVisibleChange).not.toHaveBeenCalled();+ });++ // The drag-end listeners sit on `window`, so every pointer on the page+ // reaches them. A second touch taken over by the browser for scrolling fires+ // `pointercancel` for ITS pointerId while this drag is still live — unscoped,+ // that would end the dock drag early. The dock's `endDragRef` / `onEnd`+ // closure is independent of EditorArea's, so it needs its own pin.+ test('a different pointer cancelling does not end an in-flight dock drag', () => {+ const view = renderDock(true);+ const handle = screen.getByTestId('terminal-resize-handle');+ act(() => {+ fireEvent.pointerDown(handle, { pointerId: 1 });+ });++ // An unrelated pointer is cancelled by the browser.+ act(() => {+ fireEvent.pointerCancel(window, { pointerId: 2 });+ });+ // The drag is still live, so a collapsed resize still reads as the user+ // dragging the dock shut — which is what proves the flag survived.+ view.onVisibleChange.mockClear();+ act(() => {+ terminalPanelProps?.onResize?.({ asPercentage: 0, inPixels: 0 });+ });+ expect(view.onVisibleChange).toHaveBeenCalledWith(false);++ // The originating pointer still ends it.+ act(() => {+ fireEvent.pointerCancel(window, { pointerId: 1 });+ });+ view.onVisibleChange.mockClear();+ act(() => {+ terminalPanelProps?.onResize?.({ asPercentage: 0, inPixels: 0 });+ });+ expect(view.onVisibleChange).not.toHaveBeenCalled();+ });+test('persists the bottom panel config (collapsible, sized, inert when hidden)', () => {renderDock(false);expect(terminalPanelProps?.collapsible).toBe(true);diff --git a/packages/app/src/components/TerminalDock.tsx b/packages/app/src/components/TerminalDock.tsxindex afd6824df..285c5f68a 100644--- a/packages/app/src/components/TerminalDock.tsx+++ b/packages/app/src/components/TerminalDock.tsx@@ -105,17 +105,14 @@ export function TerminalDock({);}- // The drag-end listener is added to `window` on pointerdown and normally removes- // itself on pointerup. If the shell unmounts mid-drag the closure would leak —- // track it so unmount can detach it.- const dragUpHandlerRef = useRef<(() => void) | null>(null);+ // The drag-end listeners are added to `window` on pointerdown and normally+ // detach themselves on `pointerup` or `pointercancel`. If the shell unmounts+ // mid-drag the closures would leak — track the detach so unmount can run it.+ const endDragRef = useRef<(() => void) | null>(null);useEffect(() => () => {if (writeTimerRef.current != null) clearTimeout(writeTimerRef.current);- if (dragUpHandlerRef.current != null) {- window.removeEventListener('pointerup', dragUpHandlerRef.current);- dragUpHandlerRef.current = null;- }+ endDragRef.current?.();},[],);@@ -189,18 +186,40 @@ export function TerminalDock({<ResizableHandlewithHandle={visible}disabled={!visible}- onPointerDown={() => {+ onPointerDown={(event) => {if (!visible) return;+ // A prior gesture that never saw a release would otherwise leave the+ // flag set forever.+ endDragRef.current?.();setIsDragging(true);isDraggingRef.current = true;- const handleUp = () => {+ const { pointerId } = event;+ // A drag ends on `pointerup` OR `pointercancel`: a cancelled pointer+ // fires NO pointerup — once the browser suppresses a pointer stream+ // (touch pan/zoom/scroll takeover, or the OS invalidating the+ // pointer) no further events arrive for that pointerId. Without the+ // cancel arm the flag stays set, and every later imperative or+ // observer-driven resize reads as a user drag: `onVisibleChange`+ // fires spuriously, the persisted height gets overwritten, and the+ // stranded-dock guard stops firing.+ //+ // `window` is the right target because a release outside the dock+ // still lands there; both listeners are scoped to the originating+ // `pointerId` so a second touch's cancel cannot end this drag.+ const end = () => {setIsDragging(false);isDraggingRef.current = false;- window.removeEventListener('pointerup', handleUp);- dragUpHandlerRef.current = null;+ window.removeEventListener('pointerup', onEnd);+ window.removeEventListener('pointercancel', onEnd);+ endDragRef.current = null;+ };+ const onEnd = (ev: PointerEvent) => {+ if (ev.pointerId !== pointerId) return;+ end();};- dragUpHandlerRef.current = handleUp;- window.addEventListener('pointerup', handleUp);+ endDragRef.current = end;+ window.addEventListener('pointerup', onEnd);+ window.addEventListener('pointercancel', onEnd);}}/><ResizablePaneldiff --git a/packages/app/src/components/resizable-panel-listener-attach.dom.test.tsx b/packages/app/src/components/resizable-panel-listener-attach.dom.test.tsxnew file mode 100644index 000000000..ccd62b552--- /dev/null+++ b/packages/app/src/components/resizable-panel-listener-attach.dom.test.tsx@@ -0,0 +1,136 @@+import { act, cleanup, render } from '@testing-library/react';+import { Group, Panel, Separator } from 'react-resizable-panels';+import { afterEach, describe, expect, test } from 'vitest';++// Regression guard for panels that go permanently non-resizable mid-session.+//+// react-resizable-panels installs its global pointer handlers on the owner+// document from `mountGroup`, behind a reference count shared by every mounted+// group. Upstream the install is gated on the count being exactly 1 — but the+// count is incremented several statements BEFORE the install, and everything in+// between can throw (`calculateHitRegions`, the `groupChange` emit that+// synchronously runs Panel `onResize` and Separator subscribers, the+// "Separator ids must be unique" assert). A throw there means `mountGroup`+// never returns its unmount closure, so nothing ever decrements the count: it+// stays pinned above 0 and the `=== 1` gate never fires again. Every panel in+// the document stops responding to drags until a reload, and because the throw+// surfaces as an error-boundary trip the cause looks unrelated.+//+// We patch the library (patches/[email protected]) to install+// unconditionally. `addEventListener` de-dupes identical (type, listener,+// capture) triples and the handlers are module-level singletons, so repeat+// installs are no-ops — which makes any refcount skew self-healing on the next+// group mount rather than permanent.+//+// Scope note: this drives the leak through the separator-id assert because it+// is the cheapest throw to stage. The other throw sites in that window are not+// exercised individually — they all funnel through the same install, so the+// guard holds for them too, but a refactor that moved the install out from+// under `mountGroup` could regress them while this test stayed green.++afterEach(cleanup);++/** Counts installs/removals of the library's document-level pointerdown handler. */+function trackPointerdownListeners() {+ let installs = 0;+ let removals = 0;+ const originalAdd = document.addEventListener.bind(document);+ const originalRemove = document.removeEventListener.bind(document);+ document.addEventListener = ((type: string, ...rest: unknown[]) => {+ if (type === 'pointerdown') installs += 1;+ // @ts-expect-error variadic passthrough to the captured original+ return originalAdd(type, ...rest);+ }) as typeof document.addEventListener;+ document.removeEventListener = ((type: string, ...rest: unknown[]) => {+ if (type === 'pointerdown') removals += 1;+ // @ts-expect-error variadic passthrough to the captured original+ return originalRemove(type, ...rest);+ }) as typeof document.removeEventListener;+ return {+ get installs() {+ return installs;+ },+ get removals() {+ return removals;+ },+ restore() {+ document.addEventListener = originalAdd;+ document.removeEventListener = originalRemove;+ },+ };+}++function HealthyGroup() {+ return (+ <Group orientation="horizontal" style={{ width: 900 }}>+ <Panel minSize="10%">editor</Panel>+ <Separator />+ <Panel minSize="10%">doc</Panel>+ </Group>+ );+}++// Duplicate separator ids trip `assert(!separatorIds.has(separator.id))`, which+// upstream runs after the refcount increment and before the handler install.+function GroupThatThrowsDuringMount() {+ return (+ <Group orientation="horizontal" style={{ width: 900 }}>+ <Panel minSize="10%">a</Panel>+ <Separator id="duplicate" />+ <Panel minSize="10%">b</Panel>+ <Separator id="duplicate" />+ <Panel minSize="10%">c</Panel>+ </Group>+ );+}++describe('react-resizable-panels installs its pointer handlers on every group mount', () => {+ test('a healthy group installs the document pointerdown handler, and removes it on unmount', async () => {+ const listeners = trackPointerdownListeners();+ try {+ await act(async () => {+ render(<HealthyGroup />);+ });+ expect(listeners.installs).toBeGreaterThan(0);++ // Teardown still balances: the patch drops the install-side count gate,+ // not the removal-side one, so the last group to unmount must still+ // uninstall what it installed. Asserting the pair pins that the patch+ // didn't turn the handlers into a permanent document-level leak.+ await act(async () => {+ cleanup();+ });+ expect(listeners.removals).toBeGreaterThan(0);+ } finally {+ listeners.restore();+ }+ });++ test('a group whose mount threw does not stop later groups from installing', async () => {+ // Stage the leak: this mount increments the refcount, throws before the+ // install, and never yields an unmount closure to decrement it.+ try {+ await act(async () => {+ render(<GroupThatThrowsDuringMount />);+ });+ } catch {+ // The throw is the point — it reaches the app's error boundary in+ // production. What matters is the state it leaves behind.+ }+ cleanup();++ // A well-formed group mounted afterwards must still get working handlers.+ // Before the patch this installed nothing: the refcount was stuck at 1, so+ // the `=== 1` gate never matched again and every panel in the document was+ // undraggable for the life of the page.+ const listeners = trackPointerdownListeners();+ try {+ await act(async () => {+ render(<HealthyGroup />);+ });+ expect(listeners.installs).toBeGreaterThan(0);+ } finally {+ listeners.restore();+ }+ });+});diff --git a/patches/[email protected] b/patches/[email protected]index 7f46ab0cb..5ee557b0b 100644--- a/patches/[email protected]+++ b/patches/[email protected]@@ -1,13 +1,13 @@diff --git a/dist/react-resizable-panels.cjs b/dist/react-resizable-panels.cjs-index 2083424e74cbaf3a9eac40f4803aee8fc4a943c4..df2b1a2509641955a2bac2fc35d5ded2c6bf1617 100644+index 2083424e74cbaf3a9eac40f4803aee8fc4a943c4..7c4b0bb7c3fca4b74a54f653d96db70660feb6b1 100644--- a/dist/react-resizable-panels.cjs+++ b/dist/react-resizable-panels.cjs@@ -1,2 +1,2 @@-"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("react/jsx-runtime"),z=require("react");function dt(e,t){const n=getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function pt(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),o=parseFloat(n.fontSize);return t*o}function ht(e){return e/100*window.innerHeight}function mt(e){return e/100*window.innerWidth}function gt(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function oe({groupSize:e,panelElement:t,styleProp:n}){let o;const[i,s]=gt(n);switch(s){case"%":{o=i/100*e;break}case"px":{o=i;break}case"rem":{o=pt(t,i);break}case"em":{o=dt(t,i);break}case"vh":{o=ht(i);break}case"vw":{o=mt(i);break}}return o}function O(e){return parseFloat(e.toFixed(3))}function te({group:e}){const{orientation:t,panels:n}=e;return n.reduce((o,i)=>(o+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,o),0)}function me(e){const{panels:t}=e,n=te({group:e});return n===0?t.map(o=>({groupResizeBehavior:o.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:o.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:o.panelConstraints.disabled,minSize:0,maxSize:100,panelId:o.id})):t.map(o=>{const{element:i,panelConstraints:s}=o;let u=0;if(s.collapsedSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.collapsedSize});u=O(c/n*100)}let a;if(s.defaultSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=O(c/n*100)}let r=0;if(s.minSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.minSize});r=O(c/n*100)}let l=100;if(s.maxSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.maxSize});l=O(c/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:u,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:r,maxSize:l,panelId:o.id}})}function C(e,t="Assertion error"){if(!e)throw Error(t)}function ge(e,t){return Array.from(t).sort(e==="horizontal"?yt:St)}function yt(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function St(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function Ve(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Ue(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function vt({orientation:e,rects:t,targetRect:n}){const o={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const u of t){const{x:a,y:r}=Ue(o,u),l=e==="horizontal"?a:r;l<s&&(s=l,i=u)}return C(i,"No rect found"),i}let ue;function Be(){return ue===void 0&&(typeof matchMedia=="function"?ue=!!matchMedia("(pointer:coarse)").matches:ue=!1),ue}function We(e){const{element:t,orientation:n,panels:o,separators:i}=e,s=ge(n,Array.from(t.children).filter(Ve).map(x=>({element:x}))).map(({element:x})=>x),u=[];let a=!1,r=!1,l=-1,c=-1,m=0,p,S=[];{let x=-1;for(const f of s)f.hasAttribute("data-panel")&&(x++,f.hasAttribute("data-disabled")||(m++,l===-1&&(l=x),c=x))}if(m>1){let x=-1;for(const f of s)if(f.hasAttribute("data-panel")){x++;const d=o.find(h=>h.element===f);if(d){if(p){const h=p.element.getBoundingClientRect(),y=f.getBoundingClientRect();let b;if(r){const v=n==="horizontal"?new DOMRect(h.right,h.top,0,h.height):new DOMRect(h.left,h.bottom,h.width,0),g=n==="horizontal"?new DOMRect(y.left,y.top,0,y.height):new DOMRect(y.left,y.top,y.width,0);switch(S.length){case 0:{b=[v,g];break}case 1:{const L=S[0],M=vt({orientation:n,rects:[h,y],targetRect:L.element.getBoundingClientRect()});b=[L,M===h?g:v];break}default:{b=S;break}}}else S.length?b=S:b=[n==="horizontal"?new DOMRect(h.right,y.top,y.left-h.right,y.height):new DOMRect(y.left,h.bottom,y.width,y.top-h.bottom)];for(const v of b){let g="width"in v?v:v.element.getBoundingClientRect();const L=Be()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(g.width<L){const R=L-g.width;g=new DOMRect(g.x-R/2,g.y,g.width+R,g.height)}if(g.height<L){const R=L-g.height;g=new DOMRect(g.x,g.y-R/2,g.width,g.height+R)}const M=x<=l||x>c;!a&&!M&&u.push({group:e,groupSize:te({group:e}),panels:[p,d],separator:"width"in v?void 0:v,rect:g}),a=!1}}r=!1,p=d,S=[]}}else if(f.hasAttribute("data-separator")){f.ariaDisabled!==null&&(a=!0);const d=i.find(h=>h.element===f);d?S.push(d):(p=void 0,S=[])}else r=!0}return u}class Ke{#e={};addListener(t,n){const o=this.#e[t];return o===void 0?this.#e[t]=[n]:o.includes(n)||o.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const o=this.#e[t];if(o!==void 0)if(o.length===1)o[0].call(null,n);else{let i=!1,s=null;const u=Array.from(o);for(let a=0;a<u.length;a++){const r=u[a];try{r.call(null,n)}catch(l){s===null&&(i=!0,s=l)}}if(i)throw s}}removeAllListeners(){this.#e={}}removeListener(t,n){const o=this.#e[t];if(o!==void 0){const i=o.indexOf(n);i>=0&&o.splice(i,1)}}}let Q={cursorFlags:0,state:"inactive"};const ye=new Ke;function B(){return Q}function bt(e){return ye.addListener("change",e)}function xt(e){const t=Q,n={...Q};n.cursorFlags=e,Q=n,ye.emit("change",{prev:t,next:n})}function ee(e){const t=Q;Q=e,ye.emit("change",{prev:t,next:e})}const zt=e=>e,he=()=>{},qe=1,Xe=2,Ye=4,Je=8,Re=3,Ce=12;let ce;function Ee(){return ce===void 0&&(ce=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(ce=!0)),ce}function Pt({cursorFlags:e,groups:t,state:n}){let o=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{o++;break}case"vertical":{i++;break}}})}if(!(o===0&&i===0)){switch(n){case"active":{if(e&&Ee()){const s=(e&qe)!==0,u=(e&Xe)!==0,a=(e&Ye)!==0,r=(e&Je)!==0;if(s)return a?"se-resize":r?"ne-resize":"e-resize";if(u)return a?"sw-resize":r?"nw-resize":"w-resize";if(a)return"s-resize";if(r)return"n-resize"}break}}return Ee()?o>0&&i>0?"move":o>0?"ew-resize":"ns-resize":o>0&&i>0?"grab":o>0?"col-resize":"row-resize"}}const Me=new WeakMap;function Se(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Me.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const o=B();switch(o.state){case"active":case"hover":{const i=Pt({cursorFlags:o.cursorFlags,groups:o.hitRegions.map(u=>u.group),state:o.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Me.set(e,{prevStyle:t,styleSheet:n})}let F=new Map;const Ze=new Ke;function wt(e){F=new Map(F),F.delete(e)}function ke(e,t){for(const[n]of F)if(n.id===e)return n}function H(e,t){for(const[n,o]of F)if(n.id===e)return o;if(t)throw Error(`Could not find data for Group with id ${e}`)}function q(){return F}function ve(e,t){return Ze.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function $(e,t,n){const o=F.get(e);F=new Map(F),F.set(e,t),Ze.emit("groupChange",{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:o,next:t})}function Qe(e){const t=B();let n=!1;switch(t.state){case"active":ee({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Se(e),n=!0,t.hitRegions.forEach(o=>{const i=H(o.group.id,!0);$(o.group,i,{isUserInteraction:!0})}))}return n}function Ie(e){e.defaultPrevented||Qe(e.currentTarget)}function Lt(e,t,n){let o,i={x:1/0,y:1/0};for(const s of t){const u=Ue(n,s.rect);switch(e){case"horizontal":{u.x<=i.x&&(o=s,i=u);break}case"vertical":{u.y<=i.y&&(o=s,i=u);break}}}return o?{distance:i,hitRegion:o}:void 0}function Rt(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Ct(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Oe(e),b:Oe(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)o=n.a.pop(),n.b.pop();C(o,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Te(De(n.a)),b:Te(De(n.b))};if(i.a===i.b){const s=o.childNodes,u={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const r=s[a];if(r===u.a)return 1;if(r===u.b)return-1}}return Math.sign(i.a-i.b)}const Et=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Mt(e){const t=getComputedStyle(et(e)??e).display;return t==="flex"||t==="inline-flex"}function kt(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Mt(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Et.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function De(e){let t=e.length;for(;t--;){const n=e[t];if(C(n,"Missing node"),kt(n))return n}return null}function Te(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Oe(e){const t=[];for(;e;)t.push(e),e=et(e);return t}function et(e){const{parentNode:t}=e;return Rt(t)?t.host:t}function It(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Dt({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Ve(n)||n.contains(e)||e.contains(n))return!0;if(Ct(n,e)>0){let o=n;for(;o;){if(o.contains(e))return!0;if(It(o.getBoundingClientRect(),t))return!1;o=o.parentElement}}return!0}function be(e,t){const n=[];return t.forEach((o,i)=>{if(i.disabled)return;const s=We(i),u=Lt(i.orientation,s,{x:e.clientX,y:e.clientY});u&&u.distance.x<=0&&u.distance.y<=0&&Dt({groupElement:i.element,hitRegion:u.hitRegion.rect,pointerEventTarget:e.target})&&n.push(u.hitRegion)}),n}function Tt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function D(e,t,n=0){return Math.abs(O(e)-O(t))<=n}function A(e,t){return D(e,t)?0:e>t?1:-1}function Z({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:o}){const{collapsedSize:i=0,collapsible:s,disabled:u,maxSize:a=100,minSize:r=0}=t;if(u&&!e)return n;if(A(o,r)<0)if(s){const l=(i+r)/2;A(o,l)<0?o=i:o=r}else o=r;return o=Math.min(a,o),o=O(o),o}function se({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:i,trigger:s}){if(D(e,0))return t;const u=s==="imperative-api",a=Object.values(t),r=Object.values(i),l=[...a],[c,m]=o;C(c!=null,"Invalid first pivot index"),C(m!=null,"Invalid second pivot index");let p=0;switch(s){case"keyboard":{{const f=e<0?m:c,d=n[f];C(d,`Panel constraints not found for index ${f}`);const{collapsedSize:h=0,collapsible:y,minSize:b=0}=d;if(y){const v=a[f];if(C(v!=null,`Previous layout not found for panel index ${f}`),D(v,h)){const g=b-v;A(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}{const f=e<0?c:m,d=n[f];C(d,`No panel constraints found for index ${f}`);const{collapsedSize:h=0,collapsible:y,minSize:b=0}=d;if(y){const v=a[f];if(C(v!=null,`Previous layout not found for panel index ${f}`),D(v,b)){const g=v-h;A(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}break}default:{const f=e<0?m:c,d=n[f];C(d,`Panel constraints not found for index ${f}`);const h=a[f],{collapsible:y,collapsedSize:b,minSize:v}=d;if(y&&A(h,v)<0)if(e>0){const g=v-b,L=g/2,M=h+e;A(M,v)<0&&(e=A(e,L)<=0?0:g)}else{const g=v-b,L=100-g/2,M=h-e;A(M,v)<0&&(e=A(100+e,L)>0?0:-g)}break}}{const f=e<0?1:-1;let d=e<0?m:c,h=0;for(;;){const b=a[d];C(b!=null,`Previous layout not found for panel index ${d}`);const g=Z({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:b,size:100})-b;if(h+=g,d+=f,d<0||d>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-y:y}{let d=e<0?c:m;for(;d>=0&&d<n.length;){const h=Math.abs(e)-Math.abs(p),y=a[d];C(y!=null,`Previous layout not found for panel index ${d}`);const b=y-h,v=Z({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:y,size:b});if(!D(y,v)&&(p+=y-v,l[d]=v,p.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?d--:d++}}if(Tt(r,l))return i;{const f=e<0?m:c,d=a[f];C(d!=null,`Previous layout not found for panel index ${f}`);const h=d+p,y=Z({overrideDisabledPanels:u,panelConstraints:n[f],prevSize:d,size:h});if(l[f]=y,!D(y,h)){let b=h-y,g=e<0?m:c;for(;g>=0&&g<n.length;){const L=l[g];C(L!=null,`Previous layout not found for panel index ${g}`);const M=L+b,R=Z({overrideDisabledPanels:u,panelConstraints:n[g],prevSize:L,size:M});if(D(L,R)||(b-=R-L,l[g]=R),D(b,0))break;e>0?g--:g++}}}const S=Object.values(l).reduce((f,d)=>d+f,0);if(!D(S,100,.1))return i;const x=Object.keys(i);return l.reduce((f,d,h)=>(f[x[h]]=d,f),{})}function W(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||A(e[n],t[n])!==0)return!1;return!0}function K({layout:e,panelConstraints:t}){const n=Object.values(e),o=[...n],i=o.reduce((a,r)=>a+r,0);if(o.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${o.map(a=>`${a}%`).join(", ")}`);if(!D(i,100)&&o.length>0)for(let a=0;a<t.length;a++){const r=o[a];C(r!=null,`No layout data found for index ${a}`);const l=100/i*r;o[a]=l}let s=0;for(let a=0;a<t.length;a++){const r=n[a];C(r!=null,`No layout data found for index ${a}`);const l=o[a];C(l!=null,`No layout data found for index ${a}`);const c=Z({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:r,size:l});l!=c&&(s+=l-c,o[a]=c)}if(!D(s,0))for(let a=0;a<t.length;a++){const r=o[a];C(r!=null,`No layout data found for index ${a}`);const l=r+s,c=Z({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:r,size:l});if(r!==c&&(s-=c-r,o[a]=c,D(s,0)))break}const u=Object.keys(e);return o.reduce((a,r,l)=>(a[u[l]]=r,a),{})}function tt({groupId:e,panelId:t}){const n=()=>{const r=q();for(const[l,{defaultLayoutDeferred:c,derivedPanelConstraints:m,layout:p,groupSize:S,separatorToPanels:x}]of r)if(l.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:m,group:l,groupSize:S,layout:p,separatorToPanels:x};throw Error(`Group ${e} not found`)},o=()=>{const r=n().derivedPanelConstraints.find(l=>l.panelId===t);if(r!==void 0)return r;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const r=n().group.panels.find(l=>l.id===t);if(r!==void 0)return r;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const r=n().layout[t];if(r!==void 0)return r;throw Error(`Layout not found for Panel ${t}`)},u=({nextSize:r,panels:l,prevLayout:c,derivedPanelConstraints:m})=>{const p=s(),S=l.findIndex(h=>h.id===t),x=S===0,f=S===l.length-1;if(f&&r<p&&(x||l.slice(0,S).every((h,y)=>{const b=m[y];return b?.collapsible&&D(b.collapsedSize,c[b.panelId])}))){const h=l.slice(0,S).reduce((y,b)=>y+c[b.id],0);return{...c,[t]:O(100-h)}}return se({delta:f?p-r:r-p,initialLayout:c,panelConstraints:m,pivotIndices:f?[S-1,S]:[S,S+1],prevLayout:c,trigger:"imperative-api"})},a=r=>{const l=s();if(r===l)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:m,group:p,groupSize:S,layout:x,separatorToPanels:f}=n(),d=u({nextSize:r,panels:p.panels,prevLayout:x,derivedPanelConstraints:m}),h=K({layout:d,panelConstraints:m});W(x,h)||$(p,{defaultLayoutDeferred:c,derivedPanelConstraints:m,groupSize:S,layout:h,separatorToPanels:f})};return{collapse:()=>{const{collapsible:r,collapsedSize:l}=o(),{mutableValues:c}=i(),m=s();r&&m!==l&&(c.expandToSize=m,a(l))},expand:()=>{const{collapsible:r,collapsedSize:l,minSize:c}=o(),{mutableValues:m}=i(),p=s();if(r&&p===l){let S=m.expandToSize??c;S===0&&(S=1),a(S)}},getSize:()=>{const{group:r}=n(),l=s(),{element:c}=i(),m=r.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:l,inPixels:m}},isCollapsed:()=>{const{collapsible:r,collapsedSize:l}=o(),c=s();return r&&D(l,c)},resize:r=>{const{group:l}=n(),{element:c}=i(),m=te({group:l}),p=oe({groupSize:m,panelElement:c,styleProp:r}),S=O(p/m*100);a(S)}}}function Ge(e){if(e.defaultPrevented)return;const t=q();be(e,t).forEach(o=>{if(o.separator&&!o.separator.disableDoubleClick){const i=o.panels.find(s=>s.panelConstraints.defaultSize!==void 0);if(i){const s=i.panelConstraints.defaultSize,u=tt({groupId:o.group.id,panelId:i.id});u&&s!==void 0&&(u.resize(s),e.preventDefault())}}})}function fe(e){const t=q();for(const[n]of t)if(n.separators.some(o=>o.element===e))return n;throw Error("Could not find parent Group for separator element")}function nt({groupId:e}){const t=()=>{const n=q();for(const[o,i]of n)if(o.id===e)return{group:o,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:o}=t();return n?{}:o},setLayout(n){const{defaultLayoutDeferred:o,derivedPanelConstraints:i,group:s,groupSize:u,layout:a,separatorToPanels:r}=t(),l=K({layout:n,panelConstraints:i});return o?a:(W(a,l)||$(s,{defaultLayoutDeferred:o,derivedPanelConstraints:i,groupSize:u,layout:l,separatorToPanels:r}),l)}}}function U(e,t){const n=fe(e),o=H(n.id,!0),i=n.separators.find(m=>m.element===e);C(i,"Matching separator not found");const s=o.separatorToPanels.get(i);C(s,"Matching panels not found");const u=s.map(m=>n.panels.indexOf(m)),r=nt({groupId:n.id}).getLayout(),l=se({delta:t,initialLayout:r,panelConstraints:o.derivedPanelConstraints,pivotIndices:u,prevLayout:r,trigger:"keyboard"}),c=K({layout:l,panelConstraints:o.derivedPanelConstraints});W(r,c)||$(n,{defaultLayoutDeferred:o.defaultLayoutDeferred,derivedPanelConstraints:o.derivedPanelConstraints,groupSize:o.groupSize,layout:c,separatorToPanels:o.separatorToPanels},{isUserInteraction:!0})}function Ae(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=fe(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&U(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&U(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&U(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&U(t,-5);break}case"End":{e.preventDefault(),U(t,100);break}case"Enter":{e.preventDefault();const o=fe(t),i=H(o.id,!0),{derivedPanelConstraints:s,layout:u,separatorToPanels:a}=i,r=o.separators.find(p=>p.element===t);C(r,"Matching separator not found");const l=a.get(r);C(l,"Matching panels not found");const c=l[0],m=s.find(p=>p.panelId===c.id);if(C(m,"Panel metadata not found"),m.collapsible){const p=u[c.id],S=m.collapsedSize===p?o.mutableState.expandedPanelSizes[c.id]??m.minSize:m.collapsedSize;U(t,S-p)}break}case"F6":{e.preventDefault();const i=fe(t).separators.map(r=>r.element),s=Array.from(i).findIndex(r=>r===e.currentTarget);C(s!==null,"Index not found");const u=e.shiftKey?s>0?s-1:i.length-1:s+1<i.length?s+1:0;i[u].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),U(t,-100);break}}}function Fe(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;const t=q(),n=be(e,t),o=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const u=t.get(s.group);u&&o.set(s.group,u.layout)}),ee({cursorFlags:0,hitRegions:n,initialLayoutMap:o,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function ot({document:e,event:t,hitRegions:n,initialLayoutMap:o,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:u}){let a=0;n.forEach(l=>{const{group:c,groupSize:m}=l,{orientation:p,panels:S}=c,{disableCursor:x}=c.mutableState;let f=0;s?p==="horizontal"?f=(t.clientX-s.x)/m*100:f=(t.clientY-s.y)/m*100:p==="horizontal"?f=t.clientX<0?-100:100:f=t.clientY<0?-100:100;const d=o.get(c),h=i.get(c);if(!d||!h)return;const{defaultLayoutDeferred:y,derivedPanelConstraints:b,groupSize:v,layout:g,separatorToPanels:L}=h;if(b&&g&&L){const M=se({delta:f,initialLayout:d,panelConstraints:b,pivotIndices:l.panels.map(R=>S.indexOf(R)),prevLayout:g,trigger:"mouse-or-touch"});if(W(M,g)){if(f!==0&&!x)switch(p){case"horizontal":{a|=f<0?qe:Xe;break}case"vertical":{a|=f<0?Ye:Je;break}}}else $(l.group,{defaultLayoutDeferred:y,derivedPanelConstraints:b,groupSize:v,layout:M,separatorToPanels:L})}});let r=0;t.movementX===0?r|=u&Re:r|=a&Re,t.movementY===0?r|=u&Ce:r|=a&Ce,xt(r),Se(e)}function Ne(e){const t=q(),n=B();switch(n.state){case"active":ot({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function _e(e){if(e.defaultPrevented)return;const t=B(),n=q();switch(t.state){case"active":{if(e.buttons===0){ee({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(o=>{const i=H(o.group.id,!0);$(o.group,i,{isUserInteraction:!0})});return}for(const o of t.hitRegions)if(o.separator){const{element:i}=o.separator;i.hasPointerCapture?.(e.pointerId)||i.setPointerCapture?.(e.pointerId)}ot({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const o=be(e,n);o.length===0?t.state!=="inactive"&&ee({cursorFlags:0,state:"inactive"}):ee({cursorFlags:0,hitRegions:o,state:"hover"}),Se(e.currentTarget);break}}}function je(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(B().state){case"hover":ee({cursorFlags:0,state:"inactive"})}}function $e(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;Qe(e.currentTarget)&&e.preventDefault()}function He(e){let t=0,n=0;const o={};for(const s of e)if(s.defaultSize!==void 0){t++;const u=O(s.defaultSize);n+=u,o[s.panelId]=u}else o[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=O((100-n)/i);for(const u of e)u.defaultSize===void 0&&(o[u.panelId]=s)}return o}function Ot(e,t,n){if(!n[0])return;const i=e.panels.find(l=>l.element===t);if(!i||!i.onResize)return;const s=te({group:e}),u=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,r={asPercentage:O(u/s*100),inPixels:u};i.mutableValues.prevSize=r,i.onResize(r,i.id,a)}function Gt(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const o in e)if(e[o]!==t[o])return!1;return!0}function At({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:o}){if(n<=0||t<=0||n===t)return o;let i=0,s=0,u=!1;const a=new Map,r=[];for(const m of e.panels){const p=o[m.id]??0;switch(m.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{u=!0;const S=p/100*n,x=O(S/t*100);a.set(m.id,x),i+=x;break}case"preserve-relative-size":default:{r.push(m.id),s+=p;break}}}if(!u||r.length===0)return o;const l=100-i,c={...o};if(a.forEach((m,p)=>{c[p]=m}),s>0)for(const m of r){const p=o[m]??0;c[m]=O(p/s*l)}else{const m=O(l/r.length);for(const p of r)c[p]=m}return c}function Ft(e,t){const n=e.map(i=>i.id),o=Object.keys(t);if(n.length!==o.length)return!1;for(const i of n)if(!o.includes(i))return!1;return!0}const J=new Map;function Nt(e){let t=!0;C(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,o=new Set,i=new Set,s=new n(f=>{for(const d of f){const{borderBoxSize:h,target:y}=d;if(y===e.element){if(t){const b=te({group:e});if(b===0)return;const v=H(e.id);if(!v)return;const g=me(e),L=v.defaultLayoutDeferred?He(g):v.layout,M=At({group:e,nextGroupSize:b,prevGroupSize:v.groupSize,prevLayout:L}),R=K({layout:M,panelConstraints:g});if(!v.defaultLayoutDeferred&&W(v.layout,R)&&Gt(v.derivedPanelConstraints,g)&&v.groupSize===b)return;$(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:g,groupSize:b,layout:R,separatorToPanels:v.separatorToPanels})}}else Ot(e,y,h)}});s.observe(e.element),e.panels.forEach(f=>{C(!o.has(f.id),`Panel ids must be unique; id "${f.id}" was used more than once`),o.add(f.id),f.onResize&&s.observe(f.element)});const u=te({group:e}),a=me(e),r=e.panels.map(({id:f})=>f).join(",");let l=e.mutableState.defaultLayout;l&&(Ft(e.panels,l)||(l=void 0));const c=e.mutableState.layouts[r]??l??He(a),m=K({layout:c,panelConstraints:a}),p=e.element.ownerDocument;J.set(p,(J.get(p)??0)+1);const S=new Map;return We(e).forEach(f=>{f.separator&&S.set(f.separator,f.panels)}),$(e,{defaultLayoutDeferred:u===0,derivedPanelConstraints:a,groupSize:u,layout:m,separatorToPanels:S}),e.separators.forEach(f=>{C(!i.has(f.id),`Separator ids must be unique; id "${f.id}" was used more than once`),i.add(f.id),f.element.addEventListener("keydown",Ae)}),J.get(p)===1&&(p.addEventListener("contextmenu",Ie,!0),p.addEventListener("dblclick",Ge,!0),p.addEventListener("pointerdown",Fe,!0),p.addEventListener("pointerleave",Ne),p.addEventListener("pointermove",_e),p.addEventListener("pointerout",je),p.addEventListener("pointerup",$e,!0)),function(){t=!1,J.set(p,Math.max(0,(J.get(p)??0)-1)),wt(e),e.separators.forEach(d=>{d.element.removeEventListener("keydown",Ae)}),J.get(p)||(p.removeEventListener("contextmenu",Ie,!0),p.removeEventListener("dblclick",Ge,!0),p.removeEventListener("pointerdown",Fe,!0),p.removeEventListener("pointerleave",Ne),p.removeEventListener("pointermove",_e),p.removeEventListener("pointerout",je),p.removeEventListener("pointerup",$e,!0)),s.disconnect()}}function _t(){const[e,t]=z.useState({}),n=z.useCallback(()=>t({}),[]);return[e,n]}function xe(e){const t=z.useId();return`${e??t}`}const X=typeof window<"u"?z.useLayoutEffect:z.useEffect;function ie(e){const t=z.useRef(e);return X(()=>{t.current=e},[e]),z.useCallback((...n)=>t.current?.(...n),[t])}function ze(...e){return ie(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Pe(e){const t=z.useRef({...e});return X(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const it=z.createContext(null);function jt(e,t){const n=z.useRef({getLayout:()=>({}),setLayout:zt});z.useImperativeHandle(t,()=>n.current,[]),X(()=>{Object.assign(n.current,nt({groupId:e}))})}function rt({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:i,elementRef:s,groupRef:u,id:a,onLayoutChange:r,onLayoutChanged:l,orientation:c="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:p,...S}){const x=z.useRef({onLayoutChange:{},onLayoutChanged:{}}),f=ie(P=>{W(x.current.onLayoutChange,P)||(x.current.onLayoutChange=P,r?.(P))}),d=ie((P,w)=>{W(x.current.onLayoutChanged,P)||(x.current.onLayoutChanged=P,l?.(P,{isUserInteraction:w}))}),h=xe(a),y=z.useRef(null),[b,v]=_t(),g=z.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),L=ze(y,s);jt(h,u);const M=ie((P,w)=>{const I=B(),E=ke(P),k=H(P);if(k){let T=!1;switch(I.state){case"active":{T=I.hitRegions.some(V=>V.group===E);break}}return{flexGrow:k.layout[w]??1,pointerEvents:T?"none":void 0}}if(n?.[w])return{flexGrow:n?.[w]}}),R=Pe({defaultLayout:n,disableCursor:o}),G=z.useMemo(()=>({get disableCursor(){return!!R.disableCursor},getPanelStyles:M,id:h,orientation:c,registerPanel:P=>{const w=g.current;return w.panels=ge(c,[...w.panels,P]),v(),()=>{w.panels=w.panels.filter(I=>I!==P),v()}},registerSeparator:P=>{const w=g.current;return w.separators=ge(c,[...w.separators,P]),v(),()=>{w.separators=w.separators.filter(I=>I!==P),v()}},updatePanelProps:(P,{disabled:w})=>{const E=g.current.panels.find(V=>V.id===P);E&&(E.panelConstraints.disabled=w);const k=ke(h),T=H(h);k&&T&&$(k,{...T,derivedPanelConstraints:me(k)})},updateSeparatorProps:(P,{disabled:w,disableDoubleClick:I})=>{const k=g.current.separators.find(T=>T.id===P);k&&(k.disabled=w,k.disableDoubleClick=I)}}),[M,h,v,c,R]),N=z.useRef(null);return X(()=>{const P=y.current;if(P===null)return;const w=g.current;let I;if(R.defaultLayout!==void 0&&Object.keys(R.defaultLayout).length===w.panels.length){I={};for(const _ of w.panels){const Y=R.defaultLayout[_.id];Y!==void 0&&(I[_.id]=Y)}}const E={disabled:!!i,element:P,id:h,mutableState:{defaultLayout:I,disableCursor:!!R.disableCursor,expandedPanelSizes:g.current.lastExpandedPanelSizes,layouts:g.current.layouts},orientation:c,panels:w.panels,resizeTargetMinimumSize:w.resizeTargetMinimumSize,separators:w.separators};N.current=E;const k=Nt(E),{defaultLayoutDeferred:T,derivedPanelConstraints:V,layout:ae}=H(E.id,!0);!T&&V.length>0&&(f(ae),d(ae,!1));const ne=ve(h,_=>{const{defaultLayoutDeferred:Y,derivedPanelConstraints:Le,layout:le}=_.next;if(Y||Le.length===0)return;const lt=E.panels.map(({id:j})=>j).join(",");E.mutableState.layouts[lt]=le,Le.forEach(j=>{if(j.collapsible){const{layout:pe}=_.prev??{};if(pe){const ct=D(j.collapsedSize,le[j.panelId]),ft=D(j.collapsedSize,pe[j.panelId]);ct&&!ft&&(E.mutableState.expandedPanelSizes[j.panelId]=pe[j.panelId])}}});const ut=B().state!=="active";f(le),ut&&d(le,_.isUserInteraction)});return()=>{N.current=null,k(),ne()}},[i,h,d,f,c,b,R]),z.useEffect(()=>{const P=N.current;P&&(P.mutableState.defaultLayout=n,P.mutableState.disableCursor=!!o)}),re.jsx(it.Provider,{value:G,children:re.jsx("div",{...S,className:t,"data-group":!0,"data-testid":h,id:h,ref:L,style:{height:"100%",width:"100%",overflow:"hidden",...p,display:"flex",flexDirection:c==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:c==="horizontal"?"pan-y":"pan-x"},children:e})})}rt.displayName="Group";function de(e,t){return`react-resizable-panels:${[e,...t].join(":")}`}function $t({id:e,panelIds:t,storage:n}){const o=de(e,[]),i=n.getItem(o);if(i)try{const s=JSON.parse(i);if(t){const u=t.join(","),a=s[u];if(a&&Array.isArray(a.layout)&&t.length===a.layout.length){const r={};for(let l=0;l<t.length;l++)r[t[l]]=a.layout[l];return r}}else{const u=Object.keys(s);if(u.length===1){const a=s[u[0]];if(a&&Array.isArray(a.layout)){const r=u[0].split(",");if(r.length===a.layout.length){const l={};for(let c=0;c<r.length;c++)l[r[c]]=a.layout[c];return l}}}}}catch{}}function Ht({debounceSaveMs:e=100,onlySaveAfterUserInteractions:t,panelIds:n,storage:o=localStorage,...i}){const s=n!==void 0,u="id"in i?i.id:i.groupId,a=de(u,n??[]),r=z.useSyncExternalStore(Vt,()=>o.getItem(a),()=>o.getItem(a)),l=z.useMemo(()=>{if(r){const d=JSON.parse(r),h=Object.values(d);if(Array.from(h).every(y=>typeof y=="number"))return d}},[r]),c=z.useMemo(()=>{if(!l)return $t({id:u,panelIds:n,storage:o})},[l,u,n,o]),m=l??c,p=z.useRef(null),S=z.useCallback(()=>{const d=p.current;d&&(p.current=null,clearTimeout(d))},[]);z.useLayoutEffect(()=>()=>{S()},[S]);const x=z.useCallback((d,h)=>{if(t&&!h.isUserInteraction)return;S();let y;s?y=de(u,Object.keys(d)):y=de(u,[]);try{o.setItem(y,JSON.stringify(d))}catch(b){console.error(b)}},[S,s,u,t,o]),f=z.useCallback(d=>{S(),e===0?x(d,{isUserInteraction:!1}):p.current=setTimeout(()=>{x(d,{isUserInteraction:!1})},e)},[S,e,x]);return{defaultLayout:m,onLayoutChange:f,onLayoutChanged:x}}function Vt(){return function(){}}function Ut(){return z.useState(null)}function Bt(){return z.useRef(null)}function we(){const e=z.useContext(it);return C(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Wt(e,t){const{id:n}=we(),o=z.useRef({collapse:he,expand:he,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:he});z.useImperativeHandle(t,()=>o.current,[]),X(()=>{Object.assign(o.current,tt({groupId:n,panelId:e}))})}function st({children:e,className:t,collapsedSize:n="0%",collapsible:o=!1,defaultSize:i,disabled:s,elementRef:u,groupResizeBehavior:a="preserve-relative-size",id:r,maxSize:l="100%",minSize:c="0%",onResize:m,panelRef:p,style:S,...x}){const f=!!r,d=xe(r),h=Pe({disabled:s}),y=z.useRef(null),b=ze(y,u),{getPanelStyles:v,id:g,orientation:L,registerPanel:M,updatePanelProps:R}=we(),G=m!==null,N=ie((E,k,T)=>{m?.(E,r,T)});X(()=>{const E=y.current;if(E!==null){const k={element:E,id:d,idIsStable:f,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?N:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:o,defaultSize:i,disabled:h.disabled,maxSize:l,minSize:c}};return M(k)}},[a,n,o,i,G,d,f,l,c,N,M,h]),z.useEffect(()=>{R(d,{disabled:s})},[s,d,R]),Wt(d,p);const P=()=>{const E=v(g,d);if(E)return JSON.stringify(E)},w=z.useSyncExternalStore(E=>ve(g,E),P,P);let I;return w?I=JSON.parse(w):i!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:I={flexGrow:1},re.jsx("div",{...x,"data-disabled":s||void 0,"data-panel":!0,"data-testid":d,id:d,ref:b,style:{...Kt,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:re.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...S,touchAction:L==="horizontal"?"pan-y":"pan-x"},children:e})})}st.displayName="Panel";const Kt={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function qt(){return z.useState(null)}function Xt(){return z.useRef(null)}function Yt({layout:e,panelConstraints:t,panelId:n,panelIndex:o}){let i,s;const u=e[n],a=t.find(r=>r.panelId===n);if(a){const r=a.maxSize,l=a.collapsible?a.collapsedSize:a.minSize,c=[o,o+1];s=K({layout:se({delta:l-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n],i=K({layout:se({delta:r-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:u}}function at({children:e,className:t,disabled:n,disableDoubleClick:o,elementRef:i,id:s,style:u,...a}){const r=xe(s),l=Pe({disabled:n,disableDoubleClick:o}),[c,m]=z.useState({}),[p,S]=z.useState("inactive"),[x,f]=z.useState(!1),d=z.useRef(null),h=ze(d,i),{disableCursor:y,id:b,orientation:v,registerSeparator:g,updateSeparatorProps:L}=we(),M=v==="horizontal"?"vertical":"horizontal";X(()=>{const N=d.current;if(N!==null){const P={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:N,id:r},w=g(P),I=bt(k=>{S(k.next.state!=="inactive"&&k.next.hitRegions.some(T=>T.separator===P)?k.next.state:"inactive")}),E=ve(b,k=>{const{derivedPanelConstraints:T,layout:V,separatorToPanels:ae}=k.next,ne=ae.get(P);if(ne){const _=ne[0],Y=ne.indexOf(_);m(Yt({layout:V,panelConstraints:T,panelId:_.id,panelIndex:Y}))}});return()=>{I(),E(),w()}}},[b,r,g,l]),z.useEffect(()=>{L(r,{disabled:n,disableDoubleClick:o})},[n,o,r,L]);let R;n&&!y&&(R="not-allowed");let G;if(n)G="disabled";else switch(p){case"active":{G="active";break}default:x?G="focus":G=p}return re.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":n||void 0,"aria-orientation":M,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":G,"data-testid":r,id:r,onBlur:()=>f(!1),onFocus:()=>f(!0),ref:h,role:"separator",style:{flexBasis:"auto",cursor:R,...u,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}at.displayName="Separator";exports.Group=rt;exports.Panel=st;exports.Separator=at;exports.isCoarsePointer=Be;exports.useDefaultLayout=Ht;exports.useGroupCallbackRef=Ut;exports.useGroupRef=Bt;exports.usePanelCallbackRef=qt;exports.usePanelRef=Xt;-+"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("react/jsx-runtime"),z=require("react");function dt(e,t){const n=getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function pt(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),o=parseFloat(n.fontSize);return t*o}function ht(e){return e/100*window.innerHeight}function mt(e){return e/100*window.innerWidth}function gt(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function oe({groupSize:e,panelElement:t,styleProp:n}){let o;const[i,s]=gt(n);switch(s){case"%":{o=i/100*e;break}case"px":{o=i;break}case"rem":{o=pt(t,i);break}case"em":{o=dt(t,i);break}case"vh":{o=ht(i);break}case"vw":{o=mt(i);break}}return o}function O(e){return parseFloat(e.toFixed(3))}function te({group:e}){const{orientation:t,panels:n}=e;return n.reduce((o,i)=>(o+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,o),0)}function me(e){const{panels:t}=e,n=te({group:e});return n===0?t.map(o=>({groupResizeBehavior:o.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:o.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:o.panelConstraints.disabled,minSize:0,maxSize:100,panelId:o.id})):t.map(o=>{const{element:i,panelConstraints:s}=o;let u=0;if(s.collapsedSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.collapsedSize});u=O(c/n*100)}let a;if(s.defaultSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=O(c/n*100)}let r=0;if(s.minSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.minSize});r=O(c/n*100)}let l=100;if(s.maxSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.maxSize});l=O(c/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:u,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:r,maxSize:l,panelId:o.id}})}function C(e,t="Assertion error"){if(!e)throw Error(t)}function ge(e,t){return Array.from(t).sort(e==="horizontal"?yt:St)}function yt(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function St(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function Ve(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Ue(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function vt({orientation:e,rects:t,targetRect:n}){const o={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const u of t){const{x:a,y:r}=Ue(o,u),l=e==="horizontal"?a:r;l<s&&(s=l,i=u)}return C(i,"No rect found"),i}let ue;function Be(){return ue===void 0&&(typeof matchMedia=="function"?ue=!!matchMedia("(pointer:coarse)").matches:ue=!1),ue}function We(e){const{element:t,orientation:n,panels:o,separators:i}=e,s=ge(n,Array.from(t.children).filter(Ve).map(x=>({element:x}))).map(({element:x})=>x),u=[];let a=!1,r=!1,l=-1,c=-1,m=0,p,S=[];{let x=-1;for(const f of s)f.hasAttribute("data-panel")&&(x++,f.hasAttribute("data-disabled")||(m++,l===-1&&(l=x),c=x))}if(m>1){let x=-1;for(const f of s)if(f.hasAttribute("data-panel")){x++;const d=o.find(h=>h.element===f);if(d){if(p){const h=p.element.getBoundingClientRect(),y=f.getBoundingClientRect();let b;if(r){const v=n==="horizontal"?new DOMRect(h.right,h.top,0,h.height):new DOMRect(h.left,h.bottom,h.width,0),g=n==="horizontal"?new DOMRect(y.left,y.top,0,y.height):new DOMRect(y.left,y.top,y.width,0);switch(S.length){case 0:{b=[v,g];break}case 1:{const L=S[0],M=vt({orientation:n,rects:[h,y],targetRect:L.element.getBoundingClientRect()});b=[L,M===h?g:v];break}default:{b=S;break}}}else S.length?b=S:b=[n==="horizontal"?new DOMRect(h.right,y.top,y.left-h.right,y.height):new DOMRect(y.left,h.bottom,y.width,y.top-h.bottom)];for(const v of b){let g="width"in v?v:v.element.getBoundingClientRect();const L=Be()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(g.width<L){const R=L-g.width;g=new DOMRect(g.x-R/2,g.y,g.width+R,g.height)}if(g.height<L){const R=L-g.height;g=new DOMRect(g.x,g.y-R/2,g.width,g.height+R)}const M=x<=l||x>c;!a&&!M&&u.push({group:e,groupSize:te({group:e}),panels:[p,d],separator:"width"in v?void 0:v,rect:g}),a=!1}}r=!1,p=d,S=[]}}else if(f.hasAttribute("data-separator")){f.ariaDisabled!==null&&(a=!0);const d=i.find(h=>h.element===f);d?S.push(d):(p=void 0,S=[])}else r=!0}return u}class Ke{#e={};addListener(t,n){const o=this.#e[t];return o===void 0?this.#e[t]=[n]:o.includes(n)||o.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const o=this.#e[t];if(o!==void 0)if(o.length===1)o[0].call(null,n);else{let i=!1,s=null;const u=Array.from(o);for(let a=0;a<u.length;a++){const r=u[a];try{r.call(null,n)}catch(l){s===null&&(i=!0,s=l)}}if(i)throw s}}removeAllListeners(){this.#e={}}removeListener(t,n){const o=this.#e[t];if(o!==void 0){const i=o.indexOf(n);i>=0&&o.splice(i,1)}}}let Q={cursorFlags:0,state:"inactive"};const ye=new Ke;function B(){return Q}function bt(e){return ye.addListener("change",e)}function xt(e){const t=Q,n={...Q};n.cursorFlags=e,Q=n,ye.emit("change",{prev:t,next:n})}function ee(e){const t=Q;Q=e,ye.emit("change",{prev:t,next:e})}const zt=e=>e,he=()=>{},qe=1,Xe=2,Ye=4,Je=8,Re=3,Ce=12;let ce;function Ee(){return ce===void 0&&(ce=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(ce=!0)),ce}function Pt({cursorFlags:e,groups:t,state:n}){let o=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{o++;break}case"vertical":{i++;break}}})}if(!(o===0&&i===0)){switch(n){case"active":{if(e&&Ee()){const s=(e&qe)!==0,u=(e&Xe)!==0,a=(e&Ye)!==0,r=(e&Je)!==0;if(s)return a?"se-resize":r?"ne-resize":"e-resize";if(u)return a?"sw-resize":r?"nw-resize":"w-resize";if(a)return"s-resize";if(r)return"n-resize"}break}}return Ee()?o>0&&i>0?"move":o>0?"ew-resize":"ns-resize":o>0&&i>0?"grab":o>0?"col-resize":"row-resize"}}const Me=new WeakMap;function Se(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Me.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const o=B();switch(o.state){case"active":case"hover":{const i=Pt({cursorFlags:o.cursorFlags,groups:o.hitRegions.map(u=>u.group),state:o.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Me.set(e,{prevStyle:t,styleSheet:n})}let F=new Map;const Ze=new Ke;function wt(e){F=new Map(F),F.delete(e)}function ke(e,t){for(const[n]of F)if(n.id===e)return n}function H(e,t){for(const[n,o]of F)if(n.id===e)return o;if(t)throw Error(`Could not find data for Group with id ${e}`)}function q(){return F}function ve(e,t){return Ze.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function $(e,t,n){const o=F.get(e);F=new Map(F),F.set(e,t),Ze.emit("groupChange",{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:o,next:t})}function Qe(e){const t=B();let n=!1;switch(t.state){case"active":ee({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Se(e),n=!0,t.hitRegions.forEach(o=>{const i=H(o.group.id,!0);$(o.group,i,{isUserInteraction:!0})}))}return n}function Ie(e){e.defaultPrevented||Qe(e.currentTarget)}function Lt(e,t,n){let o,i={x:1/0,y:1/0};for(const s of t){const u=Ue(n,s.rect);switch(e){case"horizontal":{u.x<=i.x&&(o=s,i=u);break}case"vertical":{u.y<=i.y&&(o=s,i=u);break}}}return o?{distance:i,hitRegion:o}:void 0}function Rt(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Ct(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Oe(e),b:Oe(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)o=n.a.pop(),n.b.pop();C(o,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Te(De(n.a)),b:Te(De(n.b))};if(i.a===i.b){const s=o.childNodes,u={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const r=s[a];if(r===u.a)return 1;if(r===u.b)return-1}}return Math.sign(i.a-i.b)}const Et=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Mt(e){const t=getComputedStyle(et(e)??e).display;return t==="flex"||t==="inline-flex"}function kt(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Mt(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Et.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function De(e){let t=e.length;for(;t--;){const n=e[t];if(C(n,"Missing node"),kt(n))return n}return null}function Te(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Oe(e){const t=[];for(;e;)t.push(e),e=et(e);return t}function et(e){const{parentNode:t}=e;return Rt(t)?t.host:t}function It(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Dt({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Ve(n)||n.contains(e)||e.contains(n))return!0;if(Ct(n,e)>0){let o=n;for(;o;){if(o.contains(e))return!0;if(It(o.getBoundingClientRect(),t))return!1;o=o.parentElement}}return!0}function be(e,t){const n=[];return t.forEach((o,i)=>{if(i.disabled)return;const s=We(i),u=Lt(i.orientation,s,{x:e.clientX,y:e.clientY});u&&u.distance.x<=0&&u.distance.y<=0&&Dt({groupElement:i.element,hitRegion:u.hitRegion.rect,pointerEventTarget:e.target})&&n.push(u.hitRegion)}),n}function Tt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function D(e,t,n=0){return Math.abs(O(e)-O(t))<=n}function A(e,t){return D(e,t)?0:e>t?1:-1}function Z({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:o}){const{collapsedSize:i=0,collapsible:s,disabled:u,maxSize:a=100,minSize:r=0}=t;if(u&&!e)return n;if(A(o,r)<0)if(s){const l=(i+r)/2;A(o,l)<0?o=i:o=r}else o=r;return o=Math.min(a,o),o=O(o),o}function se({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:i,trigger:s}){if(D(e,0))return t;const u=s==="imperative-api",a=Object.values(t),r=Object.values(i),l=[...a],[c,m]=o;C(c!=null,"Invalid first pivot index"),C(m!=null,"Invalid second pivot index");let p=0;switch(s){case"keyboard":{{const f=e<0?m:c,d=n[f];C(d,`Panel constraints not found for index ${f}`);const{collapsedSize:h=0,collapsible:y,minSize:b=0}=d;if(y){const v=a[f];if(C(v!=null,`Previous layout not found for panel index ${f}`),D(v,h)){const g=b-v;A(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}{const f=e<0?c:m,d=n[f];C(d,`No panel constraints found for index ${f}`);const{collapsedSize:h=0,collapsible:y,minSize:b=0}=d;if(y){const v=a[f];if(C(v!=null,`Previous layout not found for panel index ${f}`),D(v,b)){const g=v-h;A(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}break}default:{const f=e<0?m:c,d=n[f];C(d,`Panel constraints not found for index ${f}`);const h=a[f],{collapsible:y,collapsedSize:b,minSize:v}=d;if(y&&A(h,v)<0)if(e>0){const g=v-b,L=g/2,M=h+e;A(M,v)<0&&(e=A(e,L)<=0?0:g)}else{const g=v-b,L=100-g/2,M=h-e;A(M,v)<0&&(e=A(100+e,L)>0?0:-g)}break}}{const f=e<0?1:-1;let d=e<0?m:c,h=0;for(;;){const b=a[d];C(b!=null,`Previous layout not found for panel index ${d}`);const g=Z({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:b,size:100})-b;if(h+=g,d+=f,d<0||d>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-y:y}{let d=e<0?c:m;for(;d>=0&&d<n.length;){const h=Math.abs(e)-Math.abs(p),y=a[d];C(y!=null,`Previous layout not found for panel index ${d}`);const b=y-h,v=Z({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:y,size:b});if(!D(y,v)&&(p+=y-v,l[d]=v,p.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?d--:d++}}if(Tt(r,l))return i;{const f=e<0?m:c,d=a[f];C(d!=null,`Previous layout not found for panel index ${f}`);const h=d+p,y=Z({overrideDisabledPanels:u,panelConstraints:n[f],prevSize:d,size:h});if(l[f]=y,!D(y,h)){let b=h-y,g=e<0?m:c;for(;g>=0&&g<n.length;){const L=l[g];C(L!=null,`Previous layout not found for panel index ${g}`);const M=L+b,R=Z({overrideDisabledPanels:u,panelConstraints:n[g],prevSize:L,size:M});if(D(L,R)||(b-=R-L,l[g]=R),D(b,0))break;e>0?g--:g++}}}const S=Object.values(l).reduce((f,d)=>d+f,0);if(!D(S,100,.1))return i;const x=Object.keys(i);return l.reduce((f,d,h)=>(f[x[h]]=d,f),{})}function W(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||A(e[n],t[n])!==0)return!1;return!0}function K({layout:e,panelConstraints:t}){let n=Object.values(e),o=[...n];if(o.length!==t.length){e=He(t);n=Object.values(e);o=[...n]}const i=o.reduce((a,r)=>a+r,0);if(!D(i,100)&&o.length>0)for(let a=0;a<t.length;a++){const r=o[a];C(r!=null,`No layout data found for index ${a}`);const l=100/i*r;o[a]=l}let s=0;for(let a=0;a<t.length;a++){const r=n[a];C(r!=null,`No layout data found for index ${a}`);const l=o[a];C(l!=null,`No layout data found for index ${a}`);const c=Z({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:r,size:l});l!=c&&(s+=l-c,o[a]=c)}if(!D(s,0))for(let a=0;a<t.length;a++){const r=o[a];C(r!=null,`No layout data found for index ${a}`);const l=r+s,c=Z({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:r,size:l});if(r!==c&&(s-=c-r,o[a]=c,D(s,0)))break}const u=Object.keys(e);return o.reduce((a,r,l)=>(a[u[l]]=r,a),{})}function tt({groupId:e,panelId:t}){const n=()=>{const r=q();for(const[l,{defaultLayoutDeferred:c,derivedPanelConstraints:m,layout:p,groupSize:S,separatorToPanels:x}]of r)if(l.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:m,group:l,groupSize:S,layout:p,separatorToPanels:x};throw Error(`Group ${e} not found`)},o=()=>{const r=n().derivedPanelConstraints.find(l=>l.panelId===t);if(r!==void 0)return r;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const r=n().group.panels.find(l=>l.id===t);if(r!==void 0)return r;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const r=n().layout[t];if(r!==void 0)return r;throw Error(`Layout not found for Panel ${t}`)},u=({nextSize:r,panels:l,prevLayout:c,derivedPanelConstraints:m})=>{const p=s(),S=l.findIndex(h=>h.id===t),x=S===0,f=S===l.length-1;if(f&&r<p&&(x||l.slice(0,S).every((h,y)=>{const b=m[y];return b?.collapsible&&D(b.collapsedSize,c[b.panelId])}))){const h=l.slice(0,S).reduce((y,b)=>y+c[b.id],0);return{...c,[t]:O(100-h)}}return se({delta:f?p-r:r-p,initialLayout:c,panelConstraints:m,pivotIndices:f?[S-1,S]:[S,S+1],prevLayout:c,trigger:"imperative-api"})},a=r=>{const l=s();if(r===l)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:m,group:p,groupSize:S,layout:x,separatorToPanels:f}=n(),d=u({nextSize:r,panels:p.panels,prevLayout:x,derivedPanelConstraints:m}),h=K({layout:d,panelConstraints:m});W(x,h)||$(p,{defaultLayoutDeferred:c,derivedPanelConstraints:m,groupSize:S,layout:h,separatorToPanels:f})};return{collapse:()=>{const{collapsible:r,collapsedSize:l}=o(),{mutableValues:c}=i(),m=s();r&&m!==l&&(c.expandToSize=m,a(l))},expand:()=>{const{collapsible:r,collapsedSize:l,minSize:c}=o(),{mutableValues:m}=i(),p=s();if(r&&p===l){let S=m.expandToSize??c;S===0&&(S=1),a(S)}},getSize:()=>{const{group:r}=n(),l=s(),{element:c}=i(),m=r.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:l,inPixels:m}},isCollapsed:()=>{const{collapsible:r,collapsedSize:l}=o(),c=s();return r&&D(l,c)},resize:r=>{const{group:l}=n(),{element:c}=i(),m=te({group:l}),p=oe({groupSize:m,panelElement:c,styleProp:r}),S=O(p/m*100);a(S)}}}function Ge(e){if(e.defaultPrevented)return;const t=q();be(e,t).forEach(o=>{if(o.separator&&!o.separator.disableDoubleClick){const i=o.panels.find(s=>s.panelConstraints.defaultSize!==void 0);if(i){const s=i.panelConstraints.defaultSize,u=tt({groupId:o.group.id,panelId:i.id});u&&s!==void 0&&(u.resize(s),e.preventDefault())}}})}function fe(e){const t=q();for(const[n]of t)if(n.separators.some(o=>o.element===e))return n;throw Error("Could not find parent Group for separator element")}function nt({groupId:e}){const t=()=>{const n=q();for(const[o,i]of n)if(o.id===e)return{group:o,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:o}=t();return n?{}:o},setLayout(n){const{defaultLayoutDeferred:o,derivedPanelConstraints:i,group:s,groupSize:u,layout:a,separatorToPanels:r}=t(),l=K({layout:n,panelConstraints:i});return o?a:(W(a,l)||$(s,{defaultLayoutDeferred:o,derivedPanelConstraints:i,groupSize:u,layout:l,separatorToPanels:r}),l)}}}function U(e,t){const n=fe(e),o=H(n.id,!0),i=n.separators.find(m=>m.element===e);C(i,"Matching separator not found");const s=o.separatorToPanels.get(i);C(s,"Matching panels not found");const u=s.map(m=>n.panels.indexOf(m)),r=nt({groupId:n.id}).getLayout(),l=se({delta:t,initialLayout:r,panelConstraints:o.derivedPanelConstraints,pivotIndices:u,prevLayout:r,trigger:"keyboard"}),c=K({layout:l,panelConstraints:o.derivedPanelConstraints});W(r,c)||$(n,{defaultLayoutDeferred:o.defaultLayoutDeferred,derivedPanelConstraints:o.derivedPanelConstraints,groupSize:o.groupSize,layout:c,separatorToPanels:o.separatorToPanels},{isUserInteraction:!0})}function Ae(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=fe(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&U(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&U(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&U(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&U(t,-5);break}case"End":{e.preventDefault(),U(t,100);break}case"Enter":{e.preventDefault();const o=fe(t),i=H(o.id,!0),{derivedPanelConstraints:s,layout:u,separatorToPanels:a}=i,r=o.separators.find(p=>p.element===t);C(r,"Matching separator not found");const l=a.get(r);C(l,"Matching panels not found");const c=l[0],m=s.find(p=>p.panelId===c.id);if(C(m,"Panel metadata not found"),m.collapsible){const p=u[c.id],S=m.collapsedSize===p?o.mutableState.expandedPanelSizes[c.id]??m.minSize:m.collapsedSize;U(t,S-p)}break}case"F6":{e.preventDefault();const i=fe(t).separators.map(r=>r.element),s=Array.from(i).findIndex(r=>r===e.currentTarget);C(s!==null,"Index not found");const u=e.shiftKey?s>0?s-1:i.length-1:s+1<i.length?s+1:0;i[u].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),U(t,-100);break}}}function Fe(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;const t=q(),n=be(e,t),o=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const u=t.get(s.group);u&&o.set(s.group,u.layout)}),ee({cursorFlags:0,hitRegions:n,initialLayoutMap:o,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function ot({document:e,event:t,hitRegions:n,initialLayoutMap:o,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:u}){let a=0;n.forEach(l=>{const{group:c,groupSize:m}=l,{orientation:p,panels:S}=c,{disableCursor:x}=c.mutableState;let f=0;s?p==="horizontal"?f=(t.clientX-s.x)/m*100:f=(t.clientY-s.y)/m*100:p==="horizontal"?f=t.clientX<0?-100:100:f=t.clientY<0?-100:100;const d=o.get(c),h=i.get(c);if(!d||!h)return;const{defaultLayoutDeferred:y,derivedPanelConstraints:b,groupSize:v,layout:g,separatorToPanels:L}=h;if(b&&g&&L){const M=se({delta:f,initialLayout:d,panelConstraints:b,pivotIndices:l.panels.map(R=>S.indexOf(R)),prevLayout:g,trigger:"mouse-or-touch"});if(W(M,g)){if(f!==0&&!x)switch(p){case"horizontal":{a|=f<0?qe:Xe;break}case"vertical":{a|=f<0?Ye:Je;break}}}else $(l.group,{defaultLayoutDeferred:y,derivedPanelConstraints:b,groupSize:v,layout:M,separatorToPanels:L})}});let r=0;t.movementX===0?r|=u&Re:r|=a&Re,t.movementY===0?r|=u&Ce:r|=a&Ce,xt(r),Se(e)}function Ne(e){const t=q(),n=B();switch(n.state){case"active":ot({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function _e(e){if(e.defaultPrevented)return;const t=B(),n=q();switch(t.state){case"active":{if(e.buttons===0){ee({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(o=>{const i=H(o.group.id,!0);$(o.group,i,{isUserInteraction:!0})});return}for(const o of t.hitRegions)if(o.separator){const{element:i}=o.separator;i.hasPointerCapture?.(e.pointerId)||i.setPointerCapture?.(e.pointerId)}ot({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const o=be(e,n);o.length===0?t.state!=="inactive"&&ee({cursorFlags:0,state:"inactive"}):ee({cursorFlags:0,hitRegions:o,state:"hover"}),Se(e.currentTarget);break}}}function je(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(B().state){case"hover":ee({cursorFlags:0,state:"inactive"})}}function $e(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;Qe(e.currentTarget)&&e.preventDefault()}function He(e){let t=0,n=0;const o={};for(const s of e)if(s.defaultSize!==void 0){t++;const u=O(s.defaultSize);n+=u,o[s.panelId]=u}else o[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=O((100-n)/i);for(const u of e)u.defaultSize===void 0&&(o[u.panelId]=s)}return o}function Ot(e,t,n){if(!n[0])return;const i=e.panels.find(l=>l.element===t);if(!i||!i.onResize)return;const s=te({group:e}),u=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,r={asPercentage:O(u/s*100),inPixels:u};i.mutableValues.prevSize=r,i.onResize(r,i.id,a)}function Gt(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const o in e)if(e[o]!==t[o])return!1;return!0}function At({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:o}){if(n<=0||t<=0||n===t)return o;let i=0,s=0,u=!1;const a=new Map,r=[];for(const m of e.panels){const p=o[m.id]??0;switch(m.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{u=!0;const S=p/100*n,x=O(S/t*100);a.set(m.id,x),i+=x;break}case"preserve-relative-size":default:{r.push(m.id),s+=p;break}}}if(!u||r.length===0)return o;const l=100-i,c={...o};if(a.forEach((m,p)=>{c[p]=m}),s>0)for(const m of r){const p=o[m]??0;c[m]=O(p/s*l)}else{const m=O(l/r.length);for(const p of r)c[p]=m}return c}function Ft(e,t){const n=e.map(i=>i.id),o=Object.keys(t);if(n.length!==o.length)return!1;for(const i of n)if(!o.includes(i))return!1;return!0}const J=new Map;function Nt(e){let t=!0;C(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,o=new Set,i=new Set,s=new n(f=>{for(const d of f){const{borderBoxSize:h,target:y}=d;if(y===e.element){if(t){const b=te({group:e});if(b===0)return;const v=H(e.id);if(!v)return;const g=me(e),L=v.defaultLayoutDeferred?He(g):v.layout,M=At({group:e,nextGroupSize:b,prevGroupSize:v.groupSize,prevLayout:L}),R=K({layout:M,panelConstraints:g});if(!v.defaultLayoutDeferred&&W(v.layout,R)&&Gt(v.derivedPanelConstraints,g)&&v.groupSize===b)return;$(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:g,groupSize:b,layout:R,separatorToPanels:v.separatorToPanels})}}else Ot(e,y,h)}});s.observe(e.element),e.panels.forEach(f=>{C(!o.has(f.id),`Panel ids must be unique; id "${f.id}" was used more than once`),o.add(f.id),f.onResize&&s.observe(f.element)});const u=te({group:e}),a=me(e),r=e.panels.map(({id:f})=>f).join(",");let l=e.mutableState.defaultLayout;l&&(Ft(e.panels,l)||(l=void 0));const c=e.mutableState.layouts[r]??l??He(a),m=K({layout:c,panelConstraints:a}),p=e.element.ownerDocument;J.set(p,(J.get(p)??0)+1);const S=new Map;return We(e).forEach(f=>{f.separator&&S.set(f.separator,f.panels)}),$(e,{defaultLayoutDeferred:u===0,derivedPanelConstraints:a,groupSize:u,layout:m,separatorToPanels:S}),e.separators.forEach(f=>{C(!i.has(f.id),`Separator ids must be unique; id "${f.id}" was used more than once`),i.add(f.id),f.element.addEventListener("keydown",Ae)}),J.get(p)===1&&(p.addEventListener("contextmenu",Ie,!0),p.addEventListener("dblclick",Ge,!0),p.addEventListener("pointerdown",Fe,!0),p.addEventListener("pointerleave",Ne),p.addEventListener("pointermove",_e),p.addEventListener("pointerout",je),p.addEventListener("pointerup",$e,!0)),function(){t=!1,J.set(p,Math.max(0,(J.get(p)??0)-1)),wt(e),e.separators.forEach(d=>{d.element.removeEventListener("keydown",Ae)}),J.get(p)||(p.removeEventListener("contextmenu",Ie,!0),p.removeEventListener("dblclick",Ge,!0),p.removeEventListener("pointerdown",Fe,!0),p.removeEventListener("pointerleave",Ne),p.removeEventListener("pointermove",_e),p.removeEventListener("pointerout",je),p.removeEventListener("pointerup",$e,!0)),s.disconnect()}}function _t(){const[e,t]=z.useState({}),n=z.useCallback(()=>t({}),[]);return[e,n]}function xe(e){const t=z.useId();return`${e??t}`}const X=typeof window<"u"?z.useLayoutEffect:z.useEffect;function ie(e){const t=z.useRef(e);return X(()=>{t.current=e},[e]),z.useCallback((...n)=>t.current?.(...n),[t])}function ze(...e){return ie(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Pe(e){const t=z.useRef({...e});return X(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const it=z.createContext(null);function jt(e,t){const n=z.useRef({getLayout:()=>({}),setLayout:zt});z.useImperativeHandle(t,()=>n.current,[]),X(()=>{Object.assign(n.current,nt({groupId:e}))})}function rt({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:i,elementRef:s,groupRef:u,id:a,onLayoutChange:r,onLayoutChanged:l,orientation:c="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:p,...S}){const x=z.useRef({onLayoutChange:{},onLayoutChanged:{}}),f=ie(P=>{W(x.current.onLayoutChange,P)||(x.current.onLayoutChange=P,r?.(P))}),d=ie((P,w)=>{W(x.current.onLayoutChanged,P)||(x.current.onLayoutChanged=P,l?.(P,{isUserInteraction:w}))}),h=xe(a),y=z.useRef(null),[b,v]=_t(),g=z.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),L=ze(y,s);jt(h,u);const M=ie((P,w)=>{const I=B(),E=ke(P),k=H(P);if(k){let T=!1;switch(I.state){case"active":{T=I.hitRegions.some(V=>V.group===E);break}}return{flexGrow:k.layout[w]??1,pointerEvents:T?"none":void 0}}if(n?.[w])return{flexGrow:n?.[w]}}),R=Pe({defaultLayout:n,disableCursor:o}),G=z.useMemo(()=>({get disableCursor(){return!!R.disableCursor},getPanelStyles:M,id:h,orientation:c,registerPanel:P=>{const w=g.current;return w.panels=ge(c,[...w.panels,P]),v(),()=>{w.panels=w.panels.filter(I=>I!==P),v()}},registerSeparator:P=>{const w=g.current;return w.separators=ge(c,[...w.separators,P]),v(),()=>{w.separators=w.separators.filter(I=>I!==P),v()}},updatePanelProps:(P,{disabled:w})=>{const E=g.current.panels.find(V=>V.id===P);E&&(E.panelConstraints.disabled=w);const k=ke(h),T=H(h);k&&T&&$(k,{...T,derivedPanelConstraints:me(k)})},updateSeparatorProps:(P,{disabled:w,disableDoubleClick:I})=>{const k=g.current.separators.find(T=>T.id===P);k&&(k.disabled=w,k.disableDoubleClick=I)}}),[M,h,v,c,R]),N=z.useRef(null);return X(()=>{const P=y.current;if(P===null)return;const w=g.current;let I;if(R.defaultLayout!==void 0&&Object.keys(R.defaultLayout).length===w.panels.length){I={};for(const _ of w.panels){const Y=R.defaultLayout[_.id];Y!==void 0&&(I[_.id]=Y)}}const E={disabled:!!i,element:P,id:h,mutableState:{defaultLayout:I,disableCursor:!!R.disableCursor,expandedPanelSizes:g.current.lastExpandedPanelSizes,layouts:g.current.layouts},orientation:c,panels:w.panels,resizeTargetMinimumSize:w.resizeTargetMinimumSize,separators:w.separators};N.current=E;const k=Nt(E),{defaultLayoutDeferred:T,derivedPanelConstraints:V,layout:ae}=H(E.id,!0);!T&&V.length>0&&(f(ae),d(ae,!1));const ne=ve(h,_=>{const{defaultLayoutDeferred:Y,derivedPanelConstraints:Le,layout:le}=_.next;if(Y||Le.length===0)return;const lt=E.panels.map(({id:j})=>j).join(",");E.mutableState.layouts[lt]=le,Le.forEach(j=>{if(j.collapsible){const{layout:pe}=_.prev??{};if(pe){const ct=D(j.collapsedSize,le[j.panelId]),ft=D(j.collapsedSize,pe[j.panelId]);ct&&!ft&&(E.mutableState.expandedPanelSizes[j.panelId]=pe[j.panelId])}}});const ut=B().state!=="active";f(le),ut&&d(le,_.isUserInteraction)});return()=>{N.current=null,k(),ne()}},[i,h,d,f,c,b,R]),z.useEffect(()=>{const P=N.current;P&&(P.mutableState.defaultLayout=n,P.mutableState.disableCursor=!!o)}),re.jsx(it.Provider,{value:G,children:re.jsx("div",{...S,className:t,"data-group":!0,"data-testid":h,id:h,ref:L,style:{height:"100%",width:"100%",overflow:"hidden",...p,display:"flex",flexDirection:c==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:c==="horizontal"?"pan-y":"pan-x"},children:e})})}rt.displayName="Group";function de(e,t){return`react-resizable-panels:${[e,...t].join(":")}`}function $t({id:e,panelIds:t,storage:n}){const o=de(e,[]),i=n.getItem(o);if(i)try{const s=JSON.parse(i);if(t){const u=t.join(","),a=s[u];if(a&&Array.isArray(a.layout)&&t.length===a.layout.length){const r={};for(let l=0;l<t.length;l++)r[t[l]]=a.layout[l];return r}}else{const u=Object.keys(s);if(u.length===1){const a=s[u[0]];if(a&&Array.isArray(a.layout)){const r=u[0].split(",");if(r.length===a.layout.length){const l={};for(let c=0;c<r.length;c++)l[r[c]]=a.layout[c];return l}}}}}catch{}}function Ht({debounceSaveMs:e=100,onlySaveAfterUserInteractions:t,panelIds:n,storage:o=localStorage,...i}){const s=n!==void 0,u="id"in i?i.id:i.groupId,a=de(u,n??[]),r=z.useSyncExternalStore(Vt,()=>o.getItem(a),()=>o.getItem(a)),l=z.useMemo(()=>{if(r){const d=JSON.parse(r),h=Object.values(d);if(Array.from(h).every(y=>typeof y=="number"))return d}},[r]),c=z.useMemo(()=>{if(!l)return $t({id:u,panelIds:n,storage:o})},[l,u,n,o]),m=l??c,p=z.useRef(null),S=z.useCallback(()=>{const d=p.current;d&&(p.current=null,clearTimeout(d))},[]);z.useLayoutEffect(()=>()=>{S()},[S]);const x=z.useCallback((d,h)=>{if(t&&!h.isUserInteraction)return;S();let y;s?y=de(u,Object.keys(d)):y=de(u,[]);try{o.setItem(y,JSON.stringify(d))}catch(b){console.error(b)}},[S,s,u,t,o]),f=z.useCallback(d=>{S(),e===0?x(d,{isUserInteraction:!1}):p.current=setTimeout(()=>{x(d,{isUserInteraction:!1})},e)},[S,e,x]);return{defaultLayout:m,onLayoutChange:f,onLayoutChanged:x}}function Vt(){return function(){}}function Ut(){return z.useState(null)}function Bt(){return z.useRef(null)}function we(){const e=z.useContext(it);return C(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Wt(e,t){const{id:n}=we(),o=z.useRef({collapse:he,expand:he,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:he});z.useImperativeHandle(t,()=>o.current,[]),X(()=>{Object.assign(o.current,tt({groupId:n,panelId:e}))})}function st({children:e,className:t,collapsedSize:n="0%",collapsible:o=!1,defaultSize:i,disabled:s,elementRef:u,groupResizeBehavior:a="preserve-relative-size",id:r,maxSize:l="100%",minSize:c="0%",onResize:m,panelRef:p,style:S,...x}){const f=!!r,d=xe(r),h=Pe({disabled:s}),y=z.useRef(null),b=ze(y,u),{getPanelStyles:v,id:g,orientation:L,registerPanel:M,updatePanelProps:R}=we(),G=m!==null,N=ie((E,k,T)=>{m?.(E,r,T)});X(()=>{const E=y.current;if(E!==null){const k={element:E,id:d,idIsStable:f,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?N:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:o,defaultSize:i,disabled:h.disabled,maxSize:l,minSize:c}};return M(k)}},[a,n,o,i,G,d,f,l,c,N,M,h]),z.useEffect(()=>{R(d,{disabled:s})},[s,d,R]),Wt(d,p);const P=()=>{const E=v(g,d);if(E)return JSON.stringify(E)},w=z.useSyncExternalStore(E=>ve(g,E),P,P);let I;return w?I=JSON.parse(w):i!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:I={flexGrow:1},re.jsx("div",{...x,"data-disabled":s||void 0,"data-panel":!0,"data-testid":d,id:d,ref:b,style:{...Kt,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:re.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...S,touchAction:L==="horizontal"?"pan-y":"pan-x"},children:e})})}st.displayName="Panel";const Kt={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function qt(){return z.useState(null)}function Xt(){return z.useRef(null)}function Yt({layout:e,panelConstraints:t,panelId:n,panelIndex:o}){let i,s;const u=e[n],a=t.find(r=>r.panelId===n);if(a){const r=a.maxSize,l=a.collapsible?a.collapsedSize:a.minSize,c=[o,o+1];s=K({layout:se({delta:l-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n],i=K({layout:se({delta:r-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:u}}function at({children:e,className:t,disabled:n,disableDoubleClick:o,elementRef:i,id:s,style:u,...a}){const r=xe(s),l=Pe({disabled:n,disableDoubleClick:o}),[c,m]=z.useState({}),[p,S]=z.useState("inactive"),[x,f]=z.useState(!1),d=z.useRef(null),h=ze(d,i),{disableCursor:y,id:b,orientation:v,registerSeparator:g,updateSeparatorProps:L}=we(),M=v==="horizontal"?"vertical":"horizontal";X(()=>{const N=d.current;if(N!==null){const P={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:N,id:r},w=g(P),I=bt(k=>{S(k.next.state!=="inactive"&&k.next.hitRegions.some(T=>T.separator===P)?k.next.state:"inactive")}),E=ve(b,k=>{const{derivedPanelConstraints:T,layout:V,separatorToPanels:ae}=k.next,ne=ae.get(P);if(ne){const _=ne[0],Y=ne.indexOf(_);m(Yt({layout:V,panelConstraints:T,panelId:_.id,panelIndex:Y}))}});return()=>{I(),E(),w()}}},[b,r,g,l]),z.useEffect(()=>{L(r,{disabled:n,disableDoubleClick:o})},[n,o,r,L]);let R;n&&!y&&(R="not-allowed");let G;if(n)G="disabled";else switch(p){case"active":{G="active";break}default:x?G="focus":G=p}return re.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":n||void 0,"aria-orientation":M,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":G,"data-testid":r,id:r,onBlur:()=>f(!1),onFocus:()=>f(!0),ref:h,role:"separator",style:{flexBasis:"auto",cursor:R,...u,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}at.displayName="Separator";exports.Group=rt;exports.Panel=st;exports.Separator=at;exports.isCoarsePointer=Be;exports.useDefaultLayout=Ht;exports.useGroupCallbackRef=Ut;exports.useGroupRef=Bt;exports.usePanelCallbackRef=qt;exports.usePanelRef=Xt;++"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("react/jsx-runtime"),z=require("react");function dt(e,t){const n=getComputedStyle(e),o=parseFloat(n.fontSize);return t*o}function pt(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),o=parseFloat(n.fontSize);return t*o}function ht(e){return e/100*window.innerHeight}function mt(e){return e/100*window.innerWidth}function gt(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function oe({groupSize:e,panelElement:t,styleProp:n}){let o;const[i,s]=gt(n);switch(s){case"%":{o=i/100*e;break}case"px":{o=i;break}case"rem":{o=pt(t,i);break}case"em":{o=dt(t,i);break}case"vh":{o=ht(i);break}case"vw":{o=mt(i);break}}return o}function O(e){return parseFloat(e.toFixed(3))}function te({group:e}){const{orientation:t,panels:n}=e;return n.reduce((o,i)=>(o+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,o),0)}function me(e){const{panels:t}=e,n=te({group:e});return n===0?t.map(o=>({groupResizeBehavior:o.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:o.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:o.panelConstraints.disabled,minSize:0,maxSize:100,panelId:o.id})):t.map(o=>{const{element:i,panelConstraints:s}=o;let u=0;if(s.collapsedSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.collapsedSize});u=O(c/n*100)}let a;if(s.defaultSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=O(c/n*100)}let r=0;if(s.minSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.minSize});r=O(c/n*100)}let l=100;if(s.maxSize!==void 0){const c=oe({groupSize:n,panelElement:i,styleProp:s.maxSize});l=O(c/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:u,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:r,maxSize:l,panelId:o.id}})}function C(e,t="Assertion error"){if(!e)throw Error(t)}function ge(e,t){return Array.from(t).sort(e==="horizontal"?yt:St)}function yt(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function St(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function Ve(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Ue(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function vt({orientation:e,rects:t,targetRect:n}){const o={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const u of t){const{x:a,y:r}=Ue(o,u),l=e==="horizontal"?a:r;l<s&&(s=l,i=u)}return C(i,"No rect found"),i}let ue;function Be(){return ue===void 0&&(typeof matchMedia=="function"?ue=!!matchMedia("(pointer:coarse)").matches:ue=!1),ue}function We(e){const{element:t,orientation:n,panels:o,separators:i}=e,s=ge(n,Array.from(t.children).filter(Ve).map(x=>({element:x}))).map(({element:x})=>x),u=[];let a=!1,r=!1,l=-1,c=-1,m=0,p,S=[];{let x=-1;for(const f of s)f.hasAttribute("data-panel")&&(x++,f.hasAttribute("data-disabled")||(m++,l===-1&&(l=x),c=x))}if(m>1){let x=-1;for(const f of s)if(f.hasAttribute("data-panel")){x++;const d=o.find(h=>h.element===f);if(d){if(p){const h=p.element.getBoundingClientRect(),y=f.getBoundingClientRect();let b;if(r){const v=n==="horizontal"?new DOMRect(h.right,h.top,0,h.height):new DOMRect(h.left,h.bottom,h.width,0),g=n==="horizontal"?new DOMRect(y.left,y.top,0,y.height):new DOMRect(y.left,y.top,y.width,0);switch(S.length){case 0:{b=[v,g];break}case 1:{const L=S[0],M=vt({orientation:n,rects:[h,y],targetRect:L.element.getBoundingClientRect()});b=[L,M===h?g:v];break}default:{b=S;break}}}else S.length?b=S:b=[n==="horizontal"?new DOMRect(h.right,y.top,y.left-h.right,y.height):new DOMRect(y.left,h.bottom,y.width,y.top-h.bottom)];for(const v of b){let g="width"in v?v:v.element.getBoundingClientRect();const L=Be()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(g.width<L){const R=L-g.width;g=new DOMRect(g.x-R/2,g.y,g.width+R,g.height)}if(g.height<L){const R=L-g.height;g=new DOMRect(g.x,g.y-R/2,g.width,g.height+R)}const M=x<=l||x>c;!a&&!M&&u.push({group:e,groupSize:te({group:e}),panels:[p,d],separator:"width"in v?void 0:v,rect:g}),a=!1}}r=!1,p=d,S=[]}}else if(f.hasAttribute("data-separator")){f.ariaDisabled!==null&&(a=!0);const d=i.find(h=>h.element===f);d?S.push(d):(p=void 0,S=[])}else r=!0}return u}class Ke{#e={};addListener(t,n){const o=this.#e[t];return o===void 0?this.#e[t]=[n]:o.includes(n)||o.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const o=this.#e[t];if(o!==void 0)if(o.length===1)o[0].call(null,n);else{let i=!1,s=null;const u=Array.from(o);for(let a=0;a<u.length;a++){const r=u[a];try{r.call(null,n)}catch(l){s===null&&(i=!0,s=l)}}if(i)throw s}}removeAllListeners(){this.#e={}}removeListener(t,n){const o=this.#e[t];if(o!==void 0){const i=o.indexOf(n);i>=0&&o.splice(i,1)}}}let Q={cursorFlags:0,state:"inactive"};const ye=new Ke;function B(){return Q}function bt(e){return ye.addListener("change",e)}function xt(e){const t=Q,n={...Q};n.cursorFlags=e,Q=n,ye.emit("change",{prev:t,next:n})}function ee(e){const t=Q;Q=e,ye.emit("change",{prev:t,next:e})}const zt=e=>e,he=()=>{},qe=1,Xe=2,Ye=4,Je=8,Re=3,Ce=12;let ce;function Ee(){return ce===void 0&&(ce=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(ce=!0)),ce}function Pt({cursorFlags:e,groups:t,state:n}){let o=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{o++;break}case"vertical":{i++;break}}})}if(!(o===0&&i===0)){switch(n){case"active":{if(e&&Ee()){const s=(e&qe)!==0,u=(e&Xe)!==0,a=(e&Ye)!==0,r=(e&Je)!==0;if(s)return a?"se-resize":r?"ne-resize":"e-resize";if(u)return a?"sw-resize":r?"nw-resize":"w-resize";if(a)return"s-resize";if(r)return"n-resize"}break}}return Ee()?o>0&&i>0?"move":o>0?"ew-resize":"ns-resize":o>0&&i>0?"grab":o>0?"col-resize":"row-resize"}}const Me=new WeakMap;function Se(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=Me.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const o=B();switch(o.state){case"active":case"hover":{const i=Pt({cursorFlags:o.cursorFlags,groups:o.hitRegions.map(u=>u.group),state:o.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}Me.set(e,{prevStyle:t,styleSheet:n})}let F=new Map;const Ze=new Ke;function wt(e){F=new Map(F),F.delete(e)}function ke(e,t){for(const[n]of F)if(n.id===e)return n}function H(e,t){for(const[n,o]of F)if(n.id===e)return o;if(t)throw Error(`Could not find data for Group with id ${e}`)}function q(){return F}function ve(e,t){return Ze.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function $(e,t,n){const o=F.get(e);F=new Map(F),F.set(e,t),Ze.emit("groupChange",{group:e,isUserInteraction:n?.isUserInteraction===!0,prev:o,next:t})}function Qe(e){const t=B();let n=!1;switch(t.state){case"active":ee({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Se(e),n=!0,t.hitRegions.forEach(o=>{const i=H(o.group.id,!0);$(o.group,i,{isUserInteraction:!0})}))}return n}function Ie(e){e.defaultPrevented||Qe(e.currentTarget)}function Lt(e,t,n){let o,i={x:1/0,y:1/0};for(const s of t){const u=Ue(n,s.rect);switch(e){case"horizontal":{u.x<=i.x&&(o=s,i=u);break}case"vertical":{u.y<=i.y&&(o=s,i=u);break}}}return o?{distance:i,hitRegion:o}:void 0}function Rt(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Ct(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:Oe(e),b:Oe(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)o=n.a.pop(),n.b.pop();C(o,"Stacking order can only be calculated for elements with a common ancestor");const i={a:Te(De(n.a)),b:Te(De(n.b))};if(i.a===i.b){const s=o.childNodes,u={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const r=s[a];if(r===u.a)return 1;if(r===u.b)return-1}}return Math.sign(i.a-i.b)}const Et=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Mt(e){const t=getComputedStyle(et(e)??e).display;return t==="flex"||t==="inline-flex"}function kt(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Mt(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Et.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function De(e){let t=e.length;for(;t--;){const n=e[t];if(C(n,"Missing node"),kt(n))return n}return null}function Te(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Oe(e){const t=[];for(;e;)t.push(e),e=et(e);return t}function et(e){const{parentNode:t}=e;return Rt(t)?t.host:t}function It(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Dt({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!Ve(n)||n.contains(e)||e.contains(n))return!0;if(Ct(n,e)>0){let o=n;for(;o;){if(o.contains(e))return!0;if(It(o.getBoundingClientRect(),t))return!1;o=o.parentElement}}return!0}function be(e,t){const n=[];return t.forEach((o,i)=>{if(i.disabled)return;const s=We(i),u=Lt(i.orientation,s,{x:e.clientX,y:e.clientY});u&&u.distance.x<=0&&u.distance.y<=0&&Dt({groupElement:i.element,hitRegion:u.hitRegion.rect,pointerEventTarget:e.target})&&n.push(u.hitRegion)}),n}function Tt(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function D(e,t,n=0){return Math.abs(O(e)-O(t))<=n}function A(e,t){return D(e,t)?0:e>t?1:-1}function Z({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:o}){const{collapsedSize:i=0,collapsible:s,disabled:u,maxSize:a=100,minSize:r=0}=t;if(u&&!e)return n;if(A(o,r)<0)if(s){const l=(i+r)/2;A(o,l)<0?o=i:o=r}else o=r;return o=Math.min(a,o),o=O(o),o}function se({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:i,trigger:s}){if(D(e,0))return t;const u=s==="imperative-api",a=Object.values(t),r=Object.values(i),l=[...a],[c,m]=o;C(c!=null,"Invalid first pivot index"),C(m!=null,"Invalid second pivot index");let p=0;switch(s){case"keyboard":{{const f=e<0?m:c,d=n[f];C(d,`Panel constraints not found for index ${f}`);const{collapsedSize:h=0,collapsible:y,minSize:b=0}=d;if(y){const v=a[f];if(C(v!=null,`Previous layout not found for panel index ${f}`),D(v,h)){const g=b-v;A(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}{const f=e<0?c:m,d=n[f];C(d,`No panel constraints found for index ${f}`);const{collapsedSize:h=0,collapsible:y,minSize:b=0}=d;if(y){const v=a[f];if(C(v!=null,`Previous layout not found for panel index ${f}`),D(v,b)){const g=v-h;A(g,Math.abs(e))>0&&(e=e<0?0-g:g)}}}break}default:{const f=e<0?m:c,d=n[f];C(d,`Panel constraints not found for index ${f}`);const h=a[f],{collapsible:y,collapsedSize:b,minSize:v}=d;if(y&&A(h,v)<0)if(e>0){const g=v-b,L=g/2,M=h+e;A(M,v)<0&&(e=A(e,L)<=0?0:g)}else{const g=v-b,L=100-g/2,M=h-e;A(M,v)<0&&(e=A(100+e,L)>0?0:-g)}break}}{const f=e<0?1:-1;let d=e<0?m:c,h=0;for(;;){const b=a[d];C(b!=null,`Previous layout not found for panel index ${d}`);const g=Z({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:b,size:100})-b;if(h+=g,d+=f,d<0||d>=n.length)break}const y=Math.min(Math.abs(e),Math.abs(h));e=e<0?0-y:y}{let d=e<0?c:m;for(;d>=0&&d<n.length;){const h=Math.abs(e)-Math.abs(p),y=a[d];C(y!=null,`Previous layout not found for panel index ${d}`);const b=y-h,v=Z({overrideDisabledPanels:u,panelConstraints:n[d],prevSize:y,size:b});if(!D(y,v)&&(p+=y-v,l[d]=v,p.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?d--:d++}}if(Tt(r,l))return i;{const f=e<0?m:c,d=a[f];C(d!=null,`Previous layout not found for panel index ${f}`);const h=d+p,y=Z({overrideDisabledPanels:u,panelConstraints:n[f],prevSize:d,size:h});if(l[f]=y,!D(y,h)){let b=h-y,g=e<0?m:c;for(;g>=0&&g<n.length;){const L=l[g];C(L!=null,`Previous layout not found for panel index ${g}`);const M=L+b,R=Z({overrideDisabledPanels:u,panelConstraints:n[g],prevSize:L,size:M});if(D(L,R)||(b-=R-L,l[g]=R),D(b,0))break;e>0?g--:g++}}}const S=Object.values(l).reduce((f,d)=>d+f,0);if(!D(S,100,.1))return i;const x=Object.keys(i);return l.reduce((f,d,h)=>(f[x[h]]=d,f),{})}function W(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||A(e[n],t[n])!==0)return!1;return!0}function K({layout:e,panelConstraints:t}){let n=Object.values(e),o=[...n];if(o.length!==t.length){e=He(t);n=Object.values(e);o=[...n]}const i=o.reduce((a,r)=>a+r,0);if(!D(i,100)&&o.length>0)for(let a=0;a<t.length;a++){const r=o[a];C(r!=null,`No layout data found for index ${a}`);const l=100/i*r;o[a]=l}let s=0;for(let a=0;a<t.length;a++){const r=n[a];C(r!=null,`No layout data found for index ${a}`);const l=o[a];C(l!=null,`No layout data found for index ${a}`);const c=Z({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:r,size:l});l!=c&&(s+=l-c,o[a]=c)}if(!D(s,0))for(let a=0;a<t.length;a++){const r=o[a];C(r!=null,`No layout data found for index ${a}`);const l=r+s,c=Z({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:r,size:l});if(r!==c&&(s-=c-r,o[a]=c,D(s,0)))break}const u=Object.keys(e);return o.reduce((a,r,l)=>(a[u[l]]=r,a),{})}function tt({groupId:e,panelId:t}){const n=()=>{const r=q();for(const[l,{defaultLayoutDeferred:c,derivedPanelConstraints:m,layout:p,groupSize:S,separatorToPanels:x}]of r)if(l.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:m,group:l,groupSize:S,layout:p,separatorToPanels:x};throw Error(`Group ${e} not found`)},o=()=>{const r=n().derivedPanelConstraints.find(l=>l.panelId===t);if(r!==void 0)return r;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const r=n().group.panels.find(l=>l.id===t);if(r!==void 0)return r;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const r=n().layout[t];if(r!==void 0)return r;throw Error(`Layout not found for Panel ${t}`)},u=({nextSize:r,panels:l,prevLayout:c,derivedPanelConstraints:m})=>{const p=s(),S=l.findIndex(h=>h.id===t),x=S===0,f=S===l.length-1;if(f&&r<p&&(x||l.slice(0,S).every((h,y)=>{const b=m[y];return b?.collapsible&&D(b.collapsedSize,c[b.panelId])}))){const h=l.slice(0,S).reduce((y,b)=>y+c[b.id],0);return{...c,[t]:O(100-h)}}return se({delta:f?p-r:r-p,initialLayout:c,panelConstraints:m,pivotIndices:f?[S-1,S]:[S,S+1],prevLayout:c,trigger:"imperative-api"})},a=r=>{const l=s();if(r===l)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:m,group:p,groupSize:S,layout:x,separatorToPanels:f}=n(),d=u({nextSize:r,panels:p.panels,prevLayout:x,derivedPanelConstraints:m}),h=K({layout:d,panelConstraints:m});W(x,h)||$(p,{defaultLayoutDeferred:c,derivedPanelConstraints:m,groupSize:S,layout:h,separatorToPanels:f})};return{collapse:()=>{const{collapsible:r,collapsedSize:l}=o(),{mutableValues:c}=i(),m=s();r&&m!==l&&(c.expandToSize=m,a(l))},expand:()=>{const{collapsible:r,collapsedSize:l,minSize:c}=o(),{mutableValues:m}=i(),p=s();if(r&&p===l){let S=m.expandToSize??c;S===0&&(S=1),a(S)}},getSize:()=>{const{group:r}=n(),l=s(),{element:c}=i(),m=r.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:l,inPixels:m}},isCollapsed:()=>{const{collapsible:r,collapsedSize:l}=o(),c=s();return r&&D(l,c)},resize:r=>{const{group:l}=n(),{element:c}=i(),m=te({group:l}),p=oe({groupSize:m,panelElement:c,styleProp:r}),S=O(p/m*100);a(S)}}}function Ge(e){if(e.defaultPrevented)return;const t=q();be(e,t).forEach(o=>{if(o.separator&&!o.separator.disableDoubleClick){const i=o.panels.find(s=>s.panelConstraints.defaultSize!==void 0);if(i){const s=i.panelConstraints.defaultSize,u=tt({groupId:o.group.id,panelId:i.id});u&&s!==void 0&&(u.resize(s),e.preventDefault())}}})}function fe(e){const t=q();for(const[n]of t)if(n.separators.some(o=>o.element===e))return n;throw Error("Could not find parent Group for separator element")}function nt({groupId:e}){const t=()=>{const n=q();for(const[o,i]of n)if(o.id===e)return{group:o,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:o}=t();return n?{}:o},setLayout(n){const{defaultLayoutDeferred:o,derivedPanelConstraints:i,group:s,groupSize:u,layout:a,separatorToPanels:r}=t(),l=K({layout:n,panelConstraints:i});return o?a:(W(a,l)||$(s,{defaultLayoutDeferred:o,derivedPanelConstraints:i,groupSize:u,layout:l,separatorToPanels:r}),l)}}}function U(e,t){const n=fe(e),o=H(n.id,!0),i=n.separators.find(m=>m.element===e);C(i,"Matching separator not found");const s=o.separatorToPanels.get(i);C(s,"Matching panels not found");const u=s.map(m=>n.panels.indexOf(m)),r=nt({groupId:n.id}).getLayout(),l=se({delta:t,initialLayout:r,panelConstraints:o.derivedPanelConstraints,pivotIndices:u,prevLayout:r,trigger:"keyboard"}),c=K({layout:l,panelConstraints:o.derivedPanelConstraints});W(r,c)||$(n,{defaultLayoutDeferred:o.defaultLayoutDeferred,derivedPanelConstraints:o.derivedPanelConstraints,groupSize:o.groupSize,layout:c,separatorToPanels:o.separatorToPanels},{isUserInteraction:!0})}function Ae(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=fe(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&U(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&U(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&U(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&U(t,-5);break}case"End":{e.preventDefault(),U(t,100);break}case"Enter":{e.preventDefault();const o=fe(t),i=H(o.id,!0),{derivedPanelConstraints:s,layout:u,separatorToPanels:a}=i,r=o.separators.find(p=>p.element===t);C(r,"Matching separator not found");const l=a.get(r);C(l,"Matching panels not found");const c=l[0],m=s.find(p=>p.panelId===c.id);if(C(m,"Panel metadata not found"),m.collapsible){const p=u[c.id],S=m.collapsedSize===p?o.mutableState.expandedPanelSizes[c.id]??m.minSize:m.collapsedSize;U(t,S-p)}break}case"F6":{e.preventDefault();const i=fe(t).separators.map(r=>r.element),s=Array.from(i).findIndex(r=>r===e.currentTarget);C(s!==null,"Index not found");const u=e.shiftKey?s>0?s-1:i.length-1:s+1<i.length?s+1:0;i[u].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),U(t,-100);break}}}function Fe(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;const t=q(),n=be(e,t),o=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const u=t.get(s.group);u&&o.set(s.group,u.layout)}),ee({cursorFlags:0,hitRegions:n,initialLayoutMap:o,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function ot({document:e,event:t,hitRegions:n,initialLayoutMap:o,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:u}){let a=0;n.forEach(l=>{const{group:c,groupSize:m}=l,{orientation:p,panels:S}=c,{disableCursor:x}=c.mutableState;let f=0;s?p==="horizontal"?f=(t.clientX-s.x)/m*100:f=(t.clientY-s.y)/m*100:p==="horizontal"?f=t.clientX<0?-100:100:f=t.clientY<0?-100:100;const d=o.get(c),h=i.get(c);if(!d||!h)return;const{defaultLayoutDeferred:y,derivedPanelConstraints:b,groupSize:v,layout:g,separatorToPanels:L}=h;if(b&&g&&L){const M=se({delta:f,initialLayout:d,panelConstraints:b,pivotIndices:l.panels.map(R=>S.indexOf(R)),prevLayout:g,trigger:"mouse-or-touch"});if(W(M,g)){if(f!==0&&!x)switch(p){case"horizontal":{a|=f<0?qe:Xe;break}case"vertical":{a|=f<0?Ye:Je;break}}}else $(l.group,{defaultLayoutDeferred:y,derivedPanelConstraints:b,groupSize:v,layout:M,separatorToPanels:L})}});let r=0;t.movementX===0?r|=u&Re:r|=a&Re,t.movementY===0?r|=u&Ce:r|=a&Ce,xt(r),Se(e)}function Ne(e){const t=q(),n=B();switch(n.state){case"active":ot({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function _e(e){if(e.defaultPrevented)return;const t=B(),n=q();switch(t.state){case"active":{if(e.buttons===0){ee({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(o=>{const i=H(o.group.id,!0);$(o.group,i,{isUserInteraction:!0})});return}for(const o of t.hitRegions)if(o.separator){const{element:i}=o.separator;i.hasPointerCapture?.(e.pointerId)||i.setPointerCapture?.(e.pointerId)}ot({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const o=be(e,n);o.length===0?t.state!=="inactive"&&ee({cursorFlags:0,state:"inactive"}):ee({cursorFlags:0,hitRegions:o,state:"hover"}),Se(e.currentTarget);break}}}function je(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(B().state){case"hover":ee({cursorFlags:0,state:"inactive"})}}function $e(e){if(e.defaultPrevented)return;if(e.pointerType==="mouse"&&e.button>0)return;Qe(e.currentTarget)&&e.preventDefault()}function He(e){let t=0,n=0;const o={};for(const s of e)if(s.defaultSize!==void 0){t++;const u=O(s.defaultSize);n+=u,o[s.panelId]=u}else o[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=O((100-n)/i);for(const u of e)u.defaultSize===void 0&&(o[u.panelId]=s)}return o}function Ot(e,t,n){if(!n[0])return;const i=e.panels.find(l=>l.element===t);if(!i||!i.onResize)return;const s=te({group:e}),u=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,r={asPercentage:O(u/s*100),inPixels:u};i.mutableValues.prevSize=r,i.onResize(r,i.id,a)}function Gt(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const o in e)if(e[o]!==t[o])return!1;return!0}function At({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:o}){if(n<=0||t<=0||n===t)return o;let i=0,s=0,u=!1;const a=new Map,r=[];for(const m of e.panels){const p=o[m.id]??0;switch(m.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{u=!0;const S=p/100*n,x=O(S/t*100);a.set(m.id,x),i+=x;break}case"preserve-relative-size":default:{r.push(m.id),s+=p;break}}}if(!u||r.length===0)return o;const l=100-i,c={...o};if(a.forEach((m,p)=>{c[p]=m}),s>0)for(const m of r){const p=o[m]??0;c[m]=O(p/s*l)}else{const m=O(l/r.length);for(const p of r)c[p]=m}return c}function Ft(e,t){const n=e.map(i=>i.id),o=Object.keys(t);if(n.length!==o.length)return!1;for(const i of n)if(!o.includes(i))return!1;return!0}const J=new Map;function Nt(e){let t=!0;C(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,o=new Set,i=new Set,s=new n(f=>{for(const d of f){const{borderBoxSize:h,target:y}=d;if(y===e.element){if(t){const b=te({group:e});if(b===0)return;const v=H(e.id);if(!v)return;const g=me(e),L=v.defaultLayoutDeferred?He(g):v.layout,M=At({group:e,nextGroupSize:b,prevGroupSize:v.groupSize,prevLayout:L}),R=K({layout:M,panelConstraints:g});if(!v.defaultLayoutDeferred&&W(v.layout,R)&&Gt(v.derivedPanelConstraints,g)&&v.groupSize===b)return;$(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:g,groupSize:b,layout:R,separatorToPanels:v.separatorToPanels})}}else Ot(e,y,h)}});s.observe(e.element),e.panels.forEach(f=>{C(!o.has(f.id),`Panel ids must be unique; id "${f.id}" was used more than once`),o.add(f.id),f.onResize&&s.observe(f.element)});const u=te({group:e}),a=me(e),r=e.panels.map(({id:f})=>f).join(",");let l=e.mutableState.defaultLayout;l&&(Ft(e.panels,l)||(l=void 0));const c=e.mutableState.layouts[r]??l??He(a),m=K({layout:c,panelConstraints:a}),p=e.element.ownerDocument;J.set(p,(J.get(p)??0)+1);const S=new Map;return We(e).forEach(f=>{f.separator&&S.set(f.separator,f.panels)}),$(e,{defaultLayoutDeferred:u===0,derivedPanelConstraints:a,groupSize:u,layout:m,separatorToPanels:S}),e.separators.forEach(f=>{C(!i.has(f.id),`Separator ids must be unique; id "${f.id}" was used more than once`),i.add(f.id),f.element.addEventListener("keydown",Ae)}),(p.addEventListener("contextmenu",Ie,!0),p.addEventListener("dblclick",Ge,!0),p.addEventListener("pointerdown",Fe,!0),p.addEventListener("pointerleave",Ne),p.addEventListener("pointermove",_e),p.addEventListener("pointerout",je),p.addEventListener("pointerup",$e,!0)),function(){t=!1,J.set(p,Math.max(0,(J.get(p)??0)-1)),wt(e),e.separators.forEach(d=>{d.element.removeEventListener("keydown",Ae)}),J.get(p)||(p.removeEventListener("contextmenu",Ie,!0),p.removeEventListener("dblclick",Ge,!0),p.removeEventListener("pointerdown",Fe,!0),p.removeEventListener("pointerleave",Ne),p.removeEventListener("pointermove",_e),p.removeEventListener("pointerout",je),p.removeEventListener("pointerup",$e,!0)),s.disconnect()}}function _t(){const[e,t]=z.useState({}),n=z.useCallback(()=>t({}),[]);return[e,n]}function xe(e){const t=z.useId();return`${e??t}`}const X=typeof window<"u"?z.useLayoutEffect:z.useEffect;function ie(e){const t=z.useRef(e);return X(()=>{t.current=e},[e]),z.useCallback((...n)=>t.current?.(...n),[t])}function ze(...e){return ie(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function Pe(e){const t=z.useRef({...e});return X(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const it=z.createContext(null);function jt(e,t){const n=z.useRef({getLayout:()=>({}),setLayout:zt});z.useImperativeHandle(t,()=>n.current,[]),X(()=>{Object.assign(n.current,nt({groupId:e}))})}function rt({children:e,className:t,defaultLayout:n,disableCursor:o,disabled:i,elementRef:s,groupRef:u,id:a,onLayoutChange:r,onLayoutChanged:l,orientation:c="horizontal",resizeTargetMinimumSize:m={coarse:20,fine:10},style:p,...S}){const x=z.useRef({onLayoutChange:{},onLayoutChanged:{}}),f=ie(P=>{W(x.current.onLayoutChange,P)||(x.current.onLayoutChange=P,r?.(P))}),d=ie((P,w)=>{W(x.current.onLayoutChanged,P)||(x.current.onLayoutChanged=P,l?.(P,{isUserInteraction:w}))}),h=xe(a),y=z.useRef(null),[b,v]=_t(),g=z.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:m,separators:[]}),L=ze(y,s);jt(h,u);const M=ie((P,w)=>{const I=B(),E=ke(P),k=H(P);if(k){let T=!1;switch(I.state){case"active":{T=I.hitRegions.some(V=>V.group===E);break}}return{flexGrow:k.layout[w]??1,pointerEvents:T?"none":void 0}}if(n?.[w])return{flexGrow:n?.[w]}}),R=Pe({defaultLayout:n,disableCursor:o}),G=z.useMemo(()=>({get disableCursor(){return!!R.disableCursor},getPanelStyles:M,id:h,orientation:c,registerPanel:P=>{const w=g.current;return w.panels=ge(c,[...w.panels,P]),v(),()=>{w.panels=w.panels.filter(I=>I!==P),v()}},registerSeparator:P=>{const w=g.current;return w.separators=ge(c,[...w.separators,P]),v(),()=>{w.separators=w.separators.filter(I=>I!==P),v()}},updatePanelProps:(P,{disabled:w})=>{const E=g.current.panels.find(V=>V.id===P);E&&(E.panelConstraints.disabled=w);const k=ke(h),T=H(h);k&&T&&$(k,{...T,derivedPanelConstraints:me(k)})},updateSeparatorProps:(P,{disabled:w,disableDoubleClick:I})=>{const k=g.current.separators.find(T=>T.id===P);k&&(k.disabled=w,k.disableDoubleClick=I)}}),[M,h,v,c,R]),N=z.useRef(null);return X(()=>{const P=y.current;if(P===null)return;const w=g.current;let I;if(R.defaultLayout!==void 0&&Object.keys(R.defaultLayout).length===w.panels.length){I={};for(const _ of w.panels){const Y=R.defaultLayout[_.id];Y!==void 0&&(I[_.id]=Y)}}const E={disabled:!!i,element:P,id:h,mutableState:{defaultLayout:I,disableCursor:!!R.disableCursor,expandedPanelSizes:g.current.lastExpandedPanelSizes,layouts:g.current.layouts},orientation:c,panels:w.panels,resizeTargetMinimumSize:w.resizeTargetMinimumSize,separators:w.separators};N.current=E;const k=Nt(E),{defaultLayoutDeferred:T,derivedPanelConstraints:V,layout:ae}=H(E.id,!0);!T&&V.length>0&&(f(ae),d(ae,!1));const ne=ve(h,_=>{const{defaultLayoutDeferred:Y,derivedPanelConstraints:Le,layout:le}=_.next;if(Y||Le.length===0)return;const lt=E.panels.map(({id:j})=>j).join(",");E.mutableState.layouts[lt]=le,Le.forEach(j=>{if(j.collapsible){const{layout:pe}=_.prev??{};if(pe){const ct=D(j.collapsedSize,le[j.panelId]),ft=D(j.collapsedSize,pe[j.panelId]);ct&&!ft&&(E.mutableState.expandedPanelSizes[j.panelId]=pe[j.panelId])}}});const ut=B().state!=="active";f(le),ut&&d(le,_.isUserInteraction)});return()=>{N.current=null,k(),ne()}},[i,h,d,f,c,b,R]),z.useEffect(()=>{const P=N.current;P&&(P.mutableState.defaultLayout=n,P.mutableState.disableCursor=!!o)}),re.jsx(it.Provider,{value:G,children:re.jsx("div",{...S,className:t,"data-group":!0,"data-testid":h,id:h,ref:L,style:{height:"100%",width:"100%",overflow:"hidden",...p,display:"flex",flexDirection:c==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:c==="horizontal"?"pan-y":"pan-x"},children:e})})}rt.displayName="Group";function de(e,t){return`react-resizable-panels:${[e,...t].join(":")}`}function $t({id:e,panelIds:t,storage:n}){const o=de(e,[]),i=n.getItem(o);if(i)try{const s=JSON.parse(i);if(t){const u=t.join(","),a=s[u];if(a&&Array.isArray(a.layout)&&t.length===a.layout.length){const r={};for(let l=0;l<t.length;l++)r[t[l]]=a.layout[l];return r}}else{const u=Object.keys(s);if(u.length===1){const a=s[u[0]];if(a&&Array.isArray(a.layout)){const r=u[0].split(",");if(r.length===a.layout.length){const l={};for(let c=0;c<r.length;c++)l[r[c]]=a.layout[c];return l}}}}}catch{}}function Ht({debounceSaveMs:e=100,onlySaveAfterUserInteractions:t,panelIds:n,storage:o=localStorage,...i}){const s=n!==void 0,u="id"in i?i.id:i.groupId,a=de(u,n??[]),r=z.useSyncExternalStore(Vt,()=>o.getItem(a),()=>o.getItem(a)),l=z.useMemo(()=>{if(r){const d=JSON.parse(r),h=Object.values(d);if(Array.from(h).every(y=>typeof y=="number"))return d}},[r]),c=z.useMemo(()=>{if(!l)return $t({id:u,panelIds:n,storage:o})},[l,u,n,o]),m=l??c,p=z.useRef(null),S=z.useCallback(()=>{const d=p.current;d&&(p.current=null,clearTimeout(d))},[]);z.useLayoutEffect(()=>()=>{S()},[S]);const x=z.useCallback((d,h)=>{if(t&&!h.isUserInteraction)return;S();let y;s?y=de(u,Object.keys(d)):y=de(u,[]);try{o.setItem(y,JSON.stringify(d))}catch(b){console.error(b)}},[S,s,u,t,o]),f=z.useCallback(d=>{S(),e===0?x(d,{isUserInteraction:!1}):p.current=setTimeout(()=>{x(d,{isUserInteraction:!1})},e)},[S,e,x]);return{defaultLayout:m,onLayoutChange:f,onLayoutChanged:x}}function Vt(){return function(){}}function Ut(){return z.useState(null)}function Bt(){return z.useRef(null)}function we(){const e=z.useContext(it);return C(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function Wt(e,t){const{id:n}=we(),o=z.useRef({collapse:he,expand:he,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:he});z.useImperativeHandle(t,()=>o.current,[]),X(()=>{Object.assign(o.current,tt({groupId:n,panelId:e}))})}function st({children:e,className:t,collapsedSize:n="0%",collapsible:o=!1,defaultSize:i,disabled:s,elementRef:u,groupResizeBehavior:a="preserve-relative-size",id:r,maxSize:l="100%",minSize:c="0%",onResize:m,panelRef:p,style:S,...x}){const f=!!r,d=xe(r),h=Pe({disabled:s}),y=z.useRef(null),b=ze(y,u),{getPanelStyles:v,id:g,orientation:L,registerPanel:M,updatePanelProps:R}=we(),G=m!==null,N=ie((E,k,T)=>{m?.(E,r,T)});X(()=>{const E=y.current;if(E!==null){const k={element:E,id:d,idIsStable:f,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:G?N:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:o,defaultSize:i,disabled:h.disabled,maxSize:l,minSize:c}};return M(k)}},[a,n,o,i,G,d,f,l,c,N,M,h]),z.useEffect(()=>{R(d,{disabled:s})},[s,d,R]),Wt(d,p);const P=()=>{const E=v(g,d);if(E)return JSON.stringify(E)},w=z.useSyncExternalStore(E=>ve(g,E),P,P);let I;return w?I=JSON.parse(w):i!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:I={flexGrow:1},re.jsx("div",{...x,"data-disabled":s||void 0,"data-panel":!0,"data-testid":d,id:d,ref:b,style:{...Kt,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:re.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...S,touchAction:L==="horizontal"?"pan-y":"pan-x"},children:e})})}st.displayName="Panel";const Kt={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function qt(){return z.useState(null)}function Xt(){return z.useRef(null)}function Yt({layout:e,panelConstraints:t,panelId:n,panelIndex:o}){let i,s;const u=e[n],a=t.find(r=>r.panelId===n);if(a){const r=a.maxSize,l=a.collapsible?a.collapsedSize:a.minSize,c=[o,o+1];s=K({layout:se({delta:l-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n],i=K({layout:se({delta:r-u,initialLayout:e,panelConstraints:t,pivotIndices:c,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:u}}function at({children:e,className:t,disabled:n,disableDoubleClick:o,elementRef:i,id:s,style:u,...a}){const r=xe(s),l=Pe({disabled:n,disableDoubleClick:o}),[c,m]=z.useState({}),[p,S]=z.useState("inactive"),[x,f]=z.useState(!1),d=z.useRef(null),h=ze(d,i),{disableCursor:y,id:b,orientation:v,registerSeparator:g,updateSeparatorProps:L}=we(),M=v==="horizontal"?"vertical":"horizontal";X(()=>{const N=d.current;if(N!==null){const P={disabled:l.disabled,disableDoubleClick:l.disableDoubleClick,element:N,id:r},w=g(P),I=bt(k=>{S(k.next.state!=="inactive"&&k.next.hitRegions.some(T=>T.separator===P)?k.next.state:"inactive")}),E=ve(b,k=>{const{derivedPanelConstraints:T,layout:V,separatorToPanels:ae}=k.next,ne=ae.get(P);if(ne){const _=ne[0],Y=ne.indexOf(_);m(Yt({layout:V,panelConstraints:T,panelId:_.id,panelIndex:Y}))}});return()=>{I(),E(),w()}}},[b,r,g,l]),z.useEffect(()=>{L(r,{disabled:n,disableDoubleClick:o})},[n,o,r,L]);let R;n&&!y&&(R="not-allowed");let G;if(n)G="disabled";else switch(p){case"active":{G="active";break}default:x?G="focus":G=p}return re.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":n||void 0,"aria-orientation":M,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":G,"data-testid":r,id:r,onBlur:()=>f(!1),onFocus:()=>f(!0),ref:h,role:"separator",style:{flexBasis:"auto",cursor:R,...u,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}at.displayName="Separator";exports.Group=rt;exports.Panel=st;exports.Separator=at;exports.isCoarsePointer=Be;exports.useDefaultLayout=Ht;exports.useGroupCallbackRef=Ut;exports.useGroupRef=Bt;exports.usePanelCallbackRef=qt;exports.usePanelRef=Xt;//# sourceMappingURL=react-resizable-panels.cjs.mapdiff --git a/dist/react-resizable-panels.js b/dist/react-resizable-panels.js-index a7428e98b76a49794309fb68733c4b0854f9e2c4..2b6af644043ee242f662e8341e966a91c2ec622b 100644+index a7428e98b76a49794309fb68733c4b0854f9e2c4..83013b0f66eea0b7558878f252838de55681951c 100644--- a/dist/react-resizable-panels.js+++ b/dist/react-resizable-panels.js@@ -838,14 +838,13 @@ function K({@@ -32,3 +32,12 @@ index a7428e98b76a49794309fb68733c4b0854f9e2c4..2b6af644043ee242f662e8341e966a91if (!k(i, 100) && o.length > 0)for (let a = 0; a < t.length; a++) {const r = o[a];+@@ -1508,7 +1507,7 @@ function Bt(e) {+ !i.has(f.id),+ `Separator ids must be unique; id "${f.id}" was used more than once`+ ), i.add(f.id), f.element.addEventListener("keydown", $e);+- }), J.get(p) === 1 && (p.addEventListener("contextmenu", Ge, !0), p.addEventListener("dblclick", _e, !0), p.addEventListener("pointerdown", je, !0), p.addEventListener("pointerleave", He), p.addEventListener("pointermove", Ve), p.addEventListener("pointerout", Ue), p.addEventListener("pointerup", Be, !0)), function() {++ }), (p.addEventListener("contextmenu", Ge, !0), p.addEventListener("dblclick", _e, !0), p.addEventListener("pointerdown", je, !0), p.addEventListener("pointerleave", He), p.addEventListener("pointermove", Ve), p.addEventListener("pointerout", Ue), p.addEventListener("pointerup", Be, !0)), function() {+ t = !1, J.set(+ p,+ Math.max(0, (J.get(p) ?? 0) - 1)diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex f4ac96e96..94d13d4b1 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -138,7 +138,7 @@ patchedDependencies:hash: d59ed459a6ae570e843d0829f844dde24c0697b883351b198034f47606766517path: patches/[email protected]- hash: 57bd789941845510ee2a01f477777cb3906f16e3d9396b6f20224a999d6fc38b+ hash: 2719389c75ab504435a8017d295e1c88adae068ae5097a4ac82cef2b6cb23e92path: patches/[email protected]hash: bc95fab9af70f704280673eafabcb5a40cc180fd5122d62e6c44cac2f7076245@@ -580,7 +580,7 @@ importers:version: 5.4.3(patch_hash=d59ed459a6ae570e843d0829f844dde24c0697b883351b198034f47606766517)([email protected]([email protected]))([email protected])react-resizable-panels:specifier: ^4.9.0- version: 4.12.1(patch_hash=57bd789941845510ee2a01f477777cb3906f16e3d9396b6f20224a999d6fc38b)([email protected]([email protected]))([email protected])+ version: 4.12.1(patch_hash=2719389c75ab504435a8017d295e1c88adae068ae5097a4ac82cef2b6cb23e92)([email protected]([email protected]))([email protected])scheduler-polyfill:specifier: ^1.3.0version: 1.3.0@@ -21360,7 +21360,7 @@ snapshots:optionalDependencies:'@types/react': 19.2.17- [email protected](patch_hash=57bd789941845510ee2a01f477777cb3906f16e3d9396b6f20224a999d6fc38b)([email protected]([email protected]))([email protected]):+ [email protected](patch_hash=2719389c75ab504435a8017d295e1c88adae068ae5097a4ac82cef2b6cb23e92)([email protected]([email protected]))([email protected]):dependencies:react: 19.2.5react-dom: 19.2.5([email protected])