@aiquants/markdown-explorer 0.17.0 → 0.18.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +6 -5
  3. package/dist/{EditSurface-0owpPyLE.js → EditSurface-B2bzY1b_.js} +3 -3
  4. package/dist/{EditSurface-D-nhilRk.cjs → EditSurface-BRuIjA9L.cjs} +1 -1
  5. package/dist/{ExplorerSplit-bpEvHrCo.cjs → ExplorerSplit-BE1VJuok.cjs} +1 -1
  6. package/dist/{ExplorerSplit-8c93p1hy.js → ExplorerSplit-qAKZsLZa.js} +3 -3
  7. package/dist/{MultiLayout-BXfzR6XC.cjs → MultiLayout-Bc6RYc3U.cjs} +1 -1
  8. package/dist/{MultiLayout-Dy3DD_09.js → MultiLayout-rsmtFma5.js} +251 -247
  9. package/dist/{NativeScrollBar-CI9fTvkt.js → NativeScrollBar-Dq3YeUVY.js} +1 -1
  10. package/dist/{NativeScrollBar-Ddn0iHjv.cjs → NativeScrollBar-DqTkrnPZ.cjs} +1 -1
  11. package/dist/{TreeLayout-eFQmzpNj.js → TreeLayout-BPa7NdeT.js} +3 -3
  12. package/dist/{TreeLayout-CKZ-XQgn.cjs → TreeLayout-DXoEAcpD.cjs} +1 -1
  13. package/dist/core/geometry.d.cts +1 -1
  14. package/dist/core/geometry.d.ts +1 -1
  15. package/dist/core/labels.d.cts +1 -0
  16. package/dist/core/labels.d.ts +1 -0
  17. package/dist/{index-h9e3p5Pd.js → index-25s_q0vD.js} +7 -5
  18. package/dist/{index-5gwNJ8CB.cjs → index-W3iAjkLb.cjs} +4 -4
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +2 -2
  21. package/dist/{location-G7psbmv_.js → location-B-m9scLf.js} +82 -82
  22. package/dist/{location-D85EXiPt.cjs → location-BVEN_Ihk.cjs} +1 -1
  23. package/dist/{merge-CS3p9BVw.js → merge-B9jrWxMa.js} +1 -1
  24. package/dist/{merge-C_g05UGC.cjs → merge-DuTAponF.cjs} +1 -1
  25. package/dist/server.cjs +1 -1
  26. package/dist/server.js +1 -1
  27. package/dist/styles/markdown-explorer.css +1 -1
  28. package/dist/{useSplitPersistence-DRjsPZdH.cjs → useSplitPersistence-Ba-v64n-.cjs} +1 -1
  29. package/dist/{useSplitPersistence-B1b5Lg5E.js → useSplitPersistence-Cc4tDxB4.js} +1 -1
  30. package/docs/behavior/dom-hooks.md +1 -1
  31. package/docs/behavior/layout.md +16 -11
  32. package/docs/behavior/localization.md +2 -1
  33. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ### Breaking
6
+
7
+ - **The peer floors are `@aiquants/markdown` ^8.1.0 and `@aiquants/drag-drop-panels` ^0.12.0.** The viewer's controls
8
+ (its toolbar, the table of contents, a code block's copy button and a Mermaid diagram's controls, whose toolbar is a
9
+ row above the diagram) are 44 × 44 px targets under every pointer, and so are the panel headers' buttons and the
10
+ restore buttons of the bar of hidden panels.
11
+ - **A panel header has one move menu in place of its four move buttons.** Its button, Move the panel (the new label
12
+ `panelMove`), opens a menu of the moves the stage offers — to the previous or the next column, up and down, named by
13
+ `panelMovePreviousColumn`, `panelMoveNextColumn`, `panelMoveUp` and `panelMoveDown` as the buttons were; up and down
14
+ only on a stage of one column. A move the panel cannot make stays in the menu as `aria-disabled` and, chosen,
15
+ announces that the panel cannot make it (`panelMoveUnavailable`). After a move chosen in the menu the focus is on the
16
+ menu's button, also when the move rebuilt the panel in another column: the stage now tells a header control by its
17
+ action (`data-aqdd-panel-action`) when it gives the focus back, since the menu's button gets a new id with every
18
+ mount. The menu opens in the top layer, so a browser without the Popover API cannot open it (Alt + Shift + an arrow
19
+ still moves the panel there). A header shows at most five buttons; where the reader can hover they stay on the
20
+ title's row while the title keeps 5em, and on a device that cannot hover they take a row of their own below the
21
+ title. A host or a test that pressed a move button opens the menu (`data-aqdd-panel-action="move"`) and chooses an
22
+ item (`data-aqdd-panel-move`).
23
+
24
+ ### Added
25
+
26
+ - **The `panelMove` label** (`Move the panel`, ja `パネルを移動`) names each panel header's move menu button.
27
+
28
+ ### Changed
29
+
30
+ - **Every control of the explorer is a 44 × 44 px target under every pointer.** `--aqmx-control` is 2.75rem (44 px,
31
+ WCAG 2.2's enhanced target size) under a mouse and a pen as under a finger; a fine pointer had 2.125rem (34 px). So the
32
+ explorer's header (the source switch, the view switch and the tree's toolbar), the tree's rows and a folder's Try
33
+ again, the tree settings menu, the selection tray, the document bar (Source, Edit, Refresh document and the editor's
34
+ controls), the dialogs' buttons and the file views' toolbars are at least 44 × 44 px on a desktop too, as a new
35
+ end-to-end test measures at 1440 × 900 with a fine pointer; the tree's rows follow the token as before. The sheet's
36
+ toggle and close button read `--aqmx-control` as well, in place of the stylesheet's own `--aqmx-sheet-target`, which
37
+ is gone (it held the same 2.75rem), so a host's override of `--aqmx-control` sizes them too.
38
+ - **What stays coarse-only:** the body text's 16 px (`--aqmx-font-size-body: 1rem` under `(pointer: coarse)`, so Safari
39
+ on iOS does not zoom into a focused field) and the resize handles' bands (24 px and thin under a fine pointer, 44 px
40
+ under a coarse one; the arrow keys move them as well).
41
+
42
+ ## 0.17.0 (2026-10-24) — `@aiquants/markdown` 8 and `@aiquants/drag-drop-panels` 0.11, no ResizeObserver loop reports from the scroll bar, and a collapse check that waits for the layout to settle
43
+
5
44
  ### Changed
6
45
 
7
46
  - **Follows `@aiquants/markdown` 8.0.0 and `@aiquants/drag-drop-panels` 0.11.0.** The viewer's labels gain the ten new
