@aiquants/markdown-explorer 0.10.0 → 0.12.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 (49) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/README.md +66 -6
  3. package/dist/EditSurface-BTAhzvHi.js +509 -0
  4. package/dist/EditSurface-Dfj6Sxxb.cjs +2 -0
  5. package/dist/ExplorerSplit-DekOjAUZ.cjs +1 -0
  6. package/dist/{ExplorerSplit-D0zf7Cr_.js → ExplorerSplit-MPHjw3nW.js} +251 -248
  7. package/dist/{MultiLayout-Jy9BKofx.js → MultiLayout-DtSW4rEQ.js} +4 -4
  8. package/dist/{MultiLayout-Bq10p3a3.cjs → MultiLayout-HMzVDYWq.cjs} +1 -1
  9. package/dist/{NativeScrollBar-Dt6xH5Mb.cjs → NativeScrollBar-B0AkVF3E.cjs} +1 -1
  10. package/dist/{NativeScrollBar-CyiyL47o.js → NativeScrollBar-CNQr7JY1.js} +1 -1
  11. package/dist/{TreeLayout-8pRo1ANN.js → TreeLayout-CJO9tOPq.js} +3 -3
  12. package/dist/{TreeLayout-kVWFEKJD.cjs → TreeLayout-_XQR-9tV.cjs} +1 -1
  13. package/dist/client/MarkdownExplorer.d.cts +3 -2
  14. package/dist/client/MarkdownExplorer.d.ts +3 -2
  15. package/dist/core/contracts.d.cts +17 -0
  16. package/dist/core/contracts.d.ts +17 -0
  17. package/dist/core/labels.d.cts +2 -0
  18. package/dist/core/labels.d.ts +2 -0
  19. package/dist/core/treeSettings.d.cts +2 -1
  20. package/dist/core/treeSettings.d.ts +2 -1
  21. package/dist/dataRoute-CH3yOKR0.cjs +1 -0
  22. package/dist/dataRoute-Pm_0ue_4.js +279 -0
  23. package/dist/index-DpIVKG8Y.cjs +13 -0
  24. package/dist/{index-CfcJEnrC.js → index-o6OpR4ND.js} +967 -907
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.d.cts +1 -1
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +9 -9
  29. package/dist/location-BUNWJ4eB.cjs +1 -0
  30. package/dist/{location-Dc1qNEGm.js → location-DWd6SQhN.js} +123 -112
  31. package/dist/{merge-D0aGvFKC.cjs → merge-Bs7o3GyP.cjs} +1 -1
  32. package/dist/{merge-SRCxtHk2.js → merge-DDJaJmMU.js} +1 -1
  33. package/dist/sanitizePolicy-BfUlXI5E.cjs +1 -0
  34. package/dist/sanitizePolicy-djLC3fRN.js +96 -0
  35. package/dist/sanitizeWorker.cjs +1 -1
  36. package/dist/sanitizeWorker.js +143 -226
  37. package/dist/server.cjs +1 -1
  38. package/dist/server.js +548 -540
  39. package/docs/behavior/dom-hooks.md +2 -2
  40. package/docs/behavior/localization.md +1 -0
  41. package/docs/behavior/security.md +2 -0
  42. package/package.json +3 -3
  43. package/dist/EditSurface-1Jf0CG-f.js +0 -371
  44. package/dist/EditSurface-B-l3Do_C.cjs +0 -2
  45. package/dist/ExplorerSplit-WX8afxrQ.cjs +0 -1
  46. package/dist/dataRoute-8pyILcjL.cjs +0 -1
  47. package/dist/dataRoute-Csl1WBDz.js +0 -278
  48. package/dist/index-sNJrKoGN.cjs +0 -13
  49. package/dist/location-CRYkEWiC.cjs +0 -1
