@aiquants/markdown-explorer 0.15.0 → 0.17.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 (58) hide show
  1. package/CHANGELOG.md +173 -15
  2. package/README.md +73 -27
  3. package/dist/EditSurface-0owpPyLE.js +786 -0
  4. package/dist/EditSurface-D-nhilRk.cjs +2 -0
  5. package/dist/{ExplorerSplit-BPLECNpv.js → ExplorerSplit-8c93p1hy.js} +613 -592
  6. package/dist/ExplorerSplit-bpEvHrCo.cjs +1 -0
  7. package/dist/MultiLayout-BXfzR6XC.cjs +1 -0
  8. package/dist/MultiLayout-Dy3DD_09.js +963 -0
  9. package/dist/NativeScrollBar-CI9fTvkt.js +65 -0
  10. package/dist/NativeScrollBar-Ddn0iHjv.cjs +1 -0
  11. package/dist/TreeLayout-CKZ-XQgn.cjs +1 -0
  12. package/dist/TreeLayout-eFQmzpNj.js +72 -0
  13. package/dist/client/storage.d.cts +1 -0
  14. package/dist/client/storage.d.ts +1 -0
  15. package/dist/core/geometry.d.cts +20 -1
  16. package/dist/core/geometry.d.ts +20 -1
  17. package/dist/core/labels.d.cts +17 -0
  18. package/dist/core/labels.d.ts +17 -0
  19. package/dist/core/location.d.cts +3 -0
  20. package/dist/core/location.d.ts +3 -0
  21. package/dist/core/treeSettings.d.cts +3 -1
  22. package/dist/core/treeSettings.d.ts +3 -1
  23. package/dist/index-5gwNJ8CB.cjs +13 -0
  24. package/dist/index-h9e3p5Pd.js +3645 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +25 -25
  27. package/dist/location-D85EXiPt.cjs +1 -0
  28. package/dist/location-G7psbmv_.js +499 -0
  29. package/dist/{merge-Bi2VedIr.js → merge-CS3p9BVw.js} +5 -5
  30. package/dist/{merge-BFk7nT59.cjs → merge-C_g05UGC.cjs} +1 -1
  31. package/dist/server.cjs +1 -1
  32. package/dist/server.js +1 -1
  33. package/dist/{storage-BSthKLSG.js → storage-CmGHg7OA.js} +11 -10
  34. package/dist/storage-DM0EvkVf.cjs +1 -0
  35. package/dist/storage.cjs +1 -1
  36. package/dist/storage.js +1 -1
  37. package/dist/styles/markdown-explorer.css +1 -1
  38. package/dist/useSplitPersistence-B1b5Lg5E.js +42 -0
  39. package/dist/useSplitPersistence-DRjsPZdH.cjs +1 -0
  40. package/docs/behavior/dom-hooks.md +19 -11
  41. package/docs/behavior/layout.md +121 -42
  42. package/docs/behavior/localization.md +12 -6
  43. package/docs/behavior/url-contract.md +18 -6
  44. package/package.json +5 -5
  45. package/dist/EditSurface-BLlu5zEt.cjs +0 -2
  46. package/dist/EditSurface-CF2io496.js +0 -705
  47. package/dist/ExplorerSplit-Cjvy0JHP.cjs +0 -1
  48. package/dist/MultiLayout-BjA0k-5n.cjs +0 -1
  49. package/dist/MultiLayout-D8F0BfxA.js +0 -947
  50. package/dist/NativeScrollBar-BFF12oEd.js +0 -59
  51. package/dist/NativeScrollBar-BUWXPvTV.cjs +0 -1
  52. package/dist/TreeLayout-CQUpgsxz.cjs +0 -1
  53. package/dist/TreeLayout-rhyVTfrI.js +0 -29
  54. package/dist/index-Dn7cYy-4.cjs +0 -13
  55. package/dist/index-v997iKxe.js +0 -3464
  56. package/dist/location-D6RE3wAN.cjs +0 -1
  57. package/dist/location-IRD9h42r.js +0 -444
  58. package/dist/storage-Dgi4JXaB.cjs +0 -1
