@aiquants/markdown-explorer 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.md +63 -6
  3. package/dist/ExplorerSplit-CWcK1E4I.js +1495 -0
  4. package/dist/ExplorerSplit-ajN3GSdA.cjs +1 -0
  5. package/dist/MultiLayout-BtWtCzJV.js +922 -0
  6. package/dist/MultiLayout-DvkcdO9c.cjs +1 -0
  7. package/dist/NativeScrollBar-DbzyQ85y.cjs +1 -0
  8. package/dist/NativeScrollBar-apXjIKRW.js +59 -0
  9. package/dist/TreeLayout-BcHsv9G8.js +23 -0
  10. package/dist/TreeLayout-rwhJfLmU.cjs +1 -0
  11. package/dist/core/config.d.cts +11 -0
  12. package/dist/core/config.d.ts +11 -0
  13. package/dist/core/contracts.d.cts +21 -0
  14. package/dist/core/contracts.d.ts +21 -0
  15. package/dist/core/labels.d.cts +5 -1
  16. package/dist/core/labels.d.ts +5 -1
  17. package/dist/core/treeSettings.d.cts +4 -2
  18. package/dist/core/treeSettings.d.ts +4 -2
  19. package/dist/{dataRoute-zUX-oR9j.js → dataRoute-Btg4w3vO.js} +79 -69
  20. package/dist/dataRoute-DHpu0fg2.cjs +1 -0
  21. package/dist/{index-BJTmp0lR.js → index-CIZw73j9.js} +702 -655
  22. package/dist/index-Cie6WPiM.cjs +3 -0
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.cts +2 -2
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +22 -21
  27. package/dist/location-CSIhx-L4.cjs +1 -0
  28. package/dist/{location-V5BKeWNs.js → location-c1zdeySY.js} +202 -187
  29. package/dist/sanitizeWorker.cjs +1 -1
  30. package/dist/sanitizeWorker.js +1 -1
  31. package/dist/scrollBarGeometry-C46jBtmM.cjs +1 -0
  32. package/dist/scrollBarGeometry-DOBdGNV-.js +4 -0
  33. package/dist/server/errors.d.cts +1 -1
  34. package/dist/server/errors.d.ts +1 -1
  35. package/dist/server/fileSystemSource.d.cts +1 -0
  36. package/dist/server/fileSystemSource.d.ts +1 -0
  37. package/dist/server/ports.d.cts +4 -0
  38. package/dist/server/ports.d.ts +4 -0
  39. package/dist/server.cjs +1 -1
  40. package/dist/server.d.cts +1 -1
  41. package/dist/server.d.ts +1 -1
  42. package/dist/server.js +749 -696
  43. package/dist/styles/markdown-explorer.css +1 -1
  44. package/dist/tapScrollCircle-C5DGI-0H.cjs +1 -0
  45. package/dist/tapScrollCircle-u4EXeLhx.js +6 -0
  46. package/docs/behavior/dom-hooks.md +3 -1
  47. package/docs/behavior/layout.md +2 -0
  48. package/docs/behavior/localization.md +1 -0
  49. package/docs/behavior/security.md +1 -1
  50. package/docs/behavior/url-contract.md +1 -0
  51. package/package.json +7 -7
  52. package/dist/ExplorerSplit-B7pmzR8t.js +0 -1362
  53. package/dist/ExplorerSplit-Bi3yU6NG.cjs +0 -1
  54. package/dist/MultiLayout-BxeXOLX1.js +0 -909
  55. package/dist/MultiLayout-DtFrFRmS.cjs +0 -1
  56. package/dist/TreeLayout-BQUfVNlA.cjs +0 -1
  57. package/dist/TreeLayout-D6hCSihW.js +0 -22
  58. package/dist/dataRoute-B9Wk-G7A.cjs +0 -1
  59. package/dist/index-DkiGlM7C.cjs +0 -3
  60. package/dist/location-DfYTzfFS.cjs +0 -1
