@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
@@ -0,0 +1,3 @@
1
+ "use strict";const d=require("react/jsx-runtime"),a=require("react"),U=require("react-router"),$=require("./location-Oo21lTyV.cjs"),Ae=require("@aiquants/markdown"),z=require("./dataRoute-CKbdwkQ7.cjs"),Lt=require("@aiquants/markdown/viewer-settings"),K=require("./storage-Bkb2Axdi.cjs");function Ot(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const R=Ot(a),Ee=Object.freeze(["en","ja"]),Qe="en",et=Object.freeze({panelMoved:Object.freeze(["title","column","position"]),panelMoveUnavailable:Object.freeze(["title","move"]),panelDragStarted:Object.freeze(["title"]),panelDragCancelled:Object.freeze(["title"]),multiColumnRegion:Object.freeze(["column"])}),Ct=/\{(\w+)\}/gu,tt={explorerRegion:"Explorer",sourceLabel:"Source",refreshTreeLabel:"Refresh tree",refreshTree:"Reload the tree and the open documents from the source",treeRefreshed:"Reloaded the tree from the source",treeRefreshFailed:e=>`Could not reload the tree: ${e}`,refreshDocumentLabel:"Refresh document",refreshDocument:"Reload the document from the source",refreshDocumentNamed:e=>`Refresh ${e}`,documentRefreshed:e=>`Reloaded ${e}`,documentRefreshFailed:e=>`Could not reload the document: ${e}`,expandAll:"Expand all folders",collapseAll:"Collapse all folders",treeSettings:"Tree settings",switchToMulti:"Open in the multi-panel view",switchToTree:"Open in the tree view",resizeExplorer:"Resize the explorer",showExplorer:"Show the explorer",hideExplorer:"Close the explorer",treeRegion:"Documents",treeLoading:"Loading the tree…",treeEmptyTitle:"Nothing to show",treeEmptyBody:"This source has no documents you can open.",folderLoadFailed:"This folder could not be loaded.",loopFolderName:e=>`${e} (already open above)`,foldersLoadFailedNamed:e=>`${new Intl.ListFormat("en",{type:"conjunction"}).format(e)} could not be loaded`,foldersLoading:e=>e===1?"Loading 1 folder…":`Loading ${String(e)} folders…`,expandAllStarted:"Opening all folders…",expandAllProgress:(e,t)=>`Opening all folders (${String(e)} opened, ${String(t)} loading)…`,expandAllDone:(e,t,n)=>{const r=`Opened ${String(e)} ${e===1?"folder":"folders"}`;return t>0?`${r}; ${String(t)} could not be loaded`:n?e===0?"All folders are already open":`${r}; every folder is open`:r},expandAllFolderLimit:(e,t,n)=>`Opened ${String(e)} ${e===1?"folder":"folders"} and stopped at the limit of ${String(t)} ${t===1?"folder":"folders"} to load. Choose "${n}" again to continue`,expandAllDepthLimit:(e,t)=>`Opened ${String(e)} ${e===1?"folder":"folders"}; folders more than ${String(t)} ${t===1?"level":"levels"} deep stay closed`,treeEntryKindDirectory:"directory",treeEntryKindFile:"file",treeScrollUp:"Scroll up",treeScrollDown:"Scroll down",treeScrollToTop:"Top",treeScrollToBottom:"Bottom",selectionTitle:e=>`Selected (${String(e)})`,clearSelection:"Clear the selection",openSelectionInMulti:e=>`Open ${String(e)} in panels`,removeFromSelection:e=>`Remove ${e} from the selection`,settingSortMode:"Sort order",sortNative:"Source order",sortAscending:"Name A→Z",sortDescending:"Name Z→A",settingDirectoriesFirst:"Folders first",settingSelectionMode:"Selection",selectionSingle:"Single",selectionMultiple:"Multiple",selectionNone:"Off",settingDoubleClick:"Double-click",doubleClickRecursive:"Expand all levels",doubleClickToggle:"Toggle",settingExpandIconSize:"Expander size",expandIconSizeValue:e=>`${String(e)} px`,settingAlwaysExpanded:"Always expanded",settingRemoveRootIndent:"No root indent",settingTreeLines:"Tree lines",settingExpandIcons:"Expanders",settingDirectoryIcons:"Folder icons",settingFileIcons:"File icons",settingOn:"On",settingOff:"Off",settingAnnouncement:(e,t)=>`${e}: ${t}`,documentRegion:"Document",documentEmpty:"Select a document in the explorer.",documentLoading:"Loading the document…",documentShown:e=>`Showing ${e}`,documentFailed:(e,t)=>`${e}: ${t}`,announcementSequence:e=>e.map(t=>/[.!?]$/u.test(t)?t:`${t}.`).join(" "),textTruncated:"Only the beginning of this file is shown.",inertLink:"This link points outside the source and cannot be opened.",failureUnauthorizedTitle:"Your session has expired",failureUnauthorizedBody:"Reload the page to sign in again.",failureForbiddenTitle:"Access denied",failureForbiddenBody:"You do not have permission to open this.",failureNotFoundTitle:"Not found",failureNotFoundBody:"It may have been moved or deleted.",failureNotConfiguredTitle:"This source is not set up",failureNotConfiguredBody:"Ask your administrator to configure it.",failureInvalidTitle:"Invalid address",failureInvalidBody:"The document path in this address cannot be used.",failureTooLargeTitle:"Too large to display",failureTooLargeBody:"This file exceeds the size that can be displayed.",failureUnsupportedTitle:"Cannot be displayed",failureUnsupportedBody:"This type of file cannot be shown here.",failureFailedTitle:"Something went wrong",failureFailedBody:"Try again in a moment.",retry:"Try again",reloadPage:"Reload the page",imageZoomIn:"Zoom in",imageZoomOut:"Zoom out",imageFit:"Fit to the view",imageFitLevel:"Fit",imageZoomLevel:e=>`${String(e)}%`,openInNewTab:"Open in a new tab",download:"Download",mediaUnsupported:"Your browser cannot play this file.",fileNotShown:"This file cannot be shown here. Download it to open it.",viewerLoading:"Loading data...",viewerErrorPrefix:"Error: ",viewerStyleTitle:"Display Style",viewerSelectStyle:"Select display style",viewerPinStyle:"Pin style selector",viewerUnpinStyle:"Unpin style selector",viewerErrorTitle:"An error occurred",viewerMissingImage:"Image not found",viewerOpenToc:"Open table of contents",viewerTocTitle:"Table of contents",viewerPinToc:"Pin table of contents",viewerUnpinToc:"Unpin table of contents",viewerSelectAlign:"Select alignment",viewerAlignTitle:"Alignment",viewerPinAlign:"Pin alignment selector",viewerUnpinAlign:"Unpin alignment selector",viewerAlignLeft:"Align left",viewerAlignCenter:"Align center",viewerAlignRight:"Align right",viewerMermaidInteractionMode:"Mouse interaction mode",viewerMermaidModeNone:"No interaction",viewerMermaidModeZoom:"Zoom only",viewerMermaidModePan:"Pan only (drag)",viewerMermaidModePanShift:"Pan only (Shift+drag)",viewerMermaidModeBoth:"Zoom and pan (drag)",viewerMermaidModeBothShift:"Zoom and pan (Shift+drag)",viewerMermaidZoomIn:"Zoom In",viewerMermaidZoomOut:"Zoom Out",viewerMermaidResetView:"Reset View",viewerMermaidRetry:"Try again",viewerEmbeddedVideo:"embedded video",viewerEmbeddedPost:"embedded post",viewerEmbeddedFrame:"Embedded content",multiRegion:"Panels",multiEmpty:"Select documents in the explorer to open them side by side.",panelLimit:e=>`You can open up to ${String(e)} panels at once.`,panelOpened:e=>`Opened ${e}`,panelClosed:e=>`Closed ${e}`,panelAlreadyOpen:e=>`${e} is already open`,panelHidden:e=>`Hid ${e}`,panelShown:e=>`Showed ${e}`,panelMaximized:e=>`Maximized ${e}`,panelRestored:e=>`Restored ${e} to its size`,panelHide:"Hide the panel",panelMaximize:"Maximize the panel",panelRestore:"Restore the panel to its size",panelClose:"Close the panel",panelSwitchToCustomDrag:"Switch to the custom drag mode",panelSwitchToNormalDrag:"Back to the normal drag mode",panelCustomDragBadge:"Custom",panelMovePreviousColumn:"Move to the previous column",panelMoveNextColumn:"Move to the next column",panelMoveUp:"Move up",panelMoveDown:"Move down",panelMoved:"Moved {title} to column {column}, position {position}",panelMoveUnavailable:"{move} is not available for {title}",panelDragStarted:"Picked up {title}",panelDragCancelled:"Kept {title} where it was",hiddenPanelsTitle:"Hidden panels:",hiddenPanelBadge:"Hidden",hiddenPanelNotice:"This panel is hidden",multiColumnEmpty:"This column is empty",multiColumnRegion:"Column {column}",panelDropHere:"Drop the panel here"},Mt={explorerRegion:"エクスプローラー",sourceLabel:"ソース",refreshTreeLabel:"ツリーを更新",refreshTree:"ソースからツリーと開いている文書を読み込み直す",treeRefreshed:"ツリーをソースから読み込み直しました",treeRefreshFailed:e=>`ツリーを読み込み直せませんでした: ${e}`,refreshDocumentLabel:"文書を更新",refreshDocument:"ソースから文書を読み込み直す",refreshDocumentNamed:e=>`${e} を更新`,documentRefreshed:e=>`${e} を読み込み直しました`,documentRefreshFailed:e=>`文書を読み込み直せませんでした: ${e}`,expandAll:"すべてのフォルダーを展開",collapseAll:"すべてのフォルダーを折りたたむ",treeSettings:"ツリーの設定",switchToMulti:"マルチビューで開く",switchToTree:"ツリービューで開く",resizeExplorer:"エクスプローラーの幅を変更",showExplorer:"エクスプローラーを開く",hideExplorer:"エクスプローラーを閉じる",treeRegion:"文書の一覧",treeLoading:"ツリーを読み込み中…",treeEmptyTitle:"表示できるファイルがありません",treeEmptyBody:"このソースには開ける文書がありません。",folderLoadFailed:"このフォルダーを読み込めませんでした。",loopFolderName:e=>`${e} (上の階層で開いています)`,foldersLoadFailedNamed:e=>`${new Intl.ListFormat("ja",{type:"conjunction"}).format(e)} を読み込めませんでした`,foldersLoading:e=>`フォルダーを ${String(e)} 件読み込み中…`,expandAllStarted:"すべてのフォルダーを展開しています…",expandAllProgress:(e,t)=>`すべてのフォルダーを展開中 (展開 ${String(e)} 件、読み込み中 ${String(t)} 件)…`,expandAllDone:(e,t,n)=>{const r=`${String(e)} 件のフォルダーを展開しました`;return t>0?`${r}。うち ${String(t)} 件は読み込めませんでした`:n?e===0?"すべてのフォルダーが既に開いています":`${r}。すべてのフォルダーが開いています`:r},expandAllFolderLimit:(e,t,n)=>`${String(e)} 件のフォルダーを展開し、読み込みの上限 (${String(t)} 件) で止めました。続けるには「${n}」をもう一度押してください`,expandAllDepthLimit:(e,t)=>`${String(e)} 件のフォルダーを展開しました。深さ ${String(t)} 階層より下のフォルダーは閉じたままです`,treeEntryKindDirectory:"ディレクトリ",treeEntryKindFile:"ファイル",treeScrollUp:"上へスクロール",treeScrollDown:"下へスクロール",treeScrollToTop:"先頭へ",treeScrollToBottom:"末尾へ",selectionTitle:e=>`選択中 (${String(e)})`,clearSelection:"選択を解除",openSelectionInMulti:e=>`${String(e)} 件をパネルで開く`,removeFromSelection:e=>`${e} を選択から外す`,settingSortMode:"並び順",sortNative:"取得順",sortAscending:"名前の昇順",sortDescending:"名前の降順",settingDirectoriesFirst:"フォルダーを先に",settingSelectionMode:"選択",selectionSingle:"1 件",selectionMultiple:"複数",selectionNone:"オフ",settingDoubleClick:"ダブルクリック",doubleClickRecursive:"下の階層まで展開",doubleClickToggle:"開閉",settingExpandIconSize:"展開アイコンの大きさ",expandIconSizeValue:e=>`${String(e)} px`,settingAlwaysExpanded:"常に展開",settingRemoveRootIndent:"最上位の字下げなし",settingTreeLines:"ツリーの線",settingExpandIcons:"展開アイコン",settingDirectoryIcons:"フォルダーのアイコン",settingFileIcons:"ファイルのアイコン",settingOn:"オン",settingOff:"オフ",settingAnnouncement:(e,t)=>`${e}: ${t}`,documentRegion:"文書",documentEmpty:"エクスプローラーで文書を選んでください。",documentLoading:"文書を読み込み中…",documentShown:e=>`${e} を表示しています`,documentFailed:(e,t)=>`${e}: ${t}`,announcementSequence:e=>e.map(t=>/[。!?]$/u.test(t)?t:`${t}。`).join(""),textTruncated:"このファイルは先頭だけを表示しています。",inertLink:"リンク先がソースの外にあるため開けません。",failureUnauthorizedTitle:"セッションの有効期限が切れました",failureUnauthorizedBody:"ページを再読み込みして、もう一度サインインしてください。",failureForbiddenTitle:"アクセスが許可されていません",failureForbiddenBody:"これを開く権限がありません。",failureNotFoundTitle:"見つかりません",failureNotFoundBody:"移動または削除された可能性があります。",failureNotConfiguredTitle:"このソースは設定されていません",failureNotConfiguredBody:"管理者に設定を依頼してください。",failureInvalidTitle:"アドレスが正しくありません",failureInvalidBody:"このアドレスに含まれる文書の経路は使えません。",failureTooLargeTitle:"大きすぎて表示できません",failureTooLargeBody:"このファイルは表示できる大きさを超えています。",failureUnsupportedTitle:"表示できない形式です",failureUnsupportedBody:"この種類のファイルはここでは表示できません。",failureFailedTitle:"読み込みに失敗しました",failureFailedBody:"しばらくしてからもう一度お試しください。",retry:"再試行",reloadPage:"ページを再読み込み",imageZoomIn:"拡大",imageZoomOut:"縮小",imageFit:"画面に合わせる",imageFitLevel:"全体",imageZoomLevel:e=>`${String(e)}%`,openInNewTab:"新しいタブで開く",download:"ダウンロード",mediaUnsupported:"このブラウザではこのファイルを再生できません。",fileNotShown:"このファイルはここでは表示できません。ダウンロードして開いてください。",viewerLoading:"データを読み込み中...",viewerErrorPrefix:"エラー: ",viewerStyleTitle:"表示スタイル",viewerSelectStyle:"表示スタイルを選択",viewerPinStyle:"スタイル選択をピン留め",viewerUnpinStyle:"スタイル選択のピン留めを解除",viewerErrorTitle:"エラーが発生しました",viewerMissingImage:"画像が見つかりません",viewerOpenToc:"目次を開く",viewerTocTitle:"目次",viewerPinToc:"目次をピン留め",viewerUnpinToc:"目次のピン留めを解除",viewerSelectAlign:"揃えを選択",viewerAlignTitle:"揃え",viewerPinAlign:"揃え選択をピン留め",viewerUnpinAlign:"揃え選択のピン留めを解除",viewerAlignLeft:"左揃え",viewerAlignCenter:"中央揃え",viewerAlignRight:"右揃え",viewerMermaidInteractionMode:"マウス操作モード",viewerMermaidModeNone:"操作なし",viewerMermaidModeZoom:"拡大縮小のみ",viewerMermaidModePan:"移動のみ (左ドラッグ)",viewerMermaidModePanShift:"移動のみ (Shift+ドラッグ)",viewerMermaidModeBoth:"拡大縮小+移動 (左ドラッグ)",viewerMermaidModeBothShift:"拡大縮小+移動 (Shift+ドラッグ)",viewerMermaidZoomIn:"拡大",viewerMermaidZoomOut:"縮小",viewerMermaidResetView:"表示を元に戻す",viewerMermaidRetry:"再試行",viewerEmbeddedVideo:"埋め込みの動画",viewerEmbeddedPost:"埋め込みの投稿",viewerEmbeddedFrame:"埋め込みのコンテンツ",multiRegion:"パネル",multiEmpty:"エクスプローラーで文書を選ぶと、ここに並べて開きます。",panelLimit:e=>`同時に開けるのは ${String(e)} パネルまでです。`,panelOpened:e=>`${e} を開きました`,panelClosed:e=>`${e} を閉じました`,panelAlreadyOpen:e=>`${e} は既に開いています`,panelHidden:e=>`${e} を隠しました`,panelShown:e=>`${e} を表示しました`,panelMaximized:e=>`${e} を最大化しました`,panelRestored:e=>`${e} を元のサイズに戻しました`,panelHide:"パネルを隠す",panelMaximize:"パネルを最大化",panelRestore:"パネルを元のサイズに戻す",panelClose:"パネルを閉じる",panelSwitchToCustomDrag:"カスタムのドラッグの方式に切り替え",panelSwitchToNormalDrag:"通常のドラッグの方式に戻す",panelCustomDragBadge:"カスタム",panelMovePreviousColumn:"前の列へ移動",panelMoveNextColumn:"次の列へ移動",panelMoveUp:"上へ移動",panelMoveDown:"下へ移動",panelMoved:"{title} を {column} 列目の {position} 番目へ移動しました",panelMoveUnavailable:"{title} は「{move}」できません",panelDragStarted:"{title} を持ち上げました",panelDragCancelled:"{title} の移動を取り消しました",hiddenPanelsTitle:"隠したパネル:",hiddenPanelBadge:"非表示",hiddenPanelNotice:"このパネルは隠しています",multiColumnEmpty:"この列は空です",multiColumnRegion:"{column} 列目",panelDropHere:"ここへパネルをドロップ"},nt=Object.freeze({en:Object.freeze(tt),ja:Object.freeze(Mt)}),Le=Object.freeze(Object.keys(tt)),jt=new Set(Le),Nt=e=>jt.has(e),oe=e=>e===null?"null":typeof e=="string"?JSON.stringify(e.length>40?`${e.slice(0,40)}…`:e):typeof e=="function"?"a function":Array.isArray(e)?"an array":typeof e,rt=e=>{if(e===void 0)return Qe;if(Ee.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${Ee.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${oe(e)}`)},xe=(e,t)=>{const n=nt[rt(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${oe(t)}`);if(!$.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${oe(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Nt(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Le.join(", ")}`);const i=r[s];if(i===void 0)continue;const c=typeof n[s];if(typeof i!==c)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${c}; got ${oe(i)}`);if(typeof i=="string"&&i.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const m=et[s];if(typeof i=="string"&&m!==void 0){for(const[,h]of i.matchAll(Ct))if(!m.includes(h??""))throw new RangeError(`[markdown-explorer] labels.${s} uses the unknown placeholder {${String(h)}}; it accepts ${m.map(g=>`{${g}}`).join(", ")}`)}o[s]=i}return Object.freeze(o)},Dt=(e,t)=>{if(Object.is(e,t))return!0;if(e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const n=e,r=t,o=Object.keys(n),s=Object.keys(r);return o.length===s.length&&s.every(i=>Object.hasOwn(n,i)&&Object.is(n[i],r[i]))},be=Object.freeze(["light","dark"]),Pt=e=>{if(e===void 0)return"light";if(be.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${be.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},ot=a.createContext(null),D=()=>{const e=a.use(ot);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},J=e=>{const{viewSettings:t}=D(),n=()=>e(t.getSnapshot());return a.useSyncExternalStore(t.subscribe,n,n)},ae=()=>{const{config:e}=D(),t=U.useParams()["*"],[n]=U.useSearchParams(),r=n.toString();return a.useMemo(()=>$.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])};function $t({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm2.25 8.5a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Zm0 3a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const Ft=R.forwardRef($t),Oe=Object.freeze({browse:Object.freeze({replace:!0,preventScrollReset:!0,defaultShouldRevalidate:!1}),"switch-source":Object.freeze({replace:!1,preventScrollReset:!0,defaultShouldRevalidate:!1}),"switch-view":Object.freeze({replace:!1,preventScrollReset:!1,defaultShouldRevalidate:!1}),"follow-link":Object.freeze({replace:!1,preventScrollReset:!1,defaultShouldRevalidate:!1})}),_t=e=>Oe[e],ce=()=>{const e=U.useNavigate();return a.useCallback((t,n)=>{e(t,Oe[n])},[e])},st=({navigation:e,...t})=>d.jsx(U.Link,{...t,...Oe[e]}),lt={unauthorized:["failureUnauthorizedTitle","failureUnauthorizedBody"],forbidden:["failureForbiddenTitle","failureForbiddenBody"],"not-found":["failureNotFoundTitle","failureNotFoundBody"],"not-configured":["failureNotConfiguredTitle","failureNotConfiguredBody"],invalid:["failureInvalidTitle","failureInvalidBody"],"too-large":["failureTooLargeTitle","failureTooLargeBody"],unsupported:["failureUnsupportedTitle","failureUnsupportedBody"],failed:["failureFailedTitle","failureFailedBody"]},ee=(e,t)=>e[lt[t][0]],it=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=D(),s=ee(o,e.reason),i=o[lt[e.reason][1]],c=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning";return d.jsxs("div",{className:"aqmx-callout",role:t?"alert":void 0,"data-aqmx-tone":c,"data-testid":r===null?void 0:r,"data-aqmx-failure":r===null?void 0:e.reason,children:[d.jsx("p",{className:"aqmx-callout-title",children:s}),d.jsx("p",{className:"aqmx-callout-body",children:i}),e.reason==="unauthorized"?d.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>window.location.reload(),children:o.reloadPage}):n!==void 0&&e.reason==="failed"?d.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:o.retry}):null]})},Ce=e=>{const t=e.ownerDocument;if(e.focus({preventScroll:!0}),t.activeElement===e)return!0;if(e.hasAttribute("tabindex"))return!1;if(e.setAttribute("tabindex","-1"),e.focus({preventScroll:!0}),t.activeElement!==e)return e.removeAttribute("tabindex"),!1;const n=()=>{t.activeElement!==e&&(e.removeAttribute("tabindex"),e.removeEventListener("blur",n))};return e.addEventListener("blur",n),!0},at=(e,t)=>{const n=a.useRef(null),r=a.useRef(null),o=a.useRef(null),s=a.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);a.useEffect(()=>s,[s]);const i=a.useCallback(h=>{if(r.current!==h)return;const g=o.current;if(g!==null){g.then(()=>i(h));return}e.prefetch(h);const p=e.peek(h);if(p?.status!=="pending")return;const x=Promise.allSettled([p.promise]);o.current=x,x.then(()=>{o.current===x&&(o.current=null)})},[e]),c=a.useCallback(h=>{const g=t(h);g!==r.current&&(s(),g!==null&&(r.current=g,n.current=window.setTimeout(()=>{n.current=null,i(g)},$.PREFETCH_DWELL_MS)))},[s,t,i]),m=a.useCallback(h=>{t(h)!==r.current&&s()},[s,t]);return a.useMemo(()=>({onPointerOver:h=>c(h.target),onPointerOut:h=>m(h.relatedTarget),onFocus:h=>c(h.target),onBlur:h=>m(h.relatedTarget)}),[c,m])},te=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},ct=()=>{const e=new Map,t=new Set;let n=!1;const r=o=>{t.add(o),!n&&(n=!0,queueMicrotask(()=>{n=!1,t.clear()}))};return{hold:o=>{e.set(o,(e.get(o)??0)+1);let s=!1;return()=>{if(s)return;s=!0;const i=e.get(o);if(i!==void 0&&i>1){e.set(o,i-1);return}e.delete(o),r(o)}},isHeld:o=>e.has(o),resumes:o=>t.delete(o),heldKeys:()=>[...e.keys()]}},le=(e,t)=>{if(Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;if(Array.isArray(e)||Array.isArray(t))return!(Array.isArray(e)&&Array.isArray(t))||e.length!==t.length?!1:e.every((s,i)=>le(s,t[i]));const n=e,r=t,o=Object.keys(n);return o.length!==Object.keys(r).length?!1:o.every(s=>Object.hasOwn(r,s)&&le(n[s],r[s]))},Q=e=>{const t=e;return t.status===void 0&&(t.status="pending",e.then(n=>{t.status="fulfilled",t.value=n},n=>{t.status="rejected",t.reason=n})),t},dt=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),ne=e=>e.status==="fulfilled"?e.value:void 0,qt=55e3,Pe=Object.freeze({status:"deferred"}),$e=Object.freeze({status:"refreshed"}),he=Object.freeze({status:"superseded"}),ie=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,ut=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",Ht=({client:e,capacity:t})=>{if(!Number.isInteger(t)||t<1)throw new RangeError(`[markdown-explorer] the document cache capacity must be a positive integer; got ${String(t)}`);const n=new Map,r=ct(),o=te(),s=new WeakSet;let i=0;const c=o.emit,m=()=>(i+=1,i),h=()=>{if(!(n.size<=t))for(const f of[...n.keys()]){if(n.size<=t)return;r.isHeld(f)||n.delete(f)}},g=(f,w)=>{n.delete(f),n.set(f,w)},p=f=>performance.now()-f.validatedAt>=qt,x=(f,w,S)=>{const b=n.get(f),y=ie(b?.snapshot),F=S||b?.refreshPending===!0,I=Q(e.document(f,{refresh:F}).then(H=>({status:"loaded",document:H}))),M={snapshot:{status:"pending",promise:I,previous:y},validatedAt:performance.now(),opened:w,background:null,refreshPending:!1,seeded:void 0,stamp:m()};return g(f,M),h(),I.then(H=>{n.get(f)===M&&(M.snapshot=H,M.stamp=m(),c())}),M},T=(f,w,S,b,y,F)=>{w.background===S&&(w.background=null,!(n.get(f)!==w||w.snapshot!==b)&&(y.kind==="failure"&&b.document.kind!=="failure"||(w.validatedAt=F,w.stamp=m(),le(b.document,y)||(w.snapshot={status:"loaded",document:y}),c())))},k=async(f,w)=>{const S=w.snapshot;if(S.status!=="loaded")return null;const b={};w.background=b;const y=performance.now(),F=e.document(f,{refresh:w.refreshPending});w.refreshPending=!1;const I=await F,M=w.background===b&&n.get(f)===w&&w.snapshot===S;return T(f,w,b,S,I,y),M?I:null},L=(f,w)=>{const{snapshot:S}=w;return S.status==="pending"?!1:S.status==="loaded"&&S.document.kind!=="failure"?(k(f,w),!1):(S.status==="loaded"&&s.add(S),x(f,!0,!1),!0)},A=f=>{const w=r.hold(f);let S=!1;return()=>{if(S)return;S=!0,w();const b=n.get(f);b!==void 0&&g(f,b),h()}};return{peek:f=>n.get(f)?.snapshot,peekSeeded:f=>n.get(f)?.seeded,answerStampOf:f=>n.get(f)?.stamp,prefetch:f=>{const w=n.get(f);w!==void 0&&w.snapshot.status!=="deferred"||(x(f,!1,!1),c())},open:f=>{const w=r.resumes(f),S=A(f),b=n.get(f);if(b===void 0||b.snapshot.status==="deferred")return x(f,!0,!1),c(),S;if(g(f,b),w)return S;const{snapshot:y}=b;return y.status==="pending"?(b.opened=!0,S):y.document.kind==="failure"?(b.opened||p(b)?(s.add(y),x(f,!0,!1),c()):b.opened=!0,S):(b.opened=!0,b.background===null&&p(b)&&k(f,b),S)},retain:A,retry:f=>{const w=n.get(f);w===void 0||w.snapshot.status!=="loaded"||w.snapshot.document.kind!=="failure"||(x(f,!0,!1),c())},seed:(f,w)=>{const S=performance.now(),b=Q(w.then(H=>H===null?Pe:{status:"loaded",document:H},()=>Pe)),y=n.get(f);if(y!==void 0&&y.snapshot.status==="loaded"){const H=y.snapshot,j={};y.background=j,b.then(_=>{if(_.status==="loaded"){T(f,y,j,H,_.document,S);return}y.background===j&&(y.background=null)});return}const F=y!==void 0&&y.snapshot.status==="pending"?y.snapshot.previous:null,I={status:"pending",promise:b,previous:F},M={snapshot:I,validatedAt:S,opened:y?.opened===!0,background:null,refreshPending:y?.refreshPending===!0,seeded:I,stamp:m()};g(f,M),h(),b.then(H=>{n.get(f)===M&&(H.status==="deferred"&&r.isHeld(f)?x(f,M.opened,!1):(M.snapshot=H,M.stamp=m()),c())})},invalidate:()=>{let f=!1;for(const[w,S]of[...n]){if(S.validatedAt=Number.NEGATIVE_INFINITY,S.opened=!0,S.refreshPending=!0,!r.isHeld(w))continue;const{snapshot:b}=S;if(b.status!=="pending"){L(w,S)&&(f=!0);continue}b.promise.then(()=>{n.get(w)===S&&S.refreshPending&&r.isHeld(w)&&L(w,S)&&c()})}f&&c()},refresh:async f=>{const w=n.get(f);if(w!==void 0&&ut(w.snapshot)){w.refreshPending=!0;const b=await k(f,w);return b===null?he:b.kind==="failure"?{status:"failed",failure:b.failure}:$e}const S=x(f,!0,!0);return c(),S.snapshot.status!=="pending"?he:(await S.snapshot.promise,n.get(f)===S?$e:he)},clear:()=>{n.clear();for(const f of r.heldKeys())x(f,!0,!1);c()},subscribe:o.subscribe,noteFailureShown:f=>s.has(f)?!1:(s.add(f),!0)}};function Bt({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{d:"M10.75 2.75a.75.75 0 0 0-1.5 0v8.614L6.295 8.235a.75.75 0 1 0-1.09 1.03l4.25 4.5a.75.75 0 0 0 1.09 0l4.25-4.5a.75.75 0 0 0-1.09-1.03l-2.955 3.129V2.75Z"}),R.createElement("path",{d:"M3.5 12.75a.75.75 0 0 0-1.5 0v2.5A2.75 2.75 0 0 0 4.75 18h10.5A2.75 2.75 0 0 0 18 15.25v-2.5a.75.75 0 0 0-1.5 0v2.5c0 .69-.56 1.25-1.25 1.25H4.75c-.69 0-1.25-.56-1.25-1.25v-2.5Z"}))}const zt=R.forwardRef(Bt);function It({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M4.25 5.5a.75.75 0 0 0-.75.75v8.5c0 .414.336.75.75.75h8.5a.75.75 0 0 0 .75-.75v-4a.75.75 0 0 1 1.5 0v4A2.25 2.25 0 0 1 12.75 17h-8.5A2.25 2.25 0 0 1 2 14.75v-8.5A2.25 2.25 0 0 1 4.25 4h5a.75.75 0 0 1 0 1.5h-5Z",clipRule:"evenodd"}),R.createElement("path",{fillRule:"evenodd",d:"M6.194 12.753a.75.75 0 0 0 1.06.053L16.5 4.44v2.81a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.553l-9.056 8.194a.75.75 0 0 0-.053 1.06Z",clipRule:"evenodd"}))}const Ut=R.forwardRef(It),de=({name:e,url:t,icon:n,children:r})=>{const{labels:o}=D();return d.jsxs("div",{className:"aqmx-document-toolbar",children:[d.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:n}),d.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),r,d.jsx("a",{className:"aqmx-icon-button",href:t,target:"_blank",rel:"noopener noreferrer","aria-label":o.openInNewTab,title:o.openInNewTab,"data-testid":"markdown-explorer-file-open",children:d.jsx(Ut,{})}),d.jsx("a",{className:"aqmx-icon-button",href:t,download:e,"aria-label":o.download,title:o.download,"data-testid":"markdown-explorer-file-download",children:d.jsx(zt,{})})]})};function Zt({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M4.5 2A1.5 1.5 0 0 0 3 3.5v13A1.5 1.5 0 0 0 4.5 18h11a1.5 1.5 0 0 0 1.5-1.5V7.621a1.5 1.5 0 0 0-.44-1.06l-4.12-4.122A1.5 1.5 0 0 0 11.378 2H4.5Zm4.75 6.75a.75.75 0 0 1 1.5 0v2.546l.943-1.048a.75.75 0 0 1 1.114 1.004l-2.25 2.5a.75.75 0 0 1-1.114 0l-2.25-2.5a.75.75 0 1 1 1.114-1.004l.943 1.048V8.75Z",clipRule:"evenodd"}))}const Vt=R.forwardRef(Zt),Wt=({document:e})=>{const{labels:t}=D();return d.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[d.jsx(de,{name:e.name,url:e.url,icon:d.jsx(Vt,{})}),d.jsx("div",{className:"aqmx-document-stage",children:d.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-file-not-shown",children:[d.jsx("p",{className:"aqmx-callout-body",children:t.fileNotShown}),d.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-file-not-shown-download",children:t.download})]})})]})},Me="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",Kt=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},Gt=/(%[0-9A-Fa-f]{2})/u,je=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(Gt).flatMap((r,o)=>o%2===1?[Number.parseInt(r.slice(1),16)]:[...t.encode(r)]);return new TextDecoder("utf-8",{ignoreBOM:!0}).decode(Uint8Array.from(n))},ft=e=>`#${encodeURIComponent(e)}`,Xt=e=>{if(e==="#")return!0;const t=je(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},mt=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},Yt="http://www.w3.org/1999/xhtml",Fe=(e,t)=>{if(t==="")return null;const n=mt(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===Yt&&r.getAttribute("name")===t)return r;return null},gt=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=Fe(e,t.slice(1));if(n!==null)return n;const r=je(t);return r===null?null:Fe(e,r)},_e=e=>{const{body:t,documentElement:n}=e.ownerDocument;if(e===t){const o=getComputedStyle(n);if(o.overflowX==="visible"&&o.overflowY==="visible")return!1}const{overflowY:r}=getComputedStyle(e);return r==="auto"||r==="scroll"},Jt=e=>{const{body:t,documentElement:n}=e,r=getComputedStyle(n),o=r.overflowX==="visible"&&r.overflowY==="visible"&&t!==null?getComputedStyle(t).overflowY:r.overflowY;return o!=="hidden"&&o!=="clip"},Qt=(e,t)=>{const n=t.closest(Me),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&_e(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:i}=e.ownerDocument;for(let c=e.parentElement;c!==null&&c!==s;c=c.parentElement)if(_e(c)&&c.scrollHeight>c.clientHeight&&c.clientHeight<o)return c;return i instanceof Element&&Jt(e.ownerDocument)&&i.scrollHeight>i.clientHeight&&i.clientHeight<o?i:r},en=Object.freeze({scrollerOf:Qt,reveal:e=>{e.scrollIntoView(Se)}}),Se=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),tn=(e,t)=>{for(let n=t;n!==null&&n!==e;n=n.parentElement){const r=n.parentElement;if(r instanceof HTMLDetailsElement&&n!==r.querySelector(":scope > summary")&&(r.open=!0),n.getAttribute("hidden")?.toLowerCase()==="until-found"){if(n.dispatchEvent(new Event("beforematch",{bubbles:!0})),!n.isConnected)return;n.removeAttribute("hidden")}}},nn=(e,t)=>{if(t.getClientRects().length===0)return;const n=e===e.ownerDocument.scrollingElement?0:e.getBoundingClientRect().top+e.clientTop,{scrollMarginTop:r,scrollMarginBottom:o}=getComputedStyle(t),s=Number.parseFloat(r),i=t.getBoundingClientRect(),c=i.height+s+Number.parseFloat(o)>e.clientHeight;if(!c&&Math.abs(i.top-s-n)<1){t.scrollIntoView(Se);return}e.scrollBy({top:c?i.top-n-e.clientHeight:i.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(Se)},rn=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Me)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},qe=(e,t,n)=>{if(e===null)return null;const r=gt(e,t);return r===null?(Xt(t)&&rn(e,n),null):(tn(e,r),nn(n.scrollerOf(e,r),r),n.reveal(r),r)};function on({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{d:"M3.28 2.22a.75.75 0 0 0-1.06 1.06L5.44 6.5H2.75a.75.75 0 0 0 0 1.5h4.5A.75.75 0 0 0 8 7.25v-4.5a.75.75 0 0 0-1.5 0v2.69L3.28 2.22ZM13.5 2.75a.75.75 0 0 0-1.5 0v4.5c0 .414.336.75.75.75h4.5a.75.75 0 0 0 0-1.5h-2.69l3.22-3.22a.75.75 0 0 0-1.06-1.06L13.5 5.44V2.75ZM3.28 17.78l3.22-3.22v2.69a.75.75 0 0 0 1.5 0v-4.5a.75.75 0 0 0-.75-.75h-4.5a.75.75 0 0 0 0 1.5h2.69l-3.22 3.22a.75.75 0 1 0 1.06 1.06ZM13.5 14.56l3.22 3.22a.75.75 0 1 0 1.06-1.06l-3.22-3.22h2.69a.75.75 0 0 0 0-1.5h-4.5a.75.75 0 0 0-.75.75v4.5a.75.75 0 0 0 1.5 0v-2.69Z"}))}const sn=R.forwardRef(on);function ln({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{d:"M6.75 8.25a.75.75 0 0 0 0 1.5h4.5a.75.75 0 0 0 0-1.5h-4.5Z"}),R.createElement("path",{fillRule:"evenodd",d:"M9 2a7 7 0 1 0 4.391 12.452l3.329 3.328a.75.75 0 1 0 1.06-1.06l-3.328-3.329A7 7 0 0 0 9 2ZM3.5 9a5.5 5.5 0 1 1 11 0 5.5 5.5 0 0 1-11 0Z",clipRule:"evenodd"}))}const an=R.forwardRef(ln);function cn({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{d:"M9 6a.75.75 0 0 1 .75.75v1.5h1.5a.75.75 0 0 1 0 1.5h-1.5v1.5a.75.75 0 0 1-1.5 0v-1.5h-1.5a.75.75 0 0 1 0-1.5h1.5v-1.5A.75.75 0 0 1 9 6Z"}),R.createElement("path",{fillRule:"evenodd",d:"M2 9a7 7 0 1 1 12.452 4.391l3.328 3.329a.75.75 0 1 1-1.06 1.06l-3.329-3.328A7 7 0 0 1 2 9Zm7-5.5a5.5 5.5 0 1 0 0 11 5.5 5.5 0 0 0 0-11Z",clipRule:"evenodd"}))}const dn=R.forwardRef(cn);function un({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M1 5.25A2.25 2.25 0 0 1 3.25 3h13.5A2.25 2.25 0 0 1 19 5.25v9.5A2.25 2.25 0 0 1 16.75 17H3.25A2.25 2.25 0 0 1 1 14.75v-9.5Zm1.5 5.81v3.69c0 .414.336.75.75.75h13.5a.75.75 0 0 0 .75-.75v-2.69l-2.22-2.219a.75.75 0 0 0-1.06 0l-1.91 1.909.47.47a.75.75 0 1 1-1.06 1.06L6.53 8.091a.75.75 0 0 0-1.06 0l-2.97 2.97ZM12 7a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z",clipRule:"evenodd"}))}const fn=R.forwardRef(un),ye="data-aqmx-key-repeat",Re=Object.freeze({[ye]:"allow"}),mn=`[${ye}="${Re[ye]}"]`,gn=()=>{let e=null;return{onKeyDownCapture:t=>{if(t.key==="Enter"){if(!t.repeat){e=t.target instanceof Element?t.target:null;return}e!==null&&t.target===e&&e.closest(mn)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},se=Object.freeze([1/$.GOLDEN_RATIO**2,1/$.GOLDEN_RATIO,1,$.GOLDEN_RATIO,$.GOLDEN_RATIO**2]),He=Object.freeze({mode:"fit"}),pn=1,pt=a.createContext(null),hn=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=pn?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,Be=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<se.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?se.findIndex(o=>o>t):se.findLastIndex(o=>o<t);return r===-1?null:r},ze=(e,t,n)=>{if(e.mode==="level"){const o=Be(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=Be(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},wn=e=>{const t=se[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},Ie=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},vn=({document:e})=>{const{labels:t}=D(),n=a.use(pt),[r]=a.useState(()=>n===null?null:n.read(e.url)),[o,s]=a.useState(r===null?He:r.zoom),[i,c]=a.useState(r===null?null:r.reported),[m,h]=a.useState(null),g=a.useRef(null),p=a.useCallback(O=>{const{naturalWidth:f,naturalHeight:w}=O;c(S=>Ie(S,f,w))},[]),x=a.useCallback(O=>{g.current=O,!(O===null||!O.complete)&&(O.naturalWidth>0||O.naturalHeight>0?p(O):O.decode().then(()=>p(O),()=>{}))},[p]);a.useEffect(()=>{n!==null&&i!==null&&n.save(e.url,{zoom:o,reported:i})},[n,e.url,o,i]),a.useLayoutEffect(()=>{const O=g.current;if(O===null||i===null||o.mode!=="fit")return;const f=()=>h(S=>Ie(S,O.clientWidth,O.clientHeight));if(f(),typeof ResizeObserver>"u")return;const w=new ResizeObserver(f);return w.observe(O),()=>w.disconnect()},[i,o.mode]);const T=i===null||m===null?null:hn(i,m),k=ze(o,T,-1),L=ze(o,T,1),A=o.mode==="level"?wn(o.index):null,P=o.mode==="level"&&A!==null?{width:`${o.base.width*A}px`,height:`${o.base.height*A}px`}:void 0;return d.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[d.jsxs(de,{name:e.name,url:e.url,icon:d.jsx(fn,{}),children:[d.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":k===null,onClick:()=>{k!==null&&s(k)},...Re,children:d.jsx(an,{})}),d.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:A===null?t.imageFitLevel:t.imageZoomLevel(Math.round(A*100))}),d.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":L===null,onClick:()=>{L!==null&&s(L)},...Re,children:d.jsx(dn,{})}),d.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(He),children:d.jsx(sn,{})})]}),d.jsx("div",{className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas",children:d.jsx("img",{ref:x,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:P,onLoad:O=>p(O.currentTarget),"data-testid":"markdown-explorer-image"})})]})},ht=a.createContext(null),ue=a.createContext(void 0),wt=a.createContext(null),fe=()=>{const e=a.use(ht);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},En=()=>{const e=a.use(wt);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},me=(e,t,n,r)=>t.kind==="panel"?$.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?$.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):$.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),xn=({children:e})=>{const{config:t}=D(),n=fe(),r=ae(),o=r.kind==="location"?r.location.source:void 0,s=U.useHref(me(t,n.navigation,o,n.currentPath));return d.jsx(ue,{value:o,children:d.jsx(wt,{value:s,children:e})})},bn='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Sn=e=>{const t=e instanceof Element?e.closest(bn):null;return t===null?null:t.getAttribute("data-doc-path")},ge=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,yn=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:i,scope:c,children:m})=>{const h=U.useHref(e),g=p=>{if(ge(p)){if(p.preventDefault(),t===c.currentPath&&n!==""){c.scrollWithin(n);return}i(t,n)}};return d.jsx("a",{...s,href:h,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:g,children:m})},Rn=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:i}=D(),c=fe(),m=a.use(ue),h=Kt(e),{navigation:g}=c,p=`${me(i,g,m,t)}${h}`,x=n===!1?"false":void 0;return g.kind==="page"?d.jsx(st,{...o,to:p,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":x,children:s}):d.jsx(yn,{to:p,docPath:t,fragment:h,exists:x,className:r,attributes:o,onDocumentLink:g.onDocumentLink,scope:c,children:s})},kn=({className:e,attributes:t,children:n})=>{const{labels:r}=D();return d.jsxs("a",{...t,className:e===void 0?"aqmx-document-inert-link":`${e} aqmx-document-inert-link`,title:r.inertLink,"data-link-kind":"doc","data-doc-exists":"false",children:[n,d.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},Tn=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=D(),i=a.use(ue),c=U.useHref(`${me(s,r.navigation,i,r.currentPath)}${e}`),m=h=>{ge(h)&&(h.preventDefault(),r.scrollWithin(e))};return d.jsx("a",{...n,href:c,className:t,onClick:m,children:o})},An=({href:e,className:t,attributes:n,children:r})=>{const o=fe();if(o.navigation.kind==="page"){const s=i=>{if(!ge(i))return;const c=i.currentTarget;e==="#"?o.followEmptyFragment(i.nativeEvent):c.href===c.ownerDocument.URL&&o.followSameUrlJump(e,i.nativeEvent)};return d.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return d.jsx(Tn,{href:e,className:t,attributes:n,scope:o,children:r})},Ln=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:i})=>t==="doc"?n===void 0||!z.isAcceptableDocumentPath(n)?d.jsx(kn,{className:o,attributes:s,children:i}):d.jsx(Rn,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:i}):e.startsWith("#")?d.jsx(An,{href:e,className:o,attributes:s,children:i}):d.jsx("a",{...s,href:e,className:o,children:i}),On=()=>{const{config:e}=D(),t=fe(),n=a.use(ue),r=ce();return a.useCallback((o,s)=>{if(!ge(s))return!0;s.preventDefault();const i=ft(o.id),{navigation:c}=t;return c.kind==="panel"||je(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(i),!0):(r(`${me(e,c,n,t.currentPath)}${i}`,"follow-link"),!0)},[e,t,n,r])},Cn=()=>{const e=En();return a.useCallback(t=>`${e}${ft(t.id)}`,[e])};function Mn({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{d:"M3 3.5A1.5 1.5 0 0 1 4.5 2h6.879a1.5 1.5 0 0 1 1.06.44l4.122 4.12A1.5 1.5 0 0 1 17 7.622V16.5a1.5 1.5 0 0 1-1.5 1.5h-11A1.5 1.5 0 0 1 3 16.5v-13Z"}))}const jn=R.forwardRef(Mn);function Nn({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M1 4.75C1 3.784 1.784 3 2.75 3h14.5c.966 0 1.75.784 1.75 1.75v10.515a1.75 1.75 0 0 1-1.75 1.75h-1.5c-.078 0-.155-.005-.23-.015H4.48c-.075.01-.152.015-.23.015h-1.5A1.75 1.75 0 0 1 1 15.265V4.75Zm16.5 7.385V11.01a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25Zm0 2.005a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .108.069.2.165.235h1.585a.25.25 0 0 0 .25-.25v-1.11Zm-15 1.11v-1.11a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.164.235H2.75a.25.25 0 0 1-.25-.25Zm2-4.24v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V11.01a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25Zm13-2.005V7.88a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25v1.125c0 .138.112.25.25.25h1.5a.25.25 0 0 0 .25-.25ZM4.25 7.63a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V7.88a.25.25 0 0 1 .25-.25h1.5Zm0-3.13a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5Zm11.5 1.625a.25.25 0 0 1-.25-.25V4.75a.25.25 0 0 1 .25-.25h1.5a.25.25 0 0 1 .25.25v1.125a.25.25 0 0 1-.25.25h-1.5Zm-9 3.125a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5Z",clipRule:"evenodd"}))}const Dn=R.forwardRef(Nn);function Pn({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M17.721 1.599a.75.75 0 0 1 .279.583v11.29a2.25 2.25 0 0 1-1.774 2.2l-2.041.44a2.216 2.216 0 0 1-.938-4.332l2.662-.577a.75.75 0 0 0 .591-.733V6.112l-8 1.73v7.684a2.25 2.25 0 0 1-1.774 2.2l-2.042.44a2.216 2.216 0 1 1-.935-4.331l2.659-.573A.75.75 0 0 0 7 12.529V4.236a.75.75 0 0 1 .591-.733l9.5-2.054a.75.75 0 0 1 .63.15Z",clipRule:"evenodd"}))}const $n=R.forwardRef(Pn),Fn=e=>{switch(e){case"video":return d.jsx(Dn,{});case"audio":return d.jsx($n,{});case"pdf":return d.jsx(jn,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},_n=({document:e})=>{const{labels:t}=D();switch(e.mediaType){case"video":return d.jsx("video",{className:"aqmx-document-video",src:e.url,controls:!0,preload:"metadata","aria-label":e.name,"data-testid":"markdown-explorer-media-player",children:t.mediaUnsupported});case"audio":return d.jsx("audio",{className:"aqmx-document-audio",src:e.url,controls:!0,preload:"metadata","aria-label":e.name,"data-testid":"markdown-explorer-media-player",children:t.mediaUnsupported});case"pdf":return d.jsx("iframe",{className:"aqmx-document-frame",src:e.url,title:e.name,"data-testid":"markdown-explorer-media-player"});default:{const n=e.mediaType;throw new RangeError(`[markdown-explorer] unknown media type ${String(n)}`)}}},qn=({document:e})=>d.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[d.jsx(de,{name:e.name,url:e.url,icon:Fn(e.mediaType)}),d.jsx("div",{className:"aqmx-document-stage",children:d.jsx(_n,{document:e})})]}),Hn=e=>({loading:e.viewerLoading,errorPrefix:e.viewerErrorPrefix,styleTitle:e.viewerStyleTitle,selectStyleAria:e.viewerSelectStyle,pinStyleAria:e.viewerPinStyle,unpinStyleAria:e.viewerUnpinStyle,defaultErrorTitle:e.viewerErrorTitle,missingImage:e.viewerMissingImage,openTocAria:e.viewerOpenToc,tocTitle:e.viewerTocTitle,pinTocAria:e.viewerPinToc,unpinTocAria:e.viewerUnpinToc,selectAlignAria:e.viewerSelectAlign,alignTitle:e.viewerAlignTitle,pinAlignAria:e.viewerPinAlign,unpinAlignAria:e.viewerUnpinAlign,alignLeft:e.viewerAlignLeft,alignCenter:e.viewerAlignCenter,alignRight:e.viewerAlignRight,mermaidInteractionMode:e.viewerMermaidInteractionMode,mermaidModeNone:e.viewerMermaidModeNone,mermaidModeZoom:e.viewerMermaidModeZoom,mermaidModePan:e.viewerMermaidModePan,mermaidModePanShift:e.viewerMermaidModePanShift,mermaidModeBoth:e.viewerMermaidModeBoth,mermaidModeBothShift:e.viewerMermaidModeBothShift,mermaidZoomIn:e.viewerMermaidZoomIn,mermaidZoomOut:e.viewerMermaidZoomOut,mermaidResetView:e.viewerMermaidResetView,mermaidRetry:e.viewerMermaidRetry,embeddedVideo:e.viewerEmbeddedVideo,embeddedPost:e.viewerEmbeddedPost,embeddedFrame:e.viewerEmbeddedFrame}),vt=(e,t,n)=>{if(t!==void 0)return t;if(n!==void 0)return n;const[r]=e.documentStyles;if(r===void 0)throw new Error("[markdown-explorer] the configuration has no document style");return r.name},Et=(e,t)=>e!==void 0?e:t!==void 0?t:Lt.DEFAULT_CONTENT_ALIGN,Bn=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),zn=(e,t,n)=>{if(t.view==="multi"||t.overrides[n]===void 0)return null;const r=n==="style"?{align:t.overrides.align}:{style:t.overrides.style};return t.view==="single"?$.explorerHref(e,{view:"single",source:t.source,doc:t.doc,overrides:r,embed:t.embed}):$.explorerHref(e,{view:"tree",source:t.source,doc:t.doc,overrides:r})},ke=a.createContext("fill"),Ne=({kind:e,label:t,stale:n,busy:r,frameRef:o,intent:s,children:i})=>{const c=a.use(ke);return d.jsxs("section",{ref:o,role:"region","aria-label":t,"aria-busy":r,"data-testid":"markdown-explorer-document","data-aqmx-document-kind":e,"data-aqmx-document-flow":c,className:"aqmx-document",...s,children:[n?d.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,i]})},In=()=>{const{labels:e}=D();return d.jsx(Ne,{kind:"empty",label:e.documentRegion,stale:!1,busy:!1,children:d.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:d.jsx("p",{className:"aqmx-empty-title",children:e.documentEmpty})})})},xt=({label:e})=>{const{labels:t}=D();return d.jsxs(Ne,{kind:"loading",label:e,stale:!1,busy:!0,children:[d.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-document-skeleton",children:Bn.map(n=>d.jsx("span",{},n))}),d.jsx("p",{className:"aqmx-sr-only",children:t.documentLoading})]})},Un=({path:e,document:t,viewer:n})=>{const{reportMathDiagnostics:r}=D(),o=a.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),s=On(),i=Cn(),c=a.useMemo(()=>r===void 0?void 0:m=>r(e,m),[r,e]);return d.jsx("div",{className:"aqmx-document-viewer",children:d.jsx(Ae.MarkdownViewer,{...n,onHeadingSelect:s,headingHref:i,onMathDiagnostics:c,parseResult:o,content:null})})},Zn=({document:e,viewer:t})=>{const{labels:n}=D();return d.jsxs(d.Fragment,{children:[d.jsx(de,{name:e.name,url:e.url,icon:d.jsx(Ft,{})}),e.truncated?d.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,d.jsx("div",{className:"aqmx-document-viewer",children:d.jsx(Ae.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},Vn=({path:e,document:t,viewer:n,onRetry:r})=>{switch(t.kind){case"markdown":return d.jsx(Un,{path:e,document:t,viewer:n});case"text":return d.jsx(Zn,{document:t,viewer:n});case"image":return d.jsx(vn,{document:t});case"media":return d.jsx(qn,{document:t});case"file":return d.jsx(Wt,{document:t});case"failure":return d.jsx("div",{className:"aqmx-document-failure","data-aqmx-document-scroller":"",children:d.jsx(it,{failure:t.failure,alert:!1,onRetry:r,testId:"markdown-explorer-document-failure"})});default:{const o=t;throw new RangeError(`[markdown-explorer] unknown document kind in ${JSON.stringify(o)}`)}}},Wn='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',Kn=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:gt(e,n),r===void 0?null:mt(e,r.id),e.querySelector(Me),e.querySelector(Wn)];for(const s of o)if(s instanceof HTMLElement&&Ce(s))return s;return null},Ue=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&Ce(t)},Gn=e=>{const t=a.useRef(!1);return a.useLayoutEffect(()=>{const n=e.current;if(n===null)throw new Error("[markdown-explorer] the document region is not mounted");const r=n.ownerDocument,o=r.defaultView;if(o===null)throw new Error("[markdown-explorer] the document region's document has no window");let s=!1,i;const c=x=>{s=!(x.target instanceof Node&&n.contains(x.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(i),i=setTimeout(()=>{s=!1},0)},m=x=>{t.current=x.target instanceof Node&&n.contains(x.target)},h=x=>{x.relatedTarget===null&&s&&(t.current=!1)},g=()=>{const{activeElement:x,body:T}=r;x!==null&&x!==T&&(t.current=n.contains(x))},p=()=>{s&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",c,!0),o.addEventListener("mousedown",c,!0),o.addEventListener("focusin",m,!0),o.addEventListener("blur",g),o.addEventListener("focus",p),n.addEventListener("focusout",h),()=>{clearTimeout(i),o.removeEventListener("pointerdown",c,!0),o.removeEventListener("mousedown",c,!0),o.removeEventListener("focusin",m,!0),o.removeEventListener("blur",g),o.removeEventListener("focus",p),n.removeEventListener("focusout",h)}},[e]),t},Xn=({path:e,snapshot:t,stale:n,viewer:r,regionLabel:o,navigation:s,fragment:i,paneScroll:c,announces:m,announceFailure:h,onDocumentShown:g})=>{const{labels:p,announcer:x,documents:T}=D(),{document:k}=t,L=a.useRef(null),A=a.useRef(null),P=a.useRef(null),O=a.useRef(0),f=Gn(L),w=a.useRef({path:e,document:k}),S=a.useRef(null),b=a.useCallback(l=>{const u=L.current,v=qe(u,l,c);u!==null&&v!==null&&Ue(u,v,f.current)},[c,f]),y=a.useCallback((l,u)=>{const v=O.current;setTimeout(()=>{!u.defaultPrevented&&O.current===v&&b(l)},0)},[b]),F=a.useCallback(l=>{setTimeout(()=>{l.defaultPrevented||b("#")},0)},[b]),I=a.useMemo(()=>({navigation:s,currentPath:e,scrollWithin:b,followSameUrlJump:y,followEmptyFragment:F}),[s,e,b,y,F]),M=a.useCallback(()=>T.retry(e),[T,e]),H=at(T,Sn),j=a.useEffectEvent((l,u)=>{const v=A.current;if(v!==null&&v.path===l&&v.snapshot===u)return;A.current={path:l,snapshot:u};const E=u.document;if(E.kind==="failure"){T.noteFailureShown(u)&&h(p.documentFailed(z.lastPathSegment(l),ee(p,E.failure.reason)));return}g?.(l,E),m&&(v===null||v.path!==l||v.snapshot.document.kind==="failure")&&x.announce(p.documentShown(E.name))});a.useEffect(()=>{j(e,t)},[e,t]);const _=a.useEffectEvent(()=>{i.kind==="panel"&&i.consume()}),G=a.useEffectEvent(l=>{const u=L.current;if(u===null||!f.current)return null;const{activeElement:v,body:E}=u.ownerDocument;return v!==null&&v!==E?null:Kn(u,k,l)}),Y=a.useEffectEvent(l=>{const u=L.current;u!==null&&Ue(u,l,f.current)}),Z=a.useEffectEvent(l=>c.reveal(l)),pe=a.useEffectEvent(l=>qe(L.current,l,c));return a.useEffect(()=>{if(n)return;const l=w.current.path!==e,u=l||w.current.document!==k;w.current={path:e,document:k};const v=S.current!==e;S.current=e;let E=null;i.kind==="page"?P.current!==i.navigation&&(P.current=i.navigation,O.current+=1,E=i.fragment):i.fragment!==null&&(E=i.fragment,_());const C=()=>{const N=E===null?null:pe(E);if(!u){N!==null&&Y(N);return}const q=G(i.fragment);l&&N===null&&q!==null&&Z(q)};v?queueMicrotask(C):C()},[i,e,k,n]),d.jsx(Ne,{kind:k.kind,label:o(e,k),stale:n,busy:n,frameRef:L,intent:H,children:d.jsx(ht,{value:I,children:d.jsx(xn,{children:d.jsx(Vn,{path:e,document:k,viewer:r,onRetry:M},e)})})})},De=Object.freeze({kind:"skeleton"}),Yn=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=ie(t);if(s!==null)return{kind:"document",path:e,snapshot:s,stale:!0};if(o&&t?.status==="pending")return{kind:"streaming",path:e,promise:t.promise};const i=n===null||n===e?null:ie(r);return n===null||i===null?De:{kind:"document",path:n,snapshot:i,stale:!0}},Jn=(e,t)=>t.status==="deferred"?De:{kind:"document",path:e,snapshot:t,stale:!1},Qn=({requestedPath:e,content:t,...n})=>{const r=t.kind==="streaming"?Jn(t.path,a.use(t.promise)):t;return r.kind!=="document"?d.jsx(xt,{label:n.regionLabel(e,null)}):d.jsx(Xn,{path:r.path,snapshot:r.snapshot,stale:r.stale,...n})},bt=({path:e,display:t,navigation:n,fragment:r,paneScroll:o,announces:s,announceFailure:i,onDocumentShown:c})=>{const{config:m,labels:h,theme:g,documents:p}=D(),x=Ae.useMarkdownToolbarState(),T=a.useRef(!1);a.useLayoutEffect(()=>{T.current=!0},[]);const[k,L]=a.useState(null),A=a.useCallback(()=>e===null?void 0:p.peek(e),[p,e]),P=a.useSyncExternalStore(p.subscribe,A,A),O=a.useCallback(()=>k===null?void 0:p.peek(k),[p,k]),f=a.useSyncExternalStore(p.subscribe,O,O);a.useLayoutEffect(()=>e===null?void 0:p.open(e),[p,e]),a.useLayoutEffect(()=>k===null?void 0:p.retain(k),[p,k]);const w=e===null?De:Yn(e,P,k,f,!T.current),S=e===null?null:w.kind==="document"&&!w.stale?w.path:k;S!==k&&L(S);const b=a.useMemo(()=>Hn(h),[h]),y=a.useMemo(()=>[...m.iframeHosts],[m]),F=a.useMemo(()=>({labels:b,emptyMessage:h.documentEmpty,theme:g,availableStyles:m.documentStyles,iFrameAllowedDomains:y,embeds:m.embeds,linkComponent:Ln,toolbar:x,style:t.style,onStyleChange:t.onStyleChange,align:t.align,onAlignChange:t.onAlignChange,showToc:t.showToc,showStyle:t.showStyle,showAlign:t.showAlign,padding:t.padding,width:t.width===void 0?void 0:`min(${t.width}, 100%)`,maxWidth:t.maxWidth===void 0?void 0:`min(${t.maxWidth}, 100%)`}),[b,h.documentEmpty,g,m.documentStyles,y,m.embeds,x,t]),I=n.kind==="panel",M=a.useCallback((j,_)=>I?_===null||_.kind==="failure"?z.lastPathSegment(j):_.name:h.documentRegion,[I,h.documentRegion]),H=I?"content":"fill";return e===null?d.jsx(ke,{value:H,children:d.jsx(In,{})}):d.jsx(ke,{value:H,children:d.jsx(a.Suspense,{fallback:d.jsx(xt,{label:M(e,null)}),children:d.jsx(Qn,{requestedPath:e,content:w,viewer:F,regionLabel:M,navigation:n,fragment:r,paneScroll:o,announces:s,announceFailure:i,onDocumentShown:c})})})},er=({path:e,variant:t,onDocumentShown:n})=>{const{config:r,viewSettings:o,announcer:s}=D(),i=J(y=>y.style),c=J(y=>y.align),m=ce(),h=U.useLocation(),g=ae(),{view:p,overrides:x,embed:T}=t,k=a.useCallback(y=>{if(g.kind!=="location")return;const F=zn(r,g.location,y);F!==null&&m(F,"browse")},[r,m,g]),L=a.useCallback(y=>{o.update({style:y}),k("style")},[o,k]),A=a.useCallback(y=>{o.update({align:y}),k("align")},[o,k]),P=vt(r,x.style,i),O=Et(x.align,c),f=a.useMemo(()=>({style:P,onStyleChange:L,align:O,onAlignChange:A,showToc:T.showToc!==!1,showStyle:T.showStyle!==!1,showAlign:T.showAlign!==!1,padding:T.padding,width:T.width,maxWidth:T.maxWidth}),[P,L,O,A,T]),w=a.useMemo(()=>({kind:"page",view:p,overrides:x,embed:T}),[p,x,T]),S=a.useMemo(()=>({kind:"page",fragment:h.hash,navigation:h}),[h]),b=a.useCallback(y=>s.announce(y),[s]);return d.jsx(bt,{path:e,display:f,navigation:w,fragment:S,paneScroll:en,announces:!0,announceFailure:b,onDocumentShown:n})},tr=({path:e,variant:t,onDocumentShown:n})=>{const{config:r,viewSettings:o}=D(),s=J(w=>w.style),i=J(w=>w.align),[c,m]=a.useState(()=>vt(r,void 0,s)),h=Et(void 0,i),g=a.useCallback(w=>o.update({align:w}),[o]),{maximized:p,onDocumentLink:x,pendingHash:T,onHashConsumed:k,announceFailure:L,paneScroll:A}=t,P=a.useMemo(()=>({style:c,onStyleChange:m,align:h,onAlignChange:g,showToc:p,showStyle:p,showAlign:p,padding:void 0,width:void 0,maxWidth:void 0}),[c,h,g,p]),O=a.useMemo(()=>({kind:"panel",onDocumentLink:x}),[x]),f=a.useMemo(()=>({kind:"panel",fragment:T,consume:k}),[T,k]);return d.jsx(bt,{path:e,display:P,navigation:O,fragment:f,paneScroll:A,announces:!1,announceFailure:L,onDocumentShown:n})},St=({path:e,variant:t,onDocumentShown:n})=>t.kind==="page"?d.jsx(er,{path:e,variant:t,onDocumentShown:n}):d.jsx(tr,{path:e,variant:t,onDocumentShown:n});function nr({title:e,titleId:t,...n},r){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true","data-slot":"icon",ref:r,"aria-labelledby":t},n),e?R.createElement("title",{id:t},e):null,R.createElement("path",{fillRule:"evenodd",d:"M4.755 10.059a7.5 7.5 0 0 1 12.548-3.364l1.903 1.903h-3.183a.75.75 0 1 0 0 1.5h4.992a.75.75 0 0 0 .75-.75V4.356a.75.75 0 0 0-1.5 0v3.18l-1.9-1.9A9 9 0 0 0 3.306 9.67a.75.75 0 1 0 1.45.388Zm15.408 3.352a.75.75 0 0 0-.919.53 7.5 7.5 0 0 1-12.548 3.364l-1.902-1.903h3.183a.75.75 0 0 0 0-1.5H2.984a.75.75 0 0 0-.75.75v4.992a.75.75 0 0 0 1.5 0v-3.18l1.9 1.9a9 9 0 0 0 15.059-4.035.75.75 0 0 0-.53-.918Z",clipRule:"evenodd"}))}const yt=R.forwardRef(nr),rr=new Set,or=(e,t)=>{const{documents:n,announcer:r,labels:o}=D(),s=a.useCallback(()=>n.peek(e),[n,e]),i=a.useCallback(()=>n.peekSeeded(e),[n,e]),c=a.useSyncExternalStore(n.subscribe,s,i),m=a.useCallback(()=>n.answerStampOf(e),[n,e]),h=a.useSyncExternalStore(n.subscribe,m,m),[g]=a.useState(()=>new Set),[p,x]=a.useState(rr),[T,k]=a.useState(null);T!==null&&T.path!==e&&k(null);const L=a.useRef(null);a.useLayoutEffect(()=>(L.current=e,()=>{L.current=null}),[e]);const A=a.useCallback(()=>{const f=e,w=n.peek(f);if(g.has(f)||w?.status==="pending")return;const S=t&&!ut(w);g.add(f),x(new Set(g)),k(null),(async()=>{try{const b=await n.refresh(f);if(L.current!==f||b.status==="superseded")return;if(b.status==="failed"){k({path:f,failure:b.failure,stamp:n.answerStampOf(f)}),r.announce(o.documentRefreshFailed(ee(o,b.failure.reason)));return}const y=ie(n.peek(f));if(S||y===null||y.document.kind==="failure")return;r.announce(o.documentRefreshed(y.document.name))}finally{g.delete(f),x(new Set(g))}})()},[e,t,g,n,r,o]),P=p.has(e),O=T!==null&&T.path===e&&T.stamp===h?T.failure:null;return{refreshing:P,unavailable:P||c?.status==="pending",failure:O,refresh:A}},Rt=Object.freeze({kind:"page"}),sr=e=>{e.stopPropagation()},kt=({path:e,placement:t})=>{const{labels:n}=D(),{refreshing:r,unavailable:o,failure:s,refresh:i}=or(e,t.kind==="page"),c=t.kind==="panel"?n.refreshDocumentNamed(t.documentName):null;return d.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar",children:[d.jsx("div",{className:"aqmx-document-refresh-row",children:d.jsxs("button",{type:"button",className:c===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:c===null?n.refreshDocument:c,"aria-label":c===null?void 0:c,"aria-disabled":o,"aria-busy":r,"data-aqmx-busy":r?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:i,onDoubleClick:sr,children:[d.jsx(yt,{"aria-hidden":"true"}),c===null?d.jsx("span",{children:n.refreshDocumentLabel}):null]})}),s===null?null:d.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":s.reason,children:n.documentRefreshFailed(ee(n,s.reason))})]})},lr=({location:e})=>{const t=e.doc,n=a.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]);return d.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",children:[d.jsx(kt,{path:t,placement:Rt}),d.jsx(St,{path:t,variant:n})]})},Tt=({holds:e,testId:t})=>{const{labels:n,announcer:r}=D(),o=a.useId();a.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=a.useCallback(()=>r.shownIn(o),[r,o]),i=a.useSyncExternalStore(r.subscribe,s,s);return d.jsx("div",{className:"aqmx-sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":t,children:i.length>1?n.announcementSequence(i):i[0]})},X=Object.freeze([]),Ze=e=>{const t=new Set;let n=X,r=[],o=!1;const s=[],i=g=>{n=g;for(const p of[...t])p()},c=()=>s.at(-1)?.region,m=g=>{const p=c();g(),c()!==p&&n!==X&&i(X)},h=()=>{o=!1;const g=r.map(p=>"sentence"in p?p.sentence:p.list(p.items));r=[],i(Object.freeze(g))};return{announce:g=>{if(typeof g=="string")r.push({sentence:g});else{const p=r.find(x=>"list"in x&&x.list===g.list);p!==void 0&&"items"in p?p.items.push(g.item):r.push({list:g.list,items:[g.item]})}o||(o=!0,n!==X&&i(X),e.request(h))},subscribe:g=>(t.add(g),()=>{t.delete(g)}),claim:g=>{const p={region:g};return m(()=>s.push(p)),()=>m(()=>{const x=s.indexOf(p);x!==-1&&s.splice(x,1)})},shownIn:g=>c()===g?n:X}},ir=Object.freeze({status:"cancelled"}),ar=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(z.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return z.failureOf(n,r)},cr=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((c,m)=>globalThis.fetch(c,m)),o=(c,m)=>`${e}/${c}?${new URLSearchParams(m).toString()}`,s=async(c,m,h,g)=>{let p;try{p=await r(c,{credentials:"same-origin",...m,headers:{Accept:"application/json",...m.headers}})}catch{return g({reason:"failed"})}p.status===401&&t(null);const x=p.headers.get(z.EXPLORER_SCOPE_HEADER);x!==null&&t(x);let T;try{T=await p.json()}catch{return g({reason:z.failureReasonOfStatus(p.status)})}let k;try{k=h(T)}catch{k=!1}if(k)return T;const L=ar(T);return g(L!==null?L:{reason:p.status===200?"failed":z.failureReasonOfStatus(p.status)})},i={[z.EXPLORER_REFRESH_HEADER]:z.EXPLORER_REFRESH_HEADER_VALUE};return{tree:c=>s(o("tree",{[z.EXPLORER_DATA_QUERY.source]:c}),{method:"GET"},z.isExplorerTreeResult,m=>({status:"error",failure:m})),children:async(c,m,h)=>{const g=await s(o("children",{[z.EXPLORER_DATA_QUERY.source]:c,[z.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:h},z.isExplorerChildrenResult,p=>({status:"error",failure:p}));return h.aborted?ir:g},document:(c,{refresh:m})=>s(o("document",{[z.EXPLORER_DATA_QUERY.path]:c}),m?{method:"GET",headers:i}:{method:"GET"},z.isExplorerDocument,h=>z.failureDocument(h.reason,h.code)),refresh:c=>s(o("refresh",{[z.EXPLORER_DATA_QUERY.source]:c}),{method:"POST",headers:i},z.isExplorerTreeResult,m=>({status:"error",failure:m}))}},dr=e=>{const t=K.readStorage(e);if(t===null)return $.NO_TREE_SETTING_CHANGES;try{return $.readTreeSettingChanges(JSON.parse(t))}catch(n){return console.warn(`[markdown-explorer] localStorage key ${JSON.stringify(e)} does not hold JSON; using the default tree settings.`,n),$.NO_TREE_SETTING_CHANGES}},Ve=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=dr(e);n={changes:s,settings:$.applyTreeSettingChanges(t,s)}}return n},o=te();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:i,settings:c}=r(),m=$.recordTreeSettingChange(i,s,$.advanceTreeSetting(c,s)[s],t);return n={changes:m,settings:$.applyTreeSettingChanges(t,m)},o.emit(),K.writeStorage(e,$.serializeTreeSettingChanges(m)),n.settings}}},ur=Object.freeze({status:"refreshed"}),fr=Object.freeze({status:"superseded"}),Te=Object.freeze({status:"deferred"}),mr=dt(Te),At=4,gr=At-1,We=Object.freeze({status:"loading"}),pr=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),hr=e=>{const t=new Map,n=ct(),r=new Map,o=new Map,s=new Map,i=new Map,c=te(),m=new Set;let h=0,g=0;const p={direct:null,bulk:null},x=new Set;let T=!1,k=0;const L=()=>{k+=1,c.emit()},A=l=>o.get(l)??0,P=l=>{let u=i.get(l);return u===void 0&&(u={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},i.set(l,u)),u},O=(l,u,v)=>{l.inFlight.delete(u),h-=1,v.lane==="bulk"&&(g-=1)},f=l=>{const u=i.get(l);if(u!==void 0){for(const[v,E]of[...u.inFlight])O(u,v,E),E.controller.abort();u.direct.clear(),u.bulk.clear(),u.unclaimed.clear()}},w=l=>{const u=A(l)+1;return o.set(l,u),f(l),u},S=(l,u)=>{const v=ne(l),E={promise:l,opened:u,stale:!1,loadedAt:v?.status==="ok"?v.loadedAt:null};return l.status==="pending"&&l.then(C=>{C.status==="ok"&&(E.loadedAt=C.loadedAt)}),E},b=l=>{let u=r.get(l);return u===void 0&&(u=new Map,r.set(l,u)),u},y=l=>{const u=[...i.keys()],v=p[l],E=v===null?0:u.indexOf(v)+1;for(let C=0;C<u.length;C+=1){const N=u[(E+C)%u.length],q=N===void 0?void 0:i.get(N);if(!(N===void 0||q===void 0)){for(const B of q[l])if((q.claims.get(B)??0)!==0)return q[l].delete(B),p[l]=N,{sourceId:N,path:B}}}return null},F=(l,u,v,E)=>{const C=i.get(l);if(C===void 0||C.inFlight.get(u)!==v)return;O(C,u,v);const N=(C.claims.get(u)??0)>0,q=b(l);if(E.status==="ok"?q.set(u,{status:"loaded",entries:E.entries}):E.status==="error"&&N?q.set(u,{status:"failed",failure:E.failure}):q.delete(u),L(),E.status==="error"&&N){const B={sourceId:l,path:u,failure:E.failure};for(const V of[...m])V(B)}M()},I=(l,u,v)=>{const E={controller:new AbortController,lane:v};P(l).inFlight.set(u,E),h+=1,v==="bulk"&&(g+=1),e.children(l,u,E.controller.signal).then(C=>F(l,u,E,C),()=>F(l,u,E,pr))},M=()=>{for(;h<At;){const l=y("direct");if(l!==null){I(l.sourceId,l.path,"direct");continue}const u=g<gr?y("bulk"):null;if(u===null)return;I(u.sourceId,u.path,"bulk")}},H=(l,u,v)=>{if(!(u.direct.delete(v)||u.bulk.delete(v))){const C=u.inFlight.get(v);if(C===void 0)return!1;O(u,v,C),C.controller.abort()}return r.get(l)?.delete(v),!0},j=()=>{T=!1;let l=!1;for(const u of x){const v=P(u);for(const E of v.unclaimed)(v.claims.get(E)??0)===0&&H(u,v,E)&&(l=!0);v.unclaimed.clear()}x.clear(),l&&(L(),M())},_=(l,u)=>{t.set(l,S(Q(e.tree(l)),u))},G=(l,u,v)=>{w(l);const E=S(dt(u),v);return t.set(l,E),r.delete(l),L(),M(),E},Y=(l,u,v,E)=>{if(v!==A(l)||t.get(l)!==u)return;const C=ne(u.promise);if(!(E.status!=="ok"||C?.status!=="ok"||u.loadedAt===null||E.loadedAt<=u.loadedAt)){if(le(C.entries,E.entries)){u.loadedAt=E.loadedAt;return}G(l,E,u.opened)}},Z=(l,u)=>{const v=t.get(l);return v!==void 0&&ne(v.promise)?.status===u},pe=(l,u)=>{u.stale=!1;const v=A(l);e.tree(l).then(E=>Y(l,u,v,E))};return{read:l=>t.get(l)?.promise??mr,open:l=>{const u=n.resumes(l),v=n.hold(l),E=t.get(l);return E===void 0||Z(l,"deferred")?(_(l,!0),L()):u||(E.opened&&Z(l,"error")?(_(l,!0),L()):(E.opened=!0,E.stale&&Z(l,"ok")&&pe(l,E))),v},retry:l=>{Z(l,"error")&&(_(l,!0),L())},seed:(l,u)=>{const v=u.then(N=>N===null?Te:N,()=>Te),E=t.get(l);if(E!==void 0&&Z(l,"ok")){const N=A(l);v.then(q=>Y(l,E,N,q));return}w(l);const C=S(Q(v),E?.opened===!0);t.set(l,C),r.delete(l),M(),v.then(N=>{t.get(l)===C&&(N.status==="deferred"&&n.isHeld(l)&&_(l,C.opened),L())})},refresh:async l=>{const u=(s.get(l)??0)+1;s.set(l,u);const v=await e.refresh(l);if(s.get(l)!==u)return fr;if(v.status==="error")return{status:"failed",failure:v.failure};const E=t.get(l);if(!(E!==void 0&&E.loadedAt!==null&&Z(l,"ok")&&E.loadedAt>v.loadedAt)){const N=G(l,v,!0);if(E!==void 0&&E.promise.status==="pending"){const q=A(l);E.promise.then(B=>Y(l,N,q,B))}}for(const[N,q]of t)N!==l&&ne(q.promise)?.status==="ok"&&(q.stale=!0);return ur},children:(l,u)=>r.get(l)?.get(u),claimChildren:(l,u)=>{const v=P(l),E=b(l);let C=!1,N=!1;for(const[B,V]of u)v.claims.set(B,(v.claims.get(B)??0)+1),E.get(B)===void 0?(E.set(B,We),v[V].add(B),C=!0,N=!0):V==="direct"&&v.bulk.delete(B)&&(v.direct.add(B),N=!0);C&&L(),N&&M();let q=!1;return()=>{if(!q){q=!0;for(const B of u.keys()){const V=(v.claims.get(B)??0)-1;V>0?v.claims.set(B,V):(v.claims.delete(B),v.unclaimed.add(B))}x.add(l),!T&&(T=!0,queueMicrotask(j))}}},retryChildren:(l,u)=>{const v=r.get(l);if(v===void 0||v.get(u)?.status!=="failed")return;const E=P(l);if((E.claims.get(u)??0)>0){v.set(u,We),E.direct.add(u),L(),M();return}v.delete(u),L()},pendingChildren:l=>{const u=i.get(l);return u===void 0?0:u.direct.size+u.bulk.size+u.inFlight.size},clear:()=>{for(const l of new Set([...t.keys(),...r.keys(),...o.keys(),...i.keys()]))w(l);for(const[l,u]of s)s.set(l,u+1);t.clear(),r.clear(),L()},subscribeChildrenFailures:l=>(m.add(l),()=>{m.delete(l)}),subscribe:c.subscribe,version:()=>k}},wr=(e,t)=>{let n=e;const r=te();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},vr=1;let re=0,W=null;const Er=()=>{const{documentElement:e,body:t}=document;re===0&&(W={htmlOverflow:e.style.overflow,bodyOverflow:t.style.overflow,htmlGutter:e.style.scrollbarGutter,bodyGutter:t.style.scrollbarGutter},e.style.overflow="hidden",t.style.overflow="hidden",e.style.scrollbarGutter="auto",t.style.scrollbarGutter="auto"),re+=1;let n=!1;return()=>{n||(n=!0,re-=1,!(re>0||W===null)&&(e.style.overflow=W.htmlOverflow,t.style.overflow=W.bodyOverflow,e.style.scrollbarGutter=W.htmlGutter,t.style.scrollbarGutter=W.bodyGutter,W=null))}},xr=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],Ke=1,Ge=e=>e.getClientRects().length>0,we="Give the explorer's container a definite block size (for example height: 100dvh, or a flex column of definite height whose item has flex: 1 and min-height: 0; in a fresh React Router app also html and body at height: 100%) instead of an auto or only a minimum height.",br=e=>{if(!Ge(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+vr)return`[markdown-explorer] the explorer ends ${String(Math.round(t.bottom))}px down a ${String(n)}px viewport while lockDocumentScroll stops the page from scrolling, so the rest cannot be reached. ${we}`;if(t.height<Ke)return`[markdown-explorer] the explorer collapsed to ${String(Math.round(t.height))}px while lockDocumentScroll stops the page from scrolling, so nothing can be read. ${we}`;for(const{selector:r,name:o}of xr)for(const s of e.querySelectorAll(r)){if(!Ge(s))continue;const i=s.getBoundingClientRect().height;if(i<Ke)return`[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(i))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${we}`}return null},Sr=e=>{let t=!1;const n=()=>{if(t)return;const o=br(e);o!==null&&(t=!0,console.error(o))},r=typeof ResizeObserver>"u"?null:new ResizeObserver(n);return r?.observe(e),window.addEventListener("resize",n),n(),()=>{r?.disconnect(),window.removeEventListener("resize",n)}},yr=(e,t)=>{a.useEffect(()=>e?Er():void 0,[e]),a.useEffect(()=>{const n=t.current;if(!(!e||n===null))return Sr(n)},[e,t])},Xe='[data-testid="markdown-explorer-view-switch"]',Rr=[{control:Xe,successors:[Xe,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],kr=e=>{for(const t of Rr){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},Tr=(e,t)=>{const n=a.useRef(null);a.useEffect(()=>{const o=c=>{const m=e.current;n.current=m!==null&&c instanceof Element&&m.contains(c)?kr(c):null},s=c=>o(c.target);o(document.activeElement);const i=c=>{const m=c.target;c.relatedTarget!==null||!(m instanceof Element)||queueMicrotask(()=>{n.current?.element===m&&m.isConnected&&document.activeElement!==m&&(n.current=null)})};return document.addEventListener("focusin",s),document.addEventListener("focusout",i),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",i)}},[e]);const r=a.useRef(t);a.useLayoutEffect(()=>{if(r.current===t)return;r.current=t;const o=n.current;if(o===null)return;const s=()=>{const m=document.activeElement;if(m!==null&&m!==document.body&&m!==o.element)return!0;const h=e.current;if(h===null)return!0;for(const g of o.control.successors)for(const p of h.querySelectorAll(g))if(p!==o.element&&(p.focus({preventScroll:!0}),document.activeElement===p))return!0;return!1};if(s())return;const i=e.current;if(i===null)return;const c=new MutationObserver(()=>{s()&&c.disconnect()});return c.observe(i,{childList:!0,subtree:!0}),()=>c.disconnect()},[t,e])},Ar=a.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-CLWbWjOc.cjs")).then(e=>({default:e.TreeLayout}))),Lr=a.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-UyWxs6Xy.cjs")).then(e=>({default:e.MultiLayout}))),Or=64,Ye={request:e=>{requestAnimationFrame(e)}},Je=e=>{e.documents.clear(),e.trees.clear()},ve=(e,t)=>{t.tree!==null&&e.trees.seed(t.tree.sourceId,t.tree.result);for(const{path:n,document:r}of t.documents)e.documents.seed(n,r)},Cr=(e,t)=>{const[n,r]=a.useState(()=>({overrides:t,locale:e,labels:xe(e,t)}));if(n.locale===e&&Dt(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:xe(e,t)};return r(o),o.labels},Mr=(e,t,n)=>{const[r,o]=a.useState(()=>({scope:t,store:Ve(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:Ve(e,n)};return o(s),s.store},jr=e=>{const[t,n]=a.useState(()=>({scope:e,announcer:Ze(Ye)}));if(t.scope===e)return t.announcer;const r={scope:e,announcer:Ze(Ye)};return n(r),r.announcer},Nr=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:i,renderTreeFailure:c,lockDocumentScroll:m=!1,onMathDiagnostics:h})=>{K.assertStorageNamespace(n);const g=rt(r),p=Pt(s),x=Cr(g,o),{revalidate:T}=U.useRevalidator(),k=a.useRef(()=>{}),L=U.useHref(t.dataPath),[A]=a.useState(()=>{const j=cr({dataPath:L,onScope:G=>k.current(G)}),_={documents:Ht({client:j,capacity:Math.max(Or,t.multiView.maxPanels*2)}),trees:hr(j)};return ve(_,e),K.syncStorageScope(n,e.scope),{data:j,..._,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(A.aligned.pageData!==e||A.aligned.storageNamespace!==n){const j=A.aligned.pageData;A.aligned.pageData=e,A.aligned.storageNamespace=n,j!==e&&(j.scope!==e.scope?A.aligned.pendingReader=e:ve(A,e)),K.syncStorageScope(n,e.scope)}const P=Mr(K.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);a.useLayoutEffect(()=>{const j=A.aligned.pendingReader;j!==null&&(A.aligned.pendingReader=null,Je(A),ve(A,j))},[e,A]),a.useLayoutEffect(()=>{let j=!1;return k.current=_=>{_===e.scope||j||(j=!0,_!==null&&(Je(A),K.clearExplorerStorage(n)),T())},()=>{k.current=()=>{}}},[e,T,A,n]);const O=a.useRef(t.settingsCookie);a.useLayoutEffect(()=>{O.current=t.settingsCookie},[t.settingsCookie]);const[f]=a.useState(()=>wr(e.settings,j=>{document.cookie=$.viewSettingsCookieString(O.current,j,window.location.protocol==="https:")})),w=jr(e.scope),S=a.useMemo(()=>Q(e.notices.catch(()=>[])),[e.notices]),b=e.sources.map(j=>j.id).join(`
2
+ `),y=a.useMemo(()=>$.withExplorerSources(t,b.split(`
3
+ `)),[t,b]),F=a.useRef(h);a.useLayoutEffect(()=>{F.current=h},[h]);const[I]=a.useState(()=>(j,_)=>{F.current?.(j,_)}),M=h===void 0?void 0:I,H=a.useMemo(()=>({config:y,labels:x,locale:g,theme:p,storageNamespace:n,scope:e.scope,sources:e.sources,notices:S,documents:A.documents,trees:A.trees,data:A.data,viewSettings:f,treeSettings:P,announcer:w,renderTreeFailure:c,reportMathDiagnostics:M}),[y,x,g,p,n,e.scope,e.sources,S,A,f,P,w,c,M]);return d.jsx(ot,{value:H,children:d.jsx(Pr,{renderFrame:i,lockDocumentScroll:m},e.scope)})},Dr=({ref:e,theme:t,view:n,children:r})=>{const[o]=a.useState(gn);return d.jsx("div",{ref:e,className:"aqmx-root","data-aqmx-theme":t,"data-aqmx-view":n,"data-testid":"markdown-explorer",onKeyDownCapture:o.onKeyDownCapture,onKeyUpCapture:o.onKeyUpCapture,onBlurCapture:o.onBlurCapture,children:r})},Pr=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=D(),o=ae(),{hash:s}=U.useLocation(),i=ce(),c=a.useRef(null);yr(t,c),a.useLayoutEffect(()=>{o.kind==="redirect"&&i(`${o.href}${s}`,"browse")},[o,s,i]);const{location:m}=o,h=m.view;Tr(c,h);const g=m.view==="tree"?d.jsx(a.Suspense,{fallback:d.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading"}),children:d.jsx(Ar,{location:m})}):m.view==="multi"?d.jsx(a.Suspense,{fallback:d.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading"}),children:d.jsx(Lr,{location:m})}):d.jsx(lr,{location:m}),p=d.jsxs(Dr,{ref:c,theme:n,view:h,children:[g,d.jsx(Tt,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?p:e({view:h,children:p})},$r=({currentUrl:e,nextUrl:t,formMethod:n,defaultShouldRevalidate:r})=>n===void 0&&e.href===t.href&&r;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=Qe;exports.DocumentPane=St;exports.DocumentRefreshBar=kt;exports.EXPLORER_THEMES=be;exports.ExplorerLink=st;exports.FailureView=it;exports.ForwardRef=yt;exports.ImageViewMemoryContext=pt;exports.LiveRegion=Tt;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=nt;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Le;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=et;exports.MARKDOWN_EXPLORER_LOCALES=Ee;exports.MarkdownExplorer=Nr;exports.PAGE_DOCUMENT_REFRESH=Rt;exports.createEmitter=te;exports.explorerNavigationOptions=_t;exports.failureTitleOf=ee;exports.focusWithoutScroll=Ce;exports.resolveMarkdownExplorerLabels=xe;exports.shouldRevalidateExplorer=$r;exports.useExplorer=D;exports.useExplorerLocation=ae;exports.useExplorerNavigate=ce;exports.useIntentPrefetch=at;exports.useViewSetting=J;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./index-y9tVvDW7.cjs"),e=require("./storage-Bkb2Axdi.cjs"),E=require("./location-DWHQYntR.cjs"),_=require("./dataRoute-CKbdwkQ7.cjs");exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=L.DEFAULT_MARKDOWN_EXPLORER_LOCALE;exports.EXPLORER_THEMES=L.EXPLORER_THEMES;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=L.MARKDOWN_EXPLORER_LABEL_CATALOGS;exports.MARKDOWN_EXPLORER_LABEL_KEYS=L.MARKDOWN_EXPLORER_LABEL_KEYS;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=L.MARKDOWN_EXPLORER_LABEL_TEMPLATES;exports.MARKDOWN_EXPLORER_LOCALES=L.MARKDOWN_EXPLORER_LOCALES;exports.MarkdownExplorer=L.MarkdownExplorer;exports.resolveMarkdownExplorerLabels=L.resolveMarkdownExplorerLabels;exports.shouldRevalidateExplorer=L.shouldRevalidateExplorer;exports.clearExplorerStorage=e.clearExplorerStorage;exports.COLUMN_MIN_MEASURE=E.COLUMN_MIN_MEASURE;exports.DEFAULT_TREE_SETTINGS=E.DEFAULT_TREE_SETTINGS;exports.DEFAULT_VIEW_SLUGS=E.DEFAULT_VIEW_SLUGS;exports.EXPAND_ALL_DEPTH_LIMITS=E.EXPAND_ALL_DEPTH_LIMITS;exports.EXPAND_ALL_FOLDER_LIMITS=E.EXPAND_ALL_FOLDER_LIMITS;exports.EXPLORER_DEFAULT_PERCENT=E.EXPLORER_DEFAULT_PERCENT;exports.EXPLORER_MAX_PERCENT=E.EXPLORER_MAX_PERCENT;exports.EXPLORER_MIN_REM=E.EXPLORER_MIN_REM;exports.EXPLORER_MULTI_DEFAULT_PERCENT=E.EXPLORER_MULTI_DEFAULT_PERCENT;exports.GOLDEN_RATIO=E.GOLDEN_RATIO;exports.MULTI_VIEW_COLUMN_LIMITS=E.MULTI_VIEW_COLUMN_LIMITS;exports.MULTI_VIEW_PANEL_LIMITS=E.MULTI_VIEW_PANEL_LIMITS;exports.defineExplorerConfig=E.defineExplorerConfig;exports.explorerHref=E.explorerHref;exports.isExplorerSourceId=E.isExplorerSourceId;exports.resolveExplorerLocation=E.resolveExplorerLocation;exports.withExplorerSources=E.withExplorerSources;exports.DEFAULT_DENIED_PATH_SEGMENTS=_.DEFAULT_DENIED_PATH_SEGMENTS;exports.EXPLORER_FAILURE_REASONS=_.EXPLORER_FAILURE_REASONS;exports.EXPLORER_MAX_HEADINGS=_.EXPLORER_MAX_HEADINGS;exports.MAX_DOCUMENT_PATH_LENGTH=_.MAX_DOCUMENT_PATH_LENGTH;exports.failureDocument=_.failureDocument;exports.failureOf=_.failureOf;exports.isAcceptableDocumentPath=_.isAcceptableDocumentPath;exports.isDeniedPath=_.isDeniedPath;exports.isExplorerChildrenResult=_.isExplorerChildrenResult;exports.isExplorerFailureCode=_.isExplorerFailureCode;exports.isExplorerFailureReason=_.isExplorerFailureReason;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("./index-Cx3-jSna.cjs"),e=require("./storage-Bkb2Axdi.cjs"),E=require("./location-Oo21lTyV.cjs"),_=require("./dataRoute-CKbdwkQ7.cjs");exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=L.DEFAULT_MARKDOWN_EXPLORER_LOCALE;exports.EXPLORER_THEMES=L.EXPLORER_THEMES;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=L.MARKDOWN_EXPLORER_LABEL_CATALOGS;exports.MARKDOWN_EXPLORER_LABEL_KEYS=L.MARKDOWN_EXPLORER_LABEL_KEYS;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=L.MARKDOWN_EXPLORER_LABEL_TEMPLATES;exports.MARKDOWN_EXPLORER_LOCALES=L.MARKDOWN_EXPLORER_LOCALES;exports.MarkdownExplorer=L.MarkdownExplorer;exports.resolveMarkdownExplorerLabels=L.resolveMarkdownExplorerLabels;exports.shouldRevalidateExplorer=L.shouldRevalidateExplorer;exports.clearExplorerStorage=e.clearExplorerStorage;exports.COLUMN_MIN_MEASURE=E.COLUMN_MIN_MEASURE;exports.DEFAULT_TREE_SETTINGS=E.DEFAULT_TREE_SETTINGS;exports.DEFAULT_VIEW_SLUGS=E.DEFAULT_VIEW_SLUGS;exports.EXPAND_ALL_DEPTH_LIMITS=E.EXPAND_ALL_DEPTH_LIMITS;exports.EXPAND_ALL_FOLDER_LIMITS=E.EXPAND_ALL_FOLDER_LIMITS;exports.EXPLORER_DEFAULT_PERCENT=E.EXPLORER_DEFAULT_PERCENT;exports.EXPLORER_MAX_PERCENT=E.EXPLORER_MAX_PERCENT;exports.EXPLORER_MIN_REM=E.EXPLORER_MIN_REM;exports.EXPLORER_MULTI_DEFAULT_PERCENT=E.EXPLORER_MULTI_DEFAULT_PERCENT;exports.GOLDEN_RATIO=E.GOLDEN_RATIO;exports.MULTI_VIEW_COLUMN_LIMITS=E.MULTI_VIEW_COLUMN_LIMITS;exports.MULTI_VIEW_PANEL_LIMITS=E.MULTI_VIEW_PANEL_LIMITS;exports.defineExplorerConfig=E.defineExplorerConfig;exports.explorerHref=E.explorerHref;exports.isExplorerSourceId=E.isExplorerSourceId;exports.resolveExplorerLocation=E.resolveExplorerLocation;exports.withExplorerSources=E.withExplorerSources;exports.DEFAULT_DENIED_PATH_SEGMENTS=_.DEFAULT_DENIED_PATH_SEGMENTS;exports.EXPLORER_FAILURE_REASONS=_.EXPLORER_FAILURE_REASONS;exports.EXPLORER_MAX_HEADINGS=_.EXPLORER_MAX_HEADINGS;exports.MAX_DOCUMENT_PATH_LENGTH=_.MAX_DOCUMENT_PATH_LENGTH;exports.failureDocument=_.failureDocument;exports.failureOf=_.failureOf;exports.isAcceptableDocumentPath=_.isAcceptableDocumentPath;exports.isDeniedPath=_.isDeniedPath;exports.isExplorerChildrenResult=_.isExplorerChildrenResult;exports.isExplorerFailureCode=_.isExplorerFailureCode;exports.isExplorerFailureReason=_.isExplorerFailureReason;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { j as s, k as _, M as L, l as r, m as e, n as R, o, r as A, s as T } from "./index-BgkZ9ATV.js";
1
+ import { k as s, l as _, M as L, m as r, n as e, o as R, p as o, r as A, s as T } from "./index-BfuAu2GV.js";
2
2
  import { c as O } from "./storage-DA4ItHzl.js";
3
- import { J as D, K as P, L as N, M as I, O as S, q as i, o as p, Q as X, s as x, G as t, R as U, T as C, a as f, e as n, i as u, r as F, w as c } from "./location-Cb2Ak55B.js";
3
+ import { J as D, K as P, L as N, M as I, O as S, q as i, o as p, Q as X, s as x, G as t, R as U, T as C, a as f, e as n, i as u, r as F, w as c } from "./location-fVl2R1ee.js";
4
4
  import { D as G, A as W, E as m, M as H, s as K, f as h, i as w, t as b, w as k, b as v, a as B } from "./dataRoute-Bkfwfp1R.js";
5
5
  export {
6
6
  D as COLUMN_MIN_MEASURE,
@@ -0,0 +1 @@
1
+ "use strict";const O=require("@aiquants/markdown/embeds"),h=require("@aiquants/markdown/viewer-settings"),v=require("./dataRoute-CKbdwkQ7.cjs"),C=e=>{if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},L=new Intl.Collator("en",{numeric:!0,sensitivity:"variant"}),P=Object.freeze({sortMode:"native",directoriesFirst:!1,selectionMode:"single",doubleClickAction:"recursive",expandIconSize:8,alwaysExpanded:!1,removeRootIndent:!1,lines:!0,expandIcons:!0,directoryIcons:!0,fileIcons:!0}),ce=[!0,!1],le=(e,t)=>t?e.settingOn:e.settingOff,E=(e,t)=>({key:e,labelKey:t,values:ce,formatValue:le,requiresItemSelection:!1}),w=Object.freeze([{key:"sortMode",labelKey:"settingSortMode",values:["native","asc","desc"],formatValue:(e,t)=>t==="native"?e.sortNative:t==="asc"?e.sortAscending:e.sortDescending,requiresItemSelection:!1},E("directoriesFirst","settingDirectoriesFirst"),{key:"selectionMode",labelKey:"settingSelectionMode",values:["single","multiple","none"],formatValue:(e,t)=>t==="single"?e.selectionSingle:t==="multiple"?e.selectionMultiple:e.selectionNone,requiresItemSelection:!0},{key:"doubleClickAction",labelKey:"settingDoubleClick",values:["recursive","toggle"],formatValue:(e,t)=>t==="recursive"?e.doubleClickRecursive:e.doubleClickToggle,requiresItemSelection:!1},{key:"expandIconSize",labelKey:"settingExpandIconSize",values:[8,13,5],formatValue:(e,t)=>e.expandIconSizeValue(t),requiresItemSelection:!1},E("alwaysExpanded","settingAlwaysExpanded"),E("removeRootIndent","settingRemoveRootIndent"),E("lines","settingTreeLines"),E("expandIcons","settingExpandIcons"),E("directoryIcons","settingDirectoryIcons"),E("fileIcons","settingFileIcons")]),de=e=>e?w:w.filter(t=>!t.requiresItemSelection),X=e=>{const t=w.find(r=>r.key===e);if(t===void 0)throw new RangeError(`[markdown-explorer] no tree setting descriptor for ${e}`);return t},me=(e,t)=>{const r=X(t).values,n=r[(r.indexOf(e[t])+1)%r.length];return{...e,[t]:n}},ue=(e,t,r)=>X(r).formatValue(e,t[r]),G=2,k=Object.freeze({}),D=(e,t)=>Object.freeze(Object.fromEntries(w.filter(r=>t(r,e[r.key])).map(r=>[r.key,e[r.key]]))),fe=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return k;const t=e;return t.version!==G||t.settings===null||typeof t.settings!="object"||Array.isArray(t.settings)?k:D(t.settings,(r,n)=>r.values.includes(n))},ge=(e,t)=>{const r=D(t,(n,o)=>o!==void 0&&o!==e[n.key]);return Object.keys(r).length===0?e:Object.freeze({...e,...r})},Ee=(e,t,r,n)=>D({...e,[t]:r},(o,i)=>i!==void 0&&!(o.key===t&&i===n[t])),we=e=>JSON.stringify({version:G,settings:e}),Se=e=>{if(e.sortMode==="native"&&!e.directoriesFirst)return;const t=e.sortMode==="desc"?-1:1;return(r,n)=>{if(e.directoriesFirst&&r.type!==n.type)return r.type==="directory"?-1:1;if(e.sortMode==="native")return 0;const o=L.compare(r.name,n.name);return t*(o!==0?o:L.compare(r.path,n.path))}},u=(1+Math.sqrt(5))/2,pe=100/u**3,he=100/u**4,z=100/u**2,W=13,_e=16,ye=Object.freeze({gripThickness:5,gripLength:34,barThickness:2,barLength:21}),Oe=Object.freeze([89,144,233,377]),Te=34,xe=44,be=24,Ne=1/u,Re=1/u**3,Ae="40ch",Ie=e=>{if(!Number.isFinite(e)||e<=0)throw new RangeError(`[markdown-explorer] rootFontPixels must be a finite number > 0; got ${String(e)}`)},J=e=>(Ie(e),W*e),Le=e=>J(e)*u**2,Pe=233,ke=Oe[0],j=(e,t)=>{if(!Number.isFinite(t)||t<0)throw new RangeError(`[markdown-explorer] ${e} must be a finite number >= 0; got ${String(t)}`)},Me=({trackInlineSize:e,gap:t,minColumnInlineSize:r,logicalColumns:n})=>{if(j("trackInlineSize",e),j("gap",t),!Number.isFinite(r)||r<=0)throw new RangeError(`[markdown-explorer] minColumnInlineSize must be a finite number > 0; got ${String(r)}`);if(!Number.isInteger(n)||n<1)throw new RangeError(`[markdown-explorer] logicalColumns must be a positive integer; got ${String(n)}`);const o=Math.floor((e+t)/(r+t));return Math.min(n,Math.max(1,o))},$e=(e,t)=>{const{trackInlineSize:r,gap:n,minColumnInlineSize:o,logicalColumns:i}=t;if(!([r,n,o].every(Number.isFinite)&&r>0&&n>=0&&o>0))return e;const s=Me(t);if(e===null||s===e)return s;const l=Math.min(i,Math.max(1,e));if(s>l){const b=(l+1)*o+l*n+n/u;return r>=b?s:l}return r>=l*o+(l-1)*n?l:s},ve=(e,t)=>{if(!(Number.isInteger(e)&&Number.isInteger(t))||t<1||t>e)throw new RangeError(`[markdown-explorer] visible columns must be an integer in 1..${String(e)}; got ${String(t)}`);return Array.from({length:t},(r,n)=>[Math.floor(n*e/t),Math.floor((n+1)*e/t)])},Ce=31536e3,De=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/u,ze=e=>{if(typeof e!="string"||!De.test(e))throw new RangeError(`[markdown-explorer] settingsCookie must be a cookie-name token; got ${JSON.stringify(e)}`)},F=e=>typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=z,je=(e,t)=>{if(e===null||typeof e!="object"||Array.isArray(e))return{};const r=e,{treeExplorer:n,multiExplorer:o,style:i,align:a}=r;return{...F(n)?{treeExplorer:n}:{},...F(o)?{multiExplorer:o}:{},...typeof i=="string"&&t.includes(i)?{style:i}:{},...typeof a=="string"&&h.CONTENT_ALIGNS.includes(a)?{align:a}:{}}},Fe=(e,t)=>{if(e!==null)for(const r of e.split(";")){const n=r.indexOf("=");if(!(n<0)&&r.slice(0,n).trim()===t)return r.slice(n+1).trim()}},Ve=(e,t)=>{if(e===void 0||e==="")return{};try{return je(JSON.parse(decodeURIComponent(e)),t)}catch{return{}}},x=100,Ue=Math.floor(z*x)/x,Xe=e=>{const t=r=>Math.min(Ue,Math.max(1,Math.round(r*x))/x);return encodeURIComponent(JSON.stringify({...e.treeExplorer===void 0?{}:{treeExplorer:t(e.treeExplorer)},...e.multiExplorer===void 0?{}:{multiExplorer:t(e.multiExplorer)},...e.style===void 0?{}:{style:e.style},...e.align===void 0?{}:{align:e.align}}))},Ge=(e,t,r)=>`${e}=${Xe(t)}; Path=/; Max-Age=${String(Ce)}; SameSite=Lax${r?"; Secure":""}`,M=Object.freeze({tree:"tree",multi:"multi",single:"single"}),H=Object.freeze({default:12,min:1,max:64}),q=Object.freeze({default:4,min:1,max:6}),B=Object.freeze({default:500,min:1,max:1e4}),K=Object.freeze({default:16,min:1,max:64}),We=/^\/(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+$/u,Je=/^[A-Za-z0-9][A-Za-z0-9_-]*$/u,He=/^[a-z0-9][a-z0-9-]*$/u,qe=/^(?=.{1,253}$)(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/u,V=(e,t)=>{if(typeof t!="string")throw new TypeError(`[markdown-explorer] ${e} must be a string; got ${typeof t}`);if(!We.test(t)||t.split("/").some(r=>r==="."||r===".."))throw new RangeError(`[markdown-explorer] ${e} must start with "/", have no trailing "/", and use only letters, digits and "._~-" in each segment; got ${JSON.stringify(t)}`)},d=e=>typeof e=="string"?JSON.stringify(e):typeof e=="bigint"?`${String(e)}n`:Object.is(e,-0)?"-0":typeof e=="function"?"a function":Array.isArray(e)?"an array":e!==null&&typeof e=="object"?C(e)?"a plain object":`a non-plain object (${Object.prototype.toString.call(e)})`:String(e),_=(e,t,r)=>{if(t===void 0)return[];if(!C(t))throw new TypeError(`[markdown-explorer] ${e} must be a plain object; got ${d(t)}`);const n=Object.entries(t);for(const[o]of n)if(!r.includes(o))throw new RangeError(`[markdown-explorer] ${e}.${o} is not an option; expected ${r.join(", ")}`);return n.filter(([,o])=>o!==void 0)},Be=e=>{const t={...M};for(const[r,n]of _("views",e,Object.keys(M)))t[r]=n;for(const[r,n]of Object.entries(t))if(typeof n!="string"||!Je.test(n))throw new RangeError(`[markdown-explorer] views.${r} must start with a letter or digit and use only letters, digits, "_" and "-"; got ${JSON.stringify(n)}`);return Object.freeze(t)},T=(e,t,r)=>{if(t===void 0)return r.default;if(typeof t!="number"||!Number.isInteger(t)||t<r.min||t>r.max)throw new RangeError(`[markdown-explorer] ${e} must be an integer in ${String(r.min)}..${String(r.max)}; got ${d(t)}`);return t},Ke=e=>{const t=new Map(_("embeds",e,["providers","linkCardEndpoint"]));if(t.size===0)return O.NO_EMBEDS;const r=t.has("providers")?t.get("providers"):[];if(!Array.isArray(r))throw new RangeError(`[markdown-explorer] embeds.providers must be an array of provider ids; got ${d(r)}`);for(const o of r)if(!O.isEmbedProviderId(o))throw new RangeError(`[markdown-explorer] embeds.providers must hold only ${O.EMBED_PROVIDER_IDS.join(", ")}; got ${d(o)}`);const n=t.has("linkCardEndpoint")?t.get("linkCardEndpoint"):null;if(n!==null&&!O.isLinkCardEndpoint(n))throw new RangeError(`[markdown-explorer] embeds.linkCardEndpoint must start with "/", have no trailing "/", and use only letters, digits and "._~-" in each segment; got ${d(n)}`);return Object.freeze({providers:Object.freeze([...new Set(r)]),linkCardEndpoint:n})},Ze=e=>{const t=new Map(_("defaultTreeSettings",e,w.map(n=>n.key)));if(t.size===0)return P;const r={...P};for(const n of w){if(!t.has(n.key))continue;const o=t.get(n.key),i=n.values;if(!i.includes(o))throw new RangeError(`[markdown-explorer] defaultTreeSettings.${n.key} must be one of ${i.map(d).join(", ")}; got ${d(o)}`);r[n.key]=o}return Object.freeze(r)},Ye=e=>{if(e===null||typeof e!="object")throw new TypeError("[markdown-explorer] the explorer configuration must be an object");V("basePath",e.basePath),V("dataPath",e.dataPath);const t=Be(e.views);if(new Set([t.tree,t.multi,t.single]).size!==3)throw new RangeError(`[markdown-explorer] the view slugs must differ; got ${JSON.stringify(t)}`);if(e.dataPath===e.basePath)throw new RangeError("[markdown-explorer] dataPath must differ from basePath");if(e.dataPath.startsWith(`${e.basePath}/`)){const s=e.dataPath.slice(e.basePath.length+1).split("/")[0];if(s===t.tree||s===t.multi||s===t.single)throw new RangeError(`[markdown-explorer] dataPath must not start with a view slug under basePath; got ${JSON.stringify(e.dataPath)}`)}ze(e.settingsCookie);const r=e.iframeHosts??[];if(!Array.isArray(r)||r.some(s=>typeof s!="string"||!qe.test(s)))throw new RangeError(`[markdown-explorer] iframeHosts must be lowercase host names without scheme, port or path; got ${JSON.stringify(r)}`);const n=Object.fromEntries(_("multiView",e.multiView,["maxPanels","columns"])),o=Object.fromEntries(_("expandAll",e.expandAll,["maxFolders","maxDepth"])),i=e.documentStyles??h.DEFAULT_MARKDOWN_STYLES;if(!Array.isArray(i)||i.length===0)throw new RangeError("[markdown-explorer] documentStyles must be a non-empty array");const a=new Set;for(const s of i){if(s===null||typeof s!="object"||typeof s.name!="string"||s.name.trim()===""||typeof s.className!="string")throw new RangeError("[markdown-explorer] each document style needs a non-blank name and a className string");if(a.has(s.name))throw new RangeError(`[markdown-explorer] document style names must be unique; ${JSON.stringify(s.name)} repeats`);a.add(s.name)}return Object.freeze({basePath:e.basePath,dataPath:e.dataPath,settingsCookie:e.settingsCookie,views:t,multiView:Object.freeze({maxPanels:T("multiView.maxPanels",n.maxPanels,H),columns:T("multiView.columns",n.columns,q)}),expandAll:Object.freeze({maxFolders:T("expandAll.maxFolders",o.maxFolders,B),maxDepth:T("expandAll.maxDepth",o.maxDepth,K)}),documentStyles:Object.freeze(i.map(s=>Object.freeze({name:s.name,className:s.className}))),iframeHosts:Object.freeze([...new Set(r)]),embeds:Ke(e.embeds),defaultTreeSettings:Ze(e.defaultTreeSettings)})},Z=e=>typeof e=="string"&&He.test(e),Qe=(e,t)=>{if(e===null||typeof e!="object")throw new TypeError(`[markdown-explorer] withExplorerSources needs the configuration of defineExplorerConfig; got ${d(e)}`);if(!Array.isArray(t)||t.length===0)throw new RangeError(`[markdown-explorer] sourceIds must be a non-empty array; got ${d(t)}`);for(const r of t)if(!Z(r))throw new RangeError(`[markdown-explorer] each source id must use lowercase letters, digits and "-" and start with a letter or digit; got ${d(r)}`);if(new Set(t).size!==t.length)throw new RangeError(`[markdown-explorer] source ids must be unique; got ${JSON.stringify(t)}`);return Object.freeze({...e,sourceIds:Object.freeze([...t])})},et=e=>e.documentStyles.map(t=>t.name),c=Object.freeze({source:"source",doc:"doc",maximized:"maximized",style:"style",align:"align",showToc:"showToc",showStyle:"showStyle",showAlign:"showAlign",padding:"padding",width:"width",maxWidth:"maxWidth"}),U=".data",Y=256,Q=/^\d+(?:\.\d+)?$/u,$=/^\d+(?:\.\d+)?(?:px|rem|em|ch|vw|%)$/u,ee=Object.freeze(["showToc","showStyle","showAlign"]),tt=e=>{const t=encodeURIComponent(e.replaceAll("%","%25"));return t.endsWith(U)?`${t.slice(0,-U.length)}%2Edata`:t},rt=e=>e.replaceAll("%25","%"),te=e=>{const{sourceIds:t}=e;if(t===void 0)throw new TypeError("[markdown-explorer] the configuration has no source ids; join the server's sources with withExplorerSources(config, sourceIds)");return t},nt=(e,t,r)=>{const n=r.getAll(c.source);if(n.length===0)return t;const[o]=n;return n.length>1||o===void 0||o===t||!e.includes(o)?null:o},ot=(e,t)=>{const r=t.get(c.style),n=t.get(c.align);return{...r!==null&&e.documentStyles.some(o=>o.name===r)?{style:r}:{},...n!==null&&h.CONTENT_ALIGNS.includes(n)?{align:n}:{}}},re=e=>Number.isFinite(e)&&e>=0&&e<=Y&&Q.test(String(e)),it=e=>{const t=e.get(c.padding),r=t!==null&&Q.test(t)?Number(t):Number.NaN,n=e.get(c.width),o=e.get(c.maxWidth);return{...e.get(c.showToc)==="false"?{showToc:!1}:{},...e.get(c.showStyle)==="false"?{showStyle:!1}:{},...e.get(c.showAlign)==="false"?{showAlign:!1}:{},...re(r)?{padding:r}:{},...n!==null&&$.test(n)?{width:n}:{},...o!==null&&$.test(o)?{maxWidth:o}:{}}},ne=(e,t)=>[...new Set(t.filter(v.isAcceptableDocumentPath))].slice(0,e.multiView.maxPanels),st=(e,t,r)=>{for(const n of t)oe(n);if(new Set(t).size!==t.length)throw new RangeError(`[markdown-explorer] multi-view documents must each appear once; got ${String(t.length)} with repeats`);if(t.length>e.multiView.maxPanels)throw new RangeError(`[markdown-explorer] the multi view opens at most ${String(e.multiView.maxPanels)} documents; got ${String(t.length)}`);if(r!==null&&!t.includes(r))throw new RangeError(`[markdown-explorer] the maximized document must be one of the open documents; got ${JSON.stringify(r.slice(0,80))}`)},oe=e=>{if(!v.isAcceptableDocumentPath(e))throw new RangeError(`[markdown-explorer] not an acceptable document path: ${JSON.stringify(String(e).slice(0,80))}`);return e},at=(e,t)=>{if(t.style!==void 0&&!e.documentStyles.some(r=>r.name===t.style))throw new RangeError(`[markdown-explorer] overrides.style must name a configured document style (${e.documentStyles.map(r=>JSON.stringify(r.name)).join(", ")}); got ${JSON.stringify(t.style)}`);if(t.align!==void 0&&!h.CONTENT_ALIGNS.includes(t.align))throw new RangeError(`[markdown-explorer] overrides.align must be one of ${h.CONTENT_ALIGNS.join(", ")}; got ${JSON.stringify(t.align)}`)},ct=e=>{for(const t of ee)if(e[t]!==void 0&&typeof e[t]!="boolean")throw new RangeError(`[markdown-explorer] embed.${t} must be a boolean; got ${JSON.stringify(e[t])}`);if(e.padding!==void 0&&!re(e.padding))throw new RangeError(`[markdown-explorer] embed.padding must be 0..${String(Y)} px in plain decimal digits; got ${String(e.padding)}`);for(const t of["width","maxWidth"]){const r=e[t];if(r!==void 0&&!$.test(r))throw new RangeError(`[markdown-explorer] embed.${t} must be a CSS length in px, rem, em, ch, vw or %; got ${JSON.stringify(r)}`)}},ie=(e,t)=>{const r=new URLSearchParams;let n=`${e.basePath}/${e.views[t.view]}`;if(t.view==="multi"){const i=t.docs??[],a=t.maximized??null;st(e,i,a);for(const s of i)r.append(c.doc,s);a!==null&&r.set(c.maximized,a)}else t.doc!==void 0&&t.doc!==null&&(n+=`/${tt(oe(t.doc))}`);if(t.source!==void 0){const i=te(e);if(!i.includes(t.source))throw new RangeError(`[markdown-explorer] unknown source ${JSON.stringify(t.source)}; expected one of ${i.join(", ")}`);t.source!==i[0]&&r.set(c.source,t.source)}if(t.view!=="multi"&&t.overrides!==void 0&&(at(e,t.overrides),t.overrides.style!==void 0&&r.set(c.style,t.overrides.style),t.overrides.align!==void 0&&r.set(c.align,t.overrides.align)),t.view==="single"&&t.embed!==void 0){const{embed:i}=t;ct(i);for(const a of ee)i[a]===!1&&r.set(c[a],"false");i.padding!==void 0&&r.set(c.padding,String(i.padding)),i.width!==void 0&&r.set(c.width,i.width),i.maxWidth!==void 0&&r.set(c.maxWidth,i.maxWidth)}const o=r.toString();return o===""?n:`${n}?${o}`},lt=(e,t)=>Object.keys(e.views).find(r=>e.views[r]===t),dt=(e,t,r)=>{const n=te(e),[o]=n;if(o===void 0)throw new RangeError("[markdown-explorer] the configuration has no source");const i=nt(n,o,r),a=i===null?o:i,s=m=>({kind:"redirect",href:ie(e,m),location:m}),l=()=>s({view:"tree",source:a,doc:null,overrides:{}});if(t===void 0||t==="")return l();const S=t.indexOf("/"),b=S<0?t:t.slice(0,S),N=S<0?null:t.slice(S+1),f=lt(e,b);if(f===void 0)return l();if(f==="multi"){const m=r.getAll(c.doc),p=ne(e,m),R=r.getAll(c.maximized),[A]=R,I=R.length===1&&A!==void 0&&p.includes(A)?A:null;return N===null&&i!==null&&p.length===m.length&&p.every((se,ae)=>se===m[ae])&&(R.length===0||I!==null)?{kind:"location",location:{view:"multi",source:a,docs:p,maximized:I}}:s({view:"multi",source:a,docs:p,maximized:I})}const g=N===null?null:rt(N);if(g!==null&&!v.isAcceptableDocumentPath(g))return l();const y=ot(e,r);if(f==="single"){if(g===null)return l();const m=it(r);return i===null?s({view:f,source:a,doc:g,overrides:y,embed:m}):{kind:"location",location:{view:f,source:a,doc:g,overrides:y,embed:m}}}return i===null?s({view:f,source:a,doc:g,overrides:y}):{kind:"location",location:{view:f,source:a,doc:g,overrides:y}}};exports.ASSUMED_ROOT_FONT_PIXELS=_e;exports.COARSE_TARGET_PIXELS=xe;exports.COLUMN_MIN_MEASURE=Ae;exports.CONTROL_BLOCK_PIXELS=Te;exports.DEFAULT_TREE_SETTINGS=P;exports.DEFAULT_VIEW_SLUGS=M;exports.EXPAND_ALL_DEPTH_LIMITS=K;exports.EXPAND_ALL_FOLDER_LIMITS=B;exports.EXPLORER_DEFAULT_PERCENT=pe;exports.EXPLORER_MAX_PERCENT=z;exports.EXPLORER_MIN_REM=W;exports.EXPLORER_MULTI_DEFAULT_PERCENT=he;exports.EXPLORER_WIDTH_PERSIST_DELAY_MS=Pe;exports.FINE_TARGET_PIXELS=be;exports.GOLDEN_RATIO=u;exports.MULTI_VIEW_COLUMN_LIMITS=q;exports.MULTI_VIEW_PANEL_LIMITS=H;exports.NAME_COLLATOR=L;exports.NO_TREE_SETTING_CHANGES=k;exports.PANEL_MAX_BLOCK_RATIO=Ne;exports.PANEL_MIN_BLOCK_RATIO=Re;exports.PREFETCH_DWELL_MS=ke;exports.SPLIT_HANDLE_PIXELS=ye;exports.advanceTreeSetting=me;exports.applyTreeSettingChanges=ge;exports.canonicalMultiDocuments=ne;exports.columnGroups=ve;exports.createEntryComparator=Se;exports.defineExplorerConfig=Ye;exports.documentStyleNames=et;exports.explorerHref=ie;exports.explorerMinPixels=J;exports.explorerSheetBelowPixels=Le;exports.formatTreeSettingValue=ue;exports.isExplorerSourceId=Z;exports.isPlainObject=C;exports.parseViewSettings=Ve;exports.readCookieValue=Fe;exports.readTreeSettingChanges=fe;exports.recordTreeSettingChange=Ee;exports.replanVisibleColumns=$e;exports.resolveExplorerLocation=dt;exports.serializeTreeSettingChanges=we;exports.viewSettingsCookieString=Ge;exports.visibleTreeSettingDescriptors=de;exports.withExplorerSources=Qe;