@aiquants/markdown-explorer 0.2.0 → 0.3.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 +23 -0
- package/README.md +26 -7
- package/dist/{ExplorerSplit-DB37U7Kh.js → ExplorerSplit-B7pmzR8t.js} +2 -2
- package/dist/{ExplorerSplit-D2plJRRe.cjs → ExplorerSplit-Bi3yU6NG.cjs} +1 -1
- package/dist/{MultiLayout-DCPDu1-l.js → MultiLayout-BxeXOLX1.js} +4 -4
- package/dist/{MultiLayout-UyWxs6Xy.cjs → MultiLayout-DtFrFRmS.cjs} +1 -1
- package/dist/{TreeLayout-CLWbWjOc.cjs → TreeLayout-BQUfVNlA.cjs} +1 -1
- package/dist/{TreeLayout-BoyFelK2.js → TreeLayout-D6hCSihW.js} +3 -3
- package/dist/core/config.d.cts +4 -2
- package/dist/core/config.d.ts +4 -2
- package/dist/{dataRoute-CKbdwkQ7.cjs → dataRoute-B9Wk-G7A.cjs} +1 -1
- package/dist/{dataRoute-Bkfwfp1R.js → dataRoute-zUX-oR9j.js} +39 -38
- package/dist/{index-BfuAu2GV.js → index-BJTmp0lR.js} +3 -3
- package/dist/{index-Cx3-jSna.cjs → index-DkiGlM7C.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +13 -13
- package/dist/location-DfYTzfFS.cjs +1 -0
- package/dist/{location-fVl2R1ee.js → location-V5BKeWNs.js} +178 -164
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +1 -1
- package/dist/server/anonymous.d.cts +2 -2
- package/dist/server/anonymous.d.ts +2 -2
- package/dist/server/ports.d.cts +4 -1
- package/dist/server/ports.d.ts +4 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +631 -603
- package/docs/behavior/security.md +16 -2
- package/package.json +3 -3
- package/dist/location-Oo21lTyV.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("react/jsx-runtime"),u=require("react"),F=require("./location-Oo21lTyV.cjs"),q=require("./index-Cx3-jSna.cjs"),ne=require("./ExplorerSplit-D2plJRRe.cjs"),k=require("@aiquants/drag-drop-panels"),be=require("./dataRoute-CKbdwkQ7.cjs"),de=require("react-router"),Z=require("./storage-Bkb2Axdi.cjs"),Fe=require("react-dom"),je=0xcbf29ce484222325n,Be=0x100000001b3n,Ve=(1n<<64n)-1n,$e=(1n<<53n)-1n,Ue=new TextEncoder,Ge=e=>{let n=je;for(const t of Ue.encode(e))n=(n^BigInt(t))*Be&Ve;return Number(n&$e)},J=256,Ye=e=>`aqmx-p-${Ge(e).toString(36)}`,Ce=(e,n)=>{const t=Ye(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},We=new Map,Ke=(e,n=We)=>{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},Oe=(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]=F.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([a,p])=>e.slice(a,p).reduce((l,g)=>l+g.length,0);let s=t;for(const a of o)r(a)<r(s)&&(s=a);let i=s[0];for(let a=s[0];a<s[1];a+=1)(e[a]?.length??0)<(e[i]?.length??0)&&(i=a);return i},X=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Oe(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},Je=(e,n)=>F.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),Xe=(e,n,t)=>{const[o,r]=n,s=r-o,i=e.length,a=Array.from({length:s},(d,h)=>{const f=[0];for(const C of e)f.push((f.at(-1)??0)+(t(C)===o+h?1:0));return f}),p=(d,h,f)=>(a[d]?.[f]??0)-(a[d]?.[h]??0),l=Array.from({length:s+1},()=>Array.from({length:i+1},()=>Number.NEGATIVE_INFINITY)),g=Array.from({length:s+1},()=>Array.from({length:i+1},()=>0)),w=l[0];w&&(w[0]=0);for(let d=0;d<s;d+=1)for(let h=0;h<=i;h+=1)for(let f=0;f<=h;f+=1){const C=(l[d]?.[f]??Number.NEGATIVE_INFINITY)+p(d,f,h),E=l[d+1],L=g[d+1];E&&L&&C>(E[h]??Number.NEGATIVE_INFINITY)&&(E[h]=C,L[h]=f)}const P=Array.from({length:s},()=>[]);let O=i;for(let d=s;d>0;d-=1){const h=g[d]?.[O]??0;P[d-1]=e.slice(h,O),O=h}return P},Me=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const i of s)o.delete(i),o.set(i,r);for(const r of o.keys()){if(o.size<=J)break;o.delete(r)}return{docs:t,columnOf:o}},Ze=(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=X(e,t),s=Oe(e,n,t.logical)??Pe(r,t);r[s]?.push(n);const i=new Map(e.panelIds);return i.set(n,Ce(n,new Set(i.values()))),{state:{...e,...Me(e,r),panelIds:i},outcome:"opened"}},Le=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Map(e.panelIds);return o.delete(n),{...e,docs:e.docs.filter(r=>r!==n),hidden:t,panelIds:o,maximized:e.maximized===n?null:e.maximized}},Qe=(e,n,t,o)=>{if(e.hidden.has(n))return{state:Ne(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Le(e,n),outcome:"closed"};const r=Ze(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},en=(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 i=new Map(e.panelIds),a=i.get(n);if(a===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return i.delete(n),i.set(t,a),{state:{docs:e.docs.map(p=>p===n?t:p),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,panelIds:i},outcome:"navigated"}},Ne=(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}},nn=(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}},tn=(e,n,t)=>{const o=X(e,t),r=new Map;for(const[l,g]of o.entries())for(const w of g)r.set(w,l);const s=new Set(e.docs),i=new Set,a=F.columnGroups(t.logical,t.visible),p=Array.from({length:t.logical},()=>[]);for(const[l,g]of a.entries()){const w=(n[l]??[]).filter(P=>s.has(P)&&!i.has(P));for(const P of w)i.add(P);for(const[P,O]of Xe(w,g,d=>r.get(d)).entries())p[g[0]+P]?.push(...O)}for(const l of e.docs)i.has(l)||p[r.get(l)??0]?.push(l);return p.every((l,g)=>l.length===o[g]?.length&&l.every((w,P)=>o[g]?.[P]===w))?e:{...e,...Me(e,p)}},Q=(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)),panelIds:Ke(t,e.panelIds)}},me=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of X(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=J)break;t.delete(o)}return{...e,columnOf:t}},Te=1,B=Object.freeze({columnOf:new Map,hidden:new Set}),on=(e,n)=>{if(e===null||e==="")return B;let t;try{t=JSON.parse(e)}catch{return B}if(t===null||typeof t!="object"||Array.isArray(t))return B;const o=t;if(o.v!==Te)return B;const r=new Map;if(Array.isArray(o.columnOf))for(const i of o.columnOf.slice(-J))Array.isArray(i)&&i.length===2&&typeof i[0]=="string"&&i[0]!==""&&Number.isInteger(i[1])&&i[1]>=0&&i[1]<n&&(r.delete(i[0]),r.set(i[0],i[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(i=>typeof i=="string"&&i!==""):[]);return{columnOf:r,hidden:s}},rn=e=>JSON.stringify({v:Te,columnOf:[...e.columnOf.entries()].slice(-J),hidden:e.docs.filter(n=>e.hidden.has(n))}),oe=(e,n)=>{const t=e.get(n);return t===void 0?be.lastPathSegment(n):t},U=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},fe=e=>{if(!be.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(e.slice(0,80))}`)},sn=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,i=q.createEmitter(),a=new Map,p=new Map;let l={layout:Q({docs:n.docs,maximized:n.maximized,stored:B},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},g=!1;const w=c=>g?me(c,{logical:s,visible:l.visibleColumns}):c,P=(c,y)=>F.explorerHref(e,{view:"multi",source:c,docs:y.docs,maximized:y.maximized});let O=P(n.source,n),d=n.source,h=O;const f=[],C=[];let E=null;const L=()=>{if(!(f.length>0))for(const c of C.splice(0))c()},m=c=>{l={...l,...c},i.emit()},S=()=>{if(!l.ready)return;const c=rn(l.layout);c!==E&&(E=c,o(c))},v=(c,y,M)=>{const R=P(c,y);R!==O&&(O=R,d=c,f.push(R),t(R,M))},T=c=>{const y=new Set(c.panelIds.values());for(const b of[...a.keys()])y.has(b)||a.delete(b);for(const b of[...p.keys()])y.has(b)||p.delete(b);const M=new Set(c.docs),R=[...l.titles.keys()].every(b=>M.has(b))?l.titles:new Map([...l.titles].filter(([b])=>M.has(b))),x=[...l.pendingHashes.keys()].every(b=>y.has(b))?l.pendingHashes:new Map([...l.pendingHashes].filter(([b])=>y.has(b)));return{titles:R,pendingHashes:x}},I=c=>c===l.layout?!1:(m({layout:c,...T(c)}),v(d,c,"replace"),S(),!0),_=()=>({logical:s,visible:l.visibleColumns});return{getSnapshot:()=>l,subscribe:i.subscribe,toggle:c=>{fe(c);const{state:y,outcome:M}=Qe(l.layout,c,_(),r);return I(y),M},close:c=>I(Le(l.layout,c)),navigate:(c,y)=>{fe(y);const{state:M,outcome:R}=en(l.layout,c,y);if(R!=="navigated")return R;const x=M.panelIds.get(y);return x!==void 0&&(a.delete(x),p.delete(x)),I(M),R},setHidden:(c,y)=>I(Ne(l.layout,c,y)),maximize:c=>I(nn(l.layout,c)),arrange:c=>I(tn(l.layout,c,{logical:s,visible:c.length})),changeSource:c=>{v(c,l.layout,"push")},observeLocation:c=>{const y=P(c.source,c);if(y===O)return f.length=0,h=y,c.source!==l.source&&m({source:c.source}),L(),!1;if(y===h)return!1;h=y;const M=f.indexOf(y);if(M>=0)return f.splice(0,M+1),c.source!==l.source&&m({source:c.source}),L(),!1;f.length=0,O=y,d=c.source;const R=w(Q({docs:c.docs,maximized:c.maximized,stored:{columnOf:l.layout.columnOf,hidden:l.layout.hidden},panelIds:l.layout.panelIds},r));return m({layout:R,source:c.source,...T(R)}),S(),L(),!0},whenUrlRendered:c=>{C.push(c),L()},loadStored:c=>{m({layout:w(Q({docs:l.layout.docs,maximized:l.layout.maximized,stored:c,panelIds:l.layout.panelIds},r)),ready:!0}),S()},setVisibleColumns:c=>{if(!Number.isInteger(c)||c<1||c>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${String(c)}`);g=!0;const y=me(l.layout,{logical:s,visible:c});c===l.visibleColumns&&y===l.layout||(m({visibleColumns:c,layout:y}),y!==l.layout&&S())},setSplitDragging:c=>{c!==l.splitDragging&&m({splitDragging:c})},setTitle:(c,y)=>{!l.layout.docs.includes(c)||l.titles.get(c)===y||m({titles:new Map(l.titles).set(c,y)})},titleOf:c=>oe(l.titles,c),setPendingHash:(c,y)=>{const M=l.pendingHashes.get(c);if(y===null||y===""){if(M===void 0)return;const R=new Map(l.pendingHashes);R.delete(c),m({pendingHashes:R});return}M!==y&&m({pendingHashes:new Map(l.pendingHashes).set(c,y)})},saveReadingPosition:(c,y,M)=>{l.layout.panelIds.get(y)===c&&a.set(c,{doc:y,position:M})},readingPositionOf:(c,y)=>{const M=a.get(c);return M===void 0||M.doc!==y?null:M.position},saveImageView:(c,y,M)=>{p.set(c,{url:y,state:M})},imageViewOf:(c,y)=>{const M=p.get(c);return M===void 0||M.url!==y?null:M.state}}},ln=()=>{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}}},Ie=u.createContext(null),re=()=>{const e=u.use(Ie);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},cn=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},se="data-aqmx-column-probe",Y="data-panel-id",te="--aqmx-multi-panel-chrome",j=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,an=e=>e==="normal"?0:j(e),un=(e,n)=>{const t=e.querySelector(k.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${se}]`),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),i=t.clientWidth-j(s.paddingLeft)-j(s.paddingRight),a=t.clientHeight-j(s.paddingTop)-j(s.paddingBottom);return{plan:{trackInlineSize:i,gap:an(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:a}},dn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+j(t.paddingBottom)+j(t.borderBottomWidth)},A=(e,n)=>{const t=()=>n(e.getSnapshot());return u.useSyncExternalStore(e.subscribe,t,t)},mn=e=>{const{config:n,storageNamespace:t}=q.useExplorer(),o=de.useNavigate(),r=u.useRef(o),s=Z.storageKeys(t).multiLayout,[i]=u.useState(()=>sn({config:n,location:e,writeUrl:(l,g)=>{r.current(l,q.explorerNavigationOptions(g==="replace"?"browse":"switch-source"))},persist:l=>Z.writeStorage(s,l)}));u.useLayoutEffect(()=>{r.current=o},[o]);const a=de.useLocation(),p=u.useMemo(()=>({location:e,navigated:a}),[e,a]);return u.useLayoutEffect(()=>{i.observeLocation(p.location)},[i,p]),u.useLayoutEffect(()=>{i.loadStored(on(Z.readStorage(s),n.multiView.columns))},[i,s,n]),i},Re="[data-aqdd-scroll-area]",W="data-aqmx-panel-frame",pe="--aqmx-multi-panel-pinned-block-size",fn=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}},pn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},gn=(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),V=e=>{const n=e.closest(Re);return n instanceof HTMLElement?n:null},De=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},ke=(e,n)=>{const t=n.getBoundingClientRect().top,o=De(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},ge=(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},hn=(e,n)=>{const t=ke(e,n),o=[];let r=e;for(let s=ge([...r.children],t);s>=0;s=ge([...r.children],t)){const i=r.children[s];if(i===void 0)break;o.push(s),r=i}return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:r.getBoundingClientRect().top-t}}},he=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const r of t.anchor.path)o=o?.children[r];o!==void 0&&(n.scrollTop+=o.getBoundingClientRect().top-ke(e,n)-t.anchor.offset)},vn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),Ae=e=>JSON.stringify([e.tagName,...vn.map(n=>e.getAttribute(n))]),yn=(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)}},wn=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&Ae(o)===t.signature&&q.focusWithoutScroll(o)||n.focus({preventScroll:!0})},xn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?V(n):n.closest(k.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=gn(e,r,t);(o||En(r,s))&&(e.preventDefault(),r.scrollTop+=s)},En=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,Sn=e=>e.scrollHeight>e.clientHeight,bn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=De(t),i=()=>{const l=dn(e,n);if(!Number.isFinite(l))return;const g=s===null?0:s.getBoundingClientRect().height;g!==r&&(r=g,t.style.setProperty(pe,`${String(g)}px`));const w=l+g;w!==o&&(o=w,e.style.setProperty(te,`${String(w)}px`))};i();let a=null;const p=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{a===null&&(a=requestAnimationFrame(()=>{a=null,i()}))});return p?.observe(e),p?.observe(n),s!==null&&p?.observe(s),()=>{p?.disconnect(),a!==null&&cancelAnimationFrame(a),e.style.removeProperty(te),t.style.removeProperty(pe)}},Cn=e=>{const{docPath:n,panelId:t}=fn(e),{store:o,Body:r,maximize:s,focusCarry:i}=re(),a=A(o,d=>d.layout.maximized===n),p=A(o,d=>oe(d.titles,n)),l=u.useRef(null),g=u.useRef(null),w=u.useRef(null);u.useEffect(()=>{const d=l.current,h=d===null?null:V(d);if(d===null||h===null||a)return;const f=new Map,C=v=>{const T=f.get(v);if(T!==void 0)return T;const I=pn(v);return f.set(v,I),I},E=v=>xn(v,d,C);let L=!1;const m=()=>{const v=Sn(h);v!==L&&(L=v,v?d.addEventListener("wheel",E,{capture:!0,passive:!1}):d.removeEventListener("wheel",E,{capture:!0}))};m();const S=typeof ResizeObserver>"u"?null:new ResizeObserver(m);return S?.observe(h),S?.observe(d),()=>{S?.disconnect(),d.removeEventListener("wheel",E,{capture:!0})}},[a]),u.useLayoutEffect(()=>{const d=l.current,h=d===null?null:V(d),f=d===null?null:d.closest(`[${Y}]`);if(!(d===null||h===null||!(f instanceof HTMLElement)))return bn(f,h,d)},[]),u.useLayoutEffect(()=>{const d=l.current,h=d===null?null:V(d);if(d===null||h===null)return;const f=o.readingPositionOf(t,n);g.current=f===null?null:{doc:n,position:f},f!==null&&he(d,h,f);let C=null;const E=()=>{C===null&&(C=requestAnimationFrame(()=>{C=null;const L=w.current;L!==null&&o.saveReadingPosition(t,L,hn(d,h))}))};return h.addEventListener("scroll",E,{passive:!0}),()=>{h.removeEventListener("scroll",E),C!==null&&cancelAnimationFrame(C)}},[o,t,n]),u.useLayoutEffect(()=>{const d=l.current,h=d===null?null:d.closest(`[${Y}]`);if(d===null||h===null)return;const f=i.take(t);return f!==null&&wn(h,d,f),()=>{const C=yn(h,h.ownerDocument.activeElement);C!==null&&i.hold(t,C)}},[i,t]);const P=u.useCallback(d=>{const h=l.current,f=h===null?null:V(h);if(h===null||f===null)return;const C=w.current;w.current=d;const E=g.current;g.current=null,E!==null&&E.doc===d?he(h,f,E.position):C!==null&&C!==d&&(f.scrollTop=0)},[]),O=u.useCallback(()=>s(n),[s,n]);return N.jsx("div",{ref:l,role:"group","aria-label":p,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":a?"true":"false","data-testid":"markdown-explorer-panel-frame",onDoubleClick:a?void 0:O,children:N.jsx(r,{docPath:n,panelId:t,maximized:a,title:p,onContentShown:P})})},On=u.memo(Cn),Pn=e=>{const n=e.closest(Re);if(n===null)throw new Error("[markdown-explorer] a panel's document region is not inside the panel's scroll area");return n},Mn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:i,revealInPanel:a}=re(),{announcer:p}=q.useExplorer(),l=A(s,E=>cn(E,n)),g=u.useCallback((E,L)=>i(n,e,E,L),[i,n,e]),w=u.useCallback(()=>s.setPendingHash(n,null),[s,n]),P=u.useMemo(()=>({read:E=>s.imageViewOf(n,E),save:(E,L)=>s.saveImageView(n,E,L)}),[s,n]),O=u.useCallback((E,L)=>{L.kind!=="failure"&&s.setTitle(E,L.name),r(E)},[s,r]),d=u.useCallback(E=>{s.whenUrlRendered(()=>p.announce(E))},[s,p]),h=u.useMemo(()=>({scrollerOf:Pn,reveal:E=>a(n,E)}),[a,n]),f=u.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:g,pendingHash:l,onHashConsumed:w,announceFailure:d,paneScroll:h}),[t,g,l,w,d,h]),C=u.useMemo(()=>({kind:"panel",documentName:o}),[o]);return N.jsxs(q.ImageViewMemoryContext,{value:P,children:[N.jsx(q.DocumentRefreshBar,{path:e,placement:C}),N.jsx(q.DocumentPane,{path:e,variant:f,onDocumentShown:O})]})},ve=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",G=(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},ye=e=>Object.fromEntries(k.generateColumnIds(e).map(n=>[n,[]])),Ln=(e,n)=>{const t=Je(X(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[k.generateColumnId(r),o.map(s=>G(e,s))]))},Nn=(e,n)=>{const t=U(e);return k.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},Tn=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,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}),le="--aqmx-stage-block",In="--aqmx-multi-panel-body-floor",Rn=`calc(var(${le}) * ${String(F.PANEL_MIN_BLOCK_RATIO)})`,Dn=`max(calc(var(${le}) * ${String(F.PANEL_MAX_BLOCK_RATIO)}), calc(var(${te}) + var(${In})))`,kn=(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((i,a)=>r[a]===i)})},we=["keydown","pointerdown","wheel","touchstart"],$=new WeakMap,xe=(e,n,t)=>{for(let o=n;o!==null&&o!==t;o=o.parentElement){e.observe(o);for(let r=o.previousElementSibling;r!==null;r=r.previousElementSibling)e.observe(r)}},An=e=>{const n=new Map;for(let t=e.parentElement;t!==null;t=t.parentElement)n.set(t,{top:t.scrollTop,left:t.scrollLeft});return n},K=(e,n,t)=>{$.get(e)?.();const o=e.querySelector(`[${Y}="${n}"]`);if(!(o instanceof HTMLElement))return;const r=t!==null&&o.contains(t)?t:null;let s=new Map;const i=()=>{if(!o.isConnected)return;o.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});const w=r?.isConnected===!0?r:o;w!==o&&w.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}),s=An(w)};if(i(),typeof ResizeObserver>"u")return;const a=new ResizeObserver(i);xe(a,o,o.closest(k.SCROLL_ROOT_SELECTOR)),r!==null&&xe(a,r,o);const{ownerDocument:p}=e,l=w=>{const P=w.target===p?p.scrollingElement:w.target;if(!(P instanceof Element))return;const O=s.get(P);O!==void 0&&(P.scrollTop!==O.top||P.scrollLeft!==O.left)&&g()},g=()=>{a.disconnect();for(const w of we)p.removeEventListener(w,g,!0);p.removeEventListener("scroll",l,!0),$.get(e)===g&&$.delete(e)};for(const w of we)p.addEventListener(w,g,{capture:!0,passive:!0});p.addEventListener("scroll",l,{capture:!0,passive:!0}),$.set(e,g)},_e=(e,n)=>{const t=e.querySelector(`[${W}="${n}"]`);return t instanceof HTMLElement?(K(e,n,null),t.focus({preventScroll:!0}),!0):!1},ie=(e,n)=>{const t=e.querySelector(`[${Y}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},Ee=(e,n)=>{if(!ie(e,n))return null;const t=[...e.querySelectorAll(`[${W}]`)].map(i=>i.getAttribute(W)),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"}},Se=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&_e(t,n.panelId)||t.focus({preventScroll:!0}))})},ze=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&_e(t,n)})},_n=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(K(o,n,t&&ie(o,n)?r:null),!t||r!==null&&r!==s&&r.isConnected)return;const i=o.querySelector(`[${W}="${n}"]`);i instanceof HTMLElement&&i.focus({preventScroll:!0})})},zn=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r}=q.useExplorer(),{maximize:s}=re(),i=t.multiView.columns,a=A(e,x=>x.layout),p=A(e,x=>x.visibleColumns),l=A(e,x=>x.titles),g=A(e,x=>x.layout.maximized!==null||x.splitDragging),[w,P]=u.useState(!1),[O]=u.useState(()=>ye(p)),d=u.useMemo(()=>Tn(o),[o]),h=u.useCallback(x=>{e.arrange(Nn(e.getSnapshot().layout,x))},[e]),f=k.useDragDropColumns({initialColumnPanels:O,initialPanelVisibility:{},debugConfig:k.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:h}),{columnPanels:C,setColumnPanels:E}=f,L=u.useRef(g),m=u.useRef(C);u.useLayoutEffect(()=>{L.current=g,m.current=C},[g,C]);const S=u.useCallback(x=>{const b=n.current;if(b===null)return;const{plan:H,stageBlockSize:D}=un(b,i);if(Number.isFinite(D)&&D>0&&b.style.setProperty(le,`${String(D)}px`),L.current&&!x)return;const z=F.replanVisibleColumns(e.getSnapshot().visibleColumns,H);z!==null&&e.setVisibleColumns(z)},[e,n,i]);u.useLayoutEffect(()=>{S(!0),P(!0)},[S]),u.useEffect(()=>{const x=n.current;if(x===null||typeof ResizeObserver>"u")return;let b=null;const H=new ResizeObserver(()=>{b===null&&(b=requestAnimationFrame(()=>{b=null,S(!1)}))}),D=x.querySelector(k.SCROLL_ROOT_SELECTOR)?.firstElementChild,z=x.querySelector(`[${se}]`);return D instanceof Element&&H.observe(D),z instanceof Element&&H.observe(z),()=>{H.disconnect(),b!==null&&cancelAnimationFrame(b)}},[n,S]),u.useEffect(()=>{g||S(!1)},[g,S]);const v=u.useMemo(()=>w?Ln(a,{logical:i,visible:p}):ye(p),[w,a,i,p]);u.useLayoutEffect(()=>{kn(m.current,v)||E(v)},[v,E]);const T=u.useMemo(()=>k.sortColumnIds(Object.keys(C)).map(x=>({id:x,key:x,className:"aqmx-multi-column"})),[C]),I=u.useMemo(()=>a.docs.map(x=>{const b=G(a,x);return{id:b,component:On,title:oe(l,x),props:{docPath:x,panelId:b},minHeight:Rn,maxHeight:Dn}}),[a,l]),_=u.useMemo(()=>Object.fromEntries(a.docs.map(x=>[G(a,x),!a.hidden.has(x)])),[a]),c=a.maximized===null?null:G(a,a.maximized),y=u.useCallback(x=>{const{layout:b}=e.getSnapshot();for(const[H,D]of U(b)){const z=x[H];if(z===void 0||z!==b.hidden.has(D))continue;const ce=e.titleOf(D);if(z){if(!e.setHidden(D,!1))continue;r.announce(o.panelShown(ce)),ze(n,H);continue}const ae=n.current,ue=ae===null?null:Ee(ae,H);e.setHidden(D,!0)&&(r.announce(o.panelHidden(ce)),ue!==null&&Se(n,ue))}},[e,n,r,o]),M=u.useCallback(x=>{const b=U(e.getSnapshot().layout).get(x);if(b===void 0)return;const H=e.titleOf(b),D=n.current,z=D===null?null:Ee(D,x);e.close(b)&&(r.announce(o.panelClosed(H)),z!==null&&Se(n,z))},[e,n,r,o]),R=u.useCallback(x=>{if(x===null){s(null);return}const b=U(e.getSnapshot().layout).get(x);b!==void 0&&s(b)},[e,s]);return N.jsx("div",{className:"aqmx-multi-layout","aria-busy":!w,children:N.jsx(k.DragDropLayout,{columns:T,panels:I,columnPanels:C,onColumnPanelsChange:h,panelVisibility:_,onPanelVisibilityChange:y,dragState:f.dragState,dragOverPosition:f.dragOverPosition,originalPanelPosition:f.originalPanelPosition,dragModes:f.dragModes,debugConfig:k.DEFAULT_DEBUG_CONFIG,panelSizes:f.panelSizes,customDrag:f.customDrag,setPanelRef:f.setPanelRef,onDragStart:f.handleDragStart,onDragEnd:f.handleDragEnd,onPlaceholderDragEnter:f.handlePlaceholderDragEnter,onPlaceholderDragLeave:f.handlePlaceholderDragLeave,onDragOverWithInsert:f.handleDragOverWithInsert,onDropWithInsert:f.handleDropWithInsert,onColumnDragLeave:f.handleColumnDragLeave,onPanelMouseDown:f.handleMouseDown,onPanelSizeInfoClick:f.handlePanelSizeInfoClick,onToggleDragMode:f.toggleDragMode,onPanelClose:M,onPanelMaximizeChange:R,maximizedPanel:c,dragHandle:"header",labels:d,panelClassName:"aqmx-multi-panel"})})},ee={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},Hn=(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(i=>{const a=n.ownerDocument.elementsFromPoint(s,i),p=a.findIndex(g=>n.contains(g)),l=a.findIndex(g=>e.contains(g));return p!==-1&&l!==-1&&l<p}))},qn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(ee.blockStart,`${String(t.top)}px`),e.style.setProperty(ee.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(ee.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Fn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:i,announcer:a}=q.useExplorer(),p=u.useRef(null),l=u.useRef(null),g=A(e,m=>m.ready),w=A(e,m=>m.layout.docs.length>0),P=A(e,m=>m.visibleColumns),O=u.use(ne.SheetNoticeSlotContext),d=u.useCallback(m=>{const{layout:S}=e.getSnapshot(),v=S.maximized,T=m===null&&v!==null?S.panelIds.get(v):void 0,I=p.current,_=T!==void 0&&I!==null&&ie(I,T);e.maximize(m)&&(m!==null?a.announce(i.panelMaximized(e.titleOf(m))):v!==null&&a.announce(i.panelRestored(e.titleOf(v))),T!==void 0&&_n(p,T,_))},[e,a,i]),h=u.useCallback((m,S,v,T)=>{if(v===S){e.setPendingHash(m,T);return}const I=e.navigate(S,v);if(I==="navigated"){e.setPendingHash(m,T);return}if(I!=="existing")return;const{layout:_}=e.getSnapshot(),c=_.panelIds.get(v);c!==void 0&&(a.announce(i.panelAlreadyOpen(e.titleOf(v))),_.maximized===null?e.setHidden(v,!1):d(v),e.setPendingHash(c,T),ze(p,c))},[e,a,i,d]);u.useLayoutEffect(()=>{if(t===null||O!==null||!ve())return;const m=l.current,S=p.current;if(m===null||S===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return qn(m,S)},[t,O]),u.useEffect(()=>{const m=l.current;if(t===null||m===null)return;const{ownerDocument:S}=m;let v=null;const T=I=>{const _=I.target;_ instanceof Element&&(v!==null&&cancelAnimationFrame(v),v=requestAnimationFrame(()=>{v=null,S.activeElement===_&&m.isConnected&&Hn(m,_)&&o()}))};return S.addEventListener("focusin",T,!0),()=>{S.removeEventListener("focusin",T,!0),v!==null&&cancelAnimationFrame(v)}},[t,O,o]),u.useImperativeHandle(r,()=>({bringIntoView:m=>{requestAnimationFrame(()=>{const S=p.current,v=e.getSnapshot().layout.panelIds.get(m);S!==null&&v!==void 0&&K(S,v,null)})}}),[e]),u.useEffect(()=>{const m=p.current;return()=>{m!==null&&$.get(m)?.()}},[]);const f=u.useCallback((m,S)=>{const v=p.current;v!==null&&K(v,m,S)},[]),[C]=u.useState(ln),E=u.useMemo(()=>({store:e,Body:n,followLink:h,maximize:d,revealInPanel:f,focusCarry:C}),[e,n,h,d,f,C]),L=u.useMemo(()=>Array.from({length:s.multiView.columns},(m,S)=>k.generateColumnId(S)),[s]);return N.jsxs("section",{ref:p,className:"aqmx-multi-stage",tabIndex:-1,"aria-label":i.multiRegion,"aria-busy":w&&!g,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":P,children:[N.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[se]:""}),w?g?N.jsx(Ie,{value:E,children:N.jsx(zn,{store:e,stageRef:p})}):N.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:L.map(m=>N.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[N.jsx("span",{}),N.jsx("span",{}),N.jsx("span",{})]},m))}):N.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:N.jsx("p",{className:"aqmx-empty-title",children:i.multiEmpty})}),t===null?null:O!==null?Fe.createPortal(N.jsx("div",{ref:l,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),O):N.jsx("div",{ref:l,popover:ve()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},He=3e3,qe=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},jn=(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)}`)}}},Bn=({location:e})=>{const{config:n,labels:t,announcer:o}=q.useExplorer(),r=mn(e),s=A(r,m=>m.layout.docs),i=A(r,m=>m.layout.maximized),a=A(r,m=>m.source),[p,l]=u.useState(!1),g=u.useRef(null),[w,P]=u.useState(0),O=u.useRef(null),d=u.useRef(null);u.useLayoutEffect(()=>{const m=O.current;O.current=null,m!==null&&(r.whenUrlRendered(()=>o.announce(m.announcement)),d.current?.bringIntoView(m.doc))}),u.useEffect(()=>()=>{g.current!==null&&clearTimeout(g.current)},[]);const h=u.useCallback(()=>{g.current!==null&&clearTimeout(g.current),l(!0),g.current=setTimeout(()=>{g.current=null,l(!1)},He)},[]),f=u.useCallback(()=>{g.current!==null&&clearTimeout(g.current),g.current=null,l(!1)},[]),C=u.useCallback(m=>{const S=r.titleOf(m),v=r.toggle(m);v==="rejected"&&h();const T=v==="rejected"?t.panelLimit(n.multiView.maxPanels):jn(t,v,S);if(v==="shown"){O.current={doc:m,announcement:T},P(I=>I+1);return}r.whenUrlRendered(()=>{o.announce(T),v==="opened"&&d.current?.bringIntoView(m)})},[r,h,o,t,n]),E=u.useMemo(()=>new Set(s),[s]),L=u.useMemo(()=>({href:F.explorerHref(n,{view:"tree",source:a,doc:qe(s,i)}),target:"tree"}),[n,a,s,i]);return N.jsx(ne.ExplorerSplit,{view:"multi",explorer:N.jsx(ne.ExplorerPane,{mode:"multi",sourceId:a,currentPath:null,openPaths:E,onOpenDocument:C,onSourceChange:r.changeSource,viewSwitch:L}),content:N.jsx(Fn,{ref:d,store:r,body:Mn,limitNotice:p?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:f}),contentCoversPage:i!==null,sheetDismissals:w,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Bn;exports.PANEL_LIMIT_NOTICE_MS=He;exports.treeSwitchDocument=qe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("react/jsx-runtime"),u=require("react"),F=require("./location-DfYTzfFS.cjs"),q=require("./index-DkiGlM7C.cjs"),ne=require("./ExplorerSplit-Bi3yU6NG.cjs"),k=require("@aiquants/drag-drop-panels"),be=require("./dataRoute-B9Wk-G7A.cjs"),de=require("react-router"),Z=require("./storage-Bkb2Axdi.cjs"),Fe=require("react-dom"),je=0xcbf29ce484222325n,Be=0x100000001b3n,Ve=(1n<<64n)-1n,$e=(1n<<53n)-1n,Ue=new TextEncoder,Ge=e=>{let n=je;for(const t of Ue.encode(e))n=(n^BigInt(t))*Be&Ve;return Number(n&$e)},J=256,Ye=e=>`aqmx-p-${Ge(e).toString(36)}`,Ce=(e,n)=>{const t=Ye(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},We=new Map,Ke=(e,n=We)=>{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},Oe=(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]=F.columnGroups(n.logical,n.visible);if(t===void 0)throw new RangeError("[markdown-explorer] there must be at least one visible column");const r=([a,p])=>e.slice(a,p).reduce((l,g)=>l+g.length,0);let s=t;for(const a of o)r(a)<r(s)&&(s=a);let i=s[0];for(let a=s[0];a<s[1];a+=1)(e[a]?.length??0)<(e[i]?.length??0)&&(i=a);return i},X=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Oe(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},Je=(e,n)=>F.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),Xe=(e,n,t)=>{const[o,r]=n,s=r-o,i=e.length,a=Array.from({length:s},(d,h)=>{const f=[0];for(const C of e)f.push((f.at(-1)??0)+(t(C)===o+h?1:0));return f}),p=(d,h,f)=>(a[d]?.[f]??0)-(a[d]?.[h]??0),l=Array.from({length:s+1},()=>Array.from({length:i+1},()=>Number.NEGATIVE_INFINITY)),g=Array.from({length:s+1},()=>Array.from({length:i+1},()=>0)),w=l[0];w&&(w[0]=0);for(let d=0;d<s;d+=1)for(let h=0;h<=i;h+=1)for(let f=0;f<=h;f+=1){const C=(l[d]?.[f]??Number.NEGATIVE_INFINITY)+p(d,f,h),E=l[d+1],L=g[d+1];E&&L&&C>(E[h]??Number.NEGATIVE_INFINITY)&&(E[h]=C,L[h]=f)}const P=Array.from({length:s},()=>[]);let O=i;for(let d=s;d>0;d-=1){const h=g[d]?.[O]??0;P[d-1]=e.slice(h,O),O=h}return P},Me=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const i of s)o.delete(i),o.set(i,r);for(const r of o.keys()){if(o.size<=J)break;o.delete(r)}return{docs:t,columnOf:o}},Ze=(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=X(e,t),s=Oe(e,n,t.logical)??Pe(r,t);r[s]?.push(n);const i=new Map(e.panelIds);return i.set(n,Ce(n,new Set(i.values()))),{state:{...e,...Me(e,r),panelIds:i},outcome:"opened"}},Le=(e,n)=>{if(!e.docs.includes(n))return e;const t=new Set(e.hidden);t.delete(n);const o=new Map(e.panelIds);return o.delete(n),{...e,docs:e.docs.filter(r=>r!==n),hidden:t,panelIds:o,maximized:e.maximized===n?null:e.maximized}},Qe=(e,n,t,o)=>{if(e.hidden.has(n))return{state:Ne(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Le(e,n),outcome:"closed"};const r=Ze(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},en=(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 i=new Map(e.panelIds),a=i.get(n);if(a===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return i.delete(n),i.set(t,a),{state:{docs:e.docs.map(p=>p===n?t:p),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,panelIds:i},outcome:"navigated"}},Ne=(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}},nn=(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}},tn=(e,n,t)=>{const o=X(e,t),r=new Map;for(const[l,g]of o.entries())for(const w of g)r.set(w,l);const s=new Set(e.docs),i=new Set,a=F.columnGroups(t.logical,t.visible),p=Array.from({length:t.logical},()=>[]);for(const[l,g]of a.entries()){const w=(n[l]??[]).filter(P=>s.has(P)&&!i.has(P));for(const P of w)i.add(P);for(const[P,O]of Xe(w,g,d=>r.get(d)).entries())p[g[0]+P]?.push(...O)}for(const l of e.docs)i.has(l)||p[r.get(l)??0]?.push(l);return p.every((l,g)=>l.length===o[g]?.length&&l.every((w,P)=>o[g]?.[P]===w))?e:{...e,...Me(e,p)}},Q=(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)),panelIds:Ke(t,e.panelIds)}},me=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of X(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=J)break;t.delete(o)}return{...e,columnOf:t}},Te=1,B=Object.freeze({columnOf:new Map,hidden:new Set}),on=(e,n)=>{if(e===null||e==="")return B;let t;try{t=JSON.parse(e)}catch{return B}if(t===null||typeof t!="object"||Array.isArray(t))return B;const o=t;if(o.v!==Te)return B;const r=new Map;if(Array.isArray(o.columnOf))for(const i of o.columnOf.slice(-J))Array.isArray(i)&&i.length===2&&typeof i[0]=="string"&&i[0]!==""&&Number.isInteger(i[1])&&i[1]>=0&&i[1]<n&&(r.delete(i[0]),r.set(i[0],i[1]));const s=new Set(Array.isArray(o.hidden)?o.hidden.filter(i=>typeof i=="string"&&i!==""):[]);return{columnOf:r,hidden:s}},rn=e=>JSON.stringify({v:Te,columnOf:[...e.columnOf.entries()].slice(-J),hidden:e.docs.filter(n=>e.hidden.has(n))}),oe=(e,n)=>{const t=e.get(n);return t===void 0?be.lastPathSegment(n):t},U=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},fe=e=>{if(!be.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(e.slice(0,80))}`)},sn=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,i=q.createEmitter(),a=new Map,p=new Map;let l={layout:Q({docs:n.docs,maximized:n.maximized,stored:B},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},g=!1;const w=c=>g?me(c,{logical:s,visible:l.visibleColumns}):c,P=(c,y)=>F.explorerHref(e,{view:"multi",source:c,docs:y.docs,maximized:y.maximized});let O=P(n.source,n),d=n.source,h=O;const f=[],C=[];let E=null;const L=()=>{if(!(f.length>0))for(const c of C.splice(0))c()},m=c=>{l={...l,...c},i.emit()},S=()=>{if(!l.ready)return;const c=rn(l.layout);c!==E&&(E=c,o(c))},v=(c,y,M)=>{const R=P(c,y);R!==O&&(O=R,d=c,f.push(R),t(R,M))},T=c=>{const y=new Set(c.panelIds.values());for(const b of[...a.keys()])y.has(b)||a.delete(b);for(const b of[...p.keys()])y.has(b)||p.delete(b);const M=new Set(c.docs),R=[...l.titles.keys()].every(b=>M.has(b))?l.titles:new Map([...l.titles].filter(([b])=>M.has(b))),x=[...l.pendingHashes.keys()].every(b=>y.has(b))?l.pendingHashes:new Map([...l.pendingHashes].filter(([b])=>y.has(b)));return{titles:R,pendingHashes:x}},I=c=>c===l.layout?!1:(m({layout:c,...T(c)}),v(d,c,"replace"),S(),!0),_=()=>({logical:s,visible:l.visibleColumns});return{getSnapshot:()=>l,subscribe:i.subscribe,toggle:c=>{fe(c);const{state:y,outcome:M}=Qe(l.layout,c,_(),r);return I(y),M},close:c=>I(Le(l.layout,c)),navigate:(c,y)=>{fe(y);const{state:M,outcome:R}=en(l.layout,c,y);if(R!=="navigated")return R;const x=M.panelIds.get(y);return x!==void 0&&(a.delete(x),p.delete(x)),I(M),R},setHidden:(c,y)=>I(Ne(l.layout,c,y)),maximize:c=>I(nn(l.layout,c)),arrange:c=>I(tn(l.layout,c,{logical:s,visible:c.length})),changeSource:c=>{v(c,l.layout,"push")},observeLocation:c=>{const y=P(c.source,c);if(y===O)return f.length=0,h=y,c.source!==l.source&&m({source:c.source}),L(),!1;if(y===h)return!1;h=y;const M=f.indexOf(y);if(M>=0)return f.splice(0,M+1),c.source!==l.source&&m({source:c.source}),L(),!1;f.length=0,O=y,d=c.source;const R=w(Q({docs:c.docs,maximized:c.maximized,stored:{columnOf:l.layout.columnOf,hidden:l.layout.hidden},panelIds:l.layout.panelIds},r));return m({layout:R,source:c.source,...T(R)}),S(),L(),!0},whenUrlRendered:c=>{C.push(c),L()},loadStored:c=>{m({layout:w(Q({docs:l.layout.docs,maximized:l.layout.maximized,stored:c,panelIds:l.layout.panelIds},r)),ready:!0}),S()},setVisibleColumns:c=>{if(!Number.isInteger(c)||c<1||c>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${String(c)}`);g=!0;const y=me(l.layout,{logical:s,visible:c});c===l.visibleColumns&&y===l.layout||(m({visibleColumns:c,layout:y}),y!==l.layout&&S())},setSplitDragging:c=>{c!==l.splitDragging&&m({splitDragging:c})},setTitle:(c,y)=>{!l.layout.docs.includes(c)||l.titles.get(c)===y||m({titles:new Map(l.titles).set(c,y)})},titleOf:c=>oe(l.titles,c),setPendingHash:(c,y)=>{const M=l.pendingHashes.get(c);if(y===null||y===""){if(M===void 0)return;const R=new Map(l.pendingHashes);R.delete(c),m({pendingHashes:R});return}M!==y&&m({pendingHashes:new Map(l.pendingHashes).set(c,y)})},saveReadingPosition:(c,y,M)=>{l.layout.panelIds.get(y)===c&&a.set(c,{doc:y,position:M})},readingPositionOf:(c,y)=>{const M=a.get(c);return M===void 0||M.doc!==y?null:M.position},saveImageView:(c,y,M)=>{p.set(c,{url:y,state:M})},imageViewOf:(c,y)=>{const M=p.get(c);return M===void 0||M.url!==y?null:M.state}}},ln=()=>{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}}},Ie=u.createContext(null),re=()=>{const e=u.use(Ie);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},cn=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},se="data-aqmx-column-probe",Y="data-panel-id",te="--aqmx-multi-panel-chrome",j=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,an=e=>e==="normal"?0:j(e),un=(e,n)=>{const t=e.querySelector(k.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${se}]`),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),i=t.clientWidth-j(s.paddingLeft)-j(s.paddingRight),a=t.clientHeight-j(s.paddingTop)-j(s.paddingBottom);return{plan:{trackInlineSize:i,gap:an(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:a}},dn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+j(t.paddingBottom)+j(t.borderBottomWidth)},A=(e,n)=>{const t=()=>n(e.getSnapshot());return u.useSyncExternalStore(e.subscribe,t,t)},mn=e=>{const{config:n,storageNamespace:t}=q.useExplorer(),o=de.useNavigate(),r=u.useRef(o),s=Z.storageKeys(t).multiLayout,[i]=u.useState(()=>sn({config:n,location:e,writeUrl:(l,g)=>{r.current(l,q.explorerNavigationOptions(g==="replace"?"browse":"switch-source"))},persist:l=>Z.writeStorage(s,l)}));u.useLayoutEffect(()=>{r.current=o},[o]);const a=de.useLocation(),p=u.useMemo(()=>({location:e,navigated:a}),[e,a]);return u.useLayoutEffect(()=>{i.observeLocation(p.location)},[i,p]),u.useLayoutEffect(()=>{i.loadStored(on(Z.readStorage(s),n.multiView.columns))},[i,s,n]),i},Re="[data-aqdd-scroll-area]",W="data-aqmx-panel-frame",pe="--aqmx-multi-panel-pinned-block-size",fn=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}},pn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},gn=(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),V=e=>{const n=e.closest(Re);return n instanceof HTMLElement?n:null},De=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},ke=(e,n)=>{const t=n.getBoundingClientRect().top,o=De(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},ge=(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},hn=(e,n)=>{const t=ke(e,n),o=[];let r=e;for(let s=ge([...r.children],t);s>=0;s=ge([...r.children],t)){const i=r.children[s];if(i===void 0)break;o.push(s),r=i}return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:r.getBoundingClientRect().top-t}}},he=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const r of t.anchor.path)o=o?.children[r];o!==void 0&&(n.scrollTop+=o.getBoundingClientRect().top-ke(e,n)-t.anchor.offset)},vn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),Ae=e=>JSON.stringify([e.tagName,...vn.map(n=>e.getAttribute(n))]),yn=(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)}},wn=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&Ae(o)===t.signature&&q.focusWithoutScroll(o)||n.focus({preventScroll:!0})},xn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?V(n):n.closest(k.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=gn(e,r,t);(o||En(r,s))&&(e.preventDefault(),r.scrollTop+=s)},En=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,Sn=e=>e.scrollHeight>e.clientHeight,bn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=De(t),i=()=>{const l=dn(e,n);if(!Number.isFinite(l))return;const g=s===null?0:s.getBoundingClientRect().height;g!==r&&(r=g,t.style.setProperty(pe,`${String(g)}px`));const w=l+g;w!==o&&(o=w,e.style.setProperty(te,`${String(w)}px`))};i();let a=null;const p=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{a===null&&(a=requestAnimationFrame(()=>{a=null,i()}))});return p?.observe(e),p?.observe(n),s!==null&&p?.observe(s),()=>{p?.disconnect(),a!==null&&cancelAnimationFrame(a),e.style.removeProperty(te),t.style.removeProperty(pe)}},Cn=e=>{const{docPath:n,panelId:t}=fn(e),{store:o,Body:r,maximize:s,focusCarry:i}=re(),a=A(o,d=>d.layout.maximized===n),p=A(o,d=>oe(d.titles,n)),l=u.useRef(null),g=u.useRef(null),w=u.useRef(null);u.useEffect(()=>{const d=l.current,h=d===null?null:V(d);if(d===null||h===null||a)return;const f=new Map,C=v=>{const T=f.get(v);if(T!==void 0)return T;const I=pn(v);return f.set(v,I),I},E=v=>xn(v,d,C);let L=!1;const m=()=>{const v=Sn(h);v!==L&&(L=v,v?d.addEventListener("wheel",E,{capture:!0,passive:!1}):d.removeEventListener("wheel",E,{capture:!0}))};m();const S=typeof ResizeObserver>"u"?null:new ResizeObserver(m);return S?.observe(h),S?.observe(d),()=>{S?.disconnect(),d.removeEventListener("wheel",E,{capture:!0})}},[a]),u.useLayoutEffect(()=>{const d=l.current,h=d===null?null:V(d),f=d===null?null:d.closest(`[${Y}]`);if(!(d===null||h===null||!(f instanceof HTMLElement)))return bn(f,h,d)},[]),u.useLayoutEffect(()=>{const d=l.current,h=d===null?null:V(d);if(d===null||h===null)return;const f=o.readingPositionOf(t,n);g.current=f===null?null:{doc:n,position:f},f!==null&&he(d,h,f);let C=null;const E=()=>{C===null&&(C=requestAnimationFrame(()=>{C=null;const L=w.current;L!==null&&o.saveReadingPosition(t,L,hn(d,h))}))};return h.addEventListener("scroll",E,{passive:!0}),()=>{h.removeEventListener("scroll",E),C!==null&&cancelAnimationFrame(C)}},[o,t,n]),u.useLayoutEffect(()=>{const d=l.current,h=d===null?null:d.closest(`[${Y}]`);if(d===null||h===null)return;const f=i.take(t);return f!==null&&wn(h,d,f),()=>{const C=yn(h,h.ownerDocument.activeElement);C!==null&&i.hold(t,C)}},[i,t]);const P=u.useCallback(d=>{const h=l.current,f=h===null?null:V(h);if(h===null||f===null)return;const C=w.current;w.current=d;const E=g.current;g.current=null,E!==null&&E.doc===d?he(h,f,E.position):C!==null&&C!==d&&(f.scrollTop=0)},[]),O=u.useCallback(()=>s(n),[s,n]);return N.jsx("div",{ref:l,role:"group","aria-label":p,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":a?"true":"false","data-testid":"markdown-explorer-panel-frame",onDoubleClick:a?void 0:O,children:N.jsx(r,{docPath:n,panelId:t,maximized:a,title:p,onContentShown:P})})},On=u.memo(Cn),Pn=e=>{const n=e.closest(Re);if(n===null)throw new Error("[markdown-explorer] a panel's document region is not inside the panel's scroll area");return n},Mn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:i,revealInPanel:a}=re(),{announcer:p}=q.useExplorer(),l=A(s,E=>cn(E,n)),g=u.useCallback((E,L)=>i(n,e,E,L),[i,n,e]),w=u.useCallback(()=>s.setPendingHash(n,null),[s,n]),P=u.useMemo(()=>({read:E=>s.imageViewOf(n,E),save:(E,L)=>s.saveImageView(n,E,L)}),[s,n]),O=u.useCallback((E,L)=>{L.kind!=="failure"&&s.setTitle(E,L.name),r(E)},[s,r]),d=u.useCallback(E=>{s.whenUrlRendered(()=>p.announce(E))},[s,p]),h=u.useMemo(()=>({scrollerOf:Pn,reveal:E=>a(n,E)}),[a,n]),f=u.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:g,pendingHash:l,onHashConsumed:w,announceFailure:d,paneScroll:h}),[t,g,l,w,d,h]),C=u.useMemo(()=>({kind:"panel",documentName:o}),[o]);return N.jsxs(q.ImageViewMemoryContext,{value:P,children:[N.jsx(q.DocumentRefreshBar,{path:e,placement:C}),N.jsx(q.DocumentPane,{path:e,variant:f,onDocumentShown:O})]})},ve=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",G=(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},ye=e=>Object.fromEntries(k.generateColumnIds(e).map(n=>[n,[]])),Ln=(e,n)=>{const t=Je(X(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[k.generateColumnId(r),o.map(s=>G(e,s))]))},Nn=(e,n)=>{const t=U(e);return k.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},Tn=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,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}),le="--aqmx-stage-block",In="--aqmx-multi-panel-body-floor",Rn=`calc(var(${le}) * ${String(F.PANEL_MIN_BLOCK_RATIO)})`,Dn=`max(calc(var(${le}) * ${String(F.PANEL_MAX_BLOCK_RATIO)}), calc(var(${te}) + var(${In})))`,kn=(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((i,a)=>r[a]===i)})},we=["keydown","pointerdown","wheel","touchstart"],$=new WeakMap,xe=(e,n,t)=>{for(let o=n;o!==null&&o!==t;o=o.parentElement){e.observe(o);for(let r=o.previousElementSibling;r!==null;r=r.previousElementSibling)e.observe(r)}},An=e=>{const n=new Map;for(let t=e.parentElement;t!==null;t=t.parentElement)n.set(t,{top:t.scrollTop,left:t.scrollLeft});return n},K=(e,n,t)=>{$.get(e)?.();const o=e.querySelector(`[${Y}="${n}"]`);if(!(o instanceof HTMLElement))return;const r=t!==null&&o.contains(t)?t:null;let s=new Map;const i=()=>{if(!o.isConnected)return;o.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});const w=r?.isConnected===!0?r:o;w!==o&&w.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}),s=An(w)};if(i(),typeof ResizeObserver>"u")return;const a=new ResizeObserver(i);xe(a,o,o.closest(k.SCROLL_ROOT_SELECTOR)),r!==null&&xe(a,r,o);const{ownerDocument:p}=e,l=w=>{const P=w.target===p?p.scrollingElement:w.target;if(!(P instanceof Element))return;const O=s.get(P);O!==void 0&&(P.scrollTop!==O.top||P.scrollLeft!==O.left)&&g()},g=()=>{a.disconnect();for(const w of we)p.removeEventListener(w,g,!0);p.removeEventListener("scroll",l,!0),$.get(e)===g&&$.delete(e)};for(const w of we)p.addEventListener(w,g,{capture:!0,passive:!0});p.addEventListener("scroll",l,{capture:!0,passive:!0}),$.set(e,g)},_e=(e,n)=>{const t=e.querySelector(`[${W}="${n}"]`);return t instanceof HTMLElement?(K(e,n,null),t.focus({preventScroll:!0}),!0):!1},ie=(e,n)=>{const t=e.querySelector(`[${Y}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},Ee=(e,n)=>{if(!ie(e,n))return null;const t=[...e.querySelectorAll(`[${W}]`)].map(i=>i.getAttribute(W)),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"}},Se=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&_e(t,n.panelId)||t.focus({preventScroll:!0}))})},ze=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&_e(t,n)})},_n=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(K(o,n,t&&ie(o,n)?r:null),!t||r!==null&&r!==s&&r.isConnected)return;const i=o.querySelector(`[${W}="${n}"]`);i instanceof HTMLElement&&i.focus({preventScroll:!0})})},zn=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r}=q.useExplorer(),{maximize:s}=re(),i=t.multiView.columns,a=A(e,x=>x.layout),p=A(e,x=>x.visibleColumns),l=A(e,x=>x.titles),g=A(e,x=>x.layout.maximized!==null||x.splitDragging),[w,P]=u.useState(!1),[O]=u.useState(()=>ye(p)),d=u.useMemo(()=>Tn(o),[o]),h=u.useCallback(x=>{e.arrange(Nn(e.getSnapshot().layout,x))},[e]),f=k.useDragDropColumns({initialColumnPanels:O,initialPanelVisibility:{},debugConfig:k.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:h}),{columnPanels:C,setColumnPanels:E}=f,L=u.useRef(g),m=u.useRef(C);u.useLayoutEffect(()=>{L.current=g,m.current=C},[g,C]);const S=u.useCallback(x=>{const b=n.current;if(b===null)return;const{plan:H,stageBlockSize:D}=un(b,i);if(Number.isFinite(D)&&D>0&&b.style.setProperty(le,`${String(D)}px`),L.current&&!x)return;const z=F.replanVisibleColumns(e.getSnapshot().visibleColumns,H);z!==null&&e.setVisibleColumns(z)},[e,n,i]);u.useLayoutEffect(()=>{S(!0),P(!0)},[S]),u.useEffect(()=>{const x=n.current;if(x===null||typeof ResizeObserver>"u")return;let b=null;const H=new ResizeObserver(()=>{b===null&&(b=requestAnimationFrame(()=>{b=null,S(!1)}))}),D=x.querySelector(k.SCROLL_ROOT_SELECTOR)?.firstElementChild,z=x.querySelector(`[${se}]`);return D instanceof Element&&H.observe(D),z instanceof Element&&H.observe(z),()=>{H.disconnect(),b!==null&&cancelAnimationFrame(b)}},[n,S]),u.useEffect(()=>{g||S(!1)},[g,S]);const v=u.useMemo(()=>w?Ln(a,{logical:i,visible:p}):ye(p),[w,a,i,p]);u.useLayoutEffect(()=>{kn(m.current,v)||E(v)},[v,E]);const T=u.useMemo(()=>k.sortColumnIds(Object.keys(C)).map(x=>({id:x,key:x,className:"aqmx-multi-column"})),[C]),I=u.useMemo(()=>a.docs.map(x=>{const b=G(a,x);return{id:b,component:On,title:oe(l,x),props:{docPath:x,panelId:b},minHeight:Rn,maxHeight:Dn}}),[a,l]),_=u.useMemo(()=>Object.fromEntries(a.docs.map(x=>[G(a,x),!a.hidden.has(x)])),[a]),c=a.maximized===null?null:G(a,a.maximized),y=u.useCallback(x=>{const{layout:b}=e.getSnapshot();for(const[H,D]of U(b)){const z=x[H];if(z===void 0||z!==b.hidden.has(D))continue;const ce=e.titleOf(D);if(z){if(!e.setHidden(D,!1))continue;r.announce(o.panelShown(ce)),ze(n,H);continue}const ae=n.current,ue=ae===null?null:Ee(ae,H);e.setHidden(D,!0)&&(r.announce(o.panelHidden(ce)),ue!==null&&Se(n,ue))}},[e,n,r,o]),M=u.useCallback(x=>{const b=U(e.getSnapshot().layout).get(x);if(b===void 0)return;const H=e.titleOf(b),D=n.current,z=D===null?null:Ee(D,x);e.close(b)&&(r.announce(o.panelClosed(H)),z!==null&&Se(n,z))},[e,n,r,o]),R=u.useCallback(x=>{if(x===null){s(null);return}const b=U(e.getSnapshot().layout).get(x);b!==void 0&&s(b)},[e,s]);return N.jsx("div",{className:"aqmx-multi-layout","aria-busy":!w,children:N.jsx(k.DragDropLayout,{columns:T,panels:I,columnPanels:C,onColumnPanelsChange:h,panelVisibility:_,onPanelVisibilityChange:y,dragState:f.dragState,dragOverPosition:f.dragOverPosition,originalPanelPosition:f.originalPanelPosition,dragModes:f.dragModes,debugConfig:k.DEFAULT_DEBUG_CONFIG,panelSizes:f.panelSizes,customDrag:f.customDrag,setPanelRef:f.setPanelRef,onDragStart:f.handleDragStart,onDragEnd:f.handleDragEnd,onPlaceholderDragEnter:f.handlePlaceholderDragEnter,onPlaceholderDragLeave:f.handlePlaceholderDragLeave,onDragOverWithInsert:f.handleDragOverWithInsert,onDropWithInsert:f.handleDropWithInsert,onColumnDragLeave:f.handleColumnDragLeave,onPanelMouseDown:f.handleMouseDown,onPanelSizeInfoClick:f.handlePanelSizeInfoClick,onToggleDragMode:f.toggleDragMode,onPanelClose:M,onPanelMaximizeChange:R,maximizedPanel:c,dragHandle:"header",labels:d,panelClassName:"aqmx-multi-panel"})})},ee={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},Hn=(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(i=>{const a=n.ownerDocument.elementsFromPoint(s,i),p=a.findIndex(g=>n.contains(g)),l=a.findIndex(g=>e.contains(g));return p!==-1&&l!==-1&&l<p}))},qn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(ee.blockStart,`${String(t.top)}px`),e.style.setProperty(ee.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(ee.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Fn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:i,announcer:a}=q.useExplorer(),p=u.useRef(null),l=u.useRef(null),g=A(e,m=>m.ready),w=A(e,m=>m.layout.docs.length>0),P=A(e,m=>m.visibleColumns),O=u.use(ne.SheetNoticeSlotContext),d=u.useCallback(m=>{const{layout:S}=e.getSnapshot(),v=S.maximized,T=m===null&&v!==null?S.panelIds.get(v):void 0,I=p.current,_=T!==void 0&&I!==null&&ie(I,T);e.maximize(m)&&(m!==null?a.announce(i.panelMaximized(e.titleOf(m))):v!==null&&a.announce(i.panelRestored(e.titleOf(v))),T!==void 0&&_n(p,T,_))},[e,a,i]),h=u.useCallback((m,S,v,T)=>{if(v===S){e.setPendingHash(m,T);return}const I=e.navigate(S,v);if(I==="navigated"){e.setPendingHash(m,T);return}if(I!=="existing")return;const{layout:_}=e.getSnapshot(),c=_.panelIds.get(v);c!==void 0&&(a.announce(i.panelAlreadyOpen(e.titleOf(v))),_.maximized===null?e.setHidden(v,!1):d(v),e.setPendingHash(c,T),ze(p,c))},[e,a,i,d]);u.useLayoutEffect(()=>{if(t===null||O!==null||!ve())return;const m=l.current,S=p.current;if(m===null||S===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return qn(m,S)},[t,O]),u.useEffect(()=>{const m=l.current;if(t===null||m===null)return;const{ownerDocument:S}=m;let v=null;const T=I=>{const _=I.target;_ instanceof Element&&(v!==null&&cancelAnimationFrame(v),v=requestAnimationFrame(()=>{v=null,S.activeElement===_&&m.isConnected&&Hn(m,_)&&o()}))};return S.addEventListener("focusin",T,!0),()=>{S.removeEventListener("focusin",T,!0),v!==null&&cancelAnimationFrame(v)}},[t,O,o]),u.useImperativeHandle(r,()=>({bringIntoView:m=>{requestAnimationFrame(()=>{const S=p.current,v=e.getSnapshot().layout.panelIds.get(m);S!==null&&v!==void 0&&K(S,v,null)})}}),[e]),u.useEffect(()=>{const m=p.current;return()=>{m!==null&&$.get(m)?.()}},[]);const f=u.useCallback((m,S)=>{const v=p.current;v!==null&&K(v,m,S)},[]),[C]=u.useState(ln),E=u.useMemo(()=>({store:e,Body:n,followLink:h,maximize:d,revealInPanel:f,focusCarry:C}),[e,n,h,d,f,C]),L=u.useMemo(()=>Array.from({length:s.multiView.columns},(m,S)=>k.generateColumnId(S)),[s]);return N.jsxs("section",{ref:p,className:"aqmx-multi-stage",tabIndex:-1,"aria-label":i.multiRegion,"aria-busy":w&&!g,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":P,children:[N.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[se]:""}),w?g?N.jsx(Ie,{value:E,children:N.jsx(zn,{store:e,stageRef:p})}):N.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:L.map(m=>N.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[N.jsx("span",{}),N.jsx("span",{}),N.jsx("span",{})]},m))}):N.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:N.jsx("p",{className:"aqmx-empty-title",children:i.multiEmpty})}),t===null?null:O!==null?Fe.createPortal(N.jsx("div",{ref:l,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),O):N.jsx("div",{ref:l,popover:ve()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},He=3e3,qe=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},jn=(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)}`)}}},Bn=({location:e})=>{const{config:n,labels:t,announcer:o}=q.useExplorer(),r=mn(e),s=A(r,m=>m.layout.docs),i=A(r,m=>m.layout.maximized),a=A(r,m=>m.source),[p,l]=u.useState(!1),g=u.useRef(null),[w,P]=u.useState(0),O=u.useRef(null),d=u.useRef(null);u.useLayoutEffect(()=>{const m=O.current;O.current=null,m!==null&&(r.whenUrlRendered(()=>o.announce(m.announcement)),d.current?.bringIntoView(m.doc))}),u.useEffect(()=>()=>{g.current!==null&&clearTimeout(g.current)},[]);const h=u.useCallback(()=>{g.current!==null&&clearTimeout(g.current),l(!0),g.current=setTimeout(()=>{g.current=null,l(!1)},He)},[]),f=u.useCallback(()=>{g.current!==null&&clearTimeout(g.current),g.current=null,l(!1)},[]),C=u.useCallback(m=>{const S=r.titleOf(m),v=r.toggle(m);v==="rejected"&&h();const T=v==="rejected"?t.panelLimit(n.multiView.maxPanels):jn(t,v,S);if(v==="shown"){O.current={doc:m,announcement:T},P(I=>I+1);return}r.whenUrlRendered(()=>{o.announce(T),v==="opened"&&d.current?.bringIntoView(m)})},[r,h,o,t,n]),E=u.useMemo(()=>new Set(s),[s]),L=u.useMemo(()=>({href:F.explorerHref(n,{view:"tree",source:a,doc:qe(s,i)}),target:"tree"}),[n,a,s,i]);return N.jsx(ne.ExplorerSplit,{view:"multi",explorer:N.jsx(ne.ExplorerPane,{mode:"multi",sourceId:a,currentPath:null,openPaths:E,onOpenDocument:C,onSourceChange:r.changeSource,viewSwitch:L}),content:N.jsx(Fn,{ref:d,store:r,body:Mn,limitNotice:p?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:f}),contentCoversPage:i!==null,sheetDismissals:w,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Bn;exports.PANEL_LIMIT_NOTICE_MS=He;exports.treeSwitchDocument=qe;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),r=require("react"),u=require("./location-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),r=require("react"),u=require("./location-DfYTzfFS.cjs"),i=require("./index-DkiGlM7C.cjs"),l=require("./ExplorerSplit-Bi3yU6NG.cjs"),g=new Set,f=({location:p})=>{const{config:e}=i.useExplorer(),n=i.useExplorerNavigate(),{source:o,doc:t,overrides:c}=p,[m,d]=r.useState(l.EMPTY_SELECTION),x=r.useMemo(()=>({gathered:m,onGatheredChange:d}),[m]),h=r.useCallback(s=>n(u.explorerHref(e,{view:"tree",source:o,doc:s,overrides:c}),"browse"),[n,e,o,c]),v=r.useCallback(s=>n(u.explorerHref(e,{view:"tree",source:s,doc:t,overrides:c}),"switch-source"),[n,e,t,c]),S=r.useCallback(s=>n(u.explorerHref(e,{view:"multi",source:o,docs:u.canonicalMultiDocuments(e,s)}),"switch-view"),[n,e,o]),w=r.useMemo(()=>({href:u.explorerHref(e,{view:"multi",source:o,docs:t===null?[]:[t]}),target:"multi"}),[e,o,t]),E=r.useMemo(()=>({kind:"page",view:"tree",overrides:c,embed:{}}),[c]);return a.jsx(l.ExplorerSplit,{view:"tree",explorer:a.jsx(l.ExplorerPane,{mode:"tree",sourceId:o,currentPath:t,openPaths:g,onOpenDocument:h,onSourceChange:v,viewSwitch:w,tray:x,onOpenSelection:S}),content:a.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",children:[t===null?null:a.jsx(i.DocumentRefreshBar,{path:t,placement:i.PAGE_DOCUMENT_REFRESH}),a.jsx(i.DocumentPane,{path:t,variant:E})]})})};exports.TreeLayout=f;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as s, jsxs as S } from "react/jsx-runtime";
|
|
2
2
|
import { useState as f, useMemo as i, useCallback as u } from "react";
|
|
3
|
-
import { e as a, c as g } from "./location-
|
|
4
|
-
import { u as P, a as D, D as b, P as C, b as N } from "./index-
|
|
5
|
-
import { E as O, a as T, b as M } from "./ExplorerSplit-
|
|
3
|
+
import { e as a, c as g } from "./location-V5BKeWNs.js";
|
|
4
|
+
import { u as P, a as D, D as b, P as C, b as N } from "./index-BJTmp0lR.js";
|
|
5
|
+
import { E as O, a as T, b as M } from "./ExplorerSplit-B7pmzR8t.js";
|
|
6
6
|
const _ = /* @__PURE__ */ new Set(), q = ({ location: l }) => {
|
|
7
7
|
const { config: e } = P(), r = D(), { source: t, doc: o, overrides: n } = l, [m, p] = f(O), d = i(() => ({ gathered: m, onGatheredChange: p }), [m]), h = u((c) => r(a(e, { view: "tree", source: t, doc: c, overrides: n }), "browse"), [r, e, t, n]), v = u((c) => r(a(e, { view: "tree", source: c, doc: o, overrides: n }), "switch-source"), [r, e, o, n]), w = u((c) => r(a(e, { view: "multi", source: t, docs: g(e, c) }), "switch-view"), [r, e, t]), E = i(() => ({ href: a(e, { view: "multi", source: t, docs: o === null ? [] : [o] }), target: "multi" }), [e, t, o]), x = i(() => ({ kind: "page", view: "tree", overrides: n, embed: {} }), [n]);
|
|
8
8
|
return /* @__PURE__ */ s(
|
package/dist/core/config.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmbedProviderId, MarkdownEmbeds } from "@aiquants/markdown/embeds";
|
|
1
|
+
import { EmbedProviderId, LinkCardSize, MarkdownEmbeds } from "@aiquants/markdown/embeds";
|
|
2
2
|
import { MarkdownStyleOption } from "@aiquants/markdown/viewer-settings";
|
|
3
3
|
import { TreeSettings } from "./treeSettings.cjs";
|
|
4
4
|
export type ExplorerViewSlugs = {
|
|
@@ -25,7 +25,8 @@ export type ExplorerConfigInput = {
|
|
|
25
25
|
readonly iframeHosts?: readonly string[];
|
|
26
26
|
readonly embeds?: {
|
|
27
27
|
readonly providers?: readonly EmbedProviderId[];
|
|
28
|
-
readonly
|
|
28
|
+
readonly linkCards?: boolean;
|
|
29
|
+
readonly linkCardSize?: LinkCardSize;
|
|
29
30
|
};
|
|
30
31
|
readonly defaultTreeSettings?: Partial<TreeSettings>;
|
|
31
32
|
};
|
|
@@ -69,6 +70,7 @@ export declare const EXPAND_ALL_DEPTH_LIMITS: Readonly<{
|
|
|
69
70
|
max: 64;
|
|
70
71
|
}>;
|
|
71
72
|
export declare const defineExplorerConfig: (input: ExplorerConfigInput) => ExplorerConfig;
|
|
73
|
+
export declare const revalidateExplorerConfig: (config: ExplorerConfig) => ExplorerConfig;
|
|
72
74
|
export declare const isExplorerSourceId: (value: unknown) => value is string;
|
|
73
75
|
export type ExplorerLocationConfig = ExplorerConfig & {
|
|
74
76
|
readonly sourceIds: readonly string[];
|
package/dist/core/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EmbedProviderId, MarkdownEmbeds } from "@aiquants/markdown/embeds";
|
|
1
|
+
import { EmbedProviderId, LinkCardSize, MarkdownEmbeds } from "@aiquants/markdown/embeds";
|
|
2
2
|
import { MarkdownStyleOption } from "@aiquants/markdown/viewer-settings";
|
|
3
3
|
import { TreeSettings } from "./treeSettings.js";
|
|
4
4
|
export type ExplorerViewSlugs = {
|
|
@@ -25,7 +25,8 @@ export type ExplorerConfigInput = {
|
|
|
25
25
|
readonly iframeHosts?: readonly string[];
|
|
26
26
|
readonly embeds?: {
|
|
27
27
|
readonly providers?: readonly EmbedProviderId[];
|
|
28
|
-
readonly
|
|
28
|
+
readonly linkCards?: boolean;
|
|
29
|
+
readonly linkCardSize?: LinkCardSize;
|
|
29
30
|
};
|
|
30
31
|
readonly defaultTreeSettings?: Partial<TreeSettings>;
|
|
31
32
|
};
|
|
@@ -69,6 +70,7 @@ export declare const EXPAND_ALL_DEPTH_LIMITS: Readonly<{
|
|
|
69
70
|
max: 64;
|
|
70
71
|
}>;
|
|
71
72
|
export declare const defineExplorerConfig: (input: ExplorerConfigInput) => ExplorerConfig;
|
|
73
|
+
export declare const revalidateExplorerConfig: (config: ExplorerConfig) => ExplorerConfig;
|
|
72
74
|
export declare const isExplorerSourceId: (value: unknown) => value is string;
|
|
73
75
|
export type ExplorerLocationConfig = ExplorerConfig & {
|
|
74
76
|
readonly sourceIds: readonly string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const _=Object.freeze([".env*","*.env","*.env.*","*.env~*","*.env-*","*.env_*","*.env#*",".git",".git-credentials",".svn",".hg","node_modules","secrets",".secrets","secrets.json","secrets.yml","secrets.yaml","secrets.toml","secrets.ini","secrets.txt",".ssh",".aws",".gnupg",".docker",".kube",".terraform",".npmrc",".yarnrc",".yarnrc.yml",".netrc","_netrc",".pypirc",".pgpass",".my.cnf",".htpasswd",".vault-token","id_rsa*","id_dsa*","id_ecdsa*","id_ed25519*","*.pem","*.key","*.p8","*.p12","*.pfx","*.ppk","*.jks","*.keystore","*.kdbx","*credentials*.json","service-account*.json","*.tfstate","*.tfstate.*","*.tfvars","*.tfvars.json",".*_history","fish_history"]),D=/[\u0000-\u001f\u007f]/u,N=/\p{Cs}/u,x=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},y=e=>e.length>0&&e.length<=4096&&!N.test(e)&&!D.test(e)&&!e.includes("\\"),O=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),C=/(?:%[0-9A-Fa-f]{2})+/gu,U=new TextDecoder("utf-8"),H=/[/\\]/u,X=e=>e.replace(C,t=>U.decode(Uint8Array.from(t.slice(1).split("%").map(n=>Number.parseInt(n,16))))),
|
|
1
|
+
"use strict";const _=Object.freeze([".env*","*.env","*.env.*","*.env~*","*.env-*","*.env_*","*.env#*",".git",".git-credentials",".svn",".hg","node_modules","secrets",".secrets","secrets.json","secrets.yml","secrets.yaml","secrets.toml","secrets.ini","secrets.txt",".ssh",".aws",".gnupg",".docker",".kube",".terraform",".npmrc",".yarnrc",".yarnrc.yml",".netrc","_netrc",".pypirc",".pgpass",".my.cnf",".htpasswd",".vault-token","id_rsa*","id_dsa*","id_ecdsa*","id_ed25519*","*.pem","*.key","*.p8","*.p12","*.pfx","*.ppk","*.jks","*.keystore","*.kdbx","*credentials*.json","service-account*.json","*.tfstate","*.tfstate.*","*.tfvars","*.tfvars.json",".*_history","fish_history"]),D=/[\u0000-\u001f\u007f]/u,N=/\p{Cs}/u,x=e=>{const t=e.split("/").filter(n=>n!=="").at(-1);return t===void 0?e:t},y=e=>e.length>0&&e.length<=4096&&!N.test(e)&&!D.test(e)&&!e.includes("\\"),O=e=>e.normalize("NFKC").toUpperCase().toLowerCase(),C=/(?:%[0-9A-Fa-f]{2})+/gu,U=new TextDecoder("utf-8"),H=/[/\\]/u,X=e=>e.replace(C,t=>U.decode(Uint8Array.from(t.slice(1).split("%").map(n=>Number.parseInt(n,16))))),k=e=>{const t=[e];let n=e;for(let r=0;r<3&&n.includes("%");r+=1){const o=X(n);if(o===n)break;t.push(o),n=o}return t.map(O)},j=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=O(e).split("*").map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(".*");return new RegExp(`^${t}$`,"su")},E=e=>{if(!Array.isArray(e))throw new RangeError("[markdown-explorer] deny rules must be an array of segment patterns");const t=e.map(j),n=o=>o!==""&&t.some(s=>s.test(o)),r=o=>o!==""&&k(o).some(s=>n(s)||s.split(H).some(n));return{deniesPath:o=>o.split("/").some(r),deniesName:r}},I=E(_),w=Object.freeze({deniesPath:()=>!1,deniesName:()=>!1}),$=e=>e===void 0?I:e===!1?w:E(e),v=(e,t)=>E(e).deniesPath(t),d=Object.freeze(["unauthorized","forbidden","not-found","not-configured","invalid","too-large","unsupported","failed"]),z=Object.freeze(["file","directory"]),F=Object.freeze(["video","audio","pdf"]),M=Object.freeze(["info","warning","danger"]),V=Object.freeze(["markdown","text","image","media","file","failure"]),R=Object.freeze({min:1,max:6}),G=1e4,l=e=>typeof e=="string"&&/^\/(?![/\\])[\x21-\x7E]*$/u.test(e),Y=Object.freeze(["http:","https:","mailto:"]),K=/^[a-z0-9-]{1,64}$/u,J="https://relative.invalid/",m=64,c=(e,t)=>typeof t=="string"&&e.includes(t),a=e=>typeof e=="string"?JSON.stringify(e.length>m?`${e.slice(0,m)}…`:e):typeof e,A=e=>c(d,e),Q=e=>c(z,e),g=e=>c(F,e),B=e=>c(M,e),W=e=>c(V,e),f=e=>typeof e=="string"&&K.test(e),q=(e,t)=>{if(typeof e!="string")return!1;try{return t.includes(new URL(e,J).protocol)}catch{return!1}},p=e=>{if(e===null||typeof e!="object")return"a failure must be an object";const{reason:t,code:n}=e;return A(t)?n!==void 0&&!f(n)?`a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${a(n)}`:null:`unknown failure reason ${a(t)}`},T=e=>{if(e===null||typeof e!="object")return"an entry must be an object";const{name:t,path:n,type:r,mimeType:o,children:s,lazy:i}=e;return typeof t!="string"||t===""?"an entry needs a non-empty name":typeof n!="string"||!y(n)?"an entry needs an acceptable path":Q(r)?o!==void 0&&typeof o!="string"?"an entry mimeType must be a string":i!==void 0&&typeof i!="boolean"?"an entry lazy flag must be a boolean":s!==void 0&&!Array.isArray(s)?"entry children must be an array":r==="file"&&(s!==void 0||i===!0)?"a file entry cannot have children or be lazy":i===!0&&Array.isArray(s)&&s.length>0?"a lazy directory must not list children":null:`an entry type must be "file" or "directory"; got ${a(r)}`},h=e=>{if(T(e)!==null)return!1;const{children:t}=e;return t===void 0||t.every(h)},L=e=>{if(e===null||typeof e!="object")return!1;const{status:t,entries:n,failure:r}=e;return t==="ok"?Array.isArray(n)&&n.every(h):t==="error"&&p(r)===null},Z=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)},ee=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<R.min||n>R.max?`a heading depth must be an integer in 1..6; got ${String(n)}`:null},P=e=>{if(e===null||typeof e!="object")return"a document must be an object";const t=e,{kind:n}=t;if(!W(n))return`unknown document kind ${a(n)}`;if(n==="failure")return p(t.failure);if(typeof t.name!="string")return"a document needs a name string";switch(n){case"markdown":{const{htmlContent:r,headings:o}=t;if(typeof r!="string"||!Array.isArray(o))return"a markdown document needs htmlContent and headings";for(const s of o){const i=ee(s);if(i!==null)return i}return null}case"text":return typeof t.text!="string"||typeof t.truncated!="boolean"?"a text document needs text and truncated":l(t.url)?null:"a text document needs a root-relative url";case"image":return l(t.url)?null:"an image document needs a root-relative url";case"media":return l(t.url)?g(t.mediaType)?null:`unknown media type ${a(t.mediaType)}`:"a media document needs a root-relative url";case"file":return l(t.url)?null:"a file document needs a root-relative url"}},te=e=>P(e)===null,ne=(e,t)=>({kind:"failure",failure:b(e,t)}),b=(e,t)=>f(t)?{reason:e,code:t}:{reason:e},re=Object.freeze(["tree","children","document","refresh","asset","link-card"]),u=Object.freeze({source:"source",path:"path",version:"v"}),oe="asset",se="link-card",ie=(e,t,n)=>{const r=`${e}/${oe}?${u.path}=${encodeURIComponent(t)}`;return n===null?r:`${r}&${u.version}=${encodeURIComponent(n)}`},ae=e=>`${e}/${se}`,ce="X-Markdown-Explorer-Scope",le="X-Markdown-Explorer",ue="refresh",Ee=e=>re.includes(e),S=Object.freeze({invalid:400,unauthorized:401,forbidden:403,"not-found":404,"too-large":413,"not-configured":500,unsupported:500,failed:500}),de=e=>{const[t,...n]=d.filter(r=>S[r]===e);return t!==void 0&&n.length===0?t:"failed"};exports.DEFAULT_DENIED_PATH_SEGMENTS=_;exports.EXPLORER_DATA_QUERY=u;exports.EXPLORER_FAILURE_REASONS=d;exports.EXPLORER_FAILURE_STATUS=S;exports.EXPLORER_LINK_PROTOCOLS=Y;exports.EXPLORER_MAX_HEADINGS=G;exports.EXPLORER_REFRESH_HEADER=le;exports.EXPLORER_REFRESH_HEADER_VALUE=ue;exports.EXPLORER_SCOPE_HEADER=ce;exports.MAX_DOCUMENT_PATH_LENGTH=4096;exports.documentViolation=P;exports.entryViolation=T;exports.explorerAssetHref=ie;exports.explorerLinkCardEndpoint=ae;exports.failureDocument=ne;exports.failureOf=b;exports.failureReasonOfStatus=de;exports.failureViolation=p;exports.isAcceptableDocumentPath=y;exports.isAcceptableUrl=q;exports.isDeniedPath=v;exports.isExplorerChildrenResult=L;exports.isExplorerDataOperation=Ee;exports.isExplorerDocument=te;exports.isExplorerFailureCode=f;exports.isExplorerFailureReason=A;exports.isExplorerMediaType=g;exports.isExplorerNoticeTone=B;exports.isExplorerTreeResult=Z;exports.lastPathSegment=x;exports.resolvePathRules=$;
|
|
@@ -57,10 +57,10 @@ const _ = Object.freeze([
|
|
|
57
57
|
"*.tfvars.json",
|
|
58
58
|
".*_history",
|
|
59
59
|
"fish_history"
|
|
60
|
-
]),
|
|
60
|
+
]), O = /[\u0000-\u001f\u007f]/u, h = /\p{Cs}/u, Q = (e) => {
|
|
61
61
|
const t = e.split("/").filter((n) => n !== "").at(-1);
|
|
62
62
|
return t === void 0 ? e : t;
|
|
63
|
-
}, A = (e) => e.length > 0 && e.length <= 4096 && !
|
|
63
|
+
}, A = (e) => e.length > 0 && e.length <= 4096 && !h.test(e) && !O.test(e) && !e.includes("\\"), p = (e) => e.normalize("NFKC").toUpperCase().toLowerCase(), b = /(?:%[0-9A-Fa-f]{2})+/gu, T = new TextDecoder("utf-8"), L = /[/\\]/u, P = (e) => e.replace(
|
|
64
64
|
b,
|
|
65
65
|
(t) => T.decode(
|
|
66
66
|
Uint8Array.from(
|
|
@@ -88,30 +88,30 @@ const _ = Object.freeze([
|
|
|
88
88
|
deniesPath: (s) => s.split("/").some(r),
|
|
89
89
|
deniesName: r
|
|
90
90
|
};
|
|
91
|
-
}, D = u(_), N = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }),
|
|
91
|
+
}, D = u(_), N = Object.freeze({ deniesPath: () => !1, deniesName: () => !1 }), W = (e) => e === void 0 ? D : e === !1 ? N : u(e), Z = (e, t) => u(e).deniesPath(t), m = Object.freeze(["unauthorized", "forbidden", "not-found", "not-configured", "invalid", "too-large", "unsupported", "failed"]), j = Object.freeze(["file", "directory"]), k = Object.freeze(["video", "audio", "pdf"]), C = Object.freeze(["info", "warning", "danger"]), w = Object.freeze(["markdown", "text", "image", "media", "file", "failure"]), d = Object.freeze({ min: 1, max: 6 }), ee = 1e4, l = (e) => typeof e == "string" && /^\/(?![/\\])[\x21-\x7E]*$/u.test(e), te = Object.freeze(["http:", "https:", "mailto:"]), U = /^[a-z0-9-]{1,64}$/u, $ = "https://relative.invalid/", f = 64, c = (e, t) => typeof t == "string" && e.includes(t), a = (e) => typeof e == "string" ? JSON.stringify(e.length > f ? `${e.slice(0, f)}…` : e) : typeof e, v = (e) => c(m, e), z = (e) => c(j, e), I = (e) => c(k, e), ne = (e) => c(C, e), H = (e) => c(w, e), y = (e) => typeof e == "string" && U.test(e), re = (e, t) => {
|
|
92
92
|
if (typeof e != "string") return !1;
|
|
93
93
|
try {
|
|
94
|
-
return t.includes(new URL(e,
|
|
94
|
+
return t.includes(new URL(e, $).protocol);
|
|
95
95
|
} catch {
|
|
96
96
|
return !1;
|
|
97
97
|
}
|
|
98
98
|
}, R = (e) => {
|
|
99
99
|
if (e === null || typeof e != "object") return "a failure must be an object";
|
|
100
100
|
const { reason: t, code: n } = e;
|
|
101
|
-
return
|
|
102
|
-
},
|
|
101
|
+
return v(t) ? n !== void 0 && !y(n) ? `a failure code must be 1 to 64 lowercase letters, digits or hyphens; got ${a(n)}` : null : `unknown failure reason ${a(t)}`;
|
|
102
|
+
}, X = (e) => {
|
|
103
103
|
if (e === null || typeof e != "object") return "an entry must be an object";
|
|
104
104
|
const { name: t, path: n, type: r, mimeType: s, children: o, lazy: i } = e;
|
|
105
|
-
return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !A(n) ? "an entry needs an acceptable path" :
|
|
105
|
+
return typeof t != "string" || t === "" ? "an entry needs a non-empty name" : typeof n != "string" || !A(n) ? "an entry needs an acceptable path" : z(r) ? s !== void 0 && typeof s != "string" ? "an entry mimeType must be a string" : i !== void 0 && typeof i != "boolean" ? "an entry lazy flag must be a boolean" : o !== void 0 && !Array.isArray(o) ? "entry children must be an array" : r === "file" && (o !== void 0 || i === !0) ? "a file entry cannot have children or be lazy" : i === !0 && Array.isArray(o) && o.length > 0 ? "a lazy directory must not list children" : null : `an entry type must be "file" or "directory"; got ${a(r)}`;
|
|
106
106
|
}, g = (e) => {
|
|
107
|
-
if (
|
|
107
|
+
if (X(e) !== null) return !1;
|
|
108
108
|
const { children: t } = e;
|
|
109
109
|
return t === void 0 || t.every(g);
|
|
110
110
|
}, F = (e) => {
|
|
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(g) : t === "error" && R(r) === null;
|
|
114
|
-
},
|
|
114
|
+
}, se = (e) => {
|
|
115
115
|
if (e === null || typeof e != "object") return !1;
|
|
116
116
|
const { status: t, loadedAt: n } = e;
|
|
117
117
|
return t === "ok" && !(Number.isSafeInteger(n) && n >= 0) ? !1 : F(e);
|
|
@@ -122,7 +122,7 @@ const _ = Object.freeze([
|
|
|
122
122
|
}, V = (e) => {
|
|
123
123
|
if (e === null || typeof e != "object") return "a document must be an object";
|
|
124
124
|
const t = e, { kind: n } = t;
|
|
125
|
-
if (!
|
|
125
|
+
if (!H(n)) return `unknown document kind ${a(n)}`;
|
|
126
126
|
if (n === "failure") return R(t.failure);
|
|
127
127
|
if (typeof t.name != "string") return "a document needs a name string";
|
|
128
128
|
switch (n) {
|
|
@@ -140,14 +140,14 @@ const _ = Object.freeze([
|
|
|
140
140
|
case "image":
|
|
141
141
|
return l(t.url) ? null : "an image document needs a root-relative url";
|
|
142
142
|
case "media":
|
|
143
|
-
return l(t.url) ?
|
|
143
|
+
return l(t.url) ? I(t.mediaType) ? null : `unknown media type ${a(t.mediaType)}` : "a media document needs a root-relative url";
|
|
144
144
|
case "file":
|
|
145
145
|
return l(t.url) ? null : "a file document needs a root-relative url";
|
|
146
146
|
}
|
|
147
|
-
},
|
|
147
|
+
}, oe = (e) => V(e) === null, ie = (e, t) => ({ kind: "failure", failure: G(e, t) }), G = (e, t) => y(t) ? { reason: e, code: t } : { reason: e }, Y = Object.freeze(["tree", "children", "document", "refresh", "asset", "link-card"]), E = Object.freeze({ source: "source", path: "path", version: "v" }), K = "asset", B = "link-card", ae = (e, t, n) => {
|
|
148
148
|
const r = `${e}/${K}?${E.path}=${encodeURIComponent(t)}`;
|
|
149
149
|
return n === null ? r : `${r}&${E.version}=${encodeURIComponent(n)}`;
|
|
150
|
-
},
|
|
150
|
+
}, ce = (e) => `${e}/${B}`, le = "X-Markdown-Explorer-Scope", ue = "X-Markdown-Explorer", de = "refresh", fe = (e) => Y.includes(e), J = Object.freeze({
|
|
151
151
|
invalid: 400,
|
|
152
152
|
unauthorized: 401,
|
|
153
153
|
forbidden: 403,
|
|
@@ -156,39 +156,40 @@ const _ = Object.freeze([
|
|
|
156
156
|
"not-configured": 500,
|
|
157
157
|
unsupported: 500,
|
|
158
158
|
failed: 500
|
|
159
|
-
}),
|
|
159
|
+
}), Ee = (e) => {
|
|
160
160
|
const [t, ...n] = m.filter((r) => J[r] === e);
|
|
161
161
|
return t !== void 0 && n.length === 0 ? t : "failed";
|
|
162
162
|
};
|
|
163
163
|
export {
|
|
164
|
-
|
|
164
|
+
oe as A,
|
|
165
|
+
m as B,
|
|
165
166
|
_ as D,
|
|
166
|
-
|
|
167
|
+
ee as E,
|
|
167
168
|
q as M,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
ce as a,
|
|
170
|
+
v as b,
|
|
171
|
+
y as c,
|
|
171
172
|
ne as d,
|
|
172
|
-
|
|
173
|
+
ae as e,
|
|
173
174
|
G as f,
|
|
174
|
-
|
|
175
|
-
|
|
175
|
+
re as g,
|
|
176
|
+
I as h,
|
|
176
177
|
A as i,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
178
|
+
V as j,
|
|
179
|
+
X as k,
|
|
180
|
+
te as l,
|
|
181
|
+
fe as m,
|
|
182
|
+
J as n,
|
|
183
|
+
ue as o,
|
|
184
|
+
de as p,
|
|
185
|
+
le as q,
|
|
186
|
+
W as r,
|
|
187
|
+
E as s,
|
|
188
|
+
ie as t,
|
|
189
|
+
Z as u,
|
|
190
|
+
Q as v,
|
|
191
|
+
Ee as w,
|
|
192
|
+
F as x,
|
|
193
|
+
R as y,
|
|
193
194
|
se as z
|
|
194
195
|
};
|
|
@@ -2,9 +2,9 @@ import { jsx as d, jsxs as U, Fragment as Ft } from "react/jsx-runtime";
|
|
|
2
2
|
import * as x from "react";
|
|
3
3
|
import { createContext as ne, use as W, useMemo as I, useSyncExternalStore as te, useCallback as $, useRef as H, useEffect as Y, useState as Z, useLayoutEffect as V, Suspense as Ae, useEffectEvent as Q, useId as Pt, lazy as ft } from "react";
|
|
4
4
|
import { useParams as qt, useSearchParams as _t, useNavigate as jt, Link as Bt, useHref as he, useLocation as mt, useRevalidator as zt } from "react-router";
|
|
5
|
-
import { f as Ht,
|
|
5
|
+
import { f as Ht, a as It, u as Zt, G as se, e as le, x as Ut, y as Vt, z as Be, B as Wt, D as ze, H as Kt, w as Gt, I as Xt } from "./location-V5BKeWNs.js";
|
|
6
6
|
import { useMarkdownToolbarState as Yt, MarkdownViewer as gt } from "@aiquants/markdown";
|
|
7
|
-
import { i as Jt,
|
|
7
|
+
import { i as Jt, v as ht, s as oe, q as Qt, w as He, x as en, y as tn, f as nn, z as Ie, p as rn, t as on, A as ln, o as sn } from "./dataRoute-zUX-oR9j.js";
|
|
8
8
|
import { DEFAULT_CONTENT_ALIGN as an } from "@aiquants/markdown/viewer-settings";
|
|
9
9
|
import { w as cn, r as dn, a as un, b as Ze, s as fn, c as mn } from "./storage-DA4ItHzl.js";
|
|
10
10
|
const Ue = Object.freeze(["en", "ja"]), gn = "en", hn = Object.freeze({
|
|
@@ -1975,7 +1975,7 @@ const go = () => {
|
|
|
1975
1975
|
});
|
|
1976
1976
|
return a.observe(s, { childList: !0, subtree: !0 }), () => a.disconnect();
|
|
1977
1977
|
}, [t, e]);
|
|
1978
|
-
}, yo = ft(() => import("./TreeLayout-
|
|
1978
|
+
}, yo = ft(() => import("./TreeLayout-D6hCSihW.js").then((e) => ({ default: e.TreeLayout }))), xo = ft(() => import("./MultiLayout-BxeXOLX1.js").then((e) => ({ default: e.MultiLayout }))), ko = 64, dt = {
|
|
1979
1979
|
request: (e) => {
|
|
1980
1980
|
requestAnimationFrame(e);
|
|
1981
1981
|
}
|