@aiquants/markdown-explorer 0.7.1 → 0.9.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),u=require("react"),j=require("./location-DmzVAFvo.cjs"),q=require("./index-Dlkzr6Zn.cjs"),re=require("./ExplorerSplit-D60N3_X7.cjs"),D=require("@aiquants/drag-drop-panels"),fe=require("react-router"),ne=require("./storage-Dgi4JXaB.cjs"),Ce=require("./dataRoute-CcZ8PK00.cjs"),je=require("react-dom"),Fe=require("@aiquants/markdown"),Ve=require("./scrollBarGeometry-C46jBtmM.cjs"),Ue=()=>{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}}},Pe=u.createContext(null),ie=()=>{const e=u.use(Pe);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},$e=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},Ge=0xcbf29ce484222325n,Ye=0x100000001b3n,We=(1n<<64n)-1n,Ke=(1n<<53n)-1n,Je=new TextEncoder,Xe=e=>{let n=Ge;for(const t of Je.encode(e))n=(n^BigInt(t))*Ye&We;return Number(n&Ke)},Q=256,Ze=e=>`aqmx-p-${Xe(e).toString(36)}`,Me=(e,n)=>{const t=Ze(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Qe=new Map,en=(e,n=Qe)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??Me(r,t);t.add(s),o.set(r,s)}return o},Le=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},ke=(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,f])=>e.slice(m,f).reduce((l,y)=>l+y.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=Le(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[ke(t,n)]?.push(r);return t},nn=(e,n)=>j.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),tn=(e,n,t)=>{const[o,r]=n,s=r-o,a=e.length,m=Array.from({length:s},(c,g)=>{const w=[0];for(const h of e)w.push((w.at(-1)??0)+(t(h)===o+g?1:0));return w}),f=(c,g,w)=>(m[c]?.[w]??0)-(m[c]?.[g]??0),l=Array.from({length:s+1},()=>Array.from({length:a+1},()=>Number.NEGATIVE_INFINITY)),y=Array.from({length:s+1},()=>Array.from({length:a+1},()=>0)),S=l[0];S&&(S[0]=0);for(let c=0;c<s;c+=1)for(let g=0;g<=a;g+=1)for(let w=0;w<=g;w+=1){const h=(l[c]?.[w]??Number.NEGATIVE_INFINITY)+f(c,w,g),P=l[c+1],T=y[c+1];P&&T&&h>(P[g]??Number.NEGATIVE_INFINITY)&&(P[g]=h,T[g]=w)}const C=Array.from({length:s},()=>[]);let k=a;for(let c=s;c>0;c-=1){const g=y[c]?.[k]??0;C[c-1]=e.slice(g,k),k=g}return C},Te=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const a of s)o.delete(a),o.set(a,r);for(const r of o.keys()){if(o.size<=Q)break;o.delete(r)}return{docs:t,columnOf:o}},on=(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=Le(e,n,t.logical)??ke(r,t);r[s]?.push(n);const a=new Map(e.panelIds);return a.set(n,Me(n,new Set(a.values()))),{state:{...e,...Te(e,r),panelIds:a},outcome:"opened"}},Re=(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}},rn=(e,n,t,o)=>{if(e.hidden.has(n))return{state:Ne(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Re(e,n),outcome:"closed"};const r=on(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},sn=(e,n,t)=>{if(n===t||!e.docs.includes(n))return{state:e,outcome:"ignored"};if(e.docs.includes(t))return{state:e,outcome:"existing"};const o=new Map(e.columnOf),r=o.get(n);r!==void 0&&(o.delete(t),o.set(t,r));const s=new Set(e.hidden);s.delete(n);const a=new Map(e.panelIds),m=a.get(n);if(m===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);a.delete(n),a.set(t,m);const f=new Set(e.markup);return f.delete(n),{state:{docs:e.docs.map(l=>l===n?t:l),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,markup:f,panelIds:a},outcome:"navigated"}},Ne=(e,n,t)=>{if(!e.docs.includes(n)||e.hidden.has(n)===t)return e;const o=new Set(e.hidden);return t?o.add(n):o.delete(n),{...e,hidden:o,maximized:t&&e.maximized===n?null:e.maximized}},ln=(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}},an=(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}},cn=(e,n,t)=>{const o=ee(e,t),r=new Map;for(const[l,y]of o.entries())for(const S of y)r.set(S,l);const s=new Set(e.docs),a=new Set,m=j.columnGroups(t.logical,t.visible),f=Array.from({length:t.logical},()=>[]);for(const[l,y]of m.entries()){const S=(n[l]??[]).filter(C=>s.has(C)&&!a.has(C));for(const C of S)a.add(C);for(const[C,k]of tn(S,y,c=>r.get(c)).entries())f[y[0]+C]?.push(...k)}for(const l of e.docs)a.has(l)||f[r.get(l)??0]?.push(l);return f.every((l,y)=>l.length===o[y]?.length&&l.every((S,C)=>o[y]?.[C]===S))?e:{...e,...Te(e,f)}},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:en(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}},Ie=1,$=Object.freeze({columnOf:new Map,hidden:new Set}),un=(e,n)=>{if(e===null||e==="")return $;let t;try{t=JSON.parse(e)}catch{return $}if(t===null||typeof t!="object"||Array.isArray(t))return $;const o=t;if(o.v!==Ie)return $;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}},dn=e=>JSON.stringify({v:Ie,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: ${JSON.stringify(e.slice(0,80))}`)},mn=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,a=q.createEmitter(),m=new Map,f=new Map;let l={layout:te({docs:n.docs,maximized:n.maximized,markup:n.markup,stored:$},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},y=!1;const S=i=>y?pe(i,{logical:s,visible:l.visibleColumns}):i,C=(i,p)=>j.explorerHref(e,{view:"multi",source:i,docs:p.docs,maximized:p.maximized,markup:p.markup}),k=i=>({docs:i.docs,maximized:i.maximized,markup:[...i.markup]});let c=C(n.source,n),g=n.source,w=c;const h=[],P=[];let T=null;const A=()=>{if(!(h.length>0))for(const i of P.splice(0))i()},d=i=>{l={...l,...i},a.emit()},v=()=>{if(!l.ready)return;const i=dn(l.layout);i!==T&&(T=i,o(i))},O=(i,p,M)=>{const I=C(i,k(p));I!==c&&(c=I,g=i,h.push(I),t(I,M))},x=i=>{const p=new Set(i.panelIds.values());for(const b of[...m.keys()])p.has(b)||m.delete(b);for(const b of[...f.keys()])p.has(b)||f.delete(b);const M=new Set(i.docs),I=[...l.titles.keys()].every(b=>M.has(b))?l.titles:new Map([...l.titles].filter(([b])=>M.has(b))),E=[...l.pendingHashes.keys()].every(b=>p.has(b))?l.pendingHashes:new Map([...l.pendingHashes].filter(([b])=>p.has(b)));return{titles:I,pendingHashes:E}},R=i=>i===l.layout?!1:(d({layout:i,...x(i)}),O(g,i,"replace"),v(),!0),N=()=>({logical:s,visible:l.visibleColumns});return{getSnapshot:()=>l,subscribe:a.subscribe,toggle:i=>{ge(i);const{state:p,outcome:M}=rn(l.layout,i,N(),r);return R(p),M},close:i=>R(Re(l.layout,i)),navigate:(i,p)=>{ge(p);const{state:M,outcome:I}=sn(l.layout,i,p);if(I!=="navigated")return I;const E=M.panelIds.get(p);return E!==void 0&&(m.delete(E),f.delete(E)),R(M),I},setHidden:(i,p)=>R(Ne(l.layout,i,p)),maximize:i=>R(an(l.layout,i)),setMarkup:(i,p)=>R(ln(l.layout,i,p)),arrange:i=>R(cn(l.layout,i,{logical:s,visible:i.length})),changeSource:i=>{O(i,l.layout,"push")},revealSource:i=>{O(i,l.layout,"replace")},observeLocation:i=>{const p=C(i.source,i);if(p===c)return h.length=0,w=p,i.source!==l.source&&d({source:i.source}),A(),!1;if(p===w)return!1;w=p;const M=h.indexOf(p);if(M>=0)return h.splice(0,M+1),i.source!==l.source&&d({source:i.source}),A(),!1;h.length=0,c=p,g=i.source;const I=S(te({docs:i.docs,maximized:i.maximized,markup:i.markup,stored:{columnOf:l.layout.columnOf,hidden:l.layout.hidden},panelIds:l.layout.panelIds},r));return d({layout:I,source:i.source,...x(I)}),v(),A(),!0},whenUrlRendered:i=>{P.push(i),A()},loadStored:i=>{d({layout:S(te({docs:l.layout.docs,maximized:l.layout.maximized,markup:[...l.layout.markup],stored:i,panelIds:l.layout.panelIds},r)),ready:!0}),v()},setVisibleColumns:i=>{if(!Number.isInteger(i)||i<1||i>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${String(i)}`);y=!0;const p=pe(l.layout,{logical:s,visible:i});i===l.visibleColumns&&p===l.layout||(d({visibleColumns:i,layout:p}),p!==l.layout&&v())},setSplitDragging:i=>{i!==l.splitDragging&&d({splitDragging:i})},setTitle:(i,p)=>{!l.layout.docs.includes(i)||l.titles.get(i)===p||d({titles:new Map(l.titles).set(i,p)})},titleOf:i=>ae(l.titles,i),setPendingHash:(i,p)=>{const M=l.pendingHashes.get(i);if(p===null||p===""){if(M===void 0)return;const I=new Map(l.pendingHashes);I.delete(i),d({pendingHashes:I});return}M!==p&&d({pendingHashes:new Map(l.pendingHashes).set(i,p)})},saveReadingPosition:(i,p,M)=>{l.layout.panelIds.get(p)===i&&m.set(i,{doc:p,position:M})},readingPositionOf:(i,p)=>{const M=m.get(i);return M===void 0||M.doc!==p?null:M.position},saveImageView:(i,p,M)=>{f.set(i,{url:p,state:M})},imageViewOf:(i,p)=>{const M=f.get(i);return M===void 0||M.url!==p?null:M.state}}},_=(e,n)=>{const t=()=>n(e.getSnapshot());return u.useSyncExternalStore(e.subscribe,t,t)},fn=e=>{const{config:n,storageNamespace:t}=q.useExplorer(),o=fe.useNavigate(),r=u.useRef(o),s=ne.storageKeys(t).multiLayout,[a]=u.useState(()=>mn({config:n,location:e,writeUrl:(l,y)=>{r.current(l,q.explorerNavigationOptions(y==="replace"?"browse":"switch-source"))},persist:l=>ne.writeStorage(s,l)}));u.useLayoutEffect(()=>{r.current=o},[o]);const m=fe.useLocation(),f=u.useMemo(()=>({location:e,navigated:m}),[e,m]);return u.useLayoutEffect(()=>{a.observeLocation(f.location)},[a,f]),u.useLayoutEffect(()=>{a.loadStored(un(ne.readStorage(s),n.multiView.columns))},[a,s,n]),a},pn=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},gn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:a,revealInPanel:m}=ie(),{announcer:f}=q.useExplorer(),l=_(s,d=>$e(d,n)),y=_(s,d=>d.layout.markup.has(e)),S=u.useCallback((d,v)=>a(n,e,d,v),[a,n,e]),C=u.useCallback(()=>s.setPendingHash(n,null),[s,n]),k=u.useMemo(()=>({read:d=>s.imageViewOf(n,d),save:(d,v)=>s.saveImageView(n,d,v)}),[s,n]),c=u.useCallback((d,v)=>{v.kind!=="failure"&&s.setTitle(d,v.name),r(d)},[s,r]),g=u.useCallback(d=>{s.whenUrlRendered(()=>f.announce(d))},[s,f]),w=u.useMemo(()=>({scrollerOf:pn,reveal:d=>m(n,d)}),[m,n]),h=u.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:S,pendingHash:l,onHashConsumed:C,announceFailure:g,paneScroll:w}),[t,S,l,C,g,w]),P=u.useMemo(()=>({kind:"panel",documentName:o,maximized:t}),[o,t]),T=u.useCallback(()=>s.setMarkup(e,!s.getSnapshot().layout.markup.has(e)),[s,e]),A=u.useMemo(()=>({shown:y,toggle:T}),[y,T]);return L.jsxs(q.ImageViewMemoryContext,{value:k,children:[L.jsx(q.DocumentRefreshBar,{path:e,placement:P,markup:A}),L.jsx(q.DocumentPane,{path:e,markup:y,variant:h,onDocumentShown:c})]})},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",F=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,hn=e=>e==="normal"?0:F(e),vn=(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-F(s.paddingLeft)-F(s.paddingRight),m=t.clientHeight-F(s.paddingTop)-F(s.paddingBottom);return{plan:{trackInlineSize:a,gap:hn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:m}},yn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+F(t.paddingBottom)+F(t.borderBottomWidth)},X="data-aqmx-panel-frame",ve="--aqmx-multi-panel-pinned-block-size",Sn=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}},wn=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),G=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);return n instanceof HTMLElement?n:null},Ae=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},De=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ae(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},ye=(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},En=(e,n)=>{const t=De(e,n),o=[];let r=e;for(let s=ye([...r.children],t);s>=0;s=ye([...r.children],t)){const a=r.children[s];if(a===void 0)break;o.push(s),r=a}return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:r.getBoundingClientRect().top-t}}},Se=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const r of t.anchor.path)o=o?.children[r];o!==void 0&&(n.scrollTop+=o.getBoundingClientRect().top-De(e,n)-t.anchor.offset)},On=Object.freeze(["data-testid","aria-label","title","href","id","name"]),_e=e=>JSON.stringify([e.tagName,...On.map(n=>e.getAttribute(n))]),bn=(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:_e(n)}},Cn=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&_e(o)===t.signature&&q.focusWithoutScroll(o)||n.focus({preventScroll:!0})},Pn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?G(n):n.closest(D.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=xn(e,r,t);(o||Mn(r,s))&&(e.preventDefault(),r.scrollTop+=s)},Mn=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,Ln=e=>e.scrollHeight>e.clientHeight,kn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ae(t),a=()=>{const l=yn(e,n);if(!Number.isFinite(l))return;const y=s===null?0:s.getBoundingClientRect().height;y!==r&&(r=y,t.style.setProperty(ve,`${String(y)}px`));const S=l+y;S!==o&&(o=S,e.style.setProperty(se,`${String(S)}px`))};a();let m=null;const f=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{m===null&&(m=requestAnimationFrame(()=>{m=null,a()}))});return f?.observe(e),f?.observe(n),s!==null&&f?.observe(s),()=>{f?.disconnect(),m!==null&&cancelAnimationFrame(m),e.style.removeProperty(se),t.style.removeProperty(ve)}},Tn=e=>{const{docPath:n,panelId:t}=Sn(e),{store:o,Body:r,maximize:s,focusCarry:a}=ie(),m=_(o,c=>c.layout.maximized===n),f=_(o,c=>ae(c.titles,n)),l=u.useRef(null),y=u.useRef(null),S=u.useRef(null);u.useEffect(()=>{const c=l.current,g=c===null?null:G(c);if(c===null||g===null||m)return;const w=new Map,h=v=>{const O=w.get(v);if(O!==void 0)return O;const x=wn(v);return w.set(v,x),x},P=v=>Pn(v,c,h);let T=!1;const A=()=>{const v=Ln(g);v!==T&&(T=v,v?c.addEventListener("wheel",P,{capture:!0,passive:!1}):c.removeEventListener("wheel",P,{capture:!0}))};A();const d=typeof ResizeObserver>"u"?null:new ResizeObserver(A);return d?.observe(g),d?.observe(c),()=>{d?.disconnect(),c.removeEventListener("wheel",P,{capture:!0})}},[m]),u.useLayoutEffect(()=>{const c=l.current,g=c===null?null:G(c),w=c===null?null:c.closest(`[${J}]`);if(!(c===null||g===null||!(w instanceof HTMLElement)))return kn(w,g,c)},[]),u.useLayoutEffect(()=>{const c=l.current,g=c===null?null:G(c);if(c===null||g===null)return;const w=o.readingPositionOf(t,n);y.current=w===null?null:{doc:n,position:w},w!==null&&Se(c,g,w);let h=null;const P=()=>{h===null&&(h=requestAnimationFrame(()=>{h=null;const T=S.current;T!==null&&o.saveReadingPosition(t,T,En(c,g))}))};return g.addEventListener("scroll",P,{passive:!0}),()=>{g.removeEventListener("scroll",P),h!==null&&cancelAnimationFrame(h)}},[o,t,n]),u.useLayoutEffect(()=>{const c=l.current,g=c===null?null:c.closest(`[${J}]`);if(c===null||g===null)return;const w=a.take(t);return w!==null&&Cn(g,c,w),()=>{const h=bn(g,g.ownerDocument.activeElement);h!==null&&a.hold(t,h)}},[a,t]);const C=u.useCallback(c=>{const g=l.current,w=g===null?null:G(g);if(g===null||w===null)return;const h=S.current;S.current=c;const P=y.current;y.current=null,P!==null&&P.doc===c?Se(g,w,P.position):h!==null&&h!==c&&(w.scrollTop=0)},[]),k=u.useCallback(()=>s(n),[s,n]);return L.jsx("div",{ref:l,role:"group","aria-label":f,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":m?"true":"false","data-testid":"markdown-explorer-panel-frame",onDoubleClick:m?void 0:k,children:L.jsx(r,{docPath:n,panelId:t,maximized:m,title:f,onContentShown:C})})},Rn=u.memo(Tn),K=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return t},we=e=>Object.fromEntries(D.generateColumnIds(e).map(n=>[n,[]])),Nn=(e,n)=>{const t=nn(ee(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>K(e,s))]))},In=(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]}))},An=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,customDragModeBadge:e.panelCustomDragBadge,panelMoved:e.panelMoved,panelMoveUnavailable:e.panelMoveUnavailable,panelDragStarted:e.panelDragStarted,panelDragCancelled:e.panelDragCancelled,hiddenPanels:e.hiddenPanelsTitle,hiddenPanelBadge:e.hiddenPanelBadge,hiddenPanelNotice:e.hiddenPanelNotice,emptyColumn:e.multiColumnEmpty,dropZone:e.multiColumnRegion,dropHere:e.panelDropHere}),Dn="--aqmx-multi-stage-bar-gutter",_n=Object.freeze({[Dn]:`${String(Ve.NATIVE_SCROLL_BAR_WIDTH)}px`}),zn=Object.freeze({blockSize:"100%"}),Hn=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),qn=e=>L.jsx("div",{...Hn,children:L.jsx(q.LazyNativeScrollBar,{scroller:e,withCircle:!0})}),Bn=({props:e,children:n})=>L.jsx(Fe.HostedScrollArea,{scrollerProps:{...e,style:zn},renderScrollBar:qn,children:n}),jn=e=>L.jsx(q.LazyNativeScrollBar,{scroller:e,withCircle:!1}),ue="--aqmx-stage-block",Fn="--aqmx-multi-panel-body-floor",Vn=`calc(var(${ue}) * ${String(j.PANEL_MIN_BLOCK_RATIO)})`,Un=`max(calc(var(${ue}) * ${String(j.PANEL_MAX_BLOCK_RATIO)}), calc(var(${se}) + var(${Fn})))`,$n=(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)})},xe=["keydown","pointerdown","wheel","touchstart"],Y=new WeakMap,Ee=(e,n,t)=>{for(let o=n;o!==null&&o!==t;o=o.parentElement){e.observe(o);for(let r=o.previousElementSibling;r!==null;r=r.previousElementSibling)e.observe(r)}},Gn=e=>{const n=new Map;for(let t=e.parentElement;t!==null;t=t.parentElement)n.set(t,{top:t.scrollTop,left:t.scrollLeft});return n},Z=(e,n,t)=>{Y.get(e)?.();const o=e.querySelector(`[${J}="${n}"]`);if(!(o instanceof HTMLElement))return;const r=t!==null&&o.contains(t)?t:null;let s=new Map;const a=()=>{if(!o.isConnected)return;o.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});const S=r?.isConnected===!0?r:o;S!==o&&S.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}),s=Gn(S)};if(a(),typeof ResizeObserver>"u")return;const m=new ResizeObserver(a);Ee(m,o,o.closest(D.SCROLL_ROOT_SELECTOR)),r!==null&&Ee(m,r,o);const{ownerDocument:f}=e,l=S=>{const C=S.target===f?f.scrollingElement:S.target;if(!(C instanceof Element))return;const k=s.get(C);k!==void 0&&(C.scrollTop!==k.top||C.scrollLeft!==k.left)&&y()},y=()=>{m.disconnect();for(const S of xe)f.removeEventListener(S,y,!0);f.removeEventListener("scroll",l,!0),Y.get(e)===y&&Y.delete(e)};for(const S of xe)f.addEventListener(S,y,{capture:!0,passive:!0});f.addEventListener("scroll",l,{capture:!0,passive:!0}),Y.set(e,y)},ze=(e,n)=>{const t=e.querySelector(`[${X}="${n}"]`);return t instanceof HTMLElement?(Z(e,n,null),t.focus({preventScroll:!0}),!0):!1},de=(e,n)=>{const t=e.querySelector(`[${J}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},Oe=(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"}},be=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&ze(t,n.panelId)||t.focus({preventScroll:!0}))})},He=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&ze(t,n)})},Yn=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(Z(o,n,t&&de(o,n)?r:null),!t||r!==null&&r!==s&&r.isConnected)return;const a=o.querySelector(`[${X}="${n}"]`);a instanceof HTMLElement&&a.focus({preventScroll:!0})})},Wn=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r,edits:s}=q.useExplorer(),{maximize:a}=ie(),m=t.multiView.columns,f=_(e,E=>E.layout),l=_(e,E=>E.visibleColumns),y=_(e,E=>E.titles),S=_(e,E=>E.layout.maximized!==null||E.splitDragging),[C,k]=u.useState(!1),[c]=u.useState(()=>we(l)),g=u.useMemo(()=>An(o),[o]),w=u.useCallback(E=>{e.arrange(In(e.getSnapshot().layout,E))},[e]),h=D.useDragDropColumns({initialColumnPanels:c,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:w}),{columnPanels:P,setColumnPanels:T}=h,A=u.useRef(S),d=u.useRef(P);u.useLayoutEffect(()=>{A.current=S,d.current=P},[S,P]);const v=u.useCallback(E=>{const b=n.current;if(b===null)return;const{plan:B,stageBlockSize:z}=vn(b,m);if(Number.isFinite(z)&&z>0&&b.style.setProperty(ue,`${String(z)}px`),A.current&&!E)return;const H=j.replanVisibleColumns(e.getSnapshot().visibleColumns,B);H!==null&&e.setVisibleColumns(H)},[e,n,m]);u.useLayoutEffect(()=>{v(!0),k(!0)},[v]),u.useEffect(()=>{const E=n.current;if(E===null||typeof ResizeObserver>"u")return;let b=null;const B=new ResizeObserver(()=>{b===null&&(b=requestAnimationFrame(()=>{b=null,v(!1)}))}),z=E.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,H=E.querySelector(`[${ce}]`);return z instanceof Element&&B.observe(z),H instanceof Element&&B.observe(H),()=>{B.disconnect(),b!==null&&cancelAnimationFrame(b)}},[n,v]),u.useEffect(()=>{S||v(!1)},[S,v]);const O=u.useMemo(()=>C?Nn(f,{logical:m,visible:l}):we(l),[C,f,m,l]);u.useLayoutEffect(()=>{$n(d.current,O)||T(O)},[O,T]);const x=u.useMemo(()=>D.sortColumnIds(Object.keys(P)).map(E=>({id:E,key:E,className:"aqmx-multi-column"})),[P]),R=u.useMemo(()=>f.docs.map(E=>{const b=K(f,E);return{id:b,component:Rn,title:ae(y,E),props:{docPath:E,panelId:b},minHeight:Vn,maxHeight:Un}}),[f,y]),N=u.useMemo(()=>Object.fromEntries(f.docs.map(E=>[K(f,E),!f.hidden.has(E)])),[f]),i=f.maximized===null?null:K(f,f.maximized),p=u.useCallback(E=>{const{layout:b}=e.getSnapshot();for(const[B,z]of W(b)){const H=E[B];if(H===void 0||H!==b.hidden.has(z))continue;const V=e.titleOf(z);if(H){if(!e.setHidden(z,!1))continue;r.announce(o.panelShown(V)),He(n,B);continue}const U=n.current,me=U===null?null:Oe(U,B);e.setHidden(z,!0)&&(r.announce(o.panelHidden(V)),me!==null&&be(n,me))}},[e,n,r,o]),M=u.useCallback(E=>{const b=W(e.getSnapshot().layout).get(E);if(b===void 0)return;const B=()=>{const H=e.titleOf(b),V=n.current,U=V===null?null:Oe(V,E);e.close(b)&&(r.announce(o.panelClosed(H)),U!==null&&be(n,U))},z=s.unsavedAmong([b]);z.length===0?B():s.askToDiscard(z).then(H=>{H&&B()})},[e,n,r,o,s]),I=u.useCallback(E=>{if(E===null){a(null);return}const b=W(e.getSnapshot().layout).get(E);b!==void 0&&a(b)},[e,a]);return L.jsx("div",{className:"aqmx-multi-layout","aria-busy":!C,children:L.jsx(D.DragDropLayout,{columns:x,panels:R,columnPanels:P,onColumnPanelsChange:w,panelVisibility:N,onPanelVisibilityChange:p,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:M,onPanelMaximizeChange:I,maximizedPanel:i,dragHandle:"header",labels:g,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:Bn,renderStageScrollBar:jn})})},oe={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},Kn=(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),f=m.findIndex(y=>n.contains(y)),l=m.findIndex(y=>e.contains(y));return f!==-1&&l!==-1&&l<f}))},Jn=(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()}},Xn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:a,announcer:m,edits:f}=q.useExplorer(),l=u.useRef(null),y=u.useRef(null),S=_(e,d=>d.ready),C=_(e,d=>d.layout.docs.length>0),k=_(e,d=>d.visibleColumns),c=u.use(re.SheetNoticeSlotContext),g=u.useCallback(d=>{const{layout:v}=e.getSnapshot(),O=v.maximized,x=d===null&&O!==null?v.panelIds.get(O):void 0,R=l.current,N=x!==void 0&&R!==null&&de(R,x);e.maximize(d)&&(d!==null?m.announce(a.panelMaximized(e.titleOf(d))):O!==null&&m.announce(a.panelRestored(e.titleOf(O))),x!==void 0&&Yn(l,x,N))},[e,m,a]),w=u.useCallback((d,v,O,x)=>{if(O===v){e.setPendingHash(d,x);return}const R=f.unsavedAmong([v]);if(R.length>0){f.askToDiscard(R).then(M=>{M&&w(d,v,O,x)});return}const N=e.navigate(v,O);if(N==="navigated"){e.setPendingHash(d,x);return}if(N!=="existing")return;const{layout:i}=e.getSnapshot(),p=i.panelIds.get(O);p!==void 0&&(m.announce(a.panelAlreadyOpen(e.titleOf(O))),i.maximized===null?e.setHidden(O,!1):g(O),e.setPendingHash(p,x),He(l,p))},[e,m,a,g,f]);u.useLayoutEffect(()=>{if(t===null||c!==null||!he())return;const d=y.current,v=l.current;if(d===null||v===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return Jn(d,v)},[t,c]),u.useEffect(()=>{const d=y.current;if(t===null||d===null)return;const{ownerDocument:v}=d;let O=null;const x=R=>{const N=R.target;N instanceof Element&&(O!==null&&cancelAnimationFrame(O),O=requestAnimationFrame(()=>{O=null,v.activeElement===N&&d.isConnected&&Kn(d,N)&&o()}))};return v.addEventListener("focusin",x,!0),()=>{v.removeEventListener("focusin",x,!0),O!==null&&cancelAnimationFrame(O)}},[t,c,o]),u.useImperativeHandle(r,()=>({bringIntoView:d=>{requestAnimationFrame(()=>{const v=l.current,O=e.getSnapshot().layout.panelIds.get(d);v!==null&&O!==void 0&&Z(v,O,null)})}}),[e]),u.useEffect(()=>{const d=l.current;return()=>{d!==null&&Y.get(d)?.()}},[]);const h=u.useCallback((d,v)=>{const O=l.current;O!==null&&Z(O,d,v)},[]),[P]=u.useState(Ue),T=u.useMemo(()=>({store:e,Body:n,followLink:w,maximize:g,revealInPanel:h,focusCarry:P}),[e,n,w,g,h,P]),A=u.useMemo(()=>Array.from({length:s.multiView.columns},(d,v)=>D.generateColumnId(v)),[s]);return L.jsxs("section",{ref:l,className:"aqmx-multi-stage",style:_n,tabIndex:-1,"aria-label":a.multiRegion,"aria-busy":C&&!S,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":k,children:[L.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[ce]:""}),C?S?L.jsx(Pe,{value:T,children:L.jsx(Wn,{store:e,stageRef:l})}):L.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:A.map(d=>L.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[L.jsx("span",{}),L.jsx("span",{}),L.jsx("span",{})]},d))}):L.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:L.jsx("p",{className:"aqmx-empty-title",children:a.multiEmpty})}),t===null?null:c!==null?je.createPortal(L.jsx("div",{ref:y,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),c):L.jsx("div",{ref:y,popover:he()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},qe=3e3,Be=(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},Zn=(e,n,t)=>{switch(n){case"opened":return e.panelOpened(t);case"shown":return e.panelShown(t);case"closed":return e.panelClosed(t);default:{const o=n;throw new RangeError(`[markdown-explorer] unknown toggle outcome ${JSON.stringify(o)}`)}}},Qn=({location:e})=>{const{config:n,labels:t,announcer:o}=q.useExplorer(),r=fn(e),s=_(r,x=>x.layout.docs),a=_(r,x=>x.layout.maximized),m=_(r,x=>x.layout.markup),f=_(r,x=>x.source),[l,y]=u.useState(()=>({docs:s,latest:le([],s,null)}));l.docs!==s&&y({docs:s,latest:le(l.docs,s,l.latest)});const S=a!==null?a:l.latest,[C,k]=u.useState(!1),c=u.useRef(null),[g,w]=u.useState(0),h=u.useRef(null),P=u.useRef(null);u.useLayoutEffect(()=>{const x=h.current;h.current=null,x!==null&&(r.whenUrlRendered(()=>o.announce(x.announcement)),P.current?.bringIntoView(x.doc))}),u.useEffect(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);const T=u.useCallback(()=>{c.current!==null&&clearTimeout(c.current),k(!0),c.current=setTimeout(()=>{c.current=null,k(!1)},qe)},[]),A=u.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=null,k(!1)},[]),d=u.useCallback(x=>{const R=r.titleOf(x),N=r.toggle(x);N==="rejected"&&T();const i=N==="rejected"?t.panelLimit(n.multiView.maxPanels):Zn(t,N,R);if(N==="shown"){h.current={doc:x,announcement:i},w(p=>p+1);return}r.whenUrlRendered(()=>{o.announce(i),N==="opened"&&P.current?.bringIntoView(x)})},[r,T,o,t,n]),v=u.useMemo(()=>new Set(s),[s]),O=u.useMemo(()=>{const x=Be(s,a);return{href:j.explorerHref(n,{view:"tree",source:f,doc:x,markup:x!==null&&m.has(x)}),target:"tree"}},[n,f,s,a,m]);return L.jsx(re.ExplorerSplit,{view:"multi",explorer:L.jsx(re.ExplorerPane,{mode:"multi",sourceId:f,currentPath:S,openPaths:v,onOpenDocument:d,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:O}),content:L.jsx(Xn,{ref:P,store:r,body:gn,limitNotice:C?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:A}),contentCoversPage:a!==null,sheetDismissals:g,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Qn;exports.PANEL_LIMIT_NOTICE_MS=qe;exports.latestOpenedDocument=le;exports.treeSwitchDocument=Be;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),u=require("react"),j=require("./location-DmzVAFvo.cjs"),q=require("./index-BBtIYTXJ.cjs"),re=require("./ExplorerSplit-Brdh9fCW.cjs"),D=require("@aiquants/drag-drop-panels"),fe=require("react-router"),ne=require("./storage-Dgi4JXaB.cjs"),Ce=require("./dataRoute-CcZ8PK00.cjs"),je=require("react-dom"),Fe=require("@aiquants/markdown"),Ve=require("./scrollBarGeometry-C46jBtmM.cjs"),Ue=()=>{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}}},Pe=u.createContext(null),ie=()=>{const e=u.use(Pe);if(e===null)throw new Error("[markdown-explorer] multi-view panels must be rendered inside the multi-view stage");return e},$e=(e,n)=>{const t=e.pendingHashes.get(n);return t===void 0?null:t},Ge=0xcbf29ce484222325n,Ye=0x100000001b3n,We=(1n<<64n)-1n,Ke=(1n<<53n)-1n,Je=new TextEncoder,Xe=e=>{let n=Ge;for(const t of Je.encode(e))n=(n^BigInt(t))*Ye&We;return Number(n&Ke)},Q=256,Ze=e=>`aqmx-p-${Xe(e).toString(36)}`,Me=(e,n)=>{const t=Ze(e);let o=t;for(let r=2;n.has(o);r+=1)o=`${t}-${String(r)}`;return o},Qe=new Map,en=(e,n=Qe)=>{const t=new Set(e.flatMap(r=>n.get(r)??[])),o=new Map;for(const r of e){const s=n.get(r)??Me(r,t);t.add(s),o.set(r,s)}return o},Le=(e,n,t)=>{const o=e.columnOf.get(n);return o===void 0?void 0:Math.min(t-1,Math.max(0,o))},ke=(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,f])=>e.slice(m,f).reduce((l,y)=>l+y.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=Le(e,r,n.logical);s===void 0?o.push(r):t[s]?.push(r)}for(const r of o)t[ke(t,n)]?.push(r);return t},nn=(e,n)=>j.columnGroups(e.length,n).map(([t,o])=>e.slice(t,o).flat()),tn=(e,n,t)=>{const[o,r]=n,s=r-o,a=e.length,m=Array.from({length:s},(c,g)=>{const w=[0];for(const h of e)w.push((w.at(-1)??0)+(t(h)===o+g?1:0));return w}),f=(c,g,w)=>(m[c]?.[w]??0)-(m[c]?.[g]??0),l=Array.from({length:s+1},()=>Array.from({length:a+1},()=>Number.NEGATIVE_INFINITY)),y=Array.from({length:s+1},()=>Array.from({length:a+1},()=>0)),S=l[0];S&&(S[0]=0);for(let c=0;c<s;c+=1)for(let g=0;g<=a;g+=1)for(let w=0;w<=g;w+=1){const h=(l[c]?.[w]??Number.NEGATIVE_INFINITY)+f(c,w,g),P=l[c+1],T=y[c+1];P&&T&&h>(P[g]??Number.NEGATIVE_INFINITY)&&(P[g]=h,T[g]=w)}const C=Array.from({length:s},()=>[]);let k=a;for(let c=s;c>0;c-=1){const g=y[c]?.[k]??0;C[c-1]=e.slice(g,k),k=g}return C},Te=(e,n)=>{const t=n.flat(),o=new Map(e.columnOf);for(const[r,s]of n.entries())for(const a of s)o.delete(a),o.set(a,r);for(const r of o.keys()){if(o.size<=Q)break;o.delete(r)}return{docs:t,columnOf:o}},on=(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=Le(e,n,t.logical)??ke(r,t);r[s]?.push(n);const a=new Map(e.panelIds);return a.set(n,Me(n,new Set(a.values()))),{state:{...e,...Te(e,r),panelIds:a},outcome:"opened"}},Re=(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}},rn=(e,n,t,o)=>{if(e.hidden.has(n))return{state:Ne(e,n,!1),outcome:"shown"};if(e.docs.includes(n))return{state:Re(e,n),outcome:"closed"};const r=on(e,n,t,o);return{state:r.state,outcome:r.outcome==="rejected"?"rejected":"opened"}},sn=(e,n,t)=>{if(n===t||!e.docs.includes(n))return{state:e,outcome:"ignored"};if(e.docs.includes(t))return{state:e,outcome:"existing"};const o=new Map(e.columnOf),r=o.get(n);r!==void 0&&(o.delete(t),o.set(t,r));const s=new Set(e.hidden);s.delete(n);const a=new Map(e.panelIds),m=a.get(n);if(m===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);a.delete(n),a.set(t,m);const f=new Set(e.markup);return f.delete(n),{state:{docs:e.docs.map(l=>l===n?t:l),maximized:e.maximized===n?t:e.maximized,columnOf:o,hidden:s,markup:f,panelIds:a},outcome:"navigated"}},Ne=(e,n,t)=>{if(!e.docs.includes(n)||e.hidden.has(n)===t)return e;const o=new Set(e.hidden);return t?o.add(n):o.delete(n),{...e,hidden:o,maximized:t&&e.maximized===n?null:e.maximized}},ln=(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}},an=(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}},cn=(e,n,t)=>{const o=ee(e,t),r=new Map;for(const[l,y]of o.entries())for(const S of y)r.set(S,l);const s=new Set(e.docs),a=new Set,m=j.columnGroups(t.logical,t.visible),f=Array.from({length:t.logical},()=>[]);for(const[l,y]of m.entries()){const S=(n[l]??[]).filter(C=>s.has(C)&&!a.has(C));for(const C of S)a.add(C);for(const[C,k]of tn(S,y,c=>r.get(c)).entries())f[y[0]+C]?.push(...k)}for(const l of e.docs)a.has(l)||f[r.get(l)??0]?.push(l);return f.every((l,y)=>l.length===o[y]?.length&&l.every((S,C)=>o[y]?.[C]===S))?e:{...e,...Te(e,f)}},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:en(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}},Ie=1,$=Object.freeze({columnOf:new Map,hidden:new Set}),un=(e,n)=>{if(e===null||e==="")return $;let t;try{t=JSON.parse(e)}catch{return $}if(t===null||typeof t!="object"||Array.isArray(t))return $;const o=t;if(o.v!==Ie)return $;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}},dn=e=>JSON.stringify({v:Ie,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: ${JSON.stringify(e.slice(0,80))}`)},mn=({config:e,location:n,writeUrl:t,persist:o})=>{const{maxPanels:r,columns:s}=e.multiView,a=q.createEmitter(),m=new Map,f=new Map;let l={layout:te({docs:n.docs,maximized:n.maximized,markup:n.markup,stored:$},r),source:n.source,visibleColumns:s,ready:!1,splitDragging:!1,titles:new Map,pendingHashes:new Map},y=!1;const S=i=>y?pe(i,{logical:s,visible:l.visibleColumns}):i,C=(i,p)=>j.explorerHref(e,{view:"multi",source:i,docs:p.docs,maximized:p.maximized,markup:p.markup}),k=i=>({docs:i.docs,maximized:i.maximized,markup:[...i.markup]});let c=C(n.source,n),g=n.source,w=c;const h=[],P=[];let T=null;const A=()=>{if(!(h.length>0))for(const i of P.splice(0))i()},d=i=>{l={...l,...i},a.emit()},v=()=>{if(!l.ready)return;const i=dn(l.layout);i!==T&&(T=i,o(i))},O=(i,p,M)=>{const I=C(i,k(p));I!==c&&(c=I,g=i,h.push(I),t(I,M))},x=i=>{const p=new Set(i.panelIds.values());for(const b of[...m.keys()])p.has(b)||m.delete(b);for(const b of[...f.keys()])p.has(b)||f.delete(b);const M=new Set(i.docs),I=[...l.titles.keys()].every(b=>M.has(b))?l.titles:new Map([...l.titles].filter(([b])=>M.has(b))),E=[...l.pendingHashes.keys()].every(b=>p.has(b))?l.pendingHashes:new Map([...l.pendingHashes].filter(([b])=>p.has(b)));return{titles:I,pendingHashes:E}},R=i=>i===l.layout?!1:(d({layout:i,...x(i)}),O(g,i,"replace"),v(),!0),N=()=>({logical:s,visible:l.visibleColumns});return{getSnapshot:()=>l,subscribe:a.subscribe,toggle:i=>{ge(i);const{state:p,outcome:M}=rn(l.layout,i,N(),r);return R(p),M},close:i=>R(Re(l.layout,i)),navigate:(i,p)=>{ge(p);const{state:M,outcome:I}=sn(l.layout,i,p);if(I!=="navigated")return I;const E=M.panelIds.get(p);return E!==void 0&&(m.delete(E),f.delete(E)),R(M),I},setHidden:(i,p)=>R(Ne(l.layout,i,p)),maximize:i=>R(an(l.layout,i)),setMarkup:(i,p)=>R(ln(l.layout,i,p)),arrange:i=>R(cn(l.layout,i,{logical:s,visible:i.length})),changeSource:i=>{O(i,l.layout,"push")},revealSource:i=>{O(i,l.layout,"replace")},observeLocation:i=>{const p=C(i.source,i);if(p===c)return h.length=0,w=p,i.source!==l.source&&d({source:i.source}),A(),!1;if(p===w)return!1;w=p;const M=h.indexOf(p);if(M>=0)return h.splice(0,M+1),i.source!==l.source&&d({source:i.source}),A(),!1;h.length=0,c=p,g=i.source;const I=S(te({docs:i.docs,maximized:i.maximized,markup:i.markup,stored:{columnOf:l.layout.columnOf,hidden:l.layout.hidden},panelIds:l.layout.panelIds},r));return d({layout:I,source:i.source,...x(I)}),v(),A(),!0},whenUrlRendered:i=>{P.push(i),A()},loadStored:i=>{d({layout:S(te({docs:l.layout.docs,maximized:l.layout.maximized,markup:[...l.layout.markup],stored:i,panelIds:l.layout.panelIds},r)),ready:!0}),v()},setVisibleColumns:i=>{if(!Number.isInteger(i)||i<1||i>s)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(s)}; got ${String(i)}`);y=!0;const p=pe(l.layout,{logical:s,visible:i});i===l.visibleColumns&&p===l.layout||(d({visibleColumns:i,layout:p}),p!==l.layout&&v())},setSplitDragging:i=>{i!==l.splitDragging&&d({splitDragging:i})},setTitle:(i,p)=>{!l.layout.docs.includes(i)||l.titles.get(i)===p||d({titles:new Map(l.titles).set(i,p)})},titleOf:i=>ae(l.titles,i),setPendingHash:(i,p)=>{const M=l.pendingHashes.get(i);if(p===null||p===""){if(M===void 0)return;const I=new Map(l.pendingHashes);I.delete(i),d({pendingHashes:I});return}M!==p&&d({pendingHashes:new Map(l.pendingHashes).set(i,p)})},saveReadingPosition:(i,p,M)=>{l.layout.panelIds.get(p)===i&&m.set(i,{doc:p,position:M})},readingPositionOf:(i,p)=>{const M=m.get(i);return M===void 0||M.doc!==p?null:M.position},saveImageView:(i,p,M)=>{f.set(i,{url:p,state:M})},imageViewOf:(i,p)=>{const M=f.get(i);return M===void 0||M.url!==p?null:M.state}}},_=(e,n)=>{const t=()=>n(e.getSnapshot());return u.useSyncExternalStore(e.subscribe,t,t)},fn=e=>{const{config:n,storageNamespace:t}=q.useExplorer(),o=fe.useNavigate(),r=u.useRef(o),s=ne.storageKeys(t).multiLayout,[a]=u.useState(()=>mn({config:n,location:e,writeUrl:(l,y)=>{r.current(l,q.explorerNavigationOptions(y==="replace"?"browse":"switch-source"))},persist:l=>ne.writeStorage(s,l)}));u.useLayoutEffect(()=>{r.current=o},[o]);const m=fe.useLocation(),f=u.useMemo(()=>({location:e,navigated:m}),[e,m]);return u.useLayoutEffect(()=>{a.observeLocation(f.location)},[a,f]),u.useLayoutEffect(()=>{a.loadStored(un(ne.readStorage(s),n.multiView.columns))},[a,s,n]),a},pn=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},gn=({docPath:e,panelId:n,maximized:t,title:o,onContentShown:r})=>{const{store:s,followLink:a,revealInPanel:m}=ie(),{announcer:f}=q.useExplorer(),l=_(s,d=>$e(d,n)),y=_(s,d=>d.layout.markup.has(e)),S=u.useCallback((d,v)=>a(n,e,d,v),[a,n,e]),C=u.useCallback(()=>s.setPendingHash(n,null),[s,n]),k=u.useMemo(()=>({read:d=>s.imageViewOf(n,d),save:(d,v)=>s.saveImageView(n,d,v)}),[s,n]),c=u.useCallback((d,v)=>{v.kind!=="failure"&&s.setTitle(d,v.name),r(d)},[s,r]),g=u.useCallback(d=>{s.whenUrlRendered(()=>f.announce(d))},[s,f]),w=u.useMemo(()=>({scrollerOf:pn,reveal:d=>m(n,d)}),[m,n]),h=u.useMemo(()=>({kind:"panel",maximized:t,onDocumentLink:S,pendingHash:l,onHashConsumed:C,announceFailure:g,paneScroll:w}),[t,S,l,C,g,w]),P=u.useMemo(()=>({kind:"panel",documentName:o,maximized:t}),[o,t]),T=u.useCallback(()=>s.setMarkup(e,!s.getSnapshot().layout.markup.has(e)),[s,e]),A=u.useMemo(()=>({shown:y,toggle:T}),[y,T]);return L.jsxs(q.ImageViewMemoryContext,{value:k,children:[L.jsx(q.DocumentRefreshBar,{path:e,placement:P,markup:A}),L.jsx(q.DocumentPane,{path:e,markup:y,variant:h,onDocumentShown:c})]})},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",F=e=>e.endsWith("px")?Number.parseFloat(e):Number.NaN,hn=e=>e==="normal"?0:F(e),vn=(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-F(s.paddingLeft)-F(s.paddingRight),m=t.clientHeight-F(s.paddingTop)-F(s.paddingBottom);return{plan:{trackInlineSize:a,gap:hn(s.columnGap),minColumnInlineSize:r,logicalColumns:n},stageBlockSize:m}},yn=(e,n)=>{if(e.getClientRects().length===0)return Number.NaN;const t=getComputedStyle(e);return n.getBoundingClientRect().top-e.getBoundingClientRect().top+F(t.paddingBottom)+F(t.borderBottomWidth)},X="data-aqmx-panel-frame",ve="--aqmx-multi-panel-pinned-block-size",Sn=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}},wn=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),G=e=>{const n=e.closest(D.SCROLL_AREA_SELECTOR);return n instanceof HTMLElement?n:null},Ae=e=>{const n=e.firstElementChild;return n instanceof HTMLElement&&getComputedStyle(n).position==="sticky"?n:null},De=(e,n)=>{const t=n.getBoundingClientRect().top,o=Ae(e);return o===null?t:Math.max(t,o.getBoundingClientRect().bottom)},ye=(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},En=(e,n)=>{const t=De(e,n),o=[];let r=e;for(let s=ye([...r.children],t);s>=0;s=ye([...r.children],t)){const a=r.children[s];if(a===void 0)break;o.push(s),r=a}return{scrollTop:n.scrollTop,anchor:o.length===0?null:{path:o,offset:r.getBoundingClientRect().top-t}}},Se=(e,n,t)=>{if(n.scrollTop=t.scrollTop,t.anchor===null)return;let o=e;for(const r of t.anchor.path)o=o?.children[r];o!==void 0&&(n.scrollTop+=o.getBoundingClientRect().top-De(e,n)-t.anchor.offset)},On=Object.freeze(["data-testid","aria-label","title","href","id","name"]),_e=e=>JSON.stringify([e.tagName,...On.map(n=>e.getAttribute(n))]),bn=(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:_e(n)}},Cn=(e,n,t)=>{let o=e;for(const r of t.path)o=o?.children[r];o instanceof HTMLElement&&_e(o)===t.signature&&q.focusWithoutScroll(o)||n.focus({preventScroll:!0})},Pn=(e,n,t)=>{if(e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))return;const o=e.ctrlKey||e.metaKey,r=o?G(n):n.closest(D.SCROLL_ROOT_SELECTOR);if(!(r instanceof HTMLElement))return;const s=xn(e,r,t);(o||Mn(r,s))&&(e.preventDefault(),r.scrollTop+=s)},Mn=(e,n)=>n<0?e.scrollTop>0:n>0?Math.ceil(e.scrollTop+e.clientHeight)<e.scrollHeight:!1,Ln=e=>e.scrollHeight>e.clientHeight,kn=(e,n,t)=>{let o=Number.NaN,r=Number.NaN;const s=Ae(t),a=()=>{const l=yn(e,n);if(!Number.isFinite(l))return;const y=s===null?0:s.getBoundingClientRect().height;y!==r&&(r=y,t.style.setProperty(ve,`${String(y)}px`));const S=l+y;S!==o&&(o=S,e.style.setProperty(se,`${String(S)}px`))};a();let m=null;const f=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{m===null&&(m=requestAnimationFrame(()=>{m=null,a()}))});return f?.observe(e),f?.observe(n),s!==null&&f?.observe(s),()=>{f?.disconnect(),m!==null&&cancelAnimationFrame(m),e.style.removeProperty(se),t.style.removeProperty(ve)}},Tn=e=>{const{docPath:n,panelId:t}=Sn(e),{store:o,Body:r,maximize:s,focusCarry:a}=ie(),m=_(o,c=>c.layout.maximized===n),f=_(o,c=>ae(c.titles,n)),l=u.useRef(null),y=u.useRef(null),S=u.useRef(null);u.useEffect(()=>{const c=l.current,g=c===null?null:G(c);if(c===null||g===null||m)return;const w=new Map,h=v=>{const O=w.get(v);if(O!==void 0)return O;const x=wn(v);return w.set(v,x),x},P=v=>Pn(v,c,h);let T=!1;const A=()=>{const v=Ln(g);v!==T&&(T=v,v?c.addEventListener("wheel",P,{capture:!0,passive:!1}):c.removeEventListener("wheel",P,{capture:!0}))};A();const d=typeof ResizeObserver>"u"?null:new ResizeObserver(A);return d?.observe(g),d?.observe(c),()=>{d?.disconnect(),c.removeEventListener("wheel",P,{capture:!0})}},[m]),u.useLayoutEffect(()=>{const c=l.current,g=c===null?null:G(c),w=c===null?null:c.closest(`[${J}]`);if(!(c===null||g===null||!(w instanceof HTMLElement)))return kn(w,g,c)},[]),u.useLayoutEffect(()=>{const c=l.current,g=c===null?null:G(c);if(c===null||g===null)return;const w=o.readingPositionOf(t,n);y.current=w===null?null:{doc:n,position:w},w!==null&&Se(c,g,w);let h=null;const P=()=>{h===null&&(h=requestAnimationFrame(()=>{h=null;const T=S.current;T!==null&&o.saveReadingPosition(t,T,En(c,g))}))};return g.addEventListener("scroll",P,{passive:!0}),()=>{g.removeEventListener("scroll",P),h!==null&&cancelAnimationFrame(h)}},[o,t,n]),u.useLayoutEffect(()=>{const c=l.current,g=c===null?null:c.closest(`[${J}]`);if(c===null||g===null)return;const w=a.take(t);return w!==null&&Cn(g,c,w),()=>{const h=bn(g,g.ownerDocument.activeElement);h!==null&&a.hold(t,h)}},[a,t]);const C=u.useCallback(c=>{const g=l.current,w=g===null?null:G(g);if(g===null||w===null)return;const h=S.current;S.current=c;const P=y.current;y.current=null,P!==null&&P.doc===c?Se(g,w,P.position):h!==null&&h!==c&&(w.scrollTop=0)},[]),k=u.useCallback(()=>s(n),[s,n]);return L.jsx("div",{ref:l,role:"group","aria-label":f,className:"aqmx-multi-panel-frame",tabIndex:-1,"data-aqmx-panel-frame":t,"data-aqmx-maximized":m?"true":"false","data-testid":"markdown-explorer-panel-frame",onDoubleClick:m?void 0:k,children:L.jsx(r,{docPath:n,panelId:t,maximized:m,title:f,onContentShown:C})})},Rn=u.memo(Tn),K=(e,n)=>{const t=e.panelIds.get(n);if(t===void 0)throw new Error(`[markdown-explorer] the open document ${JSON.stringify(n)} has no panel id`);return t},we=e=>Object.fromEntries(D.generateColumnIds(e).map(n=>[n,[]])),Nn=(e,n)=>{const t=nn(ee(e,n),n.visible);return Object.fromEntries(t.map((o,r)=>[D.generateColumnId(r),o.map(s=>K(e,s))]))},In=(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]}))},An=e=>({switchToCustomDragMode:e.panelSwitchToCustomDrag,switchToNormalDragMode:e.panelSwitchToNormalDrag,hidePanel:e.panelHide,maximizePanel:e.panelMaximize,restorePanel:e.panelRestore,closePanel:e.panelClose,movePanelToPreviousColumn:e.panelMovePreviousColumn,movePanelToNextColumn:e.panelMoveNextColumn,movePanelUp:e.panelMoveUp,movePanelDown:e.panelMoveDown,customDragModeBadge:e.panelCustomDragBadge,panelMoved:e.panelMoved,panelMoveUnavailable:e.panelMoveUnavailable,panelDragStarted:e.panelDragStarted,panelDragCancelled:e.panelDragCancelled,hiddenPanels:e.hiddenPanelsTitle,hiddenPanelBadge:e.hiddenPanelBadge,hiddenPanelNotice:e.hiddenPanelNotice,emptyColumn:e.multiColumnEmpty,dropZone:e.multiColumnRegion,dropHere:e.panelDropHere}),Dn="--aqmx-multi-stage-bar-gutter",_n=Object.freeze({[Dn]:`${String(Ve.NATIVE_SCROLL_BAR_WIDTH)}px`}),zn=Object.freeze({blockSize:"100%"}),Hn=Object.freeze({[D.NO_PANEL_DRAG_ATTRIBUTE]:"",style:Object.freeze({display:"flex"})}),qn=e=>L.jsx("div",{...Hn,children:L.jsx(q.LazyNativeScrollBar,{scroller:e,withCircle:!0})}),Bn=({props:e,children:n})=>L.jsx(Fe.HostedScrollArea,{scrollerProps:{...e,style:zn},renderScrollBar:qn,children:n}),jn=e=>L.jsx(q.LazyNativeScrollBar,{scroller:e,withCircle:!1}),ue="--aqmx-stage-block",Fn="--aqmx-multi-panel-body-floor",Vn=`calc(var(${ue}) * ${String(j.PANEL_MIN_BLOCK_RATIO)})`,Un=`max(calc(var(${ue}) * ${String(j.PANEL_MAX_BLOCK_RATIO)}), calc(var(${se}) + var(${Fn})))`,$n=(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)})},xe=["keydown","pointerdown","wheel","touchstart"],Y=new WeakMap,Ee=(e,n,t)=>{for(let o=n;o!==null&&o!==t;o=o.parentElement){e.observe(o);for(let r=o.previousElementSibling;r!==null;r=r.previousElementSibling)e.observe(r)}},Gn=e=>{const n=new Map;for(let t=e.parentElement;t!==null;t=t.parentElement)n.set(t,{top:t.scrollTop,left:t.scrollLeft});return n},Z=(e,n,t)=>{Y.get(e)?.();const o=e.querySelector(`[${J}="${n}"]`);if(!(o instanceof HTMLElement))return;const r=t!==null&&o.contains(t)?t:null;let s=new Map;const a=()=>{if(!o.isConnected)return;o.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"});const S=r?.isConnected===!0?r:o;S!==o&&S.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"}),s=Gn(S)};if(a(),typeof ResizeObserver>"u")return;const m=new ResizeObserver(a);Ee(m,o,o.closest(D.SCROLL_ROOT_SELECTOR)),r!==null&&Ee(m,r,o);const{ownerDocument:f}=e,l=S=>{const C=S.target===f?f.scrollingElement:S.target;if(!(C instanceof Element))return;const k=s.get(C);k!==void 0&&(C.scrollTop!==k.top||C.scrollLeft!==k.left)&&y()},y=()=>{m.disconnect();for(const S of xe)f.removeEventListener(S,y,!0);f.removeEventListener("scroll",l,!0),Y.get(e)===y&&Y.delete(e)};for(const S of xe)f.addEventListener(S,y,{capture:!0,passive:!0});f.addEventListener("scroll",l,{capture:!0,passive:!0}),Y.set(e,y)},ze=(e,n)=>{const t=e.querySelector(`[${X}="${n}"]`);return t instanceof HTMLElement?(Z(e,n,null),t.focus({preventScroll:!0}),!0):!1},de=(e,n)=>{const t=e.querySelector(`[${J}="${n}"]`);return t instanceof HTMLElement&&t.contains(e.ownerDocument.activeElement)},Oe=(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"}},be=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&(n.kind==="panel"&&ze(t,n.panelId)||t.focus({preventScroll:!0}))})},He=(e,n)=>{requestAnimationFrame(()=>{const t=e.current;t!==null&&ze(t,n)})},Yn=(e,n,t)=>{requestAnimationFrame(()=>{const o=e.current;if(o===null)return;const{activeElement:r,body:s}=o.ownerDocument;if(Z(o,n,t&&de(o,n)?r:null),!t||r!==null&&r!==s&&r.isConnected)return;const a=o.querySelector(`[${X}="${n}"]`);a instanceof HTMLElement&&a.focus({preventScroll:!0})})},Wn=({store:e,stageRef:n})=>{const{config:t,labels:o,announcer:r,edits:s}=q.useExplorer(),{maximize:a}=ie(),m=t.multiView.columns,f=_(e,E=>E.layout),l=_(e,E=>E.visibleColumns),y=_(e,E=>E.titles),S=_(e,E=>E.layout.maximized!==null||E.splitDragging),[C,k]=u.useState(!1),[c]=u.useState(()=>we(l)),g=u.useMemo(()=>An(o),[o]),w=u.useCallback(E=>{e.arrange(In(e.getSnapshot().layout,E))},[e]),h=D.useDragDropColumns({initialColumnPanels:c,initialPanelVisibility:{},debugConfig:D.DEFAULT_DEBUG_CONFIG,onColumnPanelsChange:w}),{columnPanels:P,setColumnPanels:T}=h,A=u.useRef(S),d=u.useRef(P);u.useLayoutEffect(()=>{A.current=S,d.current=P},[S,P]);const v=u.useCallback(E=>{const b=n.current;if(b===null)return;const{plan:B,stageBlockSize:z}=vn(b,m);if(Number.isFinite(z)&&z>0&&b.style.setProperty(ue,`${String(z)}px`),A.current&&!E)return;const H=j.replanVisibleColumns(e.getSnapshot().visibleColumns,B);H!==null&&e.setVisibleColumns(H)},[e,n,m]);u.useLayoutEffect(()=>{v(!0),k(!0)},[v]),u.useEffect(()=>{const E=n.current;if(E===null||typeof ResizeObserver>"u")return;let b=null;const B=new ResizeObserver(()=>{b===null&&(b=requestAnimationFrame(()=>{b=null,v(!1)}))}),z=E.querySelector(D.SCROLL_ROOT_SELECTOR)?.firstElementChild,H=E.querySelector(`[${ce}]`);return z instanceof Element&&B.observe(z),H instanceof Element&&B.observe(H),()=>{B.disconnect(),b!==null&&cancelAnimationFrame(b)}},[n,v]),u.useEffect(()=>{S||v(!1)},[S,v]);const O=u.useMemo(()=>C?Nn(f,{logical:m,visible:l}):we(l),[C,f,m,l]);u.useLayoutEffect(()=>{$n(d.current,O)||T(O)},[O,T]);const x=u.useMemo(()=>D.sortColumnIds(Object.keys(P)).map(E=>({id:E,key:E,className:"aqmx-multi-column"})),[P]),R=u.useMemo(()=>f.docs.map(E=>{const b=K(f,E);return{id:b,component:Rn,title:ae(y,E),props:{docPath:E,panelId:b},minHeight:Vn,maxHeight:Un}}),[f,y]),N=u.useMemo(()=>Object.fromEntries(f.docs.map(E=>[K(f,E),!f.hidden.has(E)])),[f]),i=f.maximized===null?null:K(f,f.maximized),p=u.useCallback(E=>{const{layout:b}=e.getSnapshot();for(const[B,z]of W(b)){const H=E[B];if(H===void 0||H!==b.hidden.has(z))continue;const V=e.titleOf(z);if(H){if(!e.setHidden(z,!1))continue;r.announce(o.panelShown(V)),He(n,B);continue}const U=n.current,me=U===null?null:Oe(U,B);e.setHidden(z,!0)&&(r.announce(o.panelHidden(V)),me!==null&&be(n,me))}},[e,n,r,o]),M=u.useCallback(E=>{const b=W(e.getSnapshot().layout).get(E);if(b===void 0)return;const B=()=>{const H=e.titleOf(b),V=n.current,U=V===null?null:Oe(V,E);e.close(b)&&(r.announce(o.panelClosed(H)),U!==null&&be(n,U))},z=s.unsavedAmong([b]);z.length===0?B():s.askToDiscard(z).then(H=>{H&&B()})},[e,n,r,o,s]),I=u.useCallback(E=>{if(E===null){a(null);return}const b=W(e.getSnapshot().layout).get(E);b!==void 0&&a(b)},[e,a]);return L.jsx("div",{className:"aqmx-multi-layout","aria-busy":!C,children:L.jsx(D.DragDropLayout,{columns:x,panels:R,columnPanels:P,onColumnPanelsChange:w,panelVisibility:N,onPanelVisibilityChange:p,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:M,onPanelMaximizeChange:I,maximizedPanel:i,dragHandle:"header",labels:g,panelClassName:"aqmx-multi-panel",renderPanelScrollArea:Bn,renderStageScrollBar:jn})})},oe={blockStart:"--aqmx-multi-toast-block-start",inlineEnd:"--aqmx-multi-toast-inline-end",room:"--aqmx-multi-toast-room"},Kn=(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),f=m.findIndex(y=>n.contains(y)),l=m.findIndex(y=>e.contains(y));return f!==-1&&l!==-1&&l<f}))},Jn=(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()}},Xn=({store:e,body:n,limitNotice:t,onLimitNoticeCovered:o,ref:r})=>{const{config:s,labels:a,announcer:m,edits:f}=q.useExplorer(),l=u.useRef(null),y=u.useRef(null),S=_(e,d=>d.ready),C=_(e,d=>d.layout.docs.length>0),k=_(e,d=>d.visibleColumns),c=u.use(re.SheetNoticeSlotContext),g=u.useCallback(d=>{const{layout:v}=e.getSnapshot(),O=v.maximized,x=d===null&&O!==null?v.panelIds.get(O):void 0,R=l.current,N=x!==void 0&&R!==null&&de(R,x);e.maximize(d)&&(d!==null?m.announce(a.panelMaximized(e.titleOf(d))):O!==null&&m.announce(a.panelRestored(e.titleOf(O))),x!==void 0&&Yn(l,x,N))},[e,m,a]),w=u.useCallback((d,v,O,x)=>{if(O===v){e.setPendingHash(d,x);return}const R=f.unsavedAmong([v]);if(R.length>0){f.askToDiscard(R).then(M=>{M&&w(d,v,O,x)});return}const N=e.navigate(v,O);if(N==="navigated"){e.setPendingHash(d,x);return}if(N!=="existing")return;const{layout:i}=e.getSnapshot(),p=i.panelIds.get(O);p!==void 0&&(m.announce(a.panelAlreadyOpen(e.titleOf(O))),i.maximized===null?e.setHidden(O,!1):g(O),e.setPendingHash(p,x),He(l,p))},[e,m,a,g,f]);u.useLayoutEffect(()=>{if(t===null||c!==null||!he())return;const d=y.current,v=l.current;if(d===null||v===null)throw new Error("[markdown-explorer] the panel-limit notice and the stage must be mounted together");return Jn(d,v)},[t,c]),u.useEffect(()=>{const d=y.current;if(t===null||d===null)return;const{ownerDocument:v}=d;let O=null;const x=R=>{const N=R.target;N instanceof Element&&(O!==null&&cancelAnimationFrame(O),O=requestAnimationFrame(()=>{O=null,v.activeElement===N&&d.isConnected&&Kn(d,N)&&o()}))};return v.addEventListener("focusin",x,!0),()=>{v.removeEventListener("focusin",x,!0),O!==null&&cancelAnimationFrame(O)}},[t,c,o]),u.useImperativeHandle(r,()=>({bringIntoView:d=>{requestAnimationFrame(()=>{const v=l.current,O=e.getSnapshot().layout.panelIds.get(d);v!==null&&O!==void 0&&Z(v,O,null)})}}),[e]),u.useEffect(()=>{const d=l.current;return()=>{d!==null&&Y.get(d)?.()}},[]);const h=u.useCallback((d,v)=>{const O=l.current;O!==null&&Z(O,d,v)},[]),[P]=u.useState(Ue),T=u.useMemo(()=>({store:e,Body:n,followLink:w,maximize:g,revealInPanel:h,focusCarry:P}),[e,n,w,g,h,P]),A=u.useMemo(()=>Array.from({length:s.multiView.columns},(d,v)=>D.generateColumnId(v)),[s]);return L.jsxs("section",{ref:l,className:"aqmx-multi-stage",style:_n,tabIndex:-1,"aria-label":a.multiRegion,"aria-busy":C&&!S,"data-testid":"markdown-explorer-stage","data-aqmx-visible-columns":k,children:[L.jsx("span",{className:"aqmx-multi-probe","aria-hidden":"true",[ce]:""}),C?S?L.jsx(Pe,{value:T,children:L.jsx(Wn,{store:e,stageRef:l})}):L.jsx("div",{className:"aqmx-multi-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-stage-skeleton",children:A.map(d=>L.jsxs("div",{className:"aqmx-skeleton aqmx-multi-skeleton-column",children:[L.jsx("span",{}),L.jsx("span",{}),L.jsx("span",{})]},d))}):L.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-multi-empty",children:L.jsx("p",{className:"aqmx-empty-title",children:a.multiEmpty})}),t===null?null:c!==null?je.createPortal(L.jsx("div",{ref:y,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t}),c):L.jsx("div",{ref:y,popover:he()?"manual":void 0,className:"aqmx-toast aqmx-multi-toast","data-testid":"markdown-explorer-panel-limit",children:t})]})},qe=3e3,Be=(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},Zn=(e,n,t)=>{switch(n){case"opened":return e.panelOpened(t);case"shown":return e.panelShown(t);case"closed":return e.panelClosed(t);default:{const o=n;throw new RangeError(`[markdown-explorer] unknown toggle outcome ${JSON.stringify(o)}`)}}},Qn=({location:e})=>{const{config:n,labels:t,announcer:o}=q.useExplorer(),r=fn(e),s=_(r,x=>x.layout.docs),a=_(r,x=>x.layout.maximized),m=_(r,x=>x.layout.markup),f=_(r,x=>x.source),[l,y]=u.useState(()=>({docs:s,latest:le([],s,null)}));l.docs!==s&&y({docs:s,latest:le(l.docs,s,l.latest)});const S=a!==null?a:l.latest,[C,k]=u.useState(!1),c=u.useRef(null),[g,w]=u.useState(0),h=u.useRef(null),P=u.useRef(null);u.useLayoutEffect(()=>{const x=h.current;h.current=null,x!==null&&(r.whenUrlRendered(()=>o.announce(x.announcement)),P.current?.bringIntoView(x.doc))}),u.useEffect(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);const T=u.useCallback(()=>{c.current!==null&&clearTimeout(c.current),k(!0),c.current=setTimeout(()=>{c.current=null,k(!1)},qe)},[]),A=u.useCallback(()=>{c.current!==null&&clearTimeout(c.current),c.current=null,k(!1)},[]),d=u.useCallback(x=>{const R=r.titleOf(x),N=r.toggle(x);N==="rejected"&&T();const i=N==="rejected"?t.panelLimit(n.multiView.maxPanels):Zn(t,N,R);if(N==="shown"){h.current={doc:x,announcement:i},w(p=>p+1);return}r.whenUrlRendered(()=>{o.announce(i),N==="opened"&&P.current?.bringIntoView(x)})},[r,T,o,t,n]),v=u.useMemo(()=>new Set(s),[s]),O=u.useMemo(()=>{const x=Be(s,a);return{href:j.explorerHref(n,{view:"tree",source:f,doc:x,markup:x!==null&&m.has(x)}),target:"tree"}},[n,f,s,a,m]);return L.jsx(re.ExplorerSplit,{view:"multi",explorer:L.jsx(re.ExplorerPane,{mode:"multi",sourceId:f,currentPath:S,openPaths:v,onOpenDocument:d,onSourceChange:r.changeSource,onRevealSource:r.revealSource,viewSwitch:O}),content:L.jsx(Xn,{ref:P,store:r,body:gn,limitNotice:C?t.panelLimit(n.multiView.maxPanels):null,onLimitNoticeCovered:A}),contentCoversPage:a!==null,sheetDismissals:g,onDraggingChange:r.setSplitDragging})};exports.MultiLayout=Qn;exports.PANEL_LIMIT_NOTICE_MS=qe;exports.latestOpenedDocument=le;exports.treeSwitchDocument=Be;
@@ -1,7 +1,7 @@
1
1
  import { jsx as a } from "react/jsx-runtime";
2
2
  import { ScrollBar as u } from "@aiquants/virtualscroll";
3
3
  import { useCallback as p, useMemo as b, useSyncExternalStore as S } from "react";
4
- import { u as h } from "./index-etFEpIE_.js";
4
+ import { u as h } from "./index-CPoNWk1T.js";
5
5
  import { N as m } from "./scrollBarGeometry-DOBdGNV-.js";
6
6
  import { T, N as d } from "./tapScrollCircle-u4EXeLhx.js";
7
7
  const l = (e) => ({ scrollTop: e.scrollTop, scrollHeight: e.scrollHeight, clientHeight: e.clientHeight }), f = (e, t) => e.scrollTop === t.scrollTop && e.scrollHeight === t.scrollHeight && e.clientHeight === t.clientHeight, v = (e) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),i=require("react"),d=require("./index-Dlkzr6Zn.cjs"),h=require("./scrollBarGeometry-C46jBtmM.cjs"),u=require("./tapScrollCircle-C5DGI-0H.cjs"),a=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),v=(e,t)=>e.scrollTop===t.scrollTop&&e.scrollHeight===t.scrollHeight&&e.clientHeight===t.clientHeight,g=e=>{let t=a(e);return{getSnapshot:()=>t,subscribe:s=>{const o=()=>{const n=a(e);v(t,n)||(t=n,s())},r=typeof ResizeObserver>"u"?null:new ResizeObserver(o),c=()=>{if(r!==null){r.disconnect(),r.observe(e);for(const n of e.children)r.observe(n)}};c();const l=typeof MutationObserver>"u"?null:new MutationObserver(()=>{c(),o()});return l?.observe(e,{childList:!0}),e.addEventListener("scroll",o,{passive:!0}),o(),()=>{e.removeEventListener("scroll",o),l?.disconnect(),r?.disconnect()}}}},S=e=>{const t=i.useMemo(()=>g(e),[e]);return i.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)},p=(e,t)=>{const s=typeof t=="function"?t(e.scrollTop):t;return e.scrollTo({top:s,behavior:"instant"}),e.scrollTop},C=({scroller:e,withCircle:t})=>{const{locale:s}=d.useExplorer(),{scrollTop:o,scrollHeight:r,clientHeight:c}=S(e),l=i.useCallback(n=>p(e,n),[e]);return b.jsx(T.ScrollBar,{contentSize:r,viewportSize:c,scrollPosition:o,onScroll:l,scrollBarWidth:h.NATIVE_SCROLL_BAR_WIDTH,enableThumbDrag:!0,enableTrackClick:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,tapScrollCircleOptions:t?u.TAP_SCROLL_CIRCLE:u.NO_TAP_SCROLL_CIRCLE,locale:s})};exports.NativeScrollBar=C;exports.scrollScrollerTo=p;exports.useScrollerMetrics=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),T=require("@aiquants/virtualscroll"),i=require("react"),d=require("./index-BBtIYTXJ.cjs"),h=require("./scrollBarGeometry-C46jBtmM.cjs"),u=require("./tapScrollCircle-C5DGI-0H.cjs"),a=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),v=(e,t)=>e.scrollTop===t.scrollTop&&e.scrollHeight===t.scrollHeight&&e.clientHeight===t.clientHeight,g=e=>{let t=a(e);return{getSnapshot:()=>t,subscribe:s=>{const o=()=>{const n=a(e);v(t,n)||(t=n,s())},r=typeof ResizeObserver>"u"?null:new ResizeObserver(o),c=()=>{if(r!==null){r.disconnect(),r.observe(e);for(const n of e.children)r.observe(n)}};c();const l=typeof MutationObserver>"u"?null:new MutationObserver(()=>{c(),o()});return l?.observe(e,{childList:!0}),e.addEventListener("scroll",o,{passive:!0}),o(),()=>{e.removeEventListener("scroll",o),l?.disconnect(),r?.disconnect()}}}},S=e=>{const t=i.useMemo(()=>g(e),[e]);return i.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getSnapshot)},p=(e,t)=>{const s=typeof t=="function"?t(e.scrollTop):t;return e.scrollTo({top:s,behavior:"instant"}),e.scrollTop},C=({scroller:e,withCircle:t})=>{const{locale:s}=d.useExplorer(),{scrollTop:o,scrollHeight:r,clientHeight:c}=S(e),l=i.useCallback(n=>p(e,n),[e]);return b.jsx(T.ScrollBar,{contentSize:r,viewportSize:c,scrollPosition:o,onScroll:l,scrollBarWidth:h.NATIVE_SCROLL_BAR_WIDTH,enableThumbDrag:!0,enableTrackClick:!0,enableArrowButtons:!0,enableArrowButtonTabStops:!1,tapScrollCircleOptions:t?u.TAP_SCROLL_CIRCLE:u.NO_TAP_SCROLL_CIRCLE,locale:s})};exports.NativeScrollBar=C;exports.scrollScrollerTo=p;exports.useScrollerMetrics=S;
@@ -2,8 +2,8 @@ import { jsx as u, jsxs as D } from "react/jsx-runtime";
2
2
  import { useState as T, useMemo as m, useCallback as i } from "react";
3
3
  import { useLocation as b } from "react-router";
4
4
  import { e as c, c as C } from "./location-Q4sgRrUm.js";
5
- import { u as M, a as N, b as O, D as R, P as _, c as G } from "./index-etFEpIE_.js";
6
- import { E as H, a as L, b as j } from "./ExplorerSplit-C9Y02nvj.js";
5
+ import { u as M, a as N, b as O, D as R, P as _, c as G } from "./index-CPoNWk1T.js";
6
+ import { E as H, a as L, b as j } from "./ExplorerSplit-BwUurHbM.js";
7
7
  const q = /* @__PURE__ */ new Set(), U = ({ location: l }) => {
8
8
  const { config: o } = M(), r = N(), { hash: p } = b(), { source: n, doc: e, overrides: s, markup: t } = l, [h, v] = T(H), w = m(() => ({ gathered: h, onGatheredChange: v }), [h]), g = i((a) => r(c(o, { view: "tree", source: n, doc: a, overrides: s }), "browse"), [r, o, n, s]), S = i((a) => r(c(o, { view: "tree", source: a, doc: e, overrides: s, markup: t }), "switch-source"), [r, o, e, s, t]), E = i((a) => r(`${c(o, { view: "tree", source: a, doc: e, overrides: s, markup: t })}${p}`, "browse"), [r, o, e, s, t, p]), x = i(
9
9
  (a) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),s=require("react"),T=require("react-router"),a=require("./location-DmzVAFvo.cjs"),l=require("./index-Dlkzr6Zn.cjs"),p=require("./ExplorerSplit-D60N3_X7.cjs"),q=new Set,C=({location:m})=>{const{config:r}=l.useExplorer(),t=l.useExplorerNavigate(),{hash:d}=T.useLocation(),{source:n,doc:e,overrides:c,markup:o}=m,[x,v]=s.useState(p.EMPTY_SELECTION),g=s.useMemo(()=>({gathered:x,onGatheredChange:v}),[x]),w=s.useCallback(u=>t(a.explorerHref(r,{view:"tree",source:n,doc:u,overrides:c}),"browse"),[t,r,n,c]),S=s.useCallback(u=>t(a.explorerHref(r,{view:"tree",source:u,doc:e,overrides:c,markup:o}),"switch-source"),[t,r,e,c,o]),E=s.useCallback(u=>t(`${a.explorerHref(r,{view:"tree",source:u,doc:e,overrides:c,markup:o})}${d}`,"browse"),[t,r,e,c,o,d]),k=s.useCallback(u=>{const h=a.canonicalMultiDocuments(r,u);t(a.explorerHref(r,{view:"multi",source:n,docs:h,markup:o&&e!==null&&h.includes(e)?[e]:[]}),"switch-view")},[t,r,n,e,o]),b=s.useMemo(()=>({href:a.explorerHref(r,e===null?{view:"multi",source:n}:{view:"multi",source:n,docs:[e],markup:o?[e]:[]}),target:"multi"}),[r,n,e,o]),f=s.useMemo(()=>({kind:"page",view:"tree",overrides:c,embed:{}}),[c]),P=l.usePageMarkupToggle(m);return i.jsx(p.ExplorerSplit,{view:"tree",explorer:i.jsx(p.ExplorerPane,{mode:"tree",sourceId:n,currentPath:e,openPaths:q,onOpenDocument:w,onSourceChange:S,onRevealSource:E,viewSwitch:b,tray:g,onOpenSelection:k}),content:i.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",children:[e===null?null:i.jsx(l.DocumentRefreshBar,{path:e,placement:l.PAGE_DOCUMENT_REFRESH,markup:P}),i.jsx(l.DocumentPane,{path:e,markup:o,variant:f})]})})};exports.TreeLayout=C;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),s=require("react"),T=require("react-router"),a=require("./location-DmzVAFvo.cjs"),l=require("./index-BBtIYTXJ.cjs"),p=require("./ExplorerSplit-Brdh9fCW.cjs"),q=new Set,C=({location:m})=>{const{config:r}=l.useExplorer(),t=l.useExplorerNavigate(),{hash:d}=T.useLocation(),{source:n,doc:e,overrides:c,markup:o}=m,[x,v]=s.useState(p.EMPTY_SELECTION),g=s.useMemo(()=>({gathered:x,onGatheredChange:v}),[x]),w=s.useCallback(u=>t(a.explorerHref(r,{view:"tree",source:n,doc:u,overrides:c}),"browse"),[t,r,n,c]),S=s.useCallback(u=>t(a.explorerHref(r,{view:"tree",source:u,doc:e,overrides:c,markup:o}),"switch-source"),[t,r,e,c,o]),E=s.useCallback(u=>t(`${a.explorerHref(r,{view:"tree",source:u,doc:e,overrides:c,markup:o})}${d}`,"browse"),[t,r,e,c,o,d]),k=s.useCallback(u=>{const h=a.canonicalMultiDocuments(r,u);t(a.explorerHref(r,{view:"multi",source:n,docs:h,markup:o&&e!==null&&h.includes(e)?[e]:[]}),"switch-view")},[t,r,n,e,o]),b=s.useMemo(()=>({href:a.explorerHref(r,e===null?{view:"multi",source:n}:{view:"multi",source:n,docs:[e],markup:o?[e]:[]}),target:"multi"}),[r,n,e,o]),f=s.useMemo(()=>({kind:"page",view:"tree",overrides:c,embed:{}}),[c]),P=l.usePageMarkupToggle(m);return i.jsx(p.ExplorerSplit,{view:"tree",explorer:i.jsx(p.ExplorerPane,{mode:"tree",sourceId:n,currentPath:e,openPaths:q,onOpenDocument:w,onSourceChange:S,onRevealSource:E,viewSwitch:b,tray:g,onOpenSelection:k}),content:i.jsxs("div",{className:"aqmx-document-column aqmx-tree-document",children:[e===null?null:i.jsx(l.DocumentRefreshBar,{path:e,placement:l.PAGE_DOCUMENT_REFRESH,markup:P}),i.jsx(l.DocumentPane,{path:e,markup:o,variant:f})]})})};exports.TreeLayout=C;
@@ -160,6 +160,9 @@ export type MarkdownExplorerLabels = {
160
160
  readonly imageZoomLevel: (percent: number) => string;
161
161
  readonly openInNewTab: string;
162
162
  readonly download: string;
163
+ readonly copyText: string;
164
+ readonly copiedText: string;
165
+ readonly copyTextFailed: string;
163
166
  readonly mediaUnsupported: string;
164
167
  readonly fileNotShown: string;
165
168
  readonly viewerLoading: string;
@@ -160,6 +160,9 @@ export type MarkdownExplorerLabels = {
160
160
  readonly imageZoomLevel: (percent: number) => string;
161
161
  readonly openInNewTab: string;
162
162
  readonly download: string;
163
+ readonly copyText: string;
164
+ readonly copiedText: string;
165
+ readonly copyTextFailed: string;
163
166
  readonly mediaUnsupported: string;
164
167
  readonly fileNotShown: string;
165
168
  readonly viewerLoading: string;
@@ -0,0 +1,13 @@
1
+ "use strict";const l=require("react/jsx-runtime"),i=require("react"),Y=require("react-router"),I=require("./location-DmzVAFvo.cjs"),N=require("./dataRoute-CcZ8PK00.cjs"),de=require("@aiquants/markdown"),$e=require("@aiquants/markdown/source-lines"),yn=require("@aiquants/markdown/viewer-settings"),J=require("./storage-Dgi4JXaB.cjs");function Sn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const E=Sn(i),qe=Object.freeze(["en","ja"]),Ct="en",Ot=Object.freeze({panelMoved:Object.freeze(["title","column","position"]),panelMoveUnavailable:Object.freeze(["title","move"]),panelDragStarted:Object.freeze(["title"]),panelDragCancelled:Object.freeze(["title"]),multiColumnRegion:Object.freeze(["column"])}),kn=/\{(\w+)\}/gu,At={explorerRegion:"Explorer",sourceLabel:"Source",refreshTreeLabel:"Refresh tree",refreshTree:"Reload the tree and the open documents from the source",treeRefreshed:"Reloaded the tree from the source",treeRefreshFailed:e=>`Could not reload the tree: ${e}`,refreshDocumentLabel:"Refresh document",refreshDocument:"Reload the document from the source",refreshDocumentNamed:e=>`Refresh ${e}`,documentRefreshed:e=>`Reloaded ${e}`,documentRefreshFailed:e=>`Could not reload the document: ${e}`,showMarkupLabel:"Source",showMarkup:"Show the document's Markdown as written",showMarkupNamed:e=>`Source of ${e}`,editDocumentLabel:"Edit",editDocument:"Edit the document's Markdown (or double-click the document)",editDocumentNamed:e=>`Edit ${e}`,editExternallyLabel:"Open in its editor",editExternally:"Open the document in its own editor, in a new tab",editExternallyNamed:e=>`Open ${e} in its editor`,editorRegion:e=>`Editing ${e}`,editorLabel:e=>`Markdown of ${e}`,editLoading:"Loading the source for editing…",editToolbar:"Editor",saveDraft:"Save",saveDraftTooltip:"Save the draft (Ctrl+S, or ⌘S on a Mac)",closeEditor:"Close editor",previewToggle:"Preview",historyOpen:"History",draftUnsaved:"Unsaved changes",draftSaving:"Saving…",draftSaved:"Saved",draftSavedMerged:"Saved, merged with changes saved elsewhere",draftConflicts:e=>e===1?"1 conflict with changes saved elsewhere: choose what to keep, then save":`${e} conflicts with changes saved elsewhere: choose what to keep, then save`,draftSaveFailed:e=>`Could not save: ${e}`,documentSaved:e=>`Saved ${e}`,documentSavedMerged:e=>`Saved ${e}, merged with changes saved elsewhere`,conflictOurs:"your draft",conflictTheirs:"saved elsewhere",conflictUseOurs:"Use my lines",conflictUseTheirs:"Use the saved lines",conflictKeepBoth:"Keep both",conflictNext:"Next conflict",editGrantTitle:"Editing needs your permission",editGrantBody:"Allow this site to change documents on your behalf. You are asked once; signing out asks again.",editGrantAction:"Grant permission",editGrantRetry:"Try again",unsavedTitle:"Discard unsaved changes?",unsavedBody:e=>`${e} has changes that are not saved.`,unsavedDiscard:"Discard changes",unsavedStay:"Keep editing",historyTitle:e=>`Revisions of ${e}`,historyLoading:"Loading the revisions…",historyEmpty:"No revisions are kept for this document.",historyCurrent:"Current",historyKept:"Kept",historyEntry:(e,t)=>t===""?e:`${e} by ${t}`,historyRestore:"Put into the draft",historyClose:"Close",historyRestored:e=>`Put the revision into the draft of ${e}; save to keep it`,previewRegion:"Preview",previewUpdating:"Updating the preview…",previewFailed:e=>`Could not preview: ${e}`,expandAll:"Expand all folders",collapseAll:"Collapse all folders",treeSettings:"Tree settings",switchToMulti:"Open in the multi-panel view",switchToTree:"Open in the tree view",resizeExplorer:"Resize the explorer",showExplorer:"Show the explorer",hideExplorer:"Close the explorer",treeRegion:"Documents",treeLoading:"Loading the tree…",treeEmptyTitle:"Nothing to show",treeEmptyBody:"This source has no documents you can open.",folderLoadFailed:"This folder could not be loaded.",loopFolderName:e=>`${e} (already open above)`,foldersLoadFailedNamed:e=>`${new Intl.ListFormat("en",{type:"conjunction"}).format(e)} could not be loaded`,foldersLoading:e=>e===1?"Loading 1 folder…":`Loading ${String(e)} folders…`,expandAllStarted:"Opening all folders…",expandAllProgress:(e,t)=>`Opening all folders (${String(e)} opened, ${String(t)} loading)…`,expandAllDone:(e,t,n)=>{const r=`Opened ${String(e)} ${e===1?"folder":"folders"}`;return t>0?`${r}; ${String(t)} could not be loaded`:n?e===0?"All folders are already open":`${r}; every folder is open`:r},expandAllFolderLimit:(e,t,n)=>`Opened ${String(e)} ${e===1?"folder":"folders"} and stopped at the limit of ${String(t)} ${t===1?"folder":"folders"} to load. Choose "${n}" again to continue`,expandAllDepthLimit:(e,t)=>`Opened ${String(e)} ${e===1?"folder":"folders"}; folders more than ${String(t)} ${t===1?"level":"levels"} deep stay closed`,treeEntryKindDirectory:"directory",treeEntryKindFile:"file",treeScrollUp:"Scroll up",treeScrollDown:"Scroll down",treeScrollToTop:"Top",treeScrollToBottom:"Bottom",selectionTitle:e=>`Selected (${String(e)})`,clearSelection:"Clear the selection",openSelectionInMulti:e=>`Open ${String(e)} in panels`,removeFromSelection:e=>`Remove ${e} from the selection`,settingSortMode:"Sort order",sortNative:"Source order",sortAscending:"Name A→Z",sortDescending:"Name Z→A",settingFolderPlacement:"Folders",folderPlacementMixed:"Mixed",folderPlacementFirst:"First",folderPlacementLast:"Last",settingSelectionMode:"Selection",selectionSingle:"Single",selectionMultiple:"Multiple",selectionNone:"Off",settingDoubleClick:"Double-click",doubleClickRecursive:"Expand all levels",doubleClickToggle:"Toggle",settingExpandIconSize:"Expander size",expandIconSizeValue:e=>`${String(e)} px`,settingAlwaysExpanded:"Always expanded",settingRevealDocument:"Reveal the open document",settingRemoveRootIndent:"No root indent",settingTreeLines:"Tree lines",settingExpandIcons:"Expanders",settingDirectoryIcons:"Folder icons",settingFileIcons:"File icons",settingOn:"On",settingOff:"Off",settingAnnouncement:(e,t)=>`${e}: ${t}`,documentRegion:"Document",documentEmpty:"Select a document in the explorer.",documentLoading:"Loading the document…",markupLoading:"Loading the source…",documentShown:e=>`Showing ${e}`,documentFailed:(e,t)=>`${e}: ${t}`,announcementSequence:e=>e.map(t=>/[.!?]$/u.test(t)?t:`${t}.`).join(" "),textTruncated:"Only the beginning of this file is shown.",inertLink:"This link points outside the source and cannot be opened.",failureUnauthorizedTitle:"Your session has expired",failureUnauthorizedBody:"Reload the page to sign in again.",failureForbiddenTitle:"Access denied",failureForbiddenBody:"You do not have permission to open this.",failureNotFoundTitle:"Not found",failureNotFoundBody:"It may have been moved or deleted.",failureNotConfiguredTitle:"This source is not set up",failureNotConfiguredBody:"Ask your administrator to configure it.",failureInvalidTitle:"Invalid address",failureInvalidBody:"The document path in this address cannot be used.",failureTooLargeTitle:"Too large to display",failureTooLargeBody:"This file exceeds the size that can be displayed.",failureUnsupportedTitle:"Cannot be displayed",failureUnsupportedBody:"This type of file cannot be shown here.",failureFailedTitle:"Something went wrong",failureFailedBody:"Try again in a moment.",retry:"Try again",reloadPage:"Reload the page",imageZoomIn:"Zoom in",imageZoomOut:"Zoom out",imageFit:"Fit to the view",imageFitLevel:"Fit",imageZoomLevel:e=>`${String(e)}%`,openInNewTab:"Open in a new tab",download:"Download",copyText:"Copy the text",copiedText:"Copied the text",copyTextFailed:"Could not copy the text",mediaUnsupported:"Your browser cannot play this file.",fileNotShown:"This file cannot be shown here. Download it to open it.",viewerLoading:"Loading data...",viewerErrorPrefix:"Error: ",viewerStyleTitle:"Display Style",viewerSelectStyle:"Select display style",viewerPinStyle:"Pin style selector",viewerUnpinStyle:"Unpin style selector",viewerErrorTitle:"An error occurred",viewerMissingImage:"Image not found",viewerOpenToc:"Open table of contents",viewerTocTitle:"Table of contents",viewerPinToc:"Pin table of contents",viewerUnpinToc:"Unpin table of contents",viewerSelectAlign:"Select alignment",viewerAlignTitle:"Alignment",viewerPinAlign:"Pin alignment selector",viewerUnpinAlign:"Unpin alignment selector",viewerAlignLeft:"Align left",viewerAlignCenter:"Align center",viewerAlignRight:"Align right",viewerMermaidInteractionMode:"Mouse interaction mode",viewerMermaidModeNone:"No interaction",viewerMermaidModeZoom:"Zoom only",viewerMermaidModePan:"Pan only (drag)",viewerMermaidModePanShift:"Pan only (Shift+drag)",viewerMermaidModeBoth:"Zoom and pan (drag)",viewerMermaidModeBothShift:"Zoom and pan (Shift+drag)",viewerMermaidZoomIn:"Zoom In",viewerMermaidZoomOut:"Zoom Out",viewerMermaidResetView:"Reset View",viewerMermaidRetry:"Try again",viewerEmbeddedVideo:"embedded video",viewerEmbeddedPost:"embedded post",viewerEmbeddedFrame:"Embedded content",multiRegion:"Panels",multiEmpty:"Select documents in the explorer to open them side by side.",panelLimit:e=>`You can open up to ${String(e)} panels at once.`,panelOpened:e=>`Opened ${e}`,panelClosed:e=>`Closed ${e}`,panelAlreadyOpen:e=>`${e} is already open`,panelHidden:e=>`Hid ${e}`,panelShown:e=>`Showed ${e}`,panelMaximized:e=>`Maximized ${e}`,panelRestored:e=>`Restored ${e} to its size`,panelHide:"Hide the panel",panelMaximize:"Maximize the panel",panelRestore:"Restore the panel to its size",panelClose:"Close the panel",panelSwitchToCustomDrag:"Switch to the custom drag mode",panelSwitchToNormalDrag:"Back to the normal drag mode",panelCustomDragBadge:"Custom",panelMovePreviousColumn:"Move to the previous column",panelMoveNextColumn:"Move to the next column",panelMoveUp:"Move up",panelMoveDown:"Move down",panelMoved:"Moved {title} to column {column}, position {position}",panelMoveUnavailable:"{move} is not available for {title}",panelDragStarted:"Picked up {title}",panelDragCancelled:"Kept {title} where it was",hiddenPanelsTitle:"Hidden panels:",hiddenPanelBadge:"Hidden",hiddenPanelNotice:"This panel is hidden",multiColumnEmpty:"This column is empty",multiColumnRegion:"Column {column}",panelDropHere:"Drop the panel here"},Rn={explorerRegion:"エクスプローラー",sourceLabel:"ソース",refreshTreeLabel:"ツリーを更新",refreshTree:"ソースからツリーと開いている文書を読み込み直す",treeRefreshed:"ツリーをソースから読み込み直しました",treeRefreshFailed:e=>`ツリーを読み込み直せませんでした: ${e}`,refreshDocumentLabel:"文書を更新",refreshDocument:"ソースから文書を読み込み直す",refreshDocumentNamed:e=>`${e} を更新`,documentRefreshed:e=>`${e} を読み込み直しました`,documentRefreshFailed:e=>`文書を読み込み直せませんでした: ${e}`,showMarkupLabel:"ソース",showMarkup:"文書の Markdown を書いたまま表示",showMarkupNamed:e=>`${e} のソース`,editDocumentLabel:"編集",editDocument:"文書の Markdown を編集 (文書のダブルクリックでも)",editDocumentNamed:e=>`${e} を編集`,editExternallyLabel:"元のエディタで開く",editExternally:"文書を元のエディタで、新しいタブに開く",editExternallyNamed:e=>`${e} を元のエディタで開く`,editorRegion:e=>`${e} を編集中`,editorLabel:e=>`${e} の Markdown`,editLoading:"編集のためにソースを読み込み中…",editToolbar:"エディタ",saveDraft:"保存",saveDraftTooltip:"下書きを保存 (Ctrl+S、Mac は ⌘S)",closeEditor:"編集を閉じる",previewToggle:"プレビュー",historyOpen:"履歴",draftUnsaved:"保存していない変更があります",draftSaving:"保存中…",draftSaved:"保存しました",draftSavedMerged:"ほかで保存された変更と統合して保存しました",draftConflicts:e=>`ほかで保存された変更と ${e} か所が重なりました。残す方を選んでから保存してください`,draftSaveFailed:e=>`保存できませんでした: ${e}`,documentSaved:e=>`${e} を保存しました`,documentSavedMerged:e=>`${e} を、ほかで保存された変更と統合して保存しました`,conflictOurs:"あなたの下書き",conflictTheirs:"ほかで保存された版",conflictUseOurs:"自分の行を使う",conflictUseTheirs:"保存された行を使う",conflictKeepBoth:"両方を残す",conflictNext:"次の衝突へ",editGrantTitle:"編集には許可が必要です",editGrantBody:"このサイトがあなたに代わって文書を変えることを許可してください。尋ねるのは 1 回だけで、サインアウトすると次にまた尋ねます。",editGrantAction:"許可する",editGrantRetry:"もう一度試す",unsavedTitle:"保存していない変更を破棄しますか?",unsavedBody:e=>`${e} に保存していない変更があります。`,unsavedDiscard:"変更を破棄",unsavedStay:"編集を続ける",historyTitle:e=>`${e} の版`,historyLoading:"版の一覧を読み込み中…",historyEmpty:"この文書の版は残っていません。",historyCurrent:"現在の版",historyKept:"保持",historyEntry:(e,t)=>t===""?e:`${e} (${t})`,historyRestore:"下書きに戻す",historyClose:"閉じる",historyRestored:e=>`${e} の下書きに版を戻しました。残すには保存してください`,previewRegion:"プレビュー",previewUpdating:"プレビューを更新中…",previewFailed:e=>`プレビューできませんでした: ${e}`,expandAll:"すべてのフォルダーを展開",collapseAll:"すべてのフォルダーを折りたたむ",treeSettings:"ツリーの設定",switchToMulti:"マルチビューで開く",switchToTree:"ツリービューで開く",resizeExplorer:"エクスプローラーの幅を変更",showExplorer:"エクスプローラーを開く",hideExplorer:"エクスプローラーを閉じる",treeRegion:"文書の一覧",treeLoading:"ツリーを読み込み中…",treeEmptyTitle:"表示できるファイルがありません",treeEmptyBody:"このソースには開ける文書がありません。",folderLoadFailed:"このフォルダーを読み込めませんでした。",loopFolderName:e=>`${e} (上の階層で開いています)`,foldersLoadFailedNamed:e=>`${new Intl.ListFormat("ja",{type:"conjunction"}).format(e)} を読み込めませんでした`,foldersLoading:e=>`フォルダーを ${String(e)} 件読み込み中…`,expandAllStarted:"すべてのフォルダーを展開しています…",expandAllProgress:(e,t)=>`すべてのフォルダーを展開中 (展開 ${String(e)} 件、読み込み中 ${String(t)} 件)…`,expandAllDone:(e,t,n)=>{const r=`${String(e)} 件のフォルダーを展開しました`;return t>0?`${r}。うち ${String(t)} 件は読み込めませんでした`:n?e===0?"すべてのフォルダーが既に開いています":`${r}。すべてのフォルダーが開いています`:r},expandAllFolderLimit:(e,t,n)=>`${String(e)} 件のフォルダーを展開し、読み込みの上限 (${String(t)} 件) で止めました。続けるには「${n}」をもう一度押してください`,expandAllDepthLimit:(e,t)=>`${String(e)} 件のフォルダーを展開しました。深さ ${String(t)} 階層より下のフォルダーは閉じたままです`,treeEntryKindDirectory:"ディレクトリ",treeEntryKindFile:"ファイル",treeScrollUp:"上へスクロール",treeScrollDown:"下へスクロール",treeScrollToTop:"先頭へ",treeScrollToBottom:"末尾へ",selectionTitle:e=>`選択中 (${String(e)})`,clearSelection:"選択を解除",openSelectionInMulti:e=>`${String(e)} 件をパネルで開く`,removeFromSelection:e=>`${e} を選択から外す`,settingSortMode:"並び順",sortNative:"取得順",sortAscending:"名前の昇順",sortDescending:"名前の降順",settingFolderPlacement:"フォルダーの位置",folderPlacementMixed:"混ぜる",folderPlacementFirst:"先に",folderPlacementLast:"後に",settingSelectionMode:"選択",selectionSingle:"1 件",selectionMultiple:"複数",selectionNone:"オフ",settingDoubleClick:"ダブルクリック",doubleClickRecursive:"下の階層まで展開",doubleClickToggle:"開閉",settingExpandIconSize:"展開アイコンの大きさ",expandIconSizeValue:e=>`${String(e)} px`,settingAlwaysExpanded:"常に展開",settingRevealDocument:"開いた文書をツリーで表示",settingRemoveRootIndent:"最上位の字下げなし",settingTreeLines:"ツリーの線",settingExpandIcons:"展開アイコン",settingDirectoryIcons:"フォルダーのアイコン",settingFileIcons:"ファイルのアイコン",settingOn:"オン",settingOff:"オフ",settingAnnouncement:(e,t)=>`${e}: ${t}`,documentRegion:"文書",documentEmpty:"エクスプローラーで文書を選んでください。",documentLoading:"文書を読み込み中…",markupLoading:"ソースを読み込み中…",documentShown:e=>`${e} を表示しています`,documentFailed:(e,t)=>`${e}: ${t}`,announcementSequence:e=>e.map(t=>/[。!?]$/u.test(t)?t:`${t}。`).join(""),textTruncated:"このファイルは先頭だけを表示しています。",inertLink:"リンク先がソースの外にあるため開けません。",failureUnauthorizedTitle:"セッションの有効期限が切れました",failureUnauthorizedBody:"ページを再読み込みして、もう一度サインインしてください。",failureForbiddenTitle:"アクセスが許可されていません",failureForbiddenBody:"これを開く権限がありません。",failureNotFoundTitle:"見つかりません",failureNotFoundBody:"移動または削除された可能性があります。",failureNotConfiguredTitle:"このソースは設定されていません",failureNotConfiguredBody:"管理者に設定を依頼してください。",failureInvalidTitle:"アドレスが正しくありません",failureInvalidBody:"このアドレスに含まれる文書の経路は使えません。",failureTooLargeTitle:"大きすぎて表示できません",failureTooLargeBody:"このファイルは表示できる大きさを超えています。",failureUnsupportedTitle:"表示できない形式です",failureUnsupportedBody:"この種類のファイルはここでは表示できません。",failureFailedTitle:"読み込みに失敗しました",failureFailedBody:"しばらくしてからもう一度お試しください。",retry:"再試行",reloadPage:"ページを再読み込み",imageZoomIn:"拡大",imageZoomOut:"縮小",imageFit:"画面に合わせる",imageFitLevel:"全体",imageZoomLevel:e=>`${String(e)}%`,openInNewTab:"新しいタブで開く",download:"ダウンロード",copyText:"テキストをコピー",copiedText:"テキストをコピーしました",copyTextFailed:"テキストをコピーできませんでした",mediaUnsupported:"このブラウザではこのファイルを再生できません。",fileNotShown:"このファイルはここでは表示できません。ダウンロードして開いてください。",viewerLoading:"データを読み込み中...",viewerErrorPrefix:"エラー: ",viewerStyleTitle:"表示スタイル",viewerSelectStyle:"表示スタイルを選択",viewerPinStyle:"スタイル選択をピン留め",viewerUnpinStyle:"スタイル選択のピン留めを解除",viewerErrorTitle:"エラーが発生しました",viewerMissingImage:"画像が見つかりません",viewerOpenToc:"目次を開く",viewerTocTitle:"目次",viewerPinToc:"目次をピン留め",viewerUnpinToc:"目次のピン留めを解除",viewerSelectAlign:"揃えを選択",viewerAlignTitle:"揃え",viewerPinAlign:"揃え選択をピン留め",viewerUnpinAlign:"揃え選択のピン留めを解除",viewerAlignLeft:"左揃え",viewerAlignCenter:"中央揃え",viewerAlignRight:"右揃え",viewerMermaidInteractionMode:"マウス操作モード",viewerMermaidModeNone:"操作なし",viewerMermaidModeZoom:"拡大縮小のみ",viewerMermaidModePan:"移動のみ (左ドラッグ)",viewerMermaidModePanShift:"移動のみ (Shift+ドラッグ)",viewerMermaidModeBoth:"拡大縮小+移動 (左ドラッグ)",viewerMermaidModeBothShift:"拡大縮小+移動 (Shift+ドラッグ)",viewerMermaidZoomIn:"拡大",viewerMermaidZoomOut:"縮小",viewerMermaidResetView:"表示を元に戻す",viewerMermaidRetry:"再試行",viewerEmbeddedVideo:"埋め込みの動画",viewerEmbeddedPost:"埋め込みの投稿",viewerEmbeddedFrame:"埋め込みのコンテンツ",multiRegion:"パネル",multiEmpty:"エクスプローラーで文書を選ぶと、ここに並べて開きます。",panelLimit:e=>`同時に開けるのは ${String(e)} パネルまでです。`,panelOpened:e=>`${e} を開きました`,panelClosed:e=>`${e} を閉じました`,panelAlreadyOpen:e=>`${e} は既に開いています`,panelHidden:e=>`${e} を隠しました`,panelShown:e=>`${e} を表示しました`,panelMaximized:e=>`${e} を最大化しました`,panelRestored:e=>`${e} を元のサイズに戻しました`,panelHide:"パネルを隠す",panelMaximize:"パネルを最大化",panelRestore:"パネルを元のサイズに戻す",panelClose:"パネルを閉じる",panelSwitchToCustomDrag:"カスタムのドラッグの方式に切り替え",panelSwitchToNormalDrag:"通常のドラッグの方式に戻す",panelCustomDragBadge:"カスタム",panelMovePreviousColumn:"前の列へ移動",panelMoveNextColumn:"次の列へ移動",panelMoveUp:"上へ移動",panelMoveDown:"下へ移動",panelMoved:"{title} を {column} 列目の {position} 番目へ移動しました",panelMoveUnavailable:"{title} は「{move}」できません",panelDragStarted:"{title} を持ち上げました",panelDragCancelled:"{title} の移動を取り消しました",hiddenPanelsTitle:"隠したパネル:",hiddenPanelBadge:"非表示",hiddenPanelNotice:"このパネルは隠しています",multiColumnEmpty:"この列は空です",multiColumnRegion:"{column} 列目",panelDropHere:"ここへパネルをドロップ"},Lt=Object.freeze({en:Object.freeze(At),ja:Object.freeze(Rn)}),Ze=Object.freeze(Object.keys(At)),Tn=new Set(Ze),Cn=e=>Tn.has(e),we=e=>e===null?"null":typeof e=="string"?JSON.stringify(e.length>40?`${e.slice(0,40)}…`:e):typeof e=="function"?"a function":Array.isArray(e)?"an array":typeof e,jt=e=>{if(e===void 0)return Ct;if(qe.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${qe.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${we(e)}`)},Ie=(e,t)=>{const n=Lt[jt(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${we(t)}`);if(!I.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${we(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Cn(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Ze.join(", ")}`);const a=r[s];if(a===void 0)continue;const u=typeof n[s];if(typeof a!==u)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${u}; got ${we(a)}`);if(typeof a=="string"&&a.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const p=Ot[s];if(typeof a=="string"&&p!==void 0){for(const[,m]of a.matchAll(kn))if(!p.includes(m??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(m)}}; it accepts ${p.map(f=>`{${f}}`).join(", ")}`)}o[s]=a}return Object.freeze(o)},On=(e,t)=>{if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const n=e,r=t,o=Object.keys(n),s=Object.keys(r);return o.length===s.length&&s.every(a=>Object.hasOwn(n,a)&&Object.is(n[a],r[a]))},Be=Object.freeze(["light","dark"]),An=e=>{if(e===void 0)return"light";if(Be.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${Be.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},Mt=i.createContext(null),P=()=>{const e=i.use(Mt);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},ue=e=>{const{viewSettings:t}=P(),n=()=>e(t.getSnapshot());return i.useSyncExternalStore(t.subscribe,n,n)},Se=()=>{const{config:e}=P(),t=Y.useParams()["*"],[n]=Y.useSearchParams(),r=n.toString();return i.useMemo(()=>I.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])},Nt={unauthorized:["failureUnauthorizedTitle","failureUnauthorizedBody"],forbidden:["failureForbiddenTitle","failureForbiddenBody"],"not-found":["failureNotFoundTitle","failureNotFoundBody"],"not-configured":["failureNotConfiguredTitle","failureNotConfiguredBody"],invalid:["failureInvalidTitle","failureInvalidBody"],"too-large":["failureTooLargeTitle","failureTooLargeBody"],unsupported:["failureUnsupportedTitle","failureUnsupportedBody"],failed:["failureFailedTitle","failureFailedBody"]},te=(e,t)=>e[Nt[t][0]],le=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=P(),s=te(o,e.reason),a=o[Nt[e.reason][1]],u=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning";return l.jsxs("div",{className:"aqmx-callout",role:t?"alert":void 0,"data-aqmx-tone":u,"data-testid":r===null?void 0:r,"data-aqmx-failure":r===null?void 0:e.reason,children:[l.jsx("p",{className:"aqmx-callout-title",children:s}),l.jsx("p",{className:"aqmx-callout-body",children:a}),e.reason==="unauthorized"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>window.location.reload(),children:o.reloadPage}):n!==void 0&&e.reason==="failed"?l.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:o.retry}):null]})},Ln=(e,t)=>{const{phase:n,save:r,dirty:o}=t;switch(n.kind){case"opening":return e.editLoading;case"grant":return e.editGrantTitle;case"failed":return te(e,n.failure.reason)}switch(r.kind){case"saving":return e.draftSaving;case"conflicts":return e.draftConflicts(r.count);case"grant":return e.editGrantTitle;case"failed":return e.draftSaveFailed(te(e,r.failure.reason));case"saved":if(!o)return r.merged?e.draftSavedMerged:e.draftSaved;break}return o?e.draftUnsaved:""},jn=(e,t,n)=>{switch(t.kind){case"saved":return t.merged?e.documentSavedMerged(n):e.documentSaved(n);case"conflicts":return e.draftConflicts(t.count);case"grant":return e.editGrantTitle;case"failed":return e.draftSaveFailed(te(e,t.failure.reason));case"idle":case"saving":return null}},ae=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},Dt="<<<<<<<",Pt="=======",_t=">>>>>>>",rt=(e,t)=>e===t||e.startsWith(`${t} `),ot=e=>Ft(e.split(`
2
+ `)),Ft=e=>{const t=[];let n=null,r=null,o=0;for(const s of e){o+=1;const a=s.charCodeAt(0);a!==60&&a!==61&&a!==62||(rt(s,Dt)?(n=o,r=null):s===Pt?n!==null&&r===null?r=o:n=null:rt(s,_t)&&(n!==null&&r!==null&&t.push({start:n,separator:r,end:o}),n=null,r=null))}return t},st=e=>e.includes(`\r
3
+ `)?`\r
4
+ `:`
5
+ `,je=e=>e.replace(/\r\n?/gu,`
6
+ `),Mn=(e,t)=>t===`
7
+ `?e:e.replaceAll(`
8
+ `,`\r
9
+ `),Nn=3,Me=Object.freeze({kind:"idle"}),Dn=({data:e,conflictLabels:t,onSaveSettled:n,previewSetting:r})=>{const o=new Map,s=new Map,a=new Map,u=new Map,p=new Map,m=ae();let f=null,v=null;const h=(c,d)=>{c.value={...c.value,...d},m.emit()},S=(c,d)=>o.get(c)===d,A=async(c,d)=>{d.controller.abort(),d.controller=new AbortController;const{signal:g}=d.controller;h(d,{phase:{kind:"opening"}});const x=await e.edit(c,g);if(!S(c,d)||g.aborted||!("kind"in x))return;if(x.kind==="grant"){h(d,{phase:{kind:"grant",href:x.href}});return}if(x.kind==="failure"){h(d,{phase:{kind:"failed",failure:x.failure}});return}const k=je(x.text);d.base={text:k,version:x.version},d.draft=k,d.ending=st(x.text),h(d,{phase:{kind:"editing"},history:x.history,dirty:!1,save:Me,generation:d.value.generation+1})},y=c=>{const d=o.get(c);d!==void 0&&(d.controller.abort(),o.delete(c),a.delete(c))},C=(c,d,g)=>(c.set(d,g),()=>{c.get(d)===g&&c.delete(d)}),R=(c,d,g,x={})=>{h(d,{...x,save:g}),n(c,g)},M=async c=>{u.get(c)?.flush();const d=o.get(c);if(d===void 0||d.value.phase.kind!=="editing"||d.base===null||d.value.save.kind==="saving")return;const g=ot(d.draft).length;if(g>0){R(c,d,{kind:"conflicts",count:g});return}d.controller.abort(),d.controller=new AbortController;const{signal:x}=d.controller;let k=d.base,j=d.draft,T=!1;h(d,{save:{kind:"saving"}});for(let D=0;D<Nn;D+=1){const F=await e.save(c,k.version,Mn(j,d.ending),x);if(!S(c,d)||x.aborted||!("kind"in F))return;if(F.kind==="saved"){u.get(c)?.flush(),d.base={text:j,version:F.version},R(c,d,{kind:"saved",merged:T},{dirty:d.draft!==j});return}if(F.kind==="grant"){R(c,d,{kind:"grant",href:F.href});return}if(F.kind==="failure"){R(c,d,{kind:"failed",failure:F.failure});return}const{mergeDraft:V}=await Promise.resolve().then(()=>require("./merge-DgAmnpnO.cjs"));if(!S(c,d)||x.aborted)return;const K=u.get(c);K?.flush();const X=je(F.text),G=V(k.text,d.draft,X,t());if(k={text:X,version:F.version},d.base=k,d.ending=st(F.text),d.draft=G.text,K?.adopt(G.text),G.kind==="conflicts"){R(c,d,{kind:"conflicts",count:G.conflicts},{dirty:!0,generation:d.value.generation+1});return}if(T=!0,j=G.text,j===k.text){R(c,d,{kind:"saved",merged:T},{dirty:!1,generation:d.value.generation+1});return}h(d,{dirty:!0,generation:d.value.generation+1})}R(c,d,{kind:"failed",failure:{reason:"failed"}})};return{session:c=>o.get(c)?.value,subscribe:m.subscribe,start:(c,d)=>{const g=o.get(c);if(g!==void 0){h(g,{request:{anchor:d}}),(g.value.phase.kind==="failed"||g.value.phase.kind==="grant")&&A(c,g);return}s.delete(c);const x={value:{path:c,phase:{kind:"opening"},history:!1,dirty:!1,save:Me,generation:0,request:{anchor:d}},base:null,draft:"",ending:`
10
+ `,controller:new AbortController};o.set(c,x),A(c,x)},retry:c=>{const d=o.get(c);d===void 0||d.value.phase.kind==="editing"||A(c,d)},draft:c=>{const d=o.get(c);return d===void 0||d.base===null?null:d.draft},setDraft:(c,d)=>{const g=o.get(c);if(g===void 0||g.base===null)return;g.draft=d;const x={},k=d!==g.base.text;k!==g.value.dirty&&(x.dirty=k);const{save:j}=g.value;if(j.kind==="conflicts"){const T=ot(d).length;T===0?x.save=Me:T!==j.count&&(x.save={kind:"conflicts",count:T})}(x.dirty!==void 0||x.save!==void 0)&&h(g,x)},consumeRequest:c=>{const d=o.get(c);d!==void 0&&d.value.request!==null&&h(d,{request:null})},save:M,replaceDraft:(c,d)=>{const g=u.get(c);g?.flush();const x=o.get(c);if(x===void 0||x.base===null)return;const k=je(d);x.draft=k,g?.adopt(k),h(x,{dirty:k!==x.base.text,generation:x.value.generation+1})},close:c=>{if(!o.has(c))return;const d=u.get(c),g=d===void 0?null:d.returnPoint();y(c),g===null?s.delete(c):s.set(c,g),m.emit()},takeReturn:c=>{const d=s.get(c)??null;return s.delete(c),d},dirtyPaths:()=>[...o.values()].filter(c=>c.value.dirty).map(c=>c.value.path),discard:c=>{for(const d of c)y(d);c.length>0&&m.emit()},editorState:{get:c=>a.get(c),set:(c,d)=>{o.has(c)&&a.set(c,d)}},bindEditor:(c,d)=>C(u,c,d),bindView:(c,d)=>C(p,c,d),viewAnchor:c=>{const d=p.get(c);return d===void 0?null:d.anchor()},flush:c=>u.get(c)?.flush(),flushDrafts:()=>{for(const c of u.values())c.flush()},nextConflict:c=>u.get(c)?.nextConflict()===!0,hasSessions:()=>o.size>0,unsavedAmong:c=>{for(const d of u.values())d.flush();return c.filter(d=>o.get(d)?.value.dirty===!0)},askToDiscard:c=>new Promise(d=>{v?.settle(!1);const g={paths:c,settle:x=>{if(v===g){if(v=null,x)for(const k of c)y(k);m.emit(),d(x)}}};v=g,m.emit()}),discardRequest:()=>v,previewShown:()=>(f??=r.read(),f),setPreviewShown:c=>{f!==c&&(f=c,r.write(c),m.emit())}}},Ve=e=>{e.preventDefault(),e.stopPropagation()},$t=({open:e,title:t,body:n,confirmLabel:r,cancelLabel:o,onConfirm:s,onCancel:a,testId:u})=>{const p=i.useRef(null),m=i.useRef(null),f=i.useRef(null),v=i.useId(),h=i.useId();i.useLayoutEffect(()=>{const y=p.current;if(y!==null)if(e&&!y.open){const C=y.ownerDocument.activeElement;f.current=C instanceof HTMLElement?C:null,y.showModal(),m.current?.focus()}else!e&&y.open&&(y.close(),f.current?.isConnected===!0&&f.current.focus(),f.current=null)},[e]);const S=y=>{y.key!=="Escape"||y.defaultPrevented||(Ve(y),a())},A=y=>{y.target===y.currentTarget&&a()};return l.jsx("dialog",{ref:p,className:"aqmx-confirm","aria-labelledby":v,"aria-describedby":h,"data-testid":u,onKeyDown:S,onClick:A,onCancel:y=>y.preventDefault(),children:l.jsxs("div",{className:"aqmx-confirm-panel",children:[l.jsx("p",{id:v,className:"aqmx-confirm-title",children:t}),l.jsx("p",{id:h,className:"aqmx-confirm-body",children:n}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{ref:m,type:"button",className:"aqmx-callout-action","data-testid":`${u}-cancel`,onClick:a,children:o}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-aqmx-tone":"danger","data-testid":`${u}-confirm`,onClick:s,children:r})]})]})})},Pn=(e,t)=>{const n=Y.matchPath({path:`${e.basePath}/*`,end:!0},t.pathname);if(n===null)return new Set;const{location:r}=I.resolveExplorerLocation(e,n.params["*"],new URLSearchParams(t.search));switch(r.view){case"tree":return new Set(r.doc===null?[]:[r.doc]);case"single":return new Set([r.doc]);case"multi":return new Set(r.docs)}},qt=e=>{const{edits:t}=P(),n=i.useCallback(()=>t.session(e),[t,e]);return i.useSyncExternalStore(t.subscribe,n,_n)},It=()=>!1,_n=()=>{},Fn=()=>{const{edits:e}=P();return i.useSyncExternalStore(e.subscribe,e.hasSessions,It)},Bt=()=>{const{edits:e}=P();return i.useSyncExternalStore(e.subscribe,e.previewShown,It)},$n=()=>null,qn=()=>{const{edits:e,labels:t,config:n}=P(),r=i.useRef([]),o=i.useCallback(({nextLocation:v})=>{const h=Pn(n,v);return e.flushDrafts(),r.current=e.dirtyPaths().filter(S=>!h.has(S)),r.current.length>0},[e,n]),s=Y.useBlocker(o),a=Fn();i.useEffect(()=>{if(!a)return;const v=h=>{e.flushDrafts(),e.dirtyPaths().length!==0&&(h.preventDefault(),h.returnValue=!0)};return window.addEventListener("beforeunload",v),()=>window.removeEventListener("beforeunload",v)},[a,e]);const u=i.useSyncExternalStore(e.subscribe,e.discardRequest,$n),p=s.state==="blocked",f=(p?r.current:u===null?[]:u.paths).map(v=>N.lastPathSegment(v)).join(", ");return l.jsx($t,{open:p||u!==null,title:t.unsavedTitle,body:t.unsavedBody(f),confirmLabel:t.unsavedDiscard,cancelLabel:t.unsavedStay,testId:"markdown-explorer-unsaved-guard",onConfirm:()=>{if(s.state==="blocked"){e.discard(r.current),s.proceed();return}u?.settle(!0)},onCancel:()=>{if(s.state==="blocked"){s.reset();return}u?.settle(!1)}})};function In({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm2.25 8.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Zm0 3a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const Bn=E.forwardRef(In);let Ne=null;const Ht=()=>(Ne??=Promise.resolve().then(()=>require("./EditSurface-BQ5QAdDd.cjs")).catch(e=>{throw Ne=null,e}),Ne),lt=()=>{Ht().catch(()=>{})},Hn=e=>{const{default:t}=i.use(Ht());return l.jsx(t,{...e})};class Un extends i.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}retry=()=>this.setState({failed:!1});render(){return this.state.failed?this.props.fallback(this.retry):this.props.children}}const Ge=`[${$e.SOURCE_LINES_ATTRIBUTE}]`,zn="[data-aqmd-content]",Zn='a[href], button, input, select, textarea, summary, label, [contenteditable], [role="menu"], iframe, video, audio, object, embed, svg',Vn=200,fe=e=>$e.parseSourceLines(e.getAttribute($e.SOURCE_LINES_ATTRIBUTE)),Gn=(e,t)=>{for(let r=e;r!==null&&t.contains(r);r=r.parentElement){const o=fe(r);if(o!==null)return{block:r,lines:o,own:!0}}let n=null;for(const r of t.querySelectorAll(Ge)){if(!(r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))break;const o=fe(r);o!==null&&(n={block:r,lines:o})}return n===null?null:{...n,own:!1}},Kn=(e,t)=>{let n=0;for(let r=e.indexOf(t);r>=0;r=e.indexOf(t,r+t.length))n+=1;return n},Wn=e=>e.closest(zn)!==null&&e.closest(Zn)===null,Xn=(e,t,n)=>{const r=Gn(e,t);if(r===null)return null;const{block:o,own:s}=r;if(!s){const u=r.lines.last+1;return{lines:{first:u,last:u},word:null,occurrence:0,clientTop:Ee(e)}}const a=Qn(o,n);return a===null?{lines:r.lines,word:null,occurrence:0,clientTop:Ee(o)}:{lines:r.lines,word:a.text,occurrence:a.occurrence,clientTop:a.clientTop}},Yn=(e,t)=>{let n=null,r=null,o=null;for(const a of e.querySelectorAll(Ge)){const u=fe(a);if(u===null)continue;n??=zt(t,a);const{top:p,bottom:m}=a.getBoundingClientRect();p<=n&&n<m?r={lines:u,block:a}:o===null&&p>=n&&(o={lines:u,block:a})}const s=r===null?o:r;return s===null?null:{lines:s.lines,word:null,occurrence:0,clientTop:Ee(s.block)}},Ut=e=>e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,zt=(e,t)=>{const n=Number.parseFloat(getComputedStyle(t).scrollMarginTop);return Ut(e)+(Number.isFinite(n)?n:0)},Qn=(e,t)=>{if(t===null||t.rangeCount===0)return null;const n=t.getRangeAt(0);if(!(e.contains(n.startContainer)&&e.contains(n.endContainer)))return null;const r=n.toString().trim();if(r===""||r.length>Vn||/[\r\n]/u.test(r))return null;const o=e.ownerDocument.createRange();return o.setStart(e,0),o.setEnd(n.startContainer,n.startOffset),{text:r,occurrence:Kn(o.toString(),r),clientTop:n.getBoundingClientRect().top}},Jn=(e,t)=>{const n=e.split(`
11
+ `),r=Math.min(t.lines.first,n.length),o=Math.min(t.lines.last,n.length),s={line:r,column:0};if(t.word===null)return s;let a=0;for(let u=r;u<=o;u+=1){const p=n[u-1]??"";for(let m=p.indexOf(t.word);m>=0;m=p.indexOf(t.word,m+t.word.length)){if(a===t.occurrence)return{line:u,column:m};a+=1}}return a>0?er(n,r,o,t.word)??s:s},er=(e,t,n,r)=>{for(let o=n;o>=t;o-=1){const s=(e[o-1]??"").lastIndexOf(r);if(s>=0)return{line:o,column:s}}return null},Zt=(e,t)=>{let n=null,r=null;for(const o of e.querySelectorAll(Ge)){const s=fe(o);s===null||s.first>t||(s.last>=t?n=o:(r===null||s.last>=r.last)&&(r={element:o,last:s.last}))}return n!==null?n:r===null?null:r.element},Vt=(e,t)=>{const{bottom:n}=e.getBoundingClientRect(),r=Ee(e),o=fe(e);if(o===null)return r;const s=Math.min(Math.max(t-o.first,0)/(o.last-o.first+1),1);return r+(n-r)*s},Ee=e=>{const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let n=t.nextNode();n!==null;n=t.nextNode()){const o=(n.textContent??"").search(/\S/u);if(o<0)continue;const s=e.ownerDocument.createRange();s.setStart(n,o),s.setEnd(n,o+1);const{top:a,height:u}=s.getBoundingClientRect();if(u>0)return a}return e.getBoundingClientRect().top},Ke=Object.freeze({browse:Object.freeze({replace:!0,preventScrollReset:!0,defaultShouldRevalidate:!1}),"switch-source":Object.freeze({replace:!1,preventScrollReset:!0,defaultShouldRevalidate:!1}),"switch-view":Object.freeze({replace:!1,preventScrollReset:!1,defaultShouldRevalidate:!1}),"follow-link":Object.freeze({replace:!1,preventScrollReset:!1,defaultShouldRevalidate:!1})}),tr=e=>Ke[e],he=()=>{const e=Y.useNavigate();return i.useCallback((t,n)=>{e(t,Ke[n])},[e])},Gt=({navigation:e,...t})=>l.jsx(Y.Link,{...t,...Ke[e]}),We=e=>{const t=e.ownerDocument;if(e.focus({preventScroll:!0}),t.activeElement===e)return!0;if(e.hasAttribute("tabindex"))return!1;if(e.setAttribute("tabindex","-1"),e.focus({preventScroll:!0}),t.activeElement!==e)return e.removeAttribute("tabindex"),!1;const n=()=>{t.activeElement!==e&&(e.removeAttribute("tabindex"),e.removeEventListener("blur",n))};return e.addEventListener("blur",n),!0},Kt=(e,t)=>{const n=i.useRef(null),r=i.useRef(null),o=i.useRef(null),s=i.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);i.useEffect(()=>s,[s]);const a=i.useCallback(m=>{if(r.current!==m)return;const f=o.current;if(f!==null){f.then(()=>a(m));return}e.prefetch(m);const v=e.peek(m);if(v?.status!=="pending")return;const h=Promise.allSettled([v.promise]);o.current=h,h.then(()=>{o.current===h&&(o.current=null)})},[e]),u=i.useCallback(m=>{const f=t(m);f!==r.current&&(s(),f!==null&&(r.current=f,n.current=window.setTimeout(()=>{n.current=null,a(f)},I.PREFETCH_DWELL_MS)))},[s,t,a]),p=i.useCallback(m=>{t(m)!==r.current&&s()},[s,t]);return i.useMemo(()=>({onPointerOver:m=>u(m.target),onPointerOut:m=>p(m.relatedTarget),onFocus:m=>u(m.target),onBlur:m=>p(m.relatedTarget)}),[u,p])},nr=i.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-PBnODPEM.cjs")).then(e=>({default:e.NativeScrollBar})));class rr extends i.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){console.error("[markdown-explorer] a scroll bar failed to load or render; its scroller keeps its native scrolling without it.",t)}render(){return this.state.failed?null:this.props.children}}const Wt=({scroller:e,withCircle:t})=>l.jsx(rr,{children:l.jsx(i.Suspense,{fallback:null,children:l.jsx(nr,{scroller:e,withCircle:t})})}),Xt=e=>l.jsx(Wt,{scroller:e,withCircle:!0}),Yt=()=>{const e=new Map,t=new Set;let n=!1;const r=o=>{t.add(o),!n&&(n=!0,queueMicrotask(()=>{n=!1,t.clear()}))};return{hold:o=>{e.set(o,(e.get(o)??0)+1);let s=!1;return()=>{if(s)return;s=!0;const a=e.get(o);if(a!==void 0&&a>1){e.set(o,a-1);return}e.delete(o),r(o)}},isHeld:o=>e.has(o),resumes:o=>t.delete(o),heldKeys:()=>[...e.keys()]}},be=(e,t)=>{if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t))return!(Array.isArray(e)&&Array.isArray(t))||e.length!==t.length?!1:e.every((s,a)=>be(s,t[a]));const n=e,r=t,o=Object.keys(n);return o.length!==Object.keys(r).length?!1:o.every(s=>Object.hasOwn(r,s)&&be(n[s],r[s]))},me=e=>{const t=e;return t.status===void 0&&(t.status="pending",e.then(n=>{t.status="fulfilled",t.value=n},n=>{t.status="rejected",t.reason=n})),t},Qt=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),pe=e=>e.status==="fulfilled"?e.value:void 0,or=55e3,it=Object.freeze({status:"deferred"}),at=Object.freeze({status:"refreshed"}),De=Object.freeze({status:"superseded"}),oe=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,Jt=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",sr=({client:e,capacity:t})=>{if(!Number.isInteger(t)||t<1)throw new RangeError(`[markdown-explorer] the document cache capacity must be a positive integer; got ${String(t)}`);const n=new Map,r=Yt(),o=ae(),s=new WeakSet;let a=0;const u=o.emit,p=()=>(a+=1,a),m=()=>{if(!(n.size<=t))for(const c of[...n.keys()]){if(n.size<=t)return;r.isHeld(c)||n.delete(c)}},f=(c,d)=>{n.delete(c),n.set(c,d)},v=c=>performance.now()-c.validatedAt>=or,h=(c,d,g)=>{const x=n.get(c),k=oe(x?.snapshot),j=g||x?.refreshPending===!0,T=me(e.document(c,{refresh:j}).then(F=>({status:"loaded",document:F}))),D={snapshot:{status:"pending",promise:T,previous:k},validatedAt:performance.now(),opened:d,background:null,refreshPending:!1,seeded:void 0,stamp:p()};return f(c,D),m(),T.then(F=>{n.get(c)===D&&(D.snapshot=F,D.stamp=p(),u())}),D},S=(c,d,g,x,k,j)=>{d.background===g&&(d.background=null,!(n.get(c)!==d||d.snapshot!==x)&&(k.kind==="failure"&&x.document.kind!=="failure"||(d.validatedAt=j,d.stamp=p(),be(x.document,k)||(d.snapshot={status:"loaded",document:k}),u())))},A=async(c,d)=>{const g=d.snapshot;if(g.status!=="loaded")return null;const x={};d.background=x;const k=performance.now(),j=e.document(c,{refresh:d.refreshPending});d.refreshPending=!1;const T=await j,D=d.background===x&&n.get(c)===d&&d.snapshot===g;return S(c,d,x,g,T,k),D?T:null},y=(c,d)=>{const{snapshot:g}=d;return g.status==="pending"?!1:g.status==="loaded"&&g.document.kind!=="failure"?(A(c,d),!1):(g.status==="loaded"&&s.add(g),h(c,!0,!1),!0)},C=c=>{const d=r.hold(c);let g=!1;return()=>{if(g)return;g=!0,d();const x=n.get(c);x!==void 0&&f(c,x),m()}};return{peek:c=>n.get(c)?.snapshot,peekSeeded:c=>n.get(c)?.seeded,answerStampOf:c=>n.get(c)?.stamp,prefetch:c=>{const d=n.get(c);d!==void 0&&d.snapshot.status!=="deferred"||(h(c,!1,!1),u())},open:c=>{const d=r.resumes(c),g=C(c),x=n.get(c);if(x===void 0||x.snapshot.status==="deferred")return h(c,!0,!1),u(),g;if(f(c,x),d)return g;const{snapshot:k}=x;return k.status==="pending"?(x.opened=!0,g):k.document.kind==="failure"?(x.opened||v(x)?(s.add(k),h(c,!0,!1),u()):x.opened=!0,g):(x.opened=!0,x.background===null&&v(x)&&A(c,x),g)},retain:C,retry:c=>{const d=n.get(c);d===void 0||d.snapshot.status!=="loaded"||d.snapshot.document.kind!=="failure"||(h(c,!0,!1),u())},seed:(c,d)=>{const g=performance.now(),x=me(d.then(F=>F===null?it:{status:"loaded",document:F},()=>it)),k=n.get(c);if(k!==void 0&&k.snapshot.status==="loaded"){const F=k.snapshot,V={};k.background=V,x.then(K=>{if(K.status==="loaded"){S(c,k,V,F,K.document,g);return}k.background===V&&(k.background=null)});return}const j=k!==void 0&&k.snapshot.status==="pending"?k.snapshot.previous:null,T={status:"pending",promise:x,previous:j},D={snapshot:T,validatedAt:g,opened:k?.opened===!0,background:null,refreshPending:k?.refreshPending===!0,seeded:T,stamp:p()};f(c,D),m(),x.then(F=>{n.get(c)===D&&(F.status==="deferred"&&r.isHeld(c)?h(c,D.opened,!1):(D.snapshot=F,D.stamp=p()),u())})},invalidate:()=>{let c=!1;for(const[d,g]of[...n]){if(g.validatedAt=Number.NEGATIVE_INFINITY,g.opened=!0,g.refreshPending=!0,!r.isHeld(d))continue;const{snapshot:x}=g;if(x.status!=="pending"){y(d,g)&&(c=!0);continue}x.promise.then(()=>{n.get(d)===g&&g.refreshPending&&r.isHeld(d)&&y(d,g)&&u()})}c&&u()},refresh:async c=>{const d=n.get(c);if(d!==void 0&&Jt(d.snapshot)){d.refreshPending=!0;const x=await A(c,d);return x===null?De:x.kind==="failure"?{status:"failed",failure:x.failure}:at}const g=h(c,!0,!0);return u(),g.snapshot.status!=="pending"?De:(await g.snapshot.promise,n.get(c)===g?at:De)},clear:()=>{n.clear();for(const c of r.heldKeys())h(c,!0,!1);u()},subscribe:o.subscribe,noteFailureShown:c=>s.has(c)?!1:(s.add(c),!0)}};function lr({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M18 5.25a2.25 2.25 0 0 0-2.012-2.238A2.25 2.25 0 0 0 13.75 1h-1.5a2.25 2.25 0 0 0-2.238 2.012c-.875.092-1.6.686-1.884 1.488H11A2.5 2.5 0 0 1 13.5 7v7h2.25A2.25 2.25 0 0 0 18 11.75v-6.5ZM12.25 2.5a.75.75 0 0 0-.75.75v.25h3v-.25a.75.75 0 0 0-.75-.75h-1.5Z",clipRule:"evenodd"}),E.createElement("path",{fillRule:"evenodd",d:"M3 6a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V7a1 1 0 0 0-1-1H3Zm6.874 4.166a.75.75 0 1 0-1.248-.832l-2.493 3.739-.853-.853a.75.75 0 0 0-1.06 1.06l1.5 1.5a.75.75 0 0 0 1.154-.114l3-4.5Z",clipRule:"evenodd"}))}const ir=E.forwardRef(lr);function ar({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M15.988 3.012A2.25 2.25 0 0 1 18 5.25v6.5A2.25 2.25 0 0 1 15.75 14H13.5v-3.379a3 3 0 0 0-.879-2.121l-3.12-3.121a3 3 0 0 0-1.402-.791 2.252 2.252 0 0 1 1.913-1.576A2.25 2.25 0 0 1 12.25 1h1.5a2.25 2.25 0 0 1 2.238 2.012ZM11.5 3.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 .75.75v.25h-3v-.25Z",clipRule:"evenodd"}),E.createElement("path",{d:"M3.5 6A1.5 1.5 0 0 0 2 7.5v9A1.5 1.5 0 0 0 3.5 18h7a1.5 1.5 0 0 0 1.5-1.5v-5.879a1.5 1.5 0 0 0-.44-1.06L8.44 6.439A1.5 1.5 0 0 0 7.378 6H3.5Z"}))}const cr=E.forwardRef(ar);function dr({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495ZM10 5a.75.75 0 0 1 .75.75v3.5a.75.75 0 0 1-1.5 0v-3.5A.75.75 0 0 1 10 5Zm0 9a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z",clipRule:"evenodd"}))}const ur=E.forwardRef(dr),fr=2e3,ct=Object.freeze({outcome:"idle"}),mr=e=>{const t=navigator.clipboard;return t===void 0?Promise.reject(new Error("[markdown-explorer] this browser has no asynchronous clipboard")):t.writeText(e)},hr=({text:e})=>{const{announcer:t,labels:n}=P(),[r,o]=i.useState(ct);i.useEffect(()=>{if(r.outcome==="idle")return;const p=setTimeout(()=>o(ct),fr);return()=>clearTimeout(p)},[r]);const s=p=>{o({outcome:p}),t.announce(p==="copied"?n.copiedText:n.copyTextFailed)},a=()=>{mr(e).then(()=>s("copied"),()=>s("failed"))},u=r.outcome==="copied"?n.copiedText:r.outcome==="failed"?n.copyTextFailed:n.copyText;return l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":n.copyText,title:u,onClick:a,"data-aqmx-copy-outcome":r.outcome,"data-testid":"markdown-explorer-file-copy",children:r.outcome==="copied"?l.jsx(ir,{}):r.outcome==="failed"?l.jsx(ur,{}):l.jsx(cr,{})})},ie=i.createContext("fill"),gr=Object.freeze({blockSize:"100%"}),ge=({scrollerProps:e,children:t})=>i.use(ie)==="content"?l.jsx(de.HostedScrollArea,{scrollerProps:e,children:t}):l.jsx(de.HostedScrollArea,{scrollerProps:{...e,style:gr},rowClassName:"aqmx-document-scroll-row",renderScrollBar:Xt,children:t});function pr({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{d:"M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z"}),E.createElement("path",{d:"M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z"}))}const vr=E.forwardRef(pr);function wr({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z",clipRule:"evenodd"}),E.createElement("path",{fillRule:"evenodd",d:"M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z",clipRule:"evenodd"}))}const xr=E.forwardRef(wr),ke=({name:e,url:t,icon:n,children:r})=>{const{labels:o}=P();return l.jsxs("div",{className:"aqmx-document-toolbar",children:[l.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:n}),l.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),r,l.jsx("a",{className:"aqmx-icon-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":o.openInNewTab,title:o.openInNewTab,"data-testid":"markdown-explorer-file-open",children:l.jsx(xr,{})}),l.jsx("a",{className:"aqmx-icon-button",href:t,download:e,"aria-label":o.download,title:o.download,"data-testid":"markdown-explorer-file-download",children:l.jsx(vr,{})})]})};function Er({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm4.75 6.75a.75.75 0 0 1 1.5 0v2.546l.943-1.048a.75.75 0 0 1 1.114 1.004l-2.25 2.5a.75.75 0 0 1-1.114 0l-2.25-2.5a.75.75 0 1 1 1.114-1.004l.943 1.048V8.75Z",clipRule:"evenodd"}))}const br=E.forwardRef(Er),yr=Object.freeze({className:"aqmx-document-stage"}),Sr=({document:e})=>{const{labels:t}=P();return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[l.jsx(ke,{name:e.name,url:e.url,icon:l.jsx(br,{})}),l.jsx(ge,{scrollerProps:yr,children:l.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-file-not-shown",children:[l.jsx("p",{className:"aqmx-callout-body",children:t.fileNotShown}),l.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-file-not-shown-download",children:t.download})]})})]})},Re="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",kr=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},Rr=/(%[0-9A-Fa-f]{2})/u,Xe=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(Rr).flatMap((r,o)=>o%2===1?[Number.parseInt(r.slice(1),16)]:[...t.encode(r)]);return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(Uint8Array.from(n))},en=e=>`#${encodeURIComponent(e)}`,Tr=e=>{if(e==="#")return!0;const t=Xe(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},tn=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},Cr="http://www.w3.org/1999/xhtml",dt=(e,t)=>{if(t==="")return null;const n=tn(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===Cr&&r.getAttribute("name")===t)return r;return null},nn=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=dt(e,t.slice(1));if(n!==null)return n;const r=Xe(t);return r===null?null:dt(e,r)},ut=e=>{const{body:t,documentElement:n}=e.ownerDocument;if(e===t){const o=getComputedStyle(n);if(o.overflowX==="visible"&&o.overflowY==="visible")return!1}const{overflowY:r}=getComputedStyle(e);return r==="auto"||r==="scroll"},Or=e=>{const{body:t,documentElement:n}=e,r=getComputedStyle(n),o=r.overflowX==="visible"&&r.overflowY==="visible"&&t!==null?getComputedStyle(t).overflowY:r.overflowY;return o!=="hidden"&&o!=="clip"},Ar=(e,t)=>{const n=t.closest(Re),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&ut(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:a}=e.ownerDocument;for(let u=e.parentElement;u!==null&&u!==s;u=u.parentElement)if(ut(u)&&u.scrollHeight>u.clientHeight&&u.clientHeight<o)return u;return a instanceof Element&&Or(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},Lr=Object.freeze({scrollerOf:Ar,reveal:e=>{e.scrollIntoView(He)}}),He=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),jr=(e,t)=>{for(let n=t;n!==null&&n!==e;n=n.parentElement){const r=n.parentElement;if(r instanceof HTMLDetailsElement&&n!==r.querySelector(":scope > summary")&&(r.open=!0),n.getAttribute("hidden")?.toLowerCase()==="until-found"){if(n.dispatchEvent(new Event("beforematch",{bubbles:!0})),!n.isConnected)return;n.removeAttribute("hidden")}}},Mr=(e,t)=>{if(t.getClientRects().length===0)return;const n=e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,{scrollMarginTop:r,scrollMarginBottom:o}=getComputedStyle(t),s=Number.parseFloat(r),a=t.getBoundingClientRect(),u=a.height+s+Number.parseFloat(o)>e.clientHeight;if(!u&&Math.abs(a.top-s-n)<1){t.scrollIntoView(He);return}e.scrollBy({top:u?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(He)},Nr=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Re)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},ft=(e,t,n)=>{if(e===null)return null;const r=nn(e,t);return r===null?(Tr(t)&&Nr(e,n),null):(jr(e,r),Mr(n.scrollerOf(e,r),r),n.reveal(r),r)};function Dr({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{d:"M3.28 2.22a.75.75 0 0 0-1.06 1.06L5.44 6.5H2.75a.75.75 0 0 0 0 1.5h4.5A.75.75 0 0 0 8 7.25v-4.5a.75.75 0 0 0-1.5 0v2.69L3.28 2.22ZM13.5 2.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-2.69l3.22-3.22a.75.75 0 0 0-1.06-1.06L13.5 5.44V2.75ZM3.28 17.78l3.22-3.22v2.69a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.69l-3.22 3.22a.75.75 0 1 0 1.06 1.06ZM13.5 14.56l3.22 3.22a.75.75 0 1 0 1.06-1.06l-3.22-3.22h2.69a.75.75 0 0 0 0-1.5h-4.5a.75.75 0 0 0-.75.75v4.5a.75.75 0 0 0 1.5 0v-2.69Z"}))}const Pr=E.forwardRef(Dr);function _r({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{d:"M6.75 8.25a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z"}),E.createElement("path",{fillRule:"evenodd",d:"M9 2a7 7 0 1 0 4.391 12.452l3.329 3.328a.75.75 0 1 0 1.06-1.06l-3.328-3.329A7 7 0 0 0 9 2ZM3.5 9a5.5 5.5 0 1 1 11 0 5.5 5.5 0 0 1-11 0Z",clipRule:"evenodd"}))}const Fr=E.forwardRef(_r);function $r({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{d:"M9 6a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0v-1.5h-1.5a.75.75 0 0 1 0-1.5h1.5v-1.5A.75.75 0 0 1 9 6Z"}),E.createElement("path",{fillRule:"evenodd",d:"M2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Zm7-5.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z",clipRule:"evenodd"}))}const qr=E.forwardRef($r);function Ir({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0l-2.97 2.97ZM12 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",clipRule:"evenodd"}))}const Br=E.forwardRef(Ir),Ue="data-aqmx-key-repeat",ye=Object.freeze({[Ue]:"allow"}),Hr=`[${Ue}="${ye[Ue]}"]`,Ur=()=>{let e=null;return{onKeyDownCapture:t=>{if(t.key==="Enter"){if(!t.repeat){e=t.target instanceof Element?t.target:null;return}e!==null&&t.target===e&&e.closest(Hr)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},xe=Object.freeze([1/I.GOLDEN_RATIO**2,1/I.GOLDEN_RATIO,1,I.GOLDEN_RATIO,I.GOLDEN_RATIO**2]),mt=Object.freeze({mode:"fit"}),zr=1,Zr=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),rn=i.createContext(null),Vr=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=zr?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,ht=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<xe.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?xe.findIndex(o=>o>t):xe.findLastIndex(o=>o<t);return r===-1?null:r},gt=(e,t,n)=>{if(e.mode==="level"){const o=ht(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=ht(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},Gr=e=>{const t=xe[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},pt=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},Kr=({document:e})=>{const{labels:t}=P(),n=i.use(rn),[r]=i.useState(()=>n===null?null:n.read(e.url)),[o,s]=i.useState(r===null?mt:r.zoom),[a,u]=i.useState(r===null?null:r.reported),[p,m]=i.useState(null),f=i.useRef(null),v=i.useCallback(M=>{const{naturalWidth:c,naturalHeight:d}=M;u(g=>pt(g,c,d))},[]),h=i.useCallback(M=>{f.current=M,!(M===null||!M.complete)&&(M.naturalWidth>0||M.naturalHeight>0?v(M):M.decode().then(()=>v(M),()=>{}))},[v]);i.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),i.useLayoutEffect(()=>{const M=f.current;if(M===null||a===null||o.mode!=="fit")return;const c=()=>m(g=>pt(g,M.clientWidth,M.clientHeight));if(c(),typeof ResizeObserver>"u")return;const d=new ResizeObserver(c);return d.observe(M),()=>d.disconnect()},[a,o.mode]);const S=a===null||p===null?null:Vr(a,p),A=gt(o,S,-1),y=gt(o,S,1),C=o.mode==="level"?Gr(o.index):null,R=o.mode==="level"&&C!==null?{width:`${o.base.width*C}px`,height:`${o.base.height*C}px`}:void 0;return l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[l.jsxs(ke,{name:e.name,url:e.url,icon:l.jsx(Br,{}),children:[l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":A===null,onClick:()=>{A!==null&&s(A)},...ye,children:l.jsx(Fr,{})}),l.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:C===null?t.imageFitLevel:t.imageZoomLevel(Math.round(C*100))}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":y===null,onClick:()=>{y!==null&&s(y)},...ye,children:l.jsx(qr,{})}),l.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(mt),children:l.jsx(Pr,{})})]}),l.jsx(ge,{scrollerProps:Zr,children:l.jsx("img",{ref:h,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:R,onLoad:M=>v(M.currentTarget),"data-testid":"markdown-explorer-image"})})]})},on=i.createContext(null),Te=i.createContext(void 0),sn=i.createContext(null),Ce=()=>{const e=i.use(on);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},Wr=()=>{const e=i.use(sn);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},Oe=(e,t,n,r)=>t.kind==="panel"?I.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?I.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):I.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),Xr=({children:e})=>{const{config:t}=P(),n=Ce(),r=Se(),o=r.kind==="location"?r.location.source:void 0,s=Y.useHref(Oe(t,n.navigation,o,n.currentPath));return l.jsx(Te,{value:o,children:l.jsx(sn,{value:s,children:e})})},Yr='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Qr=e=>{const t=e instanceof Element?e.closest(Yr):null;return t===null?null:t.getAttribute("data-doc-path")},Ae=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,Jr=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:u,children:p})=>{const m=Y.useHref(e),f=v=>{if(Ae(v)){if(v.preventDefault(),t===u.currentPath&&n!==""){u.scrollWithin(n);return}a(t,n)}};return l.jsx("a",{...s,href:m,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:f,children:p})},eo=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=P(),u=Ce(),p=i.use(Te),m=kr(e),{navigation:f}=u,v=`${Oe(a,f,p,t)}${m}`,h=n===!1?"false":void 0;return f.kind==="page"?l.jsx(Gt,{...o,to:v,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":h,children:s}):l.jsx(Jr,{to:v,docPath:t,fragment:m,exists:h,className:r,attributes:o,onDocumentLink:f.onDocumentLink,scope:u,children:s})},to=({className:e,attributes:t,children:n})=>{const{labels:r}=P();return l.jsxs("a",{...t,className:e===void 0?"aqmx-document-inert-link":`${e} aqmx-document-inert-link`,title:r.inertLink,"data-link-kind":"doc","data-doc-exists":"false",children:[n,l.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},no=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=P(),a=i.use(Te),u=Y.useHref(`${Oe(s,r.navigation,a,r.currentPath)}${e}`),p=m=>{Ae(m)&&(m.preventDefault(),r.scrollWithin(e))};return l.jsx("a",{...n,href:u,className:t,onClick:p,children:o})},ro=({href:e,className:t,attributes:n,children:r})=>{const o=Ce();if(o.navigation.kind==="page"){const s=a=>{if(!Ae(a))return;const u=a.currentTarget;e==="#"?o.followEmptyFragment(a.nativeEvent):u.href===u.ownerDocument.URL&&o.followSameUrlJump(e,a.nativeEvent)};return l.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return l.jsx(no,{href:e,className:t,attributes:n,scope:o,children:r})},oo=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!N.isAcceptableDocumentPath(n)?l.jsx(to,{className:o,attributes:s,children:a}):l.jsx(eo,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?l.jsx(ro,{href:e,className:o,attributes:s,children:a}):l.jsx("a",{...s,href:e,className:o,children:a}),so=()=>{const{config:e}=P(),t=Ce(),n=i.use(Te),r=he();return i.useCallback((o,s)=>{if(!Ae(s))return!0;s.preventDefault();const a=en(o.id),{navigation:u}=t;return u.kind==="panel"||Xe(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${Oe(e,u,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},lo=()=>{const e=Wr();return i.useCallback(t=>`${e}${en(t.id)}`,[e])};function io({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{d:"M3 3.5A1.5 1.5 0 0 1 4.5 2h6.879a1.5 1.5 0 0 1 1.06.44l4.122 4.12A1.5 1.5 0 0 1 17 7.622V16.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 16.5v-13Z"}))}const ao=E.forwardRef(io);function co({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M1 4.75C1 3.784 1.784 3 2.75 3h14.5c.966 0 1.75.784 1.75 1.75v10.515a1.75 1.75 0 0 1-1.75 1.75h-1.5c-.078 0-.155-.005-.23-.015H4.48c-.075.01-.152.015-.23.015h-1.5A1.75 1.75 0 0 1 1 15.265V4.75Zm16.5 7.385V11.01a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25Zm0 2.005a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .108.069.2.165.235h1.585a.25.25 0 0 0 .25-.25v-1.11Zm-15 1.11v-1.11a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.164.235H2.75a.25.25 0 0 1-.25-.25Zm2-4.24v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V11.01a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25Zm13-2.005V7.88a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25ZM4.25 7.63a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V7.88a.25.25 0 0 1 .25-.25h1.5Zm0-3.13a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5Zm11.5 1.625a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5Zm-9 3.125a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const uo=E.forwardRef(co);function fo({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M17.721 1.599a.75.75 0 0 1 .279.583v11.29a2.25 2.25 0 0 1-1.774 2.2l-2.041.44a2.216 2.216 0 0 1-.938-4.332l2.662-.577a.75.75 0 0 0 .591-.733V6.112l-8 1.73v7.684a2.25 2.25 0 0 1-1.774 2.2l-2.042.44a2.216 2.216 0 1 1-.935-4.331l2.659-.573A.75.75 0 0 0 7 12.529V4.236a.75.75 0 0 1 .591-.733l9.5-2.054a.75.75 0 0 1 .63.15Z",clipRule:"evenodd"}))}const mo=E.forwardRef(fo),ho=Object.freeze({className:"aqmx-document-stage"}),go=e=>{switch(e){case"video":return l.jsx(uo,{});case"audio":return l.jsx(mo,{});case"pdf":return l.jsx(ao,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},po=({document:e})=>{const{labels:t}=P();switch(e.mediaType){case"video":return l.jsx("video",{className:"aqmx-document-video",src:e.url,controls:!0,preload:"metadata","aria-label":e.name,"data-testid":"markdown-explorer-media-player",children:t.mediaUnsupported});case"audio":return l.jsx("audio",{className:"aqmx-document-audio",src:e.url,controls:!0,preload:"metadata","aria-label":e.name,"data-testid":"markdown-explorer-media-player",children:t.mediaUnsupported});case"pdf":return l.jsx("iframe",{className:"aqmx-document-frame",src:e.url,title:e.name,"data-testid":"markdown-explorer-media-player"});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},vo=({document:e})=>l.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[l.jsx(ke,{name:e.name,url:e.url,icon:go(e.mediaType)}),l.jsx(ge,{scrollerProps:ho,children:l.jsx(po,{document:e})})]}),wo=e=>({loading:e.viewerLoading,errorPrefix:e.viewerErrorPrefix,styleTitle:e.viewerStyleTitle,selectStyleAria:e.viewerSelectStyle,pinStyleAria:e.viewerPinStyle,unpinStyleAria:e.viewerUnpinStyle,defaultErrorTitle:e.viewerErrorTitle,missingImage:e.viewerMissingImage,openTocAria:e.viewerOpenToc,tocTitle:e.viewerTocTitle,pinTocAria:e.viewerPinToc,unpinTocAria:e.viewerUnpinToc,selectAlignAria:e.viewerSelectAlign,alignTitle:e.viewerAlignTitle,pinAlignAria:e.viewerPinAlign,unpinAlignAria:e.viewerUnpinAlign,alignLeft:e.viewerAlignLeft,alignCenter:e.viewerAlignCenter,alignRight:e.viewerAlignRight,mermaidInteractionMode:e.viewerMermaidInteractionMode,mermaidModeNone:e.viewerMermaidModeNone,mermaidModeZoom:e.viewerMermaidModeZoom,mermaidModePan:e.viewerMermaidModePan,mermaidModePanShift:e.viewerMermaidModePanShift,mermaidModeBoth:e.viewerMermaidModeBoth,mermaidModeBothShift:e.viewerMermaidModeBothShift,mermaidZoomIn:e.viewerMermaidZoomIn,mermaidZoomOut:e.viewerMermaidZoomOut,mermaidResetView:e.viewerMermaidResetView,mermaidRetry:e.viewerMermaidRetry,embeddedVideo:e.viewerEmbeddedVideo,embeddedPost:e.viewerEmbeddedPost,embeddedFrame:e.viewerEmbeddedFrame}),ln=(e,t,n)=>{if(t!==void 0)return t;if(n!==void 0)return n;const[r]=e.documentStyles;if(r===void 0)throw new Error("[markdown-explorer] the configuration has no document style");return r.name},an=(e,t)=>e!==void 0?e:t!==void 0?t:yn.DEFAULT_CONTENT_ALIGN,Ye=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),xo=(e,t,n)=>{if(t.view==="multi"||t.overrides[n]===void 0)return null;const r=n==="style"?{align:t.overrides.align}:{style:t.overrides.style};return I.explorerHref(e,{...t,overrides:r})},Qe=({kind:e,view:t,label:n,stale:r,busy:o,frameRef:s,intent:a,children:u})=>{const p=i.use(ie);return l.jsxs("section",{ref:s,role:"region","aria-label":n,"aria-busy":o,"data-testid":"markdown-explorer-document","data-aqmx-document-kind":e,"data-aqmx-document-view":t,"data-aqmx-document-flow":p,className:"aqmx-document",...a,children:[r?l.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,u]})},Eo=()=>{const{labels:e}=P();return l.jsx(Qe,{kind:"empty",label:e.documentRegion,stale:!1,busy:!1,children:l.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:l.jsx("p",{className:"aqmx-empty-title",children:e.documentEmpty})})})},cn=({label:e})=>{const{labels:t}=P();return l.jsxs(Qe,{kind:"loading",label:e,stale:!1,busy:!0,children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-document-skeleton",children:Ye.map(n=>l.jsx("span",{},n))}),l.jsx("p",{className:"aqmx-sr-only",children:t.documentLoading})]})},vt=Object.freeze(["wheel","touchstart","pointerdown","keydown"]),bo=({path:e,document:t,viewer:n,editing:r})=>{const{reportMathDiagnostics:o,edits:s}=P(),a=i.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),u=so(),p=lo(),m=i.useMemo(()=>o===void 0?void 0:g=>o(e,g),[o,e]),f=i.useRef(null),{editable:v,doubleClick:h,region:S,paneScroll:A,stale:y}=r;i.useLayoutEffect(()=>{if(v)return s.bindView(e,{anchor:()=>{const g=f.current,x=S(),k=g===null?null:g.querySelector(Re);return g===null||x===null||k===null?null:Yn(g,A.scrollerOf(x,k))}})},[s,e,v,S,A]);const C=g=>{const x=f.current,{target:k}=g;!h||x===null||!(k instanceof Element)||!Wn(k)||(g.stopPropagation(),s.start(e,Xn(k,x,x.ownerDocument.getSelection())))},R=i.useRef(null),M=i.useRef(y);i.useLayoutEffect(()=>{M.current=y});const c=i.useEffectEvent(g=>{const x=f.current,k=S(),j=x===null?null:Zt(x,g.line);if(k===null||j===null)return!1;const T=A.scrollerOf(k,j);return T.scrollTop+=Vt(j,g.line)-g.clientTop,!0}),d=i.useEffectEvent(g=>{const x=S();if(x===null)return;const k=()=>{for(const T of vt)x.removeEventListener(T,j,!0);R.current?.release===k&&(R.current=null)},j=()=>k();for(const T of vt)x.addEventListener(T,j,{capture:!0,passive:!0});R.current={point:g,release:k}});return i.useLayoutEffect(()=>{const g=s.takeReturn(e);if(g!==null)return queueMicrotask(()=>{c(g)&&M.current&&d(g)}),()=>R.current?.release()},[s,e]),i.useLayoutEffect(()=>{const g=R.current;g===null||y||(g.release(),c(g.point))},[t,y]),l.jsx("div",{ref:f,className:"aqmx-document-viewer",onDoubleClick:C,children:l.jsx(de.MarkdownViewer,{...n,onHeadingSelect:u,headingHref:p,onMathDiagnostics:m,parseResult:a,content:null})})},dn=({document:e,viewer:t})=>{const{labels:n}=P();return l.jsxs(l.Fragment,{children:[l.jsx(ke,{name:e.name,url:e.url,icon:l.jsx(Bn,{}),children:e.truncated?null:l.jsx(hr,{text:e.text})}),e.truncated?l.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,l.jsx("div",{className:"aqmx-document-viewer",children:l.jsx(de.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},yo=({path:e,name:t,viewer:n})=>{const{data:r,documents:o,announcer:s,labels:a}=P(),u=i.useCallback(()=>o.answerStampOf(e),[o,e]),p=i.useSyncExternalStore(o.subscribe,u,u),[m,f]=i.useState(0),v=i.useMemo(()=>({path:e,stamp:p,attempt:m}),[e,p,m]),[h,S]=i.useState(null),A=i.useEffectEvent(C=>{S(C),C.kind==="failure"&&s.announce(a.documentFailed(t,te(a,C.failure.reason)))});i.useEffect(()=>{const C=new AbortController;return r.text(v.path,C.signal).then(R=>{"kind"in R&&A(R)}),()=>C.abort()},[r,v]);const y=i.useCallback(()=>f(C=>C+1),[]);return h===null?l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-markup-skeleton",children:Ye.map(C=>l.jsx("span",{},C))}),l.jsx("p",{className:"aqmx-sr-only",children:a.markupLoading})]}):h.kind==="failure"?l.jsx(ge,{scrollerProps:un,children:l.jsx(le,{failure:h.failure,alert:!1,onRetry:y,testId:"markdown-explorer-markup-failure"})}):l.jsx(dn,{document:h,viewer:n})},un=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),So=Object.freeze({reason:"failed"}),ko=e=>l.jsx(Un,{fallback:t=>l.jsx("div",{className:"aqmx-edit-message",children:l.jsx(le,{failure:So,alert:!1,onRetry:t,testId:"markdown-explorer-edit-load-failure"})}),children:l.jsx(i.Suspense,{fallback:l.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-skeleton",children:Ye.map(t=>l.jsx("span",{},t))}),children:l.jsx(Hn,{...e})})}),Ro=({path:e,document:t,view:n,viewer:r,onRetry:o,editing:s})=>{switch(t.kind){case"markdown":{const{session:a,layout:u,region:p,paneScroll:m,stale:f}=s;if(n==="edit"&&a!==void 0)return l.jsx(ko,{path:e,name:t.name,session:a,layout:u,viewer:r,region:p,paneScroll:m});if(n==="markup")return l.jsx(yo,{path:e,name:t.name,viewer:r});const v=t.edit!==null&&t.edit.kind==="inline";return l.jsx(bo,{path:e,document:t,viewer:r,editing:{editable:v,doubleClick:v&&u==="fill",region:p,paneScroll:m,stale:f}})}case"text":return l.jsx(dn,{document:t,viewer:r});case"image":return l.jsx(Kr,{document:t});case"media":return l.jsx(vo,{document:t});case"file":return l.jsx(Sr,{document:t});case"failure":return l.jsx(ge,{scrollerProps:un,children:l.jsx(le,{failure:t.failure,alert:!1,onRetry:o,testId:"markdown-explorer-document-failure"})});default:{const a=t;throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(a)}`)}}},To='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',Co=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:nn(e,n),r===void 0?null:tn(e,r.id),e.querySelector(Re),e.querySelector(To)];for(const s of o)if(s instanceof HTMLElement&&We(s))return s;return null},wt=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&We(t)},Oo=e=>{const t=i.useRef(!1);return i.useLayoutEffect(()=>{const n=e.current;if(n===null)throw new Error("[markdown-explorer] the document region is not mounted");const r=n.ownerDocument,o=r.defaultView;if(o===null)throw new Error("[markdown-explorer] the document region's document has no window");let s=!1,a;const u=h=>{s=!(h.target instanceof Node&&n.contains(h.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=setTimeout(()=>{s=!1},0)},p=h=>{t.current=h.target instanceof Node&&n.contains(h.target)},m=h=>{h.relatedTarget===null&&s&&(t.current=!1)},f=()=>{const{activeElement:h,body:S}=r;h!==null&&h!==S&&(t.current=n.contains(h))},v=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",u,!0),o.addEventListener("mousedown",u,!0),o.addEventListener("focusin",p,!0),o.addEventListener("blur",f),o.addEventListener("focus",v),n.addEventListener("focusout",m),()=>{clearTimeout(a),o.removeEventListener("pointerdown",u,!0),o.removeEventListener("mousedown",u,!0),o.removeEventListener("focusin",p,!0),o.removeEventListener("blur",f),o.removeEventListener("focus",v),n.removeEventListener("focusout",m)}},[e]),t},Ao=({path:e,snapshot:t,markup:n,stale:r,viewer:o,editLayout:s,regionLabel:a,navigation:u,fragment:p,paneScroll:m,announces:f,announceFailure:v,onDocumentShown:h})=>{const{labels:S,announcer:A,documents:y}=P(),{document:C}=t,R=i.useRef(null),M=i.useRef(null),c=i.useRef(null),d=i.useRef(0),g=Oo(R),x=i.useRef({path:e,document:C}),k=i.useRef(null),j=i.useCallback(H=>{const Z=R.current,W=ft(Z,H,m);Z!==null&&W!==null&&wt(Z,W,g.current)},[m,g]),T=i.useCallback((H,Z)=>{const W=d.current;setTimeout(()=>{!Z.defaultPrevented&&d.current===W&&j(H)},0)},[j]),D=i.useCallback(H=>{setTimeout(()=>{H.defaultPrevented||j("#")},0)},[j]),F=i.useMemo(()=>({navigation:u,currentPath:e,scrollWithin:j,followSameUrlJump:T,followEmptyFragment:D}),[u,e,j,T,D]),V=i.useCallback(()=>y.retry(e),[y,e]),K=Kt(y,Qr),X=qt(e),G=X!==void 0?"edit":n?"markup":"rendered",_=C.kind==="markdown"?G:void 0,z=i.useCallback(()=>R.current,[]),w=i.useMemo(()=>({session:X,layout:s,region:z,paneScroll:m,stale:r}),[X,s,z,m,r]),b=_==="edit"?!1:r,O=i.use(ie),L=_==="edit"&&s==="fill"?"fill":O,$=i.useEffectEvent((H,Z)=>{const W=M.current;if(W!==null&&W.path===H&&W.snapshot===Z)return;M.current={path:H,snapshot:Z};const Q=Z.document;if(Q.kind==="failure"){y.noteFailureShown(Z)&&v(S.documentFailed(N.lastPathSegment(H),te(S,Q.failure.reason)));return}h?.(H,Q),f&&(W===null||W.path!==H||W.snapshot.document.kind==="failure")&&A.announce(S.documentShown(Q.name))});i.useEffect(()=>{$(e,t)},[e,t]);const q=i.useEffectEvent(()=>{p.kind==="panel"&&p.consume()}),U=i.useEffectEvent(H=>{const Z=R.current;if(Z===null||!g.current)return null;const{activeElement:W,body:Q}=Z.ownerDocument;return W!==null&&W!==Q?null:Co(Z,C,H)}),B=i.useEffectEvent(H=>{const Z=R.current;Z!==null&&wt(Z,H,g.current)}),ee=i.useEffectEvent(H=>m.reveal(H)),et=i.useEffectEvent(H=>ft(R.current,H,m));return i.useEffect(()=>{if(r)return;const H=x.current.path!==e,Z=H||x.current.document!==C;x.current={path:e,document:C};const W=k.current!==e;k.current=e;let Q=null;p.kind==="page"?c.current!==p.navigation&&(c.current=p.navigation,d.current+=1,Q=p.fragment):p.fragment!==null&&(Q=p.fragment,q());const tt=()=>{const Le=Q===null?null:et(Q);if(!Z){Le!==null&&B(Le);return}const nt=U(p.fragment);H&&Le===null&&nt!==null&&ee(nt)};W?queueMicrotask(tt):tt()},[p,e,C,r]),l.jsx(ie,{value:L,children:l.jsx(Qe,{kind:C.kind,view:_,label:a(e,C),stale:b,busy:b,frameRef:R,intent:K,children:l.jsx(on,{value:F,children:l.jsx(Xr,{children:l.jsx(Ro,{path:e,document:C,view:G,viewer:o,onRetry:V,editing:w},e)})})})})},Je=Object.freeze({kind:"skeleton"}),Lo=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=oe(t);if(s!==null)return{kind:"document",path:e,snapshot:s,stale:!0};if(o&&t?.status==="pending")return{kind:"streaming",path:e,promise:t.promise};const a=n===null||n===e?null:oe(r);return n===null||a===null?Je:{kind:"document",path:n,snapshot:a,stale:!0}},jo=(e,t)=>t.status==="deferred"?Je:{kind:"document",path:e,snapshot:t,stale:!1},Mo=({requestedPath:e,content:t,markup:n,...r})=>{const o=t.kind==="streaming"?jo(t.path,i.use(t.promise)):t;return o.kind!=="document"?l.jsx(cn,{label:r.regionLabel(e,null)}):l.jsx(Ao,{path:o.path,snapshot:o.snapshot,markup:n,stale:o.stale,...r})},fn=({path:e,markup:t,display:n,navigation:r,fragment:o,paneScroll:s,announces:a,announceFailure:u,onDocumentShown:p})=>{const{config:m,labels:f,theme:v,documents:h}=P(),S=de.useMarkdownToolbarState(),A=i.useRef(!1);i.useLayoutEffect(()=>{A.current=!0},[]);const[y,C]=i.useState(null),[R,M]=i.useState(t),c=i.useCallback(()=>e===null?void 0:h.peek(e),[h,e]),d=i.useSyncExternalStore(h.subscribe,c,c),g=i.useCallback(()=>y===null?void 0:h.peek(y),[h,y]),x=i.useSyncExternalStore(h.subscribe,g,g);i.useLayoutEffect(()=>e===null?void 0:h.open(e),[h,e]),i.useLayoutEffect(()=>y===null?void 0:h.retain(y),[h,y]);const k=e===null?Je:Lo(e,d,y,x,!A.current),j=e===null?null:k.kind==="document"&&!k.stale?k.path:y;j!==y&&C(j);const T=k.kind!=="document"||k.path===e;T&&t!==R&&M(t);const D=i.useMemo(()=>wo(f),[f]),F=i.useMemo(()=>[...m.iframeHosts],[m]),V=r.kind==="panel",K=i.useMemo(()=>({labels:D,emptyMessage:f.documentEmpty,theme:v,availableStyles:m.documentStyles,iFrameAllowedDomains:F,embeds:m.embeds,linkComponent:oo,toolbar:S,style:n.style,onStyleChange:n.onStyleChange,align:n.align,onAlignChange:n.onAlignChange,showToc:n.showToc,showStyle:n.showStyle,showAlign:n.showAlign,padding:n.padding,width:n.width===void 0?void 0:`min(${n.width}, 100%)`,maxWidth:n.maxWidth===void 0?void 0:`min(${n.maxWidth}, 100%)`,renderScrollBar:V?void 0:Xt}),[D,f.documentEmpty,v,m.documentStyles,F,m.embeds,S,n,V]),X=i.useCallback((_,z)=>V?z===null||z.kind==="failure"?N.lastPathSegment(_):z.name:f.documentRegion,[V,f.documentRegion]),G=V?"content":"fill";return e===null?l.jsx(ie,{value:G,children:l.jsx(Eo,{})}):l.jsx(ie,{value:G,children:l.jsx(i.Suspense,{fallback:l.jsx(cn,{label:X(e,null)}),children:l.jsx(Mo,{requestedPath:e,content:k,markup:T?t:R,viewer:K,editLayout:n.editLayout,regionLabel:X,navigation:r,fragment:o,paneScroll:s,announces:a,announceFailure:u,onDocumentShown:p})})})},No=({path:e,markup:t,variant:n,onDocumentShown:r})=>{const{config:o,viewSettings:s,announcer:a}=P(),u=ue(j=>j.style),p=ue(j=>j.align),m=he(),f=Y.useLocation(),v=Se(),{view:h,overrides:S,embed:A}=n,y=i.useCallback(j=>{if(v.kind!=="location")return;const T=xo(o,v.location,j);T!==null&&m(T,"browse")},[o,m,v]),C=i.useCallback(j=>{s.update({style:j}),y("style")},[s,y]),R=i.useCallback(j=>{s.update({align:j}),y("align")},[s,y]),M=ln(o,S.style,u),c=an(S.align,p),d=i.useMemo(()=>({style:M,onStyleChange:C,align:c,onAlignChange:R,showToc:A.showToc!==!1,showStyle:A.showStyle!==!1,showAlign:A.showAlign!==!1,padding:A.padding,width:A.width,maxWidth:A.maxWidth,editLayout:"fill"}),[M,C,c,R,A]),g=i.useMemo(()=>({kind:"page",view:h,overrides:S,embed:A}),[h,S,A]),x=i.useMemo(()=>({kind:"page",fragment:f.hash,navigation:f}),[f]),k=i.useCallback(j=>a.announce(j),[a]);return l.jsx(fn,{path:e,markup:t,display:d,navigation:g,fragment:x,paneScroll:Lr,announces:!0,announceFailure:k,onDocumentShown:r})},Do=({path:e,markup:t,variant:n,onDocumentShown:r})=>{const{config:o,viewSettings:s}=P(),a=ue(g=>g.style),u=ue(g=>g.align),[p,m]=i.useState(()=>ln(o,void 0,a)),f=an(void 0,u),v=i.useCallback(g=>s.update({align:g}),[s]),{maximized:h,onDocumentLink:S,pendingHash:A,onHashConsumed:y,announceFailure:C,paneScroll:R}=n,M=i.useMemo(()=>({style:p,onStyleChange:m,align:f,onAlignChange:v,showToc:h,showStyle:h,showAlign:h,padding:void 0,width:void 0,maxWidth:void 0,editLayout:h?"fill":"content"}),[p,f,v,h]),c=i.useMemo(()=>({kind:"panel",onDocumentLink:S}),[S]),d=i.useMemo(()=>({kind:"panel",fragment:A,consume:y}),[A,y]);return l.jsx(fn,{path:e,markup:t,display:M,navigation:c,fragment:d,paneScroll:R,announces:!1,announceFailure:C,onDocumentShown:r})},mn=({path:e,markup:t,variant:n,onDocumentShown:r})=>n.kind==="page"?l.jsx(No,{path:e,markup:t,variant:n,onDocumentShown:r}):l.jsx(Do,{path:e,markup:t,variant:n,onDocumentShown:r});function Po({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z",clipRule:"evenodd"}))}const hn=E.forwardRef(Po);function _o({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M14.447 3.026a.75.75 0 0 1 .527.921l-4.5 16.5a.75.75 0 0 1-1.448-.394l4.5-16.5a.75.75 0 0 1 .921-.527ZM16.72 6.22a.75.75 0 0 1 1.06 0l5.25 5.25a.75.75 0 0 1 0 1.06l-5.25 5.25a.75.75 0 1 1-1.06-1.06L21.44 12l-4.72-4.72a.75.75 0 0 1 0-1.06Zm-9.44 0a.75.75 0 0 1 0 1.06L2.56 12l4.72 4.72a.75.75 0 0 1-1.06 1.06L.97 12.53a.75.75 0 0 1 0-1.06l5.25-5.25a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const Fo=E.forwardRef(_o);function $o({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M15.75 2.25H21a.75.75 0 0 1 .75.75v5.25a.75.75 0 0 1-1.5 0V4.81L8.03 17.03a.75.75 0 0 1-1.06-1.06L19.19 3.75h-3.44a.75.75 0 0 1 0-1.5Zm-10.5 4.5a1.5 1.5 0 0 0-1.5 1.5v10.5a1.5 1.5 0 0 0 1.5 1.5h10.5a1.5 1.5 0 0 0 1.5-1.5V10.5a.75.75 0 0 1 1.5 0v8.25a3 3 0 0 1-3 3H5.25a3 3 0 0 1-3-3V8.25a3 3 0 0 1 3-3h8.25a.75.75 0 0 1 0 1.5H5.25Z",clipRule:"evenodd"}))}const qo=E.forwardRef($o);function Io({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M11.47 13.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 0 0-1.06-1.06L12 11.69 5.03 4.72a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}),E.createElement("path",{fillRule:"evenodd",d:"M11.47 19.28a.75.75 0 0 0 1.06 0l7.5-7.5a.75.75 0 1 0-1.06-1.06L12 17.69l-6.97-6.97a.75.75 0 0 0-1.06 1.06l7.5 7.5Z",clipRule:"evenodd"}))}const Bo=E.forwardRef(Io);function Ho({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25ZM12.75 6a.75.75 0 0 0-1.5 0v6c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-3.75V6Z",clipRule:"evenodd"}))}const Uo=E.forwardRef(Ho);function zo({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{fillRule:"evenodd",d:"M9 1.5H5.625c-1.036 0-1.875.84-1.875 1.875v17.25c0 1.035.84 1.875 1.875 1.875h12.75c1.035 0 1.875-.84 1.875-1.875V12.75A3.75 3.75 0 0 0 16.5 9h-1.875a1.875 1.875 0 0 1-1.875-1.875V5.25A3.75 3.75 0 0 0 9 1.5Zm6.61 10.936a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 14.47a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z",clipRule:"evenodd"}),E.createElement("path",{d:"M12.971 1.816A5.23 5.23 0 0 1 14.25 5.25v1.875c0 .207.168.375.375.375H16.5a5.23 5.23 0 0 1 3.434 1.279 9.768 9.768 0 0 0-6.963-6.963Z"}))}const Zo=E.forwardRef(zo);function Vo({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{d:"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"}),E.createElement("path",{fillRule:"evenodd",d:"M1.323 11.447C2.811 6.976 7.028 3.75 12.001 3.75c4.97 0 9.185 3.223 10.675 7.69.12.362.12.752 0 1.113-1.487 4.471-5.705 7.697-10.677 7.697-4.97 0-9.186-3.223-10.675-7.69a1.762 1.762 0 0 1 0-1.113ZM17.25 12a5.25 5.25 0 1 1-10.5 0 5.25 5.25 0 0 1 10.5 0Z",clipRule:"evenodd"}))}const gn=E.forwardRef(Vo);function Go({title:e,titleId:t,...n},r){return E.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?E.createElement("title",{id:t},e):null,E.createElement("path",{d:"M21.731 2.269a2.625 2.625 0 0 0-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 0 0 0-3.712ZM19.513 8.199l-3.712-3.712-8.4 8.4a5.25 5.25 0 0 0-1.32 2.214l-.8 2.685a.75.75 0 0 0 .933.933l2.685-.8a5.25 5.25 0 0 0 2.214-1.32l8.4-8.4Z"}),E.createElement("path",{d:"M5.25 5.25a3 3 0 0 0-3 3v10.5a3 3 0 0 0 3 3h10.5a3 3 0 0 0 3-3V13.5a.75.75 0 0 0-1.5 0v5.25a1.5 1.5 0 0 1-1.5 1.5H5.25a1.5 1.5 0 0 1-1.5-1.5V8.25a1.5 1.5 0 0 1 1.5-1.5h5.25a.75.75 0 0 0 0-1.5H5.25Z"}))}const Ko=E.forwardRef(Go),pn=({href:e,onRetry:t,testId:n})=>{const{labels:r,onEditGrant:o}=P(),[s,a]=i.useState(!1),u=()=>{o===void 0||s||(a(!0),o(e).then(p=>{p&&t()}).finally(()=>a(!1)))};return l.jsxs("div",{className:"aqmx-callout aqmx-edit-grant","data-testid":n,children:[l.jsx("p",{className:"aqmx-callout-title",children:r.editGrantTitle}),l.jsx("p",{className:"aqmx-callout-body",children:r.editGrantBody}),l.jsxs("div",{className:"aqmx-edit-grant-actions",children:[o===void 0?l.jsx("a",{className:"aqmx-callout-action",href:e,target:"_blank",rel:"noopener","data-testid":`${n}-open`,children:r.editGrantAction}):l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":s,"data-testid":`${n}-open`,onClick:u,children:r.editGrantAction}),l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":`${n}-retry`,onClick:t,children:r.editGrantRetry})]})]})},xt=(e,t,n)=>{const r=e.modifiedAt===null?Number.NaN:Date.parse(e.modifiedAt);return n(Number.isNaN(r)?e.id:t.format(r),e.author===null?"":e.author)},Wo=({path:e,documentName:t,open:n,onClose:r})=>{const{data:o,edits:s,labels:a,locale:u,announcer:p}=P(),m=i.useRef(null),f=i.useRef(null),v=i.useId(),[h,S]=i.useState(null),[A,y]=i.useState(0),[C,R]=i.useState(null),[M,c]=i.useState(null),d=i.useMemo(()=>new Intl.DateTimeFormat(u,{dateStyle:"medium",timeStyle:"short"}),[u]);i.useLayoutEffect(()=>{const T=m.current;if(T!==null)if(n&&!T.open){const D=T.ownerDocument.activeElement;f.current=D instanceof HTMLElement?D:null,R(null),c(null),T.showModal()}else!n&&T.open&&(T.close(),f.current?.isConnected===!0&&f.current.focus(),f.current=null)},[n]),i.useEffect(()=>{if(!n)return;const T=new AbortController;return S(null),o.revisions(e,T.signal).then(D=>{"kind"in D&&S(D)}),()=>T.abort()},[n,o,e,A]),i.useEffect(()=>{if(!n||C===null)return;const T=new AbortController;return c(null),o.revision(e,C,T.signal).then(D=>{"kind"in D&&c(D)}),()=>T.abort()},[n,o,e,C]);const g=()=>{M===null||M.kind!=="revision"||(s.replaceDraft(e,M.text),p.announce(a.historyRestored(t)),r())},x=T=>{T.key!=="Escape"||T.defaultPrevented||(Ve(T),r())},k=T=>{T.target===T.currentTarget&&r()},j=h!==null&&h.kind==="revisions"?h.revisions.find(T=>T.id===C):void 0;return l.jsx("dialog",{ref:m,className:"aqmx-confirm aqmx-history","aria-labelledby":v,"data-testid":"markdown-explorer-history",onKeyDown:x,onClick:k,onCancel:T=>T.preventDefault(),children:l.jsxs("div",{className:"aqmx-confirm-panel aqmx-history-panel",children:[l.jsx("p",{id:v,className:"aqmx-confirm-title",children:a.historyTitle(t)}),h===null?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-loading",children:a.historyLoading}):h.kind==="failure"?l.jsx(le,{failure:h.failure,alert:!1,onRetry:()=>y(T=>T+1),testId:"markdown-explorer-history-failure"}):h.revisions.length===0?l.jsx("p",{className:"aqmx-history-note","data-testid":"markdown-explorer-history-empty",children:a.historyEmpty}):l.jsx("ul",{className:"aqmx-history-list","data-testid":"markdown-explorer-history-list",children:h.revisions.map(T=>l.jsx("li",{children:l.jsxs("button",{type:"button",className:"aqmx-history-entry","aria-pressed":T.id===C,"data-testid":"markdown-explorer-history-entry",onClick:()=>R(T.id),children:[l.jsx("span",{children:xt(T,d,a.historyEntry)}),T.current?l.jsx("span",{className:"aqmx-history-mark",children:a.historyCurrent}):null,T.kept?l.jsx("span",{className:"aqmx-history-mark",children:a.historyKept}):null]})},T.id))}),C===null?null:M===null?l.jsx("p",{className:"aqmx-history-note",children:a.historyLoading}):M.kind==="failure"?l.jsx(le,{failure:M.failure,alert:!1,testId:"markdown-explorer-history-revision-failure"}):l.jsx("section",{className:"aqmx-history-text",tabIndex:0,"aria-label":j===void 0?a.historyTitle(t):xt(j,d,a.historyEntry),"data-testid":"markdown-explorer-history-text",children:l.jsx("pre",{children:M.text})}),l.jsxs("div",{className:"aqmx-confirm-actions",children:[l.jsx("button",{type:"button",className:"aqmx-callout-action","data-testid":"markdown-explorer-history-close",onClick:r,children:a.historyClose}),l.jsx("button",{type:"button",className:"aqmx-callout-action","aria-disabled":M===null||M.kind!=="revision","data-testid":"markdown-explorer-history-restore",onClick:g,children:a.historyRestore})]})]})})},Xo=e=>{const{documents:t}=P(),n=i.useCallback(()=>t.peek(e),[t,e]),r=i.useCallback(()=>t.peekSeeded(e),[t,e]),o=i.useSyncExternalStore(t.subscribe,n,r),s=oe(o)?.document;return s===void 0||s.kind==="failure"?{edit:null,name:N.lastPathSegment(e)}:{edit:s.kind==="markdown"?s.edit:null,name:s.name}},ne=e=>{e.stopPropagation()},Yo=({path:e,documentName:t,iconOnly:n})=>{const{edits:r,labels:o}=P(),s=i.useSyncExternalStore(r.subscribe,()=>r.session(e)!==void 0,()=>!1),[a,u]=i.useState(!1),p=()=>{if(!s){r.start(e,r.viewAnchor(e));return}r.flush(e),r.session(e)?.dirty===!0?u(!0):r.close(e)},m=n?o.editDocumentNamed(t):null;return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:m===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:s?o.closeEditor:m===null?o.editDocument:m,"aria-label":m===null?void 0:m,"aria-pressed":s,"data-testid":"markdown-explorer-document-edit",onClick:p,onDoubleClick:ne,onPointerEnter:lt,onFocus:lt,children:[l.jsx(Ko,{"aria-hidden":"true"}),m===null?l.jsx("span",{children:o.editDocumentLabel}):null]}),l.jsx($t,{open:a,title:o.unsavedTitle,body:o.unsavedBody(t),confirmLabel:o.unsavedDiscard,cancelLabel:o.unsavedStay,testId:"markdown-explorer-edit-close-confirm",onConfirm:()=>{u(!1),r.close(e)},onCancel:()=>u(!1)})]})},Qo=({href:e,documentName:t,iconOnly:n})=>{const{labels:r}=P(),o=n?r.editExternallyNamed(t):null;return l.jsxs("a",{className:o===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",href:e,target:"_blank",rel:"noopener noreferrer",title:o===null?r.editExternally:o,"aria-label":o===null?void 0:o,"data-testid":"markdown-explorer-document-edit-external",onDoubleClick:ne,children:[l.jsx(qo,{"aria-hidden":"true"}),o===null?l.jsx("span",{children:r.editExternallyLabel}):null]})},Jo=({session:e})=>{const{labels:t}=P(),n=Ln(t,e);return l.jsx("p",{className:"aqmx-edit-status",title:n===""?void 0:n,"data-testid":"markdown-explorer-edit-status","data-aqmx-save":e.save.kind,children:n})},es=({path:e,documentName:t,iconOnly:n,session:r,previewAvailable:o})=>{const{edits:s,labels:a}=P(),u=Bt(),[p,m]=i.useState(!1);if(r.phase.kind!=="editing")return null;const f=r.save.kind==="saving",v=f||!r.dirty,h=()=>{s.flush(e);const A=s.session(e);A===void 0||!A.dirty||A.save.kind==="saving"||s.save(e)},S=A=>n?{className:"aqmx-icon-button","aria-label":A}:{className:"aqmx-icon-button aqmx-labelled-button"};return l.jsxs(l.Fragment,{children:[r.save.kind==="conflicts"?l.jsxs("button",{type:"button",...S(a.conflictNext),title:a.conflictNext,"data-testid":"markdown-explorer-edit-next-conflict",onClick:()=>s.nextConflict(e),onDoubleClick:ne,children:[l.jsx(Bo,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.conflictNext})]}):null,o?l.jsxs("button",{type:"button",...S(a.previewToggle),title:a.previewToggle,"aria-pressed":u,"data-testid":"markdown-explorer-edit-preview-toggle",onClick:()=>s.setPreviewShown(!u),onDoubleClick:ne,children:[l.jsx(gn,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.previewToggle})]}):null,r.history?l.jsxs("button",{type:"button",...S(a.historyOpen),title:a.historyOpen,"aria-haspopup":"dialog","data-testid":"markdown-explorer-edit-history",onClick:()=>m(!0),onDoubleClick:ne,children:[l.jsx(Uo,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.historyOpen})]}):null,l.jsxs("button",{type:"button",...S(a.saveDraft),title:a.saveDraftTooltip,"aria-disabled":v,"aria-busy":f,"aria-keyshortcuts":"Control+S Meta+S","data-testid":"markdown-explorer-edit-save",onClick:h,onDoubleClick:ne,children:[l.jsx(Zo,{"aria-hidden":"true"}),n?null:l.jsx("span",{children:a.saveDraft})]}),r.history?l.jsx(Wo,{path:e,documentName:t,open:p,onClose:()=>m(!1)}):null]})},ts=({path:e,session:t})=>{const{edits:n}=P();return t.save.kind!=="grant"?null:l.jsx(pn,{href:t.save.href,onRetry:()=>{n.save(e)},testId:"markdown-explorer-save-grant"})},ns=e=>{const{documents:t}=P(),n=i.useCallback(()=>t.peek(e),[t,e]),r=i.useCallback(()=>t.peekSeeded(e),[t,e]),o=i.useSyncExternalStore(t.subscribe,n,r);return oe(o)?.document.kind==="markdown"},vn=e=>{const{config:t}=P(),n=he(),r=i.useCallback(()=>n(I.explorerHref(t,{...e,markup:!e.markup}),"browse"),[t,n,e]);return i.useMemo(()=>({shown:e.markup,toggle:r}),[e.markup,r])},rs=new Set,os=(e,t)=>{const{documents:n,announcer:r,labels:o}=P(),s=i.useCallback(()=>n.peek(e),[n,e]),a=i.useCallback(()=>n.peekSeeded(e),[n,e]),u=i.useSyncExternalStore(n.subscribe,s,a),p=i.useCallback(()=>n.answerStampOf(e),[n,e]),m=i.useSyncExternalStore(n.subscribe,p,p),[f]=i.useState(()=>new Set),[v,h]=i.useState(rs),[S,A]=i.useState(null);S!==null&&S.path!==e&&A(null);const y=i.useRef(null);i.useLayoutEffect(()=>(y.current=e,()=>{y.current=null}),[e]);const C=i.useCallback(()=>{const c=e,d=n.peek(c);if(f.has(c)||d?.status==="pending")return;const g=t&&!Jt(d);f.add(c),h(new Set(f)),A(null),(async()=>{try{const x=await n.refresh(c);if(y.current!==c||x.status==="superseded")return;if(x.status==="failed"){A({path:c,failure:x.failure,stamp:n.answerStampOf(c)}),r.announce(o.documentRefreshFailed(te(o,x.failure.reason)));return}const k=oe(n.peek(c));if(g||k===null||k.document.kind==="failure")return;r.announce(o.documentRefreshed(k.document.name))}finally{f.delete(c),h(new Set(f))}})()},[e,t,f,n,r,o]),R=v.has(e),M=S!==null&&S.path===e&&S.stamp===m?S.failure:null;return{refreshing:R,unavailable:R||u?.status==="pending",failure:M,refresh:C}},wn=Object.freeze({kind:"page"}),xn=({path:e,placement:t,markup:n})=>{const{labels:r}=P(),{refreshing:o,unavailable:s,failure:a,refresh:u}=os(e,t.kind==="page"),p=ns(e),m=Xo(e),f=qt(e),v=t.kind==="panel"?r.refreshDocumentNamed(t.documentName):null,h=t.kind==="panel"?r.showMarkupNamed(t.documentName):null,S=t.kind==="panel",A=t.kind==="panel"?t.documentName:m.name,y=t.kind==="page"||t.maximized;return l.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar","data-aqmx-editing":f===void 0?void 0:"true",children:[l.jsxs("div",{className:"aqmx-document-refresh-row",children:[f===void 0?null:l.jsx(Jo,{session:f}),f===void 0?null:l.jsx(es,{path:e,documentName:A,iconOnly:S,session:f,previewAvailable:y}),f===void 0&&p?l.jsxs("button",{type:"button",className:h===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:h===null?r.showMarkup:h,"aria-label":h===null?void 0:h,"aria-pressed":n.shown,"data-testid":"markdown-explorer-document-markup",onClick:n.toggle,onDoubleClick:ne,children:[l.jsx(Fo,{"aria-hidden":"true"}),h===null?l.jsx("span",{children:r.showMarkupLabel}):null]}):null,f!==void 0||m.edit?.kind==="inline"?l.jsx(Yo,{path:e,documentName:A,iconOnly:S}):m.edit?.kind==="external"?l.jsx(Qo,{href:m.edit.href,documentName:A,iconOnly:S}):null,f===void 0?l.jsxs("button",{type:"button",className:v===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:v===null?r.refreshDocument:v,"aria-label":v===null?void 0:v,"aria-disabled":s,"aria-busy":o,"data-aqmx-busy":o?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:u,onDoubleClick:ne,children:[l.jsx(hn,{"aria-hidden":"true"}),v===null?l.jsx("span",{children:r.refreshDocumentLabel}):null]}):null]}),f!==void 0||a===null?null:l.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":a.reason,children:r.documentRefreshFailed(te(r,a.reason))}),f===void 0?null:l.jsx(ts,{path:e,session:f})]})},ss=({location:e})=>{const t=e.doc,n=i.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),r=vn(e);return l.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",children:[l.jsx(xn,{path:t,placement:wn,markup:r}),l.jsx(mn,{path:t,markup:e.markup,variant:n})]})},En=({holds:e,testId:t})=>{const{labels:n,announcer:r}=P(),o=i.useId();i.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=i.useCallback(()=>r.shownIn(o),[r,o]),a=i.useSyncExternalStore(r.subscribe,s,s);return l.jsx("div",{className:"aqmx-sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":t,children:a.length>1?n.announcementSequence(a):a[0]})},se=Object.freeze([]),ls=e=>{const t=new Set;let n=se,r=[],o=!1;const s=[],a=f=>{n=f;for(const v of[...t])v()},u=()=>s.at(-1)?.region,p=f=>{const v=u();f(),u()!==v&&n!==se&&a(se)},m=()=>{o=!1;const f=r.map(v=>"sentence"in v?v.sentence:v.list(v.items));r=[],a(Object.freeze(f))};return{announce:f=>{if(typeof f=="string")r.push({sentence:f});else{const v=r.find(h=>"list"in h&&h.list===f.list);v!==void 0&&"items"in v?v.items.push(f.item):r.push({list:f.list,items:[f.item]})}o||(o=!0,n!==se&&a(se),e.request(m))},subscribe:f=>(t.add(f),()=>{t.delete(f)}),claim:f=>{const v={region:f};return p(()=>s.push(v)),()=>p(()=>{const h=s.indexOf(v);h!==-1&&s.splice(h,1)})},shownIn:f=>u()===f?n:se}},ce=Object.freeze({status:"cancelled"}),is=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(N.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return N.failureOf(n,r)},as=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((m,f)=>globalThis.fetch(m,f)),o=(m,f)=>`${e}/${m}?${new URLSearchParams(f).toString()}`,s=async(m,f,v,h)=>{let S;try{S=await r(m,{credentials:"same-origin",...f,headers:{Accept:"application/json",...f.headers}})}catch{return h({reason:"failed"})}S.status===401&&t(null);const A=S.headers.get(N.EXPLORER_SCOPE_HEADER);A!==null&&t(A);let y;try{y=await S.json()}catch{return h({reason:N.failureReasonOfStatus(S.status)})}let C;try{C=v(y)}catch{C=!1}if(C)return y;const R=is(y);return h(R!==null?R:{reason:S.status===200?"failed":N.failureReasonOfStatus(S.status)})},a={[N.EXPLORER_PROOF_HEADER]:N.EXPLORER_REFRESH_PROOF},u={[N.EXPLORER_PROOF_HEADER]:N.EXPLORER_EDIT_PROOF,"Content-Type":`${N.EXPLORER_DRAFT_MEDIA_TYPE}; charset=utf-8`},p=async(m,f,v)=>{const h=await s(m,f,v,S=>N.failureDocument(S.reason,S.code));return f.signal.aborted?ce:h};return{tree:m=>s(o("tree",{[N.EXPLORER_DATA_QUERY.source]:m}),{method:"GET"},N.isExplorerTreeResult,f=>({status:"error",failure:f})),children:async(m,f,v)=>{const h=await s(o("children",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:v},N.isExplorerChildrenResult,S=>({status:"error",failure:S}));return v.aborted?ce:h},ancestors:async(m,f,v)=>{const h=await s(o("ancestors",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:v},N.isExplorerAncestorsResult,S=>({status:"error",failure:S}));return v.aborted?ce:h},reveal:async(m,f,v)=>{const h=await s(o("reveal",{[N.EXPLORER_DATA_QUERY.source]:m,[N.EXPLORER_DATA_QUERY.path]:f}),{method:"GET",signal:v},N.isExplorerRevealResult,S=>({status:"error",failure:S}));return v.aborted?ce:h},document:(m,{refresh:f})=>s(o("document",{[N.EXPLORER_DATA_QUERY.path]:m}),f?{method:"GET",headers:a}:{method:"GET"},N.isExplorerDocument,v=>N.failureDocument(v.reason,v.code)),text:async(m,f)=>{const v=await s(o("text",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerTextAnswer,h=>N.failureDocument(h.reason,h.code));return f.aborted?ce:v},edit:(m,f)=>p(o("edit",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerEditAnswer),save:(m,f,v,h)=>p(o("save",{[N.EXPLORER_DATA_QUERY.path]:m,[N.EXPLORER_DATA_QUERY.base]:f}),{method:"POST",headers:u,body:v,signal:h},N.isExplorerSaveAnswer),preview:(m,f,v)=>p(o("preview",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"POST",headers:u,body:f,signal:v},N.isExplorerPreviewAnswer),revisions:(m,f)=>p(o("revisions",{[N.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:f},N.isExplorerRevisionsAnswer),revision:(m,f,v)=>p(o("revision",{[N.EXPLORER_DATA_QUERY.path]:m,[N.EXPLORER_DATA_QUERY.revision]:f}),{method:"GET",signal:v},N.isExplorerRevisionAnswer),refresh:m=>s(o("refresh",{[N.EXPLORER_DATA_QUERY.source]:m}),{method:"POST",headers:a},N.isExplorerTreeResult,f=>({status:"error",failure:f}))}},cs=()=>{let e=null,t=null;return{settle:n=>{e=n},mayMove:n=>e!==n,move:(n,r,o)=>{e=r,t={sourceId:n,path:r,ancestors:o}},take:(n,r)=>{const o=t!==null&&t.sourceId===n&&t.path===r?t.ancestors:null;return t=null,o}}},ds=e=>{const t=J.readStorage(e);if(t===null)return I.NO_TREE_SETTING_CHANGES;try{return I.readTreeSettingChanges(JSON.parse(t))}catch(n){return console.warn(`[markdown-explorer] localStorage key ${JSON.stringify(e)} does not hold JSON; using the default tree settings.`,n),I.NO_TREE_SETTING_CHANGES}},Et=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=ds(e);n={changes:s,settings:I.applyTreeSettingChanges(t,s)}}return n},o=ae();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:a,settings:u}=r(),p=I.recordTreeSettingChange(a,s,I.advanceTreeSetting(u,s)[s],t);return n={changes:p,settings:I.applyTreeSettingChanges(t,p)},o.emit(),J.writeStorage(e,I.serializeTreeSettingChanges(p)),n.settings}}},us=Object.freeze({status:"refreshed"}),fs=Object.freeze({status:"superseded"}),ze=Object.freeze({status:"deferred"}),ms=Qt(ze),bn=4,hs=bn-1,bt=Object.freeze({status:"loading"}),gs=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),ps=e=>{const t=new Map,n=Yt(),r=new Map,o=new Map,s=new Map,a=new Map,u=ae(),p=new Set;let m=0,f=0;const v={direct:null,bulk:null},h=new Set;let S=!1,A=0;const y=()=>{A+=1,u.emit()},C=w=>o.get(w)??0,R=w=>{let b=a.get(w);return b===void 0&&(b={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(w,b)),b},M=(w,b,O)=>{w.inFlight.delete(b),m-=1,O.lane==="bulk"&&(f-=1)},c=w=>{const b=a.get(w);if(b!==void 0){for(const[O,L]of[...b.inFlight])M(b,O,L),L.controller.abort();b.direct.clear(),b.bulk.clear(),b.unclaimed.clear()}},d=w=>{const b=C(w)+1;return o.set(w,b),c(w),b},g=(w,b)=>{const O=pe(w),L={promise:w,opened:b,stale:!1,loadedAt:O?.status==="ok"?O.loadedAt:null};return w.status==="pending"&&w.then($=>{$.status==="ok"&&(L.loadedAt=$.loadedAt)}),L},x=w=>{let b=r.get(w);return b===void 0&&(b=new Map,r.set(w,b)),b},k=w=>{const b=[...a.keys()],O=v[w],L=O===null?0:b.indexOf(O)+1;for(let $=0;$<b.length;$+=1){const q=b[(L+$)%b.length],U=q===void 0?void 0:a.get(q);if(!(q===void 0||U===void 0)){for(const B of U[w])if((U.claims.get(B)??0)!==0)return U[w].delete(B),v[w]=q,{sourceId:q,path:B}}}return null},j=(w,b,O,L)=>{const $=a.get(w);if($===void 0||$.inFlight.get(b)!==O)return;M($,b,O);const q=($.claims.get(b)??0)>0,U=x(w);if(L.status==="ok"?U.set(b,{status:"loaded",entries:L.entries}):L.status==="error"&&q?U.set(b,{status:"failed",failure:L.failure}):U.delete(b),y(),L.status==="error"&&q){const B={sourceId:w,path:b,failure:L.failure};for(const ee of[...p])ee(B)}D()},T=(w,b,O)=>{const L={controller:new AbortController,lane:O};R(w).inFlight.set(b,L),m+=1,O==="bulk"&&(f+=1),e.children(w,b,L.controller.signal).then($=>j(w,b,L,$),()=>j(w,b,L,gs))},D=()=>{for(;m<bn;){const w=k("direct");if(w!==null){T(w.sourceId,w.path,"direct");continue}const b=f<hs?k("bulk"):null;if(b===null)return;T(b.sourceId,b.path,"bulk")}},F=(w,b,O)=>{if(!(b.direct.delete(O)||b.bulk.delete(O))){const $=b.inFlight.get(O);if($===void 0)return!1;M(b,O,$),$.controller.abort()}return r.get(w)?.delete(O),!0},V=()=>{S=!1;let w=!1;for(const b of h){const O=R(b);for(const L of O.unclaimed)(O.claims.get(L)??0)===0&&F(b,O,L)&&(w=!0);O.unclaimed.clear()}h.clear(),w&&(y(),D())},K=(w,b)=>{t.set(w,g(me(e.tree(w)),b))},X=(w,b,O)=>{d(w);const L=g(Qt(b),O);return t.set(w,L),r.delete(w),y(),D(),L},G=(w,b,O,L)=>{if(O!==C(w)||t.get(w)!==b)return;const $=pe(b.promise);if(!(L.status!=="ok"||$?.status!=="ok"||b.loadedAt===null||L.loadedAt<=b.loadedAt)){if(be($.entries,L.entries)){b.loadedAt=L.loadedAt;return}X(w,L,b.opened)}},_=(w,b)=>{const O=t.get(w);return O!==void 0&&pe(O.promise)?.status===b},z=(w,b)=>{b.stale=!1;const O=C(w);e.tree(w).then(L=>G(w,b,O,L))};return{read:w=>t.get(w)?.promise??ms,open:w=>{const b=n.resumes(w),O=n.hold(w),L=t.get(w);return L===void 0||_(w,"deferred")?(K(w,!0),y()):b||(L.opened&&_(w,"error")?(K(w,!0),y()):(L.opened=!0,L.stale&&_(w,"ok")&&z(w,L))),O},retry:w=>{_(w,"error")&&(K(w,!0),y())},seed:(w,b)=>{const O=b.then(q=>q===null?ze:q,()=>ze),L=t.get(w);if(L!==void 0&&_(w,"ok")){const q=C(w);O.then(U=>G(w,L,q,U));return}d(w);const $=g(me(O),L?.opened===!0);t.set(w,$),r.delete(w),D(),O.then(q=>{t.get(w)===$&&(q.status==="deferred"&&n.isHeld(w)&&K(w,$.opened),y())})},refresh:async w=>{const b=(s.get(w)??0)+1;s.set(w,b);const O=await e.refresh(w);if(s.get(w)!==b)return fs;if(O.status==="error")return{status:"failed",failure:O.failure};const L=t.get(w);if(!(L!==void 0&&L.loadedAt!==null&&_(w,"ok")&&L.loadedAt>O.loadedAt)){const q=X(w,O,!0);if(L!==void 0&&L.promise.status==="pending"){const U=C(w);L.promise.then(B=>G(w,q,U,B))}}for(const[q,U]of t)q!==w&&pe(U.promise)?.status==="ok"&&(U.stale=!0);return us},children:(w,b)=>r.get(w)?.get(b),claimChildren:(w,b)=>{const O=R(w),L=x(w);let $=!1,q=!1;for(const[B,ee]of b)O.claims.set(B,(O.claims.get(B)??0)+1),L.get(B)===void 0?(L.set(B,bt),O[ee].add(B),$=!0,q=!0):ee==="direct"&&O.bulk.delete(B)&&(O.direct.add(B),q=!0);$&&y(),q&&D();let U=!1;return()=>{if(!U){U=!0;for(const B of b.keys()){const ee=(O.claims.get(B)??0)-1;ee>0?O.claims.set(B,ee):(O.claims.delete(B),O.unclaimed.add(B))}h.add(w),!S&&(S=!0,queueMicrotask(V))}}},retryChildren:(w,b)=>{const O=r.get(w);if(O===void 0||O.get(b)?.status!=="failed")return;const L=R(w);if((L.claims.get(b)??0)>0){O.set(b,bt),L.direct.add(b),y(),D();return}O.delete(b),y()},pendingChildren:w=>{const b=a.get(w);return b===void 0?0:b.direct.size+b.bulk.size+b.inFlight.size},clear:()=>{for(const w of new Set([...t.keys(),...r.keys(),...o.keys(),...a.keys()]))d(w);for(const[w,b]of s)s.set(w,b+1);t.clear(),r.clear(),y()},subscribeChildrenFailures:w=>(p.add(w),()=>{p.delete(w)}),subscribe:u.subscribe,version:()=>A}},vs=(e,t)=>{let n=e;const r=ae();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},ws=1;let ve=0,re=null;const xs=()=>{const{documentElement:e,body:t}=document;ve===0&&(re={htmlOverflow:e.style.overflow,bodyOverflow:t.style.overflow,htmlGutter:e.style.scrollbarGutter,bodyGutter:t.style.scrollbarGutter},e.style.overflow="hidden",t.style.overflow="hidden",e.style.scrollbarGutter="auto",t.style.scrollbarGutter="auto"),ve+=1;let n=!1;return()=>{n||(n=!0,ve-=1,!(ve>0||re===null)&&(e.style.overflow=re.htmlOverflow,t.style.overflow=re.bodyOverflow,e.style.scrollbarGutter=re.htmlGutter,t.style.scrollbarGutter=re.bodyGutter,re=null))}},Es=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],yt=1,St=e=>e.getClientRects().length>0,Pe="Give the explorer's container a definite block size (for example height: 100dvh, or a flex column of definite height whose item has flex: 1 and min-height: 0; in a fresh React Router app also html and body at height: 100%) instead of an auto or only a minimum height.",bs=e=>{if(!St(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+ws)return`[markdown-explorer] the explorer ends ${String(Math.round(t.bottom))}px down a ${String(n)}px viewport while lockDocumentScroll stops the page from scrolling, so the rest cannot be reached. ${Pe}`;if(t.height<yt)return`[markdown-explorer] the explorer collapsed to ${String(Math.round(t.height))}px while lockDocumentScroll stops the page from scrolling, so nothing can be read. ${Pe}`;for(const{selector:r,name:o}of Es)for(const s of e.querySelectorAll(r)){if(!St(s))continue;const a=s.getBoundingClientRect().height;if(a<yt)return`[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(a))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${Pe}`}return null},ys=e=>{let t=!1;const n=()=>{if(t)return;const o=bs(e);o!==null&&(t=!0,console.error(o))},r=typeof ResizeObserver>"u"?null:new ResizeObserver(n);return r?.observe(e),window.addEventListener("resize",n),n(),()=>{r?.disconnect(),window.removeEventListener("resize",n)}},Ss=(e,t)=>{i.useEffect(()=>e?xs():void 0,[e]),i.useEffect(()=>{const n=t.current;if(!(!e||n===null))return ys(n)},[e,t])},kt='[data-testid="markdown-explorer-view-switch"]',ks=[{control:kt,successors:[kt,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],Rs=e=>{for(const t of ks){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},Ts=(e,t)=>{const n=i.useRef(null);i.useEffect(()=>{const o=u=>{const p=e.current;n.current=p!==null&&u instanceof Element&&p.contains(u)?Rs(u):null},s=u=>o(u.target);o(document.activeElement);const a=u=>{const p=u.target;u.relatedTarget!==null||!(p instanceof Element)||queueMicrotask(()=>{n.current?.element===p&&p.isConnected&&document.activeElement!==p&&(n.current=null)})};return document.addEventListener("focusin",s),document.addEventListener("focusout",a),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",a)}},[e]);const r=i.useRef(t);i.useLayoutEffect(()=>{if(r.current===t)return;r.current=t;const o=n.current;if(o===null)return;const s=()=>{const p=document.activeElement;if(p!==null&&p!==document.body&&p!==o.element)return!0;const m=e.current;if(m===null)return!0;for(const f of o.control.successors)for(const v of m.querySelectorAll(f))if(v!==o.element&&(v.focus({preventScroll:!0}),document.activeElement===v))return!0;return!1};if(s())return;const a=e.current;if(a===null)return;const u=new MutationObserver(()=>{s()&&u.disconnect()});return u.observe(a,{childList:!0,subtree:!0}),()=>u.disconnect()},[t,e])},Cs=i.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-DilrAILF.cjs")).then(e=>({default:e.TreeLayout}))),Os=i.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-xWd9nYaD.cjs")).then(e=>({default:e.MultiLayout}))),As=64,Ls={request:e=>{requestAnimationFrame(e)}},Rt=e=>{e.documents.clear(),e.trees.clear()},_e=(e,t)=>{t.tree!==null&&e.trees.seed(t.tree.sourceId,t.tree.result);for(const{path:n,document:r}of t.documents)e.documents.seed(n,r)},js=(e,t)=>{const[n,r]=i.useState(()=>({overrides:t,locale:e,labels:Ie(e,t)}));if(n.locale===e&&On(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:Ie(e,t)};return r(o),o.labels},Ms=(e,t,n)=>{const[r,o]=i.useState(()=>({scope:t,store:Et(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:Et(e,n)};return o(s),s.store},Fe=(e,t)=>{const[n,r]=i.useState(()=>({scope:e,value:t()}));if(n.scope===e)return n.value;const o={scope:e,value:t()};return r(o),o.value},Ns=()=>ls(Ls),Tt="on",Ds="off",Ps=(e,t)=>{const n=oe(e.peek(t));return n===null||n.document.kind==="failure"?N.lastPathSegment(t):n.document.name},_s=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:u,lockDocumentScroll:p=!1,onMathDiagnostics:m,onEditGrant:f})=>{J.assertStorageNamespace(n);const v=jt(r),h=An(s),S=js(v,o),{revalidate:A}=Y.useRevalidator(),y=i.useRef(()=>{}),C=Y.useHref(t.dataPath),[R]=i.useState(()=>{const _=as({dataPath:C,onScope:w=>y.current(w)}),z={documents:sr({client:_,capacity:Math.max(As,t.multiView.maxPanels*2)}),trees:ps(_)};return _e(z,e),J.syncStorageScope(n,e.scope),{data:_,...z,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(R.aligned.pageData!==e||R.aligned.storageNamespace!==n){const _=R.aligned.pageData;R.aligned.pageData=e,R.aligned.storageNamespace=n,_!==e&&(_.scope!==e.scope?R.aligned.pendingReader=e:_e(R,e)),J.syncStorageScope(n,e.scope)}const M=Ms(J.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);i.useLayoutEffect(()=>{const _=R.aligned.pendingReader;_!==null&&(R.aligned.pendingReader=null,Rt(R),_e(R,_))},[e,R]),i.useLayoutEffect(()=>{let _=!1;return y.current=z=>{z===e.scope||_||(_=!0,z!==null&&(Rt(R),J.clearExplorerStorage(n)),A())},()=>{y.current=()=>{}}},[e,A,R,n]);const c=i.useRef(t.settingsCookie);i.useLayoutEffect(()=>{c.current=t.settingsCookie},[t.settingsCookie]);const[d]=i.useState(()=>vs(e.settings,_=>{document.cookie=I.viewSettingsCookieString(c.current,_,window.location.protocol==="https:")})),g=Fe(e.scope,Ns),x=Fe(e.scope,cs),k=i.useRef(S);i.useLayoutEffect(()=>{k.current=S},[S]);const j=Fe(e.scope,()=>Dn({data:R.data,conflictLabels:()=>({ours:k.current.conflictOurs,theirs:k.current.conflictTheirs}),onSaveSettled:(_,z)=>{z.kind==="saved"&&R.documents.refresh(_);const w=jn(k.current,z,Ps(R.documents,_));w!==null&&g.announce(w)},previewSetting:{read:()=>J.readStorage(J.storageKeys(n).editPreview)===Tt,write:_=>J.writeStorage(J.storageKeys(n).editPreview,_?Tt:Ds)}})),T=i.useMemo(()=>me(e.notices.catch(()=>[])),[e.notices]),D=e.sources.map(_=>_.id).join(`
12
+ `),F=i.useMemo(()=>I.withExplorerSources(t,D.split(`
13
+ `)),[t,D]),V=i.useRef(m);i.useLayoutEffect(()=>{V.current=m},[m]);const[K]=i.useState(()=>(_,z)=>{V.current?.(_,z)}),X=m===void 0?void 0:K,G=i.useMemo(()=>({config:F,labels:S,locale:v,theme:h,storageNamespace:n,scope:e.scope,sources:e.sources,notices:T,documents:R.documents,trees:R.trees,data:R.data,viewSettings:d,treeSettings:M,announcer:g,reveals:x,edits:j,onEditGrant:f,renderTreeFailure:u,reportMathDiagnostics:X}),[F,S,v,h,n,e.scope,e.sources,T,R,d,M,g,x,j,f,u,X]);return l.jsx(Mt,{value:G,children:l.jsx($s,{renderFrame:a,lockDocumentScroll:p},e.scope)})},Fs=({ref:e,theme:t,view:n,children:r})=>{const[o]=i.useState(Ur);return l.jsx("div",{ref:e,className:"aqmx-root","data-aqmx-theme":t,"data-aqmx-view":n,"data-testid":"markdown-explorer",onKeyDownCapture:o.onKeyDownCapture,onKeyUpCapture:o.onKeyUpCapture,onBlurCapture:o.onBlurCapture,children:r})},$s=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=P(),o=Se(),{hash:s}=Y.useLocation(),a=he(),u=i.useRef(null);Ss(t,u),i.useLayoutEffect(()=>{o.kind==="redirect"&&a(`${o.href}${s}`,"browse")},[o,s,a]);const{location:p}=o,m=p.view;Ts(u,m);const f=p.view==="tree"?l.jsx(i.Suspense,{fallback:l.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading"}),children:l.jsx(Cs,{location:p})}):p.view==="multi"?l.jsx(i.Suspense,{fallback:l.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading"}),children:l.jsx(Os,{location:p})}):l.jsx(ss,{location:p}),v=l.jsxs(Fs,{ref:u,theme:n,view:m,children:[f,l.jsx(qn,{}),l.jsx(En,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?v:e({view:m,children:v})},qs=({currentUrl:e,nextUrl:t,formMethod:n,defaultShouldRevalidate:r})=>n===void 0&&e.href===t.href&&r;exports.ALLOW_KEY_REPEAT=ye;exports.CONFLICT_OURS_MARKER=Dt;exports.CONFLICT_SEPARATOR=Pt;exports.CONFLICT_THEIRS_MARKER=_t;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=Ct;exports.DocumentPane=mn;exports.DocumentRefreshBar=xn;exports.EXPLORER_THEMES=Be;exports.EditGrantNotice=pn;exports.ExplorerLink=Gt;exports.FailureView=le;exports.ForwardRef=hn;exports.ForwardRef$1=gn;exports.ImageViewMemoryContext=rn;exports.LazyNativeScrollBar=Wt;exports.LiveRegion=En;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=Lt;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Ze;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=Ot;exports.MARKDOWN_EXPLORER_LOCALES=qe;exports.MarkdownExplorer=_s;exports.PAGE_DOCUMENT_REFRESH=wn;exports.blockAtLine=Zt;exports.consumeKey=Ve;exports.createEmitter=ae;exports.explorerNavigationOptions=tr;exports.failureTitleOf=te;exports.findConflictsInLines=Ft;exports.focusWithoutScroll=We;exports.frameTopOf=Ut;exports.lineTopIn=Vt;exports.positionInSource=Jn;exports.resolveMarkdownExplorerLabels=Ie;exports.shouldRevalidateExplorer=qs;exports.useExplorer=P;exports.useExplorerLocation=Se;exports.useExplorerNavigate=he;exports.useIntentPrefetch=Kt;exports.usePageMarkupToggle=vn;exports.usePreviewShown=Bt;exports.useViewSetting=ue;exports.visibleTopOf=zt;