@aiquants/markdown-explorer 0.34.0 → 0.35.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.
- package/CHANGELOG.md +515 -0
- package/README.md +90 -39
- package/dist/EditSurface-CLG70Vnn.cjs +6 -0
- package/dist/EditSurface-D2j1kCEE.js +990 -0
- package/dist/ExplorerSplit-CfP1smbT.js +1589 -0
- package/dist/ExplorerSplit-D_0VohOv.cjs +2 -0
- package/dist/{MultiLayout-kcZyVnvK.js → MultiLayout-BeJ5Lubb.js} +249 -248
- package/dist/MultiLayout-CxV5SI7f.cjs +1 -0
- package/dist/{NativeScrollBar-UNed10Na.js → NativeScrollBar-BM5NULzg.js} +2 -2
- package/dist/{NativeScrollBar-pUbA4Zq3.cjs → NativeScrollBar-RWXpVhbI.cjs} +1 -1
- package/dist/TreeLayout-AxLw-36S.js +103 -0
- package/dist/TreeLayout-Bg2YH-EY.cjs +1 -0
- package/dist/client/MarkdownExplorer.d.cts +14 -1
- package/dist/client/MarkdownExplorer.d.ts +14 -1
- package/dist/client/edit/lineEndings.d.cts +4 -0
- package/dist/client/edit/lineEndings.d.ts +4 -0
- package/dist/client/hostContract.d.cts +67 -0
- package/dist/client/hostContract.d.ts +67 -0
- package/dist/core/config.d.cts +7 -0
- package/dist/core/config.d.ts +7 -0
- package/dist/core/contracts.d.cts +10 -4
- package/dist/core/contracts.d.ts +10 -4
- package/dist/core/draftAnswer.d.cts +23 -0
- package/dist/core/draftAnswer.d.ts +23 -0
- package/dist/core/labels.d.cts +68 -0
- package/dist/core/labels.d.ts +68 -0
- package/dist/core/location.d.cts +1 -2
- package/dist/core/location.d.ts +1 -2
- package/dist/core/ownUrls.d.cts +15 -0
- package/dist/core/ownUrls.d.ts +15 -0
- package/dist/core/treeSettings.d.cts +3 -2
- package/dist/core/treeSettings.d.ts +3 -2
- package/dist/core/viewSettings.d.cts +3 -1
- package/dist/core/viewSettings.d.ts +3 -1
- package/dist/describeValue-CLlVRO8d.js +17 -0
- package/dist/describeValue-Ccvhbt36.cjs +1 -0
- package/dist/explorerCore-DLpDuSev.js +998 -0
- package/dist/explorerCore-DYrxS9ez.cjs +1 -0
- package/dist/index-C1YMH-yI.js +5816 -0
- package/dist/index-LQWQfpAf.cjs +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +49 -44
- package/dist/licenses/@heroicons/react/LICENSE +21 -0
- package/dist/licenses/entities/LICENSE +11 -0
- package/dist/licenses/parse5/LICENSE +19 -0
- package/dist/location--KvTA0Ri.js +726 -0
- package/dist/location-D8DyDkuA.cjs +1 -0
- package/dist/lru-DC8GBmkX.js +39 -0
- package/dist/lru-SGmUyBQU.cjs +1 -0
- package/dist/{merge-C1MWvhCS.js → merge-Bb_HpPhe.js} +1 -1
- package/dist/{merge-BziXxZkE.cjs → merge-DQUYEGCx.cjs} +1 -1
- package/dist/nestingGuardWorker.js +5511 -0
- package/dist/ownUrls-B259RGgd.cjs +1 -0
- package/dist/ownUrls-Dh5g6ZJi.js +370 -0
- package/dist/sanitizeJob-BYRk17nr.js +21 -0
- package/dist/sanitizeJob-Cs9o3Vpl.cjs +1 -0
- package/dist/sanitizePolicy-CEMdaLUB.js +139 -0
- package/dist/sanitizePolicy-CiQfnxyd.cjs +2 -0
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +134 -139
- package/dist/sanitizerService-BY4CPCoA.cjs +1 -0
- package/dist/sanitizerService-KWXv7bPm.js +240 -0
- package/dist/server/assetResponse.d.cts +60 -0
- package/dist/server/assetResponse.d.ts +60 -0
- package/dist/server/browser/browserPlatform.d.cts +12 -0
- package/dist/server/browser/browserPlatform.d.ts +12 -0
- package/dist/server/createMarkdownExplorer.d.cts +0 -10
- package/dist/server/createMarkdownExplorer.d.ts +0 -10
- package/dist/server/explorerCore.d.cts +12 -0
- package/dist/server/explorerCore.d.ts +12 -0
- package/dist/server/fileSystemSource.d.cts +1 -0
- package/dist/server/fileSystemSource.d.ts +1 -0
- package/dist/server/inProcessFetch.d.cts +5 -0
- package/dist/server/inProcessFetch.d.ts +5 -0
- package/dist/server/platform.d.cts +18 -0
- package/dist/server/platform.d.ts +18 -0
- package/dist/server/ports.d.cts +36 -5
- package/dist/server/ports.d.ts +36 -5
- package/dist/server/sanitizeProtocol.d.cts +3 -0
- package/dist/server/sanitizeProtocol.d.ts +3 -0
- package/dist/server/sanitizer.d.cts +5 -40
- package/dist/server/sanitizer.d.ts +5 -40
- package/dist/server/sanitizerOptions.d.cts +24 -0
- package/dist/server/sanitizerOptions.d.ts +24 -0
- package/dist/server/sanitizerService.d.cts +41 -0
- package/dist/server/sanitizerService.d.ts +41 -0
- package/dist/server/{workerPool.d.cts → workerJobs.d.cts} +0 -16
- package/dist/server/{workerPool.d.ts → workerJobs.d.ts} +0 -16
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +3 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js +270 -1343
- package/dist/serverBrowser.cjs +1 -0
- package/dist/serverBrowser.d.cts +1 -0
- package/dist/serverBrowser.d.ts +1 -0
- package/dist/serverBrowser.js +120 -0
- package/dist/serverCore.cjs +1 -0
- package/dist/serverCore.d.cts +14 -0
- package/dist/serverCore.d.ts +14 -0
- package/dist/serverCore.js +46 -0
- package/dist/storage-BpYsprog.cjs +1 -0
- package/dist/{storage-CmGHg7OA.js → storage-D1uSw-xj.js} +19 -18
- package/dist/storage.cjs +1 -1
- package/dist/storage.js +1 -1
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/{tapScrollCircle-D_BpaLwY.js → tapScrollCircle-BEydRn0y.js} +1 -1
- package/dist/{tapScrollCircle-DigcJCsu.cjs → tapScrollCircle-DdX0Wri0.cjs} +1 -1
- package/dist/testing.cjs +1 -0
- package/dist/testing.d.cts +6 -0
- package/dist/testing.d.ts +6 -0
- package/dist/testing.js +4 -0
- package/dist/useSplitPersistence-B2Fj508K.cjs +1 -0
- package/dist/useSplitPersistence-Fkqak8G8.js +44 -0
- package/docs/behavior/dom-hooks.md +2 -0
- package/docs/behavior/hosting.md +123 -0
- package/docs/behavior/layout.md +5 -3
- package/docs/behavior/localization.md +25 -8
- package/docs/behavior/security.md +32 -13
- package/docs/behavior/url-contract.md +4 -3
- package/package.json +48 -10
- package/dist/EditSurface-CF82jZQg.cjs +0 -6
- package/dist/EditSurface-CqHk2R3k.js +0 -982
- package/dist/ExplorerSplit-D325YGEf.cjs +0 -1
- package/dist/ExplorerSplit-DGH9bckm.js +0 -1500
- package/dist/MultiLayout-CzR7yJ0m.cjs +0 -1
- package/dist/TreeLayout-BnIU87HX.js +0 -96
- package/dist/TreeLayout-DtvIpuOe.cjs +0 -1
- package/dist/dataRoute-D6KiSHIc.js +0 -298
- package/dist/dataRoute-DwYtgyt6.cjs +0 -1
- package/dist/index-BDCbvHDs.cjs +0 -15
- package/dist/index-DR31S_-4.js +0 -5012
- package/dist/location-C44b9H1S.js +0 -676
- package/dist/location-hGLhCCg4.cjs +0 -1
- package/dist/sanitizePolicy-CwvyPpp5.js +0 -98
- package/dist/sanitizePolicy-T5T-3vV5.cjs +0 -1
- package/dist/storage-DM0EvkVf.cjs +0 -1
- package/dist/useSplitPersistence-DCeYbJMx.js +0 -38
- package/dist/useSplitPersistence-QGcvyMAa.cjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),c=require("react"),j=require("./location-hGLhCCg4.cjs"),P=require("./index-BDCbvHDs.cjs"),oe=require("./ExplorerSplit-D325YGEf.cjs"),D=require("@aiquants/drag-drop-panels"),me=require("react-router"),ee=require("./storage-DM0EvkVf.cjs"),we=require("./dataRoute-DwYtgyt6.cjs"),He=require("react-dom"),Be=require("@aiquants/markdown"),qe=()=>{const e=new Map;return{hold:(n,t)=>{e.set(n,t),queueMicrotask(()=>{e.get(n)===t&&e.delete(n)})},take:n=>{const t=e.get(n);return e.delete(n),t===void 0?null:t}}},Oe=c.createContext(null),le=()=>{const e=c.use(Oe);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},je=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},Fe=0xcbf29ce484222325n,Ve=0x100000001b3n,Ue=(1n<<64n)-1n,$e=(1n<<53n)-1n,Ge=new TextEncoder,Ye=e=>{let n=Fe;for(const t of Ge.encode(e))n=(n^BigInt(t))*Ve&Ue;return Number(n&$e)},Z=256,We=e=>`aqmx-p-${Ye(e).toString(36)}`,Ce=(e,n)=>{const t=We(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Ke=new Map,Je=(e,n=Ke)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??Ce(r,t);t.add(s),o.set(r,s)}return o},be=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},Pe=(e,n)=>{const[t,...o]=j.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([m,g])=>e.slice(m,g).reduce((i,v)=>i+v.length,0);let s=t;for(const m of o)r(m)<r(s)&&(s=m);let a=s[0];for(let m=s[0];m<s[1];m+=1)(e[m]?.length??0)<(e[a]?.length??0)&&(a=m);return a},Q=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=be(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[Pe(t,n)]?.push(r);return t},Xe=(e,n)=>j.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),Ze=(e,n,t)=>{const[o,r]=n,s=r-o,a=e.length,m=Array.from({length:s},(x,d)=>{const y=[0];for(const h of e)y.push((y.at(-1)??0)+(t(h)===o+d?1:0));return y}),g=(x,d,y)=>(m[x]?.[y]??0)-(m[x]?.[d]??0),i=Array.from({length:s+1},()=>Array.from({length:a+1},()=>Number.NEGATIVE_INFINITY)),v=Array.from({length:s+1},()=>Array.from({length:a+1},()=>0)),O=i[0];O&&(O[0]=0);for(let x=0;x<s;x+=1)for(let d=0;d<=a;d+=1)for(let y=0;y<=d;y+=1){const h=(i[x]?.[y]??Number.NEGATIVE_INFINITY)+g(x,y,d),C=i[x+1],L=v[x+1];C&&L&&h>(C[d]??Number.NEGATIVE_INFINITY)&&(C[d]=h,L[d]=y)}const T=Array.from({length:s},()=>[]);let A=a;for(let x=s;x>0;x-=1){const d=v[x]?.[A]??0;T[x-1]=e.slice(d,A),A=d}return T},Te=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const a of s)o.delete(a),o.set(a,r);for(const r of o.keys()){if(o.size<=Z)break;o.delete(r)}return{docs:t,columnOf:o}},Qe=(e,n,t,o)=>{if(e.docs.includes(n))return{state:e,outcome:"existing"};if(e.docs.length>=o)return{state:e,outcome:"rejected"};const r=Q(e,t),s=be(e,n,t.logical)??Pe(r,t);r[s]?.push(n);const a=new Map(e.panelIds);return a.set(n,Ce(n,new Set(a.values()))),{state:{...e,...Te(e,r),panelIds:a},outcome:"opened"}},Le=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Set(e.markup);o.delete(n);const r=new Map(e.panelIds);return r.delete(n),{...e,docs:e.docs.filter(s=>s!==n),hidden:t,markup:o,panelIds:r,maximized:e.maximized===n?null:e.maximized}},en=(e,n,t,o)=>{if(e.hidden.has(n))return{state:Me(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Le(e,n),outcome:"closed"};const r=Qe(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},nn=(e,n,t)=>{if(n===t||!e.docs.includes(n))return{state:e,outcome:"ignored"};if(e.docs.includes(t))return{state:e,outcome:"existing"};const o=new Map(e.columnOf),r=o.get(n);r!==void 0&&(o.delete(t),o.set(t,r));const s=new Set(e.hidden);s.delete(n);const a=new Map(e.panelIds),m=a.get(n);if(m===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);a.delete(n),a.set(t,m);const g=new Set(e.markup);return g.delete(n),{state:{docs:e.docs.map(i=>i===n?t:i),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,markup:g,panelIds:a},outcome:"navigated"}},Me=(e,n,t)=>{if(!e.docs.includes(n)||e.hidden.has(n)===t)return e;const o=new Set(e.hidden);return t?o.add(n):o.delete(n),{...e,hidden:o,maximized:t&&e.maximized===n?null:e.maximized}},tn=(e,n,t)=>{if(!e.docs.includes(n)||e.markup.has(n)===t)return e;const o=new Set(e.markup);return t?o.add(n):o.delete(n),{...e,markup:o}},on=(e,n)=>{if(e.maximized===n||n!==null&&!e.docs.includes(n))return e;if(n===null||!e.hidden.has(n))return{...e,maximized:n};const t=new Set(e.hidden);return t.delete(n),{...e,maximized:n,hidden:t}},rn=(e,n,t)=>{const o=Q(e,t),r=new Map;for(const[i,v]of o.entries())for(const O of v)r.set(O,i);const s=new Set(e.docs),a=new Set,m=j.columnGroups(t.logical,t.visible),g=Array.from({length:t.logical},()=>[]);for(const[i,v]of m.entries()){const O=(n[i]??[]).filter(T=>s.has(T)&&!a.has(T));for(const T of O)a.add(T);for(const[T,A]of Ze(O,v,x=>r.get(x)).entries())g[v[0]+T]?.push(...A)}for(const i of e.docs)a.has(i)||g[r.get(i)??0]?.push(i);return g.every((i,v)=>i.length===o[v]?.length&&i.every((O,T)=>o[v]?.[T]===O))?e:{...e,...Te(e,g)}},ne=(e,n)=>{const t=[...new Set(e.docs)].slice(0,n),o=new Set(t),r=e.maximized!==null&&o.has(e.maximized)?e.maximized:null;return{docs:t,maximized:r,columnOf:e.stored.columnOf,hidden:new Set([...e.stored.hidden].filter(s=>o.has(s)&&s!==r)),markup:new Set(e.markup.filter(s=>o.has(s))),panelIds:Je(t,e.panelIds)}},fe=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of Q(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=Z)break;t.delete(o)}return{...e,columnOf:t}},ke=1,U=Object.freeze({columnOf:new Map,hidden:new Set}),sn=(e,n)=>{if(e===null||e==="")return U;let t;try{t=JSON.parse(e)}catch{return U}if(t===null||typeof t!="object"||Array.isArray(t))return U;const o=t;if(o.v!==ke)return U;const r=new Map;if(Array.isArray(o.columnOf))for(const a of o.columnOf.slice(-Z))Array.isArray(a)&&a.length===2&&typeof a[0]=="string"&&a[0]!==""&&Number.isInteger(a[1])&&a[1]>=0&&a[1]<n&&(r.delete(a[0]),r.set(a[0],a[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(a=>typeof a=="string"&&a!==""):[]);return{columnOf:r,hidden:s}},ln=e=>JSON.stringify({v:ke,columnOf:[...e.columnOf.entries()].slice(-Z),hidden:e.docs.filter(n=>e.hidden.has(n))}),ie=(e,n)=>{const t=e.get(n);return t===void 0?we.lastPathSegment(n):t},Y=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},pe=e=>{if(!we.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(e.slice(0,80))}`)},an=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,a=P.createEmitter(),m=new Map,g=new Map;let i={layout:ne({docs:n.docs,maximized:n.maximized,markup:n.markup,stored:U},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},v=!1;const O=l=>v?fe(l,{logical:s,visible:i.visibleColumns}):l,T=(l,S)=>j.explorerHref(e,{view:"multi",source:l,docs:S.docs,maximized:S.maximized,markup:S.markup}),A=l=>({docs:l.docs,maximized:l.maximized,markup:[...l.markup]});let x=T(n.source,n),d=n.source,y=x;const h=[],C=[];let L=null;const R=()=>{if(!(h.length>0))for(const l of C.splice(0))l()},N=l=>{i={...i,...l},a.emit()},u=()=>{if(!i.ready)return;const l=ln(i.layout);l!==L&&(L=l,o(l))},p=(l,S,b)=>{const I=T(l,A(S));I!==x&&(x=I,d=l,h.push(I),t(I,b))},f=l=>{const S=new Set(l.panelIds.values());for(const w of[...m.keys()])S.has(w)||m.delete(w);for(const w of[...g.keys()])S.has(w)||g.delete(w);const b=new Set(l.docs),I=[...i.titles.keys()].every(w=>b.has(w))?i.titles:new Map([...i.titles].filter(([w])=>b.has(w))),E=[...i.pendingHashes.keys()].every(w=>S.has(w))?i.pendingHashes:new Map([...i.pendingHashes].filter(([w])=>S.has(w)));return{titles:I,pendingHashes:E}},M=l=>l===i.layout?!1:(N({layout:l,...f(l)}),p(d,l,"replace"),u(),!0),_=()=>({logical:s,visible:i.visibleColumns});return{getSnapshot:()=>i,subscribe:a.subscribe,toggle:l=>{pe(l);const{state:S,outcome:b}=en(i.layout,l,_(),r);return M(S),b},close:l=>M(Le(i.layout,l)),navigate:(l,S)=>{pe(S);const{state:b,outcome:I}=nn(i.layout,l,S);if(I!=="navigated")return I;const E=b.panelIds.get(S);return E!==void 0&&(m.delete(E),g.delete(E)),M(b),I},setHidden:(l,S)=>M(Me(i.layout,l,S)),maximize:l=>M(on(i.layout,l)),setMarkup:(l,S)=>M(tn(i.layout,l,S)),arrange:l=>M(rn(i.layout,l,{logical:s,visible:l.length})),changeSource:l=>{p(l,i.layout,"push")},revealSource:l=>{p(l,i.layout,"replace")},observeLocation:l=>{const S=T(l.source,l);if(S===x)return h.length=0,y=S,l.source!==i.source&&N({source:l.source}),R(),!1;if(S===y)return!1;y=S;const b=h.indexOf(S);if(b>=0)return h.splice(0,b+1),l.source!==i.source&&N({source:l.source}),R(),!1;h.length=0,x=S,d=l.source;const I=O(ne({docs:l.docs,maximized:l.maximized,markup:l.markup,stored:{columnOf:i.layout.columnOf,hidden:i.layout.hidden},panelIds:i.layout.panelIds},r));return N({layout:I,source:l.source,...f(I)}),u(),R(),!0},whenUrlRendered:l=>{C.push(l),R()},loadStored:l=>{N({layout:O(ne({docs:i.layout.docs,maximized:i.layout.maximized,markup:[...i.layout.markup],stored:l,panelIds:i.layout.panelIds},r)),ready:!0}),u()},setVisibleColumns:l=>{if(!Number.isInteger(l)||l<1||l>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${String(l)}`);v=!0;const S=fe(i.layout,{logical:s,visible:l});l===i.visibleColumns&&S===i.layout||(N({visibleColumns:l,layout:S}),S!==i.layout&&u())},setSplitDragging:l=>{l!==i.splitDragging&&N({splitDragging:l})},setTitle:(l,S)=>{!i.layout.docs.includes(l)||i.titles.get(l)===S||N({titles:new Map(i.titles).set(l,S)})},titleOf:l=>ie(i.titles,l),setPendingHash:(l,S)=>{const b=i.pendingHashes.get(l);if(S===null||S===""){if(b===void 0)return;const I=new Map(i.pendingHashes);I.delete(l),N({pendingHashes:I});return}b!==S&&N({pendingHashes:new Map(i.pendingHashes).set(l,S)})},saveReadingPosition:(l,S,b)=>{i.layout.panelIds.get(S)===l&&m.set(l,{doc:S,position:b})},readingPositionOf:(l,S)=>{const b=m.get(l);return b===void 0||b.doc!==S?null:b.position},saveImageView:(l,S,b)=>{g.set(l,{url:S,state:b})},imageViewOf:(l,S)=>{const b=g.get(l);return b===void 0||b.url!==S?null:b.state}}},z=(e,n)=>{const t=()=>n(e.getSnapshot());return c.useSyncExternalStore(e.subscribe,t,t)},cn=e=>{const{config:n,storageNamespace:t}=P.useExplorer(),o=me.useNavigate(),r=c.useRef(o),s=ee.storageKeys(t).multiLayout,[a]=c.useState(()=>an({config:n,location:e,writeUrl:(i,v)=>{r.current(i,P.explorerNavigationOptions(v==="replace"?"browse":"switch-source"))},persist:i=>ee.writeStorage(s,i)}));c.useLayoutEffect(()=>{r.current=o},[o]);const m=me.useLocation(),g=c.useMemo(()=>({location:e,navigated:m}),[e,m]);return c.useLayoutEffect(()=>{a.observeLocation(g.location)},[a,g]),c.useLayoutEffect(()=>{a.loadStored(sn(ee.readStorage(s),n.multiView.columns))},[a,s,n]),a},un=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);if(n===null)throw new Error("[markdown-explorer] a panel's document region is not inside the panel's scroll area");return n},dn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:a,revealInPanel:m,keepAtStartInPanel:g}=le(),{announcer:i}=P.useExplorer(),v=z(s,u=>je(u,n)),O=z(s,u=>u.layout.markup.has(e)),T=c.useCallback((u,p)=>a(n,e,u,p),[a,n,e]),A=c.useCallback(()=>s.setPendingHash(n,null),[s,n]),x=c.useMemo(()=>({read:u=>s.imageViewOf(n,u),save:(u,p)=>s.saveImageView(n,u,p)}),[s,n]),d=c.useCallback((u,p)=>{p.kind!=="failure"&&s.setTitle(u,p.name),r(u)},[s,r]),y=c.useCallback(u=>{s.whenUrlRendered(()=>i.announce(u))},[s,i]),h=c.useMemo(()=>({scrollerOf:un,reveal:u=>m(n,u),keepAtStart:(u,p)=>g(n,u,p)}),[m,g,n]),C=c.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:T,pendingHash:v,onHashConsumed:A,announceFailure:y,paneScroll:h}),[t,T,v,A,y,h]),L=c.useMemo(()=>({kind:"panel",documentName:o,maximized:t}),[o,t]),R=c.useCallback(()=>s.setMarkup(e,!s.getSnapshot().layout.markup.has(e)),[s,e]),N=c.useMemo(()=>({shown:O,toggle:R}),[O,R]);return k.jsxs(P.ImageViewMemoryContext,{value:x,children:[k.jsx(P.DocumentRefreshBar,{path:e,placement:L,markup:N,maximize:null}),k.jsx(P.DocumentPane,{path:e,absence:P.NO_DOCUMENT,markup:O,variant:C,onDocumentShown:d})]})},ge=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",ae="data-aqmx-column-probe",K="data-panel-id",re="--aqmx-multi-panel-chrome",mn=e=>e==="normal"?0:P.cssPixels(e),fn=(e,n)=>{const t=e.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${ae}]`),r=o instanceof HTMLElement?o.getBoundingClientRect().width:Number.NaN;if(!(t instanceof HTMLElement))return{plan:{trackInlineSize:Number.NaN,gap:Number.NaN,minColumnInlineSize:r,logicalColumns:n},stageBlockSize:Number.NaN};const s=getComputedStyle(t),a=t.clientWidth-P.cssPixels(s.paddingLeft)-P.cssPixels(s.paddingRight),m=t.clientHeight-P.cssPixels(s.paddingTop)-P.cssPixels(s.paddingBottom);return{plan:{trackInlineSize:a,gap:mn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:m}},pn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+P.cssPixels(t.paddingBottom)+P.cssPixels(t.borderBottomWidth)},J="data-aqmx-panel-frame",he="--aqmx-multi-panel-pinned-block-size",gn=e=>{const{docPath:n,panelId:t}=e;if(typeof n!="string"||typeof t!="string")throw new TypeError("[markdown-explorer] a multi-view panel needs string docPath and panelId props");return{docPath:n,panelId:t}},hn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},Sn=(e,n,t)=>e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*n.clientHeight:e.deltaMode!==WheelEvent.DOM_DELTA_LINE?e.deltaY:e.deltaY*t(n),$=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);return n instanceof HTMLElement?n:null},Ne=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},Re=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ne(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},Se=(e,n)=>{let t=0,o=e.length;for(;t<o;){const r=t+o>>>1;(e[r]?.getBoundingClientRect().bottom??Number.NEGATIVE_INFINITY)>n?o=r:t=r+1}return t<e.length?t:-1},yn=(e,n)=>{const t=Re(e,n),o=[];let r=e;for(let a=Se([...r.children],t);a>=0;a=Se([...r.children],t)){const m=r.children[a];if(m===void 0)break;o.push(a),r=m}const s=r.getBoundingClientRect();return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:s.top-t,height:s.height}}},ye=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const g of t.anchor.path)o=o?.children[g];if(o===void 0)return;const r=o.getBoundingClientRect(),{offset:s,height:a}=t.anchor,m=s<0&&a>0?s/a*r.height:s;n.scrollTop+=r.top-Re(e,n)-m},xn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),Ae=e=>{const n=e.getAttribute(D.PANEL_ACTION_ATTRIBUTE);return JSON.stringify(n===null?[e.tagName,...xn.map(t=>e.getAttribute(t))]:[e.tagName,D.PANEL_ACTION_ATTRIBUTE,n])},vn=(e,n)=>{if(n===null||!e.contains(n))return null;const t=[];for(let o=n;o!==e;){const r=o.parentElement;if(r===null)return null;t.unshift([...r.children].indexOf(o)),o=r}return{path:t,signature:Ae(n)}},En=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&Ae(o)===t.signature&&P.focusWithoutScroll(o)||n.focus({preventScroll:!0})},wn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?$(n):n.closest(D.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=Sn(e,r,t);(o||On(r,s))&&(e.preventDefault(),r.scrollTop+=s)},On=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,Cn=e=>e.scrollHeight>e.clientHeight,bn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ne(t),a=()=>{const i=pn(e,n);if(!Number.isFinite(i))return;const v=s===null?0:s.getBoundingClientRect().height;v!==r&&(r=v,t.style.setProperty(he,`${String(v)}px`));const O=i+v;O!==o&&(o=O,e.style.setProperty(re,`${String(O)}px`))};a();let m=null;const g=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{m===null&&(m=requestAnimationFrame(()=>{m=null,a()}))});return g?.observe(e),g?.observe(n),s!==null&&g?.observe(s),()=>{g?.disconnect(),m!==null&&cancelAnimationFrame(m),e.style.removeProperty(re),t.style.removeProperty(he)}},Pn=e=>{const{docPath:n,panelId:t}=gn(e),{store:o,Body:r,maximize:s,focusCarry:a}=le(),m=z(o,d=>d.layout.maximized===n),g=z(o,d=>ie(d.titles,n)),i=c.useRef(null),v=c.useRef(null),O=c.useRef(null),T=c.useRef(null);c.useEffect(()=>{const d=i.current,y=d===null?null:$(d);if(d===null||y===null||m)return;const h=new Map,C=p=>{const f=h.get(p);if(f!==void 0)return f;const M=hn(p);return h.set(p,M),M},L=p=>wn(p,d,C);let R=!1;const N=()=>{const p=Cn(y);p!==R&&(R=p,p?d.addEventListener("wheel",L,{capture:!0,passive:!1}):d.removeEventListener("wheel",L,{capture:!0}))};N();const u=typeof ResizeObserver>"u"?null:new ResizeObserver(N);return u?.observe(y),u?.observe(d),()=>{u?.disconnect(),d.removeEventListener("wheel",L,{capture:!0})}},[m]),c.useLayoutEffect(()=>{const d=i.current,y=d===null?null:$(d),h=d===null?null:d.closest(`[${K}]`);if(!(d===null||y===null||!(h instanceof HTMLElement)))return bn(h,y,d)},[]),c.useLayoutEffect(()=>{const d=i.current,y=d===null?null:$(d);if(d===null||y===null)return;const h=p=>{ye(d,y,p),T.current=y.scrollTop},C=o.readingPositionOf(t,n);v.current=C===null?null:{doc:n,position:C},C!==null&&h(C);let L=null,R=d.getBoundingClientRect().width;const N=()=>{L===null&&(L=requestAnimationFrame(()=>{L=null;const p=T.current;if(T.current=null,p!==null&&y.scrollTop===p||d.getBoundingClientRect().width!==R)return;const f=O.current;f!==null&&o.saveReadingPosition(t,f,yn(d,y))}))};y.addEventListener("scroll",N,{passive:!0});const u=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const p=d.getBoundingClientRect().width;if(p===R)return;R=p;const f=o.readingPositionOf(t,n);f!==null&&h(f)});return u?.observe(d),()=>{y.removeEventListener("scroll",N),u?.disconnect(),L!==null&&cancelAnimationFrame(L)}},[o,t,n]),c.useLayoutEffect(()=>{const d=i.current,y=d===null?null:d.closest(`[${K}]`);if(d===null||y===null)return;const h=a.take(t);return h!==null&&En(y,d,h),()=>{const C=vn(y,y.ownerDocument.activeElement);C!==null&&a.hold(t,C)}},[a,t]);const A=c.useCallback(d=>{const y=i.current,h=y===null?null:$(y);if(y===null||h===null)return;const C=O.current;O.current=d;const L=v.current;v.current=null,L!==null&&L.doc===d?(ye(y,h,L.position),T.current=h.scrollTop):C!==null&&C!==d&&(h.scrollTop=0)},[]),x=c.useCallback(d=>{P.isInFullscreenBlock(d.target)||s(n)},[s,n]);return k.jsx("div",{ref:i,role:"group","aria-label":g,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":m?"true":"false","data-testid":"markdown-explorer-panel-frame",...m?P.CONTENT_PANE:{},onDoubleClick:m?void 0:x,children:k.jsx(r,{docPath:n,panelId:t,maximized:m,title:g,onContentShown:A})})},Tn=c.memo(Pn),W=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return t},xe=e=>Object.fromEntries(D.generateColumnIds(e).map(n=>[n,[]])),Ln=(e,n)=>{const t=Xe(Q(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>W(e,s))]))},Mn=(e,n)=>{const t=Y(e);return D.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},kn=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanel:e.panelMove,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,morePanelActions:e.panelMoreActions,customDragModeBadge:e.panelCustomDragBadge,panelMoved:e.panelMoved,panelMoveUnavailable:e.panelMoveUnavailable,panelDragStarted:e.panelDragStarted,panelDragCancelled:e.panelDragCancelled,hiddenPanels:e.hiddenPanelsTitle,hiddenPanelBadge:e.hiddenPanelBadge,hiddenPanelNotice:e.hiddenPanelNotice,emptyColumn:e.multiColumnEmpty,dropZone:e.multiColumnRegion,dropHere:e.panelDropHere}),Nn="--aqmx-multi-stage-bar-gutter",Rn=Object.freeze({[Nn]:`${String(P.NATIVE_SCROLL_BAR_WIDTH)}px`}),An=Object.freeze({blockSize:"100%",paddingInlineEnd:P.TAP_SCROLL_CIRCLE_GUTTER_LENGTH}),In=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),_n=e=>k.jsx("div",{...In,children:k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"content"})}),Dn=({props:e,children:n})=>k.jsx(Be.HostedScrollArea,{scrollerProps:{...e,style:An},renderScrollBar:_n,barInlineSize:P.NATIVE_SCROLL_BAR_SLOT_LENGTH,children:n}),zn=e=>k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"stage"}),ce="--aqmx-stage-block",Hn="--aqmx-multi-panel-body-floor",Bn=`calc(var(${ce}) * ${String(j.PANEL_MIN_BLOCK_RATIO)})`,qn=`max(calc(var(${ce}) * ${String(j.PANEL_MAX_BLOCK_RATIO)}), calc(var(${re}) + var(${Hn})))`,jn=(e,n)=>{const t=Object.entries(e);return t.length!==Object.keys(n).length?!1:t.every(([o,r])=>{const s=n[o];return s!==void 0&&s.length===r.length&&s.every((a,m)=>r[m]===a)})},G=(e,n,t,o)=>{P.stopKeepingInView(e);const r=e.querySelector(`[${K}="${n}"]`);if(!(r instanceof HTMLElement))return;const s=t!==null&&r.contains(t)?t:null,a=[{element:r,boundary:r.closest(D.SCROLL_ROOT_SELECTOR)}];s!==null&&a.push({element:s,boundary:r}),P.keepInView(e,()=>r.isConnected?(r.scrollIntoView(P.NEAREST),s?.isConnected!==!0?r:(o(s),s)):null,a)},X=e=>{e.scrollIntoView(P.NEAREST)},Ie=(e,n)=>{const t=e.querySelector(`[${J}="${n}"]`);return t instanceof HTMLElement?(G(e,n,null,X),t.focus({preventScroll:!0}),!0):!1},ue=(e,n)=>{const t=e.querySelector(`[${K}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},ve=(e,n)=>{if(!ue(e,n))return null;const t=[...e.querySelectorAll(`[${J}]`)].map(a=>a.getAttribute(J)),o=t.indexOf(n),r=t[o+1];if(o>=0&&typeof r=="string")return{kind:"panel",panelId:r};const s=t[o-1];return o>0&&typeof s=="string"?{kind:"panel",panelId:s}:{kind:"stage"}},Ee=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&Ie(t,n.panelId)||t.focus({preventScroll:!0}))})},_e=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&Ie(t,n)})},Fn=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(G(o,n,t&&ue(o,n)?r:null,X),!t||r!==null&&r!==s&&r.isConnected)return;const a=o.querySelector(`[${J}="${n}"]`);a instanceof HTMLElement&&a.focus({preventScroll:!0})})},Vn=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r,edits:s}=P.useExplorer(),{maximize:a}=le(),m=t.multiView.columns,g=z(e,E=>E.layout),i=z(e,E=>E.visibleColumns),v=z(e,E=>E.titles),O=z(e,E=>E.layout.maximized!==null||E.splitDragging),[T,A]=c.useState(!1),[x]=c.useState(()=>xe(i)),d=c.useMemo(()=>kn(o),[o]),y=c.useCallback(E=>{e.arrange(Mn(e.getSnapshot().layout,E))},[e]),h=D.useDragDropColumns({initialColumnPanels:x,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:y}),{columnPanels:C,setColumnPanels:L}=h,R=c.useRef(O),N=c.useRef(C);c.useLayoutEffect(()=>{R.current=O,N.current=C},[O,C]);const u=c.useCallback(E=>{const w=n.current;if(w===null)return;const{plan:q,stageBlockSize:H}=fn(w,m);if(Number.isFinite(H)&&H>0&&w.style.setProperty(ce,`${String(H)}px`),R.current&&!E)return;const B=j.replanVisibleColumns(e.getSnapshot().visibleColumns,q);B!==null&&e.setVisibleColumns(B)},[e,n,m]);c.useLayoutEffect(()=>{u(!0),A(!0)},[u]),c.useEffect(()=>{const E=n.current;if(E===null||typeof ResizeObserver>"u")return;let w=null;const q=new ResizeObserver(()=>{w===null&&(w=requestAnimationFrame(()=>{w=null,u(!1)}))}),H=E.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,B=E.querySelector(`[${ae}]`);return H instanceof Element&&q.observe(H),B instanceof Element&&q.observe(B),()=>{q.disconnect(),w!==null&&cancelAnimationFrame(w)}},[n,u]),c.useEffect(()=>{O||u(!1)},[O,u]);const p=c.useMemo(()=>T?Ln(g,{logical:m,visible:i}):xe(i),[T,g,m,i]);c.useLayoutEffect(()=>{jn(N.current,p)||L(p)},[p,L]);const f=c.useMemo(()=>D.sortColumnIds(Object.keys(C)).map(E=>({id:E,key:E,className:"aqmx-multi-column"})),[C]),M=c.useMemo(()=>g.docs.map(E=>{const w=W(g,E);return{id:w,component:Tn,title:ie(v,E),props:{docPath:E,panelId:w},minHeight:Bn,maxHeight:qn}}),[g,v]),_=c.useMemo(()=>Object.fromEntries(g.docs.map(E=>[W(g,E),!g.hidden.has(E)])),[g]),l=g.maximized===null?null:W(g,g.maximized),S=c.useCallback(E=>{const{layout:w}=e.getSnapshot();for(const[q,H]of Y(w)){const B=E[q];if(B===void 0||B!==w.hidden.has(H))continue;const F=e.titleOf(H);if(B){if(!e.setHidden(H,!1))continue;r.announce(o.panelShown(F)),_e(n,q);continue}const V=n.current,de=V===null?null:ve(V,q);e.setHidden(H,!0)&&(r.announce(o.panelHidden(F)),de!==null&&Ee(n,de))}},[e,n,r,o]),b=c.useCallback(E=>{const w=Y(e.getSnapshot().layout).get(E);if(w===void 0)return;const q=()=>{const B=e.titleOf(w),F=n.current,V=F===null?null:ve(F,E);e.close(w)&&(r.announce(o.panelClosed(B)),V!==null&&Ee(n,V))},H=s.unsavedAmong([w]);H.length===0?q():s.askToDiscard(H).then(B=>{B&&q()})},[e,n,r,o,s]),I=c.useCallback(E=>{if(E===null){a(null);return}const w=Y(e.getSnapshot().layout).get(E);w!==void 0&&a(w)},[e,a]);return k.jsx("div",{className:"aqmx-multi-layout","aria-busy":!T,children:k.jsx(D.DragDropLayout,{columns:f,panels:M,columnPanels:C,onColumnPanelsChange:y,panelVisibility:_,onPanelVisibilityChange:S,dragState:h.dragState,dragOverPosition:h.dragOverPosition,originalPanelPosition:h.originalPanelPosition,dragModes:h.dragModes,debugConfig:D.DEFAULT_DEBUG_CONFIG,panelSizes:h.panelSizes,customDrag:h.customDrag,setPanelRef:h.setPanelRef,onDragStart:h.handleDragStart,onDragEnd:h.handleDragEnd,onPlaceholderDragEnter:h.handlePlaceholderDragEnter,onPlaceholderDragLeave:h.handlePlaceholderDragLeave,onDragOverWithInsert:h.handleDragOverWithInsert,onDropWithInsert:h.handleDropWithInsert,onColumnDragLeave:h.handleColumnDragLeave,onPanelMouseDown:h.handleMouseDown,onPanelSizeInfoClick:h.handlePanelSizeInfoClick,onToggleDragMode:h.toggleDragMode,onPanelClose:b,onPanelMaximizeChange:I,maximizedPanel:l,dragHandle:"header",labels:d,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:Dn,renderStageScrollBar:zn})})},te={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},Un=(e,n)=>{const t=n.getBoundingClientRect(),o=[t.left+1,t.left+t.width/2,t.right-1],r=[t.top+1,t.top+t.height/2,t.bottom-1];return o.some(s=>r.some(a=>{const m=n.ownerDocument.elementsFromPoint(s,a),g=m.findIndex(v=>n.contains(v)),i=m.findIndex(v=>e.contains(v));return g!==-1&&i!==-1&&i<g}))},$n=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(te.blockStart,`${String(t.top)}px`),e.style.setProperty(te.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(te.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Gn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:a,announcer:m,edits:g}=P.useExplorer(),i=c.useRef(null),v=c.useRef(null),O=z(e,u=>u.ready),T=z(e,u=>u.layout.docs.length>0),A=z(e,u=>u.visibleColumns),x=c.use(oe.SheetNoticeSlotContext),d=c.useCallback(u=>{const{layout:p}=e.getSnapshot(),f=p.maximized,M=u===null&&f!==null?p.panelIds.get(f):void 0,_=i.current,l=M!==void 0&&_!==null&&ue(_,M);e.maximize(u)&&(u!==null?m.announce(a.panelMaximized(e.titleOf(u))):f!==null&&m.announce(a.panelRestored(e.titleOf(f))),M!==void 0&&Fn(i,M,l))},[e,m,a]),y=c.useCallback((u,p,f,M)=>{if(f===p){e.setPendingHash(u,M);return}const _=g.unsavedAmong([p]);if(_.length>0){g.askToDiscard(_).then(I=>{I&&y(u,p,f,M)});return}const l=e.navigate(p,f);if(l==="navigated"){e.setPendingHash(u,M);return}if(l!=="existing")return;const{layout:S}=e.getSnapshot(),b=S.panelIds.get(f);b!==void 0&&(m.announce(a.panelAlreadyOpen(e.titleOf(f))),S.maximized===null?e.setHidden(f,!1):d(f),e.setPendingHash(b,M),_e(i,b))},[e,m,a,d,g]);c.useLayoutEffect(()=>{if(t===null||x!==null||!ge())return;const u=v.current,p=i.current;if(u===null||p===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return $n(u,p)},[t,x]),c.useEffect(()=>{const u=v.current;if(t===null||u===null)return;const{ownerDocument:p}=u;let f=null;const M=_=>{const l=_.target;l instanceof Element&&(f!==null&&cancelAnimationFrame(f),f=requestAnimationFrame(()=>{f=null,p.activeElement===l&&u.isConnected&&Un(u,l)&&o()}))};return p.addEventListener("focusin",M,!0),()=>{p.removeEventListener("focusin",M,!0),f!==null&&cancelAnimationFrame(f)}},[t,x,o]),c.useImperativeHandle(r,()=>({bringIntoView:u=>{requestAnimationFrame(()=>{const p=i.current,f=e.getSnapshot().layout.panelIds.get(u);p!==null&&f!==void 0&&G(p,f,null,X)})}}),[e]),c.useEffect(()=>{const u=i.current;return()=>{u!==null&&P.stopKeepingInView(u)}},[]);const h=c.useCallback((u,p)=>{const f=i.current;f!==null&&G(f,u,p,X)},[]),C=c.useCallback((u,p,f)=>{const M=i.current;M!==null&&G(M,u,f,_=>P.alignToStart(p,_))},[]),[L]=c.useState(qe),R=c.useMemo(()=>({store:e,Body:n,followLink:y,maximize:d,revealInPanel:h,keepAtStartInPanel:C,focusCarry:L}),[e,n,y,d,h,C,L]),N=c.useMemo(()=>Array.from({length:s.multiView.columns},(u,p)=>D.generateColumnId(p)),[s]);return k.jsxs("section",{ref:i,className:"aqmx-multi-stage",style:Rn,tabIndex:-1,"aria-label":a.multiRegion,"aria-busy":T&&!O,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":A,...P.CONTENT_PANE,children:[k.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[ae]:""}),T?O?k.jsx(Oe,{value:R,children:k.jsx(Vn,{store:e,stageRef:i})}):k.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:N.map(u=>k.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[k.jsx("span",{}),k.jsx("span",{}),k.jsx("span",{})]},u))}):k.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:k.jsx("p",{className:"aqmx-empty-title",children:a.multiEmpty})}),t===null?null:x!==null?He.createPortal(k.jsx("div",{ref:v,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),x):k.jsx("div",{ref:v,popover:ge()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},De=3e3,ze=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},se=(e,n,t)=>{const o=new Set(e),r=n.filter(a=>!o.has(a)),s=r.length>0?r.at(-1):t!==null&&n.includes(t)?t:n.at(-1);return s===void 0?null:s},Yn=(e,n,t)=>{switch(n){case"opened":return e.panelOpened(t);case"shown":return e.panelShown(t);case"closed":return e.panelClosed(t);default:{const o=n;throw new RangeError(`[markdown-explorer] unknown toggle outcome ${JSON.stringify(o)}`)}}},Wn=({location:e})=>{const{config:n,labels:t,announcer:o}=P.useExplorer(),r=cn(e),s=z(r,f=>f.layout.docs),a=z(r,f=>f.layout.maximized),m=z(r,f=>f.layout.markup),g=z(r,f=>f.source),[i,v]=c.useState(()=>({docs:s,latest:se([],s,null)}));i.docs!==s&&v({docs:s,latest:se(i.docs,s,i.latest)});const O=a!==null?a:i.latest,[T,A]=c.useState(!1),x=c.useRef(null),[d,y]=c.useState(0),h=c.useRef(null),C=c.useRef(null);c.useLayoutEffect(()=>{const f=h.current;h.current=null,f!==null&&(r.whenUrlRendered(()=>o.announce(f.announcement)),C.current?.bringIntoView(f.doc))}),c.useEffect(()=>()=>{x.current!==null&&clearTimeout(x.current)},[]);const L=c.useCallback(()=>{x.current!==null&&clearTimeout(x.current),A(!0),x.current=setTimeout(()=>{x.current=null,A(!1)},De)},[]),R=c.useCallback(()=>{x.current!==null&&clearTimeout(x.current),x.current=null,A(!1)},[]),N=c.useCallback(f=>{const M=r.titleOf(f),_=r.toggle(f);_==="rejected"&&L();const l=_==="rejected"?t.panelLimit(n.multiView.maxPanels):Yn(t,_,M);if(_==="shown"){h.current={doc:f,announcement:l},y(S=>S+1);return}r.whenUrlRendered(()=>{o.announce(l),_==="opened"&&C.current?.bringIntoView(f)})},[r,L,o,t,n]),u=c.useMemo(()=>new Set(s),[s]),p=c.useMemo(()=>{const f=ze(s,a);return{href:j.explorerHref(n,{view:"tree",source:g,doc:f,markup:f!==null&&m.has(f)}),target:"tree"}},[n,g,s,a,m]);return k.jsx(oe.ExplorerSplit,{view:"multi",explorer:k.jsx(oe.ExplorerPane,{mode:"multi",sourceId:g,currentPath:O,openPaths:u,onOpenDocument:N,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:p}),content:k.jsx(Gn,{ref:C,store:r,body:dn,limitNotice:T?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:R}),contentCoversPage:a!==null,sheetDismissals:d,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Wn;exports.PANEL_LIMIT_NOTICE_MS=De;exports.latestOpenedDocument=se;exports.treeSwitchDocument=ze;
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { jsx as v, jsxs as A } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback as m, useMemo as w, useEffect as g, useSyncExternalStore as G, useState as j, useRef as q, useLayoutEffect as H } from "react";
|
|
3
|
-
import { useLocation as U } from "react-router";
|
|
4
|
-
import { e as p, c as $ } from "./location-C44b9H1S.js";
|
|
5
|
-
import { u as E, f as D, r as B, F as Y, g as J, h as K, i as Q, D as V, P as W, j as X } from "./index-DR31S_-4.js";
|
|
6
|
-
import { isMaximizeEscape as Z } from "@aiquants/drag-drop-panels";
|
|
7
|
-
import { l as I } from "./dataRoute-D6KiSHIc.js";
|
|
8
|
-
import { E as ee, a as te, b as ne } from "./ExplorerSplit-DGH9bckm.js";
|
|
9
|
-
const re = (t) => {
|
|
10
|
-
const { config: e, labels: n, announcer: r } = E(), a = D(), i = m(() => {
|
|
11
|
-
const s = t.doc !== null ? t.doc : t.folder;
|
|
12
|
-
if (s === null) throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");
|
|
13
|
-
a(p(e, { ...t, maximized: !t.maximized }), "browse");
|
|
14
|
-
const o = I(s);
|
|
15
|
-
r.announce(t.maximized ? n.documentRestored(o) : n.documentMaximized(o));
|
|
16
|
-
}, [e, a, t, r, n]);
|
|
17
|
-
return w(() => ({ maximized: t.maximized, toggle: i }), [t.maximized, i]);
|
|
18
|
-
}, ae = (t, e) => {
|
|
19
|
-
g(() => {
|
|
20
|
-
if (!t) return;
|
|
21
|
-
const n = (r) => {
|
|
22
|
-
Z(r) && (r.preventDefault(), e());
|
|
23
|
-
};
|
|
24
|
-
return window.addEventListener("keydown", n), () => window.removeEventListener("keydown", n);
|
|
25
|
-
}, [t, e]);
|
|
26
|
-
}, se = (t, e) => t.claim !== e.claim || t.readme.status !== e.readme.status ? !1 : t.readme.status === "failed" && e.readme.status === "failed" ? t.readme.failure === e.readme.failure : t.readme.status === "ok" && e.readme.status === "ok" ? t.readme.readme === e.readme.readme : !0, oe = (t, e, n) => {
|
|
27
|
-
let r = null;
|
|
28
|
-
return () => {
|
|
29
|
-
const a = t.version(), i = t.read(e), s = i.status !== "pending";
|
|
30
|
-
if (r !== null && r.version === a && r.tree === i && r.settled === s) return r.state;
|
|
31
|
-
const o = B(t, e, n), u = r !== null && se(r.state, o) ? r.state : o;
|
|
32
|
-
return r = { version: a, tree: i, settled: s, state: u }, u;
|
|
33
|
-
};
|
|
34
|
-
}, ue = (t, e, n) => {
|
|
35
|
-
let r = !0, a = null;
|
|
36
|
-
const i = () => {
|
|
37
|
-
r && n();
|
|
38
|
-
}, s = () => {
|
|
39
|
-
const u = t.read(e);
|
|
40
|
-
u === a || u.status !== "pending" || (a = u, u.then(i, i));
|
|
41
|
-
};
|
|
42
|
-
s();
|
|
43
|
-
const o = t.subscribe(() => {
|
|
44
|
-
s(), n();
|
|
45
|
-
});
|
|
46
|
-
return () => {
|
|
47
|
-
r = !1, o();
|
|
48
|
-
};
|
|
49
|
-
}, ie = () => Y, ce = (t, e) => {
|
|
50
|
-
const { trees: n } = E(), r = w(() => e === null ? null : oe(n, t, e), [n, t, e]), a = m((l) => r === null ? () => {
|
|
51
|
-
} : ue(n, t, l), [r, n, t]), i = m(() => r === null ? null : r(), [r]), s = m(() => r === null ? null : ie(), [r]), o = G(a, i, s), u = o?.claim === !0;
|
|
52
|
-
return g(() => e === null ? void 0 : n.open(t), [n, t, e]), g(() => e === null || !u ? void 0 : n.claimChildren(t, /* @__PURE__ */ new Map([[e, "direct"]])), [n, t, e, u]), o === null ? null : o.readme;
|
|
53
|
-
}, le = /* @__PURE__ */ new Set(), me = Object.freeze({ kind: "loading" }), de = (t, e) => e.status === "loading" ? me : e.status === "failed" ? { kind: "failure", folder: t, failure: e.failure, onRetry: e.retry } : { kind: "no-readme", folder: t }, Se = ({ location: t }) => {
|
|
54
|
-
const { config: e } = E(), n = D(), { hash: r } = U(), { source: a, doc: i, folder: s, overrides: o, markup: u, maximized: l } = t, [h, R] = j(ee), M = w(() => ({ gathered: h, onGatheredChange: R }), [h]), f = ce(a, s), c = f === null ? i : f.status === "ok" ? f.readme : null, S = w(() => s === null || f === null ? J : de(s, f), [s, f]), x = l && (c !== null || S.kind === "loading"), N = m((d) => n(p(e, { view: "tree", source: a, doc: d, overrides: o }), "browse"), [n, e, a, o]), P = m((d) => n(p(e, { view: "tree", source: a, folder: d, overrides: o }), "browse"), [n, e, a, o]), T = m((d) => n(p(e, { view: "tree", source: d, doc: i, folder: s, overrides: o, markup: u, maximized: l }), "switch-source"), [n, e, i, s, o, u, l]), F = m((d) => n(`${p(e, { view: "tree", source: d, doc: i, folder: s, overrides: o, markup: u, maximized: l })}${r}`, "browse"), [n, e, i, s, o, u, l, r]), L = m(
|
|
55
|
-
(d) => {
|
|
56
|
-
const O = $(e, d);
|
|
57
|
-
n(p(e, { view: "multi", source: a, docs: O, markup: u && c !== null && O.includes(c) ? [c] : [] }), "switch-view");
|
|
58
|
-
},
|
|
59
|
-
[n, e, a, c, u]
|
|
60
|
-
), C = w(() => ({ href: p(e, c === null ? { view: "multi", source: a } : { view: "multi", source: a, docs: [c], markup: u ? [c] : [] }), target: "multi" }), [e, a, c, u]), b = q(l);
|
|
61
|
-
H(() => {
|
|
62
|
-
b.current = l;
|
|
63
|
-
}, [l]);
|
|
64
|
-
const z = m(() => b.current, []), _ = w(() => ({ kind: "page", view: "tree", overrides: o, embed: {}, maximized: z }), [o, z]), y = K(t), k = re(t);
|
|
65
|
-
return ae(x, k.toggle), /* @__PURE__ */ v(
|
|
66
|
-
te,
|
|
67
|
-
{
|
|
68
|
-
view: "tree",
|
|
69
|
-
contentCoversPage: x,
|
|
70
|
-
explorer: /* @__PURE__ */ v(
|
|
71
|
-
ne,
|
|
72
|
-
{
|
|
73
|
-
mode: "tree",
|
|
74
|
-
sourceId: a,
|
|
75
|
-
currentPath: s === null ? i : s,
|
|
76
|
-
openPaths: le,
|
|
77
|
-
onOpenDocument: N,
|
|
78
|
-
onOpenFolder: P,
|
|
79
|
-
currentFolder: s !== null,
|
|
80
|
-
onSourceChange: T,
|
|
81
|
-
onRevealSource: F,
|
|
82
|
-
viewSwitch: C,
|
|
83
|
-
tray: M,
|
|
84
|
-
onOpenSelection: L
|
|
85
|
-
}
|
|
86
|
-
),
|
|
87
|
-
content: /* @__PURE__ */ A("div", { className: "aqmx-document-column aqmx-tree-document", "data-aqmx-maximized": x ? "true" : "false", ...Q, children: [
|
|
88
|
-
c === null ? null : /* @__PURE__ */ v(V, { path: c, placement: W, markup: y, maximize: k }),
|
|
89
|
-
/* @__PURE__ */ v(X, { path: c, absence: S, markup: u, variant: _ })
|
|
90
|
-
] })
|
|
91
|
-
}
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
export {
|
|
95
|
-
Se as TreeLayout
|
|
96
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react/jsx-runtime"),s=require("react"),L=require("react-router"),x=require("./location-hGLhCCg4.cjs"),i=require("./index-BDCbvHDs.cjs"),F=require("@aiquants/drag-drop-panels"),H=require("./dataRoute-DwYtgyt6.cjs"),g=require("./ExplorerSplit-D325YGEf.cjs"),_=t=>{const{config:e,labels:n,announcer:r}=i.useExplorer(),a=i.useExplorerNavigate(),c=s.useCallback(()=>{const o=t.doc!==null?t.doc:t.folder;if(o===null)throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");a(x.explorerHref(e,{...t,maximized:!t.maximized}),"browse");const u=H.lastPathSegment(o);r.announce(t.maximized?n.documentRestored(u):n.documentMaximized(u))},[e,a,t,r,n]);return s.useMemo(()=>({maximized:t.maximized,toggle:c}),[t.maximized,c])},j=(t,e)=>{s.useEffect(()=>{if(!t)return;const n=r=>{F.isMaximizeEscape(r)&&(r.preventDefault(),e())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t,e])},A=(t,e)=>t.claim!==e.claim||t.readme.status!==e.readme.status?!1:t.readme.status==="failed"&&e.readme.status==="failed"?t.readme.failure===e.readme.failure:t.readme.status==="ok"&&e.readme.status==="ok"?t.readme.readme===e.readme.readme:!0,G=(t,e,n)=>{let r=null;return()=>{const a=t.version(),c=t.read(e),o=c.status!=="pending";if(r!==null&&r.version===a&&r.tree===c&&r.settled===o)return r.state;const u=i.readFolderReadme(t,e,n),l=r!==null&&A(r.state,u)?r.state:u;return r={version:a,tree:c,settled:o,state:l},l}},U=(t,e,n)=>{let r=!0,a=null;const c=()=>{r&&n()},o=()=>{const l=t.read(e);l===a||l.status!=="pending"||(a=l,l.then(c,c))};o();const u=t.subscribe(()=>{o(),n()});return()=>{r=!1,u()}},B=()=>i.FOLDER_README_LOADING,Y=(t,e)=>{const{trees:n}=i.useExplorer(),r=s.useMemo(()=>e===null?null:G(n,t,e),[n,t,e]),a=s.useCallback(d=>r===null?()=>{}:U(n,t,d),[r,n,t]),c=s.useCallback(()=>r===null?null:r(),[r]),o=s.useCallback(()=>r===null?null:B(),[r]),u=s.useSyncExternalStore(a,c,o),l=u?.claim===!0;return s.useEffect(()=>e===null?void 0:n.open(t),[n,t,e]),s.useEffect(()=>e===null||!l?void 0:n.claimChildren(t,new Map([[e,"direct"]])),[n,t,e,l]),u===null?null:u.readme},J=new Set,K=Object.freeze({kind:"loading"}),Q=(t,e)=>e.status==="loading"?K:e.status==="failed"?{kind:"failure",folder:t,failure:e.failure,onRetry:e.retry}:{kind:"no-readme",folder:t},V=({location:t})=>{const{config:e}=i.useExplorer(),n=i.useExplorerNavigate(),{hash:r}=L.useLocation(),{source:a,doc:c,folder:o,overrides:u,markup:l,maximized:d}=t,[E,M]=s.useState(g.EMPTY_SELECTION),C=s.useMemo(()=>({gathered:E,onGatheredChange:M}),[E]),f=Y(a,o),m=f===null?c:f.status==="ok"?f.readme:null,b=s.useMemo(()=>o===null||f===null?i.NO_DOCUMENT:Q(o,f),[o,f]),v=d&&(m!==null||b.kind==="loading"),O=s.useCallback(p=>n(x.explorerHref(e,{view:"tree",source:a,doc:p,overrides:u}),"browse"),[n,e,a,u]),R=s.useCallback(p=>n(x.explorerHref(e,{view:"tree",source:a,folder:p,overrides:u}),"browse"),[n,e,a,u]),D=s.useCallback(p=>n(x.explorerHref(e,{view:"tree",source:p,doc:c,folder:o,overrides:u,markup:l,maximized:d}),"switch-source"),[n,e,c,o,u,l,d]),N=s.useCallback(p=>n(`${x.explorerHref(e,{view:"tree",source:p,doc:c,folder:o,overrides:u,markup:l,maximized:d})}${r}`,"browse"),[n,e,c,o,u,l,d,r]),P=s.useCallback(p=>{const z=x.canonicalMultiDocuments(e,p);n(x.explorerHref(e,{view:"multi",source:a,docs:z,markup:l&&m!==null&&z.includes(m)?[m]:[]}),"switch-view")},[n,e,a,m,l]),T=s.useMemo(()=>({href:x.explorerHref(e,m===null?{view:"multi",source:a}:{view:"multi",source:a,docs:[m],markup:l?[m]:[]}),target:"multi"}),[e,a,m,l]),k=s.useRef(d);s.useLayoutEffect(()=>{k.current=d},[d]);const h=s.useCallback(()=>k.current,[]),q=s.useMemo(()=>({kind:"page",view:"tree",overrides:u,embed:{},maximized:h}),[u,h]),y=i.usePageMarkupToggle(t),S=_(t);return j(v,S.toggle),w.jsx(g.ExplorerSplit,{view:"tree",contentCoversPage:v,explorer:w.jsx(g.ExplorerPane,{mode:"tree",sourceId:a,currentPath:o===null?c:o,openPaths:J,onOpenDocument:O,onOpenFolder:R,currentFolder:o!==null,onSourceChange:D,onRevealSource:N,viewSwitch:T,tray:C,onOpenSelection:P}),content:w.jsxs("div",{className:"aqmx-document-column aqmx-tree-document","data-aqmx-maximized":v?"true":"false",...i.CONTENT_PANE,children:[m===null?null:w.jsx(i.DocumentRefreshBar,{path:m,placement:i.PAGE_DOCUMENT_REFRESH,markup:y,maximize:S}),w.jsx(i.DocumentPane,{path:m,absence:b,markup:l,variant:q})]})})};exports.TreeLayout=V;
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
const Ae = 4096;
|
|
2
|
-
const N = 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
|
-
]), P = /[\u0000-\u001f\u007f]/u, L = /\p{Cs}/u, _e = (e) => {
|
|
61
|
-
const t = e.split("/").filter((n) => n !== "").at(-1);
|
|
62
|
-
return t === void 0 ? e : t;
|
|
63
|
-
}, R = (e) => e.length > 0 && e.length <= 4096 && !L.test(e) && !P.test(e) && !e.includes("\\"), h = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), D = /(?:%[0-9A-Fa-f]{2})+/gu, $ = new TextDecoder("utf-8"), j = /[/\\]/u, I = (e) => e.replace(
|
|
64
|
-
D,
|
|
65
|
-
(t) => $.decode(
|
|
66
|
-
Uint8Array.from(
|
|
67
|
-
t.slice(1).split("%").map((n) => Number.parseInt(n, 16))
|
|
68
|
-
)
|
|
69
|
-
)
|
|
70
|
-
), z = (e) => {
|
|
71
|
-
const t = [e];
|
|
72
|
-
let n = e;
|
|
73
|
-
for (let r = 0; r < 3 && n.includes("%"); r += 1) {
|
|
74
|
-
const s = I(n);
|
|
75
|
-
if (s === n) break;
|
|
76
|
-
t.push(s), n = s;
|
|
77
|
-
}
|
|
78
|
-
return t.map(h);
|
|
79
|
-
}, C = (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 = h(e).split("*").map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
83
|
-
return new RegExp(`^${t}$`, "su");
|
|
84
|
-
}, m = (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(C), n = (s) => s !== "" && t.some((i) => i.test(s)), r = (s) => s !== "" && z(s).some((i) => n(i) || i.split(j).some(n));
|
|
87
|
-
return {
|
|
88
|
-
deniesPath: (s) => s.split("/").some(r),
|
|
89
|
-
deniesName: r
|
|
90
|
-
};
|
|
91
|
-
}, X = m(N), U = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), Oe = (e) => e === void 0 ? X : e === !1 ? U : m(e), xe = (e, t) => m(e).deniesPath(t), b = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), F = Object.freeze(["file", "directory"]), H = Object.freeze(["video", "audio", "pdf"]), V = Object.freeze(["raster", "svg"]), M = Object.freeze(["csv", "tsv", "workbook"]), K = Object.freeze(["csv", "tsv"]), Y = Object.freeze(["info", "warning", "danger"]), G = Object.freeze(["markdown", "text", "image", "media", "spreadsheet", "file", "failure"]), y = Object.freeze({ min: 1, max: 6 }), Te = 1e4, u = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), Se = Object.freeze(["http:", "https:", "mailto:"]), A = 1024, W = /^[a-z0-9-]{1,64}$/u, J = "https://relative.invalid/", g = 64, l = (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, q = (e) => l(b, e), B = (e) => l(F, e), Q = (e) => l(H, e), Z = (e) => l(V, e), ee = (e) => l(M, e), we = (e) => l(Y, e), te = (e) => l(G, e), _ = (e) => typeof e == "string" && W.test(e), ke = (e, t) => {
|
|
92
|
-
if (typeof e != "string") return !1;
|
|
93
|
-
try {
|
|
94
|
-
return t.includes(new URL(e, J).protocol);
|
|
95
|
-
} catch {
|
|
96
|
-
return !1;
|
|
97
|
-
}
|
|
98
|
-
}, E = (e) => {
|
|
99
|
-
if (e === null || typeof e != "object") return "a failure must be an object";
|
|
100
|
-
const { reason: t, code: n } = e;
|
|
101
|
-
return q(t) ? n !== void 0 && !_(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${o(n)}` : null : `unknown failure reason ${o(t)}`;
|
|
102
|
-
}, ne = (e) => {
|
|
103
|
-
if (e === null || typeof e != "object") return "an entry must be an object";
|
|
104
|
-
const { name: t, path: n, type: r, mimeType: s, modifiedAt: i, children: a, lazy: c } = e;
|
|
105
|
-
return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !R(n) ? "an entry needs an acceptable path" : B(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && !Number.isSafeInteger(i) ? `an entry modifiedAt must be a safe integer of epoch milliseconds; got ${o(i)}` : c !== void 0 && typeof c != "boolean" ? "an entry lazy flag must be a boolean" : a !== void 0 && !Array.isArray(a) ? "entry children must be an array" : r === "file" && (a !== void 0 || c === !0) ? "a file entry cannot have children or be lazy" : c === !0 && Array.isArray(a) && a.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${o(r)}`;
|
|
106
|
-
}, O = (e) => {
|
|
107
|
-
if (ne(e) !== null) return !1;
|
|
108
|
-
const { children: t } = e;
|
|
109
|
-
return t === void 0 || t.every(O);
|
|
110
|
-
}, re = (e) => {
|
|
111
|
-
if (e === null || typeof e != "object") return !1;
|
|
112
|
-
const { status: t, entries: n, failure: r } = e;
|
|
113
|
-
return t === "ok" ? Array.isArray(n) && n.every(O) : t === "error" && E(r) === null;
|
|
114
|
-
}, ve = (e) => {
|
|
115
|
-
if (e === null || typeof e != "object") return !1;
|
|
116
|
-
const { status: t, ancestors: n, failure: r } = e;
|
|
117
|
-
return t === "ok" ? n === null || x(n) : t === "error" && E(r) === null;
|
|
118
|
-
}, x = (e) => Array.isArray(e) && e.every((t) => typeof t == "string" && R(t)) && new Set(e).size === e.length, Ne = (e) => {
|
|
119
|
-
if (e === null || typeof e != "object") return !1;
|
|
120
|
-
const { status: t, source: n, ancestors: r, failure: s } = e;
|
|
121
|
-
return t === "ok" ? n === null && r === null || typeof n == "string" && n !== "" && x(r) : t === "error" && E(s) === null;
|
|
122
|
-
}, Pe = (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 : re(e);
|
|
126
|
-
}, T = (e) => {
|
|
127
|
-
if (e === null || typeof e != "object") return "a heading must be an object";
|
|
128
|
-
const { text: t, depth: n, id: r } = e;
|
|
129
|
-
return typeof t != "string" || typeof r != "string" ? "a heading needs text and id strings" : typeof n != "number" || !Number.isInteger(n) || n < y.min || n > y.max ? `a heading depth must be an integer in 1..6; got ${String(n)}` : null;
|
|
130
|
-
}, se = (e) => {
|
|
131
|
-
if (e === null || typeof e != "object") return "a document must be an object";
|
|
132
|
-
const t = e, { kind: n } = t;
|
|
133
|
-
if (!te(n)) return `unknown document kind ${o(n)}`;
|
|
134
|
-
if (n === "failure") return E(t.failure);
|
|
135
|
-
if (typeof t.name != "string") return "a document needs a name string";
|
|
136
|
-
switch (n) {
|
|
137
|
-
case "markdown": {
|
|
138
|
-
const { htmlContent: r, headings: s } = t;
|
|
139
|
-
if (typeof r != "string" || !Array.isArray(s)) return "a markdown document needs htmlContent and headings";
|
|
140
|
-
for (const i of s) {
|
|
141
|
-
const a = T(i);
|
|
142
|
-
if (a !== null) return a;
|
|
143
|
-
}
|
|
144
|
-
return ie(t.edit);
|
|
145
|
-
}
|
|
146
|
-
case "text":
|
|
147
|
-
return typeof t.text != "string" || typeof t.truncated != "boolean" ? "a text document needs text and truncated" : u(t.url) ? null : "a text document needs a root-relative url";
|
|
148
|
-
case "image":
|
|
149
|
-
return u(t.url) ? Z(t.imageType) ? null : `unknown image type ${o(t.imageType)}` : "an image document needs a root-relative url";
|
|
150
|
-
case "media":
|
|
151
|
-
return u(t.url) ? Q(t.mediaType) ? null : `unknown media type ${o(t.mediaType)}` : "a media document needs a root-relative url";
|
|
152
|
-
case "spreadsheet":
|
|
153
|
-
return u(t.url) ? le(t) : "a spreadsheet document needs a root-relative url";
|
|
154
|
-
case "file":
|
|
155
|
-
return u(t.url) ? null : "a file document needs a root-relative url";
|
|
156
|
-
}
|
|
157
|
-
}, oe = (e) => se(e) === null, Le = (e) => oe(e) && (e.kind === "text" || e.kind === "failure"), ie = (e) => {
|
|
158
|
-
if (e === null) return null;
|
|
159
|
-
if (typeof e != "object") return "a markdown document's edit must be null or an object";
|
|
160
|
-
const { kind: t, href: n } = e;
|
|
161
|
-
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)}` : S(n);
|
|
162
|
-
}, ae = (e) => {
|
|
163
|
-
if (e === null) return null;
|
|
164
|
-
if (typeof e != "object") return "a spreadsheet document's edit must be null or an object";
|
|
165
|
-
const { kind: t, href: n } = e;
|
|
166
|
-
return t !== "external" ? `a spreadsheet document's edit must be external; got ${o(t)}` : S(n);
|
|
167
|
-
}, le = (e) => {
|
|
168
|
-
if (!ee(e.format)) return `unknown spreadsheet format ${o(e.format)}`;
|
|
169
|
-
const { firstSheetText: t } = e;
|
|
170
|
-
return t !== null && !l(K, t) ? `a spreadsheet document's firstSheetText must be csv, tsv or null; got ${o(t)}` : t !== null && e.format !== "workbook" ? "only a workbook's spreadsheet document names a firstSheetText" : ae(e.edit);
|
|
171
|
-
}, S = (e) => ce(e) ? null : `an external edit needs an absolute https: href; got ${o(e)}`, ce = (e) => {
|
|
172
|
-
if (typeof e != "string") return !1;
|
|
173
|
-
try {
|
|
174
|
-
return new URL(e).protocol === "https:";
|
|
175
|
-
} catch {
|
|
176
|
-
return !1;
|
|
177
|
-
}
|
|
178
|
-
}, d = (e) => typeof e == "string" && e.length > 0 && e.length <= A, ue = (e) => u(e.href) ? null : `a grant needs a root-relative href; got ${o(e.href)}`, fe = (e) => {
|
|
179
|
-
if (e === null || typeof e != "object") return "a revision must be an object";
|
|
180
|
-
const { id: t, modifiedAt: n, size: r, author: s, kept: i, current: a } = e;
|
|
181
|
-
return d(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 ${A} characters; got ${o(t)}`;
|
|
182
|
-
}, f = (e, t) => {
|
|
183
|
-
if (e === null || typeof e != "object") return "an answer must be an object";
|
|
184
|
-
const n = e, { kind: r } = n;
|
|
185
|
-
if (r === "failure") return E(n.failure);
|
|
186
|
-
if (typeof r != "string" || !t.includes(r)) return `unexpected answer kind ${o(r)}`;
|
|
187
|
-
switch (r) {
|
|
188
|
-
case "grant":
|
|
189
|
-
return ue(n);
|
|
190
|
-
case "edit":
|
|
191
|
-
return typeof n.text != "string" || typeof n.history != "boolean" ? "an edit source needs text and history" : d(n.version) ? null : `an edit source needs a version; got ${o(n.version)}`;
|
|
192
|
-
case "draft":
|
|
193
|
-
return typeof n.text == "string" ? null : "a draft source needs text";
|
|
194
|
-
case "saved":
|
|
195
|
-
return d(n.version) ? null : `a saved answer needs a version; got ${o(n.version)}`;
|
|
196
|
-
case "conflict":
|
|
197
|
-
return typeof n.text != "string" ? "a conflict needs the current text" : d(n.version) ? null : `a conflict needs the current version; got ${o(n.version)}`;
|
|
198
|
-
case "preview": {
|
|
199
|
-
const { htmlContent: s, headings: i } = n;
|
|
200
|
-
if (typeof s != "string" || !Array.isArray(i)) return "a preview needs htmlContent and headings";
|
|
201
|
-
for (const a of i) {
|
|
202
|
-
const c = T(a);
|
|
203
|
-
if (c !== null) return c;
|
|
204
|
-
}
|
|
205
|
-
return null;
|
|
206
|
-
}
|
|
207
|
-
case "revisions": {
|
|
208
|
-
if (!Array.isArray(n.revisions)) return "revisions need an array";
|
|
209
|
-
for (const s of n.revisions) {
|
|
210
|
-
const i = fe(s);
|
|
211
|
-
if (i !== null) return i;
|
|
212
|
-
}
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
case "revision":
|
|
216
|
-
return typeof n.text != "string" ? "a revision answer needs text" : d(n.id) ? null : `a revision answer needs an id; got ${o(n.id)}`;
|
|
217
|
-
default:
|
|
218
|
-
return `unexpected answer kind ${o(r)}`;
|
|
219
|
-
}
|
|
220
|
-
}, de = Object.freeze(["edit", "draft", "grant"]), pe = Object.freeze(["saved", "conflict", "grant"]), w = Object.freeze(["preview"]), Ee = Object.freeze(["revisions"]), me = Object.freeze(["revision"]), De = (e) => f(e, de) === null, $e = (e) => f(e, pe) === null, je = (e) => f(e, w) === null, Ie = (e) => f(e, Ee) === null, ze = (e) => f(e, me) === null, Ce = (e) => e !== null && typeof e == "object" && e.kind === "unavailable" ? null : f(e, w), Xe = (e, t) => ({ kind: "failure", failure: ye(e, t) }), ye = (e, t) => _(t) ? { reason: e, code: t } : { reason: e }, ge = Object.freeze(["tree", "children", "ancestors", "reveal", "document", "text", "edit", "save", "preview", "revisions", "revision", "refresh", "asset", "link-card"]), p = Object.freeze({ source: "source", path: "path", version: "v", base: "base", revision: "revision", display: "as" }), Re = "asset", he = "link-card", Ue = (e, t, n) => {
|
|
221
|
-
const r = `${e}/${Re}?${p.path}=${encodeURIComponent(t)}`;
|
|
222
|
-
return n === null ? r : `${r}&${p.version}=${encodeURIComponent(n)}`;
|
|
223
|
-
}, k = "text", v = "workbook", Fe = (e) => {
|
|
224
|
-
if (!e.includes("?")) throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);
|
|
225
|
-
return `${e}&${p.display}=${k}`;
|
|
226
|
-
}, He = (e) => {
|
|
227
|
-
if (!e.includes("?")) throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);
|
|
228
|
-
return `${e}&${p.display}=${v}`;
|
|
229
|
-
}, Ve = (e) => {
|
|
230
|
-
const t = e.getAll(p.display);
|
|
231
|
-
return t.length === 0 ? "file" : t.length !== 1 ? null : t[0] === k ? "text" : t[0] === v ? "workbook" : null;
|
|
232
|
-
}, Me = (e) => `${e}/${he}`, Ke = "X-Markdown-Explorer-Scope", Ye = "X-Markdown-Explorer", Ge = "refresh", We = "edit", Je = "text/markdown", qe = (e) => ge.includes(e), be = Object.freeze({
|
|
233
|
-
invalid: 400,
|
|
234
|
-
unauthorized: 401,
|
|
235
|
-
forbidden: 403,
|
|
236
|
-
"not-found": 404,
|
|
237
|
-
"too-large": 413,
|
|
238
|
-
"not-configured": 500,
|
|
239
|
-
unsupported: 500,
|
|
240
|
-
failed: 500
|
|
241
|
-
}), Be = (e) => {
|
|
242
|
-
const [t, ...n] = b.filter((r) => be[r] === e);
|
|
243
|
-
return t !== void 0 && n.length === 0 ? t : "failed";
|
|
244
|
-
};
|
|
245
|
-
export {
|
|
246
|
-
Ke as A,
|
|
247
|
-
p as B,
|
|
248
|
-
Xe as C,
|
|
249
|
-
Ve as D,
|
|
250
|
-
Te as E,
|
|
251
|
-
Je as F,
|
|
252
|
-
N as G,
|
|
253
|
-
xe as H,
|
|
254
|
-
Fe as I,
|
|
255
|
-
He as J,
|
|
256
|
-
Be as K,
|
|
257
|
-
E as L,
|
|
258
|
-
Ae as M,
|
|
259
|
-
Le as N,
|
|
260
|
-
Ne as O,
|
|
261
|
-
ve as P,
|
|
262
|
-
re as Q,
|
|
263
|
-
Pe as R,
|
|
264
|
-
ze as S,
|
|
265
|
-
Ie as T,
|
|
266
|
-
je as U,
|
|
267
|
-
$e as V,
|
|
268
|
-
De as W,
|
|
269
|
-
oe as X,
|
|
270
|
-
A as Y,
|
|
271
|
-
b as Z,
|
|
272
|
-
Me as a,
|
|
273
|
-
q as b,
|
|
274
|
-
_ as c,
|
|
275
|
-
Ce as d,
|
|
276
|
-
Ue as e,
|
|
277
|
-
ye as f,
|
|
278
|
-
we as g,
|
|
279
|
-
ke as h,
|
|
280
|
-
R as i,
|
|
281
|
-
Q as j,
|
|
282
|
-
Z as k,
|
|
283
|
-
_e as l,
|
|
284
|
-
se as m,
|
|
285
|
-
d as n,
|
|
286
|
-
T as o,
|
|
287
|
-
u as p,
|
|
288
|
-
ne as q,
|
|
289
|
-
fe as r,
|
|
290
|
-
le as s,
|
|
291
|
-
Se as t,
|
|
292
|
-
Oe as u,
|
|
293
|
-
qe as v,
|
|
294
|
-
be as w,
|
|
295
|
-
Ye as x,
|
|
296
|
-
Ge as y,
|
|
297
|
-
We as z
|
|
298
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
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"]),F=/[\u0000-\u001f\u007f]/u,V=/\p{Cs}/u,M=e=>{const t=e.split("/").filter(r=>r!=="").at(-1);return t===void 0?e:t},R=e=>e.length>0&&e.length<=4096&&!V.test(e)&&!F.test(e)&&!e.includes("\\"),x=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),K=/(?:%[0-9A-Fa-f]{2})+/gu,G=new TextDecoder("utf-8"),Y=/[/\\]/u,W=e=>e.replace(K,t=>G.decode(Uint8Array.from(t.slice(1).split("%").map(r=>Number.parseInt(r,16))))),J=e=>{const t=[e];let r=e;for(let n=0;n<3&&r.includes("%");n+=1){const o=W(r);if(o===r)break;t.push(o),r=o}return t.map(x)},q=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(r=>r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"su")},m=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const t=e.map(q),r=o=>o!==""&&t.some(i=>i.test(o)),n=o=>o!==""&&J(o).some(i=>r(i)||i.split(Y).some(r));return{deniesPath:o=>o.split("/").some(n),deniesName:n}},B=m(b),Q=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),Z=e=>e===void 0?B:e===!1?Q:m(e),ee=(e,t)=>m(e).deniesPath(t),y=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),te=Object.freeze(["file","directory"]),re=Object.freeze(["video","audio","pdf"]),ne=Object.freeze(["raster","svg"]),oe=Object.freeze(["csv","tsv","workbook"]),se=Object.freeze(["csv","tsv"]),ie=Object.freeze(["info","warning","danger"]),ae=Object.freeze(["markdown","text","image","media","spreadsheet","file","failure"]),O=Object.freeze({min:1,max:6}),le=1e4,u=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),ce=Object.freeze(["http:","https:","mailto:"]),_=1024,ue=/^[a-z0-9-]{1,64}$/u,fe="https://relative.invalid/",h=64,l=(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=>l(y,e),de=e=>l(te,e),P=e=>l(re,e),S=e=>l(ne,e),Ee=e=>l(oe,e),pe=e=>l(ie,e),Re=e=>l(ae,e),g=e=>typeof e=="string"&&ue.test(e),me=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,fe).protocol)}catch{return!1}},E=e=>{if(e===null||typeof e!="object")return"a failure must be an object";const{reason:t,code:r}=e;return T(t)?r!==void 0&&!g(r)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${s(r)}`:null:`unknown failure reason ${s(t)}`},L=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:t,path:r,type:n,mimeType:o,modifiedAt:i,children:a,lazy:c}=e;return typeof t!="string"||t===""?"an entry needs a non-empty name":typeof r!="string"||!R(r)?"an entry needs an acceptable path":de(n)?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)}`:c!==void 0&&typeof c!="boolean"?"an entry lazy flag must be a boolean":a!==void 0&&!Array.isArray(a)?"entry children must be an array":n==="file"&&(a!==void 0||c===!0)?"a file entry cannot have children or be lazy":c===!0&&Array.isArray(a)&&a.length>0?"a lazy directory must not list children":null:`an entry type must be "file" or "directory"; got ${s(n)}`},w=e=>{if(L(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(w)},N=e=>{if(e===null||typeof e!="object")return!1;const{status:t,entries:r,failure:n}=e;return t==="ok"?Array.isArray(r)&&r.every(w):t==="error"&&E(n)===null},ye=e=>{if(e===null||typeof e!="object")return!1;const{status:t,ancestors:r,failure:n}=e;return t==="ok"?r===null||v(r):t==="error"&&E(n)===null},v=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&R(t))&&new Set(e).size===e.length,_e=e=>{if(e===null||typeof e!="object")return!1;const{status:t,source:r,ancestors:n,failure:o}=e;return t==="ok"?r===null&&n===null||typeof r=="string"&&r!==""&&v(n):t==="error"&&E(o)===null},ge=e=>{if(e===null||typeof e!="object")return!1;const{status:t,loadedAt:r}=e;return t==="ok"&&!(Number.isSafeInteger(r)&&r>=0)?!1:N(e)},A=e=>{if(e===null||typeof e!="object")return"a heading must be an object";const{text:t,depth:r,id:n}=e;return typeof t!="string"||typeof n!="string"?"a heading needs text and id strings":typeof r!="number"||!Number.isInteger(r)||r<O.min||r>O.max?`a heading depth must be an integer in 1..6; got ${String(r)}`:null},D=e=>{if(e===null||typeof e!="object")return"a document must be an object";const t=e,{kind:r}=t;if(!Re(r))return`unknown document kind ${s(r)}`;if(r==="failure")return E(t.failure);if(typeof t.name!="string")return"a document needs a name string";switch(r){case"markdown":{const{htmlContent:n,headings:o}=t;if(typeof n!="string"||!Array.isArray(o))return"a markdown document needs htmlContent and headings";for(const i of o){const a=A(i);if(a!==null)return a}return Oe(t.edit)}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)?S(t.imageType)?null:`unknown image type ${s(t.imageType)}`:"an image document needs a root-relative url";case"media":return u(t.url)?P(t.mediaType)?null:`unknown media type ${s(t.mediaType)}`:"a media document needs a root-relative url";case"spreadsheet":return u(t.url)?I(t):"a spreadsheet document needs a root-relative url";case"file":return u(t.url)?null:"a file document needs a root-relative url"}},k=e=>D(e)===null,Ae=e=>k(e)&&(e.kind==="text"||e.kind==="failure"),Oe=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:r}=e;return t==="inline"?r===void 0?null:"an inline edit carries no href":t==="draft"?r===void 0?null:"a draft edit carries no href":t!=="external"?`unknown edit kind ${s(t)}`:$(r)},he=e=>{if(e===null)return null;if(typeof e!="object")return"a spreadsheet document's edit must be null or an object";const{kind:t,href:r}=e;return t!=="external"?`a spreadsheet document's edit must be external; got ${s(t)}`:$(r)},I=e=>{if(!Ee(e.format))return`unknown spreadsheet format ${s(e.format)}`;const{firstSheetText:t}=e;return t!==null&&!l(se,t)?`a spreadsheet document's firstSheetText must be csv, tsv or null; got ${s(t)}`:t!==null&&e.format!=="workbook"?"only a workbook's spreadsheet document names a firstSheetText":he(e.edit)},$=e=>be(e)?null:`an external edit needs an absolute https: href; got ${s(e)}`,be=e=>{if(typeof e!="string")return!1;try{return new URL(e).protocol==="https:"}catch{return!1}},f=e=>typeof e=="string"&&e.length>0&&e.length<=_,xe=e=>u(e.href)?null:`a grant needs a root-relative href; got ${s(e.href)}`,j=e=>{if(e===null||typeof e!="object")return"a revision must be an object";const{id:t,modifiedAt:r,size:n,author:o,kept:i,current:a}=e;return f(t)?r!==null&&(typeof r!="string"||Number.isNaN(Date.parse(r)))?`a revision's modifiedAt must be a date-time string or null; got ${s(r)}`:typeof n!="number"||!Number.isSafeInteger(n)||n<0?`a revision's size must be a non-negative integer; got ${s(n)}`: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)}`},p=(e,t)=>{if(e===null||typeof e!="object")return"an answer must be an object";const r=e,{kind:n}=r;if(n==="failure")return E(r.failure);if(typeof n!="string"||!t.includes(n))return`unexpected answer kind ${s(n)}`;switch(n){case"grant":return xe(r);case"edit":return typeof r.text!="string"||typeof r.history!="boolean"?"an edit source needs text and history":f(r.version)?null:`an edit source needs a version; got ${s(r.version)}`;case"draft":return typeof r.text=="string"?null:"a draft source needs text";case"saved":return f(r.version)?null:`a saved answer needs a version; got ${s(r.version)}`;case"conflict":return typeof r.text!="string"?"a conflict needs the current text":f(r.version)?null:`a conflict needs the current version; got ${s(r.version)}`;case"preview":{const{htmlContent:o,headings:i}=r;if(typeof o!="string"||!Array.isArray(i))return"a preview needs htmlContent and headings";for(const a of i){const c=A(a);if(c!==null)return c}return null}case"revisions":{if(!Array.isArray(r.revisions))return"revisions need an array";for(const o of r.revisions){const i=j(o);if(i!==null)return i}return null}case"revision":return typeof r.text!="string"?"a revision answer needs text":f(r.id)?null:`a revision answer needs an id; got ${s(r.id)}`;default:return`unexpected answer kind ${s(n)}`}},Te=Object.freeze(["edit","draft","grant"]),Pe=Object.freeze(["saved","conflict","grant"]),X=Object.freeze(["preview"]),Se=Object.freeze(["revisions"]),Le=Object.freeze(["revision"]),we=e=>p(e,Te)===null,Ne=e=>p(e,Pe)===null,ve=e=>p(e,X)===null,De=e=>p(e,Se)===null,ke=e=>p(e,Le)===null,Ie=e=>e!==null&&typeof e=="object"&&e.kind==="unavailable"?null:p(e,X),$e=(e,t)=>({kind:"failure",failure:C(e,t)}),C=(e,t)=>g(t)?{reason:e,code:t}:{reason:e},je=Object.freeze(["tree","children","ancestors","reveal","document","text","edit","save","preview","revisions","revision","refresh","asset","link-card"]),d=Object.freeze({source:"source",path:"path",version:"v",base:"base",revision:"revision",display:"as"}),Xe="asset",Ce="link-card",Ue=(e,t,r)=>{const n=`${e}/${Xe}?${d.path}=${encodeURIComponent(t)}`;return r===null?n:`${n}&${d.version}=${encodeURIComponent(r)}`},U="text",H="workbook",He=e=>{if(!e.includes("?"))throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);return`${e}&${d.display}=${U}`},ze=e=>{if(!e.includes("?"))throw new RangeError(`[markdown-explorer] an asset URL always carries a query; got ${JSON.stringify(e)}`);return`${e}&${d.display}=${H}`},Fe=e=>{const t=e.getAll(d.display);return t.length===0?"file":t.length!==1?null:t[0]===U?"text":t[0]===H?"workbook":null},Ve=e=>`${e}/${Ce}`,Me="X-Markdown-Explorer-Scope",Ke="X-Markdown-Explorer",Ge="refresh",Ye="edit",We="text/markdown",Je=e=>je.includes(e),z=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),qe=e=>{const[t,...r]=y.filter(n=>z[n]===e);return t!==void 0&&r.length===0?t:"failed"};exports.DEFAULT_DENIED_PATH_SEGMENTS=b;exports.EXPLORER_DATA_QUERY=d;exports.EXPLORER_DRAFT_MEDIA_TYPE=We;exports.EXPLORER_EDIT_PROOF=Ye;exports.EXPLORER_EDIT_TOKEN_MAX_LENGTH=_;exports.EXPLORER_FAILURE_REASONS=y;exports.EXPLORER_FAILURE_STATUS=z;exports.EXPLORER_LINK_PROTOCOLS=ce;exports.EXPLORER_MAX_HEADINGS=le;exports.EXPLORER_PROOF_HEADER=Ke;exports.EXPLORER_REFRESH_PROOF=Ge;exports.EXPLORER_SCOPE_HEADER=Me;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=D;exports.draftAnswerViolation=Ie;exports.entryViolation=L;exports.explorerAssetHref=Ue;exports.explorerLinkCardEndpoint=Ve;exports.explorerPlainTextHref=He;exports.explorerWorkbookHref=ze;exports.failureDocument=$e;exports.failureOf=C;exports.failureReasonOfStatus=qe;exports.failureViolation=E;exports.headingViolation=A;exports.isAcceptableDocumentPath=R;exports.isAcceptableUrl=me;exports.isDeniedPath=ee;exports.isExplorerAncestorsResult=ye;exports.isExplorerChildrenResult=N;exports.isExplorerDataOperation=Je;exports.isExplorerDocument=k;exports.isExplorerEditAnswer=we;exports.isExplorerEditToken=f;exports.isExplorerFailureCode=g;exports.isExplorerFailureReason=T;exports.isExplorerImageType=S;exports.isExplorerMediaType=P;exports.isExplorerNoticeTone=pe;exports.isExplorerPreviewAnswer=ve;exports.isExplorerRevealResult=_e;exports.isExplorerRevisionAnswer=ke;exports.isExplorerRevisionsAnswer=De;exports.isExplorerSaveAnswer=Ne;exports.isExplorerTextAnswer=Ae;exports.isExplorerTreeResult=ge;exports.isRootRelativeUrl=u;exports.lastPathSegment=M;exports.readExplorerAssetDisplay=Fe;exports.resolvePathRules=Z;exports.revisionViolation=j;exports.spreadsheetFieldsViolation=I;
|