@@ -1,5 +1,5 @@
1
- const q = 4096;
2
- const _ = Object.freeze([
1
+ const Q = 4096;
2
+ const O = Object.freeze([
3
3
  ".env*",
4
4
  "*.env",
5
5
  "*.env.*",
@@ -57,80 +57,88 @@ const _ = Object.freeze([
57
57
  "*.tfvars.json",
58
58
  ".*_history",
59
59
  "fish_history"
60
- ]), O = /[\u0000-\u001f\u007f]/u, h = /\p{Cs}/u, Q = (e) => {
60
+ ]), h = /[\u0000-\u001f\u007f]/u, b = /\p{Cs}/u, W = (e) => {
61
61
  const t = e.split("/").filter((n) => n !== "").at(-1);
62
62
  return t === void 0 ? e : t;
63
- }, A = (e) => e.length > 0 && e.length <= 4096 && !h.test(e) && !O.test(e) && !e.includes("\\"), p = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), b = /(?:%[0-9A-Fa-f]{2})+/gu, T = new TextDecoder("utf-8"), L = /[/\\]/u, P = (e) => e.replace(
64
- b,
65
- (t) => T.decode(
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, L = new TextDecoder("utf-8"), P = /[/\\]/u, S = (e) => e.replace(
64
+ T,
65
+ (t) => L.decode(
66
66
  Uint8Array.from(
67
67
  t.slice(1).split("%").map((n) => Number.parseInt(n, 16))
68
68
  )
69
69
  )
70
- ), S = (e) => {
70
+ ), x = (e) => {
71
71
  const t = [e];
72
72
  let n = e;
73
73
  for (let r = 0; r < 3 && n.includes("%"); r += 1) {
74
- const s = P(n);
74
+ const s = S(n);
75
75
  if (s === n) break;
76
76
  t.push(s), n = s;
77
77
  }
78
- return t.map(p);
79
- }, x = (e) => {
78
+ return t.map(y);
79
+ }, D = (e) => {
80
80
  if (typeof e != "string" || e.trim() === "" || e.includes("/") || e.includes("\\"))
81
81
  throw new RangeError(`[markdown-explorer] a deny pattern must be one non-blank path segment; got ${JSON.stringify(e)}`);
82
- const t = p(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
82
+ const t = y(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
83
83
  return new RegExp(`^${t}$`, "su");
84
- }, u = (e) => {
84
+ }, f = (e) => {
85
85
  if (!Array.isArray(e)) throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");
86
- const t = e.map(x), n = (s) => s !== "" && t.some((o) => o.test(s)), r = (s) => s !== "" && S(s).some((o) => n(o) || o.split(L).some(n));
86
+ const t = e.map(D), n = (s) => s !== "" && t.some((o) => o.test(s)), r = (s) => s !== "" && x(s).some((o) => n(o) || o.split(P).some(n));
87
87
  return {
88
88
  deniesPath: (s) => s.split("/").some(r),
89
89
  deniesName: r
90
90
  };
91
- }, D = u(_), N = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), W = (e) => e === void 0 ? D : e === !1 ? N : u(e), Z = (e, t) => u(e).deniesPath(t), m = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), j = Object.freeze(["file", "directory"]), k = Object.freeze(["video", "audio", "pdf"]), C = Object.freeze(["info", "warning", "danger"]), w = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), d = Object.freeze({ min: 1, max: 6 }), ee = 1e4, l = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), te = Object.freeze(["http:", "https:", "mailto:"]), U = /^[a-z0-9-]{1,64}$/u, $ = "https://relative.invalid/", f = 64, c = (e, t) => typeof t == "string" && e.includes(t), a = (e) => typeof e == "string" ? JSON.stringify(e.length > f ? `${e.slice(0, f)}…` : e) : typeof e, v = (e) => c(m, e), z = (e) => c(j, e), I = (e) => c(k, e), ne = (e) => c(C, e), H = (e) => c(w, e), y = (e) => typeof e == "string" && U.test(e), re = (e, t) => {
91
+ }, N = f(O), j = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), Z = (e) => e === void 0 ? N : e === !1 ? j : f(e), ee = (e, t) => f(e).deniesPath(t), R = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), k = 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 }), te = 1e4, l = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), ne = 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(k, e), X = (e) => c(C, e), re = (e) => c(w, e), v = (e) => c(U, e), g = (e) => typeof e == "string" && $.test(e), se = (e, t) => {
92
92
  if (typeof e != "string") return !1;
93
93
  try {
94
- return t.includes(new URL(e, $).protocol);
94
+ return t.includes(new URL(e, z).protocol);
95
95
  } catch {
96
96
  return !1;
97
97
  }
98
- }, R = (e) => {
98
+ }, u = (e) => {
99
99
  if (e === null || typeof e != "object") return "a failure must be an object";
100
100
  const { reason: t, code: n } = e;
101
- return v(t) ? n !== void 0 && !y(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${a(n)}` : null : `unknown failure reason ${a(t)}`;
102
- }, X = (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
103
  if (e === null || typeof e != "object") return "an entry must be an object";
104
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" || !A(n) ? "an entry needs an acceptable path" : z(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
- }, g = (e) => {
107
- if (X(e) !== null) return !1;
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
108
  const { children: t } = e;
109
- return t === void 0 || t.every(g);
110
- }, F = (e) => {
109
+ return t === void 0 || t.every(_);
110
+ }, M = (e) => {
111
111
  if (e === null || typeof e != "object") return !1;
112
112
  const { status: t, entries: n, failure: r } = e;
113
- return t === "ok" ? Array.isArray(n) && n.every(g) : t === "error" && R(r) === null;
114
- }, se = (e) => {
113
+ return t === "ok" ? Array.isArray(n) && n.every(_) : t === "error" && u(r) === null;
114
+ }, oe = (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, ie = (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
+ }, ae = (e) => {
115
123
  if (e === null || typeof e != "object") return !1;
116
124
  const { status: t, loadedAt: n } = e;
117
- return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : F(e);
118
- }, M = (e) => {
125
+ return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : M(e);
126
+ }, V = (e) => {
119
127
  if (e === null || typeof e != "object") return "a heading must be an object";
120
128
  const { text: t, depth: n, id: r } = e;
121
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;
122
- }, V = (e) => {
130
+ }, G = (e) => {
123
131
  if (e === null || typeof e != "object") return "a document must be an object";
124
132
  const t = e, { kind: n } = t;
125
- if (!H(n)) return `unknown document kind ${a(n)}`;
126
- if (n === "failure") return R(t.failure);
133
+ if (!v(n)) return `unknown document kind ${a(n)}`;
134
+ if (n === "failure") return u(t.failure);
127
135
  if (typeof t.name != "string") return "a document needs a name string";
128
136
  switch (n) {
129
137
  case "markdown": {
130
138
  const { htmlContent: r, headings: s } = t;
131
139
  if (typeof r != "string" || !Array.isArray(s)) return "a markdown document needs htmlContent and headings";
132
140
  for (const o of s) {
133
- const i = M(o);
141
+ const i = V(o);
134
142
  if (i !== null) return i;
135
143
  }
136
144
  return null;
@@ -140,14 +148,14 @@ const _ = Object.freeze([
140
148
  case "image":
141
149
  return l(t.url) ? null : "an image document needs a root-relative url";
142
150
  case "media":
143
- return l(t.url) ? I(t.mediaType) ? null : `unknown media type ${a(t.mediaType)}` : "a media document needs a root-relative url";
151
+ return l(t.url) ? X(t.mediaType) ? null : `unknown media type ${a(t.mediaType)}` : "a media document needs a root-relative url";
144
152
  case "file":
145
153
  return l(t.url) ? null : "a file document needs a root-relative url";
146
154
  }
147
- }, oe = (e) => V(e) === null, ie = (e, t) => ({ kind: "failure", failure: G(e, t) }), G = (e, t) => y(t) ? { reason: e, code: t } : { reason: e }, Y = Object.freeze(["tree", "children", "document", "refresh", "asset", "link-card"]), E = Object.freeze({ source: "source", path: "path", version: "v" }), K = "asset", B = "link-card", ae = (e, t, n) => {
148
- const r = `${e}/${K}?${E.path}=${encodeURIComponent(t)}`;
149
- return n === null ? r : `${r}&${E.version}=${encodeURIComponent(n)}`;
150
- }, ce = (e) => `${e}/${B}`, le = "X-Markdown-Explorer-Scope", ue = "X-Markdown-Explorer", de = "refresh", fe = (e) => Y.includes(e), J = Object.freeze({
155
+ }, ce = (e) => G(e) === null, le = (e, t) => ({ kind: "failure", failure: Y(e, t) }), Y = (e, t) => g(t) ? { reason: e, code: t } : { reason: e }, K = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "refresh", "asset", "link-card"]), p = Object.freeze({ source: "source", path: "path", version: "v" }), B = "asset", J = "link-card", ue = (e, t, n) => {
156
+ const r = `${e}/${B}?${p.path}=${encodeURIComponent(t)}`;
157
+ return n === null ? r : `${r}&${p.version}=${encodeURIComponent(n)}`;
158
+ }, fe = (e) => `${e}/${J}`, de = "X-Markdown-Explorer-Scope", Ee = "X-Markdown-Explorer", pe = "refresh", me = (e) => K.includes(e), q = Object.freeze({
151
159
  invalid: 400,
152
160
  unauthorized: 401,
153
161
  forbidden: 403,
@@ -156,40 +164,42 @@ const _ = Object.freeze([
156
164
  "not-configured": 500,
157
165
  unsupported: 500,
158
166
  failed: 500
159
- }), Ee = (e) => {
160
- const [t, ...n] = m.filter((r) => J[r] === e);
167
+ }), ye = (e) => {
168
+ const [t, ...n] = R.filter((r) => q[r] === e);
161
169
  return t !== void 0 && n.length === 0 ? t : "failed";
162
170
  };
163
171
  export {
164
- oe as A,
165
- m as B,
166
- _ as D,
167
- ee as E,
168
- q as M,
169
- ce as a,
170
- v as b,
171
- y as c,
172
- ne as d,
173
- ae as e,
174
- G as f,
175
- re as g,
176
- I as h,
177
- A as i,
178
- V as j,
179
- X as k,
180
- te as l,
181
- fe as m,
182
- J as n,
183
- ue as o,
184
- de as p,
185
- le as q,
186
- W as r,
187
- E as s,
188
- ie as t,
189
- Z as u,
190
- Q as v,
191
- Ee as w,
192
- F as x,
193
- R as y,
194
- se as z
172
+ u as A,
173
+ ae as B,
174
+ ce as C,
175
+ O as D,
176
+ te as E,
177
+ R as F,
178
+ Q as M,
179
+ fe as a,
180
+ I as b,
181
+ g as c,
182
+ re as d,
183
+ ue as e,
184
+ Y as f,
185
+ se as g,
186
+ X as h,
187
+ m as i,
188
+ G as j,
189
+ F as k,
190
+ ne as l,
191
+ me as m,
192
+ q as n,
193
+ Ee as o,
194
+ pe as p,
195
+ de as q,
196
+ Z as r,
197
+ p as s,
198
+ le as t,
199
+ ee as u,
200
+ W as v,
201
+ ye as w,
202
+ ie as x,
203
+ oe as y,
204
+ M as z
195
205
  };
@@ -0,0 +1 @@
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"]),x=/[\u0000-\u001f\u007f]/u,N=/\p{Cs}/u,C=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},f=e=>e.length>0&&e.length<=4096&&!N.test(e)&&!x.test(e)&&!e.includes("\\"),A=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),U=/(?:%[0-9A-Fa-f]{2})+/gu,k=new TextDecoder("utf-8"),H=/[/\\]/u,j=e=>e.replace(U,t=>k.decode(Uint8Array.from(t.slice(1).split("%").map(n=>Number.parseInt(n,16))))),X=e=>{const t=[e];let n=e;for(let r=0;r<3&&n.includes("%");r+=1){const o=j(n);if(o===n)break;t.push(o),n=o}return t.map(A)},w=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(w),n=o=>o!==""&&t.some(s=>s.test(o)),r=o=>o!==""&&X(o).some(s=>n(s)||s.split(H).some(n));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},I=d(_),$=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),z=e=>e===void 0?I:e===!1?$:d(e),F=(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"]),M=Object.freeze(["video","audio","pdf"]),V=Object.freeze(["info","warning","danger"]),G=Object.freeze(["markdown","text","image","media","file","failure"]),m=Object.freeze({min:1,max:6}),Y=1e4,u=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),K=Object.freeze(["http:","https:","mailto:"]),J=/^[a-z0-9-]{1,64}$/u,Q="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),B=e=>c(v,e),g=e=>c(M,e),W=e=>c(V,e),q=e=>c(G,e),R=e=>typeof e=="string"&&J.test(e),Z=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,Q).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)}`},h=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":B(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)}`},T=e=>{if(h(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(T)},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(T):t==="error"&&l(r)===null},ee=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,te=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},ne=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)},re=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(!q(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=re(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"}},oe=e=>b(e)===null,se=(e,t)=>({kind:"failure",failure:S(e,t)}),S=(e,t)=>R(t)?{reason:e,code:t}:{reason:e},ie=Object.freeze(["tree","children","ancestors","reveal","document","refresh","asset","link-card"]),E=Object.freeze({source:"source",path:"path",version:"v"}),ae="asset",ce="link-card",le=(e,t,n)=>{const r=`${e}/${ae}?${E.path}=${encodeURIComponent(t)}`;return n===null?r:`${r}&${E.version}=${encodeURIComponent(n)}`},ue=e=>`${e}/${ce}`,Ee="X-Markdown-Explorer-Scope",fe="X-Markdown-Explorer",de="refresh",pe=e=>ie.includes(e),D=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),Re=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=K;exports.EXPLORER_MAX_HEADINGS=Y;exports.EXPLORER_REFRESH_HEADER=fe;exports.EXPLORER_REFRESH_HEADER_VALUE=de;exports.EXPLORER_SCOPE_HEADER=Ee;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=b;exports.entryViolation=h;exports.explorerAssetHref=le;exports.explorerLinkCardEndpoint=ue;exports.failureDocument=se;exports.failureOf=S;exports.failureReasonOfStatus=Re;exports.failureViolation=l;exports.isAcceptableDocumentPath=f;exports.isAcceptableUrl=Z;exports.isDeniedPath=F;exports.isExplorerAncestorsResult=ee;exports.isExplorerChildrenResult=L;exports.isExplorerDataOperation=pe;exports.isExplorerDocument=oe;exports.isExplorerFailureCode=R;exports.isExplorerFailureReason=O;exports.isExplorerMediaType=g;exports.isExplorerNoticeTone=W;exports.isExplorerRevealResult=te;exports.isExplorerTreeResult=ne;exports.lastPathSegment=C;exports.resolvePathRules=z;