@aiquants/markdown-explorer 0.0.0-stage → 0.1.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 (78) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/LICENSE +21 -0
  3. package/README.md +588 -2
  4. package/dist/ExplorerSplit-BESGFcu6.cjs +1 -0
  5. package/dist/ExplorerSplit-DwEFmvQM.js +1362 -0
  6. package/dist/MultiLayout-DxPiARsv.js +896 -0
  7. package/dist/MultiLayout-r_qx1Mfz.cjs +1 -0
  8. package/dist/TreeLayout-9-20bbSM.cjs +1 -0
  9. package/dist/TreeLayout-CW7lgV_e.js +19 -0
  10. package/dist/client/MarkdownExplorer.d.cts +30 -0
  11. package/dist/client/MarkdownExplorer.d.ts +30 -0
  12. package/dist/client/storage.d.cts +11 -0
  13. package/dist/client/storage.d.ts +11 -0
  14. package/dist/core/config.d.cts +71 -0
  15. package/dist/core/config.d.ts +71 -0
  16. package/dist/core/contracts.d.cts +155 -0
  17. package/dist/core/contracts.d.ts +155 -0
  18. package/dist/core/geometry.d.cts +51 -0
  19. package/dist/core/geometry.d.ts +51 -0
  20. package/dist/core/labels.d.cts +175 -0
  21. package/dist/core/labels.d.ts +175 -0
  22. package/dist/core/location.d.cts +82 -0
  23. package/dist/core/location.d.ts +82 -0
  24. package/dist/core/paths.d.cts +17 -0
  25. package/dist/core/paths.d.ts +17 -0
  26. package/dist/core/revalidation.d.cts +2 -0
  27. package/dist/core/revalidation.d.ts +2 -0
  28. package/dist/core/theme.d.cts +6 -0
  29. package/dist/core/theme.d.ts +6 -0
  30. package/dist/core/treeSettings.d.cts +48 -0
  31. package/dist/core/treeSettings.d.ts +48 -0
  32. package/dist/core/viewSettings.d.cts +15 -0
  33. package/dist/core/viewSettings.d.ts +15 -0
  34. package/dist/dataRoute-Bkfwfp1R.js +194 -0
  35. package/dist/dataRoute-CKbdwkQ7.cjs +1 -0
  36. package/dist/index-BgkZ9ATV.js +2061 -0
  37. package/dist/index-y9tVvDW7.cjs +3 -0
  38. package/dist/index.cjs +1 -0
  39. package/dist/index.d.cts +12 -0
  40. package/dist/index.d.ts +12 -0
  41. package/dist/index.js +44 -0
  42. package/dist/location-Cb2Ak55B.js +382 -0
  43. package/dist/location-DWHQYntR.cjs +1 -0
  44. package/dist/sanitizeWorker.cjs +1 -0
  45. package/dist/sanitizeWorker.js +291 -0
  46. package/dist/server/anonymous.d.cts +10 -0
  47. package/dist/server/anonymous.d.ts +10 -0
  48. package/dist/server/createMarkdownExplorer.d.cts +12 -0
  49. package/dist/server/createMarkdownExplorer.d.ts +12 -0
  50. package/dist/server/errors.d.cts +26 -0
  51. package/dist/server/errors.d.ts +26 -0
  52. package/dist/server/fileSystemSource.d.cts +38 -0
  53. package/dist/server/fileSystemSource.d.ts +38 -0
  54. package/dist/server/ports.d.cts +107 -0
  55. package/dist/server/ports.d.ts +107 -0
  56. package/dist/server/sanitizeProtocol.d.cts +17 -0
  57. package/dist/server/sanitizeProtocol.d.ts +17 -0
  58. package/dist/server/sanitizer.d.cts +51 -0
  59. package/dist/server/sanitizer.d.ts +51 -0
  60. package/dist/server/workerPool.d.cts +42 -0
  61. package/dist/server/workerPool.d.ts +42 -0
  62. package/dist/server.cjs +1 -0
  63. package/dist/server.d.cts +7 -0
  64. package/dist/server.d.ts +7 -0
  65. package/dist/server.js +1253 -0
  66. package/dist/storage-Bkb2Axdi.cjs +1 -0
  67. package/dist/storage-DA4ItHzl.js +60 -0
  68. package/dist/storage.cjs +1 -0
  69. package/dist/storage.d.cts +1 -0
  70. package/dist/storage.d.ts +1 -0
  71. package/dist/storage.js +4 -0
  72. package/dist/styles/markdown-explorer.css +3 -0
  73. package/docs/behavior/dom-hooks.md +95 -0
  74. package/docs/behavior/layout.md +203 -0
  75. package/docs/behavior/localization.md +47 -0
  76. package/docs/behavior/security.md +134 -0
  77. package/docs/behavior/url-contract.md +129 -0
  78. package/package.json +141 -3
