@aiquants/markdown-explorer 0.1.0 → 0.2.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/README.md +31 -13
  3. package/dist/{ExplorerSplit-BESGFcu6.cjs → ExplorerSplit-D2plJRRe.cjs} +1 -1
  4. package/dist/{ExplorerSplit-DwEFmvQM.js → ExplorerSplit-DB37U7Kh.js} +3 -3
  5. package/dist/MultiLayout-DCPDu1-l.js +909 -0
  6. package/dist/MultiLayout-UyWxs6Xy.cjs +1 -0
  7. package/dist/TreeLayout-BoyFelK2.js +22 -0
  8. package/dist/TreeLayout-CLWbWjOc.cjs +1 -0
  9. package/dist/core/config.d.cts +6 -0
  10. package/dist/core/config.d.ts +6 -0
  11. package/dist/core/labels.d.cts +6 -1
  12. package/dist/core/labels.d.ts +6 -1
  13. package/dist/{index-BgkZ9ATV.js → index-BfuAu2GV.js} +947 -901
  14. package/dist/index-Cx3-jSna.cjs +3 -0
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.js +2 -2
  17. package/dist/location-Oo21lTyV.cjs +1 -0
  18. package/dist/{location-Cb2Ak55B.js → location-fVl2R1ee.js} +154 -141
  19. package/dist/sanitizeWorker.cjs +1 -1
  20. package/dist/sanitizeWorker.js +196 -206
  21. package/dist/server.cjs +1 -1
  22. package/dist/server.js +1 -1
  23. package/dist/styles/markdown-explorer.css +1 -1
  24. package/docs/behavior/dom-hooks.md +4 -4
  25. package/docs/behavior/layout.md +21 -9
  26. package/docs/behavior/localization.md +4 -3
  27. package/docs/behavior/security.md +7 -3
  28. package/docs/behavior/url-contract.md +8 -2
  29. package/package.json +5 -5
  30. package/dist/MultiLayout-DxPiARsv.js +0 -896
  31. package/dist/MultiLayout-r_qx1Mfz.cjs +0 -1
  32. package/dist/TreeLayout-9-20bbSM.cjs +0 -1
  33. package/dist/TreeLayout-CW7lgV_e.js +0 -19
  34. package/dist/index-y9tVvDW7.cjs +0 -3
  35. package/dist/location-DWHQYntR.cjs +0 -1
