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