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