@aiquants/markdown-explorer 0.22.0 → 0.24.0

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