@aiquants/markdown-explorer 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./index-CnX313Ss.cjs"),e=require("./storage-DM0EvkVf.cjs"),E=require("./location-l_HysaZR.cjs"),_=require("./dataRoute-DwYtgyt6.cjs");exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=L.DEFAULT_MARKDOWN_EXPLORER_LOCALE;exports.EXPLORER_THEMES=L.EXPLORER_THEMES;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=L.MARKDOWN_EXPLORER_LABEL_CATALOGS;exports.MARKDOWN_EXPLORER_LABEL_KEYS=L.MARKDOWN_EXPLORER_LABEL_KEYS;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=L.MARKDOWN_EXPLORER_LABEL_TEMPLATES;exports.MARKDOWN_EXPLORER_LOCALES=L.MARKDOWN_EXPLORER_LOCALES;exports.MarkdownExplorer=L.MarkdownExplorer;exports.resolveMarkdownExplorerLabels=L.resolveMarkdownExplorerLabels;exports.shouldRevalidateExplorer=L.shouldRevalidateExplorer;exports.clearExplorerStorage=e.clearExplorerStorage;exports.COLUMN_MIN_MEASURE=E.COLUMN_MIN_MEASURE;exports.DEFAULT_TREE_SETTINGS=E.DEFAULT_TREE_SETTINGS;exports.DEFAULT_VIEW_SLUGS=E.DEFAULT_VIEW_SLUGS;exports.EXPAND_ALL_DEPTH_LIMITS=E.EXPAND_ALL_DEPTH_LIMITS;exports.EXPAND_ALL_FOLDER_LIMITS=E.EXPAND_ALL_FOLDER_LIMITS;exports.EXPLORER_DEFAULT_PERCENT=E.EXPLORER_DEFAULT_PERCENT;exports.EXPLORER_MAX_PERCENT=E.EXPLORER_MAX_PERCENT;exports.EXPLORER_MIN_REM=E.EXPLORER_MIN_REM;exports.EXPLORER_MULTI_DEFAULT_PERCENT=E.EXPLORER_MULTI_DEFAULT_PERCENT;exports.GOLDEN_RATIO=E.GOLDEN_RATIO;exports.MULTI_VIEW_COLUMN_LIMITS=E.MULTI_VIEW_COLUMN_LIMITS;exports.MULTI_VIEW_PANEL_LIMITS=E.MULTI_VIEW_PANEL_LIMITS;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=E.REVEAL_DOCUMENT_DEPTH_LIMITS;exports.SPREADSHEET_BYTE_LIMITS=E.SPREADSHEET_BYTE_LIMITS;exports.WORKBOOK_BYTE_LIMITS=E.WORKBOOK_BYTE_LIMITS;exports.defineExplorerConfig=E.defineExplorerConfig;exports.explorerHref=E.explorerHref;exports.isExplorerSourceId=E.isExplorerSourceId;exports.resolveExplorerLocation=E.resolveExplorerLocation;exports.withExplorerSources=E.withExplorerSources;exports.DEFAULT_DENIED_PATH_SEGMENTS=_.DEFAULT_DENIED_PATH_SEGMENTS;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_.EXPLORER_EDIT_TOKEN_MAX_LENGTH;exports.EXPLORER_FAILURE_REASONS=_.EXPLORER_FAILURE_REASONS;exports.EXPLORER_MAX_HEADINGS=_.EXPLORER_MAX_HEADINGS;exports.MAX_DOCUMENT_PATH_LENGTH=_.MAX_DOCUMENT_PATH_LENGTH;exports.failureDocument=_.failureDocument;exports.failureOf=_.failureOf;exports.isAcceptableDocumentPath=_.isAcceptableDocumentPath;exports.isDeniedPath=_.isDeniedPath;exports.isExplorerChildrenResult=_.isExplorerChildrenResult;exports.isExplorerFailureCode=_.isExplorerFailureCode;exports.isExplorerFailureReason=_.isExplorerFailureReason;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./index-DgaTEKsI.cjs"),e=require("./storage-DM0EvkVf.cjs"),E=require("./location-l_HysaZR.cjs"),_=require("./dataRoute-DwYtgyt6.cjs");exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=L.DEFAULT_MARKDOWN_EXPLORER_LOCALE;exports.EXPLORER_THEMES=L.EXPLORER_THEMES;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=L.MARKDOWN_EXPLORER_LABEL_CATALOGS;exports.MARKDOWN_EXPLORER_LABEL_KEYS=L.MARKDOWN_EXPLORER_LABEL_KEYS;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=L.MARKDOWN_EXPLORER_LABEL_TEMPLATES;exports.MARKDOWN_EXPLORER_LOCALES=L.MARKDOWN_EXPLORER_LOCALES;exports.MarkdownExplorer=L.MarkdownExplorer;exports.resolveMarkdownExplorerLabels=L.resolveMarkdownExplorerLabels;exports.shouldRevalidateExplorer=L.shouldRevalidateExplorer;exports.clearExplorerStorage=e.clearExplorerStorage;exports.COLUMN_MIN_MEASURE=E.COLUMN_MIN_MEASURE;exports.DEFAULT_TREE_SETTINGS=E.DEFAULT_TREE_SETTINGS;exports.DEFAULT_VIEW_SLUGS=E.DEFAULT_VIEW_SLUGS;exports.EXPAND_ALL_DEPTH_LIMITS=E.EXPAND_ALL_DEPTH_LIMITS;exports.EXPAND_ALL_FOLDER_LIMITS=E.EXPAND_ALL_FOLDER_LIMITS;exports.EXPLORER_DEFAULT_PERCENT=E.EXPLORER_DEFAULT_PERCENT;exports.EXPLORER_MAX_PERCENT=E.EXPLORER_MAX_PERCENT;exports.EXPLORER_MIN_REM=E.EXPLORER_MIN_REM;exports.EXPLORER_MULTI_DEFAULT_PERCENT=E.EXPLORER_MULTI_DEFAULT_PERCENT;exports.GOLDEN_RATIO=E.GOLDEN_RATIO;exports.MULTI_VIEW_COLUMN_LIMITS=E.MULTI_VIEW_COLUMN_LIMITS;exports.MULTI_VIEW_PANEL_LIMITS=E.MULTI_VIEW_PANEL_LIMITS;exports.REVEAL_DOCUMENT_DEPTH_LIMITS=E.REVEAL_DOCUMENT_DEPTH_LIMITS;exports.SPREADSHEET_BYTE_LIMITS=E.SPREADSHEET_BYTE_LIMITS;exports.WORKBOOK_BYTE_LIMITS=E.WORKBOOK_BYTE_LIMITS;exports.defineExplorerConfig=E.defineExplorerConfig;exports.explorerHref=E.explorerHref;exports.isExplorerSourceId=E.isExplorerSourceId;exports.resolveExplorerLocation=E.resolveExplorerLocation;exports.withExplorerSources=E.withExplorerSources;exports.DEFAULT_DENIED_PATH_SEGMENTS=_.DEFAULT_DENIED_PATH_SEGMENTS;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_.EXPLORER_EDIT_TOKEN_MAX_LENGTH;exports.EXPLORER_FAILURE_REASONS=_.EXPLORER_FAILURE_REASONS;exports.EXPLORER_MAX_HEADINGS=_.EXPLORER_MAX_HEADINGS;exports.MAX_DOCUMENT_PATH_LENGTH=_.MAX_DOCUMENT_PATH_LENGTH;exports.failureDocument=_.failureDocument;exports.failureOf=_.failureOf;exports.isAcceptableDocumentPath=_.isAcceptableDocumentPath;exports.isDeniedPath=_.isDeniedPath;exports.isExplorerChildrenResult=_.isExplorerChildrenResult;exports.isExplorerFailureCode=_.isExplorerFailureCode;exports.isExplorerFailureReason=_.isExplorerFailureReason;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { a0 as _, a1 as L, a2 as s, a3 as R, a4 as e, a5 as r, a6 as T, a7 as A, a8 as o } from "./index-awodBw8r.js";
1
+ import { a4 as _, a5 as L, a6 as s, a7 as R, a8 as e, a9 as r, aa as T, ab as A, ac as o } from "./index-auQVKY4M.js";
2
2
  import { c as O } from "./storage-CmGHg7OA.js";
