@aiquants/markdown-explorer 0.6.0 → 0.7.1

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 (65) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +58 -8
  3. package/dist/EditSurface-5nbW7NTP.cjs +2 -0
  4. package/dist/EditSurface-CaS1O6Nt.js +371 -0
  5. package/dist/{ExplorerSplit-CN5TvRj6.js → ExplorerSplit-C9Y02nvj.js} +391 -417
  6. package/dist/ExplorerSplit-D60N3_X7.cjs +1 -0
  7. package/dist/MultiLayout-CqTyFZ_i.cjs +1 -0
  8. package/dist/MultiLayout-DBpUTcCQ.js +947 -0
  9. package/dist/{NativeScrollBar-DYEv2GLV.js → NativeScrollBar-CiVlg2ob.js} +1 -1
  10. package/dist/{NativeScrollBar-CHEQgaVx.cjs → NativeScrollBar-QlOtnddZ.cjs} +1 -1
  11. package/dist/TreeLayout-bk-Ziybl.js +29 -0
  12. package/dist/TreeLayout-uwvAgr-t.cjs +1 -0
  13. package/dist/client/MarkdownExplorer.d.cts +2 -1
  14. package/dist/client/MarkdownExplorer.d.ts +2 -1
  15. package/dist/client/storage.d.cts +1 -0
  16. package/dist/client/storage.d.ts +1 -0
  17. package/dist/core/contracts.d.cts +58 -0
  18. package/dist/core/contracts.d.ts +58 -0
  19. package/dist/core/labels.d.cts +49 -0
  20. package/dist/core/labels.d.ts +49 -0
  21. package/dist/core/location.d.cts +7 -0
  22. package/dist/core/location.d.ts +7 -0
  23. package/dist/dataRoute-CcZ8PK00.cjs +1 -0
  24. package/dist/dataRoute-D1vE1wFW.js +270 -0
  25. package/dist/index-Dlkzr6Zn.cjs +13 -0
  26. package/dist/index-etFEpIE_.js +3199 -0
  27. package/dist/index.cjs +1 -1
  28. package/dist/index.d.cts +1 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +31 -30
  31. package/dist/location-DmzVAFvo.cjs +1 -0
  32. package/dist/{location-CtM94G0O.js → location-Q4sgRrUm.js} +202 -193
  33. package/dist/merge-BR4jKpIc.cjs +5 -0
  34. package/dist/merge-DfI0ro2L.js +20 -0
  35. package/dist/sanitizeWorker.cjs +1 -1
  36. package/dist/sanitizeWorker.js +173 -172
  37. package/dist/server/errors.d.cts +1 -1
  38. package/dist/server/errors.d.ts +1 -1
  39. package/dist/server/ports.d.cts +33 -1
  40. package/dist/server/ports.d.ts +33 -1
  41. package/dist/server.cjs +1 -1
  42. package/dist/server.d.cts +1 -1
  43. package/dist/server.d.ts +1 -1
  44. package/dist/server.js +882 -751
  45. package/dist/{storage-DA4ItHzl.js → storage-BSthKLSG.js} +14 -13
  46. package/dist/storage-Dgi4JXaB.cjs +1 -0
  47. package/dist/storage.cjs +1 -1
  48. package/dist/storage.js +1 -1
  49. package/dist/styles/markdown-explorer.css +1 -1
  50. package/docs/behavior/dom-hooks.md +17 -3
  51. package/docs/behavior/layout.md +6 -1
  52. package/docs/behavior/security.md +11 -1
  53. package/docs/behavior/url-contract.md +13 -4
  54. package/package.json +11 -3
  55. package/dist/ExplorerSplit-CUIbSLQm.cjs +0 -1
  56. package/dist/MultiLayout-BDcQSpa6.cjs +0 -1
  57. package/dist/MultiLayout-hPmV-bae.js +0 -922
  58. package/dist/TreeLayout-BDaIyoGT.cjs +0 -1
  59. package/dist/TreeLayout-CqzxLpoM.js +0 -23
  60. package/dist/dataRoute-CUXlMhUJ.cjs +0 -1
  61. package/dist/dataRoute-Ce6EIuu4.js +0 -206
  62. package/dist/index-B3nShkkt.cjs +0 -3
  63. package/dist/index-gJp1iXTc.js +0 -2238
  64. package/dist/location-FavgY_gB.cjs +0 -1
  65. package/dist/storage-Bkb2Axdi.cjs +0 -1
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),n=require("react"),f=require("react-router"),a=require("./location-FavgY_gB.cjs"),l=require("./index-B3nShkkt.cjs"),i=require("./ExplorerSplit-CUIbSLQm.cjs"),q=new Set,C=({location:x})=>{const{config:e}=l.useExplorer(),r=l.useExplorerNavigate(),{hash:p}=f.useLocation(),{source:c,doc:o,overrides:t}=x,[m,d]=n.useState(i.EMPTY_SELECTION),h=n.useMemo(()=>({gathered:m,onGatheredChange:d}),[m]),v=n.useCallback(s=>r(a.explorerHref(e,{view:"tree",source:c,doc:s,overrides:t}),"browse"),[r,e,c,t]),S=n.useCallback(s=>r(a.explorerHref(e,{view:"tree",source:s,doc:o,overrides:t}),"switch-source"),[r,e,o,t]),w=n.useCallback(s=>r(`${a.explorerHref(e,{view:"tree",source:s,doc:o,overrides:t})}${p}`,"browse"),[r,e,o,t,p]),E=n.useCallback(s=>r(a.explorerHref(e,{view:"multi",source:c,docs:a.canonicalMultiDocuments(e,s)}),"switch-view"),[r,e,c]),g=n.useMemo(()=>({href:a.explorerHref(e,{view:"multi",source:c,docs:o===null?[]:[o]}),target:"multi"}),[e,c,o]),b=n.useMemo(()=>({kind:"page",view:"tree",overrides:t,embed:{}}),[t]);return u.jsx(i.ExplorerSplit,{view:"tree",explorer:u.jsx(i.ExplorerPane,{mode:"tree",sourceId:c,currentPath:o,openPaths:q,onOpenDocument:v,onSourceChange:S,onRevealSource:w,viewSwitch:g,tray:h,onOpenSelection:E}),content:u.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",children:[o===null?null:u.jsx(l.DocumentRefreshBar,{path:o,placement:l.PAGE_DOCUMENT_REFRESH}),u.jsx(l.DocumentPane,{path:o,variant:b})]})})};exports.TreeLayout=C;
@@ -1,23 +0,0 @@
1
- import { jsx as a, jsxs as g } from "react/jsx-runtime";
2
- import { useState as P, useMemo as u, useCallback as i } from "react";
3
- import { useLocation as D } from "react-router";
4
- import { e as s, c as b } from "./location-CtM94G0O.js";
5
- import { u as C, a as N, D as O, P as T, b as M } from "./index-gJp1iXTc.js";
6
- import { E as R, a as _, b as G } from "./ExplorerSplit-CN5TvRj6.js";
7
- const H = /* @__PURE__ */ new Set(), I = ({ location: p }) => {
8
- const { config: e } = C(), t = N(), { hash: m } = D(), { source: n, doc: o, overrides: r } = p, [l, h] = P(R), d = u(() => ({ gathered: l, onGatheredChange: h }), [l]), v = i((c) => t(s(e, { view: "tree", source: n, doc: c, overrides: r }), "browse"), [t, e, n, r]), w = i((c) => t(s(e, { view: "tree", source: c, doc: o, overrides: r }), "switch-source"), [t, e, o, r]), S = i((c) => t(`${s(e, { view: "tree", source: c, doc: o, overrides: r })}${m}`, "browse"), [t, e, o, r, m]), E = i((c) => t(s(e, { view: "multi", source: n, docs: b(e, c) }), "switch-view"), [t, e, n]), x = u(() => ({ href: s(e, { view: "multi", source: n, docs: o === null ? [] : [o] }), target: "multi" }), [e, n, o]), f = u(() => ({ kind: "page", view: "tree", overrides: r, embed: {} }), [r]);
9
- return /* @__PURE__ */ a(
10
- _,
11
- {
12
- view: "tree",
13
- explorer: /* @__PURE__ */ a(G, { mode: "tree", sourceId: n, currentPath: o, openPaths: H, onOpenDocument: v, onSourceChange: w, onRevealSource: S, viewSwitch: x, tray: d, onOpenSelection: E }),
14
- content: /* @__PURE__ */ g("div", { className: "aqmx-document-column aqmx-tree-document", children: [
15
- o === null ? null : /* @__PURE__ */ a(O, { path: o, placement: T }),
16
- /* @__PURE__ */ a(M, { path: o, variant: f })
17
- ] })
18
- }
19
- );
20
- };
21
- export {
22
- I as TreeLayout
23
- };
@@ -1 +0,0 @@
1
- "use strict";const _=Object.freeze([".env*","*.env","*.env.*","*.env~*","*.env-*","*.env_*","*.env#*",".git",".git-credentials",".svn",".hg","node_modules","secrets",".secrets","secrets.json","secrets.yml","secrets.yaml","secrets.toml","secrets.ini","secrets.txt",".ssh",".aws",".gnupg",".docker",".kube",".terraform",".npmrc",".yarnrc",".yarnrc.yml",".netrc","_netrc",".pypirc",".pgpass",".my.cnf",".htpasswd",".vault-token","id_rsa*","id_dsa*","id_ecdsa*","id_ed25519*","*.pem","*.key","*.p8","*.p12","*.pfx","*.ppk","*.jks","*.keystore","*.kdbx","*credentials*.json","service-account*.json","*.tfstate","*.tfstate.*","*.tfvars","*.tfvars.json",".*_history","fish_history"]),N=/[\u0000-\u001f\u007f]/u,C=/\p{Cs}/u,k=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},f=e=>e.length>0&&e.length<=4096&&!C.test(e)&&!N.test(e)&&!e.includes("\\"),A=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),U=/(?:%[0-9A-Fa-f]{2})+/gu,H=new TextDecoder("utf-8"),j=/[/\\]/u,X=e=>e.replace(U,t=>H.decode(Uint8Array.from(t.slice(1).split("%").map(n=>Number.parseInt(n,16))))),w=e=>{const t=[e];let n=e;for(let r=0;r<3&&n.includes("%");r+=1){const o=X(n);if(o===n)break;t.push(o),n=o}return t.map(A)},I=e=>{if(typeof e!="string"||e.trim()===""||e.includes("/")||e.includes("\\"))throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${JSON.stringify(e)}`);const t=A(e).split("*").map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"su")},d=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const t=e.map(I),n=o=>o!==""&&t.some(s=>s.test(o)),r=o=>o!==""&&w(o).some(s=>n(s)||s.split(j).some(n));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},$=d(_),z=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),F=e=>e===void 0?$:e===!1?z:d(e),M=(e,t)=>d(e).deniesPath(t),p=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),v=Object.freeze(["file","directory"]),V=Object.freeze(["video","audio","pdf"]),G=Object.freeze(["info","warning","danger"]),Y=Object.freeze(["markdown","text","image","media","file","failure"]),m=Object.freeze({min:1,max:6}),K=1e4,u=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),J=Object.freeze(["http:","https:","mailto:"]),Q=/^[a-z0-9-]{1,64}$/u,B="https://relative.invalid/",y=64,c=(e,t)=>typeof t=="string"&&e.includes(t),a=e=>typeof e=="string"?JSON.stringify(e.length>y?`${e.slice(0,y)}…`:e):typeof e,O=e=>c(p,e),W=e=>c(v,e),g=e=>c(V,e),q=e=>c(G,e),Z=e=>c(Y,e),R=e=>typeof e=="string"&&Q.test(e),ee=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,B).protocol)}catch{return!1}},l=e=>{if(e===null||typeof e!="object")return"a failure must be an object";const{reason:t,code:n}=e;return O(t)?n!==void 0&&!R(n)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${a(n)}`:null:`unknown failure reason ${a(t)}`},T=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:t,path:n,type:r,mimeType:o,children:s,lazy:i}=e;return typeof t!="string"||t===""?"an entry needs a non-empty name":typeof n!="string"||!f(n)?"an entry needs an acceptable path":W(r)?o!==void 0&&typeof o!="string"?"an entry mimeType must be a string":i!==void 0&&typeof i!="boolean"?"an entry lazy flag must be a boolean":s!==void 0&&!Array.isArray(s)?"entry children must be an array":r==="file"&&(s!==void 0||i===!0)?"a file entry cannot have children or be lazy":i===!0&&Array.isArray(s)&&s.length>0?"a lazy directory must not list children":null:`an entry type must be "file" or "directory"; got ${a(r)}`},h=e=>{if(T(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(h)},L=e=>{if(e===null||typeof e!="object")return!1;const{status:t,entries:n,failure:r}=e;return t==="ok"?Array.isArray(n)&&n.every(h):t==="error"&&l(r)===null},te=e=>{if(e===null||typeof e!="object")return!1;const{status:t,ancestors:n,failure:r}=e;return t==="ok"?n===null||P(n):t==="error"&&l(r)===null},P=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&f(t))&&new Set(e).size===e.length,ne=e=>{if(e===null||typeof e!="object")return!1;const{status:t,source:n,ancestors:r,failure:o}=e;return t==="ok"?n===null&&r===null||typeof n=="string"&&n!==""&&P(r):t==="error"&&l(o)===null},re=e=>{if(e===null||typeof e!="object")return!1;const{status:t,loadedAt:n}=e;return t==="ok"&&!(Number.isSafeInteger(n)&&n>=0)?!1:L(e)},oe=e=>{if(e===null||typeof e!="object")return"a heading must be an object";const{text:t,depth:n,id:r}=e;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},b=e=>{if(e===null||typeof e!="object")return"a document must be an object";const t=e,{kind:n}=t;if(!Z(n))return`unknown document kind ${a(n)}`;if(n==="failure")return l(t.failure);if(typeof t.name!="string")return"a document needs a name string";switch(n){case"markdown":{const{htmlContent:r,headings:o}=t;if(typeof r!="string"||!Array.isArray(o))return"a markdown document needs htmlContent and headings";for(const s of o){const i=oe(s);if(i!==null)return i}return null}case"text":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";case"image":return u(t.url)?null:"an image document needs a root-relative url";case"media":return u(t.url)?g(t.mediaType)?null:`unknown media type ${a(t.mediaType)}`:"a media document needs a root-relative url";case"file":return u(t.url)?null:"a file document needs a root-relative url"}},x=e=>b(e)===null,se=e=>x(e)&&(e.kind==="text"||e.kind==="failure"),ie=(e,t)=>({kind:"failure",failure:S(e,t)}),S=(e,t)=>R(t)?{reason:e,code:t}:{reason:e},ae=Object.freeze(["tree","children","ancestors","reveal","document","text","refresh","asset","link-card"]),E=Object.freeze({source:"source",path:"path",version:"v"}),ce="asset",le="link-card",ue=(e,t,n)=>{const r=`${e}/${ce}?${E.path}=${encodeURIComponent(t)}`;return n===null?r:`${r}&${E.version}=${encodeURIComponent(n)}`},Ee=e=>`${e}/${le}`,fe="X-Markdown-Explorer-Scope",de="X-Markdown-Explorer",pe="refresh",Re=e=>ae.includes(e),D=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),me=e=>{const[t,...n]=p.filter(r=>D[r]===e);return t!==void 0&&n.length===0?t:"failed"};exports.DEFAULT_DENIED_PATH_SEGMENTS=_;exports.EXPLORER_DATA_QUERY=E;exports.EXPLORER_FAILURE_REASONS=p;exports.EXPLORER_FAILURE_STATUS=D;exports.EXPLORER_LINK_PROTOCOLS=J;exports.EXPLORER_MAX_HEADINGS=K;exports.EXPLORER_REFRESH_HEADER=de;exports.EXPLORER_REFRESH_HEADER_VALUE=pe;exports.EXPLORER_SCOPE_HEADER=fe;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=b;exports.entryViolation=T;exports.explorerAssetHref=ue;exports.explorerLinkCardEndpoint=Ee;exports.failureDocument=ie;exports.failureOf=S;exports.failureReasonOfStatus=me;exports.failureViolation=l;exports.isAcceptableDocumentPath=f;exports.isAcceptableUrl=ee;exports.isDeniedPath=M;exports.isExplorerAncestorsResult=te;exports.isExplorerChildrenResult=L;exports.isExplorerDataOperation=Re;exports.isExplorerDocument=x;exports.isExplorerFailureCode=R;exports.isExplorerFailureReason=O;exports.isExplorerMediaType=g;exports.isExplorerNoticeTone=q;exports.isExplorerRevealResult=ne;exports.isExplorerTextAnswer=se;exports.isExplorerTreeResult=re;exports.lastPathSegment=k;exports.resolvePathRules=F;
@@ -1,206 +0,0 @@
1
- const W = 4096;
2
- const O = 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
- ]), h = /[\u0000-\u001f\u007f]/u, b = /\p{Cs}/u, Z = (e) => {
61
- const t = e.split("/").filter((n) => n !== "").at(-1);
62
- return t === void 0 ? e : t;
63
- }, m = (e) => e.length > 0 && e.length <= 4096 && !b.test(e) && !h.test(e) && !e.includes("\\"), y = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), T = /(?:%[0-9A-Fa-f]{2})+/gu, x = new TextDecoder("utf-8"), L = /[/\\]/u, P = (e) => e.replace(
64
- T,
65
- (t) => x.decode(
66
- Uint8Array.from(
67
- t.slice(1).split("%").map((n) => Number.parseInt(n, 16))
68
- )
69
- )
70
- ), S = (e) => {
71
- const t = [e];
72
- let n = e;
73
- for (let r = 0; r < 3 && n.includes("%"); r += 1) {
74
- const s = P(n);
75
- if (s === n) break;
76
- t.push(s), n = s;
77
- }
78
- return t.map(y);
79
- }, D = (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 = y(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
83
- return new RegExp(`^${t}$`, "su");
84
- }, f = (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(D), n = (s) => s !== "" && t.some((o) => o.test(s)), r = (s) => s !== "" && S(s).some((o) => n(o) || o.split(L).some(n));
87
- return {
88
- deniesPath: (s) => s.split("/").some(r),
89
- deniesName: r
90
- };
91
- }, N = f(O), k = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), ee = (e) => e === void 0 ? N : e === !1 ? k : f(e), te = (e, t) => f(e).deniesPath(t), R = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), j = Object.freeze(["file", "directory"]), C = Object.freeze(["video", "audio", "pdf"]), w = Object.freeze(["info", "warning", "danger"]), U = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), d = Object.freeze({ min: 1, max: 6 }), ne = 1e4, l = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), re = Object.freeze(["http:", "https:", "mailto:"]), $ = /^[a-z0-9-]{1,64}$/u, z = "https://relative.invalid/", E = 64, c = (e, t) => typeof t == "string" && e.includes(t), a = (e) => typeof e == "string" ? JSON.stringify(e.length > E ? `${e.slice(0, E)}…` : e) : typeof e, I = (e) => c(R, e), H = (e) => c(j, e), X = (e) => c(C, e), se = (e) => c(w, e), v = (e) => c(U, e), g = (e) => typeof e == "string" && $.test(e), oe = (e, t) => {
92
- if (typeof e != "string") return !1;
93
- try {
94
- return t.includes(new URL(e, z).protocol);
95
- } catch {
96
- return !1;
97
- }
98
- }, u = (e) => {
99
- if (e === null || typeof e != "object") return "a failure must be an object";
100
- const { reason: t, code: n } = e;
101
- return I(t) ? n !== void 0 && !g(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${a(n)}` : null : `unknown failure reason ${a(t)}`;
102
- }, F = (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, children: o, lazy: i } = e;
105
- return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !m(n) ? "an entry needs an acceptable path" : H(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && typeof i != "boolean" ? "an entry lazy flag must be a boolean" : o !== void 0 && !Array.isArray(o) ? "entry children must be an array" : r === "file" && (o !== void 0 || i === !0) ? "a file entry cannot have children or be lazy" : i === !0 && Array.isArray(o) && o.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${a(r)}`;
106
- }, _ = (e) => {
107
- if (F(e) !== null) return !1;
108
- const { children: t } = e;
109
- return t === void 0 || t.every(_);
110
- }, M = (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(_) : t === "error" && u(r) === null;
114
- }, ie = (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 || A(n) : t === "error" && u(r) === null;
118
- }, A = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && m(t)) && new Set(e).size === e.length, ae = (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 !== "" && A(r) : t === "error" && u(s) === null;
122
- }, ce = (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 : M(e);
126
- }, V = (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 < d.min || n > d.max ? `a heading depth must be an integer in 1..6; got ${String(n)}` : null;
130
- }, G = (e) => {
131
- if (e === null || typeof e != "object") return "a document must be an object";
132
- const t = e, { kind: n } = t;
133
- if (!v(n)) return `unknown document kind ${a(n)}`;
134
- if (n === "failure") return u(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 o of s) {
141
- const i = V(o);
142
- if (i !== null) return i;
143
- }
144
- return null;
145
- }
146
- case "text":
147
- return typeof t.text != "string" || typeof t.truncated != "boolean" ? "a text document needs text and truncated" : l(t.url) ? null : "a text document needs a root-relative url";
148
- case "image":
149
- return l(t.url) ? null : "an image document needs a root-relative url";
150
- case "media":
151
- return l(t.url) ? X(t.mediaType) ? null : `unknown media type ${a(t.mediaType)}` : "a media document needs a root-relative url";
152
- case "file":
153
- return l(t.url) ? null : "a file document needs a root-relative url";
154
- }
155
- }, Y = (e) => G(e) === null, le = (e) => Y(e) && (e.kind === "text" || e.kind === "failure"), ue = (e, t) => ({ kind: "failure", failure: K(e, t) }), K = (e, t) => g(t) ? { reason: e, code: t } : { reason: e }, B = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "text", "refresh", "asset", "link-card"]), p = Object.freeze({ source: "source", path: "path", version: "v" }), J = "asset", q = "link-card", fe = (e, t, n) => {
156
- const r = `${e}/${J}?${p.path}=${encodeURIComponent(t)}`;
157
- return n === null ? r : `${r}&${p.version}=${encodeURIComponent(n)}`;
158
- }, de = (e) => `${e}/${q}`, Ee = "X-Markdown-Explorer-Scope", pe = "X-Markdown-Explorer", me = "refresh", ye = (e) => B.includes(e), Q = Object.freeze({
159
- invalid: 400,
160
- unauthorized: 401,
161
- forbidden: 403,
162
- "not-found": 404,
163
- "too-large": 413,
164
- "not-configured": 500,
165
- unsupported: 500,
166
- failed: 500
167
- }), Re = (e) => {
168
- const [t, ...n] = R.filter((r) => Q[r] === e);
169
- return t !== void 0 && n.length === 0 ? t : "failed";
170
- };
171
- export {
172
- M as A,
173
- u as B,
174
- ce as C,
175
- O as D,
176
- ne as E,
177
- Y as F,
178
- R as G,
179
- W as M,
180
- de as a,
181
- I as b,
182
- g as c,
183
- se as d,
184
- fe as e,
185
- K as f,
186
- oe as g,
187
- X as h,
188
- m as i,
189
- G as j,
190
- F as k,
191
- re as l,
192
- ye as m,
193
- Q as n,
194
- pe as o,
195
- me as p,
196
- Ee as q,
197
- ee as r,
198
- p as s,
199
- ue as t,
200
- te as u,
201
- Z as v,
202
- Re as w,
203
- le as x,
204
- ae as y,
205
- ie as z
206
- };
@@ -1,3 +0,0 @@
1
- "use strict";const a=require("react/jsx-runtime"),l=require("react"),V=require("react-router"),q=require("./location-FavgY_gB.cjs"),ee=require("@aiquants/markdown"),j=require("./dataRoute-CUXlMhUJ.cjs"),$t=require("@aiquants/markdown/viewer-settings"),X=require("./storage-Bkb2Axdi.cjs");function Ft(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 y=Ft(l),ye=Object.freeze(["en","ja"]),nt="en",rt=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"])}),_t=/\{(\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}`,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",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",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"},qt={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} のソース`,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:"名前の降順",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:"ダウンロード",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:"ここへパネルをドロップ"},st=Object.freeze({en:Object.freeze(ot),ja:Object.freeze(qt)}),Ce=Object.freeze(Object.keys(ot)),Bt=new Set(Ce),zt=e=>Bt.has(e),ae=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 nt;if(ye.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${ye.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${ae(e)}`)},Re=(e,t)=>{const n=st[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 ${ae(t)}`);if(!q.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${ae(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!zt(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Ce.join(", ")}`);const i=r[s];if(i===void 0)continue;const c=typeof n[s];if(typeof i!==c)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${c}; got ${ae(i)}`);if(typeof i=="string"&&i.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const d=rt[s];if(typeof i=="string"&&d!==void 0){for(const[,f]of i.matchAll(_t))if(!d.includes(f??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(f)}}; it accepts ${d.map(g=>`{${g}}`).join(", ")}`)}o[s]=i}return Object.freeze(o)},Ht=(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(i=>Object.hasOwn(n,i)&&Object.is(n[i],r[i]))},Te=Object.freeze(["light","dark"]),It=e=>{if(e===void 0)return"light";if(Te.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${Te.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},it=l.createContext(null),P=()=>{const e=l.use(it);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},te=e=>{const{viewSettings:t}=P(),n=()=>e(t.getSnapshot());return l.useSyncExternalStore(t.subscribe,n,n)},fe=()=>{const{config:e}=P(),t=V.useParams()["*"],[n]=V.useSearchParams(),r=n.toString();return l.useMemo(()=>q.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])};function Ut({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Zt=y.forwardRef(Ut),je=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})}),Vt=e=>je[e],me=()=>{const e=V.useNavigate();return l.useCallback((t,n)=>{e(t,je[n])},[e])},at=({navigation:e,...t})=>a.jsx(V.Link,{...t,...je[e]}),ct={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"]},J=(e,t)=>e[ct[t][0]],Ne=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=P(),s=J(o,e.reason),i=o[ct[e.reason][1]],c=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning";return a.jsxs("div",{className:"aqmx-callout",role:t?"alert":void 0,"data-aqmx-tone":c,"data-testid":r===null?void 0:r,"data-aqmx-failure":r===null?void 0:e.reason,children:[a.jsx("p",{className:"aqmx-callout-title",children:s}),a.jsx("p",{className:"aqmx-callout-body",children:i}),e.reason==="unauthorized"?a.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>window.location.reload(),children:o.reloadPage}):n!==void 0&&e.reason==="failed"?a.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:o.retry}):null]})},Pe=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},ut=(e,t)=>{const n=l.useRef(null),r=l.useRef(null),o=l.useRef(null),s=l.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);l.useEffect(()=>s,[s]);const i=l.useCallback(f=>{if(r.current!==f)return;const g=o.current;if(g!==null){g.then(()=>i(f));return}e.prefetch(f);const h=e.peek(f);if(h?.status!=="pending")return;const b=Promise.allSettled([h.promise]);o.current=b,b.then(()=>{o.current===b&&(o.current=null)})},[e]),c=l.useCallback(f=>{const g=t(f);g!==r.current&&(s(),g!==null&&(r.current=g,n.current=window.setTimeout(()=>{n.current=null,i(g)},q.PREFETCH_DWELL_MS)))},[s,t,i]),d=l.useCallback(f=>{t(f)!==r.current&&s()},[s,t]);return l.useMemo(()=>({onPointerOver:f=>c(f.target),onPointerOut:f=>d(f.relatedTarget),onFocus:f=>c(f.target),onBlur:f=>d(f.relatedTarget)}),[c,d])},Gt=l.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-CHEQgaVx.cjs")).then(e=>({default:e.NativeScrollBar})));class Wt extends l.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 dt=({scroller:e,withCircle:t})=>a.jsx(Wt,{children:a.jsx(l.Suspense,{fallback:null,children:a.jsx(Gt,{scroller:e,withCircle:t})})}),ft=e=>a.jsx(dt,{scroller:e,withCircle:!0}),Q=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},mt=()=>{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 i=e.get(o);if(i!==void 0&&i>1){e.set(o,i-1);return}e.delete(o),r(o)}},isHeld:o=>e.has(o),resumes:o=>t.delete(o),heldKeys:()=>[...e.keys()]}},ue=(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,i)=>ue(s,t[i]));const n=e,r=t,o=Object.keys(n);return o.length!==Object.keys(r).length?!1:o.every(s=>Object.hasOwn(r,s)&&ue(n[s],r[s]))},ne=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},pt=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),se=e=>e.status==="fulfilled"?e.value:void 0,Kt=55e3,qe=Object.freeze({status:"deferred"}),Be=Object.freeze({status:"refreshed"}),be=Object.freeze({status:"superseded"}),re=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,gt=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",Xt=({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=mt(),o=Q(),s=new WeakSet;let i=0;const c=o.emit,d=()=>(i+=1,i),f=()=>{if(!(n.size<=t))for(const m of[...n.keys()]){if(n.size<=t)return;r.isHeld(m)||n.delete(m)}},g=(m,v)=>{n.delete(m),n.set(m,v)},h=m=>performance.now()-m.validatedAt>=Kt,b=(m,v,S)=>{const x=n.get(m),T=re(x?.snapshot),$=S||x?.refreshPending===!0,H=ne(e.document(m,{refresh:$}).then(z=>({status:"loaded",document:z}))),N={snapshot:{status:"pending",promise:H,previous:T},validatedAt:performance.now(),opened:v,background:null,refreshPending:!1,seeded:void 0,stamp:d()};return g(m,N),f(),H.then(z=>{n.get(m)===N&&(N.snapshot=z,N.stamp=d(),c())}),N},L=(m,v,S,x,T,$)=>{v.background===S&&(v.background=null,!(n.get(m)!==v||v.snapshot!==x)&&(T.kind==="failure"&&x.document.kind!=="failure"||(v.validatedAt=$,v.stamp=d(),ue(x.document,T)||(v.snapshot={status:"loaded",document:T}),c())))},R=async(m,v)=>{const S=v.snapshot;if(S.status!=="loaded")return null;const x={};v.background=x;const T=performance.now(),$=e.document(m,{refresh:v.refreshPending});v.refreshPending=!1;const H=await $,N=v.background===x&&n.get(m)===v&&v.snapshot===S;return L(m,v,x,S,H,T),N?H:null},O=(m,v)=>{const{snapshot:S}=v;return S.status==="pending"?!1:S.status==="loaded"&&S.document.kind!=="failure"?(R(m,v),!1):(S.status==="loaded"&&s.add(S),b(m,!0,!1),!0)},k=m=>{const v=r.hold(m);let S=!1;return()=>{if(S)return;S=!0,v();const x=n.get(m);x!==void 0&&g(m,x),f()}};return{peek:m=>n.get(m)?.snapshot,peekSeeded:m=>n.get(m)?.seeded,answerStampOf:m=>n.get(m)?.stamp,prefetch:m=>{const v=n.get(m);v!==void 0&&v.snapshot.status!=="deferred"||(b(m,!1,!1),c())},open:m=>{const v=r.resumes(m),S=k(m),x=n.get(m);if(x===void 0||x.snapshot.status==="deferred")return b(m,!0,!1),c(),S;if(g(m,x),v)return S;const{snapshot:T}=x;return T.status==="pending"?(x.opened=!0,S):T.document.kind==="failure"?(x.opened||h(x)?(s.add(T),b(m,!0,!1),c()):x.opened=!0,S):(x.opened=!0,x.background===null&&h(x)&&R(m,x),S)},retain:k,retry:m=>{const v=n.get(m);v===void 0||v.snapshot.status!=="loaded"||v.snapshot.document.kind!=="failure"||(b(m,!0,!1),c())},seed:(m,v)=>{const S=performance.now(),x=ne(v.then(z=>z===null?qe:{status:"loaded",document:z},()=>qe)),T=n.get(m);if(T!==void 0&&T.snapshot.status==="loaded"){const z=T.snapshot,Z={};T.background=Z,x.then(I=>{if(I.status==="loaded"){L(m,T,Z,z,I.document,S);return}T.background===Z&&(T.background=null)});return}const $=T!==void 0&&T.snapshot.status==="pending"?T.snapshot.previous:null,H={status:"pending",promise:x,previous:$},N={snapshot:H,validatedAt:S,opened:T?.opened===!0,background:null,refreshPending:T?.refreshPending===!0,seeded:H,stamp:d()};g(m,N),f(),x.then(z=>{n.get(m)===N&&(z.status==="deferred"&&r.isHeld(m)?b(m,N.opened,!1):(N.snapshot=z,N.stamp=d()),c())})},invalidate:()=>{let m=!1;for(const[v,S]of[...n]){if(S.validatedAt=Number.NEGATIVE_INFINITY,S.opened=!0,S.refreshPending=!0,!r.isHeld(v))continue;const{snapshot:x}=S;if(x.status!=="pending"){O(v,S)&&(m=!0);continue}x.promise.then(()=>{n.get(v)===S&&S.refreshPending&&r.isHeld(v)&&O(v,S)&&c()})}m&&c()},refresh:async m=>{const v=n.get(m);if(v!==void 0&&gt(v.snapshot)){v.refreshPending=!0;const x=await R(m,v);return x===null?be:x.kind==="failure"?{status:"failed",failure:x.failure}:Be}const S=b(m,!0,!0);return c(),S.snapshot.status!=="pending"?be:(await S.snapshot.promise,n.get(m)===S?Be:be)},clear:()=>{n.clear();for(const m of r.heldKeys())b(m,!0,!1);c()},subscribe:o.subscribe,noteFailureShown:m=>s.has(m)?!1:(s.add(m),!0)}},de=l.createContext("fill"),Yt=Object.freeze({blockSize:"100%"}),oe=({scrollerProps:e,children:t})=>l.use(de)==="content"?a.jsx(ee.HostedScrollArea,{scrollerProps:e,children:t}):a.jsx(ee.HostedScrollArea,{scrollerProps:{...e,style:Yt},rowClassName:"aqmx-document-scroll-row",renderScrollBar:ft,children:t});function Jt({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 Qt=y.forwardRef(Jt);function en({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 tn=y.forwardRef(en),pe=({name:e,url:t,icon:n,children:r})=>{const{labels:o}=P();return a.jsxs("div",{className:"aqmx-document-toolbar",children:[a.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:n}),a.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),r,a.jsx("a",{className:"aqmx-icon-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":o.openInNewTab,title:o.openInNewTab,"data-testid":"markdown-explorer-file-open",children:a.jsx(tn,{})}),a.jsx("a",{className:"aqmx-icon-button",href:t,download:e,"aria-label":o.download,title:o.download,"data-testid":"markdown-explorer-file-download",children:a.jsx(Qt,{})})]})};function nn({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 rn=y.forwardRef(nn),on=Object.freeze({className:"aqmx-document-stage"}),sn=({document:e})=>{const{labels:t}=P();return a.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[a.jsx(pe,{name:e.name,url:e.url,icon:a.jsx(rn,{})}),a.jsx(oe,{scrollerProps:on,children:a.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-file-not-shown",children:[a.jsx("p",{className:"aqmx-callout-body",children:t.fileNotShown}),a.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-file-not-shown-download",children:t.download})]})})]})},De="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",ln=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},an=/(%[0-9A-Fa-f]{2})/u,$e=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(an).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))},ht=e=>`#${encodeURIComponent(e)}`,cn=e=>{if(e==="#")return!0;const t=$e(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},wt=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},un="http://www.w3.org/1999/xhtml",ze=(e,t)=>{if(t==="")return null;const n=wt(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===un&&r.getAttribute("name")===t)return r;return null},vt=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=ze(e,t.slice(1));if(n!==null)return n;const r=$e(t);return r===null?null:ze(e,r)},He=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"},dn=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"},fn=(e,t)=>{const n=t.closest(De),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&He(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:i}=e.ownerDocument;for(let c=e.parentElement;c!==null&&c!==s;c=c.parentElement)if(He(c)&&c.scrollHeight>c.clientHeight&&c.clientHeight<o)return c;return i instanceof Element&&dn(e.ownerDocument)&&i.scrollHeight>i.clientHeight&&i.clientHeight<o?i:r},mn=Object.freeze({scrollerOf:fn,reveal:e=>{e.scrollIntoView(Le)}}),Le=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),pn=(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")}}},gn=(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),i=t.getBoundingClientRect(),c=i.height+s+Number.parseFloat(o)>e.clientHeight;if(!c&&Math.abs(i.top-s-n)<1){t.scrollIntoView(Le);return}e.scrollBy({top:c?i.top-n-e.clientHeight:i.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(Le)},hn=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(De)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},Ie=(e,t,n)=>{if(e===null)return null;const r=vt(e,t);return r===null?(cn(t)&&hn(e,n),null):(pn(e,r),gn(n.scrollerOf(e,r),r),n.reveal(r),r)};function wn({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 vn=y.forwardRef(wn);function En({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 bn=y.forwardRef(En);function xn({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 Sn=y.forwardRef(xn);function kn({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 yn=y.forwardRef(kn),Ae="data-aqmx-key-repeat",Oe=Object.freeze({[Ae]:"allow"}),Rn=`[${Ae}="${Oe[Ae]}"]`,Tn=()=>{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(Rn)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},ce=Object.freeze([1/q.GOLDEN_RATIO**2,1/q.GOLDEN_RATIO,1,q.GOLDEN_RATIO,q.GOLDEN_RATIO**2]),Ue=Object.freeze({mode:"fit"}),Ln=1,An=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),Et=l.createContext(null),On=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=Ln?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,Ze=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<ce.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?ce.findIndex(o=>o>t):ce.findLastIndex(o=>o<t);return r===-1?null:r},Ve=(e,t,n)=>{if(e.mode==="level"){const o=Ze(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=Ze(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},Mn=e=>{const t=ce[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},Ge=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},Cn=({document:e})=>{const{labels:t}=P(),n=l.use(Et),[r]=l.useState(()=>n===null?null:n.read(e.url)),[o,s]=l.useState(r===null?Ue:r.zoom),[i,c]=l.useState(r===null?null:r.reported),[d,f]=l.useState(null),g=l.useRef(null),h=l.useCallback(M=>{const{naturalWidth:m,naturalHeight:v}=M;c(S=>Ge(S,m,v))},[]),b=l.useCallback(M=>{g.current=M,!(M===null||!M.complete)&&(M.naturalWidth>0||M.naturalHeight>0?h(M):M.decode().then(()=>h(M),()=>{}))},[h]);l.useEffect(()=>{n!==null&&i!==null&&n.save(e.url,{zoom:o,reported:i})},[n,e.url,o,i]),l.useLayoutEffect(()=>{const M=g.current;if(M===null||i===null||o.mode!=="fit")return;const m=()=>f(S=>Ge(S,M.clientWidth,M.clientHeight));if(m(),typeof ResizeObserver>"u")return;const v=new ResizeObserver(m);return v.observe(M),()=>v.disconnect()},[i,o.mode]);const L=i===null||d===null?null:On(i,d),R=Ve(o,L,-1),O=Ve(o,L,1),k=o.mode==="level"?Mn(o.index):null,D=o.mode==="level"&&k!==null?{width:`${o.base.width*k}px`,height:`${o.base.height*k}px`}:void 0;return a.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[a.jsxs(pe,{name:e.name,url:e.url,icon:a.jsx(yn,{}),children:[a.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":R===null,onClick:()=>{R!==null&&s(R)},...Oe,children:a.jsx(bn,{})}),a.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:k===null?t.imageFitLevel:t.imageZoomLevel(Math.round(k*100))}),a.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":O===null,onClick:()=>{O!==null&&s(O)},...Oe,children:a.jsx(Sn,{})}),a.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(Ue),children:a.jsx(vn,{})})]}),a.jsx(oe,{scrollerProps:An,children:a.jsx("img",{ref:b,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:D,onLoad:M=>h(M.currentTarget),"data-testid":"markdown-explorer-image"})})]})},bt=l.createContext(null),ge=l.createContext(void 0),xt=l.createContext(null),he=()=>{const e=l.use(bt);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},jn=()=>{const e=l.use(xt);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},we=(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}),Nn=({children:e})=>{const{config:t}=P(),n=he(),r=fe(),o=r.kind==="location"?r.location.source:void 0,s=V.useHref(we(t,n.navigation,o,n.currentPath));return a.jsx(ge,{value:o,children:a.jsx(xt,{value:s,children:e})})},Pn='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Dn=e=>{const t=e instanceof Element?e.closest(Pn):null;return t===null?null:t.getAttribute("data-doc-path")},ve=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,$n=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:i,scope:c,children:d})=>{const f=V.useHref(e),g=h=>{if(ve(h)){if(h.preventDefault(),t===c.currentPath&&n!==""){c.scrollWithin(n);return}i(t,n)}};return a.jsx("a",{...s,href:f,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:g,children:d})},Fn=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:i}=P(),c=he(),d=l.use(ge),f=ln(e),{navigation:g}=c,h=`${we(i,g,d,t)}${f}`,b=n===!1?"false":void 0;return g.kind==="page"?a.jsx(at,{...o,to:h,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":b,children:s}):a.jsx($n,{to:h,docPath:t,fragment:f,exists:b,className:r,attributes:o,onDocumentLink:g.onDocumentLink,scope:c,children:s})},_n=({className:e,attributes:t,children:n})=>{const{labels:r}=P();return a.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,a.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},qn=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=P(),i=l.use(ge),c=V.useHref(`${we(s,r.navigation,i,r.currentPath)}${e}`),d=f=>{ve(f)&&(f.preventDefault(),r.scrollWithin(e))};return a.jsx("a",{...n,href:c,className:t,onClick:d,children:o})},Bn=({href:e,className:t,attributes:n,children:r})=>{const o=he();if(o.navigation.kind==="page"){const s=i=>{if(!ve(i))return;const c=i.currentTarget;e==="#"?o.followEmptyFragment(i.nativeEvent):c.href===c.ownerDocument.URL&&o.followSameUrlJump(e,i.nativeEvent)};return a.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return a.jsx(qn,{href:e,className:t,attributes:n,scope:o,children:r})},zn=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:i})=>t==="doc"?n===void 0||!j.isAcceptableDocumentPath(n)?a.jsx(_n,{className:o,attributes:s,children:i}):a.jsx(Fn,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:i}):e.startsWith("#")?a.jsx(Bn,{href:e,className:o,attributes:s,children:i}):a.jsx("a",{...s,href:e,className:o,children:i}),Hn=()=>{const{config:e}=P(),t=he(),n=l.use(ge),r=me();return l.useCallback((o,s)=>{if(!ve(s))return!0;s.preventDefault();const i=ht(o.id),{navigation:c}=t;return c.kind==="panel"||$e(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(i),!0):(r(`${we(e,c,n,t.currentPath)}${i}`,"follow-link"),!0)},[e,t,n,r])},In=()=>{const e=jn();return l.useCallback(t=>`${e}${ht(t.id)}`,[e])};function Un({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Zn=y.forwardRef(Un);function Vn({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Gn=y.forwardRef(Vn);function Wn({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Kn=y.forwardRef(Wn),Xn=Object.freeze({className:"aqmx-document-stage"}),Yn=e=>{switch(e){case"video":return a.jsx(Gn,{});case"audio":return a.jsx(Kn,{});case"pdf":return a.jsx(Zn,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},Jn=({document:e})=>{const{labels:t}=P();switch(e.mediaType){case"video":return a.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 a.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 a.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)}`)}}},Qn=({document:e})=>a.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[a.jsx(pe,{name:e.name,url:e.url,icon:Yn(e.mediaType)}),a.jsx(oe,{scrollerProps:Xn,children:a.jsx(Jn,{document:e})})]}),St=e=>{const{markupViews:t}=P(),n=l.useCallback(()=>t.isShown(e),[t,e]);return l.useSyncExternalStore(t.subscribe,n,n)},er=e=>{const{documents:t,markupViews:n}=P(),r=l.useCallback(()=>t.peek(e),[t,e]),o=l.useCallback(()=>t.peekSeeded(e),[t,e]),s=l.useSyncExternalStore(t.subscribe,r,o),i=St(e),c=l.useCallback(()=>n.toggle(e),[n,e]);return{available:re(s)?.document.kind==="markdown",shown:i,toggle:c}},tr=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}),kt=(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},yt=(e,t)=>e!==void 0?e:t!==void 0?t:$t.DEFAULT_CONTENT_ALIGN,Rt=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),nr=(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 t.view==="single"?q.explorerHref(e,{view:"single",source:t.source,doc:t.doc,overrides:r,embed:t.embed}):q.explorerHref(e,{view:"tree",source:t.source,doc:t.doc,overrides:r})},Fe=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:i,children:c})=>{const d=l.use(de);return a.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":d,className:"aqmx-document",...i,children:[r?a.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,c]})},rr=()=>{const{labels:e}=P();return a.jsx(Fe,{kind:"empty",label:e.documentRegion,stale:!1,busy:!1,children:a.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:a.jsx("p",{className:"aqmx-empty-title",children:e.documentEmpty})})})},Tt=({label:e})=>{const{labels:t}=P();return a.jsxs(Fe,{kind:"loading",label:e,stale:!1,busy:!0,children:[a.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-document-skeleton",children:Rt.map(n=>a.jsx("span",{},n))}),a.jsx("p",{className:"aqmx-sr-only",children:t.documentLoading})]})},or=({path:e,document:t,viewer:n})=>{const{reportMathDiagnostics:r}=P(),o=l.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),s=Hn(),i=In(),c=l.useMemo(()=>r===void 0?void 0:d=>r(e,d),[r,e]);return a.jsx("div",{className:"aqmx-document-viewer",children:a.jsx(ee.MarkdownViewer,{...n,onHeadingSelect:s,headingHref:i,onMathDiagnostics:c,parseResult:o,content:null})})},Lt=({document:e,viewer:t})=>{const{labels:n}=P();return a.jsxs(a.Fragment,{children:[a.jsx(pe,{name:e.name,url:e.url,icon:a.jsx(Zt,{})}),e.truncated?a.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,a.jsx("div",{className:"aqmx-document-viewer",children:a.jsx(ee.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},sr=({path:e,name:t,viewer:n})=>{const{data:r,documents:o,announcer:s,labels:i}=P(),c=l.useCallback(()=>o.answerStampOf(e),[o,e]),d=l.useSyncExternalStore(o.subscribe,c,c),[f,g]=l.useState(0),h=l.useMemo(()=>({path:e,stamp:d,attempt:f}),[e,d,f]),[b,L]=l.useState(null),R=l.useEffectEvent(k=>{L(k),k.kind==="failure"&&s.announce(i.documentFailed(t,J(i,k.failure.reason)))});l.useEffect(()=>{const k=new AbortController;return r.text(h.path,k.signal).then(D=>{"kind"in D&&R(D)}),()=>k.abort()},[r,h]);const O=l.useCallback(()=>g(k=>k+1),[]);return b===null?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-markup-skeleton",children:Rt.map(k=>a.jsx("span",{},k))}),a.jsx("p",{className:"aqmx-sr-only",children:i.markupLoading})]}):b.kind==="failure"?a.jsx(oe,{scrollerProps:At,children:a.jsx(Ne,{failure:b.failure,alert:!1,onRetry:O,testId:"markdown-explorer-markup-failure"})}):a.jsx(Lt,{document:b,viewer:n})},At=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),lr=({path:e,document:t,markup:n,viewer:r,onRetry:o})=>{switch(t.kind){case"markdown":return n?a.jsx(sr,{path:e,name:t.name,viewer:r}):a.jsx(or,{path:e,document:t,viewer:r});case"text":return a.jsx(Lt,{document:t,viewer:r});case"image":return a.jsx(Cn,{document:t});case"media":return a.jsx(Qn,{document:t});case"file":return a.jsx(sn,{document:t});case"failure":return a.jsx(oe,{scrollerProps:At,children:a.jsx(Ne,{failure:t.failure,alert:!1,onRetry:o,testId:"markdown-explorer-document-failure"})});default:{const s=t;throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(s)}`)}}},ir='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',ar=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:vt(e,n),r===void 0?null:wt(e,r.id),e.querySelector(De),e.querySelector(ir)];for(const s of o)if(s instanceof HTMLElement&&Pe(s))return s;return null},We=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&Pe(t)},cr=e=>{const t=l.useRef(!1);return l.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,i;const c=b=>{s=!(b.target instanceof Node&&n.contains(b.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(i),i=setTimeout(()=>{s=!1},0)},d=b=>{t.current=b.target instanceof Node&&n.contains(b.target)},f=b=>{b.relatedTarget===null&&s&&(t.current=!1)},g=()=>{const{activeElement:b,body:L}=r;b!==null&&b!==L&&(t.current=n.contains(b))},h=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",c,!0),o.addEventListener("mousedown",c,!0),o.addEventListener("focusin",d,!0),o.addEventListener("blur",g),o.addEventListener("focus",h),n.addEventListener("focusout",f),()=>{clearTimeout(i),o.removeEventListener("pointerdown",c,!0),o.removeEventListener("mousedown",c,!0),o.removeEventListener("focusin",d,!0),o.removeEventListener("blur",g),o.removeEventListener("focus",h),n.removeEventListener("focusout",f)}},[e]),t},ur=({path:e,snapshot:t,stale:n,viewer:r,regionLabel:o,navigation:s,fragment:i,paneScroll:c,announces:d,announceFailure:f,onDocumentShown:g})=>{const{labels:h,announcer:b,documents:L}=P(),{document:R}=t,O=l.useRef(null),k=l.useRef(null),D=l.useRef(null),M=l.useRef(0),m=cr(O),v=l.useRef({path:e,document:R}),S=l.useRef(null),x=l.useCallback(w=>{const E=O.current,A=Ie(E,w,c);E!==null&&A!==null&&We(E,A,m.current)},[c,m]),T=l.useCallback((w,E)=>{const A=M.current;setTimeout(()=>{!E.defaultPrevented&&M.current===A&&x(w)},0)},[x]),$=l.useCallback(w=>{setTimeout(()=>{w.defaultPrevented||x("#")},0)},[x]),H=l.useMemo(()=>({navigation:s,currentPath:e,scrollWithin:x,followSameUrlJump:T,followEmptyFragment:$}),[s,e,x,T,$]),N=l.useCallback(()=>L.retry(e),[L,e]),z=ut(L,Dn),Z=St(e)?"markup":"rendered",I=R.kind==="markdown"?Z:void 0,_=l.useEffectEvent((w,E)=>{const A=k.current;if(A!==null&&A.path===w&&A.snapshot===E)return;k.current={path:w,snapshot:E};const C=E.document;if(C.kind==="failure"){L.noteFailureShown(E)&&f(h.documentFailed(j.lastPathSegment(w),J(h,C.failure.reason)));return}g?.(w,C),d&&(A===null||A.path!==w||A.snapshot.document.kind==="failure")&&b.announce(h.documentShown(C.name))});l.useEffect(()=>{_(e,t)},[e,t]);const U=l.useEffectEvent(()=>{i.kind==="panel"&&i.consume()}),G=l.useEffectEvent(w=>{const E=O.current;if(E===null||!m.current)return null;const{activeElement:A,body:C}=E.ownerDocument;return A!==null&&A!==C?null:ar(E,R,w)}),Ee=l.useEffectEvent(w=>{const E=O.current;E!==null&&We(E,w,m.current)}),u=l.useEffectEvent(w=>c.reveal(w)),p=l.useEffectEvent(w=>Ie(O.current,w,c));return l.useEffect(()=>{if(n)return;const w=v.current.path!==e,E=w||v.current.document!==R;v.current={path:e,document:R};const A=S.current!==e;S.current=e;let C=null;i.kind==="page"?D.current!==i.navigation&&(D.current=i.navigation,M.current+=1,C=i.fragment):i.fragment!==null&&(C=i.fragment,U());const B=()=>{const F=C===null?null:p(C);if(!E){F!==null&&Ee(F);return}const W=G(i.fragment);w&&F===null&&W!==null&&u(W)};A?queueMicrotask(B):B()},[i,e,R,n]),a.jsx(Fe,{kind:R.kind,view:I,label:o(e,R),stale:n,busy:n,frameRef:O,intent:z,children:a.jsx(bt,{value:H,children:a.jsx(Nn,{children:a.jsx(lr,{path:e,document:R,markup:I==="markup",viewer:r,onRetry:N},e)})})})},_e=Object.freeze({kind:"skeleton"}),dr=(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 i=n===null||n===e?null:re(r);return n===null||i===null?_e:{kind:"document",path:n,snapshot:i,stale:!0}},fr=(e,t)=>t.status==="deferred"?_e:{kind:"document",path:e,snapshot:t,stale:!1},mr=({requestedPath:e,content:t,...n})=>{const r=t.kind==="streaming"?fr(t.path,l.use(t.promise)):t;return r.kind!=="document"?a.jsx(Tt,{label:n.regionLabel(e,null)}):a.jsx(ur,{path:r.path,snapshot:r.snapshot,stale:r.stale,...n})},Ot=({path:e,display:t,navigation:n,fragment:r,paneScroll:o,announces:s,announceFailure:i,onDocumentShown:c})=>{const{config:d,labels:f,theme:g,documents:h}=P(),b=ee.useMarkdownToolbarState(),L=l.useRef(!1);l.useLayoutEffect(()=>{L.current=!0},[]);const[R,O]=l.useState(null),k=l.useCallback(()=>e===null?void 0:h.peek(e),[h,e]),D=l.useSyncExternalStore(h.subscribe,k,k),M=l.useCallback(()=>R===null?void 0:h.peek(R),[h,R]),m=l.useSyncExternalStore(h.subscribe,M,M);l.useLayoutEffect(()=>e===null?void 0:h.open(e),[h,e]),l.useLayoutEffect(()=>R===null?void 0:h.retain(R),[h,R]);const v=e===null?_e:dr(e,D,R,m,!L.current),S=e===null?null:v.kind==="document"&&!v.stale?v.path:R;S!==R&&O(S);const x=l.useMemo(()=>tr(f),[f]),T=l.useMemo(()=>[...d.iframeHosts],[d]),$=n.kind==="panel",H=l.useMemo(()=>({labels:x,emptyMessage:f.documentEmpty,theme:g,availableStyles:d.documentStyles,iFrameAllowedDomains:T,embeds:d.embeds,linkComponent:zn,toolbar:b,style:t.style,onStyleChange:t.onStyleChange,align:t.align,onAlignChange:t.onAlignChange,showToc:t.showToc,showStyle:t.showStyle,showAlign:t.showAlign,padding:t.padding,width:t.width===void 0?void 0:`min(${t.width}, 100%)`,maxWidth:t.maxWidth===void 0?void 0:`min(${t.maxWidth}, 100%)`,renderScrollBar:$?void 0:ft}),[x,f.documentEmpty,g,d.documentStyles,T,d.embeds,b,t,$]),N=l.useCallback((Z,I)=>$?I===null||I.kind==="failure"?j.lastPathSegment(Z):I.name:f.documentRegion,[$,f.documentRegion]),z=$?"content":"fill";return e===null?a.jsx(de,{value:z,children:a.jsx(rr,{})}):a.jsx(de,{value:z,children:a.jsx(l.Suspense,{fallback:a.jsx(Tt,{label:N(e,null)}),children:a.jsx(mr,{requestedPath:e,content:v,viewer:H,regionLabel:N,navigation:n,fragment:r,paneScroll:o,announces:s,announceFailure:i,onDocumentShown:c})})})},pr=({path:e,variant:t,onDocumentShown:n})=>{const{config:r,viewSettings:o,announcer:s}=P(),i=te(T=>T.style),c=te(T=>T.align),d=me(),f=V.useLocation(),g=fe(),{view:h,overrides:b,embed:L}=t,R=l.useCallback(T=>{if(g.kind!=="location")return;const $=nr(r,g.location,T);$!==null&&d($,"browse")},[r,d,g]),O=l.useCallback(T=>{o.update({style:T}),R("style")},[o,R]),k=l.useCallback(T=>{o.update({align:T}),R("align")},[o,R]),D=kt(r,b.style,i),M=yt(b.align,c),m=l.useMemo(()=>({style:D,onStyleChange:O,align:M,onAlignChange:k,showToc:L.showToc!==!1,showStyle:L.showStyle!==!1,showAlign:L.showAlign!==!1,padding:L.padding,width:L.width,maxWidth:L.maxWidth}),[D,O,M,k,L]),v=l.useMemo(()=>({kind:"page",view:h,overrides:b,embed:L}),[h,b,L]),S=l.useMemo(()=>({kind:"page",fragment:f.hash,navigation:f}),[f]),x=l.useCallback(T=>s.announce(T),[s]);return a.jsx(Ot,{path:e,display:m,navigation:v,fragment:S,paneScroll:mn,announces:!0,announceFailure:x,onDocumentShown:n})},gr=({path:e,variant:t,onDocumentShown:n})=>{const{config:r,viewSettings:o}=P(),s=te(v=>v.style),i=te(v=>v.align),[c,d]=l.useState(()=>kt(r,void 0,s)),f=yt(void 0,i),g=l.useCallback(v=>o.update({align:v}),[o]),{maximized:h,onDocumentLink:b,pendingHash:L,onHashConsumed:R,announceFailure:O,paneScroll:k}=t,D=l.useMemo(()=>({style:c,onStyleChange:d,align:f,onAlignChange:g,showToc:h,showStyle:h,showAlign:h,padding:void 0,width:void 0,maxWidth:void 0}),[c,f,g,h]),M=l.useMemo(()=>({kind:"panel",onDocumentLink:b}),[b]),m=l.useMemo(()=>({kind:"panel",fragment:L,consume:R}),[L,R]);return a.jsx(Ot,{path:e,display:D,navigation:M,fragment:m,paneScroll:k,announces:!1,announceFailure:O,onDocumentShown:n})},Mt=({path:e,variant:t,onDocumentShown:n})=>t.kind==="page"?a.jsx(pr,{path:e,variant:t,onDocumentShown:n}):a.jsx(gr,{path:e,variant:t,onDocumentShown:n});function hr({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Ct=y.forwardRef(hr);function wr({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 vr=y.forwardRef(wr),Er=new Set,br=(e,t)=>{const{documents:n,announcer:r,labels:o}=P(),s=l.useCallback(()=>n.peek(e),[n,e]),i=l.useCallback(()=>n.peekSeeded(e),[n,e]),c=l.useSyncExternalStore(n.subscribe,s,i),d=l.useCallback(()=>n.answerStampOf(e),[n,e]),f=l.useSyncExternalStore(n.subscribe,d,d),[g]=l.useState(()=>new Set),[h,b]=l.useState(Er),[L,R]=l.useState(null);L!==null&&L.path!==e&&R(null);const O=l.useRef(null);l.useLayoutEffect(()=>(O.current=e,()=>{O.current=null}),[e]);const k=l.useCallback(()=>{const m=e,v=n.peek(m);if(g.has(m)||v?.status==="pending")return;const S=t&&!gt(v);g.add(m),b(new Set(g)),R(null),(async()=>{try{const x=await n.refresh(m);if(O.current!==m||x.status==="superseded")return;if(x.status==="failed"){R({path:m,failure:x.failure,stamp:n.answerStampOf(m)}),r.announce(o.documentRefreshFailed(J(o,x.failure.reason)));return}const T=re(n.peek(m));if(S||T===null||T.document.kind==="failure")return;r.announce(o.documentRefreshed(T.document.name))}finally{g.delete(m),b(new Set(g))}})()},[e,t,g,n,r,o]),D=h.has(e),M=L!==null&&L.path===e&&L.stamp===f?L.failure:null;return{refreshing:D,unavailable:D||c?.status==="pending",failure:M,refresh:k}},jt=Object.freeze({kind:"page"}),Ke=e=>{e.stopPropagation()},Nt=({path:e,placement:t})=>{const{labels:n}=P(),{refreshing:r,unavailable:o,failure:s,refresh:i}=br(e,t.kind==="page"),c=er(e),d=t.kind==="panel"?n.refreshDocumentNamed(t.documentName):null,f=t.kind==="panel"?n.showMarkupNamed(t.documentName):null;return a.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar",children:[a.jsxs("div",{className:"aqmx-document-refresh-row",children:[c.available?a.jsxs("button",{type:"button",className:f===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:f===null?n.showMarkup:f,"aria-label":f===null?void 0:f,"aria-pressed":c.shown,"data-testid":"markdown-explorer-document-markup",onClick:c.toggle,onDoubleClick:Ke,children:[a.jsx(vr,{"aria-hidden":"true"}),f===null?a.jsx("span",{children:n.showMarkupLabel}):null]}):null,a.jsxs("button",{type:"button",className:d===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:d===null?n.refreshDocument:d,"aria-label":d===null?void 0:d,"aria-disabled":o,"aria-busy":r,"data-aqmx-busy":r?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:i,onDoubleClick:Ke,children:[a.jsx(Ct,{"aria-hidden":"true"}),d===null?a.jsx("span",{children:n.refreshDocumentLabel}):null]})]}),s===null?null:a.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":s.reason,children:n.documentRefreshFailed(J(n,s.reason))})]})},xr=({location:e})=>{const t=e.doc,n=l.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]);return a.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",children:[a.jsx(Nt,{path:t,placement:jt}),a.jsx(Mt,{path:t,variant:n})]})},Pt=({holds:e,testId:t})=>{const{labels:n,announcer:r}=P(),o=l.useId();l.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=l.useCallback(()=>r.shownIn(o),[r,o]),i=l.useSyncExternalStore(r.subscribe,s,s);return a.jsx("div",{className:"aqmx-sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":t,children:i.length>1?n.announcementSequence(i):i[0]})},Y=Object.freeze([]),Sr=e=>{const t=new Set;let n=Y,r=[],o=!1;const s=[],i=g=>{n=g;for(const h of[...t])h()},c=()=>s.at(-1)?.region,d=g=>{const h=c();g(),c()!==h&&n!==Y&&i(Y)},f=()=>{o=!1;const g=r.map(h=>"sentence"in h?h.sentence:h.list(h.items));r=[],i(Object.freeze(g))};return{announce:g=>{if(typeof g=="string")r.push({sentence:g});else{const h=r.find(b=>"list"in b&&b.list===g.list);h!==void 0&&"items"in h?h.items.push(g.item):r.push({list:g.list,items:[g.item]})}o||(o=!0,n!==Y&&i(Y),e.request(f))},subscribe:g=>(t.add(g),()=>{t.delete(g)}),claim:g=>{const h={region:g};return d(()=>s.push(h)),()=>d(()=>{const b=s.indexOf(h);b!==-1&&s.splice(b,1)})},shownIn:g=>c()===g?n:Y}},le=Object.freeze({status:"cancelled"}),kr=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(j.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return j.failureOf(n,r)},yr=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((c,d)=>globalThis.fetch(c,d)),o=(c,d)=>`${e}/${c}?${new URLSearchParams(d).toString()}`,s=async(c,d,f,g)=>{let h;try{h=await r(c,{credentials:"same-origin",...d,headers:{Accept:"application/json",...d.headers}})}catch{return g({reason:"failed"})}h.status===401&&t(null);const b=h.headers.get(j.EXPLORER_SCOPE_HEADER);b!==null&&t(b);let L;try{L=await h.json()}catch{return g({reason:j.failureReasonOfStatus(h.status)})}let R;try{R=f(L)}catch{R=!1}if(R)return L;const O=kr(L);return g(O!==null?O:{reason:h.status===200?"failed":j.failureReasonOfStatus(h.status)})},i={[j.EXPLORER_REFRESH_HEADER]:j.EXPLORER_REFRESH_HEADER_VALUE};return{tree:c=>s(o("tree",{[j.EXPLORER_DATA_QUERY.source]:c}),{method:"GET"},j.isExplorerTreeResult,d=>({status:"error",failure:d})),children:async(c,d,f)=>{const g=await s(o("children",{[j.EXPLORER_DATA_QUERY.source]:c,[j.EXPLORER_DATA_QUERY.path]:d}),{method:"GET",signal:f},j.isExplorerChildrenResult,h=>({status:"error",failure:h}));return f.aborted?le:g},ancestors:async(c,d,f)=>{const g=await s(o("ancestors",{[j.EXPLORER_DATA_QUERY.source]:c,[j.EXPLORER_DATA_QUERY.path]:d}),{method:"GET",signal:f},j.isExplorerAncestorsResult,h=>({status:"error",failure:h}));return f.aborted?le:g},reveal:async(c,d,f)=>{const g=await s(o("reveal",{[j.EXPLORER_DATA_QUERY.source]:c,[j.EXPLORER_DATA_QUERY.path]:d}),{method:"GET",signal:f},j.isExplorerRevealResult,h=>({status:"error",failure:h}));return f.aborted?le:g},document:(c,{refresh:d})=>s(o("document",{[j.EXPLORER_DATA_QUERY.path]:c}),d?{method:"GET",headers:i}:{method:"GET"},j.isExplorerDocument,f=>j.failureDocument(f.reason,f.code)),text:async(c,d)=>{const f=await s(o("text",{[j.EXPLORER_DATA_QUERY.path]:c}),{method:"GET",signal:d},j.isExplorerTextAnswer,g=>j.failureDocument(g.reason,g.code));return d.aborted?le:f},refresh:c=>s(o("refresh",{[j.EXPLORER_DATA_QUERY.source]:c}),{method:"POST",headers:i},j.isExplorerTreeResult,d=>({status:"error",failure:d}))}},Rr=()=>{const e=new Set,t=Q();return{isShown:n=>e.has(n),toggle:n=>{e.delete(n)||e.add(n),t.emit()},subscribe:t.subscribe}},Tr=()=>{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}}},Lr=e=>{const t=X.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}},Xe=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=Lr(e);n={changes:s,settings:q.applyTreeSettingChanges(t,s)}}return n},o=Q();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:i,settings:c}=r(),d=q.recordTreeSettingChange(i,s,q.advanceTreeSetting(c,s)[s],t);return n={changes:d,settings:q.applyTreeSettingChanges(t,d)},o.emit(),X.writeStorage(e,q.serializeTreeSettingChanges(d)),n.settings}}},Ar=Object.freeze({status:"refreshed"}),Or=Object.freeze({status:"superseded"}),Me=Object.freeze({status:"deferred"}),Mr=pt(Me),Dt=4,Cr=Dt-1,Ye=Object.freeze({status:"loading"}),jr=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),Nr=e=>{const t=new Map,n=mt(),r=new Map,o=new Map,s=new Map,i=new Map,c=Q(),d=new Set;let f=0,g=0;const h={direct:null,bulk:null},b=new Set;let L=!1,R=0;const O=()=>{R+=1,c.emit()},k=u=>o.get(u)??0,D=u=>{let p=i.get(u);return p===void 0&&(p={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},i.set(u,p)),p},M=(u,p,w)=>{u.inFlight.delete(p),f-=1,w.lane==="bulk"&&(g-=1)},m=u=>{const p=i.get(u);if(p!==void 0){for(const[w,E]of[...p.inFlight])M(p,w,E),E.controller.abort();p.direct.clear(),p.bulk.clear(),p.unclaimed.clear()}},v=u=>{const p=k(u)+1;return o.set(u,p),m(u),p},S=(u,p)=>{const w=se(u),E={promise:u,opened:p,stale:!1,loadedAt:w?.status==="ok"?w.loadedAt:null};return u.status==="pending"&&u.then(A=>{A.status==="ok"&&(E.loadedAt=A.loadedAt)}),E},x=u=>{let p=r.get(u);return p===void 0&&(p=new Map,r.set(u,p)),p},T=u=>{const p=[...i.keys()],w=h[u],E=w===null?0:p.indexOf(w)+1;for(let A=0;A<p.length;A+=1){const C=p[(E+A)%p.length],B=C===void 0?void 0:i.get(C);if(!(C===void 0||B===void 0)){for(const F of B[u])if((B.claims.get(F)??0)!==0)return B[u].delete(F),h[u]=C,{sourceId:C,path:F}}}return null},$=(u,p,w,E)=>{const A=i.get(u);if(A===void 0||A.inFlight.get(p)!==w)return;M(A,p,w);const C=(A.claims.get(p)??0)>0,B=x(u);if(E.status==="ok"?B.set(p,{status:"loaded",entries:E.entries}):E.status==="error"&&C?B.set(p,{status:"failed",failure:E.failure}):B.delete(p),O(),E.status==="error"&&C){const F={sourceId:u,path:p,failure:E.failure};for(const W of[...d])W(F)}N()},H=(u,p,w)=>{const E={controller:new AbortController,lane:w};D(u).inFlight.set(p,E),f+=1,w==="bulk"&&(g+=1),e.children(u,p,E.controller.signal).then(A=>$(u,p,E,A),()=>$(u,p,E,jr))},N=()=>{for(;f<Dt;){const u=T("direct");if(u!==null){H(u.sourceId,u.path,"direct");continue}const p=g<Cr?T("bulk"):null;if(p===null)return;H(p.sourceId,p.path,"bulk")}},z=(u,p,w)=>{if(!(p.direct.delete(w)||p.bulk.delete(w))){const A=p.inFlight.get(w);if(A===void 0)return!1;M(p,w,A),A.controller.abort()}return r.get(u)?.delete(w),!0},Z=()=>{L=!1;let u=!1;for(const p of b){const w=D(p);for(const E of w.unclaimed)(w.claims.get(E)??0)===0&&z(p,w,E)&&(u=!0);w.unclaimed.clear()}b.clear(),u&&(O(),N())},I=(u,p)=>{t.set(u,S(ne(e.tree(u)),p))},_=(u,p,w)=>{v(u);const E=S(pt(p),w);return t.set(u,E),r.delete(u),O(),N(),E},U=(u,p,w,E)=>{if(w!==k(u)||t.get(u)!==p)return;const A=se(p.promise);if(!(E.status!=="ok"||A?.status!=="ok"||p.loadedAt===null||E.loadedAt<=p.loadedAt)){if(ue(A.entries,E.entries)){p.loadedAt=E.loadedAt;return}_(u,E,p.opened)}},G=(u,p)=>{const w=t.get(u);return w!==void 0&&se(w.promise)?.status===p},Ee=(u,p)=>{p.stale=!1;const w=k(u);e.tree(u).then(E=>U(u,p,w,E))};return{read:u=>t.get(u)?.promise??Mr,open:u=>{const p=n.resumes(u),w=n.hold(u),E=t.get(u);return E===void 0||G(u,"deferred")?(I(u,!0),O()):p||(E.opened&&G(u,"error")?(I(u,!0),O()):(E.opened=!0,E.stale&&G(u,"ok")&&Ee(u,E))),w},retry:u=>{G(u,"error")&&(I(u,!0),O())},seed:(u,p)=>{const w=p.then(C=>C===null?Me:C,()=>Me),E=t.get(u);if(E!==void 0&&G(u,"ok")){const C=k(u);w.then(B=>U(u,E,C,B));return}v(u);const A=S(ne(w),E?.opened===!0);t.set(u,A),r.delete(u),N(),w.then(C=>{t.get(u)===A&&(C.status==="deferred"&&n.isHeld(u)&&I(u,A.opened),O())})},refresh:async u=>{const p=(s.get(u)??0)+1;s.set(u,p);const w=await e.refresh(u);if(s.get(u)!==p)return Or;if(w.status==="error")return{status:"failed",failure:w.failure};const E=t.get(u);if(!(E!==void 0&&E.loadedAt!==null&&G(u,"ok")&&E.loadedAt>w.loadedAt)){const C=_(u,w,!0);if(E!==void 0&&E.promise.status==="pending"){const B=k(u);E.promise.then(F=>U(u,C,B,F))}}for(const[C,B]of t)C!==u&&se(B.promise)?.status==="ok"&&(B.stale=!0);return Ar},children:(u,p)=>r.get(u)?.get(p),claimChildren:(u,p)=>{const w=D(u),E=x(u);let A=!1,C=!1;for(const[F,W]of p)w.claims.set(F,(w.claims.get(F)??0)+1),E.get(F)===void 0?(E.set(F,Ye),w[W].add(F),A=!0,C=!0):W==="direct"&&w.bulk.delete(F)&&(w.direct.add(F),C=!0);A&&O(),C&&N();let B=!1;return()=>{if(!B){B=!0;for(const F of p.keys()){const W=(w.claims.get(F)??0)-1;W>0?w.claims.set(F,W):(w.claims.delete(F),w.unclaimed.add(F))}b.add(u),!L&&(L=!0,queueMicrotask(Z))}}},retryChildren:(u,p)=>{const w=r.get(u);if(w===void 0||w.get(p)?.status!=="failed")return;const E=D(u);if((E.claims.get(p)??0)>0){w.set(p,Ye),E.direct.add(p),O(),N();return}w.delete(p),O()},pendingChildren:u=>{const p=i.get(u);return p===void 0?0:p.direct.size+p.bulk.size+p.inFlight.size},clear:()=>{for(const u of new Set([...t.keys(),...r.keys(),...o.keys(),...i.keys()]))v(u);for(const[u,p]of s)s.set(u,p+1);t.clear(),r.clear(),O()},subscribeChildrenFailures:u=>(d.add(u),()=>{d.delete(u)}),subscribe:c.subscribe,version:()=>R}},Pr=(e,t)=>{let n=e;const r=Q();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},Dr=1;let ie=0,K=null;const $r=()=>{const{documentElement:e,body:t}=document;ie===0&&(K={htmlOverflow:e.style.overflow,bodyOverflow:t.style.overflow,htmlGutter:e.style.scrollbarGutter,bodyGutter:t.style.scrollbarGutter},e.style.overflow="hidden",t.style.overflow="hidden",e.style.scrollbarGutter="auto",t.style.scrollbarGutter="auto"),ie+=1;let n=!1;return()=>{n||(n=!0,ie-=1,!(ie>0||K===null)&&(e.style.overflow=K.htmlOverflow,t.style.overflow=K.bodyOverflow,e.style.scrollbarGutter=K.htmlGutter,t.style.scrollbarGutter=K.bodyGutter,K=null))}},Fr=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],Je=1,Qe=e=>e.getClientRects().length>0,xe="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.",_r=e=>{if(!Qe(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+Dr)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. ${xe}`;if(t.height<Je)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. ${xe}`;for(const{selector:r,name:o}of Fr)for(const s of e.querySelectorAll(r)){if(!Qe(s))continue;const i=s.getBoundingClientRect().height;if(i<Je)return`[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(i))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${xe}`}return null},qr=e=>{let t=!1;const n=()=>{if(t)return;const o=_r(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)}},Br=(e,t)=>{l.useEffect(()=>e?$r():void 0,[e]),l.useEffect(()=>{const n=t.current;if(!(!e||n===null))return qr(n)},[e,t])},et='[data-testid="markdown-explorer-view-switch"]',zr=[{control:et,successors:[et,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],Hr=e=>{for(const t of zr){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},Ir=(e,t)=>{const n=l.useRef(null);l.useEffect(()=>{const o=c=>{const d=e.current;n.current=d!==null&&c instanceof Element&&d.contains(c)?Hr(c):null},s=c=>o(c.target);o(document.activeElement);const i=c=>{const d=c.target;c.relatedTarget!==null||!(d instanceof Element)||queueMicrotask(()=>{n.current?.element===d&&d.isConnected&&document.activeElement!==d&&(n.current=null)})};return document.addEventListener("focusin",s),document.addEventListener("focusout",i),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",i)}},[e]);const r=l.useRef(t);l.useLayoutEffect(()=>{if(r.current===t)return;r.current=t;const o=n.current;if(o===null)return;const s=()=>{const d=document.activeElement;if(d!==null&&d!==document.body&&d!==o.element)return!0;const f=e.current;if(f===null)return!0;for(const g of o.control.successors)for(const h of f.querySelectorAll(g))if(h!==o.element&&(h.focus({preventScroll:!0}),document.activeElement===h))return!0;return!1};if(s())return;const i=e.current;if(i===null)return;const c=new MutationObserver(()=>{s()&&c.disconnect()});return c.observe(i,{childList:!0,subtree:!0}),()=>c.disconnect()},[t,e])},Ur=l.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-BDaIyoGT.cjs")).then(e=>({default:e.TreeLayout}))),Zr=l.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-BDcQSpa6.cjs")).then(e=>({default:e.MultiLayout}))),Vr=64,Gr={request:e=>{requestAnimationFrame(e)}},tt=e=>{e.documents.clear(),e.trees.clear()},Se=(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)},Wr=(e,t)=>{const[n,r]=l.useState(()=>({overrides:t,locale:e,labels:Re(e,t)}));if(n.locale===e&&Ht(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:Re(e,t)};return r(o),o.labels},Kr=(e,t,n)=>{const[r,o]=l.useState(()=>({scope:t,store:Xe(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:Xe(e,n)};return o(s),s.store},ke=(e,t)=>{const[n,r]=l.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},Xr=()=>Sr(Gr),Yr=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:i,renderTreeFailure:c,lockDocumentScroll:d=!1,onMathDiagnostics:f})=>{X.assertStorageNamespace(n);const g=lt(r),h=It(s),b=Wr(g,o),{revalidate:L}=V.useRevalidator(),R=l.useRef(()=>{}),O=V.useHref(t.dataPath),[k]=l.useState(()=>{const _=yr({dataPath:O,onScope:G=>R.current(G)}),U={documents:Xt({client:_,capacity:Math.max(Vr,t.multiView.maxPanels*2)}),trees:Nr(_)};return Se(U,e),X.syncStorageScope(n,e.scope),{data:_,...U,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(k.aligned.pageData!==e||k.aligned.storageNamespace!==n){const _=k.aligned.pageData;k.aligned.pageData=e,k.aligned.storageNamespace=n,_!==e&&(_.scope!==e.scope?k.aligned.pendingReader=e:Se(k,e)),X.syncStorageScope(n,e.scope)}const D=Kr(X.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);l.useLayoutEffect(()=>{const _=k.aligned.pendingReader;_!==null&&(k.aligned.pendingReader=null,tt(k),Se(k,_))},[e,k]),l.useLayoutEffect(()=>{let _=!1;return R.current=U=>{U===e.scope||_||(_=!0,U!==null&&(tt(k),X.clearExplorerStorage(n)),L())},()=>{R.current=()=>{}}},[e,L,k,n]);const M=l.useRef(t.settingsCookie);l.useLayoutEffect(()=>{M.current=t.settingsCookie},[t.settingsCookie]);const[m]=l.useState(()=>Pr(e.settings,_=>{document.cookie=q.viewSettingsCookieString(M.current,_,window.location.protocol==="https:")})),v=ke(e.scope,Xr),S=ke(e.scope,Tr),x=ke(e.scope,Rr),T=l.useMemo(()=>ne(e.notices.catch(()=>[])),[e.notices]),$=e.sources.map(_=>_.id).join(`
2
- `),H=l.useMemo(()=>q.withExplorerSources(t,$.split(`
3
- `)),[t,$]),N=l.useRef(f);l.useLayoutEffect(()=>{N.current=f},[f]);const[z]=l.useState(()=>(_,U)=>{N.current?.(_,U)}),Z=f===void 0?void 0:z,I=l.useMemo(()=>({config:H,labels:b,locale:g,theme:h,storageNamespace:n,scope:e.scope,sources:e.sources,notices:T,documents:k.documents,trees:k.trees,data:k.data,viewSettings:m,treeSettings:D,announcer:v,reveals:S,markupViews:x,renderTreeFailure:c,reportMathDiagnostics:Z}),[H,b,g,h,n,e.scope,e.sources,T,k,m,D,v,S,x,c,Z]);return a.jsx(it,{value:I,children:a.jsx(Qr,{renderFrame:i,lockDocumentScroll:d},e.scope)})},Jr=({ref:e,theme:t,view:n,children:r})=>{const[o]=l.useState(Tn);return a.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})},Qr=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=P(),o=fe(),{hash:s}=V.useLocation(),i=me(),c=l.useRef(null);Br(t,c),l.useLayoutEffect(()=>{o.kind==="redirect"&&i(`${o.href}${s}`,"browse")},[o,s,i]);const{location:d}=o,f=d.view;Ir(c,f);const g=d.view==="tree"?a.jsx(l.Suspense,{fallback:a.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading"}),children:a.jsx(Ur,{location:d})}):d.view==="multi"?a.jsx(l.Suspense,{fallback:a.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading"}),children:a.jsx(Zr,{location:d})}):a.jsx(xr,{location:d}),h=a.jsxs(Jr,{ref:c,theme:n,view:f,children:[g,a.jsx(Pt,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?h:e({view:f,children:h})},eo=({currentUrl:e,nextUrl:t,formMethod:n,defaultShouldRevalidate:r})=>n===void 0&&e.href===t.href&&r;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=nt;exports.DocumentPane=Mt;exports.DocumentRefreshBar=Nt;exports.EXPLORER_THEMES=Te;exports.ExplorerLink=at;exports.FailureView=Ne;exports.ForwardRef=Ct;exports.ImageViewMemoryContext=Et;exports.LazyNativeScrollBar=dt;exports.LiveRegion=Pt;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=st;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Ce;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=rt;exports.MARKDOWN_EXPLORER_LOCALES=ye;exports.MarkdownExplorer=Yr;exports.PAGE_DOCUMENT_REFRESH=jt;exports.createEmitter=Q;exports.explorerNavigationOptions=Vt;exports.failureTitleOf=J;exports.focusWithoutScroll=Pe;exports.resolveMarkdownExplorerLabels=Re;exports.shouldRevalidateExplorer=eo;exports.useExplorer=P;exports.useExplorerLocation=fe;exports.useExplorerNavigate=me;exports.useIntentPrefetch=ut;exports.useViewSetting=te;