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