@aiquants/markdown-explorer 0.36.0 → 0.37.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 +72 -0
- package/README.md +74 -11
- package/dist/{EditSurface-BCFJRyIM.js → EditSurface-BQgwRUrR.js} +250 -245
- package/dist/EditSurface-Xvk5wZu7.cjs +6 -0
- package/dist/ExplorerSplit-C_3FChSt.cjs +2 -0
- package/dist/ExplorerSplit-C_kaEnyM.js +1619 -0
- package/dist/{MultiLayout-Bo9LAXiY.cjs → MultiLayout-BZNj1GYo.cjs} +1 -1
- package/dist/{MultiLayout-Dy5TIC2t.js → MultiLayout-DROxkTdD.js} +22 -22
- package/dist/{NativeScrollBar-Bj-LKej0.cjs → NativeScrollBar-BDF9A1sc.cjs} +1 -1
- package/dist/{NativeScrollBar-DpZMYhmf.js → NativeScrollBar-DvdOpwIW.js} +2 -2
- package/dist/{TreeLayout-DsSKW_Qj.js → TreeLayout-Cc-ykewY.js} +2 -2
- package/dist/{TreeLayout-T8sc_wg7.cjs → TreeLayout-D_DYV64_.cjs} +1 -1
- package/dist/client/MarkdownExplorer.d.cts +4 -5
- package/dist/client/MarkdownExplorer.d.ts +4 -5
- package/dist/client/hostContract.d.cts +1 -8
- package/dist/client/hostContract.d.ts +1 -8
- package/dist/core/labels.d.cts +0 -9
- package/dist/core/labels.d.ts +0 -9
- package/dist/explorerCore-DivWkFQF.cjs +1 -0
- package/dist/{explorerCore-B3RGmMG6.js → explorerCore-EkU0mwdW.js} +310 -308
- package/dist/index-BmOU3xcK.cjs +18 -0
- package/dist/{index-D0l_BJqb.js → index-dtjghDWY.js} +2451 -2434
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +54 -55
- package/dist/{merge-Dckw7r9T.cjs → merge-BCFCL1cF.cjs} +1 -1
- package/dist/{merge-BwcqBd4c.js → merge-DC_h-t31.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 +5 -2
- package/dist/server/ports.d.ts +5 -2
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +12 -12
- package/dist/serverCore.cjs +1 -1
- package/dist/serverCore.d.cts +1 -1
- package/dist/serverCore.d.ts +1 -1
- package/dist/serverCore.js +1 -1
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/{tapScrollCircle-smKLgRa2.js → tapScrollCircle-CqMZzWjo.js} +1 -1
- package/dist/{tapScrollCircle-DyLInGck.cjs → tapScrollCircle-DVNlszeF.cjs} +1 -1
- package/docs/behavior/dom-hooks.md +8 -1
- package/docs/behavior/hosting.md +1 -1
- package/docs/behavior/localization.md +2 -2
- package/docs/behavior/security.md +1 -1
- package/docs/behavior/url-contract.md +2 -2
- package/package.json +6 -4
- package/dist/EditSurface-B70iRFkG.cjs +0 -6
- package/dist/ExplorerSplit-BNrHrIus.cjs +0 -2
- package/dist/ExplorerSplit-Bgccz2nm.js +0 -1589
- package/dist/explorerCore-CUkyKtm8.cjs +0 -1
- package/dist/index-lpL7GltU.cjs +0 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),c=require("react"),Y=require("./describeValue-Ccvhbt36.cjs"),j=require("./location-DrOP6t1F.cjs"),P=require("./index-lpL7GltU.cjs"),re=require("./ExplorerSplit-BNrHrIus.cjs"),D=require("@aiquants/drag-drop-panels"),fe=require("react-router"),ne=require("./storage-BpYsprog.cjs"),Ce=require("./ownUrls-BTPGNhBt.cjs"),qe=require("react-dom"),Be=require("@aiquants/markdown"),je=()=>{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),ie=()=>{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},Fe=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},Ve=0xcbf29ce484222325n,Ue=0x100000001b3n,$e=(1n<<64n)-1n,Ge=(1n<<53n)-1n,Ye=new TextEncoder,We=e=>{let n=Ve;for(const t of Ye.encode(e))n=(n^BigInt(t))*Ue&$e;return Number(n&Ge)},Q=256,Ke=e=>`aqmx-p-${We(e).toString(36)}`,be=(e,n)=>{const t=Ke(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Je=new Map,Xe=(e,n=Je)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??be(r,t);t.add(s),o.set(r,s)}return o},Pe=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},Te=(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},ee=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Pe(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[Te(t,n)]?.push(r);return t},Ze=(e,n)=>j.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),Qe=(e,n,t)=>{const[o,r]=n,s=r-o,a=e.length,m=Array.from({length:s},(y,d)=>{const x=[0];for(const h of e)x.push((x.at(-1)??0)+(t(h)===o+d?1:0));return x}),g=(y,d,x)=>(m[y]?.[x]??0)-(m[y]?.[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)),C=i[0];C&&(C[0]=0);for(let y=0;y<s;y+=1)for(let d=0;d<=a;d+=1)for(let x=0;x<=d;x+=1){const h=(i[y]?.[x]??Number.NEGATIVE_INFINITY)+g(y,x,d),O=i[y+1],L=v[y+1];O&&L&&h>(O[d]??Number.NEGATIVE_INFINITY)&&(O[d]=h,L[d]=x)}const T=Array.from({length:s},()=>[]);let A=a;for(let y=s;y>0;y-=1){const d=v[y]?.[A]??0;T[y-1]=e.slice(d,A),A=d}return T},Le=(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<=Q)break;o.delete(r)}return{docs:t,columnOf:o}},en=(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=ee(e,t),s=Pe(e,n,t.logical)??Te(r,t);r[s]?.push(n);const a=new Map(e.panelIds);return a.set(n,be(n,new Set(a.values()))),{state:{...e,...Le(e,r),panelIds:a},outcome:"opened"}},Me=(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}},nn=(e,n,t,o)=>{if(e.hidden.has(n))return{state:ke(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Me(e,n),outcome:"closed"};const r=en(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},tn=(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 ${Y.describeValue(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"}},ke=(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}},on=(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}},rn=(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}},sn=(e,n,t)=>{const o=ee(e,t),r=new Map;for(const[i,v]of o.entries())for(const C of v)r.set(C,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 C=(n[i]??[]).filter(T=>s.has(T)&&!a.has(T));for(const T of C)a.add(T);for(const[T,A]of Qe(C,v,y=>r.get(y)).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((C,T)=>o[v]?.[T]===C))?e:{...e,...Le(e,g)}},te=(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:Xe(t,e.panelIds)}},pe=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of ee(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=Q)break;t.delete(o)}return{...e,columnOf:t}},Re=1,U=Object.freeze({columnOf:new Map,hidden:new Set}),ln=(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!==Re)return U;const r=new Map;if(Array.isArray(o.columnOf))for(const a of o.columnOf.slice(-Q))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}},an=e=>JSON.stringify({v:Re,columnOf:[...e.columnOf.entries()].slice(-Q),hidden:e.docs.filter(n=>e.hidden.has(n))}),ae=(e,n)=>{const t=e.get(n);return t===void 0?Ce.lastPathSegment(n):t},W=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},ge=e=>{if(!Ce.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${Y.describeValue(e)}`)},cn=({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:te({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 C=l=>v?pe(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 y=T(n.source,n),d=n.source,x=y;const h=[],O=[];let L=null;const N=()=>{if(!(h.length>0))for(const l of O.splice(0))l()},R=l=>{i={...i,...l},a.emit()},u=()=>{if(!i.ready)return;const l=an(i.layout);l!==L&&(L=l,o(l))},p=(l,S,b)=>{const I=T(l,A(S));I!==y&&(y=I,d=l,h.push(I),t(I,b))},f=l=>{const S=new Set(l.panelIds.values());for(const E of[...m.keys()])S.has(E)||m.delete(E);for(const E of[...g.keys()])S.has(E)||g.delete(E);const b=new Set(l.docs),I=[...i.titles.keys()].every(E=>b.has(E))?i.titles:new Map([...i.titles].filter(([E])=>b.has(E))),w=[...i.pendingHashes.keys()].every(E=>S.has(E))?i.pendingHashes:new Map([...i.pendingHashes].filter(([E])=>S.has(E)));return{titles:I,pendingHashes:w}},M=l=>l===i.layout?!1:(R({layout:l,...f(l)}),p(d,l,"replace"),u(),!0),_=()=>({logical:s,visible:i.visibleColumns});return{getSnapshot:()=>i,subscribe:a.subscribe,toggle:l=>{ge(l);const{state:S,outcome:b}=nn(i.layout,l,_(),r);return M(S),b},close:l=>M(Me(i.layout,l)),navigate:(l,S)=>{ge(S);const{state:b,outcome:I}=tn(i.layout,l,S);if(I!=="navigated")return I;const w=b.panelIds.get(S);return w!==void 0&&(m.delete(w),g.delete(w)),M(b),I},setHidden:(l,S)=>M(ke(i.layout,l,S)),maximize:l=>M(rn(i.layout,l)),setMarkup:(l,S)=>M(on(i.layout,l,S)),arrange:l=>M(sn(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===y)return h.length=0,x=S,l.source!==i.source&&R({source:l.source}),N(),!1;if(S===x)return!1;x=S;const b=h.indexOf(S);if(b>=0)return h.splice(0,b+1),l.source!==i.source&&R({source:l.source}),N(),!1;h.length=0,y=S,d=l.source;const I=C(te({docs:l.docs,maximized:l.maximized,markup:l.markup,stored:{columnOf:i.layout.columnOf,hidden:i.layout.hidden},panelIds:i.layout.panelIds},r));return R({layout:I,source:l.source,...f(I)}),u(),N(),!0},whenUrlRendered:l=>{O.push(l),N()},loadStored:l=>{R({layout:C(te({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 ${Y.describeValue(l)}`);v=!0;const S=pe(i.layout,{logical:s,visible:l});l===i.visibleColumns&&S===i.layout||(R({visibleColumns:l,layout:S}),S!==i.layout&&u())},setSplitDragging:l=>{l!==i.splitDragging&&R({splitDragging:l})},setTitle:(l,S)=>{!i.layout.docs.includes(l)||i.titles.get(l)===S||R({titles:new Map(i.titles).set(l,S)})},titleOf:l=>ae(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),R({pendingHashes:I});return}b!==S&&R({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)},un=e=>{const{config:n,storageNamespace:t}=P.useExplorer(),o=fe.useNavigate(),r=c.useRef(o),s=ne.storageKeys(t).multiLayout,[a]=c.useState(()=>cn({config:n,location:e,writeUrl:(i,v)=>{r.current(i,P.explorerNavigationOptions(v==="replace"?"browse":"switch-source"))},persist:i=>ne.writeStorage(s,i)}));c.useLayoutEffect(()=>{r.current=o},[o]);const m=fe.useLocation(),g=c.useMemo(()=>({location:e,navigated:m}),[e,m]);return c.useLayoutEffect(()=>{a.observeLocation(g.location)},[a,g]),c.useLayoutEffect(()=>{a.loadStored(ln(ne.readStorage(s),n.multiView.columns))},[a,s,n]),a},dn=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},mn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:a,revealInPanel:m,keepAtStartInPanel:g}=ie(),{announcer:i}=P.useExplorer(),v=z(s,u=>Fe(u,n)),C=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]),y=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]),x=c.useCallback(u=>{s.whenUrlRendered(()=>i.announce(u))},[s,i]),h=c.useMemo(()=>({scrollerOf:dn,reveal:u=>m(n,u),keepAtStart:(u,p)=>g(n,u,p)}),[m,g,n]),O=c.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:T,pendingHash:v,onHashConsumed:A,announceFailure:x,paneScroll:h}),[t,T,v,A,x,h]),L=c.useMemo(()=>({kind:"panel",documentName:o,maximized:t}),[o,t]),N=c.useCallback(()=>s.setMarkup(e,!s.getSnapshot().layout.markup.has(e)),[s,e]),R=c.useMemo(()=>({shown:C,toggle:N}),[C,N]);return k.jsxs(P.ImageViewMemoryContext,{value:y,children:[k.jsx(P.DocumentRefreshBar,{path:e,placement:L,markup:R,maximize:null}),k.jsx(P.DocumentPane,{path:e,absence:P.NO_DOCUMENT,markup:C,variant:O,onDocumentShown:d})]})},he=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",ce="data-aqmx-column-probe",J="data-panel-id",se="--aqmx-multi-panel-chrome",fn=e=>e==="normal"?0:P.cssPixels(e),pn=(e,n)=>{const t=e.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${ce}]`),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:fn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:m}},gn=(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)},X="data-aqmx-panel-frame",Se="--aqmx-multi-panel-pinned-block-size",hn=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}},Sn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},xn=(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},Ae=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ne(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},xe=(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=Ae(e,n),o=[];let r=e;for(let a=xe([...r.children],t);a>=0;a=xe([...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-Ae(e,n)-m},vn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),Ie=e=>{const n=e.getAttribute(D.PANEL_ACTION_ATTRIBUTE);return JSON.stringify(n===null?[e.tagName,...vn.map(t=>e.getAttribute(t))]:[e.tagName,D.PANEL_ACTION_ATTRIBUTE,n])},wn=(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:Ie(n)}},En=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&Ie(o)===t.signature&&P.focusWithoutScroll(o)||n.focus({preventScroll:!0})},Cn=(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=xn(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,bn=e=>e.scrollHeight>e.clientHeight,Pn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ne(t),a=()=>{const i=gn(e,n);if(!Number.isFinite(i))return;const v=s===null?0:s.getBoundingClientRect().height;v!==r&&(r=v,t.style.setProperty(Se,`${String(v)}px`));const C=i+v;C!==o&&(o=C,e.style.setProperty(se,`${String(C)}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(se),t.style.removeProperty(Se)}},Tn=e=>{const{docPath:n,panelId:t}=hn(e),{store:o,Body:r,maximize:s,focusCarry:a}=ie(),m=z(o,d=>d.layout.maximized===n),g=z(o,d=>ae(d.titles,n)),i=c.useRef(null),v=c.useRef(null),C=c.useRef(null),T=c.useRef(null);c.useEffect(()=>{const d=i.current,x=d===null?null:$(d);if(d===null||x===null||m)return;const h=new Map,O=p=>{const f=h.get(p);if(f!==void 0)return f;const M=Sn(p);return h.set(p,M),M},L=p=>Cn(p,d,O);let N=!1;const R=()=>{const p=bn(x);p!==N&&(N=p,p?d.addEventListener("wheel",L,{capture:!0,passive:!1}):d.removeEventListener("wheel",L,{capture:!0}))};R();const u=typeof ResizeObserver>"u"?null:new ResizeObserver(R);return u?.observe(x),u?.observe(d),()=>{u?.disconnect(),d.removeEventListener("wheel",L,{capture:!0})}},[m]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:$(d),h=d===null?null:d.closest(`[${J}]`);if(!(d===null||x===null||!(h instanceof HTMLElement)))return Pn(h,x,d)},[]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:$(d);if(d===null||x===null)return;const h=p=>{ye(d,x,p),T.current=x.scrollTop},O=o.readingPositionOf(t,n);v.current=O===null?null:{doc:n,position:O},O!==null&&h(O);let L=null,N=d.getBoundingClientRect().width;const R=()=>{L===null&&(L=requestAnimationFrame(()=>{L=null;const p=T.current;if(T.current=null,p!==null&&x.scrollTop===p||d.getBoundingClientRect().width!==N)return;const f=C.current;f!==null&&o.saveReadingPosition(t,f,yn(d,x))}))};x.addEventListener("scroll",R,{passive:!0});const u=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const p=d.getBoundingClientRect().width;if(p===N)return;N=p;const f=o.readingPositionOf(t,n);f!==null&&h(f)});return u?.observe(d),()=>{x.removeEventListener("scroll",R),u?.disconnect(),L!==null&&cancelAnimationFrame(L)}},[o,t,n]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:d.closest(`[${J}]`);if(d===null||x===null)return;const h=a.take(t);return h!==null&&En(x,d,h),()=>{const O=wn(x,x.ownerDocument.activeElement);O!==null&&a.hold(t,O)}},[a,t]);const A=c.useCallback(d=>{const x=i.current,h=x===null?null:$(x);if(x===null||h===null)return;const O=C.current;C.current=d;const L=v.current;v.current=null,L!==null&&L.doc===d?(ye(x,h,L.position),T.current=h.scrollTop):O!==null&&O!==d&&(h.scrollTop=0)},[]),y=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:y,children:k.jsx(r,{docPath:n,panelId:t,maximized:m,title:g,onContentShown:A})})},Ln=c.memo(Tn),K=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${Y.describeValue(n)} has no panel id`);return t},ve=e=>Object.fromEntries(D.generateColumnIds(e).map(n=>[n,[]])),Mn=(e,n)=>{const t=Ze(ee(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>K(e,s))]))},kn=(e,n)=>{const t=W(e);return D.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},Rn=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",An=Object.freeze({[Nn]:`${String(P.NATIVE_SCROLL_BAR_WIDTH)}px`}),In=Object.freeze({blockSize:"100%",paddingInlineEnd:P.TAP_SCROLL_CIRCLE_GUTTER_LENGTH}),_n=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),Dn=e=>k.jsx("div",{..._n,children:k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"content"})}),zn=({props:e,children:n})=>k.jsx(Be.HostedScrollArea,{scrollerProps:{...e,style:In},renderScrollBar:Dn,barInlineSize:P.NATIVE_SCROLL_BAR_SLOT_LENGTH,children:n}),Hn=e=>k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"stage"}),ue="--aqmx-stage-block",qn="--aqmx-multi-panel-body-floor",Bn=`calc(var(${ue}) * ${String(j.PANEL_MIN_BLOCK_RATIO)})`,jn=`max(calc(var(${ue}) * ${String(j.PANEL_MAX_BLOCK_RATIO)}), calc(var(${se}) + var(${qn})))`,Fn=(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(`[${J}="${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)},Z=e=>{e.scrollIntoView(P.NEAREST)},_e=(e,n)=>{const t=e.querySelector(`[${X}="${n}"]`);return t instanceof HTMLElement?(G(e,n,null,Z),t.focus({preventScroll:!0}),!0):!1},de=(e,n)=>{const t=e.querySelector(`[${J}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},we=(e,n)=>{if(!de(e,n))return null;const t=[...e.querySelectorAll(`[${X}]`)].map(a=>a.getAttribute(X)),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"&&_e(t,n.panelId)||t.focus({preventScroll:!0}))})},De=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&_e(t,n)})},Vn=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(G(o,n,t&&de(o,n)?r:null,Z),!t||r!==null&&r!==s&&r.isConnected)return;const a=o.querySelector(`[${X}="${n}"]`);a instanceof HTMLElement&&a.focus({preventScroll:!0})})},Un=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r,edits:s}=P.useExplorer(),{maximize:a}=ie(),m=t.multiView.columns,g=z(e,w=>w.layout),i=z(e,w=>w.visibleColumns),v=z(e,w=>w.titles),C=z(e,w=>w.layout.maximized!==null||w.splitDragging),[T,A]=c.useState(!1),[y]=c.useState(()=>ve(i)),d=c.useMemo(()=>Rn(o),[o]),x=c.useCallback(w=>{e.arrange(kn(e.getSnapshot().layout,w))},[e]),h=D.useDragDropColumns({initialColumnPanels:y,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:x}),{columnPanels:O,setColumnPanels:L}=h,N=c.useRef(C),R=c.useRef(O);c.useLayoutEffect(()=>{N.current=C,R.current=O},[C,O]);const u=c.useCallback(w=>{const E=n.current;if(E===null)return;const{plan:B,stageBlockSize:H}=pn(E,m);if(Number.isFinite(H)&&H>0&&E.style.setProperty(ue,`${String(H)}px`),N.current&&!w)return;const q=j.replanVisibleColumns(e.getSnapshot().visibleColumns,B);q!==null&&e.setVisibleColumns(q)},[e,n,m]);c.useLayoutEffect(()=>{u(!0),A(!0)},[u]),c.useEffect(()=>{const w=n.current;if(w===null||typeof ResizeObserver>"u")return;let E=null;const B=new ResizeObserver(()=>{E===null&&(E=requestAnimationFrame(()=>{E=null,u(!1)}))}),H=w.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,q=w.querySelector(`[${ce}]`);return H instanceof Element&&B.observe(H),q instanceof Element&&B.observe(q),()=>{B.disconnect(),E!==null&&cancelAnimationFrame(E)}},[n,u]),c.useEffect(()=>{C||u(!1)},[C,u]);const p=c.useMemo(()=>T?Mn(g,{logical:m,visible:i}):ve(i),[T,g,m,i]);c.useLayoutEffect(()=>{Fn(R.current,p)||L(p)},[p,L]);const f=c.useMemo(()=>D.sortColumnIds(Object.keys(O)).map(w=>({id:w,key:w,className:"aqmx-multi-column"})),[O]),M=c.useMemo(()=>g.docs.map(w=>{const E=K(g,w);return{id:E,component:Ln,title:ae(v,w),props:{docPath:w,panelId:E},minHeight:Bn,maxHeight:jn}}),[g,v]),_=c.useMemo(()=>Object.fromEntries(g.docs.map(w=>[K(g,w),!g.hidden.has(w)])),[g]),l=g.maximized===null?null:K(g,g.maximized),S=c.useCallback(w=>{const{layout:E}=e.getSnapshot();for(const[B,H]of W(E)){const q=w[B];if(q===void 0||q!==E.hidden.has(H))continue;const F=e.titleOf(H);if(q){if(!e.setHidden(H,!1))continue;r.announce(o.panelShown(F)),De(n,B);continue}const V=n.current,me=V===null?null:we(V,B);e.setHidden(H,!0)&&(r.announce(o.panelHidden(F)),me!==null&&Ee(n,me))}},[e,n,r,o]),b=c.useCallback(w=>{const E=W(e.getSnapshot().layout).get(w);if(E===void 0)return;const B=()=>{const q=e.titleOf(E),F=n.current,V=F===null?null:we(F,w);e.close(E)&&(r.announce(o.panelClosed(q)),V!==null&&Ee(n,V))},H=s.unsavedAmong([E]);H.length===0?B():s.askToDiscard(H).then(q=>{q&&B()})},[e,n,r,o,s]),I=c.useCallback(w=>{if(w===null){a(null);return}const E=W(e.getSnapshot().layout).get(w);E!==void 0&&a(E)},[e,a]);return k.jsx("div",{className:"aqmx-multi-layout","aria-busy":!T,children:k.jsx(D.DragDropLayout,{columns:f,panels:M,columnPanels:O,onColumnPanelsChange:x,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:zn,renderStageScrollBar:Hn})})},oe={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},$n=(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}))},Gn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(oe.blockStart,`${String(t.top)}px`),e.style.setProperty(oe.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(oe.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Yn=({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),C=z(e,u=>u.ready),T=z(e,u=>u.layout.docs.length>0),A=z(e,u=>u.visibleColumns),y=c.use(re.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&&de(_,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&&Vn(i,M,l))},[e,m,a]),x=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&&x(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),De(i,b))},[e,m,a,d,g]);c.useLayoutEffect(()=>{if(t===null||y!==null||!he())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 Gn(u,p)},[t,y]),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&&$n(u,l)&&o()}))};return p.addEventListener("focusin",M,!0),()=>{p.removeEventListener("focusin",M,!0),f!==null&&cancelAnimationFrame(f)}},[t,y,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,Z)})}}),[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,Z)},[]),O=c.useCallback((u,p,f)=>{const M=i.current;M!==null&&G(M,u,f,_=>P.alignToStart(p,_))},[]),[L]=c.useState(je),N=c.useMemo(()=>({store:e,Body:n,followLink:x,maximize:d,revealInPanel:h,keepAtStartInPanel:O,focusCarry:L}),[e,n,x,d,h,O,L]),R=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:An,tabIndex:-1,"aria-label":a.multiRegion,"aria-busy":T&&!C,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":A,...P.CONTENT_PANE,children:[k.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[ce]:""}),T?C?k.jsx(Oe,{value:N,children:k.jsx(Un,{store:e,stageRef:i})}):k.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:R.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:y!==null?qe.createPortal(k.jsx("div",{ref:v,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),y):k.jsx("div",{ref:v,popover:he()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},ze=3e3,He=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},le=(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},Wn=(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 ${Y.describeValue(o)}`)}}},Kn=({location:e})=>{const{config:n,labels:t,announcer:o}=P.useExplorer(),r=un(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:le([],s,null)}));i.docs!==s&&v({docs:s,latest:le(i.docs,s,i.latest)});const C=a!==null?a:i.latest,[T,A]=c.useState(!1),y=c.useRef(null),[d,x]=c.useState(0),h=c.useRef(null),O=c.useRef(null);c.useLayoutEffect(()=>{const f=h.current;h.current=null,f!==null&&(r.whenUrlRendered(()=>o.announce(f.announcement)),O.current?.bringIntoView(f.doc))}),c.useEffect(()=>()=>{y.current!==null&&clearTimeout(y.current)},[]);const L=c.useCallback(()=>{y.current!==null&&clearTimeout(y.current),A(!0),y.current=setTimeout(()=>{y.current=null,A(!1)},ze)},[]),N=c.useCallback(()=>{y.current!==null&&clearTimeout(y.current),y.current=null,A(!1)},[]),R=c.useCallback(f=>{const M=r.titleOf(f),_=r.toggle(f);_==="rejected"&&L();const l=_==="rejected"?t.panelLimit(n.multiView.maxPanels):Wn(t,_,M);if(_==="shown"){h.current={doc:f,announcement:l},x(S=>S+1);return}r.whenUrlRendered(()=>{o.announce(l),_==="opened"&&O.current?.bringIntoView(f)})},[r,L,o,t,n]),u=c.useMemo(()=>new Set(s),[s]),p=c.useMemo(()=>{const f=He(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(re.ExplorerSplit,{view:"multi",explorer:k.jsx(re.ExplorerPane,{mode:"multi",sourceId:g,currentPath:C,openPaths:u,onOpenDocument:R,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:p}),content:k.jsx(Yn,{ref:O,store:r,body:mn,limitNotice:T?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:N}),contentCoversPage:a!==null,sheetDismissals:d,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Kn;exports.PANEL_LIMIT_NOTICE_MS=ze;exports.latestOpenedDocument=le;exports.treeSwitchDocument=He;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),c=require("react"),Y=require("./describeValue-Ccvhbt36.cjs"),j=require("./location-DrOP6t1F.cjs"),P=require("./index-BmOU3xcK.cjs"),re=require("./ExplorerSplit-C_3FChSt.cjs"),D=require("@aiquants/drag-drop-panels"),fe=require("react-router"),ne=require("./storage-BpYsprog.cjs"),Ce=require("./ownUrls-BTPGNhBt.cjs"),qe=require("react-dom"),Be=require("@aiquants/markdown"),je=()=>{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),ie=()=>{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},Fe=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},Ve=0xcbf29ce484222325n,Ue=0x100000001b3n,$e=(1n<<64n)-1n,Ge=(1n<<53n)-1n,Ye=new TextEncoder,We=e=>{let n=Ve;for(const t of Ye.encode(e))n=(n^BigInt(t))*Ue&$e;return Number(n&Ge)},Q=256,Ke=e=>`aqmx-p-${We(e).toString(36)}`,be=(e,n)=>{const t=Ke(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Je=new Map,Xe=(e,n=Je)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??be(r,t);t.add(s),o.set(r,s)}return o},Pe=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},Te=(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},ee=(e,n)=>{const t=Array.from({length:n.logical},()=>[]),o=[];for(const r of e.docs){const s=Pe(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[Te(t,n)]?.push(r);return t},Ze=(e,n)=>j.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),Qe=(e,n,t)=>{const[o,r]=n,s=r-o,a=e.length,m=Array.from({length:s},(y,d)=>{const x=[0];for(const h of e)x.push((x.at(-1)??0)+(t(h)===o+d?1:0));return x}),g=(y,d,x)=>(m[y]?.[x]??0)-(m[y]?.[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)),C=i[0];C&&(C[0]=0);for(let y=0;y<s;y+=1)for(let d=0;d<=a;d+=1)for(let x=0;x<=d;x+=1){const h=(i[y]?.[x]??Number.NEGATIVE_INFINITY)+g(y,x,d),O=i[y+1],L=v[y+1];O&&L&&h>(O[d]??Number.NEGATIVE_INFINITY)&&(O[d]=h,L[d]=x)}const T=Array.from({length:s},()=>[]);let A=a;for(let y=s;y>0;y-=1){const d=v[y]?.[A]??0;T[y-1]=e.slice(d,A),A=d}return T},Le=(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<=Q)break;o.delete(r)}return{docs:t,columnOf:o}},en=(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=ee(e,t),s=Pe(e,n,t.logical)??Te(r,t);r[s]?.push(n);const a=new Map(e.panelIds);return a.set(n,be(n,new Set(a.values()))),{state:{...e,...Le(e,r),panelIds:a},outcome:"opened"}},Me=(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}},nn=(e,n,t,o)=>{if(e.hidden.has(n))return{state:ke(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Me(e,n),outcome:"closed"};const r=en(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},tn=(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 ${Y.describeValue(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"}},ke=(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}},on=(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}},rn=(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}},sn=(e,n,t)=>{const o=ee(e,t),r=new Map;for(const[i,v]of o.entries())for(const C of v)r.set(C,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 C=(n[i]??[]).filter(T=>s.has(T)&&!a.has(T));for(const T of C)a.add(T);for(const[T,A]of Qe(C,v,y=>r.get(y)).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((C,T)=>o[v]?.[T]===C))?e:{...e,...Le(e,g)}},te=(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:Xe(t,e.panelIds)}},pe=(e,n)=>{if(e.docs.every(o=>e.columnOf.has(o)))return e;const t=new Map(e.columnOf);for(const[o,r]of ee(e,n).entries())for(const s of r)t.delete(s),t.set(s,o);for(const o of t.keys()){if(t.size<=Q)break;t.delete(o)}return{...e,columnOf:t}},Re=1,U=Object.freeze({columnOf:new Map,hidden:new Set}),ln=(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!==Re)return U;const r=new Map;if(Array.isArray(o.columnOf))for(const a of o.columnOf.slice(-Q))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}},an=e=>JSON.stringify({v:Re,columnOf:[...e.columnOf.entries()].slice(-Q),hidden:e.docs.filter(n=>e.hidden.has(n))}),ae=(e,n)=>{const t=e.get(n);return t===void 0?Ce.lastPathSegment(n):t},W=e=>{const n=new Map;for(const[t,o]of e.panelIds)n.set(o,t);return n},ge=e=>{if(!Ce.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${Y.describeValue(e)}`)},cn=({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:te({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 C=l=>v?pe(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 y=T(n.source,n),d=n.source,x=y;const h=[],O=[];let L=null;const N=()=>{if(!(h.length>0))for(const l of O.splice(0))l()},R=l=>{i={...i,...l},a.emit()},u=()=>{if(!i.ready)return;const l=an(i.layout);l!==L&&(L=l,o(l))},p=(l,S,b)=>{const I=T(l,A(S));I!==y&&(y=I,d=l,h.push(I),t(I,b))},f=l=>{const S=new Set(l.panelIds.values());for(const E of[...m.keys()])S.has(E)||m.delete(E);for(const E of[...g.keys()])S.has(E)||g.delete(E);const b=new Set(l.docs),I=[...i.titles.keys()].every(E=>b.has(E))?i.titles:new Map([...i.titles].filter(([E])=>b.has(E))),w=[...i.pendingHashes.keys()].every(E=>S.has(E))?i.pendingHashes:new Map([...i.pendingHashes].filter(([E])=>S.has(E)));return{titles:I,pendingHashes:w}},M=l=>l===i.layout?!1:(R({layout:l,...f(l)}),p(d,l,"replace"),u(),!0),_=()=>({logical:s,visible:i.visibleColumns});return{getSnapshot:()=>i,subscribe:a.subscribe,toggle:l=>{ge(l);const{state:S,outcome:b}=nn(i.layout,l,_(),r);return M(S),b},close:l=>M(Me(i.layout,l)),navigate:(l,S)=>{ge(S);const{state:b,outcome:I}=tn(i.layout,l,S);if(I!=="navigated")return I;const w=b.panelIds.get(S);return w!==void 0&&(m.delete(w),g.delete(w)),M(b),I},setHidden:(l,S)=>M(ke(i.layout,l,S)),maximize:l=>M(rn(i.layout,l)),setMarkup:(l,S)=>M(on(i.layout,l,S)),arrange:l=>M(sn(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===y)return h.length=0,x=S,l.source!==i.source&&R({source:l.source}),N(),!1;if(S===x)return!1;x=S;const b=h.indexOf(S);if(b>=0)return h.splice(0,b+1),l.source!==i.source&&R({source:l.source}),N(),!1;h.length=0,y=S,d=l.source;const I=C(te({docs:l.docs,maximized:l.maximized,markup:l.markup,stored:{columnOf:i.layout.columnOf,hidden:i.layout.hidden},panelIds:i.layout.panelIds},r));return R({layout:I,source:l.source,...f(I)}),u(),N(),!0},whenUrlRendered:l=>{O.push(l),N()},loadStored:l=>{R({layout:C(te({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 ${Y.describeValue(l)}`);v=!0;const S=pe(i.layout,{logical:s,visible:l});l===i.visibleColumns&&S===i.layout||(R({visibleColumns:l,layout:S}),S!==i.layout&&u())},setSplitDragging:l=>{l!==i.splitDragging&&R({splitDragging:l})},setTitle:(l,S)=>{!i.layout.docs.includes(l)||i.titles.get(l)===S||R({titles:new Map(i.titles).set(l,S)})},titleOf:l=>ae(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),R({pendingHashes:I});return}b!==S&&R({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)},un=e=>{const{config:n,storageNamespace:t}=P.useExplorer(),o=fe.useNavigate(),r=c.useRef(o),s=ne.storageKeys(t).multiLayout,[a]=c.useState(()=>cn({config:n,location:e,writeUrl:(i,v)=>{r.current(i,P.explorerNavigationOptions(v==="replace"?"browse":"switch-source"))},persist:i=>ne.writeStorage(s,i)}));c.useLayoutEffect(()=>{r.current=o},[o]);const m=fe.useLocation(),g=c.useMemo(()=>({location:e,navigated:m}),[e,m]);return c.useLayoutEffect(()=>{a.observeLocation(g.location)},[a,g]),c.useLayoutEffect(()=>{a.loadStored(ln(ne.readStorage(s),n.multiView.columns))},[a,s,n]),a},dn=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},mn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:a,revealInPanel:m,keepAtStartInPanel:g}=ie(),{announcer:i}=P.useExplorer(),v=z(s,u=>Fe(u,n)),C=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]),y=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]),x=c.useCallback(u=>{s.whenUrlRendered(()=>i.announce(u))},[s,i]),h=c.useMemo(()=>({scrollerOf:dn,reveal:u=>m(n,u),keepAtStart:(u,p)=>g(n,u,p)}),[m,g,n]),O=c.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:T,pendingHash:v,onHashConsumed:A,announceFailure:x,paneScroll:h}),[t,T,v,A,x,h]),L=c.useMemo(()=>({kind:"panel",documentName:o,maximized:t}),[o,t]),N=c.useCallback(()=>s.setMarkup(e,!s.getSnapshot().layout.markup.has(e)),[s,e]),R=c.useMemo(()=>({shown:C,toggle:N}),[C,N]);return k.jsxs(P.ImageViewMemoryContext,{value:y,children:[k.jsx(P.DocumentRefreshBar,{path:e,placement:L,markup:R,maximize:null}),k.jsx(P.DocumentPane,{path:e,absence:P.NO_DOCUMENT,markup:C,variant:O,onDocumentShown:d})]})},he=()=>typeof HTMLElement<"u"&&typeof HTMLElement.prototype.showPopover=="function"&&typeof HTMLElement.prototype.hidePopover=="function",ce="data-aqmx-column-probe",J="data-panel-id",se="--aqmx-multi-panel-chrome",fn=e=>e==="normal"?0:P.cssPixels(e),pn=(e,n)=>{const t=e.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,o=e.querySelector(`[${ce}]`),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:fn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:m}},gn=(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)},X="data-aqmx-panel-frame",Se="--aqmx-multi-panel-pinned-block-size",hn=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}},Sn=e=>{const n=getComputedStyle(e),t=Number.parseFloat(n.lineHeight);return Number.isFinite(t)?t:Number.parseFloat(n.fontSize)},xn=(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},Ae=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ne(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},xe=(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=Ae(e,n),o=[];let r=e;for(let a=xe([...r.children],t);a>=0;a=xe([...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-Ae(e,n)-m},vn=Object.freeze(["data-testid","aria-label","title","href","id","name"]),Ie=e=>{const n=e.getAttribute(D.PANEL_ACTION_ATTRIBUTE);return JSON.stringify(n===null?[e.tagName,...vn.map(t=>e.getAttribute(t))]:[e.tagName,D.PANEL_ACTION_ATTRIBUTE,n])},wn=(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:Ie(n)}},En=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&Ie(o)===t.signature&&P.focusWithoutScroll(o)||n.focus({preventScroll:!0})},Cn=(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=xn(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,bn=e=>e.scrollHeight>e.clientHeight,Pn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ne(t),a=()=>{const i=gn(e,n);if(!Number.isFinite(i))return;const v=s===null?0:s.getBoundingClientRect().height;v!==r&&(r=v,t.style.setProperty(Se,`${String(v)}px`));const C=i+v;C!==o&&(o=C,e.style.setProperty(se,`${String(C)}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(se),t.style.removeProperty(Se)}},Tn=e=>{const{docPath:n,panelId:t}=hn(e),{store:o,Body:r,maximize:s,focusCarry:a}=ie(),m=z(o,d=>d.layout.maximized===n),g=z(o,d=>ae(d.titles,n)),i=c.useRef(null),v=c.useRef(null),C=c.useRef(null),T=c.useRef(null);c.useEffect(()=>{const d=i.current,x=d===null?null:$(d);if(d===null||x===null||m)return;const h=new Map,O=p=>{const f=h.get(p);if(f!==void 0)return f;const M=Sn(p);return h.set(p,M),M},L=p=>Cn(p,d,O);let N=!1;const R=()=>{const p=bn(x);p!==N&&(N=p,p?d.addEventListener("wheel",L,{capture:!0,passive:!1}):d.removeEventListener("wheel",L,{capture:!0}))};R();const u=typeof ResizeObserver>"u"?null:new ResizeObserver(R);return u?.observe(x),u?.observe(d),()=>{u?.disconnect(),d.removeEventListener("wheel",L,{capture:!0})}},[m]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:$(d),h=d===null?null:d.closest(`[${J}]`);if(!(d===null||x===null||!(h instanceof HTMLElement)))return Pn(h,x,d)},[]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:$(d);if(d===null||x===null)return;const h=p=>{ye(d,x,p),T.current=x.scrollTop},O=o.readingPositionOf(t,n);v.current=O===null?null:{doc:n,position:O},O!==null&&h(O);let L=null,N=d.getBoundingClientRect().width;const R=()=>{L===null&&(L=requestAnimationFrame(()=>{L=null;const p=T.current;if(T.current=null,p!==null&&x.scrollTop===p||d.getBoundingClientRect().width!==N)return;const f=C.current;f!==null&&o.saveReadingPosition(t,f,yn(d,x))}))};x.addEventListener("scroll",R,{passive:!0});const u=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const p=d.getBoundingClientRect().width;if(p===N)return;N=p;const f=o.readingPositionOf(t,n);f!==null&&h(f)});return u?.observe(d),()=>{x.removeEventListener("scroll",R),u?.disconnect(),L!==null&&cancelAnimationFrame(L)}},[o,t,n]),c.useLayoutEffect(()=>{const d=i.current,x=d===null?null:d.closest(`[${J}]`);if(d===null||x===null)return;const h=a.take(t);return h!==null&&En(x,d,h),()=>{const O=wn(x,x.ownerDocument.activeElement);O!==null&&a.hold(t,O)}},[a,t]);const A=c.useCallback(d=>{const x=i.current,h=x===null?null:$(x);if(x===null||h===null)return;const O=C.current;C.current=d;const L=v.current;v.current=null,L!==null&&L.doc===d?(ye(x,h,L.position),T.current=h.scrollTop):O!==null&&O!==d&&(h.scrollTop=0)},[]),y=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:y,children:k.jsx(r,{docPath:n,panelId:t,maximized:m,title:g,onContentShown:A})})},Ln=c.memo(Tn),K=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${Y.describeValue(n)} has no panel id`);return t},ve=e=>Object.fromEntries(D.generateColumnIds(e).map(n=>[n,[]])),Mn=(e,n)=>{const t=Ze(ee(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>K(e,s))]))},kn=(e,n)=>{const t=W(e);return D.sortColumnIds(Object.keys(n)).map(o=>(n[o]??[]).flatMap(r=>{const s=t.get(r);return s===void 0?[]:[s]}))},Rn=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",An=Object.freeze({[Nn]:`${String(P.NATIVE_SCROLL_BAR_WIDTH)}px`}),In=Object.freeze({blockSize:"100%",paddingInlineEnd:P.TAP_SCROLL_CIRCLE_GUTTER_LENGTH}),_n=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),Dn=e=>k.jsx("div",{..._n,children:k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"content"})}),zn=({props:e,children:n})=>k.jsx(Be.HostedScrollArea,{scrollerProps:{...e,style:In},renderScrollBar:Dn,barInlineSize:P.NATIVE_SCROLL_BAR_SLOT_LENGTH,children:n}),Hn=e=>k.jsx(P.LazyNativeScrollBar,{scroller:e,kind:"stage"}),ue="--aqmx-stage-block",qn="--aqmx-multi-panel-body-floor",Bn=`calc(var(${ue}) * ${String(j.PANEL_MIN_BLOCK_RATIO)})`,jn=`max(calc(var(${ue}) * ${String(j.PANEL_MAX_BLOCK_RATIO)}), calc(var(${se}) + var(${qn})))`,Fn=(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(`[${J}="${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)},Z=e=>{e.scrollIntoView(P.NEAREST)},_e=(e,n)=>{const t=e.querySelector(`[${X}="${n}"]`);return t instanceof HTMLElement?(G(e,n,null,Z),t.focus({preventScroll:!0}),!0):!1},de=(e,n)=>{const t=e.querySelector(`[${J}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},we=(e,n)=>{if(!de(e,n))return null;const t=[...e.querySelectorAll(`[${X}]`)].map(a=>a.getAttribute(X)),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"&&_e(t,n.panelId)||t.focus({preventScroll:!0}))})},De=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&_e(t,n)})},Vn=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(G(o,n,t&&de(o,n)?r:null,Z),!t||r!==null&&r!==s&&r.isConnected)return;const a=o.querySelector(`[${X}="${n}"]`);a instanceof HTMLElement&&a.focus({preventScroll:!0})})},Un=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r,edits:s}=P.useExplorer(),{maximize:a}=ie(),m=t.multiView.columns,g=z(e,w=>w.layout),i=z(e,w=>w.visibleColumns),v=z(e,w=>w.titles),C=z(e,w=>w.layout.maximized!==null||w.splitDragging),[T,A]=c.useState(!1),[y]=c.useState(()=>ve(i)),d=c.useMemo(()=>Rn(o),[o]),x=c.useCallback(w=>{e.arrange(kn(e.getSnapshot().layout,w))},[e]),h=D.useDragDropColumns({initialColumnPanels:y,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:x}),{columnPanels:O,setColumnPanels:L}=h,N=c.useRef(C),R=c.useRef(O);c.useLayoutEffect(()=>{N.current=C,R.current=O},[C,O]);const u=c.useCallback(w=>{const E=n.current;if(E===null)return;const{plan:B,stageBlockSize:H}=pn(E,m);if(Number.isFinite(H)&&H>0&&E.style.setProperty(ue,`${String(H)}px`),N.current&&!w)return;const q=j.replanVisibleColumns(e.getSnapshot().visibleColumns,B);q!==null&&e.setVisibleColumns(q)},[e,n,m]);c.useLayoutEffect(()=>{u(!0),A(!0)},[u]),c.useEffect(()=>{const w=n.current;if(w===null||typeof ResizeObserver>"u")return;let E=null;const B=new ResizeObserver(()=>{E===null&&(E=requestAnimationFrame(()=>{E=null,u(!1)}))}),H=w.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,q=w.querySelector(`[${ce}]`);return H instanceof Element&&B.observe(H),q instanceof Element&&B.observe(q),()=>{B.disconnect(),E!==null&&cancelAnimationFrame(E)}},[n,u]),c.useEffect(()=>{C||u(!1)},[C,u]);const p=c.useMemo(()=>T?Mn(g,{logical:m,visible:i}):ve(i),[T,g,m,i]);c.useLayoutEffect(()=>{Fn(R.current,p)||L(p)},[p,L]);const f=c.useMemo(()=>D.sortColumnIds(Object.keys(O)).map(w=>({id:w,key:w,className:"aqmx-multi-column"})),[O]),M=c.useMemo(()=>g.docs.map(w=>{const E=K(g,w);return{id:E,component:Ln,title:ae(v,w),props:{docPath:w,panelId:E},minHeight:Bn,maxHeight:jn}}),[g,v]),_=c.useMemo(()=>Object.fromEntries(g.docs.map(w=>[K(g,w),!g.hidden.has(w)])),[g]),l=g.maximized===null?null:K(g,g.maximized),S=c.useCallback(w=>{const{layout:E}=e.getSnapshot();for(const[B,H]of W(E)){const q=w[B];if(q===void 0||q!==E.hidden.has(H))continue;const F=e.titleOf(H);if(q){if(!e.setHidden(H,!1))continue;r.announce(o.panelShown(F)),De(n,B);continue}const V=n.current,me=V===null?null:we(V,B);e.setHidden(H,!0)&&(r.announce(o.panelHidden(F)),me!==null&&Ee(n,me))}},[e,n,r,o]),b=c.useCallback(w=>{const E=W(e.getSnapshot().layout).get(w);if(E===void 0)return;const B=()=>{const q=e.titleOf(E),F=n.current,V=F===null?null:we(F,w);e.close(E)&&(r.announce(o.panelClosed(q)),V!==null&&Ee(n,V))},H=s.unsavedAmong([E]);H.length===0?B():s.askToDiscard(H).then(q=>{q&&B()})},[e,n,r,o,s]),I=c.useCallback(w=>{if(w===null){a(null);return}const E=W(e.getSnapshot().layout).get(w);E!==void 0&&a(E)},[e,a]);return k.jsx("div",{className:"aqmx-multi-layout","aria-busy":!T,children:k.jsx(D.DragDropLayout,{columns:f,panels:M,columnPanels:O,onColumnPanelsChange:x,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:zn,renderStageScrollBar:Hn})})},oe={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},$n=(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}))},Gn=(e,n)=>{const t=n.getBoundingClientRect(),o=n.ownerDocument.documentElement.clientWidth,r=getComputedStyle(n).direction==="rtl";return e.style.setProperty(oe.blockStart,`${String(t.top)}px`),e.style.setProperty(oe.inlineEnd,`${String(r?t.left:o-t.right)}px`),e.style.setProperty(oe.room,`${String(t.width)}px`),e.showPopover(),()=>{e.isConnected&&e.hidePopover()}},Yn=({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),C=z(e,u=>u.ready),T=z(e,u=>u.layout.docs.length>0),A=z(e,u=>u.visibleColumns),y=c.use(re.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&&de(_,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&&Vn(i,M,l))},[e,m,a]),x=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&&x(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),De(i,b))},[e,m,a,d,g]);c.useLayoutEffect(()=>{if(t===null||y!==null||!he())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 Gn(u,p)},[t,y]),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&&$n(u,l)&&o()}))};return p.addEventListener("focusin",M,!0),()=>{p.removeEventListener("focusin",M,!0),f!==null&&cancelAnimationFrame(f)}},[t,y,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,Z)})}}),[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,Z)},[]),O=c.useCallback((u,p,f)=>{const M=i.current;M!==null&&G(M,u,f,_=>P.alignToStart(p,_))},[]),[L]=c.useState(je),N=c.useMemo(()=>({store:e,Body:n,followLink:x,maximize:d,revealInPanel:h,keepAtStartInPanel:O,focusCarry:L}),[e,n,x,d,h,O,L]),R=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:An,tabIndex:-1,"aria-label":a.multiRegion,"aria-busy":T&&!C,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":A,...P.CONTENT_PANE,children:[k.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[ce]:""}),T?C?k.jsx(Oe,{value:N,children:k.jsx(Un,{store:e,stageRef:i})}):k.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:R.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:y!==null?qe.createPortal(k.jsx("div",{ref:v,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),y):k.jsx("div",{ref:v,popover:he()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},ze=3e3,He=(e,n)=>{if(n!==null)return n;const[t]=e;return t===void 0?null:t},le=(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},Wn=(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 ${Y.describeValue(o)}`)}}},Kn=({location:e})=>{const{config:n,labels:t,announcer:o}=P.useExplorer(),r=un(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:le([],s,null)}));i.docs!==s&&v({docs:s,latest:le(i.docs,s,i.latest)});const C=a!==null?a:i.latest,[T,A]=c.useState(!1),y=c.useRef(null),[d,x]=c.useState(0),h=c.useRef(null),O=c.useRef(null);c.useLayoutEffect(()=>{const f=h.current;h.current=null,f!==null&&(r.whenUrlRendered(()=>o.announce(f.announcement)),O.current?.bringIntoView(f.doc))}),c.useEffect(()=>()=>{y.current!==null&&clearTimeout(y.current)},[]);const L=c.useCallback(()=>{y.current!==null&&clearTimeout(y.current),A(!0),y.current=setTimeout(()=>{y.current=null,A(!1)},ze)},[]),N=c.useCallback(()=>{y.current!==null&&clearTimeout(y.current),y.current=null,A(!1)},[]),R=c.useCallback(f=>{const M=r.titleOf(f),_=r.toggle(f);_==="rejected"&&L();const l=_==="rejected"?t.panelLimit(n.multiView.maxPanels):Wn(t,_,M);if(_==="shown"){h.current={doc:f,announcement:l},x(S=>S+1);return}r.whenUrlRendered(()=>{o.announce(l),_==="opened"&&O.current?.bringIntoView(f)})},[r,L,o,t,n]),u=c.useMemo(()=>new Set(s),[s]),p=c.useMemo(()=>{const f=He(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(re.ExplorerSplit,{view:"multi",explorer:k.jsx(re.ExplorerPane,{mode:"multi",sourceId:g,currentPath:C,openPaths:u,onOpenDocument:R,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:p}),content:k.jsx(Yn,{ref:O,store:r,body:mn,limitNotice:T?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:N}),contentCoversPage:a!==null,sheetDismissals:d,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Kn;exports.PANEL_LIMIT_NOTICE_MS=ze;exports.latestOpenedDocument=le;exports.treeSwitchDocument=He;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs as ae, jsx as A } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { d as
|
|
2
|
+
import { createContext as Je, use as Ae, useRef as q, useState as $, useLayoutEffect as F, useMemo as D, useSyncExternalStore as Ze, useCallback as R, memo as Qe, useEffect as U, useImperativeHandle as en } from "react";
|
|
3
|
+
import { d as X } from "./describeValue-CLlVRO8d.js";
|
|
4
4
|
import { s as ue, e as Me, u as nn, P as tn, v as on } from "./location-Dh6K-y7w.js";
|
|
5
|
-
import {
|
|
6
|
-
import { S as wn, a as yn, b as Sn } from "./ExplorerSplit-
|
|
5
|
+
import { U as rn, u as J, V as ln, W as sn, D as an, j as cn, g as un, X as V, L as dn, i as ke, Y as mn, N as fn, Z as Ie, _ as pn, $ as gn, a0 as Le, a1 as hn, a2 as Re, a3 as vn } from "./index-dtjghDWY.js";
|
|
6
|
+
import { S as wn, a as yn, b as Sn } from "./ExplorerSplit-C_kaEnyM.js";
|
|
7
7
|
import { SCROLL_AREA_SELECTOR as De, SCROLL_ROOT_SELECTOR as oe, PANEL_ACTION_ATTRIBUTE as ve, generateColumnIds as xn, sortColumnIds as _e, generateColumnId as ze, NO_PANEL_DRAG_ATTRIBUTE as En, useDragDropColumns as On, DEFAULT_DEBUG_CONFIG as we, DragDropLayout as Pn } from "@aiquants/drag-drop-panels";
|
|
8
8
|
import { useNavigate as bn, useLocation as Cn } from "react-router";
|
|
9
9
|
import { s as Tn, r as Nn, w as An } from "./storage-D1uSw-xj.js";
|
|
@@ -23,7 +23,7 @@ const Rn = () => {
|
|
|
23
23
|
return e.delete(n), t === void 0 ? null : t;
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
}, He =
|
|
26
|
+
}, He = Je(null), de = () => {
|
|
27
27
|
const e = Ae(He);
|
|
28
28
|
if (e === null) throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");
|
|
29
29
|
return e;
|
|
@@ -125,7 +125,7 @@ const Rn = () => {
|
|
|
125
125
|
const l = new Set(e.hidden);
|
|
126
126
|
l.delete(n);
|
|
127
127
|
const a = new Map(e.panelIds), d = a.get(n);
|
|
128
|
-
if (d === void 0) throw new Error(`[markdown-explorer] the open document ${
|
|
128
|
+
if (d === void 0) throw new Error(`[markdown-explorer] the open document ${X(n)} has no panel id`);
|
|
129
129
|
a.delete(n), a.set(t, d);
|
|
130
130
|
const p = new Set(e.markup);
|
|
131
131
|
return p.delete(n), {
|
|
@@ -136,11 +136,11 @@ const Rn = () => {
|
|
|
136
136
|
if (!e.docs.includes(n) || e.hidden.has(n) === t) return e;
|
|
137
137
|
const o = new Set(e.hidden);
|
|
138
138
|
return t ? o.add(n) : o.delete(n), { ...e, hidden: o, maximized: t && e.maximized === n ? null : e.maximized };
|
|
139
|
-
},
|
|
139
|
+
}, Xn = (e, n, t) => {
|
|
140
140
|
if (!e.docs.includes(n) || e.markup.has(n) === t) return e;
|
|
141
141
|
const o = new Set(e.markup);
|
|
142
142
|
return t ? o.add(n) : o.delete(n), { ...e, markup: o };
|
|
143
|
-
},
|
|
143
|
+
}, Jn = (e, n) => {
|
|
144
144
|
if (e.maximized === n || n !== null && !e.docs.includes(n)) return e;
|
|
145
145
|
if (n === null || !e.hidden.has(n)) return { ...e, maximized: n };
|
|
146
146
|
const t = new Set(e.hidden);
|
|
@@ -209,7 +209,7 @@ const Rn = () => {
|
|
|
209
209
|
for (const [t, o] of e.panelIds) n.set(o, t);
|
|
210
210
|
return n;
|
|
211
211
|
}, Se = (e) => {
|
|
212
|
-
if (!kn(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${
|
|
212
|
+
if (!kn(e)) throw new RangeError(`[markdown-explorer] not an acceptable document path: ${X(e)}`);
|
|
213
213
|
}, nt = ({ config: e, location: n, writeUrl: t, persist: o }) => {
|
|
214
214
|
const { maxPanels: r, columns: l } = e.multiView, a = rn(), d = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
|
|
215
215
|
let i = {
|
|
@@ -261,8 +261,8 @@ const Rn = () => {
|
|
|
261
261
|
return S !== void 0 && (d.delete(S), p.delete(S)), T(P), I;
|
|
262
262
|
},
|
|
263
263
|
setHidden: (s, h) => T(Ue(i.layout, s, h)),
|
|
264
|
-
maximize: (s) => T(
|
|
265
|
-
setMarkup: (s, h) => T(
|
|
264
|
+
maximize: (s) => T(Jn(i.layout, s)),
|
|
265
|
+
setMarkup: (s, h) => T(Xn(i.layout, s, h)),
|
|
266
266
|
arrange: (s) => T(Zn(i.layout, s, { logical: l, visible: s.length })),
|
|
267
267
|
changeSource: (s) => {
|
|
268
268
|
f(s, i.layout, "push");
|
|
@@ -290,7 +290,7 @@ const Rn = () => {
|
|
|
290
290
|
N({ layout: E(se({ docs: i.layout.docs, maximized: i.layout.maximized, markup: [...i.layout.markup], stored: s, panelIds: i.layout.panelIds }, r)), ready: !0 }), c();
|
|
291
291
|
},
|
|
292
292
|
setVisibleColumns: (s) => {
|
|
293
|
-
if (!Number.isInteger(s) || s < 1 || s > l) throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(l)}; got ${
|
|
293
|
+
if (!Number.isInteger(s) || s < 1 || s > l) throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(l)}; got ${X(s)}`);
|
|
294
294
|
y = !0;
|
|
295
295
|
const h = ye(i.layout, { logical: l, visible: s });
|
|
296
296
|
s === i.visibleColumns && h === i.layout || (N({ visibleColumns: s, layout: h }), h !== i.layout && c());
|
|
@@ -331,7 +331,7 @@ const Rn = () => {
|
|
|
331
331
|
const t = () => n(e.getSnapshot());
|
|
332
332
|
return Ze(e.subscribe, t, t);
|
|
333
333
|
}, tt = (e) => {
|
|
334
|
-
const { config: n, storageNamespace: t } =
|
|
334
|
+
const { config: n, storageNamespace: t } = J(), o = bn(), r = q(o), l = Tn(t).multiLayout, [a] = $(
|
|
335
335
|
() => nt({
|
|
336
336
|
config: n,
|
|
337
337
|
location: e,
|
|
@@ -355,7 +355,7 @@ const Rn = () => {
|
|
|
355
355
|
if (n === null) throw new Error("[markdown-explorer] a panel's document region is not inside the panel's scroll area");
|
|
356
356
|
return n;
|
|
357
357
|
}, rt = ({ docPath: e, panelId: n, maximized: t, title: o, onContentShown: r }) => {
|
|
358
|
-
const { store: l, followLink: a, revealInPanel: d, keepAtStartInPanel: p } = de(), { announcer: i } =
|
|
358
|
+
const { store: l, followLink: a, revealInPanel: d, keepAtStartInPanel: p } = de(), { announcer: i } = J(), y = _(l, (c) => Dn(c, n)), E = _(l, (c) => c.layout.markup.has(e)), b = R((c, f) => a(n, e, c, f), [a, n, e]), k = R(() => l.setPendingHash(n, null), [l, n]), w = D(() => ({ read: (c) => l.imageViewOf(n, c), save: (c, f) => l.saveImageView(n, c, f) }), [l, n]), u = R(
|
|
359
359
|
(c, f) => {
|
|
360
360
|
f.kind !== "failure" && l.setTitle(c, f.name), r(c);
|
|
361
361
|
},
|
|
@@ -567,7 +567,7 @@ const Rn = () => {
|
|
|
567
567
|
);
|
|
568
568
|
}, St = Qe(yt), Q = (e, n) => {
|
|
569
569
|
const t = e.panelIds.get(n);
|
|
570
|
-
if (t === void 0) throw new Error(`[markdown-explorer] the open document ${
|
|
570
|
+
if (t === void 0) throw new Error(`[markdown-explorer] the open document ${X(n)} has no panel id`);
|
|
571
571
|
return t;
|
|
572
572
|
}, be = (e) => Object.fromEntries(xn(e).map((n) => [n, []])), xt = (e, n) => {
|
|
573
573
|
const t = jn(le(e, n), n.visible);
|
|
@@ -639,7 +639,7 @@ const Rn = () => {
|
|
|
639
639
|
const t = e.current;
|
|
640
640
|
t !== null && (n.kind === "panel" && Ke(t, n.panelId) || t.focus({ preventScroll: !0 }));
|
|
641
641
|
});
|
|
642
|
-
},
|
|
642
|
+
}, Xe = (e, n) => {
|
|
643
643
|
requestAnimationFrame(() => {
|
|
644
644
|
const t = e.current;
|
|
645
645
|
t !== null && Ke(t, n);
|
|
@@ -654,7 +654,7 @@ const Rn = () => {
|
|
|
654
654
|
a instanceof HTMLElement && a.focus({ preventScroll: !0 });
|
|
655
655
|
});
|
|
656
656
|
}, _t = ({ store: e, stageRef: n }) => {
|
|
657
|
-
const { config: t, labels: o, announcer: r, edits: l } =
|
|
657
|
+
const { config: t, labels: o, announcer: r, edits: l } = J(), { maximize: a } = de(), d = t.multiView.columns, p = _(e, (S) => S.layout), i = _(e, (S) => S.visibleColumns), y = _(e, (S) => S.titles), E = _(e, (S) => S.layout.maximized !== null || S.splitDragging), [b, k] = $(!1), [w] = $(() => be(i)), u = D(() => Ot(o), [o]), v = R(
|
|
658
658
|
(S) => {
|
|
659
659
|
e.arrange(Et(e.getSnapshot().layout, S));
|
|
660
660
|
},
|
|
@@ -710,7 +710,7 @@ const Rn = () => {
|
|
|
710
710
|
const j = e.titleOf(z);
|
|
711
711
|
if (H) {
|
|
712
712
|
if (!e.setHidden(z, !1)) continue;
|
|
713
|
-
r.announce(o.panelShown(j)),
|
|
713
|
+
r.announce(o.panelShown(j)), Xe(n, B);
|
|
714
714
|
continue;
|
|
715
715
|
}
|
|
716
716
|
const G = n.current, he = G === null ? null : Ce(G, B);
|
|
@@ -793,7 +793,7 @@ const Rn = () => {
|
|
|
793
793
|
e.isConnected && e.hidePopover();
|
|
794
794
|
};
|
|
795
795
|
}, Bt = ({ store: e, body: n, limitNotice: t, onLimitNoticeCovered: o, ref: r }) => {
|
|
796
|
-
const { config: l, labels: a, announcer: d, edits: p } =
|
|
796
|
+
const { config: l, labels: a, announcer: d, edits: p } = J(), i = q(null), y = q(null), E = _(e, (c) => c.ready), b = _(e, (c) => c.layout.docs.length > 0), k = _(e, (c) => c.visibleColumns), w = Ae(wn), u = R(
|
|
797
797
|
(c) => {
|
|
798
798
|
const { layout: f } = e.getSnapshot(), m = f.maximized, T = c === null && m !== null ? f.panelIds.get(m) : void 0, L = i.current, s = T !== void 0 && L !== null && ge(L, T);
|
|
799
799
|
e.maximize(c) && (c !== null ? d.announce(a.panelMaximized(e.titleOf(c))) : m !== null && d.announce(a.panelRestored(e.titleOf(m))), T !== void 0 && Dt(i, T, s));
|
|
@@ -819,7 +819,7 @@ const Rn = () => {
|
|
|
819
819
|
}
|
|
820
820
|
if (s !== "existing") return;
|
|
821
821
|
const { layout: h } = e.getSnapshot(), P = h.panelIds.get(m);
|
|
822
|
-
P !== void 0 && (d.announce(a.panelAlreadyOpen(e.titleOf(m))), h.maximized === null ? e.setHidden(m, !1) : u(m), e.setPendingHash(P, T),
|
|
822
|
+
P !== void 0 && (d.announce(a.panelAlreadyOpen(e.titleOf(m))), h.maximized === null ? e.setHidden(m, !1) : u(m), e.setPendingHash(P, T), Xe(i, P));
|
|
823
823
|
},
|
|
824
824
|
[e, d, a, u, p]
|
|
825
825
|
);
|
|
@@ -899,11 +899,11 @@ const Rn = () => {
|
|
|
899
899
|
return e.panelClosed(t);
|
|
900
900
|
default: {
|
|
901
901
|
const o = n;
|
|
902
|
-
throw new RangeError(`[markdown-explorer] unknown toggle outcome ${
|
|
902
|
+
throw new RangeError(`[markdown-explorer] unknown toggle outcome ${X(o)}`);
|
|
903
903
|
}
|
|
904
904
|
}
|
|
905
905
|
}, no = ({ location: e }) => {
|
|
906
|
-
const { config: n, labels: t, announcer: o } =
|
|
906
|
+
const { config: n, labels: t, announcer: o } = J(), r = tt(e), l = _(r, (m) => m.layout.docs), a = _(r, (m) => m.layout.maximized), d = _(r, (m) => m.layout.markup), p = _(r, (m) => m.source), [i, y] = $(() => ({ docs: l, latest: Ne([], l, null) }));
|
|
907
907
|
i.docs !== l && y({ docs: l, latest: Ne(i.docs, l, i.latest) });
|
|
908
908
|
const E = a !== null ? a : i.latest, [b, k] = $(!1), w = q(null), [u, v] = $(0), g = q(null), O = q(null);
|
|
909
909
|
F(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),S=require("react"),u=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),S=require("react"),u=require("./index-BmOU3xcK.cjs"),d=require("./tapScrollCircle-DVNlszeF.cjs"),v=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),m=(e,t)=>e.scrollTop===t.scrollTop&&e.scrollHeight===t.scrollHeight&&e.clientHeight===t.clientHeight,g=e=>{let t=v(e);return{getSnapshot:()=>t,subscribe:s=>{const o=()=>{const a=v(e);m(t,a)||(t=a,s())};let n=0;const c=()=>{n===0&&(n=requestAnimationFrame(()=>{n=0,o()}))},r=typeof ResizeObserver>"u"?null:new ResizeObserver(c),l=()=>{if(r!==null){r.disconnect(),r.observe(e);for(const a of e.children)r.observe(a)}};l();const i=typeof MutationObserver>"u"?null:new MutationObserver(()=>{l(),c()});return i?.observe(e,{childList:!0}),e.addEventListener("scroll",o,{passive:!0}),o(),()=>{e.removeEventListener("scroll",o),i?.disconnect(),r?.disconnect(),cancelAnimationFrame(n)}}}},b=e=>{const t=S.useMemo(()=>g(e),[e]);return S.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)},h=(e,t)=>{const s=typeof t=="function"?t(e.scrollTop):t;return e.scrollTo({top:s,behavior:"instant"}),e.scrollTop},f=({scroller:e,kind:t})=>{const{locale:s}=u.useExplorer(),o=u.useCoarsePointer(),{scrollTop:n,scrollHeight:c,clientHeight:r}=b(e),l=S.useCallback(i=>h(e,i),[e]);return p.jsx("div",{className:"aqmx-native-scroll-bar",children:p.jsx(T.ScrollBar,{contentSize:c,viewportSize:r,scrollPosition:n,onScroll:l,scrollBarWidth:u.NATIVE_SCROLL_BAR_WIDTH,...u.scrollBarControlsFor(o),enableArrowButtonTabStops:!1,tapScrollCircleOptions:t==="content"?d.tapScrollCircleFor(o):d.NO_TAP_SCROLL_CIRCLE,locale:s})})};exports.NativeScrollBar=f;exports.scrollScrollerTo=h;exports.useScrollerMetrics=b;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as u } from "react/jsx-runtime";
|
|
2
2
|
import { ScrollBar as m } from "@aiquants/virtualscroll";
|
|
3
3
|
import { useCallback as S, useMemo as d, useSyncExternalStore as h } from "react";
|
|
4
|
-
import { u as b, c as v, N as f, s as T } from "./index-
|
|
5
|
-
import { NO_TAP_SCROLL_CIRCLE as g, tapScrollCircleFor as H } from "./tapScrollCircle-
|
|
4
|
+
import { u as b, c as v, N as f, s as T } from "./index-dtjghDWY.js";
|
|
5
|
+
import { NO_TAP_SCROLL_CIRCLE as g, tapScrollCircleFor as H } from "./tapScrollCircle-CqMZzWjo.js";
|
|
6
6
|
const p = (e) => ({ scrollTop: e.scrollTop, scrollHeight: e.scrollHeight, clientHeight: e.clientHeight }), C = (e, t) => e.scrollTop === t.scrollTop && e.scrollHeight === t.scrollHeight && e.clientHeight === t.clientHeight, O = (e) => {
|
|
7
7
|
let t = p(e);
|
|
8
8
|
return {
|
|
@@ -2,10 +2,10 @@ import { jsx as h, jsxs as j } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback as d, useMemo as v, useEffect as g, useSyncExternalStore as q, useState as H, useRef as U, useLayoutEffect as $ } from "react";
|
|
3
3
|
import { useLocation as B } from "react-router";
|
|
4
4
|
import { e as f, c as Y } from "./location-Dh6K-y7w.js";
|
|
5
|
-
import { u as S, f as R, r as J, F as K, g as Q, h as V, i as W, D as X, P as Z, j as I } from "./index-
|
|
5
|
+
import { u as S, f as R, r as J, F as K, g as Q, h as V, i as W, D as X, P as Z, j as I } from "./index-dtjghDWY.js";
|
|
6
6
|
import { isMaximizeEscape as ee } from "@aiquants/drag-drop-panels";
|
|
7
7
|
import { l as te } from "./ownUrls-DD0cSCsF.js";
|
|
8
|
-
import { E as ne, a as re, b as se } from "./ExplorerSplit-
|
|
8
|
+
import { E as ne, a as re, b as se } from "./ExplorerSplit-C_kaEnyM.js";
|
|
9
9
|
const ae = (e) => {
|
|
10
10
|
const { config: r, labels: n, announcer: t } = S(), c = R(), s = d(() => {
|
|
11
11
|
const u = e.doc !== null ? e.doc : e.folder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),o=require("react"),H=require("react-router"),x=require("./location-DrOP6t1F.cjs"),d=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),o=require("react"),H=require("react-router"),x=require("./location-DrOP6t1F.cjs"),d=require("./index-BmOU3xcK.cjs"),_=require("@aiquants/drag-drop-panels"),j=require("./ownUrls-BTPGNhBt.cjs"),k=require("./ExplorerSplit-C_3FChSt.cjs"),A=e=>{const{config:r,labels:n,announcer:t}=d.useExplorer(),i=d.useExplorerNavigate(),s=o.useCallback(()=>{const u=e.doc!==null?e.doc:e.folder;if(u===null)throw new RangeError("[markdown-explorer] a tree view without a document or a folder has nothing to maximize");i(x.explorerHref(r,{...e,maximized:!e.maximized}),"browse");const a=j.lastPathSegment(u);t.announce(e.maximized?n.documentRestored(a):n.documentMaximized(a))},[r,i,e,t,n]);return o.useMemo(()=>({maximized:e.maximized,toggle:s}),[e.maximized,s])},G=(e,r)=>{o.useEffect(()=>{if(!e)return;const n=t=>{_.isMaximizeEscape(t)&&(t.preventDefault(),r())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[e,r])},U=(e,r)=>e.claim!==r.claim||e.readme.status!==r.readme.status?!1:e.readme.status==="failed"&&r.readme.status==="failed"?e.readme.failure===r.readme.failure:e.readme.status==="ok"&&r.readme.status==="ok"?e.readme.readme===r.readme.readme:!0,B=(e,r,n)=>{let t=null;return()=>{const i=e.version(),s=e.read(r),u=s.status!=="pending";if(t!==null&&t.version===i&&t.tree===s&&t.settled===u)return t.state;const a=d.readFolderReadme(e,r,n),l=t!==null&&U(t.state,a)?t.state:a;return t={version:i,tree:s,settled:u,state:l},l}},Y=(e,r,n)=>{let t=!0,i=null;const s=()=>{t&&n()},u=()=>{const l=e.read(r);l===i||l.status!=="pending"||(i=l,l.then(s,s))};u();const a=e.subscribe(()=>{u(),n()});return()=>{t=!1,a()}},J=()=>d.FOLDER_README_LOADING,K=(e,r)=>{const{trees:n}=d.useExplorer(),t=o.useMemo(()=>r===null?null:B(n,e,r),[n,e,r]),i=o.useCallback(p=>t===null?()=>{}:Y(n,e,p),[t,n,e]),s=o.useCallback(()=>t===null?null:t(),[t]),u=o.useCallback(()=>t===null?null:J(),[t]),a=o.useSyncExternalStore(i,s,u),l=a?.claim===!0;return o.useEffect(()=>r===null?void 0:n.open(e),[n,e,r]),o.useEffect(()=>r===null||!l?void 0:n.claimChildren(e,new Map([[r,"direct"]])),[n,e,r,l]),a===null?null:a.readme},Q=new Set,V=Object.freeze({kind:"loading"}),W=(e,r)=>r.status==="loading"?V:r.status==="failed"?{kind:"failure",folder:e,failure:r.failure,onRetry:r.retry}:{kind:"no-readme",folder:e},X=({location:e,opening:r})=>{const{config:n}=d.useExplorer(),t=d.useExplorerNavigate(),{hash:i}=H.useLocation(),{source:s,doc:u,folder:a,overrides:l,markup:p,maximized:f}=e,[g,M]=o.useState(k.EMPTY_SELECTION),O=o.useMemo(()=>({gathered:g,onGatheredChange:M}),[g]),w=K(s,a),m=w===null?u:w.status==="ok"?w.readme:null,h=o.useMemo(()=>r!==null?r:a===null||w===null?d.NO_DOCUMENT:W(a,w),[r,a,w]),b=f&&(m!==null||h.kind==="loading"),R=o.useCallback(c=>t(x.explorerHref(n,{view:"tree",source:s,doc:c,overrides:l}),"browse"),[t,n,s,l]),D=o.useCallback(c=>t(x.explorerHref(n,{view:"tree",source:s,folder:c,overrides:l}),"browse"),[t,n,s,l]),N=o.useCallback(c=>{const E=c.kind==="folder"?{folder:c.path}:c.kind==="document"?{doc:c.path}:{};t(x.explorerHref(n,{view:"tree",source:s,...E,overrides:l}),"close-folder")},[t,n,s,l]),P=o.useCallback(c=>t(x.explorerHref(n,{view:"tree",source:c,doc:u,folder:a,overrides:l,markup:p,maximized:f}),"switch-source"),[t,n,u,a,l,p,f]),T=o.useCallback(c=>t(`${x.explorerHref(n,{view:"tree",source:c,doc:u,folder:a,overrides:l,markup:p,maximized:f})}${i}`,"browse"),[t,n,u,a,l,p,f,i]),q=o.useCallback(c=>{const E=x.canonicalMultiDocuments(n,c);t(x.explorerHref(n,{view:"multi",source:s,docs:E,markup:p&&m!==null&&E.includes(m)?[m]:[]}),"switch-view")},[t,n,s,m,p]),y=o.useMemo(()=>({href:x.explorerHref(n,m===null?{view:"multi",source:s}:{view:"multi",source:s,docs:[m],markup:p?[m]:[]}),target:"multi"}),[n,s,m,p]),S=o.useRef(f);o.useLayoutEffect(()=>{S.current=f},[f]);const C=o.useCallback(()=>S.current,[]),F=o.useMemo(()=>({kind:"page",view:"tree",overrides:l,embed:{},maximized:C}),[l,C]),L=d.usePageMarkupToggle(e),z=A(e);return G(b,z.toggle),v.jsx(k.ExplorerSplit,{view:"tree",contentCoversPage:b,explorer:v.jsx(k.ExplorerPane,{mode:"tree",sourceId:s,currentPath:a===null?u:a,openPaths:Q,onOpenDocument:R,onOpenFolder:D,onCloseFolder:N,currentFolder:a!==null,onSourceChange:P,onRevealSource:T,viewSwitch:y,tray:O,onOpenSelection:q}),content:v.jsxs("div",{className:"aqmx-document-column aqmx-tree-document","data-aqmx-maximized":b?"true":"false",...d.CONTENT_PANE,children:[m===null?null:v.jsx(d.DocumentRefreshBar,{path:m,placement:d.PAGE_DOCUMENT_REFRESH,markup:L,maximize:z}),v.jsx(d.DocumentPane,{path:m,absence:h,markup:p,variant:F})]})})};exports.TreeLayout=X;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { AccessFailurePresenter } from "@aiquants/auth-core";
|
|
1
2
|
import { MarkdownMathDiagnostic } from "@aiquants/markdown";
|
|
2
3
|
import { ReactElement, ReactNode, Ref } from "react";
|
|
3
4
|
import { ExplorerConfig, ExplorerView } from "../core/config.cjs";
|
|
4
5
|
import { ExplorerDraftConverter, ExplorerFailure, ExplorerPageData } from "../core/contracts.cjs";
|
|
5
6
|
import { MarkdownExplorerLabelOverrides, MarkdownExplorerLocale } from "../core/labels.cjs";
|
|
6
7
|
import { ExplorerTheme } from "../core/theme.cjs";
|
|
7
|
-
import {
|
|
8
|
+
import { ExplorerDraftChange, ExplorerHostChange, ExplorerHostChangePolicy, MarkdownExplorerHandle } from "./hostContract.cjs";
|
|
8
9
|
export type ExplorerFrameRenderer = (frame: {
|
|
9
10
|
readonly view: ExplorerView;
|
|
10
11
|
readonly children: ReactNode;
|
|
@@ -18,6 +19,7 @@ export type MarkdownExplorerProps = {
|
|
|
18
19
|
readonly theme?: ExplorerTheme;
|
|
19
20
|
readonly renderFrame?: ExplorerFrameRenderer;
|
|
20
21
|
readonly renderTreeFailure?: (failure: ExplorerFailure) => ReactNode | undefined;
|
|
22
|
+
readonly accessFailure: AccessFailurePresenter<ReactNode>;
|
|
21
23
|
readonly lockDocumentScroll?: boolean;
|
|
22
24
|
readonly onMathDiagnostics?: (path: string, diagnostics: readonly MarkdownMathDiagnostic[]) => void;
|
|
23
25
|
readonly onEditGrant?: (href: string) => Promise<boolean>;
|
|
@@ -28,14 +30,11 @@ export type MarkdownExplorerProps = {
|
|
|
28
30
|
readonly hostChangePolicy?: ExplorerHostChangePolicy;
|
|
29
31
|
readonly ref?: Ref<MarkdownExplorerHandle>;
|
|
30
32
|
readonly guardUnload?: boolean;
|
|
31
|
-
readonly onReload?: () => void;
|
|
32
|
-
readonly onSessionEnded?: () => Promise<boolean>;
|
|
33
33
|
readonly onDraftChange?: (change: ExplorerDraftChange) => void;
|
|
34
|
-
readonly accountState?: ExplorerAccountState;
|
|
35
34
|
readonly confirmUnversionedSaves?: boolean;
|
|
36
35
|
readonly paletteKey?: string;
|
|
37
36
|
};
|
|
38
|
-
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, lockDocumentScroll, onMathDiagnostics, onEditGrant, draftConverter: draftConverterProp, fetch: fetchProp, persistSettings, subscribeHostChanges, hostChangePolicy, ref, guardUnload,
|
|
37
|
+
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, accessFailure, lockDocumentScroll, onMathDiagnostics, onEditGrant, draftConverter: draftConverterProp, fetch: fetchProp, persistSettings, subscribeHostChanges, hostChangePolicy, ref, guardUnload, onDraftChange, confirmUnversionedSaves, paletteKey, }: MarkdownExplorerProps) => ReactElement;
|
|
39
38
|
export type ExplorerRootProps = {
|
|
40
39
|
readonly ref?: Ref<HTMLDivElement>;
|
|
41
40
|
readonly theme: ExplorerTheme;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { AccessFailurePresenter } from "@aiquants/auth-core";
|
|
1
2
|
import { MarkdownMathDiagnostic } from "@aiquants/markdown";
|
|
2
3
|
import { ReactElement, ReactNode, Ref } from "react";
|
|
3
4
|
import { ExplorerConfig, ExplorerView } from "../core/config.js";
|
|
4
5
|
import { ExplorerDraftConverter, ExplorerFailure, ExplorerPageData } from "../core/contracts.js";
|
|
5
6
|
import { MarkdownExplorerLabelOverrides, MarkdownExplorerLocale } from "../core/labels.js";
|
|
6
7
|
import { ExplorerTheme } from "../core/theme.js";
|
|
7
|
-
import {
|
|
8
|
+
import { ExplorerDraftChange, ExplorerHostChange, ExplorerHostChangePolicy, MarkdownExplorerHandle } from "./hostContract.js";
|
|
8
9
|
export type ExplorerFrameRenderer = (frame: {
|
|
9
10
|
readonly view: ExplorerView;
|
|
10
11
|
readonly children: ReactNode;
|
|
@@ -18,6 +19,7 @@ export type MarkdownExplorerProps = {
|
|
|
18
19
|
readonly theme?: ExplorerTheme;
|
|
19
20
|
readonly renderFrame?: ExplorerFrameRenderer;
|
|
20
21
|
readonly renderTreeFailure?: (failure: ExplorerFailure) => ReactNode | undefined;
|
|
22
|
+
readonly accessFailure: AccessFailurePresenter<ReactNode>;
|
|
21
23
|
readonly lockDocumentScroll?: boolean;
|
|
22
24
|
readonly onMathDiagnostics?: (path: string, diagnostics: readonly MarkdownMathDiagnostic[]) => void;
|
|
23
25
|
readonly onEditGrant?: (href: string) => Promise<boolean>;
|
|
@@ -28,14 +30,11 @@ export type MarkdownExplorerProps = {
|
|
|
28
30
|
readonly hostChangePolicy?: ExplorerHostChangePolicy;
|
|
29
31
|
readonly ref?: Ref<MarkdownExplorerHandle>;
|
|
30
32
|
readonly guardUnload?: boolean;
|
|
31
|
-
readonly onReload?: () => void;
|
|
32
|
-
readonly onSessionEnded?: () => Promise<boolean>;
|
|
33
33
|
readonly onDraftChange?: (change: ExplorerDraftChange) => void;
|
|
34
|
-
readonly accountState?: ExplorerAccountState;
|
|
35
34
|
readonly confirmUnversionedSaves?: boolean;
|
|
36
35
|
readonly paletteKey?: string;
|
|
37
36
|
};
|
|
38
|
-
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, lockDocumentScroll, onMathDiagnostics, onEditGrant, draftConverter: draftConverterProp, fetch: fetchProp, persistSettings, subscribeHostChanges, hostChangePolicy, ref, guardUnload,
|
|
37
|
+
export declare const MarkdownExplorer: ({ data: pageData, config, storageNamespace, locale: localeProp, labels: labelOverrides, theme: themeProp, renderFrame, renderTreeFailure, accessFailure, lockDocumentScroll, onMathDiagnostics, onEditGrant, draftConverter: draftConverterProp, fetch: fetchProp, persistSettings, subscribeHostChanges, hostChangePolicy, ref, guardUnload, onDraftChange, confirmUnversionedSaves, paletteKey, }: MarkdownExplorerProps) => ReactElement;
|
|
39
38
|
export type ExplorerRootProps = {
|
|
40
39
|
readonly ref?: Ref<HTMLDivElement>;
|
|
41
40
|
readonly theme: ExplorerTheme;
|
|
@@ -41,22 +41,15 @@ export declare const EXPLORER_HOST_CHANGE_POLICIES: readonly [
|
|
|
41
41
|
"notify"
|
|
42
42
|
];
|
|
43
43
|
export type ExplorerHostChangePolicy = (typeof EXPLORER_HOST_CHANGE_POLICIES)[number];
|
|
44
|
-
export declare const EXPLORER_ACCOUNT_STATES: readonly [
|
|
45
|
-
"signed-in",
|
|
46
|
-
"signed-out"
|
|
47
|
-
];
|
|
48
|
-
export type ExplorerAccountState = (typeof EXPLORER_ACCOUNT_STATES)[number];
|
|
49
44
|
export type ExplorerHostOptions = {
|
|
50
45
|
readonly fetch: unknown;
|
|
51
46
|
readonly persistSettings: unknown;
|
|
52
47
|
readonly subscribeHostChanges: unknown;
|
|
53
|
-
readonly onReload: unknown;
|
|
54
|
-
readonly onSessionEnded: unknown;
|
|
55
48
|
readonly onDraftChange: unknown;
|
|
49
|
+
readonly accessFailure: unknown;
|
|
56
50
|
readonly guardUnload: unknown;
|
|
57
51
|
readonly confirmUnversionedSaves: unknown;
|
|
58
52
|
readonly hostChangePolicy: unknown;
|
|
59
|
-
readonly accountState: unknown;
|
|
60
53
|
readonly paletteKey: unknown;
|
|
61
54
|
};
|
|
62
55
|
export declare const assertExplorerHostOptions: (options: ExplorerHostOptions) => void;
|
|
@@ -41,22 +41,15 @@ export declare const EXPLORER_HOST_CHANGE_POLICIES: readonly [
|
|
|
41
41
|
"notify"
|
|
42
42
|
];
|
|
43
43
|
export type ExplorerHostChangePolicy = (typeof EXPLORER_HOST_CHANGE_POLICIES)[number];
|
|
44
|
-
export declare const EXPLORER_ACCOUNT_STATES: readonly [
|
|
45
|
-
"signed-in",
|
|
46
|
-
"signed-out"
|
|
47
|
-
];
|
|
48
|
-
export type ExplorerAccountState = (typeof EXPLORER_ACCOUNT_STATES)[number];
|
|
49
44
|
export type ExplorerHostOptions = {
|
|
50
45
|
readonly fetch: unknown;
|
|
51
46
|
readonly persistSettings: unknown;
|
|
52
47
|
readonly subscribeHostChanges: unknown;
|
|
53
|
-
readonly onReload: unknown;
|
|
54
|
-
readonly onSessionEnded: unknown;
|
|
55
48
|
readonly onDraftChange: unknown;
|
|
49
|
+
readonly accessFailure: unknown;
|
|
56
50
|
readonly guardUnload: unknown;
|
|
57
51
|
readonly confirmUnversionedSaves: unknown;
|
|
58
52
|
readonly hostChangePolicy: unknown;
|
|
59
|
-
readonly accountState: unknown;
|
|
60
53
|
readonly paletteKey: unknown;
|
|
61
54
|
};
|
|
62
55
|
export declare const assertExplorerHostOptions: (options: ExplorerHostOptions) => void;
|
package/dist/core/labels.d.cts
CHANGED
|
@@ -181,12 +181,6 @@ export type MarkdownExplorerLabels = MarkdownExplorerSpreadsheetLabels & {
|
|
|
181
181
|
readonly announcementSequence: (messages: readonly string[]) => string;
|
|
182
182
|
readonly textTruncated: string;
|
|
183
183
|
readonly inertLink: string;
|
|
184
|
-
readonly failureUnauthorizedTitle: string;
|
|
185
|
-
readonly failureUnauthorizedBody: string;
|
|
186
|
-
readonly failureUnauthorizedSignInBody: string;
|
|
187
|
-
readonly failureUnauthorizedSignedOutBody: string;
|
|
188
|
-
readonly failureForbiddenTitle: string;
|
|
189
|
-
readonly failureForbiddenBody: string;
|
|
190
184
|
readonly failureNotFoundTitle: string;
|
|
191
185
|
readonly failureNotFoundBody: string;
|
|
192
186
|
readonly failureNotConfiguredTitle: string;
|
|
@@ -200,9 +194,6 @@ export type MarkdownExplorerLabels = MarkdownExplorerSpreadsheetLabels & {
|
|
|
200
194
|
readonly failureFailedTitle: string;
|
|
201
195
|
readonly failureFailedBody: string;
|
|
202
196
|
readonly retry: string;
|
|
203
|
-
readonly reloadPage: string;
|
|
204
|
-
readonly signInAgain: string;
|
|
205
|
-
readonly signIn: string;
|
|
206
197
|
readonly imageZoomIn: string;
|
|
207
198
|
readonly imageZoomOut: string;
|
|
208
199
|
readonly imageFit: string;
|
package/dist/core/labels.d.ts
CHANGED
|
@@ -181,12 +181,6 @@ export type MarkdownExplorerLabels = MarkdownExplorerSpreadsheetLabels & {
|
|
|
181
181
|
readonly announcementSequence: (messages: readonly string[]) => string;
|
|
182
182
|
readonly textTruncated: string;
|
|
183
183
|
readonly inertLink: string;
|
|
184
|
-
readonly failureUnauthorizedTitle: string;
|
|
185
|
-
readonly failureUnauthorizedBody: string;
|
|
186
|
-
readonly failureUnauthorizedSignInBody: string;
|
|
187
|
-
readonly failureUnauthorizedSignedOutBody: string;
|
|
188
|
-
readonly failureForbiddenTitle: string;
|
|
189
|
-
readonly failureForbiddenBody: string;
|
|
190
184
|
readonly failureNotFoundTitle: string;
|
|
191
185
|
readonly failureNotFoundBody: string;
|
|
192
186
|
readonly failureNotConfiguredTitle: string;
|
|
@@ -200,9 +194,6 @@ export type MarkdownExplorerLabels = MarkdownExplorerSpreadsheetLabels & {
|
|
|
200
194
|
readonly failureFailedTitle: string;
|
|
201
195
|
readonly failureFailedBody: string;
|
|
202
196
|
readonly retry: string;
|
|
203
|
-
readonly reloadPage: string;
|
|
204
|
-
readonly signInAgain: string;
|
|
205
|
-
readonly signIn: string;
|
|
206
197
|
readonly imageZoomIn: string;
|
|
207
198
|
readonly imageZoomOut: string;
|
|
208
199
|
readonly imageFit: string;
|