@aiquants/markdown-explorer 0.12.1 → 0.14.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 (44) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/README.md +21 -12
  3. package/dist/EditSurface-BLlu5zEt.cjs +2 -0
  4. package/dist/EditSurface-CF2io496.js +705 -0
  5. package/dist/{ExplorerSplit-BjjqNRtj.js → ExplorerSplit-BPLECNpv.js} +109 -109
  6. package/dist/{ExplorerSplit-CqmbUSZ7.cjs → ExplorerSplit-Cjvy0JHP.cjs} +1 -1
  7. package/dist/{MultiLayout-BZbEl73E.cjs → MultiLayout-BjA0k-5n.cjs} +1 -1
  8. package/dist/{MultiLayout-BYXoD1aS.js → MultiLayout-D8F0BfxA.js} +25 -25
  9. package/dist/{NativeScrollBar-RP37nwmY.js → NativeScrollBar-BFF12oEd.js} +1 -1
  10. package/dist/{NativeScrollBar-B7jTbQmn.cjs → NativeScrollBar-BUWXPvTV.cjs} +1 -1
  11. package/dist/{TreeLayout-CEp5oKly.cjs → TreeLayout-CQUpgsxz.cjs} +1 -1
  12. package/dist/{TreeLayout-Uo6RG7lq.js → TreeLayout-rhyVTfrI.js} +3 -3
  13. package/dist/core/contracts.d.cts +7 -1
  14. package/dist/core/contracts.d.ts +7 -1
  15. package/dist/core/labels.d.cts +14 -1
  16. package/dist/core/labels.d.ts +14 -1
  17. package/dist/core/revalidation.d.cts +1 -2
  18. package/dist/core/revalidation.d.ts +1 -2
  19. package/dist/{dataRoute-CH3yOKR0.cjs → dataRoute-BONacTPi.cjs} +1 -1
  20. package/dist/{dataRoute-Pm_0ue_4.js → dataRoute-CObbjNxG.js} +14 -12
  21. package/dist/index-Dn7cYy-4.cjs +13 -0
  22. package/dist/index-v997iKxe.js +3464 -0
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +21 -21
  25. package/dist/{location-BUNWJ4eB.cjs → location-D6RE3wAN.cjs} +1 -1
  26. package/dist/{location-DWd6SQhN.js → location-IRD9h42r.js} +1 -1
  27. package/dist/{merge-DRGBbLuR.cjs → merge-BFk7nT59.cjs} +1 -1
  28. package/dist/{merge-q-5i8qsn.js → merge-Bi2VedIr.js} +1 -1
  29. package/dist/{sanitizePolicy-djLC3fRN.js → sanitizePolicy-DlrakwA4.js} +1 -1
  30. package/dist/{sanitizePolicy-BfUlXI5E.cjs → sanitizePolicy-DrIMuYCb.cjs} +1 -1
  31. package/dist/sanitizeWorker.cjs +1 -1
  32. package/dist/sanitizeWorker.js +1 -1
  33. package/dist/server/ports.d.cts +3 -0
  34. package/dist/server/ports.d.ts +3 -0
  35. package/dist/server.cjs +1 -1
  36. package/dist/server.js +93 -83
  37. package/dist/styles/markdown-explorer.css +1 -1
  38. package/docs/behavior/dom-hooks.md +6 -5
  39. package/docs/behavior/layout.md +10 -3
  40. package/package.json +6 -5
  41. package/dist/EditSurface-By6NPcD7.js +0 -633
  42. package/dist/EditSurface-BztcpQPW.cjs +0 -2
  43. package/dist/index-CGBl3fYT.cjs +0 -13
  44. package/dist/index-CjCr8czx.js +0 -3356
@@ -1,7 +1,7 @@
1
1
  import { jsx as a } from "react/jsx-runtime";
2
2
  import { ScrollBar as u } from "@aiquants/virtualscroll";
3
3
  import { useCallback as p, useMemo as b, useSyncExternalStore as S } from "react";
4
- import { u as h } from "./index-CjCr8czx.js";
4
+ import { u as h } from "./index-v997iKxe.js";
5
5
  import { N as m } from "./scrollBarGeometry-DOBdGNV-.js";
6
6
  import { T, N as d } from "./tapScrollCircle-u4EXeLhx.js";