package/dist/server.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./dataRoute-CKbdwkQ7.cjs"),Ze=require("node:crypto"),Se=require("react-router"),ee=require("./location-DWHQYntR.cjs"),te=require("node:fs"),q=require("node:path"),Te=require("node:url"),mt=require("node:worker_threads"),fe=require("node:fs/promises"),pt=require("node:stream");var xe=typeof document<"u"?document.currentScript:null;const Me=Object.freeze({kind:"anonymous"}),ht=Object.freeze({authenticate:async()=>({status:"signed-in",principal:Me}),principalKey:()=>Me.kind,signedOutPage:(e,t)=>new Response(null,{status:401,headers:t})}),wt="application/octet-stream",qe="application/pdf",gt=new Set(["image/png","image/apng","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/x-icon","image/vnd.microsoft.icon","audio/mpeg","audio/mp4","audio/aac","audio/ogg","audio/opus","audio/wav","audio/wave","audio/x-wav","audio/webm","audio/flac","audio/x-flac","audio/x-m4a","video/mp4","video/webm","video/ogg","video/quicktime",qe]),et="default-src 'none'; media-src 'self'; style-src 'unsafe-inline'",Et=`${et}; sandbox`,yt=`${et}; sandbox allow-same-origin`,ve=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u,bt=/^[\t\n\r ]+|[\t\n\r ]+$/gu,Ne=/^[\t ]+|[\t ]+$/gu,St=e=>{const t=[];let r="",n=0;for(;;){for(;n<e.length&&e[n]!=='"'&&e[n]!==",";)r+=e[n],n+=1;if(n<e.length&&e[n]==='"'){const s=n;for(n+=1;n<e.length&&e[n]!=='"';)n+=e[n]==="\\"?2:1;if(n=Math.min(n+1,e.length),r+=e.slice(s,n),n<e.length)continue}if(t.push(r.replace(Ne,"")),r="",n>=e.length)return t;n+=1}},Tt=e=>{const t=e.replace(bt,""),r=t.indexOf("/");if(r<0)return null;const n=t.slice(0,r),s=t.indexOf(";",r+1),o=t.slice(r+1,s<0?t.length:s).replace(/[\t\n\r ]+$/u,"");return ve.test(n)&&ve.test(o)?`${n}/${o}`.toLowerCase():null},xt=e=>{let t=null;for(const r of St(e)){const n=Tt(r);n!==null&&n!=="*/*"&&(t=n)}return t},Ot=/['()*]/gu,Rt=e=>encodeURIComponent(e).replace(Ot,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),_t=Object.freeze({"Cache-Control":"private, max-age=60, stale-while-revalidate=600, no-transform",Vary:"Cookie"}),kt=(e,t)=>{const r=xt(e),n=r!==null&&gt.has(r),s=n&&(r.startsWith("audio/")||r.startsWith("video/"));return{contentType:r===null?wt:r,inline:n,headers:{"X-Content-Type-Options":"nosniff","Content-Disposition":`${n?"inline":"attachment"}; filename*=UTF-8''${Rt(t)}`,...r===qe?{}:{"Content-Security-Policy":s?yt:Et},"Cross-Origin-Resource-Policy":"same-origin"}}},At=/^bytes=(?:(\d+)-(\d*)|-(\d+))$/iu,pe=Object.freeze({kind:"whole"}),Le=Object.freeze({kind:"unsatisfiable"}),Nt=(e,t,r)=>{const n=e.get("Range");if(n===null)return pe;const s=e.get("If-Range");if(s!==null&&s!==r)return pe;const o=At.exec(n);if(o===null)return pe;const[,c,m,g]=o;if(g!==void 0){const h=Number(g);if(h===0)return Le;const A=Math.max(0,t-h);return{kind:"partial",range:{offset:A,length:t-A}}}const x=Number(c),l=m===""?Number.POSITIVE_INFINITY:Number(m);return l<x?pe:x>=t?Le:{kind:"partial",range:{offset:x,length:Math.min(l,t-1)-x+1}}},$e="W/",Pt=e=>{const t=[];let r=0,n=!1;for(let s=0;s<e.length;s+=1)e[s]==='"'?n=!n:e[s]===","&&!n&&(t.push(e.slice(r,s).replace(Ne,"")),r=s+1);return t.push(e.slice(r).replace(Ne,"")),t},je=e=>e.startsWith($e)?e.slice($e.length):e,It=(e,t)=>{if(e===null)return!1;const r=Pt(e);if(r.length===1&&r[0]==="*")return!0;const n=je(t);return r.some(s=>je(s)===n)},Mt=(e,t)=>{let r=t;return e.pipeThrough(new TransformStream({transform:(n,s)=>{const o=n.byteLength>r?n.subarray(0,r):n;r-=o.byteLength,s.enqueue(o),r===0&&s.terminate()},flush:n=>{r>0&&n.error(new RangeError("[markdown-explorer] the asset ended before its declared length"))}}))},Oe=async(e,t,r,n,s)=>{if(n!==null&&r.set("Content-Length",String(n)),e.method.toUpperCase()==="HEAD")return new Response(null,{status:t,headers:r});const o=await s();return new Response(n===null?o:Mt(o,n),{status:t,headers:r})},vt=(e,t)=>{const r=new Headers(e);for(const[n,s]of Object.entries({"Accept-Ranges":"bytes","Content-Range":`bytes */${t}`,"Cache-Control":"private, no-store","X-Content-Type-Options":"nosniff"}))r.set(n,s);return new Response(null,{status:416,headers:r})},Lt=async(e,t,r)=>{const n=`"${t.version}"`,s=kt(t.contentType,t.name),o=new Headers(r);for(const[g,x]of Object.entries({...s.headers,..._t,ETag:n}))o.set(g,x);if(It(e.headers.get("If-None-Match"),n))return new Response(null,{status:304,headers:o});if(o.set("Content-Type",s.contentType),t.size===null)return Oe(e,200,o,null,()=>t.open(null));if(t.size===0)return o.set("Content-Length","0"),new Response(null,{status:200,headers:o});o.set("Accept-Ranges","bytes");const c=Nt(e.headers,t.size,n);if(c.kind==="unsatisfiable")return vt(r,t.size);if(c.kind==="whole")return Oe(e,200,o,t.size,()=>t.open(null));const{range:m}=c;return o.set("Content-Range",`bytes ${m.offset}-${m.offset+m.length-1}/${t.size}`),Oe(e,206,o,m.length,()=>t.open(m))},Re=(e,t)=>{const r=new AbortController,n=t(AbortSignal.any([e.signal,r.signal]));return new Promise(s=>{let o;const c=setTimeout(()=>{s(e.late),o=setTimeout(()=>r.abort(),e.handOverMs)},e.timeoutMs),m=()=>{clearTimeout(c),clearTimeout(o)};n.then(g=>{m(),s(g)},()=>{m(),s(e.late)})})},$t=Object.freeze({error:(e,t)=>{console.error(e,t)}}),tt=Symbol.for("@aiquants/markdown-explorer:ExplorerError");class me extends Error{reason;code;constructor(t,r={}){if(!y.isExplorerFailureReason(t))throw new RangeError(`[markdown-explorer] ExplorerError needs a failure reason; got ${JSON.stringify(t)}`);if(r.code!==void 0&&!y.isExplorerFailureCode(r.code))throw new RangeError(`[markdown-explorer] an ExplorerError code must be 1 to 64 lowercase letters, digits or hyphens; got ${JSON.stringify(r.code)}`);super(`[markdown-explorer] ${t}`,r.cause===void 0?void 0:{cause:r.cause}),this.name="ExplorerError",this.reason=t,this.code=r.code,Object.defineProperty(this,tt,{value:!0})}}const jt=e=>e instanceof Error&&Object.hasOwn(e,tt)&&y.isExplorerFailureReason(e.reason),Dt=e=>typeof e=="object"&&e!==null&&e.name==="AbortError",Pe=(e,t,r)=>{try{e.error(t,r)}catch(n){console.error("[markdown-explorer] the logger threw while reporting a failure",{operation:r.operation,error:n})}},ne=(e,t)=>Pe(e,`[markdown-explorer] ${t.operation} failed`,t),zt=(e,t)=>Pe(e,`[markdown-explorer] ${t.operation} left out an entry`,t),Ct=(e,t)=>Pe(e,`[markdown-explorer] ${t.operation} refused a path the deny rules match`,{...t,error:new RangeError("[markdown-explorer] the path matches a deny rule")}),De=(e,t)=>{e===null||typeof e!="object"&&typeof e!="function"||Promise.resolve(e).then(void 0,t)},re=(e,t,r,n)=>jt(e)?y.failureOf(e.reason,e.code):(Dt(e)||r.aborted||ne(n,{...t,error:e}),{reason:"failed"}),ze=(e,t)=>{if(!Number.isSafeInteger(t)||t<=0)throw new RangeError(`[markdown-explorer] a cache ${e} must be a positive integer; got ${String(t)}`)},rt=(e,t)=>{ze("capacity",e),t!==void 0&&ze("weight budget",t.max);const r=new Map;let n=0;const s=o=>{const c=r.get(o);c!==void 0&&(r.delete(o),n-=c.weight)};return{get:o=>{const c=r.get(o);if(c!==void 0)return r.delete(o),r.set(o,c),c.value},set:(o,c)=>{s(o);const m=t===void 0?0:t.of(o,c);if(!(t!==void 0&&m>t.max)){r.set(o,{value:c,weight:m}),n+=m;for(const g of r.keys()){if(r.size<=e&&(t===void 0||n<=t.max))break;s(g)}}},delete:s,size:()=>r.size,weight:()=>n}},nt=e=>Math.max(1,e-1),Ht=2147483647,Ce=Object.freeze({status:"aborted"}),se=(e,t,r)=>{const n=(e.get(t)??0)+r;n===0?e.delete(t):e.set(t,n)},ce=(e,t,r)=>{if(!Number.isSafeInteger(t)||t<=0||t>r)throw new RangeError(`[markdown-explorer] a worker pool's ${e} must be an integer in 1..${String(r)}; got ${String(t)}`)},Bt=e=>e!==null&&typeof e=="object"&&e.ready===!0&&!("id"in e),Ft=(e,t)=>e!==null&&typeof e=="object"&&e.id===t&&"output"in e,Ut=({url:e,size:t,deadlineMs:r,jobsPerScope:n,maxQueuedJobs:s,heapLimits:o})=>{ce("size",t,Number.MAX_SAFE_INTEGER),ce("deadline",r,Ht),ce("jobsPerScope",n,Number.MAX_SAFE_INTEGER),ce("maxQueuedJobs",s,Number.MAX_SAFE_INTEGER),ce("maxOldGenerationSizeMb",o.maxOldGenerationSizeMb,Number.MAX_SAFE_INTEGER),ce("maxYoungGenerationSizeMb",o.maxYoungGenerationSizeMb,Number.MAX_SAFE_INTEGER);const c=Object.freeze({maxOldGenerationSizeMb:o.maxOldGenerationSizeMb,maxYoungGenerationSizeMb:o.maxYoungGenerationSizeMb}),m=new Set,g=[],x=new Map,l=new Map,h=nt(t);let A=0;const k=(u,a)=>{const{job:E}=u;u.timer!==null&&clearTimeout(u.timer),u.timer=null,u.job=null,u.sent=!1,E!==null&&(se(x,E.scope,-1),se(l,E.scope,-1),E.settle(a))},I=u=>{const[a]=g.splice(u,1);a?.detach()},R=()=>{let u=-1,a=h,E=Number.POSITIVE_INFINITY;for(const[S,_]of g.entries()){const P=x.get(_.scope)??0,C=l.get(_.scope)??0;(P<a||P===a&&u>=0&&C<E)&&(u=S,a=P,E=C)}return u},O=(u,a)=>{m.has(u)&&(m.delete(u),k(u,a),u.worker.terminate().catch(()=>{}),D())},L=u=>{u.timer=setTimeout(()=>{O(u,{status:"timeout"})},r)},b=(u,a)=>u.sent?{status:"crashed",error:a}:{status:"unavailable",error:a},N=(u,a)=>{u.sent=!0,L(u);try{u.worker.postMessage({id:a.id,input:a.input})}catch(E){k(u,{status:"crashed",error:E}),u.worker.unref()}},z=()=>{const u={worker:new mt.Worker(e,{resourceLimits:c}),job:null,sent:!1,timer:null,ready:!1};return u.worker.unref(),u.timer=setTimeout(()=>{O(u,{status:"unavailable",error:new Error(`[markdown-explorer] a worker did not start within ${String(r)} ms`)})},r),u.worker.on("message",a=>{if(!u.ready&&Bt(a)){u.ready=!0,u.timer!==null&&clearTimeout(u.timer),u.timer=null,u.job===null?u.worker.unref():N(u,u.job),u.job===null&&D();return}const{job:E}=u;if(E===null||!Ft(a,E.id)){O(u,b(u,new Error("[markdown-explorer] a worker sent a message that answers no job")));return}k(u,{status:"done",output:a.output}),u.worker.unref(),D()}),u.worker.on("error",a=>{O(u,b(u,a))}),u.worker.on("messageerror",a=>{O(u,b(u,a))}),u.worker.on("exit",a=>{O(u,b(u,new Error(`[markdown-explorer] a worker exited with code ${String(a)}`)))}),m.add(u),u},D=()=>{for(;;){const u=R(),a=g[u];if(a===void 0)return;let E;for(const _ of m)if(_.job===null){E=_;break}if(E===void 0&&m.size<t)try{E=z()}catch(_){I(u),se(l,a.scope,-1),a.settle({status:"unavailable",error:_});continue}if(E===void 0)return;I(u),se(x,a.scope,1);const S=E;S.job=a,S.worker.ref(),S.ready&&N(S,a)}};return{run:(u,{scope:a,signal:E})=>new Promise(S=>{if(E.aborted){S(Ce);return}if((l.get(a)??0)>=n){S({status:"refused",limit:"scope"});return}A+=1;const _={id:A,input:u,scope:a,settle:S,detach:()=>{}};g.push(_),se(l,a,1),D();const P=g.indexOf(_);if(P<0)return;if(g.length>s){I(P),se(l,a,-1),S({status:"refused",limit:"queue"});return}const C=()=>{const M=g.indexOf(_);M<0||(I(M),se(l,a,-1),S(Ce))};E.addEventListener("abort",C,{once:!0}),_.detach=()=>{E.removeEventListener("abort",C)}}),workers:()=>m.size}},Ie=1024*1024,Xt=3e4,Gt=4*Ie,Jt=64*Ie,Yt=3,Wt=2,Kt=(e,t)=>e+nt(t)+Yt,Vt=4,Qt=32,Zt=512,qt=64,er=4096,tr=32,He=4096,rr=4,ot=({workerHeapMb:e,maxHtmlBytes:t})=>Math.floor(((e-qt)*Ie-t*tr)/er),nr=({maxHtmlBytes:e})=>e,or=({maxHtmlBytes:e})=>rr*e,sr=1024,ir=2147483647,ar=64,cr=2**29,ur=1024*1024,lr=64,Be=Object.freeze({status:"rejected",reason:"too-large",cause:null}),_e=Object.freeze({status:"rejected",reason:"failed",cause:null}),ie=(e,t,r,n)=>{if(t===void 0)return r;if(typeof t!="number")throw new TypeError(`[markdown-explorer] sanitizer.${e} must be a number; got ${typeof t}`);if(!Number.isSafeInteger(t)||t<=0||t>n)throw new RangeError(`[markdown-explorer] sanitizer.${e} must be an integer in 1..${String(n)}; got ${String(t)}`);return t},dr=(e,t)=>{if(e!==void 0&&(e===null||typeof e!="object"))throw new TypeError("[markdown-explorer] sanitizer must be an object of { workers, deadlineMs, maxHtmlBytes, cacheBytes, workerHeapMb, jobsPerScope, maxQueuedJobs }");const{workers:r,deadlineMs:n,maxHtmlBytes:s,cacheBytes:o,workerHeapMb:c,jobsPerScope:m,maxQueuedJobs:g}=e??{},x=ie("workers",r,Wt,ar),l=ie("jobsPerScope",m,Kt(t,x),Number.MAX_SAFE_INTEGER),h=Object.freeze({workers:x,deadlineMs:ie("deadlineMs",n,Xt,ir),maxHtmlBytes:ie("maxHtmlBytes",s,Gt,cr),cacheBytes:ie("cacheBytes",o,Jt,Number.MAX_SAFE_INTEGER),workerHeapMb:ie("workerHeapMb",c,Zt,ur),jobsPerScope:l,maxQueuedJobs:ie("maxQueuedJobs",g,Vt*l,Number.MAX_SAFE_INTEGER)});if(h.jobsPerScope<t)throw new RangeError(`[markdown-explorer] sanitizer.jobsPerScope must be at least multiView.maxPanels (${String(t)}), because a page sends the document of every panel to the sanitizer at once for one reader; got ${String(h.jobsPerScope)}`);if(h.maxQueuedJobs<t)throw new RangeError(`[markdown-explorer] sanitizer.maxQueuedJobs must be at least multiView.maxPanels (${String(t)}), because a reader whose page finds every worker busy waits with the document of every panel; got ${String(h.maxQueuedJobs)}`);if(ot(h)<He)throw new RangeError(`[markdown-explorer] sanitizer.workerHeapMb (${String(h.workerHeapMb)} MiB) must leave room for ${String(He)} parsed nodes beside HTML of sanitizer.maxHtmlBytes (${String(h.maxHtmlBytes)} bytes); raise workerHeapMb or lower maxHtmlBytes`);return h},fr=()=>{const e=typeof document>"u"?require("url").pathToFileURL(__filename).href:xe&&xe.tagName.toUpperCase()==="SCRIPT"&&xe.src||new URL("server.cjs",document.baseURI).href,t=new URL(`./sanitizeWorker${q.extname(Te.fileURLToPath(e))}`,e);if(!te.existsSync(Te.fileURLToPath(t)))throw new Error(`[markdown-explorer] the HTML sanitizer worker is missing: ${Te.fileURLToPath(t)}`);return t},Fe=new Map,mr=(e,t)=>{const r=[e.href,t.workers,t.deadlineMs,t.workerHeapMb,t.jobsPerScope,t.maxQueuedJobs].map(String).join("\0");let n=Fe.get(r);return n===void 0&&(n=Ut({url:e,size:t.workers,deadlineMs:t.deadlineMs,jobsPerScope:t.jobsPerScope,maxQueuedJobs:t.maxQueuedJobs,heapLimits:{maxOldGenerationSizeMb:t.workerHeapMb,maxYoungGenerationSizeMb:Qt}}),Fe.set(r,n)),n},pr=e=>{if(e===null||typeof e!="object")return!1;const{status:t,html:r,message:n}=e;return t==="sanitized"&&typeof r=="string"||t==="too-large"||t==="error"&&typeof n=="string"},hr=e=>e instanceof Error&&e.code==="ERR_WORKER_OUT_OF_MEMORY",wr=({iframeHosts:e,dataPath:t,options:r,pool:n})=>{const s=Object.freeze([...e]),o=ot(r),c=nr(r),m=or(r),g=rt(sr,{max:r.cacheBytes,of:(R,O)=>2*R.length+(O.status==="sanitized"?2*O.html.length:lr)}),x=new Map,l=new Map,h=R=>{x.get(R.key)===R&&x.delete(R.key);const O=l.get(R.hash);O?.delete(R),O?.size===0&&l.delete(R.hash)},A=async(R,O,L)=>{const b=await n.run({html:R,iframeHosts:s,dataPath:t,maxNodes:o,maxAttributeChars:c,maxSanitizedChars:m},{scope:O,signal:L});if(b.status==="refused"){const z=b.limit==="scope"?`its reader already has ${String(r.jobsPerScope)} documents being sanitized or waiting`:`${String(r.maxQueuedJobs)} documents are already waiting`;return{outcome:{status:"rejected",reason:"failed",cause:new Error(`[markdown-explorer] the HTML sanitizer refused a document: ${z}`)},lasting:!1}}if(b.status==="aborted")return{outcome:_e,lasting:!1};if(b.status==="timeout")return{outcome:{status:"rejected",reason:"too-large",cause:new Error(`[markdown-explorer] the HTML sanitizer did not finish within ${String(r.deadlineMs)} ms`)},lasting:!0};if(b.status==="unavailable")return{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker could not start",{cause:b.error})},lasting:!1};if(b.status==="crashed"&&hr(b.error))return{outcome:{status:"rejected",reason:"too-large",cause:new Error(`[markdown-explorer] the HTML sanitizer ran out of its ${String(r.workerHeapMb)} MiB worker heap`,{cause:b.error})},lasting:!0};if(b.status==="crashed")return{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker failed",{cause:b.error})},lasting:!0};const{output:N}=b;return pr(N)?N.status==="too-large"?{outcome:Be,lasting:!0}:N.status==="error"?{outcome:{status:"rejected",reason:"failed",cause:new Error(`[markdown-explorer] the HTML sanitizer failed: ${N.message}`)},lasting:!0}:N.html.length>m?{outcome:{status:"rejected",reason:"too-large",cause:new Error(`[markdown-explorer] the HTML sanitizer's output of ${String(N.html.length)} characters exceeds its limit of ${String(m)}`)},lasting:!0}:{outcome:{status:"sanitized",html:N.html},lasting:!0}:{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker answered something that is not an outcome")},lasting:!0}},k=(R,O,L,b)=>{let N=()=>{};const z=new Promise(a=>{N=a}),D={hash:O,key:L,outcome:z,answer:N,controller:new AbortController,waiters:0};x.set(L,D);const u=l.get(O);return u===void 0?l.set(O,new Set([D])):u.add(D),A(R,b,D.controller.signal).catch(a=>({outcome:{status:"rejected",reason:"failed",cause:a instanceof Error?a:new Error(String(a))},lasting:!0})).then(({outcome:a,lasting:E})=>{if(h(D),D.answer(a),!E)return;const S=g.get(O),_=S??(a.status==="rejected"?{...a,cause:null}:a);S===void 0&&g.set(O,_);for(const P of l.get(O)??[])h(P),P.answer(_),P.controller.abort()}),D},I=(R,O)=>new Promise(L=>{R.waiters+=1;const b=()=>{R.waiters-=1,L(_e),!(R.waiters>0)&&(h(R),R.controller.abort())};O.addEventListener("abort",b,{once:!0}),R.outcome.then(N=>{O.removeEventListener("abort",b),L(N)})});return(R,{scope:O,signal:L})=>{if(R.length>r.maxHtmlBytes||Buffer.byteLength(R,"utf8")>r.maxHtmlBytes)return Promise.resolve(Be);const b=Ze.createHash("sha256").update(R,"utf8").digest("base64"),N=g.get(b);if(N!==void 0)return Promise.resolve(N);if(L.aborted)return Promise.resolve(_e);const z=`${b}\0${O}`,D=x.get(z);return I(D===void 0?k(R,b,z,O):D,L)}},be=e=>({result:e,json:JSON.stringify(e)}),ke=Object.freeze(be(Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}))),gr=e=>e.status==="ok"&&e.entries.length>0,Er=({ttlMs:e,maxEntries:t,maxBytes:r,now:n})=>{const s=rt(t,{max:r,of:(l,h)=>2*h.tree.json.length}),o=new Map,c=new Map,m=(l,h)=>{const A=new AbortController,k={waiters:0,superseded:!1,started:!1,loadTree:h},I=c.get(l),R=(z,D)=>{const u=be(z);return!(k.superseded||A.signal.aborted)&&gr(z)&&s.set(l,{tree:u,loadedAt:D}),u},L=(async()=>{if(I!==void 0&&await I,A.signal.aborted)return ke;const z=n();return k.started=!0,R(await k.loadTree(A.signal,z),z)})().finally(()=>{o.get(l)===b&&o.delete(l)}),b={promise:L,controller:A,state:k};o.set(l,b);const N=L.then(()=>{},()=>{});return c.set(l,N),N.then(()=>{c.get(l)===N&&c.delete(l)}),b},g=(l,h,A)=>{h.state.waiters+=1;const k=()=>{h.state.waiters-=1,!(h.state.waiters>0)&&(o.get(l)===h&&o.delete(l),h.controller.abort())};return A.addEventListener("abort",k,{once:!0}),h.promise.finally(()=>{A.removeEventListener("abort",k)})},x=l=>{s.delete(l);const h=o.get(l);h?.state.started&&(h.state.superseded=!0,o.delete(l))};return{load:(l,h,A)=>{if(h.aborted)return Promise.resolve(ke);const k=s.get(l);if(k!==void 0){if(n()-k.loadedAt<e)return Promise.resolve(k.tree);s.delete(l)}const I=o.get(l);return g(l,I===void 0?m(l,A):I,h)},refresh:(l,h,A)=>{if(h.aborted)return Promise.resolve(ke);x(l);const k=o.get(l);return k===void 0?g(l,m(l,A),h):(k.state.loadTree=A,g(l,k,h))},forget:x}},yr=e=>({load:(t,r,n)=>n(r,e()).then(be),refresh:(t,r,n)=>n(r,e()).then(be),forget:()=>{}}),v=e=>{throw new TypeError(`[markdown-explorer] ${e}`)},br=e=>{if(e===null||typeof e!="object")return null;const{name:t,path:r}=e;return typeof t!="string"||typeof r!="string"?null:t===""?{path:r,reason:"an empty name"}:y.isAcceptableDocumentPath(r)?null:{path:r,reason:"a path the browser cannot address (empty, too long, a lone surrogate, a control character or a backslash)"}},Sr=(e,t,r,n,s)=>{const o=new Set,c=g=>{if(!Array.isArray(g))return v("a source returned entries that are not an array");const x=[];for(const l of g){const h=m(l);h!==null&&x.push(h)}return x},m=g=>{const x=br(g);if(x!==null)return n(x),null;const l=y.entryViolation(g);if(l!==null)return v(l);const h=g;if(o.has(h))return v("a source returned entries that contain themselves");const{name:A,path:k,type:I,mimeType:R,children:O,lazy:L}=h;if(t.deniesName(A)||t.deniesPath(k))return null;if(!s(k))return n({path:k,reason:"a path outside the source's boundary"}),null;const b=R===void 0?{name:A,path:k}:{name:A,path:k,mimeType:R};if(I==="file")return{...b,type:I};if(L===!0)return r?{...b,type:I,lazy:!0,children:[]}:v("a lazy directory came from a source without a children function");if(O===void 0)return{...b,type:I};o.add(h);const N=c(O);return o.delete(h),{...b,type:I,children:N}};return c(e)},Tr=/^[\x21\x23-\x7E]{1,256}$/u,st=e=>typeof e=="string"&&Tr.test(e),xr=new Set(["text","image","media","file"]),Or=e=>typeof e=="string"&&xr.has(e),Rr=(e,t)=>{if(e!==null&&typeof e=="object"){const s=e,{kind:o}=s;if(Or(o)){if(Object.hasOwn(s,"url"))return v(`a ${o} document carries its version, not a url`);if(typeof s.name!="string")return v("a document needs a name string");if(!st(s.version))return v(`a ${o} document needs a version of 1 to 256 visible ASCII characters other than '"'`);const c=t(s.version);switch(o){case"image":case"file":return{kind:o,name:s.name,url:c};case"media":{const{mediaType:m}=s;return y.isExplorerMediaType(m)?{kind:o,name:s.name,url:c,mediaType:m}:v(`unknown media type ${typeof m=="string"?JSON.stringify(m.slice(0,64)):typeof m}`)}case"text":return typeof s.text!="string"||typeof s.truncated!="boolean"?v("a text document needs text and truncated"):{kind:o,name:s.name,text:s.text,truncated:s.truncated,url:c}}}}const r=y.documentViolation(e);if(r!==null)return v(r);const n=e;switch(n.kind){case"failure":{const{reason:s,code:o}=n.failure;return{kind:"failure",failure:y.failureOf(s,o)}}case"markdown":return n.headings.length>y.EXPLORER_MAX_HEADINGS?{kind:"failure",failure:y.failureOf("too-large")}:{kind:"unsanitized-markdown",name:n.name,html:n.htmlContent,headings:n.headings.map(({text:s,depth:o,id:c})=>({text:s,depth:o,id:c}))}}},_r=e=>{if(e===null||typeof e!="object")return v("an asset file must be an object");const{name:t,contentType:r,size:n,version:s,open:o}=e;return typeof t!="string"||t===""?v("an asset file needs a non-empty name"):typeof r!="string"?v("an asset file needs a contentType string ('' when unknown)"):n!==null&&!(typeof n=="number"&&Number.isSafeInteger(n)&&n>=0)?v("an asset file's size must be null or a non-negative safe integer"):st(s)?typeof o!="function"?v("an asset file needs an open function"):Object.freeze({name:t,contentType:r,size:n,version:s,open:o}):v(`an asset file needs a version of 1 to 256 visible ASCII characters other than '"'`)},kr=e=>Array.isArray(e)?e.map(t=>{if(t===null||typeof t!="object")return v("a notice must be an object");const{id:r,tone:n,title:s,body:o,action:c}=t;if(typeof r!="string"||r===""||typeof s!="string")return v("a notice needs an id and a title");if(!y.isExplorerNoticeTone(n))return v(`unknown notice tone ${typeof n=="string"?JSON.stringify(n.slice(0,64)):typeof n}`);if(o!==void 0&&typeof o!="string")return v("a notice body must be a string");const g={id:r,tone:n,title:s,...o===void 0?{}:{body:o}};if(c===void 0)return g;if(c===null||typeof c!="object")return v("a notice action must be an object");const{label:x,href:l}=c;return typeof x!="string"||!y.isAcceptableUrl(l,y.EXPLORER_LINK_PROTOCOLS)?v("a notice action needs a label and an http(s), mailto or relative href"):{...g,action:{label:x,href:l}}}):v("notices must be an array"),Ar=4e3,he=Object.freeze({ttlMs:3e5,maxEntries:64,maxBytes:64*1024*1024}),Ue=32,it="private, no-store",Nr=Object.freeze({"Content-Type":"application/json; charset=utf-8","Cache-Control":it,"X-Content-Type-Options":"nosniff","Content-Security-Policy":"default-src 'none'; frame-ancestors 'none'; sandbox","Cross-Origin-Resource-Policy":"same-origin"}),Pr=22,Ir=2147483647,Ae=Object.freeze([]),Xe=Object.freeze(["contains","confirm"]),J=(e,t,r)=>{if(!(r&&t===void 0)&&typeof t!="function")throw new TypeError(`[markdown-explorer] ${e} must be a function; got ${typeof t}`)},ye=(e,t,r)=>{if(typeof t!="number")throw new TypeError(`[markdown-explorer] ${e} must be a number; got ${typeof t}`);if(!Number.isSafeInteger(t)||t<=0||t>r)throw new RangeError(`[markdown-explorer] ${e} must be an integer in 1..${String(r)}; got ${String(t)}`);return t},Mr=e=>{if(e===null||typeof e!="object"||!Object.isFrozen(e))throw new TypeError("[markdown-explorer] config must be the value returned by defineExplorerConfig");return ee.defineExplorerConfig(e)},vr=e=>{if(typeof e!="string")throw new TypeError(`[markdown-explorer] scopeSecret must be a string; got ${typeof e}`);if(e.length<Ue)throw new RangeError(`[markdown-explorer] scopeSecret must have at least ${String(Ue)} characters; got ${String(e.length)}`);return e},Lr=(e,t)=>{if(!ee.isPlainObject(t))throw new TypeError(`[markdown-explorer] ${e}.boundary must be a plain object { contains, confirm? }`);for(const r of Object.keys(t))if(!Xe.includes(r))throw new RangeError(`[markdown-explorer] ${e}.boundary.${r} is not an option; expected ${Xe.join(", ")}`);J(`${e}.boundary.contains`,t.contains,!1),J(`${e}.boundary.confirm`,t.confirm,!0)},$r=e=>{if(!Array.isArray(e))throw new TypeError("[markdown-explorer] sources must be an array");const t=e;if(t.length===0)throw new RangeError("[markdown-explorer] sources must hold at least one source");const r=new Set;for(const[n,s]of t.entries()){if(s===null||typeof s!="object")throw new TypeError(`[markdown-explorer] sources[${String(n)}] must be an object`);const{id:o,label:c,boundary:m,tree:g,children:x,cacheScope:l}=s;if(!ee.isExplorerSourceId(o))throw new RangeError(`[markdown-explorer] sources[${String(n)}].id must use lowercase letters, digits and "-" and start with a letter or digit; got ${typeof o=="string"?JSON.stringify(o):typeof o}`);const h=`source ${JSON.stringify(o)}`;if(r.has(o))throw new RangeError(`[markdown-explorer] source ids must be unique; ${JSON.stringify(o)} repeats at sources[${String(n)}]`);if(r.add(o),typeof c!="string"&&typeof c!="function")throw new TypeError(`[markdown-explorer] ${h}.label must be a string or a function`);if(typeof c=="string"&&c.trim()==="")throw new RangeError(`[markdown-explorer] ${h}.label must not be blank`);if(Lr(h,m),J(`${h}.tree`,g,!1),J(`${h}.children`,x,!0),l!==void 0&&l!=="principal"&&l!=="shared")throw new RangeError(`[markdown-explorer] ${h}.cacheScope must be "principal" or "shared"; got ${JSON.stringify(l)}`)}return t},jr=e=>{if(e===!1)return!1;if(e===void 0)return he;if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] treeCache must be { ttlMs, maxEntries, maxBytes } or false");const{ttlMs:t,maxEntries:r,maxBytes:n}=e;return{ttlMs:t===void 0?he.ttlMs:ye("treeCache.ttlMs",t,Number.MAX_SAFE_INTEGER),maxEntries:r===void 0?he.maxEntries:ye("treeCache.maxEntries",r,Number.MAX_SAFE_INTEGER),maxBytes:n===void 0?he.maxBytes:ye("treeCache.maxBytes",n,Number.MAX_SAFE_INTEGER)}},Ge=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] authenticate must resolve to { status, ... }");const{status:t}=e;if(t!=="signed-in"&&t!=="signed-out"&&t!=="forbidden")throw new TypeError(`[markdown-explorer] authenticate resolved to an unknown status ${JSON.stringify(t)}`);return e},Je=(e,t)=>{if(!(t instanceof Response))throw new TypeError(`[markdown-explorer] ${e} must return a Response`);return t},Ye=(e,t)=>{if(typeof t!="string"||t==="")throw new TypeError("[markdown-explorer] principalKey must return a non-empty string");return Ze.createHmac("sha256",e).update(t,"utf8").digest("base64url").slice(0,Pr)},Dr=e=>e.view==="multi"?e.docs:e.doc===null?[]:[e.doc],we=(e,t)=>{const r=e.getAll(t),[n]=r;return r.length===1&&n!==void 0&&n!==""?n:null},ue=(e,t,r,n={})=>{const s=new Headers(r);for(const[o,c]of Object.entries({...Nr,...n}))s.set(o,c);return new Response(t,{status:e,headers:s})},U=(e,t,r)=>ue(y.EXPLORER_FAILURE_STATUS[e.reason],JSON.stringify({failure:e}),t,r),We=e=>{if(e.headers.get(y.EXPLORER_REFRESH_HEADER)!==y.EXPLORER_REFRESH_HEADER_VALUE)return!1;const t=e.headers.get("Sec-Fetch-Site");return t===null||t==="same-origin"},zr=({parentHeaders:e,loaderHeaders:t,errorHeaders:r})=>{const n=new Headers,s=r===void 0?[e,t]:[e,t,r];for(const o of s)for(const[c,m]of o)c!=="set-cookie"&&n.set(c,m);return n},Cr=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the server configuration must be an object");const t=Mr(e.config),r=vr(e.scopeSecret);J("authenticate",e.authenticate,!1),J("principalKey",e.principalKey,!1),J("document",e.document,!1),J("asset",e.asset,!1),J("signedOutPage",e.signedOutPage,!1),J("forbiddenPage",e.forbiddenPage,!0),J("notices",e.notices,!0),J("onTreeRefreshed",e.onTreeRefreshed,!0);const n=$r(e.sources),s=ee.withExplorerSources(t,n.map(i=>i.id)),o=e.logger;if(o!==void 0&&(o===null||typeof o!="object"||typeof o.error!="function"))throw new TypeError("[markdown-explorer] logger must be an object with an error function");const c=e.logger===void 0?$t:e.logger,m=y.resolvePathRules(e.deny),g=e.deferredTimeoutMs===void 0?Ar:ye("deferredTimeoutMs",e.deferredTimeoutMs,Ir),x=jr(e.treeCache),l=()=>Date.now(),h=x===!1?yr(l):Er({...x,now:l}),A=dr(e.sanitizer,t.multiView.maxPanels),k=wr({iframeHosts:t.iframeHosts,dataPath:t.dataPath,options:A,pool:mr(fr(),A)}),I=new Map(n.map(i=>[i.id,i])),R=ee.documentStyleNames(t),{authenticate:O,principalKey:L,signedOutPage:b,forbiddenPage:N,onTreeRefreshed:z}=e,D=(i,w)=>{if(typeof i.label=="string")return i.label;const d=i.label(w);if(typeof d!="string"||d.trim()==="")throw new TypeError(`[markdown-explorer] the label of source ${JSON.stringify(i.id)} must be a non-blank string`);return d},u=(i,w)=>i.cacheScope==="shared"?i.id:`${i.id}\0${w}`,a=(i,w)=>{const d=f=>ne(c,{operation:"boundary",sourceId:i.id,path:w,error:f});let p;try{p=i.boundary.contains(w)}catch(f){return d(f),!1}return typeof p=="boolean"?p:(De(p,d),d(new TypeError(`[markdown-explorer] boundary.contains of source ${JSON.stringify(i.id)} must return a boolean; got ${typeof p}`)),!1)},E=async(i,w,d)=>{const{confirm:p}=i.boundary;if(p===void 0)return{status:"inside",readPath:d};let f;try{f=await p(w,d)}catch(V){return{status:"error",failure:re(V,{operation:"boundary",sourceId:i.id,path:d},w.signal,c)}}const T=V=>(ne(c,{operation:"boundary",sourceId:i.id,path:d,error:new TypeError(`[markdown-explorer] boundary.confirm of source ${JSON.stringify(i.id)} ${V}`)}),{status:"outside"});if(f===null||typeof f!="object")return T(`must resolve to { inside, readPath? }; got ${f===null?"null":typeof f}`);const{inside:j,readPath:H}=f;return j===!1?{status:"outside"}:j!==!0||typeof H!="string"?T("must resolve to { inside: false } or { inside: true, readPath: string }"):!y.isAcceptableDocumentPath(H)||m.deniesPath(H)?(ne(c,{operation:"boundary",sourceId:i.id,path:d,error:new RangeError(`[markdown-explorer] boundary.confirm of source ${JSON.stringify(i.id)} answered a readPath the explorer does not serve (unacceptable or denied)`)}),{status:"error",failure:{reason:"failed"}}):{status:"inside",readPath:H}},S=async(i,w)=>{const d=n.filter(f=>a(f,w));if(d.length===0)return{status:"error",failure:{reason:"forbidden"}};if(d.some(f=>f.boundary.confirm===void 0))return{status:"inside",readPath:w};let p=null;for(const f of d){const T=await E(f,i,w);if(T.status==="inside")return T;T.status==="error"&&p===null&&(p=T.failure)}return{status:"error",failure:p===null?{reason:"forbidden"}:p}},_=(i,w,d)=>{const p=({path:f,reason:T})=>zt(c,{operation:d.operation,sourceId:d.sourceId,path:f,error:new TypeError(`[markdown-explorer] an entry with ${T} was left out`)});try{return{status:"ok",entries:Sr(i,m,w.children!==void 0,p,f=>a(w,f))}}catch(f){return ne(c,{...d,error:f}),{status:"error",failure:{reason:"failed"}}}},P=async(i,w,d)=>{let p;try{p=await i.tree(w)}catch(T){return{status:"error",failure:re(T,{operation:"tree",sourceId:i.id},w.signal,c)}}const f=_(p,i,{operation:"tree",sourceId:i.id});return f.status==="ok"?{status:"ok",entries:f.entries,loadedAt:d}:f},C=(i,w,d,p)=>(f,T)=>P(i,{principal:w,request:d,signal:f,refresh:p},T),M=(i,w,d,p,f)=>h.load(u(i,d),f,C(i,w,p,!1)),X=(i,w,d,p)=>h.refresh(u(i,d),p.signal,C(i,w,p,!0)),G=(i,w)=>{if(z===void 0)return;const d=p=>ne(c,{operation:"refresh",sourceId:i.id,error:p});try{De(z(w),d)}catch(p){d(p)}},F=async(i,w,d,p)=>{if(m.deniesPath(p)||!a(i,p))return{status:"error",failure:{reason:"forbidden"}};const f=await E(i,d,p);if(f.status==="outside")return{status:"error",failure:{reason:"forbidden"}};if(f.status==="error")return{status:"error",failure:f.failure};let T;try{T=await w(d,p,f.readPath)}catch(j){return{status:"error",failure:re(j,{operation:"children",sourceId:i.id,path:p},d.signal,c)}}return _(T,i,{operation:"children",sourceId:i.id,path:p})},Z=async(i,w,d)=>{if(m.deniesPath(d))return y.failureDocument("forbidden");const p=await S(i,d);if(p.status==="error")return{kind:"failure",failure:p.failure};let f;try{f=await e.document(i,d,p.readPath)}catch(H){return{kind:"failure",failure:re(H,{operation:"document",path:d},i.signal,c)}}let T;try{T=Rr(f,H=>y.explorerAssetHref(t.dataPath,d,H))}catch(H){return ne(c,{operation:"document",path:d,error:H}),y.failureDocument("failed")}if(T.kind!=="unsanitized-markdown")return T;const j=await k(T.html,{scope:w,signal:i.signal});return j.status==="sanitized"?{kind:"markdown",name:T.name,htmlContent:j.html,headings:T.headings}:(j.cause!==null&&ne(c,{operation:"document",path:d,error:j.cause}),y.failureDocument(j.reason))},$=async i=>{if(e.notices===void 0)return Ae;try{return kr(await e.notices(i))}catch(w){return re(w,{operation:"notices"},i.signal,c),Ae}},Y=async(i,w,d)=>{const p=we(w,y.EXPLORER_DATA_QUERY.path);if(p===null||!y.isAcceptableDocumentPath(p))return U({reason:"invalid"},d);if(m.deniesPath(p))return Ct(c,{operation:"asset",path:p}),U({reason:"forbidden"},d);const f=await S(i,p);if(f.status==="error")return U(f.failure,d);try{const T=_r(await e.asset(i,p,f.readPath));return await Lt(i.request,T,d)}catch(T){return U(re(T,{operation:"asset",path:p},i.signal,c),d)}},W=async({request:i,url:w,params:d})=>{const p=Ge(await O(i)),f=new Headers(p.headers);if(f.set("Cache-Control",it),p.status==="signed-out")throw Je("signedOutPage",b(i,f));if(p.status==="forbidden")throw N===void 0?Se.data(null,{status:403,headers:f}):Je("forbiddenPage",N(i,f));const T=ee.resolveExplorerLocation(s,d["*"],w.searchParams);if(T.kind==="redirect")throw Se.redirect(T.href,{headers:f});const{location:j}=T,{principal:H}=p,V=Ye(r,L(H)),de=I.get(j.source);if(de===void 0)throw new RangeError(`[markdown-explorer] no source for ${JSON.stringify(j.source)}`);const oe={signal:i.signal,timeoutMs:g,late:null,handOverMs:g},Q={scope:V,sources:n.map(B=>({id:B.id,label:D(B,H)})),settings:ee.parseViewSettings(ee.readCookieValue(i.headers.get("Cookie"),t.settingsCookie),R),tree:j.view==="single"?null:{sourceId:j.source,result:Re(oe,B=>M(de,H,V,i,B).then(ae=>ae.result))},documents:Dr(j).map(B=>({path:B,document:Re(oe,ae=>Z({principal:H,request:i,signal:ae,refresh:!1},V,B))})),notices:Re({signal:i.signal,timeoutMs:g,late:Ae,handOverMs:0},B=>$({principal:H,request:i,signal:B,refresh:!1}))};return Se.data(Q,{headers:f})},K=async(i,w,d)=>{let p;try{p=Ge(await O(w))}catch(B){return U(re(B,{operation:"authenticate"},w.signal,c))}const f=new Headers(p.headers);if(p.status==="signed-out")return U({reason:"unauthorized"},f);if(p.status==="forbidden")return U({reason:"forbidden"},f);const{principal:T}=p;if(i==="asset")return Y({principal:T,request:w,signal:w.signal,refresh:!1},d,f);const j=Ye(r,L(T));f.set(y.EXPLORER_SCOPE_HEADER,j);const H={principal:T,request:w,signal:w.signal,refresh:!1},V=()=>U({reason:"invalid"},f);if(i==="document"){const B=we(d,y.EXPLORER_DATA_QUERY.path);if(B===null||!y.isAcceptableDocumentPath(B))return V();const ae=w.headers.has(y.EXPLORER_REFRESH_HEADER);return ae&&!We(w)?U({reason:"forbidden"},f):ue(200,JSON.stringify(await Z({...H,refresh:ae},j,B)),f)}const de=we(d,y.EXPLORER_DATA_QUERY.source),oe=we(d,y.EXPLORER_DATA_QUERY.path);if(de===null||i==="children"&&(oe===null||!y.isAcceptableDocumentPath(oe)))return V();const Q=I.get(de);if(Q===void 0)return U({reason:"not-found"},f);if(i==="tree")return ue(200,(await M(Q,T,j,w,w.signal)).json,f);if(i==="refresh"){const B=await X(Q,T,j,w);return w.signal.aborted||G(Q,u(Q,j)),ue(200,B.json,f)}return Q.children===void 0||oe===null?U({reason:"not-found"},f):ue(200,JSON.stringify(await F(Q,Q.children,H,oe)),f)},le=async(i,w,d)=>{if(new URL(i.url).pathname.endsWith(".data"))return U({reason:"not-found"});if(!y.isExplorerDataOperation(d))return U({reason:"not-found"});const p=i.method.toUpperCase(),f=d==="refresh";if(f?p!=="POST":p!=="GET"&&p!=="HEAD")return ue(405,JSON.stringify({failure:{reason:"invalid"}}),void 0,{Allow:f?"POST":"GET, HEAD"});if(f&&!We(i))return U({reason:"forbidden"});try{return await K(d,i,w.searchParams)}catch(T){return U(re(T,{operation:d},i.signal,c))}};return Object.freeze({loader:W,headers:zr,dataLoader:({request:i,url:w,params:d})=>le(i,w,d["*"]),dataAction:({request:i,url:w,params:d})=>le(i,w,d["*"]),forgetTree:i=>{if(typeof i!="string")throw new TypeError(`[markdown-explorer] forgetTree needs the string key onTreeRefreshed received; got ${typeof i}`);h.forget(i)}})},ge=Object.freeze({maxEntries:2e4,maxDocumentBytes:2*1024*1024,textPreviewBytes:8*1024,walkConcurrency:8}),Hr=new Set(["md","markdown","mdx"]),at=new Map([...[["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"],["svg","image/svg+xml"],["webp","image/webp"],["ico","image/x-icon"],["bmp","image/bmp"],["tif","image/tiff"],["tiff","image/tiff"],["avif","image/avif"]].map(([e,t])=>[e,{kind:"image",contentType:t}]),...[["mp4","video/mp4"],["m4v","video/mp4"],["webm","video/webm"],["mov","video/quicktime"],["avi","video/x-msvideo"],["mkv","video/x-matroska"],["ogv","video/ogg"]].map(([e,t])=>[e,{kind:"media",mediaType:"video",contentType:t}]),...[["mp3","audio/mpeg"],["wav","audio/wav"],["ogg","audio/ogg"],["oga","audio/ogg"],["opus","audio/ogg"],["m4a","audio/mp4"],["flac","audio/flac"],["aac","audio/aac"],["wma","audio/x-ms-wma"]].map(([e,t])=>[e,{kind:"media",mediaType:"audio",contentType:t}]),["pdf",{kind:"media",mediaType:"pdf",contentType:"application/pdf"}]]),Br=new Set(["txt","text","log","csv","tsv","json","jsonc","json5","ndjson","yaml","yml","toml","ini","cfg","conf","properties","xml","xsl","xsd","dtd","html","htm","xhtml","css","scss","sass","less","styl","js","mjs","cjs","jsx","ts","mts","cts","tsx","vue","svelte","astro","py","pyi","rb","go","rs","java","kt","kts","scala","groovy","gradle","c","h","cc","cpp","cxx","hpp","hh","hxx","cs","fs","vb","swift","m","mm","php","pl","pm","r","jl","lua","dart","ex","exs","erl","hrl","hs","ml","mli","clj","cljs","elm","nim","zig","v","sol","tf","hcl","nix","sh","bash","zsh","fish","ps1","psm1","bat","cmd","sql","graphql","gql","proto","thrift","avsc","rst","adoc","asciidoc","tex","bib","org","textile","diff","patch","srt","vtt","ics","vcf","gitignore","gitattributes","editorconfig","dockerignore","npmignore","prettierrc","eslintrc","babelrc","mailmap"]),Fr=new Set(["readme","license","licence","copying","notice","authors","contributors","changelog","changes","todo","makefile","dockerfile","containerfile","procfile","gemfile","rakefile","vagrantfile","jenkinsfile","brewfile","codeowners"]),ct=typeof te.constants.O_NOFOLLOW=="number"?te.constants.O_NOFOLLOW:0,ut=typeof te.constants.O_NONBLOCK=="number"?te.constants.O_NONBLOCK:0,Ke=e=>`${e.size}-${e.mtimeNs}`,Ur=e=>e!==""&&e!=="."&&e!==".."&&!e.includes(":")&&!e.endsWith(".")&&!e.endsWith(" "),Ve=e=>y.isAcceptableDocumentPath(e)&&e===e.normalize("NFC")&&e.split("/").every(Ur),lt=e=>{const t=e.toLowerCase(),r=t.lastIndexOf(".");return r<0?"":t.slice(r+1)},Xr=e=>{const t=lt(e);if(Hr.has(t))return{kind:"markdown"};const r=at.get(t);if(r!==void 0)return r.kind==="image"?{kind:"image"}:{kind:"media",mediaType:r.mediaType};const n=e.toLowerCase();return Br.has(t)||!n.includes(".")&&Fr.has(n)?{kind:"text"}:{kind:"file"}},dt=e=>{switch(typeof e=="object"&&e!==null?e.code:void 0){case"ENOENT":case"ENOTDIR":return"not-found";case"ELOOP":case"EACCES":case"EPERM":return"forbidden";case"ENAMETOOLONG":return"invalid";case"EISDIR":return"unsupported";default:return null}},ft=e=>{const t=dt(e);return t===null?e:new me(t)},Gr=e=>{const t=typeof e=="object"&&e!==null?e.code:void 0;return t==="EACCES"||t==="EPERM"||t==="ENOENT"||t==="ENOTDIR"},Qe=async(e,t)=>{const r=[];for await(const n of e.createReadStream({start:0,end:t-1,autoClose:!1}))r.push(n);return Buffer.concat(r)},Jr=(e,t)=>e!==null?{start:e.offset,end:e.offset+e.length-1}:t===0n?{}:{start:0,end:Number(t)-1},Yr=async(e,t,r,n)=>{let s;try{s=await fe.open(e,te.constants.O_RDONLY|ct|ut);const g=await s.stat({bigint:!0});if(!g.isFile()||g.ino!==t.ino||g.dev!==t.dev||g.size!==t.size||g.mtimeNs!==t.mtimeNs)throw new me("not-found")}catch(g){throw await s?.close(),ft(g)}const o=s.createReadStream(Jr(r,t.size)),c=pt.Readable.toWeb(o),m=()=>{o.destroy(n.reason)};return n.aborted?m():n.addEventListener("abort",m,{once:!0}),c},Wr=(e,t)=>{const r=ee.NAME_COLLATOR.compare(e,t);return r!==0?r:e===t?0:e<t?-1:1},Kr=e=>{let t=0;const r=[];return async n=>{t<e?t+=1:await new Promise(s=>r.push(s));try{return await n()}finally{const s=r.shift();s===void 0?t-=1:s()}}},Vr=(e,t)=>{if(e.isSymbolicLink())return"symbolic-link";if(!(e.isDirectory()||e.isFile()))return"special-file";const{name:r}=e;return r!==r.normalize("NFC")?"not-nfc":r.includes(":")?"colon":r.endsWith(".")||r.endsWith(" ")?"trailing-dot-or-space":y.isAcceptableDocumentPath(r)?y.isAcceptableDocumentPath(t)?null:"path-too-long":"control-character-or-backslash"},Qr=new Set(["id","label","root","pathPrefix","parse","deny","maxEntries","maxDocumentBytes","textPreviewBytes","walkConcurrency","cacheScope","reportSkipped"]),Ee=(e,t,r)=>{if(t===void 0)return r;if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new RangeError(`[markdown-explorer] ${e} must be a positive integer; got ${String(t)}`);return t},Zr=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] createFileSystemSource needs an options object");for(const a of Object.keys(e))if(!Qr.has(a))throw new TypeError(`[markdown-explorer] createFileSystemSource does not know the option ${JSON.stringify(a)}`);const{id:t,label:r,root:n,parse:s}=e;if(typeof t!="string"||t==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-empty id");if(typeof r!="string"||r.trim()==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-blank label");if(typeof s!="function")throw new TypeError("[markdown-explorer] a file-system source needs a parse function");if(typeof n!="string"||!q.isAbsolute(n))throw new RangeError(`[markdown-explorer] root must be an absolute path; got ${JSON.stringify(n)}`);let o;try{o=te.statSync(n).isDirectory()}catch(a){throw new RangeError(`[markdown-explorer] root does not exist: ${n}`,{cause:a})}if(!o)throw new RangeError(`[markdown-explorer] root is not a directory: ${n}`);const c=te.realpathSync(n),m=e.pathPrefix;if(typeof m!="string")throw new TypeError('[markdown-explorer] pathPrefix is required: "" for a source over the whole root, or relative segments ending with "/"');if(m!==""&&!(m.endsWith("/")&&Ve(m.slice(0,-1))))throw new RangeError(`[markdown-explorer] pathPrefix must be empty or relative segments ending with "/"; got ${JSON.stringify(m)}`);const g=y.resolvePathRules(e.deny),x=Ee("maxEntries",e.maxEntries,ge.maxEntries),l=Ee("maxDocumentBytes",e.maxDocumentBytes,ge.maxDocumentBytes),h=Ee("textPreviewBytes",e.textPreviewBytes,ge.textPreviewBytes),A=Ee("walkConcurrency",e.walkConcurrency,ge.walkConcurrency),k=e.cacheScope===void 0?"principal":e.cacheScope;if(k!=="principal"&&k!=="shared")throw new RangeError(`[markdown-explorer] cacheScope must be "principal" or "shared"; got ${JSON.stringify(k)}`);const I=e.reportSkipped;if(I!==void 0&&typeof I!="function")throw new TypeError("[markdown-explorer] reportSkipped must be a function");const R=I===void 0?a=>{console.warn(`[markdown-explorer] the file-system source ${JSON.stringify(a.sourceId)} does not list ${JSON.stringify(a.path)}: ${a.reason}`)}:I,O=new Set,L=a=>{const E=q.resolve(c,...a.split("/")),S=q.relative(c,E);return S===""||S===".."||S.startsWith(`..${q.sep}`)||q.isAbsolute(S)?null:E},b=(a,E)=>{const S=`${E}\0${a}`;O.has(S)||O.size>=x||(O.add(S),R({sourceId:t,path:a,reason:E}))},N=async({signal:a})=>{a.throwIfAborted();const E=new AbortController,S=()=>{E.abort(a.reason)};a.addEventListener("abort",S,{once:!0});const _=Kr(A);let P=0;const C=async(M,X)=>{const G=await _(async()=>{E.signal.throwIfAborted();try{return await fe.readdir(M,{withFileTypes:!0})}catch($){if(X===""||!Gr($))throw $;return null}});if(E.signal.throwIfAborted(),G===null)return b(`${m}${X}`,"unreadable-directory"),null;const F=[];for(const $ of G){if(g.deniesName($.name))continue;const Y=X===""?$.name:`${X}/${$.name}`,W=`${m}${Y}`,K=Vr($,W);if(K!==null){b(W,K);continue}F.push({dirent:$,relativePath:Y,path:W})}if(P+=F.length,P>x)throw new me("too-large");return F.sort(($,Y)=>Wr($.dirent.name,Y.dirent.name)),(await Promise.all(F.map(async({dirent:$,relativePath:Y,path:W})=>{if(!$.isDirectory())return{name:$.name,path:W,type:"file"};const K=await C(q.join(M,$.name),Y);return K===null?null:{name:$.name,path:W,type:"directory",children:K}}))).filter($=>$!==null)};try{const M=await C(c,"");if(M===null)throw new Error("[markdown-explorer] the source's root could not be listed");return M}catch(M){throw E.abort(),M}finally{a.removeEventListener("abort",S)}},z=async a=>{if(!a.startsWith(m))return{status:"refused",reason:"not-found"};const E=a.slice(m.length);if(!Ve(E))return{status:"refused",reason:"invalid"};if(g.deniesPath(E))return{status:"refused",reason:"forbidden"};const S=L(E);if(S===null)return{status:"refused",reason:"forbidden"};const _=await fe.lstat(S,{bigint:!0});if(_.isSymbolicLink())return{status:"refused",reason:"forbidden"};if(!_.isFile())return{status:"refused",reason:"unsupported"};const P=await fe.realpath(S);return P!==S||g.deniesPath(q.relative(c,P).split(q.sep).join("/"))?{status:"refused",reason:"forbidden"}:{status:"file",target:S,name:E.slice(E.lastIndexOf("/")+1),stats:_}},D=async(a,E,S)=>{let _;try{const P=await z(S);if(P.status==="refused")return y.failureDocument(P.reason);const{target:C,name:M,stats:X}=P,G=Xr(M),F=Ke(X);if(G.kind==="image")return{kind:"image",name:M,version:F};if(G.kind==="media")return{kind:"media",name:M,mediaType:G.mediaType,version:F};if(G.kind==="file")return{kind:"file",name:M,version:F};_=await fe.open(C,te.constants.O_RDONLY|ct|ut);const Z=await _.stat({bigint:!0});if(!Z.isFile()||Z.ino!==X.ino||Z.dev!==X.dev)return y.failureDocument("forbidden");if(G.kind==="markdown"){if(Z.size>BigInt(l))return y.failureDocument("too-large");const K=await Qe(_,l+1);if(K.length>l)return y.failureDocument("too-large");const le=await s(new TextDecoder("utf-8").decode(K),E);return{kind:"markdown",name:M,htmlContent:le.htmlContent,headings:le.headings}}const $=await Qe(_,h);if($.includes(0))return{kind:"file",name:M,version:F};const Y=Z.size>BigInt(h),W=new TextDecoder("utf-8").decode($,{stream:Y});return{kind:"text",name:M,text:W,truncated:Y,version:F}}catch(P){const C=dt(P);if(C===null)throw P;return y.failureDocument(C)}finally{await _?.close()}},u=async(a,E,S)=>{let _;try{_=await z(S)}catch(F){throw ft(F)}if(_.status==="refused")throw new me(_.reason);const{target:P,name:C,stats:M}=_,X=at.get(lt(C)),G=X===void 0?"":X.contentType;return{name:C,contentType:G,size:Number(M.size),version:Ke(M),open:F=>Yr(P,M,F,a.signal)}};return Object.freeze({id:t,label:r,cacheScope:k,boundary:Object.freeze({contains:a=>a.startsWith(m)}),tree:N,document:D,asset:u})};exports.DEFAULT_DENIED_PATH_SEGMENTS=y.DEFAULT_DENIED_PATH_SEGMENTS;exports.MAX_DOCUMENT_PATH_LENGTH=y.MAX_DOCUMENT_PATH_LENGTH;exports.isAcceptableDocumentPath=y.isAcceptableDocumentPath;exports.isDeniedPath=y.isDeniedPath;exports.ExplorerError=me;exports.anonymousAccess=ht;exports.createFileSystemSource=Zr;exports.createMarkdownExplorer=Cr;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./dataRoute-CKbdwkQ7.cjs"),Ze=require("node:crypto"),Se=require("react-router"),ee=require("./location-Oo21lTyV.cjs"),te=require("node:fs"),q=require("node:path"),Te=require("node:url"),mt=require("node:worker_threads"),fe=require("node:fs/promises"),pt=require("node:stream");var xe=typeof document<"u"?document.currentScript:null;const Me=Object.freeze({kind:"anonymous"}),ht=Object.freeze({authenticate:async()=>({status:"signed-in",principal:Me}),principalKey:()=>Me.kind,signedOutPage:(e,t)=>new Response(null,{status:401,headers:t})}),wt="application/octet-stream",qe="application/pdf",gt=new Set(["image/png","image/apng","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/x-icon","image/vnd.microsoft.icon","audio/mpeg","audio/mp4","audio/aac","audio/ogg","audio/opus","audio/wav","audio/wave","audio/x-wav","audio/webm","audio/flac","audio/x-flac","audio/x-m4a","video/mp4","video/webm","video/ogg","video/quicktime",qe]),et="default-src 'none'; media-src 'self'; style-src 'unsafe-inline'",Et=`${et}; sandbox`,yt=`${et}; sandbox allow-same-origin`,ve=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u,bt=/^[\t\n\r ]+|[\t\n\r ]+$/gu,Ne=/^[\t ]+|[\t ]+$/gu,St=e=>{const t=[];let r="",n=0;for(;;){for(;n<e.length&&e[n]!=='"'&&e[n]!==",";)r+=e[n],n+=1;if(n<e.length&&e[n]==='"'){const s=n;for(n+=1;n<e.length&&e[n]!=='"';)n+=e[n]==="\\"?2:1;if(n=Math.min(n+1,e.length),r+=e.slice(s,n),n<e.length)continue}if(t.push(r.replace(Ne,"")),r="",n>=e.length)return t;n+=1}},Tt=e=>{const t=e.replace(bt,""),r=t.indexOf("/");if(r<0)return null;const n=t.slice(0,r),s=t.indexOf(";",r+1),o=t.slice(r+1,s<0?t.length:s).replace(/[\t\n\r ]+$/u,"");return ve.test(n)&&ve.test(o)?`${n}/${o}`.toLowerCase():null},xt=e=>{let t=null;for(const r of St(e)){const n=Tt(r);n!==null&&n!=="*/*"&&(t=n)}return t},Ot=/['()*]/gu,Rt=e=>encodeURIComponent(e).replace(Ot,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),_t=Object.freeze({"Cache-Control":"private, max-age=60, stale-while-revalidate=600, no-transform",Vary:"Cookie"}),kt=(e,t)=>{const r=xt(e),n=r!==null&&gt.has(r),s=n&&(r.startsWith("audio/")||r.startsWith("video/"));return{contentType:r===null?wt:r,inline:n,headers:{"X-Content-Type-Options":"nosniff","Content-Disposition":`${n?"inline":"attachment"}; filename*=UTF-8''${Rt(t)}`,...r===qe?{}:{"Content-Security-Policy":s?yt:Et},"Cross-Origin-Resource-Policy":"same-origin"}}},At=/^bytes=(?:(\d+)-(\d*)|-(\d+))$/iu,pe=Object.freeze({kind:"whole"}),Le=Object.freeze({kind:"unsatisfiable"}),Nt=(e,t,r)=>{const n=e.get("Range");if(n===null)return pe;const s=e.get("If-Range");if(s!==null&&s!==r)return pe;const o=At.exec(n);if(o===null)return pe;const[,c,m,g]=o;if(g!==void 0){const h=Number(g);if(h===0)return Le;const A=Math.max(0,t-h);return{kind:"partial",range:{offset:A,length:t-A}}}const x=Number(c),l=m===""?Number.POSITIVE_INFINITY:Number(m);return l<x?pe:x>=t?Le:{kind:"partial",range:{offset:x,length:Math.min(l,t-1)-x+1}}},$e="W/",Pt=e=>{const t=[];let r=0,n=!1;for(let s=0;s<e.length;s+=1)e[s]==='"'?n=!n:e[s]===","&&!n&&(t.push(e.slice(r,s).replace(Ne,"")),r=s+1);return t.push(e.slice(r).replace(Ne,"")),t},je=e=>e.startsWith($e)?e.slice($e.length):e,It=(e,t)=>{if(e===null)return!1;const r=Pt(e);if(r.length===1&&r[0]==="*")return!0;const n=je(t);return r.some(s=>je(s)===n)},Mt=(e,t)=>{let r=t;return e.pipeThrough(new TransformStream({transform:(n,s)=>{const o=n.byteLength>r?n.subarray(0,r):n;r-=o.byteLength,s.enqueue(o),r===0&&s.terminate()},flush:n=>{r>0&&n.error(new RangeError("[markdown-explorer] the asset ended before its declared length"))}}))},Oe=async(e,t,r,n,s)=>{if(n!==null&&r.set("Content-Length",String(n)),e.method.toUpperCase()==="HEAD")return new Response(null,{status:t,headers:r});const o=await s();return new Response(n===null?o:Mt(o,n),{status:t,headers:r})},vt=(e,t)=>{const r=new Headers(e);for(const[n,s]of Object.entries({"Accept-Ranges":"bytes","Content-Range":`bytes */${t}`,"Cache-Control":"private, no-store","X-Content-Type-Options":"nosniff"}))r.set(n,s);return new Response(null,{status:416,headers:r})},Lt=async(e,t,r)=>{const n=`"${t.version}"`,s=kt(t.contentType,t.name),o=new Headers(r);for(const[g,x]of Object.entries({...s.headers,..._t,ETag:n}))o.set(g,x);if(It(e.headers.get("If-None-Match"),n))return new Response(null,{status:304,headers:o});if(o.set("Content-Type",s.contentType),t.size===null)return Oe(e,200,o,null,()=>t.open(null));if(t.size===0)return o.set("Content-Length","0"),new Response(null,{status:200,headers:o});o.set("Accept-Ranges","bytes");const c=Nt(e.headers,t.size,n);if(c.kind==="unsatisfiable")return vt(r,t.size);if(c.kind==="whole")return Oe(e,200,o,t.size,()=>t.open(null));const{range:m}=c;return o.set("Content-Range",`bytes ${m.offset}-${m.offset+m.length-1}/${t.size}`),Oe(e,206,o,m.length,()=>t.open(m))},Re=(e,t)=>{const r=new AbortController,n=t(AbortSignal.any([e.signal,r.signal]));return new Promise(s=>{let o;const c=setTimeout(()=>{s(e.late),o=setTimeout(()=>r.abort(),e.handOverMs)},e.timeoutMs),m=()=>{clearTimeout(c),clearTimeout(o)};n.then(g=>{m(),s(g)},()=>{m(),s(e.late)})})},$t=Object.freeze({error:(e,t)=>{console.error(e,t)}}),tt=Symbol.for("@aiquants/markdown-explorer:ExplorerError");class me extends Error{reason;code;constructor(t,r={}){if(!y.isExplorerFailureReason(t))throw new RangeError(`[markdown-explorer] ExplorerError needs a failure reason; got ${JSON.stringify(t)}`);if(r.code!==void 0&&!y.isExplorerFailureCode(r.code))throw new RangeError(`[markdown-explorer] an ExplorerError code must be 1 to 64 lowercase letters, digits or hyphens; got ${JSON.stringify(r.code)}`);super(`[markdown-explorer] ${t}`,r.cause===void 0?void 0:{cause:r.cause}),this.name="ExplorerError",this.reason=t,this.code=r.code,Object.defineProperty(this,tt,{value:!0})}}const jt=e=>e instanceof Error&&Object.hasOwn(e,tt)&&y.isExplorerFailureReason(e.reason),Dt=e=>typeof e=="object"&&e!==null&&e.name==="AbortError",Pe=(e,t,r)=>{try{e.error(t,r)}catch(n){console.error("[markdown-explorer] the logger threw while reporting a failure",{operation:r.operation,error:n})}},ne=(e,t)=>Pe(e,`[markdown-explorer] ${t.operation} failed`,t),zt=(e,t)=>Pe(e,`[markdown-explorer] ${t.operation} left out an entry`,t),Ct=(e,t)=>Pe(e,`[markdown-explorer] ${t.operation} refused a path the deny rules match`,{...t,error:new RangeError("[markdown-explorer] the path matches a deny rule")}),De=(e,t)=>{e===null||typeof e!="object"&&typeof e!="function"||Promise.resolve(e).then(void 0,t)},re=(e,t,r,n)=>jt(e)?y.failureOf(e.reason,e.code):(Dt(e)||r.aborted||ne(n,{...t,error:e}),{reason:"failed"}),ze=(e,t)=>{if(!Number.isSafeInteger(t)||t<=0)throw new RangeError(`[markdown-explorer] a cache ${e} must be a positive integer; got ${String(t)}`)},rt=(e,t)=>{ze("capacity",e),t!==void 0&&ze("weight budget",t.max);const r=new Map;let n=0;const s=o=>{const c=r.get(o);c!==void 0&&(r.delete(o),n-=c.weight)};return{get:o=>{const c=r.get(o);if(c!==void 0)return r.delete(o),r.set(o,c),c.value},set:(o,c)=>{s(o);const m=t===void 0?0:t.of(o,c);if(!(t!==void 0&&m>t.max)){r.set(o,{value:c,weight:m}),n+=m;for(const g of r.keys()){if(r.size<=e&&(t===void 0||n<=t.max))break;s(g)}}},delete:s,size:()=>r.size,weight:()=>n}},nt=e=>Math.max(1,e-1),Ht=2147483647,Ce=Object.freeze({status:"aborted"}),se=(e,t,r)=>{const n=(e.get(t)??0)+r;n===0?e.delete(t):e.set(t,n)},ce=(e,t,r)=>{if(!Number.isSafeInteger(t)||t<=0||t>r)throw new RangeError(`[markdown-explorer] a worker pool's ${e} must be an integer in 1..${String(r)}; got ${String(t)}`)},Bt=e=>e!==null&&typeof e=="object"&&e.ready===!0&&!("id"in e),Ft=(e,t)=>e!==null&&typeof e=="object"&&e.id===t&&"output"in e,Ut=({url:e,size:t,deadlineMs:r,jobsPerScope:n,maxQueuedJobs:s,heapLimits:o})=>{ce("size",t,Number.MAX_SAFE_INTEGER),ce("deadline",r,Ht),ce("jobsPerScope",n,Number.MAX_SAFE_INTEGER),ce("maxQueuedJobs",s,Number.MAX_SAFE_INTEGER),ce("maxOldGenerationSizeMb",o.maxOldGenerationSizeMb,Number.MAX_SAFE_INTEGER),ce("maxYoungGenerationSizeMb",o.maxYoungGenerationSizeMb,Number.MAX_SAFE_INTEGER);const c=Object.freeze({maxOldGenerationSizeMb:o.maxOldGenerationSizeMb,maxYoungGenerationSizeMb:o.maxYoungGenerationSizeMb}),m=new Set,g=[],x=new Map,l=new Map,h=nt(t);let A=0;const k=(u,a)=>{const{job:E}=u;u.timer!==null&&clearTimeout(u.timer),u.timer=null,u.job=null,u.sent=!1,E!==null&&(se(x,E.scope,-1),se(l,E.scope,-1),E.settle(a))},I=u=>{const[a]=g.splice(u,1);a?.detach()},R=()=>{let u=-1,a=h,E=Number.POSITIVE_INFINITY;for(const[S,_]of g.entries()){const P=x.get(_.scope)??0,C=l.get(_.scope)??0;(P<a||P===a&&u>=0&&C<E)&&(u=S,a=P,E=C)}return u},O=(u,a)=>{m.has(u)&&(m.delete(u),k(u,a),u.worker.terminate().catch(()=>{}),D())},L=u=>{u.timer=setTimeout(()=>{O(u,{status:"timeout"})},r)},b=(u,a)=>u.sent?{status:"crashed",error:a}:{status:"unavailable",error:a},N=(u,a)=>{u.sent=!0,L(u);try{u.worker.postMessage({id:a.id,input:a.input})}catch(E){k(u,{status:"crashed",error:E}),u.worker.unref()}},z=()=>{const u={worker:new mt.Worker(e,{resourceLimits:c}),job:null,sent:!1,timer:null,ready:!1};return u.worker.unref(),u.timer=setTimeout(()=>{O(u,{status:"unavailable",error:new Error(`[markdown-explorer] a worker did not start within ${String(r)} ms`)})},r),u.worker.on("message",a=>{if(!u.ready&&Bt(a)){u.ready=!0,u.timer!==null&&clearTimeout(u.timer),u.timer=null,u.job===null?u.worker.unref():N(u,u.job),u.job===null&&D();return}const{job:E}=u;if(E===null||!Ft(a,E.id)){O(u,b(u,new Error("[markdown-explorer] a worker sent a message that answers no job")));return}k(u,{status:"done",output:a.output}),u.worker.unref(),D()}),u.worker.on("error",a=>{O(u,b(u,a))}),u.worker.on("messageerror",a=>{O(u,b(u,a))}),u.worker.on("exit",a=>{O(u,b(u,new Error(`[markdown-explorer] a worker exited with code ${String(a)}`)))}),m.add(u),u},D=()=>{for(;;){const u=R(),a=g[u];if(a===void 0)return;let E;for(const _ of m)if(_.job===null){E=_;break}if(E===void 0&&m.size<t)try{E=z()}catch(_){I(u),se(l,a.scope,-1),a.settle({status:"unavailable",error:_});continue}if(E===void 0)return;I(u),se(x,a.scope,1);const S=E;S.job=a,S.worker.ref(),S.ready&&N(S,a)}};return{run:(u,{scope:a,signal:E})=>new Promise(S=>{if(E.aborted){S(Ce);return}if((l.get(a)??0)>=n){S({status:"refused",limit:"scope"});return}A+=1;const _={id:A,input:u,scope:a,settle:S,detach:()=>{}};g.push(_),se(l,a,1),D();const P=g.indexOf(_);if(P<0)return;if(g.length>s){I(P),se(l,a,-1),S({status:"refused",limit:"queue"});return}const C=()=>{const M=g.indexOf(_);M<0||(I(M),se(l,a,-1),S(Ce))};E.addEventListener("abort",C,{once:!0}),_.detach=()=>{E.removeEventListener("abort",C)}}),workers:()=>m.size}},Ie=1024*1024,Xt=3e4,Gt=4*Ie,Jt=64*Ie,Yt=3,Wt=2,Kt=(e,t)=>e+nt(t)+Yt,Vt=4,Qt=32,Zt=512,qt=64,er=4096,tr=32,He=4096,rr=4,ot=({workerHeapMb:e,maxHtmlBytes:t})=>Math.floor(((e-qt)*Ie-t*tr)/er),nr=({maxHtmlBytes:e})=>e,or=({maxHtmlBytes:e})=>rr*e,sr=1024,ir=2147483647,ar=64,cr=2**29,ur=1024*1024,lr=64,Be=Object.freeze({status:"rejected",reason:"too-large",cause:null}),_e=Object.freeze({status:"rejected",reason:"failed",cause:null}),ie=(e,t,r,n)=>{if(t===void 0)return r;if(typeof t!="number")throw new TypeError(`[markdown-explorer] sanitizer.${e} must be a number; got ${typeof t}`);if(!Number.isSafeInteger(t)||t<=0||t>n)throw new RangeError(`[markdown-explorer] sanitizer.${e} must be an integer in 1..${String(n)}; got ${String(t)}`);return t},dr=(e,t)=>{if(e!==void 0&&(e===null||typeof e!="object"))throw new TypeError("[markdown-explorer] sanitizer must be an object of { workers, deadlineMs, maxHtmlBytes, cacheBytes, workerHeapMb, jobsPerScope, maxQueuedJobs }");const{workers:r,deadlineMs:n,maxHtmlBytes:s,cacheBytes:o,workerHeapMb:c,jobsPerScope:m,maxQueuedJobs:g}=e??{},x=ie("workers",r,Wt,ar),l=ie("jobsPerScope",m,Kt(t,x),Number.MAX_SAFE_INTEGER),h=Object.freeze({workers:x,deadlineMs:ie("deadlineMs",n,Xt,ir),maxHtmlBytes:ie("maxHtmlBytes",s,Gt,cr),cacheBytes:ie("cacheBytes",o,Jt,Number.MAX_SAFE_INTEGER),workerHeapMb:ie("workerHeapMb",c,Zt,ur),jobsPerScope:l,maxQueuedJobs:ie("maxQueuedJobs",g,Vt*l,Number.MAX_SAFE_INTEGER)});if(h.jobsPerScope<t)throw new RangeError(`[markdown-explorer] sanitizer.jobsPerScope must be at least multiView.maxPanels (${String(t)}), because a page sends the document of every panel to the sanitizer at once for one reader; got ${String(h.jobsPerScope)}`);if(h.maxQueuedJobs<t)throw new RangeError(`[markdown-explorer] sanitizer.maxQueuedJobs must be at least multiView.maxPanels (${String(t)}), because a reader whose page finds every worker busy waits with the document of every panel; got ${String(h.maxQueuedJobs)}`);if(ot(h)<He)throw new RangeError(`[markdown-explorer] sanitizer.workerHeapMb (${String(h.workerHeapMb)} MiB) must leave room for ${String(He)} parsed nodes beside HTML of sanitizer.maxHtmlBytes (${String(h.maxHtmlBytes)} bytes); raise workerHeapMb or lower maxHtmlBytes`);return h},fr=()=>{const e=typeof document>"u"?require("url").pathToFileURL(__filename).href:xe&&xe.tagName.toUpperCase()==="SCRIPT"&&xe.src||new URL("server.cjs",document.baseURI).href,t=new URL(`./sanitizeWorker${q.extname(Te.fileURLToPath(e))}`,e);if(!te.existsSync(Te.fileURLToPath(t)))throw new Error(`[markdown-explorer] the HTML sanitizer worker is missing: ${Te.fileURLToPath(t)}`);return t},Fe=new Map,mr=(e,t)=>{const r=[e.href,t.workers,t.deadlineMs,t.workerHeapMb,t.jobsPerScope,t.maxQueuedJobs].map(String).join("\0");let n=Fe.get(r);return n===void 0&&(n=Ut({url:e,size:t.workers,deadlineMs:t.deadlineMs,jobsPerScope:t.jobsPerScope,maxQueuedJobs:t.maxQueuedJobs,heapLimits:{maxOldGenerationSizeMb:t.workerHeapMb,maxYoungGenerationSizeMb:Qt}}),Fe.set(r,n)),n},pr=e=>{if(e===null||typeof e!="object")return!1;const{status:t,html:r,message:n}=e;return t==="sanitized"&&typeof r=="string"||t==="too-large"||t==="error"&&typeof n=="string"},hr=e=>e instanceof Error&&e.code==="ERR_WORKER_OUT_OF_MEMORY",wr=({iframeHosts:e,dataPath:t,options:r,pool:n})=>{const s=Object.freeze([...e]),o=ot(r),c=nr(r),m=or(r),g=rt(sr,{max:r.cacheBytes,of:(R,O)=>2*R.length+(O.status==="sanitized"?2*O.html.length:lr)}),x=new Map,l=new Map,h=R=>{x.get(R.key)===R&&x.delete(R.key);const O=l.get(R.hash);O?.delete(R),O?.size===0&&l.delete(R.hash)},A=async(R,O,L)=>{const b=await n.run({html:R,iframeHosts:s,dataPath:t,maxNodes:o,maxAttributeChars:c,maxSanitizedChars:m},{scope:O,signal:L});if(b.status==="refused"){const z=b.limit==="scope"?`its reader already has ${String(r.jobsPerScope)} documents being sanitized or waiting`:`${String(r.maxQueuedJobs)} documents are already waiting`;return{outcome:{status:"rejected",reason:"failed",cause:new Error(`[markdown-explorer] the HTML sanitizer refused a document: ${z}`)},lasting:!1}}if(b.status==="aborted")return{outcome:_e,lasting:!1};if(b.status==="timeout")return{outcome:{status:"rejected",reason:"too-large",cause:new Error(`[markdown-explorer] the HTML sanitizer did not finish within ${String(r.deadlineMs)} ms`)},lasting:!0};if(b.status==="unavailable")return{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker could not start",{cause:b.error})},lasting:!1};if(b.status==="crashed"&&hr(b.error))return{outcome:{status:"rejected",reason:"too-large",cause:new Error(`[markdown-explorer] the HTML sanitizer ran out of its ${String(r.workerHeapMb)} MiB worker heap`,{cause:b.error})},lasting:!0};if(b.status==="crashed")return{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker failed",{cause:b.error})},lasting:!0};const{output:N}=b;return pr(N)?N.status==="too-large"?{outcome:Be,lasting:!0}:N.status==="error"?{outcome:{status:"rejected",reason:"failed",cause:new Error(`[markdown-explorer] the HTML sanitizer failed: ${N.message}`)},lasting:!0}:N.html.length>m?{outcome:{status:"rejected",reason:"too-large",cause:new Error(`[markdown-explorer] the HTML sanitizer's output of ${String(N.html.length)} characters exceeds its limit of ${String(m)}`)},lasting:!0}:{outcome:{status:"sanitized",html:N.html},lasting:!0}:{outcome:{status:"rejected",reason:"failed",cause:new Error("[markdown-explorer] the HTML sanitizer worker answered something that is not an outcome")},lasting:!0}},k=(R,O,L,b)=>{let N=()=>{};const z=new Promise(a=>{N=a}),D={hash:O,key:L,outcome:z,answer:N,controller:new AbortController,waiters:0};x.set(L,D);const u=l.get(O);return u===void 0?l.set(O,new Set([D])):u.add(D),A(R,b,D.controller.signal).catch(a=>({outcome:{status:"rejected",reason:"failed",cause:a instanceof Error?a:new Error(String(a))},lasting:!0})).then(({outcome:a,lasting:E})=>{if(h(D),D.answer(a),!E)return;const S=g.get(O),_=S??(a.status==="rejected"?{...a,cause:null}:a);S===void 0&&g.set(O,_);for(const P of l.get(O)??[])h(P),P.answer(_),P.controller.abort()}),D},I=(R,O)=>new Promise(L=>{R.waiters+=1;const b=()=>{R.waiters-=1,L(_e),!(R.waiters>0)&&(h(R),R.controller.abort())};O.addEventListener("abort",b,{once:!0}),R.outcome.then(N=>{O.removeEventListener("abort",b),L(N)})});return(R,{scope:O,signal:L})=>{if(R.length>r.maxHtmlBytes||Buffer.byteLength(R,"utf8")>r.maxHtmlBytes)return Promise.resolve(Be);const b=Ze.createHash("sha256").update(R,"utf8").digest("base64"),N=g.get(b);if(N!==void 0)return Promise.resolve(N);if(L.aborted)return Promise.resolve(_e);const z=`${b}\0${O}`,D=x.get(z);return I(D===void 0?k(R,b,z,O):D,L)}},be=e=>({result:e,json:JSON.stringify(e)}),ke=Object.freeze(be(Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}))),gr=e=>e.status==="ok"&&e.entries.length>0,Er=({ttlMs:e,maxEntries:t,maxBytes:r,now:n})=>{const s=rt(t,{max:r,of:(l,h)=>2*h.tree.json.length}),o=new Map,c=new Map,m=(l,h)=>{const A=new AbortController,k={waiters:0,superseded:!1,started:!1,loadTree:h},I=c.get(l),R=(z,D)=>{const u=be(z);return!(k.superseded||A.signal.aborted)&&gr(z)&&s.set(l,{tree:u,loadedAt:D}),u},L=(async()=>{if(I!==void 0&&await I,A.signal.aborted)return ke;const z=n();return k.started=!0,R(await k.loadTree(A.signal,z),z)})().finally(()=>{o.get(l)===b&&o.delete(l)}),b={promise:L,controller:A,state:k};o.set(l,b);const N=L.then(()=>{},()=>{});return c.set(l,N),N.then(()=>{c.get(l)===N&&c.delete(l)}),b},g=(l,h,A)=>{h.state.waiters+=1;const k=()=>{h.state.waiters-=1,!(h.state.waiters>0)&&(o.get(l)===h&&o.delete(l),h.controller.abort())};return A.addEventListener("abort",k,{once:!0}),h.promise.finally(()=>{A.removeEventListener("abort",k)})},x=l=>{s.delete(l);const h=o.get(l);h?.state.started&&(h.state.superseded=!0,o.delete(l))};return{load:(l,h,A)=>{if(h.aborted)return Promise.resolve(ke);const k=s.get(l);if(k!==void 0){if(n()-k.loadedAt<e)return Promise.resolve(k.tree);s.delete(l)}const I=o.get(l);return g(l,I===void 0?m(l,A):I,h)},refresh:(l,h,A)=>{if(h.aborted)return Promise.resolve(ke);x(l);const k=o.get(l);return k===void 0?g(l,m(l,A),h):(k.state.loadTree=A,g(l,k,h))},forget:x}},yr=e=>({load:(t,r,n)=>n(r,e()).then(be),refresh:(t,r,n)=>n(r,e()).then(be),forget:()=>{}}),v=e=>{throw new TypeError(`[markdown-explorer] ${e}`)},br=e=>{if(e===null||typeof e!="object")return null;const{name:t,path:r}=e;return typeof t!="string"||typeof r!="string"?null:t===""?{path:r,reason:"an empty name"}:y.isAcceptableDocumentPath(r)?null:{path:r,reason:"a path the browser cannot address (empty, too long, a lone surrogate, a control character or a backslash)"}},Sr=(e,t,r,n,s)=>{const o=new Set,c=g=>{if(!Array.isArray(g))return v("a source returned entries that are not an array");const x=[];for(const l of g){const h=m(l);h!==null&&x.push(h)}return x},m=g=>{const x=br(g);if(x!==null)return n(x),null;const l=y.entryViolation(g);if(l!==null)return v(l);const h=g;if(o.has(h))return v("a source returned entries that contain themselves");const{name:A,path:k,type:I,mimeType:R,children:O,lazy:L}=h;if(t.deniesName(A)||t.deniesPath(k))return null;if(!s(k))return n({path:k,reason:"a path outside the source's boundary"}),null;const b=R===void 0?{name:A,path:k}:{name:A,path:k,mimeType:R};if(I==="file")return{...b,type:I};if(L===!0)return r?{...b,type:I,lazy:!0,children:[]}:v("a lazy directory came from a source without a children function");if(O===void 0)return{...b,type:I};o.add(h);const N=c(O);return o.delete(h),{...b,type:I,children:N}};return c(e)},Tr=/^[\x21\x23-\x7E]{1,256}$/u,st=e=>typeof e=="string"&&Tr.test(e),xr=new Set(["text","image","media","file"]),Or=e=>typeof e=="string"&&xr.has(e),Rr=(e,t)=>{if(e!==null&&typeof e=="object"){const s=e,{kind:o}=s;if(Or(o)){if(Object.hasOwn(s,"url"))return v(`a ${o} document carries its version, not a url`);if(typeof s.name!="string")return v("a document needs a name string");if(!st(s.version))return v(`a ${o} document needs a version of 1 to 256 visible ASCII characters other than '"'`);const c=t(s.version);switch(o){case"image":case"file":return{kind:o,name:s.name,url:c};case"media":{const{mediaType:m}=s;return y.isExplorerMediaType(m)?{kind:o,name:s.name,url:c,mediaType:m}:v(`unknown media type ${typeof m=="string"?JSON.stringify(m.slice(0,64)):typeof m}`)}case"text":return typeof s.text!="string"||typeof s.truncated!="boolean"?v("a text document needs text and truncated"):{kind:o,name:s.name,text:s.text,truncated:s.truncated,url:c}}}}const r=y.documentViolation(e);if(r!==null)return v(r);const n=e;switch(n.kind){case"failure":{const{reason:s,code:o}=n.failure;return{kind:"failure",failure:y.failureOf(s,o)}}case"markdown":return n.headings.length>y.EXPLORER_MAX_HEADINGS?{kind:"failure",failure:y.failureOf("too-large")}:{kind:"unsanitized-markdown",name:n.name,html:n.htmlContent,headings:n.headings.map(({text:s,depth:o,id:c})=>({text:s,depth:o,id:c}))}}},_r=e=>{if(e===null||typeof e!="object")return v("an asset file must be an object");const{name:t,contentType:r,size:n,version:s,open:o}=e;return typeof t!="string"||t===""?v("an asset file needs a non-empty name"):typeof r!="string"?v("an asset file needs a contentType string ('' when unknown)"):n!==null&&!(typeof n=="number"&&Number.isSafeInteger(n)&&n>=0)?v("an asset file's size must be null or a non-negative safe integer"):st(s)?typeof o!="function"?v("an asset file needs an open function"):Object.freeze({name:t,contentType:r,size:n,version:s,open:o}):v(`an asset file needs a version of 1 to 256 visible ASCII characters other than '"'`)},kr=e=>Array.isArray(e)?e.map(t=>{if(t===null||typeof t!="object")return v("a notice must be an object");const{id:r,tone:n,title:s,body:o,action:c}=t;if(typeof r!="string"||r===""||typeof s!="string")return v("a notice needs an id and a title");if(!y.isExplorerNoticeTone(n))return v(`unknown notice tone ${typeof n=="string"?JSON.stringify(n.slice(0,64)):typeof n}`);if(o!==void 0&&typeof o!="string")return v("a notice body must be a string");const g={id:r,tone:n,title:s,...o===void 0?{}:{body:o}};if(c===void 0)return g;if(c===null||typeof c!="object")return v("a notice action must be an object");const{label:x,href:l}=c;return typeof x!="string"||!y.isAcceptableUrl(l,y.EXPLORER_LINK_PROTOCOLS)?v("a notice action needs a label and an http(s), mailto or relative href"):{...g,action:{label:x,href:l}}}):v("notices must be an array"),Ar=4e3,he=Object.freeze({ttlMs:3e5,maxEntries:64,maxBytes:64*1024*1024}),Ue=32,it="private, no-store",Nr=Object.freeze({"Content-Type":"application/json; charset=utf-8","Cache-Control":it,"X-Content-Type-Options":"nosniff","Content-Security-Policy":"default-src 'none'; frame-ancestors 'none'; sandbox","Cross-Origin-Resource-Policy":"same-origin"}),Pr=22,Ir=2147483647,Ae=Object.freeze([]),Xe=Object.freeze(["contains","confirm"]),J=(e,t,r)=>{if(!(r&&t===void 0)&&typeof t!="function")throw new TypeError(`[markdown-explorer] ${e} must be a function; got ${typeof t}`)},ye=(e,t,r)=>{if(typeof t!="number")throw new TypeError(`[markdown-explorer] ${e} must be a number; got ${typeof t}`);if(!Number.isSafeInteger(t)||t<=0||t>r)throw new RangeError(`[markdown-explorer] ${e} must be an integer in 1..${String(r)}; got ${String(t)}`);return t},Mr=e=>{if(e===null||typeof e!="object"||!Object.isFrozen(e))throw new TypeError("[markdown-explorer] config must be the value returned by defineExplorerConfig");return ee.defineExplorerConfig(e)},vr=e=>{if(typeof e!="string")throw new TypeError(`[markdown-explorer] scopeSecret must be a string; got ${typeof e}`);if(e.length<Ue)throw new RangeError(`[markdown-explorer] scopeSecret must have at least ${String(Ue)} characters; got ${String(e.length)}`);return e},Lr=(e,t)=>{if(!ee.isPlainObject(t))throw new TypeError(`[markdown-explorer] ${e}.boundary must be a plain object { contains, confirm? }`);for(const r of Object.keys(t))if(!Xe.includes(r))throw new RangeError(`[markdown-explorer] ${e}.boundary.${r} is not an option; expected ${Xe.join(", ")}`);J(`${e}.boundary.contains`,t.contains,!1),J(`${e}.boundary.confirm`,t.confirm,!0)},$r=e=>{if(!Array.isArray(e))throw new TypeError("[markdown-explorer] sources must be an array");const t=e;if(t.length===0)throw new RangeError("[markdown-explorer] sources must hold at least one source");const r=new Set;for(const[n,s]of t.entries()){if(s===null||typeof s!="object")throw new TypeError(`[markdown-explorer] sources[${String(n)}] must be an object`);const{id:o,label:c,boundary:m,tree:g,children:x,cacheScope:l}=s;if(!ee.isExplorerSourceId(o))throw new RangeError(`[markdown-explorer] sources[${String(n)}].id must use lowercase letters, digits and "-" and start with a letter or digit; got ${typeof o=="string"?JSON.stringify(o):typeof o}`);const h=`source ${JSON.stringify(o)}`;if(r.has(o))throw new RangeError(`[markdown-explorer] source ids must be unique; ${JSON.stringify(o)} repeats at sources[${String(n)}]`);if(r.add(o),typeof c!="string"&&typeof c!="function")throw new TypeError(`[markdown-explorer] ${h}.label must be a string or a function`);if(typeof c=="string"&&c.trim()==="")throw new RangeError(`[markdown-explorer] ${h}.label must not be blank`);if(Lr(h,m),J(`${h}.tree`,g,!1),J(`${h}.children`,x,!0),l!==void 0&&l!=="principal"&&l!=="shared")throw new RangeError(`[markdown-explorer] ${h}.cacheScope must be "principal" or "shared"; got ${JSON.stringify(l)}`)}return t},jr=e=>{if(e===!1)return!1;if(e===void 0)return he;if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] treeCache must be { ttlMs, maxEntries, maxBytes } or false");const{ttlMs:t,maxEntries:r,maxBytes:n}=e;return{ttlMs:t===void 0?he.ttlMs:ye("treeCache.ttlMs",t,Number.MAX_SAFE_INTEGER),maxEntries:r===void 0?he.maxEntries:ye("treeCache.maxEntries",r,Number.MAX_SAFE_INTEGER),maxBytes:n===void 0?he.maxBytes:ye("treeCache.maxBytes",n,Number.MAX_SAFE_INTEGER)}},Ge=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] authenticate must resolve to { status, ... }");const{status:t}=e;if(t!=="signed-in"&&t!=="signed-out"&&t!=="forbidden")throw new TypeError(`[markdown-explorer] authenticate resolved to an unknown status ${JSON.stringify(t)}`);return e},Je=(e,t)=>{if(!(t instanceof Response))throw new TypeError(`[markdown-explorer] ${e} must return a Response`);return t},Ye=(e,t)=>{if(typeof t!="string"||t==="")throw new TypeError("[markdown-explorer] principalKey must return a non-empty string");return Ze.createHmac("sha256",e).update(t,"utf8").digest("base64url").slice(0,Pr)},Dr=e=>e.view==="multi"?e.docs:e.doc===null?[]:[e.doc],we=(e,t)=>{const r=e.getAll(t),[n]=r;return r.length===1&&n!==void 0&&n!==""?n:null},ue=(e,t,r,n={})=>{const s=new Headers(r);for(const[o,c]of Object.entries({...Nr,...n}))s.set(o,c);return new Response(t,{status:e,headers:s})},U=(e,t,r)=>ue(y.EXPLORER_FAILURE_STATUS[e.reason],JSON.stringify({failure:e}),t,r),We=e=>{if(e.headers.get(y.EXPLORER_REFRESH_HEADER)!==y.EXPLORER_REFRESH_HEADER_VALUE)return!1;const t=e.headers.get("Sec-Fetch-Site");return t===null||t==="same-origin"},zr=({parentHeaders:e,loaderHeaders:t,errorHeaders:r})=>{const n=new Headers,s=r===void 0?[e,t]:[e,t,r];for(const o of s)for(const[c,m]of o)c!=="set-cookie"&&n.set(c,m);return n},Cr=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the server configuration must be an object");const t=Mr(e.config),r=vr(e.scopeSecret);J("authenticate",e.authenticate,!1),J("principalKey",e.principalKey,!1),J("document",e.document,!1),J("asset",e.asset,!1),J("signedOutPage",e.signedOutPage,!1),J("forbiddenPage",e.forbiddenPage,!0),J("notices",e.notices,!0),J("onTreeRefreshed",e.onTreeRefreshed,!0);const n=$r(e.sources),s=ee.withExplorerSources(t,n.map(i=>i.id)),o=e.logger;if(o!==void 0&&(o===null||typeof o!="object"||typeof o.error!="function"))throw new TypeError("[markdown-explorer] logger must be an object with an error function");const c=e.logger===void 0?$t:e.logger,m=y.resolvePathRules(e.deny),g=e.deferredTimeoutMs===void 0?Ar:ye("deferredTimeoutMs",e.deferredTimeoutMs,Ir),x=jr(e.treeCache),l=()=>Date.now(),h=x===!1?yr(l):Er({...x,now:l}),A=dr(e.sanitizer,t.multiView.maxPanels),k=wr({iframeHosts:t.iframeHosts,dataPath:t.dataPath,options:A,pool:mr(fr(),A)}),I=new Map(n.map(i=>[i.id,i])),R=ee.documentStyleNames(t),{authenticate:O,principalKey:L,signedOutPage:b,forbiddenPage:N,onTreeRefreshed:z}=e,D=(i,w)=>{if(typeof i.label=="string")return i.label;const d=i.label(w);if(typeof d!="string"||d.trim()==="")throw new TypeError(`[markdown-explorer] the label of source ${JSON.stringify(i.id)} must be a non-blank string`);return d},u=(i,w)=>i.cacheScope==="shared"?i.id:`${i.id}\0${w}`,a=(i,w)=>{const d=f=>ne(c,{operation:"boundary",sourceId:i.id,path:w,error:f});let p;try{p=i.boundary.contains(w)}catch(f){return d(f),!1}return typeof p=="boolean"?p:(De(p,d),d(new TypeError(`[markdown-explorer] boundary.contains of source ${JSON.stringify(i.id)} must return a boolean; got ${typeof p}`)),!1)},E=async(i,w,d)=>{const{confirm:p}=i.boundary;if(p===void 0)return{status:"inside",readPath:d};let f;try{f=await p(w,d)}catch(V){return{status:"error",failure:re(V,{operation:"boundary",sourceId:i.id,path:d},w.signal,c)}}const T=V=>(ne(c,{operation:"boundary",sourceId:i.id,path:d,error:new TypeError(`[markdown-explorer] boundary.confirm of source ${JSON.stringify(i.id)} ${V}`)}),{status:"outside"});if(f===null||typeof f!="object")return T(`must resolve to { inside, readPath? }; got ${f===null?"null":typeof f}`);const{inside:j,readPath:H}=f;return j===!1?{status:"outside"}:j!==!0||typeof H!="string"?T("must resolve to { inside: false } or { inside: true, readPath: string }"):!y.isAcceptableDocumentPath(H)||m.deniesPath(H)?(ne(c,{operation:"boundary",sourceId:i.id,path:d,error:new RangeError(`[markdown-explorer] boundary.confirm of source ${JSON.stringify(i.id)} answered a readPath the explorer does not serve (unacceptable or denied)`)}),{status:"error",failure:{reason:"failed"}}):{status:"inside",readPath:H}},S=async(i,w)=>{const d=n.filter(f=>a(f,w));if(d.length===0)return{status:"error",failure:{reason:"forbidden"}};if(d.some(f=>f.boundary.confirm===void 0))return{status:"inside",readPath:w};let p=null;for(const f of d){const T=await E(f,i,w);if(T.status==="inside")return T;T.status==="error"&&p===null&&(p=T.failure)}return{status:"error",failure:p===null?{reason:"forbidden"}:p}},_=(i,w,d)=>{const p=({path:f,reason:T})=>zt(c,{operation:d.operation,sourceId:d.sourceId,path:f,error:new TypeError(`[markdown-explorer] an entry with ${T} was left out`)});try{return{status:"ok",entries:Sr(i,m,w.children!==void 0,p,f=>a(w,f))}}catch(f){return ne(c,{...d,error:f}),{status:"error",failure:{reason:"failed"}}}},P=async(i,w,d)=>{let p;try{p=await i.tree(w)}catch(T){return{status:"error",failure:re(T,{operation:"tree",sourceId:i.id},w.signal,c)}}const f=_(p,i,{operation:"tree",sourceId:i.id});return f.status==="ok"?{status:"ok",entries:f.entries,loadedAt:d}:f},C=(i,w,d,p)=>(f,T)=>P(i,{principal:w,request:d,signal:f,refresh:p},T),M=(i,w,d,p,f)=>h.load(u(i,d),f,C(i,w,p,!1)),X=(i,w,d,p)=>h.refresh(u(i,d),p.signal,C(i,w,p,!0)),G=(i,w)=>{if(z===void 0)return;const d=p=>ne(c,{operation:"refresh",sourceId:i.id,error:p});try{De(z(w),d)}catch(p){d(p)}},F=async(i,w,d,p)=>{if(m.deniesPath(p)||!a(i,p))return{status:"error",failure:{reason:"forbidden"}};const f=await E(i,d,p);if(f.status==="outside")return{status:"error",failure:{reason:"forbidden"}};if(f.status==="error")return{status:"error",failure:f.failure};let T;try{T=await w(d,p,f.readPath)}catch(j){return{status:"error",failure:re(j,{operation:"children",sourceId:i.id,path:p},d.signal,c)}}return _(T,i,{operation:"children",sourceId:i.id,path:p})},Z=async(i,w,d)=>{if(m.deniesPath(d))return y.failureDocument("forbidden");const p=await S(i,d);if(p.status==="error")return{kind:"failure",failure:p.failure};let f;try{f=await e.document(i,d,p.readPath)}catch(H){return{kind:"failure",failure:re(H,{operation:"document",path:d},i.signal,c)}}let T;try{T=Rr(f,H=>y.explorerAssetHref(t.dataPath,d,H))}catch(H){return ne(c,{operation:"document",path:d,error:H}),y.failureDocument("failed")}if(T.kind!=="unsanitized-markdown")return T;const j=await k(T.html,{scope:w,signal:i.signal});return j.status==="sanitized"?{kind:"markdown",name:T.name,htmlContent:j.html,headings:T.headings}:(j.cause!==null&&ne(c,{operation:"document",path:d,error:j.cause}),y.failureDocument(j.reason))},$=async i=>{if(e.notices===void 0)return Ae;try{return kr(await e.notices(i))}catch(w){return re(w,{operation:"notices"},i.signal,c),Ae}},Y=async(i,w,d)=>{const p=we(w,y.EXPLORER_DATA_QUERY.path);if(p===null||!y.isAcceptableDocumentPath(p))return U({reason:"invalid"},d);if(m.deniesPath(p))return Ct(c,{operation:"asset",path:p}),U({reason:"forbidden"},d);const f=await S(i,p);if(f.status==="error")return U(f.failure,d);try{const T=_r(await e.asset(i,p,f.readPath));return await Lt(i.request,T,d)}catch(T){return U(re(T,{operation:"asset",path:p},i.signal,c),d)}},W=async({request:i,url:w,params:d})=>{const p=Ge(await O(i)),f=new Headers(p.headers);if(f.set("Cache-Control",it),p.status==="signed-out")throw Je("signedOutPage",b(i,f));if(p.status==="forbidden")throw N===void 0?Se.data(null,{status:403,headers:f}):Je("forbiddenPage",N(i,f));const T=ee.resolveExplorerLocation(s,d["*"],w.searchParams);if(T.kind==="redirect")throw Se.redirect(T.href,{headers:f});const{location:j}=T,{principal:H}=p,V=Ye(r,L(H)),de=I.get(j.source);if(de===void 0)throw new RangeError(`[markdown-explorer] no source for ${JSON.stringify(j.source)}`);const oe={signal:i.signal,timeoutMs:g,late:null,handOverMs:g},Q={scope:V,sources:n.map(B=>({id:B.id,label:D(B,H)})),settings:ee.parseViewSettings(ee.readCookieValue(i.headers.get("Cookie"),t.settingsCookie),R),tree:j.view==="single"?null:{sourceId:j.source,result:Re(oe,B=>M(de,H,V,i,B).then(ae=>ae.result))},documents:Dr(j).map(B=>({path:B,document:Re(oe,ae=>Z({principal:H,request:i,signal:ae,refresh:!1},V,B))})),notices:Re({signal:i.signal,timeoutMs:g,late:Ae,handOverMs:0},B=>$({principal:H,request:i,signal:B,refresh:!1}))};return Se.data(Q,{headers:f})},K=async(i,w,d)=>{let p;try{p=Ge(await O(w))}catch(B){return U(re(B,{operation:"authenticate"},w.signal,c))}const f=new Headers(p.headers);if(p.status==="signed-out")return U({reason:"unauthorized"},f);if(p.status==="forbidden")return U({reason:"forbidden"},f);const{principal:T}=p;if(i==="asset")return Y({principal:T,request:w,signal:w.signal,refresh:!1},d,f);const j=Ye(r,L(T));f.set(y.EXPLORER_SCOPE_HEADER,j);const H={principal:T,request:w,signal:w.signal,refresh:!1},V=()=>U({reason:"invalid"},f);if(i==="document"){const B=we(d,y.EXPLORER_DATA_QUERY.path);if(B===null||!y.isAcceptableDocumentPath(B))return V();const ae=w.headers.has(y.EXPLORER_REFRESH_HEADER);return ae&&!We(w)?U({reason:"forbidden"},f):ue(200,JSON.stringify(await Z({...H,refresh:ae},j,B)),f)}const de=we(d,y.EXPLORER_DATA_QUERY.source),oe=we(d,y.EXPLORER_DATA_QUERY.path);if(de===null||i==="children"&&(oe===null||!y.isAcceptableDocumentPath(oe)))return V();const Q=I.get(de);if(Q===void 0)return U({reason:"not-found"},f);if(i==="tree")return ue(200,(await M(Q,T,j,w,w.signal)).json,f);if(i==="refresh"){const B=await X(Q,T,j,w);return w.signal.aborted||G(Q,u(Q,j)),ue(200,B.json,f)}return Q.children===void 0||oe===null?U({reason:"not-found"},f):ue(200,JSON.stringify(await F(Q,Q.children,H,oe)),f)},le=async(i,w,d)=>{if(new URL(i.url).pathname.endsWith(".data"))return U({reason:"not-found"});if(!y.isExplorerDataOperation(d))return U({reason:"not-found"});const p=i.method.toUpperCase(),f=d==="refresh";if(f?p!=="POST":p!=="GET"&&p!=="HEAD")return ue(405,JSON.stringify({failure:{reason:"invalid"}}),void 0,{Allow:f?"POST":"GET, HEAD"});if(f&&!We(i))return U({reason:"forbidden"});try{return await K(d,i,w.searchParams)}catch(T){return U(re(T,{operation:d},i.signal,c))}};return Object.freeze({loader:W,headers:zr,dataLoader:({request:i,url:w,params:d})=>le(i,w,d["*"]),dataAction:({request:i,url:w,params:d})=>le(i,w,d["*"]),forgetTree:i=>{if(typeof i!="string")throw new TypeError(`[markdown-explorer] forgetTree needs the string key onTreeRefreshed received; got ${typeof i}`);h.forget(i)}})},ge=Object.freeze({maxEntries:2e4,maxDocumentBytes:2*1024*1024,textPreviewBytes:8*1024,walkConcurrency:8}),Hr=new Set(["md","markdown","mdx"]),at=new Map([...[["png","image/png"],["jpg","image/jpeg"],["jpeg","image/jpeg"],["gif","image/gif"],["svg","image/svg+xml"],["webp","image/webp"],["ico","image/x-icon"],["bmp","image/bmp"],["tif","image/tiff"],["tiff","image/tiff"],["avif","image/avif"]].map(([e,t])=>[e,{kind:"image",contentType:t}]),...[["mp4","video/mp4"],["m4v","video/mp4"],["webm","video/webm"],["mov","video/quicktime"],["avi","video/x-msvideo"],["mkv","video/x-matroska"],["ogv","video/ogg"]].map(([e,t])=>[e,{kind:"media",mediaType:"video",contentType:t}]),...[["mp3","audio/mpeg"],["wav","audio/wav"],["ogg","audio/ogg"],["oga","audio/ogg"],["opus","audio/ogg"],["m4a","audio/mp4"],["flac","audio/flac"],["aac","audio/aac"],["wma","audio/x-ms-wma"]].map(([e,t])=>[e,{kind:"media",mediaType:"audio",contentType:t}]),["pdf",{kind:"media",mediaType:"pdf",contentType:"application/pdf"}]]),Br=new Set(["txt","text","log","csv","tsv","json","jsonc","json5","ndjson","yaml","yml","toml","ini","cfg","conf","properties","xml","xsl","xsd","dtd","html","htm","xhtml","css","scss","sass","less","styl","js","mjs","cjs","jsx","ts","mts","cts","tsx","vue","svelte","astro","py","pyi","rb","go","rs","java","kt","kts","scala","groovy","gradle","c","h","cc","cpp","cxx","hpp","hh","hxx","cs","fs","vb","swift","m","mm","php","pl","pm","r","jl","lua","dart","ex","exs","erl","hrl","hs","ml","mli","clj","cljs","elm","nim","zig","v","sol","tf","hcl","nix","sh","bash","zsh","fish","ps1","psm1","bat","cmd","sql","graphql","gql","proto","thrift","avsc","rst","adoc","asciidoc","tex","bib","org","textile","diff","patch","srt","vtt","ics","vcf","gitignore","gitattributes","editorconfig","dockerignore","npmignore","prettierrc","eslintrc","babelrc","mailmap"]),Fr=new Set(["readme","license","licence","copying","notice","authors","contributors","changelog","changes","todo","makefile","dockerfile","containerfile","procfile","gemfile","rakefile","vagrantfile","jenkinsfile","brewfile","codeowners"]),ct=typeof te.constants.O_NOFOLLOW=="number"?te.constants.O_NOFOLLOW:0,ut=typeof te.constants.O_NONBLOCK=="number"?te.constants.O_NONBLOCK:0,Ke=e=>`${e.size}-${e.mtimeNs}`,Ur=e=>e!==""&&e!=="."&&e!==".."&&!e.includes(":")&&!e.endsWith(".")&&!e.endsWith(" "),Ve=e=>y.isAcceptableDocumentPath(e)&&e===e.normalize("NFC")&&e.split("/").every(Ur),lt=e=>{const t=e.toLowerCase(),r=t.lastIndexOf(".");return r<0?"":t.slice(r+1)},Xr=e=>{const t=lt(e);if(Hr.has(t))return{kind:"markdown"};const r=at.get(t);if(r!==void 0)return r.kind==="image"?{kind:"image"}:{kind:"media",mediaType:r.mediaType};const n=e.toLowerCase();return Br.has(t)||!n.includes(".")&&Fr.has(n)?{kind:"text"}:{kind:"file"}},dt=e=>{switch(typeof e=="object"&&e!==null?e.code:void 0){case"ENOENT":case"ENOTDIR":return"not-found";case"ELOOP":case"EACCES":case"EPERM":return"forbidden";case"ENAMETOOLONG":return"invalid";case"EISDIR":return"unsupported";default:return null}},ft=e=>{const t=dt(e);return t===null?e:new me(t)},Gr=e=>{const t=typeof e=="object"&&e!==null?e.code:void 0;return t==="EACCES"||t==="EPERM"||t==="ENOENT"||t==="ENOTDIR"},Qe=async(e,t)=>{const r=[];for await(const n of e.createReadStream({start:0,end:t-1,autoClose:!1}))r.push(n);return Buffer.concat(r)},Jr=(e,t)=>e!==null?{start:e.offset,end:e.offset+e.length-1}:t===0n?{}:{start:0,end:Number(t)-1},Yr=async(e,t,r,n)=>{let s;try{s=await fe.open(e,te.constants.O_RDONLY|ct|ut);const g=await s.stat({bigint:!0});if(!g.isFile()||g.ino!==t.ino||g.dev!==t.dev||g.size!==t.size||g.mtimeNs!==t.mtimeNs)throw new me("not-found")}catch(g){throw await s?.close(),ft(g)}const o=s.createReadStream(Jr(r,t.size)),c=pt.Readable.toWeb(o),m=()=>{o.destroy(n.reason)};return n.aborted?m():n.addEventListener("abort",m,{once:!0}),c},Wr=(e,t)=>{const r=ee.NAME_COLLATOR.compare(e,t);return r!==0?r:e===t?0:e<t?-1:1},Kr=e=>{let t=0;const r=[];return async n=>{t<e?t+=1:await new Promise(s=>r.push(s));try{return await n()}finally{const s=r.shift();s===void 0?t-=1:s()}}},Vr=(e,t)=>{if(e.isSymbolicLink())return"symbolic-link";if(!(e.isDirectory()||e.isFile()))return"special-file";const{name:r}=e;return r!==r.normalize("NFC")?"not-nfc":r.includes(":")?"colon":r.endsWith(".")||r.endsWith(" ")?"trailing-dot-or-space":y.isAcceptableDocumentPath(r)?y.isAcceptableDocumentPath(t)?null:"path-too-long":"control-character-or-backslash"},Qr=new Set(["id","label","root","pathPrefix","parse","deny","maxEntries","maxDocumentBytes","textPreviewBytes","walkConcurrency","cacheScope","reportSkipped"]),Ee=(e,t,r)=>{if(t===void 0)return r;if(typeof t!="number"||!Number.isSafeInteger(t)||t<=0)throw new RangeError(`[markdown-explorer] ${e} must be a positive integer; got ${String(t)}`);return t},Zr=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] createFileSystemSource needs an options object");for(const a of Object.keys(e))if(!Qr.has(a))throw new TypeError(`[markdown-explorer] createFileSystemSource does not know the option ${JSON.stringify(a)}`);const{id:t,label:r,root:n,parse:s}=e;if(typeof t!="string"||t==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-empty id");if(typeof r!="string"||r.trim()==="")throw new TypeError("[markdown-explorer] a file-system source needs a non-blank label");if(typeof s!="function")throw new TypeError("[markdown-explorer] a file-system source needs a parse function");if(typeof n!="string"||!q.isAbsolute(n))throw new RangeError(`[markdown-explorer] root must be an absolute path; got ${JSON.stringify(n)}`);let o;try{o=te.statSync(n).isDirectory()}catch(a){throw new RangeError(`[markdown-explorer] root does not exist: ${n}`,{cause:a})}if(!o)throw new RangeError(`[markdown-explorer] root is not a directory: ${n}`);const c=te.realpathSync(n),m=e.pathPrefix;if(typeof m!="string")throw new TypeError('[markdown-explorer] pathPrefix is required: "" for a source over the whole root, or relative segments ending with "/"');if(m!==""&&!(m.endsWith("/")&&Ve(m.slice(0,-1))))throw new RangeError(`[markdown-explorer] pathPrefix must be empty or relative segments ending with "/"; got ${JSON.stringify(m)}`);const g=y.resolvePathRules(e.deny),x=Ee("maxEntries",e.maxEntries,ge.maxEntries),l=Ee("maxDocumentBytes",e.maxDocumentBytes,ge.maxDocumentBytes),h=Ee("textPreviewBytes",e.textPreviewBytes,ge.textPreviewBytes),A=Ee("walkConcurrency",e.walkConcurrency,ge.walkConcurrency),k=e.cacheScope===void 0?"principal":e.cacheScope;if(k!=="principal"&&k!=="shared")throw new RangeError(`[markdown-explorer] cacheScope must be "principal" or "shared"; got ${JSON.stringify(k)}`);const I=e.reportSkipped;if(I!==void 0&&typeof I!="function")throw new TypeError("[markdown-explorer] reportSkipped must be a function");const R=I===void 0?a=>{console.warn(`[markdown-explorer] the file-system source ${JSON.stringify(a.sourceId)} does not list ${JSON.stringify(a.path)}: ${a.reason}`)}:I,O=new Set,L=a=>{const E=q.resolve(c,...a.split("/")),S=q.relative(c,E);return S===""||S===".."||S.startsWith(`..${q.sep}`)||q.isAbsolute(S)?null:E},b=(a,E)=>{const S=`${E}\0${a}`;O.has(S)||O.size>=x||(O.add(S),R({sourceId:t,path:a,reason:E}))},N=async({signal:a})=>{a.throwIfAborted();const E=new AbortController,S=()=>{E.abort(a.reason)};a.addEventListener("abort",S,{once:!0});const _=Kr(A);let P=0;const C=async(M,X)=>{const G=await _(async()=>{E.signal.throwIfAborted();try{return await fe.readdir(M,{withFileTypes:!0})}catch($){if(X===""||!Gr($))throw $;return null}});if(E.signal.throwIfAborted(),G===null)return b(`${m}${X}`,"unreadable-directory"),null;const F=[];for(const $ of G){if(g.deniesName($.name))continue;const Y=X===""?$.name:`${X}/${$.name}`,W=`${m}${Y}`,K=Vr($,W);if(K!==null){b(W,K);continue}F.push({dirent:$,relativePath:Y,path:W})}if(P+=F.length,P>x)throw new me("too-large");return F.sort(($,Y)=>Wr($.dirent.name,Y.dirent.name)),(await Promise.all(F.map(async({dirent:$,relativePath:Y,path:W})=>{if(!$.isDirectory())return{name:$.name,path:W,type:"file"};const K=await C(q.join(M,$.name),Y);return K===null?null:{name:$.name,path:W,type:"directory",children:K}}))).filter($=>$!==null)};try{const M=await C(c,"");if(M===null)throw new Error("[markdown-explorer] the source's root could not be listed");return M}catch(M){throw E.abort(),M}finally{a.removeEventListener("abort",S)}},z=async a=>{if(!a.startsWith(m))return{status:"refused",reason:"not-found"};const E=a.slice(m.length);if(!Ve(E))return{status:"refused",reason:"invalid"};if(g.deniesPath(E))return{status:"refused",reason:"forbidden"};const S=L(E);if(S===null)return{status:"refused",reason:"forbidden"};const _=await fe.lstat(S,{bigint:!0});if(_.isSymbolicLink())return{status:"refused",reason:"forbidden"};if(!_.isFile())return{status:"refused",reason:"unsupported"};const P=await fe.realpath(S);return P!==S||g.deniesPath(q.relative(c,P).split(q.sep).join("/"))?{status:"refused",reason:"forbidden"}:{status:"file",target:S,name:E.slice(E.lastIndexOf("/")+1),stats:_}},D=async(a,E,S)=>{let _;try{const P=await z(S);if(P.status==="refused")return y.failureDocument(P.reason);const{target:C,name:M,stats:X}=P,G=Xr(M),F=Ke(X);if(G.kind==="image")return{kind:"image",name:M,version:F};if(G.kind==="media")return{kind:"media",name:M,mediaType:G.mediaType,version:F};if(G.kind==="file")return{kind:"file",name:M,version:F};_=await fe.open(C,te.constants.O_RDONLY|ct|ut);const Z=await _.stat({bigint:!0});if(!Z.isFile()||Z.ino!==X.ino||Z.dev!==X.dev)return y.failureDocument("forbidden");if(G.kind==="markdown"){if(Z.size>BigInt(l))return y.failureDocument("too-large");const K=await Qe(_,l+1);if(K.length>l)return y.failureDocument("too-large");const le=await s(new TextDecoder("utf-8").decode(K),E);return{kind:"markdown",name:M,htmlContent:le.htmlContent,headings:le.headings}}const $=await Qe(_,h);if($.includes(0))return{kind:"file",name:M,version:F};const Y=Z.size>BigInt(h),W=new TextDecoder("utf-8").decode($,{stream:Y});return{kind:"text",name:M,text:W,truncated:Y,version:F}}catch(P){const C=dt(P);if(C===null)throw P;return y.failureDocument(C)}finally{await _?.close()}},u=async(a,E,S)=>{let _;try{_=await z(S)}catch(F){throw ft(F)}if(_.status==="refused")throw new me(_.reason);const{target:P,name:C,stats:M}=_,X=at.get(lt(C)),G=X===void 0?"":X.contentType;return{name:C,contentType:G,size:Number(M.size),version:Ke(M),open:F=>Yr(P,M,F,a.signal)}};return Object.freeze({id:t,label:r,cacheScope:k,boundary:Object.freeze({contains:a=>a.startsWith(m)}),tree:N,document:D,asset:u})};exports.DEFAULT_DENIED_PATH_SEGMENTS=y.DEFAULT_DENIED_PATH_SEGMENTS;exports.MAX_DOCUMENT_PATH_LENGTH=y.MAX_DOCUMENT_PATH_LENGTH;exports.isAcceptableDocumentPath=y.isAcceptableDocumentPath;exports.isDeniedPath=y.isDeniedPath;exports.ExplorerError=me;exports.anonymousAccess=ht;exports.createFileSystemSource=Zr;exports.createMarkdownExplorer=Cr;
package/dist/server.js CHANGED
@@ -2,7 +2,7 @@ import { a as et, b as Et, f as Re, c as yt, d as bt, g as St, h as Tt, E as xt,
2
2
  import { D as Qn, M as qn, t as eo } from "./dataRoute-Bkfwfp1R.js";
3
3
  import { createHash as Mt, createHmac as Pt } from "node:crypto";
4
4
  import { data as Ie, redirect as vt } from "react-router";
5
- import { w as $t, d as jt, a as Lt, i as zt, r as Dt, p as Ct, b as Ht, f as Bt, N as Ft } from "./location-Cb2Ak55B.js";
5
+ import { w as $t, d as jt, a as Lt, i as zt, r as Dt, p as Ct, b as Ht, f as Bt, N as Ft } from "./location-fVl2R1ee.js";
6
6
  import { existsSync as Ut, statSync as Gt, realpathSync as Xt, constants as ce } from "node:fs";
7
7
  import { extname as Jt, isAbsolute as Me, relative as Pe, sep as ve, join as Wt, resolve as Yt } from "node:path";
8
8
  import { fileURLToPath as be } from "node:url";
@@ -1,3 +1,3 @@
1
1
  /*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
2
2
  /*! @aiquants/markdown-explorer — component styles, layered in `components`. The layer order is pinned first (theme, base, components, utilities, as Tailwind CSS declares it), so a Tailwind host's preflight in `base` cannot override the explorer when this sheet is the first to name a layer. */
3
- @layer theme,base;@layer components{.aqmx-root{--aqmx-space-1:.0625rem;--aqmx-space-2:.125rem;--aqmx-space-3:.1875rem;--aqmx-space-4:.3125rem;--aqmx-space-5:.5rem;--aqmx-space-6:.8125rem;--aqmx-space-7:1.3125rem;--aqmx-space-8:2.125rem;--aqmx-space-9:3.4375rem;--aqmx-control:2.125rem;--aqmx-focus-ring-width:var(--aqmx-space-2);--aqmx-focus-ring-offset:var(--aqmx-space-2);--aqmx-icon:1rem;--aqmx-radius-s:.3125rem;--aqmx-radius-m:.5rem;--aqmx-radius-l:.8125rem;--aqmx-duration-1:89ms;--aqmx-duration-2:.144s;--aqmx-duration-3:.233s;--aqmx-duration-4:.377s;--aqmx-delay-progress:.233s;--aqmx-ease:cubic-bezier(.2, 0, 0, 1);--aqmx-font-size-body:.8125rem;--aqmx-font-size-title:1rem;--aqmx-font-size-display:1.3125rem;--aqmx-line-height-compact:1.382;--aqmx-line-height-prose:1.618;--aqmx-column-measure:40ch;--aqmx-surface:#fff;--aqmx-surface-raised:#f8fafc;--aqmx-surface-sunken:#f1f5f9;--aqmx-border:#cbd5e1;--aqmx-border-strong:#94a3b8;--aqmx-text:#0f172a;--aqmx-text-muted:#475569;--aqmx-accent:#1d4ed8;--aqmx-accent-surface:#dbeafe;--aqmx-tree-line:#64748b;--aqmx-tree-row-tint:#0f172a0f;--aqmx-tree-row-accent-tint:#2563eb29;--aqmx-focus:#2563eb;--aqmx-info-surface:#eff6ff;--aqmx-info-border:#93c5fd;--aqmx-info-text:#1e3a8a;--aqmx-warning-surface:#fffbeb;--aqmx-warning-border:#fcd34d;--aqmx-warning-text:#78350f;--aqmx-danger-surface:#fef2f2;--aqmx-danger-border:#fca5a5;--aqmx-danger-text:#7f1d1d;--aqmx-shadow:0 .0625rem .1875rem #0f172a21, 0 .3125rem .8125rem #0f172a14}.aqmx-root[data-aqmx-theme=dark]{--aqmx-surface:#0f172a;--aqmx-surface-raised:#1e293b;--aqmx-surface-sunken:#020617;--aqmx-border:#334155;--aqmx-border-strong:#64748b;--aqmx-text:#e2e8f0;--aqmx-text-muted:#94a3b8;--aqmx-accent:#93c5fd;--aqmx-accent-surface:#1e3a8a;--aqmx-tree-line:#94a3b8;--aqmx-tree-row-tint:#e2e8f00f;--aqmx-tree-row-accent-tint:#2563eb70;--aqmx-focus:#60a5fa;--aqmx-info-surface:#172554;--aqmx-info-border:#1d4ed8;--aqmx-info-text:#bfdbfe;--aqmx-warning-surface:#422006;--aqmx-warning-border:#a16207;--aqmx-warning-text:#fde68a;--aqmx-danger-surface:#450a0a;--aqmx-danger-border:#b91c1c;--aqmx-danger-text:#fecaca;--aqmx-shadow:0 .0625rem .1875rem #0000008c, 0 .3125rem .8125rem #00000057}@media (pointer:coarse){.aqmx-root{--aqmx-control:2.75rem}}@media (forced-colors:active){.aqmx-root.aqmx-root[data-aqmx-theme]{--aqmx-tree-line:CanvasText}}@media (prefers-reduced-motion:reduce){.aqmx-root{--aqmx-duration-1:0s;--aqmx-duration-2:0s;--aqmx-duration-3:0s;--aqmx-duration-4:0s}}.aqmx-root{block-size:100%;min-block-size:0;inline-size:100%;min-inline-size:0;color:var(--aqmx-text);background:var(--aqmx-surface);font-size:var(--aqmx-font-size-body);line-height:var(--aqmx-line-height-compact);flex-direction:column;display:flex;position:relative}.aqmx-root *,.aqmx-root :before,.aqmx-root :after{box-sizing:border-box}.aqmx-icon-button{inline-size:var(--aqmx-control);block-size:var(--aqmx-control);border-radius:var(--aqmx-radius-m);color:var(--aqmx-text-muted);cursor:pointer;transition:background-color var(--aqmx-duration-2) var(--aqmx-ease), color var(--aqmx-duration-2) var(--aqmx-ease);background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.aqmx-icon-button:hover{color:var(--aqmx-text);background:var(--aqmx-surface-sunken)}.aqmx-icon-button[aria-pressed=true],.aqmx-icon-button[aria-expanded=true]{color:var(--aqmx-accent);background:var(--aqmx-accent-surface)}.aqmx-icon-button:disabled{opacity:.382;cursor:not-allowed}.aqmx-icon-button[aria-disabled=true]{cursor:not-allowed}.aqmx-icon-button[aria-disabled=true]:hover{color:var(--aqmx-text-muted);background:0 0}.aqmx-icon-button>svg{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon)}.aqmx-icon-button[aria-disabled=true]>svg{opacity:.382}.aqmx-root :focus-visible{outline:var(--aqmx-focus-ring-width) solid var(--aqmx-focus);outline-offset:var(--aqmx-focus-ring-offset)}.aqmx-callout{gap:var(--aqmx-space-5);padding:var(--aqmx-space-6);border:var(--aqmx-space-1) solid var(--aqmx-info-border);border-radius:var(--aqmx-radius-l);color:var(--aqmx-info-text);background:var(--aqmx-info-surface);line-height:var(--aqmx-line-height-prose);display:grid}.aqmx-callout[data-aqmx-tone=warning]{border-color:var(--aqmx-warning-border);color:var(--aqmx-warning-text);background:var(--aqmx-warning-surface)}.aqmx-callout[data-aqmx-tone=danger]{border-color:var(--aqmx-danger-border);color:var(--aqmx-danger-text);background:var(--aqmx-danger-surface)}.aqmx-callout-title{font-size:var(--aqmx-font-size-title);font-weight:600;line-height:var(--aqmx-line-height-compact);margin:0}.aqmx-callout-body{margin:0}.aqmx-callout-action{min-block-size:var(--aqmx-control);padding-inline:var(--aqmx-space-6);border:var(--aqmx-space-1) solid currentColor;border-radius:var(--aqmx-radius-m);color:inherit;font:inherit;cursor:pointer;background:0 0;justify-self:start;align-items:center;font-weight:600;text-decoration:none;display:inline-flex}.aqmx-progress{z-index:2;block-size:var(--aqmx-space-3);pointer-events:none;position:absolute;inset-block-start:0;inset-inline:0;overflow:hidden}.aqmx-progress:before{content:"";background:var(--aqmx-accent);inline-size:38.1966%;animation:aqmx-progress calc(var(--aqmx-duration-4) * 3) var(--aqmx-ease) infinite;position:absolute;inset-block:0}@keyframes aqmx-progress{0%{inset-inline-start:-38.1966%}to{inset-inline-start:100%}}.aqmx-empty{place-content:center;justify-items:center;gap:var(--aqmx-space-6);block-size:100%;padding:var(--aqmx-space-8);color:var(--aqmx-text-muted);text-align:center;line-height:var(--aqmx-line-height-prose);display:grid}.aqmx-empty-title{color:var(--aqmx-text);font-size:var(--aqmx-font-size-title);margin:0;font-weight:600}.aqmx-skeleton{gap:var(--aqmx-space-6);padding:var(--aqmx-space-7);display:grid}.aqmx-skeleton>span{block-size:var(--aqmx-space-6);border-radius:var(--aqmx-radius-s);background:var(--aqmx-surface-sunken);animation:aqmx-pulse calc(var(--aqmx-duration-4) * 4) ease-in-out infinite;display:block}.aqmx-skeleton>span:nth-child(3n+1){inline-size:61.8034%}.aqmx-skeleton>span:nth-child(3n+2){inline-size:100%}.aqmx-skeleton>span:nth-child(3n){inline-size:85.4102%}@keyframes aqmx-pulse{50%{opacity:.618}}.aqmx-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.aqmx-toast{z-index:60;max-inline-size:min(34rem, calc(100% - var(--aqmx-space-8)));padding:var(--aqmx-space-5) var(--aqmx-space-6);border:var(--aqmx-space-1) solid var(--aqmx-warning-border);border-radius:var(--aqmx-radius-m);color:var(--aqmx-warning-text);background:var(--aqmx-warning-surface);box-shadow:var(--aqmx-shadow);position:absolute;inset-block-start:var(--aqmx-space-6);inset-inline-end:var(--aqmx-space-7)}@media (prefers-reduced-motion:reduce){.aqmx-progress:before,.aqmx-skeleton>span{animation:none}}@media (forced-colors:active){.aqmx-icon-button[aria-pressed=true],.aqmx-icon-button[aria-expanded=true]{forced-color-adjust:none;color:highlighttext;background:highlight}.aqmx-icon-button[aria-disabled=true]{color:graytext}.aqmx-root :focus-visible{outline-color:highlight}.aqmx-progress:before{forced-color-adjust:none;background:highlight}.aqmx-skeleton>span{forced-color-adjust:none;background:graytext}}.aqmx-explorer{gap:var(--aqmx-space-5);block-size:100%;min-block-size:0;min-inline-size:0;padding:var(--aqmx-space-4);color:var(--aqmx-text);background:var(--aqmx-surface);flex-direction:column;display:flex;position:relative;overflow-y:auto}.aqmx-explorer-header{align-items:center;gap:var(--aqmx-space-4);min-block-size:var(--aqmx-control);flex-wrap:wrap;flex:none;display:flex}.aqmx-explorer-source{min-inline-size:min(100%,9rem);block-size:var(--aqmx-control);padding-inline:var(--aqmx-space-5);border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-m);color:var(--aqmx-text);background:var(--aqmx-surface-raised);font:inherit;text-overflow:ellipsis;cursor:pointer;flex:9rem}.aqmx-explorer-actions{justify-content:flex-end;align-items:center;gap:var(--aqmx-space-2);flex-wrap:wrap;flex:0 auto;margin-inline-start:auto;display:flex}.aqmx-explorer-body{gap:var(--aqmx-space-5);flex-direction:column;flex:1 1 0;min-block-size:0;min-inline-size:0;display:flex;position:relative}.aqmx-labelled-button{gap:var(--aqmx-space-2);inline-size:auto;padding-inline:var(--aqmx-space-3);white-space:nowrap;display:inline-flex}.aqmx-explorer-refresh-failure,.aqmx-explorer-expand-all-stop{padding:var(--aqmx-space-4) var(--aqmx-space-5);border:var(--aqmx-space-1) solid;border-radius:var(--aqmx-radius-m);line-height:var(--aqmx-line-height-compact);overflow-wrap:anywhere;flex:none;margin:0}.aqmx-explorer-refresh-failure{border-color:var(--aqmx-danger-border);color:var(--aqmx-danger-text);background:var(--aqmx-danger-surface)}.aqmx-explorer-expand-all-stop{border-color:var(--aqmx-info-border);color:var(--aqmx-info-text);background:var(--aqmx-info-surface)}.aqmx-explorer-actions>.aqmx-labelled-button[data-aqmx-busy=true]>svg{animation:aqmx-explorer-spin calc(var(--aqmx-duration-4) * 3) linear infinite}@keyframes aqmx-explorer-spin{to{rotate:1turn}}.aqmx-explorer-actions>.aqmx-icon-button[aria-busy=true]{cursor:progress}.aqmx-explorer-menu{z-index:50;gap:var(--aqmx-space-1);max-block-size:100%;inline-size:min(21rem,100%);padding:var(--aqmx-space-3);border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-m);background:var(--aqmx-surface-raised);box-shadow:var(--aqmx-shadow);display:grid;position:absolute;inset-block-start:0;inset-inline-end:0;overflow-y:auto}.aqmx-explorer-menu-item{align-items:center;gap:var(--aqmx-space-5);inline-size:100%;min-block-size:var(--aqmx-control);padding-inline:var(--aqmx-space-5);border-radius:var(--aqmx-radius-s);color:var(--aqmx-text);font:inherit;text-align:start;cursor:pointer;transition:background-color var(--aqmx-duration-1) var(--aqmx-ease);background:0 0;border:0;display:flex}.aqmx-explorer-menu-item:hover,.aqmx-explorer-menu-item:focus-visible{background:var(--aqmx-surface-sunken)}.aqmx-explorer-menu-icon{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon);color:var(--aqmx-text-muted);flex:none}.aqmx-explorer-menu-name{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-inline-size:0;overflow:hidden}.aqmx-explorer-menu-value{color:var(--aqmx-accent);font-variant-numeric:tabular-nums;flex:none;font-weight:600}.aqmx-explorer-notices{gap:var(--aqmx-space-5);flex:none;display:grid}.aqmx-explorer-tree-area{min-block-size:calc(var(--aqmx-control) * 3);flex-direction:column;flex:1 1 0;min-inline-size:0;display:flex;position:relative}.aqmx-explorer-tree{flex:1 1 0;min-block-size:0;position:relative}.aqmx-explorer-tree-view{block-size:100%}.aqmx-explorer-tree-progress{z-index:1;align-items:center;gap:var(--aqmx-space-2) var(--aqmx-space-4);max-inline-size:calc(100% - var(--aqmx-space-5) * 3);padding:var(--aqmx-space-3) var(--aqmx-space-5);border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-m);color:var(--aqmx-text-muted);background:var(--aqmx-surface-raised);box-shadow:var(--aqmx-shadow);line-height:var(--aqmx-line-height-compact);overflow-wrap:anywhere;pointer-events:none;animation:aqmx-appear var(--aqmx-duration-2) ease-out var(--aqmx-delay-progress) both;flex-wrap:wrap;margin:0;display:flex;position:absolute;inset-block-end:var(--aqmx-space-9);inset-inline-start:var(--aqmx-space-5)}.aqmx-explorer-tree-progress-icon{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon);animation:aqmx-explorer-spin calc(var(--aqmx-duration-4) * 3) linear infinite;flex:none}@keyframes aqmx-appear{0%{opacity:0}}.aqmx-explorer-tree-probe{inline-size:0;block-size:var(--aqmx-control);visibility:hidden;pointer-events:none;color:var(--aqmx-tree-line);forced-color-adjust:none;position:absolute;inset-block-start:0;inset-inline-start:0;overflow:hidden}.aqmx-explorer-loading{gap:var(--aqmx-space-5);padding:var(--aqmx-space-6) var(--aqmx-space-5);color:var(--aqmx-text-muted);display:grid}.aqmx-explorer-loading-text{margin:0}.aqmx-explorer-loading>.aqmx-skeleton{padding:0}.aqmx-explorer-tree-message{padding:var(--aqmx-space-5);overflow-y:auto}.aqmx-explorer-empty-icon{inline-size:var(--aqmx-space-8);block-size:var(--aqmx-space-8);color:var(--aqmx-border-strong)}.aqmx-explorer-empty-body{margin:0}.aqmx-explorer-tree [role=treeitem]{border-radius:var(--aqmx-radius-s);color:var(--aqmx-text);transition:background-color var(--aqmx-duration-1) var(--aqmx-ease)}.aqmx-explorer-tree [role=treeitem]:hover{color:var(--aqmx-text);background:var(--aqmx-tree-row-tint)}.aqmx-explorer-tree [role=treeitem][data-entry-item-selected=true]{color:var(--aqmx-text);background:var(--aqmx-tree-row-tint);box-shadow:inset var(--aqmx-space-2) 0 0 currentColor}.aqmx-explorer-tree [role=treeitem][data-entry-selected=true],.aqmx-explorer-tree [role=treeitem][data-aqmx-open=true]{color:var(--aqmx-accent);background:var(--aqmx-tree-row-accent-tint)}.aqmx-explorer-tree [role=treeitem]:focus-visible{outline-offset:calc(-1 * var(--aqmx-focus-ring-width))}.aqmx-explorer-tree [role=treeitem][data-entry-item-selected=true]:focus-visible{box-shadow:inset calc(var(--aqmx-space-2) + var(--aqmx-focus-ring-width)) 0 0 currentColor}.aqmx-explorer-tree [role=treeitem][data-aqmx-open=true]{font-weight:600}.aqmx-explorer-tree [role=treeitem][data-aqmx-children=loading]{animation:aqmx-pulse calc(var(--aqmx-duration-4) * 4) ease-in-out infinite}.aqmx-explorer-tree [role=treeitem][data-aqmx-loop]{color:var(--aqmx-text-muted);font-style:italic}.aqmx-explorer-folder-failed{--aqmx-folder-name-floor:3em;align-items:center;min-inline-size:0;max-inline-size:100%;display:flex}.aqmx-explorer-folder-name{flex:10000 1 var(--aqmx-folder-name-floor);text-overflow:ellipsis;white-space:nowrap;min-inline-size:0;max-inline-size:max-content;overflow:hidden}.aqmx-explorer-folder-error{min-inline-size:0;color:var(--aqmx-danger-text);text-indent:var(--aqmx-space-4);text-overflow:ellipsis;white-space:nowrap;flex:1 1 0;overflow:hidden}.aqmx-explorer-folder-retry{flex:1000000 0 calc(var(--aqmx-icon) + (var(--aqmx-space-3) + var(--aqmx-space-1)) * 2);min-inline-size:calc(var(--aqmx-icon) + (var(--aqmx-space-3) + var(--aqmx-space-1)) * 2);max-inline-size:max-content;min-block-size:var(--aqmx-control);padding:0 var(--aqmx-space-3);border:var(--aqmx-space-1) solid var(--aqmx-danger-border);border-radius:var(--aqmx-radius-s);color:var(--aqmx-danger-text);background:var(--aqmx-danger-surface);font:inherit;line-height:var(--aqmx-line-height-compact);cursor:pointer;justify-content:center;align-items:center;margin-inline-start:var(--aqmx-space-4);display:inline-flex;overflow:hidden}.aqmx-explorer-folder-retry:focus-visible{outline-offset:calc(-1 * (var(--aqmx-focus-ring-width) + var(--aqmx-space-1)))}.aqmx-explorer-folder-retry-icon{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon);flex:none}.aqmx-explorer-folder-retry-text{min-inline-size:0;text-indent:var(--aqmx-space-3);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.aqmx-explorer-tray{gap:var(--aqmx-space-4);min-block-size:calc(var(--aqmx-control) + (var(--aqmx-space-5) + var(--aqmx-space-1)) * 2);padding:var(--aqmx-space-5);border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-m);background:var(--aqmx-surface-raised);box-shadow:var(--aqmx-shadow);flex-direction:column;flex:0 auto;display:flex;overflow-y:auto}.aqmx-explorer-tray-header{justify-content:space-between;align-items:center;gap:var(--aqmx-space-5);flex:none;display:flex}.aqmx-explorer-tray-title{margin:0;font-weight:600}.aqmx-explorer-tray-button{min-block-size:var(--aqmx-control);padding-inline:var(--aqmx-space-5);border-radius:var(--aqmx-radius-m);color:var(--aqmx-accent);font:inherit;cursor:pointer;background:0 0;border:0;flex:none;font-weight:600}.aqmx-explorer-tray-button:hover{background:var(--aqmx-surface-sunken)}.aqmx-explorer-tray-list{gap:var(--aqmx-space-1);min-block-size:var(--aqmx-control);max-block-size:calc(var(--aqmx-control) * 3);flex:0 auto;margin:0;padding:0;list-style:none;display:grid;overflow-y:auto}.aqmx-explorer-tray-item{align-items:center;gap:var(--aqmx-space-4);display:flex}.aqmx-explorer-tray-name{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-inline-size:0;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow:hidden}.aqmx-explorer-tray-open{min-block-size:var(--aqmx-control);padding-inline:var(--aqmx-space-6);border-radius:var(--aqmx-radius-m);color:var(--aqmx-surface);background:var(--aqmx-accent);font:inherit;cursor:pointer;border:0;flex:none;font-weight:600}@media (forced-colors:active){.aqmx-explorer-tree [role=treeitem][data-entry-item-selected=true],.aqmx-explorer-tree [role=treeitem][data-entry-selected=true],.aqmx-explorer-tree [role=treeitem][data-aqmx-open=true],.aqmx-explorer-menu-item[aria-checked=true]{forced-color-adjust:none;color:highlighttext;background:highlight}.aqmx-explorer-menu-item[aria-checked=true] *,.aqmx-explorer-tree [role=treeitem][data-entry-item-selected=true] *,.aqmx-explorer-tree [role=treeitem][data-entry-selected=true] *,.aqmx-explorer-tree [role=treeitem][data-aqmx-open=true] *{color:inherit!important}.aqmx-explorer-tree [role=treeitem][data-entry-item-selected=true]:focus-visible,.aqmx-explorer-tree [role=treeitem][data-entry-selected=true]:focus-visible,.aqmx-explorer-tree [role=treeitem][data-aqmx-open=true]:focus-visible{outline-color:highlighttext}.aqmx-explorer-tray-button,.aqmx-explorer-tray-open,.aqmx-explorer-tray-remove{border:var(--aqmx-space-1) solid ButtonText}}@media (prefers-reduced-motion:reduce){.aqmx-explorer-actions>.aqmx-labelled-button[data-aqmx-busy=true]>svg,.aqmx-explorer-tree-progress-icon,.aqmx-explorer-tree [role=treeitem][data-aqmx-children=loading]{animation:none}.aqmx-explorer-tree-view{transition-duration:0s!important}}.aqmx-document{contain:layout paint;--aqmd-toolbar-inset-block-start:calc(var(--aqmx-focus-ring-width) + var(--aqmx-focus-ring-offset));block-size:100%;min-block-size:0;inline-size:100%;min-inline-size:0;color:var(--aqmx-text);background:var(--aqmx-surface);flex-direction:column;display:flex;position:relative;overflow:hidden}.aqmx-document [data-theme]{background-color:#0000!important}.aqmx-document .markdown-body :is(sup,sub) a{outline-offset:var(--aqmx-focus-ring-offset)!important}.aqmx-document *{scroll-margin:calc(var(--aqmx-focus-ring-width) + var(--aqmx-focus-ring-offset))}.aqmx-document[aria-busy=true]>:not(.aqmx-progress){opacity:.618;transition:opacity var(--aqmx-duration-3) var(--aqmx-ease)}.aqmx-document-viewer{flex:1 1 0;min-block-size:0;min-inline-size:0}.aqmx-document-notice{margin:var(--aqmx-space-6) var(--aqmx-space-7) 0;overflow-wrap:anywhere;flex:none}.aqmx-document-failure{min-block-size:0;padding:var(--aqmx-space-7);flex:1 1 0;overflow:auto}.aqmx-document-file{flex-direction:column;flex:1 1 0;min-block-size:0;min-inline-size:0;display:flex}.aqmx-document-toolbar{align-items:center;gap:var(--aqmx-space-3);padding:var(--aqmx-space-3) var(--aqmx-space-6);border-block-end:var(--aqmx-space-1) solid var(--aqmx-border);background:var(--aqmx-surface-raised);flex-wrap:wrap;flex:none;display:flex}.aqmx-document-file-icon{color:var(--aqmx-text-muted);flex:none;display:inline-flex}.aqmx-document-file-icon>svg{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon)}.aqmx-document-title{text-overflow:ellipsis;white-space:nowrap;flex:1 1 0;min-inline-size:0;font-weight:600;overflow:hidden}.aqmx-document-level{min-inline-size:var(--aqmx-space-9);color:var(--aqmx-text-muted);font-variant-numeric:tabular-nums;text-align:center;flex:none}.aqmx-document-canvas{min-block-size:0;padding:var(--aqmx-space-7);background-color:var(--aqmx-surface-sunken);background-image:radial-gradient(var(--aqmx-border) var(--aqmx-space-1), transparent var(--aqmx-space-1));background-size:var(--aqmx-space-6) var(--aqmx-space-6);flex:1 1 0;grid-template:minmax(0,1fr)/minmax(0,1fr);display:grid;overflow:auto}.aqmx-document-image{margin:auto;display:block}.aqmx-document-image[data-aqmx-image-mode=fit]{object-fit:contain;max-block-size:100%;max-inline-size:100%}.aqmx-document-image[data-aqmx-image-mode=level]{max-block-size:none;max-inline-size:none}.aqmx-document-stage{min-block-size:0;padding:var(--aqmx-space-7);background:var(--aqmx-surface-sunken);flex:1 1 0;grid-template:minmax(0,1fr)/minmax(0,1fr);place-items:center;display:grid;overflow:auto}.aqmx-document-file[data-aqmx-media-type=pdf]>.aqmx-document-stage{place-items:stretch stretch;padding:0}.aqmx-document-video{border-radius:var(--aqmx-radius-l);background:var(--aqmx-surface-raised);max-block-size:100%;max-inline-size:100%;box-shadow:var(--aqmx-shadow)}.aqmx-document-audio{inline-size:min(100%, var(--aqmx-column-measure))}.aqmx-document-frame{background:var(--aqmx-surface);border:0;block-size:100%;inline-size:100%}.aqmx-document-inert-link{color:var(--aqmx-text-muted);cursor:not-allowed;text-decoration-style:dotted}.aqmx-document[data-aqmx-document-flow=content]{contain:layout;block-size:auto;overflow:visible}.aqmx-document[data-aqmx-document-flow=content]>*,.aqmx-document[data-aqmx-document-flow=content] .aqmx-document-file>*{flex:none}.aqmx-document[data-aqmx-document-flow=content] .aqmx-document-frame{aspect-ratio:1/1.41421;block-size:auto}.aqmx-multi-stage{--aqmx-multi-panel-body-floor:calc(3rem * var(--aqmx-line-height-prose));--aqdd-stage-padding-block:var(--aqmx-space-7);--aqdd-stage-padding-inline:var(--aqmx-space-6);--aqdd-column-gap:var(--aqmx-space-6);--aqdd-panel-surface:var(--aqmx-surface);--aqdd-panel-border:var(--aqmx-border);--aqdd-panel-title-color:var(--aqmx-text);--aqdd-header-button-color:var(--aqmx-text-muted);--aqdd-header-button-hover-color:var(--aqmx-text);--aqdd-header-button-hover-surface:var(--aqmx-surface-sunken);--aqdd-custom-badge-color:var(--aqmx-warning-text);--aqdd-custom-badge-surface:var(--aqmx-warning-surface);--aqdd-restore-button-color:var(--aqmx-surface);--aqdd-restore-button-surface:var(--aqmx-accent);--aqdd-restore-button-hover-surface:var(--aqmx-info-text);--aqdd-drop-placeholder-color:var(--aqmx-accent);--aqdd-drop-placeholder-surface:var(--aqmx-surface);--aqdd-drop-placeholder-target-surface:var(--aqmx-accent-surface);background:var(--aqmx-surface-sunken);block-size:100%;min-block-size:0;min-inline-size:0;color:var(--aqmx-text);flex-direction:column;display:flex;position:relative}.aqmx-multi-stage:focus-visible{outline:var(--aqmx-focus-ring-width) solid var(--aqmx-focus);outline-offset:calc(-1 * var(--aqmx-focus-ring-width))}.aqmx-multi-probe{inline-size:var(--aqmx-column-measure);visibility:hidden;pointer-events:none;block-size:0;font-size:1rem;position:absolute;inset-block-start:0;inset-inline-start:0;overflow:hidden}.aqmx-multi-layout{flex:auto;min-block-size:0}.aqmx-multi-skeleton{grid-template-columns:repeat(auto-fit, minmax(min(100%, var(--aqmx-column-measure)), 1fr));align-content:start;gap:var(--aqmx-space-7);padding:var(--aqmx-space-7);display:grid;overflow:hidden}.aqmx-multi-skeleton-column{border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-l);background:var(--aqmx-surface)}.aqmx-multi-column{min-inline-size:0}.aqmx-multi-panel{outline:var(--aqmx-space-1) solid var(--aqmx-border-strong);outline-offset:0;color:var(--aqmx-text)}.aqmx-multi-panel[data-maximized]{outline-color:var(--aqmx-focus)}.aqmx-multi-panel-frame{content-visibility:auto;contain-intrinsic-block-size:auto var(--aqmx-space-9);min-block-size:100%}.aqmx-multi-panel-frame:focus-visible{outline:var(--aqmx-focus-ring-width) solid var(--aqmx-focus);outline-offset:calc(-1 * var(--aqmx-focus-ring-width))}.aqmx-multi-panel-frame[data-aqmx-maximized=false]{-webkit-user-select:none;user-select:none}.aqmx-multi-panel-frame .aqmx-document-toolbar>.aqmx-icon-button{flex-shrink:1;min-inline-size:0}.aqmx-multi-toast{animation:aqmx-multi-toast-in var(--aqmx-duration-3) var(--aqmx-ease)}.aqmx-multi-toast:popover-open{max-inline-size:min(34rem, calc(var(--aqmx-multi-toast-room) - var(--aqmx-space-8)));margin:0;position:fixed;inset:auto;inset-block-start:calc(var(--aqmx-multi-toast-block-start) + var(--aqmx-space-6));inset-inline-end:calc(var(--aqmx-multi-toast-inline-end) + var(--aqmx-space-7));overflow:visible}@keyframes aqmx-multi-toast-in{0%{opacity:0;translate:0 calc(var(--aqmx-space-5) * -1)}}@media (prefers-reduced-motion:reduce){.aqmx-multi-toast{animation:none}}@media (forced-colors:active){.aqmx-multi-stage:focus-visible,.aqmx-multi-stage :focus-visible,.aqmx-multi-panel[data-maximized]{outline-color:highlight}}.aqmx-split-frame{--aqmx-sheet-target:2.75rem;flex-direction:column;flex:auto;min-block-size:0;min-inline-size:0;display:flex;position:relative}.aqmx-rem-probe{visibility:hidden;pointer-events:none;block-size:0;inline-size:1rem;position:absolute;inset-block-start:0;inset-inline-start:0}.aqmx-split{flex:auto;min-block-size:0}.aqmx-split-explorer,.aqmx-split-content{background:var(--aqmx-surface);min-block-size:0}.aqmx-split-explorer{background:var(--aqmx-surface-raised)}.aqmx-split-handle{background:var(--aqmx-surface-raised);transition:background-color var(--aqmx-duration-2) var(--aqmx-ease)}.aqmx-split-handle:hover,.aqmx-split-handle:focus-visible{background:var(--aqmx-surface-sunken)}.aqmx-sheet-bar{padding:var(--aqmx-space-3) var(--aqmx-space-5);border-block-end:var(--aqmx-space-1) solid var(--aqmx-border);background:var(--aqmx-surface-raised);flex:none;align-items:center;display:flex}.aqmx-sheet-toggle,.aqmx-sheet-close{justify-content:center;align-items:center;gap:var(--aqmx-space-5);min-inline-size:var(--aqmx-sheet-target);min-block-size:var(--aqmx-sheet-target);padding:0 var(--aqmx-space-6);border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-m);color:var(--aqmx-text);background:var(--aqmx-surface);font:inherit;cursor:pointer;transition:background-color var(--aqmx-duration-2) var(--aqmx-ease);display:inline-flex}.aqmx-sheet-close{z-index:1;color:var(--aqmx-text-muted);background:var(--aqmx-surface-raised);border-color:#0000;padding:0;position:relative}.aqmx-sheet-toggle:hover,.aqmx-sheet-close:hover{background:var(--aqmx-surface-sunken)}.aqmx-sheet-toggle>svg,.aqmx-sheet-close>svg{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon);flex:none}.aqmx-sheet{inline-size:min(calc(100vw - var(--aqmx-space-9)), 21rem);border:0;border-inline-end:var(--aqmx-space-1) solid var(--aqmx-border);block-size:100dvh;max-block-size:none;max-inline-size:none;color:var(--aqmx-text);background:var(--aqmx-surface-raised);box-shadow:var(--aqmx-shadow);margin:0;padding:0;position:fixed;inset-block:0;inset-inline:0 auto}.aqmx-sheet::backdrop{background:#0f172a61}.aqmx-sheet-panel{flex-direction:column;block-size:100%;display:flex}.aqmx-sheet-header{z-index:1;justify-content:flex-end;align-items:center;gap:var(--aqmx-space-3);padding:var(--aqmx-space-3);border-block-end:var(--aqmx-space-1) solid var(--aqmx-border);flex:none;display:flex;position:relative}.aqmx-sheet-notice-slot>.aqmx-toast{--aqmx-sheet-notice-band:calc(var(--aqmx-sheet-target) + var(--aqmx-space-3) * 2);--aqmx-sheet-notice-line:calc(var(--aqmx-line-height-compact) * 1em);--aqmx-sheet-notice-inset:calc((var(--aqmx-sheet-notice-band) - var(--aqmx-sheet-notice-line)) / 2);z-index:0;max-inline-size:none;padding-block:var(--aqmx-sheet-notice-inset) 0;padding-inline:var(--aqmx-space-6) var(--aqmx-space-3);border:0;border-block-end:var(--aqmx-space-1) solid var(--aqmx-warning-border);line-height:var(--aqmx-line-height-compact);overflow-wrap:anywhere;box-shadow:none;border-radius:0;position:absolute;inset-block:0 auto;inset-inline:0}.aqmx-sheet-notice-slot>.aqmx-toast:before{content:"";float:inline-end;inline-size:calc(var(--aqmx-sheet-target) + var(--aqmx-space-3));block-size:calc(var(--aqmx-sheet-notice-band) - var(--aqmx-sheet-notice-inset) - var(--aqmx-space-1))}.aqmx-sheet-notice-slot>.aqmx-toast:after{content:"";block-size:calc(var(--aqmx-sheet-notice-inset) - var(--aqmx-space-1));display:block}.aqmx-sheet-body{isolation:isolate;flex-direction:column;flex:auto;min-block-size:0;display:flex;position:relative;overflow:hidden}.aqmx-single{flex-direction:column;flex:auto;min-block-size:0;display:flex;position:relative}.aqmx-single-toolbar{padding:var(--aqmx-space-2) var(--aqmx-space-3);flex:none;justify-content:flex-end;align-items:center;display:flex}.aqmx-single>.aqmx-document{flex:1 1 0;block-size:auto;min-block-size:0}.aqmx-single-refresh-failure{margin:0 var(--aqmx-space-3) var(--aqmx-space-2);padding:var(--aqmx-space-4) var(--aqmx-space-5);border:var(--aqmx-space-1) solid var(--aqmx-danger-border);border-radius:var(--aqmx-radius-m);color:var(--aqmx-danger-text);background:var(--aqmx-danger-surface);line-height:var(--aqmx-line-height-compact);overflow-wrap:anywhere;flex:none}.aqmx-single-toolbar>.aqmx-icon-button[data-aqmx-busy=true]>svg{animation:aqmx-explorer-spin calc(var(--aqmx-duration-4) * 3) linear infinite}.aqmx-single-toolbar>.aqmx-icon-button[aria-busy=true]{cursor:progress}.aqmx-split-fallback,.aqmx-stage-fallback{background:var(--aqmx-surface-sunken);flex:auto;min-block-size:0}@media (forced-colors:active){.aqmx-sheet-toggle[aria-expanded=true]{forced-color-adjust:none;color:highlighttext;background:highlight}.aqmx-sheet-toggle:focus-visible,.aqmx-sheet-close:focus-visible{outline-color:highlight}.aqmx-split-handle:focus-visible{outline:var(--aqmx-focus-ring-width) solid Highlight!important;outline-offset:calc(-1 * var(--aqmx-focus-ring-width))!important}}@media (prefers-reduced-motion:reduce){.aqmx-split-handle,.aqmx-split-handle *{transition-duration:0s!important}.aqmx-single-toolbar>.aqmx-icon-button[data-aqmx-busy=true]>svg{animation:none}}}@layer utilities;
3
+ @layer theme,base;@layer components{.aqmx-root{--aqmx-space-1:.0625rem;--aqmx-space-2:.125rem;--aqmx-space-3:.1875rem;--aqmx-space-4:.3125rem;--aqmx-space-5:.5rem;--aqmx-space-6:.8125rem;--aqmx-space-7:1.3125rem;--aqmx-space-8:2.125rem;--aqmx-space-9:3.4375rem;--aqmx-control:2.125rem;--aqmx-focus-ring-width:var(--aqmx-space-2);--aqmx-focus-ring-offset:var(--aqmx-space-2);--aqmx-icon:1rem;--aqmx-radius-s:.3125rem;--aqmx-radius-m:.5rem;--aqmx-radius-l:.8125rem;--aqmx-duration-1:89ms;--aqmx-duration-2:.144s;--aqmx-duration-3:.233s;--aqmx-duration-4:.377s;--aqmx-delay-progress:.233s;--aqmx-ease:cubic-bezier(.2, 0, 0, 1);--aqmx-font-size-body:.8125rem;--aqmx-font-size-title:1rem;--aqmx-font-size-display:1.3125rem;--aqmx-line-height-compact:1.382;--aqmx-line-height-prose:1.618;--aqmx-column-measure:40ch;--aqmx-surface:#fff;--aqmx-surface-raised:#f8fafc;--aqmx-surface-sunken:#f1f5f9;--aqmx-border:#cbd5e1;--aqmx-border-strong:#94a3b8;--aqmx-text:#0f172a;--aqmx-text-muted:#475569;--aqmx-accent:#1d4ed8;--aqmx-accent-surface:#dbeafe;--aqmx-tree-line:#64748b;--aqmx-tree-row-tint:#0f172a0f;--aqmx-tree-row-accent-tint:#2563eb29;--aqmx-focus:#2563eb;--aqmx-info-surface:#eff6ff;--aqmx-info-border:#93c5fd;--aqmx-info-text:#1e3a8a;--aqmx-warning-surface:#fffbeb;--aqmx-warning-border:#fcd34d;--aqmx-warning-text:#78350f;--aqmx-danger-surface:#fef2f2;--aqmx-danger-border:#fca5a5;--aqmx-danger-text:#7f1d1d;--aqmx-shadow:0 .0625rem .1875rem #0f172a21, 0 .3125rem .8125rem #0f172a14}.aqmx-root[data-aqmx-theme=dark]{--aqmx-surface:#0f172a;--aqmx-surface-raised:#1e293b;--aqmx-surface-sunken:#020617;--aqmx-border:#334155;--aqmx-border-strong:#64748b;--aqmx-text:#e2e8f0;--aqmx-text-muted:#94a3b8;--aqmx-accent:#93c5fd;--aqmx-accent-surface:#1e3a8a;--aqmx-tree-line:#94a3b8;--aqmx-tree-row-tint:#e2e8f00f;--aqmx-tree-row-accent-tint:#2563eb70;--aqmx-focus:#60a5fa;--aqmx-info-surface:#172554;--aqmx-info-border:#1d4ed8;--aqmx-info-text:#bfdbfe;--aqmx-warning-surface:#422006;--aqmx-warning-border:#a16207;--aqmx-warning-text:#fde68a;--aqmx-danger-surface:#450a0a;--aqmx-danger-border:#b91c1c;--aqmx-danger-text:#fecaca;--aqmx-shadow:0 .0625rem .1875rem #0000008c, 0 .3125rem .8125rem #00000057}@media (pointer:coarse){.aqmx-root{--aqmx-control:2.75rem}}@media (forced-colors:active){.aqmx-root.aqmx-root[data-aqmx-theme]{--aqmx-tree-line:CanvasText}}@media (prefers-reduced-motion:reduce){.aqmx-root{--aqmx-duration-1:0s;--aqmx-duration-2:0s;--aqmx-duration-3:0s;--aqmx-duration-4:0s}}.aqmx-root{block-size:100%;min-block-size:0;inline-size:100%;min-inline-size:0;color:var(--aqmx-text);background:var(--aqmx-surface);font-size:var(--aqmx-font-size-body);line-height:var(--aqmx-line-height-compact);flex-direction:column;display:flex;position:relative}.aqmx-root *,.aqmx-root :before,.aqmx-root :after{box-sizing:border-box}.aqmx-icon-button{inline-size:var(--aqmx-control);block-size:var(--aqmx-control);border-radius:var(--aqmx-radius-m);color:var(--aqmx-text-muted);cursor:pointer;transition:background-color var(--aqmx-duration-2) var(--aqmx-ease), color var(--aqmx-duration-2) var(--aqmx-ease);background:0 0;border:0;flex:none;justify-content:center;align-items:center;padding:0;display:inline-flex}.aqmx-icon-button:hover{color:var(--aqmx-text);background:var(--aqmx-surface-sunken)}.aqmx-icon-button[aria-pressed=true],.aqmx-icon-button[aria-expanded=true]{color:var(--aqmx-accent);background:var(--aqmx-accent-surface)}.aqmx-icon-button:disabled{opacity:.382;cursor:not-allowed}.aqmx-icon-button[aria-disabled=true]{cursor:not-allowed}.aqmx-icon-button[aria-disabled=true]:hover{color:var(--aqmx-text-muted);background:0 0}.aqmx-icon-button>svg{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon)}.aqmx-icon-button[aria-disabled=true]>svg{opacity:.382}.aqmx-root :focus-visible{outline:var(--aqmx-focus-ring-width) solid var(--aqmx-focus);outline-offset:var(--aqmx-focus-ring-offset)}.aqmx-callout{gap:var(--aqmx-space-5);padding:var(--aqmx-space-6);border:var(--aqmx-space-1) solid var(--aqmx-info-border);border-radius:var(--aqmx-radius-l);color:var(--aqmx-info-text);background:var(--aqmx-info-surface);line-height:var(--aqmx-line-height-prose);display:grid}.aqmx-callout[data-aqmx-tone=warning]{border-color:var(--aqmx-warning-border);color:var(--aqmx-warning-text);background:var(--aqmx-warning-surface)}.aqmx-callout[data-aqmx-tone=danger]{border-color:var(--aqmx-danger-border);color:var(--aqmx-danger-text);background:var(--aqmx-danger-surface)}.aqmx-callout-title{font-size:var(--aqmx-font-size-title);font-weight:600;line-height:var(--aqmx-line-height-compact);margin:0}.aqmx-callout-body{margin:0}.aqmx-callout-action{min-block-size:var(--aqmx-control);padding-inline:var(--aqmx-space-6);border:var(--aqmx-space-1) solid currentColor;border-radius:var(--aqmx-radius-m);color:inherit;font:inherit;cursor:pointer;background:0 0;justify-self:start;align-items:center;font-weight:600;text-decoration:none;display:inline-flex}.aqmx-progress{z-index:2;block-size:var(--aqmx-space-3);pointer-events:none;position:absolute;inset-block-start:0;inset-inline:0;overflow:hidden}.aqmx-progress:before{content:"";background:var(--aqmx-accent);inline-size:38.1966%;animation:aqmx-progress calc(var(--aqmx-duration-4) * 3) var(--aqmx-ease) infinite;position:absolute;inset-block:0}@keyframes aqmx-progress{0%{inset-inline-start:-38.1966%}to{inset-inline-start:100%}}.aqmx-empty{place-content:center;justify-items:center;gap:var(--aqmx-space-6);block-size:100%;padding:var(--aqmx-space-8);color:var(--aqmx-text-muted);text-align:center;line-height:var(--aqmx-line-height-prose);display:grid}.aqmx-empty-title{color:var(--aqmx-text);font-size:var(--aqmx-font-size-title);margin:0;font-weight:600}.aqmx-skeleton{gap:var(--aqmx-space-6);padding:var(--aqmx-space-7);display:grid}.aqmx-skeleton>span{block-size:var(--aqmx-space-6);border-radius:var(--aqmx-radius-s);background:var(--aqmx-surface-sunken);animation:aqmx-pulse calc(var(--aqmx-duration-4) * 4) ease-in-out infinite;display:block}.aqmx-skeleton>span:nth-child(3n+1){inline-size:61.8034%}.aqmx-skeleton>span:nth-child(3n+2){inline-size:100%}.aqmx-skeleton>span:nth-child(3n){inline-size:85.4102%}@keyframes aqmx-pulse{50%{opacity:.618}}.aqmx-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;block-size:1px;inline-size:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.aqmx-toast{z-index:60;max-inline-size:min(34rem, calc(100% - var(--aqmx-space-8)));padding:var(--aqmx-space-5) var(--aqmx-space-6);border:var(--aqmx-space-1) solid var(--aqmx-warning-border);border-radius:var(--aqmx-radius-m);color:var(--aqmx-warning-text);background:var(--aqmx-warning-surface);box-shadow:var(--aqmx-shadow);position:absolute;inset-block-start:var(--aqmx-space-6);inset-inline-end:var(--aqmx-space-7)}@media (prefers-reduced-motion:reduce){.aqmx-progress:before,.aqmx-skeleton>span{animation:none}}@media (forced-colors:active){.aqmx-icon-button[aria-pressed=true],.aqmx-icon-button[aria-expanded=true]{forced-color-adjust:none;color:highlighttext;background:highlight}.aqmx-icon-button[aria-disabled=true]{color:graytext}.aqmx-root :focus-visible{outline-color:highlight}.aqmx-progress:before{forced-color-adjust:none;background:highlight}.aqmx-skeleton>span{forced-color-adjust:none;background:graytext}}.aqmx-explorer{gap:var(--aqmx-space-5);block-size:100%;min-block-size:0;min-inline-size:0;padding:var(--aqmx-space-4);color:var(--aqmx-text);background:var(--aqmx-surface);flex-direction:column;display:flex;position:relative;overflow-y:auto}.aqmx-explorer-header{align-items:center;gap:var(--aqmx-space-4);min-block-size:var(--aqmx-control);flex-wrap:wrap;flex:none;display:flex}.aqmx-explorer-source{min-inline-size:min(100%,9rem);block-size:var(--aqmx-control);padding-inline:var(--aqmx-space-5);border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-m);color:var(--aqmx-text);background:var(--aqmx-surface-raised);font:inherit;text-overflow:ellipsis;cursor:pointer;flex:9rem}.aqmx-explorer-actions{justify-content:flex-end;align-items:center;gap:var(--aqmx-space-2);flex-wrap:wrap;flex:0 auto;min-inline-size:0;margin-inline-start:auto;display:flex}.aqmx-explorer-body{gap:var(--aqmx-space-5);flex-direction:column;flex:1 1 0;min-block-size:0;min-inline-size:0;display:flex;position:relative}.aqmx-labelled-button{gap:var(--aqmx-space-2);min-inline-size:var(--aqmx-control);inline-size:auto;padding-inline:var(--aqmx-space-3);white-space:nowrap;flex:0 auto;display:inline-flex}.aqmx-labelled-button>svg{flex:none}.aqmx-labelled-button>span{text-overflow:ellipsis;min-inline-size:0;overflow:hidden}.aqmx-explorer-refresh-failure,.aqmx-explorer-expand-all-stop{padding:var(--aqmx-space-4) var(--aqmx-space-5);border:var(--aqmx-space-1) solid;border-radius:var(--aqmx-radius-m);line-height:var(--aqmx-line-height-compact);overflow-wrap:anywhere;flex:none;margin:0}.aqmx-explorer-refresh-failure{border-color:var(--aqmx-danger-border);color:var(--aqmx-danger-text);background:var(--aqmx-danger-surface)}.aqmx-explorer-expand-all-stop{border-color:var(--aqmx-info-border);color:var(--aqmx-info-text);background:var(--aqmx-info-surface)}.aqmx-explorer-actions>.aqmx-labelled-button[data-aqmx-busy=true]>svg{animation:aqmx-explorer-spin calc(var(--aqmx-duration-4) * 3) linear infinite}@keyframes aqmx-explorer-spin{to{rotate:1turn}}.aqmx-explorer-actions>.aqmx-icon-button[aria-busy=true]{cursor:progress}.aqmx-explorer-menu{z-index:50;gap:var(--aqmx-space-1);max-block-size:100%;inline-size:min(21rem,100%);padding:var(--aqmx-space-3);border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-m);background:var(--aqmx-surface-raised);box-shadow:var(--aqmx-shadow);display:grid;position:absolute;inset-block-start:0;inset-inline-end:0;overflow-y:auto}.aqmx-explorer-menu-item{align-items:center;gap:var(--aqmx-space-5);inline-size:100%;min-block-size:var(--aqmx-control);padding-inline:var(--aqmx-space-5);border-radius:var(--aqmx-radius-s);color:var(--aqmx-text);font:inherit;text-align:start;cursor:pointer;transition:background-color var(--aqmx-duration-1) var(--aqmx-ease);background:0 0;border:0;display:flex}.aqmx-explorer-menu-item:hover,.aqmx-explorer-menu-item:focus-visible{background:var(--aqmx-surface-sunken)}.aqmx-explorer-menu-icon{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon);color:var(--aqmx-text-muted);flex:none}.aqmx-explorer-menu-name{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-inline-size:0;overflow:hidden}.aqmx-explorer-menu-value{color:var(--aqmx-accent);font-variant-numeric:tabular-nums;flex:none;font-weight:600}.aqmx-explorer-notices{gap:var(--aqmx-space-5);flex:none;display:grid}.aqmx-explorer-tree-area{min-block-size:calc(var(--aqmx-control) * 3);flex-direction:column;flex:1 1 0;min-inline-size:0;display:flex;position:relative}.aqmx-explorer-tree{flex:1 1 0;min-block-size:0;position:relative}.aqmx-explorer-tree-view{block-size:100%}.aqmx-explorer-tree-progress{z-index:1;align-items:center;gap:var(--aqmx-space-2) var(--aqmx-space-4);max-inline-size:calc(100% - var(--aqmx-space-5) * 3);padding:var(--aqmx-space-3) var(--aqmx-space-5);border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-m);color:var(--aqmx-text-muted);background:var(--aqmx-surface-raised);box-shadow:var(--aqmx-shadow);line-height:var(--aqmx-line-height-compact);overflow-wrap:anywhere;pointer-events:none;animation:aqmx-appear var(--aqmx-duration-2) ease-out var(--aqmx-delay-progress) both;flex-wrap:wrap;margin:0;display:flex;position:absolute;inset-block-end:var(--aqmx-space-9);inset-inline-start:var(--aqmx-space-5)}.aqmx-explorer-tree-progress-icon{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon);animation:aqmx-explorer-spin calc(var(--aqmx-duration-4) * 3) linear infinite;flex:none}@keyframes aqmx-appear{0%{opacity:0}}.aqmx-explorer-tree-probe{inline-size:0;block-size:var(--aqmx-control);visibility:hidden;pointer-events:none;color:var(--aqmx-tree-line);forced-color-adjust:none;position:absolute;inset-block-start:0;inset-inline-start:0;overflow:hidden}.aqmx-explorer-loading{gap:var(--aqmx-space-5);padding:var(--aqmx-space-6) var(--aqmx-space-5);color:var(--aqmx-text-muted);display:grid}.aqmx-explorer-loading-text{margin:0}.aqmx-explorer-loading>.aqmx-skeleton{padding:0}.aqmx-explorer-tree-message{padding:var(--aqmx-space-5);overflow-y:auto}.aqmx-explorer-empty-icon{inline-size:var(--aqmx-space-8);block-size:var(--aqmx-space-8);color:var(--aqmx-border-strong)}.aqmx-explorer-empty-body{margin:0}.aqmx-explorer-tree [role=treeitem]{border-radius:var(--aqmx-radius-s);color:var(--aqmx-text);transition:background-color var(--aqmx-duration-1) var(--aqmx-ease)}.aqmx-explorer-tree [role=treeitem]:hover{color:var(--aqmx-text);background:var(--aqmx-tree-row-tint)}.aqmx-explorer-tree [role=treeitem][data-entry-item-selected=true]{color:var(--aqmx-text);background:var(--aqmx-tree-row-tint);box-shadow:inset var(--aqmx-space-2) 0 0 currentColor}.aqmx-explorer-tree [role=treeitem][data-entry-selected=true],.aqmx-explorer-tree [role=treeitem][data-aqmx-open=true]{color:var(--aqmx-accent);background:var(--aqmx-tree-row-accent-tint)}.aqmx-explorer-tree [role=treeitem]:focus-visible{outline-offset:calc(-1 * var(--aqmx-focus-ring-width))}.aqmx-explorer-tree [role=treeitem][data-entry-item-selected=true]:focus-visible{box-shadow:inset calc(var(--aqmx-space-2) + var(--aqmx-focus-ring-width)) 0 0 currentColor}.aqmx-explorer-tree [role=treeitem][data-aqmx-open=true]{font-weight:600}.aqmx-explorer-tree [role=treeitem][data-aqmx-children=loading]{animation:aqmx-pulse calc(var(--aqmx-duration-4) * 4) ease-in-out infinite}.aqmx-explorer-tree [role=treeitem][data-aqmx-loop]{color:var(--aqmx-text-muted);font-style:italic}.aqmx-explorer-folder-failed{--aqmx-folder-name-floor:3em;align-items:center;min-inline-size:0;max-inline-size:100%;display:flex}.aqmx-explorer-folder-name{flex:10000 1 var(--aqmx-folder-name-floor);text-overflow:ellipsis;white-space:nowrap;min-inline-size:0;max-inline-size:max-content;overflow:hidden}.aqmx-explorer-folder-error{min-inline-size:0;color:var(--aqmx-danger-text);text-indent:var(--aqmx-space-4);text-overflow:ellipsis;white-space:nowrap;flex:1 1 0;overflow:hidden}.aqmx-explorer-folder-retry{flex:1000000 0 calc(var(--aqmx-icon) + (var(--aqmx-space-3) + var(--aqmx-space-1)) * 2);min-inline-size:calc(var(--aqmx-icon) + (var(--aqmx-space-3) + var(--aqmx-space-1)) * 2);max-inline-size:max-content;min-block-size:var(--aqmx-control);padding:0 var(--aqmx-space-3);border:var(--aqmx-space-1) solid var(--aqmx-danger-border);border-radius:var(--aqmx-radius-s);color:var(--aqmx-danger-text);background:var(--aqmx-danger-surface);font:inherit;line-height:var(--aqmx-line-height-compact);cursor:pointer;justify-content:center;align-items:center;margin-inline-start:var(--aqmx-space-4);display:inline-flex;overflow:hidden}.aqmx-explorer-folder-retry:focus-visible{outline-offset:calc(-1 * (var(--aqmx-focus-ring-width) + var(--aqmx-space-1)))}.aqmx-explorer-folder-retry-icon{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon);flex:none}.aqmx-explorer-folder-retry-text{min-inline-size:0;text-indent:var(--aqmx-space-3);text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.aqmx-explorer-tray{gap:var(--aqmx-space-4);min-block-size:calc(var(--aqmx-control) + (var(--aqmx-space-5) + var(--aqmx-space-1)) * 2);padding:var(--aqmx-space-5);border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-m);background:var(--aqmx-surface-raised);box-shadow:var(--aqmx-shadow);flex-direction:column;flex:0 auto;display:flex;overflow-y:auto}.aqmx-explorer-tray-header{justify-content:space-between;align-items:center;gap:var(--aqmx-space-5);flex:none;display:flex}.aqmx-explorer-tray-title{margin:0;font-weight:600}.aqmx-explorer-tray-button{min-block-size:var(--aqmx-control);padding-inline:var(--aqmx-space-5);border-radius:var(--aqmx-radius-m);color:var(--aqmx-accent);font:inherit;cursor:pointer;background:0 0;border:0;flex:none;font-weight:600}.aqmx-explorer-tray-button:hover{background:var(--aqmx-surface-sunken)}.aqmx-explorer-tray-list{gap:var(--aqmx-space-1);min-block-size:var(--aqmx-control);max-block-size:calc(var(--aqmx-control) * 3);flex:0 auto;margin:0;padding:0;list-style:none;display:grid;overflow-y:auto}.aqmx-explorer-tray-item{align-items:center;gap:var(--aqmx-space-4);display:flex}.aqmx-explorer-tray-name{text-overflow:ellipsis;white-space:nowrap;flex:auto;min-inline-size:0;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;overflow:hidden}.aqmx-explorer-tray-open{min-block-size:var(--aqmx-control);padding-inline:var(--aqmx-space-6);border-radius:var(--aqmx-radius-m);color:var(--aqmx-surface);background:var(--aqmx-accent);font:inherit;cursor:pointer;border:0;flex:none;font-weight:600}@media (forced-colors:active){.aqmx-explorer-tree [role=treeitem][data-entry-item-selected=true],.aqmx-explorer-tree [role=treeitem][data-entry-selected=true],.aqmx-explorer-tree [role=treeitem][data-aqmx-open=true],.aqmx-explorer-menu-item[aria-checked=true]{forced-color-adjust:none;color:highlighttext;background:highlight}.aqmx-explorer-menu-item[aria-checked=true] *,.aqmx-explorer-tree [role=treeitem][data-entry-item-selected=true] *,.aqmx-explorer-tree [role=treeitem][data-entry-selected=true] *,.aqmx-explorer-tree [role=treeitem][data-aqmx-open=true] *{color:inherit!important}.aqmx-explorer-tree [role=treeitem][data-entry-item-selected=true]:focus-visible,.aqmx-explorer-tree [role=treeitem][data-entry-selected=true]:focus-visible,.aqmx-explorer-tree [role=treeitem][data-aqmx-open=true]:focus-visible{outline-color:highlighttext}.aqmx-explorer-tray-button,.aqmx-explorer-tray-open,.aqmx-explorer-tray-remove{border:var(--aqmx-space-1) solid ButtonText}}@media (prefers-reduced-motion:reduce){.aqmx-explorer-actions>.aqmx-labelled-button[data-aqmx-busy=true]>svg,.aqmx-explorer-tree-progress-icon,.aqmx-explorer-tree [role=treeitem][data-aqmx-children=loading]{animation:none}.aqmx-explorer-tree-view{transition-duration:0s!important}}.aqmx-document{contain:layout paint;--aqmd-toolbar-inset-block-start:calc(var(--aqmx-focus-ring-width) + var(--aqmx-focus-ring-offset));block-size:100%;min-block-size:0;inline-size:100%;min-inline-size:0;color:var(--aqmx-text);background:var(--aqmx-surface);flex-direction:column;display:flex;position:relative;overflow:hidden}.aqmx-document [data-theme]{background-color:#0000!important}.aqmx-document .markdown-body :is(sup,sub) a{outline-offset:var(--aqmx-focus-ring-offset)!important}.aqmx-document *{scroll-margin:calc(var(--aqmx-focus-ring-width) + var(--aqmx-focus-ring-offset))}.aqmx-document[aria-busy=true]>:not(.aqmx-progress){opacity:.618;transition:opacity var(--aqmx-duration-3) var(--aqmx-ease)}.aqmx-document-viewer{flex:1 1 0;min-block-size:0;min-inline-size:0}.aqmx-document-notice{margin:var(--aqmx-space-6) var(--aqmx-space-7) 0;overflow-wrap:anywhere;flex:none}.aqmx-document-failure{min-block-size:0;padding:var(--aqmx-space-7);flex:1 1 0;overflow:auto}.aqmx-document-file{flex-direction:column;flex:1 1 0;min-block-size:0;min-inline-size:0;display:flex}.aqmx-document-toolbar{align-items:center;gap:var(--aqmx-space-3);padding:var(--aqmx-space-3) var(--aqmx-space-6);border-block-end:var(--aqmx-space-1) solid var(--aqmx-border);background:var(--aqmx-surface-raised);flex-wrap:wrap;flex:none;display:flex}.aqmx-document-file-icon{color:var(--aqmx-text-muted);flex:none;display:inline-flex}.aqmx-document-file-icon>svg{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon)}.aqmx-document-title{text-overflow:ellipsis;white-space:nowrap;flex:1 1 0;min-inline-size:0;font-weight:600;overflow:hidden}.aqmx-document-level{min-inline-size:var(--aqmx-space-9);color:var(--aqmx-text-muted);font-variant-numeric:tabular-nums;text-align:center;flex:none}.aqmx-document-canvas{min-block-size:0;padding:var(--aqmx-space-7);background-color:var(--aqmx-surface-sunken);background-image:radial-gradient(var(--aqmx-border) var(--aqmx-space-1), transparent var(--aqmx-space-1));background-size:var(--aqmx-space-6) var(--aqmx-space-6);flex:1 1 0;grid-template:minmax(0,1fr)/minmax(0,1fr);display:grid;overflow:auto}.aqmx-document-image{margin:auto;display:block}.aqmx-document-image[data-aqmx-image-mode=fit]{object-fit:contain;max-block-size:100%;max-inline-size:100%}.aqmx-document-image[data-aqmx-image-mode=level]{max-block-size:none;max-inline-size:none}.aqmx-document-stage{min-block-size:0;padding:var(--aqmx-space-7);background:var(--aqmx-surface-sunken);flex:1 1 0;grid-template:minmax(0,1fr)/minmax(0,1fr);place-items:center;display:grid;overflow:auto}.aqmx-document-file[data-aqmx-media-type=pdf]>.aqmx-document-stage{place-items:stretch stretch;padding:0}.aqmx-document-video{border-radius:var(--aqmx-radius-l);background:var(--aqmx-surface-raised);max-block-size:100%;max-inline-size:100%;box-shadow:var(--aqmx-shadow)}.aqmx-document-audio{inline-size:min(100%, var(--aqmx-column-measure))}.aqmx-document-frame{background:var(--aqmx-surface);border:0;block-size:100%;inline-size:100%}.aqmx-document-inert-link{color:var(--aqmx-text-muted);cursor:not-allowed;text-decoration-style:dotted}.aqmx-document[data-aqmx-document-flow=content]{contain:layout;block-size:auto;overflow:visible}.aqmx-document[data-aqmx-document-flow=content]>*,.aqmx-document[data-aqmx-document-flow=content] .aqmx-document-file>*{flex:none}.aqmx-document[data-aqmx-document-flow=content] .aqmx-document-frame{aspect-ratio:1/1.41421;block-size:auto}.aqmx-document-refresh-bar{flex-direction:column;flex:none;display:flex}.aqmx-document-refresh-row{padding:calc(var(--aqmx-focus-ring-width) + var(--aqmx-focus-ring-offset));justify-content:flex-end;align-items:center;display:flex}.aqmx-document-refresh-failure{margin:0 var(--aqmx-space-3) var(--aqmx-space-2);padding:var(--aqmx-space-4) var(--aqmx-space-5);border:var(--aqmx-space-1) solid var(--aqmx-danger-border);border-radius:var(--aqmx-radius-m);color:var(--aqmx-danger-text);background:var(--aqmx-danger-surface);line-height:var(--aqmx-line-height-compact);overflow-wrap:anywhere}.aqmx-document-refresh-row>.aqmx-icon-button[data-aqmx-busy=true]>svg{animation:aqmx-explorer-spin calc(var(--aqmx-duration-4) * 3) linear infinite}.aqmx-document-refresh-row>.aqmx-icon-button[aria-busy=true]{cursor:progress}@media (prefers-reduced-motion:reduce){.aqmx-document-refresh-row>.aqmx-icon-button[data-aqmx-busy=true]>svg{animation:none}}.aqmx-multi-stage{--aqmx-multi-panel-body-floor:calc(3rem * var(--aqmx-line-height-prose));--aqdd-stage-padding-block:var(--aqmx-space-7);--aqdd-stage-padding-inline:var(--aqmx-space-6);--aqdd-column-gap:var(--aqmx-space-6);--aqdd-panel-surface:var(--aqmx-surface);--aqdd-panel-border:var(--aqmx-border);--aqdd-panel-title-color:var(--aqmx-text);--aqdd-header-button-color:var(--aqmx-text-muted);--aqdd-header-button-hover-color:var(--aqmx-text);--aqdd-header-button-hover-surface:var(--aqmx-surface-sunken);--aqdd-custom-badge-color:var(--aqmx-warning-text);--aqdd-custom-badge-surface:var(--aqmx-warning-surface);--aqdd-restore-button-color:var(--aqmx-surface);--aqdd-restore-button-surface:var(--aqmx-accent);--aqdd-restore-button-hover-surface:var(--aqmx-info-text);--aqdd-drop-placeholder-color:var(--aqmx-accent);--aqdd-drop-placeholder-surface:var(--aqmx-surface);--aqdd-drop-placeholder-target-surface:var(--aqmx-accent-surface);background:var(--aqmx-surface-sunken);block-size:100%;min-block-size:0;min-inline-size:0;color:var(--aqmx-text);flex-direction:column;display:flex;position:relative}.aqmx-multi-stage:focus-visible{outline:var(--aqmx-focus-ring-width) solid var(--aqmx-focus);outline-offset:calc(-1 * var(--aqmx-focus-ring-width))}.aqmx-multi-probe{inline-size:var(--aqmx-column-measure);visibility:hidden;pointer-events:none;block-size:0;font-size:1rem;position:absolute;inset-block-start:0;inset-inline-start:0;overflow:hidden}.aqmx-multi-layout{flex:auto;min-block-size:0}.aqmx-multi-skeleton{grid-template-columns:repeat(auto-fit, minmax(min(100%, var(--aqmx-column-measure)), 1fr));align-content:start;gap:var(--aqmx-space-7);padding:var(--aqmx-space-7);display:grid;overflow:hidden}.aqmx-multi-skeleton-column{border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-l);background:var(--aqmx-surface)}.aqmx-multi-column{min-inline-size:0}.aqmx-multi-panel{outline:var(--aqmx-space-1) solid var(--aqmx-border-strong);outline-offset:0;color:var(--aqmx-text)}.aqmx-multi-panel[data-maximized]{outline-color:var(--aqmx-focus)}.aqmx-multi-panel-frame{content-visibility:auto;contain-intrinsic-block-size:auto var(--aqmx-space-9);min-block-size:100%}.aqmx-multi-panel-frame:focus-visible{outline:var(--aqmx-focus-ring-width) solid var(--aqmx-focus);outline-offset:calc(-1 * var(--aqmx-focus-ring-width))}.aqmx-multi-panel-frame[data-aqmx-maximized=false]{-webkit-user-select:none;user-select:none}.aqmx-multi-panel-frame>.aqmx-document-refresh-bar{z-index:1;background:var(--aqmx-surface);position:sticky;inset-block-start:0}.aqmx-multi-panel-frame{--aqmx-multi-panel-pinned-block-size:0px}.aqmx-multi-panel-frame .aqmx-document *{scroll-margin-block-start:calc(var(--aqmx-multi-panel-pinned-block-size) + var(--aqmx-focus-ring-width) + var(--aqmx-focus-ring-offset))}.aqmx-multi-panel-frame .aqmx-document-toolbar>.aqmx-icon-button{flex-shrink:1;min-inline-size:0}.aqmx-multi-toast{animation:aqmx-multi-toast-in var(--aqmx-duration-3) var(--aqmx-ease)}.aqmx-multi-toast:popover-open{max-inline-size:min(34rem, calc(var(--aqmx-multi-toast-room) - var(--aqmx-space-8)));margin:0;position:fixed;inset:auto;inset-block-start:calc(var(--aqmx-multi-toast-block-start) + var(--aqmx-space-6));inset-inline-end:calc(var(--aqmx-multi-toast-inline-end) + var(--aqmx-space-7));overflow:visible}@keyframes aqmx-multi-toast-in{0%{opacity:0;translate:0 calc(var(--aqmx-space-5) * -1)}}@media (prefers-reduced-motion:reduce){.aqmx-multi-toast{animation:none}}@media (forced-colors:active){.aqmx-multi-stage:focus-visible,.aqmx-multi-stage :focus-visible,.aqmx-multi-panel[data-maximized]{outline-color:highlight}}.aqmx-split-frame{--aqmx-sheet-target:2.75rem;flex-direction:column;flex:auto;min-block-size:0;min-inline-size:0;display:flex;position:relative}.aqmx-rem-probe{visibility:hidden;pointer-events:none;block-size:0;inline-size:1rem;position:absolute;inset-block-start:0;inset-inline-start:0}.aqmx-split{flex:auto;min-block-size:0}.aqmx-split-explorer,.aqmx-split-content{background:var(--aqmx-surface);min-block-size:0}.aqmx-split-explorer{background:var(--aqmx-surface-raised)}.aqmx-split-handle{background:var(--aqmx-surface-raised);transition:background-color var(--aqmx-duration-2) var(--aqmx-ease)}.aqmx-split-handle:hover,.aqmx-split-handle:focus-visible{background:var(--aqmx-surface-sunken)}.aqmx-sheet-bar{padding:var(--aqmx-space-3) var(--aqmx-space-5);border-block-end:var(--aqmx-space-1) solid var(--aqmx-border);background:var(--aqmx-surface-raised);flex:none;align-items:center;display:flex}.aqmx-sheet-toggle,.aqmx-sheet-close{justify-content:center;align-items:center;gap:var(--aqmx-space-5);min-inline-size:var(--aqmx-sheet-target);min-block-size:var(--aqmx-sheet-target);padding:0 var(--aqmx-space-6);border:var(--aqmx-space-1) solid var(--aqmx-border);border-radius:var(--aqmx-radius-m);color:var(--aqmx-text);background:var(--aqmx-surface);font:inherit;cursor:pointer;transition:background-color var(--aqmx-duration-2) var(--aqmx-ease);display:inline-flex}.aqmx-sheet-close{z-index:1;color:var(--aqmx-text-muted);background:var(--aqmx-surface-raised);border-color:#0000;padding:0;position:relative}.aqmx-sheet-toggle:hover,.aqmx-sheet-close:hover{background:var(--aqmx-surface-sunken)}.aqmx-sheet-toggle>svg,.aqmx-sheet-close>svg{inline-size:var(--aqmx-icon);block-size:var(--aqmx-icon);flex:none}.aqmx-sheet{inline-size:min(calc(100vw - var(--aqmx-space-9)), 21rem);border:0;border-inline-end:var(--aqmx-space-1) solid var(--aqmx-border);block-size:100dvh;max-block-size:none;max-inline-size:none;color:var(--aqmx-text);background:var(--aqmx-surface-raised);box-shadow:var(--aqmx-shadow);margin:0;padding:0;position:fixed;inset-block:0;inset-inline:0 auto}.aqmx-sheet::backdrop{background:#0f172a61}.aqmx-sheet-panel{flex-direction:column;block-size:100%;display:flex}.aqmx-sheet-header{z-index:1;justify-content:flex-end;align-items:center;gap:var(--aqmx-space-3);padding:var(--aqmx-space-3);border-block-end:var(--aqmx-space-1) solid var(--aqmx-border);flex:none;display:flex;position:relative}.aqmx-sheet-notice-slot>.aqmx-toast{--aqmx-sheet-notice-band:calc(var(--aqmx-sheet-target) + var(--aqmx-space-3) * 2);--aqmx-sheet-notice-line:calc(var(--aqmx-line-height-compact) * 1em);--aqmx-sheet-notice-inset:calc((var(--aqmx-sheet-notice-band) - var(--aqmx-sheet-notice-line)) / 2);z-index:0;max-inline-size:none;padding-block:var(--aqmx-sheet-notice-inset) 0;padding-inline:var(--aqmx-space-6) var(--aqmx-space-3);border:0;border-block-end:var(--aqmx-space-1) solid var(--aqmx-warning-border);line-height:var(--aqmx-line-height-compact);overflow-wrap:anywhere;box-shadow:none;border-radius:0;position:absolute;inset-block:0 auto;inset-inline:0}.aqmx-sheet-notice-slot>.aqmx-toast:before{content:"";float:inline-end;inline-size:calc(var(--aqmx-sheet-target) + var(--aqmx-space-3));block-size:calc(var(--aqmx-sheet-notice-band) - var(--aqmx-sheet-notice-inset) - var(--aqmx-space-1))}.aqmx-sheet-notice-slot>.aqmx-toast:after{content:"";block-size:calc(var(--aqmx-sheet-notice-inset) - var(--aqmx-space-1));display:block}.aqmx-sheet-body{isolation:isolate;flex-direction:column;flex:auto;min-block-size:0;display:flex;position:relative;overflow:hidden}.aqmx-document-column{flex-direction:column;min-block-size:0;display:flex}.aqmx-document-column>.aqmx-document{flex:1 1 0;block-size:auto;min-block-size:0}.aqmx-single{flex:auto;position:relative}.aqmx-tree-document{block-size:100%;inline-size:100%}.aqmx-split-fallback,.aqmx-stage-fallback{background:var(--aqmx-surface-sunken);flex:auto;min-block-size:0}@media (forced-colors:active){.aqmx-sheet-toggle[aria-expanded=true]{forced-color-adjust:none;color:highlighttext;background:highlight}.aqmx-sheet-toggle:focus-visible,.aqmx-sheet-close:focus-visible{outline-color:highlight}.aqmx-split-handle:focus-visible{outline:var(--aqmx-focus-ring-width) solid Highlight!important;outline-offset:calc(-1 * var(--aqmx-focus-ring-width))!important}}@media (prefers-reduced-motion:reduce){.aqmx-split-handle,.aqmx-split-handle *{transition-duration:0s!important}}}@layer utilities;
@@ -18,9 +18,9 @@ Tests and host styling may rely on the `data-testid` values and `data-aqmx-*` at
18
18
  | `data-testid="markdown-explorer-sheet-announcer"` | The sheet's polite live region (`role="status"`), inside the dialog | Holds the announcements while the sheet is open (the modal dialog hides the root's region), with the same text as the root's region would; empty while the sheet is closed and when it opens |
19
19
  | `data-testid="markdown-explorer-split-loading"` | Placeholder while the tree view's code loads | |
20
20
  | `data-testid="markdown-explorer-single"` | Single view frame | |
21
- | `data-testid="markdown-explorer-single-toolbar"` | The single view's toolbar row | Above the document; holds the single view's Refresh |
22
- | `data-testid="markdown-explorer-single-refresh"` | The single view's Refresh button | Named by its visible label (`refresh`; tooltip `refreshDocument`). Carries `aria-busy="true"` and `data-aqmx-busy="true"` while the document reloads, and `aria-disabled="true"` then and while the document loads (never `disabled`) |
23
- | `data-testid="markdown-explorer-single-refresh-failure"` | Alert of a document reload that failed | `role="alert"`; carries `data-aqmx-failure` (the reason). Shown while the reloaded document stays on screen, until the next refresh starts, and only for that document |
21
+ | `data-testid="markdown-explorer-document-refresh-bar"` | The document refresh bar | In the tree and single views, above the document region (the button at its inline end; absent while the tree view shows no document); in the multi view, the first row of each panel's body, inside the panel's scroll area and pinned (sticky) to its top while the document scrolls under it. Holds the button row and, below it, the failure notice |
22
+ | `data-testid="markdown-explorer-document-refresh"` | The Refresh document button, in the bar | Reads that document alone again past the host's caches. The page views name it by its visible label (`refreshDocumentLabel`; tooltip `refreshDocument`); a panel's is icon-only, with `aria-label` and `title` set to `refreshDocumentNamed` (the panel title). Carries `aria-busy="true"` and `data-aqmx-busy="true"` while it runs, and `aria-disabled="true"` then and while the document loads (never `disabled`) |
23
+ | `data-testid="markdown-explorer-document-refresh-failure"` | Notice of a document refresh that failed, inside the bar below its button row | No live role (the announcer speaks the same text); carries `data-aqmx-failure` (the reason). Shown while the copy of the document it kept stays on screen: a newer answer that replaces or confirms that copy, a move to another document (it does not come back on return) and that control's next refresh take it down |
24
24
  | `data-aqmx-key-repeat="allow"` | A control inside the explorer, or an element around controls | Opts the control (or every control inside the element) in to the key repeat of a held Enter, which the explorer otherwise ignores: a press of Enter that began on the control keeps activating it once per repeat while the focus stays there, and a press that began elsewhere and handed the focus to it does not (see [Held keys](layout.md#held-keys)); the explorer sets it on Zoom in and Zoom out |
25
25
 
26
26
  ## Explorer
@@ -29,7 +29,7 @@ Tests and host styling may rely on the `data-testid` values and `data-aqmx-*` at
29
29
  | --- | --- | --- |
30
30
  | `data-testid="markdown-explorer-explorer"` | The explorer `nav` | Carries `data-aqmx-mode` (`tree` / `multi`) |
31
31
  | `data-testid="markdown-explorer-source-select"` | Source switcher | Shown with more than one source |
32
- | `data-testid="markdown-explorer-refresh"` | The tree's Refresh button | Named by its visible label (`refresh`; tooltip `refreshTree`). Carries `aria-disabled="true"`, `aria-busy="true"` and `data-aqmx-busy="true"` while the tree reloads (never `disabled`) |
32
+ | `data-testid="markdown-explorer-refresh"` | The explorer's Refresh tree button | Named by its visible label (`refreshTreeLabel`; tooltip `refreshTree`). Carries `aria-disabled="true"`, `aria-busy="true"` and `data-aqmx-busy="true"` while the tree reloads (never `disabled`) |
33
33
  | `data-testid="markdown-explorer-refresh-failure"` | Alert of a tree reload that failed | `role="alert"`, first in the explorer's body; carries `data-aqmx-failure` (the reason). The old tree stays below it; shown until the next refresh starts, and only while its source is the pane's |
34
34
  | `data-testid="markdown-explorer-expand-all"` / `-collapse-all` | Tree controls | `aria-disabled="true"` while unavailable (never `disabled`). Expand all also carries `aria-busy="true"`, `data-aqmx-busy="true"` and `aria-disabled="true"` while a press runs (it ignores presses meanwhile); Collapse all ends a running press |
35
35
  | `data-testid="markdown-explorer-tree-settings"` | Tree settings button | |