package/README.md CHANGED
@@ -32,18 +32,19 @@ revision, and is asked before an unsaved draft is lost (see [Editing](#editing))
32
32
  A single-view (embedding) page never downloads the tree and multi-panel views, which load on demand.
33
33
  - **Embeds and link cards** — with `embeds` in the configuration, a link alone in a paragraph shows its post or video from up to ten providers (YouTube, X, Instagram, Threads, TikTok, Bluesky, LinkedIn, Reddit, note and niconico) in a cross-origin frame, with no provider script in the page, or a link card the explorer's own data route reads (`{dataPath}/link-card`, through `@aiquants/markdown`'s link-card handler: internal addresses never become cards); the link itself always stays, under the frame, as the card or as the paragraph.
34
34
  - **Secure by default** — Markdown HTML is sanitized on the server with an allow-list (scripts, event handlers, `srcdoc` and foreign iframes never reach the browser), and the document viewer applies its own on every render (a document keeps only the converter's class tokens, and ids only on headings, footnotes and `user-content-…` targets); document paths are validated, and deny rules hide environment files, keys and version-control metadata through up to three percent-decoding levels; tokens, principals, server paths and raw error messages never leave the server.
35
- - **Multi-panel reading** — open documents as panels, rearrange them by dragging (on a touch screen or with a pen, after a long-press on a panel's header), with the move buttons in each panel's header, or with Alt + Shift + arrow keys, hide, maximize (Escape restores), and navigate inside a panel; the arrangement survives reloads, and a document reopened later returns to its column.
35
+ - **Multi-panel reading** — open documents as panels, rearrange them by dragging (on a touch screen or with a pen, after a long-press on a panel's header), with the move menu in each panel's header, or with Alt + Shift + arrow keys, hide, maximize (Escape restores), and navigate inside a panel; the arrangement survives reloads, and a document reopened later returns to its column.
36
36
  - **Accessible and localized** — named landmarks and controls, a keyboard-operable tree with one Tab stop on the shown document, keyboard-operable menus, panel headers and resize handle, polite announcements (spoken from the sheet while it is open), WCAG 2.2 enhanced contrast (7:1 for text) in light and dark; English (default) and Japanese built in — the tree's and the panel headers' strings included —, every string overridable.
37
37
 
38
38
  ## Requirements
39
39
 
40
40
  - React 19.2.7 or later and React Router 8 in framework mode (route modules with `loader` / `headers`).
41
41
  - Node.js 22.22 or later (the floor React Router 8 declares). The package ships ES modules and CommonJS; the CommonJS entries load the ESM-only `react-router` through `require(esm)`.
42
- - The peer packages, at these versions or later within the caret ranges the package declares: `@aiquants/markdown` ^8.0.0 (document rendering; its components' stylesheet without utilities, its Mermaid labels, its math diagnostics, gantt sizing, embeds, link cards and their sizes, the React-free `@aiquants/markdown/embeds` the sanitizer worker loads and `@aiquants/markdown/source-lines` the editor and the sanitizer read, and the Node-only link-card handler of `@aiquants/markdown/server`, which needs Node.js 22.13 or later — below the explorer's own floor),
43
- `@aiquants/directory-tree` ^4.1.1 (reveals of rows under the scroll bar's buttons), `@aiquants/drag-drop-panels` ^0.11.0 (the panel headers of a coarse pointer and of a one-column stage the behavior docs follow), `@aiquants/resize-panels` ^2.2.0 (the source of each layout change, by which the tree pane's width is saved) and `@aiquants/virtualscroll` ^3.20.0.
42
+ - The peer packages, at these versions or later within the caret ranges the package declares: `@aiquants/markdown` ^8.1.0 (document rendering; its components' stylesheet without utilities, its controls' 44 px targets under every pointer,
43
+ its Mermaid labels, its math diagnostics, gantt sizing, embeds, link cards and their sizes, the React-free `@aiquants/markdown/embeds` the sanitizer worker loads and `@aiquants/markdown/source-lines` the editor and the sanitizer read, and the Node-only link-card handler of `@aiquants/markdown/server`, which needs Node.js 22.13 or later — below the explorer's own floor),
44
+ `@aiquants/directory-tree` ^4.1.1 (reveals of rows under the scroll bar's buttons), `@aiquants/drag-drop-panels` ^0.12.0 (the panel headers' move menu, named by the explorer's `panelMove`, their 44 px buttons under every pointer and the header arrangement the behavior docs follow), `@aiquants/resize-panels` ^2.2.0 (the source of each layout change, by which the tree pane's width is saved) and `@aiquants/virtualscroll` ^3.20.0.
44
45
  The client depends on these floors, while a package manager may only warn about an older peer.
45
46
  - A Markdown parser of your choice on the server that produces HTML and its headings (the explorer sanitizes the HTML before it is sent).
46
- - Browsers: the multi view's panel-limit notice uses the Popover API (Chrome and Edge 114, Firefox 125, Safari 17 and later). In browsers without it (for example iOS 16), the notice is drawn in place at the stage's corner instead of in the top layer (while the sheet is open it spans the sheet's header, as in every browser).
47
+ - Browsers: the multi view's panel-limit notice and the panel headers' move menu use the Popover API (Chrome and Edge 114, Firefox 125, Safari 17 and later). In browsers without it (for example iOS 16), the notice is drawn in place at the stage's corner instead of in the top layer (while the sheet is open it spans the sheet's header, as in every browser), and the move menu does not open: Alt + Shift + an arrow moves a panel there.
47
48
  That notice wraps around the sheet's close button with a logical float (`float: inline-end`, Chrome and Edge 118 and later); in browsers without logical floats (before Chrome and Edge 118, the Chromium versions without the Popover API included) a long notice runs partly under the close button.
48
49
 
49
50
  ## Installation
@@ -810,7 +811,7 @@ The labels the layout fills with a value are templates with `{name}` placeholder
810
811
  | Dialogs | centered over the visible part of the content pane, at least 21 px (`--aqmx-space-7`) from every edge of the viewport |
811
812
  | Multi-view column minimum | 40ch at 1rem (the multi-column reading measure) |
812
813
  | Multi-view panel height | between the stage height / φ³ and the stage height / φ, except that the panel's scroll area always keeps three lines of 1rem × φ text below the panel's header (where the header wraps that far, the panel is the header plus that floor) |
813
- | Spacing, controls, durations | Fibonacci numbers (px written in rem; ms), except the pointer targets: 44 px (2.75rem) for every control under a coarse pointer and for the sheet's toggle and close button, and the resize handle's 24 px under a fine pointer |
814
+ | Spacing, controls, durations | Fibonacci numbers (px written in rem; ms), except the pointer targets: 44 px (2.75rem, `--aqmx-control`) for every control under every pointer (WCAG 2.2 enhanced target size), and the resize handle's 24 px under a fine pointer |
814
815
  | Text sizes | 13, 16 and 21 px (0.8125, 1 and 1.3125rem) for body text, titles and display text; under a coarse pointer the body text is 16 px (1rem) as well; tree rows are in the body size |
815
816
 
816
817
  The reader's own explorer width is remembered per view as a percentage, and only after the reader moves the handle: a drag that moved it (once, when it ends) or an arrow key that moved it, never a press that moved nothing or a change of the window. The editor's share beside the preview is remembered the same way. The document's column fills its pane; the viewer's alignment control appears only for a column a single-view embed narrows (`?width=` / `?maxWidth=`). See [Layout](docs/behavior/layout.md).
@@ -1,6 +1,6 @@
1
1
  import { jsx as L, jsxs as j, Fragment as ze } from "react/jsx-runtime";
2
2
  import { useState as le, useRef as _, useLayoutEffect as N, useEffectEvent as fe, useEffect as Oe, useImperativeHandle as Fe, useMemo as ie, startTransition as Ge, useCallback as W, useId as Ue } from "react";
3
- import { v as Y, g as ae, h as Ke, u as te, i as We, l as Xe, j as $e, k as qe, m as je, n as Ye, o as Je, p as Qe, E as Ze, q as et, s as tt, t as me, w as pe, A as rt, x as he, y as nt, z as ot, B as it, G as st } from "./index-h9e3p5Pd.js";
3
+ import { v as Y, g as ae, h as Ke, u as te, i as We, l as Xe, j as $e, k as qe, m as je, n as Ye, o as Je, p as Qe, E as Ze, q as et, s as tt, t as me, w as pe, A as rt, x as he, y as nt, z as ot, B as it, G as st } from "./index-25s_q0vD.js";
4
4
  import { history as lt, historyKeymap as at, defaultKeymap as ct, historyField as ut } from "@codemirror/commands";
5
5
  import { markdown as dt, markdownLanguage as ft } from "@codemirror/lang-markdown";
6
6
  import { syntaxHighlighting as mt, HighlightStyle as pt } from "@codemirror/language";
@@ -14,8 +14,8 @@ import { d as At, f as Q, E as Mt } from "./dataRoute-CObbjNxG.js";
14
14
  import { H as Ot, c as qt, M as Ct } from "./sanitizePolicy-DlrakwA4.js";
15
15
  import It from "isomorphic-dompurify";
16
16
  import { PanelGroup as Rt, Panel as ve, PanelResizeHandle as _t } from "@aiquants/resize-panels";
17
- import { C as Nt, F as Pt, E as Dt, a as Vt, b as Z, d as Ht } from "./location-G7psbmv_.js";
18
- import { u as Bt, a as zt } from "./useSplitPersistence-B1b5Lg5E.js";
17
+ import { C as Nt, F as Pt, E as Dt, a as Vt, b as Z, d as Ht } from "./location-B-m9scLf.js";
18
+ import { u as Bt, a as zt } from "./useSplitPersistence-Cc4tDxB4.js";
19
19
  const Re = { history: ut }, Ft = pt.define([
20
20
  { tag: [C.heading1, C.heading2, C.heading3, C.heading4, C.heading5, C.heading6, C.heading], color: "var(--aqmx-syntax-heading)", fontWeight: "700" },
21
21
  { tag: C.strong, fontWeight: "700" },
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),p=require("react"),x=require("./index-5gwNJ8CB.cjs"),ee=require("@codemirror/commands"),ae=require("@codemirror/lang-markdown"),ye=require("@codemirror/language"),ce=require("@codemirror/search"),K=require("@codemirror/state"),I=require("@codemirror/view"),_=require("@lezer/highlight"),Ce=require("@aiquants/markdown"),ne=require("@aiquants/markdown/source-lines"),W=require("./dataRoute-BONacTPi.cjs"),oe=require("./sanitizePolicy-DrIMuYCb.cjs"),_e=require("isomorphic-dompurify"),Q=require("@aiquants/resize-panels"),G=require("./location-D85EXiPt.cjs"),ue=require("./useSplitPersistence-DRjsPZdH.cjs"),Te={history:ee.historyField},Pe=ye.HighlightStyle.define([{tag:[_.tags.heading1,_.tags.heading2,_.tags.heading3,_.tags.heading4,_.tags.heading5,_.tags.heading6,_.tags.heading],color:"var(--aqmx-syntax-heading)",fontWeight:"700"},{tag:_.tags.strong,fontWeight:"700"},{tag:_.tags.emphasis,fontStyle:"italic"},{tag:_.tags.strikethrough,textDecoration:"line-through"},{tag:_.tags.link,color:"var(--aqmx-syntax-link)",textDecoration:"underline"},{tag:_.tags.url,color:"var(--aqmx-syntax-url)"},{tag:_.tags.monospace,color:"var(--aqmx-syntax-code)"},{tag:_.tags.quote,color:"var(--aqmx-syntax-quote)"},{tag:[_.tags.processingInstruction,_.tags.contentSeparator,_.tags.labelName,_.tags.meta],color:"var(--aqmx-syntax-mark)"}]),Ne=I.EditorView.theme({"&":{height:"100%",color:"var(--aqmx-text)",backgroundColor:"var(--aqmx-surface)",fontSize:"var(--aqmx-font-size-title)"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',lineHeight:"var(--aqmx-line-height-prose)"},".cm-content":{caretColor:"var(--aqmx-text)",paddingBlock:"var(--aqmx-space-6)"},".cm-line":{paddingInline:"var(--aqmx-space-6)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--aqmx-text)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--aqmx-editor-selection)"},".cm-activeLine":{backgroundColor:"var(--aqmx-editor-active-line)"},".cm-gutters":{backgroundColor:"var(--aqmx-surface-raised)",color:"var(--aqmx-editor-gutter)",borderInlineEnd:"var(--aqmx-space-1) solid var(--aqmx-border)"},".cm-activeLineGutter":{backgroundColor:"var(--aqmx-editor-active-line)"},".cm-searchMatch":{outline:"var(--aqmx-space-1) solid var(--aqmx-border-strong)"},".cm-panels":{backgroundColor:"var(--aqmx-surface-raised)",color:"var(--aqmx-text)"}}),Le="data-aqmx-conflict-actions",De=I.Decoration.line({attributes:{"data-aqmx-conflict-line":"marker"}}),Ve=I.Decoration.line({attributes:{"data-aqmx-conflict-line":"ours"}}),je=I.Decoration.line({attributes:{"data-aqmx-conflict-line":"theirs"}});class He extends I.WidgetType{constructor(t,r){super(),this.index=t,this.labels=r}index;labels;eq(t){return t.index===this.index&&t.labels===this.labels}toDOM(t){const r=document.createElement("div");r.setAttribute(Le,String(this.index));for(const[o,a]of[["ours",this.labels.useOurs],["theirs",this.labels.useTheirs],["both",this.labels.keepBoth]]){const s=document.createElement("button");s.type="button",s.textContent=a,s.setAttribute("data-aqmx-conflict-choice",o),s.addEventListener("mousedown",l=>l.preventDefault()),s.addEventListener("click",()=>{const l=Y(t.state.doc)[this.index];l!==void 0&&(ke(t,l,o),t.focus())}),r.append(s)}return r}ignoreEvent(){return!0}}const Y=e=>x.findConflictsInLines(e.iterLines()),de=(e,t)=>{const r=new K.RangeSetBuilder;return Y(e).forEach((o,a)=>{const s=e.line(o.start);r.add(s.from,s.from,I.Decoration.widget({widget:new He(a,t),block:!0,side:-1}));for(let l=o.start;l<=o.end;l+=1){const n=e.line(l).from,h=l===o.start||l===o.separator||l===o.end?De:l<o.separator?Ve:je;r.add(n,n,h)}}),r.finish()},Be=e=>K.StateField.define({create:t=>de(t.doc,e),update:(t,r)=>r.docChanged?de(r.state.doc,e):t,provide:t=>I.EditorView.decorations.from(t)}),ke=(e,t,r)=>{const{doc:o}=e.state,a=(u,c)=>{const g=[];for(let m=u;m<=c;m+=1)g.push(o.line(m).text);return g},s=a(t.start+1,t.separator-1),l=a(t.separator+1,t.end-1),n=r==="ours"?s:r==="theirs"?l:[...s,...l];let h=o.line(t.start).from,f=o.line(t.end).to;n.length===0&&(t.end<o.lines?f+=1:t.start>1&&(h-=1));const i=n.join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),p=require("react"),x=require("./index-W3iAjkLb.cjs"),ee=require("@codemirror/commands"),ae=require("@codemirror/lang-markdown"),ye=require("@codemirror/language"),ce=require("@codemirror/search"),K=require("@codemirror/state"),I=require("@codemirror/view"),_=require("@lezer/highlight"),Ce=require("@aiquants/markdown"),ne=require("@aiquants/markdown/source-lines"),W=require("./dataRoute-BONacTPi.cjs"),oe=require("./sanitizePolicy-DrIMuYCb.cjs"),_e=require("isomorphic-dompurify"),Q=require("@aiquants/resize-panels"),G=require("./location-BVEN_Ihk.cjs"),ue=require("./useSplitPersistence-Ba-v64n-.cjs"),Te={history:ee.historyField},Pe=ye.HighlightStyle.define([{tag:[_.tags.heading1,_.tags.heading2,_.tags.heading3,_.tags.heading4,_.tags.heading5,_.tags.heading6,_.tags.heading],color:"var(--aqmx-syntax-heading)",fontWeight:"700"},{tag:_.tags.strong,fontWeight:"700"},{tag:_.tags.emphasis,fontStyle:"italic"},{tag:_.tags.strikethrough,textDecoration:"line-through"},{tag:_.tags.link,color:"var(--aqmx-syntax-link)",textDecoration:"underline"},{tag:_.tags.url,color:"var(--aqmx-syntax-url)"},{tag:_.tags.monospace,color:"var(--aqmx-syntax-code)"},{tag:_.tags.quote,color:"var(--aqmx-syntax-quote)"},{tag:[_.tags.processingInstruction,_.tags.contentSeparator,_.tags.labelName,_.tags.meta],color:"var(--aqmx-syntax-mark)"}]),Ne=I.EditorView.theme({"&":{height:"100%",color:"var(--aqmx-text)",backgroundColor:"var(--aqmx-surface)",fontSize:"var(--aqmx-font-size-title)"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',lineHeight:"var(--aqmx-line-height-prose)"},".cm-content":{caretColor:"var(--aqmx-text)",paddingBlock:"var(--aqmx-space-6)"},".cm-line":{paddingInline:"var(--aqmx-space-6)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--aqmx-text)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--aqmx-editor-selection)"},".cm-activeLine":{backgroundColor:"var(--aqmx-editor-active-line)"},".cm-gutters":{backgroundColor:"var(--aqmx-surface-raised)",color:"var(--aqmx-editor-gutter)",borderInlineEnd:"var(--aqmx-space-1) solid var(--aqmx-border)"},".cm-activeLineGutter":{backgroundColor:"var(--aqmx-editor-active-line)"},".cm-searchMatch":{outline:"var(--aqmx-space-1) solid var(--aqmx-border-strong)"},".cm-panels":{backgroundColor:"var(--aqmx-surface-raised)",color:"var(--aqmx-text)"}}),Le="data-aqmx-conflict-actions",De=I.Decoration.line({attributes:{"data-aqmx-conflict-line":"marker"}}),Ve=I.Decoration.line({attributes:{"data-aqmx-conflict-line":"ours"}}),je=I.Decoration.line({attributes:{"data-aqmx-conflict-line":"theirs"}});class He extends I.WidgetType{constructor(t,r){super(),this.index=t,this.labels=r}index;labels;eq(t){return t.index===this.index&&t.labels===this.labels}toDOM(t){const r=document.createElement("div");r.setAttribute(Le,String(this.index));for(const[o,a]of[["ours",this.labels.useOurs],["theirs",this.labels.useTheirs],["both",this.labels.keepBoth]]){const s=document.createElement("button");s.type="button",s.textContent=a,s.setAttribute("data-aqmx-conflict-choice",o),s.addEventListener("mousedown",l=>l.preventDefault()),s.addEventListener("click",()=>{const l=Y(t.state.doc)[this.index];l!==void 0&&(ke(t,l,o),t.focus())}),r.append(s)}return r}ignoreEvent(){return!0}}const Y=e=>x.findConflictsInLines(e.iterLines()),de=(e,t)=>{const r=new K.RangeSetBuilder;return Y(e).forEach((o,a)=>{const s=e.line(o.start);r.add(s.from,s.from,I.Decoration.widget({widget:new He(a,t),block:!0,side:-1}));for(let l=o.start;l<=o.end;l+=1){const n=e.line(l).from,h=l===o.start||l===o.separator||l===o.end?De:l<o.separator?Ve:je;r.add(n,n,h)}}),r.finish()},Be=e=>K.StateField.define({create:t=>de(t.doc,e),update:(t,r)=>r.docChanged?de(r.state.doc,e):t,provide:t=>I.EditorView.decorations.from(t)}),ke=(e,t,r)=>{const{doc:o}=e.state,a=(u,c)=>{const g=[];for(let m=u;m<=c;m+=1)g.push(o.line(m).text);return g},s=a(t.start+1,t.separator-1),l=a(t.separator+1,t.end-1),n=r==="ours"?s:r==="theirs"?l:[...s,...l];let h=o.line(t.start).from,f=o.line(t.end).to;n.length===0&&(t.end<o.lines?f+=1:t.start>1&&(h-=1));const i=n.join(`
2
2
  `);e.dispatch({changes:{from:h,to:f,insert:i},selection:K.EditorSelection.cursor(h),scrollIntoView:!0,userEvent:"input.resolve"})},ze=({parent:e,scroll:t,text:r,saved:o,labels:a,onChange:s,onGeometry:l,onSave:n})=>{const h=[I.EditorView.scrollHandler.of((u,c,g)=>(Fe(u,c.head,g,t),!0)),I.lineNumbers(),I.highlightActiveLineGutter(),ee.history(),I.drawSelection(),I.highlightActiveLine(),ce.highlightSelectionMatches(),I.EditorView.lineWrapping,ae.markdown({base:ae.markdownLanguage}),ye.syntaxHighlighting(Pe),Be(a),I.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(n(),!0)},...ce.searchKeymap,...ee.historyKeymap,...ee.defaultKeymap]),I.EditorView.contentAttributes.of({"aria-label":a.editor,"aria-multiline":"true"}),I.EditorView.updateListener.of(u=>{u.docChanged&&s(),(u.docChanged||u.heightChanged||u.geometryChanged)&&l(u.docChanged)}),Ne],f=Xe(o,h)??K.EditorState.create({doc:r,extensions:h}),i=new I.EditorView({state:f,parent:e});return{text:()=>i.state.doc.toString(),replaceText:u=>{const c=i.state.doc.toString();if(c===u)return;let g=0;const m=Math.min(c.length,u.length);for(;g<m&&c.charCodeAt(g)===u.charCodeAt(g);)g+=1;let S=0;for(;S<m-g&&c.charCodeAt(c.length-1-S)===u.charCodeAt(u.length-1-S);)S+=1;i.dispatch({changes:{from:g,to:c.length-S,insert:u.slice(g,u.length-S)},userEvent:"input.replace"})},reveal:({line:u,column:c},g)=>{const{doc:m}=i.state,S=m.line(Math.min(Math.max(u,1),m.lines)),v=Math.min(S.from+c,S.to);i.dispatch({selection:K.EditorSelection.cursor(v),effects:fe(i,v,g,t)})},showLine:u=>{const{doc:c}=i.state,g=c.line(Math.min(Math.max(u,1),c.lines)).from;i.dispatch({effects:fe(i,g,null,t)})},topLine:()=>{const u=t.scrollerOf(i.scrollDOM),c=x.visibleTopOf(u,i.contentDOM),g=x.frameTopOf(u)+u.clientHeight,{documentTop:m}=i,{doc:S}=i.state;let v=i.lineBlockAtHeight(Math.max(c-m,0));for(;S.lineAt(v.from).text.trim()===""&&v.to<S.length;){const A=i.lineBlockAt(v.to+1);if(m+A.top>=g)break;v=A}const k=i.coordsAtPos(v.from),O=k===null?m+v.top:k.top;return{line:i.state.doc.lineAt(v.from).number,clientTop:O,offset:O-c}},lineSpans:u=>{const c=i.scrollDOM,g=c.scrollTop+i.documentTop-x.visibleTopOf(c,i.contentDOM),{doc:m}=i.state,S=v=>m.line(Math.min(Math.max(v,1),m.lines)).from;return u.map(({first:v,last:k})=>({top:g+i.lineBlockAt(S(v)).top,bottom:g+i.lineBlockAt(S(k)).bottom}))},scrollElement:i.scrollDOM,focus:()=>i.focus(),conflicts:()=>Y(i.state.doc),resolveAtCursor:u=>{const c=Y(i.state.doc),g=i.state.doc.lineAt(i.state.selection.main.head).number,m=c.find(S=>S.end>=g);return m===void 0?!1:(ke(i,m,u),!0)},nextConflict:()=>{const u=Y(i.state.doc);if(u[0]===void 0)return!1;const g=i.state.doc.lineAt(i.state.selection.main.head).number,m=u.findIndex(O=>O.start>g),S=m<0?0:m,v=i.state.doc.line(u[S].start).from;i.dispatch({selection:K.EditorSelection.cursor(v),effects:I.EditorView.scrollIntoView(v,{y:"center"})});const k=i.contentDOM.querySelector(`[${Le}="${String(S)}"] button`);return k instanceof HTMLElement?k.focus({preventScroll:!0}):i.focus(),!0},save:()=>i.state.toJSON(Te),destroy:()=>i.destroy()}},fe=(e,t,r,o)=>{const a=o.scrollerOf(e.scrollDOM),s=(r===null?x.visibleTopOf(a,e.contentDOM):r)-x.frameTopOf(a);return I.EditorView.scrollIntoView(t,{y:"start",yMargin:s})},Fe=(e,t,r,o)=>{const a=Ue(e,t),s=o.scrollerOf(e.scrollDOM),l=x.frameTopOf(s),n=x.visibleTopOf(s,e.contentDOM),h=l+s.clientHeight;let f=0;switch(r.y){case"start":f=a.top-(l+r.yMargin);break;case"center":f=(a.top+a.bottom)/2-(n+h)/2;break;case"end":f=a.bottom-(h-r.yMargin);break;default:a.top<n+r.yMargin?f=a.top-(n+r.yMargin):a.bottom>h-r.yMargin&&(f=Math.min(a.bottom-(h-r.yMargin),a.top-(n+r.yMargin)))}if(f!==0&&(s.scrollTop+=f),r.y==="start")return;const i=Ge(e,t);i!==null&&o.reveal(i)},Ue=(e,t)=>{const{node:r,offset:o}=e.domAtPos(t);if(r.nodeType===Node.TEXT_NODE){const l=r.ownerDocument?.createRange();if(l!==void 0){l.setStart(r,o),l.setEnd(r,o);const[n]=l.getClientRects();if(n!==void 0&&n.height>0)return{top:n.top,bottom:n.bottom}}}const a=e.lineBlockAt(t),s=e.documentTop+a.top;return{top:s,bottom:s+a.height}},Ge=(e,t)=>{const{node:r}=e.domAtPos(t);for(let o=r instanceof Element?r:r.parentElement;o!==null;o=o.parentElement)if(o.parentElement===e.contentDOM)return o;return null},Xe=(e,t)=>{if(e==null)return null;try{return K.EditorState.fromJSON(e,{extensions:t},Te)}catch{return null}},Ke=610,We=987,pe=Object.freeze({kind:"unavailable"}),$e="true",Ye="false",Je=e=>e===$e?!0:e===Ye?!1:null,Qe=e=>{const t=new DOMParser().parseFromString(e,"text/html"),r=[];for(const o of t.querySelectorAll("img[data-asset-src], a[data-doc-path]")){const a=o.localName==="img",s=o.getAttribute(a?"data-asset-src":"data-doc-path");s!==null&&r.push({target:{kind:a?"asset":"doc",path:s},exists:Je(o.getAttribute(a?"data-asset-exists":"data-doc-exists"))})}return r},Ze=({path:e,instant:t,preview:r,initial:o,onView:a})=>{const s=new AbortController,l={asset:new Map,doc:new Map};let n=o,h=null,f=!1,i=!1,u=null,c=null,g=[],m,S=!1,v,k=null;const O=y=>{y.parsed===n.parsed&&y.failure===n.failure&&y.busy===n.busy&&y.tier===n.tier||(n=y,a(y))},A=(y,d)=>{f||(f=!0,console.error(`[markdown-explorer] ${y}`,...d===void 0?[]:[d]))},j=y=>{if(t!==null)for(const{target:d,exists:E}of t.marksOf(y))l[d.kind].set(d.path,E)},D=()=>{clearTimeout(v),v=void 0,k?.abort(),k=null},V=()=>{c=null,g=[],clearTimeout(m),m=void 0},H=(y,d)=>{O({parsed:n.parsed,failure:y,busy:!1,tier:d})},b=()=>{clearTimeout(m),m=g.length===0?void 0:setTimeout(q,We)},T=()=>{if(t===null||c===null)return;const y=c,d=[],E={asset:new Set,doc:new Set};let R;try{R=t.sanitize(y.html,C=>{const U=l[C.kind].get(C.path);return U===void 0&&!E[C.kind].has(C.path)&&(E[C.kind].add(C.path),d.push(C)),U??void 0})}catch(C){V(),C instanceof oe.HtmlNestingLimitError?H(W.failureOf("too-large"),"instant"):(A("the draft sanitizer failed",C),H(W.failureOf("failed"),"instant"));return}g=d;const M=n.parsed!==null&&n.parsed.htmlContent===R&&n.parsed.headings===y.headings?n.parsed:{htmlContent:R,headings:y.headings};O({parsed:M,failure:null,busy:!1,tier:"instant"}),b()},q=()=>{if(m=void 0,S||c===null||g.length===0)return;S=!0;const y=g;r(e,c.text,s.signal).then(d=>{if(S=!1,!(s.signal.aborted||!("kind"in d))){d.kind==="preview"&&j(d.htmlContent);for(const E of y)l[E.kind].has(E.path)||l[E.kind].set(E.path,null);T()}})},P=y=>{D(),V(),O({...n,busy:!0,tier:"server"});const d=new AbortController;k=d,v=setTimeout(()=>{v=void 0,r(e,y,d.signal).then(E=>{if(!(d.signal.aborted||!("kind"in E))){if(k=null,E.kind==="failure"){H(E.failure,"server");return}j(E.htmlContent),O({parsed:{htmlContent:E.htmlContent,headings:E.headings},failure:null,busy:!1,tier:"server"})}})},Ke)},w=async(y,d)=>{let E;try{E=await y.convert({path:e,text:d},s.signal)}catch(M){return s.signal.aborted||A("the draft converter rejected a conversion, which its contract allows only once the signal aborted",M),pe}const R=W.draftAnswerViolation(E);return R===null?E:(A(`the draft converter answered outside its contract: ${R}`),pe)},B=(y,d)=>{switch(d.kind){case"preview":if(D(),d.headings.length>W.EXPLORER_MAX_HEADINGS){V(),H(W.failureOf("too-large"),"instant");return}c={text:y,html:d.htmlContent,headings:d.headings.map(({text:E,depth:R,id:M})=>({text:E,depth:R,id:M}))},T();return;case"failure":D(),V(),H(W.failureOf(d.failure.reason,d.failure.code),"instant");return;case"unavailable":P(y);return}},z=async y=>{i=!0;try{for(;u!==null&&!s.signal.aborted;){const d=u;u=null;const E=await w(y,d);if(s.signal.aborted)return;B(d,E)}}finally{i=!1}};return t!==null&&t.seed!==null&&j(t.seed),{update:y=>{if(!(s.signal.aborted||y===h)){if(h=y,clearTimeout(m),m=void 0,t===null){P(y);return}u=y,i||z(t.converter)}},dispose:()=>{s.abort(),u=null,clearTimeout(m),m=void 0,D()}}},et=(e,t)=>oe.createHtmlSanitizer(_e(window),e,t,oe.MAX_HTML_NESTING_DEPTH),tt=(e,t)=>e.flatMap((r,o)=>{const a=t[o];return a===void 0?[]:[{editor:a.top,preview:r.top},{editor:a.bottom,preview:r.bottom}]}),X=(e,t)=>{const r=e[t];if(r===void 0)throw new RangeError(`[markdown-explorer] a scroll map index must be in 0..${String(e.length-1)}; got ${String(t)}`);return r},rt=e=>{const t=[];for(const o of e){let a=0,s=t.length;for(;a<s;){const l=a+s>>1;X(t,l).pair.preview<=o.preview?a=l+1:s=l}t[a]={pair:o,before:a===0?void 0:X(t,a-1)}}const r=[];for(let o=t.at(-1);o!==void 0;o=o.before)r.push(o.pair);return r.reverse()},nt=(e,t)=>{const r=Math.max(t.editorMax,0),o=Math.max(t.previewMax,0),a=r-t.editorViewport,s=o-t.previewViewport,l=e.filter(f=>f.editor>0&&f.editor<a&&f.preview>0&&f.preview<s).sort((f,i)=>f.editor-i.editor||f.preview-i.preview);let n={editor:0,preview:0};const h=[n];for(const f of rt(l))f.editor>n.editor&&f.preview>n.preview&&(h.push(f),n=f);return h.push({editor:r,preview:o}),{toPreview:f=>me(h,"editor","preview",f),toEditor:f=>me(h,"preview","editor",f)}},me=(e,t,r,o)=>{const a=X(e,0),s=X(e,e.length-1);if(Number.isNaN(o)||o<=a[t])return a[r];if(o>=s[t])return s[r];let l=0,n=e.length-1;for(;n-l>1;){const i=l+n>>1;X(e,i)[t]<=o?l=i:n=i}const h=X(e,l),f=X(e,n);return h[r]+(f[r]-h[r])*(o-h[t])/(f[t]-h[t])},ot=610,he=89,ge=.5,it=({editor:e,preview:t,previewBlocks:r,editorSpans:o,requestFrame:a,cancelFrame:s,now:l})=>{let n="editor",h=0,f=null,i=null,u=!1,c=null,g=null;const m={editor:0,preview:0},S={editor:null,preview:null};let v=null,k=()=>{};const O=w=>{f!==null&&w!==f||(n=w,h=l()+ot)},A=(w,B)=>{w!==n&&f===null&&l()>=h&&!j(w,B)&&(n=w),T()},j=(w,B)=>{const z=S[w];return l()<m[w]||z!==null&&Math.abs(B.position()-z)<ge},D=e.onScroll(()=>A("editor",e)),V=e.onIntent(()=>O("editor")),H=()=>{const w=t();return w!==v&&(k(),v=w,k=w===null?()=>{}:b(w)),w},b=w=>{const B=w.onScroll(()=>A("preview",w)),z=w.onIntent(()=>O("preview"));return()=>{B(),z()}},T=()=>{!u&&i===null&&(i=a(q))},q=()=>{i=null;const w=H();w!==null&&(c??=r(),g??=nt(tt(c,o(c)),{editorMax:e.max(),previewMax:w.max(),editorViewport:e.viewport(),previewViewport:w.viewport()}),n==="editor"?P(w,"preview",g.toPreview(e.position())):P(e,"editor",g.toEditor(w.position())))},P=(w,B,z)=>{if(Math.abs(w.position()-z)<ge){S[B]=w.position();return}m[B]=l()+he,S[B]=w.scrollTo(z)};return T(),{editorChanged:w=>{g=null,w&&O("editor"),T()},previewChanged:()=>{c=null,g=null,m.preview=l()+he,T()},showAlone:w=>{f=w,!(w===null||w===n)&&(n=w,h=0,T())},dispose:()=>{u=!0,i!==null&&s(i),i=null,D(),V(),k()}}},ve=Object.freeze(["wheel","pointerdown","keydown","focusin"]),qe=e=>({position:()=>e.scrollTop,max:()=>Math.max(e.scrollHeight-e.clientHeight,0),viewport:()=>e.clientHeight,scrollTo:t=>(e.scrollTo({top:t,behavior:"instant"}),e.scrollTop),onScroll:t=>(e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)),onIntent:t=>{for(const r of ve)e.addEventListener(r,t,{capture:!0,passive:!0});return()=>{for(const r of ve)e.removeEventListener(r,t,{capture:!0})}}}),$="[data-aqmd-scroll-container]",st="[data-aqmd-content]",lt=`[${ne.SOURCE_LINES_ATTRIBUTE}]`,at=Object.freeze(["p1","p2","p3","p4","p5","p6","p7","p8"]),Re=(e,t)=>{const r=x.loadedOf(e.peek(t));return r!==null&&r.document.kind==="markdown"?{htmlContent:r.document.htmlContent,headings:r.document.headings}:null},ct=(e,t,r,o,a)=>{if(r===void 0)return null;let s;try{s=et(e,t)}catch(l){return console.error("[markdown-explorer] the draft sanitizer cannot run in this browser, so the server renders the preview",l),null}return{converter:r,sanitize:s,marksOf:Qe,seed:Re(o,a)?.htmlContent??null}},ut=e=>{const t=[];let r=null;for(const o of e.querySelectorAll(lt)){const a=ne.parseSourceLines(o.getAttribute(ne.SOURCE_LINES_ATTRIBUTE));if(a===null||o.getClientRects().length===0)continue;r??=e.scrollTop-x.visibleTopOf(e,o);const{top:s,bottom:l}=o.getBoundingClientRect();t.push({first:a.first,last:a.last,top:r+s,bottom:r+l})}return t},dt=({path:e,readDraft:t,viewer:r,concealed:o,onEditAt:a,onLayout:s,handleRef:l})=>{const{config:n,data:h,documents:f,draftConverter:i,labels:u}=x.useExplorer(),[c,g]=p.useState(()=>({parsed:Re(f,e),failure:null,busy:!0,tier:i===void 0?"server":"instant"})),m=p.useRef(null),S=p.useRef(null),v=p.useRef(c);p.useLayoutEffect(()=>{v.current=c});const k=p.useEffectEvent(()=>t());p.useEffect(()=>{const b=ct(n.iframeHosts,n.dataPath,i,f,e),T=Ze({path:e,instant:b,preview:h.preview,initial:v.current,onView:q=>p.startTransition(()=>g(q))});return S.current=T,T.update(k()),()=>{T.dispose(),S.current=null}},[n,h,f,i,e]);const O=p.useEffectEvent(()=>s());p.useLayoutEffect(()=>{c.parsed!==null&&O()},[c.parsed]);const A=c.parsed!==null;p.useLayoutEffect(()=>{const b=A?m.current?.querySelector($):null;if(!(b instanceof HTMLElement))return;b.tabIndex=0;const T=new ResizeObserver(()=>O());T.observe(b);const q=b.querySelector(st);return q!==null&&T.observe(q),()=>T.disconnect()},[A]);const j=p.useRef(null);p.useImperativeHandle(l,()=>({draft:b=>{S.current?.update(b)},scrollPort:()=>{const b=m.current?.querySelector($);return b instanceof HTMLElement?(j.current?.scroller!==b&&(j.current={scroller:b,port:qe(b)}),j.current.port):null},blocks:()=>{const b=m.current?.querySelector($);return b instanceof HTMLElement?ut(b):[]},focus:()=>{const b=m.current?.querySelector($);b instanceof HTMLElement&&b.focus({preventScroll:!0})},anchor:b=>{const T=m.current,q=T?.querySelector($);return T===null||!(q instanceof HTMLElement)?null:x.anchorOfView(T,b(q))},place:({line:b,clientTop:T},q)=>{const P=m.current,w=P===null?null:x.blockAtLine(P,b);w!==null&&(q(w).scrollTop+=x.lineTopIn(w,b)-T)}}),[]);const D=b=>{const T=m.current,{target:q}=b;if(a===void 0||T===null||!(q instanceof Element)||!x.isEditingDoubleClick(q))return;const P=x.anchorOfDoubleClick(q,T,T.ownerDocument.getSelection());P!==null&&a(P)},V=p.useMemo(()=>({...r,showToc:!1,showStyle:!1,showAlign:!1,renderScrollBar:void 0}),[r]),H=p.useMemo(()=>c.parsed===null?null:L.jsx("div",{className:"aqmx-document-viewer",children:L.jsx(Ce.MarkdownViewer,{...V,parseResult:c.parsed,content:null})}),[V,c.parsed]);return L.jsxs("section",{ref:m,className:"aqmx-edit-preview","aria-label":u.previewRegion,"aria-busy":c.busy,inert:o!==null,hidden:o==="removed","data-aqmx-preview-tier":c.tier,"data-testid":"markdown-explorer-edit-preview",onDoubleClick:a===void 0?void 0:D,children:[c.failure===null?null:L.jsx("p",{className:"aqmx-callout aqmx-document-notice","data-aqmx-tone":"warning","data-testid":"markdown-explorer-edit-preview-failure",children:u.previewFailed(x.failureTitleOf(u,c.failure.reason))}),H??(c.failure===null?L.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-preview-skeleton",children:at.map(b=>L.jsx("span",{},b))}):null),c.busy?L.jsx("p",{className:"aqmx-sr-only",children:u.previewUpdating}):null]})},we="data-aqmx-edit-split",re="--aqmx-edit-share",Ee="--aqmx-edit-gutter",ft="data-aqmx-edit-split-probe",pt="aqmx-edit-split",mt="aqmx-edit-editor",ht="aqmx-edit-preview",be={value:G.EDIT_SPLIT_MIN_PERCENT,unit:"percentage"},xe={value:G.EDIT_SPLIT_MAX_PERCENT,unit:"percentage"},Se=e=>{if(e.length!==2)return null;const[t=0,r=0]=e,o=t+r;return o>0?t/o*100:null},Z=e=>{const t=e.current?.parentElement;if(t==null)throw new Error("[markdown-explorer] the edit split is not mounted in its surface");return t},gt=(e,t,r)=>{const[o,a]=p.useState(null);return p.useLayoutEffect(()=>{const s=e.current,l=t.current;if(s===null||l===null)throw new Error("[markdown-explorer] the edit split is not mounted");const n={frame:s.getBoundingClientRect().width,measure:l.getBoundingClientRect().width},h=()=>{n.frame>0&&n.measure>0&&a(G.editSplitOrientation(n.frame,n.measure,r))};h();const f=new ResizeObserver(i=>{for(const u of i){const[c]=u.borderBoxSize;c!==void 0&&(u.target===s&&(n.frame=c.inlineSize),u.target===l&&(n.measure=c.inlineSize))}h()});return f.observe(s),f.observe(l),()=>f.disconnect()},[e,t,r]),o},vt=({editorId:e})=>{const{edits:t,labels:r}=x.useExplorer(),o=p.useRef(null),a=p.useRef(null),s=ue.useCoarsePointer()?G.COARSE_TARGET_PIXELS:G.FINE_TARGET_PIXELS,l=gt(o,a,s),[n]=p.useState(()=>t.editorShare());p.useLayoutEffect(()=>{const i=Z(o);return i.style.setProperty(Ee,`${String(s)}px`),()=>{i.style.removeProperty(Ee)}},[s]),p.useLayoutEffect(()=>{const i=Z(o);return i.style.setProperty(re,`${String(n)}%`),()=>{i.style.removeProperty(re)}},[n]),p.useLayoutEffect(()=>{if(l===null)return;const i=Z(o);return i.setAttribute(we,l),()=>i.removeAttribute(we)},[l]);const h=ue.useSplitPersistence(p.useCallback(i=>{const u=Se(i);u!==null&&t.setEditorShare(u)},[t])),f=p.useCallback((i,u)=>{const c=Se(i);c!==null&&Z(o).style.setProperty(re,`${String(c)}%`),h.layoutChanged(i,u)},[h]);return L.jsxs("div",{ref:o,className:"aqmx-edit-split","data-testid":"markdown-explorer-edit-split",children:[L.jsx("span",{ref:a,className:"aqmx-edit-split-probe","aria-hidden":"true",[ft]:""}),l===null?null:L.jsxs(Q.PanelGroup,{id:pt,direction:l==="beside"?"horizontal":"vertical",onLayout:f,className:"aqmx-edit-split-group",children:[L.jsx(Q.Panel,{id:mt,defaultSize:{value:n,unit:"percentage"},minSize:be,maxSize:xe,contentOverflow:"hidden"}),L.jsx(Q.PanelResizeHandle,{thickness:s,indicator:{visible:!0,thickness:G.SPLIT_HANDLE_PIXELS.gripThickness,length:G.SPLIT_HANDLE_PIXELS.gripLength,barThickness:G.SPLIT_HANDLE_PIXELS.barThickness,barLength:G.SPLIT_HANDLE_PIXELS.barLength},title:r.editViewSplitResize,"aria-label":r.editViewSplitResize,"aria-controls":e,onDragging:h.draggingChanged,className:"aqmx-split-handle aqmx-edit-split-handle"}),L.jsx(Q.Panel,{id:ht,defaultSize:{value:100-n,unit:"percentage"},minSize:be,maxSize:xe,contentOverflow:"hidden"})]})]})},Oe=144,wt=Object.freeze(["e1","e2","e3","e4","e5","e6","e7","e8"]),Et=e=>{if(typeof e!="object"||e===null)return!1;const{generation:t,topLine:r}=e;return"state"in e&&typeof t=="number"&&typeof r=="number"},bt=e=>{e.stopPropagation()},xt=e=>{const{path:t,name:r,session:o}=e,{edits:a,labels:s,announcer:l}=x.useExplorer(),{phase:n}=o,h=p.useCallback(()=>a.retry(t),[a,t]);switch(p.useEffect(()=>{n.kind==="failed"&&l.announce(s.documentFailed(r,x.failureTitleOf(s,n.failure.reason)))},[n,l,s,r]),n.kind){case"opening":return L.jsxs(L.Fragment,{children:[L.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-skeleton",children:wt.map(f=>L.jsx("span",{},f))}),L.jsx("p",{className:"aqmx-sr-only",children:s.editLoading})]});case"grant":return L.jsx("div",{className:"aqmx-edit-message",children:L.jsx(x.EditGrantNotice,{href:n.href,onRetry:h,testId:"markdown-explorer-edit-grant"})});case"failed":return L.jsx("div",{className:"aqmx-edit-message",children:L.jsx(x.FailureView,{failure:n.failure,alert:!1,onRetry:h,testId:"markdown-explorer-edit-failure"})});case"editing":return L.jsx(St,{...e})}},St=({path:e,name:t,session:r,layout:o,viewer:a,region:s,paneScroll:l})=>{const{edits:n,labels:h}=x.useExplorer(),f=p.useRef(null),i=p.useId(),u=p.useRef(null),c=p.useRef(null),g=p.useRef(null),m=o==="fill",S=x.useSideBySide(),v=x.editViewOf(r,S,m),k=v!=="editor"||r.previewPrepared,O=k&&m,A=p.useRef({layout:o,region:s,paneScroll:l});p.useLayoutEffect(()=>{A.current={layout:o,region:s,paneScroll:l}});const j=p.useRef(r.generation);p.useLayoutEffect(()=>{j.current=r.generation});const D=p.useRef({view:v,previewMounted:k});p.useLayoutEffect(()=>{D.current={view:v,previewMounted:k}});const V=p.useRef(null),H=p.useRef(null),b=p.useRef(!1),T=p.useMemo(()=>({editor:h.editorLabel(t),useOurs:h.conflictUseOurs,useTheirs:h.conflictUseTheirs,keepBoth:h.conflictKeepBoth}),[h,t]),q=p.useCallback(d=>{const{region:E,paneScroll:R}=A.current,M=E();return M===null?d:R.scrollerOf(M,d)},[]);p.useLayoutEffect(()=>{const d=f.current,E=n.draft(e);if(d===null||E===null)return;const R=n.editorState.get(e),M=Et(R)&&R.generation===j.current?R:null;let C=null,U=null;const te=()=>{C!==null&&clearTimeout(C),C=null,U!==null&&n.setDraft(e,U.text())},F=ze({parent:d,scroll:{scrollerOf:N=>{const{layout:J,region:Ie,paneScroll:Me}=A.current,le=Ie();return J==="fill"||le===null?N:Me.scrollerOf(le,N)},reveal:N=>A.current.paneScroll.reveal(N)},text:E,saved:M===null?void 0:M.state,labels:T,onGeometry:N=>g.current?.editorChanged(N),onChange:()=>{C??=setTimeout(te,Oe),D.current.previewMounted&&U!==null&&c.current?.draft(U.text())},onSave:()=>{n.save(e)}});U=F,u.current=F;const ie=()=>{const N=F.topLine();return{line:N.line,clientTop:N.clientTop}},se=()=>c.current?.anchor(q)??null,Ae=n.bindEditor(e,{flush:te,adopt:N=>F.replaceText(N),returnPoint:()=>{const N=D.current.view==="preview"&&A.current.layout==="content"?se():null;return N===null?ie():{line:N.lines.first,clientTop:N.clientTop}},nextConflict:()=>D.current.view!=="preview"?F.nextConflict():F.conflicts().length===0?!1:(b.current=!0,n.setView(e,"editor"),!0),beforeView:N=>{if(A.current.layout==="fill")return;if(N==="preview"){V.current={to:"preview",point:ie()};return}const J=se();V.current=J===null?null:{to:"editor",anchor:J}}});return M!==null&&F.showLine(M.topLine),()=>{te(),n.editorState.set(e,{state:F.save(),generation:j.current,topLine:F.topLine().line}),Ae(),F.destroy(),U=null,u.current=null}},[n,e,T,q]);const{request:P}=r;p.useLayoutEffect(()=>{const d=u.current,E=n.draft(e);d===null||E===null||P===null||(P.anchor!==null&&d.reveal(x.positionInSource(E,P.anchor),P.anchor.clientTop),d.focus(),n.consumeRequest(e))},[n,e,P,T]),p.useLayoutEffect(()=>{v!=="editor"&&!r.previewPrepared&&n.preparePreview(e)},[n,e,v,r.previewPrepared]),p.useLayoutEffect(()=>{const d=V.current,E=H.current,R=b.current;V.current=null,H.current=null,b.current=!1;const M=u.current;if(d?.to==="preview")c.current?.place(d.point,q);else if(d?.to==="editor"&&M!==null){const C=n.draft(e);C!==null&&M.reveal(x.positionInSource(C,d.anchor),d.anchor.clientTop)}R?M?.nextConflict():E==="editor"?M?.focus():E==="preview"&&c.current?.focus()},[n,e,v,q]);const w=p.useCallback(()=>{const d=u.current;if(d===null)throw new Error("[markdown-explorer] the preview read the draft before the editor was mounted");return d.text()},[]);p.useLayoutEffect(()=>{const d=u.current;if(!O||d===null)return;const E=it({editor:qe(d.scrollElement),preview:()=>c.current?.scrollPort()??null,previewBlocks:()=>c.current?.blocks()??[],editorSpans:R=>d.lineSpans(R),requestFrame:R=>requestAnimationFrame(R),cancelFrame:R=>cancelAnimationFrame(R),now:()=>performance.now()});return E.showAlone(x.paneShownAlone(D.current.view)),g.current=E,()=>{E.dispose(),g.current=null}},[O,n,e,T]),p.useLayoutEffect(()=>{g.current?.showAlone(x.paneShownAlone(v))},[v]);const B=p.useCallback(()=>g.current?.previewChanged(),[]),z=p.useCallback(d=>n.start(e,d),[n,e]),y=d=>{if(d.key==="Escape"){x.consumeKey(d);return}if(!x.isEditViewShortcut(d.nativeEvent,x.isApplePlatform(navigator.platform)))return;x.consumeKey(d);const E=x.toggledEditView(v);H.current=E,x.chooseEditView(n,e,E,m)};return L.jsxs("div",{className:"aqmx-edit","data-aqmx-edit-layout":o,"data-aqmx-edit-view":v,"data-testid":"markdown-explorer-edit",onKeyDown:y,onDoubleClick:bt,children:[L.jsx("div",{ref:f,id:i,className:"aqmx-edit-editor","data-testid":"markdown-explorer-editor",inert:v==="preview",hidden:v==="preview"&&!m,...x.ALLOW_KEY_REPEAT}),v==="split"?L.jsx(vt,{editorId:i}):null,k?L.jsx(dt,{path:e,readDraft:w,viewer:a,concealed:v!=="editor"?null:m?"overlay":"removed",onEditAt:v==="preview"?z:void 0,onLayout:B,handleRef:c}):null]})};exports.DRAFT_WRITE_INTERVAL_MS=Oe;exports.default=xt;