7
7
  const l = (e) => ({ scrollTop: e.scrollTop, scrollHeight: e.scrollHeight, clientHeight: e.clientHeight }), f = (e, t) => e.scrollTop === t.scrollTop && e.scrollHeight === t.scrollHeight && e.clientHeight === t.clientHeight, v = (e) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),i=require("react"),d=require("./index-CGBl3fYT.cjs"),h=require("./scrollBarGeometry-C46jBtmM.cjs"),u=require("./tapScrollCircle-C5DGI-0H.cjs"),a=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),v=(e,t)=>e.scrollTop===t.scrollTop&&e.scrollHeight===t.scrollHeight&&e.clientHeight===t.clientHeight,g=e=>{let t=a(e);return{getSnapshot:()=>t,subscribe:s=>{const o=()=>{const n=a(e);v(t,n)||(t=n,s())},r=typeof ResizeObserver>"u"?null:new ResizeObserver(o),c=()=>{if(r!==null){r.disconnect(),r.observe(e);for(const n of e.children)r.observe(n)}};c();const l=typeof MutationObserver>"u"?null:new MutationObserver(()=>{c(),o()});return l?.observe(e,{childList:!0}),e.addEventListener("scroll",o,{passive:!0}),o(),()=>{e.removeEventListener("scroll",o),l?.disconnect(),r?.disconnect()}}}},S=e=>{const t=i.useMemo(()=>g(e),[e]);return i.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)},p=(e,t)=>{const s=typeof t=="function"?t(e.scrollTop):t;return e.scrollTo({top:s,behavior:"instant"}),e.scrollTop},C=({scroller:e,withCircle:t})=>{const{locale:s}=d.useExplorer(),{scrollTop:o,scrollHeight:r,clientHeight:c}=S(e),l=i.useCallback(n=>p(e,n),[e]);return b.jsx(T.ScrollBar,{contentSize:r,viewportSize:c,scrollPosition:o,onScroll:l,scrollBarWidth:h.NATIVE_SCROLL_BAR_WIDTH,enableThumbDrag:!0,enableTrackClick:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,tapScrollCircleOptions:t?u.TAP_SCROLL_CIRCLE:u.NO_TAP_SCROLL_CIRCLE,locale:s})};exports.NativeScrollBar=C;exports.scrollScrollerTo=p;exports.useScrollerMetrics=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),i=require("react"),d=require("./index-Dn7cYy-4.cjs"),h=require("./scrollBarGeometry-C46jBtmM.cjs"),u=require("./tapScrollCircle-C5DGI-0H.cjs"),a=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),v=(e,t)=>e.scrollTop===t.scrollTop&&e.scrollHeight===t.scrollHeight&&e.clientHeight===t.clientHeight,g=e=>{let t=a(e);return{getSnapshot:()=>t,subscribe:s=>{const o=()=>{const n=a(e);v(t,n)||(t=n,s())},r=typeof ResizeObserver>"u"?null:new ResizeObserver(o),c=()=>{if(r!==null){r.disconnect(),r.observe(e);for(const n of e.children)r.observe(n)}};c();const l=typeof MutationObserver>"u"?null:new MutationObserver(()=>{c(),o()});return l?.observe(e,{childList:!0}),e.addEventListener("scroll",o,{passive:!0}),o(),()=>{e.removeEventListener("scroll",o),l?.disconnect(),r?.disconnect()}}}},S=e=>{const t=i.useMemo(()=>g(e),[e]);return i.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)},p=(e,t)=>{const s=typeof t=="function"?t(e.scrollTop):t;return e.scrollTo({top:s,behavior:"instant"}),e.scrollTop},C=({scroller:e,withCircle:t})=>{const{locale:s}=d.useExplorer(),{scrollTop:o,scrollHeight:r,clientHeight:c}=S(e),l=i.useCallback(n=>p(e,n),[e]);return b.jsx(T.ScrollBar,{contentSize:r,viewportSize:c,scrollPosition:o,onScroll:l,scrollBarWidth:h.NATIVE_SCROLL_BAR_WIDTH,enableThumbDrag:!0,enableTrackClick:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,tapScrollCircleOptions:t?u.TAP_SCROLL_CIRCLE:u.NO_TAP_SCROLL_CIRCLE,locale:s})};exports.NativeScrollBar=C;exports.scrollScrollerTo=p;exports.useScrollerMetrics=S;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),s=require("react"),T=require("react-router"),a=require("./location-BUNWJ4eB.cjs"),l=require("./index-CGBl3fYT.cjs"),p=require("./ExplorerSplit-CqmbUSZ7.cjs"),q=new Set,C=({location:m})=>{const{config:r}=l.useExplorer(),t=l.useExplorerNavigate(),{hash:d}=T.useLocation(),{source:n,doc:e,overrides:c,markup:o}=m,[x,v]=s.useState(p.EMPTY_SELECTION),g=s.useMemo(()=>({gathered:x,onGatheredChange:v}),[x]),w=s.useCallback(u=>t(a.explorerHref(r,{view:"tree",source:n,doc:u,overrides:c}),"browse"),[t,r,n,c]),S=s.useCallback(u=>t(a.explorerHref(r,{view:"tree",source:u,doc:e,overrides:c,markup:o}),"switch-source"),[t,r,e,c,o]),E=s.useCallback(u=>t(`${a.explorerHref(r,{view:"tree",source:u,doc:e,overrides:c,markup:o})}${d}`,"browse"),[t,r,e,c,o,d]),k=s.useCallback(u=>{const h=a.canonicalMultiDocuments(r,u);t(a.explorerHref(r,{view:"multi",source:n,docs:h,markup:o&&e!==null&&h.includes(e)?[e]:[]}),"switch-view")},[t,r,n,e,o]),b=s.useMemo(()=>({href:a.explorerHref(r,e===null?{view:"multi",source:n}:{view:"multi",source:n,docs:[e],markup:o?[e]:[]}),target:"multi"}),[r,n,e,o]),f=s.useMemo(()=>({kind:"page",view:"tree",overrides:c,embed:{}}),[c]),P=l.usePageMarkupToggle(m);return i.jsx(p.ExplorerSplit,{view:"tree",explorer:i.jsx(p.ExplorerPane,{mode:"tree",sourceId:n,currentPath:e,openPaths:q,onOpenDocument:w,onSourceChange:S,onRevealSource:E,viewSwitch:b,tray:g,onOpenSelection:k}),content:i.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",children:[e===null?null:i.jsx(l.DocumentRefreshBar,{path:e,placement:l.PAGE_DOCUMENT_REFRESH,markup:P}),i.jsx(l.DocumentPane,{path:e,markup:o,variant:f})]})})};exports.TreeLayout=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),s=require("react"),T=require("react-router"),a=require("./location-D6RE3wAN.cjs"),l=require("./index-Dn7cYy-4.cjs"),p=require("./ExplorerSplit-Cjvy0JHP.cjs"),q=new Set,C=({location:m})=>{const{config:r}=l.useExplorer(),t=l.useExplorerNavigate(),{hash:d}=T.useLocation(),{source:n,doc:e,overrides:c,markup:o}=m,[x,v]=s.useState(p.EMPTY_SELECTION),g=s.useMemo(()=>({gathered:x,onGatheredChange:v}),[x]),w=s.useCallback(u=>t(a.explorerHref(r,{view:"tree",source:n,doc:u,overrides:c}),"browse"),[t,r,n,c]),S=s.useCallback(u=>t(a.explorerHref(r,{view:"tree",source:u,doc:e,overrides:c,markup:o}),"switch-source"),[t,r,e,c,o]),E=s.useCallback(u=>t(`${a.explorerHref(r,{view:"tree",source:u,doc:e,overrides:c,markup:o})}${d}`,"browse"),[t,r,e,c,o,d]),k=s.useCallback(u=>{const h=a.canonicalMultiDocuments(r,u);t(a.explorerHref(r,{view:"multi",source:n,docs:h,markup:o&&e!==null&&h.includes(e)?[e]:[]}),"switch-view")},[t,r,n,e,o]),b=s.useMemo(()=>({href:a.explorerHref(r,e===null?{view:"multi",source:n}:{view:"multi",source:n,docs:[e],markup:o?[e]:[]}),target:"multi"}),[r,n,e,o]),f=s.useMemo(()=>({kind:"page",view:"tree",overrides:c,embed:{}}),[c]),P=l.usePageMarkupToggle(m);return i.jsx(p.ExplorerSplit,{view:"tree",explorer:i.jsx(p.ExplorerPane,{mode:"tree",sourceId:n,currentPath:e,openPaths:q,onOpenDocument:w,onSourceChange:S,onRevealSource:E,viewSwitch:b,tray:g,onOpenSelection:k}),content:i.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",children:[e===null?null:i.jsx(l.DocumentRefreshBar,{path:e,placement:l.PAGE_DOCUMENT_REFRESH,markup:P}),i.jsx(l.DocumentPane,{path:e,markup:o,variant:f})]})})};exports.TreeLayout=C;
@@ -1,9 +1,9 @@
1
1
  import { jsx as u, jsxs as D } from "react/jsx-runtime";
2
2
  import { useState as T, useMemo as m, useCallback as i } from "react";
3
3
  import { useLocation as b } from "react-router";
