@aiquants/markdown-explorer 0.2.0 → 0.4.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 (60) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +69 -11
  3. package/dist/ExplorerSplit-rUVsf5i-.cjs +1 -0
  4. package/dist/ExplorerSplit-uX2ojZe8.js +1479 -0
  5. package/dist/MultiLayout-8s7q3-Hm.js +919 -0
  6. package/dist/MultiLayout-ZK2V9nms.cjs +1 -0
  7. package/dist/NativeScrollBar-D3VDRQqf.js +59 -0
  8. package/dist/NativeScrollBar-DqkutcGb.cjs +1 -0
  9. package/dist/{TreeLayout-BoyFelK2.js → TreeLayout-C7ZNnaOr.js} +3 -3
  10. package/dist/{TreeLayout-CLWbWjOc.cjs → TreeLayout-DkTVgxxb.cjs} +1 -1
  11. package/dist/core/config.d.cts +15 -2
  12. package/dist/core/config.d.ts +15 -2
  13. package/dist/core/contracts.d.cts +8 -0
  14. package/dist/core/contracts.d.ts +8 -0
  15. package/dist/core/labels.d.cts +5 -1
  16. package/dist/core/labels.d.ts +5 -1
  17. package/dist/core/treeSettings.d.cts +4 -2
  18. package/dist/core/treeSettings.d.ts +4 -2
  19. package/dist/dataRoute-DYjYBiXF.cjs +1 -0
  20. package/dist/{dataRoute-Bkfwfp1R.js → dataRoute-Dl6xmEFs.js} +59 -53
  21. package/dist/index-CLe6vRXs.cjs +3 -0
  22. package/dist/{index-BfuAu2GV.js → index-Dv9lUZqD.js} +530 -503
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.d.cts +2 -2
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +23 -22
  27. package/dist/location-2QZADLiv.cjs +1 -0
  28. package/dist/location-CaNtUswk.js +424 -0
  29. package/dist/sanitizeWorker.cjs +1 -1
  30. package/dist/sanitizeWorker.js +1 -1
  31. package/dist/scrollBarGeometry-C46jBtmM.cjs +1 -0
  32. package/dist/scrollBarGeometry-DOBdGNV-.js +4 -0
  33. package/dist/server/anonymous.d.cts +2 -2
  34. package/dist/server/anonymous.d.ts +2 -2
  35. package/dist/server/errors.d.cts +1 -1
  36. package/dist/server/errors.d.ts +1 -1
  37. package/dist/server/fileSystemSource.d.cts +1 -0
  38. package/dist/server/fileSystemSource.d.ts +1 -0
  39. package/dist/server/ports.d.cts +8 -1
  40. package/dist/server/ports.d.ts +8 -1
  41. package/dist/server.cjs +1 -1
  42. package/dist/server.d.cts +1 -1
  43. package/dist/server.d.ts +1 -1
  44. package/dist/server.js +763 -690
  45. package/dist/styles/markdown-explorer.css +1 -1
  46. package/dist/tapScrollCircle-C5DGI-0H.cjs +1 -0
  47. package/dist/tapScrollCircle-u4EXeLhx.js +6 -0
  48. package/docs/behavior/dom-hooks.md +3 -1
  49. package/docs/behavior/layout.md +2 -0
  50. package/docs/behavior/localization.md +1 -0
  51. package/docs/behavior/security.md +17 -3
  52. package/package.json +7 -7
  53. package/dist/ExplorerSplit-D2plJRRe.cjs +0 -1
  54. package/dist/ExplorerSplit-DB37U7Kh.js +0 -1362
  55. package/dist/MultiLayout-DCPDu1-l.js +0 -909
  56. package/dist/MultiLayout-UyWxs6Xy.cjs +0 -1
  57. package/dist/dataRoute-CKbdwkQ7.cjs +0 -1
  58. package/dist/index-Cx3-jSna.cjs +0 -3
  59. package/dist/location-Oo21lTyV.cjs +0 -1
  60. package/dist/location-fVl2R1ee.js +0 -395