3
- import { Y as D, Z as P, _ as S, $ as N, a0 as l, B as i, A as X, a1 as p, D as x, M as U, a2 as t, a3 as C, a4 as f, a5 as F, a6 as c, a7 as n, e as u, i as H, h as d, w as G } from "./location-CKuabtKl.js";
4
- import { F as W, Y as B, Z as h, E as m, M as Y, B as w, f as V, i as b, G as v, Q as g, c as k, b as Z } from "./dataRoute-DLhQfdoW.js";
3
+ import { Y as D, Z as P, _ as S, $ as N, a0 as l, B as i, A as X, a1 as p, D as x, M as U, a2 as t, a3 as C, a4 as c, a5 as f, a6 as F, a7 as n, e as u, i as H, h as d, w as G } from "./location-CKuabtKl.js";
4
+ import { F as W, Y as B, Z as h, E as m, M as Y, B as b, f as w, i as V, G as v, Q as g, c as k, b as Z } from "./dataRoute-DLhQfdoW.js";
5
5
  export {
6
6
  D as COLUMN_MIN_MEASURE,
7
7
  W as DEFAULT_DENIED_PATH_SEGMENTS,
@@ -27,15 +27,15 @@ export {
27
27
  t as MULTI_VIEW_COLUMN_LIMITS,
28
28
  C as MULTI_VIEW_PANEL_LIMITS,
29
29
  T as MarkdownExplorer,
30
- f as REVEAL_DOCUMENT_DEPTH_LIMITS,
31
- F as SPREADSHEET_BYTE_LIMITS,
32
- c as WORKBOOK_BYTE_LIMITS,
30
+ c as REVEAL_DOCUMENT_DEPTH_LIMITS,
31
+ f as SPREADSHEET_BYTE_LIMITS,
32
+ F as WORKBOOK_BYTE_LIMITS,
33
33
  O as clearExplorerStorage,
34
34
  n as defineExplorerConfig,
35
35
  u as explorerHref,
36
- w as failureDocument,
37
- V as failureOf,
38
- b as isAcceptableDocumentPath,
36
+ b as failureDocument,
37
+ w as failureOf,
38
+ V as isAcceptableDocumentPath,
39
39
  v as isDeniedPath,
40
40
  g as isExplorerChildrenResult,
41
41
  k as isExplorerFailureCode,
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node-diff3"),r=require("./index-CnX313Ss.cjs"),R=(n,t,i,l)=>{if(t===n||t===i)return{kind:"clean",text:i};if(i===n)return{kind:"clean",text:t};const d=g.diff3Merge(t.split(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node-diff3"),r=require("./index-DgaTEKsI.cjs"),R=(n,t,i,l)=>{if(t===n||t===i)return{kind:"clean",text:i};if(i===n)return{kind:"clean",text:t};const d=g.diff3Merge(t.split(`
2
2
  `),n.split(`
3
3
  `),i.split(`
4
4
  `),{excludeFalseConflicts:!0}),o=[];let c=0;const u=s(l.ours),a=s(l.theirs);for(const e of d)e.ok!==void 0?o.push(...e.ok):e.conflict!==void 0&&(c+=1,o.push(`${r.CONFLICT_OURS_MARKER} ${u}`,...e.conflict.a,r.CONFLICT_SEPARATOR,...e.conflict.b,`${r.CONFLICT_THEIRS_MARKER} ${a}`));const f=o.join(`
@@ -1,5 +1,5 @@
1
1
  import { diff3Merge as d } from "node-diff3";
2
- import { C, a as R, b as u } from "./index-awodBw8r.js";
2
+ import { C, a as R, b as u } from "./index-auQVKY4M.js";
3
3
  const g = (n, o, e, l) => {
4
4
  if (o === n || o === e) return { kind: "clean", text: e };
5
5
  if (e === n) return { kind: "clean", text: o };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("@aiquants/virtualscroll"),e=require("./index-CnX313Ss.cjs"),L=Object.freeze({renderVisual:C.tapScrollCircleSampleVisual,...e.TAP_SCROLL_CIRCLE_SPEED_RANGE,size:e.TAP_SCROLL_CIRCLE_SIZE,offsetX:e.TAP_SCROLL_CIRCLE_OFFSET_X}),_=Object.freeze({enabled:!1});exports.NO_TAP_SCROLL_CIRCLE=_;exports.TAP_SCROLL_CIRCLE=L;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("@aiquants/virtualscroll"),e=require("./index-DgaTEKsI.cjs"),L=Object.freeze({renderVisual:C.tapScrollCircleSampleVisual,...e.TAP_SCROLL_CIRCLE_SPEED_RANGE,size:e.TAP_SCROLL_CIRCLE_SIZE,offsetX:e.TAP_SCROLL_CIRCLE_OFFSET_X}),_=Object.freeze({enabled:!1});exports.NO_TAP_SCROLL_CIRCLE=_;exports.TAP_SCROLL_CIRCLE=L;
@@ -1,5 +1,5 @@
1
1
  import { tapScrollCircleSampleVisual as e } from "@aiquants/virtualscroll";
2
- import { T as C, c as _, d as L } from "./index-awodBw8r.js";
2
+ import { T as C, c as _, d as L } from "./index-auQVKY4M.js";
3
3
  const s = Object.freeze({
4
4
  renderVisual: e,
5
5
  ...L,
@@ -117,7 +117,7 @@ Documents in the multi-panel view sit in `multiView.columns` logical columns (4
117
117
  A panel opened or closed from the explorer is announced once the URL it wrote has rendered: in the sheet that navigation closes the sheet, so the root's region speaks it instead of the closing sheet's; when several toggles render as one navigation (a fast double-click), each is still announced, in order. Picking a hidden panel's document shows the panel without changing the URL (hidden panels live in browser storage), so the view closes the sheet itself and the root's region speaks `panelShown` once it has closed: every pick that changes the stage closes the sheet.
118
118
  A panel that a pick opened or showed is then brought into the stage's view by the least distance, without moving the focus (a pick in the split leaves the focus on the tree row, so the reader keeps picking): in a crowded stage it would otherwise sit below the fold, where the pick changes nothing the reader sees and a second click on the same row closes a panel they never saw.
119
119
  A panel is always brought into view whole — its header with the title and buttons, and its body — and kept there, with the focus a restore left in it, while the stage settles around it (its own document arriving, an image loading in a panel above it once the scroll brought that panel near, the restored document's text wrapping again), until the reader's next key, press, wheel or touch anywhere on the page, or until the stage, the panel's scroll area or the page is scrolled to a place these reveals did not leave it at (assistive technology's browse mode,
120
- the browser's find bar or a script moved it).
120
+ the browser's find bar or a script moved it). Meanwhile scroll anchoring is off in the scroll containers around what is kept (`overflow-anchor: none`, restored when the keeping ends): the browser's adjustment holds a node of its own choosing, and it would be such a scroll.
121
121
  - **Maximized panels.** A maximized panel covers the stage and the explorer, and everything of the explorer it covers is inert until it is restored: the explorer makes its own side inert — the explorer and its handle (or, in sheet mode, the sheet's bar) — and drag-drop-panels everything else it renders — the other panels, the bar of hidden panels, the drop placeholders and its announcer. Tab and Shift+Tab therefore never land on the explorer's hidden controls, and Enter or Space never acts on one.
122
122
  The host's own chrome is not the explorer's to make inert: what the panel covers of it stays focusable, so a host binds `--aqdd-maximize-*` to keep its chrome uncovered (the demo binds `--aqdd-maximize-top` to its header) or makes it inert while the maximized panel's frame carries `data-aqmx-maximized="true"` (see the README's "Load the styles").
123
123
  Escape restores the panel only when nothing else used the key: drag-drop-panels ignores an Escape another handler marked handled (`preventDefault()`), one that belongs to an input method's composition, one pressed inside an open dialog, and one pressed while a popover the browser closes on Escape is open.
@@ -150,6 +150,8 @@ Documents in the multi-panel view sit in `multiView.columns` logical columns (4
150
150
  A document shown in place of another, or the first one a pane shows, is aligned once its viewer has measured its toolbar and reserved that band (within the same task, before the next paint): the band's padding, added later, would push the element down by its depth where the page or a panel's scroll area scrolls the document.
151
151
  A footnote reference the reader has scrolled to within that distance of the edge of a sideways-scrolling table keeps that side of its ring cut when it takes the focus: Chromium does not scroll an element that is already visible, scroll margin or not, and a ring drawn inside the reference would cover its glyph.
152
152
  As the browser does for a fragment of its own, what hides the element is revealed first: a closed `details` around it opens (unless the element is in its summary) and a `hidden="until-found"` ancestor gets a `beforematch` event and is shown. An element that still has no box (inside `display: none`) does not move its pane.
153
+ The element then stays at that start while what is laid out before it settles, in every view — web fonts, images, math and diagrams that arrive after the jump change the heights before it: it is aligned again whenever it or anything laid out before it in its scroller changes size, until the reader's next key, press, wheel or touch anywhere on the page, until a scroller the alignment moved is scrolled to a place it did not leave it at, or until the next jump.
154
+ Meanwhile scroll anchoring is off around it, as for a panel kept in view: the browser's adjustment would hold the block that peeks into the element's scroll margin instead.
153
155
  In the multi view the panel then comes into the stage's view with the element, its header first, and both stay there while the stage settles, as for a panel brought into view (see [The multi-panel stage](#the-multi-panel-stage)): the stage moves only when part of the panel is out of its view, and never to take the element to the stage's start.
154
156
  - A fragment that names no element of the pane but HTML's top of the document — the empty fragment (`#`), or one that decodes to `top` in any ASCII case (`#top`, `#TOP`) — takes the pane's own scroller to its beginning in both axes at once, and the scrollers around it show that scroller by the least distance (in the multi view the panel comes into the stage's view); the element the fragment indicates — an element with the id `top`, or an `<a name="top">` — is still that fragment's element, as above.
155
157
  As in HTML, the top of the document is no element: the focus and the sequential focus navigation starting point stay on the link the reader activated (Chromium leaves them there too).
@@ -321,7 +323,7 @@ Space needs no such rule on buttons, which act when the key is released, and a t
321
323
  - The tree's virtual scrolling renders 13 rows beyond each edge and reports scrolling at most every 13 ms. Its 8 px scroll bar does not grow under a coarse pointer (the wheel, touch drag and the tree's arrow keys scroll the same list), and its arrow buttons are not Tab stops. The arrow keys, Home and End keep the focused row wholly visible: when the focus moves onto a row outside the tree's window, the tree scrolls by exactly the distance needed.
322
324
  - Every scroller the reader browses scrolls natively, with an 8 px pointer scroll bar beside it in place of the native vertical scrollbar: the document of the tree and single views (`@aiquants/markdown`'s `renderScrollBar`), an image's canvas, a medium's and a file view's stage and a failure view there (`@aiquants/markdown`'s `HostedScrollArea`), each multi-view panel's scroll area (drag-drop-panels' `renderPanelScrollArea`) and the multi view's stage (`renderStageScrollBar`).
323
325
  Every bar but the stage's carries the same tap-scroll circle as the tree's bar; every bar shows only while its content overflows, is hidden from assistive technology and has no Tab stops, so the keyboard, the wheel and touch scroll the scroller itself; a zoomed image keeps its native horizontal scrollbar.
324
- The tables' grids draw their circle in the same look and speeds (the look loads on first use, as the bars' module does): a table file's preview one control wide, a document's table half a control wide and only where its options say `tapscroll=1`. Inside a multi-view panel the document and the image, media, file and failure views grow to their content and have no bar of their own: the panel's area scrolls.
326
+ The tables' grids draw their circle in the same look and speeds (the look loads on first use, as the bars' module does): a table file's preview one control wide, a document's table 24 px wide (WCAG 2.5.8's minimum target, from markdown 11.8.2) and only where its options say `tapscroll=1`. Inside a multi-view panel the document and the image, media, file and failure views grow to their content and have no bar of their own: the panel's area scrolls.
325
327
  The circle is one control wide (44 px) and sits 49 px before its bar, centred in a 54 px gutter (the circle and 5 px on each side) that every document scroller with a circle keeps at its inline end, outside its own padding: the document's scroll container (`@aiquants/markdown`'s `scrollBarGutter`), the image, media, file and failure views, and each multi-view panel's area.
326
328
  No content (a diagram's or a table's toolbar, a code block's copy button, a focused link) lies under the circle at any scroll position; only an image zoomed wider than its canvas passes beneath it while it pans sideways. The wheel and touch scroll over the gutter as over the rest of the document.
327
329
  The gutter is kept while the content fits as well, as the native scrollbar's room is, so the text never re-wraps when the bar appears. The tree's rows reach under the tree's circle: a gutter there would take 54 px from a pane as narrow as 13rem.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiquants/markdown-explorer",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "Markdown document explorer for React Router 8 (framework mode): a source tree with a single-document view and a multi-panel reading view, storage-agnostic server ports, golden-ratio layout and an en / ja UI.",
5
5
  "sideEffects": [
6
6
  "**/*.css"
@@ -70,9 +70,9 @@
70
70
  "peerDependencies": {
71
71
  "@aiquants/directory-tree": "^5.0.1",
72
72
  "@aiquants/drag-drop-panels": "^0.12.0",
73
- "@aiquants/markdown": "^11.8.0",
73
+ "@aiquants/markdown": "^11.8.2",
74
74
  "@aiquants/resize-panels": "^2.2.0",
75
- "@aiquants/spreadsheet": "^0.18.0",
75
+ "@aiquants/spreadsheet": "^0.18.1",
76
76
  "@aiquants/virtualscroll": "^3.22.1",
77
77
  "react": "^19.2.7",
78
78
  "react-dom": "^19.2.7",
@@ -81,9 +81,9 @@
81
81
  "devDependencies": {
82
82
  "@aiquants/directory-tree": "5.0.1",
83
83
  "@aiquants/drag-drop-panels": "0.12.0",
84
- "@aiquants/markdown": "11.8.0",
84
+ "@aiquants/markdown": "11.8.2",
85
85
  "@aiquants/resize-panels": "2.2.0",
86
- "@aiquants/spreadsheet": "0.18.0",
86
+ "@aiquants/spreadsheet": "0.18.1",
87
87
  "@aiquants/virtualscroll": "3.22.1",
88
88
  "@heroicons/react": "^2.2.0",
89
89
  "@playwright/test": "^1.59.1",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react/jsx-runtime"),a=require("react"),j=require("./location-l_HysaZR.cjs"),R=require("./index-CnX313Ss.cjs"),oe=require("./ExplorerSplit-B99KbYXc.cjs"),D=require("@aiquants/drag-drop-panels"),me=require("react-router"),ee=require("./storage-DM0EvkVf.cjs"),Ce=require("./dataRoute-DwYtgyt6.cjs"),Be=require("react-dom"),je=require("@aiquants/markdown"),Fe=()=>{const e=new Map;return{hold:(n,t)=>{e.set(n,t),queueMicrotask(()=>{e.get(n)===t&&e.delete(n)})},take:n=>{const t=e.get(n);return e.delete(n),t===void 0?null:t}}},be=a.createContext(null),le=()=>{const e=a.use(be);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},Ve=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},Ue=0xcbf29ce484222325n,$e=0x100000001b3n,Ge=(1n<<64n)-1n,Ye=(1n<<53n)-1n,We=new TextEncoder,Ke=e=>{let n=Ue;for(const t of We.encode(e))n=(n^BigInt(t))*$e&Ge;return Number(n&Ye)},Z=256,Je=e=>`aqmx-p-${Ke(e).toString(36)}`,Pe=(e,n)=>{const t=Je(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Xe=new Map,Ze=(e,n=Xe)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??Pe(r,t);t.add(s),o.set(r,s)}return o},Te=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},Le=(e,n)=>{const[t,...o]=j.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([u,f])=>e.slice(u,f).reduce((l,y)=>l+y.length,0);let s=t;for(const u of o)r(u)<r(s)&&(s=u);let c=s[0];for(let u=s[0];u<s[1];u+=1)(e[u]?.length??0)<(e[c]?.length??0)&&(c=u);return c},Q=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Te(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[Le(t,n)]?.push(r);return t},Qe=(e,n)=>j.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),en=(e,n,t)=>{const[o,r]=n,s=r-o,c=e.length,u=Array.from({length:s},(E,m)=>{const v=[0];for(const p of e)v.push((v.at(-1)??0)+(t(p)===o+m?1:0));return v}),f=(E,m,v)=>(u[E]?.[v]??0)-(u[E]?.[m]??0),l=Array.from({length:s+1},()=>Array.from({length:c+1},()=>Number.NEGATIVE_INFINITY)),y=Array.from({length:s+1},()=>Array.from({length:c+1},()=>0)),w=l[0];w&&(w[0]=0);for(let E=0;E<s;E+=1)for(let m=0;m<=c;m+=1)for(let v=0;v<=m;v+=1){const p=(l[E]?.[v]??Number.NEGATIVE_INFINITY)+f(E,v,m),P=l[E+1],L=y[E+1];P&&L&&p>(P[m]??Number.NEGATIVE_INFINITY)&&(P[m]=p,L[m]=v)}const C=Array.from({length:s},()=>[]);let k=c;for(let E=s;E>0;E-=1){const m=y[E]?.[k]??0;C[E-1]=e.slice(m,k),k=m}return C},Me=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const c of s)o.delete(c),o.set(c,r);for(const r of o.keys()){if(o.size<=Z)break;o.delete(r)}return{docs:t,columnOf:o}},nn=(e,n,t,o)=>{if(e.docs.includes(n))return{state:e,outcome:"existing"};if(e.docs.length>=o)return{state:e,outcome:"rejected"};const r=Q(e,t),s=Te(e,n,t.logical)??Le(r,t);r[s]?.push(n);const c=new Map(e.panelIds);return c.set(n,Pe(n,new Set(c.values()))),{state:{...e,...Me(e,r),panelIds:c},outcome:"opened"}},Re=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Set(e.markup);o.delete(n);const r=new Map(e.panelIds);return r.delete(n),{...e,docs:e.docs.filter(s=>s!==n),hidden:t,markup:o,panelIds:r,maximized:e.maximized===n?null:e.maximized}},tn=(e,n,t,o)=>{if(e.hidden.has(n))return{state:ke(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Re(e,n),outcome:"closed"};const r=nn(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},on=(e,n,t)=>{if(n===t||!e.docs.includes(n))return{state:e,outcome:"ignored"};if(e.docs.includes(t))return{state:e,outcome:"existing"};const o=new Map(e.columnOf),r=o.get(n);r!==void 0&&(o.delete(t),o.set(t,r));const s=new Set(e.hidden);s.delete(n);const c=new Map(e.panelIds),u=c.get(n);if(u===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);c.delete(n),c.set(t,u);const f=new Set(e.markup);return f.delete(n),{state:{docs:e.docs.map(l=>l===n?t:l),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,markup:f,panelIds:c},outcome:"navigated"}},ke=(e,n,t)=>{if(!e.docs.includes(n)||e.hidden.has(n)===t)return e;const o=new Set(e.hidden);return t?o.add(n):o.delete(n),{...e,hidden:o,maximized:t&&e.maximized===n?null:e.maximized}},rn=(e,n,t)=>{if(!e.docs.includes(n)||e.markup.has(n)===t)return e;const o=new Set(e.markup);return t?o.add(n):o.delete(n),{...e,markup:o}},sn=(e,n)=>{if(e.maximized===n||n!==null&&!e.docs.includes(n))return e;if(n===null||!e.hidden.has(n))return{...e,maximized:n};const t=new Set(e.hidden);return t.delete(n),{...e,maximized:n,hidden:t}},ln=(e,n,t)=>{const o=Q(e,t),r=new Map;for(const[l,y]of o.entries())for(const w of y)r.set(w,l);const s=new Set(e.docs),c=new Set,u=j.columnGroups(t.logical,t.visible),f=Array.from({length:t.logical},()=>[]);for(const[l,y]of u.entries()){const w=(n[l]??[]).filter(C=>s.has(C)&&!c.has(C));for(const C of w)c.add(C);for(const[C,k]of en(w,y,E=>r.get(E)).entries())f[y[0]+C]?.push(...k)}for(const l of e.docs)c.has(l)||f[r.get(l)??0]?.push(l);return f.every((l,y)=>l.length===o[y]?.length&&l.every((w,C)=>o[y]?.[C]===w))?e:{...e,...Me(e,f)}},ne=(e,n)=>{const t=[...new Set(e.docs)].slice(0,n),o=new Set(t),r=e.maximized!==null&&o.has(e.maximized)?e.maximized:null;return{docs:t,maximized:r,columnOf:e.stored.columnOf,hidden:new Set([...e.stored.hidden].filter(s=>o.has(s)&&s!==r)),markup:new Set(e.markup.filter(s=>o.has(s))),panelIds:Ze(t,e.panelIds)}},fe=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of Q(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=Z)break;t.delete(o)}return{...e,columnOf:t}},Ne=1,U=Object.freeze({columnOf:new Map,hidden:new Set}),cn=(e,n)=>{if(e===null||e==="")return U;let t;try{t=JSON.parse(e)}catch{return U}if(t===null||typeof t!="object"||Array.isArray(t))return U;const o=t;if(o.v!==Ne)return U;const r=new Map;if(Array.isArray(o.columnOf))for(const c of o.columnOf.slice(-Z))Array.isArray(c)&&c.length===2&&typeof c[0]=="string"&&c[0]!==""&&Number.isInteger(c[1])&&c[1]>=0&&c[1]<n&&(r.delete(c[0]),r.set(c[0],c[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(c=>typeof c=="string"&&c!==""):[]);return{columnOf:r,hidden:s}},an=e=>JSON.stringify({v:Ne,columnOf:[...e.columnOf.entries()].slice(-Z),hidden:e.docs.filter(n=>e.hidden.has(n))}),ie=(e,n)=>{const t=e.get(n);return t===void 0?Ce.lastPathSegment(n):t},Y=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},pe=e=>{if(!Ce.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(e.slice(0,80))}`)},un=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,c=R.createEmitter(),u=new Map,f=new Map;let l={layout:ne({docs:n.docs,maximized:n.maximized,markup:n.markup,stored:U},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},y=!1;const w=i=>y?fe(i,{logical:s,visible:l.visibleColumns}):i,C=(i,g)=>j.explorerHref(e,{view:"multi",source:i,docs:g.docs,maximized:g.maximized,markup:g.markup}),k=i=>({docs:i.docs,maximized:i.maximized,markup:[...i.markup]});let E=C(n.source,n),m=n.source,v=E;const p=[],P=[];let L=null;const A=()=>{if(!(p.length>0))for(const i of P.splice(0))i()},d=i=>{l={...l,...i},c.emit()},S=()=>{if(!l.ready)return;const i=an(l.layout);i!==L&&(L=i,o(i))},h=(i,g,T)=>{const _=C(i,k(g));_!==E&&(E=_,m=i,p.push(_),t(_,T))},x=i=>{const g=new Set(i.panelIds.values());for(const b of[...u.keys()])g.has(b)||u.delete(b);for(const b of[...f.keys()])g.has(b)||f.delete(b);const T=new Set(i.docs),_=[...l.titles.keys()].every(b=>T.has(b))?l.titles:new Map([...l.titles].filter(([b])=>T.has(b))),O=[...l.pendingHashes.keys()].every(b=>g.has(b))?l.pendingHashes:new Map([...l.pendingHashes].filter(([b])=>g.has(b)));return{titles:_,pendingHashes:O}},N=i=>i===l.layout?!1:(d({layout:i,...x(i)}),h(m,i,"replace"),S(),!0),I=()=>({logical:s,visible:l.visibleColumns});return{getSnapshot:()=>l,subscribe:c.subscribe,toggle:i=>{pe(i);const{state:g,outcome:T}=tn(l.layout,i,I(),r);return N(g),T},close:i=>N(Re(l.layout,i)),navigate:(i,g)=>{pe(g);const{state:T,outcome:_}=on(l.layout,i,g);if(_!=="navigated")return _;const O=T.panelIds.get(g);return O!==void 0&&(u.delete(O),f.delete(O)),N(T),_},setHidden:(i,g)=>N(ke(l.layout,i,g)),maximize:i=>N(sn(l.layout,i)),setMarkup:(i,g)=>N(rn(l.layout,i,g)),arrange:i=>N(ln(l.layout,i,{logical:s,visible:i.length})),changeSource:i=>{h(i,l.layout,"push")},revealSource:i=>{h(i,l.layout,"replace")},observeLocation:i=>{const g=C(i.source,i);if(g===E)return p.length=0,v=g,i.source!==l.source&&d({source:i.source}),A(),!1;if(g===v)return!1;v=g;const T=p.indexOf(g);if(T>=0)return p.splice(0,T+1),i.source!==l.source&&d({source:i.source}),A(),!1;p.length=0,E=g,m=i.source;const _=w(ne({docs:i.docs,maximized:i.maximized,markup:i.markup,stored:{columnOf:l.layout.columnOf,hidden:l.layout.hidden},panelIds:l.layout.panelIds},r));return d({layout:_,source:i.source,...x(_)}),S(),A(),!0},whenUrlRendered:i=>{P.push(i),A()},loadStored:i=>{d({layout:w(ne({docs:l.layout.docs,maximized:l.layout.maximized,markup:[...l.layout.markup],stored:i,panelIds:l.layout.panelIds},r)),ready:!0}),S()},setVisibleColumns:i=>{if(!Number.isInteger(i)||i<1||i>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${String(i)}`);y=!0;const g=fe(l.layout,{logical:s,visible:i});i===l.visibleColumns&&g===l.layout||(d({visibleColumns:i,layout:g}),g!==l.layout&&S())},setSplitDragging:i=>{i!==l.splitDragging&&d({splitDragging:i})},setTitle:(i,g)=>{!l.layout.docs.includes(i)||l.titles.get(i)===g||d({titles:new Map(l.titles).set(i,g)})},titleOf:i=>ie(l.titles,i),setPendingHash:(i,g)=>{const T=l.pendingHashes.get(i);if(g===null||g===""){if(T===void 0)return;const _=new Map(l.pendingHashes);_.delete(i),d({pendingHashes:_});return}T!==g&&d({pendingHashes:new Map(l.pendingHashes).set(i,g)})},saveReadingPosition:(i,g,T)=>{l.layout.panelIds.get(g)===i&&u.set(i,{doc:g,position:T})},readingPositionOf:(i,g)=>{const T=u.get(i);return T===void 0||T.doc!==g?null:T.position},saveImageView:(i,g,T)=>{f.set(i,{url:g,state:T})},imageViewOf:(i,g)=>{const T=f.get(i);return T===void 0||T.url!==g?null:T.state}}},z=(e,n)=>{const t=()=>n(e.getSnapshot());return a.useSyncExternalStore(e.subscribe,t,t)},dn=e=>{const{config:n,storageNamespace:t}=R.useExplorer(),o=me.useNavigate(),r=a.useRef(o),s=ee.storageKeys(t).multiLayout,[c]=a.useState(()=>un({config:n,location:e,writeUrl:(l,y)=>{r.current(l,R.explorerNavigationOptions(y==="replace"?"browse":"switch-source"))},persist:l=>ee.writeStorage(s,l)}));a.useLayoutEffect(()=>{r.current=o},[o]);const u=me.useLocation(),f=a.useMemo(()=>({location:e,navigated:u}),[e,u]);return a.useLayoutEffect(()=>{c.observeLocation(f.location)},[c,f]),a.useLayoutEffect(()=>{c.loadStored(cn(ee.readStorage(s),n.multiView.columns))},[c,s,n]),c},mn=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);if(n===null)throw new Error("[markdown-explorer] a panel's document region is not inside the panel's scroll area");return n},fn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:c,revealInPanel:u}=le(),{announcer:f}=R.useExplorer(),l=z(s,d=>Ve(d,n)),y=z(s,d=>d.layout.markup.has(e)),w=a.useCallback((d,S)=>c(n,e,d,S),[c,n,e]),C=a.useCallback(()=>s.setPendingHash(n,null),[s,n]),k=a.useMemo(()=>({read:d=>s.imageViewOf(n,d),save:(d,S)=>s.saveImageView(n,d,S)}),[s,n]),E=a.useCallback((d,S)=>{S.kind!=="failure"&&s.setTitle(d,S.name),r(d)},[s,r]),m=a.useCallback(d=>{s.whenUrlRendered(()=>f.announce(d))},[s,f]),v=a.useMemo(()=>({scrollerOf:mn,reveal:d=>u(n,d)}),[u,n]),p=a.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:w,pendingHash:l,onHashConsumed:C,announceFailure:m,paneScroll:v}),[t,w,l,C,m,v]),P=a.useMemo(()=>({kind:"panel",documentName:o,maximized:t}),[o,t]),L=a.useCallback(()=>s.setMarkup(e,!s.getSnapshot().layout.markup.has(e)),[s,e]),A=a.useMemo(()=>({shown:y,toggle:L}),[y,L]);return M.jsxs(R.ImageViewMemoryContext,{value:k,children:[M.jsx(R.DocumentRefreshBar,{path:e,placement:P,markup:A}),M.jsx(R.DocumentPane,{path:e,absence:R.NO_DOCUMENT,markup:y,variant:p,onDocumentShown:E})]})},ge=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",ce="data-aqmx-column-probe",K="data-panel-id",re="--aqmx-multi-panel-chrome",pn=e=>e==="normal"?0:R.cssPixels(e),gn=(e,n)=>{const t=e.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${ce}]`),r=o instanceof HTMLElement?o.getBoundingClientRect().width:Number.NaN;if(!(t instanceof HTMLElement))return{plan:{trackInlineSize:Number.NaN,gap:Number.NaN,minColumnInlineSize:r,logicalColumns:n},stageBlockSize:Number.NaN};const s=getComputedStyle(t),c=t.clientWidth-R.cssPixels(s.paddingLeft)-R.cssPixels(s.paddingRight),u=t.clientHeight-R.cssPixels(s.paddingTop)-R.cssPixels(s.paddingBottom);return{plan:{trackInlineSize:c,gap:pn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:u}},hn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+R.cssPixels(t.paddingBottom)+R.cssPixels(t.borderBottomWidth)},J="data-aqmx-panel-frame",he="--aqmx-multi-panel-pinned-block-size",vn=e=>{const{docPath:n,panelId:t}=e;if(typeof n!="string"||typeof t!="string")throw new TypeError("[markdown-explorer] a multi-view panel needs string docPath and panelId props");return{docPath:n,panelId:t}},yn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},Sn=(e,n,t)=>e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*n.clientHeight:e.deltaMode!==WheelEvent.DOM_DELTA_LINE?e.deltaY:e.deltaY*t(n),$=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);return n instanceof HTMLElement?n:null},Ae=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},Ie=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ae(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},ve=(e,n)=>{let t=0,o=e.length;for(;t<o;){const r=t+o>>>1;(e[r]?.getBoundingClientRect().bottom??Number.NEGATIVE_INFINITY)>n?o=r:t=r+1}return t<e.length?t:-1},xn=(e,n)=>{const t=Ie(e,n),o=[];let r=e;for(let c=ve([...r.children],t);c>=0;c=ve([...r.children],t)){const u=r.children[c];if(u===void 0)break;o.push(c),r=u}const s=r.getBoundingClientRect();return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:s.top-t,height:s.height}}},ye=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const f of t.anchor.path)o=o?.children[f];if(o===void 0)return;const r=o.getBoundingClientRect(),{offset:s,height:c}=t.anchor,u=s<0&&c>0?s/c*r.height:s;n.scrollTop+=r.top-Ie(e,n)-u},wn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),_e=e=>{const n=e.getAttribute(D.PANEL_ACTION_ATTRIBUTE);return JSON.stringify(n===null?[e.tagName,...wn.map(t=>e.getAttribute(t))]:[e.tagName,D.PANEL_ACTION_ATTRIBUTE,n])},En=(e,n)=>{if(n===null||!e.contains(n))return null;const t=[];for(let o=n;o!==e;){const r=o.parentElement;if(r===null)return null;t.unshift([...r.children].indexOf(o)),o=r}return{path:t,signature:_e(n)}},On=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&_e(o)===t.signature&&R.focusWithoutScroll(o)||n.focus({preventScroll:!0})},Cn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?$(n):n.closest(D.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=Sn(e,r,t);(o||bn(r,s))&&(e.preventDefault(),r.scrollTop+=s)},bn=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,Pn=e=>e.scrollHeight>e.clientHeight,Tn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ae(t),c=()=>{const l=hn(e,n);if(!Number.isFinite(l))return;const y=s===null?0:s.getBoundingClientRect().height;y!==r&&(r=y,t.style.setProperty(he,`${String(y)}px`));const w=l+y;w!==o&&(o=w,e.style.setProperty(re,`${String(w)}px`))};c();let u=null;const f=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{u===null&&(u=requestAnimationFrame(()=>{u=null,c()}))});return f?.observe(e),f?.observe(n),s!==null&&f?.observe(s),()=>{f?.disconnect(),u!==null&&cancelAnimationFrame(u),e.style.removeProperty(re),t.style.removeProperty(he)}},Ln=e=>{const{docPath:n,panelId:t}=vn(e),{store:o,Body:r,maximize:s,focusCarry:c}=le(),u=z(o,m=>m.layout.maximized===n),f=z(o,m=>ie(m.titles,n)),l=a.useRef(null),y=a.useRef(null),w=a.useRef(null),C=a.useRef(null);a.useEffect(()=>{const m=l.current,v=m===null?null:$(m);if(m===null||v===null||u)return;const p=new Map,P=h=>{const x=p.get(h);if(x!==void 0)return x;const N=yn(h);return p.set(h,N),N},L=h=>Cn(h,m,P);let A=!1;const d=()=>{const h=Pn(v);h!==A&&(A=h,h?m.addEventListener("wheel",L,{capture:!0,passive:!1}):m.removeEventListener("wheel",L,{capture:!0}))};d();const S=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return S?.observe(v),S?.observe(m),()=>{S?.disconnect(),m.removeEventListener("wheel",L,{capture:!0})}},[u]),a.useLayoutEffect(()=>{const m=l.current,v=m===null?null:$(m),p=m===null?null:m.closest(`[${K}]`);if(!(m===null||v===null||!(p instanceof HTMLElement)))return Tn(p,v,m)},[]),a.useLayoutEffect(()=>{const m=l.current,v=m===null?null:$(m);if(m===null||v===null)return;const p=h=>{ye(m,v,h),C.current=v.scrollTop},P=o.readingPositionOf(t,n);y.current=P===null?null:{doc:n,position:P},P!==null&&p(P);let L=null,A=m.getBoundingClientRect().width;const d=()=>{L===null&&(L=requestAnimationFrame(()=>{L=null;const h=C.current;if(C.current=null,h!==null&&v.scrollTop===h||m.getBoundingClientRect().width!==A)return;const x=w.current;x!==null&&o.saveReadingPosition(t,x,xn(m,v))}))};v.addEventListener("scroll",d,{passive:!0});const S=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const h=m.getBoundingClientRect().width;if(h===A)return;A=h;const x=o.readingPositionOf(t,n);x!==null&&p(x)});return S?.observe(m),()=>{v.removeEventListener("scroll",d),S?.disconnect(),L!==null&&cancelAnimationFrame(L)}},[o,t,n]),a.useLayoutEffect(()=>{const m=l.current,v=m===null?null:m.closest(`[${K}]`);if(m===null||v===null)return;const p=c.take(t);return p!==null&&On(v,m,p),()=>{const P=En(v,v.ownerDocument.activeElement);P!==null&&c.hold(t,P)}},[c,t]);const k=a.useCallback(m=>{const v=l.current,p=v===null?null:$(v);if(v===null||p===null)return;const P=w.current;w.current=m;const L=y.current;y.current=null,L!==null&&L.doc===m?(ye(v,p,L.position),C.current=p.scrollTop):P!==null&&P!==m&&(p.scrollTop=0)},[]),E=a.useCallback(()=>s(n),[s,n]);return M.jsx("div",{ref:l,role:"group","aria-label":f,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":u?"true":"false","data-testid":"markdown-explorer-panel-frame",...u?R.CONTENT_PANE:{},onDoubleClick:u?void 0:E,children:M.jsx(r,{docPath:n,panelId:t,maximized:u,title:f,onContentShown:k})})},Mn=a.memo(Ln),W=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return t},Se=e=>Object.fromEntries(D.generateColumnIds(e).map(n=>[n,[]])),Rn=(e,n)=>{const t=Qe(Q(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>W(e,s))]))},kn=(e,n)=>{const t=Y(e);return D.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},Nn=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanel:e.panelMove,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,customDragModeBadge:e.panelCustomDragBadge,panelMoved:e.panelMoved,panelMoveUnavailable:e.panelMoveUnavailable,panelDragStarted:e.panelDragStarted,panelDragCancelled:e.panelDragCancelled,hiddenPanels:e.hiddenPanelsTitle,hiddenPanelBadge:e.hiddenPanelBadge,hiddenPanelNotice:e.hiddenPanelNotice,emptyColumn:e.multiColumnEmpty,dropZone:e.multiColumnRegion,dropHere:e.panelDropHere}),An="--aqmx-multi-stage-bar-gutter",In=Object.freeze({[An]:`${String(R.NATIVE_SCROLL_BAR_WIDTH)}px`}),_n=Object.freeze({blockSize:"100%",paddingInlineEnd:`${String(R.TAP_SCROLL_CIRCLE_GUTTER)}px`}),Dn=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),zn=e=>M.jsx("div",{...Dn,children:M.jsx(R.LazyNativeScrollBar,{scroller:e,withCircle:!0})}),Hn=({props:e,children:n})=>M.jsx(je.HostedScrollArea,{scrollerProps:{...e,style:_n},renderScrollBar:zn,children:n}),qn=e=>M.jsx(R.LazyNativeScrollBar,{scroller:e,withCircle:!1}),ae="--aqmx-stage-block",Bn="--aqmx-multi-panel-body-floor",jn=`calc(var(${ae}) * ${String(j.PANEL_MIN_BLOCK_RATIO)})`,Fn=`max(calc(var(${ae}) * ${String(j.PANEL_MAX_BLOCK_RATIO)}), calc(var(${re}) + var(${Bn})))`,Vn=(e,n)=>{const t=Object.entries(e);return t.length!==Object.keys(n).length?!1:t.every(([o,r])=>{const s=n[o];return s!==void 0&&s.length===r.length&&s.every((c,u)=>r[u]===c)})},xe=["keydown","pointerdown","wheel","touchstart"],G=new WeakMap,we=(e,n,t)=>{for(let o=n;o!==null&&o!==t;o=o.parentElement){e.observe(o);for(let r=o.previousElementSibling;r!==null;r=r.previousElementSibling)e.observe(r)}},Un=e=>{const n=new Map;for(let t=e.parentElement;t!==null;t=t.parentElement)n.set(t,{top:t.scrollTop,left:t.scrollLeft});return n},X=(e,n,t)=>{G.get(e)?.();const o=e.querySelector(`[${K}="${n}"]`);if(!(o instanceof HTMLElement))return;const r=t!==null&&o.contains(t)?t:null;let s=new Map;const c=()=>{if(!o.isConnected)return;o.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});const w=r?.isConnected===!0?r:o;w!==o&&w.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}),s=Un(w)};if(c(),typeof ResizeObserver>"u")return;const u=new ResizeObserver(c);we(u,o,o.closest(D.SCROLL_ROOT_SELECTOR)),r!==null&&we(u,r,o);const{ownerDocument:f}=e,l=w=>{const C=w.target===f?f.scrollingElement:w.target;if(!(C instanceof Element))return;const k=s.get(C);k!==void 0&&(C.scrollTop!==k.top||C.scrollLeft!==k.left)&&y()},y=()=>{u.disconnect();for(const w of xe)f.removeEventListener(w,y,!0);f.removeEventListener("scroll",l,!0),G.get(e)===y&&G.delete(e)};for(const w of xe)f.addEventListener(w,y,{capture:!0,passive:!0});f.addEventListener("scroll",l,{capture:!0,passive:!0}),G.set(e,y)},De=(e,n)=>{const t=e.querySelector(`[${J}="${n}"]`);return t instanceof HTMLElement?(X(e,n,null),t.focus({preventScroll:!0}),!0):!1},ue=(e,n)=>{const t=e.querySelector(`[${K}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},Ee=(e,n)=>{if(!ue(e,n))return null;const t=[...e.querySelectorAll(`[${J}]`)].map(c=>c.getAttribute(J)),o=t.indexOf(n),r=t[o+1];if(o>=0&&typeof r=="string")return{kind:"panel",panelId:r};const s=t[o-1];return o>0&&typeof s=="string"?{kind:"panel",panelId:s}:{kind:"stage"}},Oe=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&De(t,n.panelId)||t.focus({preventScroll:!0}))})},ze=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&De(t,n)})},$n=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(X(o,n,t&&ue(o,n)?r:null),!t||r!==null&&r!==s&&r.isConnected)return;const c=o.querySelector(`[${J}="${n}"]`);c instanceof HTMLElement&&c.focus({preventScroll:!0})})},Gn=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r,edits:s}=R.useExplorer(),{maximize:c}=le(),u=t.multiView.columns,f=z(e,O=>O.layout),l=z(e,O=>O.visibleColumns),y=z(e,O=>O.titles),w=z(e,O=>O.layout.maximized!==null||O.splitDragging),[C,k]=a.useState(!1),[E]=a.useState(()=>Se(l)),m=a.useMemo(()=>Nn(o),[o]),v=a.useCallback(O=>{e.arrange(kn(e.getSnapshot().layout,O))},[e]),p=D.useDragDropColumns({initialColumnPanels:E,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:v}),{columnPanels:P,setColumnPanels:L}=p,A=a.useRef(w),d=a.useRef(P);a.useLayoutEffect(()=>{A.current=w,d.current=P},[w,P]);const S=a.useCallback(O=>{const b=n.current;if(b===null)return;const{plan:B,stageBlockSize:H}=gn(b,u);if(Number.isFinite(H)&&H>0&&b.style.setProperty(ae,`${String(H)}px`),A.current&&!O)return;const q=j.replanVisibleColumns(e.getSnapshot().visibleColumns,B);q!==null&&e.setVisibleColumns(q)},[e,n,u]);a.useLayoutEffect(()=>{S(!0),k(!0)},[S]),a.useEffect(()=>{const O=n.current;if(O===null||typeof ResizeObserver>"u")return;let b=null;const B=new ResizeObserver(()=>{b===null&&(b=requestAnimationFrame(()=>{b=null,S(!1)}))}),H=O.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,q=O.querySelector(`[${ce}]`);return H instanceof Element&&B.observe(H),q instanceof Element&&B.observe(q),()=>{B.disconnect(),b!==null&&cancelAnimationFrame(b)}},[n,S]),a.useEffect(()=>{w||S(!1)},[w,S]);const h=a.useMemo(()=>C?Rn(f,{logical:u,visible:l}):Se(l),[C,f,u,l]);a.useLayoutEffect(()=>{Vn(d.current,h)||L(h)},[h,L]);const x=a.useMemo(()=>D.sortColumnIds(Object.keys(P)).map(O=>({id:O,key:O,className:"aqmx-multi-column"})),[P]),N=a.useMemo(()=>f.docs.map(O=>{const b=W(f,O);return{id:b,component:Mn,title:ie(y,O),props:{docPath:O,panelId:b},minHeight:jn,maxHeight:Fn}}),[f,y]),I=a.useMemo(()=>Object.fromEntries(f.docs.map(O=>[W(f,O),!f.hidden.has(O)])),[f]),i=f.maximized===null?null:W(f,f.maximized),g=a.useCallback(O=>{const{layout:b}=e.getSnapshot();for(const[B,H]of Y(b)){const q=O[B];if(q===void 0||q!==b.hidden.has(H))continue;const F=e.titleOf(H);if(q){if(!e.setHidden(H,!1))continue;r.announce(o.panelShown(F)),ze(n,B);continue}const V=n.current,de=V===null?null:Ee(V,B);e.setHidden(H,!0)&&(r.announce(o.panelHidden(F)),de!==null&&Oe(n,de))}},[e,n,r,o]),T=a.useCallback(O=>{const b=Y(e.getSnapshot().layout).get(O);if(b===void 0)return;const B=()=>{const q=e.titleOf(b),F=n.current,V=F===null?null:Ee(F,O);e.close(b)&&(r.announce(o.panelClosed(q)),V!==null&&Oe(n,V))},H=s.unsavedAmong([b]);H.length===0?B():s.askToDiscard(H).then(q=>{q&&B()})},[e,n,r,o,s]),_=a.useCallback(O=>{if(O===null){c(null);return}const b=Y(e.getSnapshot().layout).get(O);b!==void 0&&c(b)},[e,c]);return M.jsx("div",{className:"aqmx-multi-layout","aria-busy":!C,children:M.jsx(D.DragDropLayout,{columns:x,panels:N,columnPanels:P,onColumnPanelsChange:v,panelVisibility:I,onPanelVisibilityChange:g,dragState:p.dragState,dragOverPosition:p.dragOverPosition,originalPanelPosition:p.originalPanelPosition,dragModes:p.dragModes,debugConfig:D.DEFAULT_DEBUG_CONFIG,panelSizes:p.panelSizes,customDrag:p.customDrag,setPanelRef:p.setPanelRef,onDragStart:p.handleDragStart,onDragEnd:p.handleDragEnd,onPlaceholderDragEnter:p.handlePlaceholderDragEnter,onPlaceholderDragLeave:p.handlePlaceholderDragLeave,onDragOverWithInsert:p.handleDragOverWithInsert,onDropWithInsert:p.handleDropWithInsert,onColumnDragLeave:p.handleColumnDragLeave,onPanelMouseDown:p.handleMouseDown,onPanelSizeInfoClick:p.handlePanelSizeInfoClick,onToggleDragMode:p.toggleDragMode,onPanelClose:T,onPanelMaximizeChange:_,maximizedPanel:i,dragHandle:"header",labels:m,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:Hn,renderStageScrollBar:qn})})},te={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},Yn=(e,n)=>{const t=n.getBoundingClientRect(),o=[t.left+1,t.left+t.width/2,t.right-1],r=[t.top+1,t.top+t.height/2,t.bottom-1];return o.some(s=>r.some(c=>{const u=n.ownerDocument.elementsFromPoint(s,c),f=u.findIndex(y=>n.contains(y)),l=u.findIndex(y=>e.contains(y));return f!==-1&&l!==-1&&l<f}))},Wn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(te.blockStart,`${String(t.top)}px`),e.style.setProperty(te.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(te.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Kn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:c,announcer:u,edits:f}=R.useExplorer(),l=a.useRef(null),y=a.useRef(null),w=z(e,d=>d.ready),C=z(e,d=>d.layout.docs.length>0),k=z(e,d=>d.visibleColumns),E=a.use(oe.SheetNoticeSlotContext),m=a.useCallback(d=>{const{layout:S}=e.getSnapshot(),h=S.maximized,x=d===null&&h!==null?S.panelIds.get(h):void 0,N=l.current,I=x!==void 0&&N!==null&&ue(N,x);e.maximize(d)&&(d!==null?u.announce(c.panelMaximized(e.titleOf(d))):h!==null&&u.announce(c.panelRestored(e.titleOf(h))),x!==void 0&&$n(l,x,I))},[e,u,c]),v=a.useCallback((d,S,h,x)=>{if(h===S){e.setPendingHash(d,x);return}const N=f.unsavedAmong([S]);if(N.length>0){f.askToDiscard(N).then(T=>{T&&v(d,S,h,x)});return}const I=e.navigate(S,h);if(I==="navigated"){e.setPendingHash(d,x);return}if(I!=="existing")return;const{layout:i}=e.getSnapshot(),g=i.panelIds.get(h);g!==void 0&&(u.announce(c.panelAlreadyOpen(e.titleOf(h))),i.maximized===null?e.setHidden(h,!1):m(h),e.setPendingHash(g,x),ze(l,g))},[e,u,c,m,f]);a.useLayoutEffect(()=>{if(t===null||E!==null||!ge())return;const d=y.current,S=l.current;if(d===null||S===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return Wn(d,S)},[t,E]),a.useEffect(()=>{const d=y.current;if(t===null||d===null)return;const{ownerDocument:S}=d;let h=null;const x=N=>{const I=N.target;I instanceof Element&&(h!==null&&cancelAnimationFrame(h),h=requestAnimationFrame(()=>{h=null,S.activeElement===I&&d.isConnected&&Yn(d,I)&&o()}))};return S.addEventListener("focusin",x,!0),()=>{S.removeEventListener("focusin",x,!0),h!==null&&cancelAnimationFrame(h)}},[t,E,o]),a.useImperativeHandle(r,()=>({bringIntoView:d=>{requestAnimationFrame(()=>{const S=l.current,h=e.getSnapshot().layout.panelIds.get(d);S!==null&&h!==void 0&&X(S,h,null)})}}),[e]),a.useEffect(()=>{const d=l.current;return()=>{d!==null&&G.get(d)?.()}},[]);const p=a.useCallback((d,S)=>{const h=l.current;h!==null&&X(h,d,S)},[]),[P]=a.useState(Fe),L=a.useMemo(()=>({store:e,Body:n,followLink:v,maximize:m,revealInPanel:p,focusCarry:P}),[e,n,v,m,p,P]),A=a.useMemo(()=>Array.from({length:s.multiView.columns},(d,S)=>D.generateColumnId(S)),[s]);return M.jsxs("section",{ref:l,className:"aqmx-multi-stage",style:In,tabIndex:-1,"aria-label":c.multiRegion,"aria-busy":C&&!w,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":k,...R.CONTENT_PANE,children:[M.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[ce]:""}),C?w?M.jsx(be,{value:L,children:M.jsx(Gn,{store:e,stageRef:l})}):M.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:A.map(d=>M.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[M.jsx("span",{}),M.jsx("span",{}),M.jsx("span",{})]},d))}):M.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:M.jsx("p",{className:"aqmx-empty-title",children:c.multiEmpty})}),t===null?null:E!==null?Be.createPortal(M.jsx("div",{ref:y,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),E):M.jsx("div",{ref:y,popover:ge()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},He=3e3,qe=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},se=(e,n,t)=>{const o=new Set(e),r=n.filter(c=>!o.has(c)),s=r.length>0?r.at(-1):t!==null&&n.includes(t)?t:n.at(-1);return s===void 0?null:s},Jn=(e,n,t)=>{switch(n){case"opened":return e.panelOpened(t);case"shown":return e.panelShown(t);case"closed":return e.panelClosed(t);default:{const o=n;throw new RangeError(`[markdown-explorer] unknown toggle outcome ${JSON.stringify(o)}`)}}},Xn=({location:e})=>{const{config:n,labels:t,announcer:o}=R.useExplorer(),r=dn(e),s=z(r,x=>x.layout.docs),c=z(r,x=>x.layout.maximized),u=z(r,x=>x.layout.markup),f=z(r,x=>x.source),[l,y]=a.useState(()=>({docs:s,latest:se([],s,null)}));l.docs!==s&&y({docs:s,latest:se(l.docs,s,l.latest)});const w=c!==null?c:l.latest,[C,k]=a.useState(!1),E=a.useRef(null),[m,v]=a.useState(0),p=a.useRef(null),P=a.useRef(null);a.useLayoutEffect(()=>{const x=p.current;p.current=null,x!==null&&(r.whenUrlRendered(()=>o.announce(x.announcement)),P.current?.bringIntoView(x.doc))}),a.useEffect(()=>()=>{E.current!==null&&clearTimeout(E.current)},[]);const L=a.useCallback(()=>{E.current!==null&&clearTimeout(E.current),k(!0),E.current=setTimeout(()=>{E.current=null,k(!1)},He)},[]),A=a.useCallback(()=>{E.current!==null&&clearTimeout(E.current),E.current=null,k(!1)},[]),d=a.useCallback(x=>{const N=r.titleOf(x),I=r.toggle(x);I==="rejected"&&L();const i=I==="rejected"?t.panelLimit(n.multiView.maxPanels):Jn(t,I,N);if(I==="shown"){p.current={doc:x,announcement:i},v(g=>g+1);return}r.whenUrlRendered(()=>{o.announce(i),I==="opened"&&P.current?.bringIntoView(x)})},[r,L,o,t,n]),S=a.useMemo(()=>new Set(s),[s]),h=a.useMemo(()=>{const x=qe(s,c);return{href:j.explorerHref(n,{view:"tree",source:f,doc:x,markup:x!==null&&u.has(x)}),target:"tree"}},[n,f,s,c,u]);return M.jsx(oe.ExplorerSplit,{view:"multi",explorer:M.jsx(oe.ExplorerPane,{mode:"multi",sourceId:f,currentPath:w,openPaths:S,onOpenDocument:d,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:h}),content:M.jsx(Kn,{ref:P,store:r,body:fn,limitNotice:C?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:A}),contentCoversPage:c!==null,sheetDismissals:m,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Xn;exports.PANEL_LIMIT_NOTICE_MS=He;exports.latestOpenedDocument=se;exports.treeSwitchDocument=qe;