4
- import { e as c, c as C } from "./location-DWd6SQhN.js";
5
- import { u as M, a as N, b as O, D as R, P as _, c as G } from "./index-CjCr8czx.js";
6
- import { E as H, a as L, b as j } from "./ExplorerSplit-BjjqNRtj.js";
4
+ import { e as c, c as C } from "./location-IRD9h42r.js";
5
+ import { u as M, a as N, b as O, D as R, P as _, c as G } from "./index-v997iKxe.js";
6
+ import { E as H, a as L, b as j } from "./ExplorerSplit-BPLECNpv.js";
7
7
  const q = /* @__PURE__ */ new Set(), U = ({ location: l }) => {
8
8
  const { config: o } = M(), r = N(), { hash: p } = b(), { source: n, doc: e, overrides: s, markup: t } = l, [h, v] = T(H), w = m(() => ({ gathered: h, onGatheredChange: v }), [h]), g = i((a) => r(c(o, { view: "tree", source: n, doc: a, overrides: s }), "browse"), [r, o, n, s]), S = i((a) => r(c(o, { view: "tree", source: a, doc: e, overrides: s, markup: t }), "switch-source"), [r, o, e, s, t]), E = i((a) => r(`${c(o, { view: "tree", source: a, doc: e, overrides: s, markup: t })}${p}`, "browse"), [r, o, e, s, t, p]), x = i(
9
9
  (a) => {
@@ -112,6 +112,8 @@ export type ExplorerTextDocument = {
112
112
  };
113
113
  export type ExplorerDocumentEdit = {
114
114
  readonly kind: "inline";
115
+ } | {
116
+ readonly kind: "draft";
115
117
  } | {
116
118
  readonly kind: "external";
117
119
  readonly href: string;
@@ -147,7 +149,11 @@ export type ExplorerEditSource = {
147
149
  readonly version: string;
148
150
  readonly history: boolean;
149
151
  };
150
- export type ExplorerEditAnswer = ExplorerEditSource | ExplorerGrantRequired | ExplorerFailureDocument;
152
+ export type ExplorerDraftSource = {
153
+ readonly kind: "draft";
154
+ readonly text: string;
155
+ };
156
+ export type ExplorerEditAnswer = ExplorerEditSource | ExplorerDraftSource | ExplorerGrantRequired | ExplorerFailureDocument;
151
157
  export type ExplorerSaveAnswer = {
152
158
  readonly kind: "saved";
153
159
  readonly version: string;
@@ -112,6 +112,8 @@ export type ExplorerTextDocument = {
112
112
  };
113
113
  export type ExplorerDocumentEdit = {
114
114
  readonly kind: "inline";
115
+ } | {
116
+ readonly kind: "draft";
115
117
  } | {
116
118
  readonly kind: "external";
117
119
  readonly href: string;
@@ -147,7 +149,11 @@ export type ExplorerEditSource = {
147
149
  readonly version: string;
148
150
  readonly history: boolean;
149
151
  };
150
- export type ExplorerEditAnswer = ExplorerEditSource | ExplorerGrantRequired | ExplorerFailureDocument;
152
+ export type ExplorerDraftSource = {
153
+ readonly kind: "draft";
154
+ readonly text: string;
155
+ };
156
+ export type ExplorerEditAnswer = ExplorerEditSource | ExplorerDraftSource | ExplorerGrantRequired | ExplorerFailureDocument;
151
157
  export type ExplorerSaveAnswer = {
152
158
  readonly kind: "saved";
153
159
  readonly version: string;
@@ -22,6 +22,8 @@ export type MarkdownExplorerLabels = {
22
22
  readonly editDocumentLabel: string;
23
23
  readonly editDocument: string;
24
24
  readonly editDocumentNamed: (name: string) => string;
25
+ readonly editDraftDocument: string;
26
+ readonly editDraftDocumentNamed: (name: string) => string;
25
27
  readonly editExternallyLabel: string;
26
28
  readonly editExternally: string;
27
29
  readonly editExternallyNamed: (name: string) => string;
@@ -32,9 +34,18 @@ export type MarkdownExplorerLabels = {
32
34
  readonly saveDraft: string;
33
35
  readonly saveDraftTooltip: string;
34
36
  readonly closeEditor: string;
35
- readonly previewToggle: string;
37
+ readonly editView: string;
38
+ readonly editViewNamed: (name: string) => string;
39
+ readonly editViewEditor: string;
40
+ readonly editViewEditorTooltip: string;
41
+ readonly editViewSplit: string;
42
+ readonly editViewSplitTooltip: string;
43
+ readonly editViewPreview: string;
44
+ readonly editViewPreviewTooltip: string;
36
45
  readonly historyOpen: string;
37
46
  readonly draftUnsaved: string;
47
+ readonly draftStatus: string;
48
+ readonly draftNotSaved: string;
38
49
  readonly draftSaving: string;
39
50
  readonly draftSaved: string;
40
51
  readonly draftSavedMerged: string;
@@ -55,6 +66,8 @@ export type MarkdownExplorerLabels = {
55
66
  readonly unsavedTitle: string;
56
67
  readonly unsavedBody: (names: string) => string;
57
68
  readonly unsavedDiscard: string;
69
+ readonly draftDiscardTitle: string;
70
+ readonly draftDiscardBody: (names: string) => string;
58
71
  readonly unsavedStay: string;
59
72
  readonly historyTitle: (name: string) => string;
60
73
  readonly historyLoading: string;
@@ -22,6 +22,8 @@ export type MarkdownExplorerLabels = {
22
22
  readonly editDocumentLabel: string;
23
23
  readonly editDocument: string;
24
24
  readonly editDocumentNamed: (name: string) => string;
25
+ readonly editDraftDocument: string;
26
+ readonly editDraftDocumentNamed: (name: string) => string;
25
27
  readonly editExternallyLabel: string;
26
28
  readonly editExternally: string;
27
29
  readonly editExternallyNamed: (name: string) => string;
@@ -32,9 +34,18 @@ export type MarkdownExplorerLabels = {
32
34
  readonly saveDraft: string;
33
35
  readonly saveDraftTooltip: string;
34
36
  readonly closeEditor: string;
35
- readonly previewToggle: string;
37
+ readonly editView: string;
38
+ readonly editViewNamed: (name: string) => string;
39
+ readonly editViewEditor: string;
40
+ readonly editViewEditorTooltip: string;
41
+ readonly editViewSplit: string;
42
+ readonly editViewSplitTooltip: string;
43
+ readonly editViewPreview: string;
44
+ readonly editViewPreviewTooltip: string;
36
45
  readonly historyOpen: string;
37
46
  readonly draftUnsaved: string;
47
+ readonly draftStatus: string;
48
+ readonly draftNotSaved: string;
38
49
  readonly draftSaving: string;
39
50
  readonly draftSaved: string;
40
51
  readonly draftSavedMerged: string;
@@ -55,6 +66,8 @@ export type MarkdownExplorerLabels = {
55
66
  readonly unsavedTitle: string;
56
67
  readonly unsavedBody: (names: string) => string;
57
68
  readonly unsavedDiscard: string;
69
+ readonly draftDiscardTitle: string;
70
+ readonly draftDiscardBody: (names: string) => string;
58
71
  readonly unsavedStay: string;
59
72
  readonly historyTitle: (name: string) => string;
60
73
  readonly historyLoading: string;
@@ -1,2 +1 @@
1
- import { ShouldRevalidateFunctionArgs } from "react-router";
2
- export declare const shouldRevalidateExplorer: ({ currentUrl, nextUrl, formMethod, defaultShouldRevalidate }: Pick<ShouldRevalidateFunctionArgs, "currentUrl" | "nextUrl" | "formMethod" | "defaultShouldRevalidate">) => boolean;
1
+ export declare const shouldRevalidateExplorer: import("@aiquants/route-revalidation").RouteShouldRevalidate;
@@ -1,2 +1 @@
1
- import { ShouldRevalidateFunctionArgs } from "react-router";
2
- export declare const shouldRevalidateExplorer: ({ currentUrl, nextUrl, formMethod, defaultShouldRevalidate }: Pick<ShouldRevalidateFunctionArgs, "currentUrl" | "nextUrl" | "formMethod" | "defaultShouldRevalidate">) => boolean;
1
+ export declare const shouldRevalidateExplorer: import("@aiquants/route-revalidation").RouteShouldRevalidate;
@@ -1 +1 @@
1
- "use strict";const b=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"]),C=/[\u0000-\u001f\u007f]/u,U=/\p{Cs}/u,H=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},R=e=>e.length>0&&e.length<=4096&&!U.test(e)&&!C.test(e)&&!e.includes("\\"),x=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),z=/(?:%[0-9A-Fa-f]{2})+/gu,F=new TextDecoder("utf-8"),V=/[/\\]/u,M=e=>e.replace(z,t=>F.decode(Uint8Array.from(t.slice(1).split("%").map(n=>Number.parseInt(n,16))))),G=e=>{const t=[e];let n=e;for(let r=0;r<3&&n.includes("%");r+=1){const o=M(n);if(o===n)break;t.push(o),n=o}return t.map(x)},K=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=x(e).split("*").map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"su")},y=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const t=e.map(K),n=o=>o!==""&&t.some(i=>i.test(o)),r=o=>o!==""&&G(o).some(i=>n(i)||i.split(V).some(n));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},Y=y(b),W=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),J=e=>e===void 0?Y:e===!1?W:y(e),Q=(e,t)=>y(e).deniesPath(t),m=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),q=Object.freeze(["file","directory"]),B=Object.freeze(["video","audio","pdf"]),Z=Object.freeze(["info","warning","danger"]),ee=Object.freeze(["markdown","text","image","media","file","failure"]),O=Object.freeze({min:1,max:6}),te=1e4,c=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),ne=Object.freeze(["http:","https:","mailto:"]),_=1024,re=/^[a-z0-9-]{1,64}$/u,oe="https://relative.invalid/",h=64,p=(e,t)=>typeof t=="string"&&e.includes(t),s=e=>typeof e=="string"?JSON.stringify(e.length>h?`${e.slice(0,h)}…`:e):typeof e,T=e=>p(m,e),se=e=>p(q,e),P=e=>p(B,e),ie=e=>p(Z,e),ae=e=>p(ee,e),A=e=>typeof e=="string"&&re.test(e),le=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,oe).protocol)}catch{return!1}},f=e=>{if(e===null||typeof e!="object")return"a failure must be an object";const{reason:t,code:n}=e;return T(t)?n!==void 0&&!A(n)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${s(n)}`:null:`unknown failure reason ${s(t)}`},S=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:t,path:n,type:r,mimeType:o,modifiedAt:i,children:a,lazy:l}=e;return typeof t!="string"||t===""?"an entry needs a non-empty name":typeof n!="string"||!R(n)?"an entry needs an acceptable path":se(r)?o!==void 0&&typeof o!="string"?"an entry mimeType must be a string":i!==void 0&&!Number.isSafeInteger(i)?`an entry modifiedAt must be a safe integer of epoch milliseconds; got ${s(i)}`:l!==void 0&&typeof l!="boolean"?"an entry lazy flag must be a boolean":a!==void 0&&!Array.isArray(a)?"entry children must be an array":r==="file"&&(a!==void 0||l===!0)?"a file entry cannot have children or be lazy":l===!0&&Array.isArray(a)&&a.length>0?"a lazy directory must not list children":null:`an entry type must be "file" or "directory"; got ${s(r)}`},N=e=>{if(S(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(N)},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(N):t==="error"&&f(r)===null},ce=e=>{if(e===null||typeof e!="object")return!1;const{status:t,ancestors:n,failure:r}=e;return t==="ok"?n===null||D(n):t==="error"&&f(r)===null},D=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&R(t))&&new Set(e).size===e.length,ue=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!==""&&D(r):t==="error"&&f(o)===null},fe=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)},g=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<O.min||n>O.max?`a heading depth must be an integer in 1..6; got ${String(n)}`:null},v=e=>{if(e===null||typeof e!="object")return"a document must be an object";const t=e,{kind:n}=t;if(!ae(n))return`unknown document kind ${s(n)}`;if(n==="failure")return f(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 i of o){const a=g(i);if(a!==null)return a}return Ee(t.edit)}case"text":return typeof t.text!="string"||typeof t.truncated!="boolean"?"a text document needs text and truncated":c(t.url)?null:"a text document needs a root-relative url";case"image":return c(t.url)?null:"an image document needs a root-relative url";case"media":return c(t.url)?P(t.mediaType)?null:`unknown media type ${s(t.mediaType)}`:"a media document needs a root-relative url";case"file":return c(t.url)?null:"a file document needs a root-relative url"}},w=e=>v(e)===null,de=e=>w(e)&&(e.kind==="text"||e.kind==="failure"),Ee=e=>{if(e===null)return null;if(typeof e!="object")return"a markdown document's edit must be null or an object";const{kind:t,href:n}=e;return t==="inline"?n===void 0?null:"an inline edit carries no href":t!=="external"?`unknown edit kind ${s(t)}`:pe(n)?null:`an external edit needs an absolute https: href; got ${s(n)}`},pe=e=>{if(typeof e!="string")return!1;try{return new URL(e).protocol==="https:"}catch{return!1}},u=e=>typeof e=="string"&&e.length>0&&e.length<=_,Re=e=>c(e.href)?null:`a grant needs a root-relative href; got ${s(e.href)}`,k=e=>{if(e===null||typeof e!="object")return"a revision must be an object";const{id:t,modifiedAt:n,size:r,author:o,kept:i,current:a}=e;return u(t)?n!==null&&(typeof n!="string"||Number.isNaN(Date.parse(n)))?`a revision's modifiedAt must be a date-time string or null; got ${s(n)}`:typeof r!="number"||!Number.isSafeInteger(r)||r<0?`a revision's size must be a non-negative integer; got ${s(r)}`:o!==null&&typeof o!="string"?`a revision's author must be a string or null; got ${s(o)}`:typeof i!="boolean"||typeof a!="boolean"?"a revision needs kept and current booleans":null:`a revision id must be a non-empty string of at most ${_} characters; got ${s(t)}`},d=(e,t)=>{if(e===null||typeof e!="object")return"an answer must be an object";const n=e,{kind:r}=n;if(r==="failure")return f(n.failure);if(typeof r!="string"||!t.includes(r))return`unexpected answer kind ${s(r)}`;switch(r){case"grant":return Re(n);case"edit":return typeof n.text!="string"||typeof n.history!="boolean"?"an edit source needs text and history":u(n.version)?null:`an edit source needs a version; got ${s(n.version)}`;case"saved":return u(n.version)?null:`a saved answer needs a version; got ${s(n.version)}`;case"conflict":return typeof n.text!="string"?"a conflict needs the current text":u(n.version)?null:`a conflict needs the current version; got ${s(n.version)}`;case"preview":{const{htmlContent:o,headings:i}=n;if(typeof o!="string"||!Array.isArray(i))return"a preview needs htmlContent and headings";for(const a of i){const l=g(a);if(l!==null)return l}return null}case"revisions":{if(!Array.isArray(n.revisions))return"revisions need an array";for(const o of n.revisions){const i=k(o);if(i!==null)return i}return null}case"revision":return typeof n.text!="string"?"a revision answer needs text":u(n.id)?null:`a revision answer needs an id; got ${s(n.id)}`;default:return`unexpected answer kind ${s(r)}`}},ye=Object.freeze(["edit","grant"]),me=Object.freeze(["saved","conflict","grant"]),I=Object.freeze(["preview"]),_e=Object.freeze(["revisions"]),Ae=Object.freeze(["revision"]),ge=e=>d(e,ye)===null,Oe=e=>d(e,me)===null,he=e=>d(e,I)===null,be=e=>d(e,_e)===null,xe=e=>d(e,Ae)===null,Te=e=>e!==null&&typeof e=="object"&&e.kind==="unavailable"?null:d(e,I),Pe=(e,t)=>({kind:"failure",failure:j(e,t)}),j=(e,t)=>A(t)?{reason:e,code:t}:{reason:e},Se=Object.freeze(["tree","children","ancestors","reveal","document","text","edit","save","preview","revisions","revision","refresh","asset","link-card"]),E=Object.freeze({source:"source",path:"path",version:"v",base:"base",revision:"revision",display:"as"}),Ne="asset",Le="link-card",De=(e,t,n)=>{const r=`${e}/${Ne}?${E.path}=${encodeURIComponent(t)}`;return n===null?r:`${r}&${E.version}=${encodeURIComponent(n)}`},$="text",ve=e=>{if(!e.includes("?"))throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);return`${e}&${E.display}=${$}`},we=e=>{const t=e.getAll(E.display);return t.length===0?"file":t.length===1&&t[0]===$?"text":null},ke=e=>`${e}/${Le}`,Ie="X-Markdown-Explorer-Scope",je="X-Markdown-Explorer",$e="refresh",Xe="edit",Ce="text/markdown",Ue=e=>Se.includes(e),X=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),He=e=>{const[t,...n]=m.filter(r=>X[r]===e);return t!==void 0&&n.length===0?t:"failed"};exports.DEFAULT_DENIED_PATH_SEGMENTS=b;exports.EXPLORER_DATA_QUERY=E;exports.EXPLORER_DRAFT_MEDIA_TYPE=Ce;exports.EXPLORER_EDIT_PROOF=Xe;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_;exports.EXPLORER_FAILURE_REASONS=m;exports.EXPLORER_FAILURE_STATUS=X;exports.EXPLORER_LINK_PROTOCOLS=ne;exports.EXPLORER_MAX_HEADINGS=te;exports.EXPLORER_PROOF_HEADER=je;exports.EXPLORER_REFRESH_PROOF=$e;exports.EXPLORER_SCOPE_HEADER=Ie;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=v;exports.draftAnswerViolation=Te;exports.entryViolation=S;exports.explorerAssetHref=De;exports.explorerLinkCardEndpoint=ke;exports.explorerPlainTextHref=ve;exports.failureDocument=Pe;exports.failureOf=j;exports.failureReasonOfStatus=He;exports.failureViolation=f;exports.headingViolation=g;exports.isAcceptableDocumentPath=R;exports.isAcceptableUrl=le;exports.isDeniedPath=Q;exports.isExplorerAncestorsResult=ce;exports.isExplorerChildrenResult=L;exports.isExplorerDataOperation=Ue;exports.isExplorerDocument=w;exports.isExplorerEditAnswer=ge;exports.isExplorerEditToken=u;exports.isExplorerFailureCode=A;exports.isExplorerFailureReason=T;exports.isExplorerMediaType=P;exports.isExplorerNoticeTone=ie;exports.isExplorerPreviewAnswer=he;exports.isExplorerRevealResult=ue;exports.isExplorerRevisionAnswer=xe;exports.isExplorerRevisionsAnswer=be;exports.isExplorerSaveAnswer=Oe;exports.isExplorerTextAnswer=de;exports.isExplorerTreeResult=fe;exports.isRootRelativeUrl=c;exports.lastPathSegment=H;exports.readExplorerAssetDisplay=we;exports.resolvePathRules=J;exports.revisionViolation=k;
1
+ "use strict";const b=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"]),C=/[\u0000-\u001f\u007f]/u,U=/\p{Cs}/u,H=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},R=e=>e.length>0&&e.length<=4096&&!U.test(e)&&!C.test(e)&&!e.includes("\\"),x=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),z=/(?:%[0-9A-Fa-f]{2})+/gu,F=new TextDecoder("utf-8"),V=/[/\\]/u,M=e=>e.replace(z,t=>F.decode(Uint8Array.from(t.slice(1).split("%").map(n=>Number.parseInt(n,16))))),G=e=>{const t=[e];let n=e;for(let r=0;r<3&&n.includes("%");r+=1){const o=M(n);if(o===n)break;t.push(o),n=o}return t.map(x)},K=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=x(e).split("*").map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"su")},y=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const t=e.map(K),n=o=>o!==""&&t.some(i=>i.test(o)),r=o=>o!==""&&G(o).some(i=>n(i)||i.split(V).some(n));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},Y=y(b),W=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),J=e=>e===void 0?Y:e===!1?W:y(e),Q=(e,t)=>y(e).deniesPath(t),m=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),q=Object.freeze(["file","directory"]),B=Object.freeze(["video","audio","pdf"]),Z=Object.freeze(["info","warning","danger"]),ee=Object.freeze(["markdown","text","image","media","file","failure"]),O=Object.freeze({min:1,max:6}),te=1e4,c=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),ne=Object.freeze(["http:","https:","mailto:"]),_=1024,re=/^[a-z0-9-]{1,64}$/u,oe="https://relative.invalid/",h=64,p=(e,t)=>typeof t=="string"&&e.includes(t),s=e=>typeof e=="string"?JSON.stringify(e.length>h?`${e.slice(0,h)}…`:e):typeof e,T=e=>p(m,e),se=e=>p(q,e),P=e=>p(B,e),ie=e=>p(Z,e),ae=e=>p(ee,e),A=e=>typeof e=="string"&&re.test(e),le=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,oe).protocol)}catch{return!1}},f=e=>{if(e===null||typeof e!="object")return"a failure must be an object";const{reason:t,code:n}=e;return T(t)?n!==void 0&&!A(n)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${s(n)}`:null:`unknown failure reason ${s(t)}`},S=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:t,path:n,type:r,mimeType:o,modifiedAt:i,children:a,lazy:l}=e;return typeof t!="string"||t===""?"an entry needs a non-empty name":typeof n!="string"||!R(n)?"an entry needs an acceptable path":se(r)?o!==void 0&&typeof o!="string"?"an entry mimeType must be a string":i!==void 0&&!Number.isSafeInteger(i)?`an entry modifiedAt must be a safe integer of epoch milliseconds; got ${s(i)}`:l!==void 0&&typeof l!="boolean"?"an entry lazy flag must be a boolean":a!==void 0&&!Array.isArray(a)?"entry children must be an array":r==="file"&&(a!==void 0||l===!0)?"a file entry cannot have children or be lazy":l===!0&&Array.isArray(a)&&a.length>0?"a lazy directory must not list children":null:`an entry type must be "file" or "directory"; got ${s(r)}`},N=e=>{if(S(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(N)},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(N):t==="error"&&f(r)===null},ce=e=>{if(e===null||typeof e!="object")return!1;const{status:t,ancestors:n,failure:r}=e;return t==="ok"?n===null||D(n):t==="error"&&f(r)===null},D=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&R(t))&&new Set(e).size===e.length,ue=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!==""&&D(r):t==="error"&&f(o)===null},fe=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)},g=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<O.min||n>O.max?`a heading depth must be an integer in 1..6; got ${String(n)}`:null},v=e=>{if(e===null||typeof e!="object")return"a document must be an object";const t=e,{kind:n}=t;if(!ae(n))return`unknown document kind ${s(n)}`;if(n==="failure")return f(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 i of o){const a=g(i);if(a!==null)return a}return Ee(t.edit)}case"text":return typeof t.text!="string"||typeof t.truncated!="boolean"?"a text document needs text and truncated":c(t.url)?null:"a text document needs a root-relative url";case"image":return c(t.url)?null:"an image document needs a root-relative url";case"media":return c(t.url)?P(t.mediaType)?null:`unknown media type ${s(t.mediaType)}`:"a media document needs a root-relative url";case"file":return c(t.url)?null:"a file document needs a root-relative url"}},w=e=>v(e)===null,de=e=>w(e)&&(e.kind==="text"||e.kind==="failure"),Ee=e=>{if(e===null)return null;if(typeof e!="object")return"a markdown document's edit must be null or an object";const{kind:t,href:n}=e;return t==="inline"?n===void 0?null:"an inline edit carries no href":t==="draft"?n===void 0?null:"a draft edit carries no href":t!=="external"?`unknown edit kind ${s(t)}`:pe(n)?null:`an external edit needs an absolute https: href; got ${s(n)}`},pe=e=>{if(typeof e!="string")return!1;try{return new URL(e).protocol==="https:"}catch{return!1}},u=e=>typeof e=="string"&&e.length>0&&e.length<=_,Re=e=>c(e.href)?null:`a grant needs a root-relative href; got ${s(e.href)}`,k=e=>{if(e===null||typeof e!="object")return"a revision must be an object";const{id:t,modifiedAt:n,size:r,author:o,kept:i,current:a}=e;return u(t)?n!==null&&(typeof n!="string"||Number.isNaN(Date.parse(n)))?`a revision's modifiedAt must be a date-time string or null; got ${s(n)}`:typeof r!="number"||!Number.isSafeInteger(r)||r<0?`a revision's size must be a non-negative integer; got ${s(r)}`:o!==null&&typeof o!="string"?`a revision's author must be a string or null; got ${s(o)}`:typeof i!="boolean"||typeof a!="boolean"?"a revision needs kept and current booleans":null:`a revision id must be a non-empty string of at most ${_} characters; got ${s(t)}`},d=(e,t)=>{if(e===null||typeof e!="object")return"an answer must be an object";const n=e,{kind:r}=n;if(r==="failure")return f(n.failure);if(typeof r!="string"||!t.includes(r))return`unexpected answer kind ${s(r)}`;switch(r){case"grant":return Re(n);case"edit":return typeof n.text!="string"||typeof n.history!="boolean"?"an edit source needs text and history":u(n.version)?null:`an edit source needs a version; got ${s(n.version)}`;case"draft":return typeof n.text=="string"?null:"a draft source needs text";case"saved":return u(n.version)?null:`a saved answer needs a version; got ${s(n.version)}`;case"conflict":return typeof n.text!="string"?"a conflict needs the current text":u(n.version)?null:`a conflict needs the current version; got ${s(n.version)}`;case"preview":{const{htmlContent:o,headings:i}=n;if(typeof o!="string"||!Array.isArray(i))return"a preview needs htmlContent and headings";for(const a of i){const l=g(a);if(l!==null)return l}return null}case"revisions":{if(!Array.isArray(n.revisions))return"revisions need an array";for(const o of n.revisions){const i=k(o);if(i!==null)return i}return null}case"revision":return typeof n.text!="string"?"a revision answer needs text":u(n.id)?null:`a revision answer needs an id; got ${s(n.id)}`;default:return`unexpected answer kind ${s(r)}`}},ye=Object.freeze(["edit","draft","grant"]),me=Object.freeze(["saved","conflict","grant"]),I=Object.freeze(["preview"]),_e=Object.freeze(["revisions"]),Ae=Object.freeze(["revision"]),ge=e=>d(e,ye)===null,Oe=e=>d(e,me)===null,he=e=>d(e,I)===null,be=e=>d(e,_e)===null,xe=e=>d(e,Ae)===null,Te=e=>e!==null&&typeof e=="object"&&e.kind==="unavailable"?null:d(e,I),Pe=(e,t)=>({kind:"failure",failure:j(e,t)}),j=(e,t)=>A(t)?{reason:e,code:t}:{reason:e},Se=Object.freeze(["tree","children","ancestors","reveal","document","text","edit","save","preview","revisions","revision","refresh","asset","link-card"]),E=Object.freeze({source:"source",path:"path",version:"v",base:"base",revision:"revision",display:"as"}),Ne="asset",Le="link-card",De=(e,t,n)=>{const r=`${e}/${Ne}?${E.path}=${encodeURIComponent(t)}`;return n===null?r:`${r}&${E.version}=${encodeURIComponent(n)}`},$="text",ve=e=>{if(!e.includes("?"))throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);return`${e}&${E.display}=${$}`},we=e=>{const t=e.getAll(E.display);return t.length===0?"file":t.length===1&&t[0]===$?"text":null},ke=e=>`${e}/${Le}`,Ie="X-Markdown-Explorer-Scope",je="X-Markdown-Explorer",$e="refresh",Xe="edit",Ce="text/markdown",Ue=e=>Se.includes(e),X=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),He=e=>{const[t,...n]=m.filter(r=>X[r]===e);return t!==void 0&&n.length===0?t:"failed"};exports.DEFAULT_DENIED_PATH_SEGMENTS=b;exports.EXPLORER_DATA_QUERY=E;exports.EXPLORER_DRAFT_MEDIA_TYPE=Ce;exports.EXPLORER_EDIT_PROOF=Xe;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_;exports.EXPLORER_FAILURE_REASONS=m;exports.EXPLORER_FAILURE_STATUS=X;exports.EXPLORER_LINK_PROTOCOLS=ne;exports.EXPLORER_MAX_HEADINGS=te;exports.EXPLORER_PROOF_HEADER=je;exports.EXPLORER_REFRESH_PROOF=$e;exports.EXPLORER_SCOPE_HEADER=Ie;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=v;exports.draftAnswerViolation=Te;exports.entryViolation=S;exports.explorerAssetHref=De;exports.explorerLinkCardEndpoint=ke;exports.explorerPlainTextHref=ve;exports.failureDocument=Pe;exports.failureOf=j;exports.failureReasonOfStatus=He;exports.failureViolation=f;exports.headingViolation=g;exports.isAcceptableDocumentPath=R;exports.isAcceptableUrl=le;exports.isDeniedPath=Q;exports.isExplorerAncestorsResult=ce;exports.isExplorerChildrenResult=L;exports.isExplorerDataOperation=Ue;exports.isExplorerDocument=w;exports.isExplorerEditAnswer=ge;exports.isExplorerEditToken=u;exports.isExplorerFailureCode=A;exports.isExplorerFailureReason=T;exports.isExplorerMediaType=P;exports.isExplorerNoticeTone=ie;exports.isExplorerPreviewAnswer=he;exports.isExplorerRevealResult=ue;exports.isExplorerRevisionAnswer=xe;exports.isExplorerRevisionsAnswer=be;exports.isExplorerSaveAnswer=Oe;exports.isExplorerTextAnswer=de;exports.isExplorerTreeResult=fe;exports.isRootRelativeUrl=c;exports.lastPathSegment=H;exports.readExplorerAssetDisplay=we;exports.resolvePathRules=J;exports.revisionViolation=k;
@@ -88,7 +88,7 @@ const v = Object.freeze([
88
88
  deniesPath: (s) => s.split("/").some(r),
89
89
  deniesName: r
90
90
  };
91
- }, C = y(v), z = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), Ee = (e) => e === void 0 ? C : e === !1 ? z : y(e), ye = (e, t) => y(e).deniesPath(t), b = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), U = Object.freeze(["file", "directory"]), X = Object.freeze(["video", "audio", "pdf"]), H = Object.freeze(["info", "warning", "danger"]), V = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), m = Object.freeze({ min: 1, max: 6 }), me = 1e4, u = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), ge = Object.freeze(["http:", "https:", "mailto:"]), h = 1024, F = /^[a-z0-9-]{1,64}$/u, M = "https://relative.invalid/", g = 64, d = (e, t) => typeof t == "string" && e.includes(t), o = (e) => typeof e == "string" ? JSON.stringify(e.length > g ? `${e.slice(0, g)}…` : e) : typeof e, K = (e) => d(b, e), G = (e) => d(U, e), W = (e) => d(X, e), Re = (e) => d(H, e), Y = (e) => d(V, e), _ = (e) => typeof e == "string" && F.test(e), Ae = (e, t) => {
91
+ }, C = y(v), z = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), Ee = (e) => e === void 0 ? C : e === !1 ? z : y(e), ye = (e, t) => y(e).deniesPath(t), h = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), U = Object.freeze(["file", "directory"]), X = Object.freeze(["video", "audio", "pdf"]), H = Object.freeze(["info", "warning", "danger"]), V = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), m = Object.freeze({ min: 1, max: 6 }), me = 1e4, u = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), ge = Object.freeze(["http:", "https:", "mailto:"]), b = 1024, F = /^[a-z0-9-]{1,64}$/u, M = "https://relative.invalid/", g = 64, d = (e, t) => typeof t == "string" && e.includes(t), o = (e) => typeof e == "string" ? JSON.stringify(e.length > g ? `${e.slice(0, g)}…` : e) : typeof e, K = (e) => d(h, e), G = (e) => d(U, e), W = (e) => d(X, e), Re = (e) => d(H, e), Y = (e) => d(V, e), _ = (e) => typeof e == "string" && F.test(e), Ae = (e, t) => {
92
92
  if (typeof e != "string") return !1;
93
93
  try {
94
94
  return t.includes(new URL(e, M).protocol);
@@ -111,11 +111,11 @@ const v = Object.freeze([
111
111
  if (e === null || typeof e != "object") return !1;
112
112
  const { status: t, entries: n, failure: r } = e;
113
113
  return t === "ok" ? Array.isArray(n) && n.every(O) : t === "error" && p(r) === null;
114
- }, be = (e) => {
114
+ }, he = (e) => {
115
115
  if (e === null || typeof e != "object") return !1;
116
116
  const { status: t, ancestors: n, failure: r } = e;
117
117
  return t === "ok" ? n === null || x(n) : t === "error" && p(r) === null;
118
- }, x = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && R(t)) && new Set(e).size === e.length, he = (e) => {
118
+ }, x = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && R(t)) && new Set(e).size === e.length, be = (e) => {
119
119
  if (e === null || typeof e != "object") return !1;
120
120
  const { status: t, source: n, ancestors: r, failure: s } = e;
121
121
  return t === "ok" ? n === null && r === null || typeof n == "string" && n !== "" && x(r) : t === "error" && p(s) === null;
@@ -156,7 +156,7 @@ const v = Object.freeze([
156
156
  if (e === null) return null;
157
157
  if (typeof e != "object") return "a markdown document's edit must be null or an object";
158
158
  const { kind: t, href: n } = e;
159
- return t === "inline" ? n === void 0 ? null : "an inline edit carries no href" : t !== "external" ? `unknown edit kind ${o(t)}` : ee(n) ? null : `an external edit needs an absolute https: href; got ${o(n)}`;
159
+ return t === "inline" ? n === void 0 ? null : "an inline edit carries no href" : t === "draft" ? n === void 0 ? null : "a draft edit carries no href" : t !== "external" ? `unknown edit kind ${o(t)}` : ee(n) ? null : `an external edit needs an absolute https: href; got ${o(n)}`;
160
160
  }, ee = (e) => {
161
161
  if (typeof e != "string") return !1;
162
162
  try {
@@ -164,10 +164,10 @@ const v = Object.freeze([
164
164
  } catch {
165
165
  return !1;
166
166
  }
167
- }, f = (e) => typeof e == "string" && e.length > 0 && e.length <= h, te = (e) => u(e.href) ? null : `a grant needs a root-relative href; got ${o(e.href)}`, ne = (e) => {
167
+ }, f = (e) => typeof e == "string" && e.length > 0 && e.length <= b, te = (e) => u(e.href) ? null : `a grant needs a root-relative href; got ${o(e.href)}`, ne = (e) => {
168
168
  if (e === null || typeof e != "object") return "a revision must be an object";
169
169
  const { id: t, modifiedAt: n, size: r, author: s, kept: i, current: a } = e;
170
- return f(t) ? n !== null && (typeof n != "string" || Number.isNaN(Date.parse(n))) ? `a revision's modifiedAt must be a date-time string or null; got ${o(n)}` : typeof r != "number" || !Number.isSafeInteger(r) || r < 0 ? `a revision's size must be a non-negative integer; got ${o(r)}` : s !== null && typeof s != "string" ? `a revision's author must be a string or null; got ${o(s)}` : typeof i != "boolean" || typeof a != "boolean" ? "a revision needs kept and current booleans" : null : `a revision id must be a non-empty string of at most ${h} characters; got ${o(t)}`;
170
+ return f(t) ? n !== null && (typeof n != "string" || Number.isNaN(Date.parse(n))) ? `a revision's modifiedAt must be a date-time string or null; got ${o(n)}` : typeof r != "number" || !Number.isSafeInteger(r) || r < 0 ? `a revision's size must be a non-negative integer; got ${o(r)}` : s !== null && typeof s != "string" ? `a revision's author must be a string or null; got ${o(s)}` : typeof i != "boolean" || typeof a != "boolean" ? "a revision needs kept and current booleans" : null : `a revision id must be a non-empty string of at most ${b} characters; got ${o(t)}`;
171
171
  }, l = (e, t) => {
172
172
  if (e === null || typeof e != "object") return "an answer must be an object";
173
173
  const n = e, { kind: r } = n;
@@ -178,6 +178,8 @@ const v = Object.freeze([
178
178
  return te(n);
179
179
  case "edit":
180
180
  return typeof n.text != "string" || typeof n.history != "boolean" ? "an edit source needs text and history" : f(n.version) ? null : `an edit source needs a version; got ${o(n.version)}`;
181
+ case "draft":
182
+ return typeof n.text == "string" ? null : "a draft source needs text";
181
183
  case "saved":
182
184
  return f(n.version) ? null : `a saved answer needs a version; got ${o(n.version)}`;
183
185
  case "conflict":
@@ -204,7 +206,7 @@ const v = Object.freeze([
204
206
  default:
205
207
  return `unexpected answer kind ${o(r)}`;
206
208
  }
207
- }, re = Object.freeze(["edit", "grant"]), se = Object.freeze(["saved", "conflict", "grant"]), S = Object.freeze(["preview"]), oe = Object.freeze(["revisions"]), ie = Object.freeze(["revision"]), xe = (e) => l(e, re) === null, Te = (e) => l(e, se) === null, Se = (e) => l(e, S) === null, Ne = (e) => l(e, oe) === null, ve = (e) => l(e, ie) === null, we = (e) => e !== null && typeof e == "object" && e.kind === "unavailable" ? null : l(e, S), Pe = (e, t) => ({ kind: "failure", failure: ae(e, t) }), ae = (e, t) => _(t) ? { reason: e, code: t } : { reason: e }, ce = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "text", "edit", "save", "preview", "revisions", "revision", "refresh", "asset", "link-card"]), E = Object.freeze({ source: "source", path: "path", version: "v", base: "base", revision: "revision", display: "as" }), le = "asset", ue = "link-card", Le = (e, t, n) => {
209
+ }, re = Object.freeze(["edit", "draft", "grant"]), se = Object.freeze(["saved", "conflict", "grant"]), S = Object.freeze(["preview"]), oe = Object.freeze(["revisions"]), ie = Object.freeze(["revision"]), xe = (e) => l(e, re) === null, Te = (e) => l(e, se) === null, Se = (e) => l(e, S) === null, Ne = (e) => l(e, oe) === null, ve = (e) => l(e, ie) === null, we = (e) => e !== null && typeof e == "object" && e.kind === "unavailable" ? null : l(e, S), Pe = (e, t) => ({ kind: "failure", failure: ae(e, t) }), ae = (e, t) => _(t) ? { reason: e, code: t } : { reason: e }, ce = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "text", "edit", "save", "preview", "revisions", "revision", "refresh", "asset", "link-card"]), E = Object.freeze({ source: "source", path: "path", version: "v", base: "base", revision: "revision", display: "as" }), le = "asset", ue = "link-card", Le = (e, t, n) => {
208
210
  const r = `${e}/${le}?${E.path}=${encodeURIComponent(t)}`;
209
211
  return n === null ? r : `${r}&${E.version}=${encodeURIComponent(n)}`;
210
212
  }, N = "text", De = (e) => {
@@ -223,7 +225,7 @@ const v = Object.freeze([
223
225
  unsupported: 500,
224
226
  failed: 500
225
227
  }), He = (e) => {
226
- const [t, ...n] = b.filter((r) => fe[r] === e);
228
+ const [t, ...n] = h.filter((r) => fe[r] === e);
227
229
  return t !== void 0 && n.length === 0 ? t : "failed";
228
230
  };
229
231
  export {
@@ -236,8 +238,8 @@ export {
236
238
  De as G,
237
239
  He as H,
238
240
  Oe as I,
239
- he as J,
240
- be as K,
241
+ be as J,
242
+ he as K,
241
243
  q as L,
242
244
  de as M,
243
245
  p as N,
@@ -248,8 +250,8 @@ export {
248
250
  Te as S,
249
251
  xe as T,
250
252
  Q as U,
251
- h as V,
252
- b as W,
253
+ b as V,
254
+ h as W,
253
255
  je as a,
254
256
  K as b,
255
257
  _ as c,