@aiquants/markdown-explorer 0.11.0 → 0.12.1

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 (42) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/README.md +65 -6
  3. package/dist/EditSurface-By6NPcD7.js +633 -0
  4. package/dist/EditSurface-BztcpQPW.cjs +2 -0
  5. package/dist/{ExplorerSplit-DwlWWfRv.js → ExplorerSplit-BjjqNRtj.js} +52 -52
  6. package/dist/{ExplorerSplit-51frK8xf.cjs → ExplorerSplit-CqmbUSZ7.cjs} +1 -1
  7. package/dist/{MultiLayout-CeR_l6Rb.js → MultiLayout-BYXoD1aS.js} +4 -4
  8. package/dist/{MultiLayout-B4PtS45V.cjs → MultiLayout-BZbEl73E.cjs} +1 -1
  9. package/dist/{NativeScrollBar-Dp4YWBp7.cjs → NativeScrollBar-B7jTbQmn.cjs} +1 -1
  10. package/dist/{NativeScrollBar-CVWeTlHC.js → NativeScrollBar-RP37nwmY.js} +1 -1
  11. package/dist/{TreeLayout-D-NyhuVM.cjs → TreeLayout-CEp5oKly.cjs} +1 -1
  12. package/dist/{TreeLayout-min5AOhr.js → TreeLayout-Uo6RG7lq.js} +3 -3
  13. package/dist/client/MarkdownExplorer.d.cts +3 -2
  14. package/dist/client/MarkdownExplorer.d.ts +3 -2
  15. package/dist/core/contracts.d.cts +16 -0
  16. package/dist/core/contracts.d.ts +16 -0
  17. package/dist/dataRoute-CH3yOKR0.cjs +1 -0
  18. package/dist/{dataRoute-CU9CKP44.js → dataRoute-Pm_0ue_4.js} +93 -92
  19. package/dist/{index-DJ_FUtYM.cjs → index-CGBl3fYT.cjs} +8 -8
  20. package/dist/{index-BPj19kIo.js → index-CjCr8czx.js} +962 -908
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.cts +1 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +9 -9
  25. package/dist/{location-LNl0QOXI.cjs → location-BUNWJ4eB.cjs} +1 -1
  26. package/dist/{location-BT23fKeh.js → location-DWd6SQhN.js} +1 -1
  27. package/dist/{merge-AnqxGn__.cjs → merge-DRGBbLuR.cjs} +1 -1
  28. package/dist/{merge-hyUGPGbJ.js → merge-q-5i8qsn.js} +1 -1
  29. package/dist/sanitizePolicy-BfUlXI5E.cjs +1 -0
  30. package/dist/sanitizePolicy-djLC3fRN.js +96 -0
  31. package/dist/sanitizeWorker.cjs +1 -1
  32. package/dist/sanitizeWorker.js +143 -226
  33. package/dist/server.cjs +1 -1
  34. package/dist/server.js +3 -3
  35. package/dist/styles/markdown-explorer.css +1 -1
  36. package/docs/behavior/dom-hooks.md +1 -1
  37. package/docs/behavior/layout.md +4 -1
  38. package/docs/behavior/security.md +2 -0
  39. package/package.json +3 -3
  40. package/dist/EditSurface-BK_Pz_LF.js +0 -371
  41. package/dist/EditSurface-CfbYYXrc.cjs +0 -2
  42. package/dist/dataRoute-CIFFX5bd.cjs +0 -1
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react/jsx-runtime"),E=require("react"),L=require("./index-CGBl3fYT.cjs"),W=require("@codemirror/commands"),Y=require("@codemirror/lang-markdown"),se=require("@codemirror/language"),J=require("@codemirror/search"),B=require("@codemirror/state"),C=require("@codemirror/view"),R=require("@lezer/highlight"),fe=require("@aiquants/markdown"),K=require("@aiquants/markdown/source-lines"),F=require("./dataRoute-CH3yOKR0.cjs"),$=require("./sanitizePolicy-BfUlXI5E.cjs"),me=require("isomorphic-dompurify"),ie={history:W.historyField},pe=se.HighlightStyle.define([{tag:[R.tags.heading1,R.tags.heading2,R.tags.heading3,R.tags.heading4,R.tags.heading5,R.tags.heading6,R.tags.heading],color:"var(--aqmx-syntax-heading)",fontWeight:"700"},{tag:R.tags.strong,fontWeight:"700"},{tag:R.tags.emphasis,fontStyle:"italic"},{tag:R.tags.strikethrough,textDecoration:"line-through"},{tag:R.tags.link,color:"var(--aqmx-syntax-link)",textDecoration:"underline"},{tag:R.tags.url,color:"var(--aqmx-syntax-url)"},{tag:R.tags.monospace,color:"var(--aqmx-syntax-code)"},{tag:R.tags.quote,color:"var(--aqmx-syntax-quote)"},{tag:[R.tags.processingInstruction,R.tags.contentSeparator,R.tags.labelName,R.tags.meta],color:"var(--aqmx-syntax-mark)"}]),he=C.EditorView.theme({"&":{height:"100%",color:"var(--aqmx-text)",backgroundColor:"var(--aqmx-surface)",fontSize:"var(--aqmx-font-size-title)"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace',lineHeight:"var(--aqmx-line-height-prose)"},".cm-content":{caretColor:"var(--aqmx-text)",paddingBlock:"var(--aqmx-space-6)"},".cm-line":{paddingInline:"var(--aqmx-space-6)"},"&.cm-focused .cm-cursor":{borderLeftColor:"var(--aqmx-text)"},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"var(--aqmx-editor-selection)"},".cm-activeLine":{backgroundColor:"var(--aqmx-editor-active-line)"},".cm-gutters":{backgroundColor:"var(--aqmx-surface-raised)",color:"var(--aqmx-editor-gutter)",borderInlineEnd:"var(--aqmx-space-1) solid var(--aqmx-border)"},".cm-activeLineGutter":{backgroundColor:"var(--aqmx-editor-active-line)"},".cm-searchMatch":{outline:"var(--aqmx-space-1) solid var(--aqmx-border-strong)"},".cm-panels":{backgroundColor:"var(--aqmx-surface-raised)",color:"var(--aqmx-text)"}}),le="data-aqmx-conflict-actions",ge=C.Decoration.line({attributes:{"data-aqmx-conflict-line":"marker"}}),ve=C.Decoration.line({attributes:{"data-aqmx-conflict-line":"ours"}}),we=C.Decoration.line({attributes:{"data-aqmx-conflict-line":"theirs"}});class Ee extends C.WidgetType{constructor(t,r){super(),this.index=t,this.labels=r}index;labels;eq(t){return t.index===this.index&&t.labels===this.labels}toDOM(t){const r=document.createElement("div");r.setAttribute(le,String(this.index));for(const[s,l]of[["ours",this.labels.useOurs],["theirs",this.labels.useTheirs],["both",this.labels.keepBoth]]){const i=document.createElement("button");i.type="button",i.textContent=l,i.setAttribute("data-aqmx-conflict-choice",s),i.addEventListener("mousedown",a=>a.preventDefault()),i.addEventListener("click",()=>{const a=U(t.state.doc)[this.index];a!==void 0&&(ae(t,a,s),t.focus())}),r.append(i)}return r}ignoreEvent(){return!0}}const U=e=>L.findConflictsInLines(e.iterLines()),Q=(e,t)=>{const r=new B.RangeSetBuilder;return U(e).forEach((s,l)=>{const i=e.line(s.start);r.add(i.from,i.from,C.Decoration.widget({widget:new Ee(l,t),block:!0,side:-1}));for(let a=s.start;a<=s.end;a+=1){const o=e.line(a).from,c=a===s.start||a===s.separator||a===s.end?ge:a<s.separator?ve:we;r.add(o,o,c)}}),r.finish()},be=e=>B.StateField.define({create:t=>Q(t.doc,e),update:(t,r)=>r.docChanged?Q(r.state.doc,e):t,provide:t=>C.EditorView.decorations.from(t)}),ae=(e,t,r)=>{const{doc:s}=e.state,l=(u,d)=>{const f=[];for(let m=u;m<=d;m+=1)f.push(s.line(m).text);return f},i=l(t.start+1,t.separator-1),a=l(t.separator+1,t.end-1),o=r==="ours"?i:r==="theirs"?a:[...i,...a];let c=s.line(t.start).from,p=s.line(t.end).to;o.length===0&&(t.end<s.lines?p+=1:t.start>1&&(c-=1));const n=o.join(`
2
+ `);e.dispatch({changes:{from:c,to:p,insert:n},selection:B.EditorSelection.cursor(c),scrollIntoView:!0,userEvent:"input.resolve"})},xe=({parent:e,scroll:t,text:r,saved:s,labels:l,onChange:i,onGeometry:a,onSave:o})=>{const c=[C.EditorView.scrollHandler.of((u,d,f)=>(ye(u,d.head,f,t),!0)),C.lineNumbers(),C.highlightActiveLineGutter(),W.history(),C.drawSelection(),C.highlightActiveLine(),J.highlightSelectionMatches(),C.EditorView.lineWrapping,Y.markdown({base:Y.markdownLanguage}),se.syntaxHighlighting(pe),be(l),C.keymap.of([{key:"Mod-s",preventDefault:!0,run:()=>(o(),!0)},...J.searchKeymap,...W.historyKeymap,...W.defaultKeymap]),C.EditorView.contentAttributes.of({"aria-label":l.editor,"aria-multiline":"true"}),C.EditorView.updateListener.of(u=>{u.docChanged&&i(),(u.docChanged||u.heightChanged||u.geometryChanged)&&a(u.docChanged)}),he],p=Te(s,c)??B.EditorState.create({doc:r,extensions:c}),n=new C.EditorView({state:p,parent:e});return{text:()=>n.state.doc.toString(),replaceText:u=>{const d=n.state.doc.toString();if(d===u)return;let f=0;const m=Math.min(d.length,u.length);for(;f<m&&d.charCodeAt(f)===u.charCodeAt(f);)f+=1;let w=0;for(;w<m-f&&d.charCodeAt(d.length-1-w)===u.charCodeAt(u.length-1-w);)w+=1;n.dispatch({changes:{from:f,to:d.length-w,insert:u.slice(f,u.length-w)},userEvent:"input.replace"})},reveal:({line:u,column:d},f)=>{const{doc:m}=n.state,w=m.line(Math.min(Math.max(u,1),m.lines)),b=Math.min(w.from+d,w.to);n.dispatch({selection:B.EditorSelection.cursor(b),effects:Z(n,b,f,t)})},showLine:u=>{const{doc:d}=n.state,f=d.line(Math.min(Math.max(u,1),d.lines)).from;n.dispatch({effects:Z(n,f,null,t)})},topLine:()=>{const u=t.scrollerOf(n.scrollDOM),d=L.visibleTopOf(u,n.contentDOM),f=L.frameTopOf(u)+u.clientHeight,{documentTop:m}=n,{doc:w}=n.state;let b=n.lineBlockAtHeight(Math.max(d-m,0));for(;w.lineAt(b.from).text.trim()===""&&b.to<w.length;){const A=n.lineBlockAt(b.to+1);if(m+A.top>=f)break;b=A}const S=n.coordsAtPos(b.from),T=S===null?m+b.top:S.top;return{line:n.state.doc.lineAt(b.from).number,clientTop:T,offset:T-d}},lineSpans:u=>{const d=n.scrollDOM,f=d.scrollTop+n.documentTop-L.visibleTopOf(d,n.contentDOM),{doc:m}=n.state,w=b=>m.line(Math.min(Math.max(b,1),m.lines)).from;return u.map(({first:b,last:S})=>({top:f+n.lineBlockAt(w(b)).top,bottom:f+n.lineBlockAt(w(S)).bottom}))},scrollElement:n.scrollDOM,focus:()=>n.focus(),conflicts:()=>U(n.state.doc),resolveAtCursor:u=>{const d=U(n.state.doc),f=n.state.doc.lineAt(n.state.selection.main.head).number,m=d.find(w=>w.end>=f);return m===void 0?!1:(ae(n,m,u),!0)},nextConflict:()=>{const u=U(n.state.doc);if(u[0]===void 0)return!1;const f=n.state.doc.lineAt(n.state.selection.main.head).number,m=u.findIndex(T=>T.start>f),w=m<0?0:m,b=n.state.doc.line(u[w].start).from;n.dispatch({selection:B.EditorSelection.cursor(b),effects:C.EditorView.scrollIntoView(b,{y:"center"})});const S=n.contentDOM.querySelector(`[${le}="${String(w)}"] button`);return S instanceof HTMLElement?S.focus({preventScroll:!0}):n.focus(),!0},save:()=>n.state.toJSON(ie),destroy:()=>n.destroy()}},Z=(e,t,r,s)=>{const l=s.scrollerOf(e.scrollDOM),i=(r===null?L.visibleTopOf(l,e.contentDOM):r)-L.frameTopOf(l);return C.EditorView.scrollIntoView(t,{y:"start",yMargin:i})},ye=(e,t,r,s)=>{const l=Se(e,t),i=s.scrollerOf(e.scrollDOM),a=L.frameTopOf(i),o=L.visibleTopOf(i,e.contentDOM),c=a+i.clientHeight;let p=0;switch(r.y){case"start":p=l.top-(a+r.yMargin);break;case"center":p=(l.top+l.bottom)/2-(o+c)/2;break;case"end":p=l.bottom-(c-r.yMargin);break;default:l.top<o+r.yMargin?p=l.top-(o+r.yMargin):l.bottom>c-r.yMargin&&(p=Math.min(l.bottom-(c-r.yMargin),l.top-(o+r.yMargin)))}if(p!==0&&(i.scrollTop+=p),r.y==="start")return;const n=ke(e,t);n!==null&&s.reveal(n)},Se=(e,t)=>{const{node:r,offset:s}=e.domAtPos(t);if(r.nodeType===Node.TEXT_NODE){const a=r.ownerDocument?.createRange();if(a!==void 0){a.setStart(r,s),a.setEnd(r,s);const[o]=a.getClientRects();if(o!==void 0&&o.height>0)return{top:o.top,bottom:o.bottom}}}const l=e.lineBlockAt(t),i=e.documentTop+l.top;return{top:i,bottom:i+l.height}},ke=(e,t)=>{const{node:r}=e.domAtPos(t);for(let s=r instanceof Element?r:r.parentElement;s!==null;s=s.parentElement)if(s.parentElement===e.contentDOM)return s;return null},Te=(e,t)=>{if(e==null)return null;try{return B.EditorState.fromJSON(e,{extensions:t},ie)}catch{return null}},Me=610,qe=987,ee=Object.freeze({kind:"unavailable"}),Le="true",Oe="false",Ce=e=>e===Le?!0:e===Oe?!1:null,Re=e=>{const t=new DOMParser().parseFromString(e,"text/html"),r=[];for(const s of t.querySelectorAll("img[data-asset-src], a[data-doc-path]")){const l=s.localName==="img",i=s.getAttribute(l?"data-asset-src":"data-doc-path");i!==null&&r.push({target:{kind:l?"asset":"doc",path:i},exists:Ce(s.getAttribute(l?"data-asset-exists":"data-doc-exists"))})}return r},Ae=({path:e,instant:t,preview:r,initial:s,onView:l})=>{const i=new AbortController,a={asset:new Map,doc:new Map};let o=s,c=null,p=!1,n=!1,u=null,d=null,f=[],m,w=!1,b,S=null;const T=v=>{v.parsed===o.parsed&&v.failure===o.failure&&v.busy===o.busy&&v.tier===o.tier||(o=v,l(v))},A=(v,x)=>{p||(p=!0,console.error(`[markdown-explorer] ${v}`,...x===void 0?[]:[x]))},j=v=>{if(t!==null)for(const{target:x,exists:y}of t.marksOf(v))a[x.kind].set(x.path,y)},h=()=>{clearTimeout(b),b=void 0,S?.abort(),S=null},k=()=>{d=null,f=[],clearTimeout(m),m=void 0},M=(v,x)=>{T({parsed:o.parsed,failure:v,busy:!1,tier:x})},N=()=>{clearTimeout(m),m=f.length===0?void 0:setTimeout(D,qe)},H=()=>{if(t===null||d===null)return;const v=d,x=[],y={asset:new Set,doc:new Set};let V;try{V=t.sanitize(v.html,P=>{const X=a[P.kind].get(P.path);return X===void 0&&!y[P.kind].has(P.path)&&(y[P.kind].add(P.path),x.push(P)),X??void 0})}catch(P){k(),P instanceof $.HtmlNestingLimitError?M(F.failureOf("too-large"),"instant"):(A("the draft sanitizer failed",P),M(F.failureOf("failed"),"instant"));return}f=x;const z=o.parsed!==null&&o.parsed.htmlContent===V&&o.parsed.headings===v.headings?o.parsed:{htmlContent:V,headings:v.headings};T({parsed:z,failure:null,busy:!1,tier:"instant"}),N()},D=()=>{if(m=void 0,w||d===null||f.length===0)return;w=!0;const v=f;r(e,d.text,i.signal).then(x=>{if(w=!1,!(i.signal.aborted||!("kind"in x))){x.kind==="preview"&&j(x.htmlContent);for(const y of v)a[y.kind].has(y.path)||a[y.kind].set(y.path,null);H()}})},g=v=>{h(),k(),T({...o,busy:!0,tier:"server"});const x=new AbortController;S=x,b=setTimeout(()=>{b=void 0,r(e,v,x.signal).then(y=>{if(!(x.signal.aborted||!("kind"in y))){if(S=null,y.kind==="failure"){M(y.failure,"server");return}j(y.htmlContent),T({parsed:{htmlContent:y.htmlContent,headings:y.headings},failure:null,busy:!1,tier:"server"})}})},Me)},q=async(v,x)=>{let y;try{y=await v.convert({path:e,text:x},i.signal)}catch(z){return i.signal.aborted||A("the draft converter rejected a conversion, which its contract allows only once the signal aborted",z),ee}const V=F.draftAnswerViolation(y);return V===null?y:(A(`the draft converter answered outside its contract: ${V}`),ee)},_=(v,x)=>{switch(x.kind){case"preview":if(h(),x.headings.length>F.EXPLORER_MAX_HEADINGS){k(),M(F.failureOf("too-large"),"instant");return}d={text:v,html:x.htmlContent,headings:x.headings.map(({text:y,depth:V,id:z})=>({text:y,depth:V,id:z}))},H();return;case"failure":h(),k(),M(F.failureOf(x.failure.reason,x.failure.code),"instant");return;case"unavailable":g(v);return}},I=async v=>{n=!0;try{for(;u!==null&&!i.signal.aborted;){const x=u;u=null;const y=await q(v,x);if(i.signal.aborted)return;_(x,y)}}finally{n=!1}};return t!==null&&t.seed!==null&&j(t.seed),{update:v=>{if(!(i.signal.aborted||v===c)){if(c=v,clearTimeout(m),m=void 0,t===null){g(v);return}u=v,n||I(t.converter)}},dispose:()=>{i.abort(),u=null,clearTimeout(m),m=void 0,h()}}},Ie=(e,t)=>$.createHtmlSanitizer(me(window),e,t,$.MAX_HTML_NESTING_DEPTH),Ne=(e,t)=>e.flatMap((r,s)=>{const l=t[s];return l===void 0?[]:[{editor:l.top,preview:r.top},{editor:l.bottom,preview:r.bottom}]}),De=e=>{const t=[],r=[];e.forEach((l,i)=>{let a=0,o=t.length;for(;a<o;){const c=a+o>>1;(e[t[c]??0]?.preview??0)<=l.preview?a=c+1:o=c}r[i]=a>0?t[a-1]??-1:-1,t[a]=i});const s=[];for(let l=t.at(-1)??-1;l>=0;l=r[l]??-1){const i=e[l];i!==void 0&&s.push(i)}return s.reverse()},_e=(e,t)=>{const r=Math.max(t.editorMax,0),s=Math.max(t.previewMax,0),l=r-t.editorViewport,i=s-t.previewViewport,a=e.filter(c=>c.editor>0&&c.editor<l&&c.preview>0&&c.preview<i).sort((c,p)=>c.editor-p.editor||c.preview-p.preview),o=[{editor:0,preview:0}];for(const c of De(a)){const p=o.at(-1);(p===void 0||c.editor>p.editor&&c.preview>p.preview)&&o.push(c)}return o.push({editor:r,preview:s}),{toPreview:c=>te(o,"editor","preview",c),toEditor:c=>te(o,"preview","editor",c)}},te=(e,t,r,s)=>{const l=e[0],i=e.at(-1);if(l===void 0||i===void 0||Number.isNaN(s)||s<=l[t])return l?.[r]??0;if(s>=i[t])return i[r];let a=0,o=e.length-1;for(;o-a>1;){const n=a+o>>1;(e[n]?.[t]??0)<=s?a=n:o=n}const c=e[a]??l,p=e[o]??i;return c[r]+(p[r]-c[r])*(s-c[t])/(p[t]-c[t])},Ve=610,re=89,ne=.5,Pe=({editor:e,preview:t,previewBlocks:r,editorSpans:s,requestFrame:l,cancelFrame:i,now:a})=>{let o="editor",c=0,p=null,n=!1,u=null,d=null;const f={editor:0,preview:0},m={editor:null,preview:null};let w=null,b=()=>{};const S=g=>{o=g,c=a()+Ve},T=(g,q)=>{g!==o&&a()>=c&&!A(g,q)&&(o=g),N()},A=(g,q)=>{const _=m[g];return a()<f[g]||_!==null&&Math.abs(q.position()-_)<ne},j=e.onScroll(()=>T("editor",e)),h=e.onIntent(()=>S("editor")),k=()=>{const g=t();return g!==w&&(b(),w=g,b=g===null?()=>{}:M(g)),g},M=g=>{const q=g.onScroll(()=>T("preview",g)),_=g.onIntent(()=>S("preview"));return()=>{q(),_()}},N=()=>{!n&&p===null&&(p=l(H))},H=()=>{p=null;const g=k();g!==null&&(u??=r(),d??=_e(Ne(u,s(u)),{editorMax:e.max(),previewMax:g.max(),editorViewport:e.viewport(),previewViewport:g.viewport()}),o==="editor"?D(g,"preview",d.toPreview(e.position())):D(e,"editor",d.toEditor(g.position())))},D=(g,q,_)=>{if(Math.abs(g.position()-_)<ne){m[q]=g.position();return}f[q]=a()+re,m[q]=g.scrollTo(_)};return N(),{editorChanged:g=>{d=null,g&&S("editor"),N()},previewChanged:()=>{u=null,d=null,f.preview=a()+re,N()},dispose:()=>{n=!0,p!==null&&i(p),p=null,j(),h(),b()}}},oe=Object.freeze(["wheel","pointerdown","keydown","focusin"]),ce=e=>({position:()=>e.scrollTop,max:()=>Math.max(e.scrollHeight-e.clientHeight,0),viewport:()=>e.clientHeight,scrollTo:t=>(e.scrollTo({top:t,behavior:"instant"}),e.scrollTop),onScroll:t=>(e.addEventListener("scroll",t,{passive:!0}),()=>e.removeEventListener("scroll",t)),onIntent:t=>{for(const r of oe)e.addEventListener(r,t,{capture:!0,passive:!0});return()=>{for(const r of oe)e.removeEventListener(r,t,{capture:!0})}}}),G="[data-aqmd-scroll-container]",je="[data-aqmd-content]",He=`[${K.SOURCE_LINES_ATTRIBUTE}]`,Be=Object.freeze(["p1","p2","p3","p4","p5","p6","p7","p8"]),ue=(e,t)=>{const r=L.loadedOf(e.peek(t));return r!==null&&r.document.kind==="markdown"?{htmlContent:r.document.htmlContent,headings:r.document.headings}:null},Fe=(e,t,r,s,l)=>{if(r===void 0)return null;let i;try{i=Ie(e,t)}catch(a){return console.error("[markdown-explorer] the draft sanitizer cannot run in this browser, so the server renders the preview",a),null}return{converter:r,sanitize:i,marksOf:Re,seed:ue(s,l)?.htmlContent??null}},ze=e=>{const t=[];let r=null;for(const s of e.querySelectorAll(He)){const l=K.parseSourceLines(s.getAttribute(K.SOURCE_LINES_ATTRIBUTE));if(l===null||s.getClientRects().length===0)continue;r??=e.scrollTop-L.visibleTopOf(e,s);const{top:i,bottom:a}=s.getBoundingClientRect();t.push({first:l.first,last:l.last,top:r+i,bottom:r+a})}return t},Ue=({path:e,readDraft:t,viewer:r,onLayout:s,handleRef:l})=>{const{config:i,data:a,documents:o,draftConverter:c,labels:p}=L.useExplorer(),[n,u]=E.useState(()=>({parsed:ue(o,e),failure:null,busy:!0,tier:c===void 0?"server":"instant"})),d=E.useRef(null),f=E.useRef(null),m=E.useRef(n);E.useLayoutEffect(()=>{m.current=n});const w=E.useEffectEvent(()=>t());E.useEffect(()=>{const h=Fe(i.iframeHosts,i.dataPath,c,o,e),k=Ae({path:e,instant:h,preview:a.preview,initial:m.current,onView:M=>E.startTransition(()=>u(M))});return f.current=k,k.update(w()),()=>{k.dispose(),f.current=null}},[i,a,o,c,e]);const b=E.useEffectEvent(()=>s());E.useLayoutEffect(()=>{n.parsed!==null&&b()},[n.parsed]);const S=n.parsed!==null;E.useEffect(()=>{const h=S?d.current?.querySelector(G):null;if(!(h instanceof HTMLElement))return;const k=new ResizeObserver(()=>b());k.observe(h);const M=h.querySelector(je);return M!==null&&k.observe(M),()=>k.disconnect()},[S]);const T=E.useRef(null);E.useImperativeHandle(l,()=>({draft:h=>{f.current?.update(h)},scrollPort:()=>{const h=d.current?.querySelector(G);return h instanceof HTMLElement?(T.current?.scroller!==h&&(T.current={scroller:h,port:ce(h)}),T.current.port):null},blocks:()=>{const h=d.current?.querySelector(G);return h instanceof HTMLElement?ze(h):[]}}),[]);const A=E.useMemo(()=>({...r,showToc:!1,showStyle:!1,showAlign:!1,renderScrollBar:void 0}),[r]),j=E.useMemo(()=>n.parsed===null?null:O.jsx("div",{className:"aqmx-document-viewer",children:O.jsx(fe.MarkdownViewer,{...A,parseResult:n.parsed,content:null})}),[A,n.parsed]);return O.jsxs("section",{ref:d,className:"aqmx-edit-preview","aria-label":p.previewRegion,"aria-busy":n.busy,"data-aqmx-preview-tier":n.tier,"data-testid":"markdown-explorer-edit-preview",children:[n.failure===null?null:O.jsx("p",{className:"aqmx-callout aqmx-document-notice","data-aqmx-tone":"warning","data-testid":"markdown-explorer-edit-preview-failure",children:p.previewFailed(L.failureTitleOf(p,n.failure.reason))}),j??(n.failure===null?O.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-preview-skeleton",children:Be.map(h=>O.jsx("span",{},h))}):null),n.busy?O.jsx("p",{className:"aqmx-sr-only",children:p.previewUpdating}):null]})},de=144,We=Object.freeze(["e1","e2","e3","e4","e5","e6","e7","e8"]),Ge=e=>{if(typeof e!="object"||e===null)return!1;const{generation:t,topLine:r}=e;return"state"in e&&typeof t=="number"&&typeof r=="number"},Ke=e=>{e.key==="Escape"&&L.consumeKey(e)},$e=e=>{e.stopPropagation()},Xe=e=>{const{path:t,name:r,session:s}=e,{edits:l,labels:i,announcer:a}=L.useExplorer(),{phase:o}=s,c=E.useCallback(()=>l.retry(t),[l,t]);switch(E.useEffect(()=>{o.kind==="failed"&&a.announce(i.documentFailed(r,L.failureTitleOf(i,o.failure.reason)))},[o,a,i,r]),o.kind){case"opening":return O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-edit-skeleton",children:We.map(p=>O.jsx("span",{},p))}),O.jsx("p",{className:"aqmx-sr-only",children:i.editLoading})]});case"grant":return O.jsx("div",{className:"aqmx-edit-message",children:O.jsx(L.EditGrantNotice,{href:o.href,onRetry:c,testId:"markdown-explorer-edit-grant"})});case"failed":return O.jsx("div",{className:"aqmx-edit-message",children:O.jsx(L.FailureView,{failure:o.failure,alert:!1,onRetry:c,testId:"markdown-explorer-edit-failure"})});case"editing":return O.jsx(Ye,{...e})}},Ye=({path:e,name:t,session:r,layout:s,viewer:l,region:i,paneScroll:a})=>{const{edits:o,labels:c}=L.useExplorer(),p=E.useRef(null),n=E.useRef(null),u=E.useRef(null),d=E.useRef(null),f=L.usePreviewShown()&&s==="fill",m=E.useRef({layout:s,region:i,paneScroll:a});E.useLayoutEffect(()=>{m.current={layout:s,region:i,paneScroll:a}});const w=E.useRef(r.generation);E.useLayoutEffect(()=>{w.current=r.generation});const b=E.useRef(f);E.useLayoutEffect(()=>{b.current=f});const S=E.useMemo(()=>({editor:c.editorLabel(t),useOurs:c.conflictUseOurs,useTheirs:c.conflictUseTheirs,keepBoth:c.conflictKeepBoth}),[c,t]);E.useLayoutEffect(()=>{const h=p.current,k=o.draft(e);if(h===null||k===null)return;const M=o.editorState.get(e),N=Ge(M)&&M.generation===w.current?M:null;let H=null,D=null;const g=()=>{H!==null&&clearTimeout(H),H=null,D!==null&&o.setDraft(e,D.text())},q=xe({parent:h,scroll:{scrollerOf:I=>{const{layout:v,region:x,paneScroll:y}=m.current,V=x();return v==="fill"||V===null?I:y.scrollerOf(V,I)},reveal:I=>m.current.paneScroll.reveal(I)},text:k,saved:N===null?void 0:N.state,labels:S,onGeometry:I=>d.current?.editorChanged(I),onChange:()=>{H??=setTimeout(g,de),b.current&&D!==null&&u.current?.draft(D.text())},onSave:()=>{o.save(e)}});D=q,n.current=q;const _=o.bindEditor(e,{flush:g,adopt:I=>q.replaceText(I),returnPoint:()=>{const I=q.topLine();return{line:I.line,clientTop:I.clientTop}},nextConflict:()=>q.nextConflict()});return N!==null&&q.showLine(N.topLine),()=>{g(),o.editorState.set(e,{state:q.save(),generation:w.current,topLine:q.topLine().line}),_(),q.destroy(),D=null,n.current=null}},[o,e,S]);const{request:T}=r;E.useLayoutEffect(()=>{const h=n.current,k=o.draft(e);h===null||k===null||T===null||(T.anchor!==null&&h.reveal(L.positionInSource(k,T.anchor),T.anchor.clientTop),h.focus(),o.consumeRequest(e))},[o,e,T,S]);const A=E.useCallback(()=>{const h=n.current;if(h===null)throw new Error("[markdown-explorer] the preview read the draft before the editor was mounted");return h.text()},[]);E.useLayoutEffect(()=>{const h=n.current;if(!f||h===null)return;const k=Pe({editor:ce(h.scrollElement),preview:()=>u.current?.scrollPort()??null,previewBlocks:()=>u.current?.blocks()??[],editorSpans:M=>h.lineSpans(M),requestFrame:M=>requestAnimationFrame(M),cancelFrame:M=>cancelAnimationFrame(M),now:()=>performance.now()});return d.current=k,()=>{k.dispose(),d.current=null}},[f,o,e,S]);const j=E.useCallback(()=>d.current?.previewChanged(),[]);return O.jsxs("div",{className:"aqmx-edit","data-aqmx-edit-layout":s,"data-testid":"markdown-explorer-edit",onKeyDown:Ke,onDoubleClick:$e,children:[O.jsx("div",{ref:p,className:"aqmx-edit-editor","data-testid":"markdown-explorer-editor",...L.ALLOW_KEY_REPEAT}),f?O.jsx(Ue,{path:e,readDraft:A,viewer:l,onLayout:j,handleRef:u}):null]})};exports.DRAFT_WRITE_INTERVAL_MS=de;exports.default=Xe;
@@ -1,8 +1,8 @@
1
1
  import { jsx as m, jsxs as A, Fragment as Ge } from "react/jsx-runtime";
2
- import { u as D, F as Nt, q as Ae, o as Ye, r as kt, k as Oe, s as Lt, t as At, h as Ot, w as Pt, x as qt, y as Ct } from "./index-BPj19kIo.js";
2
+ import { u as D, F as Nt, o as Ae, n as Ye, q as Lt, j as Oe, r as kt, s as At, h as Ot, t as Pt, w as qt, x as Ct } from "./index-CjCr8czx.js";
3
3
  import * as p from "react";
4
4
  import { use as be, createContext as Pe, useState as q, useCallback as w, useMemo as F, useRef as g, useLayoutEffect as I, useEffect as _, useSyncExternalStore as Ee, Suspense as Qe, useId as ye } from "react";
5
- import { C as Ft, k as Mt, l as Je, v as _t, m as It, n as Dt, E as Ht, o as Be, q as $t, s as Zt, S as ve, t as Bt, F as zt, A as Vt } from "./location-BT23fKeh.js";
5
+ import { C as Ft, k as Mt, l as Je, v as _t, m as It, n as Dt, E as Ht, o as Be, q as $t, s as Zt, S as ve, t as Bt, F as zt, A as Vt } from "./location-DWd6SQhN.js";
6
6
  import { useDirectoryTreeState as jt, DirectoryTree as Kt } from "@aiquants/directory-tree";
7
7
  import { T as Ut } from "./tapScrollCircle-u4EXeLhx.js";
8
8
  import { s as Wt } from "./storage-BSthKLSG.js";
@@ -194,14 +194,14 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
194
194
  return typeof r == "number" ? { name: n.name, path: n.absolutePath, type: n.type, modifiedAt: r } : { name: n.name, path: n.absolutePath, type: n.type };
195
195
  };
196
196
  return (n, r) => e(t(n), t(r));
197
- }, Le = (e, t) => {
197
+ }, ke = (e, t) => {
198
198
  const n = e.filter((r) => r.type === "directory");
199
199
  return t === void 0 ? n : n.sort(t);
200
200
  }, wn = (e, t) => {
201
201
  const n = /* @__PURE__ */ new Map();
202
202
  let r = 0;
203
203
  const o = (c) => {
204
- for (const l of Le(c, t.compare))
204
+ for (const l of ke(c, t.compare))
205
205
  if (t.isShownExpanded(l.path)) {
206
206
  if (l.lazy !== !0) {
207
207
  l.children !== void 0 && o(l.children);
@@ -253,7 +253,7 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
253
253
  issuedAgainst: null
254
254
  }), Tn = (e, t) => {
255
255
  const n = [];
256
- let r = Le(t.entries, t.compare);
256
+ let r = ke(t.entries, t.compare);
257
257
  for (let o = 1; r.length > 0; o += 1) {
258
258
  const c = [];
259
259
  for (const l of r) {
@@ -275,7 +275,7 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
275
275
  }
276
276
  n.push(a), e.opened += 1;
277
277
  }
278
- l.lazy !== !0 && l.children !== void 0 && c.push(...Le(l.children, t.compare));
278
+ l.lazy !== !0 && l.children !== void 0 && c.push(...ke(l.children, t.compare));
279
279
  }
280
280
  r = c;
281
281
  }
@@ -286,7 +286,7 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
286
286
  let n = 0;
287
287
  for (const r of e.loads) t.childrenOf(r)?.status === "failed" && (n += 1);
288
288
  return { kind: "done", opened: e.opened, failed: n, complete: rt(t.entries, t.isShownExpanded) };
289
- }, Ne = Object.freeze({ state: "idle" }), kn = (e) => {
289
+ }, Ne = Object.freeze({ state: "idle" }), Ln = (e) => {
290
290
  const t = g(null), n = g(e), [r, o] = q(Ne);
291
291
  I(() => {
292
292
  n.current = e;
@@ -309,19 +309,19 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
309
309
  o((f) => f.state === "running" && f.opened === i ? f : { state: "running", opened: i });
310
310
  }, []);
311
311
  return F(() => ({ status: r, start: c, end: l, advance: a }), [r, c, l, a]);
312
- }, je = ["pointerdown", "wheel", "touchstart", "keydown", "focusin"], Ln = 8, Ke = { least: Number.POSITIVE_INFINITY, stalled: 0 }, An = ({ tree: e, container: t, path: n, chain: r, rows: o, cancel: c, displayed: l, placement: a }) => {
312
+ }, je = ["pointerdown", "wheel", "touchstart", "keydown", "focusin"], kn = 8, Ke = { least: Number.POSITIVE_INFINITY, stalled: 0 }, An = ({ tree: e, container: t, path: n, chain: r, rows: o, cancel: c, displayed: l, placement: a }) => {
313
313
  const s = g(null), d = g(!0), u = g(Ke), i = g(null), f = g(null), h = g(r), v = g(a);
314
314
  I(() => {
315
315
  h.current = r, v.current = a;
316
316
  }, [r, a]);
317
317
  const E = w(() => {
318
- const L = i.current;
319
- L !== null && (i.current = null, L.phase === "asking" ? L.controller.abort() : h.current?.open(null));
318
+ const k = i.current;
319
+ k !== null && (i.current = null, k.phase === "asking" ? k.controller.abort() : h.current?.open(null));
320
320
  }, []), S = w(() => {
321
321
  s.current = null, E();
322
322
  }, [E]), C = w(() => {
323
- const L = t.current;
324
- s.current === null || f.current !== null || L === null || L.getClientRects().length === 0 || (f.current = requestAnimationFrame(() => {
323
+ const k = t.current;
324
+ s.current === null || f.current !== null || k === null || k.getClientRects().length === 0 || (f.current = requestAnimationFrame(() => {
325
325
  f.current = null;
326
326
  const b = s.current;
327
327
  if (b === null) return;
@@ -333,7 +333,7 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
333
333
  if (e.current?.scrollToPath(b, { align: "nearest" }) === !0) {
334
334
  i.current?.phase === "opening" && E();
335
335
  const { least: O, stalled: H } = u.current;
336
- u.current = R < O ? { least: R, stalled: 0 } : { least: O, stalled: H + 1 }, u.current.stalled < Ln && C();
336
+ u.current = R < O ? { least: R, stalled: 0 } : { least: O, stalled: H + 1 }, u.current.stalled < kn && C();
337
337
  return;
338
338
  }
339
339
  const y = i.current;
@@ -347,31 +347,31 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
347
347
  d.current = !1, u.current = Ke, C();
348
348
  }, [C]);
349
349
  _(() => {
350
- const L = t.current;
351
- if (L === null) return;
350
+ const k = t.current;
351
+ if (k === null) return;
352
352
  const b = typeof ResizeObserver > "u" ? null : new ResizeObserver(T);
353
- b?.observe(L);
354
- for (const R of je) L.addEventListener(R, S, { passive: !0 });
353
+ b?.observe(k);
354
+ for (const R of je) k.addEventListener(R, S, { passive: !0 });
355
355
  return () => {
356
356
  b?.disconnect();
357
- for (const R of je) L.removeEventListener(R, S);
357
+ for (const R of je) k.removeEventListener(R, S);
358
358
  f.current !== null && cancelAnimationFrame(f.current), f.current = null, E();
359
359
  };
360
360
  }, [t, T, S, E]);
361
- const k = r !== null;
361
+ const L = r !== null;
362
362
  _(() => {
363
- const L = t.current;
364
- if (S(), n === null || L === null || L.contains(L.ownerDocument.activeElement)) return;
363
+ const k = t.current;
364
+ if (S(), n === null || k === null || k.contains(k.ownerDocument.activeElement)) return;
365
365
  s.current = n;
366
366
  const b = h.current;
367
- if (k && b !== null) {
367
+ if (L && b !== null) {
368
368
  const R = new AbortController(), y = { phase: "asking", controller: R };
369
369
  i.current = y, b.ancestors(n, R.signal).then((O) => {
370
370
  i.current === y && (O === null ? i.current = null : (i.current = { phase: "opening", folders: O }, h.current?.open(O)), T());
371
371
  });
372
372
  }
373
373
  T();
374
- }, [n, k, t, S, T]), _(() => {
374
+ }, [n, L, t, S, T]), _(() => {
375
375
  (i.current?.phase === "opening" || s.current !== null && !d.current) && T();
376
376
  }, [o, T]);
377
377
  const Z = g(c);
@@ -492,7 +492,7 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
492
492
  expandAll: v,
493
493
  revealCancel: E
494
494
  }) => {
495
- const { trees: S, documents: C, labels: T, locale: k, theme: Z, data: M, config: L, sources: b, reveals: R } = D(), y = be(qe), [O] = q(hn), H = g(null), { rowHeight: de, lineColor: X } = _n(H, Z), { isExpanded: B, toggle: ee, expandMultiple: K, collapseMultiple: ae, expanded: V, isPending: le } = u, { alwaysExpanded: G, sortMode: $, folderPlacement: U } = o, { direct: ue, markDirect: W, unmarkDirect: ce, pruneDirect: me } = f, { running: oe, advance: he } = v, fe = g(null), te = g(null), N = F(() => Mt({ sortMode: $, folderPlacement: U }), [$, U]), Y = F(() => xn(N), [N]), z = w((x) => S.children(r, x), [S, r]), ne = F(() => gn(e), [e]), re = w((x) => !pe(x) && (B(x) || G && !ne.has(x)), [B, G, ne]), Q = g({ shownExpanded: re, isExpanded: B, unloadedFolders: ne, entries: e, childrenOf: z });
495
+ const { trees: S, documents: C, labels: T, locale: L, theme: Z, data: M, config: k, sources: b, reveals: R } = D(), y = be(qe), [O] = q(hn), H = g(null), { rowHeight: de, lineColor: X } = _n(H, Z), { isExpanded: B, toggle: ee, expandMultiple: K, collapseMultiple: ae, expanded: V, isPending: le } = u, { alwaysExpanded: G, sortMode: $, folderPlacement: U } = o, { direct: ue, markDirect: W, unmarkDirect: ce, pruneDirect: me } = f, { running: oe, advance: he } = v, fe = g(null), te = g(null), N = F(() => Mt({ sortMode: $, folderPlacement: U }), [$, U]), Y = F(() => xn(N), [N]), z = w((x) => S.children(r, x), [S, r]), ne = F(() => gn(e), [e]), re = w((x) => !pe(x) && (B(x) || G && !ne.has(x)), [B, G, ne]), Q = g({ shownExpanded: re, isExpanded: B, unloadedFolders: ne, entries: e, childrenOf: z });
496
496
  I(() => {
497
497
  Q.current = { shownExpanded: re, isExpanded: B, unloadedFolders: ne, entries: e, childrenOf: z };
498
498
  }, [re, B, ne, e, z]);
@@ -533,9 +533,9 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
533
533
  }
534
534
  ),
535
535
  [S, r, W, K]
536
- ), Ie = n === "multi" ? l : zn, { loopFolderName: De } = T, xt = F(() => O(e, { openPaths: Ie, childrenOf: z, renderFailedFolder: _e, loopFolderName: De }), [O, e, Ie, z, _e, De, t]), wt = kt(C, Kn), He = g([]), xe = w(() => {
536
+ ), Ie = n === "multi" ? l : zn, { loopFolderName: De } = T, xt = F(() => O(e, { openPaths: Ie, childrenOf: z, renderFailedFolder: _e, loopFolderName: De }), [O, e, Ie, z, _e, De, t]), wt = Lt(C, Kn), He = g([]), xe = w(() => {
537
537
  for (const x of He.current) Q.current.unloadedFolders.has(x) && W(x);
538
- }, [W]), { maxDepth: Se } = L.revealDocument, $e = g(d);
538
+ }, [W]), { maxDepth: Se } = k.revealDocument, $e = g(d);
539
539
  I(() => {
540
540
  $e.current = d;
541
541
  }, [d]);
@@ -621,7 +621,7 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
621
621
  },
622
622
  virtualScroll: Hn,
623
623
  sort: Y,
624
- locale: k,
624
+ locale: L,
625
625
  labels: St
626
626
  }
627
627
  )
@@ -668,7 +668,7 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
668
668
  I(() => {
669
669
  T.current = f;
670
670
  }, [f]);
671
- const k = l.expandAll, Z = w(() => c.announce(o.expandAllStarted), [c, o]), M = w(($) => c.announce(Un(o, k, $)), [c, o, k]), L = kn({ budget: k, expandMultiple: h, onStart: Z, onFinish: M }), { status: b, start: R, end: y, advance: O } = L, H = b.state === "running", de = F(() => ({ running: H, advance: O }), [H, O]), X = g(null), [B, ee] = q(!1), K = w(($) => {
671
+ const L = l.expandAll, Z = w(() => c.announce(o.expandAllStarted), [c, o]), M = w(($) => c.announce(Un(o, L, $)), [c, o, L]), k = Ln({ budget: L, expandMultiple: h, onStart: Z, onFinish: M }), { status: b, start: R, end: y, advance: O } = k, H = b.state === "running", de = F(() => ({ running: H, advance: O }), [H, O]), X = g(null), [B, ee] = q(!1), K = w(($) => {
672
672
  X.current = $, ee($ !== null);
673
673
  }, []);
674
674
  _(
@@ -686,7 +686,7 @@ const cn = /* @__PURE__ */ p.forwardRef(sn), qe = Pe(!0), et = "\0loop\0", tt =
686
686
  }, [e, G, R, B, H]), _(() => () => e(null), [e]), _(() => {
687
687
  B || y();
688
688
  }, [B, y]), /* @__PURE__ */ A(Ge, { children: [
689
- b.state === "stopped" ? /* @__PURE__ */ m(Qn, { stop: b.stop, opened: b.opened, budget: k }) : null,
689
+ b.state === "stopped" ? /* @__PURE__ */ m(Qn, { stop: b.stop, opened: b.opened, budget: L }) : null,
690
690
  /* @__PURE__ */ A("div", { className: "aqmx-explorer-tree-area", children: [
691
691
  /* @__PURE__ */ m(Qe, { fallback: /* @__PURE__ */ m(st, {}), children: /* @__PURE__ */ m(er, { result: d, onRetry: u, expansion: s, onShown: K, marks: i, claimsHeld: C, expandAll: de, revealCancel: V, ...t }) }),
692
692
  /* @__PURE__ */ m(Yn, { pending: n.pendingChildren(a), status: b })
@@ -748,7 +748,7 @@ const ct = /* @__PURE__ */ p.forwardRef(nr), Ue = "markdown-explorer-selection-r
748
748
  ] }, i)) }),
749
749
  r === void 0 ? null : /* @__PURE__ */ m("button", { type: "button", className: "aqmx-explorer-tray-open", "data-testid": "markdown-explorer-selection-open", onClick: () => r(s.map(([i]) => i)), children: c.openSelectionInMulti(s.length) })
750
750
  ] });
751
- }, ke = /* @__PURE__ */ new Map(), ar = (e, t) => {
751
+ }, Le = /* @__PURE__ */ new Map(), ar = (e, t) => {
752
752
  if (t.selected === e.has(t.path)) return e;
753
753
  const n = new Map(e);
754
754
  return t.selected ? n.set(t.path, t.name) : n.delete(t.path), n;
@@ -981,7 +981,7 @@ function Tr({
981
981
  }));
982
982
  }
983
983
  const Nr = /* @__PURE__ */ p.forwardRef(Tr);
984
- function kr({
984
+ function Lr({
985
985
  title: e,
986
986
  titleId: t,
987
987
  ...n
@@ -1002,7 +1002,7 @@ function kr({
1002
1002
  clipRule: "evenodd"
1003
1003
  }));
1004
1004
  }
1005
- const Lr = /* @__PURE__ */ p.forwardRef(kr);
1005
+ const kr = /* @__PURE__ */ p.forwardRef(Lr);
1006
1006
  function Ar({
1007
1007
  title: e,
1008
1008
  titleId: t,
@@ -1027,9 +1027,9 @@ const Or = /* @__PURE__ */ p.forwardRef(Ar), Pr = Object.freeze({
1027
1027
  folderPlacement: Sr,
1028
1028
  selectionMode: mr,
1029
1029
  doubleClickAction: br,
1030
- expandIconSize: Lr,
1030
+ expandIconSize: kr,
1031
1031
  alwaysExpanded: cr,
1032
- revealDocument: Lt,
1032
+ revealDocument: kt,
1033
1033
  removeRootIndent: pr,
1034
1034
  lines: Or,
1035
1035
  expandIcons: xr,
@@ -1157,13 +1157,13 @@ const Or = /* @__PURE__ */ p.forwardRef(Ar), Pr = Object.freeze({
1157
1157
  }, We = /* @__PURE__ */ new Set(), Mr = '[role="tree"] [role="treeitem"][tabindex="0"]', _r = "[data-directory-tree-tab-stop]", oa = (e) => {
1158
1158
  const { mode: t, sourceId: n, currentPath: r, openPaths: o, onOpenDocument: c, onSourceChange: l, onRevealSource: a, viewSwitch: s } = e, { labels: d, sources: u, trees: i, documents: f, announcer: h, reveals: v } = D(), { settings: E, advance: S } = Fr(), C = F(() => _t(t === "tree"), [t]), T = t === "tree" && E.selectionMode === "multiple";
1159
1159
  or(T);
1160
- const k = e.mode === "tree" ? e.tray.onGatheredChange : null, Z = e.mode === "tree" ? e.onOpenSelection : void 0, M = e.mode === "tree" && T ? e.tray.gathered : ke, L = w(
1160
+ const L = e.mode === "tree" ? e.tray.onGatheredChange : null, Z = e.mode === "tree" ? e.onOpenSelection : void 0, M = e.mode === "tree" && T ? e.tray.gathered : Le, k = w(
1161
1161
  (N) => {
1162
1162
  const Y = S(N);
1163
- return Y.selectionMode !== "multiple" && k?.(ke), Y;
1163
+ return Y.selectionMode !== "multiple" && L?.(Le), Y;
1164
1164
  },
1165
- [S, k]
1166
- ), b = Cr({ settings: E, descriptors: C, onAdvance: L }), R = w((N) => k?.((Y) => ar(Y, N)), [k]), y = w((N) => k?.((Y) => lr(Y, N)), [k]), O = w(() => k?.(ke), [k]), H = g(null), de = w(() => {
1165
+ [S, L]
1166
+ ), b = Cr({ settings: E, descriptors: C, onAdvance: k }), R = w((N) => L?.((Y) => ar(Y, N)), [L]), y = w((N) => L?.((Y) => lr(Y, N)), [L]), O = w(() => L?.(Le), [L]), H = g(null), de = w(() => {
1167
1167
  const N = H.current;
1168
1168
  if (N === null) return;
1169
1169
  [Mr, _r, '[data-testid="markdown-explorer-tree-settings"]'].map((z) => N.querySelector(z)).find((z) => z !== null)?.focus();
@@ -1275,18 +1275,18 @@ const Br = /* @__PURE__ */ p.forwardRef(Zr), zr = ({ explorer: e, toggleRef: t,
1275
1275
  u.navigated !== l && (i({ navigated: l, source: a.source }), u.source === a.source && !f && d(!1));
1276
1276
  const [v, E] = q(o);
1277
1277
  v !== o && (E(o), d(!1));
1278
- const S = g(null), C = g(null), T = g(null), k = g(!1), Z = ye();
1278
+ const S = g(null), C = g(null), T = g(null), L = g(!1), Z = ye();
1279
1279
  I(() => {
1280
1280
  const y = S.current;
1281
1281
  y !== null && (s && !y.open ? (y.showModal(), C.current?.focus()) : !s && y.open && (y.close(), t.current?.focus()), r(s ? T.current : null));
1282
1282
  }, [s, t, r]), I(() => () => r(null), [r]);
1283
1283
  const M = w((y) => {
1284
1284
  y.key !== "Escape" || y.defaultPrevented || (Oe(y), d(!1));
1285
- }, []), L = w((y) => {
1286
- k.current = y.target === y.currentTarget;
1285
+ }, []), k = w((y) => {
1286
+ L.current = y.target === y.currentTarget;
1287
1287
  }, []), b = w((y) => {
1288
- const O = k.current;
1289
- k.current = !1, O && y.target === y.currentTarget && d(!1);
1288
+ const O = L.current;
1289
+ L.current = !1, O && y.target === y.currentTarget && d(!1);
1290
1290
  }, []), R = w(() => {
1291
1291
  d(!1);
1292
1292
  }, []);
@@ -1295,7 +1295,7 @@ const Br = /* @__PURE__ */ p.forwardRef(Zr), zr = ({ explorer: e, toggleRef: t,
1295
1295
  /* @__PURE__ */ m(Br, { "aria-hidden": "true" }),
1296
1296
  /* @__PURE__ */ m("span", { children: c.showExplorer })
1297
1297
  ] }) }),
1298
- /* @__PURE__ */ m("dialog", { ref: S, id: Z, className: "aqmx-sheet", "aria-label": c.explorerRegion, "data-testid": "markdown-explorer-sheet", onKeyDown: M, onPointerDown: L, onClick: b, onClose: R, children: /* @__PURE__ */ A("div", { className: "aqmx-sheet-panel", children: [
1298
+ /* @__PURE__ */ m("dialog", { ref: S, id: Z, className: "aqmx-sheet", "aria-label": c.explorerRegion, "data-testid": "markdown-explorer-sheet", onKeyDown: M, onPointerDown: k, onClick: b, onClose: R, children: /* @__PURE__ */ A("div", { className: "aqmx-sheet-panel", children: [
1299
1299
  /* @__PURE__ */ A("div", { className: "aqmx-sheet-header", children: [
1300
1300
  /* @__PURE__ */ m("div", { ref: T, className: "aqmx-sheet-notice-slot" }),
1301
1301
  /* @__PURE__ */ m("button", { ref: C, type: "button", className: "aqmx-sheet-close", "aria-label": c.hideExplorer, title: c.hideExplorer, "data-testid": "markdown-explorer-sheet-close", onClick: () => d(!1), children: /* @__PURE__ */ m(ct, { "aria-hidden": "true" }) })
@@ -1405,7 +1405,7 @@ const Br = /* @__PURE__ */ p.forwardRef(Zr), zr = ({ explorer: e, toggleRef: t,
1405
1405
  if (O <= 0 || R <= 0) return;
1406
1406
  const H = Math.min(Be, R / O * 100);
1407
1407
  a.update(e === "tree" ? { treeExplorer: H } : { multiExplorer: H });
1408
- }, [a, e]), k = w(() => {
1408
+ }, [a, e]), L = w(() => {
1409
1409
  f.current !== null && clearTimeout(f.current), f.current = setTimeout(() => {
1410
1410
  f.current = null, T();
1411
1411
  }, Ht);
@@ -1420,18 +1420,18 @@ const Br = /* @__PURE__ */ p.forwardRef(Zr), zr = ({ explorer: e, toggleRef: t,
1420
1420
  (b, R) => {
1421
1421
  i.current = b;
1422
1422
  const [y = 0, O = 0] = b;
1423
- b.length === 2 && O > 0 && S(y <= 0), R.source === "keyboard" ? k() : R.source === "pointer" && (h.current = !0);
1423
+ b.length === 2 && O > 0 && S(y <= 0), R.source === "keyboard" ? L() : R.source === "pointer" && (h.current = !0);
1424
1424
  },
1425
- [k]
1426
- ), L = w(
1425
+ [L]
1426
+ ), k = w(
1427
1427
  (b) => {
1428
1428
  if (v.current = b, c?.(b), b) {
1429
1429
  h.current = !1;
1430
1430
  return;
1431
1431
  }
1432
- h.current && (h.current = !1, k());
1432
+ h.current && (h.current = !1, L());
1433
1433
  },
1434
- [c, k]
1434
+ [c, L]
1435
1435
  );
1436
1436
  return /* @__PURE__ */ A(Xt, { id: `aqmx-split-${e}`, direction: "horizontal", onLayout: M, className: "aqmx-split", "data-aqmx-split": e, children: [
1437
1437
  t ? null : /* @__PURE__ */ m(
@@ -1456,7 +1456,7 @@ const Br = /* @__PURE__ */ p.forwardRef(Zr), zr = ({ explorer: e, toggleRef: t,
1456
1456
  indicator: { visible: !0, thickness: ve.gripThickness, length: ve.gripLength, barThickness: ve.barThickness, barLength: ve.barLength },
1457
1457
  title: s.resizeExplorer,
1458
1458
  "aria-label": s.resizeExplorer,
1459
- onDragging: L,
1459
+ onDragging: k,
1460
1460
  inert: o,
1461
1461
  className: "aqmx-split-handle"
1462
1462
  }
@@ -1465,7 +1465,7 @@ const Br = /* @__PURE__ */ p.forwardRef(Zr), zr = ({ explorer: e, toggleRef: t,
1465
1465
  ] });
1466
1466
  };
1467
1467
  export {
1468
- ke as E,
1468
+ Le as E,
1469
1469
  Vr as S,
1470
1470
  sa as a,
1471
1471
  oa as b