@@ -0,0 +1,3 @@
1
+ "use strict";const c=require("react/jsx-runtime"),i=require("react"),U=require("react-router"),_=require("./location-2QZADLiv.cjs"),J=require("@aiquants/markdown"),F=require("./dataRoute-DYjYBiXF.cjs"),jt=require("@aiquants/markdown/viewer-settings"),W=require("./storage-Bkb2Axdi.cjs");function Nt(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=Nt(i),Se=Object.freeze(["en","ja"]),tt="en",nt=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"])}),Pt=/\{(\w+)\}/gu,rt={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",settingFolderPlacement:"Folders",folderPlacementMixed:"Mixed",folderPlacementFirst:"First",folderPlacementLast:"Last",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",settingRevealDocument:"Reveal the open document",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"},Dt={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:"名前の降順",settingFolderPlacement:"フォルダーの位置",folderPlacementMixed:"混ぜる",folderPlacementFirst:"先に",folderPlacementLast:"後に",settingSelectionMode:"選択",selectionSingle:"1 件",selectionMultiple:"複数",selectionNone:"オフ",settingDoubleClick:"ダブルクリック",doubleClickRecursive:"下の階層まで展開",doubleClickToggle:"開閉",settingExpandIconSize:"展開アイコンの大きさ",expandIconSizeValue:e=>`${String(e)} px`,settingAlwaysExpanded:"常に展開",settingRevealDocument:"開いた文書をツリーで表示",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:"ここへパネルをドロップ"},ot=Object.freeze({en:Object.freeze(rt),ja:Object.freeze(Dt)}),Oe=Object.freeze(Object.keys(rt)),$t=new Set(Oe),Ft=e=>$t.has(e),se=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,st=e=>{if(e===void 0)return tt;if(Se.includes(e))return e;throw new RangeError(`[markdown-explorer] locale is the UI language (${Se.map(t=>JSON.stringify(t)).join(" or ")}), not a BCP 47 tag; got ${se(e)}`)},ye=(e,t)=>{const n=ot[st(e)];if(t===void 0)return n;if(t===null||typeof t!="object")throw new RangeError(`[markdown-explorer] labels must be an object; got ${se(t)}`);if(!_.isPlainObject(t))throw new RangeError(`[markdown-explorer] labels must be a plain object; got ${se(t)}`);const r=t,o={...n};for(const s of Object.keys(r)){if(!Ft(s))throw new RangeError(`[markdown-explorer] labels.${s} is not a known label key; expected one of ${Oe.join(", ")}`);const a=r[s];if(a===void 0)continue;const d=typeof n[s];if(typeof a!==d)throw new TypeError(`[markdown-explorer] labels.${s} must be a ${d}; got ${se(a)}`);if(typeof a=="string"&&a.trim()==="")throw new RangeError(`[markdown-explorer] labels.${s} must be a non-blank string`);const m=nt[s];if(typeof a=="string"&&m!==void 0){for(const[,h]of a.matchAll(Pt))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]=a}return Object.freeze(o)},_t=(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(a=>Object.hasOwn(n,a)&&Object.is(n[a],r[a]))},Re=Object.freeze(["light","dark"]),qt=e=>{if(e===void 0)return"light";if(Re.includes(e))return e;throw new RangeError(`[markdown-explorer] theme must be ${Re.map(t=>JSON.stringify(t)).join(" or ")}; got ${typeof e=="string"?JSON.stringify(e):typeof e}`)},lt=i.createContext(null),D=()=>{const e=i.use(lt);if(e===null)throw new Error("[markdown-explorer] explorer components must be rendered inside <MarkdownExplorer>");return e},Q=e=>{const{viewSettings:t}=D(),n=()=>e(t.getSnapshot());return i.useSyncExternalStore(t.subscribe,n,n)},de=()=>{const{config:e}=D(),t=U.useParams()["*"],[n]=U.useSearchParams(),r=n.toString();return i.useMemo(()=>_.resolveExplorerLocation(e,t,new URLSearchParams(r)),[e,t,r])};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",{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 zt=R.forwardRef(Bt),Ce=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})}),Ht=e=>Ce[e],ue=()=>{const e=U.useNavigate();return i.useCallback((t,n)=>{e(t,Ce[n])},[e])},it=({navigation:e,...t})=>c.jsx(U.Link,{...t,...Ce[e]}),at={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"]},te=(e,t)=>e[at[t][0]],ct=({failure:e,alert:t,onRetry:n,testId:r})=>{const{labels:o}=D(),s=te(o,e.reason),a=o[at[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:s}),c.jsx("p",{className:"aqmx-callout-body",children:a}),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]})},Me=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},dt=(e,t)=>{const n=i.useRef(null),r=i.useRef(null),o=i.useRef(null),s=i.useCallback(()=>{n.current!==null&&window.clearTimeout(n.current),n.current=null,r.current=null},[]);i.useEffect(()=>s,[s]);const a=i.useCallback(h=>{if(r.current!==h)return;const g=o.current;if(g!==null){g.then(()=>a(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]),d=i.useCallback(h=>{const g=t(h);g!==r.current&&(s(),g!==null&&(r.current=g,n.current=window.setTimeout(()=>{n.current=null,a(g)},_.PREFETCH_DWELL_MS)))},[s,t,a]),m=i.useCallback(h=>{t(h)!==r.current&&s()},[s,t]);return i.useMemo(()=>({onPointerOver:h=>d(h.target),onPointerOut:h=>m(h.relatedTarget),onFocus:h=>d(h.target),onBlur:h=>m(h.relatedTarget)}),[d,m])},It=i.lazy(()=>Promise.resolve().then(()=>require("./NativeScrollBar-DqkutcGb.cjs")).then(e=>({default:e.NativeScrollBar})));class Ut extends i.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t){console.error("[markdown-explorer] a scroll bar failed to load or render; its scroller keeps its native scrolling without it.",t)}render(){return this.state.failed?null:this.props.children}}const ut=({scroller:e,withCircle:t})=>c.jsx(Ut,{children:c.jsx(i.Suspense,{fallback:null,children:c.jsx(It,{scroller:e,withCircle:t})})}),ft=e=>c.jsx(ut,{scroller:e,withCircle:!0}),ne=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),emit:()=>{for(const t of[...e])t()}}},mt=()=>{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 a=e.get(o);if(a!==void 0&&a>1){e.set(o,a-1);return}e.delete(o),r(o)}},isHeld:o=>e.has(o),resumes:o=>t.delete(o),heldKeys:()=>[...e.keys()]}},ie=(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,a)=>ie(s,t[a]));const n=e,r=t,o=Object.keys(n);return o.length!==Object.keys(r).length?!1:o.every(s=>Object.hasOwn(r,s)&&ie(n[s],r[s]))},ee=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},gt=e=>Object.assign(Promise.resolve(e),{status:"fulfilled",value:e}),re=e=>e.status==="fulfilled"?e.value:void 0,Zt=55e3,$e=Object.freeze({status:"deferred"}),Fe=Object.freeze({status:"refreshed"}),Ee=Object.freeze({status:"superseded"}),ae=e=>e===void 0||e.status==="deferred"?null:e.status==="loaded"?e:e.previous,pt=e=>e!==void 0&&e.status==="loaded"&&e.document.kind!=="failure",Vt=({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=mt(),o=ne(),s=new WeakSet;let a=0;const d=o.emit,m=()=>(a+=1,a),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>=Zt,x=(f,w,S)=>{const b=n.get(f),y=ae(b?.snapshot),P=S||b?.refreshPending===!0,I=ee(e.document(f,{refresh:P}).then(z=>({status:"loaded",document:z}))),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(z=>{n.get(f)===M&&(M.snapshot=z,M.stamp=m(),d())}),M},T=(f,w,S,b,y,P)=>{w.background===S&&(w.background=null,!(n.get(f)!==w||w.snapshot!==b)&&(y.kind==="failure"&&b.document.kind!=="failure"||(w.validatedAt=P,w.stamp=m(),ie(b.document,y)||(w.snapshot={status:"loaded",document:y}),d())))},k=async(f,w)=>{const S=w.snapshot;if(S.status!=="loaded")return null;const b={};w.background=b;const y=performance.now(),P=e.document(f,{refresh:w.refreshPending});w.refreshPending=!1;const I=await P,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),d())},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),d(),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),d()):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),d())},seed:(f,w)=>{const S=performance.now(),b=ee(w.then(z=>z===null?$e:{status:"loaded",document:z},()=>$e)),y=n.get(f);if(y!==void 0&&y.snapshot.status==="loaded"){const z=y.snapshot,j={};y.background=j,b.then(q=>{if(q.status==="loaded"){T(f,y,j,z,q.document,S);return}y.background===j&&(y.background=null)});return}const P=y!==void 0&&y.snapshot.status==="pending"?y.snapshot.previous:null,I={status:"pending",promise:b,previous:P},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(z=>{n.get(f)===M&&(z.status==="deferred"&&r.isHeld(f)?x(f,M.opened,!1):(M.snapshot=z,M.stamp=m()),d())})},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)&&d()})}f&&d()},refresh:async f=>{const w=n.get(f);if(w!==void 0&&pt(w.snapshot)){w.refreshPending=!0;const b=await k(f,w);return b===null?Ee:b.kind==="failure"?{status:"failed",failure:b.failure}:Fe}const S=x(f,!0,!0);return d(),S.snapshot.status!=="pending"?Ee:(await S.snapshot.promise,n.get(f)===S?Fe:Ee)},clear:()=>{n.clear();for(const f of r.heldKeys())x(f,!0,!1);d()},subscribe:o.subscribe,noteFailureShown:f=>s.has(f)?!1:(s.add(f),!0)}},ce=i.createContext("fill"),Gt=Object.freeze({blockSize:"100%"}),fe=({scrollerProps:e,children:t})=>i.use(ce)==="content"?c.jsx(J.HostedScrollArea,{scrollerProps:e,children:t}):c.jsx(J.HostedScrollArea,{scrollerProps:{...e,style:Gt},rowClassName:"aqmx-document-scroll-row",renderScrollBar:ft,children:t});function Wt({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 Kt=R.forwardRef(Wt);function Xt({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 Yt=R.forwardRef(Xt),me=({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(Yt,{})}),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(Kt,{})})]})};function Jt({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 Qt=R.forwardRef(Jt),en=Object.freeze({className:"aqmx-document-stage"}),tn=({document:e})=>{const{labels:t}=D();return c.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-file-view",children:[c.jsx(me,{name:e.name,url:e.url,icon:c.jsx(Qt,{})}),c.jsx(fe,{scrollerProps:en,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})]})})]})},je="[data-aqmd-scroll-container], [data-aqmx-document-scroller]",nn=e=>{const t=e.indexOf("#");return t===-1?"":e.slice(t)},rn=/(%[0-9A-Fa-f]{2})/u,Ne=e=>{if(!e.startsWith("#")||e.length===1)return null;const t=new TextEncoder,n=e.slice(1).split(rn).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))},ht=e=>`#${encodeURIComponent(e)}`,on=e=>{if(e==="#")return!0;const t=Ne(e);return t!==null&&t.replace(/[A-Z]/gu,n=>n.toLowerCase())==="top"},wt=(e,t)=>{if(t==="")return null;for(const n of e.querySelectorAll("[id]"))if(n.id===t)return n;return null},sn="http://www.w3.org/1999/xhtml",_e=(e,t)=>{if(t==="")return null;const n=wt(e,t);if(n!==null)return n;for(const r of e.querySelectorAll("a[name]"))if(r.localName==="a"&&r.namespaceURI===sn&&r.getAttribute("name")===t)return r;return null},vt=(e,t)=>{if(e===null||!t.startsWith("#"))return null;const n=_e(e,t.slice(1));if(n!==null)return n;const r=Ne(t);return r===null?null:_e(e,r)},qe=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"},ln=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"},an=(e,t)=>{const n=t.closest(je),r=n!==null&&e.contains(n)?n:e;if(r.scrollHeight>r.clientHeight&&qe(r))return r;const o=e.getBoundingClientRect().height,{documentElement:s,scrollingElement:a}=e.ownerDocument;for(let d=e.parentElement;d!==null&&d!==s;d=d.parentElement)if(qe(d)&&d.scrollHeight>d.clientHeight&&d.clientHeight<o)return d;return a instanceof Element&&ln(e.ownerDocument)&&a.scrollHeight>a.clientHeight&&a.clientHeight<o?a:r},cn=Object.freeze({scrollerOf:an,reveal:e=>{e.scrollIntoView(ke)}}),ke=Object.freeze({block:"nearest",inline:"nearest",behavior:"instant"}),dn=(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")}}},un=(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),a=t.getBoundingClientRect(),d=a.height+s+Number.parseFloat(o)>e.clientHeight;if(!d&&Math.abs(a.top-s-n)<1){t.scrollIntoView(ke);return}e.scrollBy({top:d?a.top-n-e.clientHeight:a.bottom-n+e.clientHeight,behavior:"instant"}),t.scrollIntoView(ke)},fn=(e,t)=>{const n=t.scrollerOf(e,e.querySelector(je)??e);n.getClientRects().length!==0&&(n.scrollTo({top:0,left:0,behavior:"instant"}),t.reveal(n))},Be=(e,t,n)=>{if(e===null)return null;const r=vt(e,t);return r===null?(on(t)&&fn(e,n),null):(dn(e,r),un(n.scrollerOf(e,r),r),n.reveal(r),r)};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.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 gn=R.forwardRef(mn);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",{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 hn=R.forwardRef(pn);function wn({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 vn=R.forwardRef(wn);function En({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 xn=R.forwardRef(En),Te="data-aqmx-key-repeat",Ae=Object.freeze({[Te]:"allow"}),bn=`[${Te}="${Ae[Te]}"]`,Sn=()=>{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(bn)!==null||(t.preventDefault(),t.stopPropagation())}},onKeyUpCapture:t=>{t.key==="Enter"&&(e=null)},onBlurCapture:t=>{t.target===e&&(e=null)}}},le=Object.freeze([1/_.GOLDEN_RATIO**2,1/_.GOLDEN_RATIO,1,_.GOLDEN_RATIO,_.GOLDEN_RATIO**2]),ze=Object.freeze({mode:"fit"}),yn=1,Rn=Object.freeze({className:"aqmx-document-canvas","data-testid":"markdown-explorer-image-canvas"}),Et=i.createContext(null),kn=(e,t)=>e.width>0&&e.height>0&&t.width-e.width<=yn?{base:e,scale:t.width/e.width}:t.width>0&&t.height>0?{base:t,scale:1}:null,He=(e,t,n)=>{if(e.mode==="level"){const o=e.index+n;return o>=0&&o<le.length?o:null}if(t===null||!Number.isFinite(t)||t<=0)return null;const r=n===1?le.findIndex(o=>o>t):le.findLastIndex(o=>o<t);return r===-1?null:r},Ie=(e,t,n)=>{if(e.mode==="level"){const o=He(e,null,n);return o===null?null:{mode:"level",index:o,base:e.base}}if(t===null)return null;const r=He(e,t.scale,n);return r===null?null:{mode:"level",index:r,base:t.base}},Tn=e=>{const t=le[e];if(t===void 0)throw new RangeError(`[markdown-explorer] no image zoom step ${String(e)}`);return t},Ue=(e,t,n)=>e!==null&&e.width===t&&e.height===n?e:{width:t,height:n},An=({document:e})=>{const{labels:t}=D(),n=i.use(Et),[r]=i.useState(()=>n===null?null:n.read(e.url)),[o,s]=i.useState(r===null?ze:r.zoom),[a,d]=i.useState(r===null?null:r.reported),[m,h]=i.useState(null),g=i.useRef(null),p=i.useCallback(O=>{const{naturalWidth:f,naturalHeight:w}=O;d(S=>Ue(S,f,w))},[]),x=i.useCallback(O=>{g.current=O,!(O===null||!O.complete)&&(O.naturalWidth>0||O.naturalHeight>0?p(O):O.decode().then(()=>p(O),()=>{}))},[p]);i.useEffect(()=>{n!==null&&a!==null&&n.save(e.url,{zoom:o,reported:a})},[n,e.url,o,a]),i.useLayoutEffect(()=>{const O=g.current;if(O===null||a===null||o.mode!=="fit")return;const f=()=>h(S=>Ue(S,O.clientWidth,O.clientHeight));if(f(),typeof ResizeObserver>"u")return;const w=new ResizeObserver(f);return w.observe(O),()=>w.disconnect()},[a,o.mode]);const T=a===null||m===null?null:kn(a,m),k=Ie(o,T,-1),L=Ie(o,T,1),A=o.mode==="level"?Tn(o.index):null,$=o.mode==="level"&&A!==null?{width:`${o.base.width*A}px`,height:`${o.base.height*A}px`}:void 0;return c.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-image-view",children:[c.jsxs(me,{name:e.name,url:e.url,icon:c.jsx(xn,{}),children:[c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomOut,title:t.imageZoomOut,"aria-disabled":k===null,onClick:()=>{k!==null&&s(k)},...Ae,children:c.jsx(hn,{})}),c.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))}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageZoomIn,title:t.imageZoomIn,"aria-disabled":L===null,onClick:()=>{L!==null&&s(L)},...Ae,children:c.jsx(vn,{})}),c.jsx("button",{type:"button",className:"aqmx-icon-button","aria-label":t.imageFit,title:t.imageFit,"aria-pressed":o.mode==="fit",onClick:()=>s(ze),children:c.jsx(gn,{})})]}),c.jsx(fe,{scrollerProps:Rn,children:c.jsx("img",{ref:x,className:"aqmx-document-image",src:e.url,alt:e.name,"data-aqmx-image-mode":o.mode,style:$,onLoad:O=>p(O.currentTarget),"data-testid":"markdown-explorer-image"})})]})},xt=i.createContext(null),ge=i.createContext(void 0),bt=i.createContext(null),pe=()=>{const e=i.use(xt);if(e===null)throw new Error("[markdown-explorer] document links must be rendered inside a document pane");return e},Ln=()=>{const e=i.use(bt);if(e===null)throw new Error("[markdown-explorer] table-of-contents entries must be rendered inside a document pane's links");return e},he=(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}),On=({children:e})=>{const{config:t}=D(),n=pe(),r=de(),o=r.kind==="location"?r.location.source:void 0,s=U.useHref(he(t,n.navigation,o,n.currentPath));return c.jsx(ge,{value:o,children:c.jsx(bt,{value:s,children:e})})},Cn='a[data-link-kind="doc"][data-doc-path]:not([data-doc-exists="false"])',Mn=e=>{const t=e instanceof Element?e.closest(Cn):null;return t===null?null:t.getAttribute("data-doc-path")},we=e=>!e.defaultPrevented&&e.button===0&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey,jn=({to:e,docPath:t,fragment:n,exists:r,className:o,attributes:s,onDocumentLink:a,scope:d,children:m})=>{const h=U.useHref(e),g=p=>{if(we(p)){if(p.preventDefault(),t===d.currentPath&&n!==""){d.scrollWithin(n);return}a(t,n)}};return c.jsx("a",{...s,href:h,className:o,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":r,onClick:g,children:m})},Nn=({href:e,docPath:t,docExists:n,className:r,attributes:o,children:s})=>{const{config:a}=D(),d=pe(),m=i.use(ge),h=nn(e),{navigation:g}=d,p=`${he(a,g,m,t)}${h}`,x=n===!1?"false":void 0;return g.kind==="page"?c.jsx(it,{...o,to:p,navigation:"follow-link",className:r,"data-link-kind":"doc","data-doc-path":t,"data-doc-exists":x,children:s}):c.jsx(jn,{to:p,docPath:t,fragment:h,exists:x,className:r,attributes:o,onDocumentLink:g.onDocumentLink,scope:d,children:s})},Pn=({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,")"]})]})},Dn=({href:e,className:t,attributes:n,scope:r,children:o})=>{const{config:s}=D(),a=i.use(ge),d=U.useHref(`${he(s,r.navigation,a,r.currentPath)}${e}`),m=h=>{we(h)&&(h.preventDefault(),r.scrollWithin(e))};return c.jsx("a",{...n,href:d,className:t,onClick:m,children:o})},$n=({href:e,className:t,attributes:n,children:r})=>{const o=pe();if(o.navigation.kind==="page"){const s=a=>{if(!we(a))return;const d=a.currentTarget;e==="#"?o.followEmptyFragment(a.nativeEvent):d.href===d.ownerDocument.URL&&o.followSameUrlJump(e,a.nativeEvent)};return c.jsx("a",{...n,href:e,className:t,onClick:s,children:r})}return c.jsx(Dn,{href:e,className:t,attributes:n,scope:o,children:r})},Fn=({href:e,kind:t,docPath:n,docExists:r,className:o,attributes:s,children:a})=>t==="doc"?n===void 0||!F.isAcceptableDocumentPath(n)?c.jsx(Pn,{className:o,attributes:s,children:a}):c.jsx(Nn,{href:e,docPath:n,docExists:r,className:o,attributes:s,children:a}):e.startsWith("#")?c.jsx($n,{href:e,className:o,attributes:s,children:a}):c.jsx("a",{...s,href:e,className:o,children:a}),_n=()=>{const{config:e}=D(),t=pe(),n=i.use(ge),r=ue();return i.useCallback((o,s)=>{if(!we(s))return!0;s.preventDefault();const a=ht(o.id),{navigation:d}=t;return d.kind==="panel"||Ne(s.currentTarget.ownerDocument.location.hash)===o.id?(t.scrollWithin(a),!0):(r(`${he(e,d,n,t.currentPath)}${a}`,"follow-link"),!0)},[e,t,n,r])},qn=()=>{const e=Ln();return i.useCallback(t=>`${e}${ht(t.id)}`,[e])};function Bn({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 zn=R.forwardRef(Bn);function Hn({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 In=R.forwardRef(Hn);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:"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 Zn=R.forwardRef(Un),Vn=Object.freeze({className:"aqmx-document-stage"}),Gn=e=>{switch(e){case"video":return c.jsx(In,{});case"audio":return c.jsx(Zn,{});case"pdf":return c.jsx(zn,{});default:{const t=e;throw new RangeError(`[markdown-explorer] unknown media type ${String(t)}`)}}},Wn=({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)}`)}}},Kn=({document:e})=>c.jsxs("div",{className:"aqmx-document-file","data-testid":"markdown-explorer-media-view","data-aqmx-media-type":e.mediaType,children:[c.jsx(me,{name:e.name,url:e.url,icon:Gn(e.mediaType)}),c.jsx(fe,{scrollerProps:Vn,children:c.jsx(Wn,{document:e})})]}),Xn=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}),St=(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},yt=(e,t)=>e!==void 0?e:t!==void 0?t:jt.DEFAULT_CONTENT_ALIGN,Yn=Object.freeze(["l1","l2","l3","l4","l5","l6","l7","l8"]),Jn=(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})},Pe=({kind:e,label:t,stale:n,busy:r,frameRef:o,intent:s,children:a})=>{const d=i.use(ce);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",...s,children:[n?c.jsx("div",{className:"aqmx-progress","aria-hidden":"true","data-testid":"markdown-explorer-document-progress"}):null,a]})},Qn=()=>{const{labels:e}=D();return c.jsx(Pe,{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})})})},Rt=({label:e})=>{const{labels:t}=D();return c.jsxs(Pe,{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:Yn.map(n=>c.jsx("span",{},n))}),c.jsx("p",{className:"aqmx-sr-only",children:t.documentLoading})]})},er=({path:e,document:t,viewer:n})=>{const{reportMathDiagnostics:r}=D(),o=i.useMemo(()=>({htmlContent:t.htmlContent,headings:[...t.headings]}),[t]),s=_n(),a=qn(),d=i.useMemo(()=>r===void 0?void 0:m=>r(e,m),[r,e]);return c.jsx("div",{className:"aqmx-document-viewer",children:c.jsx(J.MarkdownViewer,{...n,onHeadingSelect:s,headingHref:a,onMathDiagnostics:d,parseResult:o,content:null})})},tr=({document:e,viewer:t})=>{const{labels:n}=D();return c.jsxs(c.Fragment,{children:[c.jsx(me,{name:e.name,url:e.url,icon:c.jsx(zt,{})}),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(J.MarkdownViewer,{...t,parseResult:null,content:e.text})})]})},nr=Object.freeze({className:"aqmx-document-failure","data-aqmx-document-scroller":""}),rr=({path:e,document:t,viewer:n,onRetry:r})=>{switch(t.kind){case"markdown":return c.jsx(er,{path:e,document:t,viewer:n});case"text":return c.jsx(tr,{document:t,viewer:n});case"image":return c.jsx(An,{document:t});case"media":return c.jsx(Kn,{document:t});case"file":return c.jsx(tn,{document:t});case"failure":return c.jsx(fe,{scrollerProps:nr,children:c.jsx(ct,{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)}`)}}},or='a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), iframe, audio[controls], video[controls], [tabindex]:not([tabindex="-1"])',sr=(e,t,n)=>{const[r]=t.kind==="markdown"?t.headings:[],o=[n===null?null:vt(e,n),r===void 0?null:wt(e,r.id),e.querySelector(je),e.querySelector(or)];for(const s of o)if(s instanceof HTMLElement&&Me(s))return s;return null},Ze=(e,t,n)=>{const{activeElement:r,body:o}=e.ownerDocument,s=r===null||r===o;t instanceof HTMLElement&&n&&(s||e.contains(r))&&Me(t)},lr=e=>{const t=i.useRef(!1);return i.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,a;const d=x=>{s=!(x.target instanceof Node&&n.contains(x.target)),s&&!n.contains(r.activeElement)&&(t.current=!1),clearTimeout(a),a=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",d,!0),o.addEventListener("mousedown",d,!0),o.addEventListener("focusin",m,!0),o.addEventListener("blur",g),o.addEventListener("focus",p),n.addEventListener("focusout",h),()=>{clearTimeout(a),o.removeEventListener("pointerdown",d,!0),o.removeEventListener("mousedown",d,!0),o.removeEventListener("focusin",m,!0),o.removeEventListener("blur",g),o.removeEventListener("focus",p),n.removeEventListener("focusout",h)}},[e]),t},ir=({path:e,snapshot:t,stale:n,viewer:r,regionLabel:o,navigation:s,fragment:a,paneScroll:d,announces:m,announceFailure:h,onDocumentShown:g})=>{const{labels:p,announcer:x,documents:T}=D(),{document:k}=t,L=i.useRef(null),A=i.useRef(null),$=i.useRef(null),O=i.useRef(0),f=lr(L),w=i.useRef({path:e,document:k}),S=i.useRef(null),b=i.useCallback(l=>{const u=L.current,v=Be(u,l,d);u!==null&&v!==null&&Ze(u,v,f.current)},[d,f]),y=i.useCallback((l,u)=>{const v=O.current;setTimeout(()=>{!u.defaultPrevented&&O.current===v&&b(l)},0)},[b]),P=i.useCallback(l=>{setTimeout(()=>{l.defaultPrevented||b("#")},0)},[b]),I=i.useMemo(()=>({navigation:s,currentPath:e,scrollWithin:b,followSameUrlJump:y,followEmptyFragment:P}),[s,e,b,y,P]),M=i.useCallback(()=>T.retry(e),[T,e]),z=dt(T,Mn),j=i.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(F.lastPathSegment(l),te(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))});i.useEffect(()=>{j(e,t)},[e,t]);const q=i.useEffectEvent(()=>{a.kind==="panel"&&a.consume()}),K=i.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:sr(u,k,l)}),Y=i.useEffectEvent(l=>{const u=L.current;u!==null&&Ze(u,l,f.current)}),Z=i.useEffectEvent(l=>d.reveal(l)),ve=i.useEffectEvent(l=>Be(L.current,l,d));return i.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;a.kind==="page"?$.current!==a.navigation&&($.current=a.navigation,O.current+=1,E=a.fragment):a.fragment!==null&&(E=a.fragment,q());const C=()=>{const N=E===null?null:ve(E);if(!u){N!==null&&Y(N);return}const B=K(a.fragment);l&&N===null&&B!==null&&Z(B)};v?queueMicrotask(C):C()},[a,e,k,n]),c.jsx(Pe,{kind:k.kind,label:o(e,k),stale:n,busy:n,frameRef:L,intent:z,children:c.jsx(xt,{value:I,children:c.jsx(On,{children:c.jsx(rr,{path:e,document:k,viewer:r,onRetry:M},e)})})})},De=Object.freeze({kind:"skeleton"}),ar=(e,t,n,r,o)=>{if(t?.status==="loaded")return{kind:"document",path:e,snapshot:t,stale:!1};const s=ae(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 a=n===null||n===e?null:ae(r);return n===null||a===null?De:{kind:"document",path:n,snapshot:a,stale:!0}},cr=(e,t)=>t.status==="deferred"?De:{kind:"document",path:e,snapshot:t,stale:!1},dr=({requestedPath:e,content:t,...n})=>{const r=t.kind==="streaming"?cr(t.path,i.use(t.promise)):t;return r.kind!=="document"?c.jsx(Rt,{label:n.regionLabel(e,null)}):c.jsx(ir,{path:r.path,snapshot:r.snapshot,stale:r.stale,...n})},kt=({path:e,display:t,navigation:n,fragment:r,paneScroll:o,announces:s,announceFailure:a,onDocumentShown:d})=>{const{config:m,labels:h,theme:g,documents:p}=D(),x=J.useMarkdownToolbarState(),T=i.useRef(!1);i.useLayoutEffect(()=>{T.current=!0},[]);const[k,L]=i.useState(null),A=i.useCallback(()=>e===null?void 0:p.peek(e),[p,e]),$=i.useSyncExternalStore(p.subscribe,A,A),O=i.useCallback(()=>k===null?void 0:p.peek(k),[p,k]),f=i.useSyncExternalStore(p.subscribe,O,O);i.useLayoutEffect(()=>e===null?void 0:p.open(e),[p,e]),i.useLayoutEffect(()=>k===null?void 0:p.retain(k),[p,k]);const w=e===null?De:ar(e,$,k,f,!T.current),S=e===null?null:w.kind==="document"&&!w.stale?w.path:k;S!==k&&L(S);const b=i.useMemo(()=>Xn(h),[h]),y=i.useMemo(()=>[...m.iframeHosts],[m]),P=n.kind==="panel",I=i.useMemo(()=>({labels:b,emptyMessage:h.documentEmpty,theme:g,availableStyles:m.documentStyles,iFrameAllowedDomains:y,embeds:m.embeds,linkComponent:Fn,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%)`,renderScrollBar:P?void 0:ft}),[b,h.documentEmpty,g,m.documentStyles,y,m.embeds,x,t,P]),M=i.useCallback((j,q)=>P?q===null||q.kind==="failure"?F.lastPathSegment(j):q.name:h.documentRegion,[P,h.documentRegion]),z=P?"content":"fill";return e===null?c.jsx(ce,{value:z,children:c.jsx(Qn,{})}):c.jsx(ce,{value:z,children:c.jsx(i.Suspense,{fallback:c.jsx(Rt,{label:M(e,null)}),children:c.jsx(dr,{requestedPath:e,content:w,viewer:I,regionLabel:M,navigation:n,fragment:r,paneScroll:o,announces:s,announceFailure:a,onDocumentShown:d})})})},ur=({path:e,variant:t,onDocumentShown:n})=>{const{config:r,viewSettings:o,announcer:s}=D(),a=Q(y=>y.style),d=Q(y=>y.align),m=ue(),h=U.useLocation(),g=de(),{view:p,overrides:x,embed:T}=t,k=i.useCallback(y=>{if(g.kind!=="location")return;const P=Jn(r,g.location,y);P!==null&&m(P,"browse")},[r,m,g]),L=i.useCallback(y=>{o.update({style:y}),k("style")},[o,k]),A=i.useCallback(y=>{o.update({align:y}),k("align")},[o,k]),$=St(r,x.style,a),O=yt(x.align,d),f=i.useMemo(()=>({style:$,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}),[$,L,O,A,T]),w=i.useMemo(()=>({kind:"page",view:p,overrides:x,embed:T}),[p,x,T]),S=i.useMemo(()=>({kind:"page",fragment:h.hash,navigation:h}),[h]),b=i.useCallback(y=>s.announce(y),[s]);return c.jsx(kt,{path:e,display:f,navigation:w,fragment:S,paneScroll:cn,announces:!0,announceFailure:b,onDocumentShown:n})},fr=({path:e,variant:t,onDocumentShown:n})=>{const{config:r,viewSettings:o}=D(),s=Q(w=>w.style),a=Q(w=>w.align),[d,m]=i.useState(()=>St(r,void 0,s)),h=yt(void 0,a),g=i.useCallback(w=>o.update({align:w}),[o]),{maximized:p,onDocumentLink:x,pendingHash:T,onHashConsumed:k,announceFailure:L,paneScroll:A}=t,$=i.useMemo(()=>({style:d,onStyleChange:m,align:h,onAlignChange:g,showToc:p,showStyle:p,showAlign:p,padding:void 0,width:void 0,maxWidth:void 0}),[d,h,g,p]),O=i.useMemo(()=>({kind:"panel",onDocumentLink:x}),[x]),f=i.useMemo(()=>({kind:"panel",fragment:T,consume:k}),[T,k]);return c.jsx(kt,{path:e,display:$,navigation:O,fragment:f,paneScroll:A,announces:!1,announceFailure:L,onDocumentShown:n})},Tt=({path:e,variant:t,onDocumentShown:n})=>t.kind==="page"?c.jsx(ur,{path:e,variant:t,onDocumentShown:n}):c.jsx(fr,{path:e,variant:t,onDocumentShown:n});function mr({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 At=R.forwardRef(mr),gr=new Set,pr=(e,t)=>{const{documents:n,announcer:r,labels:o}=D(),s=i.useCallback(()=>n.peek(e),[n,e]),a=i.useCallback(()=>n.peekSeeded(e),[n,e]),d=i.useSyncExternalStore(n.subscribe,s,a),m=i.useCallback(()=>n.answerStampOf(e),[n,e]),h=i.useSyncExternalStore(n.subscribe,m,m),[g]=i.useState(()=>new Set),[p,x]=i.useState(gr),[T,k]=i.useState(null);T!==null&&T.path!==e&&k(null);const L=i.useRef(null);i.useLayoutEffect(()=>(L.current=e,()=>{L.current=null}),[e]);const A=i.useCallback(()=>{const f=e,w=n.peek(f);if(g.has(f)||w?.status==="pending")return;const S=t&&!pt(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(te(o,b.failure.reason)));return}const y=ae(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.has(e),O=T!==null&&T.path===e&&T.stamp===h?T.failure:null;return{refreshing:$,unavailable:$||d?.status==="pending",failure:O,refresh:A}},Lt=Object.freeze({kind:"page"}),hr=e=>{e.stopPropagation()},Ot=({path:e,placement:t})=>{const{labels:n}=D(),{refreshing:r,unavailable:o,failure:s,refresh:a}=pr(e,t.kind==="page"),d=t.kind==="panel"?n.refreshDocumentNamed(t.documentName):null;return c.jsxs("div",{className:"aqmx-document-refresh-bar","data-testid":"markdown-explorer-document-refresh-bar",children:[c.jsx("div",{className:"aqmx-document-refresh-row",children:c.jsxs("button",{type:"button",className:d===null?"aqmx-icon-button aqmx-labelled-button":"aqmx-icon-button",title:d===null?n.refreshDocument:d,"aria-label":d===null?void 0:d,"aria-disabled":o,"aria-busy":r,"data-aqmx-busy":r?"true":void 0,"data-testid":"markdown-explorer-document-refresh",onClick:a,onDoubleClick:hr,children:[c.jsx(At,{"aria-hidden":"true"}),d===null?c.jsx("span",{children:n.refreshDocumentLabel}):null]})}),s===null?null:c.jsx("p",{className:"aqmx-document-refresh-failure","data-testid":"markdown-explorer-document-refresh-failure","data-aqmx-failure":s.reason,children:n.documentRefreshFailed(te(n,s.reason))})]})},wr=({location:e})=>{const t=e.doc,n=i.useMemo(()=>({kind:"page",view:"single",overrides:e.overrides,embed:e.embed}),[e.overrides,e.embed]);return c.jsxs("div",{className:"aqmx-single aqmx-document-column","data-testid":"markdown-explorer-single",children:[c.jsx(Ot,{path:t,placement:Lt}),c.jsx(Tt,{path:t,variant:n})]})},Ct=({holds:e,testId:t})=>{const{labels:n,announcer:r}=D(),o=i.useId();i.useLayoutEffect(()=>e?r.claim(o):void 0,[e,r,o]);const s=i.useCallback(()=>r.shownIn(o),[r,o]),a=i.useSyncExternalStore(r.subscribe,s,s);return c.jsx("div",{className:"aqmx-sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":t,children:a.length>1?n.announcementSequence(a):a[0]})},X=Object.freeze([]),Ve=e=>{const t=new Set;let n=X,r=[],o=!1;const s=[],a=g=>{n=g;for(const p of[...t])p()},d=()=>s.at(-1)?.region,m=g=>{const p=d();g(),d()!==p&&n!==X&&a(X)},h=()=>{o=!1;const g=r.map(p=>"sentence"in p?p.sentence:p.list(p.items));r=[],a(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&&a(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=>d()===g?n:X}},Ge=Object.freeze({status:"cancelled"}),vr=e=>{if(e===null||typeof e!="object")return null;const{failure:t}=e;if(F.failureViolation(t)!==null)return null;const{reason:n,code:r}=t;return F.failureOf(n,r)},Er=({dataPath:e,onScope:t,fetch:n})=>{const r=n??((d,m)=>globalThis.fetch(d,m)),o=(d,m)=>`${e}/${d}?${new URLSearchParams(m).toString()}`,s=async(d,m,h,g)=>{let p;try{p=await r(d,{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(F.EXPLORER_SCOPE_HEADER);x!==null&&t(x);let T;try{T=await p.json()}catch{return g({reason:F.failureReasonOfStatus(p.status)})}let k;try{k=h(T)}catch{k=!1}if(k)return T;const L=vr(T);return g(L!==null?L:{reason:p.status===200?"failed":F.failureReasonOfStatus(p.status)})},a={[F.EXPLORER_REFRESH_HEADER]:F.EXPLORER_REFRESH_HEADER_VALUE};return{tree:d=>s(o("tree",{[F.EXPLORER_DATA_QUERY.source]:d}),{method:"GET"},F.isExplorerTreeResult,m=>({status:"error",failure:m})),children:async(d,m,h)=>{const g=await s(o("children",{[F.EXPLORER_DATA_QUERY.source]:d,[F.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:h},F.isExplorerChildrenResult,p=>({status:"error",failure:p}));return h.aborted?Ge:g},ancestors:async(d,m,h)=>{const g=await s(o("ancestors",{[F.EXPLORER_DATA_QUERY.source]:d,[F.EXPLORER_DATA_QUERY.path]:m}),{method:"GET",signal:h},F.isExplorerAncestorsResult,p=>({status:"error",failure:p}));return h.aborted?Ge:g},document:(d,{refresh:m})=>s(o("document",{[F.EXPLORER_DATA_QUERY.path]:d}),m?{method:"GET",headers:a}:{method:"GET"},F.isExplorerDocument,h=>F.failureDocument(h.reason,h.code)),refresh:d=>s(o("refresh",{[F.EXPLORER_DATA_QUERY.source]:d}),{method:"POST",headers:a},F.isExplorerTreeResult,m=>({status:"error",failure:m}))}},xr=e=>{const t=W.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}},We=(e,t)=>{let n=null;const r=()=>{if(n===null){const s=xr(e);n={changes:s,settings:_.applyTreeSettingChanges(t,s)}}return n},o=ne();return{storageKey:e,defaults:t,getSnapshot:()=>r().settings,getServerSnapshot:()=>t,subscribe:o.subscribe,advance:s=>{const{changes:a,settings:d}=r(),m=_.recordTreeSettingChange(a,s,_.advanceTreeSetting(d,s)[s],t);return n={changes:m,settings:_.applyTreeSettingChanges(t,m)},o.emit(),W.writeStorage(e,_.serializeTreeSettingChanges(m)),n.settings}}},br=Object.freeze({status:"refreshed"}),Sr=Object.freeze({status:"superseded"}),Le=Object.freeze({status:"deferred"}),yr=gt(Le),Mt=4,Rr=Mt-1,Ke=Object.freeze({status:"loading"}),kr=Object.freeze({status:"error",failure:Object.freeze({reason:"failed"})}),Tr=e=>{const t=new Map,n=mt(),r=new Map,o=new Map,s=new Map,a=new Map,d=ne(),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,d.emit()},A=l=>o.get(l)??0,$=l=>{let u=a.get(l);return u===void 0&&(u={claims:new Map,unclaimed:new Set,direct:new Set,bulk:new Set,inFlight:new Map},a.set(l,u)),u},O=(l,u,v)=>{l.inFlight.delete(u),h-=1,v.lane==="bulk"&&(g-=1)},f=l=>{const u=a.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=re(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=[...a.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],B=N===void 0?void 0:a.get(N);if(!(N===void 0||B===void 0)){for(const H of B[l])if((B.claims.get(H)??0)!==0)return B[l].delete(H),p[l]=N,{sourceId:N,path:H}}}return null},P=(l,u,v,E)=>{const C=a.get(l);if(C===void 0||C.inFlight.get(u)!==v)return;O(C,u,v);const N=(C.claims.get(u)??0)>0,B=b(l);if(E.status==="ok"?B.set(u,{status:"loaded",entries:E.entries}):E.status==="error"&&N?B.set(u,{status:"failed",failure:E.failure}):B.delete(u),L(),E.status==="error"&&N){const H={sourceId:l,path:u,failure:E.failure};for(const V of[...m])V(H)}M()},I=(l,u,v)=>{const E={controller:new AbortController,lane:v};$(l).inFlight.set(u,E),h+=1,v==="bulk"&&(g+=1),e.children(l,u,E.controller.signal).then(C=>P(l,u,E,C),()=>P(l,u,E,kr))},M=()=>{for(;h<Mt;){const l=y("direct");if(l!==null){I(l.sourceId,l.path,"direct");continue}const u=g<Rr?y("bulk"):null;if(u===null)return;I(u.sourceId,u.path,"bulk")}},z=(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=$(u);for(const E of v.unclaimed)(v.claims.get(E)??0)===0&&z(u,v,E)&&(l=!0);v.unclaimed.clear()}x.clear(),l&&(L(),M())},q=(l,u)=>{t.set(l,S(ee(e.tree(l)),u))},K=(l,u,v)=>{w(l);const E=S(gt(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=re(u.promise);if(!(E.status!=="ok"||C?.status!=="ok"||u.loadedAt===null||E.loadedAt<=u.loadedAt)){if(ie(C.entries,E.entries)){u.loadedAt=E.loadedAt;return}K(l,E,u.opened)}},Z=(l,u)=>{const v=t.get(l);return v!==void 0&&re(v.promise)?.status===u},ve=(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??yr,open:l=>{const u=n.resumes(l),v=n.hold(l),E=t.get(l);return E===void 0||Z(l,"deferred")?(q(l,!0),L()):u||(E.opened&&Z(l,"error")?(q(l,!0),L()):(E.opened=!0,E.stale&&Z(l,"ok")&&ve(l,E))),v},retry:l=>{Z(l,"error")&&(q(l,!0),L())},seed:(l,u)=>{const v=u.then(N=>N===null?Le:N,()=>Le),E=t.get(l);if(E!==void 0&&Z(l,"ok")){const N=A(l);v.then(B=>Y(l,E,N,B));return}w(l);const C=S(ee(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)&&q(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 Sr;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=K(l,v,!0);if(E!==void 0&&E.promise.status==="pending"){const B=A(l);E.promise.then(H=>Y(l,N,B,H))}}for(const[N,B]of t)N!==l&&re(B.promise)?.status==="ok"&&(B.stale=!0);return br},children:(l,u)=>r.get(l)?.get(u),claimChildren:(l,u)=>{const v=$(l),E=b(l);let C=!1,N=!1;for(const[H,V]of u)v.claims.set(H,(v.claims.get(H)??0)+1),E.get(H)===void 0?(E.set(H,Ke),v[V].add(H),C=!0,N=!0):V==="direct"&&v.bulk.delete(H)&&(v.direct.add(H),N=!0);C&&L(),N&&M();let B=!1;return()=>{if(!B){B=!0;for(const H of u.keys()){const V=(v.claims.get(H)??0)-1;V>0?v.claims.set(H,V):(v.claims.delete(H),v.unclaimed.add(H))}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=$(l);if((E.claims.get(u)??0)>0){v.set(u,Ke),E.direct.add(u),L(),M();return}v.delete(u),L()},pendingChildren:l=>{const u=a.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(),...a.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:d.subscribe,version:()=>k}},Ar=(e,t)=>{let n=e;const r=ne();return{getSnapshot:()=>n,subscribe:r.subscribe,update:o=>{n={...n,...o},t(n),r.emit()}}},Lr=1;let oe=0,G=null;const Or=()=>{const{documentElement:e,body:t}=document;oe===0&&(G={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"),oe+=1;let n=!1;return()=>{n||(n=!0,oe-=1,!(oe>0||G===null)&&(e.style.overflow=G.htmlOverflow,t.style.overflow=G.bodyOverflow,e.style.scrollbarGutter=G.htmlGutter,t.style.scrollbarGutter=G.bodyGutter,G=null))}},Cr=[{selector:'[data-aqmx-document-flow="fill"]',name:"document region"},{selector:"[data-aqmx-explorer-body]",name:"tree area"}],Xe=1,Ye=e=>e.getClientRects().length>0,xe="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.",Mr=e=>{if(!Ye(e))return null;const t=e.getBoundingClientRect(),n=window.innerHeight;if(t.bottom>n+Lr)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. ${xe}`;if(t.height<Xe)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. ${xe}`;for(const{selector:r,name:o}of Cr)for(const s of e.querySelectorAll(r)){if(!Ye(s))continue;const a=s.getBoundingClientRect().height;if(a<Xe)return`[markdown-explorer] the explorer's ${o} collapsed to ${String(Math.round(a))}px while lockDocumentScroll stops the page from scrolling, so it cannot be read. ${xe}`}return null},jr=e=>{let t=!1;const n=()=>{if(t)return;const o=Mr(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)}},Nr=(e,t)=>{i.useEffect(()=>e?Or():void 0,[e]),i.useEffect(()=>{const n=t.current;if(!(!e||n===null))return jr(n)},[e,t])},Je='[data-testid="markdown-explorer-view-switch"]',Pr=[{control:Je,successors:[Je,'[data-testid="markdown-explorer-sheet-toggle"]']},{control:'[data-testid="markdown-explorer-selection-open"]',successors:['[data-testid="markdown-explorer-panel-frame"]']}],Dr=e=>{for(const t of Pr){const n=e.closest(t.control);if(n!==null)return{element:n,control:t}}return null},$r=(e,t)=>{const n=i.useRef(null);i.useEffect(()=>{const o=d=>{const m=e.current;n.current=m!==null&&d instanceof Element&&m.contains(d)?Dr(d):null},s=d=>o(d.target);o(document.activeElement);const a=d=>{const m=d.target;d.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",a),()=>{document.removeEventListener("focusin",s),document.removeEventListener("focusout",a)}},[e]);const r=i.useRef(t);i.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 a=e.current;if(a===null)return;const d=new MutationObserver(()=>{s()&&d.disconnect()});return d.observe(a,{childList:!0,subtree:!0}),()=>d.disconnect()},[t,e])},Fr=i.lazy(()=>Promise.resolve().then(()=>require("./TreeLayout-DkTVgxxb.cjs")).then(e=>({default:e.TreeLayout}))),_r=i.lazy(()=>Promise.resolve().then(()=>require("./MultiLayout-ZK2V9nms.cjs")).then(e=>({default:e.MultiLayout}))),qr=64,Qe={request:e=>{requestAnimationFrame(e)}},et=e=>{e.documents.clear(),e.trees.clear()},be=(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]=i.useState(()=>({overrides:t,locale:e,labels:ye(e,t)}));if(n.locale===e&&_t(n.overrides,t))return n.labels;const o={overrides:t,locale:e,labels:ye(e,t)};return r(o),o.labels},zr=(e,t,n)=>{const[r,o]=i.useState(()=>({scope:t,store:We(e,n)}));if(r.scope===t&&r.store.storageKey===e&&r.store.defaults===n)return r.store;const s={scope:t,store:We(e,n)};return o(s),s.store},Hr=e=>{const[t,n]=i.useState(()=>({scope:e,announcer:Ve(Qe)}));if(t.scope===e)return t.announcer;const r={scope:e,announcer:Ve(Qe)};return n(r),r.announcer},Ir=({data:e,config:t,storageNamespace:n,locale:r,labels:o,theme:s,renderFrame:a,renderTreeFailure:d,lockDocumentScroll:m=!1,onMathDiagnostics:h})=>{W.assertStorageNamespace(n);const g=st(r),p=qt(s),x=Br(g,o),{revalidate:T}=U.useRevalidator(),k=i.useRef(()=>{}),L=U.useHref(t.dataPath),[A]=i.useState(()=>{const j=Er({dataPath:L,onScope:K=>k.current(K)}),q={documents:Vt({client:j,capacity:Math.max(qr,t.multiView.maxPanels*2)}),trees:Tr(j)};return be(q,e),W.syncStorageScope(n,e.scope),{data:j,...q,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:be(A,e)),W.syncStorageScope(n,e.scope)}const $=zr(W.storageKeys(n).treeSettings,e.scope,t.defaultTreeSettings);i.useLayoutEffect(()=>{const j=A.aligned.pendingReader;j!==null&&(A.aligned.pendingReader=null,et(A),be(A,j))},[e,A]),i.useLayoutEffect(()=>{let j=!1;return k.current=q=>{q===e.scope||j||(j=!0,q!==null&&(et(A),W.clearExplorerStorage(n)),T())},()=>{k.current=()=>{}}},[e,T,A,n]);const O=i.useRef(t.settingsCookie);i.useLayoutEffect(()=>{O.current=t.settingsCookie},[t.settingsCookie]);const[f]=i.useState(()=>Ar(e.settings,j=>{document.cookie=_.viewSettingsCookieString(O.current,j,window.location.protocol==="https:")})),w=Hr(e.scope),S=i.useMemo(()=>ee(e.notices.catch(()=>[])),[e.notices]),b=e.sources.map(j=>j.id).join(`
2
+ `),y=i.useMemo(()=>_.withExplorerSources(t,b.split(`
3
+ `)),[t,b]),P=i.useRef(h);i.useLayoutEffect(()=>{P.current=h},[h]);const[I]=i.useState(()=>(j,q)=>{P.current?.(j,q)}),M=h===void 0?void 0:I,z=i.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:$,announcer:w,renderTreeFailure:d,reportMathDiagnostics:M}),[y,x,g,p,n,e.scope,e.sources,S,A,f,$,w,d,M]);return c.jsx(lt,{value:z,children:c.jsx(Zr,{renderFrame:a,lockDocumentScroll:m},e.scope)})},Ur=({ref:e,theme:t,view:n,children:r})=>{const[o]=i.useState(Sn);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})},Zr=({renderFrame:e,lockDocumentScroll:t})=>{const{theme:n,labels:r}=D(),o=de(),{hash:s}=U.useLocation(),a=ue(),d=i.useRef(null);Nr(t,d),i.useLayoutEffect(()=>{o.kind==="redirect"&&a(`${o.href}${s}`,"browse")},[o,s,a]);const{location:m}=o,h=m.view;$r(d,h);const g=m.view==="tree"?c.jsx(i.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(Fr,{location:m})}):m.view==="multi"?c.jsx(i.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(_r,{location:m})}):c.jsx(wr,{location:m}),p=c.jsxs(Ur,{ref:d,theme:n,view:h,children:[g,c.jsx(Ct,{holds:!0,testId:"markdown-explorer-announcer"})]});return e===void 0?p:e({view:h,children:p})},Vr=({currentUrl:e,nextUrl:t,formMethod:n,defaultShouldRevalidate:r})=>n===void 0&&e.href===t.href&&r;exports.DEFAULT_MARKDOWN_EXPLORER_LOCALE=tt;exports.DocumentPane=Tt;exports.DocumentRefreshBar=Ot;exports.EXPLORER_THEMES=Re;exports.ExplorerLink=it;exports.FailureView=ct;exports.ForwardRef=At;exports.ImageViewMemoryContext=Et;exports.LazyNativeScrollBar=ut;exports.LiveRegion=Ct;exports.MARKDOWN_EXPLORER_LABEL_CATALOGS=ot;exports.MARKDOWN_EXPLORER_LABEL_KEYS=Oe;exports.MARKDOWN_EXPLORER_LABEL_TEMPLATES=nt;exports.MARKDOWN_EXPLORER_LOCALES=Se;exports.MarkdownExplorer=Ir;exports.PAGE_DOCUMENT_REFRESH=Lt;exports.createEmitter=ne;exports.explorerNavigationOptions=Ht;exports.failureTitleOf=te;exports.focusWithoutScroll=Me;exports.resolveMarkdownExplorerLabels=ye;exports.shouldRevalidateExplorer=Vr;exports.useExplorer=D;exports.useExplorerLocation=de;exports.useExplorerNavigate=ue;exports.useIntentPrefetch=dt;exports.useViewSetting=Q;