@@ -0,0 +1,279 @@
1
+ const de = 4096;
2
+ const v = Object.freeze([
3
+ ".env*",
4
+ "*.env",
5
+ "*.env.*",
6
+ "*.env~*",
7
+ "*.env-*",
8
+ "*.env_*",
9
+ "*.env#*",
10
+ ".git",
11
+ ".git-credentials",
12
+ ".svn",
13
+ ".hg",
14
+ "node_modules",
15
+ "secrets",
16
+ ".secrets",
17
+ "secrets.json",
18
+ "secrets.yml",
19
+ "secrets.yaml",
20
+ "secrets.toml",
21
+ "secrets.ini",
22
+ "secrets.txt",
23
+ ".ssh",
24
+ ".aws",
25
+ ".gnupg",
26
+ ".docker",
27
+ ".kube",
28
+ ".terraform",
29
+ ".npmrc",
30
+ ".yarnrc",
31
+ ".yarnrc.yml",
32
+ ".netrc",
33
+ "_netrc",
34
+ ".pypirc",
35
+ ".pgpass",
36
+ ".my.cnf",
37
+ ".htpasswd",
38
+ ".vault-token",
39
+ "id_rsa*",
40
+ "id_dsa*",
41
+ "id_ecdsa*",
42
+ "id_ed25519*",
43
+ "*.pem",
44
+ "*.key",
45
+ "*.p8",
46
+ "*.p12",
47
+ "*.pfx",
48
+ "*.ppk",
49
+ "*.jks",
50
+ "*.keystore",
51
+ "*.kdbx",
52
+ "*credentials*.json",
53
+ "service-account*.json",
54
+ "*.tfstate",
55
+ "*.tfstate.*",
56
+ "*.tfvars",
57
+ "*.tfvars.json",
58
+ ".*_history",
59
+ "fish_history"
60
+ ]), w = /[\u0000-\u001f\u007f]/u, P = /\p{Cs}/u, pe = (e) => {
61
+ const t = e.split("/").filter((n) => n !== "").at(-1);
62
+ return t === void 0 ? e : t;
63
+ }, R = (e) => e.length > 0 && e.length <= 4096 && !P.test(e) && !w.test(e) && !e.includes("\\"), A = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), L = /(?:%[0-9A-Fa-f]{2})+/gu, D = new TextDecoder("utf-8"), k = /[/\\]/u, j = (e) => e.replace(
64
+ L,
65
+ (t) => D.decode(
66
+ Uint8Array.from(
67
+ t.slice(1).split("%").map((n) => Number.parseInt(n, 16))
68
+ )
69
+ )
70
+ ), $ = (e) => {
71
+ const t = [e];
72
+ let n = e;
73
+ for (let r = 0; r < 3 && n.includes("%"); r += 1) {
74
+ const s = j(n);
75
+ if (s === n) break;
76
+ t.push(s), n = s;
77
+ }
78
+ return t.map(A);
79
+ }, I = (e) => {
80
+ if (typeof e != "string" || e.trim() === "" || e.includes("/") || e.includes("\\"))
81
+ throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${JSON.stringify(e)}`);
82
+ const t = A(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
83
+ return new RegExp(`^${t}$`, "su");
84
+ }, y = (e) => {
85
+ if (!Array.isArray(e)) throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");
86
+ const t = e.map(I), n = (s) => s !== "" && t.some((i) => i.test(s)), r = (s) => s !== "" && $(s).some((i) => n(i) || i.split(k).some(n));
87
+ return {
88
+ deniesPath: (s) => s.split("/").some(r),
89
+ deniesName: r
90
+ };
91
+ }, C = y(v), z = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), Ee = (e) => e === void 0 ? C : e === !1 ? z : y(e), ye = (e, t) => y(e).deniesPath(t), b = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), U = Object.freeze(["file", "directory"]), X = Object.freeze(["video", "audio", "pdf"]), H = Object.freeze(["info", "warning", "danger"]), V = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), m = Object.freeze({ min: 1, max: 6 }), me = 1e4, u = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), ge = Object.freeze(["http:", "https:", "mailto:"]), h = 1024, F = /^[a-z0-9-]{1,64}$/u, M = "https://relative.invalid/", g = 64, d = (e, t) => typeof t == "string" && e.includes(t), o = (e) => typeof e == "string" ? JSON.stringify(e.length > g ? `${e.slice(0, g)}…` : e) : typeof e, K = (e) => d(b, e), G = (e) => d(U, e), W = (e) => d(X, e), Re = (e) => d(H, e), Y = (e) => d(V, e), _ = (e) => typeof e == "string" && F.test(e), Ae = (e, t) => {
92
+ if (typeof e != "string") return !1;
93
+ try {
94
+ return t.includes(new URL(e, M).protocol);
95
+ } catch {
96
+ return !1;
97
+ }
98
+ }, p = (e) => {
99
+ if (e === null || typeof e != "object") return "a failure must be an object";
100
+ const { reason: t, code: n } = e;
101
+ return K(t) ? n !== void 0 && !_(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${o(n)}` : null : `unknown failure reason ${o(t)}`;
102
+ }, J = (e) => {
103
+ if (e === null || typeof e != "object") return "an entry must be an object";
104
+ const { name: t, path: n, type: r, mimeType: s, modifiedAt: i, children: a, lazy: c } = e;
105
+ return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !R(n) ? "an entry needs an acceptable path" : G(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && !Number.isSafeInteger(i) ? `an entry modifiedAt must be a safe integer of epoch milliseconds; got ${o(i)}` : c !== void 0 && typeof c != "boolean" ? "an entry lazy flag must be a boolean" : a !== void 0 && !Array.isArray(a) ? "entry children must be an array" : r === "file" && (a !== void 0 || c === !0) ? "a file entry cannot have children or be lazy" : c === !0 && Array.isArray(a) && a.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${o(r)}`;
106
+ }, O = (e) => {
107
+ if (J(e) !== null) return !1;
108
+ const { children: t } = e;
109
+ return t === void 0 || t.every(O);
110
+ }, q = (e) => {
111
+ if (e === null || typeof e != "object") return !1;
112
+ const { status: t, entries: n, failure: r } = e;
113
+ return t === "ok" ? Array.isArray(n) && n.every(O) : t === "error" && p(r) === null;
114
+ }, be = (e) => {
115
+ if (e === null || typeof e != "object") return !1;
116
+ const { status: t, ancestors: n, failure: r } = e;
117
+ return t === "ok" ? n === null || x(n) : t === "error" && p(r) === null;
118
+ }, x = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && R(t)) && new Set(e).size === e.length, he = (e) => {
119
+ if (e === null || typeof e != "object") return !1;
120
+ const { status: t, source: n, ancestors: r, failure: s } = e;
121
+ return t === "ok" ? n === null && r === null || typeof n == "string" && n !== "" && x(r) : t === "error" && p(s) === null;
122
+ }, _e = (e) => {
123
+ if (e === null || typeof e != "object") return !1;
124
+ const { status: t, loadedAt: n } = e;
125
+ return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : q(e);
126
+ }, T = (e) => {
127
+ if (e === null || typeof e != "object") return "a heading must be an object";
128
+ const { text: t, depth: n, id: r } = e;
129
+ return typeof t != "string" || typeof r != "string" ? "a heading needs text and id strings" : typeof n != "number" || !Number.isInteger(n) || n < m.min || n > m.max ? `a heading depth must be an integer in 1..6; got ${String(n)}` : null;
130
+ }, B = (e) => {
131
+ if (e === null || typeof e != "object") return "a document must be an object";
132
+ const t = e, { kind: n } = t;
133
+ if (!Y(n)) return `unknown document kind ${o(n)}`;
134
+ if (n === "failure") return p(t.failure);
135
+ if (typeof t.name != "string") return "a document needs a name string";
136
+ switch (n) {
137
+ case "markdown": {
138
+ const { htmlContent: r, headings: s } = t;
139
+ if (typeof r != "string" || !Array.isArray(s)) return "a markdown document needs htmlContent and headings";
140
+ for (const i of s) {
141
+ const a = T(i);
142
+ if (a !== null) return a;
143
+ }
144
+ return Z(t.edit);
145
+ }
146
+ case "text":
147
+ return typeof t.text != "string" || typeof t.truncated != "boolean" ? "a text document needs text and truncated" : u(t.url) ? null : "a text document needs a root-relative url";
148
+ case "image":
149
+ return u(t.url) ? null : "an image document needs a root-relative url";
150
+ case "media":
151
+ return u(t.url) ? W(t.mediaType) ? null : `unknown media type ${o(t.mediaType)}` : "a media document needs a root-relative url";
152
+ case "file":
153
+ return u(t.url) ? null : "a file document needs a root-relative url";
154
+ }
155
+ }, Q = (e) => B(e) === null, Oe = (e) => Q(e) && (e.kind === "text" || e.kind === "failure"), Z = (e) => {
156
+ if (e === null) return null;
157
+ if (typeof e != "object") return "a markdown document's edit must be null or an object";
158
+ const { kind: t, href: n } = e;
159
+ return t === "inline" ? n === void 0 ? null : "an inline edit carries no href" : t !== "external" ? `unknown edit kind ${o(t)}` : ee(n) ? null : `an external edit needs an absolute https: href; got ${o(n)}`;
160
+ }, ee = (e) => {
161
+ if (typeof e != "string") return !1;
162
+ try {
163
+ return new URL(e).protocol === "https:";
164
+ } catch {
165
+ return !1;
166
+ }
167
+ }, f = (e) => typeof e == "string" && e.length > 0 && e.length <= h, te = (e) => u(e.href) ? null : `a grant needs a root-relative href; got ${o(e.href)}`, ne = (e) => {
168
+ if (e === null || typeof e != "object") return "a revision must be an object";
169
+ const { id: t, modifiedAt: n, size: r, author: s, kept: i, current: a } = e;
170
+ return f(t) ? n !== null && (typeof n != "string" || Number.isNaN(Date.parse(n))) ? `a revision's modifiedAt must be a date-time string or null; got ${o(n)}` : typeof r != "number" || !Number.isSafeInteger(r) || r < 0 ? `a revision's size must be a non-negative integer; got ${o(r)}` : s !== null && typeof s != "string" ? `a revision's author must be a string or null; got ${o(s)}` : typeof i != "boolean" || typeof a != "boolean" ? "a revision needs kept and current booleans" : null : `a revision id must be a non-empty string of at most ${h} characters; got ${o(t)}`;
171
+ }, l = (e, t) => {
172
+ if (e === null || typeof e != "object") return "an answer must be an object";
173
+ const n = e, { kind: r } = n;
174
+ if (r === "failure") return p(n.failure);
175
+ if (typeof r != "string" || !t.includes(r)) return `unexpected answer kind ${o(r)}`;
176
+ switch (r) {
177
+ case "grant":
178
+ return te(n);
179
+ case "edit":
180
+ return typeof n.text != "string" || typeof n.history != "boolean" ? "an edit source needs text and history" : f(n.version) ? null : `an edit source needs a version; got ${o(n.version)}`;
181
+ case "saved":
182
+ return f(n.version) ? null : `a saved answer needs a version; got ${o(n.version)}`;
183
+ case "conflict":
184
+ return typeof n.text != "string" ? "a conflict needs the current text" : f(n.version) ? null : `a conflict needs the current version; got ${o(n.version)}`;
185
+ case "preview": {
186
+ const { htmlContent: s, headings: i } = n;
187
+ if (typeof s != "string" || !Array.isArray(i)) return "a preview needs htmlContent and headings";
188
+ for (const a of i) {
189
+ const c = T(a);
190
+ if (c !== null) return c;
191
+ }
192
+ return null;
193
+ }
194
+ case "revisions": {
195
+ if (!Array.isArray(n.revisions)) return "revisions need an array";
196
+ for (const s of n.revisions) {
197
+ const i = ne(s);
198
+ if (i !== null) return i;
199
+ }
200
+ return null;
201
+ }
202
+ case "revision":
203
+ return typeof n.text != "string" ? "a revision answer needs text" : f(n.id) ? null : `a revision answer needs an id; got ${o(n.id)}`;
204
+ default:
205
+ return `unexpected answer kind ${o(r)}`;
206
+ }
207
+ }, re = Object.freeze(["edit", "grant"]), se = Object.freeze(["saved", "conflict", "grant"]), S = Object.freeze(["preview"]), oe = Object.freeze(["revisions"]), ie = Object.freeze(["revision"]), xe = (e) => l(e, re) === null, Te = (e) => l(e, se) === null, Se = (e) => l(e, S) === null, Ne = (e) => l(e, oe) === null, ve = (e) => l(e, ie) === null, we = (e) => e !== null && typeof e == "object" && e.kind === "unavailable" ? null : l(e, S), Pe = (e, t) => ({ kind: "failure", failure: ae(e, t) }), ae = (e, t) => _(t) ? { reason: e, code: t } : { reason: e }, ce = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "text", "edit", "save", "preview", "revisions", "revision", "refresh", "asset", "link-card"]), E = Object.freeze({ source: "source", path: "path", version: "v", base: "base", revision: "revision", display: "as" }), le = "asset", ue = "link-card", Le = (e, t, n) => {
208
+ const r = `${e}/${le}?${E.path}=${encodeURIComponent(t)}`;
209
+ return n === null ? r : `${r}&${E.version}=${encodeURIComponent(n)}`;
210
+ }, N = "text", De = (e) => {
211
+ if (!e.includes("?")) throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);
212
+ return `${e}&${E.display}=${N}`;
213
+ }, ke = (e) => {
214
+ const t = e.getAll(E.display);
215
+ return t.length === 0 ? "file" : t.length === 1 && t[0] === N ? "text" : null;
216
+ }, je = (e) => `${e}/${ue}`, $e = "X-Markdown-Explorer-Scope", Ie = "X-Markdown-Explorer", Ce = "refresh", ze = "edit", Ue = "text/markdown", Xe = (e) => ce.includes(e), fe = Object.freeze({
217
+ invalid: 400,
218
+ unauthorized: 401,
219
+ forbidden: 403,
220
+ "not-found": 404,
221
+ "too-large": 413,
222
+ "not-configured": 500,
223
+ unsupported: 500,
224
+ failed: 500
225
+ }), He = (e) => {
226
+ const [t, ...n] = b.filter((r) => fe[r] === e);
227
+ return t !== void 0 && n.length === 0 ? t : "failed";
228
+ };
229
+ export {
230
+ ke as A,
231
+ Ue as B,
232
+ ye as C,
233
+ v as D,
234
+ me as E,
235
+ pe as F,
236
+ De as G,
237
+ He as H,
238
+ Oe as I,
239
+ he as J,
240
+ be as K,
241
+ q as L,
242
+ de as M,
243
+ p as N,
244
+ _e as O,
245
+ ve as P,
246
+ Ne as Q,
247
+ Se as R,
248
+ Te as S,
249
+ xe as T,
250
+ Q as U,
251
+ h as V,
252
+ b as W,
253
+ je as a,
254
+ K as b,
255
+ _ as c,
256
+ we as d,
257
+ Le as e,
258
+ ae as f,
259
+ Re as g,
260
+ Ae as h,
261
+ R as i,
262
+ W as j,
263
+ B as k,
264
+ f as l,
265
+ T as m,
266
+ u as n,
267
+ J as o,
268
+ ge as p,
269
+ Ee as q,
270
+ ne as r,
271
+ Xe as s,
272
+ fe as t,
273
+ Ie as u,
274
+ Ce as v,
275
+ ze as w,
276
+ $e as x,
277
+ E as y,
278
+ Pe as z
279
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";const l=require("react/jsx-runtime"),i=require("react"),X=require("react-router"),q=require("./location-BUNWJ4eB.cjs"),N=require("./dataRoute-CH3yOKR0.cjs"),de=require("@aiquants/markdown"),$e=require("@aiquants/markdown/source-lines"),bn=require("@aiquants/markdown/viewer-settings"),Q=require("./storage-Dgi4JXaB.cjs");function yn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const b=yn(i),qe=Object.freeze(["en","ja"]),Tt="en",Ct=Object.freeze({panelMoved:Object.freeze(["title","column","position"]),panelMoveUnavailable:Object.freeze(["title","move"]),panelDragStarted:Object.freeze(["title"]),panelDragCancelled:Object.freeze(["title"]),multiColumnRegion:Object.freeze(["column"])}),Sn=/\{(\w+)\}/gu,Ot={explorerRegion:"Explorer",sourceLabel:"Source",refreshTreeLabel:"Refresh tree",refreshTree:"Reload the tree and the open documents from the source",treeRefreshed:"Reloaded the tree from the source",treeRefreshFailed:e=>`Could not reload the tree: ${e}`,refreshDocumentLabel:"Refresh document",refreshDocument:"Reload the document from the source",refreshDocumentNamed:e=>`Refresh ${e}`,documentRefreshed:e=>`Reloaded ${e}`,documentRefreshFailed:e=>`Could not reload the document: ${e}`,showMarkupLabel:"Source",showMarkup:"Show the document's Markdown as written",showMarkupNamed:e=>`Source of ${e}`,editDocumentLabel:"Edit",editDocument:"Edit the document's Markdown (or double-click the document)",editDocumentNamed:e=>`Edit ${e}`,editExternallyLabel:"Open in its editor",editExternally:"Open the document in its own editor, in a new tab",editExternallyNamed:e=>`Open ${e} in its editor`,editorRegion:e=>`Editing ${e}`,editorLabel:e=>`Markdown of ${e}`,editLoading:"Loading the source for editing…",editToolbar:"Editor",saveDraft:"Save",saveDraftTooltip:"Save the draft (Ctrl+S, or ⌘S on a Mac)",closeEditor:"Close editor",previewToggle:"Preview",historyOpen:"History",draftUnsaved:"Unsaved changes",draftSaving:"Saving…",draftSaved:"Saved",draftSavedMerged:"Saved, merged with changes saved elsewhere",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`,draftSaveFailed:e=>`Could not save: ${e}`,documentSaved:e=>`Saved ${e}`,documentSavedMerged:e=>`Saved ${e}, merged with changes saved elsewhere`,conflictOurs:"your draft",conflictTheirs:"saved elsewhere",conflictUseOurs:"Use my lines",conflictUseTheirs:"Use the saved lines",conflictKeepBoth:"Keep both",conflictNext:"Next conflict",editGrantTitle:"Editing needs your permission",editGrantBody:"Allow this site to change documents on your behalf. You are asked once; signing out asks again.",editGrantAction:"Grant permission",editGrantRetry:"Try again",unsavedTitle:"Discard unsaved changes?",unsavedBody:e=>`${e} has changes that are not saved.`,unsavedDiscard:"Discard changes",unsavedStay:"Keep editing",historyTitle:e=>`Revisions of ${e}`,historyLoading:"Loading the revisions…",historyEmpty:"No revisions are kept for this document.",historyCurrent:"Current",historyKept:"Kept",historyEntry:(e,t)=>t===""?e:`${e} by ${t}`,historyRestore:"Put into the draft",historyClose:"Close",historyRestored:e=>`Put the revision into the draft of ${e}; save to keep it`,previewRegion:"Preview",previewUpdating:"Updating the preview…",previewFailed:e=>`Could not preview: ${e}`,expandAll:"Expand all folders",collapseAll:"Collapse all folders",treeSettings:"Tree settings",switchToMulti:"Open in the multi-panel view",switchToTree:"Open in the tree view",resizeExplorer:"Resize the explorer",showExplorer:"Show the explorer",hideExplorer:"Close the explorer",treeRegion:"Documents",treeLoading:"Loading the tree…",treeEmptyTitle:"Nothing to show",treeEmptyBody:"This source has no documents you can open.",folderLoadFailed:"This folder could not be loaded.",loopFolderName:e=>`${e} (already open above)`,foldersLoadFailedNamed:e=>`${new Intl.ListFormat("en",{type:"conjunction"}).format(e)} could not be loaded`,foldersLoading:e=>e===1?"Loading 1 folder…":`Loading ${String(e)} folders…`,expandAllStarted:"Opening all folders…",expandAllProgress:(e,t)=>`Opening all folders (${String(e)} opened, ${String(t)} loading)…`,expandAllDone:(e,t,n)=>{const r=`Opened ${String(e)} ${e===1?"folder":"folders"}`;return t>0?`${r}; ${String(t)} could not be loaded`:n?e===0?"All folders are already open":`${r}; every folder is open`:r},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`,expandAllDepthLimit:(e,t)=>`Opened ${String(e)} ${e===1?"folder":"folders"}; folders more than ${String(t)} ${t===1?"level":"levels"} deep stay closed`,treeEntryKindDirectory:"directory",treeEntryKindFile:"file",treeScrollUp:"Scroll up",treeScrollDown:"Scroll down",treeScrollToTop:"Top",treeScrollToBottom:"Bottom",selectionTitle:e=>`Selected (${String(e)})`,clearSelection:"Clear the selection",openSelectionInMulti:e=>`Open ${String(e)} in panels`,removeFromSelection:e=>`Remove ${e} from the selection`,settingSortMode:"Sort order",sortNative:"Source order",sortAscending:"Name A→Z",sortDescending:"Name Z→A",sortOldest:"Modified old→new",sortNewest:"Modified new→old",settingFolderPlacement:"Folders",folderPlacementMixed:"Mixed",folderPlacementFirst:"First",folderPlacementLast:"Last",settingSelectionMode:"Selection",selectionSingle:"Single",selectionMultiple:"Multiple",selectionNone:"Off",settingDoubleClick:"Double-click",doubleClickRecursive:"Expand all levels",doubleClickToggle:"Toggle",settingExpandIconSize:"Expander size",expandIconSizeValue:e=>`${String(e)} px`,settingAlwaysExpanded:"Always expanded",settingRevealDocument:"Reveal the open document",settingRemoveRootIndent:"No root indent",settingTreeLines:"Tree lines",settingExpandIcons:"Expanders",settingDirectoryIcons:"Folder icons",settingFileIcons:"File icons",settingOn:"On",settingOff:"Off",settingAnnouncement:(e,t)=>`${e}: ${t}`,documentRegion:"Document",documentEmpty:"Select a document in the explorer.",documentLoading:"Loading the document…",markupLoading:"Loading the source…",documentShown:e=>`Showing ${e}`,documentFailed:(e,t)=>`${e}: ${t}`,announcementSequence:e=>e.map(t=>/[.!?]$/u.test(t)?t:`${t}.`).join(" "),textTruncated:"Only the beginning of this file is shown.",inertLink:"This link points outside the source and cannot be opened.",failureUnauthorizedTitle:"Your session has expired",failureUnauthorizedBody:"Reload the page to sign in again.",failureForbiddenTitle:"Access denied",failureForbiddenBody:"You do not have permission to open this.",failureNotFoundTitle:"Not found",failureNotFoundBody:"It may have been moved or deleted.",failureNotConfiguredTitle:"This source is not set up",failureNotConfiguredBody:"Ask your administrator to configure it.",failureInvalidTitle:"Invalid address",failureInvalidBody:"The document path in this address cannot be used.",failureTooLargeTitle:"Too large to display",failureTooLargeBody:"This file exceeds the size that can be displayed.",failureUnsupportedTitle:"Cannot be displayed",failureUnsupportedBody:"This type of file cannot be shown here.",failureFailedTitle:"Something went wrong",failureFailedBody:"Try again in a moment.",retry:"Try again",reloadPage:"Reload the page",imageZoomIn:"Zoom in",imageZoomOut:"Zoom out",imageFit:"Fit to the view",imageFitLevel:"Fit",imageZoomLevel:e=>`${String(e)}%`,openInNewTab:"Open in a new tab",download:"Download",copyText:"Copy the text",copiedText:"Copied the text",copyTextFailed:"Could not copy the text",mediaUnsupported:"Your browser cannot play this file.",fileNotShown:"This file cannot be shown here. Download it to open it.",viewerLoading:"Loading data...",viewerErrorPrefix:"Error: ",viewerStyleTitle:"Display Style",viewerSelectStyle:"Select display style",viewerPinStyle:"Pin style selector",viewerUnpinStyle:"Unpin style selector",viewerErrorTitle:"An error occurred",viewerMissingImage:"Image not found",viewerOpenToc:"Open table of contents",viewerTocTitle:"Table of contents",viewerPinToc:"Pin table of contents",viewerUnpinToc:"Unpin table of contents",viewerSelectAlign:"Select alignment",viewerAlignTitle:"Alignment",viewerPinAlign:"Pin alignment selector",viewerUnpinAlign:"Unpin alignment selector",viewerAlignLeft:"Align left",viewerAlignCenter:"Align center",viewerAlignRight:"Align right",viewerMermaidInteractionMode:"Mouse interaction mode",viewerMermaidModeNone:"No interaction",viewerMermaidModeZoom:"Zoom only",viewerMermaidModePan:"Pan only (drag)",viewerMermaidModePanShift:"Pan only (Shift+drag)",viewerMermaidModeBoth:"Zoom and pan (drag)",viewerMermaidModeBothShift:"Zoom and pan (Shift+drag)",viewerMermaidZoomIn:"Zoom In",viewerMermaidZoomOut:"Zoom Out",viewerMermaidResetView:"Reset View",viewerMermaidRetry:"Try again",viewerEmbeddedVideo:"embedded video",viewerEmbeddedPost:"embedded post",viewerEmbeddedFrame:"Embedded content",multiRegion:"Panels",multiEmpty:"Select documents in the explorer to open them side by side.",panelLimit:e=>`You can open up to ${String(e)} panels at once.`,panelOpened:e=>`Opened ${e}`,panelClosed:e=>`Closed ${e}`,panelAlreadyOpen:e=>`${e} is already open`,panelHidden:e=>`Hid ${e}`,panelShown:e=>`Showed ${e}`,panelMaximized:e=>`Maximized ${e}`,panelRestored:e=>`Restored ${e} to its size`,panelHide:"Hide the panel",panelMaximize:"Maximize the panel",panelRestore:"Restore the panel to its size",panelClose:"Close the panel",panelSwitchToCustomDrag:"Switch to the custom drag mode",panelSwitchToNormalDrag:"Back to the normal drag mode",panelCustomDragBadge:"Custom",panelMovePreviousColumn:"Move to the previous column",panelMoveNextColumn:"Move to the next column",panelMoveUp:"Move up",panelMoveDown:"Move down",panelMoved:"Moved {title} to column {column}, position {position}",panelMoveUnavailable:"{move} is not available for {title}",panelDragStarted:"Picked up {title}",panelDragCancelled:"Kept {title} where it was",hiddenPanelsTitle:"Hidden panels:",hiddenPanelBadge:"Hidden",hiddenPanelNotice:"This panel is hidden",multiColumnEmpty:"This column is empty",multiColumnRegion:"Column {column}",panelDropHere:"Drop the panel here"},kn={explorerRegion:"エクスプローラー",sourceLabel:"ソース",refreshTreeLabel:"ツリーを更新",refreshTree:"ソースからツリーと開いている文書を読み込み直す",treeRefreshed:"ツリーをソースから読み込み直しました",treeRefreshFailed:e=>`ツリーを読み込み直せませんでした: ${e}`,refreshDocumentLabel:"文書を更新",refreshDocument:"ソースから文書を読み込み直す",refreshDocumentNamed:e=>`${e} を更新`,documentRefreshed:e=>`${e} を読み込み直しました`,documentRefreshFailed:e=>`文書を読み込み直せませんでした: ${e}`,showMarkupLabel:"ソース",showMarkup:"文書の Markdown を書いたまま表示",showMarkupNamed:e=>`${e} のソース`,editDocumentLabel:"編集",editDocument:"文書の Markdown を編集 (文書のダブルクリックでも)",editDocumentNamed:e=>`${e} を編集`,editExternallyLabel:"元のエディタで開く",editExternally:"文書を元のエディタで、新しいタブに開く",editExternallyNamed:e=>`${e} を元のエディタで開く`,editorRegion:e=>`${e} を編集中`,editorLabel:e=>`${e} の Markdown`,editLoading:"編集のためにソースを読み込み中…",editToolbar:"エディタ",saveDraft:"保存",saveDraftTooltip:"下書きを保存 (Ctrl+S、Mac は ⌘S)",closeEditor:"編集を閉じる",previewToggle:"プレビュー",historyOpen:"履歴",draftUnsaved:"保存していない変更があります",draftSaving:"保存中…",draftSaved:"保存しました",draftSavedMerged:"ほかで保存された変更と統合して保存しました",draftConflicts:e=>`ほかで保存された変更と ${e} か所が重なりました。残す方を選んでから保存してください`,draftSaveFailed:e=>`保存できませんでした: ${e}`,documentSaved:e=>`${e} を保存しました`,documentSavedMerged:e=>`${e} を、ほかで保存された変更と統合して保存しました`,conflictOurs:"あなたの下書き",conflictTheirs:"ほかで保存された版",conflictUseOurs:"自分の行を使う",conflictUseTheirs:"保存された行を使う",conflictKeepBoth:"両方を残す",conflictNext:"次の衝突へ",editGrantTitle:"編集には許可が必要です",editGrantBody:"このサイトがあなたに代わって文書を変えることを許可してください。尋ねるのは 1 回だけで、サインアウトすると次にまた尋ねます。",editGrantAction:"許可する",editGrantRetry:"もう一度試す",unsavedTitle:"保存していない変更を破棄しますか?",unsavedBody:e=>`${e} に保存していない変更があります。`,unsavedDiscard:"変更を破棄",unsavedStay:"編集を続ける",historyTitle:e=>`${e} の版`,historyLoading:"版の一覧を読み込み中…",historyEmpty:"この文書の版は残っていません。",historyCurrent:"現在の版",historyKept:"保持",historyEntry:(e,t)=>t===""?e:`${e} (${t})`,historyRestore:"下書きに戻す",historyClose:"閉じる",historyRestored:e=>`${e} の下書きに版を戻しました。残すには保存してください`,previewRegion:"プレビュー",previewUpdating:"プレビューを更新中…",previewFailed:e=>`プレビューできませんでした: ${e}`,expandAll:"すべてのフォルダーを展開",collapseAll:"すべてのフォルダーを折りたたむ",treeSettings:"ツリーの設定",switchToMulti:"マルチビューで開く",switchToTree:"ツリービューで開く",resizeExplorer:"エクスプローラーの幅を変更",showExplorer:"エクスプローラーを開く",hideExplorer:"エクスプローラーを閉じる",treeRegion:"文書の一覧",treeLoading:"ツリーを読み込み中…",treeEmptyTitle:"表示できるファイルがありません",treeEmptyBody:"このソースには開ける文書がありません。",folderLoadFailed:"このフォルダーを読み込めませんでした。",loopFolderName:e=>`${e} (上の階層で開いています)`,foldersLoadFailedNamed:e=>`${new Intl.ListFormat("ja",{type:"conjunction"}).format(e)} を読み込めませんでした`,foldersLoading:e=>`フォルダーを ${String(e)} 件読み込み中…`,expandAllStarted:"すべてのフォルダーを展開しています…",expandAllProgress:(e,t)=>`すべてのフォルダーを展開中 (展開 ${String(e)} 件、読み込み中 ${String(t)} 件)…`,expandAllDone:(e,t,n)=>{const r=`${String(e)} 件のフォルダーを展開しました`;return t>0?`${r}。うち ${String(t)} 件は読み込めませんでした`:n?e===0?"すべてのフォルダーが既に開いています":`${r}。すべてのフォルダーが開いています`:r},expandAllFolderLimit:(e,t,n)=>`${String(e)} 件のフォルダーを展開し、読み込みの上限 (${String(t)} 件) で止めました。続けるには「${n}」をもう一度押してください`,expandAllDepthLimit:(e,t)=>`${String(e)} 件のフォルダーを展開しました。深さ ${String(t)} 階層より下のフォルダーは閉じたままです`,treeEntryKindDirectory:"ディレクトリ",treeEntryKindFile:"ファイル",treeScrollUp:"上へスクロール",treeScrollDown:"下へスクロール",treeScrollToTop:"先頭へ",treeScrollToBottom:"末尾へ",selectionTitle:e=>`選択中 (${String(e)})`,clearSelection:"選択を解除",openSelectionInMulti:e=>`${String(e)} 件をパネルで開く`,removeFromSelection:e=>`${e} を選択から外す`,settingSortMode:"並び順",sortNative:"取得順",sortAscending:"名前の昇順",sortDescending:"名前の降順",sortOldest:"更新日時の昇順 (古い順)",sortNewest:"更新日時の降順 (新しい順)",settingFolderPlacement:"フォルダーの位置",folderPlacementMixed:"混ぜる",folderPlacementFirst:"先に",folderPlacementLast:"後に",settingSelectionMode:"選択",selectionSingle:"1 件",selectionMultiple:"複数",selectionNone:"オフ",settingDoubleClick:"ダブルクリック",doubleClickRecursive:"下の階層まで展開",doubleClickToggle:"開閉",settingExpandIconSize:"展開アイコンの大きさ",expandIconSizeValue:e=>`${String(e)} px`,settingAlwaysExpanded:"常に展開",settingRevealDocument:"開いた文書をツリーで表示",settingRemoveRootIndent:"最上位の字下げなし",settingTreeLines:"ツリーの線",settingExpandIcons:"展開アイコン",settingDirectoryIcons:"フォルダーのアイコン",settingFileIcons:"ファイルのアイコン",settingOn:"オン",settingOff:"オフ",settingAnnouncement:(e,t)=>`${e}: ${t}`,documentRegion:"文書",documentEmpty:"エクスプローラーで文書を選んでください。",documentLoading:"文書を読み込み中…",markupLoading:"ソースを読み込み中…",documentShown:e=>`${e} を表示しています`,documentFailed:(e,t)=>`${e}: ${t}`,announcementSequence:e=>e.map(t=>/[。!?]$/u.test(t)?t:`${t}。`).join(""),textTruncated:"このファイルは先頭だけを表示しています。",inertLink:"リンク先がソースの外にあるため開けません。",failureUnauthorizedTitle:"セッションの有効期限が切れました",failureUnauthorizedBody:"ページを再読み込みして、もう一度サインインしてください。",failureForbiddenTitle:"アクセスが許可されていません",failureForbiddenBody:"これを開く権限がありません。",failureNotFoundTitle:"見つかりません",failureNotFoundBody:"移動または削除された可能性があります。",failureNotConfiguredTitle:"このソースは設定されていません",failureNotConfiguredBody:"管理者に設定を依頼してください。",failureInvalidTitle:"アドレスが正しくありません",failureInvalidBody:"このアドレスに含まれる文書の経路は使えません。",failureTooLargeTitle:"大きすぎて表示できません",failureTooLargeBody:"このファイルは表示できる大きさを超えています。",failureUnsupportedTitle:"表示できない形式です",failureUnsupportedBody:"この種類のファイルはここでは表示できません。",failureFailedTitle:"読み込みに失敗しました",failureFailedBody:"しばらくしてからもう一度お試しください。",retry:"再試行",reloadPage:"ページを再読み込み",imageZoomIn:"拡大",imageZoomOut:"縮小",imageFit:"画面に合わせる",imageFitLevel:"全体",imageZoomLevel:e=>`${String(e)}%`,openInNewTab:"新しいタブで開く",download:"ダウンロード",copyText:"テキストをコピー",copiedText:"テキストをコピーしました",copyTextFailed:"テキストをコピーできませんでした",mediaUnsupported:"このブラウザではこのファイルを再生できません。",fileNotShown:"このファイルはここでは表示できません。ダウンロードして開いてください。",viewerLoading:"データを読み込み中...",viewerErrorPrefix:"エラー: ",viewerStyleTitle:"表示スタイル",viewerSelectStyle:"表示スタイルを選択",viewerPinStyle:"スタイル選択をピン留め",viewerUnpinStyle:"スタイル選択のピン留めを解除",viewerErrorTitle:"エラーが発生しました",viewerMissingImage:"画像が見つかりません",viewerOpenToc:"目次を開く",viewerTocTitle:"目次",viewerPinToc:"目次をピン留め",viewerUnpinToc:"目次のピン留めを解除",viewerSelectAlign:"揃えを選択",viewerAlignTitle:"揃え",viewerPinAlign:"揃え選択をピン留め",viewerUnpinAlign:"揃え選択のピン留めを解除",viewerAlignLeft:"左揃え",viewerAlignCenter:"中央揃え",viewerAlignRight:"右揃え",viewerMermaidInteractionMode:"マウス操作モード",viewerMermaidModeNone:"操作なし",viewerMermaidModeZoom:"拡大縮小のみ",viewerMermaidModePan:"移動のみ (左ドラッグ)",viewerMermaidModePanShift:"移動のみ (Shift+ドラッグ)",viewerMermaidModeBoth:"拡大縮小+移動 (左ドラッグ)",viewerMermaidModeBothShift:"拡大縮小+移動 (Shift+ドラッグ)",viewerMermaidZoomIn:"拡大",viewerMermaidZoomOut:"縮小",viewerMermaidResetView:"表示を元に戻す",viewerMermaidRetry:"再試行",viewerEmbeddedVideo:"埋め込みの動画",viewerEmbeddedPost:"埋め込みの投稿",viewerEmbeddedFrame:"埋め込みのコンテンツ",multiRegion:"パネル",multiEmpty:"エクスプローラーで文書を選ぶと、ここに並べて開きます。",panelLimit:e=>`同時に開けるのは ${String(e)} パネルまでです。`,panelOpened:e=>`${e} を開きました`,panelClosed:e=>`${e} を閉じました`,panelAlreadyOpen:e=>`${e} は既に開いています`,panelHidden:e=>`${e} を隠しました`,panelShown:e=>`${e} を表示しました`,panelMaximized:e=>`${e} を最大化しました`,panelRestored:e=>`${e} を元のサイズに戻しました`,panelHide:"パネルを隠す",panelMaximize:"パネルを最大化",panelRestore:"パネルを元のサイズに戻す",panelClose:"パネルを閉じる",panelSwitchToCustomDrag:"カスタムのドラッグの方式に切り替え",panelSwitchToNormalDrag:"通常のドラッグの方式に戻す",panelCustomDragBadge:"カスタム",panelMovePreviousColumn:"前の列へ移動",panelMoveNextColumn:"次の列へ移動",panelMoveUp:"上へ移動",panelMoveDown:"下へ移動",panelMoved:"{title} を {column} 列目の {position} 番目へ移動しました",panelMoveUnavailable:"{title} は「{move}」できません",panelDragStarted:"{title} を持ち上げました",panelDragCancelled:"{title} の移動を取り消しました",hiddenPanelsTitle:"隠したパネル:",hiddenPanelBadge:"非表示",hiddenPanelNotice:"このパネルは隠しています",multiColumnEmpty:"この列は空です",multiColumnRegion:"{column} 列目",panelDropHere:"ここへパネルをドロップ"},At=Object.freeze({en:Object.freeze(Ot),ja:Object.freeze(kn)}),Ze=Object.freeze(Object.keys(Ot)),Rn=new Set(Ze),Tn=e=>Rn.has(e),we=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,Lt=e=>{if(e===void 0)return Tt;if(qe.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${qe.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${we(e)}`)},Ie=(e,t)=>{const n=At[Lt(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${we(t)}`);if(!q.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${we(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Tn(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Ze.join(", ")}`);const a=r[s];if(a===void 0)continue;const u=typeof n[s];if(typeof a!==u)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${u}; got ${we(a)}`);if(typeof a=="string"&&a.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const v=Ct[s];if(typeof a=="string"&&v!==void 0){for(const[,m]of a.matchAll(Sn))if(!v.includes(m??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(m)}}; it accepts ${v.map(f=>`{${f}}`).join(", ")}`)}o[s]=a}return Object.freeze(o)},Cn=(e,t)=>{if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const n=e,r=t,o=Object.keys(n),s=Object.keys(r);return o.length===s.length&&s.every(a=>Object.hasOwn(n,a)&&Object.is(n[a],r[a]))},Be=Object.freeze(["light","dark"]),On=e=>{if(e===void 0)return"light";if(Be.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${Be.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},jt=i.createContext(null),P=()=>{const e=i.use(jt);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},ue=e=>{const{viewSettings:t}=P(),n=()=>e(t.getSnapshot());return i.useSyncExternalStore(t.subscribe,n,n)},Se=()=>{const{config:e}=P(),t=X.useParams()["*"],[n]=X.useSearchParams(),r=n.toString();return i.useMemo(()=>q.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},Mt={unauthorized:["failureUnauthorizedTitle","failureUnauthorizedBody"],forbidden:["failureForbiddenTitle","failureForbiddenBody"],"not-found":["failureNotFoundTitle","failureNotFoundBody"],"not-configured":["failureNotConfiguredTitle","failureNotConfiguredBody"],invalid:["failureInvalidTitle","failureInvalidBody"],"too-large":["failureTooLargeTitle","failureTooLargeBody"],unsupported:["failureUnsupportedTitle","failureUnsupportedBody"],failed:["failureFailedTitle","failureFailedBody"]},te=(e,t)=>e[Mt[t][0]],le=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=P(),s=te(o,e.reason),a=o[Mt[e.reason][1]],u=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning";return l.jsxs("div",{className:"aqmx-callout",role:t?"alert":void 0,"data-aqmx-tone":u,"data-testid":r===null?void 0:r,"data-aqmx-failure":r===null?void 0:e.reason,children:[l.jsx("p",{className:"aqmx-callout-title",children:s}),l.jsx("p",{className:"aqmx-callout-body",children:a}),e.reason==="unauthorized"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>window.location.reload(),children:o.reloadPage}):n!==void 0&&e.reason==="failed"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:o.retry}):null]})},An=(e,t)=>{const{phase:n,save:r,dirty:o}=t;switch(n.kind){case"opening":return e.editLoading;case"grant":return e.editGrantTitle;case"failed":return te(e,n.failure.reason)}switch(r.kind){case"saving":return e.draftSaving;case"conflicts":return e.draftConflicts(r.count);case"grant":return e.editGrantTitle;case"failed":return e.draftSaveFailed(te(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},Ln=(e,t,n)=>{switch(t.kind){case"saved":return t.merged?e.documentSavedMerged(n):e.documentSaved(n);case"conflicts":return e.draftConflicts(t.count);case"grant":return e.editGrantTitle;case"failed":return e.draftSaveFailed(te(e,t.failure.reason));case"idle":case"saving":return null}},ae=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},Nt="<<<<<<<",Dt="=======",Pt=">>>>>>>",rt=(e,t)=>e===t||e.startsWith(`${t} `),ot=e=>_t(e.split(`
2
+ `)),_t=e=>{const t=[];let n=null,r=null,o=0;for(const s of e){o+=1;const a=s.charCodeAt(0);a!==60&&a!==61&&a!==62||(rt(s,Nt)?(n=o,r=null):s===Dt?n!==null&&r===null?r=o:n=null:rt(s,Pt)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},st=e=>e.includes(`\r
3
+ `)?`\r
4
+ `:`
5
+ `,je=e=>e.replace(/\r\n?/gu,`
6
+ `),jn=(e,t)=>t===`
7
+ `?e:e.replaceAll(`
8
+ `,`\r
9
+ `),Mn=3,Me=Object.freeze({kind:"idle"}),Nn=({data:e,conflictLabels:t,onSaveSettled:n,previewSetting:r})=>{const o=new Map,s=new Map,a=new Map,u=new Map,v=new Map,m=ae();let f=null,p=null;const h=(c,d)=>{c.value={...c.value,...d},m.emit()},R=(c,d)=>o.get(c)===d,L=async(c,d)=>{d.controller.abort(),d.controller=new AbortController;const{signal:g}=d.controller;h(d,{phase:{kind:"opening"}});const x=await e.edit(c,g);if(!R(c,d)||g.aborted||!("kind"in x))return;if(x.kind==="grant"){h(d,{phase:{kind:"grant",href:x.href}});return}if(x.kind==="failure"){h(d,{phase:{kind:"failed",failure:x.failure}});return}const k=je(x.text);d.base={text:k,version:x.version},d.draft=k,d.ending=st(x.text),h(d,{phase:{kind:"editing"},history:x.history,dirty:!1,save:Me,generation:d.value.generation+1})},S=c=>{const d=o.get(c);d!==void 0&&(d.controller.abort(),o.delete(c),a.delete(c))},C=(c,d,g)=>(c.set(d,g),()=>{c.get(d)===g&&c.delete(d)}),M=(c,d,g,x={})=>{h(d,{...x,save:g}),n(c,g)},O=async c=>{u.get(c)?.flush();const d=o.get(c);if(d===void 0||d.value.phase.kind!=="editing"||d.base===null||d.value.save.kind==="saving")return;const g=ot(d.draft).length;if(g>0){M(c,d,{kind:"conflicts",count:g});return}d.controller.abort(),d.controller=new AbortController;const{signal:x}=d.controller;let k=d.base,j=d.draft,A=!1;h(d,{save:{kind:"saving"}});for(let D=0;D<Mn;D+=1){const F=await e.save(c,k.version,jn(j,d.ending),x);if(!R(c,d)||x.aborted||!("kind"in F))return;if(F.kind==="saved"){u.get(c)?.flush(),d.base={text:j,version:F.version},M(c,d,{kind:"saved",merged:A},{dirty:d.draft!==j});return}if(F.kind==="grant"){M(c,d,{kind:"grant",href:F.href});return}if(F.kind==="failure"){M(c,d,{kind:"failed",failure:F.failure});return}const{mergeDraft:z}=await Promise.resolve().then(()=>require("./merge-Bs7o3GyP.cjs"));if(!R(c,d)||x.aborted)return;const V=u.get(c);V?.flush();const W=je(F.text),Z=z(k.text,d.draft,W,t());if(k={text:W,version:F.version},d.base=k,d.ending=st(F.text),d.draft=Z.text,V?.adopt(Z.text),Z.kind==="conflicts"){M(c,d,{kind:"conflicts",count:Z.conflicts},{dirty:!0,generation:d.value.generation+1});return}if(A=!0,j=Z.text,j===k.text){M(c,d,{kind:"saved",merged:A},{dirty:!1,generation:d.value.generation+1});return}h(d,{dirty:!0,generation:d.value.generation+1})}M(c,d,{kind:"failed",failure:{reason:"failed"}})};return{session:c=>o.get(c)?.value,subscribe:m.subscribe,start:(c,d)=>{const g=o.get(c);if(g!==void 0){h(g,{request:{anchor:d}}),(g.value.phase.kind==="failed"||g.value.phase.kind==="grant")&&L(c,g);return}s.delete(c);const x={value:{path:c,phase:{kind:"opening"},history:!1,dirty:!1,save:Me,generation:0,request:{anchor:d}},base:null,draft:"",ending:`
10
+ `,controller:new AbortController};o.set(c,x),L(c,x)},retry:c=>{const d=o.get(c);d===void 0||d.value.phase.kind==="editing"||L(c,d)},draft:c=>{const d=o.get(c);return d===void 0||d.base===null?null:d.draft},setDraft:(c,d)=>{const g=o.get(c);if(g===void 0||g.base===null)return;g.draft=d;const x={},k=d!==g.base.text;k!==g.value.dirty&&(x.dirty=k);const{save:j}=g.value;if(j.kind==="conflicts"){const A=ot(d).length;A===0?x.save=Me:A!==j.count&&(x.save={kind:"conflicts",count:A})}(x.dirty!==void 0||x.save!==void 0)&&h(g,x)},consumeRequest:c=>{const d=o.get(c);d!==void 0&&d.value.request!==null&&h(d,{request:null})},save:O,replaceDraft:(c,d)=>{const g=u.get(c);g?.flush();const x=o.get(c);if(x===void 0||x.base===null)return;const k=je(d);x.draft=k,g?.adopt(k),h(x,{dirty:k!==x.base.text,generation:x.value.generation+1})},close:c=>{if(!o.has(c))return;const d=u.get(c),g=d===void 0?null:d.returnPoint();S(c),g===null?s.delete(c):s.set(c,g),m.emit()},takeReturn:c=>{const d=s.get(c)??null;return s.delete(c),d},dirtyPaths:()=>[...o.values()].filter(c=>c.value.dirty).map(c=>c.value.path),discard:c=>{for(const d of c)S(d);c.length>0&&m.emit()},editorState:{get:c=>a.get(c),set:(c,d)=>{o.has(c)&&a.set(c,d)}},bindEditor:(c,d)=>C(u,c,d),bindView:(c,d)=>C(v,c,d),viewAnchor:c=>{const d=v.get(c);return d===void 0?null:d.anchor()},flush:c=>u.get(c)?.flush(),flushDrafts:()=>{for(const c of u.values())c.flush()},nextConflict:c=>u.get(c)?.nextConflict()===!0,hasSessions:()=>o.size>0,unsavedAmong:c=>{for(const d of u.values())d.flush();return c.filter(d=>o.get(d)?.value.dirty===!0)},askToDiscard:c=>new Promise(d=>{p?.settle(!1);const g={paths:c,settle:x=>{if(p===g){if(p=null,x)for(const k of c)S(k);m.emit(),d(x)}}};p=g,m.emit()}),discardRequest:()=>p,previewShown:()=>(f??=r.read(),f),setPreviewShown:c=>{f!==c&&(f=c,r.write(c),m.emit())}}},Ve=e=>{e.preventDefault(),e.stopPropagation()},Ft=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:u})=>{const v=i.useRef(null),m=i.useRef(null),f=i.useRef(null),p=i.useId(),h=i.useId();i.useLayoutEffect(()=>{const S=v.current;if(S!==null)if(e&&!S.open){const C=S.ownerDocument.activeElement;f.current=C instanceof HTMLElement?C:null,S.showModal(),m.current?.focus()}else!e&&S.open&&(S.close(),f.current?.isConnected===!0&&f.current.focus(),f.current=null)},[e]);const R=S=>{S.key!=="Escape"||S.defaultPrevented||(Ve(S),a())},L=S=>{S.target===S.currentTarget&&a()};return l.jsx("dialog",{ref:v,className:"aqmx-confirm","aria-labelledby":p,"aria-describedby":h,"data-testid":u,onKeyDown:R,onClick:L,onCancel:S=>S.preventDefault(),children:l.jsxs("div",{className:"aqmx-confirm-panel",children:[l.jsx("p",{id:p,className:"aqmx-confirm-title",children:t}),l.jsx("p",{id:h,className:"aqmx-confirm-body",children:n}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{ref:m,type:"button",className:"aqmx-callout-action","data-testid":`${u}-cancel`,onClick:a,children:o}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${u}-confirm`,onClick:s,children:r})]})]})})},Dn=(e,t)=>{const n=X.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(n===null)return new Set;const{location:r}=q.resolveExplorerLocation(e,n.params["*"],new URLSearchParams(t.search));switch(r.view){case"tree":return new Set(r.doc===null?[]:[r.doc]);case"single":return new Set([r.doc]);case"multi":return new Set(r.docs)}},$t=e=>{const{edits:t}=P(),n=i.useCallback(()=>t.session(e),[t,e]);return i.useSyncExternalStore(t.subscribe,n,Pn)},qt=()=>!1,Pn=()=>{},_n=()=>{const{edits:e}=P();return i.useSyncExternalStore(e.subscribe,e.hasSessions,qt)},It=()=>{const{edits:e}=P();return i.useSyncExternalStore(e.subscribe,e.previewShown,qt)},Fn=()=>null,$n=()=>{const{edits:e,labels:t,config:n}=P(),r=i.useRef([]),o=i.useCallback(({nextLocation:p})=>{const h=Dn(n,p);return e.flushDrafts(),r.current=e.dirtyPaths().filter(R=>!h.has(R)),r.current.length>0},[e,n]),s=X.useBlocker(o),a=_n();i.useEffect(()=>{if(!a)return;const p=h=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(h.preventDefault(),h.returnValue=!0)};return window.addEventListener("beforeunload",p),()=>window.removeEventListener("beforeunload",p)},[a,e]);const u=i.useSyncExternalStore(e.subscribe,e.discardRequest,Fn),v=s.state==="blocked",f=(v?r.current:u===null?[]:u.paths).map(p=>N.lastPathSegment(p)).join(", ");return l.jsx(Ft,{open:v||u!==null,title:t.unsavedTitle,body:t.unsavedBody(f),confirmLabel:t.unsavedDiscard,cancelLabel:t.unsavedStay,testId:"markdown-explorer-unsaved-guard",onConfirm:()=>{if(s.state==="blocked"){e.discard(r.current),s.proceed();return}u?.settle(!0)},onCancel:()=>{if(s.state==="blocked"){s.reset();return}u?.settle(!1)}})};function qn({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const In=b.forwardRef(qn);let Ne=null;const Bt=()=>(Ne??=Promise.resolve().then(()=>require("./EditSurface-Dfj6Sxxb.cjs")).catch(e=>{throw Ne=null,e}),Ne),Bn=()=>{Bt().catch(()=>{})},Hn=e=>{const{default:t}=i.use(Bt());return l.jsx(t,{...e})};class Un extends i.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}retry=()=>this.setState({failed:!1});render(){return this.state.failed?this.props.fallback(this.retry):this.props.children}}const Ge=`[${$e.SOURCE_LINES_ATTRIBUTE}]`,zn="[data-aqmd-content]",Zn='a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg',Vn=200,fe=e=>$e.parseSourceLines(e.getAttribute($e.SOURCE_LINES_ATTRIBUTE)),Gn=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=fe(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(Ge)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=fe(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},Kn=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},Wn=e=>e.closest(zn)!==null&&e.closest(Zn)===null,Xn=(e,t,n)=>{const r=Gn(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const u=r.lines.last+1;return{lines:{first:u,last:u},word:null,occurrence:0,clientTop:Ee(e)}}const a=Qn(o,n);return a===null?{lines:r.lines,word:null,occurrence:0,clientTop:Ee(o)}:{lines:r.lines,word:a.text,occurrence:a.occurrence,clientTop:a.clientTop}},Yn=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(Ge)){const u=fe(a);if(u===null)continue;n??=Ut(t,a);const{top:v,bottom:m}=a.getBoundingClientRect();v<=n&&n<m?r={lines:u,block:a}:o===null&&v>=n&&(o={lines:u,block:a})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:Ee(s.block)}},Ht=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,Ut=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return Ht(e)+(Number.isFinite(n)?n:0)},Qn=(e,t)=>{if(t===null||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!(e.contains(n.startContainer)&&e.contains(n.endContainer)))return null;const r=n.toString().trim();if(r===""||r.length>Vn||/[\r\n]/u.test(r))return null;const o=e.ownerDocument.createRange();return o.setStart(e,0),o.setEnd(n.startContainer,n.startOffset),{text:r,occurrence:Kn(o.toString(),r),clientTop:n.getBoundingClientRect().top}},Jn=(e,t)=>{const n=e.split(`
11
+ `),r=Math.min(t.lines.first,n.length),o=Math.min(t.lines.last,n.length),s={line:r,column:0};if(t.word===null)return s;let a=0;for(let u=r;u<=o;u+=1){const v=n[u-1]??"";for(let m=v.indexOf(t.word);m>=0;m=v.indexOf(t.word,m+t.word.length)){if(a===t.occurrence)return{line:u,column:m};a+=1}}return a>0?er(n,r,o,t.word)??s:s},er=(e,t,n,r)=>{for(let o=n;o>=t;o-=1){const s=(e[o-1]??"").lastIndexOf(r);if(s>=0)return{line:o,column:s}}return null},zt=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(Ge)){const s=fe(o);s===null||s.first>t||(s.last>=t?n=o:(r===null||s.last>=r.last)&&(r={element:o,last:s.last}))}return n!==null?n:r===null?null:r.element},Zt=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=Ee(e),o=fe(e);if(o===null)return r;const s=Math.min(Math.max(t-o.first,0)/(o.last-o.first+1),1);return r+(n-r)*s},Ee=e=>{const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let n=t.nextNode();n!==null;n=t.nextNode()){const o=(n.textContent??"").search(/\S/u);if(o<0)continue;const s=e.ownerDocument.createRange();s.setStart(n,o),s.setEnd(n,o+1);const{top:a,height:u}=s.getBoundingClientRect();if(u>0)return a}return e.getBoundingClientRect().top},Ke=Object.freeze({browse:Object.freeze({replace:!0,preventScrollReset:!0,defaultShouldRevalidate:!1}),"switch-source":Object.freeze({replace:!1,preventScrollReset:!0,defaultShouldRevalidate:!1}),"switch-view":Object.freeze({replace:!1,preventScrollReset:!1,defaultShouldRevalidate:!1}),"follow-link":Object.freeze({replace:!1,preventScrollReset:!1,defaultShouldRevalidate:!1})}),tr=e=>Ke[e],he=()=>{const e=X.useNavigate();return i.useCallback((t,n)=>{e(t,Ke[n])},[e])},Vt=({navigation:e,...t})=>l.jsx(X.Link,{...t,...Ke[e]}),We=e=>{const t=e.ownerDocument;if(e.focus({preventScroll:!0}),t.activeElement===e)return!0;if(e.hasAttribute("tabindex"))return!1;if(e.setAttribute("tabindex","-1"),e.focus({preventScroll:!0}),t.activeElement!==e)return e.removeAttribute("tabindex"),!1;const n=()=>{t.activeElement!==e&&(e.removeAttribute("tabindex"),e.removeEventListener("blur",n))};return e.addEventListener("blur",n),!0},Gt=(e,t)=>{const n=i.useRef(null),r=i.useRef(null),o=i.useRef(null),s=i.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);i.useEffect(()=>s,[s]);const a=i.useCallback(m=>{if(r.current!==m)return;const f=o.current;if(f!==null){f.then(()=>a(m));return}e.prefetch(m);const p=e.peek(m);if(p?.status!=="pending")return;const h=Promise.allSettled([p.promise]);o.current=h,h.then(()=>{o.current===h&&(o.current=null)})},[e]),u=i.useCallback(m=>{const f=t(m);f!==r.current&&(s(),f!==null&&(r.current=f,n.current=window.setTimeout(()=>{n.current=null,a(f)},q.PREFETCH_DWELL_MS)))},[s,t,a]),v=i.useCallback(m=>{t(m)!==r.current&&s()},[s,t]);return i.useMemo(()=>({onPointerOver:m=>u(m.target),onPointerOut:m=>v(m.relatedTarget),onFocus:m=>u(m.target),onBlur:m=>v(m.relatedTarget)}),[u,v])},nr=i.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-B0AkVF3E.cjs")).then(e=>({default:e.NativeScrollBar})));class rr extends i.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){console.error("[markdown-explorer] a scroll bar failed to load or render; its scroller keeps its native scrolling without it.",t)}render(){return this.state.failed?null:this.props.children}}const Kt=({scroller:e,withCircle:t})=>l.jsx(rr,{children:l.jsx(i.Suspense,{fallback:null,children:l.jsx(nr,{scroller:e,withCircle:t})})}),Wt=e=>l.jsx(Kt,{scroller:e,withCircle:!0}),Xt=()=>{const e=new Map,t=new Set;let n=!1;const r=o=>{t.add(o),!n&&(n=!0,queueMicrotask(()=>{n=!1,t.clear()}))};return{hold:o=>{e.set(o,(e.get(o)??0)+1);let s=!1;return()=>{if(s)return;s=!0;const a=e.get(o);if(a!==void 0&&a>1){e.set(o,a-1);return}e.delete(o),r(o)}},isHeld:o=>e.has(o),resumes:o=>t.delete(o),heldKeys:()=>[...e.keys()]}},be=(e,t)=>{if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t))return!(Array.isArray(e)&&Array.isArray(t))||e.length!==t.length?!1:e.every((s,a)=>be(s,t[a]));const n=e,r=t,o=Object.keys(n);return o.length!==Object.keys(r).length?!1:o.every(s=>Object.hasOwn(r,s)&&be(n[s],r[s]))},me=e=>{const t=e;return t.status===void 0&&(t.status="pending",e.then(n=>{t.status="fulfilled",t.value=n},n=>{t.status="rejected",t.reason=n})),t},Yt=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),ge=e=>e.status==="fulfilled"?e.value:void 0,or=55e3,lt=Object.freeze({status:"deferred"}),it=Object.freeze({status:"refreshed"}),De=Object.freeze({status:"superseded"}),re=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,Qt=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",sr=({client:e,capacity:t})=>{if(!Number.isInteger(t)||t<1)throw new RangeError(`[markdown-explorer] the document cache capacity must be a positive integer; got ${String(t)}`);const n=new Map,r=Xt(),o=ae(),s=new WeakSet;let a=0;const u=o.emit,v=()=>(a+=1,a),m=()=>{if(!(n.size<=t))for(const c of[...n.keys()]){if(n.size<=t)return;r.isHeld(c)||n.delete(c)}},f=(c,d)=>{n.delete(c),n.set(c,d)},p=c=>performance.now()-c.validatedAt>=or,h=(c,d,g)=>{const x=n.get(c),k=re(x?.snapshot),j=g||x?.refreshPending===!0,A=me(e.document(c,{refresh:j}).then(F=>({status:"loaded",document:F}))),D={snapshot:{status:"pending",promise:A,previous:k},validatedAt:performance.now(),opened:d,background:null,refreshPending:!1,seeded:void 0,stamp:v()};return f(c,D),m(),A.then(F=>{n.get(c)===D&&(D.snapshot=F,D.stamp=v(),u())}),D},R=(c,d,g,x,k,j)=>{d.background===g&&(d.background=null,!(n.get(c)!==d||d.snapshot!==x)&&(k.kind==="failure"&&x.document.kind!=="failure"||(d.validatedAt=j,d.stamp=v(),be(x.document,k)||(d.snapshot={status:"loaded",document:k}),u())))},L=async(c,d)=>{const g=d.snapshot;if(g.status!=="loaded")return null;const x={};d.background=x;const k=performance.now(),j=e.document(c,{refresh:d.refreshPending});d.refreshPending=!1;const A=await j,D=d.background===x&&n.get(c)===d&&d.snapshot===g;return R(c,d,x,g,A,k),D?A:null},S=(c,d)=>{const{snapshot:g}=d;return g.status==="pending"?!1:g.status==="loaded"&&g.document.kind!=="failure"?(L(c,d),!1):(g.status==="loaded"&&s.add(g),h(c,!0,!1),!0)},C=c=>{const d=r.hold(c);let g=!1;return()=>{if(g)return;g=!0,d();const x=n.get(c);x!==void 0&&f(c,x),m()}};return{peek:c=>n.get(c)?.snapshot,peekSeeded:c=>n.get(c)?.seeded,answerStampOf:c=>n.get(c)?.stamp,prefetch:c=>{const d=n.get(c);d!==void 0&&d.snapshot.status!=="deferred"||(h(c,!1,!1),u())},open:c=>{const d=r.resumes(c),g=C(c),x=n.get(c);if(x===void 0||x.snapshot.status==="deferred")return h(c,!0,!1),u(),g;if(f(c,x),d)return g;const{snapshot:k}=x;return k.status==="pending"?(x.opened=!0,g):k.document.kind==="failure"?(x.opened||p(x)?(s.add(k),h(c,!0,!1),u()):x.opened=!0,g):(x.opened=!0,x.background===null&&p(x)&&L(c,x),g)},retain:C,retry:c=>{const d=n.get(c);d===void 0||d.snapshot.status!=="loaded"||d.snapshot.document.kind!=="failure"||(h(c,!0,!1),u())},seed:(c,d)=>{const g=performance.now(),x=me(d.then(F=>F===null?lt:{status:"loaded",document:F},()=>lt)),k=n.get(c);if(k!==void 0&&k.snapshot.status==="loaded"){const F=k.snapshot,z={};k.background=z,x.then(V=>{if(V.status==="loaded"){R(c,k,z,F,V.document,g);return}k.background===z&&(k.background=null)});return}const j=k!==void 0&&k.snapshot.status==="pending"?k.snapshot.previous:null,A={status:"pending",promise:x,previous:j},D={snapshot:A,validatedAt:g,opened:k?.opened===!0,background:null,refreshPending:k?.refreshPending===!0,seeded:A,stamp:v()};f(c,D),m(),x.then(F=>{n.get(c)===D&&(F.status==="deferred"&&r.isHeld(c)?h(c,D.opened,!1):(D.snapshot=F,D.stamp=v()),u())})},invalidate:()=>{let c=!1;for(const[d,g]of[...n]){if(g.validatedAt=Number.NEGATIVE_INFINITY,g.opened=!0,g.refreshPending=!0,!r.isHeld(d))continue;const{snapshot:x}=g;if(x.status!=="pending"){S(d,g)&&(c=!0);continue}x.promise.then(()=>{n.get(d)===g&&g.refreshPending&&r.isHeld(d)&&S(d,g)&&u()})}c&&u()},refresh:async c=>{const d=n.get(c);if(d!==void 0&&Qt(d.snapshot)){d.refreshPending=!0;const x=await L(c,d);return x===null?De:x.kind==="failure"?{status:"failed",failure:x.failure}:it}const g=h(c,!0,!0);return u(),g.snapshot.status!=="pending"?De:(await g.snapshot.promise,n.get(c)===g?it:De)},clear:()=>{n.clear();for(const c of r.heldKeys())h(c,!0,!1);u()},subscribe:o.subscribe,noteFailureShown:c=>s.has(c)?!1:(s.add(c),!0)}};function lr({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}),b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const ir=b.forwardRef(lr);function ar({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}),b.createElement("path",{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"}))}const cr=b.forwardRef(ar);function dr({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const ur=b.forwardRef(dr),fr=2e3,at=Object.freeze({outcome:"idle"}),mr=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},hr=({text:e})=>{const{announcer:t,labels:n}=P(),[r,o]=i.useState(at);i.useEffect(()=>{if(r.outcome==="idle")return;const v=setTimeout(()=>o(at),fr);return()=>clearTimeout(v)},[r]);const s=v=>{o({outcome:v}),t.announce(v==="copied"?n.copiedText:n.copyTextFailed)},a=()=>{mr(e).then(()=>s("copied"),()=>s("failed"))},u=r.outcome==="copied"?n.copiedText:r.outcome==="failed"?n.copyTextFailed:n.copyText;return l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":n.copyText,title:u,onClick:a,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?l.jsx(ir,{}):r.outcome==="failed"?l.jsx(ur,{}):l.jsx(cr,{})})},ie=i.createContext("fill"),pr=Object.freeze({blockSize:"100%"}),pe=({scrollerProps:e,children:t})=>i.use(ie)==="content"?l.jsx(de.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(de.HostedScrollArea,{scrollerProps:{...e,style:pr},rowClassName:"aqmx-document-scroll-row",renderScrollBar:Wt,children:t});function gr({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{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"}),b.createElement("path",{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"}))}const vr=b.forwardRef(gr);function wr({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}),b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const xr=b.forwardRef(wr),ke=({name:e,openUrl:t,downloadUrl:n,icon:r,children:o})=>{const{labels:s}=P();return l.jsxs("div",{className:"aqmx-document-toolbar",children:[l.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:r}),l.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),o,l.jsx("a",{className:"aqmx-icon-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":s.openInNewTab,title:s.openInNewTab,"data-testid":"markdown-explorer-file-open",children:l.jsx(xr,{})}),l.jsx("a",{className:"aqmx-icon-button",href:n,download:e,"aria-label":s.download,title:s.download,"data-testid":"markdown-explorer-file-download",children:l.jsx(vr,{})})]})};function Er({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const br=b.forwardRef(Er),yr=Object.freeze({className:"aqmx-document-stage"}),Sr=({document:e})=>{const{labels:t}=P();return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[l.jsx(ke,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(br,{})}),l.jsx(pe,{scrollerProps:yr,children:l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-file-not-shown",children:[l.jsx("p",{className:"aqmx-callout-body",children:t.fileNotShown}),l.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-file-not-shown-download",children:t.download})]})})]})},Re="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",kr=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},Rr=/(%[0-9A-Fa-f]{2})/u,Xe=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(Rr).flatMap((r,o)=>o%2===1?[Number.parseInt(r.slice(1),16)]:[...t.encode(r)]);return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(Uint8Array.from(n))},Jt=e=>`#${encodeURIComponent(e)}`,Tr=e=>{if(e==="#")return!0;const t=Xe(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},en=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},Cr="http://www.w3.org/1999/xhtml",ct=(e,t)=>{if(t==="")return null;const n=en(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===Cr&&r.getAttribute("name")===t)return r;return null},tn=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=ct(e,t.slice(1));if(n!==null)return n;const r=Xe(t);return r===null?null:ct(e,r)},dt=e=>{const{body:t,documentElement:n}=e.ownerDocument;if(e===t){const o=getComputedStyle(n);if(o.overflowX==="visible"&&o.overflowY==="visible")return!1}const{overflowY:r}=getComputedStyle(e);return r==="auto"||r==="scroll"},Or=e=>{const{body:t,documentElement:n}=e,r=getComputedStyle(n),o=r.overflowX==="visible"&&r.overflowY==="visible"&&t!==null?getComputedStyle(t).overflowY:r.overflowY;return o!=="hidden"&&o!=="clip"},Ar=(e,t)=>{const n=t.closest(Re),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&dt(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:a}=e.ownerDocument;for(let u=e.parentElement;u!==null&&u!==s;u=u.parentElement)if(dt(u)&&u.scrollHeight>u.clientHeight&&u.clientHeight<o)return u;return a instanceof Element&&Or(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},Lr=Object.freeze({scrollerOf:Ar,reveal:e=>{e.scrollIntoView(He)}}),He=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),jr=(e,t)=>{for(let n=t;n!==null&&n!==e;n=n.parentElement){const r=n.parentElement;if(r instanceof HTMLDetailsElement&&n!==r.querySelector(":scope > summary")&&(r.open=!0),n.getAttribute("hidden")?.toLowerCase()==="until-found"){if(n.dispatchEvent(new Event("beforematch",{bubbles:!0})),!n.isConnected)return;n.removeAttribute("hidden")}}},Mr=(e,t)=>{if(t.getClientRects().length===0)return;const n=e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,{scrollMarginTop:r,scrollMarginBottom:o}=getComputedStyle(t),s=Number.parseFloat(r),a=t.getBoundingClientRect(),u=a.height+s+Number.parseFloat(o)>e.clientHeight;if(!u&&Math.abs(a.top-s-n)<1){t.scrollIntoView(He);return}e.scrollBy({top:u?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(He)},Nr=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Re)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},ut=(e,t,n)=>{if(e===null)return null;const r=tn(e,t);return r===null?(Tr(t)&&Nr(e,n),null):(jr(e,r),Mr(n.scrollerOf(e,r),r),n.reveal(r),r)};function Dr({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{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"}))}const Pr=b.forwardRef(Dr);function _r({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{d:"M6.75 8.25a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z"}),b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Fr=b.forwardRef(_r);function $r({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{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"}),b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const qr=b.forwardRef($r);function Ir({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Br=b.forwardRef(Ir),Ue="data-aqmx-key-repeat",ye=Object.freeze({[Ue]:"allow"}),Hr=`[${Ue}="${ye[Ue]}"]`,Ur=()=>{let e=null;return{onKeyDownCapture:t=>{if(t.key==="Enter"){if(!t.repeat){e=t.target instanceof Element?t.target:null;return}e!==null&&t.target===e&&e.closest(Hr)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},xe=Object.freeze([1/q.GOLDEN_RATIO**2,1/q.GOLDEN_RATIO,1,q.GOLDEN_RATIO,q.GOLDEN_RATIO**2]),ft=Object.freeze({mode:"fit"}),zr=1,Zr=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),nn=i.createContext(null),Vr=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=zr?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,mt=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<xe.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?xe.findIndex(o=>o>t):xe.findLastIndex(o=>o<t);return r===-1?null:r},ht=(e,t,n)=>{if(e.mode==="level"){const o=mt(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=mt(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},Gr=e=>{const t=xe[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},pt=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},Kr=({document:e})=>{const{labels:t}=P(),n=i.use(nn),[r]=i.useState(()=>n===null?null:n.read(e.url)),[o,s]=i.useState(r===null?ft:r.zoom),[a,u]=i.useState(r===null?null:r.reported),[v,m]=i.useState(null),f=i.useRef(null),p=i.useCallback(O=>{const{naturalWidth:c,naturalHeight:d}=O;u(g=>pt(g,c,d))},[]),h=i.useCallback(O=>{f.current=O,!(O===null||!O.complete)&&(O.naturalWidth>0||O.naturalHeight>0?p(O):O.decode().then(()=>p(O),()=>{}))},[p]);i.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),i.useLayoutEffect(()=>{const O=f.current;if(O===null||a===null||o.mode!=="fit")return;const c=()=>m(g=>pt(g,O.clientWidth,O.clientHeight));if(c(),typeof ResizeObserver>"u")return;const d=new ResizeObserver(c);return d.observe(O),()=>d.disconnect()},[a,o.mode]);const R=a===null||v===null?null:Vr(a,v),L=ht(o,R,-1),S=ht(o,R,1),C=o.mode==="level"?Gr(o.index):null,M=o.mode==="level"&&C!==null?{width:`${o.base.width*C}px`,height:`${o.base.height*C}px`}:void 0;return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[l.jsxs(ke,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:l.jsx(Br,{}),children:[l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":L===null,onClick:()=>{L!==null&&s(L)},...ye,children:l.jsx(Fr,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:C===null?t.imageFitLevel:t.imageZoomLevel(Math.round(C*100))}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":S===null,onClick:()=>{S!==null&&s(S)},...ye,children:l.jsx(qr,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(ft),children:l.jsx(Pr,{})})]}),l.jsx(pe,{scrollerProps:Zr,children:l.jsx("img",{ref:h,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:M,onLoad:O=>p(O.currentTarget),"data-testid":"markdown-explorer-image"})})]})},rn=i.createContext(null),Te=i.createContext(void 0),on=i.createContext(null),Ce=()=>{const e=i.use(rn);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},Wr=()=>{const e=i.use(on);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},Oe=(e,t,n,r)=>t.kind==="panel"?q.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?q.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):q.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),Xr=({children:e})=>{const{config:t}=P(),n=Ce(),r=Se(),o=r.kind==="location"?r.location.source:void 0,s=X.useHref(Oe(t,n.navigation,o,n.currentPath));return l.jsx(Te,{value:o,children:l.jsx(on,{value:s,children:e})})},Yr='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Qr=e=>{const t=e instanceof Element?e.closest(Yr):null;return t===null?null:t.getAttribute("data-doc-path")},Ae=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Jr=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:u,children:v})=>{const m=X.useHref(e),f=p=>{if(Ae(p)){if(p.preventDefault(),t===u.currentPath&&n!==""){u.scrollWithin(n);return}a(t,n)}};return l.jsx("a",{...s,href:m,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:f,children:v})},eo=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=P(),u=Ce(),v=i.use(Te),m=kr(e),{navigation:f}=u,p=`${Oe(a,f,v,t)}${m}`,h=n===!1?"false":void 0;return f.kind==="page"?l.jsx(Vt,{...o,to:p,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":h,children:s}):l.jsx(Jr,{to:p,docPath:t,fragment:m,exists:h,className:r,attributes:o,onDocumentLink:f.onDocumentLink,scope:u,children:s})},to=({className:e,attributes:t,children:n})=>{const{labels:r}=P();return l.jsxs("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:[n,l.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},no=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=P(),a=i.use(Te),u=X.useHref(`${Oe(s,r.navigation,a,r.currentPath)}${e}`),v=m=>{Ae(m)&&(m.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:u,className:t,onClick:v,children:o})},ro=({href:e,className:t,attributes:n,children:r})=>{const o=Ce();if(o.navigation.kind==="page"){const s=a=>{if(!Ae(a))return;const u=a.currentTarget;e==="#"?o.followEmptyFragment(a.nativeEvent):u.href===u.ownerDocument.URL&&o.followSameUrlJump(e,a.nativeEvent)};return l.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return l.jsx(no,{href:e,className:t,attributes:n,scope:o,children:r})},oo=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!N.isAcceptableDocumentPath(n)?l.jsx(to,{className:o,attributes:s,children:a}):l.jsx(eo,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?l.jsx(ro,{href:e,className:o,attributes:s,children:a}):l.jsx("a",{...s,href:e,className:o,children:a}),so=()=>{const{config:e}=P(),t=Ce(),n=i.use(Te),r=he();return i.useCallback((o,s)=>{if(!Ae(s))return!0;s.preventDefault();const a=Jt(o.id),{navigation:u}=t;return u.kind==="panel"||Xe(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${Oe(e,u,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},lo=()=>{const e=Wr();return i.useCallback(t=>`${e}${Jt(t.id)}`,[e])};function io({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{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"}))}const ao=b.forwardRef(io);function co({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const uo=b.forwardRef(co);function fo({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const mo=b.forwardRef(fo),ho=Object.freeze({className:"aqmx-document-stage"}),po=e=>{switch(e){case"video":return l.jsx(uo,{});case"audio":return l.jsx(mo,{});case"pdf":return l.jsx(ao,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},go=({document:e})=>{const{labels:t}=P();switch(e.mediaType){case"video":return l.jsx("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});case"audio":return l.jsx("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});case"pdf":return l.jsx("iframe",{className:"aqmx-document-frame",src:e.url,title:e.name,"data-testid":"markdown-explorer-media-player"});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},vo=({document:e})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[l.jsx(ke,{name:e.name,openUrl:e.url,downloadUrl:e.url,icon:po(e.mediaType)}),l.jsx(pe,{scrollerProps:ho,children:l.jsx(go,{document:e})})]}),wo=e=>({loading:e.viewerLoading,errorPrefix:e.viewerErrorPrefix,styleTitle:e.viewerStyleTitle,selectStyleAria:e.viewerSelectStyle,pinStyleAria:e.viewerPinStyle,unpinStyleAria:e.viewerUnpinStyle,defaultErrorTitle:e.viewerErrorTitle,missingImage:e.viewerMissingImage,openTocAria:e.viewerOpenToc,tocTitle:e.viewerTocTitle,pinTocAria:e.viewerPinToc,unpinTocAria:e.viewerUnpinToc,selectAlignAria:e.viewerSelectAlign,alignTitle:e.viewerAlignTitle,pinAlignAria:e.viewerPinAlign,unpinAlignAria:e.viewerUnpinAlign,alignLeft:e.viewerAlignLeft,alignCenter:e.viewerAlignCenter,alignRight:e.viewerAlignRight,mermaidInteractionMode:e.viewerMermaidInteractionMode,mermaidModeNone:e.viewerMermaidModeNone,mermaidModeZoom:e.viewerMermaidModeZoom,mermaidModePan:e.viewerMermaidModePan,mermaidModePanShift:e.viewerMermaidModePanShift,mermaidModeBoth:e.viewerMermaidModeBoth,mermaidModeBothShift:e.viewerMermaidModeBothShift,mermaidZoomIn:e.viewerMermaidZoomIn,mermaidZoomOut:e.viewerMermaidZoomOut,mermaidResetView:e.viewerMermaidResetView,mermaidRetry:e.viewerMermaidRetry,embeddedVideo:e.viewerEmbeddedVideo,embeddedPost:e.viewerEmbeddedPost,embeddedFrame:e.viewerEmbeddedFrame}),sn=(e,t,n)=>{if(t!==void 0)return t;if(n!==void 0)return n;const[r]=e.documentStyles;if(r===void 0)throw new Error("[markdown-explorer] the configuration has no document style");return r.name},ln=(e,t)=>e!==void 0?e:t!==void 0?t:bn.DEFAULT_CONTENT_ALIGN,Ye=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),xo=(e,t,n)=>{if(t.view==="multi"||t.overrides[n]===void 0)return null;const r=n==="style"?{align:t.overrides.align}:{style:t.overrides.style};return q.explorerHref(e,{...t,overrides:r})},Qe=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:a,children:u})=>{const v=i.use(ie);return l.jsxs("section",{ref:s,role:"region","aria-label":n,"aria-busy":o,"data-testid":"markdown-explorer-document","data-aqmx-document-kind":e,"data-aqmx-document-view":t,"data-aqmx-document-flow":v,className:"aqmx-document",...a,children:[r?l.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,u]})},Eo=()=>{const{labels:e}=P();return l.jsx(Qe,{kind:"empty",label:e.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:e.documentEmpty})})})},an=({label:e})=>{const{labels:t}=P();return l.jsxs(Qe,{kind:"loading",label:e,stale:!1,busy:!0,children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-document-skeleton",children:Ye.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:t.documentLoading})]})},gt=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),bo=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=P(),a=i.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),u=so(),v=lo(),m=i.useMemo(()=>o===void 0?void 0:g=>o(e,g),[o,e]),f=i.useRef(null),{editable:p,doubleClick:h,region:R,paneScroll:L,stale:S}=r;i.useLayoutEffect(()=>{if(p)return s.bindView(e,{anchor:()=>{const g=f.current,x=R(),k=g===null?null:g.querySelector(Re);return g===null||x===null||k===null?null:Yn(g,L.scrollerOf(x,k))}})},[s,e,p,R,L]);const C=g=>{const x=f.current,{target:k}=g;!h||x===null||!(k instanceof Element)||!Wn(k)||(g.stopPropagation(),s.start(e,Xn(k,x,x.ownerDocument.getSelection())))},M=i.useRef(null),O=i.useRef(S);i.useLayoutEffect(()=>{O.current=S});const c=i.useEffectEvent(g=>{const x=f.current,k=R(),j=x===null?null:zt(x,g.line);if(k===null||j===null)return!1;const A=L.scrollerOf(k,j);return A.scrollTop+=Zt(j,g.line)-g.clientTop,!0}),d=i.useEffectEvent(g=>{const x=R();if(x===null)return;const k=()=>{for(const A of gt)x.removeEventListener(A,j,!0);M.current?.release===k&&(M.current=null)},j=()=>k();for(const A of gt)x.addEventListener(A,j,{capture:!0,passive:!0});M.current={point:g,release:k}});return i.useLayoutEffect(()=>{const g=s.takeReturn(e);if(g!==null)return queueMicrotask(()=>{c(g)&&O.current&&d(g)}),()=>M.current?.release()},[s,e]),i.useLayoutEffect(()=>{const g=M.current;g===null||S||(g.release(),c(g.point))},[t,S]),l.jsx("div",{ref:f,className:"aqmx-document-viewer",onDoubleClick:C,children:l.jsx(de.MarkdownViewer,{...n,onHeadingSelect:u,headingHref:v,onMathDiagnostics:m,parseResult:a,content:null})})},cn=({document:e,viewer:t})=>{const{labels:n}=P();return l.jsxs(l.Fragment,{children:[l.jsx(ke,{name:e.name,openUrl:N.explorerPlainTextHref(e.url),downloadUrl:e.url,icon:l.jsx(In,{}),children:e.truncated?null:l.jsx(hr,{text:e.text})}),e.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,l.jsx("div",{className:"aqmx-document-viewer",children:l.jsx(de.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},yo=({path:e,name:t,viewer:n})=>{const{data:r,documents:o,announcer:s,labels:a}=P(),u=i.useCallback(()=>o.answerStampOf(e),[o,e]),v=i.useSyncExternalStore(o.subscribe,u,u),[m,f]=i.useState(0),p=i.useMemo(()=>({path:e,stamp:v,attempt:m}),[e,v,m]),[h,R]=i.useState(null),L=i.useEffectEvent(C=>{R(C),C.kind==="failure"&&s.announce(a.documentFailed(t,te(a,C.failure.reason)))});i.useEffect(()=>{const C=new AbortController;return r.text(p.path,C.signal).then(M=>{"kind"in M&&L(M)}),()=>C.abort()},[r,p]);const S=i.useCallback(()=>f(C=>C+1),[]);return h===null?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-markup-skeleton",children:Ye.map(C=>l.jsx("span",{},C))}),l.jsx("p",{className:"aqmx-sr-only",children:a.markupLoading})]}):h.kind==="failure"?l.jsx(pe,{scrollerProps:dn,children:l.jsx(le,{failure:h.failure,alert:!1,onRetry:S,testId:"markdown-explorer-markup-failure"})}):l.jsx(cn,{document:h,viewer:n})},dn=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),So=Object.freeze({reason:"failed"}),ko=e=>l.jsx(Un,{fallback:t=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(le,{failure:So,alert:!1,onRetry:t,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(i.Suspense,{fallback:l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-skeleton",children:Ye.map(t=>l.jsx("span",{},t))}),children:l.jsx(Hn,{...e})})}),Ro=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:a,layout:u,region:v,paneScroll:m,stale:f}=s;if(n==="edit"&&a!==void 0)return l.jsx(ko,{path:e,name:t.name,session:a,layout:u,viewer:r,region:v,paneScroll:m});if(n==="markup")return l.jsx(yo,{path:e,name:t.name,viewer:r});const p=t.edit!==null&&t.edit.kind==="inline";return l.jsx(bo,{path:e,document:t,viewer:r,editing:{editable:p,doubleClick:p&&u==="fill",region:v,paneScroll:m,stale:f}})}case"text":return l.jsx(cn,{document:t,viewer:r});case"image":return l.jsx(Kr,{document:t});case"media":return l.jsx(vo,{document:t});case"file":return l.jsx(Sr,{document:t});case"failure":return l.jsx(pe,{scrollerProps:dn,children:l.jsx(le,{failure:t.failure,alert:!1,onRetry:o,testId:"markdown-explorer-document-failure"})});default:{const a=t;throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(a)}`)}}},To='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',Co=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:tn(e,n),r===void 0?null:en(e,r.id),e.querySelector(Re),e.querySelector(To)];for(const s of o)if(s instanceof HTMLElement&&We(s))return s;return null},vt=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&We(t)},Oo=e=>{const t=i.useRef(!1);return i.useLayoutEffect(()=>{const n=e.current;if(n===null)throw new Error("[markdown-explorer] the document region is not mounted");const r=n.ownerDocument,o=r.defaultView;if(o===null)throw new Error("[markdown-explorer] the document region's document has no window");let s=!1,a;const u=h=>{s=!(h.target instanceof Node&&n.contains(h.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=setTimeout(()=>{s=!1},0)},v=h=>{t.current=h.target instanceof Node&&n.contains(h.target)},m=h=>{h.relatedTarget===null&&s&&(t.current=!1)},f=()=>{const{activeElement:h,body:R}=r;h!==null&&h!==R&&(t.current=n.contains(h))},p=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",u,!0),o.addEventListener("mousedown",u,!0),o.addEventListener("focusin",v,!0),o.addEventListener("blur",f),o.addEventListener("focus",p),n.addEventListener("focusout",m),()=>{clearTimeout(a),o.removeEventListener("pointerdown",u,!0),o.removeEventListener("mousedown",u,!0),o.removeEventListener("focusin",v,!0),o.removeEventListener("blur",f),o.removeEventListener("focus",p),n.removeEventListener("focusout",m)}},[e]),t},Ao=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:u,fragment:v,paneScroll:m,announces:f,announceFailure:p,onDocumentShown:h})=>{const{labels:R,announcer:L,documents:S}=P(),{document:C}=t,M=i.useRef(null),O=i.useRef(null),c=i.useRef(null),d=i.useRef(0),g=Oo(M),x=i.useRef({path:e,document:C}),k=i.useRef(null),j=i.useCallback(B=>{const U=M.current,K=ut(U,B,m);U!==null&&K!==null&&vt(U,K,g.current)},[m,g]),A=i.useCallback((B,U)=>{const K=d.current;setTimeout(()=>{!U.defaultPrevented&&d.current===K&&j(B)},0)},[j]),D=i.useCallback(B=>{setTimeout(()=>{B.defaultPrevented||j("#")},0)},[j]),F=i.useMemo(()=>({navigation:u,currentPath:e,scrollWithin:j,followSameUrlJump:A,followEmptyFragment:D}),[u,e,j,A,D]),z=i.useCallback(()=>S.retry(e),[S,e]),V=Gt(S,Qr),W=$t(e),Z=W!==void 0?"edit":n?"markup":"rendered",G=C.kind==="markdown"?Z:void 0,J=i.useCallback(()=>M.current,[]),w=i.useMemo(()=>({session:W,layout:s,region:J,paneScroll:m,stale:r}),[W,s,J,m,r]),E=G==="edit"?!1:r,y=i.use(ie),T=G==="edit"&&s==="fill"?"fill":y,_=i.useEffectEvent((B,U)=>{const K=O.current;if(K!==null&&K.path===B&&K.snapshot===U)return;O.current={path:B,snapshot:U};const Y=U.document;if(Y.kind==="failure"){S.noteFailureShown(U)&&p(R.documentFailed(N.lastPathSegment(B),te(R,Y.failure.reason)));return}h?.(B,Y),f&&(K===null||K.path!==B||K.snapshot.document.kind==="failure")&&L.announce(R.documentShown(Y.name))});i.useEffect(()=>{_(e,t)},[e,t]);const $=i.useEffectEvent(()=>{v.kind==="panel"&&v.consume()}),H=i.useEffectEvent(B=>{const U=M.current;if(U===null||!g.current)return null;const{activeElement:K,body:Y}=U.ownerDocument;return K!==null&&K!==Y?null:Co(U,C,B)}),I=i.useEffectEvent(B=>{const U=M.current;U!==null&&vt(U,B,g.current)}),ee=i.useEffectEvent(B=>m.reveal(B)),et=i.useEffectEvent(B=>ut(M.current,B,m));return i.useEffect(()=>{if(r)return;const B=x.current.path!==e,U=B||x.current.document!==C;x.current={path:e,document:C};const K=k.current!==e;k.current=e;let Y=null;v.kind==="page"?c.current!==v.navigation&&(c.current=v.navigation,d.current+=1,Y=v.fragment):v.fragment!==null&&(Y=v.fragment,$());const tt=()=>{const Le=Y===null?null:et(Y);if(!U){Le!==null&&I(Le);return}const nt=H(v.fragment);B&&Le===null&&nt!==null&&ee(nt)};K?queueMicrotask(tt):tt()},[v,e,C,r]),l.jsx(ie,{value:T,children:l.jsx(Qe,{kind:C.kind,view:G,label:a(e,C),stale:E,busy:E,frameRef:M,intent:V,children:l.jsx(rn,{value:F,children:l.jsx(Xr,{children:l.jsx(Ro,{path:e,document:C,view:Z,viewer:o,onRetry:z,editing:w},e)})})})})},Je=Object.freeze({kind:"skeleton"}),Lo=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=re(t);if(s!==null)return{kind:"document",path:e,snapshot:s,stale:!0};if(o&&t?.status==="pending")return{kind:"streaming",path:e,promise:t.promise};const a=n===null||n===e?null:re(r);return n===null||a===null?Je:{kind:"document",path:n,snapshot:a,stale:!0}},jo=(e,t)=>t.status==="deferred"?Je:{kind:"document",path:e,snapshot:t,stale:!1},Mo=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?jo(t.path,i.use(t.promise)):t;return o.kind!=="document"?l.jsx(an,{label:r.regionLabel(e,null)}):l.jsx(Ao,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},un=({path:e,markup:t,display:n,navigation:r,fragment:o,paneScroll:s,announces:a,announceFailure:u,onDocumentShown:v})=>{const{config:m,labels:f,theme:p,documents:h}=P(),R=de.useMarkdownToolbarState(),L=i.useRef(!1);i.useLayoutEffect(()=>{L.current=!0},[]);const[S,C]=i.useState(null),[M,O]=i.useState(t),c=i.useCallback(()=>e===null?void 0:h.peek(e),[h,e]),d=i.useSyncExternalStore(h.subscribe,c,c),g=i.useCallback(()=>S===null?void 0:h.peek(S),[h,S]),x=i.useSyncExternalStore(h.subscribe,g,g);i.useLayoutEffect(()=>e===null?void 0:h.open(e),[h,e]),i.useLayoutEffect(()=>S===null?void 0:h.retain(S),[h,S]);const k=e===null?Je:Lo(e,d,S,x,!L.current),j=e===null?null:k.kind==="document"&&!k.stale?k.path:S;j!==S&&C(j);const A=k.kind!=="document"||k.path===e;A&&t!==M&&O(t);const D=i.useMemo(()=>wo(f),[f]),F=i.useMemo(()=>[...m.iframeHosts],[m]),z=r.kind==="panel",V=i.useMemo(()=>({labels:D,emptyMessage:f.documentEmpty,theme:p,availableStyles:m.documentStyles,iFrameAllowedDomains:F,embeds:m.embeds,linkComponent:oo,toolbar:R,style:n.style,onStyleChange:n.onStyleChange,align:n.align,onAlignChange:n.onAlignChange,showToc:n.showToc,showStyle:n.showStyle,showAlign:n.showAlign,padding:n.padding,width:n.width===void 0?void 0:`min(${n.width}, 100%)`,maxWidth:n.maxWidth===void 0?void 0:`min(${n.maxWidth}, 100%)`,renderScrollBar:z?void 0:Wt}),[D,f.documentEmpty,p,m.documentStyles,F,m.embeds,R,n,z]),W=i.useCallback((G,J)=>z?J===null||J.kind==="failure"?N.lastPathSegment(G):J.name:f.documentRegion,[z,f.documentRegion]),Z=z?"content":"fill";return e===null?l.jsx(ie,{value:Z,children:l.jsx(Eo,{})}):l.jsx(ie,{value:Z,children:l.jsx(i.Suspense,{fallback:l.jsx(an,{label:W(e,null)}),children:l.jsx(Mo,{requestedPath:e,content:k,markup:A?t:M,viewer:V,editLayout:n.editLayout,regionLabel:W,navigation:r,fragment:o,paneScroll:s,announces:a,announceFailure:u,onDocumentShown:v})})})},No=({path:e,markup:t,variant:n,onDocumentShown:r})=>{const{config:o,viewSettings:s,announcer:a}=P(),u=ue(j=>j.style),v=ue(j=>j.align),m=he(),f=X.useLocation(),p=Se(),{view:h,overrides:R,embed:L}=n,S=i.useCallback(j=>{if(p.kind!=="location")return;const A=xo(o,p.location,j);A!==null&&m(A,"browse")},[o,m,p]),C=i.useCallback(j=>{s.update({style:j}),S("style")},[s,S]),M=i.useCallback(j=>{s.update({align:j}),S("align")},[s,S]),O=sn(o,R.style,u),c=ln(R.align,v),d=i.useMemo(()=>({style:O,onStyleChange:C,align:c,onAlignChange:M,showToc:L.showToc!==!1,showStyle:L.showStyle!==!1,showAlign:L.showAlign!==!1,padding:L.padding,width:L.width,maxWidth:L.maxWidth,editLayout:"fill"}),[O,C,c,M,L]),g=i.useMemo(()=>({kind:"page",view:h,overrides:R,embed:L}),[h,R,L]),x=i.useMemo(()=>({kind:"page",fragment:f.hash,navigation:f}),[f]),k=i.useCallback(j=>a.announce(j),[a]);return l.jsx(un,{path:e,markup:t,display:d,navigation:g,fragment:x,paneScroll:Lr,announces:!0,announceFailure:k,onDocumentShown:r})},Do=({path:e,markup:t,variant:n,onDocumentShown:r})=>{const{config:o,viewSettings:s}=P(),a=ue(g=>g.style),u=ue(g=>g.align),[v,m]=i.useState(()=>sn(o,void 0,a)),f=ln(void 0,u),p=i.useCallback(g=>s.update({align:g}),[s]),{maximized:h,onDocumentLink:R,pendingHash:L,onHashConsumed:S,announceFailure:C,paneScroll:M}=n,O=i.useMemo(()=>({style:v,onStyleChange:m,align:f,onAlignChange:p,showToc:h,showStyle:h,showAlign:h,padding:void 0,width:void 0,maxWidth:void 0,editLayout:h?"fill":"content"}),[v,f,p,h]),c=i.useMemo(()=>({kind:"panel",onDocumentLink:R}),[R]),d=i.useMemo(()=>({kind:"panel",fragment:L,consume:S}),[L,S]);return l.jsx(un,{path:e,markup:t,display:O,navigation:c,fragment:d,paneScroll:M,announces:!1,announceFailure:C,onDocumentShown:r})},fn=({path:e,markup:t,variant:n,onDocumentShown:r})=>n.kind==="page"?l.jsx(No,{path:e,markup:t,variant:n,onDocumentShown:r}):l.jsx(Do,{path:e,markup:t,variant:n,onDocumentShown:r});function Po({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const mn=b.forwardRef(Po);function _o({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Fo=b.forwardRef(_o);function $o({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const qo=b.forwardRef($o);function Io({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}),b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Bo=b.forwardRef(Io);function Ho({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const Uo=b.forwardRef(Ho);function zo({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}),b.createElement("path",{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"}))}const Zo=b.forwardRef(zo);function Vo({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),b.createElement("path",{fillRule:"evenodd",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",clipRule:"evenodd"}))}const hn=b.forwardRef(Vo);function Go({title:e,titleId:t,...n},r){return b.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?b.createElement("title",{id:t},e):null,b.createElement("path",{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"}),b.createElement("path",{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"}))}const Ko=b.forwardRef(Go),pn=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=P(),[s,a]=i.useState(!1),u=()=>{o===void 0||s||(a(!0),o(e).then(v=>{v&&t()}).finally(()=>a(!1)))};return l.jsxs("div",{className:"aqmx-callout aqmx-edit-grant","data-testid":n,children:[l.jsx("p",{className:"aqmx-callout-title",children:r.editGrantTitle}),l.jsx("p",{className:"aqmx-callout-body",children:r.editGrantBody}),l.jsxs("div",{className:"aqmx-edit-grant-actions",children:[o===void 0?l.jsx("a",{className:"aqmx-callout-action",href:e,target:"_blank",rel:"noopener","data-testid":`${n}-open`,children:r.editGrantAction}):l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":s,"data-testid":`${n}-open`,onClick:u,children:r.editGrantAction}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},wt=(e,t,n)=>{const r=e.modifiedAt===null?Number.NaN:Date.parse(e.modifiedAt);return n(Number.isNaN(r)?e.id:t.format(r),e.author===null?"":e.author)},Wo=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:u,announcer:v}=P(),m=i.useRef(null),f=i.useRef(null),p=i.useId(),[h,R]=i.useState(null),[L,S]=i.useState(0),[C,M]=i.useState(null),[O,c]=i.useState(null),d=i.useMemo(()=>new Intl.DateTimeFormat(u,{dateStyle:"medium",timeStyle:"short"}),[u]);i.useLayoutEffect(()=>{const A=m.current;if(A!==null)if(n&&!A.open){const D=A.ownerDocument.activeElement;f.current=D instanceof HTMLElement?D:null,M(null),c(null),A.showModal()}else!n&&A.open&&(A.close(),f.current?.isConnected===!0&&f.current.focus(),f.current=null)},[n]),i.useEffect(()=>{if(!n)return;const A=new AbortController;return R(null),o.revisions(e,A.signal).then(D=>{"kind"in D&&R(D)}),()=>A.abort()},[n,o,e,L]),i.useEffect(()=>{if(!n||C===null)return;const A=new AbortController;return c(null),o.revision(e,C,A.signal).then(D=>{"kind"in D&&c(D)}),()=>A.abort()},[n,o,e,C]);const g=()=>{O===null||O.kind!=="revision"||(s.replaceDraft(e,O.text),v.announce(a.historyRestored(t)),r())},x=A=>{A.key!=="Escape"||A.defaultPrevented||(Ve(A),r())},k=A=>{A.target===A.currentTarget&&r()},j=h!==null&&h.kind==="revisions"?h.revisions.find(A=>A.id===C):void 0;return l.jsx("dialog",{ref:m,className:"aqmx-confirm aqmx-history","aria-labelledby":p,"data-testid":"markdown-explorer-history",onKeyDown:x,onClick:k,onCancel:A=>A.preventDefault(),children:l.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[l.jsx("p",{id:p,className:"aqmx-confirm-title",children:a.historyTitle(t)}),h===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):h.kind==="failure"?l.jsx(le,{failure:h.failure,alert:!1,onRetry:()=>S(A=>A+1),testId:"markdown-explorer-history-failure"}):h.revisions.length===0?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:a.historyEmpty}):l.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:h.revisions.map(A=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":A.id===C,"data-testid":"markdown-explorer-history-entry",onClick:()=>M(A.id),children:[l.jsx("span",{children:wt(A,d,a.historyEntry)}),A.current?l.jsx("span",{className:"aqmx-history-mark",children:a.historyCurrent}):null,A.kept?l.jsx("span",{className:"aqmx-history-mark",children:a.historyKept}):null]})},A.id))}),C===null?null:O===null?l.jsx("p",{className:"aqmx-history-note",children:a.historyLoading}):O.kind==="failure"?l.jsx(le,{failure:O.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):l.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":j===void 0?a.historyTitle(t):wt(j,d,a.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:O.text})}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":"markdown-explorer-history-close",onClick:r,children:a.historyClose}),l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":O===null||O.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:g,children:a.historyRestore})]})]})})},Xo=e=>{const{documents:t}=P(),n=i.useCallback(()=>t.peek(e),[t,e]),r=i.useCallback(()=>t.peekSeeded(e),[t,e]),o=i.useSyncExternalStore(t.subscribe,n,r),s=re(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:N.lastPathSegment(e)}:{edit:s.kind==="markdown"?s.edit:null,name:s.name}},ne=e=>{e.stopPropagation()},Yo=({path:e,documentName:t,iconOnly:n,previewAvailable:r})=>{const{draftConverter:o,edits:s,labels:a}=P(),u=i.useSyncExternalStore(s.subscribe,()=>s.session(e)!==void 0,()=>!1),[v,m]=i.useState(!1),f=()=>{if(!u){s.start(e,s.viewAnchor(e));return}s.flush(e),s.session(e)?.dirty===!0?m(!0):s.close(e)},p=()=>{u||(Bn(),r&&s.previewShown()&&o?.prepare?.())},h=n?a.editDocumentNamed(t):null;return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:h===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:u?a.closeEditor:h===null?a.editDocument:h,"aria-label":h===null?void 0:h,"aria-pressed":u,"data-testid":"markdown-explorer-document-edit",onClick:f,onDoubleClick:ne,onPointerEnter:p,onFocus:p,children:[l.jsx(Ko,{"aria-hidden":"true"}),h===null?l.jsx("span",{children:a.editDocumentLabel}):null]}),l.jsx(Ft,{open:v,title:a.unsavedTitle,body:a.unsavedBody(t),confirmLabel:a.unsavedDiscard,cancelLabel:a.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{m(!1),s.close(e)},onCancel:()=>m(!1)})]})},Qo=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=P(),o=n?r.editExternallyNamed(t):null;return l.jsxs("a",{className:o===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",href:e,target:"_blank",rel:"noopener noreferrer",title:o===null?r.editExternally:o,"aria-label":o===null?void 0:o,"data-testid":"markdown-explorer-document-edit-external",onDoubleClick:ne,children:[l.jsx(qo,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},Jo=({session:e})=>{const{labels:t}=P(),n=An(t,e);return l.jsx("p",{className:"aqmx-edit-status",title:n===""?void 0:n,"data-testid":"markdown-explorer-edit-status","data-aqmx-save":e.save.kind,children:n})},es=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{draftConverter:s,edits:a,labels:u}=P(),v=It(),[m,f]=i.useState(!1);if(r.phase.kind!=="editing")return null;const p=r.save.kind==="saving",h=p||!r.dirty,R=()=>{a.flush(e);const C=a.session(e);C===void 0||!C.dirty||C.save.kind==="saving"||a.save(e)},L=C=>n?{className:"aqmx-icon-button","aria-label":C}:{className:"aqmx-icon-button aqmx-labelled-button"},S=()=>{v||s?.prepare?.()};return l.jsxs(l.Fragment,{children:[r.save.kind==="conflicts"?l.jsxs("button",{type:"button",...L(u.conflictNext),title:u.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>a.nextConflict(e),onDoubleClick:ne,children:[l.jsx(Bo,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:u.conflictNext})]}):null,o?l.jsxs("button",{type:"button",...L(u.previewToggle),title:u.previewToggle,"aria-pressed":v,"data-testid":"markdown-explorer-edit-preview-toggle",onClick:()=>a.setPreviewShown(!v),onDoubleClick:ne,onPointerEnter:S,onFocus:S,children:[l.jsx(hn,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:u.previewToggle})]}):null,r.history?l.jsxs("button",{type:"button",...L(u.historyOpen),title:u.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>f(!0),onDoubleClick:ne,children:[l.jsx(Uo,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:u.historyOpen})]}):null,l.jsxs("button",{type:"button",...L(u.saveDraft),title:u.saveDraftTooltip,"aria-disabled":h,"aria-busy":p,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:R,onDoubleClick:ne,children:[l.jsx(Zo,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:u.saveDraft})]}),r.history?l.jsx(Wo,{path:e,documentName:t,open:m,onClose:()=>f(!1)}):null]})},ts=({path:e,session:t})=>{const{edits:n}=P();return t.save.kind!=="grant"?null:l.jsx(pn,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},ns=e=>{const{documents:t}=P(),n=i.useCallback(()=>t.peek(e),[t,e]),r=i.useCallback(()=>t.peekSeeded(e),[t,e]),o=i.useSyncExternalStore(t.subscribe,n,r);return re(o)?.document.kind==="markdown"},gn=e=>{const{config:t}=P(),n=he(),r=i.useCallback(()=>n(q.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return i.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])},rs=new Set,os=(e,t)=>{const{documents:n,announcer:r,labels:o}=P(),s=i.useCallback(()=>n.peek(e),[n,e]),a=i.useCallback(()=>n.peekSeeded(e),[n,e]),u=i.useSyncExternalStore(n.subscribe,s,a),v=i.useCallback(()=>n.answerStampOf(e),[n,e]),m=i.useSyncExternalStore(n.subscribe,v,v),[f]=i.useState(()=>new Set),[p,h]=i.useState(rs),[R,L]=i.useState(null);R!==null&&R.path!==e&&L(null);const S=i.useRef(null);i.useLayoutEffect(()=>(S.current=e,()=>{S.current=null}),[e]);const C=i.useCallback(()=>{const c=e,d=n.peek(c);if(f.has(c)||d?.status==="pending")return;const g=t&&!Qt(d);f.add(c),h(new Set(f)),L(null),(async()=>{try{const x=await n.refresh(c);if(S.current!==c||x.status==="superseded")return;if(x.status==="failed"){L({path:c,failure:x.failure,stamp:n.answerStampOf(c)}),r.announce(o.documentRefreshFailed(te(o,x.failure.reason)));return}const k=re(n.peek(c));if(g||k===null||k.document.kind==="failure")return;r.announce(o.documentRefreshed(k.document.name))}finally{f.delete(c),h(new Set(f))}})()},[e,t,f,n,r,o]),M=p.has(e),O=R!==null&&R.path===e&&R.stamp===m?R.failure:null;return{refreshing:M,unavailable:M||u?.status==="pending",failure:O,refresh:C}},vn=Object.freeze({kind:"page"}),wn=({path:e,placement:t,markup:n})=>{const{labels:r}=P(),{refreshing:o,unavailable:s,failure:a,refresh:u}=os(e,t.kind==="page"),v=ns(e),m=Xo(e),f=$t(e),p=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,h=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,R=t.kind==="panel",L=t.kind==="panel"?t.documentName:m.name,S=t.kind==="page"||t.maximized;return l.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":f===void 0?void 0:"true",children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[f===void 0?null:l.jsx(Jo,{session:f}),f===void 0?null:l.jsx(es,{path:e,documentName:L,iconOnly:R,session:f,previewAvailable:S}),f===void 0&&v?l.jsxs("button",{type:"button",className:h===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h===null?r.showMarkup:h,"aria-label":h===null?void 0:h,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:ne,children:[l.jsx(Fo,{"aria-hidden":"true"}),h===null?l.jsx("span",{children:r.showMarkupLabel}):null]}):null,f!==void 0||m.edit?.kind==="inline"?l.jsx(Yo,{path:e,documentName:L,iconOnly:R,previewAvailable:S}):m.edit?.kind==="external"?l.jsx(Qo,{href:m.edit.href,documentName:L,iconOnly:R}):null,f===void 0?l.jsxs("button",{type:"button",className:p===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:p===null?r.refreshDocument:p,"aria-label":p===null?void 0:p,"aria-disabled":s,"aria-busy":o,"data-aqmx-busy":o?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:u,onDoubleClick:ne,children:[l.jsx(mn,{"aria-hidden":"true"}),p===null?l.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),f!==void 0||a===null?null:l.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":a.reason,children:r.documentRefreshFailed(te(r,a.reason))}),f===void 0?null:l.jsx(ts,{path:e,session:f})]})},ss=({location:e})=>{const t=e.doc,n=i.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=gn(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",children:[l.jsx(wn,{path:t,placement:vn,markup:r}),l.jsx(fn,{path:t,markup:e.markup,variant:n})]})},xn=({holds:e,testId:t})=>{const{labels:n,announcer:r}=P(),o=i.useId();i.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=i.useCallback(()=>r.shownIn(o),[r,o]),a=i.useSyncExternalStore(r.subscribe,s,s);return l.jsx("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]})},se=Object.freeze([]),ls=e=>{const t=new Set;let n=se,r=[],o=!1;const s=[],a=f=>{n=f;for(const p of[...t])p()},u=()=>s.at(-1)?.region,v=f=>{const p=u();f(),u()!==p&&n!==se&&a(se)},m=()=>{o=!1;const f=r.map(p=>"sentence"in p?p.sentence:p.list(p.items));r=[],a(Object.freeze(f))};return{announce:f=>{if(typeof f=="string")r.push({sentence:f});else{const p=r.find(h=>"list"in h&&h.list===f.list);p!==void 0&&"items"in p?p.items.push(f.item):r.push({list:f.list,items:[f.item]})}o||(o=!0,n!==se&&a(se),e.request(m))},subscribe:f=>(t.add(f),()=>{t.delete(f)}),claim:f=>{const p={region:f};return v(()=>s.push(p)),()=>v(()=>{const h=s.indexOf(p);h!==-1&&s.splice(h,1)})},shownIn:f=>u()===f?n:se}},ce=Object.freeze({status:"cancelled"}),is=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(N.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return N.failureOf(n,r)},as=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((m,f)=>globalThis.fetch(m,f)),o=(m,f)=>`${e}/${m}?${new URLSearchParams(f).toString()}`,s=async(m,f,p,h)=>{let R;try{R=await r(m,{credentials:"same-origin",...f,headers:{Accept:"application/json",...f.headers}})}catch{return h({reason:"failed"})}R.status===401&&t(null);const L=R.headers.get(N.EXPLORER_SCOPE_HEADER);L!==null&&t(L);let S;try{S=await R.json()}catch{return h({reason:N.failureReasonOfStatus(R.status)})}let C;try{C=p(S)}catch{C=!1}if(C)return S;const M=is(S);return h(M!==null?M:{reason:R.status===200?"failed":N.failureReasonOfStatus(R.status)})},a={[N.EXPLORER_PROOF_HEADER]:N.EXPLORER_REFRESH_PROOF},u={[N.EXPLORER_PROOF_HEADER]:N.EXPLORER_EDIT_PROOF,"Content-Type":`${N.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},v=async(m,f,p)=>{const h=await s(m,f,p,R=>N.failureDocument(R.reason,R.code));return f.signal.aborted?ce:h};return{tree:m=>s(o("tree",{[N.EXPLORER_DATA_QUERY.source]:m}),{method:"GET"},N.isExplorerTreeResult,f=>({status:"error",failure:f})),children:async(m,f,p)=>{const h=await s(o("children",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:p},N.isExplorerChildrenResult,R=>({status:"error",failure:R}));return p.aborted?ce:h},ancestors:async(m,f,p)=>{const h=await s(o("ancestors",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:p},N.isExplorerAncestorsResult,R=>({status:"error",failure:R}));return p.aborted?ce:h},reveal:async(m,f,p)=>{const h=await s(o("reveal",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:p},N.isExplorerRevealResult,R=>({status:"error",failure:R}));return p.aborted?ce:h},document:(m,{refresh:f})=>s(o("document",{[N.EXPLORER_DATA_QUERY.path]:m}),f?{method:"GET",headers:a}:{method:"GET"},N.isExplorerDocument,p=>N.failureDocument(p.reason,p.code)),text:async(m,f)=>{const p=await s(o("text",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerTextAnswer,h=>N.failureDocument(h.reason,h.code));return f.aborted?ce:p},edit:(m,f)=>v(o("edit",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerEditAnswer),save:(m,f,p,h)=>v(o("save",{[N.EXPLORER_DATA_QUERY.path]:m,[N.EXPLORER_DATA_QUERY.base]:f}),{method:"POST",headers:u,body:p,signal:h},N.isExplorerSaveAnswer),preview:(m,f,p)=>v(o("preview",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"POST",headers:u,body:f,signal:p},N.isExplorerPreviewAnswer),revisions:(m,f)=>v(o("revisions",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerRevisionsAnswer),revision:(m,f,p)=>v(o("revision",{[N.EXPLORER_DATA_QUERY.path]:m,[N.EXPLORER_DATA_QUERY.revision]:f}),{method:"GET",signal:p},N.isExplorerRevisionAnswer),refresh:m=>s(o("refresh",{[N.EXPLORER_DATA_QUERY.source]:m}),{method:"POST",headers:a},N.isExplorerTreeResult,f=>({status:"error",failure:f}))}},cs=()=>{let e=null,t=null;return{settle:n=>{e=n},mayMove:n=>e!==n,move:(n,r,o)=>{e=r,t={sourceId:n,path:r,ancestors:o}},take:(n,r)=>{const o=t!==null&&t.sourceId===n&&t.path===r?t.ancestors:null;return t=null,o}}},ds=e=>{const t=Q.readStorage(e);if(t===null)return q.NO_TREE_SETTING_CHANGES;try{return q.readTreeSettingChanges(JSON.parse(t))}catch(n){return console.warn(`[markdown-explorer] localStorage key ${JSON.stringify(e)} does not hold JSON; using the default tree settings.`,n),q.NO_TREE_SETTING_CHANGES}},xt=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=ds(e);n={changes:s,settings:q.applyTreeSettingChanges(t,s)}}return n},o=ae();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:a,settings:u}=r(),v=q.recordTreeSettingChange(a,s,q.advanceTreeSetting(u,s)[s],t);return n={changes:v,settings:q.applyTreeSettingChanges(t,v)},o.emit(),Q.writeStorage(e,q.serializeTreeSettingChanges(v)),n.settings}}},us=Object.freeze({status:"refreshed"}),fs=Object.freeze({status:"superseded"}),ze=Object.freeze({status:"deferred"}),ms=Yt(ze),En=4,hs=En-1,Et=Object.freeze({status:"loading"}),ps=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),gs=e=>{const t=new Map,n=Xt(),r=new Map,o=new Map,s=new Map,a=new Map,u=ae(),v=new Set;let m=0,f=0;const p={direct:null,bulk:null},h=new Set;let R=!1,L=0;const S=()=>{L+=1,u.emit()},C=w=>o.get(w)??0,M=w=>{let E=a.get(w);return E===void 0&&(E={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(w,E)),E},O=(w,E,y)=>{w.inFlight.delete(E),m-=1,y.lane==="bulk"&&(f-=1)},c=w=>{const E=a.get(w);if(E!==void 0){for(const[y,T]of[...E.inFlight])O(E,y,T),T.controller.abort();E.direct.clear(),E.bulk.clear(),E.unclaimed.clear()}},d=w=>{const E=C(w)+1;return o.set(w,E),c(w),E},g=(w,E)=>{const y=ge(w),T={promise:w,opened:E,stale:!1,loadedAt:y?.status==="ok"?y.loadedAt:null};return w.status==="pending"&&w.then(_=>{_.status==="ok"&&(T.loadedAt=_.loadedAt)}),T},x=w=>{let E=r.get(w);return E===void 0&&(E=new Map,r.set(w,E)),E},k=w=>{const E=[...a.keys()],y=p[w],T=y===null?0:E.indexOf(y)+1;for(let _=0;_<E.length;_+=1){const $=E[(T+_)%E.length],H=$===void 0?void 0:a.get($);if(!($===void 0||H===void 0)){for(const I of H[w])if((H.claims.get(I)??0)!==0)return H[w].delete(I),p[w]=$,{sourceId:$,path:I}}}return null},j=(w,E,y,T)=>{const _=a.get(w);if(_===void 0||_.inFlight.get(E)!==y)return;O(_,E,y);const $=(_.claims.get(E)??0)>0,H=x(w);if(T.status==="ok"?H.set(E,{status:"loaded",entries:T.entries}):T.status==="error"&&$?H.set(E,{status:"failed",failure:T.failure}):H.delete(E),S(),T.status==="error"&&$){const I={sourceId:w,path:E,failure:T.failure};for(const ee of[...v])ee(I)}D()},A=(w,E,y)=>{const T={controller:new AbortController,lane:y};M(w).inFlight.set(E,T),m+=1,y==="bulk"&&(f+=1),e.children(w,E,T.controller.signal).then(_=>j(w,E,T,_),()=>j(w,E,T,ps))},D=()=>{for(;m<En;){const w=k("direct");if(w!==null){A(w.sourceId,w.path,"direct");continue}const E=f<hs?k("bulk"):null;if(E===null)return;A(E.sourceId,E.path,"bulk")}},F=(w,E,y)=>{if(!(E.direct.delete(y)||E.bulk.delete(y))){const _=E.inFlight.get(y);if(_===void 0)return!1;O(E,y,_),_.controller.abort()}return r.get(w)?.delete(y),!0},z=()=>{R=!1;let w=!1;for(const E of h){const y=M(E);for(const T of y.unclaimed)(y.claims.get(T)??0)===0&&F(E,y,T)&&(w=!0);y.unclaimed.clear()}h.clear(),w&&(S(),D())},V=(w,E)=>{t.set(w,g(me(e.tree(w)),E))},W=(w,E,y)=>{d(w);const T=g(Yt(E),y);return t.set(w,T),r.delete(w),S(),D(),T},Z=(w,E,y,T)=>{if(y!==C(w)||t.get(w)!==E)return;const _=ge(E.promise);if(!(T.status!=="ok"||_?.status!=="ok"||E.loadedAt===null||T.loadedAt<=E.loadedAt)){if(be(_.entries,T.entries)){E.loadedAt=T.loadedAt;return}W(w,T,E.opened)}},G=(w,E)=>{const y=t.get(w);return y!==void 0&&ge(y.promise)?.status===E},J=(w,E)=>{E.stale=!1;const y=C(w);e.tree(w).then(T=>Z(w,E,y,T))};return{read:w=>t.get(w)?.promise??ms,open:w=>{const E=n.resumes(w),y=n.hold(w),T=t.get(w);return T===void 0||G(w,"deferred")?(V(w,!0),S()):E||(T.opened&&G(w,"error")?(V(w,!0),S()):(T.opened=!0,T.stale&&G(w,"ok")&&J(w,T))),y},retry:w=>{G(w,"error")&&(V(w,!0),S())},seed:(w,E)=>{const y=E.then($=>$===null?ze:$,()=>ze),T=t.get(w);if(T!==void 0&&G(w,"ok")){const $=C(w);y.then(H=>Z(w,T,$,H));return}d(w);const _=g(me(y),T?.opened===!0);t.set(w,_),r.delete(w),D(),y.then($=>{t.get(w)===_&&($.status==="deferred"&&n.isHeld(w)&&V(w,_.opened),S())})},refresh:async w=>{const E=(s.get(w)??0)+1;s.set(w,E);const y=await e.refresh(w);if(s.get(w)!==E)return fs;if(y.status==="error")return{status:"failed",failure:y.failure};const T=t.get(w);if(!(T!==void 0&&T.loadedAt!==null&&G(w,"ok")&&T.loadedAt>y.loadedAt)){const $=W(w,y,!0);if(T!==void 0&&T.promise.status==="pending"){const H=C(w);T.promise.then(I=>Z(w,$,H,I))}}for(const[$,H]of t)$!==w&&ge(H.promise)?.status==="ok"&&(H.stale=!0);return us},children:(w,E)=>r.get(w)?.get(E),claimChildren:(w,E)=>{const y=M(w),T=x(w);let _=!1,$=!1;for(const[I,ee]of E)y.claims.set(I,(y.claims.get(I)??0)+1),T.get(I)===void 0?(T.set(I,Et),y[ee].add(I),_=!0,$=!0):ee==="direct"&&y.bulk.delete(I)&&(y.direct.add(I),$=!0);_&&S(),$&&D();let H=!1;return()=>{if(!H){H=!0;for(const I of E.keys()){const ee=(y.claims.get(I)??0)-1;ee>0?y.claims.set(I,ee):(y.claims.delete(I),y.unclaimed.add(I))}h.add(w),!R&&(R=!0,queueMicrotask(z))}}},retryChildren:(w,E)=>{const y=r.get(w);if(y===void 0||y.get(E)?.status!=="failed")return;const T=M(w);if((T.claims.get(E)??0)>0){y.set(E,Et),T.direct.add(E),S(),D();return}y.delete(E),S()},pendingChildren:w=>{const E=a.get(w);return E===void 0?0:E.direct.size+E.bulk.size+E.inFlight.size},clear:()=>{for(const w of new Set([...t.keys(),...r.keys(),...o.keys(),...a.keys()]))d(w);for(const[w,E]of s)s.set(w,E+1);t.clear(),r.clear(),S()},subscribeChildrenFailures:w=>(v.add(w),()=>{v.delete(w)}),subscribe:u.subscribe,version:()=>L}},vs=(e,t)=>{let n=e;const r=ae();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},ws=1;let ve=0,oe=null;const xs=()=>{const{documentElement:e,body:t}=document;ve===0&&(oe={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"),ve+=1;let n=!1;return()=>{n||(n=!0,ve-=1,!(ve>0||oe===null)&&(e.style.overflow=oe.htmlOverflow,t.style.overflow=oe.bodyOverflow,e.style.scrollbarGutter=oe.htmlGutter,t.style.scrollbarGutter=oe.bodyGutter,oe=null))}},Es=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],bt=1,yt=e=>e.getClientRects().length>0,Pe="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.",bs=e=>{if(!yt(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+ws)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. ${Pe}`;if(t.height<bt)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. ${Pe}`;for(const{selector:r,name:o}of Es)for(const s of e.querySelectorAll(r)){if(!yt(s))continue;const a=s.getBoundingClientRect().height;if(a<bt)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. ${Pe}`}return null},ys=e=>{let t=!1;const n=()=>{if(t)return;const o=bs(e);o!==null&&(t=!0,console.error(o))},r=typeof ResizeObserver>"u"?null:new ResizeObserver(n);return r?.observe(e),window.addEventListener("resize",n),n(),()=>{r?.disconnect(),window.removeEventListener("resize",n)}},Ss=(e,t)=>{i.useEffect(()=>e?xs():void 0,[e]),i.useEffect(()=>{const n=t.current;if(!(!e||n===null))return ys(n)},[e,t])},St='[data-testid="markdown-explorer-view-switch"]',ks=[{control:St,successors:[St,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],Rs=e=>{for(const t of ks){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},Ts=(e,t)=>{const n=i.useRef(null);i.useEffect(()=>{const o=u=>{const v=e.current;n.current=v!==null&&u instanceof Element&&v.contains(u)?Rs(u):null},s=u=>o(u.target);o(document.activeElement);const a=u=>{const v=u.target;u.relatedTarget!==null||!(v instanceof Element)||queueMicrotask(()=>{n.current?.element===v&&v.isConnected&&document.activeElement!==v&&(n.current=null)})};return document.addEventListener("focusin",s),document.addEventListener("focusout",a),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",a)}},[e]);const r=i.useRef(t);i.useLayoutEffect(()=>{if(r.current===t)return;r.current=t;const o=n.current;if(o===null)return;const s=()=>{const v=document.activeElement;if(v!==null&&v!==document.body&&v!==o.element)return!0;const m=e.current;if(m===null)return!0;for(const f of o.control.successors)for(const p of m.querySelectorAll(f))if(p!==o.element&&(p.focus({preventScroll:!0}),document.activeElement===p))return!0;return!1};if(s())return;const a=e.current;if(a===null)return;const u=new MutationObserver(()=>{s()&&u.disconnect()});return u.observe(a,{childList:!0,subtree:!0}),()=>u.disconnect()},[t,e])},Cs=i.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-_XQR-9tV.cjs")).then(e=>({default:e.TreeLayout}))),Os=i.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-HMzVDYWq.cjs")).then(e=>({default:e.MultiLayout}))),As=64,Ls={request:e=>{requestAnimationFrame(e)}},kt=e=>{e.documents.clear(),e.trees.clear()},_e=(e,t)=>{t.tree!==null&&e.trees.seed(t.tree.sourceId,t.tree.result);for(const{path:n,document:r}of t.documents)e.documents.seed(n,r)},js=(e,t)=>{const[n,r]=i.useState(()=>({overrides:t,locale:e,labels:Ie(e,t)}));if(n.locale===e&&Cn(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:Ie(e,t)};return r(o),o.labels},Ms=(e,t,n)=>{const[r,o]=i.useState(()=>({scope:t,store:xt(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:xt(e,n)};return o(s),s.store},Fe=(e,t)=>{const[n,r]=i.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},Ns=()=>ls(Ls),Rt="on",Ds="off",Ps=Object.freeze({kind:"unavailable"}),_s=e=>{if(e!==void 0&&(e===null||typeof e!="object"||typeof e.convert!="function"))throw new TypeError("[markdown-explorer] draftConverter must be an object with a convert function")},Fs=(e,t)=>{const n=re(e.peek(t));return n===null||n.document.kind==="failure"?N.lastPathSegment(t):n.document.name},$s=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:u,lockDocumentScroll:v=!1,onMathDiagnostics:m,onEditGrant:f,draftConverter:p})=>{Q.assertStorageNamespace(n),_s(p);const h=Lt(r),R=On(s),L=js(h,o),{revalidate:S}=X.useRevalidator(),C=i.useRef(()=>{}),M=X.useHref(t.dataPath),[O]=i.useState(()=>{const y=as({dataPath:M,onScope:_=>C.current(_)}),T={documents:sr({client:y,capacity:Math.max(As,t.multiView.maxPanels*2)}),trees:gs(y)};return _e(T,e),Q.syncStorageScope(n,e.scope),{data:y,...T,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(O.aligned.pageData!==e||O.aligned.storageNamespace!==n){const y=O.aligned.pageData;O.aligned.pageData=e,O.aligned.storageNamespace=n,y!==e&&(y.scope!==e.scope?O.aligned.pendingReader=e:_e(O,e)),Q.syncStorageScope(n,e.scope)}const c=Ms(Q.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);i.useLayoutEffect(()=>{const y=O.aligned.pendingReader;y!==null&&(O.aligned.pendingReader=null,kt(O),_e(O,y))},[e,O]),i.useLayoutEffect(()=>{let y=!1;return C.current=T=>{T===e.scope||y||(y=!0,T!==null&&(kt(O),Q.clearExplorerStorage(n)),S())},()=>{C.current=()=>{}}},[e,S,O,n]);const d=i.useRef(t.settingsCookie);i.useLayoutEffect(()=>{d.current=t.settingsCookie},[t.settingsCookie]);const[g]=i.useState(()=>vs(e.settings,y=>{document.cookie=q.viewSettingsCookieString(d.current,y,window.location.protocol==="https:")})),x=Fe(e.scope,Ns),k=Fe(e.scope,cs),j=i.useRef(L);i.useLayoutEffect(()=>{j.current=L},[L]);const A=Fe(e.scope,()=>Nn({data:O.data,conflictLabels:()=>({ours:j.current.conflictOurs,theirs:j.current.conflictTheirs}),onSaveSettled:(y,T)=>{T.kind==="saved"&&O.documents.refresh(y);const _=Ln(j.current,T,Fs(O.documents,y));_!==null&&x.announce(_)},previewSetting:{read:()=>Q.readStorage(Q.storageKeys(n).editPreview)===Rt,write:y=>Q.writeStorage(Q.storageKeys(n).editPreview,y?Rt:Ds)}})),D=i.useMemo(()=>me(e.notices.catch(()=>[])),[e.notices]),F=e.sources.map(y=>y.id).join(`
12
+ `),z=i.useMemo(()=>q.withExplorerSources(t,F.split(`
13
+ `)),[t,F]),V=i.useRef(m);i.useLayoutEffect(()=>{V.current=m},[m]);const[W]=i.useState(()=>(y,T)=>{V.current?.(y,T)}),Z=m===void 0?void 0:W,G=i.useRef(p);i.useLayoutEffect(()=>{G.current=p},[p]);const[J]=i.useState(()=>{let y=!1;return{convert:(T,_)=>{const $=G.current;return $===void 0?Promise.resolve(Ps):$.convert(T,_)},prepare:()=>{try{G.current?.prepare?.()}catch(T){if(y)return;y=!0,console.error("[markdown-explorer] the draft converter's prepare threw",T)}}}}),w=p===void 0?void 0:J,E=i.useMemo(()=>({config:z,labels:L,locale:h,theme:R,storageNamespace:n,scope:e.scope,sources:e.sources,notices:D,documents:O.documents,trees:O.trees,data:O.data,viewSettings:g,treeSettings:c,announcer:x,reveals:k,edits:A,onEditGrant:f,draftConverter:w,renderTreeFailure:u,reportMathDiagnostics:Z}),[z,L,h,R,n,e.scope,e.sources,D,O,g,c,x,k,A,f,w,u,Z]);return l.jsx(jt,{value:E,children:l.jsx(Is,{renderFrame:a,lockDocumentScroll:v},e.scope)})},qs=({ref:e,theme:t,view:n,children:r})=>{const[o]=i.useState(Ur);return l.jsx("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})},Is=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=P(),o=Se(),{hash:s}=X.useLocation(),a=he(),u=i.useRef(null);Ss(t,u),i.useLayoutEffect(()=>{o.kind==="redirect"&&a(`${o.href}${s}`,"browse")},[o,s,a]);const{location:v}=o,m=v.view;Ts(u,m);const f=v.view==="tree"?l.jsx(i.Suspense,{fallback:l.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading"}),children:l.jsx(Cs,{location:v})}):v.view==="multi"?l.jsx(i.Suspense,{fallback:l.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading"}),children:l.jsx(Os,{location:v})}):l.jsx(ss,{location:v}),p=l.jsxs(qs,{ref:u,theme:n,view:m,children:[f,l.jsx($n,{}),l.jsx(xn,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?p:e({view:m,children:p})},Bs=({currentUrl:e,nextUrl:t,formMethod:n,defaultShouldRevalidate:r})=>n===void 0&&e.href===t.href&&r;exports.ALLOW_KEY_REPEAT=ye;exports.CONFLICT_OURS_MARKER=Nt;exports.CONFLICT_SEPARATOR=Dt;exports.CONFLICT_THEIRS_MARKER=Pt;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=Tt;exports.DocumentPane=fn;exports.DocumentRefreshBar=wn;exports.EXPLORER_THEMES=Be;exports.EditGrantNotice=pn;exports.ExplorerLink=Vt;exports.FailureView=le;exports.ForwardRef=mn;exports.ForwardRef$1=hn;exports.ImageViewMemoryContext=nn;exports.LazyNativeScrollBar=Kt;exports.LiveRegion=xn;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=At;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Ze;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=Ct;exports.MARKDOWN_EXPLORER_LOCALES=qe;exports.MarkdownExplorer=$s;exports.PAGE_DOCUMENT_REFRESH=vn;exports.blockAtLine=zt;exports.consumeKey=Ve;exports.createEmitter=ae;exports.explorerNavigationOptions=tr;exports.failureTitleOf=te;exports.findConflictsInLines=_t;exports.focusWithoutScroll=We;exports.frameTopOf=Ht;exports.lineTopIn=Zt;exports.loadedOf=re;exports.positionInSource=Jn;exports.resolveMarkdownExplorerLabels=Ie;exports.shouldRevalidateExplorer=Bs;exports.useExplorer=P;exports.useExplorerLocation=Se;exports.useExplorerNavigate=he;exports.useIntentPrefetch=Gt;exports.usePageMarkupToggle=gn;exports.usePreviewShown=It;exports.useViewSetting=ue;exports.visibleTopOf=Ut;