@@ -1 +1 @@
1
- "use strict";const c=require("react/jsx-runtime"),v=require("./index-5gwNJ8CB.cjs"),r=require("react"),A=require("./location-D85EXiPt.cjs"),He=require("@aiquants/directory-tree"),mt=require("./tapScrollCircle-C5DGI-0H.cjs"),pt=require("./storage-DM0EvkVf.cjs"),xe=require("@aiquants/resize-panels"),Ae=require("./useSplitPersistence-DRjsPZdH.cjs"),ht=require("react-router");function xt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const p=xt(r);function wt({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15ZM9 12.75a.75.75 0 0 0 0 1.5h6a.75.75 0 0 0 0-1.5H9Z",clipRule:"evenodd"}))}const gt=p.forwardRef(wt);function Et({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15Zm-6.75-10.5a.75.75 0 0 0-1.5 0v2.25H9a.75.75 0 0 0 0 1.5h2.25v2.25a.75.75 0 0 0 1.5 0v-2.25H15a.75.75 0 0 0 0-1.5h-2.25V10.5Z",clipRule:"evenodd"}))}const bt=p.forwardRef(Et);function vt({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M16.5 6a3 3 0 0 0-3-3H6a3 3 0 0 0-3 3v7.5a3 3 0 0 0 3 3v-6A4.5 4.5 0 0 1 10.5 6h6Z"}),p.createElement("path",{d:"M18 7.5a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-7.5a3 3 0 0 1-3-3v-7.5a3 3 0 0 1 3-3H18Z"}))}const Rt=p.forwardRef(vt);function yt({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M3 6a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3V6ZM3 15.75a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-2.25Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3v-2.25Z",clipRule:"evenodd"}))}const St=p.forwardRef(yt),kt=()=>{const{notices:e}=v.useExplorer(),t=r.use(e);return t.length===0?null:c.jsx("div",{className:"aqmx-explorer-notices",children:t.map(n=>c.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":n.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":n.id,children:[c.jsx("p",{className:"aqmx-callout-title",children:n.title}),n.body===void 0?null:c.jsx("p",{className:"aqmx-callout-body",children:n.body}),n.action===void 0?null:c.jsx("a",{className:"aqmx-callout-action",href:n.action.href,children:n.action.label})]},n.id))})};function Ct({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M6.912 3a3 3 0 0 0-2.868 2.118l-2.411 7.838a3 3 0 0 0-.133.882V18a3 3 0 0 0 3 3h15a3 3 0 0 0 3-3v-4.162c0-.299-.045-.596-.133-.882l-2.412-7.838A3 3 0 0 0 17.088 3H6.912Zm13.823 9.75-2.213-7.191A1.5 1.5 0 0 0 17.088 4.5H6.912a1.5 1.5 0 0 0-1.434 1.059L3.265 12.75H6.11a3 3 0 0 1 2.684 1.658l.256.513a1.5 1.5 0 0 0 1.342.829h3.218a1.5 1.5 0 0 0 1.342-.83l.256-.512a3 3 0 0 1 2.684-1.658h2.844Z",clipRule:"evenodd"}))}const Tt=p.forwardRef(Ct),ye=r.createContext(!0),Ze="\0loop\0",$e="\0",Lt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=o=>{const l=e.get(o);if(l!==void 0)return l;const i=Object.freeze({type:"loop",name:o.name,path:o.path});return e.set(o,i),i},s=(o,l,i)=>{let f=!1;const m=o.map(h=>{const x=u(h,l,i);return x!==h&&(f=!0),x});if(!f)return o;const d=n.get(o);return d!==void 0&&d.length===m.length&&d.every((h,x)=>h===m[x])?d:(n.set(o,m),m)},u=(o,l,i)=>{if(o.type!=="directory")return o;if(i.has(o.path))return a(o);const f=o.lazy===!0?l(o.path):void 0,m=f?.status==="loaded",d=m?f.entries:o.children;if(d===void 0)return o;i.add(o.path);const h=s(d,l,i);if(i.delete(o.path),!m&&h===o.children)return o;const x=t.get(o);if(x!==void 0&&x.state===f&&x.children===h)return x.grafted;const g={...o,children:h,lazy:m?!1:o.lazy};return t.set(o,{state:f,children:h,grafted:g}),g};return(o,l)=>s(o,l,new Set)},jt=(e,t)=>`${Ze}${e}${$e}${t}`,ie=e=>e.startsWith(Ze),Pt=e=>e.slice(e.lastIndexOf($e)+1),re="data-aqmx-path",Nt=(e,t,n,a,s)=>{const u={aqmxPath:e.path};return e.modifiedAt!==void 0&&(u.aqmxModifiedAt=e.modifiedAt),n&&(u.aqmxOpen=!0),(a==="loading"||a==="failed")&&(u.aqmxChildren=a),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:s,data:u}},Ot=(e,t,n,a)=>{const s=jt(t,e.path);return{name:n,type:"directory",absolutePath:s,relativePath:s,children:a,data:{aqmxLoop:e.path}}},At=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=[],s=(l,i,f)=>{const m=l.map(h=>h.type==="loop"?u(h,i,f):o(h,i)),d=n.get(l);return d!==void 0&&d.length===m.length&&d.every((h,x)=>h===m[x])?d:(n.set(l,m),m)},u=(l,i,f)=>{const m=t.get(l);if(m!==void 0&&m.parentKey===f&&m.loopFolderName===i.loopFolderName)return m.row;const d=Ot(l,f,i.loopFolderName(l.name),a);return t.set(l,{row:d,parentKey:f,loopFolderName:i.loopFolderName}),d},o=(l,i)=>{const f=l.type==="directory"?l.children===void 0?a:s(l.children,i,l.path):void 0,m=i.openPaths.has(l.path),d=l.type==="directory"&&l.lazy===!0?i.childrenOf(l.path)?.status:void 0,h=d==="failed"?i.renderFailedFolder:void 0,x=e.get(l);if(x!==void 0&&x.open===m&&x.childrenStatus===d&&x.children===f&&x.renderFailedFolder===h)return x.row;const g=Nt(l,f,m,d,h===void 0?void 0:h(l));return e.set(l,{row:g,open:m,childrenStatus:d,children:f,renderFailedFolder:h}),g};return(l,i)=>s(l,i,"")},qt=e=>{if(e===void 0)return;const t=n=>{const a=n.data?.aqmxModifiedAt;return typeof a=="number"?{name:n.name,path:n.absolutePath,type:n.type,modifiedAt:a}:{name:n.name,path:n.absolutePath,type:n.type}};return(n,a)=>e(t(n),t(a))},Re=(e,t)=>{const n=e.filter(a=>a.type==="directory");return t===void 0?n:n.sort(t)},Mt=(e,t)=>{const n=new Map;let a=0;const s=u=>{for(const o of Re(u,t.compare))if(t.isShownExpanded(o.path)){if(o.lazy!==!0){o.children!==void 0&&s(o.children);continue}n.has(o.path)||(n.set(o.path,t.isDirect(o.path)?"direct":"bulk"),t.childrenOf(o.path)?.status!=="failed"&&(a+=1))}};return s(e),{folders:n,waiting:a}},Ft=e=>{const t=new Set,n=a=>{for(const s of a)s.type==="directory"&&(s.lazy===!0&&t.add(s.path),s.children!==void 0&&n(s.children))};return n(e),t},Be=(e,t)=>{for(const n of e){if(n.type!=="directory")continue;if(n.path===t)return n;const a=n.children===void 0?null:Be(n.children,t);if(a!==null)return a}return null},_t=(e,t,n,a)=>{let s=e;for(const u of t){const o=s.find(l=>l.type==="directory"&&l.path===u);if(o===void 0)return"missing";if(o.lazy===!0)return a.childrenOf(o.path)?.status==="failed"?"failed":"loading";if(!a.isShownExpanded(o.path))return"loading";s=o.children??[]}return s.some(u=>u.type==="file"&&u.path===n)?"ready":"missing"},qe=new Set,It=(e,t)=>e.has(t)?e:new Set(e).add(t),Dt=(e,t)=>{if(!t.some(a=>e.has(a)))return e;const n=new Set(t);return new Set([...e].filter(a=>!n.has(a)))},Ht=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),Zt=()=>{const[e,t]=r.useState(qe),n=r.useCallback(o=>t(l=>It(l,o)),[]),a=r.useCallback(o=>t(l=>Dt(l,o)),[]),s=r.useCallback(o=>t(l=>Ht(l,o)),[]),u=r.useCallback(()=>t(qe),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:a,pruneDirect:s,clearDirect:u}),[e,n,a,s,u])},$t=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),Bt=(e,t)=>{const n=[];let a=Re(t.entries,t.compare);for(let s=1;a.length>0;s+=1){const u=[];for(const o of a){const{path:l}=o;if(t.isShownExpanded(l))e.handled.add(l);else{if(e.handled.has(l))continue;if(e.handled.add(l),o.lazy===!0&&t.childrenOf(l)===void 0){if(s>e.budget.maxDepth){e.depthLimited=!0;continue}if(e.loads.size>=e.budget.maxFolders){e.folderLimited=!0;continue}e.loads.add(l)}n.push(l),e.opened+=1}o.lazy!==!0&&o.children!==void 0&&u.push(...Re(o.children,t.compare))}a=u}return n},ze=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||ze(n.children,t))),zt=(e,t)=>{if(e.folderLimited)return{kind:"folder-limit",opened:e.opened};if(e.depthLimited)return{kind:"depth-limit",opened:e.opened};let n=0;for(const a of e.loads)t.childrenOf(a)?.status==="failed"&&(n+=1);return{kind:"done",opened:e.opened,failed:n,complete:ze(t.entries,t.isShownExpanded)}},ve=Object.freeze({state:"idle"}),Vt=e=>{const t=r.useRef(null),n=r.useRef(e),[a,s]=r.useState(ve);r.useLayoutEffect(()=>{n.current=e});const u=r.useCallback(()=>{t.current===null&&(t.current=$t(n.current.budget),s({state:"running",opened:0}))},[]),o=r.useCallback(()=>{t.current=null,s(ve)},[]),l=r.useCallback(i=>{const f=t.current;if(f===null)return;const m=Bt(f,i);if(m.length>0&&(f.issuedAgainst=i.expanded,n.current.expandMultiple([...m])),!f.announcedStart&&(f.loads.size>0||i.waiting>0)&&(f.announcedStart=!0,n.current.onStart()),m.length===0&&!i.expansionPending&&i.expanded!==f.issuedAgainst&&i.waiting===0){t.current=null;const h=zt(f,i);s(h.kind==="done"?ve:{state:"stopped",stop:h.kind,opened:h.opened}),n.current.onFinish(h);return}const{opened:d}=f;s(h=>h.state==="running"&&h.opened===d?h:{state:"running",opened:d})},[]);return r.useMemo(()=>({status:a,start:u,end:o,advance:l}),[a,u,o,l])},Me=["pointerdown","wheel","touchstart","keydown","focusin"],Kt=8,Fe={least:Number.POSITIVE_INFINITY,stalled:0},Xt=({tree:e,container:t,path:n,chain:a,rows:s,cancel:u,displayed:o,placement:l})=>{const i=r.useRef(null),f=r.useRef(!0),m=r.useRef(Fe),d=r.useRef(null),h=r.useRef(null),x=r.useRef(a),g=r.useRef(l);r.useLayoutEffect(()=>{x.current=a,g.current=l},[a,l]);const E=r.useCallback(()=>{const y=d.current;y!==null&&(d.current=null,y.phase==="asking"?y.controller.abort():x.current?.open(null))},[]),j=r.useCallback(()=>{i.current=null,E()},[E]),L=r.useCallback(()=>{const y=t.current;i.current===null||h.current!==null||y===null||y.getClientRects().length===0||(h.current=requestAnimationFrame(()=>{h.current=null;const T=i.current;if(T===null)return;const S=g.current(T);if(S===0){f.current=!0,d.current?.phase==="opening"&&E();return}if(e.current?.scrollToPath(T,{align:"nearest"})===!0){d.current?.phase==="opening"&&E();const{least:q,stalled:_}=m.current;m.current=S<q?{least:S,stalled:0}:{least:q,stalled:_+1},m.current.stalled<Kt&&L();return}const b=d.current;if(b===null){i.current=null;return}b.phase==="opening"&&x.current?.progress(b.folders,T)!=="loading"&&j()}))},[e,t,E,j]),N=r.useCallback(()=>{f.current=!1,m.current=Fe,L()},[L]);r.useEffect(()=>{const y=t.current;if(y===null)return;const T=typeof ResizeObserver>"u"?null:new ResizeObserver(N);T?.observe(y);for(const S of Me)y.addEventListener(S,j,{passive:!0});return()=>{T?.disconnect();for(const S of Me)y.removeEventListener(S,j);h.current!==null&&cancelAnimationFrame(h.current),h.current=null,E()}},[t,N,j,E]);const R=a!==null;r.useEffect(()=>{const y=t.current;if(j(),n===null||y===null||y.contains(y.ownerDocument.activeElement))return;i.current=n;const T=x.current;if(R&&T!==null){const S=new AbortController,b={phase:"asking",controller:S};d.current=b,T.ancestors(n,S.signal).then(q=>{d.current===b&&(q===null?d.current=null:(d.current={phase:"opening",folders:q},x.current?.open(q)),N())})}N()},[n,R,t,j,N]),r.useEffect(()=>{(d.current?.phase==="opening"||i.current!==null&&!f.current)&&N()},[s,N]);const F=r.useRef(u);r.useEffect(()=>{F.current!==u&&(F.current=u,j())},[u,j]);const C=r.useRef(o);r.useEffect(()=>{C.current&&!o&&E(),C.current=o},[o,E])},Wt="--aqmx-tree-line",Gt=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),Ut="data-aqmx-tree-probe",Yt=Object.freeze({rowHeight:A.CONTROL_BLOCK_PIXELS,lineColor:null}),Qt=/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/u,Jt=e=>{const t=Qt.exec(e);return t===null?e:`#${t.slice(1).map(n=>Number(n).toString(16).padStart(2,"0")).join("")}`},en=(e,t)=>{const[n,a]=r.useState(Yt);return r.useLayoutEffect(()=>{const s=e.current;if(s===null)return;const u=()=>{const i=Math.round(s.getBoundingClientRect().height),f=getComputedStyle(s),m=f.getPropertyValue(Wt).trim()===""?null:Jt(f.color);a(d=>{const h=Number.isFinite(i)&&i>0?i:d.rowHeight;return d.rowHeight===h&&d.lineColor===m?d:{rowHeight:h,lineColor:m}})};u();const o=Gt.map(i=>window.matchMedia(i));for(const i of o)i.addEventListener("change",u);const l=typeof ResizeObserver>"u"?null:new ResizeObserver(u);return l?.observe(s),()=>{for(const i of o)i.removeEventListener("change",u);l?.disconnect()}},[e,t]),n},Ve="markdown-explorer-tree-scroll",tn=.5,Ke=(e,t)=>[...e.querySelectorAll(`[role="treeitem"][${re}]`)].find(n=>n.getAttribute(re)===t),nn=(e,t)=>{const n=Ke(e,t),a=n?.closest(`[data-testid="${Ve}"]`);if(n===void 0||a===null||a===void 0)return Number.POSITIVE_INFINITY;const s=a.getBoundingClientRect(),u=n.getBoundingClientRect(),o=s.top-u.top,l=u.height>s.height?Math.abs(o):Math.max(0,o)+Math.max(0,u.bottom-s.bottom);return l<=tn?0:l},rn={testId:Ve,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:{width:8,enableTrackClick:!0,enableThumbDrag:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:mt.TAP_SCROLL_CIRCLE},behaviorOptions:{enablePointerDrag:!0}},an={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},ln={color:"inherit",fontSize:"inherit"},on={paddingBlock:0,fontSize:"inherit"},sn=new Set,cn=new Map,un={color:"var(--aqmx-tree-line)"},dn=e=>{const t=e instanceof Element?e.closest(`[${re}]`):null;return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(re)},Xe=(e,t,n,a)=>n==="folder-limit"?e.expandAllFolderLimit(a,t.maxFolders,e.expandAll):e.expandAllDepthLimit(a,t.maxDepth),fn=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):Xe(e,t,n.kind,n.opened),We=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-explorer-loading","aria-busy":"true","data-testid":"markdown-explorer-tree-loading",children:[c.jsx("p",{className:"aqmx-explorer-loading-text",children:e.treeLoading}),c.jsxs("div",{className:"aqmx-skeleton","aria-hidden":"true",children:[c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{})]})]})},mn=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[c.jsx(Tt,{className:"aqmx-explorer-empty-icon","aria-hidden":"true"}),c.jsx("p",{className:"aqmx-empty-title",children:e.treeEmptyTitle}),c.jsx("p",{className:"aqmx-explorer-empty-body",children:e.treeEmptyBody})]})},pn=({name:e,onRetry:t})=>{const{labels:n}=v.useExplorer(),a=r.useId();return c.jsxs("span",{className:"aqmx-explorer-folder-failed",children:[c.jsx("span",{className:"aqmx-explorer-folder-name",children:e}),c.jsx("span",{id:a,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),c.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":a,"data-testid":"markdown-explorer-folder-retry",onClick:s=>{s.stopPropagation();const u=s.currentTarget,o=u.ownerDocument.activeElement===u?u.closest('[role="treeitem"]'):null;o instanceof HTMLElement&&v.focusWithoutScroll(o),t()},onKeyDown:s=>{s.key!=="Escape"&&s.stopPropagation()},children:[c.jsx(v.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},hn=({entries:e,version:t,mode:n,sourceId:a,settings:s,reveal:u,openPaths:o,selection:l,onOpenDocument:i,folders:f,onRevealSource:m,expansion:d,onShown:h,marks:x,claimsHeld:g,expandAll:E,revealCancel:j})=>{const{trees:L,documents:N,labels:R,locale:F,theme:C,data:y,config:T,sources:S,reveals:b}=v.useExplorer(),q=r.use(ye),[_]=r.useState(At),ae=r.useRef(null),{rowHeight:Q,lineColor:Z}=en(ae,C),{isExpanded:$,toggle:J,expandMultiple:I,collapseMultiple:X,expanded:W,isPending:G}=d,{alwaysExpanded:O,sortMode:ee,folderPlacement:le,readmePlacement:ue}=s,{direct:te,markDirect:B,unmarkDirect:U,pruneDirect:fe}=x,{running:oe,advance:se}=E,de=r.useRef(null),ne=r.useRef(null),z=r.useMemo(()=>A.createEntryComparator({sortMode:ee,folderPlacement:le,readmePlacement:ue}),[ee,le,ue]),P=r.useMemo(()=>qt(z),[z]),M=r.useCallback(w=>L.children(a,w),[L,a]),D=r.useMemo(()=>Ft(e),[e]),Y=r.useCallback(w=>!ie(w)&&($(w)||O&&!D.has(w)),[$,O,D]),V=r.useRef({shownExpanded:Y,isExpanded:$,unloadedFolders:D,entries:e,childrenOf:M});r.useLayoutEffect(()=>{V.current={shownExpanded:Y,isExpanded:$,unloadedFolders:D,entries:e,childrenOf:M}},[Y,$,D,e,M]);const Ce=r.useCallback(w=>{de.current?.scrollToPath(w,{align:"nearest"}),requestAnimationFrame(()=>{const k=ne.current,H=k===null?void 0:Ke(k,w);H!==void 0&&v.focusWithoutScroll(H)})},[]),tt=r.useCallback(w=>{if(ie(w)){Ce(Pt(w));return}V.current.isExpanded(w)?U([w]):V.current.unloadedFolders.has(w)&&B(w),J(w)},[Ce,B,U,J]),ge=r.useCallback(w=>{const k=w.filter(H=>!ie(H));k.length!==0&&(U(k),X(k))},[U,X]),nt=r.useCallback(w=>{const k=w.filter(H=>!ie(H));k.length!==0&&(k.length<w.length&&k.every(H=>V.current.shownExpanded(H))?ge(k):I(k))},[I,ge]),Te=r.useCallback(w=>c.jsx(pn,{name:w.name,onRetry:()=>{B(w.path),L.retryChildren(a,w.path),V.current.shownExpanded(w.path)||I([w.path])}}),[L,a,B,I]),Le=n==="multi"?o:sn,{loopFolderName:je}=R,rt=r.useMemo(()=>_(e,{openPaths:Le,childrenOf:M,renderFailedFolder:Te,loopFolderName:je}),[_,e,Le,M,Te,je,t]),at=v.useIntentPrefetch(N,dn),Pe=r.useRef([]),me=r.useCallback(()=>{for(const w of Pe.current)V.current.unloadedFolders.has(w)&&B(w)},[B]),{maxDepth:Ee}=T.revealDocument,Ne=r.useRef(m);r.useLayoutEffect(()=>{Ne.current=m},[m]);const lt=r.useMemo(()=>({ancestors:async(w,k)=>{const H=b.take(a,w);if(H!==null)return H;if(!b.mayMove(w)){const ce=await y.ancestors(a,w,k);return ce.status!=="ok"||ce.ancestors===null||ce.ancestors.length>Ee?null:ce.ancestors}const K=await y.reveal(a,w,k);return K.status!=="ok"||K.source===null||K.ancestors.length>Ee?null:K.source===a?K.ancestors:(k.aborted||!S.some(ce=>ce.id===K.source)||(b.move(K.source,w,K.ancestors),Ne.current(K.source)),null)},open:w=>{Pe.current=w??[],w!==null&&(me(),I([...w]))},progress:(w,k)=>_t(V.current.entries,w,k,{isShownExpanded:V.current.shownExpanded,childrenOf:V.current.childrenOf})}),[y,a,S,b,Ee,me,I]);r.useEffect(()=>me(),[me,D]);const ot=r.useMemo(()=>[e,t,W],[e,t,W]),st=r.useCallback(w=>ne.current===null?Number.POSITIVE_INFINITY:nn(ne.current,w),[]);Xt({tree:de,container:ne,path:u.path,chain:u.openFolders?lt:null,rows:ot,cancel:j,displayed:q,placement:st});const Oe=r.useCallback(w=>te.has(w),[te]),pe=r.useMemo(()=>Mt(e,{isShownExpanded:Y,childrenOf:M,compare:z,isDirect:Oe}),[e,Y,M,z,Oe,t]),he=q&&g;r.useLayoutEffect(()=>{h(e)},[e,h]),r.useLayoutEffect(()=>()=>h(null),[h]),r.useEffect(()=>L.claimChildren(a,he?pe.folders:cn),[L,a,he,pe]),r.useEffect(()=>fe(D),[fe,D]),r.useEffect(()=>{he&&oe&&se({entries:e,isShownExpanded:Y,childrenOf:M,compare:z,expanded:W,waiting:pe.waiting,expansionPending:G})},[he,oe,se,e,Y,M,z,W,pe,G]);const ct=r.useCallback(w=>{const k=w.entry.absolutePath;if(w.isDirectory){if(f===null||ie(k)||k===f.current)return;w.isExpanded&&w.preventDefault(),b.settle(k),f.open(k);return}b.settle(k),i(k)},[b,i,f]),{onChange:be}=l,it=r.useMemo(()=>be===null?void 0:(w,k)=>{ie(w.absolutePath)||be({path:w.absolutePath,name:w.name,selected:k})},[be]),ut=r.useMemo(()=>new Set(l.items),[l.items]),dt=r.useMemo(()=>({entryKindDirectory:R.treeEntryKindDirectory,entryKindFile:R.treeEntryKindFile,scrollUp:R.treeScrollUp,scrollDown:R.treeScrollDown,scrollToTop:R.treeScrollToTop,scrollToBottom:R.treeScrollToBottom}),[R]),ft=Z===null?{showTreeLines:!1}:{showTreeLines:s.lines,lineColor:Z};return c.jsxs("div",{ref:ne,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",...at,children:[c.jsx("span",{ref:ae,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[Ut]:""}),c.jsx(He.DirectoryTree,{ref:de,entries:rt,expansion:{toggle:tt,isExpanded:Y,expandMultiple:nt,collapseMultiple:ge,isPending:G&&!oe,doubleClickAction:s.doubleClickAction},selection:{mode:l.mode,selectedPath:l.shownPath,currentPath:l.shownPath,selectedItems:ut,onEntryClick:ct,onSelectionChange:it},visual:{className:"aqmx-explorer-tree-view",ariaLabel:R.treeRegion,...ft,showExpandIcons:s.expandIcons,expandIconStyle:un,showDirectoryIcons:s.directoryIcons,showFileIcons:s.fileIcons,expandIconSize:s.expandIconSize,itemHeight:Q,removeRootIndent:s.removeRootIndent,highlightStyles:an,entryStyle:on,nameStyle:ln},virtualScroll:rn,sort:P,locale:F,labels:dt})]})},xn=({pending:e,status:t})=>{const{labels:n}=v.useExplorer(),a=t.state!=="running",[s,u]=r.useState(0),o=r.useRef(!0);r.useLayoutEffect(()=>{const i=o.current;if(o.current=a,!a||e>0&&!i){u(0);return}if(e>0){u(e);return}if(s===0)return;const f=setTimeout(()=>u(0),0);return()=>clearTimeout(f)},[a,e,s]);const l=a&&e===0?s:e;return l===0&&a?null:c.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(l),"data-aqmx-expand-all":t.state,children:[l>0?c.jsx(v.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,c.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,l):n.foldersLoading(l)})]})},wn=({stop:e,opened:t,budget:n})=>{const{labels:a}=v.useExplorer();return c.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:Xe(a,n,e,t)})},gn=({entries:e,...t})=>{const{trees:n}=v.useExplorer(),a=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:s}=t,[u]=r.useState(Lt),o=r.useMemo(()=>u(e,l=>n.children(s,l)),[u,e,n,s,a]);return o.length===0?c.jsx(mn,{}):c.jsx(hn,{entries:o,version:a,...t})},En=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:a}=v.useExplorer(),s=r.use(e);if(s.status==="deferred")return c.jsx(We,{});if(s.status==="ok")return c.jsx(gn,{entries:s.entries,...n});const u=a?.(s.failure);return c.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":s.failure.reason,children:u!==void 0?u:c.jsx(v.FailureView,{failure:s.failure,alert:!0,onRetry:t,testId:null})})},bn=({onControls:e,...t})=>{const{trees:n,storageNamespace:a,labels:s,announcer:u,config:o}=v.useExplorer(),{sourceId:l}=t,i=He.useDirectoryTreeState({storageKey:pt.storageKeys(a).treeExpansion(l)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const f=n.read(l),m=r.useCallback(()=>n.retry(l),[n,l]);r.useLayoutEffect(()=>n.open(l),[n,l]);const d=Zt(),{expanded:h,expandMultiple:x,collapseAll:g}=i,[E,j]=r.useState(null),L=E!==h,N=r.useRef(h);r.useLayoutEffect(()=>{N.current=h},[h]);const R=o.expandAll,F=r.useCallback(()=>u.announce(s.expandAllStarted),[u,s]),C=r.useCallback(O=>u.announce(fn(s,R,O)),[u,s,R]),y=Vt({budget:R,expandMultiple:x,onStart:F,onFinish:C}),{status:T,start:S,end:b,advance:q}=y,_=T.state==="running",ae=r.useMemo(()=>({running:_,advance:q}),[_,q]),Q=r.useRef(null),[Z,$]=r.useState(!1),J=r.useCallback(O=>{Q.current=O,$(O!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(O=>{const ee=O.sourceId===l&&Q.current!==null?Be(Q.current,O.path):null;ee!==null&&u.announce({list:s.foldersLoadFailedNamed,item:ee.name})}),[n,l,u,s]);const{clearDirect:I}=d,[X,W]=r.useState(0),G=r.useCallback(()=>{W(O=>O+1),b(),I(),j(N.current),g()},[b,I,g]);return r.useEffect(()=>{e({collapseAll:G,expandAll:Z?S:null,expanding:_})},[e,G,S,Z,_]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{Z||b()},[Z,b]),c.jsxs(c.Fragment,{children:[T.state==="stopped"?c.jsx(wn,{stop:T.stop,opened:T.opened,budget:R}):null,c.jsxs("div",{className:"aqmx-explorer-tree-area",children:[c.jsx(r.Suspense,{fallback:c.jsx(We,{}),children:c.jsx(En,{result:f,onRetry:m,expansion:i,onShown:J,marks:d,claimsHeld:L,expandAll:ae,revealCancel:X,...t})}),c.jsx(xn,{pending:n.pendingChildren(l),status:T})]})]})};function vn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const Ge=p.forwardRef(vn),_e="markdown-explorer-selection-remove",Rn=({selection:e,onRemove:t,onClear:n,onOpenSelection:a,onLeave:s})=>{const{labels:u}=v.useExplorer(),o=r.useId(),l=r.useRef(null),i=[...e],f=(d,h)=>{if(h.ownerDocument.activeElement===h){const x=l.current===null?[]:[...l.current.querySelectorAll(`[data-testid="${_e}"]`)],g=x.indexOf(h),E=[x[g+1],x[g-1]].find(j=>j!==void 0);E===void 0?s():E.focus()}t(d)},m=()=>{const d=l.current;d!==null&&d.contains(d.ownerDocument.activeElement)&&s(),n()};return c.jsxs("section",{ref:l,className:"aqmx-explorer-tray","aria-labelledby":o,"data-testid":"markdown-explorer-selection-tray",children:[c.jsxs("div",{className:"aqmx-explorer-tray-header",children:[c.jsx("p",{id:o,className:"aqmx-explorer-tray-title",children:u.selectionTitle(i.length)}),c.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:m,children:u.clearSelection})]}),c.jsx("ul",{className:"aqmx-explorer-tray-list",children:i.map(([d,h])=>c.jsxs("li",{className:"aqmx-explorer-tray-item",children:[c.jsx("span",{className:"aqmx-explorer-tray-name",title:d,children:h}),c.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":u.removeFromSelection(h),title:u.removeFromSelection(h),"data-testid":_e,"data-aqmx-path":d,onClick:x=>f(d,x.currentTarget),children:c.jsx(Ge,{"aria-hidden":"true"})})]},d))}),a===void 0?null:c.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>a(i.map(([d])=>d)),children:u.openSelectionInMulti(i.length)})]})},we=new Map,yn=(e,t)=>{if(t.selected===e.has(t.path))return e;const n=new Map(e);return t.selected?n.set(t.path,t.name):n.delete(t.path),n},Sn=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},Ue=r.createContext(null),kn=e=>{const t=r.use(Ue);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};function Cn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M15 3.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0V5.56l-3.97 3.97a.75.75 0 1 1-1.06-1.06l3.97-3.97h-2.69a.75.75 0 0 1-.75-.75Zm-12 0A.75.75 0 0 1 3.75 3h4.5a.75.75 0 0 1 0 1.5H5.56l3.97 3.97a.75.75 0 0 1-1.06 1.06L4.5 5.56v2.69a.75.75 0 0 1-1.5 0v-4.5Zm11.47 11.78a.75.75 0 1 1 1.06-1.06l3.97 3.97v-2.69a.75.75 0 0 1 1.5 0v4.5a.75.75 0 0 1-.75.75h-4.5a.75.75 0 0 1 0-1.5h2.69l-3.97-3.97Zm-4.94-1.06a.75.75 0 0 1 0 1.06L5.56 19.5h2.69a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75v-4.5a.75.75 0 0 1 1.5 0v2.69l3.97-3.97a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Tn=p.forwardRef(Cn);function Ln({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M6.97 2.47a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.25 4.81V16.5a.75.75 0 0 1-1.5 0V4.81L3.53 8.03a.75.75 0 0 1-1.06-1.06l4.5-4.5Zm9.53 4.28a.75.75 0 0 1 .75.75v11.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 1 1 1.06-1.06l3.22 3.22V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const jn=p.forwardRef(Ln);function Pn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M11.25 4.533A9.707 9.707 0 0 0 6 3a9.735 9.735 0 0 0-3.25.555.75.75 0 0 0-.5.707v14.25a.75.75 0 0 0 1 .707A8.237 8.237 0 0 1 6 18.75c1.995 0 3.823.707 5.25 1.886V4.533ZM12.75 20.636A8.214 8.214 0 0 1 18 18.75c.966 0 1.89.166 2.75.47a.75.75 0 0 0 1-.708V4.262a.75.75 0 0 0-.5-.707A9.735 9.735 0 0 0 18 3a9.707 9.707 0 0 0-5.25 1.533v16.103Z"}))}const Nn=p.forwardRef(Pn);function On({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm13.36-1.814a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}))}const An=p.forwardRef(On);function qn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M7.72 12.53a.75.75 0 0 1 0-1.06l7.5-7.5a.75.75 0 1 1 1.06 1.06L9.31 12l6.97 6.97a.75.75 0 1 1-1.06 1.06l-7.5-7.5Z",clipRule:"evenodd"}))}const Mn=p.forwardRef(qn);function Fn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M11.47 4.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1-1.06 1.06L12 6.31 8.78 9.53a.75.75 0 0 1-1.06-1.06l3.75-3.75Zm-3.75 9.75a.75.75 0 0 1 1.06 0L12 17.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-3.75 3.75a.75.75 0 0 1-1.06 0l-3.75-3.75a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const _n=p.forwardRef(Fn);function In({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M11.078 2.25c-.917 0-1.699.663-1.85 1.567L9.05 4.889c-.02.12-.115.26-.297.348a7.493 7.493 0 0 0-.986.57c-.166.115-.334.126-.45.083L6.3 5.508a1.875 1.875 0 0 0-2.282.819l-.922 1.597a1.875 1.875 0 0 0 .432 2.385l.84.692c.095.078.17.229.154.43a7.598 7.598 0 0 0 0 1.139c.015.2-.059.352-.153.43l-.841.692a1.875 1.875 0 0 0-.432 2.385l.922 1.597a1.875 1.875 0 0 0 2.282.818l1.019-.382c.115-.043.283-.031.45.082.312.214.641.405.985.57.182.088.277.228.297.35l.178 1.071c.151.904.933 1.567 1.85 1.567h1.844c.916 0 1.699-.663 1.85-1.567l.178-1.072c.02-.12.114-.26.297-.349.344-.165.673-.356.985-.57.167-.114.335-.125.45-.082l1.02.382a1.875 1.875 0 0 0 2.28-.819l.923-1.597a1.875 1.875 0 0 0-.432-2.385l-.84-.692c-.095-.078-.17-.229-.154-.43a7.614 7.614 0 0 0 0-1.139c-.016-.2.059-.352.153-.43l.84-.692c.708-.582.891-1.59.433-2.385l-.922-1.597a1.875 1.875 0 0 0-2.282-.818l-1.02.382c-.114.043-.282.031-.449-.083a7.49 7.49 0 0 0-.985-.57c-.183-.087-.277-.227-.297-.348l-.179-1.072a1.875 1.875 0 0 0-1.85-1.567h-1.843ZM12 15.75a3.75 3.75 0 1 0 0-7.5 3.75 3.75 0 0 0 0 7.5Z",clipRule:"evenodd"}))}const Dn=p.forwardRef(In);function Hn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M12 1.5a.75.75 0 0 1 .75.75V4.5a.75.75 0 0 1-1.5 0V2.25A.75.75 0 0 1 12 1.5ZM5.636 4.136a.75.75 0 0 1 1.06 0l1.592 1.591a.75.75 0 0 1-1.061 1.06l-1.591-1.59a.75.75 0 0 1 0-1.061Zm12.728 0a.75.75 0 0 1 0 1.06l-1.591 1.592a.75.75 0 0 1-1.06-1.061l1.59-1.591a.75.75 0 0 1 1.061 0Zm-6.816 4.496a.75.75 0 0 1 .82.311l5.228 7.917a.75.75 0 0 1-.777 1.148l-2.097-.43 1.045 3.9a.75.75 0 0 1-1.45.388l-1.044-3.899-1.601 1.42a.75.75 0 0 1-1.247-.606l.569-9.47a.75.75 0 0 1 .554-.68ZM3 10.5a.75.75 0 0 1 .75-.75H6a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 10.5Zm14.25 0a.75.75 0 0 1 .75-.75h2.25a.75.75 0 0 1 0 1.5H18a.75.75 0 0 1-.75-.75Zm-8.962 3.712a.75.75 0 0 1 0 1.061l-1.591 1.591a.75.75 0 1 1-1.061-1.06l1.591-1.592a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Zn=p.forwardRef(Hn);function $n({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5H5.625ZM7.5 15a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 7.5 15Zm.75 2.25a.75.75 0 0 0 0 1.5H12a.75.75 0 0 0 0-1.5H8.25Z",clipRule:"evenodd"}),p.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const Bn=p.forwardRef($n);function zn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const Vn=p.forwardRef(zn);function Kn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M19.906 9c.382 0 .749.057 1.094.162V9a3 3 0 0 0-3-3h-3.879a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H6a3 3 0 0 0-3 3v3.162A3.756 3.756 0 0 1 4.094 9h15.812ZM4.094 10.5a2.25 2.25 0 0 0-2.227 2.568l.857 6A2.25 2.25 0 0 0 4.951 21H19.05a2.25 2.25 0 0 0 2.227-1.932l.857-6a2.25 2.25 0 0 0-2.227-2.568H4.094Z"}))}const Xn=p.forwardRef(Kn);function Wn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M10.5 3.75a6.75 6.75 0 1 0 0 13.5 6.75 6.75 0 0 0 0-13.5ZM2.25 10.5a8.25 8.25 0 1 1 14.59 5.28l4.69 4.69a.75.75 0 1 1-1.06 1.06l-4.69-4.69A8.25 8.25 0 0 1 2.25 10.5Zm8.25-3.75a.75.75 0 0 1 .75.75v2.25h2.25a.75.75 0 0 1 0 1.5h-2.25v2.25a.75.75 0 0 1-1.5 0v-2.25H7.5a.75.75 0 0 1 0-1.5h2.25V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const Gn=p.forwardRef(Wn);function Un({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M5.625 3.75a2.625 2.625 0 1 0 0 5.25h12.75a2.625 2.625 0 0 0 0-5.25H5.625ZM3.75 11.25a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75ZM3 15.75a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75ZM3.75 18.75a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75Z"}))}const Yn=p.forwardRef(Un),Qn=Object.freeze({sortMode:jn,folderPlacement:Vn,readmePlacement:Nn,selectionMode:An,doubleClickAction:Zn,expandIconSize:Gn,alwaysExpanded:Tn,revealDocument:v.ForwardRef$1,removeRootIndent:Mn,lines:Yn,expandIcons:_n,directoryIcons:Xn,fileIcons:Bn}),Ye=(e,t)=>{const n=e[t.labelKey];if(typeof n!="string")throw new TypeError(`[markdown-explorer] the tree setting ${t.key} must name a string label; labels.${t.labelKey} is a ${typeof n}`);return n},Jn=({id:e,settings:t,descriptors:n,onAdvance:a,onClose:s,ref:u})=>{const{labels:o}=v.useExplorer(),l=r.useRef([]);r.useEffect(()=>{l.current[0]?.focus()},[]);const i=r.useCallback(m=>{const d=n.length;l.current[(m%d+d)%d]?.focus()},[n.length]),f=r.useCallback((m,d)=>{switch(m.key){case"ArrowDown":m.preventDefault(),i(d+1);break;case"ArrowUp":m.preventDefault(),i(d-1);break;case"Home":m.preventDefault(),i(0);break;case"End":m.preventDefault(),i(n.length-1);break;case"Escape":v.consumeKey(m),s();break;case"Tab":s();break}},[n.length,i,s]);return c.jsx("div",{ref:u,id:e,role:"menu","aria-label":o.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((m,d)=>{const h=Qn[m.key],x=Ye(o,m),g=A.formatTreeSettingValue(o,t,m.key),E=t[m.key],j=typeof E=="boolean"?{role:"menuitemcheckbox","aria-checked":E,"aria-label":x}:{role:"menuitem","aria-label":`${x}: ${g}`};return c.jsxs("button",{ref:L=>{l.current[d]=L},type:"button",tabIndex:-1,...j,title:`${x}: ${g}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":m.key,onClick:()=>a(m),onKeyDown:L=>f(L,d),children:[c.jsx(h,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-menu-name",children:x}),c.jsx("span",{className:"aqmx-explorer-menu-value",children:g})]},m.key)})})},er=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:a,announcer:s}=v.useExplorer(),[u,o]=r.useState(!1),l=r.useRef(null),i=r.useRef(null),f=r.useRef(null),m=r.useId(),d=r.useCallback(()=>{l.current?.focus(),o(!1)},[]);r.useEffect(()=>{if(!u)return;const g=E=>{E.target instanceof Node&&(l.current?.contains(E.target)===!0||i.current?.contains(E.target)===!0)||(o(!1),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{f.current=null,(document.activeElement===null||document.activeElement===document.body)&&l.current?.focus()},0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[u]),r.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);const h=r.useCallback(g=>{g.key!=="Escape"||!u||(v.consumeKey(g),d())},[u,d]),x=r.useCallback(g=>{const E=n(g.key);s.announce(a.settingAnnouncement(Ye(a,g),A.formatTreeSettingValue(a,E,g.key)))},[s,a,n]);return{trigger:c.jsx("button",{ref:l,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":u,"aria-controls":u?m:void 0,"aria-label":a.treeSettings,title:a.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>o(g=>!g),onKeyDown:h,children:c.jsx(Dn,{"aria-hidden":"true"})}),menu:u?c.jsx(Jn,{ref:i,id:m,settings:e,descriptors:t,onAdvance:x,onClose:d}):null}},tr=()=>{const{treeSettings:e}=v.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},Ie=new Set,nr='[role="tree"] [role="treeitem"][tabindex="0"]',rr="[data-directory-tree-tab-stop]",ar=e=>{const{mode:t,sourceId:n,currentPath:a,openPaths:s,onOpenDocument:u,onSourceChange:o,onRevealSource:l,viewSwitch:i}=e,{labels:f,sources:m,trees:d,documents:h,announcer:x,reveals:g}=v.useExplorer(),{settings:E,advance:j}=tr(),L=r.useMemo(()=>A.visibleTreeSettingDescriptors(t==="tree"),[t]),N=t==="tree"&&E.selectionMode==="multiple";kn(N);const R=e.mode==="tree"?e.tray.onGatheredChange:null,F=e.mode==="tree"?e.onOpenSelection:void 0,C=e.mode==="tree"?e.onOpenFolder:null,y=e.mode==="tree"&&e.currentFolder,T=r.useMemo(()=>C===null?null:{current:a,open:C},[C,a]),S=e.mode==="tree"&&N?e.tray.gathered:we,b=r.useCallback(P=>{const M=j(P);return M.selectionMode!=="multiple"&&R?.(we),M},[j,R]),q=er({settings:E,descriptors:L,onAdvance:b}),_=r.useCallback(P=>R?.(M=>yn(M,P)),[R]),ae=r.useCallback(P=>R?.(M=>Sn(M,P)),[R]),Q=r.useCallback(()=>R?.(we),[R]),Z=r.useRef(null),$=r.useCallback(()=>{const P=Z.current;if(P===null)return;[nr,rr,'[data-testid="markdown-explorer-tree-settings"]'].map(D=>P.querySelector(D)).find(D=>D!==null)?.focus()},[]),J=r.useMemo(()=>new Set(S.keys()),[S]),I=r.useMemo(()=>a===null?Ie:new Set([a]),[a]),X=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:s,shownPath:null,onChange:null};switch(E.selectionMode){case"single":return{mode:"single",items:I,shownPath:a,onChange:null};case"multiple":return{mode:"multiple",items:J,shownPath:a,onChange:_};case"none":return{mode:"none",items:Ie,shownPath:null,onChange:null}}},[t,s,E.selectionMode,I,a,J,_]),W=r.useMemo(()=>E.revealDocument?{path:a,openFolders:!y}:{path:X.shownPath,openFolders:!1},[E.revealDocument,a,y,X.shownPath]),G=r.useCallback(P=>{a!==null&&g.settle(a),o(P)},[a,g,o]),[O,ee]=r.useState(null),[le,ue]=r.useState(!1),[te,B]=r.useState(null),U=r.useRef(!1),fe=r.useCallback(async()=>{if(!U.current){U.current=!0,ue(!0),B(null);try{const P=await d.refresh(n);if(P.status==="superseded")return;h.invalidate(),P.status==="failed"?B({sourceId:n,failure:P.failure}):x.announce(f.treeRefreshed)}finally{U.current=!1,ue(!1)}}},[d,h,n,x,f]),oe=O===null?null:O.expandAll,se=O?.expanding===!0,de=m.find(P=>P.id===n),ne=i.target==="multi"?St:Rt,z=i.target==="multi"?f.switchToMulti:f.switchToTree;return c.jsxs("nav",{ref:Z,"aria-label":f.explorerRegion,className:"aqmx-explorer","data-testid":"markdown-explorer-explorer","data-aqmx-mode":t,children:[c.jsxs("div",{className:"aqmx-explorer-header",children:[m.length>1?c.jsx("select",{className:"aqmx-explorer-source","aria-label":f.sourceLabel,title:de?.label,value:n,onChange:P=>G(P.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:m.map(P=>c.jsx("option",{value:P.id,children:P.label},P.id))}):null,c.jsxs("div",{className:"aqmx-explorer-actions",children:[c.jsx(v.ExplorerLink,{to:i.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":z,title:z,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":i.target,children:c.jsx(ne,{"aria-hidden":"true"})}),c.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:f.refreshTree,"aria-disabled":le,"aria-busy":le,"data-aqmx-busy":le?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{fe()},children:[c.jsx(v.ForwardRef,{"aria-hidden":"true"}),c.jsx("span",{children:f.refreshTreeLabel})]}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.expandAll,title:f.expandAll,"aria-disabled":oe===null||se,"aria-busy":se,"data-aqmx-busy":se?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>oe?.(),children:c.jsx(bt,{"aria-hidden":"true"})}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.collapseAll,title:f.collapseAll,"aria-disabled":O===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>O?.collapseAll(),children:c.jsx(gt,{"aria-hidden":"true"})}),q.trigger]})]}),c.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[te!==null&&te.sourceId===n?c.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":te.failure.reason,children:f.treeRefreshFailed(v.failureTitleOf(f,te.failure.reason))}):null,c.jsx(r.Suspense,{fallback:null,children:c.jsx(kt,{})}),c.jsx(bn,{mode:t,sourceId:n,settings:E,reveal:W,openPaths:s,selection:X,onOpenDocument:u,folders:T,onRevealSource:l,onControls:ee},n),N&&S.size>0?c.jsx(Rn,{selection:S,onRemove:ae,onClear:Q,onOpenSelection:F,onLeave:$}):null,q.menu]})]})};function lr({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M3 6.75A.75.75 0 0 1 3.75 6h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 6.75ZM3 12a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 12Zm0 5.25a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75Z",clipRule:"evenodd"}))}const or=p.forwardRef(lr),sr=({explorer:e,toggleRef:t,covered:n,onNoticeSlotChange:a,dismissals:s})=>{const{labels:u}=v.useExplorer(),o=ht.useLocation(),{location:l}=v.useExplorerLocation(),[i,f]=r.useState(!1),[m,d]=r.useState({navigated:o,source:l.source}),[h,x]=r.useState(!1);m.navigated!==o&&(d({navigated:o,source:l.source}),m.source===l.source&&!h&&f(!1));const[g,E]=r.useState(s);g!==s&&(E(s),f(!1));const j=r.useRef(null),L=r.useRef(null),N=r.useRef(null),R=r.useRef(!1),F=r.useId();r.useLayoutEffect(()=>{const b=j.current;b!==null&&(i&&!b.open?(b.showModal(),L.current?.focus()):!i&&b.open&&(b.close(),t.current?.focus()),a(i?N.current:null))},[i,t,a]),r.useLayoutEffect(()=>()=>a(null),[a]);const C=r.useCallback(b=>{b.key!=="Escape"||b.defaultPrevented||(v.consumeKey(b),f(!1))},[]),y=r.useCallback(b=>{R.current=b.target===b.currentTarget},[]),T=r.useCallback(b=>{const q=R.current;R.current=!1,q&&b.target===b.currentTarget&&f(!1)},[]),S=r.useCallback(()=>{f(!1)},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"aqmx-sheet-bar",inert:n,children:c.jsxs("button",{ref:t,type:"button",className:"aqmx-sheet-toggle","aria-haspopup":"dialog","aria-expanded":i,"aria-controls":F,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>f(!0),children:[c.jsx(or,{"aria-hidden":"true"}),c.jsx("span",{children:u.showExplorer})]})}),c.jsx("dialog",{ref:j,id:F,className:"aqmx-sheet","aria-label":u.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:C,onPointerDown:y,onClick:T,onClose:S,children:c.jsxs("div",{className:"aqmx-sheet-panel",children:[c.jsxs("div",{className:"aqmx-sheet-header",children:[c.jsx("div",{ref:N,className:"aqmx-sheet-notice-slot"}),c.jsx("button",{ref:L,type:"button",className:"aqmx-sheet-close","aria-label":u.hideExplorer,title:u.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>f(!1),children:c.jsx(Ge,{"aria-hidden":"true"})})]}),c.jsx("div",{className:"aqmx-sheet-body",children:c.jsx(ye,{value:i,children:c.jsx(Ue,{value:x,children:e})})}),c.jsx(v.LiveRegion,{holds:i,testId:"markdown-explorer-sheet-announcer"})]})})]})},Qe=r.createContext(null),Se="aqmx-explorer",Je="aqmx-content",cr="--aqmx-split-band",ke='[role="tree"] [role="treeitem"]',ir=`${ke}[tabindex="0"]`,ur="[data-directory-tree-tab-stop]",dr=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${Se}"] ${ke}`))if(n.getAttribute(re)===t)return n;return null},De=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:A.ASSUMED_ROOT_FONT_PIXELS}),fr=(e,t)=>{const[n,a]=r.useState(()=>De(0,0));return r.useLayoutEffect(()=>{const s=e.current,u=t.current;if(s===null||u===null)throw new Error("[markdown-explorer] the split frame is not mounted");const o={frame:s.getBoundingClientRect().width,rem:u.getBoundingClientRect().width},l=()=>{const f=De(o.frame,o.rem);a(m=>m.inlineSize===f.inlineSize&&m.rootFontPixels===f.rootFontPixels?m:f)};l();const i=new ResizeObserver(f=>{for(const m of f){const[d]=m.borderBoxSize;d!==void 0&&(m.target===s&&(o.frame=d.inlineSize),m.target===u&&(o.rem=d.inlineSize))}l()});return i.observe(s),i.observe(u),()=>i.disconnect()},[e,t]),n},et=e=>`aqmx-split-handle-${e}`,mr=(e,{frameRef:t,sheetToggleRef:n,handleId:a})=>{const s=r.useRef(!1),u=r.useRef(null),o=r.useRef(!1);r.useLayoutEffect(()=>{const i=t.current;if(i===null)throw new Error("[markdown-explorer] the split frame is not mounted");const f=d=>{const h=d.target instanceof Element?d.target:null;s.current=h!==null&&h.closest(`[data-panel-id="${Je}"]`)===null,!o.current&&(u.current=h?.closest(`${ke}[${re}]`)?.getAttribute(re)??null)},m=d=>{d.relatedTarget instanceof Node&&!i.contains(d.relatedTarget)&&(s.current=!1)};return i.addEventListener("focusin",f),i.addEventListener("focusout",m),()=>{i.removeEventListener("focusin",f),i.removeEventListener("focusout",m)}},[t]);const l=r.useRef(e);r.useLayoutEffect(()=>{if(l.current===e)return;l.current=e;const i=t.current;if(i===null||!s.current)return;const f=m=>{const{activeElement:d,body:h}=i.ownerDocument;if(d!==null&&d!==h)return;const x=m.find(g=>g!==null);if(x!=null){o.current=!0;try{x.focus()}finally{o.current=!1}}};if(e){f([n.current]);return}queueMicrotask(()=>{if(l.current!==e||!s.current)return;const m=u.current,d=`[data-panel-id="${Se}"]`;f([m===null?null:dr(i,m),i.querySelector(`${d} ${ir}`),i.querySelector(`${d} ${ur}`),i.querySelector(`[data-resize-handle-id="${a}"]`)])})},[e,t,n,a])},pr=({view:e,explorer:t,content:n,contentCoversPage:a=!1,sheetDismissals:s=0,onDraggingChange:u})=>{const o=r.useRef(null),[l,i]=r.useState(null),f=r.useRef(null),m=r.useRef(null),{inlineSize:d,rootFontPixels:h}=fr(o,f),x=d!==null&&d<A.explorerSheetBelowPixels(h);return mr(x,{frameRef:o,sheetToggleRef:m,handleId:et(e)}),c.jsxs("div",{ref:o,className:"aqmx-split-frame","data-aqmx-explorer-mode":x?"sheet":"split",children:[c.jsx("span",{ref:f,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),x?c.jsx(sr,{explorer:t,toggleRef:m,covered:a,onNoticeSlotChange:i,dismissals:s}):null,c.jsx(Qe,{value:x?l:null,children:c.jsx(hr,{view:e,sheet:x,explorer:t,content:n,contentCoversPage:a,onDraggingChange:u,explorerMinPixels:A.explorerMinPixels(h)})})]})},hr=({view:e,sheet:t,explorer:n,content:a,contentCoversPage:s,onDraggingChange:u,explorerMinPixels:o})=>{const{viewSettings:l,labels:i}=v.useExplorer(),m=v.useViewSetting(C=>e==="tree"?C.treeExplorer:C.multiExplorer)??(e==="tree"?A.EXPLORER_DEFAULT_PERCENT:A.EXPLORER_MULTI_DEFAULT_PERCENT),d=r.useRef(!1),[h,x]=r.useState(!1),g=r.useRef(u);r.useLayoutEffect(()=>{g.current=u},[u]);const E=Ae.useSplitPersistence(r.useCallback(C=>{if(C.length!==2)return;const[y=0,T=0]=C,S=y+T;if(S<=0||y<=0)return;const b=Math.min(A.EXPLORER_MAX_PERCENT,y/S*100);l.update(e==="tree"?{treeExplorer:b}:{multiExplorer:b})},[l,e]));r.useEffect(()=>()=>{d.current&&g.current?.(!1)},[]);const L=Ae.useCoarsePointer()?A.COARSE_TARGET_PIXELS:A.FINE_TARGET_PIXELS,N=r.useMemo(()=>({[cr]:`${String(t?0:L)}px`}),[t,L]),R=r.useCallback((C,y)=>{const[T=0,S=0]=C;C.length===2&&S>0&&x(T<=0),E.layoutChanged(C,y)},[E]),F=r.useCallback(C=>{d.current=C,u?.(C),E.draggingChanged(C)},[u,E]);return c.jsxs(xe.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:R,className:"aqmx-split",style:N,"data-aqmx-split":e,children:[t?null:c.jsx(xe.Panel,{id:Se,defaultSize:{value:m,unit:"percentage"},minSize:{value:o,unit:"pixels"},maxSize:{value:A.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:s,className:"aqmx-split-explorer",children:c.jsx(ye,{value:!h,children:n})}),t?null:c.jsx(xe.PanelResizeHandle,{id:et(e),thickness:L,indicator:{visible:!0,thickness:A.SPLIT_HANDLE_PIXELS.gripThickness,length:A.SPLIT_HANDLE_PIXELS.gripLength,barThickness:A.SPLIT_HANDLE_PIXELS.barThickness,barLength:A.SPLIT_HANDLE_PIXELS.barLength},title:i.resizeExplorer,"aria-label":i.resizeExplorer,onDragging:F,inert:s,className:"aqmx-split-handle"}),c.jsx(xe.Panel,{id:Je,defaultSize:{value:100-m,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...s?{style:{isolation:"auto"}}:{},children:a})]})};exports.EMPTY_SELECTION=we;exports.ExplorerPane=ar;exports.ExplorerSplit=pr;exports.SheetNoticeSlotContext=Qe;
1
+ "use strict";const c=require("react/jsx-runtime"),v=require("./index-W3iAjkLb.cjs"),r=require("react"),A=require("./location-BVEN_Ihk.cjs"),He=require("@aiquants/directory-tree"),mt=require("./tapScrollCircle-C5DGI-0H.cjs"),pt=require("./storage-DM0EvkVf.cjs"),xe=require("@aiquants/resize-panels"),Ae=require("./useSplitPersistence-Ba-v64n-.cjs"),ht=require("react-router");function xt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const p=xt(r);function wt({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15ZM9 12.75a.75.75 0 0 0 0 1.5h6a.75.75 0 0 0 0-1.5H9Z",clipRule:"evenodd"}))}const gt=p.forwardRef(wt);function Et({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15Zm-6.75-10.5a.75.75 0 0 0-1.5 0v2.25H9a.75.75 0 0 0 0 1.5h2.25v2.25a.75.75 0 0 0 1.5 0v-2.25H15a.75.75 0 0 0 0-1.5h-2.25V10.5Z",clipRule:"evenodd"}))}const bt=p.forwardRef(Et);function vt({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M16.5 6a3 3 0 0 0-3-3H6a3 3 0 0 0-3 3v7.5a3 3 0 0 0 3 3v-6A4.5 4.5 0 0 1 10.5 6h6Z"}),p.createElement("path",{d:"M18 7.5a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-7.5a3 3 0 0 1-3-3v-7.5a3 3 0 0 1 3-3H18Z"}))}const Rt=p.forwardRef(vt);function yt({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M3 6a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3V6ZM3 15.75a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-2.25Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3v-2.25Z",clipRule:"evenodd"}))}const St=p.forwardRef(yt),kt=()=>{const{notices:e}=v.useExplorer(),t=r.use(e);return t.length===0?null:c.jsx("div",{className:"aqmx-explorer-notices",children:t.map(n=>c.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":n.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":n.id,children:[c.jsx("p",{className:"aqmx-callout-title",children:n.title}),n.body===void 0?null:c.jsx("p",{className:"aqmx-callout-body",children:n.body}),n.action===void 0?null:c.jsx("a",{className:"aqmx-callout-action",href:n.action.href,children:n.action.label})]},n.id))})};function Ct({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M6.912 3a3 3 0 0 0-2.868 2.118l-2.411 7.838a3 3 0 0 0-.133.882V18a3 3 0 0 0 3 3h15a3 3 0 0 0 3-3v-4.162c0-.299-.045-.596-.133-.882l-2.412-7.838A3 3 0 0 0 17.088 3H6.912Zm13.823 9.75-2.213-7.191A1.5 1.5 0 0 0 17.088 4.5H6.912a1.5 1.5 0 0 0-1.434 1.059L3.265 12.75H6.11a3 3 0 0 1 2.684 1.658l.256.513a1.5 1.5 0 0 0 1.342.829h3.218a1.5 1.5 0 0 0 1.342-.83l.256-.512a3 3 0 0 1 2.684-1.658h2.844Z",clipRule:"evenodd"}))}const Tt=p.forwardRef(Ct),ye=r.createContext(!0),Ze="\0loop\0",$e="\0",Lt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=o=>{const l=e.get(o);if(l!==void 0)return l;const i=Object.freeze({type:"loop",name:o.name,path:o.path});return e.set(o,i),i},s=(o,l,i)=>{let f=!1;const m=o.map(h=>{const x=u(h,l,i);return x!==h&&(f=!0),x});if(!f)return o;const d=n.get(o);return d!==void 0&&d.length===m.length&&d.every((h,x)=>h===m[x])?d:(n.set(o,m),m)},u=(o,l,i)=>{if(o.type!=="directory")return o;if(i.has(o.path))return a(o);const f=o.lazy===!0?l(o.path):void 0,m=f?.status==="loaded",d=m?f.entries:o.children;if(d===void 0)return o;i.add(o.path);const h=s(d,l,i);if(i.delete(o.path),!m&&h===o.children)return o;const x=t.get(o);if(x!==void 0&&x.state===f&&x.children===h)return x.grafted;const g={...o,children:h,lazy:m?!1:o.lazy};return t.set(o,{state:f,children:h,grafted:g}),g};return(o,l)=>s(o,l,new Set)},jt=(e,t)=>`${Ze}${e}${$e}${t}`,ie=e=>e.startsWith(Ze),Pt=e=>e.slice(e.lastIndexOf($e)+1),re="data-aqmx-path",Nt=(e,t,n,a,s)=>{const u={aqmxPath:e.path};return e.modifiedAt!==void 0&&(u.aqmxModifiedAt=e.modifiedAt),n&&(u.aqmxOpen=!0),(a==="loading"||a==="failed")&&(u.aqmxChildren=a),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:s,data:u}},Ot=(e,t,n,a)=>{const s=jt(t,e.path);return{name:n,type:"directory",absolutePath:s,relativePath:s,children:a,data:{aqmxLoop:e.path}}},At=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,a=[],s=(l,i,f)=>{const m=l.map(h=>h.type==="loop"?u(h,i,f):o(h,i)),d=n.get(l);return d!==void 0&&d.length===m.length&&d.every((h,x)=>h===m[x])?d:(n.set(l,m),m)},u=(l,i,f)=>{const m=t.get(l);if(m!==void 0&&m.parentKey===f&&m.loopFolderName===i.loopFolderName)return m.row;const d=Ot(l,f,i.loopFolderName(l.name),a);return t.set(l,{row:d,parentKey:f,loopFolderName:i.loopFolderName}),d},o=(l,i)=>{const f=l.type==="directory"?l.children===void 0?a:s(l.children,i,l.path):void 0,m=i.openPaths.has(l.path),d=l.type==="directory"&&l.lazy===!0?i.childrenOf(l.path)?.status:void 0,h=d==="failed"?i.renderFailedFolder:void 0,x=e.get(l);if(x!==void 0&&x.open===m&&x.childrenStatus===d&&x.children===f&&x.renderFailedFolder===h)return x.row;const g=Nt(l,f,m,d,h===void 0?void 0:h(l));return e.set(l,{row:g,open:m,childrenStatus:d,children:f,renderFailedFolder:h}),g};return(l,i)=>s(l,i,"")},qt=e=>{if(e===void 0)return;const t=n=>{const a=n.data?.aqmxModifiedAt;return typeof a=="number"?{name:n.name,path:n.absolutePath,type:n.type,modifiedAt:a}:{name:n.name,path:n.absolutePath,type:n.type}};return(n,a)=>e(t(n),t(a))},Re=(e,t)=>{const n=e.filter(a=>a.type==="directory");return t===void 0?n:n.sort(t)},Mt=(e,t)=>{const n=new Map;let a=0;const s=u=>{for(const o of Re(u,t.compare))if(t.isShownExpanded(o.path)){if(o.lazy!==!0){o.children!==void 0&&s(o.children);continue}n.has(o.path)||(n.set(o.path,t.isDirect(o.path)?"direct":"bulk"),t.childrenOf(o.path)?.status!=="failed"&&(a+=1))}};return s(e),{folders:n,waiting:a}},Ft=e=>{const t=new Set,n=a=>{for(const s of a)s.type==="directory"&&(s.lazy===!0&&t.add(s.path),s.children!==void 0&&n(s.children))};return n(e),t},Be=(e,t)=>{for(const n of e){if(n.type!=="directory")continue;if(n.path===t)return n;const a=n.children===void 0?null:Be(n.children,t);if(a!==null)return a}return null},_t=(e,t,n,a)=>{let s=e;for(const u of t){const o=s.find(l=>l.type==="directory"&&l.path===u);if(o===void 0)return"missing";if(o.lazy===!0)return a.childrenOf(o.path)?.status==="failed"?"failed":"loading";if(!a.isShownExpanded(o.path))return"loading";s=o.children??[]}return s.some(u=>u.type==="file"&&u.path===n)?"ready":"missing"},qe=new Set,It=(e,t)=>e.has(t)?e:new Set(e).add(t),Dt=(e,t)=>{if(!t.some(a=>e.has(a)))return e;const n=new Set(t);return new Set([...e].filter(a=>!n.has(a)))},Ht=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),Zt=()=>{const[e,t]=r.useState(qe),n=r.useCallback(o=>t(l=>It(l,o)),[]),a=r.useCallback(o=>t(l=>Dt(l,o)),[]),s=r.useCallback(o=>t(l=>Ht(l,o)),[]),u=r.useCallback(()=>t(qe),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:a,pruneDirect:s,clearDirect:u}),[e,n,a,s,u])},$t=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),Bt=(e,t)=>{const n=[];let a=Re(t.entries,t.compare);for(let s=1;a.length>0;s+=1){const u=[];for(const o of a){const{path:l}=o;if(t.isShownExpanded(l))e.handled.add(l);else{if(e.handled.has(l))continue;if(e.handled.add(l),o.lazy===!0&&t.childrenOf(l)===void 0){if(s>e.budget.maxDepth){e.depthLimited=!0;continue}if(e.loads.size>=e.budget.maxFolders){e.folderLimited=!0;continue}e.loads.add(l)}n.push(l),e.opened+=1}o.lazy!==!0&&o.children!==void 0&&u.push(...Re(o.children,t.compare))}a=u}return n},ze=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||ze(n.children,t))),zt=(e,t)=>{if(e.folderLimited)return{kind:"folder-limit",opened:e.opened};if(e.depthLimited)return{kind:"depth-limit",opened:e.opened};let n=0;for(const a of e.loads)t.childrenOf(a)?.status==="failed"&&(n+=1);return{kind:"done",opened:e.opened,failed:n,complete:ze(t.entries,t.isShownExpanded)}},ve=Object.freeze({state:"idle"}),Vt=e=>{const t=r.useRef(null),n=r.useRef(e),[a,s]=r.useState(ve);r.useLayoutEffect(()=>{n.current=e});const u=r.useCallback(()=>{t.current===null&&(t.current=$t(n.current.budget),s({state:"running",opened:0}))},[]),o=r.useCallback(()=>{t.current=null,s(ve)},[]),l=r.useCallback(i=>{const f=t.current;if(f===null)return;const m=Bt(f,i);if(m.length>0&&(f.issuedAgainst=i.expanded,n.current.expandMultiple([...m])),!f.announcedStart&&(f.loads.size>0||i.waiting>0)&&(f.announcedStart=!0,n.current.onStart()),m.length===0&&!i.expansionPending&&i.expanded!==f.issuedAgainst&&i.waiting===0){t.current=null;const h=zt(f,i);s(h.kind==="done"?ve:{state:"stopped",stop:h.kind,opened:h.opened}),n.current.onFinish(h);return}const{opened:d}=f;s(h=>h.state==="running"&&h.opened===d?h:{state:"running",opened:d})},[]);return r.useMemo(()=>({status:a,start:u,end:o,advance:l}),[a,u,o,l])},Me=["pointerdown","wheel","touchstart","keydown","focusin"],Kt=8,Fe={least:Number.POSITIVE_INFINITY,stalled:0},Xt=({tree:e,container:t,path:n,chain:a,rows:s,cancel:u,displayed:o,placement:l})=>{const i=r.useRef(null),f=r.useRef(!0),m=r.useRef(Fe),d=r.useRef(null),h=r.useRef(null),x=r.useRef(a),g=r.useRef(l);r.useLayoutEffect(()=>{x.current=a,g.current=l},[a,l]);const E=r.useCallback(()=>{const y=d.current;y!==null&&(d.current=null,y.phase==="asking"?y.controller.abort():x.current?.open(null))},[]),j=r.useCallback(()=>{i.current=null,E()},[E]),L=r.useCallback(()=>{const y=t.current;i.current===null||h.current!==null||y===null||y.getClientRects().length===0||(h.current=requestAnimationFrame(()=>{h.current=null;const T=i.current;if(T===null)return;const S=g.current(T);if(S===0){f.current=!0,d.current?.phase==="opening"&&E();return}if(e.current?.scrollToPath(T,{align:"nearest"})===!0){d.current?.phase==="opening"&&E();const{least:q,stalled:_}=m.current;m.current=S<q?{least:S,stalled:0}:{least:q,stalled:_+1},m.current.stalled<Kt&&L();return}const b=d.current;if(b===null){i.current=null;return}b.phase==="opening"&&x.current?.progress(b.folders,T)!=="loading"&&j()}))},[e,t,E,j]),N=r.useCallback(()=>{f.current=!1,m.current=Fe,L()},[L]);r.useEffect(()=>{const y=t.current;if(y===null)return;const T=typeof ResizeObserver>"u"?null:new ResizeObserver(N);T?.observe(y);for(const S of Me)y.addEventListener(S,j,{passive:!0});return()=>{T?.disconnect();for(const S of Me)y.removeEventListener(S,j);h.current!==null&&cancelAnimationFrame(h.current),h.current=null,E()}},[t,N,j,E]);const R=a!==null;r.useEffect(()=>{const y=t.current;if(j(),n===null||y===null||y.contains(y.ownerDocument.activeElement))return;i.current=n;const T=x.current;if(R&&T!==null){const S=new AbortController,b={phase:"asking",controller:S};d.current=b,T.ancestors(n,S.signal).then(q=>{d.current===b&&(q===null?d.current=null:(d.current={phase:"opening",folders:q},x.current?.open(q)),N())})}N()},[n,R,t,j,N]),r.useEffect(()=>{(d.current?.phase==="opening"||i.current!==null&&!f.current)&&N()},[s,N]);const F=r.useRef(u);r.useEffect(()=>{F.current!==u&&(F.current=u,j())},[u,j]);const C=r.useRef(o);r.useEffect(()=>{C.current&&!o&&E(),C.current=o},[o,E])},Wt="--aqmx-tree-line",Gt=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),Ut="data-aqmx-tree-probe",Yt=Object.freeze({rowHeight:A.CONTROL_BLOCK_PIXELS,lineColor:null}),Qt=/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/u,Jt=e=>{const t=Qt.exec(e);return t===null?e:`#${t.slice(1).map(n=>Number(n).toString(16).padStart(2,"0")).join("")}`},en=(e,t)=>{const[n,a]=r.useState(Yt);return r.useLayoutEffect(()=>{const s=e.current;if(s===null)return;const u=()=>{const i=Math.round(s.getBoundingClientRect().height),f=getComputedStyle(s),m=f.getPropertyValue(Wt).trim()===""?null:Jt(f.color);a(d=>{const h=Number.isFinite(i)&&i>0?i:d.rowHeight;return d.rowHeight===h&&d.lineColor===m?d:{rowHeight:h,lineColor:m}})};u();const o=Gt.map(i=>window.matchMedia(i));for(const i of o)i.addEventListener("change",u);const l=typeof ResizeObserver>"u"?null:new ResizeObserver(u);return l?.observe(s),()=>{for(const i of o)i.removeEventListener("change",u);l?.disconnect()}},[e,t]),n},Ve="markdown-explorer-tree-scroll",tn=.5,Ke=(e,t)=>[...e.querySelectorAll(`[role="treeitem"][${re}]`)].find(n=>n.getAttribute(re)===t),nn=(e,t)=>{const n=Ke(e,t),a=n?.closest(`[data-testid="${Ve}"]`);if(n===void 0||a===null||a===void 0)return Number.POSITIVE_INFINITY;const s=a.getBoundingClientRect(),u=n.getBoundingClientRect(),o=s.top-u.top,l=u.height>s.height?Math.abs(o):Math.max(0,o)+Math.max(0,u.bottom-s.bottom);return l<=tn?0:l},rn={testId:Ve,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:{width:8,enableTrackClick:!0,enableThumbDrag:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:mt.TAP_SCROLL_CIRCLE},behaviorOptions:{enablePointerDrag:!0}},an={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},ln={color:"inherit",fontSize:"inherit"},on={paddingBlock:0,fontSize:"inherit"},sn=new Set,cn=new Map,un={color:"var(--aqmx-tree-line)"},dn=e=>{const t=e instanceof Element?e.closest(`[${re}]`):null;return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(re)},Xe=(e,t,n,a)=>n==="folder-limit"?e.expandAllFolderLimit(a,t.maxFolders,e.expandAll):e.expandAllDepthLimit(a,t.maxDepth),fn=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):Xe(e,t,n.kind,n.opened),We=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-explorer-loading","aria-busy":"true","data-testid":"markdown-explorer-tree-loading",children:[c.jsx("p",{className:"aqmx-explorer-loading-text",children:e.treeLoading}),c.jsxs("div",{className:"aqmx-skeleton","aria-hidden":"true",children:[c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{})]})]})},mn=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[c.jsx(Tt,{className:"aqmx-explorer-empty-icon","aria-hidden":"true"}),c.jsx("p",{className:"aqmx-empty-title",children:e.treeEmptyTitle}),c.jsx("p",{className:"aqmx-explorer-empty-body",children:e.treeEmptyBody})]})},pn=({name:e,onRetry:t})=>{const{labels:n}=v.useExplorer(),a=r.useId();return c.jsxs("span",{className:"aqmx-explorer-folder-failed",children:[c.jsx("span",{className:"aqmx-explorer-folder-name",children:e}),c.jsx("span",{id:a,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),c.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":a,"data-testid":"markdown-explorer-folder-retry",onClick:s=>{s.stopPropagation();const u=s.currentTarget,o=u.ownerDocument.activeElement===u?u.closest('[role="treeitem"]'):null;o instanceof HTMLElement&&v.focusWithoutScroll(o),t()},onKeyDown:s=>{s.key!=="Escape"&&s.stopPropagation()},children:[c.jsx(v.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},hn=({entries:e,version:t,mode:n,sourceId:a,settings:s,reveal:u,openPaths:o,selection:l,onOpenDocument:i,folders:f,onRevealSource:m,expansion:d,onShown:h,marks:x,claimsHeld:g,expandAll:E,revealCancel:j})=>{const{trees:L,documents:N,labels:R,locale:F,theme:C,data:y,config:T,sources:S,reveals:b}=v.useExplorer(),q=r.use(ye),[_]=r.useState(At),ae=r.useRef(null),{rowHeight:Q,lineColor:Z}=en(ae,C),{isExpanded:$,toggle:J,expandMultiple:I,collapseMultiple:X,expanded:W,isPending:G}=d,{alwaysExpanded:O,sortMode:ee,folderPlacement:le,readmePlacement:ue}=s,{direct:te,markDirect:B,unmarkDirect:U,pruneDirect:fe}=x,{running:oe,advance:se}=E,de=r.useRef(null),ne=r.useRef(null),z=r.useMemo(()=>A.createEntryComparator({sortMode:ee,folderPlacement:le,readmePlacement:ue}),[ee,le,ue]),P=r.useMemo(()=>qt(z),[z]),M=r.useCallback(w=>L.children(a,w),[L,a]),D=r.useMemo(()=>Ft(e),[e]),Y=r.useCallback(w=>!ie(w)&&($(w)||O&&!D.has(w)),[$,O,D]),V=r.useRef({shownExpanded:Y,isExpanded:$,unloadedFolders:D,entries:e,childrenOf:M});r.useLayoutEffect(()=>{V.current={shownExpanded:Y,isExpanded:$,unloadedFolders:D,entries:e,childrenOf:M}},[Y,$,D,e,M]);const Ce=r.useCallback(w=>{de.current?.scrollToPath(w,{align:"nearest"}),requestAnimationFrame(()=>{const k=ne.current,H=k===null?void 0:Ke(k,w);H!==void 0&&v.focusWithoutScroll(H)})},[]),tt=r.useCallback(w=>{if(ie(w)){Ce(Pt(w));return}V.current.isExpanded(w)?U([w]):V.current.unloadedFolders.has(w)&&B(w),J(w)},[Ce,B,U,J]),ge=r.useCallback(w=>{const k=w.filter(H=>!ie(H));k.length!==0&&(U(k),X(k))},[U,X]),nt=r.useCallback(w=>{const k=w.filter(H=>!ie(H));k.length!==0&&(k.length<w.length&&k.every(H=>V.current.shownExpanded(H))?ge(k):I(k))},[I,ge]),Te=r.useCallback(w=>c.jsx(pn,{name:w.name,onRetry:()=>{B(w.path),L.retryChildren(a,w.path),V.current.shownExpanded(w.path)||I([w.path])}}),[L,a,B,I]),Le=n==="multi"?o:sn,{loopFolderName:je}=R,rt=r.useMemo(()=>_(e,{openPaths:Le,childrenOf:M,renderFailedFolder:Te,loopFolderName:je}),[_,e,Le,M,Te,je,t]),at=v.useIntentPrefetch(N,dn),Pe=r.useRef([]),me=r.useCallback(()=>{for(const w of Pe.current)V.current.unloadedFolders.has(w)&&B(w)},[B]),{maxDepth:Ee}=T.revealDocument,Ne=r.useRef(m);r.useLayoutEffect(()=>{Ne.current=m},[m]);const lt=r.useMemo(()=>({ancestors:async(w,k)=>{const H=b.take(a,w);if(H!==null)return H;if(!b.mayMove(w)){const ce=await y.ancestors(a,w,k);return ce.status!=="ok"||ce.ancestors===null||ce.ancestors.length>Ee?null:ce.ancestors}const K=await y.reveal(a,w,k);return K.status!=="ok"||K.source===null||K.ancestors.length>Ee?null:K.source===a?K.ancestors:(k.aborted||!S.some(ce=>ce.id===K.source)||(b.move(K.source,w,K.ancestors),Ne.current(K.source)),null)},open:w=>{Pe.current=w??[],w!==null&&(me(),I([...w]))},progress:(w,k)=>_t(V.current.entries,w,k,{isShownExpanded:V.current.shownExpanded,childrenOf:V.current.childrenOf})}),[y,a,S,b,Ee,me,I]);r.useEffect(()=>me(),[me,D]);const ot=r.useMemo(()=>[e,t,W],[e,t,W]),st=r.useCallback(w=>ne.current===null?Number.POSITIVE_INFINITY:nn(ne.current,w),[]);Xt({tree:de,container:ne,path:u.path,chain:u.openFolders?lt:null,rows:ot,cancel:j,displayed:q,placement:st});const Oe=r.useCallback(w=>te.has(w),[te]),pe=r.useMemo(()=>Mt(e,{isShownExpanded:Y,childrenOf:M,compare:z,isDirect:Oe}),[e,Y,M,z,Oe,t]),he=q&&g;r.useLayoutEffect(()=>{h(e)},[e,h]),r.useLayoutEffect(()=>()=>h(null),[h]),r.useEffect(()=>L.claimChildren(a,he?pe.folders:cn),[L,a,he,pe]),r.useEffect(()=>fe(D),[fe,D]),r.useEffect(()=>{he&&oe&&se({entries:e,isShownExpanded:Y,childrenOf:M,compare:z,expanded:W,waiting:pe.waiting,expansionPending:G})},[he,oe,se,e,Y,M,z,W,pe,G]);const ct=r.useCallback(w=>{const k=w.entry.absolutePath;if(w.isDirectory){if(f===null||ie(k)||k===f.current)return;w.isExpanded&&w.preventDefault(),b.settle(k),f.open(k);return}b.settle(k),i(k)},[b,i,f]),{onChange:be}=l,it=r.useMemo(()=>be===null?void 0:(w,k)=>{ie(w.absolutePath)||be({path:w.absolutePath,name:w.name,selected:k})},[be]),ut=r.useMemo(()=>new Set(l.items),[l.items]),dt=r.useMemo(()=>({entryKindDirectory:R.treeEntryKindDirectory,entryKindFile:R.treeEntryKindFile,scrollUp:R.treeScrollUp,scrollDown:R.treeScrollDown,scrollToTop:R.treeScrollToTop,scrollToBottom:R.treeScrollToBottom}),[R]),ft=Z===null?{showTreeLines:!1}:{showTreeLines:s.lines,lineColor:Z};return c.jsxs("div",{ref:ne,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",...at,children:[c.jsx("span",{ref:ae,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[Ut]:""}),c.jsx(He.DirectoryTree,{ref:de,entries:rt,expansion:{toggle:tt,isExpanded:Y,expandMultiple:nt,collapseMultiple:ge,isPending:G&&!oe,doubleClickAction:s.doubleClickAction},selection:{mode:l.mode,selectedPath:l.shownPath,currentPath:l.shownPath,selectedItems:ut,onEntryClick:ct,onSelectionChange:it},visual:{className:"aqmx-explorer-tree-view",ariaLabel:R.treeRegion,...ft,showExpandIcons:s.expandIcons,expandIconStyle:un,showDirectoryIcons:s.directoryIcons,showFileIcons:s.fileIcons,expandIconSize:s.expandIconSize,itemHeight:Q,removeRootIndent:s.removeRootIndent,highlightStyles:an,entryStyle:on,nameStyle:ln},virtualScroll:rn,sort:P,locale:F,labels:dt})]})},xn=({pending:e,status:t})=>{const{labels:n}=v.useExplorer(),a=t.state!=="running",[s,u]=r.useState(0),o=r.useRef(!0);r.useLayoutEffect(()=>{const i=o.current;if(o.current=a,!a||e>0&&!i){u(0);return}if(e>0){u(e);return}if(s===0)return;const f=setTimeout(()=>u(0),0);return()=>clearTimeout(f)},[a,e,s]);const l=a&&e===0?s:e;return l===0&&a?null:c.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(l),"data-aqmx-expand-all":t.state,children:[l>0?c.jsx(v.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,c.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,l):n.foldersLoading(l)})]})},wn=({stop:e,opened:t,budget:n})=>{const{labels:a}=v.useExplorer();return c.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:Xe(a,n,e,t)})},gn=({entries:e,...t})=>{const{trees:n}=v.useExplorer(),a=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:s}=t,[u]=r.useState(Lt),o=r.useMemo(()=>u(e,l=>n.children(s,l)),[u,e,n,s,a]);return o.length===0?c.jsx(mn,{}):c.jsx(hn,{entries:o,version:a,...t})},En=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:a}=v.useExplorer(),s=r.use(e);if(s.status==="deferred")return c.jsx(We,{});if(s.status==="ok")return c.jsx(gn,{entries:s.entries,...n});const u=a?.(s.failure);return c.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":s.failure.reason,children:u!==void 0?u:c.jsx(v.FailureView,{failure:s.failure,alert:!0,onRetry:t,testId:null})})},bn=({onControls:e,...t})=>{const{trees:n,storageNamespace:a,labels:s,announcer:u,config:o}=v.useExplorer(),{sourceId:l}=t,i=He.useDirectoryTreeState({storageKey:pt.storageKeys(a).treeExpansion(l)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const f=n.read(l),m=r.useCallback(()=>n.retry(l),[n,l]);r.useLayoutEffect(()=>n.open(l),[n,l]);const d=Zt(),{expanded:h,expandMultiple:x,collapseAll:g}=i,[E,j]=r.useState(null),L=E!==h,N=r.useRef(h);r.useLayoutEffect(()=>{N.current=h},[h]);const R=o.expandAll,F=r.useCallback(()=>u.announce(s.expandAllStarted),[u,s]),C=r.useCallback(O=>u.announce(fn(s,R,O)),[u,s,R]),y=Vt({budget:R,expandMultiple:x,onStart:F,onFinish:C}),{status:T,start:S,end:b,advance:q}=y,_=T.state==="running",ae=r.useMemo(()=>({running:_,advance:q}),[_,q]),Q=r.useRef(null),[Z,$]=r.useState(!1),J=r.useCallback(O=>{Q.current=O,$(O!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(O=>{const ee=O.sourceId===l&&Q.current!==null?Be(Q.current,O.path):null;ee!==null&&u.announce({list:s.foldersLoadFailedNamed,item:ee.name})}),[n,l,u,s]);const{clearDirect:I}=d,[X,W]=r.useState(0),G=r.useCallback(()=>{W(O=>O+1),b(),I(),j(N.current),g()},[b,I,g]);return r.useEffect(()=>{e({collapseAll:G,expandAll:Z?S:null,expanding:_})},[e,G,S,Z,_]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{Z||b()},[Z,b]),c.jsxs(c.Fragment,{children:[T.state==="stopped"?c.jsx(wn,{stop:T.stop,opened:T.opened,budget:R}):null,c.jsxs("div",{className:"aqmx-explorer-tree-area",children:[c.jsx(r.Suspense,{fallback:c.jsx(We,{}),children:c.jsx(En,{result:f,onRetry:m,expansion:i,onShown:J,marks:d,claimsHeld:L,expandAll:ae,revealCancel:X,...t})}),c.jsx(xn,{pending:n.pendingChildren(l),status:T})]})]})};function vn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const Ge=p.forwardRef(vn),_e="markdown-explorer-selection-remove",Rn=({selection:e,onRemove:t,onClear:n,onOpenSelection:a,onLeave:s})=>{const{labels:u}=v.useExplorer(),o=r.useId(),l=r.useRef(null),i=[...e],f=(d,h)=>{if(h.ownerDocument.activeElement===h){const x=l.current===null?[]:[...l.current.querySelectorAll(`[data-testid="${_e}"]`)],g=x.indexOf(h),E=[x[g+1],x[g-1]].find(j=>j!==void 0);E===void 0?s():E.focus()}t(d)},m=()=>{const d=l.current;d!==null&&d.contains(d.ownerDocument.activeElement)&&s(),n()};return c.jsxs("section",{ref:l,className:"aqmx-explorer-tray","aria-labelledby":o,"data-testid":"markdown-explorer-selection-tray",children:[c.jsxs("div",{className:"aqmx-explorer-tray-header",children:[c.jsx("p",{id:o,className:"aqmx-explorer-tray-title",children:u.selectionTitle(i.length)}),c.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:m,children:u.clearSelection})]}),c.jsx("ul",{className:"aqmx-explorer-tray-list",children:i.map(([d,h])=>c.jsxs("li",{className:"aqmx-explorer-tray-item",children:[c.jsx("span",{className:"aqmx-explorer-tray-name",title:d,children:h}),c.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":u.removeFromSelection(h),title:u.removeFromSelection(h),"data-testid":_e,"data-aqmx-path":d,onClick:x=>f(d,x.currentTarget),children:c.jsx(Ge,{"aria-hidden":"true"})})]},d))}),a===void 0?null:c.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>a(i.map(([d])=>d)),children:u.openSelectionInMulti(i.length)})]})},we=new Map,yn=(e,t)=>{if(t.selected===e.has(t.path))return e;const n=new Map(e);return t.selected?n.set(t.path,t.name):n.delete(t.path),n},Sn=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},Ue=r.createContext(null),kn=e=>{const t=r.use(Ue);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};function Cn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M15 3.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 .75.75v4.5a.75.75 0 0 1-1.5 0V5.56l-3.97 3.97a.75.75 0 1 1-1.06-1.06l3.97-3.97h-2.69a.75.75 0 0 1-.75-.75Zm-12 0A.75.75 0 0 1 3.75 3h4.5a.75.75 0 0 1 0 1.5H5.56l3.97 3.97a.75.75 0 0 1-1.06 1.06L4.5 5.56v2.69a.75.75 0 0 1-1.5 0v-4.5Zm11.47 11.78a.75.75 0 1 1 1.06-1.06l3.97 3.97v-2.69a.75.75 0 0 1 1.5 0v4.5a.75.75 0 0 1-.75.75h-4.5a.75.75 0 0 1 0-1.5h2.69l-3.97-3.97Zm-4.94-1.06a.75.75 0 0 1 0 1.06L5.56 19.5h2.69a.75.75 0 0 1 0 1.5h-4.5a.75.75 0 0 1-.75-.75v-4.5a.75.75 0 0 1 1.5 0v2.69l3.97-3.97a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Tn=p.forwardRef(Cn);function Ln({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M6.97 2.47a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.25 4.81V16.5a.75.75 0 0 1-1.5 0V4.81L3.53 8.03a.75.75 0 0 1-1.06-1.06l4.5-4.5Zm9.53 4.28a.75.75 0 0 1 .75.75v11.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 1 1 1.06-1.06l3.22 3.22V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const jn=p.forwardRef(Ln);function Pn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M11.25 4.533A9.707 9.707 0 0 0 6 3a9.735 9.735 0 0 0-3.25.555.75.75 0 0 0-.5.707v14.25a.75.75 0 0 0 1 .707A8.237 8.237 0 0 1 6 18.75c1.995 0 3.823.707 5.25 1.886V4.533ZM12.75 20.636A8.214 8.214 0 0 1 18 18.75c.966 0 1.89.166 2.75.47a.75.75 0 0 0 1-.708V4.262a.75.75 0 0 0-.5-.707A9.735 9.735 0 0 0 18 3a9.707 9.707 0 0 0-5.25 1.533v16.103Z"}))}const Nn=p.forwardRef(Pn);function On({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm13.36-1.814a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}))}const An=p.forwardRef(On);function qn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M7.72 12.53a.75.75 0 0 1 0-1.06l7.5-7.5a.75.75 0 1 1 1.06 1.06L9.31 12l6.97 6.97a.75.75 0 1 1-1.06 1.06l-7.5-7.5Z",clipRule:"evenodd"}))}const Mn=p.forwardRef(qn);function Fn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M11.47 4.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1-1.06 1.06L12 6.31 8.78 9.53a.75.75 0 0 1-1.06-1.06l3.75-3.75Zm-3.75 9.75a.75.75 0 0 1 1.06 0L12 17.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-3.75 3.75a.75.75 0 0 1-1.06 0l-3.75-3.75a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const _n=p.forwardRef(Fn);function In({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M11.078 2.25c-.917 0-1.699.663-1.85 1.567L9.05 4.889c-.02.12-.115.26-.297.348a7.493 7.493 0 0 0-.986.57c-.166.115-.334.126-.45.083L6.3 5.508a1.875 1.875 0 0 0-2.282.819l-.922 1.597a1.875 1.875 0 0 0 .432 2.385l.84.692c.095.078.17.229.154.43a7.598 7.598 0 0 0 0 1.139c.015.2-.059.352-.153.43l-.841.692a1.875 1.875 0 0 0-.432 2.385l.922 1.597a1.875 1.875 0 0 0 2.282.818l1.019-.382c.115-.043.283-.031.45.082.312.214.641.405.985.57.182.088.277.228.297.35l.178 1.071c.151.904.933 1.567 1.85 1.567h1.844c.916 0 1.699-.663 1.85-1.567l.178-1.072c.02-.12.114-.26.297-.349.344-.165.673-.356.985-.57.167-.114.335-.125.45-.082l1.02.382a1.875 1.875 0 0 0 2.28-.819l.923-1.597a1.875 1.875 0 0 0-.432-2.385l-.84-.692c-.095-.078-.17-.229-.154-.43a7.614 7.614 0 0 0 0-1.139c-.016-.2.059-.352.153-.43l.84-.692c.708-.582.891-1.59.433-2.385l-.922-1.597a1.875 1.875 0 0 0-2.282-.818l-1.02.382c-.114.043-.282.031-.449-.083a7.49 7.49 0 0 0-.985-.57c-.183-.087-.277-.227-.297-.348l-.179-1.072a1.875 1.875 0 0 0-1.85-1.567h-1.843ZM12 15.75a3.75 3.75 0 1 0 0-7.5 3.75 3.75 0 0 0 0 7.5Z",clipRule:"evenodd"}))}const Dn=p.forwardRef(In);function Hn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M12 1.5a.75.75 0 0 1 .75.75V4.5a.75.75 0 0 1-1.5 0V2.25A.75.75 0 0 1 12 1.5ZM5.636 4.136a.75.75 0 0 1 1.06 0l1.592 1.591a.75.75 0 0 1-1.061 1.06l-1.591-1.59a.75.75 0 0 1 0-1.061Zm12.728 0a.75.75 0 0 1 0 1.06l-1.591 1.592a.75.75 0 0 1-1.06-1.061l1.59-1.591a.75.75 0 0 1 1.061 0Zm-6.816 4.496a.75.75 0 0 1 .82.311l5.228 7.917a.75.75 0 0 1-.777 1.148l-2.097-.43 1.045 3.9a.75.75 0 0 1-1.45.388l-1.044-3.899-1.601 1.42a.75.75 0 0 1-1.247-.606l.569-9.47a.75.75 0 0 1 .554-.68ZM3 10.5a.75.75 0 0 1 .75-.75H6a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 10.5Zm14.25 0a.75.75 0 0 1 .75-.75h2.25a.75.75 0 0 1 0 1.5H18a.75.75 0 0 1-.75-.75Zm-8.962 3.712a.75.75 0 0 1 0 1.061l-1.591 1.591a.75.75 0 1 1-1.061-1.06l1.591-1.592a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Zn=p.forwardRef(Hn);function $n({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M5.625 1.5c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5H5.625ZM7.5 15a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 7.5 15Zm.75 2.25a.75.75 0 0 0 0 1.5H12a.75.75 0 0 0 0-1.5H8.25Z",clipRule:"evenodd"}),p.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const Bn=p.forwardRef($n);function zn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const Vn=p.forwardRef(zn);function Kn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M19.906 9c.382 0 .749.057 1.094.162V9a3 3 0 0 0-3-3h-3.879a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H6a3 3 0 0 0-3 3v3.162A3.756 3.756 0 0 1 4.094 9h15.812ZM4.094 10.5a2.25 2.25 0 0 0-2.227 2.568l.857 6A2.25 2.25 0 0 0 4.951 21H19.05a2.25 2.25 0 0 0 2.227-1.932l.857-6a2.25 2.25 0 0 0-2.227-2.568H4.094Z"}))}const Xn=p.forwardRef(Kn);function Wn({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M10.5 3.75a6.75 6.75 0 1 0 0 13.5 6.75 6.75 0 0 0 0-13.5ZM2.25 10.5a8.25 8.25 0 1 1 14.59 5.28l4.69 4.69a.75.75 0 1 1-1.06 1.06l-4.69-4.69A8.25 8.25 0 0 1 2.25 10.5Zm8.25-3.75a.75.75 0 0 1 .75.75v2.25h2.25a.75.75 0 0 1 0 1.5h-2.25v2.25a.75.75 0 0 1-1.5 0v-2.25H7.5a.75.75 0 0 1 0-1.5h2.25V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const Gn=p.forwardRef(Wn);function Un({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{d:"M5.625 3.75a2.625 2.625 0 1 0 0 5.25h12.75a2.625 2.625 0 0 0 0-5.25H5.625ZM3.75 11.25a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75ZM3 15.75a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75ZM3.75 18.75a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75Z"}))}const Yn=p.forwardRef(Un),Qn=Object.freeze({sortMode:jn,folderPlacement:Vn,readmePlacement:Nn,selectionMode:An,doubleClickAction:Zn,expandIconSize:Gn,alwaysExpanded:Tn,revealDocument:v.ForwardRef$1,removeRootIndent:Mn,lines:Yn,expandIcons:_n,directoryIcons:Xn,fileIcons:Bn}),Ye=(e,t)=>{const n=e[t.labelKey];if(typeof n!="string")throw new TypeError(`[markdown-explorer] the tree setting ${t.key} must name a string label; labels.${t.labelKey} is a ${typeof n}`);return n},Jn=({id:e,settings:t,descriptors:n,onAdvance:a,onClose:s,ref:u})=>{const{labels:o}=v.useExplorer(),l=r.useRef([]);r.useEffect(()=>{l.current[0]?.focus()},[]);const i=r.useCallback(m=>{const d=n.length;l.current[(m%d+d)%d]?.focus()},[n.length]),f=r.useCallback((m,d)=>{switch(m.key){case"ArrowDown":m.preventDefault(),i(d+1);break;case"ArrowUp":m.preventDefault(),i(d-1);break;case"Home":m.preventDefault(),i(0);break;case"End":m.preventDefault(),i(n.length-1);break;case"Escape":v.consumeKey(m),s();break;case"Tab":s();break}},[n.length,i,s]);return c.jsx("div",{ref:u,id:e,role:"menu","aria-label":o.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((m,d)=>{const h=Qn[m.key],x=Ye(o,m),g=A.formatTreeSettingValue(o,t,m.key),E=t[m.key],j=typeof E=="boolean"?{role:"menuitemcheckbox","aria-checked":E,"aria-label":x}:{role:"menuitem","aria-label":`${x}: ${g}`};return c.jsxs("button",{ref:L=>{l.current[d]=L},type:"button",tabIndex:-1,...j,title:`${x}: ${g}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":m.key,onClick:()=>a(m),onKeyDown:L=>f(L,d),children:[c.jsx(h,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-menu-name",children:x}),c.jsx("span",{className:"aqmx-explorer-menu-value",children:g})]},m.key)})})},er=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:a,announcer:s}=v.useExplorer(),[u,o]=r.useState(!1),l=r.useRef(null),i=r.useRef(null),f=r.useRef(null),m=r.useId(),d=r.useCallback(()=>{l.current?.focus(),o(!1)},[]);r.useEffect(()=>{if(!u)return;const g=E=>{E.target instanceof Node&&(l.current?.contains(E.target)===!0||i.current?.contains(E.target)===!0)||(o(!1),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{f.current=null,(document.activeElement===null||document.activeElement===document.body)&&l.current?.focus()},0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[u]),r.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);const h=r.useCallback(g=>{g.key!=="Escape"||!u||(v.consumeKey(g),d())},[u,d]),x=r.useCallback(g=>{const E=n(g.key);s.announce(a.settingAnnouncement(Ye(a,g),A.formatTreeSettingValue(a,E,g.key)))},[s,a,n]);return{trigger:c.jsx("button",{ref:l,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":u,"aria-controls":u?m:void 0,"aria-label":a.treeSettings,title:a.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>o(g=>!g),onKeyDown:h,children:c.jsx(Dn,{"aria-hidden":"true"})}),menu:u?c.jsx(Jn,{ref:i,id:m,settings:e,descriptors:t,onAdvance:x,onClose:d}):null}},tr=()=>{const{treeSettings:e}=v.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},Ie=new Set,nr='[role="tree"] [role="treeitem"][tabindex="0"]',rr="[data-directory-tree-tab-stop]",ar=e=>{const{mode:t,sourceId:n,currentPath:a,openPaths:s,onOpenDocument:u,onSourceChange:o,onRevealSource:l,viewSwitch:i}=e,{labels:f,sources:m,trees:d,documents:h,announcer:x,reveals:g}=v.useExplorer(),{settings:E,advance:j}=tr(),L=r.useMemo(()=>A.visibleTreeSettingDescriptors(t==="tree"),[t]),N=t==="tree"&&E.selectionMode==="multiple";kn(N);const R=e.mode==="tree"?e.tray.onGatheredChange:null,F=e.mode==="tree"?e.onOpenSelection:void 0,C=e.mode==="tree"?e.onOpenFolder:null,y=e.mode==="tree"&&e.currentFolder,T=r.useMemo(()=>C===null?null:{current:a,open:C},[C,a]),S=e.mode==="tree"&&N?e.tray.gathered:we,b=r.useCallback(P=>{const M=j(P);return M.selectionMode!=="multiple"&&R?.(we),M},[j,R]),q=er({settings:E,descriptors:L,onAdvance:b}),_=r.useCallback(P=>R?.(M=>yn(M,P)),[R]),ae=r.useCallback(P=>R?.(M=>Sn(M,P)),[R]),Q=r.useCallback(()=>R?.(we),[R]),Z=r.useRef(null),$=r.useCallback(()=>{const P=Z.current;if(P===null)return;[nr,rr,'[data-testid="markdown-explorer-tree-settings"]'].map(D=>P.querySelector(D)).find(D=>D!==null)?.focus()},[]),J=r.useMemo(()=>new Set(S.keys()),[S]),I=r.useMemo(()=>a===null?Ie:new Set([a]),[a]),X=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:s,shownPath:null,onChange:null};switch(E.selectionMode){case"single":return{mode:"single",items:I,shownPath:a,onChange:null};case"multiple":return{mode:"multiple",items:J,shownPath:a,onChange:_};case"none":return{mode:"none",items:Ie,shownPath:null,onChange:null}}},[t,s,E.selectionMode,I,a,J,_]),W=r.useMemo(()=>E.revealDocument?{path:a,openFolders:!y}:{path:X.shownPath,openFolders:!1},[E.revealDocument,a,y,X.shownPath]),G=r.useCallback(P=>{a!==null&&g.settle(a),o(P)},[a,g,o]),[O,ee]=r.useState(null),[le,ue]=r.useState(!1),[te,B]=r.useState(null),U=r.useRef(!1),fe=r.useCallback(async()=>{if(!U.current){U.current=!0,ue(!0),B(null);try{const P=await d.refresh(n);if(P.status==="superseded")return;h.invalidate(),P.status==="failed"?B({sourceId:n,failure:P.failure}):x.announce(f.treeRefreshed)}finally{U.current=!1,ue(!1)}}},[d,h,n,x,f]),oe=O===null?null:O.expandAll,se=O?.expanding===!0,de=m.find(P=>P.id===n),ne=i.target==="multi"?St:Rt,z=i.target==="multi"?f.switchToMulti:f.switchToTree;return c.jsxs("nav",{ref:Z,"aria-label":f.explorerRegion,className:"aqmx-explorer","data-testid":"markdown-explorer-explorer","data-aqmx-mode":t,children:[c.jsxs("div",{className:"aqmx-explorer-header",children:[m.length>1?c.jsx("select",{className:"aqmx-explorer-source","aria-label":f.sourceLabel,title:de?.label,value:n,onChange:P=>G(P.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:m.map(P=>c.jsx("option",{value:P.id,children:P.label},P.id))}):null,c.jsxs("div",{className:"aqmx-explorer-actions",children:[c.jsx(v.ExplorerLink,{to:i.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":z,title:z,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":i.target,children:c.jsx(ne,{"aria-hidden":"true"})}),c.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:f.refreshTree,"aria-disabled":le,"aria-busy":le,"data-aqmx-busy":le?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{fe()},children:[c.jsx(v.ForwardRef,{"aria-hidden":"true"}),c.jsx("span",{children:f.refreshTreeLabel})]}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.expandAll,title:f.expandAll,"aria-disabled":oe===null||se,"aria-busy":se,"data-aqmx-busy":se?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>oe?.(),children:c.jsx(bt,{"aria-hidden":"true"})}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.collapseAll,title:f.collapseAll,"aria-disabled":O===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>O?.collapseAll(),children:c.jsx(gt,{"aria-hidden":"true"})}),q.trigger]})]}),c.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[te!==null&&te.sourceId===n?c.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":te.failure.reason,children:f.treeRefreshFailed(v.failureTitleOf(f,te.failure.reason))}):null,c.jsx(r.Suspense,{fallback:null,children:c.jsx(kt,{})}),c.jsx(bn,{mode:t,sourceId:n,settings:E,reveal:W,openPaths:s,selection:X,onOpenDocument:u,folders:T,onRevealSource:l,onControls:ee},n),N&&S.size>0?c.jsx(Rn,{selection:S,onRemove:ae,onClear:Q,onOpenSelection:F,onLeave:$}):null,q.menu]})]})};function lr({title:e,titleId:t,...n},a){return p.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},n),e?p.createElement("title",{id:t},e):null,p.createElement("path",{fillRule:"evenodd",d:"M3 6.75A.75.75 0 0 1 3.75 6h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 6.75ZM3 12a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 12Zm0 5.25a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75Z",clipRule:"evenodd"}))}const or=p.forwardRef(lr),sr=({explorer:e,toggleRef:t,covered:n,onNoticeSlotChange:a,dismissals:s})=>{const{labels:u}=v.useExplorer(),o=ht.useLocation(),{location:l}=v.useExplorerLocation(),[i,f]=r.useState(!1),[m,d]=r.useState({navigated:o,source:l.source}),[h,x]=r.useState(!1);m.navigated!==o&&(d({navigated:o,source:l.source}),m.source===l.source&&!h&&f(!1));const[g,E]=r.useState(s);g!==s&&(E(s),f(!1));const j=r.useRef(null),L=r.useRef(null),N=r.useRef(null),R=r.useRef(!1),F=r.useId();r.useLayoutEffect(()=>{const b=j.current;b!==null&&(i&&!b.open?(b.showModal(),L.current?.focus()):!i&&b.open&&(b.close(),t.current?.focus()),a(i?N.current:null))},[i,t,a]),r.useLayoutEffect(()=>()=>a(null),[a]);const C=r.useCallback(b=>{b.key!=="Escape"||b.defaultPrevented||(v.consumeKey(b),f(!1))},[]),y=r.useCallback(b=>{R.current=b.target===b.currentTarget},[]),T=r.useCallback(b=>{const q=R.current;R.current=!1,q&&b.target===b.currentTarget&&f(!1)},[]),S=r.useCallback(()=>{f(!1)},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"aqmx-sheet-bar",inert:n,children:c.jsxs("button",{ref:t,type:"button",className:"aqmx-sheet-toggle","aria-haspopup":"dialog","aria-expanded":i,"aria-controls":F,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>f(!0),children:[c.jsx(or,{"aria-hidden":"true"}),c.jsx("span",{children:u.showExplorer})]})}),c.jsx("dialog",{ref:j,id:F,className:"aqmx-sheet","aria-label":u.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:C,onPointerDown:y,onClick:T,onClose:S,children:c.jsxs("div",{className:"aqmx-sheet-panel",children:[c.jsxs("div",{className:"aqmx-sheet-header",children:[c.jsx("div",{ref:N,className:"aqmx-sheet-notice-slot"}),c.jsx("button",{ref:L,type:"button",className:"aqmx-sheet-close","aria-label":u.hideExplorer,title:u.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>f(!1),children:c.jsx(Ge,{"aria-hidden":"true"})})]}),c.jsx("div",{className:"aqmx-sheet-body",children:c.jsx(ye,{value:i,children:c.jsx(Ue,{value:x,children:e})})}),c.jsx(v.LiveRegion,{holds:i,testId:"markdown-explorer-sheet-announcer"})]})})]})},Qe=r.createContext(null),Se="aqmx-explorer",Je="aqmx-content",cr="--aqmx-split-band",ke='[role="tree"] [role="treeitem"]',ir=`${ke}[tabindex="0"]`,ur="[data-directory-tree-tab-stop]",dr=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${Se}"] ${ke}`))if(n.getAttribute(re)===t)return n;return null},De=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:A.ASSUMED_ROOT_FONT_PIXELS}),fr=(e,t)=>{const[n,a]=r.useState(()=>De(0,0));return r.useLayoutEffect(()=>{const s=e.current,u=t.current;if(s===null||u===null)throw new Error("[markdown-explorer] the split frame is not mounted");const o={frame:s.getBoundingClientRect().width,rem:u.getBoundingClientRect().width},l=()=>{const f=De(o.frame,o.rem);a(m=>m.inlineSize===f.inlineSize&&m.rootFontPixels===f.rootFontPixels?m:f)};l();const i=new ResizeObserver(f=>{for(const m of f){const[d]=m.borderBoxSize;d!==void 0&&(m.target===s&&(o.frame=d.inlineSize),m.target===u&&(o.rem=d.inlineSize))}l()});return i.observe(s),i.observe(u),()=>i.disconnect()},[e,t]),n},et=e=>`aqmx-split-handle-${e}`,mr=(e,{frameRef:t,sheetToggleRef:n,handleId:a})=>{const s=r.useRef(!1),u=r.useRef(null),o=r.useRef(!1);r.useLayoutEffect(()=>{const i=t.current;if(i===null)throw new Error("[markdown-explorer] the split frame is not mounted");const f=d=>{const h=d.target instanceof Element?d.target:null;s.current=h!==null&&h.closest(`[data-panel-id="${Je}"]`)===null,!o.current&&(u.current=h?.closest(`${ke}[${re}]`)?.getAttribute(re)??null)},m=d=>{d.relatedTarget instanceof Node&&!i.contains(d.relatedTarget)&&(s.current=!1)};return i.addEventListener("focusin",f),i.addEventListener("focusout",m),()=>{i.removeEventListener("focusin",f),i.removeEventListener("focusout",m)}},[t]);const l=r.useRef(e);r.useLayoutEffect(()=>{if(l.current===e)return;l.current=e;const i=t.current;if(i===null||!s.current)return;const f=m=>{const{activeElement:d,body:h}=i.ownerDocument;if(d!==null&&d!==h)return;const x=m.find(g=>g!==null);if(x!=null){o.current=!0;try{x.focus()}finally{o.current=!1}}};if(e){f([n.current]);return}queueMicrotask(()=>{if(l.current!==e||!s.current)return;const m=u.current,d=`[data-panel-id="${Se}"]`;f([m===null?null:dr(i,m),i.querySelector(`${d} ${ir}`),i.querySelector(`${d} ${ur}`),i.querySelector(`[data-resize-handle-id="${a}"]`)])})},[e,t,n,a])},pr=({view:e,explorer:t,content:n,contentCoversPage:a=!1,sheetDismissals:s=0,onDraggingChange:u})=>{const o=r.useRef(null),[l,i]=r.useState(null),f=r.useRef(null),m=r.useRef(null),{inlineSize:d,rootFontPixels:h}=fr(o,f),x=d!==null&&d<A.explorerSheetBelowPixels(h);return mr(x,{frameRef:o,sheetToggleRef:m,handleId:et(e)}),c.jsxs("div",{ref:o,className:"aqmx-split-frame","data-aqmx-explorer-mode":x?"sheet":"split",children:[c.jsx("span",{ref:f,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),x?c.jsx(sr,{explorer:t,toggleRef:m,covered:a,onNoticeSlotChange:i,dismissals:s}):null,c.jsx(Qe,{value:x?l:null,children:c.jsx(hr,{view:e,sheet:x,explorer:t,content:n,contentCoversPage:a,onDraggingChange:u,explorerMinPixels:A.explorerMinPixels(h)})})]})},hr=({view:e,sheet:t,explorer:n,content:a,contentCoversPage:s,onDraggingChange:u,explorerMinPixels:o})=>{const{viewSettings:l,labels:i}=v.useExplorer(),m=v.useViewSetting(C=>e==="tree"?C.treeExplorer:C.multiExplorer)??(e==="tree"?A.EXPLORER_DEFAULT_PERCENT:A.EXPLORER_MULTI_DEFAULT_PERCENT),d=r.useRef(!1),[h,x]=r.useState(!1),g=r.useRef(u);r.useLayoutEffect(()=>{g.current=u},[u]);const E=Ae.useSplitPersistence(r.useCallback(C=>{if(C.length!==2)return;const[y=0,T=0]=C,S=y+T;if(S<=0||y<=0)return;const b=Math.min(A.EXPLORER_MAX_PERCENT,y/S*100);l.update(e==="tree"?{treeExplorer:b}:{multiExplorer:b})},[l,e]));r.useEffect(()=>()=>{d.current&&g.current?.(!1)},[]);const L=Ae.useCoarsePointer()?A.COARSE_TARGET_PIXELS:A.FINE_TARGET_PIXELS,N=r.useMemo(()=>({[cr]:`${String(t?0:L)}px`}),[t,L]),R=r.useCallback((C,y)=>{const[T=0,S=0]=C;C.length===2&&S>0&&x(T<=0),E.layoutChanged(C,y)},[E]),F=r.useCallback(C=>{d.current=C,u?.(C),E.draggingChanged(C)},[u,E]);return c.jsxs(xe.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:R,className:"aqmx-split",style:N,"data-aqmx-split":e,children:[t?null:c.jsx(xe.Panel,{id:Se,defaultSize:{value:m,unit:"percentage"},minSize:{value:o,unit:"pixels"},maxSize:{value:A.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:s,className:"aqmx-split-explorer",children:c.jsx(ye,{value:!h,children:n})}),t?null:c.jsx(xe.PanelResizeHandle,{id:et(e),thickness:L,indicator:{visible:!0,thickness:A.SPLIT_HANDLE_PIXELS.gripThickness,length:A.SPLIT_HANDLE_PIXELS.gripLength,barThickness:A.SPLIT_HANDLE_PIXELS.barThickness,barLength:A.SPLIT_HANDLE_PIXELS.barLength},title:i.resizeExplorer,"aria-label":i.resizeExplorer,onDragging:F,inert:s,className:"aqmx-split-handle"}),c.jsx(xe.Panel,{id:Je,defaultSize:{value:100-m,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...s?{style:{isolation:"auto"}}:{},children:a})]})};exports.EMPTY_SELECTION=we;exports.ExplorerPane=ar;exports.ExplorerSplit=pr;exports.SheetNoticeSlotContext=Qe;
@@ -1,13 +1,13 @@
1
1
  import { jsx as m, jsxs as L, Fragment as Qe } from "react/jsx-runtime";
2
- import { u as $, p as kt, O as Oe, L as Je, Q as At, x as Pe, R as Lt, S as Ot, k as Pt, T as qt, U as Ct, V as Ft } from "./index-h9e3p5Pd.js";
2
+ import { u as $, p as kt, O as Oe, L as Je, Q as At, x as Pe, R as Lt, S as Ot, k as Pt, T as qt, U as Ct, V as Ft } from "./index-25s_q0vD.js";
3
3
  import * as f from "react";
4
4
  import { use as ye, createContext as qe, useState as F, useCallback as w, useMemo as C, useRef as E, useLayoutEffect as H, useEffect as D, useSyncExternalStore as Ce, Suspense as et, useId as Re } from "react";
5
- import { n as Mt, o as _t, q as tt, v as It, s as Dt, t as Ht, C as $t, F as Zt, u as Ve, x as Bt, y as zt, b as Ee, A as Vt } from "./location-G7psbmv_.js";
5
+ import { n as Mt, o as _t, q as tt, v as It, s as Dt, t as Ht, C as $t, F as Zt, u as Ve, x as Bt, y as zt, b as Ee, A as Vt } from "./location-B-m9scLf.js";
6
6
  import { useDirectoryTreeState as jt, DirectoryTree as Kt } from "@aiquants/directory-tree";
7
7
  import { T as Ut } from "./tapScrollCircle-u4EXeLhx.js";
8
8
  import { s as Gt } from "./storage-CmGHg7OA.js";
9
9
  import { PanelGroup as Wt, Panel as je, PanelResizeHandle as Xt } from "@aiquants/resize-panels";
10
- import { a as Yt, u as Qt } from "./useSplitPersistence-B1b5Lg5E.js";
10
+ import { a as Yt, u as Qt } from "./useSplitPersistence-Cc4tDxB4.js";
11
11
  import { useLocation as Jt } from "react-router";
12
12
  function en({
13
13
  title: e,