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