@aiquants/markdown-explorer 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +515 -0
- package/README.md +90 -39
- package/dist/EditSurface-CLG70Vnn.cjs +6 -0
- package/dist/EditSurface-D2j1kCEE.js +990 -0
- package/dist/ExplorerSplit-CfP1smbT.js +1589 -0
- package/dist/ExplorerSplit-D_0VohOv.cjs +2 -0
- package/dist/{MultiLayout-kcZyVnvK.js → MultiLayout-BeJ5Lubb.js} +249 -248
- package/dist/MultiLayout-CxV5SI7f.cjs +1 -0
- package/dist/{NativeScrollBar-UNed10Na.js → NativeScrollBar-BM5NULzg.js} +2 -2
- package/dist/{NativeScrollBar-pUbA4Zq3.cjs → NativeScrollBar-RWXpVhbI.cjs} +1 -1
- package/dist/TreeLayout-AxLw-36S.js +103 -0
- package/dist/TreeLayout-Bg2YH-EY.cjs +1 -0
- package/dist/client/MarkdownExplorer.d.cts +14 -1
- package/dist/client/MarkdownExplorer.d.ts +14 -1
- package/dist/client/edit/lineEndings.d.cts +4 -0
- package/dist/client/edit/lineEndings.d.ts +4 -0
- package/dist/client/hostContract.d.cts +67 -0
- package/dist/client/hostContract.d.ts +67 -0
- package/dist/core/config.d.cts +7 -0
- package/dist/core/config.d.ts +7 -0
- package/dist/core/contracts.d.cts +10 -4
- package/dist/core/contracts.d.ts +10 -4
- package/dist/core/draftAnswer.d.cts +23 -0
- package/dist/core/draftAnswer.d.ts +23 -0
- package/dist/core/labels.d.cts +68 -0
- package/dist/core/labels.d.ts +68 -0
- package/dist/core/location.d.cts +1 -2
- package/dist/core/location.d.ts +1 -2
- package/dist/core/ownUrls.d.cts +15 -0
- package/dist/core/ownUrls.d.ts +15 -0
- package/dist/core/treeSettings.d.cts +3 -2
- package/dist/core/treeSettings.d.ts +3 -2
- package/dist/core/viewSettings.d.cts +3 -1
- package/dist/core/viewSettings.d.ts +3 -1
- package/dist/describeValue-CLlVRO8d.js +17 -0
- package/dist/describeValue-Ccvhbt36.cjs +1 -0
- package/dist/explorerCore-DLpDuSev.js +998 -0
- package/dist/explorerCore-DYrxS9ez.cjs +1 -0
- package/dist/index-C1YMH-yI.js +5816 -0
- package/dist/index-LQWQfpAf.cjs +18 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +49 -44
- package/dist/licenses/@heroicons/react/LICENSE +21 -0
- package/dist/licenses/entities/LICENSE +11 -0
- package/dist/licenses/parse5/LICENSE +19 -0
- package/dist/location--KvTA0Ri.js +726 -0
- package/dist/location-D8DyDkuA.cjs +1 -0
- package/dist/lru-DC8GBmkX.js +39 -0
- package/dist/lru-SGmUyBQU.cjs +1 -0
- package/dist/{merge-C1MWvhCS.js → merge-Bb_HpPhe.js} +1 -1
- package/dist/{merge-BziXxZkE.cjs → merge-DQUYEGCx.cjs} +1 -1
- package/dist/nestingGuardWorker.js +5511 -0
- package/dist/ownUrls-B259RGgd.cjs +1 -0
- package/dist/ownUrls-Dh5g6ZJi.js +370 -0
- package/dist/sanitizeJob-BYRk17nr.js +21 -0
- package/dist/sanitizeJob-Cs9o3Vpl.cjs +1 -0
- package/dist/sanitizePolicy-CEMdaLUB.js +139 -0
- package/dist/sanitizePolicy-CiQfnxyd.cjs +2 -0
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +134 -139
- package/dist/sanitizerService-BY4CPCoA.cjs +1 -0
- package/dist/sanitizerService-KWXv7bPm.js +240 -0
- package/dist/server/assetResponse.d.cts +60 -0
- package/dist/server/assetResponse.d.ts +60 -0
- package/dist/server/browser/browserPlatform.d.cts +12 -0
- package/dist/server/browser/browserPlatform.d.ts +12 -0
- package/dist/server/createMarkdownExplorer.d.cts +0 -10
- package/dist/server/createMarkdownExplorer.d.ts +0 -10
- package/dist/server/explorerCore.d.cts +12 -0
- package/dist/server/explorerCore.d.ts +12 -0
- package/dist/server/fileSystemSource.d.cts +1 -0
- package/dist/server/fileSystemSource.d.ts +1 -0
- package/dist/server/inProcessFetch.d.cts +5 -0
- package/dist/server/inProcessFetch.d.ts +5 -0
- package/dist/server/platform.d.cts +18 -0
- package/dist/server/platform.d.ts +18 -0
- package/dist/server/ports.d.cts +36 -5
- package/dist/server/ports.d.ts +36 -5
- package/dist/server/sanitizeProtocol.d.cts +3 -0
- package/dist/server/sanitizeProtocol.d.ts +3 -0
- package/dist/server/sanitizer.d.cts +5 -40
- package/dist/server/sanitizer.d.ts +5 -40
- package/dist/server/sanitizerOptions.d.cts +24 -0
- package/dist/server/sanitizerOptions.d.ts +24 -0
- package/dist/server/sanitizerService.d.cts +41 -0
- package/dist/server/sanitizerService.d.ts +41 -0
- package/dist/server/{workerPool.d.cts → workerJobs.d.cts} +0 -16
- package/dist/server/{workerPool.d.ts → workerJobs.d.ts} +0 -16
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +3 -1
- package/dist/server.d.ts +3 -1
- package/dist/server.js +270 -1343
- package/dist/serverBrowser.cjs +1 -0
- package/dist/serverBrowser.d.cts +1 -0
- package/dist/serverBrowser.d.ts +1 -0
- package/dist/serverBrowser.js +120 -0
- package/dist/serverCore.cjs +1 -0
- package/dist/serverCore.d.cts +14 -0
- package/dist/serverCore.d.ts +14 -0
- package/dist/serverCore.js +46 -0
- package/dist/storage-BpYsprog.cjs +1 -0
- package/dist/{storage-CmGHg7OA.js → storage-D1uSw-xj.js} +19 -18
- package/dist/storage.cjs +1 -1
- package/dist/storage.js +1 -1
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/{tapScrollCircle-D_BpaLwY.js → tapScrollCircle-BEydRn0y.js} +1 -1
- package/dist/{tapScrollCircle-DigcJCsu.cjs → tapScrollCircle-DdX0Wri0.cjs} +1 -1
- package/dist/testing.cjs +1 -0
- package/dist/testing.d.cts +6 -0
- package/dist/testing.d.ts +6 -0
- package/dist/testing.js +4 -0
- package/dist/useSplitPersistence-B2Fj508K.cjs +1 -0
- package/dist/useSplitPersistence-Fkqak8G8.js +44 -0
- package/docs/behavior/dom-hooks.md +2 -0
- package/docs/behavior/hosting.md +123 -0
- package/docs/behavior/layout.md +5 -3
- package/docs/behavior/localization.md +25 -8
- package/docs/behavior/security.md +32 -13
- package/docs/behavior/url-contract.md +4 -3
- package/package.json +48 -10
- package/dist/EditSurface-CF82jZQg.cjs +0 -6
- package/dist/EditSurface-CqHk2R3k.js +0 -982
- package/dist/ExplorerSplit-D325YGEf.cjs +0 -1
- package/dist/ExplorerSplit-DGH9bckm.js +0 -1500
- package/dist/MultiLayout-CzR7yJ0m.cjs +0 -1
- package/dist/TreeLayout-BnIU87HX.js +0 -96
- package/dist/TreeLayout-DtvIpuOe.cjs +0 -1
- package/dist/dataRoute-D6KiSHIc.js +0 -298
- package/dist/dataRoute-DwYtgyt6.cjs +0 -1
- package/dist/index-BDCbvHDs.cjs +0 -15
- package/dist/index-DR31S_-4.js +0 -5012
- package/dist/location-C44b9H1S.js +0 -676
- package/dist/location-hGLhCCg4.cjs +0 -1
- package/dist/sanitizePolicy-CwvyPpp5.js +0 -98
- package/dist/sanitizePolicy-T5T-3vV5.cjs +0 -1
- package/dist/storage-DM0EvkVf.cjs +0 -1
- package/dist/useSplitPersistence-DCeYbJMx.js +0 -38
- package/dist/useSplitPersistence-QGcvyMAa.cjs +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! Bundled third-party code: @heroicons/react 2.2.0 (MIT, ./licenses/@heroicons/react/LICENSE) */
|
|
2
|
+
"use strict";const c=require("react/jsx-runtime"),v=require("./index-LQWQfpAf.cjs"),r=require("react"),q=require("./location-D8DyDkuA.cjs"),Te=require("react-router"),We=require("./ownUrls-B259RGgd.cjs"),nt=require("@aiquants/directory-tree"),rt=require("./tapScrollCircle-DdX0Wri0.cjs"),Mt=require("./storage-BpYsprog.cjs"),lt=require("./describeValue-Ccvhbt36.cjs"),ke=require("@aiquants/resize-panels"),Xe=require("./useSplitPersistence-B2Fj508K.cjs");function Ft(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const l=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,l.get?l:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const m=Ft(r);function _t({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15ZM9 12.75a.75.75 0 0 0 0 1.5h6a.75.75 0 0 0 0-1.5H9Z",clipRule:"evenodd"}))}const It=m.forwardRef(_t);function Dt({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M19.5 21a3 3 0 0 0 3-3V9a3 3 0 0 0-3-3h-5.379a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H4.5a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h15Zm-6.75-10.5a.75.75 0 0 0-1.5 0v2.25H9a.75.75 0 0 0 0 1.5h2.25v2.25a.75.75 0 0 0 1.5 0v-2.25H15a.75.75 0 0 0 0-1.5h-2.25V10.5Z",clipRule:"evenodd"}))}const Ht=m.forwardRef(Dt);function Bt({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M16.5 6a3 3 0 0 0-3-3H6a3 3 0 0 0-3 3v7.5a3 3 0 0 0 3 3v-6A4.5 4.5 0 0 1 10.5 6h6Z"}),m.createElement("path",{d:"M18 7.5a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-7.5a3 3 0 0 1-3-3v-7.5a3 3 0 0 1 3-3H18Z"}))}const Zt=m.forwardRef(Bt);function $t({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M3 6a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V6Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3v2.25a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3V6ZM3 15.75a3 3 0 0 1 3-3h2.25a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3v-2.25Zm9.75 0a3 3 0 0 1 3-3H18a3 3 0 0 1 3 3V18a3 3 0 0 1-3 3h-2.25a3 3 0 0 1-3-3v-2.25Z",clipRule:"evenodd"}))}const zt=m.forwardRef($t),Vt="http://path.invalid",Kt=/[\t\n\r]/gu,Ut=(e,t,n,l)=>{const o=e.replace(Kt,"");if(!o.startsWith("/")||o.startsWith("//")||o.includes("\\"))return null;const{pathname:i,search:a,hash:s}=new URL(o,Vt);return!We.isUnder(i,[t])||We.isUnder(i,[n])?null:`${l}${i.slice(t.length)}${a}${s}`},Wt=()=>{const{notices:e,config:t}=v.useExplorer(),n=r.use(e),l=Te.useHref(t.basePath),o=Te.useHref(t.dataPath);return n.length===0?null:c.jsx("div",{className:"aqmx-explorer-notices",children:n.map(i=>{const a=i.action===void 0?null:Ut(i.action.href,l,o,t.basePath);return c.jsxs("div",{className:"aqmx-callout","data-aqmx-tone":i.tone,"data-testid":"markdown-explorer-notice","data-aqmx-notice":i.id,children:[c.jsx("p",{className:"aqmx-callout-title",children:i.title}),i.body===void 0?null:c.jsx("p",{className:"aqmx-callout-body",children:i.body}),i.action===void 0?null:a===null?c.jsx("a",{className:"aqmx-callout-action",href:i.action.href,children:i.action.label}):c.jsx(v.ExplorerLink,{className:"aqmx-callout-action",to:a,navigation:"follow-link",children:i.action.label})]},i.id)})})};function Xt({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M6.912 3a3 3 0 0 0-2.868 2.118l-2.411 7.838a3 3 0 0 0-.133.882V18a3 3 0 0 0 3 3h15a3 3 0 0 0 3-3v-4.162c0-.299-.045-.596-.133-.882l-2.412-7.838A3 3 0 0 0 17.088 3H6.912Zm13.823 9.75-2.213-7.191A1.5 1.5 0 0 0 17.088 4.5H6.912a1.5 1.5 0 0 0-1.434 1.059L3.265 12.75H6.11a3 3 0 0 1 2.684 1.658l.256.513a1.5 1.5 0 0 0 1.342.829h3.218a1.5 1.5 0 0 0 1.342-.83l.256-.512a3 3 0 0 1 2.684-1.658h2.844Z",clipRule:"evenodd"}))}const Gt=m.forwardRef(Xt),Me=r.createContext(!0),at=r.createContext(null),ot="\0loop\0",st="\0",Yt=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,l=a=>{const s=e.get(a);if(s!==void 0)return s;const p=Object.freeze({type:"loop",name:a.name,path:a.path});return e.set(a,p),p},o=(a,s,p)=>{let f=!1;const u=a.map(h=>{const w=i(h,s,p);return w!==h&&(f=!0),w});if(!f)return a;const d=n.get(a);return d!==void 0&&d.length===u.length&&d.every((h,w)=>h===u[w])?d:(n.set(a,u),u)},i=(a,s,p)=>{if(a.type!=="directory")return a;if(p.has(a.path))return l(a);const f=a.lazy===!0?s(a.path):void 0,u=f?.status==="loaded",d=u?f.entries:a.children;if(d===void 0)return a;p.add(a.path);const h=o(d,s,p);if(p.delete(a.path),!u&&h===a.children)return a;const w=t.get(a);if(w!==void 0&&w.state===f&&w.children===h)return w.grafted;const g={...a,children:h,lazy:u?!1:a.lazy};return t.set(a,{state:f,children:h,grafted:g}),g};return(a,s)=>o(a,s,new Set)},Qt=(e,t)=>`${ot}${e}${st}${t}`,pe=e=>e.startsWith(ot),Jt=e=>e.slice(e.lastIndexOf(st)+1),ne="data-aqmx-path",en=(e,t,n,l,o)=>{const i={aqmxPath:e.path};return e.modifiedAt!==void 0&&(i.aqmxModifiedAt=e.modifiedAt),n&&(i.aqmxOpen=!0),(l==="loading"||l==="failed")&&(i.aqmxChildren=l),{name:e.name,type:e.type,absolutePath:e.path,relativePath:e.path,mimeType:e.mimeType,children:t,label:o,data:i}},tn=(e,t,n,l)=>{const o=Qt(t,e.path);return{name:n,type:"directory",absolutePath:o,relativePath:o,children:l,data:{aqmxLoop:e.path}}},nn=()=>{const e=new WeakMap,t=new WeakMap,n=new WeakMap,l=[],o=(s,p,f)=>{const u=s.map(h=>h.type==="loop"?i(h,p,f):a(h,p)),d=n.get(s);return d!==void 0&&d.length===u.length&&d.every((h,w)=>h===u[w])?d:(n.set(s,u),u)},i=(s,p,f)=>{const u=t.get(s);if(u!==void 0&&u.parentKey===f&&u.loopFolderName===p.loopFolderName)return u.row;const d=tn(s,f,p.loopFolderName(s.name),l);return t.set(s,{row:d,parentKey:f,loopFolderName:p.loopFolderName}),d},a=(s,p)=>{const f=s.type==="directory"?s.children===void 0?l:o(s.children,p,s.path):void 0,u=p.openPaths.has(s.path),d=s.type==="directory"&&s.lazy===!0?p.childrenOf(s.path)?.status:void 0,h=d==="failed"?p.renderFailedFolder:void 0,w=e.get(s);if(w!==void 0&&w.open===u&&w.childrenStatus===d&&w.children===f&&w.renderFailedFolder===h)return w.row;const g=en(s,f,u,d,h===void 0?void 0:h(s));return e.set(s,{row:g,open:u,childrenStatus:d,children:f,renderFailedFolder:h}),g};return(s,p)=>o(s,p,"")},rn=e=>{if(e===void 0)return;const t=n=>{const l=n.data?.aqmxModifiedAt;return typeof l=="number"?{name:n.name,path:n.absolutePath,type:n.type,modifiedAt:l}:{name:n.name,path:n.absolutePath,type:n.type}};return(n,l)=>e(t(n),t(l))},Pe=(e,t)=>{const n=e.filter(l=>l.type==="directory");return t===void 0?n:n.sort(t)},ln=(e,t)=>{const n=new Map;let l=0;const o=i=>{for(const a of Pe(i,t.compare))if(t.isShownExpanded(a.path)){if(a.lazy!==!0){a.children!==void 0&&o(a.children);continue}n.has(a.path)||(n.set(a.path,t.isDirect(a.path)?"direct":"bulk"),t.childrenOf(a.path)?.status!=="failed"&&(l+=1))}};return o(e),{folders:n,waiting:l}},an=e=>{const t=new Set,n=l=>{for(const o of l)o.type==="directory"&&(o.lazy===!0&&t.add(o.path),o.children!==void 0&&n(o.children))};return n(e),t},ct=(e,t)=>{for(const n of e){if(n.type!=="directory")continue;if(n.path===t)return n;const l=n.children===void 0?null:ct(n.children,t);if(l!==null)return l}return null},it=(e,t,n)=>{for(const l of e){if(l===t)return{parent:n};const o=l.children===void 0?null:it(l.children,t,l);if(o!==null)return o}return null},on=(e,t,n)=>{const l=it(e,n,null);if(l===null)throw new Error(`[markdown-explorer] the pressed folder's row is not among the tree's rows: ${lt.describeValue(n.absolutePath)}`);if(l.parent!==null)return{kind:"folder",path:l.parent.absolutePath};const o=q.folderReadmeOf(t.filter(i=>i.type!=="loop"));return o===null?{kind:"nothing"}:{kind:"document",path:o}},sn=(e,t,n,l)=>{let o=e;for(const i of t){const a=o.find(s=>s.type==="directory"&&s.path===i);if(a===void 0)return"missing";if(a.lazy===!0)return l.childrenOf(a.path)?.status==="failed"?"failed":"loading";if(!l.isShownExpanded(a.path))return"loading";o=a.children??[]}return o.some(i=>i.type==="file"&&i.path===n)?"ready":"missing"},Ge=new Set,cn=(e,t)=>e.has(t)?e:new Set(e).add(t),un=(e,t)=>{if(!t.some(l=>e.has(l)))return e;const n=new Set(t);return new Set([...e].filter(l=>!n.has(l)))},dn=(e,t)=>[...e].every(n=>t.has(n))?e:new Set([...e].filter(n=>t.has(n))),fn=()=>{const[e,t]=r.useState(Ge),n=r.useCallback(a=>t(s=>cn(s,a)),[]),l=r.useCallback(a=>t(s=>un(s,a)),[]),o=r.useCallback(a=>t(s=>dn(s,a)),[]),i=r.useCallback(()=>t(Ge),[]);return r.useMemo(()=>({direct:e,markDirect:n,unmarkDirect:l,pruneDirect:o,clearDirect:i}),[e,n,l,o,i])},pn=e=>({budget:e,handled:new Set,loads:new Set,opened:0,folderLimited:!1,depthLimited:!1,announcedStart:!1,issuedAgainst:null}),mn=(e,t)=>{const n=[];let l=Pe(t.entries,t.compare);for(let o=1;l.length>0;o+=1){const i=[];for(const a of l){const{path:s}=a;if(t.isShownExpanded(s))e.handled.add(s);else{if(e.handled.has(s))continue;if(e.handled.add(s),a.lazy===!0&&t.childrenOf(s)===void 0){if(o>e.budget.maxDepth){e.depthLimited=!0;continue}if(e.loads.size>=e.budget.maxFolders){e.folderLimited=!0;continue}e.loads.add(s)}n.push(s),e.opened+=1}a.lazy!==!0&&a.children!==void 0&&i.push(...Pe(a.children,t.compare))}l=i}return n},ut=(e,t)=>e.every(n=>n.type!=="directory"||t(n.path)&&(n.lazy===!0||n.children===void 0||ut(n.children,t))),hn=(e,t)=>{if(e.folderLimited)return{kind:"folder-limit",opened:e.opened};if(e.depthLimited)return{kind:"depth-limit",opened:e.opened};let n=0;for(const l of e.loads)t.childrenOf(l)?.status==="failed"&&(n+=1);return{kind:"done",opened:e.opened,failed:n,complete:ut(t.entries,t.isShownExpanded)}},Ae=Object.freeze({state:"idle"}),xn=e=>{const t=r.useRef(null),n=r.useRef(e),[l,o]=r.useState(Ae);r.useLayoutEffect(()=>{n.current=e});const i=r.useCallback(()=>{t.current===null&&(t.current=pn(n.current.budget),o({state:"running",opened:0}))},[]),a=r.useCallback(()=>{t.current=null,o(Ae)},[]),s=r.useCallback(p=>{const f=t.current;if(f===null)return;const u=mn(f,p);if(u.length>0&&(f.issuedAgainst=p.expanded,n.current.expandMultiple([...u])),!f.announcedStart&&(f.loads.size>0||p.waiting>0)&&(f.announcedStart=!0,n.current.onStart()),u.length===0&&!p.expansionPending&&p.expanded!==f.issuedAgainst&&p.waiting===0){t.current=null;const h=hn(f,p);o(h.kind==="done"?Ae:{state:"stopped",stop:h.kind,opened:h.opened}),n.current.onFinish(h);return}const{opened:d}=f;o(h=>h.state==="running"&&h.opened===d?h:{state:"running",opened:d})},[]);return r.useMemo(()=>({status:l,start:i,end:a,advance:s}),[l,i,a,s])},Ye=["pointerdown","wheel","touchstart","keydown","focusin"],wn=8,Qe={least:Number.POSITIVE_INFINITY,stalled:0},gn=({tree:e,container:t,path:n,chain:l,rows:o,cancel:i,displayed:a,placement:s})=>{const p=r.useRef(null),f=r.useRef(!0),u=r.useRef(Qe),d=r.useRef(null),h=r.useRef(null),w=r.useRef(l),g=r.useRef(s);r.useLayoutEffect(()=>{w.current=l,g.current=s},[l,s]);const E=r.useCallback(()=>{const T=d.current;T!==null&&(d.current=null,T.phase==="asking"?T.controller.abort():w.current?.open(null))},[]),y=r.useCallback(()=>{p.current=null,E()},[E]),L=r.useCallback(()=>{const T=t.current;p.current===null||h.current!==null||T===null||T.getClientRects().length===0||(h.current=requestAnimationFrame(()=>{h.current=null;const C=p.current;if(C===null)return;const P=g.current(C);if(P===0){f.current=!0,d.current?.phase==="opening"&&E();return}if(e.current?.scrollToPath(C,{align:"nearest"})===!0){d.current?.phase==="opening"&&E();const{least:R,stalled:k}=u.current;u.current=P<R?{least:P,stalled:0}:{least:R,stalled:k+1},u.current.stalled<wn&&L();return}const O=d.current;if(O===null){p.current=null;return}O.phase==="opening"&&w.current?.progress(O.folders,C)!=="loading"&&y()}))},[e,t,E,y]),j=r.useCallback(()=>{f.current=!1,u.current=Qe,L()},[L]);r.useEffect(()=>{const T=t.current;if(T===null)return;const C=typeof ResizeObserver>"u"?null:new ResizeObserver(j);C?.observe(T);for(const P of Ye)T.addEventListener(P,y,{passive:!0});return()=>{C?.disconnect();for(const P of Ye)T.removeEventListener(P,y);h.current!==null&&cancelAnimationFrame(h.current),h.current=null,E()}},[t,j,y,E]);const S=l!==null;r.useEffect(()=>{const T=t.current;if(y(),n===null||T===null||T.contains(T.ownerDocument.activeElement))return;p.current=n;const C=w.current;if(S&&C!==null){const P=new AbortController,O={phase:"asking",controller:P};d.current=O,C.ancestors(n,P.signal).then(R=>{d.current===O&&(R===null?d.current=null:(d.current={phase:"opening",folders:R},w.current?.open(R)),j())})}j()},[n,S,t,y,j]),r.useEffect(()=>{(d.current?.phase==="opening"||p.current!==null&&!f.current)&&j()},[o,j]);const I=r.useRef(i);r.useEffect(()=>{I.current!==i&&(I.current=i,y())},[i,y]);const M=r.useRef(a);r.useEffect(()=>{M.current&&!a&&E(),M.current=a},[a,E])},bn="--aqmx-tree-line",En=Object.freeze(["(forced-colors: active)","(prefers-color-scheme: dark)"]),vn="data-aqmx-tree-probe",Rn=Object.freeze({rowHeight:q.CONTROL_BLOCK_PIXELS,lineColor:null}),Sn=(e,t,n)=>{const[l,o]=r.useState(Rn);return r.useLayoutEffect(()=>{const i=e.current;if(i===null)return;const a=()=>{const f=Math.round(i.getBoundingClientRect().height),u=getComputedStyle(i),d=u.getPropertyValue(bn).trim()===""?null:u.color;o(h=>{const w=Number.isFinite(f)&&f>0?f:h.rowHeight;return h.rowHeight===w&&h.lineColor===d?h:{rowHeight:w,lineColor:d}})};a();const s=En.map(f=>window.matchMedia(f));for(const f of s)f.addEventListener("change",a);const p=typeof ResizeObserver>"u"?null:new ResizeObserver(a);return p?.observe(i),()=>{for(const f of s)f.removeEventListener("change",a);p?.disconnect()}},[e,t,n]),l},dt="markdown-explorer-tree-scroll",yn=.5,ft=(e,t)=>[...e.querySelectorAll(`[role="treeitem"][${ne}]`)].find(n=>n.getAttribute(ne)===t),kn=(e,t)=>{const n=ft(e,t),l=n?.closest(`[data-testid="${dt}"]`);if(n===void 0||l===null||l===void 0)return Number.POSITIVE_INFINITY;const o=l.getBoundingClientRect(),i=n.getBoundingClientRect(),a=o.top-i.top,s=i.height>o.height?Math.abs(a):Math.max(0,a)+Math.max(0,i.bottom-o.bottom);return s<=yn?0:s},qe=Object.freeze({testId:dt,overscanCount:13,callbackThrottleMs:13,scrollBarOptions:Object.freeze({width:8,...v.SCROLL_BAR_CONTROLS,enableArrowButtons:!0,enableArrowButtonTabStops:!1,enableScrollToTopBottomButtons:!0,tapScrollCircleOptions:rt.TAP_SCROLL_CIRCLE}),behaviorOptions:Object.freeze({enablePointerDrag:!0})}),Cn=Object.freeze({...qe,scrollBarOptions:Object.freeze({...qe.scrollBarOptions,...v.TOUCH_SCROLL_BAR_CONTROLS,tapScrollCircleOptions:rt.TOUCH_TAP_SCROLL_CIRCLE})}),Tn=e=>e?Cn:qe,Ln={hoverClassName:"",directorySelectedClassName:"",itemSelectedClassName:""},jn={color:"inherit",fontSize:"inherit"},On={fontSize:"inherit"},Nn=new Set,An=new Map,Pn={color:"var(--aqmx-tree-line)"},pt=e=>e instanceof Element?e.closest(`[${ne}]`):null,qn=e=>{const t=pt(e);return t===null||t.getAttribute("data-entry-type")!=="file"?null:t.getAttribute(ne)},mt=(e,t,n,l)=>n==="folder-limit"?e.expandAllFolderLimit(l,t.maxFolders,e.expandAll):e.expandAllDepthLimit(l,t.maxDepth),Mn=(e,t,n)=>n.kind==="done"?e.expandAllDone(n.opened,n.failed,n.complete):mt(e,t,n.kind,n.opened),ht=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-explorer-loading","aria-busy":"true","data-testid":"markdown-explorer-tree-loading",children:[c.jsx("p",{className:"aqmx-explorer-loading-text",children:e.treeLoading}),c.jsxs("div",{className:"aqmx-skeleton","aria-hidden":"true",children:[c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{}),c.jsx("span",{})]})]})},Fn=()=>{const{labels:e}=v.useExplorer();return c.jsxs("div",{className:"aqmx-empty","data-testid":"markdown-explorer-tree-empty",children:[c.jsx(Gt,{className:"aqmx-explorer-empty-icon","aria-hidden":"true"}),c.jsx("p",{className:"aqmx-empty-title",children:e.treeEmptyTitle}),c.jsx("p",{className:"aqmx-explorer-empty-body",children:e.treeEmptyBody})]})},_n=({name:e,onRetry:t})=>{const{labels:n}=v.useExplorer(),l=r.useId();return c.jsxs("span",{className:"aqmx-explorer-folder-failed",children:[c.jsx("span",{className:"aqmx-explorer-folder-name",children:e}),c.jsx("span",{id:l,className:"aqmx-explorer-folder-error",children:n.folderLoadFailed}),c.jsxs("button",{type:"button",className:"aqmx-explorer-folder-retry","aria-describedby":l,"data-testid":"markdown-explorer-folder-retry",onClick:o=>{o.stopPropagation();const i=o.currentTarget,a=i.ownerDocument.activeElement===i?i.closest('[role="treeitem"]'):null;a instanceof HTMLElement&&v.focusWithoutScroll(a),t()},onKeyDown:o=>{o.key!=="Escape"&&o.stopPropagation()},children:[c.jsx(v.ForwardRef,{className:"aqmx-explorer-folder-retry-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-folder-retry-text",children:n.retry})]})]})},In=({entries:e,version:t,mode:n,sourceId:l,settings:o,reveal:i,openPaths:a,selection:s,onOpenDocument:p,folders:f,onRevealSource:u,expansion:d,onShown:h,marks:w,claimsHeld:g,expandAll:E,revealCancel:y})=>{const{trees:L,documents:j,labels:S,locale:I,theme:M,paletteKey:T,data:C,config:P,sources:O,reveals:R}=v.useExplorer(),k=r.use(Me),F=r.use(at),[D]=r.useState(()=>F?.get(l)),$=Tn(v.useCoarsePointer()),le=r.useMemo(()=>D===void 0?$:{...$,initialScrollAnchor:D},[$,D]),[ae]=r.useState(nn),G=r.useRef(null),{rowHeight:oe,lineColor:Y}=Sn(G,M,T),{isExpanded:K,toggle:H,expandMultiple:_,collapseMultiple:we,expanded:Q,isPending:se}=d,{alwaysExpanded:re,sortMode:me,folderPlacement:ce,readmePlacement:ge}=o,{direct:he,markDirect:U,unmarkDirect:ie,pruneDirect:be}=w,{running:ue,advance:N}=E,V=r.useRef(null),W=r.useRef(null);r.useLayoutEffect(()=>{if(F===null)return;const x=V;return()=>{const b=x.current===null?null:x.current.getScrollAnchor();b===null?F.delete(l):F.set(l,b)}},[F,l]);const de=r.useMemo(()=>q.createEntryComparator({sortMode:me,folderPlacement:ce,readmePlacement:ge}),[me,ce,ge]),Rt=r.useMemo(()=>rn(de),[de]),X=r.useCallback(x=>L.children(l,x),[L,l]),J=r.useMemo(()=>an(e),[e]),xe=r.useCallback(x=>re&&!J.has(x),[re,J]),ee=r.useCallback(x=>!pe(x)&&(K(x)||xe(x)),[K,xe]),B=r.useRef({shownExpanded:ee,isExpanded:K,isHeld:xe,unloadedFolders:J,entries:e,childrenOf:X,folderSelection:f,openDocument:p});r.useLayoutEffect(()=>{B.current={shownExpanded:ee,isExpanded:K,isHeld:xe,unloadedFolders:J,entries:e,childrenOf:X,folderSelection:f,openDocument:p}},[ee,K,xe,J,e,X,f,p]);const[te]=r.useState(()=>new Map),Le=r.useCallback((x,b)=>{R.settle(b),x.open(b)},[R]),Ee=r.useCallback((x,b)=>{b.kind!=="nothing"&&R.settle(b.path),x.close(b)},[R]),fe=r.useCallback((x,b)=>{for(const A of x){const Z=te.get(A);if(Z===void 0)continue;te.delete(A);const z=B.current.folderSelection;!b&&z!==null&&z.current===A&&Ee(z,Z)}},[te,Ee]),De=r.useCallback(x=>{V.current?.scrollToPath(x,{align:"nearest"}),requestAnimationFrame(()=>{const b=W.current,A=b===null?void 0:ft(b,x);A!==void 0&&v.focusWithoutScroll(A)})},[]),St=r.useCallback(x=>{if(pe(x)){De(Jt(x));return}fe([x],!B.current.shownExpanded(x)),B.current.isExpanded(x)?ie([x]):B.current.unloadedFolders.has(x)&&U(x),H(x)},[De,fe,U,ie,H]),je=r.useCallback(x=>{const b=x.filter(A=>!pe(A));b.length!==0&&(fe(b,!1),ie(b),we(b))},[fe,ie,we]),yt=r.useCallback(x=>{const b=x.filter(A=>!pe(A));if(b.length!==0){if(b.length<x.length&&b.every(A=>B.current.shownExpanded(A))){je(b);return}fe(b,!0),_(b)}},[fe,_,je]),He=r.useCallback(x=>c.jsx(_n,{name:x.name,onRetry:()=>{U(x.path),L.retryChildren(l,x.path),B.current.shownExpanded(x.path)||_([x.path])}}),[L,l,U,_]),Be=n==="multi"?a:Nn,{loopFolderName:Ze}=S,ve=r.useMemo(()=>ae(e,{openPaths:Be,childrenOf:X,renderFailedFolder:He,loopFolderName:Ze}),[ae,e,Be,X,He,Ze,t]),$e=r.useRef(ve);r.useLayoutEffect(()=>{$e.current=ve},[ve]);const kt=v.useIntentPrefetch(j,qn),ze=r.useRef([]),Re=r.useCallback(()=>{for(const x of ze.current)B.current.unloadedFolders.has(x)&&U(x)},[U]),{maxDepth:Oe}=P.revealDocument,Ve=r.useRef(u);r.useLayoutEffect(()=>{Ve.current=u},[u]);const Ct=r.useMemo(()=>({ancestors:async(x,b)=>{const A=R.take(l,x);if(A!==null)return A;if(!R.mayMove(x)){const z=await C.ancestors(l,x,b);return z.status!=="ok"||z.ancestors===null||z.ancestors.length>Oe?null:z.ancestors}const Z=await C.reveal(l,x,b);return Z.status!=="ok"||Z.source===null||Z.ancestors.length>Oe?null:Z.source===l?Z.ancestors:(b.aborted||!O.some(z=>z.id===Z.source)||(R.move(Z.source,x,Z.ancestors),Ve.current(Z.source)),null)},open:x=>{ze.current=x??[],x!==null&&(Re(),_([...x]))},progress:(x,b)=>sn(B.current.entries,x,b,{isShownExpanded:B.current.shownExpanded,childrenOf:B.current.childrenOf})}),[C,l,O,R,Oe,Re,_]);r.useEffect(()=>Re(),[Re,J]);const Tt=r.useMemo(()=>[e,t,Q],[e,t,Q]),Lt=r.useCallback(x=>W.current===null?Number.POSITIVE_INFINITY:kn(W.current,x),[]);gn({tree:V,container:W,path:i.path,chain:i.openFolders?Ct:null,rows:Tt,cancel:y,displayed:k,placement:Lt});const Ke=r.useCallback(x=>he.has(x),[he]),Se=r.useMemo(()=>ln(e,{isShownExpanded:ee,childrenOf:X,compare:de,isDirect:Ke}),[e,ee,X,de,Ke,t]),ye=k&&g;r.useLayoutEffect(()=>{h(e)},[e,h]),r.useLayoutEffect(()=>()=>h(null),[h]),r.useEffect(()=>L.claimChildren(l,ye?Se.folders:An),[L,l,ye,Se]),r.useEffect(()=>be(J),[be,J]),r.useEffect(()=>{ye&&ue&&N({entries:e,isShownExpanded:ee,childrenOf:X,compare:de,expanded:Q,waiting:Se.waiting,expansionPending:se})},[ye,ue,N,e,ee,X,de,Q,Se,se]);const jt=r.useCallback(x=>{const b=x.entry.absolutePath,{folderSelection:A,openDocument:Z}=B.current;if(x.isDirectory){if(A===null||pe(b))return;const z=b===A.current,Ue=on($e.current,B.current.entries,x.entry);if(B.current.isHeld(b)){x.preventDefault(),te.delete(b),z?Ee(A,Ue):Le(A,b);return}te.set(b,Ue),x.isExpanded||z||Le(A,b);return}R.settle(b),Z(b)},[R,te,Ee,Le]),Ot=r.useCallback(x=>{if(x.key!=="ArrowLeft"&&x.key!=="ArrowRight")return;const b=pt(x.target),A=b===null?null:b.getAttribute(ne);A!==null&&te.delete(A)},[te]),{onChange:Ne}=s,Nt=r.useMemo(()=>Ne===null?void 0:(x,b)=>{pe(x.absolutePath)||Ne({path:x.absolutePath,name:x.name,selected:b})},[Ne]),At=r.useMemo(()=>new Set(s.items),[s.items]),Pt=r.useMemo(()=>({entryKindDirectory:S.treeEntryKindDirectory,entryKindFile:S.treeEntryKindFile,scrollUp:S.treeScrollUp,scrollDown:S.treeScrollDown,scrollToTop:S.treeScrollToTop,scrollToBottom:S.treeScrollToBottom}),[S]),qt=Y===null?{showTreeLines:!1}:{showTreeLines:o.lines,lineColor:Y};return c.jsxs("div",{ref:W,className:"aqmx-explorer-tree","data-testid":"markdown-explorer-tree",onKeyDownCapture:Ot,...kt,children:[c.jsx("span",{ref:G,className:"aqmx-explorer-tree-probe","aria-hidden":"true",[vn]:""}),c.jsx(nt.DirectoryTree,{ref:V,entries:ve,expansion:{toggle:St,isExpanded:ee,expandMultiple:yt,collapseMultiple:je,isPending:se&&!ue,doubleClickAction:o.doubleClickAction},selection:{mode:s.mode,selectedPath:s.shownPath,currentPath:s.shownPath,selectedItems:At,onEntryClick:jt,onSelectionChange:Nt},visual:{className:"aqmx-explorer-tree-view",ariaLabel:S.treeRegion,...qt,showExpandIcons:o.expandIcons,expandIconStyle:Pn,showDirectoryIcons:o.directoryIcons,showFileIcons:o.fileIcons,expandIconSize:o.expandIconSize,itemHeight:oe,removeRootIndent:o.removeRootIndent,highlightStyles:Ln,entryStyle:On,nameStyle:jn},virtualScroll:le,sort:Rt,locale:I,labels:Pt})]})},Dn=({pending:e,status:t})=>{const{labels:n}=v.useExplorer(),l=t.state!=="running",[o,i]=r.useState(0),a=r.useRef(!0);r.useLayoutEffect(()=>{const p=a.current;if(a.current=l,!l||e>0&&!p){i(0);return}if(e>0){i(e);return}if(o===0)return;const f=setTimeout(()=>i(0),0);return()=>clearTimeout(f)},[l,e,o]);const s=l&&e===0?o:e;return s===0&&l?null:c.jsxs("p",{className:"aqmx-explorer-tree-progress","data-testid":"markdown-explorer-tree-progress","data-aqmx-loading":String(s),"data-aqmx-expand-all":t.state,children:[s>0?c.jsx(v.ForwardRef,{className:"aqmx-explorer-tree-progress-icon","aria-hidden":"true"}):null,c.jsx("span",{children:t.state==="running"?n.expandAllProgress(t.opened,s):n.foldersLoading(s)})]})},Hn=({stop:e,opened:t,budget:n})=>{const{labels:l}=v.useExplorer();return c.jsx("p",{className:"aqmx-explorer-expand-all-stop","data-testid":"markdown-explorer-expand-all-stop","data-aqmx-stop":e,children:mt(l,n,e,t)})},Bn=({entries:e,...t})=>{const{trees:n}=v.useExplorer(),l=r.useSyncExternalStore(n.subscribe,n.version,n.version),{sourceId:o}=t,[i]=r.useState(Yt),a=r.useMemo(()=>i(e,s=>n.children(o,s)),[i,e,n,o,l]);return a.length===0?c.jsx(Fn,{}):c.jsx(In,{entries:a,version:l,...t})},Zn=({result:e,onRetry:t,...n})=>{const{renderTreeFailure:l}=v.useExplorer(),o=r.use(e);if(o.status==="deferred")return c.jsx(ht,{});if(o.status==="ok")return c.jsx(Bn,{entries:o.entries,...n});const i=l?.(o.failure);return c.jsx("div",{className:"aqmx-explorer-tree-message","data-testid":"markdown-explorer-tree-failure","data-aqmx-failure":o.failure.reason,children:i!==void 0?i:c.jsx(v.FailureView,{failure:o.failure,alert:!0,onRetry:t,testId:null})})},$n=({onControls:e,...t})=>{const{trees:n,storageNamespace:l,labels:o,announcer:i,config:a}=v.useExplorer(),{sourceId:s}=t,p=nt.useDirectoryTreeState({storageKey:Mt.storageKeys(l).treeExpansion(s)});r.useSyncExternalStore(n.subscribe,n.version,n.version);const f=n.read(s),u=r.useCallback(()=>n.retry(s),[n,s]);r.useLayoutEffect(()=>n.open(s),[n,s]);const d=fn(),{expanded:h,expandMultiple:w,collapseAll:g}=p,[E,y]=r.useState(null),L=E!==h,j=r.useRef(h);r.useLayoutEffect(()=>{j.current=h},[h]);const S=a.expandAll,I=r.useCallback(()=>i.announce(o.expandAllStarted),[i,o]),M=r.useCallback(H=>i.announce(Mn(o,S,H)),[i,o,S]),T=xn({budget:S,expandMultiple:w,onStart:I,onFinish:M}),{status:C,start:P,end:O,advance:R}=T,k=C.state==="running",F=r.useMemo(()=>({running:k,advance:R}),[k,R]),D=r.useRef(null),[$,le]=r.useState(!1),ae=r.useCallback(H=>{D.current=H,le(H!==null)},[]);r.useEffect(()=>n.subscribeChildrenFailures(H=>{const _=H.sourceId===s&&D.current!==null?ct(D.current,H.path):null;_!==null&&i.announce({list:o.foldersLoadFailedNamed,item:_.name})}),[n,s,i,o]);const{clearDirect:G}=d,[oe,Y]=r.useState(0),K=r.useCallback(()=>{Y(H=>H+1),O(),G(),y(j.current),g()},[O,G,g]);return r.useEffect(()=>{e({collapseAll:K,expandAll:$?P:null,expanding:k})},[e,K,P,$,k]),r.useEffect(()=>()=>e(null),[e]),r.useEffect(()=>{$||O()},[$,O]),c.jsxs(c.Fragment,{children:[C.state==="stopped"?c.jsx(Hn,{stop:C.stop,opened:C.opened,budget:S}):null,c.jsxs("div",{className:"aqmx-explorer-tree-area",children:[c.jsx(r.Suspense,{fallback:c.jsx(ht,{}),children:c.jsx(Zn,{result:f,onRetry:u,expansion:p,onShown:ae,marks:d,claimsHeld:L,expandAll:F,revealCancel:oe,...t})}),c.jsx(Dn,{pending:n.pendingChildren(s),status:C})]})]})};function zn({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M5.47 5.47a.75.75 0 0 1 1.06 0L12 10.94l5.47-5.47a.75.75 0 1 1 1.06 1.06L13.06 12l5.47 5.47a.75.75 0 1 1-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 0 1-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const Fe=m.forwardRef(zn),Je="markdown-explorer-selection-remove",Vn=({selection:e,onRemove:t,onClear:n,onOpenSelection:l,onLeave:o})=>{const{labels:i}=v.useExplorer(),a=r.useId(),s=r.useRef(null),p=[...e],f=(d,h)=>{if(h.ownerDocument.activeElement===h){const w=s.current===null?[]:[...s.current.querySelectorAll(`[data-testid="${Je}"]`)],g=w.indexOf(h),E=[w[g+1],w[g-1]].find(y=>y!==void 0);E===void 0?o():E.focus()}t(d)},u=()=>{const d=s.current;d!==null&&d.contains(d.ownerDocument.activeElement)&&o(),n()};return c.jsxs("section",{ref:s,className:"aqmx-explorer-tray","aria-labelledby":a,"data-testid":"markdown-explorer-selection-tray",children:[c.jsxs("div",{className:"aqmx-explorer-tray-header",children:[c.jsx("p",{id:a,className:"aqmx-explorer-tray-title",children:i.selectionTitle(p.length)}),c.jsx("button",{type:"button",className:"aqmx-explorer-tray-button","data-testid":"markdown-explorer-selection-clear",onClick:u,children:i.clearSelection})]}),c.jsx("ul",{className:"aqmx-explorer-tray-list",children:p.map(([d,h])=>c.jsxs("li",{className:"aqmx-explorer-tray-item",children:[c.jsx("span",{className:"aqmx-explorer-tray-name",title:d,children:h}),c.jsx("button",{type:"button",className:"aqmx-icon-button aqmx-explorer-tray-remove","aria-label":i.removeFromSelection(h),title:i.removeFromSelection(h),"data-testid":Je,"data-aqmx-path":d,onClick:w=>f(d,w.currentTarget),children:c.jsx(Fe,{"aria-hidden":"true"})})]},d))}),l===void 0?null:c.jsx("button",{type:"button",className:"aqmx-explorer-tray-open","data-testid":"markdown-explorer-selection-open",onClick:()=>l(p.map(([d])=>d)),children:i.openSelectionInMulti(p.length)})]})},Ce=new Map,Kn=(e,t)=>{if(t.selected===e.has(t.path))return e;const n=new Map(e);return t.selected?n.set(t.path,t.name):n.delete(t.path),n},Un=(e,t)=>{if(!e.has(t))return e;const n=new Map(e);return n.delete(t),n},xt=r.createContext(null),Wn=e=>{const t=r.use(xt);r.useLayoutEffect(()=>{if(t!==null)return t(e),()=>t(!1)},[t,e])};function Xn({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M6.97 2.47a.75.75 0 0 1 1.06 0l4.5 4.5a.75.75 0 0 1-1.06 1.06L8.25 4.81V16.5a.75.75 0 0 1-1.5 0V4.81L3.53 8.03a.75.75 0 0 1-1.06-1.06l4.5-4.5Zm9.53 4.28a.75.75 0 0 1 .75.75v11.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-4.5 4.5a.75.75 0 0 1-1.06 0l-4.5-4.5a.75.75 0 1 1 1.06-1.06l3.22 3.22V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const Gn=m.forwardRef(Xn);function Yn({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M11.25 4.533A9.707 9.707 0 0 0 6 3a9.735 9.735 0 0 0-3.25.555.75.75 0 0 0-.5.707v14.25a.75.75 0 0 0 1 .707A8.237 8.237 0 0 1 6 18.75c1.995 0 3.823.707 5.25 1.886V4.533ZM12.75 20.636A8.214 8.214 0 0 1 18 18.75c.966 0 1.89.166 2.75.47a.75.75 0 0 0 1-.708V4.262a.75.75 0 0 0-.5-.707A9.735 9.735 0 0 0 18 3a9.707 9.707 0 0 0-5.25 1.533v16.103Z"}))}const Qn=m.forwardRef(Yn);function Jn({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm13.36-1.814a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.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"}))}const er=m.forwardRef(Jn);function tr({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M7.72 12.53a.75.75 0 0 1 0-1.06l7.5-7.5a.75.75 0 1 1 1.06 1.06L9.31 12l6.97 6.97a.75.75 0 1 1-1.06 1.06l-7.5-7.5Z",clipRule:"evenodd"}))}const nr=m.forwardRef(tr);function rr({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M11.47 4.72a.75.75 0 0 1 1.06 0l3.75 3.75a.75.75 0 0 1-1.06 1.06L12 6.31 8.78 9.53a.75.75 0 0 1-1.06-1.06l3.75-3.75Zm-3.75 9.75a.75.75 0 0 1 1.06 0L12 17.69l3.22-3.22a.75.75 0 1 1 1.06 1.06l-3.75 3.75a.75.75 0 0 1-1.06 0l-3.75-3.75a.75.75 0 0 1 0-1.06Z",clipRule:"evenodd"}))}const lr=m.forwardRef(rr);function ar({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M11.078 2.25c-.917 0-1.699.663-1.85 1.567L9.05 4.889c-.02.12-.115.26-.297.348a7.493 7.493 0 0 0-.986.57c-.166.115-.334.126-.45.083L6.3 5.508a1.875 1.875 0 0 0-2.282.819l-.922 1.597a1.875 1.875 0 0 0 .432 2.385l.84.692c.095.078.17.229.154.43a7.598 7.598 0 0 0 0 1.139c.015.2-.059.352-.153.43l-.841.692a1.875 1.875 0 0 0-.432 2.385l.922 1.597a1.875 1.875 0 0 0 2.282.818l1.019-.382c.115-.043.283-.031.45.082.312.214.641.405.985.57.182.088.277.228.297.35l.178 1.071c.151.904.933 1.567 1.85 1.567h1.844c.916 0 1.699-.663 1.85-1.567l.178-1.072c.02-.12.114-.26.297-.349.344-.165.673-.356.985-.57.167-.114.335-.125.45-.082l1.02.382a1.875 1.875 0 0 0 2.28-.819l.923-1.597a1.875 1.875 0 0 0-.432-2.385l-.84-.692c-.095-.078-.17-.229-.154-.43a7.614 7.614 0 0 0 0-1.139c-.016-.2.059-.352.153-.43l.84-.692c.708-.582.891-1.59.433-2.385l-.922-1.597a1.875 1.875 0 0 0-2.282-.818l-1.02.382c-.114.043-.282.031-.449-.083a7.49 7.49 0 0 0-.985-.57c-.183-.087-.277-.227-.297-.348l-.179-1.072a1.875 1.875 0 0 0-1.85-1.567h-1.843ZM12 15.75a3.75 3.75 0 1 0 0-7.5 3.75 3.75 0 0 0 0 7.5Z",clipRule:"evenodd"}))}const or=m.forwardRef(ar);function sr({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M12 1.5a.75.75 0 0 1 .75.75V4.5a.75.75 0 0 1-1.5 0V2.25A.75.75 0 0 1 12 1.5ZM5.636 4.136a.75.75 0 0 1 1.06 0l1.592 1.591a.75.75 0 0 1-1.061 1.06l-1.591-1.59a.75.75 0 0 1 0-1.061Zm12.728 0a.75.75 0 0 1 0 1.06l-1.591 1.592a.75.75 0 0 1-1.06-1.061l1.59-1.591a.75.75 0 0 1 1.061 0Zm-6.816 4.496a.75.75 0 0 1 .82.311l5.228 7.917a.75.75 0 0 1-.777 1.148l-2.097-.43 1.045 3.9a.75.75 0 0 1-1.45.388l-1.044-3.899-1.601 1.42a.75.75 0 0 1-1.247-.606l.569-9.47a.75.75 0 0 1 .554-.68ZM3 10.5a.75.75 0 0 1 .75-.75H6a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 10.5Zm14.25 0a.75.75 0 0 1 .75-.75h2.25a.75.75 0 0 1 0 1.5H18a.75.75 0 0 1-.75-.75Zm-8.962 3.712a.75.75 0 0 1 0 1.061l-1.591 1.591a.75.75 0 1 1-1.061-1.06l1.591-1.592a.75.75 0 0 1 1.06 0Z",clipRule:"evenodd"}))}const cr=m.forwardRef(sr);function ir({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M5.625 1.5c-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.5H5.625ZM7.5 15a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5h-7.5A.75.75 0 0 1 7.5 15Zm.75 2.25a.75.75 0 0 0 0 1.5H12a.75.75 0 0 0 0-1.5H8.25Z",clipRule:"evenodd"}),m.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 ur=m.forwardRef(ir);function dr({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M19.5 21a3 3 0 0 0 3-3v-4.5a3 3 0 0 0-3-3h-15a3 3 0 0 0-3 3V18a3 3 0 0 0 3 3h15ZM1.5 10.146V6a3 3 0 0 1 3-3h5.379a2.25 2.25 0 0 1 1.59.659l2.122 2.121c.14.141.331.22.53.22H19.5a3 3 0 0 1 3 3v1.146A4.483 4.483 0 0 0 19.5 9h-15a4.483 4.483 0 0 0-3 1.146Z"}))}const fr=m.forwardRef(dr);function pr({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M19.906 9c.382 0 .749.057 1.094.162V9a3 3 0 0 0-3-3h-3.879a.75.75 0 0 1-.53-.22L11.47 3.66A2.25 2.25 0 0 0 9.879 3H6a3 3 0 0 0-3 3v3.162A3.756 3.756 0 0 1 4.094 9h15.812ZM4.094 10.5a2.25 2.25 0 0 0-2.227 2.568l.857 6A2.25 2.25 0 0 0 4.951 21H19.05a2.25 2.25 0 0 0 2.227-1.932l.857-6a2.25 2.25 0 0 0-2.227-2.568H4.094Z"}))}const mr=m.forwardRef(pr);function hr({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M10.5 3.75a6.75 6.75 0 1 0 0 13.5 6.75 6.75 0 0 0 0-13.5ZM2.25 10.5a8.25 8.25 0 1 1 14.59 5.28l4.69 4.69a.75.75 0 1 1-1.06 1.06l-4.69-4.69A8.25 8.25 0 0 1 2.25 10.5Zm8.25-3.75a.75.75 0 0 1 .75.75v2.25h2.25a.75.75 0 0 1 0 1.5h-2.25v2.25a.75.75 0 0 1-1.5 0v-2.25H7.5a.75.75 0 0 1 0-1.5h2.25V7.5a.75.75 0 0 1 .75-.75Z",clipRule:"evenodd"}))}const xr=m.forwardRef(hr);function wr({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M4.125 3C3.089 3 2.25 3.84 2.25 4.875V18a3 3 0 0 0 3 3h15a3 3 0 0 1-3-3V4.875C17.25 3.839 16.41 3 15.375 3H4.125ZM12 9.75a.75.75 0 0 0 0 1.5h1.5a.75.75 0 0 0 0-1.5H12Zm-.75-2.25a.75.75 0 0 1 .75-.75h1.5a.75.75 0 0 1 0 1.5H12a.75.75 0 0 1-.75-.75ZM6 12.75a.75.75 0 0 0 0 1.5h7.5a.75.75 0 0 0 0-1.5H6Zm-.75 3.75a.75.75 0 0 1 .75-.75h7.5a.75.75 0 0 1 0 1.5H6a.75.75 0 0 1-.75-.75ZM6 6.75a.75.75 0 0 0-.75.75v3c0 .414.336.75.75.75h3a.75.75 0 0 0 .75-.75v-3A.75.75 0 0 0 9 6.75H6Z",clipRule:"evenodd"}),m.createElement("path",{d:"M18.75 6.75h1.875c.621 0 1.125.504 1.125 1.125V18a1.5 1.5 0 0 1-3 0V6.75Z"}))}const gr=m.forwardRef(wr);function br({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{d:"M5.625 3.75a2.625 2.625 0 1 0 0 5.25h12.75a2.625 2.625 0 0 0 0-5.25H5.625ZM3.75 11.25a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75ZM3 15.75a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75ZM3.75 18.75a.75.75 0 0 0 0 1.5h16.5a.75.75 0 0 0 0-1.5H3.75Z"}))}const Er=m.forwardRef(br),vr=Object.freeze({sortMode:Gn,folderPlacement:fr,readmePlacement:Qn,selectionMode:er,doubleClickAction:cr,expandIconSize:xr,alwaysExpanded:v.ForwardRef$2,revealDocument:v.ForwardRef$1,showFolderReadme:gr,removeRootIndent:nr,lines:Er,expandIcons:lr,directoryIcons:mr,fileIcons:ur}),wt=(e,t)=>{const n=e[t.labelKey];if(typeof n!="string")throw new TypeError(`[markdown-explorer] the tree setting ${t.key} must name a string label; labels.${t.labelKey} is ${lt.describeValue(n)}`);return n},Rr=({id:e,settings:t,descriptors:n,onAdvance:l,onClose:o,ref:i})=>{const{labels:a}=v.useExplorer(),s=r.useRef([]);r.useEffect(()=>{s.current[0]?.focus()},[]);const p=r.useCallback(u=>{const d=n.length;s.current[(u%d+d)%d]?.focus()},[n.length]),f=r.useCallback((u,d)=>{switch(u.key){case"ArrowDown":u.preventDefault(),p(d+1);break;case"ArrowUp":u.preventDefault(),p(d-1);break;case"Home":u.preventDefault(),p(0);break;case"End":u.preventDefault(),p(n.length-1);break;case"Escape":v.consumeKey(u),o();break;case"Tab":o();break}},[n.length,p,o]);return c.jsx("div",{ref:i,id:e,role:"menu","aria-label":a.treeSettings,className:"aqmx-explorer-menu","data-testid":"markdown-explorer-tree-settings-menu",children:n.map((u,d)=>{const h=vr[u.key],w=wt(a,u),g=q.formatTreeSettingValue(a,t,u.key),E=t[u.key],y=typeof E=="boolean"?{role:"menuitemcheckbox","aria-checked":E,"aria-label":w}:{role:"menuitem","aria-label":`${w}: ${g}`};return c.jsxs("button",{ref:L=>{s.current[d]=L},type:"button",tabIndex:-1,...y,title:`${w}: ${g}`,className:"aqmx-explorer-menu-item","data-testid":"markdown-explorer-tree-settings-item","data-aqmx-setting":u.key,onClick:()=>l(u),onKeyDown:L=>f(L,d),children:[c.jsx(h,{className:"aqmx-explorer-menu-icon","aria-hidden":"true"}),c.jsx("span",{className:"aqmx-explorer-menu-name",children:w}),c.jsx("span",{className:"aqmx-explorer-menu-value",children:g})]},u.key)})})},Sr=({settings:e,descriptors:t,onAdvance:n})=>{const{labels:l,announcer:o}=v.useExplorer(),[i,a]=r.useState(!1),s=r.useRef(null),p=r.useRef(null),f=r.useRef(null),u=r.useId(),d=r.useCallback(()=>{s.current?.focus(),a(!1)},[]);r.useEffect(()=>{if(!i)return;const g=E=>{E.target instanceof Node&&(s.current?.contains(E.target)===!0||p.current?.contains(E.target)===!0)||(a(!1),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{f.current=null,(document.activeElement===null||document.activeElement===document.body)&&s.current?.focus()},0))};return document.addEventListener("pointerdown",g),()=>document.removeEventListener("pointerdown",g)},[i]),r.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);const h=r.useCallback(g=>{g.key!=="Escape"||!i||(v.consumeKey(g),d())},[i,d]),w=r.useCallback(g=>{const E=n(g.key);o.announce(l.settingAnnouncement(wt(l,g),q.formatTreeSettingValue(l,E,g.key)))},[o,l,n]);return{trigger:c.jsx("button",{ref:s,type:"button",className:"aqmx-icon-button","aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?u:void 0,"aria-label":l.treeSettings,title:l.treeSettings,"data-testid":"markdown-explorer-tree-settings",onClick:()=>a(g=>!g),onKeyDown:h,children:c.jsx(or,{"aria-hidden":"true"})}),menu:i?c.jsx(Rr,{ref:p,id:u,settings:e,descriptors:t,onAdvance:w,onClose:d}):null}},yr=()=>{const{treeSettings:e}=v.useExplorer();return{settings:r.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot),advance:e.advance}},et=new Set,kr='[role="tree"] [role="treeitem"][tabindex="0"]',Cr="[data-directory-tree-tab-stop]",Tr=e=>{const{mode:t,sourceId:n,currentPath:l,openPaths:o,onOpenDocument:i,onSourceChange:a,onRevealSource:s,viewSwitch:p}=e,{labels:f,sources:u,trees:d,documents:h,announcer:w,reveals:g}=v.useExplorer(),{settings:E,advance:y}=yr(),L=r.useMemo(()=>q.visibleTreeSettingDescriptors(t),[t]),j=t==="tree"&&E.selectionMode==="multiple";Wn(j);const S=e.mode==="tree"?e.tray.onGatheredChange:null,I=e.mode==="tree"?e.onOpenSelection:void 0,M=e.mode==="tree"?e.onOpenFolder:null,T=e.mode==="tree"?e.onCloseFolder:null,C=e.mode==="tree"&&e.currentFolder,P=r.useMemo(()=>M===null||T===null||!E.showFolderReadme?null:{current:l,open:M,close:T},[M,T,l,E.showFolderReadme]),O=e.mode==="tree"&&j?e.tray.gathered:Ce,R=r.useCallback(N=>{const V=y(N);return V.selectionMode!=="multiple"&&S?.(Ce),V},[y,S]),k=Sr({settings:E,descriptors:L,onAdvance:R}),F=r.useCallback(N=>S?.(V=>Kn(V,N)),[S]),D=r.useCallback(N=>S?.(V=>Un(V,N)),[S]),$=r.useCallback(()=>S?.(Ce),[S]),le=r.useRef(null),ae=r.useCallback(()=>{const N=le.current;if(N===null)return;[kr,Cr,'[data-testid="markdown-explorer-tree-settings"]'].map(W=>N.querySelector(W)).find(W=>W!==null)?.focus()},[]),G=r.useMemo(()=>new Set(O.keys()),[O]),oe=r.useMemo(()=>l===null?et:new Set([l]),[l]),Y=r.useMemo(()=>{if(t==="multi")return{mode:"multiple",items:o,shownPath:null,onChange:null};switch(E.selectionMode){case"single":return{mode:"single",items:oe,shownPath:l,onChange:null};case"multiple":return{mode:"multiple",items:G,shownPath:l,onChange:F};case"none":return{mode:"none",items:et,shownPath:null,onChange:null}}},[t,o,E.selectionMode,oe,l,G,F]),K=r.useMemo(()=>E.revealDocument?{path:l,openFolders:!C}:{path:Y.shownPath,openFolders:!1},[E.revealDocument,l,C,Y.shownPath]),H=r.useCallback(N=>{l!==null&&g.settle(l),a(N)},[l,g,a]),[_,we]=r.useState(null),[Q,se]=r.useState(!1),[re,me]=r.useState(null),ce=r.useRef(!1),ge=r.useCallback(async()=>{if(!ce.current){ce.current=!0,se(!0),me(null);try{const N=await d.refresh(n);if(N.status==="superseded")return;h.invalidate(),N.status==="failed"?me({sourceId:n,failure:N.failure}):w.announce(f.treeRefreshed)}finally{ce.current=!1,se(!1)}}},[d,h,n,w,f]),he=_===null?null:_.expandAll,U=_?.expanding===!0,ie=u.find(N=>N.id===n),be=p.target==="multi"?zt:Zt,ue=p.target==="multi"?f.switchToMulti:f.switchToTree;return c.jsxs("nav",{ref:le,"aria-label":f.explorerRegion,className:"aqmx-explorer","data-testid":"markdown-explorer-explorer","data-aqmx-mode":t,children:[c.jsxs("div",{className:"aqmx-explorer-header",children:[u.length>1?c.jsx("select",{className:"aqmx-explorer-source","aria-label":f.sourceLabel,title:ie?.label,value:n,onChange:N=>H(N.currentTarget.value),"data-testid":"markdown-explorer-source-select",children:u.map(N=>c.jsx("option",{value:N.id,children:N.label},N.id))}):null,c.jsxs("div",{className:"aqmx-explorer-actions",children:[c.jsx(v.ExplorerLink,{to:p.href,navigation:"switch-view",className:"aqmx-icon-button","aria-label":ue,title:ue,"data-testid":"markdown-explorer-view-switch","data-aqmx-target":p.target,children:c.jsx(be,{"aria-hidden":"true"})}),c.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:f.refreshTree,"aria-disabled":Q,"aria-busy":Q,"data-aqmx-busy":Q?"true":void 0,"data-testid":"markdown-explorer-refresh",onClick:()=>{ge()},children:[c.jsx(v.ForwardRef,{"aria-hidden":"true"}),c.jsx("span",{children:f.refreshTreeLabel})]}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.expandAll,title:f.expandAll,"aria-disabled":he===null||U,"aria-busy":U,"data-aqmx-busy":U?"true":void 0,"data-testid":"markdown-explorer-expand-all",onClick:()=>he?.(),children:c.jsx(Ht,{"aria-hidden":"true"})}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":f.collapseAll,title:f.collapseAll,"aria-disabled":_===null,"data-testid":"markdown-explorer-collapse-all",onClick:()=>_?.collapseAll(),children:c.jsx(It,{"aria-hidden":"true"})}),k.trigger]})]}),c.jsxs("div",{className:"aqmx-explorer-body","data-aqmx-explorer-body":"",children:[re!==null&&re.sourceId===n?c.jsx("p",{role:"alert",className:"aqmx-explorer-refresh-failure","data-testid":"markdown-explorer-refresh-failure","data-aqmx-failure":re.failure.reason,children:f.treeRefreshFailed(v.failureTitleOf(f,re.failure.reason))}):null,c.jsx(r.Suspense,{fallback:null,children:c.jsx(Wt,{})}),c.jsx($n,{mode:t,sourceId:n,settings:E,reveal:K,openPaths:o,selection:Y,onOpenDocument:i,folders:P,onRevealSource:s,onControls:we},n),j&&O.size>0?c.jsx(Vn,{selection:O,onRemove:D,onClear:$,onOpenSelection:I,onLeave:ae}):null,k.menu]})]})};function Lr({title:e,titleId:t,...n},l){return m.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:l,"aria-labelledby":t},n),e?m.createElement("title",{id:t},e):null,m.createElement("path",{fillRule:"evenodd",d:"M3 6.75A.75.75 0 0 1 3.75 6h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 6.75ZM3 12a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75A.75.75 0 0 1 3 12Zm0 5.25a.75.75 0 0 1 .75-.75h16.5a.75.75 0 0 1 0 1.5H3.75a.75.75 0 0 1-.75-.75Z",clipRule:"evenodd"}))}const gt=m.forwardRef(Lr),jr=({explorer:e,toggleRef:t,covered:n,merged:l,onNoticeSlotChange:o,dismissals:i})=>{const{labels:a}=v.useExplorer(),s=Te.useLocation(),p=Te.useNavigationType(),{location:f}=v.useExplorerLocation(),[u,d]=r.useState(!1),[h,w]=r.useState({navigated:s,source:f.source}),[g,E]=r.useState(!1);h.navigated!==s&&(w({navigated:s,source:f.source}),h.source===f.source&&!g&&v.explorerNavigationOf(p,s.state)!=="close-folder"&&d(!1));const[y,L]=r.useState(i);y!==i&&(L(i),d(!1));const j=r.useRef(null),S=r.useRef(null),I=r.useRef(null),M=r.useRef(!1),T=r.useId();r.useLayoutEffect(()=>{const k=j.current;k!==null&&(u&&!k.open?(k.showModal(),S.current?.focus()):!u&&k.open&&(k.close(),t.current?.focus()),o(u?I.current:null))},[u,t,o]),r.useLayoutEffect(()=>()=>o(null),[o]);const C=r.useCallback(k=>{k.key!=="Escape"||k.defaultPrevented||(v.consumeKey(k),d(!1))},[]),P=r.useCallback(k=>{M.current=k.target===k.currentTarget},[]),O=r.useCallback(k=>{const F=M.current;M.current=!1,F&&k.target===k.currentTarget&&d(!1)},[]),R=r.useCallback(()=>{d(!1)},[]);return c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"aqmx-sheet-bar",inert:n,"data-testid":"markdown-explorer-sheet-bar","data-aqmx-sheet-bar-merged":l?"true":"false",children:c.jsxs("button",{ref:t,type:"button",className:"aqmx-explorer-toggle",title:l?a.showExplorer:void 0,"aria-haspopup":"dialog","aria-expanded":u,"aria-controls":T,"data-testid":"markdown-explorer-sheet-toggle",onClick:()=>d(!0),children:[c.jsx(gt,{"aria-hidden":"true"}),c.jsx("span",{className:l?"aqmx-sr-only":void 0,children:a.showExplorer})]})}),c.jsx("dialog",{ref:j,id:T,className:"aqmx-sheet","aria-label":a.explorerRegion,"data-testid":"markdown-explorer-sheet",onKeyDown:C,onPointerDown:P,onClick:O,onClose:R,children:c.jsxs("div",{className:"aqmx-sheet-panel",children:[c.jsxs("div",{className:"aqmx-explorer-chrome",children:[c.jsx("div",{ref:I,className:"aqmx-sheet-notice-slot"}),c.jsx("button",{ref:S,type:"button",className:"aqmx-explorer-close","aria-label":a.hideExplorer,title:a.hideExplorer,"data-testid":"markdown-explorer-sheet-close",onClick:()=>d(!1),children:c.jsx(Fe,{"aria-hidden":"true"})})]}),c.jsx("div",{className:"aqmx-sheet-body",children:c.jsx(Me,{value:u,children:c.jsx(xt,{value:E,children:e})})}),c.jsx(v.LiveRegion,{holds:u,deferWhileFullscreenIn:null,testId:"markdown-explorer-sheet-announcer"})]})})]})},bt=r.createContext(null),_e="aqmx-explorer",Et="aqmx-content",Ie='[role="tree"] [role="treeitem"]',Or=`${Ie}[tabindex="0"]`,Nr="[data-directory-tree-tab-stop]",Ar=(e,t)=>{for(const n of e.querySelectorAll(`[data-panel-id="${_e}"] ${Ie}`))if(n.getAttribute(ne)===t)return n;return null},tt=(e,t)=>({inlineSize:e>0?e:null,rootFontPixels:t>0?t:q.ASSUMED_ROOT_FONT_PIXELS}),Pr=(e,t)=>{const[n,l]=r.useState(()=>tt(0,0));return r.useLayoutEffect(()=>{const o=e.current,i=t.current;if(o===null||i===null)throw new Error("[markdown-explorer] the split frame is not mounted");const a={frame:o.getBoundingClientRect().width,rem:i.getBoundingClientRect().width},s=()=>{const f=tt(a.frame,a.rem);l(u=>u.inlineSize===f.inlineSize&&u.rootFontPixels===f.rootFontPixels?u:f)};s();const p=new ResizeObserver(f=>{for(const u of f){const[d]=u.borderBoxSize;d!==void 0&&(u.target===o&&(a.frame=d.inlineSize),u.target===i&&(a.rem=d.inlineSize))}s()});return p.observe(o),p.observe(i),()=>p.disconnect()},[e,t]),n},vt=e=>`aqmx-split-handle-${e}`,qr=(e,{frameRef:t,sheetToggleRef:n,railToggleRef:l,closeButtonRef:o,handleId:i})=>{const a=r.useRef(!1),s=r.useRef(null),p=r.useRef(!1);r.useLayoutEffect(()=>{const u=t.current;if(u===null)throw new Error("[markdown-explorer] the split frame is not mounted");const d=w=>{const g=w.target instanceof Element?w.target:null;a.current=g!==null&&g.closest(`[data-panel-id="${Et}"]`)===null,!p.current&&(s.current=g?.closest(`${Ie}[${ne}]`)?.getAttribute(ne)??null)},h=w=>{w.relatedTarget instanceof Node&&!u.contains(w.relatedTarget)&&(a.current=!1)};return u.addEventListener("focusin",d),u.addEventListener("focusout",h),()=>{u.removeEventListener("focusin",d),u.removeEventListener("focusout",h)}},[t]);const f=r.useRef(e);r.useLayoutEffect(()=>{const u=f.current;if(u===e)return;f.current=e;const d=t.current;if(d===null||!a.current)return;const h=w=>{const{activeElement:g,body:E}=d.ownerDocument;if(g!==null&&g!==E)return;const y=w.find(L=>L!==null);if(y!=null){p.current=!0;try{y.focus()}finally{p.current=!1}}};if(e==="sheet"){h([n.current]);return}if(e==="rail"){h([l.current]);return}if(u==="rail"){h([o.current]);return}queueMicrotask(()=>{if(f.current!==e||!a.current)return;const w=s.current,g=`[data-panel-id="${_e}"]`;h([w===null?null:Ar(d,w),d.querySelector(`${g} ${Or}`),d.querySelector(`${g} ${Nr}`),d.querySelector(`[data-resize-handle-id="${i}"]`)])})},[e,t,n,l,o,i])},Mr=e=>e==="tree"?"treeExplorerHidden":"multiExplorerHidden",Fr=({view:e,explorer:t,content:n,contentCoversPage:l=!1,sheetDismissals:o=0,onDraggingChange:i})=>{const{viewSettings:a}=v.useExplorer(),s=r.useRef(null),[p,f]=r.useState(null),u=r.useRef(null),d=r.useRef(null),h=r.useRef(null),w=r.useRef(null),{inlineSize:g,rootFontPixels:E}=Pr(s,u),y=Mr(e),L=v.useViewSetting(R=>R[y]===!0),j=g!==null&&g<q.explorerSheetBelowPixels(E),S=j?"sheet":L?"rail":"split";qr(S,{frameRef:s,sheetToggleRef:d,railToggleRef:h,closeButtonRef:w,handleId:vt(e)});const I=r.useCallback(()=>a.update({[y]:!0}),[a,y]),M=r.useCallback(()=>a.update({[y]:!1}),[a,y]),[T,C]=r.useState(!1),P=r.useMemo(()=>j?{lane:!l,onBar:C}:null,[j,l]),[O]=r.useState(()=>new Map);return c.jsx(at,{value:O,children:c.jsxs("div",{ref:s,className:"aqmx-split-frame","data-aqmx-explorer-mode":S,"data-aqmx-measured":g===null?"false":"true","data-aqmx-content-covers-page":l?"true":"false",children:[c.jsx("span",{ref:u,className:"aqmx-rem-probe","aria-hidden":"true","data-aqmx-rem-probe":""}),j?c.jsx(jr,{explorer:t,toggleRef:d,covered:l,merged:T,onNoticeSlotChange:f,dismissals:o}):null,c.jsxs("div",{className:"aqmx-split-row",children:[S==="rail"?c.jsx(_r,{toggleRef:h,covered:l,onOpen:M}):null,c.jsx(bt,{value:j?p:null,children:c.jsx(v.SheetBarContext,{value:P,children:c.jsx(Ir,{view:e,mode:S,explorer:t,content:n,contentCoversPage:l,onDraggingChange:i,explorerMinPixels:q.explorerMinPixels(E),closeButtonRef:w,onHide:I})})})]})]})})},_r=({toggleRef:e,covered:t,onOpen:n})=>{const{labels:l}=v.useExplorer();return c.jsx("div",{className:"aqmx-split-rail",inert:t,"data-testid":"markdown-explorer-rail",children:c.jsx("button",{ref:e,type:"button",className:"aqmx-explorer-toggle","aria-expanded":!1,"aria-label":l.showExplorer,title:l.showExplorer,"data-testid":"markdown-explorer-rail-toggle",onClick:n,children:c.jsx(gt,{"aria-hidden":"true"})})})},Ir=({view:e,mode:t,explorer:n,content:l,contentCoversPage:o,onDraggingChange:i,explorerMinPixels:a,closeButtonRef:s,onHide:p})=>{const{viewSettings:f,labels:u}=v.useExplorer(),d=r.useMemo(()=>Xe.toPanelGroupLabels(u),[u]),w=v.useViewSetting(R=>e==="tree"?R.treeExplorer:R.multiExplorer)??(e==="tree"?q.EXPLORER_DEFAULT_PERCENT:q.EXPLORER_MULTI_DEFAULT_PERCENT),g=r.useRef(!1),[E,y]=r.useState(!1),L=r.useRef(!1),j=r.useRef(i);r.useLayoutEffect(()=>{j.current=i},[i]);const S=Xe.useSplitPersistence(r.useCallback(R=>{if(R.length!==2)return;const[k=0,F=0]=R,D=k+F;if(D<=0||k<=0)return;const $=Math.min(q.EXPLORER_MAX_PERCENT,k/D*100);f.update(e==="tree"?{treeExplorer:$}:{multiExplorer:$})},[f,e]));r.useEffect(()=>()=>{g.current&&j.current?.(!1)},[]);const M=v.useCoarsePointer()?q.COARSE_TARGET_PIXELS:q.FINE_TARGET_PIXELS,T=t==="split",C=r.useCallback(()=>{L.current=!1,y(!1),p()},[p]),P=r.useCallback((R,k)=>{const[F=0,D=0]=R;R.length===2&&D>0&&(L.current=F<=0,y(L.current)),S.layoutChanged(R,k),L.current&&k.source==="keyboard"&&C()},[S,C]),O=r.useCallback(R=>{g.current=R,i?.(R),S.draggingChanged(R),!R&&L.current&&C()},[i,S,C]);return c.jsxs(ke.PanelGroup,{id:`aqmx-split-${e}`,direction:"horizontal",onLayout:P,labels:d,className:"aqmx-split","data-aqmx-split":e,children:[T?c.jsxs(ke.Panel,{id:_e,defaultSize:{value:w,unit:"percentage"},minSize:{value:a,unit:"pixels"},maxSize:{value:q.EXPLORER_MAX_PERCENT,unit:"percentage"},collapsible:{from:"end"},pixelAdjustPriority:1,inert:o,className:"aqmx-split-explorer",children:[c.jsx("div",{className:"aqmx-explorer-chrome",children:c.jsx("button",{ref:s,type:"button",className:"aqmx-explorer-close","aria-label":u.hideExplorer,title:u.hideExplorer,"data-testid":"markdown-explorer-split-close",onClick:C,children:c.jsx(Fe,{"aria-hidden":"true"})})}),c.jsx(Me,{value:!E,children:n})]}):null,T?c.jsx(ke.PanelResizeHandle,{id:vt(e),thickness:M,indicator:{visible:!0,thickness:q.SPLIT_HANDLE_PIXELS.gripThickness,length:q.SPLIT_HANDLE_PIXELS.gripLength,barThickness:q.SPLIT_HANDLE_PIXELS.barThickness,barLength:q.SPLIT_HANDLE_PIXELS.barLength},title:u.resizeExplorer,"aria-label":u.resizeExplorer,onDragging:O,inert:o,className:"aqmx-split-handle"}):null,c.jsx(ke.Panel,{id:Et,defaultSize:{value:T?100-w:100,unit:"percentage"},contentOverflow:"hidden",className:"aqmx-split-content",...o?{style:{isolation:"auto"}}:{},children:l})]})};exports.EMPTY_SELECTION=Ce;exports.ExplorerPane=Tr;exports.ExplorerSplit=Fr;exports.SheetNoticeSlotContext=bt;
|