@@ -0,0 +1,3 @@
1
+ "use strict";const c=require("react/jsx-runtime"),a=require("react"),U=require("react-router"),F=require("./location-DWHQYntR.cjs"),Oe=require("@aiquants/markdown"),H=require("./dataRoute-CKbdwkQ7.cjs"),yt=require("@aiquants/markdown/viewer-settings"),K=require("./storage-Bkb2Axdi.cjs");function Rt(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 y=Rt(a),xe=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"])}),kt=/\{(\w+)\}/gu,tt={explorerRegion:"Explorer",sourceLabel:"Source",refresh:"Refresh",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}`,refreshDocument:"Reload the document from the source",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",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"},Tt={explorerRegion:"エクスプローラー",sourceLabel:"ソース",refresh:"更新",refreshTree:"ソースからツリーと開いている文書を読み込み直す",treeRefreshed:"ツリーをソースから読み込み直しました",treeRefreshFailed:e=>`ツリーを読み込み直せませんでした: ${e}`,refreshDocument:"ソースから文書を読み込み直す",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:"再試行",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(Tt)}),Ce=Object.freeze(Object.keys(tt)),At=new Set(Ce),Lt=e=>At.has(e),re=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(xe.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${xe.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${re(e)}`)},be=(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 ${re(t)}`);if(!F.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${re(t)}`);const r=t,o={...n};for(const i of Object.keys(r)){if(!Lt(i))throw new RangeError(`[markdown-explorer] labels.${i} is not a known label key; expected one of ${Ce.join(", ")}`);const s=r[i];if(s===void 0)continue;const d=typeof n[i];if(typeof s!==d)throw new TypeError(`[markdown-explorer] labels.${i} must be a ${d}; got ${re(s)}`);if(typeof s=="string"&&s.trim()==="")throw new RangeError(`[markdown-explorer] labels.${i} must be a non-blank string`);const g=et[i];if(typeof s=="string"&&g!==void 0){for(const[,w]of s.matchAll(kt))if(!g.includes(w??""))throw new RangeError(`[markdown-explorer] labels.${i} uses the unknown placeholder {${String(w)}}; it accepts ${g.map(m=>`{${m}}`).join(", ")}`)}o[i]=s}return Object.freeze(o)},Ot=(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),i=Object.keys(r);return o.length===i.length&&i.every(s=>Object.hasOwn(n,s)&&Object.is(n[s],r[s]))},Se=Object.freeze(["light","dark"]),Ct=e=>{if(e===void 0)return"light";if(Se.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${Se.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)},ie=()=>{const{config:e}=D(),t=U.useParams()["*"],[n]=U.useSearchParams(),r=n.toString();return a.useMemo(()=>F.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])};function Mt({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 st=y.forwardRef(Mt);function jt({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Nt=y.forwardRef(jt),Me=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=>Me[e],ae=()=>{const e=U.useNavigate();return a.useCallback((t,n)=>{e(t,Me[n])},[e])},lt=({navigation:e,...t})=>c.jsx(U.Link,{...t,...Me[e]}),it={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"]},ce=(e,t)=>e[it[t][0]],at=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=D(),i=ce(o,e.reason),s=o[it[e.reason][1]],d=e.reason==="unauthorized"||e.reason==="forbidden"||e.reason==="failed"?"danger":"warning";return c.jsxs("div",{className:"aqmx-callout",role:t?"alert":void 0,"data-aqmx-tone":d,"data-testid":r===null?void 0:r,"data-aqmx-failure":r===null?void 0:e.reason,children:[c.jsx("p",{className:"aqmx-callout-title",children:i}),c.jsx("p",{className:"aqmx-callout-body",children:s}),e.reason==="unauthorized"?c.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:()=>window.location.reload(),children:o.reloadPage}):n!==void 0&&e.reason==="failed"?c.jsx("button",{type:"button",className:"aqmx-callout-action",onClick:n,children:o.retry}):null]})},je=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},ct=(e,t)=>{const n=a.useRef(null),r=a.useRef(null),o=a.useRef(null),i=a.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);a.useEffect(()=>i,[i]);const s=a.useCallback(w=>{if(r.current!==w)return;const m=o.current;if(m!==null){m.then(()=>s(w));return}e.prefetch(w);const p=e.peek(w);if(p?.status!=="pending")return;const S=Promise.allSettled([p.promise]);o.current=S,S.then(()=>{o.current===S&&(o.current=null)})},[e]),d=a.useCallback(w=>{const m=t(w);m!==r.current&&(i(),m!==null&&(r.current=m,n.current=window.setTimeout(()=>{n.current=null,s(m)},F.PREFETCH_DWELL_MS)))},[i,t,s]),g=a.useCallback(w=>{t(w)!==r.current&&i()},[i,t]);return a.useMemo(()=>({onPointerOver:w=>d(w.target),onPointerOut:w=>g(w.relatedTarget),onFocus:w=>d(w.target),onBlur:w=>g(w.relatedTarget)}),[d,g])},ee=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},ut=()=>{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 i=!1;return()=>{if(i)return;i=!0;const s=e.get(o);if(s!==void 0&&s>1){e.set(o,s-1);return}e.delete(o),r(o)}},isHeld:o=>e.has(o),resumes:o=>t.delete(o),heldKeys:()=>[...e.keys()]}},se=(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((i,s)=>se(i,t[s]));const n=e,r=t,o=Object.keys(n);return o.length!==Object.keys(r).length?!1:o.every(i=>Object.hasOwn(r,i)&&se(n[i],r[i]))},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}),te=e=>e.status==="fulfilled"?e.value:void 0,Dt=55e3,Pe=Object.freeze({status:"deferred"}),Fe=Object.freeze({status:"refreshed"}),we=Object.freeze({status:"superseded"}),le=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,Pt=({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=ut(),o=ee(),i=new WeakSet,s=o.emit,d=()=>{if(!(n.size<=t))for(const f of[...n.keys()]){if(n.size<=t)return;r.isHeld(f)||n.delete(f)}},g=(f,h)=>{n.delete(f),n.set(f,h)},w=f=>performance.now()-f.validatedAt>=Dt,m=(f,h,b)=>{const x=n.get(f),A=le(x?.snapshot),j=b||x?.refreshPending===!0,O=Q(e.document(f,{refresh:j}).then(P=>({status:"loaded",document:P}))),N={snapshot:{status:"pending",promise:O,previous:A},validatedAt:performance.now(),opened:h,background:null,refreshPending:!1,seeded:void 0};return g(f,N),d(),O.then(P=>{n.get(f)===N&&(N.snapshot=P,s())}),N},p=(f,h,b,x,A,j)=>{h.background===b&&(h.background=null,!(n.get(f)!==h||h.snapshot!==x)&&(A.kind==="failure"&&x.document.kind!=="failure"||(h.validatedAt=j,!se(x.document,A)&&(h.snapshot={status:"loaded",document:A},s()))))},S=async(f,h)=>{const b=h.snapshot;if(b.status!=="loaded")return null;const x={};h.background=x;const A=performance.now(),j=e.document(f,{refresh:h.refreshPending});h.refreshPending=!1;const O=await j,N=h.background===x&&n.get(f)===h&&h.snapshot===b;return p(f,h,x,b,O,A),N?O:null},T=(f,h)=>{const{snapshot:b}=h;return b.status==="pending"?!1:b.status==="loaded"&&b.document.kind!=="failure"?(S(f,h),!1):(b.status==="loaded"&&i.add(b),m(f,!0,!1),!0)},R=f=>{const h=r.hold(f);let b=!1;return()=>{if(b)return;b=!0,h();const x=n.get(f);x!==void 0&&g(f,x),d()}};return{peek:f=>n.get(f)?.snapshot,peekSeeded:f=>n.get(f)?.seeded,prefetch:f=>{const h=n.get(f);h!==void 0&&h.snapshot.status!=="deferred"||(m(f,!1,!1),s())},open:f=>{const h=r.resumes(f),b=R(f),x=n.get(f);if(x===void 0||x.snapshot.status==="deferred")return m(f,!0,!1),s(),b;if(g(f,x),h)return b;const{snapshot:A}=x;return A.status==="pending"?(x.opened=!0,b):A.document.kind==="failure"?(x.opened||w(x)?(i.add(A),m(f,!0,!1),s()):x.opened=!0,b):(x.opened=!0,x.background===null&&w(x)&&S(f,x),b)},retain:R,retry:f=>{const h=n.get(f);h===void 0||h.snapshot.status!=="loaded"||h.snapshot.document.kind!=="failure"||(m(f,!0,!1),s())},seed:(f,h)=>{const b=performance.now(),x=Q(h.then(P=>P===null?Pe:{status:"loaded",document:P},()=>Pe)),A=n.get(f);if(A!==void 0&&A.snapshot.status==="loaded"){const P=A.snapshot,B={};A.background=B,x.then(I=>{if(I.status==="loaded"){p(f,A,B,P,I.document,b);return}A.background===B&&(A.background=null)});return}const j=A!==void 0&&A.snapshot.status==="pending"?A.snapshot.previous:null,O={status:"pending",promise:x,previous:j},N={snapshot:O,validatedAt:b,opened:A?.opened===!0,background:null,refreshPending:A?.refreshPending===!0,seeded:O};g(f,N),d(),x.then(P=>{n.get(f)===N&&(P.status==="deferred"&&r.isHeld(f)?m(f,N.opened,!1):N.snapshot=P,s())})},invalidate:()=>{let f=!1;for(const[h,b]of[...n]){if(b.validatedAt=Number.NEGATIVE_INFINITY,b.opened=!0,b.refreshPending=!0,!r.isHeld(h))continue;const{snapshot:x}=b;if(x.status!=="pending"){T(h,b)&&(f=!0);continue}x.promise.then(()=>{n.get(h)===b&&b.refreshPending&&r.isHeld(h)&&T(h,b)&&s()})}f&&s()},refresh:async f=>{const h=n.get(f);if(h!==void 0&&h.snapshot.status==="loaded"&&h.snapshot.document.kind!=="failure"){h.refreshPending=!0;const x=await S(f,h);return x===null?we:x.kind==="failure"?{status:"failed",failure:x.failure}:Fe}const b=m(f,!0,!0);return s(),b.snapshot.status!=="pending"?we:(await b.snapshot.promise,n.get(f)===b?Fe:we)},clear:()=>{n.clear();for(const f of r.heldKeys())m(f,!0,!1);s()},subscribe:o.subscribe,noteFailureShown:f=>i.has(f)?!1:(i.add(f),!0)}};function Ft({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 _t=y.forwardRef(Ft);function qt({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 Ht=y.forwardRef(qt),ue=({name:e,url:t,icon:n,children:r})=>{const{labels:o}=D();return c.jsxs("div",{className:"aqmx-document-toolbar",children:[c.jsx("span",{className:"aqmx-document-file-icon","aria-hidden":"true",children:n}),c.jsx("span",{className:"aqmx-document-title",title:e,"data-testid":"markdown-explorer-file-name",children:e}),r,c.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:c.jsx(Ht,{})}),c.jsx("a",{className:"aqmx-icon-button",href:t,download:e,"aria-label":o.download,title:o.download,"data-testid":"markdown-explorer-file-download",children:c.jsx(_t,{})})]})};function Bt({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 zt=y.forwardRef(Bt),It=({document:e})=>{const{labels:t}=D();return c.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[c.jsx(ue,{name:e.name,url:e.url,icon:c.jsx(zt,{})}),c.jsx("div",{className:"aqmx-document-stage",children:c.jsxs("div",{className:"aqmx-callout",role:"note","data-testid":"markdown-explorer-file-not-shown",children:[c.jsx("p",{className:"aqmx-callout-body",children:t.fileNotShown}),c.jsx("a",{className:"aqmx-callout-action",href:e.url,download:e.name,"data-testid":"markdown-explorer-file-not-shown-download",children:t.download})]})})]})},Ne="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",Ut=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},de=e=>{if(!e.startsWith("#")||e.length===1)return null;try{return decodeURIComponent(e.slice(1))}catch{return null}},ft=e=>`#${encodeURIComponent(e)}`,Zt=e=>{if(e==="#")return!0;const t=de(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},ye=(e,t)=>{for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},Vt=(e,t)=>{const n=e===null?null:de(t);return e===null||n===null?null:ye(e,n)},_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"},Wt=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"},Kt=(e,t)=>{const n=t.closest(Ne),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&_e(r))return r;const o=e.getBoundingClientRect().height,{documentElement:i,scrollingElement:s}=e.ownerDocument;for(let d=e.parentElement;d!==null&&d!==i;d=d.parentElement)if(_e(d)&&d.scrollHeight>d.clientHeight&&d.clientHeight<o)return d;return s instanceof Element&&Wt(e.ownerDocument)&&s.scrollHeight>s.clientHeight&&s.clientHeight<o?s:r},Gt=Object.freeze({scrollerOf:Kt,reveal:e=>{e.scrollIntoView(Re)}}),Re=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),Xt=(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")}}},Yt=(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),i=Number.parseFloat(r),s=t.getBoundingClientRect(),d=s.height+i+Number.parseFloat(o)>e.clientHeight;if(!d&&Math.abs(s.top-i-n)<1){t.scrollIntoView(Re);return}e.scrollBy({top:d?s.top-n-e.clientHeight:s.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(Re)},Jt=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(Ne)??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=Vt(e,t);return r===null?(Zt(t)&&Jt(e,n),null):(Xt(e,r),Yt(n.scrollerOf(e,r),r),n.reveal(r),r)};function Qt({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 en=y.forwardRef(Qt);function tn({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 nn=y.forwardRef(tn);function rn({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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"}),y.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 on=y.forwardRef(rn);function sn({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 ln=y.forwardRef(sn),ke="data-aqmx-key-repeat",Te=Object.freeze({[ke]:"allow"}),an=`[${ke}="${Te[ke]}"]`,cn=()=>{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(an)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},oe=Object.freeze([1/F.GOLDEN_RATIO**2,1/F.GOLDEN_RATIO,1,F.GOLDEN_RATIO,F.GOLDEN_RATIO**2]),He=Object.freeze({mode:"fit"}),un=1,mt=a.createContext(null),dn=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=un?{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<oe.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?oe.findIndex(o=>o>t):oe.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}},fn=e=>{const t=oe[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},mn=({document:e})=>{const{labels:t}=D(),n=a.use(mt),[r]=a.useState(()=>n===null?null:n.read(e.url)),[o,i]=a.useState(r===null?He:r.zoom),[s,d]=a.useState(r===null?null:r.reported),[g,w]=a.useState(null),m=a.useRef(null),p=a.useCallback(h=>{const{naturalWidth:b,naturalHeight:x}=h;d(A=>Ie(A,b,x))},[]),S=a.useCallback(h=>{m.current=h,!(h===null||!h.complete)&&(h.naturalWidth>0||h.naturalHeight>0?p(h):h.decode().then(()=>p(h),()=>{}))},[p]);a.useEffect(()=>{n!==null&&s!==null&&n.save(e.url,{zoom:o,reported:s})},[n,e.url,o,s]),a.useLayoutEffect(()=>{const h=m.current;if(h===null||s===null||o.mode!=="fit")return;const b=()=>w(A=>Ie(A,h.clientWidth,h.clientHeight));if(b(),typeof ResizeObserver>"u")return;const x=new ResizeObserver(b);return x.observe(h),()=>x.disconnect()},[s,o.mode]);const T=s===null||g===null?null:dn(s,g),R=ze(o,T,-1),L=ze(o,T,1),k=o.mode==="level"?fn(o.index):null,f=o.mode==="level"&&k!==null?{width:`${o.base.width*k}px`,height:`${o.base.height*k}px`}:void 0;return c.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[c.jsxs(ue,{name:e.name,url:e.url,icon:c.jsx(ln,{}),children:[c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":R===null,onClick:()=>{R!==null&&i(R)},...Te,children:c.jsx(nn,{})}),c.jsx("output",{className:"aqmx-document-level","aria-live":"polite","data-testid":"markdown-explorer-image-level",children:k===null?t.imageFitLevel:t.imageZoomLevel(Math.round(k*100))}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":L===null,onClick:()=>{L!==null&&i(L)},...Te,children:c.jsx(on,{})}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>i(He),children:c.jsx(en,{})})]}),c.jsx("div",{className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas",children:c.jsx("img",{ref:S,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:f,onLoad:h=>p(h.currentTarget),"data-testid":"markdown-explorer-image"})})]})},gt=a.createContext(null),fe=a.createContext(void 0),ht=a.createContext(null),me=()=>{const e=a.use(gt);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},gn=()=>{const e=a.use(ht);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},ge=(e,t,n,r)=>t.kind==="panel"?F.explorerHref(e,{view:"tree",source:n,doc:r}):t.view==="single"?F.explorerHref(e,{view:"single",source:n,doc:r,overrides:t.overrides,embed:t.embed}):F.explorerHref(e,{view:"tree",source:n,doc:r,overrides:t.overrides}),hn=({children:e})=>{const{config:t}=D(),n=me(),r=ie(),o=r.kind==="location"?r.location.source:void 0,i=U.useHref(ge(t,n.navigation,o,n.currentPath));return c.jsx(fe,{value:o,children:c.jsx(ht,{value:i,children:e})})},pn='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',wn=e=>{const t=e instanceof Element?e.closest(pn):null;return t===null?null:t.getAttribute("data-doc-path")},he=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,vn=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:i,onDocumentLink:s,scope:d,children:g})=>{const w=U.useHref(e),m=p=>{if(he(p)){if(p.preventDefault(),t===d.currentPath&&n!==""){d.scrollWithin(n);return}s(t,n)}};return c.jsx("a",{...i,href:w,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:m,children:g})},En=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:i})=>{const{config:s}=D(),d=me(),g=a.use(fe),w=Ut(e),{navigation:m}=d,p=`${ge(s,m,g,t)}${w}`,S=n===!1?"false":void 0;return m.kind==="page"?c.jsx(lt,{...o,to:p,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":S,children:i}):c.jsx(vn,{to:p,docPath:t,fragment:w,exists:S,className:r,attributes:o,onDocumentLink:m.onDocumentLink,scope:d,children:i})},xn=({className:e,attributes:t,children:n})=>{const{labels:r}=D();return c.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,c.jsxs("span",{className:"aqmx-sr-only",children:[" (",r.inertLink,")"]})]})},bn=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:i}=D(),s=a.use(fe),d=U.useHref(`${ge(i,r.navigation,s,r.currentPath)}${e}`),g=w=>{he(w)&&(w.preventDefault(),r.scrollWithin(e))};return c.jsx("a",{...n,href:d,className:t,onClick:g,children:o})},Sn=({href:e,className:t,attributes:n,children:r})=>{const o=me();if(o.navigation.kind==="page"){const i=s=>{if(!he(s))return;const d=s.currentTarget;e==="#"?o.followEmptyFragment(s.nativeEvent):d.href===d.ownerDocument.URL&&o.followSameUrlJump(e,s.nativeEvent)};return c.jsx("a",{...n,href:e,className:t,onClick:i,children:r})}return c.jsx(bn,{href:e,className:t,attributes:n,scope:o,children:r})},yn=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:i,children:s})=>t==="doc"?n===void 0||!H.isAcceptableDocumentPath(n)?c.jsx(xn,{className:o,attributes:i,children:s}):c.jsx(En,{href:e,docPath:n,docExists:r,className:o,attributes:i,children:s}):e.startsWith("#")?c.jsx(Sn,{href:e,className:o,attributes:i,children:s}):c.jsx("a",{...i,href:e,className:o,children:s}),Rn=()=>{const{config:e}=D(),t=me(),n=a.use(fe),r=ae();return a.useCallback((o,i)=>{if(!he(i)||(i.preventDefault(),o.id===""))return!0;const s=ft(o.id),{navigation:d}=t;return d.kind==="panel"||de(i.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(s),!0):(r(`${ge(e,d,n,t.currentPath)}${s}`,"follow-link"),!0)},[e,t,n,r])},kn=()=>{const e=gn();return a.useCallback(t=>t.id===""?e:`${e}${ft(t.id)}`,[e])};function Tn({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 An=y.forwardRef(Tn);function Ln({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 On=y.forwardRef(Ln);function Cn({title:e,titleId:t,...n},r){return y.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?y.createElement("title",{id:t},e):null,y.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 Mn=y.forwardRef(Cn),jn=e=>{switch(e){case"video":return c.jsx(On,{});case"audio":return c.jsx(Mn,{});case"pdf":return c.jsx(An,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},Nn=({document:e})=>{const{labels:t}=D();switch(e.mediaType){case"video":return c.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 c.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 c.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)}`)}}},$n=({document:e})=>c.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[c.jsx(ue,{name:e.name,url:e.url,icon:jn(e.mediaType)}),c.jsx("div",{className:"aqmx-document-stage",children:c.jsx(Nn,{document:e})})]}),Dn=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}),pt=(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},wt=(e,t)=>e!==void 0?e:t!==void 0?t:yt.DEFAULT_CONTENT_ALIGN,Pn=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),Fn=(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"?F.explorerHref(e,{view:"single",source:t.source,doc:t.doc,overrides:r,embed:t.embed}):F.explorerHref(e,{view:"tree",source:t.source,doc:t.doc,overrides:r})},Ae=a.createContext("fill"),$e=({kind:e,label:t,stale:n,busy:r,frameRef:o,intent:i,children:s})=>{const d=a.use(Ae);return c.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":d,className:"aqmx-document",...i,children:[n?c.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,s]})},_n=()=>{const{labels:e}=D();return c.jsx($e,{kind:"empty",label:e.documentRegion,stale:!1,busy:!1,children:c.jsx("div",{className:"aqmx-empty","data-testid":"markdown-explorer-document-empty",children:c.jsx("p",{className:"aqmx-empty-title",children:e.documentEmpty})})})},vt=({label:e})=>{const{labels:t}=D();return c.jsxs($e,{kind:"loading",label:e,stale:!1,busy:!0,children:[c.jsx("div",{className:"aqmx-skeleton","aria-hidden":"true","data-testid":"markdown-explorer-document-skeleton",children:Pn.map(n=>c.jsx("span",{},n))}),c.jsx("p",{className:"aqmx-sr-only",children:t.documentLoading})]})},qn=({path:e,document:t,viewer:n})=>{const{reportMathDiagnostics:r}=D(),o=a.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),i=Rn(),s=kn(),d=a.useMemo(()=>r===void 0?void 0:g=>r(e,g),[r,e]);return c.jsx("div",{className:"aqmx-document-viewer",children:c.jsx(Oe.MarkdownViewer,{...n,onHeadingSelect:i,headingHref:s,onMathDiagnostics:d,parseResult:o,content:null})})},Hn=({document:e,viewer:t})=>{const{labels:n}=D();return c.jsxs(c.Fragment,{children:[c.jsx(ue,{name:e.name,url:e.url,icon:c.jsx(Nt,{})}),e.truncated?c.jsx("p",{className:"aqmx-callout aqmx-document-notice",role:"note","data-testid":"markdown-explorer-text-truncated",children:n.textTruncated}):null,c.jsx("div",{className:"aqmx-document-viewer",children:c.jsx(Oe.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},Bn=({path:e,document:t,viewer:n,onRetry:r})=>{switch(t.kind){case"markdown":return c.jsx(qn,{path:e,document:t,viewer:n});case"text":return c.jsx(Hn,{document:t,viewer:n});case"image":return c.jsx(mn,{document:t});case"media":return c.jsx($n,{document:t});case"file":return c.jsx(It,{document:t});case"failure":return c.jsx("div",{className:"aqmx-document-failure","data-aqmx-document-scroller":"",children:c.jsx(at,{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)}`)}}},zn='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',In=(e,t,n)=>{const r=n===null?null:de(n),[o]=t.kind==="markdown"?t.headings:[],i=[r===null?null:ye(e,r),o===void 0?null:ye(e,o.id),e.querySelector(Ne),e.querySelector(zn)];for(const s of i)if(s instanceof HTMLElement&&je(s))return s;return null},Ue=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,i=r===null||r===o;t instanceof HTMLElement&&n&&(i||e.contains(r))&&je(t)},Un=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 i=!1,s;const d=S=>{i=!(S.target instanceof Node&&n.contains(S.target)),i&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(s),s=setTimeout(()=>{i=!1},0)},g=S=>{t.current=S.target instanceof Node&&n.contains(S.target)},w=S=>{S.relatedTarget===null&&i&&(t.current=!1)},m=()=>{const{activeElement:S,body:T}=r;S!==null&&S!==T&&(t.current=n.contains(S))},p=()=>{i&&!n.contains(r.activeElement)&&(t.current=!1)};return o.addEventListener("pointerdown",d,!0),o.addEventListener("mousedown",d,!0),o.addEventListener("focusin",g,!0),o.addEventListener("blur",m),o.addEventListener("focus",p),n.addEventListener("focusout",w),()=>{clearTimeout(s),o.removeEventListener("pointerdown",d,!0),o.removeEventListener("mousedown",d,!0),o.removeEventListener("focusin",g,!0),o.removeEventListener("blur",m),o.removeEventListener("focus",p),n.removeEventListener("focusout",w)}},[e]),t},Zn=({path:e,snapshot:t,stale:n,viewer:r,regionLabel:o,navigation:i,fragment:s,paneScroll:d,announces:g,announceFailure:w,onDocumentShown:m})=>{const{labels:p,announcer:S,documents:T}=D(),{document:R}=t,L=a.useRef(null),k=a.useRef(null),f=a.useRef(null),h=a.useRef(0),b=Un(L),x=a.useRef({path:e,document:R}),A=a.useRef(null),j=a.useCallback(l=>{const u=L.current,v=qe(u,l,d);u!==null&&v!==null&&Ue(u,v,b.current)},[d,b]),O=a.useCallback((l,u)=>{const v=h.current;setTimeout(()=>{!u.defaultPrevented&&h.current===v&&j(l)},0)},[j]),N=a.useCallback(l=>{setTimeout(()=>{l.defaultPrevented||j("#")},0)},[j]),P=a.useMemo(()=>({navigation:i,currentPath:e,scrollWithin:j,followSameUrlJump:O,followEmptyFragment:N}),[i,e,j,O,N]),B=a.useCallback(()=>T.retry(e),[T,e]),I=ct(T,wn),$=a.useEffectEvent((l,u)=>{const v=k.current;if(v!==null&&v.path===l&&v.snapshot===u)return;k.current={path:l,snapshot:u};const E=u.document;if(E.kind==="failure"){T.noteFailureShown(u)&&w(p.documentFailed(H.lastPathSegment(l),ce(p,E.failure.reason)));return}m?.(l,E),g&&(v===null||v.path!==l||v.snapshot.document.kind==="failure")&&S.announce(p.documentShown(E.name))});a.useEffect(()=>{$(e,t)},[e,t]);const z=a.useEffectEvent(()=>{s.kind==="panel"&&s.consume()}),G=a.useEffectEvent(l=>{const u=L.current;if(u===null||!b.current)return null;const{activeElement:v,body:E}=u.ownerDocument;return v!==null&&v!==E?null:In(u,R,l)}),Y=a.useEffectEvent(l=>{const u=L.current;u!==null&&Ue(u,l,b.current)}),Z=a.useEffectEvent(l=>d.reveal(l)),pe=a.useEffectEvent(l=>qe(L.current,l,d));return a.useEffect(()=>{if(n)return;const l=x.current.path!==e,u=l||x.current.document!==R;x.current={path:e,document:R};const v=A.current!==e;A.current=e;let E=null;s.kind==="page"?f.current!==s.navigation&&(f.current=s.navigation,h.current+=1,E=s.fragment):s.fragment!==null&&(E=s.fragment,z());const C=()=>{const M=E===null?null:pe(E);if(!u){M!==null&&Y(M);return}const _=G(s.fragment);l&&M===null&&_!==null&&Z(_)};v?queueMicrotask(C):C()},[s,e,R,n]),c.jsx($e,{kind:R.kind,label:o(e,R),stale:n,busy:n,frameRef:L,intent:I,children:c.jsx(gt,{value:P,children:c.jsx(hn,{children:c.jsx(Bn,{path:e,document:R,viewer:r,onRetry:B},e)})})})},De=Object.freeze({kind:"skeleton"}),Vn=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const i=le(t);if(i!==null)return{kind:"document",path:e,snapshot:i,stale:!0};if(o&&t?.status==="pending")return{kind:"streaming",path:e,promise:t.promise};const s=n===null||n===e?null:le(r);return n===null||s===null?De:{kind:"document",path:n,snapshot:s,stale:!0}},Wn=(e,t)=>t.status==="deferred"?De:{kind:"document",path:e,snapshot:t,stale:!1},Kn=({requestedPath:e,content:t,...n})=>{const r=t.kind==="streaming"?Wn(t.path,a.use(t.promise)):t;return r.kind!=="document"?c.jsx(vt,{label:n.regionLabel(e,null)}):c.jsx(Zn,{path:r.path,snapshot:r.snapshot,stale:r.stale,...n})},Et=({path:e,display:t,navigation:n,fragment:r,paneScroll:o,announces:i,announceFailure:s,onDocumentShown:d})=>{const{config:g,labels:w,theme:m,documents:p}=D(),S=Oe.useMarkdownToolbarState(),T=a.useRef(!1);a.useLayoutEffect(()=>{T.current=!0},[]);const[R,L]=a.useState(null),k=a.useCallback(()=>e===null?void 0:p.peek(e),[p,e]),f=a.useSyncExternalStore(p.subscribe,k,k),h=a.useCallback(()=>R===null?void 0:p.peek(R),[p,R]),b=a.useSyncExternalStore(p.subscribe,h,h);a.useLayoutEffect(()=>e===null?void 0:p.open(e),[p,e]),a.useLayoutEffect(()=>R===null?void 0:p.retain(R),[p,R]);const x=e===null?De:Vn(e,f,R,b,!T.current),A=e===null?null:x.kind==="document"&&!x.stale?x.path:R;A!==R&&L(A);const j=a.useMemo(()=>Dn(w),[w]),O=a.useMemo(()=>[...g.iframeHosts],[g]),N=a.useMemo(()=>({labels:j,emptyMessage:w.documentEmpty,theme:m,availableStyles:g.documentStyles,iFrameAllowedDomains:O,linkComponent:yn,toolbar:S,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%)`}),[j,w.documentEmpty,m,g.documentStyles,O,S,t]),P=n.kind==="panel",B=a.useCallback(($,z)=>P?z===null||z.kind==="failure"?H.lastPathSegment($):z.name:w.documentRegion,[P,w.documentRegion]),I=P?"content":"fill";return e===null?c.jsx(Ae,{value:I,children:c.jsx(_n,{})}):c.jsx(Ae,{value:I,children:c.jsx(a.Suspense,{fallback:c.jsx(vt,{label:B(e,null)}),children:c.jsx(Kn,{requestedPath:e,content:x,viewer:N,regionLabel:B,navigation:n,fragment:r,paneScroll:o,announces:i,announceFailure:s,onDocumentShown:d})})})},Gn=({path:e,variant:t,onDocumentShown:n})=>{const{config:r,viewSettings:o,announcer:i}=D(),s=J(O=>O.style),d=J(O=>O.align),g=ae(),w=U.useLocation(),m=ie(),{view:p,overrides:S,embed:T}=t,R=a.useCallback(O=>{if(m.kind!=="location")return;const N=Fn(r,m.location,O);N!==null&&g(N,"browse")},[r,g,m]),L=a.useCallback(O=>{o.update({style:O}),R("style")},[o,R]),k=a.useCallback(O=>{o.update({align:O}),R("align")},[o,R]),f=pt(r,S.style,s),h=wt(S.align,d),b=a.useMemo(()=>({style:f,onStyleChange:L,align:h,onAlignChange:k,showToc:T.showToc!==!1,showStyle:T.showStyle!==!1,showAlign:T.showAlign!==!1,padding:T.padding,width:T.width,maxWidth:T.maxWidth}),[f,L,h,k,T]),x=a.useMemo(()=>({kind:"page",view:p,overrides:S,embed:T}),[p,S,T]),A=a.useMemo(()=>({kind:"page",fragment:w.hash,navigation:w}),[w]),j=a.useCallback(O=>i.announce(O),[i]);return c.jsx(Et,{path:e,display:b,navigation:x,fragment:A,paneScroll:Gt,announces:!0,announceFailure:j,onDocumentShown:n})},Xn=({path:e,variant:t,onDocumentShown:n})=>{const{config:r,viewSettings:o}=D(),i=J(x=>x.style),s=J(x=>x.align),[d,g]=a.useState(()=>pt(r,void 0,i)),w=wt(void 0,s),m=a.useCallback(x=>o.update({align:x}),[o]),{maximized:p,onDocumentLink:S,pendingHash:T,onHashConsumed:R,announceFailure:L,paneScroll:k}=t,f=a.useMemo(()=>({style:d,onStyleChange:g,align:w,onAlignChange:m,showToc:p,showStyle:p,showAlign:p,padding:void 0,width:void 0,maxWidth:void 0}),[d,w,m,p]),h=a.useMemo(()=>({kind:"panel",onDocumentLink:S}),[S]),b=a.useMemo(()=>({kind:"panel",fragment:T,consume:R}),[T,R]);return c.jsx(Et,{path:e,display:f,navigation:h,fragment:b,paneScroll:k,announces:!1,announceFailure:L,onDocumentShown:n})},xt=({path:e,variant:t,onDocumentShown:n})=>t.kind==="page"?c.jsx(Gn,{path:e,variant:t,onDocumentShown:n}):c.jsx(Xn,{path:e,variant:t,onDocumentShown:n}),Yn=({location:e})=>{const{labels:t,documents:n,announcer:r}=D(),o=e.doc,i=a.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]),s=a.useCallback(()=>n.peek(o),[n,o]),d=a.useCallback(()=>n.peekSeeded(o),[n,o]),g=a.useSyncExternalStore(n.subscribe,s,d),[w,m]=a.useState(!1),[p,S]=a.useState(null),T=a.useRef(!1),R=w||g?.status==="pending",L=a.useCallback(async()=>{if(!(T.current||R)){T.current=!0,m(!0),S(null);try{const k=await n.refresh(o);if(k.status==="failed"){S({path:o,failure:k.failure});return}if(k.status==="superseded")return;const f=le(n.peek(o));if(f===null||f.document.kind==="failure")return;r.announce(t.documentRefreshed(f.document.name))}finally{T.current=!1,m(!1)}}},[R,n,o,r,t]);return c.jsxs("div",{className:"aqmx-single","data-testid":"markdown-explorer-single",children:[c.jsx("div",{className:"aqmx-single-toolbar","data-testid":"markdown-explorer-single-toolbar",children:c.jsxs("button",{type:"button",className:"aqmx-icon-button aqmx-labelled-button",title:t.refreshDocument,"aria-disabled":R,"aria-busy":w,"data-aqmx-busy":w?"true":void 0,"data-testid":"markdown-explorer-single-refresh",onClick:()=>{L()},children:[c.jsx(st,{"aria-hidden":"true"}),c.jsx("span",{children:t.refresh})]})}),p!==null&&p.path===o?c.jsx("p",{role:"alert",className:"aqmx-single-refresh-failure","data-testid":"markdown-explorer-single-refresh-failure","data-aqmx-failure":p.failure.reason,children:t.documentRefreshFailed(ce(t,p.failure.reason))}):null,c.jsx(xt,{path:o,variant:i})]})},bt=({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 i=a.useCallback(()=>r.shownIn(o),[r,o]),s=a.useSyncExternalStore(r.subscribe,i,i);return c.jsx("div",{className:"aqmx-sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":t,children:s.length>1?n.announcementSequence(s):s[0]})},X=Object.freeze([]),Ze=e=>{const t=new Set;let n=X,r=[],o=!1;const i=[],s=m=>{n=m;for(const p of[...t])p()},d=()=>i.at(-1)?.region,g=m=>{const p=d();m(),d()!==p&&n!==X&&s(X)},w=()=>{o=!1;const m=r.map(p=>"sentence"in p?p.sentence:p.list(p.items));r=[],s(Object.freeze(m))};return{announce:m=>{if(typeof m=="string")r.push({sentence:m});else{const p=r.find(S=>"list"in S&&S.list===m.list);p!==void 0&&"items"in p?p.items.push(m.item):r.push({list:m.list,items:[m.item]})}o||(o=!0,n!==X&&s(X),e.request(w))},subscribe:m=>(t.add(m),()=>{t.delete(m)}),claim:m=>{const p={region:m};return g(()=>i.push(p)),()=>g(()=>{const S=i.indexOf(p);S!==-1&&i.splice(S,1)})},shownIn:m=>d()===m?n:X}},Jn=Object.freeze({status:"cancelled"}),Qn=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(H.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return H.failureOf(n,r)},er=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((d,g)=>globalThis.fetch(d,g)),o=(d,g)=>`${e}/${d}?${new URLSearchParams(g).toString()}`,i=async(d,g,w,m)=>{let p;try{p=await r(d,{credentials:"same-origin",...g,headers:{Accept:"application/json",...g.headers}})}catch{return m({reason:"failed"})}p.status===401&&t(null);const S=p.headers.get(H.EXPLORER_SCOPE_HEADER);S!==null&&t(S);let T;try{T=await p.json()}catch{return m({reason:H.failureReasonOfStatus(p.status)})}let R;try{R=w(T)}catch{R=!1}if(R)return T;const L=Qn(T);return m(L!==null?L:{reason:p.status===200?"failed":H.failureReasonOfStatus(p.status)})},s={[H.EXPLORER_REFRESH_HEADER]:H.EXPLORER_REFRESH_HEADER_VALUE};return{tree:d=>i(o("tree",{[H.EXPLORER_DATA_QUERY.source]:d}),{method:"GET"},H.isExplorerTreeResult,g=>({status:"error",failure:g})),children:async(d,g,w)=>{const m=await i(o("children",{[H.EXPLORER_DATA_QUERY.source]:d,[H.EXPLORER_DATA_QUERY.path]:g}),{method:"GET",signal:w},H.isExplorerChildrenResult,p=>({status:"error",failure:p}));return w.aborted?Jn:m},document:(d,{refresh:g})=>i(o("document",{[H.EXPLORER_DATA_QUERY.path]:d}),g?{method:"GET",headers:s}:{method:"GET"},H.isExplorerDocument,w=>H.failureDocument(w.reason,w.code)),refresh:d=>i(o("refresh",{[H.EXPLORER_DATA_QUERY.source]:d}),{method:"POST",headers:s},H.isExplorerTreeResult,g=>({status:"error",failure:g}))}},tr=e=>{const t=K.readStorage(e);if(t===null)return F.NO_TREE_SETTING_CHANGES;try{return F.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),F.NO_TREE_SETTING_CHANGES}},Ve=(e,t)=>{let n=null;const r=()=>{if(n===null){const i=tr(e);n={changes:i,settings:F.applyTreeSettingChanges(t,i)}}return n},o=ee();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:i=>{const{changes:s,settings:d}=r(),g=F.recordTreeSettingChange(s,i,F.advanceTreeSetting(d,i)[i],t);return n={changes:g,settings:F.applyTreeSettingChanges(t,g)},o.emit(),K.writeStorage(e,F.serializeTreeSettingChanges(g)),n.settings}}},nr=Object.freeze({status:"refreshed"}),rr=Object.freeze({status:"superseded"}),Le=Object.freeze({status:"deferred"}),or=dt(Le),St=4,sr=St-1,We=Object.freeze({status:"loading"}),lr=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),ir=e=>{const t=new Map,n=ut(),r=new Map,o=new Map,i=new Map,s=new Map,d=ee(),g=new Set;let w=0,m=0;const p={direct:null,bulk:null},S=new Set;let T=!1,R=0;const L=()=>{R+=1,d.emit()},k=l=>o.get(l)??0,f=l=>{let u=s.get(l);return u===void 0&&(u={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},s.set(l,u)),u},h=(l,u,v)=>{l.inFlight.delete(u),w-=1,v.lane==="bulk"&&(m-=1)},b=l=>{const u=s.get(l);if(u!==void 0){for(const[v,E]of[...u.inFlight])h(u,v,E),E.controller.abort();u.direct.clear(),u.bulk.clear(),u.unclaimed.clear()}},x=l=>{const u=k(l)+1;return o.set(l,u),b(l),u},A=(l,u)=>{const v=te(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},j=l=>{let u=r.get(l);return u===void 0&&(u=new Map,r.set(l,u)),u},O=l=>{const u=[...s.keys()],v=p[l],E=v===null?0:u.indexOf(v)+1;for(let C=0;C<u.length;C+=1){const M=u[(E+C)%u.length],_=M===void 0?void 0:s.get(M);if(!(M===void 0||_===void 0)){for(const q of _[l])if((_.claims.get(q)??0)!==0)return _[l].delete(q),p[l]=M,{sourceId:M,path:q}}}return null},N=(l,u,v,E)=>{const C=s.get(l);if(C===void 0||C.inFlight.get(u)!==v)return;h(C,u,v);const M=(C.claims.get(u)??0)>0,_=j(l);if(E.status==="ok"?_.set(u,{status:"loaded",entries:E.entries}):E.status==="error"&&M?_.set(u,{status:"failed",failure:E.failure}):_.delete(u),L(),E.status==="error"&&M){const q={sourceId:l,path:u,failure:E.failure};for(const V of[...g])V(q)}B()},P=(l,u,v)=>{const E={controller:new AbortController,lane:v};f(l).inFlight.set(u,E),w+=1,v==="bulk"&&(m+=1),e.children(l,u,E.controller.signal).then(C=>N(l,u,E,C),()=>N(l,u,E,lr))},B=()=>{for(;w<St;){const l=O("direct");if(l!==null){P(l.sourceId,l.path,"direct");continue}const u=m<sr?O("bulk"):null;if(u===null)return;P(u.sourceId,u.path,"bulk")}},I=(l,u,v)=>{if(!(u.direct.delete(v)||u.bulk.delete(v))){const C=u.inFlight.get(v);if(C===void 0)return!1;h(u,v,C),C.controller.abort()}return r.get(l)?.delete(v),!0},$=()=>{T=!1;let l=!1;for(const u of S){const v=f(u);for(const E of v.unclaimed)(v.claims.get(E)??0)===0&&I(u,v,E)&&(l=!0);v.unclaimed.clear()}S.clear(),l&&(L(),B())},z=(l,u)=>{t.set(l,A(Q(e.tree(l)),u))},G=(l,u,v)=>{x(l);const E=A(dt(u),v);return t.set(l,E),r.delete(l),L(),B(),E},Y=(l,u,v,E)=>{if(v!==k(l)||t.get(l)!==u)return;const C=te(u.promise);if(!(E.status!=="ok"||C?.status!=="ok"||u.loadedAt===null||E.loadedAt<=u.loadedAt)){if(se(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&&te(v.promise)?.status===u},pe=(l,u)=>{u.stale=!1;const v=k(l);e.tree(l).then(E=>Y(l,u,v,E))};return{read:l=>t.get(l)?.promise??or,open:l=>{const u=n.resumes(l),v=n.hold(l),E=t.get(l);return E===void 0||Z(l,"deferred")?(z(l,!0),L()):u||(E.opened&&Z(l,"error")?(z(l,!0),L()):(E.opened=!0,E.stale&&Z(l,"ok")&&pe(l,E))),v},retry:l=>{Z(l,"error")&&(z(l,!0),L())},seed:(l,u)=>{const v=u.then(M=>M===null?Le:M,()=>Le),E=t.get(l);if(E!==void 0&&Z(l,"ok")){const M=k(l);v.then(_=>Y(l,E,M,_));return}x(l);const C=A(Q(v),E?.opened===!0);t.set(l,C),r.delete(l),B(),v.then(M=>{t.get(l)===C&&(M.status==="deferred"&&n.isHeld(l)&&z(l,C.opened),L())})},refresh:async l=>{const u=(i.get(l)??0)+1;i.set(l,u);const v=await e.refresh(l);if(i.get(l)!==u)return rr;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 M=G(l,v,!0);if(E!==void 0&&E.promise.status==="pending"){const _=k(l);E.promise.then(q=>Y(l,M,_,q))}}for(const[M,_]of t)M!==l&&te(_.promise)?.status==="ok"&&(_.stale=!0);return nr},children:(l,u)=>r.get(l)?.get(u),claimChildren:(l,u)=>{const v=f(l),E=j(l);let C=!1,M=!1;for(const[q,V]of u)v.claims.set(q,(v.claims.get(q)??0)+1),E.get(q)===void 0?(E.set(q,We),v[V].add(q),C=!0,M=!0):V==="direct"&&v.bulk.delete(q)&&(v.direct.add(q),M=!0);C&&L(),M&&B();let _=!1;return()=>{if(!_){_=!0;for(const q of u.keys()){const V=(v.claims.get(q)??0)-1;V>0?v.claims.set(q,V):(v.claims.delete(q),v.unclaimed.add(q))}S.add(l),!T&&(T=!0,queueMicrotask($))}}},retryChildren:(l,u)=>{const v=r.get(l);if(v===void 0||v.get(u)?.status!=="failed")return;const E=f(l);if((E.claims.get(u)??0)>0){v.set(u,We),E.direct.add(u),L(),B();return}v.delete(u),L()},pendingChildren:l=>{const u=s.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(),...s.keys()]))x(l);for(const[l,u]of i)i.set(l,u+1);t.clear(),r.clear(),L()},subscribeChildrenFailures:l=>(g.add(l),()=>{g.delete(l)}),subscribe:d.subscribe,version:()=>R}},ar=(e,t)=>{let n=e;const r=ee();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},cr=1;let ne=0,W=null;const ur=()=>{const{documentElement:e,body:t}=document;ne===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"),ne+=1;let n=!1;return()=>{n||(n=!0,ne-=1,!(ne>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))}},dr=[{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,ve="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.",fr=e=>{if(!Ge(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+cr)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. ${ve}`;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. ${ve}`;for(const{selector:r,name:o}of dr)for(const i of e.querySelectorAll(r)){if(!Ge(i))continue;const s=i.getBoundingClientRect().height;if(s<Ke)return`[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(s))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${ve}`}return null},mr=e=>{let t=!1;const n=()=>{if(t)return;const o=fr(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)}},gr=(e,t)=>{a.useEffect(()=>e?ur():void 0,[e]),a.useEffect(()=>{const n=t.current;if(!(!e||n===null))return mr(n)},[e,t])},Xe='[data-testid="markdown-explorer-view-switch"]',hr=[{control:Xe,successors:[Xe,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],pr=e=>{for(const t of hr){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},wr=(e,t)=>{const n=a.useRef(null);a.useEffect(()=>{const o=d=>{const g=e.current;n.current=g!==null&&d instanceof Element&&g.contains(d)?pr(d):null},i=d=>o(d.target);o(document.activeElement);const s=d=>{const g=d.target;d.relatedTarget!==null||!(g instanceof Element)||queueMicrotask(()=>{n.current?.element===g&&g.isConnected&&document.activeElement!==g&&(n.current=null)})};return document.addEventListener("focusin",i),document.addEventListener("focusout",s),()=>{document.removeEventListener("focusin",i),document.removeEventListener("focusout",s)}},[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 i=()=>{const g=document.activeElement;if(g!==null&&g!==document.body&&g!==o.element)return!0;const w=e.current;if(w===null)return!0;for(const m of o.control.successors)for(const p of w.querySelectorAll(m))if(p!==o.element&&(p.focus({preventScroll:!0}),document.activeElement===p))return!0;return!1};if(i())return;const s=e.current;if(s===null)return;const d=new MutationObserver(()=>{i()&&d.disconnect()});return d.observe(s,{childList:!0,subtree:!0}),()=>d.disconnect()},[t,e])},vr=a.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-9-20bbSM.cjs")).then(e=>({default:e.TreeLayout}))),Er=a.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-r_qx1Mfz.cjs")).then(e=>({default:e.MultiLayout}))),xr=64,Ye={request:e=>{requestAnimationFrame(e)}},Je=e=>{e.documents.clear(),e.trees.clear()},Ee=(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)},br=(e,t)=>{const[n,r]=a.useState(()=>({overrides:t,locale:e,labels:be(e,t)}));if(n.locale===e&&Ot(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:be(e,t)};return r(o),o.labels},Sr=(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 i={scope:t,store:Ve(e,n)};return o(i),i.store},yr=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},Rr=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:i,renderFrame:s,renderTreeFailure:d,lockDocumentScroll:g=!1,onMathDiagnostics:w})=>{K.assertStorageNamespace(n);const m=rt(r),p=Ct(i),S=br(m,o),{revalidate:T}=U.useRevalidator(),R=a.useRef(()=>{}),L=U.useHref(t.dataPath),[k]=a.useState(()=>{const $=er({dataPath:L,onScope:G=>R.current(G)}),z={documents:Pt({client:$,capacity:Math.max(xr,t.multiView.maxPanels*2)}),trees:ir($)};return Ee(z,e),K.syncStorageScope(n,e.scope),{data:$,...z,aligned:{pageData:e,storageNamespace:n,pendingReader:null}}});if(k.aligned.pageData!==e||k.aligned.storageNamespace!==n){const $=k.aligned.pageData;k.aligned.pageData=e,k.aligned.storageNamespace=n,$!==e&&($.scope!==e.scope?k.aligned.pendingReader=e:Ee(k,e)),K.syncStorageScope(n,e.scope)}const f=Sr(K.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);a.useLayoutEffect(()=>{const $=k.aligned.pendingReader;$!==null&&(k.aligned.pendingReader=null,Je(k),Ee(k,$))},[e,k]),a.useLayoutEffect(()=>{let $=!1;return R.current=z=>{z===e.scope||$||($=!0,z!==null&&(Je(k),K.clearExplorerStorage(n)),T())},()=>{R.current=()=>{}}},[e,T,k,n]);const h=a.useRef(t.settingsCookie);a.useLayoutEffect(()=>{h.current=t.settingsCookie},[t.settingsCookie]);const[b]=a.useState(()=>ar(e.settings,$=>{document.cookie=F.viewSettingsCookieString(h.current,$,window.location.protocol==="https:")})),x=yr(e.scope),A=a.useMemo(()=>Q(e.notices.catch(()=>[])),[e.notices]),j=e.sources.map($=>$.id).join(`
2
+ `),O=a.useMemo(()=>F.withExplorerSources(t,j.split(`
3
+ `)),[t,j]),N=a.useRef(w);a.useLayoutEffect(()=>{N.current=w},[w]);const[P]=a.useState(()=>($,z)=>{N.current?.($,z)}),B=w===void 0?void 0:P,I=a.useMemo(()=>({config:O,labels:S,locale:m,theme:p,storageNamespace:n,scope:e.scope,sources:e.sources,notices:A,documents:k.documents,trees:k.trees,data:k.data,viewSettings:b,treeSettings:f,announcer:x,renderTreeFailure:d,reportMathDiagnostics:B}),[O,S,m,p,n,e.scope,e.sources,A,k,b,f,x,d,B]);return c.jsx(ot,{value:I,children:c.jsx(Tr,{renderFrame:s,lockDocumentScroll:g},e.scope)})},kr=({ref:e,theme:t,view:n,children:r})=>{const[o]=a.useState(cn);return c.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})},Tr=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=D(),o=ie(),i=ae(),s=a.useRef(null);gr(t,s),a.useLayoutEffect(()=>{o.kind==="redirect"&&i(o.href,"browse")},[o,i]);const{location:d}=o,g=d.view;wr(s,g);const w=d.view==="tree"?c.jsx(a.Suspense,{fallback:c.jsx("section",{className:"aqmx-split-fallback","aria-label":r.explorerRegion,"aria-busy":"true","data-testid":"markdown-explorer-split-loading"}),children:c.jsx(vr,{location:d})}):d.view==="multi"?c.jsx(a.Suspense,{fallback:c.jsx("section",{className:"aqmx-stage-fallback","aria-label":r.multiRegion,"aria-busy":"true","data-testid":"markdown-explorer-stage-loading"}),children:c.jsx(Er,{location:d})}):c.jsx(Yn,{location:d}),m=c.jsxs(kr,{ref:s,theme:n,view:g,children:[w,c.jsx(bt,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?m:e({view:g,children:m})},Ar=({currentUrl:e,nextUrl:t,formMethod:n,defaultShouldRevalidate:r})=>n===void 0&&e.href===t.href&&r;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=Qe;exports.DocumentPane=xt;exports.EXPLORER_THEMES=Se;exports.ExplorerLink=lt;exports.FailureView=at;exports.ForwardRef=st;exports.ImageViewMemoryContext=mt;exports.LiveRegion=bt;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=nt;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Ce;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=et;exports.MARKDOWN_EXPLORER_LOCALES=xe;exports.MarkdownExplorer=Rr;exports.createEmitter=ee;exports.explorerNavigationOptions=$t;exports.failureTitleOf=ce;exports.focusWithoutScroll=je;exports.resolveMarkdownExplorerLabels=be;exports.shouldRevalidateExplorer=Ar;exports.useExplorer=D;exports.useExplorerLocation=ie;exports.useExplorerNavigate=ae;exports.useIntentPrefetch=ct;exports.useViewSetting=J;
package/dist/index.cjs ADDED
@@ -0,0 +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;
@@ -0,0 +1,12 @@
1
+ export { type ExplorerFrameRenderer, MarkdownExplorer, type MarkdownExplorerProps } from "./client/MarkdownExplorer.cjs";
2
+ export { clearExplorerStorage } from "./client/storage.cjs";
3
+ export { DEFAULT_VIEW_SLUGS, defineExplorerConfig, EXPAND_ALL_DEPTH_LIMITS, EXPAND_ALL_FOLDER_LIMITS, type ExplorerConfig, type ExplorerConfigInput, type ExplorerDocumentStyle, type ExplorerLocationConfig, type ExplorerView, type ExplorerViewSlugs, isExplorerSourceId, MULTI_VIEW_COLUMN_LIMITS, MULTI_VIEW_PANEL_LIMITS, withExplorerSources, } from "./core/config.cjs";
4
+ export { EXPLORER_FAILURE_REASONS, EXPLORER_MAX_HEADINGS, type ExplorerChildrenResult, type ExplorerDocument, type ExplorerEntry, type ExplorerFailure, type ExplorerFailureDocument, type ExplorerFailureReason, type ExplorerHeading, type ExplorerMediaType, type ExplorerNotice, type ExplorerPageData, type ExplorerSeededDocument, type ExplorerSourceSummary, type ExplorerTreeResult, failureDocument, failureOf, isExplorerChildrenResult, isExplorerFailureCode, isExplorerFailureReason, } from "./core/contracts.cjs";
5
+ export { COLUMN_MIN_MEASURE, EXPLORER_DEFAULT_PERCENT, EXPLORER_MAX_PERCENT, EXPLORER_MIN_REM, EXPLORER_MULTI_DEFAULT_PERCENT, GOLDEN_RATIO } from "./core/geometry.cjs";
6
+ export { DEFAULT_MARKDOWN_EXPLORER_LOCALE, MARKDOWN_EXPLORER_LABEL_CATALOGS, MARKDOWN_EXPLORER_LABEL_KEYS, MARKDOWN_EXPLORER_LABEL_TEMPLATES, MARKDOWN_EXPLORER_LOCALES, type MarkdownExplorerLabelKey, type MarkdownExplorerLabelOverrides, type MarkdownExplorerLabels, type MarkdownExplorerLocale, resolveMarkdownExplorerLabels, } from "./core/labels.cjs";
7
+ export { type ExplorerEmbedOptions, type ExplorerHrefTarget, type ExplorerLocation, type ExplorerLocationResult, type ExplorerOverrides, type ExplorerSourcelessHrefTarget, explorerHref, resolveExplorerLocation, } from "./core/location.cjs";
8
+ export { DEFAULT_DENIED_PATH_SEGMENTS, type ExplorerPathRules, isAcceptableDocumentPath, isDeniedPath, MAX_DOCUMENT_PATH_LENGTH } from "./core/paths.cjs";
9
+ export { shouldRevalidateExplorer } from "./core/revalidation.cjs";
10
+ export { EXPLORER_THEMES, type ExplorerTheme } from "./core/theme.cjs";
11
+ export { DEFAULT_TREE_SETTINGS, type TreeDoubleClickAction, type TreeSelectionMode, type TreeSettings, type TreeSortMode } from "./core/treeSettings.cjs";
12
+ export type { ContentAlignment, ExplorerViewSettings } from "./core/viewSettings.cjs";
@@ -0,0 +1,12 @@
1
+ export { type ExplorerFrameRenderer, MarkdownExplorer, type MarkdownExplorerProps } from "./client/MarkdownExplorer.js";
2
+ export { clearExplorerStorage } from "./client/storage.js";
3
+ export { DEFAULT_VIEW_SLUGS, defineExplorerConfig, EXPAND_ALL_DEPTH_LIMITS, EXPAND_ALL_FOLDER_LIMITS, type ExplorerConfig, type ExplorerConfigInput, type ExplorerDocumentStyle, type ExplorerLocationConfig, type ExplorerView, type ExplorerViewSlugs, isExplorerSourceId, MULTI_VIEW_COLUMN_LIMITS, MULTI_VIEW_PANEL_LIMITS, withExplorerSources, } from "./core/config.js";
4
+ export { EXPLORER_FAILURE_REASONS, EXPLORER_MAX_HEADINGS, type ExplorerChildrenResult, type ExplorerDocument, type ExplorerEntry, type ExplorerFailure, type ExplorerFailureDocument, type ExplorerFailureReason, type ExplorerHeading, type ExplorerMediaType, type ExplorerNotice, type ExplorerPageData, type ExplorerSeededDocument, type ExplorerSourceSummary, type ExplorerTreeResult, failureDocument, failureOf, isExplorerChildrenResult, isExplorerFailureCode, isExplorerFailureReason, } from "./core/contracts.js";
5
+ export { COLUMN_MIN_MEASURE, EXPLORER_DEFAULT_PERCENT, EXPLORER_MAX_PERCENT, EXPLORER_MIN_REM, EXPLORER_MULTI_DEFAULT_PERCENT, GOLDEN_RATIO } from "./core/geometry.js";
6
+ export { DEFAULT_MARKDOWN_EXPLORER_LOCALE, MARKDOWN_EXPLORER_LABEL_CATALOGS, MARKDOWN_EXPLORER_LABEL_KEYS, MARKDOWN_EXPLORER_LABEL_TEMPLATES, MARKDOWN_EXPLORER_LOCALES, type MarkdownExplorerLabelKey, type MarkdownExplorerLabelOverrides, type MarkdownExplorerLabels, type MarkdownExplorerLocale, resolveMarkdownExplorerLabels, } from "./core/labels.js";
7
+ export { type ExplorerEmbedOptions, type ExplorerHrefTarget, type ExplorerLocation, type ExplorerLocationResult, type ExplorerOverrides, type ExplorerSourcelessHrefTarget, explorerHref, resolveExplorerLocation, } from "./core/location.js";
8
+ export { DEFAULT_DENIED_PATH_SEGMENTS, type ExplorerPathRules, isAcceptableDocumentPath, isDeniedPath, MAX_DOCUMENT_PATH_LENGTH } from "./core/paths.js";
9
+ export { shouldRevalidateExplorer } from "./core/revalidation.js";
10
+ export { EXPLORER_THEMES, type ExplorerTheme } from "./core/theme.js";
11
+ export { DEFAULT_TREE_SETTINGS, type TreeDoubleClickAction, type TreeSelectionMode, type TreeSettings, type TreeSortMode } from "./core/treeSettings.js";
12
+ export type { ContentAlignment, ExplorerViewSettings } from "./core/viewSettings.js";
package/dist/index.js ADDED
@@ -0,0 +1,44 @@
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";
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";
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
+ export {
6
+ D as COLUMN_MIN_MEASURE,
7
+ G as DEFAULT_DENIED_PATH_SEGMENTS,
8
+ s as DEFAULT_MARKDOWN_EXPLORER_LOCALE,
9
+ P as DEFAULT_TREE_SETTINGS,
10
+ N as DEFAULT_VIEW_SLUGS,
11
+ I as EXPAND_ALL_DEPTH_LIMITS,
12
+ S as EXPAND_ALL_FOLDER_LIMITS,
13
+ i as EXPLORER_DEFAULT_PERCENT,
14
+ W as EXPLORER_FAILURE_REASONS,
15
+ m as EXPLORER_MAX_HEADINGS,
16
+ p as EXPLORER_MAX_PERCENT,
17
+ X as EXPLORER_MIN_REM,
18
+ x as EXPLORER_MULTI_DEFAULT_PERCENT,
19
+ _ as EXPLORER_THEMES,
20
+ t as GOLDEN_RATIO,
21
+ L as MARKDOWN_EXPLORER_LABEL_CATALOGS,
22
+ r as MARKDOWN_EXPLORER_LABEL_KEYS,
23
+ e as MARKDOWN_EXPLORER_LABEL_TEMPLATES,
24
+ R as MARKDOWN_EXPLORER_LOCALES,
25
+ H as MAX_DOCUMENT_PATH_LENGTH,
26
+ U as MULTI_VIEW_COLUMN_LIMITS,
27
+ C as MULTI_VIEW_PANEL_LIMITS,
28
+ o as MarkdownExplorer,
29
+ O as clearExplorerStorage,
30
+ f as defineExplorerConfig,
31
+ n as explorerHref,
32
+ K as failureDocument,
33
+ h as failureOf,
34
+ w as isAcceptableDocumentPath,
35
+ b as isDeniedPath,
36
+ k as isExplorerChildrenResult,
37
+ v as isExplorerFailureCode,
38
+ B as isExplorerFailureReason,
39
+ u as isExplorerSourceId,
40
+ F as resolveExplorerLocation,
41
+ A as resolveMarkdownExplorerLabels,
42
+ T as shouldRevalidateExplorer,
43
+ c as withExplorerSources
44
+ };