regular-layout 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/common/layout_config.ts", "../src/common/remove_child.ts", "../src/common/generate_grid.ts", "../src/common/calculate_intersect.ts", "../src/common/insert_child.ts", "../src/common/redistribute_panel_sizes.ts", "../src/common/generate_overlay.ts", "../src/common/calculate_split.ts", "../src/common/flatten.ts", "../src/regular-layout.ts", "../src/regular-layout-frame.ts", "../src/extensions.ts"],
4
- "sourcesContent": ["// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * The percentage of the maximum resize distance that will be clamped.\n *\n */\nexport const MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD = 0.15;\n\n/**\n * Threshold from panel edge that is considered a split vs drop action.\n */\nexport const SPLIT_EDGE_TOLERANCE = 0.15;\n\n/**\n * Tolerance threshold for considering two grid track positions as identical.\n *\n * When collecting and deduplicating track positions, any positions closer than\n * this value are treated as the same position to avoid redundant grid tracks.\n */\nexport const GRID_TRACK_COLLAPSE_TOLERANCE = 0.0001;\n\n/**\n * The representation of a CSS grid, in JSON form.\n */\nexport type Layout = SplitLayout | TabLayout;\n\n/**\n * The orientation (of a `SplitPanel`).\n */\nexport type Orientation = \"horizontal\" | \"vertical\";\n\n/**\n * A logical rectange in percent-coordinates (of a (1, 1) square).\n */\nexport interface ViewWindow {\n\trow_start: number;\n\trow_end: number;\n\tcol_start: number;\n\tcol_end: number;\n}\n\n/**\n * A split panel that divides space among multiple child layouts\n * .\n * Child panels are arranged either horizontally (side by side) or vertically\n * (stacked), via the `orientation` property `\"horizzontal\"` and `\"vertical\"`\n * (respectively).\n */\nexport interface SplitLayout {\n\ttype: \"split-panel\";\n\tchildren: Layout[];\n\tsizes: number[];\n\torientation: Orientation;\n}\n\n/**\n * A leaf panel node that contains a single named child element.\n */\nexport interface TabLayout {\n\ttype: \"child-panel\";\n\tchild: string;\n}\n\n/**\n * Represents a draggable divider between two panels in the layout.\n *\n * Used for hit detection.\n */\nexport interface LayoutDivider {\n\tpath: number[];\n\tview_window: ViewWindow;\n\ttype: Orientation;\n}\n\n/**\n * Represents a panel location result from hit detection.\n *\n * Contains both the panel identifier and its grid position in relative units.\n * The generic parameter `T` allows DOM-only properties (e.g. `DOMRect`) to be\n * shared in this cross-platform module.\n */\nexport interface LayoutPath<T = undefined> {\n\ttype: \"layout-path\";\n\tslot: string;\n\tpath: number[];\n\tview_window: ViewWindow;\n\tcolumn_offset: number;\n\trow_offset: number;\n\torientation: Orientation;\n\tbox: T;\n}\n\n/**\n * Recursively iterates over all child panel names in the layout tree, yielding\n * panel names in depth-first order.\n *\n * @param panel - The layout tree to iterate over\n * @returns Generator yielding child panel names\n */\nexport function* iter_panel_children(panel: Layout): Generator<string> {\n\tif (panel.type === \"split-panel\") {\n\t\tfor (const child of panel.children) {\n\t\t\tyield* iter_panel_children(child);\n\t\t}\n\t} else {\n\t\tyield panel.child;\n\t}\n}\n\n/**\n * An empty `Layout` with no panels.\n */\nexport const EMPTY_PANEL: Layout = {\n\ttype: \"split-panel\",\n\torientation: \"horizontal\",\n\tsizes: [],\n\tchildren: [],\n};\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout } from \"./layout_config.ts\";\nimport { EMPTY_PANEL } from \"./layout_config.ts\";\n\n/**\n * Removes a child panel from the layout tree by its name.\n *\n * Redistributes the removed panel's space proportionally among remaining\n * siblings. Automatically collapses split panels when only one child remains.\n *\n * @param panel - The root layout tree to remove from.\n * @param child - Name of the child panel to remove.\n * @returns A new layout tree with the child removed (original is not mutated).\n * Returns `EMPTY_PANEL` if the last panel is removed.\n */\nexport function remove_child(panel: Layout, child: string): Layout {\n\t// If this is a child panel and it matches, we can't remove ourselves\n\t// The caller should handle this case\n\tif (panel.type === \"child-panel\") {\n\t\treturn structuredClone(EMPTY_PANEL);\n\t}\n\n\t// Clone the panel structure\n\tconst result = structuredClone(panel);\n\n\t// Try to remove the child from this split panel's children\n\tconst index = result.children.findIndex((p) => {\n\t\tif (p.type === \"child-panel\") {\n\t\t\treturn p.child === child;\n\t\t}\n\t\treturn false;\n\t});\n\n\tif (index !== -1) {\n\t\t// Found the child at this level - remove it\n\t\tconst newChildren = result.children.filter((_, i) => i !== index);\n\t\tconst newSizes = remove_and_redistribute(result.sizes, index);\n\n\t\t// If only one child remains, collapse the split panel\n\t\tif (newChildren.length === 1) {\n\t\t\treturn newChildren[0];\n\t\t}\n\n\t\tresult.children = newChildren;\n\t\tresult.sizes = newSizes;\n\t\treturn result;\n\t}\n\n\t// Child not found at this level - recursively search children\n\tlet modified = false;\n\tconst newChildren = result.children.map((p) => {\n\t\tif (p.type === \"split-panel\") {\n\t\t\tconst updated = remove_child(p, child);\n\t\t\tif (updated !== p) {\n\t\t\t\tmodified = true;\n\t\t\t}\n\t\t\treturn updated;\n\t\t}\n\t\treturn p;\n\t});\n\n\tif (modified) {\n\t\tresult.children = newChildren;\n\t}\n\n\treturn result;\n}\n\nfunction remove_and_redistribute(arr: number[], index: number): number[] {\n\tconst result = [];\n\n\t// Get the size of the element being removed\n\tconst removed_size = arr[index];\n\n\t// Calculate the total of remaining elements\n\tlet remaining_total = 0;\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (i !== index) {\n\t\t\tremaining_total += arr[i];\n\t\t}\n\t}\n\n\t// Distribute the removed size proportionally to remaining elements\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (i !== index) {\n\t\t\tconst proportion = arr[i] / remaining_total;\n\t\t\tresult.push(arr[i] + removed_size * proportion);\n\t\t}\n\t}\n\n\treturn result;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { GRID_TRACK_COLLAPSE_TOLERANCE, type Layout } from \"./layout_config.ts\";\nimport { remove_child } from \"./remove_child.ts\";\n\ninterface GridCell {\n\tchild: string;\n\tcolStart: number;\n\tcolEnd: number;\n\trowStart: number;\n\trowEnd: number;\n}\n\nfunction dedupePositions(positions: number[]): number[] {\n\tif (positions.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst sorted = positions.sort((a, b) => a - b);\n\tconst result = [sorted[0]];\n\tfor (let i = 1; i < sorted.length; i++) {\n\t\tif (\n\t\t\tMath.abs(sorted[i] - result[result.length - 1]) >\n\t\t\tGRID_TRACK_COLLAPSE_TOLERANCE\n\t\t) {\n\t\t\tresult.push(sorted[i]);\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction collectTrackPositions(\n\tpanel: Layout,\n\torientation: \"horizontal\" | \"vertical\",\n\tstart: number,\n\tend: number,\n): number[] {\n\tif (panel.type === \"child-panel\") {\n\t\treturn [start, end];\n\t}\n\n\tif (panel.orientation === orientation) {\n\t\tconst positions: number[] = [start, end];\n\t\tlet current = start;\n\t\tfor (let i = 0; i < panel.children.length; i++) {\n\t\t\tconst size = panel.sizes[i];\n\t\t\tconst childPositions = collectTrackPositions(\n\t\t\t\tpanel.children[i],\n\t\t\t\torientation,\n\t\t\t\tcurrent,\n\t\t\t\tcurrent + size * (end - start),\n\t\t\t);\n\n\t\t\tpositions.push(...childPositions);\n\t\t\tcurrent = current + size * (end - start);\n\t\t}\n\n\t\treturn dedupePositions(positions);\n\t} else {\n\t\tconst allPositions: number[] = [start, end];\n\t\tfor (const child of panel.children) {\n\t\t\tconst childPositions = collectTrackPositions(\n\t\t\t\tchild,\n\t\t\t\torientation,\n\t\t\t\tstart,\n\t\t\t\tend,\n\t\t\t);\n\n\t\t\tallPositions.push(...childPositions);\n\t\t}\n\n\t\treturn dedupePositions(allPositions);\n\t}\n}\n\nfunction findTrackIndex(positions: number[], value: number): number {\n\tfor (let i = 0; i < positions.length; i++) {\n\t\tif (Math.abs(positions[i] - value) < 0.0001) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\tthrow new Error(`Position ${value} not found in ${positions}`);\n}\n\nfunction buildCells(\n\tpanel: Layout,\n\tcolPositions: number[],\n\trowPositions: number[],\n\tcolStart: number,\n\tcolEnd: number,\n\trowStart: number,\n\trowEnd: number,\n): GridCell[] {\n\tif (panel.type === \"child-panel\") {\n\t\treturn [\n\t\t\t{\n\t\t\t\tchild: panel.child,\n\t\t\t\tcolStart: findTrackIndex(colPositions, colStart),\n\t\t\t\tcolEnd: findTrackIndex(colPositions, colEnd),\n\t\t\t\trowStart: findTrackIndex(rowPositions, rowStart),\n\t\t\t\trowEnd: findTrackIndex(rowPositions, rowEnd),\n\t\t\t},\n\t\t];\n\t}\n\n\tconst cells: GridCell[] = [];\n\tconst { children, sizes, orientation } = panel;\n\tif (orientation === \"horizontal\") {\n\t\tlet current = colStart;\n\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\tconst next = current + sizes[i] * (colEnd - colStart);\n\t\t\tcells.push(\n\t\t\t\t...buildCells(\n\t\t\t\t\tchildren[i],\n\t\t\t\t\tcolPositions,\n\t\t\t\t\trowPositions,\n\t\t\t\t\tcurrent,\n\t\t\t\t\tnext,\n\t\t\t\t\trowStart,\n\t\t\t\t\trowEnd,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tcurrent = next;\n\t\t}\n\t} else {\n\t\tlet current = rowStart;\n\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\tconst next = current + sizes[i] * (rowEnd - rowStart);\n\t\t\tcells.push(\n\t\t\t\t...buildCells(\n\t\t\t\t\tchildren[i],\n\t\t\t\t\tcolPositions,\n\t\t\t\t\trowPositions,\n\t\t\t\t\tcolStart,\n\t\t\t\t\tcolEnd,\n\t\t\t\t\tcurrent,\n\t\t\t\t\tnext,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tcurrent = next;\n\t\t}\n\t}\n\n\treturn cells;\n}\n\nconst host_template = (rowTemplate: string, colTemplate: string) =>\n\t`:host { display: grid; gap: 0px; grid-template-rows: ${rowTemplate}; grid-template-columns: ${colTemplate}; }`;\n\nconst child_template = (slot: string, rowPart: string, colPart: string) =>\n\t`:host ::slotted([slot=${slot}]) { grid-column: ${colPart}; grid-row: ${rowPart}; }`;\n\n/**\n * Generates CSS Grid styles to render a layout tree.\n * Creates grid-template-rows, grid-template-columns, and positioning rules for\n * all child panels.\n *\n * @param layout - The layout tree to convert to CSS\n * @param round - If true, rounds percentages to whole numbers. Useful for\n * avoiding sub-pixel rendering issues. Defaults to false.\n * @returns CSS string containing :host and ::slotted rules implementing the\n * layout.\n *\n * @example\n * ```typescript\n * const layout = {\n * type: \"split-panel\",\n * orientation: \"horizontal\",\n * children: [\n * { type: \"child-panel\", child: \"sidebar\" },\n * { type: \"child-panel\", child: \"main\" }\n * ],\n * sizes: [0.25, 0.75]\n * };\n *\n * const css = create_css_grid_layout(layout);\n * // Returns CSS like:\n * // :host { display: grid; grid-template-columns: 25% 75%; ... }\n * // :host ::slotted([slot=sidebar]) { grid-column: 1; grid-row: 1; }\n * // :host ::slotted([slot=main]) { grid-column: 2; grid-row: 1; }\n * ```\n */\nexport function create_css_grid_layout(\n\tlayout: Layout,\n\tround: boolean = false,\n\toverlay?: [string, string],\n): string {\n\tif (overlay) {\n\t\tlayout = remove_child(layout, overlay[0]);\n\t}\n\n\tif (layout.type === \"child-panel\") {\n\t\treturn `${host_template(\"100%\", \"100%\")}\\n${child_template(layout.child, \"1\", \"1\")}`;\n\t}\n\n\tconst colPositions = collectTrackPositions(layout, \"horizontal\", 0, 1);\n\tconst colSizes: number[] = [];\n\tfor (let i = 0; i < colPositions.length - 1; i++) {\n\t\tcolSizes.push(colPositions[i + 1] - colPositions[i]);\n\t}\n\n\tconst colTemplate = colSizes\n\t\t.map((s) => `${round ? Math.round(s * 100) : s * 100}%`)\n\t\t.join(\" \");\n\n\tconst rowPositions = collectTrackPositions(layout, \"vertical\", 0, 1);\n\tconst rowSizes: number[] = [];\n\tfor (let i = 0; i < rowPositions.length - 1; i++) {\n\t\trowSizes.push(rowPositions[i + 1] - rowPositions[i]);\n\t}\n\n\tconst rowTemplate = rowSizes\n\t\t.map((s) => `${round ? Math.round(s * 100) : s * 100}%`)\n\t\t.join(\" \");\n\n\tconst cells = buildCells(layout, colPositions, rowPositions, 0, 1, 0, 1);\n\tconst css = [host_template(rowTemplate, colTemplate)];\n\tfor (const cell of cells) {\n\t\tconst colPart =\n\t\t\tcell.colEnd - cell.colStart === 1\n\t\t\t\t? `${cell.colStart + 1}`\n\t\t\t\t: `${cell.colStart + 1} / ${cell.colEnd + 1}`;\n\t\tconst rowPart =\n\t\t\tcell.rowEnd - cell.rowStart === 1\n\t\t\t\t? `${cell.rowStart + 1}`\n\t\t\t\t: `${cell.rowStart + 1} / ${cell.rowEnd + 1}`;\n\n\t\tcss.push(`${child_template(cell.child, rowPart, colPart)}`);\n\t\tif (cell.child === overlay?.[1]) {\n\t\t\tcss.push(`${child_template(overlay[0], rowPart, colPart)}`);\n\t\t\tcss.push(`:host ::slotted([slot=${overlay[0]}]) { z-index: 1; }`);\n\t\t}\n\t}\n\n\treturn css.join(\"\\n\");\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type {\n\tLayoutPath,\n\tLayoutDivider,\n\tLayout,\n\tViewWindow,\n} from \"./layout_config.ts\";\n\n/**\n * Determines which panel or divider is located at a given position in the\n * layout.\n *\n * @param row - Vertical position as a fraction (0-1) of the container\n * height\n * @param column - Horizontal position as a fraction (0-1) of the\n * container width\n * @param layout - The layout tree to search\n * @param check_dividers - Whether `LayoutDivider` intersection should be\n * checked, which oyu may not want for e.g. `drop` actions.\n * @returns The panel path if over a panel, a divider if over a resizable\n * boundary, or null if outside all panels\n */\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers: false,\n): LayoutPath;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers: true,\n): LayoutPath | null | LayoutDivider;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers?: boolean,\n): LayoutPath | null | LayoutDivider;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers: boolean = true,\n): LayoutPath | null | LayoutDivider {\n\treturn calculate_intersection_recursive(column, row, layout, check_dividers);\n}\n\nconst VIEW_WINDOW = {\n\trow_start: 0,\n\trow_end: 1,\n\tcol_start: 0,\n\tcol_end: 1,\n};\n\nfunction calculate_intersection_recursive(\n\tcolumn: number,\n\trow: number,\n\tpanel: Layout,\n\tcheck_dividers: boolean,\n\tparent_orientation: \"horizontal\" | \"vertical\" = \"horizontal\",\n\tview_window: ViewWindow = structuredClone(VIEW_WINDOW),\n\tpath: number[] = [],\n): LayoutPath | null | LayoutDivider {\n\t// Base case: if this is a child panel, return its name\n\tif (panel.type === \"child-panel\") {\n\t\treturn {\n\t\t\ttype: \"layout-path\",\n\t\t\tbox: undefined,\n\t\t\tslot: panel.child,\n\t\t\tpath: path,\n\t\t\tview_window: view_window,\n\t\t\tcolumn_offset:\n\t\t\t\t(column - view_window.col_start) /\n\t\t\t\t(view_window.col_end - view_window.col_start),\n\t\t\trow_offset:\n\t\t\t\t(row - view_window.row_start) /\n\t\t\t\t(view_window.row_end - view_window.row_start),\n\t\t\torientation: parent_orientation,\n\t\t};\n\t}\n\n\t// For split panels, determine which child was hit\n\tif (panel.orientation === \"vertical\") {\n\t\t// Vertical orientation = rows\n\t\tlet current_row = view_window.row_start;\n\t\tfor (let i = 0; i < panel.children.length; i++) {\n\t\t\tconst total_size = view_window.row_end - view_window.row_start;\n\t\t\tconst next_row = total_size * panel.sizes[i] + current_row;\n\t\t\tif (check_dividers && Math.abs(row - next_row) < 0.01) {\n\t\t\t\treturn {\n\t\t\t\t\tpath: [...path, i],\n\t\t\t\t\ttype: \"vertical\",\n\t\t\t\t\tview_window: {\n\t\t\t\t\t\t...view_window,\n\t\t\t\t\t\trow_start: current_row,\n\t\t\t\t\t\trow_end: next_row,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (row >= current_row && row < next_row) {\n\t\t\t\treturn calculate_intersection_recursive(\n\t\t\t\t\tcolumn,\n\t\t\t\t\trow,\n\t\t\t\t\tpanel.children[i],\n\t\t\t\t\tcheck_dividers,\n\t\t\t\t\t\"vertical\",\n\t\t\t\t\t{\n\t\t\t\t\t\t...view_window,\n\t\t\t\t\t\trow_start: current_row,\n\t\t\t\t\t\trow_end: next_row,\n\t\t\t\t\t},\n\t\t\t\t\t[...path, i],\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tcurrent_row = next_row;\n\t\t}\n\t} else {\n\t\t// Horizontal orientation = columns\n\t\tlet current_col = view_window.col_start;\n\t\tfor (let i = 0; i < panel.children.length; i++) {\n\t\t\tconst total_size = view_window.col_end - view_window.col_start;\n\t\t\tconst next_col = current_col + total_size * panel.sizes[i];\n\t\t\tif (check_dividers && Math.abs(column - next_col) < 0.01) {\n\t\t\t\treturn {\n\t\t\t\t\tpath: [...path, i],\n\t\t\t\t\ttype: \"horizontal\",\n\t\t\t\t\tview_window: {\n\t\t\t\t\t\t...view_window,\n\t\t\t\t\t\tcol_start: current_col,\n\t\t\t\t\t\tcol_end: next_col,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Check if the column falls within this child's bounds.\n\t\t\tif (column >= current_col && column < next_col) {\n\t\t\t\treturn calculate_intersection_recursive(\n\t\t\t\t\tcolumn,\n\t\t\t\t\trow,\n\t\t\t\t\tpanel.children[i],\n\t\t\t\t\tcheck_dividers,\n\t\t\t\t\t\"horizontal\",\n\t\t\t\t\t{\n\t\t\t\t\t\t...view_window,\n\t\t\t\t\t\tcol_start: current_col,\n\t\t\t\t\t\tcol_end: next_col,\n\t\t\t\t\t},\n\t\t\t\t\t[...path, i],\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tcurrent_col = next_col;\n\t\t}\n\t}\n\n\t// If we get here, the hit was outside all children (possibly in a gap or\n\t// boundary).\n\treturn null;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout } from \"./layout_config.ts\";\n\n/**\n * Inserts a new child panel into the layout tree at a specified location.\n * Creates a split panel if necessary and redistributes sizes equally among all\n * children.\n *\n * @param panel - The root layout tree to insert into\n * @param child - Unique identifier for the new child panel\n * @param path - Array of indices defining where to insert. Empty array inserts\n * at root level.\n * @param orientation - Orientation for newly created split panels. Defaults to\n * \"horizontal\".\n * @returns A new layout tree with the child inserted (original is not mutated).\n */\nexport function insert_child(\n\tpanel: Layout,\n\tchild: string,\n\tpath: number[],\n\torientation: \"horizontal\" | \"vertical\" = \"horizontal\",\n): Layout {\n\tif (path.length === 0) {\n\t\t// Insert at root level\n\t\tif (panel.type === \"child-panel\") {\n\t\t\t// Convert single child-panel to split-panel with two children\n\t\t\treturn {\n\t\t\t\ttype: \"split-panel\",\n\t\t\t\torientation,\n\t\t\t\tchildren: [\n\t\t\t\t\tpanel,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"child-panel\",\n\t\t\t\t\t\tchild,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tsizes: [0.5, 0.5],\n\t\t\t};\n\t\t} else {\n\t\t\t// Append to existing split-panel\n\t\t\tconst newChildren = [\n\t\t\t\t...panel.children,\n\t\t\t\t{\n\t\t\t\t\ttype: \"child-panel\",\n\t\t\t\t\tchild,\n\t\t\t\t} as Layout,\n\t\t\t];\n\n\t\t\tconst numChildren = newChildren.length;\n\t\t\tconst newSizes = Array(numChildren).fill(1 / numChildren);\n\t\t\treturn {\n\t\t\t\t...panel,\n\t\t\t\tchildren: newChildren,\n\t\t\t\tsizes: newSizes,\n\t\t\t};\n\t\t}\n\t}\n\n\t// Navigate down the path\n\tconst [index, ...restPath] = path;\n\tif (panel.type === \"child-panel\") {\n\t\t// This shouldn't happen if path.length > 0, but handle it gracefully\n\t\t// We need to split this child-panel\n\t\tconst newPanel: Layout = {\n\t\t\ttype: \"split-panel\",\n\t\t\torientation,\n\t\t\tchildren: [panel],\n\t\t\tsizes: [1],\n\t\t};\n\n\t\treturn insert_child(newPanel, child, path, orientation);\n\t}\n\n\tif (restPath.length === 0 || index === panel.children.length) {\n\t\t// Insert at this level at the specified index\n\t\tconst newChildren = [...panel.children];\n\t\tnewChildren.splice(index, 0, {\n\t\t\ttype: \"child-panel\",\n\t\t\tchild,\n\t\t});\n\n\t\tconst numChildren = newChildren.length;\n\t\tconst newSizes = Array(numChildren).fill(1 / numChildren);\n\t\treturn {\n\t\t\t...panel,\n\t\t\tchildren: newChildren,\n\t\t\tsizes: newSizes,\n\t\t};\n\t}\n\n\tconst targetChild = panel.children[index];\n\tif (targetChild.type === \"child-panel\" && restPath.length > 0) {\n\t\t// Need to split this child-panel\n\t\tconst oppositeOrientation =\n\t\t\tpanel.orientation === \"horizontal\" ? \"vertical\" : \"horizontal\";\n\n\t\tconst newSplitPanel = insert_child(\n\t\t\ttargetChild,\n\t\t\tchild,\n\t\t\trestPath,\n\t\t\toppositeOrientation,\n\t\t);\n\n\t\tconst newChildren = [...panel.children];\n\t\tnewChildren[index] = newSplitPanel;\n\t\treturn {\n\t\t\t...panel,\n\t\t\tchildren: newChildren,\n\t\t};\n\t}\n\n\tconst updatedChild = insert_child(targetChild, child, restPath, orientation);\n\tconst newChildren = [...panel.children];\n\tnewChildren[index] = updatedChild;\n\treturn {\n\t\t...panel,\n\t\tchildren: newChildren,\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport {\n\tMINIMUM_REDISTRIBUTION_SIZE_THRESHOLD,\n\ttype Layout,\n} from \"./layout_config.ts\";\n\n/**\n * Adjusts panel sizes during a drag operation on a divider.\n *\n * The `delta` is distributed proportionally among affected panels, maintaining\n * the sum:\n *\n * - Panels before and including the path index shrink by delta.\n * - Panels after the path index grow by delta.\n *\n * @param panel - The root layout tree to modify.\n * @param path - Path to the divider being dragged (identifies which split panel\n * to resize).\n * @param delta - Amount to resize, as a fraction (0-1). Positive values grow\n * panels before the divider, negative values shrink them.\n * @returns A new layout tree with updated sizes (original is not mutated).\n * ```\n */\nexport function redistribute_panel_sizes(\n\tpanel: Layout,\n\tpath: number[],\n\tdelta: number,\n): Layout {\n\t// Clone the entire panel structure\n\tconst result = structuredClone(panel);\n\n\t// Find the orientation of the insertion panel,\n\t// and scale the delta on the respective axis if aligned.\n\tlet current: Layout = result;\n\tconst deltas = { horizontal: delta, vertical: delta };\n\tfor (let i = 0; i < path.length - 1; i++) {\n\t\tif (current.type === \"split-panel\") {\n\t\t\tdeltas[current.orientation] /= current.sizes[path[i]];\n\t\t\tcurrent = current.children[path[i]];\n\t\t}\n\t}\n\n\t// Apply the redistribution at the final path index\n\tif (current.type === \"split-panel\") {\n\t\tconst delta = deltas[current.orientation];\n\t\tconst index = path[path.length - 1];\n\t\tcurrent.sizes = add_and_redistribute(current.sizes, index, delta);\n\t}\n\n\treturn result;\n}\n\nfunction add_and_redistribute(\n\tarr: number[],\n\tindex: number,\n\tdelta: number,\n): number[] {\n\tconst result = [...arr];\n\tlet before_total = 0;\n\tfor (let i = 0; i <= index; i++) {\n\t\tbefore_total += arr[i];\n\t}\n\n\tlet after_total = 0;\n\tfor (let i = index + 1; i < arr.length; i++) {\n\t\tafter_total += arr[i];\n\t}\n\n\t// Clamp `delta` to prevent redistributing either side to 0.\n\tdelta =\n\t\tMath.sign(delta) *\n\t\tMath.min(\n\t\t\tMath.abs(delta),\n\t\t\t(1 - MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD) *\n\t\t\t\t(delta > 0 ? before_total : after_total),\n\t\t);\n\n\t// Redistribute elements\n\tfor (let i = 0; i <= index; i++) {\n\t\tconst proportion = arr[i] / before_total;\n\t\tresult[i] = arr[i] - delta * proportion;\n\t}\n\n\tfor (let i = index + 1; i < arr.length; i++) {\n\t\tconst proportion = arr[i] / after_total;\n\t\tresult[i] = arr[i] + delta * proportion;\n\t}\n\n\treturn result;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { LayoutPath } from \"./layout_config\";\n\nexport function updateOverlaySheet({\n\tview_window: { row_start, row_end, col_start, col_end },\n\tbox,\n}: LayoutPath<DOMRect>) {\n\tconst margin = 0;\n\tconst top = row_start * box.height + margin / 2;\n\tconst left = col_start * box.width + margin / 2;\n\tconst height = (row_end - row_start) * box.height - margin;\n\tconst width = (col_end - col_start) * box.width - margin;\n\tconst css = `position:absolute!important;z-index:1;top:${top}px;left:${left}px;height:${height}px;width:${width}px;`;\n\treturn `::slotted(:not([slot])){${css}}`;\n}\n", "import { calculate_intersection } from \"./calculate_intersect\";\nimport { insert_child } from \"./insert_child\";\nimport {\n\tSPLIT_EDGE_TOLERANCE,\n\ttype Layout,\n\ttype LayoutPath,\n} from \"./layout_config\";\n\nexport function calculate_split(\n\tcol: number,\n\trow: number,\n\tpanel: Layout,\n\tslot: string,\n\tconfig: LayoutPath,\n): LayoutPath {\n\tif (\n\t\tconfig.column_offset < SPLIT_EDGE_TOLERANCE ||\n\t\tconfig.column_offset > 1 - SPLIT_EDGE_TOLERANCE\n\t) {\n\t\tif (config.orientation === \"vertical\") {\n\t\t\tconst new_panel = insert_child(panel, slot, [\n\t\t\t\t...config.path,\n\t\t\t\tconfig.column_offset < SPLIT_EDGE_TOLERANCE ? 0 : 1,\n\t\t\t]);\n\n\t\t\tconfig = calculate_intersection(col, row, new_panel, false);\n\t\t} else {\n\t\t\tconst new_panel = insert_child(panel, slot, config.path);\n\t\t\tconfig = calculate_intersection(col, row, new_panel, false);\n\t\t}\n\t}\n\n\tif (\n\t\t(config.row_offset < SPLIT_EDGE_TOLERANCE &&\n\t\t\tconfig.row_offset < config.column_offset) ||\n\t\t(config.row_offset > 1 - SPLIT_EDGE_TOLERANCE &&\n\t\t\tconfig.row_offset > config.column_offset)\n\t) {\n\t\tif (config.orientation === \"horizontal\") {\n\t\t\tconst new_panel = insert_child(panel, slot, [\n\t\t\t\t...config.path,\n\t\t\t\tconfig.row_offset < SPLIT_EDGE_TOLERANCE ? 0 : 1,\n\t\t\t]);\n\n\t\t\tconfig = calculate_intersection(col, row, new_panel, false);\n\t\t} else {\n\t\t\tconst new_panel = insert_child(panel, slot, config.path);\n\t\t\tconfig = calculate_intersection(col, row, new_panel, false);\n\t\t}\n\t}\n\n\treturn config;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout } from \"./layout_config.ts\";\n\n/**\n * Flattens the layout tree by merging parent and child split panels that have\n * the same orientation and type.\n *\n * When a split panel contains a child split panel with the same orientation,\n * they are merged into a single split panel. The sizes array is scaled\n * correctly to maintain proportions.\n *\n * @param layout - The layout tree to flatten\n * @returns A new flattened layout tree (original is not mutated).\n */\nexport function flatten(layout: Layout): Layout {\n\tif (layout.type === \"child-panel\") {\n\t\treturn layout;\n\t}\n\n\tconst flattenedChildren: Layout[] = [];\n\tconst flattenedSizes: number[] = [];\n\tfor (let i = 0; i < layout.children.length; i++) {\n\t\tconst child = layout.children[i];\n\t\tconst childSize = layout.sizes[i];\n\t\tconst flattenedChild = flatten(child);\n\n\t\tif (\n\t\t\tflattenedChild.type === \"split-panel\" &&\n\t\t\tflattenedChild.orientation === layout.orientation\n\t\t) {\n\t\t\tfor (let j = 0; j < flattenedChild.children.length; j++) {\n\t\t\t\tflattenedChildren.push(flattenedChild.children[j]);\n\t\t\t\tflattenedSizes.push(flattenedChild.sizes[j] * childSize);\n\t\t\t}\n\t\t} else {\n\t\t\tflattenedChildren.push(flattenedChild);\n\t\t\tflattenedSizes.push(childSize);\n\t\t}\n\t}\n\n\treturn {\n\t\ttype: \"split-panel\",\n\t\torientation: layout.orientation,\n\t\tchildren: flattenedChildren,\n\t\tsizes: flattenedSizes,\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * This module defines the `<regular-layout>` custom element for browser\n * environments.\n *\n * @packageDocumentation\n */\n\nimport { EMPTY_PANEL, iter_panel_children } from \"./common/layout_config.ts\";\nimport { create_css_grid_layout } from \"./common/generate_grid.ts\";\nimport type {\n\tLayoutPath,\n\tLayout,\n\tLayoutDivider,\n} from \"./common/layout_config.ts\";\nimport { calculate_intersection } from \"./common/calculate_intersect.ts\";\nimport { remove_child } from \"./common/remove_child.ts\";\nimport { insert_child } from \"./common/insert_child.ts\";\nimport { redistribute_panel_sizes } from \"./common/redistribute_panel_sizes.ts\";\nimport { updateOverlaySheet } from \"./common/generate_overlay.ts\";\nimport { calculate_split } from \"./common/calculate_split.ts\";\nimport { flatten } from \"./common/flatten.ts\";\n\nexport type OverlayMode = \"grid\" | \"absolute\" | \"interactive\";\n\nconst OVERLAY_DEFAULT: OverlayMode = \"absolute\";\n\n/**\n * A Web Component that provides a resizable panel layout system.\n * Panels are arranged using CSS Grid and can be resized by dragging dividers.\n *\n * The component uses Shadow DOM and CSS Grid to manage layout.\n *\n * @example\n * ```html\n * <regular-layout>\n * <div slot=\"sidebar\">Sidebar content</div>\n * <div slot=\"main\">Main content</div>\n * </regular-layout>\n * ```\n *\n * @example\n * ```typescript\n * const layout = document.querySelector('regular-layout');\n *\n * // Insert panels into the grid layout\n * layout.insertPanel('main');\n * layout.insertPanel('sidebar');\n *\n * // Remove a panel (DOM child is still connected, but not slotted)\n * layout.removePanel('sidebar');\n *\n * // Save current layout\n * const state = layout.save();\n *\n * // Restore layout later\n * layout.restore(state);\n * ```\n *\n */\nexport class RegularLayout extends HTMLElement {\n\tprivate _shadowRoot: ShadowRoot;\n\tprivate _panel: Layout;\n\tprivate _stylesheet: CSSStyleSheet;\n\tprivate _dragPath?: [LayoutDivider, number, number];\n\tprivate _slots: Map<string, HTMLSlotElement>;\n\tprivate _unslotted_slot: HTMLSlotElement;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis._panel = structuredClone(EMPTY_PANEL);\n\t\tthis._stylesheet = new CSSStyleSheet();\n\t\tthis._unslotted_slot = document.createElement(\"slot\");\n\t\tthis._shadowRoot = this.attachShadow({ mode: \"open\" });\n\t\tthis._shadowRoot.adoptedStyleSheets = [this._stylesheet];\n\t\tthis._shadowRoot.appendChild(this._unslotted_slot);\n\t\tthis._slots = new Map();\n\t\tthis.onPointerDown = this.onPointerDown.bind(this);\n\t\tthis.onPointerMove = this.onPointerMove.bind(this);\n\t\tthis.onPointerUp = this.onPointerUp.bind(this);\n\t}\n\n\tconnectedCallback() {\n\t\tthis.addEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis.addEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis.addEventListener(\"pointermove\", this.onPointerMove);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.removeEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis.removeEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis.removeEventListener(\"pointermove\", this.onPointerMove);\n\t}\n\n\t/**\n\t * Sets the visual overlay state during drag-and-drop operations.\n\t * Displays a preview of where a panel would be placed at the given coordinates.\n\t *\n\t * @param x - X coordinate in screen pixels.\n\t * @param y - Y coordinate in screen pixels.\n\t * @param layoutPath - Layout path containing the slot identifier.\n\t * @param mode - Overlay rendering mode: \"grid\" highlights the target,\n\t * \"absolute\" positions the panel absolutely, \"interactive\" updates the\n\t * actual layout in real-time. Defaults to \"absolute\".\n\t */\n\tsetOverlayState<T>(\n\t\tx: number,\n\t\ty: number,\n\t\t{ slot }: LayoutPath<T>,\n\t\tmode: \"grid\" | \"absolute\" | \"interactive\" = OVERLAY_DEFAULT,\n\t) {\n\t\tlet panel = this._panel;\n\t\tif (mode === \"absolute\") {\n\t\t\tpanel = remove_child(panel, slot);\n\t\t\tthis._slots.get(slot)?.assignedElements()[0]?.removeAttribute(\"slot\");\n\t\t}\n\n\t\tconst [col, row, box] = this.relativeCoordinates(x, y);\n\t\tlet drop_target = calculate_intersection(col, row, panel, false);\n\t\tif (drop_target) {\n\t\t\tdrop_target = calculate_split(col, row, panel, slot, drop_target);\n\t\t}\n\n\t\tif (drop_target) {\n\t\t\tif (mode === \"interactive\") {\n\t\t\t\tlet new_panel = remove_child(this._panel, slot);\n\t\t\t\tnew_panel = flatten(insert_child(new_panel, slot, drop_target.path));\n\t\t\t\tconst css = create_css_grid_layout(new_panel);\n\t\t\t\tthis._stylesheet.replaceSync(css);\n\t\t\t} else if (mode === \"grid\") {\n\t\t\t\tconst path: [string, string] = [slot, drop_target.slot];\n\t\t\t\tconst css = create_css_grid_layout(this._panel, false, path);\n\t\t\t\tthis._stylesheet.replaceSync(css);\n\t\t\t} else if (mode === \"absolute\") {\n\t\t\t\tconst css = `${create_css_grid_layout(panel)}\\n${updateOverlaySheet({ ...drop_target, box })}`;\n\t\t\t\tthis._stylesheet.replaceSync(css);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Clears the overlay state and commits the panel placement.\n\t *\n\t * @param x - X coordinate in screen pixels.\n\t * @param y - Y coordinate in screen pixels.\n\t * @param layout_path - Layout path containing the slot identifier.\n\t * @param mode - Overlay rendering mode that was used, must match the mode\n\t * passed to `setOverlayState`. Defaults to \"absolute\".\n\t */\n\tclearOverlayState<T>(\n\t\tx: number,\n\t\ty: number,\n\t\tdrag_target: LayoutPath<T>,\n\t\tmode: \"grid\" | \"absolute\" | \"interactive\" = OVERLAY_DEFAULT,\n\t) {\n\t\tlet panel = this._panel;\n\t\tif (mode === \"absolute\") {\n\t\t\tpanel = remove_child(panel, drag_target.slot);\n\t\t\tthis._unslotted_slot\n\t\t\t\t.assignedElements()[0]\n\t\t\t\t?.setAttribute(\"slot\", drag_target.slot);\n\t\t}\n\n\t\tconst [col, row, _] = this.relativeCoordinates(x, y);\n\t\tlet drop_target = calculate_intersection(col, row, panel, false);\n\t\tif (drop_target) {\n\t\t\t// TODO I think I only need the new path here?\n\t\t\tdrop_target = calculate_split(\n\t\t\t\tcol,\n\t\t\t\trow,\n\t\t\t\tpanel,\n\t\t\t\tdrag_target.slot,\n\t\t\t\tdrop_target,\n\t\t\t);\n\t\t}\n\n\t\tconst { path } = drop_target ? drop_target : drag_target;\n\t\tthis.removePanel(drag_target.slot);\n\t\tthis.insertPanel(drag_target.slot, path);\n\t}\n\n\t/**\n\t * Inserts a new panel into the layout at a specified path.\n\t *\n\t * @param name - Unique identifier for the new panel.\n\t * @param path - Index path defining where to insert.\n\t */\n\tinsertPanel(name: string, path: number[] = []) {\n\t\tthis.restore(insert_child(this._panel, name, path));\n\t}\n\n\t/**\n\t * Removes a panel from the layout by name.\n\t *\n\t * @param name - Name of the panel to remove\n\t */\n\tremovePanel(name: string) {\n\t\tthis.restore(remove_child(this._panel, name));\n\t}\n\n\t/**\n\t * Determines which panel is at a given screen coordinate.\n\t * Useful for drag-and-drop operations or custom interactions.\n\t *\n\t * @param column - X coordinate in screen pixels.\n\t * @param row - Y coordinate in screen pixels.\n\t * @returns Panel information if a panel is at that position, null otherwise.\n\t */\n\tcalculateIntersect(\n\t\tx: number,\n\t\ty: number,\n\t\tcheck_dividers: boolean = false,\n\t): LayoutPath<DOMRect> | null {\n\t\tconst [col, row, box] = this.relativeCoordinates(x, y);\n\t\tconst panel = calculate_intersection(col, row, this._panel, check_dividers);\n\t\tif (panel?.type === \"layout-path\") {\n\t\t\treturn { ...panel, box };\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Restores the layout from a saved state.\n\t *\n\t * @param layout - The layout tree to restore\n\t *\n\t * @example\n\t * ```typescript\n\t * const layout = document.querySelector('regular-layout');\n\t * const savedState = JSON.parse(localStorage.getItem('layout'));\n\t * layout.restore(savedState);\n\t * ```\n\t */\n\trestore(layout: Layout, _is_flattened: boolean = false) {\n\t\tthis._panel = !_is_flattened ? flatten(layout) : layout;\n\t\tconst css = create_css_grid_layout(layout);\n\t\tthis._stylesheet.replaceSync(css);\n\t\tconst old = new Set(this._slots.keys());\n\t\tfor (const name of iter_panel_children(layout)) {\n\t\t\told.delete(name);\n\t\t\tif (!this._slots.has(name)) {\n\t\t\t\tconst slot = document.createElement(\"slot\");\n\t\t\t\tslot.setAttribute(\"name\", name);\n\t\t\t\tthis._shadowRoot.appendChild(slot);\n\t\t\t\tthis._slots.set(name, slot);\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of old) {\n\t\t\tconst child = this._slots.get(key);\n\t\t\tif (child) {\n\t\t\t\tthis._shadowRoot.removeChild(child);\n\t\t\t\tthis._slots.delete(key);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Serializes the current layout state, which can be restored via `restore`.\n\t *\n\t * @returns The current layout tree\n\t *\n\t * @example\n\t * ```typescript\n\t * const layout = document.querySelector('regular-layout');\n\t * const state = layout.save();\n\t * localStorage.setItem('layout', JSON.stringify(state));\n\t * ```\n\t */\n\tsave(): Layout {\n\t\treturn structuredClone(this._panel);\n\t}\n\n\tprivate relativeCoordinates(\n\t\tclientX: number,\n\t\tclientY: number,\n\t): [number, number, DOMRect] {\n\t\tconst box = this.getBoundingClientRect();\n\t\tconst col = (clientX - box.left) / (box.right - box.left);\n\t\tconst row = (clientY - box.top) / (box.bottom - box.top);\n\t\treturn [col, row, box];\n\t}\n\n\tprivate onPointerDown(event: PointerEvent) {\n\t\tconst [col, row] = this.relativeCoordinates(event.clientX, event.clientY);\n\t\tconst hit = calculate_intersection(col, row, this._panel);\n\t\tif (hit && hit.type !== \"layout-path\") {\n\t\t\tthis._dragPath = [hit, col, row];\n\t\t\tthis.setPointerCapture(event.pointerId);\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopImmediatePropagation();\n\t\t}\n\t}\n\n\tprivate onPointerMove(event: PointerEvent) {\n\t\tif (this._dragPath) {\n\t\t\tconst [col, row] = this.relativeCoordinates(event.clientX, event.clientY);\n\t\t\tconst old_panel = this._panel;\n\t\t\tconst [{ path, type }, old_col, old_row] = this._dragPath;\n\t\t\tconst offset = type === \"horizontal\" ? old_col - col : old_row - row;\n\t\t\tconst panel = redistribute_panel_sizes(old_panel, path, offset);\n\t\t\tthis._stylesheet.replaceSync(create_css_grid_layout(panel));\n\t\t}\n\t}\n\n\tprivate onPointerUp(event: PointerEvent) {\n\t\tif (this._dragPath) {\n\t\t\tthis.releasePointerCapture(event.pointerId);\n\t\t\tconst [col, row] = this.relativeCoordinates(event.clientX, event.clientY);\n\t\t\tconst old_panel = this._panel;\n\t\t\tconst [{ path }, old_col, old_row] = this._dragPath;\n\t\t\tif (this._dragPath[0].type === \"horizontal\") {\n\t\t\t\tconst panel = redistribute_panel_sizes(old_panel, path, old_col - col);\n\t\t\t\tthis.restore(panel, true);\n\t\t\t} else {\n\t\t\t\tconst panel = redistribute_panel_sizes(old_panel, path, old_row - row);\n\t\t\t\tthis.restore(panel, true);\n\t\t\t}\n\n\t\t\tthis._dragPath = undefined;\n\t\t}\n\t}\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { LayoutPath } from \"./common/layout_config.ts\";\nimport type { RegularLayout } from \"./regular-layout.ts\";\n\nconst CSS = `\n:host{--titlebar--height:24px;box-sizing:border-box}\n:host([slot]){margin-top:calc(var(--titlebar--height) + 3px)!important;}\n:host([slot])::part(container){position:absolute;top:0;left:0;right:0;bottom:0;display:flex;flex-direction:column;background-color:inherit;border-radius:inherit}\n:host([slot])::part(titlebar){height:var(--titlebar--height);margin-top:calc(-2px - var(--titlebar--height));user-select: none;}\n:host([slot])::part(body){flex:1 1 auto;}\n`;\n\n/**\n * A custom element that represents a draggable panel within a\n * `<regular-layout>`.\n *\n * `<regular-layout-frame>` is optional - you may also use a `<regular-layout>`\n * with just plain `<div>` children (for example), but panels will not be\n * moveable within the layout unless you manually call `setOverlayState` and\n * `clearOverlayState` (or otherwise impement panel moving via the\n * `<regular-layout>` API).\n *\n * `<regular-layout-frame>` simple and highly customizable implementations\n * based on [CSS `part`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/::part)\n * for custom styling, and symmetric\n * [named `slot`s](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_templates_and_slots)\n * for wholesale replacement of the underlying Shadow DOM.\n *\n * @example\n * ```html\n * <regular-layout>\n * <regular-layout-frame slot=\"panel-1\">\n * <!-- Panel content here -->\n * </regular-layout-frame>\n * </regular-layout>\n * ```\n */\nexport class RegularLayoutFrame extends HTMLElement {\n\tprivate _shadowRoot: ShadowRoot;\n\tprivate _container_sheet: CSSStyleSheet;\n\tprivate _layout!: RegularLayout;\n\tprivate _header!: HTMLElement;\n\tprivate _drag_state: LayoutPath<DOMRect> | null = null;\n\tconstructor() {\n\t\tsuper();\n\t\tthis._container_sheet = new CSSStyleSheet();\n\t\tthis._container_sheet.replaceSync(CSS);\n\t\tthis._shadowRoot = this.attachShadow({ mode: \"open\" });\n\t\tthis._shadowRoot.adoptedStyleSheets = [this._container_sheet];\n\t\tthis._shadowRoot.innerHTML = `<slot part=\"container\"><slot part=\"titlebar\">header</slot><slot part=\"body\"><slot></slot></slot></slot>`;\n\t\tthis._layout = this.parentElement as RegularLayout;\n\t\tthis._header = this._shadowRoot.children[0].children[0] as HTMLElement;\n\t}\n\n\tconnectedCallback() {\n\t\tthis._header.addEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis._header.addEventListener(\"pointermove\", this.onPointerMove);\n\t\tthis._header.addEventListener(\"pointerup\", this.onPointerUp);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis._header.removeEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis._header.removeEventListener(\"pointermove\", this.onPointerMove);\n\t\tthis._header.removeEventListener(\"pointerup\", this.onPointerUp);\n\t}\n\n\tprivate onPointerDown = (event: PointerEvent): void => {\n\t\tthis._drag_state = this._layout.calculateIntersect(\n\t\t\tevent.clientX,\n\t\t\tevent.clientY,\n\t\t);\n\n\t\tif (!this._drag_state) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._header.setPointerCapture(event.pointerId);\n\t\tevent.preventDefault();\n\t\tevent.stopImmediatePropagation();\n\t};\n\n\tprivate onPointerMove = (event: PointerEvent): void => {\n\t\tif (this._drag_state) {\n\t\t\tthis._layout.setOverlayState(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tthis._drag_state,\n\t\t\t);\n\t\t}\n\t};\n\n\tprivate onPointerUp = (event: PointerEvent): void => {\n\t\tif (this._drag_state) {\n\t\t\tthis._layout.clearOverlayState(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tthis._drag_state,\n\t\t\t);\n\n\t\t\tthis._header.releasePointerCapture(event.pointerId);\n\t\t\tthis._drag_state = null;\n\t\t}\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { RegularLayout } from \"./regular-layout.ts\";\nimport { RegularLayoutFrame } from \"./regular-layout-frame.ts\";\n\ncustomElements.define(\"regular-layout-frame\", RegularLayoutFrame);\n\ncustomElements.define(\"regular-layout\", RegularLayout);\n\ndeclare global {\n\tinterface Document {\n\t\tcreateElement(\n\t\t\ttagName: \"regular-layout\",\n\t\t\toptions?: ElementCreationOptions,\n\t\t): RegularLayout;\n\n\t\tcreateElement(\n\t\t\ttagName: \"regular-layout-frame\",\n\t\t\toptions?: ElementCreationOptions,\n\t\t): RegularLayoutFrame;\n\n\t\tquerySelector<E extends Element = Element>(selectors: string): E | null;\n\t\tquerySelector(selectors: \"regular-layout\"): RegularLayout | null;\n\t\tquerySelector(selectors: \"regular-layout-frame\"): RegularLayoutFrame | null;\n\t}\n\n\tinterface CustomElementRegistry {\n\t\tget(tagName: \"regular-lay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AA8B,CAChD,KAAK,cACR,KAAK,QAAQ,kBACZA,EAAM,QACNA,EAAM,QACN,KAAK,WACN,EAEA,KAAK,QAAQ,sBAAsBA,EAAM,SAAS,EAClD,KAAK,YAAc,KAErB,CACD,ECnGA,eAAe,OAAO,uBAAwBC,CAAkB,EAEhE,eAAe,OAAO,iBAAkBC,CAAa",
6
- "names": ["iter_panel_children", "panel", "child", "EMPTY_PANEL", "remove_child", "panel", "child", "EMPTY_PANEL", "result", "index", "p", "newChildren", "_", "i", "newSizes", "remove_and_redistribute", "modified", "updated", "arr", "removed_size", "remaining_total", "proportion", "dedupePositions", "positions", "sorted", "a", "b", "result", "i", "collectTrackPositions", "panel", "orientation", "start", "end", "current", "size", "childPositions", "allPositions", "child", "findTrackIndex", "value", "buildCells", "colPositions", "rowPositions", "colStart", "colEnd", "rowStart", "rowEnd", "cells", "children", "sizes", "next", "host_template", "rowTemplate", "colTemplate", "child_template", "slot", "rowPart", "colPart", "create_css_grid_layout", "layout", "round", "overlay", "remove_child", "colSizes", "s", "rowSizes", "css", "cell", "calculate_intersection", "column", "row", "layout", "check_dividers", "calculate_intersection_recursive", "VIEW_WINDOW", "panel", "parent_orientation", "view_window", "path", "current_row", "i", "next_row", "current_col", "total_size", "next_col", "insert_child", "panel", "child", "path", "orientation", "newChildren", "numChildren", "newSizes", "index", "restPath", "targetChild", "oppositeOrientation", "newSplitPanel", "updatedChild", "redistribute_panel_sizes", "panel", "path", "delta", "result", "current", "deltas", "index", "add_and_redistribute", "arr", "before_total", "after_total", "proportion", "updateOverlaySheet", "row_start", "row_end", "col_start", "col_end", "box", "top", "left", "height", "width", "calculate_split", "col", "row", "panel", "slot", "config", "new_panel", "insert_child", "calculate_intersection", "flatten", "layout", "flattenedChildren", "flattenedSizes", "i", "child", "childSize", "flattenedChild", "j", "OVERLAY_DEFAULT", "RegularLayout", "EMPTY_PANEL", "x", "y", "slot", "mode", "panel", "remove_child", "col", "row", "box", "drop_target", "calculate_intersection", "calculate_split", "new_panel", "flatten", "insert_child", "css", "create_css_grid_layout", "path", "updateOverlaySheet", "drag_target", "_", "name", "check_dividers", "layout", "_is_flattened", "old", "iter_panel_children", "key", "child", "clientX", "clientY", "event", "hit", "old_panel", "type", "old_col", "old_row", "offset", "redistribute_panel_sizes", "CSS", "RegularLayoutFrame", "event", "RegularLayoutFrame", "RegularLayout"]
4
+ "sourcesContent": ["// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * The percentage of the maximum resize distance that will be clamped.\n *\n */\nexport const MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD = 0.15;\n\n/**\n * Threshold from panel edge that is considered a split vs drop action.\n */\nexport const SPLIT_EDGE_TOLERANCE = 0.25;\n\n/**\n * Tolerance threshold for considering two grid track positions as identical.\n *\n * When collecting and deduplicating track positions, any positions closer than\n * this value are treated as the same position to avoid redundant grid tracks.\n */\nexport const GRID_TRACK_COLLAPSE_TOLERANCE = 0.001;\n\n/**\n * The overlay default behavior.\n */\nexport const OVERLAY_DEFAULT: OverlayMode = \"absolute\";\n\n/**\n * The overlay behavior type.\n */\nexport type OverlayMode = \"grid\" | \"absolute\" | \"interactive\";\n\n/**\n * The representation of a CSS grid, in JSON form.\n */\nexport type Layout = SplitLayout | TabLayout;\n\n/**\n * The orientation (of a `SplitPanel`).\n */\nexport type Orientation = \"horizontal\" | \"vertical\";\n\n/**\n * A logical rectange in percent-coordinates (of a (1, 1) square).\n */\nexport interface ViewWindow {\n\trow_start: number;\n\trow_end: number;\n\tcol_start: number;\n\tcol_end: number;\n}\n\n/**\n * A split panel that divides space among multiple child layouts\n * .\n * Child panels are arranged either horizontally (side by side) or vertically\n * (stacked), via the `orientation` property `\"horizzontal\"` and `\"vertical\"`\n * (respectively).\n */\nexport interface SplitLayout {\n\ttype: \"split-panel\";\n\tchildren: Layout[];\n\tsizes: number[];\n\torientation: Orientation;\n}\n\n/**\n * A leaf panel node that contains a single named child element.\n */\nexport interface TabLayout {\n\ttype: \"child-panel\";\n\tchild: string[];\n\tselected?: number;\n}\n\n/**\n * Represents a draggable divider between two panels in the layout.\n *\n * Used for hit detection.\n */\nexport interface LayoutDivider {\n\tpath: number[];\n\tview_window: ViewWindow;\n\ttype: Orientation;\n}\n\n/**\n * Represents a panel location result from hit detection.\n *\n * Contains both the panel identifier and its grid position in relative units.\n * The generic parameter `T` allows DOM-only properties (e.g. `DOMRect`) to be\n * shared in this cross-platform module.\n */\nexport interface LayoutPath<T = undefined> {\n\ttype: \"layout-path\";\n\tslot: string;\n\tpanel: TabLayout;\n\tpath: number[];\n\tview_window: ViewWindow;\n\tcolumn_offset: number;\n\trow_offset: number;\n\torientation: Orientation;\n\tis_edge: boolean;\n\tbox: T;\n}\n\n/**\n * Recursively iterates over all child panel names in the layout tree, yielding\n * panel names in depth-first order.\n *\n * @param panel - The layout tree to iterate over\n * @returns Generator yielding child panel names\n */\nexport function* iter_panel_children(panel: Layout): Generator<string> {\n\tif (panel.type === \"split-panel\") {\n\t\tfor (const child of panel.children) {\n\t\t\tyield* iter_panel_children(child);\n\t\t}\n\t} else {\n\t\tyield* panel.child;\n\t}\n}\n\n/**\n * An empty `Layout` with no panels.\n */\nexport const EMPTY_PANEL: Layout = {\n\ttype: \"split-panel\",\n\torientation: \"horizontal\",\n\tsizes: [],\n\tchildren: [],\n};\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout, TabLayout } from \"./layout_config.ts\";\nimport { EMPTY_PANEL } from \"./layout_config.ts\";\n\n/**\n * Removes a child panel from the layout tree by its name.\n *\n * Redistributes the removed panel's space proportionally among remaining\n * siblings. Automatically collapses split panels when only one child remains.\n *\n * @param panel - The root layout tree to remove from.\n * @param child - Name of the child panel to remove.\n * @returns A new layout tree with the child removed (original is not mutated).\n * Returns `EMPTY_PANEL` if the last panel is removed.\n */\nexport function remove_child(panel: Layout, child: string): Layout {\n\t// If this is a child panel, handle tab removal\n\tif (panel.type === \"child-panel\") {\n\t\tif (panel.child.includes(child)) {\n\t\t\tconst newChild = panel.child.filter((c) => c !== child);\n\t\t\tif (newChild.length === 0) {\n\t\t\t\treturn structuredClone(EMPTY_PANEL);\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttype: \"child-panel\",\n\t\t\t\tchild: newChild,\n\t\t\t};\n\t\t}\n\t\treturn structuredClone(panel);\n\t}\n\n\t// Clone the panel structure\n\tconst result = structuredClone(panel);\n\n\t// Try to remove the child from this split panel's children\n\tconst index = result.children.findIndex((p) => {\n\t\tif (p.type === \"child-panel\") {\n\t\t\treturn p.child.includes(child);\n\t\t}\n\n\t\treturn false;\n\t});\n\n\tif (index !== -1) {\n\t\tconst tab_layout = result.children[index] as TabLayout;\n\t\tif (tab_layout.child.length === 1) {\n\t\t\t// Found the child at this level - remove it\n\t\t\tconst newChildren = result.children.filter((_, i) => i !== index);\n\t\t\tconst newSizes = remove_and_redistribute(result.sizes, index);\n\n\t\t\t// If only one child remains, collapse the split panel\n\t\t\tif (newChildren.length === 1) {\n\t\t\t\treturn newChildren[0];\n\t\t\t}\n\n\t\t\tresult.children = newChildren;\n\t\t\tresult.sizes = newSizes;\n\t\t} else {\n\t\t\ttab_layout.child.splice(tab_layout.child.indexOf(child), 1);\n\t\t\tif (\n\t\t\t\ttab_layout.selected &&\n\t\t\t\ttab_layout.selected >= tab_layout.child.length\n\t\t\t) {\n\t\t\t\ttab_layout.selected--;\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}\n\n\t// Child not found at this level - recursively search children\n\tlet modified = false;\n\tconst newChildren = result.children.map((p) => {\n\t\tif (p.type === \"split-panel\") {\n\t\t\tconst updated = remove_child(p, child);\n\t\t\tif (updated !== p) {\n\t\t\t\tmodified = true;\n\t\t\t}\n\n\t\t\treturn updated;\n\t\t}\n\n\t\treturn p;\n\t});\n\n\tif (modified) {\n\t\tresult.children = newChildren;\n\t}\n\n\treturn result;\n}\n\nfunction remove_and_redistribute(arr: number[], index: number): number[] {\n\tconst result = [];\n\n\t// Get the size of the element being removed\n\tconst removed_size = arr[index];\n\n\t// Calculate the total of remaining elements\n\tlet remaining_total = 0;\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (i !== index) {\n\t\t\tremaining_total += arr[i];\n\t\t}\n\t}\n\n\t// Distribute the removed size proportionally to remaining elements\n\tfor (let i = 0; i < arr.length; i++) {\n\t\tif (i !== index) {\n\t\t\tconst proportion = arr[i] / remaining_total;\n\t\t\tresult.push(arr[i] + removed_size * proportion);\n\t\t}\n\t}\n\n\treturn result;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { GRID_TRACK_COLLAPSE_TOLERANCE, type Layout } from \"./layout_config.ts\";\nimport { remove_child } from \"./remove_child.ts\";\n\ninterface GridCell {\n\tchild: string;\n\tcolStart: number;\n\tcolEnd: number;\n\trowStart: number;\n\trowEnd: number;\n}\n\nfunction dedupePositions(positions: number[]): number[] {\n\tif (positions.length === 0) {\n\t\treturn [];\n\t}\n\n\tconst sorted = positions.sort((a, b) => a - b);\n\tconst result = [sorted[0]];\n\tfor (let i = 1; i < sorted.length; i++) {\n\t\tif (\n\t\t\tMath.abs(sorted[i] - result[result.length - 1]) >\n\t\t\tGRID_TRACK_COLLAPSE_TOLERANCE\n\t\t) {\n\t\t\tresult.push(sorted[i]);\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction collectTrackPositions(\n\tpanel: Layout,\n\torientation: \"horizontal\" | \"vertical\",\n\tstart: number,\n\tend: number,\n): number[] {\n\tif (panel.type === \"child-panel\") {\n\t\treturn [start, end];\n\t}\n\n\tif (panel.orientation === orientation) {\n\t\tconst positions: number[] = [start, end];\n\t\tlet current = start;\n\t\tfor (let i = 0; i < panel.children.length; i++) {\n\t\t\tconst size = panel.sizes[i];\n\t\t\tconst childPositions = collectTrackPositions(\n\t\t\t\tpanel.children[i],\n\t\t\t\torientation,\n\t\t\t\tcurrent,\n\t\t\t\tcurrent + size * (end - start),\n\t\t\t);\n\n\t\t\tpositions.push(...childPositions);\n\t\t\tcurrent = current + size * (end - start);\n\t\t}\n\n\t\treturn dedupePositions(positions);\n\t} else {\n\t\tconst allPositions: number[] = [start, end];\n\t\tfor (const child of panel.children) {\n\t\t\tconst childPositions = collectTrackPositions(\n\t\t\t\tchild,\n\t\t\t\torientation,\n\t\t\t\tstart,\n\t\t\t\tend,\n\t\t\t);\n\n\t\t\tallPositions.push(...childPositions);\n\t\t}\n\n\t\treturn dedupePositions(allPositions);\n\t}\n}\n\nfunction findTrackIndex(positions: number[], value: number): number {\n\tfor (let i = 0; i < positions.length; i++) {\n\t\tif (Math.abs(positions[i] - value) < GRID_TRACK_COLLAPSE_TOLERANCE) {\n\t\t\treturn i;\n\t\t}\n\t}\n\n\tthrow new Error(`Position ${value} not found in ${positions}`);\n}\n\nfunction buildCells(\n\tpanel: Layout,\n\tcolPositions: number[],\n\trowPositions: number[],\n\tcolStart: number,\n\tcolEnd: number,\n\trowStart: number,\n\trowEnd: number,\n): GridCell[] {\n\tif (panel.type === \"child-panel\") {\n\t\tconst selected = panel.selected ?? 0;\n\t\treturn [\n\t\t\t{\n\t\t\t\tchild: panel.child[selected],\n\t\t\t\tcolStart: findTrackIndex(colPositions, colStart),\n\t\t\t\tcolEnd: findTrackIndex(colPositions, colEnd),\n\t\t\t\trowStart: findTrackIndex(rowPositions, rowStart),\n\t\t\t\trowEnd: findTrackIndex(rowPositions, rowEnd),\n\t\t\t},\n\t\t];\n\t}\n\n\tconst cells: GridCell[] = [];\n\tconst { children, sizes, orientation } = panel;\n\tif (orientation === \"horizontal\") {\n\t\tlet current = colStart;\n\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\tconst next = current + sizes[i] * (colEnd - colStart);\n\t\t\tcells.push(\n\t\t\t\t...buildCells(\n\t\t\t\t\tchildren[i],\n\t\t\t\t\tcolPositions,\n\t\t\t\t\trowPositions,\n\t\t\t\t\tcurrent,\n\t\t\t\t\tnext,\n\t\t\t\t\trowStart,\n\t\t\t\t\trowEnd,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tcurrent = next;\n\t\t}\n\t} else {\n\t\tlet current = rowStart;\n\t\tfor (let i = 0; i < children.length; i++) {\n\t\t\tconst next = current + sizes[i] * (rowEnd - rowStart);\n\t\t\tcells.push(\n\t\t\t\t...buildCells(\n\t\t\t\t\tchildren[i],\n\t\t\t\t\tcolPositions,\n\t\t\t\t\trowPositions,\n\t\t\t\t\tcolStart,\n\t\t\t\t\tcolEnd,\n\t\t\t\t\tcurrent,\n\t\t\t\t\tnext,\n\t\t\t\t),\n\t\t\t);\n\n\t\t\tcurrent = next;\n\t\t}\n\t}\n\n\treturn cells;\n}\n\nconst host_template = (rowTemplate: string, colTemplate: string) =>\n\t`:host { display: grid; gap: 0px; grid-template-rows: ${rowTemplate}; grid-template-columns: ${colTemplate}; }`;\n\nconst child_template = (slot: string, rowPart: string, colPart: string) =>\n\t`:host ::slotted([slot=${slot}]) { grid-column: ${colPart}; grid-row: ${rowPart}; }`;\n\n/**\n * Generates CSS Grid styles to render a layout tree.\n * Creates grid-template-rows, grid-template-columns, and positioning rules for\n * all child panels.\n *\n * @param layout - The layout tree to convert to CSS\n * @param round - If true, rounds percentages to whole numbers. Useful for\n * avoiding sub-pixel rendering issues. Defaults to false.\n * @returns CSS string containing :host and ::slotted rules implementing the\n * layout.\n *\n * @example\n * ```typescript\n * const layout = {\n * type: \"split-panel\",\n * orientation: \"horizontal\",\n * children: [\n * { type: \"child-panel\", child: \"sidebar\" },\n * { type: \"child-panel\", child: \"main\" }\n * ],\n * sizes: [0.25, 0.75]\n * };\n *\n * const css = create_css_grid_layout(layout);\n * // Returns CSS like:\n * // :host { display: grid; grid-template-columns: 25% 75%; ... }\n * // :host ::slotted([slot=sidebar]) { grid-column: 1; grid-row: 1; }\n * // :host ::slotted([slot=main]) { grid-column: 2; grid-row: 1; }\n * ```\n */\nexport function create_css_grid_layout(\n\tlayout: Layout,\n\tround: boolean = false,\n\toverlay?: [string, string],\n): string {\n\tif (overlay) {\n\t\tlayout = remove_child(layout, overlay[0]);\n\t}\n\n\tif (layout.type === \"child-panel\") {\n\t\tconst selected = layout.selected ?? 0;\n\t\treturn `${host_template(\"100%\", \"100%\")}\\n${child_template(layout.child[selected], \"1\", \"1\")}`;\n\t}\n\n\tconst colPositions = collectTrackPositions(layout, \"horizontal\", 0, 1);\n\tconst colSizes: number[] = [];\n\tfor (let i = 0; i < colPositions.length - 1; i++) {\n\t\tcolSizes.push(colPositions[i + 1] - colPositions[i]);\n\t}\n\n\tconst colTemplate = colSizes\n\t\t.map((s) => `${round ? Math.round(s * 100) : s * 100}%`)\n\t\t.join(\" \");\n\n\tconst rowPositions = collectTrackPositions(layout, \"vertical\", 0, 1);\n\tconst rowSizes: number[] = [];\n\tfor (let i = 0; i < rowPositions.length - 1; i++) {\n\t\trowSizes.push(rowPositions[i + 1] - rowPositions[i]);\n\t}\n\n\tconst rowTemplate = rowSizes\n\t\t.map((s) => `${round ? Math.round(s * 100) : s * 100}%`)\n\t\t.join(\" \");\n\n\tconst cells = buildCells(layout, colPositions, rowPositions, 0, 1, 0, 1);\n\tconst css = [host_template(rowTemplate, colTemplate)];\n\tfor (const cell of cells) {\n\t\tconst colPart =\n\t\t\tcell.colEnd - cell.colStart === 1\n\t\t\t\t? `${cell.colStart + 1}`\n\t\t\t\t: `${cell.colStart + 1} / ${cell.colEnd + 1}`;\n\t\tconst rowPart =\n\t\t\tcell.rowEnd - cell.rowStart === 1\n\t\t\t\t? `${cell.rowStart + 1}`\n\t\t\t\t: `${cell.rowStart + 1} / ${cell.rowEnd + 1}`;\n\n\t\tcss.push(`${child_template(cell.child, rowPart, colPart)}`);\n\t\tif (cell.child === overlay?.[1]) {\n\t\t\tcss.push(`${child_template(overlay[0], rowPart, colPart)}`);\n\t\t\tcss.push(`:host ::slotted([slot=${overlay[0]}]) { z-index: 1; }`);\n\t\t}\n\t}\n\n\treturn css.join(\"\\n\");\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type {\n\tLayoutPath,\n\tLayoutDivider,\n\tLayout,\n\tViewWindow,\n} from \"./layout_config.ts\";\n\n/**\n * Determines which panel or divider is located at a given position in the\n * layout.\n *\n * @param row - Vertical position as a fraction (0-1) of the container\n * height\n * @param column - Horizontal position as a fraction (0-1) of the\n * container width\n * @param layout - The layout tree to search\n * @param check_dividers - Whether `LayoutDivider` intersection should be\n * checked, which oyu may not want for e.g. `drop` actions.\n * @returns The panel path if over a panel, a divider if over a resizable\n * boundary, or null if outside all panels\n */\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers: false,\n): LayoutPath;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers: true,\n): LayoutPath | null | LayoutDivider;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers?: boolean,\n): LayoutPath | null | LayoutDivider;\n\nexport function calculate_intersection(\n\tcolumn: number,\n\trow: number,\n\tlayout: Layout,\n\tcheck_dividers: boolean = true,\n): LayoutPath | null | LayoutDivider {\n\treturn calculate_intersection_recursive(column, row, layout, check_dividers);\n}\n\nconst VIEW_WINDOW = {\n\trow_start: 0,\n\trow_end: 1,\n\tcol_start: 0,\n\tcol_end: 1,\n};\n\nfunction calculate_intersection_recursive(\n\tcolumn: number,\n\trow: number,\n\tpanel: Layout,\n\tcheck_dividers: boolean,\n\tparent_orientation: \"horizontal\" | \"vertical\" | null = null,\n\tview_window: ViewWindow = structuredClone(VIEW_WINDOW),\n\tpath: number[] = [],\n): LayoutPath | null | LayoutDivider {\n\tif (column < 0 || row < 0 || column > 1 || row > 1) {\n\t\treturn null;\n\t}\n\n\t// Base case: if this is a child panel, return its name\n\tif (panel.type === \"child-panel\") {\n\t\tconst selected = panel.selected ?? 0;\n\t\tconst column_offset =\n\t\t\t(column - view_window.col_start) /\n\t\t\t(view_window.col_end - view_window.col_start);\n\t\tconst row_offset =\n\t\t\t(row - view_window.row_start) /\n\t\t\t(view_window.row_end - view_window.row_start);\n\n\t\treturn {\n\t\t\ttype: \"layout-path\",\n\t\t\tbox: undefined,\n\t\t\tslot: panel.child[selected],\n\t\t\tpanel: structuredClone(panel),\n\t\t\tpath: path,\n\t\t\tview_window: view_window,\n\t\t\tis_edge: false,\n\t\t\tcolumn_offset,\n\t\t\trow_offset,\n\t\t\torientation: parent_orientation || \"horizontal\",\n\t\t};\n\t}\n\n\t// For split panels, determine which child was hit\n\tif (panel.orientation === \"vertical\") {\n\t\t// Vertical orientation = rows\n\t\tlet current_row = view_window.row_start;\n\t\tfor (let i = 0; i < panel.children.length; i++) {\n\t\t\tconst total_size = view_window.row_end - view_window.row_start;\n\t\t\tconst next_row = total_size * panel.sizes[i] + current_row;\n\t\t\tif (check_dividers && Math.abs(row - next_row) < 0.01) {\n\t\t\t\treturn {\n\t\t\t\t\tpath: [...path, i],\n\t\t\t\t\ttype: \"vertical\",\n\t\t\t\t\tview_window: {\n\t\t\t\t\t\t...view_window,\n\t\t\t\t\t\trow_start: current_row,\n\t\t\t\t\t\trow_end: next_row,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif (row >= current_row && row < next_row) {\n\t\t\t\treturn calculate_intersection_recursive(\n\t\t\t\t\tcolumn,\n\t\t\t\t\trow,\n\t\t\t\t\tpanel.children[i],\n\t\t\t\t\tcheck_dividers,\n\t\t\t\t\t\"vertical\",\n\t\t\t\t\t{\n\t\t\t\t\t\t...view_window,\n\t\t\t\t\t\trow_start: current_row,\n\t\t\t\t\t\trow_end: next_row,\n\t\t\t\t\t},\n\t\t\t\t\t[...path, i],\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tcurrent_row = next_row;\n\t\t}\n\t} else {\n\t\t// Horizontal orientation = columns\n\t\tlet current_col = view_window.col_start;\n\t\tfor (let i = 0; i < panel.children.length; i++) {\n\t\t\tconst total_size = view_window.col_end - view_window.col_start;\n\t\t\tconst next_col = current_col + total_size * panel.sizes[i];\n\t\t\tif (check_dividers && Math.abs(column - next_col) < 0.01) {\n\t\t\t\treturn {\n\t\t\t\t\tpath: [...path, i],\n\t\t\t\t\ttype: \"horizontal\",\n\t\t\t\t\tview_window: {\n\t\t\t\t\t\t...view_window,\n\t\t\t\t\t\tcol_start: current_col,\n\t\t\t\t\t\tcol_end: next_col,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Check if the column falls within this child's bounds.\n\t\t\tif (column >= current_col && column < next_col) {\n\t\t\t\treturn calculate_intersection_recursive(\n\t\t\t\t\tcolumn,\n\t\t\t\t\trow,\n\t\t\t\t\tpanel.children[i],\n\t\t\t\t\tcheck_dividers,\n\t\t\t\t\t\"horizontal\",\n\t\t\t\t\t{\n\t\t\t\t\t\t...view_window,\n\t\t\t\t\t\tcol_start: current_col,\n\t\t\t\t\t\tcol_end: next_col,\n\t\t\t\t\t},\n\t\t\t\t\t[...path, i],\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tcurrent_col = next_col;\n\t\t}\n\t}\n\n\t// If we get here, the hit was outside all children (possibly in a gap or\n\t// boundary).\n\treturn null;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout } from \"./layout_config.ts\";\n\n/**\n * Inserts a new child panel into the layout tree at a specified location.\n * Creates a split panel if necessary and redistributes sizes equally among all\n * children.\n *\n * @param panel - The root layout tree to insert into\n * @param child - Unique identifier for the new child panel\n * @param path - Array of indices defining where to insert. Empty array inserts\n * at root level.\n * @param orientation - Orientation for newly created split panels. Defaults to\n * \"horizontal\".\n * @returns A new layout tree with the child inserted (original is not mutated).\n */\nexport function insert_child(\n\tpanel: Layout,\n\tchild: string,\n\tpath: number[],\n\torientation: \"horizontal\" | \"vertical\" = \"horizontal\",\n\tis_edge?: boolean,\n): Layout {\n\tif (path.length === 0) {\n\t\t// Insert at root level\n\t\tif (panel.type === \"child-panel\") {\n\t\t\t// Add to existing child-panel as a tab\n\t\t\treturn {\n\t\t\t\ttype: \"child-panel\",\n\t\t\t\tchild: [child, ...panel.child],\n\t\t\t};\n\t\t} else {\n\t\t\t// Append to existing split-panel\n\t\t\tconst newChildren = [\n\t\t\t\t...panel.children,\n\t\t\t\t{\n\t\t\t\t\ttype: \"child-panel\",\n\t\t\t\t\tchild: [child],\n\t\t\t\t} as Layout,\n\t\t\t];\n\n\t\t\tconst numChildren = newChildren.length;\n\t\t\tconst newSizes = Array(numChildren).fill(1 / numChildren);\n\t\t\treturn {\n\t\t\t\t...panel,\n\t\t\t\tchildren: newChildren,\n\t\t\t\tsizes: newSizes,\n\t\t\t};\n\t\t}\n\t}\n\n\t// Navigate down the path\n\tconst [index, ...restPath] = path;\n\tif (panel.type === \"child-panel\") {\n\t\t// This shouldn't happen if path.length > 0, but handle it gracefully\n\t\t// We need to split this child-panel\n\t\tconst newPanel: Layout = {\n\t\t\ttype: \"split-panel\",\n\t\t\torientation,\n\t\t\tchildren: [panel],\n\t\t\tsizes: [1],\n\t\t};\n\n\t\treturn insert_child(newPanel, child, path, orientation, is_edge);\n\t}\n\n\tif (restPath.length === 0 || index === panel.children.length) {\n\t\tif (is_edge && panel.children[index]?.type === \"child-panel\") {\n\t\t\tpanel.children[index].child.unshift(child);\n\t\t\treturn panel;\n\t\t}\n\n\t\t// Insert at this level at the specified index\n\t\tconst newChildren = [...panel.children];\n\t\tnewChildren.splice(index, 0, {\n\t\t\ttype: \"child-panel\",\n\t\t\tchild: [child],\n\t\t});\n\n\t\tconst numChildren = newChildren.length;\n\t\tconst newSizes = Array(numChildren).fill(1 / numChildren);\n\t\treturn {\n\t\t\t...panel,\n\t\t\tchildren: newChildren,\n\t\t\tsizes: newSizes,\n\t\t};\n\t}\n\n\tconst targetChild = panel.children[index];\n\tif (targetChild.type === \"child-panel\" && restPath.length > 0) {\n\t\t// Need to split this child-panel\n\t\tconst oppositeOrientation =\n\t\t\tpanel.orientation === \"horizontal\" ? \"vertical\" : \"horizontal\";\n\n\t\tconst newSplitPanel = insert_child(\n\t\t\ttargetChild,\n\t\t\tchild,\n\t\t\trestPath,\n\t\t\toppositeOrientation,\n\t\t\tis_edge,\n\t\t);\n\n\t\tconst newChildren = [...panel.children];\n\t\tnewChildren[index] = newSplitPanel;\n\t\treturn {\n\t\t\t...panel,\n\t\t\tchildren: newChildren,\n\t\t};\n\t}\n\n\tconst updatedChild = insert_child(\n\t\ttargetChild,\n\t\tchild,\n\t\trestPath,\n\t\torientation,\n\t\tis_edge,\n\t);\n\n\tconst newChildren = [...panel.children];\n\tnewChildren[index] = updatedChild;\n\treturn {\n\t\t...panel,\n\t\tchildren: newChildren,\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport {\n\tMINIMUM_REDISTRIBUTION_SIZE_THRESHOLD,\n\ttype Layout,\n} from \"./layout_config.ts\";\n\n/**\n * Adjusts panel sizes during a drag operation on a divider.\n *\n * The `delta` is distributed proportionally among affected panels, maintaining\n * the sum:\n *\n * - Panels before and including the path index shrink by delta.\n * - Panels after the path index grow by delta.\n *\n * @param panel - The root layout tree to modify.\n * @param path - Path to the divider being dragged (identifies which split panel\n * to resize).\n * @param delta - Amount to resize, as a fraction (0-1). Positive values grow\n * panels before the divider, negative values shrink them.\n * @returns A new layout tree with updated sizes (original is not mutated).\n * ```\n */\nexport function redistribute_panel_sizes(\n\tpanel: Layout,\n\tpath: number[],\n\tdelta: number,\n): Layout {\n\t// Clone the entire panel structure\n\tconst result = structuredClone(panel);\n\n\t// Find the orientation of the insertion panel,\n\t// and scale the delta on the respective axis if aligned.\n\tlet current: Layout = result;\n\tconst deltas = { horizontal: delta, vertical: delta };\n\tfor (let i = 0; i < path.length - 1; i++) {\n\t\tif (current.type === \"split-panel\") {\n\t\t\tdeltas[current.orientation] /= current.sizes[path[i]];\n\t\t\tcurrent = current.children[path[i]];\n\t\t}\n\t}\n\n\t// Apply the redistribution at the final path index\n\tif (current.type === \"split-panel\") {\n\t\tconst delta = deltas[current.orientation];\n\t\tconst index = path[path.length - 1];\n\n\t\t// It would be fun to remove this condition.\n\t\tif (index < current.sizes.length - 1) {\n\t\t\tcurrent.sizes = add_and_redistribute(current.sizes, index, delta);\n\t\t}\n\t}\n\n\treturn result;\n}\n\nfunction add_and_redistribute(\n\tarr: number[],\n\tindex: number,\n\tdelta: number,\n): number[] {\n\tconst result = [...arr];\n\tlet before_total = 0;\n\tfor (let i = 0; i <= index; i++) {\n\t\tbefore_total += arr[i];\n\t}\n\n\tlet after_total = 0;\n\tfor (let i = index + 1; i < arr.length; i++) {\n\t\tafter_total += arr[i];\n\t}\n\n\t// Clamp `delta` to prevent redistributing either side to 0.\n\tdelta =\n\t\tMath.sign(delta) *\n\t\tMath.min(\n\t\t\tMath.abs(delta),\n\t\t\t(1 - MINIMUM_REDISTRIBUTION_SIZE_THRESHOLD) *\n\t\t\t\t(delta > 0 ? before_total : after_total),\n\t\t);\n\n\t// Redistribute elements\n\tfor (let i = 0; i <= index; i++) {\n\t\tconst proportion = arr[i] / before_total;\n\t\tresult[i] = arr[i] - delta * proportion;\n\t}\n\n\tfor (let i = index + 1; i < arr.length; i++) {\n\t\tconst proportion = arr[i] / after_total;\n\t\tresult[i] = arr[i] + delta * proportion;\n\t}\n\n\treturn result;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { LayoutPath } from \"./layout_config\";\n\nexport function updateOverlaySheet({\n\tview_window: { row_start, row_end, col_start, col_end },\n\tbox,\n}: LayoutPath<DOMRect>) {\n\tconst margin = 0;\n\tconst top = row_start * box.height + margin / 2;\n\tconst left = col_start * box.width + margin / 2;\n\tconst height = (row_end - row_start) * box.height - margin;\n\tconst width = (col_end - col_start) * box.width - margin;\n\tconst css = `position:absolute!important;z-index:1;top:${top}px;left:${left}px;height:${height}px;width:${width}px;`;\n\treturn `::slotted(:not([slot])){${css}}`;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { calculate_intersection } from \"./calculate_intersect\";\nimport { insert_child } from \"./insert_child\";\nimport {\n\tSPLIT_EDGE_TOLERANCE,\n\ttype Layout,\n\ttype LayoutPath,\n} from \"./layout_config\";\n\n/**\n * Calculates an insertion point (which may involve splitting a single\n * `\"child-panel\"` into a new `\"split-panel\"`), based on the cursor position.\n * *\n * @param col - The cursor column.\n * @param row - The cursor row.\n * @param panel - The `Layout` to insert into.\n * @param slot - The slot identifier where the insert should occur\n * @param drop_target - The `LayoutPath` (from `calculateIntersect`) of the\n * panel to either insert next to, or split by.\n * @returns A new `LayoutPath` reflecting the updated (maybe) `\"split-panel\"`,\n * which is enough to draw the overlay.\n */\nexport function calculate_split(\n\tcol: number,\n\trow: number,\n\tpanel: Layout,\n\tslot: string,\n\tdrop_target: LayoutPath,\n): LayoutPath {\n\tif (\n\t\tdrop_target.column_offset < SPLIT_EDGE_TOLERANCE ||\n\t\tdrop_target.column_offset > 1 - SPLIT_EDGE_TOLERANCE\n\t) {\n\t\tif (drop_target.orientation === \"horizontal\") {\n\t\t\tconst is_before = drop_target.column_offset < SPLIT_EDGE_TOLERANCE;\n\t\t\tif (drop_target.path.length === 0) {\n\t\t\t\tconst insert_index = is_before ? 0 : 1;\n\t\t\t\tconst new_panel = insert_child(panel, slot, [insert_index]);\n\t\t\t\t// When inserting before, point to new panel; when after, keep original\n\t\t\t\tif (is_before) {\n\t\t\t\t\tdrop_target = calculate_intersection(col, row, new_panel, false);\n\t\t\t\t} else {\n\t\t\t\t\tconst new_drop_target = calculate_intersection(\n\t\t\t\t\t\tcol,\n\t\t\t\t\t\trow,\n\t\t\t\t\t\tnew_panel,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t);\n\t\t\t\t\tdrop_target = {\n\t\t\t\t\t\t...new_drop_target,\n\t\t\t\t\t\tpath: [0],\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst path_without_last = drop_target.path.slice(0, -1);\n\t\t\t\tconst last_index = drop_target.path[drop_target.path.length - 1];\n\t\t\t\tconst insert_index = is_before ? last_index : last_index + 1;\n\t\t\t\tconst new_panel = insert_child(panel, slot, [\n\t\t\t\t\t...path_without_last,\n\t\t\t\t\tinsert_index,\n\t\t\t\t]);\n\t\t\t\t// When inserting before, point to new panel; when after, keep original\n\t\t\t\tif (is_before) {\n\t\t\t\t\tdrop_target = calculate_intersection(col, row, new_panel, false);\n\t\t\t\t} else {\n\t\t\t\t\t// Keep the original panel but update view_window from new layout\n\t\t\t\t\tconst new_drop_target = calculate_intersection(\n\t\t\t\t\t\tcol,\n\t\t\t\t\t\trow,\n\t\t\t\t\t\tnew_panel,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t);\n\t\t\t\t\tdrop_target = {\n\t\t\t\t\t\t...new_drop_target,\n\t\t\t\t\t\tpath: [...path_without_last, last_index],\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst insert_index =\n\t\t\t\tdrop_target.column_offset < SPLIT_EDGE_TOLERANCE ? 0 : 1;\n\t\t\tconst original_path = drop_target.path;\n\t\t\tconst new_panel = insert_child(\n\t\t\t\tpanel,\n\t\t\t\tslot,\n\t\t\t\t[...original_path, insert_index],\n\t\t\t\t\"horizontal\",\n\t\t\t);\n\t\t\tdrop_target = calculate_intersection(col, row, new_panel, false);\n\t\t\t// Override to point to the newly inserted panel\n\t\t\tdrop_target = {\n\t\t\t\t...drop_target,\n\t\t\t\tslot,\n\t\t\t\tpath: [...original_path, insert_index],\n\t\t\t};\n\t\t}\n\n\t\tif (drop_target) {\n\t\t\tdrop_target.is_edge = true;\n\t\t}\n\t} else if (\n\t\tdrop_target.row_offset < SPLIT_EDGE_TOLERANCE ||\n\t\tdrop_target.row_offset > 1 - SPLIT_EDGE_TOLERANCE\n\t) {\n\t\tif (drop_target.orientation === \"vertical\") {\n\t\t\tconst is_before = drop_target.row_offset < SPLIT_EDGE_TOLERANCE;\n\t\t\tif (drop_target.path.length === 0) {\n\t\t\t\tconst insert_index = is_before ? 0 : 1;\n\t\t\t\tconst new_panel = insert_child(panel, slot, [insert_index]);\n\t\t\t\t// When inserting before, point to new panel; when after, keep original\n\t\t\t\tif (is_before) {\n\t\t\t\t\tdrop_target = calculate_intersection(col, row, new_panel, false);\n\t\t\t\t} else {\n\t\t\t\t\tconst new_drop_target = calculate_intersection(\n\t\t\t\t\t\tcol,\n\t\t\t\t\t\trow,\n\t\t\t\t\t\tnew_panel,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t);\n\t\t\t\t\tdrop_target = {\n\t\t\t\t\t\t...new_drop_target,\n\t\t\t\t\t\tpath: [0],\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst path_without_last = drop_target.path.slice(0, -1);\n\t\t\t\tconst last_index = drop_target.path[drop_target.path.length - 1];\n\t\t\t\tconst insert_index = is_before ? last_index : last_index + 1;\n\t\t\t\tconst new_panel = insert_child(panel, slot, [\n\t\t\t\t\t...path_without_last,\n\t\t\t\t\tinsert_index,\n\t\t\t\t]);\n\t\t\t\t// When inserting before, point to new panel; when after, keep original\n\t\t\t\tif (is_before) {\n\t\t\t\t\tdrop_target = calculate_intersection(col, row, new_panel, false);\n\t\t\t\t} else {\n\t\t\t\t\t// Keep the original panel but update view_window from new layout\n\t\t\t\t\tconst new_drop_target = calculate_intersection(\n\t\t\t\t\t\tcol,\n\t\t\t\t\t\trow,\n\t\t\t\t\t\tnew_panel,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t);\n\t\t\t\t\tdrop_target = {\n\t\t\t\t\t\t...new_drop_target,\n\t\t\t\t\t\tpath: [...path_without_last, last_index],\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst insert_index =\n\t\t\t\tdrop_target.row_offset < SPLIT_EDGE_TOLERANCE ? 0 : 1;\n\t\t\tconst original_path = drop_target.path;\n\t\t\tconst new_panel = insert_child(\n\t\t\t\tpanel,\n\t\t\t\tslot,\n\t\t\t\t[...original_path, insert_index],\n\t\t\t\t\"vertical\",\n\t\t\t);\n\t\t\tdrop_target = calculate_intersection(col, row, new_panel, false);\n\t\t\t// Override to point to the newly inserted panel\n\t\t\tdrop_target = {\n\t\t\t\t...drop_target,\n\t\t\t\tslot,\n\t\t\t\tpath: [...original_path, insert_index],\n\t\t\t};\n\t\t}\n\n\t\tif (drop_target) {\n\t\t\tdrop_target.is_edge = true;\n\t\t}\n\t}\n\n\treturn drop_target;\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Layout } from \"./layout_config.ts\";\n\n/**\n * Flattens the layout tree by merging parent and child split panels that have\n * the same orientation and type.\n *\n * When a split panel contains a child split panel with the same orientation,\n * they are merged into a single split panel. The sizes array is scaled\n * correctly to maintain proportions.\n *\n * @param layout - The layout tree to flatten\n * @returns A new flattened layout tree (original is not mutated).\n */\nexport function flatten(layout: Layout): Layout {\n\tif (layout.type === \"child-panel\") {\n\t\treturn layout;\n\t}\n\n\tconst flattenedChildren: Layout[] = [];\n\tconst flattenedSizes: number[] = [];\n\tfor (let i = 0; i < layout.children.length; i++) {\n\t\tconst child = layout.children[i];\n\t\tconst childSize = layout.sizes[i];\n\t\tconst flattenedChild = flatten(child);\n\n\t\tif (\n\t\t\tflattenedChild.type === \"split-panel\" &&\n\t\t\tflattenedChild.orientation === layout.orientation\n\t\t) {\n\t\t\tfor (let j = 0; j < flattenedChild.children.length; j++) {\n\t\t\t\tflattenedChildren.push(flattenedChild.children[j]);\n\t\t\t\tflattenedSizes.push(flattenedChild.sizes[j] * childSize);\n\t\t\t}\n\t\t} else {\n\t\t\tflattenedChildren.push(flattenedChild);\n\t\t\tflattenedSizes.push(childSize);\n\t\t}\n\t}\n\n\tif (flattenedChildren.length === 1) {\n\t\treturn flattenedChildren[0];\n\t}\n\n\treturn {\n\t\ttype: \"split-panel\",\n\t\torientation: layout.orientation,\n\t\tchildren: flattenedChildren,\n\t\tsizes: flattenedSizes,\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * This module defines the `<regular-layout>` custom element for browser\n * environments.\n *\n * @packageDocumentation\n */\n\nimport {\n\tEMPTY_PANEL,\n\titer_panel_children,\n\tOVERLAY_DEFAULT,\n} from \"./common/layout_config.ts\";\nimport { create_css_grid_layout } from \"./common/generate_grid.ts\";\nimport type {\n\tLayoutPath,\n\tLayout,\n\tLayoutDivider,\n\tTabLayout,\n} from \"./common/layout_config.ts\";\nimport { calculate_intersection } from \"./common/calculate_intersect.ts\";\nimport { remove_child } from \"./common/remove_child.ts\";\nimport { insert_child } from \"./common/insert_child.ts\";\nimport { redistribute_panel_sizes } from \"./common/redistribute_panel_sizes.ts\";\nimport { updateOverlaySheet } from \"./common/generate_overlay.ts\";\nimport { calculate_split } from \"./common/calculate_split.ts\";\nimport { flatten } from \"./common/flatten.ts\";\n\n/**\n * A Web Component that provides a resizable panel layout system.\n * Panels are arranged using CSS Grid and can be resized by dragging dividers.\n *\n * The component uses Shadow DOM and CSS Grid to manage layout.\n *\n * @example\n * ```html\n * <regular-layout>\n * <div slot=\"sidebar\">Sidebar content</div>\n * <div slot=\"main\">Main content</div>\n * </regular-layout>\n * ```\n *\n * @example\n * ```typescript\n * const layout = document.querySelector('regular-layout');\n *\n * // Insert panels into the grid layout\n * layout.insertPanel('main');\n * layout.insertPanel('sidebar');\n *\n * // Remove a panel (DOM child is still connected, but not slotted)\n * layout.removePanel('sidebar');\n *\n * // Save current layout\n * const state = layout.save();\n *\n * // Restore layout later\n * layout.restore(state);\n * ```\n *\n */\nexport class RegularLayout extends HTMLElement {\n\tprivate _shadowRoot: ShadowRoot;\n\tprivate _panel: Layout;\n\tprivate _stylesheet: CSSStyleSheet;\n\tprivate _dragPath?: [LayoutDivider, number, number];\n\tprivate _slots: Map<string, HTMLSlotElement>;\n\tprivate _unslotted_slot: HTMLSlotElement;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis._panel = structuredClone(EMPTY_PANEL);\n\t\tthis._stylesheet = new CSSStyleSheet();\n\t\tthis._unslotted_slot = document.createElement(\"slot\");\n\t\tthis._shadowRoot = this.attachShadow({ mode: \"open\" });\n\t\tthis._shadowRoot.adoptedStyleSheets = [this._stylesheet];\n\t\tthis._shadowRoot.appendChild(this._unslotted_slot);\n\t\tthis._slots = new Map();\n\t\tthis.onPointerDown = this.onPointerDown.bind(this);\n\t\tthis.onPointerMove = this.onPointerMove.bind(this);\n\t\tthis.onPointerUp = this.onPointerUp.bind(this);\n\t}\n\n\tconnectedCallback() {\n\t\tthis.addEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis.addEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis.addEventListener(\"pointermove\", this.onPointerMove);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis.removeEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis.removeEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis.removeEventListener(\"pointermove\", this.onPointerMove);\n\t}\n\n\t/**\n\t * Sets the visual overlay state during drag-and-drop operations.\n\t * Displays a preview of where a panel would be placed at the given coordinates.\n\t *\n\t * @param x - X coordinate in screen pixels.\n\t * @param y - Y coordinate in screen pixels.\n\t * @param layoutPath - Layout path containing the slot identifier.\n\t * @param mode - Overlay rendering mode: \"grid\" highlights the target,\n\t * \"absolute\" positions the panel absolutely, \"interactive\" updates the\n\t * actual layout in real-time. Defaults to \"absolute\".\n\t */\n\tsetOverlayState<T>(\n\t\tx: number,\n\t\ty: number,\n\t\t{ slot }: LayoutPath<T>,\n\t\tmode: \"grid\" | \"absolute\" | \"interactive\" = OVERLAY_DEFAULT,\n\t) {\n\t\tlet panel = this._panel;\n\t\tif (mode === \"absolute\") {\n\t\t\tpanel = remove_child(panel, slot);\n\t\t\tthis._slots.get(slot)?.assignedElements()[0]?.removeAttribute(\"slot\");\n\t\t}\n\n\t\tconst [col, row, box] = this.relativeCoordinates(x, y);\n\t\tlet drop_target = calculate_intersection(col, row, panel, false);\n\t\tif (drop_target) {\n\t\t\tdrop_target = calculate_split(col, row, panel, slot, drop_target);\n\t\t\tif (mode === \"interactive\") {\n\t\t\t\tlet new_panel = remove_child(this._panel, slot);\n\t\t\t\tnew_panel = flatten(insert_child(new_panel, slot, drop_target.path));\n\t\t\t\tconst css = create_css_grid_layout(new_panel);\n\t\t\t\tthis._stylesheet.replaceSync(css);\n\t\t\t} else if (mode === \"grid\") {\n\t\t\t\tconst path: [string, string] = [slot, drop_target.slot];\n\t\t\t\tconst css = create_css_grid_layout(this._panel, false, path);\n\t\t\t\tthis._stylesheet.replaceSync(css);\n\t\t\t} else if (mode === \"absolute\") {\n\t\t\t\tconst css = `${create_css_grid_layout(panel)}\\n${updateOverlaySheet({ ...drop_target, box })}`;\n\t\t\t\tthis._stylesheet.replaceSync(css);\n\t\t\t}\n\t\t} else {\n\t\t\tconst css = `${create_css_grid_layout(panel)}}`;\n\t\t\tthis._stylesheet.replaceSync(css);\n\t\t}\n\n\t\tconst event = new CustomEvent(\"regular-layout-update\", { detail: panel });\n\t\tthis.dispatchEvent(event);\n\t}\n\n\t/**\n\t * Clears the overlay state and commits the panel placement.\n\t *\n\t * @param x - X coordinate in screen pixels.\n\t * @param y - Y coordinate in screen pixels.\n\t * @param layout_path - Layout path containing the slot identifier.\n\t * @param mode - Overlay rendering mode that was used, must match the mode\n\t * passed to `setOverlayState`. Defaults to \"absolute\".\n\t */\n\tclearOverlayState<T>(\n\t\tx: number,\n\t\ty: number,\n\t\tdrag_target: LayoutPath<T>,\n\t\tmode: \"grid\" | \"absolute\" | \"interactive\" = OVERLAY_DEFAULT,\n\t) {\n\t\tlet panel = this._panel;\n\t\tif (mode === \"absolute\") {\n\t\t\tpanel = remove_child(panel, drag_target.slot);\n\t\t\tthis._unslotted_slot\n\t\t\t\t.assignedElements()[0]\n\t\t\t\t?.setAttribute(\"slot\", drag_target.slot);\n\t\t}\n\n\t\tconst [col, row, _] = this.relativeCoordinates(x, y);\n\t\tlet drop_target = calculate_intersection(col, row, panel, false);\n\t\tif (drop_target) {\n\t\t\t// TODO I think I only need the new path here?\n\t\t\tdrop_target = calculate_split(\n\t\t\t\tcol,\n\t\t\t\trow,\n\t\t\t\tpanel,\n\t\t\t\tdrag_target.slot,\n\t\t\t\tdrop_target,\n\t\t\t);\n\t\t}\n\n\t\tconst { path, orientation } = drop_target ? drop_target : drag_target;\n\n\t\tthis.restore(\n\t\t\tinsert_child(\n\t\t\t\tpanel,\n\t\t\t\tdrag_target.slot,\n\t\t\t\tpath,\n\t\t\t\torientation,\n\t\t\t\t!drop_target?.is_edge,\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * Inserts a new panel into the layout at a specified path.\n\t *\n\t * @param name - Unique identifier for the new panel.\n\t * @param path - Index path defining where to insert.\n\t */\n\tinsertPanel(name: string, path: number[] = []) {\n\t\tthis.restore(insert_child(this._panel, name, path));\n\t}\n\n\t/**\n\t * Removes a panel from the layout by name.\n\t *\n\t * @param name - Name of the panel to remove\n\t */\n\tremovePanel(name: string) {\n\t\tthis.restore(remove_child(this._panel, name));\n\t}\n\n\tgetPanel(name: string, layout: Layout = this._panel): TabLayout | null {\n\t\tif (layout.type === \"child-panel\") {\n\t\t\tif (layout.child.includes(name)) {\n\t\t\t\treturn layout;\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\n\t\tfor (const child of layout.children) {\n\t\t\tconst found = this.getPanel(name, child);\n\t\t\tif (found) {\n\t\t\t\treturn found;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Determines which panel is at a given screen coordinate.\n\t * Useful for drag-and-drop operations or custom interactions.\n\t *\n\t * @param column - X coordinate in screen pixels.\n\t * @param row - Y coordinate in screen pixels.\n\t * @returns Panel information if a panel is at that position, null otherwise.\n\t */\n\tcalculateIntersect(\n\t\tx: number,\n\t\ty: number,\n\t\tcheck_dividers: boolean = false,\n\t): LayoutPath<DOMRect> | null {\n\t\tconst [col, row, box] = this.relativeCoordinates(x, y);\n\t\tconst panel = calculate_intersection(col, row, this._panel, check_dividers);\n\t\tif (panel?.type === \"layout-path\") {\n\t\t\treturn { ...panel, box };\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tclear() {\n\t\tthis.restore(EMPTY_PANEL);\n\t}\n\n\t/**\n\t * Restores the layout from a saved state.\n\t *\n\t * @param layout - The layout tree to restore\n\t *\n\t * @example\n\t * ```typescript\n\t * const layout = document.querySelector('regular-layout');\n\t * const savedState = JSON.parse(localStorage.getItem('layout'));\n\t * layout.restore(savedState);\n\t * ```\n\t */\n\trestore(layout: Layout, _is_flattened: boolean = false) {\n\t\tthis._panel = !_is_flattened ? flatten(layout) : layout;\n\t\tconst css = create_css_grid_layout(layout);\n\t\tthis._stylesheet.replaceSync(css);\n\t\tconst old = new Set(this._slots.keys());\n\t\tfor (const name of iter_panel_children(layout)) {\n\t\t\told.delete(name);\n\t\t\tif (!this._slots.has(name)) {\n\t\t\t\tconst slot = document.createElement(\"slot\");\n\t\t\t\tslot.setAttribute(\"name\", name);\n\t\t\t\tthis._shadowRoot.appendChild(slot);\n\t\t\t\tthis._slots.set(name, slot);\n\t\t\t}\n\t\t}\n\n\t\tfor (const key of old) {\n\t\t\tconst child = this._slots.get(key);\n\t\t\tif (child) {\n\t\t\t\tthis._shadowRoot.removeChild(child);\n\t\t\t\tthis._slots.delete(key);\n\t\t\t}\n\t\t}\n\n\t\tconst event = new CustomEvent(\"regular-layout-update\", { detail: layout });\n\t\tthis.dispatchEvent(event);\n\t}\n\n\t/**\n\t * Serializes the current layout state, which can be restored via `restore`.\n\t *\n\t * @returns The current layout tree\n\t *\n\t * @example\n\t * ```typescript\n\t * const layout = document.querySelector('regular-layout');\n\t * const state = layout.save();\n\t * localStorage.setItem('layout', JSON.stringify(state));\n\t * ```\n\t */\n\tsave(): Layout {\n\t\treturn structuredClone(this._panel);\n\t}\n\n\tprivate relativeCoordinates(\n\t\tclientX: number,\n\t\tclientY: number,\n\t): [number, number, DOMRect] {\n\t\tconst box = this.getBoundingClientRect();\n\t\tconst col = (clientX - box.left) / (box.right - box.left);\n\t\tconst row = (clientY - box.top) / (box.bottom - box.top);\n\t\treturn [col, row, box];\n\t}\n\n\tprivate onPointerDown(event: PointerEvent) {\n\t\tif (event.target === this) {\n\t\t\tconst [col, row] = this.relativeCoordinates(event.clientX, event.clientY);\n\t\t\tconst hit = calculate_intersection(col, row, this._panel);\n\t\t\tif (hit && hit.type !== \"layout-path\") {\n\t\t\t\tthis._dragPath = [hit, col, row];\n\t\t\t\tthis.setPointerCapture(event.pointerId);\n\t\t\t\t// event.preventDefault();\n\t\t\t\t// event.stopImmediatePropagation();\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onPointerMove(event: PointerEvent) {\n\t\tif (this._dragPath) {\n\t\t\tconst [col, row] = this.relativeCoordinates(event.clientX, event.clientY);\n\t\t\tconst old_panel = this._panel;\n\t\t\tconst [{ path, type }, old_col, old_row] = this._dragPath;\n\t\t\tconst offset = type === \"horizontal\" ? old_col - col : old_row - row;\n\t\t\tconst panel = redistribute_panel_sizes(old_panel, path, offset);\n\t\t\tthis._stylesheet.replaceSync(create_css_grid_layout(panel));\n\t\t}\n\t}\n\n\tprivate onPointerUp(event: PointerEvent) {\n\t\tif (this._dragPath) {\n\t\t\tthis.releasePointerCapture(event.pointerId);\n\t\t\tconst [col, row] = this.relativeCoordinates(event.clientX, event.clientY);\n\t\t\tconst old_panel = this._panel;\n\t\t\tconst [{ path }, old_col, old_row] = this._dragPath;\n\t\t\tif (this._dragPath[0].type === \"horizontal\") {\n\t\t\t\tconst panel = redistribute_panel_sizes(old_panel, path, old_col - col);\n\t\t\t\tthis.restore(panel, true);\n\t\t\t} else {\n\t\t\t\tconst panel = redistribute_panel_sizes(old_panel, path, old_row - row);\n\t\t\t\tthis.restore(panel, true);\n\t\t\t}\n\n\t\t\tthis._dragPath = undefined;\n\t\t}\n\t}\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { LayoutPath } from \"./common/layout_config.ts\";\nimport type { RegularLayoutEvent } from \"./extensions.ts\";\nimport type { RegularLayout } from \"./regular-layout.ts\";\n\nconst CSS = `\n:host{--titlebar--height:24px;box-sizing:border-box}\n:host([slot]){margin-top:calc(var(--titlebar--height) + 3px)!important;}\n:host([slot])::part(container){position:absolute;top:0;left:0;right:0;bottom:0;display:flex;flex-direction:column;background-color:inherit;border-radius:inherit}\n:host([slot])::part(titlebar){height:var(--titlebar--height);margin-top:calc(0px - var(--titlebar--height));user-select: none;}\n:host([slot])::part(body){flex:1 1 auto;}\n`;\n\nconst HTML_TEMPLATE = `<slot part=\"container\"><slot part=\"titlebar\"></slot><slot part=\"body\"><slot></slot></slot></slot>`;\n\n/**\n * A custom element that represents a draggable panel within a\n * `<regular-layout>`.\n *\n * `<regular-layout-frame>` is optional - you may also use a `<regular-layout>`\n * with just plain `<div>` children (for example), but panels will not be\n * moveable within the layout unless you manually call `setOverlayState` and\n * `clearOverlayState` (or otherwise impement panel moving via the\n * `<regular-layout>` API).\n *\n * `<regular-layout-frame>` simple and highly customizable implementations\n * based on [CSS `part`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/::part)\n * for custom styling, and symmetric\n * [named `slot`s](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_templates_and_slots)\n * for wholesale replacement of the underlying Shadow DOM.\n *\n * @example\n * ```html\n * <regular-layout>\n * <regular-layout-frame slot=\"panel-1\">\n * <!-- Panel content here -->\n * </regular-layout-frame>\n * </regular-layout>\n * ```\n */\nexport class RegularLayoutFrame extends HTMLElement {\n\tprivate _shadowRoot: ShadowRoot;\n\tprivate _container_sheet: CSSStyleSheet;\n\tprivate _layout!: RegularLayout;\n\tprivate _header!: HTMLElement;\n\tprivate _drag_state: LayoutPath<DOMRect> | null = null;\n\tprivate _drag_moved: boolean = false;\n\tprivate _tab_to_index_map: WeakMap<HTMLDivElement, number> = new WeakMap();\n\tconstructor() {\n\t\tsuper();\n\t\tthis._container_sheet = new CSSStyleSheet();\n\t\tthis._container_sheet.replaceSync(CSS);\n\t\tthis._shadowRoot = this.attachShadow({ mode: \"open\" });\n\t\tthis._shadowRoot.adoptedStyleSheets = [this._container_sheet];\n\t\tthis.drawTabs = this.drawTabs.bind(this);\n\t\tthis.onPointerDown = this.onPointerDown.bind(this);\n\t\tthis.onPointerMove = this.onPointerMove.bind(this);\n\t\tthis.onPointerUp = this.onPointerUp.bind(this);\n\t\tthis.onPointerLost = this.onPointerLost.bind(this);\n\t}\n\n\tconnectedCallback() {\n\t\tthis._shadowRoot.innerHTML = HTML_TEMPLATE;\n\t\tthis._layout = this.parentElement as RegularLayout;\n\t\tthis._header = this._shadowRoot.children[0].children[0] as HTMLElement;\n\t\tthis._header.addEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis._header.addEventListener(\"pointermove\", this.onPointerMove);\n\t\tthis._header.addEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis._header.addEventListener(\"lostpointercapture\", this.onPointerLost);\n\t\tthis._layout.addEventListener(\"regular-layout-update\", this.drawTabs);\n\t}\n\n\tdisconnectedCallback() {\n\t\tthis._header.removeEventListener(\"pointerdown\", this.onPointerDown);\n\t\tthis._header.removeEventListener(\"pointermove\", this.onPointerMove);\n\t\tthis._header.removeEventListener(\"pointerup\", this.onPointerUp);\n\t\tthis._header.removeEventListener(\"lostpointercapture\", this.onPointerLost);\n\t\tthis._layout.removeEventListener(\"regular-layout-update\", this.drawTabs);\n\t}\n\n\tprivate drawTabs(event: RegularLayoutEvent) {\n\t\tconst slot = this.getAttribute(\"slot\");\n\t\tif (slot) {\n\t\t\tconst result = this._layout.getPanel(slot, event.detail);\n\t\t\tthis._header.textContent = \"\";\n\t\t\tif (!result) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfor (let e = 0; e < (result?.child?.length || 0); e++) {\n\t\t\t\tconst elem = result?.child[e];\n\t\t\t\tconst div = document.createElement(\"div\");\n\t\t\t\tthis._tab_to_index_map.set(div, e);\n\t\t\t\t// div.dataset.index = `${e}`;\n\t\t\t\tdiv.textContent = elem || \"\";\n\t\t\t\tdiv.setAttribute(\n\t\t\t\t\t\"part\",\n\t\t\t\t\te === (result?.selected || 0) ? \"tab active-tab\" : \"tab\",\n\t\t\t\t);\n\n\t\t\t\tconst x = e;\n\t\t\t\tif (e !== (result?.selected || 0)) {\n\t\t\t\t\tdiv.addEventListener(\"pointerdown\", (pointerEvent: PointerEvent) => {\n\t\t\t\t\t\tresult.selected = x;\n\t\t\t\t\t\tthis._layout.restore(event.detail);\n\t\t\t\t\t\tpointerEvent.preventDefault();\n\t\t\t\t\t\tpointerEvent.stopImmediatePropagation();\n\t\t\t\t\t\tpointerEvent.stopPropagation();\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tthis._header.appendChild(div);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate onPointerDown = (event: PointerEvent): void => {\n\t\tthis._drag_state = this._layout.calculateIntersect(\n\t\t\tevent.clientX,\n\t\t\tevent.clientY,\n\t\t);\n\n\t\tif (this._drag_state) {\n\t\t\tconst elem = event.target as HTMLDivElement;\n\t\t\tif (elem.part.contains(\"tab\")) {\n\t\t\t\tconst last_index = this._drag_state.path.length - 1;\n\t\t\t\tconst selected = this._tab_to_index_map.get(elem);\n\t\t\t\tif (selected) {\n\t\t\t\t\tthis._drag_state.path[last_index] = selected;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthis._header.setPointerCapture(event.pointerId);\n\t\t\t// event.preventDefault();\n\t\t\t// event.stopImmediatePropagation();\n\t\t}\n\t};\n\n\tprivate onPointerMove = (event: PointerEvent): void => {\n\t\tif (this._drag_state) {\n\t\t\tthis._drag_moved = true;\n\t\t\tthis._layout.setOverlayState(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tthis._drag_state,\n\t\t\t);\n\t\t}\n\t};\n\n\tprivate onPointerUp = (event: PointerEvent): void => {\n\t\tif (this._drag_state && this._drag_moved) {\n\t\t\tthis._layout.clearOverlayState(\n\t\t\t\tevent.clientX,\n\t\t\t\tevent.clientY,\n\t\t\t\tthis._drag_state,\n\t\t\t);\n\t\t}\n\n\t\t// TODO This may be handled by `onPointerLost`, not sure if this is\n\t\t// browser-specific behavior ...\n\t\tthis._header.releasePointerCapture(event.pointerId);\n\t\tthis._drag_state = null;\n\t\tthis._drag_moved = false;\n\t};\n\n\tprivate onPointerLost = (event: PointerEvent): void => {\n\t\tif (this._drag_state) {\n\t\t\tthis._layout.clearOverlayState(-1, -1, this._drag_state);\n\t\t}\n\n\t\tthis._header.releasePointerCapture(event.pointerId);\n\t\tthis._drag_state = null;\n\t\tthis._drag_moved = false;\n\t};\n}\n", "// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2584\u2580\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2580\u2588\u2591\u2588\u2591\u2588\u2591\u2580\u2588\u2580\u2591\u2580\u2584\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2584\u2591\u2591\u2588\u2580\u2584\u2591\u2588\u2580\u2580\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2588\u2580\u2584\u2591\u2580\u2580\u2580\u2591\u2588\u2591\u2591\u2591\u2588\u2580\u2588\u2591\u2591\u2588\u2591\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2588\u2591\u2591\u2588\u2591\u2591\u2591\u2584\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2580\u2580\u2591\u2580\u2580\u2580\u2591\u2591\u2580\u2591\u2591\u2580\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\n// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 * Copyright (c) 2026, the Regular Layout Authors. This file is part * \u2503\n// \u2503 * of the Regular Layout library, distributed under the terms of the * \u2503\n// \u2503 * [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). * \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { RegularLayout } from \"./regular-layout.ts\";\nimport { RegularLayoutFrame } from \"./regular-layout-frame.ts\";\nimport { Layout } from \"./common/layout_config.ts\";\n\ncustomElements.define(\"regular-layout\", RegularLayout);\ncustomElements.define(\"regular-layout-frame\", RegularLayoutFrame);\n\ndeclare global {\n\tinterface Document {\n\t\tcreateElement(\n\t\t\ttagName: \"regular-layout\",\n\t\t\toptions?: ElementCreationOptions,\n\t\t): RegularLayout;\n\n\t\tcreateElement(\n\t\t\ttagName: \"regular-layout-frame\",\n\t\t\toptions?: ElementCreationOptions,\n\t\t): RegularLayoutFrame;\n\n\t\tquerySelector<E extends Element = Element>(selectors: string): E | null;\n\t\tquerySelector(selectors: \"regular-layout\"): RegularLayout | null;\n\t\tquerySelector(selectors: \"regular-layout-frame\"): RegularLayoutFrame | null;\n\t}\n\n\tinterface CustomElementRegistry {\n\t\tget(tagName: \"regular-layout\"): typeof RegularLayout;\n\t\tget(tagName: \"regular-layout-frame\"): typeof RegularLayoutFrame;\n\t}\n\n\tinterface HTMLElement {\n\t\taddEventListener(\n\t\t\tname: \"regular-layout-update\",\n\t\t\tcb: (e: RegularLayoutEvent) => void,\n\t\t\toptions?: { signal: AbortSignal },\n\t\t): void;\n\n\t\tremoveEventListener(name: \"regular-layout-update\", cb: any): void;\n\t}\n}\n\nexport interface RegularLayoutEvent extends CustomEvent {\n\tdetail: Layout;\n}\n\nexport interface PerspectiveViewerElementExt {\n\taddEventListener(\n\t\tname: \"regular-layout-update\",\n\t\tcb: (e: RegularLayoutEvent) => void,\n\t\toptions?: { signal: AbortSignal },\n\t): void;\n\n\tremoveEventListener(name: \"regular-layout-update\", cb: any): void;\n}\n"],
5
+ "mappings": "AAiCO,IAAMA,EAA+B,WAwFrC,SAAUC,EAAoBC,EAAkC,CACtE,GAAIA,EAAM,OAAS,cAClB,QAAWC,KAASD,EAAM,SACzB,MAAOD,EAAoBE,CAAK,OAGjC,MAAOD,EAAM,KAEf,CAKO,IAAME,EAAsB,CAClC,KAAM,cACN,YAAa,aACb,MAAO,CAAC,EACR,SAAU,CAAC,CACZ,EClHO,SAASC,EAAaC,EAAeC,EAAuB,CAElE,GAAID,EAAM,OAAS,cAAe,CACjC,GAAIA,EA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U,EAAIC,EAEtC,CAEA,KAAK,QAAQ,kBAAkBR,EAAM,SAAS,CAG/C,CACD,EAEQ,cAAiBA,GAA8B,CAClD,KAAK,cACR,KAAK,YAAc,GACnB,KAAK,QAAQ,gBACZA,EAAM,QACNA,EAAM,QACN,KAAK,WACN,EAEF,EAEQ,YAAeA,GAA8B,CAChD,KAAK,aAAe,KAAK,aAC5B,KAAK,QAAQ,kBACZA,EAAM,QACNA,EAAM,QACN,KAAK,WACN,EAKD,KAAK,QAAQ,sBAAsBA,EAAM,SAAS,EAClD,KAAK,YAAc,KACnB,KAAK,YAAc,EACpB,EAEQ,cAAiBA,GAA8B,CAClD,KAAK,aACR,KAAK,QAAQ,kBAAkB,GAAI,GAAI,KAAK,WAAW,EAGxD,KAAK,QAAQ,sBAAsBA,EAAM,SAAS,EAClD,KAAK,YAAc,KACnB,KAAK,YAAc,EACpB,CACD,ECzKA,eAAe,OAAO,iBAAkBS,CAAa,EACrD,eAAe,OAAO,uBAAwBC,CAAkB",
6
+ "names": ["OVERLAY_DEFAULT", "iter_panel_children", "panel", "child", "EMPTY_PANEL", "remove_child", "panel", "child", "newChild", "c", "EMPTY_PANEL", "result", "index", "p", "tab_layout", "newChildren", "_", "i", "newSizes", "remove_and_redistribute", "modified", "updated", "arr", "removed_size", "remaining_total", "proportion", "dedupePositions", "positions", "sorted", "a", "b", "result", "i", "collectTrackPositions", "panel", "orientation", "start", "end", "current", "size", "childPositions", "allPositions", "child", "findTrackIndex", "value", "buildCells", "colPositions", "rowPositions", "colStart", "colEnd", "rowStart", "rowEnd", "selected", "cells", "children", "sizes", "next", "host_template", "rowTemplate", "colTemplate", "child_template", "slot", "rowPart", "colPart", "create_css_grid_layout", "layout", "round", "overlay", "remove_child", "colSizes", "s", "rowSizes", "css", "cell", "calculate_intersection", "column", "row", "layout", "check_dividers", "calculate_intersection_recursive", "VIEW_WINDOW", "panel", "parent_orientation", "view_window", "path", "selected", "column_offset", "row_offset", "current_row", "i", "next_row", "current_col", "total_size", "next_col", "insert_child", "panel", "child", "path", "orientation", "is_edge", "newChildren", "numChildren", "newSizes", "index", "restPath", "targetChild", "oppositeOrientation", "newSplitPanel", "updatedChild", "redistribute_panel_sizes", "panel", "path", "delta", "result", "current", "deltas", "i", "index", "add_and_redistribute", "arr", "before_total", "after_total", "proportion", "updateOverlaySheet", "row_start", "row_end", "col_start", "col_end", "box", "top", "left", "height", "width", "calculate_split", "col", "row", "panel", "slot", "drop_target", "is_before", "new_panel", "insert_child", "calculate_intersection", "path_without_last", "last_index", "insert_index", "original_path", "flatten", "layout", "flattenedChildren", "flattenedSizes", "i", "child", "childSize", "flattenedChild", "j", "RegularLayout", "EMPTY_PANEL", "x", "y", "slot", "mode", "OVERLAY_DEFAULT", "panel", "remove_child", "col", "row", "box", "drop_target", "calculate_intersection", "calculate_split", "new_panel", "flatten", "insert_child", "css", "create_css_grid_layout", "path", "updateOverlaySheet", "event", "drag_target", "_", "orientation", "name", "layout", "child", "found", "check_dividers", "_is_flattened", "old", "iter_panel_children", "key", "clientX", "clientY", "hit", "old_panel", "type", "old_col", "old_row", "offset", "redistribute_panel_sizes", "CSS", "HTML_TEMPLATE", "RegularLayoutFrame", "event", "slot", "result", "elem", "div", "x", "pointerEvent", "last_index", "selected", "RegularLayout", "RegularLayoutFrame"]
7
7
  }