@@ -0,0 +1,3645 @@
1
+ import { jsxs as F, jsx as c, Fragment as Pe } from "react/jsx-runtime";
2
+ import * as y from "react";
3
+ import { createContext as pe, use as ne, useMemo as G, useSyncExternalStore as ee, useRef as _, useLayoutEffect as H, useCallback as P, useId as Se, useEffect as te, Component as tn, Suspense as ke, lazy as it, useState as B, useEffectEvent as le } from "react";
4
+ import { useParams as _n, useSearchParams as In, matchPath as Bn, useBlocker as zn, useNavigate as jn, Link as Hn, useHref as $e, useLocation as nn, useRevalidator as Vn } from "react-router";
5
+ import { j as Un, g as rn, z as Zn, E as on, a as ln, B as Gn, D as wt, G as Wn, H as be, e as ye, I as Kn, J as Xn, K as gt, L as Yn, M as bt, O as Jn, w as Qn, Q as er } from "./location-G7psbmv_.js";
6
+ import { F as se, i as tr, G as nr, y as J, x as rr, H as Et, z as Ve, I as or, J as ir, K as lr, L as ar, N as sr, f as cr, O as yt, v as dr, P as ur, Q as fr, R as mr, B as hr, w as pr, S as vr, T as wr, U as gr, u as xt } from "./dataRoute-CObbjNxG.js";
7
+ import { HostedScrollArea as St, useMarkdownToolbarState as br, MarkdownViewer as an } from "@aiquants/markdown";
8
+ import { SOURCE_LINES_ATTRIBUTE as sn, parseSourceLines as Er } from "@aiquants/markdown/source-lines";
9
+ import { DEFAULT_CONTENT_ALIGN as yr } from "@aiquants/markdown/viewer-settings";
10
+ import { w as Je, r as Qe, a as xr, b as kt, s as we, c as Sr } from "./storage-CmGHg7OA.js";
11
+ import { createShouldRevalidate as kr } from "@aiquants/route-revalidation";
12
+ const Tt = Object.freeze(["en", "ja"]), Tr = "en", Rr = Object.freeze({
13
+ panelMoved: Object.freeze(["title", "column", "position"]),
14
+ panelMoveUnavailable: Object.freeze(["title", "move"]),
15
+ panelDragStarted: Object.freeze(["title"]),
16
+ panelDragCancelled: Object.freeze(["title"]),
17
+ multiColumnRegion: Object.freeze(["column"])
18
+ }), Mr = /\{(\w+)\}/gu, cn = {
19
+ explorerRegion: "Explorer",
20
+ sourceLabel: "Source",
21
+ refreshTreeLabel: "Refresh tree",
22
+ refreshTree: "Reload the tree and the open documents from the source",
23
+ treeRefreshed: "Reloaded the tree from the source",
24
+ treeRefreshFailed: (e) => `Could not reload the tree: ${e}`,
25
+ refreshDocumentLabel: "Refresh document",
26
+ refreshDocument: "Reload the document from the source",
27
+ refreshDocumentNamed: (e) => `Refresh ${e}`,
28
+ documentRefreshed: (e) => `Reloaded ${e}`,
29
+ documentRefreshFailed: (e) => `Could not reload the document: ${e}`,
30
+ showMarkupLabel: "Source",
31
+ showMarkup: "Show the document's Markdown as written",
32
+ showMarkupNamed: (e) => `Source of ${e}`,
33
+ editDocumentLabel: "Edit",
34
+ editDocument: "Edit the document's Markdown (or double-click the document)",
35
+ editDocumentNamed: (e) => `Edit ${e}`,
36
+ editDraftDocument: "Edit the document's Markdown without saving, to try it in the preview (or double-click the document)",
37
+ editDraftDocumentNamed: (e) => `Edit ${e} without saving`,
38
+ editExternallyLabel: "Open in its editor",
39
+ editExternally: "Open the document in its own editor, in a new tab",
40
+ editExternallyNamed: (e) => `Open ${e} in its editor`,
41
+ editorRegion: (e) => `Editing ${e}`,
42
+ editorLabel: (e) => `Markdown of ${e}`,
43
+ editLoading: "Loading the source for editing…",
44
+ editToolbar: "Editor",
45
+ saveDraft: "Save",
46
+ saveDraftTooltip: "Save the draft (Ctrl+S, or ⌘S on a Mac)",
47
+ closeEditor: "Close editor",
48
+ editView: "View",
49
+ editViewNamed: (e) => `View of ${e}`,
50
+ editViewEditor: "Editor",
51
+ editViewEditorTooltip: "Show the editor (Ctrl+E, or ⌘E on a Mac, switches with the preview)",
52
+ editViewSplit: "Side by side",
53
+ editViewSplitTooltip: "Show the editor and the preview side by side",
54
+ editViewSplitResize: "Resize the editor and the preview",
55
+ editViewPreview: "Preview",
56
+ editViewPreviewTooltip: "Show the preview (Ctrl+E, or ⌘E on a Mac, switches with the editor)",
57
+ historyOpen: "History",
58
+ draftUnsaved: "Unsaved changes",
59
+ draftStatus: "Draft, not saved",
60
+ draftNotSaved: "This draft is not saved: the document cannot be saved here.",
61
+ draftSaving: "Saving…",
62
+ draftSaved: "Saved",
63
+ draftSavedMerged: "Saved, merged with changes saved elsewhere",
64
+ draftConflicts: (e) => e === 1 ? "1 conflict with changes saved elsewhere: choose what to keep, then save" : `${e} conflicts with changes saved elsewhere: choose what to keep, then save`,
65
+ draftSaveFailed: (e) => `Could not save: ${e}`,
66
+ documentSaved: (e) => `Saved ${e}`,
67
+ documentSavedMerged: (e) => `Saved ${e}, merged with changes saved elsewhere`,
68
+ conflictOurs: "your draft",
69
+ conflictTheirs: "saved elsewhere",
70
+ conflictUseOurs: "Use my lines",
71
+ conflictUseTheirs: "Use the saved lines",
72
+ conflictKeepBoth: "Keep both",
73
+ conflictNext: "Next conflict",
74
+ editGrantTitle: "Editing needs your permission",
75
+ editGrantBody: "Allow this site to change documents on your behalf. You are asked once; signing out asks again.",
76
+ editGrantAction: "Grant permission",
77
+ editGrantRetry: "Try again",
78
+ unsavedTitle: "Discard unsaved changes?",
79
+ unsavedBody: (e) => `${e} has changes that are not saved.`,
80
+ unsavedDiscard: "Discard changes",
81
+ draftDiscardTitle: "Discard the draft?",
82
+ draftDiscardBody: (e) => `The changes to ${e} are not saved anywhere and will be lost.`,
83
+ unsavedStay: "Keep editing",
84
+ historyTitle: (e) => `Revisions of ${e}`,
85
+ historyLoading: "Loading the revisions…",
86
+ historyEmpty: "No revisions are kept for this document.",
87
+ historyCurrent: "Current",
88
+ historyKept: "Kept",
89
+ historyEntry: (e, t) => t === "" ? e : `${e} by ${t}`,
90
+ historyRestore: "Put into the draft",
91
+ historyClose: "Close",
92
+ historyRestored: (e) => `Put the revision into the draft of ${e}; save to keep it`,
93
+ previewRegion: "Preview",
94
+ previewUpdating: "Updating the preview…",
95
+ previewFailed: (e) => `Could not preview: ${e}`,
96
+ expandAll: "Expand all folders",
97
+ collapseAll: "Collapse all folders",
98
+ treeSettings: "Tree settings",
99
+ switchToMulti: "Open in the multi-panel view",
100
+ switchToTree: "Open in the tree view",
101
+ resizeExplorer: "Resize the explorer",
102
+ showExplorer: "Show the explorer",
103
+ hideExplorer: "Close the explorer",
104
+ treeRegion: "Documents",
105
+ treeLoading: "Loading the tree…",
106
+ treeEmptyTitle: "Nothing to show",
107
+ treeEmptyBody: "This source has no documents you can open.",
108
+ folderLoadFailed: "This folder could not be loaded.",
109
+ loopFolderName: (e) => `${e} (already open above)`,
110
+ foldersLoadFailedNamed: (e) => `${new Intl.ListFormat("en", { type: "conjunction" }).format(e)} could not be loaded`,
111
+ foldersLoading: (e) => e === 1 ? "Loading 1 folder…" : `Loading ${String(e)} folders…`,
112
+ expandAllStarted: "Opening all folders…",
113
+ expandAllProgress: (e, t) => `Opening all folders (${String(e)} opened, ${String(t)} loading)…`,
114
+ expandAllDone: (e, t, n) => {
115
+ const r = `Opened ${String(e)} ${e === 1 ? "folder" : "folders"}`;
116
+ return t > 0 ? `${r}; ${String(t)} could not be loaded` : n ? e === 0 ? "All folders are already open" : `${r}; every folder is open` : r;
117
+ },
118
+ expandAllFolderLimit: (e, t, n) => `Opened ${String(e)} ${e === 1 ? "folder" : "folders"} and stopped at the limit of ${String(t)} ${t === 1 ? "folder" : "folders"} to load. Choose "${n}" again to continue`,
119
+ expandAllDepthLimit: (e, t) => `Opened ${String(e)} ${e === 1 ? "folder" : "folders"}; folders more than ${String(t)} ${t === 1 ? "level" : "levels"} deep stay closed`,
120
+ treeEntryKindDirectory: "directory",
121
+ treeEntryKindFile: "file",
122
+ treeScrollUp: "Scroll up",
123
+ treeScrollDown: "Scroll down",
124
+ treeScrollToTop: "Top",
125
+ treeScrollToBottom: "Bottom",
126
+ selectionTitle: (e) => `Selected (${String(e)})`,
127
+ clearSelection: "Clear the selection",
128
+ openSelectionInMulti: (e) => `Open ${String(e)} in panels`,
129
+ removeFromSelection: (e) => `Remove ${e} from the selection`,
130
+ settingSortMode: "Sort order",
131
+ sortNative: "Source order",
132
+ sortAscending: "Name A→Z",
133
+ sortDescending: "Name Z→A",
134
+ sortOldest: "Modified old→new",
135
+ sortNewest: "Modified new→old",
136
+ settingFolderPlacement: "Folders",
137
+ folderPlacementMixed: "Mixed",
138
+ folderPlacementFirst: "First",
139
+ folderPlacementLast: "Last",
140
+ settingReadmePlacement: "README",
141
+ readmePlacementMixed: "Mixed",
142
+ readmePlacementFirst: "First",
143
+ readmePlacementLast: "Last",
144
+ settingSelectionMode: "Selection",
145
+ selectionSingle: "Single",
146
+ selectionMultiple: "Multiple",
147
+ selectionNone: "Off",
148
+ settingDoubleClick: "Double-click",
149
+ doubleClickRecursive: "Expand all levels",
150
+ doubleClickToggle: "Toggle",
151
+ settingExpandIconSize: "Expander size",
152
+ expandIconSizeValue: (e) => `${String(e)} px`,
153
+ settingAlwaysExpanded: "Always expanded",
154
+ settingRevealDocument: "Reveal the open document",
155
+ settingRemoveRootIndent: "No root indent",
156
+ settingTreeLines: "Tree lines",
157
+ settingExpandIcons: "Expanders",
158
+ settingDirectoryIcons: "Folder icons",
159
+ settingFileIcons: "File icons",
160
+ settingOn: "On",
161
+ settingOff: "Off",
162
+ settingAnnouncement: (e, t) => `${e}: ${t}`,
163
+ documentRegion: "Document",
164
+ documentEmpty: "Select a document in the explorer.",
165
+ folderReadmeMissing: (e) => `${e} has no README.`,
166
+ documentLoading: "Loading the document…",
167
+ markupLoading: "Loading the source…",
168
+ documentShown: (e) => `Showing ${e}`,
169
+ documentFailed: (e, t) => `${e}: ${t}`,
170
+ announcementSequence: (e) => e.map((t) => /[.!?]$/u.test(t) ? t : `${t}.`).join(" "),
171
+ textTruncated: "Only the beginning of this file is shown.",
172
+ inertLink: "This link points outside the source and cannot be opened.",
173
+ failureUnauthorizedTitle: "Your session has expired",
174
+ failureUnauthorizedBody: "Reload the page to sign in again.",
175
+ failureForbiddenTitle: "Access denied",
176
+ failureForbiddenBody: "You do not have permission to open this.",
177
+ failureNotFoundTitle: "Not found",
178
+ failureNotFoundBody: "It may have been moved or deleted.",
179
+ failureNotConfiguredTitle: "This source is not set up",
180
+ failureNotConfiguredBody: "Ask your administrator to configure it.",
181
+ failureInvalidTitle: "Invalid address",
182
+ failureInvalidBody: "The document path in this address cannot be used.",
183
+ failureTooLargeTitle: "Too large to display",
184
+ failureTooLargeBody: "This file exceeds the size that can be displayed.",
185
+ failureUnsupportedTitle: "Cannot be displayed",
186
+ failureUnsupportedBody: "This type of file cannot be shown here.",
187
+ failureFailedTitle: "Something went wrong",
188
+ failureFailedBody: "Try again in a moment.",
189
+ retry: "Try again",
190
+ reloadPage: "Reload the page",
191
+ imageZoomIn: "Zoom in",
192
+ imageZoomOut: "Zoom out",
193
+ imageFit: "Fit to the view",
194
+ imageFitLevel: "Fit",
195
+ imageZoomLevel: (e) => `${String(e)}%`,
196
+ openInNewTab: "Open in a new tab",
197
+ download: "Download",
198
+ copyText: "Copy the text",
199
+ copiedText: "Copied the text",
200
+ copyTextFailed: "Could not copy the text",
201
+ mediaUnsupported: "Your browser cannot play this file.",
202
+ fileNotShown: "This file cannot be shown here. Download it to open it.",
203
+ pdfNotShown: "This browser does not show PDF files inside the page. Open it in a new tab or download it.",
204
+ viewerLoading: "Loading data...",
205
+ viewerErrorPrefix: "Error: ",
206
+ viewerStyleTitle: "Display Style",
207
+ viewerSelectStyle: "Select display style",
208
+ viewerPinStyle: "Pin style selector",
209
+ viewerUnpinStyle: "Unpin style selector",
210
+ viewerErrorTitle: "An error occurred",
211
+ viewerMissingImage: "Image not found",
212
+ viewerOpenToc: "Open table of contents",
213
+ viewerTocTitle: "Table of contents",
214
+ viewerPinToc: "Pin table of contents",
215
+ viewerUnpinToc: "Unpin table of contents",
216
+ viewerSelectAlign: "Select alignment",
217
+ viewerAlignTitle: "Alignment",
218
+ viewerPinAlign: "Pin alignment selector",
219
+ viewerUnpinAlign: "Unpin alignment selector",
220
+ viewerAlignLeft: "Align left",
221
+ viewerAlignCenter: "Align center",
222
+ viewerAlignRight: "Align right",
223
+ viewerMermaidInteractionMode: "Mouse interaction mode",
224
+ viewerMermaidInteractionModeTouch: "Touch interaction mode",
225
+ viewerMermaidModeNone: "No interaction",
226
+ viewerMermaidModeZoom: "Zoom only",
227
+ viewerMermaidModePan: "Pan only (drag)",
228
+ viewerMermaidModePanShift: "Pan only (Shift+drag)",
229
+ viewerMermaidModeBoth: "Zoom and pan (drag)",
230
+ viewerMermaidModeBothShift: "Zoom and pan (Shift+drag)",
231
+ viewerMermaidModeNoneTouch: "No interaction (a finger scrolls the page)",
232
+ viewerMermaidModeZoomTouch: "Zoom only (two fingers)",
233
+ viewerMermaidModePanTouch: "Pan only (one-finger drag while the diagram overflows)",
234
+ viewerMermaidModeBothTouch: "Zoom and pan (two fingers, one finger while the diagram overflows)",
235
+ viewerMermaidZoomIn: "Zoom In",
236
+ viewerMermaidZoomOut: "Zoom Out",
237
+ viewerMermaidResetView: "Reset View",
238
+ viewerMermaidPanUp: "Pan Up",
239
+ viewerMermaidPanDown: "Pan Down",
240
+ viewerMermaidPanLeft: "Pan Left",
241
+ viewerMermaidPanRight: "Pan Right",
242
+ viewerMermaidDiagram: "Diagram (arrow keys pan, + and - zoom, 0 resets)",
243
+ viewerMermaidRetry: "Try again",
244
+ viewerEmbeddedVideo: "embedded video",
245
+ viewerEmbeddedPost: "embedded post",
246
+ viewerEmbeddedFrame: "Embedded content",
247
+ multiRegion: "Panels",
248
+ multiEmpty: "Select documents in the explorer to open them side by side.",
249
+ panelLimit: (e) => `You can open up to ${String(e)} panels at once.`,
250
+ panelOpened: (e) => `Opened ${e}`,
251
+ panelClosed: (e) => `Closed ${e}`,
252
+ panelAlreadyOpen: (e) => `${e} is already open`,
253
+ panelHidden: (e) => `Hid ${e}`,
254
+ panelShown: (e) => `Showed ${e}`,
255
+ panelMaximized: (e) => `Maximized ${e}`,
256
+ panelRestored: (e) => `Restored ${e} to its size`,
257
+ panelHide: "Hide the panel",
258
+ panelMaximize: "Maximize the panel",
259
+ panelRestore: "Restore the panel to its size",
260
+ panelClose: "Close the panel",
261
+ panelSwitchToCustomDrag: "Switch to the custom drag mode",
262
+ panelSwitchToNormalDrag: "Back to the normal drag mode",
263
+ panelCustomDragBadge: "Custom",
264
+ panelMovePreviousColumn: "Move to the previous column",
265
+ panelMoveNextColumn: "Move to the next column",
266
+ panelMoveUp: "Move up",
267
+ panelMoveDown: "Move down",
268
+ panelMoved: "Moved {title} to column {column}, position {position}",
269
+ panelMoveUnavailable: "{move} is not available for {title}",
270
+ panelDragStarted: "Picked up {title}",
271
+ panelDragCancelled: "Kept {title} where it was",
272
+ hiddenPanelsTitle: "Hidden panels:",
273
+ hiddenPanelBadge: "Hidden",
274
+ hiddenPanelNotice: "This panel is hidden",
275
+ multiColumnEmpty: "This column is empty",
276
+ multiColumnRegion: "Column {column}",
277
+ panelDropHere: "Drop the panel here"
278
+ }, Or = {
279
+ explorerRegion: "エクスプローラー",
280
+ sourceLabel: "ソース",
281
+ refreshTreeLabel: "ツリーを更新",
282
+ refreshTree: "ソースからツリーと開いている文書を読み込み直す",
283
+ treeRefreshed: "ツリーをソースから読み込み直しました",
284
+ treeRefreshFailed: (e) => `ツリーを読み込み直せませんでした: ${e}`,
285
+ refreshDocumentLabel: "文書を更新",
286
+ refreshDocument: "ソースから文書を読み込み直す",
287
+ refreshDocumentNamed: (e) => `${e} を更新`,
288
+ documentRefreshed: (e) => `${e} を読み込み直しました`,
289
+ documentRefreshFailed: (e) => `文書を読み込み直せませんでした: ${e}`,
290
+ showMarkupLabel: "ソース",
291
+ showMarkup: "文書の Markdown を書いたまま表示",
292
+ showMarkupNamed: (e) => `${e} のソース`,
293
+ editDocumentLabel: "編集",
294
+ editDocument: "文書の Markdown を編集 (文書のダブルクリックでも)",
295
+ editDocumentNamed: (e) => `${e} を編集`,
296
+ editDraftDocument: "文書の Markdown を保存せずに編集し、プレビューで確かめる (文書のダブルクリックでも)",
297
+ editDraftDocumentNamed: (e) => `${e} を保存せずに編集`,
298
+ editExternallyLabel: "元のエディタで開く",
299
+ editExternally: "文書を元のエディタで、新しいタブに開く",
300
+ editExternallyNamed: (e) => `${e} を元のエディタで開く`,
301
+ editorRegion: (e) => `${e} を編集中`,
302
+ editorLabel: (e) => `${e} の Markdown`,
303
+ editLoading: "編集のためにソースを読み込み中…",
304
+ editToolbar: "エディタ",
305
+ saveDraft: "保存",
306
+ saveDraftTooltip: "下書きを保存 (Ctrl+S、Mac は ⌘S)",
307
+ closeEditor: "編集を閉じる",
308
+ editView: "表示",
309
+ editViewNamed: (e) => `${e} の表示`,
310
+ editViewEditor: "エディタ",
311
+ editViewEditorTooltip: "エディタを表示 (Ctrl+E、Mac は ⌘E でプレビューと切り替え)",
312
+ editViewSplit: "並べて表示",
313
+ editViewSplitTooltip: "エディタとプレビューを並べて表示",
314
+ editViewSplitResize: "エディタとプレビューの割合を変更",
315
+ editViewPreview: "プレビュー",
316
+ editViewPreviewTooltip: "プレビューを表示 (Ctrl+E、Mac は ⌘E でエディタと切り替え)",
317
+ historyOpen: "履歴",
318
+ draftUnsaved: "保存していない変更があります",
319
+ draftStatus: "保存しない下書き",
320
+ draftNotSaved: "この下書きは保存しません。ここでは文書を保存できません。",
321
+ draftSaving: "保存中…",
322
+ draftSaved: "保存しました",
323
+ draftSavedMerged: "ほかで保存された変更と統合して保存しました",
324
+ draftConflicts: (e) => `ほかで保存された変更と ${e} か所が重なりました。残す方を選んでから保存してください`,
325
+ draftSaveFailed: (e) => `保存できませんでした: ${e}`,
326
+ documentSaved: (e) => `${e} を保存しました`,
327
+ documentSavedMerged: (e) => `${e} を、ほかで保存された変更と統合して保存しました`,
328
+ conflictOurs: "あなたの下書き",
329
+ conflictTheirs: "ほかで保存された版",
330
+ conflictUseOurs: "自分の行を使う",
331
+ conflictUseTheirs: "保存された行を使う",
332
+ conflictKeepBoth: "両方を残す",
333
+ conflictNext: "次の衝突へ",
334
+ editGrantTitle: "編集には許可が必要です",
335
+ editGrantBody: "このサイトがあなたに代わって文書を変えることを許可してください。尋ねるのは 1 回だけで、サインアウトすると次にまた尋ねます。",
336
+ editGrantAction: "許可する",
337
+ editGrantRetry: "もう一度試す",
338
+ unsavedTitle: "保存していない変更を破棄しますか?",
339
+ unsavedBody: (e) => `${e} に保存していない変更があります。`,
340
+ unsavedDiscard: "変更を破棄",
341
+ draftDiscardTitle: "下書きを破棄しますか?",
342
+ draftDiscardBody: (e) => `${e} への変更はどこにも保存されず、失われます。`,
343
+ unsavedStay: "編集を続ける",
344
+ historyTitle: (e) => `${e} の版`,
345
+ historyLoading: "版の一覧を読み込み中…",
346
+ historyEmpty: "この文書の版は残っていません。",
347
+ historyCurrent: "現在の版",
348
+ historyKept: "保持",
349
+ historyEntry: (e, t) => t === "" ? e : `${e} (${t})`,
350
+ historyRestore: "下書きに戻す",
351
+ historyClose: "閉じる",
352
+ historyRestored: (e) => `${e} の下書きに版を戻しました。残すには保存してください`,
353
+ previewRegion: "プレビュー",
354
+ previewUpdating: "プレビューを更新中…",
355
+ previewFailed: (e) => `プレビューできませんでした: ${e}`,
356
+ expandAll: "すべてのフォルダーを展開",
357
+ collapseAll: "すべてのフォルダーを折りたたむ",
358
+ treeSettings: "ツリーの設定",
359
+ switchToMulti: "マルチビューで開く",
360
+ switchToTree: "ツリービューで開く",
361
+ resizeExplorer: "エクスプローラーの幅を変更",
362
+ showExplorer: "エクスプローラーを開く",
363
+ hideExplorer: "エクスプローラーを閉じる",
364
+ treeRegion: "文書の一覧",
365
+ treeLoading: "ツリーを読み込み中…",
366
+ treeEmptyTitle: "表示できるファイルがありません",
367
+ treeEmptyBody: "このソースには開ける文書がありません。",
368
+ folderLoadFailed: "このフォルダーを読み込めませんでした。",
369
+ loopFolderName: (e) => `${e} (上の階層で開いています)`,
370
+ foldersLoadFailedNamed: (e) => `${new Intl.ListFormat("ja", { type: "conjunction" }).format(e)} を読み込めませんでした`,
371
+ foldersLoading: (e) => `フォルダーを ${String(e)} 件読み込み中…`,
372
+ expandAllStarted: "すべてのフォルダーを展開しています…",
373
+ expandAllProgress: (e, t) => `すべてのフォルダーを展開中 (展開 ${String(e)} 件、読み込み中 ${String(t)} 件)…`,
374
+ expandAllDone: (e, t, n) => {
375
+ const r = `${String(e)} 件のフォルダーを展開しました`;
376
+ return t > 0 ? `${r}。うち ${String(t)} 件は読み込めませんでした` : n ? e === 0 ? "すべてのフォルダーが既に開いています" : `${r}。すべてのフォルダーが開いています` : r;
377
+ },
378
+ expandAllFolderLimit: (e, t, n) => `${String(e)} 件のフォルダーを展開し、読み込みの上限 (${String(t)} 件) で止めました。続けるには「${n}」をもう一度押してください`,
379
+ expandAllDepthLimit: (e, t) => `${String(e)} 件のフォルダーを展開しました。深さ ${String(t)} 階層より下のフォルダーは閉じたままです`,
380
+ treeEntryKindDirectory: "ディレクトリ",
381
+ treeEntryKindFile: "ファイル",
382
+ treeScrollUp: "上へスクロール",
383
+ treeScrollDown: "下へスクロール",
384
+ treeScrollToTop: "先頭へ",
385
+ treeScrollToBottom: "末尾へ",
386
+ selectionTitle: (e) => `選択中 (${String(e)})`,
387
+ clearSelection: "選択を解除",
388
+ openSelectionInMulti: (e) => `${String(e)} 件をパネルで開く`,
389
+ removeFromSelection: (e) => `${e} を選択から外す`,
390
+ settingSortMode: "並び順",
391
+ sortNative: "取得順",
392
+ sortAscending: "名前の昇順",
393
+ sortDescending: "名前の降順",
394
+ sortOldest: "更新日時の昇順 (古い順)",
395
+ sortNewest: "更新日時の降順 (新しい順)",
396
+ settingFolderPlacement: "フォルダーの位置",
397
+ folderPlacementMixed: "混ぜる",
398
+ folderPlacementFirst: "先に",
399
+ folderPlacementLast: "後に",
400
+ settingReadmePlacement: "README の位置",
401
+ readmePlacementMixed: "混ぜる",
402
+ readmePlacementFirst: "先に",
403
+ readmePlacementLast: "後に",
404
+ settingSelectionMode: "選択",
405
+ selectionSingle: "1 件",
406
+ selectionMultiple: "複数",
407
+ selectionNone: "オフ",
408
+ settingDoubleClick: "ダブルクリック",
409
+ doubleClickRecursive: "下の階層まで展開",
410
+ doubleClickToggle: "開閉",
411
+ settingExpandIconSize: "展開アイコンの大きさ",
412
+ expandIconSizeValue: (e) => `${String(e)} px`,
413
+ settingAlwaysExpanded: "常に展開",
414
+ settingRevealDocument: "開いた文書をツリーで表示",
415
+ settingRemoveRootIndent: "最上位の字下げなし",
416
+ settingTreeLines: "ツリーの線",
417
+ settingExpandIcons: "展開アイコン",
418
+ settingDirectoryIcons: "フォルダーのアイコン",
419
+ settingFileIcons: "ファイルのアイコン",
420
+ settingOn: "オン",
421
+ settingOff: "オフ",
422
+ settingAnnouncement: (e, t) => `${e}: ${t}`,
423
+ documentRegion: "文書",
424
+ documentEmpty: "エクスプローラーで文書を選んでください。",
425
+ folderReadmeMissing: (e) => `${e} には README がありません。`,
426
+ documentLoading: "文書を読み込み中…",
427
+ markupLoading: "ソースを読み込み中…",
428
+ documentShown: (e) => `${e} を表示しています`,
429
+ documentFailed: (e, t) => `${e}: ${t}`,
430
+ announcementSequence: (e) => e.map((t) => /[。!?]$/u.test(t) ? t : `${t}。`).join(""),
431
+ textTruncated: "このファイルは先頭だけを表示しています。",
432
+ inertLink: "リンク先がソースの外にあるため開けません。",
433
+ failureUnauthorizedTitle: "セッションの有効期限が切れました",
434
+ failureUnauthorizedBody: "ページを再読み込みして、もう一度サインインしてください。",
435
+ failureForbiddenTitle: "アクセスが許可されていません",
436
+ failureForbiddenBody: "これを開く権限がありません。",
437
+ failureNotFoundTitle: "見つかりません",
438
+ failureNotFoundBody: "移動または削除された可能性があります。",
439
+ failureNotConfiguredTitle: "このソースは設定されていません",
440
+ failureNotConfiguredBody: "管理者に設定を依頼してください。",
441
+ failureInvalidTitle: "アドレスが正しくありません",
442
+ failureInvalidBody: "このアドレスに含まれる文書の経路は使えません。",
443
+ failureTooLargeTitle: "大きすぎて表示できません",
444
+ failureTooLargeBody: "このファイルは表示できる大きさを超えています。",
445
+ failureUnsupportedTitle: "表示できない形式です",
446
+ failureUnsupportedBody: "この種類のファイルはここでは表示できません。",
447
+ failureFailedTitle: "読み込みに失敗しました",
448
+ failureFailedBody: "しばらくしてからもう一度お試しください。",
449
+ retry: "再試行",
450
+ reloadPage: "ページを再読み込み",
451
+ imageZoomIn: "拡大",
452
+ imageZoomOut: "縮小",
453
+ imageFit: "画面に合わせる",
454
+ imageFitLevel: "全体",
455
+ imageZoomLevel: (e) => `${String(e)}%`,
456
+ openInNewTab: "新しいタブで開く",
457
+ download: "ダウンロード",
458
+ copyText: "テキストをコピー",
459
+ copiedText: "テキストをコピーしました",
460
+ copyTextFailed: "テキストをコピーできませんでした",
461
+ mediaUnsupported: "このブラウザではこのファイルを再生できません。",
462
+ fileNotShown: "このファイルはここでは表示できません。ダウンロードして開いてください。",
463
+ pdfNotShown: "このブラウザはページの中に PDF を表示しません。新しいタブで開くか、ダウンロードしてください。",
464
+ viewerLoading: "データを読み込み中...",
465
+ viewerErrorPrefix: "エラー: ",
466
+ viewerStyleTitle: "表示スタイル",
467
+ viewerSelectStyle: "表示スタイルを選択",
468
+ viewerPinStyle: "スタイル選択をピン留め",
469
+ viewerUnpinStyle: "スタイル選択のピン留めを解除",
470
+ viewerErrorTitle: "エラーが発生しました",
471
+ viewerMissingImage: "画像が見つかりません",
472
+ viewerOpenToc: "目次を開く",
473
+ viewerTocTitle: "目次",
474
+ viewerPinToc: "目次をピン留め",
475
+ viewerUnpinToc: "目次のピン留めを解除",
476
+ viewerSelectAlign: "揃えを選択",
477
+ viewerAlignTitle: "揃え",
478
+ viewerPinAlign: "揃え選択をピン留め",
479
+ viewerUnpinAlign: "揃え選択のピン留めを解除",
480
+ viewerAlignLeft: "左揃え",
481
+ viewerAlignCenter: "中央揃え",
482
+ viewerAlignRight: "右揃え",
483
+ viewerMermaidInteractionMode: "マウス操作モード",
484
+ viewerMermaidInteractionModeTouch: "タッチ操作モード",
485
+ viewerMermaidModeNone: "操作なし",
486
+ viewerMermaidModeZoom: "拡大縮小のみ",
487
+ viewerMermaidModePan: "移動のみ (左ドラッグ)",
488
+ viewerMermaidModePanShift: "移動のみ (Shift+ドラッグ)",
489
+ viewerMermaidModeBoth: "拡大縮小+移動 (左ドラッグ)",
490
+ viewerMermaidModeBothShift: "拡大縮小+移動 (Shift+ドラッグ)",
491
+ viewerMermaidModeNoneTouch: "操作なし (指はページをスクロール)",
492
+ viewerMermaidModeZoomTouch: "拡大縮小のみ (2 本指)",
493
+ viewerMermaidModePanTouch: "移動のみ (はみ出す図を 1 本指でドラッグ)",
494
+ viewerMermaidModeBothTouch: "拡大縮小+移動 (2 本指・はみ出す図は 1 本指)",
495
+ viewerMermaidZoomIn: "拡大",
496
+ viewerMermaidZoomOut: "縮小",
497
+ viewerMermaidResetView: "表示を元に戻す",
498
+ viewerMermaidPanUp: "上へ移動",
499
+ viewerMermaidPanDown: "下へ移動",
500
+ viewerMermaidPanLeft: "左へ移動",
501
+ viewerMermaidPanRight: "右へ移動",
502
+ viewerMermaidDiagram: "図 (矢印キーで移動、+ と - で拡大縮小、0 で元に戻す)",
503
+ viewerMermaidRetry: "再試行",
504
+ viewerEmbeddedVideo: "埋め込みの動画",
505
+ viewerEmbeddedPost: "埋め込みの投稿",
506
+ viewerEmbeddedFrame: "埋め込みのコンテンツ",
507
+ multiRegion: "パネル",
508
+ multiEmpty: "エクスプローラーで文書を選ぶと、ここに並べて開きます。",
509
+ panelLimit: (e) => `同時に開けるのは ${String(e)} パネルまでです。`,
510
+ panelOpened: (e) => `${e} を開きました`,
511
+ panelClosed: (e) => `${e} を閉じました`,
512
+ panelAlreadyOpen: (e) => `${e} は既に開いています`,
513
+ panelHidden: (e) => `${e} を隠しました`,
514
+ panelShown: (e) => `${e} を表示しました`,
515
+ panelMaximized: (e) => `${e} を最大化しました`,
516
+ panelRestored: (e) => `${e} を元のサイズに戻しました`,
517
+ panelHide: "パネルを隠す",
518
+ panelMaximize: "パネルを最大化",
519
+ panelRestore: "パネルを元のサイズに戻す",
520
+ panelClose: "パネルを閉じる",
521
+ panelSwitchToCustomDrag: "カスタムのドラッグの方式に切り替え",
522
+ panelSwitchToNormalDrag: "通常のドラッグの方式に戻す",
523
+ panelCustomDragBadge: "カスタム",
524
+ panelMovePreviousColumn: "前の列へ移動",
525
+ panelMoveNextColumn: "次の列へ移動",
526
+ panelMoveUp: "上へ移動",
527
+ panelMoveDown: "下へ移動",
528
+ panelMoved: "{title} を {column} 列目の {position} 番目へ移動しました",
529
+ panelMoveUnavailable: "{title} は「{move}」できません",
530
+ panelDragStarted: "{title} を持ち上げました",
531
+ panelDragCancelled: "{title} の移動を取り消しました",
532
+ hiddenPanelsTitle: "隠したパネル:",
533
+ hiddenPanelBadge: "非表示",
534
+ hiddenPanelNotice: "このパネルは隠しています",
535
+ multiColumnEmpty: "この列は空です",
536
+ multiColumnRegion: "{column} 列目",
537
+ panelDropHere: "ここへパネルをドロップ"
538
+ }, Cr = Object.freeze({
539
+ en: Object.freeze(cn),
540
+ ja: Object.freeze(Or)
541
+ }), dn = Object.freeze(Object.keys(cn)), Lr = new Set(dn), Ar = (e) => Lr.has(e), Ce = (e) => e === null ? "null" : typeof e == "string" ? JSON.stringify(e.length > 40 ? `${e.slice(0, 40)}…` : e) : typeof e == "function" ? "a function" : Array.isArray(e) ? "an array" : typeof e, un = (e) => {
542
+ if (e === void 0) return Tr;
543
+ if (Tt.includes(e)) return e;
544
+ throw new RangeError(`[markdown-explorer] locale is the UI language (${Tt.map((t) => JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${Ce(e)}`);
545
+ }, Rt = (e, t) => {
546
+ const n = Cr[un(e)];
547
+ if (t === void 0) return n;
548
+ if (t === null || typeof t != "object")
549
+ throw new RangeError(`[markdown-explorer] labels must be an object; got ${Ce(t)}`);
550
+ if (!Un(t))
551
+ throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${Ce(t)}`);
552
+ const r = t, o = { ...n };
553
+ for (const i of Object.keys(r)) {
554
+ if (!Ar(i))
555
+ throw new RangeError(`[markdown-explorer] labels.${i} is not a known label key; expected one of ${dn.join(", ")}`);
556
+ const l = r[i];
557
+ if (l === void 0) continue;
558
+ const u = typeof n[i];
559
+ if (typeof l !== u)
560
+ throw new TypeError(`[markdown-explorer] labels.${i} must be a ${u}; got ${Ce(l)}`);
561
+ if (typeof l == "string" && l.trim() === "")
562
+ throw new RangeError(`[markdown-explorer] labels.${i} must be a non-blank string`);
563
+ const m = Rr[i];
564
+ if (typeof l == "string" && m !== void 0) {
565
+ for (const [, f] of l.matchAll(Mr))
566
+ if (!m.includes(f ?? ""))
567
+ throw new RangeError(`[markdown-explorer] labels.${i} uses the unknown placeholder {${String(f)}}; it accepts ${m.map((d) => `{${d}}`).join(", ")}`);
568
+ }
569
+ o[i] = l;
570
+ }
571
+ return Object.freeze(o);
572
+ }, Nr = (e, t) => {
573
+ if (Object.is(e, t)) return !0;
574
+ if (e === null || t === null || typeof e != "object" || typeof t != "object") return !1;
575
+ const n = e, r = t, o = Object.keys(n), i = Object.keys(r);
576
+ return o.length === i.length && i.every((l) => Object.hasOwn(n, l) && Object.is(n[l], r[l]));
577
+ }, Mt = Object.freeze(["light", "dark"]), Dr = (e) => {
578
+ if (e === void 0) return "light";
579
+ if (Mt.includes(e)) return e;
580
+ throw new RangeError(`[markdown-explorer] theme must be ${Mt.map((t) => JSON.stringify(t)).join(" or ")}; got ${typeof e == "string" ? JSON.stringify(e) : typeof e}`);
581
+ }, fn = pe(null), D = () => {
582
+ const e = ne(fn);
583
+ if (e === null) throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");
584
+ return e;
585
+ }, Ae = (e) => {
586
+ const { viewSettings: t } = D(), n = () => e(t.getSnapshot());
587
+ return ee(t.subscribe, n, n);
588
+ }, lt = () => {
589
+ const { config: e } = D(), t = _n()["*"], [n] = In(), r = n.toString();
590
+ return G(() => rn(e, t, new URLSearchParams(r)), [e, t, r]);
591
+ }, mn = {
592
+ unauthorized: ["failureUnauthorizedTitle", "failureUnauthorizedBody"],
593
+ forbidden: ["failureForbiddenTitle", "failureForbiddenBody"],
594
+ "not-found": ["failureNotFoundTitle", "failureNotFoundBody"],
595
+ "not-configured": ["failureNotConfiguredTitle", "failureNotConfiguredBody"],
596
+ invalid: ["failureInvalidTitle", "failureInvalidBody"],
597
+ "too-large": ["failureTooLargeTitle", "failureTooLargeBody"],
598
+ unsupported: ["failureUnsupportedTitle", "failureUnsupportedBody"],
599
+ failed: ["failureFailedTitle", "failureFailedBody"]
600
+ }, ae = (e, t) => e[mn[t][0]], me = ({ failure: e, alert: t, onRetry: n, testId: r }) => {
601
+ const { labels: o } = D(), i = ae(o, e.reason), l = o[mn[e.reason][1]], u = e.reason === "unauthorized" || e.reason === "forbidden" || e.reason === "failed" ? "danger" : "warning";
602
+ return /* @__PURE__ */ F("div", { className: "aqmx-callout", role: t ? "alert" : void 0, "data-aqmx-tone": u, "data-testid": r === null ? void 0 : r, "data-aqmx-failure": r === null ? void 0 : e.reason, children: [
603
+ /* @__PURE__ */ c("p", { className: "aqmx-callout-title", children: i }),
604
+ /* @__PURE__ */ c("p", { className: "aqmx-callout-body", children: l }),
605
+ e.reason === "unauthorized" ? /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", onClick: () => window.location.reload(), children: o.reloadPage }) : n !== void 0 && e.reason === "failed" ? /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", onClick: n, children: o.retry }) : null
606
+ ] });
607
+ }, Pr = (e, t) => {
608
+ const { phase: n, save: r, dirty: o } = t;
609
+ switch (n.kind) {
610
+ case "opening":
611
+ return e.editLoading;
612
+ case "grant":
613
+ return e.editGrantTitle;
614
+ case "failed":
615
+ return ae(e, n.failure.reason);
616
+ }
617
+ switch (r.kind) {
618
+ case "draft":
619
+ return e.draftStatus;
620
+ case "saving":
621
+ return e.draftSaving;
622
+ case "conflicts":
623
+ return e.draftConflicts(r.count);
624
+ case "grant":
625
+ return e.editGrantTitle;
626
+ case "failed":
627
+ return e.draftSaveFailed(ae(e, r.failure.reason));
628
+ case "saved":
629
+ if (!o) return r.merged ? e.draftSavedMerged : e.draftSaved;
630
+ break;
631
+ }
632
+ return o ? e.draftUnsaved : "";
633
+ }, $r = (e, t, n) => {
634
+ switch (t.kind) {
635
+ case "draft":
636
+ return e.draftNotSaved;
637
+ case "saved":
638
+ return t.merged ? e.documentSavedMerged(n) : e.documentSaved(n);
639
+ case "conflicts":
640
+ return e.draftConflicts(t.count);
641
+ case "grant":
642
+ return e.editGrantTitle;
643
+ case "failed":
644
+ return e.draftSaveFailed(ae(e, t.failure.reason));
645
+ case "idle":
646
+ case "saving":
647
+ return null;
648
+ }
649
+ }, Me = () => {
650
+ const e = /* @__PURE__ */ new Set();
651
+ return {
652
+ subscribe: (t) => (e.add(t), () => {
653
+ e.delete(t);
654
+ }),
655
+ emit: () => {
656
+ for (const t of [...e]) t();
657
+ }
658
+ };
659
+ }, Fr = "<<<<<<<", qr = "=======", _r = ">>>>>>>", Ot = (e, t) => e === t || e.startsWith(`${t} `), Ct = (e) => Ir(e.split(`
660
+ `)), Ir = (e) => {
661
+ const t = [];
662
+ let n = null, r = null, o = 0;
663
+ for (const i of e) {
664
+ o += 1;
665
+ const l = i.charCodeAt(0);
666
+ l !== 60 && l !== 61 && l !== 62 || (Ot(i, Fr) ? (n = o, r = null) : i === qr ? n !== null && r === null ? r = o : n = null : Ot(i, _r) && (n !== null && r !== null && t.push({ start: n, separator: r, end: o }), n = null, r = null));
667
+ }
668
+ return t;
669
+ }, Lt = (e) => e.includes(`\r
670
+ `) ? `\r
671
+ ` : `
672
+ `, Ue = (e) => e.replace(/\r\n?/gu, `
673
+ `), Br = (e, t) => t === `
674
+ ` ? e : e.replaceAll(`
675
+ `, `\r
676
+ `), zr = 3, jr = /^\d+(?:\.\d+)?$/u, Hr = (e) => {
677
+ if (e === null || !jr.test(e)) return null;
678
+ const t = Number(e);
679
+ return t >= ln && t <= on ? t : null;
680
+ }, Ze = Object.freeze({ kind: "idle" }), At = Object.freeze({ kind: "draft" }), Vr = ({ data: e, conflictLabels: t, onSaveSettled: n, sideBySideSetting: r, editorShareSetting: o }) => {
681
+ const i = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), d = Me();
682
+ let h = null, g = null, b = null;
683
+ const M = (a, s) => {
684
+ a.value = { ...a.value, ...s }, d.emit();
685
+ }, R = (a, s) => i.get(a) === s, S = async (a, s) => {
686
+ s.controller.abort(), s.controller = new AbortController();
687
+ const { signal: w } = s.controller;
688
+ M(s, { phase: { kind: "opening" } });
689
+ const T = await e.edit(a, w);
690
+ if (!R(a, s) || w.aborted || !("kind" in T)) return;
691
+ if (T.kind === "grant") {
692
+ M(s, { phase: { kind: "grant", href: T.href } });
693
+ return;
694
+ }
695
+ if (T.kind === "failure") {
696
+ M(s, { phase: { kind: "failed", failure: T.failure } });
697
+ return;
698
+ }
699
+ const C = Ue(T.text), N = T.kind === "draft";
700
+ s.base = { text: C, version: N ? null : T.version }, s.draft = C, s.ending = Lt(T.text), M(s, { phase: { kind: "editing" }, history: N ? !1 : T.history, dirty: !1, save: N ? At : Ze, generation: s.value.generation + 1 });
701
+ }, A = (a) => {
702
+ const s = i.get(a);
703
+ s !== void 0 && (s.controller.abort(), i.delete(a), u.delete(a));
704
+ }, L = (a, s, w) => (a.set(s, w), () => {
705
+ a.get(s) === w && a.delete(s);
706
+ }), E = (a, s, w, T = {}) => {
707
+ M(s, { ...T, save: w }), n(a, w);
708
+ }, v = async (a) => {
709
+ m.get(a)?.flush();
710
+ const s = i.get(a);
711
+ if (s === void 0 || s.value.phase.kind !== "editing" || s.base === null || s.value.save.kind === "saving") return;
712
+ const { version: w } = s.base;
713
+ if (w === null) {
714
+ n(a, At);
715
+ return;
716
+ }
717
+ const T = Ct(s.draft).length;
718
+ if (T > 0) {
719
+ E(a, s, { kind: "conflicts", count: T });
720
+ return;
721
+ }
722
+ s.controller.abort(), s.controller = new AbortController();
723
+ const { signal: C } = s.controller;
724
+ let N = { text: s.base.text, version: w }, q = s.draft, W = !1;
725
+ M(s, { save: { kind: "saving" } });
726
+ for (let z = 0; z < zr; z += 1) {
727
+ const j = await e.save(a, N.version, Br(q, s.ending), C);
728
+ if (!R(a, s) || C.aborted || !("kind" in j)) return;
729
+ if (j.kind === "saved") {
730
+ m.get(a)?.flush(), s.base = { text: q, version: j.version }, E(a, s, { kind: "saved", merged: W }, { dirty: s.draft !== q });
731
+ return;
732
+ }
733
+ if (j.kind === "grant") {
734
+ E(a, s, { kind: "grant", href: j.href });
735
+ return;
736
+ }
737
+ if (j.kind === "failure") {
738
+ E(a, s, { kind: "failed", failure: j.failure });
739
+ return;
740
+ }
741
+ const { mergeDraft: Y } = await import("./merge-CS3p9BVw.js");
742
+ if (!R(a, s) || C.aborted) return;
743
+ const V = m.get(a);
744
+ V?.flush();
745
+ const re = Ue(j.text), p = Y(N.text, s.draft, re, t());
746
+ if (N = { text: re, version: j.version }, s.base = N, s.ending = Lt(j.text), s.draft = p.text, V?.adopt(p.text), p.kind === "conflicts") {
747
+ E(a, s, { kind: "conflicts", count: p.conflicts }, { dirty: !0, generation: s.value.generation + 1 });
748
+ return;
749
+ }
750
+ if (W = !0, q = p.text, q === N.text) {
751
+ E(a, s, { kind: "saved", merged: W }, { dirty: !1, generation: s.value.generation + 1 });
752
+ return;
753
+ }
754
+ M(s, { dirty: !0, generation: s.value.generation + 1 });
755
+ }
756
+ E(a, s, { kind: "failed", failure: { reason: "failed" } });
757
+ };
758
+ return {
759
+ session: (a) => i.get(a)?.value,
760
+ subscribe: d.subscribe,
761
+ start: (a, s) => {
762
+ const w = i.get(a);
763
+ if (w !== void 0) {
764
+ M(w, { request: { anchor: s }, view: "editor" }), (w.value.phase.kind === "failed" || w.value.phase.kind === "grant") && S(a, w);
765
+ return;
766
+ }
767
+ l.delete(a);
768
+ const T = {
769
+ value: { path: a, phase: { kind: "opening" }, view: "editor", previewPrepared: !1, history: !1, dirty: !1, save: Ze, generation: 0, request: { anchor: s } },
770
+ base: null,
771
+ draft: "",
772
+ ending: `
773
+ `,
774
+ controller: new AbortController()
775
+ };
776
+ i.set(a, T), S(a, T);
777
+ },
778
+ retry: (a) => {
779
+ const s = i.get(a);
780
+ s === void 0 || s.value.phase.kind === "editing" || S(a, s);
781
+ },
782
+ draft: (a) => {
783
+ const s = i.get(a);
784
+ return s === void 0 || s.base === null ? null : s.draft;
785
+ },
786
+ setDraft: (a, s) => {
787
+ const w = i.get(a);
788
+ if (w === void 0 || w.base === null) return;
789
+ w.draft = s;
790
+ const T = {}, C = s !== w.base.text;
791
+ C !== w.value.dirty && (T.dirty = C);
792
+ const { save: N } = w.value;
793
+ if (N.kind === "conflicts") {
794
+ const q = Ct(s).length;
795
+ q === 0 ? T.save = Ze : q !== N.count && (T.save = { kind: "conflicts", count: q });
796
+ }
797
+ (T.dirty !== void 0 || T.save !== void 0) && M(w, T);
798
+ },
799
+ consumeRequest: (a) => {
800
+ const s = i.get(a);
801
+ s !== void 0 && s.value.request !== null && M(s, { request: null });
802
+ },
803
+ save: v,
804
+ replaceDraft: (a, s) => {
805
+ const w = m.get(a);
806
+ w?.flush();
807
+ const T = i.get(a);
808
+ if (T === void 0 || T.base === null) return;
809
+ const C = Ue(s);
810
+ T.draft = C, w?.adopt(C), M(T, { dirty: C !== T.base.text, generation: T.value.generation + 1 });
811
+ },
812
+ close: (a) => {
813
+ if (!i.has(a)) return;
814
+ const s = m.get(a), w = s === void 0 ? null : s.returnPoint();
815
+ A(a), w === null ? l.delete(a) : l.set(a, w), d.emit();
816
+ },
817
+ takeReturn: (a) => {
818
+ const s = l.get(a) ?? null;
819
+ return l.delete(a), s;
820
+ },
821
+ dirtyPaths: () => [...i.values()].filter((a) => a.value.dirty).map((a) => a.value.path),
822
+ discard: (a) => {
823
+ for (const s of a) A(s);
824
+ a.length > 0 && d.emit();
825
+ },
826
+ editorState: {
827
+ get: (a) => u.get(a),
828
+ set: (a, s) => {
829
+ i.has(a) && u.set(a, s);
830
+ }
831
+ },
832
+ bindEditor: (a, s) => L(m, a, s),
833
+ bindView: (a, s) => L(f, a, s),
834
+ viewAnchor: (a) => {
835
+ const s = f.get(a);
836
+ return s === void 0 ? null : s.anchor();
837
+ },
838
+ flush: (a) => m.get(a)?.flush(),
839
+ flushDrafts: () => {
840
+ for (const a of m.values()) a.flush();
841
+ },
842
+ nextConflict: (a) => m.get(a)?.nextConflict() === !0,
843
+ hasSessions: () => i.size > 0,
844
+ unsavedAmong: (a) => {
845
+ for (const s of m.values()) s.flush();
846
+ return a.filter((s) => i.get(s)?.value.dirty === !0);
847
+ },
848
+ askToDiscard: (a) => new Promise((s) => {
849
+ b?.settle(!1);
850
+ const w = {
851
+ paths: a,
852
+ settle: (T) => {
853
+ if (b === w) {
854
+ if (b = null, T) for (const C of a) A(C);
855
+ d.emit(), s(T);
856
+ }
857
+ }
858
+ };
859
+ b = w, d.emit();
860
+ }),
861
+ discardRequest: () => b,
862
+ sideBySide: () => (h ??= r.read(), h),
863
+ setSideBySide: (a) => {
864
+ h !== a && (h = a, r.write(a), d.emit());
865
+ },
866
+ editorShare: () => (g ??= o.read() ?? Zn, g),
867
+ setEditorShare: (a) => {
868
+ if (!Number.isFinite(a)) throw new RangeError(`[markdown-explorer] an editor share must be a finite number; got ${String(a)}`);
869
+ const s = Math.min(on, Math.max(ln, a));
870
+ g !== s && (g = s, o.write(s));
871
+ },
872
+ setView: (a, s) => {
873
+ const w = i.get(a);
874
+ w === void 0 || w.value.view === s || (m.get(a)?.beforeView(s), M(w, { view: s, previewPrepared: w.value.previewPrepared || s === "preview" }));
875
+ },
876
+ preparePreview: (a) => {
877
+ const s = i.get(a);
878
+ s !== void 0 && !s.value.previewPrepared && M(s, { previewPrepared: !0 });
879
+ }
880
+ };
881
+ }, hn = (e) => {
882
+ e.preventDefault(), e.stopPropagation();
883
+ }, Ur = (e) => e.endsWith("px") ? Number.parseFloat(e) : Number.NaN, pn = "data-aqmx-content-pane", et = Object.freeze({ [pn]: "" }), Zr = "--aqmx-dialog-left", Gr = "--aqmx-dialog-top", Wr = '[data-testid="markdown-explorer"]', Kr = (e) => {
884
+ const t = e.closest(Wr)?.querySelectorAll(`[${pn}]`), n = t?.item(t.length - 1);
885
+ if (!(n instanceof HTMLElement)) throw new Error("[markdown-explorer] a dialog opened where the explorer marks no content pane");
886
+ return n;
887
+ }, Xr = (e) => {
888
+ const t = Ur(getComputedStyle(e).marginTop);
889
+ if (Number.isNaN(t)) return null;
890
+ const n = Kr(e), r = e.getBoundingClientRect(), o = e.ownerDocument.documentElement, { left: i, top: l } = Gn(n.getBoundingClientRect(), { width: r.width + 2 * t, height: r.height + 2 * t }, { width: o.clientWidth, height: o.clientHeight });
891
+ return e.style.setProperty(Zr, `${String(i)}px`), e.style.setProperty(Gr, `${String(l)}px`), n;
892
+ }, Yr = (e) => e.preventDefault(), vn = ({ open: e, onOpen: t, onDismiss: n }) => {
893
+ const r = _(null), o = _(null), i = _(!1), l = _(t);
894
+ H(() => {
895
+ l.current = t;
896
+ }, [t]), H(() => {
897
+ i.current = e;
898
+ const d = r.current;
899
+ if (d !== null)
900
+ if (e && !d.open) {
901
+ const h = d.ownerDocument.activeElement;
902
+ o.current = h instanceof HTMLElement ? h : null, d.showModal(), l.current?.();
903
+ } else !e && d.open && (d.close(), o.current?.isConnected === !0 && o.current.focus(), o.current = null);
904
+ }, [e]), H(() => {
905
+ const d = r.current;
906
+ if (!e || d === null) return;
907
+ const h = new ResizeObserver(() => b());
908
+ let g = null;
909
+ const b = () => {
910
+ const R = Xr(d);
911
+ R === null || R === g || (g !== null && h.unobserve(g), h.observe(R), g = R);
912
+ };
913
+ b(), h.observe(d);
914
+ const M = d.ownerDocument.defaultView;
915
+ return M?.addEventListener("resize", b), d.ownerDocument.addEventListener("scroll", b, { capture: !0, passive: !0 }), () => {
916
+ h.disconnect(), M?.removeEventListener("resize", b), d.ownerDocument.removeEventListener("scroll", b, { capture: !0 });
917
+ };
918
+ }, [e]);
919
+ const u = P(
920
+ (d) => {
921
+ d.key !== "Escape" || d.defaultPrevented || (hn(d), n());
922
+ },
923
+ [n]
924
+ ), m = P(
925
+ (d) => {
926
+ d.target === d.currentTarget && n();
927
+ },
928
+ [n]
929
+ ), f = P(() => {
930
+ i.current && n();
931
+ }, [n]);
932
+ return { ref: r, onKeyDown: u, onClick: m, onCancel: Yr, onClose: f };
933
+ }, wn = ({ open: e, title: t, body: n, confirmLabel: r, cancelLabel: o, onConfirm: i, onCancel: l, testId: u }) => {
934
+ const m = _(null), f = Se(), d = Se(), h = P(() => m.current?.focus(), []), g = vn({ open: e, onOpen: h, onDismiss: l });
935
+ return /* @__PURE__ */ c("dialog", { ...g, className: "aqmx-confirm", "aria-labelledby": f, "aria-describedby": d, "data-testid": u, children: /* @__PURE__ */ F("div", { className: "aqmx-confirm-panel", children: [
936
+ /* @__PURE__ */ c("p", { id: f, className: "aqmx-confirm-title", children: t }),
937
+ /* @__PURE__ */ c("p", { id: d, className: "aqmx-confirm-body", children: n }),
938
+ /* @__PURE__ */ F("div", { className: "aqmx-confirm-actions", children: [
939
+ /* @__PURE__ */ c("button", { ref: m, type: "button", className: "aqmx-callout-action", "data-testid": `${u}-cancel`, onClick: l, children: o }),
940
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", "data-aqmx-tone": "danger", "data-testid": `${u}-confirm`, onClick: i, children: r })
941
+ ] })
942
+ ] }) });
943
+ }, Te = (e) => {
944
+ const t = e;
945
+ return t.status === void 0 && (t.status = "pending", e.then(
946
+ (n) => {
947
+ t.status = "fulfilled", t.value = n;
948
+ },
949
+ (n) => {
950
+ t.status = "rejected", t.reason = n;
951
+ }
952
+ )), t;
953
+ }, gn = (e) => Object.assign(Promise.resolve(e), { status: "fulfilled", value: e }), Ee = (e) => e.status === "fulfilled" ? e.value : void 0, Jr = Object.freeze({ readme: Object.freeze({ status: "loading" }), claim: !1 }), Qr = Object.freeze({ readme: Object.freeze({ status: "loading" }), claim: !0 }), eo = (e, t, n) => {
954
+ const r = /* @__PURE__ */ new Set(), o = [...e].reverse();
955
+ for (let i = o.pop(); i !== void 0; i = o.pop()) {
956
+ if (i.type !== "directory" || r.has(i.path)) continue;
957
+ r.add(i.path);
958
+ const l = i.lazy === !0 ? n(i.path) : void 0, u = i.lazy === !0 ? l?.status === "loaded" ? l.entries : null : i.children === void 0 ? [] : i.children;
959
+ if (i.path === t) return u;
960
+ if (u !== null) for (const m of [...u].reverse()) o.push(m);
961
+ }
962
+ return null;
963
+ }, to = (e, t, n) => {
964
+ const r = Ee(e.read(t));
965
+ if (r === void 0 || r.status === "deferred") return Jr;
966
+ if (r.status === "error") return { readme: { status: "failed", failure: r.failure, retry: () => e.retry(t) }, claim: !1 };
967
+ const o = eo(r.entries, n, (l) => e.children(t, l));
968
+ if (o !== null) return { readme: { status: "ok", readme: wt(o) }, claim: !1 };
969
+ const i = e.children(t, n);
970
+ return i === void 0 || i.status === "loading" ? Qr : i.status === "failed" ? { readme: { status: "failed", failure: i.failure, retry: () => e.retryChildren(t, n) }, claim: !0 } : { readme: { status: "ok", readme: wt(i.entries) }, claim: !0 };
971
+ }, no = (e, t, n) => {
972
+ const { readme: r } = to(e, t, n);
973
+ return r.status === "ok" ? r.readme : null;
974
+ }, ro = (e, t, n) => {
975
+ const r = Bn({ path: `${e.basePath}/*`, end: !0 }, t.pathname);
976
+ if (r === null) return /* @__PURE__ */ new Set();
977
+ const { location: o } = rn(e, r.params["*"], new URLSearchParams(t.search));
978
+ switch (o.view) {
979
+ case "tree": {
980
+ const i = o.folder === null ? o.doc : n(o.source, o.folder);
981
+ return new Set(i === null ? [] : [i]);
982
+ }
983
+ case "single":
984
+ return /* @__PURE__ */ new Set([o.doc]);
985
+ case "multi":
986
+ return new Set(o.docs);
987
+ }
988
+ }, bn = (e) => {
989
+ const { edits: t } = D(), n = P(() => t.session(e), [t, e]);
990
+ return ee(t.subscribe, n, oo);
991
+ }, En = () => !1, oo = () => {
992
+ }, io = () => {
993
+ const { edits: e } = D();
994
+ return ee(e.subscribe, e.hasSessions, En);
995
+ }, lo = () => {
996
+ const { edits: e } = D();
997
+ return ee(e.subscribe, e.sideBySide, En);
998
+ }, ao = () => null, so = () => {
999
+ const { edits: e, labels: t, config: n, trees: r } = D(), o = _([]), i = P(
1000
+ ({ nextLocation: b }) => {
1001
+ const M = ro(n, b, (R, S) => no(r, R, S));
1002
+ return e.flushDrafts(), o.current = e.dirtyPaths().filter((R) => !M.has(R)), o.current.length > 0;
1003
+ },
1004
+ [e, n, r]
1005
+ ), l = zn(i), u = io();
1006
+ te(() => {
1007
+ if (!u) return;
1008
+ const b = (M) => {
1009
+ e.flushDrafts(), e.dirtyPaths().length !== 0 && (M.preventDefault(), M.returnValue = !0);
1010
+ };
1011
+ return window.addEventListener("beforeunload", b), () => window.removeEventListener("beforeunload", b);
1012
+ }, [u, e]);
1013
+ const m = ee(e.subscribe, e.discardRequest, ao), f = l.state === "blocked", d = f ? o.current : m === null ? [] : m.paths, h = d.map((b) => se(b)).join(", "), g = d.length > 0 && d.every((b) => e.session(b)?.save.kind === "draft");
1014
+ return /* @__PURE__ */ c(
1015
+ wn,
1016
+ {
1017
+ open: f || m !== null,
1018
+ title: g ? t.draftDiscardTitle : t.unsavedTitle,
1019
+ body: g ? t.draftDiscardBody(h) : t.unsavedBody(h),
1020
+ confirmLabel: t.unsavedDiscard,
1021
+ cancelLabel: t.unsavedStay,
1022
+ testId: "markdown-explorer-unsaved-guard",
1023
+ onConfirm: () => {
1024
+ if (l.state === "blocked") {
1025
+ e.discard(o.current), l.proceed();
1026
+ return;
1027
+ }
1028
+ m?.settle(!0);
1029
+ },
1030
+ onCancel: () => {
1031
+ if (l.state === "blocked") {
1032
+ l.reset();
1033
+ return;
1034
+ }
1035
+ m?.settle(!1);
1036
+ }
1037
+ }
1038
+ );
1039
+ };
1040
+ function co({
1041
+ title: e,
1042
+ titleId: t,
1043
+ ...n
1044
+ }, r) {
1045
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1046
+ xmlns: "http://www.w3.org/2000/svg",
1047
+ viewBox: "0 0 20 20",
1048
+ fill: "currentColor",
1049
+ "aria-hidden": "true",
1050
+ "data-slot": "icon",
1051
+ ref: r,
1052
+ "aria-labelledby": t
1053
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1054
+ id: t
1055
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1056
+ fillRule: "evenodd",
1057
+ d: "M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm2.25 8.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Zm0 3a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",
1058
+ clipRule: "evenodd"
1059
+ }));
1060
+ }
1061
+ const uo = /* @__PURE__ */ y.forwardRef(co);
1062
+ let Ge = null;
1063
+ const yn = () => (Ge ??= import("./EditSurface-0owpPyLE.js").catch((e) => {
1064
+ throw Ge = null, e;
1065
+ }), Ge), fo = () => {
1066
+ yn().catch(() => {
1067
+ });
1068
+ }, mo = (e) => {
1069
+ const { default: t } = ne(yn());
1070
+ return /* @__PURE__ */ c(t, { ...e });
1071
+ };
1072
+ class ho extends tn {
1073
+ state = { failed: !1 };
1074
+ static getDerivedStateFromError() {
1075
+ return { failed: !0 };
1076
+ }
1077
+ retry = () => this.setState({ failed: !1 });
1078
+ render() {
1079
+ return this.state.failed ? this.props.fallback(this.retry) : this.props.children;
1080
+ }
1081
+ }
1082
+ const at = `[${sn}]`, po = "[data-aqmd-content]", vo = 'a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg', wo = 200, Re = (e) => Er(e.getAttribute(sn)), go = (e, t) => {
1083
+ for (let r = e; r !== null && t.contains(r); r = r.parentElement) {
1084
+ const o = Re(r);
1085
+ if (o !== null) return { block: r, lines: o, own: !0 };
1086
+ }
1087
+ let n = null;
1088
+ for (const r of t.querySelectorAll(at)) {
1089
+ if (!(r.compareDocumentPosition(e) & Node.DOCUMENT_POSITION_FOLLOWING)) break;
1090
+ const o = Re(r);
1091
+ o !== null && (n = { block: r, lines: o });
1092
+ }
1093
+ return n === null ? null : { ...n, own: !1 };
1094
+ }, bo = (e, t) => {
1095
+ let n = 0;
1096
+ for (let r = e.indexOf(t); r >= 0; r = e.indexOf(t, r + t.length)) n += 1;
1097
+ return n;
1098
+ }, Eo = (e) => e.closest(po) !== null && e.closest(vo) === null, yo = (e, t, n) => {
1099
+ const r = go(e, t);
1100
+ if (r === null) return null;
1101
+ const { block: o, own: i } = r;
1102
+ if (!i) {
1103
+ const u = r.lines.last + 1;
1104
+ return { lines: { first: u, last: u }, word: null, occurrence: 0, clientTop: Ne(e) };
1105
+ }
1106
+ const l = To(o, n);
1107
+ return l === null ? { lines: r.lines, word: null, occurrence: 0, clientTop: Ne(o) } : { lines: r.lines, word: l.text, occurrence: l.occurrence, clientTop: l.clientTop };
1108
+ }, xo = (e, t) => {
1109
+ let n = null, r = null, o = null;
1110
+ for (const l of e.querySelectorAll(at)) {
1111
+ const u = Re(l);
1112
+ if (u === null) continue;
1113
+ n ??= ko(t, l);
1114
+ const { top: m, bottom: f } = l.getBoundingClientRect();
1115
+ m <= n && n < f ? r = { lines: u, block: l } : o === null && m >= n && (o = { lines: u, block: l });
1116
+ }
1117
+ const i = r === null ? o : r;
1118
+ return i === null ? null : { lines: i.lines, word: null, occurrence: 0, clientTop: Ne(i.block) };
1119
+ }, So = (e) => e === e.ownerDocument.scrollingElement ? 0 : e.getBoundingClientRect().top + e.clientTop, ko = (e, t) => {
1120
+ const n = Number.parseFloat(getComputedStyle(t).scrollMarginTop);
1121
+ return So(e) + (Number.isFinite(n) ? n : 0);
1122
+ }, To = (e, t) => {
1123
+ if (t === null || t.rangeCount === 0) return null;
1124
+ const n = t.getRangeAt(0);
1125
+ if (!(e.contains(n.startContainer) && e.contains(n.endContainer))) return null;
1126
+ const r = n.toString().trim();
1127
+ if (r === "" || r.length > wo || /[\r\n]/u.test(r)) return null;
1128
+ const o = e.ownerDocument.createRange();
1129
+ return o.setStart(e, 0), o.setEnd(n.startContainer, n.startOffset), { text: r, occurrence: bo(o.toString(), r), clientTop: n.getBoundingClientRect().top };
1130
+ }, Xa = (e, t) => {
1131
+ const n = e.split(`
1132
+ `), r = Math.min(t.lines.first, n.length), o = Math.min(t.lines.last, n.length), i = { line: r, column: 0 };
1133
+ if (t.word === null) return i;
1134
+ let l = 0;
1135
+ for (let u = r; u <= o; u += 1) {
1136
+ const m = n[u - 1] ?? "";
1137
+ for (let f = m.indexOf(t.word); f >= 0; f = m.indexOf(t.word, f + t.word.length)) {
1138
+ if (l === t.occurrence) return { line: u, column: f };
1139
+ l += 1;
1140
+ }
1141
+ }
1142
+ return l > 0 ? Ro(n, r, o, t.word) ?? i : i;
1143
+ }, Ro = (e, t, n, r) => {
1144
+ for (let o = n; o >= t; o -= 1) {
1145
+ const i = (e[o - 1] ?? "").lastIndexOf(r);
1146
+ if (i >= 0) return { line: o, column: i };
1147
+ }
1148
+ return null;
1149
+ }, Mo = (e, t) => {
1150
+ let n = null, r = null;
1151
+ for (const o of e.querySelectorAll(at)) {
1152
+ const i = Re(o);
1153
+ i === null || i.first > t || (i.last >= t ? n = o : (r === null || i.last >= r.last) && (r = { element: o, last: i.last }));
1154
+ }
1155
+ return n !== null ? n : r === null ? null : r.element;
1156
+ }, Oo = (e, t) => {
1157
+ const { bottom: n } = e.getBoundingClientRect(), r = Ne(e), o = Re(e);
1158
+ if (o === null) return r;
1159
+ const i = Math.min(Math.max(t - o.first, 0) / (o.last - o.first + 1), 1);
1160
+ return r + (n - r) * i;
1161
+ }, Ne = (e) => {
1162
+ const t = e.ownerDocument.createTreeWalker(e, NodeFilter.SHOW_TEXT);
1163
+ for (let n = t.nextNode(); n !== null; n = t.nextNode()) {
1164
+ const o = (n.textContent ?? "").search(/\S/u);
1165
+ if (o < 0) continue;
1166
+ const i = e.ownerDocument.createRange();
1167
+ i.setStart(n, o), i.setEnd(n, o + 1);
1168
+ const { top: l, height: u } = i.getBoundingClientRect();
1169
+ if (u > 0) return l;
1170
+ }
1171
+ return e.getBoundingClientRect().top;
1172
+ }, st = Object.freeze({
1173
+ browse: Object.freeze({ replace: !0, preventScrollReset: !0, defaultShouldRevalidate: !1 }),
1174
+ "switch-source": Object.freeze({ replace: !1, preventScrollReset: !0, defaultShouldRevalidate: !1 }),
1175
+ "switch-view": Object.freeze({ replace: !1, preventScrollReset: !1, defaultShouldRevalidate: !1 }),
1176
+ "follow-link": Object.freeze({ replace: !1, preventScrollReset: !1, defaultShouldRevalidate: !1 })
1177
+ }), Ya = (e) => st[e], Fe = () => {
1178
+ const e = jn();
1179
+ return P(
1180
+ (t, n) => {
1181
+ e(t, st[n]);
1182
+ },
1183
+ [e]
1184
+ );
1185
+ }, Co = ({ navigation: e, ...t }) => /* @__PURE__ */ c(Hn, { ...t, ...st[e] }), xn = (e) => {
1186
+ const t = e.ownerDocument;
1187
+ if (e.focus({ preventScroll: !0 }), t.activeElement === e) return !0;
1188
+ if (e.hasAttribute("tabindex")) return !1;
1189
+ if (e.setAttribute("tabindex", "-1"), e.focus({ preventScroll: !0 }), t.activeElement !== e)
1190
+ return e.removeAttribute("tabindex"), !1;
1191
+ const n = () => {
1192
+ t.activeElement !== e && (e.removeAttribute("tabindex"), e.removeEventListener("blur", n));
1193
+ };
1194
+ return e.addEventListener("blur", n), !0;
1195
+ }, Lo = (e, t) => {
1196
+ const n = _(null), r = _(null), o = _(null), i = P(() => {
1197
+ n.current !== null && window.clearTimeout(n.current), n.current = null, r.current = null;
1198
+ }, []);
1199
+ te(() => i, [i]);
1200
+ const l = P(
1201
+ (f) => {
1202
+ if (r.current !== f) return;
1203
+ const d = o.current;
1204
+ if (d !== null) {
1205
+ d.then(() => l(f));
1206
+ return;
1207
+ }
1208
+ e.prefetch(f);
1209
+ const h = e.peek(f);
1210
+ if (h?.status !== "pending") return;
1211
+ const g = Promise.allSettled([h.promise]);
1212
+ o.current = g, g.then(() => {
1213
+ o.current === g && (o.current = null);
1214
+ });
1215
+ },
1216
+ [e]
1217
+ ), u = P(
1218
+ (f) => {
1219
+ const d = t(f);
1220
+ d !== r.current && (i(), d !== null && (r.current = d, n.current = window.setTimeout(() => {
1221
+ n.current = null, l(d);
1222
+ }, Wn)));
1223
+ },
1224
+ [i, t, l]
1225
+ ), m = P(
1226
+ (f) => {
1227
+ t(f) !== r.current && i();
1228
+ },
1229
+ [i, t]
1230
+ );
1231
+ return G(
1232
+ () => ({
1233
+ onPointerOver: (f) => u(f.target),
1234
+ onPointerOut: (f) => m(f.relatedTarget),
1235
+ onFocus: (f) => u(f.target),
1236
+ onBlur: (f) => m(f.relatedTarget)
1237
+ }),
1238
+ [u, m]
1239
+ );
1240
+ }, Ao = it(() => import("./NativeScrollBar-CI9fTvkt.js").then((e) => ({ default: e.NativeScrollBar })));
1241
+ class No extends tn {
1242
+ state = { failed: !1 };
1243
+ static getDerivedStateFromError() {
1244
+ return { failed: !0 };
1245
+ }
1246
+ componentDidCatch(t) {
1247
+ console.error("[markdown-explorer] a scroll bar failed to load or render; its scroller keeps its native scrolling without it.", t);
1248
+ }
1249
+ render() {
1250
+ return this.state.failed ? null : this.props.children;
1251
+ }
1252
+ }
1253
+ const Do = ({ scroller: e, withCircle: t }) => /* @__PURE__ */ c(No, { children: /* @__PURE__ */ c(ke, { fallback: null, children: /* @__PURE__ */ c(Ao, { scroller: e, withCircle: t }) }) }), Sn = (e) => /* @__PURE__ */ c(Do, { scroller: e, withCircle: !0 }), kn = () => {
1254
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
1255
+ let n = !1;
1256
+ const r = (o) => {
1257
+ t.add(o), !n && (n = !0, queueMicrotask(() => {
1258
+ n = !1, t.clear();
1259
+ }));
1260
+ };
1261
+ return {
1262
+ hold: (o) => {
1263
+ e.set(o, (e.get(o) ?? 0) + 1);
1264
+ let i = !1;
1265
+ return () => {
1266
+ if (i) return;
1267
+ i = !0;
1268
+ const l = e.get(o);
1269
+ if (l !== void 0 && l > 1) {
1270
+ e.set(o, l - 1);
1271
+ return;
1272
+ }
1273
+ e.delete(o), r(o);
1274
+ };
1275
+ },
1276
+ isHeld: (o) => e.has(o),
1277
+ resumes: (o) => t.delete(o),
1278
+ heldKeys: () => [...e.keys()]
1279
+ };
1280
+ }, De = (e, t) => {
1281
+ if (Object.is(e, t)) return !0;
1282
+ if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
1283
+ if (Array.isArray(e) || Array.isArray(t))
1284
+ return !(Array.isArray(e) && Array.isArray(t)) || e.length !== t.length ? !1 : e.every((i, l) => De(i, t[l]));
1285
+ const n = e, r = t, o = Object.keys(n);
1286
+ return o.length !== Object.keys(r).length ? !1 : o.every((i) => Object.hasOwn(r, i) && De(n[i], r[i]));
1287
+ }, Po = 55e3, Nt = Object.freeze({ status: "deferred" }), Dt = Object.freeze({ status: "refreshed" }), We = Object.freeze({ status: "superseded" }), ue = (e) => e === void 0 || e.status === "deferred" ? null : e.status === "loaded" ? e : e.previous, Tn = (e) => e !== void 0 && e.status === "loaded" && e.document.kind !== "failure", $o = ({ client: e, capacity: t }) => {
1288
+ if (!Number.isInteger(t) || t < 1) throw new RangeError(`[markdown-explorer] the document cache capacity must be a positive integer; got ${String(t)}`);
1289
+ const n = /* @__PURE__ */ new Map(), r = kn(), o = Me(), i = /* @__PURE__ */ new WeakSet();
1290
+ let l = 0;
1291
+ const u = o.emit, m = () => (l += 1, l), f = () => {
1292
+ if (!(n.size <= t))
1293
+ for (const E of [...n.keys()]) {
1294
+ if (n.size <= t) return;
1295
+ r.isHeld(E) || n.delete(E);
1296
+ }
1297
+ }, d = (E, v) => {
1298
+ n.delete(E), n.set(E, v);
1299
+ }, h = (E) => performance.now() - E.validatedAt >= Po, g = (E, v, a) => {
1300
+ const s = n.get(E), w = ue(s?.snapshot), T = a || s?.refreshPending === !0, C = Te(e.document(E, { refresh: T }).then((q) => ({ status: "loaded", document: q }))), N = { snapshot: { status: "pending", promise: C, previous: w }, validatedAt: performance.now(), opened: v, background: null, refreshPending: !1, seeded: void 0, stamp: m() };
1301
+ return d(E, N), f(), C.then((q) => {
1302
+ n.get(E) === N && (N.snapshot = q, N.stamp = m(), u());
1303
+ }), N;
1304
+ }, b = (E, v, a, s, w, T) => {
1305
+ v.background === a && (v.background = null, !(n.get(E) !== v || v.snapshot !== s) && (w.kind === "failure" && s.document.kind !== "failure" || (v.validatedAt = T, v.stamp = m(), De(s.document, w) || (v.snapshot = { status: "loaded", document: w }), u())));
1306
+ }, M = async (E, v) => {
1307
+ const a = v.snapshot;
1308
+ if (a.status !== "loaded") return null;
1309
+ const s = {};
1310
+ v.background = s;
1311
+ const w = performance.now(), T = e.document(E, { refresh: v.refreshPending });
1312
+ v.refreshPending = !1;
1313
+ const C = await T, N = v.background === s && n.get(E) === v && v.snapshot === a;
1314
+ return b(E, v, s, a, C, w), N ? C : null;
1315
+ }, R = (E, v) => {
1316
+ const { snapshot: a } = v;
1317
+ return a.status === "pending" ? !1 : a.status === "loaded" && a.document.kind !== "failure" ? (M(E, v), !1) : (a.status === "loaded" && i.add(a), g(E, !0, !1), !0);
1318
+ }, S = (E) => {
1319
+ const v = r.hold(E);
1320
+ let a = !1;
1321
+ return () => {
1322
+ if (a) return;
1323
+ a = !0, v();
1324
+ const s = n.get(E);
1325
+ s !== void 0 && d(E, s), f();
1326
+ };
1327
+ };
1328
+ return {
1329
+ peek: (E) => n.get(E)?.snapshot,
1330
+ peekSeeded: (E) => n.get(E)?.seeded,
1331
+ answerStampOf: (E) => n.get(E)?.stamp,
1332
+ prefetch: (E) => {
1333
+ const v = n.get(E);
1334
+ v !== void 0 && v.snapshot.status !== "deferred" || (g(E, !1, !1), u());
1335
+ },
1336
+ open: (E) => {
1337
+ const v = r.resumes(E), a = S(E), s = n.get(E);
1338
+ if (s === void 0 || s.snapshot.status === "deferred")
1339
+ return g(E, !0, !1), u(), a;
1340
+ if (d(E, s), v) return a;
1341
+ const { snapshot: w } = s;
1342
+ return w.status === "pending" ? (s.opened = !0, a) : w.document.kind === "failure" ? (s.opened || h(s) ? (i.add(w), g(E, !0, !1), u()) : s.opened = !0, a) : (s.opened = !0, s.background === null && h(s) && M(E, s), a);
1343
+ },
1344
+ retain: S,
1345
+ retry: (E) => {
1346
+ const v = n.get(E);
1347
+ v === void 0 || v.snapshot.status !== "loaded" || v.snapshot.document.kind !== "failure" || (g(E, !0, !1), u());
1348
+ },
1349
+ seed: (E, v) => {
1350
+ const a = performance.now(), s = Te(
1351
+ v.then(
1352
+ (q) => q === null ? Nt : { status: "loaded", document: q },
1353
+ () => Nt
1354
+ )
1355
+ ), w = n.get(E);
1356
+ if (w !== void 0 && w.snapshot.status === "loaded") {
1357
+ const q = w.snapshot, W = {};
1358
+ w.background = W, s.then((z) => {
1359
+ if (z.status === "loaded") {
1360
+ b(E, w, W, q, z.document, a);
1361
+ return;
1362
+ }
1363
+ w.background === W && (w.background = null);
1364
+ });
1365
+ return;
1366
+ }
1367
+ const T = w !== void 0 && w.snapshot.status === "pending" ? w.snapshot.previous : null, C = { status: "pending", promise: s, previous: T }, N = { snapshot: C, validatedAt: a, opened: w?.opened === !0, background: null, refreshPending: w?.refreshPending === !0, seeded: C, stamp: m() };
1368
+ d(E, N), f(), s.then((q) => {
1369
+ n.get(E) === N && (q.status === "deferred" && r.isHeld(E) ? g(E, N.opened, !1) : (N.snapshot = q, N.stamp = m()), u());
1370
+ });
1371
+ },
1372
+ invalidate: () => {
1373
+ let E = !1;
1374
+ for (const [v, a] of [...n]) {
1375
+ if (a.validatedAt = Number.NEGATIVE_INFINITY, a.opened = !0, a.refreshPending = !0, !r.isHeld(v)) continue;
1376
+ const { snapshot: s } = a;
1377
+ if (s.status !== "pending") {
1378
+ R(v, a) && (E = !0);
1379
+ continue;
1380
+ }
1381
+ s.promise.then(() => {
1382
+ n.get(v) === a && a.refreshPending && r.isHeld(v) && R(v, a) && u();
1383
+ });
1384
+ }
1385
+ E && u();
1386
+ },
1387
+ refresh: async (E) => {
1388
+ const v = n.get(E);
1389
+ if (v !== void 0 && Tn(v.snapshot)) {
1390
+ v.refreshPending = !0;
1391
+ const s = await M(E, v);
1392
+ return s === null ? We : s.kind === "failure" ? { status: "failed", failure: s.failure } : Dt;
1393
+ }
1394
+ const a = g(E, !0, !0);
1395
+ return u(), a.snapshot.status !== "pending" ? We : (await a.snapshot.promise, n.get(E) === a ? Dt : We);
1396
+ },
1397
+ clear: () => {
1398
+ n.clear();
1399
+ for (const E of r.heldKeys()) g(E, !0, !1);
1400
+ u();
1401
+ },
1402
+ subscribe: o.subscribe,
1403
+ noteFailureShown: (E) => i.has(E) ? !1 : (i.add(E), !0)
1404
+ };
1405
+ };
1406
+ function Fo({
1407
+ title: e,
1408
+ titleId: t,
1409
+ ...n
1410
+ }, r) {
1411
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1412
+ xmlns: "http://www.w3.org/2000/svg",
1413
+ viewBox: "0 0 20 20",
1414
+ fill: "currentColor",
1415
+ "aria-hidden": "true",
1416
+ "data-slot": "icon",
1417
+ ref: r,
1418
+ "aria-labelledby": t
1419
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1420
+ id: t
1421
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1422
+ fillRule: "evenodd",
1423
+ d: "M18 5.25a2.25 2.25 0 0 0-2.012-2.238A2.25 2.25 0 0 0 13.75 1h-1.5a2.25 2.25 0 0 0-2.238 2.012c-.875.092-1.6.686-1.884 1.488H11A2.5 2.5 0 0 1 13.5 7v7h2.25A2.25 2.25 0 0 0 18 11.75v-6.5ZM12.25 2.5a.75.75 0 0 0-.75.75v.25h3v-.25a.75.75 0 0 0-.75-.75h-1.5Z",
1424
+ clipRule: "evenodd"
1425
+ }), /* @__PURE__ */ y.createElement("path", {
1426
+ fillRule: "evenodd",
1427
+ d: "M3 6a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H3Zm6.874 4.166a.75.75 0 1 0-1.248-.832l-2.493 3.739-.853-.853a.75.75 0 0 0-1.06 1.06l1.5 1.5a.75.75 0 0 0 1.154-.114l3-4.5Z",
1428
+ clipRule: "evenodd"
1429
+ }));
1430
+ }
1431
+ const qo = /* @__PURE__ */ y.forwardRef(Fo);
1432
+ function _o({
1433
+ title: e,
1434
+ titleId: t,
1435
+ ...n
1436
+ }, r) {
1437
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1438
+ xmlns: "http://www.w3.org/2000/svg",
1439
+ viewBox: "0 0 20 20",
1440
+ fill: "currentColor",
1441
+ "aria-hidden": "true",
1442
+ "data-slot": "icon",
1443
+ ref: r,
1444
+ "aria-labelledby": t
1445
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1446
+ id: t
1447
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1448
+ fillRule: "evenodd",
1449
+ d: "M15.988 3.012A2.25 2.25 0 0 1 18 5.25v6.5A2.25 2.25 0 0 1 15.75 14H13.5v-3.379a3 3 0 0 0-.879-2.121l-3.12-3.121a3 3 0 0 0-1.402-.791 2.252 2.252 0 0 1 1.913-1.576A2.25 2.25 0 0 1 12.25 1h1.5a2.25 2.25 0 0 1 2.238 2.012ZM11.5 3.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 .75.75v.25h-3v-.25Z",
1450
+ clipRule: "evenodd"
1451
+ }), /* @__PURE__ */ y.createElement("path", {
1452
+ d: "M3.5 6A1.5 1.5 0 0 0 2 7.5v9A1.5 1.5 0 0 0 3.5 18h7a1.5 1.5 0 0 0 1.5-1.5v-5.879a1.5 1.5 0 0 0-.44-1.06L8.44 6.439A1.5 1.5 0 0 0 7.378 6H3.5Z"
1453
+ }));
1454
+ }
1455
+ const Io = /* @__PURE__ */ y.forwardRef(_o);
1456
+ function Bo({
1457
+ title: e,
1458
+ titleId: t,
1459
+ ...n
1460
+ }, r) {
1461
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1462
+ xmlns: "http://www.w3.org/2000/svg",
1463
+ viewBox: "0 0 20 20",
1464
+ fill: "currentColor",
1465
+ "aria-hidden": "true",
1466
+ "data-slot": "icon",
1467
+ ref: r,
1468
+ "aria-labelledby": t
1469
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1470
+ id: t
1471
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1472
+ fillRule: "evenodd",
1473
+ d: "M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",
1474
+ clipRule: "evenodd"
1475
+ }));
1476
+ }
1477
+ const zo = /* @__PURE__ */ y.forwardRef(Bo), jo = 2e3, Pt = Object.freeze({ outcome: "idle" }), Ho = (e) => {
1478
+ const t = navigator.clipboard;
1479
+ return t === void 0 ? Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")) : t.writeText(e);
1480
+ }, Vo = ({ text: e }) => {
1481
+ const { announcer: t, labels: n } = D(), [r, o] = B(Pt);
1482
+ te(() => {
1483
+ if (r.outcome === "idle") return;
1484
+ const m = setTimeout(() => o(Pt), jo);
1485
+ return () => clearTimeout(m);
1486
+ }, [r]);
1487
+ const i = (m) => {
1488
+ o({ outcome: m }), t.announce(m === "copied" ? n.copiedText : n.copyTextFailed);
1489
+ }, l = () => {
1490
+ Ho(e).then(
1491
+ () => i("copied"),
1492
+ () => i("failed")
1493
+ );
1494
+ }, u = r.outcome === "copied" ? n.copiedText : r.outcome === "failed" ? n.copyTextFailed : n.copyText;
1495
+ return (
1496
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-icon-button", "aria-label": n.copyText, title: u, onClick: l, "data-aqmx-copy-outcome": r.outcome, "data-testid": "markdown-explorer-file-copy", children: r.outcome === "copied" ? /* @__PURE__ */ c(qo, {}) : r.outcome === "failed" ? /* @__PURE__ */ c(zo, {}) : /* @__PURE__ */ c(Io, {}) })
1497
+ );
1498
+ }, he = pe("fill"), Uo = Object.freeze({ blockSize: "100%" }), ve = ({ scrollerProps: e, children: t }) => ne(he) === "content" ? /* @__PURE__ */ c(St, { scrollerProps: e, children: t }) : /* @__PURE__ */ c(St, { scrollerProps: { ...e, style: Uo }, rowClassName: "aqmx-document-scroll-row", renderScrollBar: Sn, children: t });
1499
+ function Zo({
1500
+ title: e,
1501
+ titleId: t,
1502
+ ...n
1503
+ }, r) {
1504
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1505
+ xmlns: "http://www.w3.org/2000/svg",
1506
+ viewBox: "0 0 20 20",
1507
+ fill: "currentColor",
1508
+ "aria-hidden": "true",
1509
+ "data-slot": "icon",
1510
+ ref: r,
1511
+ "aria-labelledby": t
1512
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1513
+ id: t
1514
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1515
+ d: "M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z"
1516
+ }), /* @__PURE__ */ y.createElement("path", {
1517
+ d: "M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z"
1518
+ }));
1519
+ }
1520
+ const Go = /* @__PURE__ */ y.forwardRef(Zo);
1521
+ function Wo({
1522
+ title: e,
1523
+ titleId: t,
1524
+ ...n
1525
+ }, r) {
1526
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1527
+ xmlns: "http://www.w3.org/2000/svg",
1528
+ viewBox: "0 0 20 20",
1529
+ fill: "currentColor",
1530
+ "aria-hidden": "true",
1531
+ "data-slot": "icon",
1532
+ ref: r,
1533
+ "aria-labelledby": t
1534
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1535
+ id: t
1536
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1537
+ fillRule: "evenodd",
1538
+ d: "M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z",
1539
+ clipRule: "evenodd"
1540
+ }), /* @__PURE__ */ y.createElement("path", {
1541
+ fillRule: "evenodd",
1542
+ d: "M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z",
1543
+ clipRule: "evenodd"
1544
+ }));
1545
+ }
1546
+ const Ko = /* @__PURE__ */ y.forwardRef(Wo), qe = ({ name: e, openUrl: t, downloadUrl: n, icon: r, children: o }) => {
1547
+ const { labels: i } = D();
1548
+ return /* @__PURE__ */ F("div", { className: "aqmx-document-toolbar", children: [
1549
+ /* @__PURE__ */ c("span", { className: "aqmx-document-file-icon", "aria-hidden": "true", children: r }),
1550
+ /* @__PURE__ */ c("span", { className: "aqmx-document-title", title: e, "data-testid": "markdown-explorer-file-name", children: e }),
1551
+ o,
1552
+ /* @__PURE__ */ c("a", { className: "aqmx-icon-button", href: t, target: "_blank", rel: "noopener noreferrer", "aria-label": i.openInNewTab, title: i.openInNewTab, "data-testid": "markdown-explorer-file-open", children: /* @__PURE__ */ c(Ko, {}) }),
1553
+ /* @__PURE__ */ c("a", { className: "aqmx-icon-button", href: n, download: e, "aria-label": i.download, title: i.download, "data-testid": "markdown-explorer-file-download", children: /* @__PURE__ */ c(Go, {}) })
1554
+ ] });
1555
+ };
1556
+ function Xo({
1557
+ title: e,
1558
+ titleId: t,
1559
+ ...n
1560
+ }, r) {
1561
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1562
+ xmlns: "http://www.w3.org/2000/svg",
1563
+ viewBox: "0 0 20 20",
1564
+ fill: "currentColor",
1565
+ "aria-hidden": "true",
1566
+ "data-slot": "icon",
1567
+ ref: r,
1568
+ "aria-labelledby": t
1569
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1570
+ id: t
1571
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1572
+ fillRule: "evenodd",
1573
+ d: "M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm4.75 6.75a.75.75 0 0 1 1.5 0v2.546l.943-1.048a.75.75 0 0 1 1.114 1.004l-2.25 2.5a.75.75 0 0 1-1.114 0l-2.25-2.5a.75.75 0 1 1 1.114-1.004l.943 1.048V8.75Z",
1574
+ clipRule: "evenodd"
1575
+ }));
1576
+ }
1577
+ const Yo = /* @__PURE__ */ y.forwardRef(Xo), Jo = Object.freeze({ className: "aqmx-document-stage" }), Qo = ({ document: e }) => {
1578
+ const { labels: t } = D();
1579
+ return /* @__PURE__ */ F("div", { className: "aqmx-document-file", "data-testid": "markdown-explorer-file-view", children: [
1580
+ /* @__PURE__ */ c(qe, { name: e.name, openUrl: e.url, downloadUrl: e.url, icon: /* @__PURE__ */ c(Yo, {}) }),
1581
+ /* @__PURE__ */ c(ve, { scrollerProps: Jo, children: /* @__PURE__ */ F("div", { className: "aqmx-callout", role: "note", "data-testid": "markdown-explorer-file-not-shown", children: [
1582
+ /* @__PURE__ */ c("p", { className: "aqmx-callout-body", children: t.fileNotShown }),
1583
+ /* @__PURE__ */ c("a", { className: "aqmx-callout-action", href: e.url, download: e.name, "data-testid": "markdown-explorer-file-not-shown-download", children: t.download })
1584
+ ] }) })
1585
+ ] });
1586
+ }, _e = "[data-aqmd-scroll-container], [data-aqmx-document-scroller]", ei = (e) => {
1587
+ const t = e.indexOf("#");
1588
+ return t === -1 ? "" : e.slice(t);
1589
+ }, ti = /(%[0-9A-Fa-f]{2})/u, ct = (e) => {
1590
+ if (!e.startsWith("#") || e.length === 1) return null;
1591
+ const t = new TextEncoder(), n = e.slice(1).split(ti).flatMap((r, o) => o % 2 === 1 ? [Number.parseInt(r.slice(1), 16)] : [...t.encode(r)]);
1592
+ return new TextDecoder("utf-8", { ignoreBOM: !0 }).decode(Uint8Array.from(n));
1593
+ }, Rn = (e) => `#${encodeURIComponent(e)}`, ni = (e) => {
1594
+ if (e === "#") return !0;
1595
+ const t = ct(e);
1596
+ return t !== null && t.replace(/[A-Z]/gu, (n) => n.toLowerCase()) === "top";
1597
+ }, Mn = (e, t) => {
1598
+ if (t === "") return null;
1599
+ for (const n of e.querySelectorAll("[id]"))
1600
+ if (n.id === t) return n;
1601
+ return null;
1602
+ }, ri = "http://www.w3.org/1999/xhtml", $t = (e, t) => {
1603
+ if (t === "") return null;
1604
+ const n = Mn(e, t);
1605
+ if (n !== null) return n;
1606
+ for (const r of e.querySelectorAll("a[name]"))
1607
+ if (r.localName === "a" && r.namespaceURI === ri && r.getAttribute("name") === t) return r;
1608
+ return null;
1609
+ }, On = (e, t) => {
1610
+ if (e === null || !t.startsWith("#")) return null;
1611
+ const n = $t(e, t.slice(1));
1612
+ if (n !== null) return n;
1613
+ const r = ct(t);
1614
+ return r === null ? null : $t(e, r);
1615
+ }, Ft = (e) => {
1616
+ const { body: t, documentElement: n } = e.ownerDocument;
1617
+ if (e === t) {
1618
+ const o = getComputedStyle(n);
1619
+ if (o.overflowX === "visible" && o.overflowY === "visible") return !1;
1620
+ }
1621
+ const { overflowY: r } = getComputedStyle(e);
1622
+ return r === "auto" || r === "scroll";
1623
+ }, oi = (e) => {
1624
+ const { body: t, documentElement: n } = e, r = getComputedStyle(n), o = r.overflowX === "visible" && r.overflowY === "visible" && t !== null ? getComputedStyle(t).overflowY : r.overflowY;
1625
+ return o !== "hidden" && o !== "clip";
1626
+ }, ii = (e, t) => {
1627
+ const n = t.closest(_e), r = n !== null && e.contains(n) ? n : e;
1628
+ if (r.scrollHeight > r.clientHeight && Ft(r)) return r;
1629
+ const o = e.getBoundingClientRect().height, { documentElement: i, scrollingElement: l } = e.ownerDocument;
1630
+ for (let u = e.parentElement; u !== null && u !== i; u = u.parentElement)
1631
+ if (Ft(u) && u.scrollHeight > u.clientHeight && u.clientHeight < o) return u;
1632
+ return l instanceof Element && oi(e.ownerDocument) && l.scrollHeight > l.clientHeight && l.clientHeight < o ? l : r;
1633
+ }, li = Object.freeze({
1634
+ scrollerOf: ii,
1635
+ reveal: (e) => {
1636
+ e.scrollIntoView(tt);
1637
+ }
1638
+ }), tt = Object.freeze({ block: "nearest", inline: "nearest", behavior: "instant" }), ai = (e, t) => {
1639
+ for (let n = t; n !== null && n !== e; n = n.parentElement) {
1640
+ const r = n.parentElement;
1641
+ if (r instanceof HTMLDetailsElement && n !== r.querySelector(":scope > summary") && (r.open = !0), n.getAttribute("hidden")?.toLowerCase() === "until-found") {
1642
+ if (n.dispatchEvent(new Event("beforematch", { bubbles: !0 })), !n.isConnected) return;
1643
+ n.removeAttribute("hidden");
1644
+ }
1645
+ }
1646
+ }, si = (e, t) => {
1647
+ if (t.getClientRects().length === 0) return;
1648
+ const n = e === e.ownerDocument.scrollingElement ? 0 : e.getBoundingClientRect().top + e.clientTop, { scrollMarginTop: r, scrollMarginBottom: o } = getComputedStyle(t), i = Number.parseFloat(r), l = t.getBoundingClientRect(), u = l.height + i + Number.parseFloat(o) > e.clientHeight;
1649
+ if (!u && Math.abs(l.top - i - n) < 1) {
1650
+ t.scrollIntoView(tt);
1651
+ return;
1652
+ }
1653
+ e.scrollBy({ top: u ? l.top - n - e.clientHeight : l.bottom - n + e.clientHeight, behavior: "instant" }), t.scrollIntoView(tt);
1654
+ }, ci = (e, t) => {
1655
+ const n = t.scrollerOf(e, e.querySelector(_e) ?? e);
1656
+ n.getClientRects().length !== 0 && (n.scrollTo({ top: 0, left: 0, behavior: "instant" }), t.reveal(n));
1657
+ }, qt = (e, t, n) => {
1658
+ if (e === null) return null;
1659
+ const r = On(e, t);
1660
+ return r === null ? (ni(t) && ci(e, n), null) : (ai(e, r), si(n.scrollerOf(e, r), r), n.reveal(r), r);
1661
+ };
1662
+ function di({
1663
+ title: e,
1664
+ titleId: t,
1665
+ ...n
1666
+ }, r) {
1667
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1668
+ xmlns: "http://www.w3.org/2000/svg",
1669
+ viewBox: "0 0 20 20",
1670
+ fill: "currentColor",
1671
+ "aria-hidden": "true",
1672
+ "data-slot": "icon",
1673
+ ref: r,
1674
+ "aria-labelledby": t
1675
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1676
+ id: t
1677
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1678
+ d: "M3.28 2.22a.75.75 0 0 0-1.06 1.06L5.44 6.5H2.75a.75.75 0 0 0 0 1.5h4.5A.75.75 0 0 0 8 7.25v-4.5a.75.75 0 0 0-1.5 0v2.69L3.28 2.22ZM13.5 2.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-2.69l3.22-3.22a.75.75 0 0 0-1.06-1.06L13.5 5.44V2.75ZM3.28 17.78l3.22-3.22v2.69a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.69l-3.22 3.22a.75.75 0 1 0 1.06 1.06ZM13.5 14.56l3.22 3.22a.75.75 0 1 0 1.06-1.06l-3.22-3.22h2.69a.75.75 0 0 0 0-1.5h-4.5a.75.75 0 0 0-.75.75v4.5a.75.75 0 0 0 1.5 0v-2.69Z"
1679
+ }));
1680
+ }
1681
+ const ui = /* @__PURE__ */ y.forwardRef(di);
1682
+ function fi({
1683
+ title: e,
1684
+ titleId: t,
1685
+ ...n
1686
+ }, r) {
1687
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1688
+ xmlns: "http://www.w3.org/2000/svg",
1689
+ viewBox: "0 0 20 20",
1690
+ fill: "currentColor",
1691
+ "aria-hidden": "true",
1692
+ "data-slot": "icon",
1693
+ ref: r,
1694
+ "aria-labelledby": t
1695
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1696
+ id: t
1697
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1698
+ d: "M6.75 8.25a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z"
1699
+ }), /* @__PURE__ */ y.createElement("path", {
1700
+ fillRule: "evenodd",
1701
+ d: "M9 2a7 7 0 1 0 4.391 12.452l3.329 3.328a.75.75 0 1 0 1.06-1.06l-3.328-3.329A7 7 0 0 0 9 2ZM3.5 9a5.5 5.5 0 1 1 11 0 5.5 5.5 0 0 1-11 0Z",
1702
+ clipRule: "evenodd"
1703
+ }));
1704
+ }
1705
+ const mi = /* @__PURE__ */ y.forwardRef(fi);
1706
+ function hi({
1707
+ title: e,
1708
+ titleId: t,
1709
+ ...n
1710
+ }, r) {
1711
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1712
+ xmlns: "http://www.w3.org/2000/svg",
1713
+ viewBox: "0 0 20 20",
1714
+ fill: "currentColor",
1715
+ "aria-hidden": "true",
1716
+ "data-slot": "icon",
1717
+ ref: r,
1718
+ "aria-labelledby": t
1719
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1720
+ id: t
1721
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1722
+ d: "M9 6a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0v-1.5h-1.5a.75.75 0 0 1 0-1.5h1.5v-1.5A.75.75 0 0 1 9 6Z"
1723
+ }), /* @__PURE__ */ y.createElement("path", {
1724
+ fillRule: "evenodd",
1725
+ d: "M2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Zm7-5.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z",
1726
+ clipRule: "evenodd"
1727
+ }));
1728
+ }
1729
+ const pi = /* @__PURE__ */ y.forwardRef(hi);
1730
+ function vi({
1731
+ title: e,
1732
+ titleId: t,
1733
+ ...n
1734
+ }, r) {
1735
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1736
+ xmlns: "http://www.w3.org/2000/svg",
1737
+ viewBox: "0 0 20 20",
1738
+ fill: "currentColor",
1739
+ "aria-hidden": "true",
1740
+ "data-slot": "icon",
1741
+ ref: r,
1742
+ "aria-labelledby": t
1743
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1744
+ id: t
1745
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1746
+ fillRule: "evenodd",
1747
+ d: "M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0l-2.97 2.97ZM12 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",
1748
+ clipRule: "evenodd"
1749
+ }));
1750
+ }
1751
+ const wi = /* @__PURE__ */ y.forwardRef(vi), nt = "data-aqmx-key-repeat", rt = Object.freeze({ [nt]: "allow" }), gi = `[${nt}="${rt[nt]}"]`, bi = () => {
1752
+ let e = null;
1753
+ return {
1754
+ onKeyDownCapture: (t) => {
1755
+ if (t.key === "Enter") {
1756
+ if (!t.repeat) {
1757
+ e = t.target instanceof Element ? t.target : null;
1758
+ return;
1759
+ }
1760
+ e !== null && t.target === e && e.closest(gi) !== null || (t.preventDefault(), t.stopPropagation());
1761
+ }
1762
+ },
1763
+ onKeyUpCapture: (t) => {
1764
+ t.key === "Enter" && (e = null);
1765
+ },
1766
+ onBlurCapture: (t) => {
1767
+ t.target === e && (e = null);
1768
+ }
1769
+ };
1770
+ }, Le = Object.freeze([1 / be ** 2, 1 / be, 1, be, be ** 2]), _t = Object.freeze({ mode: "fit" }), Ei = 1, Cn = Object.freeze({ className: "aqmx-document-canvas", "data-testid": "markdown-explorer-image-canvas" }), It = `[data-testid="${Cn["data-testid"]}"]`, yi = pe(null), xi = (e, t) => e.width > 0 && e.height > 0 && t.width - e.width <= Ei ? { base: e, scale: t.width / e.width } : t.width > 0 && t.height > 0 ? { base: t, scale: 1 } : null, Bt = (e, t, n) => {
1771
+ if (e.mode === "level") {
1772
+ const o = e.index + n;
1773
+ return o >= 0 && o < Le.length ? o : null;
1774
+ }
1775
+ if (t === null || !Number.isFinite(t) || t <= 0) return null;
1776
+ const r = n === 1 ? Le.findIndex((o) => o > t) : Le.findLastIndex((o) => o < t);
1777
+ return r === -1 ? null : r;
1778
+ }, zt = (e, t, n) => {
1779
+ if (e.mode === "level") {
1780
+ const o = Bt(e, null, n);
1781
+ return o === null ? null : { mode: "level", index: o, base: e.base };
1782
+ }
1783
+ if (t === null) return null;
1784
+ const r = Bt(e, t.scale, n);
1785
+ return r === null ? null : { mode: "level", index: r, base: t.base };
1786
+ }, Si = (e, t) => {
1787
+ if (e <= 0 || t <= 0) return 0;
1788
+ const n = Math.trunc(Math.log(t / e) / Math.log(be));
1789
+ return n === 0 ? 0 : n;
1790
+ }, jt = (e) => {
1791
+ const t = e[0], n = e[1];
1792
+ return e.length !== 2 || t === void 0 || n === void 0 ? null : { distance: Math.hypot(n.clientX - t.clientX, n.clientY - t.clientY), middle: { x: (t.clientX + n.clientX) / 2, y: (t.clientY + n.clientY) / 2 } };
1793
+ }, ki = (e) => {
1794
+ const t = Le[e];
1795
+ if (t === void 0) throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);
1796
+ return t;
1797
+ }, Ht = (e, t, n) => e !== null && e.width === t && e.height === n ? e : { width: t, height: n }, Ti = ({ document: e }) => {
1798
+ const { labels: t } = D(), n = ne(yi), [r] = B(() => n === null ? null : n.read(e.url)), [o, i] = B(r === null ? _t : r.zoom), [l, u] = B(r === null ? null : r.reported), [m, f] = B(null), d = _(null), h = P((v) => {
1799
+ const { naturalWidth: a, naturalHeight: s } = v;
1800
+ u((w) => Ht(w, a, s));
1801
+ }, []), g = P(
1802
+ (v) => {
1803
+ d.current = v, !(v === null || !v.complete) && (v.naturalWidth > 0 || v.naturalHeight > 0 ? h(v) : v.decode().then(
1804
+ () => h(v),
1805
+ () => {
1806
+ }
1807
+ ));
1808
+ },
1809
+ [h]
1810
+ );
1811
+ te(() => {
1812
+ n !== null && l !== null && n.save(e.url, { zoom: o, reported: l });
1813
+ }, [n, e.url, o, l]), H(() => {
1814
+ const v = d.current;
1815
+ if (v === null || l === null || o.mode !== "fit") return;
1816
+ const a = () => f((w) => Ht(w, v.clientWidth, v.clientHeight));
1817
+ if (a(), typeof ResizeObserver > "u") return;
1818
+ const s = new ResizeObserver(a);
1819
+ return s.observe(v), () => s.disconnect();
1820
+ }, [l, o.mode]);
1821
+ const b = l === null || m === null ? null : xi(l, m), M = zt(o, b, -1), R = zt(o, b, 1), S = o.mode === "level" ? ki(o.index) : null, A = _({ zoomIn: R, zoomOut: M });
1822
+ H(() => {
1823
+ A.current = { zoomIn: R, zoomOut: M };
1824
+ });
1825
+ const L = _(null);
1826
+ H(() => {
1827
+ const v = L.current, a = d.current?.closest(It);
1828
+ L.current = null, !(v === null || a === null || a === void 0) && (a.scrollLeft = v.across * a.scrollWidth - v.x, a.scrollTop = v.down * a.scrollHeight - v.y);
1829
+ }, [o]), te(() => {
1830
+ const v = d.current?.closest(It);
1831
+ if (v == null) return;
1832
+ let a = null;
1833
+ const s = (C) => {
1834
+ const N = jt(C.touches);
1835
+ a = N === null ? null : { distance: N.distance, steps: 0 };
1836
+ }, w = (C) => {
1837
+ const N = jt(C.touches);
1838
+ if (a === null || N === null) return;
1839
+ C.preventDefault();
1840
+ const q = Si(a.distance, N.distance);
1841
+ if (q === a.steps) return;
1842
+ const W = q > a.steps ? 1 : -1, z = W === 1 ? A.current.zoomIn : A.current.zoomOut;
1843
+ if (z === null) return;
1844
+ a.steps += W;
1845
+ const j = v.getBoundingClientRect(), Y = N.middle.x - j.left, V = N.middle.y - j.top;
1846
+ L.current = v.scrollWidth > 0 && v.scrollHeight > 0 ? { x: Y, y: V, across: (v.scrollLeft + Y) / v.scrollWidth, down: (v.scrollTop + V) / v.scrollHeight } : null, i(z);
1847
+ }, T = (C) => {
1848
+ C.touches.length < 2 && (a = null);
1849
+ };
1850
+ return v.addEventListener("touchstart", s, { passive: !0 }), v.addEventListener("touchmove", w, { passive: !1 }), v.addEventListener("touchend", T, { passive: !0 }), v.addEventListener("touchcancel", T, { passive: !0 }), () => {
1851
+ v.removeEventListener("touchstart", s), v.removeEventListener("touchmove", w), v.removeEventListener("touchend", T), v.removeEventListener("touchcancel", T);
1852
+ };
1853
+ }, []);
1854
+ const E = o.mode === "level" && S !== null ? { width: `${o.base.width * S}px`, height: `${o.base.height * S}px` } : void 0;
1855
+ return /* @__PURE__ */ F("div", { className: "aqmx-document-file", "data-testid": "markdown-explorer-image-view", children: [
1856
+ /* @__PURE__ */ F(qe, { name: e.name, openUrl: e.url, downloadUrl: e.url, icon: /* @__PURE__ */ c(wi, {}), children: [
1857
+ /* @__PURE__ */ c(
1858
+ "button",
1859
+ {
1860
+ type: "button",
1861
+ className: "aqmx-icon-button",
1862
+ "aria-label": t.imageZoomOut,
1863
+ title: t.imageZoomOut,
1864
+ "aria-disabled": M === null,
1865
+ onClick: () => {
1866
+ M !== null && i(M);
1867
+ },
1868
+ ...rt,
1869
+ children: /* @__PURE__ */ c(mi, {})
1870
+ }
1871
+ ),
1872
+ /* @__PURE__ */ c("output", { className: "aqmx-document-level", "aria-live": "polite", "data-testid": "markdown-explorer-image-level", children: S === null ? t.imageFitLevel : t.imageZoomLevel(Math.round(S * 100)) }),
1873
+ /* @__PURE__ */ c(
1874
+ "button",
1875
+ {
1876
+ type: "button",
1877
+ className: "aqmx-icon-button",
1878
+ "aria-label": t.imageZoomIn,
1879
+ title: t.imageZoomIn,
1880
+ "aria-disabled": R === null,
1881
+ onClick: () => {
1882
+ R !== null && i(R);
1883
+ },
1884
+ ...rt,
1885
+ children: /* @__PURE__ */ c(pi, {})
1886
+ }
1887
+ ),
1888
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-icon-button", "aria-label": t.imageFit, title: t.imageFit, "aria-pressed": o.mode === "fit", onClick: () => i(_t), children: /* @__PURE__ */ c(ui, {}) })
1889
+ ] }),
1890
+ /* @__PURE__ */ c(ve, { scrollerProps: Cn, children: /* @__PURE__ */ c("img", { ref: g, className: "aqmx-document-image", src: e.url, alt: e.name, "data-aqmx-image-mode": o.mode, style: E, onLoad: (v) => h(v.currentTarget), "data-testid": "markdown-explorer-image" }) })
1891
+ ] });
1892
+ }, Ln = pe(null), Ie = pe(void 0), An = pe(null), Be = () => {
1893
+ const e = ne(Ln);
1894
+ if (e === null) throw new Error("[markdown-explorer] document links must be rendered inside a document pane");
1895
+ return e;
1896
+ }, Ri = () => {
1897
+ const e = ne(An);
1898
+ if (e === null) throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");
1899
+ return e;
1900
+ }, ze = (e, t, n, r) => t.kind === "panel" ? ye(e, { view: "tree", source: n, doc: r }) : t.view === "single" ? ye(e, { view: "single", source: n, doc: r, overrides: t.overrides, embed: t.embed }) : ye(e, { view: "tree", source: n, doc: r, overrides: t.overrides }), Mi = ({ children: e }) => {
1901
+ const { config: t } = D(), n = Be(), r = lt(), o = r.kind === "location" ? r.location.source : void 0, i = $e(ze(t, n.navigation, o, n.currentPath));
1902
+ return /* @__PURE__ */ c(Ie, { value: o, children: /* @__PURE__ */ c(An, { value: i, children: e }) });
1903
+ }, Oi = 'a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])', Ci = (e) => {
1904
+ const t = e instanceof Element ? e.closest(Oi) : null;
1905
+ return t === null ? null : t.getAttribute("data-doc-path");
1906
+ }, je = (e) => !e.defaultPrevented && e.button === 0 && !e.metaKey && !e.ctrlKey && !e.shiftKey && !e.altKey, Li = ({ to: e, docPath: t, fragment: n, exists: r, className: o, attributes: i, onDocumentLink: l, scope: u, children: m }) => {
1907
+ const f = $e(e);
1908
+ return /* @__PURE__ */ c("a", { ...i, href: f, className: o, "data-link-kind": "doc", "data-doc-path": t, "data-doc-exists": r, onClick: (h) => {
1909
+ if (je(h)) {
1910
+ if (h.preventDefault(), t === u.currentPath && n !== "") {
1911
+ u.scrollWithin(n);
1912
+ return;
1913
+ }
1914
+ l(t, n);
1915
+ }
1916
+ }, children: m });
1917
+ }, Ai = ({ href: e, docPath: t, docExists: n, className: r, attributes: o, children: i }) => {
1918
+ const { config: l } = D(), u = Be(), m = ne(Ie), f = ei(e), { navigation: d } = u, h = `${ze(l, d, m, t)}${f}`, g = n === !1 ? "false" : void 0;
1919
+ return d.kind === "page" ? /* @__PURE__ */ c(Co, { ...o, to: h, navigation: "follow-link", className: r, "data-link-kind": "doc", "data-doc-path": t, "data-doc-exists": g, children: i }) : /* @__PURE__ */ c(Li, { to: h, docPath: t, fragment: f, exists: g, className: r, attributes: o, onDocumentLink: d.onDocumentLink, scope: u, children: i });
1920
+ }, Ni = ({ className: e, attributes: t, children: n }) => {
1921
+ const { labels: r } = D();
1922
+ return (
1923
+ /* @__PURE__ */ F("a", { ...t, className: e === void 0 ? "aqmx-document-inert-link" : `${e} aqmx-document-inert-link`, title: r.inertLink, "data-link-kind": "doc", "data-doc-exists": "false", children: [
1924
+ n,
1925
+ /* @__PURE__ */ F("span", { className: "aqmx-sr-only", children: [
1926
+ " (",
1927
+ r.inertLink,
1928
+ ")"
1929
+ ] })
1930
+ ] })
1931
+ );
1932
+ }, Di = ({ href: e, className: t, attributes: n, scope: r, children: o }) => {
1933
+ const { config: i } = D(), l = ne(Ie), u = $e(`${ze(i, r.navigation, l, r.currentPath)}${e}`);
1934
+ return /* @__PURE__ */ c("a", { ...n, href: u, className: t, onClick: (f) => {
1935
+ je(f) && (f.preventDefault(), r.scrollWithin(e));
1936
+ }, children: o });
1937
+ }, Pi = ({ href: e, className: t, attributes: n, children: r }) => {
1938
+ const o = Be();
1939
+ return o.navigation.kind === "page" ? /* @__PURE__ */ c("a", { ...n, href: e, className: t, onClick: (l) => {
1940
+ if (!je(l)) return;
1941
+ const u = l.currentTarget;
1942
+ e === "#" ? o.followEmptyFragment(l.nativeEvent) : u.href === u.ownerDocument.URL && o.followSameUrlJump(e, l.nativeEvent);
1943
+ }, children: r }) : /* @__PURE__ */ c(Di, { href: e, className: t, attributes: n, scope: o, children: r });
1944
+ }, $i = ({ href: e, kind: t, docPath: n, docExists: r, className: o, attributes: i, children: l }) => t === "doc" ? n === void 0 || !tr(n) ? /* @__PURE__ */ c(Ni, { className: o, attributes: i, children: l }) : /* @__PURE__ */ c(Ai, { href: e, docPath: n, docExists: r, className: o, attributes: i, children: l }) : e.startsWith("#") ? /* @__PURE__ */ c(Pi, { href: e, className: o, attributes: i, children: l }) : /* @__PURE__ */ c("a", { ...i, href: e, className: o, children: l }), Fi = () => {
1945
+ const { config: e } = D(), t = Be(), n = ne(Ie), r = Fe();
1946
+ return P(
1947
+ (o, i) => {
1948
+ if (!je(i)) return !0;
1949
+ i.preventDefault();
1950
+ const l = Rn(o.id), { navigation: u } = t;
1951
+ return u.kind === "panel" || ct(i.currentTarget.ownerDocument.location.hash) === o.id ? (t.scrollWithin(l), !0) : (r(`${ze(e, u, n, t.currentPath)}${l}`, "follow-link"), !0);
1952
+ },
1953
+ [e, t, n, r]
1954
+ );
1955
+ }, qi = () => {
1956
+ const e = Ri();
1957
+ return P((t) => `${e}${Rn(t.id)}`, [e]);
1958
+ };
1959
+ function _i({
1960
+ title: e,
1961
+ titleId: t,
1962
+ ...n
1963
+ }, r) {
1964
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1965
+ xmlns: "http://www.w3.org/2000/svg",
1966
+ viewBox: "0 0 20 20",
1967
+ fill: "currentColor",
1968
+ "aria-hidden": "true",
1969
+ "data-slot": "icon",
1970
+ ref: r,
1971
+ "aria-labelledby": t
1972
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1973
+ id: t
1974
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1975
+ d: "M3 3.5A1.5 1.5 0 0 1 4.5 2h6.879a1.5 1.5 0 0 1 1.06.44l4.122 4.12A1.5 1.5 0 0 1 17 7.622V16.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 16.5v-13Z"
1976
+ }));
1977
+ }
1978
+ const Ii = /* @__PURE__ */ y.forwardRef(_i);
1979
+ function Bi({
1980
+ title: e,
1981
+ titleId: t,
1982
+ ...n
1983
+ }, r) {
1984
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
1985
+ xmlns: "http://www.w3.org/2000/svg",
1986
+ viewBox: "0 0 20 20",
1987
+ fill: "currentColor",
1988
+ "aria-hidden": "true",
1989
+ "data-slot": "icon",
1990
+ ref: r,
1991
+ "aria-labelledby": t
1992
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
1993
+ id: t
1994
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
1995
+ fillRule: "evenodd",
1996
+ d: "M1 4.75C1 3.784 1.784 3 2.75 3h14.5c.966 0 1.75.784 1.75 1.75v10.515a1.75 1.75 0 0 1-1.75 1.75h-1.5c-.078 0-.155-.005-.23-.015H4.48c-.075.01-.152.015-.23.015h-1.5A1.75 1.75 0 0 1 1 15.265V4.75Zm16.5 7.385V11.01a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25Zm0 2.005a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .108.069.2.165.235h1.585a.25.25 0 0 0 .25-.25v-1.11Zm-15 1.11v-1.11a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.164.235H2.75a.25.25 0 0 1-.25-.25Zm2-4.24v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V11.01a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25Zm13-2.005V7.88a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25ZM4.25 7.63a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V7.88a.25.25 0 0 1 .25-.25h1.5Zm0-3.13a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5Zm11.5 1.625a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5Zm-9 3.125a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",
1997
+ clipRule: "evenodd"
1998
+ }));
1999
+ }
2000
+ const zi = /* @__PURE__ */ y.forwardRef(Bi);
2001
+ function ji({
2002
+ title: e,
2003
+ titleId: t,
2004
+ ...n
2005
+ }, r) {
2006
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
2007
+ xmlns: "http://www.w3.org/2000/svg",
2008
+ viewBox: "0 0 20 20",
2009
+ fill: "currentColor",
2010
+ "aria-hidden": "true",
2011
+ "data-slot": "icon",
2012
+ ref: r,
2013
+ "aria-labelledby": t
2014
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
2015
+ id: t
2016
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
2017
+ fillRule: "evenodd",
2018
+ d: "M17.721 1.599a.75.75 0 0 1 .279.583v11.29a2.25 2.25 0 0 1-1.774 2.2l-2.041.44a2.216 2.216 0 0 1-.938-4.332l2.662-.577a.75.75 0 0 0 .591-.733V6.112l-8 1.73v7.684a2.25 2.25 0 0 1-1.774 2.2l-2.042.44a2.216 2.216 0 1 1-.935-4.331l2.659-.573A.75.75 0 0 0 7 12.529V4.236a.75.75 0 0 1 .591-.733l9.5-2.054a.75.75 0 0 1 .63.15Z",
2019
+ clipRule: "evenodd"
2020
+ }));
2021
+ }
2022
+ const Hi = /* @__PURE__ */ y.forwardRef(ji), Vi = Object.freeze({ className: "aqmx-document-stage" }), Ui = () => () => {
2023
+ }, Zi = () => navigator.pdfViewerEnabled !== !1, Gi = () => null, Wi = ({ document: e }) => {
2024
+ const { labels: t } = D(), n = ee(Ui, Zi, Gi);
2025
+ return n === null ? null : n ? /* @__PURE__ */ c("iframe", { className: "aqmx-document-frame", src: e.url, title: e.name, "data-testid": "markdown-explorer-media-player" }) : /* @__PURE__ */ F("div", { className: "aqmx-callout", role: "note", "data-testid": "markdown-explorer-pdf-not-shown", children: [
2026
+ /* @__PURE__ */ c("p", { className: "aqmx-callout-body", children: t.pdfNotShown }),
2027
+ /* @__PURE__ */ F("div", { className: "aqmx-callout-actions", children: [
2028
+ /* @__PURE__ */ c("a", { className: "aqmx-callout-action", href: e.url, target: "_blank", rel: "noopener noreferrer", "data-testid": "markdown-explorer-pdf-not-shown-open", children: t.openInNewTab }),
2029
+ /* @__PURE__ */ c("a", { className: "aqmx-callout-action", href: e.url, download: e.name, "data-testid": "markdown-explorer-pdf-not-shown-download", children: t.download })
2030
+ ] })
2031
+ ] });
2032
+ }, Ki = (e) => {
2033
+ switch (e) {
2034
+ case "video":
2035
+ return /* @__PURE__ */ c(zi, {});
2036
+ case "audio":
2037
+ return /* @__PURE__ */ c(Hi, {});
2038
+ case "pdf":
2039
+ return /* @__PURE__ */ c(Ii, {});
2040
+ default: {
2041
+ const t = e;
2042
+ throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`);
2043
+ }
2044
+ }
2045
+ }, Xi = ({ document: e }) => {
2046
+ const { labels: t } = D();
2047
+ switch (e.mediaType) {
2048
+ case "video":
2049
+ return (
2050
+ /* @__PURE__ */ c("video", { className: "aqmx-document-video", src: e.url, controls: !0, preload: "metadata", "aria-label": e.name, "data-testid": "markdown-explorer-media-player", children: t.mediaUnsupported })
2051
+ );
2052
+ case "audio":
2053
+ return (
2054
+ /* @__PURE__ */ c("audio", { className: "aqmx-document-audio", src: e.url, controls: !0, preload: "metadata", "aria-label": e.name, "data-testid": "markdown-explorer-media-player", children: t.mediaUnsupported })
2055
+ );
2056
+ case "pdf":
2057
+ return /* @__PURE__ */ c(Wi, { document: e });
2058
+ default: {
2059
+ const n = e.mediaType;
2060
+ throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`);
2061
+ }
2062
+ }
2063
+ }, Yi = ({ document: e }) => /* @__PURE__ */ F("div", { className: "aqmx-document-file", "data-testid": "markdown-explorer-media-view", "data-aqmx-media-type": e.mediaType, children: [
2064
+ /* @__PURE__ */ c(qe, { name: e.name, openUrl: e.url, downloadUrl: e.url, icon: Ki(e.mediaType) }),
2065
+ /* @__PURE__ */ c(ve, { scrollerProps: Vi, children: /* @__PURE__ */ c(Xi, { document: e }) })
2066
+ ] }), Ji = (e) => ({
2067
+ loading: e.viewerLoading,
2068
+ errorPrefix: e.viewerErrorPrefix,
2069
+ styleTitle: e.viewerStyleTitle,
2070
+ selectStyleAria: e.viewerSelectStyle,
2071
+ pinStyleAria: e.viewerPinStyle,
2072
+ unpinStyleAria: e.viewerUnpinStyle,
2073
+ defaultErrorTitle: e.viewerErrorTitle,
2074
+ missingImage: e.viewerMissingImage,
2075
+ openTocAria: e.viewerOpenToc,
2076
+ tocTitle: e.viewerTocTitle,
2077
+ pinTocAria: e.viewerPinToc,
2078
+ unpinTocAria: e.viewerUnpinToc,
2079
+ selectAlignAria: e.viewerSelectAlign,
2080
+ alignTitle: e.viewerAlignTitle,
2081
+ pinAlignAria: e.viewerPinAlign,
2082
+ unpinAlignAria: e.viewerUnpinAlign,
2083
+ alignLeft: e.viewerAlignLeft,
2084
+ alignCenter: e.viewerAlignCenter,
2085
+ alignRight: e.viewerAlignRight,
2086
+ mermaidInteractionMode: e.viewerMermaidInteractionMode,
2087
+ mermaidInteractionModeTouch: e.viewerMermaidInteractionModeTouch,
2088
+ mermaidModeNone: e.viewerMermaidModeNone,
2089
+ mermaidModeZoom: e.viewerMermaidModeZoom,
2090
+ mermaidModePan: e.viewerMermaidModePan,
2091
+ mermaidModePanShift: e.viewerMermaidModePanShift,
2092
+ mermaidModeBoth: e.viewerMermaidModeBoth,
2093
+ mermaidModeBothShift: e.viewerMermaidModeBothShift,
2094
+ mermaidModeNoneTouch: e.viewerMermaidModeNoneTouch,
2095
+ mermaidModeZoomTouch: e.viewerMermaidModeZoomTouch,
2096
+ mermaidModePanTouch: e.viewerMermaidModePanTouch,
2097
+ mermaidModeBothTouch: e.viewerMermaidModeBothTouch,
2098
+ mermaidZoomIn: e.viewerMermaidZoomIn,
2099
+ mermaidZoomOut: e.viewerMermaidZoomOut,
2100
+ mermaidResetView: e.viewerMermaidResetView,
2101
+ mermaidPanUp: e.viewerMermaidPanUp,
2102
+ mermaidPanDown: e.viewerMermaidPanDown,
2103
+ mermaidPanLeft: e.viewerMermaidPanLeft,
2104
+ mermaidPanRight: e.viewerMermaidPanRight,
2105
+ mermaidDiagram: e.viewerMermaidDiagram,
2106
+ mermaidRetry: e.viewerMermaidRetry,
2107
+ embeddedVideo: e.viewerEmbeddedVideo,
2108
+ embeddedPost: e.viewerEmbeddedPost,
2109
+ embeddedFrame: e.viewerEmbeddedFrame
2110
+ }), Nn = (e, t, n) => {
2111
+ if (t !== void 0) return t;
2112
+ if (n !== void 0) return n;
2113
+ const [r] = e.documentStyles;
2114
+ if (r === void 0) throw new Error("[markdown-explorer] the configuration has no document style");
2115
+ return r.name;
2116
+ }, Dn = (e, t) => e !== void 0 ? e : t !== void 0 ? t : yr, Qi = Object.freeze({ kind: "empty" }), dt = Object.freeze(["l1", "l2", "l3", "l4", "l5", "l6", "l7", "l8"]), el = (e, t, n) => {
2117
+ if (t.view === "multi" || t.overrides[n] === void 0) return null;
2118
+ const r = n === "style" ? { align: t.overrides.align } : { style: t.overrides.style };
2119
+ return ye(e, { ...t, overrides: r });
2120
+ }, xe = ({ kind: e, view: t, label: n, stale: r, busy: o, frameRef: i, intent: l, children: u }) => {
2121
+ const m = ne(he);
2122
+ return (
2123
+ /* @__PURE__ */ F("section", { ref: i, role: "region", "aria-label": n, "aria-busy": o, "data-testid": "markdown-explorer-document", "data-aqmx-document-kind": e, "data-aqmx-document-view": t, "data-aqmx-document-flow": m, className: "aqmx-document", ...l, children: [
2124
+ r ? /* @__PURE__ */ c("div", { className: "aqmx-progress", "aria-hidden": "true", "data-testid": "markdown-explorer-document-progress" }) : null,
2125
+ u
2126
+ ] })
2127
+ );
2128
+ }, tl = ({ absence: e, announces: t, announceFailure: n }) => {
2129
+ const { labels: r, announcer: o } = D(), i = e.kind === "no-readme" ? e.folder : null, l = e.kind === "failure" ? e.folder : null, u = e.kind === "failure" ? e.failure : null;
2130
+ switch (te(() => {
2131
+ t && i !== null && o.announce(r.folderReadmeMissing(se(i)));
2132
+ }, [t, i, o, r]), te(() => {
2133
+ l !== null && u !== null && n(r.documentFailed(se(l), ae(r, u.reason)));
2134
+ }, [l, u, n, r]), e.kind) {
2135
+ case "empty":
2136
+ return /* @__PURE__ */ c(xe, { kind: "empty", label: r.documentRegion, stale: !1, busy: !1, children: /* @__PURE__ */ c("div", { className: "aqmx-empty", "data-testid": "markdown-explorer-document-empty", children: /* @__PURE__ */ c("p", { className: "aqmx-empty-title", children: r.documentEmpty }) }) });
2137
+ case "loading":
2138
+ return /* @__PURE__ */ c(ut, { label: r.documentRegion });
2139
+ case "no-readme":
2140
+ return /* @__PURE__ */ c(xe, { kind: "empty", label: r.documentRegion, stale: !1, busy: !1, children: /* @__PURE__ */ c("div", { className: "aqmx-empty", "data-testid": "markdown-explorer-folder-empty", children: /* @__PURE__ */ c("p", { className: "aqmx-empty-title", children: r.folderReadmeMissing(se(e.folder)) }) }) });
2141
+ case "failure":
2142
+ return /* @__PURE__ */ c(xe, { kind: "failure", label: r.documentRegion, stale: !1, busy: !1, children: /* @__PURE__ */ c(ve, { scrollerProps: ft, children: /* @__PURE__ */ c(me, { failure: e.failure, alert: !1, onRetry: e.onRetry, testId: "markdown-explorer-folder-failure" }) }) });
2143
+ }
2144
+ }, ut = ({ label: e }) => {
2145
+ const { labels: t } = D();
2146
+ return /* @__PURE__ */ F(xe, { kind: "loading", label: e, stale: !1, busy: !0, children: [
2147
+ /* @__PURE__ */ c("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-document-skeleton", children: dt.map((n) => /* @__PURE__ */ c("span", {}, n)) }),
2148
+ /* @__PURE__ */ c("p", { className: "aqmx-sr-only", children: t.documentLoading })
2149
+ ] });
2150
+ }, Vt = Object.freeze(["wheel", "touchstart", "pointerdown", "keydown"]), nl = ({ path: e, document: t, viewer: n, editing: r }) => {
2151
+ const { reportMathDiagnostics: o, edits: i } = D(), l = G(() => ({ htmlContent: t.htmlContent, headings: [...t.headings] }), [t]), u = Fi(), m = qi(), f = G(() => o === void 0 ? void 0 : (a) => o(e, a), [o, e]), d = _(null), { editable: h, doubleClick: g, region: b, paneScroll: M, stale: R } = r;
2152
+ H(() => {
2153
+ if (h)
2154
+ return i.bindView(e, {
2155
+ anchor: () => {
2156
+ const a = d.current, s = b(), w = a === null ? null : a.querySelector(_e);
2157
+ return a === null || s === null || w === null ? null : xo(a, M.scrollerOf(s, w));
2158
+ }
2159
+ });
2160
+ }, [i, e, h, b, M]);
2161
+ const S = (a) => {
2162
+ const s = d.current, { target: w } = a;
2163
+ !g || s === null || !(w instanceof Element) || !Eo(w) || (a.stopPropagation(), i.start(e, yo(w, s, s.ownerDocument.getSelection())));
2164
+ }, A = _(null), L = _(R);
2165
+ H(() => {
2166
+ L.current = R;
2167
+ });
2168
+ const E = le((a) => {
2169
+ const s = d.current, w = b(), T = s === null ? null : Mo(s, a.line);
2170
+ if (w === null || T === null) return !1;
2171
+ const C = M.scrollerOf(w, T);
2172
+ return C.scrollTop += Oo(T, a.line) - a.clientTop, !0;
2173
+ }), v = le((a) => {
2174
+ const s = b();
2175
+ if (s === null) return;
2176
+ const w = () => {
2177
+ for (const C of Vt) s.removeEventListener(C, T, !0);
2178
+ A.current?.release === w && (A.current = null);
2179
+ }, T = () => w();
2180
+ for (const C of Vt) s.addEventListener(C, T, { capture: !0, passive: !0 });
2181
+ A.current = { point: a, release: w };
2182
+ });
2183
+ return H(() => {
2184
+ const a = i.takeReturn(e);
2185
+ if (a !== null)
2186
+ return queueMicrotask(() => {
2187
+ E(a) && L.current && v(a);
2188
+ }), () => A.current?.release();
2189
+ }, [i, e]), H(() => {
2190
+ const a = A.current;
2191
+ a === null || R || (a.release(), E(a.point));
2192
+ }, [t, R]),
2193
+ /* @__PURE__ */ c("div", { ref: d, className: "aqmx-document-viewer", onDoubleClick: S, children: /* @__PURE__ */ c(an, { ...n, onHeadingSelect: u, headingHref: m, onMathDiagnostics: f, parseResult: l, content: null }) });
2194
+ }, Pn = ({ document: e, viewer: t }) => {
2195
+ const { labels: n } = D();
2196
+ return /* @__PURE__ */ F(Pe, { children: [
2197
+ /* @__PURE__ */ c(qe, { name: e.name, openUrl: nr(e.url), downloadUrl: e.url, icon: /* @__PURE__ */ c(uo, {}), children: e.truncated ? null : /* @__PURE__ */ c(Vo, { text: e.text }) }),
2198
+ e.truncated ? /* @__PURE__ */ c("p", { className: "aqmx-callout aqmx-document-notice", role: "note", "data-testid": "markdown-explorer-text-truncated", children: n.textTruncated }) : null,
2199
+ /* @__PURE__ */ c("div", { className: "aqmx-document-viewer", children: /* @__PURE__ */ c(an, { ...t, parseResult: null, content: e.text }) })
2200
+ ] });
2201
+ }, rl = ({ path: e, name: t, viewer: n }) => {
2202
+ const { data: r, documents: o, announcer: i, labels: l } = D(), u = P(() => o.answerStampOf(e), [o, e]), m = ee(o.subscribe, u, u), [f, d] = B(0), h = G(() => ({ path: e, stamp: m, attempt: f }), [e, m, f]), [g, b] = B(null), M = le((S) => {
2203
+ b(S), S.kind === "failure" && i.announce(l.documentFailed(t, ae(l, S.failure.reason)));
2204
+ });
2205
+ te(() => {
2206
+ const S = new AbortController();
2207
+ return r.text(h.path, S.signal).then((A) => {
2208
+ "kind" in A && M(A);
2209
+ }), () => S.abort();
2210
+ }, [r, h]);
2211
+ const R = P(() => d((S) => S + 1), []);
2212
+ return g === null ? /* @__PURE__ */ F(Pe, { children: [
2213
+ /* @__PURE__ */ c("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-markup-skeleton", children: dt.map((S) => /* @__PURE__ */ c("span", {}, S)) }),
2214
+ /* @__PURE__ */ c("p", { className: "aqmx-sr-only", children: l.markupLoading })
2215
+ ] }) : g.kind === "failure" ? /* @__PURE__ */ c(ve, { scrollerProps: ft, children: /* @__PURE__ */ c(me, { failure: g.failure, alert: !1, onRetry: R, testId: "markdown-explorer-markup-failure" }) }) : /* @__PURE__ */ c(Pn, { document: g, viewer: n });
2216
+ }, ft = Object.freeze({ className: "aqmx-document-failure", "data-aqmx-document-scroller": "" }), ol = Object.freeze({ reason: "failed" }), il = (e) => /* @__PURE__ */ c(
2217
+ ho,
2218
+ {
2219
+ fallback: (t) => /* @__PURE__ */ c("div", { className: "aqmx-edit-message", children: /* @__PURE__ */ c(me, { failure: ol, alert: !1, onRetry: t, testId: "markdown-explorer-edit-load-failure" }) }),
2220
+ children: /* @__PURE__ */ c(
2221
+ ke,
2222
+ {
2223
+ fallback: /* @__PURE__ */ c("div", { className: "aqmx-skeleton", "aria-hidden": "true", "data-testid": "markdown-explorer-edit-skeleton", children: dt.map((t) => /* @__PURE__ */ c("span", {}, t)) }),
2224
+ children: /* @__PURE__ */ c(mo, { ...e })
2225
+ }
2226
+ )
2227
+ }
2228
+ ), ll = ({ path: e, document: t, view: n, viewer: r, onRetry: o, editing: i }) => {
2229
+ switch (t.kind) {
2230
+ case "markdown": {
2231
+ const { session: l, layout: u, region: m, paneScroll: f, stale: d } = i;
2232
+ if (n === "edit" && l !== void 0) return /* @__PURE__ */ c(il, { path: e, name: t.name, session: l, layout: u, viewer: r, region: m, paneScroll: f });
2233
+ if (n === "markup") return /* @__PURE__ */ c(rl, { path: e, name: t.name, viewer: r });
2234
+ const h = t.edit !== null && (t.edit.kind === "inline" || t.edit.kind === "draft");
2235
+ return /* @__PURE__ */ c(nl, { path: e, document: t, viewer: r, editing: { editable: h, doubleClick: h && u === "fill", region: m, paneScroll: f, stale: d } });
2236
+ }
2237
+ case "text":
2238
+ return /* @__PURE__ */ c(Pn, { document: t, viewer: r });
2239
+ case "image":
2240
+ return /* @__PURE__ */ c(Ti, { document: t });
2241
+ case "media":
2242
+ return /* @__PURE__ */ c(Yi, { document: t });
2243
+ case "file":
2244
+ return /* @__PURE__ */ c(Qo, { document: t });
2245
+ case "failure":
2246
+ return /* @__PURE__ */ c(ve, { scrollerProps: ft, children: /* @__PURE__ */ c(me, { failure: t.failure, alert: !1, onRetry: o, testId: "markdown-explorer-document-failure" }) });
2247
+ default: {
2248
+ const l = t;
2249
+ throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(l)}`);
2250
+ }
2251
+ }
2252
+ }, al = 'a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])', sl = (e, t, n) => {
2253
+ const [r] = t.kind === "markdown" ? t.headings : [], o = [n === null ? null : On(e, n), r === void 0 ? null : Mn(e, r.id), e.querySelector(_e), e.querySelector(al)];
2254
+ for (const i of o)
2255
+ if (i instanceof HTMLElement && xn(i)) return i;
2256
+ return null;
2257
+ }, Ut = (e, t, n) => {
2258
+ const { activeElement: r, body: o } = e.ownerDocument, i = r === null || r === o;
2259
+ t instanceof HTMLElement && n && (i || e.contains(r)) && xn(t);
2260
+ }, cl = (e) => {
2261
+ const t = _(!1);
2262
+ return H(() => {
2263
+ const n = e.current;
2264
+ if (n === null) throw new Error("[markdown-explorer] the document region is not mounted");
2265
+ const r = n.ownerDocument, o = r.defaultView;
2266
+ if (o === null) throw new Error("[markdown-explorer] the document region's document has no window");
2267
+ let i = !1, l;
2268
+ const u = (g) => {
2269
+ i = !(g.target instanceof Node && n.contains(g.target)), i && !n.contains(r.activeElement) && (t.current = !1), clearTimeout(l), l = setTimeout(() => {
2270
+ i = !1;
2271
+ }, 0);
2272
+ }, m = (g) => {
2273
+ t.current = g.target instanceof Node && n.contains(g.target);
2274
+ }, f = (g) => {
2275
+ g.relatedTarget === null && i && (t.current = !1);
2276
+ }, d = () => {
2277
+ const { activeElement: g, body: b } = r;
2278
+ g !== null && g !== b && (t.current = n.contains(g));
2279
+ }, h = () => {
2280
+ i && !n.contains(r.activeElement) && (t.current = !1);
2281
+ };
2282
+ return o.addEventListener("pointerdown", u, !0), o.addEventListener("mousedown", u, !0), o.addEventListener("focusin", m, !0), o.addEventListener("blur", d), o.addEventListener("focus", h), n.addEventListener("focusout", f), () => {
2283
+ clearTimeout(l), o.removeEventListener("pointerdown", u, !0), o.removeEventListener("mousedown", u, !0), o.removeEventListener("focusin", m, !0), o.removeEventListener("blur", d), o.removeEventListener("focus", h), n.removeEventListener("focusout", f);
2284
+ };
2285
+ }, [e]), t;
2286
+ }, dl = ({ path: e, snapshot: t, markup: n, stale: r, viewer: o, editLayout: i, regionLabel: l, navigation: u, fragment: m, paneScroll: f, announces: d, announceFailure: h, onDocumentShown: g }) => {
2287
+ const { labels: b, announcer: M, documents: R } = D(), { document: S } = t, A = _(null), L = _(null), E = _(null), v = _(0), a = cl(A), s = _({ path: e, document: S }), w = _(null), T = P(
2288
+ (Z) => {
2289
+ const X = A.current, Q = qt(X, Z, f);
2290
+ X !== null && Q !== null && Ut(X, Q, a.current);
2291
+ },
2292
+ [f, a]
2293
+ ), C = P(
2294
+ (Z, X) => {
2295
+ const Q = v.current;
2296
+ setTimeout(() => {
2297
+ !X.defaultPrevented && v.current === Q && T(Z);
2298
+ }, 0);
2299
+ },
2300
+ [T]
2301
+ ), N = P(
2302
+ (Z) => {
2303
+ setTimeout(() => {
2304
+ Z.defaultPrevented || T("#");
2305
+ }, 0);
2306
+ },
2307
+ [T]
2308
+ ), q = G(() => ({ navigation: u, currentPath: e, scrollWithin: T, followSameUrlJump: C, followEmptyFragment: N }), [u, e, T, C, N]), W = P(() => R.retry(e), [R, e]), z = Lo(R, Ci), j = bn(e), Y = j !== void 0 ? "edit" : n ? "markup" : "rendered", V = S.kind === "markdown" ? Y : void 0, re = P(() => A.current, []), p = G(() => ({ session: j, layout: i, region: re, paneScroll: f, stale: r }), [j, i, re, f, r]), x = V === "edit" ? !1 : r, k = ne(he), O = V === "edit" && i === "fill" ? "fill" : k, $ = le((Z, X) => {
2309
+ const Q = L.current;
2310
+ if (Q !== null && Q.path === Z && Q.snapshot === X) return;
2311
+ L.current = { path: Z, snapshot: X };
2312
+ const oe = X.document;
2313
+ if (oe.kind === "failure") {
2314
+ R.noteFailureShown(X) && h(b.documentFailed(se(Z), ae(b, oe.failure.reason)));
2315
+ return;
2316
+ }
2317
+ g?.(Z, oe), d && (Q === null || Q.path !== Z || Q.snapshot.document.kind === "failure") && M.announce(b.documentShown(oe.name));
2318
+ });
2319
+ te(() => {
2320
+ $(e, t);
2321
+ }, [e, t]);
2322
+ const I = le(() => {
2323
+ m.kind === "panel" && m.consume();
2324
+ }), K = le((Z) => {
2325
+ const X = A.current;
2326
+ if (X === null || !a.current) return null;
2327
+ const { activeElement: Q, body: oe } = X.ownerDocument;
2328
+ return Q !== null && Q !== oe ? null : sl(X, S, Z);
2329
+ }), U = le((Z) => {
2330
+ const X = A.current;
2331
+ X !== null && Ut(X, Z, a.current);
2332
+ }), ie = le((Z) => f.reveal(Z)), ht = le((Z) => qt(A.current, Z, f));
2333
+ return te(() => {
2334
+ if (r) return;
2335
+ const Z = s.current.path !== e, X = Z || s.current.document !== S;
2336
+ s.current = { path: e, document: S };
2337
+ const Q = w.current !== e;
2338
+ w.current = e;
2339
+ let oe = null;
2340
+ m.kind === "page" ? E.current !== m.navigation && (E.current = m.navigation, v.current += 1, oe = m.fragment) : m.fragment !== null && (oe = m.fragment, I());
2341
+ const pt = () => {
2342
+ const He = oe === null ? null : ht(oe);
2343
+ if (!X) {
2344
+ He !== null && U(He);
2345
+ return;
2346
+ }
2347
+ const vt = K(m.fragment);
2348
+ Z && He === null && vt !== null && ie(vt);
2349
+ };
2350
+ Q ? queueMicrotask(pt) : pt();
2351
+ }, [m, e, S, r]), /* @__PURE__ */ c(he, { value: O, children: /* @__PURE__ */ c(xe, { kind: S.kind, view: V, label: l(e, S), stale: x, busy: x, frameRef: A, intent: z, children: /* @__PURE__ */ c(Ln, { value: q, children: /* @__PURE__ */ c(Mi, { children: /* @__PURE__ */ c(ll, { path: e, document: S, view: Y, viewer: o, onRetry: W, editing: p }, e) }) }) }) });
2352
+ }, mt = Object.freeze({ kind: "skeleton" }), ul = (e, t, n, r, o) => {
2353
+ if (t?.status === "loaded") return { kind: "document", path: e, snapshot: t, stale: !1 };
2354
+ const i = ue(t);
2355
+ if (i !== null) return { kind: "document", path: e, snapshot: i, stale: !0 };
2356
+ if (o && t?.status === "pending") return { kind: "streaming", path: e, promise: t.promise };
2357
+ const l = n === null || n === e ? null : ue(r);
2358
+ return n === null || l === null ? mt : { kind: "document", path: n, snapshot: l, stale: !0 };
2359
+ }, fl = (e, t) => t.status === "deferred" ? mt : { kind: "document", path: e, snapshot: t, stale: !1 }, ml = ({ requestedPath: e, content: t, markup: n, ...r }) => {
2360
+ const o = t.kind === "streaming" ? fl(t.path, ne(t.promise)) : t;
2361
+ return o.kind !== "document" ? /* @__PURE__ */ c(ut, { label: r.regionLabel(e, null) }) : /* @__PURE__ */ c(dl, { path: o.path, snapshot: o.snapshot, markup: n, stale: o.stale, ...r });
2362
+ }, $n = ({ path: e, absence: t, markup: n, display: r, navigation: o, fragment: i, paneScroll: l, announces: u, announceFailure: m, onDocumentShown: f }) => {
2363
+ const { config: d, labels: h, theme: g, documents: b } = D(), M = br(), R = _(!1);
2364
+ H(() => {
2365
+ R.current = !0;
2366
+ }, []);
2367
+ const [S, A] = B(null), [L, E] = B(n), v = P(() => e === null ? void 0 : b.peek(e), [b, e]), a = ee(b.subscribe, v, v), s = P(() => S === null ? void 0 : b.peek(S), [b, S]), w = ee(b.subscribe, s, s);
2368
+ H(() => e === null ? void 0 : b.open(e), [b, e]), H(() => S === null ? void 0 : b.retain(S), [b, S]);
2369
+ const T = e === null ? mt : ul(e, a, S, w, !R.current), C = e === null ? null : T.kind === "document" && !T.stale ? T.path : S;
2370
+ C !== S && A(C);
2371
+ const N = T.kind !== "document" || T.path === e;
2372
+ N && n !== L && E(n);
2373
+ const q = G(() => Ji(h), [h]), W = G(() => [...d.iframeHosts], [d]), z = o.kind === "panel", j = G(
2374
+ () => ({
2375
+ labels: q,
2376
+ emptyMessage: h.documentEmpty,
2377
+ theme: g,
2378
+ availableStyles: d.documentStyles,
2379
+ iFrameAllowedDomains: W,
2380
+ embeds: d.embeds,
2381
+ linkComponent: $i,
2382
+ toolbar: M,
2383
+ style: r.style,
2384
+ onStyleChange: r.onStyleChange,
2385
+ align: r.align,
2386
+ onAlignChange: r.onAlignChange,
2387
+ showToc: r.showToc,
2388
+ showStyle: r.showStyle,
2389
+ showAlign: r.showAlign,
2390
+ padding: r.padding,
2391
+ width: r.width === void 0 ? void 0 : `min(${r.width}, 100%)`,
2392
+ maxWidth: r.maxWidth === void 0 ? void 0 : `min(${r.maxWidth}, 100%)`,
2393
+ renderScrollBar: z ? void 0 : Sn
2394
+ }),
2395
+ [q, h.documentEmpty, g, d.documentStyles, W, d.embeds, M, r, z]
2396
+ ), Y = P((re, p) => z ? p === null || p.kind === "failure" ? se(re) : p.name : h.documentRegion, [z, h.documentRegion]), V = z ? "content" : "fill";
2397
+ return e === null ? /* @__PURE__ */ c(he, { value: V, children: /* @__PURE__ */ c(tl, { absence: t, announces: u, announceFailure: m }) }) : /* @__PURE__ */ c(he, { value: V, children: /* @__PURE__ */ c(ke, { fallback: /* @__PURE__ */ c(ut, { label: Y(e, null) }), children: /* @__PURE__ */ c(
2398
+ ml,
2399
+ {
2400
+ requestedPath: e,
2401
+ content: T,
2402
+ markup: N ? n : L,
2403
+ viewer: j,
2404
+ editLayout: r.editLayout,
2405
+ regionLabel: Y,
2406
+ navigation: o,
2407
+ fragment: i,
2408
+ paneScroll: l,
2409
+ announces: u,
2410
+ announceFailure: m,
2411
+ onDocumentShown: f
2412
+ }
2413
+ ) }) });
2414
+ }, hl = ({ path: e, absence: t, markup: n, variant: r, onDocumentShown: o }) => {
2415
+ const { config: i, viewSettings: l, announcer: u } = D(), m = Ae((C) => C.style), f = Ae((C) => C.align), d = Fe(), h = nn(), g = lt(), { view: b, overrides: M, embed: R } = r, S = P(
2416
+ (C) => {
2417
+ if (g.kind !== "location") return;
2418
+ const N = el(i, g.location, C);
2419
+ N !== null && d(N, "browse");
2420
+ },
2421
+ [i, d, g]
2422
+ ), A = P(
2423
+ (C) => {
2424
+ l.update({ style: C }), S("style");
2425
+ },
2426
+ [l, S]
2427
+ ), L = P(
2428
+ (C) => {
2429
+ l.update({ align: C }), S("align");
2430
+ },
2431
+ [l, S]
2432
+ ), E = Nn(i, M.style, m), v = Dn(M.align, f), a = G(
2433
+ () => ({
2434
+ style: E,
2435
+ onStyleChange: A,
2436
+ align: v,
2437
+ onAlignChange: L,
2438
+ showToc: R.showToc !== !1,
2439
+ showStyle: R.showStyle !== !1,
2440
+ showAlign: R.showAlign !== !1,
2441
+ padding: R.padding,
2442
+ width: R.width,
2443
+ maxWidth: R.maxWidth,
2444
+ editLayout: "fill"
2445
+ }),
2446
+ [E, A, v, L, R]
2447
+ ), s = G(() => ({ kind: "page", view: b, overrides: M, embed: R }), [b, M, R]), w = G(() => ({ kind: "page", fragment: h.hash, navigation: h }), [h]), T = P((C) => u.announce(C), [u]);
2448
+ return /* @__PURE__ */ c($n, { path: e, absence: t, markup: n, display: a, navigation: s, fragment: w, paneScroll: li, announces: !0, announceFailure: T, onDocumentShown: o });
2449
+ }, pl = ({ path: e, absence: t, markup: n, variant: r, onDocumentShown: o }) => {
2450
+ const { config: i, viewSettings: l } = D(), u = Ae((s) => s.style), m = Ae((s) => s.align), [f, d] = B(() => Nn(i, void 0, u)), h = Dn(void 0, m), g = P((s) => l.update({ align: s }), [l]), { maximized: b, onDocumentLink: M, pendingHash: R, onHashConsumed: S, announceFailure: A, paneScroll: L } = r, E = G(
2451
+ () => ({
2452
+ style: f,
2453
+ onStyleChange: d,
2454
+ align: h,
2455
+ onAlignChange: g,
2456
+ showToc: b,
2457
+ showStyle: b,
2458
+ showAlign: b,
2459
+ padding: void 0,
2460
+ width: void 0,
2461
+ maxWidth: void 0,
2462
+ editLayout: b ? "fill" : "content"
2463
+ }),
2464
+ [f, h, g, b]
2465
+ ), v = G(() => ({ kind: "panel", onDocumentLink: M }), [M]), a = G(() => ({ kind: "panel", fragment: R, consume: S }), [R, S]);
2466
+ return /* @__PURE__ */ c($n, { path: e, absence: t, markup: n, display: E, navigation: v, fragment: a, paneScroll: L, announces: !1, announceFailure: A, onDocumentShown: o });
2467
+ }, vl = ({ path: e, absence: t, markup: n, variant: r, onDocumentShown: o }) => r.kind === "page" ? /* @__PURE__ */ c(hl, { path: e, absence: t, markup: n, variant: r, onDocumentShown: o }) : /* @__PURE__ */ c(pl, { path: e, absence: t, markup: n, variant: r, onDocumentShown: o });
2468
+ function wl({
2469
+ title: e,
2470
+ titleId: t,
2471
+ ...n
2472
+ }, r) {
2473
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
2474
+ xmlns: "http://www.w3.org/2000/svg",
2475
+ viewBox: "0 0 24 24",
2476
+ fill: "currentColor",
2477
+ "aria-hidden": "true",
2478
+ "data-slot": "icon",
2479
+ ref: r,
2480
+ "aria-labelledby": t
2481
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
2482
+ id: t
2483
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
2484
+ fillRule: "evenodd",
2485
+ d: "M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z",
2486
+ clipRule: "evenodd"
2487
+ }));
2488
+ }
2489
+ const gl = /* @__PURE__ */ y.forwardRef(wl);
2490
+ function bl({
2491
+ title: e,
2492
+ titleId: t,
2493
+ ...n
2494
+ }, r) {
2495
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
2496
+ xmlns: "http://www.w3.org/2000/svg",
2497
+ viewBox: "0 0 24 24",
2498
+ fill: "currentColor",
2499
+ "aria-hidden": "true",
2500
+ "data-slot": "icon",
2501
+ ref: r,
2502
+ "aria-labelledby": t
2503
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
2504
+ id: t
2505
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
2506
+ fillRule: "evenodd",
2507
+ d: "M14.447 3.026a.75.75 0 0 1 .527.921l-4.5 16.5a.75.75 0 0 1-1.448-.394l4.5-16.5a.75.75 0 0 1 .921-.527ZM16.72 6.22a.75.75 0 0 1 1.06 0l5.25 5.25a.75.75 0 0 1 0 1.06l-5.25 5.25a.75.75 0 1 1-1.06-1.06L21.44 12l-4.72-4.72a.75.75 0 0 1 0-1.06Zm-9.44 0a.75.75 0 0 1 0 1.06L2.56 12l4.72 4.72a.75.75 0 0 1-1.06 1.06L.97 12.53a.75.75 0 0 1 0-1.06l5.25-5.25a.75.75 0 0 1 1.06 0Z",
2508
+ clipRule: "evenodd"
2509
+ }));
2510
+ }
2511
+ const Fn = /* @__PURE__ */ y.forwardRef(bl);
2512
+ function El({
2513
+ title: e,
2514
+ titleId: t,
2515
+ ...n
2516
+ }, r) {
2517
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
2518
+ xmlns: "http://www.w3.org/2000/svg",
2519
+ viewBox: "0 0 24 24",
2520
+ fill: "currentColor",
2521
+ "aria-hidden": "true",
2522
+ "data-slot": "icon",
2523
+ ref: r,
2524
+ "aria-labelledby": t
2525
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
2526
+ id: t
2527
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
2528
+ fillRule: "evenodd",
2529
+ d: "M15.75 2.25H21a.75.75 0 0 1 .75.75v5.25a.75.75 0 0 1-1.5 0V4.81L8.03 17.03a.75.75 0 0 1-1.06-1.06L19.19 3.75h-3.44a.75.75 0 0 1 0-1.5Zm-10.5 4.5a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h10.5a1.5 1.5 0 0 0 1.5-1.5V10.5a.75.75 0 0 1 1.5 0v8.25a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h8.25a.75.75 0 0 1 0 1.5H5.25Z",
2530
+ clipRule: "evenodd"
2531
+ }));
2532
+ }
2533
+ const yl = /* @__PURE__ */ y.forwardRef(El);
2534
+ function xl({
2535
+ title: e,
2536
+ titleId: t,
2537
+ ...n
2538
+ }, r) {
2539
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
2540
+ xmlns: "http://www.w3.org/2000/svg",
2541
+ viewBox: "0 0 24 24",
2542
+ fill: "currentColor",
2543
+ "aria-hidden": "true",
2544
+ "data-slot": "icon",
2545
+ ref: r,
2546
+ "aria-labelledby": t
2547
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
2548
+ id: t
2549
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
2550
+ fillRule: "evenodd",
2551
+ d: "M11.47 13.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 0 0-1.06-1.06L12 11.69 5.03 4.72a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",
2552
+ clipRule: "evenodd"
2553
+ }), /* @__PURE__ */ y.createElement("path", {
2554
+ fillRule: "evenodd",
2555
+ d: "M11.47 19.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 1 0-1.06-1.06L12 17.69l-6.97-6.97a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",
2556
+ clipRule: "evenodd"
2557
+ }));
2558
+ }
2559
+ const Sl = /* @__PURE__ */ y.forwardRef(xl);
2560
+ function kl({
2561
+ title: e,
2562
+ titleId: t,
2563
+ ...n
2564
+ }, r) {
2565
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
2566
+ xmlns: "http://www.w3.org/2000/svg",
2567
+ viewBox: "0 0 24 24",
2568
+ fill: "currentColor",
2569
+ "aria-hidden": "true",
2570
+ "data-slot": "icon",
2571
+ ref: r,
2572
+ "aria-labelledby": t
2573
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
2574
+ id: t
2575
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
2576
+ fillRule: "evenodd",
2577
+ d: "M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25ZM12.75 6a.75.75 0 0 0-1.5 0v6c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-3.75V6Z",
2578
+ clipRule: "evenodd"
2579
+ }));
2580
+ }
2581
+ const Tl = /* @__PURE__ */ y.forwardRef(kl);
2582
+ function Rl({
2583
+ title: e,
2584
+ titleId: t,
2585
+ ...n
2586
+ }, r) {
2587
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
2588
+ xmlns: "http://www.w3.org/2000/svg",
2589
+ viewBox: "0 0 24 24",
2590
+ fill: "currentColor",
2591
+ "aria-hidden": "true",
2592
+ "data-slot": "icon",
2593
+ ref: r,
2594
+ "aria-labelledby": t
2595
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
2596
+ id: t
2597
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
2598
+ fillRule: "evenodd",
2599
+ d: "M9 1.5H5.625c-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.5Zm6.61 10.936a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 14.47a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",
2600
+ clipRule: "evenodd"
2601
+ }), /* @__PURE__ */ y.createElement("path", {
2602
+ 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"
2603
+ }));
2604
+ }
2605
+ const Ml = /* @__PURE__ */ y.forwardRef(Rl);
2606
+ function Ol({
2607
+ title: e,
2608
+ titleId: t,
2609
+ ...n
2610
+ }, r) {
2611
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
2612
+ xmlns: "http://www.w3.org/2000/svg",
2613
+ viewBox: "0 0 24 24",
2614
+ fill: "currentColor",
2615
+ "aria-hidden": "true",
2616
+ "data-slot": "icon",
2617
+ ref: r,
2618
+ "aria-labelledby": t
2619
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
2620
+ id: t
2621
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
2622
+ d: "M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"
2623
+ }), /* @__PURE__ */ y.createElement("path", {
2624
+ fillRule: "evenodd",
2625
+ d: "M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",
2626
+ clipRule: "evenodd"
2627
+ }));
2628
+ }
2629
+ const Cl = /* @__PURE__ */ y.forwardRef(Ol);
2630
+ function Ll({
2631
+ title: e,
2632
+ titleId: t,
2633
+ ...n
2634
+ }, r) {
2635
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
2636
+ xmlns: "http://www.w3.org/2000/svg",
2637
+ viewBox: "0 0 24 24",
2638
+ fill: "currentColor",
2639
+ "aria-hidden": "true",
2640
+ "data-slot": "icon",
2641
+ ref: r,
2642
+ "aria-labelledby": t
2643
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
2644
+ id: t
2645
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
2646
+ d: "M21.731 2.269a2.625 2.625 0 0 0-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 0 0 0-3.712ZM19.513 8.199l-3.712-3.712-8.4 8.4a5.25 5.25 0 0 0-1.32 2.214l-.8 2.685a.75.75 0 0 0 .933.933l2.685-.8a5.25 5.25 0 0 0 2.214-1.32l8.4-8.4Z"
2647
+ }), /* @__PURE__ */ y.createElement("path", {
2648
+ d: "M5.25 5.25a3 3 0 0 0-3 3v10.5a3 3 0 0 0 3 3h10.5a3 3 0 0 0 3-3V13.5a.75.75 0 0 0-1.5 0v5.25a1.5 1.5 0 0 1-1.5 1.5H5.25a1.5 1.5 0 0 1-1.5-1.5V8.25a1.5 1.5 0 0 1 1.5-1.5h5.25a.75.75 0 0 0 0-1.5H5.25Z"
2649
+ }));
2650
+ }
2651
+ const Al = /* @__PURE__ */ y.forwardRef(Ll);
2652
+ function Nl({
2653
+ title: e,
2654
+ titleId: t,
2655
+ ...n
2656
+ }, r) {
2657
+ return /* @__PURE__ */ y.createElement("svg", Object.assign({
2658
+ xmlns: "http://www.w3.org/2000/svg",
2659
+ viewBox: "0 0 24 24",
2660
+ fill: "currentColor",
2661
+ "aria-hidden": "true",
2662
+ "data-slot": "icon",
2663
+ ref: r,
2664
+ "aria-labelledby": t
2665
+ }, n), e ? /* @__PURE__ */ y.createElement("title", {
2666
+ id: t
2667
+ }, e) : null, /* @__PURE__ */ y.createElement("path", {
2668
+ d: "M15 3.75H9v16.5h6V3.75ZM16.5 20.25h3.375c1.035 0 1.875-.84 1.875-1.875V5.625c0-1.036-.84-1.875-1.875-1.875H16.5v16.5ZM4.125 3.75H7.5v16.5H4.125a1.875 1.875 0 0 1-1.875-1.875V5.625c0-1.036.84-1.875 1.875-1.875Z"
2669
+ }));
2670
+ }
2671
+ const Dl = /* @__PURE__ */ y.forwardRef(Nl), Pl = ({ href: e, onRetry: t, testId: n }) => {
2672
+ const { labels: r, onEditGrant: o } = D(), [i, l] = B(!1), u = () => {
2673
+ o === void 0 || i || (l(!0), o(e).then((m) => {
2674
+ m && t();
2675
+ }).finally(() => l(!1)));
2676
+ };
2677
+ return /* @__PURE__ */ F("div", { className: "aqmx-callout aqmx-edit-grant", "data-testid": n, children: [
2678
+ /* @__PURE__ */ c("p", { className: "aqmx-callout-title", children: r.editGrantTitle }),
2679
+ /* @__PURE__ */ c("p", { className: "aqmx-callout-body", children: r.editGrantBody }),
2680
+ /* @__PURE__ */ F("div", { className: "aqmx-edit-grant-actions", children: [
2681
+ o === void 0 ? /* @__PURE__ */ c("a", { className: "aqmx-callout-action", href: e, target: "_blank", rel: "noopener", "data-testid": `${n}-open`, children: r.editGrantAction }) : (
2682
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", "aria-disabled": i, "data-testid": `${n}-open`, onClick: u, children: r.editGrantAction })
2683
+ ),
2684
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", "data-testid": `${n}-retry`, onClick: t, children: r.editGrantRetry })
2685
+ ] })
2686
+ ] });
2687
+ }, $l = "Control+E Meta+E", Fl = (e, t, n) => n && t ? "split" : e.view, Zt = (e, t, n, r) => {
2688
+ if (n === "split") {
2689
+ e.setSideBySide(!0);
2690
+ return;
2691
+ }
2692
+ e.setView(t, n), r && e.sideBySide() && e.setSideBySide(!1);
2693
+ }, Ja = (e) => e === "split" ? null : e, ql = (e) => e === "preview" ? "editor" : "preview", _l = (e) => /Mac|iPhone|iPad|iPod/u.test(e), Il = (e, t) => {
2694
+ if (e.isComposing || e.altKey || e.shiftKey || (t ? !e.metaKey || e.ctrlKey : !e.ctrlKey || e.metaKey)) return !1;
2695
+ const n = e.key.toLowerCase();
2696
+ return n === "e" || e.code === "KeyE" && /^\p{L}$/u.test(n) && !/^[a-z]$/u.test(n);
2697
+ }, Gt = (e, t, n) => {
2698
+ const r = e.modifiedAt === null ? Number.NaN : Date.parse(e.modifiedAt);
2699
+ return n(Number.isNaN(r) ? e.id : t.format(r), e.author === null ? "" : e.author);
2700
+ }, Bl = ({ path: e, documentName: t, open: n, onClose: r }) => {
2701
+ const { data: o, edits: i, labels: l, locale: u, announcer: m } = D(), f = Se(), [d, h] = B(null), [g, b] = B(0), [M, R] = B(null), [S, A] = B(null), L = G(() => new Intl.DateTimeFormat(u, { dateStyle: "medium", timeStyle: "short" }), [u]), E = P(() => {
2702
+ R(null), A(null);
2703
+ }, []), v = vn({ open: n, onOpen: E, onDismiss: r });
2704
+ te(() => {
2705
+ if (!n) return;
2706
+ const w = new AbortController();
2707
+ return h(null), o.revisions(e, w.signal).then((T) => {
2708
+ "kind" in T && h(T);
2709
+ }), () => w.abort();
2710
+ }, [n, o, e, g]), te(() => {
2711
+ if (!n || M === null) return;
2712
+ const w = new AbortController();
2713
+ return A(null), o.revision(e, M, w.signal).then((T) => {
2714
+ "kind" in T && A(T);
2715
+ }), () => w.abort();
2716
+ }, [n, o, e, M]);
2717
+ const a = () => {
2718
+ S === null || S.kind !== "revision" || (i.replaceDraft(e, S.text), m.announce(l.historyRestored(t)), r());
2719
+ }, s = d !== null && d.kind === "revisions" ? d.revisions.find((w) => w.id === M) : void 0;
2720
+ return /* @__PURE__ */ c("dialog", { ...v, className: "aqmx-confirm aqmx-history", "aria-labelledby": f, "data-testid": "markdown-explorer-history", children: /* @__PURE__ */ F("div", { className: "aqmx-confirm-panel aqmx-history-panel", children: [
2721
+ /* @__PURE__ */ c("p", { id: f, className: "aqmx-confirm-title", children: l.historyTitle(t) }),
2722
+ d === null ? /* @__PURE__ */ c("p", { className: "aqmx-history-note", "data-testid": "markdown-explorer-history-loading", children: l.historyLoading }) : d.kind === "failure" ? /* @__PURE__ */ c(me, { failure: d.failure, alert: !1, onRetry: () => b((w) => w + 1), testId: "markdown-explorer-history-failure" }) : d.revisions.length === 0 ? /* @__PURE__ */ c("p", { className: "aqmx-history-note", "data-testid": "markdown-explorer-history-empty", children: l.historyEmpty }) : /* @__PURE__ */ c("ul", { className: "aqmx-history-list", "data-testid": "markdown-explorer-history-list", children: d.revisions.map((w) => /* @__PURE__ */ c("li", { children: /* @__PURE__ */ F("button", { type: "button", className: "aqmx-history-entry", "aria-pressed": w.id === M, "data-testid": "markdown-explorer-history-entry", onClick: () => R(w.id), children: [
2723
+ /* @__PURE__ */ c("span", { children: Gt(w, L, l.historyEntry) }),
2724
+ w.current ? /* @__PURE__ */ c("span", { className: "aqmx-history-mark", children: l.historyCurrent }) : null,
2725
+ w.kept ? /* @__PURE__ */ c("span", { className: "aqmx-history-mark", children: l.historyKept }) : null
2726
+ ] }) }, w.id)) }),
2727
+ M === null ? null : S === null ? /* @__PURE__ */ c("p", { className: "aqmx-history-note", children: l.historyLoading }) : S.kind === "failure" ? /* @__PURE__ */ c(me, { failure: S.failure, alert: !1, testId: "markdown-explorer-history-revision-failure" }) : (
2728
+ /* @__PURE__ */ c("section", { className: "aqmx-history-text", tabIndex: 0, "aria-label": s === void 0 ? l.historyTitle(t) : Gt(s, L, l.historyEntry), "data-testid": "markdown-explorer-history-text", children: /* @__PURE__ */ c("pre", { children: S.text }) })
2729
+ ),
2730
+ /* @__PURE__ */ F("div", { className: "aqmx-confirm-actions", children: [
2731
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", "data-testid": "markdown-explorer-history-close", onClick: r, children: l.historyClose }),
2732
+ /* @__PURE__ */ c("button", { type: "button", className: "aqmx-callout-action", "aria-disabled": S === null || S.kind !== "revision", "data-testid": "markdown-explorer-history-restore", onClick: a, children: l.historyRestore })
2733
+ ] })
2734
+ ] }) });
2735
+ }, zl = (e) => {
2736
+ const { documents: t } = D(), n = P(() => t.peek(e), [t, e]), r = P(() => t.peekSeeded(e), [t, e]), o = ee(t.subscribe, n, r), i = ue(o)?.document;
2737
+ return i === void 0 || i.kind === "failure" ? { edit: null, name: se(e) } : { edit: i.kind === "markdown" ? i.edit : null, name: i.name };
2738
+ }, ce = (e) => {
2739
+ e.stopPropagation();
2740
+ }, jl = ({ path: e, documentName: t, iconOnly: n, previewAvailable: r, draft: o }) => {
2741
+ const { draftConverter: i, edits: l, labels: u } = D(), m = ee(
2742
+ l.subscribe,
2743
+ () => l.session(e) !== void 0,
2744
+ () => !1
2745
+ ), [f, d] = B(null), h = () => {
2746
+ if (!m) {
2747
+ l.start(e, l.viewAnchor(e));
2748
+ return;
2749
+ }
2750
+ l.flush(e);
2751
+ const R = l.session(e);
2752
+ R?.dirty === !0 ? d(R.save.kind === "draft" ? "draft" : "unsaved") : l.close(e);
2753
+ }, g = () => {
2754
+ m || (fo(), r && l.sideBySide() && i?.prepare?.());
2755
+ }, b = n ? o ? u.editDraftDocumentNamed(t) : u.editDocumentNamed(t) : null, M = o ? u.editDraftDocument : u.editDocument;
2756
+ return /* @__PURE__ */ F(Pe, { children: [
2757
+ /* @__PURE__ */ F(
2758
+ "button",
2759
+ {
2760
+ type: "button",
2761
+ className: b === null ? "aqmx-icon-button aqmx-labelled-button" : "aqmx-icon-button",
2762
+ title: m ? u.closeEditor : b === null ? M : b,
2763
+ "aria-label": b === null ? void 0 : b,
2764
+ "aria-pressed": m,
2765
+ "data-testid": "markdown-explorer-document-edit",
2766
+ onClick: h,
2767
+ onDoubleClick: ce,
2768
+ onPointerEnter: g,
2769
+ onFocus: g,
2770
+ children: [
2771
+ /* @__PURE__ */ c(Al, { "aria-hidden": "true" }),
2772
+ b === null ? /* @__PURE__ */ c("span", { children: u.editDocumentLabel }) : null
2773
+ ]
2774
+ }
2775
+ ),
2776
+ /* @__PURE__ */ c(
2777
+ wn,
2778
+ {
2779
+ open: f !== null,
2780
+ title: f === "draft" ? u.draftDiscardTitle : u.unsavedTitle,
2781
+ body: f === "draft" ? u.draftDiscardBody(t) : u.unsavedBody(t),
2782
+ confirmLabel: u.unsavedDiscard,
2783
+ cancelLabel: u.unsavedStay,
2784
+ testId: "markdown-explorer-edit-close-confirm",
2785
+ onConfirm: () => {
2786
+ d(null), l.close(e);
2787
+ },
2788
+ onCancel: () => d(null)
2789
+ }
2790
+ )
2791
+ ] });
2792
+ }, Hl = ({ href: e, documentName: t, iconOnly: n }) => {
2793
+ const { labels: r } = D(), o = n ? r.editExternallyNamed(t) : null;
2794
+ return /* @__PURE__ */ F(
2795
+ "a",
2796
+ {
2797
+ className: o === null ? "aqmx-icon-button aqmx-labelled-button" : "aqmx-icon-button",
2798
+ href: e,
2799
+ target: "_blank",
2800
+ rel: "noopener noreferrer",
2801
+ title: o === null ? r.editExternally : o,
2802
+ "aria-label": o === null ? void 0 : o,
2803
+ "data-testid": "markdown-explorer-document-edit-external",
2804
+ onDoubleClick: ce,
2805
+ children: [
2806
+ /* @__PURE__ */ c(yl, { "aria-hidden": "true" }),
2807
+ o === null ? /* @__PURE__ */ c("span", { children: r.editExternallyLabel }) : null
2808
+ ]
2809
+ }
2810
+ );
2811
+ }, Vl = ({ session: e }) => {
2812
+ const { labels: t } = D(), n = Pr(t, e);
2813
+ return /* @__PURE__ */ c("p", { className: "aqmx-edit-status", title: n === "" ? void 0 : n, "data-testid": "markdown-explorer-edit-status", "data-aqmx-save": e.save.kind, children: n });
2814
+ }, Ul = Object.freeze(["editor", "split", "preview"]), Zl = Object.freeze(["editor", "preview"]), Gl = Object.freeze({ editor: Fn, split: Dl, preview: Cl }), Wl = ({ path: e, documentName: t, iconOnly: n, session: r, previewAvailable: o }) => {
2815
+ const { draftConverter: i, edits: l, labels: u } = D(), m = lo(), f = Fl(r, m, o), d = o ? Ul : Zl, h = Se(), g = _(/* @__PURE__ */ new Map()), b = {
2816
+ editor: { label: u.editViewEditor, tooltip: u.editViewEditorTooltip },
2817
+ split: { label: u.editViewSplit, tooltip: u.editViewSplitTooltip },
2818
+ preview: { label: u.editViewPreview, tooltip: u.editViewPreviewTooltip }
2819
+ }, M = () => {
2820
+ l.preparePreview(e), i?.prepare?.();
2821
+ }, R = (S) => {
2822
+ if (!Il(S.nativeEvent, _l(navigator.platform))) return;
2823
+ hn(S);
2824
+ const A = ql(f);
2825
+ Zt(l, e, A, o), g.current.get(A)?.focus();
2826
+ };
2827
+ return /* @__PURE__ */ c("div", { role: "radiogroup", "aria-label": n ? u.editViewNamed(t) : u.editView, className: "aqmx-edit-view", "data-testid": "markdown-explorer-edit-view", onKeyDown: R, children: d.map((S) => {
2828
+ const A = Gl[S], { label: L, tooltip: E } = b[S], v = S === "preview" ? M : void 0;
2829
+ return /* @__PURE__ */ F("label", { className: n ? "aqmx-icon-button" : "aqmx-icon-button aqmx-labelled-button", children: [
2830
+ /* @__PURE__ */ c(
2831
+ "input",
2832
+ {
2833
+ ref: (a) => {
2834
+ a === null ? g.current.delete(S) : g.current.set(S, a);
2835
+ },
2836
+ type: "radio",
2837
+ name: h,
2838
+ value: S,
2839
+ checked: S === f,
2840
+ "aria-label": L,
2841
+ "aria-keyshortcuts": S === "split" ? void 0 : $l,
2842
+ title: E,
2843
+ "data-testid": `markdown-explorer-edit-view-${S}`,
2844
+ onChange: () => Zt(l, e, S, o),
2845
+ onDoubleClick: ce,
2846
+ onPointerEnter: v,
2847
+ onFocus: v
2848
+ }
2849
+ ),
2850
+ /* @__PURE__ */ c(A, { "aria-hidden": "true" }),
2851
+ n ? null : /* @__PURE__ */ c("span", { children: L })
2852
+ ] }, S);
2853
+ }) });
2854
+ }, Kl = ({ path: e, documentName: t, iconOnly: n, session: r, previewAvailable: o }) => {
2855
+ const { edits: i, labels: l } = D(), [u, m] = B(!1);
2856
+ if (r.phase.kind !== "editing") return null;
2857
+ const f = r.save.kind === "saving", d = f || !r.dirty, h = () => {
2858
+ i.flush(e);
2859
+ const b = i.session(e);
2860
+ b === void 0 || !b.dirty || b.save.kind === "saving" || i.save(e);
2861
+ }, g = (b) => n ? { className: "aqmx-icon-button", "aria-label": b } : { className: "aqmx-icon-button aqmx-labelled-button" };
2862
+ return /* @__PURE__ */ F(Pe, { children: [
2863
+ r.save.kind === "conflicts" ? /* @__PURE__ */ F("button", { type: "button", ...g(l.conflictNext), title: l.conflictNext, "data-testid": "markdown-explorer-edit-next-conflict", onClick: () => i.nextConflict(e), onDoubleClick: ce, children: [
2864
+ /* @__PURE__ */ c(Sl, { "aria-hidden": "true" }),
2865
+ n ? null : /* @__PURE__ */ c("span", { children: l.conflictNext })
2866
+ ] }) : null,
2867
+ /* @__PURE__ */ c(Wl, { path: e, documentName: t, iconOnly: n, session: r, previewAvailable: o }),
2868
+ r.history ? /* @__PURE__ */ F("button", { type: "button", ...g(l.historyOpen), title: l.historyOpen, "aria-haspopup": "dialog", "data-testid": "markdown-explorer-edit-history", onClick: () => m(!0), onDoubleClick: ce, children: [
2869
+ /* @__PURE__ */ c(Tl, { "aria-hidden": "true" }),
2870
+ n ? null : /* @__PURE__ */ c("span", { children: l.historyOpen })
2871
+ ] }) : null,
2872
+ r.save.kind === "draft" ? null : /* @__PURE__ */ F("button", { type: "button", ...g(l.saveDraft), title: l.saveDraftTooltip, "aria-disabled": d, "aria-busy": f, "aria-keyshortcuts": "Control+S Meta+S", "data-testid": "markdown-explorer-edit-save", onClick: h, onDoubleClick: ce, children: [
2873
+ /* @__PURE__ */ c(Ml, { "aria-hidden": "true" }),
2874
+ n ? null : /* @__PURE__ */ c("span", { children: l.saveDraft })
2875
+ ] }),
2876
+ r.history ? /* @__PURE__ */ c(Bl, { path: e, documentName: t, open: u, onClose: () => m(!1) }) : null
2877
+ ] });
2878
+ }, Xl = ({ path: e, session: t }) => {
2879
+ const { edits: n } = D();
2880
+ return t.save.kind !== "grant" ? null : /* @__PURE__ */ c(Pl, { href: t.save.href, onRetry: () => {
2881
+ n.save(e);
2882
+ }, testId: "markdown-explorer-save-grant" });
2883
+ }, Yl = (e) => {
2884
+ const { documents: t } = D(), n = P(() => t.peek(e), [t, e]), r = P(() => t.peekSeeded(e), [t, e]), o = ee(t.subscribe, n, r);
2885
+ return ue(o)?.document.kind === "markdown";
2886
+ }, Jl = (e) => {
2887
+ const { config: t } = D(), n = Fe(), r = P(() => n(ye(t, { ...e, markup: !e.markup }), "browse"), [t, n, e]);
2888
+ return G(() => ({ shown: e.markup, toggle: r }), [e.markup, r]);
2889
+ }, Ql = /* @__PURE__ */ new Set(), ea = (e, t) => {
2890
+ const { documents: n, announcer: r, labels: o } = D(), i = P(() => n.peek(e), [n, e]), l = P(() => n.peekSeeded(e), [n, e]), u = ee(n.subscribe, i, l), m = P(() => n.answerStampOf(e), [n, e]), f = ee(n.subscribe, m, m), [d] = B(() => /* @__PURE__ */ new Set()), [h, g] = B(Ql), [b, M] = B(null);
2891
+ b !== null && b.path !== e && M(null);
2892
+ const R = _(null);
2893
+ H(() => (R.current = e, () => {
2894
+ R.current = null;
2895
+ }), [e]);
2896
+ const S = P(() => {
2897
+ const E = e, v = n.peek(E);
2898
+ if (d.has(E) || v?.status === "pending") return;
2899
+ const a = t && !Tn(v);
2900
+ d.add(E), g(new Set(d)), M(null), (async () => {
2901
+ try {
2902
+ const s = await n.refresh(E);
2903
+ if (R.current !== E || s.status === "superseded") return;
2904
+ if (s.status === "failed") {
2905
+ M({ path: E, failure: s.failure, stamp: n.answerStampOf(E) }), r.announce(o.documentRefreshFailed(ae(o, s.failure.reason)));
2906
+ return;
2907
+ }
2908
+ const w = ue(n.peek(E));
2909
+ if (a || w === null || w.document.kind === "failure") return;
2910
+ r.announce(o.documentRefreshed(w.document.name));
2911
+ } finally {
2912
+ d.delete(E), g(new Set(d));
2913
+ }
2914
+ })();
2915
+ }, [e, t, d, n, r, o]), A = h.has(e), L = b !== null && b.path === e && b.stamp === f ? b.failure : null;
2916
+ return { refreshing: A, unavailable: A || u?.status === "pending", failure: L, refresh: S };
2917
+ }, ta = Object.freeze({ kind: "page" }), na = ({ path: e, placement: t, markup: n }) => {
2918
+ const { labels: r } = D(), { refreshing: o, unavailable: i, failure: l, refresh: u } = ea(e, t.kind === "page"), m = Yl(e), f = zl(e), d = bn(e), h = t.kind === "panel" ? r.refreshDocumentNamed(t.documentName) : null, g = t.kind === "panel" ? r.showMarkupNamed(t.documentName) : null, b = t.kind === "panel", M = t.kind === "panel" ? t.documentName : f.name, R = t.kind === "page" || t.maximized;
2919
+ return /* @__PURE__ */ F("div", { className: "aqmx-document-refresh-bar", "data-testid": "markdown-explorer-document-refresh-bar", "data-aqmx-editing": d === void 0 ? void 0 : "true", children: [
2920
+ /* @__PURE__ */ F("div", { className: "aqmx-document-refresh-row", children: [
2921
+ d === void 0 ? null : /* @__PURE__ */ c(Vl, { session: d }),
2922
+ d === void 0 ? null : /* @__PURE__ */ c(Kl, { path: e, documentName: M, iconOnly: b, session: d, previewAvailable: R }),
2923
+ d === void 0 && m ? /* @__PURE__ */ F(
2924
+ "button",
2925
+ {
2926
+ type: "button",
2927
+ className: g === null ? "aqmx-icon-button aqmx-labelled-button" : "aqmx-icon-button",
2928
+ title: g === null ? r.showMarkup : g,
2929
+ "aria-label": g === null ? void 0 : g,
2930
+ "aria-pressed": n.shown,
2931
+ "data-testid": "markdown-explorer-document-markup",
2932
+ onClick: n.toggle,
2933
+ onDoubleClick: ce,
2934
+ children: [
2935
+ /* @__PURE__ */ c(Fn, { "aria-hidden": "true" }),
2936
+ g === null ? /* @__PURE__ */ c("span", { children: r.showMarkupLabel }) : null
2937
+ ]
2938
+ }
2939
+ ) : null,
2940
+ d !== void 0 || f.edit?.kind === "inline" || f.edit?.kind === "draft" ? /* @__PURE__ */ c(jl, { path: e, documentName: M, iconOnly: b, previewAvailable: R, draft: f.edit?.kind === "draft" }) : f.edit?.kind === "external" ? /* @__PURE__ */ c(Hl, { href: f.edit.href, documentName: M, iconOnly: b }) : null,
2941
+ d === void 0 ? /* @__PURE__ */ F(
2942
+ "button",
2943
+ {
2944
+ type: "button",
2945
+ className: h === null ? "aqmx-icon-button aqmx-labelled-button" : "aqmx-icon-button",
2946
+ title: h === null ? r.refreshDocument : h,
2947
+ "aria-label": h === null ? void 0 : h,
2948
+ "aria-disabled": i,
2949
+ "aria-busy": o,
2950
+ "data-aqmx-busy": o ? "true" : void 0,
2951
+ "data-testid": "markdown-explorer-document-refresh",
2952
+ onClick: u,
2953
+ onDoubleClick: ce,
2954
+ children: [
2955
+ /* @__PURE__ */ c(gl, { "aria-hidden": "true" }),
2956
+ h === null ? /* @__PURE__ */ c("span", { children: r.refreshDocumentLabel }) : null
2957
+ ]
2958
+ }
2959
+ ) : null
2960
+ ] }),
2961
+ d !== void 0 || l === null ? null : /* @__PURE__ */ c("p", { className: "aqmx-document-refresh-failure", "data-testid": "markdown-explorer-document-refresh-failure", "data-aqmx-failure": l.reason, children: r.documentRefreshFailed(ae(r, l.reason)) }),
2962
+ d === void 0 ? null : /* @__PURE__ */ c(Xl, { path: e, session: d })
2963
+ ] });
2964
+ }, ra = ({ location: e }) => {
2965
+ const t = e.doc, n = G(() => ({ kind: "page", view: "single", overrides: e.overrides, embed: e.embed }), [e.overrides, e.embed]), r = Jl(e);
2966
+ return /* @__PURE__ */ F("div", { className: "aqmx-single aqmx-document-column", "data-testid": "markdown-explorer-single", ...et, children: [
2967
+ /* @__PURE__ */ c(na, { path: t, placement: ta, markup: r }),
2968
+ /* @__PURE__ */ c(vl, { path: t, absence: Qi, markup: e.markup, variant: n })
2969
+ ] });
2970
+ }, oa = ({ holds: e, testId: t }) => {
2971
+ const { labels: n, announcer: r } = D(), o = Se();
2972
+ H(() => e ? r.claim(o) : void 0, [e, r, o]);
2973
+ const i = P(() => r.shownIn(o), [r, o]), l = ee(r.subscribe, i, i);
2974
+ return /* @__PURE__ */ c("div", { className: "aqmx-sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true", "data-testid": t, children: l.length > 1 ? n.announcementSequence(l) : l[0] });
2975
+ }, fe = Object.freeze([]), ia = (e) => {
2976
+ const t = /* @__PURE__ */ new Set();
2977
+ let n = fe, r = [], o = !1;
2978
+ const i = [], l = (d) => {
2979
+ n = d;
2980
+ for (const h of [...t]) h();
2981
+ }, u = () => i.at(-1)?.region, m = (d) => {
2982
+ const h = u();
2983
+ d(), u() !== h && n !== fe && l(fe);
2984
+ }, f = () => {
2985
+ o = !1;
2986
+ const d = r.map((h) => "sentence" in h ? h.sentence : h.list(h.items));
2987
+ r = [], l(Object.freeze(d));
2988
+ };
2989
+ return {
2990
+ announce: (d) => {
2991
+ if (typeof d == "string") r.push({ sentence: d });
2992
+ else {
2993
+ const h = r.find((g) => "list" in g && g.list === d.list);
2994
+ h !== void 0 && "items" in h ? h.items.push(d.item) : r.push({ list: d.list, items: [d.item] });
2995
+ }
2996
+ o || (o = !0, n !== fe && l(fe), e.request(f));
2997
+ },
2998
+ subscribe: (d) => (t.add(d), () => {
2999
+ t.delete(d);
3000
+ }),
3001
+ claim: (d) => {
3002
+ const h = { region: d };
3003
+ return m(() => i.push(h)), () => m(() => {
3004
+ const g = i.indexOf(h);
3005
+ g !== -1 && i.splice(g, 1);
3006
+ });
3007
+ },
3008
+ shownIn: (d) => u() === d ? n : fe
3009
+ };
3010
+ }, ge = Object.freeze({ status: "cancelled" }), la = (e) => {
3011
+ if (e === null || typeof e != "object") return null;
3012
+ const { failure: t } = e;
3013
+ if (sr(t) !== null) return null;
3014
+ const { reason: n, code: r } = t;
3015
+ return cr(n, r);
3016
+ }, aa = ({ dataPath: e, onScope: t, fetch: n }) => {
3017
+ const r = n ?? ((f, d) => globalThis.fetch(f, d)), o = (f, d) => `${e}/${f}?${new URLSearchParams(d).toString()}`, i = async (f, d, h, g) => {
3018
+ let b;
3019
+ try {
3020
+ b = await r(f, { credentials: "same-origin", ...d, headers: { Accept: "application/json", ...d.headers } });
3021
+ } catch {
3022
+ return g({ reason: "failed" });
3023
+ }
3024
+ b.status === 401 && t(null);
3025
+ const M = b.headers.get(rr);
3026
+ M !== null && t(M);
3027
+ let R;
3028
+ try {
3029
+ R = await b.json();
3030
+ } catch {
3031
+ return g({ reason: Et(b.status) });
3032
+ }
3033
+ let S;
3034
+ try {
3035
+ S = h(R);
3036
+ } catch {
3037
+ S = !1;
3038
+ }
3039
+ if (S) return R;
3040
+ const A = la(R);
3041
+ return g(A !== null ? A : { reason: b.status === 200 ? "failed" : Et(b.status) });
3042
+ }, l = { [xt]: dr }, u = { [xt]: pr, "Content-Type": `${hr}; charset=utf-8` }, m = async (f, d, h) => {
3043
+ const g = await i(f, d, h, (b) => Ve(b.reason, b.code));
3044
+ return d.signal.aborted ? ge : g;
3045
+ };
3046
+ return {
3047
+ tree: (f) => i(o("tree", { [J.source]: f }), { method: "GET" }, yt, (d) => ({ status: "error", failure: d })),
3048
+ children: async (f, d, h) => {
3049
+ const g = await i(o("children", { [J.source]: f, [J.path]: d }), { method: "GET", signal: h }, ar, (b) => ({ status: "error", failure: b }));
3050
+ return h.aborted ? ge : g;
3051
+ },
3052
+ ancestors: async (f, d, h) => {
3053
+ const g = await i(o("ancestors", { [J.source]: f, [J.path]: d }), { method: "GET", signal: h }, lr, (b) => ({ status: "error", failure: b }));
3054
+ return h.aborted ? ge : g;
3055
+ },
3056
+ reveal: async (f, d, h) => {
3057
+ const g = await i(o("reveal", { [J.source]: f, [J.path]: d }), { method: "GET", signal: h }, ir, (b) => ({ status: "error", failure: b }));
3058
+ return h.aborted ? ge : g;
3059
+ },
3060
+ document: (f, { refresh: d }) => i(o("document", { [J.path]: f }), d ? { method: "GET", headers: l } : { method: "GET" }, gr, (h) => Ve(h.reason, h.code)),
3061
+ text: async (f, d) => {
3062
+ const h = await i(o("text", { [J.path]: f }), { method: "GET", signal: d }, or, (g) => Ve(g.reason, g.code));
3063
+ return d.aborted ? ge : h;
3064
+ },
3065
+ edit: (f, d) => m(o("edit", { [J.path]: f }), { method: "GET", signal: d }, wr),
3066
+ save: (f, d, h, g) => m(o("save", { [J.path]: f, [J.base]: d }), { method: "POST", headers: u, body: h, signal: g }, vr),
3067
+ preview: (f, d, h) => m(o("preview", { [J.path]: f }), { method: "POST", headers: u, body: d, signal: h }, mr),
3068
+ revisions: (f, d) => m(o("revisions", { [J.path]: f }), { method: "GET", signal: d }, fr),
3069
+ revision: (f, d, h) => m(o("revision", { [J.path]: f, [J.revision]: d }), { method: "GET", signal: h }, ur),
3070
+ refresh: (f) => i(o("refresh", { [J.source]: f }), { method: "POST", headers: l }, yt, (d) => ({ status: "error", failure: d }))
3071
+ };
3072
+ }, sa = () => {
3073
+ let e = null, t = null;
3074
+ return {
3075
+ settle: (n) => {
3076
+ e = n;
3077
+ },
3078
+ mayMove: (n) => e !== n,
3079
+ move: (n, r, o) => {
3080
+ e = r, t = { sourceId: n, path: r, ancestors: o };
3081
+ },
3082
+ take: (n, r) => {
3083
+ const o = t !== null && t.sourceId === n && t.path === r ? t.ancestors : null;
3084
+ return t = null, o;
3085
+ }
3086
+ };
3087
+ }, ca = (e) => {
3088
+ const t = Qe(e);
3089
+ if (t === null) return bt;
3090
+ try {
3091
+ return Jn(JSON.parse(t));
3092
+ } catch (n) {
3093
+ return console.warn(`[markdown-explorer] localStorage key ${JSON.stringify(e)} does not hold JSON; using the default tree settings.`, n), bt;
3094
+ }
3095
+ }, Wt = (e, t) => {
3096
+ let n = null;
3097
+ const r = () => {
3098
+ if (n === null) {
3099
+ const i = ca(e);
3100
+ n = { changes: i, settings: gt(t, i) };
3101
+ }
3102
+ return n;
3103
+ }, o = Me();
3104
+ return {
3105
+ storageKey: e,
3106
+ defaults: t,
3107
+ getSnapshot: () => r().settings,
3108
+ getServerSnapshot: () => t,
3109
+ subscribe: o.subscribe,
3110
+ advance: (i) => {
3111
+ const { changes: l, settings: u } = r(), m = Kn(l, i, Xn(u, i)[i], t);
3112
+ return n = { changes: m, settings: gt(t, m) }, o.emit(), Je(e, Yn(m)), n.settings;
3113
+ }
3114
+ };
3115
+ }, da = Object.freeze({ status: "refreshed" }), ua = Object.freeze({ status: "superseded" }), ot = Object.freeze({ status: "deferred" }), fa = gn(ot), qn = 4, ma = qn - 1, Kt = Object.freeze({ status: "loading" }), ha = Object.freeze({ status: "error", failure: Object.freeze({ reason: "failed" }) }), pa = (e) => {
3116
+ const t = /* @__PURE__ */ new Map(), n = kn(), r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = Me(), m = /* @__PURE__ */ new Set();
3117
+ let f = 0, d = 0;
3118
+ const h = { direct: null, bulk: null }, g = /* @__PURE__ */ new Set();
3119
+ let b = !1, M = 0;
3120
+ const R = () => {
3121
+ M += 1, u.emit();
3122
+ }, S = (p) => o.get(p) ?? 0, A = (p) => {
3123
+ let x = l.get(p);
3124
+ return x === void 0 && (x = { claims: /* @__PURE__ */ new Map(), unclaimed: /* @__PURE__ */ new Set(), direct: /* @__PURE__ */ new Set(), bulk: /* @__PURE__ */ new Set(), inFlight: /* @__PURE__ */ new Map() }, l.set(p, x)), x;
3125
+ }, L = (p, x, k) => {
3126
+ p.inFlight.delete(x), f -= 1, k.lane === "bulk" && (d -= 1);
3127
+ }, E = (p) => {
3128
+ const x = l.get(p);
3129
+ if (x !== void 0) {
3130
+ for (const [k, O] of [...x.inFlight])
3131
+ L(x, k, O), O.controller.abort();
3132
+ x.direct.clear(), x.bulk.clear(), x.unclaimed.clear();
3133
+ }
3134
+ }, v = (p) => {
3135
+ const x = S(p) + 1;
3136
+ return o.set(p, x), E(p), x;
3137
+ }, a = (p, x) => {
3138
+ const k = Ee(p), O = { promise: p, opened: x, stale: !1, loadedAt: k?.status === "ok" ? k.loadedAt : null };
3139
+ return p.status === "pending" && p.then(($) => {
3140
+ $.status === "ok" && (O.loadedAt = $.loadedAt);
3141
+ }), O;
3142
+ }, s = (p) => {
3143
+ let x = r.get(p);
3144
+ return x === void 0 && (x = /* @__PURE__ */ new Map(), r.set(p, x)), x;
3145
+ }, w = (p) => {
3146
+ const x = [...l.keys()], k = h[p], O = k === null ? 0 : x.indexOf(k) + 1;
3147
+ for (let $ = 0; $ < x.length; $ += 1) {
3148
+ const I = x[(O + $) % x.length], K = I === void 0 ? void 0 : l.get(I);
3149
+ if (!(I === void 0 || K === void 0)) {
3150
+ for (const U of K[p])
3151
+ if ((K.claims.get(U) ?? 0) !== 0)
3152
+ return K[p].delete(U), h[p] = I, { sourceId: I, path: U };
3153
+ }
3154
+ }
3155
+ return null;
3156
+ }, T = (p, x, k, O) => {
3157
+ const $ = l.get(p);
3158
+ if ($ === void 0 || $.inFlight.get(x) !== k) return;
3159
+ L($, x, k);
3160
+ const I = ($.claims.get(x) ?? 0) > 0, K = s(p);
3161
+ if (O.status === "ok" ? K.set(x, { status: "loaded", entries: O.entries }) : O.status === "error" && I ? K.set(x, { status: "failed", failure: O.failure }) : K.delete(x), R(), O.status === "error" && I) {
3162
+ const U = { sourceId: p, path: x, failure: O.failure };
3163
+ for (const ie of [...m]) ie(U);
3164
+ }
3165
+ N();
3166
+ }, C = (p, x, k) => {
3167
+ const O = { controller: new AbortController(), lane: k };
3168
+ A(p).inFlight.set(x, O), f += 1, k === "bulk" && (d += 1), e.children(p, x, O.controller.signal).then(
3169
+ ($) => T(p, x, O, $),
3170
+ () => T(p, x, O, ha)
3171
+ );
3172
+ }, N = () => {
3173
+ for (; f < qn; ) {
3174
+ const p = w("direct");
3175
+ if (p !== null) {
3176
+ C(p.sourceId, p.path, "direct");
3177
+ continue;
3178
+ }
3179
+ const x = d < ma ? w("bulk") : null;
3180
+ if (x === null) return;
3181
+ C(x.sourceId, x.path, "bulk");
3182
+ }
3183
+ }, q = (p, x, k) => {
3184
+ if (!(x.direct.delete(k) || x.bulk.delete(k))) {
3185
+ const $ = x.inFlight.get(k);
3186
+ if ($ === void 0) return !1;
3187
+ L(x, k, $), $.controller.abort();
3188
+ }
3189
+ return r.get(p)?.delete(k), !0;
3190
+ }, W = () => {
3191
+ b = !1;
3192
+ let p = !1;
3193
+ for (const x of g) {
3194
+ const k = A(x);
3195
+ for (const O of k.unclaimed)
3196
+ (k.claims.get(O) ?? 0) === 0 && q(x, k, O) && (p = !0);
3197
+ k.unclaimed.clear();
3198
+ }
3199
+ g.clear(), p && (R(), N());
3200
+ }, z = (p, x) => {
3201
+ t.set(p, a(Te(e.tree(p)), x));
3202
+ }, j = (p, x, k) => {
3203
+ v(p);
3204
+ const O = a(gn(x), k);
3205
+ return t.set(p, O), r.delete(p), R(), N(), O;
3206
+ }, Y = (p, x, k, O) => {
3207
+ if (k !== S(p) || t.get(p) !== x) return;
3208
+ const $ = Ee(x.promise);
3209
+ if (!(O.status !== "ok" || $?.status !== "ok" || x.loadedAt === null || O.loadedAt <= x.loadedAt)) {
3210
+ if (De($.entries, O.entries)) {
3211
+ x.loadedAt = O.loadedAt;
3212
+ return;
3213
+ }
3214
+ j(p, O, x.opened);
3215
+ }
3216
+ }, V = (p, x) => {
3217
+ const k = t.get(p);
3218
+ return k !== void 0 && Ee(k.promise)?.status === x;
3219
+ }, re = (p, x) => {
3220
+ x.stale = !1;
3221
+ const k = S(p);
3222
+ e.tree(p).then((O) => Y(p, x, k, O));
3223
+ };
3224
+ return {
3225
+ read: (p) => t.get(p)?.promise ?? fa,
3226
+ open: (p) => {
3227
+ const x = n.resumes(p), k = n.hold(p), O = t.get(p);
3228
+ return O === void 0 || V(p, "deferred") ? (z(p, !0), R()) : x || (O.opened && V(p, "error") ? (z(p, !0), R()) : (O.opened = !0, O.stale && V(p, "ok") && re(p, O))), k;
3229
+ },
3230
+ retry: (p) => {
3231
+ V(p, "error") && (z(p, !0), R());
3232
+ },
3233
+ seed: (p, x) => {
3234
+ const k = x.then(
3235
+ (I) => I === null ? ot : I,
3236
+ () => ot
3237
+ ), O = t.get(p);
3238
+ if (O !== void 0 && V(p, "ok")) {
3239
+ const I = S(p);
3240
+ k.then((K) => Y(p, O, I, K));
3241
+ return;
3242
+ }
3243
+ v(p);
3244
+ const $ = a(Te(k), O?.opened === !0);
3245
+ t.set(p, $), r.delete(p), N(), k.then((I) => {
3246
+ t.get(p) === $ && (I.status === "deferred" && n.isHeld(p) && z(p, $.opened), R());
3247
+ });
3248
+ },
3249
+ refresh: async (p) => {
3250
+ const x = (i.get(p) ?? 0) + 1;
3251
+ i.set(p, x);
3252
+ const k = await e.refresh(p);
3253
+ if (i.get(p) !== x) return ua;
3254
+ if (k.status === "error") return { status: "failed", failure: k.failure };
3255
+ const O = t.get(p);
3256
+ if (!(O !== void 0 && O.loadedAt !== null && V(p, "ok") && O.loadedAt > k.loadedAt)) {
3257
+ const I = j(p, k, !0);
3258
+ if (O !== void 0 && O.promise.status === "pending") {
3259
+ const K = S(p);
3260
+ O.promise.then((U) => Y(p, I, K, U));
3261
+ }
3262
+ }
3263
+ for (const [I, K] of t)
3264
+ I !== p && Ee(K.promise)?.status === "ok" && (K.stale = !0);
3265
+ return da;
3266
+ },
3267
+ children: (p, x) => r.get(p)?.get(x),
3268
+ claimChildren: (p, x) => {
3269
+ const k = A(p), O = s(p);
3270
+ let $ = !1, I = !1;
3271
+ for (const [U, ie] of x)
3272
+ k.claims.set(U, (k.claims.get(U) ?? 0) + 1), O.get(U) === void 0 ? (O.set(U, Kt), k[ie].add(U), $ = !0, I = !0) : ie === "direct" && k.bulk.delete(U) && (k.direct.add(U), I = !0);
3273
+ $ && R(), I && N();
3274
+ let K = !1;
3275
+ return () => {
3276
+ if (!K) {
3277
+ K = !0;
3278
+ for (const U of x.keys()) {
3279
+ const ie = (k.claims.get(U) ?? 0) - 1;
3280
+ ie > 0 ? k.claims.set(U, ie) : (k.claims.delete(U), k.unclaimed.add(U));
3281
+ }
3282
+ g.add(p), !b && (b = !0, queueMicrotask(W));
3283
+ }
3284
+ };
3285
+ },
3286
+ retryChildren: (p, x) => {
3287
+ const k = r.get(p);
3288
+ if (k === void 0 || k.get(x)?.status !== "failed") return;
3289
+ const O = A(p);
3290
+ if ((O.claims.get(x) ?? 0) > 0) {
3291
+ k.set(x, Kt), O.direct.add(x), R(), N();
3292
+ return;
3293
+ }
3294
+ k.delete(x), R();
3295
+ },
3296
+ pendingChildren: (p) => {
3297
+ const x = l.get(p);
3298
+ return x === void 0 ? 0 : x.direct.size + x.bulk.size + x.inFlight.size;
3299
+ },
3300
+ clear: () => {
3301
+ for (const p of /* @__PURE__ */ new Set([...t.keys(), ...r.keys(), ...o.keys(), ...l.keys()])) v(p);
3302
+ for (const [p, x] of i) i.set(p, x + 1);
3303
+ t.clear(), r.clear(), R();
3304
+ },
3305
+ subscribeChildrenFailures: (p) => (m.add(p), () => {
3306
+ m.delete(p);
3307
+ }),
3308
+ subscribe: u.subscribe,
3309
+ version: () => M
3310
+ };
3311
+ }, va = (e, t) => {
3312
+ let n = e;
3313
+ const r = Me();
3314
+ return {
3315
+ getSnapshot: () => n,
3316
+ subscribe: r.subscribe,
3317
+ update: (o) => {
3318
+ n = { ...n, ...o }, t(n), r.emit();
3319
+ }
3320
+ };
3321
+ }, wa = 1;
3322
+ let Oe = 0, de = null;
3323
+ const ga = () => {
3324
+ const { documentElement: e, body: t } = document;
3325
+ Oe === 0 && (de = { htmlOverflow: e.style.overflow, bodyOverflow: t.style.overflow, htmlGutter: e.style.scrollbarGutter, bodyGutter: t.style.scrollbarGutter }, e.style.overflow = "hidden", t.style.overflow = "hidden", e.style.scrollbarGutter = "auto", t.style.scrollbarGutter = "auto"), Oe += 1;
3326
+ let n = !1;
3327
+ return () => {
3328
+ n || (n = !0, Oe -= 1, !(Oe > 0 || de === null) && (e.style.overflow = de.htmlOverflow, t.style.overflow = de.bodyOverflow, e.style.scrollbarGutter = de.htmlGutter, t.style.scrollbarGutter = de.bodyGutter, de = null));
3329
+ };
3330
+ }, ba = [
3331
+ { selector: '[data-aqmx-document-flow="fill"]', name: "document region" },
3332
+ { selector: "[data-aqmx-explorer-body]", name: "tree area" }
3333
+ ], Xt = 1, Ea = 1e3, Yt = (e) => e.getClientRects().length > 0, Ke = "Give the explorer's container a definite block size (for example height: 100dvh, or a flex column of definite height whose item has flex: 1 and min-height: 0; in a fresh React Router app also html and body at height: 100%) instead of an auto or only a minimum height.", ya = (e) => {
3334
+ if (!Yt(e)) return null;
3335
+ const t = e.getBoundingClientRect(), n = window.innerHeight;
3336
+ if (t.bottom > n + wa)
3337
+ return `[markdown-explorer] the explorer ends ${String(Math.round(t.bottom))}px down a ${String(n)}px viewport while lockDocumentScroll stops the page from scrolling, so the rest cannot be reached. ${Ke}`;
3338
+ if (t.height < Xt)
3339
+ return `[markdown-explorer] the explorer collapsed to ${String(Math.round(t.height))}px while lockDocumentScroll stops the page from scrolling, so nothing can be read. ${Ke}`;
3340
+ for (const { selector: r, name: o } of ba)
3341
+ for (const i of e.querySelectorAll(r)) {
3342
+ if (!Yt(i)) continue;
3343
+ const l = i.getBoundingClientRect().height;
3344
+ if (l < Xt)
3345
+ return `[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(l))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${Ke}`;
3346
+ }
3347
+ return null;
3348
+ }, xa = (e) => {
3349
+ let t = !1, n;
3350
+ const r = () => {
3351
+ n = void 0;
3352
+ const l = ya(e);
3353
+ l !== null && (t = !0, console.error(l));
3354
+ }, o = () => {
3355
+ t || (clearTimeout(n), n = setTimeout(r, Ea));
3356
+ }, i = typeof ResizeObserver > "u" ? null : new ResizeObserver(o);
3357
+ return i?.observe(e), window.addEventListener("resize", o), o(), () => {
3358
+ clearTimeout(n), i?.disconnect(), window.removeEventListener("resize", o);
3359
+ };
3360
+ }, Sa = (e, t) => {
3361
+ te(() => e ? ga() : void 0, [e]), te(() => {
3362
+ const n = t.current;
3363
+ if (!(!e || n === null))
3364
+ return xa(n);
3365
+ }, [e, t]);
3366
+ }, Jt = '[data-testid="markdown-explorer-view-switch"]', ka = [
3367
+ { control: Jt, successors: [Jt, '[data-testid="markdown-explorer-sheet-toggle"]'] },
3368
+ { control: '[data-testid="markdown-explorer-selection-open"]', successors: ['[data-testid="markdown-explorer-panel-frame"]'] }
3369
+ ], Ta = (e) => {
3370
+ for (const t of ka) {
3371
+ const n = e.closest(t.control);
3372
+ if (n !== null) return { element: n, control: t };
3373
+ }
3374
+ return null;
3375
+ }, Ra = (e, t) => {
3376
+ const n = _(null);
3377
+ te(() => {
3378
+ const o = (u) => {
3379
+ const m = e.current;
3380
+ n.current = m !== null && u instanceof Element && m.contains(u) ? Ta(u) : null;
3381
+ }, i = (u) => o(u.target);
3382
+ o(document.activeElement);
3383
+ const l = (u) => {
3384
+ const m = u.target;
3385
+ u.relatedTarget !== null || !(m instanceof Element) || queueMicrotask(() => {
3386
+ n.current?.element === m && m.isConnected && document.activeElement !== m && (n.current = null);
3387
+ });
3388
+ };
3389
+ return document.addEventListener("focusin", i), document.addEventListener("focusout", l), () => {
3390
+ document.removeEventListener("focusin", i), document.removeEventListener("focusout", l);
3391
+ };
3392
+ }, [e]);
3393
+ const r = _(t);
3394
+ H(() => {
3395
+ if (r.current === t) return;
3396
+ r.current = t;
3397
+ const o = n.current;
3398
+ if (o === null) return;
3399
+ const i = () => {
3400
+ const m = document.activeElement;
3401
+ if (m !== null && m !== document.body && m !== o.element) return !0;
3402
+ const f = e.current;
3403
+ if (f === null) return !0;
3404
+ for (const d of o.control.successors)
3405
+ for (const h of f.querySelectorAll(d))
3406
+ if (h !== o.element && (h.focus({ preventScroll: !0 }), document.activeElement === h))
3407
+ return !0;
3408
+ return !1;
3409
+ };
3410
+ if (i()) return;
3411
+ const l = e.current;
3412
+ if (l === null) return;
3413
+ const u = new MutationObserver(() => {
3414
+ i() && u.disconnect();
3415
+ });
3416
+ return u.observe(l, { childList: !0, subtree: !0 }), () => u.disconnect();
3417
+ }, [t, e]);
3418
+ }, Ma = it(() => import("./TreeLayout-eFQmzpNj.js").then((e) => ({ default: e.TreeLayout }))), Oa = it(() => import("./MultiLayout-Dy3DD_09.js").then((e) => ({ default: e.MultiLayout }))), Ca = 64, La = {
3419
+ request: (e) => {
3420
+ requestAnimationFrame(e);
3421
+ }
3422
+ }, Qt = (e) => {
3423
+ e.documents.clear(), e.trees.clear();
3424
+ }, Xe = (e, t) => {
3425
+ t.tree !== null && e.trees.seed(t.tree.sourceId, t.tree.result);
3426
+ for (const { path: n, document: r } of t.documents) e.documents.seed(n, r);
3427
+ }, Aa = (e, t) => {
3428
+ const [n, r] = B(() => ({ overrides: t, locale: e, labels: Rt(e, t) }));
3429
+ if (n.locale === e && Nr(n.overrides, t)) return n.labels;
3430
+ const o = { overrides: t, locale: e, labels: Rt(e, t) };
3431
+ return r(o), o.labels;
3432
+ }, Na = (e, t, n) => {
3433
+ const [r, o] = B(() => ({ scope: t, store: Wt(e, n) }));
3434
+ if (r.scope === t && r.store.storageKey === e && r.store.defaults === n) return r.store;
3435
+ const i = { scope: t, store: Wt(e, n) };
3436
+ return o(i), i.store;
3437
+ }, Ye = (e, t) => {
3438
+ const [n, r] = B(() => ({ scope: e, value: t() }));
3439
+ if (n.scope === e) return n.value;
3440
+ const o = { scope: e, value: t() };
3441
+ return r(o), o.value;
3442
+ }, Da = () => ia(La), en = "on", Pa = "off", $a = Object.freeze({ kind: "unavailable" }), Fa = (e) => {
3443
+ if (e !== void 0 && (e === null || typeof e != "object" || typeof e.convert != "function"))
3444
+ throw new TypeError("[markdown-explorer] draftConverter must be an object with a convert function");
3445
+ }, qa = (e, t) => {
3446
+ const n = ue(e.peek(t));
3447
+ return n === null || n.document.kind === "failure" ? se(t) : n.document.name;
3448
+ }, Qa = ({
3449
+ data: e,
3450
+ config: t,
3451
+ storageNamespace: n,
3452
+ locale: r,
3453
+ labels: o,
3454
+ theme: i,
3455
+ renderFrame: l,
3456
+ renderTreeFailure: u,
3457
+ lockDocumentScroll: m = !1,
3458
+ onMathDiagnostics: f,
3459
+ onEditGrant: d,
3460
+ draftConverter: h
3461
+ }) => {
3462
+ xr(n), Fa(h);
3463
+ const g = un(r), b = Dr(i), M = Aa(g, o), { revalidate: R } = Vn(), S = _(() => {
3464
+ }), A = $e(t.dataPath), [L] = B(() => {
3465
+ const k = aa({ dataPath: A, onScope: ($) => S.current($) }), O = { documents: $o({ client: k, capacity: Math.max(Ca, t.multiView.maxPanels * 2) }), trees: pa(k) };
3466
+ return Xe(O, e), kt(n, e.scope), { data: k, ...O, aligned: { pageData: e, storageNamespace: n, pendingReader: null } };
3467
+ });
3468
+ if (L.aligned.pageData !== e || L.aligned.storageNamespace !== n) {
3469
+ const k = L.aligned.pageData;
3470
+ L.aligned.pageData = e, L.aligned.storageNamespace = n, k !== e && (k.scope !== e.scope ? L.aligned.pendingReader = e : Xe(L, e)), kt(n, e.scope);
3471
+ }
3472
+ const E = Na(we(n).treeSettings, e.scope, t.defaultTreeSettings);
3473
+ H(() => {
3474
+ const k = L.aligned.pendingReader;
3475
+ k !== null && (L.aligned.pendingReader = null, Qt(L), Xe(L, k));
3476
+ }, [e, L]), H(() => {
3477
+ let k = !1;
3478
+ return S.current = (O) => {
3479
+ O === e.scope || k || (k = !0, O !== null && (Qt(L), Sr(n)), R());
3480
+ }, () => {
3481
+ S.current = () => {
3482
+ };
3483
+ };
3484
+ }, [e, R, L, n]);
3485
+ const v = _(t.settingsCookie);
3486
+ H(() => {
3487
+ v.current = t.settingsCookie;
3488
+ }, [t.settingsCookie]);
3489
+ const [a] = B(
3490
+ () => va(e.settings, (k) => {
3491
+ document.cookie = er(v.current, k, window.location.protocol === "https:");
3492
+ })
3493
+ ), s = Ye(e.scope, Da), w = Ye(e.scope, sa), T = _(M);
3494
+ H(() => {
3495
+ T.current = M;
3496
+ }, [M]);
3497
+ const C = Ye(
3498
+ e.scope,
3499
+ () => Vr({
3500
+ data: L.data,
3501
+ conflictLabels: () => ({ ours: T.current.conflictOurs, theirs: T.current.conflictTheirs }),
3502
+ onSaveSettled: (k, O) => {
3503
+ O.kind === "saved" && L.documents.refresh(k);
3504
+ const $ = $r(T.current, O, qa(L.documents, k));
3505
+ $ !== null && s.announce($);
3506
+ },
3507
+ sideBySideSetting: {
3508
+ read: () => Qe(we(n).editPreview) === en,
3509
+ write: (k) => Je(we(n).editPreview, k ? en : Pa)
3510
+ },
3511
+ editorShareSetting: {
3512
+ read: () => Hr(Qe(we(n).editSplit)),
3513
+ write: (k) => Je(we(n).editSplit, String(k))
3514
+ }
3515
+ })
3516
+ ), N = G(() => Te(e.notices.catch(() => [])), [e.notices]), q = e.sources.map((k) => k.id).join(`
3517
+ `), W = G(() => Qn(t, q.split(`
3518
+ `)), [t, q]), z = _(f);
3519
+ H(() => {
3520
+ z.current = f;
3521
+ }, [f]);
3522
+ const [j] = B(() => (k, O) => {
3523
+ z.current?.(k, O);
3524
+ }), Y = f === void 0 ? void 0 : j, V = _(h);
3525
+ H(() => {
3526
+ V.current = h;
3527
+ }, [h]);
3528
+ const [re] = B(() => {
3529
+ let k = !1;
3530
+ return {
3531
+ convert: (O, $) => {
3532
+ const I = V.current;
3533
+ return I === void 0 ? Promise.resolve($a) : I.convert(O, $);
3534
+ },
3535
+ prepare: () => {
3536
+ try {
3537
+ V.current?.prepare?.();
3538
+ } catch (O) {
3539
+ if (k) return;
3540
+ k = !0, console.error("[markdown-explorer] the draft converter's prepare threw", O);
3541
+ }
3542
+ }
3543
+ };
3544
+ }), p = h === void 0 ? void 0 : re, x = G(
3545
+ () => ({
3546
+ config: W,
3547
+ labels: M,
3548
+ locale: g,
3549
+ theme: b,
3550
+ storageNamespace: n,
3551
+ scope: e.scope,
3552
+ sources: e.sources,
3553
+ notices: N,
3554
+ documents: L.documents,
3555
+ trees: L.trees,
3556
+ data: L.data,
3557
+ viewSettings: a,
3558
+ treeSettings: E,
3559
+ announcer: s,
3560
+ reveals: w,
3561
+ edits: C,
3562
+ onEditGrant: d,
3563
+ draftConverter: p,
3564
+ renderTreeFailure: u,
3565
+ reportMathDiagnostics: Y
3566
+ }),
3567
+ [W, M, g, b, n, e.scope, e.sources, N, L, a, E, s, w, C, d, p, u, Y]
3568
+ );
3569
+ return /* @__PURE__ */ c(fn, { value: x, children: /* @__PURE__ */ c(Ia, { renderFrame: l, lockDocumentScroll: m }, e.scope) });
3570
+ }, _a = ({ ref: e, theme: t, view: n, children: r }) => {
3571
+ const [o] = B(bi);
3572
+ return /* @__PURE__ */ c("div", { ref: e, className: "aqmx-root", "data-aqmx-theme": t, "data-aqmx-view": n, "data-testid": "markdown-explorer", onKeyDownCapture: o.onKeyDownCapture, onKeyUpCapture: o.onKeyUpCapture, onBlurCapture: o.onBlurCapture, children: r });
3573
+ }, Ia = ({ renderFrame: e, lockDocumentScroll: t }) => {
3574
+ const { theme: n, labels: r } = D(), o = lt(), { hash: i } = nn(), l = Fe(), u = _(null);
3575
+ Sa(t, u), H(() => {
3576
+ o.kind === "redirect" && l(`${o.href}${i}`, "browse");
3577
+ }, [o, i, l]);
3578
+ const { location: m } = o, f = m.view;
3579
+ Ra(u, f);
3580
+ const d = m.view === "tree" ? /* @__PURE__ */ c(ke, { fallback: /* @__PURE__ */ c("section", { className: "aqmx-split-fallback", "aria-label": r.explorerRegion, "aria-busy": "true", "data-testid": "markdown-explorer-split-loading", ...et }), children: /* @__PURE__ */ c(Ma, { location: m }) }) : m.view === "multi" ? /* @__PURE__ */ c(ke, { fallback: /* @__PURE__ */ c("section", { className: "aqmx-stage-fallback", "aria-label": r.multiRegion, "aria-busy": "true", "data-testid": "markdown-explorer-stage-loading", ...et }), children: /* @__PURE__ */ c(Oa, { location: m }) }) : /* @__PURE__ */ c(ra, { location: m }), h = /* @__PURE__ */ F(_a, { ref: u, theme: n, view: f, children: [
3581
+ d,
3582
+ /* @__PURE__ */ c(so, {}),
3583
+ /* @__PURE__ */ c(oa, { holds: !0, testId: "markdown-explorer-announcer" })
3584
+ ] });
3585
+ return e === void 0 ? h : e({ view: f, children: h });
3586
+ }, es = kr({ submissions: "skip", otherPath: "skip", query: "skip", hashChange: "skip" });
3587
+ export {
3588
+ Tt as $,
3589
+ rt as A,
3590
+ Zt as B,
3591
+ Fr as C,
3592
+ na as D,
3593
+ Pl as E,
3594
+ Jr as F,
3595
+ ql as G,
3596
+ Me as H,
3597
+ Ya as I,
3598
+ yi as J,
3599
+ Ur as K,
3600
+ xn as L,
3601
+ Do as M,
3602
+ Qi as N,
3603
+ gl as O,
3604
+ ta as P,
3605
+ Lo as Q,
3606
+ Cl as R,
3607
+ Co as S,
3608
+ lt as T,
3609
+ oa as U,
3610
+ Ae as V,
3611
+ Tr as W,
3612
+ Mt as X,
3613
+ Cr as Y,
3614
+ dn as Z,
3615
+ Rr as _,
3616
+ qr as a,
3617
+ Qa as a0,
3618
+ Rt as a1,
3619
+ es as a2,
3620
+ _r as b,
3621
+ Fe as c,
3622
+ Jl as d,
3623
+ et as e,
3624
+ vl as f,
3625
+ So as g,
3626
+ Ir as h,
3627
+ Mo as i,
3628
+ xo as j,
3629
+ ae as k,
3630
+ Oo as l,
3631
+ ue as m,
3632
+ Eo as n,
3633
+ yo as o,
3634
+ me as p,
3635
+ lo as q,
3636
+ to as r,
3637
+ Fl as s,
3638
+ Xa as t,
3639
+ D as u,
3640
+ ko as v,
3641
+ Ja as w,
3642
+ hn as x,
3643
+ Il as y,
3644
+ _l as z
3645
+ };