@@ -29,10 +29,14 @@ export declare class RegularLayoutFrame extends HTMLElement {
29
29
  private _layout;
30
30
  private _header;
31
31
  private _drag_state;
32
+ private _drag_moved;
33
+ private _tab_to_index_map;
32
34
  constructor();
33
35
  connectedCallback(): void;
34
36
  disconnectedCallback(): void;
37
+ private drawTabs;
35
38
  private onPointerDown;
36
39
  private onPointerMove;
37
40
  private onPointerUp;
41
+ private onPointerLost;
38
42
  }
@@ -1,5 +1,4 @@
1
- import type { LayoutPath, Layout } from "./common/layout_config.ts";
2
- export type OverlayMode = "grid" | "absolute" | "interactive";
1
+ import type { LayoutPath, Layout, TabLayout } from "./common/layout_config.ts";
3
2
  /**
4
3
  * A Web Component that provides a resizable panel layout system.
5
4
  * Panels are arranged using CSS Grid and can be resized by dragging dividers.
@@ -78,6 +77,7 @@ export declare class RegularLayout extends HTMLElement {
78
77
  * @param name - Name of the panel to remove
79
78
  */
80
79
  removePanel(name: string): void;
80
+ getPanel(name: string, layout?: Layout): TabLayout | null;
81
81
  /**
82
82
  * Determines which panel is at a given screen coordinate.
83
83
  * Useful for drag-and-drop operations or custom interactions.
@@ -87,6 +87,7 @@ export declare class RegularLayout extends HTMLElement {
87
87
  * @returns Panel information if a panel is at that position, null otherwise.
88
88
  */
89
89
  calculateIntersect(x: number, y: number, check_dividers?: boolean): LayoutPath<DOMRect> | null;
90
+ clear(): void;
90
91
  /**
91
92
  * Restores the layout from a saved state.
92
93
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "regular-layout",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "A regular CSS `grid` container",
5
5
  "keywords": [],
6
6
  "license": "Apache-2.0",